@loro-dev/roost 0.1.0

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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +397 -0
  3. package/dist/codec.d.ts +66 -0
  4. package/dist/codec.js +275 -0
  5. package/dist/crypto.d.ts +21 -0
  6. package/dist/crypto.js +103 -0
  7. package/dist/durable-framing.d.ts +44 -0
  8. package/dist/durable-framing.js +207 -0
  9. package/dist/framing.d.ts +28 -0
  10. package/dist/framing.js +144 -0
  11. package/dist/history-publication.d.ts +58 -0
  12. package/dist/history-publication.js +234 -0
  13. package/dist/identity.d.ts +14 -0
  14. package/dist/identity.js +62 -0
  15. package/dist/inbox.d.ts +69 -0
  16. package/dist/inbox.js +262 -0
  17. package/dist/index.d.ts +9 -0
  18. package/dist/index.js +6 -0
  19. package/dist/indexeddb.d.ts +38 -0
  20. package/dist/indexeddb.js +299 -0
  21. package/dist/json.d.ts +23 -0
  22. package/dist/json.js +221 -0
  23. package/dist/lody-history.d.ts +397 -0
  24. package/dist/lody-history.js +1559 -0
  25. package/dist/projection.d.ts +53 -0
  26. package/dist/projection.js +543 -0
  27. package/dist/replay.d.ts +63 -0
  28. package/dist/replay.js +201 -0
  29. package/dist/sender.d.ts +26 -0
  30. package/dist/sender.js +67 -0
  31. package/dist/store.d.ts +384 -0
  32. package/dist/store.js +1437 -0
  33. package/dist/sync/coverage.d.ts +276 -0
  34. package/dist/sync/coverage.js +1084 -0
  35. package/dist/sync/crypto.d.ts +64 -0
  36. package/dist/sync/crypto.js +155 -0
  37. package/dist/sync/execute.d.ts +142 -0
  38. package/dist/sync/execute.js +321 -0
  39. package/dist/sync/history.d.ts +214 -0
  40. package/dist/sync/history.js +786 -0
  41. package/dist/sync/index.d.ts +17 -0
  42. package/dist/sync/index.js +9 -0
  43. package/dist/sync/link.d.ts +192 -0
  44. package/dist/sync/link.js +663 -0
  45. package/dist/sync/mod.d.ts +24 -0
  46. package/dist/sync/mod.js +15 -0
  47. package/dist/sync/policy.d.ts +62 -0
  48. package/dist/sync/policy.js +128 -0
  49. package/dist/sync/registry.d.ts +129 -0
  50. package/dist/sync/registry.js +333 -0
  51. package/dist/sync/transport.d.ts +91 -0
  52. package/dist/sync/transport.js +162 -0
  53. package/dist/sync/work.d.ts +351 -0
  54. package/dist/sync/work.js +1344 -0
  55. package/package.json +47 -0
