Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/heimdall

docs/v2/one-shot-job.md

The one-shot function job (B3): API proposal

Heimdall is a defensive sandbox. PROPOSAL of 2026-11-13 (lane f-lane), ACCEPTED the same day by heimdal and by Holger h40, and revised once with Holger's answers. It answers Holger h40's requests of 10:41Z and 13:12Z (its slices S-b and S-e). Base: c-lane/a5 9925ce0 (heimdall-core 0.5.1, heimdall-container 0.5.6). The code follows section h, step by step. Steps 1 to 4 were built on that base and merged on top of 0.6.0: they are released as heimdall-core 0.6.1 and heimdall-container 0.7.0 ("Function jobs" in ../API.md). The two bounds in time, the caller's stop (section d) and the proof that the fixed profile is installed are heimdall-core 0.7.0 and heimdall-container 0.8.0.

A one-shot function job starts ONE function of the caller's program in its own youki container, with no OCI image: files and arguments in, files out, a signed answer, and then the container is gone. It is not a second runner. It is the function service's container (F1, start_function) with the image job's way in, way out, limits and refusal codes.

Order of need (Holger): 1. the application build (fetch, build, graph extract); 2. the per-check jobs, check-license first; 3. holger judge, last. Section h builds in that order. The first version builds pure-Rust applications; applications with C are the second slice (its own section below).

What is reused, what is new

Need Reused as it is New
Container the function service's: Starter pinned by sha256, the copy that CALLS the function, the namespaces, the empty network namespace, no capabilities, no-new-privs, Landlock, the fixed profile and the generated one on top nothing
Files in the image job's /in (read-only), the function service's read binds (BindRo) nothing
Files out the image job's /out (write-only), the output scan, the caps, check_outputs nothing
Limits Limits, the shim's wall clock, the refusal codes the wall clock on a function container
Work place Policy::workspace (/work, capped, deleted) allowed for a function job
Network Policy::net, the broker's injected socket and its checked connect, the events allowed for a function job, ONE peer
Signature the per-boot key, SignedStart, SignedResult the two as a pair, bound by the nonce
Profile Policy::seccomp (SeccompProfileRef, pinned by sha256) required; an index per starter
FunctionJob, JobRunner::run_function, starter::run_if_job, the tools tree, heimdall run --job function

a. In, out and the signature

Arguments args: the function's &[String]; signed (the start record's argv)
Input files input_dir at /in, read-only. A large shared file (the advisories dump) is a read bind, not a copy
A tree in /in CONFIRMED: /in may be a directory TREE of some thousands of files (a cargo local registry beside source.tar). The whole input_dir is bound (rbind, read-only) and one Landlock rule covers all beneath it; nothing counts, scans or hashes it, so no cap meets it. The one number near it is Limits::nofile (1024 unless the job says more): files open AT ONCE, not files there. A read bind may be a tree too
Output regular files the function writes into /out, within max_output_files, max_output_file_bytes and max_output_total_bytes (the caller sets 2 GiB). stdout and stderr are /dev/null: a log is a file in /out
Two verdicts The function's own verdict is a FILE (verdict.json). Heimdall's Verdict says how the RUN went: Accepted = the function returned 0 and its outputs passed the scan
What signs the runner's per-boot Ed25519 key, as for every job. The caller pins it (runner.pinned())
Record What the signature covers
SignedStart (wire as today) name = the function's name; image_digest = starter:sha256:<hex> (starter_record_digest: the starter's bytes, checked at this start); argv = the args; profile_digest; features as reported from inside; start_id = the job's nonce
SignedResult (wire v2 as today) job id, nonce, Verdict, each output's name, sha256 and length, exit, the times, runner (Generated { profile_digest }), the events (each connect), the kernel report

b. Network

Declared policy.net = Some(NetAllow::one(host, addr, port)). The caller resolves host; Heimdall resolves nothing
ONE a function job with two peers is InvalidJob. "The repository plus the git host" would be two jobs. In Holger's first use only app-fetch has a peer: the account's process writes a cargo local registry, and the build is offline with policy.net = None
A proxy the one peer may be an HTTP CONNECT proxy, with git getting https_proxy through env. The events then name the PROXY's address, never the git host behind it
NONE policy.net = None, the default: the empty network namespace, and Landlock refuses every TCP connect and bind
Enforced as a fetch job today: the job's namespace stays empty; the broker makes the TCP socket in the runner's namespace, injects it, and does the connect itself, only to the declared addr:port. Every other socket, connect, bind or listen is EACCES and an event. No broker in full mode: Unsupported before anything runs
The function learns it HEIMDALL_NET_PEERS, as today
By name NEW and small: the job's /etc/hosts holds the one line addr host, so git reaches the peer by its name with no resolver (cargo too, in a build that has a peer)
The caller sees each connect in result.events (addr=<ip:port>, result=ok or the errno, or the refusal). A job with no network has no connect event

As built in step 4 (heimdall-container 0.7.0), decided there:

c. The tools tree and the work place

Tools tree Work place
Declared tools: Some(<host dir>); refused unless the dir is in HeimdallConfig::tool_trees policy.workspace = Some(Workspace { bytes, exec })
Inside the tree's top-level entries, read-only, in the job's root, as an image's are (rustup's cargo finds its loader there). The view is then an image job's (/proc read) /work, read and write: a host folder above 1 GiB
Execute Landlock read and execute on the tree; the image job's fixed profile (it has execve) only with exec: true and HeimdallConfig::allow_workspace_exec (cargo runs build scripts and loads proc macros from its target dir)
Without it an EMPTY root, execute NOWHERE, the function service's fixed profile (no execve): the check jobs and judge no writable place but /out
After the job untouched deleted, whatever the end

As built in step 3 (heimdall-container 0.7.0), decided there:

d. Limits

Limits { wall: 1 h, memory_bytes: 8 GiB, pids: 4096, cpus, max_output_file_bytes: 2 GiB, max_output_total_bytes: 2 GiB, ..Default::default() }

