Skip to content
Toolkit

Job 009: url-lifecycle

Status: DONE Owner: @work, the routine

Phase: all buildable phases closed · Status: DONE (close-out) · Updated: 2026-08-30

Scoreboard: npm run check:lifecycle — 9 of 9 enforced (1 fact, 5 states, 3 notices). The committed number, not a census: rule L6 fails the build when it drifts from the tree.

Dependencies: none open. 006 is DONE (close-out); 008 left the redirect path already evaluating gates, display rules, schedules and click limits, and left six public types with renderers — which is what an archive has to serve. Charter: ./README.md. Routine: ./ROUTINE.md (batch loop, claim refs claim/009-*, budgets — inherited from 006 unchanged, plus the clock is injected, never waited for). Source: product gap assessment .archives/removal-safe/docs/assessments/PRODUCT-GAP-ASSESSMENT-082926.md §Card view and URL lifecycle, §Address.

Objective

A URL's life is a stored, servable state rather than a policy in prose: quiet is noticed, the owner is told before anything is taken, a lapsed slug is released on a schedule the product can state, what was there stays readable at an archive address, and the name can be reclaimed within a window. The charter's phase table carries the bars; they are not restated here.

Completed

  • Chartered — README, ROUTINE (006's protocol, claim namespace claim/009-*, plus the injected-clock rule), this file; ROADMAP's 009 row flipped ACTIVE and 006 closed DONE in the same PR. Findings re-verified on bab2292 rather than inherited from the assessment: cron_tasks.go registers seven tasks and not one concerns a link; no migration carries an archived, released, reclaim or lapse column on links, and the only expires_at columns belong to idempotency keys and API tokens; subdomains have zero references in apps/, packages/ or docs/; a disabled or deleted link is a 404 with no read-only mode and no second address. Also verified, as the buildable ground: per-link click capture with timestamps (track_links), links.datetime/last_datetime, users.last_activity maintained by an existing cron task, host→domain_id resolution in the redirect path, and the internal-notifications fan-out 006 used twice.

  • Phase 00 — the lifecycle ledger and its gate, minted before any state machine. Nine rows at 0 of 9: one fact (quiet-since), five state (notified, lapsed, released, archived, reclaim-window), three notice. Each names the writer, the SERVING path that must read it, its behaviour test and — for a state or a notice — its idempotence test, all null until the commit that adds the reader. Two rules are this track's own and are already non-vacuous: L4, a row names its window as a configuration key and never a number, so Blocker 3 stays the owner's, and no row may be enforced at all while the thresholds configuration does not exist; L5, no writer of an enforced row may call time.Now(). All five rules watched failing (evidence .station/jobs/009-url-lifecycle/evidence/phase-00-gate-watched-failing.md); the gate joined npm run verify.

  • Phase 01 — quiet-since is a fact about a resource. links.last_used_at (migration 000038, applied and rolled back against a live database), backfilled to the latest of the row's creation, last edit and last recorded click, and maintained by exactly two paths — the click path and the edit path, because a visitor arriving and an owner working are both use. The serving path answers with it: GetByID and both workspace listings select it, the public and directory queries deliberately do not. Two rules moved with it (ADR-0113): a ledger dependency may name a list of files, because a row naming one of two writers does not notice the other going; and L5 exempts a fact, which records that something happened now, while still binding every state and notice, which decide that enough time has passed. Proved against PostgreSQL 16 and watched failing four ways (evidence .station/jobs/009-url-lifecycle/evidence/phase-01-quiet-since-2026-08-30.md).

  • Phase 02, first slice — active → notified, the lifecycle's first transition. links.lifecycle_state with its CHECK vocabulary (migration 000039, applied and rolled back live), the daily lifecycle_notice_quiet cron task, and the two things every later transition inherits: config.LifecycleThresholds (seven windows, stated defaults, Blocker 3 still the owner's) and services.Clock, handed in at the composition root. The transition is split at the layer: the service decides when from a clock and a window it is given, the repository holds the statement, and its own predicate is what makes a second run move nothing. Both maintenance paths revive a quiet resource; released is deliberately not revivable. Refused as a client-settable field: no write path reads it off a request. Watched failing five ways, one of them an accident the gate caught (evidence .station/jobs/009-url-lifecycle/evidence/phase-02-quiet-sweep-2026-08-30.md).

  • Phase 02, second slice — notified → lapsed, the first transition that takes something. A lapsed resource stops serving, and the serving path is not one door but seven: the redirect path, the five public data endpoints 008's renderers fetch, and the unlock endpoint — a lapse the 302 enforces and the endpoint behind the page does not is one a bookmark walks around. One predicate answers all seven (models.LifecycleServes, an allowlist, so an unwritten state refuses), GetLinkByURL selects the column it reads (#393, replayed), and the refusal is the 404 a missing link shows: a page saying "this lapsed" tells a slug-prober the name is taken and its owner has stopped turning up. The sweep moves rows out of notified and never out of active, and is armed by configuration, disarmed by default (LIFECYCLE_TAKING_ENABLED) — the charter's order is that the owner is told first, and the notices are phase 03 (ADR-0114). Proved against PostgreSQL 16, watched failing six ways, one of them the gate's own catch (evidence .station/jobs/009-url-lifecycle/evidence/phase-02-lapse-2026-08-30.md).

  • Phase 02, third slice — lapsed → released, and the claim path that had never existed. The ledger's released row names the claim path as its reader; there was none. links.url carries no unique index, no create or rename checked an address, and GetLinkByURL resolves ORDER BY is_enabled DESC, link_id DESC LIMIT 1 — so a second account creating a link at somebody else's slug did not collide with them, it replaced them, and the owner's visitors went to the stranger's destination. Proved against a live database before the fix. One check now answers all fourteen write paths, scoped exactly the way resolution is (a narrower claim calls a name free and then resolves it to somebody else), refusing 409 and naming nobody; a rename is a claim and only a rename is. The transition counts its window from the lapse, not from last use, and is armed by ADR-0114's switch (ADR-0115). Watched failing four ways (evidence .station/jobs/009-url-lifecycle/evidence/phase-02-release-2026-08-30.md).

  • Phase 03, first slice — notice.quiet, the first thing in this track that reaches a person. A notice cannot be idempotent the way a transition is: sending changes nothing about the resource, so a notice sent from a SELECT is sent again by every run, every retry and every second process. It is a claim — links.lifecycle_notice (migration 000040, applied and rolled back live) is set in the same UPDATE … RETURNING that selects the rows due, so the second run of the day claims nothing, and a send that fails hands its rung back. Both maintenance paths clear the rung in the statement that already revives the state. What the notice may SAY depends on LIFECYCLE_TAKING_ENABLED: armed, it states the lapse date computed from the windows; disarmed, it reports the quiet and promises nothing, because that deployment will not stop serving anything. The path is the existing one (CreateBatch), and with no notifier the sweep claims nothing at all (ADR-0116). Watched failing eight ways, three of them the gate's (evidence .station/jobs/009-url-lifecycle/evidence/phase-03-notice-quiet-2026-08-30.md).

  • Phase 03, second slice — notice.lapse-warning, the first rung claimed off another. The first notice stands on an empty column; this one stands on quiet, and that is what makes the ladder unskippable — an owner cannot be warned that a name is going without first having been told the resource went quiet, and no window misconfiguration can reorder it, because the order is a precondition on a stored fact rather than arithmetic between two numbers. A failed send hands the claim back to quiet, never to nothing: clearing it would re-send the first notice and restart a ladder whose windows had already passed. Claimed only for notified rows, because a notice saying the resource still serves and will stop is not owed to one that has lapsed. Armed, it states both dates, the release counted from the lapse rather than from last use; disarmed, it is a second report of quiet, title included (ADR-0116 one rung up) (ADR-0117). Proved against PostgreSQL 16, watched failing eight ways — two of them the gate's, one of which caught this slice's own ledger row naming a writer file that reads the wall clock (evidence .station/jobs/009-url-lifecycle/evidence/phase-03-notice-warning-2026-08-30.md).

  • Phase 03, third slice — notice.final, and the phase closed. ADR-0117's shape one rung up, with the one decision SESSION left open: its subject is the name, not the serving, so it is claimed for every state the resource can still be saved from (LifecycleRevivable — notified and lapsed) and never for released. Scoping it to notified as the warning is scoped was the wrong answer for a reason the defaults make plain: NOTICE_FINAL_DAYS and LAPSE_DAYS are both 118, two unordered daily tasks, so whichever ran first would decide whether the owner was ever told — and a row that lapses first never returns to notified. The body states one date, the earliest the address can go (both windows consecutively, ADR-0115's rule), and says that nothing is deleted when it does — Blocker 4 in the sentence, at the moment an owner would otherwise assume the worst (ADR-0118). Proved against PostgreSQL 16, watched failing seven ways, one of them the gate's (evidence .station/jobs/009-url-lifecycle/evidence/phase-03-notice-final-2026-08-30.md).

  • Phase 04, first slice — the archive address, and what stands at it. A lapse never deletes anything: phase 02 freed the name, and this is the other half. The address cannot be the old slug — SlugTaken treats a released name as free, so somebody else may hold it — and cannot be link_id, which makes every archived document readable by a stranger who can count. It is an opaque key minted by the release transition itself (migration 000041, applied and rolled back live), COALESCEd so a row released twice keeps the address already handed out. What stands at it is the same projection the card serves (ADR-0105), so it cannot leak what the type's own allowlist withholds — the charter's named risk for this phase, made structurally impossible rather than carefully avoided — with the gate intact and no target, since one built from the freed name would send the reader to whoever holds it now. Nothing is recorded: a visit to an archive is not use. Blocker 1 stays the owner's, as ARCHIVE_ORIGIN with an ARCHIVE_PATH_PREFIX default put together in one place (ADR-0119). Watched failing seven ways, one of them the gate's and one of which corrected the code's own comment (evidence .station/jobs/009-url-lifecycle/evidence/phase-04-archive-address-2026-08-30.md).

  • Phase 04, second slice — the archive page. The address had no reader. Three properties are the design, each a rule about what an archive must not do: it summarises through the card's own summariser (summarise moved into lib/cardSummary, both pages importing it — two switches over one payload is ADR-0105's forbidden second payload in different clothes); nothing is clickable to the former name, which is free and may already be somebody else's, so the name is stated as a past fact and that is how the page says the address is gone; and a gated archive offers no door, because /u/{url} resolves the gate by the one thing this resource no longer has — a held grant is still forwarded and still honoured, only the invitation to earn one is withdrawn. A file or static archive names its document and says the bytes are not served here. The path is configuration on both halves, so rule L7 holds their defaults equal: a drifted prefix is an archive addressed where nothing renders it, with no error on either side (ADR-0120). Watched failing six ways (evidence .station/jobs/009-url-lifecycle/evidence/phase-04-archive-page-2026-08-30.md).

  • Phase 04, third slice — the owner is told where their archive is, and the phase closed. Everyone could find the address except the person it belongs to: the final notice cannot carry it, because the key does not exist until the release that notice precedes (ADR-0118), so the surface is the owner's own read of the resource. GetByID selects the column and the handler hands back an assembled address, never the key — ArchiveKey is now json:"-" and a computed ArchiveURL takes its place, because config.ArchiveAddressSet.URL is the one place origin and prefix are put together (ADR-0119) and a caller holding the key would be a second. Computed rather than stored: it changes the moment Blocker 1 is answered, and a stored copy would go stale in the same breath. omitempty carries the rest — a resource still holding its own name has no archive, so the field is absent rather than empty. The link detail page draws it as a read-only address the owner can open, where the archive page's former name is deliberately not a link: a key resolves to this resource and nothing else. Watched failing five ways, three of them the gate's — one of which was the gate catching this slice's own edit to GetByID's select list (evidence .station/jobs/009-url-lifecycle/evidence/phase-04-archive-told-2026-08-30.md).

  • Phase 05 — the reclaim window, and the ledger's last row (8 of 9 → 9 of 9). For LIFECYCLE_RECLAIM_DAYS after a release the name is the workspace's that held it and nobody else's. The reader is ADR-0115's one claim check, which gained two arguments: who is asking, and the moment a release stops reserving. The claimant is a workspace, not a user — workspace_id has been the access boundary since 000026, so a team's name is the team's to take back rather than the one member's who created it. An unconfigured window reserves nothing, which is phase 02 unchanged: an unset window must relax, never lock names away for a period nobody chose. And the refusal is byte-identical to the one a stranger meets at a live name, so the claim path never becomes an oracle for which workspace once held which (ADR-0109/0110, a third time). The gate refused the row on flip and was right: this row's subject is a refusal, so nothing is written when its window matters and its writer read a different window days earlier. The rule was widened rather than dodged — a row declares decides_window: "reader" and L4/L5 hold its reader to exactly what they held the writer to (ADR-0121). Watched failing seven ways, five of them the gate's — one of which proves the widened L5 reaches the reader (evidence .station/jobs/009-url-lifecycle/evidence/phase-05-reclaim-2026-08-30.md).

  • Phase 05's statement, proved on PostgreSQL 16.13 — the phase closed. The reader is one predicate whose two deciding arms are invisible from Go: the IS NOT NULL that decides whether a release reserves anything, and the workspace_id <> $6 that is the whole difference between a former owner and a stranger. A local cluster with all 41 migrations applied ran the test that skipped last run, and the nine lifecycle statements before it — ten of ten pass — then watched the reclaim statement failing four ways against the same database: nobody the former workspace, the comparison inverted, an unset window reserving everything, and the window compared the wrong way round. No code changed (evidence .station/jobs/009-url-lifecycle/evidence/phase-05-reclaim-postgres-2026-08-30.md).

