@sema-agent/core 7.69.0 → 7.69.1
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 +583 -0
- package/dist/agents/repair-loop.js +6 -14
- package/dist/agents/subagent.js +2 -1
- package/dist/agents/verify.d.ts +1 -1
- package/dist/agents/verify.js +7 -1
- package/dist/brain/reasoning-request.d.ts +7 -0
- package/dist/brain/reasoning-request.js +6 -0
- package/dist/core/agent-config-dir.d.ts +39 -3
- package/dist/core/agent-config-dir.js +67 -11
- package/dist/core/allow-entry.d.ts +5 -5
- package/dist/core/allow-entry.js +12 -6
- package/dist/core/ask-headline.d.ts +2 -2
- package/dist/core/ask-origin.d.ts +31 -31
- package/dist/core/ask-origin.js +20 -13
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +1 -0
- package/dist/core/auto-compaction.d.ts +44 -62
- package/dist/core/auto-compaction.js +44 -103
- package/dist/core/cache-break-detector.d.ts +23 -11
- package/dist/core/cache-break-detector.js +11 -5
- package/dist/core/checkpoint-features.d.ts +1 -1
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +6 -0
- package/dist/core/checkpoint-row-verdict.js +3 -0
- package/dist/core/checkpoint-store.d.ts +13 -2
- package/dist/core/child-clamp-seats.d.ts +30 -3
- package/dist/core/child-clamp-seats.js +24 -0
- package/dist/core/compaction-retired-members.d.ts +12 -0
- package/dist/core/compaction-retired-members.js +22 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +2 -0
- package/dist/core/context-edit.d.ts +32 -17
- package/dist/core/context-edit.js +28 -0
- package/dist/core/cron.d.ts +68 -0
- package/dist/core/cron.js +259 -0
- package/dist/core/engine-attestation.d.ts +16 -0
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-capabilities.d.ts +14 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +18 -7
- package/dist/core/engine-version.js +1 -1
- package/dist/core/gate-outcome.d.ts +29 -2
- package/dist/core/gate-outcome.js +6 -0
- package/dist/core/git-read-only.d.ts +10 -0
- package/dist/core/git-read-only.js +1 -0
- package/dist/core/git-worktree-env.js +9 -8
- package/dist/core/governance-codes.d.ts +9 -2
- package/dist/core/governance-codes.js +9 -0
- package/dist/core/locked-config.js +7 -3
- package/dist/core/lsp.d.ts +3 -0
- package/dist/core/lsp.js +3 -2
- package/dist/core/memory-engine/engine.d.ts +48 -12
- package/dist/core/memory-engine/engine.js +108 -46
- package/dist/core/memory-engine/file-backend.d.ts +2 -1
- package/dist/core/memory-engine/index-copies.d.ts +47 -0
- package/dist/core/memory-engine/index-copies.js +88 -0
- package/dist/core/memory-engine/layout.d.ts +20 -3
- package/dist/core/memory-engine/layout.js +39 -3
- package/dist/core/memory-engine/origin-clearance.d.ts +9 -7
- package/dist/core/memory-engine/origin-clearance.js +2 -4
- package/dist/core/memory-engine/types.d.ts +16 -3
- package/dist/core/mode-policy.d.ts +7 -1
- package/dist/core/mode-policy.js +9 -0
- package/dist/core/mods/session-compact.js +3 -3
- package/dist/core/mods/stations.d.ts +2 -0
- package/dist/core/mods/stations.js +2 -1
- package/dist/core/path-guard-rows.d.ts +8 -3
- package/dist/core/path-guard-rows.js +18 -5
- package/dist/core/peer-seat.d.ts +3 -0
- package/dist/core/peer-seat.js +3 -0
- package/dist/core/permission-rule-model.js +3 -2
- package/dist/core/process-identity.d.ts +11 -3
- package/dist/core/process-identity.js +26 -16
- package/dist/core/runner/assemble-result.d.ts +5 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/cleared-results-record.d.ts +33 -0
- package/dist/core/runner/cleared-results-record.js +56 -0
- package/dist/core/runner/compact-session.js +14 -9
- package/dist/core/runner/compaction-knobs.d.ts +1 -1
- package/dist/core/runner/continuation-gate.js +2 -1
- package/dist/core/runner/continues-from.d.ts +1 -1
- package/dist/core/runner/continues-from.js +1 -1
- package/dist/core/runner/contracts.d.ts +83 -31
- package/dist/core/runner/conversation-segment.d.ts +19 -12
- package/dist/core/runner/conversation-segment.js +27 -7
- package/dist/core/runner/derived-route-fallback.d.ts +2 -12
- package/dist/core/runner/derived-route-fallback.js +0 -6
- package/dist/core/runner/gate-exit.d.ts +2 -1
- package/dist/core/runner/gate-exit.js +4 -2
- package/dist/core/runner/git-status-frame.d.ts +2 -2
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/leg-caller-places.d.ts +39 -0
- package/dist/core/runner/leg-caller-places.js +23 -0
- package/dist/core/runner/leg-frame.d.ts +8 -2
- package/dist/core/runner/leg-receipt.d.ts +29 -2
- package/dist/core/runner/leg-receipt.js +37 -6
- package/dist/core/runner/media-removed-seat.d.ts +10 -6
- package/dist/core/runner/media-removed-seat.js +6 -3
- package/dist/core/runner/messages-omitted-seat.d.ts +2 -1
- package/dist/core/runner/messages-omitted-seat.js +15 -5
- package/dist/core/runner/person-path-rows.d.ts +25 -7
- package/dist/core/runner/person-path-rows.js +16 -2
- package/dist/core/runner/prefix-ledger.d.ts +120 -0
- package/dist/core/runner/prefix-ledger.js +176 -0
- package/dist/core/runner/prepare-advisor.d.ts +2 -0
- package/dist/core/runner/prepare-advisor.js +2 -1
- package/dist/core/runner/prepare-artifact.d.ts +3 -0
- package/dist/core/runner/prepare-artifact.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -8
- package/dist/core/runner/prepare-config-doors.js +15 -12
- package/dist/core/runner/prepare-context-lane.d.ts +25 -6
- package/dist/core/runner/prepare-context-lane.js +82 -27
- package/dist/core/runner/prepare-gate-stations.d.ts +1 -2
- package/dist/core/runner/prepare-gate-stations.js +2 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +18 -5
- package/dist/core/runner/prepare-hands-readface.js +41 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +5 -0
- package/dist/core/runner/prepare-inherited-gate.js +2 -0
- package/dist/core/runner/prepare-memory.d.ts +10 -2
- package/dist/core/runner/prepare-memory.js +51 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -0
- package/dist/core/runner/prepare-policy-chain.js +13 -2
- package/dist/core/runner/prepare-prompt-assembly.d.ts +12 -4
- package/dist/core/runner/prepare-prompt-assembly.js +10 -4
- package/dist/core/runner/prepare-prompt-inputs.d.ts +3 -7
- package/dist/core/runner/prepare-prompt-inputs.js +6 -7
- package/dist/core/runner/prepare-safety-scan.js +7 -0
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -0
- package/dist/core/runner/prepare-suspend-saga.js +3 -2
- package/dist/core/runner/prepare-task.js +59 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -11
- package/dist/core/runner/prepare-tool-disclosure-mount.js +7 -8
- package/dist/core/runner/prepare-turn-wiring.d.ts +16 -25
- package/dist/core/runner/prepare-turn-wiring.js +8 -18
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
- package/dist/core/runner/prepare-wiring-manifest.js +3 -2
- package/dist/core/runner/prompt-suggestions.d.ts +3 -1
- package/dist/core/runner/prompt-suggestions.js +1 -1
- package/dist/core/runner/read-block-judge.d.ts +47 -0
- package/dist/core/runner/read-block-judge.js +33 -0
- package/dist/core/runner/role-resolution-table.d.ts +15 -10
- package/dist/core/runner/role-resolution-table.js +4 -5
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +7 -4
- package/dist/core/runner/rule-store-unreadable-notice.js +4 -3
- package/dist/core/runner/run-compaction-machinery.d.ts +0 -10
- package/dist/core/runner/run-compaction-machinery.js +3 -39
- package/dist/core/runner/run-harness-handlers.js +4 -17
- package/dist/core/runner/run-identity-wiring.js +4 -1
- package/dist/core/runner/run-leg.js +11 -1
- package/dist/core/runner/run-recovery-lanes.d.ts +0 -4
- package/dist/core/runner/run-recovery-lanes.js +34 -18
- package/dist/core/runner/run-settle-and-teardown.d.ts +1 -3
- package/dist/core/runner/run-settle-and-teardown.js +14 -22
- package/dist/core/runner/run-telemetry-and-budget-seats.js +0 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +11 -30
- package/dist/core/runner/run-terminal-adoption.js +5 -88
- package/dist/core/runner/run-tool-mount-facts.js +1 -5
- package/dist/core/runner/run-turn-boundary.js +56 -26
- package/dist/core/runner/runtask.js +7 -7
- package/dist/core/runner/session-hash-salt.d.ts +18 -0
- package/dist/core/runner/session-hash-salt.js +36 -0
- package/dist/core/runner/shell-env-withheld.d.ts +8 -5
- package/dist/core/runner/shell-env-withheld.js +3 -3
- package/dist/core/runner/side-call-account.d.ts +9 -1
- package/dist/core/runner/side-call-account.js +15 -4
- package/dist/core/runner/skill-mention.d.ts +12 -0
- package/dist/core/runner/skill-mention.js +50 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-table-view.d.ts +5 -9
- package/dist/core/runner/tool-table-view.js +23 -21
- package/dist/core/runner/write-protection-station.d.ts +5 -2
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +25 -27
- package/dist/core/scheduler.d.ts +13 -3
- package/dist/core/scheduler.js +0 -12
- package/dist/core/secret-env.d.ts +47 -11
- package/dist/core/secret-env.js +65 -4
- package/dist/core/sensitive-path-policy.js +4 -0
- package/dist/core/session-checkout.js +10 -9
- package/dist/core/shell-read-silence.d.ts +2 -1
- package/dist/core/shell-run-candidates.d.ts +1 -1
- package/dist/core/shell-run-candidates.js +11 -3
- package/dist/core/task-event.d.ts +32 -10
- package/dist/core/task-intake.d.ts +5 -3
- package/dist/core/task-intake.js +6 -2
- package/dist/core/task-result.d.ts +39 -0
- package/dist/core/task-spec-members.d.ts +3 -0
- package/dist/core/task-spec-members.js +2 -2
- package/dist/core/task-spec.d.ts +37 -20
- package/dist/core/tool-policy.d.ts +30 -18
- package/dist/core/tool-policy.js +44 -32
- package/dist/core/tool-roster.d.ts +21 -7
- package/dist/core/tool-roster.js +34 -6
- package/dist/core/tool-spec-members.js +1 -1
- package/dist/core/tool-spec.d.ts +27 -0
- package/dist/core/tools.js +1 -0
- package/dist/core/trace.d.ts +42 -19
- package/dist/core/unc-spelling.d.ts +31 -0
- package/dist/core/unc-spelling.js +51 -0
- package/dist/core/wiring-manifest.d.ts +30 -3
- package/dist/core/wiring-manifest.js +10 -0
- package/dist/core/workflow-run-store-contract.js +22 -0
- package/dist/core/workflow-run-store.d.ts +17 -13
- package/dist/core/workflow-run-store.js +1 -1
- package/dist/core/write-protect.d.ts +4 -0
- package/dist/core/write-protect.js +17 -15
- package/dist/engine/compaction/compaction.d.ts +48 -98
- package/dist/engine/compaction/compaction.js +136 -216
- package/dist/engine/compaction/utils.d.ts +2 -11
- package/dist/engine/compaction/utils.js +4 -13
- package/dist/engine/execution-env/node-execution-env.js +17 -6
- package/dist/engine/harness/agent-harness.d.ts +19 -5
- package/dist/engine/harness/agent-harness.js +18 -7
- package/dist/engine/harness/types.d.ts +5 -7
- package/dist/engine/loop/agent-loop.d.ts +14 -1
- package/dist/engine/loop/agent-loop.js +31 -11
- package/dist/engine/loop/types.d.ts +8 -2
- package/dist/index.d.ts +9 -6
- package/dist/index.js +8 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-spec.js +7 -2
- package/dist/orchestration/run-workflow-tool.js +5 -3
- package/dist/orchestration/workflow-park-adoption.d.ts +66 -8
- package/dist/orchestration/workflow-park-adoption.js +195 -45
- package/dist/orchestration/workflow-types.d.ts +20 -0
- package/dist/orchestration/workflow-types.js +1 -0
- package/dist/orchestration/workflow.d.ts +3 -2
- package/dist/orchestration/workflow.js +10 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/events.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/mechanism.d.ts +8 -0
- package/dist/prompt-assembly/catalog/mechanism.js +1 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +1 -1
- package/dist/prompt-assembly/catalog/schema.js +1 -0
- package/dist/prompt-assembly/catalog/sections.js +8 -0
- package/dist/prompt-assembly/event-registry.js +1 -0
- package/dist/prompt-assembly/select.js +1 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +14 -27
- package/dist/prompt-assembly/turn-snapshot.js +6 -18
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/default.d.ts +9 -0
- package/dist/prompts/default.js +4 -0
- package/dist/shell/lex.d.ts +75 -11
- package/dist/shell/lex.js +340 -76
- package/dist/tools/fs/bash-program-position.js +2 -6
- package/dist/tools/fs/bash-readonly-classifier.d.ts +18 -3
- package/dist/tools/fs/bash-readonly-classifier.js +19 -9
- package/dist/tools/fs/containment-face.d.ts +12 -3
- package/dist/tools/fs/containment-face.js +16 -7
- package/dist/tools/fs/file-read-check.d.ts +26 -1
- package/dist/tools/fs/file-read-check.js +20 -2
- package/dist/tools/fs/fs-bash.js +4 -4
- package/dist/tools/fs/fs-read.d.ts +3 -0
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-search-tools.d.ts +2 -2
- package/dist/tools/fs/fs-search-tools.js +4 -4
- package/dist/tools/fs/index.js +5 -3
- package/dist/tools/fs/pdf.js +12 -4
- package/dist/tools/fs/read-deny-home.d.ts +13 -2
- package/dist/tools/fs/read-deny-home.js +26 -22
- package/dist/tools/fs/read-deny.js +15 -6
- package/dist/tools/fs/removal-targets.d.ts +33 -17
- package/dist/tools/fs/removal-targets.js +160 -61
- package/dist/tools/fs/repo-map.d.ts +1 -1
- package/dist/tools/fs/repo-map.js +2 -2
- package/dist/tools/fs/safety.d.ts +28 -5
- package/dist/tools/fs/safety.js +72 -8
- package/dist/tools/fs/shell-read-bindings.d.ts +8 -2
- package/dist/tools/fs/shell-read-bindings.js +25 -6
- package/dist/tools/fs/shell-read-check.d.ts +3 -0
- package/dist/tools/fs/shell-read-check.js +22 -4
- package/dist/tools/fs/shell-read-establish.js +73 -43
- package/dist/tools/fs/shell-read-judge.d.ts +32 -14
- package/dist/tools/fs/shell-read-judge.js +13 -5
- package/dist/tools/fs/shell-read-object-path.d.ts +5 -1
- package/dist/tools/fs/shell-read-object-path.js +17 -4
- package/dist/tools/fs/shell-read-plan.d.ts +8 -2
- package/dist/tools/fs/shell-read-plan.js +36 -22
- package/dist/tools/fs/shell-read-sourced.js +12 -4
- package/dist/tools/fs/shell-read-start.d.ts +4 -2
- package/dist/tools/fs/shell-read-start.js +3 -3
- package/dist/tools/fs/shell-read-workdir.d.ts +14 -6
- package/dist/tools/fs/shell-read-workdir.js +35 -17
- package/dist/tools/scheduler-tools.d.ts +7 -17
- package/dist/tools/scheduler-tools.js +9 -85
- package/dist/tools/worktree.js +5 -4
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +47 -1
- package/wire-changes/core-stores-sql@7.68.6.json +39 -0
- package/wire-changes/core-stores-sql@7.69.1.json +39 -0
- package/wire-changes/core@7.68.6.json +125 -0
- package/wire-changes/core@7.69.1.json +2561 -0
- package/wire-changes/mods-kernel@7.68.6.json +39 -0
- package/wire-changes/mods-kernel@7.69.1.json +39 -0
- package/wire-changes/primitives@7.68.6.json +39 -0
- package/wire-changes/primitives@7.69.1.json +39 -0
- package/wire-changes/wiki-gate@7.68.6.json +39 -0
- package/wire-changes/wiki-gate@7.69.1.json +39 -0
- package/dist/core/runner/prompt-hash-salt.d.ts +0 -1
- package/dist/core/runner/prompt-hash-salt.js +0 -2
|
@@ -47,6 +47,8 @@ export interface PrepareAdvisorInput {
|
|
|
47
47
|
runId: string | undefined;
|
|
48
48
|
/** borrowed-readonly — the leg's usage-account door (the run body binds it before any tool call). */
|
|
49
49
|
sideCallBookRef: Prepared["sideCallBookRef"];
|
|
50
|
+
/** borrowed-readonly — reads each consultation's request against the session's main line before it goes out. */
|
|
51
|
+
observeSideRequest: Prepared["observeSideRequest"];
|
|
50
52
|
/** borrowed-readonly — the request the main lane last sent (read at each call). */
|
|
51
53
|
lastSentRequest: () => CompactionForkContext | undefined;
|
|
52
54
|
/** borrowed-readonly — the leg's resolved brain-call guardrail (the value doors' answer; `undefined` = off). */
|
|
@@ -8,6 +8,7 @@ import { derivedRouteFallsBack } from "./derived-route-fallback.js";
|
|
|
8
8
|
import { derivedLegBrain } from "./side-call-account.js";
|
|
9
9
|
import { withBrainCallGuardrail } from "../../brain/timeout.js";
|
|
10
10
|
import { modelLaneBrainOf } from "./model-lane-seat.js";
|
|
11
|
+
import { observingBrain } from "./prefix-ledger.js";
|
|
11
12
|
export async function prepareAdvisor(input) {
|
|
12
13
|
const { spec, deps, model, onceLedger, sessionId, runId } = input;
|
|
13
14
|
const told = onceLedger.arms().advisor;
|
|
@@ -74,7 +75,7 @@ function advisorSeat(input, model) {
|
|
|
74
75
|
const guarded = (b) => (ms === undefined ? b : { ...b, stream: withBrainCallGuardrail((m, c, o) => b.stream(m, c, o), ms, {}) });
|
|
75
76
|
return {
|
|
76
77
|
model,
|
|
77
|
-
brain: derivedLegBrain(() => guarded(modelLaneBrainOf(input.deps)), "advisor", book),
|
|
78
|
+
brain: derivedLegBrain(() => observingBrain(guarded(modelLaneBrainOf(input.deps)), input.observeSideRequest), "advisor", book),
|
|
78
79
|
lastSentRequest: input.lastSentRequest,
|
|
79
80
|
readBranch: () => input.session.getBranch(),
|
|
80
81
|
getApiKeyAndHeaders: input.spec.getApiKeyAndHeaders,
|
|
@@ -59,6 +59,9 @@ export interface PrepareArtifactInput {
|
|
|
59
59
|
* live set: an in-flight read-root grant widens it); `ready` settles once the run's newest tables are compiled — this
|
|
60
60
|
* reader is no call, and reads them only then. */
|
|
61
61
|
additionalRootsCanonical: (() => readonly string[]) & Pick<ReadRootsSeat, "ready">;
|
|
62
|
+
/** borrowed-readonly — what a refusal of a local file outside those roots names in place of the escape hint (the run's read
|
|
63
|
+
* face's remedy on a leg that refuses reads outside its directories); absent ⇒ the escape hint. */
|
|
64
|
+
outsideReadRemedy: string | undefined;
|
|
62
65
|
/** borrowed-readonly — the read-deny matcher in force for the run, when any. */
|
|
63
66
|
readDenyMatcher: PlacedReadDenyMatcher | undefined;
|
|
64
67
|
/** borrowed-readonly — the resolved read face (`"open"` lifts root containment for reads). */
|
|
@@ -14,7 +14,7 @@ import { sharedReadClassifier } from "./shared-read-classifier.js";
|
|
|
14
14
|
import { frozenApproverRoute } from "../wiring-manifest.js";
|
|
15
15
|
import { thrownText } from "../thrown-value.js";
|
|
16
16
|
export function prepareArtifact(input) {
|
|
17
|
-
const { deps, runId, taskId, sessionId, agentName, onAsk: approver, toolOccurrences, permissionMode, autoMode, executionEnv, rootCanonical, additionalRootsCanonical, readDenyMatcher, resolvedReadFace, handsCwdRef, roster, firstPartyOffload, artifactStoreRef } = input;
|
|
17
|
+
const { deps, runId, taskId, sessionId, agentName, onAsk: approver, toolOccurrences, permissionMode, autoMode, executionEnv, rootCanonical, additionalRootsCanonical, outsideReadRemedy, readDenyMatcher, resolvedReadFace, handsCwdRef, roster, firstPartyOffload, artifactStoreRef } = input;
|
|
18
18
|
const host = deps.artifactHost;
|
|
19
19
|
if (host === undefined)
|
|
20
20
|
return { artifactPlane: undefined };
|
|
@@ -50,7 +50,7 @@ export function prepareArtifact(input) {
|
|
|
50
50
|
return { ok: false, reason: "refused", text: "Error (Artifact): this task has no filesystem root, so a local file cannot be published." };
|
|
51
51
|
await additionalRootsCanonical.ready(signal);
|
|
52
52
|
const cwd = handsCwdRef?.current;
|
|
53
|
-
const judge = (s) => resolveKey(executionEnv, rootCanonical, path, s, cwd, additionalRootsCanonical, undefined, readDenyMatcher, resolvedReadFace);
|
|
53
|
+
const judge = (s) => resolveKey(executionEnv, rootCanonical, path, s, cwd, additionalRootsCanonical, undefined, readDenyMatcher, resolvedReadFace, outsideReadRemedy);
|
|
54
54
|
const rk = await judge(signal);
|
|
55
55
|
if (!rk.ok)
|
|
56
56
|
return { ok: false, reason: "refused", text: violationText("Artifact", rk.violation), details: violationDetails(rk.violation) };
|
|
@@ -152,6 +152,8 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
152
152
|
approvalParkNotResumable: ApprovalParkNotResumable | undefined;
|
|
153
153
|
/** borrowed-mutable — `Prepared.sideCallBookRef`: written by the run body (never here); the classifier books each of its replies through it. */
|
|
154
154
|
sideCallBookRef: Prepared["sideCallBookRef"];
|
|
155
|
+
/** borrowed-readonly — `Prepared.observeSideRequest`: reads each classification request against the session's main line before it goes out. */
|
|
156
|
+
observeSideRequest: Prepared["observeSideRequest"];
|
|
155
157
|
/** borrowed-readonly — whether the BUILT-IN SendMessage is on this face (the lane rule's second term). */
|
|
156
158
|
peerSendMessageBuiltIn: boolean;
|
|
157
159
|
/** borrowed-readonly — the trusted Runner self-reference the Workflow mount executes children through; undefined when
|
|
@@ -29,6 +29,7 @@ import { valveLeaves } from "../../agents/tool-filter.js";
|
|
|
29
29
|
import { RosterBuilder, callerMountSource } from "../tool-roster.js";
|
|
30
30
|
import { asThrownError, thrownText } from "../thrown-value.js";
|
|
31
31
|
import { modelLaneBrainOf } from "./model-lane-seat.js";
|
|
32
|
+
import { observingBrain } from "./prefix-ledger.js";
|
|
32
33
|
import { effectiveDurableApprovalOf } from "../tool-policy.js";
|
|
33
34
|
import { callerEntryOrigin, rebindProductEntry, specArmCanBuild } from "./caller-roster.js";
|
|
34
35
|
function assembleParentCaptureState(o, i, ctl, ancestors) {
|
|
@@ -122,14 +123,14 @@ function autoModeArmReasonOf(intent, facePresent, caps, capsFaulted) {
|
|
|
122
123
|
return { armed: true, reason: "armed" };
|
|
123
124
|
}
|
|
124
125
|
export async function prepareCapsAndWorkflow(input) {
|
|
125
|
-
const { spec, deps, parentSpecSeat, checkpointSeat, internals, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, delegationCwd, model, thinking, lockedPreflight, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, askSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, taskArtifacts, requestReview, enterPlanMode, permissionMode, readDenyEntries, peerLaneActive, peerSendMessageBuiltIn, runnerSelf, delegated, checkpointScope, approvalParkNotResumable, sideCallBookRef } = input;
|
|
126
|
+
const { spec, deps, parentSpecSeat, checkpointSeat, internals, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, delegationCwd, model, thinking, lockedPreflight, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, askSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, taskArtifacts, requestReview, enterPlanMode, permissionMode, readDenyEntries, peerLaneActive, peerSendMessageBuiltIn, runnerSelf, delegated, checkpointScope, approvalParkNotResumable, sideCallBookRef, observeSideRequest } = input;
|
|
126
127
|
const roster = new RosterBuilder(toolEffects);
|
|
127
128
|
roster.mounts.bindLeg({ leaves: valveLeaves(toolFaceSnapshot.selector), declared: spec.tools ?? [] });
|
|
128
129
|
roster.mounts.know(input.mountFacts);
|
|
129
130
|
for (const t of spec.tools ?? []) {
|
|
130
131
|
const mounted = mountCallerTool(t);
|
|
131
132
|
if (roster.mounts.judgeMember("caller", mounted))
|
|
132
|
-
roster.mount(mounted, { source: callerMountSource(mounted), mountedBy: "scenario" });
|
|
133
|
+
roster.mount(mounted, { source: callerMountSource(mounted), mountedBy: "scenario", ...(t.perTurn === true ? { perTurn: true } : {}) });
|
|
133
134
|
}
|
|
134
135
|
function mountCallerTool(t) {
|
|
135
136
|
const rebound = rebindProductEntry(t, enrichSpecToolCtx);
|
|
@@ -240,7 +241,7 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
240
241
|
const derivedDenyRules = readDenyClassifierRules(table.entries, table.ruleRows);
|
|
241
242
|
let classifierSystemPromptMemo;
|
|
242
243
|
const classifierSystemPrompt = () => (classifierSystemPromptMemo ??= buildAutoModePrompt({ ...am, derivedDenyRules, ...(classifierLaneRule ? { crossSessionMessagesRule: CROSS_SESSION_CLASSIFIER_RULE } : {}) }));
|
|
243
|
-
const classifierRuntime = brainToRuntime(modelLaneBrainOf(deps));
|
|
244
|
+
const classifierRuntime = brainToRuntime(observingBrain(modelLaneBrainOf(deps), observeSideRequest));
|
|
244
245
|
const classifierRungs = classifierLadderRungs(am.classifierFallback, classifierModel, model);
|
|
245
246
|
const denialTracking = createAutoModeDenialTracker(am.denialLimit);
|
|
246
247
|
const decider = createAutoModeDecider({
|
|
@@ -20,12 +20,16 @@ import type { PromptTraitName, RenderedLocale } from "../../prompt-assembly/cata
|
|
|
20
20
|
import { type CallerRosterSpec, type RosterSpec } from "./caller-roster.js";
|
|
21
21
|
import { type ScreenedNestedMemory } from "./nested-memory-lane.js";
|
|
22
22
|
/**
|
|
23
|
-
* The
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* written at `seat` passes the fast-tier door there.
|
|
23
|
+
* The compaction members a request may still carry that no pass reads (the summary always runs on the main model and
|
|
24
|
+
* reuses the main request): received, never resolved, told once per process each. One reading for a run's prepare and the
|
|
25
|
+
* out-of-run `Runner.compactSession` (`seat` names which face carried them).
|
|
27
26
|
*/
|
|
28
|
-
export declare function
|
|
27
|
+
export declare function announceIgnoredCompactionMembers(request: {
|
|
28
|
+
compactionModel?: unknown;
|
|
29
|
+
compaction?: {
|
|
30
|
+
clampTolerance?: unknown;
|
|
31
|
+
};
|
|
32
|
+
}, seat: "TaskSpec" | "compactSession", onNotice: RunnerDeps["onNotice"]): void;
|
|
29
33
|
export declare function limitConfigError(code: string, message: string): Error & {
|
|
30
34
|
code?: string;
|
|
31
35
|
};
|
|
@@ -199,9 +203,6 @@ export interface PrepareConfigDoorsResult {
|
|
|
199
203
|
model: Model;
|
|
200
204
|
/** owned — caller-explicit > role default > model default; undefined = off. */
|
|
201
205
|
thinking: ThinkingLevel | undefined;
|
|
202
|
-
/** owned — the compaction model: explicit wins, else the `summarize` role, else undefined (main
|
|
203
|
-
* model fallback inside maybeCompact). NOT derivable from {@link resolvedRole}. */
|
|
204
|
-
compModel: Model | undefined;
|
|
205
206
|
/** owned, frozen — model-gate DISCLOSURE data (the application itself already
|
|
206
207
|
* happened on {@link spec}: its `tools` is the survivor rebind when anything was removed).
|
|
207
208
|
* prepareTask emits the notices from this after the doors return (the onNotice station);
|
|
@@ -18,11 +18,12 @@ import { readSkillsSeat } from "./skills-seat.js";
|
|
|
18
18
|
import { screenHandsBandOptions } from "../hands-band-screen.js";
|
|
19
19
|
import { assertAutoConsolidationWirable } from "./memory-consolidation-driver.js";
|
|
20
20
|
import { malformedPricingField, priceTableOf } from "../pricing.js";
|
|
21
|
-
import {
|
|
21
|
+
import { fastTierNoticeTo } from "../fast-tier-door.js";
|
|
22
|
+
import { announceIgnoredCompactionMember } from "../compaction-retired-members.js";
|
|
22
23
|
import { receiveRoleMapPriced, resolveRunModel } from "./seat-model-doors.js";
|
|
23
24
|
import { ENTER_AS_IS, preflightLockedConfig, received } from "../locked-config.js";
|
|
24
25
|
import { assertRetentionWords } from "../retention.js";
|
|
25
|
-
import {
|
|
26
|
+
import { screenModelRole } from "../roles.js";
|
|
26
27
|
import { resolveSkillListingBudget } from "../skill-listing-budget.js";
|
|
27
28
|
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
28
29
|
import { compactionSeatsDefect } from "../context-settings.js";
|
|
@@ -64,11 +65,11 @@ const RETIRED_TASK_LIMIT_KEYS = {
|
|
|
64
65
|
callCapByDeadline: "(retired — no replacement)",
|
|
65
66
|
gracefulFinalize: "(retired — the approach notice is the only end-of-budget prompt)",
|
|
66
67
|
};
|
|
67
|
-
export function
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
export function announceIgnoredCompactionMembers(request, seat, onNotice) {
|
|
69
|
+
if (request.compactionModel !== undefined)
|
|
70
|
+
announceIgnoredCompactionMember(`${seat}.compactionModel`, onNotice);
|
|
71
|
+
if (request.compaction?.clampTolerance !== undefined)
|
|
72
|
+
announceIgnoredCompactionMember(`${seat}.compaction.clampTolerance`, onNotice);
|
|
72
73
|
}
|
|
73
74
|
export function limitConfigError(code, message) {
|
|
74
75
|
const e = new Error(message);
|
|
@@ -188,7 +189,7 @@ export function resolveMicroCompactKnob(bag) {
|
|
|
188
189
|
if (declaredMachine !== undefined && !MICRO_COMPACT_MACHINES.includes(declaredMachine)) {
|
|
189
190
|
throw microCompactConfigError("machine", declaredMachine, MICRO_COMPACT_MACHINES.map((m) => `"${m}"`).join(" | "));
|
|
190
191
|
}
|
|
191
|
-
return { machine: declaredMachine ?? "
|
|
192
|
+
return { machine: declaredMachine ?? "off", clearOnRejection: resolveClearOnRejection(bag) };
|
|
192
193
|
}
|
|
193
194
|
function resolveClearOnRejection(bag) {
|
|
194
195
|
const declared = bag?.clearOnRejection;
|
|
@@ -313,6 +314,8 @@ export function configValueDoors(input, enter = ENTER_AS_IS) {
|
|
|
313
314
|
});
|
|
314
315
|
if (spec.classifyAllShell !== undefined && typeof spec.classifyAllShell !== "boolean")
|
|
315
316
|
enter("taskConfig", () => { throw limitConfigError("config.invalid_argument", `TaskSpec.classifyAllShell must be a boolean when present (got ${describeRejectedValue(spec.classifyAllShell)}) — true lets no shell allow entry clear a call in auto mode; omit the key for the default.`); });
|
|
317
|
+
if (spec.blockReadsOutsideRoots !== undefined && typeof spec.blockReadsOutsideRoots !== "boolean")
|
|
318
|
+
enter("taskConfig", () => { throw limitConfigError("config.invalid_argument", `TaskSpec.blockReadsOutsideRoots must be a boolean when present (got ${describeRejectedValue(spec.blockReadsOutsideRoots)}) — true refuses reads outside this task's directories without asking; omit the key for the default.`); });
|
|
316
319
|
if (spec.fastMode !== undefined && typeof spec.fastMode !== "boolean")
|
|
317
320
|
enter("taskConfig", () => { throw limitConfigError("config.invalid_argument", `TaskSpec.fastMode must be a boolean when present (got ${describeRejectedValue(spec.fastMode)}) — true asks for fast speed on the models whose catalog entry declares it; omit the key for standard speed.`); });
|
|
318
321
|
const compactionSeats = typeof spec.compaction === "object" && spec.compaction !== null ? compactionSeatsDefect(spec.compaction, "TaskSpec.compaction") : undefined;
|
|
@@ -461,10 +464,11 @@ export function prepareConfigDoors(input) {
|
|
|
461
464
|
if (!entryDelegates(t))
|
|
462
465
|
return t;
|
|
463
466
|
const rebuilt = t.withAgents(perTask);
|
|
464
|
-
const
|
|
467
|
+
const stamps = { ...(t.modelGate !== undefined && rebuilt.modelGate === undefined ? { modelGate: t.modelGate } : {}), ...(t.perTurn !== undefined && rebuilt.perTurn === undefined ? { perTurn: t.perTurn } : {}) };
|
|
468
|
+
const restamp = Object.keys(stamps).length > 0;
|
|
465
469
|
if (restamp)
|
|
466
470
|
refuseRetiredMember(rebuilt, index);
|
|
467
|
-
return rosterFaceOf(restamp ? { ...rebuilt,
|
|
471
|
+
return rosterFaceOf(restamp ? { ...rebuilt, ...stamps } : rebuilt, index);
|
|
468
472
|
}),
|
|
469
473
|
};
|
|
470
474
|
}
|
|
@@ -521,7 +525,7 @@ export function prepareConfigDoors(input) {
|
|
|
521
525
|
discardedEnvRaw: gateDecision.discardedEnvRaw,
|
|
522
526
|
});
|
|
523
527
|
const thinking = resolvedRole.thinking;
|
|
524
|
-
|
|
528
|
+
announceIgnoredCompactionMembers(spec, "TaskSpec", deps.onNotice);
|
|
525
529
|
return {
|
|
526
530
|
spec,
|
|
527
531
|
deps,
|
|
@@ -538,7 +542,6 @@ export function prepareConfigDoors(input) {
|
|
|
538
542
|
resolvedRole,
|
|
539
543
|
model,
|
|
540
544
|
thinking,
|
|
541
|
-
compModel,
|
|
542
545
|
modelGate,
|
|
543
546
|
memoryDelegationEvidence,
|
|
544
547
|
skillListingBudget,
|
|
@@ -25,12 +25,14 @@ import type { ContextWindowOverlay } from "../context-settings.js";
|
|
|
25
25
|
import { type RequestCoreRef, type RequestSize } from "../context-guard.js";
|
|
26
26
|
import { type ToolResultSeat } from "../tool-result-store.js";
|
|
27
27
|
import { type RunnerDeps } from "../types.js";
|
|
28
|
-
import type { Prepared, PreparedMicroCompact } from "./contracts.js";
|
|
28
|
+
import type { InTurnCompactionVerdict, Prepared, PreparedMicroCompact } from "./contracts.js";
|
|
29
|
+
import type { CompactionForkContext } from "../auto-compaction.js";
|
|
29
30
|
import type { TurnPromptSnapshot } from "../../prompt-assembly/turn-snapshot.js";
|
|
30
31
|
import { type GitStatusLaneRef } from "./git-status-frame.js";
|
|
31
32
|
import type { ReadFileState } from "../../tools/fs/safety.js";
|
|
32
33
|
import { type ToolRosterDeltaSeat } from "../tool-roster.js";
|
|
33
34
|
import { type MediaBudgetRecord } from "./media-removed-seat.js";
|
|
35
|
+
import { type ClearedResultsSession } from "./cleared-results-record.js";
|
|
34
36
|
export interface PrepareContextLaneInput {
|
|
35
37
|
/** borrowed-readonly — the task model: the budgets, the trigger-window geometry and `charsPerToken` are read off it. */
|
|
36
38
|
model: Model;
|
|
@@ -60,6 +62,9 @@ export interface PrepareContextLaneInput {
|
|
|
60
62
|
* handler (the harness owns the listener; nothing unregisters it) — and `onToolTurnRepaired`, the provider boundary's
|
|
61
63
|
* repair sink. */
|
|
62
64
|
harness: AgentHarness;
|
|
65
|
+
/** borrowed-readonly — the request-build pass's main request: the request the loop is about to send for a view, rendered with
|
|
66
|
+
* no side effect (`undefined`: none to reuse — the pass keeps the independent form). Absent ⇒ never one. */
|
|
67
|
+
renderTurnStartRequest?: (view: AgentMessage[], signal?: AbortSignal) => Promise<CompactionForkContext | undefined>;
|
|
63
68
|
/** borrowed-mutable — the turn's halt fact (`Prepared.batchHaltRef`). Writer here: the handler CLEARS it at every new
|
|
64
69
|
* provider request (a new request means the halted boundary was legitimately passed). The judgment site sets it. */
|
|
65
70
|
batchHaltRef: Prepared["batchHaltRef"];
|
|
@@ -107,6 +112,9 @@ export interface PrepareContextLaneInput {
|
|
|
107
112
|
seededCopies?: ReadonlyMap<string, string>;
|
|
108
113
|
/** borrowed-readonly — the session's reminder mark, for the projection's marked sentences. */
|
|
109
114
|
reminderMark?: string;
|
|
115
|
+
/** borrowed-mutable — the leg's session: the cleared-results record is read at the first request build and appended after a
|
|
116
|
+
* build that changed the ledger (`cleared-results-record.ts`). */
|
|
117
|
+
session: ClearedResultsSession;
|
|
110
118
|
}
|
|
111
119
|
/**
|
|
112
120
|
* The request's copy projection as one request build reads it (`request-copy-projection.ts`): the lane measures the view
|
|
@@ -124,6 +132,8 @@ export interface RequestCopies {
|
|
|
124
132
|
/** The budget arm: when the core alone cannot fit `line`, the identities of its copies carried as pointers (oldest lose
|
|
125
133
|
* their contents first) — recorded for this request, and the read-state entries their copies witness retired. */
|
|
126
134
|
degradeCore(view: readonly AgentMessage[], held: ReadonlySet<AgentMessage>, line: number, cpt: number): void;
|
|
135
|
+
/** The copy identities the budget arm carries as pointers on this request (their contents left out); empty when none. */
|
|
136
|
+
pointed(): ReadonlySet<string>;
|
|
127
137
|
/** A new request build: no pointer identities yet. */
|
|
128
138
|
reset(): void;
|
|
129
139
|
}
|
|
@@ -184,9 +194,9 @@ export declare function landStaleResultClears(args: {
|
|
|
184
194
|
toolCallId?: string;
|
|
185
195
|
}>;
|
|
186
196
|
readFileState?: ReadFileState;
|
|
187
|
-
/** The leg's declaration seat: a clear that lands is a
|
|
197
|
+
/** The leg's declaration seat: a clear that lands is a `tool_result_clear` (the ledger replays it byte-stably after). The
|
|
198
|
+
* declaration names who changed the request and how; where it changed is the prefix ledger's byte measurement. */
|
|
188
199
|
seat: Pick<TurnPromptSnapshot, "declare"> | undefined;
|
|
189
|
-
firstChangedIndex?: number;
|
|
190
200
|
}): void;
|
|
191
201
|
/** See {@link runGuardChain}. */
|
|
192
202
|
export interface GuardChainArgs {
|
|
@@ -205,7 +215,9 @@ export interface GuardChainArgs {
|
|
|
205
215
|
trimPressureRef: {
|
|
206
216
|
droppedMessages: boolean;
|
|
207
217
|
};
|
|
208
|
-
|
|
218
|
+
/** Arm B is closed for this build, with what compaction already did: `landed` (the recheck after an adoption) or `noop` (the resend
|
|
219
|
+
* of a refused request, whose forced pass found nothing to fold). Absent ⇒ arm B is open. */
|
|
220
|
+
closedBy: "landed" | "noop" | undefined;
|
|
209
221
|
signal: AbortSignal | undefined;
|
|
210
222
|
/** The r7 per-request observation buffer — the chain DROPS it on its early returns (a discarded
|
|
211
223
|
* provisional projection must not narrate itself). */
|
|
@@ -222,6 +234,11 @@ export interface GuardChainArgs {
|
|
|
222
234
|
copies?: RequestCopies;
|
|
223
235
|
/** The leg's declaration seat: arm A's landing and the guard trim's drop declare their `history_rewrite` on it. */
|
|
224
236
|
seat: Pick<TurnPromptSnapshot, "declare"> | undefined;
|
|
237
|
+
/** The frontier pass's clear on this build: the size the view it cleared was judged at, and what the clear saved. */
|
|
238
|
+
cleared?: {
|
|
239
|
+
before: number;
|
|
240
|
+
saved: number;
|
|
241
|
+
};
|
|
225
242
|
}
|
|
226
243
|
export type GuardChainOutcome = {
|
|
227
244
|
earlyReturn: {
|
|
@@ -234,12 +251,14 @@ export type GuardChainOutcome = {
|
|
|
234
251
|
trimDroppedMessages: boolean;
|
|
235
252
|
/** the request reached the trim over the guard line — its core is then the caller's to judge */ overLine: boolean;
|
|
236
253
|
/** how many messages the trim left out (zero: the view fits) — absent on the stand-down, whose view is never announced */ omitted?: number;
|
|
254
|
+
/** what compaction did for this request over its guard — absent when arm B was not reached or its seat is unwired */ compaction?: InTurnCompactionVerdict;
|
|
255
|
+
/** the line a resend of this request is trimmed to after a refusal (see {@link resendLineOf}) */ lineAfterRefusal: (failureMessage: string | undefined) => number | undefined;
|
|
237
256
|
};
|
|
238
257
|
/**
|
|
239
258
|
* The GUARD CHAIN over one request build (D-7 case-ii transfer table),
|
|
240
259
|
* the chain reads the anchored
|
|
241
|
-
* coordinate re-estimated on the EDITED array
|
|
242
|
-
*
|
|
260
|
+
* coordinate re-estimated on the EDITED array, bounded by what this build's clear saved (the frontier
|
|
261
|
+
* pass's, {@link GuardChainArgs.cleared}, or arm A's). The opt-out machine = the pre-374 backstop order byte-identical
|
|
243
262
|
* (trim as the ordinary second line); otherwise arm A (blocking machine run, only when the
|
|
244
263
|
* frontier pass is off) → arm B (in-turn forced compaction behind the adopt seam) → arm C (trim,
|
|
245
264
|
* the disaster-only last resort and this chain's sole `context.trim` emitter). Returns either the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { convertToLlm, DEFAULT_CHARS_PER_TOKEN, estimateContextTokens, estimateTokens } from "../../internal/harness.js";
|
|
1
|
+
import { convertToLlm, DEFAULT_CHARS_PER_TOKEN, estimateContextTokens, estimateTokens, refusalShortfall } from "../../internal/harness.js";
|
|
2
2
|
import { ensureToolTurnInvariants, TOOL_TURN_REPAIR_DROPS } from "../../internal/llm.js";
|
|
3
3
|
import { droppedTransmissions, messageTransmission } from "../user-attachment.js";
|
|
4
4
|
import { chooseDegraded, copyIdentityOf, projectRequestCopies, projectRequestView } from "../request-copy-projection.js";
|
|
@@ -18,6 +18,8 @@ import { createToolTurnRepairSeat } from "./tool-turn-repair-seat.js";
|
|
|
18
18
|
import { createMediaBudgetSeat, createProviderRefusalSeat, createToolSchemaRemovedSeat } from "./media-removed-seat.js";
|
|
19
19
|
import { announceDigest, tellOncePerSession } from "./announce-once-ledger.js";
|
|
20
20
|
import { createMessagesOmittedSeat } from "./messages-omitted-seat.js";
|
|
21
|
+
import { createClearedResultsSeat } from "./cleared-results-record.js";
|
|
22
|
+
import { thrownText } from "../thrown-value.js";
|
|
21
23
|
export function createRequestCopies(seat) {
|
|
22
24
|
let degraded = new Set();
|
|
23
25
|
const input = () => ({ degraded, ...(seat.seeded !== undefined ? { seeded: seat.seeded } : {}), ...(seat.mark !== undefined ? { mark: seat.mark } : {}) });
|
|
@@ -60,6 +62,7 @@ export function createRequestCopies(seat) {
|
|
|
60
62
|
applyContextShrinkToReadFileState(seat.readFileState, { kind: "transmissions-gone", transmissions: gone });
|
|
61
63
|
}
|
|
62
64
|
},
|
|
65
|
+
pointed: () => degraded,
|
|
63
66
|
reset() {
|
|
64
67
|
degraded = new Set();
|
|
65
68
|
},
|
|
@@ -97,19 +100,38 @@ export function prepareContextLane(input) {
|
|
|
97
100
|
announceRepairs(repairs);
|
|
98
101
|
};
|
|
99
102
|
const mediaNotices = { onNotice: deps.onNotice, sessionId, runId };
|
|
100
|
-
|
|
101
|
-
harness.
|
|
102
|
-
|
|
103
|
+
const rewrote = (cause) => () => turnSnapshotRef.current?.declare({ cause });
|
|
104
|
+
harness.onImagesRemoved = createProviderRefusalSeat(mediaNotices, rewrote("history_rewrite"));
|
|
105
|
+
harness.onToolSchemaRefused = createToolSchemaRemovedSeat(deps.onNotice, { sessionId, runId }, rewrote("tool_table"));
|
|
106
|
+
const accountMediaCut = createMediaBudgetSeat(mediaNotices, input.announced, { tracer: deps.tracer, taskId: hostTaskId }, rewrote("history_rewrite"));
|
|
103
107
|
const announceOmitted = createMessagesOmittedSeat(mediaNotices);
|
|
108
|
+
let trimmedBefore = false;
|
|
109
|
+
let pointedBefore = new Set();
|
|
104
110
|
const copies = createRequestCopies({ ...(input.seededCopies !== undefined ? { seeded: input.seededCopies } : {}), ...(input.reminderMark !== undefined ? { mark: input.reminderMark } : {}), ...(readFileState !== undefined ? { readFileState } : {}) });
|
|
105
111
|
harness.projectRequestCopies = (view, folds) => projectRequestCopies(view, { ...copies.input(), folds });
|
|
112
|
+
const clearedResults = createClearedResultsSeat(input.session, (err, step) => {
|
|
113
|
+
try {
|
|
114
|
+
deps.onError?.(new Error(step === "read"
|
|
115
|
+
? `the session's record of cleared tool results could not be read (${thrownText(err)}): this run starts with none, so results an earlier run cleared are sent in full until they are cleared again`
|
|
116
|
+
: `the cleared tool results could not be recorded in the session (${thrownText(err)}): this run keeps them cleared and records them again at its next request; a later run that finds no record sends them in full until it clears them`), { phase: "degraded", sessionId, classification: "cleared-results-record" });
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
}
|
|
120
|
+
});
|
|
106
121
|
harness.on("context", async ({ messages, recheck, signal }) => {
|
|
122
|
+
const owed = microCompact.turnStartCompactionRef.owed;
|
|
123
|
+
microCompact.turnStartCompactionRef.owed = undefined;
|
|
124
|
+
const held = microCompact.projectionRef.resendLine;
|
|
125
|
+
microCompact.projectionRef.resendLine = undefined;
|
|
126
|
+
const resendLine = held !== undefined && held.turn === signal ? held.line : undefined;
|
|
107
127
|
copies.reset();
|
|
108
128
|
batchHaltRef.current = undefined;
|
|
109
129
|
const pendingProjectionObservations = [];
|
|
110
130
|
try {
|
|
111
|
-
const { editAt, guardAt, charsPerToken: cpt, media } = requestGeometry();
|
|
131
|
+
const { editAt, guardAt: windowLine, charsPerToken: cpt, media } = requestGeometry();
|
|
132
|
+
const guardAt = resendLine !== undefined ? Math.min(windowLine, resendLine) : windowLine;
|
|
112
133
|
const healed = dropEmptyFailureAssistants(messages);
|
|
134
|
+
await clearedResults.seed(microCompact.ledger);
|
|
113
135
|
const replay = replayClearedProjection(healed, microCompact.ledger);
|
|
114
136
|
const replayed = replay.messages;
|
|
115
137
|
const capped = await capAggregateToolResults(replayed, {
|
|
@@ -125,6 +147,13 @@ export function prepareContextLane(input) {
|
|
|
125
147
|
ts: Date.now(),
|
|
126
148
|
}))),
|
|
127
149
|
});
|
|
150
|
+
if (owed !== undefined) {
|
|
151
|
+
const fork = async () => replayed !== healed || trimRequestMedia(capped, media).removed.length > 0 ? undefined : await input.renderTurnStartRequest?.(capped, signal);
|
|
152
|
+
if ((await microCompact.turnStartCompactionRef.current?.(owed, signal, fork)) === true) {
|
|
153
|
+
pendingProjectionObservations.length = 0;
|
|
154
|
+
return { messages: capped, adoptSessionRebuild: true };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
128
157
|
const mediaTrim = trimRequestMedia(capped, media);
|
|
129
158
|
const mediaCapped = mediaTrim.messages;
|
|
130
159
|
if (mediaTrim.removed.length > 0)
|
|
@@ -146,11 +175,12 @@ export function prepareContextLane(input) {
|
|
|
146
175
|
const isHeld = (m) => held.has(m);
|
|
147
176
|
const chain = await runGuardChain({
|
|
148
177
|
edited, replayed, index: replay.index, microCompact, guardAt, charsPerToken: cpt,
|
|
149
|
-
taskId: hostTaskId, deps, trimPressureRef, recheck, signal, toolNameOf,
|
|
178
|
+
taskId: hostTaskId, deps, trimPressureRef, closedBy: recheck === true ? "landed" : resendLine !== undefined ? "noop" : undefined, signal, toolNameOf,
|
|
150
179
|
pendingProjectionObservations, seat: turnSnapshotRef.current,
|
|
151
180
|
...(readFileState !== undefined ? { readFileState } : {}),
|
|
152
181
|
held,
|
|
153
182
|
copies,
|
|
183
|
+
...(ccPass !== undefined ? { cleared: { before: copies.measure(mediaCapped, cpt).anchoredTokens, saved: ccPass.tokensSavedEstimate } } : {}),
|
|
154
184
|
});
|
|
155
185
|
if ("earlyReturn" in chain) {
|
|
156
186
|
return chain.earlyReturn;
|
|
@@ -168,6 +198,7 @@ export function prepareContextLane(input) {
|
|
|
168
198
|
sizeOf: sentTrimmed.sizeOf,
|
|
169
199
|
...(overLine ? { held: isHeld } : {}),
|
|
170
200
|
onDegrade: (message) => {
|
|
201
|
+
rewrote("history_rewrite")();
|
|
171
202
|
try {
|
|
172
203
|
deps.onError?.(new Error(message), { phase: "degraded", sessionId, classification: "env-git-snapshot" });
|
|
173
204
|
}
|
|
@@ -193,16 +224,25 @@ export function prepareContextLane(input) {
|
|
|
193
224
|
}
|
|
194
225
|
requestLossyRef.current =
|
|
195
226
|
replayed !== healed ||
|
|
196
|
-
capped !== replayed ||
|
|
197
227
|
mediaCapped !== capped ||
|
|
198
228
|
edited !== mediaCapped ||
|
|
199
229
|
working !== edited ||
|
|
200
230
|
trimDroppedMessages ||
|
|
231
|
+
copies.pointed().size > 0 ||
|
|
201
232
|
gitStatusRef.overBudgetShrunk === true;
|
|
202
|
-
microCompact.projectionRef.current = { messages: trimmed, keyOf: replay.index.keyOf };
|
|
203
|
-
const { omitted } = chain;
|
|
204
|
-
if (omitted !== undefined)
|
|
205
|
-
pendingProjectionObservations.push(() => announceOmitted(omitted));
|
|
233
|
+
microCompact.projectionRef.current = { messages: trimmed, keyOf: replay.index.keyOf, lineAfterRefusal: chain.lineAfterRefusal };
|
|
234
|
+
const { omitted, compaction } = chain;
|
|
235
|
+
if (omitted !== undefined) {
|
|
236
|
+
pendingProjectionObservations.push(() => announceOmitted(omitted, compaction));
|
|
237
|
+
if (omitted === 0 && trimmedBefore)
|
|
238
|
+
turnSnapshotRef.current?.declare({ cause: "history_rewrite" });
|
|
239
|
+
trimmedBefore = omitted > 0;
|
|
240
|
+
}
|
|
241
|
+
const pointedNow = copies.pointed();
|
|
242
|
+
if (pointedNow.size !== pointedBefore.size || [...pointedNow].some((id) => !pointedBefore.has(id)))
|
|
243
|
+
turnSnapshotRef.current?.declare({ cause: "history_rewrite" });
|
|
244
|
+
pointedBefore = pointedNow;
|
|
245
|
+
await clearedResults.record(microCompact.ledger);
|
|
206
246
|
return { messages: trimmed };
|
|
207
247
|
}
|
|
208
248
|
finally {
|
|
@@ -234,6 +274,7 @@ function buildMicroCompactState(deps, model, sessionId, runId, offloadStore, kno
|
|
|
234
274
|
ledger: createClearedProjectionLedger(),
|
|
235
275
|
projectionRef: {},
|
|
236
276
|
inTurnCompactionRef: {},
|
|
277
|
+
turnStartCompactionRef: { owed: "leg-start" },
|
|
237
278
|
...(offloadStore
|
|
238
279
|
? { offloadPersist: createOffloadPersist(offloadStore, sessionId, deps.onNotice, (deliver) => tellOncePerSession(announced, announceDigest("tool_result.offload_put_failed", `${sessionId}\nno_identity`), deliver)) }
|
|
239
280
|
: {}),
|
|
@@ -247,7 +288,7 @@ export function landStaleResultClears(args) {
|
|
|
247
288
|
transmissions.push(c.toolCallId);
|
|
248
289
|
}
|
|
249
290
|
if (args.cleared.length > 0)
|
|
250
|
-
args.seat?.declare({ cause: "
|
|
291
|
+
args.seat?.declare({ cause: "tool_result_clear" });
|
|
251
292
|
if (args.readFileState !== undefined) {
|
|
252
293
|
applyContextShrinkToReadFileState(args.readFileState, { kind: "transmissions-gone", transmissions });
|
|
253
294
|
}
|
|
@@ -268,7 +309,7 @@ function recordFrontierClears(args) {
|
|
|
268
309
|
});
|
|
269
310
|
}
|
|
270
311
|
}
|
|
271
|
-
landStaleResultClears({ ledger: args.ledger, cleared: landed, seat: args.seat, ...(args.
|
|
312
|
+
landStaleResultClears({ ledger: args.ledger, cleared: landed, seat: args.seat, ...(args.readFileState !== undefined ? { readFileState: args.readFileState } : {}) });
|
|
272
313
|
emitTrace(args.tracer, () => ({
|
|
273
314
|
kind: "context.mc_clear",
|
|
274
315
|
version: 1,
|
|
@@ -288,29 +329,41 @@ function flushProjectionObservations(pending) {
|
|
|
288
329
|
}
|
|
289
330
|
}
|
|
290
331
|
}
|
|
332
|
+
function resendLineOf(kept, keptTokens, charsPerToken, isHeld, sizeOf) {
|
|
333
|
+
return (failureMessage) => {
|
|
334
|
+
if (trimToBudget(kept, 0, undefined, charsPerToken, isHeld, sizeOf).length === kept.length)
|
|
335
|
+
return undefined;
|
|
336
|
+
return Math.max(irreducibleCoreTokens(kept, isHeld, charsPerToken, sizeOf), keptTokens - refusalShortfall(keptTokens, failureMessage, 1));
|
|
337
|
+
};
|
|
338
|
+
}
|
|
291
339
|
export async function runGuardChain(args) {
|
|
292
340
|
const { edited, microCompact, guardAt, charsPerToken, deps, taskId, held, copies } = args;
|
|
293
341
|
const isHeld = held !== undefined ? (m) => held.has(m) : undefined;
|
|
294
342
|
const anchoredOf = (view) => (copies !== undefined ? copies.measure(view, charsPerToken).anchoredTokens : estimateContextTokens([...view], charsPerToken).tokens);
|
|
295
343
|
const trimAsSent = (view, anchoredTotal) => {
|
|
296
|
-
if (copies === undefined)
|
|
297
|
-
|
|
344
|
+
if (copies === undefined) {
|
|
345
|
+
const kept = trimToBudget(view, guardAt, anchoredTotal, charsPerToken, isHeld);
|
|
346
|
+
return { kept, lineAfterRefusal: resendLineOf(kept, kept === view ? anchoredTotal : anchoredOf(kept), charsPerToken, isHeld) };
|
|
347
|
+
}
|
|
298
348
|
let kept = view;
|
|
299
349
|
let total = anchoredTotal;
|
|
300
350
|
for (;;) {
|
|
301
|
-
const
|
|
351
|
+
const { sizeOf } = copies.measure(kept, charsPerToken);
|
|
352
|
+
const next = trimToBudget(kept, guardAt, total, charsPerToken, isHeld, sizeOf);
|
|
302
353
|
if (next === kept || next.length >= kept.length)
|
|
303
|
-
return kept;
|
|
354
|
+
return { kept, lineAfterRefusal: resendLineOf(kept, total, charsPerToken, isHeld, sizeOf) };
|
|
304
355
|
kept = next;
|
|
305
356
|
total = anchoredOf(kept);
|
|
306
357
|
}
|
|
307
358
|
};
|
|
308
359
|
const applyGuardTrim = (view, anchoredTotal) => {
|
|
309
360
|
if (copies !== undefined && held !== undefined && anchoredTotal > guardAt) {
|
|
361
|
+
const was = anchoredOf(view);
|
|
310
362
|
copies.degradeCore(view, held, guardAt, charsPerToken);
|
|
311
|
-
anchoredTotal
|
|
363
|
+
anchoredTotal -= was - anchoredOf(view);
|
|
312
364
|
}
|
|
313
|
-
|
|
365
|
+
const { kept, lineAfterRefusal } = trimAsSent(view, anchoredTotal);
|
|
366
|
+
let trimmed = kept;
|
|
314
367
|
const dropped = trimmed.length < view.length;
|
|
315
368
|
const omitted = view.length - trimmed.length;
|
|
316
369
|
if (dropped) {
|
|
@@ -327,10 +380,11 @@ export async function runGuardChain(args) {
|
|
|
327
380
|
ts: Date.now(),
|
|
328
381
|
}));
|
|
329
382
|
}
|
|
330
|
-
return { trimmed, dropped, omitted };
|
|
383
|
+
return { trimmed, dropped, omitted, lineAfterRefusal };
|
|
331
384
|
};
|
|
385
|
+
const judged = (view, cleared) => cleared === undefined ? anchoredOf(view) : Math.min(anchoredOf(view), cleared.before - cleared.saved);
|
|
332
386
|
let working = edited;
|
|
333
|
-
let anchoredWorking =
|
|
387
|
+
let anchoredWorking = judged(working, args.cleared);
|
|
334
388
|
if (microCompact.machine === "off" && anchoredWorking > guardAt) {
|
|
335
389
|
let blockingPass;
|
|
336
390
|
const blockingEdited = clearStaleToolResults(working, {
|
|
@@ -344,21 +398,22 @@ export async function runGuardChain(args) {
|
|
|
344
398
|
});
|
|
345
399
|
if (blockingPass !== undefined) {
|
|
346
400
|
recordFrontierClears({ pass: blockingPass, index: args.index, edited: blockingEdited, ledger: microCompact.ledger, tracer: deps.tracer, taskId, trigger: "blocking", seat: args.seat, ...(args.readFileState !== undefined ? { readFileState: args.readFileState } : {}) });
|
|
401
|
+
anchoredWorking = judged(blockingEdited, { before: anchoredWorking, saved: blockingPass.tokensSavedEstimate });
|
|
347
402
|
working = blockingEdited;
|
|
348
|
-
anchoredWorking = anchoredOf(working);
|
|
349
403
|
}
|
|
350
404
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
405
|
+
let compaction = args.closedBy;
|
|
406
|
+
if (anchoredWorking > guardAt && args.closedBy === undefined) {
|
|
407
|
+
compaction = await microCompact.inTurnCompactionRef.current?.(args.signal, anchoredWorking);
|
|
408
|
+
if (compaction === "landed") {
|
|
354
409
|
args.pendingProjectionObservations.length = 0;
|
|
355
410
|
return { earlyReturn: { messages: working, adoptSessionRebuild: true } };
|
|
356
411
|
}
|
|
357
412
|
if (args.signal?.aborted === true) {
|
|
358
413
|
args.pendingProjectionObservations.length = 0;
|
|
359
|
-
return { working, trimmed: working, trimDroppedMessages: false, overLine: false };
|
|
414
|
+
return { working, trimmed: working, trimDroppedMessages: false, overLine: false, lineAfterRefusal: resendLineOf(working, anchoredWorking, charsPerToken, isHeld) };
|
|
360
415
|
}
|
|
361
416
|
}
|
|
362
417
|
const t = applyGuardTrim(working, anchoredWorking);
|
|
363
|
-
return { working, trimmed: t.trimmed, trimDroppedMessages: t.dropped, overLine: anchoredWorking > guardAt, omitted: t.omitted };
|
|
418
|
+
return { working, trimmed: t.trimmed, trimDroppedMessages: t.dropped, overLine: anchoredWorking > guardAt, omitted: t.omitted, ...(compaction !== undefined ? { compaction } : {}), lineAfterRefusal: t.lineAfterRefusal };
|
|
364
419
|
}
|
|
@@ -55,8 +55,7 @@ import { type CommandSandboxPlan } from "../command-sandbox.js";
|
|
|
55
55
|
* parity: the reference's reject handler (one handler for a tool call's card and the plan card) aborts the turn
|
|
56
56
|
* exactly when there is no feedback, no attached content and the run is not a subagent; a rejection WITH the decider's
|
|
57
57
|
* note, and every delegated child — forks included — keep the continue / adapt-or-report posture. True iff the record
|
|
58
|
-
* IS a person's refusal (
|
|
59
|
-
* that merely followed a human interaction), the refusal carried NO note (`settlement.note` absent — a fact composed
|
|
58
|
+
* IS a person's refusal ({@link isHumanRefusal}), the refusal carried NO note (`settlement.note` absent — a fact composed
|
|
60
59
|
* at the refusal, never re-derived from message text), and the leg is not a delegated child (the raw trusted
|
|
61
60
|
* delegation facet — the same fact that selects the refusal text's posture, so the boundary and the words the model
|
|
62
61
|
* was told always agree). Policy/hook/classifier denies and window/abort settlements never satisfy it. A leg it
|
|
@@ -4,7 +4,7 @@ import { heldWhileClassifying } from "../auto-mode.js";
|
|
|
4
4
|
import { complianceCallDenial } from "../compliance.js";
|
|
5
5
|
import { formatHookFeedback, runToolGate } from "../hooks.js";
|
|
6
6
|
import { continuationGateOf } from "./continuation-gate.js";
|
|
7
|
-
import { screenGateOutcome } from "../gate-outcome.js";
|
|
7
|
+
import { isHumanRefusal, screenGateOutcome } from "../gate-outcome.js";
|
|
8
8
|
import { directDeny, frozenInputSnapshot, permissionDeniedOf } from "./gate-exit.js";
|
|
9
9
|
import { emitTrace } from "../trace.js";
|
|
10
10
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
@@ -33,9 +33,7 @@ function screenGateResult(result) {
|
|
|
33
33
|
return defects.length > 0 ? { defects } : { gate, defects };
|
|
34
34
|
}
|
|
35
35
|
export function isBareHumanRefusal(gate, isDelegatedChild) {
|
|
36
|
-
|
|
37
|
-
const s = gate?.settlement;
|
|
38
|
-
return d?.kind === "denied" && d.deniedBy === "ask_resolution" && s?.kind === "human_refused" && s.note === undefined && !isDelegatedChild;
|
|
36
|
+
return isHumanRefusal(gate) && gate.settlement.note === undefined && !isDelegatedChild;
|
|
39
37
|
}
|
|
40
38
|
export function maybeHumanRejectionHalt(input) {
|
|
41
39
|
if (!isBareHumanRefusal(input.gate, input.isDelegatedChild))
|