TRAIL Search tells a brand what to change on its pages so that AI answer engines can read and cite them. A prescription is worth nothing until it is on the page, and most clients cannot put it there: the shop runs on a hosted commerce platform, or nobody on their side edits the site's source. This layer is how an approved change reaches a client's page anyway, by whichever channel the client's own permissions allow.

  • RoleFounder of TRAIL Labs and sole engineer
  • TimelineBuilt July to September 2026. Serving client traffic
  • EdgeCloudflare Workers, Workers KV, HTMLRewriter, Analytics Engine
  • Admin consoleTypeScript, Next.js, Prisma on a MongoDB replica set
  • PlatformCafe24 Admin API through an OAuth app
  • Quality745 tests across the Worker and the console. Lint with zero warnings, type-check and tests on every commit

Three channels

Two bands. The same start for every client: diagnosis, where the client's pages are read and scored; proposals, each with the evidence it was built from; approval, where a person adopts or skips each page's proposals; and write scope, set per site, off by default, then technical, then additive. Three channels, chosen by what the client's permissions allow: A, platform app, for a shop that runs on Cafe24, where an installed app edits product descriptions and SEO fields through the Admin API; B, direct source, for a site we built, where the change goes directly into its code; and C, edge relay, when neither is possible, where a Cloudflare Worker in front of the site adds the content to the response and the origin is never touched. A note: most clients cannot edit their own site's source, so the channel is decided by what access the client can give, not by what is easiest to build.
Figure 1. Every change starts the same way and ends by one of three channels. Diagnosis produces proposals with evidence, a person approves them, and a per-site write scope decides what may be written.
ChannelWhen it appliesHow the change reaches the pageState of the build
A · Platform appThe shop runs on Cafe24An installed OAuth app writes product descriptions and SEO fields through the Admin APIInstall, token handling, throttled client, product reads and writes with a dry-run mode: built and tested. Applying from the console is not wired in yet
B · Direct sourceWe built the client’s siteThe change goes into the site’s codeManual. The console shows the prescription to paste
C · Edge relayNeither of the aboveA Cloudflare Worker in front of the site merges the content into the HTML as it streams. The origin is not modifiedEnd to end: approve, plan, apply, served

The edge relay is the channel for clients who can offer neither of the other two, and it is the one that carries the most risk. A Worker in front of a client’s shop sits on the path of every page view and every order. Most of the engineering in this project is about making that position safe.

The rules the layer is built on

  • Our failure must not become the client’s failure. Any exception in the Worker returns the origin’s own response. A broken configuration disables injection for that site instead of applying half of it.
  • Nothing ships without a person. Every change is a proposal with evidence, adopted or skipped by a named person. A site’s write scope is off until someone grants more.
  • Add, never overwrite. The Worker adds to a page’s structured data and leaves the site’s own name, price and rating alone. The origin is live and our copy is a snapshot.
  • The same bytes for everyone. There is no branch on the user agent. A crawler and a person receive identical content.
  • Read the plan before you write. Every write to the edge is shown first as a plan: what would be written, what would be deleted. Applying is a second, explicit step.

Reading order

  1. ArchitectureThe admin console, the Worker, and the one thing they share. The KV contract, sync semantics, platform limits, and the decisions behind the design.
  2. The edge relayA request through the Worker: classify, fetch once, guard, merge. Fail-open in code, and how structured data is merged and not replaced.
  3. The Cafe24 appOAuth install, tokens that rotate on every refresh, a lock that lets only one process refresh, and a client that stays under the rate limit.
  4. The approval inboxProposals with evidence, four decision states, the write scope, plan and apply, and an apply log with before and after values.
  5. An edge latency postmortemA latency criterion that failed on the first measurement, and the six ways the first client connection went wrong.
  6. ResultsEach claim with the mechanism and the test behind it.

Results in three lines

  • A change reaches a client’s page without the client editing anything: the Worker reads a payload from KV and merges it into the origin’s HTML in a stream.
  • Any exception in the Worker returns the origin’s response. Tests assert the edge cases: broken KV data, error pages, non-HTML responses, a POST with a body, and a dead origin answered with a 502 and no retry.
  • 745 tests run on every commit, with lint at zero warnings and a type-check, across the Worker and the admin console.