# Sprint 30: Clean Slate — Server Tasks **Goal:** Close Phase 1 wiki quality debt — stereotype correction, data integrity fixes, and atlas regressions — so the wiki stands correct before Phase 1 UI work begins. **Branch:** `server` **Agents:** Dudley (dev), Tyre (arch), Hoshe (QA) ## New Tickets | # | Title | Priority | Blocked by | |---|-------|----------|------------| | #762 | fix(atlas): habitable_planet_count filter uses 'breathable' but proposals use 'standard' | medium | — | | #752 | Add settings.db creation-on-missing routine + gitignore | medium | — | | #744 | Add corridor-status command to atlas CLI | medium | — | Use `tooling/db/ticket show ` for full details. ## Key Decisions - `decisions/architecture.md` — D-094 (chunk size 32, district 256×256), D-139 (composable behavior primitives) - `decisions/scope.md` — D-114 (server simulation is Phase 1 infrastructure) ## Notes ### #762 — habitable_planet_count filter mismatch **File:** `server/src/bin/atlas.rs`, `cmd_commit_system` function, line ~1293. The filter reads: ```rust b.atmosphere.as_deref() == Some("breathable") ``` But all Track B/C/D body catalog proposals use `atmosphere: "standard"`, not `"breathable"`. As a result, `habitable_planet_count` is written as 0 for every committed system regardless of actual habitability. Fix the filter value to `"standard"`. Verify by querying the committed systems table after the fix: `tooling/db/sqlite-query "SELECT gj_id, habitable_planet_count FROM star_systems WHERE habitable_planet_count > 0 LIMIT 10"` should return non-zero counts after recommitting a test system. If both `"breathable"` and `"standard"` are valid atmosphere values that should count as habitable, update the filter to accept both: `matches!(b.atmosphere.as_deref(), Some("breathable") | Some("standard"))`. **Do not retroactively fix existing committed systems** — the fix applies to new commits. If you want to backfill, do it in a separate migration with a clear comment. ### #752 — settings.db creation-on-missing **File:** `server/src/main.rs` lines 158-169, `server/src/settings/` module. `main.rs` calls `SettingsStore::open(&settings_path)` but if `settings.db` does not exist the call logs a warning and continues without settings persistence — it does not crash, but it silently degrades. Improve this: 1. In `SettingsStore::open()` (likely in `server/src/settings/store.rs`), if the file does not exist, create it with default schema. Use `rusqlite::Connection::open()` which creates the file if absent, then run the settings schema `CREATE TABLE IF NOT EXISTS` DDL on first open. 2. Add `settings.db` to `.gitignore` (it is a runtime artifact, not source). 3. Verify: delete `settings.db`, run the server binary, confirm `settings.db` is created and the server starts without warnings about missing settings. **Schema reference:** Check `server/src/settings/types.rs` and `server/src/settings/store.rs` to understand the existing schema and what tables need to be created on first run. ### #744 — corridor-status command for atlas CLI **File:** `server/src/bin/atlas.rs`. The atlas binary already has a subcommand infrastructure (clap-based, see lines 32-40). Add a `corridor-status` subcommand that shows remaining unfinished systems grouped by `geographic_sector` and `hop_distance`. Currently this is done via ad-hoc raw SQL queries. **What to deliver:** - New `CorridorStatus` subcommand struct in atlas.rs - Implementation queries `star_systems` for systems where body catalog is incomplete (no committed bodies, or `status != 'complete'` if such a field exists) - Groups output by `geographic_sector`, then by `hop_distance` within each sector - Output format: plain text table, corridor → hop → count of remaining systems, one row per corridor/hop combination - Add to the atlas binary's help text **Query basis:** The equivalent SQL is approximately: ```sql SELECT geographic_sector, hop_distance, COUNT(*) as remaining FROM star_systems WHERE body_catalog_complete = 0 OR body_catalog_complete IS NULL GROUP BY geographic_sector, hop_distance ORDER BY geographic_sector, hop_distance; ``` Verify the actual column name against `db/schema.sql`. ## Dependency Chain ``` #762 (breathable filter fix) — standalone #752 (settings.db create) — standalone #744 (corridor-status cmd) — standalone ``` All three tickets are parallel tracks. No cross-dependencies. ## PR Workflow When ready to submit, create a PR with `tea` CLI. **All flags are required** to avoid TTY prompts (see CLAUDE.md "Gitea access" section): ```bash tea pr create --repo jpmschweitzer/settled-reach --login schweitz --title "fix(server): Sprint 30 atlas filter, settings.db init, corridor-status cmd" --description "body" --base main --head server ```