A snippet sequence · after the eighteen steps

The Frame, Not the Paint

A snippet sequence in three steps: transplanted pages that can wear the site's header — without the system touching a single byte of them.

The wish: on any device, the non-managed pages — the transplanted raw documents and the folder-served files — may optionally wear a header like the one the managed pages wear, chosen by a checkbox in the edit window.

A snippet sequence obeys the three rules of the original, plus three of its own. It must attach at points in the existing structure you can name. It must leave a live datastore untouched, or touch it only by addition — existing entities never learn that anything happened. And it must be the least of all sufficient changes, using organs the organism already has.

And this wish walks straight into the organism's oldest promise about those pages, made at step five and renewed by snippet A: served exactly as stored, byte for byte, never touched. A lesser resolution would quietly bend the promise. The snippet's entire work is to keep it absolutely — which turns out to decide the whole design.

Step D1

The recorded wish

A page may ask for the site's coat; the asking is a fact about the page, so it lives on the page.

A boolean on the Page: chrome, default off. This is the first new model field in four snippet sequences, and it is taken only after the cheaper routes are checked and refused: kind already means something else; body is spoken for (snippet A spent it); a naming convention would be a meaning hidden in a string, which is a lie waiting to be believed. When a wish is genuinely a new fact about a page, the honest place for it is a field — and a defaulted boolean is addition-only tissue: every entity in a live datastore already reads correctly without being written.

Then the dividend arrives, from two snippets back. The export manifest carries the flag automatically (it speaks whole records); old archives that have never heard of it import cleanly, the field taking its default through the tolerance clause. etl.py changes by zero lines. When snippet B claimed its archive format was built to unfold, this is what it was claiming.

@dataclass
class Page:
    ...
    in_nav: bool = False    # step 8
    chrome: bool = False    # snippet D: raw/file pages may ask
                            # for the site header

# etl.py — no change. The flag rides the manifest; old archives
# import with the default. Snippet B's promise, collected.

Addition-only tissue: a defaulted boolean, and a dividend.

Step D2

The frame, not the paint

The header stands around the transplanted page; it is not painted onto it.

Three ways to put a header on a document the system has promised never to touch. Surgery: parse the document, extract its body, pour it into the site template — the promise broken outright, and every transplanted script or stylesheet that assumes its own document structure breaks with it. Imitation: inject a lookalike header bar into the bytes at serve time — the stored bytes survive but the served ones don't, and a lookalike drifts from the real chrome one adjustment at a time. The frame: serve the genuine chrome — the actual masthead, the actual navigation, the reader's actual login state — around an inline frame whose source is this same address with ?bare=1; and at the bare address, serve the document exactly as before, byte for byte.

The frame wins on every axis the promise cares about. The document's bytes, scripts and styles are never entered. The header is the real one, not a copy. And because the bare address is the address, every relative reference in the document — snippet A's companion stylesheets and images — resolves exactly as it always did. Sizing on any device is one flex column, scoped to this template alone: the header keeps its natural height, the frame takes every remaining pixel.

framed = (page.chrome and page.content_type == "text/html"
          and "bare" not in request.args)
if framed:
    body = render_template("frame.html", page=page, **chrome())
    return cached_response("/" + path, body)

# frame.html:
#   <iframe class="transplant"
#           src="/{{ page.path }}?bare=1"></iframe>
#   body { display:flex; flex-direction:column; height:100dvh }
#   main { flex:1; ... }  iframe { flex:1; width:100% }

The same address, bare, inside the genuine chrome.

Step D3

The checkbox joins its kinds

A control appears only where its meaning does.

The checkbox — Wear the site header — joins the edit form beside its siblings from step eight, and shows itself only when the chosen kind is raw or file: a managed page always wears the chrome, so offering it the choice would be a control without a meaning. One guard travels with it: the frame applies only to text/html, so a companion stylesheet with the flag mistakenly set stays exactly what it is.

The verification, nine points, two worth naming. The bare address was compared to the stored document byte for byte — not "looks right," but equality — because that is the promise under test. And the rendered form was checked as rendered, with the checkbox present and the surfaces alive, because the previous erratum taught this sequence where its end-to-end actually ends: at a person in front of the form.

document.getElementById("chrome-label").style.display =
  (k === "raw" || k === "file") ? "" : "none";

# and the test that matters most:
bare = client.get("/demo?bare=1")
assert bare.data.decode() == RAW_DOC    # byte-for-byte, or fail

The control where it means something; the promise, tested as bytes.

What it cost, and what it proved

The totals: one boolean on the model (the first new field in four snippets — taken only after establishing that no existing field could carry the meaning), one new template, one branch in the serving pathway, one checkbox, and three lines of JavaScript. etl.py: zero changes — the flag rides the manifest automatically, old archives import with the default, and snippet B's tolerance clause pays its first real dividend.

The cost, stated as always: at its chosen address, a framed page's content now sits one frame deep, which crawlers read more weakly than inline content — the reason the coat is per-page and off by default. A raw page that wants both the header and full crawlability is telling you it wants to be a managed page; the checkbox is for the ones that don't.

And the promise, restated more precisely than it was ever stated before: the system does not touch the transplanted document — not to store it, not to serve it, and now not even to dress it. The frame stands on its own feet, around the window; the glass is never painted.