@sema-agent/core 7.57.0 → 7.58.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 +385 -0
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/brain/route-adjudicator.js +2 -1
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/allow-entry.d.ts +2 -1
- package/dist/core/allow-entry.js +2 -1
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +27 -11
- package/dist/core/checkpoint-store.js +13 -3
- package/dist/core/engine-notice.d.ts +1 -1
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +6 -3
- package/dist/core/gate-lanes.js +11 -2
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/hooks.d.ts +4 -1
- package/dist/core/hooks.js +12 -5
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/locked-config.d.ts +15 -1
- package/dist/core/locked-config.js +38 -2
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +7 -1
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-link.d.ts +5 -2
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +6 -14
- package/dist/core/mcp.js +77 -37
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +10 -8
- package/dist/core/mods/kernel/events.d.ts +5 -1
- package/dist/core/mods/kernel/events.js +1 -1
- package/dist/core/mods/kernel/registration.d.ts +5 -1
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +2 -2
- package/dist/core/mods/stations.js +1 -1
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +12 -3
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +186 -0
- package/dist/core/peer-seat.js +307 -0
- package/dist/core/present-plan-tool.d.ts +10 -1
- package/dist/core/present-plan-tool.js +46 -2
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +37 -0
- package/dist/core/rewrite-rejudge.js +40 -0
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +13 -5
- package/dist/core/runner/gate-exit.d.ts +18 -4
- package/dist/core/runner/gate-exit.js +5 -1
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
- package/dist/core/runner/prepare-config-doors.d.ts +8 -5
- package/dist/core/runner/prepare-config-doors.js +12 -10
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +15 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -3
- package/dist/core/runner/prepare-hands-readface.js +4 -1
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +19 -23
- package/dist/core/runner/prepare-policy-chain.d.ts +4 -4
- package/dist/core/runner/prepare-policy-chain.js +2 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +3 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.js +25 -12
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -2
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.js +1 -0
- package/dist/core/runner/run-leg.js +5 -1
- package/dist/core/runner/run-notification-lane.js +3 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +1 -0
- package/dist/core/runner/tool-occurrence.d.ts +4 -1
- package/dist/core/runner/tool-occurrence.js +2 -1
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +2 -2
- package/dist/core/sensitive-path-policy.js +6 -7
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-store.d.ts +84 -19
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/task-event.d.ts +68 -8
- package/dist/core/task-registry-shared.d.ts +2 -1
- package/dist/core/task-spec.d.ts +37 -0
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +1 -1
- package/dist/core/tool-catalog-entries.js +1 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- package/dist/core/wiring-manifest.d.ts +12 -3
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/execution-env/node-execution-env.js +15 -11
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +5 -0
- package/dist/engine/harness/agent-harness.js +2 -0
- package/dist/engine/harness/types.d.ts +48 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/types.d.ts +12 -3
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +7 -1
- package/dist/index.d.ts +13 -6
- package/dist/index.js +10 -4
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +2 -2
- package/dist/internal/harness.js +2 -2
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +1 -1
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +8 -1
- package/dist/tools/fs/shell-read-check.js +59 -15
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +10 -1
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +4 -2
- package/test/export-surface.snapshot.json +63 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
|
@@ -28,6 +28,7 @@ export function runIdentityWiring(input) {
|
|
|
28
28
|
internalsNotifier.notify(() => observeThenableRejection(internals?.onWiringManifest?.(wiringManifest), internalsNotifier, "runtask.onWiringManifest"), "runtask.onWiringManifest");
|
|
29
29
|
prepared.toolRosterDeltas.subscribe((delta) => queue.push({ type: "tool_roster_delta", delta, ...ident() }));
|
|
30
30
|
prepared.toolDisclosure?.subscribe((snapshot) => queue.push({ type: "tool_disclosure", ...snapshot, ...ident() }));
|
|
31
|
+
prepared.workspaceFrame.subscribe((snapshot) => queue.push({ type: "workspace_changed", ...snapshot, ...ident() }));
|
|
31
32
|
const delegationLifecycleNotifier = createSafeNotifier({
|
|
32
33
|
onError: (f) => console.warn(`[sema-core] ${f.site}: delegation-lifecycle observer threw (contained; further failures counted, not re-disclosed): ${f.error.message}`),
|
|
33
34
|
});
|
|
@@ -59,6 +59,7 @@ export async function runLeg(input) {
|
|
|
59
59
|
let abortedLive = false;
|
|
60
60
|
let userInterruptedLive = false;
|
|
61
61
|
let strandedHumanAnswers = [];
|
|
62
|
+
const legRunOrigin = prepared.wiringManifest.leg?.runOrigin;
|
|
62
63
|
try {
|
|
63
64
|
if (prepared.abortController.signal.aborted) {
|
|
64
65
|
const e = new Error("run aborted");
|
|
@@ -224,6 +225,7 @@ export async function runLeg(input) {
|
|
|
224
225
|
...(steer.actor !== undefined ? { actor: steer.actor } : {}),
|
|
225
226
|
...(steer.actor?.issuer !== undefined ? { issuer: steer.actor.issuer } : {}),
|
|
226
227
|
...(spec.principal !== undefined ? { principal: spec.principal } : {}),
|
|
228
|
+
...(steer.runOrigin !== undefined ? { runOrigin: steer.runOrigin } : {}),
|
|
227
229
|
}),
|
|
228
230
|
...ident(),
|
|
229
231
|
});
|
|
@@ -244,7 +246,7 @@ export async function runLeg(input) {
|
|
|
244
246
|
if (steer.trusted)
|
|
245
247
|
engineSegments.push({ start, end: continuation.length });
|
|
246
248
|
appliedEvents.push(() => ({
|
|
247
|
-
...buildAppliedHumanInputEvent({ carrier: source, source, sessionSeq: nextHumanInputSeq(prepared.harness), inputId: steer.inputId, actor: steer.actor, principal: spec.principal }),
|
|
249
|
+
...buildAppliedHumanInputEvent({ carrier: source, source, sessionSeq: nextHumanInputSeq(prepared.harness), inputId: steer.inputId, actor: steer.actor, principal: spec.principal, runOrigin: steer.runOrigin }),
|
|
248
250
|
...ident(),
|
|
249
251
|
}));
|
|
250
252
|
}
|
|
@@ -493,6 +495,7 @@ export async function runLeg(input) {
|
|
|
493
495
|
...(objectiveActor?.issuer !== undefined ? { issuer: objectiveActor.issuer } : {}),
|
|
494
496
|
...(spec.principal !== undefined ? { principal: spec.principal } : {}),
|
|
495
497
|
...(attachmentFrames.length > 0 ? { attachments: humanInputAttachmentsOf(attachmentFrames) } : {}),
|
|
498
|
+
...(legRunOrigin !== undefined ? { runOrigin: legRunOrigin } : {}),
|
|
496
499
|
}),
|
|
497
500
|
...ident(),
|
|
498
501
|
});
|
|
@@ -501,6 +504,7 @@ export async function runLeg(input) {
|
|
|
501
504
|
...(enginePrefixChars > 0 ? { enginePrefixChars } : {}),
|
|
502
505
|
...(attachmentFrames.length > 0 ? { trailing: attachmentFrames.map((f) => f.seed) } : {}),
|
|
503
506
|
...(objectiveActor !== undefined ? { actor: objectiveActor } : {}),
|
|
507
|
+
...(legRunOrigin !== undefined ? { runOrigin: legRunOrigin } : {}),
|
|
504
508
|
}));
|
|
505
509
|
await flushGitMirror();
|
|
506
510
|
if (prepared.gitStatusRef.announced?.pending === true)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createPeerInboundChainRef, createPeerSelfRef } from "../../agents/peer-admission.js";
|
|
2
2
|
import { boundInputHashOf } from "../canonical-json.js";
|
|
3
|
+
import { readPendingSteerQueue } from "../checkpoint-store.js";
|
|
4
|
+
import { wakeOpening } from "../run-origin.js";
|
|
3
5
|
import { createLiveNotificationLane, DurableAppendObligations, injectionLaneOf, isDelegatedAgentTerminal, isTerminalTaskNotification, renderTaskNotificationXml, routeOrParkNotification, SystemInjectionQueue, taskNotificationDedupKey } from "../task-notification.js";
|
|
4
6
|
import { ToolDetachHub } from "../tool-detach.js";
|
|
5
7
|
import { pendingContentAskCallId } from "./decide-continuation.js";
|
|
@@ -15,6 +17,7 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
15
17
|
suspendedBatch: new Set(resume.cp.pendingAction.kind === "tool_approval" ? resume.cp.pendingAction.batchToolCallIds : []),
|
|
16
18
|
seed: resume.cp.state,
|
|
17
19
|
outcome: resume.outcome,
|
|
20
|
+
...((opening) => (opening !== undefined ? { opening } : {}))(resume.outcome.gate === "wake" ? wakeOpening(readPendingSteerQueue(resume.cp.state), resume.wakeMessage) : undefined),
|
|
18
21
|
...(resume.legMods !== undefined ? { legMods: resume.legMods } : {}),
|
|
19
22
|
priorSuspendCount: resume.cp.suspendCount,
|
|
20
23
|
priorLedger: resume.cp.resourceLedger,
|
|
@@ -4,6 +4,7 @@ import { isProviderCondition, isProviderConditionSource } from "../../brain/prov
|
|
|
4
4
|
import { admittedRequestRoute } from "../../brain/request-route.js";
|
|
5
5
|
import { readMember } from "../thrown-value.js";
|
|
6
6
|
import { egressText } from "../untrusted-egress.js";
|
|
7
|
+
import { REDACTION_MARK } from "../redaction-marks.js";
|
|
7
8
|
import { isSensitiveName, looksLikeCredentialValue } from "../secret-env.js";
|
|
8
9
|
import { isSensitiveRecordKey } from "../credential-vocabulary.js";
|
|
9
10
|
export function providerVerdictOf(final) {
|
|
@@ -38,7 +39,6 @@ const CODED_DETAIL_ENTRIES = 64;
|
|
|
38
39
|
const CODED_DETAIL_STRING = 4_096;
|
|
39
40
|
const CODED_DETAIL_VALUES = 256;
|
|
40
41
|
const CODED_DETAIL_CHARS = 16_384;
|
|
41
|
-
const REDACTED = "[redacted]";
|
|
42
42
|
const INDEX_KEY_RE = /^(?:0|[1-9][0-9]*)$/;
|
|
43
43
|
function carriesCredential(text) {
|
|
44
44
|
return looksLikeCredentialValue(text) || egressText("same-principal", text) !== text;
|
|
@@ -58,14 +58,14 @@ function charge(budget, chars) {
|
|
|
58
58
|
}
|
|
59
59
|
function leafOf(keyContext, read, depth, budget) {
|
|
60
60
|
if (keyContext !== undefined && namesCredential(keyContext))
|
|
61
|
-
return charge(budget,
|
|
61
|
+
return charge(budget, REDACTION_MARK.length) ? REDACTION_MARK : undefined;
|
|
62
62
|
const value = read();
|
|
63
63
|
if (value === null || typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value)))
|
|
64
64
|
return charge(budget, 0) ? value : undefined;
|
|
65
65
|
if (typeof value === "string") {
|
|
66
66
|
if (value.length > CODED_DETAIL_STRING)
|
|
67
67
|
return undefined;
|
|
68
|
-
const shown = carriesCredential(value) ?
|
|
68
|
+
const shown = carriesCredential(value) ? REDACTION_MARK : value;
|
|
69
69
|
return charge(budget, shown.length) ? shown : undefined;
|
|
70
70
|
}
|
|
71
71
|
if (typeof value !== "object" || depth >= CODED_DETAIL_DEPTH)
|
|
@@ -77,6 +77,7 @@ export function emitSettled(table, start, end, frames) {
|
|
|
77
77
|
...toolEndBodyFrom(end.result, isError, frames, gate, end.gatedCallIdOfRun),
|
|
78
78
|
...(gate?.disposition.kind === "denied" && occ.wireName !== undefined ? { wireName: occ.wireName } : {}),
|
|
79
79
|
...(notExecuted ? { notExecuted: true } : {}), ...(occ.answeredInPlaceBy !== undefined ? { answeredBy: occ.answeredInPlaceBy } : {}), ...(occ.requestedBy !== undefined ? { requestedBy: occ.requestedBy } : {}),
|
|
80
|
+
...(occ.rewrite !== undefined && !notExecuted ? { rewrite: occ.rewrite } : {}),
|
|
80
81
|
});
|
|
81
82
|
return { ...(gate !== undefined ? { gate } : {}), isError, ...(notExecuted ? { notExecuted: true } : {}) };
|
|
82
83
|
}
|
|
@@ -68,6 +68,9 @@ export interface ToolOccurrence extends OccurrenceStart {
|
|
|
68
68
|
/** An extension at `tool.call` answered for the call in place of its body — its result, or its refusal — and named here:
|
|
69
69
|
* the body was never called (positive evidence the call did not run). Absent: no station answered in its place. */
|
|
70
70
|
readonly answeredInPlaceBy?: string;
|
|
71
|
+
/** The latest gate exit's record of a rewrite (`tool_end.rewrite`): the args it let the call go with and who replaced them,
|
|
72
|
+
* when they are not the ones it took. Each gate round writes it (a round without one clears it). */
|
|
73
|
+
readonly rewrite?: import("../task-event.js").ToolInputRewrite;
|
|
71
74
|
}
|
|
72
75
|
/** The table of one leg's occurrences — the record's only writer. */
|
|
73
76
|
export interface ToolOccurrenceTable {
|
|
@@ -87,7 +90,7 @@ export interface ToolOccurrenceTable {
|
|
|
87
90
|
/** The engine lets the call go to its executor — the one transition into `released`, whichever leg makes it. */
|
|
88
91
|
release(toolCallId: string): void;
|
|
89
92
|
/** A gate exit for this call: its record and the input it decided on (frozen by the gate's exit). */
|
|
90
|
-
gateRound(toolCallId: string, outcome: GateOutcome, finalInput?: unknown): void;
|
|
93
|
+
gateRound(toolCallId: string, outcome: GateOutcome, finalInput?: unknown, rewrite?: import("../task-event.js").ToolInputRewrite): void;
|
|
91
94
|
/** A station after the gate refused the call: one more gate record, minted as a veto of whatever the latest one
|
|
92
95
|
* settled (a person's yes stays on the settlement; the refusing layer is the disposition). Returns the record. */
|
|
93
96
|
refuse(toolCallId: string, layer: DeniedBy): GateOutcome;
|
|
@@ -84,11 +84,12 @@ export function createToolOccurrenceTable() {
|
|
|
84
84
|
throw new Error(`tool occurrence: call "${toolCallId}" (attempt ${occ.attempt}) cannot be released from "${occ.life}"`);
|
|
85
85
|
occ.life = "released";
|
|
86
86
|
},
|
|
87
|
-
gateRound(toolCallId, outcome, finalInput) {
|
|
87
|
+
gateRound(toolCallId, outcome, finalInput, rewrite) {
|
|
88
88
|
const occ = held(toolCallId, "a gate round");
|
|
89
89
|
occ.gateRounds.push(outcome);
|
|
90
90
|
if (finalInput !== undefined)
|
|
91
91
|
occ.finalInput = finalInput;
|
|
92
|
+
occ.rewrite = rewrite;
|
|
92
93
|
},
|
|
93
94
|
refuse(toolCallId, layer) {
|
|
94
95
|
const occ = held(toolCallId, "a refusal");
|
|
@@ -25,7 +25,7 @@ import type { RunnerDeps } from "../runner-deps.js";
|
|
|
25
25
|
import type { TaskSpec } from "../task-spec.js";
|
|
26
26
|
import type { ToolRoster } from "../tool-roster.js";
|
|
27
27
|
import type { ToolPolicy } from "../tool-policy.js";
|
|
28
|
-
import { type WriteProtectionMount } from "../write-protect.js";
|
|
28
|
+
import { type ExemptFile, type ManagedCheckoutView, type WriteProtectionMount } from "../write-protect.js";
|
|
29
29
|
import type { ShellReadBoundary } from "../../tools/fs/shell-read-judge.js";
|
|
30
30
|
/** The leg's write judgment, read by its two readers: the gate's tighten over the always-on table (`mount`, absent when that
|
|
31
31
|
* table is empty) and the shell station's ONE question about each write target a command names (`judgeWriteTarget`, over
|
|
@@ -35,10 +35,16 @@ export interface LegWriteProtection {
|
|
|
35
35
|
readonly judgeWriteTarget: ShellReadBoundary["writeTargetJudge"];
|
|
36
36
|
}
|
|
37
37
|
/** The leg's write-guard seats: its one exempt root (the leg's single resolution of `RunnerDeps.memoryEngineDir`, the same
|
|
38
|
-
* list every policy adjudication of the leg is stamped with)
|
|
38
|
+
* list every policy adjudication of the leg is stamped with), the chain policies' guarded write rows, and the leg's current
|
|
39
|
+
* managed tree (`checkout`, read per judgment off the leg's one write-location reader — the write judgment's current-tree
|
|
40
|
+
* reading, `WriteProtectionCompileOptions.checkoutOf`). */
|
|
39
41
|
export interface LegWriteGuard {
|
|
40
42
|
readonly exemptRoots: readonly string[];
|
|
43
|
+
/** The engine's own files the table does not demote — the session plan file as the advertised-writable seat admitted it
|
|
44
|
+
* (absent when none was declared). */
|
|
45
|
+
readonly exemptFiles?: readonly ExemptFile[];
|
|
41
46
|
readonly rows: ToolPolicy["writeGuardRows"];
|
|
47
|
+
readonly checkout?: () => ReadonlyArray<ManagedCheckoutView> | undefined;
|
|
42
48
|
}
|
|
43
49
|
export declare function mountWriteProtection(input: {
|
|
44
50
|
/** borrowed-readonly — the deployment seats: the table (`writeProtectedPaths`; absent ⇒ the default
|
|
@@ -7,7 +7,9 @@ export function mountWriteProtection(input) {
|
|
|
7
7
|
const announced = new Set();
|
|
8
8
|
const judgment = compileLegWriteJudgment(unionAddOnly("writeProtectedAdditions", resolveWriteProtectedTable(input.deps.writeProtectedPaths), input.spec.writeProtectedAdditions), {
|
|
9
9
|
exemptRoots: input.guard.exemptRoots,
|
|
10
|
+
...(input.guard.exemptFiles !== undefined ? { exemptFiles: input.guard.exemptFiles } : {}),
|
|
10
11
|
...(input.guard.rows !== undefined ? { guardRows: input.guard.rows } : {}),
|
|
12
|
+
...(input.guard.checkout !== undefined ? { checkoutOf: input.guard.checkout } : {}),
|
|
11
13
|
...(input.deps.agentConfigDir !== undefined ? { agentConfigDir: input.deps.agentConfigDir } : {}),
|
|
12
14
|
...(input.env !== undefined ? { env: input.env } : {}),
|
|
13
15
|
rootPath: input.rootPath,
|
|
@@ -140,10 +140,10 @@ export interface RunnerDeps {
|
|
|
140
140
|
* notice (a resume re-materializes and may announce again — the standing condition is re-news at
|
|
141
141
|
* each fresh mount, never per-call). The notice is a deployment wiring fact: `detail: { message }`
|
|
142
142
|
* only, no session attribution, `"operator"` audience by its explicit {@link NOTICE_AUDIENCE} row — a wire projector
|
|
143
|
-
* forwards it operator-tier and needs no per-session de-duplication of its own.
|
|
144
|
-
* The probe's second argument, `{ fingerprint }`, is passed exactly when the server's declaration carries one.
|
|
143
|
+
* forwards it operator-tier and needs no per-session de-duplication of its own. The probe's second argument, `{ fingerprint }`, is passed exactly when the server's declaration carries one.
|
|
145
144
|
*/
|
|
146
145
|
mcpRevocations?: import("./mcp-server-spec.js").McpRevocationLedger;
|
|
146
|
+
peerSeat?: import("./peer-seat.js").PeerSeat;
|
|
147
147
|
/**
|
|
148
148
|
* design/147 S1c (ruled 2026-07-18) — the DURABLE name→agent roster behind explicit-name
|
|
149
149
|
* addressing, a storage-tier seam like the checkpoint store: core bundles `MemoryRosterStore`
|
|
@@ -3,7 +3,7 @@ import { isAbsolute, join, resolve } from "node:path";
|
|
|
3
3
|
import { anchorSpelling, canonicalizeTarget, expandHomeTilde, isAbsoluteForFamily, isWinFormPath, pathFamilyOf, writeTargetPath } from "../tools/fs/safety.js";
|
|
4
4
|
import { spelledExemptionOf } from "./write-protect.js";
|
|
5
5
|
import { compileSegmentPattern, READ_FACE_BUILTIN_DENY_TABLE, readDenyPatternRun, segmentGuardRow } from "../tools/fs/read-deny.js";
|
|
6
|
-
import { judgePathRows } from "./path-guard-rows.js";
|
|
6
|
+
import { guardHitReachClause, guardHitVia, judgePathRows } from "./path-guard-rows.js";
|
|
7
7
|
import { agentConfigDirSegments, agentConfigDirTail, checkedAgentConfigDir } from "./agent-config-dir.js";
|
|
8
8
|
import { isProtectedWrite, protectivePathTargetOf } from "./tool-registry.js";
|
|
9
9
|
import { pathTargetBaseOf } from "./effective-path-target.js";
|
|
@@ -182,7 +182,7 @@ export function createSensitivePathPolicy(opts) {
|
|
|
182
182
|
return { kind: "clear" };
|
|
183
183
|
if (hit.unreadable !== undefined)
|
|
184
184
|
return { kind: "unresolved", cause: hit.unreadable };
|
|
185
|
-
return { kind: "hit", pattern: hit.row.name, via: hit.viewKind
|
|
185
|
+
return { kind: "hit", pattern: hit.row.name, via: guardHitVia(hit.viewKind) };
|
|
186
186
|
};
|
|
187
187
|
return {
|
|
188
188
|
...(compiled.length > 0 ? { writeGuardRows: (at) => rowsOf(at.env, at.signal) } : {}),
|
|
@@ -200,13 +200,12 @@ export function createSensitivePathPolicy(opts) {
|
|
|
200
200
|
return { action: "deny", message: `write to "${path}" is refused (target_unresolved): where it leads on disk could not be determined, so the sensitive-path list cannot tell whether it is a guarded path — ${judged.cause}`, decisionReason: "safety" };
|
|
201
201
|
}
|
|
202
202
|
if (judged.kind === "hit") {
|
|
203
|
+
const reach = guardHitReachClause(judged.via);
|
|
203
204
|
return {
|
|
204
205
|
action: "deny",
|
|
205
|
-
message:
|
|
206
|
-
? `write to "${path}" is blocked: its
|
|
207
|
-
: judged.
|
|
208
|
-
? `write to "${path}" is blocked: its symlink chain passes through the guarded sensitive path "${judged.pattern}"`
|
|
209
|
-
: `write to "${path}" is blocked: its path names the guarded sensitive path "${judged.pattern}"`,
|
|
206
|
+
message: reach === undefined
|
|
207
|
+
? `write to "${path}" is blocked: its path names the guarded sensitive path "${judged.pattern}"`
|
|
208
|
+
: `write to "${path}" is blocked: the guarded sensitive path "${judged.pattern}" — ${reach}`,
|
|
210
209
|
decisionReason: "safety",
|
|
211
210
|
};
|
|
212
211
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type SessionHead, type SessionRowExpectation, type SessionRowRead, type SessionTreeEntry } from "../internal/harness.js";
|
|
2
|
+
import type { SessionLogTransfer } from "./session.js";
|
|
3
|
+
/**
|
|
4
|
+
* What a store's {@link SessionLogTransfer} reads and writes through: the repo's one read of a row (metadata, head and log of one
|
|
5
|
+
* generation) and its conditional import (judged against the row as that read answered it, in the import's own step, answering the head
|
|
6
|
+
* it wrote), and the store's own hold of an id — the one gate its other row writers (acquire, register, release) wait on, which also drops
|
|
7
|
+
* the store's cached view of the id so the view a commit replaces is not served again. Writers the hold does not see (another instance,
|
|
8
|
+
* a write straight through the repo) are met by the import's expectation instead.
|
|
9
|
+
*/
|
|
10
|
+
export interface LogTransferSeat {
|
|
11
|
+
readRow(sessionId: string): Promise<SessionRowRead | undefined>;
|
|
12
|
+
importEntries(sessionId: string, owner: string | undefined, entries: SessionTreeEntry[], options: {
|
|
13
|
+
preserveActorAssertions?: boolean;
|
|
14
|
+
expect: SessionRowExpectation;
|
|
15
|
+
}): Promise<SessionHead>;
|
|
16
|
+
holding<T>(sessionId: string, work: () => Promise<T>): Promise<T>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The {@link SessionLogTransfer} of a store over a repo that holds each log whole: reads are the repo's row read, a staging lives in this
|
|
20
|
+
* process until its commit, and a commit is the repo's conditional import under the store's hold of the id — the import itself judging,
|
|
21
|
+
* in the step that replaces the log, the write law (`importRowCells`: an existing row must already be the committer's; a placed row is
|
|
22
|
+
* refused) and that the row is still the one the commit read (its head, log included), and answering the head it wrote.
|
|
23
|
+
*/
|
|
24
|
+
export declare function repoLogTransfer(seat: LogTransferSeat): SessionLogTransfer;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { SessionError, StreamingImportValidator, importRowCells, ownerCell, sessionLogMarkOf, uuidv7 } from "../internal/harness.js";
|
|
2
|
+
import { receiptRefusal, receiveOwnProperties } from "./own-property-receipt.js";
|
|
3
|
+
import { thrownText } from "./thrown-value.js";
|
|
4
|
+
const EXPORT_WORDS = { subject: "SessionLogExportOptions", unit: "member", moment: "at SessionLogTransfer.exportStream" };
|
|
5
|
+
const BEGIN_WORDS = { subject: "SessionLogTransfer.beginReplace options", unit: "member", moment: "at SessionLogTransfer.beginReplace" };
|
|
6
|
+
const COMMIT_WORDS = { subject: "SessionLogCommit", unit: "member", moment: "at SessionLogReplace.commit" };
|
|
7
|
+
async function logOrNull(seat, sessionId) {
|
|
8
|
+
return (await seat.readRow(sessionId))?.entries ?? null;
|
|
9
|
+
}
|
|
10
|
+
function committedHead(sessionId, answer) {
|
|
11
|
+
if (typeof answer === "object" && answer !== null) {
|
|
12
|
+
const { owner, incarnation, leafId } = answer;
|
|
13
|
+
if ((owner === null || typeof owner === "string") && (incarnation === undefined || typeof incarnation === "string") && (leafId === null || typeof leafId === "string"))
|
|
14
|
+
return { owner, incarnation, leafId };
|
|
15
|
+
}
|
|
16
|
+
throw new SessionError("storage", `the repo's importEntries wrote session ${sessionId}'s log but answered no head (got ${answer === null ? "null" : typeof answer}) — a repo behind SessionStore.logTransfer answers the head its write committed; read the row again`);
|
|
17
|
+
}
|
|
18
|
+
function readRecord(raw, words, names) {
|
|
19
|
+
if (typeof raw !== "object" || raw === null)
|
|
20
|
+
throw receiptRefusal(`${words.subject} must be an object, got ${raw === null ? "null" : typeof raw}`);
|
|
21
|
+
const got = receiveOwnProperties(raw, words);
|
|
22
|
+
for (const name of Object.keys(got))
|
|
23
|
+
if (!names.includes(name))
|
|
24
|
+
throw receiptRefusal(`${words.subject} carries "${name}" — not a member this face reads`);
|
|
25
|
+
return got;
|
|
26
|
+
}
|
|
27
|
+
function isIntegerFrom(value, floor) {
|
|
28
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= floor;
|
|
29
|
+
}
|
|
30
|
+
function readExportOptions(raw) {
|
|
31
|
+
if (raw === undefined)
|
|
32
|
+
return { afterSeq: -1 };
|
|
33
|
+
const got = readRecord(raw, EXPORT_WORDS, ["afterSeq", "batchSize"]);
|
|
34
|
+
const afterSeq = got["afterSeq"];
|
|
35
|
+
if (afterSeq !== undefined && !isIntegerFrom(afterSeq, -1))
|
|
36
|
+
throw receiptRefusal("SessionLogExportOptions.afterSeq must be an integer ≥ -1 when present");
|
|
37
|
+
if (got["batchSize"] !== undefined && !isIntegerFrom(got["batchSize"], 1))
|
|
38
|
+
throw receiptRefusal("SessionLogExportOptions.batchSize must be an integer ≥ 1 when present");
|
|
39
|
+
return { afterSeq: isIntegerFrom(afterSeq, -1) ? afterSeq : -1 };
|
|
40
|
+
}
|
|
41
|
+
function readBeginOptions(raw) {
|
|
42
|
+
if (raw === undefined)
|
|
43
|
+
return {};
|
|
44
|
+
const preserveActorAssertions = readRecord(raw, BEGIN_WORDS, ["preserveActorAssertions"])["preserveActorAssertions"];
|
|
45
|
+
if (preserveActorAssertions === undefined)
|
|
46
|
+
return {};
|
|
47
|
+
if (typeof preserveActorAssertions !== "boolean")
|
|
48
|
+
throw receiptRefusal("beginReplace options.preserveActorAssertions must be a boolean when present");
|
|
49
|
+
return { preserveActorAssertions };
|
|
50
|
+
}
|
|
51
|
+
function readCommit(raw) {
|
|
52
|
+
const { owner, decide } = readRecord(raw, COMMIT_WORDS, ["owner", "decide"]);
|
|
53
|
+
if (owner === undefined)
|
|
54
|
+
throw receiptRefusal("SessionLogCommit.owner must be a principal name or null (anonymous), got undefined");
|
|
55
|
+
try {
|
|
56
|
+
ownerCell(owner);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
throw receiptRefusal(`SessionLogCommit.owner: ${thrownText(err)}`);
|
|
60
|
+
}
|
|
61
|
+
if (typeof decide !== "function")
|
|
62
|
+
throw receiptRefusal(`SessionLogCommit.decide must be a function, got ${typeof decide}`);
|
|
63
|
+
return { owner: owner, decide: decide };
|
|
64
|
+
}
|
|
65
|
+
function detachedCopy(entry) {
|
|
66
|
+
try {
|
|
67
|
+
return structuredClone(entry);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
throw new SessionError("invalid_session", `a staged entry is not plain data: ${thrownText(err)}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function pick(log, ids, side) {
|
|
74
|
+
const byId = new Map(log.map((e) => [e.id, e]));
|
|
75
|
+
return ids.map((id) => {
|
|
76
|
+
const entry = byId.get(id);
|
|
77
|
+
if (entry === undefined)
|
|
78
|
+
throw new SessionError("not_found", `the ${side} log holds no entry ${id}`);
|
|
79
|
+
return entry;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export function repoLogTransfer(seat) {
|
|
83
|
+
return {
|
|
84
|
+
async listEntryIds(sessionId) {
|
|
85
|
+
const log = await logOrNull(seat, sessionId);
|
|
86
|
+
return log === null ? null : log.map((e) => e.id);
|
|
87
|
+
},
|
|
88
|
+
async exportStream(sessionId, opts) {
|
|
89
|
+
const { afterSeq } = readExportOptions(opts);
|
|
90
|
+
const log = await logOrNull(seat, sessionId);
|
|
91
|
+
if (log === null)
|
|
92
|
+
return null;
|
|
93
|
+
const tail = log.slice(afterSeq + 1);
|
|
94
|
+
return (async function* () {
|
|
95
|
+
yield* tail;
|
|
96
|
+
})();
|
|
97
|
+
},
|
|
98
|
+
beginReplace(sessionId, opts) {
|
|
99
|
+
return stagedReplace(seat, sessionId, readBeginOptions(opts));
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function stagedReplace(seat, sessionId, gate) {
|
|
104
|
+
const validator = new StreamingImportValidator(gate);
|
|
105
|
+
let staged = [];
|
|
106
|
+
let ended;
|
|
107
|
+
const refuseEnded = () => {
|
|
108
|
+
if (ended !== undefined)
|
|
109
|
+
throw new SessionError("invalid_session", `the staging of session ${sessionId} has ended (${ended}) — it takes nothing more`);
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
stagingId: `${sessionId}#stg-${uuidv7()}`,
|
|
113
|
+
async append(entries) {
|
|
114
|
+
refuseEnded();
|
|
115
|
+
try {
|
|
116
|
+
if (!Array.isArray(entries))
|
|
117
|
+
throw receiptRefusal(`SessionLogReplace.append takes an array of entries, got ${entries === null ? "null" : typeof entries}`);
|
|
118
|
+
for (const entry of entries) {
|
|
119
|
+
const copy = detachedCopy(entry);
|
|
120
|
+
validator.step(copy);
|
|
121
|
+
staged.push(copy);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
ended = "a batch was refused";
|
|
126
|
+
staged = [];
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
async commit(input) {
|
|
131
|
+
refuseEnded();
|
|
132
|
+
ended = "committed";
|
|
133
|
+
const entries = staged;
|
|
134
|
+
staged = [];
|
|
135
|
+
const { owner, decide } = readCommit(input);
|
|
136
|
+
validator.finish();
|
|
137
|
+
const stagedIds = entries.map((e) => e.id);
|
|
138
|
+
return seat.holding(sessionId, async () => {
|
|
139
|
+
const row = await seat.readRow(sessionId);
|
|
140
|
+
if (row !== undefined)
|
|
141
|
+
importRowCells(sessionId, owner, row.metadata, row.metadata.createdAt);
|
|
142
|
+
const current = row === undefined ? null : row.entries;
|
|
143
|
+
const view = {
|
|
144
|
+
current: current === null ? null : current.map((e) => e.id),
|
|
145
|
+
staged: stagedIds,
|
|
146
|
+
read: async (side, ids) => structuredClone(side === "current" ? pick(current ?? [], ids, "current") : pick(entries, ids, "staged")),
|
|
147
|
+
};
|
|
148
|
+
const verdict = await decide(view);
|
|
149
|
+
if (verdict !== "replace" && verdict !== "keep")
|
|
150
|
+
throw receiptRefusal(`SessionLogCommit.decide must answer "replace" or "keep", got ${typeof verdict === "string" ? `"${verdict}"` : typeof verdict}`);
|
|
151
|
+
if (verdict === "keep") {
|
|
152
|
+
if (row === undefined)
|
|
153
|
+
throw new SessionError("invalid_session", `decide answered "keep" for session ${sessionId}, which has no row — there is no log to keep`);
|
|
154
|
+
return { outcome: "kept", head: row.head };
|
|
155
|
+
}
|
|
156
|
+
const expect = row === undefined ? { row: null } : { row: row.head, log: sessionLogMarkOf(row.entries) };
|
|
157
|
+
const answer = await seat.importEntries(sessionId, owner ?? undefined, entries, { ...gate, expect });
|
|
158
|
+
return { outcome: "replaced", head: committedHead(sessionId, answer) };
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
async abort() {
|
|
162
|
+
ended ??= "aborted";
|
|
163
|
+
staged = [];
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Session, type SessionHead, type SessionPlacementRecord, type SessionRepo } from "../internal/harness.js";
|
|
2
|
-
import { type AcquiredSession, type PlacedSessionRow, type SessionListQuery, type SessionPlacement, type SessionStore, type SessionStoreSummary } from "./session.js";
|
|
2
|
+
import { type AcquiredSession, type PlacedSessionRow, type SessionListQuery, type SessionLogTransfer, type SessionPlacement, type SessionStore, type SessionStoreHooks, type SessionStoreSummary } from "./session.js";
|
|
3
3
|
import type { StoreDurability } from "./checkpoint-store.js";
|
|
4
|
+
import { type RetentionDeclaration } from "./retention.js";
|
|
4
5
|
import { SESSION_DEFAULT_TTL_DAYS } from "../config/defaults.js";
|
|
5
6
|
export { SESSION_DEFAULT_TTL_DAYS };
|
|
6
7
|
/** What idle-eviction and `release` do to the underlying repo. */
|
|
@@ -51,6 +52,17 @@ export interface TtlSessionStoreOptions {
|
|
|
51
52
|
durability: StoreDurability;
|
|
52
53
|
};
|
|
53
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* The store's managed-retention declaration ({@link RetentionDeclaration}): `"managed"` says this store's rows are deleted
|
|
57
|
+
* on schedule by the deployment. Same declaration rule as {@link durability}: this cache layer runs no sweep and cannot see
|
|
58
|
+
* one, so the party that runs the sweep over the repo's rows states it. Default `"none"`. A word other than the two is refused
|
|
59
|
+
* at construction (`config.retention_capability`).
|
|
60
|
+
*/
|
|
61
|
+
retention?: RetentionDeclaration;
|
|
62
|
+
/** The deployment's hooks on this store's row deletions ({@link SessionStoreHooks}): `beforeSessionDelete` runs, awaited, before
|
|
63
|
+
* every row this store deletes — an owner's `delete`, a placed `release`, an `evict: "delete"` release or idle sweep. A hook that is
|
|
64
|
+
* not a function, or a member this store does not run, is refused at construction. */
|
|
65
|
+
hooks?: SessionStoreHooks;
|
|
54
66
|
}
|
|
55
67
|
/**
|
|
56
68
|
* The one placement admission of a session store's `acquire` — every backend that declares the placement partition
|
|
@@ -97,12 +109,12 @@ export declare function admitSessionPlacement(sessionId: string, persisted: Sess
|
|
|
97
109
|
* See `design/10-会话持久化与会话中心.md` for the durable-backend (TiDB) contract.
|
|
98
110
|
*/
|
|
99
111
|
export declare class TtlSessionStore implements SessionStore {
|
|
100
|
-
/** Managed-retention declaration (
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* is declaration-agnostic; the retention face is the structural `RetentionDeclaring` shape.) */
|
|
105
|
-
readonly retention:
|
|
112
|
+
/** Managed-retention declaration (retention.ts): whether this store's rows are deleted on schedule by the deployment — given
|
|
113
|
+
* by the party that runs the sweep ({@link TtlSessionStoreOptions.retention}), `"none"` when none is given. This layer deletes
|
|
114
|
+
* nothing on schedule itself: with a custom repo the default evict policy is `forget` (cache eviction only, the durable rows
|
|
115
|
+
* live on), so a locked retention policy refuses this store at the default. (The `SessionStore` interface
|
|
116
|
+
* itself is declaration-agnostic; the retention face is the structural `RetentionDeclaring` shape.) */
|
|
117
|
+
readonly retention: RetentionDeclaration;
|
|
106
118
|
/** design/173 §2.3 — see {@link TtlSessionStoreOptions.durability} for the declaration rules. */
|
|
107
119
|
readonly durability?: StoreDurability;
|
|
108
120
|
/** Subagent transcript persistence — see {@link TtlSessionStoreOptions.placements}. */
|
|
@@ -124,6 +136,20 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
124
136
|
/** The repo's head read as this store's own decisions read the row through it (the cache check, the existence check), held
|
|
125
137
|
* privately so the store's reading of its rows is the repo's whatever a host does with the face. */
|
|
126
138
|
private readonly repoHead?;
|
|
139
|
+
/** The storage half of a cross-backend move ({@link SessionStore.logTransfer}), over the repo's row read and its conditional import:
|
|
140
|
+
* present only when the repo has both and a head read. A staging lives in this process; a commit holds the id as a release does, and
|
|
141
|
+
* the import it ends with is conditional on the row the commit read. */
|
|
142
|
+
readonly logTransfer?: SessionLogTransfer;
|
|
143
|
+
/** The owner-guarded delete ({@link SessionStore.delete}): present only when the repo has a head read (the owner it guards on) and
|
|
144
|
+
* the row read (so its removal is conditional on the row it judged). */
|
|
145
|
+
readonly delete?: (sessionId: string, guard: {
|
|
146
|
+
owner: string | null;
|
|
147
|
+
}) => Promise<boolean>;
|
|
148
|
+
/** Whether the repo judges the expectation of the writes this store hands it (`SessionRepo.delete` / `importEntries` with `expect`):
|
|
149
|
+
* a repo with a head read and the row read ({@link SessionRepo.readRow}). Over any other repo a deletion is of the id it judged. */
|
|
150
|
+
private readonly judgesRows;
|
|
151
|
+
/** {@link TtlSessionStoreOptions.hooks}' deletion hook, read once at construction. */
|
|
152
|
+
private readonly beforeRowDelete?;
|
|
127
153
|
private repo;
|
|
128
154
|
private entries;
|
|
129
155
|
/** In-flight acquisitions keyed by id, so concurrent acquire(sameId) share one session. */
|
|
@@ -138,6 +164,8 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
138
164
|
* and then lose) an authority the delete is about to close, and the caller would hold a session whose first append answers
|
|
139
165
|
* log_closed while the file still exists. The gate is per-id and bounded by the release's own settlement (both outcomes release it). */
|
|
140
166
|
private releasing;
|
|
167
|
+
/** Resolutions of an id in flight (`openOrCreate`), each marked when a hold of the id starts while it reads the row. */
|
|
168
|
+
private readonly resolutions;
|
|
141
169
|
/** Sessions pinned by a design/45 checkpoint — skipped by idle sweep until unpinned (B6/§5). */
|
|
142
170
|
private pinned;
|
|
143
171
|
private defaultTtlMs;
|
|
@@ -157,16 +185,24 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
157
185
|
* view without positive proof is dropped and the id resolved from the row; over one with no head read (it mints no occupant token)
|
|
158
186
|
* the cached view is the only evidence of the occupant, and it stands. */
|
|
159
187
|
private viewStandsFor;
|
|
160
|
-
/** Whether a cached view is still the occupant the row holds ({@link viewStandsFor}, over the row's head read in one read)
|
|
161
|
-
*
|
|
162
|
-
|
|
188
|
+
/** Whether a cached view is still the occupant the row holds ({@link viewStandsFor}, over the row's head read in one read) and still
|
|
189
|
+
* the log it holds — the row's leaf is the view's: a log replaced under the same occupant (a cross-backend move's commit, through
|
|
190
|
+
* another instance or the repo) is another log, and its view is dropped and the id resolved from the row. Answers the head that read
|
|
191
|
+
* gave when the view stands — the row a deletion through the view expects (`SessionRepo.delete`'s expectation) — and `undefined` when
|
|
192
|
+
* it does not. Over a repo with no head read there is no row to read: the judge's answer for no row there is "stands" (`null`: no head
|
|
193
|
+
* to expect), given without reading the view. */
|
|
194
|
+
private standingRow;
|
|
163
195
|
/** The placement admission ({@link admitSessionPlacement}) for this store, judged on every resolution path. The
|
|
164
196
|
* partition declaration is a getter over this store's live field, so it is read where the admission judges the
|
|
165
197
|
* mirror direction (after the request's own members, and only then) — never captured at construction. */
|
|
166
198
|
private assertPlacementAdmission;
|
|
167
199
|
/** Resume an existing session from the repo, or create it if the backend has no such id (unless
|
|
168
|
-
* `requireExisting`, in which case a genuinely-missing id fails loud instead — design/114 Phase3).
|
|
200
|
+
* `requireExisting`, in which case a genuinely-missing id fails loud instead — design/114 Phase3). A resolution that a hold of the id
|
|
201
|
+
* (a commit, a delete, a release) overtook while it read the row is withdrawn and made again after the hold: the view it read may be of
|
|
202
|
+
* a log the hold replaced, and it is never left published. */
|
|
169
203
|
private openOrCreate;
|
|
204
|
+
/** One resolution of {@link openOrCreate}: open the row, or create it on a miss. */
|
|
205
|
+
private resolveRow;
|
|
170
206
|
private createAndStore;
|
|
171
207
|
/** Refresh the idle timer for a session, and record the activity on its row through the repo ({@link SessionRepo.touch}, where the repo
|
|
172
208
|
* has it) — the time {@link list} orders by. A fault recording it rejects. */
|
|
@@ -208,17 +244,46 @@ export declare class TtlSessionStore implements SessionStore {
|
|
|
208
244
|
/** Run a release that may delete the row while it holds the id: the gate is set before the first await, after any release already in
|
|
209
245
|
* flight for the id, and `acquire` / `register` answer after it settles — no caller captures an authority the delete is about to tear
|
|
210
246
|
* down (the repo closes the shared authority before its removal can fail), or writes the row mid-decision. */
|
|
247
|
+
/** Resolves once the hold of the id in flight when the caller arrived settles (either outcome). A hold queued behind it is the next
|
|
248
|
+
* resolution's concern: `openOrCreate` resolves again after any hold that overtakes it. */
|
|
249
|
+
private settledHolds;
|
|
211
250
|
private holdingId;
|
|
212
251
|
/** The deciding half of {@link release}, under its gate. A delete goes through the cached view only while the row still stands for it
|
|
213
|
-
* (`
|
|
214
|
-
* created it again), the row decides — its placement read cold ({@link rowIsPlaced}) — and an unplaced row
|
|
215
|
-
* as it is. Placement obligation 4: a placed row's release is a REAL deletion whatever the evict policy (the
|
|
216
|
-
* agent row first and then calls this to end the transcript; a forget would strand it). A delete runs only on a
|
|
217
|
-
* — the head read with the view still standing, or the row's own placement: a read that faults deletes nothing, and
|
|
218
|
-
* rejects with it. A placed release that fails (a read or the delete) leaves the tombstone, so the retry reads the row
|
|
219
|
-
* never a retained cache entry, which could serve a closed log; an unplaced view's release under `evict: "delete"` leaves
|
|
220
|
-
* so its retry after a failed read resolves and deletes nothing.
|
|
252
|
+
* (`standingRow`); with no view, or a view of an occupant the row no longer holds (another writer deleted the row, or deleted and
|
|
253
|
+
* created it again), the row decides — its head read first, then its placement read cold ({@link rowIsPlaced}) — and an unplaced row
|
|
254
|
+
* nobody here holds is left as it is. Placement obligation 4: a placed row's release is a REAL deletion whatever the evict policy (the
|
|
255
|
+
* joint reap deletes the agent row first and then calls this to end the transcript; a forget would strand it). A delete runs only on a
|
|
256
|
+
* read that answered — the head read with the view still standing, or the row's own placement: a read that faults deletes nothing, and
|
|
257
|
+
* the release rejects with it. A placed release that fails (a read or the delete) leaves the tombstone, so the retry reads the row
|
|
258
|
+
* again — never a retained cache entry, which could serve a closed log; an unplaced view's release under `evict: "delete"` leaves
|
|
259
|
+
* nothing, so its retry after a failed read resolves and deletes nothing. What the deletion expects of the row is what was judged:
|
|
260
|
+
* a placed transcript's deletion is owed to its occupant, so it expects the occupant only; an unplaced view's eviction judged its log
|
|
261
|
+
* idle, so it expects the view's occupant and the view's log as it stands after the hook ({@link idleViewExpectation}). A cold release
|
|
262
|
+
* expects the head it read before the placement (no row read ⇒ it expects no row, and so deletes none): the deletion lands only on
|
|
263
|
+
* that generation, and a row once replaced never comes back, so the placement read after it was of that same row. */
|
|
221
264
|
private releaseRow;
|
|
265
|
+
/** What the deletion of a view judged idle (an `evict: "delete"` release or sweep) expects of the row, read after the hook: the occupant
|
|
266
|
+
* the view stood for and the view's log as it stands then — an append through the view itself while the hook ran is still the view's
|
|
267
|
+
* log; a write through anyone else is not, and the row is not deleted. Over a repo that does not judge rows, none (the id judged). */
|
|
268
|
+
private idleViewExpectation;
|
|
269
|
+
/** Every row deletion this store makes, after its caller judged the row: the deployment's {@link TtlSessionStoreOptions.hooks} deletion
|
|
270
|
+
* hook first, awaited — when it rejects the row is not deleted and the deletion rejects with it — then the repo's delete, conditional
|
|
271
|
+
* on the row the caller judged (`expect`, read after the hook and judged by the repo in the step that removes the row: the hook ran in
|
|
272
|
+
* another writer's time, which may have deleted the row, created another under the id, or written it). Answers whether it deleted: a
|
|
273
|
+
* missed expectation (`conflict`) deletes nothing and answers `false`. With no expectation (a repo that does not judge rows) the
|
|
274
|
+
* deletion is of the id judged. */
|
|
275
|
+
private deleteRow;
|
|
276
|
+
/**
|
|
277
|
+
* The owner-guarded delete ({@link SessionStore.delete}), holding the id as a release does: the row's head decides — no row, or an
|
|
278
|
+
* owner other than `guard.owner` (null-safe), deletes nothing — and a placed row is left to `release` (the joint reap). A deleted row
|
|
279
|
+
* leaves no cached view and no pin: the id answers nothing afterwards, and a later create under it is a new occupant.
|
|
280
|
+
*/
|
|
281
|
+
private deleteOwned;
|
|
282
|
+
/** The row's metadata as the repo holds it, its placement included; `undefined` = no row. A read fault rejects. */
|
|
283
|
+
private rowMetadata;
|
|
284
|
+
/** The row's placement: the repo's placement probe where it has one, else the row's own metadata; `undefined` = no row or an unplaced
|
|
285
|
+
* one. A read fault rejects. */
|
|
286
|
+
private readPlacement;
|
|
222
287
|
/** The repo's placement probe, where it has one. */
|
|
223
288
|
private placementProbe;
|
|
224
289
|
/** Whether an uncached id's row is worth reading for its placement: through the probe on a store that declares placements, and by
|