Skip to content

Move to Node 26.13.1 and pnpm 12.21.0 - #1621

Merged
haowjy merged 4 commits into
mainfrom
chore/node26-pnpm12
Nov 16, 2026
Merged

haowjy merged 4 commits into
mainfrom
chore/node26-pnpm12

Conversation

@haowjy

@haowjy haowjy commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Changelog

  • Changed: Flow develops, tests and runs on Node 26.13.1 (was 24.17.0) and pnpm 12.21.0 (was 10.34.3). Run mise install and use pnpm 12 (the repo pins it in packageManager).

Why

Node 26 is the current LTS ("Lithium", supported to April 2029) and pnpm 12 is the current pnpm. Staying on Node 24 and pnpm 10 means older security fixes and a package manager that no longer gets releases. After this merges, .tool-versions, CI and packageManager all name the same versions.

Examples

No visual change. The upgrade changes the runtime and package manager under the app; the writer flow it runs through is a chat turn.

A chat turn on Node 26

  1. Setup: this branch, LIVE_TEST_MODEL= MODEL_PROVIDER=mock pnpm dev (the empty LIVE_TEST_MODEL stops the main checkout's .env from selecting a live model).
  2. Steps: ./mf thread create, then ./mf thread send <id> "hello from node 26".
  3. Expect: the mock turn streams a reply and ends complete; logs/portless.log has no ExperimentalWarning (checked on a fresh stack with NODE_OPTIONS=--trace-warnings, after hitting the app and server pages). This is debugging output, not a browser run (see Not exercised).

Benchmarks

None. Nothing on a writer-facing path was changed by this PR; Node 26 and pnpm 12 were not timed. The final pnpm check run took 65 s of tests against the 150 s reference; I did not time the same run on Node 24.

Design decisions

  1. Node's localStorage global is turned off in app tests. Node 25+ defines globalThis.localStorage; without --localstorage-file it is undefined and it shadows jsdom's, so 12 app test files failed. apps/app/vitest.config.ts passes --no-experimental-webstorage to the test workers. Ruled out: assigning jsdom's storage in vitest.setup.ts (a second repair per test environment) and --localstorage-file (writes a file on every run).
  2. The localStorage warning is fixed at its sources, not by a flag. Two things probed localStorage on Node 26. lib0 (a Yjs dependency) did it at import; lib0 0.2.120 guards the probe (commit) and this PR raises the range to ^0.2.120. Flow's own LocalDocumentCopies default (typeof localStorage) and schema-fence ran during the app's server-side render, so the first page load printed the warning (stack from --trace-warnings: LocalDocumentCopies ← DocumentSessionRegistry ← AccountFeatureLifetime). Both now go through browserStorage("local"), which returns null outside a window. Ruled out: --no-experimental-webstorage in every start script and NODE_OPTIONS, which would leave the next library that probes it still printing.
  3. pnpm 11+ settings are written down, not left to defaults. allowBuilds now lists esbuild, lefthook and protobufjs as false (they were skipped silently before and pnpm 11+ fails the install on an unlisted build script; nx stays true). verifyDepsBeforeRun: false moves from .npmrc (pnpm 11+ reads only auth and registry settings there) to pnpm-workspace.yaml, and .npmrc is deleted. minimumReleaseAgeExclude: ['@meridian-flow/*'] lets us take our own packages the day they are published (pnpm now holds back anything under a day old). Git hooks don't depend on lefthook: false: lefthook's build script is only a fallback download, the binary comes from its platform package, so the root prepare script (lefthook install) still writes pre-commit and pre-push on every install (checked on a fresh clone of this branch).
  4. process.disconnect is optional-called. @types/node 26 types it as possibly undefined, matching the existing process.send?.() beside it in tools/dev/cleanup-test-databases.ts.

Changes

# Part Why it's here Key paths Source Tests Docs
1 Node and pnpm pins The upgrade .tool-versions, package.json, .github/workflows/*.yml +9 / -9 +0 / -0 +2 / -2
2 pnpm 11+ settings Strict builds, .npmrc no longer read, release-age gate pnpm-workspace.yaml, .npmrc +9 / -2 +0 / -0 +0 / -0
3 @types/node ^26 and the type fix New typings pnpm-workspace.yaml, tools/dev/cleanup-test-databases.ts +2 / -2 +0 / -0 +0 / -0
4 Web Storage in tests Node 25+ global shadows jsdom apps/app/vitest.config.ts +0 / -0 +3 / -0 +0 / -0
5 lib0 0.2.120 Stops the server warning 6 package.json files +6 / -6 +0 / -0 +0 / -0
Total (15 files, excluding the lockfile) +26 / -19 +3 / -0 +2 / -2

The lockfile (+406 / -513) is regenerated by pnpm 12: a leading document pinning pnpm, patchedDependencies written as name@version: hash, peer suffixes on some entries, @types/node 26.6.6 and lib0 0.2.120. The patch hashes are unchanged and all eight patches apply on a clean install.

Upgrades

Each range was read from the project's changelog or release notes; I did not run every item.

Node 24.17.0 → 26.13.1 (v24 changelog 24.18–24.22.3, v25, v26 26.0.0–26.13.1)

  • Touches Flow: Web Storage is on by default from 25.0 and localStorage is undefined without --localstorage-file from 26.0 (#61333). It broke 12 app test files and made lib0 print a warning (decisions 1 and 2).
  • Removed APIs (SlowBuffer, _stream_*, http.Server#writeHeader, fs.F_OK, assert.CallTracker, --experimental-transform-types, among others): nothing in Flow's source uses them; I did not scan node_modules, and the full test suite and prod boot pass.
  • Behaviour changes with no break seen: readable streams read one buffer at a time (#60441); HTTP upgrades with bodies are handled differently (#60016), which is the WebSocket path (the DB suite and a mock chat turn over the thread socket ran clean); undici 8 behind fetch/WebSocket; V8 14.6 turns Temporal on; native-module ABI is 147.
  • require(esm) loading changed in 26.11 and was reverted in 26.12 (#66786): no net change. Corepack is no longer shipped from Node 25 (#57617); mise installs Node and pnpm comes from packageManager and pnpm/action-setup.
  • 24.18–24.22: additive minors and security fixes; nothing that touches Flow.

pnpm 10.34.3 → 12.21.0 (v11.0.0 through v11.28.12, v12.0.0 through v12.21.0; there is no 10.35)

  • Touches Flow: strict dependency builds by default, the one-day release age gate, settings no longer read from .npmrc (decision 3). Unknown keys in pnpm-workspace.yaml now fail (v12.0.0); every key in ours is valid.
  • Lockfile stays lockfileVersion: '9.0'. pnpm 10 may not read the new leading pnpm-pin document; I did not test that.
  • Patches: a missing patch is now an error and ignorePatchFailures is gone; ours all apply.
  • CLI: --frozen-lockfile false is rejected (we use none); pnpm link <name> is removed (unused). --filter, exec and dlx are unchanged for our use.
  • pnpm 12 prints "Agent skills awaiting approval: @tanstack/react-start" after install; this PR does not approve it.

@types/node ^24 → ^26 (24.13.2 → 26.6.6) (DefinitelyTyped tracks the Node API; no changelog of its own)

  • Touches Flow: process.disconnect is possibly undefined (decision 4). localStorage is declared as a global, so typeof localStorage guards still type-check. Typings for removed APIs are gone; Flow uses none.

lib0 0.2.117 → 0.2.120 (compare)

  • Touches Flow: the localStorage guard (101cb479). Decoding now checks reads against the Uint8Array bounds (49383f27, 425f28dc): a malformed Yjs update throws instead of reading past the buffer. Nothing else.

pnpm/action-setup is already on v6 on main (#1617); v6.1.0 added pnpm 12 support (release). Nothing else in this PR moves an action.

Compatibility and risk

  • Breaking or changed for writers: None. Developers need Node 26.13.1 (mise install) and pnpm 12.21.0; pnpm 10 cannot be used on the repo.
  • Migrations and state: None.
  • Clients during a deploy: None; the browser bundle is unchanged. The deployed server runs on Node 26 wherever its runtime reads the version (CI's prod-boot job covers the build and boot).
  • Rollback: revert the PR; the lockfile returns to pnpm 10's format.
  • Where to look: pnpm-workspace.yaml (new pnpm 11+ settings), apps/app/vitest.config.ts, and the prod deploy's Node version, which this repo does not pin outside CI and .tool-versions.

Verification

  • Browser: two agent-browser runs on Node 26.13.1, each in a fresh worktree with its own database. Run 1 was at c27e056d5f; run 2 was at f61e508737, the last code change.

    • Text, a table and an image survive a reload, and two sessions see each other's edits.
    • A mock chat turn streams; Stop ends it cleanly; a tool turn creates a document. A live deepseek-flash turn completes.
    • Typing offline shows "Saved locally (offline)". Back online, the text is there and a second session sees it.
    • The server log has no ExperimentalWarning.
    • A peer's image briefly shows "This image never finished uploading" before it renders. main (ad051799c6) does the same, so this PR didn't cause it.

    Text after reload
    Table and image after reload
    Two sessions
    Mock turn streaming
    Mock turn stopped
    Tool turn created a document
    Live deepseek-flash turn
    Typed offline
    Back online
    Second session sees it

  • Model: mock provider; the harness is unchanged.

  • Tests: none added, changed or deleted. pnpm check before the fix failed 49 app tests and one server test, all from the localStorage change above; after it, the final full pnpm check on the rebased branch passes (300 files, 2011 tests; it also ran the DB probes: 93 files, 605 tests), and pnpm test:db passes separately (93 files, 605 tests). pnpm smoke:prod-boot passes (/ 307, /login 200).

  • Not exercised: reloading while offline (Chrome shows its own offline page, because Flow has no offline app shell, on main too); a staging or production deploy on Node 26; pnpm 10 reading the new lockfile; Windows or macOS installs.

  • Gates: pnpm install --frozen-lockfile, pnpm check (Biome via BIOME_BINARY), pnpm test:db, pnpm smoke:prod-boot, pnpm dev + ./mf thread send.

Deferred

None.

References

  • Work item: Direct maintenance.
  • Related: #1617 moved the GitHub Actions to current majors.
  • Docs updated: DEVELOPMENT.md (Node version).
  • After merge: run mise install and install pnpm 12.21.0, then pnpm install; running stacks need pnpm dev:restart.
Spawn Agent Model Role
p17892 coder Sonnet 5.5 Made the change and ran the gates
(subagent) subagent sonnet Read the Node, pnpm and @types/node changelogs

Node and pnpm pins in .tool-versions, CI and docs; @types/node ^26.
pnpm 11+ settings: allowBuilds lists every build script,
verifyDepsBeforeRun moves from .npmrc (no longer read) to the workspace
file, and first-party @meridian-flow packages skip the release age gate.
Node 25+ defines a global localStorage that shadows jsdom's, so app tests
run with --no-experimental-webstorage; lib0 0.2.120 stops the server
logging that warning at import. @types/node 26 makes process.disconnect
optional.
@haowjy
haowjy force-pushed the chore/node26-pnpm12 branch from 943a0b5 to 5f7aa49 Compare November 15, 2026 23:58
@haowjy
haowjy merged commit 99d3389 into main Nov 16, 2026
11 checks passed
@haowjy
haowjy deleted the chore/node26-pnpm12 branch November 16, 2026 00:04
haowjy added a commit that referenced this pull request Nov 16, 2026
…d; protocol 4 (#1638)

* Run on @meridian-flow/gateway from npm; delete packages/gateway (#1604)

* Run on @meridian-flow/gateway from npm; delete packages/gateway

The gateway moved to haowjy/meridian-runtime. apps/server and packages/contracts take it
from the pnpm catalog (one version). The model-request debug capture now copies named
fields, so GenerateRequest.auth (a credential) never reaches a record. The architecture
map shows the gateway as an external package and drops its import rule; the baselines
lose its entries. What only Flow knew in the gateway's CONTEXT and its mock-provider
recipe moved to apps/server/server/lib/gateway/.context. The root AGENTS.md says how to
try a gateway change here before it is published.

pnpm-lock.yaml has no resolution for the gateway until 0.1.0 is on npm: run pnpm install
after the publish.

* docs: keep package behaviour in the package's CONTEXT, Flow wiring doc holds Flow's choices

* docs: restore Flow's registry validation and promptCache merge rules to the gateway wiring doc

* Resolve @meridian-flow/gateway 0.1.0 from npm

* docs: capture gateway npm browser verification

* Say when the protocol minimum moves

* Tree rooms wait out their store work when the gateway drains (#1608)

* Unsent edits in a room that comes back read-only: rebuild and hand back (#1580)

* A read-admitted room finds what the server lacks from each handshake

A read-admitted connection no longer sends Update frames, and its handshake
says what the document holds that the server lacks (the SyncStep1 and
SyncStep2 pair), so acknowledgement there is the session's verdict instead
of a SyncStatus the server always answers false. The session tells the
writer's edits from the editor binding's own repairs by the sync plugin's
mark, keeps a ledger of typing, and carries display writes to peer tabs and
the copy so a repair made by one tab is never counted by another.

Nothing replaces a room yet: the session only exposes holdsUndeliverableEdits.
The undo manager skips a binding write that has no mark.

* A room's local copy has incarnations

A session that must stop offering what its copy holds opens the next
incarnation of the copy instead of emptying it under the tabs that have it
open. The incarnation is a trailing number on the database name, and its
pointer is in localStorage; two tabs advancing at once both end on the same
next number. An older incarnation no tab holds is read against the first
handshake of the session that opens the current one, its words are handed
back, and it is deleted. text() reads the current incarnation only, and a
copy's lock is per database.

* A room admitted read-only is replaced by one loaded from the server

When a read admission's handshake shows the document holds edits the server
lacks, the registry hands the typing back in a toast, makes the session
inert and opens a new one on the next incarnation of the copy. The new
session starts read-only with the server's text; its holders (live bindings,
open tabs, draft room readers) bind it, and the old session is destroyed when
its editors have unmounted, under its own persistence name so the room stays
available.

* A review mount keeps its place across a replaced session

A room that came back read-only is rebuilt from the server and its editor
remounts. A live mount already restored its place from the reading-position
store; a review mount kept none, so it now carries its place across the
replacement only (not between visits).

* Docs and catalogs for the read-only handback

* PR screenshots for the read-only handback (linked at this commit)

* A replaced session never reconnects; a handed-back copy is deleted; Discard counts as the writer's

The replaced session ignores attachTransport for good, so no retain, restart
or pending attachment can reconnect it and upload the words just handed back.
Older-copy cleanup offers recovered words only (no wordless toast for a copy
the server already has). A Discard's origin is a local write, so a Discard
made offline is the writer's own wordless change and gets its toast. The old
incarnation is deleted when its session is destroyed (CopyHold.drop), so its
words are not offered again after a reload.

* A copy is deleted only after its whole content is read against the server: replaced sessions retire by the older-copy path

* A copy records what was handed back from it, so no later read offers it again

When a replaced session handed back its typing, the record of what it had
returned lived only in the callback that retired it. If another tab still held
the old copy, that read was skipped, and the next read (a reload, the other tab
closing) offered the returned words again with the other tab's new ones.

The session now writes the state its deciding handshake covered (the server's
state plus every struct the server lacked) into its copy's custom store when it
hands back. Every older-copy read takes those records with the copy and offers
only what lies beyond them and the server. Words written after that handshake
are not covered and come back once.

The copy can't instead hold nothing already handed back: it is shared with tabs
still writing into it, and Yjs can't remove an operation.

Also: a session's copy is named from the one pointer read that records its
incarnation; reading the pointer twice could open one incarnation and record
another.

* A hand-back is recorded in its copy when the writer is done with the toast

The record that keeps a later read from offering handed-back words again was
written when the toast showed. That ended a settled rule: words found in an
older copy after a reload are offered again, so a toast the writer never acted
on is not the only place their words are.

The record is now written when the writer copies the words or dismisses the
toast (`UnsentTyping.done`), into the copy the hand-back came from, under its
shared lock and never recreating a deleted copy. Until then the tab holds the
hand-back as pending: its own reads offer none of it again and keep the copy,
so a reload or crash offers the words again. Once acted on, in any tab, no read
offers them again. The toast still never times out.

* PR screenshots: a reload after Copy, and a reload with the toast not acted on

* Each notice records exactly what it offered, and every reader subtracts the same records

A hand-back record was one "covered up to" state vector, so acting on a later
notice also consumed an earlier notice's words, and the replacement reader
ignored records, so a tab still on the old copy offered words already acted on.

A notice now carries the item ranges whose words it shows; Copy or Dismiss adds
that set alone to the copy. Both readers (the replacement and the older-copy
read) offer through rescued-text's offer: what the server lacks minus the
copy's acted-on sets minus this tab's notices still showing. A copy is
deletable only when nothing beyond the server has words outside its acted-on
sets. The range helpers move from unsent-edits.ts to item-ranges.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* PR screenshots: two toasts, Copy on the second only, a reload offers the first again

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* A closed or removed room's notice records what it offered, like every other notice

The hand-back at a closing or removing retirement called `handBack` with no copy and no
ranges, so its Copy or Dismiss recorded nothing and a later read admission of the same
copy offered the words again.

`handBack` now takes the copy's name and an `Offer`, which only `offer` makes, so a notice
can't be built outside the accounting. The retirement reads the session's unacknowledged
typing synchronously (`DocumentSession.unsentEdits`, the items and an encoded document),
then reads the copy's records and offers what is left minus this tab's pending notices.
`clearLocalCopy` waits for that read before it deletes the copy. `unsentText` is gone.

* PR screenshots: a closed draft's notice, and the draft reopened read-only offering nothing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Capture offline hand-back browser verification

* Capture discard and reconnect browser checks

* Hand back closed-draft typing at once, say "changes", and let lookups wait for the sources

- A draft room kept read-only for its owner (closed draft, refused updates) retires on the
  next task once its last owner leaves, not after the 3 s grace: it can never reopen, and its
  retirement is what shows the hand-back toast. The toast came about 3 s after the side panel
  closed; it now comes in about 0.2 s.
- The hand-back toast says "Your latest changes": a wordless notice (a format change or a
  deletion) was told it was typing.
- A document lookup (the side's descriptor, an open) waits when the list shows the document
  but the server's answer of the sources has not come, as it already waits for the list. A
  list read from this browser's copy while offline or reconnecting made the side say "Couldn't
  look up the document to show here." until Retry. `ProjectTrees.ready` says when `find` can
  answer.

* Drop the draft pool's unused DocumentSessionAccess import

* Offer an unacted hand-back toast again at the next start, wherever its document is

A toast the writer never pressed Copy or Dismiss on came back after a reload
only when its document opened, because only that open read its copy. A closed
draft is rarely opened again, so its words sat unseen.

Each notice with words is now kept in localStorage (one key per notice under
the account: copy name, cause, item ranges, words) until its record is written.
The registry's first unsent-typing observer replays the kept notices under the
same id, through `offer` against the copy read without opening the document,
or from the kept words when the copy is gone (a purge). The older-copy read
waits for that replay: the replay's hold on the copy made it skip the copy, so
a reload offered only the kept notice. Sign-out forgets the account's notices.

* Keep unacted notices in their copy, not in a second store

The localStorage index of unacted notices held the words a second time, with
a lifetime of its own, and the review found three ways the two stores
disagreed: a peer's delete between the lookup and the lock recreated an empty
copy and erased the notice; a purged copy's replay offered overlapping and
already-acted words again; and a full localStorage left the words only in the
toast once the copy was removed.

The index is gone. A notice with words now writes what it offered (cause and
item ranges, no words) into its copy beside the acted-on records, so unacted
is offered minus acted, read from one database under one lock. The registry,
as it is made, reads every copy of the account no tab holds and offers each
unacted record again under its own id, overlapping records once, without
opening its document. A removal no longer deletes a copy with an unacted
offer: it marks it retired, and the copy goes when the last offer is acted on
or at a start that finds nothing left. Every read checks the copy exists under
the lock it reads under and never creates one.

The server's state can't be the measure at start: only a connected session
knows what the server lacks, and treating it as empty would offer a purged
document's whole text.

* Capture browser checks for unacted notices kept in their copy

* Extract the journal's open-and-transact code for the notice store to share

The command journal's IndexedDB open (close on versionchange, reopen on next
call) and its one-readwrite-transaction shape move to
core/indexeddb-database.ts, so the hand-back notice store uses the same code
instead of a copy of it.

Co-Authored-By: Claude <noreply@anthropic.com>

* Keep hand-back notices in one store per account, not in the copies

A hand-back notice is now a record that holds its own words, in
`meridian-handback:<account>` (hand-back-notices.ts). `claim` is the one way to
make a notice: in one readwrite transaction it subtracts what earlier notices
from the same copy hold and adds the rest. `act` (Copy or Dismiss) only sets
`acted`. No write rewrites a notice's ranges or clears `acted`, so no stale tab
can take a fact back, and two tabs holding the same words get one notice.

The registry shows `unacted()` when its first observer subscribes and whenever
another tab claims or acts (BroadcastChannel ping). A notice acted on in one
tab is withdrawn from every other tab's screen. The three callers
(replaceRoom, the older-copy read, terminal retirement) claim before any copy
is deleted; a claim that rejects shows its words unstored and keeps the copy
where it can.

The copies go back to working storage: the offered and handed-back records,
the retired mark, openUnacted, the start's copy read and the registry's
pending notices are deleted. clear deletes; clearAll deletes the notice
database only when no copy was left behind, and other accounts are found from
notice database names too.

Co-Authored-By: Claude <noreply@anthropic.com>

* Describe the hand-back notice store in the editor's context

Co-Authored-By: Claude <noreply@anthropic.com>

* Keep a toast acted on in this page when another registry withdraws it

The toaster belongs to the page, and a page can hold more than one registry
(dev StrictMode builds a second AccountFeatureLifetime it never closes). That
registry hears this page's own act and withdrew the toast that should stay,
showing Copied. The toast layer now withdraws only toasts not acted on here.

Co-Authored-By: Claude <noreply@anthropic.com>

* Resolve a transaction's end to its failure instead of discarding a rejection

Co-Authored-By: Claude <noreply@anthropic.com>

* Capture browser checks for the hand-back notice store

Co-Authored-By: Claude <noreply@anthropic.com>

* Read reportError when a notice read fails, not when the account starts

Co-Authored-By: Claude <noreply@anthropic.com>

* Keep acted hand-back notices, and let a press that wasn't stored be pressed again

Cleanup deleted an acted notice once its copy database was gone, but a
terminal retirement's claim can still be on its way from the session's
snapshot then, in any tab; it found nothing held and offered the words
again. Nothing in the store is deleted now but the whole database at
sign-out. Acting drops the words and keeps the items, and unacted
notices carry a field a sparse index lists, so a tab's read costs the
open notices only.

done() set its flag before act() was stored, so a rejected act left a
callback that never tried again and a notice a reload offered with no
way to settle it. done() now resolves when act commits; on rejection the
toast comes back with "Didn't go through. Try again." and the next press
runs act again.

* Extract the failed hand-back press line into the catalogs

* Close a dismissed hand-back toast when its act commits

Sonner keeps a toast it is still removing when it is shown again under
the same id, so a Dismiss whose act failed could not bring its toast
back. Dismiss now waits the moment its local write takes; a failure
leaves the toast in place with the failure line.

* Add final offline hand-back browser evidence

* Add archived draft browser evidence

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Remove PR screenshots for #1580 (linked at their commits)

* Import the gateway from @meridian-flow/runtime (#1612)

* Import the gateway from @meridian-flow/runtime/gateway

The gateway package became the runtime package's gateway entry. Imports,
dependencies, the catalog entry and docs follow; the lockfile waits for the
npm publish of @meridian-flow/runtime@0.1.0.

## Changelog

None: no user-visible change.

* Resolve @meridian-flow/runtime 0.1.0 from npm

* docs: capture runtime gateway browser verification

* An Agent package shows what Save will put in use: a list of changes and a side-by-side diff (#1609)

* Show what Save would change: a diff of each Agent file since its last save

A package's unsaved state now opens the list of its files added, changed and
deleted since the last save; each opens a read-only two-column diff of the
saved text against the file. GET /api/agents/saved-file serves the saved side
and replaces GET /api/agents/builtin (level=builtin), so one route reads a
file's text as new chats use it. The line diff is diffKeys over lines, with
wordDiff marking the words of an edited line.

* Keep a viewer's and a findings popover's clicks out of the row behind them

* Fix saved diff edge cases

* Fix empty document reads and narrow Agent review states

* Remove PR screenshots for #1609 (linked at their commits)

* Copy, not move, at a project's edge (#1598)

* Undo at a folder's old address finds the folder's move

The model's `undo` at a path nothing stands at now finds what moved away from it
(`nodeLeftAt`). An in-list folder move writes a receipt row for the folder only, so a
document that was inside it is found by the folder's old address above the path, and the
folder's move is what is taken back. What was deleted at the path, or a create undone
there, still comes first. `receiptsAt` had no other caller and is gone.

* A model undo or redo that worked no longer shows as "Couldn't undo"

`documentToolFailed` counted every write status other than `success` as a failure, so
an `undo` or `redo` that answered `reversed` (or `reconciled`) drew a red "Couldn't undo"
row in the chat. Those two are the call doing what it was asked, as the turn card's
reversal copy already reads them.

* Screenshots for the in-list move fixes PR

* Undo at an old address takes what last stood there; one set of done statuses

- `nodeLeftAt` walks this chat's receipt rows that touched the address or a folder above it,
  in order, carrying whether something still stood there. A folder that moved after the
  document had already left it (Notes/Alpha to Shelf/, then Notes/ to Old/) no longer answers
  for the document: `undo` at Notes/Alpha takes back Alpha's own move.
- `DONE_WRITE_STATUSES` / `isDoneWriteStatus` in `@meridian/contracts/protocol`, beside
  `UndoRedoOutcome`: the chat row (`documentToolFailed`) and the turn card's reversal copy read
  the same set.

* Undo at an old address counts a folder's move only when that folder holds the path now

A receipt for a folder's move can't say what the folder held, so the folder's
rows in nodeLeftAt now count only when that folder (by id) holds a node at the
rest of the path in the live tree. Another chat moving the document out first,
a name that never existed, and a folder that left, came back and left again no
longer bring the folder back.

* The AI's move between a project and Your files copies

A project's files and the account's user:// files are two lists, and a list
is the unit of history: Undo, Trash and pending changes each belong to one.
A model move whose source is in the other list now runs the writer's Copy
(port.copy) for that source; the original stays where it is. Sources in the
destination's list still move, in the same call, and the answer says which
moved and which were copied.

The copy runs before the call's command because Copy reads its sources
outside any transaction; each copied root's create receipt is written inside
the command, so the model's undo and the turn card's Undo take the copy away.
A drafted call that would copy across is refused: a Work's draft lives in one
list.

The chat row reads "Copied X to Y" when the call only copied.

* Delete the move between lists; Move… and filing stay in their own list

With the AI's cross-list move now a copy, nothing moves a node between a
project's list and the account's. Deleted: moveBetweenLists and the replay's
leave case, moveAcrossLists through the context port, adapter, router,
context-fs and tree-writes, the cross-list route, tree-across-lists.ts,
the receipts' across_lists column and their move-back path, the store's
leaving/arrivedIn claims, the app's moveDocumentAcrossLists, and casebook
cases 30 and 31.

In the app, Move… and the identity filing chip offer only the row's own
list; a drop on the other list offers Copy and Cancel. An old leave record
in a database names a parent no replay knows, so it is skipped as a missing
parent and the node stands where it was before the move.

* A dragged Copy names a Work only for a Work's own area

execute-copy sent the open Work's id with every copy, and the copy route
answered 400 for a kb:// or user:// destination given a Work. It now sends
workId and rootThreadId only when the area is Work-scoped.

* Screenshots for the copy at a project's edge PR

* The AI's copy across lists is one receipt that takes the folders it made

A copy into a folder that doesn't exist yet makes the folder, and Undo left it
behind. Copy's result now names the folders its insert made, and the AI's copy
records one create receipt for the call with every copied root and those
folders, as the in-list move does. An undone create answers the path it was
asked by, not its name in Trash.

* Raise the protocol to 2: an open tab from before the move between lists reloads

The cross-list move route an old tab sends is gone, and the copy result's
folders field is required: a tab below protocol 2 reloads.

* Move… with a selection in both lists offers Copy; the AI's copy reads its path as a move does

A selection spanning the project's files and Your files is offered Copy N
items to… instead of Move…, which moved only the first list's rows. Each row's
menu grants its list, and the selection group says when it crosses lists.

copyAcross decides into-or-at with movesInto, the rule runTreeCommand uses:
a folder copied to a trailing-slash path that names no folder lands at that
path, renamed, instead of inside a new folder. reversal.md no longer names
the across_lists receipt.

* Screenshots for the mixed selection's Copy

* tools.md: a copy across lists reads path as a move does; revert of its handle takes the copy only

* Locale catalogs for the selection's Copy

* A move's chat row names and opens where the node landed

The row read its destination and door from the path the model asked for, so a
copy beside a namesake read 'Your files/Probe folder' while it landed as
'Probe folder (2)'. It now takes the answer's path, as undo and redo rows do;
a document moved into a folder opens itself, not the folder, and a folder
gets no door: it opens as no document.

* Answer old moves with Copy and name folder copies on turn cards

* ci: update GitHub Actions to current majors (#1617)

* ci: update GitHub Actions to current majors

* TMP: staging steps copy

* Remove temporary staging steps copy

* Remove PR screenshots for #1598 (linked at their commits)

* fix(editor): keep selected cells across peer edits and Undo (#1618)

* fix(editor): preserve cell selections across peer updates and Undo

* docs(editor): explain cell coverage and remaining range mismatch

* docs(editor): keep the remaining selection task link current

* docs(editor): record mapped cell selection after Redo

* applyFiles: one way to create, merge and delete an Agent level's files, with Undo of a Save on it (#1614)

* refactor: share atomic tree insertion with package file application

Prepare and bind new package files before the caller's transaction, then recheck and insert them through Copy's tree path. Return per-file outcomes and clash counts, and merge or delete under the level list and sorted document locks.

Undo of a Save uses the prepared operation with creation and deletion disabled, keeping its existing transaction and collab mutation path. Check all destination roots before creating parent folders so a stale multi-folder plan leaves nothing behind. Preserve binary or prose replacements rather than mistaking a missing journal for an unchanged empty source file.

* Settle obstructed Agent file paths without losing other writes

Classify folders, blocked ancestors, prose and binaries before choosing a
source-text operation, both during preparation and under the list lock.
Preserve each obstruction and report landed-elsewhere with its actual path;
callers record that path for later updates. Deletion skips obstructions.

Keep Copy's allocation policy separate while sharing plan identities,
binding and insertion. Take the list lock through treeLists.lock and align
the in-memory changed-deletion result with PostgreSQL.

Verified folder, ancestor, prose, binary and between-phase arrivals against
PostgreSQL, plus actual-path updates, disabled creation and rollback on an
infrastructure failure. The temporary probe fails on the pre-fix adapter.

* TreeListStore.lock's comment says it also takes seam Works' locks, inside a transaction

* PR screenshots for #1614 (browser runs p17898, p17928)

* Remove PR screenshots for #1614 (linked at their commits)

* Undo and Un-Apply match plain Yjs (#1615)

* Undo and Un-Apply restore the original beside the writer's text, as plain Yjs does

Delete the stranded rule (strandedByRemoval) and Un-Apply's word rule
(changesLaterWord, keepLaterWords).

* Update the Undo-after-replacement case to the plain Yjs result

* Add browser run screenshots

* Drop the Un-Apply text-stayed notice; state the contract and doc examples as they are

* Add final-head Un-Apply browser evidence

* Remove PR screenshots for #1615 (linked at their commits)

* AI find edit writes only the words it changed (#1607)

* feat(agent-edit): a find edit writes only the words it changed

A find's match window is word-diffed on its own, so the writer's edit to a
word the model kept survives, even where that leaves a fragment.

* docs: browser proof screenshots for find-edit-changed-words

* fix(agent-edit): keep marks across a split run; describe a part in reading order

An insert that cut a run copied its tail with no attributes for plain text, which Yjs reads as
'inherit the marks before it', so bold, links and breaks spread onto the plain tail. Each tail
segment now carries its full mark state. A part's before/after text on the card, in the model's
edit list and in draft states is read from document positions (first to last changed unit, with
the kept text between), not joined by clock. lowerText has one diff loop: no window is one
whole-block window. Stale 'written whole' text corrected.

* docs: browser proof screenshots for the split-run marks and card text

* Show only the changed words in the before → after excerpt

describeRanges rebuilt the unchanged text between changes from the clock frontier, which cannot say what was visible: words the writer deleted before the write came back, and text between two inline atoms went missing. The excerpt now reads only the changed units in document order, joined by … within a block. The walker is the one rescued text already used, moved into agent-edit so the server and the app share it.

* docs: capture find edit browser verification

* Remove PR screenshots for #1607 (linked at their commits)

* Move to Node 26.13.1 and pnpm 12.21.0 (#1621)

* Move to Node 26.13.1 and pnpm 12.21.0

Node and pnpm pins in .tool-versions, CI and docs; @types/node ^26.
pnpm 11+ settings: allowBuilds lists every build script,
verifyDepsBeforeRun moves from .npmrc (no longer read) to the workspace
file, and first-party @meridian-flow packages skip the release age gate.
Node 25+ defines a global localStorage that shadows jsdom's, so app tests
run with --no-experimental-webstorage; lib0 0.2.120 stops the server
logging that warning at import. @types/node 26 makes process.disconnect
optional.

* docs: capture Node 26 browser probe

* Read localStorage only in a window, so Node 26 SSR prints no ExperimentalWarning

* docs: capture offline recovery and collaboration probe

* Undo and Redo of names and places read the moves and renames in force (#1597)

* Undo and Redo of names and places read the moves and renames in force

Two copies of a project tree that are out of step could lose a name or a
place on merge. A rename an Undo never saw was overwritten by the old name,
a second concurrent Undo of one rename brought back the name before the
unseen rename, a Redo of a move dropped its numbered name, and a stale Undo
of a move sent the node to where its author last saw it. All of them happen
on main.

The cause: the replay showed the name and place an opposite record
carries, which is what its author's copy showed, and undoChange decided a
Redo or second Undo by comparing carried values (reverses, movedAfter,
lastSetBy). The merged list said neither.

Now, for moves and renames only:
- A node's name and place are what the last move or rename in force says,
  or its create. A move or rename is in force unless the last record about
  it is an Undo (a Redo is an Undo of an Undo).
- An Undo or Redo sets nothing itself. withTurned says what turning one
  change out or back in does to a fact; the replay applies it and
  undoChange calls it on the projection's lists, so there is one copy.
- undoChange answers already when the change is where the press wants it,
  and changed_since when a later change holds every fact, or the place
  would be inside the node; it writes nothing then.
- undoFacts says which fact of a move that also set a name stays, so
  undoApply's left no longer guesses it from the record's type.
- projection.inForce replaces recordsInForce; creates, deletes and
  restores keep main's rule there, since Trash counts deletes its own way.
- admission stamps dropped by where the replay leaves the node for an
  Undo or Redo of a move (Change.parent), not by its carried parent.
- The review's folder row reads the Work's tree against live for the name
  it was, and for where an Undo or Redo of a move puts the folder.

Deleted: Setter.before, arrivedBefore, setFact, reverses, movedAfter,
lastSetBy, both Redo branches of undoChange with Redo's name recalculation
and its refusal to Redo a type change, recordsInForce, and the replay's
isAncestor (wouldLoop is the one cycle check).

The casebook gains the cases two copies out of step produce; 13 of them
fail on main, and the Un-Apply fact case fails on the design's prototype.

* Test budget: the casebook's cases for two copies out of step

The casebook grows from 71 to 98 cases and admission from 11 to 12: the
Undo and Redo cases of names and places, kept to prove the rule.

* Undo by the changes in force: the sidebar's comment, and the PR's browser screenshots

* Replay: a node's name arrival moves only when its name list changes

A plain move recomputed when the node came to show its name, calling
shownName down the name list on every move. Keep it on the node
(namedAt) and recompute it when the name list changes. Warm replay of
2,000 nodes and 20,000 moves and renames: 90-95 ms before, 55-79 ms
after; main 35-64 ms.

* Undo: one in-force rule for every record; readers ask what an Undo turned

A record is in force unless a later record in force undoes it (standingOf), for
moves and renames as for creates, deletes and restores. The parity rule ("the
last word"), Change.depth, head and Holder.at are gone. The replay applies the
rule over one change's chain as each Undo arrives and turns that node's facts
there, so an Undo of an Undo that did nothing when it landed no longer brings
the change back (Un-Apply of an applied stale Undo, property seed 250381).
undoChange writes its record even when another Undo keeps the change out, so
Un-Apply takes its copy out.

Readers of an Undo ask the replay's Change, not the record's type: admission
reads Change.parent for an Undo of any type, Apply's factsIn gives an Undo its
base change's facts, and the review row reads the trees once an Undo follows
the last move. projection.setters goes (the server reads history); the dead
exports go from index.ts.

The review's forward-only replay (apply only the moves in force) was tried and
dropped: an Undo then rewrites past placement and can turn another node's move
into a cycle, which undoChange cannot foresee.

Casebook: Redo-only cases deleted (chat Redo is dropped), Undo halves kept, one
case for the Un-Apply regression. The property test allows for a skipped
drafted record that starts to land (seeds 400309, 500623) and for a record with
two live copies in force (seed 250790; one Undo takes both).

* Undo by the one in-force rule: the PR's browser screenshots on the final code

* Remove PR screenshots for #1597 (linked at their commits)

* The home folder belongs to the account, not the first project (#1599)

* The home folder's source belongs to the account, not the first project

`~` (scheme `user`) was a source of the project marked `is_personal`, so every
home document named that project: deleting it took the writer's home with it,
and a chat elsewhere reached `~` only through it.

Now a source, a document and a link ahead are owned by a project or by an
account, exactly one. The account's `user` source is made by a trigger on
`users` insert. Every reader takes a source's owner from `source-owner.ts`
(one SQL fragment, `TreeList` as the owner) instead of joining a project
through the source, and "belongs to this request" is one rule,
`ownedByRequest`: its project, or its account's home folder.

- File policy: `FileFacts.owner`, an `account` node, owner ref and grant.
- The request's project comes from the principal (`Principal.agent.projectId`,
  the thread's), not the file's: a model's draft of a `~` document opens its
  branch in the chat's project; link scopes read in it.
- A home document read by id reads its links in the viewer thread's project;
  Agent files pass theirs.
- `is_personal` and `default_bootstrap_ready` are deleted: an account with no
  live project gets one at sign-in; `./mf --project default` is the oldest.
- `document_block_rooms.project_id` and `document_blocks.project_id` are
  deleted (only the copy read them); `purgeUnviewed` locks the owner's list.

* ./mf finds the home folder's source, which the account now owns

A source's owner gained `account`; `doc` commands matched only `project`,
so `./mf doc rm user://...` answered "No source". The auth gate's comment
named the personal project.

* An image in the home folder is spelled for the model; dead project-scoped recovery deleted

The link scope's assetAddress matched an image row on the snapshot's project, which an
account-owned row never has, so a home image read back as ![p]() everywhere. nameable,
assetAddress and assetFor now share ownedByRequest: a project row in the reader's project,
an account row of the reader's account.

Deleted, all without production callers: countIncomingLinks (its "Updated N links" line
went with #1457), the derivation service's project-scoped flush, drainAheads, the scope
on stale(), and the registry recovery's project scope. An unused test getter goes too.

* Old tabs reload: protocol 2, since a tab on 1 can't find the account-owned home source

On protocol 1 the app's sourceFor knows no {kind: "account"} owner, so an open tab
would lose the user:// source. The server keeps no path for the old shape, so the
minimum moves with the current version.

* A home document's links read as its account; the read route reads in its project

A link scope keyed by a home document with no viewer thread resolved neither a project
nor a viewer, so ownedByRequest matched nothing and doc read of a ~ note spelled every
image blank. Such a scope now reads as the document's account and joins an enclosing
snapshot that account opened; GET .../documents/:id/read opens one in its project, so a
~ note spells the project's images there too.

* Store home note images in the home folder

* Wait for chat creation before reading its draft

* fix(server): built server crashed at import with __exportAll is not a function (#1627)

* fix(server): built server crashed at import with "__exportAll is not a function"

Repro: cd apps/server; pnpm exec nitro build; node .output/server/index.mjs
(or pnpm smoke:prod-boot).

Cause: Rolldown put its helpers in _chunks/limits.mjs, which since #1455 also
held html-markdown.ts. That imports the unified libs, which import the helpers
back, so Node ran hast-util-from-html before the helpers existed. html-markdown
now has its own chunk. The prod-boot smoke now also builds and starts the API
server and probes /healthz, which the job never did.

* fix(server): end the chunk-cycle class with Rolldown 1.2.19; make the prod-boot smoke mean it boots

Rolldown 1.2.16 hosts its runtime only in a chunk every consumer's entries
load, so no lib chunk can cycle with the helpers. The per-file chunk group is
deleted. The smoke now waits for startup.complete against a throwaway
Postgres database, fails on a startup failure or child exit, and checks the
server build for chunk import cycles. The prod-boot job starts a Postgres.

* A Save's Undo stays offered after you edit again, and every surface agrees on it (#1624)

* fix(agents): keep Save Undo available after later edits

* PR screenshots: a Save's Undo stays after edits

* fix(agents): derive Save Undo offers from package status

Record Undo provenance and Save origin on the existing Save rows. Read the
latest undoable Save from the files query so AI Saves, reloads and other
tabs share the same offer. Publish the existing files hint after commits,
including Undo that changes no document text.

Keep only pending requests and retryable failures in client Undo state.
Distinguish repeated Undo from a superseded Save, and retain saved removal
offers without treating those removals as unsaved changes.

* fix(agents): an undone Save's receipt still says Undone after a later Save

The package status listed only the latest row's undone Save, so after Undo and a
later Save the old receipt fell through to "A later Save is in use". The status
now carries every Save of the package an Undo took back.

* PR screenshots: an undone AI Save stays Undone after a later Save

* Remove PR screenshots for #1624 (linked at their commits)

* Keep offline typing in a document purged before its room reconnects (#1616)

* Keep offline typing in a document purged before its room reconnects

Each local copy now holds a mark of what the server is known to have: a
Yjs state vector in its `custom` store, taken from the server's SyncStep1
at every handshake, from each update the server sends, and from the
document whenever the server has acknowledged everything. The mark only
grows, per client, in one transaction; a handshake whose vector does not
cover it replaces it, because the room then lacks items it counts (a room
restored from a checkpoint or reseeded).

Deleting a copy now claims what it holds beyond its mark first, and keeps
the copy when the claim can't be stored, so a later start claims it again.
A closing or removing retirement reads its copy the same way instead of
the session's unacknowledged updates. A copy with no mark is deleted as
before; an empty copy starts with an empty mark.

Before this, a reload while offline left the typing only in the copy, and
a purge before the room reconnected deleted it unread.

* Read a server update's items by their end clocks; describe the mark beside the code

Y.encodeStateVectorFromUpdate counts only runs that start at clock 0, so
an incremental update from the server read as nothing and a collaborator's
words stayed beyond the mark.

* PR screenshots for the server mark

* Note what a shipped restore owes the mark

* Mark only what the server has shown; offer a copy with no mark whole

An update the server sends is not evidence: Yjs can integrate a local peer's
pending items in the same provider-origin transaction, and Hocuspocus never
uploads such an update, so the mark counted the peer's unsent words as the
server's. The mark now takes the server's SyncStep1 and, at a full
acknowledgement, the document's state vector; a server frame that releases
pending local items is sent up as a local change, so a full acknowledgement
still means the server holds the whole document.

A copy with no mark counts as marking nothing, so its whole content is
offered instead of deleted unread.

* Send what the server lacks after each server frame; end a metadata-closed draft's transport

The pendingStructs snapshot depended on how transactions nest: a schema repair
opened inside the provider's transaction overwrote it, so a local peer's
pending words released by a server frame were never uploaded, the repair's
acknowledgement marked them saved, and a purge deleted them unoffered.

The transport now keeps, per socket, the state vector its frames show the
server holds: the server's SyncStep1, every update it sends, every one written
to the socket (server-has.ts). After each server frame, once the provider and
every transaction it opened are done, an editable room sends what the
document holds beyond it. The full-acknowledgement mark is that vector, not
the document's, so the mark only counts what crossed the wire.

A draft closed by metadata now ends its transport as the socket's close does,
so nothing more is sent from it; the status guard that kept such a room closed
against later socket news is gone with the news.

* Claim nothing before SyncStep1, grow only contiguous runs in server-has

A server Update before this socket's SyncStep1 left the vector holding
only that update, so the after-frame check uploaded almost the whole
document (12 KB in p17987's early-broadcast probe; a draft room queued
one per early frame). lacking now returns null until SyncStep1 arrives.

A payload can carry structs past a gap that the server holds only as
pending; parseUpdateMeta's end clocks over-claimed them. holds() now
extends a client's clock only by runs continuing from it, and received
frames are noted before the provider applies them so the SyncStep2
reply continues from the server's clocks.

Header and CONTEXT.md say the check covers inserts; deletions go with
the next handshake.

* Browser pass on the final code: screenshots (p18004)

* Remove PR screenshots for #1616 (linked at their commits)

* Upgrade prosemirror-view, hocuspocus, tanstack router, micromark; re-port their patches (#1622)

* Upgrade prosemirror-view, hocuspocus, tanstack router, micromark; re-port or drop their patches

prosemirror-view 1.41.9 -> 1.42.9 (selectionForDOM re-ported; two Firefox reads added), prosemirror-model/transform to current,
@hocuspocus/* 4.3.0 -> 4.8.0 (awareness ownership re-ported), @tanstack/history 1.162.3 -> 1.162.5 and the router packages (traversal patch re-ported),
micromark 4.0.2 -> 4.0.3 (line-suffix half of the patch dropped: upstream uses an edit map; text-merge half kept).
decode-named-character-reference 1.3.0 is latest and its patch is still needed.

* Regenerate routeTree.gen.ts with the upgraded router generator

* Add PR screenshot: editor after the upgrade

* Drop validate from paragraph align/level and table align

prosemirror-model 1.25.12 runs attribute validate inside NodeType.create. The
y-tiptap binding deletes a Yjs element it cannot build, and the server's
readRepairedRoot writes that delete into the room, so a paragraph with level
"2", level 7 or align "left" vanished. No document-schema attribute has a
validate now; the codec and paste parsers still check what Flow writes. The
editor's heading renderer treats an unknown level as a paragraph.

* Dedupe prosemirror-transform and prosemirror-model in the lockfile

* Add browser probe screenshots for dependency upgrades

* Add block and draft review probe screenshots

* Use landed tree addresses and preserve import arrival order

* Move Flow to @meridian-flow/runtime 0.2.0 (#1628)

* Keep media out of assistant messages for runtime 0.2.0

The runtime's Message is now a union by role. The context builder builds
assistant parts from their own block mapper (text, reasoning, tool use) and
user parts from another (text, media), instead of one mapper that could put
media into an assistant message. Tests that placed a tool_result inside an
assistant message now use a tool message.

* Move Flow to @meridian-flow/runtime 0.2.0

* Resolve lockfile for runtime 0.2.0 on pnpm 12

* Add runtime 0.2 browser probe screenshots

* Correct the blockToUserPart comment

* Only an Agent with mode: primary starts a chat; a new Agent starts as primary (#1633)

* fix(agents): only an Agent with mode: primary starts a chat

An Agent with no mode was offered in the picker, so an imported package whose
helpers leave mode out would fill it with subagents. Mars lists such an Agent as a
subagent; Flow now does the same, in the picker, Send, and the Agents tab's pickable.

* PR screenshot: the picker without a mode-less Agent

* fix(agents): a new Agent starts as mode: primary; one rule for who starts a chat

A new Agent from the Agents tab had no mode, so under the primary rule it never
reached the picker. Its template now says mode: primary. Fork and handoff use the
catalog's isPrimary, so user-invocable: false is refused there too. save_agents
tells the model what mode means, and two fixtures declare their primaries.

* test(agents-through-mars): probe Agents are primary unless a fixture says otherwise

* Remove PR screenshots for #1633 (linked at their commits)

* Move several to a source's top again; Agent level files only merge

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
haowjy added a commit that referenced this pull request Nov 16, 2026
haowjy added a commit that referenced this pull request Nov 16, 2026
…ses one (#1643)

* Names repeat, part 1: twins keep the name, the later's path carries ~id (#1602)

* contracts: read a twin's ~id segment in one place

readSegment splits a path segment into its name and a later twin's suffix.
validateContextEntryPath normalises only the name part, so Kael~b21c reaches
the walkers as written. The leaf readers in contracts (canonicalLeaf,
documentTitleFromUri, filetypeForKnownPath, documentFilenameAt,
omittedExtensionPath, documentPathCandidateNames) read the name and keep the
suffix aside. normalEntryName's output is unchanged.

* Rule 14: twins keep the name, and the later's path carries ~id

The replay no longer numbers a clash nobody saw. Every twin after the first
to arrive carries the shortest start, four hex digits or more, of its id that
no other shown sibling's begins with: label Kael, segment Kael~b21c.
TreeNode.displayName goes; name is the label, suffix the twin's.
childAtSegment walks a segment (lowest id when a hand-shortened suffix fits
two, no Trash fall-through) and segmentOf spells one. A restore that undoes a
delete keeps the arrival, so an Undo leaves the twins as they were. Writers
still number the clashes they can see; that goes in part 2.

Rows carry suffix, and tree_nodes and branch_tree_nodes a generated segment
that walks, path spelling and the walk index use. A Work's row that differs
from live only in a suffix is not a change it made (branch_tree_nodes.changed,
BranchRow.changed): the count, the Changes list and the review list skip it.

Readers take the label or the segment: the SQL relations and placed nodes
expose segment, and every path speller (addresses, folder chains, findById,
context availability, liveDocuments, the store's ls, stat, grep and copy
snapshot, Agents files, the browser's tree view and mf's lookup) joins
segments. The router keeps a leaf's ~id when it re-renders the leaf, which
it dropped before. Titles, breadcrumbs, upload chips and export folders read
the label. The ambiguous path outcome, its fault and every consumer go: a
segment reaches one node. Apply's carry of a numbered name had nothing left
to carry and goes.

* docs: a path is segments; context-location import after its header

* PR screenshots for names repeat part 1

* Names repeat, part 2: writers stop numbering and refusing; same-titled tabs show their place (#1619)

* Keep same-named entries as twins

* Distinguish same-named document tabs

* Capture same-named document examples

* Capture apply and import collision results

* Preserve old moves and landed creation paths

* Names repeat, part 3: receipts record where things landed; main merged; protocol 4 (#1638)

* Run on @meridian-flow/gateway from npm; delete packages/gateway (#1604)

* Run on @meridian-flow/gateway from npm; delete packages/gateway

The gateway moved to haowjy/meridian-runtime. apps/server and packages/contracts take it
from the pnpm catalog (one version). The model-request debug capture now copies named
fields, so GenerateRequest.auth (a credential) never reaches a record. The architecture
map shows the gateway as an external package and drops its import rule; the baselines
lose its entries. What only Flow knew in the gateway's CONTEXT and its mock-provider
recipe moved to apps/server/server/lib/gateway/.context. The root AGENTS.md says how to
try a gateway change here before it is published.

pnpm-lock.yaml has no resolution for the gateway until 0.1.0 is on npm: run pnpm install
after the publish.

* docs: keep package behaviour in the package's CONTEXT, Flow wiring doc holds Flow's choices

* docs: restore Flow's registry validation and promptCache merge rules to the gateway wiring doc

* Resolve @meridian-flow/gateway 0.1.0 from npm

* docs: capture gateway npm browser verification

* Say when the protocol minimum moves

* Tree rooms wait out their store work when the gateway drains (#1608)

* Unsent edits in a room that comes back read-only: rebuild and hand back (#1580)

* A read-admitted room finds what the server lacks from each handshake

A read-admitted connection no longer sends Update frames, and its handshake
says what the document holds that the server lacks (the SyncStep1 and
SyncStep2 pair), so acknowledgement there is the session's verdict instead
of a SyncStatus the server always answers false. The session tells the
writer's edits from the editor binding's own repairs by the sync plugin's
mark, keeps a ledger of typing, and carries display writes to peer tabs and
the copy so a repair made by one tab is never counted by another.

Nothing replaces a room yet: the session only exposes holdsUndeliverableEdits.
The undo manager skips a binding write that has no mark.

* A room's local copy has incarnations

A session that must stop offering what its copy holds opens the next
incarnation of the copy instead of emptying it under the tabs that have it
open. The incarnation is a trailing number on the database name, and its
pointer is in localStorage; two tabs advancing at once both end on the same
next number. An older incarnation no tab holds is read against the first
handshake of the session that opens the current one, its words are handed
back, and it is deleted. text() reads the current incarnation only, and a
copy's lock is per database.

* A room admitted read-only is replaced by one loaded from the server

When a read admission's handshake shows the document holds edits the server
lacks, the registry hands the typing back in a toast, makes the session
inert and opens a new one on the next incarnation of the copy. The new
session starts read-only with the server's text; its holders (live bindings,
open tabs, draft room readers) bind it, and the old session is destroyed when
its editors have unmounted, under its own persistence name so the room stays
available.

* A review mount keeps its place across a replaced session

A room that came back read-only is rebuilt from the server and its editor
remounts. A live mount already restored its place from the reading-position
store; a review mount kept none, so it now carries its place across the
replacement only (not between visits).

* Docs and catalogs for the read-only handback

* PR screenshots for the read-only handback (linked at this commit)

* A replaced session never reconnects; a handed-back copy is deleted; Discard counts as the writer's

The replaced session ignores attachTransport for good, so no retain, restart
or pending attachment can reconnect it and upload the words just handed back.
Older-copy cleanup offers recovered words only (no wordless toast for a copy
the server already has). A Discard's origin is a local write, so a Discard
made offline is the writer's own wordless change and gets its toast. The old
incarnation is deleted when its session is destroyed (CopyHold.drop), so its
words are not offered again after a reload.

* A copy is deleted only after its whole content is read against the server: replaced sessions retire by the older-copy path

* A copy records what was handed back from it, so no later read offers it again

When a replaced session handed back its typing, the record of what it had
returned lived only in the callback that retired it. If another tab still held
the old copy, that read was skipped, and the next read (a reload, the other tab
closing) offered the returned words again with the other tab's new ones.

The session now writes the state its deciding handshake covered (the server's
state plus every struct the server lacked) into its copy's custom store when it
hands back. Every older-copy read takes those records with the copy and offers
only what lies beyond them and the server. Words written after that handshake
are not covered and come back once.

The copy can't instead hold nothing already handed back: it is shared with tabs
still writing into it, and Yjs can't remove an operation.

Also: a session's copy is named from the one pointer read that records its
incarnation; reading the pointer twice could open one incarnation and record
another.

* A hand-back is recorded in its copy when the writer is done with the toast

The record that keeps a later read from offering handed-back words again was
written when the toast showed. That ended a settled rule: words found in an
older copy after a reload are offered again, so a toast the writer never acted
on is not the only place their words are.

The record is now written when the writer copies the words or dismisses the
toast (`UnsentTyping.done`), into the copy the hand-back came from, under its
shared lock and never recreating a deleted copy. Until then the tab holds the
hand-back as pending: its own reads offer none of it again and keep the copy,
so a reload or crash offers the words again. Once acted on, in any tab, no read
offers them again. The toast still never times out.

* PR screenshots: a reload after Copy, and a reload with the toast not acted on

* Each notice records exactly what it offered, and every reader subtracts the same records

A hand-back record was one "covered up to" state vector, so acting on a later
notice also consumed an earlier notice's words, and the replacement reader
ignored records, so a tab still on the old copy offered words already acted on.

A notice now carries the item ranges whose words it shows; Copy or Dismiss adds
that set alone to the copy. Both readers (the replacement and the older-copy
read) offer through rescued-text's offer: what the server lacks minus the
copy's acted-on sets minus this tab's notices still showing. A copy is
deletable only when nothing beyond the server has words outside its acted-on
sets. The range helpers move from unsent-edits.ts to item-ranges.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* PR screenshots: two toasts, Copy on the second only, a reload offers the first again

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* A closed or removed room's notice records what it offered, like every other notice

The hand-back at a closing or removing retirement called `handBack` with no copy and no
ranges, so its Copy or Dismiss recorded nothing and a later read admission of the same
copy offered the words again.

`handBack` now takes the copy's name and an `Offer`, which only `offer` makes, so a notice
can't be built outside the accounting. The retirement reads the session's unacknowledged
typing synchronously (`DocumentSession.unsentEdits`, the items and an encoded document),
then reads the copy's records and offers what is left minus this tab's pending notices.
`clearLocalCopy` waits for that read before it deletes the copy. `unsentText` is gone.

* PR screenshots: a closed draft's notice, and the draft reopened read-only offering nothing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Capture offline hand-back browser verification

* Capture discard and reconnect browser checks

* Hand back closed-draft typing at once, say "changes", and let lookups wait for the sources

- A draft room kept read-only for its owner (closed draft, refused updates) retires on the
  next task once its last owner leaves, not after the 3 s grace: it can never reopen, and its
  retirement is what shows the hand-back toast. The toast came about 3 s after the side panel
  closed; it now comes in about 0.2 s.
- The hand-back toast says "Your latest changes": a wordless notice (a format change or a
  deletion) was told it was typing.
- A document lookup (the side's descriptor, an open) waits when the list shows the document
  but the server's answer of the sources has not come, as it already waits for the list. A
  list read from this browser's copy while offline or reconnecting made the side say "Couldn't
  look up the document to show here." until Retry. `ProjectTrees.ready` says when `find` can
  answer.

* Drop the draft pool's unused DocumentSessionAccess import

* Offer an unacted hand-back toast again at the next start, wherever its document is

A toast the writer never pressed Copy or Dismiss on came back after a reload
only when its document opened, because only that open read its copy. A closed
draft is rarely opened again, so its words sat unseen.

Each notice with words is now kept in localStorage (one key per notice under
the account: copy name, cause, item ranges, words) until its record is written.
The registry's first unsent-typing observer replays the kept notices under the
same id, through `offer` against the copy read without opening the document,
or from the kept words when the copy is gone (a purge). The older-copy read
waits for that replay: the replay's hold on the copy made it skip the copy, so
a reload offered only the kept notice. Sign-out forgets the account's notices.

* Keep unacted notices in their copy, not in a second store

The localStorage index of unacted notices held the words a second time, with
a lifetime of its own, and the review found three ways the two stores
disagreed: a peer's delete between the lookup and the lock recreated an empty
copy and erased the notice; a purged copy's replay offered overlapping and
already-acted words again; and a full localStorage left the words only in the
toast once the copy was removed.

The index is gone. A notice with words now writes what it offered (cause and
item ranges, no words) into its copy beside the acted-on records, so unacted
is offered minus acted, read from one database under one lock. The registry,
as it is made, reads every copy of the account no tab holds and offers each
unacted record again under its own id, overlapping records once, without
opening its document. A removal no longer deletes a copy with an unacted
offer: it marks it retired, and the copy goes when the last offer is acted on
or at a start that finds nothing left. Every read checks the copy exists under
the lock it reads under and never creates one.

The server's state can't be the measure at start: only a connected session
knows what the server lacks, and treating it as empty would offer a purged
document's whole text.

* Capture browser checks for unacted notices kept in their copy

* Extract the journal's open-and-transact code for the notice store to share

The command journal's IndexedDB open (close on versionchange, reopen on next
call) and its one-readwrite-transaction shape move to
core/indexeddb-database.ts, so the hand-back notice store uses the same code
instead of a copy of it.

Co-Authored-By: Claude <noreply@anthropic.com>

* Keep hand-back notices in one store per account, not in the copies

A hand-back notice is now a record that holds its own words, in
`meridian-handback:<account>` (hand-back-notices.ts). `claim` is the one way to
make a notice: in one readwrite transaction it subtracts what earlier notices
from the same copy hold and adds the rest. `act` (Copy or Dismiss) only sets
`acted`. No write rewrites a notice's ranges or clears `acted`, so no stale tab
can take a fact back, and two tabs holding the same words get one notice.

The registry shows `unacted()` when its first observer subscribes and whenever
another tab claims or acts (BroadcastChannel ping). A notice acted on in one
tab is withdrawn from every other tab's screen. The three callers
(replaceRoom, the older-copy read, terminal retirement) claim before any copy
is deleted; a claim that rejects shows its words unstored and keeps the copy
where it can.

The copies go back to working storage: the offered and handed-back records,
the retired mark, openUnacted, the start's copy read and the registry's
pending notices are deleted. clear deletes; clearAll deletes the notice
database only when no copy was left behind, and other accounts are found from
notice database names too.

Co-Authored-By: Claude <noreply@anthropic.com>

* Describe the hand-back notice store in the editor's context

Co-Authored-By: Claude <noreply@anthropic.com>

* Keep a toast acted on in this page when another registry withdraws it

The toaster belongs to the page, and a page can hold more than one registry
(dev StrictMode builds a second AccountFeatureLifetime it never closes). That
registry hears this page's own act and withdrew the toast that should stay,
showing Copied. The toast layer now withdraws only toasts not acted on here.

Co-Authored-By: Claude <noreply@anthropic.com>

* Resolve a transaction's end to its failure instead of discarding a rejection

Co-Authored-By: Claude <noreply@anthropic.com>

* Capture browser checks for the hand-back notice store

Co-Authored-By: Claude <noreply@anthropic.com>

* Read reportError when a notice read fails, not when the account starts

Co-Authored-By: Claude <noreply@anthropic.com>

* Keep acted hand-back notices, and let a press that wasn't stored be pressed again

Cleanup deleted an acted notice once its copy database was gone, but a
terminal retirement's claim can still be on its way from the session's
snapshot then, in any tab; it found nothing held and offered the words
again. Nothing in the store is deleted now but the whole database at
sign-out. Acting drops the words and keeps the items, and unacted
notices carry a field a sparse index lists, so a tab's read costs the
open notices only.

done() set its flag before act() was stored, so a rejected act left a
callback that never tried again and a notice a reload offered with no
way to settle it. done() now resolves when act commits; on rejection the
toast comes back with "Didn't go through. Try again." and the next press
runs act again.

* Extract the failed hand-back press line into the catalogs

* Close a dismissed hand-back toast when its act commits

Sonner keeps a toast it is still removing when it is shown again under
the same id, so a Dismiss whose act failed could not bring its toast
back. Dismiss now waits the moment its local write takes; a failure
leaves the toast in place with the failure line.

* Add final offline hand-back browser evidence

* Add archived draft browser evidence

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Remove PR screenshots for #1580 (linked at their commits)

* Import the gateway from @meridian-flow/runtime (#1612)

* Import the gateway from @meridian-flow/runtime/gateway

The gateway package became the runtime package's gateway entry. Imports,
dependencies, the catalog entry and docs follow; the lockfile waits for the
npm publish of @meridian-flow/runtime@0.1.0.

## Changelog

None: no user-visible change.

* Resolve @meridian-flow/runtime 0.1.0 from npm

* docs: capture runtime gateway browser verification

* An Agent package shows what Save will put in use: a list of changes and a side-by-side diff (#1609)

* Show what Save would change: a diff of each Agent file since its last save

A package's unsaved state now opens the list of its files added, changed and
deleted since the last save; each opens a read-only two-column diff of the
saved text against the file. GET /api/agents/saved-file serves the saved side
and replaces GET /api/agents/builtin (level=builtin), so one route reads a
file's text as new chats use it. The line diff is diffKeys over lines, with
wordDiff marking the words of an edited line.

* Keep a viewer's and a findings popover's clicks out of the row behind them

* Fix saved diff edge cases

* Fix empty document reads and narrow Agent review states

* Remove PR screenshots for #1609 (linked at their commits)

* Copy, not move, at a project's edge (#1598)

* Undo at a folder's old address finds the folder's move

The model's `undo` at a path nothing stands at now finds what moved away from it
(`nodeLeftAt`). An in-list folder move writes a receipt row for the folder only, so a
document that was inside it is found by the folder's old address above the path, and the
folder's move is what is taken back. What was deleted at the path, or a create undone
there, still comes first. `receiptsAt` had no other caller and is gone.

* A model undo or redo that worked no longer shows as "Couldn't undo"

`documentToolFailed` counted every write status other than `success` as a failure, so
an `undo` or `redo` that answered `reversed` (or `reconciled`) drew a red "Couldn't undo"
row in the chat. Those two are the call doing what it was asked, as the turn card's
reversal copy already reads them.

* Screenshots for the in-list move fixes PR

* Undo at an old address takes what last stood there; one set of done statuses

- `nodeLeftAt` walks this chat's receipt rows that touched the address or a folder above it,
  in order, carrying whether something still stood there. A folder that moved after the
  document had already left it (Notes/Alpha to Shelf/, then Notes/ to Old/) no longer answers
  for the document: `undo` at Notes/Alpha takes back Alpha's own move.
- `DONE_WRITE_STATUSES` / `isDoneWriteStatus` in `@meridian/contracts/protocol`, beside
  `UndoRedoOutcome`: the chat row (`documentToolFailed`) and the turn card's reversal copy read
  the same set.

* Undo at an old address counts a folder's move only when that folder holds the path now

A receipt for a folder's move can't say what the folder held, so the folder's
rows in nodeLeftAt now count only when that folder (by id) holds a node at the
rest of the path in the live tree. Another chat moving the document out first,
a name that never existed, and a folder that left, came back and left again no
longer bring the folder back.

* The AI's move between a project and Your files copies

A project's files and the account's user:// files are two lists, and a list
is the unit of history: Undo, Trash and pending changes each belong to one.
A model move whose source is in the other list now runs the writer's Copy
(port.copy) for that source; the original stays where it is. Sources in the
destination's list still move, in the same call, and the answer says which
moved and which were copied.

The copy runs before the call's command because Copy reads its sources
outside any transaction; each copied root's create receipt is written inside
the command, so the model's undo and the turn card's Undo take the copy away.
A drafted call that would copy across is refused: a Work's draft lives in one
list.

The chat row reads "Copied X to Y" when the call only copied.

* Delete the move between lists; Move… and filing stay in their own list

With the AI's cross-list move now a copy, nothing moves a node between a
project's list and the account's. Deleted: moveBetweenLists and the replay's
leave case, moveAcrossLists through the context port, adapter, router,
context-fs and tree-writes, the cross-list route, tree-across-lists.ts,
the receipts' across_lists column and their move-back path, the store's
leaving/arrivedIn claims, the app's moveDocumentAcrossLists, and casebook
cases 30 and 31.

In the app, Move… and the identity filing chip offer only the row's own
list; a drop on the other list offers Copy and Cancel. An old leave record
in a database names a parent no replay knows, so it is skipped as a missing
parent and the node stands where it was before the move.

* A dragged Copy names a Work only for a Work's own area

execute-copy sent the open Work's id with every copy, and the copy route
answered 400 for a kb:// or user:// destination given a Work. It now sends
workId and rootThreadId only when the area is Work-scoped.

* Screenshots for the copy at a project's edge PR

* The AI's copy across lists is one receipt that takes the folders it made

A copy into a folder that doesn't exist yet makes the folder, and Undo left it
behind. Copy's result now names the folders its insert made, and the AI's copy
records one create receipt for the call with every copied root and those
folders, as the in-list move does. An undone create answers the path it was
asked by, not its name in Trash.

* Raise the protocol to 2: an open tab from before the move between lists reloads

The cross-list move route an old tab sends is gone, and the copy result's
folders field is required: a tab below protocol 2 reloads.

* Move… with a selection in both lists offers Copy; the AI's copy reads its path as a move does

A selection spanning the project's files and Your files is offered Copy N
items to… instead of Move…, which moved only the first list's rows. Each row's
menu grants its list, and the selection group says when it crosses lists.

copyAcross decides into-or-at with movesInto, the rule runTreeCommand uses:
a folder copied to a trailing-slash path that names no folder lands at that
path, renamed, instead of inside a new folder. reversal.md no longer names
the across_lists receipt.

* Screenshots for the mixed selection's Copy

* tools.md: a copy across lists reads path as a move does; revert of its handle takes the copy only

* Locale catalogs for the selection's Copy

* A move's chat row names and opens where the node landed

The row read its destination and door from the path the model asked for, so a
copy beside a namesake read 'Your files/Probe folder' while it landed as
'Probe folder (2)'. It now takes the answer's path, as undo and redo rows do;
a document moved into a folder opens itself, not the folder, and a folder
gets no door: it opens as no document.

* Answer old moves with Copy and name folder copies on turn cards

* ci: update GitHub Actions to current majors (#1617)

* ci: update GitHub Actions to current majors

* TMP: staging steps copy

* Remove temporary staging steps copy

* Remove PR screenshots for #1598 (linked at their commits)

* fix(editor): keep selected cells across peer edits and Undo (#1618)

* fix(editor): preserve cell selections across peer updates and Undo

* docs(editor): explain cell coverage and remaining range mismatch

* docs(editor): keep the remaining selection task link current

* docs(editor): record mapped cell selection after Redo

* applyFiles: one way to create, merge and delete an Agent level's files, with Undo of a Save on it (#1614)

* refactor: share atomic tree insertion with package file application

Prepare and bind new package files before the caller's transaction, then recheck and insert them through Copy's tree path. Return per-file outcomes and clash counts, and merge or delete under the level list and sorted document locks.

Undo of a Save uses the prepared operation with creation and deletion disabled, keeping its existing transaction and collab mutation path. Check all destination roots before creating parent folders so a stale multi-folder plan leaves nothing behind. Preserve binary or prose replacements rather than mistaking a missing journal for an unchanged empty source file.

* Settle obstructed Agent file paths without losing other writes

Classify folders, blocked ancestors, prose and binaries before choosing a
source-text operation, both during preparation and under the list lock.
Preserve each obstruction and report landed-elsewhere with its actual path;
callers record that path for later updates. Deletion skips obstructions.

Keep Copy's allocation policy separate while sharing plan identities,
binding and insertion. Take the list lock through treeLists.lock and align
the in-memory changed-deletion result with PostgreSQL.

Verified folder, ancestor, prose, binary and between-phase arrivals against
PostgreSQL, plus actual-path updates, disabled creation and rollback on an
infrastructure failure. The temporary probe fails on the pre-fix adapter.

* TreeListStore.lock's comment says it also takes seam Works' locks, inside a transaction

* PR screenshots for #1614 (browser runs p17898, p17928)

* Remove PR screenshots for #1614 (linked at their commits)

* Undo and Un-Apply match plain Yjs (#1615)

* Undo and Un-Apply restore the original beside the writer's text, as plain Yjs does

Delete the stranded rule (strandedByRemoval) and Un-Apply's word rule
(changesLaterWord, keepLaterWords).

* Update the Undo-after-replacement case to the plain Yjs result

* Add browser run screenshots

* Drop the Un-Apply text-stayed notice; state the contract and doc examples as they are

* Add final-head Un-Apply browser evidence

* Remove PR screenshots for #1615 (linked at their commits)

* AI find edit writes only the words it changed (#1607)

* feat(agent-edit): a find edit writes only the words it changed

A find's match window is word-diffed on its own, so the writer's edit to a
word the model kept survives, even where that leaves a fragment.

* docs: browser proof screenshots for find-edit-changed-words

* fix(agent-edit): keep marks across a split run; describe a part in reading order

An insert that cut a run copied its tail with no attributes for plain text, which Yjs reads as
'inherit the marks before it', so bold, links and breaks spread onto the plain tail. Each tail
segment now carries its full mark state. A part's before/after text on the card, in the model's
edit list and in draft states is read from document positions (first to last changed unit, with
the kept text between), not joined by clock. lowerText has one diff loop: no window is one
whole-block window. Stale 'written whole' text corrected.

* docs: browser proof screenshots for the split-run marks and card text

* Show only the changed words in the before → after excerpt

describeRanges rebuilt the unchanged text between changes from the clock frontier, which cannot say what was visible: words the writer deleted before the write came back, and text between two inline atoms went missing. The excerpt now reads only the changed units in document order, joined by … within a block. The walker is the one rescued text already used, moved into agent-edit so the server and the app share it.

* docs: capture find edit browser verification

* Remove PR screenshots for #1607 (linked at their commits)

* Move to Node 26.13.1 and pnpm 12.21.0 (#1621)

* Move to Node 26.13.1 and pnpm 12.21.0

Node and pnpm pins in .tool-versions, CI and docs; @types/node ^26.
pnpm 11+ settings: allowBuilds lists every build script,
verifyDepsBeforeRun moves from .npmrc (no longer read) to the workspace
file, and first-party @meridian-flow packages skip the release age gate.
Node 25+ defines a global localStorage that shadows jsdom's, so app tests
run with --no-experimental-webstorage; lib0 0.2.120 stops the server
logging that warning at import. @types/node 26 makes process.disconnect
optional.

* docs: capture Node 26 browser probe

* Read localStorage only in a window, so Node 26 SSR prints no ExperimentalWarning

* docs: capture offline recovery and collaboration probe

* Undo and Redo of names and places read the moves and renames in force (#1597)

* Undo and Redo of names and places read the moves and renames in force

Two copies of a project tree that are out of step could lose a name or a
place on merge. A rename an Undo never saw was overwritten by the old name,
a second concurrent Undo of one rename brought back the name before the
unseen rename, a Redo of a move dropped its numbered name, and a stale Undo
of a move sent the node to where its author last saw it. All of them happen
on main.

The cause: the replay showed the name and place an opposite record
carries, which is what its author's copy showed, and undoChange decided a
Redo or second Undo by comparing carried values (reverses, movedAfter,
lastSetBy). The merged list said neither.

Now, for moves and renames only:
- A node's name and place are what the last move or rename in force says,
  or its create. A move or rename is in force unless the last record about
  it is an Undo (a Redo is an Undo of an Undo).
- An Undo or Redo sets nothing itself. withTurned says what turning one
  change out or back in does to a fact; the replay applies it and
  undoChange calls it on the projection's lists, so there is one copy.
- undoChange answers already when the change is where the press wants it,
  and changed_since when a later change holds every fact, or the place
  would be inside the node; it writes nothing then.
- undoFacts says which fact of a move that also set a name stays, so
  undoApply's left no longer guesses it from the record's type.
- projection.inForce replaces recordsInForce; creates, deletes and
  restores keep main's rule there, since Trash counts deletes its own way.
- admission stamps dropped by where the replay leaves the node for an
  Undo or Redo of a move (Change.parent), not by its carried parent.
- The review's folder row reads the Work's tree against live for the name
  it was, and for where an Undo or Redo of a move puts the folder.

Deleted: Setter.before, arrivedBefore, setFact, reverses, movedAfter,
lastSetBy, both Redo branches of undoChange with Redo's name recalculation
and its refusal to Redo a type change, recordsInForce, and the replay's
isAncestor (wouldLoop is the one cycle check).

The casebook gains the cases two copies out of step produce; 13 of them
fail on main, and the Un-Apply fact case fails on the design's prototype.

* Test budget: the casebook's cases for two copies out of step

The casebook grows from 71 to 98 cases and admission from 11 to 12: the
Undo and Redo cases of names and places, kept to prove the rule.

* Undo by the changes in force: the sidebar's comment, and the PR's browser screenshots

* Replay: a node's name arrival moves only when its name list changes

A plain move recomputed when the node came to show its name, calling
shownName down the name list on every move. Keep it on the node
(namedAt) and recompute it when the name list changes. Warm replay of
2,000 nodes and 20,000 moves and renames: 90-95 ms before, 55-79 ms
after; main 35-64 ms.

* Undo: one in-force rule for every record; readers ask what an Undo turned

A record is in force unless a later record in force undoes it (standingOf), for
moves and renames as for creates, deletes and restores. The parity rule ("the
last word"), Change.depth, head and Holder.at are gone. The replay applies the
rule over one change's chain as each Undo arrives and turns that node's facts
there, so an Undo of an Undo that did nothing when it landed no longer brings
the change back (Un-Apply of an applied stale Undo, property seed 250381).
undoChange writes its record even when another Undo keeps the change out, so
Un-Apply takes its copy out.

Readers of an Undo ask the replay's Change, not the record's type: admission
reads Change.parent for an Undo of any type, Apply's factsIn gives an Undo its
base change's facts, and the review row reads the trees once an Undo follows
the last move. projection.setters goes (the server reads history); the dead
exports go from index.ts.

The review's forward-only replay (apply only the moves in force) was tried and
dropped: an Undo then rewrites past placement and can turn another node's move
into a cycle, which undoChange cannot foresee.

Casebook: Redo-only cases deleted (chat Redo is dropped), Undo halves kept, one
case for the Un-Apply regression. The property test allows for a skipped
drafted record that starts to land (seeds 400309, 500623) and for a record with
two live copies in force (seed 250790; one Undo takes both).

* Undo by the one in-force rule: the PR's browser screenshots on the final code

* Remove PR screenshots for #1597 (linked at their commits)

* The home folder belongs to the account, not the first project (#1599)

* The home folder's source belongs to the account, not the first project

`~` (scheme `user`) was a source of the project marked `is_personal`, so every
home document named that project: deleting it took the writer's home with it,
and a chat elsewhere reached `~` only through it.

Now a source, a document and a link ahead are owned by a project or by an
account, exactly one. The account's `user` source is made by a trigger on
`users` insert. Every reader takes a source's owner from `source-owner.ts`
(one SQL fragment, `TreeList` as the owner) instead of joining a project
through the source, and "belongs to this request" is one rule,
`ownedByRequest`: its project, or its account's home folder.

- File policy: `FileFacts.owner`, an `account` node, owner ref and grant.
- The request's project comes from the principal (`Principal.agent.projectId`,
  the thread's), not the file's: a model's draft of a `~` document opens its
  branch in the chat's project; link scopes read in it.
- A home document read by id reads its links in the viewer thread's project;
  Agent files pass theirs.
- `is_personal` and `default_bootstrap_ready` are deleted: an account with no
  live project gets one at sign-in; `./mf --project default` is the oldest.
- `document_block_rooms.project_id` and `document_blocks.project_id` are
  deleted (only the copy read them); `purgeUnviewed` locks the owner's list.

* ./mf finds the home folder's source, which the account now owns

A source's owner gained `account`; `doc` commands matched only `project`,
so `./mf doc rm user://...` answered "No source". The auth gate's comment
named the personal project.

* An image in the home folder is spelled for the model; dead project-scoped recovery deleted

The link scope's assetAddress matched an image row on the snapshot's project, which an
account-owned row never has, so a home image read back as ![p]() everywhere. nameable,
assetAddress and assetFor now share ownedByRequest: a project row in the reader's project,
an account row of the reader's account.

Deleted, all without production callers: countIncomingLinks (its "Updated N links" line
went with #1457), the derivation service's project-scoped flush, drainAheads, the scope
on stale(), and the registry recovery's project scope. An unused test getter goes too.

* Old tabs reload: protocol 2, since a tab on 1 can't find the account-owned home source

On protocol 1 the app's sourceFor knows no {kind: "account"} owner, so an open tab
would lose the user:// source. The server keeps no path for the old shape, so the
minimum moves with the current version.

* A home document's links read as its account; the read route reads in its project

A link scope keyed by a home document with no viewer thread resolved neither a project
nor a viewer, so ownedByRequest matched nothing and doc read of a ~ note spelled every
image blank. Such a scope now reads as the document's account and joins an enclosing
snapshot that account opened; GET .../documents/:id/read opens one in its project, so a
~ note spells the project's images there too.

* Store home note images in the home folder

* Wait for chat creation before reading its draft

* fix(server): built server crashed at import with __exportAll is not a function (#1627)

* fix(server): built server crashed at import with "__exportAll is not a function"

Repro: cd apps/server; pnpm exec nitro build; node .output/server/index.mjs
(or pnpm smoke:prod-boot).

Cause: Rolldown put its helpers in _chunks/limits.mjs, which since #1455 also
held html-markdown.ts. That imports the unified libs, which import the helpers
back, so Node ran hast-util-from-html before the helpers existed. html-markdown
now has its own chunk. The prod-boot smoke now also builds and starts the API
server and probes /healthz, which the job never did.

* fix(server): end the chunk-cycle class with Rolldown 1.2.19; make the prod-boot smoke mean it boots

Rolldown 1.2.16 hosts its runtime only in a chunk every consumer's entries
load, so no lib chunk can cycle with the helpers. The per-file chunk group is
deleted. The smoke now waits for startup.complete against a throwaway
Postgres database, fails on a startup failure or child exit, and checks the
server build for chunk import cycles. The prod-boot job starts a Postgres.

* A Save's Undo stays offered after you edit again, and every surface agrees on it (#1624)

* fix(agents): keep Save Undo available after later edits

* PR screenshots: a Save's Undo stays after edits

* fix(agents): derive Save Undo offers from package status

Record Undo provenance and Save origin on the existing Save rows. Read the
latest undoable Save from the files query so AI Saves, reloads and other
tabs share the same offer. Publish the existing files hint after commits,
including Undo that changes no document text.

Keep only pending requests and retryable failures in client Undo state.
Distinguish repeated Undo from a superseded Save, and retain saved removal
offers without treating those removals as unsaved changes.

* fix(agents): an undone Save's receipt still says Undone after a later Save

The package status listed only the latest row's undone Save, so after Undo and a
later Save the old receipt fell through to "A later Save is in use". The status
now carries every Save of the package an Undo took back.

* PR screenshots: an undone AI Save stays Undone after a later Save

* Remove PR screenshots for #1624 (linked at their commits)

* Keep offline typing in a document purged before its room reconnects (#1616)

* Keep offline typing in a document purged before its room reconnects

Each local copy now holds a mark of what the server is known to have: a
Yjs state vector in its `custom` store, taken from the server's SyncStep1
at every handshake, from each update the server sends, and from the
document whenever the server has acknowledged everything. The mark only
grows, per client, in one transaction; a handshake whose vector does not
cover it replaces it, because the room then lacks items it counts (a room
restored from a checkpoint or reseeded).

Deleting a copy now claims what it holds beyond its mark first, and keeps
the copy when the claim can't be stored, so a later start claims it again.
A closing or removing retirement reads its copy the same way instead of
the session's unacknowledged updates. A copy with no mark is deleted as
before; an empty copy starts with an empty mark.

Before this, a reload while offline left the typing only in the copy, and
a purge before the room reconnected deleted it unread.

* Read a server update's items by their end clocks; describe the mark beside the code

Y.encodeStateVectorFromUpdate counts only runs that start at clock 0, so
an incremental update from the server read as nothing and a collaborator's
words stayed beyond the mark.

* PR screenshots for the server mark

* Note what a shipped restore owes the mark

* Mark only what the server has shown; offer a copy with no mark whole

An update the server sends is not evidence: Yjs can integrate a local peer's
pending items in the same provider-origin transaction, and Hocuspocus never
uploads such an update, so the mark counted the peer's unsent words as the
server's. The mark now takes the server's SyncStep1 and, at a full
acknowledgement, the document's state vector; a server frame that releases
pending local items is sent up as a local change, so a full acknowledgement
still means the server holds the whole document.

A copy with no mark counts as marking nothing, so its whole content is
offered instead of deleted unread.

* Send what the server lacks after each server frame; end a metadata-closed draft's transport

The pendingStructs snapshot depended on how transactions nest: a schema repair
opened inside the provider's transaction overwrote it, so a local peer's
pending words released by a server frame were never uploaded, the repair's
acknowledgement marked them saved, and a purge deleted them unoffered.

The transport now keeps, per socket, the state vector its frames show the
server holds: the server's SyncStep1, every update it sends, every one written
to the socket (server-has.ts). After each server frame, once the provider and
every transaction it opened are done, an editable room sends what the
document holds beyond it. The full-acknowledgement mark is that vector, not
the document's, so the mark only counts what crossed the wire.

A draft closed by metadata now ends its transport as the socket's close does,
so nothing more is sent from it; the status guard that kept such a room closed
against later socket news is gone with the news.

* Claim nothing before SyncStep1, grow only contiguous runs in server-has

A server Update before this socket's SyncStep1 left the vector holding
only that update, so the after-frame check uploaded almost the whole
document (12 KB in p17987's early-broadcast probe; a draft room queued
one per early frame). lacking now returns null until SyncStep1 arrives.

A payload can carry structs past a gap that the server holds only as
pending; parseUpdateMeta's end clocks over-claimed them. holds() now
extends a client's clock only by runs continuing from it, and received
frames are noted before the provider applies them so the SyncStep2
reply continues from the server's clocks.

Header and CONTEXT.md say the check covers inserts; deletions go with
the next handshake.

* Browser pass on the final code: screenshots (p18004)

* Remove PR screenshots for #1616 (linked at their commits)

* Upgrade prosemirror-view, hocuspocus, tanstack router, micromark; re-port their patches (#1622)

* Upgrade prosemirror-view, hocuspocus, tanstack router, micromark; re-port or drop their patches

prosemirror-view 1.41.9 -> 1.42.9 (selectionForDOM re-ported; two Firefox reads added), prosemirror-model/transform to current,
@hocuspocus/* 4.3.0 -> 4.8.0 (awareness ownership re-ported), @tanstack/history 1.162.3 -> 1.162.5 and the router packages (traversal patch re-ported),
micromark 4.0.2 -> 4.0.3 (line-suffix half of the patch dropped: upstream uses an edit map; text-merge half kept).
decode-named-character-reference 1.3.0 is latest and its patch is still needed.

* Regenerate routeTree.gen.ts with the upgraded router generator

* Add PR screenshot: editor after the upgrade

* Drop validate from paragraph align/level and table align

prosemirror-model 1.25.12 runs attribute validate inside NodeType.create. The
y-tiptap binding deletes a Yjs element it cannot build, and the server's
readRepairedRoot writes that delete into the room, so a paragraph with level
"2", level 7 or align "left" vanished. No document-schema attribute has a
validate now; the codec and paste parsers still check what Flow writes. The
editor's heading renderer treats an unknown level as a paragraph.

* Dedupe prosemirror-transform and prosemirror-model in the lockfile

* Add browser probe screenshots for dependency upgrades

* Add block and draft review probe screenshots

* Use landed tree addresses and preserve import arrival order

* Move Flow to @meridian-flow/runtime 0.2.0 (#1628)

* Keep media out of assistant messages for runtime 0.2.0

The runtime's Message is now a union by role. The context builder builds
assistant parts from their own block mapper (text, reasoning, tool use) and
user parts from another (text, media), instead of one mapper that could put
media into an assistant message. Tests that placed a tool_result inside an
assistant message now use a tool message.

* Move Flow to @meridian-flow/runtime 0.2.0

* Resolve lockfile for runtime 0.2.0 on pnpm 12

* Add runtime 0.2 browser probe screenshots

* Correct the blockToUserPart comment

* Only an Agent with mode: primary starts a chat; a new Agent starts as primary (#1633)

* fix(agents): only an Agent with mode: primary starts a chat

An Agent with no mode was offered in the picker, so an imported package whose
helpers leave mode out would fill it with subagents. Mars lists such an Agent as a
subagent; Flow now does the same, in the picker, Send, and the Agents tab's pickable.

* PR screenshot: the picker without a mode-less Agent

* fix(agents): a new Agent starts as mode: primary; one rule for who starts a chat

A new Agent from the Agents tab had no mode, so under the primary rule it never
reached the picker. Its template now says mode: primary. Fork and handoff use the
catalog's isPrimary, so user-invocable: false is refused there too. save_agents
tells the model what mode means, and two fixtures declare their primaries.

* test(agents-through-mars): probe Agents are primary unless a fixture says otherwise

* Remove PR screenshots for #1633 (linked at their commits)

* Move several to a source's top again; Agent level files only merge

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Names repeat: a create opens what it made; twins show their ~id (#1649)

* Open the node a create made, not the plain twin of its typed name

A new file named like an existing one landed as a twin (Kael~xxxx), but the
sidebar opened it by the typed name's path, which reaches the plain twin, so
the writer typed into the wrong document.

TreeActions.create now returns the path the node landed at, read from the
replay after the write. The sidebar's New file and the Agents/skills create
wait for the new row by id; the created-folder focus matches by id; New
document and a link's Create open at the landed path.

* Show a twin's ~id faintly after its name in the sidebar and the composer chip

Two documents named Kael in one folder read the same in the tree and in a
chat's reference chip. A later twin now shows its path segment's suffix after
the name in the muted colour (EntryName), on its sidebar row and on the
composer chip, which reads the suffix from its address. Rows truncate the name
and keep the suffix; the chip wraps as prose does. Tabs are unchanged.

* Record: a create opens by id or landed path; twins show their suffix

* PR screenshots: create with a taken name; twin suffix

* Read folder walks at folder level; show every twin row's suffix

A link's Create walked its folders with findPath, whose last segment is a
leaf, so a document `Kael` answered before the folder `Kael~f051` and every
click made another twin folder. TreeView.findFolder reads every segment at
folder level, as childAtSegment's folder level and the server's nodesAt do;
makeFolders (find the deepest, make the rest) serves the link's Create and
the Agents/skills create, and the menu trail, identity commit and the tree
panel's reveal and root use findFolder.

TreeActions.pathOf reads where a node is now from the replay. create returns
it, or none instead of a guessed /<name>, and the identity commit takes the
moved or renamed document's path from it rather than joining the typed name.
buildTreeView uses the package's pathOf under its entry cache.

Every list of tree entries shows a twin's ~id: the @ menu, file
suggestions, the drill-in menus and their back rows, the side picker
(tabs, recents, search, explorer), the tree's search results and Recently
opened. Rows built from the replay carry suffix; where only an address is
at hand, twinSuffix reads it. A truncating row's accessible name is the
joined segment ("Kael~2db3"), as the chip, tab and row menu say it.

* Names repeat: links through a twin folder resolve (#1664)

* Names repeat: server link resolution walks the tree's folders

* Names repeat: link scope answers documentFor from the tree's walk

* Names repeat: the editor's link index resolves addresses through the project trees

* Names repeat: the in-memory link catalog walks folders as the tree does

* Delete the live-documents read of context sources, which links no longer use

* Add screenshots for the twin-folder link PR

* Names repeat: link scope reads the tree's walk in batches and for every live address

* Names repeat: screenshots for the PR; the old provenance route's deletion note names protocol 5

* Names repeat: three docs and a comment stop describing free-name numbering

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant