ADR-0123 — The product renders the Markdown, and the kind is a fact on the row
Status: Accepted · Date: 2026-08-30 · Track: 010 artifact hosting, phase 01 · Supersedes: nothing · Related: 0096, 0103, 0122
Context
text/markdown was in no allowlist in either tree, so Markdown had no serving
path to be excluded from. Adding one raises two questions that look unrelated
and are the same question.
What does the product do with the bytes? Markdown carries raw HTML by specification. A renderer that passes it through produces a static page with none of ADR-0103's protection in front of it — the author picked the Markdown door and was served through the HTML one. And the usual answer, "render, then sanitise", is a promise about a component nobody in this tree owns: a sanitiser is a denylist of everything markup can do, and it is wrong in exactly the cases that matter.
How does the serving path know it is Markdown? The existing static branch
reads the stored file's extension (storedStaticIsHTML). That extension came
from the uploaded filename, which came from a stranger. It was harmless while one
kind was served — a wrong answer meant a 404 — but with a second kind it decides
which renderer runs, and that is the thing ADR-0122's rule H7 forbids.
Decision
1. The product renders, and escaping comes first. services.RenderMarkdown
escapes the source before anything else looks at it, then emits a bounded subset
— headings, paragraphs, lists, blockquotes, code, emphasis, links. Every tag in
the response was written by this tree. There is no sanitiser to get wrong,
because nothing of the author's is ever treated as markup, and a construct the
subset lacks renders as the text it is, which is the failure direction that
cannot hurt anybody.
Two narrower calls follow from ADR-0103 rather than from Markdown:
- A link may point at
http,httpsormailto.javascript:is the obvious refusal;data:is the same defect wearing another word; a relative URL is worse than either, because it resolves against the product's own origin and turns an author's document into a navigation into the app. A refused link keeps its words and loses its destination. - An image renders as its alt text. A remote image is a request to another
host on the visitor's behalf — the unlisted beacon 007 phase 03 refused to
emit — and ADR-0103's
img-src data:would block it anyway. An author whose picture silently fails to load is worse served than one whose words say what was meant to be there.
The response is text/html because the product produced HTML, not because
anything about the upload said so, and it carries ADR-0103's headers whole: a
Markdown page that could act would be the HTML door with a step in front of it.
2. The kind is a fact the product stores. The upload path writes
settings.static_kind — html, markdown or bundle — decided from the
declared type it had already agreed with the bytes, and the serving path reads
that. The artifact's name never decides which renderer runs.
One exception is written down rather than generalised: a row created before this fact existed has no kind, and for those rows the extension is consulted for HTML only — the pre-existing branch, unchanged, kept for the rows it was already serving. Markdown has no legacy rows by construction, so it is served only where the product itself wrote the kind down.
Consequences
check:hostingreads 2 of 5. The row flipped in the commit that added its serving path, which is ADR-0122's rule and the reason the html row's own anchors had to be updated in the same diff: the gate refused the change until they named the branch that now exists.- A declared-Markdown document that sniffs as HTML is refused. The agreement check (F-6) accepts a plain-text sniff and not an HTML one, so the doors stay separate at the entrance rather than downstream.
- The subset is a floor, not a ceiling: tables, footnotes and the rest can be added, each as a construct this tree emits. What may not be added is a mode that passes the author's HTML through — that is the HTML kind, which already exists and already has its headers.
- The renderer is ~300 lines of this repository rather than a dependency. That is a deliberate trade: the escape-first design is what makes it small enough to read, and a Markdown library's value is in the constructs this subset declines to support.
- Proved on a running stack against a real database, and watched failing twice —
the renderer removed (the author's
<script>served verbatim astext/html), and the extension deciding (a row the product never recorded, served 200 instead of 404) (evidence.station/jobs/010-artifact-hosting/evidence/phase-01-markdown-running-stack-2026-08-30.md).
Source: docs/decisions/0123-the-product-renders-the-markdown-and-the-kind-is-a-fact-on-the-row.md