Repository navigation
Keep each leaf.page drafts store under the drafts shape it was written at - #7198
Merged
Merged
Conversation
…n at leaf.page's session object kept one drafts store per page, keyed by its root alone, and a restore wrote whatever store it received as the container's own `drafts@<since>.json`. `DRAFTS.since` moves without a protocol bump whenever the drafts record changes shape at a later protocol (`layer-registry.md`, "Page protocol"), and the session object is keyed by protocol and store format only, so the first release after such a change read the previous release's stores as its own shape. With `DRAFTS.since` moved from 51 to 57 and the protocol at 57, a store written at `leaf-drafts/51` came back as `[email protected]` stamped `leaf-drafts/57`, and `read_drafts` served it. The site manifest now carries the release's `DRAFTS.format` as `drafts_format`, and `leaf_drafts` is keyed by root and format. A release reads and replaces only the stores at its own format, as a local Leaf reads only its own shape's file since #7157: after a shape change a page starts with no saved drafts, and a release back at the earlier shape finds that store as it was left. No container code changes, since every page-store request and every saved response the object serves comes from or for the manifest's release. The table change moves `STORE_FORMAT` to 2, which, as a protocol bump does, starts every visitor on the published page at the deploy that lands this. Net lines: production code +6, comments +11, tests +43, prose +1. Tests: a Worker test that a store saved at one drafts format is neither restored nor turned into a refusal at another, and is restored again at its own; it fails against main's `storage.ts`. `pnpm run check` passes, as do `tests/process/website_server/test_saved_records.py` and `dev/tests/process/test_website_server.py`. Edited but not run locally: `tests/journeys/test_site.py`, which now asserts the built manifest's `drafts_format`. > _This was written by Claude Code on behalf of max-sixty_
leaf-agent
previously approved these changes
Nov 26, 2026
# Conflicts: # dev/leaf_dev/commands/site/_build.py # tests/journeys/test_site.py
leaf-agent
approved these changes
Nov 26, 2026
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.
leaf.page's session object kept one drafts store per page, keyed by the page's root alone, and a container's restore wrote whatever store it received as its own
drafts@<since>.json.DRAFTS.sincemoves without a protocol bump whenever the drafts record changes shape at a later protocol (src/leaf/layer-registry.md, "Page protocol"), and the session object is keyed only by protocol and store format, so the first release after such a change would read the previous release's stores as its own shape and could lose or misread a visitor's unsent words.Reproduced on main. A scratch probe on the process tier's page-store double wrote a draft at
leaf-drafts/51, then restored the page withDRAFTS.sinceset to 57 (the current protocol, so no bump). The store came back as[email protected]stampedleaf-drafts/57, andread_draftsserved it as the new shape. The new Worker test below fails against main'sstorage.tsfor the same reason: a release at another drafts format receives the earlier format's store in its restore snapshot.The change. The site manifest now carries the release's
DRAFTS.formatasdrafts_format, and theleaf_draftstable is keyed by root and format. A release reads and replaces only the stores at its own format, as a local Leaf reads only its own shape's file since #7157. After a shape change a page starts with no saved drafts (an open tab still saves the words it holds once the visitor acts, as after a protocol bump), and a release back at the earlier shape, such as a rollback, finds that store as it was left. Nothing reads another shape's store, and no store is migrated. The container code is unchanged: every page-store request and every saved response the session object serves comes from or for the manifest's release.The table change moves
STORE_FORMATto 2. As a protocol bump does, that starts every visitor on the published page at the deploy that lands this.Net lines: production code +6, comments +11, tests +43, prose +1.
Verified.
worker/test/storage.test.ts, "reads and replaces only the drafts stores written at its own drafts shape": a store saved at one format is neither restored nor a reason to turn a save away at another, and is restored again at its own. Fails against main'sstorage.ts.pnpm run checkpasses.tests/process/website_server/test_saved_records.pyanddev/tests/process/test_website_server.pypass.tests/journeys/test_site.py, which now asserts the built manifest'sdrafts_format.