Skip to content

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 into
mainfrom
gsta-123/absorb-pstack-decision-trail-worktree-audit
Oct 27, 2026
Merged

capy-ai[bot] merged 9 commits into
mainfrom
gsta-123/absorb-pstack-decision-trail-worktree-audit

Conversation

@garrytan

@garrytan garrytan commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3494,
  "head": "7082b63f350c32b516a10f93dd8d2e2f14311361",
  "version": "1.91.267.0",
  "base": "main",
  "gate": {
    "pregate.json/remote_gate": {
      "pass": 17389,
      "fail": 0,
      "skip": 0
    },
    "free-tests.yml/macos-named-regressions": {
      "pass": 3,
      "fail": 0,
      "skip": 0
    },
    "windows-free-tests.yml/windows-free-shard": {
      "pass": 574,
      "fail": 0,
      "skip": 0
    }
  },
  "spend_usd": 0.3,
  "session_kind": "unattended",
  "pregate": "requires-remote cleared @da2acf276f81 (1 checks, current for 7082b63f350c)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/40453181365",
    "windows-free-tests.yml/windows-free-shard: https://github.com/garrytan/gstack/actions/runs/40453181349",
    "pregate.json/remote_gate: remote-gate tree=da2acf276f81 tests=17389"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      3494
    ],
    "flakes": []
  },
  "review_loop": {
    "passes": 6,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 6,
    "fixed": 21,
    "scope": "frozen"
  }
}

What changed

Before: a lane's handoff is prose a reviewer takes on faith. After: one TSV row per decision with the reason and a pointer that resolves, start rows marking where each run's account begins, and a formula-looking evidence cell quoted instead of executable.

Before: a lane's handoff is prose a reviewer takes on faith. After: gstack-decision-trail writes one TSV row per decision with the reason and a pointer that resolves, start rows mark where each run's account begins, and an evidence cell that starts like a formula is quoted instead of executable.

Before: git worktree list shows six paths and nothing about whether any can go. After: size, age, merge state, tracked edits vs scratch, remote, PR and last chat per worktree with a suggested bucket.

Before: git worktree list shows six paths and nothing about whether any can go. After: gstack-worktree-audit gives 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 is review rather than safe (removing it would lose the scratch), the merged flaky-retry is safe, 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's start row naming the earlier rows and run:<id>, and is a no-op while that row is the newest start row; --run <id> on an append refuses with DECISION_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/--help is help so a -h cell 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 the Attention section) is in docs/unattended.md ("The decision trail") and one paragraph at the end of autoplan/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 through gh --jq (no jq), LAST_CHAT from Claude Code's per-worktree project directory, BUCKET (prunable for a registered worktree whose directory is gone > hold-wip > hold-open-pr > verify-recent-chat > safe > review; safe only for a clean tree with nothing unpushed, so an unpushed commit or an untracked file on a merged branch is review). 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 in landing-report/SKILL.md.tmpl offers it when the sibling table is stale; docs/CONTRIBUTOR_REFERENCE.md has the Conductor guide; docs/standalone-binaries.md lists both bins; docs/troubleshooting.md gains the refusal and the MERGED/base note.
  • Licensing: both are code ports of Lauren Tan's pstack (cursor/plugins at 99b609a7), so each file's header names its source, licenses/MIT-pstack.txt carries 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-work and worktree-audit.sh were 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

Date Ask Words Covers
2026-10-26 Combined tstack/pstack absorb plan (plans/absorb-tstack.md, plans/absorb-pstack.md), relayed by GStack Minder "Do it, send" every recommendation in both plans at full scope: pstack items 1–11 (this PR is items 5 and 10), every tstack take, the opt-in attribution callout (off by default), MIT notices in NOTICE.md

Behavior changes

The pre-landing review passes tightened the audit's safe bucket (the port's rule called a worktree with unpushed commits or untracked files safe when its PR was closed; now review), added the prunable row, a broken row for a worktree whose own .git link is gone (git would otherwise describe the containing repository and hide its files), review for a locked entry whose directory is gone, clean,ignored:<n> for gitignored data, and pinned git status to --untracked-files=normal --ignore-submodules=none so a user's status.showUntrackedFiles=no cannot hide untracked files; every change is stricter than the source, never looser. Otherwise none outside the plan's items. The bin is named gstack-decision-trail, not the plan's gstack-decision-log: that name already belongs to the event-sourced JSON decision store behind gstack-decision-search.

