Build step 3 of 5 — Phase K (umbrella #215)
Build doc: documentation/plans/phase-k-build-plan.md §4 Step K.3
What to build
extract_build_order_signature(game_id) -> list[tuple[str, int]] — returns the first 5 minutes of unit/structure production as [(unit_name, count), ...] ranked by frequency. Read from transitions or decision_audit.json.
Auto-theme function: infer_themes(signature) -> list[str] with 3-5 hardcoded rules:
≥3 Stargate-tech in first 5 min → skytoss
≥2 Robo-tech → tech-rush (Immortals/Colossus path)
Cannons before 2nd base → defensive
≤1 base in first 5 min, ≥10 Zealots → cheese-rush
- (default) →
ground
Existing context
- Game-level data lives in
bots/<version>/data/training.db (transitions table) and bots/<version>/data/decision_audit.json.
- Use whichever is faster to query for unit-production-events. Transitions table likely; one query per game_id.
- 5-minute cutoff: convert from game_loops via
bots.v0.config.GAME_STEP_LOOPS (existing).
Files to modify/create
src/orchestrator/build_order_signature.py — NEW. Pure function reading from training.db.
src/orchestrator/auto_theme.py — NEW. Pure function over the signature output.
tests/test_build_order_signature.py — NEW. Fixture-based.
tests/test_auto_theme.py — NEW. 5 hand-crafted signatures.
Done when
- Signature extraction tests pass on a fixture game ID (synthetic transitions).
- Auto-theme produces sensible labels on 5 hand-crafted signatures.
uv run mypy src --strict + uv run ruff check clean.
Flags
--reviewers code --isolation worktree
Depends on
K.2.
Produces
Two new modules + their tests.
Synced from build doc by /repo-sync
Build step 3 of 5 — Phase K (umbrella #215)
Build doc: documentation/plans/phase-k-build-plan.md §4 Step K.3
What to build
extract_build_order_signature(game_id) -> list[tuple[str, int]]— returns the first 5 minutes of unit/structure production as[(unit_name, count), ...]ranked by frequency. Read fromtransitionsordecision_audit.json.Auto-theme function:
infer_themes(signature) -> list[str]with 3-5 hardcoded rules:≥3 Stargate-tech in first 5 min→skytoss≥2 Robo-tech→tech-rush(Immortals/Colossus path)Cannons before 2nd base→defensive≤1 base in first 5 min, ≥10 Zealots→cheese-rushgroundExisting context
bots/<version>/data/training.db(transitions table) andbots/<version>/data/decision_audit.json.bots.v0.config.GAME_STEP_LOOPS(existing).Files to modify/create
src/orchestrator/build_order_signature.py— NEW. Pure function reading from training.db.src/orchestrator/auto_theme.py— NEW. Pure function over the signature output.tests/test_build_order_signature.py— NEW. Fixture-based.tests/test_auto_theme.py— NEW. 5 hand-crafted signatures.Done when
uv run mypy src --strict+uv run ruff checkclean.Flags
--reviewers code --isolation worktreeDepends on
K.2.
Produces
Two new modules + their tests.
Synced from build doc by /repo-sync