Repository navigation
Commit ae268ae
authored
Fixes #3077
Owner: Dev-3
Reviewer: Birfy
Written-by: Dev-3
Bot: FlyBot Dev-3
Claim-Id: 171de2f559ab43f2aa9b4d358a4fc085
Base: f210567 — the live `main` this
branch was cut from (`#3076`'s merge commit), read with `git ls-remote
up HEAD` right before the cut and again before the push; no rebase
Pushed head: cca7f38
Tree: 1bd6027
Tier: T3 — `scripts/i18n-usage.mjs` and its tests. No gate file is
touched: `policy/gates.json` lists
`.github/scripts/{merge-gate,review-gate,pass-label,risk-gate,policy-sign,enqueue-guard,enqueue-rules,gate-check}.mjs`,
`scripts/self-test-catalog.mjs`, the four workflows and `policy/` — this
PR edits none of them, so `policy-sign` stays green and `test` runs for
real.
Ran: red-first twice on `f2105675` with the three new tests and
`scripts/i18n-usage.mjs` at its base blob; at the tip: the five i18n
suites 39/39, the three new tests 3/3, `i18n-usage --missing` 167, bare
draws 20, template draws 43, `i18n-usage --missing --write … --force` no
change, `build-client --check` exit 0, `ds-bot-patches check` 3 lines +
`canonical` no-op, `changelog.mjs check` 7 fragments, `arch-docs: OK (0
changed file(s))`
Not run: `oxlint` (no oxlint binary in this checkout or in the harness
dir, with `DSH_HARNESS` set) and `npm run verify` as one command (no
`node_modules` in this worktree beyond a linked `core/node_modules`);
every step was run individually, listed below. No client bundle is
touched, so no rebuild is owed.
## What changed
`tokens()` in `scripts/i18n-usage.mjs` emitted a punct token for `(` and
`[` but not for `]` (`:195` only did `calls.pop()` and stepped over it).
Every depth that started at a bracket therefore never returned to zero,
and the walk stopped splitting `? :` and `||` at depth 0 — so a returned
literal beside an indexed read (`return list[0] || 'None yet'`) was
swallowed together with the rest of the file. `missingCopy()` on that
snippet returned `[]`; without `[0]` the same literal is reported.
- **The tokenizer closes what it opens.** `]` now emits `{ type:
'punct', value: ']' }` the way `)` and `[` do, before the `calls.pop()`,
so the depth bookkeeping (`:325-332`, `:436-440`, `:461-470`,
`:540-550`) sees the token it was written against.
- **That alone flips an existing pin off by accident.** With the bracket
closed, the run that used to overrun to end-of-file no longer does, and
one already-pinned sentence stops being found by overrun:
`plugins/social/client.js`'s `FriendNote` keeps its words in a local
interpolated into a template (`` `${who} stays a friend: still shared
through ${linked}.` ``). The pin for the sibling branch was an artefact
of the overrun, not of a read.
- **So the walk now records the names a `${}` hole interpolates.** A
template token carries `holes` (the identifiers inside its `${}` code),
and `yieldedLiterals` counts a name as read when it appears in a hole
*and* the sentence is a substituted template — a hole has no room for a
bare word, so a bare word read only through a hole stays data (`||
'share'` is still not copy). Both branches of that sentence are then
reported on their own merit, and the baseline grows by exactly one pin.
- `core/test/i18n-missing-entries.test.js` gains three tests (below);
`changelog.d/3077-i18n-indexed-read.changed.md` carries the note. The
`patches/ds-bot/files/` copies of the two test-side files are the same
bytes (`ds-bot-patches check` proves it).
## Red first
Base `f2105675` with the three new tests present and
`scripts/i18n-usage.mjs` at its base blob, run twice; output identical
after normalising durations and the checkout path (both normalised files
sha256 `97e7ad2a45aeb92447ea…`).
```
TMPDIR=/tmp/i18nred TZ=UTC node --import ./test/harness-resolve.mjs --test \
--test-name-pattern '#3077' test/i18n-missing-entries.test.js
```
```
not ok 1 - #3077: the tokenizer closes the bracket it opened
location: 'core/test/i18n-missing-entries.test.js:287:1'
error: Expected values to be strictly deep-equal: + actual - expected
actual: ['=', '['] expected: ['=', '[', ']'] (assertion at :289:10)
not ok 2 - #3077: a literal beside an indexed read is still copy
location: 'core/test/i18n-missing-entries.test.js:294:1'
error: Expected values to be strictly deep-equal: + actual - expected
actual: [] expected: ['None yet'] (assertion at :299:10)
not ok 3 - #3077: a name a template interpolates is a read, not a dead local
location: 'core/test/i18n-missing-entries.test.js:306:1'
error: Expected values to be strictly deep-equal: + actual - expected
actual: [] expected: ['{} stays a friend: still shared through {}.',
'Your own Bots stay shared. {} can share it again.'] (assertion at :316:10)
# tests 3
# pass 0
# fail 3
```
Test 2 is the defect Product reported (`[]` where the copy is `'None
yet'`). Test 3 is the pin the `]` fix flips: on the base it reports
nothing because the whole `FriendNote` body was lost to the overrun.
## Verification at the tip
Tip `cca7f387d09850e0f3bd45bbe4c6a06978de15c9` (tree
`1bd6027fa1a4051097bab6de76bdf6149cd0eb39`, base `f2105675`), **1
commit**, 6 files **+104/−6**:
- `scripts/i18n-usage.mjs` +19/−4,
`core/test/i18n-missing-entries.test.js` +41/−1,
`patches/ds-bot/files/test/i18n-missing-entries.test.js` +41/−1, the two
baselines +1 each, `changelog.d/3077-i18n-indexed-read.changed.md` +1
- `i18n` suites (`i18n`, `i18n-plugins`, `i18n-plugins-missing-zh`,
`i18n-template-draws`, `i18n-missing-entries`): **39/39**
- the three new tests: 3/3, `--test-name-pattern '#3077'`
- `node scripts/i18n-usage.mjs --missing` → `167 drawn copy strings with
no zh entry in 4 files` (main 166; the one new pin is
`plugins/social/client.js:Your own Bots stay shared. {} can share it
again.`)
- `node scripts/i18n-usage.mjs` → `20 bare draws in 4 files`
(unchanged); `--template-draws` → `43 template draws … in 3 files`
(unchanged)
- `node scripts/i18n-usage.mjs --missing --write
core/test/i18n-missing-entries.baseline.json --force` → `wrote 167
entries (+0/-0)` (the pinned file is exactly what the scan now produces;
the +1 is the accepted intake, nothing was removed)
- `node core/scripts/build-client.mjs --check`: exit 0
- `node scripts/ds-bot-patches.mjs check`: `ok ds-bot/ =
Fei2411/DeepSeek-Bot@2b10c70 (tree 5834c00, v0.1.5)`, `ok 10 patches
apply cleanly in order`, `ok core/ equals ds-bot/ + patches/ds-bot/`;
`canonical`: `ok patches/ds-bot/ is what generate writes (generate is a
no-op)`
- `node .github/scripts/changelog.mjs check`: `7 fragment(s) in
changelog.d/ are well formed`
- `ARCH_DOCS_BASE=f2105675ee6fee5fefbef9e73ef32c4003677e90 node
core/scripts/check-arch-docs.mjs`: `arch-docs: OK (0 changed file(s))`
- `git rev-list --count f210567..HEAD` = 1
## Checkpoint
<!-- flybot:checkpoint -->
```json
{"pr":3078,"claim":"Dev-3","issue":3077,"summary":"`tokens()` sent a punct token for `(` and `[` but not `]`, so bracket depth never returned to zero: `? :` and `||` stopped splitting and `return list[0] || 'None yet'` was dropped. `]` now emits its token before the single `calls.pop()`, so each close decrements once. Closing the bracket flipped one existing pin off by accident, so templates record the names their `${}` holes interpolate; a name read only in a hole counts for a substituted template. `--missing` moves 166 to 167 (a string already on main); bare draws stay 20, template draws 43, `--write --force` is +0/-0, no gate file touched.","files":["scripts/i18n-usage.mjs","core/test/i18n-missing-entries.test.js","core/test/i18n-missing-entries.baseline.json","patches/ds-bot/files/test/i18n-missing-entries.test.js","patches/ds-bot/files/test/i18n-missing-entries.baseline.json","changelog.d/3077-i18n-indexed-read.changed.md"],"checks":{"ran":"base f210567 + three new tests: 3 tests, 0 pass, 3 fail; tip: five i18n suites 39/39, --missing 167, bare 20, template 43, --write --force +0/-0, build-client --check exit 0, ds-bot-patches check 3 ok + canonical no-op, changelog 7 fragments, 1 commit","result":"green","at":"cca7f387d09850e0f3bd45bbe4c6a06978de15c9"},"next":"head frozen at cca7f38; the PASS at this tip lets enqueue-guard pass; merge then closes #3077"}
```
<!-- /flybot:checkpoint -->
1 parent f210567 commit ae268ae
6 files changed
Lines changed: 104 additions & 6 deletions
File tree
- changelog.d
- core/test
- patches/ds-bot/files/test
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
| |||
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| |||
166 | 175 | | |
167 | 176 | | |
168 | 177 | | |
169 | | - | |
| 178 | + | |
170 | 179 | | |
171 | 180 | | |
172 | 181 | | |
| |||
193 | 202 | | |
194 | 203 | | |
195 | 204 | | |
196 | | - | |
| 205 | + | |
197 | 206 | | |
198 | 207 | | |
199 | 208 | | |
| |||
609 | 618 | | |
610 | 619 | | |
611 | 620 | | |
612 | | - | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
613 | 628 | | |
614 | 629 | | |
615 | 630 | | |
616 | 631 | | |
617 | 632 | | |
618 | 633 | | |
619 | 634 | | |
620 | | - | |
| 635 | + | |
621 | 636 | | |
622 | 637 | | |
623 | 638 | | |
| |||
0 commit comments