|
| 1 | +# Committed Update Time Implementation Plan |
| 2 | + |
| 3 | +> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. |
| 4 | +
|
| 5 | +**Goal:** Publish `/parsing_status.update_date` only after a successful full parse run, while preserving the original replay-list snapshot timestamp (`replaysListPreparedAt`) used by that run. |
| 6 | + |
| 7 | +**Architecture:** Capture run-local `replaysListPreparedAt` at parse start in `replays-parser`, commit it into `results/parsing_status.json` only after successful output generation, and make `server` read update time from that committed artifact. Keep strict fallback behavior for bootstrap and corrupted metadata cases. |
| 8 | + |
| 9 | +**Tech Stack:** TypeScript (replays-parser), Node.js CommonJS (server), Jest, node:test, fs-extra. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +### Task 1: Add committed parsing status utilities in replays-parser |
| 14 | + |
| 15 | +**Files:** |
| 16 | +- Create: `/home/afgan0r/Projects/SolidGames/replays-parser/src/0 - utils/parsingStatus.ts` |
| 17 | +- Modify: `/home/afgan0r/Projects/SolidGames/replays-parser/src/0 - utils/paths.ts` |
| 18 | + |
| 19 | +**Step 1: Write the failing test** |
| 20 | + |
| 21 | +- Create parser utility tests that expect: |
| 22 | +1. read run snapshot from `replaysList.json.replaysListPreparedAt` |
| 23 | +2. write `results/parsing_status.json` atomically |
| 24 | + |
| 25 | +**Step 2: Run test to verify it fails** |
| 26 | + |
| 27 | +Run: `npm run test -- src/!tests/unit-tests/0 - utils/parsingStatus.test.ts` |
| 28 | +Expected: FAIL (module/functions missing) |
| 29 | + |
| 30 | +**Step 3: Write minimal implementation** |
| 31 | + |
| 32 | +- Add `parsingStatusPath` in `paths.ts` pointing to `results/parsing_status.json`. |
| 33 | +- Implement in `parsingStatus.ts`: |
| 34 | +1. `readRunReplayListPreparedAt(): string | null` |
| 35 | +2. `commitParsingStatus(updateTime: string | null): void` |
| 36 | +3. Atomic write via temp file + rename. |
| 37 | + |
| 38 | +**Step 4: Run test to verify it passes** |
| 39 | + |
| 40 | +Run: `npm run test -- src/!tests/unit-tests/0 - utils/parsingStatus.test.ts` |
| 41 | +Expected: PASS |
| 42 | + |
| 43 | +**Step 5: Commit** |
| 44 | + |
| 45 | +```bash |
| 46 | +git add src/0\ -\ utils/parsingStatus.ts src/0\ -\ utils/paths.ts src/!tests/unit-tests/0\ -\ utils/parsingStatus.test.ts |
| 47 | +git commit -m "feat: add committed parsing status utility" |
| 48 | +``` |
| 49 | + |
| 50 | +### Task 2: Wire committed status into parse pipeline |
| 51 | + |
| 52 | +**Files:** |
| 53 | +- Modify: `/home/afgan0r/Projects/SolidGames/replays-parser/src/index.ts` |
| 54 | +- Test: `/home/afgan0r/Projects/SolidGames/replays-parser/src/!tests/unit-tests/schedule.test.ts` |
| 55 | + |
| 56 | +**Step 1: Write the failing test** |
| 57 | + |
| 58 | +- Add test that on successful parse run status commit is called with run snapshot. |
| 59 | +- Add test that on failure commit is not called. |
| 60 | + |
| 61 | +**Step 2: Run test to verify it fails** |
| 62 | + |
| 63 | +Run: `npm run test -- src/!tests/unit-tests/schedule.test.ts` |
| 64 | +Expected: FAIL (missing commit behavior) |
| 65 | + |
| 66 | +**Step 3: Write minimal implementation** |
| 67 | + |
| 68 | +In `src/index.ts`: |
| 69 | +1. read run snapshot before heavy parsing starts |
| 70 | +2. after successful `generateOutput`, call `commitParsingStatus(runSnapshot)` |
| 71 | +3. keep failure path unchanged (no commit) |
| 72 | + |
| 73 | +**Step 4: Run test to verify it passes** |
| 74 | + |
| 75 | +Run: `npm run test -- src/!tests/unit-tests/schedule.test.ts` |
| 76 | +Expected: PASS |
| 77 | + |
| 78 | +**Step 5: Commit** |
| 79 | + |
| 80 | +```bash |
| 81 | +git add src/index.ts src/!tests/unit-tests/schedule.test.ts |
| 82 | +git commit -m "feat: commit update time only after successful parse" |
| 83 | +``` |
| 84 | + |
| 85 | +### Task 3: Switch server update_date to committed status artifact |
| 86 | + |
| 87 | +**Files:** |
| 88 | +- Modify: `/home/afgan0r/Projects/SolidGames/server/src/utils/date.js` |
| 89 | +- Modify: `/home/afgan0r/Projects/SolidGames/server/src/server.js` |
| 90 | +- Test: `/home/afgan0r/Projects/SolidGames/server/src/utils/date.test.js` |
| 91 | + |
| 92 | +**Step 1: Write the failing test** |
| 93 | + |
| 94 | +Add/adjust tests for `getParsingStatusUpdateDate(listsPath, resultsPath)`: |
| 95 | +1. returns `parsing_status.json.updateTime` when valid |
| 96 | +2. falls back to `stats.zip` mtime when status file missing/invalid |
| 97 | +3. falls back to `new Date()` when all unavailable |
| 98 | + |
| 99 | +**Step 2: Run test to verify it fails** |
| 100 | + |
| 101 | +Run: `npm test` |
| 102 | +Expected: FAIL on old fallback logic |
| 103 | + |
| 104 | +**Step 3: Write minimal implementation** |
| 105 | + |
| 106 | +In `date.js`: |
| 107 | +1. read `results/parsing_status.json` |
| 108 | +2. validate `updateTime` as date |
| 109 | +3. fallback chain: status file -> `stats.zip` mtime -> now |
| 110 | + |
| 111 | +In `server.js`: |
| 112 | +- keep `/parsing_status` using `getParsingStatusUpdateDate(listsPath, resultsPath)` |
| 113 | + |
| 114 | +**Step 4: Run test to verify it passes** |
| 115 | + |
| 116 | +Run: `npm test` |
| 117 | +Expected: PASS |
| 118 | + |
| 119 | +**Step 5: Commit** |
| 120 | + |
| 121 | +```bash |
| 122 | +git add src/utils/date.js src/server.js src/utils/date.test.js |
| 123 | +git commit -m "feat: read parsing update time from committed status file" |
| 124 | +``` |
| 125 | + |
| 126 | +### Task 4: Cross-repo verification and docs refresh |
| 127 | + |
| 128 | +**Files:** |
| 129 | +- Modify: `/home/afgan0r/Projects/SolidGames/replays-parser/docs/architecture.md` |
| 130 | +- Modify (if needed): `/home/afgan0r/Projects/SolidGames/replays-parser/docs/plans/2026-02-15-committed-update-time-design.md` |
| 131 | + |
| 132 | +**Step 1: Write failing verification expectation** |
| 133 | + |
| 134 | +- Define acceptance criteria: |
| 135 | +1. During parsing: `status=parsing`, `update_date` unchanged from previous success |
| 136 | +2. After successful run: `update_date` equals committed run snapshot (`replaysListPreparedAt` captured at run start) |
| 137 | + |
| 138 | +**Step 2: Run verification commands** |
| 139 | + |
| 140 | +Replays parser: |
| 141 | +- `npm run lint` |
| 142 | +- `npm run test` |
| 143 | +- `npm run build-dist` |
| 144 | + |
| 145 | +Server: |
| 146 | +- `npm test` |
| 147 | + |
| 148 | +Expected: all PASS |
| 149 | + |
| 150 | +**Step 3: Update architecture docs** |
| 151 | + |
| 152 | +- Document committed status artifact and fallback chain. |
| 153 | + |
| 154 | +**Step 4: Re-run verification** |
| 155 | + |
| 156 | +Run same commands as step 2. |
| 157 | +Expected: all PASS |
| 158 | + |
| 159 | +**Step 5: Commit** |
| 160 | + |
| 161 | +```bash |
| 162 | +git add docs/architecture.md docs/plans/2026-02-15-committed-update-time-design.md |
| 163 | +git commit -m "docs: describe committed update time semantics" |
| 164 | +``` |
0 commit comments