diff --git a/docs/superpowers/plans/2026-11-20-park-range-wilderness-pages.md b/docs/superpowers/plans/2026-11-20-park-range-wilderness-pages.md new file mode 100644 index 0000000..9e26e27 --- /dev/null +++ b/docs/superpowers/plans/2026-11-20-park-range-wilderness-pages.md @@ -0,0 +1,460 @@ +# Park, Range and Wilderness Pages Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add pages for national and provincial parks, mountain ranges and wilderness areas with 3 or more trails, crossed with the existing lists, from a place field on every record. + +**Architecture:** A top-level `places.toml` registry and a `[[place]]` table on each record hold membership. `tools/place_trails.py` (third-party geometry libraries, never part of the build) measures tracks against published outlines and writes both. The build (standard library only) reads the registry and records, and the state-page code is generalised so a place is a kind plus a slug, with states as one kind. + +**Tech Stack:** Python 3.12 standard library for `tools/validate.py` and `web/`; `shapely`, `pyproj`, `pyogrio` for `tools/place_trails.py` only; `unittest`; GitHub Actions. + +**Spec:** `docs/superpowers/specs/2026-11-20-park-range-wilderness-pages-design.md` + +## Global Constraints + +- Membership: at least 1 mile (1.6 km) of the trail's main track inside the outline; alternates do not count. A nested range also gives membership of every `within` parent. +- A place page and a place-plus-list page need 3 or more trails; the 3 counts both bases (`track` and `stated`). A place below 3 gets no page and no link. A place-plus-list page is not built when the list holds every trail on the place page. +- URLs: `/parks//`, `/ranges//`, `/wilderness//`, and `////`. No existing URL changes. Navigation stays as built (`layout.NAV`: Trails, Places, Lists, About). +- The site build and `tools/validate.py` use only the Python standard library. Only `tools/place_trails.py` may use other libraries. +- Every change to a record fact has a `[[history]]` entry (`docs/schema.md`, "The check"). Adding or removing a place on a record is a fact change; a re-run that only changes `km` is not. +- Every ship has a `CHANGELOG.md` entry in the same commit as the ship (standing rule). Land each ship as one squash commit so the entry travels with the code. Commit messages end with the attribution line the session gives. +- Counts shown are exact. A browsing page's first screen holds the filter bar, rows and map; search-oriented text goes below. +- The words `record`, `tier`, `wave`, `held`, `listing`, `entry`, `regions` and the rest of `BANNED` in `web/tests/test_facets.py` never appear on a browsing page. +- The measured `km` inside a place is never shown anywhere, including `[[history]]` text and the page's structured data. +- Never kill a process by name (`pkill`, `killall`). Kill only a PID you started. +- Boundary sources, licences and credits are those of the spec's "Boundary sources" table. Outlines are cached outside the repo and never committed. +- Slugs are unique within a kind, not across kinds. + +## Existing refresh machinery and docs/audit.md + +Found, not invented here: + +- `.claude/skills/refresh-trails/SKILL.md` is the monthly refresh runbook (phases 0 to 9, `light` mode). It verifies every record against its cited pages, re-checks the left-out list, searches for missing trails, updates tracks and emblems, reviews, and applies. `tools/refresh.py` does its mechanical parts (`preflight`, `slices`, `links`, `collect`, `apply`); staging is `refresh//`, which `.gitignore` lists. `tools/tests/test_refresh_skill.py` guards the skill's wording and files. +- Its phase 8 worker (`briefs/apply.md`) applies new records. After this plan a new record fails `validate.py` without `places_checked`, so the brief and the skill gain a step that runs `place_trails.py` for new or changed-track ids. +- The "monthly audit of everything" has no written checklist. `docs/audit.md` becomes it: a plain checklist the owner runs, whose first items are the existing machinery (`/refresh-trails` full or light, `python3 tools/refresh.py links`, `validate.py`, `check_history.py`, both test suites) and whose new items are `place_trails.py --check` and the hand review of `stated` placements. `docs/audit.md` does not duplicate the skill's phases; it points at them. The monthly GitHub workflow in this plan runs only the automatic part. + +## Decisions the design left to the builder + +1. A record's `[[place]]` carries `kind` and `slug` (the design's example omits `kind`, but slugs repeat across kinds). +2. A record carries two top-level fields: `places_checked` (a date) and `places_track` (first 16 hex digits of the SHA-256 of `line.geojson`'s bytes; absent when the record has no track). The validator fails a record whose `places_track` differs from its track's hash. Neither field is a fact in `trail_history`. `place.km` is not a fact; `place.kind`, `place.slug`, `place.basis` and `place.source` are. +3. Parents are never stored on records. The build closes membership over `within` (`places.membership`); a `within` cycle or unknown parent is a validator error. +4. `basis = "stated"` is allowed only on a record with no track; `track` only on one with a track. A trail later given a track must be re-measured, which the `places_track` check forces. +5. Ship 1 validates shape only. The rule "every record has `places_checked`" is switched on by one constant, `check_places.REQUIRE_PLACES_CHECKED`, in ship 2 after the records are written. +6. Registry fields: `slug`, `kind`, `name`, `where`, `within`, `source`, `source_id` (a string, or an array when one page joins units), `source_version`, `box`. `where` is proposed by the tool from the `regions` codes shared by at least half of the place's measured trails and is confirmed by a reviewer. +7. The range allow-list and the extra park units live in `tools/place_allowlist.toml`; wilderness and national parks are taken whole from their sources. Slugs come from the name; a collision within a kind is resolved by appending the state code. +8. On a place page: rows in plain A to Z (the state pages' "wholly in" lead does not apply), `where="all"` filter, map opened on the registry `box`, `summary.facts(place=(name, ()))` so no whole-trail figure is given as the place's. +9. Titles: parks "Long Hikes in {name}"; ranges and wilderness "Long Hikes in {name}, {State}" when `where` has one state, else no suffix; each adds ": N Trails" when it fits (`common.fit_title`). Place plus list: "{lst.noun} in {title name}". +10. Place-plus-list uses `PLACE_MIN = 3` and `browse.shown` (the list must be shown at all), and keeps `SAME_SET` de-duplication. State-plus-list keeps `browse.MIN_SIZE = 5`. +11. Site search: place names join the place text of each row's `data-search` (`searchtext.place_names`). The box filters rows; it does not return pages. +12. The Places hub title stays; its lede gains a sentence and three sections. +13. Ship 4 changes titles of state-plus-list pages where a list's `noun` changes. This is the design's intent ("existing list pages retitled"); the state pages themselves (`/regions//`) stay unchanged. +14. Tool output, proposals and worksheets go to `refresh//places/` (gitignored). Cache: `$PLACES_CACHE`, default `$XDG_CACHE_HOME/longhikes-places`. + +## Review Focus + +- A track in several features or parts whose short pieces inside an outline add up to over 1.6 km (counts); one that skims with 1.5 km in total (does not). Tested in Task 4. +- A place that has exactly 3 trails loses one: its page, its place-plus-list pages, its links and its hub row all go, and counts elsewhere stay exact. Tested in Tasks 7 and 11. +- Two places in different kinds share a slug (`glacier` park, `glacier` wilderness): both pages build, both resolve. Tested in Tasks 2 and 7. +- A `within` chain: a Teton Range trail is on the Rocky Mountains page; a cycle in `within` is refused. Tested in Tasks 3 and 7. +- A trackless trail given a track later: its `stated` entries become invalid and its `places_track` is required. Tested in Task 3. + +--- + +## Ship 1: registry, record field, validator, tool, proposal + +### Task 1: Guard for the existing state pages + +The existing tests (`test_place_order`, `test_place_view`, `test_filter_bar`, `test_search_text`, `test_views`, `test_first_screen`, `test_empty_places`) check pieces of state pages. None compares their built output. Add one, before any code changes. + +**Files:** +- Create: `web/tests/test_state_pages_unchanged.py`, `web/tests/golden/state-pages.json`, `web/tests/make_golden.py` +- Test: the same + +**Interfaces:** +- Produces: `normalise(html: str) -> str` in the test module: removes `data-search="..."` attributes, and removes any `