Skip to content

fix: a granted fix-check after a fix-check plans in the loop (GST-1681) - #4096

Merged
capy-ai[bot] merged 2 commits into
mainfrom
capy/gst-1681-granted-third-fix-round
Nov 6, 2026
Merged

capy-ai[bot] merged 2 commits into
mainfrom
capy/gst-1681-granted-third-fix-round

Conversation

@garrytan

@garrytan garrytan commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 4096,
  "head": "24082b93f4551c308bf3a2a4a3b06b04475d4dd5",
  "version": "1.97.0.0",
  "base": "main",
  "gate": {
    "free": {
      "pass": 1620,
      "fail": 0,
      "skip": 6
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42296806806,
      "attempt": 1,
      "tree": "da3d01ac6b29cf9d7a5cbaf31eae059cffbafee4"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "da3d01ac6b29cf9d7a5cbaf31eae059cffbafee4",
  "product_patch_id": "606078c7c874cf03114e30c99923ddcd574bfaaf",
  "gstack_version": "1.97.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 31,
    "rules": "70895942bb8a8ee2",
    "base": "688e3ab9d131bd4f9d7b173d81ed15c299d3387a",
    "registry": "688e3ab9d131bd4f9d7b173d81ed15c299d3387a",
    "gate_scan": {
      "tagged": 0,
      "head": "24082b93f4551c308bf3a2a4a3b06b04475d4dd5"
    },
    "reasons": [
      "gate-class",
      "runtime=31"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @da3d01ac6b29 (8 checks, current for 24082b93f455)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42296806806/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/42295454723/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=da3d01ac6b29 tests=36068 skipped=92 runs=42296806806/1 profiles=ci-reuse/free-tests heads=24082b93f455 verified=2026-11-06T21:34:06.754Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ and changelog.d/ (read-only audit of the 10 committed files, 688e3ab9..24082b93)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 1,
    "deferred": 0,
    "noted": 5,
    "fixed": 2,
    "scope": "frozen",
    "rounds": 2,
    "est_input_tokens": 4730,
    "unrecorded": 1,
    "ledgers_read": 4,
    "dispatches": {
      "specialist-batched": 2,
      "red-team": 2
    }
  },
  "ruled_notes": [
    {
      "finding": "bin/gstack-review-plan:167:adversarial",
      "head": "24082b93f4551c308bf3a2a4a3b06b04475d4dd5",
      "by": "Captain GStack Minder (GSTA-36), 2026-11-06",
      "reason": "Caller-written timestamp fails toward one wasted fix-check; finish one-grant-per-link still refuses a false clear; follow-up GST-1684",
      "at": "2026-11-06T21:30:07.066Z",
      "approval": "a-fd9dcccd3139"
    }
  ]
}

What changed

Before: after round 2's fix-check and one granted fix-check, an owner who granted one more round at the last fix-check's stop head got NEXT: stop from gstack-review-plan. In the loop a fix-check never earned another, so GEVA-363 (gstack-evals#254) hand-ran fc3 on a --fix-range token and finish printed FIX_CHECK: not counted (fix-range pass; only a later full pass can clear review).

After: a new recorded review_loop_grant naming the last fix-check's commit (--range-base, the stop it answers) plans one more scoped fix-check, the next link of the fix-check chain finish already counts. A grant recorded before a later logged fix-check has already bought its link, so the planner refuses it (exit 3) instead of planning a second paid fix-check on one grant.

Why

#4093 (GST-1676) covered this only for --post-review. The in-loop stop after a second fix-check still had no path, so a Captain's grant past the cap was hand-rendered and finish couldn't count it.

How

  • bin/gstack-review-plan: outside --post-review, after a fix-check, a grant whose stop head is exactly --range-base sets a new chained history flag. The previous link's grant names an earlier stop head and is refused (exit 3); a grant at any other commit plans nothing. One grant, one link.
  • bin/gstack-review-plan (24082b9, the pre-landing review fix): in the loop, a grant recorded before a later logged review-fix-check row is spent and refused (exit 3). That closes the replay pass 1 found, where a post-review link's grant or a stale --range-base bought a second link. When gstack-review-read can't read the log, the planner fails closed (exit 1) rather than plan a fix-check the grant may not buy.
  • lib/review-depth.ts: nextStep turns that stop into one fix-check when chained, a grant and no open blocker are present; gate class still runs Step 11's voices first. Without chained a fix-check still never earns another (GEVA-223 and GST-1676 tests unchanged).
  • Docs: the transitions table in docs/review-policy.md and docs/ship-policy.md#fix-check-chain, plus the --grant help text.
  • Pin: lib/review-depth.ts repinned under replay GST-1681 (deterministic no-loss: the GST-967 and GST-972 grids hash unchanged since none sets chained).

Tests (written first, failing on main)

  • test/review-plan-cli.test.ts GST-1681: GEVA-363's exact shape (--pass 1 --last fix-check --fix-checks 2 --fixed-blocking --range-base <fc2> --grant <grant at fc2>) plans a fix-check; the previous grant refuses; no grant, an open blocker, or a grant at another commit stop. It also pins GBRA-336's --post-review --last fix-check --fix-checks 2 --grant invocation, which plans on main since fix: finish counts a post-review fix-check chain's first link; review-plan plans the next chained fix-check (GST-1676) #4093.
  • test/review-plan-cli.test.ts (24082b9): "in the loop, a grant recorded before a later logged fix-check is spent and refused" covers the post-review-link replay and the stale --range-base replay, and a grant recorded after the newest fix-check still plans. It fails on 9bcbfa2's bin and passes at 24082b9.
  • test/review-depth.test.ts: the chained transition, lean and full loop, gate voices first.
  • test/ship-finish-ruled-notes.test.ts: finish counts the GEVA-363 chain (fc2 and fc3, each under its own grant; the in-cap fc1 isn't a link). This one already passes on main.

Blast radius

The planner only, and only after a fix-check with a grant. Nothing changes unless a grant names exactly the last fix-check's commit, and the new guard can only refuse such a grant, never plan one (read at bin/gstack-review-plan:165-167 and covered by the CLI regression).

Approvals

Approved: yes (record r-ed038bdcd511). The full approval record stays private: this repository is public or its visibility is unknown.

GStack Minder (GSTA-36) scoped this as GST-1681 step 2.

Summary

A Captain's grant for one more fix-check after a fix-check now plans that fix-check in the loop, and the same grant can't buy two. The branch has two commits. 9bcbfa2 is the planner change with its tests, and 24082b9 is the pre-landing review fix that refuses a spent grant.

Test Coverage

All new code paths have test coverage except the fail-closed read branch and malformed timestamps, both listed under Review notes.
Coverage: deterministic (4 changed runtime files each have a changed test: bin/gstack-review-plan 3, docs/review-policy.md 1, docs/ship-policy.md 2, lib/review-depth.ts 4).
Tests ran: free 1620 (files, CI carry run 42296806806/1 at tree da3d01ac6b29; 6 files skipped here, not owed)

Pre-Landing Review

Pass 1 (gate class, full depth, 4 dispatches) raised 3 issues. The 2 asked were fixed in 24082b9, and red team #2 became a note. Pass 2 (range 9bcbfa2..24082b9, 4 dispatches) raised 4 issues, all kept as notes, none deferred. Step 11: adversarial-native 5 findings (1 Medium folded into the ruled note, 4 Low noted), outside voice 1 CRITICAL (ruled below).

REVIEW_LOOP: passes=2 blocking_found=1 deferred=0 noted=5 fixed=2 scope=frozen unrecorded=1 ledgers_read=4 dispatches=4 est_input_tokens=4730

Ruled note: bin/gstack-review-plan:167:adversarial at 24082b9 ruled by Captain GStack Minder (GSTA-36), 2026-11-06 at 2026-11-06T21:30:07.066Z: Caller-written timestamp fails toward one wasted fix-check; finish one-grant-per-link still refuses a false clear; follow-up GST-1684 (approval a-fd9dcccd3139)

Gate edits: none detected (5 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Outside review: openai/gpt-6.1-sol (medium) found 1 CRITICAL (p2/outside-voice#1, bin/gstack-review-plan:167:adversarial: the spent-grant check trusts the caller-written timestamp). The Captain ruled it a disclosed note (above, follow-up GST-1684). VERIFY: clean for pass 1 and pass 2.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL bin/gstack-review-plan:166 The new fail-closed branch, which returns EXIT.fail when gstack-review-read exits nonzero, has no test. The GST-1681 test covers only the spent-grant refusal (exit 3) and the fresh-grant plan (exit 0). A regression that flips this guard to fail open, so the planner plans a fix-check whenever the review log can't be read, would pass the suite.
  • INFORMATIONAL bin/gstack-review-plan:167 The spent-grant check fails open when a timestamp doesn't parse. If a review-fix-check row has a missing or malformed timestamp, or a legacy approval row has no recorded_at, Date.parse returns NaN and the comparison is false. The grant is then treated as unspent, and that one grant can buy a second paid fix-check. No test covers either malformed input.
  • INFORMATIONAL bin/gstack-review-plan:167 Approval ids are deterministic: sha256 of source, date, ask, words and by (lib/approval-record.ts buildRow), and appendRows skips an id that is already present. The new spent-grant check now depends on recorded_at, so it matters when a fresh grant cannot be told apart from the spent one. The in-loop case this change handles reuses the same stop head as the spent grant (the test's gc and fresh both name c). If the lane records the owner's new grant with the same ask template, words and by on the same day, gstack-approvals add prints 'APPROVAL_RECORDED: (already present)' and keeps the old recorded_at. Every replan is then refused with exit 3, and the owner's legitimate grant can never buy its link. The refusal text makes this likely, because its suggested remedy is the generic template '... (review_loop_grant )'. Reproduced: two adds of an identical ask with words 'do it' and by 'GStack Minder', one second apart, returned the same id a-078957f004a5, and the second was marked 'already present'. The test avoids the collision only because its asks differ by a label ('post-review link at c' vs 'fc5').
  • INFORMATIONAL bin/gstack-review-plan:167 The check orders a fix-check against the grant by the row's caller-written timestamp field. gstack-review-log never stamps that field, and the ship prose only asks for 'ISO 8601'. The specialists already flagged the NaN case. This is a separate one: valid ISO 8601 forms that parse to the wrong instant. Date-only '2026-11-06' parses as UTC midnight. A zone-less '2026-11-06T21:20:30' written from date -u parses as local time, which is off by hours on a non-UTC machine such as a lane on Garry's Mac. Either form can place a fix-check that ran after the grant before recorded_at, so a spent grant looks unspent and buys a second paid fix-check. The logger already stamps a trusted start time on every bound row, review_binding.started_at, taken when the fix-check's start token is minted (lib/review-evidence.ts bindReview).
  • INFORMATIONAL bin/gstack-review-plan:161 (pass 1, red team refactor: reorganize codebase into modular structure #2, noted by lead judgment) A valid grant at a later in-range commit than --range-base is ignored in the loop after a fix-check without a message: the planner exits 0 with NEXT: stop asking for a grant. main behaves the same for that invocation, and refusing it would break GST-1676's pinned NEXT: stop case.
  • Low (Step 11 adversarial-native refactor: reorganize codebase into modular structure #2) Fix-checks that left only a dispatch ledger are invisible to the guard: it reads only review-log rows, so a granted fix-check whose row was never logged leaves its grant looking unspent.
  • Low (Step 11 adversarial-native Project-local .claude/skills/gstack install breaks /browse and setup can report false success #3) An incomplete fix-check still spends the grant: a completed:false or unavailable review-fix-check row refuses a rerun under the same grant. This fails closed, so it costs an owner round-trip, not safety.
  • Low (Step 11 adversarial-native Fix project-local /browse installs and harden setup #4) recorded_at and the fix-check row's time come from different clocks (the machine that ran gstack-approvals add and the lane machine), so clock skew can make a spent grant look unspent. Synced cloud clocks make this unlikely.
  • Low (Step 11 adversarial-native fix: harden /browse lifecycle and ref safety #5) On a timeout or launch failure spawnSync returns status: null, so the refusal prints "gstack-review-read exited null". The planner still fails closed; only the message is unclear.
  • Process (GST-1685) The Step 11 adversarial-native row was mis-logged converged:false, and the reader was rerun under the Captain's grant before Step 11.5 bound the reviews (VERIFY clean, briefs=1 outputs=1).

Exploratory QA

Smoke probe qa-probe.sh reproduced pass-1 red team #1 on 9bcbfa2 (a spent grant replayed and planned NEXT: fix-check). The fixed regression test fails on 9bcbfa2's bin and passes at 24082b9.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped (no prompt, template, judge or harness change; eval:select lists behavior probes as release coverage only, quality judges none).

Review bot comments

No review bot comments.

Plan Completion

Plan completion audit: not run (no plan bound; --kind fix)

Issues

Refs p1/red-team#1
Refs p1/specialist-batched#1

TODOS

No TODO items completed in this PR.

Documentation

Status: current. No documentation edits were needed, and there are no blockers.

Scope: the 10 committed files from base 688e3ab to head 24082b9 (no staged, unstaged or new files). The changes are the GST-1681 in-loop granted fix-check chain link in bin/gstack-review-plan and lib/review-depth.ts, with tests and fixtures.

Documentation health:

  • docs/review-policy.md: current. The round-3 prose and the transitions table cover the in-loop grant link.
  • docs/ship-policy.md: current. The cap section explains the in-loop link and why the previous link's grant is refused.
  • changelog.d/capy-gst-1681-granted-third-fix-round.md: current. The fragment matches the behavior.
  • bin/gstack-review-plan --help: current. The --grant help text describes the new link.

Coverage debt: the new History.chained field and the in-loop grant path have reference coverage (the policy docs and the CLI help) but no how-to example. That is a common gap, and nothing critical is missing.

Diagram drift: none.

Test plan

  • bun run test (CI carry, free-tests run 42296806806/1 at tree da3d01ac6b29): 1620 files pass, 0 fail, 6 skip (not owed here)
  • Focused at 24082b9: review-plan-cli, review-depth, module-size-ratchet and spawnsync-timeout-tripwire, 199 of 199 green; bun run typecheck clean; bun run typecheck:test no new diagnostics
  • gstack-pregate at tree da3d01ac6b29: requires-remote cleared (macos-named-regressions and remote_gate by run 42296806806/1, windows-smoke by run 42295454723/1)

🤖 Generated with Claude Code

Open in Capy

In the loop, a new review_loop_grant naming the last fix-check's commit
(--range-base, the stop it answers) plans one more scoped fix-check, the
next link of the fix-check chain finish counts (GEVA-363, gstack-evals#254).

Replay: GST-1681 (repins lib/review-depth.ts)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

In the loop, a grant recorded before a later logged fix-check already bought a link of the fix-check chain, so gstack-review-plan refuses it (exit 3): a post-review link's grant names the commit its fix-check read, and a stale --range-base names an earlier link. A CLI regression covers both, and a grant recorded after the newest fix-check still plans.

Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/specialist-batched#1 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
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