Repository navigation
fix(meta-mode): harden plan checks and worktree audit - #31
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e safe Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… in worktree audit Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mjsfailed 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 programwith prose but no checkbox.worktree-audit.mjsread only the directory inMSTACK_TRANSCRIPTS_DIR, so a worktree with a recent Codex, Claude Code or pi session read assafe. It matched a path as a bare substring, sowt-longheldwt, and it missed Windows backslash, UNC and drive-letter-case spellings.worktree-audit.mjsclassified any worktree with a non-open PR assafe, including a CLOSED (never merged) PR and commits made after a merged PR. Squash merges leave the HEAD outsideorigin/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 Codeprojects(CLAUDE_CONFIG_DIR), Codexsessionsandarchived_sessions(CODEX_HOME), pi sessions (PI_CODING_AGENT_SESSION_DIRorPI_CODING_AGENT_DIR), existing stores only;MSTACK_TRANSCRIPTS_DIRstill 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:safeneeds HEAD inorigin/mainor a MERGED PR whoseheadRefOidequals the worktree HEAD. Open PRs are preferred when a branch has several.package.jsontest script gainstools/meta-mode/check-plan.test.mjs(no version bump).profiles/skill-manifest.jsontarget digests are refreshed for the touched tool files, sinceskill-baseline --checkfails otherwise; pinned source digests are unchanged.Verification
npm test: 278 pass, 0 fail (Windows, Node 24).npm run check-packagepasses.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).safe).orch,watch-pr; bun is not installed here), ubuntu/macos CI.Ported vs already present
check-planBOM stripcheck-planstricter fences, box checkscheck-plan.test.mjscheck-playbooksBOM stripreadFileSync(...).replace(/^/)) with a testworktree-auditCodex sessions and archived,CODEX_HOME,CLAUDE_CONFIG_DIR, pi storesworktree-auditWindows/UNC spellings, no sibling-prefix matchclassifywas missing itresumeangle-bracket link destinationsresume.mjsdoes 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.origin/main, missing-transcripts warningsgenerate.mjsfixes (0.9.66 to 0.9.69)orch/watch-prdifferencesskip: <reason>, principle names cited only if read, child reports with required fields)skills/meta-mode/SKILL.mdand docs. No script receives a todo list, a citation record or a child report, andcheck-plan.mjsvalidates 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