Skip to content
Toolkit

009-url-lifecycle — routine prompt

The prompt block below is this track's live driver: the CS-Hourly routine reads ROADMAP's front track and follows that track's ROUTINE.md, so this file is the prompt and edits here take effect on the next firing without touching the trigger.

It inherits 006's protocol wholesale, which was 008's, which was 007's, 005's, 004's, 003's and 002's — batch loop, atomic claim refs, read / verify / output budgets, worktree rule, track handoff. Each was earned by a recorded failure and is not re-derived here. What changes is the claim namespace (claim/009-*), the read budget's file, the scoreboard, the WORK shapes — 009's seven phases — and one addition this track earns on its own: the clock is injected, never waited for.


Advance the URL lifecycle (009) by a BATCH of items, then stop.

BATCH LOOP: repeat {claim → build → verify → PR → merge → update
SESSION.md} item by item — one item per PR (revertible slices), each fully
merged before the next is claimed. Continue until the FIRST of:
- 4 items landed this run;
- the next item is a phase-scale block (a whole phase, one slice per PR
  notwithstanding) — do its first shippable slice as one item, then stop;
- the next item is blocked → one line in SESSION.md, stop;
- no unclaimed item remains, or remaining context is too small to land
  another item cleanly (never start what you cannot merge).
Read budgets are paid ONCE per run; between items re-read nothing — only
`git fetch` + the claim check for the next item.

READ BUDGET (hard): read .station/jobs/009-url-lifecycle/SESSION.md
from the top through the end of "Next", once per run, and stop there. Open
the charter, the product gap assessment or an ADR only when the claimed
item names it. Trust SESSION.md's scoreboard line; re-run a gate only after
a diff that moves it. Re-deriving settled context is the run's largest cost
— spend it on the diff.

CI POLICY (settled — spend zero words on it): GitHub Actions here is
noise; the merge gate is local `npm run verify` exit 0, plus
`cd apps/api && go vet ./... && go test ./...` only if apps/api changed.
Green locally → merge the PR. Never re-run, mention, or "fix" Actions.
Canonical: ROADMAP.md "Standing policy".

CLAIM, THEN BUILD (002's protocol — the open-PR gate alone raced 8 times):
1. `git fetch origin` · list open PRs · `git ls-remote origin 'refs/heads/claim/*'`.
   - An open 009 PR exists → resume and land THAT PR as the batch's first
     item, then continue the loop.
   - Else take the top item under "Next" whose `claim/009-<item-slug>` ref
     is absent OR stale. Ref deletion returns 403 in the remote
     environment, so claim refs accumulate: a claim ref with no open PR
     and no branch commit newer than 3 hours is stale — treat it as free
     and re-claim over it. A slug SESSION.md's Completed already records
     is done, not in flight.
2. Claim atomically BEFORE writing any code:
     git push origin origin/main:refs/heads/claim/009-<item-slug>
   Rejected push = claimed between your list and your push → return to 1.
   Only a successful push is a claim; a SESSION.md line is not.
3. When your PR merges, attempt to delete branch and claim ref once; a
   403 is expected there, not a failure — move on.
Take ADR numbers only after `git fetch`, from origin/main's docs/decisions/.

WORK: fan out where the item is an enumeration, solo where it is not.
- Phase 00 mints the lifecycle ledger AND its gate BEFORE any state
  machine lands, for 004/006/007/008's reason: a scoreboard minted after
  the work measures nothing. One row per lifecycle state and per notice,
  all unenforced, each naming the writer, the SERVING path that must read
  it, and its test. A row flips only in the commit that adds its reader.
- Phases 01–05 each add ONE stored fact and the path that reads it. No new
  logging system: activity is derived from `track_links` and the resource's
  own row. Notices go out on the EXISTING internal-notifications path,
  never a new one. Migrations at the next free number with .down.sql,
  applied and rolled back against a live database before any handler reads
  the column.
- THE CLOCK IS INJECTED, NEVER WAITED FOR. Every threshold is
  configuration with a stated default; a transition reads a clock the test
  can set, never `time.Now()` inside itself. A test that sleeps is a test
  that will be deleted for flaking, and a threshold compiled into a
  handler fails phase 03's gate.
- EVERY TRANSITION IS IDEMPOTENT. The bar for phase 03 is that a second
  run sends nothing; the bar for phase 02 is that a second run moves
  nothing. A cron task that is not re-runnable is a cron task that
  double-notifies the first time it retries.
- NOTHING IS DELETED BY A CLOCK (charter Blocker 4). Release the slug,
  archive the document; deletion stays the owner's own act.
- An archive serves 008's own renderers and their allowlists (ADR-0105's
  projection rule) — never a second payload, and never anything the live
  resource withheld.
