Skip to content

v1.91.266.0 feat(pr-wait): gstack-pr-wait event watcher (tstack pr-wait design port) and /land-and-deploy Step 3 wiring - #3495

Merged
capy-ai[bot] merged 6 commits into
mainfrom
gsta-119/pr-wait
Oct 27, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
gsta-119/pr-wait

Conversation

@garrytan

@garrytan garrytan commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3495,
  "head": "c26e7401379b7f5893f81e64c8eacd7cd6c5931d",
  "version": "1.91.256.0",
  "base": "main",
  "gate": {
    "pr-wait": {
      "pass": 48,
      "fail": 0,
      "skip": 0
    },
    "adjacent": {
      "pass": 419,
      "fail": 0,
      "skip": 0
    },
    "parity-suite": {
      "pass": 2,
      "fail": 0,
      "skip": 0
    },
    "remote-gate(ubicloud)": {
      "pass": 22814,
      "fail": 0,
      "skip": 0
    }
  },
  "spend_usd": 0.11,
  "session_kind": "unattended",
  "thread": "GSTA-119",
  "pregate": "requires-remote cleared @ff932f808db1 (1 checks, current for c26e7401379b)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/40412029841",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/40412029841",
    "windows-free-tests.yml/windows-free-shard: https://github.com/garrytan/gstack/actions/runs/40412034135",
    "pregate.json/remote_gate: remote-gate tree=ff932f808db1 tests=22814"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      3495
    ],
    "flakes": []
  },
  "review_loop": {
    "passes": 3,
    "blocking_found": 1,
    "deferred": 0,
    "noted": 12,
    "fixed": 22,
    "scope": "frozen"
  }
}

What changed

/land-and-deploy Step 3 before (4-minute gstack-ci-gate polling rounds) and after (one gstack-pr-wait call), plus a captured watcher run on garrytan/gstack#3487 naming its failing free-tests job and refusing a duplicate watcher

Before: Step 3 polls gstack-ci-gate --wait 240 in 4-minute rounds for 15 minutes, then asks whether to wait more. After: one gstack-pr-wait "$PR_NUMBER" --repo "$REPO" --until green call. Bottom: the watcher run on this repository on 2026-10-26, naming #3487's failing job with its link in one poll, and a second watcher for the same PR refusing to start.

