@astrosheep/square 0.3.86 → 0.3.88
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/artifact.d.ts +6 -1
- package/dist/artifact.js +79 -10
- package/dist/boundary-presentation.d.ts +5 -4
- package/dist/boundary-presentation.js +21 -25
- package/dist/catch-decisions.js +2 -1
- package/dist/claude-delivery-status.d.ts +8 -2
- package/dist/claude-delivery-status.js +26 -10
- package/dist/claude-delivery.d.ts +8 -4
- package/dist/claude-delivery.js +114 -104
- package/dist/claude-mcp-context.js +2 -2
- package/dist/claude-mod.js +119 -105
- package/dist/cli/context.d.ts +3 -1
- package/dist/cli/context.js +25 -1
- package/dist/cli/express-presentation.d.ts +3 -1
- package/dist/cli/express-presentation.js +14 -10
- package/dist/cli/mcp-server-command.js +2 -2
- package/dist/cli/observation-commands.js +1 -0
- package/dist/cli/registry.js +0 -2
- package/dist/cli/square-commands.d.ts +4 -2
- package/dist/cli/square-commands.js +21 -6
- package/dist/codex-hook.d.ts +3 -3
- package/dist/codex-hook.js +4 -4
- package/dist/codex-queue.d.ts +5 -6
- package/dist/codex-queue.js +9 -5
- package/dist/decisions.d.ts +3 -2
- package/dist/decisions.js +18 -6
- package/dist/delivery-health.d.ts +32 -2
- package/dist/delivery-health.js +108 -45
- package/dist/delivery-operations.d.ts +1 -2
- package/dist/delivery-operations.js +155 -196
- package/dist/delivery.d.ts +14 -23
- package/dist/delivery.js +48 -18
- package/dist/file-lock.d.ts +8 -1
- package/dist/file-lock.js +2 -0
- package/dist/help.js +8 -11
- package/dist/inbox.d.ts +35 -9
- package/dist/inbox.js +228 -144
- package/dist/index.d.ts +3 -4
- package/dist/index.js +1 -3
- package/dist/list.js +9 -4
- package/dist/mcp.js +12 -1
- package/dist/model.d.ts +39 -5
- package/dist/model.js +84 -0
- package/dist/notifications.d.ts +8 -6
- package/dist/notifications.js +56 -143
- package/dist/operation-presentation.js +7 -4
- package/dist/participant-identity.d.ts +0 -3
- package/dist/participant-identity.js +0 -31
- package/dist/paseo-delivery.d.ts +5 -6
- package/dist/paseo-delivery.js +13 -8
- package/dist/paseo.d.ts +1 -1
- package/dist/paseo.js +1 -1
- package/dist/plugins/opencode/delivery.d.ts +8 -3
- package/dist/plugins/opencode/delivery.js +187 -132
- package/dist/plugins/opencode/index.js +12 -38
- package/dist/ports.d.ts +112 -40
- package/dist/presentation-operations.d.ts +1 -1
- package/dist/presentation-operations.js +51 -35
- package/dist/presentation.js +8 -3
- package/dist/seats.d.ts +7 -0
- package/dist/seats.js +27 -0
- package/dist/session-lifecycle.d.ts +2 -2
- package/dist/session-lifecycle.js +10 -12
- package/dist/sqlite-square.d.ts +20 -9
- package/dist/sqlite-square.js +476 -341
- package/dist/square-api.d.ts +1 -0
- package/dist/square-api.js +3 -4
- package/dist/square-core.d.ts +3 -2
- package/dist/square-domain.d.ts +12 -5
- package/dist/square-domain.js +163 -7
- package/dist/square-facade.d.ts +16 -10
- package/dist/square-index.d.ts +24 -0
- package/dist/square-index.js +131 -0
- package/dist/square-legacy-framing.d.ts +9 -0
- package/dist/square-legacy-framing.js +56 -0
- package/dist/square-migration-host-ledger.d.ts +26 -0
- package/dist/square-migration-host-ledger.js +168 -0
- package/dist/square-migration.d.ts +5 -5
- package/dist/square-migration.js +373 -71
- package/dist/square-sqlite.d.ts +9 -9
- package/dist/square-sqlite.js +329 -79
- package/dist/square-stdio.d.ts +1 -1
- package/dist/square-stdio.js +12 -7
- package/dist/square-tools.d.ts +1 -1
- package/dist/square-tools.js +80 -27
- package/dist/stdio-server.js +4 -2
- package/dist/stream.d.ts +3 -2
- package/dist/stream.js +9 -10
- package/dist/views.d.ts +9 -14
- package/dist/views.js +52 -70
- package/dist/wakes.d.ts +6 -5
- package/dist/wakes.js +20 -17
- package/guides/application-facade-delivery-evidence.md +1 -1
- package/guides/claude-native.md +9 -9
- package/guides/mcp.md +2 -2
- package/guides/migration.md +107 -67
- package/guides/pi-tools.md +1 -1
- package/guides/row-storage-design.md +1 -1
- package/guides/square-api.md +61 -28
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/hooks/register.js +1 -1
- package/plugins/claude/skills/square/SKILL.md +4 -4
- package/plugins/claude/types.d.ts +1 -1
- package/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/plugins/opencode/delivery.ts +170 -118
- package/plugins/opencode/index.ts +12 -30
- package/plugins/pi/square-pi.js +56 -18
- package/skills/square/SKILL.md +4 -4
- package/dist/cli/ledger-command.d.ts +0 -12
- package/dist/cli/ledger-command.js +0 -72
- package/dist/host-ledger-file-adapter.d.ts +0 -47
- package/dist/host-ledger-file-adapter.js +0 -384
- package/dist/host-ledger-migration.d.ts +0 -27
- package/dist/host-ledger-migration.js +0 -264
- package/dist/host-ledger-root.d.ts +0 -2
- package/dist/host-ledger-root.js +0 -9
- package/dist/host-ledger-sqlite.d.ts +0 -65
- package/dist/host-ledger-sqlite.js +0 -368
- package/dist/host-ledger.d.ts +0 -195
- package/dist/host-ledger.js +0 -1
- package/dist/ledger-maintenance.d.ts +0 -30
- package/dist/ledger-maintenance.js +0 -110
- package/dist/open-square.d.ts +0 -38
- package/dist/open-square.js +0 -81
- package/dist/participant-host.d.ts +0 -23
- package/dist/participant-host.js +0 -92
- package/dist/registry.d.ts +0 -55
- package/dist/registry.js +0 -123
- package/dist/routes.d.ts +0 -39
- package/dist/routes.js +0 -99
- package/dist/square-actions.d.ts +0 -56
- package/dist/square-actions.js +0 -353
- package/dist/square-projections.d.ts +0 -31
- package/dist/square-projections.js +0 -64
- package/dist/wake-attempts.d.ts +0 -10
- package/dist/wake-attempts.js +0 -39
- package/dist/wake-eligibility.d.ts +0 -53
- package/dist/wake-eligibility.js +0 -123
- package/dist/wake-evidence.d.ts +0 -33
- package/dist/wake-evidence.js +0 -32
- package/guides/host-ledger.md +0 -58
- package/guides/indexed-host-ledger-performance.md +0 -39
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { promises as fs } from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { DatabaseSync } from 'node:sqlite';
|
|
5
|
-
import { canonicalPathSync } from './canonical-path.js';
|
|
6
|
-
import { withFileLock } from './file-lock.js';
|
|
7
|
-
import { hostLedgerRoot } from './host-ledger-root.js';
|
|
8
|
-
import { LEDGER_FILENAME, initializeLedger, insertLedgerRecord, ledgerRecordColumns, setLedgerRevisions, upgradeLedger, validateLedger, verifyLedger, inspectLedgerIdentity, migrationRequired, } from './host-ledger-sqlite.js';
|
|
9
|
-
import { inSqliteTransaction } from './sqlite-transaction.js';
|
|
10
|
-
function rootFor(options) {
|
|
11
|
-
return canonicalPathSync(options.rootPath ?? hostLedgerRoot(options.env));
|
|
12
|
-
}
|
|
13
|
-
function abort(signal) {
|
|
14
|
-
if (signal?.aborted)
|
|
15
|
-
throw signal.reason ?? new Error('Host ledger migration aborted');
|
|
16
|
-
}
|
|
17
|
-
async function exists(file) {
|
|
18
|
-
try {
|
|
19
|
-
await fs.lstat(file);
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
if (error.code === 'ENOENT')
|
|
24
|
-
return false;
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function verificationFailure(root, file, format) {
|
|
29
|
-
const name = file ?? path.join(root, LEDGER_FILENAME);
|
|
30
|
-
const detail = format === 'unsupported'
|
|
31
|
-
? 'It has an unsupported format version.'
|
|
32
|
-
: format === 'unrelated'
|
|
33
|
-
? 'It is unrelated to a Square host ledger.'
|
|
34
|
-
: format === undefined
|
|
35
|
-
? 'It could not be read.'
|
|
36
|
-
: 'Its identity is current but its contents failed verification.';
|
|
37
|
-
return new Error(`Host ledger verification failed at ${name}; ${detail}\nDestination left untouched. Migration is not a repair command. Keep the affected sessions and MCP services stopped, preserve the ledger, and diagnose the underlying file before retrying.`);
|
|
38
|
-
}
|
|
39
|
-
async function verifyDatabase(file, root, signal) {
|
|
40
|
-
abort(signal);
|
|
41
|
-
let db;
|
|
42
|
-
try {
|
|
43
|
-
db = new DatabaseSync(file, { readOnly: true });
|
|
44
|
-
const counts = await inSqliteTransaction(db, false, () => validateLedger(db), () => verifyLedger(db), signal);
|
|
45
|
-
return { status: 'sqlite', rootPath: root, ...counts };
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
abort(signal);
|
|
49
|
-
let format;
|
|
50
|
-
try {
|
|
51
|
-
db = new DatabaseSync(file, { readOnly: true });
|
|
52
|
-
format = inspectLedgerIdentity(db);
|
|
53
|
-
db.close();
|
|
54
|
-
db = undefined;
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
db?.close();
|
|
58
|
-
db = undefined;
|
|
59
|
-
}
|
|
60
|
-
if (format === 'old-sqlite')
|
|
61
|
-
throw migrationRequired(root);
|
|
62
|
-
throw verificationFailure(root, file, format);
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
db?.close();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async function readLegacy(root, kind, signal) {
|
|
69
|
-
let bytes;
|
|
70
|
-
try {
|
|
71
|
-
bytes = await fs.readFile(path.join(root, `${kind}.ndjsonl`));
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
if (error.code === 'ENOENT')
|
|
75
|
-
return { rows: [], report: { records: 0, ignored: 0, rejected: 0, sha256: null } };
|
|
76
|
-
throw new Error(`Cannot read legacy ${kind} source.`);
|
|
77
|
-
}
|
|
78
|
-
const rows = [];
|
|
79
|
-
let ignored = 0, rejected = 0;
|
|
80
|
-
let firstRejectedLine;
|
|
81
|
-
const lines = bytes.toString('utf8').split('\n');
|
|
82
|
-
for (let index = 0; index < lines.length; index++) {
|
|
83
|
-
abort(signal);
|
|
84
|
-
if (lines[index].trim() === '')
|
|
85
|
-
continue;
|
|
86
|
-
let row;
|
|
87
|
-
try {
|
|
88
|
-
row = JSON.parse(lines[index]);
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
ignored++;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
if (row === null || typeof row !== 'object' || row.v !== 1 || typeof (row.at ?? row.updatedAt) !== 'number') {
|
|
95
|
-
ignored++;
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
// This compatibility normalization belongs only to the explicit importer.
|
|
99
|
-
if (row.kind === 'wake' && row.outcome === 'unknown' && row.unknownSource === undefined) {
|
|
100
|
-
row = { ...row, unknownSource: row.signature === 'worker_interrupted_during_dispatch' ? 'interrupted' : 'transport' };
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
ledgerRecordColumns(kind, row);
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
rejected++;
|
|
107
|
-
firstRejectedLine ??= index + 1;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
rows.push(row);
|
|
111
|
-
}
|
|
112
|
-
return { rows, firstRejectedLine, report: { records: rows.length, ignored, rejected, sha256: createHash('sha256').update(bytes).digest('hex') } };
|
|
113
|
-
}
|
|
114
|
-
async function readSources(root, signal) {
|
|
115
|
-
return { presence: await readLegacy(root, 'presence', signal), evidence: await readLegacy(root, 'evidence', signal) };
|
|
116
|
-
}
|
|
117
|
-
function sourceReport(root, sources) {
|
|
118
|
-
return {
|
|
119
|
-
status: sources.presence.report.sha256 === null && sources.evidence.report.sha256 === null ? 'empty' : 'legacy',
|
|
120
|
-
rootPath: root,
|
|
121
|
-
presence: sources.presence.rows.length, evidence: sources.evidence.rows.length,
|
|
122
|
-
sources: { presence: sources.presence.report, evidence: sources.evidence.report },
|
|
123
|
-
ready: sources.presence.report.rejected === 0 && sources.evidence.report.rejected === 0,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/** Read-only readiness/integrity check. Never creates a root, lock, or database. */
|
|
127
|
-
export async function verifyHostLedger(options = {}) {
|
|
128
|
-
const root = rootFor(options);
|
|
129
|
-
abort(options.signal);
|
|
130
|
-
const destination = path.join(root, LEDGER_FILENAME);
|
|
131
|
-
if (await exists(destination))
|
|
132
|
-
return verifyDatabase(destination, root, options.signal);
|
|
133
|
-
return sourceReport(root, await readSources(root, options.signal));
|
|
134
|
-
}
|
|
135
|
-
/** The fixed offline fence: ownership claim, then both legacy source locks, in that order. */
|
|
136
|
-
function withOfflineLocks(root, signal, body) {
|
|
137
|
-
const lockOptions = { retryMs: 10, signal };
|
|
138
|
-
return withFileLock(path.join(root, 'presence-claim.lock'), lockOptions, () => withFileLock(path.join(root, 'presence.ndjsonl.lock'), lockOptions, () => withFileLock(path.join(root, 'evidence.ndjsonl.lock'), lockOptions, body)))
|
|
139
|
-
.catch((error) => { abort(signal); throw error; });
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Under the offline fence: a current ledger verifies read-only, an older SQLite format is upgraded in
|
|
143
|
-
* place through the explicit transaction owner, and anything else is refused without repair.
|
|
144
|
-
*/
|
|
145
|
-
async function currentFormat(root, signal) {
|
|
146
|
-
const destination = path.join(root, LEDGER_FILENAME);
|
|
147
|
-
try {
|
|
148
|
-
return await verifyDatabase(destination, root, signal);
|
|
149
|
-
}
|
|
150
|
-
catch {
|
|
151
|
-
abort(signal);
|
|
152
|
-
}
|
|
153
|
-
if (!await exists(destination))
|
|
154
|
-
throw verificationFailure(root);
|
|
155
|
-
let db;
|
|
156
|
-
try {
|
|
157
|
-
db = new DatabaseSync(destination);
|
|
158
|
-
const upgraded = await inSqliteTransaction(db, true, () => { }, () => upgradeLedger(db), signal);
|
|
159
|
-
db.close();
|
|
160
|
-
db = undefined;
|
|
161
|
-
return { ...await verifyDatabase(destination, root, signal), status: upgraded ? 'upgraded' : 'sqlite' };
|
|
162
|
-
}
|
|
163
|
-
catch {
|
|
164
|
-
abort(signal);
|
|
165
|
-
throw verificationFailure(root, destination);
|
|
166
|
-
}
|
|
167
|
-
finally {
|
|
168
|
-
db?.close();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/** Offline only: locks fence compatible writers, but do not prove hosts have stopped. */
|
|
172
|
-
export async function migrateHostLedger(options = {}) {
|
|
173
|
-
const root = rootFor(options), signal = options.signal;
|
|
174
|
-
abort(signal);
|
|
175
|
-
const destination = path.join(root, LEDGER_FILENAME);
|
|
176
|
-
if (await exists(destination)) {
|
|
177
|
-
try {
|
|
178
|
-
return await verifyDatabase(destination, root, signal);
|
|
179
|
-
}
|
|
180
|
-
catch {
|
|
181
|
-
abort(signal);
|
|
182
|
-
}
|
|
183
|
-
// Inspect only the database identity; record/schema verification remains the migration fence.
|
|
184
|
-
let format;
|
|
185
|
-
let probe;
|
|
186
|
-
try {
|
|
187
|
-
probe = new DatabaseSync(destination, { readOnly: true });
|
|
188
|
-
format = inspectLedgerIdentity(probe);
|
|
189
|
-
}
|
|
190
|
-
catch {
|
|
191
|
-
format = undefined;
|
|
192
|
-
}
|
|
193
|
-
finally {
|
|
194
|
-
probe?.close();
|
|
195
|
-
}
|
|
196
|
-
if (format === 'old-sqlite') {
|
|
197
|
-
// Only the supported prior format enters the existing offline upgrade fence.
|
|
198
|
-
return withOfflineLocks(root, signal, () => currentFormat(root, signal));
|
|
199
|
-
}
|
|
200
|
-
throw verificationFailure(root, destination, format);
|
|
201
|
-
}
|
|
202
|
-
if (!await exists(path.join(root, 'presence.ndjsonl')) && !await exists(path.join(root, 'evidence.ndjsonl'))) {
|
|
203
|
-
return { status: 'empty', rootPath: root, presence: 0, evidence: 0 };
|
|
204
|
-
}
|
|
205
|
-
return withOfflineLocks(root, signal, () => convertLegacy(root, destination, signal));
|
|
206
|
-
}
|
|
207
|
-
/** The offline NDJSON import: build, verify and publish a new database without touching sources. */
|
|
208
|
-
async function convertLegacy(root, destination, signal) {
|
|
209
|
-
if (await exists(destination))
|
|
210
|
-
return currentFormat(root, signal);
|
|
211
|
-
const sources = await readSources(root, signal);
|
|
212
|
-
const report = sourceReport(root, sources);
|
|
213
|
-
if (!report.ready) {
|
|
214
|
-
const rejected = ['presence', 'evidence'].filter((kind) => sources[kind].report.rejected > 0)
|
|
215
|
-
.map((kind) => `${kind}: ${sources[kind].report.rejected} rejected (first line ${sources[kind].firstRejectedLine})`);
|
|
216
|
-
throw new Error(`Unsafe legacy records; conversion refused. ${rejected.join('; ')}.`);
|
|
217
|
-
}
|
|
218
|
-
const temporary = await fs.mkdtemp(path.join(root, '.host-ledger-migrate-'));
|
|
219
|
-
const file = path.join(temporary, LEDGER_FILENAME);
|
|
220
|
-
let db;
|
|
221
|
-
try {
|
|
222
|
-
abort(signal);
|
|
223
|
-
// The temporary connection remains under the ledger root, including journals.
|
|
224
|
-
await fs.writeFile(file, '', { flag: 'wx', mode: 0o600 });
|
|
225
|
-
db = new DatabaseSync(file);
|
|
226
|
-
initializeLedger(db);
|
|
227
|
-
await inSqliteTransaction(db, true, () => { }, () => {
|
|
228
|
-
for (const kind of ['presence', 'evidence']) {
|
|
229
|
-
for (const row of sources[kind].rows) {
|
|
230
|
-
abort(signal);
|
|
231
|
-
insertLedgerRecord(db, kind, row);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
setLedgerRevisions(db, { presence: report.presence ? 1 : 0, evidence: report.evidence ? 1 : 0 });
|
|
235
|
-
}, signal);
|
|
236
|
-
db.close();
|
|
237
|
-
db = undefined;
|
|
238
|
-
const verified = await verifyDatabase(file, root, signal);
|
|
239
|
-
if (verified.presence !== report.presence || verified.evidence !== report.evidence) {
|
|
240
|
-
throw new Error('Host ledger import counts do not match; conversion refused.');
|
|
241
|
-
}
|
|
242
|
-
abort(signal);
|
|
243
|
-
try {
|
|
244
|
-
await fs.link(file, destination);
|
|
245
|
-
}
|
|
246
|
-
catch (error) {
|
|
247
|
-
if (error.code === 'EEXIST')
|
|
248
|
-
return await verifyDatabase(destination, root, signal);
|
|
249
|
-
throw error;
|
|
250
|
-
}
|
|
251
|
-
const directory = await fs.open(root, 'r');
|
|
252
|
-
try {
|
|
253
|
-
await directory.sync();
|
|
254
|
-
}
|
|
255
|
-
finally {
|
|
256
|
-
await directory.close();
|
|
257
|
-
}
|
|
258
|
-
return { ...verified, status: 'migrated', sources: report.sources };
|
|
259
|
-
}
|
|
260
|
-
finally {
|
|
261
|
-
db?.close();
|
|
262
|
-
await fs.rm(temporary, { recursive: true, force: true });
|
|
263
|
-
}
|
|
264
|
-
}
|
package/dist/host-ledger-root.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
|
-
/** Resolve the single user-level host ledger root. */
|
|
4
|
-
export function hostLedgerRoot(env = process.env) {
|
|
5
|
-
return env.SQUARE_HOST_LEDGER_ROOT
|
|
6
|
-
?? (env.SQUARE_REGISTRY === undefined
|
|
7
|
-
? path.join(homedir(), '.square', 'host-ledger')
|
|
8
|
-
: path.dirname(env.SQUARE_REGISTRY));
|
|
9
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { DatabaseSync, type SQLInputValue } from 'node:sqlite';
|
|
2
|
-
import type { PresenceRecord, PresenceLookup, EvidenceRecord, EvidenceLookup, NativeTokenLookup, NativeTokenResult } from './host-ledger.js';
|
|
3
|
-
export declare const LEDGER_FILENAME = "host-ledger.sqlite";
|
|
4
|
-
export declare const LEDGER_APPLICATION_ID = 1397835852;
|
|
5
|
-
export declare const LEDGER_VERSION = 2;
|
|
6
|
-
export declare const LEDGER_RETENTION: number;
|
|
7
|
-
type Kind = 'presence' | 'evidence';
|
|
8
|
-
export interface Stored<T> {
|
|
9
|
-
readonly seq: number;
|
|
10
|
-
readonly record: T;
|
|
11
|
-
}
|
|
12
|
-
export type HostLedgerFormat = 'current' | 'old-sqlite' | 'unrelated' | 'unsupported';
|
|
13
|
-
/** The complete record remains authority; these are only reproducible lookup projections. */
|
|
14
|
-
export declare function ledgerRecordColumns(kind: Kind, input: object): Record<string, SQLInputValue>;
|
|
15
|
-
export declare function initializeLedger(db: DatabaseSync): void;
|
|
16
|
-
export declare function setLedgerRevisions(db: DatabaseSync, revisions: {
|
|
17
|
-
presence: number;
|
|
18
|
-
evidence: number;
|
|
19
|
-
}): void;
|
|
20
|
-
export declare function insertLedgerRecord(db: DatabaseSync, kind: Kind, row: object): void;
|
|
21
|
-
export declare function ledgerRevisions(db: DatabaseSync): {
|
|
22
|
-
presence: number;
|
|
23
|
-
evidence: number;
|
|
24
|
-
};
|
|
25
|
-
export declare function validateLedger(db: DatabaseSync): void;
|
|
26
|
-
export declare function verifyLedger(db: DatabaseSync): {
|
|
27
|
-
presence: number;
|
|
28
|
-
evidence: number;
|
|
29
|
-
presenceRevision: number;
|
|
30
|
-
evidenceRevision: number;
|
|
31
|
-
};
|
|
32
|
-
/** Read the file-type stamp and format version without making the runtime authority. */
|
|
33
|
-
export declare function inspectLedgerIdentity(db: DatabaseSync): HostLedgerFormat;
|
|
34
|
-
/** Explicit offline migration only; the caller owns the write transaction. Preserve all records and revisions. */
|
|
35
|
-
export declare function upgradeLedger(db: DatabaseSync): boolean;
|
|
36
|
-
export declare function migrationRequired(root: string): Error;
|
|
37
|
-
/** Transaction-local storage rows; sequence coordinates never cross HostLedgerPort. */
|
|
38
|
-
export declare class LedgerTransaction {
|
|
39
|
-
private readonly db;
|
|
40
|
-
private readonly changed;
|
|
41
|
-
constructor(db: DatabaseSync);
|
|
42
|
-
presence(input: PresenceLookup & {
|
|
43
|
-
channel?: string;
|
|
44
|
-
}, now: number, includeFuture?: boolean): Stored<PresenceRecord>[];
|
|
45
|
-
evidence(input: EvidenceLookup & {
|
|
46
|
-
claimToken?: string;
|
|
47
|
-
}, now: number, includeFuture?: boolean): Stored<EvidenceRecord>[];
|
|
48
|
-
private select;
|
|
49
|
-
/** Both halves of recognition are read in the enclosing SQLite snapshot, with indexed session/token predicates. */
|
|
50
|
-
nativeTokens(input: NativeTokenLookup): NativeTokenResult;
|
|
51
|
-
/** Called only after exact-record CAS. No housekeeping of unrelated rows belongs here. */
|
|
52
|
-
retireEvidence(row: Stored<EvidenceRecord>): boolean;
|
|
53
|
-
insert(kind: Kind, row: object): void;
|
|
54
|
-
replace(kind: Kind, seq: number, row: object): void;
|
|
55
|
-
remove(kind: Kind, rows: readonly Stored<unknown>[]): void;
|
|
56
|
-
/** Only invoke at the point where the former implementation published a mutation. */
|
|
57
|
-
publish(kind: Kind, now: number): void;
|
|
58
|
-
commitRevisions(): void;
|
|
59
|
-
}
|
|
60
|
-
export declare function withLedger<T>(root: string, write: boolean, select: (rows: LedgerTransaction) => T, absent: T, signal?: AbortSignal): Promise<T>;
|
|
61
|
-
export declare function readLedgerRevisions(root: string, signal?: AbortSignal): Promise<{
|
|
62
|
-
presence: number;
|
|
63
|
-
evidence: number;
|
|
64
|
-
} | undefined>;
|
|
65
|
-
export {};
|