f473fa8930b7ea48fbfe2ee952cc032bd28eddff
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3749f86ac3 |
fix: bind explicit plan selectors, floor slug modes on the project root, and classify doctor output on the data frame
Three defects reported by Raymond Manaloto (@sortakool), each reproduced on Windows with Git Bash before any code changed. Two of them let a session work on a plan nobody selected; the third made the diagnostic that should have caught them report PASS. closes #237: an explicit PLAN_ID was a hint, not a binding resolve_from_env returned 1 both when no selector was set and when the selector was rejected, so a PLAN_ID of valid slug shape naming no directory fell through to .active_plan and then to newest-by-mtime. attest-plan.sh locked that other plan at rc=0 and injection followed it. The guard in attest-plan.sh written for exactly this case was unreachable, because the resolver never returned empty. commands/plan-attest.md has promised the opposite since v3.9.0. A non-empty PLAN_ID now resolves or stops, for every rejection reason: slug shape (traversal included), naming no directory, or failing containment. An empty value still means unset, which init-session.sh depends on. The rule went into every resolver, because they disagreed otherwise: resolve-plan-dir.sh, resolve-plan-dir.ps1, the inline resolver inside inject-plan.sh, and the Hermes, OpenCode and Pi plugin resolvers. v3.14.0 had made the two plugin resolvers fall through to match the shell; that parity was right and its target was wrong. Fixing the resolver alone would have moved the bug rather than removed it, so every consumer was audited. check-complete.sh would have read the root plan's completion state, which decides whether an autonomous run may stop. ledger-summary.sh feeds phase counts into autonomous turns. phase-status.sh and ledger-append.sh write into the directory they pick. The five Codex hooks call the resolver directly and each fell through to the legacy root, stop.sh and pre-compact.sh included. All of them now stop on a rejected selector, and the once-per-turn routes print a notice, because a fail-closed path with no stated cause would trade a wrong-plan bug for a silent one. closes #238: a slug plan with no .mode bypassed the project's root .mode A project makes attestation mandatory by committing a root .mode, a reviewed project setting. inject-plan.sh read the slug's .mode and never the root's, and init-session.sh writes no .mode unless --autonomous or --gated was passed, so init-session.sh <name>, which /plan runs, produced a plan with no attestation requirement and full injection. The policy was a flag the agent chose at plan creation. The root .mode is now a floor. Strictness-raising tokens count from either file, so a slug may raise and never lower; the one strictness-lowering token, plan-guard-off, needs the root's agreement. The same floor applies to the completion gate in check-complete.sh and check-complete.ps1, which read .mode the same way and had the same bypass, and to the Hermes and OpenCode plugins. init-session.sh seeds a new slug from the root .mode so the effective policy is visible in the plan directory, not only in the resolver. With no root .mode present the effective token set is exactly the slug's, so existing projects are unchanged. closes #236: plan-doctor.sh reported PASS on a fully dark-hooks state The injection check substring-matched five control strings against output that carries the plan body verbatim inside the BEGIN-PWF-DATA fences. A plan whose phase line read "fix the false PLAN TAMPERED warning in plan-doctor" reported a hash mismatch while correctly attested. Worse, the PWF_PLAN_ROOT arm matched a literal that is not a substring of what inject-plan.sh emits, so the arm was dead code and execution fell to the success arm: PWF_PLAN_ROOT=/nonexistent printed "PASS injection: emits plan context (123 bytes)" while nothing was injected, counting the refusal notice's own bytes as plan context. The file's own comment four lines above already warned against exactly that. Classification now branches on the frame. Every refusal path exits before frame_file runs, so a frame proves injection happened and unframed output is by construction a notice. The default arm warns, so a reworded or translated banner degrades noisily instead of silently. The stale literal is corrected against the emitting echo. Tests: Python suite 653 to 696, OpenCode Vitest 28 to 34. New files test_plan_selector_binding.py, test_root_mode_floor.py and test_plan_doctor_classification.py; new arms in test_resolver_parity.py, test_resolve_plan_dir.py, test_resolver_plan_root_pin.py and test_hermes_first_class.py. Five existing tests asserted the fall-through and were rewritten to assert the refusal, keeping their original security assertion. Each suite carries a control arm: two first drafts passed on fixtures that could not have failed, a gate assertion over a plan with every phase complete and a parallel-write-guard assertion over a plan with nothing checked to lose. |
||
|
|
ef32a32464 |
fix: resolve the plan against an explicit root and refuse ambiguous shared cwds
Plan resolution was cwd relative with no notion of a thread: PLAN_ID, then .planning/.active_plan, then the newest plan directory by mtime, every read taken relative to the process cwd. A Codex thread sitting at a shared parent such as /workspace therefore saw only the parent's pointer, and the plan of an unrelated project was injected on every prompt and every matched tool call while the nested project's own .active_plan was never consulted (#212). PWF_PLAN_ROOT binds resolution to a project root by absolute path, which a cwd relative PLAN_ID slug structurally cannot express. A pin that does not resolve fails closed with a notice rather than falling back to the ambiguous plan the caller was escaping. Containment is checked against the pin. When the plan was chosen by a cwd guess (the shared pointer, newest by mtime, or a legacy root task_plan.md) and a project one directory below carries its own live plan, nothing is injected and the notice names both escape hatches. An explicit PLAN_ID, a pin, or an attached session stays authoritative and skips the check. Detection is one glob at depth one, which is the whole per fire budget. A nested pointer that is empty or names a deleted directory does not compete, so an abandoned subproject cannot kill injection at the root. The session attachment guard from #146 now runs on this route too. It is not silent: on hosts that never set PWF_SESSION_ID every session is unattached by construction, so a stale .planning/sessions/ directory would otherwise kill injection permanently with no symptom, and .planning/ is gitignored so the state is invisible to review. The notice is turn scoped so it cannot become per tool call spam. Also fixed here, both found by the new tests: - ledger-summary.sh now takes the resolved plan directory as an argument. Under a pin it previously re-resolved from the process cwd, so an autonomous loop could read the parent's "1/1 complete" while its own pinned plan had an open phase. With no plan directory determinable it says so instead of reporting a confident 0/0. - GNU sha256sum prefixes its output line with a backslash when the filename needs escaping, which any Windows style pin triggers, so every attested pinned plan reported PLAN TAMPERED on every fire. plan-doctor reports a refusal as its own state with the remedy. It previously counted the refusal notice as bytes of plan context and printed PASS, so the one tool a dark user is pointed at gave a green light. The legacy invariant holds: with no pin, no sessions directory and no nested competing plan, output is byte identical to the previous release across every context and mode, verified by diffing captured stdout against HEAD. |
||
|
|
d5d86d5824 |
fix(scripts): ship ledger trio in root scripts/ for plugin-marketplace route
The marketplace fallback resolves dispatchers from repo-root scripts/. The review wave restored inject-plan.sh and gate-stop.sh there but not ledger-append, ledger-summary, phase-status (sh + ps1), so autonomous and gated mode on that route silently fell back to injecting the raw progress.md tail instead of the structured ledger summary. Copies are byte-identical to the skill scripts; a new location-parity test pins the full dual-shipped set in both places. |