- The archive domain (Blocker 1), the subdomain rollout (Blocker 2) and
  the retention windows (Blocker 3) are OWNER DECISIONS. Build every phase
  around them: 04 against a configured archive origin with a path-prefix
  default, 06 not at all until Blocker 2 is answered. A phase that starts
  answering one has left the charter.
- A new or widened gate is watched FAILING once on a deliberately broken
  input, and the run that widened it records that in evidence/.
- TRACK HANDOFF: when every charter phase is closed and verified, write
  reports/CLOSE.md, then the next run's single item is to charter 010 —
  artifact hosting — from ROADMAP's table under docs/guides/workstream.md
  — README, ROUTINE.md (inherit this protocol), SESSION.md —
  scoped from ROADMAP's 010 section and the assessment's §Host; where that
  section says chartering collects owner decisions (the storage and size
  model), the charter names each as a Blocker with options and a
  recommendation — never invents the answer. Then mark 009 DONE on
  ROADMAP, and subsequent runs work the new track. Tracks follow
  ROADMAP's "last stretch" order; when the last one closes, drain
  ROADMAP's "Standing repairs" the same way, then report completion and
  recommend disabling the routine — do not invent scope.
Integrate and verify results yourself; never merge on an agent's word.
Any agent that writes ANYTHING runs in its own `git worktree`, never the
run's tree (an in-tree reviewer destroyed an uncommitted fix on 002); if
worktree tests resolve workspace packages, relink node_modules first — a
symlink into the run's tree reads the wrong files and false-passes.

VERIFY ONCE: while iterating, run only the touched tests
(`npx vitest run <files>`, `go test ./internal/<pkg>/...`) or the one gate
the item moves. Run `npm run verify` exactly once, when the diff is final,
immediately before the PR, plus `go vet ./... && go test ./...` in apps/api
if apps/api changed; if it fails, fix and re-run — never as a baseline,
progress check, or "before and after".

RULES THAT STAND: migrations at the next free number with .down.sql,
applied manually, never renumbered; handler → repository → database
layering, no business logic in handlers; APIResponse envelope; breaking
API changes under /api/v2/, never in place; frontend uses Studio
primitives and tokens only — nothing new in components/ui, no raw
colours; product vocabulary from docs/GLOSSARY.md; strings behind `t()`
with the key in the `en` bundle (005 closed; a new surface does not
reopen it); Redis is optional (AGENTS.md §4) and every phase works
degraded without it; no adjacent cleanup — one SESSION.md row instead.
Nothing user-visible merges wired to nothing, and a stored lifecycle
state no serving path reads is exactly that. Consequential product calls
become ADRs, never silent choices.

OUTPUT BUDGET (hard — the run's meaning is its diff, not its prose):
- New ADR only for a decision that constrains future work, ≤ 120 lines.
- SESSION.md Completed entries ≤ 8 lines, linking the ADR/PR.
- ≤ 3 new open-item rows per run, ≤ 3 lines each; a one-line fix in a
  file already touched is fixed, not recorded.
- PR body ≤ 20 lines. Final report: one line per item landed (item, merge
  commit, scoreboard before → after) + one line for what is next.

Close out per item: SESSION.md Completed entry + refresh "Next"; tick
ROADMAP.md's 009 row only when verification proved it. Conventional
Commit, PR to main, merge on local green.

Shape notes

  • Inherited, not re-derived. The protocol above is 006's, which was 008's, 007's, 005's, 004's, 003's and 002's. The history behind each rule lives in 002's ROUTINE.md shape notes; a run that wants to change a rule reads that first, because each one is a fix for something that actually went wrong.
  • The scoreboard is one number from one script, so it cannot drift: enforced over states, printed by scripts/check-lifecycle-parity.mjs and committed beside it. It rises only in the commit that adds the serving path's reader — never in the commit that adds the row. This is 007's enforcement ledger applied to a state machine rather than a control.
  • The clock is the new rule, and it is this track's own. Every previous track could prove its bar by doing a thing and looking. This one's subject is elapsed time, and the only two ways to test that are to wait — which produces a suite nobody can run — or to inject the clock. Every threshold is configuration and every transition reads a clock it is handed.
  • The riskiest thing this track can ship is a clock that takes something. Hence Blocker 4's recommendation (nothing is deleted by a clock), idempotent transitions, and a notice schedule whose bar is that running it twice sends once.
  • Three owner decisions are named, not guessed. The archive domain, the subdomain rollout and the retention windows are the assessment's own "chartering collects owner decisions" list. The charter's answer to each is a shape that makes the decision configuration rather than a rewrite — except subdomains, which gate their phase outright.

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

Library