Skip to content
Toolkit

Job 010: artifact-hosting

Status: DONE Owner: @work, the routine

Phase: all six met · Status: DONE (close-out) · Updated: 2026-08-30

Scoreboard: npm run check:hosting — 5 of 5 served (3 document, 1 bundle, 1 asset) and 5 of 5 caps read from configuration. Every kind an author can bring is hosted: html (008's), markdown, svg, zip-bundle at the resource's own address, and now bundle-asset — every other file of a bundle, at an address under it and behind the same gate.

Dependencies: none open. 009 is DONE (close-out) and leaves the serving path evaluating gates, display rules, schedules, click limits and a lifecycle predicate — all of which a bundle's every entry has to pass. 008 left FileStorage with a read side (local under a root guard, S3 by a signed GET) and ADR-0102/0103, which are this track's floor rather than its starting point. Charter: ./README.md. Routine: ./ROUTINE.md (batch loop, claim refs claim/010-*, budgets — inherited from 009 unchanged, plus nothing the artifact contains decides anything). Source: product gap assessment .archives/removal-safe/docs/assessments/PRODUCT-GAP-ASSESSMENT-082926.md §Host.

Objective

An artifact an author already built is hosted: stored under a stated model, unpacked where it is a bundle, addressed file by file under the resource's own slug, and served through the same gate, schedule and limit every other public document passes — with the product deciding each file's content type rather than inheriting the author's word for it. The charter's phase table carries the bars; they are not restated here.

Completed

  • Chartered — README, ROUTINE (009's protocol, claim namespace claim/010-*, plus the nothing-decides rule), this file; ROADMAP's 010 row flipped ACTIVE and 009 closed DONE in the run before. Findings re-verified against 7fe909f rather than inherited, and the assessment is stale in two places because 008 shipped in between: handlers/static_pages.go:105 already accepts text/html and application/zip (the allowlist the assessment quotes governs the file type and generic uploads), and archive/zip is imported — by handlers/account.go, for the account export. What holds: nothing unpacks an upload; stored_static.go:84 404s a static page whose document is not HTML and names this track; no serving path resolves a second file in a bundle; text/markdown appears in no allowlist and image/svg+xml is excluded twice with F-5's reason; one 10 MB constant caps every upload; and all fourteen plan quota axes are counts, none in bytes.

  • Phase 00 — the hosting ledger and its gate, minted before any kind is widened. scripts/hosting-ledger.json holds five rows, html alone served, and npm run check:hosting (rules H1–H7) is in verify, reporting 1 of 5. A served row names its store, its serving path, the bound that refuses an oversized upload before a byte is written, the place the product decides the content type, its test — and, for a bundle or asset row, hostile fixtures. H7 is the track's own rule made checkable: every Content-Type a serving path sets is an expression its row declares, and no serving path may call http.DetectContentType — sniffing at upload checks a declaration, sniffing at serve is the artifact deciding. Caps stay visible rather than forbidden: the ledger names each key, points bound at today's constant and commits a second count, configured = 0, which phase 04 moves (ADR-0122). Watched failing nine ways, including the author's declared type written into the response and a serving path that sniffs (evidence .station/jobs/010-artifact-hosting/evidence/phase-00-gate-watched-failing-2026-08-30.md)

  • Phase 01, first slice — Markdown, stored and served in one commit. text/markdown joins the static allowlist, the agreement check accepts a plain-text sniff and refuses an HTML one, and the product RENDERS: a bounded subset, escaped first, so every tag in the response was written by this tree and none by the author — no sanitiser to get wrong. Links carry http/https/ mailto only (a relative URL would resolve against the product's own origin), images render as alt text rather than as a request to another host, and ADR-0103's headers are set whole. The kind is now a stored fact (settings.static_kind), written at upload and read at serve, never off the file's extension — with the pre-existing extension branch kept for HTML rows written before that fact existed (ADR-0123). Proved on a running stack — PostgreSQL, 41 migrations, the API built from this tree — and watched failing twice: the renderer removed, and the extension deciding (evidence .station/jobs/010-artifact-hosting/evidence/phase-01-markdown-running-stack-2026-08-30.md)

  • Phase 01, second slice — SVG, and phase 01 closes with it. F-5's exclusion is ANSWERED rather than deleted: image/svg+xml joins the STATIC-page allowlist and stays out of both image allowlists, with one test holding all three facts so widening the wrong door fails the build. An SVG is served as stored — it is the document, so there is nothing to render — with ADR-0103's headers whole, and its content type declared from the kind on the row (ADR-0124). The gate, the interstitials and 009's lifecycle predicate hold on the new kind because the branch sits below them, proved on a running stack: a sensitive-content mark 302s to the door and a lapsed row 404s on the same document that serves 200. Watched failing three ways — the headers dropped (the branch then inherits the app's global script-src 'self', which is F-5's finding live), the type declared nowhere in the ledger, and the type taken off the stored file's name. H7 was refined in this slice and the refinement is in the ADR: the check is the union across rows naming a serving-path file, not every row restating its neighbours' decisions (evidence .station/jobs/010-artifact-hosting/evidence/phase-01-svg-running-stack-2026-08-30.md)

  • Phase 02, first slice — the bounded refusal. An archive is judged WHOLE before a byte of it is stored: traversal (checked on the name as it arrived, because cleaning first inspects a name the archive never contained), absolute and drive-qualified paths, a backslash separator, a symlink, an irregular mode, a case-insensitive duplicate, the entry count, the per-entry size, the total expansion and the compression ratio — every one a bound read from config.HostingLimits(), which also takes over the per-file cap and demotes services.MaxUploadSize to its default (ADR-0125). The inspection runs before SaveFile on both write paths, so a refusal is the whole upload — proved on a running stack with four hostile archives built outside this tree: four 400s, zero rows, zero bytes, one ordinary archive stored, and the same ordinary archive refused by a deployment that set HOSTING_MAX_BUNDLE_BYTES=100 with no code change. The zip-bundle row does not flip: nothing serves a bundle, and the gate holds it there. H3 was relaxed so a row may be bounded before it is served (evidence .station/jobs/010-artifact-hosting/evidence/phase-02-bounded-refusal-running-stack-2026-08-30.md)

  • Phase 02, second slice — the expansion, and phase 02 closes with it. An accepted archive's files are written under a minted per-resource prefix and a manifest beside them maps the paths the archive used onto the keys the bytes went to. The write API accepts no name — that is the security property rather than a convenience, since the method that would have taken a path is the one a traversal is aimed at — so the leaf is minted, carries no extension, and a prefix is a shape this product mints, checked again before the one RemoveAll in the tree. The manifest is written LAST and any failure removes the whole prefix, the disk's own failures included; the expansion runs before the archive is stored, so a bundle that cannot be written out costs no row and no byte. A refused cap is a 400 naming the rule and a failed write is a 500, because telling a stranger their archive was wrong when the disk was full is a lie (ADR-0126). zip-bundle stays unserved and a bundle still 404s — nothing reads a manifest until phase 03. H3 widened as ADR-0125 widened it once already: an unserved row names its whole store half and the gate holds those anchors. Proved on a running stack and watched failing seven ways, one of them the inversion rebuilt and run live — the archive naming the file put ../etc/passwd two directories above its bundle, on a 201 (evidence .station/jobs/010-artifact-hosting/evidence/phase-02-expansion-running-stack-2026-08-30.md)

  • Phase 03, first slice — the bundle serves its index. The product NAMES the entry a site opens with (index.html), records it on the manifest at expansion and reads it from there at serve — not the first entry, not the shallowest, not something the archive nominates, each of which is the artifact deciding; an archive with none is refused whole at upload, because a site nothing can open would be stored bytes no serving path reads. The entry is resolved by manifest LOOKUP and opened at the key the product minted; the manifest's address is composed from the prefix on the row rather than stored beside it (ADR-0119's rule, one subject over — bundle_manifest was dropped from settings in the same commit), a manifest naming a key outside its own bundle is refused entirely, and a version this build does not read is refused rather than guessed at. The branch sits below the lifecycle predicate, the targeting rules, the schedule, the click limit and all three interstitials, so a bundle inherits the gate rather than being handed a second one; ADR-0103's headers are whole and unchanged, since what would relax them is Blocker 3 and that is the owner's (ADR-0127). Scoreboard 3 → 4. Proved on a running stack — the index served, a no-index archive refused with nothing stored, a sensitive mark 302ing to the door and a lapsed row 404ing on the same document that serves 200 — and watched failing six ways, one of them live: with the containment check removed and the API rebuilt, an edited manifest served another bundle's bytes on a 200 (evidence .station/jobs/010-artifact-hosting/evidence/phase-03-bundle-index-running-stack-2026-08-30.md)

  • Phase 03, second slice — the asset address, and phase 03 closes with it. Every OTHER entry has an address under the resource's own, reached through the same Handle: the lifecycle predicate, the targeting rules, the schedule, the click limit and all three interstitials run for the hundredth file exactly as for the index — 009's seven doors applied to a directory, and a second serving function is how one of them gets left out. The visitor's path is a manifest KEY and nothing else, so a traversal has nothing to traverse and the product's own manifest is not an entry. The content type is a CLOSED table of this tree's, keyed by the entry's suffix — a lookup key, never a value copied out of the archive — with application/octet-stream for anything else and JavaScript deliberately absent, because sandbox runs no script and calling it one would be the response saying what the floor refuses. An entry is evaluated by the click limit and never spends it. Two things the slice had to settle to work at all: a bundle's own address is a directory (/l/{slug} 302s to /l/{slug}/, below every refusal and above the click record) so relative references resolve under the resource; and the origin a document may load its own files from is configuration (HOSTING_ARTIFACT_ORIGIN), because sandbox gives an opaque origin and 'self' is exactly what an opaque origin does not match — unset keeps ADR-0103's floor whole, and which origin it should be is Blocker 3's (ADR-0128). Scoreboard 4 → 5. Proved on a running stack — the index and its stylesheet served, per-entry types from the table, five hostile paths 404ing, three entry fetches adding no click, and the gate, the lifecycle and the limit each holding on an entry — and watched failing five ways, one of them live: with the lookup replaced by a path join and the API rebuilt, one bundle served another bundle's secret and its own manifest, both on a 200 (evidence .station/jobs/010-artifact-hosting/evidence/phase-03-bundle-assets-running-stack-2026-08-30.md)

  • Phase 04, first slice — storage measured. What a workspace stores is a number this product knows: migration 000042 adds links.stored_bytes, written by the paths that WRITE bytes and by nothing else — deliberately not a column on Update, which reads a struct back and writes it whole, so a number riding along would be cleared by every edit that said nothing about it (#393's defect, twice learned by this table). The figure comes from the BACKEND: SaveFile now reports what it wrote, because the store is the only party that knows what landed and the only number that also counts a bundle's expansion — so a bundle is archive + expansion, which is what deleting it frees. The workspace total is DERIVED, summed over the rows that carry the tenant in one query (006's ADR-0112, one subject over) and drawn on the owner's own read as a Studio Stat; a sum that fails costs the figure, never the list. No quota axis is added and no number seeded — the ladder is 011's and what a plan may store is Blocker 2 (ADR-0129). Proved on a running stack — the migration up, down and up against a live database; a bundle at 647 + 139 and a document at 29 totalling 815 on the owner's read; an edit that stored nothing leaving the number alone — and watched failing with the expansion uncounted, live and at unit level (evidence .station/jobs/010-artifact-hosting/evidence/phase-04-storage-measured-running-stack-2026-08-30.md)

  • Phase 04, second slice — the bound. storage_bytes_limit joins the quota registry as its first MAGNITUDE axis, registry-shaped and unseeded (the ladder and its numbers are 011's; an unset quota unlimits). It is not a count and the difference is the slice: the comparison is current + incoming > max, because under check's own current >= max a workspace one byte under its allowance accepts a fifty-megabyte archive. The amount is the PRODUCT's: a file is charged what the multipart reader took off the wire, a bundle the archive plus what InspectBundle measured its entries coming to — so InspectBundle now reports that total, and the bound is asked BEFORE ExpandBundle writes anything. A replacement is charged the difference, the row's own figure credited. The measurement is of the WORKSPACE and the allowance is the writer's plan, whose consequence in a shared workspace the ADR states rather than leaves to be found. ValidatePlanQuotas's ceiling becomes per axis — maxPlanQuota's billion is a narrowing reason belonging to the count path, and a small allowance of storage (ADR-0130). check:entitlements widened to follow the family (Register\w*, check\w*); watched failing five ways, three on the gate and two on what no gate can see — the count's comparison, and the bound asked after the expansion had written (evidence .station/jobs/010-artifact-hosting/evidence/phase-04-bound-watched-failing-2026-08-30.md)

  • Phase 04, third slice — freeing. The figure is derived, so a delete moves it to zero whether or not a byte was freed — and three delete paths were freeing three different amounts. StaticPageHandler.Delete removed the archive and left the whole expansion, the larger half and the one with no other referent once the row is gone; LinkHandler.Delete, which deletes a row of ANY type by id, freed nothing at all, so the same resource lost its bytes through one door and kept them through another. One function frees now, called by all three: the expansion first, best effort, and never a condition of the deletion — a delete that refused over a byte would leave the owner with a resource they cannot get rid of. The generic path reads the row first, because what it holds is only knowable from it, and releases only behind the same workspace test the deletion makes (ADR-0131). Watched failing on both states this tree was actually in — the generic path freeing nothing, and the release freeing the archive and not the expansion — with the tenant boundary asserted rather than assumed (evidence .station/jobs/010-artifact-hosting/evidence/phase-04-freeing-watched-failing-2026-08-30.md)

  • Phase 05, first slice — one address. The bytes were reachable at three addresses besides the resource's own. /uploads/* answers to a PATH rather than to a resource, so it consults no gate, no schedule, no click limit and no lifecycle state; file_url was composed onto every file link the owner reads, pointing at that mount, so the product handed the author a working way around the gate the author had set; static_url was composed from static/<folder>/index.html, a directory nothing in this tree has ever written, so that button 404'd for every owner who followed it. This slice takes a bundle's half of the mount and both composed addresses: GuardUngatedUploads refuses anything under the bundle root — every entry has had a gated address since phase 03, so the mount's copy is the way around rather than a fallback — reading the CLEANED path, because that is what a file server opens, and testing the prefix the PRODUCT mints. The mount's F-5 headers move into the same function and are set on the refusal too. Both owner surfaces now link to shortLinkUrl(url), the resource's own address, which for a file link is strictly better than what it replaced and for a static page is the first working link it has ever had (ADR-0132). Watched failing twice — the door as it stood, and the guard reading the raw path, which refuses the obvious spelling and answers the climbing one (evidence .station/jobs/010-artifact-hosting/evidence/phase-05-one-address-watched-failing-2026-08-30.md)

  • Phase 05, second slice — the document paths. The half the first slice left open, and the harder one: a file link's document and a static page's HTML, Markdown, SVG or archive were written by the same SaveFile to the same <date>/<random>.<ext> as an avatar, so /uploads/* served a gated document to a visitor the gate had just refused and no test at the mount could have known. Nothing about the REQUEST tells them apart and nothing ever will; what tells them apart is the PURPOSE of the write, which is known at write time and nowhere else — so the write records it as the place the bytes go (services.DocumentPrefixRoot, both backends, the same shape bundles/ already had) and the mount reads that back, its refusal list being the product's own constants asserted against the constants. A path→row lookup was rejected with its reason: it closes the old rows too, but puts a query in front of every avatar and lets a deleted row un-gate its orphaned bytes (ADR-0133). Documents written before the split keep their second address and moving their bytes is Blocker 4. Watched failing six ways (evidence .station/jobs/010-artifact-hosting/evidence/phase-05-document-paths-watched-failing-2026-08-30.md)

Active

Nothing claimed.

Open items

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

  • /uploads/* is a second, ungated address for every stored document (cmd/server/main.go:988), and static_pages.go's List and Get compose static_url from static/<folder>/index.html, an address nothing ever wrote. Inherited from 008's close-out; it is phase 05 here rather than an open item, because hosting is the track that owns the bytes.
  • A standalone splash_page link still falls through default: past the document it already has (008's close-out). Not this track's; recorded so it is not rediscovered.
  • Rows written before 000042 read 0 bytes until something rewrites them. Measuring is a forward fact and a migration cannot stat a bucket; a backfill that walks the store per backend is a decision, not a slice's aside.
  • Generic uploads (/api/v1/uploads) are counted by nothing — they have no resource row to record on. The other half of phase 05's /uploads/*.
  • A gated bundle's subresources are refused rather than served. A grant travels in the query (ADR-0092) and a browser fetching a stylesheet does not carry one, so an entry of a password-gated or sensitive-marked bundle 302s to the door. The gate holding is the phase bar and it holds; a grant a subresource could carry is a change to 007's mechanism, not this slice's.
  • The live E2E suite does not run in this environment — Playwright's browser build does not match the pre-installed Chromium, and the dev server wants API_PROXY_TARGET at the API's real host. A PostgreSQL 16 cluster, however, runs here without Docker (binaries installed, daemon down), so repository integration tests do not have to skip.

Blockers

All four are owner decisions with options and a recommendation in the charter; none blocks phases 00–02 or 04–05, and the third gates only the part of phase 03 that is script.

  1. What is the storage model for a bundle? Recommendation: expand at upload under a per-resource prefix with a stored manifest, so the read path is the one 008 already built and the asset path is a lookup rather than a path join.
  2. What may a plan store? Recommendation: the per-file cap becomes configuration defaulting to today's 10 MB, and a per-workspace bytes axis joins the quota registry unseeded — 011 owns the ladder.
  3. What may a hosted artifact execute, and on which origin? Recommendation: no script now, a separate session-free origin as the real answer — 007's blocker 2 and 008's re-presentation of it, arriving a third time with a concrete need. Handing an author's build the origin where sessions live is refused outright rather than offered as an option.
  4. What happens to documents already stored at the shared paths? Raised by phase 05's second slice: every gated document written from it on is under documents/, which the mount refuses; every one written before it is indistinguishable from an avatar by construction and keeps a second, ungated address. Recommendation: a one-off operator relocation — copy, update the row, delete the old object — finite work on a known set, and it keeps the mount's test a pure shape test on where the product put the bytes.

A fifth question the charter answers rather than asks: the product decides the content type, for every byte a stranger uploaded.

Decisions

  • The ledger before the widening — 007's enforcement ledger and 009's lifecycle ledger, one subject over: a kind is unserved until a named serving path reads it, and a row flips only in the commit that adds that path.
  • Nothing the artifact contains decides anything — not its declared type, extension, first bytes, stored entry size or internal path. The product decides where a byte is written, what bounds it and what the response calls it, before reading what the artifact says about itself.
  • A refusal is the whole upload — a half-unpacked bundle is never stored.
  • ADR-0103 is the floor — no script, no origin of its own, no outbound fetch, until an owner answers Blocker 3.

Files changed

  • .station/jobs/010-artifact-hosting/ — charter, routine, this file, evidence
  • scripts/hosting-ledger.json, scripts/check-hosting-parity.mjs, package.json (check:hosting, in verify)
  • apps/api/internal/services/markdown.go (+ test), internal/models/link.go (the kind vocabulary), internal/handlers/static_pages.go, internal/handlers/stored_static.go (+ tests)
  • apps/api/internal/config/hosting.go (every limit, with its default), internal/services/bundle.go (+ the hostile-archive suite), internal/services/storage.go and storage_s3.go (the cap they are handed)

Verification

The charter's §Verification, unchanged from the last five 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, each migration applied and rolled back against a live database before any handler reads its column — plus this track's own: a hostile archive per unpacking rule, each watched refusing the whole upload.

Next actions

  1. Charter 011 — the plan ladder. 010 is closed (close-out); the handoff item is the next track's charter, per docs/guides/workstream.md: README, ROUTINE.md inheriting this protocol, SESSION.md, scoped from ROADMAP's 011 section and the assessment's §Plans, with pricing and the tier table named as Blockers with options and a recommendation rather than invented.

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

Library