Commit Graph
104 Commits
Author SHA1 Message Date
OthmanAdi 3827d3c018 release: v3.20.6 2026-09-23 21:58:59 +02:00
OthmanAdi b7edae42dc fix: retry transient PowerShell pointer inspection 2026-09-23 21:51:09 +02:00
TayfurYldz abd39f7e9b fix: retry concurrent PowerShell pointer replacement 2026-09-23 20:55:49 +02:00
TayfurYldz 388b591f77 fix: recover PowerShell bracketed project cwd 2026-09-23 20:55:43 +02:00
TayfurYldz a3bd42954b fix: reject read-only active plan pointers 2026-09-23 20:55:38 +02:00
kuei51307-hub f7b9be9d58 fix(locking): claim phase status lock atomically 2026-09-23 20:54:59 +02:00
Shaun Lin f869dfb4d0 fix: fail PowerShell init on denied writes 2026-09-21 20:57:40 +02:00
kuei51307-hub 428b96c982 fix(init): report attestation failures 2026-09-21 20:57:36 +02:00
TayfurYldz 5ad5452276 fix: tolerate malformed OpenCode replay parts 2026-09-21 20:56:53 +02:00
OthmanAdi 3a4f2077be fix(powershell): attest-plan.ps1 refuses only name-surrogate reparse points
ValidateRegular in the attester's native helper threw "Refusing a
reparse-point file" for any file with the ReparsePoint attribute, so in a
project under OneDrive (Files On-Demand marks every synced file, tag
0x9000601A) attestation, --show and --clear all failed, and init-session.ps1
still printed "attested" because it swallows the attester's failure. The
check now refuses only name-surrogate tags (bit 29 set: symlinks, junctions
and any unknown surrogate), which is exactly the set Windows path parsing
follows, so the security property is unchanged and placeholder files read
as the regular files they are. Every mirror synced (#275).
2026-09-19 20:35:25 +02:00
OthmanAdi a33fc3eb1a fix(powershell): the .active_plan pointer check is LinkType, not the ReparsePoint attribute
resolve-plan-dir.ps1, the Cursor hook resolve-plan-context.ps1 and the
set-active-plan.ps1 writer refused an .active_plan pointer that carried the
ReparsePoint attribute. OneDrive Files On-Demand marks every synced file as
a reparse point, so in a project under OneDrive the Cursor hooks stopped
with the unsafe-pointer notice, the resolver printed nothing for
attest-plan.ps1 and check-complete.ps1, and set-active-plan.ps1 refused to
write, while every other route read the pointer normally. The three checks
now refuse a container or a LinkType of SymbolicLink or Junction, the same
predicate v3.20.3 gave the directory checks and the `[ -L ]` of the shell
scripts. Every mirror synced. Tests cover the plain pointer and the
symlinked pointer (skipped where file symlinks need a privilege). Fixes #275.
2026-09-19 20:18:27 +02:00
OthmanAdi f54f8144c2 fix(scripts): match symlinks and junctions only, and keep linked directories out of set-active-plan
Review of the previous two commits found the PowerShell resolver testing the
ReparsePoint attribute, which every OneDrive Files On-Demand directory
carries: a project under OneDrive would have lost every plan on the Cursor
route. The resolver now tests LinkType for SymbolicLink or Junction, the
exact `[ -L ]` of the shell scripts and is_link of the Python twin, and the
Codex counter uses the same symlink-or-junction tag rule instead of the
adapter's any-reparse helper.

set-active-plan.sh and set-active-plan.ps1 refuse to point the shared
default at a linked directory and leave it out of --list, since no route
selects it; the sh/py/ps1 suites cover PLAN_ID naming a link (refused with
the existing notice) and the pointer naming one (falls through to the real
plan like a stale pointer). Hermes docstring names the routes precisely (#270).
2026-09-19 11:13:08 +02:00
OthmanAdi 0308a2f819 fix(scripts): a linked plan directory is never selectable, on every shell-family route
PR #271 made the several-plans counters in inject-plan.sh and
resolve-plan-dir.sh skip symlinked and junctioned plan directories, matching
the Hermes plugin. Skipping the link in the counter alone left the selection
paths following it through containment: one real plan plus a newer linked
one counted as one plan and the newest-mtime scan then selected the linked
directory, the mtime guess the #240 rule exists to prevent. The PowerShell
twin reproduced that after the counter port.

The rule now holds end to end in the shell family: resolve-plan-dir.sh,
inject-plan.sh, resolve-plan-dir.ps1 and the Python twin inject-plan.py
refuse a linked plan directory in the PLAN_ID, .active_plan and
newest-mtime branches and never count it. Every shipped copy is synced.

Tests: the sh/py parity suite gains the linked-directory fixture (the twin
contract), and test_unarmed_plan_ambiguity drives both resolvers and both
injectors over a real plan plus a junction or symlink (#270).
2026-09-19 10:43:59 +02:00
Shaun Lin 0bbc43cff3 fix: skip linked plan dirs in ambiguity counts 2026-09-19 10:36:51 +02:00
OthmanAdi c05821a1cf fix(init): bind the attest selectors in slug mode only, clear them in root mode
Binding PWF_PLAN_ROOT for the attestation call in both modes (#265) made
root-mode --autonomous and --gated plans unattested on the shell and the
PowerShell route: the attester only falls back to the legacy ./task_plan.md
when no selector is set and refuses the root plan under an explicit pin,
while init still reported the plan as attested and every hook then refused
to inject it. Slug mode keeps the binding from #265 (PWF_PLAN_ROOT and
PLAN_ID name the plan just created); root mode now clears both selectors,
which also stops an inherited PLAN_ID from redirecting the shell attester
to a sibling slug plan, as the PowerShell twin already did (#261).

Regression tests cover root-mode attestation for --autonomous and --gated
with and without an inherited PWF_PLAN_ROOT and PLAN_ID, on both routes.
2026-09-18 17:32:57 +02:00
TayfurYldz d03002bcee fix: normalize multiline plan slugs 2026-09-18 17:31:54 +02:00
TayfurYldz 1bea197584 fix: bind init attestation to current project 2026-09-18 17:31:38 +02:00
Shaun Lin e33359977c fix(catchup): skip malformed OpenCode parts 2026-09-18 17:31:18 +02:00
OthmanAdi 3160256d2e fix: read an empty active pointer as empty and send Cursor hook output as UTF-8
Get-Content -Raw returns nothing for a zero-byte .active_plan, and the
[string] cast of that result is still $null, so resolve-plan-dir.ps1,
ledger-append.ps1, ledger-summary.ps1 and phase-status.ps1 raised on .Trim().
Run standalone the resolver still printed its answer and exited 0; called
in-process by the Cursor context helper the exception unwound it first, and
the route refused where every canonical route falls through to the newest
plan or the root plan. The pointer is now read through string interpolation,
which yields an empty string, in all shipped copies.

The Cursor PowerShell hooks set the console output encoding to UTF-8 before
printing. Under the OEM code page both Windows PowerShell 5.1 and pwsh sent
the em-dash as "-" and non-ASCII plan text as "?" or CP437 bytes.

resolve-plan-context.ps1 keeps a containment refusal silent, as inject-plan.sh
does, and the broken-pin notice uses the canonical wording, since the
PowerShell check is the canonical absolute-local-directory check.

Parity rows 07c, 27 and 28 from the v3.20.0 review are regression fixtures.
2026-09-17 23:09:26 +02:00
OthmanAdi bb2ee81404 fix: resolve plans by literal path and validate the attester pin without IsPathFullyQualified
resolve-plan-dir.ps1 tested candidate plan directories with wildcard-interpreting
Test-Path and listed .planning with Get-ChildItem -Path. In a project path
containing [ or ] those calls match nothing under pwsh, so a valid .active_plan
pointer, the newest-plan fallback, and even an explicit PLAN_ID resolved to an
empty result and every PowerShell route injected nothing. Every path test is
now literal, like the rest of the file.

attest-plan.ps1 still validated PWF_PLAN_ROOT with [IO.Path]::IsPathFullyQualified,
which Windows PowerShell 5.1 does not have, so the attester aborted whenever the
pin was set. It now uses the same drive-qualified check PR #251 gave the
resolver. Both changes are synced to all 15 shipped copies.

Found by the v3.20.0 review of PR #251.
2026-09-17 23:09:26 +02:00
kuei51307-hub 6031c38709 fix(cursor): resolve named plans in PowerShell hooks 2026-09-17 23:08:41 +02:00
OthmanAdi bb48bb0a1e fix: verify the planning root in constant time before named-plan init
PR #249 probed the planning root with set-active-plan.sh --list, which
canonicalizes and parses every existing plan directory: on Git Bash a
slug init with 30 plans took 19 s. It also checked the pointer only
after the plan directory and files existed, so a refused pointer left a
new directory behind and a retry produced a -2 suffix.

Add --verify-root to set-active-plan.sh and -VerifyRoot to
set-active-plan.ps1: the planning root, when present, must be inside
the project and an existing pointer must be a replaceable regular
file. Nothing is read, listed or written. Both initializers call it
before creating anything; the same 30-plan init now takes under 3 s.

Also: the shared pointer keeps a umask-derived mode instead of the
0600 that mktemp creates, an unreadable pointer no longer aborts the
listing under set -e, and SCRIPT_DIR ignores CDPATH when it locates
the sibling scripts. All 18 selector copies and 10 initializer copies
are synced.
2026-09-17 10:11:23 +02:00
OthmanAdi ea8b17860d fix: iterate OpenCode planning parts lazily in session catchup
The exact-path lookup from #248 replaced LIMIT 1 with fetchall and a
Python revalidation loop. OpenCode write parts carry whole file bodies,
so a session with many planning writes materialized all of them before
the first validated row ended the loop (measured 20 MB peak for 2,000
10 KB writes). Iterate the cursor instead; the loop still stops at the
first exact match. Applied to every copy that carries the query.

The OpenCode lookalike test now seeds a later part so it fails on the
suffix-matching baseline instead of passing through the empty-parts
early return.
2026-09-17 10:11:23 +02:00
OthmanAdi 808694b726 fix: keep PowerShell plan ids ASCII and plan paths literal
Review follow-ups for the named-plan flow in init-session.ps1:

- Build the slug with -creplace. The case-insensitive -replace lets
  letters that .NET folds to ASCII, such as a dotted capital I, survive
  into the plan id, which the resolvers and the selector then reject.
  A slug that is still not ASCII falls back to untitled-<id>.
- Write the plan files with Out-File -LiteralPath. Once the target path
  is absolute, -FilePath treats [ and ] as wildcards and pwsh fails the
  write while the script still reports success.
- Inherit the root .mode marker case-sensitively, matching
  init-session.sh and the injector.
- Treat an empty positional name as legacy root mode and report
  "untitled" for -PlanDir without a name, both like the shell twin.

The tests drop a developer's PWF_PLAN_ROOT pin from the child
environment and cover each item, with the bracketed-path case run
under pwsh only because Windows PowerShell 5.1 relocates its own cwd
for such paths.
2026-09-17 10:11:23 +02:00
OthmanAdi c82f647718 fix: replace PowerShell active pointers through the selector
PR #247 gave init-session.ps1 the same named-plan flow as the shell
initializer, but it wrote .planning\.active_plan with Set-Content. That
write follows a reparse point and truncates a hardlinked pointer in
place, so it could overwrite whichever file shared the inode, and it
created the plan even when .planning was a junction to a directory
outside the project.

Route the pointer write through set-active-plan.ps1, which already owns
the contained atomic replacement, and run its listing check on the
physical planning root before creating anything beneath it. This is the
PowerShell twin of PR #249. A missing selector now stops named-plan
creation, matching the shell initializer. Ten copies synced, four
regressions added: hardlinked pointer, symlinked pointer, junctioned
planning root, and the selector requirement.
2026-09-17 10:11:23 +02:00
OthmanAdi e9da40fc87 fix: require exact planning filenames in unsynced catchup copies
PR #248 replaced suffix matching with an exact-basename rule in the
session-catchup.py copies that sync-ide-folders.py maintains. Three more
copies live outside that tool and kept the old boundary: the root
scripts/session-catchup.py, which is the Claude Code plugin install path,
and the five translated skills/i18n copies. A later write to a lookalike
such as draft_task_plan.md could still move their catchup anchor forward.

Apply the same helper to all six, replace the LIKE suffix query in the
root and zh OpenCode paths with the exact-path query and Python
revalidation, and add a test that loads every shipped copy so the
boundary cannot drift again in one of them.
2026-09-17 10:11:23 +02:00
kuei51307-hub 893cb38299 fix(init): replace active pointers safely 2026-09-17 10:10:50 +02:00
Shaun Lin aae2d1ebc5 fix: attest PowerShell plans across hosts 2026-09-17 10:10:27 +02:00
Shaun Lin f1ebb38d42 fix: add PowerShell slug-mode plan initialization 2026-09-17 10:10:27 +02:00
OthmanAdi 0d41eeeddd fix: silence completed-plan Stop notices 2026-09-16 13:21:35 +02:00
kuei51307-hub 8379610e83 fix(sync): report missing canonical sources 2026-09-16 11:08:52 +02:00
kuei51307-hub 6834e65f0b fix(plans): accept BOM-prefixed active pointers 2026-09-15 10:41:37 +02:00
OthmanAdi ae7e3ae817 fix: make plan listing safe and useful across install surfaces 2026-09-13 13:27:56 +02:00
Dphoshoba 6317beb930 feat: list active planning sessions 2026-09-13 13:27:41 +02:00
OthmanAdi ecaf63f689 fix: refuse ambiguous unpinned named plans (#240) 2026-09-08 12:08:09 +02:00
OthmanAdi f118ab5025 feat: answer Claude Code hook events in one Python process
hooks/claude-hook.sh answered every event by running resolve-plan-dir.sh
and inject-plan.sh, about 130 forks per UserPromptSubmit. Under Git Bash
on Windows a fork costs about 90 ms, so a prompt took 7 to 12 s against
the 10 s hook timeout and Claude Code discarded the plan context, and
PreToolUse added 5 s before every tool call. Measured on the reporting
machine: 8.1, 10.2 and 7.1 s per prompt before, 0.33 s after.

scripts/inject-plan.py is a byte-identical twin of inject-plan.sh plus
the dispatcher logic of claude-hook.sh. The launcher finds a CPython 3
with a fork-free PATH walk, runs the twin with -I -B and falls back to
the shell chain on any non-zero exit; PWF_FAST_PATH=0 forces the shell
chain; a directory without planning state exits before any fork. The
launcher hands the twin its own $PWD spelling so both routes share one
turn-marker and one progress-guard slot per plan. skill-hook.sh uses the
twin after eligibility and isolates its own two interpreter calls. Both
dispatchers run the json_string awk under LC_ALL=C so a character outside
the BMP no longer leaves as a lone surrogate on Windows. The twin ships in
every scripts directory that ships inject-plan.sh.

tests/test_inject_plan_python_parity.py runs both implementations over
the same fixtures and asserts identical stdout, including what the
second-model review found and this commit fixes: NUL bytes in
.active_plan, the awk "phases: /N" quirk for a plan with no completed
phase, the CRLF progress tail under Git for Windows sed, cache slots
shared across routes, and non-BMP characters through the JSON encoder.
2026-09-07 09:37:36 +02:00
OthmanAdi ec2ec0a796 fix: start hook interpreters in isolated mode
The python - heredocs and -c snippets in inject-plan.sh and
resolve-plan-dir.sh put the current directory first on sys.path, so a
repository carrying its own secrets.py, hashlib.py or ctypes.py had that
file imported by the hook on every prompt, with the hook's privileges.
Every interpreter start in the two scripts now passes -I, in the canonical
skill and in every synced copy.
2026-09-07 09:37:06 +02:00
OthmanAdi d47a61950e fix: encode hook context consistently across awk variants 2026-09-05 22:32:54 +02:00
OthmanAdi 8743f71e0b fix: preserve POSIX hook cache identity and JSON escaping 2026-09-05 22:29:12 +02:00
OthmanAdi 91b152cfd2 fix: bind parallel sessions and repair standalone hook delivery 2026-09-05 22:21:37 +02:00
OthmanAdi 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.
2026-09-03 00:23:03 +02:00
OthmanAdi f21d94bbcb fix: preserve trusted injection containment 2026-08-31 13:39:19 +02:00
OthmanAdi 3b358c5be7 fix: restore cross-platform hook portability 2026-08-31 11:22:19 +02:00
OthmanAdi 77390d2a20 fix: attest plans from their slug directory 2026-08-31 10:27:24 +02:00
OthmanAdi f19077cf5f fix: make ClawHub staging and version parity reproducible 2026-08-30 09:23:32 +02:00
OthmanAdi 52bb4be2fe fix: serialize phase status updates fail closed 2026-08-30 09:22:59 +02:00
OthmanAdi fd6d52e12b fix(security): require explicit local session recovery 2026-08-30 09:22:46 +02:00
OthmanAdi a579482e15 fix(security): preserve direct hook compatibility 2026-08-29 15:16:09 +02:00
OthmanAdi 9ee78a0831 fix(security): quarantine cross-project recovery data 2026-08-29 14:55:11 +02:00
OthmanAdi f9086cda91 fix(security): harden planning context isolation 2026-08-29 14:54:53 +02:00