|
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
|
What happened: a bulk sed -i rename run over the Cowork mounted filesystem silently truncated 55 source files + 8 notes on the real disk. The mount does partial/truncated writes under load (and also gives false-truncated reads). The damage was real (the Windows compiler saw the truncation), and git HEAD had been committed after the damage, so it was not a usable restore point.
Recovery method (worked): reconstructed every file from prior-session Cowork chat transcripts (APPDATA%\Claude\local-agent-mode-sessions\...\.claude\projects\*.jsonl). Each transcript records every tool call — Read results (full file dumps with line numbers), Write/Edit inputs, and bash commands. Techniques, by fidelity: (1) a full Write or full Read capture = exact; (2) line-number stitching of multiple partial Reads; (3) replaying the captured Edit history onto the af883fd clone base for files only ever edited incrementally; (4) grafting intact disk-head + af883fd tail. Every result was validated against the most recent transcript reads and written/verified with Windows-side PowerShell (the bash mount is unreliable). Full how-to: ../../reference/diagnostic-methods.md → "Recovering files from Cowork chat transcripts".
Final outcome — fully recovered, project intact:
Verified final state: 380 source files, 0 truncated, 0 missing Apache headers, 0 stray name/gmail, 0 INCOMPLETE banners.
HARD RULE: NEVER bulk-edit project files with sed -i / perl -i / shell redirection over the Cowork mount — it silently corrupts files. Use the Read/Edit/Write tools or PowerShell ([System.IO.File]::WriteAllText, UTF8-no-BOM) and verify every write (re-read + brace balance). See ../../decisions/rejected.md.
The recovered tree did NOT build clean — recovery left many residual defects that surfaced only on compile/link/run. Worked through them error-by-error; the project then compiled, linked, ran, AND confirmed runtime parity with the pre-corruption build. Recovery effectively complete.
Key lesson (by design): diagnose against git history, not HEAD — HEAD (2c2d6e5) is the corrupted commit (many files truncated in it); the only clean reference is the 2020 tree (af883fd). Defect classes fixed (all in ../../reference/fix-patterns.md): stray duplicate util/hiddencoinsdb in CMake; dropped #includes (mapdbentry, Qt6 metatype-complete property headers across savefile, pse-db/db.h); dropped private members (gamecornerdb/fontsdb store/ind/buyPrice, mapsearch tail); dropped friends (ItemDBEntry); dropped method bodies (DB::qmlProtect/qmlHook, FontSearch::clear/keepAnyOf, PlayerBasics::getPlayerId/getNonTradeMons/ fixNonTradeMons); truncated/eaten declarations (area.h class line, filemanagement expandRecentFiles); old-API reversions (pokemonbox.cpp Random::/store/getIndAt); protected-field direct access (areasign/areasprites/mapselectmodel → getters); and a runtime hang — FontsDB::splice lost its out.remove() (reverted s13y replace-not-insert) → infinite loop expanding a variable tile.
A project-wide doc-comment effort began alongside the Doxygen setup. The common layer is fully documented + verified (the style reference). Remaining layers (savefile, db, app, qml) are queued and tracked in ../../reference/documentation.md → "Progress"; conventions in the same file. A deliberate multi-session effort (~374 files).