Repository navigation
v1.91.268.0 feat(bin): gstack-decision-trail and gstack-worktree-audit, ported from pstack (GSTA-123) - #3494
Merged
capy-ai[bot] merged 9 commits intoOct 27, 2026
Conversation
…om pstack (GSTA-123) Two MIT ports from Lauren Tan's pstack (licenses/MIT-pstack.txt, NOTICE.md): a TSV decision trail with the header-once append, the formula guard, a start row per run and a --run admission check; and a read-only worktree audit with size, merge state, dirty, remote, PR, last chat and a suggested bucket. Docs: docs/unattended.md (the decision trail and its end-of-run audit), autoplan/DRIVER.md, docs/CONTRIBUTOR_REFERENCE.md, docs/standalone-binaries.md, docs/troubleshooting.md, one line in landing-report. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
…base fetch Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
bin/gstack-worktree-audit: a worktree path with a space is read whole (sed on the porcelain 'worktree ' line, not awk's second field); a registered worktree whose directory is gone prints a 'prunable' row instead of being skipped; 'safe' now requires a clean tree and either merged into the base or a closed/merged PR with every commit pushed, so unpushed commits or untracked files on a merged branch read 'review' (the port's rule called them safe); fork PRs are dropped and an open PR wins over an older closed one on a reused branch name; GIT_TERMINAL_PROMPT=0 on the base fetch. bin/gstack-decision-trail: only a leading -h/--help is help, so a '-h' cell is appended as data; a trail without a final newline, with CRLF rows or with a repeated header line is appended to correctly; a run id is limited to [A-Za-z0-9._:@/-] (exit 2) so a tab or quote cannot break the start-row idempotence check. Tests cover each case; the 'without gh' test resolves git from 'git --exec-path' instead of a PATH rebuilt from a tool list. Docs, CHANGELOG and --help text describe the stricter buckets. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
bin/gstack-worktree-audit: a worktree whose own .git link is gone (git marks it prunable, or its toplevel is another repository) prints a 'broken' row in 'review' instead of describing the containing repository as clean and safe; a locked entry whose directory is gone reads 'review', not 'prunable', since prune would not touch it; a clean tree names its gitignored entries as 'clean,ignored:<n>' without changing the bucket; the branch name is read from refs/heads/ by hand so a tag of the same name cannot hide the PR; porcelain blocks are read with IFS=tab so paths with leading or trailing spaces survive; a failed git status reads 'unknown', never 'clean'; the base fetch also sets GIT_ASKPASS=true and ssh BatchMode. bin/gstack-decision-trail: a file whose first line is not the header (a blank file, rows written by hand) gets the header appended, and a UTF-8 BOM before the header no longer turns it into a data row. Tests: the fake gh records its argv and runs the audit's own --jq over canned JSON with a fork PR when jq is installed; row counts are asserted before the every() checks; each test starts from the same gh and closed worktree; the snapshot includes the worktree registry; new fixtures for locked, broken, tag-shadowed and ignored-only worktrees, a blank trail and a BOM. Docs and CHANGELOG describe the new DIRTY values and buckets. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
bin/gstack-decision-trail: hasHeader looks for a header line anywhere in the file, so a blank or hand-written trail gets exactly one header rather than one per append. bin/gstack-worktree-audit: the broken-worktree check uses rev-parse --show-cdup and the presence of /.git instead of comparing two spellings of the same path, which differ on Git for Windows. Test: the blank-trail case appends twice and asserts a single header. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
bin/gstack-worktree-audit: git status runs with --untracked-files=normal --ignore-submodules=none, so a user's status.showUntrackedFiles=no config cannot hide untracked files and let a worktree holding them read clean and safe. Test: the fresh worktree under that config via GIT_CONFIG_* still reads scratch:1 / review (red before the fix). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
docs/standalone-binaries.md, docs/CONTRIBUTOR_REFERENCE.md, docs/troubleshooting.md: the audit's safe condition is stated in full (clean and merged, or PR closed/merged with every commit pushed), the DIRTY list names missing, broken and unknown, start is a reserved phase name, and 'read-only' names the base fetch as the one write --no-fetch skips. CHANGELOG.md says the same (the audit's one decision item). Audit id gsta123-docs-20261026T221657Z, status updated, no blockers. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ecision-trail-worktree-audit Rule-19 grant from GStack Minder for #3494. CHANGELOG.md merged by mergeChangelogs (branch entry stays under [Unreleased]); NOTICE.md keeps main's pstack ideas paragraph (GSTA-124) and this branch's ported-scripts section after it; docs/unattended.md took both sections automatically. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
8 tasks done
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This was referenced Oct 27, 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.
What changed
Before: a lane's handoff is prose a reviewer takes on faith. After:
gstack-decision-trailwrites one TSV row per decision with the reason and a pointer that resolves,startrows mark where each run's account begins, and an evidence cell that starts like a formula is quoted instead of executable.Before:
git worktree listshows six paths and nothing about whether any can go. After:gstack-worktree-auditgives size, age, merge state, tracked edits vs scratch, remote, PR and last chat per worktree with a suggested bucket; the 13 MB spike has two untracked files and a closed PR, so it isreviewrather thansafe(removing it would lose the scratch), the merged flaky-retry issafe, the dashboard has tracked edits and an open PR so it is held, and nothing was deleted.bin/gstack-decision-trail <file> <phase> <decision> <why> <evidence> <result>(TypeScript, isolated bun shebang): appends one UTC-stamped row to a run's TSV trail, header once and only ever appended, cells flattened to one line, a leading=,+,-or@quoted.start <file> <run-id>appends a run'sstartrow naming the earlier rows andrun:<id>, and is a no-op while that row is the newest start row;--run <id>on an append refuses withDECISION_TRAIL_START_REQUIRED(exit 3) until the run has opened its stretch; a run id is letters, digits and. _ : @ / -(exit 2 otherwise), only a leading-h/--helpis help so a-hcell is data, and a trail missing its final newline, with CRLF rows or a repeated header is appended to correctly. The end-of-run rule (audit the trail against the transcript, correct the log not the story, a cross-family reviewer and theAttentionsection) is indocs/unattended.md("The decision trail") and one paragraph at the end ofautoplan/DRIVER.md's coordinator contract.bin/gstack-worktree-audit [-b <ref>] [--no-fetch] [repo](bash, read-only): one TSV row per worktree beside the main one, largest first: SIZE, AGE, MERGED, DIRTY (clean/wip:<n>/scratch:<n>), REMOTE (pushed/ahead<n>/no-remote/detached), PR throughgh --jq(nojq), LAST_CHAT from Claude Code's per-worktree project directory, BUCKET (prunablefor a registered worktree whose directory is gone >hold-wip>hold-open-pr>verify-recent-chat>safe>review;safeonly for a clean tree with nothing unpushed, so an unpushed commit or an untracked file on a merged branch isreview). Fork PRs are ignored, an open PR wins over an older closed one on a reused branch name, and worktree paths with spaces are read whole. Never deletes or prunes. One line inlanding-report/SKILL.md.tmploffers it when the sibling table is stale;docs/CONTRIBUTOR_REFERENCE.mdhas the Conductor guide;docs/standalone-binaries.mdlists both bins;docs/troubleshooting.mdgains the refusal and the MERGED/base note.cursor/pluginsat 99b609a7), so each file's header names its source,licenses/MIT-pstack.txtcarries the MIT text with upstream's copyright line, and NOTICE.md gets a "pstack, ported scripts" entry beside the existing ideas-only entry. Every sentence of prose is gstack's own.Why
pstack's
show-me-your-workandworktree-audit.shwere the two pieces of its tooling worth taking as code ([plans/absorb-pstack.md §4 items 5 and 10]): a long or unattended run today hands back prose, and a reviewer has no way to tell which decisions were made, in what order, or on what evidence without the transcript; and after weeks of Conductor lanes a checkout carries worktrees nobody can classify without poking at each one. The trail gives the Captain a plain file to read before the report, and the audit gives a Conductor user a bucket per worktree without ever touching one.Approvals
Behavior changes
The pre-landing review passes tightened the audit's
safebucket (the port's rule called a worktree with unpushed commits or untracked filessafewhen its PR was closed; nowreview), added theprunablerow, abrokenrow for a worktree whose own.gitlink is gone (git would otherwise describe the containing repository and hide its files),reviewfor a locked entry whose directory is gone,clean,ignored:<n>for gitignored data, and pinnedgit statusto--untracked-files=normal --ignore-submodules=noneso a user'sstatus.showUntrackedFiles=nocannot hide untracked files; every change is stricter than the source, never looser. Otherwise none outside the plan's items. The bin is namedgstack-decision-trail, not the plan'sgstack-decision-log: that name already belongs to the event-sourced JSON decision store behindgstack-decision-search.Gate integrity
landing-report/SKILL.mdgrows by one line and is unpinned (parity 22/22, size budget OK).test/autoplan-driver.test.tsline cap onautoplan/DRIVER.md160 → 162 (measured 162): the file was exactly at the cap and the decision-trail paragraph is the one addition the plan asks for there.Tests
test/decision-trail.test.ts(11): header once, the formula guard on every leading byte it covers, flattened tabs and line breaks, the start row and its idempotent rerun, a second run's start row,--runrefusal and admission, a-hcell appended as data, a missing final newline, CRLF rows and a repeated header, a blank file and a BOM, run ids with whitespace or quotes refused, usage errors.test/worktree-audit.test.ts(4): bare origin, clone and twelve worktrees (including a path with a space, a merged branch with only an untracked file, a registered worktree whose directory is gone, a locked one whose directory is gone, a broken one inside the clone whose.gitlink is missing, one whose branch shares its name with a tag, one with only a gitignored.env) classified into every bucket through a fakeghand aCLAUDE_CONFIG_DIRtranscript directory; the fixture is byte-identical after the audit;-b,--no-fetch, an unpushed commit on a closed PR readingreviewand an open PR on the reused name winning, noghon PATH (git resolved fromgit --exec-path), a failinggh,status.showUntrackedFiles=noin the user's config not hiding untracked files, missing base, non-repo path. The fakeghrecords its argv and runs the audit's own--jqover canned JSON with a fork PR whenjqis installed.test/egress-receipt-wiring.test.ts: a reasoned exemption forbin/gstack-worktree-audit's best-effortgit fetchof the base ref (read-only audit,--no-fetchopts out, GIT_TERMINAL_PROMPT=0).Review loop
REVIEW_LOOP: passes=6 blocking_found=3 deferred=0 noted=6 fixed=21 scope=frozen. Pass 1 (whole diff, five specialists + Red Team): 8 findings, 2 blocking (safeignored unpushed/untracked; the no-ghtest rebuilt PATH), all fixed in c9ae990. Pass 2 (range): 13 findings, 1 blocking (the broken-.gitworktree readingsafe), fixed in c555ce3. Pass 3 (range): 6 notes, two small ones fixed in 96927f2. Pass 4 (14-line range): no findings, converged. Step 11 native adversarial pass then found one floor-level defect (status.showUntrackedFiles=nohid untracked files); fixed in 0d372b7 under the Captain's rule-23 grant bounded to that finding, pass 5 on that range: no findings. Codex outside voice:outside_status: unavailable(the OpenAI endpoint answers 401 with this machine's key; recorded as missing coverage, non-blocking). Documentation audit (document-release, spawned):updated, three doc corrections in 564d341, no blockers. Pass 6 (range 564d341..7082b63, the rule-19 merge of main d9b0d60: CHANGELOG via mergeChangelogs, NOTICE.md both pstack entries, docs/unattended.md both sections): no findings.Review notes
Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.
bin/gstack-worktree-audit:164pushed is judged against the local origin/ ref as last fetched; a pruned or stale ref shifts the bucket toward reviewbin/gstack-worktree-audit:100in a fork workflow every PR is cross-repository so the PR column is - (conservative)test/worktree-audit.test.ts:135the broken fixture is caught by both guards so neither is pinned alonetest/worktree-audit.test.ts:176dirty=unknown has no fixturetest/worktree-audit.test.ts:177GIT_ASKPASS/BatchMode on the fetch is not assertedtest/worktree-audit.test.ts:208the fork filter runs only where jq is installed; the argv assertion guards it elsewherebin/gstack-decision-trail:133two runs interleaving on one trail must each re-start before every append (the one-run-at-a-time contract); starts are read-then-write with no lockbin/gstack-decision-trail:61a cell beginning with a double quote, or holding \v \f \x1c-\x1e U+0085 U+2028/2029, can be read as a record break by CSV parsersbin/gstack-worktree-audit:157git status refreshes the index under index.lock; GIT_OPTIONAL_LOCKS=0 would avoid colliding with a concurrent git add in that worktreebin/gstack-worktree-audit:170pushed is judged against the local origin/ ref as last fetchedbin/gstack-worktree-audit:131a locked worktree whose directory exists is bucketed by its state like any other; only a locked entry whose directory is gone reads reviewbin/gstack-worktree-audit:106gh pr list --limit 1000 truncates silently in a repository with more PRsbin/gstack-worktree-audit:186verify-recent-chat only sees Claude Code transcripts named after the worktree path; other agents' sessions are not detectedbin/gstack-decision-trail:80a directory passed as throws EISDIR instead of a usage error; a trail literally named start must be written as ./startIssues
Refs #3494 (the rule-19 base-merge commit names this PR in its message; no separate issue is linked)