Gate integrity

  • No threshold, timeout, trial count or case kind changed. No pinned skill changed; landing-report/SKILL.md grows by one line and is unpinned (parity 22/22, size budget OK).
  • test/autoplan-driver.test.ts line cap on autoplan/DRIVER.md 160 → 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, --run refusal and admission, a -h cell 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 .git link is missing, one whose branch shares its name with a tag, one with only a gitignored .env) classified into every bucket through a fake gh and a CLAUDE_CONFIG_DIR transcript directory; the fixture is byte-identical after the audit; -b, --no-fetch, an unpushed commit on a closed PR reading review and an open PR on the reused name winning, no gh on PATH (git resolved from git --exec-path), a failing gh, status.showUntrackedFiles=no in the user's config not hiding untracked files, missing base, non-repo path. The fake gh records its argv and runs the audit's own --jq over canned JSON with a fork PR when jq is installed.
  • test/egress-receipt-wiring.test.ts: a reasoned exemption for bin/gstack-worktree-audit's best-effort git fetch of the base ref (read-only audit, --no-fetch opts out, GIT_TERMINAL_PROMPT=0).
  • Focused run on the final head: see the READY block for counts.

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 (safe ignored unpushed/untracked; the no-gh test rebuilt PATH), all fixed in c9ae990. Pass 2 (range): 13 findings, 1 blocking (the broken-.git worktree reading safe), 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=no hid 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.

  • INFORMATIONAL bin/gstack-worktree-audit:164 pushed is judged against the local origin/ ref as last fetched; a pruned or stale ref shifts the bucket toward review
  • INFORMATIONAL bin/gstack-worktree-audit:100 in a fork workflow every PR is cross-repository so the PR column is - (conservative)
  • INFORMATIONAL test/worktree-audit.test.ts:135 the broken fixture is caught by both guards so neither is pinned alone
  • INFORMATIONAL test/worktree-audit.test.ts:176 dirty=unknown has no fixture
  • INFORMATIONAL test/worktree-audit.test.ts:177 GIT_ASKPASS/BatchMode on the fetch is not asserted
  • INFORMATIONAL test/worktree-audit.test.ts:208 the fork filter runs only where jq is installed; the argv assertion guards it elsewhere
  • INFORMATIONAL bin/gstack-decision-trail:133 two 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 lock
  • INFORMATIONAL bin/gstack-decision-trail:61 a 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 parsers
  • INFORMATIONAL bin/gstack-worktree-audit:157 git status refreshes the index under index.lock; GIT_OPTIONAL_LOCKS=0 would avoid colliding with a concurrent git add in that worktree
  • INFORMATIONAL bin/gstack-worktree-audit:170 pushed is judged against the local origin/ ref as last fetched
  • INFORMATIONAL bin/gstack-worktree-audit:131 a locked worktree whose directory exists is bucketed by its state like any other; only a locked entry whose directory is gone reads review
  • INFORMATIONAL bin/gstack-worktree-audit:106 gh pr list --limit 1000 truncates silently in a repository with more PRs
  • INFORMATIONAL bin/gstack-worktree-audit:186 verify-recent-chat only sees Claude Code transcripts named after the worktree path; other agents' sessions are not detected
  • INFORMATIONAL bin/gstack-decision-trail:80 a directory passed as throws EISDIR instead of a usage error; a trail literally named start must be written as ./start

Issues

Refs #3494 (the rule-19 base-merge commit names this PR in its message; no separate issue is linked)

Open in Capy

…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>
@trunk-io

trunk-io Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 7 commits October 26, 2026 21:23
…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>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@github-actions github-actions Bot changed the title feat(bin): gstack-decision-trail and gstack-worktree-audit, ported from pstack (GSTA-123) v1.91.268.0 feat(bin): gstack-decision-trail and gstack-worktree-audit, ported from pstack (GSTA-123) Oct 27, 2026
@capy-ai
capy-ai Bot merged commit 76aa68f into main Oct 27, 2026
62 checks passed
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