Skip to content

Keep each leaf.page drafts store under the drafts shape it was written at - #7198

Merged
max-sixty merged 2 commits into
mainfrom
agent-a915d4e056ea8734d
Nov 26, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-a915d4e056ea8734d

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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.since moves 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 with DRAFTS.since set to 57 (the current protocol, so no bump). The store came back as [email protected] stamped leaf-drafts/57, and read_drafts served it as the new shape. The new Worker test below fails against main's storage.ts for 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.format as drafts_format, and the leaf_drafts table 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_FORMAT to 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's storage.ts.
  • pnpm run check passes.
  • tests/process/website_server/test_saved_records.py and dev/tests/process/test_website_server.py pass.
  • 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

…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
leaf-agent previously approved these changes Nov 26, 2026
# Conflicts:
#	dev/leaf_dev/commands/site/_build.py
#	tests/journeys/test_site.py
@max-sixty
max-sixty merged commit 40a758a into main Nov 26, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-a915d4e056ea8734d branch November 26, 2026 02:44
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