@@ -0,0 +1,24 @@
1
+ /** Remote synchronization support: durable remote registration (RS1-01),
2
+ * per-remote operation coverage with closed assertions (RS2-01), durable
3
+ * send tasks and discovery progress (RS2-02), and dependency-first backfill
4
+ * execution (RS2-03) — the IndexedDB mirrors of src/sync/. No network I/O;
5
+ * routing, registration and coverage state never feed the signed node hash. */
6
+ export { ARCHIVE_KEY_TAG, archivePrefix, generationIn, generationKeyFragment, generationSourceKeyTag, GenerationSource, RECORD_KEY_TAG, RECORD_VERSION, recordKey, RegistryError, RemoteRegistry, REMOTE_SPACE, } from './registry.js';
7
+ export type { EndpointConfig, Generation, RemoteId, RemoteRecord } from './registry.js';
8
+ export { CHILD_KEY_TAG, CLOSED_KEY_TAG, CONFLICT_KEY_TAG, COVERAGE_KEY_TAG, COVERAGE_SPACE, coverageKey, CoverageError, CoverageStore, closedKey, conflictKey, ISLAND_KEY_TAG, MAX_PRESENT_SEQS, RECORD_VERSION as COVERAGE_RECORD_VERSION, SEQ_KEY_TAG, SUMMARY_RECORD_VERSION, } from './coverage.js';
9
+ export type { ClosedRecord, CoverageScope, MarkResult, ParentRef, PresentState, SealClaim } from './coverage.js';
10
+ export { MAX_TASK_BYTES, MAX_TASK_DEPS, MAX_WAITERS_PER_DEP, OPEN_TURN_KEY_TAG, PREFIX_KEY_TAG, STATUS_INDEX_KEY_TAG, taskKey, TASK_KEY_TAG, WAIT_KEY_TAG, waitKey, WORK_SPACE, WorkError, WorkStore, } from './work.js';
11
+ export type { AcquiredTask, AttemptToken, ConfirmResult, DepRef, DiscoverOutcome, DiscoverResult, DiscoveryState, OpenTurn, OpRef, ResumePlan, TaskInfo, TaskRef, TaskStatus, WorkScope, } from './work.js';
12
+ export { ExecuteError, Executor, TransportError } from './execute.js';
13
+ export type { DiscoverReport, FlushReport, ResumeReport, SendTransport } from './execute.js';
14
+ export { SYNC_CONTENT_TYPE, StreamsTransport } from './transport.js';
15
+ export type { HeadInfo, ReadPage, ReadTransport } from './transport.js';
16
+ export { CryptoError, ENVELOPE_MAGIC, openConcatenated, openConcatenatedPrefix, openFirstEnvelope, openEnvelope, sealEnvelope, } from './crypto.js';
17
+ export type { PayloadCrypto, AsyncPayloadCrypto } from './crypto.js';
18
+ export { DEFAULT_MIRROR_POLICY, POLICY_KEY_TAG, POLICY_SPACE, PolicyError, PolicyStore, RECORD_VERSION as POLICY_RECORD_VERSION, } from './policy.js';
19
+ export type { MirrorDirection, MirrorPolicy } from './policy.js';
20
+ export { Link, LinkError, linkLimitsForSync } from './link.js';
21
+ export type { BridgeReport, DownloadReport, LinkLimits, StopToken } from './link.js';
22
+ export { HistoryError, HistoryReader } from './history.js';
23
+ export type { BackwardByteSource, BackwardPage, HistoryReport, PrefixScan } from './history.js';
24
+ export { sealEnvelopeAsync, openEnvelopeAsync, openFirstEnvelopeAsync, openConcatenatedAsync, openConcatenatedPrefixAsync } from './crypto.js';
@@ -0,0 +1,15 @@
1
+ /** Remote synchronization support: durable remote registration (RS1-01),
2
+ * per-remote operation coverage with closed assertions (RS2-01), durable
3
+ * send tasks and discovery progress (RS2-02), and dependency-first backfill
4
+ * execution (RS2-03) — the IndexedDB mirrors of src/sync/. No network I/O;
5
+ * routing, registration and coverage state never feed the signed node hash. */
6
+ export { ARCHIVE_KEY_TAG, archivePrefix, generationIn, generationKeyFragment, generationSourceKeyTag, GenerationSource, RECORD_KEY_TAG, RECORD_VERSION, recordKey, RegistryError, RemoteRegistry, REMOTE_SPACE, } from './registry.js';
7
+ export { CHILD_KEY_TAG, CLOSED_KEY_TAG, CONFLICT_KEY_TAG, COVERAGE_KEY_TAG, COVERAGE_SPACE, coverageKey, CoverageError, CoverageStore, closedKey, conflictKey, ISLAND_KEY_TAG, MAX_PRESENT_SEQS, RECORD_VERSION as COVERAGE_RECORD_VERSION, SEQ_KEY_TAG, SUMMARY_RECORD_VERSION, } from './coverage.js';
8
+ export { MAX_TASK_BYTES, MAX_TASK_DEPS, MAX_WAITERS_PER_DEP, OPEN_TURN_KEY_TAG, PREFIX_KEY_TAG, STATUS_INDEX_KEY_TAG, taskKey, TASK_KEY_TAG, WAIT_KEY_TAG, waitKey, WORK_SPACE, WorkError, WorkStore, } from './work.js';
9
+ export { ExecuteError, Executor, TransportError } from './execute.js';
10
+ export { SYNC_CONTENT_TYPE, StreamsTransport } from './transport.js';
11
+ export { CryptoError, ENVELOPE_MAGIC, openConcatenated, openConcatenatedPrefix, openFirstEnvelope, openEnvelope, sealEnvelope, } from './crypto.js';
12
+ export { DEFAULT_MIRROR_POLICY, POLICY_KEY_TAG, POLICY_SPACE, PolicyError, PolicyStore, RECORD_VERSION as POLICY_RECORD_VERSION, } from './policy.js';
13
+ export { Link, LinkError, linkLimitsForSync } from './link.js';
14
+ export { HistoryError, HistoryReader } from './history.js';
15
+ export { sealEnvelopeAsync, openEnvelopeAsync, openFirstEnvelopeAsync, openConcatenatedAsync, openConcatenatedPrefixAsync } from './crypto.js';
@@ -0,0 +1,62 @@
1
+ import type { IndexedDbStorage } from '../indexeddb.js';
2
+ import type { WorkScope } from './work.js';
3
+ /**
4
+ * Durable mirror policy for remote sync (RS3-02), the IndexedDB mirror of
5
+ * src/sync/policy.rs: which streams mirror to which remotes and in which
6
+ * direction, per (remote, generation, stream).
7
+ *
8
+ * Mirroring is an explicit, persisted user choice (never implied by
9
+ * connectivity): a `both` policy uploads local work and downloads the
10
+ * remote; `upload_only` mirrors out without reading the remote in;
11
+ * `download_only` (a read-only client) reads without ever scheduling an
12
+ * upload. A disabled policy stops both directions without deleting the
13
+ * remote's durable work or coverage. The absent-record default is `both`
14
+ * and enabled, matching the executor's existing behavior for scopes the
15
+ * host simply runs; anything stricter must be written explicitly.
16
+ *
17
+ * Layout (private to this module, not a wire format): space
18
+ * `rsync_policy`, one record per scope at
19
+ * `[0x01] || remote[16] || generation_key_fragment || stream_len[4 BE] ||
20
+ * stream[..]`, value `[0x01] || {"v":1,"direction":"...","enabled":bool}`
21
+ * (JSON, deterministic field order) — byte-identical to the Rust encoding.
22
+ * The scope key embeds the full generation identity, so a rebound
23
+ * generation starts from the default policy again while the old record
24
+ * stays retained, never inherited.
25
+ */
26
+ /** KV space holding all mirror-policy records. */
27
+ export declare const POLICY_SPACE = "rsync_policy";
28
+ /** Current record encoding version. */
29
+ export declare const RECORD_VERSION = 1;
30
+ /** Policy record keys start with this tag. */
31
+ export declare const POLICY_KEY_TAG = 1;
32
+ /** The mirror direction of one (remote, generation, stream). */
33
+ export type MirrorDirection = 'both' | 'upload_only' | 'download_only';
34
+ /** One scope's mirror policy as persisted. */
35
+ export type MirrorPolicy = {
36
+ direction: MirrorDirection;
37
+ enabled: boolean;
38
+ };
39
+ /** The absent-record default: mirror both ways, enabled. A policy that
40
+ * restricts a scope must be written explicitly. */
41
+ export declare const DEFAULT_MIRROR_POLICY: MirrorPolicy;
42
+ /** Errors returned by PolicyStore. */
43
+ export declare class PolicyError extends Error {
44
+ readonly code: 'storage' | 'corrupt' | 'unsupportedVersion' | 'invalid';
45
+ constructor(code: 'storage' | 'corrupt' | 'unsupportedVersion' | 'invalid', message?: string, options?: ErrorOptions);
46
+ }
47
+ /** The mirror-policy store over the device's single storage owner. */
48
+ export declare class PolicyStore {
49
+ readonly storage: IndexedDbStorage;
50
+ constructor(storage: IndexedDbStorage);
51
+ /** The scope's persisted policy, or the absent-record default
52
+ * (`both`, enabled). */
53
+ get(scope: WorkScope): Promise<MirrorPolicy>;
54
+ /** Persist a policy for one scope. Restrictions are always explicit:
55
+ * a write that narrows or widens mirroring lands atomically, and a
56
+ * disabled scope keeps all of its durable work and coverage. */
57
+ set(scope: WorkScope, policy: MirrorPolicy): Promise<void>;
58
+ /** Whether the scope's policy permits uploading local work. */
59
+ allowsUpload(scope: WorkScope): Promise<boolean>;
60
+ /** Whether the scope's policy permits downloading the remote. */
61
+ allowsDownload(scope: WorkScope): Promise<boolean>;
62
+ }
@@ -0,0 +1,128 @@
1
+ import { generationKeyFragment } from './registry.js';
2
+ /**
3
+ * Durable mirror policy for remote sync (RS3-02), the IndexedDB mirror of
4
+ * src/sync/policy.rs: which streams mirror to which remotes and in which
5
+ * direction, per (remote, generation, stream).
6
+ *
7
+ * Mirroring is an explicit, persisted user choice (never implied by
8
+ * connectivity): a `both` policy uploads local work and downloads the
9
+ * remote; `upload_only` mirrors out without reading the remote in;
10
+ * `download_only` (a read-only client) reads without ever scheduling an
11
+ * upload. A disabled policy stops both directions without deleting the
12
+ * remote's durable work or coverage. The absent-record default is `both`
13
+ * and enabled, matching the executor's existing behavior for scopes the
14
+ * host simply runs; anything stricter must be written explicitly.
15
+ *
16
+ * Layout (private to this module, not a wire format): space
17
+ * `rsync_policy`, one record per scope at
18
+ * `[0x01] || remote[16] || generation_key_fragment || stream_len[4 BE] ||
19
+ * stream[..]`, value `[0x01] || {"v":1,"direction":"...","enabled":bool}`
20
+ * (JSON, deterministic field order) — byte-identical to the Rust encoding.
21
+ * The scope key embeds the full generation identity, so a rebound
22
+ * generation starts from the default policy again while the old record
23
+ * stays retained, never inherited.
24
+ */
25
+ /** KV space holding all mirror-policy records. */
26
+ export const POLICY_SPACE = 'rsync_policy';
27
+ /** Current record encoding version. */
28
+ export const RECORD_VERSION = 1;
29
+ /** Policy record keys start with this tag. */
30
+ export const POLICY_KEY_TAG = 0x01;
31
+ /** The absent-record default: mirror both ways, enabled. A policy that
32
+ * restricts a scope must be written explicitly. */
33
+ export const DEFAULT_MIRROR_POLICY = Object.freeze({ direction: 'both', enabled: true });
34
+ /** Errors returned by PolicyStore. */
35
+ export class PolicyError extends Error {
36
+ code;
37
+ constructor(code, message = code, options) {
38
+ super(message, options);
39
+ this.code = code;
40
+ this.name = 'PolicyError';
41
+ }
42
+ }
43
+ const utf8 = new TextEncoder();
44
+ const utf8d = new TextDecoder('utf-8', { fatal: true });
45
+ function policyKey(scope) {
46
+ if (scope.stream.length === 0)
47
+ throw new PolicyError('invalid', 'empty stream');
48
+ const stream = utf8.encode(scope.stream);
49
+ if (stream.length > 0xFFFFFFFF)
50
+ throw new PolicyError('invalid', 'stream name too long');
51
+ const fragment = generationKeyFragment(scope.generation);
52
+ const key = new Uint8Array(1 + 16 + fragment.length + 4 + stream.length);
53
+ const view = new DataView(key.buffer);
54
+ key[0] = POLICY_KEY_TAG;
55
+ key.set(scope.remote, 1);
56
+ key.set(fragment, 17);
57
+ view.setUint32(17 + fragment.length, stream.length, false);
58
+ key.set(stream, 21 + fragment.length);
59
+ return key;
60
+ }
61
+ function encode(policy) {
62
+ // Field order is part of the encoding (byte-identical to the Rust
63
+ // serde struct order): v, direction, enabled.
64
+ const json = `{"v":1,"direction":${JSON.stringify(policy.direction)},"enabled":${policy.enabled}}`;
65
+ const payload = utf8.encode(json);
66
+ const out = new Uint8Array(1 + payload.length);
67
+ out[0] = RECORD_VERSION;
68
+ out.set(payload, 1);
69
+ return out;
70
+ }
71
+ function decode(bytes) {
72
+ if (bytes.length === 0)
73
+ throw new PolicyError('corrupt', 'empty record');
74
+ const version = bytes[0];
75
+ if (version !== RECORD_VERSION)
76
+ throw new PolicyError('unsupportedVersion', `unsupported policy record version: ${version}`);
77
+ let dto;
78
+ try {
79
+ dto = JSON.parse(utf8d.decode(bytes.subarray(1)));
80
+ }
81
+ catch (e) {
82
+ throw new PolicyError('corrupt', `record JSON: ${e instanceof Error ? e.message : e}`);
83
+ }
84
+ const record = dto;
85
+ if (record.v !== RECORD_VERSION)
86
+ throw new PolicyError('unsupportedVersion', `unsupported policy record version: ${record.v}`);
87
+ if (record.direction !== 'both' && record.direction !== 'upload_only' && record.direction !== 'download_only')
88
+ throw new PolicyError('corrupt', 'unknown mirror direction');
89
+ if (typeof record.enabled !== 'boolean')
90
+ throw new PolicyError('corrupt', 'enabled must be a boolean');
91
+ return { direction: record.direction, enabled: record.enabled };
92
+ }
93
+ /** The mirror-policy store over the device's single storage owner. */
94
+ export class PolicyStore {
95
+ storage;
96
+ constructor(storage) {
97
+ this.storage = storage;
98
+ }
99
+ /** The scope's persisted policy, or the absent-record default
100
+ * (`both`, enabled). */
101
+ async get(scope) {
102
+ const key = policyKey(scope);
103
+ const raw = await this.storage.transact(false, function* (tx) {
104
+ return yield* tx.get(POLICY_SPACE, key);
105
+ });
106
+ return raw === undefined ? { ...DEFAULT_MIRROR_POLICY } : decode(raw);
107
+ }
108
+ /** Persist a policy for one scope. Restrictions are always explicit:
109
+ * a write that narrows or widens mirroring lands atomically, and a
110
+ * disabled scope keeps all of its durable work and coverage. */
111
+ async set(scope, policy) {
112
+ const key = policyKey(scope);
113
+ const value = encode(policy);
114
+ await this.storage.transact(true, function* (tx) {
115
+ yield* tx.put(POLICY_SPACE, key, value);
116
+ });
117
+ }
118
+ /** Whether the scope's policy permits uploading local work. */
119
+ async allowsUpload(scope) {
120
+ const policy = await this.get(scope);
121
+ return policy.enabled && (policy.direction === 'both' || policy.direction === 'upload_only');
122
+ }
123
+ /** Whether the scope's policy permits downloading the remote. */
124
+ async allowsDownload(scope) {
125
+ const policy = await this.get(scope);
126
+ return policy.enabled && (policy.direction === 'both' || policy.direction === 'download_only');
127
+ }
128
+ }
@@ -0,0 +1,129 @@
1
+ import { IndexedDbStorage, type KvTransaction, type Step } from '../indexeddb.js';
2
+ /**
3
+ * Durable registration of sync remotes (RS1-01), the IndexedDB mirror of
4
+ * src/sync/registry.rs. Registration state is routing/configuration only:
5
+ * none of it feeds the signed node hash, so renaming, disabling, rebinding or
6
+ * removing a remote never changes Turn bytes, hashes or signatures (RS0-01 §1).
7
+ *
8
+ * Storage layout (private to this module, not a wire format) — byte-for-byte
9
+ * the Rust layout, so one physical database is readable from both ends:
10
+ *
11
+ * | Keys | Range | Value |
12
+ * | --- | --- | --- |
13
+ * | `[0x01] \|\| remote_id[16]` | start `[0x01]`, end `[0x02)` | current RemoteRecord |
14
+ * | `[0x02] \|\| remote_id[16] \|\| seq[8 BE]` | start `[0x02]\|\|id`, end prefix successor | superseded record, append-only |
15
+ *
16
+ * Values are `[version byte] || serde_json` with a fixed DTO field order, so
17
+ * the encoding is deterministic and identical to the Rust serde encoding.
18
+ * The leading version byte is authoritative: a mismatch is reported as
19
+ * `unsupportedVersion` and never silently decoded, including by get/list.
20
+ * Identity keys carry no URL, name or token, so identity survives renames
21
+ * and endpoint moves. Every multi-step mutation runs in one IDB transaction;
22
+ * a semantic rejection aborts it and the previous state stays byte-identical.
23
+ * This module performs no network I/O and never awaits inside a transaction.
24
+ */
25
+ /** KV space holding all remote registry keys (same name as the Rust space). */
26
+ export declare const REMOTE_SPACE = "rsync_remote";
27
+ /** Current record encoding version. */
28
+ export declare const RECORD_VERSION = 1;
29
+ /** Record keys start with this tag: `[RECORD_KEY_TAG][16B remote_id]`. */
30
+ export declare const RECORD_KEY_TAG = 1;
31
+ /** Archive keys start with this tag: `[ARCHIVE_KEY_TAG][16B remote_id][8B seq]`. */
32
+ export declare const ARCHIVE_KEY_TAG = 2;
33
+ /** Where a generation observation came from (RS0-01 §2, D-GEN contract). */
34
+ export type GenerationSource = 'app_marker' | 'server_header' | 'unknown';
35
+ export declare const GenerationSource: Record<'AppMarker' | 'ServerHeader' | 'Unknown', GenerationSource>;
36
+ /** Opaque remote generation. Compared as a whole (bytes + provenance) for CAS. */
37
+ export type Generation = {
38
+ bytes: Uint8Array;
39
+ source: GenerationSource;
40
+ };
41
+ /** Scope-key discriminator used by the coverage/work layouts, byte-identical
42
+ * to Rust `GenerationSource::key_tag`. Deliberately nonzero: a key written
43
+ * before the source entered the scope encoding carries the leading zero of
44
+ * the big-endian stream length at this position, so such legacy keys can
45
+ * never collide with a scoped key and are orphaned instead of silently
46
+ * trusted. */
47
+ export declare function generationSourceKeyTag(source: GenerationSource): number;
48
+ /** The full generation identity inside a coverage/work scope key:
49
+ * `gen_len[1] || gen[..] || source_tag[1]`. Generations with equal bytes but
50
+ * different provenance never share a key, so a provenance change (including
51
+ * to `unknown`) inherits nothing. Byte-identical to Rust
52
+ * `generation_key_fragment`. */
53
+ export declare function generationKeyFragment(generation: Generation): Uint8Array;
54
+ /** Physical routing for one remote: endpoint URL and physical stream name. */
55
+ export type EndpointConfig = {
56
+ url: string;
57
+ stream: string;
58
+ };
59
+ /** The durable registration record of one remote. */
60
+ export type RemoteRecord = {
61
+ id: Uint8Array;
62
+ name: string;
63
+ endpoint: EndpointConfig;
64
+ generation: Generation;
65
+ enabled: boolean;
66
+ };
67
+ /** Stable local identity of a registered remote: exactly 16 bytes. */
68
+ export type RemoteId = Uint8Array;
69
+ /** Errors returned by RemoteRegistry. `code` mirrors the Rust RegistryError variants. */
70
+ export declare class RegistryError extends Error {
71
+ readonly code: 'storage' | 'notFound' | 'generationConflict' | 'unsupportedVersion' | 'corrupt' | 'invalid';
72
+ constructor(code: 'storage' | 'notFound' | 'generationConflict' | 'unsupportedVersion' | 'corrupt' | 'invalid', message?: string, options?: ErrorOptions);
73
+ }
74
+ /** Record key for one remote: `[RECORD_KEY_TAG][16B remote_id]`. */
75
+ export declare function recordKey(id: Uint8Array): Uint8Array;
76
+ /** Scan prefix for one remote's generation archive: `[ARCHIVE_KEY_TAG][16B id]`. */
77
+ export declare function archivePrefix(id: Uint8Array): Uint8Array;
78
+ /** The current generation of one remote, read inside the caller's
79
+ * transaction (the Rust `generation_in`): a confirm that must be bound to
80
+ * the registry's current generation reads it through this in-transaction
81
+ * path, so a rebind committed before the confirm's transaction starts is
82
+ * always observed (G009 — no read/cache window outside the write
83
+ * transaction). Composition point for the work store's confirm. */
84
+ export declare function generationIn(tx: KvTransaction, id: RemoteId): Step<Generation | undefined>;
85
+ /**
86
+ * Registry of sync remotes over a shared IndexedDbStorage owner.
87
+ *
88
+ * Construct with the same IndexedDbStorage the host's Store uses, so registry
89
+ * writes and stream content commit through one fixed owner (one physical
90
+ * database; the space prefix keeps registry keys disjoint from stream keys).
91
+ * The registry never opens its own connection and never touches the network.
92
+ */
93
+ export declare class RemoteRegistry {
94
+ readonly storage: IndexedDbStorage;
95
+ constructor(storage: IndexedDbStorage);
96
+ private load;
97
+ private nextArchiveSeq;
98
+ /** Register a new remote in one write transaction and return its fresh id. */
99
+ register(name: string, endpoint: EndpointConfig, generation: Generation): Promise<RemoteId>;
100
+ /** All registered remotes in key order. A record with an unsupported
101
+ * version fails the whole listing instead of being silently skipped. */
102
+ list(): Promise<RemoteRecord[]>;
103
+ /** Fetch one remote, or undefined when unregistered. */
104
+ get(id: RemoteId): Promise<RemoteRecord | undefined>;
105
+ /** Rename one remote. Only the display name changes: id, endpoint and
106
+ * generation are carried over untouched. */
107
+ rename(id: RemoteId, newName: string): Promise<void>;
108
+ /** Enable or disable one remote. Disabling is persistent and deletes no
109
+ * shared stream content, pending work or coverage. */
110
+ setEnabled(id: RemoteId, enabled: boolean): Promise<void>;
111
+ /** Rebind the endpoint and generation of one remote, compare-and-swap on
112
+ * the generation: succeeds only when the stored generation equals
113
+ * `expected`. On success the previous record is appended to the
114
+ * generation archive (one write transaction); on conflict the record is
115
+ * unchanged and the current generation is carried on the thrown error
116
+ * for an explicit, deliberate re-bind. */
117
+ rebind(id: RemoteId, expected: Generation, newEndpoint: EndpointConfig, newGeneration: Generation): Promise<void>;
118
+ /** Remove one remote's registration record. Only the registry record is
119
+ * deleted: stream content, Turn hashes and shared coverage stay. The
120
+ * generation archive is retained for later audit. */
121
+ remove(id: RemoteId): Promise<void>;
122
+ /** The current generation of one remote, for ack validation: a success
123
+ * callback bound to a task's generation must be refused when it no longer
124
+ * matches (CASE-02). */
125
+ currentGeneration(id: RemoteId): Promise<Generation | undefined>;
126
+ /** The superseded records of one remote in archive order. Each entry is
127
+ * the complete record as it was before a successful `rebind`. */
128
+ generationArchive(id: RemoteId): Promise<RemoteRecord[]>;
129
+ }