Repository navigation
Commit d949cab
committed
fix(jsonFileRecovery): scope leftover tails per prefix so a timestamp-only backup is still recoverable
The platform-unit-test (ubuntu-latest) arm went red at 9f150f5 on my own change. Its annotation reads "command (/home/runner/work/Zoo-Code/Zoo-Code/src) .../pnpm run test:coverage:core exited (1)" (check run 128966094221); the platform-unit-test (windows-latest) run 128966094415 was cancelled by fail-fast and carries no verdict of its own. Reproducing the expanded script locally (vitest run --config vitest.core.config.ts --coverage) reproduced it deterministically at that head: exit 1, "Tests 1 failed | 4233 passed | 9 skipped", failing row core/task-persistence/__tests__/TaskHistoryStore.realConcurrency.spec.ts > "preserves a recovered record instead of overwriting it during legacy migration", which plants .history_item.json.bak_1.tmp and expects migration to recover it. The same spec passes at the parent d29b7a3 (exit 0, 12 passed), and reverting only src/utils/jsonFileRecovery.ts to the parent version at this head makes it pass too (12 passed), so the cause is mine: the tail I required for every prefix, ^\d+_[^_]+\.tmp$, dropped the timestamp-only backup names that predate the random token.
Scope the tail by what each prefix already pins. The dot-anchored prefixes .<basename>.new_ and .<basename>.bak_ carry the basename behind a literal dot, so a timestamp alone identifies the name and the token stays optional. The underscore-anchored staged prefix .new_<basename>_ is not scoped by its prefix alone - a.json_extra.json beside a.json stages .new_a.json_extra_<ts>_<rand>.tmp, which starts with .new_a.json_ and belongs to a writer holding only the sibling's lock - so only the full <ts>_<rand>.tmp tail attributes a staged-looking name there.
Proof rows: jsonFileRecovery.test.ts adds "collects a timestamp-only backup name under the dot-anchored prefix" (fails with a uniform strict tail: 1 failed / 17 passed) and "does not collect a staged-looking name that lacks the token" (fails with a uniform relaxed tail: 1 failed / 17 passed). The coverage command on the fixed tree: run 3 exit 0, "196 passed (196)", "4234 passed | 9 skipped", no failing file; run 4 exit 1 with the same 196 files and 4234 tests passing and 1 unhandled EnvironmentTeardownError ("[vitest-worker]: Closing rpc while onUserConsoleLog was pending", originating in core/webview/__tests__/ClineProvider.spec.ts). That teardown error is the shard's own flake, independent of this fix: 12 occurrences at the previous head, 0 in the second run there, 0 in run 3 and 1 in run 4 here, and it flips the exit code with zero failing tests.1 parent 9f150f5 commit d949cab
2 files changed
Lines changed: 51 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
139 | 163 | | |
140 | 164 | | |
141 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 23 | + | |
31 | 24 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
| |||
0 commit comments