@jini-ai/db 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -10
- package/dist/core/artifact-naming.d.ts +4 -1
- package/dist/core/artifact-naming.js +3 -4
- package/dist/core/index.d.ts +1 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/pg-types.d.ts +52 -0
- package/dist/core/pg-types.js +8 -0
- package/dist/core/transfer-naming.d.ts +10 -0
- package/dist/core/transfer-naming.js +2 -0
- package/dist/kernel/dialect.d.ts +2 -1
- package/dist/kernel/dialect.js +5 -2
- package/dist/kernel/postgres/driver.d.ts +1 -1
- package/dist/kernel/postgres/driver.js +1 -1
- package/dist/kernel/postgres/pglite-socket.d.ts +1 -1
- package/dist/kernel/postgres/pglite-socket.js +1 -1
- package/dist/pg-fixture.d.ts +50 -0
- package/dist/pg-fixture.js +84 -0
- package/dist/pglite/owner.js +7 -0
- package/dist/postgres/index.d.ts +1 -1
- package/dist/postgres/index.js +1 -1
- package/dist/postgres/types.d.ts +1 -52
- package/dist/postgres/types.js +2 -13
- package/dist/recovery/deep-link.d.ts +60 -0
- package/dist/recovery/deep-link.js +16 -0
- package/dist/recovery/degraded-banners.d.ts +40 -0
- package/dist/recovery/degraded-banners.js +69 -0
- package/dist/recovery/disclosure.d.ts +58 -0
- package/dist/recovery/disclosure.js +55 -0
- package/dist/recovery/evaluate-boot-migration-policy.d.ts +41 -0
- package/dist/recovery/evaluate-boot-migration-policy.js +50 -0
- package/dist/recovery/hook-policy.d.ts +9 -0
- package/dist/recovery/hook-policy.js +2 -0
- package/dist/recovery/index.d.ts +15 -0
- package/dist/recovery/index.js +13 -0
- package/dist/recovery/lookup-adapters.d.ts +40 -0
- package/dist/recovery/lookup-adapters.js +44 -0
- package/dist/recovery/migrate-forward-execute.d.ts +65 -0
- package/dist/recovery/migrate-forward-execute.js +68 -0
- package/dist/recovery/migrate-forward-hooks.d.ts +118 -0
- package/dist/recovery/migrate-forward-hooks.js +85 -0
- package/dist/recovery/operation-lock.d.ts +78 -0
- package/dist/recovery/operation-lock.js +58 -0
- package/dist/recovery/reconcile-interrupted-migration.d.ts +73 -0
- package/dist/recovery/reconcile-interrupted-migration.js +47 -0
- package/dist/recovery/recovery-orchestrator.d.ts +204 -0
- package/dist/recovery/recovery-orchestrator.js +96 -0
- package/dist/recovery/restore-hooks.d.ts +105 -0
- package/dist/recovery/restore-hooks.js +154 -0
- package/dist/recovery/restore-point-create.d.ts +80 -0
- package/dist/recovery/restore-point-create.js +37 -0
- package/dist/sqlite/open.d.ts +1 -1
- package/dist/sqlite/open.js +3 -3
- package/dist/sqlite/restore-types.d.ts +7 -3
- package/dist/tools/read-tools.js +7 -4
- package/dist/tools/restore-points.d.ts +3 -0
- package/dist/tools/restore-points.js +2 -2
- package/dist/tools/surface-port.d.ts +11 -29
- package/dist/tools/timeline.d.ts +4 -0
- package/dist/tools/timeline.js +8 -2
- package/dist/tools/transfer-tools.js +36 -37
- package/dist/transfer/internal-ddl.d.ts +3 -0
- package/dist/transfer/internal-ddl.js +6 -2
- package/dist/transfer/types.d.ts +3 -9
- package/package.json +48 -6
- package/dist/kernel/pg-types.d.ts +0 -22
- package/dist/kernel/pg-types.js +0 -26
- package/dist/kernel/socket.d.ts +0 -8
- package/dist/kernel/socket.js +0 -8
- package/dist/pglite/dialect.d.ts +0 -11
- package/dist/pglite/dialect.js +0 -88
- package/dist/pglite/driver.d.ts +0 -30
- package/dist/pglite/driver.js +0 -46
- package/dist/pglite/ops.d.ts +0 -39
- package/dist/pglite/ops.js +0 -78
- package/dist/postgres/driver.d.ts +0 -23
- package/dist/postgres/driver.js +0 -41
- package/dist/postgres/ops.d.ts +0 -12
- package/dist/postgres/ops.js +0 -46
- package/dist/postgres/pglite-socket.d.ts +0 -23
- package/dist/postgres/pglite-socket.js +0 -51
- package/dist/sqlite/driver.d.ts +0 -71
- package/dist/sqlite/driver.js +0 -132
- package/dist/sqlite/ops.d.ts +0 -12
- package/dist/sqlite/ops.js +0 -40
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C-301/CIC U-003 — `plan()` step. Never reaches the gateway when a fresh `costClass` recheck
|
|
3
|
+
* reports `'unavailable'` (U-003-ORD1); `'expensive'` still reaches it (only `'unavailable'`
|
|
4
|
+
* short-circuits, per ADR-041 §2's "no attestation override" carried into this domain).
|
|
5
|
+
*
|
|
6
|
+
* @complexity O(1) plus one `getCapabilities()` call and, when not short-circuited, one
|
|
7
|
+
* `gateway.plan()` call.
|
|
8
|
+
*/
|
|
9
|
+
export async function planRestore(required, _optional = {}) {
|
|
10
|
+
const { deps, input } = required;
|
|
11
|
+
const capabilities = await deps.dbOps.getCapabilities();
|
|
12
|
+
if (capabilities.costClass === "unavailable") {
|
|
13
|
+
return {
|
|
14
|
+
ok: false,
|
|
15
|
+
error: {
|
|
16
|
+
code: "COST_CLASS_UNAVAILABLE",
|
|
17
|
+
message: `restore point '${input.restorePointId}' has no available restore mechanism for this site (no attestation override)`,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return deps.gateway.plan({
|
|
22
|
+
principalId: input.principalId,
|
|
23
|
+
principalKind: input.principalKind,
|
|
24
|
+
restorePointId: input.restorePointId,
|
|
25
|
+
costClass: capabilities.costClass,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* C-302/CIC U-002 — `confirm()` step. `disclosureAcknowledged` must be exactly `true` (a truthy
|
|
30
|
+
* non-boolean, e.g. the string `"true"`, is rejected — U-002-B1's exact wording) before the
|
|
31
|
+
* gateway is ever consulted; plan provenance (whether `planId` was actually minted by this
|
|
32
|
+
* server's own `planRestore`) is verified entirely by the injected gateway, never re-derived or
|
|
33
|
+
* short-circuit-trusted here (U-002-ORD1).
|
|
34
|
+
*
|
|
35
|
+
* @complexity O(1) plus, when the acknowledgment gate passes, one `gateway.confirm()` call.
|
|
36
|
+
*/
|
|
37
|
+
export async function confirmRestore(required, _optional = {}) {
|
|
38
|
+
const { deps, input } = required;
|
|
39
|
+
if (input.disclosureAcknowledged !== true) {
|
|
40
|
+
return {
|
|
41
|
+
ok: false,
|
|
42
|
+
error: {
|
|
43
|
+
code: "VALIDATION_ERROR",
|
|
44
|
+
message: "disclosureAcknowledged must be exactly true before a restore confirmation token may be minted",
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return deps.gateway.confirm({ planId: input.planId, planHash: input.planHash });
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* C-303/CIC U-001-ORD1 — `execute()` step. Acquires the shared cross-domain operation lock BEFORE
|
|
52
|
+
* the gateway's own `execute()` runs, and releases it in a `finally` regardless of outcome (never
|
|
53
|
+
* leaks a held lock). Never calls `pendingMigrationTracker.clearPendingMigration()` — a restore to
|
|
54
|
+
* an older snapshot does not, by itself, resolve schema drift against the current runtime
|
|
55
|
+
* (ADR-045 §4).
|
|
56
|
+
*
|
|
57
|
+
* @complexity O(1) plus one lock acquire/release pair and one `gateway.execute()` call.
|
|
58
|
+
*/
|
|
59
|
+
export async function executeRestore(required, _optional = {}) {
|
|
60
|
+
const { deps, input } = required;
|
|
61
|
+
const acquireResult = await deps.operationLock.acquireOperationLock({
|
|
62
|
+
deps: { clock: deps.clock },
|
|
63
|
+
input: { siteId: input.siteId, operationKind: "restore" },
|
|
64
|
+
});
|
|
65
|
+
if (!acquireResult.ok) {
|
|
66
|
+
return {
|
|
67
|
+
ok: false,
|
|
68
|
+
error: {
|
|
69
|
+
code: "RESTORE_OPERATION_IN_FLIGHT",
|
|
70
|
+
message: acquireResult.error.message ?? `an operation is already in flight for site '${input.siteId}'`,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const confirmerPrincipalId = input.principalKind === "agent" ? input.delegatedByPrincipalId : input.principalId;
|
|
76
|
+
const executeResult = await deps.gateway.execute({
|
|
77
|
+
confirmationToken: input.confirmationToken,
|
|
78
|
+
...(confirmerPrincipalId !== undefined ? { confirmerPrincipalId } : {}),
|
|
79
|
+
});
|
|
80
|
+
if (!executeResult.ok) {
|
|
81
|
+
return executeResult;
|
|
82
|
+
}
|
|
83
|
+
const value = { ...executeResult.value };
|
|
84
|
+
if (value.state === "RESTORED") {
|
|
85
|
+
value.databaseTimelineDeepLink = { v: 1, siteId: input.siteId, intent: "view" };
|
|
86
|
+
}
|
|
87
|
+
return { ok: true, value };
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
await deps.operationLock.releaseOperationLock({
|
|
91
|
+
deps: { clock: deps.clock },
|
|
92
|
+
input: { siteId: input.siteId, handle: acquireResult.value },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=recovery-orchestrator.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Clock as ClockPort, IdGenerator as IdGeneratorPort } from "@jini-ai/core/primitives";
|
|
2
|
+
import { type GatedMutationHooks } from "@jini-ai/core/gated-mutations";
|
|
3
|
+
import type { RecoveryHookPolicy } from "./hook-policy.js";
|
|
4
|
+
import type { MigrationRunsRepoPort, SiteStatusPort } from "./reconcile-interrupted-migration.js";
|
|
5
|
+
import type { LedgerAppendPort } from "./migrate-forward-hooks.js";
|
|
6
|
+
/**
|
|
7
|
+
* @file Recovery's `GatedMutationHooks` factory for the `restore` ceremony (SPEC-019 C-301/C-303),
|
|
8
|
+
* plus `toRecoveryResult` (the throwing-gateway-to-`Result` adapter `recovery-orchestrator.ts`'s
|
|
9
|
+
* ports declare) — the domain-specific quarter of what used to be
|
|
10
|
+
* `server/gated-mutations-composition.ts`, split out so Recovery no longer needs a back-edge into
|
|
11
|
+
* `server/` for its own hook builder. The generic pieces every ceremony shares (`buildGatewayDeps`,
|
|
12
|
+
* `planHashOf`, `resolveActorClassIdentity`, `buildConfirmOnlyHooks`) stayed in
|
|
13
|
+
* `core/gated-mutations/composition.ts`, which this file imports from — the correct direction (a
|
|
14
|
+
* domain depending on `core`), unlike the old direction (a domain depending on `server`).
|
|
15
|
+
*
|
|
16
|
+
* `LedgerAppendPort` is imported from `features/database/gated-hooks.ts` rather than duplicated —
|
|
17
|
+
* Recovery already imports several other Database-owned ports (`restore-points.ts`,
|
|
18
|
+
* `boot/reconcile-interrupted-migration.ts`), so this is the established "Recovery depends on
|
|
19
|
+
* Database, never the reverse" direction, not a new one.
|
|
20
|
+
*/
|
|
21
|
+
export interface BuildRestoreHooksInput extends RecoveryHookPolicy {
|
|
22
|
+
workspaceId: string;
|
|
23
|
+
actorId: string;
|
|
24
|
+
restorePointId: string;
|
|
25
|
+
clock: ClockPort;
|
|
26
|
+
idGen: IdGeneratorPort;
|
|
27
|
+
restorePointsRepo: {
|
|
28
|
+
list(): Promise<Array<{
|
|
29
|
+
id: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
artifactRef: string;
|
|
32
|
+
}>>;
|
|
33
|
+
};
|
|
34
|
+
databaseLedgerRepo: LedgerAppendPort;
|
|
35
|
+
/** SPEC-016 `DbOpsPort` — real (SQLite) composition performs the physical file swap;
|
|
36
|
+
* hermetic-test composition's in-memory double is a no-op (`restartRequired: false`). */
|
|
37
|
+
dbOps: {
|
|
38
|
+
restoreFromArtifact(required: {
|
|
39
|
+
artifactRef: string;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
restartRequired: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
};
|
|
44
|
+
/** Round-5 re-audit (2026-07-16, TM-adr041-043-044-045-audit-001, R5-F2 / Fable
|
|
45
|
+
* `R5-F2-BLOCK-HAS-NO-EXIT` fix): a successful restore must actually exit
|
|
46
|
+
* `BLOCKED_PENDING_RECOVERY` — before this fix, nothing did. */
|
|
47
|
+
migrationRunsRepo: Pick<MigrationRunsRepoPort, "findNonTerminalForSite" | "markResolved">;
|
|
48
|
+
siteStatus: SiteStatusPort;
|
|
49
|
+
}
|
|
50
|
+
export declare class RestorePointNotFoundError extends Error {
|
|
51
|
+
constructor(message: string);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* SPEC-019 C-301/C-303 — the Recovery `restore` ceremony's `GatedMutationHooks`.
|
|
55
|
+
*
|
|
56
|
+
* `executeMutation()` is a deliberately, disclosedly SCOPED implementation: it validates the
|
|
57
|
+
* target restore point still exists and records a real `restore.executed` `database_ledger` row —
|
|
58
|
+
* the honest, auditable half of a restore. It does NOT physically overwrite the live `content.db`
|
|
59
|
+
* file. This codebase has no mechanism to hot-swap the shared, already-open `content.db`
|
|
60
|
+
* connection every other repo across `server/deps.ts` holds a reference to (doing so would either
|
|
61
|
+
* crash every other in-flight request against a closed handle, or silently leave every existing
|
|
62
|
+
* repo instance reading the stale pre-restore file) — inventing an unreviewed live-swap or
|
|
63
|
+
* process-restart mechanism here is exactly the kind of unrequested architecture this dispatch's
|
|
64
|
+
* own guardrails warn against, and ADR-041/ADR-045 do not pin a specific mechanism for it either.
|
|
65
|
+
* `[CIC_REQUESTED]` Unit=gated-mutations-composition Trigger=recovery restore execute
|
|
66
|
+
* Property=REQ-06/AC-XX "a confirmed restore actually replaces content.db's data"
|
|
67
|
+
* PlausibleWrong=silently faking a full hot restore, or crashing the process mid-request
|
|
68
|
+
* MissingConstraint=a defined live-swap-or-restart mechanism for the shared `content.db`
|
|
69
|
+
* connection Evidence=ADR-041 §2 (`content.db` restore = whole-file copy), ADR-045 §3, this file.
|
|
70
|
+
* The plan -> confirm -> execute ceremony itself (token flow, authorize, operation-lock,
|
|
71
|
+
* disclosure-acknowledgment gate) is fully real and this file's own test coverage exercises it
|
|
72
|
+
* end-to-end; only the final byte-for-byte file replacement is the disclosed gap.
|
|
73
|
+
*
|
|
74
|
+
* `scopeKind: "instance"` (internal audit, 2026-08-12): `dbOps.restoreFromArtifact` (`db/sqlite/
|
|
75
|
+
* db-ops.ts`) physically swaps the entire `content.db` file, and a `content.db` can hold more
|
|
76
|
+
* than one workspace row (`site-dir/resolve-workspace.ts`, ADR-007, SPEC-044's admin CRUD). A
|
|
77
|
+
* principal authorized only within one workspace has no standing to replace data belonging to
|
|
78
|
+
* every OTHER workspace that file also holds — the ordinary workspace-scoped `authorize()` this
|
|
79
|
+
* hook used before would either deny every principal (no real workspace ever matches a
|
|
80
|
+
* whole-instance operation) or let one workspace's admin approve a cross-tenant file swap. See
|
|
81
|
+
* `core/gated-mutations/gateway.ts`'s `GatedMutationHooks.scopeKind` and `core/gated-mutations/
|
|
82
|
+
* composition.ts`'s `buildOwnerOnlyInstanceAuthorize` for the evaluator this now routes through.
|
|
83
|
+
*
|
|
84
|
+
* @complexity O(n) in the number of restore points (one `list()` scan per `computePlan` and per
|
|
85
|
+
* `executeMutation` — low-volume, ADR-041 §2).
|
|
86
|
+
*/
|
|
87
|
+
export declare function buildRestoreHooks(input: BuildRestoreHooksInput, _optional?: Record<string, never>): GatedMutationHooks<{
|
|
88
|
+
restorePointId: string;
|
|
89
|
+
}, {
|
|
90
|
+
restoreRunId: string;
|
|
91
|
+
state: string;
|
|
92
|
+
restartRequired: boolean;
|
|
93
|
+
}>;
|
|
94
|
+
export type { RecoveryErrorPayload } from "./recovery-orchestrator.js";
|
|
95
|
+
import type { RecoveryErrorPayload } from "./recovery-orchestrator.js";
|
|
96
|
+
export declare function toRecoveryResult<T>({ run }: {
|
|
97
|
+
run: () => Promise<T>;
|
|
98
|
+
}, _optional?: Record<string, never>): Promise<{
|
|
99
|
+
ok: true;
|
|
100
|
+
value: T;
|
|
101
|
+
} | {
|
|
102
|
+
ok: false;
|
|
103
|
+
error: RecoveryErrorPayload;
|
|
104
|
+
}>;
|
|
105
|
+
//# sourceMappingURL=restore-hooks.d.ts.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { nowIso as clockNowIso } from "@jini-ai/core/primitives";
|
|
2
|
+
import { ForbiddenError, PlanStaleError, } from "@jini-ai/core/gated-mutations";
|
|
3
|
+
import { TokenAlreadyRedeemedError, TokenExpiredError } from "@jini-ai/core/gated-mutations";
|
|
4
|
+
export class RestorePointNotFoundError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "RestorePointNotFoundError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* SPEC-019 C-301/C-303 — the Recovery `restore` ceremony's `GatedMutationHooks`.
|
|
12
|
+
*
|
|
13
|
+
* `executeMutation()` is a deliberately, disclosedly SCOPED implementation: it validates the
|
|
14
|
+
* target restore point still exists and records a real `restore.executed` `database_ledger` row —
|
|
15
|
+
* the honest, auditable half of a restore. It does NOT physically overwrite the live `content.db`
|
|
16
|
+
* file. This codebase has no mechanism to hot-swap the shared, already-open `content.db`
|
|
17
|
+
* connection every other repo across `server/deps.ts` holds a reference to (doing so would either
|
|
18
|
+
* crash every other in-flight request against a closed handle, or silently leave every existing
|
|
19
|
+
* repo instance reading the stale pre-restore file) — inventing an unreviewed live-swap or
|
|
20
|
+
* process-restart mechanism here is exactly the kind of unrequested architecture this dispatch's
|
|
21
|
+
* own guardrails warn against, and ADR-041/ADR-045 do not pin a specific mechanism for it either.
|
|
22
|
+
* `[CIC_REQUESTED]` Unit=gated-mutations-composition Trigger=recovery restore execute
|
|
23
|
+
* Property=REQ-06/AC-XX "a confirmed restore actually replaces content.db's data"
|
|
24
|
+
* PlausibleWrong=silently faking a full hot restore, or crashing the process mid-request
|
|
25
|
+
* MissingConstraint=a defined live-swap-or-restart mechanism for the shared `content.db`
|
|
26
|
+
* connection Evidence=ADR-041 §2 (`content.db` restore = whole-file copy), ADR-045 §3, this file.
|
|
27
|
+
* The plan -> confirm -> execute ceremony itself (token flow, authorize, operation-lock,
|
|
28
|
+
* disclosure-acknowledgment gate) is fully real and this file's own test coverage exercises it
|
|
29
|
+
* end-to-end; only the final byte-for-byte file replacement is the disclosed gap.
|
|
30
|
+
*
|
|
31
|
+
* `scopeKind: "instance"` (internal audit, 2026-08-12): `dbOps.restoreFromArtifact` (`db/sqlite/
|
|
32
|
+
* db-ops.ts`) physically swaps the entire `content.db` file, and a `content.db` can hold more
|
|
33
|
+
* than one workspace row (`site-dir/resolve-workspace.ts`, ADR-007, SPEC-044's admin CRUD). A
|
|
34
|
+
* principal authorized only within one workspace has no standing to replace data belonging to
|
|
35
|
+
* every OTHER workspace that file also holds — the ordinary workspace-scoped `authorize()` this
|
|
36
|
+
* hook used before would either deny every principal (no real workspace ever matches a
|
|
37
|
+
* whole-instance operation) or let one workspace's admin approve a cross-tenant file swap. See
|
|
38
|
+
* `core/gated-mutations/gateway.ts`'s `GatedMutationHooks.scopeKind` and `core/gated-mutations/
|
|
39
|
+
* composition.ts`'s `buildOwnerOnlyInstanceAuthorize` for the evaluator this now routes through.
|
|
40
|
+
*
|
|
41
|
+
* @complexity O(n) in the number of restore points (one `list()` scan per `computePlan` and per
|
|
42
|
+
* `executeMutation` — low-volume, ADR-041 §2).
|
|
43
|
+
*/
|
|
44
|
+
export function buildRestoreHooks(input, _optional = {}) {
|
|
45
|
+
return {
|
|
46
|
+
domain: "backup.restore",
|
|
47
|
+
readPermission: "backup.read",
|
|
48
|
+
mutatePermission: "backup.restore",
|
|
49
|
+
scopeId: input.workspaceId,
|
|
50
|
+
scopeKind: "instance",
|
|
51
|
+
// The plan refuses an unknown restore point itself: without this, a wrong id passed plan AND
|
|
52
|
+
// confirm (minting a real token) and only failed at execute. The gateway re-runs this at
|
|
53
|
+
// execute's plan re-derivation too, so a point deleted after confirm is caught there.
|
|
54
|
+
computePlan: async () => {
|
|
55
|
+
await findRestorePoint(input);
|
|
56
|
+
const details = { restorePointId: input.restorePointId };
|
|
57
|
+
return { planHash: input.planHashOf({ details }, {}), details };
|
|
58
|
+
},
|
|
59
|
+
executeMutation: async () => {
|
|
60
|
+
// Re-checked here, not trusted from the plan: the point can be deleted between execute's
|
|
61
|
+
// plan re-derivation and this mutation (token redemption runs in between).
|
|
62
|
+
const target = await findRestorePoint(input);
|
|
63
|
+
// 2026-07-16: closes the "ledger-only" gap this file previously disclosed — swap the file
|
|
64
|
+
// FIRST, ledger-record second. If the process dies between the two, the file already
|
|
65
|
+
// reflects reality (a missing ledger entry is reconcilable later; a ledger entry claiming a
|
|
66
|
+
// restore that never physically happened would not be).
|
|
67
|
+
const { restartRequired } = await input.dbOps.restoreFromArtifact({ artifactRef: target.artifactRef });
|
|
68
|
+
const restoreRunId = input.idGen.newId();
|
|
69
|
+
const now = clockNowIso({ clock: input.clock });
|
|
70
|
+
await input.databaseLedgerRepo.append({
|
|
71
|
+
id: input.idGen.newId(),
|
|
72
|
+
kind: "restore.executed",
|
|
73
|
+
restorePointId: input.restorePointId,
|
|
74
|
+
outcome: "success",
|
|
75
|
+
detailJson: JSON.stringify({ restoreRunId, restartRequired }),
|
|
76
|
+
actorWorkspaceId: input.workspaceId,
|
|
77
|
+
actorId: input.actorId,
|
|
78
|
+
createdAt: now,
|
|
79
|
+
});
|
|
80
|
+
// Round-5 re-audit (TM-adr041-043-044-045-audit-001, R5-F2 fix): a successful restore is the
|
|
81
|
+
// ceremony ADR-041 §3's own text names as how an operator "resolves" a crash-interrupted
|
|
82
|
+
// migration -- so it must actually exit BLOCKED_PENDING_RECOVERY, not just record a ledger
|
|
83
|
+
// row. Terminalize whatever non-terminal migration_runs row exists for this site (if any --
|
|
84
|
+
// a restore can also be run for reasons unrelated to a crash-interrupted migration, in which
|
|
85
|
+
// case there is nothing to resolve) so the next boot's findNonTerminalForSite no longer
|
|
86
|
+
// re-detects it.
|
|
87
|
+
//
|
|
88
|
+
// Round-6 re-audit (TM-adr041-043-044-045-audit-001, codex `R6-F1-RESTART-REQUIRED-RESTORE-
|
|
89
|
+
// UNBLOCKS-STALE-DB`, verified directly against `db-ops.ts`'s own doc comment): the DURABLE
|
|
90
|
+
// resolution (markResolved) and the IN-PROCESS unblock (siteStatus.set) are NOT the same
|
|
91
|
+
// thing and must not be conflated. `SqliteDbOpsAdapter.restoreFromArtifact` always returns
|
|
92
|
+
// `restartRequired: true` for a real file-backed db -- the running process keeps its open
|
|
93
|
+
// file descriptor pointed at the now-unlinked OLD inode until it restarts, so clearing the
|
|
94
|
+
// gate in-process here would let normal traffic resume against stale pre-restore data, with
|
|
95
|
+
// writes accepted in that window silently lost on the eventual restart. Only clear the
|
|
96
|
+
// in-process block when the restore genuinely didn't require one (memory-mode dev, or a
|
|
97
|
+
// future adapter that can restore live) -- when a restart IS required, the durable
|
|
98
|
+
// terminalization above is what makes the NEXT boot resolve to SERVING; the running process
|
|
99
|
+
// stays blocked (correctly) until then.
|
|
100
|
+
const nonTerminal = await input.migrationRunsRepo.findNonTerminalForSite(input.workspaceId);
|
|
101
|
+
if (nonTerminal) {
|
|
102
|
+
await input.migrationRunsRepo.markResolved({ id: nonTerminal.id });
|
|
103
|
+
if (!restartRequired) {
|
|
104
|
+
await input.siteStatus.set(input.workspaceId, "SERVING");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return { restoreRunId, state: "RESTORED", restartRequired };
|
|
108
|
+
},
|
|
109
|
+
resolveActorClassIdentity: input.resolveActorClassIdentity,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Looks up the restore point `input.restorePointId` names, throwing `RestorePointNotFoundError`
|
|
113
|
+
* when it does not exist. @complexity O(n) in restore points (one `list()` scan). */
|
|
114
|
+
async function findRestorePoint(input) {
|
|
115
|
+
const points = await input.restorePointsRepo.list();
|
|
116
|
+
const target = points.find((p) => p.id === input.restorePointId);
|
|
117
|
+
if (!target) {
|
|
118
|
+
throw new RestorePointNotFoundError(`restore point '${input.restorePointId}' was not found`);
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Adapts a throwing call against the real (throwing) `core/gated-mutations` gateway into the
|
|
124
|
+
* `Result<T, RecoveryErrorPayload>` shape `features/recovery/recovery-orchestrator.ts`'s
|
|
125
|
+
* `PlanRestoreGatewayPort`/`ConfirmRestoreGatewayPort`/`ExecuteRestoreGatewayPort` all declare —
|
|
126
|
+
* exactly the "Result-wrapped composition-root binding over the real throwing gateway" Session 4's
|
|
127
|
+
* progress-ledger entry named as still-owed future work. Maps each of `gateway.ts`'s typed thrown
|
|
128
|
+
* errors to a stable `code` string; every other error collapses to `INTERNAL_ERROR`.
|
|
129
|
+
*/
|
|
130
|
+
/** Maps one caught error to its stable `code` string — split out of {@link toRecoveryResult}'s
|
|
131
|
+
* `catch` block as a whole unit, not just its branchiest arm, since every arm here pays the same
|
|
132
|
+
* nesting cost inside a `catch`. */
|
|
133
|
+
function classifyRecoveryError(err) {
|
|
134
|
+
if (err instanceof ForbiddenError)
|
|
135
|
+
return { code: err.reasonCode, message: err.message };
|
|
136
|
+
if (err instanceof PlanStaleError)
|
|
137
|
+
return { code: "PLAN_STALE", message: err.message };
|
|
138
|
+
if (err instanceof TokenExpiredError)
|
|
139
|
+
return { code: "TOKEN_EXPIRED", message: err.message };
|
|
140
|
+
if (err instanceof TokenAlreadyRedeemedError)
|
|
141
|
+
return { code: "TOKEN_ALREADY_REDEEMED", message: err.message };
|
|
142
|
+
if (err instanceof RestorePointNotFoundError)
|
|
143
|
+
return { code: "RESTORE_POINT_NOT_FOUND", message: err.message };
|
|
144
|
+
return { code: "INTERNAL_ERROR", message: err instanceof Error ? err.message : "internal error" };
|
|
145
|
+
}
|
|
146
|
+
export async function toRecoveryResult({ run }, _optional = {}) {
|
|
147
|
+
try {
|
|
148
|
+
return { ok: true, value: await run() };
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
return { ok: false, error: classifyRecoveryError(err) };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=restore-hooks.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { PrincipalKind, Result } from "./recovery-orchestrator.js";
|
|
2
|
+
/**
|
|
3
|
+
* @file SPEC-019 C-304 / REQ-05 — `createRestorePoint`, an ordinary `authorize()`-gated mutation
|
|
4
|
+
* (ADR-045 §3, "backup.create" independent of any migration).
|
|
5
|
+
*
|
|
6
|
+
* Purpose:
|
|
7
|
+
* Structurally distinct from the gated restore ceremony (`recovery-orchestrator.ts`): this never
|
|
8
|
+
* calls the gateway's `plan()`/`confirm()`/`execute()` at all (AC-10) — it mints a restore point
|
|
9
|
+
* directly once `authorize()` and the shared-lock "no operation in flight" check both pass.
|
|
10
|
+
* `authorize()` runs on EVERY call, before the idempotency short-circuit (AC-11, SPEC-016 REQ-14)
|
|
11
|
+
* — a repeated idempotency key never skips re-authorization, only re-creation.
|
|
12
|
+
*
|
|
13
|
+
* How it relates to the project:
|
|
14
|
+
* `operationInFlight` is supplied by the caller (typically derived from the same shared
|
|
15
|
+
* `core/operation-lock` state `recovery-orchestrator.ts`'s `executeRestore` consults) rather than
|
|
16
|
+
* this module acquiring the lock itself — REQ-13's "extends here too, via `onBeforeCreateOrExecute`"
|
|
17
|
+
* is a pre-check on an already-resolved flag, not this module owning lock lifecycle.
|
|
18
|
+
*/
|
|
19
|
+
export interface CreateRestorePointRepoPort {
|
|
20
|
+
save(row: {
|
|
21
|
+
restorePointId: string;
|
|
22
|
+
idempotencyKey: string;
|
|
23
|
+
trigger: string;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
createdBy: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
findByIdempotencyKey(key: string): Promise<{
|
|
28
|
+
restorePointId: string;
|
|
29
|
+
idempotencyKey: string;
|
|
30
|
+
} | null>;
|
|
31
|
+
}
|
|
32
|
+
export interface CreateRestorePointClockPort {
|
|
33
|
+
nowIso(): string;
|
|
34
|
+
}
|
|
35
|
+
export interface CreateRestorePointIdPort {
|
|
36
|
+
newId(): string;
|
|
37
|
+
}
|
|
38
|
+
export type CreateRestorePointAuthorizeFn = (params: {
|
|
39
|
+
principalId: string;
|
|
40
|
+
permission: string;
|
|
41
|
+
}) => Promise<{
|
|
42
|
+
allowed: boolean;
|
|
43
|
+
reason: string;
|
|
44
|
+
}>;
|
|
45
|
+
export interface CreateRestorePointRequired {
|
|
46
|
+
deps: {
|
|
47
|
+
repo: CreateRestorePointRepoPort;
|
|
48
|
+
clock: CreateRestorePointClockPort;
|
|
49
|
+
ids: CreateRestorePointIdPort;
|
|
50
|
+
authorize: CreateRestorePointAuthorizeFn;
|
|
51
|
+
/** Present in the seam for shape-parity with the gated ceremony's deps; deliberately never
|
|
52
|
+
* called here (AC-10) — kept so a caller wiring a shared deps object cannot be tempted to
|
|
53
|
+
* route restore-point creation through it. */
|
|
54
|
+
gateway: {
|
|
55
|
+
plan: (...args: unknown[]) => Promise<unknown>;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
input: {
|
|
59
|
+
principalId: string;
|
|
60
|
+
principalKind: PrincipalKind;
|
|
61
|
+
idempotencyKey: string;
|
|
62
|
+
trigger: "manual" | "pre-migration-auto" | "template-upgrade";
|
|
63
|
+
operationInFlight: boolean;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface CreateRestorePointValue {
|
|
67
|
+
restorePointId: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* AC-10/AC-11/REQ-05/REQ-13 — authorize (always) -> in-flight refusal -> idempotency lookup ->
|
|
71
|
+
* write. Never invokes `deps.gateway` at all.
|
|
72
|
+
*
|
|
73
|
+
* @complexity O(1) plus one `authorize()` call, one idempotency lookup, and (on the first call for
|
|
74
|
+
* a given key) one `repo.save()` call.
|
|
75
|
+
*/
|
|
76
|
+
export declare function createRestorePoint(required: CreateRestorePointRequired, _optional?: Record<string, never>): Promise<Result<CreateRestorePointValue, {
|
|
77
|
+
code: string;
|
|
78
|
+
message?: string;
|
|
79
|
+
}>>;
|
|
80
|
+
//# sourceMappingURL=restore-point-create.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AC-10/AC-11/REQ-05/REQ-13 — authorize (always) -> in-flight refusal -> idempotency lookup ->
|
|
3
|
+
* write. Never invokes `deps.gateway` at all.
|
|
4
|
+
*
|
|
5
|
+
* @complexity O(1) plus one `authorize()` call, one idempotency lookup, and (on the first call for
|
|
6
|
+
* a given key) one `repo.save()` call.
|
|
7
|
+
*/
|
|
8
|
+
export async function createRestorePoint(required, _optional = {}) {
|
|
9
|
+
const { deps, input } = required;
|
|
10
|
+
const authResult = await deps.authorize({ principalId: input.principalId, permission: "backup.create" });
|
|
11
|
+
if (!authResult.allowed) {
|
|
12
|
+
return { ok: false, error: { code: "FORBIDDEN", message: authResult.reason } };
|
|
13
|
+
}
|
|
14
|
+
if (input.operationInFlight) {
|
|
15
|
+
return {
|
|
16
|
+
ok: false,
|
|
17
|
+
error: {
|
|
18
|
+
code: "RESTORE_OPERATION_IN_FLIGHT",
|
|
19
|
+
message: "a migration or restore is already in flight for this site",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const existing = await deps.repo.findByIdempotencyKey(input.idempotencyKey);
|
|
24
|
+
if (existing) {
|
|
25
|
+
return { ok: true, value: { restorePointId: existing.restorePointId } };
|
|
26
|
+
}
|
|
27
|
+
const restorePointId = deps.ids.newId();
|
|
28
|
+
await deps.repo.save({
|
|
29
|
+
restorePointId,
|
|
30
|
+
idempotencyKey: input.idempotencyKey,
|
|
31
|
+
trigger: input.trigger,
|
|
32
|
+
createdAt: deps.clock.nowIso(),
|
|
33
|
+
createdBy: input.principalId,
|
|
34
|
+
});
|
|
35
|
+
return { ok: true, value: { restorePointId } };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=restore-point-create.js.map
|
package/dist/sqlite/open.d.ts
CHANGED
|
@@ -54,5 +54,5 @@ export declare const DEFAULT_PRAGMAS: readonly string[];
|
|
|
54
54
|
* @throws Any error from the recovery hook, opener, or pragma application.
|
|
55
55
|
* @complexity O(p) calls for p pragmas; storage costs belong to the injected driver.
|
|
56
56
|
*/
|
|
57
|
-
export declare function openSqliteConnection<Connection extends SqliteClient>(
|
|
57
|
+
export declare function openSqliteConnection<Connection extends SqliteClient>(required: Pick<OpenSqliteConnectionOptions<Connection>, "filePath" | "open">, options?: Pick<OpenSqliteConnectionOptions<Connection>, "recover" | "pragmas">): Connection;
|
|
58
58
|
//# sourceMappingURL=open.d.ts.map
|
package/dist/sqlite/open.js
CHANGED
|
@@ -32,9 +32,9 @@ export const DEFAULT_PRAGMAS = [
|
|
|
32
32
|
* @throws Any error from the recovery hook, opener, or pragma application.
|
|
33
33
|
* @complexity O(p) calls for p pragmas; storage costs belong to the injected driver.
|
|
34
34
|
*/
|
|
35
|
-
export function openSqliteConnection(options) {
|
|
36
|
-
options.recover?.(
|
|
37
|
-
const connection =
|
|
35
|
+
export function openSqliteConnection(required, options = {}) {
|
|
36
|
+
options.recover?.({ filePath: required.filePath }, {});
|
|
37
|
+
const connection = required.open({ filePath: required.filePath }, {});
|
|
38
38
|
for (const pragma of options.pragmas ?? DEFAULT_PRAGMAS) {
|
|
39
39
|
connection.pragma(pragma);
|
|
40
40
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* package boundary cleanly. See `open.ts`'s module doc for the measured failure that made this a
|
|
8
8
|
* rule rather than a preference.
|
|
9
9
|
*/
|
|
10
|
-
import type { SqliteClient
|
|
10
|
+
import type { SqliteClient } from './types.js';
|
|
11
11
|
/**
|
|
12
12
|
* A caller-injected hook run against `filePath` BEFORE the connection is opened.
|
|
13
13
|
*
|
|
@@ -17,10 +17,14 @@ import type { SqliteClient, SqliteOpener } from './types.js';
|
|
|
17
17
|
* supplied it runs for every path, including `:memory:`. A host with file-only recovery must make
|
|
18
18
|
* its hook a no-op for ephemeral connections and hermetic tests, where there is nothing to recover.
|
|
19
19
|
*/
|
|
20
|
-
export type SqliteRecoveryHook = (
|
|
20
|
+
export type SqliteRecoveryHook = (required: {
|
|
21
|
+
filePath: string;
|
|
22
|
+
}, options?: Record<string, never>) => void;
|
|
21
23
|
export interface OpenSqliteConnectionOptions<Connection extends SqliteClient = SqliteClient> {
|
|
22
24
|
/** The consumer opens with its own driver copy. */
|
|
23
|
-
readonly open:
|
|
25
|
+
readonly open: (required: {
|
|
26
|
+
filePath: string;
|
|
27
|
+
}, options: Record<string, never>) => Connection;
|
|
24
28
|
/** Filesystem path, or `':memory:'` for an ephemeral connection. */
|
|
25
29
|
readonly filePath: string;
|
|
26
30
|
/**
|
package/dist/tools/read-tools.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Portable DB read/restore-point handlers; migration gateways stay host-owned. See docs/decisions/DR-001-bounded-operational-timeline.md. */
|
|
2
|
-
import { ToolInputError } from "@jini-ai/core";
|
|
2
|
+
import { readToolLimit, ToolInputError } from "@jini-ai/core";
|
|
3
3
|
import { nowIso } from "@jini-ai/core/primitives";
|
|
4
4
|
import { defaultDbMessages } from "../core/messages.js";
|
|
5
5
|
import { getDatabaseAgentToolCatalog } from "./database-catalog.js";
|
|
6
|
-
import { getTimeline } from "./timeline.js";
|
|
6
|
+
import { DEFAULT_TIMELINE_PAGE_SIZE, getTimeline, MAX_TIMELINE_PAGE_SIZE } from "./timeline.js";
|
|
7
7
|
import { createRestorePoint as createDatabaseRestorePoint, listRestorePoints } from "./restore-points.js";
|
|
8
8
|
import { registrations } from "./registration.js";
|
|
9
9
|
/**
|
|
@@ -15,7 +15,7 @@ import { registrations } from "./registration.js";
|
|
|
15
15
|
*/
|
|
16
16
|
export function createDatabaseReadTools(ports, _optional = {}) {
|
|
17
17
|
const messages = _optional.messages ?? defaultDbMessages;
|
|
18
|
-
const { noInput: requireNoInput, isRecord, optionalString,
|
|
18
|
+
const { noInput: requireNoInput, isRecord, optionalString, optionalBoolean } = ports.readers;
|
|
19
19
|
const handlers = {
|
|
20
20
|
database_query_timeline: async (ctx) => {
|
|
21
21
|
if (ctx.input !== undefined && !isRecord(ctx.input))
|
|
@@ -30,7 +30,9 @@ export function createDatabaseReadTools(ports, _optional = {}) {
|
|
|
30
30
|
fromDate: optionalString(input, "fromDate"),
|
|
31
31
|
toDate: optionalString(input, "toDate"),
|
|
32
32
|
cursor: optionalString(input, "cursor"),
|
|
33
|
-
|
|
33
|
+
// The catalog promises "server-capped at 200, defaults to 50": cap here, and refuse 0/-1/2.5
|
|
34
|
+
// as a ToolInputError the model can read instead of getTimeline's redacted plain Error.
|
|
35
|
+
limit: readToolLimit({ input, max: MAX_TIMELINE_PAGE_SIZE, fallback: DEFAULT_TIMELINE_PAGE_SIZE }),
|
|
34
36
|
},
|
|
35
37
|
});
|
|
36
38
|
},
|
|
@@ -67,6 +69,7 @@ export function createDatabaseReadTools(ports, _optional = {}) {
|
|
|
67
69
|
let captured;
|
|
68
70
|
const summary = await createDatabaseRestorePoint({
|
|
69
71
|
costClass: capabilities.restorePoint.costClass,
|
|
72
|
+
kind: capabilities.restorePoint.kind,
|
|
70
73
|
costAck: costAck ?? false,
|
|
71
74
|
capture: async () => {
|
|
72
75
|
captured = await ports.dbOps.captureRestorePoint({ scopeId: ports.workspaceId });
|
|
@@ -42,6 +42,9 @@ export interface RestorePointSummary {
|
|
|
42
42
|
*/
|
|
43
43
|
export declare function createRestorePoint(required: {
|
|
44
44
|
costClass: RestorePointCostClass;
|
|
45
|
+
/** The host capability's restore kind (`getCapabilities().restorePoint.kind`), returned as-is.
|
|
46
|
+
* Required, not defaulted: a hardcoded `file-snapshot` mislabeled every Postgres logical dump. */
|
|
47
|
+
kind: string;
|
|
45
48
|
costAck?: boolean;
|
|
46
49
|
capture: () => Promise<{
|
|
47
50
|
artifactRef: string;
|
|
@@ -23,7 +23,7 @@ export class RestorePointUnavailableError extends Error {
|
|
|
23
23
|
* @overallScore 100
|
|
24
24
|
*/
|
|
25
25
|
export async function createRestorePoint(required, _optional = {}) {
|
|
26
|
-
const { costClass, costAck = false, capture } = required;
|
|
26
|
+
const { costClass, kind, costAck = false, capture } = required;
|
|
27
27
|
const messages = _optional.messages ?? defaultDbMessages;
|
|
28
28
|
if (costClass === "unavailable") {
|
|
29
29
|
throw new RestorePointUnavailableError(
|
|
@@ -36,7 +36,7 @@ export async function createRestorePoint(required, _optional = {}) {
|
|
|
36
36
|
"an 'expensive' restore point requires an explicit costAck; the confirmer must acknowledge the cost/disk estimate first");
|
|
37
37
|
}
|
|
38
38
|
await capture();
|
|
39
|
-
return { id: randomUUID(), costClass, kind
|
|
39
|
+
return { id: randomUUID(), costClass, kind };
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Lists every restore point recorded for this site, newest-first (the port's own contract —
|
|
@@ -1,36 +1,18 @@
|
|
|
1
|
+
import type { ApprovalAnswer, ToolExecutionContext, ToolExecutionOptions } from "@jini-ai/core";
|
|
1
2
|
/** Structural surface protocol: transport, confirmation policy and builders belong to the consumer. */
|
|
2
|
-
import type { SurfaceEmission,
|
|
3
|
+
import type { SurfaceEmission, SurfaceExchangeConversation, SurfaceExchangeStore, SurfaceAskThenReport } from "@jini-ai/core";
|
|
4
|
+
export type { SurfaceExchangeConversation as SurfaceExchange, SurfaceMessage } from "@jini-ai/core";
|
|
3
5
|
import type { DatabaseTransferPlan } from "./plan-store.js";
|
|
4
|
-
export type SurfaceMessage = {
|
|
5
|
-
status: "received";
|
|
6
|
-
params: Record<string, unknown>;
|
|
7
|
-
} | {
|
|
8
|
-
status: "expired" | "abandoned";
|
|
9
|
-
};
|
|
10
|
-
export interface SurfaceExchange {
|
|
11
|
-
readonly id: string;
|
|
12
|
-
send(emission: SurfaceEmission): Promise<void>;
|
|
13
|
-
receive(): Promise<SurfaceMessage>;
|
|
14
|
-
close(): void;
|
|
15
|
-
}
|
|
16
6
|
export interface TransferSurfacePorts {
|
|
17
|
-
open(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} | {
|
|
25
|
-
confirmed: false;
|
|
26
|
-
reason: "declined" | "expired" | "abandoned";
|
|
27
|
-
}>;
|
|
7
|
+
open(required: Parameters<SurfaceExchangeStore["open"]>[0], optional?: Record<string, never>): SurfaceExchangeConversation;
|
|
8
|
+
/** Host transport only. The core approval owner calls it once for a replacement plan;
|
|
9
|
+
* the host binds principal/tool/expiry and never accepts model input as consent. */
|
|
10
|
+
confirmApproval(required: {
|
|
11
|
+
ctx: ToolExecutionContext;
|
|
12
|
+
plan: DatabaseTransferPlan;
|
|
13
|
+
}, optional: ToolExecutionOptions): Promise<ApprovalAnswer>;
|
|
28
14
|
/** Must close in finally; outcome-delivery failures cannot replace a settled result. */
|
|
29
|
-
askThenReport
|
|
30
|
-
result: T;
|
|
31
|
-
outcome?: SurfaceEmission;
|
|
32
|
-
}>): Promise<T>;
|
|
33
|
-
confirmation(plan: DatabaseTransferPlan, exchangeId: string): SurfaceEmission;
|
|
15
|
+
askThenReport: SurfaceAskThenReport;
|
|
34
16
|
destinationForm(exchangeId: string): SurfaceEmission;
|
|
35
17
|
destinationOutcome(input: {
|
|
36
18
|
exchangeId: string;
|
package/dist/tools/timeline.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ export interface LedgerReadPort {
|
|
|
39
39
|
nextCursor: string | null;
|
|
40
40
|
}>;
|
|
41
41
|
}
|
|
42
|
+
/** The server-side row cap — no raw/unbounded query surface is ever offered. See docs/decisions/DR-001-bounded-operational-timeline.md. */
|
|
43
|
+
export declare const MAX_TIMELINE_PAGE_SIZE = 200;
|
|
44
|
+
/** Page size when a caller names none. */
|
|
45
|
+
export declare const DEFAULT_TIMELINE_PAGE_SIZE = 50;
|
|
42
46
|
/**
|
|
43
47
|
* Returns a filtered, cursor-paginated page of the Timeline ledger.
|
|
44
48
|
*
|