oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1# The page renderer out of the instance (design note)
2
3Status: rev 4, built on this branch. Rev 2 was approved by the
4coordinating session (2026-11-30). Rev 3 adds the host probe's findings and
5the SOURCES record. Rev 4 folds in Astra's build round 1 (below). Branch
6`renderer-out-of-instance` off main dd66ff0c. Rev 1 had one Astra review
7(NOT READY, 4 Important, 2 Minor). Its findings are folded in below and
8listed at the end. It was not reviewed again.
9
10## Problem
11
12dd66ff0c's instance artifact is 374 MB. `scripts/build-instance-release.sh`
13copies the Linux runner's `renderer.tar.gz` (230,650,088 bytes) into
14`internal/release/bundled`, which `//go:embed bundled/*` links into the
15instance so it can serve `/releases/<version>/renderer.tar.gz`. CARLOS caps
16one ship at 256 MiB (carlos/platform `internal/console/apicli.go:1827`), so
17`carlos deploy` answers 413. Ruling (a): the renderer stops riding inside
18the instance binary, and the runner gets it separately, verified as install
19verifies it today. No chunked deploys, no split binary.
20
21## Who reads the instance's copy today
22
23Only the self-serve install: `install-v1.sh` runs the runner's
24`setup.installUser` (`internal/runner/setup/install.go`). It fetches
25`<origin>/releases/<v>/renderer.tar.gz` when no verified tree for the
26linked pin is on disk, and requires the archive's MANIFEST digest to equal
27both the pin linked into the runner (`release.rendererSHA256`) and the
28install manifest's `targets.linux.renderer_sha256`.
29
30The operator paths never touch it. `scripts/upgrade-thin.sh`,
31`cutover-thin.sh`, `cutover-finish-thin.sh` and `staging-thin.py` run
32the runner's `install-renderer <kit>/renderer.tar.gz` from the release
33kit, after `renderer_linked` checks the MANIFEST digest against the runner.
34The Mac updater (`thin/mac.go`) fetches only darwin assets, and a Mac has no
35renderer. `verify-installed` reads the tree on disk and renders the fixture.
36
37So the change is confined to where the self-serve install gets the archive,
38and to what the instance embeds and serves.
39
40## Decision: a release asset on the forge, addressed by the archive
41
42Each renderer archive is published once as a release on the amadan forge,
43in oficina/equipo, and the runner knows exactly which one:
44
45- The archive digest `rendererArchiveSHA256` is linked into the Linux
46 runner beside the tree pin (`rendererSHA256`), from the same kit file
47 (Makefile `release-runner`).
48- So is a release tag `rendererTag`: `renderer-<first 12 of the archive
49 digest>`, or `renderer-<12>-r<n>` if an earlier publication of the same
50 bytes was withdrawn (see below).
51- The forge origin and repository path are constants in the runner
52 (`https://amadan.net/oficina/equipo/-/releases/`), not data. The runner
53 builds the URL itself: origin + tag + `/renderer.tar.gz`. Nothing the
54 instance or the install manifest says can point it elsewhere.
55
56The asset is the kit's `renderer.tar.gz`, byte for byte. The forge says
57"anyone who can see the repo can download a file", and the repo is public.
58
59The addressing is by archive bytes, not by tree pin. A builder or
60compression change can keep the MANIFEST and change the archive. It then
61gets its own tag rather than colliding with the published one. Most
62releases change neither, link the same tag and publish nothing.
63
64### What the install manifest records
65
66`targets.linux` gains `renderer_archive_sha256` and
67`renderer_archive_size` beside `renderer_sha256` (the tree pin,
68unchanged). They are informational for the instance and for operators. The
69runner checks them against its own linked values and refuses a
70disagreement (`runner.install.checksum`). No URL is recorded.
71
72### Trust does not move
73
74The runner checks, in order, before anything of the runner is written:
75
761. the download is exactly `renderer_archive_size` bytes (bounded by
77 `RendererArchiveMax`, 384 MiB) and its SHA-256 is the linked archive
78 digest
792. the archive's MANIFEST digest is the linked tree pin
80 (`RendererArchivePin`, as today)
813. the unpacked tree verifies in full before it is renamed into place
82 (`InstallRenderer` and `VerifyRenderer`, as today). The MANIFEST check
83 alone does not cover payload bytes.
84
85Redirects: the forge answers the asset URL with `302` to a presigned S3
86URL (host probe, 2026-11-30: `s3.eu-west-1.amazonaws.com`, five-minute
87expiry). So the runner follows exactly one redirect, only from the fixed
88forge URL, and only to an `https` URL with no credentials in it. A second
89redirect, a non-https target or any other status is
90`runner.install.release`. The target host is not pinned: the bytes are
91checked by size and digest, and the presigned host is the forge's storage
92detail. A HEAD, or a ranged GET, is never sent. The forge counts a
93redirect it issues as a download (the probe's HEAD made the release
94impossible to undo).
95
96### The download
97
98One private scratch file (`O_TMPFILE`, or a 0600 file in the install's own
99scratch directory) keeps a single descriptor throughout. The response body
100is copied through a hash, bounded at size + 1. A short read, an overlong
101read, a cancelled context or a failed check deletes the scratch and stops.
102After step 1 the descriptor is rewound for step 2, then again for
103unpacking. The deadline is per transfer, with a long overall bound (for
104example 20 minutes) and a stall timeout, not `fetchRelease`'s 2 minutes. No
105230 MB buffer stays in memory, as one does today.
106
107## What changes, by path
108
109**Instance.** `build-instance-release.sh` stops copying `renderer.tar.gz`
110into the bundle. `install_assets.go` stops requiring it, checking its pin
111and serving it, so `/releases/<v>/renderer.tar.gz` is a 404, as any unknown
112name is. `TestBundledInstallAssets` and the bundle tests drop it. Expected
113artifact size is back near 152 MB. A test bounds the bundle (for example
114the sum of embedded files under 200 MiB) so this cannot regress silently.
115
116**Self-serve install** (`setup/install.go`):
117
118- A tree already verified for the pin is kept and nothing is fetched (as
119 today).
120- Otherwise, if the previous release directory beside it has a tree that
121 verifies for the same pin, it is copied (not hardlinked:
122 `VerifyRenderer` refuses files with more than one link) into a scratch
123 directory, verified and renamed into place. Nothing is fetched.
124- Otherwise the runner fetches its own URL (above), streams to scratch and
125 checks 1-3.
126- Failure keys stay as they are, with no new copy: unreachable means
127 `runner.install.release`, a wrong digest, size or pin means
128 `runner.install.checksum`, and nothing of the runner is written (the
129 order today: renderer unpacked and verified before any runner file).
130
131**Upgrade, cutover, staging** (operator, agent-run): no change. They
132already install from the kit's `renderer.tar.gz` and verify it against the
133runner.
134
135**verify-installed:** no change. The tree is beside the runner, as today.
136
137**Mac:** no change.
138
139## Offline, outage, mismatch
140
141- A runner that already has the tree for its pin needs nothing. Its
142 restarts and Design work never fetch.
143- A new install, or a new pin, while amadan.net is unreachable fails
144 closed, as an install fails today when the instance is unreachable
145 (`runner.install.release`). The old tree and the old release stay.
146- A mismatch at any of 1-3 refuses (`runner.install.checksum`), writes
147 nothing, and the scratch is removed.
148- A runner whose tree is missing or wrong still runs Engineering. Its
149 renderer health says so, and Design waits (`design_renderer`, the
150 existing copy), as today.
151- A withdrawn asset (forge `release withdraw`) makes new installs of that
152 pin fail closed. The fix is a new renderer pin and release, as for any
153 bad build.
154
155## The release kit and the release step
156
157- `make release-runner` keeps building `renderer.tar.gz` into the kit (the
158 operator scripts need it). It links the tree pin, the archive digest and
159 `rendererTag` into the Linux runner.
160- Provenance: `scripts/staged-artifacts.py` records the hashes of
161 `renderer.tar.gz` and of `install-manifest.json` in its `artifacts()`
162 when the kit is staged, and verifies them on every later use. Then the
163 kit's archive and manifest cannot both be swapped after staging while
164 the instance embeds the originals.
165- New step `scripts/publish-renderer.sh <kit>`. It reads the tag linked
166 into the kit's runner. If that release exists, it downloads the asset
167 unauthenticated and requires its SHA-256 to equal the kit's. Otherwise it
168 tags the current commit, runs `amadan release create <tag>
169 <kit>/renderer.tar.gz` and checks the upload the same way. It needs
170 writer access (an agent account's token, or a PAT in CI).
171- Ordering: `staging-thin.py` runs the same check, a full unauthenticated
172 GET of the published asset and its digest against the staged provenance,
173 never a HEAD, as a prerequisite before it installs anything. Staging installs from the kit, so without this an unpublished
174 asset would only show at a user's install. Production promotion goes
175 through staging, so it cannot ship before the asset exists.
176- Withdrawal: if a published asset must be withdrawn, the same bytes are
177 republished as `renderer-<12>-r<n+1>`. A new runner build links that tag,
178 and an Equipo release follows. Runners already installed keep their
179 verified trees.
180
181## Alternatives considered
182
183- **Build the tree on the runner from the pinned debs** (98 packages,
184 171 MB, from snapshot.debian.org by sha256). It needs no new hosting,
185 and `ulikunitz/xz` is already a dependency. But it means a Go port of
186 `build-renderer-tree.py` whose MANIFEST must match byte for byte (or
187 replacing the Python with it). It also means 98 requests per install to
188 a service that asks not to be used as a mirror, and regular mirrors drop
189 pinned Chromium builds within weeks. Kept as a possible later fallback.
190- **A separate CARLOS ship for the archive.** 230.6 MB is 90% of the
191 256 MiB cap, so a Chromium update could cross it. That is the same limit
192 again.
193- **Object storage outside CARLOS** (an S3 bucket, like the platform's CI
194 mirror). New infrastructure, and it steps around the platform.
195
196## Host probe (done 2026-11-30)
197
198The forge accepted a 251,658,240-byte (240 MiB) random blob as release
199`probe-size-20261130` in 1 min 49 s, and reported the same SHA-256. An
200unauthenticated HEAD answered `302` to presigned S3. That HEAD counted as a
201download, so the release could not be undone: an owner withdraws it. The
202full anonymous transfer is proven when staging installs from the published
203asset (below).
204
205## SOURCES: what we distribute
206
207Publishing the archive makes us a public distributor of the Debian
208packages in it and of Chromium. The renderer release therefore carries a
209second asset, `SOURCES`, and its notes say so in one line ("The page
210renderer: Debian packages and Chromium headless shell <version>. Where
211each one's source is: SOURCES.").
212
213`SOURCES` is generated from `internal/release/renderer.json`, the same
214pinned list the archive is built from, by
215`scripts/renderer-sources.py <renderer.json> <SOURCES>`, so it cannot
216drift. It is deterministic text:
217
218- a header: the Chromium headless-shell version (`renderer.json`
219 `version`), and its source package on snapshot.debian.org
220 (`https://snapshot.debian.org/package/chromium/<version>/`, which links
221 the `.dsc` and upstream tarballs)
222- one line per amd64 package, in the pin's order: package, exact version,
223 architecture, the snapshot URL of the binary it was built from, and its
224 source package page
225 (`https://snapshot.debian.org/package/<source>/<source version>/`)
226
227A package's source name and version are not in `renderer.json` today
228(its `package` is the binary). The generator reads them from each `.deb`'s
229`control` (`Source:` field, which defaults to the binary's name and
230version), which the archive build already fetches and checks by sha256.
231So `build-renderer-tree.py` writes `SOURCES` beside `renderer.tar.gz` in
232the same run, and `scripts/renderer-sources.py` is the function it calls.
233A test checks `SOURCES` lists exactly the pinned packages.
234`publish-renderer.sh` uploads both assets. Its check (full GET, digest)
235covers `SOURCES` too, against the kit's copy.
236
237## Astra rev 1 findings and what changed
238
239- Important, URL policy: an https URL from data permits any destination.
240 Now the URL is built from a runner constant and a linked tag, and
241 only one redirect, from the forge to https, is followed (rev 3).
242- Important, provenance: staged artifacts did not record the archive or
243 the manifest. Both are now recorded and re-verified.
244- Important, identity: a tree pin does not identify the compressed bytes.
245 Now addressed by the archive digest, with a revision suffix after a
246 withdrawal.
247- Important, ordering and hosting: now a full-size upload is proven first,
248 and staging requires the published asset as a prerequisite.
249- Minor, download lifecycle: specified (one descriptor, bounded, rewound,
250 scratch removed on any failure), and the full-tree check is kept.
251- Minor, hardlinks: tree reuse copies.
252
253## Tests the build would add
254
255- install builds the URL from the linked tag only, follows one redirect to
256 https and refuses a second, a non-https target or a credentialed URL, and
257 refuses a wrong size, archive digest or tree pin, and a truncated or
258 cancelled download, with nothing written and the scratch gone. It keeps
259 a verified tree without fetching, and copies one from the previous
260 release.
261- the instance bundle has no renderer and stays under its bound; the
262 instance answers 404 for it.
263- manifest validation requires the archive digest and size on Linux, and
264 install refuses a manifest that disagrees with the linked values.
265- `staged-artifacts.py` refuses a kit whose archive or manifest changed
266 after staging.
267- `publish-renderer.sh` refuses a published asset that differs from the
268 kit.
269
270## Astra build round 1 (on rev 3) and what changed
271
272- Important, provenance: adding the archive and the install manifest to
273 `artifacts()` would send them through the Go build-information check.
274 Now every artifact is hashed, and only binaries are asked for build
275 information (`NOT_BINARIES`). The exact Linux-target comparison
276 includes the archive's digest and size.
277- Important, SOURCES lacked provenance. It is now one of the staged
278 artifacts, hashed and re-verified like the archive.
279- Minor, tagging: `publish-renderer.sh` tags the kit's `COMMIT`, never the
280 checkout, and refuses a forge tag on another commit.
281- Minor, size: the archive size is linked into the runner
282 (`rendererArchiveSize`) from the same file, and `RendererAsset.Valid`
283 requires `0 < size <= RendererArchiveMax`.
284
285