Skip to content

Stop the Worker, container and site build re-validating each other's output - #2500

Merged
max-sixty merged 1 commit into
mainfrom
cut-worker-rechecks
Oct 12, 2026
Merged

max-sixty merged 1 commit into
mainfrom
cut-worker-rechecks

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The Worker, its container (worker/leaf_website) and the site build (dev/leaf_dev/site.py) are Leaf's own code, ship in one release, and leaf-dev verify-site website-worker drives them together on every PR and before each deploy. Several checks on that path validated values one of them produced for another, as if it came from the internet. They go; validation of what does come from the internet (startup reports, interaction batches, request cookies, sample ids, page-fault bodies) stays. Part of the complication-weight sweep (#26 there, and the dev half of #21).

Removed

  • Site manifest: the Zod schemas and parseSiteManifest in worker/src/routing.ts become TypeScript interfaces. site.py constructs every field the schema checked (the asset path from the release, the state from the current revision, the image from a media file check_links proves resolves, title and description refused at build).
  • Agent start/fail protocol: no longer validated at both ends. The Worker's failure code is typed WorkerFailure = "rate_limited" | "startup_failed", so "only the container writes turn_failed" is a type on the one producer; askContainer reduces to ok → json(). The container reads posted["event"] and posted["failure"] directly; an unknown code still fails at FAILURE_RECEIPTS[failure] and an unknown event at admission. No public path reaches these routes: the Worker 404s every /_leaf/ path, pageRoute forwards only API, layer, session and vendored-file paths, and the container matches routes exactly.
  • OPENAI_API_KEY runtime check: wrangler.toml requires the secret, so deploy refuses without it.
  • The shape check on the sample URL the container returns, three routing guards on values already checked or freshly generated, _finish_turn's stderr line repeating turn_stream_completed, and _select_page's events.jsonl check.
  • Dev catalog readers: example_data.py and site.py stop explaining dead example routes and missing captions, which check_links refuses or a None access reports; example_previews.py's fallback is min(glob).

Behavior change: a build or container bug in these fields now fails as a routing or Python error in verify-site instead of a named validation error. The container's private /_leaf/agent/fail route would accept turn_failed if something posted it; only the Worker's type and the route's unreachability rule that out.

This was written by Claude Code on behalf of max-sixty

Both sides of the website ship in one release, and `leaf-dev verify-site
website-worker` drives them together on every pull request and before deploy,
so a check on a value Leaf's own build or container produced restates what its
producer already guarantees. Public-edge validation (startup reports,
interaction batches, request cookies, sample ids, page-fault bodies) stays.

- The site manifest is a TS interface read with a typed parse, not a Zod schema:
  `leaf-dev site` builds every field by construction.
- The private agent start/fail protocol is checked at neither end. The Worker
  404s every `/_leaf/` path from outside, so only it reaches these routes, and
  the failure code it may send is now the type `WorkerFailure`, which leaves
  out `turn_failed`. The container reads the body directly, and
  `FAILURE_RECEIPTS[failure]` still refuses an unknown code. Behavior change: the
  container no longer answers a malformed Worker request with a 400. The test
  pinning those refusals is gone.
- The model proxy no longer checks for a missing OPENAI_API_KEY at runtime:
  wrangler.toml requires the secret, so deploy refuses without it. Its test
  is gone.
- The sample URL the container returns, the session id the Worker mints, and the
  page roots from the manifest are no longer shape-checked.
- `_finish_turn` no longer prints how a turn ended to stderr, which
  `turn_stream_completed` already records; `_select_page` no longer checks for
  an event log every published page is built with.
- The catalog reader drops its route, missing, repeated and empty checks, and
  `catalog_markup` its caption check: a bad route is a dead link `check_links`
  refuses, and a missing file or caption fails where it is read.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit d83203f into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the cut-worker-rechecks branch October 12, 2026 06:09
max-sixty added a commit that referenced this pull request Oct 12, 2026
…is not input (#2556)

Most of what the complication-weight sweep cut (#2500, #2507, #2555) was
a reader re-checking a value another Leaf module produced, as if it came
from outside: the browser re-validating the server's answers, the Worker
the manifest its own build wrote, Python the rules admission already
enforced. AGENTS.md's "Validate once and share readings" names the
boundaries but not which seams aren't one. This adds that to "Let the
agent correct its own input" in `/developing-leaf`, with the one
exception (records an older Leaf left in the state home) and the
matching rule for recovery from states no Leaf writer produces.

**Scored before landing** (scratch A/B, the section with and without the
paragraph, `claude -p` with no tools): both arms passed every case, so
the paragraph shows no measurable change on cold prompts — a browser
reader of a server answer (7/7 each arm, with and without the user's
global instructions loaded), the same reader written beside a neighbour
that over-validates (8/8 each), an unproducible-state recovery (3/3
each, "leave"), and a control where a package-supplied anchor identity
should keep its check (3/3 each, "refuse"). The control shows the rule
doesn't over-apply. It lands as the statement reviewers and later sweeps
can cite; the defensive code it describes accumulated in incident fixes
the cold cases don't reproduce.

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants