Skip to content

ship-receipt write: the targeted record survives a main merge (GST-1593) - #4058

Merged
capy-ai[bot] merged 7 commits into
mainfrom
gst-1593-targeted-merge
Nov 6, 2026
Merged

capy-ai[bot] merged 7 commits into
mainfrom
gst-1593-targeted-merge

Conversation

@garrytan

@garrytan garrytan commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 4058,
  "head": "e71ea9704dd9328b68005d71dff4338c405f5fa3",
  "version": "1.96.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 35870,
      "fail": 0,
      "skip": 19
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42186516696,
      "attempt": 1,
      "tree": "29a4b1db2d8597527db229893402fbed84545e4c"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "29a4b1db2d8597527db229893402fbed84545e4c",
  "product_patch_id": "acbe3bbedc77b49a4098eb2c04a3705fe284f5f1",
  "gstack_version": "1.96.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 104,
    "rules": "70895942bb8a8ee2",
    "base": "4b1a1152844abf3e0562fb72767856dcdd5ba331",
    "registry": "4b1a1152844abf3e0562fb72767856dcdd5ba331",
    "gate_scan": {
      "tagged": 1,
      "head": "e71ea9704dd9328b68005d71dff4338c405f5fa3"
    },
    "reasons": [
      "gate-class",
      "runtime=104"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "warn @29a4b1db2d85 (7 checks, current for e71ea9704dd9)",
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md and changelog.d/ (read-only audit ship4058-docs-1, base 4b1a115 to e71ea97)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 4,
    "deferred": 0,
    "noted": 3,
    "fixed": 5,
    "scope": "frozen",
    "fix_checks": 2,
    "rounds": 4,
    "ledgers_read": 6,
    "unbound": 1,
    "dispatches": {
      "specialist": 6,
      "red-team": 2
    }
  },
  "review_loop_exception": {
    "accepted_by": "GStack Minder",
    "date": "2026-11-06",
    "via": "Captain ruling relayed to lane GSTA-334, approval a-934d8c892682",
    "reason": "A1 granted: one more scoped fix-check on #4058 covering the first-parent skip-CI regression plus the mode-only-change check; the last one for this PR",
    "fix_check": {
      "head": "e6e99ddc16608781d3b801dde81122db5dbe6130",
      "findings": 1
    }
  },
  "review_targeted": {
    "classes": [
      "gate"
    ],
    "rules": "30e6bce187be0d59",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "acbe3bbedc77b49a4098eb2c04a3705fe284f5f1",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}

What changed

gstack-ship-receipt write --review-targeted computes "what changed since the targeted read" over the PR's own change instead of the merge-inclusive <read>..HEAD range. A main merge after the read that leaves the PR's diff alone no longer voids the record, whatever money- or secret-tagged files it brought in.

Why

HARN-1 on harness-evals #293 (also #292 and #225): write refused with "the targeted reader read … the product changed after the read" though the product patch id was unchanged (f903d10bd327 before and after). targetedClassesSince(<read>..HEAD) diffed across the merge commit, so main's budget-ledger, lane-spend and results files counted as changes since the read.

How

  • ownChangeSince (lib/ship-receipt-depth.ts) finds the paths whose part of the PR's diff against its merge base with origin/<base> differs between the read and HEAD (product_patch_id's basis, with tests and metadata kept), and builds a commit on the read with only those paths at HEAD's content. A path whose base content main left alone moves on any change. A path main also changed moves unless replaying main's change onto the read's content (git merge-file) gives HEAD's bytes and mode exactly. With no resolvable merge base every path in <read>..HEAD moves, the old behavior.
  • The built commit carries the message of every commit since the read that origin/<base> does not hold, side-branch merges included, so a CI-skip marker after the read stays gate class (RH-14).
  • targetedClassesSince classifies <read>..<that commit> and runs the gate scan with gstack-gate-diff --commit over it. plainDocsSince (GST-1195's docs carry) had the same merge-inclusive range and uses the same basis.
  • Write passes its base to both (one line in bin/gstack-ship-receipt).

Blast radius

Only write's targeted-record binding moves. The patch-id check in parseReviewTargeted is unchanged, so any product change still refuses on its own; the classes check stays the extra guard for tests and metadata. A branch-side money, secret, auth or gate change after the read, a hunk moved to an identical context, a mode-only change, a CI-skip commit message, or a merge resolution that changes the PR's own hunks still moves its path and refuses (tests below). Every new failure path fails closed: git errors, conflicts and missing blobs move the path.

Tests

New cases in test/review-targeted-record.test.ts, each failing first against the code before its fix:

  • the feat: Prism skill — foundation fix with research gate, decision boundary, operator boundary #293 shape: read, main merge bringing lib/budget-ledger.ts and lib/secrets.ts: write binds, classes since the read are none (main gave money,secret);
  • after a main merge, a branch money edit and a branch skipped test: refused (money, gate);
  • after a main merge, a plain docs commit: binds (main refused);
  • a merge whose resolution edits the PR's own src/charge.ts: refused, classes money only;
  • no main merge, the money line moved to an identical-context block after the read: refused (money);
  • a main merge that changed the PR's own file binds, and moving the money line after it is refused;
  • a branch commit after the read whose message skips CI: refused (gate), and the same commit on a side branch merged with --no-ff: refused;
  • after a main merge to the PR's own file, a mode-only change: refused (money).

The GST-1593 cases call targetedClassesSince in-process under the fixture's env, so the gate scan they spawn writes nothing under the real ~/.gstack (CI run 42179129702's FREE_SUBSHARD_REJECTED).