Active

Nothing claimed.

Open items

None in flight. Residue handed back to the owner is listed here, once:

  • No surface shows an owner when a resource was last used. The API answers with last_used_at on the read and both listings; no page draws it yet. One PR, and it wants a phase 02 state beside it to be worth a column.
  • links.url has no unique index, so the claim path is a check and not a constraint. Two simultaneous creates of the same slug can both pass. The fix is a partial unique index on (url, COALESCE(domain_id, 0)) WHERE lifecycle_state <> 'released', and it needs a duplicate audit on a real database first — 004's grandfathering shape. One PR, after the audit.
  • Should an archive serve a stored document's bytes? Today it names them (ADR-0120 §4): ADR-0102's byte path is addressed by the slug, so serving here needs a route keyed on the archive key, and an archived document readable forever by anyone holding that key is its own security bar. One PR, after that bar is written down — and 010's storage model may settle it first.
  • A PostgreSQL 16 cluster runs locally here without Docker — the daemon is down, but the server binaries are installed, so a cluster plus every *.up.sql in order is a working database in about a minute. Recorded so the next run that needs one does not conclude, as the last did, that it has none.
  • Playwright's browser build does not match the pre-installed Chromium, and the dev server needs API_PROXY_TARGET pointed at the API's real host. The live suite needs both pinned to run in the remote environment at all. Not this track's to fix — recorded so the next run does not rediscover it.