Limit Enforced by At the limit The caller sees (a SIGNED refusal) Outputs written so far
wall, 1 h (0: no wall clock, only with a CPU bound) the shim: SIGKILL to the whole container all of it dies heimdall-limit-wall, exit.killed = Wall stay listed
CPU time, cpu_time (none unless set) the shim reads the CPU time of the job's cgroup every 50 ms: SIGKILL to the whole container all of it dies heimdall-limit-cpu, exit.killed = Cpu stay listed
a stop by the caller, JobStop::stop the runner: cgroup.kill of the job's cgroup all of it dies, at once heimdall-stopped, exit.killed = Stopped stay listed
memory, 8 GiB cgroup v2 memory.max, swap 0, memory.oom.group the OOM kill takes every process of the job heimdall-limit-memory, exit.killed = Memory stay listed
pids, 4096 cgroup v2 pids.max a fork fails inside; the job is not killed heimdall-limit-pids, whatever its exit stay listed
work place, bytes the shim measures the folder every 200 ms SIGKILL heimdall-limit-workspace, exit.killed = Workspace stay listed
a call outside the profile by the function itself the generated profile, KILL_PROCESS SIGSYS to the function: the job ends heimdall-seccomp-1, naming the profile's digest stay listed
a call outside the profile by a program the function started the same profile (a started program inherits it), KILL_PROCESS SIGSYS to that program and nothing else; the call never runs, and the function sees its child end by signal 31 no code of its own: the function's own end decides (heimdall-exit-1 when it returns non-zero, Accepted when it goes on and returns 0) stay listed
the function returns non-zero, or panics (101) heimdall-exit-1 stay listed
one file over RLIMIT_FSIZE the kernel SIGXFSZ heimdall-exit-2, naming the size limit stay listed
output, 2 GiB (a file, or the sum), or an extra in /out the output scan the scan refuses the directory heimdall-out-2, heimdall-out-1 LOST: the list is empty and /out is emptied

