@sema-agent/core 7.63.0 → 7.64.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 +408 -0
- package/dist/agents/cc-peer-directory.js +1 -0
- package/dist/agents/cc-peer-wire.d.ts +4 -0
- package/dist/agents/cc-peer-wire.js +1 -0
- package/dist/agents/cc-uds-peer-channel.js +5 -0
- package/dist/agents/cross-session-judge.d.ts +3 -1
- package/dist/agents/cross-session-judge.js +4 -1
- package/dist/agents/peer-directory.d.ts +8 -0
- package/dist/agents/peer-directory.js +4 -0
- package/dist/agents/peer-held-queue.d.ts +9 -3
- package/dist/agents/peer-held-queue.js +12 -9
- package/dist/agents/peer-idle.d.ts +20 -1
- package/dist/agents/peer-idle.js +23 -12
- package/dist/agents/peer-notice-route.d.ts +16 -5
- package/dist/agents/peer-notice-route.js +11 -9
- package/dist/agents/peer-notices.d.ts +25 -8
- package/dist/agents/peer-notices.js +6 -1
- package/dist/agents/peer-session-drain.d.ts +32 -6
- package/dist/agents/peer-session-drain.js +100 -26
- package/dist/agents/send-message-tool.d.ts +7 -0
- package/dist/agents/send-message-tool.js +18 -6
- package/dist/agents/subagent.js +20 -3
- package/dist/core/allow-entry.d.ts +4 -0
- package/dist/core/ask-origin.d.ts +1 -1
- package/dist/core/ask-origin.js +2 -2
- package/dist/core/ask-unresolvable-notice.d.ts +13 -4
- package/dist/core/ask-unresolvable-notice.js +10 -3
- package/dist/core/auto-compaction.d.ts +7 -5
- package/dist/core/background-agent-store.d.ts +7 -0
- package/dist/core/background-agent-store.js +3 -0
- package/dist/core/checkpoint-queries.d.ts +9 -6
- package/dist/core/checkpoint-queries.js +8 -3
- package/dist/core/checkpoint-store.d.ts +5 -1
- package/dist/core/context-settings.d.ts +40 -9
- package/dist/core/context-settings.js +32 -10
- package/dist/core/engine-attestation.d.ts +26 -6
- package/dist/core/engine-attestation.js +5 -1
- package/dist/core/engine-notice.d.ts +24 -1
- package/dist/core/extension-requester.d.ts +9 -0
- package/dist/core/extension-requester.js +7 -0
- package/dist/core/file-history-store.d.ts +28 -0
- package/dist/core/file-history-store.js +48 -5
- package/dist/core/fs-write-gate-policy.js +1 -1
- package/dist/core/gate-fold.js +2 -0
- package/dist/core/gate-lanes.js +2 -0
- package/dist/core/gate-outcome.d.ts +39 -2
- package/dist/core/gate-outcome.js +20 -1
- package/dist/core/governance-codes.d.ts +3 -1
- package/dist/core/governance-codes.js +4 -0
- package/dist/core/leg-identity.d.ts +19 -1
- package/dist/core/leg-identity.js +12 -0
- package/dist/core/mailbox-store.d.ts +39 -4
- package/dist/core/mailbox-store.js +14 -2
- package/dist/core/memory-engine/consolidation.d.ts +3 -2
- package/dist/core/memory-engine/consolidation.js +16 -0
- package/dist/core/memory-engine/control-objects.d.ts +25 -0
- package/dist/core/memory-engine/control-objects.js +151 -0
- package/dist/core/memory-engine/control-plane-adoption.d.ts +48 -0
- package/dist/core/memory-engine/control-plane-adoption.js +159 -0
- package/dist/core/memory-engine/delegation-settlement.d.ts +21 -5
- package/dist/core/memory-engine/delegation-settlement.js +217 -26
- package/dist/core/memory-engine/dual-root.js +2 -2
- package/dist/core/memory-engine/engine.d.ts +38 -23
- package/dist/core/memory-engine/engine.js +14 -14
- package/dist/core/memory-engine/file-backend.d.ts +41 -65
- package/dist/core/memory-engine/file-backend.js +59 -166
- package/dist/core/memory-engine/index.d.ts +3 -2
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +6 -1
- package/dist/core/memory-engine/layout.js +12 -7
- package/dist/core/memory-engine/memory-backend-contract.d.ts +10 -3
- package/dist/core/memory-engine/memory-backend-contract.js +158 -2
- package/dist/core/memory-engine/memory-deployment.d.ts +11 -3
- package/dist/core/memory-engine/memory-deployment.js +31 -6
- package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
- package/dist/core/memory-engine/origin-clearance.js +68 -9
- package/dist/core/memory-engine/session-write-home.d.ts +34 -1
- package/dist/core/memory-engine/session-write-home.js +37 -10
- package/dist/core/memory-engine/types.d.ts +44 -7
- package/dist/core/memory-engine/types.js +2 -1
- package/dist/core/mode-policy.js +3 -3
- package/dist/core/mods/agent-stations.d.ts +18 -0
- package/dist/core/mods/agent-stations.js +8 -6
- package/dist/core/mods/extension-call.d.ts +4 -0
- package/dist/core/mods/extension-call.js +8 -0
- package/dist/core/mods/tool-call.js +3 -4
- package/dist/core/parent-spec-seat.d.ts +2 -2
- package/dist/core/peer-channel.d.ts +5 -0
- package/dist/core/permission-rule-consent.d.ts +21 -10
- package/dist/core/permission-rule-consent.js +50 -23
- package/dist/core/permission-rule-store.d.ts +41 -16
- package/dist/core/permission-rule-store.js +2 -0
- package/dist/core/refusal-echo.d.ts +20 -0
- package/dist/core/refusal-echo.js +33 -0
- package/dist/core/retention.d.ts +180 -10
- package/dist/core/retention.js +45 -0
- package/dist/core/retired-keys.d.ts +5 -0
- package/dist/core/retired-keys.js +3 -0
- package/dist/core/rule-offer-read.d.ts +0 -4
- package/dist/core/rule-offer-read.js +2 -18
- package/dist/core/runner/classifier-ladder.d.ts +7 -1
- package/dist/core/runner/classifier-ladder.js +4 -2
- package/dist/core/runner/compact-session.js +10 -7
- package/dist/core/runner/compaction-call-options.d.ts +7 -7
- package/dist/core/runner/compaction-call-options.js +3 -2
- package/dist/core/runner/contracts.d.ts +21 -2
- package/dist/core/runner/delegation-owner.d.ts +10 -3
- package/dist/core/runner/delegation-owner.js +4 -1
- package/dist/core/runner/gate-exit.d.ts +6 -0
- package/dist/core/runner/gate-exit.js +11 -2
- package/dist/core/runner/memory-consolidation-driver.d.ts +4 -2
- package/dist/core/runner/memory-consolidation-driver.js +8 -5
- package/dist/core/runner/prepare-ask-lane.js +3 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -1
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -2
- package/dist/core/runner/prepare-config-doors.js +4 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +2 -2
- package/dist/core/runner/prepare-gate-stations.d.ts +5 -0
- package/dist/core/runner/prepare-gate-stations.js +5 -5
- package/dist/core/runner/prepare-hands-readface.js +1 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +3 -1
- package/dist/core/runner/prepare-inherited-gate.js +4 -2
- package/dist/core/runner/prepare-memory.d.ts +4 -0
- package/dist/core/runner/prepare-memory.js +14 -20
- package/dist/core/runner/prepare-policy-chain.js +7 -7
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-task.js +15 -10
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +3 -2
- package/dist/core/runner/resume-admission.d.ts +2 -2
- package/dist/core/runner/resume-admission.js +2 -23
- package/dist/core/runner/role-resolution-table.d.ts +98 -0
- package/dist/core/runner/role-resolution-table.js +62 -0
- package/dist/core/runner/run-compaction-machinery.js +2 -2
- package/dist/core/runner/run-identity-wiring.js +12 -9
- package/dist/core/runner/run-leg.js +8 -4
- package/dist/core/runner/run-notification-lane.js +22 -22
- package/dist/core/runner/run-recovery-lanes.js +3 -3
- package/dist/core/runner/run-terminal-adoption.js +1 -1
- package/dist/core/runner/run-turn-boundary.js +14 -15
- package/dist/core/runner/runtask.js +1 -1
- package/dist/core/runner/tool-occurrence.d.ts +4 -2
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner-deps.d.ts +1 -1
- package/dist/core/session-checkout.d.ts +63 -3
- package/dist/core/session-checkout.js +152 -58
- package/dist/core/shell-read-silence.js +8 -0
- package/dist/core/store-contracts/peer-directory-contract.js +8 -1
- package/dist/core/task-event.d.ts +9 -5
- package/dist/core/task-notification.d.ts +110 -31
- package/dist/core/task-notification.js +180 -100
- package/dist/core/task-registry-agent.d.ts +11 -0
- package/dist/core/task-registry-agent.js +11 -3
- package/dist/core/task-registry-shared.d.ts +7 -0
- package/dist/core/task-registry.d.ts +18 -0
- package/dist/core/task-registry.js +27 -8
- package/dist/core/task-spec.d.ts +7 -2
- package/dist/core/tool-errors.d.ts +14 -6
- package/dist/core/tool-errors.js +1 -1
- package/dist/core/tool-policy.d.ts +18 -1
- package/dist/core/tool-policy.js +16 -7
- package/dist/core/tool-result-store.d.ts +20 -0
- package/dist/core/tool-spec.d.ts +4 -0
- package/dist/core/trace.d.ts +3 -2
- package/dist/core/workflow-journal-store.d.ts +11 -0
- package/dist/core/workflow-journal-store.js +7 -0
- package/dist/core/workflow-run-store.d.ts +9 -0
- package/dist/core/workflow-run-store.js +6 -0
- package/dist/engine/compaction/compaction.d.ts +2 -1
- package/dist/engine/harness/types.d.ts +1 -0
- package/dist/engine/session/session.d.ts +7 -1
- package/dist/engine/session/session.js +5 -2
- package/dist/index.d.ts +7 -5
- package/dist/index.js +7 -5
- package/dist/orchestration/run-workflow-tool.d.ts +4 -0
- package/dist/orchestration/run-workflow-tool.js +7 -0
- package/dist/orchestration/workflow-types.d.ts +2 -1
- package/dist/orchestration/workflow.d.ts +3 -0
- package/dist/orchestration/workflow.js +2 -1
- package/dist/stores/file/checkpoint-store.d.ts +6 -0
- package/dist/stores/file/checkpoint-store.js +4 -1
- package/dist/stores/file/file-history-store.d.ts +13 -0
- package/dist/stores/file/file-history-store.js +75 -13
- package/dist/stores/file/index.d.ts +11 -1
- package/dist/stores/file/index.js +7 -11
- package/dist/stores/file/permission-rule-store.d.ts +23 -0
- package/dist/stores/file/permission-rule-store.js +75 -7
- package/dist/stores/file/tool-result-store.d.ts +14 -0
- package/dist/stores/file/tool-result-store.js +39 -2
- package/dist/stores/file/workflow-journal-store.d.ts +4 -0
- package/dist/stores/file/workflow-journal-store.js +17 -0
- package/dist/stores/file/workflow-run-store.d.ts +3 -0
- package/dist/stores/file/workflow-run-store.js +15 -0
- package/dist/tools/fs/read-deny.d.ts +15 -2
- package/dist/tools/fs/read-deny.js +10 -2
- package/dist/tools/fs/shell-read-check.d.ts +8 -2
- package/dist/tools/fs/shell-read-check.js +7 -7
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +63 -1
- package/wire-changes/core-stores-sql@7.64.0.json +30 -0
- package/wire-changes/core@7.64.0.json +2653 -0
- package/wire-changes/mods-kernel@7.64.0.json +30 -0
- package/wire-changes/primitives@7.64.0.json +30 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { screenGateOutcome, SETTLEMENT_IS_REFUSAL } from "../gate-outcome.js";
|
|
1
|
+
import { DENIED_BY_MAY_ECHO, screenGateOutcome, SETTLEMENT_IS_REFUSAL } from "../gate-outcome.js";
|
|
2
2
|
import { askFaceOf, classifyAsk, headlessApprovalRemedy } from "../ask-origin.js";
|
|
3
3
|
import { wireOf } from "../tool-name-readings.js";
|
|
4
4
|
import { isProtectedWrite } from "../tool-registry.js";
|
|
5
5
|
import { attestationOf, decisionText, foldHookAsk, licenseCovers } from "../tool-policy.js";
|
|
6
|
+
import { engineSentenceOf } from "../engine-attestation.js";
|
|
6
7
|
import { pathDenialCardOf } from "../../tools/fs/safety.js";
|
|
7
8
|
import { argsAsTheToolReads } from "../effective-path-target.js";
|
|
8
9
|
import { rewriteRecordOf } from "../rewrite-rejudge.js";
|
|
@@ -24,6 +25,7 @@ export function mintGateOutcome(facts) {
|
|
|
24
25
|
deniedBy: facts.deniedBy,
|
|
25
26
|
...(facts.cause !== undefined ? { cause: facts.cause } : {}),
|
|
26
27
|
...(extension !== undefined ? { extension } : {}),
|
|
28
|
+
...(facts.echoed !== undefined ? { echoed: Object.freeze(facts.echoed.map((e) => Object.freeze({ ...e }))) } : {}),
|
|
27
29
|
...(attribution !== undefined ? { classifier: attribution } : {}),
|
|
28
30
|
...(facts.modeRefusal !== undefined ? { mode: facts.modeRefusal.mode, askClass: facts.modeRefusal.askClass, classes: Object.freeze([...facts.modeRefusal.classes]) } : {}),
|
|
29
31
|
}
|
|
@@ -277,6 +279,12 @@ function unresolvableCauseOfSettlement(gate) {
|
|
|
277
279
|
return "no_approver_wired";
|
|
278
280
|
return undefined;
|
|
279
281
|
}
|
|
282
|
+
function refusalEchoOf(pass, call) {
|
|
283
|
+
const by = pass.deniedBy;
|
|
284
|
+
if (by === undefined || !DENIED_BY_MAY_ECHO[by])
|
|
285
|
+
return undefined;
|
|
286
|
+
return by === "read_boundary" ? pass.denyEchoed : by === "ask_resolution" ? engineSentenceOf(pass.decision, call)?.echoed : undefined;
|
|
287
|
+
}
|
|
280
288
|
export async function exitGate(pass) {
|
|
281
289
|
const { input, toolName, toolCallId, ledger, notifyPermissionDenied } = pass;
|
|
282
290
|
if (pass.decision.action === "deny") {
|
|
@@ -291,7 +299,8 @@ export async function exitGate(pass) {
|
|
|
291
299
|
pass.deniedBy = "mode";
|
|
292
300
|
ledger.supersede();
|
|
293
301
|
}
|
|
294
|
-
const
|
|
302
|
+
const echoed = refusalEchoOf(pass, { toolCallId, toolName });
|
|
303
|
+
const gate = mintGateOutcome({ deniedBy: pass.deniedBy, ...(pass.deniedBy === "hook" && pass.deniedExtension !== undefined ? { extension: pass.deniedExtension } : {}), ...(echoed !== undefined ? { echoed } : {}), ...(pass.denyCause !== undefined ? { cause: pass.denyCause } : {}), ...(ledger.settled !== undefined ? { settled: ledger.settled } : {}), ...(pass.classifierRound !== undefined ? { classifier: pass.classifierRound } : {}), ...(modeRefusal !== undefined ? { modeRefusal: { mode: modeRefusal.mode, askClass: modeRefusal.askClass, classes: modeRefusal.classes } } : {}) });
|
|
295
304
|
const foldCause = attestationOf(pass.decision, { toolCallId, toolName })?.unresolvableCause;
|
|
296
305
|
const unresolvable = foldCause ?? unresolvableCauseOfSettlement(gate);
|
|
297
306
|
const tableSeat = unresolvable !== undefined ? askUnresolvableRemedySeat(unresolvable) : undefined;
|
|
@@ -40,6 +40,8 @@ export interface MemoryConsolidationDriverDeps {
|
|
|
40
40
|
/** Optional per-model auth hook (the TaskSpec-shaped seat) for the role-resolved path. */
|
|
41
41
|
getApiKeyAndHeaders?: TaskSpec["getApiKeyAndHeaders"];
|
|
42
42
|
}
|
|
43
|
+
/** What the seat's reading takes of the deployment: the model catalog, tier bindings and role map — no brain. */
|
|
44
|
+
export type ConsolidationSeatDeps = Omit<MemoryConsolidationDriverDeps, "brain">;
|
|
43
45
|
/**
|
|
44
46
|
* Resolve a deployment's driver options: `{ chat, model }` from the explicit seat or the role
|
|
45
47
|
* chain, plus the deployment knobs (contract / maxCycles / mintRepairBudget) and the protocol
|
|
@@ -56,7 +58,7 @@ export declare function resolveMemoryConsolidationDriver(deps: MemoryConsolidati
|
|
|
56
58
|
* DIFFERENT bad value, caught loudly by the driver's own screen when it runs). False ⇔ the resolve
|
|
57
59
|
* verb would throw its "no model seat" refusal. Pinned against that resolve for drift.
|
|
58
60
|
*/
|
|
59
|
-
export declare function consolidationSeatResolvable(deps:
|
|
61
|
+
export declare function consolidationSeatResolvable(deps: ConsolidationSeatDeps): boolean;
|
|
60
62
|
/**
|
|
61
63
|
* The advisory-to-execution bridge: fire ONE host consolidation run for the
|
|
62
64
|
* recommended `scope`, fire-and-forget. Called from the post-task settle tail (NOT the harvest tail)
|
|
@@ -122,6 +124,6 @@ export declare function scopeHasUnconsumedRecommendation(engine: Pick<Consolidat
|
|
|
122
124
|
* invisible-failure family) cannot ship: a deployment learns at boot, not one silently dropped
|
|
123
125
|
* recommendation later. Lives beside {@link consolidationSeatResolvable}, the one question it asks.
|
|
124
126
|
*/
|
|
125
|
-
export declare function assertAutoConsolidationWirable(deps:
|
|
127
|
+
export declare function assertAutoConsolidationWirable(deps: ConsolidationSeatDeps & {
|
|
126
128
|
autoRunOnRecommendation?: unknown;
|
|
127
129
|
}): void;
|
|
@@ -5,6 +5,10 @@ import { runMemoryConsolidationDriver } from "../memory-engine/consolidation-dri
|
|
|
5
5
|
import { recommendationUnconsumed } from "../memory-engine/consolidation.js";
|
|
6
6
|
import { deliverWriteRefusal } from "./memory-consolidation-write-judge.js";
|
|
7
7
|
import { asThrownError } from "../thrown-value.js";
|
|
8
|
+
const CONSOLIDATION_CHAIN = ["consolidate", "summarize"];
|
|
9
|
+
function consolidationRoleModel(models, roles) {
|
|
10
|
+
return roleModelIfSet(CONSOLIDATION_CHAIN[0], {}, { models, roles }) ?? roleModelIfSet(CONSOLIDATION_CHAIN[1], {}, { models, roles });
|
|
11
|
+
}
|
|
8
12
|
function seatRefusal(message) {
|
|
9
13
|
const e = new Error(message);
|
|
10
14
|
e.code = "config.memory_consolidation_driver";
|
|
@@ -27,9 +31,9 @@ export function resolveMemoryConsolidationDriver(deps) {
|
|
|
27
31
|
}
|
|
28
32
|
else {
|
|
29
33
|
const models = catalogOfDeps(deps);
|
|
30
|
-
const resolved =
|
|
34
|
+
const resolved = consolidationRoleModel(models, deps.roles);
|
|
31
35
|
if (resolved === undefined) {
|
|
32
|
-
throw unheldChainRefusal(
|
|
36
|
+
throw unheldChainRefusal(CONSOLIDATION_CHAIN, models, deps.roles) ?? seatRefusal('memory consolidation has no model seat: configure RunnerDeps.memoryConsolidationDriver.chat (an endpoint triple or a chat function), or declare roles.consolidate / roles.summarize (a tier-expanded catalog\'s "flash" binding also satisfies the summarize hop). The chain deliberately does NOT fall back to the default main model — a whole-library distillation must not silently ride the most expensive seat.');
|
|
33
37
|
}
|
|
34
38
|
if (isAliasModelId(resolved.id)) {
|
|
35
39
|
throw seatRefusal(`the resolved consolidation model id ${JSON.stringify(resolved.id)} is an alias spelling — an alias can be re-pointed upstream and would move the run with no trace in the archive; bind an explicit id.`);
|
|
@@ -65,8 +69,7 @@ export function resolveMemoryConsolidationDriver(deps) {
|
|
|
65
69
|
export function consolidationSeatResolvable(deps) {
|
|
66
70
|
if (deps.memoryConsolidationDriver?.chat !== undefined)
|
|
67
71
|
return true;
|
|
68
|
-
|
|
69
|
-
return (roleModelIfSet("consolidate", {}, { models, roles: deps.roles }) ?? roleModelIfSet("summarize", {}, { models, roles: deps.roles })) !== undefined;
|
|
72
|
+
return consolidationRoleModel(catalogOfDeps(deps), deps.roles) !== undefined;
|
|
70
73
|
}
|
|
71
74
|
export function autoRunConsolidationFromRecommendation(args) {
|
|
72
75
|
const { deps, engine, scope, sessionId, writeJudge, compliance, onNotice, onError } = args;
|
|
@@ -116,6 +119,6 @@ export function assertAutoConsolidationWirable(deps) {
|
|
|
116
119
|
throw autoRunRefusal("RunnerDeps.autoRunOnRecommendation is true but RunnerDeps.memoryConsolidation is absent — the recommendation that would trigger a run is never minted (consolidation is OFF) and the engine's verbs refuse coded, so the trigger can never fire. An armed-but-unrunnable trigger is refused, never folded to off: wire memoryConsolidation, or leave autoRunOnRecommendation unset.");
|
|
117
120
|
}
|
|
118
121
|
if (!consolidationSeatResolvable(deps)) {
|
|
119
|
-
throw unheldChainRefusal(
|
|
122
|
+
throw unheldChainRefusal(CONSOLIDATION_CHAIN, catalogOfDeps(deps), deps.roles) ?? autoRunRefusal("RunnerDeps.autoRunOnRecommendation is true but no consolidation model seat resolves — configure RunnerDeps.memoryConsolidationDriver.chat (an endpoint triple or a chat function), or declare roles.consolidate / roles.summarize. Arming auto-run with no model to run it is refused, never folded to off (a whole-library distillation must not silently ride the default main model).");
|
|
120
123
|
}
|
|
121
124
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cardDisclosureOf } from "../allow-entry.js";
|
|
2
2
|
import { primaryActivityArg } from "../arg-summary.js";
|
|
3
3
|
import { classicEventBase, observeClassic } from "../mods/stations.js";
|
|
4
|
-
import { advertisedWritableRootsSeat, exemptRootsSeat, attest, attestationOf, isLiveApproverSeat,
|
|
4
|
+
import { advertisedWritableRootsSeat, exemptRootsSeat, attest, attestationOf, isLiveApproverSeat, resolveAskFor } from "../tool-policy.js";
|
|
5
5
|
import { exactBoundInputHashOf } from "../canonical-json.js";
|
|
6
6
|
import { composeCallSignal, raceSettlementAgainstSignal } from "./abort-race.js";
|
|
7
7
|
import { failedJudgmentDeny, policyCheckAbortedDeny } from "./policy-throw.js";
|
|
@@ -95,7 +95,7 @@ export function prepareAskLane(input) {
|
|
|
95
95
|
if (grantReuse !== undefined)
|
|
96
96
|
return grantReuse;
|
|
97
97
|
const t0 = now();
|
|
98
|
-
const resolved = await
|
|
98
|
+
const resolved = await resolveAskFor({
|
|
99
99
|
toolName: req.toolName,
|
|
100
100
|
toolCallId: req.toolCallId,
|
|
101
101
|
args: req.args,
|
|
@@ -117,7 +117,7 @@ export function prepareAskLane(input) {
|
|
|
117
117
|
...(decision.action === "ask" && decision.probeCause !== undefined ? { probeCause: decision.probeCause } : {}),
|
|
118
118
|
...(decision.action === "ask" && decision.probeReadRootCandidate !== undefined ? { readRootCandidate: decision.probeReadRootCandidate } : {}),
|
|
119
119
|
...(decision.action === "ask" && decision.ruleEvidence !== undefined ? { ruleEvidence: decision.ruleEvidence } : {}),
|
|
120
|
-
}, onAsk, composedCallSignal(callSignal), lateAskSettlementObserver({ toolName: req.toolName, toolCallId: req.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError }));
|
|
120
|
+
}, onAsk, composedCallSignal(callSignal), lateAskSettlementObserver({ toolName: req.toolName, toolCallId: req.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError }), decision);
|
|
121
121
|
const waitMs = Math.max(0, now() - t0);
|
|
122
122
|
const granting = settleReadRootGrant(resolved.readRootGrant, grantReadRoot, { toolName: req.toolName, toolCallId: req.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, signal: composedCallSignal(callSignal) });
|
|
123
123
|
if (granting !== undefined)
|
|
@@ -57,7 +57,7 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
57
57
|
/** borrowed-readonly — the trusted spawn-side channel; the Workflow mount forwards `rootSessionId`, `placementRoot`,
|
|
58
58
|
* `onTaskNotification`, `workflowDepth`, the capture-floor getter reads `memoryCaptureAncestors`, and the arming reads
|
|
59
59
|
* the chain's auto-mode face (`inheritedGate.autoModeFace`). */
|
|
60
|
-
internals: Pick<RunInternals, "rootSessionId" | "placementRoot" | "onTaskNotification" | "workflowDepth" | "memoryCaptureAncestors" | "workflowParkedResume" | "holder" | "questionFaceStripped" | "inheritedGate"> | undefined;
|
|
60
|
+
internals: Pick<RunInternals, "rootSessionId" | "rootSessionIncarnation" | "placementRoot" | "onTaskNotification" | "workflowDepth" | "memoryCaptureAncestors" | "workflowParkedResume" | "holder" | "questionFaceStripped" | "inheritedGate"> | undefined;
|
|
61
61
|
/** borrowed-readonly — the tree's cross-boundary token (inherited or minted), which the Workflow mount hands to its children. */ crossBoundaryTree: import("../cross-boundary-taint.js").CrossBoundaryTreeToken;
|
|
62
62
|
/** borrowed-readonly — the tree's owner seat, which the Workflow mount hands to its children (by reference). */ delegationOwner: import("./delegation-owner.js").DelegationOwnerSeat;
|
|
63
63
|
/** borrowed-readonly — the acquired session; the classifier leg rebuilds its transcript window from `buildContext`. */
|
|
@@ -147,6 +147,8 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
147
147
|
runnerSelf: RunnerSelfSeat | undefined;
|
|
148
148
|
/** borrowed-readonly — LATE-BOUND: the memory-engine session; the Workflow mount's capture-floor getter reads it at ITS call time. */
|
|
149
149
|
memoryEngineSession: () => Prepared["memoryEngineSession"];
|
|
150
|
+
/** borrowed-readonly — LATE-BOUND: this leg's occupant (the lineage read assigns it); the Workflow mount's root-occupant seat reads it at ITS call time. */
|
|
151
|
+
sessionIncarnation: () => string | undefined;
|
|
150
152
|
/** borrowed-readonly — LATE-BOUND: the adopted center artifact; the Workflow mount's two center getters read it at THEIR call time. */
|
|
151
153
|
centerAdoption: () => {
|
|
152
154
|
artifact: PromptArtifact;
|
|
@@ -331,7 +331,7 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
331
331
|
scope: taskScope,
|
|
332
332
|
notifier: deps.workflowCompletionNotifier,
|
|
333
333
|
originatingSessionId: sessionId,
|
|
334
|
-
rootSessionId: internals?.rootSessionId ?? sessionId, ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}), crossBoundaryTree: input.crossBoundaryTree, delegationOwner: input.delegationOwner,
|
|
334
|
+
rootSessionId: internals?.rootSessionId ?? sessionId, rootSessionIncarnation: () => (internals?.rootSessionId !== undefined ? internals.rootSessionIncarnation : input.sessionIncarnation()), ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}), crossBoundaryTree: input.crossBoundaryTree, delegationOwner: input.delegationOwner,
|
|
335
335
|
taskRegistry: defaultTaskRegistry,
|
|
336
336
|
taskNotification: internals?.onTaskNotification, ...(taskArtifacts !== undefined ? { taskArtifacts } : {}),
|
|
337
337
|
taskOwner: hostTaskId,
|
|
@@ -359,7 +359,7 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
359
359
|
...(resolvedInteractionPosture !== undefined ? { parentInteractionPosture: resolvedInteractionPosture } : {}),
|
|
360
360
|
parentMemoryCaptureState: () => {
|
|
361
361
|
const memoryEngineSession = input.memoryEngineSession();
|
|
362
|
-
const ctl = memoryEngineSession?.engine.
|
|
362
|
+
const ctl = memoryEngineSession?.engine.controlPlaneRoot;
|
|
363
363
|
const co = memoryEngineSession?.captureOptOut;
|
|
364
364
|
return assembleParentCaptureState(co?.optedOut() ?? false, co?.indeterminate() ?? false, ctl, [...(internals?.memoryCaptureAncestors ?? []), { sessionId, ...(ctl !== undefined ? { controlDir: ctl } : {}) }]);
|
|
365
365
|
},
|
|
@@ -21,6 +21,7 @@ import { assertRetentionWords } from "../retention.js";
|
|
|
21
21
|
import { resolveModel, resolveTaskModel, roleModelIfSet, screenRoleMap } from "../roles.js";
|
|
22
22
|
import { resolveSkillListingBudget } from "../skill-listing-budget.js";
|
|
23
23
|
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
24
|
+
import { compactionSeatsDefect } from "../context-settings.js";
|
|
24
25
|
import { assertAdvisorModelShape } from "../advisor-verdict.js";
|
|
25
26
|
import { applyToolModelGate, assertRestoreGatedToolsValue } from "../tool-model-gate.js";
|
|
26
27
|
import { resolveUsageWindows } from "../usage-window-store.js";
|
|
@@ -286,6 +287,9 @@ export function configValueDoors(input, enter = ENTER_AS_IS) {
|
|
|
286
287
|
});
|
|
287
288
|
if (spec.classifyAllShell !== undefined && typeof spec.classifyAllShell !== "boolean")
|
|
288
289
|
enter("taskConfig", () => { throw limitConfigError("config.invalid_argument", `TaskSpec.classifyAllShell must be a boolean when present (got ${describeRejectedValue(spec.classifyAllShell)}) — true lets no shell allow entry clear a call in auto mode; omit the key for the default.`); });
|
|
290
|
+
const compactionSeats = typeof spec.compaction === "object" && spec.compaction !== null ? compactionSeatsDefect(spec.compaction, "TaskSpec.compaction") : undefined;
|
|
291
|
+
if (compactionSeats !== undefined)
|
|
292
|
+
enter("taskConfig", () => { throw limitConfigError(compactionSeats.kind === "retired" ? "config.spec_retired_key" : "config.invalid_argument", compactionSeats.sentence); });
|
|
289
293
|
if (spec.toolMaterializeStrategy === "static" && spec.deferSelfResolve === false)
|
|
290
294
|
enter("taskConfig", () => {
|
|
291
295
|
const e = new Error(`toolMaterializeStrategy "static" cannot be combined with deferSelfResolve: false — with the direct-call ` +
|
|
@@ -43,6 +43,9 @@ export interface PrepareDelegationSurfaceInput {
|
|
|
43
43
|
resume: Pick<PrepareResume, "seed"> | undefined;
|
|
44
44
|
/** borrowed-readonly — the acquired session id (the mounts' session axis). */
|
|
45
45
|
sessionId: string;
|
|
46
|
+
/** borrowed-readonly — the leg's own session address (`sessionAddressOf`: the id and the occupant its acquire read): the peer seats
|
|
47
|
+
* name it as the sender's own, so what comes back is for this occupant. */
|
|
48
|
+
sessionAddress: import("../task-notification.js").SessionAddress;
|
|
46
49
|
/** borrowed-readonly — the per-task identity (the mounts' owner axis). */
|
|
47
50
|
hostTaskId: string;
|
|
48
51
|
/** borrowed-readonly — the registry scope the mounts register in. */
|
|
@@ -13,7 +13,7 @@ import { deliverEngineNotice } from "../types.js";
|
|
|
13
13
|
import { RosterBuilder } from "../tool-roster.js";
|
|
14
14
|
import { sendMessageContinuationSeats } from "./send-message-continuation.js";
|
|
15
15
|
export function prepareDelegationSurface(input) {
|
|
16
|
-
const { spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, sessionBox, roster, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, taskArtifacts, subagentRetain, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat } = input;
|
|
16
|
+
const { spec, deps, internals, resume, sessionId, sessionAddress, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, sessionBox, roster, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, taskArtifacts, subagentRetain, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat } = input;
|
|
17
17
|
let worktreeSessionRef;
|
|
18
18
|
const delegationSurfaceActive = backgroundTaskToolsActive || workflowToolsActive;
|
|
19
19
|
const leaves = valveLeaves(spec, toolFaceSnapshot.selector);
|
|
@@ -55,7 +55,7 @@ export function prepareDelegationSurface(input) {
|
|
|
55
55
|
...(deps.backgroundAgentStore !== undefined ? { agentStore: deps.backgroundAgentStore } : {}),
|
|
56
56
|
...(deps.mailboxStore !== undefined ? { mailbox: deps.mailboxStore } : {}),
|
|
57
57
|
...(reviveSpawn !== undefined ? { reviveSpawn } : {}),
|
|
58
|
-
...(peerLaneActive ? peerLaneSendMessageSeats({ peerDirectory: deps.peerDirectory, ...(deps.peerChannel !== undefined ? { peerChannel: deps.peerChannel } : {}),
|
|
58
|
+
...(peerLaneActive ? peerLaneSendMessageSeats({ peerDirectory: deps.peerDirectory, ...(deps.peerChannel !== undefined ? { peerChannel: deps.peerChannel } : {}), address: sessionAddress, scope: taskScope, ...(internals?.explicitAgentName !== undefined ? { name: internals.explicitAgentName } : {}), refs: peerLaneRefs, listingMounted: listAgentsMountable({ leaves, specTools: spec.tools ?? [] }) }) : {}),
|
|
59
59
|
onNotifyError: (f) => emitTrace(deps.tracer, () => ({ kind: "observer.notify_failed", version: 1, taskId: hostTaskId, site: f.site, message: f.error.message, ts: Date.now() })),
|
|
60
60
|
onTranscriptIntegrityGap: (handle, scope) => deliverEngineNotice(deps.onNotice, {
|
|
61
61
|
code: "delegation.transcript_integrity",
|
|
@@ -35,6 +35,7 @@ import { type HookEnvCapabilities, type HookInvocationIdentity } from "../hooks.
|
|
|
35
35
|
import type { ToolPolicy } from "../tool-policy.js";
|
|
36
36
|
import { type GateOutcome } from "../gate-outcome.js";
|
|
37
37
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
38
|
+
import type { NoticeAddress } from "../leg-identity.js";
|
|
38
39
|
import { type WiringManifest } from "../wiring-manifest.js";
|
|
39
40
|
import type { WriteProtectionCheck } from "../write-protect.js";
|
|
40
41
|
import type { ShellReadCheck } from "../../tools/fs/shell-read-check.js";
|
|
@@ -152,6 +153,10 @@ export interface PrepareGateStationsInput {
|
|
|
152
153
|
hostTaskId: string;
|
|
153
154
|
/** borrowed-readonly — the acquired session id (the settlement defects' error tag). */
|
|
154
155
|
sessionId: string;
|
|
156
|
+
/** borrowed-readonly — where this station's user-face notices are addressed (`noticeAddressOf`, minted once per leg beside the
|
|
157
|
+
* ask source): the leg's own session on a top-level leg; the delegation tree's root, naming this leg, on a delegated one —
|
|
158
|
+
* every notice below spreads it in place of the bare session id. */
|
|
159
|
+
noticeAddress: NoticeAddress;
|
|
155
160
|
/** borrowed-readonly — the hand's live tracked cwd, or undefined; `current` is read per screening / per post seat. Not
|
|
156
161
|
* written here. */
|
|
157
162
|
handsCwdRef: CwdRef | undefined;
|
|
@@ -50,7 +50,7 @@ export function maybeHumanRejectionHalt(input) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
export function prepareGateStations(input) {
|
|
53
|
-
const { askLane, parkAsk, tools, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, readFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, permissionMode, toolMarkSources, a2aIsolatePeers, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations } = input;
|
|
53
|
+
const { askLane, parkAsk, tools, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, noticeAddress, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, readFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, permissionMode, toolMarkSources, a2aIsolatePeers, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations } = input;
|
|
54
54
|
const releasesAnnounced = new Map();
|
|
55
55
|
const onModeReleased = (info) => {
|
|
56
56
|
const table = info.readUnestablished === true ? input.readDenyInForce(info.toolCallId) : undefined;
|
|
@@ -59,7 +59,7 @@ export function prepareGateStations(input) {
|
|
|
59
59
|
deliverEngineNotice(deps.onNotice, {
|
|
60
60
|
code: "permission.read_deny_unapplied",
|
|
61
61
|
message: `the ${info.release.mode} permission mode released "${info.toolName}" although a read-deny table is in force (${named}): the read boundary could not establish what this command reads, so no row of the table was applied to it`,
|
|
62
|
-
detail: { mode: info.release.mode, toolCallId: info.toolCallId, tiers: [...table.tiers], rows: table.rows.slice(0, 8), rowCount: table.rows.length,
|
|
62
|
+
detail: { mode: info.release.mode, toolCallId: info.toolCallId, tiers: [...table.tiers], rows: table.rows.slice(0, 8), rowCount: table.rows.length, ...noticeAddress, runId },
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
const key = `${info.release.mode}\u0000${info.release.askClass}`;
|
|
@@ -70,7 +70,7 @@ export function prepareGateStations(input) {
|
|
|
70
70
|
deliverEngineNotice(deps.onNotice, {
|
|
71
71
|
code: "permission.ask_released_by_mode",
|
|
72
72
|
message: `the ${info.release.mode} permission mode released a ${info.release.askClass} ask on "${info.toolName}" without putting it to anyone (further releases of this pair in this run ride each call's tool_end.gate.disposition.released)`,
|
|
73
|
-
detail: { mode: info.release.mode, askClass: info.release.askClass, ...(info.release.origin !== undefined ? { origin: info.release.origin } : {}), ...(info.release.mandate !== undefined ? { mandate: info.release.mandate } : {}), count, firstToolCallId: info.toolCallId,
|
|
73
|
+
detail: { mode: info.release.mode, askClass: info.release.askClass, ...(info.release.origin !== undefined ? { origin: info.release.origin } : {}), ...(info.release.mandate !== undefined ? { mandate: info.release.mandate } : {}), count, firstToolCallId: info.toolCallId, ...noticeAddress, runId },
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
if (askLane !== undefined && parkAsk !== undefined) {
|
|
@@ -140,7 +140,7 @@ export function prepareGateStations(input) {
|
|
|
140
140
|
abortSignal: abortController.signal,
|
|
141
141
|
onHookError: notifyHookError,
|
|
142
142
|
shellGated: tierSeat?.shellGated(shellGatedTools, toolMarkSources) === true,
|
|
143
|
-
...(autoModeDecider.current !== undefined ? { autoMode: { decider: autoModeDecider.current, ...(autoModeDenialTracking.current !== undefined ? { denialTracking: autoModeDenialTracking.current } : {}), unavailable: classifierUnavailableSeat({ station: "leg", ...(autoModeDecider.current.timeoutMs !== undefined ? { budgetMs: autoModeDecider.current.timeoutMs } : {}), route: approvalRouteOf(askRoute), onNotice: deps.onNotice,
|
|
143
|
+
...(autoModeDecider.current !== undefined ? { autoMode: { decider: autoModeDecider.current, ...(autoModeDenialTracking.current !== undefined ? { denialTracking: autoModeDenialTracking.current } : {}), unavailable: classifierUnavailableSeat({ station: "leg", ...(autoModeDecider.current.timeoutMs !== undefined ? { budgetMs: autoModeDecider.current.timeoutMs } : {}), route: approvalRouteOf(askRoute), onNotice: deps.onNotice, ...noticeAddress, runId }) } } : {}),
|
|
144
144
|
permissionMode: () => permissionMode.current, askSeatForm: askRoute.form,
|
|
145
145
|
...(markSources.size > 0 ? { toolMarkSources: markSources } : {}),
|
|
146
146
|
...seatInputsFor(e.toolName, wireOf("gate.skillActivationSeat", call)),
|
|
@@ -149,7 +149,7 @@ export function prepareGateStations(input) {
|
|
|
149
149
|
onModeReleased,
|
|
150
150
|
ancestorArbitrationOf: (toolCallId) => ancestorArbitrations.get(toolCallId),
|
|
151
151
|
onHeadlessDenialLimit: stopForDenialLimit,
|
|
152
|
-
onAskUnresolvable: (info) => deliverEngineNotice(deps.onNotice, askUnresolvableNotice({
|
|
152
|
+
onAskUnresolvable: (info) => deliverEngineNotice(deps.onNotice, askUnresolvableNotice({ ...noticeAddress, ...info })),
|
|
153
153
|
...(permissionRuleLane
|
|
154
154
|
? {
|
|
155
155
|
persistedRules: {
|
|
@@ -331,7 +331,7 @@ export async function prepareHandsMount(input) {
|
|
|
331
331
|
seatOf: () => (handsReadOnly ? "readonly" : "full_shell"),
|
|
332
332
|
boundaryOf: (_tool, _cwd, toolCallId) => readonlyBoundary(toolCallId) ?? shellReadBoundary(toolCallId), rootsCanonical: true,
|
|
333
333
|
homeViews: tables.readDeny.homeViews,
|
|
334
|
-
onAdmissionRefused: (toolCallId) => void input.toolOccurrences.refuse(toolCallId, "read_boundary"),
|
|
334
|
+
onAdmissionRefused: (toolCallId, echoed) => void input.toolOccurrences.refuse(toolCallId, "read_boundary", echoed !== undefined ? { echoed } : undefined),
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
if (!handsReadOnly) {
|
|
@@ -80,7 +80,7 @@ export interface PrepareInheritedGateInput {
|
|
|
80
80
|
/** borrowed-readonly — the trusted spawn-side channel: `inheritedGate` (the LIVE half of the chain fold), `ownOrgAdmissionRef`
|
|
81
81
|
* (the same-session continuation's freeze), `delegationProvenance` (the F-012 stamp), and the identity / peer / notification
|
|
82
82
|
* seats the ctx enrichment forwards. Never mutated. */
|
|
83
|
-
internals: Pick<RunInternals, "inheritedGate" | "sessionModeSeats" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "insideFork" | "questionFaceStripped"> | undefined;
|
|
83
|
+
internals: Pick<RunInternals, "inheritedGate" | "sessionModeSeats" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "rootSessionIncarnation" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "insideFork" | "questionFaceStripped"> | undefined;
|
|
84
84
|
/** borrowed-readonly — the resume leg, or undefined on a fresh one: `seed.inheritedGate` is the CHECKPOINT half of the chain
|
|
85
85
|
* fold (the trust floor the live half may only tighten), `seed.readFace` the hands-less re-park's carried section. */
|
|
86
86
|
resume: Pick<PrepareResume, "seed" | "outcome"> | undefined;
|
|
@@ -212,6 +212,8 @@ export interface PrepareInheritedGateInput {
|
|
|
212
212
|
} | undefined;
|
|
213
213
|
/** borrowed-readonly — LATE-BOUND: the memory-engine session (the ctx's capture-floor getters read it at THEIR call time). */
|
|
214
214
|
memoryEngineSession: () => Prepared["memoryEngineSession"];
|
|
215
|
+
/** borrowed-readonly — LATE-BOUND: this leg's occupant (`SessionMetadata.incarnation` of the acquired session; the lineage read assigns it). */
|
|
216
|
+
sessionIncarnation: () => string | undefined;
|
|
215
217
|
}
|
|
216
218
|
export interface PrepareInheritedGateResult {
|
|
217
219
|
/** owned — the LIVE half of the inherited chain as supplied (`internals.inheritedGate`); the durable-gate notice reads it. */
|
|
@@ -190,6 +190,7 @@ export function prepareInheritedGate(input) {
|
|
|
190
190
|
const centerAdoption = input.centerAdoption();
|
|
191
191
|
const agentStations = input.agentStations();
|
|
192
192
|
const sendStation = input.sendStation();
|
|
193
|
+
const rootSessionIncarnation = internals?.rootSessionId !== undefined ? internals.rootSessionIncarnation : input.sessionIncarnation();
|
|
193
194
|
return {
|
|
194
195
|
...ctx,
|
|
195
196
|
delegationEntryCaps: delegationEntryCapsResolved,
|
|
@@ -221,10 +222,10 @@ export function prepareInheritedGate(input) {
|
|
|
221
222
|
return input.memoryEngineSession()?.captureOptOut?.indeterminate() ?? false;
|
|
222
223
|
},
|
|
223
224
|
get memoryCaptureControlDir() {
|
|
224
|
-
return input.memoryEngineSession()?.engine.
|
|
225
|
+
return input.memoryEngineSession()?.engine.controlPlaneRoot;
|
|
225
226
|
},
|
|
226
227
|
get memoryCaptureAncestors() {
|
|
227
|
-
const ctl = input.memoryEngineSession()?.engine.
|
|
228
|
+
const ctl = input.memoryEngineSession()?.engine.controlPlaneRoot;
|
|
228
229
|
return [...(internals?.memoryCaptureAncestors ?? []), { sessionId, ...(ctl !== undefined ? { controlDir: ctl } : {}) }];
|
|
229
230
|
},
|
|
230
231
|
getApiKeyAndHeaders: spec.getApiKeyAndHeaders,
|
|
@@ -253,6 +254,7 @@ export function prepareInheritedGate(input) {
|
|
|
253
254
|
...(internals?.parentTaskId !== undefined ? { parentTaskId: internals.parentTaskId } : {}),
|
|
254
255
|
...(internals?.parentSessionId !== undefined ? { parentSessionId: internals.parentSessionId } : {}),
|
|
255
256
|
...(internals?.rootSessionId !== undefined ? { rootSessionId: internals.rootSessionId } : {}), ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}),
|
|
257
|
+
...(rootSessionIncarnation !== undefined ? { rootSessionIncarnation } : {}),
|
|
256
258
|
delegationOwner: input.delegationOwner,
|
|
257
259
|
...(internals?.explicitAgentName !== undefined ? { spawnedAgentName: internals.explicitAgentName } : {}),
|
|
258
260
|
...(internals?.peerSelfRef !== undefined ? { peerSelfRef: internals.peerSelfRef } : {}),
|
|
@@ -198,6 +198,10 @@ export interface MemoryInjectionComposition {
|
|
|
198
198
|
path: string;
|
|
199
199
|
content: string;
|
|
200
200
|
}>;
|
|
201
|
+
/** #1123 — the notices this prepare drained, as whole engine reminders (the engine's `announceBlock`, then the
|
|
202
|
+
* session-scope coda in its own reminder when one is owed): an EVENT, so it never enters `memoryBlock` (the cached
|
|
203
|
+
* prefix) — the leg's first request carries it once, ahead of the user's message. Absent when nothing was drained. */
|
|
204
|
+
noticesFrame?: string;
|
|
201
205
|
}
|
|
202
206
|
export interface PrepareMemoryResult {
|
|
203
207
|
memoryEngineSession: Prepared["memoryEngineSession"];
|
|
@@ -6,6 +6,7 @@ import { derivePersonalControlDir, derivePersonalMemoryDir, directoryPinOf, memo
|
|
|
6
6
|
import { memoryProjectScopeAbsentNotice, normalizeMemorySpec } from "../memory.js";
|
|
7
7
|
import { deriveSupersededSet, fileGovernanceStore } from "../memory-engine/consolidation.js";
|
|
8
8
|
import { shadowNamesOf } from "../memory-engine/shadowing.js";
|
|
9
|
+
import { mintSystemReminder } from "../reminder-mint.js";
|
|
9
10
|
import { MEMORY_ANNOUNCEMENT_CAPTURE_OPTOUT_CODA, MEMORY_ANNOUNCEMENT_READONLY_CODA, MEMORY_CAPTURE_OPTOUT_NOTICE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, MemoryEngine, entryFileHeadCarriesOrigin, memoryCaptureOptedOutNotice, memoryCaptureOptOutUnpersistedNotice, memoryConsolidationRecommendedNotice, memoryHarvestConflictNotice, memoryHarvestQuarantinedNotice, memoryHarvestRefusedNotice, memoryHoldNotices, memoryRecallDisciplineSegment, memoryRestoreWithheldNotice, memorySessionPollutedNotice, memoryUnavailableNotice, pollutionContainmentCounts, } from "../memory-engine/engine.js";
|
|
10
11
|
import { adjudicateCaptureOptOut, captureOptOutDeniedError, captureOptOutUnpersistedError } from "./memory-capture-optout.js";
|
|
11
12
|
import { readSessionCaptureOptOut } from "../memory-engine/layout.js";
|
|
@@ -206,7 +207,7 @@ export async function prepareMemory(input) {
|
|
|
206
207
|
}
|
|
207
208
|
if (samePlane.fault)
|
|
208
209
|
anyFault = true;
|
|
209
|
-
if (ancestorDir !== undefined && ancestorDir !== eng.
|
|
210
|
+
if (ancestorDir !== undefined && ancestorDir !== eng.controlPlaneRoot) {
|
|
210
211
|
try {
|
|
211
212
|
const crossPlane = deps.memoryCaptureRecordStore !== undefined ? await deps.memoryCaptureRecordStore({ controlDir: ancestorDir }).read(ancestorId) : readSessionCaptureOptOut(ancestorDir, ancestorId);
|
|
212
213
|
if (crossPlane !== undefined) {
|
|
@@ -311,7 +312,7 @@ export async function prepareMemory(input) {
|
|
|
311
312
|
for (const [ancestorId, ancestorDir] of ancestors) {
|
|
312
313
|
const samePlane = await writeEngine.sessionCaptureOptOutOrFault(ancestorId);
|
|
313
314
|
let crossPlane;
|
|
314
|
-
if (ancestorDir !== undefined && ancestorDir !== writeEngine.
|
|
315
|
+
if (ancestorDir !== undefined && ancestorDir !== writeEngine.controlPlaneRoot) {
|
|
315
316
|
try {
|
|
316
317
|
crossPlane = deps.memoryCaptureRecordStore !== undefined ? await deps.memoryCaptureRecordStore({ controlDir: ancestorDir }).read(ancestorId) : readSessionCaptureOptOut(ancestorDir, ancestorId);
|
|
317
318
|
}
|
|
@@ -497,7 +498,7 @@ export async function prepareMemory(input) {
|
|
|
497
498
|
}
|
|
498
499
|
const foreignUnderRoot = [];
|
|
499
500
|
if (input.writeToolsMounted && writeHandle.writeScope !== null && input.advertisedWritableDirs !== undefined) {
|
|
500
|
-
const controlPlane = canonicalize(writeEngine.
|
|
501
|
+
const controlPlane = canonicalize(writeEngine.controlPlaneRoot);
|
|
501
502
|
if (isContainedIn(writableRootOf(writeHandle), controlPlane))
|
|
502
503
|
foreignUnderRoot.push(`the engine's control plane ${controlPlane}`);
|
|
503
504
|
}
|
|
@@ -697,7 +698,7 @@ export async function prepareMemory(input) {
|
|
|
697
698
|
execIsExternalContent: memorySpec.execIsExternalContent === true,
|
|
698
699
|
},
|
|
699
700
|
...(input.memoryProvenance !== "off"
|
|
700
|
-
? { settlement: { governance: writeEngine.governance, controlDir: writeEngine.
|
|
701
|
+
? { settlement: { governance: writeEngine.governance, controlDir: writeEngine.controlPlaneRoot, sessionId, provenance: "carry" } }
|
|
701
702
|
: {}),
|
|
702
703
|
...(input.memoryProvenance !== "off"
|
|
703
704
|
? {
|
|
@@ -772,36 +773,28 @@ export async function prepareMemory(input) {
|
|
|
772
773
|
let memoryBlock;
|
|
773
774
|
let seedFiles;
|
|
774
775
|
let recallDisciplineSegment;
|
|
776
|
+
let noticesFrame;
|
|
775
777
|
if (memoryEngineSession) {
|
|
776
778
|
const injection = await memoryEngineSession.inject();
|
|
777
779
|
let blockBody = injection.block;
|
|
778
780
|
if (captureOptedOut) {
|
|
779
|
-
blockBody = [MEMORY_CAPTURE_OPTOUT_NOTICE, injection.index
|
|
781
|
+
blockBody = [MEMORY_CAPTURE_OPTOUT_NOTICE, injection.index].filter((s) => Boolean(s && s.trim())).join("\n\n");
|
|
780
782
|
}
|
|
781
783
|
else if (captureIndeterminate && facts.rosterCanPersist) {
|
|
782
|
-
blockBody = [memoryUnavailableNotice({ what: "capture-record-unreadable", notesReadable: true }), injection.index
|
|
784
|
+
blockBody = [memoryUnavailableNotice({ what: "capture-record-unreadable", notesReadable: true }), injection.index].filter((s) => Boolean(s && s.trim())).join("\n\n");
|
|
783
785
|
}
|
|
784
786
|
else if (!facts.rosterCanPersist && injection.instruction === "" && injection.readOnlyNotice === undefined) {
|
|
785
787
|
blockBody = blockBody.trim() ? `${MEMORY_READONLY_NOTICE}\n\n${blockBody}` : MEMORY_READONLY_NOTICE;
|
|
786
788
|
}
|
|
787
789
|
else if (!facts.rosterCanPersist && injection.instruction !== "") {
|
|
788
|
-
blockBody = [MEMORY_READONLY_NOTICE, injection.index
|
|
790
|
+
blockBody = [MEMORY_READONLY_NOTICE, injection.index].filter((s) => Boolean(s && s.trim())).join("\n\n");
|
|
789
791
|
}
|
|
790
792
|
else if (input.memoryPersistenceDeclared === true && injection.readOnlyNotice !== undefined) {
|
|
791
|
-
blockBody = [injection.index
|
|
793
|
+
blockBody = [injection.index].filter((s) => Boolean(s && s.trim())).join("\n\n");
|
|
792
794
|
}
|
|
793
|
-
if (
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
!blockBody.trimEnd().endsWith(MEMORY_ANNOUNCEMENT_READONLY_CODA)) {
|
|
797
|
-
blockBody = `${blockBody}\n\n${MEMORY_ANNOUNCEMENT_READONLY_CODA}`;
|
|
798
|
-
}
|
|
799
|
-
if (captureOptedOut &&
|
|
800
|
-
facts.rosterCanPersist &&
|
|
801
|
-
(injection.announceBlock?.trim() ?? "") !== "" &&
|
|
802
|
-
blockBody.includes(injection.announceBlock) &&
|
|
803
|
-
!blockBody.trimEnd().endsWith(MEMORY_ANNOUNCEMENT_CAPTURE_OPTOUT_CODA)) {
|
|
804
|
-
blockBody = `${blockBody}\n\n${MEMORY_ANNOUNCEMENT_CAPTURE_OPTOUT_CODA}`;
|
|
795
|
+
if ((injection.announceBlock?.trim() ?? "") !== "") {
|
|
796
|
+
const coda = !facts.rosterCanPersist ? MEMORY_ANNOUNCEMENT_READONLY_CODA : captureOptedOut ? MEMORY_ANNOUNCEMENT_CAPTURE_OPTOUT_CODA : undefined;
|
|
797
|
+
noticesFrame = coda === undefined ? injection.announceBlock : `${injection.announceBlock}\n${mintSystemReminder(coda, input.reminderMark)}`;
|
|
805
798
|
}
|
|
806
799
|
if (blockBody.trim())
|
|
807
800
|
memoryBlock = blockBody;
|
|
@@ -822,6 +815,7 @@ export async function prepareMemory(input) {
|
|
|
822
815
|
memoryBlock,
|
|
823
816
|
...(recallDisciplineSegment !== undefined ? { recallDisciplineSegment } : {}),
|
|
824
817
|
...(seedFiles !== undefined ? { seedFiles } : {}),
|
|
818
|
+
...(noticesFrame !== undefined ? { noticesFrame } : {}),
|
|
825
819
|
};
|
|
826
820
|
};
|
|
827
821
|
if (effectiveMemoryScopes === undefined) {
|
|
@@ -10,7 +10,7 @@ import { isCoveringRuleName, ruleNameCovers } from "../namespaced-rule-name.js";
|
|
|
10
10
|
import { isIsolated } from "../remote-env.js";
|
|
11
11
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
12
12
|
import { earlierGrammarNotice } from "../session-policy-store.js";
|
|
13
|
-
import { attest, attestationOf, checkToolPolicyProjection, combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, durableParkOptInDeclared, isLiveApproverSeat, mergeAttestation, refuseOutOfContractDecision,
|
|
13
|
+
import { attest, attestationOf, checkToolPolicyProjection, combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, durableParkOptInDeclared, isLiveApproverSeat, mergeAttestation, refuseOutOfContractDecision, resolveAskFor, toolPolicyNameSets, withAttestation, wrapToolPolicy } from "../tool-policy.js";
|
|
14
14
|
import { judgeRuleToolName, mountedToolNames, nearMissSpellingOf } from "../tool-name-aliases.js";
|
|
15
15
|
import { approvalCardMemberOf } from "../tool-roster.js";
|
|
16
16
|
import { NAMESPACED_NAME_SHAPES } from "../protocol-table.js";
|
|
@@ -400,7 +400,7 @@ export async function preparePolicyChain(input) {
|
|
|
400
400
|
if (editArbitrated !== undefined && !outletReleased) {
|
|
401
401
|
return onApproval(editArbitrated.action === "allow" ? { action: "allow", updatedInput: editArgs, decisionReason: "mode" } : editArbitrated);
|
|
402
402
|
}
|
|
403
|
-
const { resolved: rr, judged: settled } = await resolveInheritedAsk(judged, (j) =>
|
|
403
|
+
const { resolved: rr, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAskFor({
|
|
404
404
|
toolName: creq.toolName,
|
|
405
405
|
toolCallId: creq.toolCallId,
|
|
406
406
|
args: editArgs,
|
|
@@ -414,7 +414,7 @@ export async function preparePolicyChain(input) {
|
|
|
414
414
|
...askMandateMember(ancestorFacts(j.ask)),
|
|
415
415
|
...inheritedAskCarry(j, isLiveApproverSeat(onAskOf), ancestorTracker),
|
|
416
416
|
ruleEvidence: inheritedAskEvidence,
|
|
417
|
-
}, onAskOf, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError })), ancestorTracker, creq, inheritedStationFacts(creq));
|
|
417
|
+
}, onAskOf, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError }), j.ask), ancestorTracker, creq, inheritedStationFacts(creq));
|
|
418
418
|
void settleReadRootGrant(rr.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice });
|
|
419
419
|
settleDenialLimitFallback({ fallback: settled.fallback, mintedHere: settled.mintedHere, tracker: ancestorTracker, resolved: rr, headless: headlessDenyAtRecheck, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
|
|
420
420
|
if (rr.action !== "allow")
|
|
@@ -456,7 +456,7 @@ export async function preparePolicyChain(input) {
|
|
|
456
456
|
if (arbitrated !== undefined)
|
|
457
457
|
return settledAs(arbitrated);
|
|
458
458
|
const askT0 = now();
|
|
459
|
-
const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) =>
|
|
459
|
+
const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAskFor({
|
|
460
460
|
toolName: creq.toolName,
|
|
461
461
|
toolCallId: creq.toolCallId,
|
|
462
462
|
args: presentedArgs,
|
|
@@ -470,7 +470,7 @@ export async function preparePolicyChain(input) {
|
|
|
470
470
|
...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
471
471
|
...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
|
|
472
472
|
ruleEvidence: inheritedAskEvidence,
|
|
473
|
-
}, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
|
|
473
|
+
}, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError }), j.ask), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
|
|
474
474
|
void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice });
|
|
475
475
|
const askWaitMs = Math.max(0, now() - askT0);
|
|
476
476
|
if (resolved.action === "deny" && resolved.approverUnavailable === true) {
|
|
@@ -539,7 +539,7 @@ export async function preparePolicyChain(input) {
|
|
|
539
539
|
return arbitrated;
|
|
540
540
|
const presentedArgs = creq.args;
|
|
541
541
|
const askT0 = now();
|
|
542
|
-
const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) =>
|
|
542
|
+
const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAskFor({
|
|
543
543
|
toolName: creq.toolName,
|
|
544
544
|
toolCallId: creq.toolCallId,
|
|
545
545
|
args: presentedArgs,
|
|
@@ -553,7 +553,7 @@ export async function preparePolicyChain(input) {
|
|
|
553
553
|
...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
554
554
|
...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
|
|
555
555
|
ruleEvidence: inheritedAskEvidence,
|
|
556
|
-
}, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
|
|
556
|
+
}, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice, onError: deps.onError }), j.ask), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
|
|
557
557
|
void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, taskId: hostTaskId, onNotice: deps.onNotice });
|
|
558
558
|
const askWaitMs = Math.max(0, now() - askT0);
|
|
559
559
|
if (resolved.action === "deny" && resolved.approverUnavailable === true) {
|
|
@@ -28,7 +28,7 @@ export async function preparePromptInputs(input) {
|
|
|
28
28
|
goalEnabled: internals?.goalMode === true,
|
|
29
29
|
awarenessEnabled: thinking !== undefined && ULTRA_REASONING_TIERS.has(thinking),
|
|
30
30
|
worktreeIsolated: internals?.isolation === "worktree" && ownedEnv !== undefined,
|
|
31
|
-
withinTaskCompactionEnabled: compactionEnabled(spec.compaction
|
|
31
|
+
withinTaskCompactionEnabled: compactionEnabled("autoCompact", spec.compaction, input.contextOverlay) && (spec.compaction?.withinTask ?? true),
|
|
32
32
|
isSubagent: delegation.isNonForkChild,
|
|
33
33
|
};
|
|
34
34
|
const sugar = requestBodySugar({ spec, resolvedRole, ...(input.taskRole !== undefined ? { taskRole: input.taskRole } : {}), ...(internals !== undefined ? { internals } : {}) });
|