@cleocode/core 2026.10.8 → 2026.10.9
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/dist/build-provenance.json +2 -2
- package/dist/cloud/auto-sync-command-entry.d.ts +13 -0
- package/dist/cloud/auto-sync-command-entry.d.ts.map +1 -0
- package/dist/cloud/auto-sync-command-entry.js +18 -0
- package/dist/cloud/auto-sync-command-entry.js.map +1 -0
- package/dist/cloud/auto-sync-command.d.ts +64 -0
- package/dist/cloud/auto-sync-command.d.ts.map +1 -0
- package/dist/cloud/auto-sync-command.js +109 -0
- package/dist/cloud/auto-sync-command.js.map +1 -0
- package/dist/cloud/auto-sync.d.ts +111 -0
- package/dist/cloud/auto-sync.d.ts.map +1 -0
- package/dist/cloud/auto-sync.js +275 -0
- package/dist/cloud/auto-sync.js.map +1 -0
- package/dist/cloud/nexus-cloud-device-overview.d.ts +52 -0
- package/dist/cloud/nexus-cloud-device-overview.d.ts.map +1 -0
- package/dist/cloud/nexus-cloud-device-overview.js +105 -0
- package/dist/cloud/nexus-cloud-device-overview.js.map +1 -0
- package/dist/cloud/nexus-cloud-journal-activity.d.ts +56 -0
- package/dist/cloud/nexus-cloud-journal-activity.d.ts.map +1 -0
- package/dist/cloud/nexus-cloud-journal-activity.js +98 -0
- package/dist/cloud/nexus-cloud-journal-activity.js.map +1 -0
- package/dist/cloud/nexus-cloud-status.d.ts.map +1 -1
- package/dist/cloud/nexus-cloud-status.js +88 -5
- package/dist/cloud/nexus-cloud-status.js.map +1 -1
- package/dist/cloud/nexus-vault.d.ts +19 -5
- package/dist/cloud/nexus-vault.d.ts.map +1 -1
- package/dist/cloud/nexus-vault.js +376 -71
- package/dist/cloud/nexus-vault.js.map +1 -1
- package/dist/cloud/replica-rebind.d.ts +14 -0
- package/dist/cloud/replica-rebind.d.ts.map +1 -1
- package/dist/cloud/replica-rebind.js +20 -1
- package/dist/cloud/replica-rebind.js.map +1 -1
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -0
- package/dist/config.js.map +1 -1
- package/dist/docs/docs-ops.d.ts +4 -2
- package/dist/docs/docs-ops.d.ts.map +1 -1
- package/dist/docs/docs-ops.js +107 -15
- package/dist/docs/docs-ops.js.map +1 -1
- package/dist/doctor/system-health.d.ts +76 -2
- package/dist/doctor/system-health.d.ts.map +1 -1
- package/dist/doctor/system-health.js +264 -41
- package/dist/doctor/system-health.js.map +1 -1
- package/dist/hooks/project-runner.d.ts +10 -0
- package/dist/hooks/project-runner.d.ts.map +1 -0
- package/dist/hooks/project-runner.js +328 -0
- package/dist/hooks/project-runner.js.map +1 -0
- package/dist/hooks/project-state.d.ts +41 -0
- package/dist/hooks/project-state.d.ts.map +1 -0
- package/dist/hooks/project-state.js +331 -0
- package/dist/hooks/project-state.js.map +1 -0
- package/dist/hooks/release-gate.d.ts +61 -0
- package/dist/hooks/release-gate.d.ts.map +1 -0
- package/dist/hooks/release-gate.js +70 -0
- package/dist/hooks/release-gate.js.map +1 -0
- package/dist/nexus/analyze-orchestrator.d.ts +2 -0
- package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
- package/dist/nexus/analyze-orchestrator.js +1 -0
- package/dist/nexus/analyze-orchestrator.js.map +1 -1
- package/dist/nexus/freshness.d.ts +67 -3
- package/dist/nexus/freshness.d.ts.map +1 -1
- package/dist/nexus/freshness.js +130 -9
- package/dist/nexus/freshness.js.map +1 -1
- package/dist/nexus/refresh-child.d.ts +14 -0
- package/dist/nexus/refresh-child.d.ts.map +1 -0
- package/dist/nexus/refresh-child.js +24 -0
- package/dist/nexus/refresh-child.js.map +1 -0
- package/dist/orchestrate/spawn-ops.d.ts +8 -1
- package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
- package/dist/orchestrate/spawn-ops.js +42 -12
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestration/spawn.d.ts +5 -0
- package/dist/orchestration/spawn.d.ts.map +1 -1
- package/dist/orchestration/spawn.js +4 -1
- package/dist/orchestration/spawn.js.map +1 -1
- package/dist/release/channel.d.ts.map +1 -1
- package/dist/release/channel.js +10 -0
- package/dist/release/channel.js.map +1 -1
- package/dist/release/github-pr.d.ts.map +1 -1
- package/dist/release/github-pr.js +1 -0
- package/dist/release/github-pr.js.map +1 -1
- package/dist/release/plan.d.ts +8 -3
- package/dist/release/plan.d.ts.map +1 -1
- package/dist/release/plan.js +72 -15
- package/dist/release/plan.js.map +1 -1
- package/dist/release/reconcile.d.ts.map +1 -1
- package/dist/release/reconcile.js +6 -15
- package/dist/release/reconcile.js.map +1 -1
- package/dist/sentient/daemon-entry.d.ts +6 -0
- package/dist/sentient/daemon-entry.d.ts.map +1 -1
- package/dist/sentient/daemon-entry.js +12 -0
- package/dist/sentient/daemon-entry.js.map +1 -1
- package/dist/sentient/worktree-dispatch.d.ts +7 -0
- package/dist/sentient/worktree-dispatch.d.ts.map +1 -1
- package/dist/sentient/worktree-dispatch.js +37 -1
- package/dist/sentient/worktree-dispatch.js.map +1 -1
- package/dist/sessions/session-end-snapshot-entry.d.ts +4 -1
- package/dist/sessions/session-end-snapshot-entry.d.ts.map +1 -1
- package/dist/sessions/session-end-snapshot-entry.js +9 -1
- package/dist/sessions/session-end-snapshot-entry.js.map +1 -1
- package/dist/spawn/agent-identity.d.ts.map +1 -1
- package/dist/spawn/agent-identity.js +96 -1
- package/dist/spawn/agent-identity.js.map +1 -1
- package/dist/spawn/branch-lock.d.ts +27 -8
- package/dist/spawn/branch-lock.d.ts.map +1 -1
- package/dist/spawn/branch-lock.js +57 -73
- package/dist/spawn/branch-lock.js.map +1 -1
- package/dist/store/agent-resolver.d.ts +6 -0
- package/dist/store/agent-resolver.d.ts.map +1 -1
- package/dist/store/agent-resolver.js +2 -0
- package/dist/store/agent-resolver.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts +20 -0
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +81 -8
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/bare-family.d.ts.map +1 -1
- package/dist/store/exodus/bare-family.js +4 -1
- package/dist/store/exodus/bare-family.js.map +1 -1
- package/dist/store/exodus/migrate.d.ts.map +1 -1
- package/dist/store/exodus/migrate.js +2 -0
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/on-open.d.ts.map +1 -1
- package/dist/store/exodus/on-open.js +16 -4
- package/dist/store/exodus/on-open.js.map +1 -1
- package/dist/store/exodus/reconcile.d.ts.map +1 -1
- package/dist/store/exodus/reconcile.js +2 -0
- package/dist/store/exodus/reconcile.js.map +1 -1
- package/dist/store/portable-bundle-import.d.ts +17 -0
- package/dist/store/portable-bundle-import.d.ts.map +1 -1
- package/dist/store/portable-bundle-import.js +46 -31
- package/dist/store/portable-bundle-import.js.map +1 -1
- package/dist/store/portable-bundle-scan.d.ts.map +1 -1
- package/dist/store/portable-bundle-scan.js +5 -0
- package/dist/store/portable-bundle-scan.js.map +1 -1
- package/dist/store/row-identity-registry.d.ts +4 -3
- package/dist/store/row-identity-registry.d.ts.map +1 -1
- package/dist/store/row-identity-registry.js +37 -35
- package/dist/store/row-identity-registry.js.map +1 -1
- package/dist/store/row-identity.d.ts.map +1 -1
- package/dist/store/row-identity.js +6 -1
- package/dist/store/row-identity.js.map +1 -1
- package/dist/store/schema/cleo-global/agent-registry.d.ts +16 -0
- package/dist/store/schema/cleo-global/agent-registry.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/agent-registry.js +4 -1
- package/dist/store/schema/cleo-global/agent-registry.js.map +1 -1
- package/dist/store/schema/cleo-project/provenance-orphans.d.ts +126 -1
- package/dist/store/schema/cleo-project/provenance-orphans.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/provenance-orphans.js +41 -1
- package/dist/store/schema/cleo-project/provenance-orphans.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts +40 -0
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +122 -0
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sync/activity.d.ts +64 -0
- package/dist/store/sync/activity.d.ts.map +1 -0
- package/dist/store/sync/activity.js +220 -0
- package/dist/store/sync/activity.js.map +1 -0
- package/dist/store/sync/apply/applier.d.ts.map +1 -1
- package/dist/store/sync/apply/applier.js +58 -2
- package/dist/store/sync/apply/applier.js.map +1 -1
- package/dist/store/sync/apply/write-api.d.ts.map +1 -1
- package/dist/store/sync/apply/write-api.js +45 -3
- package/dist/store/sync/apply/write-api.js.map +1 -1
- package/dist/store/sync/capture.d.ts +6 -4
- package/dist/store/sync/capture.d.ts.map +1 -1
- package/dist/store/sync/capture.js +16 -4
- package/dist/store/sync/capture.js.map +1 -1
- package/dist/store/sync/collision-settle.d.ts +120 -0
- package/dist/store/sync/collision-settle.d.ts.map +1 -1
- package/dist/store/sync/collision-settle.js +342 -5
- package/dist/store/sync/collision-settle.js.map +1 -1
- package/dist/store/sync/flags.d.ts +34 -0
- package/dist/store/sync/flags.d.ts.map +1 -1
- package/dist/store/sync/flags.js +46 -0
- package/dist/store/sync/flags.js.map +1 -1
- package/dist/store/sync/genesis.d.ts +8 -0
- package/dist/store/sync/genesis.d.ts.map +1 -1
- package/dist/store/sync/genesis.js +18 -5
- package/dist/store/sync/genesis.js.map +1 -1
- package/dist/store/sync/push.d.ts +4 -2
- package/dist/store/sync/push.d.ts.map +1 -1
- package/dist/store/sync/push.js +10 -1
- package/dist/store/sync/push.js.map +1 -1
- package/dist/store/sync/rebind.d.ts +20 -0
- package/dist/store/sync/rebind.d.ts.map +1 -1
- package/dist/store/sync/rebind.js +86 -4
- package/dist/store/sync/rebind.js.map +1 -1
- package/dist/store/sync/reconcile-copy.d.ts +152 -0
- package/dist/store/sync/reconcile-copy.d.ts.map +1 -0
- package/dist/store/sync/reconcile-copy.js +428 -0
- package/dist/store/sync/reconcile-copy.js.map +1 -0
- package/dist/store/sync/reconcile.d.ts +80 -0
- package/dist/store/sync/reconcile.d.ts.map +1 -1
- package/dist/store/sync/reconcile.js +97 -5
- package/dist/store/sync/reconcile.js.map +1 -1
- package/dist/store/sync/repair.d.ts +11 -0
- package/dist/store/sync/repair.d.ts.map +1 -1
- package/dist/store/sync/repair.js +14 -3
- package/dist/store/sync/repair.js.map +1 -1
- package/dist/store/sync/replica.d.ts +74 -1
- package/dist/store/sync/replica.d.ts.map +1 -1
- package/dist/store/sync/replica.js +104 -6
- package/dist/store/sync/replica.js.map +1 -1
- package/dist/store/sync/row-meta.d.ts +4 -2
- package/dist/store/sync/row-meta.d.ts.map +1 -1
- package/dist/store/sync/row-meta.js +6 -4
- package/dist/store/sync/row-meta.js.map +1 -1
- package/dist/store/sync/sealer.d.ts +2 -0
- package/dist/store/sync/sealer.d.ts.map +1 -1
- package/dist/store/sync/sealer.js +33 -4
- package/dist/store/sync/sealer.js.map +1 -1
- package/dist/store/sync/structural.d.ts.map +1 -1
- package/dist/store/sync/structural.js +3 -1
- package/dist/store/sync/structural.js.map +1 -1
- package/dist/store/sync/timestamp-canon.d.ts.map +1 -1
- package/dist/store/sync/timestamp-canon.js +2 -0
- package/dist/store/sync/timestamp-canon.js.map +1 -1
- package/dist/store/table-classification.d.ts +29 -0
- package/dist/store/table-classification.d.ts.map +1 -1
- package/dist/store/table-classification.js +85 -19
- package/dist/store/table-classification.js.map +1 -1
- package/dist/store/twin-collapse.d.ts.map +1 -1
- package/dist/store/twin-collapse.js +28 -10
- package/dist/store/twin-collapse.js.map +1 -1
- package/dist/store/vault-manifest.d.ts +5 -0
- package/dist/store/vault-manifest.d.ts.map +1 -1
- package/dist/store/vault-manifest.js +14 -1
- package/dist/store/vault-manifest.js.map +1 -1
- package/dist/tasks/affected-packages.d.ts +15 -5
- package/dist/tasks/affected-packages.d.ts.map +1 -1
- package/dist/tasks/affected-packages.js +20 -8
- package/dist/tasks/affected-packages.js.map +1 -1
- package/dist/tasks/done-record.d.ts +14 -4
- package/dist/tasks/done-record.d.ts.map +1 -1
- package/dist/tasks/done-record.js +21 -9
- package/dist/tasks/done-record.js.map +1 -1
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +45 -4
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/gate-runner.d.ts +5 -4
- package/dist/tasks/gate-runner.d.ts.map +1 -1
- package/dist/tasks/gate-runner.js +18 -11
- package/dist/tasks/gate-runner.js.map +1 -1
- package/dist/tasks/tool-cache.d.ts +27 -1
- package/dist/tasks/tool-cache.d.ts.map +1 -1
- package/dist/tasks/tool-cache.js +110 -6
- package/dist/tasks/tool-cache.js.map +1 -1
- package/dist/tools/fs.d.ts +3 -1
- package/dist/tools/fs.d.ts.map +1 -1
- package/dist/tools/fs.js +35 -2
- package/dist/tools/fs.js.map +1 -1
- package/dist/validation/engine-ops.d.ts +10 -3
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +17 -8
- package/dist/validation/engine-ops.js.map +1 -1
- package/migrations/drizzle-cleo-global/20261010180000_t12915-agent-registry-uids/migration.sql +18 -0
- package/migrations/drizzle-cleo-project/20261010170000_t12896b-brain-task-observations/migration.sql +37 -0
- package/migrations/sync-journal/20261009150000_t13335-capture-pin/migration.sql +13 -0
- package/package.json +18 -13
- package/schemas/config.schema.json +12 -0
- package/schemas/project-context.schema.json +5 -0
- package/templates/CLEO-INJECTION.md +2 -2
- package/templates/CLEO-REFERENCE.md +6 -4
- package/templates/git-hooks/pre-push +29 -1
- package/templates/workflows/release-prepare.yml.tmpl +1 -0
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import { withImmediateTransaction } from './clock-store.js';
|
|
35
35
|
import { reconcileInPlace } from './reconcile.js';
|
|
36
|
-
import { activeReplica, rebindReplicaWith } from './replica.js';
|
|
36
|
+
import { activeReplica, RETIRE_DUE_KEY, rebindReplicaWith, retireDue, } from './replica.js';
|
|
37
37
|
import { queueRetireTxn } from './retire.js';
|
|
38
|
-
import { hasTable } from './schema.js';
|
|
38
|
+
import { GENESIS_CUT_KEY_PREFIX, hasTable } from './schema.js';
|
|
39
39
|
import { FOREIGN_TOUCH_COUNT_KEY, FOREIGN_TOUCH_INCOMPLETE_KEY, UNDO_BUDGET_EXCEEDED_KEY, } from './sequencing.js';
|
|
40
40
|
/**
|
|
41
41
|
* `_sync_meta` key holding the server half of a rebind the store committed
|
|
@@ -142,8 +142,7 @@ export function rebindAtHead(db, o) {
|
|
|
142
142
|
at: nowIso,
|
|
143
143
|
};
|
|
144
144
|
tx.prepare('DELETE FROM _sync_meta WHERE key = ?').run(UNDO_BUDGET_EXCEEDED_KEY);
|
|
145
|
-
tx
|
|
146
|
-
'ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at').run(REBIND_PENDING_KEY, JSON.stringify(pending), nowIso);
|
|
145
|
+
writePendingRebind(tx, pending);
|
|
147
146
|
return { undoDropped, reconcile, pending };
|
|
148
147
|
});
|
|
149
148
|
return {
|
|
@@ -155,6 +154,89 @@ export function rebindAtHead(db, o) {
|
|
|
155
154
|
reconcile: out.result.reconcile,
|
|
156
155
|
};
|
|
157
156
|
}
|
|
157
|
+
/** Record the server half of a committed rebind, in the caller's transaction. */
|
|
158
|
+
function writePendingRebind(db, pending) {
|
|
159
|
+
db.prepare('INSERT INTO _sync_meta (key, value, updated_at) VALUES (?, ?, ?) ' +
|
|
160
|
+
'ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at').run(REBIND_PENDING_KEY, JSON.stringify(pending), pending.at);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The stream a store announces a retirement on: the one it holds a pushed
|
|
164
|
+
* high-water, a genesis cut or a pull position for. A store has one stream
|
|
165
|
+
* (T13303); with several, its genesis cut's stream wins, then the first by
|
|
166
|
+
* name. Null when the store never joined a stream.
|
|
167
|
+
*/
|
|
168
|
+
function retireStream(db, hwm) {
|
|
169
|
+
const cut = db
|
|
170
|
+
.prepare('SELECT key FROM _sync_meta WHERE key >= ? AND key < ? ORDER BY key')
|
|
171
|
+
.all(GENESIS_CUT_KEY_PREFIX, `${GENESIS_CUT_KEY_PREFIX}\uffff`).map((r) => r.key.slice(GENESIS_CUT_KEY_PREFIX.length));
|
|
172
|
+
if (cut.length > 0)
|
|
173
|
+
return cut[0];
|
|
174
|
+
const cursors = hasTable(db, '_sync_cursor')
|
|
175
|
+
? db.prepare('SELECT stream FROM _sync_cursor ORDER BY stream').all().map((r) => r.stream)
|
|
176
|
+
: [];
|
|
177
|
+
const all = [...new Set([...Object.keys(hwm), ...cursors])].sort();
|
|
178
|
+
return all[0] ?? null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Turn the retirement an open-pass rebind owes (a rollback or a
|
|
182
|
+
* cross-filesystem move, {@link RETIRE_DUE_KEY}; T13337) into the signed
|
|
183
|
+
* `retire` transaction and the pending server rebind, in one transaction.
|
|
184
|
+
* `cloud sync` then completes the server half (`completeServerRebind`)
|
|
185
|
+
* before it pushes or pulls, as after a rebind at head.
|
|
186
|
+
*
|
|
187
|
+
* The retire names the highest replicaSeq of the old replica persisted on
|
|
188
|
+
* the stream, by the store or the device registry; a replica that persisted
|
|
189
|
+
* nothing retires with no journal transaction. A store that never joined a
|
|
190
|
+
* stream owes nothing, and the record is dropped. While another rebind's
|
|
191
|
+
* server half is still pending, nothing is done: that one completes first.
|
|
192
|
+
*
|
|
193
|
+
* @param db - The store, outside a transaction.
|
|
194
|
+
* @param opts - Clock override (tests).
|
|
195
|
+
* @returns The pending rebind it recorded, or null.
|
|
196
|
+
*/
|
|
197
|
+
export function settleRetireDue(db, opts = {}) {
|
|
198
|
+
if (retireDue(db) === null || pendingRebind(db) !== null)
|
|
199
|
+
return null;
|
|
200
|
+
return withImmediateTransaction(db, () => {
|
|
201
|
+
const due = retireDue(db);
|
|
202
|
+
if (due === null || pendingRebind(db) !== null)
|
|
203
|
+
return null;
|
|
204
|
+
db.prepare('DELETE FROM _sync_meta WHERE key = ?').run(RETIRE_DUE_KEY);
|
|
205
|
+
// A later rebind superseded this one: the store no longer is `to`.
|
|
206
|
+
if (activeReplica(db, due.scope)?.replicaId !== due.to)
|
|
207
|
+
return null;
|
|
208
|
+
const stream = retireStream(db, due.hwm);
|
|
209
|
+
if (stream === null)
|
|
210
|
+
return null;
|
|
211
|
+
const now = opts.now?.() ?? new Date();
|
|
212
|
+
const segmented = hasTable(db, '_sync_segment')
|
|
213
|
+
? db
|
|
214
|
+
.prepare('SELECT max(replica_seq) AS s FROM _sync_segment WHERE stream = ? AND replica_id = ?')
|
|
215
|
+
.get(stream, due.from).s
|
|
216
|
+
: null;
|
|
217
|
+
const candidates = [due.hwm[stream], segmented === null ? undefined : Number(segmented)].filter((v) => v !== undefined);
|
|
218
|
+
const lastReplicaSeq = candidates.length > 0 ? Math.max(...candidates) : null;
|
|
219
|
+
const retireTxn = lastReplicaSeq === null
|
|
220
|
+
? null
|
|
221
|
+
: queueRetireTxn(db, {
|
|
222
|
+
scope: due.scope,
|
|
223
|
+
stream,
|
|
224
|
+
retire: { replica: due.from, successor: due.to, lastReplicaSeq },
|
|
225
|
+
nowMs: now.getTime(),
|
|
226
|
+
});
|
|
227
|
+
const pending = {
|
|
228
|
+
stream,
|
|
229
|
+
scope: due.scope,
|
|
230
|
+
from: due.from,
|
|
231
|
+
to: due.to,
|
|
232
|
+
lastReplicaSeq,
|
|
233
|
+
retireTxn,
|
|
234
|
+
at: now.toISOString(),
|
|
235
|
+
};
|
|
236
|
+
writePendingRebind(db, pending);
|
|
237
|
+
return pending;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
158
240
|
/**
|
|
159
241
|
* Empty the undo log in the rebind transaction (D5). First every transaction
|
|
160
242
|
* of the old replica the stream has not sequenced is inherited, including
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rebind.js","sourceRoot":"","sources":["../../../src/store/sync/rebind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;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AAE,CAAC,OAAO,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,QAAQ,CAAC,EAAE,EAAE,qBAAqB,CAAC,EAAE,CAAC;QACxC,EAAE,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC,GAAG,EAAE,CAAC;QACpD,EAAE,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAAC,GAAG,CAC1D,4BAA4B,EAC5B,uBAAuB,CACxB,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The copy reconcile (journal spec §1.5 N7, H3; T13335).
|
|
3
|
+
*
|
|
4
|
+
* Every rebind the open pass makes (a copy, a move, a rollback, another
|
|
5
|
+
* device's store) discards the inherited pull cursor, pauses push and records
|
|
6
|
+
* `sync.reconcile_due` (`replica.ts`). The new replica then reconciles its
|
|
7
|
+
* own state against the stream's MERGED state: the latest verified
|
|
8
|
+
* checkpoint restored into a scratch store (`sync: 'off'`) and pulled to head
|
|
9
|
+
* there with the merge engine (`cloud/nexus-vault.ts` builds it). Here, in
|
|
10
|
+
* one apply frame on the store:
|
|
11
|
+
*
|
|
12
|
+
* - **Rule 1** (`reconcile.ts`): a field an inherited capture or an
|
|
13
|
+
* inherited sealed-but-unpushed op changed is re-emitted from the live row
|
|
14
|
+
* at `tick(at_ms)` of that change.
|
|
15
|
+
* - Every other field is compared per (table, uid, column) with the merged
|
|
16
|
+
* state; a differing field is decided by {@link decideReconcileField}:
|
|
17
|
+
* - **rule 2**, the local field HLC is below the merged one (a row with
|
|
18
|
+
* no row meta, as a never-synced store merging in holds, is dated by its
|
|
19
|
+
* genesis HLC, §1.2; a local value it loses is reported in `overwritten`):
|
|
20
|
+
* the merged value is written locally in the apply frame, its intents
|
|
21
|
+
* recorded so the sealer never sends it, and the merged field HLC stored
|
|
22
|
+
* in the row meta. Nothing is emitted;
|
|
23
|
+
* - **rule 3**, the local HLC is at or above the merged one (a value the
|
|
24
|
+
* original replica sealed but the stream never saw): it is emitted in
|
|
25
|
+
* the `rebind` frame with that HLC pinned (op `fh`, or `h` for a delete).
|
|
26
|
+
* - The store takes the merged state's pull position, and the due record is
|
|
27
|
+
* cleared, which lets push resume.
|
|
28
|
+
*
|
|
29
|
+
* Rows: a row only the merged state has is adopted (inserted) unless the
|
|
30
|
+
* store holds a newer tombstone for it (rule 3: a pinned delete); a row the
|
|
31
|
+
* merged state deleted is adopted (deleted) unless the store's row is newer
|
|
32
|
+
* (rule 3: the whole live row re-inserted as an I whose op HLC is above the
|
|
33
|
+
* tombstone, its field HLCs pinned; the merge engine voids a U on a
|
|
34
|
+
* tombstoned row but re-creates the row from a newer I, T13392). A live row the merged state never knew, with
|
|
35
|
+
* no inherited change, is emitted: with its row meta's HLCs pinned when it
|
|
36
|
+
* has meta, else as a plain insert (nothing local is ever deleted that the
|
|
37
|
+
* stream cannot account for).
|
|
38
|
+
*
|
|
39
|
+
* Reference columns are compared by the uid of the row they point at, and an
|
|
40
|
+
* adopted reference is resolved to this store's local key ({@link resolveRef}).
|
|
41
|
+
* A merged row whose reference does not resolve here, or whose insert hits a
|
|
42
|
+
* local constraint, is left out and counted in `unresolved`. In a merge join
|
|
43
|
+
* (T13466) a local constraint refuses the whole reconcile instead
|
|
44
|
+
* ({@link MergeKeyCollisionError}, T13504).
|
|
45
|
+
*
|
|
46
|
+
* @task T13335
|
|
47
|
+
* @module store/sync/reconcile-copy
|
|
48
|
+
*/
|
|
49
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
50
|
+
import type { TableScope } from '@cleocode/contracts';
|
|
51
|
+
import type { LedgerWireValue } from '@cleocode/contracts/ledger';
|
|
52
|
+
import { type StreamCursor } from './pull.js';
|
|
53
|
+
import { type ReconcileReport } from './reconcile.js';
|
|
54
|
+
/** Options for {@link reconcileCopy}. */
|
|
55
|
+
export interface ReconcileCopyOptions {
|
|
56
|
+
readonly scope: TableScope;
|
|
57
|
+
/** The stream the merged state was pulled to the head of. */
|
|
58
|
+
readonly stream: string;
|
|
59
|
+
/** The merged state's pull position at head: the store takes it. */
|
|
60
|
+
readonly mergedCursor: StreamCursor;
|
|
61
|
+
/** Wall clock (ms). @defaultValue Date.now */
|
|
62
|
+
readonly now?: () => number;
|
|
63
|
+
/**
|
|
64
|
+
* The checkpoint as restored, before the pull (T13507). A merge join dates a
|
|
65
|
+
* meta-less local row by its `updated_at`, which cannot show which fields it
|
|
66
|
+
* touched; a stream field whose HLC moved past this baseline is a real write
|
|
67
|
+
* since the cut and wins.
|
|
68
|
+
*/
|
|
69
|
+
readonly baseline?: DatabaseSync;
|
|
70
|
+
}
|
|
71
|
+
/** What {@link reconcileCopy} did. */
|
|
72
|
+
export interface ReconcileCopyReport {
|
|
73
|
+
/** Fields adopted from the merged state (rule 2), and rows inserted and deleted by adoption. */
|
|
74
|
+
readonly adoptedFields: number;
|
|
75
|
+
readonly adoptedInserts: number;
|
|
76
|
+
readonly adoptedDeletes: number;
|
|
77
|
+
/** Rule-3 emits with pinned HLCs. */
|
|
78
|
+
readonly pinned: number;
|
|
79
|
+
/** Merged rows left out: a reference that does not resolve here, or a local constraint. */
|
|
80
|
+
readonly unresolved: number;
|
|
81
|
+
/**
|
|
82
|
+
* Fields of a row this store held with no row meta (a merge join, T13466)
|
|
83
|
+
* whose local value lost to a newer merged one: the local value was
|
|
84
|
+
* replaced. Read the store's safety backup to recover one.
|
|
85
|
+
*/
|
|
86
|
+
readonly overwritten: ReadonlyArray<{
|
|
87
|
+
table: string;
|
|
88
|
+
uid: string;
|
|
89
|
+
column: string;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* The other direction (T13507): fields of such a row whose newer local value
|
|
93
|
+
* replaced the stream's value, so every replica takes the local one.
|
|
94
|
+
*/
|
|
95
|
+
readonly replaced: ReadonlyArray<{
|
|
96
|
+
table: string;
|
|
97
|
+
uid: string;
|
|
98
|
+
column: string;
|
|
99
|
+
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Rows of a never-synced store that a newer stream delete removed (T13508). The store's
|
|
102
|
+
* safety backup holds them.
|
|
103
|
+
*/
|
|
104
|
+
readonly deleted: ReadonlyArray<{
|
|
105
|
+
table: string;
|
|
106
|
+
uid: string;
|
|
107
|
+
}>;
|
|
108
|
+
/** The `rebind` frame (rule 1 and rule 3). */
|
|
109
|
+
readonly frame: ReconcileReport;
|
|
110
|
+
}
|
|
111
|
+
/** A merged row a merge join cannot place: a row this store holds already has its local key (T13504). */
|
|
112
|
+
export interface MergeKeyCollision {
|
|
113
|
+
readonly table: string;
|
|
114
|
+
readonly uid: string;
|
|
115
|
+
/** The merged row's local key values. */
|
|
116
|
+
readonly key: readonly LedgerWireValue[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A merge join refused: a merged row's local key is held by this store's own
|
|
120
|
+
* row, and nothing yet settles such a collision across devices, so emitting
|
|
121
|
+
* this store's row would leave it held on every peer (T13504). The apply
|
|
122
|
+
* frame rolls back: nothing is adopted or emitted, and the reconcile stays due.
|
|
123
|
+
*/
|
|
124
|
+
export declare class MergeKeyCollisionError extends Error {
|
|
125
|
+
readonly collisions: readonly MergeKeyCollision[];
|
|
126
|
+
constructor(collisions: readonly MergeKeyCollision[]);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Reconcile a rebound store against the merged state (module docs). Must
|
|
130
|
+
* run outside a transaction. Does nothing, and returns null, when no
|
|
131
|
+
* reconcile is due.
|
|
132
|
+
*
|
|
133
|
+
* @param db - The rebound store (the canonical store).
|
|
134
|
+
* @param merged - The scratch store: the latest verified checkpoint pulled to head. Read-only here.
|
|
135
|
+
* @param o - Scope, stream, the merged pull position and the clock.
|
|
136
|
+
* @returns What was adopted and emitted, or null when nothing was due.
|
|
137
|
+
*/
|
|
138
|
+
export declare function reconcileCopy(db: DatabaseSync, merged: DatabaseSync, o: ReconcileCopyOptions): ReconcileCopyReport | null;
|
|
139
|
+
/**
|
|
140
|
+
* The merged rows a merge join (T13466) could not place: a live merged row
|
|
141
|
+
* this store has no row for, whose local key a different row here already
|
|
142
|
+
* holds. Read-only; run it before the join so a refusal changes nothing
|
|
143
|
+
* (T13504). Tables whose key holds a reference are left to the reconcile's
|
|
144
|
+
* own check, which refuses the same way.
|
|
145
|
+
*
|
|
146
|
+
* @param db - The store about to merge in.
|
|
147
|
+
* @param merged - The merged state (checkpoint pulled to head).
|
|
148
|
+
* @param scope - The store's scope.
|
|
149
|
+
* @returns The colliding merged rows, in table order.
|
|
150
|
+
*/
|
|
151
|
+
export declare function mergeKeyCollisions(db: DatabaseSync, merged: DatabaseSync, scope: TableScope): MergeKeyCollision[];
|
|
152
|
+
//# sourceMappingURL=reconcile-copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile-copy.d.ts","sourceRoot":"","sources":["../../../src/store/sync/reconcile-copy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAQlE,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,WAAW,CAAC;AACjE,OAAO,EAKL,KAAK,eAAe,EAGrB,MAAM,gBAAgB,CAAC;AAOxB,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,8CAA8C;IAC9C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC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