Gate P5a — File-level code anchors¶
Status: Passed (2026-11-02). G0 passed 2026-10-21 (ADR 0011 r0.3, independent G0 review; r0.4 §9, r0.5 §10 and owner policy r0.6 §11 amendments). The implementation passed an independent counterexample review; its findings are fixed or listed below. Passed 2026-11-02, when P4 passed (SPEC A11, v1.6.12). Live .contextdb/bin and .contextdb/db are untouched.
Scope¶
SPEC SD18, SD14b, §5 P5a, §6.5 path filtering and pre-push range checks. No symbol parsing, branch product API, validators or ACL.
Gate matrix¶
| Layer | Requirement | Result | Evidence |
|---|---|---|---|
| G0 | ADR 0011, SPEC ambiguity closure, independent review | Pass | ADR 0011 r0.3; SPEC v1.6.1 |
| G1 | fmt, Clippy, workspace tests, deny, dependency boundaries | Pass | bash scripts/check.sh on macOS and on Linux (remote Ubuntu 24.04) for the final tree; GitHub Actions still starts no job (account billing) |
| G2 | T42a, T42c, T43, T43b, T44, T46b, T46c, S13-rows-e2e | Pass | anchors/tests/anchors.rs (T42/T43/T46b with exact oracle counters, T44 incl. Sem asserted-p closure, descriptor/OID bounds, raw SHA-1/SHA-256 OIDs vs Git, symlink/FIFO/socket/nested-.git, gitlinks); daemon/tests/anchors.rs (T44 for read/recall/check, T46c incl. case alias, hard link, symlink, nested repository and gitfile fallbacks, strict root proofs across restart, legacy MissingBaseline, range binding); cli/tests/anchors_cli.rs; proto/tests/observation_cutoff.rs |
| G3 | PROP12, 10,000 fixed seeds, coverage; classifier mutation | Pass | PROP12 rewritten to the ADR: generated multi-file histories, Git fast-import/cat-file as the independent record, oracle re-encodes descriptor/position bytes and never calls the classifier. 100,000 transactions: delete 26,802, identical restore 7,153, old-head ABA 22,673, CAS retry 5,701, lag 6,850, unavailable 7,090, unsupported paths 5,971, SHA-256 2,000 (all above the floors). Injected classifier bug (no AssertBase on restore) is caught. Mutation of classify.rs on the final tree: 19 mutants, 19 caught |
| G4 | interruption, CAS concurrency, missed wakeups, restart/failure | Pass | Observer batch interrupted at every store step (append, write, sync, sync_weak, rename, sync_dir, sync_dir_weak) then crashed with torn/zero/garbage tails: state is wholly before or after, rescan converges; corrupt descriptor → scope Unknown; racing wakeups commit once; racing restores of a broken anchor lose on the watermark CAS; watch/restart/missed wakeup/oversized file in the CLI test. Semantic goldens use a 2 s sample deadline (set_anchor_live_timeout) so a cold sample on a loaded machine is not Unknown; the production 40 ms budget is measured in G5 |
| G5 | P4 hook budgets; capture/reconcile costs at 10/100/1,000 anchors | Pass (rule: owner decision 2026-10-22) | p5a-g5-anchors.txt, confirmation run at load ≈ 8–10 on tree a89258e: p5a_g5_pass=true. 10/100 anchors: every certified read, 0 capture failures, hook p95 ≤ 7.1 ms, p99 ≤ 13.6 ms. 1,000 anchors (the supported bound): capture p95 18.5–19.2 ms, 0 capture failures, 972–982 of 1,000 certified reads (the rest Unknown, fail closed), hook p95 36.2–37.3 ms, p99 50.4–50.5 ms (budgets 50 / 100 ms). Capture is parallel, reuses gitlink decoding while the index bytes are identical and the opened repository while its identity holds; descriptor checks run beside capture; the hint cutoff is O(1) (r0.4). Earlier runs on a loaded desktop (load 12–55) are in the file's history |
| G6 | ≥3 real repos × ≥1,000 commits; ≥200 agent-labelled stratified pairs (ADR 0011 r0.6 §11, SPEC v1.6.4) | Pass (agent-labelled baseline, r0.6) | 3,000 commits through the real daemon/observer, 1,352 pairs, 0 Git disagreements. 210 agent labels and hashed evidence, 35 per repository × fired/not-fired. Existing optional human audit: 84 judgments, 80 agree, 4 contested; the remaining 126 are AI-only. No manual top-ups or human agreement threshold. Contested pairs stay outside headline rates with both resolutions reported. Current report and raw score: p5a_g6_evidence_complete=true. Command: anchor_replay score --assisted docs/gates/p5a-g6/ai-review/proposals.tsv docs/gates/p5a-g6/*.tsv after the hash check. Rates are agent-labelled stratified diagnostics, not population rates or independent human truth. Supported lowercase paths only (ripgrep 129/184, click 95/115, fd 32/38 at the start commit). |
| G7 | P0–P4 regressions; P4 must pass first | Pass (P4 pending) | scripts/gate-regression.sh (now incl. P5a suites) on the remote host for the final tree: G7 PASS |
| G8 | README, semantics, CHANGELOG, status | Pass | README §文件级代码锚点(P5a), CHANGELOG, IMPLEMENTATION_STATUS |
| Independent review | non-implementing counterexample review | Pass with open items | See below |
Independent implementation review (2026-10-21)¶
No blockers. Fixed with regression tests unless noted:
- M1 path filter ignored nested repositories/linked worktrees inside the bound repo (wrong Allow): any intermediate
.gitnow forces a full check. - M2 outbox streams are never deleted; the per-stream hint cutoff opened every stream twice per sample and errored above 1,000, so live evidence would eventually fail closed for every anchor. Fixed by ADR 0011 r0.4 (§9) after its own G0 review and closure check: hooks announce before appending an Action fact (random epoch + counter, replaced whole by rename); ctxd reads the record before the first and after the last capture; missing/corrupt/unequal records, a failed announce (record unlinked,
announce.failedsentinel,ctx anchors repair-announce) or a missingannounce-v1appender marker are Unknown; dropped facts no longer gate freshness. Tests:proto/tests/announce.rs(2,000 streams, corruption, delete/recreate, marker, sentinel, failed announce, dropped edit, kill points). - m1 Unix socket at an anchor path (EOPNOTSUPP) made the scope Unavailable: now Broken.
- m2 cached repo identity now covers the
.gitentry (gitfile) and the canonical root. - m3 per-root vector merge was order-dependent: earliest read wins (fixed; no dedicated test).
- m4 case-alias registration: exact on-disk spelling required.
- m5 Open (documented limit): the gitlink decode reads the whole index (≤ 8 MiB, about 80k files); index rewrites during capture give Unknown.
- m6
.gitprobe errors other than ENOENT are Unavailable; a.gitsymlink is Broken. - m7 the watermark CAS is first in the batch, so a racing loser retries.
- Git hooks: a failed scan no longer fails
git checkout/commit/merge.