bin/gstack-pr-wait, lib/pr-wait.ts, lib/pr-wait-github.ts. An event-driven pull-request watcher, a TypeScript port of the design of tstack's pr-wait (t3dotgg/tstack, MIT, Theo Browne) on gstack's isolated bun shebang. gstack-pr-wait <pr> [--repo owner/name] [--until green|ready|any-change] [--interval SECONDS] [--timeout MINUTES] prints one stdout line per real event, prefixed #<pr>, with progress on stderr, so a monitor wakes the agent once per event and never for a poll that found nothing. Events: a check failed (name and link), all checks finished on the head, a comment, review, thread or reply from someone other than the PR author or the gh user, a review bot finished on the head or a gating bot's summary changed, the base branch moved and its new commits touch this PR's files, merge state BEHIND or DIRTY (once per head), merged or closed.

  • green gates on every check on the head, as gstack-ci-gate does, so /land-and-deploy Step 2 and Step 3 read the same set and cannot bounce. A check the base branch requires (rulesets and classic branch protection; a 403 on the classic read is logged and skipped) is pending until it appears, never green by omission. Two identical polls confirm the check set before green.
  • ready is green plus a gating bot's review of the head (green alone when no gating bot is configured), no unresolved review thread, and a known merge state (GitHub's UNKNOWN right after a push holds it). A gating bot's failed check is a failed check, never a review.
  • --timeout (default 60 minutes, 0 for none) ends a watch that met nothing as PR_WAIT_BLOCKED, naming the still-pending checks.
  • Exit 0 when the condition is met or the PR merged; 1 when it needs action (PR_WAIT_BLOCKED); 2 on bad input, an unreadable PR, a live second watcher for the same PR, or a local error such as an unwritable state root (PR_WAIT_REFUSED), so exit 1 always carries a PR_WAIT_BLOCKED line. The loop is synchronous and installs no signal handlers: Ctrl-C and kill stop it at once and the next watcher takes over a dead pid's lock.
  • State lives under <state root>/pr-wait/<owner>__<name>__<pr>.json through the lib/state-root.ts chain; a baseline older than 6 hours is discarded, and a restart within that window reports what arrived while no watcher ran. Transient gh failures (5xx, 429, network, gh's own 60 s spawn timeout) retry with doubling backoff; ten failed polls in a row end the watch as blocked. Control characters in GitHub text never start a second stdout line.

Review bots are configuration, not constants. gstack-config set pr_wait_gating_bots greptile,macroscope (default) names the bots --until ready waits for; pr_wait_advisory_bots coderabbit (default) names the ones whose review it reports but never waits on (their checks gate like any other). A bot owns the logins that start with its name (greptile-apps[bot], not notgreptile) and the checks that mention it. Values are comma-separated lowercase names; none empties a list; anything else is rejected with the stored value unchanged.

/land-and-deploy Step 3 is one watcher call. Exit 0 reruns Step 2's gate on the pinned head (a moved head is a new push: restart at Step 1); exit 1 stops with the watcher's lines (a red required=n check stays the one case Step 3.5 may approve; a timeout is a STOP with the pending checks named); exit 2 shows the refusal. The Important Rules line about polling intervals names the watcher. The generated skill renders at exactly its pinned size on every host, so no pin moved.

Result codes and docs. PR_WAIT_BLOCKED and PR_WAIT_REFUSED in lib/result-codes-release.ts (the generated bin/gstack-doctor-components.sh anchor table gained both), a ## gstack-pr-wait section with both anchors in docs/troubleshooting.md, a row in docs/standalone-binaries.md, the README standalone-CLI list, CHANGELOG under [Unreleased], and NOTICE.md's tstack entry extended with the design-port paragraph (licenses/MIT-tstack.txt).

Out of scope here (GSTA-110 owns lib/ship-queue*): wiring the base-overlap event into gstack-ship-queue. What the train would consume is written up in the Captain's drive at handoffs/GSTA-119/ship-queue-consumer.md.

Why

Every crew thread babysits its PR by hand today: /land-and-deploy polls CI in 4-minute rounds for 15 minutes and then asks, learns that main moved under its files only when the merge train refuses the pin, and learns about a reviewer's comment only when a person says so. A watcher that prints one line per real event turns all three into push-time signals the agent can act on. Garry approved the tstack/pstack absorption plans at full scope on 2026-10-26 ("Do it, send"); this is item 1 of plans/absorb-tstack.md §4.

Approvals

Date Asked Exact words Outcome Covers Still pending
2026-10-26 Absorb the tstack and pstack plans (plans/absorb-tstack.md §4 item 1: gstack-pr-wait watcher + /land-and-deploy Step 3 wiring, review bots as config, MIT notice in NOTICE.md) “Do it, send” (Garry (via GStack Minder, GSTA-36)) approved every recommendation in plans/absorb-tstack.md and plans/absorb-pstack.md at full scope: this watcher, its land-and-deploy wiring, the gstack-config bot lists, the NOTICE.md MIT notice none
2026-10-15 Spend on this PR's checks “it's fine run as many $93 paid gates as you want who cares” (Garry) standing approval three Ubicloud free-suite runs for this PR ($0.04 + $0.04 + $0.03); no paid eval case ran none

Source: gstack-approvals record for gsta-119/pr-wait (display only; not an approval citation).

Summary

  • The watcher: bin/gstack-pr-wait, lib/pr-wait.ts (event logic, state, lock, the three --until conditions, --timeout), lib/pr-wait-github.ts (the gh reads: GraphQL PR, checks, rulesets and protection, compare, behind-by; transient retry).
  • Configuration: gstack-config keys pr_wait_gating_bots and pr_wait_advisory_bots with set-time validation.
  • Wiring: /land-and-deploy Step 3 and its Important Rules line; test/land-and-deploy-ci-gate.test.ts pins the new shape.
  • Three /ship review passes folded in (see Pre-Landing Review): every check gates green, --timeout, prefix-matched bot logins, no signal handlers, ETIMEDOUT retried, local faults as exit 2, BEHIND keyed on the head, a verdict that survives a failed state save.

Test Coverage

test/pr-wait.test.ts (new, 48 cases through a fake gh runner): the baseline poll, the six-hour staleness and the restart carry, author/gh-user/bot/edit filtering, merged and closed, a required check pending by omission, a failed required check on the baseline poll, an unknown bucket as failed, two identical polls before green, every check on the head gating (a pending or red non-required check), a failed gating-bot check, prefix-matched bot logins, ready with a gating bot, with none configured, and while the merge state is UNKNOWN, unresolved threads and BEHIND blocking ready, the base-overlap event and its silent negative, BEHIND once per head and never again for a moving base, DIRTY, the configured bot lists and none, the per-PR lock (live holder refused, dead holder taken over, released on exit, a real SIGTERM against the bin), --timeout, the ten-failure and non-transient run() endings, a gh spawn timeout retried, a local fault as exit 2, a verdict kept when the state file cannot be written, control characters in check names, gstack-config rejecting malformed bot lists and its defaults matching the lib constants, argument parsing, and the fourteen state-matrix cells the state-machines specialist listed (gstack-state-matrix check: ok, 37/37 cells tested).

Tests ran: pr-wait 48; adjacent (troubleshooting-anchors, doctor-components, gstack-doctor, plan-tune-cathedral, timeline-stop-hook-slug, pr-dependencies, spawnsync-timeout-tripwire, module-size-ratchet, land-and-deploy-ci-gate, gstack-config-defaults, changelog-merge-damage, skill-md-size-guard) 419; parity-suite 2; full free suite on Ubicloud 22,814 (0 failed) at tree ff932f808db1 = c26e740.

Pre-Landing Review

Pass 1 (whole diff; 6 specialists + Red Team): 16 findings, 1 blocking. The blocker: the bin's SIGINT/SIGTERM/SIGHUP handlers never ran in the synchronous poll loop and made the process ignore kill (Red Team, confidence 9). Also fixed in pass 1: Step 2 (every check) and Step 3 (--until green, required only) disagreeing while a non-required check pends; ready polling forever with an empty gating list or when the merge state is UNKNOWN; no deadline; a gh spawn timeout treated as fatal; a failed gating-bot check counting as a review; substring bot logins; control characters on stdout; an uncaught local error exiting 1 without a PR_WAIT_BLOCKED line; BEHIND announced on the transition only; the test gaps (config validation, run() negative paths, 14 state-matrix cells). Pass 2 (range 7da2d98..13c5784; 6 specialists + Red Team + Claude adversarial): no blocker; fixed the advisory-check exemption that still let Step 2 and Step 3 disagree, BEHIND re-announced on every base commit, a verdict downgraded to exit 2 when the final state save failed, two stale result-code summaries and a stale docstring. Pass 3 (range 13c5784..c26e740, the cap; 6 specialists + Red Team + Claude adversarial): NO FINDINGS from 4 reviewers, notes only from the rest, no edits applied.

REVIEW_LOOP: passes=3 blocking_found=1 deferred=0 noted=12 fixed=22 scope=frozen

Gate edits: none detected (every changed file unmatched by gstack-gate-diff main; the two gate-adjacent files are listed under Gate integrity below).

Outside review: Codex unavailable (not installed on this machine); missing coverage. The Claude adversarial subagent ran on pass 2 and pass 3 (fixtures in summary mode); recommendations "ship as-is" both times.

Review notes

Below-floor items left as named notes (docs/review-policy.md: not fixed after pass 1, no further pass):

  • lib/pr-wait.ts:276 isAdvisory() is dead since pass 2 made advisory checks gate; delete in the next touch.
  • lib/pr-wait.ts:376 the (advisory, not waited on) suffix on a check-backed advisory bot's "finished" line sits beside the check failed line when that same check blocked the watch; reword to "(advisory review, not waited on)" or drop it when the bot has checks.
  • docs/standalone-binaries.md:19 carries both the new "its checks gate like any other" clause and the older "(advisory bots are reported, never waited on)" parenthetical in one row.
  • lib/pr-wait.ts:272 bot ownership of a login is a case-insensitive prefix match and does not require the GraphQL Bot typename; a human account named greptile-fan would be treated as greptile. Not reachable from --until green, which is what /land-and-deploy runs. Ruled (GStack Minder, 2026-10-26): bot ownership stays login-list based; no Bot typename requirement.
  • lib/pr-wait.ts:479 the --timeout deadline is checked after each successful poll, so a stretch of gh retries can run past it; the ten-failed-polls rule bounds that case.
  • lib/pr-wait.ts:480 the timeout line names only pending checks; when ready is unmet because no gating bot reviewed or the merge state stayed UNKNOWN it says "nothing pending, the condition was not met".
  • lib/pr-wait.ts:404 State.merge_state is written and never read since BEHIND/DIRTY are keyed on the head.
  • lib/pr-wait-github.ts:94 fatal-vs-retry for a spawn error keys on the "not installed" wording lib/ci-gate.ts produces.
  • bin/gstack-pr-wait a lock whose pid was recycled by an unrelated live process refuses with kill <pid> advice; pid plus start time would close it.
  • lib/pr-wait.ts:250 the stdout sanitizer strips C0/DEL only; C1 controls and bidi overrides in a comment snippet pass through to a human reader.
  • lib/pr-wait.ts:435 --until any-change and the ready default have no in-repo caller yet (ported contract, kept).
  • land-and-deploy/SKILL.md.tmpl:188 a non-required check stuck in pending now holds --until green for the full timeout and then stops; gstack-ci-gate --exclude has no watcher equivalent. Ruled (GStack Minder, 2026-10-26): add --exclude <check,...> to gstack-pr-wait as a follow-up PR after this one lands, not in this pin.

Exploratory QA

Functional surface: the gstack-pr-wait CLI and the two gstack-config keys, read-only against garrytan/gstack with an isolated GSTACK_STATE_ROOT. Eleven probes (.gstack/qa-reports/gsta119-ship-20261026T214018Z/functional, checkpoints 002–011): --help exit 0; #3487 --until green named its failed check with the run link and exited 1 with the PR_WAIT_BLOCKED line (before the fixes it reported green because the failing check was not required; after them, probe 011, it blocks on windows-free-shard (4) and windows-free-tests); a non-PR target refused with exit 2 and the PR_WAIT_REFUSED anchor; gstack-config set pr_wait_gating_bots 'Greptile, foo' rejected with exit 1 and the stored value unchanged (probes 004/005 ran the installed 1.91.256.0 binary by mistake and were superseded by 007/008 on this branch's bin); none empties the advisory list; a stale lock holding a dead pid was taken over; #3495 itself at 7da2d98 (every check green) exited 0 with one green on 7da2d98: 48 pass, 11 skipping line. No product defect open.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt a paid case covers changed in a way that needs a paid run: the land-and-deploy Step 3 prose change is pinned by test/land-and-deploy-ci-gate.test.ts and the skill renders at exactly its pinned size; parity-suite 2/0.

Greptile Review

No Greptile comments.

Documentation

Updated with the code: docs/troubleshooting.md (## gstack-pr-wait, anchors pr-wait-blocked and pr-wait-refused), docs/standalone-binaries.md, README standalone-CLI list, bin/gstack-config header comments, the watcher's own usage text, CHANGELOG [Unreleased], NOTICE.md and licenses/MIT-tstack.txt.

Gate integrity

No threshold, timeout, trial count or case kind changed. Gate-adjacent edits in the diff: test/fixtures/module-size-ratchet.json registers lib/pr-wait.ts and lib/pr-wait-github.ts under the existing 800-line cap; test/land-and-deploy-ci-gate.test.ts's Step 3 assertion changes from "calls gstack-ci-gate --wait N" to "one gstack-pr-wait call, the three exit outcomes, no polling prose", because the prose it pinned is the prose this PR replaces. test/fixtures/skill-md-size-allowlist.json is unchanged.

Issues

Refs #3495

…rt) and /land-and-deploy Step 3 wiring

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 5 commits October 26, 2026 21:31
… fixtures that copy the module list keep working

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…regate TSX import scanner maps the lib files

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…t, bot identity, signal disposition

Red Team and specialist findings on #3495, all fixed in the diff:

- green gates on every check on the head, as gstack-ci-gate does, so
  land-and-deploy Step 2 and Step 3 can no longer disagree while a
  non-required check pends; required checks still gate before they appear
- --timeout MINUTES (default 60, 0 = none) ends a watch that met nothing as
  PR_WAIT_BLOCKED naming the still-pending checks; restores Step 3's cap
- a bot owns logins that start with its name (greptile-apps[bot]), not any
  login containing it; a failed gating-bot check is a failed check, never a
  completed review
- ready: green alone when no gating bot is configured (pr_wait_gating_bots
  none no longer polls forever); held while merge state is UNKNOWN
- BEHIND and DIRTY announced once per head, with the short head in the line
- the bin installs no signal handlers: the synchronous loop never ran them
  and they made the process ignore SIGTERM/SIGINT; default disposition kills
  it at once and the next watcher takes over the dead pid's lock
- a gh spawn timeout (ETIMEDOUT) is retried like any transient failure
- a local fault (unwritable state root) is PR_WAIT_REFUSED exit 2, so exit 1
  always carries a PR_WAIT_BLOCKED line
- control characters in GitHub text never start a second event line

Tests: 21 new cases including a real SIGTERM against the bin, gstack-config
set-time validation and default parity, and the 14 state-matrix cells the
state-machines specialist listed (gstack-state-matrix check: ok, 33/33).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…keyed on the head, verdict survives a failed save

- an advisory bot's review is never waited for, but its check gates like any
  other, so gstack-ci-gate (Step 2) and gstack-pr-wait --until green (Step 3)
  read the same check set with no exception
- BEHIND and DIRTY are keyed on the head alone; the pass-1 key also held the
  base oid, so a base that kept moving re-announced BEHIND to a restarted
  watcher on every commit
- finish() keeps the printed verdict's exit code when the state file cannot
  be written; the save error goes to stderr
- PR_WAIT_BLOCKED and PR_WAIT_REFUSED summaries name every exit-1 and exit-2
  path (--timeout, a local error); emitBots docstring matches the gating rule
- CHANGELOG says what a timeout means at land-and-deploy Step 3: a STOP with
  the pending checks named, no wait-more question

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…eploy Step 3 wiring (#3495)

Merge origin/main a50cf58 into gsta-119/pr-wait (CHANGELOG.md resolved by mergeChangelogs, additive).

RESTAMP: 1.91.265.0 -> 1.91.266.0 (stamped; queue_mode=stamp-at-merge base=origin/main@a50cf58 policy=base origin/main@a50cf589656c:.gstack/ship-policy.json)
STAMP_VERSION: 1.91.266.0
stage version: done (wrote 1.91.266.0)
stage release_tool: done (bun scripts/gen-agents-digest.ts)
stage changelog: done (Unreleased -> 1.91.266.0)
stage apply: done (4 file(s))
FILES: CHANGELOG.md VERSION agents-digest/gstack-AGENTS.md package.json
MERGE_CONDITION: sha=c26e7401379b7f5893f81e64c8eacd7cd6c5931d

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@github-actions github-actions Bot changed the title feat(pr-wait): gstack-pr-wait event watcher (tstack pr-wait design port) and /land-and-deploy Step 3 wiring v1.91.266.0 feat(pr-wait): gstack-pr-wait event watcher (tstack pr-wait design port) and /land-and-deploy Step 3 wiring Oct 27, 2026
@capy-ai
capy-ai Bot merged commit 6bbd0a5 into main Oct 27, 2026
63 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