@sema-agent/core 7.62.0 → 7.63.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 +528 -0
- package/dist/agents/subagent-transcript-placement.d.ts +23 -0
- package/dist/agents/subagent-transcript-placement.js +14 -0
- package/dist/agents/subagent.js +82 -51
- package/dist/brain/route-adjudicator.js +9 -4
- package/dist/core/approval-object.js +1 -1
- package/dist/core/arg-summary.js +1 -1
- package/dist/core/ask-question.d.ts +2 -2
- package/dist/core/canonical-json.d.ts +23 -13
- package/dist/core/canonical-json.js +4 -4
- package/dist/core/checkpoint-queries.d.ts +47 -4
- package/dist/core/checkpoint-queries.js +36 -16
- package/dist/core/checkpoint-requirements.d.ts +3 -3
- package/dist/core/checkpoint-requirements.js +2 -1
- package/dist/core/checkpoint-row-verdict.d.ts +15 -4
- package/dist/core/checkpoint-row-verdict.js +22 -2
- package/dist/core/checkpoint-store.d.ts +23 -10
- package/dist/core/checkpoint-store.js +45 -4
- package/dist/core/compliance.d.ts +6 -2
- package/dist/core/compliance.js +3 -3
- package/dist/core/engine-attestation.d.ts +1 -1
- package/dist/core/engine-notice.d.ts +19 -4
- package/dist/core/git-worktree-env.d.ts +62 -3
- package/dist/core/git-worktree-env.js +91 -30
- package/dist/core/governance-codes.d.ts +7 -3
- package/dist/core/governance-codes.js +13 -3
- package/dist/core/memory-engine/consolidation-driver.d.ts +32 -17
- package/dist/core/memory-engine/consolidation-driver.js +99 -98
- package/dist/core/memory-engine/consolidation.d.ts +73 -10
- package/dist/core/memory-engine/consolidation.js +167 -11
- package/dist/core/memory-engine/data-plane.d.ts +8 -4
- package/dist/core/memory-engine/data-plane.js +11 -6
- package/dist/core/memory-engine/delegation-settlement.d.ts +37 -35
- package/dist/core/memory-engine/delegation-settlement.js +53 -59
- package/dist/core/memory-engine/dual-root.d.ts +12 -6
- package/dist/core/memory-engine/dual-root.js +9 -5
- package/dist/core/memory-engine/engine.d.ts +98 -35
- package/dist/core/memory-engine/engine.js +477 -380
- package/dist/core/memory-engine/entry-scan.d.ts +8 -0
- package/dist/core/memory-engine/entry-scan.js +3 -0
- package/dist/core/memory-engine/file-backend.d.ts +29 -3
- package/dist/core/memory-engine/file-backend.js +66 -35
- package/dist/core/memory-engine/index.d.ts +7 -7
- package/dist/core/memory-engine/index.js +6 -6
- package/dist/core/memory-engine/landing-admission.d.ts +5 -3
- package/dist/core/memory-engine/landing-admission.js +3 -3
- package/dist/core/memory-engine/layout.d.ts +121 -45
- package/dist/core/memory-engine/layout.js +252 -102
- package/dist/core/memory-engine/memory-backend-contract.d.ts +19 -1
- package/dist/core/memory-engine/memory-backend-contract.js +320 -0
- package/dist/core/memory-engine/memory-deployment.d.ts +31 -8
- package/dist/core/memory-engine/memory-deployment.js +26 -12
- package/dist/core/memory-engine/scope-contract.d.ts +52 -11
- package/dist/core/memory-engine/scope-contract.js +68 -19
- package/dist/core/memory-engine/session-write-home.d.ts +3 -1
- package/dist/core/memory-engine/session-write-home.js +1 -1
- package/dist/core/memory-engine/sync-client.d.ts +3 -1
- package/dist/core/memory-engine/sync-client.js +7 -0
- package/dist/core/memory-engine/sync-report.d.ts +3 -2
- package/dist/core/memory-engine/sync-report.js +6 -2
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.js +10 -10
- package/dist/core/memory-engine/types.d.ts +118 -19
- package/dist/core/memory-engine/types.js +1 -0
- package/dist/core/memory.js +15 -6
- package/dist/core/mods/stations.d.ts +20 -1
- package/dist/core/mods/stations.js +21 -2
- package/dist/core/park-selfcheck.js +2 -2
- package/dist/core/pause-registry.d.ts +2 -0
- package/dist/core/pause-registry.js +3 -0
- package/dist/core/permission-rule-consent.d.ts +10 -3
- package/dist/core/permission-rule-consent.js +37 -24
- package/dist/core/permission-rule-store.d.ts +35 -1
- package/dist/core/permission-rule-store.js +27 -8
- package/dist/core/read-only-shell.js +3 -2
- package/dist/core/redaction-marks.d.ts +8 -0
- package/dist/core/redaction-marks.js +6 -0
- package/dist/core/remote-env.d.ts +12 -1
- package/dist/core/remote-env.js +3 -0
- package/dist/core/runner/child-tree.d.ts +29 -3
- package/dist/core/runner/child-tree.js +39 -16
- package/dist/core/runner/contracts.d.ts +18 -9
- package/dist/core/runner/gate-exit.js +2 -2
- package/dist/core/runner/inherited-ask-grants.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.d.ts +6 -3
- package/dist/core/runner/memory-consolidation-driver.js +4 -4
- package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
- package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
- package/dist/core/runner/person-path-rows.d.ts +8 -3
- package/dist/core/runner/person-path-rows.js +5 -1
- package/dist/core/runner/placement-fence.d.ts +12 -0
- package/dist/core/runner/placement-fence.js +20 -6
- package/dist/core/runner/prepare-ask-lane.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -1
- package/dist/core/runner/prepare-caps-and-workflow.js +5 -2
- package/dist/core/runner/prepare-execution-env.js +17 -6
- package/dist/core/runner/prepare-hands-readface.d.ts +2 -1
- package/dist/core/runner/prepare-hands-readface.js +4 -3
- package/dist/core/runner/prepare-inherited-gate.d.ts +10 -8
- package/dist/core/runner/prepare-inherited-gate.js +8 -4
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
- package/dist/core/runner/prepare-memory-engine-session.js +4 -4
- package/dist/core/runner/prepare-memory.d.ts +3 -2
- package/dist/core/runner/prepare-memory.js +28 -20
- package/dist/core/runner/prepare-park-ask.js +4 -3
- package/dist/core/runner/prepare-task.js +15 -12
- package/dist/core/runner/prepare-workspace-restore.js +3 -6
- package/dist/core/runner/run-leg.js +1 -1
- package/dist/core/runner/run-settle-and-teardown.js +3 -2
- package/dist/core/runner/terminal-account.js +1 -1
- package/dist/core/runner-deps.d.ts +6 -2
- package/dist/core/secret-env.d.ts +1 -1
- package/dist/core/secret-env.js +4 -4
- package/dist/core/session-checkout.d.ts +108 -0
- package/dist/core/session-checkout.js +485 -0
- package/dist/core/session-store.d.ts +12 -4
- package/dist/core/session-store.js +23 -3
- package/dist/core/session.d.ts +16 -2
- package/dist/core/session.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +0 -12
- package/dist/core/store-contracts/checkpoint-store-contract.js +6 -7
- package/dist/core/store-contracts/session-store-contract.js +39 -0
- package/dist/core/task-event.d.ts +21 -0
- package/dist/core/task-notification.d.ts +9 -1
- package/dist/core/task-notification.js +6 -0
- package/dist/core/task-registry-agent.d.ts +14 -2
- package/dist/core/task-registry-agent.js +45 -19
- package/dist/core/task-registry-shared.d.ts +26 -11
- package/dist/core/task-registry.d.ts +15 -9
- package/dist/core/task-registry.js +9 -10
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +20 -0
- package/dist/core/tool-policy.d.ts +14 -12
- package/dist/core/tool-policy.js +11 -10
- package/dist/core/tool-spec.d.ts +38 -19
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +15 -4
- package/dist/core/untrusted-egress.js +23 -22
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/harness/types.d.ts +66 -1
- package/dist/engine/harness/types.js +108 -0
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +24 -1
- package/dist/engine/session/session.js +45 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +7 -4
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +4 -1
- package/dist/orchestration/run-workflow-tool.js +1 -0
- package/dist/orchestration/workflow.d.ts +3 -0
- package/dist/orchestration/workflow.js +3 -1
- package/dist/stores/file/session-store.js +2 -1
- package/dist/tools/fs/bash-program-position.js +3 -3
- package/dist/tools/fs/program-read-model.d.ts +34 -10
- package/dist/tools/fs/program-read-model.js +37 -7
- package/dist/tools/fs/program-read-model.rows.js +13 -2
- package/dist/tools/fs/read-deny.d.ts +13 -1
- package/dist/tools/fs/read-deny.js +10 -2
- package/dist/tools/fs/removal-targets.js +3 -3
- package/dist/tools/fs/safety.d.ts +2 -0
- package/dist/tools/fs/safety.js +1 -1
- package/dist/tools/fs/shell-read-argv.d.ts +8 -1
- package/dist/tools/fs/shell-read-argv.js +34 -29
- package/dist/tools/fs/shell-read-bindings.d.ts +2 -0
- package/dist/tools/fs/shell-read-bindings.js +5 -1
- package/dist/tools/fs/shell-read-brace.d.ts +18 -0
- package/dist/tools/fs/shell-read-brace.js +79 -0
- package/dist/tools/fs/shell-read-check.js +10 -8
- package/dist/tools/fs/shell-read-establish.js +23 -16
- package/dist/tools/fs/shell-read-judge.d.ts +11 -0
- package/dist/tools/fs/shell-read-judge.js +3 -3
- package/dist/tools/fs/shell-read-plan.d.ts +10 -0
- package/dist/tools/fs/shell-read-plan.js +189 -93
- package/dist/tools/fs/shell-read-start.d.ts +19 -9
- package/dist/tools/fs/shell-read-start.js +20 -12
- package/dist/tools/fs/shell-read-word.d.ts +10 -0
- package/dist/tools/fs/shell-read-word.js +9 -5
- package/dist/tools/fs/shell-read-workdir.d.ts +26 -7
- package/dist/tools/fs/shell-read-workdir.js +73 -12
- package/dist/tools/fs/shell-read-write-targets.js +13 -8
- package/dist/tools/worktree.d.ts +3 -2
- package/dist/tools/worktree.js +7 -35
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +73 -11
- package/wire-changes/core-stores-sql@7.63.0.json +30 -0
- package/wire-changes/core@7.63.0.json +3523 -0
- package/wire-changes/mods-kernel@7.63.0.json +30 -0
- package/wire-changes/primitives@7.63.0.json +445 -0
- package/dist/core/credential-vocabulary.d.ts +0 -176
- package/dist/core/credential-vocabulary.js +0 -190
- package/dist/core/redaction-passes.d.ts +0 -82
- package/dist/core/redaction-passes.js +0 -377
|
@@ -2,7 +2,7 @@ import { StubExecutionEnv } from "../stub-env.js";
|
|
|
2
2
|
import { hasDestroy } from "../remote-env.js";
|
|
3
3
|
import { mintPlacementFence } from "./placement-fence.js";
|
|
4
4
|
import { announceMalformedCapabilities } from "./env-capability-census.js";
|
|
5
|
-
import { childPlacementOnLeg, deploymentCanRerootChild, worktreeNotHonored } from "./child-tree.js";
|
|
5
|
+
import { callerTreeMissed, canonicalOrSelf, childPlacementOnLeg, deploymentCanRerootChild, factoryIgnoredHint, worktreeNotHonored } from "./child-tree.js";
|
|
6
6
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
7
7
|
export async function prepareExecutionEnv(input) {
|
|
8
8
|
const { deps, spec, internals, resume, placementRootResolved, sessionId, forgetOnThrow, rollback } = input;
|
|
@@ -73,13 +73,24 @@ export async function prepareExecutionEnv(input) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
const handsEnabled = ownedEnv !== undefined || deps.executionEnv !== undefined;
|
|
76
|
-
const
|
|
76
|
+
const parentCwd = internals?.worktreeOffered !== true ? internals?.parentCwd : undefined;
|
|
77
|
+
const childAtCaller = parentCwd !== undefined && (ownedEnv === undefined || (await canonicalOrSelf(executionEnv, executionEnv.cwd)) === (await canonicalOrSelf(executionEnv, parentCwd)));
|
|
78
|
+
const taskRootInitial = childAtCaller && parentCwd !== undefined
|
|
79
|
+
? parentCwd
|
|
80
|
+
: internals?.isolation === "worktree" || internals?.requestedCwd !== undefined || internals?.worktreeOffered === true || !deps.rootPath ? executionEnv.cwd : deps.rootPath;
|
|
77
81
|
const placement = internals?.callerRoot === undefined ? undefined : await childPlacementOnLeg(executionEnv, { ...internals, callerRoot: internals.callerRoot }, taskRootInitial);
|
|
78
|
-
|
|
79
|
-
await settleTeardownLeg(() => forgetOnThrow(),
|
|
80
|
-
await settleTeardownLeg(() => (ownedEnv && hasDestroy(ownedEnv) ? ownedEnv.destroy() : undefined),
|
|
82
|
+
const refuseChild = async (leg, refusal) => {
|
|
83
|
+
await settleTeardownLeg(() => forgetOnThrow(), `forgetOnThrow (${leg} leg)`, (err) => deps.onError?.(err, { phase: "config", sessionId }));
|
|
84
|
+
await settleTeardownLeg(() => (ownedEnv && ownedEnv !== deps.executionEnv && hasDestroy(ownedEnv) ? ownedEnv.destroy() : undefined), `ownedEnv.destroy (${leg} leg)`, (err) => deps.onError?.(err, { phase: "config", sessionId }));
|
|
81
85
|
ownedEnvSeat.current = undefined;
|
|
82
|
-
throw
|
|
86
|
+
throw refusal;
|
|
87
|
+
};
|
|
88
|
+
if (placement !== undefined && internals?.callerRoot !== undefined) {
|
|
89
|
+
if (internals.worktreeOffered === true && placement === "caller_tree")
|
|
90
|
+
await refuseChild("worktree-not-honored", worktreeNotHonored(executionEnv.cwd));
|
|
91
|
+
const missedTree = await callerTreeMissed(executionEnv, placement, internals.callerRoot, taskRootInitial);
|
|
92
|
+
if (missedTree !== undefined)
|
|
93
|
+
await refuseChild("caller-tree-missed", factoryIgnoredHint(taskRootInitial, executionEnv.cwd, missedTree));
|
|
83
94
|
}
|
|
84
95
|
return { executionEnv, ownedEnvSeat, ownedEnvObservedAt, handsEnabled, taskRootInitial, placement, placementFence };
|
|
85
96
|
}
|
|
@@ -39,7 +39,8 @@ export interface PrepareHandsReadFaceInput {
|
|
|
39
39
|
taskRootCanonical: string;
|
|
40
40
|
/** borrowed-readonly — the leg's ONE write-location reader (prepare-task's `currentCheckoutOf` over the worktree seat): the
|
|
41
41
|
* primary WRITE root of the structured write tools and of the shell's write targets, read per call — it is the task root
|
|
42
|
-
* until EnterWorktree switches it, and moves back on ExitWorktree. The READ roots
|
|
42
|
+
* until EnterWorktree switches it, and moves back on ExitWorktree. The READ roots read it too, and only when it left the task
|
|
43
|
+
* root: a managed tree hangs at the REPOSITORY root (#2738), so for a task rooted below that root the tree lies outside it. */
|
|
43
44
|
writeLocation: () => string;
|
|
44
45
|
/** borrowed-readonly — B-4's checkpoint-path rebaser (T7): identity unless a divergent restore
|
|
45
46
|
* armed it; applied to the readFileState seed keys and the handsCwd seed. */
|
|
@@ -196,7 +196,8 @@ export async function prepareHandsMount(input) {
|
|
|
196
196
|
const handsReadOnly = spec.handsReadOnly === true;
|
|
197
197
|
backgroundTaskToolsActive = handsIncludeShell && !handsReadOnly && hasBackgroundShell(executionEnv);
|
|
198
198
|
const shellFaceHere = [...predictMountedToolNames(new Set(backgroundTaskToolsActive ? ["hands", "backgroundTasks"] : ["hands"]))].filter(isShellFaceToolName);
|
|
199
|
-
|
|
199
|
+
const checkpointTracked = resume?.seed.handsCwd !== undefined;
|
|
200
|
+
wsSnapshot = checkpointTracked || !(handsIncludeShell && !handsReadOnly) ? undefined : await session.getWorkspaceState().catch(() => undefined);
|
|
200
201
|
rebaseWsPath = (p) => (wsSnapshot === undefined || wsSnapshot.taskRoot === rootCanonical ? p : rebaseWorkspacePath(p, wsSnapshot.taskRoot, rootCanonical));
|
|
201
202
|
if (handsIncludeShell && !handsReadOnly) {
|
|
202
203
|
handsCwdRef = { current: rootCanonical };
|
|
@@ -207,7 +208,7 @@ export async function prepareHandsMount(input) {
|
|
|
207
208
|
workspaceStateSettle = {
|
|
208
209
|
rootCanonical,
|
|
209
210
|
restoredHandsCwd: handsCwdRef.current !== rootCanonical ? handsCwdRef.current : undefined,
|
|
210
|
-
...(resume !== undefined ? { baselineUnknown: true } : {}),
|
|
211
|
+
...(resume !== undefined && wsSnapshot === undefined ? { baselineUnknown: true } : {}),
|
|
211
212
|
};
|
|
212
213
|
}
|
|
213
214
|
const seedReadFaceSection = resume?.seed.readFace;
|
|
@@ -226,7 +227,7 @@ export async function prepareHandsMount(input) {
|
|
|
226
227
|
const tables = (pathTables = await input.personRows.attachTables(judgedRunTables));
|
|
227
228
|
readDenyMatcher = tables.readDeny;
|
|
228
229
|
runReadFloor = readFloorSeat(tables.readDeny);
|
|
229
|
-
readRoots = readRootsOver({ own: () => [...additionalRootsCanonical, ...additionalReadRootsCanonical], tables, ready: input.personRows.tablesReady, store: () => artifactStoreRef.current,
|
|
230
|
+
readRoots = readRootsOver({ own: () => [...(input.writeLocation() === rootCanonical ? [] : [input.writeLocation()]), ...additionalRootsCanonical, ...additionalReadRootsCanonical], tables, ready: input.personRows.tablesReady, store: () => artifactStoreRef.current,
|
|
230
231
|
onHeld: (entry, store) => emitTrace(deps.tracer, () => ({ kind: "config.additional_directory_skipped", version: 1, taskId: hostTaskId, entry, field: "persistedReadRule", reason: `admits_artifact_store: the local artifact store ${store} lies inside it or it inside the store — the Artifact tool's ledger and stored files stay outside every root the file tools reach`, ts: Date.now() })) });
|
|
231
232
|
readDenyBuiltinTiersActive = activeReadDenyBuiltinTiers(readDenyBuiltinCfg);
|
|
232
233
|
readDenyAdditionsNormalized = compileReadDeny(readDenyAdditions, "readDenyPatterns", { tiers: [] }).entries;
|
|
@@ -43,7 +43,7 @@ import type { LockedPreflight } from "../locked-config.js";
|
|
|
43
43
|
import type { OwnOrgAdmissionVerdict } from "../memory-admission.js";
|
|
44
44
|
import type { DelegationContentSafety } from "../memory-engine/delegation-provenance.js";
|
|
45
45
|
import type { SessionPermissionRules } from "../session-policy-store.js";
|
|
46
|
-
import type
|
|
46
|
+
import { type SessionStore } from "../session.js";
|
|
47
47
|
import { type PlacementTarget } from "../remote-env.js";
|
|
48
48
|
import { type OnAsk, type ToolPolicy } from "../tool-policy.js";
|
|
49
49
|
import type { PathRuleBases } from "../permission-rule-model.js";
|
|
@@ -51,6 +51,7 @@ import type { PermissionMode, RunnerDeps, RuntimeCaps, ShellGateDoctrine, TaskEv
|
|
|
51
51
|
import { PermissionModeController } from "../mode-policy.js";
|
|
52
52
|
import { type SkillGrantTable } from "../skill-grant.js";
|
|
53
53
|
import type { InheritedGate, Prepared, PrepareResume, RunInternals, StopForDenialLimit, ToolFaceSnapshot, WriteFaceSeat } from "./contracts.js";
|
|
54
|
+
import type { DelegationSettlementSeat } from "../tool-spec.js";
|
|
54
55
|
export interface PrepareInheritedGateInput {
|
|
55
56
|
/** borrowed-readonly — the REBOUND spec. Read: `shellGate` (the own doctrine the chain fold tightens), `durableApproval`
|
|
56
57
|
* (the mandate tests + the children's copy), `onQuestion` (the frozen question seat), `handsReadOnly` / `interactiveTools`
|
|
@@ -84,16 +85,20 @@ export interface PrepareInheritedGateInput {
|
|
|
84
85
|
* fold (the trust floor the live half may only tighten), `seed.readFace` the hands-less re-park's carried section. */
|
|
85
86
|
resume: Pick<PrepareResume, "seed" | "outcome"> | undefined;
|
|
86
87
|
/** borrowed-readonly — the session store's fork face: `fork` / `release` are bound into the ctx's `hostSessionFork` (present
|
|
87
|
-
* only when the store can fork). */
|
|
88
|
-
sessions: Pick<SessionStore, "fork" | "release">;
|
|
88
|
+
* only when the store can fork); `placements` decides whether a fork placement is handed on. */
|
|
89
|
+
sessions: Pick<SessionStore, "fork" | "release" | "placements">;
|
|
89
90
|
/** borrowed-readonly — the acquired session id (the crash lane's context, the ctx seat, the ancestor chain's own row). */
|
|
90
91
|
sessionId: string;
|
|
91
92
|
/** borrowed-readonly — the run's invocation id (the stop seat's notice names it). */
|
|
92
93
|
runId: string;
|
|
93
94
|
/** borrowed-readonly — the per-task identity (`ctx.taskId`, the same fallback the runner uses). */
|
|
94
95
|
hostTaskId: string;
|
|
95
|
-
/** borrowed-readonly — the SETTLED task root (`ctx.
|
|
96
|
+
/** borrowed-readonly — the SETTLED task root (`ctx.callerRoot`: the checkout a delegated child must not be placed inside). */
|
|
96
97
|
taskRootFinal: string;
|
|
98
|
+
/** borrowed-readonly — where a delegated child is asked to work, read per tool call (`ctx.parentCwd`): the leg's write
|
|
99
|
+
* location (`writeLocationOf` — the active EnterWorktree tree while one is tracked), else the task root as the deployment
|
|
100
|
+
* spelled it. */
|
|
101
|
+
delegationCwd: () => string;
|
|
97
102
|
/** borrowed-readonly — the target this leg's env reported as its workspace settled (`ctx.placementTarget`: the fence of
|
|
98
103
|
* every agent the delegation tools spawn or wake from this leg); absent when it reported none. */
|
|
99
104
|
ownTarget: PlacementTarget | undefined;
|
|
@@ -319,10 +324,7 @@ export interface PrepareInheritedGateResult {
|
|
|
319
324
|
/** borrowed-mutable — the delegation-settlement coordinates. Writer: the memory-engine-session phase, once per leg when the
|
|
320
325
|
* mounted session carries a settlement seat. Read lazily by delegation tools through the ctx. */
|
|
321
326
|
delegationSettlementRef: {
|
|
322
|
-
current?:
|
|
323
|
-
controlDir: string;
|
|
324
|
-
sessionId: string;
|
|
325
|
-
};
|
|
327
|
+
current?: DelegationSettlementSeat;
|
|
326
328
|
};
|
|
327
329
|
/** owned — chain assembly SINGLE SITE: upstream chain + this task's own contribution, called by delegation tools at spawn. */
|
|
328
330
|
inheritedGateForChildren: () => InheritedGate;
|
|
@@ -5,6 +5,7 @@ import { parentSpecSeatOf } from "../parent-spec-seat.js";
|
|
|
5
5
|
import { chainJudges, sameInstallation } from "../mods/stations.js";
|
|
6
6
|
import { childClampSeats, clampSourceOf } from "../child-clamp-seats.js";
|
|
7
7
|
import { rowFollowsFloor } from "./session-rule-policy.js";
|
|
8
|
+
import { declaresSubagentPlacement } from "../session.js";
|
|
8
9
|
import { performsIo } from "../remote-env.js";
|
|
9
10
|
import { durableMandateSourceOf } from "../tool-policy.js";
|
|
10
11
|
import { chainAnchorRecords } from "./child-tree.js";
|
|
@@ -16,7 +17,7 @@ import { frozenSkillGrants } from "../skill-grant.js";
|
|
|
16
17
|
import { attachRebuiltDenialTrackers, createDenialLimitStop } from "./denial-limit-arms.js";
|
|
17
18
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
18
19
|
export function prepareInheritedGate(input) {
|
|
19
|
-
const { spec, deps, askSeat, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, executionEnv, ownedEnv, lockedPreflight, pathRuleAnchors, toolFaceSnapshot, mountsCallerTool, promptLean, resolvedInteractionPosture, permissionModeSeat, handsEnabled, reportUsage, harnessRef, skillGrants, forwardEvent, subagentRetain, taskArtifacts, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun } = input;
|
|
20
|
+
const { spec, deps, askSeat, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, delegationCwd, executionEnv, ownedEnv, lockedPreflight, pathRuleAnchors, toolFaceSnapshot, mountsCallerTool, promptLean, resolvedInteractionPosture, permissionModeSeat, handsEnabled, reportUsage, harnessRef, skillGrants, forwardEvent, subagentRetain, taskArtifacts, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun } = input;
|
|
20
21
|
const liveInheritedGate = internals?.inheritedGate;
|
|
21
22
|
const seedInheritedGate = resume?.seed.inheritedGate;
|
|
22
23
|
const inheritedAncestorRules = (() => {
|
|
@@ -227,7 +228,10 @@ export function prepareInheritedGate(input) {
|
|
|
227
228
|
return [...(internals?.memoryCaptureAncestors ?? []), { sessionId, ...(ctl !== undefined ? { controlDir: ctl } : {}) }];
|
|
228
229
|
},
|
|
229
230
|
getApiKeyAndHeaders: spec.getApiKeyAndHeaders,
|
|
230
|
-
parentCwd
|
|
231
|
+
get parentCwd() {
|
|
232
|
+
return delegationCwd();
|
|
233
|
+
},
|
|
234
|
+
callerRoot: taskRootFinal,
|
|
231
235
|
...(input.ownTarget !== undefined ? { placementTarget: input.ownTarget } : {}),
|
|
232
236
|
...(input.hostFloor !== undefined ? { hostFloor: input.hostFloor } : {}),
|
|
233
237
|
...(fileHistoryEnabled ? { fileHistoryLineage: { scope: historyScope, root: historyRoot, fs: historyFs } } : {}),
|
|
@@ -256,11 +260,11 @@ export function prepareInheritedGate(input) {
|
|
|
256
260
|
...(deps.rosterStore !== undefined ? { roster: deps.rosterStore } : {}),
|
|
257
261
|
...(sessions.fork !== undefined
|
|
258
262
|
? {
|
|
259
|
-
hostSessionFork: async () => {
|
|
263
|
+
hostSessionFork: async (forkOpts) => {
|
|
260
264
|
const tree = await input.delegationOwner.read();
|
|
261
265
|
if (!tree.bound)
|
|
262
266
|
throw delegationOwnerUnbound(tree.reason);
|
|
263
|
-
const forked = (await sessions.fork(sessionId, tree.owner)) ?? null;
|
|
267
|
+
const forked = (await sessions.fork(sessionId, tree.owner, forkOpts !== undefined && declaresSubagentPlacement(sessions) ? forkOpts : undefined)) ?? null;
|
|
264
268
|
if (forked === null)
|
|
265
269
|
return null;
|
|
266
270
|
return {
|
|
@@ -17,6 +17,7 @@ import type { LockedPreflight } from "../locked-config.js";
|
|
|
17
17
|
import { type DelegationContentSafety } from "../memory-engine/delegation-provenance.js";
|
|
18
18
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
19
19
|
import type { Prepared, RunInternals } from "./contracts.js";
|
|
20
|
+
import type { DelegationSettlementSeat } from "../tool-spec.js";
|
|
20
21
|
import { RosterBuilder } from "../tool-roster.js";
|
|
21
22
|
export interface PrepareMemoryEngineSessionInput {
|
|
22
23
|
/** borrowed-readonly — the mounted engine session, or undefined (the ARMING fact's first half). Read: `pollution`
|
|
@@ -50,10 +51,7 @@ export interface PrepareMemoryEngineSessionInput {
|
|
|
50
51
|
/** borrowed-mutable — the children's settlement seat (the inherited-gate phase mints it). Writer: THIS phase, once at
|
|
51
52
|
* arming, when the memory session mounted a settlement (memoryProvenance "carry"). */
|
|
52
53
|
delegationSettlementRef: {
|
|
53
|
-
current?:
|
|
54
|
-
controlDir: string;
|
|
55
|
-
sessionId: string;
|
|
56
|
-
};
|
|
54
|
+
current?: DelegationSettlementSeat;
|
|
57
55
|
};
|
|
58
56
|
/** borrowed-readonly — the REBOUND spec; only `tools` (the RAW caller specs: caller-tool names and the marker-bearing
|
|
59
57
|
* delegation entries — the assembled roster objects carry neither marker). Never mutated. */
|
|
@@ -30,7 +30,7 @@ export function prepareMemoryEngineSession(input) {
|
|
|
30
30
|
onNotice: deps.onNotice,
|
|
31
31
|
});
|
|
32
32
|
if (memoryEngineSession?.settlement !== undefined) {
|
|
33
|
-
delegationSettlementRef.current = { controlDir: memoryEngineSession.settlement.controlDir, sessionId: memoryEngineSession.settlement.sessionId };
|
|
33
|
+
delegationSettlementRef.current = { governance: memoryEngineSession.settlement.governance, controlDir: memoryEngineSession.settlement.controlDir, sessionId: memoryEngineSession.settlement.sessionId };
|
|
34
34
|
}
|
|
35
35
|
const recordExternal = () => {
|
|
36
36
|
if (delegationProvenanceChannel !== undefined)
|
|
@@ -118,7 +118,7 @@ export function prepareMemoryEngineSession(input) {
|
|
|
118
118
|
let preCallLaunchRows;
|
|
119
119
|
if (delegationEvidenceAttestedOnly && memoryEngineSession?.settlement !== undefined) {
|
|
120
120
|
try {
|
|
121
|
-
preCallLaunchRows = new Set(sessionSettlements(memoryEngineSession.settlement.
|
|
121
|
+
preCallLaunchRows = new Set((await sessionSettlements(memoryEngineSession.settlement.governance, memoryEngineSession.settlement.sessionId))
|
|
122
122
|
.filter((r) => r.row.lane === "background" && r.row.toolUseId === toolCallId)
|
|
123
123
|
.map((r) => r.row.settleId));
|
|
124
124
|
}
|
|
@@ -165,7 +165,7 @@ export function prepareMemoryEngineSession(input) {
|
|
|
165
165
|
preCallLaunchRows !== undefined &&
|
|
166
166
|
claimedSettleId !== undefined &&
|
|
167
167
|
!preCallLaunchRows.has(claimedSettleId) &&
|
|
168
|
-
sessionSettlements(settlementSeat.
|
|
168
|
+
(await sessionSettlements(settlementSeat.governance, settlementSeat.sessionId)).some((r) => r.row.lane === "background" && r.row.settleId === claimedSettleId && r.row.toolUseId === toolCallId);
|
|
169
169
|
}
|
|
170
170
|
catch {
|
|
171
171
|
isLaunchReceipt = false;
|
|
@@ -173,7 +173,7 @@ export function prepareMemoryEngineSession(input) {
|
|
|
173
173
|
}
|
|
174
174
|
if (!isLaunchReceipt && settlementSeat !== undefined) {
|
|
175
175
|
try {
|
|
176
|
-
recordSyncUnattestable(settlementSeat.
|
|
176
|
+
await recordSyncUnattestable(settlementSeat.governance, { sessionId: settlementSeat.sessionId, toolCallId, now: Date.now });
|
|
177
177
|
}
|
|
178
178
|
catch (err) {
|
|
179
179
|
const e = new Error(`delegated output withheld (fail-closed): the delegation delivered without a provable attestation and the settlement account could not record the fact (${thrownText(err)}) — repair the memory control plane or retry`);
|
|
@@ -212,12 +212,13 @@ export interface PrepareMemoryResult {
|
|
|
212
212
|
* so a hands-phase refusal cannot consume announcements a later prepare should deliver, and it takes the
|
|
213
213
|
* roster-wide persistence verdict the driver can only read off the MOUNTED roster (`rosterCanPersist`: the
|
|
214
214
|
* `memoryPersistenceCapable` declaration when set, else the store-path inference over the assembled tools) and
|
|
215
|
-
* `isSubagent` (a non-fork delegated child — no user conversation, no not-mounted notice). Call once per prepare
|
|
215
|
+
* `isSubagent` (a non-fork delegated child — no user conversation, no not-mounted notice). Call once per prepare;
|
|
216
|
+
* async because the drain goes through the engine's governance store.
|
|
216
217
|
*/
|
|
217
218
|
composeInjection: (facts: {
|
|
218
219
|
rosterCanPersist: boolean;
|
|
219
220
|
isSubagent: boolean;
|
|
220
|
-
}) => MemoryInjectionComposition
|
|
221
|
+
}) => Promise<MemoryInjectionComposition>;
|
|
221
222
|
/**
|
|
222
223
|
* The FROZEN org-admission verdict of this prepare: every org scope the task actually mounts
|
|
223
224
|
* (deployment-origin kept + request-origin admitted). Threaded into the run's child chain
|
|
@@ -4,9 +4,9 @@ import { admitMemoryScopes } from "../memory-admission.js";
|
|
|
4
4
|
import { adoptLegacyRepoDirs, canonicalize, deriveRepoControlPlaneDir, deriveProjectControlDir, deriveProjectMemoryDir, deriveRepoKey, deriveRepoMemoryDir, effectiveControlRootOf, isContainedIn, lookupProjectIdHint, recordProjectIdHint, resolveMemoryEngineRoot, transferMemoryAnnouncements } from "../memory-engine/layout.js";
|
|
5
5
|
import { derivePersonalControlDir, derivePersonalMemoryDir, directoryPinOf, memoryPlaneStore, mergeHarvestReports, mergeInjections, needsDualRoots, parsedProjectPlane, scopePlanesOf } from "../memory-engine/dual-root.js";
|
|
6
6
|
import { memoryProjectScopeAbsentNotice, normalizeMemorySpec } from "../memory.js";
|
|
7
|
-
import { deriveSupersededSet } from "../memory-engine/consolidation.js";
|
|
7
|
+
import { deriveSupersededSet, fileGovernanceStore } from "../memory-engine/consolidation.js";
|
|
8
8
|
import { shadowNamesOf } from "../memory-engine/shadowing.js";
|
|
9
|
-
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, memoryHarvestQuarantinedNotice, memoryHoldNotices, memoryRecallDisciplineSegment, memoryRestoreWithheldNotice, memorySessionPollutedNotice, memoryUnavailableNotice, pollutionContainmentCounts, } from "../memory-engine/engine.js";
|
|
9
|
+
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
10
|
import { adjudicateCaptureOptOut, captureOptOutDeniedError, captureOptOutUnpersistedError } from "./memory-capture-optout.js";
|
|
11
11
|
import { readSessionCaptureOptOut } from "../memory-engine/layout.js";
|
|
12
12
|
import { sessionIncarnationResolver } from "../memory-engine/session-incarnation.js";
|
|
@@ -129,11 +129,11 @@ export async function prepareMemory(input) {
|
|
|
129
129
|
const firstSwitch = verdictOnPartitionRoot && lookupProjectIdHint(engineRoot, repoRoot) !== marker.projectId;
|
|
130
130
|
if (verdictOnPartitionRoot)
|
|
131
131
|
recordProjectIdHint(engineRoot, repoRoot, marker.projectId);
|
|
132
|
-
if (firstSwitch) {
|
|
132
|
+
if (firstSwitch && backend.governance === undefined) {
|
|
133
133
|
try {
|
|
134
134
|
const oldCtl = deriveRepoControlPlaneDir(engineRoot, repoRoot);
|
|
135
135
|
const newCtl = deriveProjectControlDir(engineRoot, marker.projectId);
|
|
136
|
-
transferMemoryAnnouncements(oldCtl, newCtl);
|
|
136
|
+
await transferMemoryAnnouncements(fileGovernanceStore(oldCtl), fileGovernanceStore(newCtl));
|
|
137
137
|
}
|
|
138
138
|
catch (err) {
|
|
139
139
|
deps.onError?.(asThrownError(err), { phase: "config", sessionId });
|
|
@@ -376,12 +376,12 @@ export async function prepareMemory(input) {
|
|
|
376
376
|
sessionId,
|
|
377
377
|
...(m.write === null && shadowNames !== undefined && shadowNames.size > 0 ? { shadowNames } : {}),
|
|
378
378
|
});
|
|
379
|
-
openedLegs.push(() =>
|
|
379
|
+
openedLegs.push(() => m.engine.endSessionLeg(handle, sessionId));
|
|
380
380
|
mounted.push(handle);
|
|
381
381
|
materializedResidue.push(...planeScopes(m.scopes, m.write));
|
|
382
382
|
if (m.write !== null) {
|
|
383
383
|
try {
|
|
384
|
-
const withheld = new Set(m.engine.readChallengeExclusions().keys());
|
|
384
|
+
const withheld = new Set((await m.engine.readChallengeExclusions()).keys());
|
|
385
385
|
const committed = await m.engine.listCommittedHeaders([m.write]);
|
|
386
386
|
const superseded = deriveSupersededSet(committed, { excluded: (id) => withheld.has(id) });
|
|
387
387
|
shadowNames = shadowNamesOf(committed, m.write, { excluded: (id) => withheld.has(id) || superseded.has(id) });
|
|
@@ -398,7 +398,7 @@ export async function prepareMemory(input) {
|
|
|
398
398
|
writeHandle = writeIsPersonal ? personalHandle : projectHandle;
|
|
399
399
|
readOnlyEngine = writeIsPersonal ? projectEngine : personalEngine;
|
|
400
400
|
readOnlyHandle = writeIsPersonal ? projectHandle : personalHandle;
|
|
401
|
-
injectFn = () => mergeInjections(projectEngine.inject(projectHandle, { writeToolMounted: writeChannelOpen, reminderMark: input.reminderMark }), personalEngine.inject(personalHandle, { writeToolMounted: writeChannelOpen, reminderMark: input.reminderMark }));
|
|
401
|
+
injectFn = async () => mergeInjections(await projectEngine.inject(projectHandle, { writeToolMounted: writeChannelOpen, reminderMark: input.reminderMark }), await personalEngine.inject(personalHandle, { writeToolMounted: writeChannelOpen, reminderMark: input.reminderMark }));
|
|
402
402
|
toolPlanes = [
|
|
403
403
|
{
|
|
404
404
|
backend: retrievalBackend(backend, adoptionRestricted || captureOptedOut || captureIndeterminate || p.writePlane !== "project"),
|
|
@@ -440,7 +440,7 @@ export async function prepareMemory(input) {
|
|
|
440
440
|
const personalEngine = personal.engine;
|
|
441
441
|
await armCaptureOptOut(personalEngine);
|
|
442
442
|
const handle = await personalEngine.materialize(memorySpec.scopes, memorySpec.writeScope, { adoptionRestricted: adoptionRestricted || captureOptedOut || captureIndeterminate, sessionId });
|
|
443
|
-
openedLegs.push(() =>
|
|
443
|
+
openedLegs.push(() => personalEngine.endSessionLeg(handle, sessionId));
|
|
444
444
|
materializedResidue.push(...planeScopes(memorySpec.scopes, memorySpec.writeScope));
|
|
445
445
|
memoryMarkedEntriesServed = handle.markedEntriesPresent === true;
|
|
446
446
|
writeEngine = personalEngine;
|
|
@@ -470,7 +470,7 @@ export async function prepareMemory(input) {
|
|
|
470
470
|
});
|
|
471
471
|
await armCaptureOptOut(engine);
|
|
472
472
|
const handle = await engine.materialize(memorySpec.scopes, memorySpec.writeScope, { adoptionRestricted: adoptionRestricted || captureOptedOut || captureIndeterminate, sessionId });
|
|
473
|
-
openedLegs.push(() =>
|
|
473
|
+
openedLegs.push(() => engine.endSessionLeg(handle, sessionId));
|
|
474
474
|
materializedResidue.push(...planeScopes(memorySpec.scopes, memorySpec.writeScope));
|
|
475
475
|
memoryMarkedEntriesServed = handle.markedEntriesPresent === true;
|
|
476
476
|
writeEngine = engine;
|
|
@@ -557,6 +557,12 @@ export async function prepareMemory(input) {
|
|
|
557
557
|
}
|
|
558
558
|
deliverEngineNotice(deps.onNotice, memoryHarvestQuarantinedNotice({ count, moved, escalated, ...(report.reportId !== undefined ? { reportId: report.reportId } : {}), ...(reason !== undefined ? { reason } : {}), sessionId, provenance: input.memoryProvenance, ...(indexOnly ? { indexRolledBack: true } : {}) }));
|
|
559
559
|
}
|
|
560
|
+
const refused = memoryHarvestRefusedNotice(report, sessionId);
|
|
561
|
+
if (refused !== undefined)
|
|
562
|
+
deliverEngineNotice(deps.onNotice, refused);
|
|
563
|
+
const conflicted = memoryHarvestConflictNotice(report, sessionId);
|
|
564
|
+
if (conflicted !== undefined)
|
|
565
|
+
deliverEngineNotice(deps.onNotice, conflicted);
|
|
560
566
|
if (report.restoreWithheld !== undefined && report.restoreWithheld.length > 0) {
|
|
561
567
|
deliverEngineNotice(deps.onNotice, memoryRestoreWithheldNotice({ paths: report.restoreWithheld, sessionId }));
|
|
562
568
|
}
|
|
@@ -607,11 +613,12 @@ export async function prepareMemory(input) {
|
|
|
607
613
|
memoryEngineSession = {
|
|
608
614
|
engine: writeEngine,
|
|
609
615
|
handle: writeHandle,
|
|
616
|
+
scopeContract: memorySpec.scopeContract,
|
|
610
617
|
inject: injectFn,
|
|
611
618
|
harvest: harvestSafe,
|
|
612
|
-
release: () => {
|
|
619
|
+
release: async () => {
|
|
613
620
|
for (const end of openedLegs)
|
|
614
|
-
end();
|
|
621
|
+
await end();
|
|
615
622
|
},
|
|
616
623
|
captureOptOut: {
|
|
617
624
|
optedOut: () => {
|
|
@@ -677,11 +684,12 @@ export async function prepareMemory(input) {
|
|
|
677
684
|
pollution: {
|
|
678
685
|
polluted: () => writeEngine.sessionPollution(sessionId),
|
|
679
686
|
markPolluted: (reason, cause) => {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
687
|
+
void writeEngine.markSessionPolluted(sessionId, reason, cause).then((outcome) => {
|
|
688
|
+
if (outcome === "existed" || (outcome === "unpersisted" && pollutionAnnounced))
|
|
689
|
+
return;
|
|
690
|
+
pollutionAnnounced = true;
|
|
691
|
+
deliverEngineNotice(deps.onNotice, memorySessionPollutedNotice({ reason, sessionId, provenance: input.memoryProvenance }));
|
|
692
|
+
});
|
|
685
693
|
},
|
|
686
694
|
},
|
|
687
695
|
contentSafety: {
|
|
@@ -689,7 +697,7 @@ export async function prepareMemory(input) {
|
|
|
689
697
|
execIsExternalContent: memorySpec.execIsExternalContent === true,
|
|
690
698
|
},
|
|
691
699
|
...(input.memoryProvenance !== "off"
|
|
692
|
-
? { settlement: { controlDir: writeEngine.controlPlaneDir, sessionId, provenance: "carry" } }
|
|
700
|
+
? { settlement: { governance: writeEngine.governance, controlDir: writeEngine.controlPlaneDir, sessionId, provenance: "carry" } }
|
|
693
701
|
: {}),
|
|
694
702
|
...(input.memoryProvenance !== "off"
|
|
695
703
|
? {
|
|
@@ -733,7 +741,7 @@ export async function prepareMemory(input) {
|
|
|
733
741
|
catch (err) {
|
|
734
742
|
if (memoryEngineSession === undefined)
|
|
735
743
|
for (const end of openedLegs)
|
|
736
|
-
end();
|
|
744
|
+
await end();
|
|
737
745
|
if (typeof err.code === "string" &&
|
|
738
746
|
(err.code.startsWith("config.memory_scope") ||
|
|
739
747
|
err.code.startsWith("config.memory_project") ||
|
|
@@ -760,12 +768,12 @@ export async function prepareMemory(input) {
|
|
|
760
768
|
const detail = "TaskSpec.memory is enabled but RunnerDeps.memoryBackend is not configured; memory is inactive for this task (the legacy memoryStore fallback was retired in design/138 S4 and the dep was removed in design/157 B19).";
|
|
761
769
|
deps.onError?.(new Error(detail), { phase: "config", sessionId });
|
|
762
770
|
}
|
|
763
|
-
const composeInjection = (facts) => {
|
|
771
|
+
const composeInjection = async (facts) => {
|
|
764
772
|
let memoryBlock;
|
|
765
773
|
let seedFiles;
|
|
766
774
|
let recallDisciplineSegment;
|
|
767
775
|
if (memoryEngineSession) {
|
|
768
|
-
const injection = memoryEngineSession.inject();
|
|
776
|
+
const injection = await memoryEngineSession.inject();
|
|
769
777
|
let blockBody = injection.block;
|
|
770
778
|
if (captureOptedOut) {
|
|
771
779
|
blockBody = [MEMORY_CAPTURE_OPTOUT_NOTICE, injection.index, injection.announceBlock].filter((s) => Boolean(s && s.trim())).join("\n\n");
|
|
@@ -57,6 +57,7 @@ export function prepareParkAsk(input) {
|
|
|
57
57
|
return refuseBeforeDelivery("question.malformed_request");
|
|
58
58
|
}
|
|
59
59
|
const retainedQuestionsHash = boundInputHashOf(retained.questions);
|
|
60
|
+
const retainedCallHash = exactBoundInputHashOf(req.toolName, retained);
|
|
60
61
|
if (!Value.Check(mountedQuestionTool.parameters, retained) || validateAskQuestions(presented) !== undefined) {
|
|
61
62
|
return refuseBeforeDelivery("question.malformed_request");
|
|
62
63
|
}
|
|
@@ -71,7 +72,7 @@ export function prepareParkAsk(input) {
|
|
|
71
72
|
toolCallId: req.toolCallId,
|
|
72
73
|
questions: presented,
|
|
73
74
|
...questionSourceOf(askSource),
|
|
74
|
-
boundInputHash:
|
|
75
|
+
...(retainedCallHash !== undefined ? { boundInputHash: retainedCallHash } : {}),
|
|
75
76
|
deliveryId,
|
|
76
77
|
}, contentAskSignal))();
|
|
77
78
|
const settlement = await raceAbort(facePromise.then((outcome) => ({ tag: "outcome", outcome }), (error) => ({ tag: "threw", error })), contentAskSignal, () => ({ tag: "aborted" }));
|
|
@@ -149,7 +150,7 @@ export function prepareParkAsk(input) {
|
|
|
149
150
|
const bindable = bindableArgsOf(req.toolName, parkedArgs);
|
|
150
151
|
if (!bindable.ok)
|
|
151
152
|
throw new ParkRefusal(bindable.refusal);
|
|
152
|
-
const parkedHash = exactBoundInputHashOf(parkedArgs);
|
|
153
|
+
const parkedHash = exactBoundInputHashOf(req.toolName, parkedArgs);
|
|
153
154
|
if (parkedHash === undefined)
|
|
154
155
|
throw new ParkRefusal(`the canonical form of the arguments of "${req.toolName}" cannot be built — no approval row can be bound to them`);
|
|
155
156
|
const projectionMovedArgs = backendFidelity !== "structured-clone" && !samePlainValue(parked.value, parkedArgs);
|
|
@@ -306,7 +307,7 @@ export function prepareParkAsk(input) {
|
|
|
306
307
|
toolCallId: req.toolCallId,
|
|
307
308
|
toolName: req.toolName,
|
|
308
309
|
...parkedToolIdentity(toolRosterDeltas.current, req.toolName), ...parkedToolFace(toolRosterDeltas.current, req),
|
|
309
|
-
...(licenseCovers(parkedHash, req.args) ? approvalTargetsOf(callTargetReadingOf(req), shellReadLandings?.(req.toolCallId)) : {}),
|
|
310
|
+
...(licenseCovers(parkedHash, req.toolName, req.args) ? approvalTargetsOf(callTargetReadingOf(req), shellReadLandings?.(req.toolCallId)) : {}),
|
|
310
311
|
args: parkedArgs,
|
|
311
312
|
...(() => {
|
|
312
313
|
const p = approvalPreviewOf(req.toolName, parkedArgs);
|
|
@@ -88,7 +88,7 @@ import { createRollbackStack } from "./rollback-stack.js";
|
|
|
88
88
|
export { __resetMaterializeEnvAnnouncements } from "./prepare-tool-disclosure-mount.js";
|
|
89
89
|
export { fileHistoryFilesystemIdentity, resolveFileHistoryScope } from "./prepare-file-history.js";
|
|
90
90
|
import { resolveTriggerWindow, } from "../context-edit.js";
|
|
91
|
-
import { declaredHostLocalPaths,
|
|
91
|
+
import { declaredHostLocalPaths, isDeclaredSandboxOffHost, pathsAreHostLocal, targetIsExternal } from "../remote-env.js";
|
|
92
92
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
93
93
|
import { defaultTaskRegistry } from "../task-registry.js";
|
|
94
94
|
import { announcePeerLaneMount, judgeSessionBoxDrain } from "../../agents/peer-session-drain.js";
|
|
@@ -118,6 +118,7 @@ import { AdvertisedWritableDirs, checkedPlanFileShape, planFileInvalid, planFile
|
|
|
118
118
|
import { resolveTaskRootCanonical } from "./task-root-canonical.js";
|
|
119
119
|
import { projectMarkerFsOf, resolveSessionProject } from "../memory-engine/scope-contract.js";
|
|
120
120
|
import { createWorkspaceFrameSeat } from "../workspace-snapshot.js";
|
|
121
|
+
import { openSessionCheckout, sessionFrameOf } from "../session-checkout.js";
|
|
121
122
|
import { createStructuredProjector } from "./tool-output-projection.js";
|
|
122
123
|
import { imageUnprocessedSeat, toolResultMediaRefusedSeat } from "./tool-result-media-seat.js";
|
|
123
124
|
import { asThrownError, thrownText } from "../thrown-value.js";
|
|
@@ -440,11 +441,10 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
440
441
|
failIsolation("the executionEnvFactory returned the shared static env instead of a worktree-rooted env");
|
|
441
442
|
}
|
|
442
443
|
else if (!pathsAreHostLocal(ownedEnvSeat.current)) {
|
|
443
|
-
if (
|
|
444
|
-
failIsolation(
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
failIsolation("the executionEnvFactory returned an env whose paths are not the host's (capabilities.hostLocalPaths), without capabilities.isolation — a target that is no declared sandbox is a shared checkout, not a per-agent worktree, and its paths cannot be compared from here");
|
|
444
|
+
if (!isDeclaredSandboxOffHost(ownedEnvSeat.current)) {
|
|
445
|
+
failIsolation(declaredHostLocalPaths(ownedEnvSeat.current) !== false
|
|
446
|
+
? "the executionEnvFactory returned an env that does not declare where its paths land (capabilities.hostLocalPaths) — its tree can be neither compared from here nor exempted as a sandbox"
|
|
447
|
+
: "the executionEnvFactory returned an env whose paths are not the host's (capabilities.hostLocalPaths), without capabilities.isolation — a target that is no declared sandbox is a shared checkout, not a per-agent worktree, and its paths cannot be compared from here");
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
else {
|
|
@@ -468,8 +468,12 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
const ownedEnv = ownedEnvSeat.current;
|
|
471
|
-
const { taskRootFinal, rebaseRestoredPath, remote: workspaceRemote, ownTarget } = await prepareWorkspaceRestore({ ownedEnv, deps, spec, internals, resume, taskRootInitial, placement, placementFence, abortController, sessionId });
|
|
471
|
+
const { taskRootFinal: taskRootRestored, rebaseRestoredPath, remote: workspaceRemote, ownTarget } = await prepareWorkspaceRestore({ ownedEnv, deps, spec, internals, resume, taskRootInitial, placement, placementFence, abortController, sessionId });
|
|
472
|
+
const sessionCheckout = await openSessionCheckout({ env: executionEnv, session, sessionId, declaration: spec.workspace, baseRoot: taskRootRestored, additionalDirectories: spec.additionalDirectories });
|
|
473
|
+
const taskRootFinal = sessionCheckout.taskRoot;
|
|
472
474
|
const { canonical: taskRootCanonical } = await resolveTaskRootCanonical({ env: executionEnv, given: taskRootFinal, onNotice: deps.onNotice, sessionId, runId });
|
|
475
|
+
const { seat: worktreeSeat, writeLocation, checkout } = writeLocationOf({ spelled: taskRootFinal, canonical: taskRootCanonical });
|
|
476
|
+
const delegationCwd = () => { const at = writeLocation(); return at === taskRootCanonical ? taskRootFinal : at; };
|
|
473
477
|
const legHome = validatePath(executionEnv.homeDir, { intent: "validate-coordinate" });
|
|
474
478
|
const legAnchors = { root: taskRootCanonical, ...(legHome !== undefined ? { home: legHome } : {}) };
|
|
475
479
|
const chainTop = chainTopAnchors({ leg: legAnchors, live: internals?.inheritedGate?.pathRuleAnchors, seed: resume?.seed.inheritedGate?.pathRuleAnchors, placement, rebase: rebaseRestoredPath });
|
|
@@ -492,7 +496,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
492
496
|
const mcpPool = installedPreflight.mcp?.length ? { pool: internals?.mcpPool ?? new McpConnectionPool(), owned: internals?.mcpPool === undefined } : undefined;
|
|
493
497
|
const mcpHostSeats = internals?.mcpHostSeats;
|
|
494
498
|
const mountedMcpNow = mcpPool !== undefined ? () => mountedMcpOf({ declared: installedPreflight.mcp, roster: roster.tools, aggregateNames: new Set(mcp.tools.filter((t) => t.mcpRemoteName === undefined).map((t) => t.name)), pool: mcpPool.pool, ...(mcpHostSeats !== undefined ? { hostSeats: mcpHostSeats } : {}) }) : undefined;
|
|
495
|
-
const { liveInheritedGate, seedInheritedGate, inheritedAncestorRules, inheritedShellGate, inheritedParentConstraints, permissionMode, commitModeSeats, endModeCeiling, inheritedAdmittedOrgScopes, priorOwnOrgVerdict, orgGovernedProvenance, effectiveShellGate, ownSessionRulesRef, ancestorSessionRulesRef, ancestorRulesNow, memoryAdmittedOrgScopesRef, ownOrgVerdictRef, runClampSource, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, frozenOnAsk, hookEnvSource, frozenOnQuestion, parentSpecSeat, provenanceForChildrenRef, delegationSettlementRef, inheritedGateForChildren, carrierReadFace, carrierWriteFace, fullShellReachable, gateStopRef, stopForDenialLimit, enrichSpecToolCtx } = prepareInheritedGate({ spec, deps, delegationOwner, askSeat: doors.askSeat, hostFloor: doors.hostFloor, crossBoundaryTree, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, ownTarget, executionEnv, ownedEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { chainTop, onLeg: onLeg.chained }, checkpointSeat, checkpointScope, toolFaceSnapshot, mountsCallerTool, ...(mountedMcpNow !== undefined ? { mountedMcp: mountedMcpNow } : {}), promptLean, resolvedInteractionPosture, permissionModeSeat, handsEnabled, reportUsage, harnessRef, skillGrants, requestAllowedTools: allowedToolTables.request, forwardEvent, subagentRetain, taskArtifacts, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun: () => { abortController.abort(); void harness.abort(); }, runtimeCaps: () => runtimeCaps, modBus: legMods.standing, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, autoModeDenialTracking: () => autoModeDenialTrackingRef.current, autoModeArming: () => autoModeArmingRef.current, agentForkDenial: () => agentForkDenial, agentStations: () => agentStationsRef.current, sendStation: () => sendStationRef.current, observersActive: () => observersActive, resolvedReadFace: () => resolvedReadFace, resolvedWriteFace: () => resolvedWriteFace, readDenyAdditionsNormalized: () => readDenyAdditionsNormalized, handsLessResolvedFace: () => handsLessResolvedFace, handsLessResolvedWriteFace: () => handsLessResolvedWriteFace, centerAdoption: () => centerAdoptionRef.current, memoryEngineSession: () => memoryEngineSession });
|
|
499
|
+
const { liveInheritedGate, seedInheritedGate, inheritedAncestorRules, inheritedShellGate, inheritedParentConstraints, permissionMode, commitModeSeats, endModeCeiling, inheritedAdmittedOrgScopes, priorOwnOrgVerdict, orgGovernedProvenance, effectiveShellGate, ownSessionRulesRef, ancestorSessionRulesRef, ancestorRulesNow, memoryAdmittedOrgScopesRef, ownOrgVerdictRef, runClampSource, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, frozenOnAsk, hookEnvSource, frozenOnQuestion, parentSpecSeat, provenanceForChildrenRef, delegationSettlementRef, inheritedGateForChildren, carrierReadFace, carrierWriteFace, fullShellReachable, gateStopRef, stopForDenialLimit, enrichSpecToolCtx } = prepareInheritedGate({ spec, deps, delegationOwner, askSeat: doors.askSeat, hostFloor: doors.hostFloor, crossBoundaryTree, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, delegationCwd, ownTarget, executionEnv, ownedEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { chainTop, onLeg: onLeg.chained }, checkpointSeat, checkpointScope, toolFaceSnapshot, mountsCallerTool, ...(mountedMcpNow !== undefined ? { mountedMcp: mountedMcpNow } : {}), promptLean, resolvedInteractionPosture, permissionModeSeat, handsEnabled, reportUsage, harnessRef, skillGrants, requestAllowedTools: allowedToolTables.request, forwardEvent, subagentRetain, taskArtifacts, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun: () => { abortController.abort(); void harness.abort(); }, runtimeCaps: () => runtimeCaps, modBus: legMods.standing, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, autoModeDenialTracking: () => autoModeDenialTrackingRef.current, autoModeArming: () => autoModeArmingRef.current, agentForkDenial: () => agentForkDenial, agentStations: () => agentStationsRef.current, sendStation: () => sendStationRef.current, observersActive: () => observersActive, resolvedReadFace: () => resolvedReadFace, resolvedWriteFace: () => resolvedWriteFace, readDenyAdditionsNormalized: () => readDenyAdditionsNormalized, handsLessResolvedFace: () => handsLessResolvedFace, handsLessResolvedWriteFace: () => handsLessResolvedWriteFace, centerAdoption: () => centerAdoptionRef.current, memoryEngineSession: () => memoryEngineSession });
|
|
496
500
|
bindPermissionModeSeat(permissionMode);
|
|
497
501
|
const personRowNotices = { onUnread: ruleStoreUnreadableNotice(deps.onNotice, { sessionId, runId }), onRowsDropped: ruleRowsDroppedNotice(deps.onNotice, { sessionId, runId }) };
|
|
498
502
|
const readerOf = (signals) => personPathRowsOfTask({ deps, notices: personRowNotices, principal: spec.principal, ids: { sessionId, runId, taskId: hostTaskId }, root: taskRootFinal, rootCanonical: taskRootCanonical, leads: headLeads, chainTop, occurrences: toolOccurrences, signals });
|
|
@@ -508,10 +512,9 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
508
512
|
const effectivePathDenyRules = policyDenyRows.filter((r) => r.unanchored === undefined);
|
|
509
513
|
const writeTargetJudgeRef = {};
|
|
510
514
|
const legExemptRoots = Object.freeze(dataRootSpellings(deps.memoryEngineDir));
|
|
511
|
-
const { seat: worktreeSeat, writeLocation, checkout } = writeLocationOf({ spelled: taskRootFinal, canonical: taskRootCanonical });
|
|
512
515
|
const legWriteGuard = { exemptRoots: legExemptRoots, rows: toolPolicyWriteGuardRows([installedToolPolicy, ...(inheritedParentConstraints ?? []).map((c) => c.policy)]), checkout };
|
|
513
516
|
const sideCallBookRef = {};
|
|
514
|
-
const { roster, blockedRef, runtimeCaps, runtimeCapsFaulted, complianceDenies, complianceDegraded, agentForkDenial, observersActive, autoModeArmReason, autoModeDeciderRef, autoModeDenialTrackingRef, autoModeArmingRef, armAutoMode, selfOrchestrationActive, workflowToolsActive, workflowSizeGuideline } = await prepareCapsAndWorkflow({ spec, deps, delegationOwner, askSeat: doors.askSeat, internals, crossBoundaryTree, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, ownTarget, model, thinking, lockedPreflight, checkpointSeat, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, parentSpecSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, taskArtifacts, requestReview, ...(spec.planFile !== undefined ? { planFileSource: { path: spec.planFile, shown: planFileShown(spec.planFile), read: (signal) => advertisedWritableDirs?.readPlanFile(signal) ?? Promise.resolve({ ok: false, reason: "this run admitted no plan file" }) } } : {}), enterPlanMode, permissionMode, readDenyEntries: () => personRows.tablesReady().then(() => ({ entries: readDenyMatcher?.entries ?? [], ruleRows: pathTables?.ruleRows() ?? effectivePathDenyRules })), peerLaneActive, peerSendMessageBuiltIn, runnerSelf, memoryEngineSession: () => memoryEngineSession, centerAdoption: () => centerAdoptionRef.current, agentStations: () => agentStationsRef.current, delegated: delegation.isDelegatedChild, sideCallBookRef });
|
|
517
|
+
const { roster, blockedRef, runtimeCaps, runtimeCapsFaulted, complianceDenies, complianceDegraded, agentForkDenial, observersActive, autoModeArmReason, autoModeDeciderRef, autoModeDenialTrackingRef, autoModeArmingRef, armAutoMode, selfOrchestrationActive, workflowToolsActive, workflowSizeGuideline } = await prepareCapsAndWorkflow({ spec, deps, delegationOwner, askSeat: doors.askSeat, internals, crossBoundaryTree, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, delegationCwd, ownTarget, model, thinking, lockedPreflight, checkpointSeat, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, parentSpecSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, taskArtifacts, requestReview, ...(spec.planFile !== undefined ? { planFileSource: { path: spec.planFile, shown: planFileShown(spec.planFile), read: (signal) => advertisedWritableDirs?.readPlanFile(signal) ?? Promise.resolve({ ok: false, reason: "this run admitted no plan file" }) } } : {}), enterPlanMode, permissionMode, readDenyEntries: () => personRows.tablesReady().then(() => ({ entries: readDenyMatcher?.entries ?? [], ruleRows: pathTables?.ruleRows() ?? effectivePathDenyRules })), peerLaneActive, peerSendMessageBuiltIn, runnerSelf, memoryEngineSession: () => memoryEngineSession, centerAdoption: () => centerAdoptionRef.current, agentStations: () => agentStationsRef.current, delegated: delegation.isDelegatedChild, sideCallBookRef });
|
|
515
518
|
const tools = roster.tools;
|
|
516
519
|
const crossBoundary = await prepareCrossBoundaryLane({ token: crossBoundaryTree, posture: doors.crossBoundaryPosture, externalContentTargetActive, env: executionEnv, session, resumeLeg: resume !== undefined, sessionId, runId, hostTaskId, deps });
|
|
517
520
|
const sessionProject = await resolveSessionProject(projectMarkerFsOf(executionEnv), taskRootCanonical, spec.projectId);
|
|
@@ -707,7 +710,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
707
710
|
}
|
|
708
711
|
}
|
|
709
712
|
const rosterCanPersist = rosterCanPersistMemory(tools.filter(valveLeaves(spec, toolFaceSnapshot.selector)), { effects: toolEffects, handsOffHost: handsEnabled && !pathsAreHostLocal(executionEnv) }, spec.memoryPersistenceCapable);
|
|
710
|
-
const { memoryBlock: memoryBlockFromEngine, recallDisciplineSegment: memoryRecallSegment, seedFiles: memorySeedFiles } = composeMemoryInjection({ rosterCanPersist, isSubagent: delegation.isNonForkChild });
|
|
713
|
+
const { memoryBlock: memoryBlockFromEngine, recallDisciplineSegment: memoryRecallSegment, seedFiles: memorySeedFiles } = await composeMemoryInjection({ rosterCanPersist, isSubagent: delegation.isNonForkChild });
|
|
711
714
|
if (memorySeedFiles?.length && seedContextFiles) {
|
|
712
715
|
try {
|
|
713
716
|
await seedContextFiles(memorySeedFiles);
|
|
@@ -873,7 +876,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
873
876
|
const preparedHolder = {};
|
|
874
877
|
const { cacheBreakDetector, cacheFingerprint, promptOverheadTokens, compactionRestore, normalizeAttachmentPath, isDedupStubResult, recentlyReadFiles, onCompactionApplied, detectExternalChanges, syntheticReadVerdict, consolidationWriteJudge, listBackgroundTasks, taskReadHandleOf, centerCompactionCandidate, effectiveReadFaceObserved, effectiveWriteFaceObserved, effectiveReadDenyObserved } = prepareTurnWiring({ deps, systemPromptSeat, harnessTools, fpRef, model, promptIdentityDigest: promptManifest.identity.artifact, systemBlocks, thinking, spec, sessionId, turnSnapshotRef, promptManifest, charsPerToken, handsEnabled, executionEnv, attachmentRootCanonical, readRoots, modelFileReader: modelFileReaderSeat.current, reminderMark, reminderDisclosureCounts, resolvedReadFace, handsCwdRef, readFileStateForCheckpoint, denyNarrowingPolicy, skillGrants: skillGrantLane, callerPolicy: installedToolPolicy, inheritedPolicies: (inheritedParentConstraints ?? []).flatMap((c) => (c.policy !== undefined ? [c.policy] : [])), persistedRuleLane: permissionRuleLane, ruleLaneFacts, personRowsBeyondRun, orgRuleLane: permissionRuleOrgLane, stampCallTarget, abortController, hostTaskId, taskScope, buildAssembleInputs, identityFor, adoptsCandidates, centerAdoptionRef, harnessRef, carrierReadFace, carrierWriteFace, readDenyAdditionsNormalized, preparedHolder });
|
|
875
878
|
await onceLedger.settle(session, announcedListingsRef);
|
|
876
|
-
const buildPrepared = () => ({ harness, session, sessionId, taskId: hostTaskId, runId, crossBoundary, ...(doors.hostFloor !== undefined ? { hostFloor: doors.hostFloor } : {}), registryAccess: { owner: hostTaskId, scope: taskScope }, reminderMark, reminderDisclosureCounts, fullShellReachable, approvalPosture: { get mode() { return permissionMode.current; }, askEffective: askSeatEffective(wiringManifest) }, ...(outputStyleFrame !== undefined ? { outputStyleFrame } : {}), permissionMode, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, compModel: effectiveCompModel, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, conflictRef, blockedToolCalls, toolOccurrences, batchHaltRef, nestedStats, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), effectiveMemoryScopes: memoryEffectiveScopes, ...(placementValueOrAbsent(placementRootResolved) !== undefined ? { placementRoot: placementRootResolved } : {}), cwdRef: handsCwdRef, ...(attachmentRootCanonical !== undefined ? { handsRoot: attachmentRootCanonical } : {}), ...(stampCallTarget !== undefined ? { stampCallTarget } : {}), toolProgressRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), exemptRoots: legExemptRoots, ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), workspaceFrame: createWorkspaceFrameSeat({ root: taskRootCanonical, ...(handsCwdRef !== undefined ? { cwdRef: handsCwdRef } : {}), ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...(sessionProject.project !== undefined ? { project: sessionProject.project } : {}), remote: workspaceRemote }), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, skillGrants: skillGrantLane, skillSpecs, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), consolidationWriteJudge, ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, endModeCeiling, settleContentAskBindings, cacheBreakDetector, cacheFingerprint, wiringManifest, promptManifest, promptIdentity, activeTools, ...(deferred.size > 0 ? { deferredToolNames: deferred } : {}), toolMaterializeStatic, deferDirectCall, ...(staticFaceForRef.current !== undefined ? { staticFaceFor: staticFaceForRef.current } : {}), ownedEnv, pausedRef, undeliveredContinuationRef, suspendProgressRef, remoteEnvFailures, reviewRequestRef, suspendLoopRef, suspendForResource, ...(suspendForPlatformLimit !== undefined ? { suspendForPlatformLimit } : {}), ...(envLifetimeSuspendAt !== undefined ? { envLifetimeSuspendAt } : {}), ...(usageGovernance !== undefined ? { usageGovernance } : {}), callIssuedAtRef, workCutRef, loopTerminalRef, brainCallGuardrailRef, gateStopRef, stopForDenialLimit, suspendForReview, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}), resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolRoster, toolRosterDeltas: rosterSeat, structuredProjector, toolEffects, wakeRecovered, promptOverheadTokens, lastBrainContext, lastSentRequest: () => lastBrainContextRef.current, ...(advisor.instruction !== undefined ? { advisorInstruction: advisor.instruction } : {}), ...(compactionRestore !== undefined ? { compactionRestore } : {}), recentlyReadFiles, normalizeAttachmentPath, isDedupStubResult, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit && withheldDiagnosticsOf ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent, withheldOf: withheldDiagnosticsOf } } : {}), stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(instructionSources ? { instructionSources } : {}), ...(projectInstructionContent !== undefined ? { projectInstructionContent } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(mcpUnavailable ? { mcpUnavailable } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts, frameSettlement, ...(userAttachmentsSeat !== undefined ? { userAttachments: userAttachmentsSeat } : {}), attachmentDelivery: createAttachmentDelivery(), imageUnprocessed, ...(modelFileReaderSeat.current !== undefined ? { modelFileReader: modelFileReaderSeat.current } : {}), syntheticReadVerdict, ...(peerLaneRefs.boundaryRound !== undefined ? { peerBoundaryRound: peerLaneRefs.boundaryRound } : {}), gitStatusRef, postureFrameRef, listBackgroundTasks, taskReadHandleOf, hookIdentity, modBus: legMods.bus, admitRows: rowSeat.admitRows, receiveSeat, turnOpenRedelivery: {}, compactStation, sessionMeasure, sideCallBookRef, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(shellReadLandings !== undefined ? { shellReadLandings } : {}), ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}), ...(approvedCallScreen !== undefined ? { approvedCallScreen } : {}), ...(toolCallStationRef.current !== undefined ? { toolCallStation: toolCallStationRef.current } : {}) });
|
|
879
|
+
const buildPrepared = () => ({ harness, session, sessionId, taskId: hostTaskId, runId, crossBoundary, ...(doors.hostFloor !== undefined ? { hostFloor: doors.hostFloor } : {}), registryAccess: { owner: hostTaskId, scope: taskScope }, reminderMark, reminderDisclosureCounts, fullShellReachable, approvalPosture: { get mode() { return permissionMode.current; }, askEffective: askSeatEffective(wiringManifest) }, ...(outputStyleFrame !== undefined ? { outputStyleFrame } : {}), permissionMode, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, compModel: effectiveCompModel, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, conflictRef, blockedToolCalls, toolOccurrences, batchHaltRef, nestedStats, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), effectiveMemoryScopes: memoryEffectiveScopes, ...(placementValueOrAbsent(placementRootResolved) !== undefined ? { placementRoot: placementRootResolved } : {}), cwdRef: handsCwdRef, ...(attachmentRootCanonical !== undefined ? { handsRoot: attachmentRootCanonical } : {}), ...(stampCallTarget !== undefined ? { stampCallTarget } : {}), toolProgressRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), exemptRoots: legExemptRoots, ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), workspaceFrame: createWorkspaceFrameSeat({ root: taskRootCanonical, ...(handsCwdRef !== undefined ? { cwdRef: handsCwdRef } : {}), ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...(() => { const s = sessionFrameOf(sessionCheckout.record); return s !== undefined ? { session: s } : {}; })(), ...(sessionProject.project !== undefined ? { project: sessionProject.project } : {}), remote: workspaceRemote }), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, skillGrants: skillGrantLane, skillSpecs, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), consolidationWriteJudge, ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, endModeCeiling, settleContentAskBindings, cacheBreakDetector, cacheFingerprint, wiringManifest, promptManifest, promptIdentity, activeTools, ...(deferred.size > 0 ? { deferredToolNames: deferred } : {}), toolMaterializeStatic, deferDirectCall, ...(staticFaceForRef.current !== undefined ? { staticFaceFor: staticFaceForRef.current } : {}), ownedEnv, pausedRef, undeliveredContinuationRef, suspendProgressRef, remoteEnvFailures, reviewRequestRef, suspendLoopRef, suspendForResource, ...(suspendForPlatformLimit !== undefined ? { suspendForPlatformLimit } : {}), ...(envLifetimeSuspendAt !== undefined ? { envLifetimeSuspendAt } : {}), ...(usageGovernance !== undefined ? { usageGovernance } : {}), callIssuedAtRef, workCutRef, loopTerminalRef, brainCallGuardrailRef, gateStopRef, stopForDenialLimit, suspendForReview, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}), resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolRoster, toolRosterDeltas: rosterSeat, structuredProjector, toolEffects, wakeRecovered, promptOverheadTokens, lastBrainContext, lastSentRequest: () => lastBrainContextRef.current, ...(advisor.instruction !== undefined ? { advisorInstruction: advisor.instruction } : {}), ...(compactionRestore !== undefined ? { compactionRestore } : {}), recentlyReadFiles, normalizeAttachmentPath, isDedupStubResult, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit && withheldDiagnosticsOf ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent, withheldOf: withheldDiagnosticsOf } } : {}), stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(instructionSources ? { instructionSources } : {}), ...(projectInstructionContent !== undefined ? { projectInstructionContent } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(mcpUnavailable ? { mcpUnavailable } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts, frameSettlement, ...(userAttachmentsSeat !== undefined ? { userAttachments: userAttachmentsSeat } : {}), attachmentDelivery: createAttachmentDelivery(), imageUnprocessed, ...(modelFileReaderSeat.current !== undefined ? { modelFileReader: modelFileReaderSeat.current } : {}), syntheticReadVerdict, ...(peerLaneRefs.boundaryRound !== undefined ? { peerBoundaryRound: peerLaneRefs.boundaryRound } : {}), gitStatusRef, postureFrameRef, listBackgroundTasks, taskReadHandleOf, hookIdentity, modBus: legMods.bus, admitRows: rowSeat.admitRows, receiveSeat, turnOpenRedelivery: {}, compactStation, sessionMeasure, sideCallBookRef, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(shellReadLandings !== undefined ? { shellReadLandings } : {}), ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}), ...(approvedCallScreen !== undefined ? { approvedCallScreen } : {}), ...(toolCallStationRef.current !== undefined ? { toolCallStation: toolCallStationRef.current } : {}) });
|
|
877
880
|
refuseLateRosterChanges(callerRoster.roster);
|
|
878
881
|
rollback.commit();
|
|
879
882
|
commitModeSeats(abortController.signal);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { declaredSuspend, frozenHandleCopy, isRemoteExecutionEnv, missingRestoreSurface, pathsAreHostLocal, placementHonored, placementTargetOf } from "../remote-env.js";
|
|
2
|
-
import { settleOwnTarget } from "./placement-fence.js";
|
|
2
|
+
import { deviceMoveRefusal, settleOwnTarget } from "./placement-fence.js";
|
|
3
3
|
import { remoteEnvFailureNote, restoreWorkspaceWithRetry } from "./remote-env-retry.js";
|
|
4
4
|
import { rebaseWorkspacePathAcross } from "./workspace-path.js";
|
|
5
5
|
export { remoteEnvFailureNote, restoreWorkspaceWithRetry } from "./remote-env-retry.js";
|
|
@@ -22,11 +22,8 @@ export async function prepareWorkspaceRestore(input) {
|
|
|
22
22
|
failResume(`resume workspace identity mismatch: the checkpoint records provider "${handle.provider}" but the resumed env reports "${resumedHandle.provider}" — refusing to continue a workspace on a different backend (wire the factory to rebuild the checkpointed lane and re-resume)`);
|
|
23
23
|
}
|
|
24
24
|
const reported = placementTargetOf(resumedHandle);
|
|
25
|
-
if (!placementHonored(input.placementFence, reported))
|
|
26
|
-
|
|
27
|
-
? `resume workspace identity mismatch: the placement fence names deviceId "${input.placementFence?.deviceId}" but the resumed env reports none — a device-bound workspace cannot be verified on a handle that does not state its device (absence is not a match)`
|
|
28
|
-
: `resume workspace identity mismatch: the placement fence names deviceId "${input.placementFence?.deviceId}" but the resumed env reports "${reported.deviceId}" — refusing to continue on a different physical device`);
|
|
29
|
-
}
|
|
25
|
+
if (!placementHonored(input.placementFence, reported))
|
|
26
|
+
throw deviceMoveRefusal("resume.env_failed", input.placementFence?.deviceId, reported?.deviceId);
|
|
30
27
|
};
|
|
31
28
|
if (ownedEnv === undefined || !isRemoteExecutionEnv(ownedEnv)) {
|
|
32
29
|
failResume("resume needs a RemoteExecutionEnv from executionEnvFactory to restore the workspace snapshot");
|
|
@@ -696,7 +696,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
696
696
|
return;
|
|
697
697
|
}
|
|
698
698
|
const executedArgs = resolvedArgs;
|
|
699
|
-
const unseen = !licenseCovers(pendingAction.boundInputHash, executedArgs);
|
|
699
|
+
const unseen = !licenseCovers(pendingAction.boundInputHash, pendingAction.toolName, executedArgs);
|
|
700
700
|
let beltReading;
|
|
701
701
|
const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}), ...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, prepared.skillSpecs, SKILL_TOOL_NAME), pendingAction, executedArgs) });
|
|
702
702
|
const unjudgeable = unseen ? chainCannotJudge(resume.cp.state.inheritedGate) : undefined;
|