@sema-agent/core 7.15.0 → 7.17.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 +202 -0
- package/dist/agents/builtin-agents.d.ts +3 -3
- package/dist/agents/cross-session-envelope.d.ts +0 -1
- package/dist/agents/cross-session-envelope.js +0 -1
- package/dist/agents/peer-notices.d.ts +0 -9
- package/dist/agents/peer-notices.js +0 -63
- package/dist/agents/subagent.js +7 -15
- package/dist/brain/request-params.d.ts +2 -2
- package/dist/config/defaults.d.ts +0 -7
- package/dist/config/defaults.js +0 -2
- package/dist/core/artifact-host.d.ts +218 -0
- package/dist/core/artifact-host.js +92 -0
- package/dist/core/ask-origin.d.ts +29 -3
- package/dist/core/ask-origin.js +17 -9
- package/dist/core/ask-question.d.ts +25 -0
- package/dist/core/ask-question.js +4 -0
- package/dist/core/ask-unresolvable-notice.d.ts +30 -21
- package/dist/core/ask-unresolvable-notice.js +16 -8
- package/dist/core/auto-compaction.d.ts +10 -10
- package/dist/core/auto-mode-arming.d.ts +2 -2
- package/dist/core/background-agent-store.d.ts +5 -5
- package/dist/core/background-shell.d.ts +1 -1
- package/dist/core/checkpoint-execution-record.d.ts +0 -3
- package/dist/core/checkpoint-execution-record.js +0 -4
- package/dist/core/checkpoint-store.d.ts +71 -99
- package/dist/core/checkpoint-store.js +9 -16
- package/dist/core/context-edit.d.ts +36 -104
- package/dist/core/context-edit.js +37 -60
- package/dist/core/effective-path-target.d.ts +68 -8
- package/dist/core/effective-path-target.js +42 -30
- package/dist/core/engine-notice.d.ts +46 -32
- package/dist/core/env-budget.d.ts +31 -0
- package/dist/core/env-budget.js +39 -0
- package/dist/core/exec-output-tail.d.ts +5 -5
- package/dist/core/file-history-store.js +3 -6
- package/dist/core/fs-write-gate-policy.d.ts +1 -1
- package/dist/core/fs-write-gate-policy.js +3 -3
- package/dist/core/gate-lanes.js +9 -15
- package/dist/core/governance-codes.d.ts +1 -1
- package/dist/core/governance-codes.js +4 -0
- package/dist/core/hands-band.d.ts +1 -1
- package/dist/core/hooks.d.ts +18 -17
- package/dist/core/lsp-session.d.ts +1 -1
- package/dist/core/lsp.d.ts +1 -1
- package/dist/core/lsp.js +5 -4
- package/dist/core/mcp.d.ts +5 -5
- package/dist/core/mcp.js +4 -48
- package/dist/core/memory-engine/delegation-settlement.d.ts +37 -12
- package/dist/core/memory-engine/delegation-settlement.js +128 -39
- package/dist/core/memory-engine/engine.d.ts +9 -8
- package/dist/core/memory-engine/engine.js +115 -120
- package/dist/core/memory-engine/file-backend.d.ts +17 -5
- package/dist/core/memory-engine/file-backend.js +78 -34
- package/dist/core/memory-engine/index.d.ts +2 -2
- package/dist/core/memory-engine/index.js +2 -2
- package/dist/core/memory-engine/layout.d.ts +152 -54
- package/dist/core/memory-engine/layout.js +441 -104
- package/dist/core/memory-engine/types.d.ts +8 -3
- package/dist/core/memory-engine/types.js +5 -0
- package/dist/core/memory-recall.d.ts +0 -8
- package/dist/core/memory.d.ts +1 -1
- package/dist/core/oracle-isolation.js +2 -2
- package/dist/core/parent-spec-seat.d.ts +66 -0
- package/dist/core/parent-spec-seat.js +47 -0
- package/dist/core/permission-rule-model.d.ts +11 -6
- package/dist/core/permission-rule-model.js +53 -37
- package/dist/core/permission-rules.js +8 -3
- package/dist/core/protocol-naming.d.ts +2 -2
- package/dist/core/remote-env.d.ts +1 -1
- package/dist/core/retired-keys.d.ts +19 -0
- package/dist/core/retired-keys.js +15 -0
- package/dist/core/runner/abort-race.d.ts +3 -3
- package/dist/core/runner/active-skill-scope.d.ts +2 -2
- package/dist/core/runner/active-skill-scope.js +3 -3
- package/dist/core/runner/assemble-result.d.ts +42 -40
- package/dist/core/runner/assemble-result.js +5 -4
- package/dist/core/runner/checkpoint-scope.d.ts +4 -4
- package/dist/core/runner/clock-and-limits.d.ts +3 -3
- package/dist/core/runner/compaction-call-options.d.ts +35 -99
- package/dist/core/runner/compaction-knobs.d.ts +4 -4
- package/dist/core/runner/compaction-seams.d.ts +5 -5
- package/dist/core/runner/contracts.d.ts +232 -233
- package/dist/core/runner/decide-continuation.d.ts +6 -6
- package/dist/core/runner/denial-limit-arms.d.ts +8 -8
- package/dist/core/runner/derived-route-fallback.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +6 -6
- package/dist/core/runner/gate-exit.js +15 -1
- package/dist/core/runner/git-status-frame.d.ts +7 -7
- package/dist/core/runner/halt-attribution.d.ts +35 -0
- package/dist/core/runner/halt-attribution.js +16 -0
- package/dist/core/runner/inherited-ask-grants.d.ts +6 -6
- package/dist/core/runner/memory-capture-optout.d.ts +1 -1
- package/dist/core/runner/memory-consolidation-driver.d.ts +4 -4
- package/dist/core/runner/memory-consolidation.d.ts +6 -8
- package/dist/core/runner/memory-consolidation.js +0 -1
- package/dist/core/runner/park-commit.d.ts +6 -6
- package/dist/core/runner/permission-rule-lanes.d.ts +19 -19
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -4
- package/dist/core/runner/prepare-artifact.d.ts +53 -0
- package/dist/core/runner/prepare-artifact.js +77 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +3 -3
- package/dist/core/runner/prepare-boundary-parks.d.ts +3 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +9 -7
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -3
- package/dist/core/runner/prepare-config-doors.d.ts +24 -24
- package/dist/core/runner/prepare-config-doors.js +5 -2
- package/dist/core/runner/prepare-context-lane.d.ts +8 -8
- package/dist/core/runner/prepare-context-lane.js +2 -13
- package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
- package/dist/core/runner/prepare-file-history.d.ts +3 -3
- package/dist/core/runner/prepare-file-history.js +3 -52
- package/dist/core/runner/prepare-gate-stations.d.ts +5 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +35 -38
- package/dist/core/runner/prepare-hands-readface.js +3 -2
- package/dist/core/runner/prepare-inherited-gate.d.ts +9 -6
- package/dist/core/runner/prepare-inherited-gate.js +7 -8
- package/dist/core/runner/prepare-listings.d.ts +3 -3
- package/dist/core/runner/prepare-lsp.d.ts +3 -3
- package/dist/core/runner/prepare-memory-engine-session.d.ts +5 -5
- package/dist/core/runner/prepare-memory.d.ts +4 -6
- package/dist/core/runner/prepare-memory.js +10 -9
- package/dist/core/runner/prepare-offload-wrappers.d.ts +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +6 -6
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
- package/dist/core/runner/prepare-policy-chain.js +15 -30
- package/dist/core/runner/prepare-prompt-assembly.js +1 -1
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -5
- package/dist/core/runner/prepare-protocol-tools.d.ts +1 -1
- package/dist/core/runner/prepare-question-face.d.ts +4 -4
- package/dist/core/runner/prepare-run-refs.d.ts +11 -11
- package/dist/core/runner/prepare-safety-scan.d.ts +2 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -4
- package/dist/core/runner/prepare-suspend-saga.js +0 -2
- package/dist/core/runner/prepare-task.d.ts +12 -12
- package/dist/core/runner/prepare-task.js +10 -9
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +2 -3
- package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -4
- package/dist/core/runner/prepare-wiring-manifest.js +9 -7
- package/dist/core/runner/prepare-workspace-restore.d.ts +1 -1
- package/dist/core/runner/remote-env-retry.d.ts +3 -3
- package/dist/core/runner/resume-admission.d.ts +1 -1
- package/dist/core/runner/resume-admission.js +2 -1
- package/dist/core/runner/resume-claim.d.ts +1 -1
- package/dist/core/runner/resume-internals-and-config.d.ts +1 -1
- package/dist/core/runner/resume-internals-and-config.js +4 -0
- package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
- package/dist/core/runner/resume-preflight.d.ts +1 -1
- package/dist/core/runner/resume-review-outcome.d.ts +1 -1
- package/dist/core/runner/retired-runner-deps.d.ts +3 -0
- package/dist/core/runner/retired-runner-deps.js +7 -0
- package/dist/core/runner/run-brain-sinks.d.ts +1 -1
- package/dist/core/runner/run-clock-and-content.d.ts +4 -4
- package/dist/core/runner/run-compaction-machinery.d.ts +3 -3
- package/dist/core/runner/run-git-lane.d.ts +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +2 -2
- package/dist/core/runner/run-harness-handlers.js +2 -3
- package/dist/core/runner/run-identity-wiring.d.ts +4 -4
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-notification-lane.d.ts +2 -2
- package/dist/core/runner/run-reasoning-seat.d.ts +2 -2
- package/dist/core/runner/run-settle-and-teardown.d.ts +5 -5
- package/dist/core/runner/run-settle-and-teardown.js +3 -1
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +5 -5
- package/dist/core/runner/runtask.d.ts +14 -14
- package/dist/core/runner/session-file-state-replay.d.ts +3 -3
- package/dist/core/runner/session-file-state-replay.js +3 -3
- package/dist/core/runner/session-rule-policy.d.ts +2 -2
- package/dist/core/runner/session-rule-policy.js +3 -4
- package/dist/core/runner/steer-admission.d.ts +2 -2
- package/dist/core/runner/stream-halt-verbs.d.ts +1 -1
- package/dist/core/runner/stream-halt-verbs.js +1 -1
- package/dist/core/runner/stream-reap.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +1 -4
- package/dist/core/runner/synthetic-tools.d.ts +8 -8
- package/dist/core/runner/teardown-bounded.d.ts +2 -2
- package/dist/core/runner/tool-defer-gate.d.ts +1 -1
- package/dist/core/runner/tool-disclosure.d.ts +33 -33
- package/dist/core/runner/tool-end-body.d.ts +3 -3
- package/dist/core/runner/tool-face-overlay.d.ts +2 -2
- package/dist/core/runner/tool-output-projection.d.ts +2 -2
- package/dist/core/runner/turn-attachments.d.ts +53 -53
- package/dist/core/runner/usage-accounting.d.ts +4 -4
- package/dist/core/runner/workspace-path.d.ts +1 -1
- package/dist/core/runner/workspace-path.js +3 -0
- package/dist/core/runner-deps.d.ts +30 -49
- package/dist/core/safe-notify.d.ts +1 -1
- package/dist/core/sensitive-path-policy.d.ts +1 -1
- package/dist/core/sensitive-path-policy.js +4 -4
- package/dist/core/session.d.ts +2 -2
- package/dist/core/skill-tool-specifier.d.ts +1 -1
- package/dist/core/skills-directory.d.ts +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +1 -1
- package/dist/core/strategy-store.d.ts +8 -11
- package/dist/core/task-event.d.ts +20 -17
- package/dist/core/task-limits.d.ts +1 -1
- package/dist/core/task-notification.d.ts +5 -5
- package/dist/core/task-registry-agent.d.ts +5 -5
- package/dist/core/task-registry-monitor.d.ts +2 -2
- package/dist/core/task-registry-shared.d.ts +27 -27
- package/dist/core/task-registry-shared.js +3 -13
- package/dist/core/task-registry.d.ts +8 -8
- package/dist/core/task-result.d.ts +37 -37
- package/dist/core/task-spec.d.ts +5 -5
- package/dist/core/task-stream.d.ts +16 -11
- package/dist/core/tool-catalog-entries.d.ts +1 -0
- package/dist/core/tool-catalog-entries.js +5 -0
- package/dist/core/tool-conformance.d.ts +0 -2
- package/dist/core/tool-conformance.js +1 -3
- package/dist/core/tool-errors.d.ts +5 -0
- package/dist/core/tool-errors.js +1 -0
- package/dist/core/tool-policy.d.ts +51 -22
- package/dist/core/tool-policy.js +28 -5
- package/dist/core/tool-result-budget.d.ts +1 -1
- package/dist/core/tool-result-store.d.ts +11 -11
- package/dist/core/tool-spec.d.ts +34 -38
- package/dist/core/tools.d.ts +2 -2
- package/dist/core/trace.d.ts +12 -15
- package/dist/core/untrusted-text.d.ts +1 -1
- package/dist/core/wiring-manifest.d.ts +4 -3
- package/dist/core/workflow-journal-store.d.ts +11 -11
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -2
- package/dist/engine/execution-env/node-execution-env.js +4 -2
- package/dist/engine/harness/agent-harness.d.ts +47 -4
- package/dist/engine/harness/agent-harness.js +52 -9
- package/dist/engine/llm/types.d.ts +1 -1
- package/dist/engine/loop/agent-loop.js +15 -8
- package/dist/engine/loop/types.d.ts +5 -0
- package/dist/index.d.ts +21 -16
- package/dist/index.js +17 -12
- package/dist/internal/harness.d.ts +1 -0
- package/dist/orchestration/run-spec.d.ts +3 -0
- package/dist/orchestration/run-spec.js +3 -3
- package/dist/orchestration/run-workflow-tool.d.ts +12 -6
- package/dist/orchestration/run-workflow-tool.js +23 -5
- package/dist/orchestration/workflow-primitives.d.ts +4 -2
- package/dist/orchestration/workflow-primitives.js +1 -4
- package/dist/orchestration/workflow-types.d.ts +34 -4
- package/dist/orchestration/workflow-types.js +2 -0
- package/dist/orchestration/workflow.d.ts +39 -7
- package/dist/orchestration/workflow.js +234 -113
- package/dist/prompt-assembly/assemble.d.ts +2 -2
- package/dist/prompt-assembly/assemble.js +9 -9
- package/dist/prompt-assembly/composer.d.ts +6 -7
- package/dist/prompt-assembly/composer.js +10 -10
- package/dist/prompt-assembly/epoch.js +1 -1
- package/dist/prompt-assembly/event-registry.d.ts +0 -21
- package/dist/prompt-assembly/packs/sema-default.js +30 -30
- package/dist/prompt-assembly/types.d.ts +14 -14
- package/dist/prompts/coordinator.d.ts +0 -13
- package/dist/prompts/coordinator.js +0 -3
- package/dist/stores/file/checkpoint-store.js +1 -5
- package/dist/stores/file/file-history-store.js +2 -2
- package/dist/stores/file/permission-rule-store.d.ts +4 -35
- package/dist/stores/file/permission-rule-store.js +4 -148
- package/dist/tools/artifact/artifact-text.d.ts +62 -0
- package/dist/tools/artifact/artifact-text.js +68 -0
- package/dist/tools/artifact/artifact-tool.d.ts +52 -0
- package/dist/tools/artifact/artifact-tool.js +351 -0
- package/dist/tools/artifact/local-stub.d.ts +26 -0
- package/dist/tools/artifact/local-stub.js +296 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +114 -48
- package/dist/tools/fs/bash-readonly-classifier.js +171 -60
- package/dist/tools/fs/encoding.d.ts +31 -40
- package/dist/tools/fs/fs-bash.d.ts +49 -45
- package/dist/tools/fs/fs-bash.js +19 -27
- package/dist/tools/fs/fs-pdf.d.ts +8 -8
- package/dist/tools/fs/fs-search-tools.d.ts +4 -4
- package/dist/tools/fs/fs-search-tools.js +5 -2
- package/dist/tools/fs/fs-shared.d.ts +146 -158
- package/dist/tools/fs/fs-shared.js +3 -11
- package/dist/tools/fs/fs-write.d.ts +8 -8
- package/dist/tools/fs/gh-rate-limit.d.ts +13 -14
- package/dist/tools/fs/index.d.ts +78 -78
- package/dist/tools/fs/index.js +4 -1
- package/dist/tools/fs/notebook.d.ts +24 -25
- package/dist/tools/fs/pdf.d.ts +3 -3
- package/dist/tools/fs/read-deny.d.ts +22 -22
- package/dist/tools/fs/read-face.d.ts +21 -24
- package/dist/tools/fs/repo-map.d.ts +8 -8
- package/dist/tools/fs/safety.d.ts +233 -130
- package/dist/tools/fs/safety.js +131 -31
- package/dist/tools/fs/search.d.ts +63 -71
- package/dist/tools/fs/search.js +8 -6
- package/package.json +6 -2
- package/test/export-surface.snapshot.json +119 -39
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { forkGovernanceDenial, resolveDelegationEntryCaps } from "../../agents/subagent.js";
|
|
2
2
|
import { isLiveQuestionFace } from "../ask-question.js";
|
|
3
|
+
import { parentSpecSeatOf } from "../parent-spec-seat.js";
|
|
3
4
|
import { createPreToolUseConstraintPolicy } from "../hooks.js";
|
|
4
5
|
import { StubExecutionEnv } from "../stub-env.js";
|
|
5
|
-
import { askApproverIdentity,
|
|
6
|
+
import { askApproverIdentity, durableMandateSourceOf } from "../tool-policy.js";
|
|
6
7
|
import { attachRebuiltDenialTrackers, createDenialLimitStop } from "./denial-limit-arms.js";
|
|
7
8
|
export function prepareInheritedGate(input) {
|
|
8
9
|
const { spec, deps, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, executionEnv, ownedEnv, lockedPreflight, toolFaceSnapshot, promptProfile, resolvedInteractionPosture, autoModeSeat, handsEnabled, reportUsage, harnessRef, skillScope, forwardEvent, subagentRetain, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun } = input;
|
|
@@ -93,6 +94,7 @@ export function prepareInheritedGate(input) {
|
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
96
|
const frozenOnQuestion = spec.onQuestion ?? deps.onQuestion;
|
|
97
|
+
const parentSpecSeat = parentSpecSeatOf(spec, frozenOnQuestion);
|
|
96
98
|
const provenanceForChildrenRef = {};
|
|
97
99
|
const delegationProvenanceForChildren = () => provenanceForChildrenRef.current;
|
|
98
100
|
const delegationSettlementRef = {};
|
|
@@ -106,8 +108,7 @@ export function prepareInheritedGate(input) {
|
|
|
106
108
|
...(ownSessionRulesRef.current !== undefined ? [ownSessionRulesRef.current] : []),
|
|
107
109
|
];
|
|
108
110
|
const ownCallerPolicy = lockedPreflight.toolPolicy;
|
|
109
|
-
const durableMandate = input.runtimeCaps()?.forceDurableGate === true
|
|
110
|
-
(spec.durableApproval !== undefined && !isLiveApproverSeat(frozenOnAsk));
|
|
111
|
+
const durableMandate = durableMandateSourceOf({ forceDurableGate: input.runtimeCaps()?.forceDurableGate === true, durableApprovalDeclared: spec.durableApproval !== undefined, onAsk: frozenOnAsk }) !== undefined;
|
|
111
112
|
const contentMandate = input.runtimeCaps()?.forceDurableGate === true ||
|
|
112
113
|
(spec.durableApproval !== undefined && !isLiveQuestionFace(frozenOnQuestion));
|
|
113
114
|
const ownPreToolUse = input.preToolUseObservational() ? undefined : input.hooks()?.preToolUse;
|
|
@@ -186,15 +187,13 @@ export function prepareInheritedGate(input) {
|
|
|
186
187
|
...(readDenyAdditionsNormalized.length > 0 ? { readDenyPatterns: Object.freeze(readDenyAdditionsNormalized.map((e) => ({ ...e }))) } : {}),
|
|
187
188
|
...(spec.interactiveTools === false ? { interactiveTools: false } : {}),
|
|
188
189
|
oneShot: spec.oneShot,
|
|
189
|
-
|
|
190
|
+
parentSpecSeat,
|
|
191
|
+
...(internals?.questionFaceStripped === true ? { questionFaceStripped: true } : {}),
|
|
190
192
|
excludeTools: toolFaceSnapshot.exclude,
|
|
191
193
|
deferTools: toolFaceSnapshot.defer,
|
|
192
194
|
alwaysLoadTools: toolFaceSnapshot.alwaysLoad,
|
|
193
195
|
...(toolFaceSnapshot.restoreGated !== undefined ? { restoreGatedTools: toolFaceSnapshot.restoreGated } : {}),
|
|
194
196
|
promptProfile,
|
|
195
|
-
...(spec.additionalDirectories !== undefined ? { additionalDirectories: Object.freeze([...spec.additionalDirectories]) } : {}),
|
|
196
|
-
...(spec.additionalReadDirectories !== undefined ? { additionalReadDirectories: Object.freeze([...spec.additionalReadDirectories]) } : {}),
|
|
197
|
-
...(spec.envFacts !== undefined ? { envFacts: { ...spec.envFacts } } : {}),
|
|
198
197
|
...(spec.memoryPersistenceCapable !== undefined ? { memoryPersistenceCapable: spec.memoryPersistenceCapable } : {}),
|
|
199
198
|
get memoryCaptureOptedOut() {
|
|
200
199
|
return input.memoryEngineSession()?.captureOptOut?.optedOut() ?? false;
|
|
@@ -263,5 +262,5 @@ export function prepareInheritedGate(input) {
|
|
|
263
262
|
...(spec.enablePlanMode === true ? { enterPlanMode } : {}),
|
|
264
263
|
};
|
|
265
264
|
};
|
|
266
|
-
return { liveInheritedGate, seedInheritedGate, inheritedAncestorRules, inheritedShellGate, inheritedParentConstraints, autoModeIntent, inheritedAdmittedOrgScopes, priorOwnOrgVerdict, orgGovernedProvenance, effectiveShellGate, ownSessionRulesRef, memoryAdmittedOrgScopesRef, ownOrgVerdictRef, orgAdmissionCheckpointState, faceCheckpointSection, faceCheckpointState, f012CheckpointState, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, frozenOnQuestion, provenanceForChildrenRef, delegationSettlementRef, inheritedGateForChildren, carrierReadFace, fullShellReachable, gateStopRef, stopForDenialLimit, enrichSpecToolCtx };
|
|
265
|
+
return { liveInheritedGate, seedInheritedGate, inheritedAncestorRules, inheritedShellGate, inheritedParentConstraints, autoModeIntent, inheritedAdmittedOrgScopes, priorOwnOrgVerdict, orgGovernedProvenance, effectiveShellGate, ownSessionRulesRef, memoryAdmittedOrgScopesRef, ownOrgVerdictRef, orgAdmissionCheckpointState, faceCheckpointSection, faceCheckpointState, f012CheckpointState, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, frozenOnQuestion, parentSpecSeat, provenanceForChildrenRef, delegationSettlementRef, inheritedGateForChildren, carrierReadFace, fullShellReachable, gateStopRef, stopForDenialLimit, enrichSpecToolCtx };
|
|
267
266
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PrepareTask's LISTINGS phase: the per-task agent definitions' tool-name audit
|
|
3
3
|
* (deny entries fail loud, allow entries advise), the agent-listing announce face read off the
|
|
4
4
|
* delegation tool's roster (with its deferred / excluded / removal-to-zero arms), the two listing
|
|
5
5
|
* opt-out advisories, the announced-listings mirror seeded from the once-per-session ledger, the
|
|
6
6
|
* deferred roster's ToolSearch ride, and the date_change seam. The body is the driver's stretch moved
|
|
7
|
-
* verbatim; the interface is the dependency list it had implicitly
|
|
7
|
+
* verbatim; the interface is the dependency list it had implicitly.
|
|
8
8
|
*
|
|
9
9
|
* SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await, so the phase adds no yield between
|
|
10
|
-
* the disclosure mount before it and the context-lane seats after it (
|
|
10
|
+
* the disclosure mount before it and the context-lane seats after it (a stretch
|
|
11
11
|
* with no await is extracted as a sync function — an `async` wrapper would open a microtask window).
|
|
12
12
|
*
|
|
13
13
|
* Throws pass through unchanged: `config.agent.unknown_tool` (a deny entry naming a tool this
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PrepareTask's LSP phase, verbatim from the driver: the manager fold (spec > deps), the
|
|
3
3
|
* LSP tool mount over the per-task env with its git-ignore filter, the diagnostics lane behind its four
|
|
4
4
|
* preconditions (a manager whose sessions feed a registry, write-capable hands, not opted out), the run-scoped
|
|
5
5
|
* registry key, and the edit nudge (raw path → the SAME resolution the tool leg uses → registry reset +
|
|
6
6
|
* session didChange). No manager ⇒ nothing mounts and both lane seats are undefined. The interface is the
|
|
7
|
-
* dependency list the segment had implicitly
|
|
7
|
+
* dependency list the segment had implicitly.
|
|
8
8
|
*
|
|
9
9
|
* SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await, so the phase adds no yield between the
|
|
10
|
-
* fork-governance note before it and the memory trio's occupancy read after it (
|
|
10
|
+
* fork-governance note before it and the memory trio's occupancy read after it (a stretch
|
|
11
11
|
* with no await is extracted as a sync function — an `async` wrapper would open a microtask window).
|
|
12
12
|
* Read-stability of the host handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
|
|
13
13
|
*/
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* classification + one-way session pollution wrap section (
|
|
4
|
-
*
|
|
2
|
+
* PrepareTask's MEMORY-ENGINE-SESSION phase, verbatim from the driver: the content-origin
|
|
3
|
+
* classification + one-way session pollution wrap section (consolidating several design threads).
|
|
4
|
+
* Its arming predicate (a mounted memory session OR an
|
|
5
5
|
* upstream recorder channel), the chain-narrowed classification config, the children's provenance seat, the
|
|
6
6
|
* declared-MCP-class announcement, the settlement seat, the per-tool wrap with its three record verbs (mark /
|
|
7
7
|
* recordExternal / recordIncomplete), the Read tool's recall-taint arm and the delegation arm's three-valued
|
|
8
8
|
* attestation judgment all live here; the announcement helper only this section called moved with it. The
|
|
9
|
-
* interface is the dependency list the segment had implicitly
|
|
9
|
+
* interface is the dependency list the segment had implicitly.
|
|
10
10
|
*
|
|
11
11
|
* SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await of its own (the awaits sit inside the wrappers it
|
|
12
12
|
* installs, which run at tool-call time), so the phase adds no yield between the deferred classification before it
|
|
13
|
-
* and the prompt assembly after it (
|
|
13
|
+
* and the prompt assembly after it (a stretch with no await is extracted as a sync function).
|
|
14
14
|
* Read-stability of the host handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
|
|
15
15
|
*
|
|
16
16
|
* One read changed spelling and nothing else: the declared-class announcement read `mcp?.statuses` while `mcp` had
|
|
@@ -18,12 +18,6 @@ export interface PrepareMemoryInput {
|
|
|
18
18
|
/** borrowed-readonly — the resolved task root: the containment boundary every derived memory dir
|
|
19
19
|
* is checked against, and the repo-root fallback when `deps.rootPath` is unset. */
|
|
20
20
|
taskRootPath: string;
|
|
21
|
-
/** borrowed-mutable — the caller's write-gate cell, and THIS phase is its writer: it installs the
|
|
22
|
-
* memory write gate into `.current` (the module header's one out-param effect). Identity is the
|
|
23
|
-
* contract — the caller's hands/read-face seat reads this exact cell. */
|
|
24
|
-
memoryWriteGateRef: {
|
|
25
|
-
current?: BeforeWriteHook;
|
|
26
|
-
};
|
|
27
21
|
/**
|
|
28
22
|
* borrowed-readonly — #181-F5: whether a tool NAMED `Write` (the tool the CC `# Memory` instruction names) is on the
|
|
29
23
|
* ASSEMBLED roster this run, not excluded, AND can actually REACH the host-side memory root:
|
|
@@ -199,6 +193,10 @@ export interface MemoryInjectionComposition {
|
|
|
199
193
|
export interface PrepareMemoryResult {
|
|
200
194
|
memoryEngineSession: Prepared["memoryEngineSession"];
|
|
201
195
|
memoryTools?: ToolSpec[];
|
|
196
|
+
/** owned — the memory WRITE gate (Write/Edit/NotebookEdit run their FINAL text through MemoryEngine.gateWrite when
|
|
197
|
+
* the target lands inside the memory writable root; the read-only plane refuses its own domain). Present iff a memory
|
|
198
|
+
* engine mounted; the hands phase composes it into the band's beforeWrite (a memory-less run: every write passes). */
|
|
199
|
+
memoryWriteGate?: BeforeWriteHook;
|
|
202
200
|
/**
|
|
203
201
|
* owned — #691: the injection's COMPOSITION step, run by the driver AFTER the hands phase (the mount above runs
|
|
204
202
|
* BEFORE it). It performs the one destructive read this phase has — `inject()` drains the announcement queue —
|
|
@@ -10,9 +10,11 @@ import { readSessionCaptureOptOut } from "../memory-engine/layout.js";
|
|
|
10
10
|
import { createMemoryEngineTools } from "../memory-engine/tools.js";
|
|
11
11
|
import { assertScopeContractPlacement, parseScopeKey, resolveProjectId } from "../memory-engine/scope-contract.js";
|
|
12
12
|
import { FileMemoryEngineBackend } from "../memory-engine/file-backend.js";
|
|
13
|
+
import { writableRootOf } from "../memory-engine/types.js";
|
|
13
14
|
let undeclaredCapturePostureAnnounced = false;
|
|
14
15
|
export async function prepareMemory(input) {
|
|
15
|
-
const { spec, deps, sessionId, taskRootPath,
|
|
16
|
+
const { spec, deps, sessionId, taskRootPath, admissionCtx } = input;
|
|
17
|
+
let memoryWriteGate;
|
|
16
18
|
const memorySpec = normalizeMemorySpec(spec.memory);
|
|
17
19
|
let admittedOrgScopes = [];
|
|
18
20
|
let ownOrgVerdict;
|
|
@@ -460,21 +462,19 @@ export async function prepareMemory(input) {
|
|
|
460
462
|
}
|
|
461
463
|
const foreignUnderRoot = [];
|
|
462
464
|
if (input.writeToolsMounted && writeHandle.writeScope !== null && input.advertisedWritableDirs !== undefined) {
|
|
463
|
-
for (const d of [...writeEngine.readonlyDirNamesUnderRoot(writeHandle)].sort())
|
|
464
|
-
foreignUnderRoot.push(`another scope's directory ${d}`);
|
|
465
465
|
const controlPlane = canonicalize(writeEngine.controlPlaneDir);
|
|
466
|
-
if (isContainedIn(writeHandle
|
|
466
|
+
if (isContainedIn(writableRootOf(writeHandle), controlPlane))
|
|
467
467
|
foreignUnderRoot.push(`the engine's control plane ${controlPlane}`);
|
|
468
468
|
}
|
|
469
469
|
if (foreignUnderRoot.length > 0) {
|
|
470
|
-
deps.onError?.(new Error(`memory advertised writable directory refused: the write scope's root ${writeHandle
|
|
470
|
+
deps.onError?.(new Error(`memory advertised writable directory refused: the write scope's root ${writableRootOf(writeHandle)} contains what is not the model's to touch (${foreignUnderRoot.join("; ")}) — the file tools' root fence is directory-granular, so admitting it would expose those files; memory writes through the file tools stay closed this session and the write instruction is not taught.`), { phase: "config", sessionId });
|
|
471
471
|
}
|
|
472
472
|
writeChannelOpen =
|
|
473
473
|
input.writeToolsMounted &&
|
|
474
474
|
writeHandle.writeScope !== null &&
|
|
475
475
|
foreignUnderRoot.length === 0 &&
|
|
476
|
-
(input.advertisedWritableDirs === undefined || (await input.advertisedWritableDirs.admit({ path: writeHandle
|
|
477
|
-
|
|
476
|
+
(input.advertisedWritableDirs === undefined || (await input.advertisedWritableDirs.admit({ path: writableRootOf(writeHandle), advertiser: "memory", expectCanonical: writableRootOf(writeHandle) })));
|
|
477
|
+
memoryWriteGate = async (w) => {
|
|
478
478
|
if (readOnlyEngine !== undefined && readOnlyHandle !== undefined) {
|
|
479
479
|
const ro = readOnlyEngine.gateWrite(readOnlyHandle, w.key, w.content);
|
|
480
480
|
if (!ro.ok)
|
|
@@ -482,7 +482,7 @@ export async function prepareMemory(input) {
|
|
|
482
482
|
}
|
|
483
483
|
if (input.memoryPersistenceDeclared === false) {
|
|
484
484
|
const root = writeHandle.writableRoot;
|
|
485
|
-
if (w.key === root || w.key.startsWith(`${root}${sep}`)) {
|
|
485
|
+
if (root !== null && (w.key === root || w.key.startsWith(`${root}${sep}`))) {
|
|
486
486
|
return {
|
|
487
487
|
ok: false,
|
|
488
488
|
code: "read_only_layering",
|
|
@@ -493,7 +493,7 @@ export async function prepareMemory(input) {
|
|
|
493
493
|
}
|
|
494
494
|
{
|
|
495
495
|
const root = writeHandle.writableRoot;
|
|
496
|
-
if (w.key === root || w.key.startsWith(`${root}${sep}`)) {
|
|
496
|
+
if (root !== null && (w.key === root || w.key.startsWith(`${root}${sep}`))) {
|
|
497
497
|
const state = captureOptedOut ? { record: { at: 0, reason: "in-run state" }, fault: false } : await writeEngine.sessionCaptureOptOutOrFault(sessionId);
|
|
498
498
|
if (state.record !== undefined || state.fault) {
|
|
499
499
|
return {
|
|
@@ -777,6 +777,7 @@ export async function prepareMemory(input) {
|
|
|
777
777
|
ownOrgVerdict,
|
|
778
778
|
effectiveMemoryScopes,
|
|
779
779
|
...(memoryTools !== undefined ? { memoryTools } : {}),
|
|
780
|
+
...(memoryWriteGate !== undefined ? { memoryWriteGate } : {}),
|
|
780
781
|
composeInjection,
|
|
781
782
|
};
|
|
782
783
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* (The offload half of the prelude) — prepareTask's nested-usage accumulator, the
|
|
3
3
|
* large-tool-result offload store resolution and the THREE offload wrappers every later mount site
|
|
4
4
|
* applies (caller tools, first-party hand tools, remote MCP/A2A peers), verbatim from the driver.
|
|
5
5
|
*
|
|
6
6
|
* SYNCHRONOUS by construction: the segment held no await in the driver, and a phase that yields where
|
|
7
7
|
* the driver did not would open a microtask window between two steps that used to be adjacent (the
|
|
8
|
-
*
|
|
8
|
+
* posture). Nothing here touches the store — the wrappers close over it and only the
|
|
9
9
|
* wrapped tools' `execute` reach it, at run time.
|
|
10
10
|
*
|
|
11
11
|
* What stays in the driver: the trust-axis choice of `offloadScope` (`spec.principal ?? "default"`)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PrepareTask's PARK CLOSURE and CONTENT-ASK ROUTING closure, verbatim from the driver's
|
|
3
3
|
* gate-machinery block: `resolveContentAsk` (the question face's delivery race, the binding table's cap and redemption
|
|
4
4
|
* identity, the stranded-answer disclosure) and `suspendAsk` (the sync-first decline and the park-priority mandates, the
|
|
5
5
|
* args capture / fidelity projection / re-adjudication steps, the pause-then-cut fence, the gate-kind choice, the row
|
|
6
6
|
* mint, the commit through the saga and the post-commit publication). The one module-scope helper only this segment
|
|
7
|
-
* threw (`ParkRefusal`) moved with it. The interface is the dependency list the segment had implicitly
|
|
8
|
-
*
|
|
7
|
+
* threw (`ParkRefusal`) moved with it. The interface is the dependency list the segment had implicitly
|
|
8
|
+
* — the two closures used to capture every seat here off the driver's scope, which is the capture surface this
|
|
9
9
|
* decomposition exists to make explicit.
|
|
10
10
|
*
|
|
11
11
|
* The thirteen-argument park closure is unchanged: twelve positional seats then the structural {@link AskCarry}, the
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* carry onto the row exactly as before — this phase mints no origin, changes no word, adds no arm to the closed set.
|
|
14
14
|
*
|
|
15
15
|
* SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await of its own (both closures run per tool call), so the
|
|
16
|
-
* phase adds no yield between the boundary parks before it and the gate station after it
|
|
16
|
+
* phase adds no yield between the boundary parks before it and the gate station after it.
|
|
17
17
|
* Read-stability of the host handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
|
|
18
18
|
*
|
|
19
19
|
* Both closures exist exactly when the ask lane and the saga do (the same predicate) — an absent lane answers two absent
|
|
@@ -50,7 +50,7 @@ export interface PrepareParkAskInput {
|
|
|
50
50
|
/** borrowed-readonly — the leg's checkpoint store, or undefined (then `suspendAsk` is absent — the park predicate's store
|
|
51
51
|
* term). Read: the declared fidelity; the saga writes to it. */
|
|
52
52
|
checkpointStore: CheckpointStore | undefined;
|
|
53
|
-
/** borrowed-readonly — the leg's delta seat (
|
|
53
|
+
/** borrowed-readonly — the leg's delta seat (B18): the park reads the gated tool's identity off its
|
|
54
54
|
* CURRENT roster snapshot so the row carries who the action was minted against. */
|
|
55
55
|
toolRosterDeltas: ToolRosterDeltaSeat;
|
|
56
56
|
/** borrowed-readonly — the wiring-manifest phase's park predicate (`parkLane.effective`): arms `suspendAsk`. */
|
|
@@ -155,7 +155,7 @@ export interface PrepareParkAskResult {
|
|
|
155
155
|
/** The M19 park-ask phase body — prepareTask's park closure and content-ask routing stretch, verbatim (see the module header). */
|
|
156
156
|
export declare function prepareParkAsk(input: PrepareParkAskInput): PrepareParkAskResult;
|
|
157
157
|
/**
|
|
158
|
-
* From the resumed/active transcript, the batch position of `currentId
|
|
158
|
+
* From the resumed/active transcript, the batch position of `currentId`: the tool-call
|
|
159
159
|
* ids of the assistant message that issued it (the batch), and the subset already resolved (executed
|
|
160
160
|
* before the suspend — #1..k-1). ID-based, not positional (council Question #1): immune to reordering.
|
|
161
161
|
*/
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PrepareTask's POLICY-CHAIN phase, verbatim from the driver: the caller policy
|
|
3
3
|
* and its name audit (advisory once per deployment; the two hard refusals), the session / ancestor / frozen-projection /
|
|
4
4
|
* skill-scope deny-narrowing layers and their fold, the resume-edit base policy, the hook record with its timeout seat
|
|
5
5
|
* and observational half, the same-instance arbitration machinery (the caller slot's first-decision record), the
|
|
6
|
-
* inherited-unavailable marker channel, the
|
|
6
|
+
* inherited-unavailable marker channel, the grant record, the sandbox-admission mode's arming and its three
|
|
7
7
|
* sideband maps, the source-identity and risk-axes factories, the two permission-rule lanes and the rule-offer
|
|
8
8
|
* factory, the approved-edit re-check, the inherited-constraint wrappers (the same-instance adapter and the true
|
|
9
9
|
* wrapper), the rewrite-emitter index and the instrumented chain, the integrity guards, the fold, and the final-form
|
|
10
10
|
* re-check that is the effective policy. The advised-names dedupe pair only this section reads moved with it.
|
|
11
|
-
* The interface is the dependency list the segment had implicitly
|
|
11
|
+
* The interface is the dependency list the segment had implicitly.
|
|
12
12
|
*
|
|
13
13
|
* ASYNC PHASE: the stretch awaits the session-policy store (the task's own rules and each ancestor's live re-read)
|
|
14
14
|
* exactly where the segment did; the closures it builds await at tool-call time. The phase boundary adds one
|
|
@@ -75,9 +75,9 @@ export interface PreparePolicyChainInput {
|
|
|
75
75
|
irreversible?: false;
|
|
76
76
|
egress?: false;
|
|
77
77
|
}>;
|
|
78
|
-
/** borrowed-readonly — the
|
|
79
|
-
*
|
|
80
|
-
|
|
78
|
+
/** borrowed-readonly — the ENGINE HAND roster: every tool whose effect dispatches through the task's execution env,
|
|
79
|
+
* membership minted at the mount sites (the sandbox boundary predicate's one containment fact). */
|
|
80
|
+
envHandToolNames: ReadonlySet<string>;
|
|
81
81
|
/** borrowed-readonly — the shell-seat provenance set (the offer factory's `shellGated` mandate term, read per call). */
|
|
82
82
|
shellGatedTools: ReadonlySet<string>;
|
|
83
83
|
/** borrowed-readonly — the tracked-cwd seat, read per call by the lanes and the offer factory (never written here). */
|
|
@@ -148,7 +148,7 @@ export interface PreparePolicyChainResult {
|
|
|
148
148
|
/** borrowed-mutable — the inherited-unavailable marker channel. Writers: the inherited arms here (mark); the gate station
|
|
149
149
|
* (the lifecycle-end sweep) and the park lane's consumers (delete on consumption). */
|
|
150
150
|
inheritedUnavailableAsks: Set<string>;
|
|
151
|
-
/** borrowed-mutable — the
|
|
151
|
+
/** borrowed-mutable — the grant record. Writers: the inherited arms here (record a clean allow at a live approver);
|
|
152
152
|
* the gate station (consume on reuse, sweep at settlement). */
|
|
153
153
|
inheritedAskGrants: Map<string, {
|
|
154
154
|
approver: unknown;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { SEND_MESSAGE_TOOL_NAME } from "../../agents/send-message-tool.js";
|
|
2
1
|
import { policyAskClassOf } from "../ask-class.js";
|
|
3
2
|
import { ASK_USER_QUESTION_TOOL_NAME } from "../ask-question.js";
|
|
4
3
|
import { resolveCheckpointStore } from "../checkpoint-store.js";
|
|
5
4
|
import { cloneObserverInput, resolveHookTimeoutMs } from "../hooks.js";
|
|
6
5
|
import { isNamespacedCoveringRuleName, namespacedRuleNameCovers } from "../permission-rules.js";
|
|
7
6
|
import { isIsolated } from "../remote-env.js";
|
|
8
|
-
import { askApproverIdentity, carryEngineAttestations, carryPrecedingSettlement, checkToolPolicyProjection, combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, isLiveApproverSeat, resolveAsk, toolPolicyNameSets } from "../tool-policy.js";
|
|
7
|
+
import { askApproverIdentity, carryEngineAttestations, carryPrecedingSettlement, checkToolPolicyProjection, combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, isLiveApproverSeat, resolveAsk, toolPolicyNameSets, attestAskUnresolvableCause } from "../tool-policy.js";
|
|
9
8
|
import { RETIRED_TOOL_NAMES } from "../tool-name-aliases.js";
|
|
10
9
|
import { NAMESPACED_NAME_SHAPES, protocolOf } from "../protocol-table.js";
|
|
11
10
|
import { emitTrace } from "../trace.js";
|
|
@@ -16,7 +15,7 @@ import { askGrantShapeOf } from "./inherited-ask-grants.js";
|
|
|
16
15
|
import { createPermissionRuleLanes, inheritedAskRuleEvidence, createRuleOffersOf } from "./permission-rule-lanes.js";
|
|
17
16
|
import { createSessionRulePolicy } from "./session-rule-policy.js";
|
|
18
17
|
export async function preparePolicyChain(input) {
|
|
19
|
-
const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, executionEnv, lockedPreflight, tools, harnessTools, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives,
|
|
18
|
+
const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, executionEnv, lockedPreflight, tools, harnessTools, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, envHandToolNames, handsCwdRef, readDenyMatcher, questionToolMounted, runtimeCaps, inheritedAncestorRules, inheritedParentConstraints, seedInheritedGate, hasSkillManifest, skillScope, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, autoModeDecider, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef } = input;
|
|
20
19
|
const policy = lockedPreflight.toolPolicy;
|
|
21
20
|
const auditPolicyNames = (auditee) => {
|
|
22
21
|
const nameGroups = toolPolicyNameSets(auditee);
|
|
@@ -144,6 +143,12 @@ export async function preparePolicyChain(input) {
|
|
|
144
143
|
inheritedUnavailableAsks.add(toolCallId);
|
|
145
144
|
return true;
|
|
146
145
|
};
|
|
146
|
+
const mandatedCallFloats = (toolCallId) => resolveCheckpointStore(spec, deps) !== undefined && (spec.durableApproval !== undefined || runtimeCaps?.forceDurableGate === true) && markInheritedUnavailable(toolCallId);
|
|
147
|
+
const mandateUnreconstructibleDeny = (creq) => attestAskUnresolvableCause({
|
|
148
|
+
action: "deny",
|
|
149
|
+
message: `inherited parent policy requires durable approval for "${creq.toolName}" — the parent's durable ask cannot be reconstructed in a delegated child; denied fail-closed (tighten-only)`,
|
|
150
|
+
}, "mandate_unreconstructible", creq);
|
|
151
|
+
const markerChannelFullDeny = (creq) => attestAskUnresolvableCause({ action: "deny", message: `no approver is reachable for the inherited approval of "${creq.toolName}" and the marker channel is at capacity — denied fail-closed` }, "approver_unavailable", creq);
|
|
147
152
|
const inheritedAskGrants = new Map();
|
|
148
153
|
const recordInheritedAskGrant = (toolCallId, approver, presented, waitMs) => {
|
|
149
154
|
if (typeof approver !== "function")
|
|
@@ -190,7 +195,7 @@ export async function preparePolicyChain(input) {
|
|
|
190
195
|
list.push({ cls, layer });
|
|
191
196
|
foldAskClasses.set(toolCallId, list);
|
|
192
197
|
};
|
|
193
|
-
const sandboxBoundaryCapable = (toolName) => egressTools.has(toolName) ||
|
|
198
|
+
const sandboxBoundaryCapable = (toolName) => egressTools.has(toolName) || !envHandToolNames.has(toolName);
|
|
194
199
|
const emitSandboxAdmitted = (info) => {
|
|
195
200
|
emitTrace(deps.tracer, () => ({
|
|
196
201
|
kind: "permission.sandbox_admitted",
|
|
@@ -358,16 +363,9 @@ export async function preparePolicyChain(input) {
|
|
|
358
363
|
};
|
|
359
364
|
}
|
|
360
365
|
if (pc.durableMandate === true) {
|
|
361
|
-
if (
|
|
362
|
-
(spec.durableApproval !== undefined || runtimeCaps?.forceDurableGate === true) &&
|
|
363
|
-
markInheritedUnavailable(creq.toolCallId)) {
|
|
366
|
+
if (mandatedCallFloats(creq.toolCallId))
|
|
364
367
|
return first;
|
|
365
|
-
|
|
366
|
-
return {
|
|
367
|
-
action: "deny",
|
|
368
|
-
message: `inherited parent policy requires durable approval for "${creq.toolName}" — the parent's durable ` +
|
|
369
|
-
`ask cannot be reconstructed in a delegated child; denied fail-closed (tighten-only)`,
|
|
370
|
-
};
|
|
368
|
+
return mandateUnreconstructibleDeny(creq);
|
|
371
369
|
}
|
|
372
370
|
const judged = await judgeInheritedClassifier({ autoMode: pc.autoMode, ask: first, req: creq, signal: csignal ?? abortController.signal, subject: "this call" });
|
|
373
371
|
if (judged.kind === "allow")
|
|
@@ -398,10 +396,7 @@ export async function preparePolicyChain(input) {
|
|
|
398
396
|
if (resolved.action === "deny" && resolved.approverUnavailable === true) {
|
|
399
397
|
if (markInheritedUnavailable(creq.toolCallId))
|
|
400
398
|
return inheritedAsk;
|
|
401
|
-
return
|
|
402
|
-
action: "deny",
|
|
403
|
-
message: `no approver is reachable for the inherited approval of "${creq.toolName}" and the marker channel is at capacity — denied fail-closed`,
|
|
404
|
-
};
|
|
399
|
+
return markerChannelFullDeny(creq);
|
|
405
400
|
}
|
|
406
401
|
settleDenialLimitFallback({ fallback, mintedHere, tracker: pc.autoMode?.denialTracking, resolved, headless: headlessDenyAtFold, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
|
|
407
402
|
if (resolved.action !== "allow")
|
|
@@ -437,16 +432,9 @@ export async function preparePolicyChain(input) {
|
|
|
437
432
|
};
|
|
438
433
|
}
|
|
439
434
|
if (pc.durableMandate === true) {
|
|
440
|
-
if (
|
|
441
|
-
(spec.durableApproval !== undefined || runtimeCaps?.forceDurableGate === true) &&
|
|
442
|
-
markInheritedUnavailable(creq.toolCallId)) {
|
|
435
|
+
if (mandatedCallFloats(creq.toolCallId))
|
|
443
436
|
return decision;
|
|
444
|
-
|
|
445
|
-
return {
|
|
446
|
-
action: "deny",
|
|
447
|
-
message: `inherited parent policy requires durable approval for "${creq.toolName}" — the parent's durable ` +
|
|
448
|
-
`ask cannot be reconstructed in a delegated child; denied fail-closed (tighten-only)`,
|
|
449
|
-
};
|
|
437
|
+
return mandateUnreconstructibleDeny(creq);
|
|
450
438
|
}
|
|
451
439
|
const presentedArgs = decision.updatedInput !== undefined ? decision.updatedInput : creq.args;
|
|
452
440
|
const judged = await judgeInheritedClassifier({ autoMode: pc.autoMode, ask: decision, req: { ...creq, args: presentedArgs }, signal: csignal ?? abortController.signal, subject: "this call" });
|
|
@@ -477,10 +465,7 @@ export async function preparePolicyChain(input) {
|
|
|
477
465
|
if (resolved.action === "deny" && resolved.approverUnavailable === true) {
|
|
478
466
|
if (markInheritedUnavailable(creq.toolCallId))
|
|
479
467
|
return inheritedAsk;
|
|
480
|
-
return
|
|
481
|
-
action: "deny",
|
|
482
|
-
message: `no approver is reachable for the inherited approval of "${creq.toolName}" and the marker channel is at capacity — denied fail-closed`,
|
|
483
|
-
};
|
|
468
|
+
return markerChannelFullDeny(creq);
|
|
484
469
|
}
|
|
485
470
|
settleDenialLimitFallback({ fallback, mintedHere, tracker: pc.autoMode?.denialTracking, resolved, headless: headlessDenyAtFold, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
|
|
486
471
|
if (resolved.action !== "allow")
|
|
@@ -95,7 +95,7 @@ export async function preparePromptAssembly(input) {
|
|
|
95
95
|
}
|
|
96
96
|
: undefined;
|
|
97
97
|
const promptConstitution = assembled.constitution;
|
|
98
|
-
const promptBlocks = assembled.
|
|
98
|
+
const promptBlocks = assembled.blocks;
|
|
99
99
|
const collisionAudit = auditToolCollisions(tools);
|
|
100
100
|
for (const y of collisionAudit.yields) {
|
|
101
101
|
onceLedger.onError(new Error(`tool mount: caller tool "${y.name}" shadows another tool with the same canonical name (deliberate last-write-wins yield — the later mount serves)`), { phase: "config", sessionId });
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PrepareTask's PROMPT-INPUTS phase: the prompt provider selection, the runtime
|
|
3
3
|
* feature flags the harness-context block gates on (so it never claims a mechanism the task lacks),
|
|
4
4
|
* the three-source user system prompt + the caller's append block, the fenced MCP server-instructions
|
|
5
5
|
* block, the environment facts (client zone + date basis, knowledge cutoff, the deployment's sandbox
|
|
6
6
|
* axes, resume-continuity facts on a durable-resume leg only, the hands facts + the one batched env
|
|
7
|
-
* probe with its cwd/pwd alignment guard) and the git-status lane probe. The body is
|
|
8
|
-
*
|
|
7
|
+
* probe with its cwd/pwd alignment guard) and the git-status lane probe. The body is moved verbatim
|
|
8
|
+
* from the driver's own stretch; its interface is the dependency list that stretch had implicitly.
|
|
9
9
|
*
|
|
10
10
|
* ASYNC BY CONTENT: the stretch awaits the env probe (hands) and the git-status lane probe (always).
|
|
11
11
|
* It sits past prepareTask's first await, so the driver's `await` adds no window a caller could reach.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* The one input computed by the DRIVER rather than read here: `failClosedReason` — the
|
|
14
14
|
* self-orchestration fail-closed advisory's text. Its helper takes the whole `TaskSpec`/`RunnerDeps`
|
|
15
15
|
* (it audits several deployment seats), which this phase's narrow `spec`/`deps` seats cannot satisfy
|
|
16
|
-
*
|
|
16
|
+
* The driver evaluates the helper in the Input literal and this phase only announces
|
|
17
17
|
* the result on the operator lane, exactly where the stretch always did.
|
|
18
18
|
*
|
|
19
19
|
* Nothing here throws on its own: the env probe and the alignment guard are best-effort (a stub/odd env
|
|
@@ -91,7 +91,7 @@ export interface PreparePromptInputsInput {
|
|
|
91
91
|
additionalRootsCanonical: readonly string[];
|
|
92
92
|
/** borrowed-readonly — the canonical extra read-only roots (copied into the env facts). */
|
|
93
93
|
additionalReadRootsCanonical: readonly string[];
|
|
94
|
-
/** borrowed-readonly —
|
|
94
|
+
/** borrowed-readonly — the advertised-writable-directory seat (hands only). The scratchpad section is
|
|
95
95
|
* rendered only when the seat did not SKIP the scratchpad — a directory the fence refused is not advertised. */
|
|
96
96
|
advertisedWritableDirs?: AdvertisedWritableDirs;
|
|
97
97
|
/** borrowed-readonly — the acquired session's id (operator-line context). */
|
|
@@ -36,7 +36,7 @@ export interface PrepareProtocolToolsInput {
|
|
|
36
36
|
* wrapper) and, at RUN time, the refresh closure's splice within a server's name-prefix domain. Later
|
|
37
37
|
* phases push their own mounts; the roster's full writer table is the delegation-surface phase's. */
|
|
38
38
|
roster: RosterBuilder;
|
|
39
|
-
/** borrowed-mutable — the run-time delta seat
|
|
39
|
+
/** borrowed-mutable — the run-time delta seat: the refresh closure re-mints the roster through it after
|
|
40
40
|
* every re-splice so the stream learns of the change. Armed by the driver after the roster is minted. */
|
|
41
41
|
rosterSeat: ToolRosterDeltaSeat;
|
|
42
42
|
/** borrowed-readonly — the large-result wrapper for protocol tools (per-tool `_meta` bar, 50K default). */
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PrepareTask's QUESTION-FACE phase, verbatim from the driver: the leg's ONE checkpoint-store
|
|
3
3
|
* read, the durable mandate as it binds at the question seat, the content-ask binding table (with the leak
|
|
4
4
|
* bound the routing lane checks against — the constant below), the stranded-answer disclosure and the leg-end
|
|
5
5
|
* settle, the three-way mount decision (live face / durable face / override), and the AskUserQuestion mount
|
|
6
6
|
* with its redeemed-approval, posture, fallback and synthetic-continuation arms. The interface is the
|
|
7
|
-
* dependency list the segment had implicitly
|
|
7
|
+
* dependency list the segment had implicitly.
|
|
8
8
|
*
|
|
9
9
|
* SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await, so the phase adds no yield between the
|
|
10
|
-
* offload-reader mount before it and the scheduler mount after it (
|
|
10
|
+
* offload-reader mount before it and the scheduler mount after it (a stretch with no await
|
|
11
11
|
* is extracted as a sync function — an `async` wrapper would open a microtask window). Read-stability of the
|
|
12
12
|
* host handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
|
|
13
13
|
*
|
|
14
|
-
* One seat is a LIVE GETTER
|
|
14
|
+
* One seat is a LIVE GETTER: the inherited-unavailable marker set is declared by the driver's
|
|
15
15
|
* gate-fold section AFTER this phase and read per call at RUN time, so it enters as `() => ReadonlySet` — a
|
|
16
16
|
* read before the driver declares it throws (temporal dead zone), which is the fail-loud an uninitialized
|
|
17
17
|
* live read owes.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PrepareTask's RUN-REFS phase, verbatim from the driver: the run's own edited-files
|
|
3
3
|
* ledger, the harness ref, the per-task skill scope, the display-forwarding wrapper, the three run-local refs
|
|
4
4
|
* (review request / stop-after-turn / plan mode) with the ctx primitives that write them, the subagent-retain
|
|
5
5
|
* ledger and the worktree-isolation helper. Nothing here has behavior of its own: the phase MINTS SEATS —
|
|
6
6
|
* mutable cells and the closures bound to them — that later phases, the tool ctx and the run loop read and
|
|
7
|
-
* write. The interface is the dependency list the segment had implicitly
|
|
7
|
+
* write. The interface is the dependency list the segment had implicitly.
|
|
8
8
|
*
|
|
9
9
|
* SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await, so the phase adds no yield between the
|
|
10
|
-
* file-history phase before it and the inherited-gate fold after it (
|
|
10
|
+
* file-history phase before it and the inherited-gate fold after it (a stretch with no
|
|
11
11
|
* await is extracted as a sync function — an `async` wrapper would open a microtask window).
|
|
12
12
|
*
|
|
13
|
-
* Every cell that leaves here as `borrowed-mutable` carries its writer table on the Result member
|
|
14
|
-
*
|
|
13
|
+
* Every cell that leaves here as `borrowed-mutable` carries its writer table on the Result member:
|
|
14
|
+
* the closures minted here, the driver's harness build, the project-context phase's inherited-skill
|
|
15
15
|
* seed, the skill tool, and the run loop's two writes — nothing else writes them. Read-stability of the host
|
|
16
16
|
* handles for the call: {@link RunInternals} (`@contract prepare.deps-read-stable`).
|
|
17
17
|
*/
|
|
@@ -43,8 +43,8 @@ export interface PrepareRunRefsResult {
|
|
|
43
43
|
/** owned — the ledger's LIVE read face (`Prepared.editedFilesSnapshot`, read at result assembly). */
|
|
44
44
|
editedFilesSnapshot: EditedFilesLedger["snapshot"];
|
|
45
45
|
/** borrowed-mutable — the harness seat: holds the harness once built, so a tool's execute can read the model
|
|
46
|
-
* the parent is CURRENTLY on (
|
|
47
|
-
* for `inherit`), and breaks the harness↔tool_search build cycle (
|
|
46
|
+
* the parent is CURRENTLY on (the `ToolExecuteContext.model` snapshot a delegation tool uses
|
|
47
|
+
* for `inherit`), and breaks the harness↔tool_search build cycle (rematerialize). Writers (R-3):
|
|
48
48
|
* the driver, ONCE, when the harness is built (`harnessRef.current = harness`) — before any run. Readers:
|
|
49
49
|
* `requestStopAfterTurn` here (mirrors the stop onto the harness's one-way flag), the tool ctx's model
|
|
50
50
|
* snapshot, the rebuild seam and the delegation mounts. Identity is the contract: every closure minted
|
|
@@ -63,7 +63,7 @@ export interface PrepareRunRefsResult {
|
|
|
63
63
|
* (the first request wins) and the run loop's turn-boundary consumer, which clears `pending` once the
|
|
64
64
|
* `plan_review` checkpoint is minted. */
|
|
65
65
|
reviewRequestRef: Prepared["reviewRequestRef"];
|
|
66
|
-
/** owned — the ctx primitive that arms `reviewRequestRef
|
|
66
|
+
/** owned — the ctx primitive that arms `reviewRequestRef`. */
|
|
67
67
|
requestReview: (opts?: {
|
|
68
68
|
reason?: string;
|
|
69
69
|
}) => void;
|
|
@@ -79,7 +79,7 @@ export interface PrepareRunRefsResult {
|
|
|
79
79
|
/** owned — the ctx primitive (mounted on the ctx only under `enablePlanMode`). */
|
|
80
80
|
enterPlanMode: () => void;
|
|
81
81
|
/** ownership-ref — the parent-run subagent-retain ledger, or undefined when the spec did not opt in. Its
|
|
82
|
-
* lifecycle protocol belongs to the Runner (disposed in the task's terminal finally
|
|
82
|
+
* lifecycle protocol belongs to the Runner (disposed in the task's terminal finally); a
|
|
83
83
|
* prepare that throws has nothing to release here — the ledger is empty until a delegation retains. */
|
|
84
84
|
subagentRetain: SubagentRetainLedger | undefined;
|
|
85
85
|
/** owned — the Agent tool's worktree-isolation helper (lazy; write-capable runs only), or undefined. */
|
|
@@ -90,8 +90,8 @@ export interface PrepareRunRefsResult {
|
|
|
90
90
|
* A run that opted into `forwardSubagentEvents` may have BACKGROUND children whose frames are forwarded to the
|
|
91
91
|
* deployment's sink from the child's own run. Those forwards are scheduled on later microtasks than the parent's
|
|
92
92
|
* turn, so "the parent stream ended" and "the child's already-emitted frames reached the sink" are two different
|
|
93
|
-
* moments — the gap is one microtask ladder deep and moves whenever the gate's station structure changes
|
|
94
|
-
*
|
|
93
|
+
* moments — the gap is one microtask ladder deep and moves whenever the gate's station structure changes
|
|
94
|
+
* (the three-layer gate added three async frames to a child's gated call, and a consumer that read the parent
|
|
95
95
|
* to `done` then inspected the sink lost the child's `tool_end`). The rule is not a tick count: **before the parent
|
|
96
96
|
* says `done`, every frame a child had already handed to the forward channel is delivered.** One macrotask turn is
|
|
97
97
|
* the smallest boundary that strictly orders after all pending microtasks; it is taken only on the opted-in run,
|
|
@@ -9,10 +9,10 @@ export interface PrepareSafetyScanInput {
|
|
|
9
9
|
deps: RunnerDeps;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* The scan's outputs. Ownership annotations (
|
|
12
|
+
* The scan's outputs. Ownership annotations (four-class form):
|
|
13
13
|
*
|
|
14
14
|
* `ownToolNames` is **borrowed-readonly** — a first-await snapshot with no mutation anywhere after
|
|
15
|
-
* the scan
|
|
15
|
+
* the scan (sandbox containment reads the env-hand roster, not this set).
|
|
16
16
|
*
|
|
17
17
|
* The six collections are **borrowed-mutable**: the driver and later phases fold into them IN
|
|
18
18
|
* PLACE (identity is part of the contract — closures alias these exact objects). Mutation owners
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PrepareTask's DURABLE SETTLEMENT machinery, verbatim from the driver's
|
|
3
3
|
* gate-machinery block: the in-flight spend and repair-bundle folds, the §4.bis correctness-state serializer, the shared
|
|
4
4
|
* paused-VM compensation bound to this task's failure ledger, the put-commit + put-failure saga (the pre-put cut
|
|
5
5
|
* checkpoint, the screening-park disclosure, the rejection read-back with its three answers), the suspend-loop cap, the
|
|
6
6
|
* env capability split (suspendable / park-only / neither) and the park-only handle. The module-scope helpers only this
|
|
7
7
|
* segment called moved with it (the compensation's bound and body, the auto-mode latch reading, the placement stamp).
|
|
8
|
-
* The interface is the dependency list the segment had implicitly
|
|
8
|
+
* The interface is the dependency list the segment had implicitly — every seat below used to be
|
|
9
9
|
* captured off the driver's scope.
|
|
10
10
|
*
|
|
11
11
|
* SYNCHRONOUS FUNCTION, SYNCHRONOUS CALL: the stretch has no await of its own (every await lives inside the closures it
|
|
12
12
|
* builds, which run at park time), so the phase adds no yield between the ask lane before it and the boundary parks
|
|
13
|
-
* after it
|
|
13
|
+
* after it. Read-stability of the host handles for the call: {@link RunInternals}
|
|
14
14
|
* (`@contract prepare.deps-read-stable`).
|
|
15
15
|
*
|
|
16
16
|
* The saga exists exactly when the wiring-manifest phase's `gateMachineryActive` holds (the ask lane's presence law) —
|
|
@@ -27,7 +27,7 @@ import type { OutputRef } from "./synthetic-tools.js";
|
|
|
27
27
|
import type { HookInvocationIdentity } from "../hooks.js";
|
|
28
28
|
import type { InheritedGate, Prepared, PrepareResume, RunInternals, SuspendSaga } from "./contracts.js";
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* The ONE compensation for a paused-but-unparked VM, shared by the fence's
|
|
31
31
|
* post-pause checkpoints (③ in the park closure, ④ in the saga) and the saga's put-failure absent
|
|
32
32
|
* arm (previously inline there: same two hops, one implementation now, so the three sites cannot
|
|
33
33
|
* drift). Restores the workspace (bounded transient retry) then re-establishes consistency
|