Repository navigation
Stop the Worker, container and site build re-validating each other's output - #2500
Merged
Merged
Conversation
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]>
leaf-agent
approved these changes
Oct 12, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andleaf-dev verify-site website-workerdrives 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
parseSiteManifestinworker/src/routing.tsbecome TypeScript interfaces.site.pyconstructs every field the schema checked (the asset path from the release, the state from the current revision, the image from a media filecheck_linksproves resolves, title and description refused at build).WorkerFailure = "rate_limited" | "startup_failed", so "only the container writesturn_failed" is a type on the one producer;askContainerreduces to ok →json(). The container readsposted["event"]andposted["failure"]directly; an unknown code still fails atFAILURE_RECEIPTS[failure]and an unknown event at admission. No public path reaches these routes: the Worker 404s every/_leaf/path,pageRouteforwards only API, layer, session and vendored-file paths, and the container matches routes exactly.OPENAI_API_KEYruntime check:wrangler.tomlrequires the secret, so deploy refuses without it._finish_turn's stderr line repeatingturn_stream_completed, and_select_page'sevents.jsonlcheck.example_data.pyandsite.pystop explaining dead example routes and missing captions, whichcheck_linksrefuses or aNoneaccess reports;example_previews.py's fallback ismin(glob).Behavior change: a build or container bug in these fields now fails as a routing or Python error in
verify-siteinstead of a named validation error. The container's private/_leaf/agent/failroute would acceptturn_failedif something posted it; only the Worker's type and the route's unreachability rule that out.