Skip to content

Keep a layer that reads a page's own package copy in that page's memory - #6432

Merged
max-sixty merged 2 commits into
mainfrom
agent-afd3db36f01608f5d
Nov 18, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-afd3db36f01608f5d

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Continues #6411, which moved the server's per-page stores into page memory.

A layer whose selection includes a copy the page holds of a package it selects by path is now that page's reading: its vocabulary and composition live in the page's memory beside the copy's stamp (layer._held). A page init that replaces the copy replaces the layer, which goes when the page's memory does. A selection of shared package roots alone stays held for the process.

Before, _vocabularies and _compositions were module dicts keyed by the inputs and the copies' stamps, and nothing dropped an entry. Each copy-changing page init, and each live sample of a page with copies, kept another composed layer (about 2.9 MB served) for the process's life: five inits held five, now one.

layer._Layers holds a selection's vocabulary and composition together, for the process and per page memory. once still composes a layer once for requests arriving together. forget_layers (#6412) replaces the shared store, and a page's layer, kept beside it, is composed again.

The new test fails against the old store, a process-wide store, one ignoring the copy's stamp, and one ignoring forget_layers.

This was written by Claude Code on behalf of max-sixty

A layer whose selection includes a copy the page holds of a package it
selects by path is now a reading of that page: its vocabulary and full
composition live in the page's memory (`page_memory.memo`), beside the
copy's stamp. A `page init` that replaces the copy replaces the layer
instead of adding one beside it, and the layer goes when the page's
memory does. A selection of shared package roots alone stays held for the
process, one per selection, as before.

Before, both readings sat in module dicts keyed by the selection's inputs
and the copies' stamps, and nothing dropped an entry. Each `page init`
that changed a copy, and each live sample of a page with copies (a new
temporary page directory every time), added a composed layer for the
life of the process: five inits of one page held five layers, each about
2.9 MB of served files for the default layer alone. Now it holds one.

- `layer._Layers` keeps a selection's vocabulary and composition
  together by its inputs, replaced whole once a copy's stamp moves. One
  instance serves the process (`_shared`); a page's memory holds another.
  `page_memory.once` still makes each reading once for requests arriving
  together.
- `page_memory`'s header and `layer-registry.md` no longer say every
  layer is held for the process.

The new test edits a page copy three times and asserts one composed layer
stays alive, and none after the page's memory is dropped; it fails against
the old store, against a process-wide store, and against a store that
ignores the copy's stamp.

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit 4c9615e into main Nov 18, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-afd3db36f01608f5d branch November 18, 2026 22:58
max-sixty added a commit that referenced this pull request Nov 18, 2026
…ages share (#6440)

Continues #6432. A layer vocabulary of shared package roots is one
object for every page that selects those packages, held for the process,
and its `readings` dict gained entries for each page that read it: the
vocabulary with the page's `$layer`, and each revision's composed
vocabulary, a deep copy of the layer's registry. Both name the page's
generation, so no other page read them, and nothing dropped them. After
24 pages past the eight a process keeps, it held 7.4 MiB, growing 238
KiB per page; it now holds 3.9 MiB at 24 or 64.

A revision's vocabulary now lives in its page's memory
(`registry.storage._Revisions`), beside the layer vocabulary it was
composed over, and is composed again once that is replaced. A page's
revisions that declare the same still share one. The `$layer` vocabulary
is a shallow copy made per call. `_Revisions` and `layer._Layers` share
one keyed store, `page_memory.Stamped`.

A sample composes its own revision vocabulary instead of sharing its
parent's, holding 2.8 MiB rather than 2.6 MiB.

The new test fails against the old store, a page store keyed by the
vocabulary, and one blind to it.

> _This was written by Claude Code on behalf of max-sixty_
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