fix(drive-local): enforce scope and selected package acceptance
A local drive tick could accept unrelated edits, an unmet package, or a replaced judge. This flow selects a bounded backlog package, runs an implementation agent, enforces scope, executes its acceptance commands and the SDK suite, rechecks scope, and reports the diff.
node scripts/run-drive-local.mjs pins the original Git commit before submission. The first journaled step, gate-snapshot, extracts the package helper, verifier and SDK picker TypeScript source with git --no-replace-objects show <head>:<path>, then builds the picker in a temporary directory outside the checkout. The extraction script itself also comes from that commit. Gate inputs never come from working-tree helpers or ignored SDK dist. The work package records the ref as head, and checks compare it to the submitted pin so metadata cannot repin a moved HEAD. There is no SHA256SUMS manifest or adjacent ref file supplying integrity.
A same-user agent can still write to the temporary execution directory. The bar met here is that gate inputs come from a pinned Git ref rather than files implementation edits. Extracted runtime files are not claimed to be immutable or isolated from same-user processes. The installed TypeScript compiler and local launcher remain trusted tools.
Remaining acceptance-input decision: pinned argv can still load an agent-edited check script or dependency. Declared immutable acceptance inputs or a preserved acceptance workspace need an explicit contract before unattended readiness is claimed. No kernel or journal protocol changes; no merge was performed. Includes the unmerged generalization from #242.
Validation at f3fde5dcf05708caa704a51a8dedcf70329e6749 (literal command and captured output):
$ node --test ops/local-work-package.test.mjs ops/local-work-review.test.mjs ops/local-work-gate.test.mjs ops/local-work-git-input.test.mjs ops/drive-local-flow.test.mjs
✔ drive-local journals failure and blocks reporting for outside edit (1569.386209ms)
✔ drive-local journals failure and blocks reporting for verifier edit (1338.876042ms)
✔ drive-local journals failure and blocks reporting for unchanged package (1419.740917ms)
✔ drive-local journals failure and blocks reporting for HEAD repin (1237.099416ms)
✔ drive-local journals failure and blocks reporting for forged snapshot (1282.077542ms)
✔ committing outside scope and repinning metadata cannot replace the submitted HEAD (933.017166ms)
✔ forged legacy checkout snapshot and compiled picker cannot replace the Git-extracted judge (1304.608875ms)
✔ raw template refuses selection before implementation without captured gate inputs (174.595834ms)
✔ selection advances past rejected duplicate title: Same title (617.767041ms)
✔ selection advances past rejected duplicate title: Regex [a].* (b) + $ (600.579708ms)
✔ preparation reads the committed gate instead of a working-tree replacement (1081.631542ms)
✔ gate-snapshot builds committed picker source outside the checkout (999.972542ms)
✔ a committed picker compile failure prevents package selection (513.214333ms)
✔ an ignored compiled picker cannot become the input to selection (1016.511833ms)
✔ Git replacement objects cannot substitute gate source at the pinned ref (970.567792ms)
✔ skip cursor passes a later title mentioned in an earlier body (817.737334ms)
✔ selection skips missing checks and stale paths with reasons (804.1355ms)
✔ a non-SDK package fails unchanged and passes only after its check holds (1051.719084ms)
✔ multiple acceptance checks all execute and failures propagate (829.5705ms)
✔ scope refuses an outside unstaged path (669.861834ms)
✔ scope refuses an outside staged path (631.429708ms)
✔ scope refuses an outside untracked path (594.261792ms)
✔ scope refuses an outside staged reversal path (568.371417ms)
✔ scope refuses an outside rename path (569.997916ms)
✔ scope refuses an outside deleted path (519.848917ms)
✔ the submitted scope command refuses a changed ops/local-work-package.mjs before loading it (501.358125ms)
✔ the submitted scope command refuses a changed ops/local-work-verification.mjs before loading it (495.480167ms)
✔ the submitted scope command refuses a changed ops/BACKLOG.md before loading it (462.9035ms)
✔ editing ignored package metadata cannot widen scope or replace checks (524.0125ms)
✔ scope allows directory children but rejects a sibling with the same prefix (584.357666ms)
✔ scope allows in-scope deletions and rejects symlink escapes (606.571792ms)
✔ replacing a scoped file with a directory does not authorize its children (505.246208ms)
✔ a check that writes outside scope fails verification (586.051958ms)
✔ interrupted package write preserves the original and retry replaces it atomically (1099.643667ms)
✔ report includes an allowed unstaged change (976.478625ms)
✔ report includes an allowed staged change (911.101833ms)
✔ report includes an allowed untracked change (891.555583ms)
✔ directory scope checks a pre-existing dangling escape symlink (770.519ms)
✔ directory scope checks a pre-existing existing internal symlink (706.921209ms)
✔ selection skips untracked scope and accepts the next committed scope (510.050208ms)
✔ reporting after SDK suite effects enforces scope for outside.txt (781.408584ms)
✔ reporting after SDK suite effects enforces scope for src/value.txt (895.763ms)
ℹ tests 42
ℹ suites 0
ℹ pass 42
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 12484.159542
EXIT_CODE=0
Before-fix regression output and ownership/remaining-decision record. These are before/after reproductions, not mutation verification. No full SDK-suite rerun or independent swarm pass is claimed at this head.
[!NOTE]
Medium Risk
Changes agent-driven local execution and trust boundaries around scope/verification; a documented acceptance-script bypass remains, but production kernel paths are untouched.
Overview
Replaces the single-item F8b local drive with a general loop: SDK backlog picker selects the next bounded package (explicit paths + Verify: JSON argv), an agent implements it, then scope → package checks → full SDK vitest → final scope → report.
Trust boundary: scripts/run-drive-local.mjs builds the SDK, pins HEAD / branch / backlog hash, and submits a prepared flow where gate-snapshot extracts helpers and picker source from the pinned commit (git --no-replace-objects show) into a temp dir outside the checkout, compiles the picker there, and journals those commands before implementation. Scope/verify reconstruct package fields from the pinned backlog so ignored package.json edits cannot widen scope or swap checks; HEAD repin, forged .drive-gate/ snapshots, working-tree gate tampering, and symlink escapes are refused. Raw workflows/drive-local.yaml without the launcher fails with LOCAL_DRIVE_NOT_PREPARED.
Adds ops/DRIVE-LOCAL.md, broad ops tests (including real-daemon journal cases), runtime-evidence captures, and a BACKLOG F8b source assertion. Still blocked for unattended use: pinned argv can run agent-edited acceptance scripts (documented probe); no kernel/journal protocol changes.
Reviewed by Cursor Bugbot for commit f3fde5dcf05708caa704a51a8dedcf70329e6749. Bugbot is set up for automated code reviews on this repo. Configure here.