Skip to content

Serve product site as live Leaf pages - #380

Merged
max-sixty merged 3 commits into
mainfrom
codex/live-product-pages
Sep 7, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/live-product-pages

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 7, 2026 •

Copy link
Copy Markdown
Owner

The product site currently publishes Leaf-authored markup as script-free HTML, so the homepage looks like Leaf but lacks its runtime, threads, versions, and state. This change makes the five product routes live Leaf pages without restoring the removed browser-side session emulator.

The site build now produces a complete page directory for each product route. The Worker routes product pages and examples through the canonical Python server in a private per-reader container, while shared social media assets remain static. Website state, session naming, and the Durable Object binding are generalized from examples to publications; a Wrangler migration preserves the existing Durable Object class.

The route tests cover product assets, example assets, private paths, canonical slashes, event delivery, and the /examples/ catalog namespace alongside /examples/<slug>/. Deployment verification checks both a product page and an example after publishing.

The server now exercises homepage and catalog agent turns end to end. The generated .assetsignore limits the Worker asset manifest to the shared media and site note it can serve; complete page directories remain in the container image. Worker tests also cover CSP preservation when the response receives a new session cookie.

Tested with the 907-test Python suite, 19 Worker tests, TypeScript checking, the full pre-commit gate, a 35-page site build, a Wrangler deployment dry-run, and browser interaction checks on desktop and mobile.

This was written by Codex on behalf of max-sixty

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two of the six route families can't reach their agent, so the change's headline claim doesn't hold on the homepage.

agentRequest in worker/src/index.ts builds http://container${root}/_leaf/agent/${action}, with root empty when route === "/". That produces /_leaf/agent/turn for / and /examples/_leaf/agent/turn for /examples. published_page in worker/server.py resolves neither: / and /examples are exactly the two routes the PRODUCT_ROUTES loop skips, PAGE_RESOURCE has no _leaf alternative, and EXAMPLE_ROUTE's [a-z0-9-]+ slug cannot match _leaf. Both fall through to return None, so _select_page returns false and the container answers _not_found().

Running the two route tables against each other:

/_leaf/agent/turn                            -> None
/examples/_leaf/agent/turn                   -> None
/how-it-works/_leaf/agent/turn               -> ('how-it-works', '/how-it-works', '/_leaf/agent/turn', 'product')
/examples/design-decision/_leaf/agent/reply  -> ('design-decision', '/examples/design-decision', '/_leaf/agent/reply', 'example')

What a reader gets: a comment on / or /examples/ is accepted, acceptedObligation starts the workflow, and askContainer(..., "turn") takes a 404. Because the status is under 500 that is a NonRetryableError, which runAgentWorkflow's catch converts into GENERATION_FAILURE_REPLY; the append generation failure step then 404s the same way and throws out of step.do. The workflow fails, the obligation never settles, and the banner goes on promising that state.publication.agent "replies here" on the very page docs/index.html now invites people to use ("or use the controls on this page").

The two inline suggestions close it. I checked that they leave every other route resolving as before and open no external hole: the Worker still 404s /_leaf/* ahead of routing, and pageRoute("/examples/_leaf/agent/turn") still returns null, so neither path is reachable from outside the container.

Supporting observations:

  • Nothing exercises a product-route agent turn end to end. worker/test/index.test.ts parametrizes the workflow start over / and /examples/design-decision, but the container-side resolution of _leaf/agent/* is only covered for examples, in tests/test_website_server.py. A POST to /_leaf/agent/turn inside test_a_product_route_uses_the_same_real_page_server would have caught this.
  • The product route table and the page-resource allowlist now live in four places with nothing pinning them together: PRODUCT_ROUTES in scripts/site.py, PRODUCT_ROUTES and PAGE_RESOURCE in worker/server.py, PRODUCT_ROOTS and PAGE_RESOURCE in worker/src/routing.ts, and the inline route array in validatedAgentParams. The bug above is drift between two of them, and the suite currently notices drift in only one direction.
  • Each of the five product page directories is a full copytree of the prepared page — the diagram (1.6M), diff (1.8M), and default (512K) vendor bundles plus every product image, five times over. The resulting .tmp/site goes both into the container image and into the Workers asset upload, but after this change ASSETS only ever answers /media/* and /sitenote.js: isPrivatePageRequest 404s /_leaf/* and pageRoute sends everything else to the container. The asset binding is now carrying roughly 25 MB it can never serve.
  • worker/test/index.test.ts's "serves the product route %s through Leaf" asserts the Content-Security-Policy that its own container mock returned, and with a cookie present the Worker returns that same Response untouched, so the assertion cannot fail. The old test verified that staticAssetResponse added the header. The header itself is still correct — Handler sends frame_ancestors_policy on HTML — but nothing pins it at the Worker boundary any more.

Comment thread worker/server.py Resolved
Comment thread worker/server.py Resolved
@max-sixty
max-sixty merged commit 14c746b into main Sep 7, 2026
19 checks passed
@max-sixty
max-sixty deleted the codex/live-product-pages branch September 7, 2026 07:10
max-sixty added a commit that referenced this pull request Sep 7, 2026
One conflict, in the banner's status writer. Main's #380 renamed
`state.example` to `state.publication` and gave it a `kind`, so a published
page says either "This is an example on the Leaf website." or "This website is
a Leaf page."; this branch had moved that sentence out of the reading and into
`exampleWords`, so the measured status floor could ask the same writer for it.

Both, so: the words follow main's two subjects and its `lf-publication-install`
class, and they stay a writer of their own, now `publicationWords`, which the
floor's enumeration goes on reading. The harness renamed its `website_example`
argument to `website_publication` in the same commit, so this branch's floor
test follows it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 26, 2026
The directories a page answers beneath its root were listed four times:
`schema.py`'s served paths, `http.py`'s rooted-reference rebasing, the
website adapter's route regex in `worker/server.py`, and the Worker's
copy
in `worker/src/routing.ts`, which a Python test held to the vendored
files
by parsing the TypeScript. Both Worker-side lists still routed
`guidance/`,
which no server has served since #380.

- `schema.PAGE_ROUTE_DIRS` names the namespace's directories. The
website
  adapter builds its route regex from it and `VENDORED_FILES`.
- `scripts/site.py` writes both into the site manifest as
  `routes: {dirs, files}`, and the Worker's `pageRoute` and
`releaseAssetRoute` route from the manifest, which it already loads and
  validates, instead of a hand-written regex.
- `http.py`'s rooted-reference set is built from the same layer
constants.
  It differs from the route set on purpose, and its comment says how: it
leaves out the documents, whose addresses the server writes itself, and
  takes in the authored `page/` tree, served only beneath a revision.
- `schema.REVISION_NAME` and `VERSION_NAME` are the revision and version
file-name patterns that `files.py`, `http.py`'s two revision routes and
  `SERVED_PATH` each spelled out.

Behaviour that moved:
- `<page>/guidance/...` is no longer routed to a page by the Worker or
the
  adapter; it falls through to static assets, where nothing lives.
- The site manifest gains a required `routes` field; the Worker refuses
a
  manifest without one.
- `test_the_worker_routes_every_file_a_page_vendors` is deleted: the
Worker
  no longer holds a copy of the list for it to check. `routing.test.ts`
  now asserts a `guidance/` path is not routed.


The worker TypeScript gate (`npm run typecheck` and `npm test` in
`worker/`) passes locally; `scripts/verify-site-local.sh` was not run.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> _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