Files
pokemon/docs/superpowers/specs/2026-08-14-romhack-update-swarm-design.md
T
ginnoirandClaude Opus 5 0e32a01415 docs: add update-swarm design spec and implementation plan
Both documents already back the shipped scripts/update_swarm/ package and
are cited as the canonical spec from the Obsidian vault's ROM Hacks
reference, but they had never been committed — so the repo carried the
implementation without the design it was built from.

- specs/2026-08-14-romhack-update-swarm-design.md — approved design
- plans/2026-08-14-romhack-update-swarm.md — task-by-task implementation plan

Checked for credential-shaped strings before committing; clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-31 03:12:35 -05:00

165 lines
9.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ROM Hack / Fangame Update Swarm
Date: 2026-08-14
Status: design approved in chat; awaiting spec review before implementation plan
Repo: `C:\Users\MattC\Documents\pokemon`
Vault catalog: `Pokémon ROM Hacks/` (~411 notes)
Library: valhalla `/storage1/Emulation/roms/<platform>/` via RomM
## What we decided
- **Shape:** pipeline swarm. Census and scouts run in parallel; one librarian mutates the library; site deploys once per run.
- **Place:** auto-download and place ungated English updates (GitHub, archive.org, MediaFire, public Mega with `#key`). Queue gated hosts (itch, Drive, Discord, Ko-fi, and anything else that needs a human click).
- **Scope:** whole catalog, including Demo Watchlist and Wanted.
- **Watchlist:** auto-place only if the game is now **Complete** and the English build is ungated. Still-demo updates are a report + note bump, not a download.
- **Writeback:** every successful place updates the vault note, archives the superseded file, runs a scoped RomM scan, then one MOC + `catalog.json` + site deploy at the end of the run. Watchlist reports still bump the note even when nothing is placed.
- **Installed version:** read from the files first. Vault `version` is an acceptable fallback. Do not launch games for screenshots.
- **Latest version:** official site → HackDex → PokeCommunity → other. Always the latest **English** build, even when another language is newer (the Z rule).
## Pipeline
```
Census (parallel, local, script)
→ Scouts (parallel, web, LLM agents)
→ Judge (one script, no downloads)
→ Fetchers (parallel, staging only)
→ Librarian (one, serial)
→ Site deploy (once per run)
```
| Role | Job |
|---|---|
| Census | Installed version from files (notes as backup). Notes also supply homepage/source URLs. |
| Scout | Latest English version from the source list. HackDex is anti-bot: browser or skip, never invent a version. |
| Judge | Bucket each stem. English wins over a newer foreign build. |
| Fetcher | Ungated URLs only, into `staging/`. Never writes `roms/`. |
| Librarian | Archive superseded → place → scoped RomM scan → vault patch. |
| Deploy | `build-vault-mocs.py` + `build-wiki-data.py` + site build/deploy once after the librarian finishes. |
Watchlist still-demo: Census + Scout + Judge + note bump. No fetch.
Wanted that stays gated: gated queue. No fetch.
Wanted that is Complete and ungated: same as Update (place it).
## Census — installed version
Do not launch games. Priority:
1. Changelog / readme inside the zip or next to the ROM — the “Current Version” line, not the banner (Infinity’s README lied).
2. `Game.ini` / `mkxp.json` / other packaged metadata.
3. Version tokens in the filename (`[3.3.1]`, `v1.0.4.2`).
4. ROM/header strings when they are actually a version, not just the hack name.
5. Vault `version` field — backup, tagged `source: note`.
6. Unknown — still scout. Compare later by hash if needed.
`Game.exe` (and ROM) hashes confirm a download matches; they are not a version number.
Notes are never the source of truth for *latest available*. That is Scout’s job.
## Scout — latest English
Source order, first hit that names an English build wins:
1. Game’s own website / GitHub releases / project page
2. HackDex (catalog reference; Cloudflare worker is not scrapable — browser or `hackdex: blocked`)
3. PokeCommunity
4. Other (Eevee Expo, PokeHarbor, Romhacking.net, Reddit, …)
Record: latest English version, URL, host (`github` | `archive` | `mediafire` | `mega` | `itch` | `drive` | `discord` | `kofi` | `other`), gate (`ungated` | `gated`), language matrix when EN trails, and which source was used.
Ungated: GitHub release assets, archive.org, MediaFire file pages, Mega public links that include the `#key` fragment (`megadl`). Mega without a key is gated.
## Judge — buckets
| Bucket | When | Action |
|---|---|---|
| Current | Installed English ≥ latest English | No file or note change. No “checked” stamp in v1. |
| Update | Newer English exists, ungated | Fetch → librarian places + full writeback |
| Gated queue | Newer English exists, gated host | Link + version on `gated.md`; no fetch. If it is also now Complete, bump the note status anyway. |
| Watchlist report | Still a demo, newer build exists | Note bump + `watchlist-report.md`; stay on watchlist |
| Watchlist promote | Watchlist item is now Complete **and** English is ungated | Same as Update; remove from Demo Watchlist |
Hard rules:
- Compare versions after stripping `v`/`V` and language tags (`(EN)`, `(ES)`). If they still do not order (dates, “Final”, “Nightly”), the Judge records `incomparable` and the orchestrator decides — never guess a “greater than.”
- Vault says one version, file is another language, site has a newer foreign and an older English → keep/serve **English**. Archive a newer non-English library copy; do not serve it.
- Scout sources disagree → official site, then HackDex, then PokeCommunity, then other. Store the URL used.
- Installed version unknown → skip fetch only if the scout’s English file is byte-identical to disk; otherwise Update.
- Watchlist Complete but gated → Gated queue + note bump, not promote. Promote requires a successful place.
## Run folder
`C:\Users\MattC\Documents\pokemon\.scrape\update-runs\YYYY-MM-DD\` (gitignored with the rest of `.scrape/`).
| Path | Writer |
|---|---|
| `jobs.json` | Orchestrator — one row per catalog stem |
| `census/*.json` | Census script on valhalla |
| `scouts/*.json` | One file per scout wave |
| `verdict.json` | Judge |
| `staging/` | Fetchers |
| `gated.md` | Judge / librarian |
| `watchlist-report.md` | Judge / librarian |
| `log.md` | Librarian + deploy |
Waves:
1. Census script walks every `library_path` on valhalla. Catalog-only stems (no file) skip file steps and use note version (`source: note` or `unknown`).
2. Scout agents in waves of ~12 stems. Each agent receives title, homepage/source URLs, installed version + source tag. Returns the scout record above. No downloads.
3. Judge script fills `verdict.json`.
4. Fetchers pull Update + Watchlist promote ungated URLs into `staging/`.
5. One librarian for the whole batch.
6. One site deploy covering every successful place in the run.
A scout that cannot beat Cloudflare records `hackdex: blocked` and falls through. It does not invent a version.
## Librarian
- Input is `staging/` only.
- Live path keeps the current name (`Pokemon - <Hack> [Hack].<ext>`).
- Old file → `/storage1/igir/romhacks/incoming/_done/_superseded-YYYY-MM-DD/` with the old version in the filename. Never delete.
- PC zips stay vendor-shaped if `launch-pc-hack.ps1` already finds the launcher. Repack only when unplayable (`.rar`, split archives, installer stubs).
- `chmod o+r` after place.
- RomM: always pass `platform_ids`. `roms_ids` alone walks the whole library. QUICK first; HASHES only if `files=0`. Confirm `missing_from_fs=false` and size matches staging.
- Vault: `version`, `release_date`, better `source`/`homepage` if found. Append `## Version history` (language matrix when EN trails). Watchlist promote sets `status: Complete` and removes the stem from Demo Watchlist. Watchlist report bumps `version`/`status` and leaves it listed.
- Site authoring: Summary is prose-only; link labels have no parentheses.
- If `vault_patch` misses a heading on a freshly written note, edit the file on disk.
MOCs, `wiki/catalog.json`, site copy, and deploy happen **once** after the librarian pass, not per game.
## Failures
- Scout blocked/timeout → mark blocked, fall through the source list, no invented version.
- Download hash/size mismatch, or the archive changelog is not the English version we wanted → leave in `staging/`, do not place.
- RomM unhappy → keep superseded + staging, do not patch the note as success.
- Librarian crash → `verdict.json` + `log.md` record `placed` vs `pending`. Resume without re-scouting completed stems.
- Site deploy fail → files + notes may still be right; retry deploy alone.
## First run (smoke)
Not the whole catalog. Orchestrator picks 8–12 stems covering:
- 2–3 library GBA/NDS with a homepage
- 2 PC fangames (one with a changelog in the zip)
- 1 multilingual (Z-class: confirm we keep English)
- 1 watchlist demo (expect report, not place)
- 1 watchlist that might be Complete (promote path)
- 1 gated Wanted (expect queue only)
If `verdict.json` looks sane, continue in waves of ~40.
Z itself is a valid multilingual smoke candidate if we want a known control (already on English v2.13 as of 2026-08-14).
## Out of scope (v1)
- Launching games or capturing in-game version screenshots
- Parallel librarians
- Per-game site deploys
- Auto-placing gated hosts (itch CSRF, Drive, Discord, Ko-fi)
- Deleting superseded builds
- Stamping “last checked” on Current games
- Inventing versions when every source fails (record `unknown` and skip)
## Success
A run is done when `verdict.json` has a bucket for every stem in `jobs.json`, every Update/promote either `placed` or failed-open in `log.md`, `gated.md` and `watchlist-report.md` exist, vault notes match placed files, and (on a full successful librarian pass) the site has been rebuilt once.