@sema-agent/core 7.58.0 → 7.59.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/CHANGELOG.md +776 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +87 -21
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +18 -6
- package/dist/core/allow-entry.js +16 -8
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +58 -12
- package/dist/core/checkpoint-store.js +18 -6
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +98 -8
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +8 -4
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +31 -3
- package/dist/core/hooks.js +5 -6
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +5 -2
- package/dist/core/locked-config.js +2 -1
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-failure.d.ts +114 -18
- package/dist/core/mcp-failure.js +63 -5
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp.d.ts +12 -8
- package/dist/core/mcp.js +42 -25
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +2 -1
- package/dist/core/mods/kernel/events.d.ts +2 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/stations.d.ts +31 -10
- package/dist/core/mods/stations.js +44 -10
- package/dist/core/mods/tool-call.js +1 -1
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/peer-seat.d.ts +70 -8
- package/dist/core/peer-seat.js +143 -11
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/rewrite-rejudge.d.ts +1 -0
- package/dist/core/rewrite-rejudge.js +2 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/contracts.d.ts +20 -16
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +12 -4
- package/dist/core/runner/gate-exit.js +10 -7
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -0
- package/dist/core/runner/prepare-config-doors.js +2 -0
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +1 -0
- package/dist/core/runner/prepare-hands-readface.d.ts +4 -0
- package/dist/core/runner/prepare-hands-readface.js +5 -0
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.js +10 -17
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -3
- package/dist/core/runner/prepare-policy-chain.js +16 -13
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.js +9 -1
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-task.js +4 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -1
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +5 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +37 -28
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner-deps.d.ts +1 -1
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +2 -5
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +32 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +5 -0
- package/dist/core/task-spec.d.ts +12 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +9 -12
- package/dist/engine/harness/agent-harness.d.ts +25 -2
- package/dist/engine/harness/agent-harness.js +41 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +8 -0
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +16 -10
- package/dist/index.js +11 -7
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/index.js +6 -2
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +87 -1
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
|
@@ -172,6 +172,29 @@ export declare function computeBundleSectionHashes(bundle: Pick<MemoryExportBund
|
|
|
172
172
|
* a tampered package fails integrity before its hash ever matters.
|
|
173
173
|
*/
|
|
174
174
|
export declare function computeMemoryBundleHash(sectionHashes: Record<string, string>): string;
|
|
175
|
+
/**
|
|
176
|
+
* The SCOPE AUTHORIZATION SEAT (`expectedScopes`) — ONE reading for every host verb that takes it
|
|
177
|
+
* (`importMemoryBundle(bundle, { expectedScopes })` and `eraseMemoryEntries({ …, expectedScopes })`).
|
|
178
|
+
* A service endpoint pins its principal's grant set here. Present ⇒ every scope the request NAMES or
|
|
179
|
+
* RESOLVES TO must be a member of the set, and a touch that cannot be attributed to a scope is not a
|
|
180
|
+
* member. Absent ⇒ the host is the authorizer (no narrowing). The seat authorizes the verb only; it
|
|
181
|
+
* never widens or narrows a session's memory scopes or write scope.
|
|
182
|
+
*
|
|
183
|
+
* This is the seat's shape rule: an array (read once by the caller's capture) of non-empty strings.
|
|
184
|
+
* Duplicates are tolerated (the set is a set — {@link canonicalExpectedScopes}); anything else is a
|
|
185
|
+
* bad value and refused loudly, never read as "no narrowing" or as some other set.
|
|
186
|
+
*/
|
|
187
|
+
export declare function expectedScopesInvalid(v: unknown): string | undefined;
|
|
188
|
+
/** The grant set's canonical form — sorted, de-duplicated (the form an erasure anchor records and a
|
|
189
|
+
* replay compares; two spellings of one set are one authorization). */
|
|
190
|
+
export declare function canonicalExpectedScopes(grant: readonly string[]): string[];
|
|
191
|
+
/**
|
|
192
|
+
* The seat's ONE membership judgment: the index of the first touched scope that is NOT a member of
|
|
193
|
+
* `grant` (an `undefined` touch — a scope the store cannot attribute — is never a member), or -1 when
|
|
194
|
+
* every touch is a member. The caller decides what a refusal may say (the import names its own
|
|
195
|
+
* bundle scope; the erasure lane names nothing).
|
|
196
|
+
*/
|
|
197
|
+
export declare function firstOutsideExpectedScopes(grant: readonly string[], touched: readonly (string | undefined)[]): number;
|
|
175
198
|
/**
|
|
176
199
|
* design/178 v2-c §1-2① — the PURE bundle validation (integrity/structure/self-consistency; zero
|
|
177
200
|
* store reads, zero side effects). Returns the FIRST violation, or undefined (valid). Every
|
|
@@ -33,6 +33,23 @@ function stringArrayInvalid(v, what) {
|
|
|
33
33
|
function countInvalid(v, what) {
|
|
34
34
|
return typeof v === "number" && Number.isInteger(v) && v >= 0 ? undefined : `${what} is not a non-negative integer`;
|
|
35
35
|
}
|
|
36
|
+
export function expectedScopesInvalid(v) {
|
|
37
|
+
if (!Array.isArray(v))
|
|
38
|
+
return "expectedScopes is not an array (the grant set is a list of scope names)";
|
|
39
|
+
for (let i = 0; i < v.length; i++) {
|
|
40
|
+
const s = v[i];
|
|
41
|
+
if (typeof s !== "string" || s.length === 0)
|
|
42
|
+
return "expectedScopes carries a non-string or empty scope name";
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
export function canonicalExpectedScopes(grant) {
|
|
47
|
+
return [...new Set(grant)].sort();
|
|
48
|
+
}
|
|
49
|
+
export function firstOutsideExpectedScopes(grant, touched) {
|
|
50
|
+
const members = new Set(grant);
|
|
51
|
+
return touched.findIndex((s) => s === undefined || !members.has(s));
|
|
52
|
+
}
|
|
36
53
|
function entryInvalid(raw, scopes) {
|
|
37
54
|
if (!isRecord(raw))
|
|
38
55
|
return "entry is not an object";
|
|
@@ -119,10 +136,12 @@ export function memoryBundleInvalid(raw, opts = {}) {
|
|
|
119
136
|
if (typeof b.storeId !== "string" || b.storeId.length === 0)
|
|
120
137
|
return "bundle.storeId is missing";
|
|
121
138
|
if (opts.expectedScopes !== undefined) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
139
|
+
const grantBad = expectedScopesInvalid(opts.expectedScopes);
|
|
140
|
+
if (grantBad !== undefined)
|
|
141
|
+
return grantBad;
|
|
142
|
+
const outside = firstOutsideExpectedScopes(opts.expectedScopes, scopes);
|
|
143
|
+
if (outside >= 0)
|
|
144
|
+
return `bundle scope ${JSON.stringify(scopes[outside])} is outside the expected scope set — whole package refused`;
|
|
126
145
|
}
|
|
127
146
|
const entriesArr = Array.isArray(b.entries) && b.entries;
|
|
128
147
|
if (entriesArr === false)
|
|
@@ -11,15 +11,41 @@ export type ErasureSelect = {
|
|
|
11
11
|
} | {
|
|
12
12
|
sessionId: string;
|
|
13
13
|
};
|
|
14
|
-
/** design/178 v2-b §3.3(c) — one erased row's coordinates
|
|
15
|
-
*
|
|
14
|
+
/** design/178 v2-b §3.3(c) — one erased row's coordinates: the scope it was bound in, never its slug
|
|
15
|
+
* (a model-chosen file name can restate the content being erased; attestation v2). */
|
|
16
16
|
export type ErasedBinding = {
|
|
17
17
|
state: "bound";
|
|
18
18
|
scope: string;
|
|
19
|
-
slug: string;
|
|
20
19
|
} | {
|
|
21
20
|
state: "unbound";
|
|
22
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* The closed set of places a copy of an erased entry can live in one store (attestation v2,
|
|
24
|
+
* `residuals.carriers`). `complete` means every one of them answers `remaining: 0`:
|
|
25
|
+
* - `projection` — the entry's files under its scope home (bound path + every census copy);
|
|
26
|
+
* - `shadow` — the control plane's committed copy;
|
|
27
|
+
* - `indexLine` — MEMORY.md pointer lines (name + description) naming a deleted projection path;
|
|
28
|
+
* - `quarantineCopy` — quarantine files whose frontmatter id is the erased id;
|
|
29
|
+
* - `planArchive` / `planWorkbook` — the consolidation plane's mint archive and plan workbook;
|
|
30
|
+
* - `evidenceBinding` — evidence-chain rows that still spell the entry's slug;
|
|
31
|
+
* - `backendDerived` — anything a backend derives privately (vectors, summaries).
|
|
32
|
+
*/
|
|
33
|
+
export declare const ERASURE_CARRIER_CLASSES: readonly ["projection", "shadow", "indexLine", "quarantineCopy", "planArchive", "planWorkbook", "evidenceBinding", "backendDerived"];
|
|
34
|
+
export type ErasureCarrierClass = (typeof ERASURE_CARRIER_CLASSES)[number];
|
|
35
|
+
/** One carrier class's answer: what this call removed and what is known to remain, or `unverified`
|
|
36
|
+
* when the answering lane cannot read that class (which never reads as clean). */
|
|
37
|
+
export type ErasureCarrierAnswer = {
|
|
38
|
+
removed: number;
|
|
39
|
+
remaining: number;
|
|
40
|
+
} | {
|
|
41
|
+
unverified: true;
|
|
42
|
+
};
|
|
43
|
+
/** A store-level count that does not decide `status`; `unverified` when the lane cannot count. */
|
|
44
|
+
export type ErasureCountAnswer = {
|
|
45
|
+
count: number;
|
|
46
|
+
} | {
|
|
47
|
+
unverified: true;
|
|
48
|
+
};
|
|
23
49
|
/** The input of the erasure lane (engine host API `eraseMemoryEntries` and the File capability face
|
|
24
50
|
* `eraseWithEvidence` share it; the File face ignores `allowUnevidenced` — with the evidence
|
|
25
51
|
* capability present there is nothing to degrade to). */
|
|
@@ -29,20 +55,47 @@ export interface EraseMemoryEntriesInput {
|
|
|
29
55
|
select: ErasureSelect;
|
|
30
56
|
/** Evidence-capability-ABSENT degradation opt-in (engine lane only; default = loud refusal). */
|
|
31
57
|
allowUnevidenced?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The scope AUTHORIZATION seat `importMemoryBundle` takes — one shape rule and one membership
|
|
60
|
+
* predicate ({@link expectedScopesInvalid} / {@link firstOutsideExpectedScopes}). Present ⇒ a
|
|
61
|
+
* `{ scope }` selector's own scope and the BINDING scope of every resolved id must be members (an id
|
|
62
|
+
* with no binding — no account row, unbound, a non-entry-id key, unledgered file — is not); any violation
|
|
63
|
+
* refuses the whole request (`config.memory_erasure_scope`) naming no count, id or scope, with
|
|
64
|
+
* nothing deleted or recorded. The evidence lane judges in its lock and records the canonical set on
|
|
65
|
+
* the anchor; a replay must carry the same set and is judged against the scopes its first execution
|
|
66
|
+
* recorded (the request's projection rows), never the live account. A face honours the seat only when
|
|
67
|
+
* its backend declares {@link FileMemoryEngineBackend.judgesErasureScopes}. The degraded lane judges
|
|
68
|
+
* the read faces' answer with no lock before its CAS'd deletes (an entry moved to another scope with
|
|
69
|
+
* unchanged content in that window is not seen). Absent ⇒ the host is the authorizer.
|
|
70
|
+
*/
|
|
71
|
+
expectedScopes?: readonly string[];
|
|
32
72
|
}
|
|
33
73
|
/**
|
|
34
74
|
* design/178 v2-b §3.3(c) — the erasure attestation (the deliverable a compliance caller archives).
|
|
35
75
|
* Every claim is black-box re-checkable: an `erased` row is verified by `committedSnapshotOf(id)`
|
|
36
76
|
* answering `"absent"`, the chain containing its `evidenceEv` delete row, and `getByIds([id])`
|
|
37
|
-
* answering empty.
|
|
77
|
+
* answering empty. It names ids, scopes, revs, sessions and counts — never a slug, a file name or
|
|
78
|
+
* entry text.
|
|
79
|
+
*
|
|
80
|
+
* Contract (version 2): the evidence chain is append-only and a delete row never expires with any
|
|
81
|
+
* retention period; on the evidence lane (`replay: "converges"`) a replay of the same requestId
|
|
82
|
+
* converges with no time limit (so a ≥ 24 h replay window holds); the degraded lane promises no
|
|
83
|
+
* replay convergence and says so (`replay: "unsupported"`).
|
|
38
84
|
*/
|
|
39
85
|
export interface MemoryErasureAttestation {
|
|
40
|
-
/** Version envelope — a consumer reading `v >
|
|
41
|
-
|
|
86
|
+
/** Version envelope — a consumer reading `v > 2` must refuse, never reinterpret. Version 2 dropped
|
|
87
|
+
* every slug (`erased[].binding`, `erasedPreviously[].from`) and replaced the residual name lists
|
|
88
|
+
* with the carrier table. */
|
|
89
|
+
v: 2;
|
|
42
90
|
requestId: string;
|
|
43
91
|
at: number;
|
|
44
92
|
/** `"complete"` ⇔ conflicts empty ∧ every pinned id ∈ erased ∪ erasedPreviously ∪ (notFound with
|
|
45
|
-
* `custodyState === "complete"`)
|
|
93
|
+
* `custodyState === "complete"`) ∧ every `residuals.carriers` class answers `remaining: 0`
|
|
94
|
+
* ({@link erasureStatusOf} — one predicate for every lane). Its reach is THIS store and the
|
|
95
|
+
* selected ids: another entry that restates an erased one is counted on `residuals.derivedEntries`
|
|
96
|
+
* and does not decide it. Everything else is `"partial"`; a replay converges the classes the lane
|
|
97
|
+
* can clear, and says when it cannot (`unverified`, or `evidenceBinding.remaining` — rows the
|
|
98
|
+
* append-only chain keeps). */
|
|
46
99
|
status: "complete" | "partial";
|
|
47
100
|
/** `"journal"` = the File evidence path; `"none"` = the explicit `allowUnevidenced` degradation
|
|
48
101
|
* lane (always present — a silent downgrade is the forbidden shape). */
|
|
@@ -86,18 +139,6 @@ export interface MemoryErasureAttestation {
|
|
|
86
139
|
id: string;
|
|
87
140
|
ev: string;
|
|
88
141
|
at: number;
|
|
89
|
-
/** The pre-delete binding from the most recent same-request delete row that RECORDED one —
|
|
90
|
-
* carried so a REPLAY can still run the index-line sweep (the ledger row is gone; the evidence
|
|
91
|
-
* row is the only surviving source of the projection path). `ev`/`at` come from the MOST RECENT
|
|
92
|
-
* same-request delete row (which may be a later, binding-less re-erase). Absent in THREE cases:
|
|
93
|
-
* no same-request delete row ever recorded a binding (unbound / pre-v2-form), or the recorded
|
|
94
|
-
* path is OCCUPIED now (a live account row binds that scope+slug, or bytes exist at the path —
|
|
95
|
-
* the binding is known but suppressed: the index line there belongs to the occupant, and a
|
|
96
|
-
* consumer must not read absence as "no residue possible"). */
|
|
97
|
-
from?: {
|
|
98
|
-
scope: string;
|
|
99
|
-
slug: string;
|
|
100
|
-
};
|
|
101
142
|
}>;
|
|
102
143
|
/** Per-id planning-stage faults (io/plan errors under the lock — there is no CAS loser inside a
|
|
103
144
|
* single lock span). Non-fatal; a replay converges them. */
|
|
@@ -106,26 +147,44 @@ export interface MemoryErasureAttestation {
|
|
|
106
147
|
reason: string;
|
|
107
148
|
}>;
|
|
108
149
|
residuals: {
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
* the
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*
|
|
123
|
-
|
|
150
|
+
/** Every class of {@link ERASURE_CARRIER_CLASSES}, each answered. The derived-index class
|
|
151
|
+
* (`indexLine`) is the ENGINE's plane: the File face answers it `unverified` while the deleted
|
|
152
|
+
* projection paths wait in its transient sweep record, and `MemoryEngine.eraseMemoryEntries`
|
|
153
|
+
* sweeps the index lines naming those paths (whoever holds the path now — an occupant's line
|
|
154
|
+
* comes back in mechanical form at the next materialize), drops the record, and answers it.
|
|
155
|
+
* `evidenceBinding.remaining` counts rows minted before slugs left the chain (pre-version-2
|
|
156
|
+
* delete rows, and move / migration-bind rows) — the append-only chain keeps them, so they keep
|
|
157
|
+
* the request `partial` and a replay cannot clear them. */
|
|
158
|
+
carriers: Record<ErasureCarrierClass, ErasureCarrierAnswer>;
|
|
159
|
+
/** Quarantine files no id could be read from (fragments / non-entry shapes) — the honest bound of
|
|
160
|
+
* the quarantine read; a store-level count that does not decide `status`. */
|
|
161
|
+
quarantineUnattributed: ErasureCountAnswer;
|
|
162
|
+
/** Committed entries outside the selection whose consolidation lineage names an erased id (they
|
|
163
|
+
* may restate it) — counted, not erased; their closure is the caller's to compute. */
|
|
164
|
+
derivedEntries: ErasureCountAnswer;
|
|
165
|
+
/** Whether a replay of this requestId converges (the evidence lane) or is a new request (the
|
|
166
|
+
* degraded lane). */
|
|
167
|
+
replay: "converges" | "unsupported";
|
|
124
168
|
/** Propagation boundary, self-declared always: deletion is a THIS-store fact; remote-peer
|
|
125
169
|
* convergence is the sync deployment's half to prove. */
|
|
126
170
|
propagation: "local-store-only";
|
|
127
171
|
};
|
|
128
172
|
}
|
|
173
|
+
/** The status law of {@link MemoryErasureAttestation.status} — every lane answers through it. */
|
|
174
|
+
export declare function erasureStatusOf(att: Pick<MemoryErasureAttestation, "conflicts" | "resolvedIds" | "erased" | "erasedPreviously" | "notFound" | "custodyState" | "residuals">): "complete" | "partial";
|
|
175
|
+
/** The paths the request's index sweep still owes at `storeRoot`, or `[]` when it owes none. */
|
|
176
|
+
export declare function readErasureSweep(controlDir: string, storeRoot: string, requestId: string): string[];
|
|
177
|
+
/**
|
|
178
|
+
* Run an index sweep as a transaction of the store — under its transaction lock (the lock its commits,
|
|
179
|
+
* recoveries and a re-anchor of its root take, so none of them lands inside a sweep) and under the
|
|
180
|
+
* record's lock — handed the paths `requestId` owes at `storeRoot` (`[]` without a request — the
|
|
181
|
+
* degraded lane sweeps its own deletes the same way); when `sweep` answers that every owed line is
|
|
182
|
+
* gone, the request's row goes. Two sweeps never interleave their read-filter-write of one index (a
|
|
183
|
+
* lost update would otherwise put a swept line back after its obligation was settled). The lock is
|
|
184
|
+
* proved still this holder's before the sweep acts and again before its answer is acted on, as at a
|
|
185
|
+
* commit ({@link assertStoreTxnLockOwnership}): a holder stolen from throws, and the row stays.
|
|
186
|
+
*/
|
|
187
|
+
export declare function sweepUnderErasureRecord(controlDir: string, storeRoot: string, requestId: string | undefined, sweep: (owed: readonly string[]) => boolean): Promise<void>;
|
|
129
188
|
/** sha256 hex over the selector's canonical JSON + LF — the replay-identity judge (§4.6) and the
|
|
130
189
|
* anchor validator's recomputation basis (a 64-hex shape check alone would let a forged anchor swap
|
|
131
190
|
* the selector under a kept hash). */
|
|
@@ -134,6 +193,11 @@ export declare function erasureSelectHash(select: ErasureSelect): string;
|
|
|
134
193
|
* set — the selector the anchor row echoes verbatim must pass the anchor's own validator, so the
|
|
135
194
|
* entry check and the chain check are the same predicate). Returns the violation, or undefined. */
|
|
136
195
|
export declare function erasureRequestInvalid(input: EraseMemoryEntriesInput): string | undefined;
|
|
196
|
+
/** The authorization refusal, one text for both lanes; it names no count, id or scope (saying which
|
|
197
|
+
* id sits where would answer the very question the seat withholds). */
|
|
198
|
+
export declare function erasureScopeRefusal(where: string): Error & {
|
|
199
|
+
code: string;
|
|
200
|
+
};
|
|
137
201
|
/**
|
|
138
202
|
* Snapshot the erasure input into PLAIN data by reading every accessor exactly once (round-2 #3/#5):
|
|
139
203
|
* validation and use must observe the SAME value, so an accessor-backed (getter/Proxy) selector or
|
|
@@ -457,8 +521,12 @@ export declare class FileMemoryEngineBackend implements MemoryBackend {
|
|
|
457
521
|
/** Fail-open announcement convenience (S2-B queue posture — an unwritable queue never fails the
|
|
458
522
|
* operation that had something to say; the fail-CLOSED evidence lane is `transfers.jsonl`). */
|
|
459
523
|
private enqueueExternalItems;
|
|
524
|
+
/** The operator half of {@link enqueueExternalItems}: said to the host only. */
|
|
525
|
+
private withholdNotice;
|
|
460
526
|
/** One-shot dedup for adopting-face notices (see {@link adoptionNoticeKeys}). */
|
|
461
527
|
private announceAdoptionNotice;
|
|
528
|
+
/** The last unbound-row reading said to the host (the operator face is told when it changes). */
|
|
529
|
+
private unboundReadingSaid;
|
|
462
530
|
/**
|
|
463
531
|
* §3.4 — the standing unbound-row disclosure, in ONE spelling for BOTH faces that carry it (the
|
|
464
532
|
* harvest preflight `checkControlPlane` and the restricted sweep `auditRestrictedDivergence` used
|
|
@@ -466,27 +534,11 @@ export declare class FileMemoryEngineBackend implements MemoryBackend {
|
|
|
466
534
|
* clause, which is if anything MORE apt there — a restricted session has no write channel of its
|
|
467
535
|
* own to converge the row).
|
|
468
536
|
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
* · a backend instance is a RUNNER-level dependency reused across every session it serves, so a
|
|
475
|
-
* per-instance latch would announce the standing condition to the first session and then hold
|
|
476
|
-
* its peace forever — turning a flood into silence, against this disclosure's own contract
|
|
477
|
-
* (「the STATE does not go silent」). The queue is DRAINED at each session's first injection, so
|
|
478
|
-
* "is an identical line still pending?" is exactly the right question: no repeat within a
|
|
479
|
-
* session, one fresh statement in every session that has not yet been told.
|
|
480
|
-
* · a latch key would have to encode the id set, and ledger row ids are arbitrary external
|
|
481
|
-
* strings (a comma is legal) — `join(",")` makes `["a,b","c"]` and `["a","b,c"]` the same key,
|
|
482
|
-
* so a real change of state could be suppressed. Comparing the RENDERED LINE has no such seam:
|
|
483
|
-
* two states that render the same sentence are, to every consumer, the same statement.
|
|
484
|
-
*
|
|
485
|
-
* The test runs INSIDE the queue's own locked read-modify-write
|
|
486
|
-
* ({@link enqueueMemoryAnnouncement}'s `supersedesPrefix`), not as a peek followed by an append: a
|
|
487
|
-
* peek-then-enqueue would race a concurrent drain, and two processes could both peek-miss and both
|
|
488
|
-
* append. Fail-open like every announce site — an unwritable queue never fails an operation that
|
|
489
|
-
* had something to say.
|
|
537
|
+
* An unbound row is one whose scope cannot be derived, and the sentence counts rows over the whole
|
|
538
|
+
* store — so it is no session's to read and goes to the host's incident sink only. It is said when
|
|
539
|
+
* the reading changes (compared as the RENDERED LINE: ledger row ids are arbitrary external strings,
|
|
540
|
+
* so a key built by joining them could make two different states look the same), not at every
|
|
541
|
+
* preflight that re-derives it.
|
|
490
542
|
*/
|
|
491
543
|
private announceUnboundRows;
|
|
492
544
|
/** Resolve a binding's absolute projection path WITHOUT registering anything (probes must stay
|
|
@@ -975,6 +1027,10 @@ export declare class FileMemoryEngineBackend implements MemoryBackend {
|
|
|
975
1027
|
applyPatches(patches: readonly NotePatch[], opts?: Parameters<MemoryBackend["applyPatches"]>[1]): Promise<PatchReport>;
|
|
976
1028
|
/** The caller's `admit` is honored: every add's final spelling is resolved under the lock and admitted before it is written. */
|
|
977
1029
|
readonly admitsLandings: true;
|
|
1030
|
+
/** {@link eraseWithEvidence} judges `EraseMemoryEntriesInput.expectedScopes` in its lock. A
|
|
1031
|
+
* declaration, never duck-typing: the engine refuses a grant-bearing erasure over an evidence face
|
|
1032
|
+
* that does not state it (a face that ignored the set would erase outside it). */
|
|
1033
|
+
readonly judgesErasureScopes: true;
|
|
978
1034
|
private txnLockDir;
|
|
979
1035
|
/** The store's transaction lock, waited for ({@link acquireStoreTxnLock} — the one mkdir mutex, shared with a re-anchor of the root). */
|
|
980
1036
|
private acquireTxnLock;
|
|
@@ -1031,6 +1087,23 @@ export declare class FileMemoryEngineBackend implements MemoryBackend {
|
|
|
1031
1087
|
* converges them); everything before the journal write refuses cleanly (F-1); every crash window
|
|
1032
1088
|
* after it converges through the shared recovery leg (F-2..F-5, F-13).
|
|
1033
1089
|
*/
|
|
1090
|
+
/** The sweep-record row an erasure journal owes: its request's physical projection deletes, relative
|
|
1091
|
+
* to this store's root. One derivation for the commit path and for recovery rolling the same journal
|
|
1092
|
+
* forward — including a journal an older binary wrote, which never had a record (an erasure journal
|
|
1093
|
+
* carries exactly one request's delete rows; a journal with none owes none). The commit path derives
|
|
1094
|
+
* it before its commit point, so a target the row cannot name refuses with nothing committed. */
|
|
1095
|
+
private journalSweepRow;
|
|
1096
|
+
/** Write the journal's sweep-record row ({@link journalSweepRow}; idempotent — a union). */
|
|
1097
|
+
private recordJournalSweep;
|
|
1098
|
+
/** Delete every quarantine file whose frontmatter id is in `ids` (a quarantined copy is a copy of the
|
|
1099
|
+
* entry). Runs under the erasure's lock after its commit; a file that cannot be removed stays
|
|
1100
|
+
* counted as `remaining` and a replay retries it. Files no id can be read from are counted, not
|
|
1101
|
+
* touched. An unreadable quarantine directory refuses the attestation (the deletions themselves
|
|
1102
|
+
* are committed; a replay converges). */
|
|
1103
|
+
private eraseQuarantineCopiesLocked;
|
|
1104
|
+
/** Does the control-plane directory `name` hold any entry? ENOENT ⇒ no; any other read failure ⇒
|
|
1105
|
+
* yes (an unreadable directory may hold anything). */
|
|
1106
|
+
private controlDirHoldsAnything;
|
|
1034
1107
|
eraseWithEvidence(input: EraseMemoryEntriesInput): Promise<MemoryErasureAttestation>;
|
|
1035
1108
|
/** Bounded journal-quiescence fence (attempt count × retry pause). Constants, not knobs: the
|
|
1036
1109
|
* contended window is the commit tail of one transaction (milliseconds); a store where it stays
|