Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4730c26be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| echo "error: staged copy changed after sync for slot=$slot run=$run; source preserved" >&2 | ||
| exit 1 | ||
| fi | ||
| mv -n "$stage_entry" "$destination" |
There was a problem hiding this comment.
Publish to the exact destination path
Captain, if another process creates $destination as a directory after the existence check, the mv --help SOURCE... DIRECTORY form means this command moves the staged entry to $destination/item rather than leaving it unpublished; -n only prevents overwriting an existing file. The subsequent check sees $stage_entry gone and reports COPIED, so this collision mutates the canonical run before later verification merely defers source cleanup. Use an atomic no-replace operation that treats $destination as the exact target path.
Useful? React with 👍 / 👎.
Intent
Implement Decision OS bead dos-3ndcm so every Firstmate-launched Decision OS Treehouse lane writes review evidence directly into the canonical shared data/local/reviews store. Use the canonical project path already owned by Firstmate lane allocation and bind the lane before worker launch; refuse ambiguous or wrong-project paths, missing or non-directory canonical destinations, and any conflicting real lane review directory that may contain evidence, without overwriting or hiding evidence. Preserve all behavior for projects that do not expose the Decision OS review-store symlink contract. Add public-interface regressions for clean setup, idempotent repeat, a pre-existing correct link, conflicting evidence, wrong or missing canonical target, and non-Decision-OS work. Provide the narrowest guarded one-time migration owned by Firstmate: inventory every pool copy, detect active or changing runs including rechecking activity before source retirement, copy first, verify exact path/type/byte completeness and SHA-256 manifests, refuse non-identical collisions, remove sources only after durable verification, and resume safely after interruption. Do not run the real migration during implementation or validation; report the exact guarded command and read-only preflight evidence for Firstmate to execute only after the code lands. Do not modify Decision OS project files, prune branches, broadly clean pool slots, or alter unrelated Firstmate behavior. Validate relevant backend and Treehouse behavior, pinned ShellCheck lint, documentation audiences, tests, and CI. Create a green pull request whose title contains dos-3ndcm. Delivery remains incomplete after merge: Firstmate separately owns executing the migration, verifying canonical gate visibility and reclaimability, appending the Closure-Receipt, closing dos-3ndcm, and landing that tracker close in the same shift.
What Changed
bin/fm-spawn.shnow binds every Decision OS Treehouse lane to the canonical shareddata/local/reviewsstore before worker launch (symlink via the lane's canonical project path), refusing wrong-project or ambiguous paths, missing/non-directory canonical targets, and any conflicting real lane reviews directory that could hold evidence; projects without the Decision OS review-store symlink contract are untouched.bin/fm-decision-os-review-migrate.sh, a guarded one-time migration for existing pool copies: dry-run inventory by default, defers in-use or process-bearing slots (with an activity recheck before source retirement, including the empty/missing-reviews branches per the review pass), copy-first with exact path/type/byte and SHA-256 manifest verification, refuses non-identical collisions, removes sources only after durable verification, and resumes safely after interruption. The real migration was not run; it remains a separate guarded--applystep.tests/fm-spawn-decision-os-reviews.test.sh(5 cases) andtests/fm-decision-os-review-migrate.test.sh(8 cases), wired intobin/fm-test-run.sh, plus adocs/scripts.mdentry for the migration script.Risk Assessment
✅ Low: The follow-up commit precisely implements the requested guard — active slots are deferred before any review-path mutation, link failures degrade to per-slot refusals instead of set -e aborts, and a new public-interface regression proves --apply leaves in-use slots untouched — with no unrelated behavior changes and all prior concerns either fixed or explicitly waived.
Testing
Ran both new regression suites (13 tests, all passing) and a manual end-to-end demo driving the real fm-spawn and migration scripts against fixture Decision OS projects; the transcript shows lane evidence landing in the canonical shared store, fail-closed refusals that preserve evidence, unchanged behavior for non-contract projects, a verified mutation-free preflight, and a fixture-only guarded apply — the real migration was not executed, matching the intent's constraint.
Evidence: End-to-end CLI transcript: spawn binding, refusals, preflight, and fixture apply
Evidence: Demo script that produced the transcript (fixture-only, real scripts)
Evidence: Key transcript excerpt: lane write-through and guarded apply
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 3 issues found → auto-fixed ✅
bin/fm-decision-os-review-migrate.sh:245- Under --apply, the reviews-path-missing branch (lines 243–250) and empty-reviews-dir branch (lines 266–274) execute mkdir/rmdir/ln -s before the slot activity check at line 278, so an in-use, process-bearing slot with a missing or empty reviews directory is mutated while its worker runs. This contradicts the script's own header contract ('Apply defers every in-use or process-bearing slot'), and because rmdir/ln -s are unguarded under set -eu, a racing worker that recreates or populates the directory between the check and the mutation aborts the entire migration mid-run. No evidence can be destroyed (only empty/absent directories are touched), but the deferral invariant and whole-run robustness are compromised. Fix: gate the LINKED action in both branches on the same status==available && processes==0 condition (or a slot_still_available recheck), and guard the rmdir/ln failures as a per-slot REFUSE instead of a set -e abort.bin/fm-decision-os-review-migrate.sh:195- Successful migration leaves empty residue directories behind: the staging tree $PROJECT/data/local/.dos-3ndcm-review-migration/<slot>/<run_key>/ (stage entries are moved out but parents never removed, and STAGE_ROOT is never cleaned at exit) and per-slot $slot/data/local/.dos-3ndcm-review-migrated/<run>/ parents after rm -rf of the hash-keyed leaf. Harmless to correctness, but visible clutter during Firstmate's later canonical-visibility and reclaimability verification.bin/fm-spawn.sh:1500- bind_project_review_store creates the lane symlink data/local/reviews without adding it to git info/exclude, unlike other spawn-created worktree artifacts that use the exclude_path helper (defined later at line 1980). If the target project does not gitignore data/, the lane worktree gains untracked state that could trip teardown's dirty checks or leak into a worker commit. Likely moot because the Decision OS contract presumes data/local is local-only (a tracked symlink would resolve lane-locally and refuse every spawn), but excluding it would be cheap hardening.🔧 Fix: guard empty-lane review linking behind slot activity check
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-spawn-decision-os-reviews.test.sh— all 5 public-interface regressions pass (clean setup + idempotent repeat, pre-existing correct link, conflicting evidence refusal, missing/wrong canonical target refusal, non-Decision-OS unchanged)bash tests/fm-decision-os-review-migrate.test.sh— all 8 migration-guard regressions pass (dry-run inventory, active-lane deferral, activity recheck before retirement, copy/verify/remove/link idempotent apply, non-identical collision refusal, changing-source deferral, interrupted-copy resume, wrong-project/invalid-store refusal)Manual end-to-end demo (e2e-demo.sh) running the realbin/fm-spawn.shandbin/fm-decision-os-review-migrate.shagainst fixture git worktrees: lane review link created before launch, write-through of lane evidence into the canonical store, refusal transcript for a conflicting lane reviews directory with evidence left intact, non-Decision-OS project untouched, read-only preflight verified mutation-free via before/after content hashing, and a fixture-only guarded--applyshowing INVENTORY→COPIED→VERIFIED→REMOVED→LINKED with the in-use slot deferred✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.