# Recovery progress and where to continue (written 2026-10-05 ~11:50, work stopped at the user's request)

Read `000-reconstruction-plan.md` first (situation, sources, rules). This file says what is DONE and what is NEXT.

## Done

1. **Backups** (do not delete): `~/Documents/milionar-recovery/claude-transcripts.tgz` (Claude transcripts + file-history).
2. **Nightly ZIP restored** (94 files, no-clobber): `scripts/dialog_harness/*` (2026-09-27 state), `scripts/generate_ladder_pill.py`,
   39 texture generators `resources/media/*.py`, ~36 images. List: `docs/plan/recovery/tools/nightly_restored_files.txt`.
3. **Stage 1 (copied into the addon folder, no-clobber, 80 files; list: `~/Documents/milionar-recovery/copied_stage1.txt`)**:
   - from Claude `Write/Edit/Read-full` replay (`~/Documents/milionar-recovery/vfs-claude/`, MANIFEST.tsv): `AGENTS.md` (OLDER version, see below),
     `.agents/skills/*`, `.agents/commands/{deploy,feature}.md` (deploy.md OLDER), `.agents/scripts/tmdb.py`, `docs/plan/*`, `docs/features/013-*`,
     `scripts/dialog_harness/{kodi_live.py (OLDER, lacks window/skin/reload/jsonrpc/mark/log/close), compare_images.py}`,
     `scripts/library_harness/{test_autoplay,test_channels,test_clicks}.py`, `scripts/search_harness/*`, `wcs/devtools/harness_service.py`, `scripts/release.py` (OLDER);
   - from Codex apply_patch replay (`~/Documents/milionar-recovery/vfs-codex/files/`, REPORT.txt): `scripts/build_zip.sh` (LEAN/old version, must be patched),
     `scripts/library_harness/{context_probe,test_appearance,test_asset_paths,test_mark_performance,test_metadata_refresh,test_migration,test_performance_profile,
     test_row_performance,test_skin_cache_performance,test_upgrade,test_vinyl_performance,test_widget_context,vinyl_probe}.py`,
     `scripts/skin_harness/{test_installer_performance,test_refresh_hooks,test_refresh_service,test_release_textures}.py`, `docs/audits/2026-10-04-widget-performance.md`,
     `docs/plan/skin-milionar/{160-vinyl,170-context-manager}.md`, `resources/media/generate_skin_logo.py`.
   These are BASE versions: later changes made with Bash `python3 - <<EOF` patch scripts / `cat > file <<EOF` / `sed -i` are NOT in them.
4. **Tools written** (all in `docs/plan/recovery/tools/`): `replay_claude_transcripts.py` (Write/Edit/Read replay -> pickle),
   `replay_codex_sessions.py` (apply_patch + heredoc replay -> `OUT/files`, `OUT/REPORT.txt`), `replay_bash_patches.py` (see 5).
   Work copies: `~/Documents/milionar-recovery/work/` (`bash.json` = all 1928 Bash commands of all Claude sessions with timestamp, session and result;
   `base_ts.json` = last structured-event timestamp per path; `release_files.txt` = 448 runtime files of the 2.1.26 release = authoritative, never recover those).
5. **Bash-patch replay (first full run finished, result was thrown away with the scratch dir state, re-run needed)**: `replay_bash_patches.py N START_INDEX`
   executes, in time order, the python heredocs / `cat > f <<EOF` / `sed -i` of the Claude Bash commands inside a SANDBOX copy of the addon folder
   (`$N/sbx`), reverts runtime files after every command and reverts dev files whose structured snapshot is newer than the command. It needs `$N` with
   `bash.json`, `base_ts.json`, `release_files.txt` (copy them from `work/` to a scratch dir and adjust the `N` path argument; it takes about 25 min, run it in the
   background). The v3 script tracks `cd` inside a command (earlier run put files like `do.md`, `rules/*.md`, `stubs.py` in the wrong folder). Its output file is only
   written at the end. WARNING: it executes shell `sed` lines: it must never run `kodi_live.py`, `ssh`, anything touching `userdata` (it did once leave
   `harness/ENABLED` and `harness/request.json` in addon_data; they were deleted).
   Result of the first run (before cwd fix): it recreated, from heredocs, these dev files (use them, but check paths): `.gitignore`, `scripts/skin_harness/{gen_slots,
   gen_start,baseline,deploy_check,test_startrows,test_warm}.py`, `screens.json`, `scripts/library_harness/{stubs,make_fixtures,make_media,live,test_library,test_rules,
   test_menu,test_next_up,test_listings,test_rows,test_slots}.py`, `.agents/commands/{do,explain,quiet,reload,snap,test-game,test-tmdb}.md`, `.agents/rules/{ai-code,
   kodi-python,kodi-xml}.md`, `docs/features/012-skin-milionar.md`, `repository/repository.milionar/addon.xml`, `resources/skins/Default/1080i/devtools/Harness*.xml`,
   `wcs/library2/{dev_list,fixture_provider}.py`, and patched most of the "MODIFIED" files in section 6. These are only in the sandbox (scratch, volatile `/private/tmp`),
   NOT yet in the addon folder: re-run the script to get them again.

