@sema-agent/core 7.61.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 +840 -0
- package/dist/agents/cascade.d.ts +11 -3
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/peer-held-queue.d.ts +27 -4
- package/dist/agents/peer-held-queue.js +81 -36
- package/dist/agents/peer-session-drain.js +13 -3
- package/dist/agents/subagent-transcript-placement.d.ts +23 -0
- package/dist/agents/subagent-transcript-placement.js +14 -0
- package/dist/agents/subagent.d.ts +6 -1
- package/dist/agents/subagent.js +143 -58
- package/dist/agents/suspend-guard.d.ts +38 -16
- package/dist/agents/suspend-guard.js +9 -4
- package/dist/agents/verify.js +4 -3
- 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-features.d.ts +722 -0
- package/dist/core/checkpoint-features.js +98 -0
- package/dist/core/checkpoint-queries.d.ts +47 -4
- package/dist/core/checkpoint-queries.js +36 -16
- package/dist/core/checkpoint-requirements.d.ts +12 -5
- package/dist/core/checkpoint-requirements.js +11 -5
- package/dist/core/checkpoint-row-verdict.d.ts +110 -0
- package/dist/core/checkpoint-row-verdict.js +245 -0
- package/dist/core/checkpoint-store.d.ts +76 -753
- package/dist/core/checkpoint-store.js +83 -144
- 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 +38 -7
- package/dist/core/engine-notice.js +9 -2
- package/dist/core/gate-fold.js +2 -2
- 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 +9 -3
- package/dist/core/governance-codes.js +16 -3
- package/dist/core/hooks.d.ts +13 -0
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +1 -1
- package/dist/core/locked-config.d.ts +2 -2
- package/dist/core/mcp-host-seat.js +6 -1
- package/dist/core/memory-engine/consolidation-driver.d.ts +33 -18
- 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-vector.d.ts +1 -1
- package/dist/core/memory.d.ts +10 -10
- package/dist/core/memory.js +15 -6
- package/dist/core/mode-policy.js +1 -1
- package/dist/core/mods/classic-events.d.ts +9 -1
- package/dist/core/mods/dollar.d.ts +32 -1
- package/dist/core/mods/dollar.js +13 -1
- package/dist/core/mods/kernel/events.d.ts +11 -3
- package/dist/core/mods/kernel/events.js +13 -10
- package/dist/core/mods/lifecycle-stations.d.ts +36 -4
- package/dist/core/mods/lifecycle-stations.js +44 -9
- package/dist/core/mods/session-append.d.ts +4 -1
- package/dist/core/mods/session-append.js +7 -0
- package/dist/core/mods/session-receive.js +12 -15
- package/dist/core/mods/stations.d.ts +70 -6
- package/dist/core/mods/stations.js +144 -1
- package/dist/core/own-property-receipt.d.ts +7 -0
- package/dist/core/own-property-receipt.js +3 -0
- 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/read-root-candidate.js +1 -1
- 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/resume-startup-cause.d.ts +5 -4
- package/dist/core/runner/child-tree.d.ts +29 -3
- package/dist/core/runner/child-tree.js +39 -16
- package/dist/core/runner/compact-session.js +5 -2
- package/dist/core/runner/contracts.d.ts +36 -17
- package/dist/core/runner/delegation-owner.d.ts +43 -0
- package/dist/core/runner/delegation-owner.js +59 -0
- package/dist/core/runner/gate-exit.js +2 -2
- package/dist/core/runner/inherited-ask-grants.js +1 -1
- package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
- package/dist/core/runner/lineage-reroot-view.js +108 -0
- 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/permission-rule-lanes.d.ts +2 -1
- package/dist/core/runner/permission-rule-lanes.js +2 -2
- package/dist/core/runner/person-path-rows.d.ts +23 -3
- package/dist/core/runner/person-path-rows.js +31 -4
- package/dist/core/runner/placement-fence.d.ts +12 -0
- package/dist/core/runner/placement-fence.js +20 -6
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
- package/dist/core/runner/prepare-ask-lane.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -1
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -6
- package/dist/core/runner/prepare-config-doors.js +3 -4
- package/dist/core/runner/prepare-execution-env.js +17 -6
- package/dist/core/runner/prepare-hands-readface.d.ts +3 -2
- package/dist/core/runner/prepare-hands-readface.js +32 -10
- package/dist/core/runner/prepare-inherited-gate.d.ts +12 -8
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- 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 +22 -16
- package/dist/core/runner/prepare-workspace-restore.js +3 -6
- package/dist/core/runner/resume-admission.d.ts +3 -3
- package/dist/core/runner/resume-admission.js +6 -3
- package/dist/core/runner/resume-apply.d.ts +4 -0
- package/dist/core/runner/resume-apply.js +11 -4
- package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
- package/dist/core/runner/resume-checkpoint-screen.js +4 -84
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +4 -1
- package/dist/core/runner/run-harness-handlers.d.ts +2 -0
- package/dist/core/runner/run-harness-handlers.js +3 -2
- package/dist/core/runner/run-leg.js +25 -8
- package/dist/core/runner/run-settle-and-teardown.js +6 -4
- package/dist/core/runner/run-stop-and-final-verify.js +2 -1
- package/dist/core/runner/run-turn-boundary.js +7 -4
- package/dist/core/runner/runtask.js +6 -6
- package/dist/core/runner/steering-preview.d.ts +9 -0
- package/dist/core/runner/steering-preview.js +5 -0
- package/dist/core/runner/stream-steer-verb.js +8 -0
- package/dist/core/runner/terminal-account.js +1 -1
- package/dist/core/runner/tool-face-overlay.js +2 -0
- package/dist/core/runner/turn-attachments.d.ts +5 -0
- package/dist/core/runner/turn-attachments.js +1 -1
- package/dist/core/runner-deps.d.ts +8 -4
- package/dist/core/secret-env.d.ts +9 -6
- package/dist/core/secret-env.js +41 -22
- package/dist/core/session-checkout.d.ts +108 -0
- package/dist/core/session-checkout.js +485 -0
- package/dist/core/session-store.d.ts +13 -5
- package/dist/core/session-store.js +28 -4
- package/dist/core/session.d.ts +29 -5
- package/dist/core/session.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +6 -12
- package/dist/core/store-contracts/checkpoint-store-contract.js +73 -6
- package/dist/core/store-contracts/session-store-contract.js +61 -8
- package/dist/core/task-event.d.ts +28 -1
- package/dist/core/task-notification.d.ts +9 -1
- package/dist/core/task-notification.js +8 -1
- package/dist/core/task-registry-agent.d.ts +40 -8
- package/dist/core/task-registry-agent.js +57 -24
- package/dist/core/task-registry-shared.d.ts +33 -11
- package/dist/core/task-registry-workflow.js +4 -3
- package/dist/core/task-registry.d.ts +27 -10
- package/dist/core/task-registry.js +19 -13
- package/dist/core/task-result.d.ts +5 -5
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +21 -1
- package/dist/core/terminal-cause.d.ts +6 -6
- package/dist/core/tool-face.d.ts +6 -2
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-policy.d.ts +16 -13
- package/dist/core/tool-policy.js +11 -10
- package/dist/core/tool-roster.d.ts +4 -4
- package/dist/core/tool-spec.d.ts +42 -19
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +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/execution-env/node-execution-env.d.ts +3 -0
- package/dist/engine/execution-env/node-execution-env.js +12 -5
- package/dist/engine/harness/types.d.ts +77 -1
- package/dist/engine/harness/types.js +108 -0
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/parent-chain-guard.d.ts +3 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.d.ts +18 -3
- package/dist/engine/session/path-to-root.js +15 -1
- package/dist/engine/session/repo-utils.d.ts +12 -1
- package/dist/engine/session/repo-utils.js +41 -0
- package/dist/engine/session/session.d.ts +24 -1
- package/dist/engine/session/session.js +46 -2
- package/dist/engine/session/storage-base.d.ts +20 -0
- package/dist/engine/session/storage-base.js +28 -9
- package/dist/index.d.ts +16 -12
- package/dist/index.js +11 -8
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/orchestration/run-workflow-tool.d.ts +7 -1
- package/dist/orchestration/run-workflow-tool.js +28 -11
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow.d.ts +6 -0
- package/dist/orchestration/workflow.js +5 -8
- package/dist/stores/file/checkpoint-store.d.ts +2 -0
- package/dist/stores/file/checkpoint-store.js +7 -6
- package/dist/stores/file/fs-atomic.d.ts +0 -22
- package/dist/stores/file/fs-atomic.js +0 -17
- package/dist/stores/file/index.d.ts +2 -9
- package/dist/stores/file/index.js +2 -4
- package/dist/stores/file/session-store.d.ts +13 -7
- package/dist/stores/file/session-store.js +42 -18
- package/dist/tools/fs/bash-program-position.d.ts +3 -2
- package/dist/tools/fs/bash-program-position.js +10 -10
- 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 +5 -5
- 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 +11 -2
- package/dist/tools/fs/shell-read-argv.js +45 -29
- package/dist/tools/fs/shell-read-bindings.d.ts +20 -2
- package/dist/tools/fs/shell-read-bindings.js +153 -69
- 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 +29 -11
- package/dist/tools/fs/shell-read-establish.js +43 -22
- package/dist/tools/fs/shell-read-functions.js +2 -2
- 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-object-path.d.ts +59 -0
- package/dist/tools/fs/shell-read-object-path.js +119 -0
- package/dist/tools/fs/shell-read-plan.d.ts +18 -0
- package/dist/tools/fs/shell-read-plan.js +217 -104
- package/dist/tools/fs/shell-read-start.d.ts +76 -13
- package/dist/tools/fs/shell-read-start.js +97 -17
- 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 +54 -14
- package/dist/tools/fs/shell-read-workdir.js +103 -19
- 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 +93 -43
- package/wire-changes/core-stores-sql@7.62.0.json +30 -0
- package/wire-changes/core-stores-sql@7.63.0.json +30 -0
- package/wire-changes/core@7.62.0.json +2181 -0
- package/wire-changes/core@7.63.0.json +3523 -0
- package/wire-changes/mods-kernel@7.62.0.json +42 -0
- package/wire-changes/mods-kernel@7.63.0.json +30 -0
- package/wire-changes/primitives@7.62.0.json +30 -0
- package/wire-changes/primitives@7.63.0.json +445 -0
- package/dist/core/consolidate-scope.d.ts +0 -93
- package/dist/core/consolidate-scope.js +0 -98
- 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
- package/dist/core/runner/memory-consolidation.d.ts +0 -109
- package/dist/core/runner/memory-consolidation.js +0 -251
|
@@ -29,6 +29,10 @@ export function createPersonPathRows(cfg) {
|
|
|
29
29
|
const unit = { durable: { failedSeq: 0 }, session: { failedSeq: 0 } };
|
|
30
30
|
let seqs = 0;
|
|
31
31
|
const pins = new Map();
|
|
32
|
+
let prepared;
|
|
33
|
+
let silent;
|
|
34
|
+
let answeredSeq = 0;
|
|
35
|
+
let requestSeq = 0;
|
|
32
36
|
let compile;
|
|
33
37
|
const compiled = new Map();
|
|
34
38
|
let unitTables;
|
|
@@ -72,22 +76,40 @@ export function createPersonPathRows(cfg) {
|
|
|
72
76
|
raw = Promise.reject(err);
|
|
73
77
|
}
|
|
74
78
|
const outcomeOf = (view) => ({ seq, view: holdsPersonRows ? view : { ...view, rules: [] }, failed: holdsPersonRows ? failedOf(view) : new Set() });
|
|
79
|
+
const answer = () => void (answeredSeq = Math.max(answeredSeq, seq));
|
|
75
80
|
void raw.then((view) => {
|
|
81
|
+
answer();
|
|
76
82
|
for (const line of view.disclosures)
|
|
77
83
|
cfg.onDisclosure(line);
|
|
78
84
|
cfg.onRowsDropped(view.droppedRows);
|
|
79
85
|
if (holdsPersonRows && view.unreadable !== undefined)
|
|
80
86
|
announce(at, view.unreadable, view.unreadableSources);
|
|
81
87
|
land(outcomeOf(view));
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
const
|
|
88
|
+
}, answer);
|
|
89
|
+
const read = withGateTimeout(raw, PERSON_READ_BOUND_MS, cfg.signal, "personRules").then((view) => readOf(outcomeOf(view)), (err) => {
|
|
90
|
+
const failure = gateWaitFailureOf(err);
|
|
91
|
+
const cut = failure === "aborted";
|
|
85
92
|
const outcome = { seq, failed: new Set(partitions), why: thrownText(err), ...(cut ? { cut: true } : {}) };
|
|
86
93
|
land(outcome);
|
|
87
94
|
if (holdsPersonRows && !cut)
|
|
88
95
|
announce(at, outcome.why);
|
|
96
|
+
if (failure === "timeout" && seq > (silent?.seq ?? 0))
|
|
97
|
+
silent = { seq, read };
|
|
89
98
|
return readOf(outcome);
|
|
90
99
|
});
|
|
100
|
+
if (at === "prepare")
|
|
101
|
+
prepared = { seq, read };
|
|
102
|
+
return read;
|
|
103
|
+
};
|
|
104
|
+
const forRequest = () => {
|
|
105
|
+
const first = prepared;
|
|
106
|
+
prepared = undefined;
|
|
107
|
+
const s = silent;
|
|
108
|
+
const read = first !== undefined && first.seq === seqs ? first.read
|
|
109
|
+
: s !== undefined && s.seq > requestSeq && s.seq > answeredSeq ? s.read
|
|
110
|
+
: readOnce("call");
|
|
111
|
+
requestSeq = seqs;
|
|
112
|
+
return read;
|
|
91
113
|
};
|
|
92
114
|
const failedOf = (view) => view.unreadable !== undefined && (view.unreadableSources ?? []).length === 0 ? new Set(partitions) : new Set((view.unreadableSources ?? []).map(partitionOf).filter((p) => partitions.includes(p)));
|
|
93
115
|
const defect = (message) => {
|
|
@@ -245,6 +267,7 @@ export function createPersonPathRows(cfg) {
|
|
|
245
267
|
? readOnce("prepare").then(() => undefined)
|
|
246
268
|
: undefined,
|
|
247
269
|
pin,
|
|
270
|
+
forRequest,
|
|
248
271
|
tablesReady: (toolCallId, signal) => {
|
|
249
272
|
const p = pinOf(toolCallId);
|
|
250
273
|
const cut = signal === undefined || cfg.signal === undefined ? (signal ?? cfg.signal) : AbortSignal.any([signal, cfg.signal]);
|
|
@@ -280,6 +303,7 @@ export function createPersonPathRows(cfg) {
|
|
|
280
303
|
},
|
|
281
304
|
matchPath: (path) => judging().writeDeny.matchPath(path),
|
|
282
305
|
matchTarget: (canonicalKey, lexicalView, opts) => judging().writeDeny.matchTarget(canonicalKey, lexicalView, opts),
|
|
306
|
+
guardsReads: (pattern) => judging().writeDeny.guardsReads?.(pattern) === true,
|
|
283
307
|
homeViews: readDeny.homeViews,
|
|
284
308
|
forCall: (id) => tablesFor(id).writeDeny,
|
|
285
309
|
};
|
|
@@ -312,7 +336,10 @@ const SEATS = new WeakMap();
|
|
|
312
336
|
export function denySeatsOf(t) {
|
|
313
337
|
let seats = SEATS.get(t);
|
|
314
338
|
if (seats === undefined) {
|
|
315
|
-
seats = {
|
|
339
|
+
seats = {
|
|
340
|
+
read: readDenySeat(t.readDeny),
|
|
341
|
+
write: t.writeDeny.ruleRows.length > 0 ? { writeDenyMatch: (p) => t.writeDeny.matchPath(p)?.pattern ?? null, writeDenyGuardsReads: (pattern) => t.writeDeny.guardsReads?.(pattern) === true } : {},
|
|
342
|
+
};
|
|
316
343
|
SEATS.set(t, seats);
|
|
317
344
|
}
|
|
318
345
|
return seats;
|
|
@@ -24,3 +24,15 @@ export declare function mintPlacementFence(row: WorkspaceHandle | undefined, han
|
|
|
24
24
|
* any other leg `config.placement_not_honored`.
|
|
25
25
|
*/
|
|
26
26
|
export declare function settleOwnTarget(env: ExecutionEnv | undefined, fence: PlacementTarget | undefined, restoredCheckpoint: boolean): PlacementTarget | undefined;
|
|
27
|
+
/** The codes a device move is refused with: a fresh fenced leg, and a leg that restores or resumes a checkpointed workspace. */
|
|
28
|
+
export type DeviceMoveRefusalCode = "config.placement_not_honored" | "resume.env_failed";
|
|
29
|
+
/**
|
|
30
|
+
* THE refusal every device receipt throws — the settle point's two arms and the resume restore's identity check — so the
|
|
31
|
+
* three speak one sentence. A delegating model reads it as the child's `error:` line, which the report bounds at 300
|
|
32
|
+
* characters and which sits beside no code line of its own: the code, the two devices (each held to a budget, so an id of
|
|
33
|
+
* any length leaves room) and the way on come first, the host's part of the contract last, where a cut costs the least.
|
|
34
|
+
* The way on is the model's to act on: bring the workspace back to the fenced device, or start the work in a new workspace.
|
|
35
|
+
*/
|
|
36
|
+
export declare function deviceMoveRefusal(code: DeviceMoveRefusalCode, fenceDevice: string | undefined, reportedDevice: string | undefined): Error & {
|
|
37
|
+
code: string;
|
|
38
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { placementHonored, placementTargetOf, reportedPlacementTarget } from "../remote-env.js";
|
|
2
|
+
import { sliceHeadSafe, sliceTailSafe } from "../surrogate-safe-slice.js";
|
|
3
|
+
import { inlineUntrusted } from "../untrusted-text.js";
|
|
2
4
|
export function mintPlacementFence(row, handedValue) {
|
|
3
5
|
const fromRow = row !== undefined ? placementTargetOf(row) : undefined;
|
|
4
6
|
const handed = handedFence(handedValue);
|
|
@@ -20,14 +22,26 @@ function handedFence(value) {
|
|
|
20
22
|
}
|
|
21
23
|
export function settleOwnTarget(env, fence, restoredCheckpoint) {
|
|
22
24
|
const own = reportedPlacementTarget(env);
|
|
23
|
-
if (!placementHonored(fence, own))
|
|
24
|
-
|
|
25
|
-
throw restoredCheckpoint
|
|
26
|
-
? refusal("resume.env_failed", `resume workspace identity mismatch: the placement fence names deviceId "${fence?.deviceId}" but the restored execution environment ${reported} once its workspace settled — refusing to continue on a different physical device`)
|
|
27
|
-
: refusal("config.placement_not_honored", `this agent's placement fence names device "${fence?.deviceId}" but its execution environment ${reported} — refusing to run it on another target than the one it was handed (the factory must mint on the fenced device or throw)`);
|
|
28
|
-
}
|
|
25
|
+
if (!placementHonored(fence, own))
|
|
26
|
+
throw deviceMoveRefusal(restoredCheckpoint ? "resume.env_failed" : "config.placement_not_honored", fence?.deviceId, own?.deviceId);
|
|
29
27
|
return own;
|
|
30
28
|
}
|
|
29
|
+
export function deviceMoveRefusal(code, fenceDevice, reportedDevice) {
|
|
30
|
+
const fenced = fenceDevice !== undefined ? `device "${renderDeviceId(fenceDevice)}"` : "no device";
|
|
31
|
+
const reports = reportedDevice !== undefined ? `device "${renderDeviceId(reportedDevice)}"` : "no device";
|
|
32
|
+
return refusal(code, `${code}: refused before it ran — fenced to ${fenced}, but the environment reports ${reports}. Bring the workspace back to that device or open a new workspace for this work. (The factory must mint on the fenced device or throw.)`);
|
|
33
|
+
}
|
|
34
|
+
const DEVICE_ID_RENDER_MAX = 48;
|
|
35
|
+
const DEVICE_ID_FOLD_WINDOW = 4 * DEVICE_ID_RENDER_MAX;
|
|
36
|
+
const foldDeviceId = (s) => inlineUntrusted(s, 4 * s.length + 8);
|
|
37
|
+
function renderDeviceId(id) {
|
|
38
|
+
const folded = id.length <= 2 * DEVICE_ID_FOLD_WINDOW ? foldDeviceId(id) : `${foldDeviceId(sliceHeadSafe(id, DEVICE_ID_FOLD_WINDOW))}…${foldDeviceId(sliceTailSafe(id, DEVICE_ID_FOLD_WINDOW))}`;
|
|
39
|
+
if (folded.length <= DEVICE_ID_RENDER_MAX)
|
|
40
|
+
return folded;
|
|
41
|
+
const keep = DEVICE_ID_RENDER_MAX - 1;
|
|
42
|
+
const head = Math.ceil(keep / 2);
|
|
43
|
+
return `${sliceHeadSafe(folded, head)}…${sliceTailSafe(folded, keep - head)}`;
|
|
44
|
+
}
|
|
31
45
|
function placementNotHonored(message) {
|
|
32
46
|
return refusal("config.placement_not_honored", message);
|
|
33
47
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* cached view and never hands out a half-acquired resource.
|
|
15
15
|
*
|
|
16
16
|
* Throws pass through unchanged: `resume.session_not_found` (requireExisting fail-loud mapping),
|
|
17
|
-
* the `resume_at.*` target-validation refusals, `
|
|
17
|
+
* the `resume_at.*` target-validation refusals, `corrupt_session` for a log whose parent links loop back, and — after the
|
|
18
18
|
* bounded re-wake budget — the session conflict itself. A throw after a `resumeAt` branch landed first writes that branch
|
|
19
19
|
* back (`settleBranchWriteBack`); on success the branch is handed over with the session.
|
|
20
20
|
*/
|
|
@@ -25,6 +25,7 @@ import type { TaskSpec, ToolEffect } from "../types.js";
|
|
|
25
25
|
import type { PrepareResume } from "./contracts.js";
|
|
26
26
|
import { type ResumeAtBranch } from "./branch-writeback.js";
|
|
27
27
|
import { type LegWrites } from "./session-write-ledger.js";
|
|
28
|
+
import { replayLossLeg } from "./lineage-reroot-view.js";
|
|
28
29
|
export interface PrepareAcquireReconcileInput {
|
|
29
30
|
/** borrowed-mutable (service port) — the deployment's session store. This phase's verbs on it are
|
|
30
31
|
* the acquire/forget half of the session resource protocol: `acquire` per attempt, `forget` to
|
|
@@ -57,6 +58,8 @@ export interface PrepareAcquireReconcileInput {
|
|
|
57
58
|
report?: (err: Error, sessionId: string) => void;
|
|
58
59
|
/** borrowed-mutable (the Runner's) — this leg's view of the session write ledger, every storage write issued through it ({@link writesThroughLeg}); absent for a standalone prepare. */
|
|
59
60
|
legWrites?: LegWrites;
|
|
61
|
+
/** borrowed-readonly — where the leg says what the log's replay dropped, and re-rooted a branch at it ({@link replayLossLeg}): absent ⇒ nothing said and no re-root (a break is refused). */
|
|
62
|
+
replayLossNotice?: Parameters<typeof replayLossLeg>[0];
|
|
60
63
|
}
|
|
61
64
|
/** The phase's outputs (four-class form). All six are fresh bindings —
|
|
62
65
|
* the driver destructures them into consts, so a consumer moved ahead of this call is a lexical
|
|
@@ -7,6 +7,7 @@ import { reconcileInterruptedSession } from "../session-reconcile.js";
|
|
|
7
7
|
import { detectConflicts, settleBranchWriteBack } from "./branch-writeback.js";
|
|
8
8
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
9
9
|
import { writesThroughLeg } from "./session-write-ledger.js";
|
|
10
|
+
import { replayLossLeg } from "./lineage-reroot-view.js";
|
|
10
11
|
const RECONCILE_MAX_RETRIES = 3;
|
|
11
12
|
export async function prepareAcquireReconcile(input) {
|
|
12
13
|
const { sessions, spec, resume, wakeEffects } = input;
|
|
@@ -15,6 +16,7 @@ export async function prepareAcquireReconcile(input) {
|
|
|
15
16
|
let conflictRef;
|
|
16
17
|
let wakeRecovered = [];
|
|
17
18
|
let branch;
|
|
19
|
+
const lossLeg = input.replayLossNotice !== undefined ? replayLossLeg(input.replayLossNotice) : undefined;
|
|
18
20
|
for (let attempt = 0;; attempt++) {
|
|
19
21
|
try {
|
|
20
22
|
acquired = await sessions.acquire(spec.sessionId, spec.requireExistingSession ? { requireExisting: true } : input.placement !== undefined ? { placement: input.placement } : undefined);
|
|
@@ -30,14 +32,15 @@ export async function prepareAcquireReconcile(input) {
|
|
|
30
32
|
}
|
|
31
33
|
conflictRef = { hit: false };
|
|
32
34
|
const own = { ids: undefined };
|
|
33
|
-
|
|
35
|
+
const legStorage = input.legWrites !== undefined ? writesThroughLeg(acquired.session.getStorage(), input.legWrites, acquired.sessionId) : acquired.session.getStorage();
|
|
36
|
+
session = new StoredSession(detectConflicts(lossLeg !== undefined ? lossLeg.view(legStorage, acquired.sessionId) : legStorage, conflictRef, own));
|
|
34
37
|
if (!spec.sessionId) {
|
|
35
38
|
break;
|
|
36
39
|
}
|
|
37
40
|
try {
|
|
38
41
|
if (resume) {
|
|
39
42
|
await session.getStorage().setLeafId(resume.leafId).catch((cut) => {
|
|
40
|
-
throw readMember(cut, "code") === "not_found" ? new SessionError("
|
|
43
|
+
throw readMember(cut, "code") === "not_found" ? new SessionError("corrupt_session", `session "${spec.sessionId}" no longer holds the entry its checkpoint was cut at ("${resume.leafId}")`, cut) : cut;
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
else if (spec.resumeAt !== undefined) {
|
|
@@ -113,6 +116,7 @@ export async function prepareAcquireReconcile(input) {
|
|
|
113
116
|
await settleTeardownLeg(() => Promise.resolve(forget(id)).catch(() => undefined), "forget (acquire-reconcile re-wake leg)", (e) => input.report?.(e, id));
|
|
114
117
|
}
|
|
115
118
|
branch = undefined;
|
|
119
|
+
lossLeg?.discard();
|
|
116
120
|
continue;
|
|
117
121
|
}
|
|
118
122
|
if (branch !== undefined)
|
|
@@ -121,5 +125,6 @@ export async function prepareAcquireReconcile(input) {
|
|
|
121
125
|
throw err;
|
|
122
126
|
}
|
|
123
127
|
}
|
|
128
|
+
lossLeg?.settle();
|
|
124
129
|
return { acquired, session, conflictRef, wakeRecovered, branch };
|
|
125
130
|
}
|
|
@@ -88,8 +88,8 @@ export function prepareAskLane(input) {
|
|
|
88
88
|
};
|
|
89
89
|
const settlement = { kind: "approver_unavailable", who: { party: "none" }, when: now() };
|
|
90
90
|
return decision.action === "ask"
|
|
91
|
-
? attest(intercepted, req, { settlement, ...(decision.origin !== undefined ? { origin: decision.origin } : {}), ...(decision.classes !== undefined ? { classes: decision.classes } : {}), inputDigest: exactBoundInputHashOf(req.args) })
|
|
92
|
-
: attest(intercepted, req, { settlement, inputDigest: exactBoundInputHashOf(req.args) });
|
|
91
|
+
? attest(intercepted, req, { settlement, ...(decision.origin !== undefined ? { origin: decision.origin } : {}), ...(decision.classes !== undefined ? { classes: decision.classes } : {}), inputDigest: exactBoundInputHashOf(req.toolName, req.args) })
|
|
92
|
+
: attest(intercepted, req, { settlement, inputDigest: exactBoundInputHashOf(req.toolName, req.args) });
|
|
93
93
|
}
|
|
94
94
|
const grantReuse = consumeInheritedAskGrant(inheritedAskGrants, onAsk, humanReviewRef, decision, req);
|
|
95
95
|
if (grantReuse !== undefined)
|
|
@@ -59,6 +59,7 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
59
59
|
* the chain's auto-mode face (`inheritedGate.autoModeFace`). */
|
|
60
60
|
internals: Pick<RunInternals, "rootSessionId" | "placementRoot" | "onTaskNotification" | "workflowDepth" | "memoryCaptureAncestors" | "workflowParkedResume" | "holder" | "questionFaceStripped" | "inheritedGate"> | undefined;
|
|
61
61
|
/** borrowed-readonly — the tree's cross-boundary token (inherited or minted), which the Workflow mount hands to its children. */ crossBoundaryTree: import("../cross-boundary-taint.js").CrossBoundaryTreeToken;
|
|
62
|
+
/** borrowed-readonly — the tree's owner seat, which the Workflow mount hands to its children (by reference). */ delegationOwner: import("./delegation-owner.js").DelegationOwnerSeat;
|
|
62
63
|
/** borrowed-readonly — the acquired session; the classifier leg rebuilds its transcript window from `buildContext`. */
|
|
63
64
|
session: Pick<StoredSession, "buildContext">;
|
|
64
65
|
/** borrowed-readonly — the acquired session id (operator-line context, the refusal codes' phase record). */
|
|
@@ -69,8 +70,11 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
69
70
|
hostTaskId: string;
|
|
70
71
|
/** borrowed-readonly — the registry scope the Workflow mount registers in. */
|
|
71
72
|
taskScope: string;
|
|
72
|
-
/** borrowed-readonly — the SETTLED task root the Workflow mount hands its children as `
|
|
73
|
+
/** borrowed-readonly — the SETTLED task root the Workflow mount hands its children as `callerRoot`. */
|
|
73
74
|
taskRootFinal: string;
|
|
75
|
+
/** borrowed-readonly — where a delegated child is asked to work (the leg's write location, else the task root as spelled),
|
|
76
|
+
* read at the spawn: the Workflow mount hands it to its children as `parentCwd`. */
|
|
77
|
+
delegationCwd: () => string;
|
|
74
78
|
/** borrowed-readonly — this leg's own target (absent: none), the fence the Workflow mount hands every agent it spawns. */
|
|
75
79
|
ownTarget: import("../remote-env.js").PlacementTarget | undefined;
|
|
76
80
|
/** borrowed-readonly — the run's resolved model: the classifier leg's fallback and the route pre-flight's primary. */
|
|
@@ -117,7 +117,7 @@ function autoModeArmReasonOf(intent, facePresent, caps, capsFaulted) {
|
|
|
117
117
|
return { armed: true, reason: "armed" };
|
|
118
118
|
}
|
|
119
119
|
export async function prepareCapsAndWorkflow(input) {
|
|
120
|
-
const { spec, deps, parentSpecSeat, checkpointSeat, internals, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, model, thinking, lockedPreflight, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, askSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, taskArtifacts, requestReview, enterPlanMode, permissionMode, readDenyEntries, peerLaneActive, peerSendMessageBuiltIn, runnerSelf, delegated, sideCallBookRef } = input;
|
|
120
|
+
const { spec, deps, parentSpecSeat, checkpointSeat, internals, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, delegationCwd, model, thinking, lockedPreflight, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, askSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, taskArtifacts, requestReview, enterPlanMode, permissionMode, readDenyEntries, peerLaneActive, peerSendMessageBuiltIn, runnerSelf, delegated, sideCallBookRef } = input;
|
|
121
121
|
const roster = new RosterBuilder(toolEffects);
|
|
122
122
|
for (const t of spec.tools ?? []) {
|
|
123
123
|
const mounted = mountCallerTool(t);
|
|
@@ -331,7 +331,7 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
331
331
|
scope: taskScope,
|
|
332
332
|
notifier: deps.workflowCompletionNotifier,
|
|
333
333
|
originatingSessionId: sessionId,
|
|
334
|
-
rootSessionId: internals?.rootSessionId ?? sessionId, ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}), crossBoundaryTree: input.crossBoundaryTree,
|
|
334
|
+
rootSessionId: internals?.rootSessionId ?? sessionId, ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}), crossBoundaryTree: input.crossBoundaryTree, delegationOwner: input.delegationOwner,
|
|
335
335
|
taskRegistry: defaultTaskRegistry,
|
|
336
336
|
taskNotification: internals?.onTaskNotification, ...(taskArtifacts !== undefined ? { taskArtifacts } : {}),
|
|
337
337
|
taskOwner: hostTaskId,
|
|
@@ -366,7 +366,10 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
366
366
|
autoModeReview: () => (autoModeDeciderRef.current !== undefined ? { decider: autoModeDeciderRef.current } : undefined),
|
|
367
367
|
agentStations: input.agentStations,
|
|
368
368
|
workflowDepth: internals?.workflowDepth,
|
|
369
|
-
parentCwd
|
|
369
|
+
get parentCwd() {
|
|
370
|
+
return delegationCwd();
|
|
371
|
+
},
|
|
372
|
+
callerRoot: taskRootFinal,
|
|
370
373
|
...(input.ownTarget !== undefined ? { placementTarget: input.ownTarget } : {}),
|
|
371
374
|
parentThinking: () => childThinkingSeat(undefined, deploymentSubagentThinking(runnerSelf.agentCatalog?.roles), harnessRef.current?.getThinkingLevel() ?? thinking).thinking,
|
|
372
375
|
parentClamps: runClampSource,
|
|
@@ -24,7 +24,6 @@ import type { ThinkingLevel } from "../../internal/harness.js";
|
|
|
24
24
|
import { type MicroCompactMachine } from "../context-edit.js";
|
|
25
25
|
import { type CrossBoundaryPosture } from "../cross-boundary-taint.js";
|
|
26
26
|
import { type HostFloor } from "../host-floor.js";
|
|
27
|
-
import { type CheckpointState } from "../checkpoint-store.js";
|
|
28
27
|
import { runOriginOfLeg, type RunOrigin } from "../run-origin.js";
|
|
29
28
|
import { type ConfigDoorEntry, type LockedPreflight, type ReceivedPeerDeclarations } from "../locked-config.js";
|
|
30
29
|
import { type ResolvedRole } from "../roles.js";
|
|
@@ -269,15 +268,16 @@ export declare function configValueDoors(input: {
|
|
|
269
268
|
* The doors a RESUMED leg's prepare refuses at, run as one screen BEFORE the claim — prepare's own functions, so a refusal carries
|
|
270
269
|
* the very sentence and code prepare throws: the mode doors (`refusePermissionModeDoors`), the output-style seat, the approval
|
|
271
270
|
* reach, the skills invoked by name (the part no roster changes), the attachments (a resume sends no new human message, so any
|
|
272
|
-
* entry is refused), the leg declarations of the tools it re-supplies (this phase's first door), this phase's value doors over the config, the deployment's deps and the session store the Runner holds
|
|
273
|
-
* ({@link configValueDoors}, the retention capability door and the run-origin door over the
|
|
274
|
-
*
|
|
271
|
+
* entry is refused), the leg declarations of the tools it re-supplies (this phase's first door), and this phase's value doors over the config, the deployment's deps and the session store the Runner holds
|
|
272
|
+
* ({@link configValueDoors}, the retention capability door and the run-origin door over the config's word included). The words the
|
|
273
|
+
* row recorded (its mode seed, its run origin) are not this door's: the row's own verdict judged them before it (`judgeCheckpointRow`,
|
|
274
|
+
* checkpoint-row-verdict.ts), so this door reads nothing off the row. It leaves by the resume's ONE refusal channel (`asResumeConfigRefusal`:
|
|
275
275
|
* `checkpoint.config_refused`, `detail.code` = prepare's code, `detail.field` = `"taskConfig"`, `"deps"` or `"inheritedGate"`)
|
|
276
276
|
* where prepare would end the leg `failed` after the claim — the row consumed on a store without `reopen`, replayed as a system
|
|
277
277
|
* retry on one with it, which a configuration fix cannot reach. Before the claim the row stays `pending` and byte-identical and the
|
|
278
278
|
* corrected resume redeems the same token. A throw that is none of prepare's codes leaves as it was thrown. Returns the config the
|
|
279
|
-
* leg is handed: the caller's, its MCP servers and A2A peers the
|
|
279
|
+
* leg is handed: the caller's, its MCP servers and A2A peers the lock layer's judged copies of the lists THIS resume handed (read once, dialed as judged; the row records none).
|
|
280
280
|
*/
|
|
281
|
-
export declare function refuseResumeDoors<C extends ValueDoorSpec & Pick<TaskSpec, "userAttachments">>(config: C,
|
|
281
|
+
export declare function refuseResumeDoors<C extends ValueDoorSpec & Pick<TaskSpec, "userAttachments">>(config: C, deps: RunnerDeps, sessions: SessionStore, holder?: string): C;
|
|
282
282
|
export declare function prepareConfigDoors(input: PrepareConfigDoorsInput): PrepareConfigDoorsResult;
|
|
283
283
|
export {};
|
|
@@ -5,7 +5,7 @@ import { assertAddOnlySeats } from "../child-clamp-seats.js";
|
|
|
5
5
|
import { CROSS_BOUNDARY_POSTURES } from "../cross-boundary-taint.js";
|
|
6
6
|
import { compileHostFloor } from "../host-floor.js";
|
|
7
7
|
import { assertNoRetiredRunnerDeps } from "./retired-runner-deps.js";
|
|
8
|
-
import {
|
|
8
|
+
import { resolveCheckpointStore } from "../checkpoint-store.js";
|
|
9
9
|
import { runOriginOfLeg, screenRecordedRunOrigin } from "../run-origin.js";
|
|
10
10
|
import { assertCheckpointStoreJudgesHolder, assertHolderValue } from "../checkpoint-generation.js";
|
|
11
11
|
import { asResumeConfigRefusal, refusePermissionModeDoors } from "../mode-policy.js";
|
|
@@ -346,7 +346,7 @@ export function configValueDoors(input, enter = ENTER_AS_IS) {
|
|
|
346
346
|
enter("taskConfig", () => assertRetentionWords({ ...retention, stores: [{ name: "checkpointStore", store: taskStore }] }));
|
|
347
347
|
return { toolFaceLists, promptHost, promptBinding, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, deploymentRoles, taskRoles };
|
|
348
348
|
}
|
|
349
|
-
export function refuseResumeDoors(config,
|
|
349
|
+
export function refuseResumeDoors(config, deps, sessions, holder) {
|
|
350
350
|
asResumeConfigRefusal("taskConfig", () => {
|
|
351
351
|
refusePermissionModeDoors(config);
|
|
352
352
|
resolveOutputStyleFrame(config.outputStyle);
|
|
@@ -356,8 +356,7 @@ export function refuseResumeDoors(config, recorded, deps, sessions, holder) {
|
|
|
356
356
|
assertToolBoundaryLegs(config.tools);
|
|
357
357
|
assertToolCardDeclarations(config.tools);
|
|
358
358
|
});
|
|
359
|
-
const { lockedPreflight, skills } = configValueDoors({ spec: config, deps, resumeLeg: true, sessions, holder,
|
|
360
|
-
asResumeConfigRefusal("inheritedGate", () => void recordedModeSeed(recorded?.inheritedGate));
|
|
359
|
+
const { lockedPreflight, skills } = configValueDoors({ spec: config, deps, resumeLeg: true, sessions, holder, resumedRow: { recorded: undefined } }, asResumeConfigRefusal);
|
|
361
360
|
return { ...config, ...(config.mcp !== undefined ? { mcp: lockedPreflight.mcp ?? [] } : {}), ...(config.a2a !== undefined ? { a2a: lockedPreflight.a2a ?? [] } : {}), skills };
|
|
362
361
|
}
|
|
363
362
|
export function prepareConfigDoors(input) {
|
|
@@ -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
|
}
|
|
@@ -6,7 +6,7 @@ import { type ShellReadAdmission, type ShellReadCheck, type ShellReadLandings }
|
|
|
6
6
|
import { type ReadFloorSeat } from "../../tools/fs/read-floor.js";
|
|
7
7
|
import type { ShellReadBoundary } from "../../tools/fs/shell-read-judge.js";
|
|
8
8
|
import type { RunnerDeps, ShellGateDoctrine, TaskSpec } from "../types.js";
|
|
9
|
-
import type
|
|
9
|
+
import { type Model } from "../../internal/llm.js";
|
|
10
10
|
import type { AgentHarness, AgentTool, ExecutionEnv, WorkspaceState } from "../../internal/harness.js";
|
|
11
11
|
import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
12
12
|
import { type ArtifactStoreRef, type GrantReadRoot } from "./read-root-grant.js";
|
|
@@ -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. */
|
|
@@ -15,10 +15,11 @@ import { isShellFaceToolName, predictMountedToolNames, readTargetToolNames } fro
|
|
|
15
15
|
import { normalizeFileText } from "../../tools/fs/encoding.js";
|
|
16
16
|
import { wholeFileRecordsFromTranscript } from "./session-file-state-replay.js";
|
|
17
17
|
import { deliverEngineNotice } from "../types.js";
|
|
18
|
+
import { toolNameIndex } from "../../internal/llm.js";
|
|
18
19
|
import { readRootGrantOver } from "./read-root-grant.js";
|
|
19
20
|
import { sessionSeatAnchorHolds } from "./session-read-file-states.js";
|
|
20
21
|
import { rebaseWorkspacePath } from "./workspace-path.js";
|
|
21
|
-
import { RosterBuilder } from "../tool-roster.js";
|
|
22
|
+
import { RosterBuilder, survivorsByName } from "../tool-roster.js";
|
|
22
23
|
import { unionAddOnly } from "../child-clamp-seats.js";
|
|
23
24
|
import { assertStringArraySeat, screenReadDenySeat } from "../read-face-seats.js";
|
|
24
25
|
import { modePolicyOf } from "../mode-policy.js";
|
|
@@ -195,7 +196,8 @@ export async function prepareHandsMount(input) {
|
|
|
195
196
|
const handsReadOnly = spec.handsReadOnly === true;
|
|
196
197
|
backgroundTaskToolsActive = handsIncludeShell && !handsReadOnly && hasBackgroundShell(executionEnv);
|
|
197
198
|
const shellFaceHere = [...predictMountedToolNames(new Set(backgroundTaskToolsActive ? ["hands", "backgroundTasks"] : ["hands"]))].filter(isShellFaceToolName);
|
|
198
|
-
|
|
199
|
+
const checkpointTracked = resume?.seed.handsCwd !== undefined;
|
|
200
|
+
wsSnapshot = checkpointTracked || !(handsIncludeShell && !handsReadOnly) ? undefined : await session.getWorkspaceState().catch(() => undefined);
|
|
199
201
|
rebaseWsPath = (p) => (wsSnapshot === undefined || wsSnapshot.taskRoot === rootCanonical ? p : rebaseWorkspacePath(p, wsSnapshot.taskRoot, rootCanonical));
|
|
200
202
|
if (handsIncludeShell && !handsReadOnly) {
|
|
201
203
|
handsCwdRef = { current: rootCanonical };
|
|
@@ -206,7 +208,7 @@ export async function prepareHandsMount(input) {
|
|
|
206
208
|
workspaceStateSettle = {
|
|
207
209
|
rootCanonical,
|
|
208
210
|
restoredHandsCwd: handsCwdRef.current !== rootCanonical ? handsCwdRef.current : undefined,
|
|
209
|
-
...(resume !== undefined ? { baselineUnknown: true } : {}),
|
|
211
|
+
...(resume !== undefined && wsSnapshot === undefined ? { baselineUnknown: true } : {}),
|
|
210
212
|
};
|
|
211
213
|
}
|
|
212
214
|
const seedReadFaceSection = resume?.seed.readFace;
|
|
@@ -225,7 +227,7 @@ export async function prepareHandsMount(input) {
|
|
|
225
227
|
const tables = (pathTables = await input.personRows.attachTables(judgedRunTables));
|
|
226
228
|
readDenyMatcher = tables.readDeny;
|
|
227
229
|
runReadFloor = readFloorSeat(tables.readDeny);
|
|
228
|
-
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,
|
|
229
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() })) });
|
|
230
232
|
readDenyBuiltinTiersActive = activeReadDenyBuiltinTiers(readDenyBuiltinCfg);
|
|
231
233
|
readDenyAdditionsNormalized = compileReadDeny(readDenyAdditions, "readDenyPatterns", { tiers: [] }).entries;
|
|
@@ -346,6 +348,7 @@ export async function prepareHandsMount(input) {
|
|
|
346
348
|
exempt: (key) => bgOutputExempt?.(key) === true,
|
|
347
349
|
});
|
|
348
350
|
}
|
|
351
|
+
const valveLeft = valveLeaves(spec, toolFaceSnapshot.selector);
|
|
349
352
|
const band = createHandsToolkit(executionEnv, readFileState, rootCanonical, {
|
|
350
353
|
...(additionalRootsCanonical.length > 0 ? { additionalRoots: additionalRootsCanonical } : {}),
|
|
351
354
|
writeRoot: input.writeLocation,
|
|
@@ -388,14 +391,33 @@ export async function prepareHandsMount(input) {
|
|
|
388
391
|
return memoryWriteGate?.(w);
|
|
389
392
|
},
|
|
390
393
|
mountBackgroundTaskTools: false,
|
|
391
|
-
monitorToolActive: backgroundTaskToolsActive &&
|
|
394
|
+
monitorToolActive: backgroundTaskToolsActive && valveLeft({ name: "Monitor" }),
|
|
392
395
|
});
|
|
393
396
|
{
|
|
394
|
-
const
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
397
|
+
const callerLeft = (spec.tools ?? []).filter((t) => valveLeft(t));
|
|
398
|
+
const bandLeft = band.filter((t) => valveLeft(t));
|
|
399
|
+
const bandTools = new Set(bandLeft);
|
|
400
|
+
const serves = toolNameIndex([...survivorsByName([...callerLeft, ...bandLeft]).values()]);
|
|
401
|
+
const lostTo = (name, tool) => {
|
|
402
|
+
const holder = serves(name);
|
|
403
|
+
return holder !== undefined && holder !== tool && bandTools.has(holder) ? holder : undefined;
|
|
404
|
+
};
|
|
405
|
+
const collisions = [];
|
|
406
|
+
for (const t of callerLeft) {
|
|
407
|
+
const replacedBy = lostTo(t.name, t);
|
|
408
|
+
if (replacedBy !== undefined) {
|
|
409
|
+
collisions.push(`"${t.name}" is replaced by the built-in "${replacedBy.name}", which serves that name (the caller tool never dispatches)`);
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
const aliases = (t.aliases ?? []).flatMap((a) => {
|
|
413
|
+
const holder = lostTo(a, t);
|
|
414
|
+
return holder === undefined ? [] : [`"${a}" serves the built-in "${holder.name}"`];
|
|
415
|
+
});
|
|
416
|
+
if (aliases.length > 0)
|
|
417
|
+
collisions.push(`"${t.name}" stays mounted under its own name, but its ${aliases.length > 1 ? "aliases" : "alias"} ${aliases.join(" and ")}`);
|
|
418
|
+
}
|
|
419
|
+
if (collisions.length > 0) {
|
|
420
|
+
deps.onError?.(new Error(`spec.tools ${collisions.length > 1 ? "entries collide" : "entry collides"} with the built-in hands tool band — the built-in wins each contested name: ${collisions.join("; ")}. Rename the colliding name, or don't inject executionEnv if you intend to replace the band.`), { phase: "config", sessionId });
|
|
399
421
|
}
|
|
400
422
|
}
|
|
401
423
|
roster.mountAll(band.map((t) => (envHandToolNames.add(t.name), firstPartyOffload(afterCallTables(input.personRows, t)))), { source: "builtin", mountedBy: "hands" });
|
|
@@ -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`
|
|
@@ -74,6 +75,8 @@ export interface PrepareInheritedGateInput {
|
|
|
74
75
|
askSeat: import("../wiring-manifest.js").AskSeat;
|
|
75
76
|
/** borrowed-readonly — the tree's cross-boundary token (the leg's lane: inherited, or minted by a root leg), handed to children. */
|
|
76
77
|
crossBoundaryTree: import("../cross-boundary-taint.js").CrossBoundaryTreeToken;
|
|
78
|
+
/** borrowed-readonly — the run's delegation tree owner seat (the spawner's, or one over the row this run acquired). */
|
|
79
|
+
delegationOwner: import("./delegation-owner.js").DelegationOwnerSeat;
|
|
77
80
|
/** borrowed-readonly — the trusted spawn-side channel: `inheritedGate` (the LIVE half of the chain fold), `ownOrgAdmissionRef`
|
|
78
81
|
* (the same-session continuation's freeze), `delegationProvenance` (the F-012 stamp), and the identity / peer / notification
|
|
79
82
|
* seats the ctx enrichment forwards. Never mutated. */
|
|
@@ -82,16 +85,20 @@ export interface PrepareInheritedGateInput {
|
|
|
82
85
|
* fold (the trust floor the live half may only tighten), `seed.readFace` the hands-less re-park's carried section. */
|
|
83
86
|
resume: Pick<PrepareResume, "seed" | "outcome"> | undefined;
|
|
84
87
|
/** borrowed-readonly — the session store's fork face: `fork` / `release` are bound into the ctx's `hostSessionFork` (present
|
|
85
|
-
* only when the store can fork). */
|
|
86
|
-
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">;
|
|
87
90
|
/** borrowed-readonly — the acquired session id (the crash lane's context, the ctx seat, the ancestor chain's own row). */
|
|
88
91
|
sessionId: string;
|
|
89
92
|
/** borrowed-readonly — the run's invocation id (the stop seat's notice names it). */
|
|
90
93
|
runId: string;
|
|
91
94
|
/** borrowed-readonly — the per-task identity (`ctx.taskId`, the same fallback the runner uses). */
|
|
92
95
|
hostTaskId: string;
|
|
93
|
-
/** 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). */
|
|
94
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;
|
|
95
102
|
/** borrowed-readonly — the target this leg's env reported as its workspace settled (`ctx.placementTarget`: the fence of
|
|
96
103
|
* every agent the delegation tools spawn or wake from this leg); absent when it reported none. */
|
|
97
104
|
ownTarget: PlacementTarget | undefined;
|
|
@@ -317,10 +324,7 @@ export interface PrepareInheritedGateResult {
|
|
|
317
324
|
/** borrowed-mutable — the delegation-settlement coordinates. Writer: the memory-engine-session phase, once per leg when the
|
|
318
325
|
* mounted session carries a settlement seat. Read lazily by delegation tools through the ctx. */
|
|
319
326
|
delegationSettlementRef: {
|
|
320
|
-
current?:
|
|
321
|
-
controlDir: string;
|
|
322
|
-
sessionId: string;
|
|
323
|
-
};
|
|
327
|
+
current?: DelegationSettlementSeat;
|
|
324
328
|
};
|
|
325
329
|
/** owned — chain assembly SINGLE SITE: upstream chain + this task's own contribution, called by delegation tools at spawn. */
|
|
326
330
|
inheritedGateForChildren: () => InheritedGate;
|