Every row is Ok(outcome) with a signed verdict: a Refused, but for a started program's call outside the profile, where the function's own end decides. Accepted therefore does not say that no started program tried such a call; a function that must fail in that case checks the status of every program it starts (ended by signal 31) and returns non-zero. Err(RunError) means nothing ran or nothing can be trusted (a bad job, a changed starter, no profile, a failed set-up, a stop by the caller before the function's first instruction): nothing is signed. Page cache of writes into a host-folder work place counts against memory_bytes.

The log after a refusal. This is the image job's code today (heimdall-container lib.rs: the scan runs after every end, and outputs is its list whatever the code), and the function job keeps it. So build.log stays listed after heimdall-seccomp-1, heimdall-limit-memory, heimdall-limit-workspace and heimdall-limit-pids, as after limit-wall and exit-1. Only the scan's own refusals lose it, and a limit code whose scan also refuses. The smallest change that keeps a log there is none in Heimdall, and two rules for the function: it makes its large output in /work and copies it into /out only when it is within the cap (else it says so in the log and returns non-zero: heimdall-exit-1), and it writes the log line by line (a kill loses what a process still holds in a buffer).

The two bounds in time, and the caller's stop (heimdall-core 0.7.0)

A function job has a wall clock, a CPU bound, or both. A job with neither is InvalidJob.

A stop by the caller. The caller makes a JobStop before the run, keeps a clone of it, and passes it to run_function_stoppable. stop() may be called from any thread, at any time and any number of times; it returns at once and cannot fail. What it does depends on where the job is:

stop() is called What happens The caller gets
before the starter is started (also before run_function_stoppable is called) nothing is started Err(RunError::Stopped): nothing ran, nothing is signed
after that, before the function's first instruction (the container is being made; nothing is confirmed from inside yet) every process of the job is killed Err(RunError::Stopped): the function did not run, and there is no start to sign
while the function runs every process of the job is killed at once: cgroup.kill of the job's cgroup, the end a service's stop comes to after its grace. A job gets no SIGTERM and no grace Ok(outcome): both records signed, both verify. Refused with heimdall-stopped, exit.killed = Stopped, exit.signal = 9. The outputs are treated as after a limit: the scan runs and its list is signed
after the end (the function returned, or a limit took the job) nothing the outcome the job had

The runner looks at the handle every 10 ms. Stopped is signed only when the job's first process died from that kill; a function that returned by itself in the same instant keeps its own outcome.

How long a stop takes. While the function runs, the job is gone and the call has returned within some tens of milliseconds. A stop that comes while the container is being made has nothing to kill yet: the job's cgroup gets its first process only at the end of the start. The runner writes cgroup.kill at every look, so that process dies within 10 ms of its first moment, and the call returns when the starter has answered: at the latest about when the start would have been through. The starter itself is never killed for a stop; it removes what it made. As measured in the kernel tests (a debug build, where a start takes 6.7 s because the starter reads its own 247 MB program for its digest): a stop at 2 % of the start returned at 6.77 s, a stop while the function ran returned 18 ms after it.

A stop together with a limit names the limit. When a limit and a stop both ended the job (the stop came when the wall clock had just fired, or the OOM killer had already taken one of its processes), the result says Wall, Workspace, Cpu or Memory, not Stopped. The reason: a limit is a fact about the job that its caller can learn nowhere else (this build needs more memory than it was given; this input makes the check spin), while the caller knows already that it called stop(). And the two cannot be put in order: both are a SIGKILL of the same processes, the limit's own record is exact (the cgroup's OOM count, the starter's clock and readings), and which kill reached a process first is known to nobody. So Stopped is signed only when the stop alone ended the job.

A job's stop beside a service's (the two are kept alike where it fits):

A service, ServiceHandle A function job, JobStop
The handle exists from the start on: start returns it before the run: the call blocks until the end, so its caller holds the handle first
The stop SIGTERM, the grace, then cgroup.kill; stop returns when the service is gone cgroup.kill at once; stop returns at once, and the blocked call returns the end
Asked to end by itself, never killed terminate: SIGTERM once the program can take it, and no start after it; returns at once, the end comes on end_fd() none: a job has no such call
A second stop, a stop after the end nothing nothing
The end is learned from ended(), end_fd() the return of run_function_stoppable
Dropping the handle stops the service: it lives as long as its handle nothing: a job lives as long as its call
What is signed about the end nothing: a service's end is not signed the result, with exit.killed = Stopped

e. The jobs, written out

// A job names ANY starter program: the caller itself, or another program on the host whose
// `main` calls `run_if_job`. Holger's `app-fetch` and `app-build` live in a starter of their
// own beside `holger` (here `holger-build`; the name is Holger's), so that the dump reader's
// zstd C never enters the account's process. The check jobs and judge stay in `holger`.
// Each starter has its own table and its own index of profiles.
let holger = Starter::current_exe()?;                        // holger is its own starter
let builder = Starter::of("/usr/lib/holger/holger-build")?;  // pinned by the sha256 of its bytes, read here
let profiles = FunctionProfiles::read("/usr/lib/holger/profiles/holger")?;
let build_profiles = FunctionProfiles::read("/usr/lib/holger/profiles/holger-build")?;
let tree = PathBuf::from("/var/lib/holger/toolchain");       // cargo, cargo-mimir-dump, the nightly driver, git

// 1. THE APPLICATION BUILD: the fetch job has the ONE peer, the build job has none.
// The fetch brings the application's own repository at one commit: no submodules, and
// Holger refuses git dependencies of the lock file by name before the build job.
let mut fetch = FunctionJob::new(builder.clone(), "app-fetch", &empty_dir, &src_dir, build_profiles.of("app-fetch")?);
fetch.args = vec!["https://git.example.org/acme/billing.git".into(), "main".into()];
fetch.tools = Some(tree.clone());
fetch.policy.net = Some(NetAllow::one("git.example.org", "203.0.113.7", 443));
// through a proxy: NetAllow::one("proxy.acme.example", "10.0.0.9", 3128) and
// fetch.env = vec![("https_proxy".into(), "http://proxy.acme.example:3128".into())];
fetch.policy.workspace = Some(Workspace { bytes: 4 << 30, exec: false });
let fetched = runner.run_function(fetch)?;                   // /out: source.tar, lock.json, commit, fetch.log

// The account's process reads lock.json and writes a cargo local registry (a TREE) beside source.tar:
//   build_in/source.tar   build_in/registry/index/...   build_in/registry/*.crate
let mut build = FunctionJob::new(builder, "app-build", &build_in, &graph_dir, build_profiles.of("app-build")?);
build.args = vec!["/in/source.tar".into(), source_sha256, "/in/registry".into()];
build.tools = Some(tree);
build.policy.net = None;                                     // offline: no peer, no connect event
build.policy.workspace = Some(Workspace { bytes: 16 << 30, exec: true });
build.policy.limits = Limits { wall: Duration::from_secs(3600), memory_bytes: 8 << 30, pids: 4096, cpus: 6.0,
    max_output_file_bytes: 2 << 30, max_output_total_bytes: 2 << 30, ..Default::default() };
let ticket = build.ticket();
let built = runner.run_function(build)?;                     // /out: graph-package.znippy, build.log
let result = verify_function(&built, &runner.verifying_key(), &ticket)?;
check_outputs(result, &graph_dir)?;                          // on a refusal: show the tail of build.log
// app_build(args): unpack into /work, `cargo build --offline --locked` against /in/registry
// under cargo-mimir-dump, then nornir's `mimir_lens::lens_graph::graph_package` as a library
// call; the graph is copied to /out when it fits.
// With a peer instead (not Holger's first use): policy.net = Some(NetAllow::one(<the repository>)).

// 2. A CHECK, `check-license` first: one function per check, a package file in, a verdict out.
// No tools, no network, no work place.
let mut license = FunctionJob::new(holger.clone(), "check-license", &package_dir, &out_dir, profiles.of("check-license")?);
license.args = vec!["/in/time-0.1.43.crate".into(), package_sha256];
let checked = runner.run_function(license)?;                 // /out: verdict.json
// the same call for "check-malware", "check-provenance", "check-signatures"; "check-cve" also takes
// the advisories dump: cve.read = vec![BindRo { host: dump.clone(), dest: "/data/advisories.znippy".into() }];

// 3. holger judge, LAST (it starts life in the account's process behind a trait): a graph and a dump in, a verdict out.
let mut judge = FunctionJob::new(holger, "judge", &graph_dir, &verdict_dir, profiles.of("judge")?);
judge.args = vec!["/in/graph-package.znippy".into(), graph_sha256, "/data/advisories.znippy".into(), dump_sha256, "billing".into()];
judge.read = vec![BindRo { host: dump, dest: "/data/advisories.znippy".into() }];
let judged = runner.run_function(judge)?;                    // /out: verdict.json

f. The call shape

Rust: additions only in heimdall-core (0.6.1). heimdall-container is 0.7.0: two of its structs that a struct literal can build have a new public field (HeimdallConfig::tool_trees, ShimResponse::no_function), which is a break by this project's rule. A new struct and a defaulted trait method, as F1 was added: a JobKind variant would be a breaking release.

// heimdall-core
#[non_exhaustive]
pub struct FunctionJob {
    pub id: JobId,                       // fresh in new()
    pub nonce: Nonce,                    // fresh in new()
    pub starter: Starter,
    pub function: String,                // a name of the starter's table, [a-z0-9_.-]
    pub args: Vec<String>,
    pub env: Vec<(String, String)>,      // the function's whole environment (HOME=/ is added when it names none)
    pub input_dir: PathBuf,              // /in
    pub output_dir: PathBuf,             // /out: it exists and is empty
    pub read: Vec<BindRo>,
    pub tools: Option<PathBuf>,
    pub policy: Policy,                  // limits, net, workspace, seccomp. Refused: read, write, graph, a seccomp fallback
}
impl FunctionJob {
    pub fn new(starter: Starter, function: impl Into<String>, input_dir: impl Into<PathBuf>,
               output_dir: impl Into<PathBuf>, profile: SeccompProfileRef) -> FunctionJob;
    pub fn ticket(&self) -> FunctionTicket;   // job id, nonce, starter digest, function, args, profile digest
}
pub struct FunctionOutcome { pub start: SignedStart, pub result: SignedResult }

pub trait JobRunner {                    // run, verifying_key and features stay
    fn run_function(&self, job: FunctionJob) -> Result<FunctionOutcome, RunError>;   // default: Unsupported
}
/// Both signatures, the binding by the nonce, and everything the ticket names.
pub fn verify_function<'a>(o: &'a FunctionOutcome, key: &VerifyingKey, t: &FunctionTicket)
    -> Result<&'a JobResult, FunctionVerifyError>;     // its own error: `VerifyError` is a closed enum
/// What every runner refuses before anything runs (`InvalidJob`, by name).
pub fn check_function_job(job: &FunctionJob) -> Result<(), RunError>;
pub struct FunctionProfiles { /* jobs.json */ }
impl FunctionProfiles { pub fn read(dir: impl AsRef<Path>) -> io::Result<Self>; pub fn of(&self, function: &str) -> Option<SeccompProfileRef>; }

