import { JobResult, JobSpec, RunHooks, RunnerOptions } from "./types.js"; /** Per-job limit defaults, used when JobSpec.limits omits a value. */ export declare const LIMIT_DEFAULTS: { cpus: number; memoryMb: number; timeoutMs: number; pidsMax: number; tmpfsMb: number; }; /** * Payload-opaque job executor over rootless podman + gVisor. * Owns sandboxing, limits, mounts, and the egress policy. Knows nothing about * integrations, queues, or destinations; those live in the server. */ export declare class Runner { /** Resolved options with defaults applied */ private opts; /** Serializes network preparation, so concurrent jobs never race to recreate the keeper */ private networkLock; /** Creates a runner; unspecified options fall back to DEFAULTS. */ constructor(options?: RunnerOptions); /** * Verifies the stack and prepares network, keeper, and egress rules. Also * removes meters whose job container is gone (left by a crashed process). * Idempotent, and safe while other processes run jobs on the same network. */ ensureReady(): Promise; /** Brings up network, keeper and rules; sweepMeters also removes meters of vanished jobs. */ private prepareStack; /** * Re-verifies the job network before a launch: restarts the keeper (or * rebuilds it) and re-applies the egress rules. A keeper that died while * idle takes the netns and its drop rules with it, and the next job would * otherwise get a fresh netns with open egress. */ private prepareNetwork; /** Runs network changes one at a time across this runner's concurrent jobs. */ private withNetworkLock; /** Brings the netns to its required state: bridge MAC pinned, egress policy and meter applied. */ private ensureNetworkState; /** * Pins the job bridge's MAC address to its current value. A Linux bridge * without an assigned MAC takes the lowest MAC among its ports, so it changes * as job containers join and leave, and running containers keep sending to * the old gateway MAC until their neighbour entry expires: their network * goes dark for seconds at a time, often for a whole job. netavark 1.4 * (Ubuntu 24.04) leaves the MAC unassigned; assigning it, even unchanged, * stops it following the ports. */ private pinBridgeMac; /** * Applies the egress policy and the traffic meter table when configured. The * meter table is created once per netns, since re-creating it would drop * running jobs' meters. */ private ensureEgress; /** Removes meters whose job container no longer exists. Failures leave them for the next sweep. */ private sweepMeters; /** * Meters a starting job's traffic, with an optional quota. Waits for the * container's address on the job network, then routes it to a fresh counter. */ private attachMeter; /** Bytes counted so far by a job's meter. */ private meterBytes; /** Removes a finished job's meter, returning its byte count. */ private detachMeter; /** Chain the meter map currently routes an address to, or null when it has no element. */ private meterElementTarget; /** Meter map elements: job container address to the chain it routes to. */ private meterElements; /** Removes the keeper container and job network. */ teardown(): Promise; /** * Runs a single job to completion. The payload goes to stdin; stdout is the * result channel; stderr streams to hooks and is kept as a capped tail. */ run(spec: JobSpec, hooks?: RunHooks): Promise; /** * Kills every job container carrying the label, or the label with the given * value. Called at startup to remove containers a previous process left * running, since a job whose owner is gone can only ever commit twice. * Returns the number of containers removed. */ killLabelled(key: string, value?: string): Promise; /** Applies the egress ruleset inside the rootless infra netns. Idempotent. */ private applyEgressRules; /** * Removes a job container that must not run, once podman has created it. The job cannot * have started: its payload is never written. Killing the podman client instead would * leave conmon and the sandbox running with no record of them. */ private removeBeforeStart; /** Applies an nft script inside the rootless infra netns, atomically. */ private nftScript; /** Runs a podman command, returning trimmed stdout; throws on nonzero exit. */ private podman; /** Runs a podman command, returning whether it exited zero. */ private podmanOk; } /** Ceilings applied to a job's systemd scope. */ interface ScopeLimits { /** MemoryMax in MB; swap is disabled */ memoryMb: number; /** CPU cores, as CPUQuota */ cpus: number; /** TasksMax */ tasksMax: number; } /** * The cgroup of podman's own scope (`podman-.scope`) when podman's current cgroup is that * scope or inside it, else null. With --cgroups=split podman moves itself into the scope and, * tens of milliseconds later, into a `runtime` child of it, so a poll can see either. Exported * for tests. */ export declare function podmanScopeCgroup(cgroup: string, pid: number): string | null; /** * Compares a scope's cgroup v2 limit files with the limits requested; returns what differs, * or null when every limit is in effect. Exported for tests. */ export declare function scopeLimitsProblem(cgroupDir: string, limits: ScopeLimits): Promise; /** Parses the stdout of a succeeded job as the harness result JSON. */ export declare function parseJobOutput(result: JobResult): T; export {};