Repository navigation
Serve an active reader's live page document from their own container - #682
Conversation
The edge answers the stable page address out of the built site, which is a revision behind any the reader's own session has published. Since a live revision now activates by reloading that address, the reloaded document reports the older revision, the runtime asks for the newer one again, and the reader reloads forever. An active session takes its live document from the container that owns its index.html.
leaf-agent
left a comment
There was a problem hiding this comment.
worker/README.md is the document that states this routing rule, and the change leaves two of its sentences false. It opens with "Cloudflare serves each product and example page's live shell and initial canonical projection from .tmp/site-assets, so the document paints and presents without waiting for a container" — after this change an active reader's live shell comes from their container, and that reader does wait for one. It then enumerates the fallthrough as "Published media, revisions, and version documents stay on the edge; when one of those paths is absent from the release, the Worker asks the reader's active container so a newly created private revision can become the live document" — that absent-from-the-release condition is no longer how a private revision becomes live, which is the whole mechanism this PR repairs. A reader deriving the delivery model from that paragraph would conclude an active reader's document is still edge-served and still release-addressed, which is exactly the wrong picture to make the next edit to index.ts against. I'm pushing the prose update to this branch.
Two things I checked that hold, since the routing now splits document and module graph across the two origins. The container composes the live document against /<page>/revisions/rN-<hash>/, and artifact_name digests the document together with every resource, so a release that moves the runtime yields a different rN-<hash>: the edge 404s that path, isPageSessionFileRequest falls it through, and the same container that served the document serves its modules. Document and module graph cannot land on different releases. The container's HTML also keeps frame-ancestors 'none' (Handler.frame_ancestors_policy, which WebsitePageHandler does not override), so dropping staticAssetResponse from this path costs no clickjacking header.
npm run typecheck --prefix worker and npm test --prefix worker pass at 63, and reverting only the new clause in the edge condition reds the two added cases — they pin the behaviour rather than the shape.
|
This break recurred on main: run 34780462213 on The Both failures isolate cleanly to the agent turn. The rollout pass ahead of it settled and passed in this run ( Nothing to add to the diff from here — merging it is what clears main, so I have opened no separate fix. |
leaf-agent
left a comment
There was a problem hiding this comment.
The routing change and the README rewrite agree with the code, but the details block's
conclusion about /examples/ship-review/ does not survive this change.
That note says the startup failure reproduces "only when the container serves the module
graph as well as the document", and concludes "This change neither causes nor addresses
it — with the container serving only the document, ship-review presents cleanly." The
container serves only the document while the reader's active revision is still the build's
revision, because rN-<hash> is present in the release and the edge answers it. The moment
the agent publishes, the document changes, so artifact_name yields a hash the build does
not carry, the edge 404s that path, and isPageSessionFileRequest falls the whole revision
directory through to the container — which the README's own new sentence states. So after a
publish the container serves the document and its module graph, which is the configuration
the note names as broken, and it is reached on this fix's success path rather than only from
a drained rollout.
The verification in this PR drove /examples/triage-board/, which the note says is
unaffected, so the case that matters here is untested. Drive a publish through
/examples/ship-review/ under this routing before landing. If it presents, the note's
reproduction condition is narrower than stated and the sentence should say so; if it does
not, this change makes an existing live defect reachable for any reader of that page whose
agent publishes, and that belongs in the PR's cost section rather than in a collapsed
"unrelated" block.
|
Third consecutive red merge run, and this one caught the reload directly: run 34781705451 on That is the same failure, one reload later. The rollout pass ahead of the agent turn settled and passed again ( |
|
Every
The last green Run 34784221223 reads exactly as the first one did: the non-agent pass confirmed release This branch still merges cleanly into Nothing further is needed from CI to characterise this. Each red merge run opens a |
publish-sitedeployed release5903b07fand then failed its agent pass on run 34777568838, and the gate was reporting a live break rather than a flaky reading: on leaf.page today, a reader whose agent publishes a revision is thrown into an endless reload. The page never reaches the revision, never presents, and never shows the conversation again —reply never became visible in Threads: {'panel': True, 'messages': []}is that page, caught mid-reload with nothing rendered.What causes it
#666 made every live revision activate by reloading the stable page address (
prepareActivationinskills/leaf/assets/runtime/version.js), replacing the fetch of the revision document that preceded it. The Worker answers that address from the built site:worker/src/index.tstakes the edge branch for any page GET that is not an API request, and only falls through to the container when the edge answers 404, which the page root never does. So the reloaded document is the build's revision, the runtime reads it back as the revision it was leaving, asks to activate again, and the loop closes. The session's ownindex.html— the one its agent just wrote — is in the container the whole time.Session files already avoid this:
media,revisionsandversionsmiss at the edge and fall through. The live document is the one case the edge answers with a stale 200, so this adds it to the same rule — an active session reads its live document from its container. Passive readers, every static asset, and the release-addressed module graph are untouched.Verification
Measured against the deployed release on leaf.page, driving the page the way the gate does:
/examples/triage-board/continuously for the whole six-minute observation, still on revision 1, still readingRelease triage, never presented, no messages;Deployment probe verified, presented, conversation rendered, no browser errors.npm run typecheck --prefix workerandnpm test --prefix workerpass (63 tests, including two new cases that fail without the change).The cost, and what it does not cover
The container composes its document with page-relative asset paths, so an active reader's document loads the revision's modules from
/<page>/revisions/rN-<hash>/…. The edge still serves those files, but underpublic, max-age=0, must-revalidaterather than theimmutableyear that/_leaf-release/<release>/…carries, so an active reader's reload revalidates its module graph instead of reading it from cache. That route is content-addressed by the revision's own digest, so marking build-present revision assets immutable would recover it; that is a separate change and this one does not make it.The local pre-deploy gate could not have caught this:
scripts/verify-site-local.shrunsverify_site.pywithout--agent, so the Worker is exercised before the deploy but the agent turn only afterwards, against the public origin.An unrelated live defect found while reproducing this
A session pinned to its container by the
__Host-leaf-containercookie — the state a drained rollout leaves — cannot start/examples/ship-review/at all: the page throwsleaf: page failed to start: leaf: $command.widgets declares no command role, thenLeaf application has not been mounted, and never presents. It reproduces on every attempt, and only when the container serves the module graph as well as the document;/examples/triage-board/is unaffected, and the registry the two routes return is byte-identical and does carry$command. This change neither causes nor addresses it — with the container serving only the document, ship-review presents cleanly.