Skip to content

fix(meta-mode): harden plan checks and worktree audit - #31

Merged
3metaJun merged 4 commits into
mainfrom
fix/meta-mode-helper-hardening
Oct 6, 2026
Merged

3metaJun merged 4 commits into
mainfrom
fix/meta-mode-helper-hardening

Conversation

@3metaJun

@3metaJun 3metaJun commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Problem

Three meta-mode helpers had gaps that pstack-claude (v0.9.64 to 0.9.69) already closed, and one more found while checking them:

  • check-plan.mjs failed a plan saved with a UTF-8 BOM, treated any line starting with three backticks as a fence toggle (so a longer outer fence, a ~~~ fence or an indented fence leaked example text into the prose rules), and accepted a program task heading or ## Close the program with prose but no checkbox.
  • worktree-audit.mjs read only the directory in MSTACK_TRANSCRIPTS_DIR, so a worktree with a recent Codex, Claude Code or pi session read as safe. It matched a path as a bare substring, so wt-long held wt, and it missed Windows backslash, UNC and drive-letter-case spellings.
  • worktree-audit.mjs classified any worktree with a non-open PR as safe, including a CLOSED (never merged) PR and commits made after a merged PR. Squash merges leave the HEAD outside origin/main, so the PR is the only evidence, and it only covers the commit it carried.

Solution

  • check-plan.mjs: strip a leading BOM; parse fences by CommonMark rules (3+ backticks or tildes, closes on the same character and at least as many, backtick info string cannot contain a backtick); require a checkbox under each program task heading and under Close the program.
  • worktree-audit.mjs: default roots are Claude Code projects (CLAUDE_CONFIG_DIR), Codex sessions and archived_sessions (CODEX_HOME), pi sessions (PI_CODING_AGENT_SESSION_DIR or PI_CODING_AGENT_DIR), existing stores only; MSTACK_TRANSCRIPTS_DIR still replaces them. One pass over transcripts answers for every worktree, with boundary-checked needles in plain, JSON-escaped, slash, backslash, UNC and both drive-letter-case spellings.
  • worktree-audit.mjs: safe needs HEAD in origin/main or a MERGED PR whose headRefOid equals the worktree HEAD. Open PRs are preferred when a branch has several.
  • package.json test script gains tools/meta-mode/check-plan.test.mjs (no version bump). profiles/skill-manifest.json target digests are refreshed for the touched tool files, since skill-baseline --check fails otherwise; pinned source digests are unchanged.

Verification

  • npm test: 278 pass, 0 fail (Windows, Node 24). npm run check-package passes.
  • node --test tools/meta-mode/resume.test.mjs tools/meta-mode/pr-safety.test.mjs: 12 pass (not in the npm script before this PR, left as is).
  • The new PR-vouching test failed before the classify change (closed PR read safe).
  • Not run: bun tests (orch, watch-pr; bun is not installed here), ubuntu/macos CI.

Ported vs already present

pstack-claude item mstack status
check-plan BOM strip Ported
check-plan stricter fences, box checks Ported, with check-plan.test.mjs
check-playbooks BOM strip Already present (readFileSync(...).replace(/^/)) with a test
worktree-audit Codex sessions and archived, CODEX_HOME, CLAUDE_CONFIG_DIR, pi stores Ported
worktree-audit Windows/UNC spellings, no sibling-prefix match Ported
Merged-PR vouching only for the exact HEAD Ported; shape differs, mstack's classify was missing it
resume angle-bracket link destinations Not applicable: mstack's resume.mjs does not parse note links or require links to be registered with --artifact. A note with [Q](<questions (draft).md>) already begins, publishes and reads. Porting the link-registration rule would be a new behaviour, not a fix.
Trunk detection other than origin/main, missing-transcripts warnings Not ported: features, outside 0.9.64-0.9.69
pstack Pi, hook, generate.mjs fixes (0.9.66 to 0.9.69) Not shared code in mstack
orch / watch-pr differences Left alone: diverged implementations, no verified bug found
Article invariants (playbook steps copied to the todo list with skip: <reason>, principle names cited only if read, child reports with required fields) Prose only in skills/meta-mode/SKILL.md and docs. No script receives a todo list, a citation record or a child report, and check-plan.mjs validates a plan file with no skip concept, so no cheap check fits an existing script. Nothing added.

Model: Claude Sonnet 5.5 | Harness: Claude Code

🤖 Generated with Claude Code

3metaJun and others added 2 commits October 6, 2026 12:08
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e safe

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@3metaJun 3metaJun changed the title fix(meta-mode): harden plan, resume and worktree audit helpers fix(meta-mode): harden plan checks and worktree audit Oct 6, 2026
3metaJun and others added 2 commits October 6, 2026 12:20
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… in worktree audit

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@3metaJun
3metaJun merged commit 2451fa9 into main Oct 6, 2026
9 checks passed
@3metaJun
3metaJun deleted the fix/meta-mode-helper-hardening branch October 6, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant