Repository navigation
Commit a3aa1d2
fix(pm): dispatch-gates derives the change set with -z, so a non-ASCII governed path keeps its tier (#33998)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi916SWCJMeiaqJP9Bb2wnp2s)_
Fixes #33847
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:派发工具 `dispatch-gates.mjs` 的 `changedPathsFromGit`
读变更路径(已提交、未提交、未跟踪三份清单)时改成加 `-z`、按 NUL 切分,三份清单走同一个读取函数,`-z` 由该函数统一插入。
- 为什么改:不加 `-z` 时 git 会把含中文等非 ASCII 字符或换行的路径打印成带引号的转义串,它对不上任何 glob,于是
`skills/**` 下这样命名的受管文件在派发时算不出复审档位,派生的门禁清单也漏掉它;未跟踪的这种文件还被记成「读不到、0 行」。
- 风险与回滚:只改 `scripts/pm/**` 一个工具脚本和它的自测,不发布任何包;所有 ASCII 路径的读数逐字节不变。回滚即还原本
PR。
- 先看:`scripts/pm/dispatch-gates.mjs` 的 `gitPathList`(新读取函数)与
`changedPathsFromGit` 的三处调用;自测文件里 `quoted-names` 场景。
- 两分钟验证:在一个分支上提交 `skills/objectstack-data/文档.md` 后跑 `node
scripts/pm/dispatch-gates.mjs --tier`,预期 stderr 列出原样的中文路径,stdout
给出契约复审档位(修复前是带引号的转义串、无档位)。
- 需要你做的:无,席位落地(非受管面)。
## What changes
`changedPathsFromGit` (it feeds `--tier`, `--commands` and the
changed-line size) read its three path lists line by line, with no `-z`:
| Read | Was | Now |
|:--|:--|:--|
| committed | `diff --name-only --no-renames MERGE_BASE HEAD`, split on
newline, trimmed | `diff -z --name-only --no-renames MERGE_BASE HEAD`,
split on NUL, not trimmed |
| working tree | `diff --name-only --no-renames HEAD`, same | `diff -z
…`, same |
| untracked | `ls-files --others --exclude-standard`, same | `ls-files
-z …`, same |
| `changedLinesFromGit` fallback (no `untracked` passed) | the untracked
read above | the same `-z` read |
Git C-quotes a path holding a non-ASCII byte, a double quote or a
control character (a file named in Chinese prints as a quoted octal
string), and that spelling starts with a quote mark, so it matched no
glob. Measured on a real repo before the fix: a committed `skills/x/`
file named in Chinese plus an untracked one derived `tier: null`, and
the untracked one was counted as 1 unreadable file of 0 lines. After:
both raw, tier `CONTRACT_REVIEW_TIER`, 0 unreadable.
All four reads now go through one reader, `gitPathList`, which splices
`-z` in after the subcommand itself, so no caller in this file can list
paths the other way. The old `gitLines` had no other caller and is gone.
Not done, per the card: `core.quotePath=false` alone, which would still
split a newline name in two.
Not changed: the size read `diff --numstat -M` (summed by `parseNumstat`
in `check-governed-merges.mjs`) only adds the two counts, which quoting
never touches; the same call was left as is in #33804 for the same
reason.
## Tests
`node scripts/pm/dispatch-gates.mjs --self-test` on acb82a3: **2520
cases pass**, exit 0 (lock VERDICT command-exit 0). Five new cases, in
the slow tier's real-git section, on a fixture repo that sets
`core.quotePath true` itself so it quotes on any machine. Each of the
three reads carries one name git quotes: a committed file named in
Chinese, an uncommitted edit to another, and an untracked file whose
name holds a newline.
- CONTROL: the plain read (no `-z`) of the same branch quotes all three,
and they derive no tier and name no gate family.
- The derived change set lists each name raw (committed 1, worktree 1,
untracked 1).
- Those raw names derive `CONTRACT_REVIEW_TIER` through `skills/**` (3
hits).
- They name `check:skill-*` gate families, the ones the derived
`--commands` list is built from.
- The untracked newline-named file is counted from disk: 0 unreadable,
+3 lines.
No existing test was edited.
<details><summary>Ablation: the old reader restored on disk, exactly the
four new rows red, restored (head acb82a3)</summary>
Each mutation through `node scripts/ablation-replace.mjs` (anchor hits 1
then 0 on disk, blob changed), the self-test under `os-verify-lock.sh`;
restore: blob == HEAD (`6343de57fbce`) and `git diff HEAD` empty, both
legs.
```text
leg 2 (the card's ablation): gitPathList body back to the old gitLines body
(no -z, split on newline, trimmed) -> VERDICT command-exit 1, 4 of 2520 failed:
the derived change set spells each C-quoted name as it is on disk: committed, uncommitted and untracked (newline included)
and those raw names derive the contract-review tier through the skills/** glob
and they name the skill gate families the derived --commands list is built from
and the untracked newline-named file is counted from disk, not as an unreadable file of 0 lines
(the CONTROL row stays green, as it must)
leg 1: only the spliced -z dropped, NUL split kept -> VERDICT command-exit 1, 12 of 2520 failed:
the four rows above, plus 8 older real-git derivation rows: without -z
the whole newline-joined listing comes back as ONE name, so -z and the
NUL split are bound in one reader and cannot drift apart
```
</details>
## Acceptance notes
- Every ASCII path reads byte-identically: the 2515 cases that existed
before all stay green on the fix.
- `derivationProvenance` prints one path per stderr line, so a path with
a newline in its name now prints raw across two lines there. That is
display only (stdout and the tier are unaffected); not changed.
- Serial: #33848 edits the same two files and waits for this PR to
merge.
## Verification
Local subset on acb82a3 (final head): `node
scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 30 commands; all 30 exit 0 (each
exit captured before any pipe). `--ran` with every line annotated `::
exit N`: **30 derived, 30 run, 0 NOT-MEASURED, 0 UNRUN** (a derived
zero, all 30 recorded an exit code). `pnpm check:pm-dispatch-gates` is
in that 30 (its fast tier, 2205 cases); the full both-tier battery is
the 2520 above. The script's other callers of `changedPathsFromGit` are
only `check-dispatch-gates.mjs`, covered there. No package touched, so
no build closure and no package test is owed; CI runs the rest.
<details><summary>The 30 commands and their exit codes</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-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
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:cross-package-test-inputs :: exit 0
pnpm check:declared-population-live :: 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: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>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmPfzYmYaFdzt3TJ9w2)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent b37d5ab commit a3aa1d2
2 files changed
Lines changed: 91 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15967 | 15967 | | |
15968 | 15968 | | |
15969 | 15969 | | |
15970 | | - | |
| 15970 | + | |
| 15971 | + | |
| 15972 | + | |
| 15973 | + | |
| 15974 | + | |
| 15975 | + | |
| 15976 | + | |
| 15977 | + | |
| 15978 | + | |
| 15979 | + | |
| 15980 | + | |
| 15981 | + | |
| 15982 | + | |
| 15983 | + | |
| 15984 | + | |
| 15985 | + | |
| 15986 | + | |
| 15987 | + | |
15971 | 15988 | | |
15972 | 15989 | | |
15973 | | - | |
| 15990 | + | |
15974 | 15991 | | |
15975 | 15992 | | |
15976 | 15993 | | |
| |||
16046 | 16063 | | |
16047 | 16064 | | |
16048 | 16065 | | |
16049 | | - | |
16050 | | - | |
16051 | | - | |
| 16066 | + | |
| 16067 | + | |
| 16068 | + | |
| 16069 | + | |
| 16070 | + | |
16052 | 16071 | | |
16053 | 16072 | | |
16054 | 16073 | | |
| |||
16084 | 16103 | | |
16085 | 16104 | | |
16086 | 16105 | | |
16087 | | - | |
| 16106 | + | |
16088 | 16107 | | |
16089 | 16108 | | |
16090 | 16109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11332 | 11332 | | |
11333 | 11333 | | |
11334 | 11334 | | |
| 11335 | + | |
| 11336 | + | |
| 11337 | + | |
| 11338 | + | |
| 11339 | + | |
| 11340 | + | |
| 11341 | + | |
| 11342 | + | |
| 11343 | + | |
| 11344 | + | |
| 11345 | + | |
| 11346 | + | |
| 11347 | + | |
| 11348 | + | |
| 11349 | + | |
| 11350 | + | |
| 11351 | + | |
| 11352 | + | |
| 11353 | + | |
| 11354 | + | |
| 11355 | + | |
| 11356 | + | |
| 11357 | + | |
| 11358 | + | |
| 11359 | + | |
| 11360 | + | |
| 11361 | + | |
| 11362 | + | |
| 11363 | + | |
| 11364 | + | |
| 11365 | + | |
| 11366 | + | |
| 11367 | + | |
| 11368 | + | |
| 11369 | + | |
| 11370 | + | |
| 11371 | + | |
| 11372 | + | |
| 11373 | + | |
| 11374 | + | |
| 11375 | + | |
| 11376 | + | |
| 11377 | + | |
| 11378 | + | |
| 11379 | + | |
| 11380 | + | |
| 11381 | + | |
| 11382 | + | |
| 11383 | + | |
| 11384 | + | |
| 11385 | + | |
| 11386 | + | |
| 11387 | + | |
| 11388 | + | |
| 11389 | + | |
| 11390 | + | |
| 11391 | + | |
| 11392 | + | |
| 11393 | + | |
| 11394 | + | |
| 11395 | + | |
| 11396 | + | |
| 11397 | + | |
| 11398 | + | |
| 11399 | + | |
| 11400 | + | |
11335 | 11401 | | |
11336 | 11402 | | |
11337 | 11403 | | |
| |||
0 commit comments