@loro-dev/roost 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,12 +12,12 @@ The `Inbox` module adds atomic raw receipt/cursor storage, without authenticatin
12
12
  or applying those bytes.
13
13
 
14
14
  ```sh
15
- npm install @loro-dev/roost@0.2.0
15
+ npm install @loro-dev/roost@0.3.1
16
16
  ```
17
17
 
18
- This source targets the coordinated Rust/TypeScript/Native 0.2.0 release;
18
+ This source targets the coordinated Rust/TypeScript/Native 0.3.1 release;
19
19
  the registry determines npm availability. Native SQLite storage in
20
- this release accepts fresh/v4 containers only. Preserve older databases with
20
+ this release accepts fresh/v10 containers only. Preserve older databases with
21
21
  their compatible runtime; there is no automatic migration or deletion.
22
22
 
23
23
  For source development and browser tests:
@@ -359,6 +359,45 @@ page cannot combine membership from before a batch with content from after it.
359
359
  Already published incomplete Turns expose their applied prefix. Unsealed content
360
360
  remains provisional; the projected `sealed` flag is not a verification level.
361
361
 
362
+ Node active-branch pages privately reuse sealed bodies after matching authoritative
363
+ headers, including sequence, seal and parent edges. The per-history cache keeps at
364
+ most 64 bodies and 8 MiB of source JSON UTF-16 bytes (an input budget, not exact
365
+ heap usage). Oversized and unsealed bodies are not retained. Returned bodies are
366
+ independent copies. Page membership, cursors, availability and event fences are
367
+ still checked on every read; first hydration performs the usual JSON validation.
368
+
369
+ After Node binding/publication indexes settle at one event cursor, repeated
370
+ catch-up calls still read the journal directly. They reuse the settled checkpoint
371
+ only if that fresh read finds no event. New events or failed reads retain normal
372
+ indexing, dependency wakeup and retry behavior. A publication page that adds no
373
+ work may commit its cursor and ready marker together, with the old ready/revision
374
+ in the same CAS; pending or newly discovered work keeps the full drain path.
375
+ `observedEventCursor()` returns that private settled cursor after the same fresh
376
+ event check; it needs no second persisted-cursor read. A failed event query still
377
+ rejects, and a new history handle must establish its own checkpoint.
378
+
379
+ With a matching `derived-indexes-v1` Native host, `NodeLodyHistory.commitContentBatch`
380
+ can commit edits, application receipts and private SDK checkpoints in one durable
381
+ transaction. It only plans a fast checkpoint for content-subtree edits of at most
382
+ 16 already published message Turns, with settled binding/publication checkpoints,
383
+ matching Create/binding/member records and no waiting target dependency. Other
384
+ writes keep ordinary catch-up. Callers may provide `derivedIndexPuts` for their own
385
+ cursor-fenced projections; the SDK owns all private table names and formats.
386
+ Native independently checks the entire actual event interval before installing
387
+ any derived put. `derivedIndexesApplied` is false when that proof fails; complete
388
+ catch-up still processes all events. SDK reuse is installed only after a confirmed
389
+ matching reply, and never after a lost reply. This is an additive local API;
390
+ subprocess/browser hosts retain their existing paths and advertise no new support.
391
+
392
+ After confirmed application, Node retains one private checkpoint plan (at most
393
+ 16 IDs and 256 KiB). Each subsequent eligible write still compares every original
394
+ proof row inside Native; only the committed progress values advance. An index-only
395
+ CAS change refreshes the plan once after Native proves the attempt committed no
396
+ write. Unknown outcomes clear reuse and never trigger an automatic retry.
397
+ Fresh plans are detached once from host index results and command IDs before
398
+ reuse. Every host call receives its own copied proof; subsequent private plans
399
+ can share the retained SDK evidence without copying it again after each commit.
400
+
362
401
  Use the shared cache for a live list on either adapter:
363
402
 