Blockers

All three are owner decisions with options and a recommendation in the charter; none blocks phases 00–03 or 05, phase 04 needs the first before its address is final, and phase 06 is gated outright by the second.

  1. What is the archive domain? Recommendation: build against a configured archive origin with a path-prefix default, so the answer is configuration rather than a rewrite.
  2. Do subdomains ship, and under what rollout? Recommendation: custom domains the owner already controls first — it needs no new certificate story — with name.card.site for everyone a separate decision beside 011's quota axis.
  3. What are the retention windows? Recommendation: configuration with stated defaults (90 days quiet; notices at 90/104/118; release 30 days after lapse; reclaim 30 days after release), with the gate refusing a threshold compiled into a handler.

A fourth question the charter answers rather than asks: a lapse never deletes anything. Release the slug, archive the document; deletion stays the owner's own act.

Decisions

  • The ledger before the state machine — 007's enforcement ledger applied to lifecycle states: a state is unenforced until a named serving path reads it, and a row flips only in the commit that adds that reader.
  • The clock is injected, never waited for — every threshold is configuration with a stated default, and every transition reads a clock the test can set. A suite that sleeps is a suite nobody runs.
  • Every transition is idempotent — phase 02's bar is that a second run moves nothing; phase 03's is that a second run sends nothing.
  • A fact is stamped, a transition is handed a clock (ADR-0113) — the injected-clock rule binds where elapsed time is decided, not where a moment is recorded; and a ledger row names every writer it has, not the first one.

