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. |
||
|
|
b49ea488fb |
feat: make the Stop hook and session recovery fire everywhere, add long-run injection controls
The Stop scalar never dispatched on macOS or Linux (the PowerShell branch was always selected because check-complete.ps1 ships on every platform) and was a silent no-op anywhere CLAUDE_SKILL_DIR was unset (the :- install path fallback can never substitute because the probed variable is always a non-empty string). Both the legacy completion advisory and the v3 completion gate were dead in those environments. The scalar now selects targets by file existence and dispatches by platform, PowerShell only under MINGW/MSYS/CYGWIN, sh elsewhere. Windows output is unchanged. Patched in all 14 SKILL.md variants that carry the scalar. session-catchup probed a ~/.claude/projects name that Claude Code never writes for POSIX paths (leading dash stripped) or paths containing an underscore (replaced with a dash), so recovery after /clear silently found nothing there. The mapper now probes the exact spelling first, keeps both legacy spellings for stores created by older versions, and settles ambiguity via the cwd recorded in the newest session file. Propagated to every shipped copy including the older-generation root, .hermes, and .mastracode scripts. Also: the attestation SHA cache is keyed on the absolute plan path so two projects can no longer share a slot and report a false PLAN TAMPERED; resolve-plan-dir.ps1 reaches parity with the sh resolver (slug filter, task_plan.md requirement in the newest-dir scan, fail-closed containment); ledger-append.sh no longer truncates summaries mid-codepoint (UTF-8-safe trim via iconv with a pure-sh fallback). New long-run features, all opt-in or additive: structure-aware injection (PWF_INJECT=smart or an inject-smart .mode token) keeps the active phase, phase counts, and the last three decisions in the window late in long plans; a Next Step section in both plan templates plus a sixth reboot question; session-catchup annotates tool results (ok or FAILED with the first error line) instead of only listing attempts. Infrastructure: macos-latest joins the CI matrix, a BSD-userland simulation harness runs the script fleet without realpath, readlink, flock, or sha256sum on the Linux leg, and .gitattributes pins LF for scripts. SEO surfaces: llms.txt rewritten as a Q&A page, three problem-query docs pages, plugin.json and CITATION.cff keyword hygiene. Suite grows from 217 to 301 passed, 11 skipped, on Windows and both existing CI legs; default hook output stays byte-identical to v2.43 (legacy invariant proven by the existing invariant tests). |
||
|
|
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. |