## NOT done / next steps (in this order)

1. Re-run `replay_bash_patches.py` (cwd-aware v3) in the background; then diff the sandbox against the addon folder and copy ONLY dev files (not in
   `release_files.txt`) with `rsync --ignore-existing` for new files and a reviewed copy for modified ones. Skip junk paths (`$D/..`, `$S/..`, `$M/..`).
2. Final-text sources that are only in this conversation, not in transcripts of earlier sessions: the CURRENT `AGENTS.md` (the version in the 2026-10-04 session start
   reminder is newer than the recovered one: it has the 2560x1440 GUI line, "Open, check and test only what the plan covers..." rule, `/deploy`-only rule, the question-tool
   rule); it is also in the first lines of the transcript of session `be4b352a-...` and `7c93f65a-...` (search the jsonl for `# Milionář — Kodi addon`).
   Same for `.agents/rules/kodi-python.md` (also shown in that transcript). Use the latest occurrence.
3. Files still missing a good base (see `vfs-codex/REPORT.txt` FAILED lines): `scripts/skin_harness/gen_slots.py` (rebuild from the generated
   `Includes_MilionarSlots.xml` + section 5 of `000-reconstruction-plan.md`), `scripts/library_harness/{test_menu,test_slots,stubs,test_library,test_clicks}.py`
   (bases appear in Bash `cat` outputs in `work/bash.json`: search `res` fields), the newer `kodi_live.py` (commands window/skin/reload/jsonrpc/mark/log/close were added by Claude
   Bash patches in session `380f354f` on 2026-09-30; replay them on top of the Sep-29 Write), `wcs/devtools/harness_service.py` (check it answers those requests),
   `.agents/rules/*`, `.agents/tests/*`, `.agents/state/skin_deploy.json`, `scripts/skin_harness/{baseline,deploy_check,screens.json}`, `docs/` files listed in `000-index.md`.
4. Recompose `scripts/build_zip.sh` to the FAITHFUL version (spec in section 5.1 of the plan; the Codex base is the old lean one; the faithful steps were python
   patches in session `7c93f65a`, timestamps 2026-10-04 16:00-18:40), `scripts/release.py` (older Write + fixes: see plan 5.4), `.agents/commands/deploy.md` (final text:
   session `7c93f65a`, 2026-10-04 18:29 `cat > ... deploy.md` + later python edits), `docs/plan/skin-milionar/060-widgets.md` sections 7-9, `gen_start.py`, `test_warm.py`,
   `test_startrows.py`, `repository/repository.milionar/{addon.xml,icon.png}` (icon = 256 px copy of `resources/media/brand/milionar-mark.png`).
5. Verify (plan section 6): py_compile/xmllint everything; regenerate `Includes_MilionarSlots.xml` and `Includes_MilionarStart.xml` byte-identically; run the offline tests;
   `python3 scripts/release.py build` must give ~5 MB / 440 files equal to `repo/plugin.video.milionar/plugin.video.milionar-2.1.26.zip` on the hosting (compare file lists).
6. `ln -s .agents .claude`; `git init` + commit; backup (plan section 8). Do not recreate the `addons/skin.milionar` symlink in this Kodi (the installed skin is a real copy now).

## State of the machine (2026-10-05)

- Kodi (macOS) runs the installed release 2.1.26 with the real skin copy (symlink removed, skin 1.3.17 installed by the service). Free disk about 1.7 GB.
- Scratch dir of the stopped session (volatile): `/private/tmp/claude-501/-Users-chudy-Library-Application-Support-Kodi-addons-plugin-video-milionar/be4b352a-e88d-4532-b688-0769ac50507f/scratchpad/`
  (`sbx/` sandbox, `bash.json`, `vfs2.pkl`, `replay_out*.txt`). Everything needed is copied to `~/Documents/milionar-recovery/work/`.
- Nothing in the addon folder was overwritten: only missing files were added (rsync --ignore-existing / copy of non-existing paths).

## Update 2026-10-05 ~12:25 (session 8c56dc7f)

- `AGENTS.md` replaced by the NEWER text (2560x1440 line, "Open, check and test only what the plan covers", from session `7c93f65a` attachment, 2026-10-04 16:03). Step 2 first half DONE.
- Bash-patch replay re-run finished (sandbox `scratchpad/sbx`, its stdout stats file was empty). Applied to the addon folder:
  36 NEW dev files (`.gitignore`, `.agents/commands/{do,explain,quiet,reload,snap,test-game,test-tmdb}.md`, `.agents/rules/{ai-code,kodi-python,kodi-xml}.md`,
  `docs/features/012-skin-milionar.md`, `repository/repository.milionar/addon.xml`, devtools `Harness*.xml`, `scripts/library_harness/{live,make_fixtures,make_media,stubs,
  test_library,test_listings,test_menu,test_next_up,test_rows,test_rules,test_slots}.py`, `scripts/skin_harness/{baseline,deploy_check,gen_slots}.py`, `screens.json`,
  `wcs/library2/{dev_list,fixture_provider}.py`) and 36 patched files (docs/plan, skills, kodi_live.py, harness_service.py, search_harness, test_*). Pre-merge originals of the
  patched files: `~/Documents/milionar-recovery/pre-bash-merge/`. All .py/.xml compile/lint clean.
