@sema-agent/core 7.54.1 → 7.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +950 -0
- package/dist/agents/agent-transcript-tool.js +2 -1
- package/dist/agents/builtin-agents.d.ts +12 -14
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/cc-peer-directory.d.ts +36 -0
- package/dist/agents/cc-peer-directory.js +139 -0
- package/dist/agents/cc-peer-wire.d.ts +105 -0
- package/dist/agents/cc-peer-wire.js +98 -0
- package/dist/agents/cc-uds-peer-channel.d.ts +40 -0
- package/dist/agents/cc-uds-peer-channel.js +457 -0
- package/dist/agents/child-model-seat.d.ts +0 -11
- package/dist/agents/child-model-seat.js +0 -3
- package/dist/agents/cross-session-envelope.d.ts +4 -1
- package/dist/agents/cross-session-envelope.js +8 -1
- package/dist/agents/cross-session-judge.d.ts +2 -2
- package/dist/agents/list-agents-tool.d.ts +3 -1
- package/dist/agents/list-agents-tool.js +9 -8
- package/dist/agents/observer.d.ts +4 -5
- package/dist/agents/observer.js +2 -1
- package/dist/agents/peer-admission.d.ts +6 -0
- package/dist/agents/peer-admission.js +4 -1
- package/dist/agents/peer-directory.d.ts +65 -13
- package/dist/agents/peer-directory.js +90 -25
- package/dist/agents/peer-notices.d.ts +1 -1
- package/dist/agents/peer-session-drain.d.ts +3 -1
- package/dist/agents/peer-session-drain.js +3 -2
- package/dist/agents/read-inbox-tool.js +2 -1
- package/dist/agents/repair-loop.js +2 -2
- package/dist/agents/retain-ledger.d.ts +1 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/send-message-tool.d.ts +10 -0
- package/dist/agents/send-message-tool.js +37 -8
- package/dist/agents/subagent.d.ts +39 -82
- package/dist/agents/subagent.js +109 -106
- package/dist/agents/tool-filter.d.ts +31 -46
- package/dist/agents/tool-filter.js +13 -33
- package/dist/agents/verify.d.ts +6 -5
- package/dist/agents/verify.js +3 -3
- package/dist/brain/anthropic.js +43 -81
- package/dist/brain/errors.d.ts +15 -0
- package/dist/brain/errors.js +10 -0
- package/dist/brain/media-degrade.d.ts +18 -7
- package/dist/brain/media-degrade.js +13 -2
- package/dist/brain/model-capability.d.ts +37 -0
- package/dist/brain/model-capability.js +34 -0
- package/dist/brain/model-presets.d.ts +6 -12
- package/dist/brain/model-presets.js +1 -6
- package/dist/brain/open-responses.js +27 -35
- package/dist/brain/openai.js +30 -98
- package/dist/brain/provider-dialect.d.ts +39 -3
- package/dist/brain/provider-dialect.js +28 -0
- package/dist/brain/reasoning-request.d.ts +96 -0
- package/dist/brain/reasoning-request.js +174 -0
- package/dist/brain/reasoning.d.ts +12 -12
- package/dist/brain/reasoning.js +4 -3
- package/dist/brain/request-params.d.ts +62 -9
- package/dist/brain/request-params.js +42 -7
- package/dist/brain/retry.d.ts +1 -1
- package/dist/brain/route-adjudicator.d.ts +15 -0
- package/dist/brain/route-adjudicator.js +15 -0
- package/dist/brain/status-sink.d.ts +20 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/stream-engine.js +6 -5
- package/dist/brain/stream-shared.d.ts +1 -1
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +19 -13
- package/dist/core/advisor-verdict.d.ts +120 -0
- package/dist/core/advisor-verdict.js +92 -0
- package/dist/core/agent-definition.d.ts +17 -8
- package/dist/core/allow-entry.d.ts +69 -36
- package/dist/core/allow-entry.js +81 -52
- package/dist/core/allow-rule-shadow.d.ts +10 -3
- package/dist/core/approval-object.d.ts +2 -1
- package/dist/core/approval-object.js +6 -6
- package/dist/core/ask-origin.d.ts +127 -29
- package/dist/core/ask-origin.js +87 -25
- package/dist/core/ask-question.d.ts +51 -8
- package/dist/core/ask-question.js +12 -7
- package/dist/core/ask-unresolvable-notice.d.ts +8 -3
- package/dist/core/ask-unresolvable-notice.js +16 -2
- package/dist/core/auto-compaction.d.ts +11 -8
- package/dist/core/auto-compaction.js +4 -2
- package/dist/core/auto-mode-arming.d.ts +2 -2
- package/dist/core/auto-mode-defaults.d.ts +8 -8
- package/dist/core/auto-mode-prompt-assets.d.ts +3 -3
- package/dist/core/auto-mode-prompt.d.ts +1 -1
- package/dist/core/auto-mode.d.ts +17 -9
- package/dist/core/auto-mode.js +9 -6
- package/dist/core/background-agent-store.d.ts +3 -3
- package/dist/core/canonical-json.d.ts +1 -1
- package/dist/core/canonical-json.js +2 -2
- package/dist/core/checkpoint-generation.d.ts +53 -0
- package/dist/core/checkpoint-generation.js +35 -0
- package/dist/core/checkpoint-queries.d.ts +180 -0
- package/dist/core/checkpoint-queries.js +272 -0
- package/dist/core/checkpoint-requirements.d.ts +19 -4
- package/dist/core/checkpoint-requirements.js +8 -14
- package/dist/core/checkpoint-store.d.ts +165 -72
- package/dist/core/checkpoint-store.js +79 -82
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +3 -16
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/context-edit.d.ts +6 -7
- package/dist/core/cross-boundary-taint.d.ts +11 -4
- package/dist/core/cross-boundary-taint.js +3 -3
- package/dist/core/decision-receipt.d.ts +37 -3
- package/dist/core/decision-receipt.js +19 -19
- package/dist/core/delegation-not-started.d.ts +6 -0
- package/dist/core/delegation-not-started.js +17 -0
- package/dist/core/effective-path-target.d.ts +1 -1
- package/dist/core/engine-attestation.d.ts +93 -0
- package/dist/core/engine-attestation.js +70 -0
- package/dist/core/engine-capabilities.d.ts +4 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +45 -12
- package/dist/core/exec-output-tail.d.ts +1 -1
- package/dist/core/file-history-retention.d.ts +1 -1
- package/dist/core/file-history-store.d.ts +147 -21
- package/dist/core/file-history-store.js +58 -32
- package/dist/core/gate-fold.d.ts +1 -1
- package/dist/core/gate-fold.js +24 -11
- package/dist/core/gate-lanes.js +81 -68
- package/dist/core/gate-outcome.d.ts +40 -6
- package/dist/core/gate-outcome.js +56 -0
- package/dist/core/governance-codes.d.ts +17 -3
- package/dist/core/governance-codes.js +16 -0
- package/dist/core/hands-band.d.ts +1 -1
- package/dist/core/hooks.d.ts +21 -20
- package/dist/core/hooks.js +3 -1
- package/dist/core/host-floor.d.ts +128 -0
- package/dist/core/host-floor.js +206 -0
- package/dist/core/host-target.d.ts +84 -0
- package/dist/core/host-target.js +92 -0
- package/dist/core/image-downsample.d.ts +1 -1
- package/dist/core/lsp-diagnostics.d.ts +4 -4
- package/dist/core/lsp.d.ts +3 -3
- package/dist/core/mailbox-store.d.ts +4 -0
- package/dist/core/mcp-connection-pool.d.ts +18 -2
- package/dist/core/mcp-connection-pool.js +53 -6
- package/dist/core/mcp-failure.d.ts +23 -4
- package/dist/core/mcp-failure.js +26 -11
- package/dist/core/mcp-listing-drift.d.ts +10 -0
- package/dist/core/mcp-listing-drift.js +6 -0
- package/dist/core/mcp-server-link.d.ts +173 -0
- package/dist/core/mcp-server-link.js +127 -0
- package/dist/core/mcp-server-spec.d.ts +4 -2
- package/dist/core/mcp-session-end.d.ts +26 -0
- package/dist/core/mcp-session-end.js +29 -0
- package/dist/core/mcp-startup-request.d.ts +17 -0
- package/dist/core/mcp-startup-request.js +17 -0
- package/dist/core/mcp.d.ts +17 -13
- package/dist/core/mcp.js +240 -189
- package/dist/core/media-byte-cap.d.ts +1 -1
- package/dist/core/memory-engine/delegation-settlement.js +15 -24
- package/dist/core/memory-engine/engine.d.ts +9 -9
- package/dist/core/memory-engine/engine.js +4 -4
- package/dist/core/memory-engine/layout.d.ts +60 -8
- package/dist/core/memory-engine/layout.js +65 -6
- package/dist/core/memory-engine/provenance-wording.d.ts +1 -1
- package/dist/core/memory-engine/tools.js +4 -1
- package/dist/core/mode-policy.d.ts +1 -1
- package/dist/core/model-seat.d.ts +10 -3
- package/dist/core/mods/classic-events.d.ts +67 -0
- package/dist/core/mods/classic-events.js +1 -0
- package/dist/core/mods/dollar.d.ts +13 -0
- package/dist/core/mods/extension-call.d.ts +31 -0
- package/dist/core/mods/extension-call.js +43 -0
- package/dist/core/mods/kernel/dispatch.d.ts +20 -3
- package/dist/core/mods/kernel/dispatch.js +140 -69
- package/dist/core/mods/kernel/events.d.ts +47 -11
- package/dist/core/mods/kernel/events.js +66 -42
- package/dist/core/mods/kernel/index.d.ts +4 -4
- package/dist/core/mods/kernel/index.js +2 -2
- package/dist/core/mods/kernel/receive.d.ts +39 -5
- package/dist/core/mods/kernel/receive.js +290 -17
- package/dist/core/mods/kernel/registration.d.ts +33 -2
- package/dist/core/mods/kernel/registration.js +6 -7
- package/dist/core/mods/kernel/site-rules.d.ts +44 -16
- package/dist/core/mods/kernel/site-rules.js +24 -42
- package/dist/core/mods/spec-seats.d.ts +69 -0
- package/dist/core/mods/spec-seats.js +114 -0
- package/dist/core/mods/stations.d.ts +28 -8
- package/dist/core/mods/stations.js +29 -13
- package/dist/core/mods/tool-call.d.ts +79 -0
- package/dist/core/mods/tool-call.js +152 -0
- package/dist/core/namespaced-rule-name.d.ts +44 -24
- package/dist/core/namespaced-rule-name.js +50 -43
- package/dist/core/output-style.d.ts +1 -1
- package/dist/core/param-rule-reach.d.ts +15 -0
- package/dist/core/param-rule-reach.js +30 -0
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +6 -0
- package/dist/core/park-selfcheck.js +1 -0
- package/dist/core/pause-registry.d.ts +16 -5
- package/dist/core/pause-registry.js +6 -2
- package/dist/core/peer-channel.d.ts +70 -0
- package/dist/core/peer-channel.js +1 -0
- package/dist/core/permission-rule-consent.d.ts +30 -5
- package/dist/core/permission-rule-consent.js +147 -50
- package/dist/core/permission-rule-model.d.ts +245 -65
- package/dist/core/permission-rule-model.js +421 -107
- package/dist/core/permission-rule-org.d.ts +6 -2
- package/dist/core/permission-rule-org.js +7 -3
- package/dist/core/permission-rule-provider.d.ts +6 -2
- package/dist/core/permission-rule-provider.js +41 -11
- package/dist/core/permission-rule-store.d.ts +22 -26
- package/dist/core/permission-rule-store.js +12 -6
- package/dist/core/permission-rule-sync.d.ts +11 -2
- package/dist/core/permission-rule-sync.js +11 -3
- package/dist/core/permission-rule-syntax.d.ts +5 -4
- package/dist/core/permission-rule-syntax.js +2 -2
- package/dist/core/permission-rules.d.ts +53 -15
- package/dist/core/permission-rules.js +125 -100
- package/dist/core/persisted-rule-arms.d.ts +6 -4
- package/dist/core/persisted-rule-arms.js +10 -12
- package/dist/core/present-plan-tool.js +3 -1
- package/dist/core/principal-name.d.ts +20 -0
- package/dist/core/principal-name.js +22 -0
- package/dist/core/prompt-section-seat.js +4 -6
- package/dist/core/protocol-http-auth.d.ts +26 -5
- package/dist/core/protocol-http-auth.js +137 -4
- package/dist/core/protocol-naming.d.ts +2 -2
- package/dist/core/read-only-shell-table.d.ts +1 -1
- package/dist/core/read-only-shell.d.ts +1 -1
- package/dist/core/retired-keys.d.ts +16 -0
- package/dist/core/retired-keys.js +16 -4
- package/dist/core/rewrite-rejudge.d.ts +60 -0
- package/dist/core/rewrite-rejudge.js +36 -0
- package/dist/core/roles.d.ts +34 -3
- package/dist/core/roles.js +66 -53
- package/dist/core/rule-lane-reads.d.ts +20 -15
- package/dist/core/rule-lane-reads.js +45 -17
- package/dist/core/rule-offer-read.d.ts +53 -0
- package/dist/core/rule-offer-read.js +146 -0
- package/dist/core/rule-owner.d.ts +46 -0
- package/dist/core/rule-owner.js +29 -0
- package/dist/core/runner/advisor-instructions.d.ts +70 -0
- package/dist/core/runner/advisor-instructions.js +61 -0
- package/dist/core/runner/advisor-tool.d.ts +33 -0
- package/dist/core/runner/advisor-tool.js +112 -0
- package/dist/core/runner/announce-once-ledger.d.ts +18 -26
- package/dist/core/runner/announce-once-ledger.js +19 -46
- package/dist/core/runner/approval-feedback.js +6 -3
- package/dist/core/runner/assemble-result.d.ts +2 -1
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/call-hook-stations.d.ts +3 -2
- package/dist/core/runner/caller-roster.d.ts +21 -2
- package/dist/core/runner/caller-roster.js +38 -0
- package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
- package/dist/core/runner/capability-withheld-seat.js +24 -0
- package/dist/core/runner/classifier-ladder.d.ts +33 -13
- package/dist/core/runner/classifier-ladder.js +15 -14
- package/dist/core/runner/compaction-restate.d.ts +10 -6
- package/dist/core/runner/compaction-restate.js +9 -3
- package/dist/core/runner/construction-doors.js +3 -0
- package/dist/core/runner/contracts.d.ts +40 -33
- package/dist/core/runner/conversation-segment.d.ts +28 -0
- package/dist/core/runner/conversation-segment.js +42 -0
- package/dist/core/runner/cross-boundary-lane.d.ts +21 -16
- package/dist/core/runner/cross-boundary-lane.js +58 -34
- package/dist/core/runner/decide-continuation.d.ts +7 -4
- package/dist/core/runner/decide-continuation.js +2 -2
- package/dist/core/runner/denial-limit-arms.d.ts +4 -4
- package/dist/core/runner/denial-limit-arms.js +1 -1
- package/dist/core/runner/derived-route-fallback.d.ts +24 -24
- package/dist/core/runner/derived-route-fallback.js +9 -7
- package/dist/core/runner/file-history-request.d.ts +18 -0
- package/dist/core/runner/file-history-request.js +21 -13
- package/dist/core/runner/file-history-restore.d.ts +45 -0
- package/dist/core/runner/file-history-restore.js +46 -0
- package/dist/core/runner/gate-exit.d.ts +9 -3
- package/dist/core/runner/gate-exit.js +11 -5
- package/dist/core/runner/image.d.ts +7 -17
- package/dist/core/runner/image.js +9 -60
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +6 -6
- package/dist/core/runner/permission-rule-lanes.js +38 -15
- package/dist/core/runner/person-path-rows.d.ts +12 -9
- package/dist/core/runner/person-path-rows.js +19 -8
- package/dist/core/runner/prepare-advisor.d.ts +63 -0
- package/dist/core/runner/prepare-advisor.js +77 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
- package/dist/core/runner/prepare-ask-lane.js +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
- package/dist/core/runner/prepare-caps-and-workflow.js +5 -4
- package/dist/core/runner/prepare-config-doors.d.ts +31 -38
- package/dist/core/runner/prepare-config-doors.js +57 -34
- package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
- package/dist/core/runner/prepare-defer-classify.js +7 -8
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +1 -1
- package/dist/core/runner/prepare-file-history.d.ts +48 -8
- package/dist/core/runner/prepare-file-history.js +41 -73
- package/dist/core/runner/prepare-gate-stations.d.ts +2 -5
- package/dist/core/runner/prepare-gate-stations.js +12 -8
- package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
- package/dist/core/runner/prepare-hands-readface.js +15 -14
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -7
- package/dist/core/runner/prepare-inherited-gate.js +8 -6
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.js +12 -12
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -4
- package/dist/core/runner/prepare-policy-chain.js +68 -81
- package/dist/core/runner/prepare-project-context.d.ts +5 -2
- package/dist/core/runner/prepare-project-context.js +6 -3
- package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
- package/dist/core/runner/prepare-prompt-assembly.js +10 -8
- package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
- package/dist/core/runner/prepare-prompt-inputs.js +4 -6
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +5 -4
- package/dist/core/runner/prepare-safety-scan.d.ts +9 -12
- package/dist/core/runner/prepare-safety-scan.js +8 -23
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +5 -6
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +41 -35
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
- package/dist/core/runner/prepare-tool-disclosure-mount.js +24 -18
- package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
- package/dist/core/runner/prepare-turn-wiring.js +2 -7
- package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -4
- package/dist/core/runner/prepare-wiring-manifest.js +3 -3
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -12
- package/dist/core/runner/resume-checkpoint-screen.js +3 -0
- package/dist/core/runner/resume-claim.d.ts +4 -2
- package/dist/core/runner/resume-claim.js +15 -8
- package/dist/core/runner/resume-policy-outcome.js +1 -1
- package/dist/core/runner/retired-runner-deps.js +2 -1
- package/dist/core/runner/rewind-files.d.ts +15 -0
- package/dist/core/runner/rewind-files.js +132 -0
- package/dist/core/runner/run-attachment-seats.js +2 -2
- package/dist/core/runner/run-brain-sinks.d.ts +4 -1
- package/dist/core/runner/run-brain-sinks.js +4 -2
- package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
- package/dist/core/runner/run-compaction-machinery.js +2 -12
- package/dist/core/runner/run-git-lane.d.ts +1 -0
- package/dist/core/runner/run-harness-handlers.js +14 -7
- package/dist/core/runner/run-leg.d.ts +1 -1
- package/dist/core/runner/run-leg.js +43 -18
- package/dist/core/runner/run-settle-and-teardown.js +3 -2
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/run-turn-boundary.d.ts +1 -0
- package/dist/core/runner/run-turn-boundary.js +15 -22
- package/dist/core/runner/runtask.d.ts +3 -0
- package/dist/core/runner/runtask.js +8 -9
- package/dist/core/runner/session-read-file-states.d.ts +15 -0
- package/dist/core/runner/session-read-file-states.js +28 -0
- package/dist/core/runner/session-rule-policy.d.ts +22 -21
- package/dist/core/runner/session-rule-policy.js +17 -31
- package/dist/core/runner/shell-env-withheld.d.ts +33 -0
- package/dist/core/runner/shell-env-withheld.js +51 -0
- package/dist/core/runner/side-call-account.d.ts +32 -8
- package/dist/core/runner/side-call-account.js +23 -1
- package/dist/core/runner/skills-seat.js +6 -2
- package/dist/core/runner/stream-settle-backstop.js +1 -1
- package/dist/core/runner/strict-output-schema.d.ts +1 -1
- package/dist/core/runner/sub-agent-deny-lists.js +4 -6
- package/dist/core/runner/synthetic-tools.d.ts +16 -13
- package/dist/core/runner/synthetic-tools.js +8 -3
- package/dist/core/runner/tool-disclosure.d.ts +10 -12
- package/dist/core/runner/tool-disclosure.js +3 -4
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-end-body.js +10 -9
- package/dist/core/runner/tool-face-overlay.d.ts +2 -1
- package/dist/core/runner/tool-face-overlay.js +17 -1
- package/dist/core/runner/tool-not-executed.d.ts +5 -0
- package/dist/core/runner/tool-not-executed.js +11 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -0
- package/dist/core/runner/tool-occurrence.js +7 -0
- package/dist/core/runner/tool-progress-lane.d.ts +2 -2
- package/dist/core/runner/tool-turn-repair-seat.d.ts +3 -2
- package/dist/core/runner/turn-attachments.d.ts +91 -80
- package/dist/core/runner/turn-attachments.js +62 -37
- package/dist/core/runner-deps.d.ts +42 -42
- package/dist/core/runtime-caps.d.ts +4 -4
- package/dist/core/safety-axis-vocab.d.ts +6 -4
- package/dist/core/safety-axis-vocab.js +6 -5
- package/dist/core/safety-merge-corpus.js +26 -2
- package/dist/core/same-plain-value.d.ts +40 -0
- package/dist/core/same-plain-value.js +49 -0
- package/dist/core/scheduler.d.ts +1 -1
- package/dist/core/secret-env.d.ts +26 -3
- package/dist/core/secret-env.js +44 -8
- package/dist/core/select-model.js +3 -3
- package/dist/core/sensitive-path-policy.d.ts +1 -1
- package/dist/core/sensitive-path-policy.js +1 -1
- package/dist/core/session-policy-store.d.ts +102 -35
- package/dist/core/session-policy-store.js +210 -48
- package/dist/core/session-reconcile.d.ts +2 -2
- package/dist/core/session-store.d.ts +106 -37
- package/dist/core/session-store.js +165 -91
- package/dist/core/session.d.ts +101 -57
- package/dist/core/session.js +53 -0
- package/dist/core/shared-memory/tools.js +3 -1
- package/dist/core/shared-memory/types.d.ts +1 -1
- package/dist/core/shell-read-silence.d.ts +11 -12
- package/dist/core/shell-read-silence.js +9 -5
- package/dist/core/shell-run-candidates.js +3 -1
- package/dist/core/shell-wrapper-projection.js +1 -1
- package/dist/core/shell-wrapper-table.d.ts +14 -7
- package/dist/core/shell-wrapper-table.js +5 -4
- package/dist/core/side-query.d.ts +10 -0
- package/dist/core/side-query.js +15 -1
- package/dist/core/skill-grant.d.ts +7 -2
- package/dist/core/skill-grant.js +5 -0
- package/dist/core/skills-directory.js +6 -2
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +168 -3
- package/dist/core/store-contracts/file-history-store-contract.js +74 -4
- package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
- package/dist/core/store-contracts/peer-directory-contract.js +14 -2
- package/dist/core/store-contracts/session-policy-store-contract.d.ts +7 -0
- package/dist/core/store-contracts/session-policy-store-contract.js +130 -0
- package/dist/core/store-contracts/session-repo-contract.js +176 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +6 -8
- package/dist/core/store-contracts/session-store-contract.js +361 -51
- package/dist/core/store-contracts/workflow-journal-store-contract.js +26 -1
- package/dist/core/stub-env.d.ts +2 -0
- package/dist/core/stub-env.js +1 -0
- package/dist/core/surrogate-safe-slice.d.ts +3 -3
- package/dist/core/synthetic-read-verdict.js +3 -3
- package/dist/core/task-event.d.ts +42 -8
- package/dist/core/task-notification.d.ts +19 -15
- package/dist/core/task-registry-agent.d.ts +4 -4
- package/dist/core/task-registry-shared.d.ts +4 -4
- package/dist/core/task-registry-shared.js +1 -0
- package/dist/core/task-registry.d.ts +13 -4
- package/dist/core/task-registry.js +14 -2
- package/dist/core/task-result.d.ts +21 -3
- package/dist/core/task-spec.d.ts +69 -64
- package/dist/core/task-stream.d.ts +6 -6
- package/dist/core/task-tool-shape.d.ts +4 -4
- package/dist/core/tighten-task-spec.d.ts +1 -1
- package/dist/core/tighten-task-spec.js +2 -1
- package/dist/core/tool-catalog-entries.d.ts +36 -2
- package/dist/core/tool-catalog-entries.js +69 -43
- package/dist/core/tool-check-reading.d.ts +11 -0
- package/dist/core/tool-check-reading.js +11 -6
- package/dist/core/tool-conformance.js +1 -0
- package/dist/core/tool-errors.d.ts +2 -2
- package/dist/core/tool-face-reader.js +5 -3
- package/dist/core/tool-face.d.ts +21 -2
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-model-gate.d.ts +5 -5
- package/dist/core/tool-name-aliases.d.ts +29 -8
- package/dist/core/tool-name-aliases.js +22 -4
- package/dist/core/tool-name-readings.d.ts +10 -43
- package/dist/core/tool-name-readings.js +2 -11
- package/dist/core/tool-policy.d.ts +85 -196
- package/dist/core/tool-policy.js +150 -175
- package/dist/core/tool-registry.d.ts +14 -7
- package/dist/core/tool-registry.js +17 -7
- package/dist/core/tool-result-store.js +5 -1
- package/dist/core/tool-roster.d.ts +57 -33
- package/dist/core/tool-roster.js +56 -68
- package/dist/core/tool-spec-members.js +8 -3
- package/dist/core/tool-spec.d.ts +53 -31
- package/dist/core/tools.js +51 -10
- package/dist/core/trace.d.ts +6 -2
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +1 -1
- package/dist/core/untrusted-text.d.ts +1 -1
- package/dist/core/user-attachment.d.ts +8 -1
- package/dist/core/user-attachment.js +64 -4
- package/dist/core/warm-resume.d.ts +1 -1
- package/dist/core/wiring-manifest.d.ts +58 -0
- package/dist/core/wiring-manifest.js +14 -5
- package/dist/core/workflow-journal-store.d.ts +62 -0
- package/dist/core/workflow-journal-store.js +78 -2
- package/dist/core/workflow-run-store.d.ts +6 -0
- package/dist/core/workflow-run-store.js +2 -0
- package/dist/engine/compaction/compaction.d.ts +9 -9
- package/dist/engine/compaction/compaction.js +3 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +26 -8
- package/dist/engine/execution-env/node-execution-env.js +54 -24
- package/dist/engine/harness/agent-harness.d.ts +39 -9
- package/dist/engine/harness/agent-harness.js +87 -33
- package/dist/engine/harness/types.d.ts +58 -9
- package/dist/engine/harness/types.js +12 -1
- package/dist/engine/llm/types.d.ts +36 -19
- package/dist/engine/llm/validation.d.ts +4 -1
- package/dist/engine/llm/validation.js +13 -1
- package/dist/engine/loop/agent-loop.d.ts +23 -1
- package/dist/engine/loop/agent-loop.js +26 -34
- package/dist/engine/loop/types.d.ts +31 -19
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/memory-repo.d.ts +18 -12
- package/dist/engine/session/memory-repo.js +24 -9
- package/dist/engine/session/parent-chain-guard.d.ts +3 -2
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/repo-utils.d.ts +32 -3
- package/dist/engine/session/repo-utils.js +50 -5
- package/dist/index.d.ts +47 -23
- package/dist/index.js +35 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +3 -3
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/goal.js +2 -2
- package/dist/orchestration/run-workflow-tool.d.ts +8 -6
- package/dist/orchestration/run-workflow-tool.js +10 -6
- package/dist/orchestration/workflow-size-guideline.d.ts +4 -4
- package/dist/orchestration/workflow-types.d.ts +18 -0
- package/dist/orchestration/workflow-types.js +6 -0
- package/dist/orchestration/workflow.d.ts +5 -13
- package/dist/orchestration/workflow.js +57 -49
- package/dist/prompt-assembly/artifact.d.ts +2 -2
- package/dist/prompt-assembly/artifact.js +5 -3
- package/dist/prompt-assembly/assemble.d.ts +3 -2
- package/dist/prompt-assembly/assemble.js +1 -1
- package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
- package/dist/prompt-assembly/catalog/schema.js +34 -2
- package/dist/prompt-assembly/catalog/sections.js +0 -1
- package/dist/prompt-assembly/composer.d.ts +3 -1
- package/dist/prompt-assembly/composer.js +1 -1
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/overlay.js +3 -3
- package/dist/prompt-assembly/renderers.d.ts +1 -1
- package/dist/prompt-assembly/renderers.js +0 -3
- package/dist/prompt-assembly/role-base.d.ts +15 -0
- package/dist/prompt-assembly/role-base.js +9 -0
- package/dist/prompt-assembly/select.d.ts +39 -14
- package/dist/prompt-assembly/select.js +47 -16
- package/dist/prompt-assembly/sugar.d.ts +17 -11
- package/dist/prompt-assembly/sugar.js +8 -3
- package/dist/prompt-assembly/tool-catalog.d.ts +39 -2
- package/dist/prompt-assembly/tool-catalog.js +117 -4
- package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
- package/dist/prompt-assembly/turn-snapshot.js +0 -3
- package/dist/prompt-assembly/types.d.ts +0 -7
- package/dist/prompts/default.d.ts +14 -14
- package/dist/scenarios/full-body.d.ts +15 -15
- package/dist/scenarios/full-body.js +4 -3
- package/dist/shell/lex.js +10 -1
- package/dist/stores/file/adoption/adopt.d.ts +4 -3
- package/dist/stores/file/adoption/adopt.js +27 -33
- package/dist/stores/file/adoption/marker.d.ts +6 -13
- package/dist/stores/file/adoption/marker.js +9 -17
- package/dist/stores/file/checkpoint-store.d.ts +24 -0
- package/dist/stores/file/checkpoint-store.js +45 -7
- package/dist/stores/file/file-history-store.d.ts +20 -19
- package/dist/stores/file/file-history-store.js +157 -141
- package/dist/stores/file/fs-atomic.d.ts +15 -0
- package/dist/stores/file/fs-atomic.js +89 -14
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +2 -1
- package/dist/stores/file/mailbox-store.d.ts +3 -0
- package/dist/stores/file/mailbox-store.js +3 -1
- package/dist/stores/file/permission-rule-adopt.d.ts +1 -1
- package/dist/stores/file/permission-rule-adopt.js +18 -18
- package/dist/stores/file/permission-rule-store.d.ts +18 -2
- package/dist/stores/file/permission-rule-store.js +31 -18
- package/dist/stores/file/session-policy-store.d.ts +3 -3
- package/dist/stores/file/session-store.d.ts +54 -16
- package/dist/stores/file/session-store.js +114 -85
- package/dist/stores/file/workflow-journal-store.d.ts +10 -4
- package/dist/stores/file/workflow-journal-store.js +28 -13
- package/dist/tools/artifact/artifact-text.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +5 -3
- package/dist/tools/fs/bash-program-position.d.ts +19 -2
- package/dist/tools/fs/bash-program-position.js +56 -9
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -3
- package/dist/tools/fs/fs-bash.d.ts +2 -2
- package/dist/tools/fs/fs-bash.js +8 -6
- package/dist/tools/fs/fs-glob.d.ts +86 -0
- package/dist/tools/fs/fs-glob.js +226 -0
- package/dist/tools/fs/fs-read.js +14 -14
- package/dist/tools/fs/fs-search-tools.js +7 -7
- package/dist/tools/fs/fs-shared.d.ts +8 -8
- package/dist/tools/fs/gh-rate-limit.d.ts +1 -1
- package/dist/tools/fs/notebook.d.ts +2 -2
- package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
- package/dist/tools/fs/pattern-kill-guard.js +397 -0
- package/dist/tools/fs/pdf.d.ts +9 -6
- package/dist/tools/fs/pdf.js +3 -3
- package/dist/tools/fs/program-read-model.d.ts +57 -7
- package/dist/tools/fs/program-read-model.js +11 -1
- package/dist/tools/fs/program-read-model.rows.js +78 -21
- package/dist/tools/fs/read-deny-home.js +3 -2
- package/dist/tools/fs/read-deny.d.ts +29 -7
- package/dist/tools/fs/read-deny.js +63 -22
- package/dist/tools/fs/removal-targets.d.ts +18 -8
- package/dist/tools/fs/removal-targets.js +47 -20
- package/dist/tools/fs/safety.d.ts +9 -9
- package/dist/tools/fs/search.d.ts +16 -6
- package/dist/tools/fs/search.js +20 -26
- package/dist/tools/fs/shell-read-argv.js +89 -12
- package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
- package/dist/tools/fs/shell-read-bindings.js +41 -0
- package/dist/tools/fs/shell-read-check.js +12 -20
- package/dist/tools/fs/shell-read-environment.d.ts +5 -1
- package/dist/tools/fs/shell-read-environment.js +3 -2
- package/dist/tools/fs/shell-read-establish.d.ts +15 -0
- package/dist/tools/fs/shell-read-establish.js +19 -20
- package/dist/tools/fs/shell-read-judge.d.ts +4 -0
- package/dist/tools/fs/shell-read-judge.js +5 -2
- package/dist/tools/fs/shell-read-plan.js +24 -16
- package/dist/tools/fs/shell-read-start.d.ts +6 -1
- package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
- package/dist/tools/fs/shell-read-write-targets.js +2 -3
- package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
- package/dist/tools/fs/shell-reentry-text.js +40 -2
- package/dist/tools/loop-tick.d.ts +2 -2
- package/dist/tools/scheduler-tools.js +5 -1
- package/dist/tools/task-list.d.ts +7 -7
- package/dist/tools/task-list.js +5 -1
- package/dist/tools/todo.js +65 -64
- package/dist/tools/web.d.ts +20 -15
- package/dist/tools/web.js +55 -69
- package/dist/tools/worktree.d.ts +3 -3
- package/dist/tools/worktree.js +3 -1
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +5894 -5638
- package/wire-changes/core@7.55.0.json +3318 -0
- package/wire-changes/core@7.56.0.json +3891 -0
- package/wire-changes/mods-kernel@7.56.0.json +303 -0
- package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +0 -39
- package/dist/core/store-contracts/session-store-incarnation-contract.js +0 -95
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
* WHERE THE STATE LIVES. The tree's state is one object, reached from the tree's opaque token (`RunInternals.crossBoundaryTree`,
|
|
6
6
|
* `ToolExecuteContext.crossBoundaryTreeForChildren`) through this module alone; each leg joins into it what it knows at prepare (its
|
|
7
7
|
* environment's declaration, its session's newest record, its posture) and every bit an exit sets lands there before the call
|
|
8
|
-
* runs
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* governed
|
|
13
|
-
*
|
|
8
|
+
* runs — after the record that carries it, so a call the exit refuses sets nothing. Each leg's session holds a record
|
|
9
|
+
* (`CROSS_BOUNDARY_RECORD_TYPE`) of the state its content is read under — written only for an armed tree: at prepare and at an
|
|
10
|
+
* exit (before the call runs) when the state grew past what the session already says, and at a leg's end (before a suspend's row is
|
|
11
|
+
* put, when the leg settles) also when conversation content follows the newest record. A write that fails refuses its call (or its
|
|
12
|
+
* row) on a governed tree; a prepare's or a settle's, and any write on a tree that is not governed, mints
|
|
13
|
+
* `config.cross_boundary_record_unwritten`, once per state. A record says how the content before it is READ: a leg's end record also
|
|
14
|
+
* carries what the session is still owed — each unfinished background task the leg's TaskOutput reaches, judged as the poll the
|
|
15
|
+
* session's next leg (another tree) would make of it, so its delivery is read under the bit it brings. A leg that takes over a
|
|
16
|
+
* session whose content no record covers (none on the branch, or after the newest), on an armed tree, reads that content as
|
|
17
|
+
* off-target.
|
|
14
18
|
*
|
|
15
19
|
* THE OBLIGATION of a call is read off three things at the moment it is asked ({@link crossBoundaryObligation}): the legs the
|
|
16
20
|
* call travels (its roster row's declaration, or what the dispatching code gives per call), whether the environment the `env`
|
|
@@ -18,7 +22,7 @@
|
|
|
18
22
|
*/
|
|
19
23
|
import type { AgentTool } from "../../internal/harness.js";
|
|
20
24
|
import type { SessionTreeEntry } from "../../internal/harness-types.js";
|
|
21
|
-
import { type CrossBoundaryCheck, type CrossBoundaryPosture, type CrossBoundaryTreeToken } from "../cross-boundary-taint.js";
|
|
25
|
+
import { type CrossBoundaryCheck, type CrossBoundaryPosture, type CrossBoundaryTreeToken, type OwedDeliveries } from "../cross-boundary-taint.js";
|
|
22
26
|
import { type ToolRoster } from "../tool-roster.js";
|
|
23
27
|
import type { RunnerDeps } from "../types.js";
|
|
24
28
|
/** A new tree with no bit set, and the token that names it — the one mint of a token. */
|
|
@@ -38,23 +42,24 @@ export interface CrossBoundaryLane {
|
|
|
38
42
|
seat(view: CrossBoundaryLegView): CrossBoundaryCheck | undefined;
|
|
39
43
|
/** The seat minted by {@link seat}, for the resumed call's exit. */
|
|
40
44
|
readonly check: CrossBoundaryCheck | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* that is not governed, the write failed and was reported); throws when it cannot be written on a governed tree.
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
owe(atLeaf
|
|
45
|
+
/** A suspend (a leg's end) writes the record its row's leaf owes: the new entry's id, or undefined when nothing was owed (or, on a
|
|
46
|
+
* tree that is not governed, the write failed and was reported); throws when it cannot be written on a governed tree. The record
|
|
47
|
+
* covers the content after the newest one and what the session is still `owed`, and is written only as the child of `atLeaf` (the
|
|
48
|
+
* row then points at it). */
|
|
49
|
+
owe(atLeaf: string, owed: OwedDeliveries): Promise<string | undefined>;
|
|
46
50
|
/** The tree is armed, so the session OWES the tree's record and a parked row says a reader must read it — on a tree that is not
|
|
47
51
|
* governed a failed write leaves the record missing (the notice says so), and the reader then reads the content after the newest
|
|
48
52
|
* record as off-target. */
|
|
49
53
|
recorded(): boolean;
|
|
50
|
-
/** The leg settles: the record that covers what it added
|
|
51
|
-
* content after the newest record as off-target). */
|
|
52
|
-
settle(): Promise<void>;
|
|
54
|
+
/** The leg settles: the record that covers what it added and what the session is still `owed` is written, a failure reported
|
|
55
|
+
* loudly (the next leg then reads the content after the newest record as off-target). */
|
|
56
|
+
settle(owed: OwedDeliveries): Promise<void>;
|
|
53
57
|
/** How many times this leg's record writes have waited on the session store — a station that judged before an exit reads again
|
|
54
58
|
* when the count moved across it (the exit's own form: judged again after a wait). */
|
|
55
59
|
storeWaits(): number;
|
|
56
60
|
}
|
|
57
|
-
/** What the seat reads per call: the live roster (the legs a row declares) and the mounted instances (a `"per_call"` resolver
|
|
61
|
+
/** What the seat reads per call: the live roster (the legs a row declares) and the mounted instances (a `"per_call"` row's resolver,
|
|
62
|
+
* read off the later mount under the row's name — the instance the row was minted from, but in a redial window: KL-2284-c). */
|
|
58
63
|
export interface CrossBoundaryLegView {
|
|
59
64
|
readonly tools: readonly AgentTool[];
|
|
60
65
|
readonly roster: {
|
|
@@ -2,7 +2,7 @@ import { BOUNDARY_LEGS, CROSS_BOUNDARY_RECORD_TYPE, CROSS_BOUNDARY_TAINT_BITS, S
|
|
|
2
2
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
3
3
|
import { policyCannotAnswer } from "../real-approval.js";
|
|
4
4
|
import { thrownText } from "../thrown-value.js";
|
|
5
|
-
import { rosterEntryNamed } from "../tool-roster.js";
|
|
5
|
+
import { rosterEntryNamed, survivorsByName } from "../tool-roster.js";
|
|
6
6
|
import { emitTrace } from "../trace.js";
|
|
7
7
|
const TREE_STATE = new WeakMap();
|
|
8
8
|
export function mintCrossBoundaryTree() {
|
|
@@ -21,6 +21,7 @@ export function joinedCrossBoundaryTree(handed, report) {
|
|
|
21
21
|
return token;
|
|
22
22
|
}
|
|
23
23
|
const EVERY_LEG = Object.freeze([...BOUNDARY_LEGS]);
|
|
24
|
+
const ONE_OUTSIDE_READ = Object.freeze([Object.freeze({ legs: Object.freeze(["outside_read"]) })]);
|
|
24
25
|
const bitsOf = (t) => CROSS_BOUNDARY_TAINT_BITS.filter((b) => t[b] === true);
|
|
25
26
|
function legsOfCall(view, legEnv, token, call, report) {
|
|
26
27
|
const roster = view.roster.current;
|
|
@@ -30,7 +31,7 @@ function legsOfCall(view, legEnv, token, call, report) {
|
|
|
30
31
|
if (row.boundaryLegs !== "per_call")
|
|
31
32
|
return { legs: row.boundaryLegs, env: legEnv };
|
|
32
33
|
const strictest = (why) => (report(`tool "${row.name}" declares its boundary legs per call, and its boundaryLegsFor ${why} — the call reads as every leg, off the target (the strictest reading)`), { legs: EVERY_LEG, env: undefined });
|
|
33
|
-
const resolve = view.tools.
|
|
34
|
+
const resolve = survivorsByName(view.tools).get(row.name)?.boundaryLegsFor;
|
|
34
35
|
if (typeof resolve !== "function")
|
|
35
36
|
return strictest("is missing");
|
|
36
37
|
let given;
|
|
@@ -47,7 +48,13 @@ function legsOfCall(view, legEnv, token, call, report) {
|
|
|
47
48
|
}
|
|
48
49
|
export async function prepareCrossBoundaryLane(input) {
|
|
49
50
|
const { posture, externalContentTargetActive, env, session, resumeLeg, sessionId, runId, hostTaskId, deps } = input;
|
|
50
|
-
const report = (message) =>
|
|
51
|
+
const report = (message) => {
|
|
52
|
+
try {
|
|
53
|
+
deps.onError?.(new Error(message), { phase: "config", sessionId });
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
}
|
|
57
|
+
};
|
|
51
58
|
const token = input.token ?? mintCrossBoundaryTree();
|
|
52
59
|
const ref = TREE_STATE.get(token);
|
|
53
60
|
if (ref === undefined)
|
|
@@ -70,52 +77,56 @@ export async function prepareCrossBoundaryLane(input) {
|
|
|
70
77
|
tree = joinCrossBoundaryTree(tree, { offTargetReadObserved: true });
|
|
71
78
|
ref.current = tree;
|
|
72
79
|
const stationEngaged = posture !== undefined || externalContentTargetActive || crossBoundaryTreeGoverned(tree);
|
|
73
|
-
|
|
80
|
+
let reported;
|
|
81
|
+
const unwritten = (phase, state, err) => {
|
|
82
|
+
if (reported !== undefined && crossBoundaryTreeCovers(reported, state))
|
|
83
|
+
return;
|
|
84
|
+
reported = state;
|
|
85
|
+
deliverEngineNotice(deps.onNotice, crossBoundaryRecordUnwrittenNotice({ sessionId, runId, phase, governed: crossBoundaryTreeGoverned(ref.current), cause: thrownText(err) }));
|
|
86
|
+
};
|
|
74
87
|
let writing = Promise.resolve();
|
|
75
88
|
let storeWaits = 0;
|
|
76
|
-
const write = (phase, atLeaf) => {
|
|
89
|
+
const write = (phase, atLeaf, joins = () => undefined) => {
|
|
77
90
|
const next = writing.then(async () => {
|
|
78
|
-
|
|
79
|
-
let cover = phase === "suspend" || phase === "settle";
|
|
91
|
+
const legEnd = phase === "suspend" || phase === "settle";
|
|
80
92
|
let written;
|
|
81
93
|
for (;;) {
|
|
82
|
-
|
|
83
|
-
if (state.targetExecutionArmed !== true)
|
|
94
|
+
if (ref.current.targetExecutionArmed !== true)
|
|
84
95
|
return written;
|
|
96
|
+
const state = joinCrossBoundaryTree(ref.current, joins() ?? {});
|
|
85
97
|
const grown = !crossBoundaryTreeCovers(recorded, state);
|
|
86
|
-
if (!grown && !
|
|
98
|
+
if (!grown && !legEnd)
|
|
87
99
|
return written;
|
|
88
100
|
try {
|
|
89
101
|
if (!grown) {
|
|
90
102
|
storeWaits++;
|
|
91
103
|
const now = readCrossBoundaryRecord((await session.getBranch()));
|
|
92
|
-
if (now.kind !== "malformed" && !now.uncoveredContent)
|
|
93
|
-
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
104
|
+
if (now.kind !== "malformed" && !now.uncoveredContent)
|
|
105
|
+
return written;
|
|
96
106
|
}
|
|
97
|
-
if (
|
|
107
|
+
if (atLeaf !== undefined) {
|
|
98
108
|
storeWaits++;
|
|
99
|
-
if ((await session.getLeafId()) !==
|
|
109
|
+
if ((await session.getLeafId()) !== atLeaf)
|
|
100
110
|
throw new Error("the session moved past the row's leaf before its record could be written");
|
|
101
111
|
}
|
|
102
112
|
storeWaits++;
|
|
103
113
|
const entryId = await session.appendCustomEntry(CROSS_BOUNDARY_RECORD_TYPE, crossBoundaryRecordData(state));
|
|
104
114
|
if (typeof entryId !== "string" || entryId.length === 0)
|
|
105
115
|
throw new Error(`the session store answered the record's append with no entry id (${typeof entryId})`);
|
|
106
|
-
if (
|
|
116
|
+
if (atLeaf !== undefined && (storeWaits++, await session.getLeafId()) !== entryId)
|
|
107
117
|
throw new Error("the record the session store appended is not the session's new leaf");
|
|
108
118
|
recorded = state;
|
|
109
119
|
written = entryId;
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
cover = false;
|
|
120
|
+
if (legEnd)
|
|
121
|
+
return written;
|
|
113
122
|
}
|
|
114
123
|
catch (err) {
|
|
115
|
-
|
|
124
|
+
const governed = crossBoundaryTreeGoverned(ref.current);
|
|
125
|
+
if (governed && (phase === "exit" || phase === "suspend"))
|
|
116
126
|
throw err;
|
|
117
|
-
unwritten(phase, err);
|
|
118
|
-
|
|
127
|
+
unwritten(phase, state, err);
|
|
128
|
+
if (!governed)
|
|
129
|
+
recorded = state;
|
|
119
130
|
return written;
|
|
120
131
|
}
|
|
121
132
|
}
|
|
@@ -123,13 +134,24 @@ export async function prepareCrossBoundaryLane(input) {
|
|
|
123
134
|
writing = next.catch(() => undefined);
|
|
124
135
|
return next;
|
|
125
136
|
};
|
|
126
|
-
const
|
|
137
|
+
const OBSERVED = Object.freeze({ offTargetReadObserved: true });
|
|
138
|
+
const addedBy = (record) => (record && ref.current.offTargetReadObserved !== true ? OBSERVED : undefined);
|
|
139
|
+
const owedBit = (owed) => {
|
|
140
|
+
const records = (given) => given.some((d) => crossBoundaryObligation(d.legs, d.env?.externalContentTarget === true, ref.current).record);
|
|
141
|
+
try {
|
|
142
|
+
return addedBy(records(owed()));
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
report(`the deliveries this leg's session is still owed could not be read (${thrownText(err)}) — read as content from beyond the device`);
|
|
146
|
+
return addedBy(records(ONE_OUTSIDE_READ));
|
|
147
|
+
}
|
|
148
|
+
};
|
|
127
149
|
const trace = (phase, call) => emitTrace(deps.tracer, () => ({ kind: "permission.cross_boundary_taint", version: 1, taskId: hostTaskId, runId, phase, taint: bitsOf(ref.current), governed: ref.current.governed === true, ...(call !== undefined ? { toolName: call.toolName, ...(call.toolCallId !== undefined ? { toolCallId: call.toolCallId } : {}) } : {}), ts: Date.now() }));
|
|
128
150
|
if (tree.targetExecutionArmed === true) {
|
|
129
151
|
trace(resumeLeg ? "resume" : "prepare");
|
|
130
152
|
if (posture === undefined && tree.governed !== true)
|
|
131
153
|
deliverEngineNotice(deps.onNotice, crossBoundaryPostureUndeclaredNotice({ sessionId, runId, tree }));
|
|
132
|
-
await write("prepare")
|
|
154
|
+
await write("prepare");
|
|
133
155
|
}
|
|
134
156
|
let check;
|
|
135
157
|
const lane = {
|
|
@@ -163,28 +185,30 @@ export async function prepareCrossBoundaryLane(input) {
|
|
|
163
185
|
message: `tool "${call.toolName}" needs a person's confirmation: this run executes on a target device${ref.current.offTargetReadObserved === true ? " and has since let content from beyond it in, so a call that reaches beyond the device or back into it" : ", so a call that writes beyond the device"} is put to a person — this call was allowed by a configuration, not a person, and was not executed`,
|
|
164
186
|
};
|
|
165
187
|
}
|
|
166
|
-
|
|
167
|
-
ref.current = joinCrossBoundaryTree(ref.current, { offTargetReadObserved: true });
|
|
168
|
-
trace("observed", call);
|
|
169
|
-
}
|
|
188
|
+
const adds = addedBy(now.record);
|
|
170
189
|
const judged = ref.current;
|
|
171
190
|
try {
|
|
172
|
-
await
|
|
191
|
+
await write("exit", undefined, () => adds);
|
|
173
192
|
}
|
|
174
193
|
catch (err) {
|
|
175
194
|
return { kind: "unrecorded", message: `tool "${call.toolName}" was not executed: the session's cross-boundary record could not be written before it ran (${thrownText(err)}) — on a governed tree a call that owes its record does not run without it; refused fail-closed` };
|
|
176
195
|
}
|
|
177
|
-
if (ref.current
|
|
178
|
-
|
|
196
|
+
if (ref.current !== judged)
|
|
197
|
+
continue;
|
|
198
|
+
if (adds !== undefined) {
|
|
199
|
+
ref.current = joinCrossBoundaryTree(ref.current, adds);
|
|
200
|
+
trace("observed", call);
|
|
201
|
+
}
|
|
202
|
+
return undefined;
|
|
179
203
|
}
|
|
180
204
|
},
|
|
181
205
|
};
|
|
182
206
|
return check;
|
|
183
207
|
},
|
|
184
|
-
owe,
|
|
208
|
+
owe: (atLeaf, owed) => write("suspend", atLeaf, () => owedBit(owed)),
|
|
185
209
|
storeWaits: () => storeWaits,
|
|
186
210
|
recorded: () => ref.current.targetExecutionArmed === true,
|
|
187
|
-
settle: () => write("settle"
|
|
211
|
+
settle: (owed) => write("settle", undefined, () => owedBit(owed)).then(() => undefined),
|
|
188
212
|
};
|
|
189
213
|
return lane;
|
|
190
214
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { type AskOrigin } from "../ask-origin.js";
|
|
19
19
|
import { type OnQuestion, type QuestionAnswer } from "../ask-question.js";
|
|
20
|
-
import { type Checkpoint, type ResolvedOutcome, type ResumeOutcome } from "../checkpoint-store.js";
|
|
20
|
+
import { type Checkpoint, type CheckpointErrorField, type ResolvedOutcome, type ResumeOutcome } from "../checkpoint-store.js";
|
|
21
21
|
import { type GateOutcome, type HostDecisionFacts } from "../gate-outcome.js";
|
|
22
22
|
import type { ResumeRun } from "./contracts.js";
|
|
23
23
|
/**
|
|
@@ -130,10 +130,13 @@ export declare function mintDecideRecord(cp: Checkpoint, facts: HostDecisionFact
|
|
|
130
130
|
* answer differently each time — the check passing on text it never inspected. Refused pre-CAS so the
|
|
131
131
|
* row stays `pending` for a well-formed decide, exactly like the other capture-time domain refusals,
|
|
132
132
|
* and BEFORE the hygiene check so no guard ever consults a value outside the domain. The rejected field
|
|
133
|
-
* is named in the message
|
|
134
|
-
*
|
|
133
|
+
* is named in the message, and in `detail` where the caller hands the closed set's word for the cell
|
|
134
|
+
* (`CheckpointErrorField`: `feedback` has one; `reason` and `editedPlan` have none, and widening the set is a
|
|
135
|
+
* wire-surface change of its own).
|
|
135
136
|
*/
|
|
136
|
-
export declare function assertOutcomeText(value: string | undefined, field: "editedPlan" | "reason" | "feedback"
|
|
137
|
+
export declare function assertOutcomeText(value: string | undefined, field: "editedPlan" | "reason" | "feedback", detail?: {
|
|
138
|
+
field: CheckpointErrorField;
|
|
139
|
+
}): void;
|
|
137
140
|
/**
|
|
138
141
|
* The continuation prompt for a resumed run. The vendored harness only exposes
|
|
139
142
|
* `prompt(text)` (it always appends a user message — there is no "continue from tool results" entry), so
|
|
@@ -123,9 +123,9 @@ export function mintDecideRecord(cp, facts, verdict) {
|
|
|
123
123
|
const settlement = settlementOfHostDecision(facts, verdict.allowed ? "allowed" : "refused", verdict.note);
|
|
124
124
|
return mintGateOutcome({ ...(verdict.allowed ? {} : { deniedBy: "ask_resolution" }), settled: { settlement, origin } });
|
|
125
125
|
}
|
|
126
|
-
export function assertOutcomeText(value, field) {
|
|
126
|
+
export function assertOutcomeText(value, field, detail) {
|
|
127
127
|
if (value !== undefined && typeof value !== "string") {
|
|
128
|
-
throw new CheckpointError("checkpoint.invalid_outcome", `resume \`${field}\` is not a plain string (got ${typeof value}) — a decide's text payload is an operator's plain data, not a live object; refusing pre-CAS, the checkpoint stays pending
|
|
128
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `resume \`${field}\` is not a plain string (got ${typeof value}) — a decide's text payload is an operator's plain data, not a live object; refusing pre-CAS, the checkpoint stays pending`, detail);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
function reorientClause(fullShellReachable) {
|
|
@@ -103,9 +103,9 @@ export type InheritedAsk = Extract<PermissionResult, {
|
|
|
103
103
|
* {@link judgeInheritedClassifier} and threaded to every reader ({@link inheritedAskCarry}).
|
|
104
104
|
* The MANDATE marks here are empty (the base names no seat): the policy-chain phase builds each call's facts over this
|
|
105
105
|
* base with THIS task's tool seat — the seat the request's risk axes are read from — so a marked tool's ask is
|
|
106
|
-
* classified by the seat at the station as at the gate. What the ancestor's ask carries on ITSELF still answers.
|
|
106
|
+
* classified by the seat at the station as at the gate. What the ancestor's ask carries on ITSELF still answers. No call either (each station's own).
|
|
107
107
|
*/
|
|
108
|
-
export declare const INHERITED_STATION_FACTS: AskOriginFacts
|
|
108
|
+
export declare const INHERITED_STATION_FACTS: Omit<AskOriginFacts, "call">;
|
|
109
109
|
/** The members of a surviving ask that ride onto the approval request with a COMPUTED value — what the
|
|
110
110
|
* four request mint stations (the gate's own and the three inherited-lane ones) spread after the seats
|
|
111
111
|
* they spell themselves: the ask's origin word, its class (the word and the set, carried together) and its
|
|
@@ -170,13 +170,13 @@ export type InheritedClassifierJudgment<A extends InheritedAsk> =
|
|
|
170
170
|
};
|
|
171
171
|
/**
|
|
172
172
|
* The ancestor's frozen classifier, run BEFORE its frozen approver in the ancestor's own gate order,
|
|
173
|
-
* with the denial-limit count folded in (
|
|
173
|
+
* with the denial-limit count folded in (count-then-judge): `allow` ⇒ the classifier's
|
|
174
174
|
* auto-allow (and the streak resets); `block` below the bound ⇒ deny, the exact verdict the ancestor's
|
|
175
175
|
* gate would have produced; `block` AT the bound ⇒ the ask is re-spoken in the classifier's voice as
|
|
176
176
|
* the fallback (`decisionReason:"classifier"`, `requiresRealApproval`, the member carrying counts +
|
|
177
177
|
* window) for the arm to resolve at the frozen approver; a classification that did not rule (`unavailable`, or a reply
|
|
178
178
|
* with no verdict) ⇒ the gate's own exit (`classifierNoRulingArm`) on the frozen approver — a live one resolves the incoming
|
|
179
|
-
* ask carrying why (never counted); none ⇒ the unavailable form is a DENY that says so (
|
|
179
|
+
* ask carrying why (never counted); none ⇒ the unavailable form is a DENY that says so (never counted) and
|
|
180
180
|
* a reply with no verdict takes the block path with the CC parse-failure sentence (counted); a CONFLICTING reply takes the
|
|
181
181
|
* block path too; excluded / no classifier ⇒ the incoming ask, unchanged. The member may ALREADY be on the incoming
|
|
182
182
|
* ask (a deeper ancestor's fallback, minted inside the nested fold — the case the exclusion names):
|
|
@@ -86,7 +86,7 @@ export function inheritedAskCarry(judged, liveApprover, tracker) {
|
|
|
86
86
|
export const inheritedAskFallbackMessage = (toolName) => `approval required for "${toolName}" (inherited parent policy)`;
|
|
87
87
|
export async function judgeInheritedClassifier(opts) {
|
|
88
88
|
const { autoMode, req } = opts;
|
|
89
|
-
const facts = opts.facts ?? INHERITED_STATION_FACTS, m = facts.mandateMarks;
|
|
89
|
+
const facts = opts.facts ?? { ...INHERITED_STATION_FACTS, call: req }, m = facts.mandateMarks;
|
|
90
90
|
const frames = [...(m.egress === true ? [markTightenMessage(req.toolName, "egress")] : []), ...(m.irreversibility === "always" ? [markTightenMessage(req.toolName, "irreversible")] : [])];
|
|
91
91
|
const ask = (frames.length > 0 ? { ...opts.ask, message: [opts.ask.message ?? inheritedAskFallbackMessage(req.toolName), ...frames].join(" — ") } : opts.ask);
|
|
92
92
|
const origin = askOriginOf(ask, facts);
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The derived-leg route pre-flight shared by prepareTask's
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* spelling it twice. The judgment law and both announcements live in the brain's route adjudicator; this is the one
|
|
6
|
-
* guarded seat around them.
|
|
2
|
+
* The derived-leg route pre-flight shared by prepareTask's derived seats: the compaction-summary model, the auto-mode
|
|
3
|
+
* classifier model and the advisor model. One guarded seat, reached DOWN for by each phase instead of spelled again; the
|
|
4
|
+
* judgment law and the announcements live in the brain's route adjudicator.
|
|
7
5
|
*/
|
|
8
|
-
import type { Model } from "../../internal/llm.js";
|
|
6
|
+
import type { Model, RouteRefusalCode } from "../../internal/llm.js";
|
|
9
7
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
8
|
+
/** What the pre-flight decided: keep the seat's model (same route as the primary, the pairing holds, the judge abstained, or
|
|
9
|
+
* the deployment declined a fallback — the seat is kept and its calls refused), swap it for the primary, or take the seat
|
|
10
|
+
* off this run. A move carries the refusal that caused it. */
|
|
11
|
+
export type DerivedSeatOutcome = {
|
|
12
|
+
readonly action: "keep";
|
|
13
|
+
} | {
|
|
14
|
+
readonly action: "fall_back" | "detach";
|
|
15
|
+
readonly cause: RouteRefusalCode;
|
|
16
|
+
};
|
|
10
17
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* failed": at the compaction seat the session is already acquired and the throw-cleanup contract
|
|
17
|
-
* is not yet armed, so a throw here would leak the acquired session view, and the garbage value
|
|
18
|
-
* still earns its loud refusal at the request gate the moment the derived leg is actually used.
|
|
19
|
-
* Returns whether the seat should fall back to the primary model.
|
|
18
|
+
* Judge the derived model where its route differs from the primary's, announce what a broken pairing means for THIS seat
|
|
19
|
+
* (`onBrokenPairing`), and ABSTAIN (keep) on ANY throw. The pre-flight is advisory — the brain's request gate re-runs the
|
|
20
|
+
* same law — so neither a throwing judge face nor a garbage catalog value may widen into "task preparation failed": at the
|
|
21
|
+
* compaction seat the session is already acquired and the throw-cleanup contract is not yet armed, and the garbage value
|
|
22
|
+
* still earns its loud refusal at the request gate the moment the derived leg is used.
|
|
20
23
|
*/
|
|
21
24
|
export declare function derivedRouteFallsBack(args: {
|
|
22
25
|
seat: string;
|
|
@@ -25,14 +28,11 @@ export declare function derivedRouteFallsBack(args: {
|
|
|
25
28
|
brain: RunnerDeps["brain"];
|
|
26
29
|
getApiKeyAndHeaders: TaskSpec["getApiKeyAndHeaders"];
|
|
27
30
|
onNotice: RunnerDeps["onNotice"];
|
|
28
|
-
/** The
|
|
29
|
-
* (the audience stays operator: correlation, not entitlement). Absent ⇒ nothing is fabricated. */
|
|
31
|
+
/** The session / INVOCATION this resolution belongs to: correlation keys on the notice (the audience stays operator). */
|
|
30
32
|
sessionId?: string;
|
|
31
|
-
/** The INVOCATION this seat resolution belongs to. The session cannot stand in for it: two
|
|
32
|
-
* runs of one session that both fall back on the same seat mint otherwise byte-identical lines. */
|
|
33
33
|
runId?: string;
|
|
34
|
-
/**
|
|
35
|
-
* (the
|
|
36
|
-
*
|
|
37
|
-
onBrokenPairing?: "fall_back" | "refuse";
|
|
38
|
-
}): Promise<
|
|
34
|
+
/** Absent / `"fall_back"`: swap and announce `route.fallback_to_primary`. `"refuse"`: keep the seat and announce
|
|
35
|
+
* `route.classifier_unroutable` (the deployment declined a fallback — never granted quietly). `"detach"`: take the seat
|
|
36
|
+
* off the run and announce `route.seat_detached` (a seat the primary model cannot stand in for). */
|
|
37
|
+
onBrokenPairing?: "fall_back" | "refuse" | "detach";
|
|
38
|
+
}): Promise<DerivedSeatOutcome>;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { adjudicateDerivedRoute, fallbackToPrimaryNotice, sameRouteIdentity, unroutableSeatNotice } from "../../brain/route-adjudicator.js";
|
|
1
|
+
import { adjudicateDerivedRoute, fallbackToPrimaryNotice, sameRouteIdentity, seatDetachedNotice, unroutableSeatNotice } from "../../brain/route-adjudicator.js";
|
|
2
2
|
import { deliverEngineNotice } from "../types.js";
|
|
3
3
|
export async function derivedRouteFallsBack(args) {
|
|
4
4
|
try {
|
|
5
5
|
if (sameRouteIdentity(args.derived, args.primary))
|
|
6
|
-
return
|
|
6
|
+
return { action: "keep" };
|
|
7
7
|
const verdict = await adjudicateDerivedRoute({ brain: args.brain, model: args.derived, getApiKeyAndHeaders: args.getApiKeyAndHeaders });
|
|
8
8
|
if (verdict === undefined || verdict.ok)
|
|
9
|
-
return
|
|
9
|
+
return { action: "keep" };
|
|
10
10
|
const shared = { seat: args.seat, from: args.derived.id, verdict, ...(args.sessionId !== undefined ? { sessionId: args.sessionId } : {}), ...(args.runId !== undefined ? { runId: args.runId } : {}) };
|
|
11
|
-
const
|
|
12
|
-
if (refuse)
|
|
11
|
+
const posture = args.onBrokenPairing ?? "fall_back";
|
|
12
|
+
if (posture === "refuse")
|
|
13
13
|
deliverEngineNotice(args.onNotice, unroutableSeatNotice({ ...shared, primary: args.primary.id }));
|
|
14
|
+
else if (posture === "detach")
|
|
15
|
+
deliverEngineNotice(args.onNotice, seatDetachedNotice(shared));
|
|
14
16
|
else
|
|
15
17
|
deliverEngineNotice(args.onNotice, fallbackToPrimaryNotice({ ...shared, to: args.primary.id }));
|
|
16
|
-
return
|
|
18
|
+
return posture === "refuse" ? { action: "keep" } : { action: posture, cause: verdict.code };
|
|
17
19
|
}
|
|
18
20
|
catch {
|
|
19
|
-
return
|
|
21
|
+
return { action: "keep" };
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -11,6 +11,24 @@ import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
|
11
11
|
* exactly as it was. What it resolves rides into the file-history phase (`prepareFileHistory`) unchanged.
|
|
12
12
|
*/
|
|
13
13
|
export declare function resolveFileHistoryRequest(spec: Pick<TaskSpec, "resumeAt" | "resumeAtMode" | "restoreFiles" | "rewindFilesTo" | "fileHistory">, deps: Pick<RunnerDeps, "onTrackFailure" | "fileHistoryStore" | "fileHistoryCapture">): FileHistoryRequest;
|
|
14
|
+
/**
|
|
15
|
+
* The DEPLOYMENT's file-history door — the three seats a deployment sets once (`RunnerDeps.onTrackFailure`,
|
|
16
|
+
* `RunnerDeps.fileHistoryStore`, `RunnerDeps.fileHistoryCapture`), each refused by name on a bad value. Read by
|
|
17
|
+
* every seat that touches file history: the run's request door above and the out-of-run `Runner.rewindFiles`, so a
|
|
18
|
+
* misconfigured deployment is refused the same way at both. `fileHistoryStore` is the store after the declared
|
|
19
|
+
* `"disabled"` word; `captureStore` additionally drops it when capture is `"off"` (recording stops, restore stays).
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveDeploymentFileHistory(deps: Pick<RunnerDeps, "onTrackFailure" | "fileHistoryStore" | "fileHistoryCapture">): {
|
|
22
|
+
onTrackFailure: "refuse" | "proceed-unprotected";
|
|
23
|
+
wiredSeat: FileHistoryStore | "disabled" | undefined;
|
|
24
|
+
captureOff: boolean;
|
|
25
|
+
fileHistoryStore: FileHistoryStore | undefined;
|
|
26
|
+
captureStore: FileHistoryStore | undefined;
|
|
27
|
+
};
|
|
28
|
+
/** A restore asked of a deployment that holds no history backend (none wired, or declared `"disabled"`). */
|
|
29
|
+
export declare function storeUnconfiguredRefusal(wiredSeat: FileHistoryStore | "disabled" | undefined, target: string): Error & {
|
|
30
|
+
code?: string;
|
|
31
|
+
};
|
|
14
32
|
/** What {@link resolveFileHistoryRequest} resolved: the validated seats and words, the run's store (after every off
|
|
15
33
|
* switch) and its capture store, and the restore target (`undefined` = no restore asked). */
|
|
16
34
|
export interface FileHistoryRequest {
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
export function resolveFileHistoryRequest(spec, deps) {
|
|
2
|
-
const
|
|
3
|
-
if (onTrackFailure !== "refuse" && onTrackFailure !== "proceed-unprotected") {
|
|
4
|
-
const e = new Error(`RunnerDeps.onTrackFailure must be "refuse" or "proceed-unprotected"; got ${JSON.stringify(deps.onTrackFailure)} — refusing prepare rather than silently defaulting a first-touch-failure policy.`);
|
|
5
|
-
e.code = "config.invalid_on_track_failure";
|
|
6
|
-
throw e;
|
|
7
|
-
}
|
|
8
|
-
const wiredSeat = resolveWiredFileHistoryStore(deps.fileHistoryStore);
|
|
2
|
+
const { onTrackFailure, wiredSeat, captureOff } = resolveDeploymentFileHistory(deps);
|
|
9
3
|
const runDeclaredOff = resolveRunFileHistoryWord(spec.fileHistory);
|
|
10
|
-
const captureOff = resolveFileHistoryCaptureWord(deps.fileHistoryCapture, wiredSeat);
|
|
11
4
|
const declaredOff = wiredSeat === "disabled" || runDeclaredOff;
|
|
12
5
|
const fileHistoryStore = declaredOff ? undefined : wiredSeat;
|
|
13
6
|
const captureStore = captureOff ? undefined : fileHistoryStore;
|
|
@@ -34,14 +27,29 @@ export function resolveFileHistoryRequest(spec, deps) {
|
|
|
34
27
|
if (rewindTarget !== undefined && fileHistoryStore === undefined) {
|
|
35
28
|
if (runDeclaredOff)
|
|
36
29
|
throw captureDisabledRefusal(rewindTarget);
|
|
37
|
-
|
|
38
|
-
? `rewind-files: restoring files to entry "${rewindTarget}" requires a history backend, but this deployment declared file history disabled (RunnerDeps.fileHistoryStore: "disabled"), so there is no history to restore — the files were NOT rewound`
|
|
39
|
-
: `rewind-files: restoring files to entry "${rewindTarget}" requires a history backend, but this deployment wired no RunnerDeps.fileHistoryStore — no file history was ever recorded, so the files were NOT rewound`);
|
|
40
|
-
e.code = "rewind.store_unconfigured";
|
|
41
|
-
throw e;
|
|
30
|
+
throw storeUnconfiguredRefusal(wiredSeat, rewindTarget);
|
|
42
31
|
}
|
|
43
32
|
return { onTrackFailure, wiredSeat, runDeclaredOff, captureOff, declaredOff, fileHistoryStore, captureStore, rewindTarget, rewindBefore };
|
|
44
33
|
}
|
|
34
|
+
export function resolveDeploymentFileHistory(deps) {
|
|
35
|
+
const onTrackFailure = deps.onTrackFailure === undefined ? "refuse" : deps.onTrackFailure;
|
|
36
|
+
if (onTrackFailure !== "refuse" && onTrackFailure !== "proceed-unprotected") {
|
|
37
|
+
const e = new Error(`RunnerDeps.onTrackFailure must be "refuse" or "proceed-unprotected"; got ${JSON.stringify(deps.onTrackFailure)} — refusing prepare rather than silently defaulting a first-touch-failure policy.`);
|
|
38
|
+
e.code = "config.invalid_on_track_failure";
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
const wiredSeat = resolveWiredFileHistoryStore(deps.fileHistoryStore);
|
|
42
|
+
const captureOff = resolveFileHistoryCaptureWord(deps.fileHistoryCapture, wiredSeat);
|
|
43
|
+
const fileHistoryStore = wiredSeat === "disabled" ? undefined : wiredSeat;
|
|
44
|
+
return { onTrackFailure, wiredSeat, captureOff, fileHistoryStore, captureStore: captureOff ? undefined : fileHistoryStore };
|
|
45
|
+
}
|
|
46
|
+
export function storeUnconfiguredRefusal(wiredSeat, target) {
|
|
47
|
+
const e = new Error(wiredSeat === "disabled"
|
|
48
|
+
? `rewind-files: restoring files to entry "${target}" requires a history backend, but this deployment declared file history disabled (RunnerDeps.fileHistoryStore: "disabled"), so there is no history to restore — the files were NOT rewound`
|
|
49
|
+
: `rewind-files: restoring files to entry "${target}" requires a history backend, but this deployment wired no RunnerDeps.fileHistoryStore — no file history was ever recorded, so the files were NOT rewound`);
|
|
50
|
+
e.code = "rewind.store_unconfigured";
|
|
51
|
+
return e;
|
|
52
|
+
}
|
|
45
53
|
function resolveWiredFileHistoryStore(candidate) {
|
|
46
54
|
if (candidate === undefined || candidate === "disabled")
|
|
47
55
|
return candidate;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE restore of a session's tracked set and the ONE reading of its answer, reached DOWN for by the two seats that
|
|
3
|
+
* restore: the file-history phase's restore seat (`prepare-file-history.ts`, a `restoreFiles` / `rewindFilesTo` run)
|
|
4
|
+
* and the out-of-run rewind (`rewind-files.ts`, `Runner.rewindFiles`). A rewind outside a run is therefore the same
|
|
5
|
+
* history operation as the one a run performs, refused with the same codes and sentences, and handing the paths it
|
|
6
|
+
* moved to the same read-state channel.
|
|
7
|
+
*/
|
|
8
|
+
import type { ExecutionEnv } from "../../internal/harness.js";
|
|
9
|
+
import type { FileHistoryRestoreResult, FileHistoryStore, RewindFilesResult } from "../file-history-store.js";
|
|
10
|
+
import type { SessionReadFileStates } from "./session-read-file-states.js";
|
|
11
|
+
/** A restore outcome a seat may accept: the ledger, with `failed` (the operation could not run) already refused —
|
|
12
|
+
* the out-of-run rewind's answer carries exactly this. */
|
|
13
|
+
export type AcceptedFileHistoryRestore = Extract<RewindFilesResult, {
|
|
14
|
+
dryRun: false;
|
|
15
|
+
}>["restore"];
|
|
16
|
+
/**
|
|
17
|
+
* The ONE restore of a session's tracked set and the ONE reading of its answer — the run's restore seat and the
|
|
18
|
+
* out-of-run `Runner.rewindFiles` both call it, so the two cannot disagree about what a restore means:
|
|
19
|
+
* · every path the attempt may have moved (`filesChanged` ∪ `failed[].path`, whatever the outcome) goes to the
|
|
20
|
+
* session's read-state channel (`noteRestored`), because a read record of the old bytes must stop vouching
|
|
21
|
+
* for them on the session's next leg;
|
|
22
|
+
* · `not_found` is "no boundary for that entry" — `rewind_snapshot.unresolvable` (in a "before" restore, the
|
|
23
|
+
* before-specific sentence);
|
|
24
|
+
* · any other `failed` outcome is `rewind.restore_failed` carrying the ledger and the store's own judgment on
|
|
25
|
+
* the coded `detail` channel (a host reads it, never the prose).
|
|
26
|
+
* A `complete` or `partial` answer is returned for the caller to accept: only a run goes on to work on the tree,
|
|
27
|
+
* so only the run seat has a partial-restore policy.
|
|
28
|
+
*/
|
|
29
|
+
export declare function settleFileHistoryRestore(input: {
|
|
30
|
+
store: FileHistoryStore;
|
|
31
|
+
sessionId: string;
|
|
32
|
+
target: string;
|
|
33
|
+
before: boolean;
|
|
34
|
+
env: ExecutionEnv;
|
|
35
|
+
root: string;
|
|
36
|
+
signal: AbortSignal | undefined;
|
|
37
|
+
readStates: Pick<SessionReadFileStates, "noteRestored"> | undefined;
|
|
38
|
+
}): Promise<AcceptedFileHistoryRestore>;
|
|
39
|
+
/** The per-file ledger as one sentence (counts, then each refused / failed path with its reason). */
|
|
40
|
+
export declare function fileHistoryRestoreLedgerLine(r: FileHistoryRestoreResult): string;
|
|
41
|
+
/** A restore whose entry has no boundary on the session; a PREVIEW's form says "usable" — its probe
|
|
42
|
+
* (`canRestore`) cannot tell a boundary never made from one that is there and unreadable, a real restore can. */
|
|
43
|
+
export declare function noBoundaryRefusal(target: string, sessionId: string, preview?: boolean): Error & {
|
|
44
|
+
code?: string;
|
|
45
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { resolveTrackKey } from "../file-history-store.js";
|
|
2
|
+
import { isGovernanceRetryClass } from "../governance-codes.js";
|
|
3
|
+
export async function settleFileHistoryRestore(input) {
|
|
4
|
+
const { store, sessionId, target, env, root } = input;
|
|
5
|
+
const restored = await store.restore(sessionId, target, env, root, input.signal);
|
|
6
|
+
input.readStates?.noteRestored(sessionId, restoredAbsPathsOf(restored, root));
|
|
7
|
+
if (restored.outcome !== "failed")
|
|
8
|
+
return restored;
|
|
9
|
+
if (restored.error?.code === "not_found") {
|
|
10
|
+
if (input.before)
|
|
11
|
+
throw beforeWithoutBoundaryRefusal(target, sessionId);
|
|
12
|
+
throw noBoundaryRefusal(target, sessionId);
|
|
13
|
+
}
|
|
14
|
+
const e = new Error(`rewind-files restore failed (${restored.error?.code ?? "restore_failed"}): ${restored.error?.message ?? "unknown"} — ledger: ${fileHistoryRestoreLedgerLine(restored)}`);
|
|
15
|
+
e.code = "rewind.restore_failed";
|
|
16
|
+
if (restored.error !== undefined)
|
|
17
|
+
e.detail = { code: restored.error.code, ...(isGovernanceRetryClass(restored.error.permanence) ? { permanence: restored.error.permanence } : {}) };
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
20
|
+
export function fileHistoryRestoreLedgerLine(r) {
|
|
21
|
+
return `applied ${r.filesChanged.length}, identical ${r.identicalSkipped.length}, refused ${r.refused.length}${r.refused.length > 0 ? ` (${r.refused.map((f) => `${f.path}: ${f.reason}`).join("; ")})` : ""}, failed ${r.failed.length}${r.failed.length > 0 ? ` (${r.failed.map((f) => `${f.path}: ${f.reason}`).join("; ")})` : ""}`;
|
|
22
|
+
}
|
|
23
|
+
export function noBoundaryRefusal(target, sessionId, preview = false) {
|
|
24
|
+
const e = new Error(preview
|
|
25
|
+
? `rewind-files: no usable file-history boundary exists for entry "${target}" on session "${sessionId}" (never made, reaped, or there but unreadable — a real rewind names which), so there is nothing to preview. ${rewindRefusalTail()}`
|
|
26
|
+
: `rewind-files: no file-history boundary exists for entry "${target}" on session "${sessionId}" — the working tree was NOT rewound. ${rewindRefusalTail()}`);
|
|
27
|
+
e.code = "rewind_snapshot.unresolvable";
|
|
28
|
+
return e;
|
|
29
|
+
}
|
|
30
|
+
function restoredAbsPathsOf(restored, root) {
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const key of [...restored.filesChanged, ...restored.failed.map((f) => f.path)]) {
|
|
33
|
+
const abs = resolveTrackKey(root, key);
|
|
34
|
+
if (abs.ok)
|
|
35
|
+
out.push(abs.abs);
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function rewindRefusalTail() {
|
|
40
|
+
return `Boundaries are keyed by a turn's INITIAL entry and exist only for turns that recorded history (a RunnerDeps.fileHistoryStore wired, capture on, and the run's file history not disabled); a boundary from the retired whole-tree snapshot era is not restorable by this seat, and reaped boundaries have none.`;
|
|
41
|
+
}
|
|
42
|
+
function beforeWithoutBoundaryRefusal(target, sessionId) {
|
|
43
|
+
const e = new Error(`rewind-files: entry "${target}" has no file-history boundary on session "${sessionId}" — a before-restore needs the target's own boundary and never crosses into an earlier turn, so the working tree was NOT rewound. ${rewindRefusalTail()}`);
|
|
44
|
+
e.code = "rewind_snapshot.unresolvable";
|
|
45
|
+
return e;
|
|
46
|
+
}
|