@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
|
@@ -467,6 +467,25 @@ export async function ruleStoreChecksum(payload) {
|
|
|
467
467
|
}
|
|
468
468
|
export const REMOVAL_LIVENESS_WORDS = Object.freeze(["yes", "no", "unknown"]);
|
|
469
469
|
export const RULE_WRITE_COMMITTED_WORDS = Object.freeze(["no", "unknown"]);
|
|
470
|
+
export const RULE_REFUSAL_CODES = Object.freeze([
|
|
471
|
+
"unsupported.layer_root",
|
|
472
|
+
"ticket_invalid",
|
|
473
|
+
"record_missing",
|
|
474
|
+
"wrong_principal",
|
|
475
|
+
"record_schema_stale",
|
|
476
|
+
"not_confirmed",
|
|
477
|
+
"record_malformed",
|
|
478
|
+
"not_chosen",
|
|
479
|
+
"parse_rejected",
|
|
480
|
+
"store_unavailable",
|
|
481
|
+
"record_changed",
|
|
482
|
+
"withheld",
|
|
483
|
+
"store_read",
|
|
484
|
+
"store_write",
|
|
485
|
+
"session_ended",
|
|
486
|
+
"occ",
|
|
487
|
+
"dot_removed",
|
|
488
|
+
]);
|
|
470
489
|
function resolveRuleWriter(store) {
|
|
471
490
|
let w;
|
|
472
491
|
try {
|
|
@@ -641,35 +660,35 @@ export async function landRuleAdd(args) {
|
|
|
641
660
|
rev = snapshot.rev;
|
|
642
661
|
const refusal = await args.preflight?.(snapshot);
|
|
643
662
|
if (refusal !== undefined)
|
|
644
|
-
return { landed: false, reason: refusal, committed: "no" };
|
|
663
|
+
return { landed: false, reason: refusal, committed: "no", code: "withheld" };
|
|
645
664
|
}
|
|
646
665
|
catch (err) {
|
|
647
|
-
return { landed: false, reason: `could not read the permission-rule store: ${errText(err)}`, committed: "no" };
|
|
666
|
+
return { landed: false, reason: `could not read the permission-rule store: ${errText(err)}`, committed: "no", code: "store_read" };
|
|
648
667
|
}
|
|
649
668
|
let res;
|
|
650
669
|
try {
|
|
651
670
|
res = await args.writer.apply(args.delta, { expectedRev: rev });
|
|
652
671
|
}
|
|
653
672
|
catch (err) {
|
|
654
|
-
return { landed: false, reason: `the permission-rule store refused the write: ${errText(err)}`, committed: "unknown" };
|
|
673
|
+
return { landed: false, reason: `the permission-rule store refused the write: ${errText(err)}`, committed: "unknown", code: "store_write" };
|
|
655
674
|
}
|
|
656
675
|
const reading = readRuleWriteOutcome(res);
|
|
657
676
|
if (reading.kind === "refused")
|
|
658
|
-
return { landed: false, reason: SESSION_ENDED_REFUSAL, committed: "no" };
|
|
677
|
+
return { landed: false, reason: SESSION_ENDED_REFUSAL, committed: "no", code: "session_ended" };
|
|
659
678
|
if (reading.kind === "unreadable")
|
|
660
|
-
return { landed: false, reason: `the permission-rule store answered the write unreadably: ${reading.why}`, committed: "unknown" };
|
|
679
|
+
return { landed: false, reason: `the permission-rule store answered the write unreadably: ${reading.why}`, committed: "unknown", code: "store_write" };
|
|
661
680
|
if (reading.kind === "landed") {
|
|
662
681
|
const witness = await witnessRuleAdd(args.store, args.writer, args.delta);
|
|
663
682
|
if ("unreadable" in witness) {
|
|
664
|
-
return { landed: false, reason: `the permission-rule store reported a landing at revision ${String(reading.rev)}, and the read-back that would have witnessed it could not be taken (${witness.unreadable})`, committed: "unknown" };
|
|
683
|
+
return { landed: false, reason: `the permission-rule store reported a landing at revision ${String(reading.rev)}, and the read-back that would have witnessed it could not be taken (${witness.unreadable})`, committed: "unknown", code: "store_read" };
|
|
665
684
|
}
|
|
666
685
|
if (!witness.seen) {
|
|
667
|
-
return { landed: false, reason: `the permission-rule store reported a landing at revision ${String(reading.rev)}, and a read-back of this add's own dot finds no trace of it — a revision says the ANSWER was well formed, not that a row exists, so nothing here can say the write landed`, committed: "unknown" };
|
|
686
|
+
return { landed: false, reason: `the permission-rule store reported a landing at revision ${String(reading.rev)}, and a read-back of this add's own dot finds no trace of it — a revision says the ANSWER was well formed, not that a row exists, so nothing here can say the write landed`, committed: "unknown", code: "store_write" };
|
|
668
687
|
}
|
|
669
688
|
return { landed: true, rev: reading.rev };
|
|
670
689
|
}
|
|
671
690
|
}
|
|
672
|
-
return { landed: false, reason: `optimistic-concurrency retries exhausted after ${RULE_ADD_MAX_ATTEMPTS} attempts`, committed: "no" };
|
|
691
|
+
return { landed: false, reason: `optimistic-concurrency retries exhausted after ${RULE_ADD_MAX_ATTEMPTS} attempts`, committed: "no", code: "occ" };
|
|
673
692
|
}
|
|
674
693
|
export async function addPersistedRule(opts) {
|
|
675
694
|
const behavior = opts.behavior;
|
|
@@ -3,6 +3,7 @@ import { lexedWordOf, readShellCommand } from "./shell-run-candidates.js";
|
|
|
3
3
|
import { unlistedReaderSentence } from "../tools/fs/bash-readonly-classifier.js";
|
|
4
4
|
import { descriptorsOfPlan, newLineDescriptors, standardDeviceUnrebound } from "../tools/fs/shell-read-device.js";
|
|
5
5
|
import { planShellReads } from "../tools/fs/shell-read-plan.js";
|
|
6
|
+
import { programKeyOf } from "../tools/fs/program-read-model.js";
|
|
6
7
|
import { writesOnlyStandardDevices } from "../tools/fs/shell-read-write-targets.js";
|
|
7
8
|
import { FIND_ACTION_PRIMARIES, FIND_NEWER_PRIMARY, FIND_VALUE_PRIMARIES, FLAG_VALUE_ACCEPTS, READ_ONLY_BARE_ONLY, READ_ONLY_BARE_PROGRAMS, READ_ONLY_COMMAND_TABLE, READ_ONLY_ENV_NAMES, READ_ONLY_EXACT_FORMS, READ_ONLY_GLOB_PROGRAMS, XARGS_READ_ONLY_TARGETS, dockerRetargetDanger, } from "./read-only-shell-table.js";
|
|
8
9
|
const NOT = (reason) => ({ readOnly: false, reason });
|
|
@@ -182,7 +183,7 @@ function segmentVerdict(seg, line, bindings, readers) {
|
|
|
182
183
|
return unlisted;
|
|
183
184
|
if (run.some((w) => expansionKind(w) === "glob"))
|
|
184
185
|
return GLOB_PROGRAMS.has(program) ? READ_ONLY : NOT(`\`${program}\` with a glob argument — the glob may name anything`);
|
|
185
|
-
if (DEVICE_WRITERS.has(program) && writesOnlyStandardDevices(program, words.slice(1), bindings()))
|
|
186
|
+
if (DEVICE_WRITERS.has(programKeyOf(program)) && writesOnlyStandardDevices(program, words.slice(1), bindings()))
|
|
186
187
|
return READ_ONLY;
|
|
187
188
|
const structural = structuralReading(words);
|
|
188
189
|
if (structural !== null)
|
|
@@ -192,7 +193,7 @@ function segmentVerdict(seg, line, bindings, readers) {
|
|
|
192
193
|
export function lineDescriptorsOfText(command) {
|
|
193
194
|
return descriptorsOfPlan(planShellReads(command, { readers: new Set(), cwd: "/", roots: [] }));
|
|
194
195
|
}
|
|
195
|
-
const DEVICE_WRITERS = new Set(["tee", "cp"]);
|
|
196
|
+
const DEVICE_WRITERS = new Set(["tee", "cp", "dd"]);
|
|
196
197
|
function structuralReading(words) {
|
|
197
198
|
const program = words[0];
|
|
198
199
|
if (BARE_ONLY.has(program))
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SecretNotation } from "@sema-agent/primitives";
|
|
1
2
|
/** The marks, by what they stand for. `whole` is the bare mark (a span removed whole — a credential value, a floor, a
|
|
2
3
|
* depth cut); the others name the shape that was withheld: `credentials` a URL's userinfo, `url` a whole URL, `path` an
|
|
3
4
|
* absolute filesystem path. A mark the engine writes is exactly one of these four. Frozen: the table is exported to hosts, and every
|
|
@@ -10,6 +11,13 @@ export declare const REDACTION_MARKS: Readonly<{
|
|
|
10
11
|
}>;
|
|
11
12
|
/** The bare mark — what a host compares against to tell that the engine withheld a value. */
|
|
12
13
|
export declare const REDACTION_MARK: "[redacted]";
|
|
14
|
+
/** The engine's notation for the credential renderer (`renderSecrets`): a credential value is the bare mark, a URL userinfo
|
|
15
|
+
* the credentials mark, and a text no reading can afford is the bare mark whole. Built from the table, so it follows it. */
|
|
16
|
+
export declare const REDACTION_NOTATION: SecretNotation;
|
|
17
|
+
/** The spelling a request-route rendering writes for a withheld query value or URL user (`«redacted»`) — shown to a person
|
|
18
|
+
* in a refusal or a route display, never written by a redaction pass. It is not a member of {@link REDACTION_MARKS}: the
|
|
19
|
+
* marks the readers below recognize are that table's four, and this spelling is not one of them. */
|
|
20
|
+
export declare const WITHHELD_VALUE_MARK = "\u00ABredacted\u00BB";
|
|
13
21
|
/** Where the marks sit in `s`, one [start, end) span at a time, leftmost first. Lazy: a reader that stops early (a display cut stops
|
|
14
22
|
* at its bound) pays for the marks it looked at, not for every mark an input of a million of them holds. */
|
|
15
23
|
export declare function eachRedactionMarkerSpan(s: string): Generator<[number, number], void, undefined>;
|
|
@@ -5,6 +5,12 @@ export const REDACTION_MARKS = Object.freeze({
|
|
|
5
5
|
path: "[redacted-path]",
|
|
6
6
|
});
|
|
7
7
|
export const REDACTION_MARK = REDACTION_MARKS.whole;
|
|
8
|
+
export const REDACTION_NOTATION = Object.freeze({
|
|
9
|
+
value: REDACTION_MARKS.whole,
|
|
10
|
+
byKind: Object.freeze({ "url-credentials": REDACTION_MARKS.credentials }),
|
|
11
|
+
overStrip: REDACTION_MARKS.whole,
|
|
12
|
+
});
|
|
13
|
+
export const WITHHELD_VALUE_MARK = "«redacted»";
|
|
8
14
|
const escapeLiteral = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9
15
|
const REDACTION_MARKER_RE = new RegExp(Object.values(REDACTION_MARKS).map(escapeLiteral).join("|"), "g");
|
|
10
16
|
export function* eachRedactionMarkerSpan(s) {
|
|
@@ -512,7 +512,11 @@ export interface ExecutionEnvFactoryContext {
|
|
|
512
512
|
* main session's cwd. A single-user/TOC factory SHOULD root the child env here (unless `isolation`
|
|
513
513
|
* requests a worktree — that wins); a multi-tenant/TOB factory minting isolated containers may ignore
|
|
514
514
|
* it. Absent on top-level tasks. Static shared-`executionEnv` deployments need nothing — the child
|
|
515
|
-
* already shares the parent env (and its cwd).
|
|
515
|
+
* already shares the parent env (and its cwd). When the parent works in a managed tree (a session's own
|
|
516
|
+
* tree), the child MUST be rooted at this hint or inside that tree: an env the factory roots elsewhere on
|
|
517
|
+
* the host — the base checkout the tree isolates, another tree — is refused before the child's first turn
|
|
518
|
+
* (`workspace.isolation_unavailable`, `factory_ignored_hint`); a declared sandbox off the host's disk
|
|
519
|
+
* (`hostLocalPaths: false` with `isolation: true`) is another namespace and is not judged.
|
|
516
520
|
*/
|
|
517
521
|
parentCwd?: string;
|
|
518
522
|
/**
|
|
@@ -746,6 +750,13 @@ export declare function declaredHostLocalPaths(env: Pick<ExecutionEnv, "capabili
|
|
|
746
750
|
* engine never presents a path it cannot vouch for as a host path. Total: it never throws.
|
|
747
751
|
*/
|
|
748
752
|
export declare function pathsAreHostLocal(env: Pick<ExecutionEnv, "capabilities">): boolean;
|
|
753
|
+
/**
|
|
754
|
+
* Is this environment a DECLARED sandbox off the host's disk — its paths another namespace's (`hostLocalPaths: false`) and its
|
|
755
|
+
* containment its own job (`isolation: true`)? The one reading that exempts an environment from comparing its paths with the
|
|
756
|
+
* caller's: the worktree request's guard and a delegated child's caller-tree floor both take it. Only the two declarations
|
|
757
|
+
* together earn it; an undeclared or non-isolated environment off the host's disk (an SSH host, a device) does not. Total.
|
|
758
|
+
*/
|
|
759
|
+
export declare function isDeclaredSandboxOffHost(env: Pick<ExecutionEnv, "capabilities">): boolean;
|
|
749
760
|
/**
|
|
750
761
|
* Does content this environment produces come from outside the deployment's trust boundary
|
|
751
762
|
* ({@link ExecutionEnvCapabilities.externalContentTarget})? Three states: `true`, `false`, or `"undeclared"` (absent, not a
|
package/dist/core/remote-env.js
CHANGED
|
@@ -188,6 +188,9 @@ export function declaredHostLocalPaths(env) {
|
|
|
188
188
|
export function pathsAreHostLocal(env) {
|
|
189
189
|
return declaredHostLocalPaths(env) === true;
|
|
190
190
|
}
|
|
191
|
+
export function isDeclaredSandboxOffHost(env) {
|
|
192
|
+
return declaredHostLocalPaths(env) === false && isIsolated(env);
|
|
193
|
+
}
|
|
191
194
|
export function targetIsExternal(env) {
|
|
192
195
|
return declaredCapability(env, "externalContentTarget") ?? UNDECLARED_CAPABILITY_READING.externalContentTarget.reads;
|
|
193
196
|
}
|
|
@@ -21,19 +21,45 @@ export declare function deploymentCanRerootChild(deps: Pick<RunnerDeps, "executi
|
|
|
21
21
|
* ONE judgment every reader of that fact takes
|
|
22
22
|
* (the delegation tool's worktree request, and the anchors of the rules the child inherits):
|
|
23
23
|
* · `honored` — the environment's root is where the child was asked to be (canonical on both sides);
|
|
24
|
-
* · `caller_tree` — it is not, and it lies inside the caller's own tree (`callerRoot
|
|
24
|
+
* · `caller_tree` — it is not, and it lies inside the caller's own tree (`callerRoot`, or the checkout the caller has switched
|
|
25
|
+
* to — `callerCheckout`, which can lie outside the root): the same filesystem, the wrong
|
|
25
26
|
* directory — a worktree request then fails (the child would write the caller's checkout);
|
|
26
27
|
* · `elsewhere` — neither: another filesystem namespace (a sandbox the factory minted). The child runs there, it is not
|
|
27
28
|
* in the worktree it was offered, and it takes the caller's path rules again at its own anchors.
|
|
28
29
|
* A path the environment cannot canonicalize is compared as spelled. Residual: two namespaces that hold the same path
|
|
29
30
|
* string, with a factory claiming to honor it, read `honored`.
|
|
30
31
|
*/
|
|
31
|
-
export declare function childPlacementOf(env: Pick<ExecutionEnv, "canonicalPath">, childRoot: string, asked: string | undefined, callerRoot: string): Promise<ChildPlacement>;
|
|
32
|
+
export declare function childPlacementOf(env: Pick<ExecutionEnv, "canonicalPath">, childRoot: string, asked: string | undefined, callerRoot: string, callerCheckout?: string): Promise<ChildPlacement>;
|
|
33
|
+
/** `p` as the environment resolves it, or as spelled when it cannot (the placement judgments' one spelling reading). */
|
|
34
|
+
export declare function canonicalOrSelf(env: Pick<ExecutionEnv, "canonicalPath">, p: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* The managed tree a delegated child was placed outside of — `undefined` when nothing binds it there. A caller whose root lies
|
|
37
|
+
* in a managed tree (a session's own tree, or a worktree the caller itself was started in) works in that tree; a child its
|
|
38
|
+
* environment did not place where it was asked (`placement` other than `honored`) must still start inside it (at or below the
|
|
39
|
+
* tree's root, canonical), or it would read and write the checkout the tree isolates. The caller's tree is read on the canonical
|
|
40
|
+
* spelling of its root (a symlink alias or a `.` segment names the same tree). Asked only on a placed leg (one a delegation
|
|
41
|
+
* caller placed; any other has no placement). Not bound: a child placed where asked, a caller outside every managed tree, and an
|
|
42
|
+
* environment that is a declared sandbox off the host's disk ({@link isDeclaredSandboxOffHost} — another namespace, the same
|
|
43
|
+
* reading the worktree request's guard exempts by).
|
|
44
|
+
*/
|
|
45
|
+
export declare function callerTreeMissed(env: ExecutionEnv, placement: ChildPlacement, callerRoot: string, childRoot: string): Promise<string | undefined>;
|
|
46
|
+
/** The refusal of a child placed outside the managed tree its caller works in ({@link callerTreeMissed}); `envCwd` is named too
|
|
47
|
+
* when the child's root is not its environment's own directory. */
|
|
48
|
+
export declare function factoryIgnoredHint(childRoot: string, envCwd: string, tree: string): Error & {
|
|
49
|
+
code: "workspace.isolation_unavailable";
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The placement seats a delegation caller hands its child (`RunInternals.callerRoot` / `callerCheckout`), read from where the
|
|
53
|
+
* caller works (`parentCwd`) and its task root (`callerRoot`) — the ONE reading every spawn lane takes (the delegation tool and
|
|
54
|
+
* both workflow lanes). A caller that names only where it works is its own root; the checkout seat is filled only when the caller
|
|
55
|
+
* has switched to a tree other than its root (it can lie outside that root). Neither named ⇒ no seats: no placement is judged.
|
|
56
|
+
*/
|
|
57
|
+
export declare function callerPlacementSeats(parentCwd: string | undefined, callerRoot: string | undefined): Pick<RunInternals, "callerRoot" | "callerCheckout">;
|
|
32
58
|
/** A delegated leg's placement: the place asked for is the hint (a minted worktree, an explicit cwd, the caller's own cwd)
|
|
33
59
|
* — or, for a worktree the factory mints itself (`isolation`), that worktree on the caller's host when the environment's
|
|
34
60
|
* paths are the host's (`pathsAreHostLocal`; any other environment's is another namespace). A leg no delegation caller
|
|
35
61
|
* placed (no `callerRoot`) has no placement and reads nothing. */
|
|
36
|
-
export declare function childPlacementOnLeg(env: ExecutionEnv, internals: Pick<RunInternals, "isolation" | "parentCwd"> & {
|
|
62
|
+
export declare function childPlacementOnLeg(env: ExecutionEnv, internals: Pick<RunInternals, "isolation" | "parentCwd" | "callerCheckout"> & {
|
|
37
63
|
readonly callerRoot: string;
|
|
38
64
|
}, root: string): Promise<ChildPlacement>;
|
|
39
65
|
/** The refusal of a worktree the caller minted for a child its environment placed in the caller's own tree. */
|
|
@@ -1,30 +1,53 @@
|
|
|
1
|
-
import { pathsAreHostLocal } from "../remote-env.js";
|
|
1
|
+
import { isDeclaredSandboxOffHost, pathsAreHostLocal } from "../remote-env.js";
|
|
2
|
+
import { managedTreeAt } from "../git-worktree-env.js";
|
|
2
3
|
import { validatePath } from "../effective-path-target.js";
|
|
3
4
|
import { installPolicyAnchors, installationAnchorsOf, installedFrom } from "../path-rule-binding.js";
|
|
4
5
|
import { CheckpointError } from "../checkpoint-store.js";
|
|
5
6
|
export function deploymentCanRerootChild(deps) {
|
|
6
7
|
return deps.executionEnvFactory !== undefined;
|
|
7
8
|
}
|
|
8
|
-
export async function childPlacementOf(env, childRoot, asked, callerRoot) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const r = await env.canonicalPath(p);
|
|
12
|
-
return r.ok ? r.value : p;
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return p;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const root = await canon(childRoot);
|
|
19
|
-
if (asked !== undefined && (await canon(asked)) === root)
|
|
9
|
+
export async function childPlacementOf(env, childRoot, asked, callerRoot, callerCheckout) {
|
|
10
|
+
const root = await canonicalOrSelf(env, childRoot);
|
|
11
|
+
if (asked !== undefined && (await canonicalOrSelf(env, asked)) === root)
|
|
20
12
|
return "honored";
|
|
21
|
-
|
|
13
|
+
return (await atOrBelow(env, root, callerRoot)) || (callerCheckout !== undefined && (await atOrBelow(env, root, callerCheckout))) ? "caller_tree" : "elsewhere";
|
|
14
|
+
}
|
|
15
|
+
export async function canonicalOrSelf(env, p) {
|
|
16
|
+
try {
|
|
17
|
+
const r = await env.canonicalPath(p);
|
|
18
|
+
return r.ok ? r.value : p;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return p;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function atOrBelow(env, root, dir) {
|
|
25
|
+
const tree = await canonicalOrSelf(env, dir);
|
|
22
26
|
const sep = tree.includes("\\") && !tree.includes("/") ? "\\" : "/";
|
|
23
|
-
return root === tree || root.startsWith(tree.endsWith(sep) ? tree : tree + sep)
|
|
27
|
+
return root === tree || root.startsWith(tree.endsWith(sep) ? tree : tree + sep);
|
|
28
|
+
}
|
|
29
|
+
export async function callerTreeMissed(env, placement, callerRoot, childRoot) {
|
|
30
|
+
if (placement === "honored")
|
|
31
|
+
return undefined;
|
|
32
|
+
const tree = managedTreeAt(await canonicalOrSelf(env, callerRoot))?.root;
|
|
33
|
+
if (tree === undefined || isDeclaredSandboxOffHost(env))
|
|
34
|
+
return undefined;
|
|
35
|
+
return (await atOrBelow(env, await canonicalOrSelf(env, childRoot), tree)) ? undefined : tree;
|
|
36
|
+
}
|
|
37
|
+
export function factoryIgnoredHint(childRoot, envCwd, tree) {
|
|
38
|
+
const where = envCwd === childRoot ? childRoot : `${childRoot} (its environment stands at ${envCwd})`;
|
|
39
|
+
return Object.assign(new Error(`The sub-agent was not started (factory_ignored_hint): the execution environment factory placed the child at ${where} while the session's tree is ${tree}, where its caller works — a child outside that tree would read and write the checkout it isolates. The factory must root the child at the parentCwd it is handed; the child is never started outside the tree instead.`), { code: "workspace.isolation_unavailable" });
|
|
40
|
+
}
|
|
41
|
+
export function callerPlacementSeats(parentCwd, callerRoot) {
|
|
42
|
+
const root = callerRoot ?? parentCwd;
|
|
43
|
+
return {
|
|
44
|
+
...(root !== undefined ? { callerRoot: root } : {}),
|
|
45
|
+
...(parentCwd !== undefined && callerRoot !== undefined && parentCwd !== callerRoot ? { callerCheckout: parentCwd } : {}),
|
|
46
|
+
};
|
|
24
47
|
}
|
|
25
48
|
export function childPlacementOnLeg(env, internals, root) {
|
|
26
49
|
const asked = internals.isolation === "worktree" ? (pathsAreHostLocal(env) ? root : undefined) : internals.parentCwd;
|
|
27
|
-
return childPlacementOf(env, root, asked, internals.callerRoot);
|
|
50
|
+
return childPlacementOf(env, root, asked, internals.callerRoot, internals.callerCheckout);
|
|
28
51
|
}
|
|
29
52
|
export function worktreeNotHonored(cwd) {
|
|
30
53
|
return Object.assign(new Error(`isolation "worktree" was requested but cannot be honored: the execution environment factory placed the sub-agent at "${cwd}", inside the caller's own tree, instead of the worktree it was offered. The sub-agent was not started (fail-closed — no silent fallback to the shared working tree).`), { code: "isolation.unavailable" });
|
|
@@ -706,12 +706,14 @@ export interface Prepared {
|
|
|
706
706
|
* plane that owns the write gate — the read-only plane is internal to `inject`/`harvest`). */
|
|
707
707
|
engine: MemoryEngine;
|
|
708
708
|
handle: MemorySessionHandle;
|
|
709
|
+
/** The session's scope contract (`TaskSpec.memory.scopeContract`): the owner of `handle.writeScope` is read under it. */
|
|
710
|
+
scopeContract: "v2" | undefined;
|
|
709
711
|
/** Merged injection across all planes (single-root sessions: identical to engine.inject(handle)). */
|
|
710
|
-
inject: () => import("../memory-engine/engine.js").MemoryInjection
|
|
712
|
+
inject: () => Promise<import("../memory-engine/engine.js").MemoryInjection>;
|
|
711
713
|
harvest: (phase?: "checkpoint" | "terminal") => Promise<HarvestReport | undefined>;
|
|
712
714
|
/** End this mount's session leg WITHOUT a harvest: the run that mounted it will never reach its
|
|
713
715
|
* terminal harvest (a prepare that failed after the mount). Never throws. */
|
|
714
|
-
release: () => void
|
|
716
|
+
release: () => Promise<void>;
|
|
715
717
|
/**
|
|
716
718
|
* The session's capture opt-out face (the `TaskStream.optOutMemoryCapture`
|
|
717
719
|
* verb's target; host-API only — no tool face reads it, §2.6). `flip` re-adjudicates the
|
|
@@ -757,15 +759,16 @@ export interface Prepared {
|
|
|
757
759
|
execIsExternalContent: boolean;
|
|
758
760
|
};
|
|
759
761
|
/**
|
|
760
|
-
* The delegation-settlement handle:
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
* an `"off"` deployment keeps the pre-336 accepted-cost posture byte-level.
|
|
762
|
+
* The delegation-settlement handle: what a settlement writer needs. Consumers (the subagent
|
|
763
|
+
* background leg's write-ahead + terminal observation, the tool wrap's sync unattestable row)
|
|
764
|
+
* can outlive this prepared leg, so they write through these fields alone — never through the
|
|
765
|
+
* live engine/session objects above. Present only under `memoryProvenance: "carry"` (the
|
|
766
|
+
* default): an `"off"` deployment keeps the pre-336 accepted-cost posture byte-level.
|
|
766
767
|
*/
|
|
767
768
|
settlement?: {
|
|
768
|
-
/** The WRITE plane's
|
|
769
|
+
/** The WRITE plane's governance store (the settlement / lineage / challenge documents). */
|
|
770
|
+
governance: import("../memory-engine/types.js").MemoryGovernanceDocs;
|
|
771
|
+
/** The WRITE plane's control-plane dir (the pollution marker and hold custody files). */
|
|
769
772
|
controlDir: string;
|
|
770
773
|
sessionId: string;
|
|
771
774
|
provenance: "carry";
|
|
@@ -2308,6 +2311,12 @@ export interface RunInternals {
|
|
|
2308
2311
|
* leg, a caller that does not delegate through core).
|
|
2309
2312
|
*/
|
|
2310
2313
|
callerRoot?: string;
|
|
2314
|
+
/**
|
|
2315
|
+
* The checkout the SPAWNING run writes in when it has switched to a tree other than its root (an EnterWorktree tree — it can
|
|
2316
|
+
* lie outside {@link callerRoot}, since a managed tree hangs at the repository root): a child placed inside it is placed in the
|
|
2317
|
+
* caller's own tree as well. Filled ONLY by core delegation callers beside {@link callerRoot}; absent when the caller writes in its root.
|
|
2318
|
+
*/
|
|
2319
|
+
callerCheckout?: string;
|
|
2311
2320
|
/**
|
|
2312
2321
|
* `parentCwd` is a worktree the caller minted for THIS child (the delegation tool's `isolation: "worktree"`): a child
|
|
2313
2322
|
* its environment placed inside the caller's own tree instead is refused before it starts (`isolation.unavailable`).
|
|
@@ -93,7 +93,7 @@ export function createSettlementLedger(call) {
|
|
|
93
93
|
`(\`attestation\`), never a resolver's member; denied fail-closed rather than recording a settlement nobody can attribute`, contractRefusal(origin));
|
|
94
94
|
}
|
|
95
95
|
const edited = resolved.action === "allow" && resolved.updatedInput !== undefined;
|
|
96
|
-
const licensed = () => edited ? licenseCovers(record.inputDigest, resolved.updatedInput) : licenseCovers(record.inputDigest, req.args) && (resolved.presentedInput === undefined || licenseCovers(record.inputDigest, resolved.presentedInput));
|
|
96
|
+
const licensed = () => edited ? licenseCovers(record.inputDigest, call.toolName, resolved.updatedInput) : licenseCovers(record.inputDigest, call.toolName, req.args) && (resolved.presentedInput === undefined || licenseCovers(record.inputDigest, call.toolName, resolved.presentedInput));
|
|
97
97
|
const bound = record?.settlement !== undefined && record.origin === origin && sameClasses(record.classes, asked.classes) ? record.settlement : undefined;
|
|
98
98
|
const refusal = bound !== undefined && SETTLEMENT_IS_REFUSAL[bound.kind] ? bound : undefined;
|
|
99
99
|
if (resolved.action === "allow") {
|
|
@@ -134,7 +134,7 @@ export function createSettlementLedger(call) {
|
|
|
134
134
|
return { decision, deniedBy: refusal ? "ask_resolution" : "policy" };
|
|
135
135
|
},
|
|
136
136
|
keepForBytes(runs) {
|
|
137
|
-
if (settled !== undefined && !licenseCovers(settled.licensed, runs))
|
|
137
|
+
if (settled !== undefined && !licenseCovers(settled.licensed, call.toolName, runs))
|
|
138
138
|
settled = undefined;
|
|
139
139
|
},
|
|
140
140
|
causeOf(decision) {
|
|
@@ -34,5 +34,5 @@ export function consumeInheritedAskGrant(grants, onAsk, humanReviewRef, decision
|
|
|
34
34
|
const settlement = attestationOf(grant.settled, req)?.settlement;
|
|
35
35
|
if (settlement === undefined || decision.action !== "ask")
|
|
36
36
|
return reused;
|
|
37
|
-
return attest(reused, req, { settlement, ...(decision.origin !== undefined ? { origin: decision.origin } : {}), ...(decision.classes !== undefined ? { classes: decision.classes } : {}), inputDigest: exactBoundInputHashOf(grant.presented) });
|
|
37
|
+
return attest(reused, req, { settlement, ...(decision.origin !== undefined ? { origin: decision.origin } : {}), ...(decision.classes !== undefined ? { classes: decision.classes } : {}), inputDigest: exactBoundInputHashOf(req.toolName, grant.presented) });
|
|
38
38
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import type { Model } from "../../internal/llm.js";
|
|
16
16
|
import type { Brain, ModelRoles, ModelRef, TaskSpec } from "../types.js";
|
|
17
17
|
import { type DistillerChatFn } from "../memory-engine/distiller.js";
|
|
18
|
-
import { type RunMemoryConsolidationOptions, type ConsolidationDriverEngine, type ConsolidationWriteJudge } from "../memory-engine/consolidation-driver.js";
|
|
18
|
+
import { type RunMemoryConsolidationOptions, type ConsolidationCompliance, type ConsolidationDriverEngine, type ConsolidationWriteJudge } from "../memory-engine/consolidation-driver.js";
|
|
19
19
|
import { type MemoryConsolidationOptions } from "../memory-engine/consolidation.js";
|
|
20
20
|
import type { LlmDistillerContract } from "../memory-engine/distiller.js";
|
|
21
21
|
import type { EngineNotice } from "../engine-notice.js";
|
|
@@ -65,7 +65,8 @@ export declare function consolidationSeatResolvable(deps: MemoryConsolidationDri
|
|
|
65
65
|
* failure table settles the run (zero-write on mint failure, `_incomplete` on non-convergence), this
|
|
66
66
|
* bridge only relays the run's advisory notices to `onNotice` and routes a seat/engine fault to
|
|
67
67
|
* `onError(phase:"memory")`. Adds no failure semantics of its own — the trigger is the only new thing.
|
|
68
|
-
* The write judge is the LEG's; its refusal is a person's standing rule at work, so it is a refusal NOTICE, never a fault
|
|
68
|
+
* The write judge is the LEG's; its refusal is a person's standing rule at work, so it is a refusal NOTICE, never a fault —
|
|
69
|
+
* as is the compliance posture's denial; a posture seat that faulted reaches `onError`.
|
|
69
70
|
*/
|
|
70
71
|
export declare function autoRunConsolidationFromRecommendation(args: {
|
|
71
72
|
deps: MemoryConsolidationDriverDeps;
|
|
@@ -73,6 +74,8 @@ export declare function autoRunConsolidationFromRecommendation(args: {
|
|
|
73
74
|
scope: string;
|
|
74
75
|
sessionId: string;
|
|
75
76
|
writeJudge: ConsolidationWriteJudge;
|
|
77
|
+
/** The run's compliance veto: the deployment's posture seat, the leg's scope contract and its own denies. */
|
|
78
|
+
compliance: ConsolidationCompliance;
|
|
76
79
|
onNotice?: (notice: EngineNotice) => void;
|
|
77
80
|
onError?: (err: unknown, ctx: {
|
|
78
81
|
phase: "memory";
|
|
@@ -111,7 +114,7 @@ export declare function autoRunOnRecommendationEffective(deps: MemoryConsolidati
|
|
|
111
114
|
* a scope forever: the edge sat disarmed, nothing advanced `lastRunAt`.) A gate the engine cannot read
|
|
112
115
|
* answers `false` — the verbs would refuse loudly on it anyway.
|
|
113
116
|
*/
|
|
114
|
-
export declare function scopeHasUnconsumedRecommendation(engine: Pick<ConsolidationDriverEngine, "readConsolidationGate">, scope: string): boolean
|
|
117
|
+
export declare function scopeHasUnconsumedRecommendation(engine: Pick<ConsolidationDriverEngine, "readConsolidationGate">, scope: string): Promise<boolean>;
|
|
115
118
|
/**
|
|
116
119
|
* The auto-consolidation ARMING door (bad-value loudness, three states), called from
|
|
117
120
|
* the prepare config doors at construction on every leg. A garbage value refuses; a CONTRADICTION
|
|
@@ -69,10 +69,10 @@ export function consolidationSeatResolvable(deps) {
|
|
|
69
69
|
return (roleModelIfSet("consolidate", {}, { models, roles: deps.roles }) ?? roleModelIfSet("summarize", {}, { models, roles: deps.roles })) !== undefined;
|
|
70
70
|
}
|
|
71
71
|
export function autoRunConsolidationFromRecommendation(args) {
|
|
72
|
-
const { deps, engine, scope, sessionId, writeJudge, onNotice, onError } = args;
|
|
72
|
+
const { deps, engine, scope, sessionId, writeJudge, compliance, onNotice, onError } = args;
|
|
73
73
|
return (async () => {
|
|
74
74
|
try {
|
|
75
|
-
await runMemoryConsolidationDriver(engine, scope, { ...resolveMemoryConsolidationDriver(deps), writeJudge, onNotice });
|
|
75
|
+
await runMemoryConsolidationDriver(engine, scope, { ...resolveMemoryConsolidationDriver(deps), writeJudge, compliance, onNotice });
|
|
76
76
|
}
|
|
77
77
|
catch (err) {
|
|
78
78
|
if (deliverWriteRefusal(err, scope, onNotice))
|
|
@@ -94,8 +94,8 @@ export function autoRunOnRecommendationEffective(deps) {
|
|
|
94
94
|
return false;
|
|
95
95
|
return AUTO_RUN_ON_RECOMMENDATION_DEFAULT && deps.memoryConsolidation !== undefined && consolidationSeatResolvable(deps);
|
|
96
96
|
}
|
|
97
|
-
export function scopeHasUnconsumedRecommendation(engine, scope) {
|
|
98
|
-
const row = engine.readConsolidationGate(scope);
|
|
97
|
+
export async function scopeHasUnconsumedRecommendation(engine, scope) {
|
|
98
|
+
const row = await engine.readConsolidationGate(scope);
|
|
99
99
|
return row !== undefined && recommendationUnconsumed(row);
|
|
100
100
|
}
|
|
101
101
|
function autoRunRefusal(message) {
|
|
@@ -57,5 +57,6 @@ export interface ConsolidationWriteJudgeLeg {
|
|
|
57
57
|
* engine's leg passes the same `input` and its `leg`, so the same rows give the same answer on both.
|
|
58
58
|
*/
|
|
59
59
|
export declare function createConsolidationWriteJudge(input: ConsolidationWriteJudgeInput, leg?: ConsolidationWriteJudgeLeg): ConsolidationWriteJudge;
|
|
60
|
-
/** Deliver a
|
|
60
|
+
/** Deliver a standing judgment's refusal of a consolidation run — the write judge's or the compliance posture's — as the
|
|
61
|
+
* verb's refusal notice; false (nothing delivered) for any other error. */
|
|
61
62
|
export declare function deliverWriteRefusal(err: unknown, scope: string, onNotice: ((notice: EngineNotice) => void) | undefined): boolean;
|
|
@@ -44,9 +44,10 @@ function hostLeg(input, owner) {
|
|
|
44
44
|
facts: () => ({ face: engineWriteFace(), ...(root !== undefined ? { root, cwd: root } : {}) }),
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
const STANDING_REFUSAL_CODES = [CONSOLIDATION_WRITE_REFUSED_CODE, "config.compliance_denied"];
|
|
47
48
|
export function deliverWriteRefusal(err, scope, onNotice) {
|
|
48
|
-
if (!(err instanceof ConsolidationRefusedError) || err.code
|
|
49
|
+
if (!(err instanceof ConsolidationRefusedError) || !STANDING_REFUSAL_CODES.includes(err.code))
|
|
49
50
|
return false;
|
|
50
|
-
deliverEngineNotice(onNotice, memoryConsolidationRefusedNotice({ code:
|
|
51
|
+
deliverEngineNotice(onNotice, memoryConsolidationRefusedNotice({ code: err.code, scope, reason: err.message, occurrenceId: err.occurrenceId }));
|
|
51
52
|
return true;
|
|
52
53
|
}
|
|
@@ -199,11 +199,15 @@ export declare function readRootsOver(seats: {
|
|
|
199
199
|
readonly store: () => string | undefined;
|
|
200
200
|
readonly onHeld: (dir: string, store: string) => void;
|
|
201
201
|
}): ReadRootsSeat;
|
|
202
|
+
/** The deny seats a shell read boundary carries for one compiled table pair, through the ONE adapter every face mounting a
|
|
203
|
+
* deny table uses (`readDenySeat`: zero entries is no judge), resolved once per table. */
|
|
204
|
+
type WriteDenySeat = {
|
|
205
|
+
readonly writeDenyMatch?: (p: string) => string | null;
|
|
206
|
+
readonly writeDenyGuardsReads?: (pattern: string) => boolean;
|
|
207
|
+
};
|
|
202
208
|
export declare function denySeatsOf(t: PathTables): {
|
|
203
209
|
readonly read: ReadDenySeat;
|
|
204
|
-
readonly write:
|
|
205
|
-
readonly writeDenyMatch?: (p: string) => string | null;
|
|
206
|
-
};
|
|
210
|
+
readonly write: WriteDenySeat;
|
|
207
211
|
};
|
|
208
212
|
/**
|
|
209
213
|
* The leg's read stations as ONE gate input, each judgment on its call's pinned read of the person's rules: a station is
|
|
@@ -263,3 +267,4 @@ export declare function ruleRowsDroppedNotice(onNotice: RunnerDeps["onNotice"],
|
|
|
263
267
|
readonly sessionId: string;
|
|
264
268
|
readonly runId: string;
|
|
265
269
|
}): (rows: EffectivePermissionRules["droppedRows"]) => void;
|
|
270
|
+
export {};
|
|
@@ -303,6 +303,7 @@ export function createPersonPathRows(cfg) {
|
|
|
303
303
|
},
|
|
304
304
|
matchPath: (path) => judging().writeDeny.matchPath(path),
|
|
305
305
|
matchTarget: (canonicalKey, lexicalView, opts) => judging().writeDeny.matchTarget(canonicalKey, lexicalView, opts),
|
|
306
|
+
guardsReads: (pattern) => judging().writeDeny.guardsReads?.(pattern) === true,
|
|
306
307
|
homeViews: readDeny.homeViews,
|
|
307
308
|
forCall: (id) => tablesFor(id).writeDeny,
|
|
308
309
|
};
|
|
@@ -335,7 +336,10 @@ const SEATS = new WeakMap();
|
|
|
335
336
|
export function denySeatsOf(t) {
|
|
336
337
|
let seats = SEATS.get(t);
|
|
337
338
|
if (seats === undefined) {
|
|
338
|
-
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
|
+
};
|
|
339
343
|
SEATS.set(t, seats);
|
|
340
344
|
}
|
|
341
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
|
}
|
|
@@ -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)
|
|
@@ -70,8 +70,11 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
70
70
|
hostTaskId: string;
|
|
71
71
|
/** borrowed-readonly — the registry scope the Workflow mount registers in. */
|
|
72
72
|
taskScope: string;
|
|
73
|
-
/** 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`. */
|
|
74
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;
|
|
75
78
|
/** borrowed-readonly — this leg's own target (absent: none), the fence the Workflow mount hands every agent it spawns. */
|
|
76
79
|
ownTarget: import("../remote-env.js").PlacementTarget | undefined;
|
|
77
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);
|
|
@@ -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,
|