Skip to content

fix(ship-receipt): name the non-ancestor targeted-read commit in RECEIPT_INVALID (GST-1700) - #4106

Merged
capy-ai[bot] merged 1 commit into
mainfrom
capy/name-the-non-ancestor
Nov 7, 2026
Merged

capy-ai[bot] merged 1 commit into
mainfrom
capy/name-the-non-ancestor

Conversation

@garrytan

@garrytan garrytan commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

When the commit the targeted reader read is not an ancestor of HEAD, gstack-ship-receipt write --review-targeted refused the record with "the product changed after the read", even while printing two equal product patch ids (qm#2952: whose product patch 58b965dd1ece is not this receipt's 58b965dd1ece). The lane went looking for a product change that wasn't there.

What changed. parseReviewTargeted takes an optional ancestor callback that only picks the wording; write passes git merge-base --is-ancestor <read> <head>. When the existing refusal fires and the read commit is not HEAD's ancestor, RECEIPT_INVALID now says:

the targeted reader read <sha12>, which is not an ancestor of HEAD (usually after a rebase or a redone merge resolution, which rewrites the commit the reader read): a targeted record carries only from HEAD or an ancestor of it, even when the product patch is unchanged, so run the targeted reader on HEAD, rerun gstack-review-dispatch verify --targeted-out and write again

The "even when the product patch is unchanged" clause appears only when the patches really are equal. Every other refusal keeps the old text.

What passes and fails is unchanged. The refusal condition is untouched. A non-ancestor read already failed because targetedClassesSince and docsChangeSince return null for a non-ancestor from (by design since GST-986, and gstack-review-plan's targeted-delta skips the same case), so a fresh targeted read on HEAD is required. The read does not carry even with an unchanged patch.

Test. test/review-targeted-record.test.ts adds a failing-first case: read on a main merge, redo that merge (same tree, new commit), then write. Before the fix it printed the "product changed" text with equal patch ids. Now it pins the new message and the RECEIPT_INVALID code.

Changelog: changelog.d/capy-gst-1700-non-ancestor-targeted-read.md.

Open in Capy

{
  "schema_version": 1,
  "pr": 4106,
  "head": "b01d420b3f6a5d9bb2a6537876a524d26d1ae22b",
  "version": "1.97.0.0",
  "base": "main",
  "gate": {
    "tests": {
      "pass": 1622,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "tests",
      "run": 42328238636,
      "attempt": 1,
      "tree": "6018aaa70f0b9f800eb8560d660480174f1df7d3"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "6018aaa70f0b9f800eb8560d660480174f1df7d3",
  "product_patch_id": "450c1708a7d56d6079e9e804abba7daec3fd9449",
  "gstack_version": "1.97.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 8,
    "rules": "70895942bb8a8ee2",
    "base": "487506bd38f73cfc33454b8bcb1ad25b74994220",
    "registry": "487506bd38f73cfc33454b8bcb1ad25b74994220",
    "gate_scan": {
      "tagged": 0,
      "head": "b01d420b3f6a5d9bb2a6537876a524d26d1ae22b"
    },
    "reasons": [
      "gate-class",
      "runtime=8"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "pass @6018aaa70f0b (8 checks, current for b01d420b3f6a)",
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, AGENTS.md, CLAUDE.md, CONTRIBUTING.md (docs/troubleshooting.md and docs/review-policy.md read for the changed contract)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 0,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 2,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  }
}

What changed

RECEIPT_INVALID for a targeted read on a redone merge: before it blamed a product change while printing two equal patch ids; now it names the non-ancestor commit and the recovery

RECEIPT_INVALID for a targeted read on a redone merge: before, it blamed a product change while printing two equal patch ids. Now it names the non-ancestor commit and the recovery.

Before/after as text: RECEIPT_INVALID for a targeted read on a redone merge: before it blamed a product change while printing two equal patch ids; now it names the non-ancestor commit and the recovery
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+gstack-ship-receipt write: RECEIPT_INVALID the targeted reader read 3f9c2a71b0d4, which is not an ancestor of HEAD (usually after a rebase or a redone merge resolution, which rewrites the commit the reader read): a targeted record carries only from HEAD or an ancestor of it, even when the product patch is unchanged, so run the targeted reader on HEAD, rerun gstack-review-dispatch verify --targeted-out and write again
-gstack-ship-receipt write: RECEIPT_INVALID the targeted reader read 3f9c2a71b0d4, whose product patch 8be1d07c5a92 is not this receipt's 8be1d07c5a92: the product changed after the read (only release stamps and a docs change with no numeric, results, prereg, eval, money or security claim carry the record), so run the targeted reader on HEAD and verify again
 

Why

Lanes reported that "the receipt says the product changed after the read but prints the same patch id twice" (qm#2952). They then went looking for a product change that wasn't there. The real cause was a targeted read on a commit that a rebase or a redone merge resolution had rewritten. The refusal now says that directly. It also tells the lane to run the targeted reader on HEAD, rerun verify, and write again.

Blast radius

Only the wording of one RECEIPT_INVALID refusal in gstack-ship-receipt write changes. The new ancestor callback runs only after the existing refusal condition is already true, so no receipt that passed before fails now, and none that failed now passes (verified by reading lib/ship-receipt-depth.ts:252, and by running test/review-targeted-record.test.ts, 21 pass, 0 fail). parseReviewTargeted has one caller, bin/gstack-ship-receipt:300, and v.head is checked against hex 40-64 before it reaches git merge-base.

Approvals

No approvals recorded for branch capy/name-the-non-ancestor.

Summary

gstack-ship-receipt write used to refuse a targeted record read on a rewritten commit by saying the product changed after the read, even when both patch ids were equal. It now names the read commit, says it is not an ancestor of HEAD, and says the record carries only from HEAD or an ancestor. Which receipts pass and which fail is unchanged. A regression test redoes a main merge, giving the same tree on a new commit, and asserts the new wording.

Test Coverage

Both changed runtime files have a changed test naming them (deterministic coverage map, no audit reader). New test: a read on a redone merge resolution names the non-ancestor commit and the recovery in test/review-targeted-record.test.ts.
Tests ran: tests 1622 (files, carried from CI run 42328238636/1 at tree 6018aaa70f0b)

Pre-Landing Review

Review plan: gate class, full depth (bin/gstack-ship-receipt is a gate path). Readers: a batched specialist (testing, security and state-machines checklists), red team, native adversarial, and an outside voice (openai/gpt-6.1-sol, completed, no findings). There were no blocking findings and no fix round. The two specialist test-gap items were skipped as nits below the blocking floor. The four native adversarial items are Low, marked Blocks: no, and scoped as notes.
REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=0 fixed=0 scope=frozen ledgers_read=2 dispatches=4
Gate edits: none detected (1 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: completed (openai/gpt-6.1-sol via host subagent): no actionable findings.

Review notes

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

  • INFORMATIONAL bin/gstack-ship-receipt:300 null/128 merge-base status read as non-ancestor; wording only (Low, Blocks: no)
  • INFORMATIONAL bin/gstack-ship-receipt:300 absent read commit (exit 128) worded as rewritten; recovery unchanged (Low, Blocks: no)
  • INFORMATIONAL lib/ship-receipt-depth.ts:252 equal-ids product-changed message still prints for ancestor reads refused by classesSince; pre-existing (Low)
  • INFORMATIONAL lib/ship-receipt-depth.ts:238 ancestor without classesSince could word a passing case as refused; no such caller (Low)
  • INFORMATIONAL bin/gstack-ship-receipt:300 (testing, skipped): any nonzero merge-base --is-ancestor status takes the non-ancestor wording. For an absent commit (exit 128) the statement is still true and the recovery is the same.
  • INFORMATIONAL test/review-targeted-record.test.ts:383 (testing, skipped): no end-to-end test covers a non-ancestor read with a different product patch (no suffix). QA probe 003 exercised that branch directly.

Exploratory QA

Functional (CLI/library), smoke budget 300 s:

  • 001: bun test test/review-targeted-record.test.ts: 21 pass, 0 fail (exit 0).
  • 002: the wording probe with an invalid status input was rejected by the existing validator. That was a probe error, superseded by 003.
  • 003: parseReviewTargeted with an absent read commit, with an equal-patch non-ancestor read, and with an ancestor read. The first two refuse with the non-ancestor wording (suffix only when the patches are equal), and the ancestor read passes.
  • git merge-base --is-ancestor <absent sha> HEAD exits 128.

Design Review

No frontend files changed, so design review was skipped.

Eval Results

No prompt-related files changed, so evals were skipped.

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). This is a bug fix (--kind fix) with a failing-first regression test.

TODOS

No TODO items completed in this PR.

Documentation

Status: current. The docs already match this change, so nothing was edited.

Scope: base e4b1e34 to head b01d420 (one commit, GST-1700), with no staged, unstaged or untracked changes. It touches bin/gstack-ship-receipt, lib/ship-receipt-depth.ts, test/review-targeted-record.test.ts and a new changelog fragment. The change only rewords one RECEIPT_INVALID message: when the targeted reader read a commit that is not an ancestor of HEAD, the message now says so. What passes and fails is unchanged.

Documentation health:

  • docs/troubleshooting.md: current. The RECEIPT_INVALID entry already covers the non-ancestor refusal and its recovery.
  • docs/review-policy.md: current. The review_targeted row already names the non-ancestor refusal.
  • changelog.d/capy-gst-1700-non-ancestor-targeted-read.md: new fragment, not edited.

Coverage debt: none. The change adds no new public surface.

Diagram drift: none.

Test plan

  • bun run test: carried from CI run 42328238636/1 at tree 6018aaa70f0b (1622 files, 0 failed)
  • bun --no-env-file test --timeout=30000 test/review-targeted-record.test.ts: 21 pass, 0 fail
  • gstack-pregate --allow-repo-commands: pass on the stamped tree (guards typecheck, module-size, conflict-markers)

🤖 Generated with Claude Code

…IPT_INVALID (GST-1700)

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

trunk-io Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai
capy-ai Bot merged commit 1970da5 into main Nov 7, 2026
64 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