interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / tools / aien-test / docs / LOCAL_VERIFICATION.md

677 lines · 42568 bytes Raw Blame History Rendered
1# Local verification with aien-test
2
3ADR 0033 Slices E and H: the planner, the trusted worker, the status and
4verify commands, and the sandbox seam. Everything here runs on the Spark,
5offline, with no outside service in the loop. GitHub only receives a commit
6status when it can be reached; it is never asked for permission.
7
8## Commands
9
10| Command | What it does | Exit |
11|---|---|---|
12| `aien-test plan [--base REF] [--repo NAME] [--operator] [--allow-dirty] [--full]` | Which gates BASE..HEAD needs, by section, with the graph digest. BASE defaults to `origin/main`, then `main`. `--full`: every gate at HEAD (see "Full scope" below). | 0 runnable, 2 NOT_RUN (unmapped path or removed gate), 4 BLOCKED_OPERATOR |
13| `aien-test test changed [--base REF]` | Prints the plan, then runs the non-blocked selection through the normal runner. | the campaign verdict (PASS 0, FAIL 1, NOT_RUN 2, BLOCKED 3/4, MISSING 5) |
14| `aien-test test crate:NAME` | The gates covering a workspace crate (from `cargo metadata`) and every crate that depends on it. | campaign verdict |
15| `aien-test status [--state-dir DIR]` | Pools, GPU lock holder, aien-proof slots, quiet flag, worker heartbeat, pending triggers and outbox, newest bundle per repository. Read-only. | 0 |
16| `aien-test verify COMMIT [--repo NAME] [--base REF] [--state-dir DIR] [--release]` | The independent check of a bundle, printed as the fixed report block below. | 0 only on `MERGE ELIGIBILITY: READY`, else 1 |
17| `aien-test worker [--once REPO SHA] [--full] [--poll SECS] [--repos A,B] [--github] [--iterations N] [--state-dir DIR] [--key FILE] [--clones DIR] [--wt-root DIR] [--wt-tool FILE] [--base REF] [--sandbox user\|none --dev-unsandboxed]` | The trusted worker: one head with `--once`, or the loop. Runs gates in the user sandbox unless told otherwise. `--full`: an Alpha qualification (see "Full scope" below). | `--once`: the plan verdict; loop: 0; 2 on a refused sandbox mode |
18| `aien-test run GATE --sandbox user`, `aien-test test ... --sandbox user` | Any run, with every gate program started through the exec helper. | as before |
19
20`--release` (run, test, verify): qualification mode. No cache reuse, the tree
21must be clean even with `--allow-dirty`, and in `verify` a cached result of a
22gate whose `cache_scope` is `hardware` cannot count.
23
24## The plan
25
26Selection is the set of gates whose watched paths (declared `inputs`, the
27D3 implied inputs, the manifest file, the golden file) cover a changed path,
28plus the always set, closed over dependents and then dependencies. Sections:
29
30- **Required**: runs on this machine now.
31- **Cached**: an evidence receipt already settles it (`plan` only; `verify` takes cached entries from the bundle).
32- **Needs Spark**: pool `qemu`, or `arch`/`bare_metal` requirements.
33- **Needs GB10**: pool `gb10`.
34- **Advisory**: exactness ADVISORY; never required, never moves the verdict.
35- **Blocked**: `PIPELINE_CONFIG_CHANGED` or `OPERATOR_STEP_PENDING`. A gate
36 with `requires: operator` is `OPERATOR_STEP_PENDING` in every automatic run;
37 under `--operator` (`plan`, `test`, `worker`) it takes its normal section and
38 runs, with its own timeout, and its receipt counts like any other. The
39 operator starting the run by hand is the attestation the manifest asks for
40 (ADR 0033 Decision 2); nothing else lifts it.
41
42A changed path no gate covers is listed under `UNMAPPED` and the verdict is
43`NOT_RUN UNMAPPED_PATH`. A gate that exists at BASE and is gone at HEAD is
44`NOT_RUN GATE_REMOVED`. Both are refusals, not failures: nothing vouches for
45that change.
46
47### Trust rules A1 and A4
48
49- **A1**: the always set (`.aien/always`), the unmapped allow-list
50 (`.aien/unmapped-ok`) and the trusted keys (`.aien/verify.pub`) are read
51 from BASE through git objects, never from the working tree or from HEAD. A
52 change under test cannot widen its own allow-list or add its own key.
53- **A4**: a change under `.aien/`, `tests/gates/`, `.github/workflows/`,
54 `.forgejo/` or `tools/aien-test/` is a pipeline configuration change. The
55 whole plan is `BLOCKED_OPERATOR PIPELINE_CONFIG_CHANGED` unless the operator
56 passes `--operator`.
57
58`graph_digest` is sha256 over the canonical `[{gate, check_id, depends_on}]`
59of the selected gates, sorted by gate. `verify` recomputes it from the
60manifests at COMMIT and rejects a bundle whose digest differs.
61
62## Manifests: `run.exec`
63
64`run.exec` is either a repo-relative path or a bare program name:
65
66- A name **with a slash** (`tools/run.sh`) is resolved against the repository
67 root. Absolute paths and any `..` component are a manifest reject
68 (`BAD_MANIFEST`, exit 1), never NOT_RUN and never a silent run. A path that
69 leaves the repository through a symlink (`tools/run.sh -> /bin/true`) is
70 treated as absent: `MISSING_IMPLEMENTATION`, never run, never PASS.
71- A name **without a slash** (`crumb`, `true`) is a program on a PATH. Under
72 `--sandbox none` that is the runner's own PATH. Under `--sandbox user` it
73 is the exec helper's trusted PATH
74 (`/var/lib/aien-run/cargo/bin:/usr/local/bin:/usr/bin:/bin`, the
75 `TRUSTED_PATH` constant); the runner resolves the name there itself and
76 hands the helper the full path, so the program hashed into the receipt and
77 the cache key (`binary_sha256`) is the program that runs. A name not found
78 there is `MISSING_IMPLEMENTATION`.
79
80This is what lets the shared gate template say `exec: crumb` with
81`args: [verify, .]`: INFRA installs a pinned `crumb` at `/usr/local/bin/crumb`
82(root-owned, on the trusted PATH). Proven end to end on 2026-10-11: a gate
83running `crumb verify .` as `aien-run` in a worker checkout passed.
84
85**The crumb tool is pinned by the repository, not by the host (sc#602).**
86Since DRA-97 (2026-11-07) Crumbs are retired from the active workflow: this
87repository has no CRUMB-VERIFY gate and `READY` does not depend on the
88`Crumb status:` line, which is still printed for history. What follows
89describes how that line is computed.
90`crumb.lock` at the repository root holds one aien-architecture commit. The
91retired CRUMB-VERIFY gate (`tests/gates/run.sh crumb-verify`) built `tools/crumb` at
92that commit from the sibling `../aien-architecture` into
93`$CARGO_TARGET_DIR/crumb-tool/<pin>` and runs that binary; the receipt records
94`crumb_tool_commit`. The readiness report does the same from the trusted clone
95`<clones>/aien-architecture` into `<state>/crumb-tool/<pin>` and prints
96`Crumb tool: pinned <sha> (crumb.lock)`, so the gate and the `Crumb status:`
97line can never disagree because of a different `crumb` on PATH.
98aien-architecture owns the tool and has no `crumb.lock`: its commits are
99checked with the tool at the commit under test (`Crumb tool: pinned <that
100commit>`), as its hosted workflow does, so a change to the crumb format is
101judged by the tool that writes it. Any other commit
102without `crumb.lock` still uses the PATH `crumb` and the report says
103`Crumb tool: crumb on PATH (no crumb.lock at COMMIT)`. If the pinned tool cannot
104be built (no sibling clone, bad lock) the status is STALE with the reason in
105`Crumb note:`. Moving the pin is an ordinary change to `crumb.lock` followed by
106`crumb compile .` with the new tool.
107
108## The sandbox seam (C8)
109
110`--sandbox user` rewrites every gate launch into
111
112```
113sudo -n /usr/local/sbin/aien-run-exec --cwd CWD --timeout SECS --profile host|qemu|gb10 [--env CARGO_TARGET_DIR=...] -- PROGRAM ARGS
114```
115
116Only `CARGO_TARGET_DIR` is passed through, plus `AIEN_GB10_LOCK_HELD=1` for a
117gb10 gate while the runner holds the GPU locks for it (also set without the
118sandbox). The runner, not the gate, serializes gb10 under `/tmp/aien-gb10.lock`
119(ADR 0033); a gate script that takes that lock by hand for operator use must
120skip the `flock` when it sees the marker, because `aien-run` cannot open the
121worker's lock file and the same user would block behind the runner's own lock.
122Under `--sandbox user` the
123receipt's `core.machine` also carries `sandbox_helper_sha256` (sha256 of
124the installed helper), so it is in `machine_digest` and the cache key: a
125result made under another helper (other network, mounts or limits) is
126never reused. The runner's own timeout and
127kill rules are unchanged; a gb10 timeout stays advisory. For `run` and
128`test`, `--sandbox none` (the default) leaves the launch exactly as it was.
129
130What the helper requires (INFRA, read from the installed script): `--cwd`
131canonical, and inside `/var/lib/aien-run` only a run directory
132`wt/<repo>/<40-hex>` or below it; host and qemu checks get a private `/tmp`, so a tree
133under `/tmp` is invisible to them; `CARGO_TARGET_DIR` only as
134`/var/lib/aien-run/target/<repo>/pr/<sha40>` or `.../main/<sha40>`, the head's own (created on demand).
135Inside a run everything is read-only except the run's own run directory (file
136ownership inside it still applies: siblings are not writable), its one
137target dir and a private `/tmp`. host and qemu checks have no network but
138their own loopback: `lo` is up inside their private network namespace, so a
139test may start a server on 127.0.0.1 and talk to it; the host's own
140127.0.0.1 services stay out of reach. When the helper refuses a call it exits 2
141and its stderr starts with `aien-run-exec:`; nothing ran. The runner records
142such a run with no exit status, so it is FAIL and can never meet
143`expects.exit`, not even `exit: 2` (`runner::sandbox_refused`).
144
145## The worker and the sandbox
146
147The worker runs other people's code, so it uses `--sandbox user` unless told
148otherwise. `--sandbox none` runs gates as the worker's own user, who can read
149the signing key: the worker refuses it (exit 2) unless `--dev-unsandboxed` is
150given, and refuses it with `--github` in every case. The library has the same
151rule (`Config.allow_unsandboxed`, default false). Under `--sandbox user` the
152worker passes `CARGO_TARGET_DIR=/var/lib/aien-run/target/<repo>/main/<sha>` for a
153head already on the base line and `.../pr/<sha>` for any other head (A2). One dir
154per head: in a shared dir cargo linked one head's build into another (sc #605);
155`wt.sh remove` deletes the dir with the worktree.
156
157The gates of one head share that target dir, so the runner holds it for one
158gate at a time: every gate that runs takes an exclusive `flock` on
159`<state>/locks/target/<sanitised target dir>.lock` (the `CARGO_TARGET_DIR` it
160is given, or else the worktree's own `target/`) for its whole run, build and
161execution, and releases it when its process has exited. Every gate, not only
162those whose manifest names cargo inputs: SC-INQUISITOR builds with cargo and
163lists no `Cargo.toml`, and the runner cannot see inside a script. The lock is
164the worker's, never the gate's. Without it two gates built in one target dir
165at once and one relinked a test binary the other was executing (sc fix/521:
166SC-AGENT-PREFLIGHT under SC-TEST, `current_exe: NotFound`, a false FAIL).
167Gates given different target dirs still run at the same time. The fixed lock
168order of one gate is: pool slot, target-dir lock, `prepare` (if any),
169`/tmp/aien-gb10.lock`,
170aien-proof `slots/gpu.lock`; the worker's target priming takes only the
171target-dir lock. Known limit: a gb10 gate is never killed on timeout, so a
172hung one holds the target dir until it exits on its own.
173
174A held GPU lock is waited for, up to a bound, then the gate is NOT_RUN
175`gpu_lock` (or `gpu_lock_proof`). The live model server takes
176`/tmp/aien-gb10.lock` around every request (one request held it 108 s median,
177222 s at most, over 323 requests on 2026-10-19), so the old single try lost
178nearly every time. The wait is a blocking `flock` in the kernel's queue, the
179same queue the server's requests (`GpuLock::acquire_queued_at`, 300 s per
180request) and `flock(1)` jobs wait in: the gate takes its turn between
181requests and never jumps the queue. A poller with `LOCK_NB` is starved by
182queued waiters (2026-10-19, two back-to-back 300 ms holders: polling got in
183after 13 to 17 s or gave up at 20 s in 2 of 5 tries; the queue got in after
1840.3 to 0.6 s in 5 of 5). Default bound 30 minutes (`DEFAULT_GPU_WAIT`, the
185server's own upload wait); `--gpu-wait 0` refuses at once, `--gpu-wait 90s`
186sets another bound, `--wait-gpu` waits without one. While it waits the gate
187keeps its pool slot and target-dir lock (never the GPU idle), so other gates
188of the same target dir wait too, at most the bound. Every gb10 receipt
189records `volatile.gpu_wait`: `mode`, `bound_ms`, `waited_ms`, `acquired`,
190and `volatile.gpu_held_ms`, how long the run held the GPU locks.
191
192A gb10 gate that must build before it touches the chip names the build in a
193v2 `prepare:` key (same shape as `run:`: `exec` plus a one-line `args` list).
194The runner runs it after the pool slot and target-dir lock and BEFORE
195`/tmp/aien-gb10.lock`, under the host sandbox profile with the gate's timeout
196enforced, without `AIEN_GB10_LOCK_HELD`; then it takes the GPU locks for `run`
197alone. A prepare that exits non-zero or times out fails the gate
198(`prepare_failed`), `run` never starts and the GPU lock is never asked for;
199its exit status and output are the receipt's. `volatile.prepare` records
200`duration_ms`, `exit_status`, `timed_out` and the two output blob hashes. Why
201(L154, 2026-10-20): omega's chip gates build their program inside the lock,
202so one PR run held the chip 84 minutes for three gates while the GPU sat idle
203compiling (OMEGA-COMPOSITION-GATE-GPU 846 s, OMEGA-M17 2233 s, OMEGA-M19
2041933 s, omega 47699e9d). A gate without `prepare` behaves as before.
205
206Under `--sandbox user` every checkout is made with INFRA's worktree tool
207(`--wt-tool`, default `<clones>/aien-sovereign-core/tools/aien-local-ci/wt.sh`;
208without it the worker refuses to run). `wt.sh sync` refreshes the bare mirror
209`/var/lib/aien-run/mirror/<repo>.git` from the trusted clone (a head no branch
210names is then fetched into the mirror by its id), and `wt.sh add` checks the
211head out at `/var/lib/aien-run/wt/<repo>/<sha>/<repo>` (the run directory
212`wt/<repo>/<sha>/` holds it and its siblings): files owned by `aien-run`,
213the `.git` link root-owned and pointing into the mirror. An older tree for
214the same head is removed first, never reused. The worker opens that tree
215with its own git only after checking the link (a regular root-owned file
216nobody else can write, pointing into `<mirror>/worktrees/`), and then only
217through git's command-line `safe.directory` for that one path
218(`process::trust_worktree`): every git setting and hook git reads there is
219the operator's mirror, never the checked-out code. `wt.sh remove` deletes
220the run directory (checkout and siblings) afterwards.
221
222Before it fetches or runs anything the worker refuses a repository name that
223is not a plain name (letters, digits, `.`, `_`, `-`, not starting with a
224dot), a commit that is not 40 lowercase hex, and a signing key whose mode
225gives group or other any access (it must be 0600).
226
227## Sibling checkouts
228
229Some gates build or read a neighbouring repository: `tests/gates/run.sh`
230calls `need_sibling <dir>` or `pin <name> <repo> <sha>` and reads `../<dir>`,
231the way the hosted job checks that repository out beside the one under test.
232The one rule:
233
2341. **Where.** A sibling is always `../<dir>` of the checkout under test. The
235 worker runs a head in a run directory `<wt-root>/<repo>/<sha>/`: the
236 checkout at `<repo>/`, each sibling at `<dir>/`, so `..` from the checkout
237 is the run directory. Under `--sandbox user` the exec helper gets
238 `--cwd <wt-root>/<repo>/<sha>/<repo>`.
2392. **What.** A sibling is a read-only checkout of a trusted clone
240 `<clones>/<source>` at `refs/remotes/origin/<ref>` as that clone has it
241 when the run starts. The worker never fetches it for the run and never
242 uses the network for it. Under `--sandbox user` it is a worktree of the
243 `wt.sh` mirror (`wt.sh sync <source>`, then `wt.sh sibling`), owned by the
244 operator with no group or other write, so `aien-run` can read the files
245 and their git history (`git -C ../<dir> rev-parse HEAD` works) but cannot
246 change them or add entries to the run directory. Under `--sandbox none` it
247 is a `git worktree add --detach` from the clone.
2483. **Which.** The operator's sibling map decides, never the change under
249 test: `tools/aien-local-ci/siblings` in the trusted clone of
250 aien-sovereign-core (`--siblings FILE` overrides), one line
251 `<repo> <dir> <source-repo> <ref>`. Names are plain names, the ref a plain
252 branch name; one malformed line, or an explicit map that cannot be read,
253 refuses every run before anything is checked out. A repository the map
254 does not name gets no siblings. A sibling that cannot be made (no
255 `origin/<ref>` in its clone, a `wt.sh` failure) is a journal note and its
256 gates fail on the missing directory; they never pass without it.
2574. **Recorded.** The journal names every sibling with its commit
258 (`sibling ../<dir>: <source> origin/<ref> <sha>`), and `run.sh` records
259 the commit it used in the receipt as an `AIEN-OBS` observation.
2605. **Other commits.** A gate that needs a sibling at a commit other than its
261 head (a lock file, a pinned protocol version) materialises that commit
262 from the sibling's object store into a writable, ignored place:
263 `$CARGO_TARGET_DIR/aien-pins/<name>` (aien-sovereign-core) or a
264 gitignored build directory, never inside the sibling and never in a
265 tracked path. The mirror holds every branch of the trusted clone, so a
266 commit on any branch is there.
2676. **Manifests.** A gate that needs a sibling is `requires: host` (or a
268 stronger pool), never `portable`: `portable` means the tree alone, which
269 is what the hosted thin gate runs.
2707. **Cache.** A sibling lies outside the tree the cache key covers, so the
271 worker records each sibling made (`name` = its `dir`) and each operator
272 pin (`name` = `pin:<source>`) with its commit in the receipt's `pins`,
273 which is part of the cache key. The worker's evidence directory is per
274 head (`evidence/<repo>/<sha>/`); results cross heads only through the
275 shared store `<state>/gate-cache/<repo>/` (judge once, Drake 2026-10-20),
276 and only as far as the gate allows (`cache::cross_head`):
277 - **Never across heads:** `cache: never`, gb10/nvrm (chip state),
278 bare_metal/analog, `requires: operator`, `cache_scope: hardware`,
279 APPROXIMATE/ADVISORY. These keep the per-head cache only.
280 - **Whole tree identical:** every other gate, by default. Gates read files
281 they do not declare (SC-TEST reads the root `README.md` and
282 `COVENANT.md`), so declared inputs alone could hand a commit another
283 commit's PASS. Two heads with the same tree id (a squash merge of an
284 up-to-date PR, a re-push, a duplicate PR) share every such result.
285 - **Declared inputs identical:** a gate whose manifest says
286 `cache: inputs_complete`, the author's promise that `inputs` name every
287 file the gate reads. Any head with the same key reuses it.
288 A promise is checked, not trusted: `aien-audit-inputs GATE_FILE` runs the
289 gate once under `strace -f -y -Y` (cold target dir, private TMPDIR) and
290 lists every file it opened that the manifest does not cover; RESULT FAIL
291 means the promise is false. Three manifest keys say what `inputs` alone
292 cannot (L335): `outside_inputs` (files outside the repository, `~/` or
293 absolute, hashed into the key: the PREFILL-E2E-2 checkpoint), `listed`
294 (directories whose entry names, not bytes, join the key: cargo lists
295 `tests/`, `src/bin/`, `examples/` of every workspace member to load the
296 workspace) and `*` patterns in `inputs` and `listed`
297 (`crates/*/Cargo.toml`). `target_lock: none` lets a gate that never
298 starts cargo (the audit refuses it if it does) skip the head's target-dir
299 lock instead of queueing behind every cargo gate.
300 The key adds the repository build files (`runner::IMPLIED_BUILD_FILES`:
301 Cargo.toml, Cargo.lock, rust-toolchain(.toml), .cargo/config(.toml),
302 native-artifacts.lock, mojoproject.toml) and the judge's own sha256
303 (`machine.judge_sha256`), so an entry dies with a new judge or exec
304 helper. A FAIL is reused as FAIL. The reuse receipt says
305 `volatile.cache.reused_from` and `reused_from_commit`; the bundle entry
306 is `cached` with `resolution.resolved_from` and `resolved_from_commit`.
307 One flock per entry (`locks/<entry>.lock`) makes a second judge of the
308 same key wait and reuse instead of running it again. A declared sibling
309 that cannot be made turns the cache off for the head (`no_cache`).
310
311`wt.sh remove` takes the whole run directory away (checkout and siblings)
312and prunes every mirror's worktree list. An older `wt.sh` that still makes
313the flat layout (`<wt-root>/<repo>/<sha>` is the checkout) keeps working;
314the worker then journals that no siblings were provided.
315
316
317### Pinned sibling commits and model checkpoints
318
319Some gates check out a pinned commit of a sibling (`pin <dir> <repo> <sha>` in
320`tests/gates/run.sh`, cloned from `../<repo>`). The sandbox has no network,
321so a pinned commit that is on no fetched branch must already be in the
322sibling. `tools/aien-local-ci/pins` (beside `siblings`, read from the
323operator's trusted sc clone, never from the head) lists them as
324`<repo> <source-repo> <sha40>`. Before the siblings are made, the worker
325(`ensure_pins`, trusted side, provisioning time only) fetches a missing pinned
326commit by its sha from the trusted clone's own `origin` and holds it as
327`refs/remotes/aien-pins/<sha>`, so `wt.sh sync` copies it into the mirror and
328git never prunes it. A pin that cannot be made present is a journal note; the
329gate that needs it then fails, never PASS. Pins read from lock files (omega's
330`omega.lock` and the locks inside it) follow main and are not listed.
331
332Model gates (PREFILL-E2E-2 and its eight mutant gates, `requires: host`) read
333the TinyLlama-1.1B-Chat-v1.0 checkpoint at `$HOME/models/TinyLlama-1.1B-Chat-v1.0`
334(`model.safetensors`, `tokenizer.json`). Inside the sandbox `$HOME` is
335`/var/lib/aien-run`; `aien-run-exec` mounts the sudo caller's `~/models`
336read-only at `/var/lib/aien-run/models` (empty root-owned mount point made by
337`install.sh`), so the default path resolves there. The script records the
338weights' sha256 as the observation `model_sha256`. Without the checkpoint it
339prints `AIEN-OBS not_run_reason "model_missing"` and exits 77: the verdict is
340NOT_RUN with reason `model_missing`, never PASS. Exit 77 with a plain
341lowercase `not_run_reason` is the general rule (`verdict::SELF_NOT_RUN_EXIT`);
342without that observation, or when a manifest itself expects 77, it is an
343ordinary exit.
344
345The mutant gates apply their patch to a private copy of the tree in `/tmp`,
346never to the checkout: the gates of one head run in parallel in one checkout,
347and a patched file there would fail every other gate's clean-tree check.
348
349`wt.sh sync` also copies the trusted clone's `origin` URL into the mirror, so
350`git remote get-url origin` in a sandbox checkout gives the GitHub URL, as on a
351GitHub runner (the sc tier-1 test f62 reads it). Nothing fetches through it:
352the sandbox has no network and cannot write the mirror.
353
354## The worker
355
356For one head `REPO SHA`:
357
3581. The refusals above (names, key mode, sandbox mode).
3592. `git fetch --all` in the trusted clone `<clones>/<repo>` (default
360 `~/workspace/<repo>`); its checkout is never touched.
3613. Under `--sandbox user`: `wt.sh sync` and `wt.sh add` (see above). Under
362 `--sandbox none`: `git worktree add --detach <wt-root>/<repo>/<sha>/<repo>`
363 from the clone (default `/var/lib/aien-run/wt`). Then the siblings of
364 `<repo>` from the sibling map (see "Sibling checkouts"), each journaled
365 with its commit.
3664. `crumb claim` on the worktree when it has a `.crumb` (a missing one is a
367 journal note, not an error).
3685. Plan against BASE: `origin/main` (`--base` overrides), or the head's first
369 parent when the head is already on that line (the tip of main or an older
370 main commit). `verify` applies the same rule, so both compute one plan.
3716. Run the non-blocked selection with the pools and the sandbox; receipts go
372 to `evidence/<repo>/<sha>/`.
3737. Build the bundle: one `checks[]` entry per planned gate with status
374 `run`, `cached`, `blocked` or `not_run`; `tree_digest` is sha256 of the
375 commit's tree id; the executor is the key's fingerprint with class
376 `spark`. Sign with `~/.aien/verify.key` and write
377 `bundles/<repo>/<sha>/bundle.json` (canonical bytes). The bundle also
378 carries a `plan` member (`verdict`, `reason`, `unmapped`, `removed`,
379 `blocked`): the bundle algebra says PASS when no required check failed,
380 which is vacuously true for an unmapped change with no checks. The plan
381 member is signed with the rest, so a reader can tell the vacuous case
382 apart: `verify-bundle` reports such a bundle as NOT_RUN (see below).
3838. Run the independent check on the bundle just written, exactly as
384 `aien-test verify` does (keys at BASE, signature, graph digest, check ids,
385 receipts and their manifests, crumb). The journal records `verify: READY`
386 or `BLOCKED` with the reasons.
3879. Heartbeat (`worker.heartbeat`), journal line (`journal.jsonl`), `crumb
388 close aien-worker . worker test`, remove the worktree (`wt.sh remove`
389 under `--sandbox user`). A crumb failure is
390 a journal note, never a verdict change.
391
392With `--github` the commit status `AIEN Verification (Spark)` is posted:
393`success` only when step 8 said READY (which needs the bundle and the plan to
394say PASS), `failure` when the bundle or the plan says FAIL, `error`
395otherwise; the description names the bundle path. When `gh` cannot reach
396GitHub the status is queued as `outbox/<seq>.<repo>.<sha>.json`, where `<seq>`
397is a 20-digit number that only grows, and the journal says `publication:
398pending`. Every later round of a loop started with `--github` replays the
399outbox first, in queue order (a loop without `--github` leaves it queued); the
400first status GitHub refuses stops the replay, so a newer status never
401overtakes an older one. A newer status for the same head replaces the queued
402one and moves to the end. A file that is not a status is renamed to `*.bad`
403and journaled. GitHub being down never fails a local verification.
404
405The loop (`worker` without `--once`) serves trigger files
406`trigger/<repo>.<sha>` oldest first (by modification time), then, with
407`--github`, the open pull request heads and `main` of each `--repos` entry
408that has no bundle yet, then sleeps `--poll` seconds. `--iterations N`
409bounds the rounds (tests). Trigger names that are not a plain repository
410name and a 40-hex commit are ignored.
411
412With `--repos`, the loop takes only trigger files of those repositories and
413leaves the others for the poller that lists them. Before judging a head (loop
414or `--once`) the worker takes an `flock` on `locks/judging/<repo>.<sha>`
415(holder pid inside); if another process holds it the head is skipped with
416`SKIP already being judged by pid N` (`--once` exits 75), because every judge
417of a head shares one worktree and the first to finish removes it.
418
419What starts a run, and what does not (checked 2026-10-11 on the Spark):
420
421| trigger | how | covers today |
422|---|---|---|
423| operator | `aien-local-ci trigger <repo> <sha>` writes `trigger/<repo>.<sha>`; `aien-local-ci once` runs in the foreground | any repository with a trusted clone |
424| Forgejo push | `tools/aien-local-ci/forgejo-webhook.sh install <repo>` puts a post-receive hook in the Forgejo bare repository; a push there writes the trigger file, no network involved | installed for `aien-sovereign-core` only; Forgejo holds no copy of omega, aienos, physics or aien-architecture, and the copies it holds stopped at September commits because nothing pushes to them |
425| GitHub poll | the loop started with `--github` (`aien-local-ci start --github`) lists open pull request heads and `main` of every `--repos` entry each round | all nine repositories, but it also posts the `AIEN Verification (Spark)` status, so it is off until the operator switches it on |
426
427So a loop started without `--github` never picks up a new pull request head
428or a new `main` commit by itself: someone has to write a trigger (or push to
429Forgejo). Merging a pull request on GitHub does not wake it.
430
431`--jobs host=N,qemu=M` and `--no-cache` apply to the runs the worker starts,
432as they do for `aien-test test`. `--no-cache` runs every selected gate again
433(results come from this head or, through the shared store, from another head
434with the same key, see "Sibling checkouts"). `--jobs host=1`
435runs one host gate at a time: omega's gates share one checkout's `build/`
436and pin clones, and on main 771af52 ten of them failed from parallel races
437("Text file busy" on `build/omegatool`, concurrent clones of
438`build/pins/aienos-src`); its operator runs use
439`aien-local-ci once omega <sha> --operator --jobs host=1` until the gates or
440a per-repository pool setting make them safe in parallel.
441
442### Batches: shared gates once and first (judge once, 2026-10-20)
443
444`aien-test worker --batch REPO SHA SHA...` judges several heads of one
445repository together, and the loop does the same for the heads it finds of
446one repository, `--batch-heads N` at a time (default 6). The heads run side
447by side; each gate that will really run takes a slot of one budget the batch
448shares, `--batch-host N` host slots (default half the CPUs), and every gb10
449gate takes the batch's single gb10 slot before `/tmp/aien-gb10.lock`, so GPU
450gates stay one at a time and heads never spend their bounded GPU wait on each
451other. A gate that other heads of the batch also select (same manifest, same
452blob ids for its inputs and the repository build files, read from git before
453checkout: `worker::batch_first`) is picked first in its head and served first
454from the budget, so the shared gates run before the per-head ones. Two heads
455that reach the same key meet at that key's lock: the second waits, then
456reuses. The ordering is only a hint; the cache key alone decides reuse. A
457head is judged by one worker at a time (`<state>/locks/head/<repo>.<sha>.lock`,
458non-blocking: a second judge of the same head is refused), and checkouts,
459pins, siblings and worktree removal are done one head at a time.
460`--jobs host=1` still limits each head's own pool (omega).
461
462## verify-bundle and the vacuous PASS
463
464`aien-test verify-bundle` (the GitHub thin gate's command) prints and exits
465with the gate verdict, not the raw algebra: a bundle with no required check,
466or whose signed `plan.verdict` is not PASS, is `NOT_RUN` (exit 2) with the
467reason in brackets, even though its `verdict` member says PASS.
468
469## Full scope: Alpha qualification
470
471A commit already on main becomes an Alpha when the Spark judge runs every
472gate on it, not only the gates its diff selects. `aien-test worker --once
473REPO SHA --full` plans in full scope: every gate at HEAD is selected (the
474same set as `test ./...`), so every non-advisory gate is required, gb10 and
475Spark gates included, and the worker runs them all (the sections still say
476which need the chip). What changed only labels the entries (`because`);
477UNMAPPED_PATH and GATE_REMOVED do not apply. PIPELINE_CONFIG_CHANGED and
478operator gates keep their rules (`--operator`). `aien-test plan --full`
479prints the same selection with a `Scope: full` line.
480
481The bundle's signed `plan` object carries `"scope": "full"` or
482`"scope": "changed"`; a bundle without the member is `changed`, so older
483bundles stay valid. `aien-test verify` plans in the scope the bundle signs.
484`verify-bundle ... --require-full` exits 3 (REJECTED) unless that scope is
485`full`:
486
487```
488AIEN Verification: REJECTED NOT_FULL_SCOPE: plan scope is changed, not a full-scope (Alpha) qualification
489```
490
491It also exits 3 when the full-scope bundle carries no GPU check at all:
492
493```
494AIEN Verification: REJECTED NO_GPU_RECEIPT: an Alpha needs a required check on backend gb10 that ran on the Spark's GPU, and this full-scope bundle has none (checks by backend: host=34; gb10 checks: none)
495```
496
497An Alpha is the stage tested on the Spark's GPU, so a full-scope PASS of host
498gates alone is not one (the first Alpha, `alpha/20261024.1`, was 34 checks, all
499`backend: host`). The receipt is a required check on backend `gb10` that ran,
500or was resolved from cache: a gb10 result is never reused across heads, so a
501`cached` entry is still this commit's own GPU run. A gb10 check that ran and
502FAILed is a receipt too, and the bundle is then `FAIL` (exit 1), which says
503more than "no receipt"; a gb10 check that self-not-ran (exit 77, for example
504no checkpoint or not enough free memory) is not one. The message names the
505backends the bundle does have, so a host-only plan is visible at a glance.
506sovereign-core's receipt is `SC-GB10-SERVE-CHAT`
507(`tests/gates/sc-gb10-serve-chat.gate`, `scripts/gb10-serve-chat.sh`): build
508the server on the real Omega GPU engine, start Qwen3.8-27B, one greedy chat
509request, clean SIGTERM shutdown. Full scope selects every gate, so the Alpha
510run always includes it; a pull request's changed scope does not, and its result
511is never cached (`cache: never`).
512`tests/gates/run.sh` swaps the sandbox's read-only `$HOME` for a fresh writable
513one per step and exports `AIEN_MODELS_DIR` as the read-only home's `models/`
514mount, so the gate finds the checkpoint there, not under the fresh HOME
515(`tests/gates/step-home.sh`). Before any check it records the checkpoint it
516resolved as `model_dir` and where that came from as `model_dir_source`
517(`override` when `MODEL_DIR` was set, `models-mount`, or `home`), so a receipt
518never leaves the model's provenance to the default. `SC-GB10-MODEL-DIR`
519(`scripts/test-gb10-model-dir.sh`, portable, no GPU) runs that resolution and
520the gate's NOT_RUN `model_missing` path, which ends before the memory check,
521the build and any GPU start, with a read-only HOME.
522
523The full-scope bundle is written to the head's usual bundle path. The loop
524skips any head that already has a bundle, whatever its scope, so an Alpha
525of a head the loop already judged is run with `--once --full`.
526
527## The verify report
528
529```
530AIEN LOCAL VERIFICATION
531Repository: github.com/aien-dev/<repo>
532Commit: <40 hex>
533Changed files: N
534Affected gates: N (names) | none
535Executed gates: ...
536Cached gates: ...
537Failed gates: ...
538Blocked gates: ...
539Crumb status: CURRENT | STALE
540Evidence status: VERIFIED | INVALID
541Hardware status: QUALIFIED | NOT_REQUIRED | BLOCKED
542Final verdict: PASS | FAIL | NOT_RUN | BLOCKED
543Queue time: N ms | n/a
544GPU lock wait: N ms | n/a
545Build time: n/a
546Test time: N ms | n/a
547Total time: N ms | n/a
548MERGE ELIGIBILITY: READY | BLOCKED
549```
550
551Lines after the block (`Evidence note`, `Crumb note`, `Verdict reason`,
552`Unmapped`, `Problem`, `Bundle`) say why. Checks, in order: the bundle's
553shape and signature against the keys at BASE (several keys allowed, one hex
554per line, `#` comments; the key the bundle names must be one of them, else
555`UNKNOWN_KEY`), repository, commit, executor fingerprint, every required
556gate present, the verdict algebra; then the graph digest against a fresh
557plan (BASE by the worker's rule above); then every entry's `check_id` must
558be the one the plan computes at COMMIT (`CHECK_ID_MISMATCH`); then every
559`run` entry's receipt must exist under `evidence/<repo>/<commit>/` with the
560same gate, commit and verdict (an altered receipt no longer matches its
561digest and is reported missing) and with the `manifest_digest` of the gate's
562manifest at COMMIT (`MANIFEST_MISMATCH`); then the plan judge. Every
563rejection is a `Problem` or `Evidence note` line and leaves READY out of
564reach; no path defaults to PASS. Crumb status comes from `crumb verify .` in a temporary
565detached worktree at COMMIT, removed afterwards. Queue time is the sum of
566`pool_wait_ms`, `batch_wait_ms` (waiting for a slot of the `worker --batch`
567budget) and `target_wait_ms` (waiting for the target dir another gate holds), GPU lock wait the sum of `gpu_wait.waited_ms` (gb10 gates:
568how long each waited in the kernel queue of `/tmp/aien-gb10.lock`, see
569below), test time the sum of `duration_ms` over the executed
570receipts less those two waits (both fall inside `duration_ms`), total time the bundle's `finished_utc - started_utc`; build time
571is not measured yet.
572
573`READY` requires: evidence VERIFIED, final verdict PASS, no
574unmapped path, no blocked gate, no problem line. Crumb status is reported but
575no longer required (DRA-97, 2026-11-07).
576
577## File layout
578
579```
580~/.aien/verify.key the worker's signing seed, mode 0600
581<repo>/.aien/verify.pub trusted public keys, read at BASE
582<repo>/.aien/always gates that always run, read at BASE
583<repo>/.aien/unmapped-ok paths no gate needs to cover, read at BASE
584~/.local/state/aien-local-ci/
585 evidence/<repo>/<sha>/<digest>.json receipts of that run
586 bundles/<repo>/<sha>/bundle.json the signed bundle
587 trigger/<repo>.<sha> a run request (removed when served)
588 locks/judging/<repo>.<sha> held while one process judges that head
589 outbox/<seq>.<repo>.<sha>.json a commit status waiting for GitHub, in queue order
590 journal.jsonl one line per finished head
591 worker.heartbeat pid, phase, repo, sha, utc
592/var/lib/aien-run/wt/<repo>/<sha>/ the run directory of one head (operator, 0755)
593 <repo>/ the detached checkout under test
594 <dir>/ a read-only sibling checkout (../<dir> from the checkout)
595<clones>/aien-sovereign-core/tools/aien-local-ci/siblings the operator's sibling map
596/var/lib/aien-run/target/<repo>/pr|main/<sha> cargo target dir per head and trust class (sandbox user)
597/usr/local/sbin/aien-run-exec the exec helper (INFRA)
598```
599
600`<repo>` is the last segment of the repository name
601(`github.com/aien-spark/aien-sovereign-core` gives `aien-sovereign-core`).
602
603## Tests
604
605`cargo test -p aien-test` covers the planner (selection, sections, A1, A4,
606removed gates, verdict algebra), the sandbox rewrite, status parsing, the
607gate verdict of `verify-bundle`, the worker's name and sandbox rules, and in
608`tests/local_ci.rs` the pipeline end to end on a throwaway repository: a
609worker run that `verify` reports READY, then the refusals: an altered
610receipt, a bad signature, a bundle presented for another commit, a required
611check left out of a re-signed bundle, a hardware-scoped cached result under
612`--release`, an executor whose key is not in `verify.pub`, a signing key
613another uid cannot read, a signing key with mode 0644, an entry for another
614check id, a receipt made from another manifest, `--sandbox none` without
615`--dev-unsandboxed` or with `--github` (library and CLI), unsafe repository
616names and commit ids, a status that is never `success` when the independent
617check is not READY, GitHub down then back (fake `gh`), an outbox that
618replays in queue order and stops at the first refusal, a trigger file served
619by the loop, a head on main checked against its first parent, a bare
620`exec: true` running, escaping exec paths refused and a symlinked exec that
621leaves the tree never run, and, when the helper is installed, a gate and a
622whole worker run in the user sandbox through `wt.sh` (in
623`/var/lib/aien-run/wt/aien-test-selftest`, because the sandbox does not share
624`/tmp`), a wrong target dir refused by the helper with exit 2 and never
625counted as the program's exit, only a root-owned `wt.sh` link trusted, and
626the user sandbox refused without the worktree tool, and siblings: a gate
627that reads `../sib` fails without the map and passes with it, the run
628directory and both worktree lists are clean afterwards, a malformed or
629unreadable map refuses the run, and in the user sandbox the sibling is
630readable but neither it nor the run directory is writable.
631`mutations/run_mutants.sh` must
632kill every line of `mutations/aien-test.mutants`.
633
634## Accepted limits (ENGINE-2 review, 2026-10-11)
635
636- A head that no branch names is fetched into the `wt.sh` mirror by its id;
637 its objects stay there unreferenced until git prunes them. The mirror is
638 readable by `aien-run`, like every other object in it.
639- While a worktree is trusted, the worker sets `GIT_CONFIG_COUNT` and
640 `GIT_CONFIG_KEY_n` / `GIT_CONFIG_VALUE_n` on the git and crumb processes it
641 starts; a value of these variables in the worker's own environment is
642 replaced for those processes.
643- The `main` target dir is not wiped after a FAIL or timeout yet (A2 asks for
644 it); the dir is owned by `aien-run`, so the wipe has to run through the
645 helper or `sudo -n rm -rf`. Until then a poisoned `main` target dir is
646 cleared by INFRA's `gc.sh` or by hand.
647- `--dev-unsandboxed` runs are not marked in the bundle (the executor class
648 stays `spark`); only the journal and the command line show it. Never use
649 it on a machine whose bundles are published.
650- A `cached` entry is trusted through the bundle signature; `verify` does not
651 reopen the receipt it was resolved from.
652- `verify` has no `--operator`: a pipeline-configuration change is never
653 READY, also after the operator ran it by hand with `worker --operator`. The
654 operator merges such a change himself (A1).
655- A head whose base is a root commit with no parent cannot be planned on the
656 base line (the worker reports an error, never PASS).
657- Build time is `n/a` in the report. Total time comes from the bundle's
658 whole-second timestamps, so a run inside one second reports `0 ms`; the
659 per-gate test time is exact.
660- A sibling is as fresh as its trusted clone: the worker fetches the clone
661 of the repository it serves, not the sibling's clone (SANDBOX lane,
662 2026-10-11). The commit used is journaled, so a stale sibling is visible.
663- The sibling map and `wt.sh` are read from the trusted clone of
664 aien-sovereign-core; after a change to either merges, that clone's
665 checkout must be moved to the new main by the operator before the worker
666 uses it (the worker never touches a clone's checkout).
667- Five aien-test self-tests (`a_wrong_target_dir_is_refused_by_the_helper`,
668 `user_sandbox_when_the_helper_exists`, `worker_in_the_user_sandbox_is_ready`,
669 `worker_in_the_user_sandbox_reads_a_read_only_sibling`,
670 `worker_provides_a_sibling_checkout_and_removes_it`) start a sandbox or
671 provision sibling worktrees themselves, which `aien-run` cannot do inside the
672 sandbox. They skip only when `AIEN_SANDBOX_NESTED=1`, which the sandbox
673 wrapper sets for every program it runs (`sandbox::NESTED_MARKER`); they run
674 on GitHub runners and in operator runs. SC-TEST and SC-AGENT-PREFLIGHT record
675 the skip as the observation `nested_sandbox_skips`.
676- The model mount exposes the whole of the operator's `~/models` read-only to
677 every sandboxed gate (all model files, and anything else kept there).