Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
2026-06-06 — Session Log

sed/mount corruption + full transcript recovery

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:

  • ~45 source files + all notes: exact recovery.
  • pokemonbox.cpp (1781 ln) / pokemonbox.h (455 ln): reconstructed by replaying the captured Edit history + the ::ind.value(::inst()->getIndAt( DB refactor onto af883fd; validated line-for-line vs recent reads (h 12/12 exact, cpp 120/122 — the 2 diffs are pre-edit older reads). These are ~1765-line files lightly edited from af883fd, NOT rewrites.
  • The 7 "clone-based" files (settings.cpp, fontsdb.cpp, area.h, areasign.cpp, areasprites.cpp, pokemonstoragebox.h, storage.cpp): af883fd + replayed Edits + refactor, then read-corrected. Residuals fixed: fontsdb splice()/search()/getStoreAt/getIndAt restored from reads; area.h s13c include-trim restored; settings previewOutdoor accessor + areasign/areasprites mapdbentry.h include restored.
  • Notes comprehensively restored to their fullest recent versions.
  • The Apache-2.0 header / gmail-removal work was re-applied consistently.

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.

Post-recovery build-up — error-by-error to a clean build

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 hangFontsDB::splice lost its out.remove() (reverted s13y replace-not-insert) → infinite loop expanding a variable tile.

Documentation pass started

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).