Contracts, Charter & Verification Gates Audit — PR #734
selene: parallelize startup disk scan and coalesce small header reads · head 015076e · base main @ 22d2ac9
Changed files (pr_files): selene/src/shared/record.rs (+424/−23), selene/src/input.rs (+130/−7). Nothing else.
Verdict: one Major contract/verification gate miss (served-workload A/B evidence), one Minor documentation-contract drift, no blockers on core-format/wire/graph boundaries, vendored code, or cross-PR dependencies. No failing tests or CI failures are reported anywhere, so no failing-test gate applies.
Gate 1 — Signed core-format / wire / captured-graph / public contract boundaries: PASS
- No new proto, core-format, captured-graph enum, wire kind, or graph operation family. The diff touches only two Selene files. No
*.proto, nohelios/src/core/*, noignition/*, nodocs/core-format-design.md(not opened) surface, nodocs/scheduling-theory.md(not opened) /docs/scheduling-runtime-design.md(not opened) invariant.docs/design-review.md:22-26(op-family approval) andAGENTS.md:377-382(captured-graph contracts) are not triggered, so the "recorded owner approval" requirement does not apply. - No new public API.
par_mapispub(crate)(selene/src/shared/record.rs:1148), soselene-managercannot and does not gain a new dependency on it;pub(crate)visibility is unchanged from the base's absence.PARALLEL_SCAN_THRESHOLD/MAX_SCAN_WORKERS(:1142,:1144) are private consts. Header::read_metadatasignature is unchanged (pub fn read_metadata(mut file: impl io::Read) -> io::Result<Vec<u8>>,record.rs:361). The only contract change is cursor position, and it is documented in the doc comment (record.rs:357-360: "May read ahead past the end of the metadata … callers must not rely on the reader cursor position"). I verified all five production callers are cursor-safe:selene/src/disk.rs:1478— the openedFileis retained, but every later read is positional:read_exact_atatdisk.rs:1464for packed reads,io_uringopcode::Read::…offset(chunk.offset)atdisk.rs:1985-1988, Windowsqueue.submit(slot, file, addr, len, chunk.offset, write)atdisk.rs:2148-2149. No sequentialread/seekon that handle exists (grepforreading.fileyields onlyread_exact_atand theRing::transferpositional paths).selene/src/shard.rs:1202and:1251— handle is a temporary, dropped in the same expression/call.selene-manager/src/disk.rs:77—Header::read_metadata(File::open(entry.path())?), temporary dropped per iteration.selene/src/shared/record.rs:1334(inspect) — handle dropped after the call; only the returned block andsymlink_metadatalength are used.- Test-only callers (
selene-manager/tests/packed.rs:526(not opened),selene/src/offload/sharded/tests.rs:450-451(not opened), newrecord.rs:2474+) are unaffected. The described read-ahead can pull ≤ 4 KiB of the first page segment into a stack buffer and discard it (record.rs:376-379); no current caller observes it.
record::scan's public contract (ordering, return) is preserved. Signature unchanged; the deterministic reduction keepsrecords.sort_by_key((consumed_tokens, digest))(record.rs:1300) andremove_orphansis untouched. Symlink semantics are unchanged and now pinned by test (symlinks aresymlink_metadata-inspected and treated asAbsent,record.rs:1246-1258; the input side usesentry.file_type()atinput.rs:530-535), matchingdocs/prefix-cache-offload.md:677-680("validates magic, version, identity, fingerprint, name … deletes temporary files"). Otherrecord::scanconsumers (selene-manager/tests/client.rs:2357 (not opened),2431,2558,selene-manager/tests/packed.rs:469(not opened),helios/src/offload/gpu_tests.rs(not opened)) call it unchanged.- No on-disk format change: no
Header::encode/packed::REVISION/.inputHEADER = 88change (input.rs:21), noCargo.tomlchange, no dependency added (selene/Cargo.toml:22-51untouched;libcalready present at:28, and the newlibc::geteuid()use is inside a#[cfg(unix)]test with a justified// SAFETY:comment).
Minor (documentation-contract drift, not a blocker): docs/prefix-cache-offload.md:684-690 states that across a restart "partial temporary files are discarded" and :677-680 states the startup scan "deletes temporary files"; :1180-1182 states startup fails if scanning or cleanup cannot establish disk usage. The new fail-closed ordering returns an Unreadable error before deleting .tmp/invalid files (record.rs:1265-1277) and before unlinking .input.pending (input.rs:554-567), so on the failure path temporaries survive where the old code had already deleted them. Because startup aborts on that error (input.rs:506-510; offload.rs:750-761 propagates with ?), the accounting invariant at :1180-1182 still holds and the next startup removes the leftovers — the end state on the success path is identical. Still, the normative prose at :677-690 is the contract this PR changes behavior under, and AGENTS.md:233 names docs/prefix-cache-offload.md as required reading for Selene changes. Recommend one sentence there for the fail-closed ordering (and for the new deterministic .input admission order, which is undocumented anywhere, unlike the checkpoint path at :250).
Gate 2 — Vendored upstream dependencies & cross-PR conflicts: PASS
- No vendored upstream file is modified or forked: nothing under
helios/native/(e.g.roce_proxy.c(not opened)), nothird_party, no submodule, no lockfile, noCargo.toml/uv.lockedit in the diff. - No unmerged external recipe/PR dependency. The change is self-contained on
main@22d2ac9; the description recordsgit merge-tree --write-treeclean and identicalgit archivebases. The sibling PRs #496/#497 are already merged and are not required (no shared hunks — they touchdisk.rs/disk_store.rs(not opened)/shard.rs, this touchesrecord.rs/input.rs). No pin or link to an external branch is relied on.
Gate 3 — Mandatory verification evidence: ONE MAJOR MISS (evidence), otherwise PASS
Major — performance claim lacks an attributable served-workload A/B measurement. The governing rules are explicit:
- Charter, Bring real evidence: "Performance PRs need benchmarks showing an actual speedup over
mainon a served workload (#210)." docs/design-review.md:106-115(principle 12): "Performance claims require equivalent baselines, complete GPU steps across all ranks, and actual Helios service measurements … Keep raw measurements and disclose unrun checks and material limitations. Satisfy every applicable layer of the testing hierarchy."docs/core-design.md:1828-1856(Performance acceptance): the minimum measurement set includes a Startup row, and "Report individual workloads and tail latency; an aggregate win does not erase a workload regression."
The PR measures the right baselines (control 22d2ac97 vs candidate 015076ec, interleaved A-B-B-A, two architectures, cold/warm, medians with p10–p90) — but only at component level: in-process record::scan and InputStore::start_bounded. The description states this plainly: "These are isolated component microbenchmarks, not end-to-end flare run startup timings." No flare run / Prepare host prefix cache measurement exists, on either architecture, in any round.
Why this is a real gate miss rather than pedantry here:
- The claimed benefit is operator-visible startup latency, and the measurement surface already ships and is documented —
selene/src/offload.rs:750-765recordstimings.disk_scanaroundrecord::scanandInputStore::start_boundedinside thePrepare host prefix cachephase, withon_step("scanning disk records"), and it is documented atdocs/prefix-cache-offload.md:1070-1076. Aflare runcold-restart A/B would require no new instrumentation. - The PR itself declares a served-path regression: warm
InputStore::start_boundedon x86_64, 1,000 files,2.09 → 2.53 ms(0.83x, +0.44 ms), with the cause "not separately isolated by ablation", plus bimodal aarch64 warm distributions with overlapping arms.docs/core-design.md:1834-1836("an aggregate win does not erase a workload regression") means a declared regression on a common restart path needs the served measurement to establish whether it is even visible, and an ablation to attribute it. Without either, the regression is unresolved by the PR's own evidence. - The ~200-line harness is not in the diff (
pr_files= 2 files;selene/Cargo.tomldeclares only therank_nodeexample,:57-59). It exists only as pasted prose, which conflicts withAGENTS.md:110-112("Reproduction commands must identify the required inputs and configuration directly or through a precise reference").
Required to clear the gate: one flare run (exported core, local disk tier) restart A/B on main vs head, cold and warm page cache, report Prepare host prefix cache / disk_scan duration — plus an ablation isolating read coalescing from par_map (and, for the warm .input regression, entries.sort() vs thread-scope setup) that #497's review round also asked for.
Not applicable — correctly omitted, not a miss:
- TLA+
verification/helios-lifecycle/check.py(not opened) (docs/design-review.md:209-220): the trigger list is admission, fences, generations, cancellation, speculation accounting, cache compaction, snapshot aliases, response buffering/ownership, offload aggregation, readiness, rank coordination. This diff changes none:selene/src/shard.rs(offload aggregation) andhelios/src/*schedulers are untouched; the change is confined to pre-serving startup directory inspection, no ownership/ordering protocol state. Running it is not required. - Kani (
docs/design-review.md:221-225): triggers are completion-vector validation, prepared completion contracts, state-view extent arithmetic, sequential validators over an input domain.record::scanandWorker::scanare none of these; the new arithmetic is bounded buffer indexing insideread_metadata, covered by the new unit test over short reads/EINTR/truncation/invalid directory length. - Mutation testing: triggers "adding or changing safety guards" in the modeled domain; the fail-closed error-before-delete ordering is covered by two new tests (
record.rsparallel_scan_preserves_directory_on_unreadable_entry,input.rsparallel_scan_preserves_directory_and_budget_on_unreadable_entry) that would fail if the ordering were reverted. - GPU/CUDA/VMM and scheduler/worker-lifecycle paths: untouched. No core-format change, so no live export/serve + legacy core replay is required (principle 13 unaffected: no protobuf addition, no wire identifier removal, no reader removal).
No failing test or CI evidence to act on. Nothing in the description, the dossier, or pr_comments reports a failing check. selene-spark-pipeline-style CI is not evidenced either way; per calibration I am not flagging CI absence. The author reports 591 selene tests (test-support) and 566 (--no-default-features) passing on both bare-metal aarch64 GB10 and containerized x86_64, non-root, with both 0o000 unreadable-entry tests and the live-symlink test executing rather than skipping — counts consistent with the new tests visible in the diff. The one admitted hardware gap (no native Windows execution) is disclosed and would be exercised by .github/workflows/native-serving.yml:53-55 (not opened) (windows-2022, cargo test … selene), since the new scan tests are not #[cfg(unix)]-gated except the two permission tests that self-skip via modes_restrict_user().
Gate 4 — Material scope / claim contradictions: PASS
- Every named test exists in the diff.
read_metadata_uses_single_read_for_v3_and_small_v4_and_handles_large_v4(record.rs:2474, with 37-byte short-read on v3 and v4, one-shotEINTR,UnexpectedEofon 4095-byte v3 and truncated v4 directory,InvalidDataon directory length 0 andMAX_DIRECTORY + 1);parallel_scan_handles_large_mixed_v3_v4_directory_deterministically(140 valid + 12.tmp+ 10 truncated + 10 bogus + 6 wrong-identity + 10 orphans; foreign file,nested.ckptsubdirectory, dangling and live symlinks all asserted to survive; second scan asserted equal);parallel_scan_preserves_directory_on_unreadable_entry;input.rsparallel_scan_recovers_large_directory_deterministically_under_tight_budget(140 records,keep_count = 80, budget-tight) andparallel_scan_preserves_directory_and_budget_on_unreadable_entry(80 valid + corrupt +.pending+0o000blocked, assertingcheckpoint_limit/checkpoint_pressureuntouched andreserve_input(limit)still succeeds). No phantom test or benchmark is claimed. - No unrelated tooling bundle. +554/−30 in two files, of which +419 are tests inside the same modules. No new example, binary, script, or docs file is added to the tree.
- Claim-vs-diff consistency. "0 production
unsafe" holds (the onlyunsafeislibc::geteuid()in a#[cfg(unix)]test with a// SAFETY:comment); "0 new dependencies" holds; "+105 net production LOC" is arithmetically consistent with +554 − 419.
Info / Nit (correcting the Discovery Dossier, not a gate violation): Dossier Key finding 7 calls the deferred deletion and the lexicographic .input admission order "undeclared behavioural changes". They are declared in the PR body's Worker::scan and record::scan bullets ("sorts .input paths lexicographically", "rejects non-InvalidData I/O errors before unlinking .input.pending files or mutating self.disk/self.budget", "returns any Unreadable error before deleting .tmp or invalid entries"). They are undeclared in the docs, which is Gate 1's Minor above. Likewise the dossier's "selene-manager is only half covered" is fair as an effect caveat (selene-manager/src/disk.rs:71-98 identity pre-pass stays sequential because par_map is pub(crate)) but is not a contract or scope violation.
Summary
| Gate | Result |
|---|---|
| 1. Core-format / wire / captured-graph / public contract | Pass — no proto/wire/graph change; read_metadata signature unchanged with documented cursor semantics and all 5 callers verified cursor-safe; par_map is pub(crate). Minor doc drift on the fail-closed deletion ordering (docs/prefix-cache-offload.md:677-690, :1180-1182) and the undocumented .input admission order. |
| 2. Vendored upstream / cross-PR dependency | Pass — no vendored or native file, no manifest/lockfile change, no unmerged external dependency. |
| 3. Mandatory verification | Major miss (evidence only) — performance claim has an attributable main-vs-head A/B but only at component level; no served-workload (flare run / Prepare host prefix cache disk_scan) measurement, a declared warm .input regression (0.83x) unresolved, and an uncommitted harness, against charter #210, docs/design-review.md:106-115, docs/core-design.md:1828-1856. TLA+, Kani, mutation, GPU and core-replay gates correctly not applicable. No failing tests/CI reported. |
| 4. Material scope / claim contradictions | Pass — all named tests present, focused diff, no unrelated tooling. |
Blockers: none. Should fix before merge: (1) the end-to-end Prepare host prefix cache / disk_scan A/B on main vs head, cold and warm, on at least one architecture, plus a coalescing-vs-par_map ablation that resolves the warm .input regression; (2) commit or reference the benchmark harness so the numbers are reproducible from the branch; (3) one paragraph in docs/prefix-cache-offload.md covering the fail-closed deletion ordering and the deterministic .input admission order.