Give every trail a permanent number in trail-numbers.txt, and check it is only appended to

The Saved page's short links will be bit sets over these numbers, so a number
must never change or be reused. The registry is one id per line, seeded
alphabetically; build_index appends new records; the validator fails on a
record with no line, a repeated id or a malformed line; check_history fails
when an earlier line is changed, moved or removed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-19 15:19:50 -07:00
1 parent 6440e43176
commit 358f0c4928
10 files changed
+580 -7

No files matched your search

+12 -1
View File
@@ -16,7 +16,12 @@ try:
except ModuleNotFoundError: # Python < 3.11: minimal fallback for this repo's TOML subset
tomllib = None
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(HERE)
sys.path.insert(0, HERE)
import trail_numbers # noqa: E402
BEGIN = "<!-- BEGIN TRAIL TABLE -->"
END = "<!-- END TRAIL TABLE -->"
COUNT_BEGIN = "<!-- BEGIN COUNTS -->"
@@ -271,9 +276,15 @@ def main():
f.write(idx_data)
with open(readme_path, "w", encoding="utf-8") as f:
f.write(readme_data)
appended = trail_numbers.append(ROOT, [t["id"] for t in trails])
with_line = sum(1 for t in trails if t.get("source", {}).get("line_file"))
print(f"Wrote trails.csv, index.geojson and README table: "
f"{len(trails)} trails, {with_line} with a track.")
if appended:
print(f"Appended {len(appended)} to {trail_numbers.FILE}, in sorted order: "
f"{', '.join(appended)}. Commit the file with the record.")
else:
print(f"{trail_numbers.FILE} is complete: every record has a number.")
return 0