Skip to content

The agent that grows with you

docs(sessions): the bounded legacy backfill and branch copies keeping message_uid

kshitijk4poor9d680cb95cd4
diff --git a/website/docs/developer-guide/context-engine-plugin.md b/website/docs/developer-guide/context-engine-plugin.md
index ec16fa13fb4..6f429606ed2 100644
--- a/website/docs/developer-guide/context-engine-plugin.md
+++ b/website/docs/developer-guide/context-engine-plugin.md
@@ -151,11 +151,15 @@ What the host guarantees:
input list, `on_turn_complete()` clones, `post_llm_call`'s
`conversation_history`, `on_session_end()` messages, and every restored
history (CLI, TUI, ACP, gateway, compression's durable-snapshot adoption). It
- is restored unconditionally, unlike `_row_id`.
+ is restored unconditionally, unlike `_row_id`. The one exception is a row
+ written before the column existed: on a large store the upgrade mints those
+ over the next few opens, so a legacy row can briefly arrive without one.
+ Treat a missing uid as "no identity yet", never as an error.
- **Kept across every host copy of the same logical message:** in-place
compaction generations and their concurrent-tail clones, rotation-child
handoff copies and foreign-tail clones, `replace_messages` re-issues,
- rewind, export/import.
+ rewind, export/import, and `/branch` / Desktop branch copies (the child
+ session's copied rows keep the parent's uids).
- **Kept across content rewrites of the same row:** the persist override, the
sanitizer's row-addressed rewrite, the interrupted-stream fill. Treat
`(message_uid, content)` as a *version* of the message; never fail closed on
diff --git a/website/docs/developer-guide/session-storage.md b/website/docs/developer-guide/session-storage.md
index 261c6035af1..26622383c27 100644
--- a/website/docs/developer-guide/session-storage.md
+++ b/website/docs/developer-guide/session-storage.md
@@ -292,7 +292,7 @@ The `schema_version` table stores a single integer. Simple column additions are
| 23 | FTS storage redesign — external-content FTS tables replacing the v11 inline-mode copies (opt-in transition for existing DBs) |
| 29 | Cron sessions leave the trigram (substring/CJK) index; `messages_fts_trigram_src` view + triggers filter on `sessions.source`, one-time rebuild purges historical rows |
| 30 | Delegate-child (subagent) sessions leave the trigram index too — `source='subagent'` or the `$._delegate_from` marker (`FTS_TRIGRAM_SESSION_SQL`). Rows stay in `messages` and the standard `messages_fts` word index, so `session_search` still finds them; only the ~2.6× trigram shadow tables shrink. Same one-time rebuild as v29 |
-| 31 | `messages.message_uid`, `absorbed_message_uids`, `tool_call_uids`, `tool_call_uid` (declarative column adds), a one-time backfill of a fresh `message_uid` onto every row that predates the column (gated by the `message_uid_backfill` meta marker), and the `messages_message_uid_insert` trigger that mints one for any row inserted without it (an older build writing into the store), so a v31 store hands every row to consumers with an id (tool-call uids are minted when a row is next written; results are paired on restore) |
+| 31 | `messages.message_uid`, `absorbed_message_uids`, `tool_call_uids`, `tool_call_uid` (declarative column adds), a backfill of a fresh `message_uid` onto every row that predates the column (2,000-id chunks, each its own short write; one open spends about a second past its first chunk and resumes from the `message_uid_backfill_id` meta cursor on the next open, until the `message_uid_backfill` marker ends it, so a large store never holds the write lock for the whole table), and the `messages_message_uid_insert` trigger that mints one for any row inserted without it (an older build writing into the store), so a v31 store hands every row to consumers with an id (tool-call uids are minted when a row is next written; results are paired on restore) |
Versions not listed above were declarative column additions handled by `_reconcile_columns()` (version bump only, no data migration).