{
  "notes": "EPISODE 2: Recovery from a refused submission, not a retry of landed work. Authoritative goal.json has trunk=null, batches=[], handed=[], effects.pending=0, items.used=0 of 50, no requester notes and no children. Episode 1's statement that 25 items were used is wrong: spawn usaciv-targets-1 was refused because its brief asked about the worker's machine. All its reads and wake then failed because no batch existed. The exact rejected brief was not handed over, so its offending phrase cannot be identified. No old batch is running to cancel. This episode's briefs concern only assigned project files, feature implementation and target checks. No machine inspection is requested.\n\nSOURCE: In this episode fetched the public source archive into memory with curl and verified SHA-256 52b3b2c3cf189b8ceff2376c48188db7ec88634d6a0f73ae254077ed50306314; 8,008,568 archive bytes, 189 files under usaciv/. No project was imported or implemented in the orchestrator workspace. Three import checks compare sorted path + NUL + content + NUL fingerprints against the verified archive. docs: 6 files, web: 102, rest: 80 plus tests/test_builders.py. The rest fingerprint excludes only tests/test_builders.py for the planned fix; the import brief still requires exact copying/comparing ALL 81 rest files. Imports download only the pinned original source; all later dataset fetching belongs to rebuild.\n\nDECISION: Submit ONE new code target batch usaciv-targets-2, attempts=3, 25 targets, no minutes, no after staging, no machine requirements. If accepted this reserves 25/50 items before any worker splits; read actual budget next episode. Read all 25 target results and wake only when the batch settles, with no timed wake. finish=false. This submits work; it does not claim that spawn or any target has already succeeded.\n\nGRAPH (all scopes in the submitted decisions are full repository paths; overlapping scopes ordered transitively): imp-docs, imp-web, imp-rest; fix-tests needs imp-rest; doc needs all imports and fix-tests. regions needs doc; insets needs regions; etopo/natural-earth/nlcd need doc; ak-fixes needs insets; cities needs regions; world needs insets, etopo, natural-earth, nlcd; rebuild needs all eight map targets. g-seams needs doc; g-config needs g-seams; g-tiles and g-cities need g-config; g-units needs both; g-turn needs g-units; g-layer needs g-units; g-hud needs g-turn; g-docs needs g-hud. Every game target also needs doc. ui needs rebuild and g-seams (insets is transitive). export needs ui, g-docs, g-layer and imp-rest. Default check is python3 -m unittest discover -s tests. Imports use pinned-content checks; doc adds test -s; rebuild uses python3 -m pipeline check; game uses node --test web/js/ext/game/test/<key>.test.js; ui syntax-checks every non-game JS file; export uses test -f dist/index.html.\n\nWHY fix-tests: Episode 1 reported the original PlanningTest.test_staleness repeatedly failing with [b,c,cat] instead of [cat], caused by equal fixture mtimes and production is_stale >= semantics. This episode did not rerun the project tests. The target must reproduce if present and make the fixture timestamps deterministic without sleeps, skipped assertions or production changes, then run the suite. This prevents a known default-check blocker.\n\nCONTRACTS TO KEEP: One region/off-map definition: lower 48+DC, AK 02, HI 15, PR 72 on; GU 66, VI 78, AS 60, MP 69 off. MapProjection public methods/callers remain; old lower-48 coordinates unchanged; true-scale Albers per region; AK positive longitude -> lon-360; insets right/bottom, serialized min_x/max_y/margin plus inset transforms, JS mirror in terrain.js. World writes projection to interim _world and public world.json, appends new state/county IDs, preserves old centres/owners, clips sources by region. Source lower-48 URLs/filenames/keys remain. NLCD AK 2016, HI/PR 2001, each its own CRS; PRI/VIR classified US, VIR off-map. FEMA AK crosswalk feeds disasters; eastern AK mine longitudes retained. ACS AK/HI/PR metros retained and snapped within first-listed state; DC sole capital. landBox/fitScale keep lower-48 meaning.\n\nGAME: Always-on extension, preserve #turn/keys/exports. game/index.js exports install(app), constructs documented shared state/subscription/command interfaces and loads optional layer.js/hud.js/docs.js exporting install(app,game). g-seams documents these in state.js JSDoc and game/README.md so later targets do not need out-of-scope integration edits. ui/pedia.js exports addPage(title,render); app/help.js exports addSection(title,rows). Pure rule modules use seeded RNG in state, no DOM/Math.random, fixture tests without web/data. Real food/production/gold/science/culture times constants; null contributes zero but stays flagged. Player owns cities listing selected state first; passive rivals. Food growth, production districts/wonders/scouts/armies, capture strictly weaker cities. Win with largest cities in ten states, science target, or top score by turn 100. All invented constants live in rules/config.js or RULES. HUD imports its stylesheet, connects pure rules, and versions saves. Docs render actual constants.\n\nNEXT EPISODE 3: Read actual trunk/board/results/refusals, not assumptions in prior notes. If spawn was refused, fix the specific reason and explicitly resubmit under a new name: there are no itemsFrom targets for a nonexistent batch. Otherwise re-send only stuck targets plus unlanded dependents in one new target batch, dropping needs already landed and keeping overlap ordering. Use failure evidence to narrow/split hard targets, especially world/rebuild/ui. Never re-import over landed feature changes; use presence checks if an import must recover on a changed tree. Check remaining item budget including splits; reserve at least ONE item for episode 4 if export is unlanded, so at most remaining-1 items for episode 3 in that case. A 403 needs a curl retry; a failed dataset leaves documented null/flagged gaps, not fabricated coverage. Syntax checks alone do not prove visual behavior: read ui/layer/HUD reports. JS module test runtime failures are execution limitations to report, not a reason to invent test success.\n\nEPISODE 4: If export is unlanded, submit export ALONE, no needs, scope dist/** and .gitignore, test -f dist/index.html, so whatever web/ actually landed ships. EPISODE 5 at latest: finish honestly. Final write-up must use the actual trunk URL+commit from goal.json, list landed targets and stuck targets with reasons, distinguish unverified behavior, mention the test-fixture repair, and explain running python3 -m pipeline serve (http://127.0.0.1:8765), or python3 -m http.server in dist/, plus unittest, pipeline check and pipeline all commands. No trunk URL/commit currently exists; none was fabricated. Partial is explicitly allowed; never claim missing data, checks, source features or deployments are complete.",
  "spawn": [
    {
      "name": "usaciv-targets-2",
      "mode": "code",
      "targets": {
        "attempts": 3
      },
      "brief": "Implement exactly target {{name}} for usaciv (MIT, Andrej Karpathy): docs, Alaska/Hawaii/Puerto Rico, and an always-on turn-based extension.\nContext: {{context}}\nWork: {{task}}\nAllowed changes: {{paths}}. Scratch only in .cache/.\nInputs: {{inputs}}\nAcceptance command from repository root: {{check}}\nUse python3, not uv. No npm, frameworks or packages. Preserve #turn, existing keys and exports. GU/VI/AS/MP stay off-map. Missing values stay null and flagged; never invent source data. Invented game constants go in rules/config.js or RULES.\nYour result must contain: target key; changed paths; checks with exit status and concise relevant failures; unresolved, null or flagged data; interface notes needed by dependents. Report this target's implementation and validation.",
      "items": [
        {
          "key": "imp-docs",
          "vars": {
            "name": "imp-docs",
            "context": "Bootstrap the documentation from the pinned original before any documentation changes. This is one exact-copy target.",
            "task": "Copy all files under usaciv/docs/ to docs/, byte for byte, including images. Preserve MIT attribution. Compare every copied file with the verified archive; report checksum, file count and comparison result. Do not write ARCHITECTURE.md yet.",
            "paths": "docs/**",
            "inputs": "Fetch https://karpathy.ai/usaciv/usaciv-source.zip; require SHA-256 52b3b2c3cf189b8ceff2376c48188db7ec88634d6a0f73ae254077ed50306314; unzip under .cache/ and copy from usaciv/. This pinned source import is separate from rebuild data downloads.",
            "check": "python3 -c 'from pathlib import Path as P;from hashlib import sha256 as H;f=sorted([p for d in [\"docs\"] for p in P(d).rglob(\"*\") if p.is_file() and \"__pycache__\" not in p.parts and p.name!=\"test_builders.py\"],key=str);assert H(b\"\".join(str(p).encode()+b\"\\0\"+p.read_bytes()+b\"\\0\" for p in f)).hexdigest()==\"4df0f40f0fc446db21cafee89c2493c355d1bf27ac1af1c99104432e0e36aec9\"'"
          },
          "scope": [
            "docs/**"
          ],
          "needs": [],
          "check": "python3 -c 'from pathlib import Path as P;from hashlib import sha256 as H;f=sorted([p for d in [\"docs\"] for p in P(d).rglob(\"*\") if p.is_file() and \"__pycache__\" not in p.parts and p.name!=\"test_builders.py\"],key=str);assert H(b\"\".join(str(p).encode()+b\"\\0\"+p.read_bytes()+b\"\\0\" for p in f)).hexdigest()==\"4df0f40f0fc446db21cafee89c2493c355d1bf27ac1af1c99104432e0e36aec9\"'"
        },
        {
          "key": "imp-web",
          "vars": {
            "name": "imp-web",
            "context": "Bootstrap the original web application and shipped data before any map or gameplay changes. This is one exact-copy target.",
            "task": "Copy all files under usaciv/web/ to web/, byte for byte, including data and dev assets. Compare every copied file with the verified archive; report checksum, file count and comparison result. Do not implement new features in this target.",
            "paths": "web/**",
            "inputs": "Fetch https://karpathy.ai/usaciv/usaciv-source.zip; require SHA-256 52b3b2c3cf189b8ceff2376c48188db7ec88634d6a0f73ae254077ed50306314; unzip under .cache/ and copy from usaciv/. This pinned source import is separate from rebuild data downloads.",
            "check": "python3 -c 'from pathlib import Path as P;from hashlib import sha256 as H;f=sorted([p for d in [\"web\"] for p in P(d).rglob(\"*\") if p.is_file() and \"__pycache__\" not in p.parts and p.name!=\"test_builders.py\"],key=str);assert H(b\"\".join(str(p).encode()+b\"\\0\"+p.read_bytes()+b\"\\0\" for p in f)).hexdigest()==\"2f3e28235cafe56f835bb9593080fc588afd3fe7000069b4f276ddeae4cf0ee4\"'"
          },
          "scope": [
            "web/**"
          ],
          "needs": [],
          "check": "python3 -c 'from pathlib import Path as P;from hashlib import sha256 as H;f=sorted([p for d in [\"web\"] for p in P(d).rglob(\"*\") if p.is_file() and \"__pycache__\" not in p.parts and p.name!=\"test_builders.py\"],key=str);assert H(b\"\".join(str(p).encode()+b\"\\0\"+p.read_bytes()+b\"\\0\" for p in f)).hexdigest()==\"2f3e28235cafe56f835bb9593080fc588afd3fe7000069b4f276ddeae4cf0ee4\"'"
        },
        {
          "key": "imp-rest",
          "vars": {
            "name": "imp-rest",
            "context": "Bootstrap the original root files, pipeline and tests. The later fix-tests target owns the timestamp-test repair.",
            "task": "Copy the assigned root files and complete pipeline/ and tests/ trees from usaciv/, byte for byte. Compare EVERY copied file, including tests/test_builders.py, with the verified archive. The acceptance fingerprint omits that one test file to allow its subsequent deterministic repair; it must still be imported unchanged. Report checksum, file count and comparison result.",
            "paths": "README.md, LICENSE, pyproject.toml, uv.lock, .gitignore, pipeline/**, tests/**",
            "inputs": "Fetch https://karpathy.ai/usaciv/usaciv-source.zip; require SHA-256 52b3b2c3cf189b8ceff2376c48188db7ec88634d6a0f73ae254077ed50306314; unzip under .cache/ and copy from usaciv/. This pinned source import is separate from rebuild data downloads.",
            "check": "python3 -c 'from pathlib import Path as P;from hashlib import sha256 as H;f=sorted([p for d in [\"pipeline\",\"tests\"] for p in P(d).rglob(\"*\") if p.is_file() and \"__pycache__\" not in p.parts and p.name!=\"test_builders.py\"]+[P(p) for p in \"README.md LICENSE pyproject.toml uv.lock .gitignore\".split()],key=str);assert H(b\"\".join(str(p).encode()+b\"\\0\"+p.read_bytes()+b\"\\0\" for p in f)).hexdigest()==\"0972c971de5e71e4822ad76b6882b2a2cb4944ad521478c5eac637c018e28e9d\"'"
          },
          "scope": [
            "README.md",
            "LICENSE",
            "pyproject.toml",
            "uv.lock",
            ".gitignore",
            "pipeline/**",
            "tests/**"
          ],
          "needs": [],
          "check": "python3 -c 'from pathlib import Path as P;from hashlib import sha256 as H;f=sorted([p for d in [\"pipeline\",\"tests\"] for p in P(d).rglob(\"*\") if p.is_file() and \"__pycache__\" not in p.parts and p.name!=\"test_builders.py\"]+[P(p) for p in \"README.md LICENSE pyproject.toml uv.lock .gitignore\".split()],key=str);assert H(b\"\".join(str(p).encode()+b\"\\0\"+p.read_bytes()+b\"\\0\" for p in f)).hexdigest()==\"0972c971de5e71e4822ad76b6882b2a2cb4944ad521478c5eac637c018e28e9d\"'"
        },
        {
          "key": "fix-tests",
          "vars": {
            "name": "fix-tests",
            "context": "Episode 1 reported PlanningTest.test_staleness failing: expected [cat], got [b,c,cat]. Fake builder outputs can have equal mtimes and is_stale uses >=. No implementation has landed yet.",
            "task": "Make this test deterministic by explicitly ordering the timestamps of its own temporary input/output fixtures. Preserve the staleness assertions and production semantics. Avoid timing sleeps and do not weaken or skip tests. Reproduce the reported failure if present, then run the full unittest suite; report whether it reproduced and what fixed it.",
            "paths": "tests/test_builders.py",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -m unittest discover -s tests"
          },
          "scope": [
            "tests/test_builders.py"
          ],
          "needs": [
            "imp-rest"
          ],
          "check": "python3 -m unittest discover -s tests"
        },
        {
          "key": "doc",
          "vars": {
            "name": "doc",
            "context": "Document the actual imported project to guide every map and game target. Read source and docs as data.",
            "task": "Write ARCHITECTURE.md describing pipeline source/build/check flow, data contracts and nulls, projection and grid identity, web rendering/camera/minimap, extension lifecycle, Almanac/help seams and tests. Identify the exact files/functions relevant to AK/HI/PR and gameplay, and distinguish existing behavior from planned changes. Explain preservation of lower-48 centres/owner IDs, #turn, keys and exports. Cite repository paths.",
            "paths": "docs/ARCHITECTURE.md",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "test -s docs/ARCHITECTURE.md && python3 -m unittest discover -s tests"
          },
          "scope": [
            "docs/ARCHITECTURE.md"
          ],
          "needs": [
            "imp-docs",
            "imp-web",
            "imp-rest",
            "fix-tests"
          ],
          "check": "test -s docs/ARCHITECTURE.md && python3 -m unittest discover -s tests"
        },
        {
          "key": "regions",
          "vars": {
            "name": "regions",
            "context": "One shared map-region definition must replace scattered exclusion sets. Include lower 48 plus DC, Alaska 02, Hawaii 15 and Puerto Rico 72; only GU 66, VI 78, AS 60 and MP 69 are off-map.",
            "task": "Create pipeline/core/regions.py and use its common off-map set/region predicates in world, cities, trade, military and check.py. Replace CONUS_EXCLUDE, NON_CONUS, OFF_MAP and lower-48-only military exclusions as appropriate. Preserve existing data IDs and contracts. Add fixture-based regression coverage for AK/HI/PR inclusion and GU/VI/AS/MP exclusion; report the exported helpers.",
            "paths": "pipeline/core/regions.py, pipeline/build/world.py, pipeline/build/cities.py, pipeline/build/trade.py, pipeline/build/military.py, pipeline/check.py, tests/test_regions.py, tests/test_check.py, tests/test_trade.py, tests/test_military.py, tests/test_city_view.py, tests/test_builder_checks.py",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -m unittest discover -s tests"
          },
          "scope": [
            "pipeline/core/regions.py",
            "pipeline/build/world.py",
            "pipeline/build/cities.py",
            "pipeline/build/trade.py",
            "pipeline/build/military.py",
            "pipeline/check.py",
            "tests/test_regions.py",
            "tests/test_check.py",
            "tests/test_trade.py",
            "tests/test_military.py",
            "tests/test_city_view.py",
            "tests/test_builder_checks.py"
          ],
          "needs": [
            "doc"
          ],
          "check": "python3 -m unittest discover -s tests"
        },
        {
          "key": "insets",
          "vars": {
            "name": "insets",
            "context": "MapProjection remains the public API: proj(lon,lat), inverse, to_dict and MapProjection(**world[\"projection\"]). Existing lower-48 projection remains unchanged. JS has ALBERS/SHIPPED_PROJ in terrain.js.",
            "task": "Make MapProjection composite with true-scale Albers per region: lower 48, AK, HI, PR. Place new regions right/below the original rectangle at the same physical scale. Normalize AK longitude >0 by subtracting 360. Preserve callers, min_x/max_y/margin and old serialized inputs; add serializable inset transforms/bounds and inverse dispatch. Mirror transforms in terrain.js. Test regional round trips, positive-longitude AK and unchanged lower-48 coordinates; describe the serialization schema.",
            "paths": "pipeline/core/geo.py, pipeline/core/regions.py, web/js/render/art/terrain.js, tests/test_insets.py",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -m unittest discover -s tests"
          },
          "scope": [
            "pipeline/core/geo.py",
            "pipeline/core/regions.py",
            "web/js/render/art/terrain.js",
            "tests/test_insets.py"
          ],
          "needs": [
            "regions"
          ],
          "check": "python3 -m unittest discover -s tests"
        },
        {
          "key": "etopo",
          "vars": {
            "name": "etopo",
            "context": "Extend the existing elevation source to AK/HI/PR while keeping its lower-48 URL, window, filename, keys and interpretation unchanged.",
            "task": "Add separate region-tagged ETOPO coverage/windows for AK, HI and PR, including Alaska across the longitude wrap, with explicit clipping metadata usable by world. Preserve lower-48 behavior. Test source selection, bounds and missing-data handling with offline fixtures. Implement fetching logic only; rebuild performs downloads. Report the regional artifact/schema contract.",
            "paths": "pipeline/sources/etopo.py, tests/test_etopo.py",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -m unittest discover -s tests"
          },
          "scope": [
            "pipeline/sources/etopo.py",
            "tests/test_etopo.py"
          ],
          "needs": [
            "doc"
          ],
          "check": "python3 -m unittest discover -s tests"
        },
        {
          "key": "natural-earth",
          "vars": {
            "name": "natural-earth",
            "context": "Extend Natural Earth coast/land/neighbor inputs to AK/HI/PR. PRI and VIR are US, never foreign; VIR still remains off-map.",
            "task": "Produce region-tagged/clipped Natural Earth inputs for lower 48, AK, HI and PR without changing lower-48 URLs, filenames or keys. Correct country classification for PRI and VIR and preserve the off-map distinction. Cover the dateline and empty/missing features with offline fixtures. Implement download logic without fetching data. Report the keys, bounds and artifact contract for world.",
            "paths": "pipeline/sources/natural_earth.py, tests/test_natural_earth.py",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -m unittest discover -s tests"
          },
          "scope": [
            "pipeline/sources/natural_earth.py",
            "tests/test_natural_earth.py"
          ],
          "needs": [
            "doc"
          ],
          "check": "python3 -m unittest discover -s tests"
        },
        {
          "key": "nlcd",
          "vars": {
            "name": "nlcd",
            "context": "NLCD must use Alaska 2016, Hawaii 2001 and Puerto Rico 2001. Each raster has its own CRS; existing lower-48 source selection stays unchanged.",
            "task": "Implement region-tagged NLCD sources for these exact years. Use each raster's actual CRS/transform when sampling and clipping; never assume the lower-48 CRS for an inset. Preserve lower-48 URLs, filenames and keys. Leave unavailable coverage null and flagged. Test per-region selection, CRS handling and nodata with local fixtures. Add fetch logic only; rebuild downloads. Report source selections and schema.",
            "paths": "pipeline/sources/nlcd.py, tests/test_nlcd.py",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -m unittest discover -s tests"
          },
          "scope": [
            "pipeline/sources/nlcd.py",
            "tests/test_nlcd.py"
          ],
          "needs": [
            "doc"
          ],
          "check": "python3 -m unittest discover -s tests"
        },
        {
          "key": "ak-fixes",
          "vars": {
            "name": "ak-fixes",
            "context": "Alaska borough/census-area changes require a documented FEMA code crosswalk, used like the existing Connecticut mapping. Eastern-longitude Alaska mines are valid.",
            "task": "Implement pipeline/core/ak_fema.py and consume its crosswalk in build/disasters.py, preserving totals and flagging ambiguous/unmapped records. Make msha_mines accept real positive eastern longitudes for Alaska, including 172..180, without inventing coordinates or corrupting other states. Use committed evidence/fixtures; unresolved mappings stay flagged. Test split/renamed areas, aggregation and longitude normalization with offline fixtures.",
            "paths": "pipeline/build/disasters.py, pipeline/sources/openfema.py, pipeline/sources/msha_mines.py, pipeline/core/ak_fema.py, tests/test_ak_fixes.py, tests/test_county_lenses.py",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -m unittest discover -s tests"
          },
          "scope": [
            "pipeline/build/disasters.py",
            "pipeline/sources/openfema.py",
            "pipeline/sources/msha_mines.py",
            "pipeline/core/ak_fema.py",
            "tests/test_ak_fixes.py",
            "tests/test_county_lenses.py"
          ],
          "needs": [
            "insets"
          ],
          "check": "python3 -m unittest discover -s tests"
        },
        {
          "key": "cities",
          "vars": {
            "name": "cities",
            "context": "ACS metros in AK, HI and PR must survive selection. A city's first listed state determines ownership and its own-state snapping. DC remains the sole national capital.",
            "task": "Keep AK/HI/PR ACS metro rows and snap each to a valid hex belonging to its own first-listed state, never to a nearby unrelated region. Keep unavailable values null and flagged and handle no eligible hex explicitly. Preserve lower-48 identifiers/yields. Ensure DC alone has national-capital status. Add offline tests for all three regions, multi-state metros, own-state snap and DC.",
            "paths": "pipeline/build/cities.py, tests/test_cities.py, tests/test_city_view.py",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -m unittest discover -s tests"
          },
          "scope": [
            "pipeline/build/cities.py",
            "tests/test_cities.py",
            "tests/test_city_view.py"
          ],
          "needs": [
            "regions"
          ],
          "check": "python3 -m unittest discover -s tests"
        },
        {
          "key": "world",
          "vars": {
            "name": "world",
            "context": "Combine the regional source contracts and composite projection. Original lower-48 cells must keep their centres and owner IDs. New states/counties append after existing ones, and the grid grows only right/down.",
            "task": "Build inset cells and region-clipped coast/elevation/land-cover inputs without cross-region contamination. Preserve original lower-48 hex centres, indexing/ownership and all existing IDs, even when grid dimensions expand. Append AK/HI/PR state/county IDs deterministically. Write the complete projection to both interim _world and public web/data/world.json through the builder. Extend checks/tests for projection round trips, lower-48 identity, region ownership, new-state ordering and nulls; no downloads.",
            "paths": "pipeline/build/world.py, pipeline/check.py, tests/test_world.py, tests/test_gdp_fill.py, tests/test_check.py",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -m unittest discover -s tests"
          },
          "scope": [
            "pipeline/build/world.py",
            "pipeline/check.py",
            "tests/test_world.py",
            "tests/test_gdp_fill.py",
            "tests/test_check.py"
          ],
          "needs": [
            "insets",
            "etopo",
            "natural-earth",
            "nlcd"
          ],
          "check": "python3 -m unittest discover -s tests"
        },
        {
          "key": "rebuild",
          "vars": {
            "name": "rebuild",
            "context": "All map implementations are prerequisites. This is the only target that fetches pipeline datasets. Keep the committed original dataset available as a fallback for sources that fail.",
            "task": "Run python3 -m pipeline all, repair scoped pipeline/test integration as needed, then python3 -m pipeline check. Commit rebuilt web/data and docs/REBUILD.md. Verify lower-48 identity plus AK/HI/PR coverage and projection metadata. Document commands, source URLs/years, retrieval failures and resulting null/flagged gaps. Do not manufacture missing observations or present stale data as fresh. If a source fails, finish independent outputs and document exact limitations. Keep caches and downloaded/raw inputs in .cache/, out of deliverables.",
            "paths": "pipeline/**, tests/**, web/data/**, docs/REBUILD.md",
            "inputs": "Fetch the public data sources configured by the imported pipeline and the regional source targets; use python3. For a 403 retry curl -sS -A Mozilla/5.0 before recording an unavailable source. No guessed data or credentials.",
            "check": "python3 -m pipeline check"
          },
          "scope": [
            "pipeline/**",
            "tests/**",
            "web/data/**",
            "docs/REBUILD.md"
          ],
          "needs": [
            "regions",
            "insets",
            "etopo",
            "natural-earth",
            "nlcd",
            "ak-fixes",
            "cities",
            "world"
          ],
          "check": "python3 -m pipeline check"
        },
        {
          "key": "g-seams",
          "vars": {
            "name": "g-seams",
            "context": "Gameplay is an always-on extension, never a mode. Subsequent targets must integrate entirely through the contracts established here, with no further edits to these seams.",
            "task": "Wire game/index.js export install(app) into ext/index.js. Create a game object exposing data references, state, subscriptions/update and command hooks; document it with JSDoc in state.js and a file/API map in README.md. Load optional ./layer.js, ./hud.js and ./docs.js, each exporting install(app,game), so later modules can install independently. Export addPage(title,render) from ui/pedia.js and addSection(title,rows) from app/help.js. Preserve existing exports and behavior; tolerate absent planned modules, surface actual errors. Test initialization/hooks without DOM or dataset dependencies.",
            "paths": "web/js/ext/index.js, web/js/ui/pedia.js, web/js/app/help.js, web/js/ext/game/index.js, web/js/ext/game/state.js, web/js/ext/game/README.md, web/js/ext/game/test/g-seams.test.js",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "node --test web/js/ext/game/test/g-seams.test.js"
          },
          "scope": [
            "web/js/ext/index.js",
            "web/js/ui/pedia.js",
            "web/js/app/help.js",
            "web/js/ext/game/index.js",
            "web/js/ext/game/state.js",
            "web/js/ext/game/README.md",
            "web/js/ext/game/test/g-seams.test.js"
          ],
          "needs": [
            "doc"
          ],
          "check": "node --test web/js/ext/game/test/g-seams.test.js"
        },
        {
          "key": "ui",
          "vars": {
            "name": "ui",
            "context": "Use the rebuilt projection and game seams. terrain.js already mirrors composite Albers. landBox and fitScale must keep their original lower-48 meaning.",
            "task": "Render and label AK/HI/PR insets, extend minimap and camera navigation/hit-testing to reach each region, and correct lower-48-only words and counts throughout the assigned UI. Keep landBox/fitScale lower-48; add separate composite bounds where necessary. Preserve existing input keys, #turn, modes, exports and the addPage/addSection seams. Verify region selection/camera behavior and all changed JS syntax. Report visual checks actually performed and remaining null/flagged data.",
            "paths": "web/index.html, web/css/**, web/js/main.js, web/js/camera.js, web/js/world.js, web/js/hex.js, web/js/render/**, web/js/ui/**, web/js/app/**, web/js/ext/advisors/**, web/js/ext/cityView/**, web/js/ext/layers/**",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "python3 -c 'from pathlib import Path;import subprocess;fs=[p for p in Path(\"web/js\").rglob(\"*.js\") if \"web/js/ext/game/\" not in p.as_posix()];assert fs;[subprocess.run([\"node\",\"--check\",str(p)],check=True) for p in fs]'"
          },
          "scope": [
            "web/index.html",
            "web/css/**",
            "web/js/main.js",
            "web/js/camera.js",
            "web/js/world.js",
            "web/js/hex.js",
            "web/js/render/**",
            "web/js/ui/**",
            "web/js/app/**",
            "web/js/ext/advisors/**",
            "web/js/ext/cityView/**",
            "web/js/ext/layers/**"
          ],
          "needs": [
            "rebuild",
            "g-seams"
          ],
          "check": "python3 -c 'from pathlib import Path;import subprocess;fs=[p for p in Path(\"web/js\").rglob(\"*.js\") if \"web/js/ext/game/\" not in p.as_posix()];assert fs;[subprocess.run([\"node\",\"--check\",str(p)],check=True) for p in fs]'"
        },
        {
          "key": "g-config",
          "vars": {
            "name": "g-config",
            "context": "Follow web/js/ext/game/README.md and state.js contracts. Pure rule modules: no DOM, storage or Math.random; deterministic seeded RNG lives in state. Tests use small fixtures, never web/data.",
            "task": "Define all invented gameplay constants in rules/config.js and a deterministic seeded RNG in rules/rng.js. Establish documented immutable rule configuration and initial-state creation compatible with state.js. Selecting a state grants cities whose state listing names it FIRST; other cities are passive rivals. Normalize real city yields food/production/gold/science/culture with null contributing zero and retain missing flags. Cover deterministic initialization, multi-state ownership, real zero vs null and reproducible RNG; document exported APIs for dependent modules.",
            "paths": "web/js/ext/game/rules/config.js, web/js/ext/game/rules/rng.js, web/js/ext/game/test/g-config.test.js",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "node --test web/js/ext/game/test/g-config.test.js"
          },
          "scope": [
            "web/js/ext/game/rules/config.js",
            "web/js/ext/game/rules/rng.js",
            "web/js/ext/game/test/g-config.test.js"
          ],
          "needs": [
            "doc",
            "g-seams"
          ],
          "check": "node --test web/js/ext/game/test/g-config.test.js"
        },
        {
          "key": "g-tiles",
          "vars": {
            "name": "g-tiles",
            "context": "Follow web/js/ext/game/README.md and state.js contracts. Pure rule modules: no DOM, storage or Math.random; deterministic seeded RNG lives in state. Tests use small fixtures, never web/data.",
            "task": "Implement pure tile yields as real city yields times config constants, null = 0; movement cost and deterministic A* over the actual hex adjacency contract. Region/inset separation must not create spurious neighbors. Keep unknown data flagged, validate invalid/unreachable destinations and tie-break deterministically. Test yields, obstacles/costs, boundaries, optimal paths and unreachable/region-separated tiles. Expose/document APIs used by units and the map layer.",
            "paths": "web/js/ext/game/rules/tiles.js, web/js/ext/game/test/g-tiles.test.js",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "node --test web/js/ext/game/test/g-tiles.test.js"
          },
          "scope": [
            "web/js/ext/game/rules/tiles.js",
            "web/js/ext/game/test/g-tiles.test.js"
          ],
          "needs": [
            "doc",
            "g-config"
          ],
          "check": "node --test web/js/ext/game/test/g-tiles.test.js"
        },
        {
          "key": "g-cities",
          "vars": {
            "name": "g-cities",
            "context": "Follow web/js/ext/game/README.md and state.js contracts. Pure rule modules: no DOM, storage or Math.random; deterministic seeded RNG lives in state. Tests use small fixtures, never web/data.",
            "task": "Implement pure per-turn city food growth, production queues and passive rival progression from real yields and config. Queues build districts, wonders, scouts and armies; return unit-completion events for units to consume without circular imports. Enforce queue costs/eligibility and deterministic overflow rules; keep owner from first-listed state. Test null yields, growth thresholds, production/queue completion, wonders, passive rivals and stable event order; document APIs.",
            "paths": "web/js/ext/game/rules/cities.js, web/js/ext/game/test/g-cities.test.js",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "node --test web/js/ext/game/test/g-cities.test.js"
          },
          "scope": [
            "web/js/ext/game/rules/cities.js",
            "web/js/ext/game/test/g-cities.test.js"
          ],
          "needs": [
            "doc",
            "g-config"
          ],
          "check": "node --test web/js/ext/game/test/g-cities.test.js"
        },
        {
          "key": "g-units",
          "vars": {
            "name": "g-units",
            "context": "Follow web/js/ext/game/README.md and state.js contracts. Pure rule modules: no DOM, storage or Math.random; deterministic seeded RNG lives in state. Tests use small fixtures, never web/data.",
            "task": "Implement pure unit creation from city completion events, scout/army movement via tile costs/A*, per-turn movement limits and army capture of strictly weaker cities. Use configured costs/strengths, update ownership consistently, and prevent invalid moves, friendly capture and attacking equal/stronger cities. Rivals remain passive. Tests cover queues spawning units, reachable paths, turn movement reset, valid/invalid captures and deterministic ownership changes. Document APIs for turn and layer.",
            "paths": "web/js/ext/game/rules/units.js, web/js/ext/game/test/g-units.test.js",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "node --test web/js/ext/game/test/g-units.test.js"
          },
          "scope": [
            "web/js/ext/game/rules/units.js",
            "web/js/ext/game/test/g-units.test.js"
          ],
          "needs": [
            "doc",
            "g-tiles",
            "g-cities"
          ],
          "check": "node --test web/js/ext/game/test/g-units.test.js"
        },
        {
          "key": "g-turn",
          "vars": {
            "name": "g-turn",
            "context": "Follow web/js/ext/game/README.md and state.js contracts. Pure rule modules: no DOM, storage or Math.random; deterministic seeded RNG lives in state. Tests use small fixtures, never web/data.",
            "task": "Implement deterministic End Turn orchestration for cities, queues, units, seeded state and victory. Win by owning the largest city in each of ten distinct states, reaching the configured science target, or having top score at turn 100; document deterministic ties/scoring in exported RULES if constants are needed beyond config. Use first-listed state for state membership and forbid further advancement after game over. Add a seeded 100-turn simulation and tests for each victory path, passive rivals, null yields, turn limits and repeatability; expose the turn API needed by HUD.",
            "paths": "web/js/ext/game/rules/turn.js, web/js/ext/game/test/g-turn.test.js",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "node --test web/js/ext/game/test/g-turn.test.js"
          },
          "scope": [
            "web/js/ext/game/rules/turn.js",
            "web/js/ext/game/test/g-turn.test.js"
          ],
          "needs": [
            "doc",
            "g-units"
          ],
          "check": "node --test web/js/ext/game/test/g-turn.test.js"
        },
        {
          "key": "g-layer",
          "vars": {
            "name": "g-layer",
            "context": "Follow game README.md and state.js; this optional layer installs through game/index.js. Pure units/tiles/cities are ready. Do not edit main.js, terrain.js or the extension seams.",
            "task": "Export install(app,game) using existing renderer hooks and game subscriptions. Draw owned/rival city markers, scouts/armies, selected units and valid movement paths; support selection and move/capture commands through pure unit rules. Respect composite insets, pan/zoom and region boundaries. Preserve ordinary map interaction and exports. Use fixture/mocked rendering tests for selection, movement dispatch, redraw after state change and cleanup; report any visual behavior unverified.",
            "paths": "web/js/ext/game/layer.js, web/js/ext/game/test/g-layer.test.js",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "node --test web/js/ext/game/test/g-layer.test.js"
          },
          "scope": [
            "web/js/ext/game/layer.js",
            "web/js/ext/game/test/g-layer.test.js"
          ],
          "needs": [
            "doc",
            "g-units"
          ],
          "check": "node --test web/js/ext/game/test/g-layer.test.js"
        },
        {
          "key": "g-hud",
          "vars": {
            "name": "g-hud",
            "context": "Follow the game README.md/state.js interfaces and turn/unit/city APIs. HUD owns gameplay controls and persistence; layer observes the shared state. The game is always-on, never registerMode.",
            "task": "Export install(app,game). Provide initial state selection, owned cities first, yields/growth/queues, district/wonder/scout/army production, unit actions and End Turn wired to pure rules. Show game turn, victory/score and missing-data flags while preserving existing #turn. Load game.css from hud.js. Implement versioned localStorage save/load with seed/state and safe handling of corrupt/incompatible saves or unavailable storage. Reconcile saves to actual city IDs; no invented data. Test selection, End Turn wiring, controls and save round trips with mocks.",
            "paths": "web/js/ext/game/hud.js, web/js/ext/game/save.js, web/js/ext/game/game.css, web/js/ext/game/test/g-hud.test.js",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "node --test web/js/ext/game/test/g-hud.test.js"
          },
          "scope": [
            "web/js/ext/game/hud.js",
            "web/js/ext/game/save.js",
            "web/js/ext/game/game.css",
            "web/js/ext/game/test/g-hud.test.js"
          ],
          "needs": [
            "doc",
            "g-turn"
          ],
          "check": "node --test web/js/ext/game/test/g-hud.test.js"
        },
        {
          "key": "g-docs",
          "vars": {
            "name": "g-docs",
            "context": "Follow game README.md/state.js and the established addPage(title,render)/addSection(title,rows) seams. Game config, turns and HUD are ready; documentation must reflect their actual rules.",
            "task": "Export install(app,game), register an Almanac rules page through addPage and help through addSection. Explain state selection/first-listed-city ownership, passive rivals, real yield scaling/null=0, food growth, production choices, scouts/armies/capture, End Turn, save/load and every victory route including turn 100/ties. Render invented constants from actual config or exported RULES so rules stay consistent with code. Test registration and content using mocks; preserve existing help and Almanac pages.",
            "paths": "web/js/ext/game/docs.js, web/js/ext/game/test/g-docs.test.js",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "node --test web/js/ext/game/test/g-docs.test.js"
          },
          "scope": [
            "web/js/ext/game/docs.js",
            "web/js/ext/game/test/g-docs.test.js"
          ],
          "needs": [
            "doc",
            "g-hud"
          ],
          "check": "node --test web/js/ext/game/test/g-docs.test.js"
        },
        {
          "key": "export",
          "vars": {
            "name": "export",
            "context": "Package the landed application as a static export. The output must run without npm, frameworks, packages or a build service.",
            "task": "Create dist/ as a complete byte-preserving copy of web/ except web/dev/ and remove the dist/ ignore rule from .gitignore. Include actual data, all extension modules, styles and assets. Remove stale dist files so contents match the final web tree. Check dist/index.html, relative asset/module links and copied-file equality; document static-serving command and any inherited incomplete features. Do not change web/.",
            "paths": "dist/**, .gitignore",
            "inputs": "Use committed project inputs and local fixtures. Data-source downloads belong only to rebuild.",
            "check": "test -f dist/index.html"
          },
          "scope": [
            "dist/**",
            ".gitignore"
          ],
          "needs": [
            "ui",
            "g-docs",
            "g-layer",
            "imp-rest"
          ],
          "check": "test -f dist/index.html"
        }
      ],
      "output": {
        "format": "markdown",
        "maxBytes": 12000
      }
    }
  ],
  "read": [
    "usaciv-targets-2/imp-docs",
    "usaciv-targets-2/imp-web",
    "usaciv-targets-2/imp-rest",
    "usaciv-targets-2/fix-tests",
    "usaciv-targets-2/doc",
    "usaciv-targets-2/regions",
    "usaciv-targets-2/insets",
    "usaciv-targets-2/etopo",
    "usaciv-targets-2/natural-earth",
    "usaciv-targets-2/nlcd",
    "usaciv-targets-2/ak-fixes",
    "usaciv-targets-2/cities",
    "usaciv-targets-2/world",
    "usaciv-targets-2/rebuild",
    "usaciv-targets-2/g-seams",
    "usaciv-targets-2/ui",
    "usaciv-targets-2/g-config",
    "usaciv-targets-2/g-tiles",
    "usaciv-targets-2/g-cities",
    "usaciv-targets-2/g-units",
    "usaciv-targets-2/g-turn",
    "usaciv-targets-2/g-layer",
    "usaciv-targets-2/g-hud",
    "usaciv-targets-2/g-docs",
    "usaciv-targets-2/export"
  ],
  "cancel": [],
  "wake": {
    "batches": [
      "usaciv-targets-2"
    ]
  },
  "finish": false
}
