@sema-agent/core 7.64.0 → 7.65.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 +317 -0
- package/dist/agents/peer-held-queue.js +1 -1
- package/dist/agents/peer-idle.js +1 -1
- package/dist/agents/peer-session-drain.js +3 -3
- package/dist/agents/subagent.js +5 -2
- package/dist/core/auto-promote.d.ts +3 -2
- package/dist/core/background-agent-store.d.ts +7 -0
- package/dist/core/checkpoint-store.d.ts +2 -3
- package/dist/core/context-settings.d.ts +1 -2
- package/dist/core/context-settings.js +1 -1
- package/dist/core/engine-attestation.d.ts +2 -2
- package/dist/core/engine-notice.d.ts +13 -1
- package/dist/core/engine-notice.js +3 -1
- package/dist/core/file-history-store.d.ts +2 -2
- package/dist/core/file-history-store.js +0 -4
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +6 -4
- package/dist/core/governance-codes.js +4 -3
- package/dist/core/leg-identity.d.ts +18 -2
- package/dist/core/leg-identity.js +5 -7
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.d.ts +10 -4
- package/dist/core/memory-engine/consolidation.js +11 -1
- package/dist/core/memory-engine/control-objects.d.ts +36 -3
- package/dist/core/memory-engine/control-objects.js +134 -12
- package/dist/core/memory-engine/control-plane-adoption.d.ts +5 -2
- package/dist/core/memory-engine/control-plane-adoption.js +5 -3
- package/dist/core/memory-engine/delegation-settlement.d.ts +59 -42
- package/dist/core/memory-engine/delegation-settlement.js +175 -202
- package/dist/core/memory-engine/dual-root.d.ts +3 -2
- package/dist/core/memory-engine/dual-root.js +5 -1
- package/dist/core/memory-engine/engine.d.ts +16 -10
- package/dist/core/memory-engine/engine.js +138 -145
- package/dist/core/memory-engine/file-backend.d.ts +17 -11
- package/dist/core/memory-engine/file-backend.js +53 -103
- package/dist/core/memory-engine/layout.d.ts +129 -49
- package/dist/core/memory-engine/layout.js +202 -82
- package/dist/core/memory-engine/memory-age.d.ts +12 -0
- package/dist/core/memory-engine/memory-age.js +17 -0
- package/dist/core/memory-engine/memory-backend-contract.js +5 -4
- package/dist/core/memory-engine/memory-deployment.d.ts +1 -1
- package/dist/core/memory-engine/origin-clearance.js +1 -5
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.js +7 -7
- package/dist/core/memory-engine/types.d.ts +16 -10
- package/dist/core/memory-vector.d.ts +6 -14
- package/dist/core/memory.d.ts +0 -462
- package/dist/core/memory.js +0 -333
- package/dist/core/permission-rule-consent.d.ts +49 -18
- package/dist/core/permission-rule-consent.js +59 -38
- package/dist/core/permission-rule-store.d.ts +24 -14
- package/dist/core/retention.d.ts +2 -7
- package/dist/core/retention.js +0 -1
- package/dist/core/runner/classifier-ladder.d.ts +3 -1
- package/dist/core/runner/classifier-ladder.js +2 -2
- package/dist/core/runner/contracts.d.ts +9 -9
- package/dist/core/runner/delegation-owner.d.ts +0 -8
- package/dist/core/runner/delegation-owner.js +1 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -5
- package/dist/core/runner/prepare-gate-stations.js +13 -5
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.js +9 -9
- package/dist/core/runner/prepare-policy-chain.js +11 -3
- package/dist/core/runner/prepare-task.d.ts +5 -1
- package/dist/core/runner/prepare-task.js +3 -3
- package/dist/core/runner/run-notification-lane.js +1 -1
- package/dist/core/runner/sub-agent-deny-lists.d.ts +19 -0
- package/dist/core/runner/sub-agent-deny-lists.js +25 -0
- package/dist/core/secret-env.d.ts +2 -2
- package/dist/core/secret-env.js +6 -20
- package/dist/core/session-store.d.ts +6 -6
- package/dist/core/session-store.js +3 -3
- package/dist/core/store-contracts/background-agent-store-contract.js +13 -0
- package/dist/core/task-notification.d.ts +35 -8
- package/dist/core/task-notification.js +31 -13
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +4 -0
- package/dist/core/tool-errors.d.ts +3 -3
- package/dist/core/tool-spec.d.ts +7 -7
- package/dist/core/write-protect.d.ts +16 -0
- package/dist/core/write-protect.js +10 -0
- package/dist/engine/session/repo-utils.d.ts +14 -4
- package/dist/engine/session/repo-utils.js +5 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/prompts/default.d.ts +1 -2
- package/dist/scenarios/full-body.d.ts +1 -1
- package/dist/stores/file/adoption/adopt.d.ts +1 -1
- package/dist/stores/file/index.d.ts +1 -15
- package/dist/stores/file/index.js +1 -15
- package/dist/stores/file/permission-rule-store.d.ts +12 -1
- package/dist/stores/file/permission-rule-store.js +31 -4
- package/dist/stores/file/session-store.js +1 -1
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +9 -73
- package/wire-changes/core-stores-sql@7.65.0.json +30 -0
- package/wire-changes/core@7.65.0.json +1650 -0
- package/wire-changes/mods-kernel@7.65.0.json +30 -0
- package/wire-changes/primitives@7.65.0.json +337 -0
- package/dist/core/memory-recall.d.ts +0 -208
- package/dist/core/memory-recall.js +0 -136
- package/dist/stores/file/memory-store.d.ts +0 -124
- package/dist/stores/file/memory-store.js +0 -353
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isMailboxDecisionDeliverable, isMailboxDecisionFinal } from "../core/mailbox-store.js";
|
|
2
|
-
import { sameOccupant } from "../
|
|
2
|
+
import { sameOccupant } from "../engine/session/repo-utils.js";
|
|
3
3
|
import { PEER_HELD_QUEUE_CAP, PEER_HELD_REVIEW_CAUSES, peerHeldReceiptStateOf } from "./peer-notices.js";
|
|
4
4
|
import { peerSessionBoxHandle } from "./peer-directory.js";
|
|
5
5
|
export const realPeerClock = {
|
package/dist/agents/peer-idle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sameOccupant } from "../
|
|
1
|
+
import { sameOccupant } from "../engine/session/repo-utils.js";
|
|
2
2
|
import { PEER_IDLE_FIRE_DEBOUNCE_MS, PEER_IDLE_HELD_BACKOFF_MS, PEER_IDLE_OUTSTANDING_CAP, PEER_IDLE_PRIORS_KEPT, PEER_IDLE_SUBSCRIBER_TABLE_CAP, PEER_IDLE_SUBSCRIPTION_TTL_MS } from "./peer-notices.js";
|
|
3
3
|
import { realPeerClock } from "./peer-held-queue.js";
|
|
4
4
|
import { peerSessionBoxHandle } from "./peer-directory.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isMailboxDecisionFinal, moveMailboxDecision, sessionBoxMountVerdict } from "../core/mailbox-store.js";
|
|
2
|
-
import { decodeEngineFrame, deliveryDiscardedNotice, ENGINE_FRAME_CODEC_VERSION, renderTaskNotificationXml, taskNotificationDedupKey } from "../core/task-notification.js";
|
|
3
|
-
import { sameOccupant } from "../
|
|
2
|
+
import { decodeEngineFrame, deliveryDiscardedNotice, ENGINE_FRAME_CODEC_VERSION, frameDelivery, renderTaskNotificationXml, taskNotificationDedupKey } from "../core/task-notification.js";
|
|
3
|
+
import { sameOccupant } from "../engine/session/repo-utils.js";
|
|
4
4
|
import { createFrameSettlement, toolResultReceiptKey } from "../core/frame-settlement.js";
|
|
5
5
|
import { PRINCIPAL_INBOX_HANDLE } from "./cross-session-ref.js";
|
|
6
6
|
import { isGateMintedRecord, principalInboxConsumerOf } from "./org-delivery-gate.js";
|
|
@@ -325,7 +325,7 @@ export function createPeerSessionDrain(opts) {
|
|
|
325
325
|
if (decoded.ok)
|
|
326
326
|
frame = decoded.payload;
|
|
327
327
|
}
|
|
328
|
-
deliverEngineNotice(opts.onNotice, deliveryDiscardedNotice({ sessionId, occupant: meta?.occupant }, opts.occupant, frame, "box"));
|
|
328
|
+
deliverEngineNotice(opts.onNotice, deliveryDiscardedNotice({ sessionId, occupant: meta?.occupant }, opts.occupant, frameDelivery(frame), "box"));
|
|
329
329
|
if (meta?.kind !== "peer_message" || meta.fromRoot !== undefined)
|
|
330
330
|
return;
|
|
331
331
|
const to = receiptAddress(sessionLane, m);
|
package/dist/agents/subagent.js
CHANGED
|
@@ -2252,6 +2252,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2252
2252
|
...((reviveClaim.row.rootSessionId ?? reviveClaim.row.parentSessionId) !== undefined
|
|
2253
2253
|
? { rootSessionId: reviveClaim.row.rootSessionId ?? reviveClaim.row.parentSessionId }
|
|
2254
2254
|
: {}),
|
|
2255
|
+
...(reviveClaim.row.rootSessionId !== undefined && reviveClaim.row.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: reviveClaim.row.rootSessionIncarnation } : {}),
|
|
2255
2256
|
}
|
|
2256
2257
|
: {
|
|
2257
2258
|
...(ctx.taskId !== undefined ? { parentTaskId: ctx.taskId } : {}),
|
|
@@ -2601,7 +2602,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2601
2602
|
}
|
|
2602
2603
|
if (settled && verdict === "external") {
|
|
2603
2604
|
try {
|
|
2604
|
-
await replayExternalSettlementEffects(forkSettlementSeat.governance,
|
|
2605
|
+
await replayExternalSettlementEffects(forkSettlementSeat.governance, { carry: true, now: Date.now });
|
|
2605
2606
|
}
|
|
2606
2607
|
catch {
|
|
2607
2608
|
}
|
|
@@ -2625,6 +2626,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2625
2626
|
...(ctx.taskId !== undefined && ctx.taskId !== ctx.sessionId ? { parentTaskId: ctx.taskId } : {}),
|
|
2626
2627
|
...(ctx.sessionId !== undefined ? { parentSessionId: ctx.sessionId } : {}),
|
|
2627
2628
|
...((ctx.rootSessionId ?? ctx.sessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? ctx.sessionId } : {}),
|
|
2629
|
+
...(ctx.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: ctx.rootSessionIncarnation } : {}),
|
|
2628
2630
|
...(rowModelKey !== undefined ? { model: rowModelKey } : {}),
|
|
2629
2631
|
deliveryChannel: "attaching",
|
|
2630
2632
|
toolUseId: ctx.toolCallId,
|
|
@@ -3118,7 +3120,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3118
3120
|
}
|
|
3119
3121
|
if (settled && verdict === "external") {
|
|
3120
3122
|
try {
|
|
3121
|
-
await replayExternalSettlementEffects(settlementSeat.governance,
|
|
3123
|
+
await replayExternalSettlementEffects(settlementSeat.governance, { carry: true, now: Date.now });
|
|
3122
3124
|
}
|
|
3123
3125
|
catch {
|
|
3124
3126
|
}
|
|
@@ -3177,6 +3179,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3177
3179
|
...(ctx.taskId !== undefined && ctx.taskId !== ctx.sessionId ? { parentTaskId: ctx.taskId } : {}),
|
|
3178
3180
|
...(ctx.sessionId !== undefined ? { parentSessionId: ctx.sessionId } : {}),
|
|
3179
3181
|
...((ctx.rootSessionId ?? ctx.sessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? ctx.sessionId } : {}),
|
|
3182
|
+
...(ctx.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: ctx.rootSessionIncarnation } : {}),
|
|
3180
3183
|
...(rowModelKey !== undefined ? { model: rowModelKey } : {}),
|
|
3181
3184
|
deliveryChannel: "attaching",
|
|
3182
3185
|
toolUseId: ctx.toolCallId,
|
|
@@ -16,8 +16,9 @@ export type AutoPromoteTerminal = "auto_promote" | "candidate_only" | "needs_hum
|
|
|
16
16
|
*/
|
|
17
17
|
export interface PromotedRecord {
|
|
18
18
|
/**
|
|
19
|
-
* Gate-2
|
|
20
|
-
*
|
|
19
|
+
* Gate-2 result: the promotable write landed WITH a positive utility verdict, or it was absent/ungated. The core
|
|
20
|
+
* ships no Gate-2 door since 7.65.0 — the caller computes this verdict itself and hands it in. Only
|
|
21
|
+
* `"present_positive"` is gate-passing; `"absent_or_ungated"` ⇒ needs_human.
|
|
21
22
|
*/
|
|
22
23
|
gate2Verdict: "present_positive" | "absent_or_ungated";
|
|
23
24
|
}
|
|
@@ -38,6 +38,13 @@ export interface BackgroundAgentRecord {
|
|
|
38
38
|
* restart, intermediate spawner sessions are dead ends — "everything under this host session"
|
|
39
39
|
* keys on THIS field (listBySession matches it as a second arm), not on an alias walk. */
|
|
40
40
|
rootSessionId?: string;
|
|
41
|
+
/** The occupant of {@link rootSessionId}'s row (its `SessionMetadata.incarnation`) as the spawning tree held it — the other
|
|
42
|
+
* half of the root anchor's address, written beside it by the registration that creates the row. A revival reads it back
|
|
43
|
+
* with the anchor, so the frames its subtree escalates to the root are addressed to the occupant the tree was born under
|
|
44
|
+
* (delivered while that occupant holds the root, discarded and announced once the id was created again). ABSENT = the
|
|
45
|
+
* spawning tree held no occupant for its root, or a row an earlier release wrote: the revived tree's root occupant is
|
|
46
|
+
* then unknown. A store returns it as written, absent as absent. */
|
|
47
|
+
rootSessionIncarnation?: string;
|
|
41
48
|
parentTaskId?: string;
|
|
42
49
|
/** The agent's name — the spawner's explicit one, or the one the engine derives from `handle`
|
|
43
50
|
* (`engineAgentName`) when the spawn named none. Written by the registration that creates the row, so
|
|
@@ -18,8 +18,7 @@ export { BINDING_CHECKPOINT_VERSION, CHECKPOINT_CONFIG_REFUSAL_CODES, CHECKPOINT
|
|
|
18
18
|
/**
|
|
19
19
|
* design/45 — the **durable-checkpoint** primitive: cross-process / resumable `suspend`/`resume`.
|
|
20
20
|
*
|
|
21
|
-
* A {@link CheckpointStore} is
|
|
22
|
-
* `MemoryStore`): a token-addressable store of "enough state to resume a suspended task", with an
|
|
21
|
+
* A {@link CheckpointStore} is a pluggable durable seam (alongside `ToolResultStore`): a token-addressable store of "enough state to resume a suspended task", with an
|
|
23
22
|
* **atomic CAS `resolve`** so a token is acted on **exactly once** even across replicas / double
|
|
24
23
|
* approvals. Two profiles share this one seam (design/43 原语 4, proven by two service instances):
|
|
25
24
|
*
|
|
@@ -2131,7 +2130,7 @@ export declare function summarizeCheckpoint(cp: Checkpoint, disclose?: (sentence
|
|
|
2131
2130
|
*/
|
|
2132
2131
|
export declare function summarizeStoredCheckpoint(cp: Checkpoint, memo: WeakMap<Checkpoint, CheckpointRowVerdict>, disclose?: (sentence: string) => void): CheckpointSummary;
|
|
2133
2132
|
/**
|
|
2134
|
-
* The pluggable durable seam (design/45 §2.1). Symmetric with `ToolResultStore
|
|
2133
|
+
* The pluggable durable seam (design/45 §2.1). Symmetric with `ToolResultStore`:
|
|
2135
2134
|
* create-once `put`, `get`, an **atomic CAS `resolve`** (the once-only foundation), and a `reap` for TTL
|
|
2136
2135
|
* expiry. A durable backend (TiDB) makes resume cross-replica; the default in-memory impl is single
|
|
2137
2136
|
* instance / tests only.
|
|
@@ -44,7 +44,7 @@ export interface ContextWindowOverlay {
|
|
|
44
44
|
* only — a pass outside a run is a requested one) and a deployment's overlay carry them, and every one of those
|
|
45
45
|
* doors judges them with {@link compactionSeatsDefect}.
|
|
46
46
|
*/
|
|
47
|
-
declare const COMPACTION_SEATS: readonly ["autoCompact", "manualCompact"];
|
|
47
|
+
export declare const COMPACTION_SEATS: readonly ["autoCompact", "manualCompact"];
|
|
48
48
|
export type CompactionSeat = (typeof COMPACTION_SEATS)[number];
|
|
49
49
|
/**
|
|
50
50
|
* The seats' ONE judgment, for every bag that carries them (a task's `compaction`, a `Runner.compactSession` request's
|
|
@@ -131,4 +131,3 @@ export declare function compactionEnabled(seat: CompactionSeat, requested: Reado
|
|
|
131
131
|
* number there is.
|
|
132
132
|
*/
|
|
133
133
|
export declare function physicalWindowOf(model: Model, overlay: ContextWindowOverlay | undefined): number;
|
|
134
|
-
export {};
|
|
@@ -4,7 +4,7 @@ import { RETIRED_COMPACTION_SEAT_KEYS, retiredKeyOf, retiredKeyRefusal } from ".
|
|
|
4
4
|
import { describeRejectedValue } from "./tool-search-setting.js";
|
|
5
5
|
const OVERLAY_KEYS = optionKeys()({ contextTokens: 0, autoCompactTokens: 0, autoCompact: 0, manualCompact: 0 });
|
|
6
6
|
const OVERLAY_READ_NAMES = Object.freeze([...OVERLAY_KEYS, ...Object.keys(RETIRED_COMPACTION_SEAT_KEYS)]);
|
|
7
|
-
const COMPACTION_SEATS = Object.freeze(["autoCompact", "manualCompact"]);
|
|
7
|
+
export const COMPACTION_SEATS = Object.freeze(["autoCompact", "manualCompact"]);
|
|
8
8
|
const SEAT_REACH = Object.freeze({
|
|
9
9
|
autoCompact: "false switches off the passes the engine starts by itself",
|
|
10
10
|
manualCompact: "false refuses the passes a caller asks for",
|
|
@@ -71,8 +71,8 @@ export interface EngineAttestation {
|
|
|
71
71
|
* is the engine's generic question (the chain's entry mint, {@link import("./ask-origin.js").chainAskReasonsOf}, writes no
|
|
72
72
|
* entry for one), and the literals it quotes. Valid only while the decision's `message` is still that sentence — a later
|
|
73
73
|
* layer that spread the decision and put its own words in `message` keeps them, and the account then reads as absent.
|
|
74
|
-
* Written only by the station that composed the sentence, for that sentence (the write gate's and the plan mode's questions
|
|
75
|
-
* the ask resolver's refusal that quotes one of them); a composer cannot state it (an unbranded record is refused). */
|
|
74
|
+
* Written only by the station that composed the sentence, for that sentence (the write gate's and the plan mode's questions,
|
|
75
|
+
* and the longer text `askWithTableSentence` makes of one of them; the ask resolver's refusal that quotes one of them); a composer cannot state it (an unbranded record is refused). */
|
|
76
76
|
readonly sentence?: EngineSentence;
|
|
77
77
|
/** The askers a station read off this ask where it first received it, before it narrated the sentence (an inherited station
|
|
78
78
|
* floating an ancestor's ask back into this leg's fold: its mark frames, its denial-limit fallback's sentence). The chain's
|
|
@@ -612,6 +612,15 @@ export interface EngineNotice {
|
|
|
612
612
|
* sessionId }` — `entries` every one, `entry` through the same reading as `permission.allowed_tool_not_granted`'s;
|
|
613
613
|
* `reader` ∈ `no_rule` / `named_no_tool` / `grammar_revised`; `rewrite.by` = `operator_write_without_rev`; `rulesSessionId` the session
|
|
614
614
|
* whose rules they are (an ancestor's on a delegated child), `sessionId` the run that read them.
|
|
615
|
+
* - `"config.legacy_tool_name"` — a tool policy's `deny` or `ask` list (the run's own policy, the session's stored rules, or the rules
|
|
616
|
+
* an ancestor's session handed down) holds names of tools the engine retired with NO successor (`TaskOutput`, `TeamCreate`, …: the
|
|
617
|
+
* retirement table's `removed` and `folded` lines). Such a name reaches no tool in any roster, so the prepare-time name audit leaves
|
|
618
|
+
* the entry out and the run goes on; this says so, because the person who wrote it believes it guards a tool. A retired name that
|
|
619
|
+
* was RENAMED (it has a successor the entry used to guard) is not here: it is still refused at prepare with the name to write, and
|
|
620
|
+
* the same code rides that thrown error. Audience `user`. Once per audited layer per prepared task, and only when the run goes on.
|
|
621
|
+
* `detail: { layer, entries: [{ field, entry, layer, guidance }], total, sessionId }` — `layer` ∈ `caller_policy` / `session_rules` /
|
|
622
|
+
* `ancestor_session_rules`, `field` ∈ `deny` / `ask`, `guidance` the retirement table's own line, `entries` unique by (field,
|
|
623
|
+
* entry) in scan order (at most 32), `total` every one.
|
|
615
624
|
* - `"config.durable_gate_unavailable"` — a durable-approval MANDATE is in force on a leg with NO
|
|
616
625
|
* checkpoint store: the per-principal `forceDurableGate` entitlement, or the task's own
|
|
617
626
|
* `durableApproval` opt-in with no live approver seat (`durableMandateSourceOf`, the predicate the
|
|
@@ -1180,8 +1189,11 @@ export declare function __resetMalformedNoticeSeatAnnouncement(): void;
|
|
|
1180
1189
|
* seat defect — the one fact every fallback would otherwise repeat — is announced once per process.
|
|
1181
1190
|
* · an ABSENT seat goes to the default seat a host installed ({@link setDefaultEngineNoticeSeat}; a function seat as above, and
|
|
1182
1191
|
* a present seat — non-function included — never falls through to it), else prints the historic `console.warn` line verbatim.
|
|
1192
|
+
* · `admission`, when given, is asked once with the notice as it will leave (after the text pass and the routing lift): `false`
|
|
1193
|
+
* hands it to no seat. A predicate that answers `false` has already said so on its own account (the occupant judge mints its
|
|
1194
|
+
* `delegation.delivery_discarded`); it only judges and never rewrites the notice — the mint stays at the call site.
|
|
1183
1195
|
*/
|
|
1184
|
-
export declare function deliverEngineNotice(onNotice: ((notice: EngineNotice) => void) | undefined, notice: EngineNotice): void;
|
|
1196
|
+
export declare function deliverEngineNotice(onNotice: ((notice: EngineNotice) => void) | undefined, notice: EngineNotice, admission?: (notice: EngineNotice) => boolean): void;
|
|
1185
1197
|
/**
|
|
1186
1198
|
* #259 loud half, one notice PER FAMILY (`task.user_steer_undrained` / `task.user_followup_undrained`):
|
|
1187
1199
|
* a consumer routing on `code` alone must never mistake a stranded follow-up for a stranded steer, so
|
|
@@ -9,7 +9,7 @@ let malformedNoticeSeatAnnounced = false;
|
|
|
9
9
|
export function __resetMalformedNoticeSeatAnnouncement() {
|
|
10
10
|
malformedNoticeSeatAnnounced = false;
|
|
11
11
|
}
|
|
12
|
-
export function deliverEngineNotice(onNotice, notice) {
|
|
12
|
+
export function deliverEngineNotice(onNotice, notice, admission) {
|
|
13
13
|
notice = {
|
|
14
14
|
...notice,
|
|
15
15
|
message: typeof notice.message === "string" ? egressText("same-principal", notice.message) : notice.message,
|
|
@@ -18,6 +18,8 @@ export function deliverEngineNotice(onNotice, notice) {
|
|
|
18
18
|
if (notice.sessionId === undefined && typeof notice.detail?.["sessionId"] === "string") {
|
|
19
19
|
notice = { ...notice, sessionId: notice.detail["sessionId"] };
|
|
20
20
|
}
|
|
21
|
+
if (admission !== undefined && !admission(notice))
|
|
22
|
+
return;
|
|
21
23
|
const seat = onNotice === undefined ? defaultNoticeSeat : onNotice;
|
|
22
24
|
if (typeof seat === "function") {
|
|
23
25
|
try {
|
|
@@ -639,8 +639,8 @@ export interface FileHistoryBlobExchange {
|
|
|
639
639
|
/**
|
|
640
640
|
* The store's blob exchange, read as one capability: `undefined` when the store carries no `blobExchange`; its three
|
|
641
641
|
* members, bound, when it carries the whole group; a refusal (`config.invalid_argument`) when the group is not an
|
|
642
|
-
* object or a member is missing or not a function.
|
|
643
|
-
*
|
|
642
|
+
* object or a member is missing or not a function. The group is the only reading: no other member of the store says
|
|
643
|
+
* anything about the capability.
|
|
644
644
|
*/
|
|
645
645
|
export declare function fileHistoryBlobExchangeOf(store: FileHistoryStore): FileHistoryBlobExchange | undefined;
|
|
646
646
|
/**
|
|
@@ -249,17 +249,13 @@ function judgeFileHistoryEnvelope(data) {
|
|
|
249
249
|
const BLOB_EXCHANGE_MEMBERS = Object.freeze(["put", "get", "has"]);
|
|
250
250
|
export function fileHistoryBlobExchangeOf(store) {
|
|
251
251
|
const owner = "FileHistoryStore.blobExchange";
|
|
252
|
-
let marker;
|
|
253
252
|
let group;
|
|
254
253
|
try {
|
|
255
|
-
marker = Reflect.get(store, "syncBlobFaces");
|
|
256
254
|
group = store.blobExchange;
|
|
257
255
|
}
|
|
258
256
|
catch (cause) {
|
|
259
257
|
throw invalidBlobExchange(`${owner} could not be read (${thrownText(cause)}).`);
|
|
260
258
|
}
|
|
261
|
-
if (marker !== undefined)
|
|
262
|
-
throw invalidBlobExchange(`FileHistoryStore carries the retired syncBlobFaces marker — the blob exchange is the ${owner} group (put / get / has): present means the capability, absent means none.`);
|
|
263
259
|
if (group === undefined)
|
|
264
260
|
return undefined;
|
|
265
261
|
if (typeof group !== "object" || group === null)
|
package/dist/core/gate-fold.js
CHANGED
|
@@ -5,7 +5,7 @@ import { normalizeReadRootCandidate } from "./read-root-candidate.js";
|
|
|
5
5
|
import { engineFailClosedExit, hookDenyExit, settledScreenExit, takeInheritedScreen } from "./runner/gate-exit.js";
|
|
6
6
|
import { noteRewrite, POLICY_AUTHOR, readRejudge, screenRewrite } from "./rewrite-rejudge.js";
|
|
7
7
|
import { traceHookCrash } from "./gate-crash-trace.js";
|
|
8
|
-
import { writeProtectionMandated, writeProtectionReachOf, writeProtectionTightenDecision } from "./write-protect.js";
|
|
8
|
+
import { askWithTableSentence, writeProtectionMandated, writeProtectionReachOf, writeProtectionTightenDecision } from "./write-protect.js";
|
|
9
9
|
import { createGateDeadline, awaitWriteProtectionJudgment, gateWaitFailureOf, withGateTimeout } from "./gate-bounded-await.js";
|
|
10
10
|
import { shellReadFaceWords } from "../tools/fs/shell-read-face.js";
|
|
11
11
|
import { failedJudgmentDeny } from "./runner/policy-throw.js";
|
|
@@ -183,6 +183,8 @@ export async function runGateFold(pass) {
|
|
|
183
183
|
else
|
|
184
184
|
pass.deniedBy = "write_protection";
|
|
185
185
|
}
|
|
186
|
+
else if (decision?.action === "ask" && decision.message !== undefined && pass.decision.action === "ask")
|
|
187
|
+
pass.decision = askWithTableSentence(pass.decision, decision.message, { toolCallId, toolName });
|
|
186
188
|
}
|
|
187
189
|
if (pass.decision.action !== "deny" && input.crossBoundaryCheck?.obligation({ toolName, args: pass.policyRewrite !== undefined ? pass.policyRewrite : pass.currentInput, toolCallId }).mandate === true) {
|
|
188
190
|
const marks = { requiresRealApproval: true, crossBoundaryMandated: true };
|
|
@@ -23,9 +23,9 @@ export declare const GOVERNANCE_CODES: {
|
|
|
23
23
|
};
|
|
24
24
|
export type GovernanceCode = keyof typeof GOVERNANCE_CODES;
|
|
25
25
|
/**
|
|
26
|
-
* `memory.*` error codes DELIBERATELY outside governance:
|
|
27
|
-
*
|
|
28
|
-
* mechanical faults and
|
|
26
|
+
* `memory.*` error codes DELIBERATELY outside governance: engine incident codes (announce /
|
|
27
|
+
* partition incidents, tail truncation, consolidation outcomes) —
|
|
28
|
+
* mechanical faults and disclosures, not per-principal policy verdicts; they classify
|
|
29
29
|
* as `logic`. The gate test forces every `memory.*` literal minted in src/ to appear EITHER in
|
|
30
30
|
* {@link GOVERNANCE_CODES} or here — a new code gets NAMED and dispositioned, never silently
|
|
31
31
|
* classified.
|
|
@@ -145,7 +145,7 @@ export type NoticeAudience = "user" | "operator";
|
|
|
145
145
|
* the union's catalog ({@link EngineNotice.code}). The groups below say only which family a row joins,
|
|
146
146
|
* so the catalog is not written a second time here and the two cannot drift.
|
|
147
147
|
*/
|
|
148
|
-
export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.forward_sink_failed", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "permission.allowed_tool_not_granted", "mods.registration_refused", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "delegation.resume_lane_missing", "delegation.delivery_discarded", "mcp.injection_dropped", "mcp.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.harvest_refused", "memory.harvest_conflict", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "task.user_steer_undrained", "task.user_followup_undrained", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "session.lineage_rerooted", "instructions.source_changed", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped"];
|
|
148
|
+
export declare const ENGINE_NOTICE_CODES: readonly ["config.autocompact_window_clamped", "config.env_timeout_discarded", "config.materialize_env_discarded", "config.models_swapped", "config.context_settings_swapped", "config.read_face_swapped", "config.read_face_deployment_clamped", "config.write_face_swapped", "config.write_face_deployment_clamped", "config.read_deny_swapped", "config.tool_model_gate_removed", "config.tool_model_gate_unknown_class", "config.tool_model_gate_env_invalid", "config.artifact_host_invalid", "config.task_root_not_canonical", "config.write_protection_target_view_absent", "config.path_view_unresolved", "config.execution_env_capability_invalid", "config.read_deny_floor_unkept", "config.read_floor_confinement_unavailable", "config.tool_card_undeclared", "config.tool_face_undeclared", "config.tool_face_invalid", "config.forward_sink_failed", "config.durable_gate_unavailable", "config.peer_admission_out_of_range", "config.peer_lane_unmounted", "config.secret_env_scrubbed", "inherit_env.names_withheld", "config.credential_not_withheld", "config.cross_boundary_posture_undeclared", "config.cross_boundary_record_unwritten", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "config.session_rules_earlier_grammar", "config.legacy_tool_name", "permission.allowed_tool_not_granted", "mods.registration_refused", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "classifier.fallback", "classifier.seat_rate_limited", "classifier.role_defaulted", "classifier.contract_broken", "classifier.unavailable", "checkpoint.execution_outcome_unrecorded", "delegation.transcript_integrity", "delegation.ask_unresolvable", "delegation.resume_lane_missing", "delegation.delivery_discarded", "mcp.injection_dropped", "mcp.revocation_probe_failed", "mcp.server_redialed", "mcp.authorization_required", "mcp.credential_echoed", "workflow.governance_key_stripped", "workflow.agent_option_ignored", "memory.session_polluted", "memory.harvest_quarantined", "memory.harvest_refused", "memory.harvest_conflict", "memory.delegation_static_mark_waived", "memory.content_class_declared", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "memory.consolidation_recommended", "memory.consolidation_committed", "memory.consolidation_conflict", "memory.consolidation_incomplete", "memory.consolidation_refused", "memory.consolidation_withheld", "memory.restore_withheld", "memory.project_scope_absent", "route.fallback_to_primary", "route.classifier_unroutable", "route.seat_detached", "advisor.not_attached", "route.credential_origin_mismatch", "route.credential_rebound", "route.response_model_mismatch", "route.tool_call_id_folded", "route.finish_reason_unknown", "route.stream_end_ignored", "route.extra_body_reserved_dropped", "model.capability_downgraded", "model.role_defaulted", "context.tool_turn_repaired", "context.media_removed", "context.tool_schema_removed", "task.user_steer_undrained", "task.user_followup_undrained", "steering.parked_input_blocked", "task.turn_interrupted", "task.halt_unconsumed", "task.late_approval", "task.interrupt_unconsumed", "task.tool_turn_incomplete", "approval.read_root_granted", "approval.read_root_grant_rejected", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "skills.listing_truncated", "agents.listing_truncated", "tool_result.offload_put_failed", "tool_result.media_refused", "config.image_processor_unavailable", "fs.staging_file_left", "fs.staging_file_swept", "session.lineage_rerooted", "instructions.source_changed", "memory.layer_locked_legacy", "server.model_unreachable", "permission.entry_mode_clamped"];
|
|
149
149
|
/** A catalogued code (see {@link ENGINE_NOTICE_CODES}); {@link NOTICE_MINTER} says who mints it. NOT the type of
|
|
150
150
|
* `EngineNotice.code`, which stays `string` — a host forwarding its own notices through the same
|
|
151
151
|
* sink is a supported shape, and narrowing that field would break it. */
|
|
@@ -198,6 +198,7 @@ declare const NOTICE_AUDIENCE_TABLE: {
|
|
|
198
198
|
readonly "permission.rule_store_unavailable": "user";
|
|
199
199
|
readonly "permission.rule_row_dropped": "user";
|
|
200
200
|
readonly "config.session_rules_earlier_grammar": "user";
|
|
201
|
+
readonly "config.legacy_tool_name": "user";
|
|
201
202
|
readonly "permission.allowed_tool_not_granted": "user";
|
|
202
203
|
readonly "mods.registration_refused": "user";
|
|
203
204
|
readonly "memory.capture_opted_out": "user";
|
|
@@ -345,6 +346,7 @@ declare const NOTICE_MINTER_TABLE: {
|
|
|
345
346
|
readonly "permission.rule_store_unavailable": "engine";
|
|
346
347
|
readonly "permission.rule_row_dropped": "engine";
|
|
347
348
|
readonly "config.session_rules_earlier_grammar": "engine";
|
|
349
|
+
readonly "config.legacy_tool_name": "engine";
|
|
348
350
|
readonly "permission.allowed_tool_not_granted": "engine";
|
|
349
351
|
readonly "mods.registration_refused": "engine";
|
|
350
352
|
readonly "peer.inbound_disposition": "engine";
|
|
@@ -12,8 +12,6 @@ export const GOVERNANCE_CODES = {
|
|
|
12
12
|
"memory.capture_optout_denied": "terminal",
|
|
13
13
|
};
|
|
14
14
|
export const NON_GOVERNANCE_MEMORY_CODES = new Set([
|
|
15
|
-
"memory.secret_detected",
|
|
16
|
-
"memory.promotable_ungated",
|
|
17
15
|
"memory.announce_failed",
|
|
18
16
|
"memory.announcement_withheld",
|
|
19
17
|
"memory.partition_adopt_failed",
|
|
@@ -43,7 +41,6 @@ export const NON_GOVERNANCE_MEMORY_CODES = new Set([
|
|
|
43
41
|
"memory.consolidation_withheld",
|
|
44
42
|
"memory.restore_withheld",
|
|
45
43
|
"memory.project_scope_absent",
|
|
46
|
-
"memory.projection_failed",
|
|
47
44
|
"memory.observation_settlement_unavailable",
|
|
48
45
|
"memory.consolidation_disabled",
|
|
49
46
|
"memory.consolidation_gated",
|
|
@@ -97,6 +94,7 @@ export const NON_GOVERNANCE_MEMORY_CODES = new Set([
|
|
|
97
94
|
"memory.capture_optout_sweep_failed",
|
|
98
95
|
"memory.target_outside_store",
|
|
99
96
|
"memory.scope_home_not_directory",
|
|
97
|
+
"memory.control_plane_links_unsupported",
|
|
100
98
|
"memory.root_anchor_backfilled",
|
|
101
99
|
"memory.root_reanchored",
|
|
102
100
|
]);
|
|
@@ -167,6 +165,7 @@ export const ENGINE_NOTICE_CODES = Object.freeze([
|
|
|
167
165
|
"permission.rule_store_unavailable",
|
|
168
166
|
"permission.rule_row_dropped",
|
|
169
167
|
"config.session_rules_earlier_grammar",
|
|
168
|
+
"config.legacy_tool_name",
|
|
170
169
|
"permission.allowed_tool_not_granted",
|
|
171
170
|
"mods.registration_refused",
|
|
172
171
|
"peer.inbound_disposition",
|
|
@@ -283,6 +282,7 @@ const NOTICE_AUDIENCE_TABLE = {
|
|
|
283
282
|
"permission.rule_store_unavailable": "user",
|
|
284
283
|
"permission.rule_row_dropped": "user",
|
|
285
284
|
"config.session_rules_earlier_grammar": "user",
|
|
285
|
+
"config.legacy_tool_name": "user",
|
|
286
286
|
"permission.allowed_tool_not_granted": "user",
|
|
287
287
|
"mods.registration_refused": "user",
|
|
288
288
|
"memory.capture_opted_out": "user",
|
|
@@ -411,6 +411,7 @@ const NOTICE_MINTER_TABLE = {
|
|
|
411
411
|
"permission.rule_store_unavailable": "engine",
|
|
412
412
|
"permission.rule_row_dropped": "engine",
|
|
413
413
|
"config.session_rules_earlier_grammar": "engine",
|
|
414
|
+
"config.legacy_tool_name": "engine",
|
|
414
415
|
"permission.allowed_tool_not_granted": "engine",
|
|
415
416
|
"mods.registration_refused": "engine",
|
|
416
417
|
"peer.inbound_disposition": "engine",
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* mods layer).
|
|
5
5
|
*/
|
|
6
6
|
import type { HookInvocationIdentity } from "./hooks.js";
|
|
7
|
+
import type { SessionAddress } from "./task-notification.js";
|
|
7
8
|
import type { AskSourceIdentity } from "./tool-policy.js";
|
|
8
9
|
/**
|
|
9
10
|
* The id a delegated leg's events carry as `agentId`: the leg's task id ({@link legTaskIdOf}) — for a background child, the
|
|
@@ -70,11 +71,26 @@ export interface NoticeAddress {
|
|
|
70
71
|
/** Present on a delegated leg that carries one ({@link agentIdOf}): the agent id the leg's events and its spawner's card name. */
|
|
71
72
|
readonly agentId?: string;
|
|
72
73
|
}
|
|
74
|
+
/** Where a leg's user-face notice goes ({@link noticeAddressOf}): the keys it carries, and the session address it is for. */
|
|
75
|
+
export interface NoticeRoute {
|
|
76
|
+
/** The keys the notice carries — spread into its detail as-is. */
|
|
77
|
+
readonly address: NoticeAddress;
|
|
78
|
+
/** The session address a notice routed away from the leg's own session is for: on a delegated leg addressed to its tree's
|
|
79
|
+
* root, the root's id and the root occupant the tree was born under (absent = unknown). A delivery to it is judged like any
|
|
80
|
+
* frame addressed there (`PendingSessionNotifications.discardsStaleNotice`). Never spread into a notice: an occupant token
|
|
81
|
+
* is an addressing fact, not a word the wire carries. Absent when the notice goes to the leg's own session. */
|
|
82
|
+
readonly destination?: SessionAddress;
|
|
83
|
+
}
|
|
73
84
|
/**
|
|
74
85
|
* The address of a leg's user-face notice — one rule: a user-face notice goes to the end of the delegation tree a person
|
|
75
86
|
* watches, and says which leg it came from. A top-level leg's notice is addressed to its own session and carries no source
|
|
76
87
|
* keys. A delegated leg's notice is addressed to the tree's root session (`internals.rootSessionId`: an intermediate parent
|
|
77
88
|
* at depth ≥ 2 has no host leg of its own to read it on) and carries the delegated leg's session and agent id — the shape a
|
|
78
|
-
* subagent's permission denial takes upstream (the top-level session id plus the agent id).
|
|
89
|
+
* subagent's permission denial takes upstream (the top-level session id plus the agent id). The root is a session address
|
|
90
|
+
* like every other destination: its id and its occupant (`internals.rootSessionIncarnation`), so a notice of a tree whose
|
|
91
|
+
* root was deleted and created again is not delivered to the root's later occupant.
|
|
79
92
|
*/
|
|
80
|
-
export declare function noticeAddressOf(askSource: AskSourceIdentity,
|
|
93
|
+
export declare function noticeAddressOf(askSource: AskSourceIdentity, root: {
|
|
94
|
+
readonly rootSessionId?: string;
|
|
95
|
+
readonly rootSessionIncarnation?: string;
|
|
96
|
+
} | undefined): NoticeRoute;
|
|
@@ -16,15 +16,13 @@ export function mintAskSourceIdentity(leg) {
|
|
|
16
16
|
...(leg.isDelegatedChild ? { isDelegatedChild: true } : {}),
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
export function noticeAddressOf(askSource,
|
|
19
|
+
export function noticeAddressOf(askSource, root) {
|
|
20
20
|
const own = askSource.sourceSessionId;
|
|
21
21
|
if (own === undefined || own.length === 0)
|
|
22
22
|
throw new TypeError("noticeAddressOf: the leg's ask source carries no session");
|
|
23
23
|
if (askSource.isDelegatedChild !== true)
|
|
24
|
-
return { sessionId: own };
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
...(askSource.agentId !== undefined ? { agentId: askSource.agentId } : {}),
|
|
29
|
-
};
|
|
24
|
+
return { address: { sessionId: own } };
|
|
25
|
+
const rootId = root?.rootSessionId !== undefined && root.rootSessionId.length > 0 ? root.rootSessionId : undefined;
|
|
26
|
+
const address = { sessionId: rootId ?? own, sourceSessionId: own, ...(askSource.agentId !== undefined ? { agentId: askSource.agentId } : {}) };
|
|
27
|
+
return rootId !== undefined && rootId !== own ? { address, destination: { sessionId: rootId, occupant: root?.rootSessionIncarnation } } : { address };
|
|
30
28
|
}
|
|
@@ -103,7 +103,7 @@ export interface MailboxPeerMeta {
|
|
|
103
103
|
* WHO the record is for: the occupant (`SessionMetadata.incarnation`) of the session the writer addressed, as the writer
|
|
104
104
|
* resolved that address — a park seat from its leg's address, a sender from the recipient's directory row, a notice from the
|
|
105
105
|
* reply address it answers. A session box outlives its occupant (the id can be deleted and created again, the box stays), so a
|
|
106
|
-
* drain hands a record only to the occupant it names ({@link import("
|
|
106
|
+
* drain hands a record only to the occupant it names ({@link import("../engine/session/repo-utils.js").sameOccupant}: absent on
|
|
107
107
|
* both sides is one occupant — a deployment whose store mints no tokens; absent on one side only is another occupant). A
|
|
108
108
|
* record for another occupant is discarded with an account, never delivered. An addressing fact, not a secret and not a
|
|
109
109
|
* credential: it proves nothing about who wrote the record.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* they land) — a second implementation would be a drift seam, exactly the class the challenge
|
|
9
9
|
* exclusion view closed.
|
|
10
10
|
*/
|
|
11
|
-
import type { MemoryBackend, MemoryEntry, MemoryEntryHeader, MemoryEntryOrigin, MemoryGovernanceStore, NotePatch } from "./types.js";
|
|
11
|
+
import type { MemoryBackend, MemoryEntry, MemoryEntryHeader, MemoryEntryOrigin, MemoryGovernanceObjects, MemoryGovernanceStore, NotePatch } from "./types.js";
|
|
12
12
|
import type { ConsolidationDriverRunRow } from "./consolidation-driver.js";
|
|
13
13
|
/**
|
|
14
14
|
* Derive the SUPERSEDED set from a committed header listing: superseded entry id → the standing
|
|
@@ -547,9 +547,9 @@ export type MemoryGovernanceDurability = "backend" | "replica-local";
|
|
|
547
547
|
* `"backend"` ⇔ the backend publishes its own control plane (`controlPlaneRoot`, a non-empty string — the File backend:
|
|
548
548
|
* every control-plane record, the consolidation store and the governance ledgers alike, sits in its directory). A
|
|
549
549
|
* backend that carries `MemoryBackend.governance` but no control plane still answers `"replica-local"`: the
|
|
550
|
-
* consolidation state
|
|
551
|
-
* announcement queue a consolidation writes)
|
|
552
|
-
*
|
|
550
|
+
* consolidation state, the governance documents (lineage, challenges, settlements, session accounts and the
|
|
551
|
+
* announcement queue a consolidation writes) and the instruction holds with their captured bytes (#3485) ride its
|
|
552
|
+
* store, and the answer stays `"replica-local"` there: eligibility also reads the capture opt-out records
|
|
553
553
|
* (`MemoryEngineOptions.captureRecordStore`: a carrier the host injects is its declaration of a store every replica
|
|
554
554
|
* reads; the default is a file in the engine's control plane — the store's own directory on the File backend): an
|
|
555
555
|
* answer that turns `"backend"` for a backend without a control plane must hold for the default carrier as well.
|
|
@@ -557,6 +557,12 @@ export type MemoryGovernanceDurability = "backend" | "replica-local";
|
|
|
557
557
|
export declare function memoryGovernanceDurability(backend: MemoryBackend): MemoryGovernanceDurability;
|
|
558
558
|
/** The control plane a File governance store keeps its documents in; `undefined` for any other store. */
|
|
559
559
|
export declare function fileGovernanceStoreDir(store: MemoryGovernanceStore): string | undefined;
|
|
560
|
+
/** A store's control objects as a reader that must see damage rather than be spared it reads them — an erasure's count,
|
|
561
|
+
* an export's roster: for a File store the listing names every entry standing in the kind's directory
|
|
562
|
+
* (`standingFileControlObjectNames`) — a subdirectory, a dangling link, a name no writer could have used — so the verbs
|
|
563
|
+
* that meet it refuse it by name and the reader counts it; any other store's listing is its own (KL-3466-c). The other
|
|
564
|
+
* verbs are the store's. */
|
|
565
|
+
export declare function standingControlObjectsOf(store: MemoryGovernanceStore): MemoryGovernanceObjects;
|
|
560
566
|
/**
|
|
561
567
|
* The consolidation state's File store over one control plane — the gate file, the plan workbook, the intent
|
|
562
568
|
* credentials, the run account and the mint archive exactly as they have always been laid out (same names, same
|
|
@@ -2,7 +2,7 @@ import { existsSync, readdirSync, readFileSync, renameSync, rmSync } from "node:
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { uuidv7 } from "../../engine/session/uuid.js";
|
|
4
4
|
import { atomicWriteFileSync, fileGovernanceDocOf, lockedStrictUpdate, readStrictSidecar, ControlPlaneCorruptError, ensureDirExists } from "./layout.js";
|
|
5
|
-
import { deleteFileControlObject, getFileControlObject, listFileControlObjects, moveFileControlObject, putFileControlObject } from "./control-objects.js";
|
|
5
|
+
import { deleteFileControlObject, getFileControlObject, listFileControlObjects, moveFileControlObject, putFileControlObject, standingFileControlObjectNames } from "./control-objects.js";
|
|
6
6
|
import { thrownText } from "../thrown-value.js";
|
|
7
7
|
import { optionKeys, receiveMembers } from "../own-property-receipt.js";
|
|
8
8
|
export function deriveSupersededSet(headers, opts = {}) {
|
|
@@ -408,6 +408,16 @@ const FILE_GOVERNANCE_DIRS = new WeakMap();
|
|
|
408
408
|
export function fileGovernanceStoreDir(store) {
|
|
409
409
|
return FILE_GOVERNANCE_DIRS.get(store);
|
|
410
410
|
}
|
|
411
|
+
export function standingControlObjectsOf(store) {
|
|
412
|
+
const dir = fileGovernanceStoreDir(store);
|
|
413
|
+
return {
|
|
414
|
+
putObject: (kind, name, bytes, meta) => store.putObject(kind, name, bytes, meta),
|
|
415
|
+
getObject: (kind, name) => store.getObject(kind, name),
|
|
416
|
+
listObjects: dir === undefined ? (kind) => store.listObjects(kind) : async (kind) => standingFileControlObjectNames(dir, kind),
|
|
417
|
+
moveObject: (from, to) => store.moveObject(from, to),
|
|
418
|
+
deleteObject: (kind, name) => store.deleteObject(kind, name),
|
|
419
|
+
};
|
|
420
|
+
}
|
|
411
421
|
function isMintArchive(value) {
|
|
412
422
|
return typeof value === "object" && value !== null && Reflect.get(value, "kind") === "llm-consolidation-plan";
|
|
413
423
|
}
|
|
@@ -1,17 +1,43 @@
|
|
|
1
1
|
import { type MemoryControlObjectKind } from "./types.js";
|
|
2
|
+
import { type QuarantineCapture } from "./layout.js";
|
|
2
3
|
/** Where a File store stages an object's bytes before publishing them under the object's name. Never a kind's
|
|
3
4
|
* directory: a listing of a kind answers published names only. */
|
|
4
5
|
export declare const CONTROL_OBJECT_STAGE_DIR = ".control-object-stage";
|
|
5
6
|
/** A control-object kind's directory under a File store's control plane. A kind outside
|
|
6
7
|
* {@link MEMORY_CONTROL_OBJECT_KINDS} is refused (`memory.control_object_unknown`) — never given a directory of its own. */
|
|
7
8
|
export declare function fileControlObjectDirOf(kind: MemoryControlObjectKind): string;
|
|
8
|
-
/** A name a store keeps an object under: one opaque, non-empty segment — never `.` / `..`, never a
|
|
9
|
+
/** A name a store keeps an object under: one opaque, non-empty segment of at most 255 UTF-8 bytes — never `.` / `..`, never a
|
|
10
|
+
* separator or a NUL. */
|
|
9
11
|
export declare function isControlObjectName(name: unknown): name is string;
|
|
10
|
-
/**
|
|
12
|
+
/** The filesystem code behind a File control-object refusal: the refusal's own `code` when it is the filesystem's, else
|
|
13
|
+
* the code of the filesystem error it was raised over (`cause`) — `undefined` when neither names one. */
|
|
14
|
+
export declare function fileControlObjectFaultCode(err: unknown): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The open judge of a File governance store over `controlDir` (#3512): the store publishes every object with `link`
|
|
17
|
+
* ({@link putFileControlObject}, {@link moveFileControlObject}), so on a file system that cannot make a hard link every
|
|
18
|
+
* object write would fail — and a containment whose copy fails still takes the suspect off the plane (its copy is
|
|
19
|
+
* lost, not kept). One link is tried, at the open, between two files at the control plane's top level (named with
|
|
20
|
+
* `LINK_PROBE_PREFIX`), and both are removed; a link the file system refuses is refused here
|
|
21
|
+
* (`memory.control_plane_links_unsupported`, `controlPlaneLinksRefusal`, `detail.path` = `controlDir`). Not judged — the
|
|
22
|
+
* open proceeds as before — when the first file cannot be created (a control plane that is read-only, full or not
|
|
23
|
+
* writable: what was not tried is not claimed) or when the link's name already stands. Asked at each open, never
|
|
24
|
+
* cached. The callers are the two holders of a File store: the File backend's construction and an engine whose backend
|
|
25
|
+
* carries no store of its own. `controlDir` stands when it is asked.
|
|
26
|
+
*/
|
|
27
|
+
export declare function probeControlPlaneLinks(controlDir: string): void;
|
|
28
|
+
/** Write `(kind, name)` once ({@link import("./types.js").MemoryGovernanceStore.putObject}): `"existed"` only when the name already
|
|
29
|
+
* holds these same bytes; a name holding other bytes is refused, never answered as written. */
|
|
11
30
|
export declare function putFileControlObject(controlDir: string, kind: MemoryControlObjectKind, name: string, bytes: Uint8Array): "created" | "existed";
|
|
12
31
|
/** A control object's bytes ({@link import("./types.js").MemoryGovernanceStore.getObject}). */
|
|
13
32
|
export declare function getFileControlObject(controlDir: string, kind: MemoryControlObjectKind, name: string): Uint8Array | undefined;
|
|
14
|
-
/** Every name
|
|
33
|
+
/** Every name standing in a kind's directory, sorted — the objects and whatever else stands there (a subdirectory, a dangling link,
|
|
34
|
+
* a name no writer could have used). For the readers that must see damage rather than be spared it: the adoption of a replica
|
|
35
|
+
* refuses each such entry by name and withholds the documents behind it, and the strays reader counts them — an entry standing
|
|
36
|
+
* where an object's record belongs is a fact, never an absence. {@link listFileControlObjects} is the store's verb: objects only. */
|
|
37
|
+
export declare function standingFileControlObjectNames(controlDir: string, kind: MemoryControlObjectKind): string[];
|
|
38
|
+
/** Every name of `kind`, sorted ({@link import("./types.js").MemoryGovernanceStore.listObjects}): the regular files under a legal
|
|
39
|
+
* name — the entries {@link getFileControlObject} reads. A subdirectory or a dangling link in a kind's directory is no object and
|
|
40
|
+
* is not named here; the verbs that meet it refuse it, and {@link standingFileControlObjectNames} still names it. */
|
|
15
41
|
export declare function listFileControlObjects(controlDir: string, kind: MemoryControlObjectKind): string[];
|
|
16
42
|
/** Move one object, never overwriting ({@link import("./types.js").MemoryGovernanceStore.moveObject}). */
|
|
17
43
|
export declare function moveFileControlObject(controlDir: string, from: {
|
|
@@ -21,5 +47,12 @@ export declare function moveFileControlObject(controlDir: string, from: {
|
|
|
21
47
|
readonly kind: MemoryControlObjectKind;
|
|
22
48
|
readonly name: string;
|
|
23
49
|
}): "moved" | "already-moved";
|
|
50
|
+
/** {@link putFileControlObject} for a writer whose record is the first one under the name — the synchronous twin of
|
|
51
|
+
* `putControlObjectOnce` (`layout.ts`), one law: `"existed"` ⇔ an object stands there that reads back (the same bytes,
|
|
52
|
+
* or other bytes the put refused); a refusal no readable object explains is the put's own and is thrown. */
|
|
53
|
+
export declare function putFileControlObjectOnce(controlDir: string, kind: MemoryControlObjectKind, name: string, bytes: Uint8Array): "created" | "existed";
|
|
54
|
+
/** The File store's capture of one suspect file's copy into its `quarantine` objects — the synchronous twin of
|
|
55
|
+
* `captureIntoQuarantine` (`layout.ts`) for the File backend's own synchronous read paths, under the same names. */
|
|
56
|
+
export declare function captureIntoFileQuarantine(controlDir: string, path: string, content: string, now: () => number): QuarantineCapture;
|
|
24
57
|
/** Delete one object ({@link import("./types.js").MemoryGovernanceStore.deleteObject}). */
|
|
25
58
|
export declare function deleteFileControlObject(controlDir: string, kind: MemoryControlObjectKind, name: string): boolean;
|