Skip to content
Toolkit

010-artifact-hosting — 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 009's protocol wholesale, which was 006's, 008's, 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/010-*), the read budget's file, the scoreboard, the WORK shapes — 010's six phases — and one addition this track earns on its own: nothing the artifact contains decides anything.


Advance artifact hosting (010) 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/010-artifact-hosting/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 010 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/010-<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/010-<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 hosting ledger AND its gate BEFORE any kind is
  widened, for 004/006/007/008/009's reason: a scoreboard minted after the
  work measures nothing. One row per artifact kind, naming what stores it,
  the SERVING path that must read it, the limit key that bounds it, and its
  test. `html` starts true — 008 shipped it — and every other row starts
  unserved. A row flips only in the commit that adds its serving path.
- NOTHING THE ARTIFACT CONTAINS DECIDES ANYTHING. Not its declared type,
  not its extension, not its first bytes, not an entry's stored size, not a
  path inside a zip. Every one of those was written by a stranger. The
  product decides the content type it serves, the place a byte is written
  and the limit that stops it, and it decides all three BEFORE reading what
  the artifact says about itself.
- EVERY LIMIT IS CONFIGURATION READ BEFORE THE FIRST BYTE IS WRITTEN.
  A limit discovered while unpacking is a limit that has already spent the
  disk; a threshold compiled into a handler fails the gate the way 009's
  did.
- A REFUSAL IS THE WHOLE UPLOAD. A half-unpacked bundle is never stored,
  and a partially served one is never addressed. One slice per kind: the
  allowlist entry, the sniff agreement, the serving path and the ADR land
  together, or none of them do.
- The gate, the schedule, the click limit and 009's lifecycle predicate
  hold on EVERY entry a bundle serves, not just its index — 009's
  seven-doors finding applied to a directory. An address that skips one is
  the same defect 008 found at `/uploads/*`, which phase 05 owns.
- ADR-0103 IS THE FLOOR, NOT A STARTING POSITION: no script, no origin of
  its own, no outbound fetch, on the origin where sessions live. The
  separate origin is Blocker 3 and is the OWNER's; build phase 03 so the
  origin is configuration and the policy is one place. A phase that starts
  answering a Blocker has left the charter.
- Storage quotas: phase 04 leaves the axis REGISTRY-SHAPED and unseeded —
  the ladder and its numbers are 011's. An unset quota unlimits (004's
  fail-open), which is the opposite of a capability's default deny.
- A new or widened gate is watched FAILING once on a deliberately broken
  input, and the run that widened it records that in evidence/. A hostile
  archive — traversal, bomb, symlink, duplicate name, a lying size — is a
  fixture per rule, not a review checklist.
- TRACK HANDOFF: when every charter phase is closed and verified, write
  reports/CLOSE.md, then the next run's single item is to charter 011 —
  plan ladder — from ROADMAP's table under docs/guides/workstream.md —
  README, ROUTINE.md (inherit this protocol), SESSION.md — scoped
  from ROADMAP's 011 section and the assessment's §Plans; where that
  section says chartering collects owner decisions (pricing and the tier
  table), the charter names each as a Blocker with options and a
  recommendation — never invents the answer. Then mark 010 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". A PostgreSQL 16 cluster runs here
without Docker (the daemon is down, the server binaries are installed):
initdb, start, apply every `apps/api/migrations/*.up.sql` in order, and the
repository integration tests stop skipping.

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 artifact 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 010 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 009's, which was 006's, 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: served over kinds, printed by scripts/check-hosting-parity.mjs and committed beside it. It rises only in the commit that adds the serving path's reader. This is 007's enforcement ledger and 009's lifecycle ledger, one subject over.
  • The new rule is this track's own, and it is the whole track. Every previous track's inputs came from the product's own forms; this one's arrive as an archive somebody else built. So the rule is not "validate uploads" — it is that no field, name, path or byte inside the artifact is ever the thing that decides where it is written, what it is called, or what the response says it is.
  • The riskiest thing this track can ship is a second address. 008 found one at /uploads/* and recorded its blast radius; 009 found seven doors behind one lapse. A bundle multiplies both by the number of files in it, which is why the gate holding per entry is a phase bar rather than a review note.
  • Three owner decisions are named, not guessed — the storage model, the size model, and what a hosted artifact may execute. The third is 007's public-origin question arriving for the third time; this charter's answer is to make the origin configuration and refuse the option that hands an author's build the session token.

Source: .station/jobs/010-artifact-hosting/ROUTINE.md

Library