@sema-agent/core 7.71.1 → 7.73.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 +500 -0
- package/dist/agents/cross-session-ref.d.ts +2 -2
- package/dist/agents/cross-session-ref.js +7 -2
- package/dist/agents/inherited-tool-pool.d.ts +30 -2
- package/dist/agents/inherited-tool-pool.js +53 -7
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/send-message-tool.js +7 -2
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +47 -12
- package/dist/agents/verify.js +23 -7
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.js +14 -9
- package/dist/brain/open-responses.js +4 -5
- package/dist/brain/openai.js +30 -23
- package/dist/brain/stream-engine.js +159 -151
- package/dist/core/a2a.d.ts +24 -3
- package/dist/core/a2a.js +27 -8
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/agent-state.d.ts +28 -7
- package/dist/core/agent-state.js +19 -6
- package/dist/core/allow-entry.js +3 -3
- package/dist/core/approval-object.d.ts +7 -3
- package/dist/core/approval-object.js +30 -9
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/checkpoint-features.d.ts +16 -5
- package/dist/core/checkpoint-features.js +35 -6
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +10 -4
- package/dist/core/checkpoint-store.d.ts +24 -2
- package/dist/core/checkpoint-store.js +1 -0
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/effective-path-target.d.ts +19 -0
- package/dist/core/effective-path-target.js +95 -38
- package/dist/core/engine-capabilities.d.ts +5 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +34 -23
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/file-history-store.d.ts +15 -4
- package/dist/core/file-history-store.js +53 -23
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +10 -1
- package/dist/core/governance-codes.js +17 -5
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/judged-read.d.ts +57 -0
- package/dist/core/judged-read.js +1 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-host-seat.d.ts +5 -0
- package/dist/core/mcp-host-seat.js +7 -1
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp.js +3 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.js +6 -4
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +69 -11
- package/dist/core/memory-engine/scope-contract.js +99 -34
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +21 -6
- package/dist/core/mode-policy.js +15 -6
- package/dist/core/mounted-mcp.d.ts +7 -2
- package/dist/core/mounted-mcp.js +10 -1
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/param-rule-reach.d.ts +8 -3
- package/dist/core/param-rule-reach.js +9 -1
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +18 -0
- package/dist/core/peer-registration.d.ts +52 -0
- package/dist/core/peer-registration.js +37 -0
- package/dist/core/peer-seat.d.ts +3 -1
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +34 -6
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/chain-mismatch.d.ts +32 -0
- package/dist/core/runner/chain-mismatch.js +29 -0
- package/dist/core/runner/changes-history.d.ts +1 -0
- package/dist/core/runner/changes-history.js +2 -2
- package/dist/core/runner/checkpoint-scope.d.ts +13 -3
- package/dist/core/runner/checkpoint-scope.js +12 -4
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +22 -3
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/file-history-restore.d.ts +3 -1
- package/dist/core/runner/file-history-restore.js +9 -6
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/loaded-skills.d.ts +2 -0
- package/dist/core/runner/loaded-skills.js +10 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +23 -20
- package/dist/core/runner/person-path-rows.js +82 -18
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +105 -90
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +5 -3
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-file-history.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +10 -2
- package/dist/core/runner/prepare-hands-readface.js +36 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +2 -2
- package/dist/core/runner/prepare-memory.js +3 -15
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +50 -37
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -4
- package/dist/core/runner/read-session-changes.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
- package/dist/core/runner/resume-checkpoint-screen.js +7 -6
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/rewind-files.js +3 -2
- package/dist/core/runner/run-harness-handlers.js +3 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +9 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +3 -2
- package/dist/core/runner/shell-env-withheld.js +1 -2
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +10 -1
- package/dist/core/runner/terminal-account.js +23 -3
- package/dist/core/runner/tool-face-overlay.d.ts +2 -11
- package/dist/core/runner/tool-face-overlay.js +39 -0
- package/dist/core/runner/trim-stretch.js +7 -2
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner-deps.d.ts +13 -10
- package/dist/core/scheduler.d.ts +47 -7
- package/dist/core/scheduler.js +19 -7
- package/dist/core/secret-env.d.ts +60 -37
- package/dist/core/secret-env.js +45 -48
- package/dist/core/sensitive-path-policy.js +14 -7
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +11 -3
- package/dist/core/task-notification.d.ts +97 -10
- package/dist/core/task-notification.js +129 -5
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +39 -2
- package/dist/core/task-registry.js +76 -12
- package/dist/core/task-result.d.ts +13 -0
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +11 -3
- package/dist/core/task-spec.d.ts +57 -23
- package/dist/core/tool-catalog-entries.js +4 -0
- package/dist/core/tool-face-reader.js +1 -1
- package/dist/core/tool-face.d.ts +7 -0
- package/dist/core/tool-face.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +5 -3
- package/dist/core/tool-mount-facts.js +4 -3
- package/dist/core/tool-mount-plan.d.ts +7 -3
- package/dist/core/tool-mount-plan.js +11 -5
- package/dist/core/tool-mount-static.d.ts +2 -2
- package/dist/core/tool-mount-static.js +28 -14
- package/dist/core/tool-registry.d.ts +33 -1
- package/dist/core/tool-registry.js +33 -0
- package/dist/core/tool-result-store.d.ts +19 -2
- package/dist/core/tool-result-store.js +51 -2
- package/dist/core/tool-roster.d.ts +16 -0
- package/dist/core/tool-roster.js +6 -0
- package/dist/core/tool-spec.d.ts +13 -4
- package/dist/core/tools.d.ts +6 -0
- package/dist/core/tools.js +1 -1
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +89 -29
- package/dist/core/wiring-manifest.js +44 -4
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.js +3 -1
- package/dist/engine/harness/messages.d.ts +1 -1
- package/dist/engine/harness/messages.js +2 -1
- package/dist/engine/harness/types.d.ts +24 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +5 -7
- package/dist/engine/loop/types.d.ts +2 -0
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +35 -5
- package/dist/index.d.ts +27 -12
- package/dist/index.js +20 -8
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +30 -6
- package/dist/orchestration/workflow.js +117 -54
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/stores/file/adoption/marker.d.ts +2 -27
- package/dist/stores/file/adoption/marker.js +12 -0
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +11 -6
- package/dist/tools/fs/file-read-check.d.ts +45 -11
- package/dist/tools/fs/file-read-check.js +200 -57
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/judged-reads.d.ts +51 -0
- package/dist/tools/fs/judged-reads.js +68 -0
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +12 -1
- package/dist/tools/fs/safety.js +16 -3
- package/dist/tools/fs/shell-read-check.d.ts +25 -5
- package/dist/tools/fs/shell-read-check.js +100 -15
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +34 -14
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +5 -0
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/scheduler-store-move.d.ts +74 -0
- package/dist/tools/scheduler-store-move.js +103 -0
- package/dist/tools/scheduler-tools.d.ts +43 -29
- package/dist/tools/scheduler-tools.js +161 -118
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +173 -3
- package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core@7.72.0.json +84 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/primitives@7.72.0.json +6 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/core-stores-sql@7.72.0.json +215 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core@7.72.0.json +2426 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/mods-kernel@7.72.0.json +147 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/primitives@7.72.0.json +143 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/wiki-gate@7.72.0.json +145 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
|
@@ -17,6 +17,10 @@ import { engineLaneLegOf } from "./park-resumability.js";
|
|
|
17
17
|
import { planStaticToolMounts } from "./tool-mount-static.js";
|
|
18
18
|
import { EXECUTION_ENV_NEEDS } from "./tool-mount-plan.js";
|
|
19
19
|
import { enterConfigDoor } from "./config-refusal-input.js";
|
|
20
|
+
import { readCallerSpec } from "./task-spec-members.js";
|
|
21
|
+
import { PROJECT_MARKER_UNREADABLE_REASONS } from "./memory-engine/scope-contract.js";
|
|
22
|
+
import { codedDetailStringOf } from "./runner/terminal-account.js";
|
|
23
|
+
import { readLegInstanceFact, receiveHostInstance } from "./host-instance.js";
|
|
20
24
|
export function wiringLegKindOf(resumed, internals) {
|
|
21
25
|
return resumed ? "resume" : engineLaneLegOf(internals) ? "child" : "root";
|
|
22
26
|
}
|
|
@@ -238,9 +242,33 @@ function readSessionRulesFact(fact) {
|
|
|
238
242
|
throw new Error(`the session-rules wiring fact ${JSON.stringify(fact)} is not a boolean`);
|
|
239
243
|
return { childrenReadLive: fact };
|
|
240
244
|
}
|
|
245
|
+
function readProjectFact(fact) {
|
|
246
|
+
const { id, source } = typeof fact === "object" && fact !== null ? fact : { id: undefined, source: undefined };
|
|
247
|
+
if (typeof id !== "string" || id.length === 0 || (source !== "marker" && source !== "declared")) {
|
|
248
|
+
throw new Error(`the project wiring fact is inconsistent (${JSON.stringify(fact)}) — id must be a non-empty string and source "marker"|"declared"`);
|
|
249
|
+
}
|
|
250
|
+
return { id, source };
|
|
251
|
+
}
|
|
252
|
+
function readProjectMarkerUnreadableFact(fact) {
|
|
253
|
+
const { reason, markerPath } = typeof fact === "object" && fact !== null ? fact : { reason: undefined, markerPath: undefined };
|
|
254
|
+
if (typeof reason !== "string" || !PROJECT_MARKER_UNREADABLE_REASONS.includes(reason)) {
|
|
255
|
+
throw new Error(`the projectMarkerUnreadable wiring fact is inconsistent (${JSON.stringify(fact)}) — reason must be one of ${PROJECT_MARKER_UNREADABLE_REASONS.join("|")}`);
|
|
256
|
+
}
|
|
257
|
+
if (reason === "repo_root_unreadable") {
|
|
258
|
+
if (markerPath !== undefined) {
|
|
259
|
+
throw new Error(`the projectMarkerUnreadable wiring fact is inconsistent (${JSON.stringify(fact)}) — markerPath must be omitted for repo_root_unreadable`);
|
|
260
|
+
}
|
|
261
|
+
return { reason };
|
|
262
|
+
}
|
|
263
|
+
if (markerPath !== undefined && (typeof markerPath !== "string" || markerPath.length === 0)) {
|
|
264
|
+
throw new Error(`the projectMarkerUnreadable wiring fact is inconsistent (${JSON.stringify(fact)}) — markerPath must be a non-empty string or omitted`);
|
|
265
|
+
}
|
|
266
|
+
const shown = markerPath !== undefined ? codedDetailStringOf(markerPath) : undefined;
|
|
267
|
+
return shown !== undefined ? { reason: reason, markerPath: shown } : { reason: reason };
|
|
268
|
+
}
|
|
241
269
|
export function deriveWiringManifest(facts) {
|
|
242
|
-
if (facts.half === "static" && (facts.leg !== undefined || facts.runOrigin !== undefined)) {
|
|
243
|
-
throw new Error("a static wiring manifest has no leg — leg identity (its kind and its run origin) is an effective-half fact");
|
|
270
|
+
if (facts.half === "static" && (facts.leg !== undefined || facts.legInstance !== undefined || facts.runOrigin !== undefined)) {
|
|
271
|
+
throw new Error("a static wiring manifest has no leg — leg identity (its kind, its instance and its run origin) is an effective-half fact");
|
|
244
272
|
}
|
|
245
273
|
if (facts.half === "effective" && facts.leg === undefined) {
|
|
246
274
|
throw new Error("an effective wiring manifest requires its leg kind");
|
|
@@ -252,6 +280,9 @@ export function deriveWiringManifest(facts) {
|
|
|
252
280
|
if (facts.forcedGateNotResumable === true && (facts.half !== "effective" || facts.parkLegNotResumable !== true)) {
|
|
253
281
|
throw new Error("the wiring facts are inconsistent (forcedGateNotResumable) — the forced gate's refusal stands only on an effective half whose leg cannot be resumed (parkLegNotResumable)");
|
|
254
282
|
}
|
|
283
|
+
if (facts.half === "effective" && facts.project !== undefined && facts.projectMarkerUnreadable !== undefined) {
|
|
284
|
+
throw new Error("the wiring facts are inconsistent (project and projectMarkerUnreadable) — a leg cannot carry both a project verdict and an unreadable-marker fact");
|
|
285
|
+
}
|
|
255
286
|
const parkLane = deriveParkLane(facts);
|
|
256
287
|
const questionChannel = facts.questionWired
|
|
257
288
|
? "wired"
|
|
@@ -260,7 +291,8 @@ export function deriveWiringManifest(facts) {
|
|
|
260
291
|
: "absent";
|
|
261
292
|
const manifest = {
|
|
262
293
|
schemaVersion: 1,
|
|
263
|
-
...(facts.leg !== undefined ? { leg: { kind: facts.leg, ...(facts.runOrigin !== undefined ? { runOrigin: readWordFact(facts.runOrigin, RUN_ORIGINS, "run origin") } : {}) } } : {}),
|
|
294
|
+
...(facts.leg !== undefined ? { leg: { kind: facts.leg, ...(facts.legInstance !== undefined ? { instance: readLegInstanceFact(facts.legInstance) } : {}), ...(facts.runOrigin !== undefined ? { runOrigin: readWordFact(facts.runOrigin, RUN_ORIGINS, "run origin") } : {}) } } : {}),
|
|
295
|
+
...(facts.host !== undefined ? { host: receiveHostInstance(facts.host, "WiringFacts.host") } : {}),
|
|
264
296
|
ask: {
|
|
265
297
|
form: facts.askForm,
|
|
266
298
|
...(facts.askProvenance !== undefined ? { provenance: facts.askProvenance } : {}),
|
|
@@ -331,6 +363,8 @@ export function deriveWiringManifest(facts) {
|
|
|
331
363
|
...(facts.half === "effective" && facts.sessionRulesChildrenReadLive !== undefined ? { sessionRules: readSessionRulesFact(facts.sessionRulesChildrenReadLive) } : {}),
|
|
332
364
|
...(facts.half === "effective" && facts.advisor !== undefined ? { advisor: { ...facts.advisor, ...(facts.advisor.hold !== undefined ? { hold: { ...facts.advisor.hold } } : {}) } } : {}),
|
|
333
365
|
...(facts.half === "effective" && facts.hostFloor !== undefined ? { hostFloor: { onlyMode: facts.hostFloor.onlyMode, denyCount: facts.hostFloor.denyCount, onlyCount: facts.hostFloor.onlyCount } } : {}),
|
|
366
|
+
...(facts.half === "effective" && facts.project !== undefined ? { project: readProjectFact(facts.project) } : {}),
|
|
367
|
+
...(facts.half === "effective" && facts.projectMarkerUnreadable !== undefined ? { projectMarkerUnreadable: readProjectMarkerUnreadableFact(facts.projectMarkerUnreadable) } : {}),
|
|
334
368
|
...(facts.half === "effective" && facts.teamRole !== undefined ? { teamRole: facts.teamRole } : {}),
|
|
335
369
|
...(facts.half === "effective" && facts.peerPresence !== undefined && (facts.peerPresence.agent !== undefined || facts.peerPresence.intent !== undefined)
|
|
336
370
|
? { peerPresence: { ...(facts.peerPresence.agent !== undefined ? { agent: facts.peerPresence.agent } : {}), ...(facts.peerPresence.intent !== undefined ? { intent: facts.peerPresence.intent } : {}) } }
|
|
@@ -422,13 +456,19 @@ export function screenInteractionPostureWord(posture) {
|
|
|
422
456
|
e.code = "config.interaction_posture";
|
|
423
457
|
throw e;
|
|
424
458
|
}
|
|
425
|
-
export function describeStaticWiring(deps,
|
|
459
|
+
export function describeStaticWiring(deps, handed = {}, statement = {}) {
|
|
460
|
+
const read = readCallerSpec(handed);
|
|
461
|
+
if (read.refusal !== undefined)
|
|
462
|
+
throw read.refusal;
|
|
463
|
+
const spec = read.spec;
|
|
464
|
+
const host = receiveHostInstance(deps.host, "RunnerDeps.host");
|
|
426
465
|
const ask = resolveAskSeamForm(spec, deps);
|
|
427
466
|
const question = resolveQuestionSeam(spec, deps);
|
|
428
467
|
const checkpointStore = resolveCheckpointStore(spec, deps);
|
|
429
468
|
const capable = checkpointStore !== undefined;
|
|
430
469
|
return deriveWiringManifest({
|
|
431
470
|
half: "static",
|
|
471
|
+
...(host !== undefined ? { host } : {}),
|
|
432
472
|
askForm: ask.form,
|
|
433
473
|
...(ask.provenance !== undefined ? { askProvenance: ask.provenance } : {}),
|
|
434
474
|
...(ask.answeredClasses !== undefined ? { askAnsweredClasses: ask.answeredClasses } : {}),
|
|
@@ -284,7 +284,32 @@ export interface ResumeClaimAnswer {
|
|
|
284
284
|
* not read (0 or less: refused while expired is a contradiction; not a safe integer; over the bound) names no instant and
|
|
285
285
|
* says the store's answer does not read. */
|
|
286
286
|
remainingMs?: number;
|
|
287
|
+
/** On a refusal because the key carries a permanent stop tombstone ({@link WorkflowJournalStore.stopResumeClaim}): who stopped
|
|
288
|
+
* the workflow tree. Reported explicitly by the store, never guessed by a caller from a prefix on `holder`. */
|
|
289
|
+
stopped?: {
|
|
290
|
+
readonly by: string;
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/** Input to {@link WorkflowJournalStore.stopResumeClaim} (#5156 R1). */
|
|
294
|
+
export interface StopResumeClaimArgs {
|
|
295
|
+
/** The claim key (the workflow tree's root or tree id — opaque to the store, keyed verbatim as in {@link ResumeClaimArgs}). */
|
|
296
|
+
sourceRunId: string;
|
|
297
|
+
scope: string;
|
|
298
|
+
/** Non-empty identifier of who stopped the workflow tree (e.g. `"user"`, `"parent"`, `"system"`), echoed on
|
|
299
|
+
* {@link ResumeClaimAnswer.stopped}. */
|
|
300
|
+
stoppedBy: string;
|
|
301
|
+
/** When given, a binding claim currently held by THIS holder (arm (c): the caller's own in-process run, or a terminal run
|
|
302
|
+
* whose release failed) is rewritten into a tombstone in place; any other binding holder refuses without writing. */
|
|
303
|
+
holder?: string;
|
|
287
304
|
}
|
|
305
|
+
/** What {@link WorkflowJournalStore.stopResumeClaim} answers: `{ stopped: true }` once a tombstone stands on `(sourceRunId, scope)`,
|
|
306
|
+
* or `{ stopped: false, holder? }` when another binding holder owns the claim (nothing written). */
|
|
307
|
+
export type StopResumeClaimAnswer = {
|
|
308
|
+
readonly stopped: true;
|
|
309
|
+
} | {
|
|
310
|
+
readonly stopped: false;
|
|
311
|
+
readonly holder?: string;
|
|
312
|
+
};
|
|
288
313
|
/**
|
|
289
314
|
* The seam a resume reads/writes its journal through. Core ships {@link InMemoryWorkflowJournalStore}; a durable
|
|
290
315
|
* deployment provides a Postgres-backed one (service SVC-2) so a workflow survives a replica crash. The owner of
|
|
@@ -446,6 +471,21 @@ export interface WorkflowJournalStore {
|
|
|
446
471
|
* rely on the engine waiting indefinitely for cleanup.
|
|
447
472
|
*/
|
|
448
473
|
releaseResumeClaim?(input: ResumeClaimArgs): Promise<void>;
|
|
474
|
+
/**
|
|
475
|
+
* Write a permanent stop tombstone on `(sourceRunId, scope)` in one compare-and-write (#5156 R1):
|
|
476
|
+
* - (a) row absent ⇒ write tombstone, answer `{ stopped: true }`;
|
|
477
|
+
* - (b) row no longer binds (expired, or holder process proven gone on a store that checks it) ⇒ replace with tombstone,
|
|
478
|
+
* answer `{ stopped: true }`;
|
|
479
|
+
* - (c) `holder` given and matches the current holder ⇒ rewrite in place into a tombstone (dropping any holder process),
|
|
480
|
+
* answer `{ stopped: true }`;
|
|
481
|
+
* - (d) already a tombstone ⇒ idempotent, preserve the existing tombstone as stored, answer `{ stopped: true }`;
|
|
482
|
+
* - held by another and still binding ⇒ write nothing, answer `{ stopped: false, holder }`.
|
|
483
|
+
*
|
|
484
|
+
* A tombstone never expires, is never taken over, is never deleted by {@link releaseResumeClaim} (for any holder string),
|
|
485
|
+
* sweep or {@link deleteRun}, and makes {@link resumeClaim} answer `{ granted: false, stopped: { by } }`.
|
|
486
|
+
* OPTIONAL: a store without this verb is legal.
|
|
487
|
+
*/
|
|
488
|
+
stopResumeClaim?(input: StopResumeClaimArgs): Promise<StopResumeClaimAnswer>;
|
|
449
489
|
}
|
|
450
490
|
export declare const MAX_JOURNAL_RESULT_BYTES: number;
|
|
451
491
|
/** True when a serialized journal result is too large to store (UTF-8 byte length over {@link MAX_JOURNAL_RESULT_BYTES}). */
|
|
@@ -524,21 +564,24 @@ export declare const IN_MEMORY_RESUME_CLAIM_TTL_MS: number;
|
|
|
524
564
|
* this one process. */
|
|
525
565
|
export declare class InMemoryWorkflowJournalStore implements WorkflowJournalStore {
|
|
526
566
|
private readonly runs;
|
|
527
|
-
/** RB-367 resume claims, nested by scope then sourceRunId (rather than a single
|
|
528
|
-
* untrusted-length `scope`/`sourceRunId` text (`sourceRunId` is `resumeFromRunId` — LLM-controlled)
|
|
529
|
-
* collide across the boundary between the two fields.
|
|
567
|
+
/** RB-367 resume claims and #5156 R1 native tombstones, nested by scope then sourceRunId (rather than a single
|
|
568
|
+
* string-concatenated key) so untrusted-length `scope`/`sourceRunId` text (`sourceRunId` is `resumeFromRunId` — LLM-controlled)
|
|
569
|
+
* can never collide across the boundary between the two fields. Tombstones are a distinct variant — never a sentinel holder
|
|
570
|
+
* string — so `releaseResumeClaim` for any string can never delete one. */
|
|
530
571
|
private readonly resumeClaims;
|
|
531
572
|
private claimsForScope;
|
|
532
|
-
/** Contract parity with the file store: keyed by `(sourceRunId, scope)`;
|
|
533
|
-
* SAME holder; an unexpired claim held by someone else refuses (naming the holder); an expired or
|
|
534
|
-
* claim is free to take. Acquisition is a single synchronous Map read-then-write with no `await` between
|
|
535
|
-
* the
|
|
536
|
-
*
|
|
537
|
-
*
|
|
573
|
+
/** Contract parity with the file store: keyed by `(sourceRunId, scope)`; a tombstone always refuses with `stopped: { by }`;
|
|
574
|
+
* idempotent re-grant to the SAME holder; an unexpired claim held by someone else refuses (naming the holder); an expired or
|
|
575
|
+
* absent claim is free to take. Acquisition is a single synchronous Map read-then-write with no `await` between the check and
|
|
576
|
+
* the publish — there is no window (matching the atomicity RB-354 requires of a durable implementation) in which a concurrent
|
|
577
|
+
* caller could observe the key as free mid-acquire. Both answers say how long the claim has left by this process's clock (a
|
|
578
|
+
* re-claim by its holder starts the lease again). */
|
|
538
579
|
resumeClaim(input: ResumeClaimArgs): Promise<ResumeClaimAnswer>;
|
|
539
|
-
/** Release ONLY a claim `newRunId` still holds (a missing/foreign/already-taken-over claim is a
|
|
580
|
+
/** Release ONLY a claim `newRunId` still holds (a missing/foreign/already-taken-over claim or a tombstone is a
|
|
540
581
|
* no-op, never an error — matches the file store's contract). */
|
|
541
582
|
releaseResumeClaim(input: ResumeClaimArgs): Promise<void>;
|
|
583
|
+
/** #5156 R1 — compare-and-write a native tombstone on `(sourceRunId, scope)` (single synchronous Map step). */
|
|
584
|
+
stopResumeClaim(input: StopResumeClaimArgs): Promise<StopResumeClaimAnswer>;
|
|
542
585
|
deleteRun(runId: string, scope: string): Promise<boolean>;
|
|
543
586
|
/** Launch records by run id, each with the scope it was kept under. */
|
|
544
587
|
private readonly launches;
|
|
@@ -312,11 +312,16 @@ export class InMemoryWorkflowJournalStore {
|
|
|
312
312
|
const table = this.claimsForScope(input.scope);
|
|
313
313
|
const now = Date.now();
|
|
314
314
|
const existing = table.get(input.sourceRunId);
|
|
315
|
-
if (existing !== undefined
|
|
316
|
-
|
|
315
|
+
if (existing !== undefined) {
|
|
316
|
+
if (existing.kind === "tombstone") {
|
|
317
|
+
return { granted: false, stopped: { by: existing.stoppedBy } };
|
|
318
|
+
}
|
|
319
|
+
if (existing.expiresAt > now && existing.holder !== input.newRunId) {
|
|
320
|
+
return { granted: false, holder: existing.holder, ...resumeClaimRemainingMember(existing.expiresAt, now) };
|
|
321
|
+
}
|
|
317
322
|
}
|
|
318
323
|
const expiresAt = now + IN_MEMORY_RESUME_CLAIM_TTL_MS;
|
|
319
|
-
table.set(input.sourceRunId, { holder: input.newRunId, expiresAt });
|
|
324
|
+
table.set(input.sourceRunId, { kind: "claim", holder: input.newRunId, expiresAt });
|
|
320
325
|
return { granted: true, ...resumeClaimRemainingMember(expiresAt, now) };
|
|
321
326
|
}
|
|
322
327
|
async releaseResumeClaim(input) {
|
|
@@ -324,9 +329,27 @@ export class InMemoryWorkflowJournalStore {
|
|
|
324
329
|
if (table === undefined)
|
|
325
330
|
return;
|
|
326
331
|
const existing = table.get(input.sourceRunId);
|
|
327
|
-
if (existing !== undefined && existing.holder === input.newRunId)
|
|
332
|
+
if (existing !== undefined && existing.kind === "claim" && existing.holder === input.newRunId)
|
|
328
333
|
table.delete(input.sourceRunId);
|
|
329
334
|
}
|
|
335
|
+
async stopResumeClaim(input) {
|
|
336
|
+
if (typeof input.stoppedBy !== "string" || input.stoppedBy === "") {
|
|
337
|
+
throw new TypeError("workflow journal: stopResumeClaim requires a non-empty stoppedBy string");
|
|
338
|
+
}
|
|
339
|
+
const table = this.claimsForScope(input.scope);
|
|
340
|
+
const now = Date.now();
|
|
341
|
+
const existing = table.get(input.sourceRunId);
|
|
342
|
+
if (existing !== undefined) {
|
|
343
|
+
if (existing.kind === "tombstone")
|
|
344
|
+
return { stopped: true };
|
|
345
|
+
const binds = existing.expiresAt > now;
|
|
346
|
+
if (binds && (input.holder === undefined || existing.holder !== input.holder)) {
|
|
347
|
+
return { stopped: false, holder: existing.holder };
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
table.set(input.sourceRunId, { kind: "tombstone", stoppedBy: input.stoppedBy, stoppedAt: now });
|
|
351
|
+
return { stopped: true };
|
|
352
|
+
}
|
|
330
353
|
async deleteRun(runId, scope) {
|
|
331
354
|
const launch = this.launches.get(runId);
|
|
332
355
|
if (launch !== undefined && launch.scope === scope)
|
|
@@ -155,6 +155,22 @@ export async function workflowRunStoreContract(make, runAssertion = defaultSeque
|
|
|
155
155
|
assert.equal(await store.update("fin", "tenant-a", { ...passed, parks: [{ ...entry, passedTo: "fin-other" }] }, { rev: got.rev ?? 0 }), false, "the same expectation loses once the row moved");
|
|
156
156
|
assert.deepEqual((await store.get("fin")).parks, [{ ...entry, passedTo: "fin-next" }], "a lost write changes nothing");
|
|
157
157
|
});
|
|
158
|
+
run("update never moves a terminal run (completed or failed) back to running: the write loses and changes nothing", async () => {
|
|
159
|
+
const store = make();
|
|
160
|
+
for (const status of ["completed", "failed"]) {
|
|
161
|
+
const id = `term-${status}`;
|
|
162
|
+
await store.put(id, createWorkflowRun({ id, status, creationId: `c-${status}` }));
|
|
163
|
+
const before = (await store.get(id));
|
|
164
|
+
const backToRunning = { ...before, status: "running", endedAt: undefined };
|
|
165
|
+
assert.equal(await store.update(id, "tenant-a", backToRunning, { rev: before.rev ?? 0 }), false, `${status} -> running loses with matching rev`);
|
|
166
|
+
assert.equal(await store.update(id, "tenant-a", backToRunning, { rev: before.rev ?? 0, creationId: `c-${status}` }), false, `${status} -> running loses with matching rev and creationId`);
|
|
167
|
+
assert.equal(await store.update(id, "tenant-a", backToRunning), false, `${status} -> running loses without expect`);
|
|
168
|
+
for (const cause of WORKFLOW_RUN_UPDATE_CAUSES) {
|
|
169
|
+
assert.equal(await store.update(id, "tenant-a", backToRunning, { rev: before.rev ?? 0, creationId: `c-${status}` }, { cause }), false, `${status} -> running loses with cause ${cause}`);
|
|
170
|
+
}
|
|
171
|
+
assert.deepEqual(await store.get(id), before, `${status} row is untouched after refused writes`);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
158
174
|
run("an update stating a cause persists the same row as one stating none, and wins and loses on rev, scope and a missing row the same way", async () => {
|
|
159
175
|
const store = make();
|
|
160
176
|
for (const cause of WORKFLOW_RUN_UPDATE_CAUSES) {
|
|
@@ -267,9 +267,11 @@ export interface WorkflowRunStore {
|
|
|
267
267
|
* Atomic CAS update of an EXISTING run (`UPDATE … SET … WHERE id=? AND scope=?` [`AND rev=?`] [`AND` the creation id]). Returns
|
|
268
268
|
* `true` for the winner, `false` when the row is missing, the `scope` does not match (multi-tenant
|
|
269
269
|
* isolation — a wrong-scope update must not win), `expect.rev` does not match the live row's `rev`
|
|
270
|
-
* (an intervening update bumped it),
|
|
270
|
+
* (an intervening update bumped it), `expect.creationId` is given and the live row is another creation of the id
|
|
271
271
|
* ({@link WorkflowRunUpdateExpect}: a string must equal the row's member, `null` matches only a row whose member is not a string —
|
|
272
|
-
* a SQL twin compares "is the extracted value a string", never "IS NULL", since a stored JSON null reads differently per dialect)
|
|
272
|
+
* a SQL twin compares "is the extracted value a string", never "IS NULL", since a stored JSON null reads differently per dialect),
|
|
273
|
+
* or the live row is terminal (`completed` / `failed`) and the candidate would move it back to `running` (a finished run never moves
|
|
274
|
+
* back to running; updates that keep a terminal row terminal — `park_pass`, `park_decision_settled`, `tree_id_stamp` — still apply).
|
|
273
275
|
* A write that loses changes nothing. On success the store bumps the row's `rev` (monotonic) and persists
|
|
274
276
|
* the new `run`. The workflow owner writes its record while it runs (best-effort progress recording — design/97 §F);
|
|
275
277
|
* once the run has finished, a later continuation of its chain may write it again to take over a park it holds
|
|
@@ -337,8 +339,8 @@ export interface WorkflowRunStore {
|
|
|
337
339
|
/**
|
|
338
340
|
* REF-A5 — THE optimistic-concurrency guard for {@link WorkflowRunStore.update}, shared by every backend:
|
|
339
341
|
* scope in the WHERE (multi-tenant isolation — a wrong-scope update never wins), row must exist, an
|
|
340
|
-
* `expect.rev` that no longer matches the LIVE row loses (an intervening update bumped it),
|
|
341
|
-
* not loses ({@link WorkflowRunUpdateExpect}). Returns the
|
|
342
|
+
* `expect.rev` that no longer matches the LIVE row loses (an intervening update bumped it), an `expect.creationId` the live row is
|
|
343
|
+
* not loses ({@link WorkflowRunUpdateExpect}), and a terminal row never moves back to a non-terminal state. Returns the
|
|
342
344
|
* row to persist, or `null` when the CAS lost; PURE — it neither reads nor writes any store state, so
|
|
343
345
|
* each backend keeps its own persistence mechanism (in-memory `Map.set` vs ledger commit) around it.
|
|
344
346
|
* RB-59 (a cross-instance CAS both instances won) landed on this predicate.
|
|
@@ -400,9 +402,9 @@ export interface WorkflowRunReapFault {
|
|
|
400
402
|
* erases its runs ({@link import("./retention.js").RETENTION_CASCADE}): its journal, then its persisted script, then its row
|
|
401
403
|
* ({@link WorkflowRunStore.deleteRun}) — so nothing a run id keys outlives the row it is found through. Before a run's first leg its
|
|
402
404
|
* record is read again and the selection re-judged on it (gone, no longer a terminal run of the scope, or — doomed by age — ended
|
|
403
|
-
* since: skipped, nothing of it erased). A run's three parts are all there or its row is gone
|
|
404
|
-
* terminal row back to running
|
|
405
|
-
*
|
|
405
|
+
* since: skipped, nothing of it erased). A run's three parts are all there or its row is gone (a conforming store refuses moving a
|
|
406
|
+
* terminal row back to running; only an id deleted and recreated as running between that re-judgment and the row step leaves the
|
|
407
|
+
* new running row in `kept`). Once its first leg has run, every
|
|
406
408
|
* leg runs, the row's last, whatever the ones before it answered — a row left beside an erased journal is a run a resume would run
|
|
407
409
|
* again from its start. A leg that throws is one entry of `kept` (its part stays in that store; a run whose row's own leg threw keeps
|
|
408
410
|
* its row, and the next sweep finds it again); a row that is no longer a terminal run when its own turn comes is reported the same
|
|
@@ -124,7 +124,10 @@ export function nextWorkflowRunOnUpdate(cur, id, scope, run, expect, disclose) {
|
|
|
124
124
|
next.id = id;
|
|
125
125
|
next.scope = scope;
|
|
126
126
|
next.rev = (live.rev ?? 0) + 1;
|
|
127
|
-
|
|
127
|
+
const admitted = admitWorkflowRun(next, id);
|
|
128
|
+
if (isTerminalWorkflowStatus(live.status) && !isTerminalWorkflowStatus(admitted.status))
|
|
129
|
+
return null;
|
|
130
|
+
return admitted;
|
|
128
131
|
}
|
|
129
132
|
function orderKey(value) {
|
|
130
133
|
return typeof value === "number" && Number.isFinite(value) ? value : -Infinity;
|
|
@@ -9,7 +9,7 @@ import { basename, dirname, isAbsolute, join, sep } from "node:path";
|
|
|
9
9
|
import { createInterface } from "node:readline";
|
|
10
10
|
import { ExecutionError, err, FileError, ok, toError, } from "../harness/types.js";
|
|
11
11
|
import { killProcessTree, shutdownDebug } from "./kill-tree.js";
|
|
12
|
-
import { __resetSecretEnvScrubNoticeAnnouncement, announceSecretEnvScrub, declaredInheritEntry, hostChildEnv, hostChildEnvProblem, inheritEnvPolicyProblem, inheritedHostEnv } from "../../core/secret-env.js";
|
|
12
|
+
import { __resetSecretEnvScrubNoticeAnnouncement, announceSecretEnvScrub, declaredInheritEntry, hostChildEnv, hostChildEnvProblem, inheritEnvPolicyProblem, inheritedHostEnv, noteChildSpawned } from "../../core/secret-env.js";
|
|
13
13
|
import { deliverEngineNotice } from "../../core/engine-notice.js";
|
|
14
14
|
import { confineShellStart, SANDBOX_EXEC, SEATBELT_PROBE_PROFILE } from "../../core/shell-confinement.js";
|
|
15
15
|
import { physicalPathOfAsync } from "../../core/physical-path.js";
|
|
@@ -846,6 +846,7 @@ export class NodeExecutionEnv {
|
|
|
846
846
|
...shellChildStdio(execSpoolFds, input !== undefined),
|
|
847
847
|
windowsHide: true,
|
|
848
848
|
});
|
|
849
|
+
noteChildSpawned(this.inheritEnv);
|
|
849
850
|
}
|
|
850
851
|
catch (error) {
|
|
851
852
|
closeSpoolFds();
|
|
@@ -1711,6 +1712,7 @@ export class NodeExecutionEnv {
|
|
|
1711
1712
|
...shellChildStdio(spoolFds, false),
|
|
1712
1713
|
windowsHide: true,
|
|
1713
1714
|
});
|
|
1715
|
+
noteChildSpawned(this.inheritEnv);
|
|
1714
1716
|
}
|
|
1715
1717
|
catch (error) {
|
|
1716
1718
|
if (spoolFds) {
|
|
@@ -13,7 +13,7 @@ export declare function bashExecutionToText(msg: BashExecutionMessage): string;
|
|
|
13
13
|
* drives the wrapper's scale disclosure; omitted ⇒ the wrapper stays byte-identical.
|
|
14
14
|
* `unsummarizedMessages` (PTL-shortfall accounting): how many of those the summary does NOT cover
|
|
15
15
|
* (input shed by a reactive prompt-too-long retry); omitted / 0 ⇒ no uncovered clause. */
|
|
16
|
-
export declare function createCompactionSummaryMessage(summary: string, tokensBefore: number, timestamp: string, elidedMessages?: number, unsummarizedMessages?: number): CompactionSummaryMessage;
|
|
16
|
+
export declare function createCompactionSummaryMessage(summary: string, tokensBefore: number, timestamp: string, elidedMessages?: number, unsummarizedMessages?: number, entryId?: string): CompactionSummaryMessage;
|
|
17
17
|
/** Build a custom transcript message that can be shown and replayed into context. */
|
|
18
18
|
export declare function createCustomMessage(customType: string, content: string | (TextContent | ImageContent)[], display: boolean, details: unknown, timestamp: string): CustomMessage;
|
|
19
19
|
/** Prefix stamped on a salvaged block so readers (model, summaries, humans) see it is a normalization
|
|
@@ -38,7 +38,7 @@ export function bashExecutionToText(msg) {
|
|
|
38
38
|
}
|
|
39
39
|
return text;
|
|
40
40
|
}
|
|
41
|
-
export function createCompactionSummaryMessage(summary, tokensBefore, timestamp, elidedMessages, unsummarizedMessages) {
|
|
41
|
+
export function createCompactionSummaryMessage(summary, tokensBefore, timestamp, elidedMessages, unsummarizedMessages, entryId) {
|
|
42
42
|
return {
|
|
43
43
|
role: "compactionSummary",
|
|
44
44
|
summary,
|
|
@@ -46,6 +46,7 @@ export function createCompactionSummaryMessage(summary, tokensBefore, timestamp,
|
|
|
46
46
|
timestamp: requireSessionTimestampMs(timestamp, "compaction summary timestamp"),
|
|
47
47
|
...(elidedMessages !== undefined ? { elidedMessages } : {}),
|
|
48
48
|
...(unsummarizedMessages !== undefined ? { unsummarizedMessages } : {}),
|
|
49
|
+
...(entryId !== undefined ? { entryId } : {}),
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
export function createCustomMessage(customType, content, display, details, timestamp) {
|
|
@@ -1059,6 +1059,24 @@ export interface ReminderMarkEntry extends SessionTreeEntryBase {
|
|
|
1059
1059
|
/** The opaque mark token (bounded; scheme-verified by the consumer, never by the store). */
|
|
1060
1060
|
mark: string;
|
|
1061
1061
|
}
|
|
1062
|
+
/**
|
|
1063
|
+
* A run's MEMBER LEDGER as one delivery carried it (`TaskSpec.runLedger`): written beside each report the run's report tool
|
|
1064
|
+
* delivered and once at the run's end, so a session reopened later replays the engine's half of every delivery exactly as it was.
|
|
1065
|
+
* Never rendered into the model's context. The ledger is an open record (`RunLedger`, `v` its shape version); the log keeps it as
|
|
1066
|
+
* written and a reader judges the members it knows.
|
|
1067
|
+
*/
|
|
1068
|
+
export interface RunLedgerEntry extends SessionTreeEntryBase {
|
|
1069
|
+
type: "run_ledger";
|
|
1070
|
+
/** The ledger snapshot (`RunLedger`) — plain data. */
|
|
1071
|
+
ledger: {
|
|
1072
|
+
readonly v: number;
|
|
1073
|
+
readonly seq: number;
|
|
1074
|
+
readonly final: boolean;
|
|
1075
|
+
readonly rows: readonly unknown[];
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
/** The shape gate of a {@link RunLedgerEntry}'s ledger (the append's and the import door's one check). */
|
|
1079
|
+
export declare function isRunLedgerRecord(v: unknown): v is RunLedgerEntry["ledger"];
|
|
1062
1080
|
/**
|
|
1063
1081
|
* design/319: strict shape gate for the reminder-mark entry — the SINGLE normalization the read
|
|
1064
1082
|
* walk, the public append, and the import-validate door all use (the {@link normalizeAnnouncedListing}
|
|
@@ -1236,7 +1254,7 @@ export declare function isSyntheticApiErrorMessage(m: unknown): boolean;
|
|
|
1236
1254
|
export declare function isOptionalDisplayString(v: unknown, max?: number): boolean;
|
|
1237
1255
|
export declare function normalizeAnnouncedListing(v: unknown): AnnouncedListingSnapshot | undefined;
|
|
1238
1256
|
/** All persisted session tree entry variants. */
|
|
1239
|
-
export type SessionTreeEntry = MessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | CompactionEntry | CustomEntry | CustomMessageEntry | LabelEntry | SessionInfoEntry | LeafEntry | PromptEpochEntry | AnnouncedListingEntry | GitAnnouncementEntry | WorkspaceStateEntry | SessionCheckoutEntry | ReminderMarkEntry;
|
|
1257
|
+
export type SessionTreeEntry = MessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | CompactionEntry | CustomEntry | CustomMessageEntry | LabelEntry | SessionInfoEntry | LeafEntry | PromptEpochEntry | AnnouncedListingEntry | GitAnnouncementEntry | WorkspaceStateEntry | SessionCheckoutEntry | ReminderMarkEntry | RunLedgerEntry;
|
|
1240
1258
|
export interface SessionContext {
|
|
1241
1259
|
messages: AgentMessage[];
|
|
1242
1260
|
thinkingLevel: string;
|
|
@@ -1452,6 +1470,11 @@ export interface Session<TMetadata extends SessionMetadata = SessionMetadata> {
|
|
|
1452
1470
|
* mark restore ladder — the checkpoint seed stays first, the trusted fork channel second).
|
|
1453
1471
|
* Undefined ⇒ no entry visible. OPTIONAL, same posture as `appendReminderMark`. */
|
|
1454
1472
|
getReminderMark?(): Promise<string | undefined>;
|
|
1473
|
+
/** Persist a run's member ledger snapshot as a first-class {@link RunLedgerEntry} (see `Session.appendRunLedger`). OPTIONAL on
|
|
1474
|
+
* the interface — an implementer without it records none (the result and the report tool's own result still carry it). */
|
|
1475
|
+
appendRunLedger?(ledger: RunLedgerEntry["ledger"]): Promise<string>;
|
|
1476
|
+
/** The run-ledger entries on the active branch, oldest first — a reopened session's replay of every delivery's engine half. OPTIONAL, same posture. */
|
|
1477
|
+
getRunLedgers?(): Promise<RunLedgerEntry["ledger"][]>;
|
|
1455
1478
|
/** The branch's current prompt-epoch descriptor (semantics: `Session.getPromptEpoch`). OPTIONAL on
|
|
1456
1479
|
* the interface (typecheck 车 2026-07-24): the built-in `Session` class always implements it;
|
|
1457
1480
|
* optionality keeps external `Session` implementers compatible. The consumer (`maybeCompact`'s
|
|
@@ -92,6 +92,16 @@ export class NothingQueuedError extends AgentHarnessError {
|
|
|
92
92
|
}
|
|
93
93
|
export const ANNOUNCED_LANGUAGE_MAX_CHARS = 256;
|
|
94
94
|
export const REMINDER_MARK_MAX_CHARS = 64;
|
|
95
|
+
export function isRunLedgerRecord(v) {
|
|
96
|
+
if (v === null || typeof v !== "object" || Array.isArray(v))
|
|
97
|
+
return false;
|
|
98
|
+
const l = v;
|
|
99
|
+
const posInt = (x) => typeof x === "number" && Number.isSafeInteger(x) && x > 0;
|
|
100
|
+
const t = l["trigger"];
|
|
101
|
+
const kind = t !== null && typeof t === "object" ? t["kind"] : undefined;
|
|
102
|
+
const consistent = t === undefined || (typeof kind === "string" && (kind === "run_end") === l["final"]);
|
|
103
|
+
return posInt(l["v"]) && posInt(l["seq"]) && typeof l["final"] === "boolean" && Array.isArray(l["rows"]) && consistent;
|
|
104
|
+
}
|
|
95
105
|
export function normalizeReminderMark(v) {
|
|
96
106
|
if (typeof v !== "object" || v === null)
|
|
97
107
|
return undefined;
|
|
@@ -947,13 +947,11 @@ export type AssistantMessageEvent = {
|
|
|
947
947
|
partial: AssistantMessage;
|
|
948
948
|
}
|
|
949
949
|
/**
|
|
950
|
-
* design/124 tier B
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
* fresh snapshot that REPLACES the previous attempt's content — CC's "drop the thinking" semantics);
|
|
956
|
-
* a consumer keying blocks by index gets exactly the intended replacement.
|
|
950
|
+
* design/124 tier B: after a thinking-only mid-stream cut, the brain seals (`thinking_end`) and
|
|
951
|
+
* re-sends without a second `start`, reopening thinking at the same `contentIndex` (each retry
|
|
952
|
+
* carries a fresh `partial` snapshot replacing the previous attempt's thinking). For a turn whose
|
|
953
|
+
* reasoning is interleaved with text, a live event's `contentIndex` is the order of arrival and
|
|
954
|
+
* is not an index into the saved message's `content`.
|
|
957
955
|
*/
|
|
958
956
|
| {
|
|
959
957
|
type: "thinking_start";
|
|
@@ -743,6 +743,7 @@ export interface CompactionSummaryMessage {
|
|
|
743
743
|
tokensAfter?: number;
|
|
744
744
|
/** Optional first retained entry id from the compaction range. */
|
|
745
745
|
firstKeptEntryId?: string;
|
|
746
|
+
entryId?: string;
|
|
746
747
|
/** Optional implementation-specific compaction metadata. */
|
|
747
748
|
details?: unknown;
|
|
748
749
|
}
|
|
@@ -854,6 +855,7 @@ export interface AgentTool<TParameters extends TSchema = TSchema, TDetails = unk
|
|
|
854
855
|
* keyed by the folded-away spelling must stay inert rather than land on the other tool. Absent on non-MCP tools.
|
|
855
856
|
*/
|
|
856
857
|
mcpRemoteName?: string;
|
|
858
|
+
peerRegistration?: string;
|
|
857
859
|
/**
|
|
858
860
|
* The MCP server's own read-only declaration (`annotations.readOnlyHint === true` on its tools/list entry), set by
|
|
859
861
|
* the MCP materializer. It answers ONE question: whether the `plan` mode leaves the tool to run (the reference's
|
|
@@ -11,7 +11,7 @@ import { TransportLspSession } from "../../core/lsp-session.js";
|
|
|
11
11
|
import { StdioLspTransport } from "./stdio-lsp-transport.js";
|
|
12
12
|
import { MAX_LSP_FILE_BYTES, SharedAbortScope, settleOnAbort } from "../../core/lsp.js";
|
|
13
13
|
import { asThrownError, thrownText } from "../../core/thrown-value.js";
|
|
14
|
-
import { announceSecretEnvScrub, hostChildEnv, hostChildEnvProblem } from "../../core/secret-env.js";
|
|
14
|
+
import { announceSecretEnvScrub, hostChildEnv, hostChildEnvProblem, noteChildSpawned } from "../../core/secret-env.js";
|
|
15
15
|
export const DEFAULT_LSP_SERVERS = {
|
|
16
16
|
typescript: "typescript-language-server --stdio",
|
|
17
17
|
javascript: "typescript-language-server --stdio",
|
|
@@ -364,6 +364,7 @@ const lspSpawnWithEnv = (grant, onNotice) => (command, args, cwd, signal) => new
|
|
|
364
364
|
const { env, withheld } = hostChildEnv("scrub", grant);
|
|
365
365
|
announceSecretEnvScrub(onNotice, withheld);
|
|
366
366
|
child = spawn(command, args, { ...lspSpawnOptions(cwd), env });
|
|
367
|
+
noteChildSpawned("scrub");
|
|
367
368
|
}
|
|
368
369
|
catch (e) {
|
|
369
370
|
return reject(asThrownError(e));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SessionError, normalizeAnnouncedListing, normalizeReminderMark, normalizeGitAnnouncement, isSessionCheckoutStand, normalizeSessionCheckoutFact, normalizeSessionCheckoutStatement, normalizeWorkspaceState, normalizeCompactionStateCarrier, isValidThinkingLevelChange, isValidModelChange, isOptionalDisplayString, } from "../harness/types.js";
|
|
1
|
+
import { SessionError, normalizeAnnouncedListing, normalizeReminderMark, isRunLedgerRecord, normalizeGitAnnouncement, isSessionCheckoutStand, normalizeSessionCheckoutFact, normalizeSessionCheckoutStatement, normalizeWorkspaceState, normalizeCompactionStateCarrier, isValidThinkingLevelChange, isValidModelChange, isOptionalDisplayString, } from "../harness/types.js";
|
|
2
2
|
import { leafIdAfterEntry } from "./storage-base.js";
|
|
3
3
|
import { parseSessionTimestampMs } from "./timestamps.js";
|
|
4
4
|
import { flattenableUserText, normalizeEngineSegments } from "../../core/untrusted-text.js";
|
|
@@ -127,6 +127,11 @@ export class StreamingImportValidator {
|
|
|
127
127
|
throw new SessionError("invalid_session", `reminder_mark entry "${e.id}" is structurally invalid`);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
else if (e.type === "run_ledger") {
|
|
131
|
+
if (!isRunLedgerRecord(e.ledger)) {
|
|
132
|
+
throw new SessionError("invalid_session", `run_ledger entry "${e.id}" is structurally invalid`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
130
135
|
else if (e.type === "git_announcement") {
|
|
131
136
|
if (!normalizeGitAnnouncement(e)) {
|
|
132
137
|
throw new SessionError("invalid_session", `git_announcement entry "${e.id}" is structurally invalid`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ImageContent, TextContent } from "../llm/index.js";
|
|
2
2
|
import type { AgentMessage } from "../loop/types.js";
|
|
3
|
-
import type { AnnouncedListingSnapshot, AnnouncedListingSnapshotInput, GitAnnouncementState, Session, SessionCheckoutRecord, SessionCheckoutStand, SessionCheckoutStatement, SessionContext, SessionMetadata, SessionStorage, SessionTreeEntry, WorkspaceState } from "../harness/types.js";
|
|
3
|
+
import type { AnnouncedListingSnapshot, AnnouncedListingSnapshotInput, GitAnnouncementState, RunLedgerEntry, Session, SessionCheckoutRecord, SessionCheckoutStand, SessionCheckoutStatement, SessionContext, SessionMetadata, SessionStorage, SessionTreeEntry, WorkspaceState } from "../harness/types.js";
|
|
4
4
|
import type { BuildContextOptions } from "../harness/types.js";
|
|
5
5
|
import type { PromptEpochDescriptor, StoredPromptEpoch } from "../../prompt-assembly/epoch.js";
|
|
6
6
|
/** Which entry types the branch renders into the model's context — the one table, read twice: by the renderer below (a type
|
|
@@ -95,6 +95,14 @@ export declare class StoredSession<TMetadata extends SessionMetadata = SessionMe
|
|
|
95
95
|
* verify port on the value it is persisting.
|
|
96
96
|
*/
|
|
97
97
|
appendReminderMark(mark: string): Promise<string>;
|
|
98
|
+
/**
|
|
99
|
+
* Persist a run's member ledger snapshot (`TaskSpec.runLedger`) as a first-class {@link RunLedgerEntry} — written beside each
|
|
100
|
+
* delivery of the run's report tool and once at the run's end. The ledger is kept as plain data (a structured copy: nothing the
|
|
101
|
+
* caller holds afterwards can change what was written); a value that is not a ledger record refuses.
|
|
102
|
+
*/
|
|
103
|
+
appendRunLedger(ledger: RunLedgerEntry["ledger"]): Promise<string>;
|
|
104
|
+
/** The run-ledger entries on the ACTIVE branch, oldest first (malformed ones skipped) — what a reopened session replays. */
|
|
105
|
+
getRunLedgers(): Promise<RunLedgerEntry["ledger"][]>;
|
|
98
106
|
/**
|
|
99
107
|
* design/319: recover the session's reminder provenance mark for the ACTIVE branch — the nearest
|
|
100
108
|
* `reminder_mark` entry walking back from the leaf (SNAPSHOT semantics: first hit wins).
|
|
@@ -225,8 +233,13 @@ export type SessionCheckoutRead = {
|
|
|
225
233
|
* reads (a window cut along the branch alone does not load other branches: KNOWN-LIMITS KL-3468-b). Never
|
|
226
234
|
* best-effort: a store read that throws, an own entry or restatement that is not structurally valid, a restatement that says
|
|
227
235
|
* unreadable, two different allocations, or a release that names another allocation answers `unreadable`.
|
|
236
|
+
*
|
|
237
|
+
* A package-root export (#4898): a host reads with it whether a session has a checkout record before it releases or admits a leg.
|
|
238
|
+
* `sessionId` absent ⇒ the session row's own id (`getMetadata().id`), the id the release door reads — a row that cannot be read answers
|
|
239
|
+
* `unreadable`, never `none` (an explicit `sessionId` reads the log directly without reading metadata). Zero writes: no entry appended,
|
|
240
|
+
* no environment opened, no git run; every read or fold failure answers `unreadable` rather than rejecting.
|
|
228
241
|
*/
|
|
229
|
-
export declare function readSessionCheckout(session: Session, sessionId
|
|
242
|
+
export declare function readSessionCheckout(session: Session, sessionId?: string): Promise<SessionCheckoutRead>;
|
|
230
243
|
/** #3468: what a compaction restates of `sessionId`'s checkout — only a fact of the log later entries add to but never overturn: what the
|
|
231
244
|
* reader vouches for (no `window`: not the view's), and a `none` only where no declaration can follow (`closed`:
|
|
232
245
|
* {@link checkoutDeclarationClosed} as the compaction lands). Else nothing. */
|