Siblings checked

  • targetedClassesSince has one caller (write); plainDocsSince fixed here.
  • Not the same bug, left alone: the docs-audit check in writeExcludeBinds (<snapshot>..HEAD within one /ship run), ship-release's fix-check and review-loop-exception routing (already compares the PR's own sides, comparePath / own-paths intersection), and the queue's acceptedReceiptHeads (classifies merge parents against the base).

Approvals

Approved: yes (record r-85abf98a6119). The full approval record stays private: this repository is public or its visibility is unknown.

Review-loop exception: accepted by GStack Minder 2026-11-06 via Captain ruling relayed to lane GSTA-334, approval a-934d8c892682: A1 granted: one more scoped fix-check on #4058 covering the first-parent skip-CI regression plus the mode-only-change check; the last one for this PR (fix-check at e6e99dd, 1 finding)

Pre-Landing Review

REVIEW_LOOP: passes=2 blocking_found=4 deferred=0 noted=3 fixed=5 scope=frozen unbound=1 ledgers_read=6 fix_checks=2 dispatches=8

Gate class, full panel. Pass 1 (8ac95c0): red-team CRITICAL (identical-context relocation with no main merge), fixed in 2f769b4. Pass 2 (range 8ac95c0..2f769b4): one test-gap note. Step 11 (2f769b4): outside voice (openai/gpt-6.1-sol) two CRITICAL and adversarial one Medium, fixed in c462483. Fix-check 1 (3d009c1): one CRITICAL (side-branch CI-skip messages) and one INFORMATIONAL (mode-only change), both fixed in e6e99dd under the exception above. Fix-check 2 and targeted reader (e6e99dd): one fail-closed note, no findings. Step 11 rebind at e6e99dd (tree 08b2d50c): adversarial five findings, all Blocks: no; outside voice and targeted reader clean.

Gate edits: 3 listed, 2 read, 0 findings. The RH-14 hit is commit c462483, whose message quoted a CI-skip marker in prose; CI then ran at 3d009c1 on the identical tree, so it silences nothing.

Review notes

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

  • INFORMATIONAL lib/ship-receipt-depth.ts:540 The message source <read>..<head> ^origin/<base> also picks up messages of base commits the local origin/<base> ref does not cover; a CI-skip marker there refuses (fails closed).
  • Medium lib/ship-receipt-depth.ts ~577: skill directories for plainDocsSince come from the built tree, so a branch edit to prose under a skill directory main added after the read can ride the docs-only carry; the claim-word filter and the queue's verdict at head still apply. Follow-up.
  • Low: a moved path that is a directory at head is written as a tree entry into the built index (mangled main content, no bypass); renames and adjacent main edits refuse; temp files can outlive a killed process; local origin/<base> trust is unchanged.

Exploratory QA

Functional, smoke budget 300 s, report-only. Captures 001-002 at 8ac95c0 reproduced the real-home leak and the red-team relocation bypass; 003-004 at 2f769b4 passed (relocation reports money; the focused file passes with the home fixture count unchanged). Verdict: pass. checkpoint 002 checkpoint 003 checkpoint 004

Documentation

Status: current. No documentation edits needed.

