@sema-agent/core 7.63.0 → 7.65.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 +725 -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.js +25 -5
- package/dist/core/allow-entry.d.ts +4 -0
- package/dist/core/ask-origin.d.ts +1 -1
- package/dist/core/ask-origin.js +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/auto-promote.d.ts +3 -2
- package/dist/core/background-agent-store.d.ts +14 -0
- package/dist/core/background-agent-store.js +3 -0
- package/dist/core/checkpoint-queries.d.ts +9 -6
- package/dist/core/checkpoint-queries.js +8 -3
- package/dist/core/checkpoint-store.d.ts +7 -4
- package/dist/core/context-settings.d.ts +39 -9
- package/dist/core/context-settings.js +32 -10
- package/dist/core/engine-attestation.d.ts +26 -6
- package/dist/core/engine-attestation.js +5 -1
- package/dist/core/engine-notice.d.ts +37 -2
- package/dist/core/engine-notice.js +3 -1
- 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 +30 -2
- package/dist/core/file-history-store.js +48 -9
- package/dist/core/fs-write-gate-policy.js +1 -1
- package/dist/core/gate-fold.js +5 -1
- 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/governance-codes.d.ts +8 -4
- package/dist/core/governance-codes.js +8 -3
- package/dist/core/leg-identity.d.ts +35 -1
- package/dist/core/leg-identity.js +10 -0
- package/dist/core/mailbox-store.d.ts +39 -4
- package/dist/core/mailbox-store.js +14 -2
- package/dist/core/memory-engine/consolidation.d.ts +13 -6
- package/dist/core/memory-engine/consolidation.js +26 -0
- package/dist/core/memory-engine/control-objects.d.ts +58 -0
- package/dist/core/memory-engine/control-objects.js +273 -0
- package/dist/core/memory-engine/control-plane-adoption.d.ts +51 -0
- package/dist/core/memory-engine/control-plane-adoption.js +161 -0
- package/dist/core/memory-engine/delegation-settlement.d.ts +73 -40
- package/dist/core/memory-engine/delegation-settlement.js +271 -107
- package/dist/core/memory-engine/dual-root.d.ts +3 -2
- package/dist/core/memory-engine/dual-root.js +7 -3
- package/dist/core/memory-engine/engine.d.ts +54 -33
- package/dist/core/memory-engine/engine.js +150 -157
- package/dist/core/memory-engine/file-backend.d.ts +58 -76
- package/dist/core/memory-engine/file-backend.js +111 -268
- package/dist/core/memory-engine/index.d.ts +3 -2
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +135 -50
- package/dist/core/memory-engine/layout.js +214 -89
- package/dist/core/memory-engine/memory-age.d.ts +12 -0
- package/dist/core/memory-engine/memory-age.js +17 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +10 -3
- package/dist/core/memory-engine/memory-backend-contract.js +159 -2
- package/dist/core/memory-engine/memory-deployment.d.ts +12 -4
- package/dist/core/memory-engine/memory-deployment.js +31 -6
- package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
- package/dist/core/memory-engine/origin-clearance.js +64 -9
- package/dist/core/memory-engine/session-write-home.d.ts +34 -1
- package/dist/core/memory-engine/session-write-home.js +37 -10
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.js +7 -7
- package/dist/core/memory-engine/types.d.ts +55 -12
- package/dist/core/memory-engine/types.js +2 -1
- package/dist/core/memory-vector.d.ts +6 -14
- package/dist/core/memory.d.ts +0 -462
- package/dist/core/memory.js +0 -333
- 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/tool-call.js +3 -4
- package/dist/core/parent-spec-seat.d.ts +2 -2
- package/dist/core/peer-channel.d.ts +5 -0
- package/dist/core/permission-rule-consent.d.ts +64 -22
- package/dist/core/permission-rule-consent.js +106 -58
- package/dist/core/permission-rule-store.d.ts +56 -21
- package/dist/core/permission-rule-store.js +2 -0
- package/dist/core/refusal-echo.d.ts +20 -0
- package/dist/core/refusal-echo.js +33 -0
- package/dist/core/retention.d.ts +175 -10
- package/dist/core/retention.js +44 -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/classifier-ladder.d.ts +10 -2
- 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 +28 -9
- package/dist/core/runner/delegation-owner.d.ts +2 -3
- package/dist/core/runner/delegation-owner.js +2 -1
- package/dist/core/runner/gate-exit.d.ts +6 -0
- package/dist/core/runner/gate-exit.js +11 -2
- package/dist/core/runner/memory-consolidation-driver.d.ts +4 -2
- package/dist/core/runner/memory-consolidation-driver.js +8 -5
- package/dist/core/runner/prepare-ask-lane.js +3 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -1
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -2
- 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-gate-stations.d.ts +8 -0
- package/dist/core/runner/prepare-gate-stations.js +15 -7
- package/dist/core/runner/prepare-hands-readface.js +1 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +3 -1
- package/dist/core/runner/prepare-inherited-gate.js +4 -2
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +4 -0
- package/dist/core/runner/prepare-memory.js +22 -28
- package/dist/core/runner/prepare-policy-chain.js +18 -10
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-task.d.ts +5 -1
- package/dist/core/runner/prepare-task.js +16 -11
- 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/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 +8 -4
- package/dist/core/runner/run-notification-lane.js +23 -23
- package/dist/core/runner/run-recovery-lanes.js +3 -3
- 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/sub-agent-deny-lists.d.ts +19 -0
- package/dist/core/runner/sub-agent-deny-lists.js +25 -0
- 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 +1 -1
- package/dist/core/secret-env.d.ts +2 -2
- package/dist/core/secret-env.js +6 -20
- package/dist/core/session-checkout.d.ts +63 -3
- package/dist/core/session-checkout.js +152 -58
- package/dist/core/session-store.d.ts +6 -6
- package/dist/core/session-store.js +3 -3
- package/dist/core/shell-read-silence.js +8 -0
- package/dist/core/store-contracts/background-agent-store-contract.js +13 -0
- package/dist/core/store-contracts/peer-directory-contract.js +8 -1
- package/dist/core/task-event.d.ts +9 -5
- package/dist/core/task-notification.d.ts +137 -31
- package/dist/core/task-notification.js +198 -100
- package/dist/core/task-registry-agent.d.ts +11 -0
- package/dist/core/task-registry-agent.js +12 -3
- package/dist/core/task-registry-shared.d.ts +11 -0
- package/dist/core/task-registry.d.ts +18 -0
- package/dist/core/task-registry.js +27 -8
- package/dist/core/task-spec.d.ts +7 -2
- package/dist/core/tool-errors.d.ts +17 -9
- package/dist/core/tool-errors.js +1 -1
- package/dist/core/tool-policy.d.ts +18 -1
- package/dist/core/tool-policy.js +16 -7
- package/dist/core/tool-result-store.d.ts +20 -0
- package/dist/core/tool-spec.d.ts +10 -6
- package/dist/core/trace.d.ts +3 -2
- 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/write-protect.d.ts +16 -0
- package/dist/core/write-protect.js +10 -0
- package/dist/engine/compaction/compaction.d.ts +2 -1
- package/dist/engine/harness/types.d.ts +1 -0
- package/dist/engine/session/repo-utils.d.ts +14 -4
- package/dist/engine/session/repo-utils.js +5 -4
- package/dist/engine/session/session.d.ts +7 -1
- package/dist/engine/session/session.js +5 -2
- package/dist/index.d.ts +13 -11
- package/dist/index.js +13 -11
- package/dist/orchestration/run-workflow-tool.d.ts +4 -0
- package/dist/orchestration/run-workflow-tool.js +7 -0
- package/dist/orchestration/workflow-types.d.ts +2 -1
- package/dist/orchestration/workflow.d.ts +3 -0
- package/dist/orchestration/workflow.js +2 -1
- package/dist/prompts/default.d.ts +1 -2
- package/dist/scenarios/full-body.d.ts +1 -1
- package/dist/stores/file/adoption/adopt.d.ts +1 -1
- 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 +12 -16
- package/dist/stores/file/index.js +7 -25
- package/dist/stores/file/permission-rule-store.d.ts +34 -0
- package/dist/stores/file/permission-rule-store.js +104 -9
- package/dist/stores/file/session-store.js +1 -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/read-deny.d.ts +15 -2
- package/dist/tools/fs/read-deny.js +10 -2
- package/dist/tools/fs/shell-read-check.d.ts +8 -2
- package/dist/tools/fs/shell-read-check.js +7 -7
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +71 -73
- package/wire-changes/core-stores-sql@7.64.0.json +30 -0
- package/wire-changes/core-stores-sql@7.65.0.json +30 -0
- package/wire-changes/core@7.64.0.json +2653 -0
- package/wire-changes/core@7.65.0.json +1650 -0
- package/wire-changes/mods-kernel@7.64.0.json +30 -0
- package/wire-changes/mods-kernel@7.65.0.json +30 -0
- package/wire-changes/primitives@7.64.0.json +30 -0
- package/wire-changes/primitives@7.65.0.json +337 -0
- package/dist/core/memory-recall.d.ts +0 -208
- package/dist/core/memory-recall.js +0 -136
- package/dist/stores/file/memory-store.d.ts +0 -124
- package/dist/stores/file/memory-store.js +0 -353
|
@@ -5,6 +5,8 @@ import { readRuleOwner } from "./rule-owner.js";
|
|
|
5
5
|
import { thrownText } from "./thrown-value.js";
|
|
6
6
|
import { validatePath } from "./effective-path-target.js";
|
|
7
7
|
export const PERMISSION_RULES_LATER_GRAMMAR_CODE = "permission_rules.later_grammar";
|
|
8
|
+
export const PERMISSION_RULES_DAMAGED_BUCKET_CODE = "permission_rules.bucket_damaged";
|
|
9
|
+
export const PERMISSION_RULES_UNREADABLE_BUCKET_CODE = "permission_rules.bucket_unreadable";
|
|
8
10
|
export function isRuleRevision(rev) {
|
|
9
11
|
return typeof rev === "number" && Number.isSafeInteger(rev) && rev >= 0;
|
|
10
12
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** What a quoted span of a refusal sentence IS: a file path, a command line, or a deny/rule pattern. */
|
|
2
|
+
export declare const REFUSAL_ECHO_KINDS: readonly ["path", "command", "pattern"];
|
|
3
|
+
export type RefusalEchoKind = (typeof REFUSAL_ECHO_KINDS)[number];
|
|
4
|
+
/** Membership test for {@link RefusalEchoKind}. */
|
|
5
|
+
export declare function isRefusalEchoKind(v: unknown): v is RefusalEchoKind;
|
|
6
|
+
/**
|
|
7
|
+
* One literal the sentence quotes, in the order the sentence quotes them. `value` is the literal as the refusing judge
|
|
8
|
+
* held it — the sentence elides the middle of a long one, this member never does. `canonical` stands on a `path` whose
|
|
9
|
+
* canonical target the sentence also names because the two differ.
|
|
10
|
+
*/
|
|
11
|
+
export interface RefusalEcho {
|
|
12
|
+
readonly kind: RefusalEchoKind;
|
|
13
|
+
readonly value: string;
|
|
14
|
+
readonly canonical?: string;
|
|
15
|
+
}
|
|
16
|
+
/** The defects of `v` read as a list of {@link RefusalEcho} (an empty list is a clean one): a dense non-empty array holding nothing
|
|
17
|
+
* but its elements (no hole, no member of its own beside them — a method name or a symbol on the array is read by nobody here and
|
|
18
|
+
* JSON drops it), of records that hold exactly `kind` (a member of the set), `value` (a non-empty string) and, on a `path`, an
|
|
19
|
+
* optional non-empty `canonical`. Reads the list by index alone: no method of a caller's array is ever called. */
|
|
20
|
+
export declare function refusalEchoDefects(v: unknown): string[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { strayMembersOf } from "./own-property-receipt.js";
|
|
2
|
+
const ECHO_MEMBERS = Object.freeze(["kind", "value", "canonical"]);
|
|
3
|
+
const ECHO_WORDS = Object.freeze({ subject: "an echo", unit: "member", moment: "at the gate record" });
|
|
4
|
+
export const REFUSAL_ECHO_KINDS = Object.freeze(["path", "command", "pattern"]);
|
|
5
|
+
const KIND_SET = new Set(REFUSAL_ECHO_KINDS);
|
|
6
|
+
export function isRefusalEchoKind(v) {
|
|
7
|
+
return KIND_SET.has(v);
|
|
8
|
+
}
|
|
9
|
+
export function refusalEchoDefects(v) {
|
|
10
|
+
if (!Array.isArray(v) || v.length === 0)
|
|
11
|
+
return ["echoed is not a non-empty list"];
|
|
12
|
+
const out = [];
|
|
13
|
+
if (Reflect.ownKeys(v).length !== v.length + 1)
|
|
14
|
+
out.push("echoed holds a hole or a member that is no element");
|
|
15
|
+
for (let i = 0; i < v.length; i++) {
|
|
16
|
+
const e = v[i];
|
|
17
|
+
if (typeof e !== "object" || e === null || Array.isArray(e)) {
|
|
18
|
+
out.push(`echoed[${i}] is not an object`);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const r = e;
|
|
22
|
+
if (!isRefusalEchoKind(r.kind))
|
|
23
|
+
out.push(`echoed[${i}].kind is outside the closed set`);
|
|
24
|
+
if (typeof r.value !== "string" || r.value === "")
|
|
25
|
+
out.push(`echoed[${i}].value is not a non-empty string`);
|
|
26
|
+
if (r.canonical !== undefined && (typeof r.canonical !== "string" || r.canonical === "" || r.kind !== "path"))
|
|
27
|
+
out.push(`echoed[${i}].canonical stands only on a path, as a non-empty string`);
|
|
28
|
+
const stray = strayMembersOf(r, ECHO_WORDS, ECHO_MEMBERS);
|
|
29
|
+
if (stray !== undefined)
|
|
30
|
+
out.push(`echoed[${i}]: ${stray.sentence}`);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
package/dist/core/retention.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { EngineStorageBackend } from "./engine-storage-backend.js";
|
|
2
|
+
import type { WorkflowRunStore } from "./workflow-run-store.js";
|
|
1
3
|
/** A store's retention declaration: `"managed"` = this store's rows are deleted on schedule by the
|
|
2
4
|
* deployment; `"none"` = nothing deletes them on schedule. Absent ⇒ read fail-closed as `"none"`. */
|
|
3
5
|
export type RetentionDeclaration = "managed" | "none";
|
|
@@ -30,7 +32,7 @@ export interface RetentionPolicy {
|
|
|
30
32
|
/**
|
|
31
33
|
* The executor that deletes the rows of the stores declaring `retention: "managed"` — a backend's
|
|
32
34
|
* `retention` member (contract TYPE — core ships no implementation; the server half consumes this.
|
|
33
|
-
*
|
|
35
|
+
* The legs it calls, store by store and in order, are {@link RETENTION_CASCADE}). A deployment
|
|
34
36
|
* that declares a store managed runs one over that store's rows. Every method is expected to be:
|
|
35
37
|
* - **tenant-domain scoped**: work is enumerated and executed per retention domain (tenant/scope),
|
|
36
38
|
* never as one global sweep;
|
|
@@ -45,7 +47,10 @@ export interface RetentionPolicy {
|
|
|
45
47
|
* therefore the CALL's three counts, deliberately not an audit row. Where the deletion and the
|
|
46
48
|
* sweep's context live on two sides — a SQL backend writes the deletion, the deployment holds the op —
|
|
47
49
|
* the deployment writes the audit row through the backend's `audit` transaction hook, inside the
|
|
48
|
-
* deleting transaction, from the receipt it is handed there
|
|
50
|
+
* deleting transaction, from the receipt it is handed there;
|
|
51
|
+
* - **bounded by its call**: each call carries its own `cutoffMs`, computed by the party that runs the
|
|
52
|
+
* sweep (from its own horizon, e.g. a host's cleanup period in days) — an executor never reads
|
|
53
|
+
* {@link RetentionPolicy.maxAgeDays}, which is the startup check's to judge.
|
|
49
54
|
*/
|
|
50
55
|
export interface ManagedRetentionCapability {
|
|
51
56
|
/** Enumerate the retention domains (tenant/scope keys) this store holds data for. */
|
|
@@ -60,7 +65,8 @@ export interface ManagedRetentionCapability {
|
|
|
60
65
|
/** Lineage-aware transcript/session deletion: a session tree is deleted only when no live
|
|
61
66
|
* reference (fork child, background child, workflow run, pending checkpoint) still points into
|
|
62
67
|
* it — references are re-checked inside the deletion transaction, never assumed from a prior
|
|
63
|
-
* scan; {@link RETENTION_CASCADE_EXEMPT} is never deleted with one.
|
|
68
|
+
* scan; {@link RETENTION_CASCADE_EXEMPT} is never deleted with one. What one session's deletion
|
|
69
|
+
* erases, and in which order, is {@link RETENTION_CASCADE}'s session-tree legs. */
|
|
64
70
|
deleteExpiredSessions(input: {
|
|
65
71
|
domain: string;
|
|
66
72
|
cutoffMs: number;
|
|
@@ -72,6 +78,172 @@ export interface ManagedRetentionCapability {
|
|
|
72
78
|
cutoffMs: number;
|
|
73
79
|
}): Promise<RetentionReceipt>;
|
|
74
80
|
}
|
|
81
|
+
/** @contract retention.cascade_domains — the executor's three destructive operations, one domain each: checkpoint expiry
|
|
82
|
+
* (`expireCheckpoints`), session-tree deletion (`deleteExpiredSessions`) and orphan tool-result deletion
|
|
83
|
+
* (`deleteOrphanToolResults`). Every leg of {@link RETENTION_CASCADE} belongs to exactly one of them, and each has a leg. */
|
|
84
|
+
export declare const RETENTION_CASCADE_DOMAINS: readonly ["checkpoints", "session-trees", "orphan-tool-results"];
|
|
85
|
+
/** One of {@link RETENTION_CASCADE_DOMAINS}. */
|
|
86
|
+
export type RetentionCascadeDomain = (typeof RETENTION_CASCADE_DOMAINS)[number];
|
|
87
|
+
/** @contract retention.governance_records_outlive_the_purge — the pollution marker dir, the capture
|
|
88
|
+
* opt-out record dir and the lineage ledger are governance FACTS about content that exists, not
|
|
89
|
+
* session data: deleting them makes a one-way privacy record revocable. */
|
|
90
|
+
export declare const RETENTION_CASCADE_EXEMPT: readonly ["session-pollution", "session-capture-optout", "lineage.json"];
|
|
91
|
+
/** The stores {@link RETENTION_CASCADE} covers, by seat name: every store member of {@link EngineStorageBackend} and the
|
|
92
|
+
* workflow-run store a deployment constructs itself. */
|
|
93
|
+
export type RetentionCascadeStores = Omit<EngineStorageBackend, "retention" | "dispose"> & {
|
|
94
|
+
readonly workflowRunStore: WorkflowRunStore;
|
|
95
|
+
};
|
|
96
|
+
/** One leg of a store's row: the store method a domain's operation calls on it. */
|
|
97
|
+
export interface RetentionCascadeLeg<S = {
|
|
98
|
+
readonly [verb: string]: unknown;
|
|
99
|
+
}> {
|
|
100
|
+
readonly domain: RetentionCascadeDomain;
|
|
101
|
+
/** The store's method — a member of its interface (checked by the table's type). */
|
|
102
|
+
readonly verb: Extract<keyof S, string>;
|
|
103
|
+
/** What the call is given and what it removes. */
|
|
104
|
+
readonly selects: string;
|
|
105
|
+
/** A session-tree leg's place in one session's erasure (ascending; unique across the table). Present on a
|
|
106
|
+
* `"session-trees"` leg, absent on the other two domains' legs, whose operations each call one leg. */
|
|
107
|
+
readonly step?: number;
|
|
108
|
+
/** A fence the leg's store runs before the session's first step, where the store carries it (absent there ⇒ no fence). */
|
|
109
|
+
readonly fence?: Extract<keyof S, string>;
|
|
110
|
+
}
|
|
111
|
+
/** A store's one row: the legs that erase its rows, or why none do. */
|
|
112
|
+
export type RetentionCascadeRow<S = {
|
|
113
|
+
readonly [verb: string]: unknown;
|
|
114
|
+
}> = {
|
|
115
|
+
readonly legs: readonly RetentionCascadeLeg<S>[];
|
|
116
|
+
} | {
|
|
117
|
+
readonly exempt: string;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* @contract retention.cascade_table — what deleting a session erases, as one table: every store the engine persists in has exactly one
|
|
121
|
+
* row (typed complete against {@link RetentionCascadeStores}), either the legs that erase its rows (domain, verb, what the verb selects,
|
|
122
|
+
* and for a session-tree leg its step) or an exemption naming why its rows are not session data. A session tree is erased child
|
|
123
|
+
* sessions first; within one session every leg's fence runs before the first step, then the steps ascend and the session row's leg
|
|
124
|
+
* is last — a leg that fails leaves the row, so a retry runs the cascade again from its first step and converges. A leg that finds
|
|
125
|
+
* what it erases through another store's rows runs before that store's leg (the journals before the runs, the background agents'
|
|
126
|
+
* boxes before their rows), so a retry still finds them. A workflow run
|
|
127
|
+
* started in a deleted session goes with it, journal included: a later resume of that run from another session is refused
|
|
128
|
+
* `workflow.park_truth_unreadable` with `detail.reason: "record_missing"`, the word an absent prior record already answers. The run
|
|
129
|
+
* store is what indexes runs by session, so a deployment that wires a journal store without one leaves its journals out of reach.
|
|
130
|
+
*/
|
|
131
|
+
export declare const RETENTION_CASCADE: {
|
|
132
|
+
workflowJournalStore: {
|
|
133
|
+
legs: {
|
|
134
|
+
domain: "session-trees";
|
|
135
|
+
step: number;
|
|
136
|
+
verb: "deleteRun";
|
|
137
|
+
selects: string;
|
|
138
|
+
}[];
|
|
139
|
+
};
|
|
140
|
+
workflowRunStore: {
|
|
141
|
+
legs: {
|
|
142
|
+
domain: "session-trees";
|
|
143
|
+
step: number;
|
|
144
|
+
verb: "deleteBySession";
|
|
145
|
+
selects: string;
|
|
146
|
+
}[];
|
|
147
|
+
};
|
|
148
|
+
backgroundAgentStore: {
|
|
149
|
+
legs: {
|
|
150
|
+
domain: "session-trees";
|
|
151
|
+
step: number;
|
|
152
|
+
verb: "delete";
|
|
153
|
+
selects: string;
|
|
154
|
+
}[];
|
|
155
|
+
};
|
|
156
|
+
rosterStore: {
|
|
157
|
+
legs: {
|
|
158
|
+
domain: "session-trees";
|
|
159
|
+
step: number;
|
|
160
|
+
verb: "releaseAgent";
|
|
161
|
+
selects: string;
|
|
162
|
+
}[];
|
|
163
|
+
};
|
|
164
|
+
checkpointStore: {
|
|
165
|
+
legs: ({
|
|
166
|
+
domain: "session-trees";
|
|
167
|
+
step: number;
|
|
168
|
+
verb: "deleteSessionCheckpoints";
|
|
169
|
+
selects: string;
|
|
170
|
+
} | {
|
|
171
|
+
domain: "checkpoints";
|
|
172
|
+
verb: "reap";
|
|
173
|
+
selects: string;
|
|
174
|
+
step?: undefined;
|
|
175
|
+
})[];
|
|
176
|
+
};
|
|
177
|
+
toolResultStore: {
|
|
178
|
+
legs: ({
|
|
179
|
+
domain: "session-trees";
|
|
180
|
+
step: number;
|
|
181
|
+
verb: "deleteBySession";
|
|
182
|
+
selects: string;
|
|
183
|
+
} | {
|
|
184
|
+
domain: "orphan-tool-results";
|
|
185
|
+
verb: "deleteUnattributable";
|
|
186
|
+
selects: string;
|
|
187
|
+
step?: undefined;
|
|
188
|
+
})[];
|
|
189
|
+
};
|
|
190
|
+
sessionPolicyStore: {
|
|
191
|
+
legs: {
|
|
192
|
+
domain: "session-trees";
|
|
193
|
+
step: number;
|
|
194
|
+
verb: "deleteBySession";
|
|
195
|
+
selects: string;
|
|
196
|
+
}[];
|
|
197
|
+
};
|
|
198
|
+
fileHistoryStore: {
|
|
199
|
+
legs: {
|
|
200
|
+
domain: "session-trees";
|
|
201
|
+
step: number;
|
|
202
|
+
verb: "deleteBySession";
|
|
203
|
+
selects: string;
|
|
204
|
+
}[];
|
|
205
|
+
};
|
|
206
|
+
mailboxStore: {
|
|
207
|
+
legs: ({
|
|
208
|
+
domain: "session-trees";
|
|
209
|
+
step: number;
|
|
210
|
+
verb: "drop";
|
|
211
|
+
selects: string;
|
|
212
|
+
fence?: undefined;
|
|
213
|
+
} | {
|
|
214
|
+
domain: "session-trees";
|
|
215
|
+
step: number;
|
|
216
|
+
verb: "drop";
|
|
217
|
+
fence: "retireRecipient";
|
|
218
|
+
selects: string;
|
|
219
|
+
})[];
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* @contract retention.image_bytes_live_in_the_session_store — a transcript's image bytes have one holder, the engine's session store:
|
|
223
|
+
* they ride the session's log entries, so the session row's leg deletes them. A host that keeps a transcript of its own keeps a
|
|
224
|
+
* reference to them (session id, entry id, block index), never a second copy.
|
|
225
|
+
*/
|
|
226
|
+
sessionStore: {
|
|
227
|
+
legs: ({
|
|
228
|
+
domain: "session-trees";
|
|
229
|
+
step: number;
|
|
230
|
+
verb: "delete";
|
|
231
|
+
selects: string;
|
|
232
|
+
} | {
|
|
233
|
+
domain: "checkpoints";
|
|
234
|
+
verb: "unpin";
|
|
235
|
+
selects: string;
|
|
236
|
+
step?: undefined;
|
|
237
|
+
})[];
|
|
238
|
+
};
|
|
239
|
+
usageWindowStore: {
|
|
240
|
+
exempt: string;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
/** One session's erasure in order — {@link RETENTION_CASCADE}'s session-tree legs, ascending by step (the one reading of the order). */
|
|
244
|
+
export declare const RETENTION_SESSION_TREE_STEPS: readonly (RetentionCascadeLeg & {
|
|
245
|
+
readonly store: keyof RetentionCascadeStores;
|
|
246
|
+
})[];
|
|
75
247
|
/**
|
|
76
248
|
* The three counts one destructive retention call produced. NOT an audit row and deliberately
|
|
77
249
|
* identity-free (see the capability's `audited` clause): a scheduler that needs to tell two
|
|
@@ -79,13 +251,6 @@ export interface ManagedRetentionCapability {
|
|
|
79
251
|
* own occurrence id, operation, and timestamp inside the deleting transaction. Adding those here
|
|
80
252
|
* would ask a return value to know its own call context.
|
|
81
253
|
*/
|
|
82
|
-
/** @contract retention.cascade_domains — a managed-retention cascade deletes checkpoint rows,
|
|
83
|
-
* session trees (transcripts and lineage) and orphan tool results; nothing else is session data. */
|
|
84
|
-
export declare const RETENTION_CASCADE_DOMAINS: readonly ["checkpoints", "session-trees", "orphan-tool-results"];
|
|
85
|
-
/** @contract retention.governance_records_outlive_the_purge — the pollution marker dir, the capture
|
|
86
|
-
* opt-out record dir and the lineage ledger are governance FACTS about content that exists, not
|
|
87
|
-
* session data: deleting them makes a one-way privacy record revocable. */
|
|
88
|
-
export declare const RETENTION_CASCADE_EXEMPT: readonly ["session-pollution", "session-capture-optout", "lineage.json"];
|
|
89
254
|
export interface RetentionReceipt {
|
|
90
255
|
domain: string;
|
|
91
256
|
/** Rows destroyed by THIS call (idempotent retries count already-gone rows as 0, not errors). */
|
package/dist/core/retention.js
CHANGED
|
@@ -11,6 +11,50 @@ 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
|
+
});
|
|
55
|
+
export const RETENTION_SESSION_TREE_STEPS = deepFreeze(Object.entries(RETENTION_CASCADE)
|
|
56
|
+
.flatMap(([store, row]) => ("legs" in row ? row.legs.filter((leg) => leg.domain === "session-trees").map((leg) => ({ store, ...leg })) : []))
|
|
57
|
+
.sort((a, b) => (a.step ?? 0) - (b.step ?? 0)));
|
|
14
58
|
function codedError(code, message) {
|
|
15
59
|
const e = new Error(message);
|
|
16
60
|
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;
|
|
@@ -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,14 +162,20 @@ 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
|
|
166
|
-
* `classifier.unavailable` notice through the one throat
|
|
170
|
+
* `classifier.unavailable` notice through the one throat, under the leg's notice admission when it has one (`admission`).
|
|
171
|
+
* Both stations (the gate, the inherited fold) take it. */
|
|
167
172
|
export declare function classifierUnavailableSeat(args: ClassifierUnavailableStation & {
|
|
168
173
|
route: ApprovalRoute;
|
|
169
174
|
onNotice: RunnerDeps["onNotice"];
|
|
175
|
+
admission?: (notice: EngineNotice) => boolean;
|
|
170
176
|
sessionId?: string;
|
|
177
|
+
sourceSessionId?: string;
|
|
178
|
+
agentId?: string;
|
|
171
179
|
runId?: string;
|
|
172
180
|
}): ClassifierUnavailableSeat;
|
|
173
181
|
/** 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, admission, 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 } : {}) }), admission) };
|
|
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
|
}
|