Skip to content

Refuse to archive a thread that holds an open PR, and close a landed PR's issue (GST-2188) - #4244

Merged
capy-ai[bot] merged 6 commits into
mainfrom
capy/catch-orphaned-work-at-archive-and-land
Nov 9, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
capy/catch-orphaned-work-at-archive-and-land

Conversation

@garrytan

@garrytan garrytan commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

A thread that still has an open pull request can no longer be archived, and the issue a merged pull request names now closes in the same step. This serves the crew goal that no PR or issue is left with nobody to wake it.

Summary

gstack-archive-check thread runs right before a Captain archives a crew thread. The Captain writes the raw thread and open-issue reads to a file, and the check re-reads every PR the thread holds from GitHub. It refuses while any PR is open, successor or not (R91), or while an issue in a working state is still assigned to the thread. It refuses stale, truncated, header-only or unparsable reads and failed gh reads. Every run prints a handoff stub for a successor brief. gstack-archive-check landed --pr <n> names the tracker codes in a merged PR's title so the Captain closes those issues in the same program.

What changed

  • New bin/gstack-archive-check and lib/archive-check.ts, with five ARCHIVE_* result codes and troubleshooting sections.
  • crew/docs/captain.md, capy/skill/gstack/factory.md item 12, /captain, /runaway-stopper and the successor brief now say a thread with an open PR stays until that PR merges or closes.
  • docs/skills.md says the same for the runaway-stopper Stop step.

Why

A 6-hour sweep found orphans hours after they happened: 24 archived threads with open PRs in the first sweep, then 14 more plus 12 live issues. Checking at archive time stops them before they exist.

Blast radius

Captains archiving crew threads and the land step. The check fails closed, so a bad read blocks an archive instead of allowing one. gstack-ship-queue is unchanged.

Documentation

