Skip to content

v4.0.0 — every station gets a permanent slug

Choose a tag to compare

@clarkbw clarkbw released this 30 Aug 21:11
b42bf03

A slug is now allocated once and published, rather than derived from a station's name on every read. A name proposes a slug at allocation; after that the table is the record and the name is free to change. That is what makes an over-the-air name correction safe: it can no longer move a link already sitting in someone's group chat.

Breaking

The lock API is gone. buildSlugsLock, readSlugsLock and checkSlugs are replaced by buildSlugTable, emptyTable, readSlugTable and checkSlugTable. data/slugs.lock.json is replaced by data/slugs.json and data/slug-tombstones.json.

resolve().slug reads the published table. It previously derived toSlug(name), which had drifted: across the bundled catalogue, 194 stations resolved to a slug published for a different station — Aberdeen, Scotland returned aberdeen, which belongs to Aberdeen, Washington. A station absent from the table now returns "" rather than a derived fallback, because a fallback re-creates that collision in a narrower form.

The CLI requires its catalogues. slugs and check-slugs take repeatable --tides and --currents flags, and refuse to run without both kinds. A station missing from the input is indistinguishable from one that departed, and a departure tombstones a slug permanently.

What ships

data/slugs.json4,690 slugs, 3,823 tide and 867 current, partitioned by kind.

  • Kind is a namespace. A tide and a current station at one place may both hold dodd-narrows; they become different URLs. Uniqueness is enforced within a kind.
  • Allocation is order-independent. Candidates sort by station id, so catalogue ordering cannot change who wins a contested name. Adding stations never moves an existing slug.
  • A slug is never reused. A departed station's slug moves to slug-tombstones.json and is never reallocated. Freeing it would let a future station inherit an old link and show different water — for anyone timing a transit, worse than a dead link.
  • The artifact is reproducible. No wall-clock field, and catalogue digests are order-independent, so repeated builds from one catalogue are byte-identical.

CI now fails a pull request if a published slug moved since the previous release tag.

Coverage

These 4,690 are the harmonic stations. NOAA's subordinate stations — 2,244 tide and 1,705 current — are not yet in the bundled catalogue and so hold no slugs. They allocate when the generators start emitting them; existing slugs are unaffected.