{
  "notes": "EPISODE 3: Recovering from two refused spawns. Authoritative input: trunk=null, batches=[], handed=[], effects.pending=0, items.used=0 of 50, no requester notes, no children bought/opened, stalled.inARow=2. No implementation has landed. Episode 2 spawn usaciv-targets-2 was refused because imp-docs variable task requested a command's verbatim output; associated reads/wake then referred to a nonexistent batch. Episode 1 also failed brief screening. Earlier statements about spent seats are not evidence of actual dispatch. Nothing exists to cancel or retry with itemsFrom.\n\nDECISION: Submit ONE new code target batch usaciv-targets-3, attempts=3, 25 explicit targets, no minutes, no after, no machine requirements. It contains the requested 24 targets plus fix-tests. Every brief asks for one scoped implementation and an authored report of changed project paths, behavior, validation pass/fail with reasons in the worker's own words, gaps and interfaces. No command transcripts or machine inspection are requested. Read all 25 target results and wake when this batch settles, without a timer. finish=false. Submission is a request, not proof of acceptance. If accepted, 25 of 50 initial items remain before splits, leaving capacity for the required episode-4 export fallback.\n\nSOURCE verified in memory this episode: https://karpathy.ai/usaciv/usaciv-source.zip, SHA-256 52b3b2c3cf189b8ceff2376c48188db7ec88634d6a0f73ae254077ed50306314, 8008568 bytes, 189 files under usaciv/. No source files were imported into this orchestrator checkout. Imports must verify then extract in .cache/ and copy only assigned paths. Offline import checks hash sorted path + NUL + contents + NUL: docs 6 files hash 4df0f40f0fc446db21cafee89c2493c355d1bf27ac1af1c99104432e0e36aec9; web 102 hash 2f3e28235cafe56f835bb9593080fc588afd3fe7000069b4f276ddeae4cf0ee4; rest 81 hash ef55a42cc96b4cd7748e9532ec1560190ce24f1293e08393656c5d114bbc7924. Unlike episode 2's planned check, rest covers tests/test_builders.py too; only generated __pycache__ directories are excluded. These fingerprints apply to import commits. Never re-import or apply pristine-tree fingerprints over later feature edits.\n\nGRAPH: imp-docs, imp-web, imp-rest first. 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. Every game target needs doc: g-seams -> g-config -> [g-tiles,g-cities] -> g-units -> g-turn -> g-hud -> g-docs; g-layer needs g-units. ui needs rebuild and g-seams. export needs ui, g-docs, g-layer, imp-rest. Full repository paths in every scope; overlapping scopes ordered transitively. Default check python3 -m unittest discover -s tests. Imports use offline fingerprints; doc adds test -s; rebuild uses python3 -m pipeline check; game uses node --test web/js/ext/game/test/<key>.test.js; ui invokes node --check per non-game JS file; export uses test -f dist/index.html.\n\nfix-tests rationale: episode 1 reported PlanningTest.test_staleness repeatedly yielding [b,c,cat] instead of [cat], because fixture writes shared an mtime while is_stale uses >=. Not rerun here. Target must reproduce and set deterministic fixture timestamps without sleeps, dropped assertions or production changes. Keep it narrow and report actual findings.\n\nMAP contracts: one region/off-map definition, lower48+DC and AK02/HI15/PR72 mapped, GU66/VI78/AS60/MP69 off. True-scale Albers per region; AK positive longitude normalized by -360. Existing MapProjection calls and lower-48 transform unchanged; serialize inset transforms alongside min_x/max_y/margin, with JS mirror in terrain.js and existing fallback. Grid grows right/bottom; lower-48 centres/owner IDs retained, new IDs appended; clip sources per region. Persist projection in interim _world and public world.json. PRI/VIR are US, VIR stays excluded. NLCD AK2016, HI2001, PR2001, each own CRS. Alaska FEMA crosswalk must feed disasters; retain real eastern AK mine longitudes. Keep ACS AK/HI/PR metros, first-state-only snapping, DC sole capital. landBox/fitScale remain lower-48. Only import targets fetch the pinned archive; only rebuild fetches datasets. Missing datasets mean documented null/flagged gaps, never synthetic coverage or weakened validation.\n\nGAME contracts: always-on extension; preserve #turn, keys and exports. Verified original loader uses install(app), tolerates missing modules and installs in list order. g-seams publishes shared state/subscriptions/commands, optional layer/hud/docs install(app,game), JSDoc state and README interfaces; later targets need no edits to those files. pedia addPage(title,render) and help addSection(title,rows) work after initialization too. Pure rules use seeded state and fixture tests, no DOM/Math.random. First state in city state list determines ownership, others passive. Real food/production/gold/science/culture times config constants; null contributes zero but stays flagged. Food growth; production districts/wonders/scouts/armies; capture strictly weaker cities. Own largest city in each of 10 distinct states OR science target OR top score at turn100. All invented constants in rules/config.js or RULES. HUD connects reducers/commands and versioned localStorage saves including RNG; layer uses the same state; docs show actual constants. Node module-runtime or visual limitations must be described accurately, not counted as verified behavior.\n\nNEXT EPISODE 4: Read actual trunk, target board, refusals and handed reports. If export is unlanded, re-send export ALONE in a new target batch with no needs, scope dist/** and .gitignore, check test -f dist/index.html. Copy whatever web/ actually landed except web/dev/, remove dist/ ignore rule, preserve included bytes. This fallback must not wait on stuck map/game targets. Never re-import over changed trees. If no web/ exists, acknowledge that rather than fabricate an application. If export already landed, use remaining capacity only for evidenced stuck targets plus unlanded dependents, dropping landed needs and keeping overlaps ordered; otherwise finish. Never assume this spawn was accepted. Prior refusals were brief-screening issues, not implementation failures.\n\nEPISODE 5 at latest: finish and write up actual trunk URL+commit, landed targets, stuck targets/reasons, missing or unverified coverage and how to run. Do not fabricate a URL/commit. Run python3 -m pipeline serve at http://127.0.0.1:8765; alternatively cd dist then python3 -m http.server. Tests: python3 -m unittest discover -s tests and individual node --test web/js/ext/game/test/<key>.test.js; data validation python3 -m pipeline check; rebuild python3 -m pipeline all. Mention the fixture repair according to what actually landed. Partial delivery is explicitly allowed. No child website/deployment is bought or required here.",
  "spawn": [
    {
      "name": "usaciv-targets-3",
      "mode": "code",
      "brief": "Implement one target, {{name}}, in Andrej Karpathy's MIT usaciv project, extending its real-data map to AK/HI/PR and adding an always-on turn game.\nContext: {{context}}\nWork: {{task}}\nAllowed paths: {{paths}}.\n{{access}}\nUse python3, not uv. Scratch only in .cache/. No npm, frameworks or new packages. Missing source values stay null and flagged; GU/VI/AS/MP stay off-map. Preserve existing keys, exports and #turn.\nTarget check: {{validation}}\nYour result must contain a concise report of changed project paths, implemented behavior, validation pass/fail with reasons in your own words, remaining gaps, and interfaces dependents need.",
      "items": [
        {
          "key": "imp-docs",
          "vars": {
            "name": "imp-docs",
            "context": "Original source: https://karpathy.ai/usaciv/usaciv-source.zip; required SHA-256 52b3b2c3cf189b8ceff2376c48188db7ec88634d6a0f73ae254077ed50306314. The archive root is usaciv/; repository paths are relative to that root.",
            "task": "Import the six original files under usaciv/docs/ into docs/ byte for byte, including DATA_CONTRACTS.md and images/. Preserve the original paths and contents. The target check validates the imported tree against the verified archive. Leave architecture additions to doc.",
            "paths": "docs/**",
            "access": "Fetch this pinned source archive only, verify its SHA-256, extract under .cache/, and copy only the assigned paths. Dataset fetching is reserved for rebuild.",
            "validation": "python3 -c 'import hashlib as h,pathlib as p;a=sorted(q for r in [\"docs\"] for q in ([p.Path(r)] if p.Path(r).is_file() else p.Path(r).rglob(\"*\")) if q.is_file() and \"__pycache__\" not in q.parts);assert h.sha256(b\"\".join(str(q).encode()+b\"\\0\"+q.read_bytes()+b\"\\0\" for q in a)).hexdigest()==\"4df0f40f0fc446db21cafee89c2493c355d1bf27ac1af1c99104432e0e36aec9\"'"
          },
          "scope": [
            "docs/**"
          ],
          "needs": [],
          "check": "python3 -c 'import hashlib as h,pathlib as p;a=sorted(q for r in [\"docs\"] for q in ([p.Path(r)] if p.Path(r).is_file() else p.Path(r).rglob(\"*\")) if q.is_file() and \"__pycache__\" not in q.parts);assert h.sha256(b\"\".join(str(q).encode()+b\"\\0\"+q.read_bytes()+b\"\\0\" for q in a)).hexdigest()==\"4df0f40f0fc446db21cafee89c2493c355d1bf27ac1af1c99104432e0e36aec9\"'"
        },
        {
          "key": "imp-web",
          "vars": {
            "name": "imp-web",
            "context": "Original source: https://karpathy.ai/usaciv/usaciv-source.zip; required SHA-256 52b3b2c3cf189b8ceff2376c48188db7ec88634d6a0f73ae254077ed50306314. The archive root is usaciv/; repository paths are relative to that root.",
            "task": "Import all 102 original files under usaciv/web/ into web/ byte for byte, including web/data/ and web/dev/. Preserve the original paths and contents. The target check validates the imported tree against the verified archive. Feature work follows in dependent targets.",
            "paths": "web/**",
            "access": "Fetch this pinned source archive only, verify its SHA-256, extract under .cache/, and copy only the assigned paths. Dataset fetching is reserved for rebuild.",
            "validation": "python3 -c 'import hashlib as h,pathlib as p;a=sorted(q for r in [\"web\"] for q in ([p.Path(r)] if p.Path(r).is_file() else p.Path(r).rglob(\"*\")) if q.is_file() and \"__pycache__\" not in q.parts);assert h.sha256(b\"\".join(str(q).encode()+b\"\\0\"+q.read_bytes()+b\"\\0\" for q in a)).hexdigest()==\"2f3e28235cafe56f835bb9593080fc588afd3fe7000069b4f276ddeae4cf0ee4\"'"
          },
          "scope": [
            "web/**"
          ],
          "needs": [],
          "check": "python3 -c 'import hashlib as h,pathlib as p;a=sorted(q for r in [\"web\"] for q in ([p.Path(r)] if p.Path(r).is_file() else p.Path(r).rglob(\"*\")) if q.is_file() and \"__pycache__\" not in q.parts);assert h.sha256(b\"\".join(str(q).encode()+b\"\\0\"+q.read_bytes()+b\"\\0\" for q in a)).hexdigest()==\"2f3e28235cafe56f835bb9593080fc588afd3fe7000069b4f276ddeae4cf0ee4\"'"
        },
        {
          "key": "imp-rest",
          "vars": {
            "name": "imp-rest",
            "context": "Original source: https://karpathy.ai/usaciv/usaciv-source.zip; required SHA-256 52b3b2c3cf189b8ceff2376c48188db7ec88634d6a0f73ae254077ed50306314. The archive root is usaciv/; repository paths are relative to that root.",
            "task": "Import all 81 original files in the assigned paths from usaciv/ byte for byte. Include all tests, fixtures and tests/test_builders.py unchanged. Preserve MIT attribution. The target check validates the imported tree against the verified archive; the subsequent fix-tests target owns any fixture repair.",
            "paths": "README.md, LICENSE, pyproject.toml, uv.lock, .gitignore, pipeline/**, tests/**",
            "access": "Fetch this pinned source archive only, verify its SHA-256, extract under .cache/, and copy only the assigned paths. Dataset fetching is reserved for rebuild.",
            "validation": "python3 -c 'import hashlib as h,pathlib as p;a=sorted(q for r in [\"README.md\",\"LICENSE\",\"pyproject.toml\",\"uv.lock\",\".gitignore\",\"pipeline\",\"tests\"] for q in ([p.Path(r)] if p.Path(r).is_file() else p.Path(r).rglob(\"*\")) if q.is_file() and \"__pycache__\" not in q.parts);assert h.sha256(b\"\".join(str(q).encode()+b\"\\0\"+q.read_bytes()+b\"\\0\" for q in a)).hexdigest()==\"ef55a42cc96b4cd7748e9532ec1560190ce24f1293e08393656c5d114bbc7924\"'"
          },
          "scope": [
            "README.md",
            "LICENSE",
            "pyproject.toml",
            "uv.lock",
            ".gitignore",
            "pipeline/**",
            "tests/**"
          ],
          "needs": [],
          "check": "python3 -c 'import hashlib as h,pathlib as p;a=sorted(q for r in [\"README.md\",\"LICENSE\",\"pyproject.toml\",\"uv.lock\",\".gitignore\",\"pipeline\",\"tests\"] for q in ([p.Path(r)] if p.Path(r).is_file() else p.Path(r).rglob(\"*\")) if q.is_file() and \"__pycache__\" not in q.parts);assert h.sha256(b\"\".join(str(q).encode()+b\"\\0\"+q.read_bytes()+b\"\\0\" for q in a)).hexdigest()==\"ef55a42cc96b4cd7748e9532ec1560190ce24f1293e08393656c5d114bbc7924\"'"
        },
        {
          "key": "fix-tests",
          "vars": {
            "name": "fix-tests",
            "context": "Earlier episode notes report repeated equal-timestamp failures in this test because pipeline/__main__.py is_stale uses >=. This episode has not rerun those tests. Exact source import precedes this narrowly scoped repair.",
            "task": "Make PlanningTest.test_staleness deterministic by setting fixture output mtimes with explicit ordering. First reproduce the reported equal-mtime case where expected [cat] becomes [b,c,cat]. Preserve assertions and production semantics; use controlled fixture times without sleeps. Run the full unittest suite. If the current fixture is already deterministic, justify that with a focused regression case.",
            "paths": "tests/test_builders.py",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Source is imported unchanged apart from the focused test fixture repair. Document the actual code, including the extension loader, pedia/help initialization, and projection fallback in render/art/terrain.js.",
            "task": "Write an accurate architecture guide: source acquisition/cache, build dependency graph, projection/hex grid, data contracts and null handling, browser startup/render/camera/UI, extension API, tests and local serving. Map relevant full paths and explain planned map/game integration contracts. Distinguish existing behavior from planned work; preserve MIT attribution. Include python3 commands for serve, all, check and unittest, plus Node game checks.",
            "paths": "docs/ARCHITECTURE.md",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "This target establishes the shared region contract; composite projection, geographic sources, city placement and expanded world are later targets. Keep checks compatible with shipped data while it still reflects the original build.",
            "task": "Create one shared definition of mapped regions and off-map state FIPS. Include lower 48 plus DC, AK 02, HI 15 and PR 72; exclude exactly GU 66, VI 78, AS 60 and MP 69. Replace divergent world/check CONUS_EXCLUDE, cities NON_CONUS, trade OFF_MAP and military lower-48 filtering with this definition. Preserve lower-48 results. Add fixture tests covering the common set and each affected consumer.",
            "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",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Shared regions come from pipeline/core/regions.py. Off-map regions remain excluded. The original world.json lacks projection; world later writes it. Transform dimensions and offsets must be shared through serialization, not separately guessed by renderers.",
            "task": "Turn MapProjection into a composite: retain the lower-48 transform exactly; add true-scale Albers transforms for AK, HI and PR with offsets to the right/bottom. Normalize AK lon>0 to lon-360. Preserve proj(lon,lat), inverse, to_dict and MapProjection(**projection) usage so callers stay unchanged. Serialize inset definitions alongside min_x/max_y/margin. Mirror forward/inverse/normalization logic in terrain.js and retain its SHIPPED_PROJ fallback for original data. Test round-trips, seams, eastern Aleutians and unchanged lower-48 centres.",
            "paths": "pipeline/core/geo.py, pipeline/core/regions.py, web/js/render/art/terrain.js, tests/test_insets.py",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "This target implements acquisition/parsing support only; rebuild later fetches datasets. Missing elevations remain null with provenance/flags, never invented terrain.",
            "task": "Extend elevation ingestion to AK, HI and PR. Keep existing lower-48 window, URL, filename, keys and samples compatible. Expose separately tagged regional windows/rasters for the world builder, including Alaska longitude normalization. Avoid loading a global raster unnecessarily. Test extraction, bounds, nodata and antimeridian handling with tiny fixtures. Record the regional return contract for world.",
            "paths": "pipeline/sources/etopo.py, tests/test_etopo.py",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Source adapters can land independently of the composite projection. Expose regional data for the later world builder; no dataset download in this target.",
            "task": "Extend Natural Earth ingestion to clipped regional geometry for AK, HI and PR while retaining lower-48 behavior and source keys. Treat PRI and VIR as US polygons rather than foreign land; VIR still remains off-map. Handle Alaska antimeridian geometry and prevent polygons from crossing unrelated inset areas. Test classification, clipping and missing fields using small geometry fixtures. State the return contract for world.",
            "paths": "pipeline/sources/natural_earth.py, tests/test_natural_earth.py",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Only rebuild fetches remote datasets. Geographic source adapters must use the existing standard-library project conventions and introduce no package dependency.",
            "task": "Add land-cover sources for AK 2016, HI 2001 and PR 2001, preserving lower-48 URLs, filenames, keys and behavior. Keep each region raster in its own native CRS and convert sampling coordinates appropriately. Expose region-tagged metadata, nodata handling and sampling interfaces for world. Test separate CRS paths, vintage selection, bounds and nodata with fixtures. Keep unsupported/missing observations null and flagged.",
            "paths": "pipeline/sources/nlcd.py, tests/test_nlcd.py",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Use source metadata and project facts for crosswalk entries. Do not invent county correspondences or fetch datasets here. Preserve lower-48 disaster totals and mine coordinates.",
            "task": "Implement an Alaska FEMA county-code crosswalk in core/ak_fema.py and actually apply it in build/disasters.py, following the existing Connecticut treatment. Account for supported historical county/borough changes without double counting; ambiguous or unmapped codes remain explicitly flagged. Fix MSHA mine longitude handling to retain valid eastern AK longitudes (172..180), using the composite projection for display. Add offline fixture regressions for FEMA aggregation and Aleutian mine placement.",
            "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",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "The shared regions set is landed. City inputs retain real source values; absent metrics stay null and flagged. Placement must work with the original grid and forthcoming composite world.",
            "task": "Keep AK/HI/PR ACS metros when building cities. Preserve the ACS state list order and place/snap a metro only to a hex owned by its first-listed state; never snap an island metro across an inset gap. Make DC the sole capital marker. Keep existing lower-48 city IDs and data contracts. Test AK, HI, PR, a cross-state metro, DC, own-state snapping and absence of an eligible hex with fixtures.",
            "paths": "pipeline/build/cities.py, tests/test_cities.py, tests/test_city_view.py",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Use the regional source interfaces and composite MapProjection already landed. This target changes the builder, not committed web/data. Grid gaps are water/empty, never fabricated US land; unknown source values remain null with flags.",
            "task": "Build the composite grid by extending columns rightward and rows downward. Preserve every existing lower-48 hex centre and state/county owner ID, including through any flat-index stride change; append new states/counties last. Clip/sample geometry, elevation and land-cover by owning region, preventing overlap and false bridges. Include AK/HI/PR and exclude GU/VI/AS/MP. Persist the full projection in both interim _world and web/data/world.json builder output. Add fixtures proving lower-48 invariance, inset coverage, projection round-trip and array/index consistency; adapt checker expectations honestly.",
            "paths": "pipeline/build/world.py, pipeline/check.py, tests/test_world.py, tests/test_gdp_fill.py, tests/test_check.py",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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 implementation targets have landed. This is the only dataset-fetching target. Keep downloaded/cache/interim material under .cache/ and deliver generated data needed to serve without fetching.",
            "task": "Run python3 -m pipeline all to rebuild the map datasets, fixing in-scope pipeline integration defects and regression tests as needed. Commit generated web/data and docs/REBUILD.md. Verify AK/HI/PR coverage, off-map exclusions, unchanged lower-48 centres/owner IDs, appended identifiers, projection serialization and cross-file references. Document source vintages/provenance, gaps, reproduction steps and validation findings. Partial coverage is allowed: retain valid shipped data where a source fails, represent unavailable added-region fields as null with explicit flags, and keep datasets consistent. Never relax checks to hide invalid data.",
            "paths": "pipeline/**, tests/**, web/data/**, docs/REBUILD.md",
            "access": "Fetch only public datasets used by the project pipeline. Use python3 for pipeline commands; existing adapters define acquisition and parsing.",
            "validation": "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": "Create integration seams only. The existing loader imports modules in parallel and installs them in order. The game must coexist with cityView/advisors/layers, use the app extension API and be always-on without registerMode. Later rule, layer, HUD and docs targets have disjoint scopes, so publish usable interfaces now. All invented game constants belong in rules/config.js or RULES.",
            "task": "Add the game entry to the extension loader. Export game/index.js install(app); construct shared state/subscriptions and a command registration interface; load optional layer.js, hud.js and docs.js via install(app,game) without requiring later edits to this file. Document state and contracts with JSDoc in state.js and a module map/API in README.md. Export addPage(title,render) from pedia.js and addSection(title,rows) from help.js; registrations must work before and after UI initialization. Keep existing exports, keys, #turn and browsing behavior. Add fixture tests for installation, late registration and absent optional modules.",
            "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",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "g-config",
          "vars": {
            "name": "g-config",
            "context": "Game is an always-on extension, never a mode. Pick a state; own cities whose state list names it first, all others passive rivals. Real city food/production/gold/science/culture yields are multiplied by constants; null contributes zero while remaining flagged. Food grows cities; production builds districts, wonders, scouts and armies; armies capture strictly weaker cities. Win by owning the largest city in each of 10 distinct states, reaching a science target, or top score at turn 100. All invented constants belong in rules/config.js or RULES. Pure rules have no DOM or Math.random and use seeded state. Use the shared state/command contracts in game/state.js and game/README.md. Tests use fixtures, not web/data.",
            "task": "Define the exported RULES/config for yield scaling, growth, production costs/effects, movement, strength, scoring, science victory, ten-state victory and 100-turn limit. Mark simulation choices separately from real source values and document units. Provide a deterministic serializable seeded RNG. Follow the seams state contract and provide stable named exports usable by all later modules. Test validation of constants and RNG repeatability/state restoration.",
            "paths": "web/js/ext/game/rules/config.js, web/js/ext/game/rules/rng.js, web/js/ext/game/test/g-config.test.js",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Game is an always-on extension, never a mode. Pick a state; own cities whose state list names it first, all others passive rivals. Real city food/production/gold/science/culture yields are multiplied by constants; null contributes zero while remaining flagged. Food grows cities; production builds districts, wonders, scouts and armies; armies capture strictly weaker cities. Win by owning the largest city in each of 10 distinct states, reaching a science target, or top score at turn 100. All invented constants belong in rules/config.js or RULES. Pure rules have no DOM or Math.random and use seeded state. Use the shared state/command contracts in game/state.js and game/README.md. Tests use fixtures, not web/data.",
            "task": "Implement pure yield conversion, terrain/movement costs and deterministic A* over the existing hex-grid representation. Use real city yield values times configured constants; null adds zero and stays flagged. Honor valid region adjacency, impassable water and gaps so inset neighbors are never joined accidentally. Return explicit no-path outcomes. Test weighted optimal paths, unreachable tiles, deterministic tie handling, edges, null yields and preserved input data.",
            "paths": "web/js/ext/game/rules/tiles.js, web/js/ext/game/test/g-tiles.test.js",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Game is an always-on extension, never a mode. Pick a state; own cities whose state list names it first, all others passive rivals. Real city food/production/gold/science/culture yields are multiplied by constants; null contributes zero while remaining flagged. Food grows cities; production builds districts, wonders, scouts and armies; armies capture strictly weaker cities. Win by owning the largest city in each of 10 distinct states, reaching a science target, or top score at turn 100. All invented constants belong in rules/config.js or RULES. Pure rules have no DOM or Math.random and use seeded state. Use the shared state/command contracts in game/state.js and game/README.md. Tests use fixtures, not web/data.",
            "task": "Implement pure city initialization/ownership by first-listed state, passive rivals, food accumulation and growth, and production queues for districts/wonders/scouts/armies. Define production completion events that g-units can consume. Use config for all prices/effects and preserve real source fields. Enforce legal queues and wonder uniqueness; handle overflow deterministically. Test multi-state metros, passive-rival behavior, growth, queues, null yields and production completion.",
            "paths": "web/js/ext/game/rules/cities.js, web/js/ext/game/test/g-cities.test.js",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Game is an always-on extension, never a mode. Pick a state; own cities whose state list names it first, all others passive rivals. Real city food/production/gold/science/culture yields are multiplied by constants; null contributes zero while remaining flagged. Food grows cities; production builds districts, wonders, scouts and armies; armies capture strictly weaker cities. Win by owning the largest city in each of 10 distinct states, reaching a science target, or top score at turn 100. All invented constants belong in rules/config.js or RULES. Pure rules have no DOM or Math.random and use seeded state. Use the shared state/command contracts in game/state.js and game/README.md. Tests use fixtures, not web/data.",
            "task": "Implement pure scout/army creation from city production events, movement with per-turn budgets, exploration and capture of strictly weaker rival cities. Use tile costs/pathfinding and city ownership interfaces; reject illegal, impassable, cross-inset and over-budget movement. Scouts cannot capture; equal/stronger defenders cannot be captured. Handle ownership transfer and state updates consistently. Add deterministic fixture tests for production spawning, movement, capture, weaker/equal/stronger defenders and turn reset.",
            "paths": "web/js/ext/game/rules/units.js, web/js/ext/game/test/g-units.test.js",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Game is an always-on extension, never a mode. Pick a state; own cities whose state list names it first, all others passive rivals. Real city food/production/gold/science/culture yields are multiplied by constants; null contributes zero while remaining flagged. Food grows cities; production builds districts, wonders, scouts and armies; armies capture strictly weaker cities. Win by owning the largest city in each of 10 distinct states, reaching a science target, or top score at turn 100. All invented constants belong in rules/config.js or RULES. Pure rules have no DOM or Math.random and use seeded state. Use the shared state/command contracts in game/state.js and game/README.md. Tests use fixtures, not web/data.",
            "task": "Compose a deterministic pure end-turn reducer from city, tile and unit rules: accrue yields, growth/queues, completion events, movement resets, science and score, then evaluate victory. Ten-state victory requires the largest city in each of 10 distinct states, using a documented deterministic tie rule; support science and top score at turn 100. Keep passive rivals passive. Add seeded 100-turn regression, exact victory boundaries, ties, repeatability and game-over stability tests.",
            "paths": "web/js/ext/game/rules/turn.js, web/js/ext/game/test/g-turn.test.js",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Game is an always-on extension, never a mode. Pick a state; own cities whose state list names it first, all others passive rivals. Real city food/production/gold/science/culture yields are multiplied by constants; null contributes zero while remaining flagged. Food grows cities; production builds districts, wonders, scouts and armies; armies capture strictly weaker cities. Win by owning the largest city in each of 10 distinct states, reaching a science target, or top score at turn 100. All invented constants belong in rules/config.js or RULES. Pure rules have no DOM or Math.random and use seeded state. Use the shared state/command contracts in game/state.js and game/README.md. Tests use fixtures, not web/data.",
            "task": "Export install(app,game) using the seams subscriptions/commands. Draw unit tokens, ownership/exploration cues and selected-unit paths over the existing map via its render hooks. Dispatch selection/movement/capture commands through the shared game interface and pure rule validation. Support inset coordinates/camera transforms and remain inert before a state is picked. Preserve existing map interaction and keys; clean up listeners when appropriate. Test rendering decisions, command dispatch and ownership updates with minimal app/canvas fixtures.",
            "paths": "web/js/ext/game/layer.js, web/js/ext/game/test/g-layer.test.js",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Game is an always-on extension, never a mode. Pick a state; own cities whose state list names it first, all others passive rivals. Real city food/production/gold/science/culture yields are multiplied by constants; null contributes zero while remaining flagged. Food grows cities; production builds districts, wonders, scouts and armies; armies capture strictly weaker cities. Win by owning the largest city in each of 10 distinct states, reaching a science target, or top score at turn 100. All invented constants belong in rules/config.js or RULES. Pure rules have no DOM or Math.random and use seeded state. Use the shared state/command contracts in game/state.js and game/README.md. Tests use fixtures, not web/data.",
            "task": "Export install(app,game), wiring pure rules to shared commands/subscriptions. Provide state selection, owned-city growth/queues, district/wonder/scout/army production controls, unit controls and End Turn; show science, score, victory and the game turn separately from existing #turn. Load game.css from hud.js. Implement versioned localStorage save/load/reset with validation and graceful missing/corrupt/storage-failure handling; preserve RNG state. Ensure layer commands use the same state and reducer. Test state selection, End Turn, queue actions, save round-trip, bad saves and terminal state using fixtures.",
            "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",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "Game is an always-on extension, never a mode. Pick a state; own cities whose state list names it first, all others passive rivals. Real city food/production/gold/science/culture yields are multiplied by constants; null contributes zero while remaining flagged. Food grows cities; production builds districts, wonders, scouts and armies; armies capture strictly weaker cities. Win by owning the largest city in each of 10 distinct states, reaching a science target, or top score at turn 100. All invented constants belong in rules/config.js or RULES. Pure rules have no DOM or Math.random and use seeded state. Use the shared state/command contracts in game/state.js and game/README.md. Tests use fixtures, not web/data.",
            "task": "Export install(app,game), registering an Almanac game-rules page through addPage and a help section through addSection. Explain picking a state, first-state city ownership, passive rivals, real yields versus simulated scaling, null-as-zero behavior, growth/production, units/capture, victories, 100 turns and save/reset. Render actual exported constants so rules cannot drift. Keep wording honest about partial data and experimental game rules. Test registration, actual constants, null guidance and all win conditions with fixtures.",
            "paths": "web/js/ext/game/docs.js, web/js/ext/game/test/g-docs.test.js",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "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": "ui",
          "vars": {
            "name": "ui",
            "context": "Rebuilt data and game seams have landed. Game modules are outside this scope and may land concurrently; rely on their published extension contracts. Use projection metadata, not independently guessed inset offsets. Missing fields stay visibly unavailable.",
            "task": "Render AK/HI/PR inset frames/labels and terrain using serialized composite projection. Extend minimap, camera bounds, hit testing, fit-to-region/selection and navigation for the enlarged grid. Keep landBox and fitScale semantics lower-48; compute separate full-map bounds. Replace obsolete lower-48-only claims and fixed state counts with accurate data-driven wording. Preserve late pedia/help registration, extension APIs, existing keys, exports and #turn. Exercise lower-48/inset navigation, minimap picking and resize using project fixtures or an interactive smoke check where available; report any unverified visuals.",
            "paths": "web/index.html, web/css/**, web/js/main.js, web/js/camera.js, web/js/world.js, web/js/hex.js, web/js/terrain.js, web/js/render/**, web/js/ui/**, web/js/app/**, web/js/ext/advisors/**, web/js/ext/cityView/**, web/js/ext/layers/**",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "python3 -c 'from pathlib import Path; import subprocess; fs=[p for p in Path(\"web/js\").rglob(\"*.js\") if \"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/terrain.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 \"ext/game/\" not in p.as_posix()]; assert fs; [subprocess.run([\"node\",\"--check\",str(p)],check=True) for p in fs]'"
        },
        {
          "key": "export",
          "vars": {
            "name": "export",
            "context": "This target packages the landed web application, including insets and always-on game. No bundler or downloads are needed. Export is also the standalone fallback target for episode 4 if this dependency-gated target cannot land.",
            "task": "Create dist/ as an exact copy of the current web/ tree except web/dev/. Preserve relative layout, game modules/styles/tests and generated data; remove stale dist entries. Remove the dist/ ignore rule so the generated export is deliverable. Keep other ignore rules intact. Check dist/index.html, asset references and byte equality to web/ for included files. Summarize what the export contains and how to serve it with python3 -m http.server from dist/.",
            "paths": "dist/**, .gitignore",
            "access": "Use the landed project and fixture data; dataset fetching belongs only to rebuild.",
            "validation": "test -f dist/index.html"
          },
          "scope": [
            "dist/**",
            ".gitignore"
          ],
          "needs": [
            "ui",
            "g-docs",
            "g-layer",
            "imp-rest"
          ],
          "check": "test -f dist/index.html"
        }
      ],
      "targets": {
        "attempts": 3
      },
      "output": {
        "format": "markdown",
        "maxBytes": 12000
      }
    }
  ],
  "read": [
    "usaciv-targets-3/imp-docs",
    "usaciv-targets-3/imp-web",
    "usaciv-targets-3/imp-rest",
    "usaciv-targets-3/fix-tests",
    "usaciv-targets-3/doc",
    "usaciv-targets-3/regions",
    "usaciv-targets-3/insets",
    "usaciv-targets-3/etopo",
    "usaciv-targets-3/natural-earth",
    "usaciv-targets-3/nlcd",
    "usaciv-targets-3/ak-fixes",
    "usaciv-targets-3/cities",
    "usaciv-targets-3/world",
    "usaciv-targets-3/rebuild",
    "usaciv-targets-3/g-seams",
    "usaciv-targets-3/g-config",
    "usaciv-targets-3/g-tiles",
    "usaciv-targets-3/g-cities",
    "usaciv-targets-3/g-units",
    "usaciv-targets-3/g-turn",
    "usaciv-targets-3/g-layer",
    "usaciv-targets-3/g-hud",
    "usaciv-targets-3/g-docs",
    "usaciv-targets-3/ui",
    "usaciv-targets-3/export"
  ],
  "cancel": [],
  "wake": {
    "batches": [
      "usaciv-targets-3"
    ]
  },
  "finish": false
}