Files changed

  • .station/jobs/009-url-lifecycle/ — charter, routine, this file, evidence
  • scripts/lifecycle-ledger.json, scripts/check-lifecycle-parity.mjs, package.json — the ledger, its gate (L1–L6), and check:lifecycle in verify
  • apps/api/migrations/000038_*, internal/models/link.go, internal/repository/links.go, internal/repository/track_links.go, internal/repository/links_last_used_integration_test.go — last_used_at
  • apps/api/migrations/000039_*, internal/config/lifecycle.go, internal/services/clock.go, internal/services/lifecycle.go, internal/services/cron_tasks.go, cmd/server/main.go, and the two lifecycle test files — lifecycle_state and the sweep that moves it
  • internal/models/link.go (LifecycleServes), internal/repository/links.go (MarkNotifiedAsLapsed), internal/repository/track_links.go (the column in the redirect path's query), the seven public resolvers in internal/handlers/, and internal/handlers/redirect_lifecycle_test.go — the lapse and the seven refusals that make it real
  • internal/handlers/link_slug.go + link_slug_test.go, internal/handlers/interfaces.go (SlugClaimStore), the seven creates and seven renames, internal/repository/links.go (SlugTaken, MarkLapsedAsReleased) and internal/services/lifecycle.go (SweepRelease) — the claim path and the release
  • apps/api/migrations/000040_*, internal/models/link.go (the notice rungs and LifecycleNoticeTarget), internal/repository/links.go (ClaimQuietNotices, ReleaseNoticeClaim, ClaimNoticeRung with its per-rung state scope, RestoreNoticeRung, the rung cleared on revive), and — phase 04 — apps/api/migrations/000041_*, MarkLapsedAsReleased's minted key, GetByArchiveKey, internal/config/lifecycle.go (ArchiveAddress), internal/handlers/public_archive.go + its test, and the route in cmd/server/main.go internal/repository/track_links.go (the same on the click path), internal/services/lifecycle.go (SweepNoticeQuiet, LifecycleNotifier), internal/services/cron_tasks.go, cmd/server/main.go — the first notice

Verification

Phase 00 is a gate, so its own bar is the watched failure rather than a running stack. The bar for everything after it is the charter's §Verification, unchanged from the last four tracks: npm run verify exit 0 and go vet ./... && go test ./... green before every merge, a live E2E spec per new surface asserting a database read, every new or widened gate watched failing once on a deliberately broken input, and each migration applied and rolled back against a live database before any handler reads its column.

Next actions

Nothing. The track is closed (close-out): every buildable charter phase met its own bar, phase 06 stays gated on Blocker 2 and is nobody's to build unanswered, and ADR-0114's precondition is discharged — 03 and 05 have both landed, so arming LIFECYCLE_TAKING_ENABLED is a deployment decision rather than a code one.

The next run's single item is the routine's track handoff: charter 010 — artifact hosting.

Source: .station/jobs/009-url-lifecycle/SESSION.md

Library