Skip to content
Toolkit

ADR-0096 — A pixel emits as a beacon, because the origin is where sessions live

Status: Accepted · Date: 2026-08-29 · Track: 007-enforcement, phase 03

Context

links.pixels_ids has been in the schema since 000001. The /pixels surface mints pixels against a 24-provider registry, the link create handler declared a pixels_ids field, and no visitor has ever been counted: the field was decoded into an interface{} and never assigned, no INSERT or UPDATE named the column, no SELECT read it, and no page emitted anything. Every layer existed and none of them touched.

Phase 03's row is the last in the enforcement ledger, and it has been waiting on one question the earlier phases did not have to answer: where a pixel emits. A pixel needs a document, and the redirect path is a 302 — it has no document at all. The ledger's own note forbids the obvious workaround: a synthetic redirect page invented to carry a tag is a page nobody asked for.

That leaves the documents the product actually serves. Phase 02 shipped two of them — the password/warning interstitial and the splash — and the public biolink page has always been one.

Decision

1. The surface is the author's document, never the product's chrome

A pixel emits on the public biolink page and nowhere else.

The interstitials are excluded, and by an existing rule rather than a new one: ADR-0094 settled that a splash page is drawn from the product's own allowlist and never carries the author's custom_js. An interstitial is the product speaking to a visitor about a resource — refusing them, warning them, holding them. An advertiser's tag fired there measures the product's own refusal, on a page the author does not own. The same reasoning excludes it that excluded their script.

When 008 adds public renderers for the remaining resource types, each is the author's document and each may carry the same beacons. That is a widening of this decision, not a reversal.

2. A pixel emits as an image, never as a script

The public page is served from the app's own origin — the origin whose localStorage holds the session token (services/api.ts). A provider's <script> tag runs with full read access to it, so a biolink page carrying a tracking script would hand every configured vendor, and anyone who compromises a vendor's CDN, the token of any logged-in user who happens to view any public page in the product. This is ADR-0094's finding one surface over, and it is worse there than it was for custom_js, because the author is not even the attacker: the vendor is a third party neither party controls.

So a pixel emits as the provider's own no-JavaScript beacon — the <noscript> half of the snippet every provider publishes — requested as a 1×1 image. An image cannot read storage, cannot reach the DOM, and cannot execute. It carries the top-level referrer and the provider's own cookies, which is exactly what the noscript fallback is for.

The ceiling is real and is named here rather than discovered later: a provider with no beacon does not emit, and no amount of registry data changes that. Of the 24 registered providers, four publish one this port can build — facebook, linkedin, pinterest, quora. The rest (google_analytics, google_tag_manager, tiktok, the session-recording and chat vendors) are script-only by design and are unemitted, not silently half-emitted. Lifting that ceiling means serving the public pages from an origin that holds no session, which is an owner decision with an infrastructure cost, recorded as a blocker rather than assumed.

custom never emits at all. Its stored value is the author's own HTML, which is precisely what ADR-0094 refuses to run here — and its column holds 64 characters, so it could not hold a working snippet in any case.

3. The address is built server-side

The registry entry carries the provider's template with {id} in it, and models.PixelBeaconURL fills it. The renderer is handed a URL to request and knows no provider, the way a framed block is handed embed_url and knows no service (ADR-0055). Adding a provider is a row in pixel_types.go; apps/web does not change.

An author's id reaches that address, so it is bounded to ^[A-Za-z0-9._-]{1,64}$ — every registered provider's id is an opaque alphanumeric token, so the charset costs nothing and leaves the substitution unable to carry a second query parameter, a path segment or a scheme into a URL the visitor's browser will request. A value outside it emits nothing.

4. The workspace is the boundary, and it is on the serving side

The write path stores the ids it is given, normalized (positive, deduplicated, capped at 25) and nothing more. The serving path resolves them within the link's own workspace (ListByIDs), so an id belonging to someone else resolves to nothing and emits nothing — whoever wrote it, and whenever. A boundary on the read is one a write that predates it cannot walk around.

Measurement never costs a page: a resolve that fails is logged and the page serves without it. A biolink that will not render is a worse outcome than one that is not counted.

Consequence, and the defect this uncovered

Adding pixels_ids to the link UPDATE meant checking what that statement writes against what GetByID — the read the edit path builds its struct from — loads. It loaded neither splash_page_id, nor display_rules, nor timezone, nor scheduled_at/scheduled_end, all five of which the UPDATE writes. Each therefore arrived as its zero value and was written back as one: renaming a link cleared its targeting, its splash page, its timezone and its schedule — silently un-configuring the enforcement phases 01 and 02 had just built, from the neighbouring write path.

This is #393's rule on the write side, and the same sentence covers both: a query that omits a column does not fail, it substitutes a zero. GetByID now selects every column Update writes, and an integration test renames a link and reads the other five back. pixels_ids would have been the fifth casualty.

Alternatives rejected

  • Emit the provider's script anyway. The exposure above, for every logged-in viewer of any public page.
  • Run the scripts in a sandboxed iframe. An opaque origin cannot set the provider's cookies, so the retargeting the pixel is bought for does not happen. It would be emission that measures nothing — the shape this whole track exists to remove.
  • Move the token out of localStorage first. The right long-term answer and a cross-cutting change of its own; it does not belong inside a phase whose subject is emission.
  • A synthetic redirect page so a 302 can carry a tag. Forbidden by the ledger row itself, and it would be a page nobody asked for standing between a visitor and their destination.

Source: docs/decisions/0096-a-pixel-emits-as-a-beacon-because-the-origin-is-where-sessions-live.md

Library