Add designs and plans for park, range and wilderness pages and for a season on every trail

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-20 09:16:16 -07:00
1 parent b9977094ba
commit b0ddaeac48
4 files changed
+1440

No files matched your search

@@ -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/<slug>/`, `/ranges/<slug>/`, `/wilderness/<slug>/`, and `/<kind>/<slug>/<list key>/`. 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/<date>/`, 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/<state>/`) stay unchanged.
14. Tool output, proposals and worksheets go to `refresh/<date>/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 `<nav class="region-nav" aria-label="Parks, ranges and wilderness in ...">` block (added in ship 2); later tasks reuse it.
- [ ] **Step 1: Write the golden maker.** `make_golden.py` builds a fixed set of fake records (use `fake()` from `test_hike.py`; 12 records over `US-CO`, `US-UT`, `CA-ON`, one `CA-*`, mixed trails and routes, loops, tracks with `derived["bbox"]` as `test_place_view` sets) and writes `{path: sha256(normalise(html))}` for `regions.region_page` (every state), `regions.group_page` (every group), `regions.regions_index_page`, `regions.empty_place_page("US-HI", ...)` and every `placefacets.page` of `placefacets.plan`.
- [ ] **Step 2: Write the test** `StatePagesUnchangedTest.test_every_state_group_and_state_list_page_is_byte_identical_after_normalising`: rebuilds the same map and `assertEqual`s it to `golden/state-pages.json`, naming each path that differs.
- [ ] **Step 3: Run the maker on current `main`**, before any other change: `python3 web/tests/make_golden.py`. Commit the golden.
- [ ] **Step 4: Take a whole-site baseline** for the ship gates: `python3 web/build.py --out web/.cache/baseline-site` (`web/.cache/` is ignored). Do not delete it until ship 4 lands.
- [ ] **Step 5: Run** `python3 -m unittest discover -s web/tests -p "test_state_pages_unchanged.py"`. Expected: OK.
- [ ] **Step 6: Commit** `test: pin the built state, group and state-list pages`.
### Task 2: Schema, registry file and the record's history fields
**Files:**
- Create: `places.toml` (header comment only, no entries), `tools/tests/test_places_schema.py`
- Modify: `docs/schema.md` (new sections `places.toml` and `[[place]]` on the record, plus `places_checked`, `places_track` under "Top level"; update the fact lists), `tools/trail_history.py` (`_TABLES`, `NOT_FACTS`, `FACTS_TEXT`, `NOT_FACTS_TEXT`), `web/olt/datafiles.py`
- Test: `tools/tests/test_places_schema.py`
**Interfaces:**
- Produces: `trail_history._TABLES[""]` gains `"places_checked", "places_track"`; new `_TABLES["place"] = ("kind", "slug", "basis", "km", "source")`; `NOT_FACTS` gains `"places_checked", "places_track", "place.km"`; `datafiles.places(repo_root) -> list[dict]` (the `[[place]]` tables of `places.toml`).
- [ ] **Step 1: Write failing tests.**
- `test_place_fields_are_schema_fields`: `"place" in H.SCHEMA_FIELDS`, `"place.km" in H.SCHEMA_FIELDS`, `"places_checked" in H.SCHEMA_FIELDS`.
- `test_km_and_stamps_are_not_facts`: `H.is_fact("place.km") is False`, same for `places_checked`, `places_track`; `H.is_fact("place.slug") is True`, `H.is_fact("place.basis") is True`.
- `test_a_km_only_change_needs_no_history`: `H.changed_paths(old, new)` where only `place.km` differs returns `["place.km"]`, and a filter by `is_fact` is empty.
- `test_schema_documents_every_place_field`: every name in `_TABLES["place"]` and `places_checked`, `places_track` appears in `docs/schema.md`.
- `test_facts_text_names_place`: `"place" in H.FACTS_TEXT`.
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_places_schema.py"`; expect FAIL.
- [ ] **Step 3: Implement** the edits above. In `docs/schema.md` document: registry fields (decision 6; `box` is `[west, south, east, north]` rounded to 2 decimals; `km` and `box` are measurements); the record `[[place]]` (`basis` `track` needs `km`, `stated` needs `source` and forbids `km`); `places_checked`, `places_track`; and say `km` is never shown. Add `datafiles.places`.
- [ ] **Step 4: Run** the new test and `python3 -m unittest discover tools/tests`; expect OK.
- [ ] **Step 5: Commit** `feat: schema for place registry and record place fields`.
### Task 3: Validator checks (`tools/check_places.py`)
**Files:**
- Create: `tools/check_places.py`, `tools/tests/test_places.py`
- Modify: `tools/validate.py` (call after `check_datafiles.check_datafiles(...)`), `.github/workflows/validate.yml` (add `python3 -m unittest discover tools/tests -p "test_places*.py"` to the `validate` job)
- Test: `tools/tests/test_places.py` (standard library only; no shapely)
**Interfaces:**
- Produces: `check_places.REQUIRE_PLACES_CHECKED = False`; `check_places.track_hash(path: str) -> str` (16 hex digits); `check_places.check_registry(entries: list[dict], errors: list[str]) -> None`; `check_places.check_record(tid: str, rec: dict, tdir: str, registry: dict[tuple[str, str], dict], errors: list[str]) -> None`; `check_places.check(root: str, trails: list[dict], errors: list[str]) -> None` (loads `places.toml`, builds `registry` keyed `(kind, slug)`, runs both, then the cross-checks).
- [ ] **Step 1: Write failing tests** (each builds small dicts or a temp directory; assert the error text contains the quoted phrase):
- `test_registry_entry_needs_every_field`: missing `box` → "box".
- `test_kind_must_be_park_range_or_wilderness`.
- `test_same_slug_in_two_kinds_is_allowed_and_twice_in_one_kind_is_not`.
- `test_within_names_existing_ranges_and_has_no_cycle`: unknown parent and a two-entry cycle each → "within".
- `test_source_id_is_a_string_or_a_list_of_strings`.
- `test_box_is_west_south_east_north_inside_the_world`.
- `test_record_place_must_be_in_the_registry`: `(kind, slug)` absent → "not in places.toml".
- `test_track_basis_needs_km_and_forbids_source_and_stated_the_reverse`.
- `test_stated_needs_a_source_url_and_a_trackless_record`: a record with `source.line_file` and a `stated` place → "stated".
- `test_a_place_is_listed_once_per_record`.
- `test_every_registry_entry_is_named_by_a_record`: unnamed entry → "named by no record".
- `test_places_track_must_match_the_track_file`: write `line.geojson`, set a wrong `places_track` → "track has changed since".
- `test_a_record_with_a_track_needs_places_track_and_one_without_must_not_have_it`.
- `test_places_checked_required_only_when_switched_on`: with `REQUIRE_PLACES_CHECKED` patched true, a record without it → "places_checked"; false → no error; a bad date → error either way.
- `test_a_trackless_trail_given_a_track_later_is_refused`: stated place plus a track file → error (Review Focus).
- `test_the_real_repository_passes`: `check_places.check(ROOT, trails, errors)` leaves `errors == []`.
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_places.py"`; expect FAIL (module missing).
- [ ] **Step 3: Implement** the signatures above. Follow `check_datafiles.py`: one message per problem, standard library only. `track_hash` hashes the file's bytes with `hashlib.sha256`.
- [ ] **Step 4: Run** the test, then `python3 tools/validate.py`; expect `OK 223 trails`.
- [ ] **Step 5: Commit** `feat: validate places.toml and the record's place fields`.
### Task 4: `tools/place_trails.py` geometry and measuring
**Files:**
- Create: `tools/place_trails.py`, `tools/place_trails.requirements.txt` (`shapely>=2.0`, `pyproj>=3.6`, `pyogrio>=0.7`), `tools/tests/test_place_trails.py`
- Modify: `.gitignore` (add `.venv-places/`)
- Test: `tools/tests/test_place_trails.py` (`unittest.skipUnless(shapely importable)`; no network, tiny synthetic outlines and tracks)
**Interfaces:**
- Produces: `MIN_KM = 1.609344`; `main_track(rec_dir: str) -> shapely.MultiLineString | None` (every feature of the record's `source.line_file` only; `alternates.geojson` and `line-<source>.geojson` are never read); `km_inside(track, outline) -> float` (geodesic length of `track ∩ outline` with `pyproj.Geod(ellps="WGS84")`, summed over all pieces, holes respected); `box_of(outline) -> list[float]` (rounded to 2 decimals); `track_hash(rec_dir) -> str` (same value as `check_places.track_hash`; import it).
- Third-party use: only this file, and only after a guarded import so `python3 tools/place_trails.py --help` explains the install on failure.
- [ ] **Step 1: Write failing tests.**
- `test_pieces_inside_are_summed`: a track of three features, each 0.7 km inside one outline → `km_inside` ≈ 2.1, over `MIN_KM`.
- `test_a_skimming_track_is_under_the_threshold`: 1.5 km inside → below `MIN_KM`.
- `test_a_hole_is_not_inside`: a track wholly in an enclave hole → 0.
- `test_alternates_are_ignored`: a record directory with a long `alternates.geojson` inside and a short main track outside → `km_inside == 0`.
- `test_a_record_with_no_line_file_has_no_track`: `main_track` returns `None`.
- `test_box_of_is_west_south_east_north_rounded`.
- `test_track_hash_matches_the_validators`.
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_place_trails.py"` inside the venv (see Step 3); expect FAIL.
- [ ] **Step 3: Implement.** Install: `python3 -m venv .venv-places && .venv-places/bin/pip install -r tools/place_trails.requirements.txt`. The venv is for this tool only; the site build, `validate.py` and the `site` and `validate` workflow jobs never install it. Intersect in lon/lat; measure on the ellipsoid.
- [ ] **Step 4: Run** with `.venv-places/bin/python -m unittest discover tools/tests -p "test_place_trails.py"`; expect OK. Run `python3 -m unittest discover tools/tests` with the system Python; expect the file skipped, not failed.
- [ ] **Step 5: Commit** `feat: place_trails geometry`.
### Task 5: Outline sources, catalogue and the proposal
**Files:**
- Modify: `tools/place_trails.py`, `tools/tests/test_place_trails.py`
- Create: `tools/place_allowlist.toml` (empty tables, comments only)
**Interfaces:**
- Consumes: Task 4's functions.
- Produces: `SOURCES: dict[str, Source]` for `nps`, `wilderness-connect`, `cpcad`, `gmba-v2`; each `Source` holds `url` (confirmed in Step 3), `licence`, `credit`, and a reader `read(path) -> Iterator[Outline]`; `Outline = (kind, source, source_id, name, state_codes_hint, geometry)`; `fetch(source, cache_dir) -> tuple[str, str]` returns `(path, source_version)` (the publisher's version, else the download date) and never re-downloads a cached file; `catalogue(cache_dir) -> list[Outline]` (parks: NPS unit type National Park plus the allow-list's `[[park]]` extras, which carry two `source_id`s for Sequoia and Kings Canyon; all Wilderness Connect polygons; CPCAD national parks and BC and Alberta provincial parks; ranges only the allow-list's `[[range]]` ids: `gmba_id`, `slug`, `name`, `within`); `propose(records, outlines) -> Proposal`; `render_proposal(p, path) -> None`; subcommands `candidates` and `propose`.
- [ ] **Step 1: Write failing tests** (synthetic outlines through a stub `Source`):
- `test_propose_lists_per_trail_places_and_per_place_trails`.
- `test_a_trail_under_the_threshold_is_not_in_the_place`.
- `test_places_with_fewer_than_three_trails_are_marked_no_page`.
- `test_near_threshold_items_are_listed_first_and_flagged`: any `km` within 0.5 km of `MIN_KM`.
- `test_where_is_the_regions_most_trails_share`.
- `test_a_slug_collision_inside_a_kind_gets_the_state_code`.
- `test_the_proposal_names_every_trail_with_no_track_as_needing_a_person`.
- `test_one_gmba_id_outside_the_allow_list_is_not_proposed_but_is_listed_by_candidates` (`candidates` prints GMBA ranges that 3 or more tracks cross and that are not allow-listed).
- [ ] **Step 2: Run** the new tests; expect FAIL.
- [ ] **Step 3: Implement.** Before coding the readers, open each publisher's download page and confirm the endpoint, file format and field names (NPS boundary service unit-type field; Wilderness Connect; CPCAD's park-type and jurisdiction fields; GMBA v2's id field). The design's findings were not verified by the designer. Write each confirmed fact in the `SOURCES` comments. Proposal output: `refresh/<date>/places/proposal.md` (per trail, then per place) and `proposal.json` (the machine form Task 6 reads). `km` appears in the proposal for reviewers only.
- [ ] **Step 4: Run** the test file in the venv; expect OK.
- [ ] **Step 5: Commit** `feat: place_trails outline catalogue and proposal`.
### Task 6: Writing records and the registry; `stated`, `stamp` and `--check`
**Files:**
- Modify: `tools/place_trails.py`, `tools/tests/test_place_trails.py`
**Interfaces:**
- Consumes: `refresh.Doc` from `tools/refresh.py` (targeted line edits; `set_value`, `append_block`, `append_history`), Task 5's `Proposal`.
- Produces: `apply(proposal_path: str, root: str, today: str) -> list[str]` (ids written); `write_registry(root, entries) -> None` (rewrites `places.toml` sorted by kind then slug, only places some record names; keeps comments above the first entry); `add_stated(root, rid, kind, slug, source_url, quote, today) -> None`; `stamp_none(root, rid, today) -> None`; `check(root, cache_dir) -> list[str]` (differences; empty when none); subcommands `apply`, `stated`, `stamp`, `--check`.
- [ ] **Step 1: Write failing tests** (a temporary repository with two small records):
- `test_apply_adds_place_tables_stamp_and_hash_by_line_edits`: the rest of `trail.toml` is byte-identical.
- `test_apply_adds_one_history_entry_naming_place_with_no_distance_in_it`: `fields == ["place"]`, `asked_by` is `H.OWN_CHECK`, `basis_url` is the source's page, and `change` and `basis` match no `\d\s*(km|mi)`.
- `test_a_rerun_that_only_changes_km_adds_no_history_and_keeps_the_stamp_date_rule`: updates `places_checked` and `km`, adds no entry.
- `test_a_rerun_that_adds_or_removes_a_place_adds_history`.
- `test_registry_lists_only_named_places_and_is_sorted`.
- `test_stated_requires_an_http_source_a_quote_and_a_trackless_record`.
- `test_stamp_none_sets_places_checked_with_no_place_tables_and_no_history`.
- `test_check_reports_a_place_gained_lost_a_moved_boundary_and_a_place_crossing_three_trails`, each as its own line.
- `test_check_exits_nonzero_with_differences_and_zero_without`.
- `test_the_written_records_pass_check_places`: runs `check_places.check` on the temp repository.
- [ ] **Step 2: Run**; expect FAIL.
- [ ] **Step 3: Implement.** `apply` writes top-level `places_checked` and `places_track` with `Doc.set_value`, each `[[place]]` with `Doc.append_block("place", ...)`, and the history with `Doc.append_history`. History date is today; `basis` names the outline source and its `source_version`; `basis_url` is the source's page. `--check` reuses `propose` against the current outlines (cache refreshed), compares to the committed records and registry (including `source_version`), and prints one difference per line.
- [ ] **Step 4: Run** the tool tests in the venv; expect OK.
- [ ] **Step 5: Commit** `feat: place_trails writes records, stated placements and --check`.
### Task 7: First run, proposal review and the ship
This is data work with a gate: nothing is written to records in this ship.
**Files:**
- Modify: `tools/place_allowlist.toml`, `CHANGELOG.md`
- No record changes.
- [ ] **Step 1: Run** `.venv-places/bin/python tools/place_trails.py propose`, then `candidates`. Both write to `refresh/<date>/places/`.
- [ ] **Step 2: Review.** A worker on a different model family from the one that built the tool reads `proposal.md` and reports, for each of: (a) every trail whose proposed places do not fit its own summary, `designation` or ends; (b) every near-threshold item (open the clipped piece in `near-threshold.geojson` and say whether the track really enters); (c) places that would fall under 3 trails; (d) the range candidates (3 or more tracks cross): keep, drop, rename; (e) any source whose field or licence reading looks wrong. The owner reads the reviewer's list and the proposed range allow-list and rules on both. The owner's rulings are recorded in `tools/place_allowlist.toml`.
- [ ] **Step 3: Run** `python3 tools/validate.py` and `python3 -m unittest discover tools/tests`, then `python3 -m unittest discover -s web/tests` and `python3 web/build.py --out _site`; all pass and the site is unchanged.
- [ ] **Step 4: Compare** `diff -r web/.cache/baseline-site _site -q`; expect only files that embed a build date or hash (explain any other).
- [ ] **Step 5: Add the CHANGELOG entry** `## 2026-MM-DD - The place registry and the placing tool`, in the voice of the entries there: for contributors, `places.toml`, the `[[place]]` table, `places_checked`, `place_trails.py` (venv install line), the allow-list; no visitor change.
- [ ] **Step 6: Squash and ship** (one commit with the entry); push. Expected: `validate`, `history` and `site` jobs green.
---
## Ship 2: records written, place pages, hub and cross-links
### Task 8: The place loader (`web/olt/places.py`)
**Files:**
- Create: `web/olt/places.py`, `web/tests/test_places.py`
- Modify: `web/olt/datafiles.py` (already has `places`)
- Test: `web/tests/test_places.py`
**Interfaces:**
- Produces: `PAGE_MIN = 3`; `KINDS: dict[str, Kind]` with `Kind(key, segment, hub_title, noun)` for `park` (`parks`, "Parks"), `range` (`ranges`, "Mountain ranges"), `wilderness` (`wilderness`, "Wilderness areas"); `load(repo_root) -> dict[tuple[str, str], dict]` (registry keyed `(kind, slug)`); `membership(records, registry) -> dict[tuple[str, str], list[dict]]` (each place's records, deduplicated, A to Z by `home.sort_name`, closed over `within`); `collect(records, registry) -> dict[tuple[str, str], dict]` (only places with `PAGE_MIN` or more records; each info dict: `kind`, `slug`, `key` (`"<kind>/<slug>"`), `name`, `where`, `box`, `records`, `path`, `title_name`); `path(kind, slug) -> str` (`/parks/glacier/`); `title_name(info) -> str` (decision 9); `in_state(infos, state_key) -> list[dict]`; `of_record(rec, infos) -> list[dict]` (places of a trail that have a page, by kind then name).
- [ ] **Step 1: Write failing tests** (fixtures from `test_hike.fake`):
- `test_a_range_gets_a_page_at_three_trails_and_not_at_two`.
- `test_stated_and_track_trails_both_count`.
- `test_a_trail_in_a_nested_range_is_on_every_parent` (Teton Range within Rocky Mountains).
- `test_slugs_repeat_across_kinds`: `/parks/glacier/` and `/wilderness/glacier/` both collect, with different records.
- `test_a_parent_is_counted_once_when_a_trail_is_in_two_children`.
- `test_title_name_adds_the_state_for_a_range_with_one_state_only`: "Wind River Range, Wyoming"; a park gives its name alone.
- `test_of_record_leaves_out_a_place_below_the_minimum`.
- [ ] **Step 2: Run** `python3 -m unittest discover -s web/tests -p "test_places.py"`; expect FAIL.
- [ ] **Step 3: Implement**, standard library only. `records.load_record` passes unknown tables through, so no change there; attach nothing to `rec["derived"]`.
- [ ] **Step 4: Run**; expect OK.
- [ ] **Step 5: Commit** `feat: place loader and membership`.
### Task 9: Generalise the state-page code
**Files:**
- Modify: `web/olt/regions.py` (`collect_regions`, `region_page`), `web/olt/home.py` only if a string is baked in
- Test: `web/tests/test_state_pages_unchanged.py` (Task 1) is the guard; add `web/tests/test_place_page.py` in Task 10
**Interfaces:**
- Produces: in `regions.py`, `PageKind` (frozen dataclass: `kicker(info) -> str`, `crumbs(info) -> str`, `lede(info, recs, n_gpx) -> str`, `where: str`, `wholly: bool`, `facts_place(info) -> tuple`, `title_options(info, recs, site) -> list[str]`, `description(info, recs) -> str`); `STATE = PageKind(...)` reproducing today's strings exactly; `regions.place_page(info, records, site, kind, *, facet_pages=(), place_links="") -> (title, description, body, needs_map)`. `region_page(slug, records, site, facet_pages=(), place_links="")` becomes a call to `place_page` with `STATE`. State info dicts gain `"kind": "state"`.
- [ ] **Step 1: Run** the Task 1 guard first; expect OK (baseline).
- [ ] **Step 2: Refactor** `region_page` into `place_page` plus `STATE`; no string changes. `place_links` is HTML put after the existing navs (empty for every state until Task 12).
- [ ] **Step 3: Run** `python3 -m unittest discover -s web/tests`; expect OK, including the guard.
- [ ] **Step 4: Commit** `refactor: state pages built through a page kind`.
### Task 10: Place pages and the page-kind plug-in point
**Files:**
- Create: `web/olt/placepages.py`, `web/tests/test_place_page.py`
- Modify: `web/olt/pages.py` (`render_site`), `web/olt/layout.py` (`NAV_PARENT`), `web/tests/test_facets.py` (`browsing_pages`)
- Test: `web/tests/test_place_page.py`
**Interfaces:**
- Consumes: `places.collect`, `regions.place_page`, `regions.PageKind`.
- Produces: `placepages.PARK`, `RANGE`, `WILDERNESS` (`PageKind`s); `placepages.Built = (path, title, description, body, needs_map, recs)`; `placepages.build(records, site, repo_root) -> list[Built]`. In `pages.py`: `EXTRA_PAGE_BUILDERS = (placepages.build,)`, run after the state and group pages; each `Built` is added with `add(...)` and its path appended to `region_paths` (so it reaches the sitemap). `layout.NAV_PARENT` gains `"/parks/": "/regions/"`, `"/ranges/": "/regions/"`, `"/wilderness/": "/regions/"`.
- [ ] **Step 1: Write failing tests** (fixtures with a three-trail park and a two-trail park):
- `test_a_place_with_three_trails_gets_a_page_and_one_with_two_does_not`.
- `test_the_page_has_the_filter_bar_rows_and_map_before_the_summary`: `body.index('class="finder__bar"') < body.index('class="browse__list"') < body.index('class="browse-about"')` (filter bar only with 10 or more trails, as `home.listing`; the fixture for this assertion has 10).
- `test_the_count_in_the_lede_the_title_and_the_rows_agree`.
- `test_the_map_opens_on_the_registry_box`: `data-bbox` equals the entry's `box`.
- `test_trails_are_in_plain_a_to_z_order`.
- `test_no_banned_word_and_no_internal_km`: with `km = 123.456` set, none of `123.4`, `123.5`, `76.7`, `76.8` (its miles) appears in the page, its structured data or its history-free text; none of the `BANNED` patterns matches `site_words(...)`.
- `test_the_title_follows_the_search_phrasing`: "Long Hikes in the Wind River Range, Wyoming: 5 Trails" (or the shorter option when `common.fit_title` needs it).
- `test_the_breadcrumb_is_trails_places_name` and `test_the_page_is_in_the_sitemap_with_the_newest_trail_date`.
- `test_the_structured_data_is_a_collection_of_the_trails`.
- `test_places_is_the_current_nav_item_on_a_place_page`.
- [ ] **Step 2: Run**; expect FAIL.
- [ ] **Step 3: Implement.** Kicker is the kind's label and the states from `where` (full names). The summary uses `summary.facts(recs, records, place=(name, ()))` and `summary.details(recs)`. Edit `test_facets.BuiltVocabularyTest.browsing_pages` to walk `parks`, `ranges` and `wilderness` as well as `regions` and `lists`.
- [ ] **Step 4: Run** `python3 -m unittest discover -s web/tests`; expect OK (golden still identical: no registry entries yet, no pages).
- [ ] **Step 5: Commit** `feat: park, range and wilderness pages`.
### Task 11: Hub sections, state-page and trail-page links, search, sources
**Files:**
- Modify: `web/olt/regions.py` (`regions_index_page`, `place_links` builder), `web/olt/pages.py` (pass infos), `web/olt/trail.py` (`record_block`'s `where`, and `onward`), `web/olt/searchtext.py` (`place_names`), `SOURCES.md`
- Test: `web/tests/test_place_links.py` (create), `web/tests/test_search_text.py` (extend), `web/tests/test_state_pages_unchanged.py` (extend)
**Interfaces:**
- Produces: `regions.regions_index_page(records, site, infos=())` (adds one `<section class="places__group">` per kind that has pages, each row `name` and exact count); `regions.place_links_for(state_key, infos) -> Markup` (a `<nav class="region-nav" aria-label="Parks, ranges and wilderness in {state}">` block, empty when none); `trail.place_links(rec, infos) -> Markup` (one link per place that has a page, in the glance beside the states); `searchtext.place_names(rec, infos=())` extended so a row's place tier also holds the names of the record's places.
- [ ] **Step 1: Write failing tests.**
- `test_the_hub_lists_each_kind_with_exact_counts_and_hides_empty_kinds`.
- `test_the_hub_still_lists_every_state_group_as_before` (strip the new sections, compare).
- `test_a_state_page_links_to_the_places_in_the_state_with_exact_counts_and_nothing_else_changes`: `normalise(page)` equals the golden for the same page.
- `test_a_state_with_no_place_has_no_block`.
- `test_a_trail_page_links_to_each_of_its_places_that_has_a_page_and_not_to_a_place_below_three`.
- `test_search_text_holds_the_place_names`: `searchtext.attribute` of a trail in the Wind River Range contains "wind river range".
- `test_state_pages_differ_only_in_data_search_and_the_new_block` (this is the reason `normalise` strips `data-search`).
- [ ] **Step 2: Run**; expect FAIL.
- [ ] **Step 3: Implement.** The hub's lede gains: "Parks, mountain ranges and wilderness areas with three or more trails have pages too." Add rows to `SOURCES.md` (existing form: terms quoted, page, date read, credit) for the four sources, after reading each publisher's licence page; the site's sources page renders `SOURCES.md` (`docs.sources_page`), so no code change.
- [ ] **Step 4: Run** `python3 -m unittest discover -s web/tests`; expect OK.
- [ ] **Step 5: Commit** `feat: hub sections, links from state and trail pages, search by place`.
### Task 12: Data entry: place the 124 tracked trails
Data work, batched. Nothing here is code.
**Files:**
- Modify: `places.toml`, up to 124 `<id>/trail.toml` (targeted line edits by the tool)
- [ ] **Step 1: Run the tool for real.** `.venv-places/bin/python tools/place_trails.py propose` (allow-list from Task 7), writing `refresh/<date>/places/proposal.md`.
- [ ] **Step 2: Batch.** Split the proposal into batches of about 15 trails, grouped by the record's first `regions` code (so a reviewer knows the ground), about 8 batches. One reviewer per batch, a different model family from the one that built the tool. A reviewer checks, for every trail in the batch: (a) each proposed place fits the trail's `summary`, `designation`, `start` and `end`; (b) every item within 0.5 km of the threshold, opened in `near-threshold.geojson`; (c) no place whose only evidence is a skimming track; (d) the place names, kinds and `where` (read the outline's source page, not the proposal); (e) a trail the reviewer knows to run through a place the proposal omits is listed in `misses.md` for the owner and not edited. The reviewer's report lists accept, change and reject per trail; rejected ones are listed by `<id> <kind>/<slug>` in `refresh/<date>/places/exclude.txt`.
- [ ] **Step 3: Apply** `.venv-places/bin/python tools/place_trails.py apply refresh/<date>/places/proposal.json --exclude refresh/<date>/places/exclude.txt`. It writes the records and `places.toml`.
- [ ] **Step 4: Verify.** `python3 tools/validate.py` ends `OK 223 trails`; `python3 tools/check_history.py --base origin/main` ends `OK history`; `git diff --stat` touches only `places.toml` and `*/trail.toml`; in any three records the diff is only `places_checked`, `places_track`, `[[place]]` blocks and one new `[[history]]` entry, with no distance in its text.
- [ ] **Step 5: Commit** `data: place the trails with a track`.
### Task 13: Data entry: place the 99 trackless trails
The slow part. A trackless trail's places come from a cited source, never from guesswork.
**Files:**
- Modify: `places.toml`, up to 99 `<id>/trail.toml`
- [ ] **Step 1: Make the worklist.** Use `.venv-places/bin/python tools/place_trails.py worklist` (add as a small subcommand: records with no `source.line_file` and no `places_checked`), writing `refresh/<date>/places/worklist.md` with each id, name, `regions`, `designation`, `hike.start`, `hike.end`, `hike.start_lonlat` and `hike.end_lonlat`, and the registry or outline places within 25 km of either end (`place_trails.py candidates --near <id>`).
- [ ] **Step 2: Batch.** Group by first `regions` code into batches of 12 to 13, about 8 batches, one worker each. A worker fills `refresh/<date>/places/stated-NN.toml`: for each id either `places = [{kind, slug, source, quote}]` (a page naming the trail in or on the place, with the sentence that says so) or `none = true` with `why` (what the record's summary and ends show). Find places with `place_trails.py find "<name>"`, which searches the catalogue and gives `kind`, `slug` and the outline's name. A place not found in the catalogue is reported, not invented.
- [ ] **Step 3: Review.** A different model family opens every cited address, confirms the quote is on the page and that it puts this trail in this place (the trail, not a neighbour; the place, not a gateway town), and spot-checks one in five `none` decisions against the record's summary and the place's outline. It marks each item accept or reject with a reason; rejected items go back to the worker once, then to the owner.
- [ ] **Step 4: Apply** accepted items with `place_trails.py stated --file stated-NN.toml` (one history entry per record, `fields = ["place"]`, `basis` quoting the source's page) and `place_trails.py stamp --file` for the `none` items (sets `places_checked`, no history).
- [ ] **Step 5: Verify** as Task 12, Step 4. Then `python3 tools/validate.py` with `REQUIRE_PLACES_CHECKED` patched on by hand in a scratch run (`python3 -c "import sys; sys.path.insert(0,'tools'); import check_places as C; C.REQUIRE_PLACES_CHECKED=True; import validate; sys.exit(validate.main())"`) ends `OK 223 trails`: every record is stamped.
- [ ] **Step 6: Commit** `data: place the trails with no track from cited sources`.
### Task 14: Enforcement, the audit checklist, the monthly workflow
**Files:**
- Create: `docs/audit.md`, `.github/workflows/places.yml`, `tools/tests/test_audit_doc.py`
- Modify: `tools/check_places.py` (`REQUIRE_PLACES_CHECKED = True`), `.claude/skills/refresh-trails/SKILL.md` (phase 8: a clause pointing at `docs/audit.md` and at placing new records), `.claude/skills/refresh-trails/briefs/apply.md` (a step after step 4: run `place_trails.py` for each new or changed-track id, and `stated` for each new trackless one), `CONTRIBUTING.md` (one sentence: a new record needs its places; run the tool)
- Test: `tools/tests/test_audit_doc.py`, `tools/tests/test_places.py` (flag), `tools/tests/test_refresh_skill.py` (must still pass unchanged)
- [ ] **Step 1: Write failing tests.**
- `test_every_record_must_have_places_checked_now`: `check_places.REQUIRE_PLACES_CHECKED is True` and a record without the date fails.
- `test_the_audit_checklist_exists_and_names_each_step`: `docs/audit.md` contains `/refresh-trails`, `python3 tools/refresh.py links`, `place_trails.py --check`, `python3 tools/validate.py`, `python3 tools/check_history.py`, `python3 -m unittest discover tools/tests`, `python3 -m unittest discover -s web/tests`, and the words "stated" and "by hand".
- `test_the_monthly_workflow_runs_the_check_and_installs_only_the_tool_requirements`: `places.yml` has a `schedule` cron, `tools/place_trails.requirements.txt`, `place_trails.py --check`, and the `validate.yml` file contains no `pip install`.
- `test_the_apply_brief_places_new_records`: `briefs/apply.md` contains `place_trails.py`.
- `test_docs_audit_keeps_the_house_wording`: no dash used as punctuation (`" - "`, `–`, `—`), as `test_refresh_skill.test_house_wording` demands.
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_audit_doc.py"`; expect FAIL.
- [ ] **Step 3: Implement.** `docs/audit.md` is a short numbered checklist: `/refresh-trails` (full quarterly, `light` between), links, `validate.py`, `check_history.py`, both suites, `place_trails.py --check` (and what each kind of difference means and who rules), then "Review the `stated` placements by hand": open each cited page again (no tool can re-measure them), dated in the record's `places_checked`. `places.yml`: `schedule: cron "0 6 1 * *"` plus `workflow_dispatch`; steps: checkout, `setup-python` 3.12, `actions/cache` on the outline cache directory, `pip install -r tools/place_trails.requirements.txt`, `python tools/place_trails.py --check`. A failing run lists the differences in its log.
- [ ] **Step 4: Run** `python3 tools/validate.py`, `python3 -m unittest discover tools/tests`; expect OK (the validator is now strict).
- [ ] **Step 5: Commit** `feat: require places on every record; audit checklist; monthly place check`.
### Task 15: Ship 2 gate
**Files:**
- Modify: `CHANGELOG.md`
- [ ] **Step 1: Run** all checks: `python3 tools/validate.py`, `python3 tools/check_history.py --base origin/main`, `python3 -m unittest discover tools/tests`, `python3 -m unittest discover -s web/tests`, `python3 web/build.py --out _site`.
- [ ] **Step 2: Compare with the baseline.** `diff -r -q web/.cache/baseline-site/regions _site/regions`: the only differing files are the hub, the state pages that gained the new block, and the state-list pages' `data-search` attributes; confirm by `normalise`. Every trail page differs by its place links and search text only; spot-read three.
- [ ] **Step 3: Read the built pages**: one park, one range, one wilderness page at 390, 768 and 1280 px widths and at real viewport heights in a browser (`web/serve.py`): the filter bar, rows and map are on the first screen at each; the summary is below. Check the counts against the number of rows. No `km` of a place, no banned word.
- [ ] **Step 4: Add the CHANGELOG entry**: a visitor-facing bullet (parks, ranges and wilderness areas, how many pages, the hub, links from states and trails, search by place name) and a contributor bullet (every record now carries its places; `place_trails.py`; the monthly check; `docs/audit.md`); exact counts of pages and of trails placed (124 by track, 99 by hand, how many in no place).
- [ ] **Step 5: Squash and ship** with the entry in the one commit.
---
## Ship 3: place-plus-list pages
### Task 16: Plan and build the pages
**Files:**
- Modify: `web/olt/placefacets.py`, `web/olt/pages.py`, `web/olt/placepages.py`, `web/olt/regions.py` (`place_page` nav)
- Test: `web/tests/test_place_facets.py` (create); `web/tests/test_state_pages_unchanged.py`, `web/tests/test_views.py` (must pass unchanged)
**Interfaces:**
- Produces: `placefacets.plan(records)` keeps its signature and result for states. New `placefacets.plan_places(infos, records) -> list[dict]` with the keys `slug`, `info`, `lst`, `recs`, `path` (path `"/<segment>/<slug>/<list key>/"`) and `kind`; a shared `_plan(units, records, min_size, path_of)` used by both, with `PLACE_MIN = 3` and `browse.MIN_SIZE` respectively. `placefacets.page(p, records, site, all_pages)` reads the kind's strings from `p["info"]["kind"]`. `placefacets.pages_by_place` keys by `(kind, slug)` for places, `slug` for states.
- [ ] **Step 1: Write failing tests.**
- `test_a_place_list_page_exists_at_three_trails_not_two`.
- `test_not_built_when_the_list_holds_every_trail_on_the_place_page`.
- `test_not_built_when_the_list_is_not_shown_at_all`: below `browse.MIN_SIZE` or above `MAX_SHARE` of every trail.
- `test_two_lists_with_nearly_the_same_trails_make_one_page` (`SAME_SET`).
- `test_state_plan_is_unchanged_and_still_needs_five`.
- `test_the_path_is_segment_slug_list_key`: `/ranges/wind-river-range/loops/`.
- `test_title_h1_lede_use_the_list_noun_and_the_places_title_name`: "Loop Hiking Trails in Glacier National Park: 4 Trails".
- `test_the_lede_count_and_the_row_count_agree` and `test_there_is_one_more_in_nav_and_a_link_back_to_the_place`.
- `test_the_first_screen_order_and_no_km_and_no_banned_word`.
- `test_the_place_page_links_to_its_list_pages_with_exact_counts`.
- `test_losing_a_trail_removes_the_place_page_the_list_pages_and_every_link` (Review Focus; the place drops to 2, assert all four vanish).
- [ ] **Step 2: Run**; expect FAIL.
- [ ] **Step 3: Implement.** `region_page`/`place_page` gains the "More in {name}" nav through the existing `facet_pages` argument. In `render_site`, add the pages after the place pages and extend `region_paths`.
- [ ] **Step 4: Run** `python3 -m unittest discover -s web/tests`; expect OK, golden identical.
- [ ] **Step 5: Commit** `feat: place-plus-list pages`.
### Task 17: Ship 3 gate
- [ ] **Step 1: Run** the Task 15 Step 1 commands. Expect OK.
- [ ] **Step 2: Compare** `_site/regions` with the baseline as in Task 15 Step 2; nothing new differs. Count the built place-plus-list pages and confirm each has 3 or more rows and fewer rows than its place page.
- [ ] **Step 3: Check** the vocabulary test sees the new directories (`test_facets.browsing_pages`) and passes.
- [ ] **Step 4: Add the CHANGELOG entry** with the exact number of new pages and two or three examples by name.
- [ ] **Step 5: Squash and ship.**
---
## Ship 4: reworded lists
### Task 18: Titles, headings and ledes
URLs and rules do not change; only `title`, `blurb`, `page_title` and `noun` in `web/olt/browse.py`.
**Files:**
- Modify: `web/olt/browse.py` (the entries below), `web/tests/test_state_pages_unchanged.py` and `web/tests/golden/state-pages.json` (regenerate deliberately with `make_golden.py`, then review the diff)
- Create: `web/tests/test_list_wording.py`
**Interfaces:**
- Consumes: `browse.List`, `browse.by_key`, `search_title(n)`.
Wording decided here (each within the vocabulary rules and `common.TITLE_LIMIT` through `fit_title`):
| Key | `page_title` | `noun` (place-plus-list titles) |
|---|---|---|
| `longest` | "Longest Hiking Trails in the US: {n} Trails of 1,000+ Miles" | none |
| `under-100-miles` | "Short Thru-Hikes Under 100 Miles: {n} Long Trails" | "Short Thru-Hikes" |
| `under-200-miles` | "Thru-Hikes Under 200 Miles: {n} Long Trails" (unchanged) | none |
| `a-week-or-less` | "Week-Long Backpacking Trips: {n} Long Trails" | "Week-Long Backpacking Trips" (new) |
| `loops` | "Best Backpacking Loops: {n} Long Trail Loops" | "Backpacking Loops" |
The `title` and `blurb` of each list are reworded to match (for example `loops`: title "Loops", blurb "Backpacking loops: trails that finish where they start."), and `longest` keeps its lede's mile and kilometre figures.
- [ ] **Step 1: Write failing tests.**
- `test_the_five_lists_have_the_new_page_titles`: `browse.by_key(k).search_title(7)` equals the table's text with `{n}` = 7.
- `test_nouns_give_the_place_page_titles`: `placefacets.page` title for a loops list in a park starts "Backpacking Loops in".
- `test_no_banned_word_in_any_list_title_blurb_or_noun`: each `BANNED` pattern against `title`, `blurb`, `search_title(9)` and `noun` of every list.
- `test_list_urls_and_keys_are_unchanged`: `[lst.key for lst in browse.LISTS]` equals the pre-change list, written out in the test, and `browse.path(browse.by_key("loops")) == "/lists/loops/"`.
- `test_every_search_title_is_unique_and_fits` (`test_views` already checks uniqueness; this also checks `common.TITLE_LIMIT` with `fit_title`).
- [ ] **Step 2: Run**; expect FAIL.
- [ ] **Step 3: Implement** the edits. `a-week-or-less` gets a `noun`, so it gains state-plus-list and place-plus-list pages wherever 5 (states) or 3 (places) trails match; the Task 17 count therefore changes only for it.
- [ ] **Step 4: Regenerate the golden** (`python3 web/tests/make_golden.py`) and read `git diff web/tests/golden`: only state-list pages for `loops`, `under-100-miles` and `a-week-or-less` change, and the state pages themselves (`/regions/<state>/`) do not.
- [ ] **Step 5: Run** `python3 -m unittest discover -s web/tests` and `python3 tools/validate.py`; expect OK.
- [ ] **Step 6: Commit** `feat: list titles in the words people search with`.
### Task 19: Ship 4 gate
- [ ] **Step 1: Run** all checks (Task 15 Step 1).
- [ ] **Step 2: Compare** with the baseline: the only differing pages besides earlier ships' are the five lists, their state-list and place-list pages, and the pages that link to them by title. Confirm no URL went missing: `test_facets.test_old_urls_still_built` passes, and `diff <(cd web/.cache/baseline-site && find . -name index.html | sort) <(cd _site && find . -name index.html | sort)` shows only added paths.
- [ ] **Step 3: Add the CHANGELOG entry** naming the five old and new titles.
- [ ] **Step 4: Squash and ship.** Then delete `web/.cache/baseline-site`.
---
## Self-review
- **Spec coverage:** place registry (T2, T3), record field and history (T2, T6), membership rule and parents (T4, T8), boundary sources and cache (T5), tool and its three guards: every push (T3, T14), every month (T6, T14), every audit (T14); pages (T10), hub and links (T11), place plus list (T16), rewording (T18), order (ships 1 to 4), "settled" items: reuse (T9), map box (T2, T10), filters (T10; decision 8), counting (T8), history (T2, T6), reproducing (`source_version`, T5), slugs (T3, T8), plug-in point (T10), builder's tests (T3, T8, T10). Data entry: T7, T12, T13.
- **Types:** `places.collect` info keys (`kind`, `slug`, `key`, `name`, `where`, `box`, `records`, `path`, `title_name`) are the ones `placepages`, `placefacets.plan_places` and `regions.place_page` read; `track_hash` is defined once (`check_places`) and imported by the tool; `normalise` is defined in Task 1 and reused in Task 11.
- **Proportion:** the plan is about three times the spec's length, mostly test names; no function bodies.
@@ -0,0 +1,554 @@
# A Season on Every Trail 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:** Every one of the 223 trail records carries `hike.season`, `hike.months` and where the season came from, and the site says which seasons are estimates.
**Architecture:** One new provenance field pair on `[hike]` (`season_basis`, `season_method`) checked by a new `tools/season.py` that `tools/validate.py` calls. The 109 existing seasons are classified by a proposed table a person reviews. The 114 missing ones are researched in batches, then the remainder are estimated by `tools/estimate_season.py`, whose rule is a pure function over monthly climate normals; the download (`tools/season_climate.py`) is separate and cached outside the repository. Seasons are written through the existing `tools/refresh.py` proposal and apply pipeline, so no record is re-serialised and every change carries a `[[history]]` entry. Site code changes only in the last ship.
**Tech Stack:** Python 3.12 standard library only (as CI has no packages), `unittest`, TOML records, the static site in `web/olt/` with `web/assets/app.js`, GitHub Actions.
**Spec:** `docs/superpowers/specs/2026-11-20-season-on-every-trail-design.md`. The owner has also ruled that a route author's stated season counts as `primary`.
## Commands (all from the repository root)
- Validator: `python3 tools/validate.py` (prints errors; ends with a non-zero exit on any).
- History check: `python3 tools/check_history.py --base main`.
- Tool tests: `python3 -m unittest discover tools/tests` (about 10 s). One file: `python3 -m unittest discover tools/tests -p "test_season_basis.py" -v`.
- Web tests: `python3 -m unittest discover -s web/tests` (builds the site; takes over two minutes, so run it in the background and read the tail). One file: `python3 -m unittest discover -s web/tests -p "test_facets.py" -v`.
- Site build: `python3 web/build.py --out _site`.
- A ship is done only when all five of the above pass on the branch and the ship's `CHANGELOG.md` entry is in the same commit.
## Global Constraints
- Every change to a record fact gets a `[[history]]` entry in the same change (`docs/schema.md`, section `[[history]]`; `python3 tools/check_history.py --base main` must pass). `season_basis` and `season_method` are facts for history purposes.
- Every ship adds a `CHANGELOG.md` entry, newest first, headed `## <date> - <title>`, in the same commit as the ship.
- Counts shown are exact: computed from the records at build time, never typed.
- An estimate must never read as a stated fact: it says "About", carries a note, is marked in rows, and is left out of structured data.
- The words record, tier, wave, held, listing, entry and the other dataset terms in `BANNED` (`web/tests/test_facets.py`) never appear on browsing pages. Site copy in this plan is already worded to avoid them; keep it so.
- Miles and feet come first on the site (`words.length`, `words.elevation` already do this; no new figure is written another way).
- Never kill a process by name or pattern (`pkill`, `killall`). Kill only a PID you started yourself, and only if it must stop.
- Tools use Python standard library only; the estimator runs in CI.
- House wording in new `.md` and workflow text: no em or en dashes, no " - " as punctuation, no all-capital emphasis words.
- A fact found on no acceptable page is never guessed, except season, which may be estimated and must then say so. Acceptable page: the trail's holder or a government page first; else an established hiking reference, guidebook publisher's page or association list. Not AllTrails, forums, social media or wikis.
- Work on a branch, never directly on `main`. Do not push; shipping is the owner's call.
## Decisions the design left open
| Question | Decision |
|---|---|
| Climate source | Settled by Task 11's trial on twelve trails, by licence, then coverage of the US, Canada and Alaska, then fit. |
| Sampling | One point per 50 km of track, at least 3, at most 12, evenly spaced along the track. No track: `hike.start_lonlat` and `hike.end_lonlat`; neither: the centre of the box of the record's first region (`web/place-bounds.toml`), flagged. Elevation per point from `<id>/elevation.json` `profile` (`[km, metres]` pairs); no profile: `high_point_m` for the highest point and the climate source's own cell elevation for the rest. |
| High and low ground | High ground is the sample points at or above the upper quartile of the profile (at least one point); low ground is the points at or below the median. |
| Measures | Per month: mean daily high temperature (`tmax_c`) and mean snow depth (`snow_cm`) at the point's elevation, normals period 1991 to 2020, fixed so a re-run changes only when records, tracks or the rule change. A month is in season when, over the high-ground points (median), `tmax_c >= cold_c_min` and `snow_cm <= snow_cm_max`, and over the low-ground points (median) `tmax_c <= heat_c_max`. If the source has no snow measure, the `snow_cm` test is dropped and `cold_c_min` alone stands in. |
| Fit | `fit_params` grid-searches the three numbers on the sourced trails whose id hashes even; the figure reported and tested is on those that hash odd; the numbers then shipped are refit on all. The figure on the site is the all-trails one, labelled as fitted on the same trails. |
| Bar (owner to confirm) | At least 75 percent of the held-out sourced trails have the estimated season within one month at each end, and at least 90 percent of sourced trails have enough data to be estimated at all. If either fails, estimates are not written (Task 17 stops). |
| Month arcs | A season's span is the smallest circular arc covering all its months (December to February is one arc). Grades: exact (same first and last month), within one (each end within one month), worse. |
| Phrase for an estimate | Built from the months, `"June to September"`; runs separated by "and"; twelve months `"All year"`. The site adds "About". |
| `season_method` | One fixed sentence from `season.method_sentence(...)`, naming the dataset, the period, the number and kind of points and the rule version. |
| Estimate source entry | One `[[hike.source]]` for the climate dataset, `facts = ["season", "months"]`. |
| Replacing an estimate | By hand-edit (a worker deletes the climate source block and `season_method`, sets the basis), because `refresh.py apply` cannot delete a source block. Validator, history check and the audit step guard it. |
| Batch size for research | 10 trails, grouped by region group, so 114 trails make 12 batches. A group of more than 10 is split, one of fewer than 5 is joined to its neighbour. |
| Where research and classification are staged | In the refresh pipeline's staging directory (`refresh/<date>/`, git-ignored), as `proposal.toml` files that `tools/refresh.py collect` and `apply` already handle. |
| Month rows | Every row writes a `Season` fact; CSS hides it unless the list is a month list or a month is chosen. The first screen is unchanged. |
| Leave-out control | A checkbox "Leave out estimated seasons", parameter `stated=1`, disabled until a month is chosen. |
| Home of the researchers' brief | `docs/season-research.md`, linked from `docs/audit.md`, so the audit's fresh search for sources uses the same brief. |
## Shared files (a sibling plan changes some of these at the same time, in another worktree)
Keep every edit to these small and local, and rebase onto the other branch before each ship.
| File | Our edit | Merge risk |
|---|---|---|
| `tools/validate.py` | `HIKE_KEYS` line, one `check_season(...)` call in `check_hike`, ship 4: one more call in `main` | High: edit in `check_hike` body |
| `docs/schema.md` | `[hike]` rows and one sentence in the `[hike]` intro, `[[history]]` fact lists | High |
| `tools/trail_history.py` | `_TABLES["hike"]` tuple, `FACTS_TEXT` | Medium |
| `<id>/trail.toml` (223 files) | `[hike]` lines, `[[hike.source]]` blocks, appended `[[history]]` entries | High where both add history to one file: the later merge keeps both entries in date order |
| `CHANGELOG.md` | One entry at the top per ship | Medium: keep both entries, newest first |
| `docs/audit.md` | `## Seasons` section (create the file if absent; add only the section if present) | Low |
| `.github/workflows/validate.yml` | One added step in the `validate` job | Low |
| `web/olt/browse.py`, `home.py`, `reference.py`, `facets.py`, `trail.py`, `words.py`, `glossary.toml`, `web/assets/app.js`, `web/assets/style.css`, `web/tests/test_facets.py`, `test_views.py`, `test_filter_bar.py` | Ship 4 only | Medium: sibling may add place pages that touch the same lists |
Files only we touch: `tools/season.py`, `tools/estimate_season.py`, `tools/season_climate.py`, `tools/season_batches.py`, `tools/season_classify.py`, `tools/season_fit.json`, `docs/season-research.md`, `.github/workflows/season-check.yml`, the `tools/tests/test_season*.py` files and `tools/tests/fixtures/season/`.
## Review Focus
Inputs and conditions the spec implies but does not name, most likely first. Each has a test in the named task.
1. A season that wraps the year end (a desert trail walked November to March): `months = [11, 12, 1, 2, 3]`, phrase "November to March", arcs and grades must be circular. Tasks 10 and 12.
2. A trail where no month qualifies (arctic, or hot all year), or where all twelve do: never write empty months; an empty result is flagged for hand review, twelve months reads "All year". Task 12.
3. Missing or partial climate data for a point (a download gap): the estimator refuses and lists the trail as "no data"; it never fills in zeros. Tasks 11 and 12.
4. A multi-part track (gaps, `MultiLineString`) or a track with a short profile: sample points still come out spaced along the parts, and a record with no `elevation.json` falls back as decided. Task 13.
5. An estimate leaking as a stated fact: structured data, the in-brief sentence, the summary line, collection tables and search must each show it as an estimate or leave it out. Tasks 21 and 22.
---
# Ship 1: Schema, validator, history tool, classify the 109
Leaves the site building and every test passing. The site changes by one line in "About this data" (Task 6).
### Task 1: Register the fields and write the schema rule
**Files:**
- Modify: `tools/trail_history.py` (`_TABLES["hike"]`, `FACTS_TEXT`)
- Modify: `docs/schema.md` (the `[hike]` intro paragraph, the `season` and `months` rows, two new rows, the `[[history]]` fact list)
- Test: `tools/tests/test_season_fields.py` (create)
**Interfaces:**
- Produces: `trail_history.SCHEMA_FIELDS` contains `hike.season_basis` and `hike.season_method`; both are facts (`trail_history.is_fact(...)` true).
- [ ] **Step 1: Write the failing tests** in `test_season_fields.py` (header as in `tools/tests/test_length_facts.py`):
```python
def test_the_new_fields_are_known_to_the_history_tool(self):
for f in ("hike.season_basis", "hike.season_method"):
self.assertIn(f, H.SCHEMA_FIELDS)
self.assertTrue(H.is_fact(f))
def test_the_facts_text_names_them(self):
self.assertIn("season_basis", H.FACTS_TEXT)
def test_the_schema_documents_them_and_the_estimate_exception(self):
text = open(os.path.join(V.ROOT, "docs", "schema.md"), encoding="utf-8").read()
for needle in ("`season_basis`", "`season_method`", "except season, which may be estimated"):
self.assertIn(needle, text)
```
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_season_fields.py" -v`. Expected: 3 failures.
- [ ] **Step 3: Implement.** Add `"season_basis", "season_method"` after `"months"` in `_TABLES["hike"]`; add them to `FACTS_TEXT`'s hike list. In `docs/schema.md` add rows after `months`: `season_basis` (string, required when `season` is present; one of `primary`, `sources`, `source`, `estimate` with the design's table of meanings, including that a route author's stated season is `primary`) and `season_method` (string, required with `estimate`, refused otherwise: one sentence naming method and inputs). Replace "A fact found on no acceptable page is left out, never guessed." with the same sentence plus "except season, which may be estimated and must then say so". Say in the `season` row that `months` and `season` come together, and that for `estimate` the phrase is built from the months. Say typical time is estimated at page-build time and never stored, while an estimated season is stored.
- [ ] **Step 4: Run** the same command. Expected: PASS. Also `python3 -m unittest discover tools/tests` stays green (schema text is read by `web/olt/reference.py`; Task 24 rewrites that sentence).
- [ ] **Step 5: Commit** `git add tools/trail_history.py docs/schema.md tools/tests/test_season_fields.py && git commit -m "Register season_basis and season_method; schema allows estimated seasons"`
### Task 2: The season checks, not yet wired
**Files:**
- Create: `tools/season.py`
- Test: `tools/tests/test_season_basis.py` (create)
**Interfaces:**
- Produces (all in `tools/season.py`):
- `BASES = ("primary", "sources", "source", "estimate")`
- `PROVENANCE_KEYS = frozenset({"season_basis", "season_method"})`
- `check_season(tid: str, hike: dict, errors: list[str]) -> None`
- `SEASON_REQUIRED = False` (Task 19 sets it true)
Rules `check_season` enforces (error text starts `f"{tid}: hike."`): `season` and `months` appear together; `season_basis` present exactly when `season` is, and one of `BASES`; `season_method` present exactly with `estimate`, non-empty string under 400 characters; for `primary` and `source`, at least one `[[hike.source]]` names `season`; for `sources`, at least two sources with different publishers (case-insensitive) name `season`; for `estimate`, exactly one source names `season` or `months`. If `SEASON_REQUIRED`, a hike without `season` is an error.
- [ ] **Step 1: Write failing tests** in `test_season_basis.py` with a helper `check(**hike_fields)` that builds a hike with sources and returns the errors list. Tests: `test_primary_with_one_naming_source_passes`; `test_season_without_basis_is_an_error` (expects "season_basis"); `test_basis_without_season_is_an_error`; `test_unknown_basis_is_an_error`; `test_months_without_season_is_an_error` and the reverse; `test_sources_needs_two_publishers` (two sources, same publisher, differing case: one error; different publishers: none); `test_source_basis_needs_a_naming_source`; `test_estimate_needs_a_method_and_refuses_one_otherwise`; `test_estimate_with_two_naming_sources_is_an_error`; `test_a_hike_without_season_passes_until_required` and `test_required_flag_makes_it_an_error` (patch `season.SEASON_REQUIRED`).
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_season_basis.py" -v`. Expected: import error.
- [ ] **Step 3: Implement** the module as specified. Stdlib only; no imports from `validate.py` (it will import this module).
- [ ] **Step 4: Run** the same command. Expected: PASS.
- [ ] **Step 5: Commit** `git add tools/season.py tools/tests/test_season_basis.py && git commit -m "Add the season provenance checks (not yet wired)"`
### Task 3: The classification table
**Files:**
- Create: `tools/season_classify.py`
- Test: `tools/tests/test_season_classify.py` (create)
**Interfaces:**
- Consumes: `refresh.load_toml`, `refresh.trail_ids(root)`, `refresh.staging_dir(root, given, create)` from `tools/refresh.py`.
- Produces:
- `suggest_basis(rec: dict) -> tuple[str, str]`: (basis, reason).
- `table(root: str) -> list[dict]` with keys `id, season, months, publishers, urls, n_sources, n_publishers, suggested, reason`.
- CLI `python3 tools/season_classify.py table [--dir DIR]` writes `<staging>/season/classification.csv`.
The suggestion rule (a person reviews every row): among sources naming `season`, `primary` if a source's host equals the host of `hike.official_url` or `source.publisher_url`, or the record is a route (`kind == "route"`) and the source host equals the host of a `[[guide]]` url whose `link_is` is `author` or `publisher`, or `route.creator_words_url`; otherwise `sources` if two or more different publishers name it; otherwise `source`. `reason` says which signal fired.
- [ ] **Step 1: Write failing tests** with small in-memory records: `test_official_site_host_is_primary`; `test_route_author_page_is_primary` (the owner's ruling); `test_two_unrelated_publishers_are_sources`; `test_one_unrelated_page_is_source`; `test_www_and_bare_host_are_the_same_host`; `test_table_covers_every_record_with_a_season` (real records: row count equals the number of records with `hike.season`, currently 109, and every row's `suggested` is in `season.BASES`); `test_table_has_a_reason_for_every_row`.
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_season_classify.py" -v`. Expected: import error.
- [ ] **Step 3: Implement** `suggest_basis`, `table`, and the CSV writer (`csv` module, columns in the order above).
- [ ] **Step 4: Run** the same command. Expected: PASS.
- [ ] **Step 5: Commit** `git add tools/season_classify.py tools/tests/test_season_classify.py && git commit -m "Add the season classification table"`
### Task 4: A person reviews the table
**Files:** none in the repository. Output `refresh/<date>/season/classification.reviewed.csv` (git-ignored).
- [ ] **Step 1:** Run `python3 tools/season_classify.py table` and `wc -l refresh/*/season/classification.csv` (expected: 110 lines, header plus 109).
- [ ] **Step 2:** A worker of a different model family from the one that wrote Task 3 opens, for every row, the page that names the season, and writes `classification.reviewed.csv` with the columns of the table plus `basis` (final) and `note`. It changes any row where the publisher is not the managing body, the association, or (for a route) the author, and says why. It never opens a page that refuses automated reads; it records the refusal.
- [ ] **Step 3:** Put the rows where `basis` differs from `suggested`, and any with a `note`, in front of the owner, with a recommendation on each. The owner's rulings are written into the reviewed file. Do not go on without them.
- [ ] **Step 4:** Check yourself: `python3 - <<'E'` counting rows per `basis` prints four numbers that add to 109 (no `estimate` among them).
### Task 5: Write the 109 bases
**Files:**
- Modify: `tools/season_classify.py` (add `proposals(root, reviewed_csv) -> int`)
- Modify: the 109 `<id>/trail.toml` files, through `tools/refresh.py apply`
- Test: `tools/tests/test_season_classify.py`
**Interfaces:**
- Produces: CLI `python3 tools/season_classify.py proposals --reviewed PATH` writes `<staging>/staged/season-classify/<id>/proposal.toml` and `report.csv`. Each proposal is `kind = "change"` with one `[[proposal.edit]]` (`field = "hike.season_basis"`, `new = <basis>`, `page`, `quote`) and a `[proposal.history]`: `change` "The season is recorded as coming from <plain basis words>.", `basis` naming the publisher and what the page says, `basis_url` the page, `asked_by = "the dataset's own check"`, `fields = ["hike.season_basis"]`.
- [ ] **Step 1: Write the failing test** `test_a_proposal_collects_cleanly_and_applies`: build a temporary copy of one record (use `tempfile`, the helpers in `tools/tests/test_refresh.py`), run `proposals`, `refresh.cmd_collect`, `refresh.cmd_apply` against it, and assert the record gains `season_basis`, gains a history entry whose `fields == ["hike.season_basis"]`, and still parses.
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_season_classify.py" -v`. Expected: the new test fails.
- [ ] **Step 3: Implement** `proposals` (one proposal per row; `quote` is the season phrase the record already holds).
- [ ] **Step 4: Run** the test. Expected: PASS.
- [ ] **Step 5: Apply to the real records.** `python3 tools/season_classify.py proposals --reviewed refresh/<date>/season/classification.reviewed.csv`, then `python3 tools/refresh.py collect`, `python3 tools/refresh.py apply --dry-run`, then `python3 tools/refresh.py apply`. Expected: 109 applied; `git diff --stat` shows 109 `trail.toml` files and no other file; `git diff` of any three shows one added line in `[hike]` and one added `[[history]]` block.
- [ ] **Step 6: Commit** `git add tools/season_classify.py tools/tests/test_season_classify.py */trail.toml && git commit -m "Record where each of the 109 seasons came from"`
### Task 6: Show the basis in "About this data", turn the check on, ship
**Files:**
- Modify: `tools/validate.py` (`HIKE_KEYS`; one `season.check_season(tid, hike, errors)` call at the end of `check_hike`; the coverage loop near the end of `check_hike` skips `PROVENANCE_KEYS`)
- Modify: `web/olt/facets.py` (add `SEASON_BASIS_TEXT` and `season_basis_line(rec) -> str`)
- Modify: `web/olt/trail.py` (`hike_sources_block` appends the line under "Checked ...")
- Modify: `CHANGELOG.md`
- Modify: `.github/workflows/validate.yml` (in `validate` job: `- run: python3 -m unittest discover tools/tests -p "test_season*.py"`)
- Test: `tools/tests/test_season_basis.py`, `web/tests/test_hike.py`
**Interfaces:**
- Consumes: `season.check_season`, `season.PROVENANCE_KEYS`, `season.BASES`.
- Produces: `facets.season_basis(rec) -> str` (`""` when none) and `facets.season_basis_line(rec) -> str`, texts: `primary` "The season comes from the page of the body that manages the trail or, for a route, its author."; `sources` "Two or more pages from different publishers agree on the season."; `source` "One page states the season. It is not the trail's own page."; `estimate` (used from Task 21) the method sentence plus "No page states a season."
- [ ] **Step 1: Write failing tests.** In `test_season_basis.py`: `test_every_record_with_a_season_passes_the_validator` (run `V.check_hike` over every real record; zero errors) and `test_provenance_keys_need_no_source_fact` (a hike with `season_basis` not in any source's facts passes). In `web/tests/test_hike.py`: `test_about_this_data_says_where_the_season_came_from` (a fixture with `season_basis = "primary"` renders the primary sentence inside `hike_sources_block`; one with no season renders no basis sentence).
- [ ] **Step 2: Run** both files. Expected: failures (validator rejects `season_basis` as an unknown field; no sentence).
- [ ] **Step 3: Implement** the edits above. `HIKE_KEYS = HIKE_FACTS | {"checked"} | season.PROVENANCE_KEYS`; `import season` next to the existing sibling imports.
- [ ] **Step 4: Changelog.** Add, headed with the ship date and `Every season now says where it came from`: the 109 seasons on file are now recorded as from the body that manages the trail (N), from several agreeing pages (N), or from one page (N); each trail page's "About this data" says which. Take N from the reviewed table; they must add to 109.
- [ ] **Step 5: Run everything.** `python3 tools/validate.py` (no errors), `python3 tools/check_history.py --base main` (no failures), `python3 -m unittest discover tools/tests` (OK), the full web tests (OK), `python3 web/build.py --out _site` (exit 0). Read the built HTML of two trails' "About this data".
- [ ] **Step 6: Commit** `git add tools/validate.py web/olt/facets.py web/olt/trail.py CHANGELOG.md .github/workflows/validate.yml tools/tests web/tests && git commit -m "Show where a season came from; check it"`. **Ship 1 is complete.**
---
# Ship 2: Research the 114
Each cycle (Task 9) is a ship of its own. The site needs no change: the month lists already count exact numbers (`browse.month_note`), and they grow as seasons land.
### Task 7: The researchers' brief and the batches
**Files:**
- Create: `docs/season-research.md`
- Create: `tools/season_batches.py`
- Test: `tools/tests/test_season_batches.py` (create)
**Interfaces:**
- Produces: `season_batches.missing_ids(root: str) -> list[str]` (records with no `hike.season`, sorted); `season_batches.batches(root: str, size: int = 10) -> list[list[str]]`; `REGION_GROUPS: dict[str, tuple[str, ...]]` (region codes by group: west coast, interior west, southwest, Rockies, plains and midwest, northeast, southeast, Canada west, Canada east and north). CLI `python3 tools/season_batches.py --n 10` writes `<staging>/season/batches/season-NN.txt`, one id per line.
**What `docs/season-research.md` says** (it is the brief; write it for a worker with nothing else):
1. Goal and the rules in Global Constraints that matter to a researcher (acceptable pages, never guess, nothing copied: the wording is ours).
2. For each trail the researcher stages one `[[proposal]]` (kind `change`, format in `.claude/skills/refresh-trails/proposal-format.md`) holding: `hike.season` (a short phrase in our words), `hike.months` (a month counts when about half of it or more is in season; for a trail walked in more than one window list every month), `hike.season_basis` (see below), `hike.checked` (the date the page was read), an appended `hike.source` entry (page `url`, `publisher`, `facts = ["season", "months"]`), the page's own address and a quote of at most 25 words as `quote`, and a `[proposal.history]` with `fields = ["hike.season", "hike.months", "hike.season_basis"]`, `asked_by = "the dataset's own check"`.
3. Basis: `primary` if the page is the managing body's, the trail's own association's, or for a route its author's; `sources` if no such page but two or more pages from different publishers agree; `source` if one other acceptable page; trip reports count only when they speak of the usual season, never of one trip, and then only as `source`. Where pages disagree, the managing body wins, and the phrase may carry the nuance ("northbound starts late February to April").
4. A trail with no acceptable page gets a `report.csv` row `not-found` listing every page and search tried (at least three places). It stays for estimating; a quiet first pass gets a second worker of another model family.
5. What a reviewer checks, every trail, not a sample: the page opens and says the quoted thing; the phrase is in our words; months follow the phrase and the half-month rule; the basis fits the publisher (managing body or not) and the count of different publishers; the page is about this trail and not a section or a different year's event; a disagreement was resolved toward the managing body; no hut or park opening dates stand in for a walking season unless they set it; the `hike.source` entry names `season` and `months`. A different model family from the researcher's. Reviewers write `review/<name>.csv` as the refresh pipeline does.
6. Never kill a process by name; plain User-Agent; do not work round a site that refuses automated reads.
7. "Replacing an estimate" (used by the audit): by hand-edit, in order: set `season`, `months`, `season_basis`; delete `season_method`; delete the climate `[[hike.source]]` block; add the page's source block; append a history entry naming `hike.season`, `hike.months`, `hike.season_basis`, `hike.season_method`; run the validator and history check.
- [ ] **Step 1: Write failing tests.** `test_missing_ids_are_the_records_without_a_season` (tmp root with three records, one with a season); `test_batches_are_at_most_the_size_and_cover_every_id_once`; `test_a_batch_stays_in_one_region_group_unless_joined` (a group of 23 splits into 10, 10, 3, and the 3 joins a neighbouring group's batch only if that batch has room); `test_real_count` (`len(missing_ids(ROOT))` equals the count of records without `hike.season`, and `len(batches(ROOT)) == ceil(n / 10)` or one more); `test_the_brief_names_what_a_researcher_records` (reads `docs/season-research.md`; asserts it contains `hike.season_basis`, `hike.months`, `quote`, `not-found`, `publisher`).
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_season_batches.py" -v`. Expected: import error.
- [ ] **Step 3: Implement** `season_batches.py` and write `docs/season-research.md` as above.
- [ ] **Step 4: Run** the same command. Expected: PASS. Then `python3 tools/season_batches.py --n 10` prints the batch count (about 12) and the total (114 at the time of writing).
- [ ] **Step 5: Commit** `git add tools/season_batches.py tools/tests/test_season_batches.py docs/season-research.md && git commit -m "Add the season research brief and the batches"`
### Task 8: Make `refresh.py apply` take the new fields
The staged proposal format checks field names with `tools/refresh.py` `schema_path` and `validate_proposal`. Task 1 made the names known; this task proves the whole route works for a researched season before the first batch.
**Files:**
- Test: `tools/tests/test_season_batches.py`
- [ ] **Step 1: Write the test** `test_a_researched_season_proposal_collects_and_applies`: in a temporary copy of a record that has `[hike]` but no season, stage a proposal exactly as Task 7's brief describes it (edits adding `hike.season`, `hike.months`, `hike.season_basis`, `hike.checked`; an append to `hike.source`; a history block), run `collect` and `apply`, and assert the resulting record passes `V.check_hike` and `trail_history.check_entries`, and `hike.season` and `hike.months` are in the right order and type.
- [ ] **Step 2: Run** the file. Expected: it fails or passes; if `validate_proposal` rejects the shape (for example `months` as an array in `new`), fix `tools/refresh.py` minimally so it accepts it and keep the test.
- [ ] **Step 3: Run** `python3 -m unittest discover tools/tests`. Expected: OK.
- [ ] **Step 4: Commit** `git add tools/refresh.py tools/tests && git commit -m "Prove a researched season applies through the refresh pipeline"`
### Task 9: Land a group of batches (repeat per ship)
**Files:** the `trail.toml` of the researched trails; `CHANGELOG.md`.
- [ ] **Step 1: Research.** For each batch file in the group (three batches at a time, about 30 trails), start one researcher on the most capable model available with `docs/season-research.md` and the batch file, one batch per researcher, all at once. Do not poll; wait for each.
- [ ] **Step 2: Collect.** `python3 tools/refresh.py collect`. Expected: no problems; every id has a report row; `not-found` rows each list pages. Send back any that do not.
- [ ] **Step 3: Review.** One reviewer of a different model family per batch, following the brief's section 5 for every trail. Read the rejections yourself. Revise and re-review until the `must fix` list is empty.
- [ ] **Step 4: Owner rules** on borderline items: a trail whose only page is a trip report, any disagreement between a managing body and an association, any basis that looks too high. Record rulings in `owner.csv`.
- [ ] **Step 5: Apply.** `python3 tools/refresh.py apply --dry-run`, then `apply`. Expected: one `change` applied per accepted trail; `git diff --stat` matches the accepted list and touches no other trail.
- [ ] **Step 6: Verify.** `python3 tools/validate.py`; `python3 tools/check_history.py --base main`; `python3 -m unittest discover tools/tests`; the full web tests; `python3 web/build.py --out _site`. Read the built "Hiking in July" list page: its note says how many trails have a season exactly as many as the records now carry.
- [ ] **Step 7: Changelog and commit.** Entry headed `Seasons for N more trails`: the exact count added, how many are from the managing body, how many from other pages, and the new "of 223" figure; no figure typed that you did not compute from the records. `git add */trail.toml CHANGELOG.md && git commit -m "Add sourced seasons for N trails"`.
- [ ] **Step 8:** Repeat Steps 1 to 7 until `python3 tools/season_batches.py --n 10` lists only trails whose reports say `not-found`. Those are the trails left to estimate. **Ship 2 is complete when no unresearched batch remains.**
---
# Ship 3: The estimator, its check, the review list
Tools, a workflow and a checklist only. The site is unchanged, so the ship's `CHANGELOG.md` entry is a short "For contributors" one.
### Task 10: Season helpers shared by the checker and the estimator
**Files:**
- Modify: `tools/season.py`
- Test: `tools/tests/test_season_basis.py` (add), `tools/tests/test_season_helpers.py` (create)
**Interfaces:**
- Produces in `tools/season.py`:
- `span(months: list[int]) -> tuple[int, int]`: the smallest circular arc covering the months (first, last).
- `grade(estimated: list[int], sourced: list[int]) -> str`: `"exact"`, `"within1"` or `"worse"`.
- `phrase_for(months: list[int]) -> str`.
- `method_sentence(dataset: str, period: str, n_points: int, kind: str, rule_version: int) -> str`, `kind` one of `"track"`, `"ends"`, `"place"`.
- [ ] **Step 1: Write failing tests** in `test_season_helpers.py`: `test_span_wraps_the_year` (`span([11, 12, 1, 2, 3]) == (11, 3)`); `test_span_of_two_windows_covers_both` (`span([4, 5, 9, 10]) == (4, 10)`); `test_grade_exact`, `test_grade_within_one_at_each_end` (`grade([5,6,7,8,9],[6,7,8]) == "within1"`), `test_grade_worse` (`grade([6,7],[9,10]) == "worse"`), `test_grade_across_the_year_end` (`grade([12,1,2],[1,2,3]) == "within1"`); `test_phrase_runs` (`[6,7,8,9] -> "June to September"`; `[11,12,1,2,3] -> "November to March"`; `[4,5,9,10] -> "April to May and September to October"`; `[7] -> "July"`; all twelve `-> "All year"`); `test_method_sentence_names_dataset_period_and_points`.
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_season_helpers.py" -v`. Expected: failures.
- [ ] **Step 3: Implement** the four functions. `phrase_for` uses `facets.MONTHS` names duplicated as a local tuple (tools do not import the web package).
- [ ] **Step 4: Run** the file. Expected: PASS.
- [ ] **Step 5: Commit** `git add tools/season.py tools/tests/test_season_helpers.py && git commit -m "Add season arcs, grades, phrases and the method sentence"`
### Task 11: Choose the climate source by trial
**Files:**
- Create: `tools/season_climate.py`
- Create: `tools/tests/fixtures/season/` (a small canned response per candidate, three points each)
- Test: `tools/tests/test_season_climate.py` (create)
- Modify: `NOTICE.md` (attribution for the chosen source, one short section)
**Interfaces:**
- Produces: `CACHE_DIR` (default `~/.cache/longhikes-climate/`, overridable by environment variable `LONGHIKES_CLIMATE_CACHE`); `PointNormals` (frozen dataclass: `lat: float`, `lon: float`, `elev_m: float`, `tmax_c: tuple[float, ...]` of 12, `snow_cm: tuple[float, ...] | None`); `fetch_normals(lat: float, lon: float, elev_m: float | None, cache: str = CACHE_DIR, opener=urllib.request.urlopen) -> PointNormals | None` (None when the source has no data for the point; never zeros); `SOURCE: dict` with `name`, `publisher`, `url`, `licence`, `period = "1991-2020"`. An adapter per candidate, each normalising to `PointNormals`: Open-Meteo historical API (ERA5 and ERA5-Land, CC BY 4.0), NOAA 1991 to 2020 normals and SNODAS (public domain, US only), Environment Canada normals (Canada only).
The trial (a command, `python3 tools/estimate_season.py trial`, added in Task 15; this task builds the adapters and the table it prints): twelve sourced trails, chosen by rule: at least two in Canada, one in Alaska or the far north (Akshayuk Pass), three alpine, two desert, two coastal, one prairie, one southeast. For each candidate and each trail it records: did data come back; the estimated months under a coarse default rule; the grade against the sourced months.
Choose by this order: (1) licence: derived monthly figures may be stored and published with attribution, with no non-commercial or private-use clause that excludes a public dataset (read the terms page and quote the line in the docstring); (2) coverage: data for all twelve trails including Canada and the far north, from one source or one per country normalised to `PointNormals`; (3) fit on the twelve; ties go to the simpler. Record the decision, the three tables and the quoted licence lines in the module docstring, and add the attribution to `NOTICE.md`.
- [ ] **Step 1: Write failing tests** in `test_season_climate.py`, all offline using an injected `opener` that returns the fixtures: `test_a_fixture_response_becomes_point_normals` (12 values each, rounded to 0.1); `test_a_second_call_reads_the_cache_not_the_network` (opener called once, assert via a counter); `test_a_point_with_no_data_returns_none_not_zeros`; `test_the_cache_is_outside_the_repository` (`CACHE_DIR` does not start with `V.ROOT`); `test_the_source_says_its_licence_and_period`.
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_season_climate.py" -v`. Expected: import error.
- [ ] **Step 3: Implement** `season_climate.py` (urllib, `json`, a plain User-Agent with no personal or project details, a pause between requests, one request at a time, a cache file per point keyed by rounded coordinates and elevation). Network use happens only when the cache lacks a point.
- [ ] **Step 4: Run** the file. Expected: PASS.
- [ ] **Step 5: Run the trial** once Task 15 exists (`python3 tools/estimate_season.py trial`). If it runs long, start it in the background and wait for it; stop it only by the PID you started. If no candidate passes (1) and (2), stop and tell the owner; do not choose a source that fails the licence test.
- [ ] **Step 6: Commit** `git add tools/season_climate.py tools/tests NOTICE.md && git commit -m "Add the climate download, cached outside the repository, and record the source chosen"`
### Task 12: The rule, as a pure function
**Files:**
- Create: `tools/estimate_season.py`
- Test: `tools/tests/test_estimate_season.py` (create)
**Interfaces:**
- Consumes: `season_climate.PointNormals`.
- Produces: `SamplePoint` (frozen dataclass: `lat`, `lon`, `elev_m`, `km: float | None`); `Params` (frozen: `snow_cm_max`, `cold_c_min`, `heat_c_max`); `RULE_VERSION = 1`; `months_in_season(points: list[PointNormals], params: Params) -> list[int] | None` (sorted month numbers; None when `points` is empty or any point lacks data; an empty list is never returned, it is None with the reason from `why_not(points, params) -> str`).
- [ ] **Step 1: Write failing tests** with hand-made normals (a helper `normals(elev, tmax, snow=None)` builds a `PointNormals`): `test_a_cold_high_point_closes_the_winter` (high ground at or below `cold_c_min` in Jan to Mar drops them); `test_snow_over_the_limit_closes_a_month`; `test_heat_at_the_low_ground_closes_a_summer_month` (a desert trail: low ground at 40 degrees C in Jun to Aug gives `[10,11,12,1,2,3,4]`... assert the wrapped set); `test_high_ground_is_the_upper_quartile_of_points` (four points, only the highest decides snow); `test_no_snow_measure_uses_temperature_alone`; `test_a_wrapped_season_is_returned_sorted` (`[1,2,3,11,12]`); `test_no_qualifying_month_is_none_with_a_reason` (an arctic point: `months_in_season(...) is None`, `why_not(...)` contains "no month"); `test_all_twelve_months_is_allowed` (a mild coast point returns 1 to 12); `test_a_point_with_missing_data_makes_the_trail_unestimable` (a list containing `None` returns None, `why_not` contains "no data").
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_estimate_season.py" -v`. Expected: import error.
- [ ] **Step 3: Implement** `months_in_season` and `why_not` exactly per the decisions table (quantile selection and medians via `statistics`; thresholds compared with `>=` and `<=`; values rounded to 0.1 before comparing so a re-run on cached data is bit-identical). No network access in this module's imports beyond `season_climate` types.
- [ ] **Step 4: Run** the file. Expected: PASS.
- [ ] **Step 5: Commit** `git add tools/estimate_season.py tools/tests/test_estimate_season.py && git commit -m "Add the season rule as a pure function over monthly normals"`
### Task 13: Sample points from a record
**Files:**
- Modify: `tools/estimate_season.py`
- Test: `tools/tests/test_estimate_season.py`
**Interfaces:**
- Produces: `sample_points(root: str, rec: dict) -> tuple[list[SamplePoint], str]`: the points and a kind, one of `"track"`, `"ends"`, `"place"`. Reads `<id>/line.geojson` (LineString or MultiLineString; parts are concatenated in order, gaps ignored), spaces points one per 50 km of track length (min 3, max 12) by cumulative haversine distance, and gets each point's elevation from `<id>/elevation.json` `profile` by interpolating on `km`; with no profile, `hike.high_point_m` for the highest point and `None` elsewhere (the climate adapter then supplies the cell elevation). No track: `hike.start_lonlat` and `hike.end_lonlat` (`"ends"`); neither: the centre of the box in `web/place-bounds.toml` for `rec["regions"][0]` with the country prefix (`"place"`), read with `tomllib`.
- [ ] **Step 1: Write failing tests** with a temporary record directory: `test_a_track_gives_points_spaced_along_it` (a 200 km synthetic line gives 5 points, first at km 0, last within 50 km of the end); `test_a_short_track_still_gets_three_points`; `test_a_very_long_track_is_capped_at_twelve`; `test_a_multipart_track_is_sampled_along_all_parts`; `test_elevation_comes_from_the_profile_by_distance`; `test_a_track_without_a_profile_uses_the_high_point_for_the_top_only`; `test_no_track_uses_the_two_ends` (kind `"ends"`); `test_no_track_and_no_ends_uses_the_place_centre` (kind `"place"`, point inside the box).
- [ ] **Step 2: Run** the file. Expected: new tests fail.
- [ ] **Step 3: Implement** `sample_points`.
- [ ] **Step 4: Run** the file. Expected: PASS.
- [ ] **Step 5: Commit** `git add tools/estimate_season.py tools/tests/test_estimate_season.py && git commit -m "Sample points along a track, from the ends, or from the place"`
### Task 14: Fit the rule against the sourced seasons
**Files:**
- Modify: `tools/estimate_season.py`
- Create: `tools/season_fit.json` (written by the tool, committed)
- Test: `tools/tests/test_estimate_season.py`, `tools/tests/test_season_fit.py` (create)
**Interfaces:**
- Produces: `BAR = {"within1_min": 0.75, "coverage_min": 0.90}`, a figure for the owner to confirm, held in one place; `fit_params(sourced: list[tuple[str, list[PointNormals], list[int]]], grid: dict[str, list[float]]) -> Params`; `report(sourced, params) -> dict` with `n`, `exact`, `within1`, `worse`, `no_data` (counts) and `by_group` (the same, per region group from `tools/season_batches.REGION_GROUPS`); `held_out(tid: str) -> bool` (true when a stable hash of the id is odd; use `hashlib.sha256`, not `hash()`); CLI `python3 tools/estimate_season.py fit` loads every record with a sourced season (`season_basis` not `estimate`), fetches its normals through the cache, grid-searches on the even-hash trails, reports on the odd-hash trails, refits the shipped numbers on all, and writes `tools/season_fit.json`: `computed`, `rule_version`, `dataset`, `period`, `params`, the all-trails report, the held-out report, `bar`, `passes` (true when held-out `within1 / n >= within1_min` and `1 - no_data / n >= coverage_min`).
- [ ] **Step 1: Write failing tests**: `test_held_out_is_stable_and_splits_roughly_in_half` (1000 ids, between 40 and 60 percent); `test_fit_recovers_known_params_from_synthetic_trails` (generate normals and sourced months from a known `Params`; the fit returns values within one grid step); `test_report_counts_grades_and_no_data` (`exact + within1 + worse + no_data == n`; `within1` counts exact too, or state the convention and assert it); `test_passes_is_false_below_the_bar_and_true_at_it` (call the pass logic with 74 of 100 and 75 of 100); `test_the_same_input_gives_the_same_report_twice`. In `test_season_fit.py`: `test_the_committed_fit_has_the_fields_the_site_reads` (keys listed above) and `test_estimates_only_with_a_passing_fit`: if any real record has `season_basis == "estimate"` then `season_fit.json["passes"]` is true and `held_out.within1 / n >= BAR["within1_min"]`.
- [ ] **Step 2: Run** both files. Expected: failures.
- [ ] **Step 3: Implement.** The search is a plain grid over the three numbers with ranges that cover the trial's plausible values (snow 0 to 60 cm in 5 cm steps; cold 0 to 12 degrees C in 1; heat 24 to 40 in 1); the score is mean grade (exact 2, within one 1, worse 0). Run the CLI; read `tools/season_fit.json`.
- [ ] **Step 4: Run** both files. Expected: PASS. If `passes` is false, keep the file (it is the evidence), and say so in the Task 17 gate.
- [ ] **Step 5: Commit** `git add tools/estimate_season.py tools/season_fit.json tools/tests && git commit -m "Fit the season rule against the sourced seasons and record the figure"`
### Task 15: The review list, the proposals and the check
**Files:**
- Modify: `tools/estimate_season.py`
- Test: `tools/tests/test_estimate_season.py`
**Interfaces:**
- Produces: `estimate(root: str, rec: dict, params: Params, fetch=season_climate.fetch_normals) -> dict` with `months`, `phrase`, `method`, `kind`, `flags: list[str]`, `comparable: str`; flags are `no-track`, `place-centre`, `no-data`, `no-month`, `desert`, `coast`, `far-north` (latitude above 60), `few-points`; `comparable` is the id of the nearest sourced trail by distance between sample centres, with its phrase. CLI: `trial`; `propose` (writes `<staging>/season/estimates.csv`: `id, proposed_months, phrase, kind, flags, comparable, comparable_phrase`, and lists every unestimable trail with its reason); `proposals --reviewed PATH` (writes `<staging>/staged/season-estimate/<id>/proposal.toml` per accepted row, `kind = "change"`, edits adding `hike.season`, `hike.months`, `hike.season_basis = "estimate"`, `hike.season_method`, `hike.checked`; an append to `hike.source` (`url`, `publisher` from `season_climate.SOURCE`, `facts = ["season", "months"]`); a history block with `fields = ["hike.season", "hike.months", "hike.season_basis", "hike.season_method"]`, `basis` "No page states a season; it is estimated from climate (rule version N).", `basis_url` the dataset's address, `asked_by = "the dataset's own check"`); `check` (re-runs every record whose basis is `estimate` and the fit; exit 1 with a listed difference when an estimate would now come out different, or the held-out `within1` has fallen by more than 0.02 from `season_fit.json`, or `passes` is false).
- [ ] **Step 1: Write failing tests** with an injected `fetch` returning synthetic normals: `test_a_no_track_record_is_flagged`; `test_a_trail_with_no_data_is_listed_not_estimated`; `test_flags_include_far_north_above_sixty_degrees`; `test_comparable_is_the_nearest_sourced_trail`; `test_propose_writes_one_row_per_unsourced_trail` (csv header and count); `test_check_passes_when_nothing_changed` and `test_check_names_the_trail_whose_estimate_changed` (change one normal; the output lists the id with old and new months); `test_check_fails_when_the_fit_got_worse`; `test_proposals_collect_cleanly` (collect a staged proposal with `tools/refresh.py`, as in Task 5); `test_nothing_in_estimate_touches_the_network_without_a_fetch` (the default `fetch` is only used when none is passed; assert with a fetch that raises).
- [ ] **Step 2: Run** the file. Expected: failures.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** the file and `python3 -m unittest discover tools/tests`. Expected: OK.
- [ ] **Step 5: Commit** `git add tools/estimate_season.py tools/tests && git commit -m "Add the estimate review list, the proposals and the check"`
### Task 16: The monthly workflow, the audit checklist, ship
**Files:**
- Create: `.github/workflows/season-check.yml`
- Create or modify: `docs/audit.md` (create if absent, with a one-paragraph introduction saying it is the checklist for the roughly monthly audit of everything, that `/refresh-trails` (`.claude/skills/refresh-trails/SKILL.md`) is the step for pages and records, and one `## <name>` section per topic; if the file exists, add only the `## Seasons` section and touch nothing else)
- Modify: `.github/workflows/validate.yml` (already has the season step from Task 6)
- Modify: `CHANGELOG.md`
- Test: `tools/tests/test_season_audit.py` (create)
**Interfaces:** `docs/audit.md` section `## Seasons` has two numbered steps: (1) run `python3 tools/estimate_season.py check` and act on what it lists; (2) for every record whose `season_basis` is `estimate` (list them with `python3 tools/estimate_season.py estimates`), search afresh for a page that states a season, using `docs/season-research.md`, and replace the estimate when one turns up. `estimate_season.py estimates` prints the ids of records with basis `estimate`, one per line.
The workflow: triggers `schedule` (monthly: `cron: "17 6 1 * *"`) and `workflow_dispatch`; one job on `ubuntu-latest`, Python 3.12; `actions/cache` on `~/.cache/longhikes-climate` keyed by month; runs `python3 tools/estimate_season.py check`; a failure fails the job so the owner is notified.
- [ ] **Step 1: Write failing tests** in `test_season_audit.py`: `test_the_audit_checklist_has_a_seasons_section_naming_both_steps` (`docs/audit.md` exists, contains `## Seasons`, `estimate_season.py check`, `docs/season-research.md`); `test_the_commands_it_names_exist` (the `estimate_season.py` parser has the subcommands `check` and `estimates`); `test_the_monthly_workflow_runs_the_check_on_a_schedule` (text of `season-check.yml` contains `schedule`, `workflow_dispatch`, `estimate_season.py check`); `test_house_wording_in_the_audit_doc` (no em or en dash, no " - " outside code).
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_season_audit.py" -v`. Expected: failures.
- [ ] **Step 3: Implement** the files and the `estimates` subcommand.
- [ ] **Step 4: Changelog.** Entry headed `A written audit checklist, and a monthly check of estimated seasons`, "For contributors" style: what the checklist is, that the check runs monthly and fails with a list, no site change.
- [ ] **Step 5: Run everything** (the five commands). Also `python3 tools/estimate_season.py check` once by hand with a warm cache; expected: exits 0 when there are no estimates yet and says so.
- [ ] **Step 6: Commit** `git add .github docs/audit.md tools CHANGELOG.md && git commit -m "Check estimated seasons monthly, and write the season steps into the audit"`. **Ship 3 is complete.**
---
# Ship 4: Write the estimates, change the site
### Task 17: The gate, the run, the review
**Files:** none in the repository. Output `refresh/<date>/season/estimates.reviewed.csv`.
- [ ] **Step 1: Gate.** `python3 tools/estimate_season.py fit`, then read `tools/season_fit.json`. If `passes` is false, stop here: tell the owner the held-out figure, the bar, and the groups that fail, and do not run Step 2. The estimate is not shipped below the bar. (The bar is the figure in `BAR`: 75 percent within one month at each end, held out, and 90 percent of sourced trails estimable; the owner confirms it before this ship starts.)
- [ ] **Step 2:** `python3 tools/estimate_season.py propose`. Expected: one row per trail still with no season; every other row flagged or clean; trails with `no-data` or `no-month` listed with reasons.
- [ ] **Step 3: Review.** A person (the owner, with a worker preparing the comparison) reads every row. Rows flagged `no-track`, `place-centre`, `desert`, `coast`, `far-north` or `few-points` are hand checked against the `comparable` sourced trail and the high-ground and heat reasoning; a row that does not hold up is corrected (months edited in the reviewed file, with a `note`) or, for an unestimable trail, researched again by hand under `docs/season-research.md`. An edited row keeps `season_method` truthful: the method sentence then ends "and adjusted by hand against <comparable>". Write `estimates.reviewed.csv`.
- [ ] **Step 4:** Check yourself: the reviewed file has a row for every trail with no season, and none has empty months.
### Task 18: Write the estimates
**Files:** the remaining `trail.toml` files, through `tools/refresh.py apply`.
- [ ] **Step 1:** `python3 tools/estimate_season.py proposals --reviewed refresh/<date>/season/estimates.reviewed.csv`, then `python3 tools/refresh.py collect` (no problems), `apply --dry-run`, `apply`.
- [ ] **Step 2: Check.** `git diff --stat` lists exactly the reviewed trails; read three hunks: each adds `season`, `months`, `season_basis = "estimate"`, `season_method`, a climate `[[hike.source]]` block, and one `[[history]]` block naming four fields. `python3 tools/validate.py` still passes (the validator does not yet require a season for every record).
- [ ] **Step 3: Commit** `git add */trail.toml && git commit -m "Estimate a season for the trails no page gives one for"`
### Task 19: Every record has a season; the validator says so
**Files:**
- Modify: `tools/season.py` (`SEASON_REQUIRED = True`; `CLIMATE_HOSTS` from `season_climate.SOURCE`)
- Modify: `tools/validate.py` (nothing more than the existing call; confirm a record with no `[hike]` is also an error when seasons are required: in `main`, one line `season.check_present(tid, rec, errors)` next to the other `check_*` calls)
- Test: `tools/tests/test_season_basis.py`, `tools/tests/test_season_records.py` (create)
**Interfaces:**
- Produces: `season.check_present(tid: str, rec: dict, errors: list[str]) -> None` (error when `rec` has no `hike` or no `hike.season`); `season.CLIMATE_HOSTS: frozenset[str]` (host of the chosen climate source). `check_season` additionally requires, for `estimate`, that the one source naming `season` has a host in `CLIMATE_HOSTS`, and for every other basis that no source naming `season` or `months` has one.
- [ ] **Step 1: Write failing tests.** `test_season_records.py` over the real records: `test_every_record_has_season_months_and_a_basis`; `test_the_basis_fits_the_sources` (each record passes `season.check_season`); `test_every_estimate_has_a_method_and_a_climate_source`; `test_no_sourced_season_cites_climate_data`; `test_no_record_says_a_season_is_missing` (no record's `hike` summary or caution contains "no season"); `test_the_estimated_phrase_is_built_from_its_months` (`hike.season == season.phrase_for(hike.months)` for every estimate). In `test_season_basis.py`: `test_a_record_with_no_hike_is_an_error_when_required` and `test_estimate_from_a_non_climate_host_is_an_error`.
- [ ] **Step 2: Run** `python3 -m unittest discover tools/tests -p "test_season*.py" -v`. Expected: failures on the new tests.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** the same command, then `python3 tools/validate.py`. Expected: PASS, no errors.
- [ ] **Step 5: Commit** `git add tools && git commit -m "The validator requires a season on every trail"`
### Task 20: The season as the site reads it
**Files:**
- Modify: `web/olt/facets.py`
- Test: `web/tests/test_facets.py` (add), `web/tests/test_hike.py`
**Interfaces:**
- Produces in `facets.py`: `season_estimated(rec) -> bool` (true when `hike.season_basis == "estimate"`); `season_text(rec)` returns `"About " + phrase` for an estimate (phrase left as it is after "About", so "About June to September"), unchanged for others; `season_note(rec) -> str` (`""` unless estimated; else "Estimated from climate at the trail's elevation. No source states a season. People do walk it outside these months."); `SEASON_STATED_NOTE` not needed.
- [ ] **Step 1: Write failing tests** (fixtures built like `fake(...)` in `web/tests/test_views.py`): `test_an_estimated_season_reads_about_and_has_a_note`; `test_a_stated_season_is_unchanged_and_has_no_note`; `test_an_estimated_all_year_season_reads_about_all_year`; `test_season_estimated_is_false_without_a_basis`.
- [ ] **Step 2: Run** `python3 -m unittest discover -s web/tests -p "test_facets.py" -v`. Expected: the new tests fail.
- [ ] **Step 3: Implement** in `facets.py` (`"About"` is not doubled when the phrase already starts with "about", as `time_text` does).
- [ ] **Step 4: Run** the file. Expected: PASS.
- [ ] **Step 5: Commit** `git add web/olt/facets.py web/tests && git commit -m "Say an estimated season is about, with a note"`
### Task 21: Trail page, summary, structured data
**Files:**
- Modify: `web/olt/trail.py` (`season_sentence`, `glance`)
- Modify: `web/olt/summary.py`
- Modify: `web/olt/seo.py` (the `Usual season` property, near line 287)
- Modify: `web/olt/facets.py` (`season_basis_line` for `estimate`)
- Test: `web/tests/test_hike.py`, `web/tests/test_trust.py`, `web/tests/test_structured_data.py`
**Behaviour:**
- Glance: the Season row passes `facets.season_note(rec)` as the row's note; `SEASON` is removed from the `missing` list that writes "... not on file for this trail yet."
- In brief (`season_sentence`): an estimate returns `("estimate", "No source gives a season; the climate suggests about June to September")` (months phrase from `hike.season`), and the caller adds the full stop; it is never joined to the GPX clause with "and".
- Summary line (`summary.py`, line 149 area): "Season: About June to September, estimated from climate."
- Structured data: `Usual season` is emitted only when `hike.season_basis != "estimate"`.
- About this data: `season_basis_line` for `estimate` is the record's `season_method` followed by "No page states a season."
- [ ] **Step 1: Write failing tests.** `test_hike.py`: `test_an_estimated_season_row_carries_the_note`; `test_a_sparse_trail_no_longer_says_season_is_missing` (the fixture at lines 135 and 166 now expects "Terrain, walking and permits are not on file for this trail yet." and no "Season ... not on file"); `test_about_this_data_gives_the_method_for_an_estimate`. `test_trust.py`: `test_an_estimated_season_sentence_says_no_source_gives_one` (and the in-brief paragraph of every estimated real record contains "No source gives a season"); rewrite the check at lines 222 to 236 so it asserts that every real record's in-brief paragraph has a season sentence, not that records without one lack it. `test_structured_data.py`: replace line 214 with `("Usual season", None) in props == bool(h.get("season") and h.get("season_basis") != "estimate")`; add `test_no_estimated_season_appears_in_structured_data`.
- [ ] **Step 2: Run** the three files. Expected: failures.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** the three files. Expected: PASS.
- [ ] **Step 5: Commit** `git add web && git commit -m "Show an estimated season as an estimate on the trail page, and not in structured data"`
### Task 22: Month lists, rows, collection tables
**Files:**
- Modify: `web/olt/browse.py` (`BROWSE` blurb at the `month` group, `_month_list`, `month_note`)
- Modify: `web/olt/home.py` (`entry`: a `Season` fact and `data-estimate`)
- Modify: `web/olt/standing.py` (`season_cell`, `figures_note`)
- Modify: `web/assets/style.css` (hide `.entry__season` unless `[data-season-shown]`)
- Test: `web/tests/test_views.py`, `web/tests/test_facets.py`, `web/tests/test_filter_bar.py`
**Behaviour and copy:**
- Group blurb: "Trails normally hiked in the month. Estimated seasons are marked."
- `_month_list` description: "Trails normally hiked in {name}. Estimated seasons are marked."
- `month_note(name)` returns "A source states the season for X of these. For the other Y it is estimated from climate, and marked." (X, Y computed; with Y zero: "A source states the season for all X."; with X zero: "No source states the season for these, so each is estimated from climate.")
- Row: `<div class="entry__season"><dt>Season</dt><dd>{season_text}<small class="entry__est">estimate</small></dd></div>` (the small label only when estimated), `data-estimate="yes"` on the row when estimated, nothing when not. `listing()` sets `data-season-shown` on the results container for month lists; Task 23's script sets it when a month is chosen.
- `standing.season_cell(rec)` returns `facets.season_text(rec)` ("Not on file" removed); `figures_note` adds "Seasons that start with “About” are estimated from climate (N of these)."
- [ ] **Step 1: Write failing tests.** `test_views.py`: rewrite `MonthListTest.test_a_month_needs_eight_trails_and_says_how_many_have_a_season` as `test_a_month_note_counts_stated_and_estimated_exactly` (ten stated and five estimated in July: the note contains "A source states the season for 10 of these. For the other 5 it is estimated from climate, and marked."), plus `test_a_month_list_with_no_estimates_says_so` and `test_the_month_blurb_no_longer_says_only_some_trails`. `test_facets.py`: `test_a_row_marks_an_estimated_season` (the row HTML contains `data-estimate="yes"` and `entry__est">estimate`; a stated one contains neither); `test_the_season_fact_is_hidden_unless_a_month_is_shown` (CSS text contains the `[data-season-shown]` rule). `test_filter_bar.py`: `test_standing_tables_mark_an_estimated_season` (collection table cell reads "About June to September"). Run `BuiltVocabularyTest.test_no_banned_word_on_a_browsing_page` after.
- [ ] **Step 2: Run** the three files. Expected: failures.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** the three files. Expected: PASS.
- [ ] **Step 5: Commit** `git add web && git commit -m "Month lists, rows and tables include every trail and mark estimates"`
### Task 23: The filter bar
**Files:**
- Modify: `web/olt/home.py` (`finder_form`: the checkbox inside the `data-facet="month"` field; `results()`: remove the `unseasoned` note)
- Modify: `web/assets/app.js` (state `stated`; `FacetCount.passes`; URL parameter; remove the `unseasoned` block near lines 2062 to 2071, 2464 to 2471 and 2502 to 2509; set `data-season-shown` when a month is chosen)
- Test: `web/tests/test_filter_bar.py`, `web/tests/test_facets.py`
**Behaviour:** a checkbox `<input type="checkbox" name="stated" value="1">` labelled "Leave out estimated seasons", inside the month field, `disabled` until a month is chosen; rows carry `data-estimate`; with a month and `stated` on, `FacetCount.passes(d, s, 'month')` is false for a row whose `d.estimate` is true; the address carries `?month=7&stated=1`; the count words and the per-month numbers ignore estimated rows exactly when `stated` is on (they come from `passes`). The "N trails with no season on file" note, the "Show them" button and their script are gone.
- [ ] **Step 1: Write failing tests.** Delete `UnseasonedNoteTest` and replace with `LeaveOutEstimatesTest`: `test_the_month_field_has_the_checkbox_and_it_starts_disabled`; `test_the_results_have_no_unseasoned_note` (`'data-unseasoned'` absent from `home.results(recs, finder=True)`); under node (skip when node is missing, as the file does): `test_with_stated_on_estimated_rows_leave_the_month` and `test_counts_follow_it` (rows `{months: [7], estimate: true}` and `{months: [7], estimate: false}`; month 7 count is 2 with it off and 1 with it on; the shown count matches `sum(...)`, as `test_the_number_is_the_trails_that_pass_everything_else...` does). In `test_facets.py`: drop `test_a_month_row_with_no_season_is_left_out...` assertions that pin "no season on file" only if they fail, keeping the generic mechanism test on `terrain`; assert `data-months=""` is no longer needed for real records (every real row has months).
- [ ] **Step 2: Run** the two files. Expected: failures.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** the two files. Expected: PASS.
- [ ] **Step 5: Commit** `git add web && git commit -m "Let the month filter leave out estimated seasons; drop the no-season note"`
### Task 24: Reference page, glossary, schema wording
**Files:**
- Modify: `web/olt/reference.py` (the coverage rows around line 123; the "Season and high point" section around line 147)
- Modify: `glossary.toml` (the `season` term)
- Modify: `docs/schema.md` (only if Task 1's `season` meaning needs the phrase the reference page quotes)
- Test: `web/tests/test_trust.py` or `web/tests/test_pages.py` (whichever holds the reference page assertions; find with `grep -n "reference\\." web/tests/*.py`)
**Behaviour:**
- Coverage table: the single "A season" row becomes "A season a source states" and "A season estimated from climate", each counted from the records (their two counts add to 223).
- "Season and high point" section: drops "Not every record has them, so a page built from them says how many records it covers." for season; adds a paragraph: "Every trail has a season. Where a page states one, the season is that page's. Where none does, the season is estimated from climate at the trail's elevation, shown as 'About' with a note, and marked in lists. Checked against the seasons that pages do state, the estimates for N of M trails (P percent) come within a month at each end of the stated season." N, M, P come from `tools/season_fit.json` at build time, labelled as fitted on the same trails; the paragraph says it again as "This is a measure of fit, not a promise for a single trail."
- Glossary `season`: "The months in which the whole trail is usually walked. Where a page states them, that is shown. Otherwise they are estimated from climate at the trail's elevation, and the page says so." (Remove "Only some records state one.")
- [ ] **Step 1: Write failing tests:** `test_the_reference_page_counts_stated_and_estimated_seasons` (the two rows' counts equal the real counts and add to the number of trails); `test_the_reference_page_gives_the_fit_from_the_fit_file` (the page contains the figures in `season_fit.json`); `test_the_glossary_no_longer_says_only_some_records_state_a_season`; `test_no_page_says_only_some_trails_have_a_season` (build once and search the built HTML of every page for "Only some trails have a season" and "season on file"; none).
- [ ] **Step 2: Run** the file. Expected: failures.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** the file. Expected: PASS.
- [ ] **Step 5: Commit** `git add web glossary.toml docs && git commit -m "Reference page and glossary describe seasons and the fit of the estimates"`
### Task 25: Verify and ship
**Files:** `CHANGELOG.md`.
- [ ] **Step 1: Changelog.** Entry headed `Every trail now has a season`: exact counts of stated and estimated seasons (computed, not typed), what "About" means, that estimated seasons are marked in lists and left out of structured data, that the month filter can leave estimates out, the fit figure from `tools/season_fit.json`, and that the month lists now include every trail.
- [ ] **Step 2: Run everything.** `python3 tools/validate.py`; `python3 tools/check_history.py --base main`; `python3 -m unittest discover tools/tests`; the full web tests (includes `BuiltVocabularyTest`, which fails on any banned word on a browsing page); `python3 web/build.py --out _site`.
- [ ] **Step 3: Read the built pages.** Three trails (one primary, one sourced from one page, one estimated with no track), the "Hiking in July" list, the home page with `?month=7` (use the built `_site/index.html` and read the form), the reference page. Check: miles and feet first; no estimate without "About" and a note; no "no season on file" anywhere; counts equal the records'.
- [ ] **Step 4: Commit** `git add CHANGELOG.md && git commit -m "Every trail has a season"`. **Ship 4 is complete.**
---
## Self-review
**Spec coverage.**
- Schema, `season_basis`, `season_method`, the estimate exception: Task 1. Validator rules (count fits basis, exempt from the facts rule, `season` with `months`, estimate's only source is climate): Tasks 2, 6, 19. History: Global Constraints, Tasks 5, 9, 15, 18.
- Step 1 classify the 109 (proposed table, person reviews): Tasks 3 to 5. Step 2 research the 114: Tasks 7 to 9 (batch size 10, what is recorded, what is acceptable, what a reviewer checks). Step 3 estimator: Tasks 10 to 16 (every push by the validator in Task 19, every month by Task 16's workflow, every audit by `docs/audit.md`); where, elevation, climate, rule, check, review list: Tasks 11 to 15; the bar and the "not shipped" gate: Tasks 14 and 17; climate source by trial: Task 11.
- Site: trail page, rows, month lists, blurb, note and button removal, filter, glossary, reference, structured data: Tasks 20 to 24. Tests rewritten, not patched: Tasks 21 to 23.
- Order, four ships with changelog entries: Tasks 6, 9, 16, 25.
**Step scan.** Every code step names a file and signature; tests name their assertions; commands and expected results are given.
**Type consistency.** `PointNormals` is defined in Task 11 and used in Tasks 12, 14, 15; `SamplePoint`, `Params` in Task 12; `season.BASES`, `PROVENANCE_KEYS`, `check_season`, `SEASON_REQUIRED` in Task 2 and used in 6 and 19; `phrase_for`, `span`, `grade`, `method_sentence` in Task 10 and used in 14, 15 and 19; `facets.season_basis_line` in Task 6 and extended in Task 21; `BAR` in Task 14 and used in 17.
**Proportion.** About three times the spec's length; the extra is the data tasks and test names, with no function bodies.
## Not verifiable from here
- The web test suite was not run to completion in planning (it takes over two minutes); the tool tests passed (322).
- Whether `refresh.py` `validate_proposal` accepts an array value for `hike.months` in an edit is proved or fixed by Task 8.
- The climate sources' current terms, rates and coverage, and whether any passes the bar, are unknown until Tasks 11 and 14. The 75 percent bar is a proposal for the owner to confirm.
- `grep -n "reference\\." web/tests/*.py` (Task 24) must find where the reference page is tested; none was located during planning.
@@ -0,0 +1,223 @@
# Park, range and wilderness pages
Design, 2026-11-20. Status: awaiting approval.
## Intent
People search for long hikes by named place: "wind river range wyoming",
"backpacking trips in glacier national park", "best backpacking loops in the
adirondacks". The site answers by state and province only. This adds pages for
national parks, mountain ranges and wilderness areas, so a search for a place
lands on the long trails in it. The aim is reach for free information, not
revenue.
## Goals
- A page for every national park, mountain range and wilderness area that has
3 or more trails.
- Each of those pages crossed with the existing lists (loops, length bands,
time bands and so on) wherever 3 or more trails match, as the state pages
are today.
- Existing list pages retitled and re-led to match how people ask.
- Every trail placed, including the 99 with no track.
## Non-goals
- National forests, gateway towns, counties, beginner or no-permit lists.
- New rule-based lists (high routes, winter, desert, coastal).
- Showing boundary outlines on maps.
- Any planning feature. This is discovery.
## Anti-goals
- A page that lists one or two trails, or that repeats another page's set
under a different name.
- A trail on a place page because its track skims the boundary.
- A place assignment nobody can check.
- Breaking any existing URL.
## Approaches considered
1. **A field on each record, filled from boundaries (chosen).** Each record
lists the places it is in. A tool fills the list by crossing tracks with
published outlines; trails without a track are filled by hand from a cited
source. Covers every trail and each assignment can be reviewed.
2. **Computed at build only.** Nothing stored. No hand entry, but 99 trails
could never appear on a place page.
3. **Hand-named sets in `collections.toml`.** Simple, but nothing checks an
assignment against a boundary.
The owner picked 1.
## Decided by the owner
- Membership is a field on the record (approach 1).
- Kinds: national parks, mountain ranges, wilderness areas.
- A place page needs 3 or more trails.
- Place plus list pages, and rewording of existing lists, are in scope.
## Design
### Place registry
A new `places.toml` at the repo root, one entry per place that any record
names:
```toml
[[place]]
slug = "wind-river-range"
kind = "range" # park | range | wilderness
name = "Wind River Range"
where = ["us-wy"] # state or province codes
within = ["rocky-mountains"] # optional, parent place slugs
source = "gmba-v2"
source_id = "..." # the publisher's id for the outline
```
Only places that at least one record names are listed. The registry is the
one spot where a place's display name, kind and source live.
### On the record
```toml
[[place]]
slug = "wind-river-range"
basis = "track" # track | stated
km = 142.3 # track length inside, basis "track" only
source = "..." # citation, basis "stated" only
```
- `basis = "track"`: the tool measured it. `km` is recorded so the threshold
can be audited. It is never shown on the site.
- `basis = "stated"`: no track. A person entered it, with a source that says
the trail is in that place.
- Adding places to a record gets a `[[history]]` entry like any other fact.
### Membership rule
A trail is in a place when at least 1 mile (1.6 km) of its main track lies
inside the outline. Alternates do not count. A nested range also gives
membership of every `within` parent, so a Teton Range trail is on the Rocky
Mountains page too.
### Boundary sources
| Kind | Source | Licence |
|---|---|---|
| US national parks | National Park Service boundary service (unit type National Park, plus units the owner's search list names, such as Sequoia and Kings Canyon as one page) | Public domain |
| US wilderness | Wilderness Connect, all four agencies | Federal work, public domain; credited |
| Canadian national parks, BC and Alberta provincial parks | Environment and Climate Change Canada, CPCAD | Open Government Licence, Canada |
| Mountain ranges | GMBA Mountain Inventory v2 | CC BY 4.0 |
Outlines are downloaded by the tool into a cache outside the repo and are not
committed. Each source gets an entry on the site's sources page.
Ranges come from an allow-list in the tool (GMBA ids), not from one hierarchy
level, because the useful names sit at different depths. The list starts from
the ranges the owner named and every GMBA range that 3 or more tracks cross,
and is reviewed by a person before records are written.
### Tool
`tools/place_trails.py`. It is not part of the site build, because the build
uses only the standard library and the outlines are large. It is never left
to someone remembering to run it (the owner's ruling). Three things make sure
of that:
- **Every push.** Each record carries `places_checked`, the date its places
were last measured or reviewed, and the fingerprint of the track that was
measured. The validator fails a record that has no `places_checked`, or
whose track has changed since. A new trail or a new track cannot ship
unplaced. A record in no park, range or wilderness still carries the date.
- **Every month.** A scheduled workflow runs `place_trails.py --check`: it
downloads the current outlines, re-measures every track, and fails with a
list of every difference from the records (a place gained or lost, a
boundary that moved, a place that crossed the 3-trail line).
- **Every audit.** `docs/audit.md`, a new written checklist for the monthly
audit of everything, lists the place check as a step, with the hand review
of the `stated` placements, which no tool can re-measure.
What the tool does:
1. Download and cache outlines; reproject to lon/lat.
2. For each record with `line.geojson`, measure the track length inside each
candidate outline.
3. Print a proposal: per trail, the places and kilometres; per place, the
trails. Nothing is written until the proposal is reviewed.
4. Write `[[place]]` entries and registry entries.
The tool may use libraries outside the standard library. The site build may
not, and does not need to: it reads only the records and the registry.
### Pages
- `/parks/<slug>/`, `/ranges/<slug>/`, `/wilderness/<slug>/`, each with the
same layout as a state page: filter bar, rows, map and counts on the first
screen, summary panel and cross-links below.
- `/parks/<slug>/<list>/` and so on for place plus list, 3 or more trails,
and not when the list holds every trail on the place page.
- The Places hub (`/regions/`) gains three sections listing them. Navigation
stays Trails, Places, About.
- State pages link to the parks, ranges and wilderness areas in the state.
Trail pages link to each of their places.
- Titles follow the search phrasing: "Long Hikes in the Wind River Range,
Wyoming", "Backpacking Loops in Yosemite National Park".
- Structured data, sitemap and filter behaviour are the same as for state
pages. Counts are exact. A place below 3 trails gets no page and no link.
### Rewording existing lists (second ship)
Titles, headings and ledes only; URLs and rules unchanged. Targets: "longest
hiking trails in the US", "thru-hikes under 100 / 200 miles", "short
thru-hikes", "week-long backpacking trips", "best backpacking loops". Wording
must pass the banned-word test in `test_facets`.
### Order
1. Registry, record field, validator, tool, and the proposal for review.
2. Records written, place pages, hub and cross-links. Ship with a changelog
entry.
3. Place plus list pages. Ship.
4. Reworded lists. Ship.
## Settled after a builder's read (designer's calls)
- **Reuse, not a copy.** The state-page code (`regions.region_page`,
`placefacets.plan`, `home.listing`) is generalised so a place is a kind plus
a slug, with states as one kind. The existing state-page tests are the
guard: they must pass unchanged. Strings such as "in a state or province"
become per-kind.
- **Map view.** The tool computes each place's bounding box from its outline
and writes it to the registry entry as `box`. `web/place-bounds.toml` stays
for states.
- **Filters.** On a place page the Where filter lists states and provinces as
it does today. The home page's Where filter is unchanged in the first ship.
Site search matches place names, so typing "wind river" finds the page.
- **Counting.** The 3-trail minimum counts both bases, track and stated.
- **History.** Adding or removing a place on a record needs a `[[history]]`
entry. `km` is a measurement, not a fact: a re-run that only changes `km`
needs none.
- **Reproducing.** Each registry entry records the source's version or
download date as `source_version`, so a measurement can be re-derived from
the same outline.
- **Slugs** are unique within a kind, not across kinds: `/parks/glacier/` and
`/wilderness/glacier-peak/` can coexist. A page that joins two units
(Sequoia and Kings Canyon) is one registry entry with two `source_id`s.
- `pages.py` has no plug-in point for new page kinds today; adding one is
part of the work.
## Left to the builder
- Schema and validator details for `[[place]]` and `places.toml`.
- Point-in-polygon and length-inside code, and simplification of outlines.
- Exact page titles and ledes within the vocabulary rules.
- Tests: every `[[place]]` slug is in the registry, every registry entry is
named by a record, no place page below 3 trails, page structure tests as
for state pages.
## Open risks
- Boundary findings come from a research worker and were not opened by the
designer. The first tool run is the check.
- Hand-placing 99 trackless trails is the slow part. Many are in no park or
wilderness and can be settled from the record's summary.
@@ -0,0 +1,203 @@
# A season on every trail
Design, 2026-11-20. Status: awaiting approval.
## Intent
The "By month" lists say "Only some trails have a season", and they are right:
109 of 223 records have one. A hiker picking a month sees half the catalogue.
The owner wants every record to carry a season, with its provenance on the
record, so a reader and a maintainer can tell a season an association
publishes from one worked out from climate. Some will be less trustworthy than
others, and the site says which.
## Goals
- All 223 records have `hike.season` and `hike.months`.
- Each season records where it came from and how far to trust it.
- A sourced season is always preferred. An estimate is the last resort and is
replaced when a source turns up.
- The site marks estimated seasons wherever a season is shown, and stops
saying only some trails have one.
## Non-goals
- Conditions, snow reports, or anything that changes year to year.
- Per-section or per-direction seasons beyond what the season phrase already
says.
- Re-researching the 109 seasons already on file, beyond classifying them.
## Anti-goals
- An estimate that reads like a stated fact.
- A season that tells someone a trail is closed. Trails in cold places are
walked in snow; an estimated season means the usual snow-free, not
dangerously hot months, and says so.
- A method nobody can re-run or check.
## Approaches considered
1. **Research first, estimate the rest, mark both (chosen).** Look for a
stated season for each of the 114 missing records. Estimate only what is
left, from climate normals, with a rule tested against the 109 seasons
already sourced.
2. **Estimate all 114 from climate.** Fast and uniform, but throws away
seasons that pages do state, and the Pacific Crest and Continental Divide
trails are among the 114.
3. **Research only, leave the rest blank.** Keeps the "never guessed" rule but
does not meet the goal.
## Decided by the owner
- Every record ends with a season.
- Provenance is on the record: a source, several sources, or an estimate, and
how much it is trusted.
- Climate data may be used to estimate, with the known weakness that people do
hike in snow and cold.
## Design (designer's calls, for the owner to correct)
### Schema
One new field, `hike.season_basis`, required whenever `season` is present:
| Value | Meaning | Trust |
|---|---|---|
| `primary` | The managing agency, the trail's own association, or for a route its author states it | Highest |
| `sources` | No primary page, but two or more pages from different publishers agree | High |
| `source` | One page that is not a primary one | Medium |
| `estimate` | No page states one; worked out from climate | Low |
- For the first three, `[[hike.source]]` entries name `season` in `facts`, as
today. The validator checks the count fits the basis (`sources` needs two).
- For `estimate`, a second new field `hike.season_method` holds one sentence
naming the method and its inputs, and the `[[hike.source]]` entry cites the
climate data. `months` is still given; `season` is the plain phrase built
from the months.
- `docs/schema.md` changes its rule: a hike fact found on no acceptable page
is left out, never guessed, **except season, which may be estimated and
must then say so**. Typical time is estimated too, but at page-build time
and never stored; an estimated season is stored on the record. Only the
display pattern is shared ("About …" plus a note, and the small estimate
label on rows).
- `season_basis` and `season_method` are facts for history purposes. Each
record changed gets a `[[history]]` entry.
### Step 1: classify the 109
Each existing season gets a basis from its sources: by publisher (managing
body or not) and by count. A worker proposes; a person reviews the table.
### Step 2: research the 114
For each record with no season, look for a page that states when the trail is
normally hiked: the managing agency, the association, a guidebook publisher,
the route author. Record the season phrase, the months, the sources and the
basis. Trip reports count as `source` only when they speak of the usual
season, not one trip. Disagreement between pages is resolved toward the
managing body, and the season phrase may carry the nuance ("northbound starts
late February to April").
### Step 3: estimate the remainder
`tools/estimate_season.py`. It is not part of the site build, and it is never
left to someone remembering to run it (the owner's ruling):
- **Every push.** The validator fails any record with no season, so a new
trail cannot ship without one, sourced or estimated.
- **Every month.** A scheduled workflow runs `estimate_season.py --check`: it
re-runs every estimate and the fit against sourced seasons, and fails with
a list of estimates that would now come out different, or a fit that has
got worse.
- **Every audit.** `docs/audit.md`, the written checklist for the monthly
audit of everything, lists two season steps: the check above, and a fresh
search for a source for every season still marked `estimate`, so estimates
shrink over time.
What the tool does:
- **Where:** sample points along the track. With no track, the start and end
points; with neither, the place centroid of the record's regions, flagged
for hand review.
- **Elevation:** the track's high ground (upper quartile of the profile),
since the high sections decide when a trail opens. With no track,
`high_point_m` or the terrain at the sample points.
- **Climate:** monthly normals for temperature and snow cover at those points
and elevations, from an openly licensed source. Candidates to settle in the
plan: Open-Meteo's historical API (ERA5, CC BY 4.0), NOAA climate normals
and SNODAS (public domain, US only), Environment Canada normals.
- **Rule:** a month is in season when the high ground is normally free of snow
and the mean daily high at the low ground is under a heat limit. The
thresholds are fitted, not chosen: the rule is run against the 109 sourced
seasons and tuned until it reproduces them as well as it can.
- **Check:** the tool reports how often its months match the sourced months
(exact, within one month at each end, worse). That figure goes on the
site's reference page, so the trust in an estimate is a number. If the rule
cannot get most sourced trails within one month, estimates are not shipped
and the owner is told.
- **Review:** the proposed seasons are listed for a person to read before any
record is written. Odd ones (desert, coastal, far north) get a hand check
against a comparable sourced trail nearby.
### On the site
- Trail page: an estimated season reads "About June to September" with a
note, as estimated time does today: "Estimated from climate at the trail's
elevation. No source states a season. People do walk it outside these
months." Sourced seasons show their basis in "About this data".
- Rows, summary lines and month lists include every trail. Estimated seasons
are marked in the row.
- The "By month" blurb becomes "Trails normally hiked in the month. Estimated
seasons are marked." The "N trails with no season on file" note, the "Show
them" button and the "Not on file" cell go once coverage is complete.
- The filter bar's month filter gains a way to leave estimates out.
- The glossary entry and reference page coverage row are rewritten to match.
- Structured data states a season only for sourced ones.
### Order
1. Schema, validator, history tool, classify the 109. Ship.
2. Research the 114 in batches by region; write sourced seasons. Ship as
batches land.
3. Estimator, its check against sourced seasons, the review list.
4. Write estimates, change the site wording and filters. Ship.
## Settled after a builder's read (designer's calls)
- **Who is primary is a judgement, not a lookup.** `publisher` is free text
with 92 distinct values, so step 1 is a proposed table of all 109, read by
a person. The rule follows the schema's existing idea of the acceptable
page: the managing body, or for a route its author.
- **Most seasons will be `primary` or `source`.** Only 6 of the 109 have more
than one source naming the season today. `sources` is for the few with no
primary page and several agreeing ones.
- **Validator.** `season_basis` and `season_method` are provenance, not
facts: they are exempt from the rule that every hike field is named in a
source's `facts`, as `checked` is. `season` and `months` must appear
together. An estimate's only source naming `season` and `months` is the
climate data; any other source naming them makes the basis wrong.
- **Shipping step 1.** `season_basis` is required wherever `season` is
present from the first ship, covering the 109.
- **Site code.** Rows, the filter bar, `standing.season_cell` and
`reference.py` assume seasons are partial and tests pin that wording; those
tests are rewritten, not patched. They change only in the last step, when
coverage is complete.
## Left to the builder
- The climate source, after trying the candidates on a dozen trails.
- Sampling density, the exact snow and heat measures, and the fit.
- Wording of notes within the vocabulary rules and the banned-word test.
- Tests: every record has season, months and basis; basis fits the sources;
estimates have a method; no page says a season is missing.
## Open risks
- Climate normals are coarse in steep terrain. The fit against sourced
seasons is the guard, and it may show the method is too weak for some
regions.
- 42 of the 114 have no track and 95 have no high point, so some estimates
rest on a start point or less. Those are the least trustworthy and are
flagged for hand review.
- Research may find seasons for most of the 114, leaving few estimates. That
is the good outcome.