@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
|
@@ -29,12 +29,11 @@ export interface WriteFaceSeat {
|
|
|
29
29
|
readonly fenced: boolean;
|
|
30
30
|
}
|
|
31
31
|
import type { MaterializedA2a } from "../a2a.js";
|
|
32
|
-
import type {
|
|
32
|
+
import type { CompactionForkContext, RapidRefillState } from "../auto-compaction.js";
|
|
33
33
|
import type { AutoModeArmingRecipe } from "../auto-mode-arming.js";
|
|
34
34
|
import type { AutoModeDecider, AutoModeDenialTracker, DenialLimitFallbackFace } from "../auto-mode.js";
|
|
35
35
|
import type { SettlementKind } from "../gate-outcome.js";
|
|
36
36
|
import type { AskClass } from "../ask-origin.js";
|
|
37
|
-
import type { CacheBreakDetector, ToolFingerprintInput } from "../cache-break-detector.js";
|
|
38
37
|
import type { Checkpoint, CheckpointState, CheckpointStore, CheckpointToken, PendingSteerEntry, PlatformLimitReason, ReopenReason, ResourceLedger, ResourceLimitReason, ResumeOutcome, SerializedCheckpointState } from "../checkpoint-store.js";
|
|
39
38
|
import type { ExecutionOutcomeRecordWord } from "../checkpoint-execution-record.js";
|
|
40
39
|
import type { ClearedProjectionLedger, MicroCompactMachine, OccurrenceIndex } from "../context-edit.js";
|
|
@@ -219,6 +218,25 @@ export interface DateAnchorRead {
|
|
|
219
218
|
/** The request head the anchor for the current segment recorded (the head of the epoch the session last
|
|
220
219
|
* opened); undefined ⇒ none recorded — the leg compares nothing and anchors its own. */
|
|
221
220
|
head?: PrefixHeadDigests;
|
|
221
|
+
/** Which store content the current segment's memory band was composed from; undefined ⇒ none recorded — the leg reads
|
|
222
|
+
* the store live and anchors what it read. */
|
|
223
|
+
memory?: MemoryTailSnapshot;
|
|
224
|
+
/** The head the session's legs last anchored, whatever segment it was written for (across a compaction too): what a
|
|
225
|
+
* leg's own head is compared with to declare a leg-start change; undefined ⇒ the branch holds none. */
|
|
226
|
+
lastHead?: PrefixHeadDigests;
|
|
227
|
+
}
|
|
228
|
+
/** Which store content the memory band of one segment was composed from, as the epoch anchor names it — never the content
|
|
229
|
+
* itself: the bytes (`IndexCopy`, each plane's raw index text and the marked bit) are kept in this process's memory only
|
|
230
|
+
* and found by both members together. A leg of the segment that finds them composes the band from them (its
|
|
231
|
+
* configuration-driven parts — the write instruction or a notice, the disciplines — are each leg's own), so a memory write
|
|
232
|
+
* moves the system prompt at the next segment; a leg that does not (another process, a moved key) reads the store live. */
|
|
233
|
+
export interface MemoryTailSnapshot {
|
|
234
|
+
/** Short digest of what the band may show (each plane's memory directory, scopes and write scope, whether the engine trusts
|
|
235
|
+
* its index, whether the mount reads the committed view only, the store state — the entries withheld as challenged, the
|
|
236
|
+
* erasure count): a leg whose key differs — memory mounted differently, a withholding or an erasure since — reads live. */
|
|
237
|
+
mount: string;
|
|
238
|
+
/** The sha256 of the content's bytes (`indexCopyDigest`). */
|
|
239
|
+
digest: string;
|
|
222
240
|
}
|
|
223
241
|
/** A leg's request head as the session's epoch anchor keeps it: one short unsalted digest per prompt block (by block
|
|
224
242
|
* id) and the tool table's wire digest — what a later leg compares its own head with to name the segments that moved. */
|
|
@@ -363,7 +381,6 @@ export interface Prepared {
|
|
|
363
381
|
/** The leg's fast mode (`TaskSpec.fastMode`, `TaskStream.setFastMode`) over its session tree's facts — the per-call handle
|
|
364
382
|
* (the main loop's, a compaction pass's, the suggestions') and every reading (`./fast-mode-seat.ts`). */
|
|
365
383
|
fastMode: import("./fast-mode-seat.js").FastModeLeg;
|
|
366
|
-
compModel?: Model;
|
|
367
384
|
mcp: MaterializedMcp;
|
|
368
385
|
/** The run handle's `reconnectMcpServer` implementation — {@link MaterializedMcp.reconnect} plus the
|
|
369
386
|
* live-roster application and the operator disclosure, which are runner concerns and not the MCP
|
|
@@ -451,11 +468,17 @@ export interface Prepared {
|
|
|
451
468
|
/** The normalized deny ADDITIONS in force (deployment ∪ task ∪ checkpoint seed; built-ins excluded), echoed on
|
|
452
469
|
* `TaskResult.effectiveReadDenyPatterns`. Present iff non-empty; a defensive copy (the working array stays the engine's). */
|
|
453
470
|
effectiveReadDenyPatterns?: readonly import("../../tools/fs/read-deny.js").NormalizedReadDenyEntry[];
|
|
471
|
+
/** The leg's declared places; their carried parts are echoed on `TaskResult.effectiveAgent{Config,Home}Dirs`. */ callerPlaces?: import("./leg-caller-places.js").LegCallerPlaces;
|
|
454
472
|
/** The memory-visibility observation prepareMemory minted (echoed on
|
|
455
473
|
* `TaskResult.effectiveMemoryScopes`). Always present on a completed prepare (the memory-less
|
|
456
474
|
* states are their own values); the seat is optional only so a Prepared shape without the phase
|
|
457
475
|
* cannot fabricate one. */
|
|
458
476
|
effectiveMemoryScopes?: import("../types.js").EffectiveMemoryScopes;
|
|
477
|
+
/** The byte floor's latch over every read-deny table this leg compiles, at prepare and after (the read-face phase's own,
|
|
478
|
+
* read, never re-derived): echoed on `TaskResult.readDenyFloor` at assembly; the wiring manifest read it when it was derived. */
|
|
479
|
+
readFloorUnkept: {
|
|
480
|
+
readonly current: boolean;
|
|
481
|
+
};
|
|
459
482
|
/** The leg's placement fixed point as prepare resolved it ONCE — the value the env-factory ctx was minted with and the suspend
|
|
460
483
|
* stamp records — echoed on `TaskResult.placementRoot`. Absent when the resolution came out empty (`""` is absence). */
|
|
461
484
|
placementRoot?: string;
|
|
@@ -579,15 +602,13 @@ export interface Prepared {
|
|
|
579
602
|
deliveryId: string;
|
|
580
603
|
toolCallId: string;
|
|
581
604
|
}>;
|
|
582
|
-
/**
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
tools: ToolFingerprintInput[];
|
|
590
|
-
};
|
|
605
|
+
/** The leg's main requests that do not extend the session's previous main request (`./prefix-ledger.ts`), in the order
|
|
606
|
+
* they were about to go out; the run's stream subscribes and mints one `prefix_changed` frame per change (released with
|
|
607
|
+
* the leg). Nothing is published while `RunnerDeps.cacheBreakDetection` is `false`. */
|
|
608
|
+
prefixChanges: import("./prefix-ledger.js").PrefixChangeSeat;
|
|
609
|
+
/** Reads a side request (a summary, a classification, an advisor or mod call, the suggestion pass) against the session's
|
|
610
|
+
* main line before it goes out; its reply's `brain.call` row carries the reading (`readingOfUsage`). */
|
|
611
|
+
observeSideRequest: import("./prefix-ledger.js").RequestObserver;
|
|
591
612
|
/**
|
|
592
613
|
* 提示词主权批 — the labelled composition of the assembled system prompt, emitted as the
|
|
593
614
|
* `prompt.assembled` trace event at task start. `constitution` says who owned the safety layer:
|
|
@@ -689,6 +710,8 @@ export interface Prepared {
|
|
|
689
710
|
chars: number;
|
|
690
711
|
hash: string;
|
|
691
712
|
}>;
|
|
713
|
+
/** How far the salted digests compare (`session` / `leg`) — `./session-hash-salt.ts`. */
|
|
714
|
+
hashScope: import("../trace.js").PromptHashScope;
|
|
692
715
|
sections: import("../trace.js").PromptManifestSection[];
|
|
693
716
|
/** Each overlay the composition superseded; absent when none was. */
|
|
694
717
|
superseded?: import("../../prompt-assembly/overlay.js").SupersededOverlay[];
|
|
@@ -774,8 +797,13 @@ export interface Prepared {
|
|
|
774
797
|
handle: MemorySessionHandle;
|
|
775
798
|
/** The session's scope contract (`TaskSpec.memory.scopeContract`): the owner of `handle.writeScope` is read under it. */
|
|
776
799
|
scopeContract: "v2" | undefined;
|
|
777
|
-
/** Merged injection across all planes (single-root sessions: identical to engine.inject(handle)).
|
|
778
|
-
|
|
800
|
+
/** Merged injection across all planes (single-root sessions: identical to engine.inject(handle)). `frozen` = the
|
|
801
|
+
* segment's anchored index text by plane (each plane serves its own instead of reading); `served` = the text each
|
|
802
|
+
* plane's injection was composed from (what the anchor freezes when nothing was frozen yet). */
|
|
803
|
+
inject: (frozen: import("../memory-engine/index-copies.js").IndexCopy["planes"] | undefined) => Promise<{
|
|
804
|
+
injection: import("../memory-engine/engine.js").MemoryInjection;
|
|
805
|
+
served: import("../memory-engine/index-copies.js").IndexCopy["planes"];
|
|
806
|
+
}>;
|
|
779
807
|
harvest: (phase?: "checkpoint" | "terminal") => Promise<HarvestReport | undefined>;
|
|
780
808
|
/** End this mount's session leg WITHOUT a harvest: the run that mounted it will never reach its
|
|
781
809
|
* terminal harvest (a prepare that failed after the mount). Never throws. */
|
|
@@ -1221,10 +1249,12 @@ export interface Prepared {
|
|
|
1221
1249
|
/** The leg's epoch-anchor seat: the anchor prepare read (undefined ⇒ the branch was unreadable, nothing is written) and
|
|
1222
1250
|
* the leg's request head as it stands when read (`tools` is the table as mounted, after the leg's activations and
|
|
1223
1251
|
* roster refreshes, before any request's view). The settle lane
|
|
1224
|
-
* writes the anchor when the head is not the recorded one (`owedDateAnchor`).
|
|
1252
|
+
* writes the anchor when the head is not the recorded one (`owedDateAnchor`). `memory` = the name of the store content
|
|
1253
|
+
* this leg read live, when it is not the one the segment's anchor names (present ⇒ the settle lane anchors it). */
|
|
1225
1254
|
prefixAnchor?: {
|
|
1226
1255
|
read: DateAnchorRead | undefined;
|
|
1227
1256
|
head: () => PrefixHeadDigests;
|
|
1257
|
+
memory?: MemoryTailSnapshot;
|
|
1228
1258
|
};
|
|
1229
1259
|
/** The `workflow_size_guideline_change` lane's seam, the {@link dateChange} shape one lane over:
|
|
1230
1260
|
* `legGuideline` = the RESOLVED guideline this leg's Workflow tool card was built with (the card is
|
|
@@ -1382,12 +1412,17 @@ export interface Prepared {
|
|
|
1382
1412
|
};
|
|
1383
1413
|
/** The microCompact machine state this run: the selected clearing
|
|
1384
1414
|
* machine, the cleared-projection ledger (request-view application, durable decisions — see
|
|
1385
|
-
* `context-edit.ts`'s ledger note;
|
|
1386
|
-
*
|
|
1415
|
+
* `context-edit.ts`'s ledger note; seeded from the session's record at the run's first request
|
|
1416
|
+
* build and recorded back after a build that changed it — `cleared-results-record.ts`), the last request's projection seat (what the provider actually
|
|
1387
1417
|
* saw — the MC-R rejection arm computes its candidates and savings on THIS view, never on the
|
|
1388
1418
|
* raw session rebuild), the MC-R knob, and the slice-3 arm-B seat. */
|
|
1389
1419
|
microCompact: PreparedMicroCompact;
|
|
1390
1420
|
}
|
|
1421
|
+
/** What the in-turn forced compaction did for a request over its guard: `landed` (the harness rebuilds and re-sends), or why it
|
|
1422
|
+
* did not — `off` (the run's automatic compaction is off), `paused` (the consecutive-failure breaker is open), `suppressed` (the
|
|
1423
|
+
* last landing freed too little and the conversation has not grown past it since), `noop` (nothing older to summarize), `failed`
|
|
1424
|
+
* (the summary did not land), `cut` (the turn, the run or its caller stopped). The guard trim's account to the person names it. */
|
|
1425
|
+
export type InTurnCompactionVerdict = "landed" | "off" | "paused" | "suppressed" | "noop" | "failed" | "cut";
|
|
1391
1426
|
/** See {@link Prepared.microCompact}. */
|
|
1392
1427
|
export interface PreparedMicroCompact {
|
|
1393
1428
|
/** The frontier-machine selection — `"off"` = no proactive frontier clearing (the machine
|
|
@@ -1398,7 +1433,7 @@ export interface PreparedMicroCompact {
|
|
|
1398
1433
|
clearOnRejection: boolean;
|
|
1399
1434
|
/** The in-turn forced-compaction seat: runtask wires a closure
|
|
1400
1435
|
* that runs the SAME forced-compaction pass the prompt-too-long recovery uses (gates included)
|
|
1401
|
-
* and answers
|
|
1436
|
+
* and answers what it did ({@link InTurnCompactionVerdict}: `landed` in the session, or why not). The context hook calls it when the
|
|
1402
1437
|
* pre-send estimate breaks the guard budget and then returns `adoptSessionRebuild` so the
|
|
1403
1438
|
* harness adopts the reduced transcript. `signal` is the TURN-scoped abort of the request
|
|
1404
1439
|
* build (r3): a turn interrupt must be able to cut the summary call short instead of waiting
|
|
@@ -1408,7 +1443,19 @@ export interface PreparedMicroCompact {
|
|
|
1408
1443
|
* declines and the chain falls to the trim last resort — same posture as a compaction-disabled
|
|
1409
1444
|
* run. */
|
|
1410
1445
|
inTurnCompactionRef: {
|
|
1411
|
-
current?: (signal?: AbortSignal, anchoredEstimate?: number) => Promise<
|
|
1446
|
+
current?: (signal?: AbortSignal, anchoredEstimate?: number) => Promise<InTurnCompactionVerdict>;
|
|
1447
|
+
};
|
|
1448
|
+
/** The request-build seat of the automatic threshold: the automatic compaction is judged before a request, never after
|
|
1449
|
+
* one. The turn boundary wires a closure that runs its OWN automatic pass (the natural threshold, the anti-thrash floor,
|
|
1450
|
+
* the breaker, the preCompact hook, the same landing and frames) and answers whether a compaction landed; the context hook
|
|
1451
|
+
* calls it when a judgment is `owed`, consuming the mark on entry. `owed` is `"leg-start"` at the leg's first build (the
|
|
1452
|
+
* automatic switch alone admits it) and `"boundary"` at the build after a boundary (which only measured; the within-task
|
|
1453
|
+
* switch admits it); a boundary no request follows leaves its mark unread. `signal` is the turn's abort (an interrupt cuts
|
|
1454
|
+
* the pass and is no compaction failure), `fork` the request that build is about to send (the reuse form's main request;
|
|
1455
|
+
* `undefined` ⇒ the independent form). Unwired ⇒ the request goes as built. */
|
|
1456
|
+
turnStartCompactionRef: {
|
|
1457
|
+
owed?: "leg-start" | "boundary";
|
|
1458
|
+
current?: (owed: "leg-start" | "boundary", signal: AbortSignal | undefined, fork: () => Promise<CompactionForkContext | undefined>) => Promise<boolean>;
|
|
1412
1459
|
};
|
|
1413
1460
|
ledger: ClearedProjectionLedger;
|
|
1414
1461
|
projectionRef: {
|
|
@@ -1417,6 +1464,17 @@ export interface PreparedMicroCompact {
|
|
|
1417
1464
|
messages: AgentMessage[];
|
|
1418
1465
|
/** Occurrence coordinates of that view (object-identity first, unambiguous-group fallback). */
|
|
1419
1466
|
keyOf: OccurrenceIndex["keyOf"];
|
|
1467
|
+
/** The line a resend of that request is trimmed to after a refusal (the refusal's error text in), or none when the
|
|
1468
|
+
* trim can shed nothing more from it — the guard chain's reading of its own trim. */
|
|
1469
|
+
lineAfterRefusal: (failureMessage: string | undefined) => number | undefined;
|
|
1470
|
+
};
|
|
1471
|
+
/** The rejection lane's answer to that request when the provider refused it and the forced pass found nothing to
|
|
1472
|
+
* fold: the line the resend is trimmed to, for the turn whose request it answers (`turn`, that turn's signal). The next
|
|
1473
|
+
* request build consumes it, and only the resend reads it — a build of another turn drops it: its guard line is the lower
|
|
1474
|
+
* of the window's and this one, and its forced pass has had its shot. */
|
|
1475
|
+
resendLine?: {
|
|
1476
|
+
readonly line: number;
|
|
1477
|
+
readonly turn: AbortSignal | undefined;
|
|
1420
1478
|
};
|
|
1421
1479
|
};
|
|
1422
1480
|
/** The run's ONE offload persist (write-once, idempotent): the frontier pass, the blocking-point arm and the MC-R arm all clear
|
|
@@ -2307,7 +2365,8 @@ export interface RunInternals {
|
|
|
2307
2365
|
* push (its own members cannot be reassigned; nested objects such as `manifest`, `entered`, `session` are the same objects
|
|
2308
2366
|
* the stream frame carries and are not frozen by this rule — read them, do not write them), offered at the push and only
|
|
2309
2367
|
* when the queue accepted it, so this seat sees the leg's frames in the order the stream holds them. `at` is
|
|
2310
|
-
* {@link LegAt}: the leg's `taskId` and `
|
|
2368
|
+
* {@link LegAt}: the leg's `taskId`, `sessionId` and `runId` (engine facts, on every frame; `runId` is the one two legs of one
|
|
2369
|
+
* session do not share) and `leg`,
|
|
2311
2370
|
* the composition's label for the leg when the dispatcher bound one — absent means nobody labelled the leg, never
|
|
2312
2371
|
* "implementation" (a plain `runTask` and a workflow agent call carry none; the verify gate labels `impl` / `verifier` /
|
|
2313
2372
|
* `fix`, the cascade labels each rung `rung` with its place on the ladder).
|
|
@@ -2739,7 +2798,6 @@ export interface RunState {
|
|
|
2739
2798
|
runId: string;
|
|
2740
2799
|
taskStart: number;
|
|
2741
2800
|
taskStartMonotonic: number;
|
|
2742
|
-
cacheBreakReported: boolean;
|
|
2743
2801
|
};
|
|
2744
2802
|
degrade: {
|
|
2745
2803
|
degradeToModel: Model | undefined;
|
|
@@ -3056,7 +3114,6 @@ export interface TurnBoundaryDeps {
|
|
|
3056
3114
|
compactionBreaker: {
|
|
3057
3115
|
failures: number;
|
|
3058
3116
|
};
|
|
3059
|
-
windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">;
|
|
3060
3117
|
rapidRefill: RapidRefillState;
|
|
3061
3118
|
drainManualCompact: (outcome: CompactOutcome) => void;
|
|
3062
3119
|
/** The leg's display (a top-level leg's), waited on at each boundary before its work. */
|
|
@@ -3278,6 +3335,10 @@ export interface TaskIdRef {
|
|
|
3278
3335
|
effectiveReasoning?: TaskResult["effectiveReasoning"];
|
|
3279
3336
|
delegationTerminalOwed?: HookInvocationIdentity;
|
|
3280
3337
|
editedFiles?: () => TaskResult["editedFiles"];
|
|
3338
|
+
/** The leg's byte-floor latch ({@link Prepared.readFloorUnkept}), read live: the backstop's `TaskResult.readDenyFloor`. */
|
|
3339
|
+
readFloorUnkept?: {
|
|
3340
|
+
readonly current: boolean;
|
|
3341
|
+
};
|
|
3281
3342
|
/** `false` from the moment a leg holding an owner seat starts until its row's owner is verified ({@link RunInternals.onSessionVerified}): a result minted meanwhile names no session (`""`). */
|
|
3282
3343
|
rowVerified?: boolean;
|
|
3283
3344
|
/** Whether the leg's prompt message was committed: `{ committed: false }` from the carrier's creation, replaced at the prompt
|
|
@@ -3300,15 +3361,6 @@ export interface ManualCompactRef {
|
|
|
3300
3361
|
}>;
|
|
3301
3362
|
emitMooted?: (reason: string) => void;
|
|
3302
3363
|
}
|
|
3303
|
-
/**
|
|
3304
|
-
* The end-of-task compaction pass's outcome (`Runner.finish`'s return): what the terminal-adoption lane
|
|
3305
|
-
* hands the settle lane, which reads it for the `compacted` frame, the phase-timings frame and the detector reset: what
|
|
3306
|
-
* the `compacted` frame's mint reads ({@link CompactedFrameSource}), plus whether the pass landed. Named once here so the
|
|
3307
|
-
* two lanes and the method spell one type.
|
|
3308
|
-
*/
|
|
3309
|
-
export type EndOfTaskCompaction = ({
|
|
3310
|
-
compacted: boolean;
|
|
3311
|
-
} & CompactedFrameSource) | undefined;
|
|
3312
3364
|
/**
|
|
3313
3365
|
* The notification lane's BINDINGS: the run-notification-lane's own `let`s as ONE seat (getters and setters over the lane's
|
|
3314
3366
|
* variables, never a copy). The identity-wiring lane binds `harness` / `sessionId` / `ident` the moment `prepared` exists; the
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { SessionTreeEntry } from "../../internal/harness-types.js";
|
|
2
|
-
import type { DateAnchorRead, PrefixHeadDigests, Prepared } from "./contracts.js";
|
|
2
|
+
import type { DateAnchorRead, MemoryTailSnapshot, PrefixHeadDigests, Prepared } from "./contracts.js";
|
|
3
3
|
/** The conversation's epoch ANCHOR (engine-owned; never model-visible): what the head of the session's requests was
|
|
4
|
-
* frozen to for the current segment — the date the system prefix renders,
|
|
4
|
+
* frozen to for the current segment — the date the system prefix renders, the head's own digests, and the name of the
|
|
5
|
+
* memory store content the memory band was composed from (never the content: that is kept in process memory only). */
|
|
5
6
|
export declare const DATE_ANCHOR_CUSTOM_TYPE = "engine:date-anchor";
|
|
7
|
+
/** The most index text (all planes together, in characters) a segment's memory band freezes; a larger index is served
|
|
8
|
+
* live on every leg. */
|
|
9
|
+
export declare const MEMORY_TAIL_MAX_CHARS: number;
|
|
6
10
|
/** The id of the active branch's latest compaction entry — the segment a fact is recorded for — or `null` before any. */
|
|
7
11
|
export declare function conversationSegmentOf(branch: ReadonlyArray<SessionTreeEntry>): string | null;
|
|
8
12
|
/** A seat that tells the model something once per segment: the frame its leg's first request still owes, and the segment that
|
|
@@ -30,10 +34,11 @@ export declare function restateToldSeat<V>(prepared: Pick<Prepared, "reminderMar
|
|
|
30
34
|
}): Promise<void>;
|
|
31
35
|
/**
|
|
32
36
|
* Read the session's epoch anchor off the active branch: the nearest anchor entry NEWER than the nearest compaction
|
|
33
|
-
* that carries each half (the date pair, the head), honored only when it was written for that
|
|
34
|
-
* anchor written by a leg whose prefix predates a compaction that landed in between therefore reads as
|
|
35
|
-
* one rule that makes a compaction re-anchor the epoch
|
|
36
|
-
*
|
|
37
|
+
* that carries each half (the date pair, the head, the memory content's name), honored only when it was written for that
|
|
38
|
+
* same segment. An anchor written by a leg whose prefix predates a compaction that landed in between therefore reads as
|
|
39
|
+
* absent — the one rule that makes a compaction re-anchor the epoch: the first leg of the new segment renders today's
|
|
40
|
+
* date and the memory store as it stands, and anchors them. An unreadable branch returns undefined (the leg renders
|
|
41
|
+
* today and the live store, compares nothing, writes nothing).
|
|
37
42
|
*/
|
|
38
43
|
export declare function readDateAnchor(session: {
|
|
39
44
|
getBranch(): Promise<ReadonlyArray<SessionTreeEntry>>;
|
|
@@ -49,15 +54,17 @@ export declare function prefixHeadBlocksOf(blocks: ReadonlyArray<{
|
|
|
49
54
|
export declare function headSegmentsChanged(anchored: PrefixHeadDigests, now: PrefixHeadDigests): string[];
|
|
50
55
|
/**
|
|
51
56
|
* The anchor write a leg owes when it settles, or undefined. Owed when the leg rendered a date and prepare found no
|
|
52
|
-
* anchored date for the segment or the model has since been told a newer one,
|
|
53
|
-
* the anchor recorded (the leg opened an epoch: its own head becomes the anchor)
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
+
* anchored date for the segment or the model has since been told a newer one, when the leg's head is not the one
|
|
58
|
+
* the anchor recorded (the leg opened an epoch: its own head becomes the anchor), or when the leg read the memory store
|
|
59
|
+
* live and what it read is not what the segment's anchor names (`memory`: the name of what it read); never after an
|
|
60
|
+
* unreadable branch. The date and head halves are small and ride every write (a half this leg did not produce is
|
|
61
|
+
* carried over from the anchor it read); the memory half is written only when owed — the halves are read one by one, so
|
|
62
|
+
* an entry without it never hides an earlier one. Best-effort — a lost write costs one re-rendered prefix, one repeated
|
|
63
|
+
* reminder, or one un-attributed leg start next leg, never a wrong date.
|
|
57
64
|
*/
|
|
58
65
|
export declare function owedDateAnchor(session: {
|
|
59
66
|
appendCustomEntry(customType: string, data?: unknown): Promise<string>;
|
|
60
67
|
}, read: DateAnchorRead | undefined, date: {
|
|
61
68
|
legDate: string;
|
|
62
69
|
announcedDate: string;
|
|
63
|
-
} | undefined, head: PrefixHeadDigests | undefined): (() => Promise<void>) | undefined;
|
|
70
|
+
} | undefined, head: PrefixHeadDigests | undefined, memory: MemoryTailSnapshot | undefined): (() => Promise<void>) | undefined;
|
|
@@ -6,7 +6,15 @@ import { flushOwedAnnouncedSnapshot } from "./announce-once-ledger.js";
|
|
|
6
6
|
export const DATE_ANCHOR_CUSTOM_TYPE = "engine:date-anchor";
|
|
7
7
|
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
8
8
|
const DIGEST = /^[0-9a-z:]{1,80}$/;
|
|
9
|
+
const SHA256 = /^[0-9a-f]{64}$/;
|
|
9
10
|
const MAX_HEAD_BLOCKS = 64;
|
|
11
|
+
export const MEMORY_TAIL_MAX_CHARS = 1024 * 1024;
|
|
12
|
+
function normalizeMemoryTail(v) {
|
|
13
|
+
if (typeof v !== "object" || v === null)
|
|
14
|
+
return undefined;
|
|
15
|
+
const { mount, digest } = v;
|
|
16
|
+
return typeof mount === "string" && DIGEST.test(mount) && typeof digest === "string" && SHA256.test(digest) ? { mount, digest } : undefined;
|
|
17
|
+
}
|
|
10
18
|
function normalizeHead(v) {
|
|
11
19
|
if (typeof v !== "object" || v === null)
|
|
12
20
|
return undefined;
|
|
@@ -21,14 +29,15 @@ function normalizeHead(v) {
|
|
|
21
29
|
function normalizeAnchor(v) {
|
|
22
30
|
if (typeof v !== "object" || v === null)
|
|
23
31
|
return undefined;
|
|
24
|
-
const { prefixDate, announcedDate, segment, head } = v;
|
|
32
|
+
const { prefixDate, announcedDate, segment, head, memory } = v;
|
|
25
33
|
if (segment !== null && (typeof segment !== "string" || segment.length > 200))
|
|
26
34
|
return undefined;
|
|
27
35
|
const date = typeof prefixDate === "string" && ISO_DATE.test(prefixDate) && typeof announcedDate === "string" && ISO_DATE.test(announcedDate) ? { prefixDate, announcedDate } : undefined;
|
|
28
36
|
const headRead = normalizeHead(head);
|
|
29
|
-
|
|
37
|
+
const memoryRead = normalizeMemoryTail(memory);
|
|
38
|
+
if (date === undefined && headRead === undefined && memoryRead === undefined)
|
|
30
39
|
return undefined;
|
|
31
|
-
return { ...(date !== undefined ? { date } : {}), ...(headRead !== undefined ? { head: headRead } : {}), segment };
|
|
40
|
+
return { ...(date !== undefined ? { date } : {}), ...(headRead !== undefined ? { head: headRead } : {}), ...(memoryRead !== undefined ? { memory: memoryRead } : {}), segment };
|
|
32
41
|
}
|
|
33
42
|
export function conversationSegmentOf(branch) {
|
|
34
43
|
for (let i = branch.length - 1; i >= 0; i--)
|
|
@@ -69,7 +78,8 @@ export async function readDateAnchor(session) {
|
|
|
69
78
|
}
|
|
70
79
|
let date;
|
|
71
80
|
let head;
|
|
72
|
-
|
|
81
|
+
let memory;
|
|
82
|
+
for (let i = branch.length - 1; i >= 0 && branch[i].type !== "compaction" && (date === undefined || head === undefined || memory === undefined); i--) {
|
|
73
83
|
const e = branch[i];
|
|
74
84
|
if (e.type !== "custom" || e.customType !== DATE_ANCHOR_CUSTOM_TYPE)
|
|
75
85
|
continue;
|
|
@@ -80,12 +90,22 @@ export async function readDateAnchor(session) {
|
|
|
80
90
|
date = entry;
|
|
81
91
|
if (head === undefined && entry.head !== undefined)
|
|
82
92
|
head = entry;
|
|
93
|
+
if (memory === undefined && entry.memory !== undefined)
|
|
94
|
+
memory = entry;
|
|
83
95
|
}
|
|
84
96
|
const segment = conversationSegmentOf(branch);
|
|
97
|
+
let lastHead;
|
|
98
|
+
for (let i = branch.length - 1; i >= 0 && lastHead === undefined; i--) {
|
|
99
|
+
const e = branch[i];
|
|
100
|
+
if (e.type === "custom" && e.customType === DATE_ANCHOR_CUSTOM_TYPE)
|
|
101
|
+
lastHead = normalizeAnchor(e.data)?.head;
|
|
102
|
+
}
|
|
85
103
|
return {
|
|
86
104
|
current: date !== undefined && date.segment === segment ? date.date : undefined,
|
|
87
105
|
segment,
|
|
88
106
|
...(head !== undefined && head.segment === segment ? { head: head.head } : {}),
|
|
107
|
+
...(memory !== undefined && memory.segment === segment ? { memory: memory.memory } : {}),
|
|
108
|
+
...(lastHead !== undefined ? { lastHead } : {}),
|
|
89
109
|
};
|
|
90
110
|
}
|
|
91
111
|
export function prefixHeadBlocksOf(blocks) {
|
|
@@ -102,14 +122,14 @@ export function headSegmentsChanged(anchored, now) {
|
|
|
102
122
|
const moved = [...new Set([...before, ...after])].filter((id) => anchored.blocks[id] !== now.blocks[id] || before.indexOf(id) !== after.indexOf(id)).sort();
|
|
103
123
|
return anchored.tools === now.tools ? moved : [...moved, "tools"];
|
|
104
124
|
}
|
|
105
|
-
export function owedDateAnchor(session, read, date, head) {
|
|
125
|
+
export function owedDateAnchor(session, read, date, head, memory) {
|
|
106
126
|
if (read === undefined)
|
|
107
127
|
return undefined;
|
|
108
128
|
const dateOwed = date !== undefined && read.current?.announcedDate !== date.announcedDate;
|
|
109
129
|
const headOwed = head !== undefined && (read.head === undefined || headSegmentsChanged(read.head, head).length > 0);
|
|
110
|
-
if (!dateOwed && !headOwed)
|
|
130
|
+
if (!dateOwed && !headOwed && memory === undefined)
|
|
111
131
|
return undefined;
|
|
112
132
|
const pair = date !== undefined ? { prefixDate: date.legDate, announcedDate: date.announcedDate } : read.current;
|
|
113
|
-
const data = { ...(pair !== undefined ? pair : {}), segment: read.segment, ...(head !== undefined ? { head } : read.head !== undefined ? { head: read.head } : {}) };
|
|
133
|
+
const data = { ...(pair !== undefined ? pair : {}), segment: read.segment, ...(head !== undefined ? { head } : read.head !== undefined ? { head: read.head } : {}), ...(memory !== undefined ? { memory } : {}) };
|
|
114
134
|
return () => session.appendCustomEntry(DATE_ANCHOR_CUSTOM_TYPE, data).then(() => undefined, () => undefined);
|
|
115
135
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The derived-leg route pre-flight shared by the run's derived seats: the
|
|
3
|
-
*
|
|
2
|
+
* The derived-leg route pre-flight shared by the run's derived seats: the auto-mode classifier model, the advisor model and
|
|
3
|
+
* the prompt-suggestion model (a compaction summary has no seat of its own: it runs on the main model). One guarded seat, reached DOWN for by each phase instead of spelled
|
|
4
4
|
* again; the judgment's reading and the announcements live in the brain's route adjudicator.
|
|
5
5
|
*/
|
|
6
6
|
import type { Model } from "../../internal/llm.js";
|
|
@@ -15,16 +15,6 @@ export type DerivedSeatOutcome = {
|
|
|
15
15
|
readonly action: "fall_back" | "detach";
|
|
16
16
|
readonly cause?: RouteJudgmentCause;
|
|
17
17
|
};
|
|
18
|
-
/**
|
|
19
|
-
* Whether the compaction-summary model is ROLE-derived — the only one whose route is pre-flighted (an EXPLICIT
|
|
20
|
-
* compaction model is a named leg and keeps the request gate's loud refusal). Synchronous: a caller awaits the
|
|
21
|
-
* pre-flight only when this holds, so a run with nothing to judge takes no suspension point at the seat.
|
|
22
|
-
*/
|
|
23
|
-
export declare function compactionSummaryIsDerived(explicit: boolean, compModel: Model | undefined): compModel is Model;
|
|
24
|
-
/** The compaction-summary seat after its route pre-flight: a refused derived summary model must not sink the pass — it falls back
|
|
25
|
-
* to the primary (`undefined`: the pass summarizes on the main model) and the fallback is announced. One reading for a run's
|
|
26
|
-
* prepare and the out-of-run compaction. */
|
|
27
|
-
export declare function compactionSummaryFallback(args: Omit<Parameters<typeof derivedRouteFallsBack>[0], "seat" | "onBrokenPairing">): Promise<Model | undefined>;
|
|
28
18
|
/**
|
|
29
19
|
* Judge the derived model where its route differs from the primary's and dispose of a refusal as THIS seat does
|
|
30
20
|
* (`onBrokenPairing`) — a judgment that throws or answers no verdict is a refusal like any other (the model lane would refuse every
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { adjudicateDerivedRoute, fallbackToPrimaryNotice, sameRouteIdentity, seatDetachedNotice, unroutableSeatNotice } from "../../brain/route-adjudicator.js";
|
|
2
2
|
import { deliverEngineNotice } from "../types.js";
|
|
3
|
-
export function compactionSummaryIsDerived(explicit, compModel) {
|
|
4
|
-
return !explicit && compModel !== undefined;
|
|
5
|
-
}
|
|
6
|
-
export async function compactionSummaryFallback(args) {
|
|
7
|
-
return (await derivedRouteFallsBack({ ...args, seat: "compaction-summary" })).action === "fall_back" ? undefined : args.derived;
|
|
8
|
-
}
|
|
9
3
|
export async function derivedRouteFallsBack(args) {
|
|
10
4
|
try {
|
|
11
5
|
if (sameRouteIdentity(args.derived, args.primary))
|
|
@@ -129,7 +129,8 @@ export interface SettlementLedger {
|
|
|
129
129
|
/** Record an ask's resolution; returns the resolution the gate goes on with (the resolver's, or the engine's refusal). */
|
|
130
130
|
fromResolved(resolved: ResolvedAsk, asked: PermissionResult, req: ToolCallRequest): ResolvedAsk;
|
|
131
131
|
/** Read an adjudication's record; returns the decision the gate goes on with and, for a deny, the refusing layer word
|
|
132
|
-
* (
|
|
132
|
+
* (a station's refusal settled in its name says the station's own word, `EngineAttestation.stationRefusal`;
|
|
133
|
+
* `ask_resolution` for a refusal record, `policy` otherwise — a veto when a yes rides the settlement). */
|
|
133
134
|
fromDecision(decision: PermissionResult): {
|
|
134
135
|
decision: PermissionResult;
|
|
135
136
|
deniedBy?: DeniedBy;
|
|
@@ -95,6 +95,7 @@ const SETTLEMENT_IS_HUMAN = {
|
|
|
95
95
|
policy_allowed: false,
|
|
96
96
|
policy_refused: false,
|
|
97
97
|
task_aborted: false,
|
|
98
|
+
approval_withdrawn: false,
|
|
98
99
|
};
|
|
99
100
|
const answerGroupOf = (r) => ({ ...(r.inputDigest !== undefined ? { licensed: r.inputDigest } : {}), ...(r.classes !== undefined ? { classes: r.classes } : {}) });
|
|
100
101
|
const sameClasses = (a, b) => a === undefined || b === undefined ? a === b : a.length === b.length && a.every((c, i) => c === b[i]);
|
|
@@ -174,7 +175,7 @@ export function createSettlementLedger(call) {
|
|
|
174
175
|
return { decision };
|
|
175
176
|
return { decision: { action: "deny", message: `the decision for "${call.toolName}" says allow but its engine record names a refusal ("${answer.settlement.kind}") — denied fail-closed`, decisionReason: "rule" }, deniedBy: "ask_resolution" };
|
|
176
177
|
}
|
|
177
|
-
return { decision, deniedBy: refusal ? "ask_resolution" : "policy" };
|
|
178
|
+
return { decision, deniedBy: record?.stationRefusal?.layer ?? (refusal ? "ask_resolution" : "policy") };
|
|
178
179
|
},
|
|
179
180
|
keepForBytes(runs) {
|
|
180
181
|
if (settled !== undefined && !licenseCovers(settled.licensed, call.toolName, runs))
|
|
@@ -394,7 +395,8 @@ export async function exitGate(pass) {
|
|
|
394
395
|
gate,
|
|
395
396
|
finalInput,
|
|
396
397
|
...(() => {
|
|
397
|
-
const
|
|
398
|
+
const record = attestationOf(pass.decision, { toolCallId, toolName });
|
|
399
|
+
const details = pathDenialCardOf(record?.pathDenial) ?? record?.stationRefusal?.details ?? pass.denyDetails ?? (modeRefusal !== undefined ? undefined : pass.shellReadDetails);
|
|
398
400
|
return details !== undefined ? { details } : {};
|
|
399
401
|
})(),
|
|
400
402
|
preToolContext: pass.preToolContext,
|
|
@@ -137,8 +137,8 @@ export interface GitStatusLaneRef {
|
|
|
137
137
|
*
|
|
138
138
|
* H4 anchor notes carried from the prepareTask body: four sections split by a sentinel line —
|
|
139
139
|
* main-branch inference (CC qP symref → [inferred, main, master] each show-ref → renderer falls
|
|
140
|
-
* back "main"), `git config user.name`, `git
|
|
141
|
-
* `
|
|
140
|
+
* back "main"), `git config user.name`, `git status --short`, and `git log --oneline -n 5` (CC-exact commands), every one
|
|
141
|
+
* opened with the read-only prefix (`GIT_READ_ONLY`: no hook, no fsmonitor program, no optional lock). The two
|
|
142
142
|
* REQUIRED sections fail the WHOLE script with distinct exit codes (41 = status, 42 = log) so a
|
|
143
143
|
* failing status never half-renders as "(clean)"; both now DEGRADE the frame to the branch+dirty
|
|
144
144
|
* residual instead of silently skipping. The main-branch/user sections stay best-effort.
|
|
@@ -6,6 +6,7 @@ import { openSystemReminder } from "../reminder-mint.js";
|
|
|
6
6
|
import { coreOverBudgetTerminal, engineRegionCovers, protectGitFrame } from "../context-guard.js";
|
|
7
7
|
import { gitFrameContextVisible } from "../../internal/harness.js";
|
|
8
8
|
import { thrownText } from "../thrown-value.js";
|
|
9
|
+
import { GIT_READ_ONLY as G } from "../git-read-only.js";
|
|
9
10
|
export const GIT_STATUS_FRAME_FORMAT_VERSION = 1;
|
|
10
11
|
const READ_BACK = (() => {
|
|
11
12
|
const readings = shippedReadings();
|
|
@@ -86,7 +87,7 @@ export async function probeGitStatusLane(args) {
|
|
|
86
87
|
};
|
|
87
88
|
try {
|
|
88
89
|
const snapFloor = readFloor?.();
|
|
89
|
-
const snap = await executionEnv.exec(`(m=$(
|
|
90
|
+
const snap = await executionEnv.exec(`(m=$(${G} symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null); m=\${m#origin/}; for s in "$m" main master; do if [ -n "$s" ] && ${G} show-ref --verify --quiet "refs/remotes/origin/$s"; then echo "$s"; break; fi; done) || true; echo "${SEP}"; (${G} config user.name 2>/dev/null || true); echo "${SEP}"; gs=$(${G} status --short) || exit 41; printf '%s\\n' "$gs"; echo "${SEP}"; gl=$(${G} log --oneline -n 5) || exit 42; printf '%s\\n' "$gl"`, { cwd: envFacts.cwd, timeout: 10, ...(snapFloor !== undefined ? { readFloor: snapFloor } : {}) });
|
|
90
91
|
if (snap.ok && snap.value.exitCode === 0) {
|
|
91
92
|
const parts = snap.value.stdout.split(`${SEP}\n`);
|
|
92
93
|
if (parts.length === 4) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function createRunState() {
|
|
2
2
|
return {
|
|
3
|
-
telemetry: { requestedModel: undefined, cacheFamily: "input-excludes-cached", pricing: { inputPer1M: 0, outputPer1M: 0 }, pricingConfigured: true, unpricedSpend: false, unpricedCause: undefined, tracer: undefined, taskId: "", runId: "", taskStart: 0, taskStartMonotonic: 0
|
|
3
|
+
telemetry: { requestedModel: undefined, cacheFamily: "input-excludes-cached", pricing: { inputPer1M: 0, outputPer1M: 0 }, pricingConfigured: true, unpricedSpend: false, unpricedCause: undefined, tracer: undefined, taskId: "", runId: "", taskStart: 0, taskStartMonotonic: 0 },
|
|
4
4
|
degrade: { degradeToModel: undefined, degraded: undefined, budgetSwitched: false, outputErrorStreak: 0, outputInvalid: false, recordDegraded: () => { }, priceOf: () => ({ pricing: { inputPer1M: 0, outputPer1M: 0 }, pricingConfigured: false, cacheFamily: "input-excludes-cached" }), fallbackSeat: { observe: () => { } } },
|
|
5
5
|
limits: { turnsExceeded: false, budgetHit: undefined, budgetAxis: undefined, platformTerminal: undefined, outputRetryCap: 0, effectiveMaxTurns: undefined, walltimeCrossedMs: undefined, budgetOverAtTurnCap: undefined },
|
|
6
6
|
budget: { remainingMicroUsd: undefined, maxCostMicroUsd: undefined, remainingTokens: undefined, maxTokensWindow: undefined, overBudget: () => undefined, streamCancel: false, callOutputChars: 0, lastStreamBudgetCheck: 0, projectedOverBudget: () => undefined, estimateRatesOf: () => ({ inputPer1M: 0, outputPer1M: 0 }), uncountedSpendStop: () => undefined },
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { RunnerDeps } from "../runner-deps.js";
|
|
2
|
+
import type { TaskSpec } from "../task-spec.js";
|
|
3
|
+
/** Which layer declared a place — the wiring manifest's word per place. */
|
|
4
|
+
export type DeclaredPlaceSource = "deployment" | "task" | "checkpoint";
|
|
5
|
+
/** One list of a leg's declared places: every place once, and the layers that declared it (index-aligned). `carried` is the part
|
|
6
|
+
* a child and a parked row take — every place a task layer declared (the task's own, a resumed row's); a place only the
|
|
7
|
+
* deployment declared is not carried, because every leg of the deployment declares it again (so a deployment that hands no
|
|
8
|
+
* task place mints its children's specs and its rows as before). */
|
|
9
|
+
export interface LegDeclaredPlaces {
|
|
10
|
+
readonly dirs: readonly string[];
|
|
11
|
+
readonly sources: ReadonlyArray<readonly DeclaredPlaceSource[]>;
|
|
12
|
+
readonly carried: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
/** A leg's two lists, and what a parked row records of them (each list's carried part as a fresh copy, an empty one absent). */
|
|
15
|
+
export interface LegCallerPlaces {
|
|
16
|
+
readonly configRoots: LegDeclaredPlaces;
|
|
17
|
+
readonly homes: LegDeclaredPlaces;
|
|
18
|
+
recorded(): {
|
|
19
|
+
agentConfigDirs: string[] | undefined;
|
|
20
|
+
agentHomeDirs: string[] | undefined;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** The members of a parked row a resume reads back (judged by shape here; a damaged one refuses the resume). */
|
|
24
|
+
export interface RecordedCallerPlaces {
|
|
25
|
+
readonly agentConfigDirs?: unknown;
|
|
26
|
+
readonly agentHomeDirs?: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Mint a leg's declared places.
|
|
30
|
+
*
|
|
31
|
+
* @contract agent_config_dir.leg_places_one_mint — the places a leg puts the configuration directory's rows and the
|
|
32
|
+
* home-anchored rows at are these two lists: every face reads them, none unions the layers again, and the deployment's root
|
|
33
|
+
* is among the roots whenever it is declared.
|
|
34
|
+
*/
|
|
35
|
+
export declare function legCallerPlaces(input: {
|
|
36
|
+
readonly deps: Pick<RunnerDeps, "agentConfigDir">;
|
|
37
|
+
readonly spec: Pick<TaskSpec, "agentConfigDirs" | "agentHomeDirs">;
|
|
38
|
+
readonly recorded: RecordedCallerPlaces | undefined;
|
|
39
|
+
}): LegCallerPlaces;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { recordedDeclaredDirs, declaredDirIdentity } from "../agent-config-dir.js";
|
|
2
|
+
import { unionAddOnly } from "../child-clamp-seats.js";
|
|
3
|
+
function placesOf(seat, layers) {
|
|
4
|
+
const dirs = unionAddOnly(seat, ...layers.map(([, list]) => list));
|
|
5
|
+
const sources = dirs.map((dir) => layers.filter(([, list]) => (list ?? []).some((d) => declaredDirIdentity(d) === declaredDirIdentity(dir))).map(([from]) => from));
|
|
6
|
+
const carried = dirs.filter((_, i) => sources[i].some((from) => from !== "deployment"));
|
|
7
|
+
return { dirs: Object.freeze([...dirs]), sources: Object.freeze(sources.map((s) => Object.freeze(s))), carried: Object.freeze(carried) };
|
|
8
|
+
}
|
|
9
|
+
export function legCallerPlaces(input) {
|
|
10
|
+
const recordedRoots = recordedDeclaredDirs("config", input.recorded?.agentConfigDirs, "CheckpointState.agentConfigDirs");
|
|
11
|
+
const recordedHomes = recordedDeclaredDirs("home", input.recorded?.agentHomeDirs, "CheckpointState.agentHomeDirs");
|
|
12
|
+
const configRoots = placesOf("agentConfigDirs", [
|
|
13
|
+
["deployment", input.deps.agentConfigDir === undefined ? undefined : [input.deps.agentConfigDir]],
|
|
14
|
+
["task", input.spec.agentConfigDirs],
|
|
15
|
+
["checkpoint", recordedRoots],
|
|
16
|
+
]);
|
|
17
|
+
const homes = placesOf("agentHomeDirs", [
|
|
18
|
+
["task", input.spec.agentHomeDirs],
|
|
19
|
+
["checkpoint", recordedHomes],
|
|
20
|
+
]);
|
|
21
|
+
const copy = (list) => (list.length > 0 ? [...list] : undefined);
|
|
22
|
+
return { configRoots, homes, recorded: () => ({ agentConfigDirs: copy(configRoots.carried), agentHomeDirs: copy(homes.carried) }) };
|
|
23
|
+
}
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
*
|
|
15
15
|
* WHAT. One frame object per offer, the very object the leg's queue received, shallow-frozen before the push; offered
|
|
16
16
|
* only when the queue accepted it (a closed stream refuses a late frame, and so does the seat). `at` names the leg the
|
|
17
|
-
* frame came from: its task id
|
|
18
|
-
* dispatcher bound one (`leg`, absent = nobody labelled this leg; the engine never mints one).
|
|
17
|
+
* frame came from: its task id, the session its rows land in and its run id (engine facts), and the composition's label when
|
|
18
|
+
* the dispatcher bound one (`leg`, absent = nobody labelled this leg; the engine never mints one).
|
|
19
19
|
*/
|
|
20
20
|
import type { TaskEvent } from "../types.js";
|
|
21
21
|
/** The frames a drained leg offers to `RunInternals.onLegFrame` — closed: a frame type outside it never reaches the seat. */
|
|
@@ -41,6 +41,12 @@ export interface LegAt {
|
|
|
41
41
|
readonly taskId: string;
|
|
42
42
|
/** The session the leg's rows land in. */
|
|
43
43
|
readonly sessionId: string;
|
|
44
|
+
/** The leg's run (`TaskResult.runId` of that leg; the engine's mint, one per leg). Two legs of one session — a verify
|
|
45
|
+
* gate's implementation leg and its fix legs, one task's successive messages — share `taskId` and `sessionId` and differ
|
|
46
|
+
* here, so a frame joins the result of the leg that offered it by this id. The engine sets it on every frame it offers;
|
|
47
|
+
* optional only so an address a host builds itself without it still type-checks. A leg whose prepare did not complete
|
|
48
|
+
* offers no frame at all (its frames start after prepare): a result whose `runId` no frame carries is such a leg. */
|
|
49
|
+
readonly runId?: string;
|
|
44
50
|
/** The composition's label for the leg; absent = nobody labelled it. */
|
|
45
51
|
readonly leg?: LegLabel;
|
|
46
52
|
}
|