- NOT applied (manual, plan step 4): `scripts/build_zip.sh`, `scripts/release.py`, `.agents/commands/deploy.md`, `resources/media/generate_skin_logo.py`.
- Still missing from this replay: `gen_start.py`, `test_warm.py`, `test_startrows.py` (not produced by the run), `.agents/tests/*`, `.agents/state/skin_deploy.json`, `ln -s .agents .claude`.
- NEXT: step 3 leftovers (gen_start/test_warm/test_startrows from bash.json `cat` outputs), step 4 (build_zip.sh/release.py/deploy.md), step 5 verification, step 6 git init.

## Update 2026-10-05 ~13:00: step 4 DONE (release pipeline)

- `scripts/build_zip.sh` recomposed (faithful variant, shell-escape damage from the Codex replay removed): the build gives 448 files / 4.97 MB, file list
  identical to the 2.1.26 release and every file byte-identical to the release copies in this folder (`resources/skin.milionar/addon.xml` included, icon `../plugin.video.milionar/...`).
  Lean original kept in `~/Documents/milionar-recovery/pre-bash-merge/build_zip.lean.sh`. PNG recompression/logo shrinking are NOT in the script (the tree images already equal the release).
- `scripts/release.py publish` now: build -> secret scan -> version-order check -> repo upload (rsync -rt, relative remote mv) -> record -> upload of the WHOLE dev tree to
  `kodi/dev/current` (previous -> `dev/previous`, `DEPLOY.json`) -> prune: only current + previous of every versioned ZIP. Tested end to end against a local fake host
  (3 consecutive releases: dev/{current,previous}, 2 ZIPs kept). The real hosting was NOT touched. `repository/repository.milionar/icon.png` created (256 px).
- `.agents/commands/deploy.md` rewritten (one command, no nightly ZIPs). `ln -s .agents .claude` done.
- Still open: `gen_start.py`, `test_warm.py`, `test_startrows.py`, `.agents/tests/*`, `.agents/state/skin_deploy.json` (`deploy_check.py record` writes it after the first publish),
  `060-widgets.md` sections 7-9, step 5 verification of the generators, step 6 `git init`.

## Update 2026-10-05 ~14:30: recovery finished (session 8c56dc7f)

- New tool `tools/replay_all.py`: ONE time-ordered replay of every recorded operation (Claude Write/Edit/Read-full + Bash python/cat/sed heredocs,
  Codex apply_patch + exec_command heredocs). Replayed code runs under `sandbox-exec` (no network, writes only in the sandbox dir).
  Needs a work dir with `bash.json`, `release_files.txt`, `sbx/` (release files + nightly files). ~12 min. Its result (n7) was merged into the addon;
  pre-merge copies: `~/Documents/milionar-recovery/pre-n7-merge/` (+ `pre-bash-merge/`).
- Tests that had to be adapted by hand to the runtime (the last test edits were not recorded): `test_rules.py` (versioned `set_mirrored`, mirror RPC
  runs in `jobs.process_mirrors`, schema 3), `test_channels.py` (`load_channel_history`, cached show meta), `test_clicks.py` (duplicate stale test
  removed), `stubs.py` (`xbmcvfs` file functions). `gen_slots.py` rewritten from the generated XML (byte-identical), `gen_start.py` identical.
- Offline tests: all green except `skin_harness/test_release_textures.py` and `library_harness/test_asset_paths.py` (they test the abandoned "lean"
  native-texture packaging; the faithful release ships everything unchanged). `.agents/tests/test_millionaire_game.py` comes from
  `~/Documents/Projector/Projects/milionar/docs/original/.agent/tests/` + the 2 recorded patches.
- Release: `build_zip.sh` reproduces 2.1.26 (448 files, byte-identical); `release.py publish` auto-bumps the patch version, uploads the repo and the whole
  tree to `kodi/dev/current` (+ `dev/previous`), prunes to current + previous. Tested only against a fake local host. NEVER delete anything else on the hosting.
- `git init` done, first commit `efdea3c` (local only, no remote); backup bundle `~/Documents/milionar-recovery/milionar-2026-10-05.bundle`.
- Not recoverable: skin store art (`resources/skin.milionar/resources/{fanart,screenshot-*}`), loose Estuary textures in `resources/skin.milionar/media/`,
  `fonts/*.ttf`, `extras/*.jpg` (plan section 7). `.agents/state/skin_deploy.json` is created by the first `publish`.