Scope: base 4b1a115 to head e71ea97 on gst-1593-targeted-merge (6 committed files; no staged, unstaged or untracked content), plus 168 discovered docs. Changed: lib/ship-receipt-depth.ts (targeted classes and plain-docs carry computed over the PR's own change against its merge base), bin/gstack-ship-receipt (passes the base), a test file, a changelog fragment, and two docs.

Documentation health:

  • docs/review-policy.md: current (targeted-record paragraph already describes the PR's-own-change basis, GST-1593)
  • docs/troubleshooting.md: current (RECEIPT_INVALID entry already says a base merge that leaves the PR's diff alone never voids the record)
  • changelog.d/capy-gst-1593-targeted-main-merge.md: present and accurate
  • ship/sections/handoff.md.tmpl, ship/sections/adversarial.md.tmpl: current (command usage unchanged; no new flags)
  • README.md, docs/skills.md and other docs: no affected contract

Coverage debt: no new public commands, flags or env vars; the changed functions are internal. No gaps. Diagram drift: none (no diagrams reference these functions).

Debt note: one very long run-on sentence in docs/review-policy.md (~line 489) could be reflowed; cosmetic, not changed in read-only mode.

Test plan

  • bun test --timeout=30000 test/review-targeted-record.test.ts at e6e99dd: 20 pass, 0 fail; every new case failed first against the code before its fix
  • bun run typecheck: exit 0; test/module-size-ratchet.test.ts: 6 pass; conflict markers: none
  • CI free suite carried from the workflow_dispatch run at the final head (see the receipt)

Open in Capy

garrytan and others added 2 commits November 6, 2026 07:08
…s since the read cover the PR's own change (GST-1593)

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

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

trunk-io Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 5 commits November 6, 2026 07:26
…lways voids the targeted record; isolate the GST-1593 tests' gate scan from the real home (GST-1593)

ownChangeSince compared the PR's per-path hunks with line numbers stripped even when main had not moved the
path's base content, so a branch commit after the targeted read that relocated the PR's money line to an
identical-context block read as unchanged and the record bound (red-team, /ship #4058 pass 1). Hunk
comparison now applies only when the base blob moved. The four direct targetedClassesSince calls in the
GST-1593 tests now run with the fixture's env, so gstack-gate-diff no longer writes under the real
~/.gstack (CI run 42179129702, free-suite (4): FREE_SUBSHARD_REJECTED real home changed).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
ownChangeSince: a path whose base content main also changed now moves unless replaying main's change onto
the read's content (git merge-file) gives HEAD's content exactly, so relocating the PR's money hunk to an
identical context after a main merge voids the targeted record; position-free hunk comparison is gone. The
built commit carries the branch's first-parent messages since the read, so a [skip ci] commit stays RH-14
gate class. Two red-first tests cover both.

Review-Finding: v1/outside-voice#1 reader=outside-voice
Review-Finding: v1/adversarial-native#1 reader=adversarial-native
Review-Finding: v1/outside-voice#2 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The previous commit's message quoted a CI skip marker, so no workflow ran at c462483. This commit changes
no file; the tree is c462483's.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The built commit now carries the message of every commit since the read that origin/main does not hold,
so a CI-skip marker on a side-branch commit merged with --no-ff still tags RH-14. A path whose mode at
HEAD is not the replayed mode now moves, so a mode-only change after a main merge to the PR's own file
voids the record. Two red-first tests cover both.

Review-Finding: fc1/fix-check#1 reader=fix-check
Review-Finding: fc1/fix-check#2 reader=fix-check
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…lint)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit f7015fa into main Nov 6, 2026
67 checks passed
garrytan added a commit that referenced this pull request Nov 6, 2026
…#4058)

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 6, 2026
…y reader (GST-1598) (#4062)

* test: failing-first repro for GST-1598 (post-review docs money delta has no targeted-only reader)

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

* review-plan: a docs claim added after the loop plans one targeted-only reader (GST-1598)

After a finished review loop, a docs change with a money, security or numeric
claim left the receipt unable to carry the targeted record and the plan at
done, so nothing could dispatch the reader the receipt asks for (harness-evals
#225). With --range-base naming the commit the targeted reader read and
--targeted-ran its patch, a docs-only change since then now plans NEXT:
targeted: one targeted reader on HEAD for the head classes, with
TARGETED_DELTA printed. Code changes keep done; --force targeted refuses and
names the route; gstack-review-dispatch pass builds the one-reader manifest.

Repins lib/review-depth.ts under replay GST-1598 (one Step union member;
the GST-967 and GST-972 grids hash unchanged).

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

* review-targeted-delta: pass the base to plainDocsSince (GST-1598 after #4058)

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

* fix: pre-landing review fixes

targetedDelta counts a path whose branch hunks are unchanged and only the base moved lines beside them (comparePath context) as unchanged, so a main merge next to a reviewed hunk no longer hides the targeted-only read (GST-1598).

Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p1/adversarial-native#2 reader=adversarial-native
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* changelog: GST-1598 targeted-only read fragment

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