Skip to content

Commit 385ea1c

Browse files
fix(pm): the regeneration carry lists a renamed path by both sides, not its destination alone (#34049)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi91bnws1UqmPVLyN8RpkkrJg)_ Fixes #33578 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:已留档的合同复审记录被「纯再生成/纯文案」跳转带到新 head 时,判定用的路径清单改为不做改名合并(`--no-renames`),改名同时列出源路径和目的路径。 - 为什么改:原来改名只列目的路径,把受审文件挪进文档目录(如 `skills/a/rules/security.md` → `content/docs/security.md`)只会看到文档路径,旧记录会被错误地延续到新 head。 - 风险与回滚:只动 `scripts/pm/` 内部工具与其自测,不发布任何包;回滚即还原本 PR 的提交。 - 先看:`scripts/pm/record-recognisers.mjs` 的 `CARRY_DIFF_ARGV` 与 `unexplainedPathsBetween`;同文件新增的真 git 自测行;`check-governed-queue-guard.mjs` 假 git 一行。 - 两分钟验证:`node scripts/pm/record-recognisers.mjs --self-test`,预期 401 例全过。 - 需要你做的:无,席位落地。 ## What changes - `scripts/pm/record-recognisers.mjs` (carry region): `unexplainedPathsBetween` lists a hop's paths, and the pull request's own delta at each head, through one module-private argv, `CARRY_DIFF_ARGV = ['diff', '-z', '--name-only', '--no-renames']`. Both reads go through the one `names` helper, so the flag is spelled once. A rename now reads as a delete plus an add, so the source path is judged by the prose arm, the `merge=os-regen` attribute and the own-delta arm like any other path. - Same file, self-test: the regen battery's fake git answers only that exact argv (any other spelling answers no paths), the two existing argument pins now spell `--no-renames`, and two cases are added (battery floor 22 → 24): - an argument pin: every `diff` the carry sent is `diff -z --name-only --no-renames A B`; - a REAL-git row in a temp repository: `skills/a/rules/security.md` moved to `content/docs/security.md`; a plain rename-detecting diff lists only the destination (the blind spot, measured in the same row), and `unexplainedPathsBetween` lists `skills/a/rules/security.md`. The row runs with `GIT_*` stripped (`gitFreeEnv`), `GIT_CONFIG_NOSYSTEM=1`, `GIT_CONFIG_GLOBAL=/dev/null`, and `-c` identity, `commit.gpgsign=false` and `diff.renames=true`, so it reads the same on any machine. - `scripts/pm/check-governed-queue-guard.mjs` (claim amendment 6897818459, one line): the regen battery's fake git took the revs positionally (`[, , , a, b]`), so the new argv read `--no-renames` as rev A and four guard cases went red. It now takes the two revs from the tail of argv. **Forced test edit.** - `scripts/pm/check-governed-merges.mjs` (claim amendment 6897818459, card comment 6887759291): the older real-git self-test fixtures (the real prober, the derive, size, oversized-sweep, rename-size and banner fixtures, and the argv-root `init`/`remote add`) now pass `env: gitFreeEnv()`; the three backdated-commit spawns spread `gitFreeEnv()` under their `GIT_*_DATE` keys. All of them already passed `-c commit.gpgsign=false`; the argv-root `init`/`remote add` make no commit. **Forced test edit** (hygiene, no behaviour change). ## Why A carried contract-review record re-runs `unexplainedPathsBetween` on the committed trees of each `Regen-provenance:` hop. With git's default rename detection, `git diff --name-only` lists a rename by its destination alone. A hop that moved a reviewed file onto a prose face listed only the prose path, the prose arm explained it, and the record carried to a head where a reviewed file had left its face. The own-delta read had the same blind spot. The queue guard's own row enumeration and its low-risk carry check already pass `--no-renames`; this brings the carry reader in line. ## Tests <details><summary>record-recognisers self-test (head 6c6a5c9, after merging main)</summary> `node scripts/pm/record-recognisers.mjs --self-test` → exit 0, `✓ record-recognisers self-test: 401 cases pass` (the two new cases on top of main e71ecc1's set; 402 on the pre-merge head 80fb531, whose base was c3c0c30). </details> <details><summary>Ablation: drop the no-renames flag (heads 80fb531 and 6c6a5c9)</summary> `node scripts/ablation-replace.mjs --file scripts/pm/record-recognisers.mjs --anchor "Object.freeze(['diff', '-z', '--name-only', '--no-renames'])" --replacement "Object.freeze(['diff', '-z', '--name-only'])" -- node scripts/pm/record-recognisers.mjs --self-test` - 80fb531: `ok mutation landed: anchor 1 -> 0, blob d15231d -> 9da9b7818a7d`, exit 1, `4 of 402 case(s) failed`. - 6c6a5c9 (after the merge): `ok mutation landed: anchor 1 -> 0, blob 03ae346 -> 4352da5184ff`, exit 1, `4 of 401 case(s) failed`. - Both times the four reds are: the real-git row (`{"destinationOnly":["content/docs/security.md"],"unexplained":[]}`), the new argument pin, and the two existing argv pins. - Restore: `git diff HEAD` empty and the file's hash equals its HEAD blob. </details> <details><summary>Queue guard self-test</summary> `node scripts/pm/check-governed-queue-guard.mjs --self-test`: with the carry change alone (head 0f2341b) exit 1, 4 of 534 failed (the regen battery's slipped-in, names-the-path, hand-resolved and prose-and-code cases). With the tail-reading fake: exit 0. </details> <details><summary>check-governed-merges self-test under a hook-shaped environment</summary> - `node scripts/pm/check-governed-merges.mjs --self-test` → exit 0. - `GIT_INDEX_FILE=SCRATCH/probe.index node scripts/pm/check-governed-merges.mjs --self-test` → exit 0, no index file written. - Control, the base file under the same environment → exit 1, 4 failures (the oversized-sweep and banner fixtures could not commit, and the INCOMPLETE-banner battery fell below its floor), and the outside index file was written. </details> ## Acceptance notes - The `check-governed-merges` self-test also spawns its own CLI (`spawnSync(process.execPath, [scriptPath, …])`) with `process.env`-based environments, and that child runs real git in the fixture roots. Those spawns were left as they are: the amendment scopes this PR to the fixtures' own git calls. carrier: #34066. - Merged `origin/main` (e71ecc1) as a merge commit: the one conflict was the adjacent `SELF_TEST_BATTERIES` rows, resolved keeping both floors (this PR's regen battery 24, main's template battery 32). The delta against main is unchanged, +67 / -17 over the three files. - On the first gate round, `check:pm-dispatch-gates` went red because the header export list grew by one line and moved the `self-test-reads` marker off the line its census pins (`record-recognisers.mjs:77`). The argv is now module-private and the header is unchanged; the marker is back on line 77. ## Verification Local gate round on head `6c6a5c9e` (the merge of main, after the last commit): `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 36 commands from the three `scripts/pm/` paths; all 36 ran, all exit 0. `--ran` reconciliation: `36 derived famil(ies) accounted for — 36 run, 0 NOT-MEASURED`. `check:pm-dispatch-gates` fast tier: `2205 cases pass; 9 slow section(s) deferred`. The same 36 were green on the pre-merge head `80fb5317`. Every family CI runs is read from this PR's check-runs, not re-run here. <details><summary>The 36 commands and their exit codes (head 6c6a5c9)</summary> ```text node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-declaration-mirrors.mjs :: exit 0 node scripts/check-declaration-mirrors.mjs --self-test :: exit 0 node scripts/check-self-test-wired.mjs :: exit 0 node scripts/check-self-test-wired.mjs --self-test :: exit 0 node scripts/check-self-test-workflow-commands.mjs :: exit 0 node scripts/check-self-test-workflow-commands.mjs --self-test :: exit 0 node scripts/check-skills-token-ratchet.mjs :: exit 0 node scripts/check-skills-token-ratchet.mjs --self-test :: exit 0 node scripts/check-whole-set-label-write.mjs :: exit 0 node scripts/check-whole-set-label-write.mjs --self-test :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 node scripts/pm/bare-root-worklist.mjs --self-test :: exit 0 node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0 pnpm check:agent-test-spelling :: exit 0 pnpm check:bash32-floor :: exit 0 pnpm check:ci-filter-parity :: exit 0 pnpm check:cli-command-ids :: exit 0 pnpm check:closing-target-claim :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:entry-guard :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:parse-guard :: exit 0 pnpm check:pm-dispatch-gates :: exit 0 pnpm check:pm-governed-merges :: exit 0 pnpm check:pm-record-recognisers :: exit 0 pnpm check:pnpm-filter-targets :: exit 0 pnpm check:pnpm-flag-spellings :: exit 0 pnpm check:ratchet-remedy-authority :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:scripts-symbol-anchors :: exit 0 pnpm check:watch-hint-literal :: 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; `pnpm lint` passes. (CI) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. (`scripts/pm/**` only: `skip-changeset`) - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (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. <!-- signed: domain:skills#1 · os-steve · session_01ADHkmQk5t2iVNRP4bBd2qx --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5af956f commit 385ea1c

3 files changed

Lines changed: 67 additions & 17 deletions

File tree

‎scripts/pm/check-governed-merges.mjs‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7698,6 +7698,7 @@ async function selfTest() {
76987698
execFileSync('git', ['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'init.defaultBranch=main', '-c', 'commit.gpgsign=false', ...rest], {
76997699
cwd,
77007700
encoding: 'utf8',
7701+
env: gitFreeEnv(),
77017702
stdio: ['ignore', 'pipe', 'pipe'],
77027703
});
77037704
const seed = join(fxRoot, 'seed');
@@ -7710,7 +7711,7 @@ async function selfTest() {
77107711
execFileSync(
77117712
'git',
77127713
['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'commit.gpgsign=false', 'commit', '-q', '--allow-empty', '-m', msg],
7713-
{ cwd: seed, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], env: { ...process.env, GIT_COMMITTER_DATE: when, GIT_AUTHOR_DATE: when } },
7714+
{ cwd: seed, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], env: { ...gitFreeEnv(), GIT_COMMITTER_DATE: when, GIT_AUTHOR_DATE: when } },
77147715
);
77157716
backdated('chore: forty days ago', new Date(Date.now() - 40 * 86_400_000).toISOString());
77167717
backdated('chore: thirty-five days ago', new Date(Date.now() - 35 * 86_400_000).toISOString());
@@ -8980,7 +8981,7 @@ async function selfTest() {
89808981
try {
89818982
const g2 = (cwd, ...rest) =>
89828983
execFileSync('git', ['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'init.defaultBranch=main', '-c', 'commit.gpgsign=false', ...rest],
8983-
{ cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
8984+
{ cwd, encoding: 'utf8', env: gitFreeEnv(), stdio: ['ignore', 'pipe', 'pipe'] });
89848985
const repo = join(derFx, 'repo');
89858986
g2(derFx, 'init', '-q', repo);
89868987
// The fixture is a checkout OF a governed repository: `--branch` / `--test`
@@ -9254,7 +9255,7 @@ async function selfTest() {
92549255
try {
92559256
const g3 = (cwd, ...rest) =>
92569257
execFileSync('git', ['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'init.defaultBranch=main', '-c', 'commit.gpgsign=false', ...rest],
9257-
{ cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
9258+
{ cwd, encoding: 'utf8', env: gitFreeEnv(), stdio: ['ignore', 'pipe', 'pipe'] });
92589259
const repo = join(sizeFx, 'repo');
92599260
g3(sizeFx, 'init', '-q', repo);
92609261
g3(repo, 'remote', 'add', 'origin', 'https://github.com/objectstack-ai/objectstack.git'); // the checkout's repository (ruling B2)
@@ -9435,14 +9436,14 @@ async function selfTest() {
94359436
try {
94369437
const og = (cwd, ...rest) =>
94379438
execFileSync('git', ['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'init.defaultBranch=main', '-c', 'commit.gpgsign=false', ...rest],
9438-
{ cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
9439+
{ cwd, encoding: 'utf8', env: gitFreeEnv(), stdio: ['ignore', 'pipe', 'pipe'] });
94399440
const seed = join(overFx, 'seed');
94409441
og(overFx, 'init', '-q', seed);
94419442
for (const [msg, ago] of [['chore: forty days ago', 40], ['chore: thirty-five days ago', 35]]) {
94429443
const when = new Date(Date.now() - ago * 86_400_000).toISOString();
94439444
execFileSync('git', ['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'commit.gpgsign=false', 'commit', '-q', '--allow-empty', '-m', msg], {
94449445
cwd: seed, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'],
9445-
env: { ...process.env, GIT_COMMITTER_DATE: when, GIT_AUTHOR_DATE: when },
9446+
env: { ...gitFreeEnv(), GIT_COMMITTER_DATE: when, GIT_AUTHOR_DATE: when },
94469447
});
94479448
}
94489449
const lines = (n) => `${Array.from({ length: n }, (_, i) => `line ${i}`).join('\n')}\n`;
@@ -9525,7 +9526,7 @@ async function selfTest() {
95259526
try {
95269527
const rg = (cwd, ...rest) =>
95279528
execFileSync('git', ['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'init.defaultBranch=main', '-c', 'commit.gpgsign=false', ...rest],
9528-
{ cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
9529+
{ cwd, encoding: 'utf8', env: gitFreeEnv(), stdio: ['ignore', 'pipe', 'pipe'] });
95299530
const repo = join(renFx, 'repo');
95309531
rg(renFx, 'init', '-q', repo);
95319532
rg(repo, 'config', 'diff.renames', 'false'); // a config that turns rename detection off must not reach the size read
@@ -9702,6 +9703,7 @@ async function selfTest() {
97029703
execFileSync('git', ['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'init.defaultBranch=main', '-c', 'commit.gpgsign=false', ...rest], {
97039704
cwd,
97049705
encoding: 'utf8',
9706+
env: gitFreeEnv(),
97059707
stdio: ['ignore', 'pipe', 'pipe'],
97069708
});
97079709
const bannerSeed = join(bannerFx, 'seed');
@@ -9713,7 +9715,7 @@ async function selfTest() {
97139715
const when = new Date(Date.now() - ago * 86_400_000).toISOString();
97149716
execFileSync('git', ['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'commit.gpgsign=false', 'commit', '-q', '--allow-empty', '-m', msg], {
97159717
cwd: bannerSeed, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'],
9716-
env: { ...process.env, GIT_COMMITTER_DATE: when, GIT_AUTHOR_DATE: when },
9718+
env: { ...gitFreeEnv(), GIT_COMMITTER_DATE: when, GIT_AUTHOR_DATE: when },
97179719
});
97189720
}
97199721
mkdirSync(join(bannerSeed, 'docs', 'adr'), { recursive: true });
@@ -9863,8 +9865,8 @@ async function selfTest() {
98639865
// A checkout whose origin IS objectstack, so the bare number's repository is
98649866
// fixed by the fixture rather than by whatever clone runs this.
98659867
const argvRoot = join(argvFx, 'objectstack');
9866-
execFileSync('git', ['init', '-q', argvRoot], { stdio: 'ignore' });
9867-
execFileSync('git', ['remote', 'add', 'origin', 'https://github.com/objectstack-ai/objectstack.git'], { cwd: argvRoot, stdio: 'ignore' });
9868+
execFileSync('git', ['init', '-q', argvRoot], { env: gitFreeEnv(), stdio: 'ignore' });
9869+
execFileSync('git', ['remote', 'add', 'origin', 'https://github.com/objectstack-ai/objectstack.git'], { cwd: argvRoot, env: gitFreeEnv(), stdio: 'ignore' });
98689870
const runArgv = (argv, env = {}) => new Promise((done) => {
98699871
apiReads.length = 0;
98709872
const child = spawn(process.execPath, [scriptPath, ...argv, '--root', argvRoot], {

‎scripts/pm/check-governed-queue-guard.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5777,7 +5777,7 @@ export async function selfTest() {
57775777
if (args[0] === 'merge-base') return `mb-${args[2]}\n`;
57785778
if (args[0] === 'check-attr') return spec.attrs;
57795779
if (args[0] === 'rev-parse') return `${REF_OLD}\n`;
5780-
const [, , , a, b] = args; // diff -z --name-only A B
5780+
const [a, b] = args.slice(-2); // diff -z --name-only --no-renames A B: the two revs are the TAIL
57815781
return a === REF_OLD && b === REF_HEAD ? spec.moved : (spec.own?.[b] ?? '');
57825782
};
57835783
const qRegen = { moved: 'packages/spec/api-surface/ui.txt\0', attrs: 'packages/spec/api-surface/ui.txt\0merge\0os-regen\0' };

‎scripts/pm/record-recognisers.mjs‎

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@
7777
// dispatch-gates: self-test-reads .claude/skills/pm-dispatch/references/project-forms.md .claude/skills/pm-dispatch/references/contract-review.md -- the mailbox doorbell battery pins the key table both ways against project-forms.md's 〈信箱 PR〉 section (every key named there, no other key named there), the claim-line battery pins the `Contract-review-claim:` template and its lapse hours in contract-review.md, and the hold-line battery pins the `Contract-review-hold:` template and its listing hours there, so a change to any of those spellings is judged here
7878

7979
import process from 'node:process';
80-
import { spawnSync } from 'node:child_process';
81-
import { readFileSync } from 'node:fs';
80+
import { execFileSync, spawnSync } from 'node:child_process';
81+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
82+
import { tmpdir } from 'node:os';
83+
import { join } from 'node:path';
8284
import { fileURLToPath } from 'node:url';
85+
import { gitFreeEnv } from '../git-env.mjs';
8386
import { isEntrypoint } from '../invoked-as.mjs';
8487
import {
8588
CONTRACT_REVIEW_HEADING_MARKER,
@@ -438,6 +441,10 @@ export function regenChainToHead(pair) {
438441
return chain.length === 0 ? null : chain;
439442
}
440443

444+
// The one argv the carry lists a hop's paths with — `--no-renames`, so a rename names BOTH sides
445+
// (why: `unexplainedPathsBetween` below).
446+
const CARRY_DIFF_ARGV = Object.freeze(['diff', '-z', '--name-only', '--no-renames']);
447+
441448
/**
442449
* The ruled test on COMMITTED trees: which moved paths are explained by NONE of
443450
* the arms of 「every touched path is a generated artefact OR THE MERGE COMMIT'S
@@ -462,9 +469,16 @@ export function regenChainToHead(pair) {
462469
* hand-resolved merge leaves its resolution in the delta at the NEW head, and a
463470
* slipped-in edit in whichever delta carries it. `-z` throughout: a path may
464471
* hold a space, a quote or a colon and the parse must not be the weak link.
472+
*
473+
* ⛔ `--no-renames` on every read, owned by the ONE helper both reads go
474+
* through: with rename detection on (git's default) a rename is listed by its
475+
* DESTINATION alone, so a hop that moves a reviewed file onto a prose face
476+
* (`skills/a/rules/security.md` → `content/docs/security.md`) would list only
477+
* the prose path and carry the record past a file that left its face. Read as
478+
* a delete plus an add, the SOURCE path is listed and judged like any other.
465479
*/
466480
export function unexplainedPathsBetween(runGit, { from, to, base }) {
467-
const names = (a, b) => String(runGit(['diff', '-z', '--name-only', a, b])).split('\0').filter((p) => p !== '');
481+
const names = (a, b) => String(runGit([...CARRY_DIFF_ARGV, a, b])).split('\0').filter((p) => p !== '');
468482
const moved = names(from, to).filter((p) => !isOutsideReviewSurface(p));
469483
if (moved.length === 0) return [];
470484
const f = String(runGit(['check-attr', '--source', to, '-z', 'merge', '--stdin'], moved.join('\0'))).split('\0');
@@ -2457,7 +2471,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
24572471
'the locator: the newest `## Contract review` on this head, on EITHER thread (#17302)': 19,
24582472
'#18141 · #27979: the head sha sits in a span of ITS OWN on the `Head-sha:` line — the key-in-span spelling and a span in the prose name no head': 14,
24592473
'the `Served-tier:` reading — the tier that SERVED the record (#17915 · #18060 · #18174)': 27,
2460-
'⭐ the 2026-09-20 ruling: a pure-regeneration head move KEEPS the record, decided on the COMMITTED trees': 22,
2474+
'⭐ the 2026-09-20 ruling: a pure-regeneration head move KEEPS the record, decided on the COMMITTED trees': 24,
24612475
// Raised 30 → 32 with ③'s SQL push-down check in the legend on every face, and its faceless-PR carrier: two pins.
24622476
'#18042: the copyable record TEMPLATE — the one machine-read artefact with nothing to copy': 32,
24632477
// Raised 17 → 19 by #33541: the template record's one `VERDICT:` line read PASS by the guard, and the same record
@@ -2840,7 +2854,9 @@ export async function selfTest() {
28402854
if (args[0] === 'merge-base') return `mb-${args[2]}\n`;
28412855
if (args[0] === 'check-attr') return spec.attrs;
28422856
if (args[0] === 'rev-parse') return `${HEAD_9AF9}00\n`;
2843-
const [, , , a, b] = args; // diff -z --name-only A B
2857+
// ⛔ Exact argv or nothing: a diff spelled any other way answers no paths, so a dropped flag cannot ride through.
2858+
if (args.length !== CARRY_DIFF_ARGV.length + 2 || CARRY_DIFF_ARGV.some((w, i) => args[i] !== w)) return '';
2859+
const [a, b] = args.slice(CARRY_DIFF_ARGV.length); // diff -z --name-only --no-renames A B
28442860
return a === HEAD_9AF9 && b === NEW_HEAD ? spec.moved : (spec.own?.[b] ?? '');
28452861
};
28462862
const REGEN_ONLY = { moved: 'packages/spec/api-surface/data.txt\0', attrs: 'packages/spec/api-surface/data.txt\0merge\0os-regen\0' };
@@ -2867,7 +2883,7 @@ export async function selfTest() {
28672883
t('⛔ a thread with no line carries none, so the ordinary rule is untouched where nobody claims the exception', regenChainToHead(moved([RECORD_ON_9AF9])) === null && regenCarry(moved([RECORD_ON_9AF9])).state === 'none' && locateReviewOfRecord(moved([RECORD_ON_9AF9], GIT_EMPTY)).state === 'absent');
28682884
// the tree test — and it reads COMMITTED trees, never the working one
28692885
t('⭐ an EMPTY non-`merge=os-regen` diff CARRIES the record', regenCarry(CARRIED()).state === 'carried');
2870-
t('…and a generated path DID move: the test named two COMMITS and read `.gitattributes` out of the new one', GIT_SEEN.includes(`diff -z --name-only ${HEAD_9AF9} ${NEW_HEAD}`) && GIT_SEEN.includes(`check-attr --source ${NEW_HEAD} -z merge --stdin`), GIT_SEEN.join(' | '));
2886+
t('…and a generated path DID move: the test named two COMMITS and read `.gitattributes` out of the new one', GIT_SEEN.includes(`diff -z --name-only --no-renames ${HEAD_9AF9} ${NEW_HEAD}`) && GIT_SEEN.includes(`check-attr --source ${NEW_HEAD} -z merge --stdin`), GIT_SEEN.join(' | '));
28712887
t('…so the record is FOUND on the new head, naming the head it actually judged and the hop count', (() => { const r = locateReviewOfRecord(CARRIED()); return r.state === 'found' && r.carriedFrom.startsWith(HEAD_9AF9) && r.carriedHops === 1; })());
28722888
t('⛔ a HAND-WRITTEN path in the same range certifies nothing — refused, and the reason says which path', (() => { const r = regenCarry(moved([RECORD_ON_9AF9, PROV()], GIT_HAND)); return r.state === 'refused' && says(r.reason, 'scripts/pm/x.mjs'); })() && locateReviewOfRecord(moved([RECORD_ON_9AF9, PROV()], GIT_HAND)).state === 'absent');
28732889
t('⛔ a chain whose hops name DIFFERENT records certifies nothing', regenCarry(moved([RECORD_ON_9AF9, PROV(HEAD_9AF9, 'bbbbbbbb', 3301), PROV('bbbbbbbb', NEW_HEAD, 9999)], GIT_EMPTY)).state === 'refused');
@@ -2883,8 +2899,40 @@ export async function selfTest() {
28832899
t('⭐ (i) a MERGE-FORWARD carrying ANOTHER PR\'s hand-written path beside the regeneration is CARRIED', regenCarry(withGit(GIT(CARRY_OVER))).state === 'carried' && locateReviewOfRecord(withGit(GIT(CARRY_OVER))).state === 'found');
28842900
t('⛔ (iii) the SAME path, hand-resolved so the new head no longer holds what main brought, is REFUSED', (() => { const r = regenCarry(withGit(GIT(HAND_RESOLVED))); return r.state === 'refused' && says(r.reason, 'AGENTS.md'); })());
28852901
t('⇒ the DELTA decides, ⛔ never the path name: one path, two specimens, two verdicts', unexplainedPathsBetween(GIT(CARRY_OVER), { from: HEAD_9AF9, to: NEW_HEAD, base: BASE }).length === 0 && unexplainedPathsBetween(GIT(HAND_RESOLVED), { from: HEAD_9AF9, to: NEW_HEAD, base: BASE }).join() === 'AGENTS.md');
2886-
t('…and the delta is read ONCE PER HEAD against `merge-base BASE head`, ⛔ never once per path', GIT_SEEN.includes(`merge-base ${BASE} ${HEAD_9AF9}`) && GIT_SEEN.includes(`diff -z --name-only mb-${NEW_HEAD} ${NEW_HEAD}`), GIT_SEEN.slice(-4).join(' | '));
2902+
t('…and the delta is read ONCE PER HEAD against `merge-base BASE head`, ⛔ never once per path', GIT_SEEN.includes(`merge-base ${BASE} ${HEAD_9AF9}`) && GIT_SEEN.includes(`diff -z --name-only --no-renames mb-${NEW_HEAD} ${NEW_HEAD}`), GIT_SEEN.slice(-4).join(' | '));
28872903
t('⛔ (iv) a run naming NO base ref cannot tell main\'s carry-over from a hand edit — UNREADABLE, ⛔ never clean', (() => { const r = regenCarry(withGit(GIT(CARRY_OVER), { baseRef: null })); return r.state === 'unreadable' && r.gaps.some((g) => g.includes('base ref')); })());
2904+
// ⛔ A rename is read as a delete plus an add (`--no-renames`), so a hop that moves a reviewed file onto
2905+
// a prose face lists the SOURCE path and is judged by it: the fake git above answers nothing to any
2906+
// other spelling, and every diff it was sent is the one argv the reader owns.
2907+
t('⛔ every name list the carry reads is sent as `diff -z --name-only --no-renames A B`, ⛔ never with rename detection on', (() => { const diffs = GIT_SEEN.filter((c) => c.startsWith('diff ')); return diffs.length > 0 && diffs.every((c) => /^diff -z --name-only --no-renames \S+ \S+$/.test(c)); })(), GIT_SEEN.filter((c) => c.startsWith('diff ')).join(' | '));
2908+
const RENAMED_OUT = (() => {
2909+
const dir = mkdtempSync(join(tmpdir(), 'carry-rename-'));
2910+
try {
2911+
// GIT_* stripped (GIT_ENV_ISOLATION_RULE) and no global or system config read: identity, signing and
2912+
// rename detection are all set here, so the row reads the same on every machine.
2913+
const env = { ...gitFreeEnv(), GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '/dev/null' };
2914+
const realGit = (args, input) => execFileSync('git', ['-c', 'user.email=t@t.invalid', '-c', 'user.name=t', '-c', 'init.defaultBranch=main', '-c', 'commit.gpgsign=false', '-c', 'diff.renames=true', ...args], { cwd: dir, encoding: 'utf8', env, input, stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'] });
2915+
realGit(['init', '-q']);
2916+
mkdirSync(join(dir, 'skills/a/rules'), { recursive: true });
2917+
writeFileSync(join(dir, 'skills/a/rules/security.md'), 'Never echo a token back.\n'.repeat(20));
2918+
realGit(['add', '-A']);
2919+
realGit(['commit', '-q', '-m', 'base']);
2920+
const from = realGit(['rev-parse', 'HEAD']).trim();
2921+
realGit(['checkout', '-q', '-b', 'pr']);
2922+
mkdirSync(join(dir, 'content/docs'), { recursive: true });
2923+
realGit(['mv', 'skills/a/rules/security.md', 'content/docs/security.md']);
2924+
realGit(['commit', '-q', '-m', 'move']);
2925+
const to = realGit(['rev-parse', 'HEAD']).trim();
2926+
const destinationOnly = realGit(['diff', '-z', '--name-only', from, to]).split('\0').filter(Boolean);
2927+
const unexplained = unexplainedPathsBetween(realGit, { from, to, base: 'main' });
2928+
return destinationOnly.join() === 'content/docs/security.md' && unexplained.join() === 'skills/a/rules/security.md' ? true : JSON.stringify({ destinationOnly, unexplained });
2929+
} catch (error) {
2930+
return String(error?.message ?? error);
2931+
} finally {
2932+
rmSync(dir, { recursive: true, force: true });
2933+
}
2934+
})();
2935+
t('⛔ on REAL git, a reviewed file RENAMED onto a prose face is unexplained by its SOURCE path — the destination alone would carry the record', RENAMED_OUT === true, RENAMED_OUT);
28882936

28892937
// ⭐ the PROSE arm (B′ with C, ruling record 6159870311): a head that moves only on faces outside the
28902938
// review surface keeps the record — decided on the same committed trees, by the same line.

0 commit comments

Comments
 (0)