@opendatalabs/personal-server-ts-core 1.38.1 → 1.40.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.
- package/dist/localdb/delete.d.ts +28 -0
- package/dist/localdb/delete.d.ts.map +1 -1
- package/dist/localdb/delete.js +111 -1
- package/dist/localdb/delete.js.map +1 -1
- package/dist/localdb/import-ledger.d.ts +8 -0
- package/dist/localdb/import-ledger.d.ts.map +1 -1
- package/dist/localdb/import-ledger.js +8 -1
- package/dist/localdb/import-ledger.js.map +1 -1
- package/dist/localdb/index.d.ts +1 -0
- package/dist/localdb/index.d.ts.map +1 -1
- package/dist/localdb/index.js +1 -0
- package/dist/localdb/index.js.map +1 -1
- package/dist/localdb/legacy-import.d.ts +6 -4
- package/dist/localdb/legacy-import.d.ts.map +1 -1
- package/dist/localdb/legacy-import.js +47 -30
- package/dist/localdb/legacy-import.js.map +1 -1
- package/dist/localdb/listing.d.ts.map +1 -1
- package/dist/localdb/listing.js +2 -1
- package/dist/localdb/listing.js.map +1 -1
- package/dist/localdb/log-apply.d.ts +8 -4
- package/dist/localdb/log-apply.d.ts.map +1 -1
- package/dist/localdb/log-apply.js +15 -6
- package/dist/localdb/log-apply.js.map +1 -1
- package/dist/localdb/log-batch.d.ts +17 -0
- package/dist/localdb/log-batch.d.ts.map +1 -1
- package/dist/localdb/log-batch.js +26 -13
- package/dist/localdb/log-batch.js.map +1 -1
- package/dist/localdb/log-erase.d.ts +137 -0
- package/dist/localdb/log-erase.d.ts.map +1 -0
- package/dist/localdb/log-erase.js +398 -0
- package/dist/localdb/log-erase.js.map +1 -0
- package/dist/localdb/log-publish.d.ts.map +1 -1
- package/dist/localdb/log-publish.js +10 -1
- package/dist/localdb/log-publish.js.map +1 -1
- package/dist/localdb/log-tombstone-recovery.d.ts +3 -0
- package/dist/localdb/log-tombstone-recovery.d.ts.map +1 -0
- package/dist/localdb/log-tombstone-recovery.js +59 -0
- package/dist/localdb/log-tombstone-recovery.js.map +1 -0
- package/dist/localdb/purge.d.ts +2 -0
- package/dist/localdb/purge.d.ts.map +1 -1
- package/dist/localdb/purge.js +28 -0
- package/dist/localdb/purge.js.map +1 -1
- package/dist/localdb/schema.d.ts.map +1 -1
- package/dist/localdb/schema.js +11 -0
- package/dist/localdb/schema.js.map +1 -1
- package/dist/localdb/seed.d.ts.map +1 -1
- package/dist/localdb/seed.js +8 -27
- package/dist/localdb/seed.js.map +1 -1
- package/dist/localdb/sync.d.ts +8 -0
- package/dist/localdb/sync.d.ts.map +1 -1
- package/dist/localdb/sync.js +32 -2
- package/dist/localdb/sync.js.map +1 -1
- package/dist/stream-sync-read/service.d.ts +3 -2
- package/dist/stream-sync-read/service.d.ts.map +1 -1
- package/dist/stream-sync-read/service.js.map +1 -1
- package/dist-test/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { VersionInventoryClient } from "../additions/version-inventory.js";
|
|
2
|
+
import type { SqlDriver } from "./driver.js";
|
|
3
|
+
import { type StreamCryptoPort } from "../stream-sync/crypto-port.js";
|
|
4
|
+
import type { StreamSyncBlobs, StreamSyncKeyPorts, StreamSyncRegistry } from "../stream-sync/ports.js";
|
|
5
|
+
/** The registry's version inventory of one scope (`GET /v1/data/:id/versions`). */
|
|
6
|
+
export interface LogVersionLister {
|
|
7
|
+
list(scope: string, options?: {
|
|
8
|
+
readonly signal?: AbortSignal;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
/** True only when all pages of the version inventory were read. */
|
|
11
|
+
readonly complete: boolean;
|
|
12
|
+
readonly versions: readonly {
|
|
13
|
+
readonly expectedVersion: string;
|
|
14
|
+
readonly dataHash: string;
|
|
15
|
+
readonly isTombstone: boolean;
|
|
16
|
+
}[];
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Whether a control tombstone can no longer be rolled back
|
|
21
|
+
* (`TombstoneFinalityPort.tombstoneState`).
|
|
22
|
+
*/
|
|
23
|
+
export interface TombstoneFinality {
|
|
24
|
+
tombstoneState(scope: string, atOrAbove: string): Promise<{
|
|
25
|
+
/** The highest finalized tombstone at or above the asked version. */
|
|
26
|
+
readonly finalized: string | null;
|
|
27
|
+
/** Set when the tombstone failed and the row is live data again. */
|
|
28
|
+
readonly rolledBack: unknown;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The owner-signed per-object storage delete (`DeleteDataPort.deleteBlobVersions`):
|
|
33
|
+
* `names` are blob names under `scope`. An absent object is reported as
|
|
34
|
+
* `missing`, which counts as deleted; a failure is reported per name, never
|
|
35
|
+
* thrown for the batch.
|
|
36
|
+
*/
|
|
37
|
+
export interface LogObjectEraser {
|
|
38
|
+
deleteBlobVersions(scope: string, names: string[]): Promise<{
|
|
39
|
+
readonly deleted: readonly string[];
|
|
40
|
+
readonly missing: readonly string[];
|
|
41
|
+
readonly failed: readonly {
|
|
42
|
+
readonly version: string;
|
|
43
|
+
error: string;
|
|
44
|
+
}[];
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Where the pass writes down the body pieces it leaves in storage (see 3
|
|
49
|
+
* above), durably, before it deletes the objects that name them. Writing a
|
|
50
|
+
* name twice is fine. A failure fails the pass before any delete.
|
|
51
|
+
*/
|
|
52
|
+
export interface RetainedPieces {
|
|
53
|
+
keep(scope: string, names: readonly string[]): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `RetainedPieces` in the local database (`retained_log_pieces`). The table is
|
|
57
|
+
* keyed by scope and name and survives a connection's purge: it is the
|
|
58
|
+
* record of what a delete left in storage, which nothing else names.
|
|
59
|
+
*/
|
|
60
|
+
export declare function retainedPiecesIn(db: Pick<SqlDriver, "batch">): RetainedPieces;
|
|
61
|
+
export interface LogErasureDeps {
|
|
62
|
+
readonly registry: Pick<StreamSyncRegistry, "read" | "listControlRows">;
|
|
63
|
+
readonly versions: LogVersionLister;
|
|
64
|
+
readonly finality: TombstoneFinality;
|
|
65
|
+
readonly blobs: Pick<StreamSyncBlobs, "get">;
|
|
66
|
+
readonly keys: Pick<StreamSyncKeyPorts, "namespaceHmac" | "decrypt">;
|
|
67
|
+
readonly streamCrypto?: StreamCryptoPort;
|
|
68
|
+
readonly objects: LogObjectEraser;
|
|
69
|
+
readonly retained: RetainedPieces;
|
|
70
|
+
readonly logger: {
|
|
71
|
+
info(obj: Record<string, unknown>, msg?: string): void;
|
|
72
|
+
warn(obj: Record<string, unknown>, msg?: string): void;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** What a host supplies to erase; the rest of `LogErasureDeps` is the sync's own. */
|
|
76
|
+
export type LogErasurePorts = Pick<LogErasureDeps, "versions" | "finality" | "objects">;
|
|
77
|
+
/**
|
|
78
|
+
* The version inventory as a `LogVersionLister`. One traversal is "not a
|
|
79
|
+
* completeness certificate" (`VersionInventoryClient.list`): a segment the
|
|
80
|
+
* registry still lists can be missed. The inventory is read again and the two
|
|
81
|
+
* reads compared, as every other certifying reader does
|
|
82
|
+
* (`additions/durable.ts`); it is complete only when they match. A traversal
|
|
83
|
+
* that cannot finish (a changed head, an exceeded page budget, a failed read)
|
|
84
|
+
* throws, which a pass reports as pending.
|
|
85
|
+
*/
|
|
86
|
+
export declare function inventoryVersionLister(inventory: Pick<VersionInventoryClient, "list">): LogVersionLister;
|
|
87
|
+
export type ErasureOutcome =
|
|
88
|
+
/**
|
|
89
|
+
* Every object discovered from the complete version inventory was acknowledged
|
|
90
|
+
* deleted or missing, except the body pieces, which are not deleted and are
|
|
91
|
+
* recorded (`retained`, see 3 above). A successful outcome always has zero
|
|
92
|
+
* unenumerated objects.
|
|
93
|
+
*/
|
|
94
|
+
{
|
|
95
|
+
readonly kind: "erased";
|
|
96
|
+
readonly deleted: number;
|
|
97
|
+
readonly retained: number;
|
|
98
|
+
readonly unenumerated: number;
|
|
99
|
+
}
|
|
100
|
+
/** Not finished; the same call again continues. */
|
|
101
|
+
| {
|
|
102
|
+
readonly kind: "pending";
|
|
103
|
+
readonly why: "finality" | "storage" | "inventory" | "error";
|
|
104
|
+
readonly detail?: string;
|
|
105
|
+
}
|
|
106
|
+
/** Not erased, and a repeat will not change that. */
|
|
107
|
+
| {
|
|
108
|
+
readonly kind: "stopped";
|
|
109
|
+
/**
|
|
110
|
+
* `re-added`: the control row moved since the pass began.
|
|
111
|
+
* `rolled-back`: the tombstone failed; the connection is live again.
|
|
112
|
+
* `head-unreadable`: the newest segment does not open with this key.
|
|
113
|
+
*/
|
|
114
|
+
readonly why: "re-added" | "rolled-back" | "head-unreadable";
|
|
115
|
+
};
|
|
116
|
+
export interface ConnectionErasure {
|
|
117
|
+
readonly connector: string;
|
|
118
|
+
readonly ns: string;
|
|
119
|
+
readonly outcome: ErasureOutcome;
|
|
120
|
+
}
|
|
121
|
+
export interface ErasureReport {
|
|
122
|
+
readonly connections: readonly ConnectionErasure[];
|
|
123
|
+
/** True when a later call can still make progress (a `pending` outcome). */
|
|
124
|
+
readonly pending: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Erase the log objects of every deleted connection of `connector` (every
|
|
128
|
+
* deleted connection of the owner when none is named). The connection deleter
|
|
129
|
+
* calls it once the delete has settled on this device (`delete.ts`,
|
|
130
|
+
* `eraseLogs`), and again to resume. It never throws and never touches the delete itself: a failure
|
|
131
|
+
* comes back as a `pending` outcome for the caller to repeat later.
|
|
132
|
+
*/
|
|
133
|
+
export declare function eraseDeletedConnectionLogs(deps: LogErasureDeps, options?: {
|
|
134
|
+
readonly connector?: string;
|
|
135
|
+
readonly signal?: AbortSignal;
|
|
136
|
+
}): Promise<ErasureReport>;
|
|
137
|
+
//# sourceMappingURL=log-erase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-erase.d.ts","sourceRoot":"","sources":["../../src/localdb/log-erase.ts"],"names":[],"mappings":"AAmFA,OAAO,KAAK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CAAA;CAAO,GAC3E,OAAO,CAAC,aAAa,CAAC,CAoCxB"}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
// Physical erasure of a deleted connection's log objects from storage.
|
|
2
|
+
//
|
|
3
|
+
// A connection delete writes one fence: the control row's tombstone. It leaves
|
|
4
|
+
// the connection's encrypted objects in storage (segments `s-<hex>`, snapshot
|
|
5
|
+
// parts `q-<hex>`, out-of-line body pieces `v-<hex>`, all under the log scope
|
|
6
|
+
// `pdpp.<c>~<ns>.~log`), and the owner's own key can still read them. This
|
|
7
|
+
// module deletes them with the owner-signed per-object storage delete the
|
|
8
|
+
// legacy delete used.
|
|
9
|
+
//
|
|
10
|
+
// WHAT IS SAFE TO DELETE, AND WHEN
|
|
11
|
+
//
|
|
12
|
+
// A re-add of the same connection uses the SAME log scope: the log row is not
|
|
13
|
+
// tombstoned by the delete, its position keeps counting, and the new lifetime's
|
|
14
|
+
// first segment starts at `base` = the old position (`log-apply.ts`, "a log of
|
|
15
|
+
// an earlier lifetime holds none of this one"). So physical delete can race a
|
|
16
|
+
// re-add (`docs/design/write-once-publication.md`: no read-then-delete
|
|
17
|
+
// reclaim). The fence:
|
|
18
|
+
//
|
|
19
|
+
// 1. Nothing is deleted until the control tombstone is FINALIZED at its own
|
|
20
|
+
// version or above (a lower finalized version says nothing about it). A tombstone
|
|
21
|
+
// the gateway has queued can still fail and roll the control row back to
|
|
22
|
+
// live data; erasing before that is ruled out would destroy a connection
|
|
23
|
+
// the registry can still show. The legacy blob delete waits the same way.
|
|
24
|
+
// 2. The control row is read again before every batch of deletes, and must
|
|
25
|
+
// still be the tombstone this pass started from (same version). A log
|
|
26
|
+
// commit requires the control row active at its generation, in the same
|
|
27
|
+
// registry transaction (`log-publish.ts`), so while the control row is that
|
|
28
|
+
// tombstone the log row cannot move: every version the inventory listed
|
|
29
|
+
// belongs to a lifetime that ended. Once the control row moves (a re-add),
|
|
30
|
+
// the pass stops and deletes nothing more.
|
|
31
|
+
// 3. Segment and part names cannot be shared with a later lifetime: they are
|
|
32
|
+
// the Keccak-256 of clear bytes that hold the generation and the position,
|
|
33
|
+
// and a position is used once per log row. Body pieces CAN: they are named
|
|
34
|
+
// by the Keccak-256 of their clear bytes alone, so a re-add that collects
|
|
35
|
+
// the same large record names the same piece, and storage keeps the first
|
|
36
|
+
// bytes of a name, so its upload is answered by the old copy. A re-add that
|
|
37
|
+
// commits between the control check of 2 and the DELETE reaching storage
|
|
38
|
+
// would then name a piece the DELETE removes, and its log would not read
|
|
39
|
+
// ("apply: missing a piece of an out-of-line body"). No read here can close
|
|
40
|
+
// that window (`write-once-publication.md`: no read-then-delete reclaim),
|
|
41
|
+
// and cutting pieces at other offsets does not either. Salting the name per
|
|
42
|
+
// connection lifetime would, but it changes what a reader checks
|
|
43
|
+
// (`keccak(piece) = name`): a LOG_FORMAT change every device must understand
|
|
44
|
+
// first, and a follow-up. UNTIL THEN THE ERASER NEVER DELETES A BODY PIECE.
|
|
45
|
+
// It still finds them, to write their names down (`RetainedPieces`) before
|
|
46
|
+
// it deletes the parts and segments that name them: afterwards nothing
|
|
47
|
+
// names them, so the record is the only way the salting change can sweep
|
|
48
|
+
// them. A name in the record is a candidate, not proof it is unused: a live
|
|
49
|
+
// log can name the same piece, and the sweep must check that first.
|
|
50
|
+
//
|
|
51
|
+
// RETRY WITHOUT A JOURNAL
|
|
52
|
+
//
|
|
53
|
+
// Objects are deleted in an order that keeps the log readable until what it
|
|
54
|
+
// names is gone: parts, then segments, the newest segment (the one the
|
|
55
|
+
// registry's log row names) last. Each phase finishes before the next starts,
|
|
56
|
+
// and a failed batch stops the pass. So a pass that stops anywhere, or a
|
|
57
|
+
// restart, leaves every segment that names a remaining part in place, and the
|
|
58
|
+
// next pass enumerates the same objects again. The piece names are recorded
|
|
59
|
+
// before the first delete, so no restart loses them. The newest segment is
|
|
60
|
+
// removed only after a complete inventory and acknowledged deletes. Its
|
|
61
|
+
// absence is checked against the full version inventory before a repeat
|
|
62
|
+
// reports completion. A delete that answers 404 counts as done, so every step
|
|
63
|
+
// repeats.
|
|
64
|
+
import { bodyPieceBlobName, classifyControl, controlHashes, controlScope, deriveKeyCheck, logScope, parseScope, segmentBlobName, snapshotPartBlobName, verifySegment, verifySnapshotPart, } from "@opendatalabs/personal-server-ts-stream-sync";
|
|
65
|
+
import { keccakOf } from "../stream-sync/crypto-port.js";
|
|
66
|
+
import { PARTS_IN_FLIGHT } from "../stream-sync/storage-retry.js";
|
|
67
|
+
/** Rows per batch: a large body can name many pieces. */
|
|
68
|
+
const KEEP_BATCH = 500;
|
|
69
|
+
/**
|
|
70
|
+
* `RetainedPieces` in the local database (`retained_log_pieces`). The table is
|
|
71
|
+
* keyed by scope and name and survives a connection's purge: it is the
|
|
72
|
+
* record of what a delete left in storage, which nothing else names.
|
|
73
|
+
*/
|
|
74
|
+
export function retainedPiecesIn(db) {
|
|
75
|
+
return {
|
|
76
|
+
async keep(scope, names) {
|
|
77
|
+
for (let at = 0; at < names.length; at += KEEP_BATCH)
|
|
78
|
+
await db.batch(names.slice(at, at + KEEP_BATCH).map((name) => ({
|
|
79
|
+
sql: "INSERT OR IGNORE INTO retained_log_pieces(scope, name, recorded_at) VALUES (?, ?, CAST(strftime('%s','now') AS INTEGER) * 1000)",
|
|
80
|
+
params: [scope, name],
|
|
81
|
+
})));
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The version inventory as a `LogVersionLister`. One traversal is "not a
|
|
87
|
+
* completeness certificate" (`VersionInventoryClient.list`): a segment the
|
|
88
|
+
* registry still lists can be missed. The inventory is read again and the two
|
|
89
|
+
* reads compared, as every other certifying reader does
|
|
90
|
+
* (`additions/durable.ts`); it is complete only when they match. A traversal
|
|
91
|
+
* that cannot finish (a changed head, an exceeded page budget, a failed read)
|
|
92
|
+
* throws, which a pass reports as pending.
|
|
93
|
+
*/
|
|
94
|
+
export function inventoryVersionLister(inventory) {
|
|
95
|
+
return {
|
|
96
|
+
async list(scope, options) {
|
|
97
|
+
const read = () => inventory.list(scope, { signal: options?.signal });
|
|
98
|
+
const first = await read();
|
|
99
|
+
const second = await read();
|
|
100
|
+
return {
|
|
101
|
+
complete: JSON.stringify(first) === JSON.stringify(second),
|
|
102
|
+
versions: second.versions.map((v) => ({
|
|
103
|
+
expectedVersion: v.expectedVersion,
|
|
104
|
+
dataHash: v.dataHash,
|
|
105
|
+
isTombstone: v.isTombstone,
|
|
106
|
+
})),
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** The legacy delete's batch: vana-storage rate-limits DELETE per owner. */
|
|
112
|
+
const DELETE_BATCH = 15;
|
|
113
|
+
/**
|
|
114
|
+
* Erase the log objects of every deleted connection of `connector` (every
|
|
115
|
+
* deleted connection of the owner when none is named). The connection deleter
|
|
116
|
+
* calls it once the delete has settled on this device (`delete.ts`,
|
|
117
|
+
* `eraseLogs`), and again to resume. It never throws and never touches the delete itself: a failure
|
|
118
|
+
* comes back as a `pending` outcome for the caller to repeat later.
|
|
119
|
+
*/
|
|
120
|
+
export async function eraseDeletedConnectionLogs(deps, options = {}) {
|
|
121
|
+
const connections = [];
|
|
122
|
+
try {
|
|
123
|
+
const keyCheck = await deriveKeyCheck((m) => deps.keys.namespaceHmac(m));
|
|
124
|
+
const hashes = await controlHashes(keccakOf(deps.streamCrypto), keyCheck);
|
|
125
|
+
const rows = await deps.registry.listControlRows(options.signal);
|
|
126
|
+
for (const { scope, read } of rows) {
|
|
127
|
+
const parsed = parseScope(scope);
|
|
128
|
+
if (parsed?.kind !== "control")
|
|
129
|
+
continue;
|
|
130
|
+
if (options.connector !== undefined &&
|
|
131
|
+
parsed.connector !== options.connector)
|
|
132
|
+
continue;
|
|
133
|
+
const state = classifyControl(read, hashes);
|
|
134
|
+
if (state.kind !== "deleted")
|
|
135
|
+
continue;
|
|
136
|
+
const { connector, ns } = parsed;
|
|
137
|
+
const outcome = await eraseOne(deps, { connector, ns, keyCheck, hashes, tombstone: state.version }, options.signal);
|
|
138
|
+
report(deps, connector, outcome);
|
|
139
|
+
connections.push({ connector, ns, outcome });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
deps.logger.warn({ error: error instanceof Error ? error.message : String(error) }, "stream sync: connection log erasure could not list the deleted connections");
|
|
144
|
+
return { connections, pending: true };
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
connections,
|
|
148
|
+
pending: connections.some((c) => c.outcome.kind === "pending"),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function report(deps, connector, o) {
|
|
152
|
+
if (o.kind === "erased")
|
|
153
|
+
deps.logger.info({
|
|
154
|
+
connector,
|
|
155
|
+
deleted: o.deleted,
|
|
156
|
+
retained: o.retained,
|
|
157
|
+
unenumerated: o.unenumerated,
|
|
158
|
+
}, "stream sync: erased a deleted connection's log objects, not its body pieces");
|
|
159
|
+
else
|
|
160
|
+
deps.logger.warn({ connector, ...o }, "stream sync: a deleted connection's log objects are not erased yet");
|
|
161
|
+
}
|
|
162
|
+
class Moved extends Error {
|
|
163
|
+
}
|
|
164
|
+
async function eraseOne(deps, target, signal) {
|
|
165
|
+
const { connector, ns, tombstone } = target;
|
|
166
|
+
const control = controlScope(connector, ns);
|
|
167
|
+
const scope = logScope(connector, ns);
|
|
168
|
+
try {
|
|
169
|
+
const finality = await deps.finality.tombstoneState(control, String(tombstone));
|
|
170
|
+
if (finality.rolledBack)
|
|
171
|
+
return { kind: "stopped", why: "rolled-back" };
|
|
172
|
+
// The port answers the highest finalized tombstone at or above the asked
|
|
173
|
+
// version, but an adapter can answer a lower one while a newer tombstone
|
|
174
|
+
// is still settling and could yet roll back. Only a finalized version at
|
|
175
|
+
// or above the one this pass erases for proves it final.
|
|
176
|
+
if (!finalizedAtOrAbove(finality.finalized, tombstone))
|
|
177
|
+
return { kind: "pending", why: "finality" };
|
|
178
|
+
const head = await deps.registry.read(scope, signal);
|
|
179
|
+
const headRef = head.found
|
|
180
|
+
? { dataHash: head.dataHash, position: head.version }
|
|
181
|
+
: null;
|
|
182
|
+
const headName = headRef ? segmentBlobName(headRef.dataHash) : null;
|
|
183
|
+
const inventory = await deps.versions.list(scope, { signal });
|
|
184
|
+
if (inventory.complete !== true)
|
|
185
|
+
return {
|
|
186
|
+
kind: "pending",
|
|
187
|
+
why: "inventory",
|
|
188
|
+
detail: "log version inventory is incomplete",
|
|
189
|
+
};
|
|
190
|
+
// Every object is found by the name its bytes hash to: the registry's
|
|
191
|
+
// data hashes name the segments, and a verified segment names its parts.
|
|
192
|
+
// `position` is set where the registry or a ref promised one.
|
|
193
|
+
const segments = new Map();
|
|
194
|
+
for (const v of inventory.versions)
|
|
195
|
+
if (!v.isTombstone)
|
|
196
|
+
segments.set(segmentBlobName(v.dataHash), { dataHash: v.dataHash });
|
|
197
|
+
const opened = headRef
|
|
198
|
+
? await openSegment(deps, scope, target, headRef)
|
|
199
|
+
: "absent";
|
|
200
|
+
if (headName === null || opened === "absent") {
|
|
201
|
+
// A finished pass leaves no listed segment in storage (the head went
|
|
202
|
+
// last). Do not treat a missing head with surviving segments as proof.
|
|
203
|
+
for (const name of segments.keys()) {
|
|
204
|
+
if (name !== headName &&
|
|
205
|
+
(await deps.blobs.get(`${scope}/${name}`)) !== null)
|
|
206
|
+
return {
|
|
207
|
+
kind: "pending",
|
|
208
|
+
why: "inventory",
|
|
209
|
+
detail: "log head is missing with listed segments still present",
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
return { kind: "erased", deleted: 0, retained: 0, unenumerated: 0 };
|
|
213
|
+
}
|
|
214
|
+
if (opened === "unreadable")
|
|
215
|
+
return { kind: "stopped", why: "head-unreadable" };
|
|
216
|
+
segments.set(headName, headRef);
|
|
217
|
+
for (const ref of opened.refs)
|
|
218
|
+
segments.set(segmentBlobName(ref.dataHash), {
|
|
219
|
+
dataHash: ref.dataHash,
|
|
220
|
+
position: ref.position,
|
|
221
|
+
});
|
|
222
|
+
const parts = new Map();
|
|
223
|
+
const pieces = new Set();
|
|
224
|
+
let unenumerated = 0;
|
|
225
|
+
const note = (references) => {
|
|
226
|
+
for (const op of references)
|
|
227
|
+
if (op.kind === "upsert-ref")
|
|
228
|
+
for (const piece of op.body.pieces)
|
|
229
|
+
pieces.add(bodyPieceBlobName(piece));
|
|
230
|
+
};
|
|
231
|
+
await each([...segments.values()], async (expected) => {
|
|
232
|
+
const segment = await openSegment(deps, scope, target, expected);
|
|
233
|
+
if (segment === "absent")
|
|
234
|
+
return;
|
|
235
|
+
if (segment === "unreadable") {
|
|
236
|
+
unenumerated += 1;
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
for (const part of segment.snapshot?.parts ?? [])
|
|
240
|
+
parts.set(snapshotPartBlobName(part.dataHash), {
|
|
241
|
+
dataHash: part.dataHash,
|
|
242
|
+
position: segment.snapshot.position,
|
|
243
|
+
});
|
|
244
|
+
note(segment.operations);
|
|
245
|
+
});
|
|
246
|
+
await each([...parts.values()], async (expected) => {
|
|
247
|
+
const part = await openPart(deps, scope, target, expected);
|
|
248
|
+
if (part === "absent")
|
|
249
|
+
return;
|
|
250
|
+
if (part === "unreadable") {
|
|
251
|
+
unenumerated += 1;
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
note(part.entries);
|
|
255
|
+
});
|
|
256
|
+
if (unenumerated > 0)
|
|
257
|
+
return {
|
|
258
|
+
kind: "pending",
|
|
259
|
+
why: "inventory",
|
|
260
|
+
detail: `${unenumerated} log objects could not be enumerated`,
|
|
261
|
+
};
|
|
262
|
+
// Written down before anything that names them is deleted (see 3 above).
|
|
263
|
+
if (pieces.size > 0)
|
|
264
|
+
await deps.retained.keep(scope, [...pieces]);
|
|
265
|
+
const rest = [...segments.keys()].filter((name) => name !== headName);
|
|
266
|
+
let deleted = 0;
|
|
267
|
+
for (const phase of [[...parts.keys()], rest, [headName]]) {
|
|
268
|
+
for (let at = 0; at < phase.length; at += DELETE_BATCH) {
|
|
269
|
+
signal?.throwIfAborted();
|
|
270
|
+
await stillTombstoned(deps, target, signal);
|
|
271
|
+
const batch = phase.slice(at, at + DELETE_BATCH);
|
|
272
|
+
const outcome = await deps.objects
|
|
273
|
+
.deleteBlobVersions(scope, batch)
|
|
274
|
+
.catch((error) => ({
|
|
275
|
+
deleted: [],
|
|
276
|
+
missing: [],
|
|
277
|
+
failed: batch.map((version) => ({
|
|
278
|
+
version,
|
|
279
|
+
error: error instanceof Error ? error.message : String(error),
|
|
280
|
+
})),
|
|
281
|
+
}));
|
|
282
|
+
deleted += outcome.deleted.length;
|
|
283
|
+
// A failure stops the pass: the next phase would delete what this
|
|
284
|
+
// one still needs in order to be found again.
|
|
285
|
+
if (outcome.failed.length > 0)
|
|
286
|
+
return {
|
|
287
|
+
kind: "pending",
|
|
288
|
+
why: "storage",
|
|
289
|
+
detail: `${outcome.failed.length} of ${batch.length} deletes failed: ${outcome.failed[0].error}`,
|
|
290
|
+
};
|
|
291
|
+
const acknowledged = [...outcome.deleted, ...outcome.missing];
|
|
292
|
+
const names = new Set(acknowledged);
|
|
293
|
+
if (acknowledged.length !== batch.length ||
|
|
294
|
+
names.size !== batch.length ||
|
|
295
|
+
batch.some((name) => !names.has(name)))
|
|
296
|
+
return {
|
|
297
|
+
kind: "pending",
|
|
298
|
+
why: "storage",
|
|
299
|
+
detail: "delete batch was not fully acknowledged",
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return { kind: "erased", deleted, retained: pieces.size, unenumerated };
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
if (error instanceof Moved)
|
|
307
|
+
return { kind: "stopped", why: "re-added" };
|
|
308
|
+
return {
|
|
309
|
+
kind: "pending",
|
|
310
|
+
why: "error",
|
|
311
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/** Throws `Moved` unless the control row is still the tombstone the pass began from. */
|
|
316
|
+
async function stillTombstoned(deps, target, signal) {
|
|
317
|
+
const read = await deps.registry.read(controlScope(target.connector, target.ns), signal);
|
|
318
|
+
const state = classifyControl(read, target.hashes);
|
|
319
|
+
if (state.kind !== "deleted" || state.version !== target.tombstone)
|
|
320
|
+
throw new Moved();
|
|
321
|
+
}
|
|
322
|
+
/** A decrypted object, `"absent"` when storage has none, `"unreadable"` when it does not open. */
|
|
323
|
+
async function open(deps, scope, name) {
|
|
324
|
+
const cipher = await deps.blobs.get(`${scope}/${name}`);
|
|
325
|
+
if (cipher === null)
|
|
326
|
+
return "absent";
|
|
327
|
+
try {
|
|
328
|
+
return await deps.keys.decrypt(scope, cipher);
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
return "unreadable";
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* The reader's own checks (`verifySegment`, as `fetchSegment` in `log-apply.ts`
|
|
336
|
+
* runs them) on the segment a name holds: its bytes hash to the name, it is
|
|
337
|
+
* this connection's log, under this key, at the promised position. An object
|
|
338
|
+
* that fails any of them, however well it decodes, is another object served
|
|
339
|
+
* under this name, and is not read for what it names. `"absent"` when storage
|
|
340
|
+
* has none.
|
|
341
|
+
*/
|
|
342
|
+
async function openSegment(deps, scope, target, expected) {
|
|
343
|
+
const bytes = await open(deps, scope, segmentBlobName(expected.dataHash));
|
|
344
|
+
if (bytes === "absent" || bytes === "unreadable")
|
|
345
|
+
return bytes;
|
|
346
|
+
const verified = await verifySegment(keccakOf(deps.streamCrypto), bytes, {
|
|
347
|
+
dataHash: expected.dataHash,
|
|
348
|
+
connector: target.connector,
|
|
349
|
+
ns: target.ns,
|
|
350
|
+
keyCheck: target.keyCheck,
|
|
351
|
+
...(expected.position !== undefined && { position: expected.position }),
|
|
352
|
+
});
|
|
353
|
+
return verified.kind === "ok" ? verified.segment : "unreadable";
|
|
354
|
+
}
|
|
355
|
+
/** `openSegment` for a snapshot part. */
|
|
356
|
+
async function openPart(deps, scope, target, expected) {
|
|
357
|
+
const bytes = await open(deps, scope, snapshotPartBlobName(expected.dataHash));
|
|
358
|
+
if (bytes === "absent" || bytes === "unreadable")
|
|
359
|
+
return bytes;
|
|
360
|
+
const verified = await verifySnapshotPart(keccakOf(deps.streamCrypto), bytes, {
|
|
361
|
+
dataHash: expected.dataHash,
|
|
362
|
+
connector: target.connector,
|
|
363
|
+
ns: target.ns,
|
|
364
|
+
keyCheck: target.keyCheck,
|
|
365
|
+
position: expected.position,
|
|
366
|
+
});
|
|
367
|
+
return verified.kind === "ok" ? verified.part : "unreadable";
|
|
368
|
+
}
|
|
369
|
+
/** Whether `finalized` is a version at or above `tombstone`. */
|
|
370
|
+
function finalizedAtOrAbove(finalized, tombstone) {
|
|
371
|
+
if (finalized === null)
|
|
372
|
+
return false;
|
|
373
|
+
try {
|
|
374
|
+
return BigInt(finalized) >= BigInt(tombstone);
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/** `work` over `items`, at most the store gate's width at once; the first failure stops it. */
|
|
381
|
+
async function each(items, work) {
|
|
382
|
+
let next = 0;
|
|
383
|
+
let failed = false;
|
|
384
|
+
const lane = async () => {
|
|
385
|
+
while (!failed && next < items.length) {
|
|
386
|
+
const item = items[next++];
|
|
387
|
+
try {
|
|
388
|
+
await work(item);
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
failed = true;
|
|
392
|
+
throw error;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
await Promise.all(Array.from({ length: Math.min(PARTS_IN_FLIGHT, items.length) }, lane));
|
|
397
|
+
}
|
|
398
|
+
//# sourceMappingURL=log-erase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-erase.js","sourceRoot":"","sources":["../../src/localdb/log-erase.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,+EAA+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AAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CACtE,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-publish.d.ts","sourceRoot":"","sources":["../../src/localdb/log-publish.ts"],"names":[],"mappings":"AA4FA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"log-publish.d.ts","sourceRoot":"","sources":["../../src/localdb/log-publish.ts"],"names":[],"mappings":"AA4FA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAsB/C,OAAO,EAaL,KAAK,aAAa,EAEnB,MAAM,cAAc,CAAC;AAqBtB,eAAO,MAAM,UAAU,QAAkB,CAAC;AAkI1C;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,aAAa,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAoCnC;AAs3CD;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,OAAO,CAAC,EACzC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC,CA+BlB"}
|
|
@@ -55,7 +55,7 @@ import { tombstoneOmissions } from "./admit.js";
|
|
|
55
55
|
import { planCompaction } from "./log-compact.js";
|
|
56
56
|
import { logPublishPhases, openPhases, } from "./log-publish-phases.js";
|
|
57
57
|
import { readLogState, writeLogState } from "./log-apply.js";
|
|
58
|
-
import { rowsPerStatement } from "./log-batch.js";
|
|
58
|
+
import { prepareOperations, rowsPerStatement, tombstoneStatements, } from "./log-batch.js";
|
|
59
59
|
import { replaceDelete, seenBeforeParams, SEEN_BEFORE, withOrigin, } from "./merge.js";
|
|
60
60
|
import { discardFencedRuns, discardForeignLifetimeRuns, excludeSeedsIfAny, hasDeleteIntent, lifetimeHolds, metadataHashFor, planStream, postBatchOnce, runPublicationStatements, retainedRuns, } from "./publish.js";
|
|
61
61
|
import { BODY_BYTES } from "./part-layout.js";
|
|
@@ -1632,6 +1632,15 @@ function publishedResults(connectionId, candidate) {
|
|
|
1632
1632
|
async function candidateAcknowledgements(held, connectionId, candidate, acknowledged) {
|
|
1633
1633
|
const statements = [];
|
|
1634
1634
|
const touched = candidate.planned.filter((p) => p.included);
|
|
1635
|
+
// The deletions and omissions this segment sends become tombstones with its
|
|
1636
|
+
// acknowledgement, on the direct path and when history shows the commit
|
|
1637
|
+
// landed. Compaction prunes the changes that recorded them, and a record
|
|
1638
|
+
// removed and published must stay removed when a late seed fills the
|
|
1639
|
+
// stream (`late-seed`). A segment this device applies from the log writes
|
|
1640
|
+
// the same rows through `operationStatements`.
|
|
1641
|
+
for (const p of touched)
|
|
1642
|
+
if (p.meta)
|
|
1643
|
+
statements.push(...tombstoneStatements(connectionId, await prepareOperations([p.meta], p.operations.filter((op) => op.kind !== "upsert"))));
|
|
1635
1644
|
// A replace still under way read the stream at its basis; the segment this
|
|
1636
1645
|
// round committed is this device's own, so the basis moves to it (after the
|
|
1637
1646
|
// head columns above have).
|