// heimdall-container, in a starter's main, FIRST (the six rules of a starter hold). A program
// may be a service's starter, a job starter, or both, and a job names any starter.
// In holger:
heimdall_container::starter::run_if_starter(account_entry);          // a service, as today
heimdall_container::starter::run_if_job(&[("check-license", check_license), ("judge", judge)]);
// In holger-build, a program of its own:
heimdall_container::starter::run_if_job(&[("app-fetch", app_fetch), ("app-build", app_build)]);
pub fn run_if_job(table: &[(&str, ServeFn)]);                        // ServeFn = fn(&[String]) -> i32, as today

CLI (<out>/files is the job's /out, with <out>/start.signed and <out>/result.signed beside it; exit codes as heimdall run today):

heimdall run --job function --starter <program> --function <name> --in <dir> --out <new dir>
             --profile <oci.json> [--profile-sha256 sha256:<hex>] [--read <host>:<dest>]... [--tools <dir>]
             [--net <host>=<addr>:<port>] [--work-bytes <N> [--work-exec]] [--env K=V]...
             [--wall-secs N] [--memory-mib N] [--pids N] [--cpus F] [--out-mib N]
             [--job-id <32 hex>] [--nonce <64 hex>] [--pin-out <file>] -- <args>...
heimdall verify-result <out>/result.signed --start <out>/start.signed --key <key file | key record>
             [--files <dir>] [--job-id <32 hex> --nonce <64 hex>]

The bounds in time and the stop (heimdall-core 0.7.0, heimdall-container 0.8.0; section d). Core breaks here: Limits has a new public field, KillReason two new variants and RunError one. Both enums are #[non_exhaustive] from 0.7.0 on, so the next reason or error is no break. The signed result's killed byte has two new values (6 = Cpu, 7 = Stopped); the record's version does not change, as when Workspace = 5 came. A verifier refuses a byte it does not know: one built on core 0.6 refuses a result that says Cpu or Stopped, and verifies every other result as before.

// heimdall-core 0.7.0
pub struct Limits { /* as before, and: */ pub cpu_time: Option<Duration> }   // None (the default): no CPU bound
#[non_exhaustive]
pub enum KillReason { Wall, Memory, Pids, Fuel, Workspace, Cpu, Stopped }
pub mod codes { pub const LIMIT_CPU: &str = "heimdall-limit-cpu"; pub const STOPPED: &str = "heimdall-stopped"; }
#[non_exhaustive]
pub enum RunError { /* as before, and: */ Stopped }    // stopped before the function ran: nothing is signed

/// A caller's handle to stop ONE function job. Its clones are the same handle.
#[derive(Clone, Debug, Default)]
pub struct JobStop { /* private */ }
impl JobStop {
    pub fn new() -> JobStop;
    pub fn stop(&self);                  // any thread, any time, any number of times; returns at once
    pub fn is_stopped(&self) -> bool;
}
pub trait JobRunner {                    // run, verifying_key, features and run_function stay
    /// `run_function` with a stop handle. The default REFUSES (`Unsupported`): a runner that
    /// cannot stop a job never runs it and ignores the stop. Only a runner that can stop overrides it.
    fn run_function_stoppable(&self, job: FunctionJob, stop: &JobStop) -> Result<FunctionOutcome, RunError>;
}

// A build with no wall clock, eight CPU-hours, and a cancel button:
let stop = JobStop::new();
cancel_button.on_press({ let stop = stop.clone(); move || stop.stop() });
build.policy.limits = Limits { wall: Duration::ZERO, cpu_time: Some(Duration::from_secs(8 * 3600)),
    memory_bytes: 8 << 30, pids: 4096, cpus: 6.0, ..Default::default() };
let ticket = build.ticket();
match runner.run_function_stoppable(build, &stop) {
    Ok(outcome) => {
        let result = verify_function(&outcome, &runner.verifying_key(), &ticket)?;
        // result.exit.killed: Some(KillReason::Stopped) after the cancel, Some(KillReason::Cpu) at the bound
    }
    Err(RunError::Stopped) => { /* cancelled before the function ran: nothing is signed */ }
    Err(e) => return Err(e.into()),
}

0.6.0's rules for every start, as they hold for the job (decided at the merge, 2026-11-16)

Place Where it comes from
/in, /out The caller names a path (input_dir, output_dir: the call shape of section f is unchanged). The runner opens each ONCE and does everything through that descriptor: the check that the output dir is empty, the owner change of a host id range, the mount, and the scan of the outputs after the job
The tools tree Each of its directories and files from a descriptor of its own, opened beneath ONE descriptor of the tree, no link followed
A read bind As its caller gave it (BindRo::host is a BindSource). A descriptor is checked, handed over and proven as a service's is. A path is bound as that path: the caller's choice, as for a service
The work place's host folder BY PATH. The runner makes it in its own work dir under the job's id right before the start, as it makes the job's bundle (its root and its config) there, and deletes it at the end. Whoever can swap a directory in the runner's work dir can rewrite the job's config, so a descriptor would prove nothing more. Its size is measured by that path, by the image job's code. A tmpfs work place has no host side at all

Each mount from a descriptor is PROVEN inside the container before the function runs: what stands at the place is the object the descriptor names (device, inode number, kind, mode, owner). Every descriptor is closed before the function's first instruction. A starter that reports fewer proofs than it was handed binds ends the run in an error, and nothing is signed. The runner itself holds two descriptors through a job's run (/in, /out); the tree's and the duplicates for the starter are closed as soon as the starter is started.

One rule for a filesystem where device and inode number prove nothing. The proof is claimed only where that pair names one object: ext2/3/4, xfs, btrfs, and a tmpfs with inode64. On overlayfs (the root of most containers), FUSE or a network filesystem two live objects can show the same pair, and a "proven" mount there would be a false statement. There:

/in, /out, the tools tree bound by the PATHS their caller gave, as before 0.7.0. The tree goes whole: all its entries from descriptors, or all by path
Never silently The SIGNED result says which place went by path and why: one event per place, before the broker's events. call is bind (heimdall_core::BIND_BY_PATH), at 0 ms, Allowed; its args are place=/in (or place=/out, place=tools), by=path and warning: <the place> is on <the filesystem>: .... A result with no such event had every one of these places bound from a descriptor and proven. No wire or record version changes: these are entries of the result's own events
A descriptor the CALLER gave refused there, as in 0.6.0 (BIND_FD_REFUSED). The caller asked for that object; it is never bound by some path in its place

Why a path there and not a refusal: the caller named a path, so binding that path is what it asked for, and a refusal would end every job in a container whose root is overlayfs (a CI runner, this repository's own test container) with nothing gained. What is lost there is the proof, and the signed result says so. A caller that must have the proof reads the events and refuses the result itself.

The fixed profile is proven installed (heimdall-container 0.8.0)

Every job and every service of heimdall-container runs under the FIXED seccomp profile, which the container runtime installs from the job's config; a function job runs under its generated profile on top of it. Until 0.8.0 the report from inside said only that a seccomp filter was on. A filter is inherited. A runner that itself runs under a seccomp profile (in a podman or Docker container with the default profile, a unit with a SystemCallFilter, a server under a measured profile of its own) brings one along, so "a filter is on" was true there even when the runtime had installed nothing. Where the runner had no filter of its own, a missing fixed profile was refused before 0.8.0 too. From 0.8.0:

What the count proves: the runtime added a seccomp filter between the starter and the executor's first step. What it does not prove: which filter. That the filter the runtime adds is the fixed profile is held by other tests: the config's section is Heimdall's profile (the_seccomp_profile_in_the_config_is_heimdalls_profile, tests/spec.rs), and a real job is refused what that profile refuses (the_default_seccomp_profile_blocks_new_namespaces_and_mount and a_killed_syscall_kills_the_calling_process_with_sigsys, tests/container.rs). The two together are the proof.

The tests' own way in is no way around it. HeimdallConfig::no_fixed_profile (only in a build with the feature containment-tests) makes the runner write configs without the fixed profile, so that the tests can show the refusal. A consumer who turns that feature on and sets the field gets every start refused by this check, never a job without the profile: the check is the gate, the feature is not.

The one path without this check is the learning run (the probe's measured run in a container). Its config carries no fixed profile by design: the executor installs the learning filter there, which must see every call, and the run is held to that filter by a check of its own (the filter was installed and its listener handed over, reported after the install).

g. The profile

From the tools only. No rule is written or edited by hand, and a function job never runs under the fixed profile alone.

Function Is its program closed? Its profile Made by
no tools tree (check-*, judge) yes when its graph has 0 open items the graph filter: the graph's calls and nothing measured cargo mimir make rooted at the function and at starter::call, then heimdall graph filter --make <dir> --bin <starter> --libc <libc> (exit 0 only with 0 open items)
the same, with open items no the measured static profile heimdall profile probe-container in the job's own container (new: --starter and --function where --image and --digest stand) over its runs, --error-path too, then heimdall profile gen <w> --function <name>
with a tools tree (app-build, app-fetch) never: cargo, rustc, the linker and the build scripts inherit the filter, and they are other programs measured, always as the row above, over the measured builds

How each kind of function is measured truly

A measured run is the job's profile only when the function could do in it what its job lets it do, and no more. There are two places to measure:

Function Measured truly Why
no tools tree, no peer (check-*, judge) outside, in the job probe mode its view outside is its job's view
a tools tree (app-build) outside ONLY where the tools tree IS the root: --tools / in a container made from the toolchain tree, with the job's dirs bound in. Anywhere else: in its own container a job's tree is its ROOT, and nothing outside a container puts a tree at /. A dynamically linked program (cargo, rustc, the linker) of a tree at another place asks for its loader at the host's root, outside the view, and its start is refused (pinned by a_job_function_starts_a_program_only_from_its_tools_tree)
a peer (app-fetch) ONLY in its own container, with its own broker three reasons, each enough: the peer's name resolves through the job's own /etc/hosts and nsswitch.conf, which only the job's root has (outside, the resolver takes the paths a job is refused); Landlock opens TCP by port, never by address, so "the one peer" would be every host on that port; and the connect is the broker's, while the recorder already holds the one listener a process may have

NOT offered, for a function with a peer: a profile "measured outside up to the refused connect, plus the graph". Everything the function does after its connect would be missing wherever its graph is open, and the missing calls would be found one by one by kills at run time. A profile is never completed by kills.

What no view outside a container holds, for any function: /proc (with a tools tree) is the host's, where a job's shows only the job; and a socket that is not TCP (UDP, a unix socket by its path) is not refused as a job's empty network namespace and empty root refuse it. The measured run in the job's own container has none of these limits.

The measured run in the job's own container (landing 3, BUILT)

heimdall profile probe-container for a function job: --starter <program> --function <name> stand where --image and --digest stand, with the job's own places, named as probe-exec --function --job names them where they are the same thing (--input-dir, --output-dir, --tools <dir>, --work-exec), and --read <host>=<dest>, --work-mib <n>, --peer <host>=<addr:port>; the function's args come after --. The evidence file, --workload, --run, --error-path, --env and the limits are as for an image. The starter's digest is read from the program by the command: a measured run signs nothing, and the pin is the real job's business. Without --input-dir or --output-dir the job gets an empty one of the command's own. The runner's part is HeimdallRunner::learn_function (heimdall-container, learn::LearnFunctionJob), the ONLY way into a function job's learning run: no field of a job, no setting of the runner and nothing in the environment makes run_function ask its starter for one. The starter holds the same line from its side: a learning plan in a job's request is refused, and a measured run has a request of its own (the table below).

It IS the job. The runner makes the container with the code that makes a real job's: the same root, the binds by descriptor, the tools tree, the work place, the job's /etc, the limits, the cgroup, and the function's view entered by starter::enter_view: Landlock, and the mounts without the right to execute. In a real job these two keep exec out together with the fixed profile; in a measured run they do it by themselves, because a measured run has no fixed profile. So a measured run is refused on a kernel without Landlock, exactly as a real job is, and an_exec_outside_the_tools_tree_is_refused_in_a_measured_run_as_in_a_real_one runs a real job and a measured run of the same job side by side: without a tools tree no exec works, with one no exec outside it. Three things differ, and nothing else:

A real job A measured run
The filter the fixed profile, the broker's filter (a job with a peer), the job's generated profile ONE filter: the learning filter of every measured run (a call is sent to the recorder unless heimdall-probe's fixed rules answer it: clone3 gets ENOSYS, and the four calls the kernel issues itself are allowed), with the starter's own prelude before it (the hand-off sendmsg, the close of the hand-off socket, the report's write and close). No fixed profile, as in an image job's learning run, and no profile of the job: policy.seccomp must be None
The records a signed start and a signed result none. learn_function answers with a LearnOutcome, which holds no record; a measured run is no job run, and its output dir is the measurer's own (a_measured_run_signs_nothing_and_leaves_no_record)
The request to the starter the job's request, its function under the key function_job, with the job's generated profile. Unchanged, byte for byte. A learning plan in it is refused (a_jobs_request_with_a_learning_plan_is_refused_by_the_starter) the same request with the learning plan in place of the profile, and its function under a key of its OWN: learn_function (shim::LearnFunctionShimRequest; a_measured_runs_request_names_its_function_under_its_own_key). The starter tells the two apart by the key, where it reads its request and before it makes anything (shim::route_job): learn_function without a learning plan, with a generated profile, or beside function_job is refused (a_measured_runs_request_without_its_plan_or_with_a_profile_is_refused, a_request_with_learning_and_a_generated_profile_is_refused). So no function runs without a filter, and no field of a job's request reaches the learning filter

A starter built before a function job could be measured knows only function_job, and its own parse needs that key. It refuses a measured run's request before it makes anything, so it never runs the function as a job without a filter (a_starter_from_before_the_measured_run_is_refused_before_its_function_runs: the request type as it is at 41e39c9b, kept frozen in the test; a measured run's bytes fail that parse and a real job's bytes pass it).

The programs the function starts inherit the filter and are recorded with it.

The runner hands the measurer no listener. learn_function's on_start gets a learn::StartedJob (the pid, the libc), and its record(evidence, done) is the only way to the run's calls: it runs heimdall-probe's recorder to the end and gives back the observations, how the recorder ended, and for a job with a peer the broker's report. So no caller can answer a call of the job by itself, with a peer or without.

The starter's own calls between the install of the filter and the call of the function are let through by the prelude, each on ONE reserved descriptor number near the top of the default limit (1014 the report, 1021 the hand-off), and the hand-off sendmsg only with the one flag it is sent with: a sendmsg with MSG_FASTOPEN is the broker's to decide on any descriptor. One call of the starter's has no rule: the close of its own end of the listener. That number is the lowest free one, which the function's own files get next, so a rule for it would let the function's own close through unrecorded and leave it out of the profile. It is sent on like every call, and the RUNNER answers it before it makes the StartedJob: it must be the first call, a close, of the listener's own number, by the job's first process; anything else ends the run (learn::is_own_close). The runner knows the number without being told: it is 3 (learn::LISTENER_FD), because the starter has closed everything but stdio, the report and the hand-off before it installs the filter, and the starter itself ends the start if the kernel gave the listener any other number. The runner holds the listener until that call is answered and looks for it once per round of its wait, so it goes on passing the caller's signals to the starter and sees the starter's end and the run's deadline all the while; a starter that makes no call at all is ended after ten seconds. Both ends are run by kernel tests with a REAL starter that breaks the start in one place (learn::LearnDoor, a field that exists only in a test build, feature containment-tests): another call before the close, a listener with another number, and no call at all (the tests are named in the list below). So the function never holds its own listener, it starts with stdio and nothing else as in its job, and no call of the starter's is recorded as the function's. A function that still held the listener could answer its own calls, and with a peer its own connect; so the end state is asked from INSIDE, with and without a peer (the_function_of_a_measured_run_holds_no_listener_and_neither_does_a_program_it_starts: the function asks every descriptor number it could hold whether it is a seccomp listener, and a program of its tools tree lists its own open files).

Every rule that answers a call without the recorder is held by a test without a kernel (no_call_the_measured_runs_filter_answers_itself_is_one_of_the_brokers): for every rule of the prelude and of heimdall-probe's fixed rules, and every argument set the rule admits, the broker's own filter program says "allow"; the other way round, every call the broker's filter sends on is sent on by the learning filter; and every call of the arch by its number. The same walk over the prelude of the OTHER measured runs (heimdall-seccomp's launch::prelude_for, for a program whose network namespace is empty and that has no broker) finds its sendmsg rule, which takes any flags: a rule widened later turns the test red. In a REAL job with a peer no rule lets a send past the broker by its descriptor number: the broker's filter has no prelude, its three MSG_FASTOPEN rules look at the flags argument only, the job's own profile allows only write and close on the report's number before its rules, and the kernel takes the strictest answer of all filters.

A job with a peer: one listener for the recorder and the broker. The kernel gives a process ONE listener (a second filter with a listener is refused with EBUSY). In a real job the broker's filter holds it. In a measured run the learning filter holds it, so there is no broker filter, and the recorder serves the broker's calls with the broker's own code:

  1. The recorder takes each call from the listener and records it, as it records every call.
  2. It then asks the broker: Broker::on_call(&notification) -> bool, the per-call entry of heimdall-broker (with Broker::sharing, a broker over a listener it shares, and Broker::finish, its report). The recorder's hook is heimdall_probe::record_with.
  3. on_call runs THE BROKER'S OWN FILTER PROGRAM over the call's number and arguments, in user space (heimdall_seccomp::interp::run over filter::program(Notify, exec): the program the kernel runs in a real job). There is no second list of "the broker's calls". None of the calls the learning filter answers by itself is one of them (the test above), and a call of another arch is killed by the learning filter as by the broker's.

    • The filter says "ask the broker": on_call runs dispatch, the decision code of a real run, UNCHANGED. It answers the call itself (the descriptor it opened and injects, the errno, the refusal with EACCES and its event) and returns true. The recorder answers nothing.
    • The filter says "allow": on_call returns false and the recorder lets the call go on, as it does for every call of a job without a peer.

That the interpreter picks what the kernel picks is a kernel test of heimdall-broker (the_interpreter_picks_the_calls_the_kernel_sends_to_the_broker): the selftest installs the broker's filter program on itself, makes 28 calls (every kind of call the broker has, a send with and without MSG_FASTOPEN, with the flag in the wrong argument and with dirty upper bits, and calls that are none of the broker's), and for each call the kernel's pick, sent to the listener or run, is the interpreter's.

The broker's rules brokered::function_job_policy(job, tree): the ONE function a real run calls. Full mode only (USER_NOTIF and ADDFD), else Unsupported before anything runs, as for a real job
Where the broker runs in the probe command's process: the runner's namespaces and uid, no Landlock. In a real job it is a thread of the starter outside the container: the same namespaces and the same uid. It opens through the job's root (/proc/<pid>/root), makes the TCP socket in the runner's network namespace and does the connect itself, only to the ONE declared address
The request to the starter ONE named case, in the starter's code and in the field's doc (ShimRequest::broker): learning together with broker is the measured run of a function job with a peer, and means only that the function's process is made DUMPABLE, as a job's with a broker is, so that the broker can reach its root and its memory. The starter starts no broker thread, makes no hand-off pair for a broker's listener and installs no broker filter. For an image's learning run the two together are refused (shim::check_request; a_learning_run_with_a_broker_is_a_function_jobs_and_in_full_mode). From inside (a_measured_run_has_one_filter_more_than_its_starter_and_is_dumpable_only_with_a_peer, by the Seccomp_filters count that proves a real job's fixed profile): a measured run has exactly ONE filter more than its starter began with, with a peer and without; it is dumpable with a peer and not without; the real jobs of the same shape have two more, and three with a peer
Bounds in time the broker answers a connect from a thread of its own, so the recorder goes on with the function's other calls while a connect waits. A connect ends with the kernel's answer (a closed port: ECONNREFUSED, the broker's event says so and the function goes on) or, for a peer that takes no connect at all, with the run's own wall clock (wall_killed). Both are tested: a_peer_that_does_not_answer_ends_a_measured_run_in_the_brokers_error_or_at_its_wall_clock
What the function sees what it sees in a real run: the job's /etc/hosts and nsswitch.conf (written by the same code), HEIMDALL_NET_PEERS, EACCES where the broker refuses
What is recorded every call, the broker's too (openat, socket, connect, execve): the job's profile must hold them, because seccomp takes the strictest answer of all filters (section b)
What the measurer sees the broker's report, in the command's LAST status line and nowhere else: "broker": {"mode", "connects": [{"addr", "decision", "result"}], "refused": [{"call", "args"}], "decisions", "dropped", "warnings"}. Not in the evidence file (its format does not change) and in no second file. The command's exit status is the function's own, as for an image's measured run: a refusal alone does not fail the command, the function took it and went on as in its job. A run whose fetch was refused is seen at once in the line

The line held. Nothing is allowed in a measured run that the broker would refuse in a real run: a call the broker's filter catches gets the broker's answer and no other, and the recorder never answers such a call. The broker's access through /proc is not widened: the open code is not touched (RESOLVE_NO_MAGICLINKS, /proc only as the caller's own self).

One difference in time, and none in what is allowed: in a real job the kernel answers a call the broker never sees at once; in a measured run every call waits for the recorder. A measured run is slower, so it takes its own --wall-secs and the job's wall clock is not its bound.

No new record version, and a real job's request to its starter is unchanged. The measured run's request is new with this landing: the fields a request has (learning, with generated empty, and for a job with a peer broker, the named case above), and its function under the one new key, learn_function.

The tests, kernel tests in the loki guest unless said:

One command for every function's profile

The job does not pick at run time. ONE command makes every function's profile and the index:

cargo heimdall jobs <workload> --bin <starter> --libc glibc|musl --graph <dir> --out <dir>
                    --function <name>=<Mímir instance>...          (a thin wrapper, like `cargo heimdall union`)
  per function, as built: the three steps of `cargo heimdall union --function` (below)
  as designed, with step 7: the graph filter; refused for open items → the measured profile; neither → no row, said by name
  <dir>/jobs/<name>/<arch>-<libc>.oci.json
  <dir>/jobs.json    heimdall.jobs/1: [{ function, instance, kind: "graph" | "measured" | "union", profile, sha256, open_items }]

At run time FunctionProfiles::of(name) gives the SeccompProfileRef of that row. No row, no policy.seccomp, or fallback_to_default: InvalidJob, nothing runs. The start record signs the digest; the index says which kind it is.

State today: no Holger function is closed (the h40 flow engine has 7 open items at 290 call sites; 1 item is expected with nornir 0.7.0). So every row starts as union (below), and a function moves to graph the day its graph closes, with no change in the caller.

As built in step 5 (heimdall-core 0.6.1, heimdall-cli 0.8.1), decided there:

heimdall graph src <workspace> --bin <starter> --out <graph>/<name> --function <instance>
heimdall profile gen <workload> --profiles <profiles> --libc <libc> --function <instance>
heimdall profile union --measured <profiles>/<workload>/jobs/<the function's path>/<arch>-<libc>.json
                       --possible <graph>/<name>/<starter>.full.possible.json --out <dir>/jobs/<name>
FunctionProfiles::record(<dir>, <name>, <instance>, union, <arch>-<libc>.oci.json, its bytes, no open items counted)

The measured side comes from the function's probe runs (how each kind of function is measured truly: above). A step that fails ends the command with its code: that function gets no row, and the rows written before it stay. A name is refused before anything runs when no starter table can have it, when it is given twice, or when its function is main.

h. Not in the first version, and the build steps

Not in the first version:

Build steps, each RED first. The application build runs after step 6; the check jobs need only steps 1, 2, 5 and 6, so they come with it (check-license is the first, and the shape of the selftest's first job function: no tools, no network); judge needs nothing more.

# Step Size RED tests
1 core: FunctionJob, FunctionTicket, FunctionOutcome, run_function (default), the job check, verify_function S a_function_job_without_a_profile_is_refused, a_function_job_with_two_peers_is_refused, a_runner_without_function_jobs_says_unsupported, a_start_and_a_result_of_different_jobs_never_verify_together
2 container: the job in a function container: run_if_job, /in, /out, the wall clock, the output scan, both records M kernel tests with heimdall-function-selftest: a_function_job_writes_its_output_and_both_records_verify, an_unknown_function_is_refused_before_the_container_exists, a_changed_starter_is_refused, the_wall_clock_ends_the_job_with_heimdall_limit_wall, an_oom_ends_the_job_with_heimdall_limit_memory, an_output_over_the_cap_gives_heimdall_out_2_and_an_empty_out, a_refused_job_keeps_the_outputs_it_wrote (exit-1, limit-wall, limit-memory, limit-pids), an_input_tree_of_thousands_of_files_is_read, a_job_without_a_tools_tree_can_execute_nothing
3 the tools tree, and the work place with exec M a_job_runs_a_program_of_its_tools_tree, a_tree_the_runner_does_not_list_is_refused, a_write_into_the_tools_tree_fails, a_program_built_in_the_work_place_runs_only_with_exec, the_work_place_is_gone_after_the_job, a_work_place_over_its_cap_gives_heimdall_limit_workspace_and_keeps_the_log
4 ONE peer through the broker, and the hosts line M a_fetch_job_reaches_its_one_peer_and_the_event_names_it, a_connect_elsewhere_is_refused_and_recorded, a_job_without_net_has_no_connect_event, the_peer_is_reached_by_name_through_the_hosts_line
5 the measured profile of a job: probe-container for a function, gen --function, cargo heimdall jobs, jobs.json, FunctionProfiles M the_probe_of_a_job_records_its_child_programs_too, a_call_outside_the_profile_gives_heimdall_seccomp_1_and_keeps_the_log, a_function_without_a_row_has_no_profile_and_the_job_is_refused
6 CLI: heimdall run --job function, verify-result --start S the_cli_runs_a_function_job_and_verify_result_accepts_both_records
THE APPLICATION BUILD (Holger's S-b) Holger's: the fixture git repo builds; with time gone from the repository it is refused naming time@0.1.43; the build job's events show no connection
7 the graph-filter pick in cargo heimdall jobs S a_closed_function_gets_the_graph_filter_and_the_index_says_graph, an_open_function_gets_the_measured_profile_and_the_index_names_its_open_items
8 the two bounds in time and the caller's stop (section d): Limits::cpu_time, no wall clock, JobStop, run_function_stoppable, KillReason::Cpu and Stopped, RunError::Stopped; core 0.7.0, container 0.8.0. BUILT M core: a_function_job_without_a_wall_clock_needs_a_cpu_bound_above_zero, the_cpu_bound_and_the_stop_have_bytes_of_their_own_in_the_signed_result, a_job_killed_at_its_cpu_bound_and_a_stopped_one_verify_as_a_pair_and_say_so, a_runner_that_cannot_stop_a_job_refuses_one_with_a_stop_handle_and_runs_nothing; fake starter: a_job_with_a_cpu_bound_needs_no_wall_clock_and_the_bound_reaches_its_starter, a_job_without_a_wall_clock_is_not_ended_by_the_runners_own_clock, without_a_wall_clock_the_runner_ends_a_starter_that_is_past_the_cpu_bound, a_kill_at_the_cpu_bound_is_a_signed_refusal_that_names_the_bound_and_keeps_the_log, a_stop_before_the_start_starts_nothing, a_stop_while_the_job_runs_ends_its_cgroup_and_the_signed_result_says_stopped, a_stop_before_the_report_from_inside_signs_nothing, a_stop_after_the_end_changes_nothing, a_stop_together_with_a_limit_names_the_limit, after_a_stop_the_runner_ends_a_starter_that_does_not_answer, the_cpu_bound_of_an_image_job_reaches_its_shim_and_its_kill_is_refused_with_the_cpu_code; kernel: a_job_without_a_wall_clock_is_killed_at_its_cpu_bound_counted_over_its_child_programs, a_job_without_a_wall_clock_is_ended_by_its_callers_stop, a_stop_ends_the_child_programs_of_a_job_too, a_stop_before_the_start_runs_nothing, a_stop_after_the_end_changes_nothing, a_stop_at_any_moment_of_the_start_gives_one_of_its_two_ends, the_cpu_bound_kills_an_image_job_whose_two_processes_use_cpu_time

Second slice: applications with C

First version: pure-Rust applications. No measured build compiles C. A build script that makes a call no measured build made is killed by the kernel (signal 31) and the call never runs. The job does not end as heimdall-seccomp-1 for it (that code is for a call the function itself makes): the job's answer is what the function makes of its failed build. A function that returns non-zero then ends the job as heimdall-exit-1, and its build.log stays listed.

CONFIRMED: taking applications with C (Holger itself links openzl and blake3's assembly through cc) costs a bigger tree and measuring again, with no change to FunctionJob.

What Changes in the second slice
The tools tree plus the C compiler, the assembler and the libc headers: more files under the same tools dir
The measured builds plus builds whose build scripts use cc; measure again; a new digest in the app-build row of jobs.json
The caller's numbers perhaps pids, memory_bytes and workspace.bytes; the compiler's temp files go to /work through TMPDIR in env
FunctionJob, the runner, the fixed profile, the two records, the CLI nothing

Why nothing else: the tree is the job's root with Landlock's execute right over all of it, so cc starts cc1, as and the linker with no new grant; the objects land in /work, which the build job already has with exec; and the filter is the measured one, inherited by every child.

One fact for the FIRST tree: cargo links the build scripts and proc macros of pure-Rust dependencies too, and rustc on linux-gnu starts its linker through cc unless cargo's config names another one. So "no C compiler" cannot mean "no linker", and may not mean "no cc program". The first measured build settles what the tree needs; the job's API is the same either way.

What a caller on eab16b3 changes

Holger h40 pins Heimdall eab16b3. Nothing between eab16b3 and a5 touches a caller's API (heimdall-core 0.5.1 and heimdall-container 0.5.6 at both).

To use the job
Pin the release that holds the job (additions only: start_function and the flow engine's service do not change)
main add starter::run_if_job(&[…]) beside run_if_starter(…), before any thread; or first in the main of a starter program of its own (app-fetch and app-build): a job names any starter
Job functions plain fn(&[String]) -> i32: read /in, write /out, work in /work, return 0 when the run is good; the verdict is a file
Profiles cargo heimdall jobs in the build; ship its out dir with the program; FunctionProfiles::read at start
Runner config tool_trees = [the toolchain tree] and allow_workspace_exec = true on the build runner only; the broker in full mode for a job with a peer
3.8's run_job_net and the holger_job_runner wire runner.run_function(job), verify_function, check_outputs

Decisions taken in this proposal (accepted)

  1. Two existing signed records bound by the nonce, not a new wire version.
  2. A new struct and a defaulted trait method, not a JobKind variant: an additive release.
  3. The tools tree is the job's read-only root and comes from the runner's config, never from the job alone.
  4. ONE peer per job at most: the fetch job has it (the git host, or a proxy), the build job has none.
  5. The profile is picked when the profiles are made (the index), never at run time, and never by hand.