Re-audit after rebasing onto main 6088c86 (#4240). Scope: the two files with rebase conflicts, capy/skill/gstack/factory.md item 12 and the docs/skills.md /runaway-stopper Stop bullet, plus cross-reference checks against crew/docs/captain.md and docs/troubleshooting.md. Result: current, with no edits. Both conflict files keep #4240's PR-scoped handoff and 1B check-in wording and add this branch's rule never to archive a thread that holds an open PR (R91), enforced through gstack-archive-check thread. The gstack-archive-check docs and troubleshooting codes agree with that wording. Debt: none found. The rest of the docs were covered by the first audit (ship4244-docs1).

Documentation exception: accepted by Captain GStack Minder (GSTA-36) 2026-11-09 via Captain reply relayed by GSTA-462 at head 4ae42d8: runaway-stopper/SKILL.md step 3 was trimmed by 2 lines after docs re-audit ship4244-docs2, to fit the context budget; the trim was reviewed by the granted fix-check (no findings above the floor). Accepted by Captain GStack Minder (GSTA-36), 2026-11-09.

Test plan

  • test/archive-check.test.ts: written failing first, then extended by the review fixes (stub truncation, landed CLI, header-only issue lists, case-insensitive codes).
  • Focused set on the rebased tree: 495 pass, 0 fail, typecheck clean; CI run 42702356486 green at 4ae42d8.
Agent notes

Approvals

Approved: yes (record r-67ae61234af2). The full approval record stays private.
Plan: approved (record r-4ebf5d80b9a2)
Plan check: approved (record r-4ebf5d80b9a2)

REVIEW_LOOP: plan once (gate panel), one fix round, owner grants a-17bfd75b8437 and a-afeb441aaf97 (scoped fix-checks), docs-risk exception a-5067421a16e0.

Agent notes
{
  "schema_version": 1,
  "pr": 4244,
  "head": "4ae42d87bd3c77604ce3dc47af3b706e68b1f6cd",
  "version": "1.98.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1656,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42702356486,
      "attempt": 1,
      "tree": "72d30e155c865744c48b960072ae01a23e19dd85"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "72d30e155c865744c48b960072ae01a23e19dd85",
  "product_patch_id": "9d1ce0a711f76748975868d309f2af30cf11761e",
  "gstack_version": "1.98.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 341,
    "rules": "66e5174161eecc2c",
    "base": "6088c86f61b104062c5530cdc7359823590fe924",
    "registry": "6088c86f61b104062c5530cdc7359823590fe924",
    "gate_scan": {
      "tagged": 2,
      "head": "4ae42d87bd3c77604ce3dc47af3b706e68b1f6cd"
    },
    "reasons": [
      "gate-class",
      "risk:security",
      "runtime=341"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @72d30e155c86 (8 checks, current for 4ae42d87bd3c)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/42702356486/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42702356486/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/42702356542/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=72d30e155c86 tests=36902 skipped=106 runs=42702356486/1 profiles=ci-reuse/free-tests heads=4ae42d87bd3c verified=2026-11-09T21:42:48.481Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "blocked",
    "scope": "docs/, crew/docs/, capy/skill/gstack/, README.md (audits ship4244-docs1 updated, ship4244-docs2 current); runaway-stopper/SKILL.md step 3 trimmed after ship4244-docs2",
    "exception": {
      "accepted_by": "Captain GStack Minder (GSTA-36)",
      "date": "2026-11-09",
      "via": "Captain reply relayed by GSTA-462 at head 4ae42d87bd3c77604ce3dc47af3b706e68b1f6cd",
      "reason": "runaway-stopper/SKILL.md step 3 was trimmed by 2 lines after docs re-audit ship4244-docs2, to fit the context budget; the trim was reviewed by the granted fix-check (no findings above the floor). Accepted by Captain GStack Minder (GSTA-36), 2026-11-09."
    }
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 9,
    "fixed": 4,
    "scope": "frozen",
    "fix_checks": 3,
    "rounds": 4,
    "unbound": 2,
    "dispatches": {
      "specialist": 3
    }
  },
  "review_targeted": {
    "classes": [
      "gate"
    ],
    "rules": "8811fd300bf305f0",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "9d1ce0a711f76748975868d309f2af30cf11761e",
    "status": "done",
    "findings": 2,
    "raised_by": "targeted"
  }
}
{
  "schema_version": 1,
  "pr": 4244,
  "head": "4ae42d87bd3c77604ce3dc47af3b706e68b1f6cd",
  "version": "1.98.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1656,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42702356486,
      "attempt": 1,
      "tree": "72d30e155c865744c48b960072ae01a23e19dd85"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "72d30e155c865744c48b960072ae01a23e19dd85",
  "product_patch_id": "9d1ce0a711f76748975868d309f2af30cf11761e",
  "gstack_version": "1.98.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 341,
    "rules": "66e5174161eecc2c",
    "base": "6088c86f61b104062c5530cdc7359823590fe924",
    "registry": "6088c86f61b104062c5530cdc7359823590fe924",
    "gate_scan": {
      "tagged": 2,
      "head": "4ae42d87bd3c77604ce3dc47af3b706e68b1f6cd"
    },
    "reasons": [
      "gate-class",
      "risk:security",
      "runtime=341"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @72d30e155c86 (8 checks, current for 4ae42d87bd3c)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/42702356486/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42702356486/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/42702356542/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=72d30e155c86 tests=36902 skipped=106 runs=42702356486/1 profiles=ci-reuse/free-tests heads=4ae42d87bd3c verified=2026-11-09T21:42:48.481Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "blocked",
    "scope": "docs/, crew/docs/, capy/skill/gstack/, README.md (audits ship4244-docs1 updated, ship4244-docs2 current); runaway-stopper/SKILL.md step 3 trimmed after ship4244-docs2",
    "exception": {
      "accepted_by": "Captain GStack Minder (GSTA-36)",
      "date": "2026-11-09",
      "via": "Captain reply relayed by GSTA-462 at head 4ae42d87bd3c77604ce3dc47af3b706e68b1f6cd",
      "reason": "runaway-stopper/SKILL.md step 3 was trimmed by 2 lines after docs re-audit ship4244-docs2, to fit the context budget; the trim was reviewed by the granted fix-check (no findings above the floor). Accepted by Captain GStack Minder (GSTA-36), 2026-11-09."
    }
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 9,
    "fixed": 4,
    "scope": "frozen",
    "fix_checks": 3,
    "rounds": 4,
    "unbound": 2,
    "dispatches": {
      "specialist": 3
    }
  },
  "review_targeted": {
    "classes": [
      "gate"
    ],
    "rules": "8811fd300bf305f0",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "9d1ce0a711f76748975868d309f2af30cf11761e",
    "status": "done",
    "findings": 2,
    "raised_by": "targeted"
  }
}

@trunk-io

trunk-io Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 5 commits November 9, 2026 21:19
…GST-2188)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…R's issue (GST-2188)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ly that long PR lists cannot be checked

Review-Finding: p1/specialist-batched#2 reader=testing
Review-Finding: p1/specialist-batched#3 reader=state-machines
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#3 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…des in any case when closing a landed PR's issues

Review-Finding: p3/outside-voice#1 reader=outside-voice
Review-Finding: p3/outside-voice#2 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…one of its PRs is open

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…t budget after the rebase

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@garrytan
garrytan force-pushed the capy/catch-orphaned-work-at-archive-and-land branch from f8fa4e1 to 4ae42d8 Compare November 9, 2026 21:25
garrytan added a commit that referenced this pull request Nov 9, 2026
…with #4244

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit 83bfdc5 into main Nov 9, 2026
57 checks passed
garrytan added a commit that referenced this pull request Nov 9, 2026
…with #4244

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
capy-ai Bot added a commit that referenced this pull request Nov 9, 2026
…at hold a PR (GST-2226) (#4250)

* Stop the runaway scan from telling Captains to rotate crew threads that hold a PR (GST-2226)

Only a thread marked standing rotates, and never while it holds an open PR or its PR list is missing; a crew thread gets one CHECK_IN past 1B own tokens (R70 as amended, R91).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Trim the runaway-stopper wording so it fits the skill context budget with #4244

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Reword the runaway-scan changelog entry so it passes the prose check

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>
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