Repository navigation
Commit 753aae6
fix(pm): check-governed-merges hands the guard's readers a git that carries stdin (#37071)
<!-- claude-projects-attribution: {"github_login":"huangyiirene"} -->
_Requested by **Irene** · [project
thread](https://claude.ai/code/project/chan_01TJXtQ1tVD26ecLDZxFS67x?thread=cmsg_01TJXtQ1tVD26ecLDZxFS67x8Be2AAcUBhodBsvnWLd3Xs)_
Fixes #37038
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:用户无感;车队席位落地前的预读和合并后的受管审计,现在能正确指出"重生成链里夹带的手改文件",之前一律读成"已解释"。
- 为什么做:修车队受管合并审计工具里一个读数错误(席位预读与事后审计会漏报夹带手改的重生成 PR)。
- 出错会怎样:只影响席位预读和事后审计这两份报告,合并队列自己的守卫不受影响;有问题可直接撤回此 PR。
- 要你做什么:这是守卫工具本身,属人合档,请你审阅后合并。
## What changes
`scripts/pm/check-governed-merges.mjs` only.
- `git(root, args, input)`: takes an optional `input`. With one, git
gets it on a piped stdin; without one, stdin stays `'ignore'` exactly as
before, so every existing plain caller (`tryGit`, the enumeration reads)
is unchanged. The options live in `gitSpawnOptions(root, input)` so the
self-test can pin them.
- `checkoutGitReader(root)` returns `(argv, input) => git(root, argv,
input)`, the queue guard's own `runGit` shape. Both handoffs now use it:
- `--pr` into `pullRecordStage`: was `sameCheckout ? (argv) => git(root,
argv) : null`.
- the post-merge sweep into `readArmLanding`: was `(argv) => git(root,
argv)`.
- `readArmLanding`'s two wrappers around that reader (`armGit`, and the
`git` wrapper in `armSettledWithoutUnread`) forward `input` too. Neither
carries a stdin read today, but both are git readers handed to
`guard.readLowRiskTier`, so a later stdin read there would hit the same
hole.
Every `(argv) => git(root, argv)` style handoff in this file, as grep
finds it at the base `938a48f1`:
| Line at base | Handed to | Reaches a stdin command? | Changed |
|---|---|---|---|
| `runGit:` in `--pr` | `pullRecordStage` → `readLowRiskRecordStage` →
`regenCarry` → `unexplainedPathsBetween` (`check-attr --stdin`) | yes |
yes |
| `runGit:` in the sweep's arm leg | `readArmLanding` → record pair →
`regenCarry` → `unexplainedPathsBetween` | yes | yes |
| `armGit` / `armSettledWithoutUnread` `git` | `guard.readLowRiskTier`
(show, ls-tree, diff-tree) | no, today | forwarded anyway |
| `git:` into `readWorkflowDiff` (`--branch` and `--pr`) | `ls-tree`,
`show` | no | no |
| `run:` (`tryGit`) into `deriveBranchPaths`, `pullWorkflowDiff`,
`pullChangesetReading`, `pullCatalogReading` | plain reads | no | no |
The only stdin command across `record-recognisers.mjs`,
`check-governed-queue-guard.mjs` and this file is
`unexplainedPathsBetween`'s `check-attr --stdin`. The guard and the
recognisers are not edited, and no regen-carry logic is restated here.
## Why
`unexplainedPathsBetween` passes the moved paths as `runGit`'s second
argument to `git check-attr --stdin`. The handoffs dropped that argument
and `git()` ignored stdin, so check-attr read nothing and every moved
path read as explained. That let `regenCarry` read a false carry in
`--pr`'s pre-landing reading and in the post-merge governed audit. The
queue guard passes input itself, so the merge gate was never affected.
## Tests
<details><summary>Self-test, final head 4d8079f: 972 assertions, exit 0
(base 938a48f: 963)</summary>
`bash scripts/pm/os-verify-lock.sh -c 'node
scripts/pm/check-governed-merges.mjs --self-test'` gives `VERDICT
command-exit 0`, `972 assertions`. That is 9 new cases:
- New battery `⭐ the git reader handed to the guard's readers carries
STDIN (check-attr --stdin)`, floor 6. The roster floor goes from 41 to
42. It runs offline, with real git, on a throwaway repo. The repo has
`.gitattributes` routing `gen/out.json` to `merge=os-regen`, and a
branch that moves `scripts/pm/x.mjs` and `gen/out.json` together, then
the generated path alone.
1. `check-attr --stdin` through `checkoutGitReader` answers
`unspecified` for the hand path and `os-regen` for the generated one.
2. Through the guard's own `unexplainedPathsBetween`, the moved
non-regen path reads **unexplained**. This is the card's case that fails
today.
3. Control: a hop that moves only the `os-regen` path reads explained.
4. A read with no input still answers (empty) on an ignored stdin.
5. `gitSpawnOptions` with no input gives `stdio[0] === 'ignore'` and no
`input` key.
6. `gitSpawnOptions` with input gives a piped stdin carrying it byte for
byte.
- The low-risk arm battery gets one seam pin for `--pr`.
`pullRecordStage` is handed `checkoutGitReader(fixture)`, and the reader
the guard's `readLowRiskRecordStage` receives reads the moved non-regen
path as unexplained.
- The post-merge arm battery gets two seam pins for `readArmLanding`.
First, every git reader it hands the guard (to `readLowRiskTier` and the
record pair given to `recordVerdict`) passes stdin through. Second, the
sweep's checkout reader reaches real git through the landing's wrapper
and reads the moved non-regen path as unexplained.
</details>
<details><summary>Red before, green after: three ablations on committed
head 4d8079f (blob aced044)</summary>
Each leg goes through `node scripts/ablation-replace.mjs`: the anchor
hits once, the mutation lands with its blob moving, and the restore is
verified as blob equal to HEAD with an empty `git diff HEAD`.
- **A**: `git()` drops input, which is origin/main's spawner. Exit 1
with 5 failures: battery cases 1, 2 and 6, the `--pr` pin, and the sweep
real-git pin. Case 2 reads `[]` in place of `scripts/pm/x.mjs`.
- **B**: the handoff drops its second argument, which is origin/main's
`(argv) => git(root, argv)`. Exit 1 with 4 failures: battery cases 1 and
2, the `--pr` pin, and the sweep real-git pin.
- **C**: `armGit` drops input. Exit 1 with 2 failures: the
forward-through pin (`{"state":"pass","arm":2,"pair":1}`) and the sweep
real-git pin.
- Restored: exit 0, 972 assertions.
</details>
<details><summary>The card's repro on PR #36509's real trees</summary>
`4342cf009..bf71994`, base `e4e3bcfe`, fetched into a scratch ref
that has since been deleted. Run through `unexplainedPathsBetween`:
- before, with origin/main's ignored stdin: **0** unexplained
- after, with `checkoutGitReader`: **14** unexplained
The 14 begin with `packages/spec/src/ui/component.zod.ts`,
`scripts/sdui-manifest.record.json` and `sdui.manifest.json`. This
matches the card's measured 14 and 0.
</details>
## Acceptance notes
- The two seam pins drive the reader the handoffs are built from
(`checkoutGitReader`) through the real `pullRecordStage` and
`readArmLanding`. They do not run `--pr` or the sweep end to end,
because both read GitHub. The two call sites themselves are one token
each. Ablation B shows that any reader with the old `(argv) => git(root,
argv)` shape reds the battery.
- `pnpm check:i18n-coverage` is derived for this path, but it reads
`packages/cli/dist` and the examples' build closure, which are not built
here. It exited 3 (PREREQUISITE NOT MET) locally, so it is NOT MEASURED;
CI runs it.
## Verification
Read first, by risk:
1. `git()` / `gitSpawnOptions`: the no-input branch must stay `'ignore'`
for every plain caller.
2. The two `runGit:` handoffs (`--pr`, sweep arm leg), now
`checkoutGitReader(root)`.
3. `armGit` and the `armSettledWithoutUnread` wrapper, which only
forward `input`.
Two-minute check: `node scripts/pm/check-governed-merges.mjs
--self-test` should print `✓ … 972 assertions`, ending in the stdin
clause.
<details><summary>Local gates, head 4d8079f</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 63 families. Run reconciliation
(`--ran`) printed `✓ dispatch-gates --ran: 63 derived famil(ies)
accounted for — 62 run, 1 NOT-MEASURED`.
- Every derived family exits 0 except `pnpm check:i18n-coverage` (exit
3, prerequisite not met, above). That includes `pnpm
check:pm-governed-merges`, `pnpm check:pm-record-recognisers`, `node
scripts/pm/check-governed-queue-guard.mjs --self-test`, `pnpm
check:pm-dispatch-gates` (fast tier, 2273 cases), `pnpm
check:commit-card-trailers` and `pnpm check:nul-bytes`.
- `ui/scripts/__tests__/check-governed-queue-guard.test.ts` spawns this
script and passes 10/10.
- `npx eslint --no-inline-config scripts/pm/check-governed-merges.mjs`
exits 0. The repo-wide `pnpm lint` is CI's.
- `node scripts/pm/overlap-check.mjs` reports `VERDICT clean exit 0`.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; eslint is clean on the file (repo-wide `pnpm
lint` in CI).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. Publishes nothing (`scripts/pm`), so `skip-changeset`; both
declaration lines are above.
- [x] 6. `packages/spec` not touched.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01J8VVAm5Tp3iBkiJk6nMwa5
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent a10345a commit 753aae6
1 file changed
Lines changed: 152 additions & 11 deletions
0 commit comments