@sema-agent/core 7.62.0 → 7.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +936 -0
- package/dist/agents/cc-peer-directory.js +1 -0
- package/dist/agents/cc-peer-wire.d.ts +4 -0
- package/dist/agents/cc-peer-wire.js +1 -0
- package/dist/agents/cc-uds-peer-channel.js +5 -0
- package/dist/agents/cross-session-judge.d.ts +3 -1
- package/dist/agents/cross-session-judge.js +4 -1
- package/dist/agents/peer-directory.d.ts +8 -0
- package/dist/agents/peer-directory.js +4 -0
- package/dist/agents/peer-held-queue.d.ts +9 -3
- package/dist/agents/peer-held-queue.js +12 -9
- package/dist/agents/peer-idle.d.ts +20 -1
- package/dist/agents/peer-idle.js +23 -12
- package/dist/agents/peer-notice-route.d.ts +16 -5
- package/dist/agents/peer-notice-route.js +11 -9
- package/dist/agents/peer-notices.d.ts +25 -8
- package/dist/agents/peer-notices.js +6 -1
- package/dist/agents/peer-session-drain.d.ts +32 -6
- package/dist/agents/peer-session-drain.js +100 -26
- package/dist/agents/send-message-tool.d.ts +7 -0
- package/dist/agents/send-message-tool.js +18 -6
- package/dist/agents/subagent-transcript-placement.d.ts +23 -0
- package/dist/agents/subagent-transcript-placement.js +14 -0
- package/dist/agents/subagent.js +102 -54
- package/dist/brain/route-adjudicator.js +9 -4
- package/dist/core/allow-entry.d.ts +4 -0
- package/dist/core/approval-object.js +1 -1
- package/dist/core/arg-summary.js +1 -1
- package/dist/core/ask-origin.d.ts +1 -1
- package/dist/core/ask-origin.js +2 -2
- package/dist/core/ask-question.d.ts +2 -2
- package/dist/core/ask-unresolvable-notice.d.ts +13 -4
- package/dist/core/ask-unresolvable-notice.js +10 -3
- package/dist/core/auto-compaction.d.ts +7 -5
- package/dist/core/background-agent-store.d.ts +7 -0
- package/dist/core/background-agent-store.js +3 -0
- package/dist/core/canonical-json.d.ts +23 -13
- package/dist/core/canonical-json.js +4 -4
- package/dist/core/checkpoint-queries.d.ts +50 -4
- package/dist/core/checkpoint-queries.js +42 -17
- 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 +28 -11
- 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/context-settings.d.ts +40 -9
- package/dist/core/context-settings.js +32 -10
- package/dist/core/engine-attestation.d.ts +27 -7
- package/dist/core/engine-attestation.js +5 -1
- package/dist/core/engine-notice.d.ts +43 -5
- package/dist/core/extension-requester.d.ts +9 -0
- package/dist/core/extension-requester.js +7 -0
- package/dist/core/file-history-store.d.ts +28 -0
- package/dist/core/file-history-store.js +48 -5
- package/dist/core/fs-write-gate-policy.js +1 -1
- package/dist/core/gate-fold.js +2 -0
- package/dist/core/gate-lanes.js +2 -0
- package/dist/core/gate-outcome.d.ts +39 -2
- package/dist/core/gate-outcome.js +20 -1
- package/dist/core/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 +17 -3
- package/dist/core/leg-identity.d.ts +19 -1
- package/dist/core/leg-identity.js +12 -0
- package/dist/core/mailbox-store.d.ts +39 -4
- package/dist/core/mailbox-store.js +14 -2
- package/dist/core/memory-engine/consolidation-driver.d.ts +32 -17
- package/dist/core/memory-engine/consolidation-driver.js +99 -98
- package/dist/core/memory-engine/consolidation.d.ts +74 -10
- package/dist/core/memory-engine/consolidation.js +183 -11
- package/dist/core/memory-engine/control-objects.d.ts +25 -0
- package/dist/core/memory-engine/control-objects.js +151 -0
- package/dist/core/memory-engine/control-plane-adoption.d.ts +48 -0
- package/dist/core/memory-engine/control-plane-adoption.js +159 -0
- package/dist/core/memory-engine/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 +58 -40
- package/dist/core/memory-engine/delegation-settlement.js +270 -85
- package/dist/core/memory-engine/dual-root.d.ts +12 -6
- package/dist/core/memory-engine/dual-root.js +11 -7
- package/dist/core/memory-engine/engine.d.ts +136 -58
- package/dist/core/memory-engine/engine.js +491 -394
- 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 +62 -60
- package/dist/core/memory-engine/file-backend.js +122 -198
- package/dist/core/memory-engine/index.d.ts +8 -7
- package/dist/core/memory-engine/index.js +7 -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 +127 -46
- package/dist/core/memory-engine/layout.js +264 -109
- package/dist/core/memory-engine/memory-backend-contract.d.ts +26 -1
- package/dist/core/memory-engine/memory-backend-contract.js +476 -0
- package/dist/core/memory-engine/memory-deployment.d.ts +42 -11
- package/dist/core/memory-engine/memory-deployment.js +54 -15
- package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
- package/dist/core/memory-engine/origin-clearance.js +68 -9
- package/dist/core/memory-engine/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 +37 -2
- package/dist/core/memory-engine/session-write-home.js +38 -11
- 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 +155 -19
- package/dist/core/memory-engine/types.js +2 -0
- package/dist/core/memory.js +15 -6
- package/dist/core/mode-policy.js +3 -3
- package/dist/core/mods/agent-stations.d.ts +18 -0
- package/dist/core/mods/agent-stations.js +8 -6
- package/dist/core/mods/extension-call.d.ts +4 -0
- package/dist/core/mods/extension-call.js +8 -0
- package/dist/core/mods/stations.d.ts +20 -1
- package/dist/core/mods/stations.js +21 -2
- package/dist/core/mods/tool-call.js +3 -4
- package/dist/core/parent-spec-seat.d.ts +2 -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/peer-channel.d.ts +5 -0
- package/dist/core/permission-rule-consent.d.ts +26 -8
- package/dist/core/permission-rule-consent.js +76 -36
- package/dist/core/permission-rule-store.d.ts +72 -13
- package/dist/core/permission-rule-store.js +29 -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/refusal-echo.d.ts +20 -0
- package/dist/core/refusal-echo.js +33 -0
- package/dist/core/remote-env.d.ts +12 -1
- package/dist/core/remote-env.js +3 -0
- package/dist/core/retention.d.ts +180 -10
- package/dist/core/retention.js +45 -0
- package/dist/core/retired-keys.d.ts +5 -0
- package/dist/core/retired-keys.js +3 -0
- package/dist/core/rule-offer-read.d.ts +0 -4
- package/dist/core/rule-offer-read.js +2 -18
- package/dist/core/runner/child-tree.d.ts +29 -3
- package/dist/core/runner/child-tree.js +39 -16
- package/dist/core/runner/classifier-ladder.d.ts +7 -1
- package/dist/core/runner/classifier-ladder.js +4 -2
- package/dist/core/runner/compact-session.js +10 -7
- package/dist/core/runner/compaction-call-options.d.ts +7 -7
- package/dist/core/runner/compaction-call-options.js +3 -2
- package/dist/core/runner/contracts.d.ts +39 -11
- package/dist/core/runner/delegation-owner.d.ts +10 -3
- package/dist/core/runner/delegation-owner.js +4 -1
- package/dist/core/runner/gate-exit.d.ts +6 -0
- package/dist/core/runner/gate-exit.js +13 -4
- package/dist/core/runner/inherited-ask-grants.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.d.ts +10 -5
- package/dist/core/runner/memory-consolidation-driver.js +12 -9
- 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 +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +7 -4
- package/dist/core/runner/prepare-config-doors.js +4 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +2 -2
- package/dist/core/runner/prepare-execution-env.js +17 -6
- package/dist/core/runner/prepare-gate-stations.d.ts +5 -0
- package/dist/core/runner/prepare-gate-stations.js +5 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +2 -1
- package/dist/core/runner/prepare-hands-readface.js +5 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +13 -9
- package/dist/core/runner/prepare-inherited-gate.js +12 -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 +7 -2
- package/dist/core/runner/prepare-memory.js +41 -39
- package/dist/core/runner/prepare-park-ask.js +4 -3
- package/dist/core/runner/prepare-policy-chain.js +7 -7
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-task.js +26 -18
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +3 -2
- package/dist/core/runner/prepare-workspace-restore.js +3 -6
- package/dist/core/runner/resume-admission.d.ts +2 -2
- package/dist/core/runner/resume-admission.js +2 -23
- package/dist/core/runner/role-resolution-table.d.ts +98 -0
- package/dist/core/runner/role-resolution-table.js +62 -0
- package/dist/core/runner/run-compaction-machinery.js +2 -2
- package/dist/core/runner/run-identity-wiring.js +12 -9
- package/dist/core/runner/run-leg.js +9 -5
- package/dist/core/runner/run-notification-lane.js +22 -22
- package/dist/core/runner/run-recovery-lanes.js +3 -3
- package/dist/core/runner/run-settle-and-teardown.js +3 -2
- package/dist/core/runner/run-terminal-adoption.js +1 -1
- package/dist/core/runner/run-turn-boundary.js +14 -15
- package/dist/core/runner/runtask.js +1 -1
- package/dist/core/runner/terminal-account.js +1 -1
- package/dist/core/runner/tool-occurrence.d.ts +4 -2
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner-deps.d.ts +7 -3
- package/dist/core/secret-env.d.ts +1 -1
- package/dist/core/secret-env.js +4 -4
- package/dist/core/session-checkout.d.ts +168 -0
- package/dist/core/session-checkout.js +579 -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/shell-read-silence.js +8 -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/peer-directory-contract.js +8 -1
- package/dist/core/store-contracts/session-store-contract.js +39 -0
- package/dist/core/task-event.d.ts +30 -5
- package/dist/core/task-notification.d.ts +119 -32
- package/dist/core/task-notification.js +186 -100
- package/dist/core/task-registry-agent.d.ts +25 -2
- package/dist/core/task-registry-agent.js +56 -22
- package/dist/core/task-registry-shared.d.ts +33 -11
- package/dist/core/task-registry.d.ts +33 -9
- package/dist/core/task-registry.js +36 -18
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +27 -2
- package/dist/core/tool-errors.d.ts +14 -6
- package/dist/core/tool-errors.js +1 -1
- package/dist/core/tool-policy.d.ts +32 -13
- package/dist/core/tool-policy.js +27 -17
- package/dist/core/tool-result-store.d.ts +20 -0
- package/dist/core/tool-spec.d.ts +42 -19
- package/dist/core/trace.d.ts +3 -2
- 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/workflow-journal-store.d.ts +11 -0
- package/dist/core/workflow-journal-store.js +7 -0
- package/dist/core/workflow-run-store.d.ts +9 -0
- package/dist/core/workflow-run-store.js +6 -0
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/compaction/compaction.d.ts +2 -1
- package/dist/engine/harness/types.d.ts +67 -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 +30 -1
- package/dist/engine/session/session.js +48 -1
- package/dist/index.d.ts +12 -7
- package/dist/index.js +12 -7
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +8 -1
- package/dist/orchestration/run-workflow-tool.js +8 -0
- package/dist/orchestration/workflow-types.d.ts +2 -1
- package/dist/orchestration/workflow.d.ts +6 -0
- package/dist/orchestration/workflow.js +5 -2
- package/dist/stores/file/checkpoint-store.d.ts +6 -0
- package/dist/stores/file/checkpoint-store.js +4 -1
- package/dist/stores/file/file-history-store.d.ts +13 -0
- package/dist/stores/file/file-history-store.js +75 -13
- package/dist/stores/file/index.d.ts +11 -1
- package/dist/stores/file/index.js +7 -11
- package/dist/stores/file/permission-rule-store.d.ts +23 -0
- package/dist/stores/file/permission-rule-store.js +75 -7
- package/dist/stores/file/session-store.js +2 -1
- package/dist/stores/file/tool-result-store.d.ts +14 -0
- package/dist/stores/file/tool-result-store.js +39 -2
- package/dist/stores/file/workflow-journal-store.d.ts +4 -0
- package/dist/stores/file/workflow-journal-store.js +17 -0
- package/dist/stores/file/workflow-run-store.d.ts +3 -0
- package/dist/stores/file/workflow-run-store.js +15 -0
- package/dist/tools/fs/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 +28 -3
- package/dist/tools/fs/read-deny.js +18 -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.d.ts +8 -2
- package/dist/tools/fs/shell-read-check.js +16 -14
- 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 +135 -11
- package/wire-changes/core-stores-sql@7.63.0.json +30 -0
- package/wire-changes/core-stores-sql@7.64.0.json +30 -0
- package/wire-changes/core@7.63.0.json +3523 -0
- package/wire-changes/core@7.64.0.json +2653 -0
- package/wire-changes/mods-kernel@7.63.0.json +30 -0
- package/wire-changes/mods-kernel@7.64.0.json +30 -0
- package/wire-changes/primitives@7.63.0.json +445 -0
- package/wire-changes/primitives@7.64.0.json +30 -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
package/dist/core/retention.js
CHANGED
|
@@ -11,6 +11,51 @@ export function readRetentionDeclaration(name, value) {
|
|
|
11
11
|
}
|
|
12
12
|
export const RETENTION_CASCADE_DOMAINS = Object.freeze(["checkpoints", "session-trees", "orphan-tool-results"]);
|
|
13
13
|
export const RETENTION_CASCADE_EXEMPT = Object.freeze(["session-pollution", "session-capture-optout", "lineage.json"]);
|
|
14
|
+
function deepFreeze(value) {
|
|
15
|
+
if (typeof value === "object" && value !== null) {
|
|
16
|
+
for (const member of Object.values(value))
|
|
17
|
+
deepFreeze(member);
|
|
18
|
+
Object.freeze(value);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
export const RETENTION_CASCADE = deepFreeze({
|
|
23
|
+
workflowJournalStore: { legs: [{ domain: "session-trees", step: 1, verb: "deleteRun", selects: "the journal of each terminal workflow run the session started, found through the run store's listByScope session filter while the run rows still exist (a running run is a live reference, so the tree is not deleted)" }] },
|
|
24
|
+
workflowRunStore: { legs: [{ domain: "session-trees", step: 2, verb: "deleteBySession", selects: "the session's terminal workflow runs in its scope; answers the run ids it deleted" }] },
|
|
25
|
+
backgroundAgentStore: { legs: [{ domain: "session-trees", step: 4, verb: "delete", selects: "each terminal row listBySession names for the session (a running or parked row is a live reference)" }] },
|
|
26
|
+
rosterStore: { legs: [{ domain: "session-trees", step: 5, verb: "releaseAgent", selects: "every agent whose roster entry names the session as its session" }] },
|
|
27
|
+
checkpointStore: {
|
|
28
|
+
legs: [
|
|
29
|
+
{ domain: "session-trees", step: 6, verb: "deleteSessionCheckpoints", selects: "the session's checkpoint rows in any status, guarded by the session row's owner (so it runs while the row exists)" },
|
|
30
|
+
{ domain: "checkpoints", verb: "reap", selects: "the scope's pending rows whose deadline is before the call's cutoff, flipped to expired (no row is deleted)" },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
toolResultStore: {
|
|
34
|
+
legs: [
|
|
35
|
+
{ domain: "session-trees", step: 7, verb: "deleteBySession", selects: "the entries whose owner record names the session" },
|
|
36
|
+
{ domain: "orphan-tool-results", verb: "deleteUnattributable", selects: "the entries stored with no owner record, older than the call's cutoff" },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
sessionPolicyStore: { legs: [{ domain: "session-trees", step: 8, verb: "deleteBySession", selects: "the session's permission rules" }] },
|
|
40
|
+
fileHistoryStore: { legs: [{ domain: "session-trees", step: 9, verb: "deleteBySession", selects: "the session's whole history scope (the scope is the session id): boundaries, version records, pristine baselines, and the blobs no other scope references" }] },
|
|
41
|
+
mailboxStore: {
|
|
42
|
+
legs: [
|
|
43
|
+
{ domain: "session-trees", step: 3, verb: "drop", selects: "the box of each terminal background-agent row backgroundAgentStore.listBySession names for the session (the row's scope and handle), found through those rows while they still exist" },
|
|
44
|
+
{ domain: "session-trees", step: 10, verb: "drop", fence: "retireRecipient", selects: "the session's box (its peer session handle) in the session owner's scope; the fence is the optional retireRecipient pair's — run first, it refuses deliveries from then on, and a store without the pair (the bundled two) keeps no recipient lifecycle and has its box dropped" },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
sessionStore: {
|
|
48
|
+
legs: [
|
|
49
|
+
{ domain: "session-trees", step: 11, verb: "delete", selects: "the session's row and its whole log (a placed subagent row is its agent row's joint reap: release after a winning delete)" },
|
|
50
|
+
{ domain: "checkpoints", verb: "unpin", selects: "the session each expired checkpoint pinned" },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
usageWindowStore: { exempt: "a usage-governance ledger keyed by principal: token and cost counts, no session content, bounded by the deployment's live window set" },
|
|
54
|
+
memoryStore: { exempt: "memory is not session data: entries outlive the session that wrote them, and the governance records about them are RETENTION_CASCADE_EXEMPT" },
|
|
55
|
+
});
|
|
56
|
+
export const RETENTION_SESSION_TREE_STEPS = deepFreeze(Object.entries(RETENTION_CASCADE)
|
|
57
|
+
.flatMap(([store, row]) => ("legs" in row ? row.legs.filter((leg) => leg.domain === "session-trees").map((leg) => ({ store, ...leg })) : []))
|
|
58
|
+
.sort((a, b) => (a.step ?? 0) - (b.step ?? 0)));
|
|
14
59
|
function codedError(code, message) {
|
|
15
60
|
const e = new Error(message);
|
|
16
61
|
e.code = code;
|
|
@@ -42,6 +42,11 @@ export declare const RETIRED_TASK_SPEC_KEYS: Readonly<Record<string, string>>;
|
|
|
42
42
|
* the seat, owner `TaskSpec` (same code, same `TaskSpec.skills[].…` sentence). Kept out of {@link RETIRED_TASK_SPEC_KEYS}:
|
|
43
43
|
* the spec's read judging these rows would read into the caller's `skills` entries before the seat's reader does. */
|
|
44
44
|
export declare const RETIRED_SKILLS_SEAT_KEYS: Readonly<Record<string, string>>;
|
|
45
|
+
/** The RETIRED member of every bag that carries the compaction seats — a task's `compaction`, a `Runner.compactSession`
|
|
46
|
+
* request's `compaction`, a deployment's `contextSettings` overlay — keyed relative to the bag. The table the seats' one
|
|
47
|
+
* judgment reads (`compactionSeatsDefect`, `context-settings.ts`), each door with its own owner and code. Kept out of
|
|
48
|
+
* {@link RETIRED_TASK_SPEC_KEYS} for the reason the skills rows are: the seats have their own reader. */
|
|
49
|
+
export declare const RETIRED_COMPACTION_SEAT_KEYS: Readonly<Record<string, string>>;
|
|
45
50
|
/** The RETIRED `ToolSpec` members — a spec still carrying one is refused by name (`config.deps_retired_key`) where the
|
|
46
51
|
* factory reads the spec, never dropped unseen: a description the author wrote for one prompt shape would silently
|
|
47
52
|
* never be shown. */
|
|
@@ -39,6 +39,9 @@ export const RETIRED_TASK_SPEC_KEYS = Object.freeze({
|
|
|
39
39
|
export const RETIRED_SKILLS_SEAT_KEYS = Object.freeze({
|
|
40
40
|
"skills[].manifest": "a skill's tools are its `allowedTools` / `disallowedTools` now — an allow-rule and a deny-rule source for the run the skill is activated in, never a fence; move `manifest.allowTools` to `allowedTools`. To fence tools write deny rules (or a delegated agent definition's `allowTools`); to fence write paths use session `allowDirs`",
|
|
41
41
|
});
|
|
42
|
+
export const RETIRED_COMPACTION_SEAT_KEYS = Object.freeze({
|
|
43
|
+
enabled: "compaction is switched by two seats now — `autoCompact` (the passes the engine starts by itself: the turn-boundary pass at the window threshold, a prompt-too-long or guard recovery pass, the end-of-task summary) and `manualCompact` (the passes a caller asks for: `TaskStream.compact`, `Runner.compactSession`, `$.session.compact`). Write the seat you mean; `enabled: false` switched off both",
|
|
44
|
+
});
|
|
42
45
|
export const RETIRED_TOOL_SPEC_KEYS = Object.freeze({
|
|
43
46
|
descriptionClassic: 'a description\'s other forms are `descriptionVariants` now — the long form is `{ id: "classic", traits: { noneOf: ["lean_prompt"] }, text }`, chosen at mount by the run\'s prompt traits',
|
|
44
47
|
});
|
|
@@ -24,10 +24,6 @@ export interface RuleOfferRead {
|
|
|
24
24
|
/** Present when the batch's `uncoveredDetail` seat was not one well-formed row per counted segment and was left out
|
|
25
25
|
* (the count is the truth source and an absent seat claims nothing); the caller owes that loss a disclosure. */
|
|
26
26
|
readonly uncoveredDetailDropped?: true;
|
|
27
|
-
/** Present when at least one batch member was read through the kind-less stored form (no `kind`, the four command
|
|
28
|
-
* text members). A backend counts these to know whether its rows still carry the form that retirement line
|
|
29
|
-
* RL-2164-kindless-batch-member waits on. */
|
|
30
|
-
readonly kindlessForm?: true;
|
|
31
27
|
}
|
|
32
28
|
/** One element not read, and why. The rest of the list is read regardless. */
|
|
33
29
|
export interface RuleOfferDropped {
|
|
@@ -62,29 +62,23 @@ function readBatch(value) {
|
|
|
62
62
|
if (length === 0)
|
|
63
63
|
return MALFORMED;
|
|
64
64
|
const members = [];
|
|
65
|
-
let kindless = false;
|
|
66
65
|
for (let i = 0; i < length; i++) {
|
|
67
66
|
const verdict = readBatchMember(rules[i]);
|
|
68
67
|
if ("problem" in verdict)
|
|
69
68
|
return verdict;
|
|
70
69
|
members.push(verdict.member);
|
|
71
|
-
if (verdict.kindlessForm === true)
|
|
72
|
-
kindless = true;
|
|
73
70
|
}
|
|
74
71
|
if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0)
|
|
75
72
|
return MALFORMED;
|
|
76
73
|
const offer = { kind: "batch", rules: members, uncoveredSegments: count };
|
|
77
|
-
const marks = kindless ? { kindlessForm: true } : {};
|
|
78
74
|
if (detail === undefined)
|
|
79
|
-
return { offer
|
|
75
|
+
return { offer };
|
|
80
76
|
const rows = detailRowsOf(detail, count);
|
|
81
|
-
return rows !== undefined ? { offer: { ...offer, uncoveredDetail: rows }
|
|
77
|
+
return rows !== undefined ? { offer: { ...offer, uncoveredDetail: rows } } : { offer, uncoveredDetailDropped: true };
|
|
82
78
|
}
|
|
83
79
|
function readBatchMember(value) {
|
|
84
80
|
if (!isPlainRecord(value))
|
|
85
81
|
return MALFORMED;
|
|
86
|
-
if (!("kind" in value))
|
|
87
|
-
return readKindlessBatchMember(value);
|
|
88
82
|
const kind = wordOf(value.kind, RULE_OFFER_BATCH_MEMBER_KINDS);
|
|
89
83
|
if (typeof kind !== "string")
|
|
90
84
|
return kind;
|
|
@@ -105,16 +99,6 @@ function readBatchMember(value) {
|
|
|
105
99
|
}
|
|
106
100
|
}
|
|
107
101
|
}
|
|
108
|
-
function readKindlessBatchMember(value) {
|
|
109
|
-
const rule = value.rule;
|
|
110
|
-
const match = value.match;
|
|
111
|
-
const command = value.command;
|
|
112
|
-
const segment = value.segment;
|
|
113
|
-
if (typeof rule !== "string" || typeof match !== "string" || typeof command !== "string" || typeof segment !== "string")
|
|
114
|
-
return MALFORMED;
|
|
115
|
-
const verdict = commandMember(rule, match, command, segment);
|
|
116
|
-
return "problem" in verdict ? verdict : { ...verdict, kindlessForm: true };
|
|
117
|
-
}
|
|
118
102
|
function commandMember(rule, rawMatch, command, segment) {
|
|
119
103
|
if (typeof rule !== "string")
|
|
120
104
|
return MALFORMED;
|
|
@@ -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" });
|
|
@@ -152,7 +152,9 @@ export declare function announceClassifierRoleDefaulted(args: {
|
|
|
152
152
|
* itself is never the count: the unavailable form is never counted; a reply with no verdict refused for want of a seat is
|
|
153
153
|
* counted by the station's ruling path, not by this line.
|
|
154
154
|
*
|
|
155
|
-
* `detail: { toolName, toolCallId, cause, disposition, sessionId?, runId? }` —
|
|
155
|
+
* `detail: { toolName, toolCallId, cause, disposition, sessionId?, sourceSessionId?, agentId?, runId? }` — the session triple is the
|
|
156
|
+
* station's notice address (`noticeAddressOf`, leg-identity.ts: a delegated leg's notice goes to the tree's root and names its
|
|
157
|
+
* source leg); `cause` is why the classification did not rule,
|
|
156
158
|
* an `AutoModeFallbackCause` word (`timeout` / `error`, or `parse_error` for a reply with no verdict). The sentence names the seat the station forked on — `leg` (this
|
|
157
159
|
* run's own approval seat) or `ancestor` (the frozen approver of the ancestor layer whose classifier it was) — and, on a
|
|
158
160
|
* timeout, the budget the classifier actually held (`budgetMs`, the decider's {@link AutoModeDecider.timeoutMs}; a
|
|
@@ -160,6 +162,8 @@ export declare function announceClassifierRoleDefaulted(args: {
|
|
|
160
162
|
*/
|
|
161
163
|
export declare function classifierUnavailableNotice(args: ClassifierUnavailableInfo & ClassifierUnavailableStation & {
|
|
162
164
|
sessionId?: string;
|
|
165
|
+
sourceSessionId?: string;
|
|
166
|
+
agentId?: string;
|
|
163
167
|
runId?: string;
|
|
164
168
|
}): EngineNotice;
|
|
165
169
|
/** A classifier station's fork facts, wired once per leg: the route an ask the station hands on takes, and the
|
|
@@ -168,6 +172,8 @@ export declare function classifierUnavailableSeat(args: ClassifierUnavailableSta
|
|
|
168
172
|
route: ApprovalRoute;
|
|
169
173
|
onNotice: RunnerDeps["onNotice"];
|
|
170
174
|
sessionId?: string;
|
|
175
|
+
sourceSessionId?: string;
|
|
176
|
+
agentId?: string;
|
|
171
177
|
runId?: string;
|
|
172
178
|
}): ClassifierUnavailableSeat;
|
|
173
179
|
/** Which station forked (`leg` — the leg's gate, on its own approval seat; `ancestor` — an ancestor's frozen classifier in
|
|
@@ -129,13 +129,15 @@ export function classifierUnavailableNotice(args) {
|
|
|
129
129
|
cause: args.cause,
|
|
130
130
|
disposition: classifierUnavailableDispositionOf(args.route),
|
|
131
131
|
...(args.sessionId !== undefined ? { sessionId: args.sessionId } : {}),
|
|
132
|
+
...(args.sourceSessionId !== undefined ? { sourceSessionId: args.sourceSessionId } : {}),
|
|
133
|
+
...(args.agentId !== undefined ? { agentId: args.agentId } : {}),
|
|
132
134
|
...(args.runId !== undefined ? { runId: args.runId } : {}),
|
|
133
135
|
},
|
|
134
136
|
};
|
|
135
137
|
}
|
|
136
138
|
export function classifierUnavailableSeat(args) {
|
|
137
|
-
const { route, onNotice, sessionId, runId, station, budgetMs } = args;
|
|
138
|
-
return { route, onUnavailable: (info) => deliverEngineNotice(onNotice, classifierUnavailableNotice({ ...info, station, ...(budgetMs !== undefined ? { budgetMs } : {}), ...(sessionId !== undefined ? { sessionId } : {}), ...(runId !== undefined ? { runId } : {}) })) };
|
|
139
|
+
const { route, onNotice, sessionId, sourceSessionId, agentId, runId, station, budgetMs } = args;
|
|
140
|
+
return { route, onUnavailable: (info) => deliverEngineNotice(onNotice, classifierUnavailableNotice({ ...info, station, ...(budgetMs !== undefined ? { budgetMs } : {}), ...(sessionId !== undefined ? { sessionId } : {}), ...(sourceSessionId !== undefined ? { sourceSessionId } : {}), ...(agentId !== undefined ? { agentId } : {}), ...(runId !== undefined ? { runId } : {}) })) };
|
|
139
141
|
}
|
|
140
142
|
function classifierFallbackAnnouncer(args) {
|
|
141
143
|
const announced = new Set();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { convertToLlm, uuidv7 } from "../../internal/harness.js";
|
|
2
2
|
import { compactionFailureReason, compactionPassReport, DEFAULT_COMPACTION_INSTRUCTIONS, isCompactionManualCancel, manualCompactOutcomeOf, maybeCompact, mintCompactedEvent } from "../auto-compaction.js";
|
|
3
|
-
import { contextOverlayFor } from "../context-settings.js";
|
|
3
|
+
import { compactionSeatsDefect, contextOverlayFor } from "../context-settings.js";
|
|
4
|
+
import { RETIRED_COMPACTION_SEAT_KEYS } from "../retired-keys.js";
|
|
4
5
|
import { createRowSeat, promptCountOf } from "../mods/session-append.js";
|
|
5
6
|
import { createCompactStation } from "../mods/session-compact.js";
|
|
6
7
|
import { admitLegMods, legFacadeSeats } from "../mods/stations.js";
|
|
@@ -18,7 +19,7 @@ import { derivedLegBrain, sideCallBookOf } from "./side-call-account.js";
|
|
|
18
19
|
import { acquireExistingSession, claimIdleSession, readPlainRequest, shownValue } from "./session-verb-doors.js";
|
|
19
20
|
const VERB = "Runner.compactSession";
|
|
20
21
|
const REQUEST_KEYS = new Set(["sessionId", "model", "instructions", "compaction", "compactionModel", "getApiKeyAndHeaders", "signal"]);
|
|
21
|
-
const SETTINGS_KEYS = new Set(["
|
|
22
|
+
const SETTINGS_KEYS = new Set(["manualCompact", "reserveTokens", "keepRecentTokens", "instructions", "clampTolerance", ...Object.keys(RETIRED_COMPACTION_SEAT_KEYS)]);
|
|
22
23
|
export async function compactIdleSession(seats, request) {
|
|
23
24
|
const req = screenCompactSessionRequest(request);
|
|
24
25
|
const { deps } = seats;
|
|
@@ -90,7 +91,7 @@ async function compactOnSession(req, deps, session, resolved, named, legMods) {
|
|
|
90
91
|
brain: derivedLegBrain(() => deps.brain, "compaction", book),
|
|
91
92
|
...(req.getApiKeyAndHeaders !== undefined ? { getApiKeyAndHeaders: req.getApiKeyAndHeaders } : {}),
|
|
92
93
|
...(thinking !== undefined ? { thinking } : {}),
|
|
93
|
-
settings: legCompactionSettings(req.compaction !== undefined ? { compaction: req.compaction } : {}, overlay),
|
|
94
|
+
settings: legCompactionSettings(req.compaction !== undefined ? { compaction: req.compaction } : {}, overlay, "manualCompact"),
|
|
94
95
|
customInstructions: req.instructions ?? req.compaction?.instructions ?? DEFAULT_COMPACTION_INSTRUCTIONS,
|
|
95
96
|
...(req.signal !== undefined ? { signal: req.signal, manualCancelSignal: req.signal } : {}),
|
|
96
97
|
minTokens: 0,
|
|
@@ -193,9 +194,11 @@ function screenCompactSessionRequest(request) {
|
|
|
193
194
|
};
|
|
194
195
|
}
|
|
195
196
|
function screenSettings(raw, bad) {
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
const read = readPlainRequest(raw, SETTINGS_KEYS, (what) => bad(`compaction: ${what}`));
|
|
198
|
+
const seats = compactionSeatsDefect(read, "compaction");
|
|
199
|
+
if (seats !== undefined)
|
|
200
|
+
return bad(seats.sentence);
|
|
201
|
+
const { manualCompact, reserveTokens, keepRecentTokens, instructions, clampTolerance } = read;
|
|
199
202
|
for (const [name, v] of [["reserveTokens", reserveTokens], ["keepRecentTokens", keepRecentTokens], ["clampTolerance", clampTolerance]]) {
|
|
200
203
|
if (v !== undefined && typeof v !== "number")
|
|
201
204
|
return bad(`compaction.${name} must be a number when given, got ${shownValue(v)}`);
|
|
@@ -203,7 +206,7 @@ function screenSettings(raw, bad) {
|
|
|
203
206
|
if (instructions !== undefined && typeof instructions !== "string")
|
|
204
207
|
return bad(`compaction.instructions must be a string when given, got ${shownValue(instructions)}`);
|
|
205
208
|
return {
|
|
206
|
-
...(
|
|
209
|
+
...(manualCompact !== undefined ? { manualCompact: manualCompact } : {}),
|
|
207
210
|
...(reserveTokens !== undefined ? { reserveTokens: reserveTokens } : {}),
|
|
208
211
|
...(keepRecentTokens !== undefined ? { keepRecentTokens: keepRecentTokens } : {}),
|
|
209
212
|
...(instructions !== undefined ? { instructions: instructions } : {}),
|
|
@@ -4,7 +4,7 @@ import type { StaleToolResultOffloadOptions, TaskSpec } from "../types.js";
|
|
|
4
4
|
import type { Context } from "../../internal/llm.js";
|
|
5
5
|
import { type ToolResultStore } from "../tool-result-store.js";
|
|
6
6
|
import type { Prepared, RunnerDepsSeat } from "./contracts.js";
|
|
7
|
-
import { type ContextWindowOverlay } from "../context-settings.js";
|
|
7
|
+
import { type CompactionSeat, type ContextWindowOverlay } from "../context-settings.js";
|
|
8
8
|
import { type CompactionSettings } from "../../internal/harness.js";
|
|
9
9
|
/**
|
|
10
10
|
* The maybeCompact call arguments that MUST be assembled identically on all three
|
|
@@ -159,10 +159,10 @@ export declare function legContextOverlayOption(prepared: Prepared, runner: Runn
|
|
|
159
159
|
* The compaction SETTINGS a pass runs under — the assembly all three lanes and the out-of-run `Runner.compactSession` share.
|
|
160
160
|
*
|
|
161
161
|
* `{ ...DEFAULT_COMPACTION_SETTINGS, ...spec.compaction }` was hand-copied at each lane, and it is where the
|
|
162
|
-
* deployment's live
|
|
163
|
-
* `settings.enabled
|
|
164
|
-
* the recovery pass and the end-of-task summary
|
|
165
|
-
*
|
|
166
|
-
* declared it > on).
|
|
162
|
+
* deployment's live seat declarations belong: `maybeCompact` has exactly one enablement gate (it reads
|
|
163
|
+
* `settings.enabled`, the pass's own), so resolving it HERE from the seat of the pass the lane runs — `autoCompact`
|
|
164
|
+
* for the boundary's own pass, the recovery pass and the end-of-task summary, `manualCompact` for a requested one —
|
|
165
|
+
* keeps "who decides whether this pass runs" a single expression ({@link compactionEnabled}: the request authored the
|
|
166
|
+
* seat > the deployment declared it > on). The two seats themselves do not ride the settings: the pass reads its gate.
|
|
167
167
|
*/
|
|
168
|
-
export declare function legCompactionSettings(spec: Pick<TaskSpec, "compaction">, overlay: ContextWindowOverlay | undefined): CompactionSettings;
|
|
168
|
+
export declare function legCompactionSettings(spec: Pick<TaskSpec, "compaction">, overlay: ContextWindowOverlay | undefined, seat: CompactionSeat): CompactionSettings;
|
|
@@ -121,6 +121,7 @@ export function legContextOverlayOption(prepared, runner) {
|
|
|
121
121
|
const overlay = contextOverlayFor(runner.deps.contextSettings, prepared.harness.getModelRef(), runner.deps);
|
|
122
122
|
return overlay !== undefined ? { contextOverlay: overlay } : {};
|
|
123
123
|
}
|
|
124
|
-
export function legCompactionSettings(spec, overlay) {
|
|
125
|
-
|
|
124
|
+
export function legCompactionSettings(spec, overlay, seat) {
|
|
125
|
+
const { autoCompact: _auto, manualCompact: _manual, ...members } = spec.compaction ?? {};
|
|
126
|
+
return { ...DEFAULT_COMPACTION_SETTINGS, ...members, enabled: compactionEnabled(seat, spec.compaction, overlay) };
|
|
126
127
|
}
|
|
@@ -271,6 +271,14 @@ export interface Prepared {
|
|
|
271
271
|
* the `Session` contract instead. */
|
|
272
272
|
session: StoredSession;
|
|
273
273
|
sessionId: string;
|
|
274
|
+
/** The occupant of the session row this leg acquired (`SessionMetadata.incarnation`, read once from {@link session} at
|
|
275
|
+
* prepare); absent = no token (a row written before occupants were minted, or that read failed). With {@link sessionId} it
|
|
276
|
+
* is the leg's session ADDRESS (`task-notification.ts` `SessionAddress`): what its notification lane parks under, drains
|
|
277
|
+
* and registers as. */
|
|
278
|
+
sessionIncarnation?: string;
|
|
279
|
+
/** `true` = that read threw: the leg names no occupant it knows, so the notification store takes it as no admission and drains
|
|
280
|
+
* it nothing (`SessionAddress.unread`); what is kept for the session waits for a leg that reads its occupant. */
|
|
281
|
+
sessionIncarnationUnread?: true;
|
|
274
282
|
/** This leg's task id, minted ONCE at prepare ({@link import("../leg-identity.js").legTaskIdOf}): its identity, frames, events'
|
|
275
283
|
* `sourceTaskId`, trace frames and `TaskResult.taskId` read it here; none re-spells it. */
|
|
276
284
|
taskId: string;
|
|
@@ -573,7 +581,7 @@ export interface Prepared {
|
|
|
573
581
|
/**
|
|
574
582
|
* This session's DURABLE box, present iff this leg mounted the session-box drain (a top-level leg
|
|
575
583
|
* over a cross-process-safe mailbox with a grammatical session id). The notification lane binds it
|
|
576
|
-
* to the park seat ({@link import("../task-notification.js").PendingSessionNotifications.
|
|
584
|
+
* to the park seat ({@link import("../task-notification.js").PendingSessionNotifications.admit})
|
|
577
585
|
* so a child's uplink frame parked for this session while it is idle lands in the box the next run
|
|
578
586
|
* drains — one mount judgment, the drain and the park read it alike. Absent ⇒ in-process parking.
|
|
579
587
|
*/
|
|
@@ -706,12 +714,14 @@ export interface Prepared {
|
|
|
706
714
|
* plane that owns the write gate — the read-only plane is internal to `inject`/`harvest`). */
|
|
707
715
|
engine: MemoryEngine;
|
|
708
716
|
handle: MemorySessionHandle;
|
|
717
|
+
/** The session's scope contract (`TaskSpec.memory.scopeContract`): the owner of `handle.writeScope` is read under it. */
|
|
718
|
+
scopeContract: "v2" | undefined;
|
|
709
719
|
/** Merged injection across all planes (single-root sessions: identical to engine.inject(handle)). */
|
|
710
|
-
inject: () => import("../memory-engine/engine.js").MemoryInjection
|
|
720
|
+
inject: () => Promise<import("../memory-engine/engine.js").MemoryInjection>;
|
|
711
721
|
harvest: (phase?: "checkpoint" | "terminal") => Promise<HarvestReport | undefined>;
|
|
712
722
|
/** End this mount's session leg WITHOUT a harvest: the run that mounted it will never reach its
|
|
713
723
|
* terminal harvest (a prepare that failed after the mount). Never throws. */
|
|
714
|
-
release: () => void
|
|
724
|
+
release: () => Promise<void>;
|
|
715
725
|
/**
|
|
716
726
|
* The session's capture opt-out face (the `TaskStream.optOutMemoryCapture`
|
|
717
727
|
* verb's target; host-API only — no tool face reads it, §2.6). `flip` re-adjudicates the
|
|
@@ -757,15 +767,16 @@ export interface Prepared {
|
|
|
757
767
|
execIsExternalContent: boolean;
|
|
758
768
|
};
|
|
759
769
|
/**
|
|
760
|
-
* The delegation-settlement handle:
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
* an `"off"` deployment keeps the pre-336 accepted-cost posture byte-level.
|
|
770
|
+
* The delegation-settlement handle: what a settlement writer needs. Consumers (the subagent
|
|
771
|
+
* background leg's write-ahead + terminal observation, the tool wrap's sync unattestable row)
|
|
772
|
+
* can outlive this prepared leg, so they write through these fields alone — never through the
|
|
773
|
+
* live engine/session objects above. Present only under `memoryProvenance: "carry"` (the
|
|
774
|
+
* default): an `"off"` deployment keeps the pre-336 accepted-cost posture byte-level.
|
|
766
775
|
*/
|
|
767
776
|
settlement?: {
|
|
768
|
-
/** The WRITE plane's
|
|
777
|
+
/** The WRITE plane's governance store (the settlement / lineage / challenge documents). */
|
|
778
|
+
governance: import("../memory-engine/types.js").MemoryGovernanceDocs;
|
|
779
|
+
/** The WRITE plane's control-plane dir (the pollution marker and hold custody files). */
|
|
769
780
|
controlDir: string;
|
|
770
781
|
sessionId: string;
|
|
771
782
|
provenance: "carry";
|
|
@@ -1048,6 +1059,10 @@ export interface Prepared {
|
|
|
1048
1059
|
lastSentRequest: () => CompactionForkContext | undefined;
|
|
1049
1060
|
/** The leg's advisor-instructions seat (advisor-instructions.ts); absent when the leg neither mounts the advisor nor has told the model of it. */
|
|
1050
1061
|
advisorInstruction?: import("./advisor-instructions.js").AdvisorInstructionSeat;
|
|
1062
|
+
/** #1123 — the memory notices this prepare drained (whole engine reminders, model lane only, no echo): the leg's first
|
|
1063
|
+
* request carries them once, ahead of the user's message — a fresh leg's first user message, a resumed leg's
|
|
1064
|
+
* continuation. Never the system prompt (an event there breaks the cached prefix twice). Absent when nothing drained. */
|
|
1065
|
+
memoryNoticesFrame?: string;
|
|
1051
1066
|
/** The post-compaction restore (`MaybeCompactOptions.workingFileAttachments.restore`): re-reads the candidates through
|
|
1052
1067
|
* the leg's one file reader under the run's synthetic-Read judge — the user attachment's own path read — deduplicated
|
|
1053
1068
|
* against the read state the summary leaves, and mints their attachment frames (`readCompactionRestore`); a file it
|
|
@@ -2060,6 +2075,12 @@ export interface RunInternals {
|
|
|
2060
2075
|
* after a restart those intermediate sessions are dead ends, and a recovery face enumerating
|
|
2061
2076
|
* "everything under this host session" needs the root anchor, not an alias walk. */
|
|
2062
2077
|
rootSessionId?: string;
|
|
2078
|
+
/** The occupant of {@link rootSessionId}'s row (`SessionMetadata.incarnation`) as the tree's root run acquired it — the
|
|
2079
|
+
* other half of the root anchor's ADDRESS, carried beside it by the same fixed point (the spawner passes its own
|
|
2080
|
+
* `ctx.rootSessionIncarnation`). Absent = unknown: a revival, a resume or a wake (the row records no root occupant) and a
|
|
2081
|
+
* row written before occupants were minted; a frame the notification lane escalates to the root anchor is then addressed
|
|
2082
|
+
* to an unknown occupant, which a root holding a token is not. TRUSTED run-scoped channel (never a TaskSpec field). */
|
|
2083
|
+
rootSessionIncarnation?: string;
|
|
2063
2084
|
/** The delegation tree's owner seat ({@link import("./delegation-owner.js").DelegationOwnerSeat}): a fixed point like
|
|
2064
2085
|
* {@link rootSessionId} — the spawning run hands its own seat down by reference (the delegation and workflow lanes), so the tree
|
|
2065
2086
|
* reads its root row's owner once. Absent ⇒ this run is nobody's child here (a top-level run, a revival, a resumed park) and its
|
|
@@ -2308,6 +2329,12 @@ export interface RunInternals {
|
|
|
2308
2329
|
* leg, a caller that does not delegate through core).
|
|
2309
2330
|
*/
|
|
2310
2331
|
callerRoot?: string;
|
|
2332
|
+
/**
|
|
2333
|
+
* The checkout the SPAWNING run writes in when it has switched to a tree other than its root (an EnterWorktree tree — it can
|
|
2334
|
+
* lie outside {@link callerRoot}, since a managed tree hangs at the repository root): a child placed inside it is placed in the
|
|
2335
|
+
* caller's own tree as well. Filled ONLY by core delegation callers beside {@link callerRoot}; absent when the caller writes in its root.
|
|
2336
|
+
*/
|
|
2337
|
+
callerCheckout?: string;
|
|
2311
2338
|
/**
|
|
2312
2339
|
* `parentCwd` is a worktree the caller minted for THIS child (the delegation tool's `isolation: "worktree"`): a child
|
|
2313
2340
|
* its environment placed inside the caller's own tree instead is refused before it starts (`isolation.unavailable`).
|
|
@@ -3086,7 +3113,8 @@ export type EndOfTaskCompaction = {
|
|
|
3086
3113
|
*/
|
|
3087
3114
|
export interface NotificationLaneBindings {
|
|
3088
3115
|
harness: AgentHarness | undefined;
|
|
3089
|
-
|
|
3116
|
+
/** The leg's session address (its session id and the occupant it acquired), bound by the identity lane once prepared. */
|
|
3117
|
+
address: import("../task-notification.js").SessionAddress | undefined;
|
|
3090
3118
|
ident: () => {
|
|
3091
3119
|
eventId?: string;
|
|
3092
3120
|
parentToolCallId?: string;
|
|
@@ -22,11 +22,18 @@ export type DelegationOwnerReading = {
|
|
|
22
22
|
export interface DelegationOwnerSeat {
|
|
23
23
|
read(): Promise<DelegationOwnerReading>;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Whether two readings of one session id's occupant cell (`SessionMetadata.incarnation`, `undefined` = no token) name the occupant a
|
|
27
|
+
* run holds: the same token, or no token on either side (a row written before occupants were minted, taken as it reads — a row
|
|
28
|
+
* created again under the id is minted a token, so it never reads as the one before it). A token on one side only is another
|
|
29
|
+
* occupant. The one reading of this question for a run's own seats: the tree owner below and the session address a frame is
|
|
30
|
+
* delivered to (`task-notification.ts`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function sameOccupant(held: string | undefined, current: string | undefined): boolean;
|
|
25
33
|
/**
|
|
26
34
|
* The seat of a run nobody spawned: the owner of the row it acquired, read by id through its own store's {@link SessionStore.headOf}
|
|
27
|
-
* and taken only while the row's occupant is the one acquired
|
|
28
|
-
*
|
|
29
|
-
* the reading is `null`.
|
|
35
|
+
* and taken only while the row's occupant is the one acquired ({@link sameOccupant} of the head's `incarnation` and the acquired
|
|
36
|
+
* session's metadata's). A store without a by-id read has no owner to read: the reading is `null`.
|
|
30
37
|
*/
|
|
31
38
|
export declare function ownRowDelegationOwner(sessions: Pick<SessionStore, "headOf">, sessionId: string, acquiredIncarnation: () => Promise<string | undefined>): DelegationOwnerSeat;
|
|
32
39
|
/** The refusal of a delegation whose tree owner does not bind ({@link DelegationOwnerReading}): the child is not started and no row is
|
|
@@ -4,6 +4,9 @@ function ownerCellReading(sessionId, head) {
|
|
|
4
4
|
return { bound: true, owner };
|
|
5
5
|
return { bound: false, reason: `the session ${sessionId}'s row answers an owner that is neither a name nor anonymous (${owner === undefined ? "none" : typeof owner})` };
|
|
6
6
|
}
|
|
7
|
+
export function sameOccupant(held, current) {
|
|
8
|
+
return held === current;
|
|
9
|
+
}
|
|
7
10
|
export function ownRowDelegationOwner(sessions, sessionId, acquiredIncarnation) {
|
|
8
11
|
let settled;
|
|
9
12
|
let inFlight;
|
|
@@ -14,7 +17,7 @@ export function ownRowDelegationOwner(sessions, sessionId, acquiredIncarnation)
|
|
|
14
17
|
const [head, acquired] = await Promise.all([headOf.call(sessions, sessionId), acquiredIncarnation()]);
|
|
15
18
|
if (head === undefined)
|
|
16
19
|
return { bound: false, reason: `the session ${sessionId} this run acquired has no row any more` };
|
|
17
|
-
if (head.incarnation
|
|
20
|
+
if (!sameOccupant(head.incarnation, acquired))
|
|
18
21
|
return { bound: false, reason: `the session ${sessionId} this run acquired now holds another occupant` };
|
|
19
22
|
return ownerCellReading(sessionId, head);
|
|
20
23
|
};
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* the reminder envelope and the text helpers. Its `import type` edges up to `hooks.ts` name the gate's public
|
|
22
22
|
* contract (`ToolGateInput`, `ToolGateResult`, the observer payload), which stays declared there.
|
|
23
23
|
*/
|
|
24
|
+
import type { RefusalEcho } from "../refusal-echo.js";
|
|
24
25
|
import { type ClassifierDenyCause, type DeniedBy, type GateOutcome, type ModeRefusal, type ModeRelease, type Settlement } from "../gate-outcome.js";
|
|
25
26
|
import type { AllowRuleClearance } from "../allow-rule-shadow.js";
|
|
26
27
|
import type { AutoModeClassifierRound } from "../auto-mode.js";
|
|
@@ -58,6 +59,8 @@ export interface GateExitFacts {
|
|
|
58
59
|
/** The registration whose handler ended the call at the hook layer (its deny answer or its failure) — only beside `deniedBy: "hook"`.
|
|
59
60
|
* As the bus names it: the engine's own origin word is read as no extension at the mint, once. */
|
|
60
61
|
extension?: string;
|
|
62
|
+
/** The literals the refusal's sentence quotes, minted with it — only beside a layer word {@link DENIED_BY_MAY_ECHO} admits. */
|
|
63
|
+
echoed?: readonly RefusalEcho[];
|
|
61
64
|
}
|
|
62
65
|
/**
|
|
63
66
|
* Mint the outcome. A defect here is an ENGINE defect (a refusing site that did not say who refused, a
|
|
@@ -344,6 +347,9 @@ export interface GatePass {
|
|
|
344
347
|
* beside `deniedBy` by that station alone; the exit puts it on the gate result for the loop's error result.
|
|
345
348
|
* OPTIONAL (the `probeUnanswered` form): the dispatch that builds the pass has nothing to declare here. */
|
|
346
349
|
denyDetails?: unknown;
|
|
350
|
+
/** borrowed-mutable — the literals the shell read station's deny sentence quotes, written beside `deniedBy: "read_boundary"` by
|
|
351
|
+
* the sites that apply a refusing verdict; the exit mints `GateDisposition.echoed` from it ({@link DENIED_BY_MAY_ECHO}). */
|
|
352
|
+
denyEchoed?: readonly RefusalEcho[];
|
|
347
353
|
/** borrowed-mutable — the shell read station's containment card behind a standing MANDATED ask (an out-of-root
|
|
348
354
|
* or unestablishable read): when that ask ends as a refusal (a person's no, nobody to ask), the exit puts the
|
|
349
355
|
* card on the gate result, so the refusal's `tool_end` still says WHAT was found (`readonly_out_of_root`) beside
|