Repository navigation
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
Merged
Conversation
…rt) and /land-and-deploy Step 3 wiring Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
… 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>
6 tasks done
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: Step 3 polls
gstack-ci-gate --wait 240in 4-minute rounds for 15 minutes, then asks whether to wait more. After: onegstack-pr-wait "$PR_NUMBER" --repo "$REPO" --until greencall. 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'spr-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.greengates on every check on the head, asgstack-ci-gatedoes, so/land-and-deployStep 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 beforegreen.readyis 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'sUNKNOWNright 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 asPR_WAIT_BLOCKED, naming the still-pending checks.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 aPR_WAIT_BLOCKEDline. The loop is synchronous and installs no signal handlers: Ctrl-C andkillstop it at once and the next watcher takes over a dead pid's lock.<state root>/pr-wait/<owner>__<name>__<pr>.jsonthrough 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 readywaits 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], notnotgreptile) and the checks that mention it. Values are comma-separated lowercase names;noneempties a list; anything else is rejected with the stored value unchanged./land-and-deployStep 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 redrequired=ncheck 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_BLOCKEDandPR_WAIT_REFUSEDinlib/result-codes-release.ts(the generatedbin/gstack-doctor-components.shanchor table gained both), a## gstack-pr-waitsection 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 intogstack-ship-queue. What the train would consume is written up in the Captain's drive athandoffs/GSTA-119/ship-queue-consumer.md.Why
Every crew thread babysits its PR by hand today:
/land-and-deploypolls 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
Source: gstack-approvals record for gsta-119/pr-wait (display only; not an approval citation).
Summary
bin/gstack-pr-wait,lib/pr-wait.ts(event logic, state, lock, the three--untilconditions,--timeout),lib/pr-wait-github.ts(the gh reads: GraphQL PR, checks, rulesets and protection, compare, behind-by; transient retry).gstack-configkeyspr_wait_gating_botsandpr_wait_advisory_botswith set-time validation./land-and-deployStep 3 and its Important Rules line;test/land-and-deploy-ci-gate.test.tspins the new shape.--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,readywith a gating bot, with none configured, and while the merge state is UNKNOWN, unresolved threads and BEHIND blockingready, the base-overlap event and its silent negative, BEHIND once per head and never again for a moving base, DIRTY, the configured bot lists andnone, 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-transientrun()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-configrejecting 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;readypolling 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 aPR_WAIT_BLOCKEDline; 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
unmatchedbygstack-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:276isAdvisory()is dead since pass 2 made advisory checks gate; delete in the next touch.lib/pr-wait.ts:376the(advisory, not waited on)suffix on a check-backed advisory bot's "finished" line sits beside thecheck failedline 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:19carries 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:272bot ownership of a login is a case-insensitive prefix match and does not require the GraphQLBottypename; a human account namedgreptile-fanwould 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; noBottypename requirement.lib/pr-wait.ts:479the--timeoutdeadline 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:480the timeout line names only pending checks; whenreadyis 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:404State.merge_stateis written and never read since BEHIND/DIRTY are keyed on the head.lib/pr-wait-github.ts:94fatal-vs-retry for a spawn error keys on the "not installed" wordinglib/ci-gate.tsproduces.bin/gstack-pr-waita lock whose pid was recycled by an unrelated live process refuses withkill <pid>advice; pid plus start time would close it.lib/pr-wait.ts:250the 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-changeand thereadydefault have no in-repo caller yet (ported contract, kept).land-and-deploy/SKILL.md.tmpl:188a non-required check stuck in pending now holds--until greenfor the full timeout and then stops;gstack-ci-gate --excludehas 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-waitCLI and the twogstack-configkeys, read-only against garrytan/gstack with an isolatedGSTACK_STATE_ROOT. Eleven probes (.gstack/qa-reports/gsta119-ship-20261026T214018Z/functional, checkpoints 002–011):--helpexit 0; #3487--until greennamed its failed check with the run link and exited 1 with thePR_WAIT_BLOCKEDline (before the fixes it reported green because the failing check was not required; after them, probe 011, it blocks onwindows-free-shard (4)andwindows-free-tests); a non-PR target refused with exit 2 and thePR_WAIT_REFUSEDanchor;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);noneempties the advisory list; a stale lock holding a dead pid was taken over; #3495 itself at 7da2d98 (every check green) exited 0 with onegreen on 7da2d98: 48 pass, 11 skippingline. 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.tsand 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, anchorspr-wait-blockedandpr-wait-refused),docs/standalone-binaries.md, README standalone-CLI list,bin/gstack-configheader comments, the watcher's own usage text, CHANGELOG[Unreleased], NOTICE.md andlicenses/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.jsonregisterslib/pr-wait.tsandlib/pr-wait-github.tsunder the existing 800-line cap;test/land-and-deploy-ci-gate.test.ts's Step 3 assertion changes from "callsgstack-ci-gate --wait N" to "onegstack-pr-waitcall, the three exit outcomes, no polling prose", because the prose it pinned is the prose this PR replaces.test/fixtures/skill-md-size-allowlist.jsonis unchanged.Issues
Refs #3495