364
403
  ```ts
@@ -438,7 +477,7 @@ both browser and Node adapters: it atomically creates and seals a non-message
438
477
  reconstruct the rollback, including an empty restored view, from that native
439
478
  record. `branch_state` is readable as an internal history identity but is excluded
440
479
  from `HistoryWriteIdentity`, `AcceptHistory` and batch commands; generic authoring
441
- rejects it at runtime as well. Use `restoreActiveBranch` as the only write path. It
480
+ rejects it at runtime as well. Use the dedicated branch APIs for this reserved identity. It
442
481
  does not edit sealed Turns or change the Rust state machine/wire.
443
482
 
444
483
  Active-branch pages return `startPosition`, `totalCount`, `hasMoreOlder`, and an
@@ -454,6 +493,17 @@ the host fetches or repairs that boundary instead of declaring shorter history.
454
493
  Generic published-message reverse
455
494
  pages include superseded messages and cannot substitute for active-branch pages.
456
495
 
496
+ For a confirmed Native linear creation, `advanceActiveBranchDirectory(page, result,
497
+ limit)` can return a directory transition with `retainedFrom`, one new `message`,
498
+ and its committed `through` cursor. Retain `page.messages.slice(retainedFrom)`
499
+ and append `message`; use the returned state/count/older cursor. This transforms
500
+ membership only, retaining the consumer's own checkpoint-bound old bodies. It is
501
+ not a fresh read or proof that no later event exists. The owner must still observe
502
+ and process subsequent events, including state/permission corrections. Results
503
+ and page state are matched against private host proofs; copied results, forks,
504
+ partial pages and uncertain intervals return undefined and require ordinary page
505
+ reads. Older cursors retain late successor segments when the window advances.
506
+
457
507
  An append preserves older cursors while adding any intervening late successors.
458
508
  A fork that removes the cursor's ancestry rejects it as `stale`; refresh the
459
509
  loaded window and obtain a new cursor. The last reverse page can contain fewer
@@ -498,3 +548,24 @@ Recorded example: 2026-09-17 results and measurement limits.
498
548
  Host payload crypto may return a Promise (`AsyncPayloadCrypto`), including
499
549
  WebCrypto. Encryption and decryption are awaited outside storage transactions;
500
550
  failed transforms never fall back to plaintext. See RSE1.
551
+
552
+ ### Selected membership and sparse branch changes (0.3.1)
553
+
554
+ `readActiveBranchMembers(viewId, options)` returns logical positions, member references and ancestry
555
+ cursors. `lookupMember(identity)` returns header information;
556
+ `readActiveBranchMessages(viewId, businessIds)` hydrates selected active bodies.
557
+
558
+ `NodeLodyHistory.replaceActiveBranchMembers` accepts an ordered list of logical segment references
559
+ and optional new messages. Each logical row has one primary. Existing physical Turns are reused;
560
+ a fresh `primary:<id>` physical segment can represent a reinserted business ID's logical `primary`.
561
+ A signed `branch_state` with v2 metadata holds the membership root, which subsequent appends reference.
562
+ New messages are sealed by default; `sealed: false` creates an unsealed replacement.
563
+
564
+ The manifest uses bounded private array appends. Its Create binds the intent digest, retries compare
565
+ the stored prefix, and the completed root is sealed. A small activation claim commits branch state
566
+ and operation/application receipts in one exclusive Native transaction. Operation-ID retries return
567
+ the original receipt. Incomplete membership is reported until referenced records arrive.
568
+
569
+ The SDK reads existing v1 branches in place and v2 membership views. V1 SDKs read v1 views. This API
570
+ requires matching `field-reads-v1` and `exclusive-batch-v1` Native capabilities; consumers update their
571
+ version pins after the paired SDK/Native release.
@@ -53,6 +53,19 @@ export declare const PUBLICATION_DONE = "lody_history_publication_done_v1";
53
53
  export declare const PUBLICATION_CURSOR: IndexKey;
54
54
  export declare const publicationHex: (v: Uint8Array) => string;
55
55
  export declare const publicationBytes: (v: string) => Uint8Array<ArrayBuffer>;
56
+ export declare function publicationFence(port: PublicationPort, cursor: bigint): Promise<IndexEntry[]>;
57
+ /** Plan only the cursor-only effect of editing already published message bodies.
58
+ * The Native owner must independently certify the complete event interval before
59
+ * installing these puts. Every inspected row is compared in that transaction. */
60
+ export declare function planContentCheckpoint(port: PublicationPort, before: bigint, through: bigint, ids: Uint8Array[], owner: Uint8Array): Promise<{
61
+ expected: IndexEntry[];
62
+ puts: (IndexKey & {
63
+ value: Uint8Array;
64
+ })[];
65
+ } | undefined>;
66
+ /** Reuse only after this exact plan was confirmed applied. All original proof
67
+ * rows remain transaction preconditions; only its own four progress rows move. */
68
+ export declare function continueContentCheckpoint(applied: NonNullable<Awaited<ReturnType<typeof planContentCheckpoint>>>, through: bigint): NonNullable<Awaited<ReturnType<typeof planContentCheckpoint>>>;
56
69
  export declare function checkPublicationRefs(refs: PublicationRef[]): PublicationRef[];
57
70
  export declare function publicationValue(refs: PublicationRef[]): JsonValue;
58
71
  export declare function catchUpPublications(port: PublicationPort): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  /** Private, rebuildable publication projection. All durable work uses the same
2
2
  * database as the core; no signer or outgoing operation is needed here. */
3
3
  import { blake3 } from '@noble/hashes/blake3.js';
4
- import { encodeUtf8, decodeUtf8, encodeJson } from './json.js';
4
+ import { encodeUtf8, decodeUtf8, encodeJson, decodeJson } from './json.js';
5
5
  import { StoreError } from './store.js';
6
6
  export const PUBLICATION_OBJECTS = 'lody_history_publication_objects_v1';
7
7
  export const PUBLICATION_DONE = 'lody_history_publication_done_v1';
@@ -21,10 +21,85 @@ const same = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
21
21
  const pack = (v) => encodeUtf8(JSON.stringify(v));
22
22
  const unpack = (v) => JSON.parse(decodeUtf8(v));
23
23
  const counter = (raw) => raw === null ? 0n : BigInt(decodeUtf8(raw));
24
+ export async function publicationFence(port, cursor) {
25
+ const keys = [BINDING_CURSOR, PUBLICATION_CURSOR, REVISION, READY];
26
+ const values = await port.readIndex(keys);
27
+ if (counter(values[0]) !== cursor || counter(values[1]) !== cursor || counter(values[2]) !== counter(values[3]))
28
+ throw new StoreError('stale', 'publication is not settled');
29
+ return keys.map((key, i) => ({ ...key, value: values[i] }));
30
+ }
24
31
  const row = (table, key, value) => ({ table, key, value });
25
32
  const identityKey = (ref) => JSON.stringify(['message', ref.businessId, ref.segmentId]);
26
33
  const targetKey = (key) => blake3(encodeUtf8(key));
27
34
  const waitKey = (key, id) => { const out = new Uint8Array(48); out.set(targetKey(key)); out.set(id, 32); return out; };
35
+ /** Plan only the cursor-only effect of editing already published message bodies.
36
+ * The Native owner must independently certify the complete event interval before
37
+ * installing these puts. Every inspected row is compared in that transaction. */
38
+ export async function planContentCheckpoint(port, before, through, ids, owner) {
39
+ if (!ids.length || ids.length > 16 || through <= before)
40
+ return;
41
+ const keys = [REVISION, PUBLICATION_CURSOR, BINDING_CURSOR, READY,
42
+ ...ids.map(key => ({ table: PUBLICATION_OBJECTS, key })),
43
+ ...ids.map(key => ({ table: 'lody_history_receipt_ids_v1', key }))];
44
+ const values = await port.readIndex(keys);
45
+ const [revision, cursor, bindingCursor, ready] = values;
46
+ if (!revision || !ready || !same(revision, ready) || counter(cursor) !== before || counter(bindingCursor) !== before)
47
+ return;
48
+ const expected = keys.map((key, i) => ({ ...key, value: values[i] }));
49
+ const objects = [];
50
+ for (let i = 0; i < ids.length; i++) {
51
+ const raw = values[4 + i];
52
+ if (!raw || values[4 + ids.length + i] !== null)
53
+ return;
54
+ const object = unpack(raw);
55
+ if (!object || object.kind !== 'message' || object.owner !== publicationHex(owner))
56
+ return;
57
+ const identity = JSON.parse(object.key);
58
+ if (!Array.isArray(identity) || identity.length !== 3 || identity[0] !== 'message' || typeof identity[1] !== 'string' || typeof identity[2] !== 'string')
59
+ return;
60
+ objects.push(object);
61
+ }
62
+ const checks = objects.flatMap((object, i) => [
63
+ { table: BINDINGS, key: encodeUtf8(object.key) },
64
+ { table: TARGETS, key: targetKey(object.key) },
65
+ { table: IDS, key: encodeUtf8(object.key) },
66
+ { table: MEMBERS, key: ids[i] },
67
+ ]);
68
+ const checked = await port.readIndex(checks);
69
+ for (let i = 0; i < ids.length; i++) {
70
+ const [binding, watched, publishedId, member] = checked.slice(4 * i, 4 * i + 4);
71
+ if (!binding || watched !== null || !publishedId || !same(publishedId, ids[i]) || !member)
72
+ return;
73
+ const b = unpack(binding);
74
+ const object = objects[i];
75
+ if (b.version !== 1 || b.conflict || !Array.isArray(b.turnId) || !Array.isArray(b.owner) || !Array.isArray(b.digest) ||
76
+ !same(Uint8Array.from(b.turnId), ids[i]) || publicationHex(Uint8Array.from(b.owner)) !== object.owner || publicationHex(Uint8Array.from(b.digest)) !== object.digest)
77
+ return;
78
+ const m = decodeJson(member), identity = JSON.parse(object.key);
79
+ if (!(m instanceof Map) || m.get('version') !== '2' || m.get('businessId') !== identity[1] || m.get('segmentId') !== identity[2])
80
+ return;
81
+ }
82
+ expected.push(...checks.map((key, i) => ({ ...key, value: checked[i] })));
83
+ const next = encodeUtf8((counter(revision) + 1n).toString()), end = encodeUtf8(through.toString());
84
+ return { expected, puts: [
85
+ { ...BINDING_CURSOR, value: end }, { ...PUBLICATION_CURSOR, value: end },
86
+ { ...REVISION, value: next }, { ...READY, value: next },
87
+ ] };
88
+ }
89
+ /** Reuse only after this exact plan was confirmed applied. All original proof
90
+ * rows remain transaction preconditions; only its own four progress rows move. */
91
+ export function continueContentCheckpoint(applied, through) {
92
+ const at = (a, b) => a.table === b.table && same(a.key, b.key);
93
+ const expected = applied.expected.map(entry => ({
94
+ ...entry, value: applied.puts.find(put => at(put, entry))?.value ?? entry.value,
95
+ }));
96
+ const next = encodeUtf8((counter(applied.puts.find(put => at(put, REVISION)).value) + 1n).toString());
97
+ const end = encodeUtf8(through.toString());
98
+ return { expected, puts: [
99
+ { ...BINDING_CURSOR, value: end }, { ...PUBLICATION_CURSOR, value: end },
100
+ { ...REVISION, value: next }, { ...READY, value: next },
101
+ ] };
102
+ }
28
103
  export function checkPublicationRefs(refs) {
29
104
  if (!Array.isArray(refs) || refs.length > 64 || pack(refs).length > 256 * 1024)
30
105
  throw new StoreError('invalid', 'publication reference limit');
@@ -49,7 +124,7 @@ export function publicationValue(refs) {
49
124
  /** A revision serializes ingestion, dependency wakeup and complete-batch
50
125
  * publication. Comparing the binding checkpoint rejects stale identity reads. */
51
126
  async function snapshot(port) {
52
- const keys = [REVISION, PUBLICATION_CURSOR, BINDING_CURSOR];
127
+ const keys = [REVISION, PUBLICATION_CURSOR, BINDING_CURSOR, READY];
53
128
  const values = await port.readIndex(keys);
54
129
  return { cursor: counter(values[1]), expected: keys.map((key, i) => ({ ...key, value: values[i] })),
55
130
  revision: row(REVISION.table, REVISION.key, encodeUtf8((counter(values[0]) + 1n).toString())) };
@@ -63,7 +138,7 @@ async function ingest(port) {
63
138
  const at = await snapshot(port), bound = counter(at.expected[2].value);
64
139
  const events = (await port.events(at.cursor, PAGE)).filter(record => record.cursor <= bound);
65
140
  if (!events.length)
66
- return false;
141
+ return 'idle';
67
142
  const touched = new Map();
68
143
  for (const { event } of events)
69
144
  if (event.kind === 'changed' && event.update) {
@@ -91,9 +166,15 @@ async function ingest(port) {
91
166
  for (let i = 0; i < messages.length; i++)
92
167
  if (watched[i] !== null)
93
168
  changes.push(row(WAKE, messages[i].hash, encodeUtf8(messages[i].object.key)));
94
- changes.push(row(PUBLICATION_CURSOR.table, PUBLICATION_CURSOR.key, encodeUtf8(events.at(-1).cursor.toString())));
95
- await commit(port, at, changes);
96
- return true;
169
+ const through = events.at(-1).cursor;
170
+ const priorRevision = at.expected[0].value, priorReady = at.expected[3].value;
171
+ const settled = changes.length === 0 && through === bound && priorRevision !== null &&
172
+ priorReady !== null && same(priorRevision, priorReady);
173
+ changes.push(row(PUBLICATION_CURSOR.table, PUBLICATION_CURSOR.key, encodeUtf8(through.toString())));
174
+ if (settled)
175
+ changes.push(row(READY.table, READY.key, at.revision.value));
176
+ const committed = await commit(port, at, changes);
177
+ return committed && settled ? 'settled' : 'more';
97
178
  }
98
179
  async function wake(port) {
99
180
  const at = await snapshot(port), [target] = await port.scanIndex(WAKE, EMPTY, 1);
@@ -210,7 +291,13 @@ export async function catchUpPublications(port) {
210
291
  if (ready && revision && same(ready, revision) && counter(cursor) === counter(bindingCursor))
211
292
  return;
212
293
  for (;;) {
213
- while (await ingest(port)) { /* durable bounded event pages */ }
294
+ for (;;) {
295
+ const ingested = await ingest(port);
296
+ if (ingested === 'settled')
297
+ return;
298
+ if (ingested === 'idle')
299
+ break;
300
+ }
214
301
  while (await wake(port)) { /* bounded fanout, consumed dependencies are deleted */ }
215
302
  let worked = false;
216
303
  while (await apply(port))
@@ -58,6 +58,7 @@ export type HistoryBatchOptions = {
58
58
  export type HistoryProjectedMessage = {
59
59
  businessId: string;
60
60
  segmentId: string;
61
+ physicalSegmentId?: string;
61
62
  turnId: Uint8Array;
62
63
  content: JsonValue;
63
64
  nextSeq: bigint;
@@ -93,6 +94,7 @@ export type BranchViewState = {
93
94
  head: HistoryIdentity | null;
94
95
  operationId: string | null;
95
96
  logicalCount?: bigint;
97
+ membershipBase?: HistoryIdentity;
96
98
  conflict?: boolean;
97
99
  };
98
100
  export type BranchMutationResult = {
@@ -136,6 +138,10 @@ export type ActiveBranchPageRead = {
136
138
  cursor: ActiveBranchPageCursor | null;
137
139
  complete: boolean;
138
140
  };
141
+ /** Read active member references and headers. */
142
+ export type ActiveBranchMembersRead = Omit<ActiveBranchPageRead, 'messages'> & {
143
+ members: ActiveBranchSegmentRef[];
144
+ };
139
145
  export type ActiveBranchPageCursor = {
140
146
  viewId: string;
141
147
  turnId: Uint8Array;
@@ -148,6 +154,35 @@ export type ActiveBranchPageCursor = {
148
154
  turnId: Uint8Array;
149
155
  }[];
150
156
  };
157
+ /** Directory transition only. Retained bodies remain the caller's snapshots. */
158
+ export type ActiveBranchPageAdvance = Omit<ActiveBranchPageRead, 'messages'> & {
159
+ retainedFrom: number;
160
+ message: HistoryProjectedMessage;
161
+ through: bigint;
162
+ };
163
+ export type ActiveBranchMemberIdentity = {
164
+ identity: HistoryIdentity;
165
+ segmentId: string;
166
+ };
167
+ export type ReplaceActiveBranchMembersInput = {
168
+ viewId: string;
169
+ expectedRevision: bigint;
170
+ expectedHead: HistoryIdentity | null;
171
+ operationId: string;
172
+ members: ActiveBranchMemberIdentity[];
173
+ messages?: {
174
+ identity: HistoryWriteIdentity;
175
+ content: JsonValue;
176
+ parents?: ParentRef[];
177
+ attachments?: AcceptHistory['attachments'];
178
+ sealed?: boolean;
179
+ }[];
180
+ supersedes?: HistoryIdentity[];
181
+ receipts?: Extract<HistoryBatchCommand, {
182
+ type: 'accept';
183
+ }>[];
184
+ expectedEventCursor: bigint;
185
+ };
151
186
  export type RestoreActiveBranchInput = {
152
187
  viewId: string;
153
188
  expectedRevision: bigint;
@@ -275,22 +310,67 @@ export type NodeHistoryRead = {
275
310
  turnId: Uint8Array;
276
311
  prefix: NodeHistoryTurn | null;
277
312
  };
313
+ type NodeHistoryPath = ({
314
+ key: string;
315
+ } | {
316
+ index: bigint;
317
+ })[];
278
318
  export type NodeHistoryOp = {
279
319
  kind: 'appendText';
280
- path: ({
281
- key: string;
282
- } | {
283
- index: bigint;
284
- })[];
320
+ path: NodeHistoryPath;
285
321
  text: string;
286
322
  } | {
287
323
  kind: 'set';
288
- path: ({
289
- key: string;
290
- } | {
291
- index: bigint;
292
- })[];
324
+ path: NodeHistoryPath;
293
325
  contentJson: string;
326
+ } | {
327
+ kind: 'remove';
328
+ path: NodeHistoryPath;
329
+ } | {
330
+ kind: 'spliceText';
331
+ path: NodeHistoryPath;
332
+ index: bigint;
333
+ delete: bigint;
334
+ text: string;
335
+ } | {
336
+ kind: 'spliceArray';
337
+ path: NodeHistoryPath;
338
+ index: bigint;
339
+ delete: bigint;
340
+ valuesJson: string;
341
+ };
342
+ export type NodeHistoryIndexPut = NodeIndexKey & {
343
+ value: Uint8Array;
344
+ onceKey?: Uint8Array;
345
+ emitEvent?: boolean;
346
+ };
347
+ export type NodeHistoryBatchOptions = {
348
+ requireLocalInterval?: boolean;
349
+ indexPuts?: NodeHistoryIndexPut[];
350
+ expectedEventCursor?: bigint;
351
+ expectedIndexes?: NodeIndexEntry[];
352
+ receiptChecks?: NodeIndexEntry[];
353
+ commitMetadata?: {
354
+ scope: Uint8Array;
355
+ value: Uint8Array;
356
+ };
357
+ derivedIndexes?: {
358
+ through: bigint;
359
+ indexPuts: (NodeIndexKey & {
360
+ value: Uint8Array;
361
+ })[];
362
+ };
363
+ };
364
+ export type NodeHistoryBatchResult = {
365
+ updates: {
366
+ turnId: Uint8Array;
367
+ seq: bigint;
368
+ }[];
369
+ before?: bigint;
370
+ through?: bigint;
371
+ metadataAttached?: boolean;
372
+ derivedIndexesApplied?: boolean;
373
+ replayed?: boolean[];
294
374
  };
295
375
  export interface LodyNodeHost {
296
376
  eventsAfter(after: bigint, limit: bigint): Promise<{
@@ -305,6 +385,21 @@ export interface LodyNodeHost {
305
385
  key?: Uint8Array;
306
386
  };
307
387
  }[]>;
388
+ readonly fieldReads?: boolean;
389
+ readonly exclusiveBatches?: boolean;
390
+ readCreateFields?(id: Uint8Array, selectors: {
391
+ path: NodeHistoryPath;
392
+ }[], omitDigestKeys: string[]): Promise<{
393
+ fields: ({
394
+ state: 'missing';
395
+ } | {
396
+ state: 'ready';
397
+ contentJson: string;
398
+ })[];
399
+ owner: Uint8Array;
400
+ digest: Uint8Array;
401
+ filteredDigest: Uint8Array;
402
+ }>;
308
403
  exportUpdates(id: Uint8Array, from: bigint, limit: bigint): Promise<Uint8Array>;
309
404
  createOnce(key: Uint8Array, parents: ParentRef[], contentJson: string, options?: {
310
405
  expectedEventCursor?: bigint;
@@ -372,16 +467,7 @@ export interface LodyNodeHost {
372
467
  kind: 'sealOnce';
373
468
  key: Uint8Array;
374
469
  expectedNextSeq: bigint;
375
- })[], options?: {
376
- indexPuts?: {
377
- table: string;
378
- key: Uint8Array;
379
- value: Uint8Array;
380
- onceKey?: Uint8Array;
381
- emitEvent?: boolean;
382
- }[];
383
- expectedEventCursor?: bigint;
384
- }): Promise<unknown>;
470
+ })[], options?: NodeHistoryBatchOptions): Promise<NodeHistoryBatchResult>;
385
471
  scanIndex(table: string, start: Uint8Array, limit: bigint): Promise<{
386
472
  key: Uint8Array;
387
473
  value: Uint8Array;
@@ -412,6 +498,16 @@ export declare class NodeLodyHistory {
412
498
  * a stale page together with every derived change. */
413
499
  indexPage(limit?: number): Promise<boolean>;
414
500
  catchUpIndex(): Promise<void>;
501
+ /** Requires a host supporting derived-indexes-v1. The SDK, never the consumer,
502
+ * owns private checkpoint formats. General/unfinished/watched writes keep the
503
+ * ordinary catch-up path. Application derived puts share the same proof. */
504
+ publicationFence(cursor: bigint): Promise<NodeIndexEntry[]>;
505
+ commitContentBatch(writes: Parameters<LodyNodeHost['writeBatch']>[0], options?: Omit<NodeHistoryBatchOptions, 'derivedIndexes'> & {
506
+ derivedIndexPuts?: (NodeIndexKey & {
507
+ value: Uint8Array;
508
+ })[];
509
+ unclaimedIdentities?: HistoryIdentity[];
510
+ }): Promise<NodeHistoryBatchResult>;
415
511
  invalidMessages(limit?: number): Promise<HistoryDiagnostic[]>;
416
512
  lookup(input: HistoryIdentity): Promise<NodeHistoryRead | undefined>;
417
513
  acceptJson(input: {
@@ -444,6 +540,21 @@ export declare class NodeLodyHistory {
444
540
  latest?: boolean;
445
541
  limit?: number;
446
542
  }): Promise<ActiveBranchPageRead>;
543
+ readActiveBranchMembers(viewId: string, input?: {
544
+ before?: ActiveBranchPageCursor;
545
+ from?: number;
546
+ latest?: boolean;
547
+ limit?: number;
548
+ }): Promise<ActiveBranchMembersRead>;
549
+ /** Resolve an identity to its Turn header. */
550
+ lookupMember(identity: HistoryIdentity): Promise<{
551
+ turnId: Uint8Array;
552
+ nextSeq: bigint;
553
+ sealed: boolean;
554
+ } | undefined>;
555
+ replaceActiveBranchMembers(input: ReplaceActiveBranchMembersInput): Promise<RestoreActiveBranchResult>;
556
+ readActiveBranchMessages(viewId: string, businessIds: readonly string[]): Promise<HistoryProjectedMessage[]>;
557
+ advanceActiveBranchDirectory(page: ActiveBranchPageRead, result: BranchMutationResult, limit?: number): ActiveBranchPageAdvance | undefined;
447
558
  respondPermission(input: {
448
559
  requestId: string;
449
560
  assistantBusinessId: string;
@@ -484,6 +595,12 @@ export declare class NodeLodyHistory {
484
595
  }>;
485
596
  }
486
597
  type HistoryHost = LodyHistory | NodeLodyHistory;
598
+ type ActiveBranchSegmentRef = {
599
+ businessId: string;
600
+ segmentId: string;
601
+ turnId: Uint8Array;
602
+ physicalSegmentId?: string;
603
+ };
487
604
  export type HistoryMessageViewUpdate = {
488
605
  /** Treat rows and their nested content as read-only. Unchanged rows retain identity. */
489
606
  messages: readonly HistoryProjectedMessage[];