Skip to content

On Capy, /ship hands its pull request edits and comments to Capy's PR tool, always naming the right repository (GST-3183) - #4518

Merged
capy-ai[bot] merged 6 commits into
mainfrom
capy-host-publish-full-destination
Nov 19, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
capy-host-publish-full-destination

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

On Capy, /ship's PR body edits, comments and new PRs no longer go out through gh under the machine owner's GitHub account.
Each write runs its checks, saves the exact text to a private file and prints a HOST_PUBLISH: line that names the repository (and host, off github.com) it belongs to, so Capy's PR tool sends it to the same place gh would have.
Nothing changes outside Capy (GSTACK_CAPY unset).

Why

During an unattended /ship on garrytan/gbrain-evals#523 (gstack 1.101.0.0), the command that records /ship's review rounds in the PR body ran gh pr edit, so another system's PR body was edited as garrytan even though the brief said to publish only through the PR tool. The rule is that GitHub writes from Capy go only through Capy's PR tools.

A first version (#4517) handed the writes off but left the repository out when --repo wasn't passed, and /ship's own Step 9 call never passes it. Capy's PR tool would then fall back to the thread's main repository, so in a thread with several repositories or a fork, one PR's body could replace another repository's.

What changed
  • lib/host-publish.ts (new): hostPublishes() is true under GSTACK_CAPY=1. handOff() writes each part to its own private folder <state root>/publish/<op>-<target>-<random>/<part>.md (folder 0700, file 0600) and returns one HOST_PUBLISH: line naming the files, the destination and the host tool to use. It refuses a hand-off without an owner/name repository, so no caller can print a partial line.
  • The commands that record /ship's review rounds in the PR body (listed in Agent notes) hand off on Capy instead of running gh pr edit. They read the destination with gh repo view [--repo] --json nameWithOwner,url, the same resolution gh pr edit uses, and put repo= (and host= when it isn't github.com) on the line. When that read fails they refuse and hand nothing off.
  • gstack-post: every write op (pr-body, pr-title, pr-comment, issue-comment, reply, pr-create, issue-create) runs its plain-title, plain-body, security and secret checks as before, then hands off with the repository and host gh would have written to (read with gh repo view, so a fork checkout's upstream is honoured), a reply's comment id, and a new PR's base, head (the current branch when --head is missing, as gh pr create would infer) and draft state. A HIGH finding still refuses with no file written.
  • gstack-greptile-early open says the draft went to the host tool instead of "did not print the new PR URL".
  • Prose: the Capy PR section and Step 19's "mark it ready" line say to use the host's PR tool, to the repo= the line names; docs/troubleshooting.md#host-publish explains the line.
Blast radius

Only runs with GSTACK_CAPY=1 change; the --body <file> paths and every non-Capy path are byte-identical (the existing round-recording and gstack-post suites pass unchanged). Reads through gh (pr view, repo view, api GETs) are unchanged, plus one gh repo view read per round-recording hand-off.

Documentation

Status: current. Read-only audit of base f13dbb0..c6fc158 (6 commits, 15 files, clean working tree) found every changed doc accurate; nothing needed editing.

Scope: the Capy host-publish hand-off (GST-3183). It covers lib/host-publish.ts, gstack-post, gstack-ship-receipt stub/stop/claim/carry, the greptile-early hand-off exit, the ship capy-pr and pr-body sections and their templates, the new docs/troubleshooting.md#host-publish entry and the changelog fragment. Related docs read: docs/capy-install.md, docs/designs/GSTACK_ON_CAPY.md, docs/ship-policy.md, docs/writing-prs.md.

Documentation health

  • docs/troubleshooting.md: current. The host-publish entry matches the HOST_PUBLISH line format, the folder layout and file modes, how the repo and host are resolved, and the refusal when the repo can't be resolved.
  • ship/sections/capy-pr.md(.tmpl): current.
  • ship/sections/pr-body.md(.tmpl): current.
  • changelog.d/capy-ship-writes-through-host-pr-tool.md: current (reviewed only).
  • docs/capy-install.md, docs/designs/GSTACK_ON_CAPY.md, docs/ship-policy.md, docs/writing-prs.md: current. Nothing in them contradicts the change.

Coverage debt

  • HOST_PUBLISH: hand-off: has reference and how-to coverage (troubleshooting), plus mentions in the ship section. It isn't mentioned in the Capy install or design docs, which is a common gap.
  • gstack-greptile-early exit 3 on a hand-off: covered only by its error text, which is a common gap.
  • /document-generate can fill these later.

Diagram drift: none.

Agent notes

Agent notes

Open notes (GStack Minder's rulings: ship as disclosed notes, no third fix round; both fixes lead the follow-up batch).

  1. A fork pr-create through gstack-post on Capy names the bare local branch as head= (lib/gstack-post.ts:845), while gh pr create would have pushed to the fork and sent owner:branch, so the hand-off can name an upstream branch that doesn't exist or is the wrong one. Raised as blocking by the second-model reader at c6fc158. Fix: resolve the head's owner and send owner:branch (or refuse without --head owner:branch) when the head repo differs from repo=.
  2. With GH_REPO set to another repository, gh repo view (no argument) still answers the checkout's repository while gh pr view/gh pr edit follow GH_REPO (checked against gh 2.103.3), so both hand-off paths can name a different repo= than the write they replace. Found by the second-family decision-trail read. Fix: pass GH_REPO (or --repo) to gh repo view in postBody and gstack-post, with a test that sets GH_REPO.
  3. The review tool misread a line of the native reader's scope notes as a HIGH finding (p1/adversarial-native#1, test/capy-host-publish.test.ts:0:scope-list-line); GStack Minder ruled it not a finding. Fix: the review-dispatch collector should not parse scope-list bullets as findings.

Ruled note: lib/gstack-post.ts:845:fork-head at c6fc158 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T11:00:03.322Z: fork pr-create via gstack-post names the bare local branch as head=; Capy crews open PRs with their own tool; owner-prefixed head fix leads the follow-up batch (approval a-f69330b78aa2)

Ruled note: test/capy-host-publish.test.ts:0:scope-list-line at c6fc158 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T11:25:02.296Z: parser misread of the native reader's scope notes ('- a HIGH finding still refused;'), not a finding; the collector bug goes to review-dispatch's owner (approval a-4e6d4d77dff4)

Plan: exempt: bug fix (R65)

Lessons.

  1. A hand-off that replaces a gh write has to carry everything gh would have inferred from the checkout: repository, host, comment id, base, head and draft state. The receiving tool has no checkout and falls back to its own default.
  2. Its test has to assert where the write goes, not only that gh wrote nothing. On Capy, /ship no longer edits or comments on pull requests as you (GST-3183) #4517's zero-write test passed while every receipt hand-off was missing its repository.

Tests. test/capy-host-publish.test.ts puts a recording gh shim on PATH and parses each HOST_PUBLISH: line into its destination fields, asserting the whole destination object for receipt stub (with and without --repo), stop, claim, carry (on a GitHub Enterprise host) and all seven gstack-post write ops, plus: a two-repository fixture where the main repository differs from the PR's, a fork checkout where gh resolves the upstream repository and origin is the fork, a GitHub Enterprise host on stub and gstack-post, a new PR's inferred head, a refusal when the repository can't be resolved, a refusal in both commands when the repository can't be resolved, and a negative control showing the shim records gh pr comment when GSTACK_CAPY is unset. At #4517's head content (a3f4de0, carried here as e7c2ef1) 7 of 10 cases fail; at the fix all 10 pass.

Round-recording commands. gstack-ship-receipt stub, stop, claim and carry with --pr share one postBody, which hands off on Capy. claim can't read its marker back before the host publishes, so on Capy it trusts its own write; a double claim is still caught by the next history read.

Fork fix. /ship's second-model reader found that gstack-post took repo= from origin while gh's write follows gh repo set-default and GH_REPO; c6fc158 resolves it through gh repo view (its two new tests fail at d8fe752).

Carried from #4517. Commits 6e93604, e436151 and a3f4de0 are cherry-picked onto main f13dbb0 unchanged (9b96a63, 6b58851, e7c2ef1); 0fa1f3b adds the destination fix.

gh write inventory (/ship, review and ship-queue paths)

Fixed here (can run under GSTACK_CAPY=1):

  • bin/gstack-ship-receipt postBody (gh pr edit), used by stub, stop, claim and carry (which had its own gh pr edit)
  • lib/gstack-post.ts send paths (gh pr comment, gh issue comment, gh api --method=POST reply, gh pr edit title/body, gh pr create, gh issue create) and the gh api --method=PATCH fallback. Reached from /ship Step 5 (early draft PR), Step 6.5 (Greptile draft and trigger comment, lib/greptile-early.ts), Step 19 (body and title) and the stop comment.
  • ship/sections/pr-body.md.tmpl gh pr ready (prose): now names the host's PR tool on Capy.

Left as is, with reason:

  • crew/lib/ship-queue-wave.ts:411 (pr comment) and :579 (pr close), crew/lib/ship-queue-train-land.ts:226 (pr edit --add-label), lib/ship-queue-land.ts:309 (pr create for a drift repair): all run inside gstack-ship-queue land / wave and train landing, the merge action kept out of scope (and gstack itself is merge: direct, so the wave and train paths don't run here). Worth a follow-up if a Capy Captain lands a wave or train repo.
  • lib/squash-message.ts:90, crew/lib/ship-queue-train-land.ts:147 (pr merge): the land merge, out of scope.
  • crew/lib/ship-queue-dispatch-ci.ts:61, crew/lib/ship-queue-train-gate.ts:267/565, crew/lib/ship-queue-train.ts:485, crew/lib/release-gate.ts:177 (gh workflow run): CI dispatches that post no text, and Capy has no tool for them.
  • lib/release-stamp.ts:169 (pr create for the release PR): release path, not /ship.
  • scripts/resolvers/preamble/generate-test-failure-triage.ts:96 (gh issue create, prose): only on the interactive "assign a GitHub issue" answer in a collaborative repo; Capy has no GitHub issue tool, and editing the shared preamble regenerates every skill.

Known unrelated failure. #4517's free-suite (10) at 6e93604 (job 135468206031) was test/first-use.test.ts:152: lib/first-use.ts:116 lists user drive folders in readdirSync order, which is filesystem-dependent, and the test expects alphabetical order. It passes locally and isn't touched here.

Size ledger: test/size-ledger/ship/capy-ship-writes-through-host-pr-tool.json (+276 bytes, the prose lines).

{
  "schema_version": 1,
  "pr": 4518,
  "head": "c6fc1587487636b3093b19ded9b263736deb254a",
  "version": "1.101.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1705,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 44512086681,
      "attempt": 1,
      "tree": "5733be6b184a1f8387580c089b4c0413beeb304b"
    }
  ],
  "session_kind": "unattended",
  "run": "ship-4518-r3",
  "head_tree": "5733be6b184a1f8387580c089b4c0413beeb304b",
  "product_patch_id": "2b599590d3987da1fe6cc33488e5e6b9f4e15c94",
  "gstack_version": "1.101.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 126,
    "rules": "1afa38a4be3b5eef",
    "base": "55aaa6c4a5dff86e02d9bf9bfc7557c491f98a37",
    "registry": "55aaa6c4a5dff86e02d9bf9bfc7557c491f98a37",
    "gate_scan": {
      "tagged": 0,
      "head": "c6fc1587487636b3093b19ded9b263736deb254a"
    },
    "reasons": [
      "gate-class",
      "risk:security",
      "runtime=126"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @5733be6b184a (8 checks, current for c6fc15874876)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44512086681/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44507129702/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=5733be6b184a tests=37928 skipped=104 runs=44512086681/1 profiles=ci-reuse/free-tests heads=c6fc15874876 verified=2026-11-19T11:22:09.798Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ and README.md, read-only, base f13dbb0..c6fc158"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 7,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  },
  "ruled_notes": [
    {
      "finding": "lib/gstack-post.ts:845:fork-head",
      "head": "c6fc1587487636b3093b19ded9b263736deb254a",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "fork pr-create via gstack-post names the bare local branch as head=; Capy crews open PRs with their own tool; owner-prefixed head fix leads the follow-up batch",
      "at": "2026-11-19T11:00:03.322Z",
      "approval": "a-f69330b78aa2"
    },
    {
      "finding": "test/capy-host-publish.test.ts:0:scope-list-line",
      "head": "c6fc1587487636b3093b19ded9b263736deb254a",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "parser misread of the native reader's scope notes ('- a HIGH finding still refused;'), not a finding; the collector bug goes to review-dispatch's owner",
      "at": "2026-11-19T11:25:02.296Z",
      "approval": "a-4e6d4d77dff4"
    }
  ],
  "gate_dispositions": []
}
{"head":"d8fe752ac9eff3dec1a91145a715a5bde58255fc","run":"ship-4518","status":"started","review_loop":{"passes":1,"blocking_found":0,"deferred":0,"noted":1,"fixed":3,"scope":"frozen","rounds":1,"dispatches":{"specialist":3}}}
{"head":"c6fc1587487636b3093b19ded9b263736deb254a","run":"ship-4518-r3","mark":"stop","tree":"5733be6b184a1f8387580c089b4c0413beeb304b"}

Open in Capy

garrytan and others added 4 commits November 19, 2026 10:04
…ST-3183)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…se branch and draft state

Review-Finding: p1/specialist-batched#1 reader=specialist-batched
Review-Finding: p1/specialist-batched#3 reader=specialist-batched
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…never lands in another's file

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…s to, so one repo's PR body never lands on another's

gstack-ship-receipt stub, stop, claim and carry now read the repository with gh repo view when --repo is not
passed and put repo= (and host= off github.com) on every HOST_PUBLISH line; when it cannot be resolved they
refuse and hand nothing off. gstack-post adds host= and the current branch as a new PR's head. handOff refuses a
hand-off without a repository.

GST-3183

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

trunk-io Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 2 commits November 19, 2026 10:27
…eading as a refused secret

gstack-post now exits 3 with a message, and gstack-ship-receipt reports the write as failed, when the private hand-off file for the host's PR tool cannot be written. Before, the error escaped as exit 1, which callers read as a HIGH finding refused. Adds tests for that path, for pr-create on a detached HEAD, and for gstack-greptile-early open when gstack-post hands the draft off.

Review-Finding: p1/red-team#6 reader=red-team
Review-Finding: p1/specialist-batched#1 reader=testing
Review-Finding: p1/specialist-batched#2 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…o a fork checkout's hand-off reaches the upstream PR

On GitHub the hand-off's repo= and host= now come from gh repo view --json nameWithOwner,url, which follows
gh repo set-default and GH_REPO like the gh write it replaces, instead of the origin remote. When gh cannot
resolve the repository gstack-post refuses with exit 3 and hands nothing off.

GST-3183

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit e95cea8 into main Nov 19, 2026
82 of 84 checks passed
capy-ai Bot added a commit that referenced this pull request Nov 19, 2026
… reading reviewers' scope lists as findings (GST-3201) (#4527)

Pre-commit /verify now fails a check that times out and runs its checks
on one time budget; a reviewer's scope-list bullets no longer need an
owner ruling to clear; stack tests fail when git can't list a PR's
tests.

Why: each let a result read clean with nothing proving it, or block on
nothing (#4518, #4519). Goal: gates never pass on missing evidence.

Nothing to do; `gstack-checks quick --timeout` is now one budget the
checks share (540 s default).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p1/outside-voice#2 reader=outside-voice
@garrytan garrytan mentioned this pull request Nov 19, 2026
capy-ai Bot added a commit that referenced this pull request Nov 19, 2026
- `gstack-artifact validate` no longer passes a run.json that gstack-autoplan never wrote. (#4494)
- /ship's changed-number check no longer stops on tests that only share a word with the change (#4478). (#4496)
- On Capy, /ship no longer edits or comments on pull requests as you. (#4518)
- The destructive-command check stops asking about scratch deletes and catches the real damage it used to miss. (#4513)
- The destructive-command check reads commands more carefully, closing gaps found after the last release. (#4525)
- The Codex readiness check and the second-model review now pick the same model for a custom Codex provider (GST-3089). (#4491)
- gstack's Codex hooks work when your Codex folder's path has a `(`, `&` or other shell character in it. (#4528)
- Uninstalling gstack keeps your own Codex hooks trusted. (#4528)
- Codex hook setup matches Codex more closely. (#4528)
- On Windows, setup copies the Claude Code hook code that gstack's Codex hooks import (#4528)
- /review's checklist on Codex reads shell commands more carefully. (#4528)
- On Codex, gstack now suggests the right skill for a prompt and stops destructive commands before they run. (#4512)
- On Codex, /review is now held once when it tries to finish without its adversarial pass or its report, as it already is on Claude Code. (#4522)
- On Codex, gstack's skill suggestion now names the skill the way Codex lists it. (#4523)
- On Codex, gstack's suggested prompts and docs now name skills the way Codex lists them. (#4524)
- /review on Codex with gpt-6.1-sol is no longer held back for a second-model pass it already ran. (#4526)
- On Codex, office-hours, plan-design-review and gstack-upgrade work again when you name them. (#4510)
- gstack knows when Codex is running unattended. (#4510)
- Codex reviewers start with a clean context. (#4510)
- Docs no longer say Codex has no hook support. (#4510)
- A command whose output was cut off no longer counts as a finished read. (#4492)
- A folder marked as published data can no longer hide source code or agent files from /ship's review. (#4516)
- Correction to the on-by-default helper hooks entry: the hook still routes only to /review, /qa and /verify, so skills you've installed yourself aren't suggested yet. With gstack's skills it routes 14 of 60 real bug reports (was 17), and long prompts are no longer skipped. (#4505)
- /sync-gbrain's read check now works when the first page in your code source is over 64 KB. (#4497)
- Free-suite CI no longer fails before any test runs when Ubuntu's package mirror is slow. (#4530)
- Syncing a second repo no longer makes the first one ask for /sync-gbrain again. (#4532)
- gstack's helper hooks are now on by default in Claude Code, OpenClaw and Hermes, and the prompt-routing hook fires on real bug reports. (#4503)
- `gstack-pregate clear --receipt` accepts a remote gate run from before a merged release when the release only regenerated a declared release output. (#4483)
- The second-model review now keeps the reviewer's own result, and reports a used-up budget as a budget stop. (#4515)
- When the reviewer wrote its review to the result file it was asked for, Codex then replaced that file with its short closing message ("Done, I wrote the review"), so the review was thrown away and reported as missing its markers. (#4515)
- When the provider refuses the call with HTTP 402 Payment Required (usually a metering proxy that hit its allowance, or an account out of credits or quota), gstack used to record only "exit 1". (#4515)
- The pre-commit /verify check now fails a check that times out, and its checks share one time budget (GST-3201). (#4527)
- /ship's review collector no longer reads a reviewer's own scope list or list of passed checks as findings (GST-3201). (#4527)
- Merge-queue stack tests fail when git cannot list a PR's added test files (GST-3201). (#4527)
- /ship can now review results PRs that publish raw session data. (#4511)
- /ship's review pass works when the checkout you ship isn't the project's default checkout. (#4507)
- A second review round no longer reports done when nothing was reviewed. (#4520)
- The prompt-routing hook now suggests skills you install yourself, and no longer sends ordinary bug reports to /qa (GST-3123). (#4506)
- gstack's script runner and merge-queue checks now also refuse cut-off output. (#4502)
- A failed second-model review reports the cause that actually stopped it, and the runner never deletes its own prompt. (#4519)
- `gstack-ship-queue ready` now fills in the trial merges and the second-model trail read instead of printing lines to fill. (#4529)
- Five small ship-tool fixes. (#4529)
- A ruling the owner gives while a `/ship` run is open can be relayed. (#4529)
- /ship no longer kills a working test run as stalled when the test command starts its workers in their own session. (#4533)
- /ship no longer stops a review because the state-machine reader started its reply the way its instructions say. (#4504)
- When Claude Code runs /verify right before a commit, it now gets a quick check instead of the full fix loop (GST-3150). (#4508)

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