@sema-agent/core 7.66.1 → 7.67.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 +3483 -0
- package/LICENSE +2 -1
- package/dist/agents/agent-definition.js +2 -1
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/agent-transcript-tool.js +4 -3
- package/dist/agents/builtin-agents.d.ts +10 -7
- package/dist/agents/builtin-agents.js +1 -0
- package/dist/agents/cascade.d.ts +24 -11
- package/dist/agents/cascade.js +21 -9
- package/dist/agents/child-failure.d.ts +30 -0
- package/dist/agents/child-failure.js +25 -1
- package/dist/agents/composition-placement.d.ts +6 -2
- package/dist/agents/composition-placement.js +7 -3
- package/dist/agents/cross-session-envelope.d.ts +10 -1
- package/dist/agents/cross-session-envelope.js +6 -2
- package/dist/agents/cross-session-judge.d.ts +7 -1
- package/dist/agents/cross-session-judge.js +1 -0
- package/dist/agents/cumulative-stats.d.ts +36 -2
- package/dist/agents/cumulative-stats.js +44 -9
- package/dist/agents/delegation-registry-seat.js +2 -3
- package/dist/agents/inherited-tool-pool.d.ts +9 -4
- package/dist/agents/inherited-tool-pool.js +7 -1
- package/dist/agents/leg-label.d.ts +28 -0
- package/dist/agents/leg-label.js +9 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/list-agents-tool.js +4 -4
- package/dist/agents/org-delivery-gate.d.ts +129 -23
- package/dist/agents/org-delivery-gate.js +41 -20
- package/dist/agents/peer-held-queue.d.ts +15 -10
- package/dist/agents/peer-held-queue.js +47 -19
- package/dist/agents/peer-notice-route.js +2 -2
- package/dist/agents/peer-notices.d.ts +13 -2
- package/dist/agents/peer-notices.js +12 -2
- package/dist/agents/peer-session-drain.d.ts +65 -15
- package/dist/agents/peer-session-drain.js +198 -41
- package/dist/agents/read-inbox-tool.d.ts +3 -2
- package/dist/agents/read-inbox-tool.js +7 -5
- package/dist/agents/repair-loop.js +20 -16
- package/dist/agents/retain-ledger.d.ts +1 -1
- package/dist/agents/retain-ledger.js +2 -4
- package/dist/agents/root-session-lane.d.ts +27 -0
- package/dist/agents/root-session-lane.js +57 -0
- package/dist/agents/roster-store.js +1 -2
- package/dist/agents/send-message-tool.js +6 -4
- package/dist/agents/subagent.d.ts +20 -4
- package/dist/agents/subagent.js +218 -183
- package/dist/agents/tool-filter.d.ts +3 -10
- package/dist/agents/tool-filter.js +0 -13
- package/dist/agents/verifier-independence.d.ts +31 -0
- package/dist/agents/verifier-independence.js +23 -0
- package/dist/agents/verify.d.ts +23 -11
- package/dist/agents/verify.js +28 -12
- package/dist/agents/yield-adoption.d.ts +24 -0
- package/dist/agents/yield-adoption.js +84 -0
- package/dist/bench/metrics.d.ts +2 -2
- package/dist/brain/anthropic.d.ts +4 -2
- package/dist/brain/anthropic.js +49 -35
- package/dist/brain/brain-faces.d.ts +11 -0
- package/dist/brain/brain-faces.js +6 -0
- package/dist/brain/cache-retention.d.ts +2 -0
- package/dist/brain/cache-retention.js +9 -0
- package/dist/brain/circuit-breaker.js +51 -26
- package/dist/brain/errors.d.ts +15 -1
- package/dist/brain/errors.js +8 -0
- package/dist/brain/failover.d.ts +6 -0
- package/dist/brain/failover.js +52 -37
- package/dist/brain/media-degrade.d.ts +5 -0
- package/dist/brain/media-degrade.js +4 -0
- package/dist/brain/model-capability.d.ts +2 -1
- package/dist/brain/model-lane.d.ts +145 -0
- package/dist/brain/model-lane.js +444 -0
- package/dist/brain/open-responses.js +19 -22
- package/dist/brain/openai.js +23 -22
- package/dist/brain/provider-message.d.ts +9 -0
- package/dist/brain/provider-message.js +18 -0
- package/dist/brain/reasoning-request.d.ts +9 -7
- package/dist/brain/reasoning-request.js +9 -10
- package/dist/brain/reasoning.d.ts +47 -13
- package/dist/brain/reasoning.js +20 -10
- package/dist/brain/route-adjudicator.d.ts +8 -2
- package/dist/brain/route-adjudicator.js +35 -1
- package/dist/brain/route-conformance.js +17 -0
- package/dist/brain/routing.d.ts +2 -0
- package/dist/brain/routing.js +19 -8
- package/dist/brain/status-sink.d.ts +5 -4
- package/dist/brain/status-sink.js +2 -2
- package/dist/brain/stream-engine.js +8 -2
- package/dist/brain/stream-shared.d.ts +12 -0
- package/dist/brain/stream-shared.js +18 -0
- package/dist/brain/timeout.d.ts +28 -0
- package/dist/brain/timeout.js +13 -4
- package/dist/brain/tool-schema-projection.d.ts +2 -0
- package/dist/brain/tool-schema-projection.js +108 -0
- package/dist/brain/usage-reading.d.ts +49 -0
- package/dist/brain/usage-reading.js +44 -0
- package/dist/brain/usage-reasoning.d.ts +38 -0
- package/dist/brain/usage-reasoning.js +9 -0
- package/dist/config/catalog.d.ts +3 -0
- package/dist/config/catalog.js +18 -9
- package/dist/core/a2a.d.ts +22 -4
- package/dist/core/a2a.js +191 -50
- package/dist/core/agent-definition.d.ts +3 -1
- package/dist/core/agent-state.d.ts +29 -16
- package/dist/core/agent-state.js +36 -9
- package/dist/core/allow-entry.d.ts +12 -3
- package/dist/core/allow-entry.js +10 -3
- package/dist/core/approval-display.d.ts +18 -0
- package/dist/core/approval-display.js +26 -0
- package/dist/core/approval-object.js +2 -2
- package/dist/core/approval-route.d.ts +16 -0
- package/dist/core/approval-route.js +5 -0
- package/dist/core/approval-words.d.ts +43 -0
- package/dist/core/approval-words.js +37 -0
- package/dist/core/ask-origin.d.ts +37 -10
- package/dist/core/ask-origin.js +19 -7
- package/dist/core/ask-question.d.ts +36 -8
- package/dist/core/ask-question.js +24 -9
- package/dist/core/ask-unresolvable-notice.d.ts +3 -2
- package/dist/core/ask-unresolvable-notice.js +3 -2
- package/dist/core/attachment-source.d.ts +50 -0
- package/dist/core/attachment-source.js +46 -0
- package/dist/core/auto-compaction.d.ts +151 -40
- package/dist/core/auto-compaction.js +115 -50
- package/dist/core/auto-mode.d.ts +5 -0
- package/dist/core/auto-mode.js +11 -4
- package/dist/core/background-agent-store.d.ts +151 -23
- package/dist/core/background-agent-store.js +201 -61
- package/dist/core/background-shell.d.ts +4 -1
- package/dist/core/background-shell.js +1 -0
- package/dist/core/cache-break-detector.d.ts +49 -25
- package/dist/core/cache-break-detector.js +99 -44
- package/dist/core/caller-text.d.ts +28 -0
- package/dist/core/caller-text.js +12 -0
- package/dist/core/canonical-json.d.ts +5 -0
- package/dist/core/canonical-json.js +7 -0
- package/dist/core/checkpoint-features.d.ts +80 -9
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-generation.d.ts +8 -1
- package/dist/core/checkpoint-generation.js +3 -0
- package/dist/core/checkpoint-queries.d.ts +47 -14
- package/dist/core/checkpoint-queries.js +63 -30
- package/dist/core/checkpoint-requirements.d.ts +36 -3
- package/dist/core/checkpoint-requirements.js +11 -1
- package/dist/core/checkpoint-row-verdict.d.ts +0 -2
- package/dist/core/checkpoint-row-verdict.js +5 -8
- package/dist/core/checkpoint-store.d.ts +166 -41
- package/dist/core/checkpoint-store.js +96 -15
- package/dist/core/child-clamp-seats.d.ts +10 -2
- package/dist/core/child-clamp-seats.js +2 -2
- package/dist/core/classifier-unavailable-arm.d.ts +11 -9
- package/dist/core/classifier-unavailable-arm.js +4 -2
- package/dist/core/command-sandbox-dispatch.d.ts +13 -0
- package/dist/core/command-sandbox-dispatch.js +8 -0
- package/dist/core/command-sandbox.d.ts +231 -0
- package/dist/core/command-sandbox.js +344 -0
- package/dist/core/completion-id.d.ts +21 -0
- package/dist/core/completion-id.js +14 -0
- package/dist/core/config-refusal-codes.d.ts +22 -0
- package/dist/core/config-refusal-codes.js +196 -0
- package/dist/core/context-edit.d.ts +26 -0
- package/dist/core/context-edit.js +4 -2
- package/dist/core/context-guard.d.ts +80 -7
- package/dist/core/context-guard.js +126 -25
- package/dist/core/context-settings.d.ts +32 -0
- package/dist/core/context-settings.js +41 -3
- package/dist/core/contract-faces.d.ts +22 -0
- package/dist/core/contract-faces.js +1 -0
- package/dist/core/credential-echo.d.ts +2 -2
- package/dist/core/credential-echo.js +2 -2
- package/dist/core/cross-boundary-taint.d.ts +10 -8
- package/dist/core/decision-receipt.d.ts +3 -2
- package/dist/core/decision-receipt.js +1 -1
- package/dist/core/definition-entry-grammar.d.ts +42 -0
- package/dist/core/definition-entry-grammar.js +15 -0
- package/dist/core/engine-attestation.d.ts +19 -4
- package/dist/core/engine-attestation.js +4 -0
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-contracts/open-face-contract.d.ts +39 -0
- package/dist/core/engine-contracts/open-face-contract.js +57 -0
- package/dist/core/engine-notice.d.ts +161 -33
- package/dist/core/exclusive-temp.d.ts +25 -0
- package/dist/core/exclusive-temp.js +19 -0
- package/dist/core/existing-target.d.ts +112 -0
- package/dist/core/existing-target.js +88 -0
- package/dist/core/file-history-store.d.ts +14 -6
- package/dist/core/gate-lanes.js +8 -3
- package/dist/core/gate-outcome.d.ts +2 -1
- package/dist/core/git-worktree-env.d.ts +92 -1
- package/dist/core/git-worktree-env.js +87 -6
- package/dist/core/governance-codes.d.ts +49 -8
- package/dist/core/governance-codes.js +59 -8
- package/dist/core/hands-band.d.ts +10 -6
- package/dist/core/hooks.d.ts +60 -6
- package/dist/core/hooks.js +10 -2
- package/dist/core/host-floor.d.ts +24 -8
- package/dist/core/host-floor.js +45 -16
- package/dist/core/human-input-projection.d.ts +7 -0
- package/dist/core/human-input-projection.js +11 -3
- package/dist/core/image-admission.d.ts +16 -4
- package/dist/core/image-admission.js +29 -17
- package/dist/core/input-author.d.ts +43 -1
- package/dist/core/input-author.js +19 -0
- package/dist/core/isolation-scope.d.ts +41 -0
- package/dist/core/isolation-scope.js +10 -0
- package/dist/core/json-schema-seats.d.ts +11 -0
- package/dist/core/json-schema-seats.js +5 -0
- package/dist/core/leg-identity.d.ts +53 -5
- package/dist/core/leg-identity.js +32 -1
- package/dist/core/locked-config.d.ts +33 -38
- package/dist/core/locked-config.js +21 -3
- package/dist/core/lsp.js +2 -1
- package/dist/core/mailbox-store.d.ts +111 -18
- package/dist/core/mailbox-store.js +101 -13
- package/dist/core/mcp-call-meta.js +1 -1
- package/dist/core/mcp-connection-pool.d.ts +8 -2
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +6 -1
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-host-read.d.ts +293 -0
- package/dist/core/mcp-host-read.js +428 -0
- package/dist/core/mcp-server-link.d.ts +28 -6
- package/dist/core/mcp-server-link.js +35 -7
- package/dist/core/mcp-server-spec.d.ts +22 -29
- package/dist/core/mcp-server-spec.js +7 -14
- package/dist/core/mcp-server-unavailable-notice.d.ts +32 -0
- package/dist/core/mcp-server-unavailable-notice.js +15 -0
- package/dist/core/mcp-session-end.d.ts +5 -2
- package/dist/core/mcp-session-end.js +7 -2
- package/dist/core/mcp-tool-meta.d.ts +6 -0
- package/dist/core/mcp-tool-meta.js +1 -0
- package/dist/core/mcp.d.ts +54 -19
- package/dist/core/mcp.js +194 -241
- package/dist/core/memory-engine/committed-shadow-read.d.ts +16 -0
- package/dist/core/memory-engine/committed-shadow-read.js +21 -0
- package/dist/core/memory-engine/consolidation-driver.js +2 -1
- package/dist/core/memory-engine/consolidation.d.ts +3 -3
- package/dist/core/memory-engine/control-objects.d.ts +4 -3
- package/dist/core/memory-engine/control-objects.js +6 -4
- package/dist/core/memory-engine/delegation-settlement.d.ts +127 -25
- package/dist/core/memory-engine/delegation-settlement.js +145 -18
- package/dist/core/memory-engine/distiller.d.ts +2 -1
- package/dist/core/memory-engine/distiller.js +10 -5
- package/dist/core/memory-engine/dual-root.js +2 -2
- package/dist/core/memory-engine/engine.d.ts +127 -33
- package/dist/core/memory-engine/engine.js +774 -323
- package/dist/core/memory-engine/entry-scan.d.ts +3 -0
- package/dist/core/memory-engine/entry-scan.js +8 -0
- package/dist/core/memory-engine/export-bundle.d.ts +4 -0
- package/dist/core/memory-engine/export-bundle.js +2 -0
- package/dist/core/memory-engine/file-backend.d.ts +62 -17
- package/dist/core/memory-engine/file-backend.js +155 -99
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layer-observations.d.ts +7 -1
- package/dist/core/memory-engine/layer-observations.js +6 -0
- package/dist/core/memory-engine/layout.d.ts +88 -26
- package/dist/core/memory-engine/layout.js +105 -29
- package/dist/core/memory-engine/memory-deployment.js +4 -4
- package/dist/core/memory-engine/mount-failed-notice.d.ts +24 -0
- package/dist/core/memory-engine/mount-failed-notice.js +22 -0
- package/dist/core/memory-engine/origin-clearance.d.ts +15 -1
- package/dist/core/memory-engine/origin-clearance.js +30 -10
- package/dist/core/memory-engine/scan.js +1 -1
- package/dist/core/memory-engine/scope-contract.js +4 -3
- package/dist/core/memory-engine/session-write-home.js +13 -1
- package/dist/core/memory-engine/sync-client.d.ts +1 -1
- package/dist/core/memory-engine/sync-client.js +3 -1
- package/dist/core/memory-engine/tools.d.ts +5 -4
- package/dist/core/memory-engine/tools.js +1 -1
- package/dist/core/memory-engine/types.d.ts +18 -1
- package/dist/core/memory-engine/types.js +1 -0
- package/dist/core/memory.d.ts +1 -1
- package/dist/core/memory.js +2 -6
- package/dist/core/mode-policy.d.ts +8 -1
- package/dist/core/mode-policy.js +6 -2
- package/dist/core/model-fallbacks.d.ts +103 -0
- package/dist/core/model-fallbacks.js +79 -0
- package/dist/core/model-receipt.d.ts +15 -3
- package/dist/core/model-receipt.js +22 -1
- package/dist/core/model-seat.d.ts +1 -1
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/dollar.d.ts +47 -2
- package/dist/core/mods/dollar.js +28 -5
- package/dist/core/mods/kernel/budget.d.ts +6 -0
- package/dist/core/mods/kernel/budget.js +6 -0
- package/dist/core/mods/kernel/dispatch.d.ts +23 -2
- package/dist/core/mods/kernel/dispatch.js +104 -15
- package/dist/core/mods/kernel/events.d.ts +18 -1
- package/dist/core/mods/kernel/events.js +7 -6
- package/dist/core/mods/kernel/index.d.ts +2 -2
- package/dist/core/mods/kernel/index.js +1 -1
- package/dist/core/mods/kernel/receive.d.ts +2 -1
- package/dist/core/mods/lifecycle-stations.d.ts +13 -4
- package/dist/core/mods/lifecycle-stations.js +8 -3
- package/dist/core/mods/message-display.d.ts +81 -0
- package/dist/core/mods/message-display.js +369 -0
- package/dist/core/mods/prompt-submit.d.ts +1 -1
- package/dist/core/mods/prompt-submit.js +5 -2
- package/dist/core/mods/session-append.d.ts +2 -2
- package/dist/core/mods/session-append.js +2 -1
- package/dist/core/mods/session-compact.js +2 -2
- package/dist/core/mods/stations.d.ts +48 -18
- package/dist/core/mods/stations.js +100 -19
- package/dist/core/mods/stop-answers.d.ts +23 -0
- package/dist/core/mods/stop-answers.js +20 -0
- package/dist/core/mounted-mcp.d.ts +48 -8
- package/dist/core/mounted-mcp.js +82 -16
- package/dist/core/namespaced-rule-name.js +2 -1
- package/dist/core/own-property-receipt.js +3 -5
- package/dist/core/parent-spec-seat.d.ts +20 -1
- package/dist/core/parent-spec-seat.js +13 -3
- package/dist/core/park-selfcheck.js +1 -0
- package/dist/core/path-identity.js +2 -1
- package/dist/core/peer-seat.d.ts +21 -7
- package/dist/core/peer-seat.js +25 -16
- package/dist/core/permission-rule-consent.js +15 -5
- package/dist/core/permission-rule-model.d.ts +4 -2
- package/dist/core/permission-rule-model.js +43 -23
- package/dist/core/permission-rule-store.d.ts +31 -16
- package/dist/core/permission-rule-store.js +27 -18
- package/dist/core/present-plan-tool.d.ts +6 -1
- package/dist/core/present-plan-tool.js +11 -3
- package/dist/core/pricing.d.ts +8 -6
- package/dist/core/pricing.js +1 -1
- package/dist/core/principal-name.d.ts +13 -0
- package/dist/core/principal-name.js +9 -2
- package/dist/core/process-identity.d.ts +140 -0
- package/dist/core/process-identity.js +215 -0
- package/dist/core/protocol-http-auth.d.ts +28 -6
- package/dist/core/protocol-http-auth.js +22 -5
- package/dist/core/protocol-naming.d.ts +7 -0
- package/dist/core/protocol-naming.js +12 -2
- package/dist/core/protocol-revocation.d.ts +72 -0
- package/dist/core/protocol-revocation.js +98 -0
- package/dist/core/protocol-table.d.ts +4 -4
- package/dist/core/protocol-table.js +3 -2
- package/dist/core/push-queue.d.ts +35 -2
- package/dist/core/push-queue.js +60 -4
- package/dist/core/read-only-shell.d.ts +19 -0
- package/dist/core/read-only-shell.js +38 -11
- package/dist/core/real-approval.d.ts +26 -0
- package/dist/core/real-approval.js +15 -0
- package/dist/core/redaction-marks.d.ts +6 -2
- package/dist/core/redaction-marks.js +3 -0
- package/dist/core/reminder-mint.d.ts +6 -0
- package/dist/core/reminder-mint.js +9 -8
- package/dist/core/remote-env.d.ts +31 -15
- package/dist/core/remote-env.js +29 -0
- package/dist/core/request-copy-projection.d.ts +51 -0
- package/dist/core/request-copy-projection.js +410 -0
- package/dist/core/resume-config-judge.d.ts +69 -0
- package/dist/core/resume-config-judge.js +78 -0
- package/dist/core/resume-startup-cause.d.ts +14 -4
- package/dist/core/resume-startup-cause.js +12 -2
- package/dist/core/retention-policy.js +2 -1
- package/dist/core/retention.d.ts +119 -24
- package/dist/core/retention.js +60 -16
- package/dist/core/retired-keys.d.ts +0 -10
- package/dist/core/retired-keys.js +2 -3
- package/dist/core/roles.d.ts +6 -0
- package/dist/core/roles.js +65 -4
- package/dist/core/row-shape.d.ts +149 -0
- package/dist/core/row-shape.js +184 -0
- package/dist/core/runner/advertised-writable-dirs.js +10 -9
- package/dist/core/runner/advisor-instructions.d.ts +11 -27
- package/dist/core/runner/advisor-instructions.js +18 -20
- package/dist/core/runner/advisor-tool.js +1 -0
- package/dist/core/runner/announce-once-ledger.js +4 -1
- package/dist/core/runner/approval-feedback.d.ts +17 -8
- package/dist/core/runner/approval-feedback.js +18 -13
- package/dist/core/runner/approver-defect-announcer.d.ts +17 -0
- package/dist/core/runner/approver-defect-announcer.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +29 -14
- package/dist/core/runner/assemble-result.js +16 -25
- package/dist/core/runner/cache-hit-account.d.ts +77 -0
- package/dist/core/runner/cache-hit-account.js +46 -0
- package/dist/core/runner/call-hook-stations.d.ts +3 -2
- package/dist/core/runner/call-hook-stations.js +5 -4
- package/dist/core/runner/changed-files-scan.d.ts +43 -0
- package/dist/core/runner/changed-files-scan.js +34 -0
- package/dist/core/runner/checkpoint-scope.d.ts +33 -9
- package/dist/core/runner/checkpoint-scope.js +27 -1
- package/dist/core/runner/classifier-ladder.d.ts +2 -2
- package/dist/core/runner/classifier-ladder.js +18 -9
- package/dist/core/runner/clock-and-limits.d.ts +15 -4
- package/dist/core/runner/clock-and-limits.js +19 -1
- package/dist/core/runner/compact-session.js +84 -14
- package/dist/core/runner/compaction-call-options.d.ts +2 -29
- package/dist/core/runner/compaction-call-options.js +2 -9
- package/dist/core/runner/compaction-restate.d.ts +18 -2
- package/dist/core/runner/compaction-restate.js +36 -2
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/context-room.d.ts +55 -0
- package/dist/core/runner/context-room.js +71 -0
- package/dist/core/runner/contracts.d.ts +313 -205
- package/dist/core/runner/conversation-segment.d.ts +49 -14
- package/dist/core/runner/conversation-segment.js +92 -19
- package/dist/core/runner/cross-boundary-lane.d.ts +4 -0
- package/dist/core/runner/cross-boundary-lane.js +9 -6
- package/dist/core/runner/decide-continuation.js +1 -1
- package/dist/core/runner/deferred-ask.d.ts +62 -0
- package/dist/core/runner/deferred-ask.js +44 -0
- package/dist/core/runner/delegation-owner.d.ts +19 -0
- package/dist/core/runner/delegation-owner.js +27 -1
- package/dist/core/runner/denial-limit-arms.d.ts +10 -6
- package/dist/core/runner/denial-limit-arms.js +13 -7
- package/dist/core/runner/env-capability-census.d.ts +1 -1
- package/dist/core/runner/file-history-request.js +2 -1
- package/dist/core/runner/file-history-restore.d.ts +16 -2
- package/dist/core/runner/file-history-restore.js +9 -1
- package/dist/core/runner/gate-exit.d.ts +18 -5
- package/dist/core/runner/gate-exit.js +26 -15
- package/dist/core/runner/git-status-frame.d.ts +26 -8
- package/dist/core/runner/git-status-frame.js +14 -9
- package/dist/core/runner/halt-attribution.d.ts +29 -12
- package/dist/core/runner/halt-attribution.js +38 -11
- package/dist/core/runner/image.js +3 -2
- package/dist/core/runner/initial-run-state.d.ts +1 -1
- package/dist/core/runner/initial-run-state.js +4 -4
- package/dist/core/runner/language-frame.d.ts +66 -0
- package/dist/core/runner/language-frame.js +76 -0
- package/dist/core/runner/leg-frame.d.ts +81 -0
- package/dist/core/runner/leg-frame.js +68 -0
- package/dist/core/runner/main-call-account.d.ts +34 -0
- package/dist/core/runner/main-call-account.js +50 -0
- package/dist/core/runner/mcp-redial.d.ts +9 -7
- package/dist/core/runner/mcp-redial.js +20 -21
- package/dist/core/runner/memory-consolidation-driver.d.ts +2 -0
- package/dist/core/runner/memory-consolidation-driver.js +5 -3
- package/dist/core/runner/messages-omitted-seat.d.ts +2 -0
- package/dist/core/runner/messages-omitted-seat.js +21 -0
- package/dist/core/runner/model-fallback-seat.d.ts +20 -0
- package/dist/core/runner/model-fallback-seat.js +43 -0
- package/dist/core/runner/model-lane-seat.d.ts +12 -0
- package/dist/core/runner/model-lane-seat.js +35 -0
- package/dist/core/runner/nested-memory-content.d.ts +33 -0
- package/dist/core/runner/nested-memory-content.js +171 -0
- package/dist/core/runner/nested-memory-lane.d.ts +181 -0
- package/dist/core/runner/nested-memory-lane.js +673 -0
- package/dist/core/runner/park-commit.d.ts +7 -0
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-advisor.d.ts +7 -9
- package/dist/core/runner/prepare-advisor.js +11 -5
- package/dist/core/runner/prepare-artifact.d.ts +1 -1
- package/dist/core/runner/prepare-artifact.js +8 -3
- package/dist/core/runner/prepare-ask-lane.d.ts +21 -3
- package/dist/core/runner/prepare-ask-lane.js +32 -28
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +21 -17
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +10 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +24 -18
- package/dist/core/runner/prepare-config-doors.d.ts +51 -5
- package/dist/core/runner/prepare-config-doors.js +73 -73
- package/dist/core/runner/prepare-context-lane.d.ts +68 -3
- package/dist/core/runner/prepare-context-lane.js +137 -27
- package/dist/core/runner/prepare-defer-classify.d.ts +0 -4
- package/dist/core/runner/prepare-defer-classify.js +9 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +8 -8
- package/dist/core/runner/prepare-delegation-surface.js +72 -64
- package/dist/core/runner/prepare-execution-env.js +1 -9
- package/dist/core/runner/prepare-file-history.d.ts +3 -2
- package/dist/core/runner/prepare-file-history.js +11 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +21 -11
- package/dist/core/runner/prepare-gate-stations.js +13 -13
- package/dist/core/runner/prepare-hands-readface.d.ts +23 -6
- package/dist/core/runner/prepare-hands-readface.js +18 -12
- package/dist/core/runner/prepare-inherited-gate.d.ts +12 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -10
- package/dist/core/runner/prepare-lsp.js +2 -1
- package/dist/core/runner/prepare-memory-engine-session.js +30 -10
- package/dist/core/runner/prepare-memory.d.ts +4 -0
- package/dist/core/runner/prepare-memory.js +38 -16
- package/dist/core/runner/prepare-offload-wrappers.d.ts +3 -16
- package/dist/core/runner/prepare-offload-wrappers.js +6 -5
- package/dist/core/runner/prepare-park-ask.d.ts +11 -3
- package/dist/core/runner/prepare-park-ask.js +23 -19
- package/dist/core/runner/prepare-policy-chain.d.ts +17 -3
- package/dist/core/runner/prepare-policy-chain.js +144 -120
- package/dist/core/runner/prepare-project-context.d.ts +15 -53
- package/dist/core/runner/prepare-project-context.js +20 -83
- package/dist/core/runner/prepare-prompt-assembly.d.ts +7 -1
- package/dist/core/runner/prepare-prompt-assembly.js +9 -7
- package/dist/core/runner/prepare-prompt-inputs.d.ts +9 -3
- package/dist/core/runner/prepare-prompt-inputs.js +5 -3
- package/dist/core/runner/prepare-protocol-tools.d.ts +9 -4
- package/dist/core/runner/prepare-protocol-tools.js +46 -27
- package/dist/core/runner/prepare-question-face.d.ts +6 -5
- package/dist/core/runner/prepare-question-face.js +7 -6
- package/dist/core/runner/prepare-suspend-saga.d.ts +3 -0
- package/dist/core/runner/prepare-suspend-saga.js +1 -1
- package/dist/core/runner/prepare-task.d.ts +3 -3
- package/dist/core/runner/prepare-task.js +113 -61
- package/dist/core/runner/prepare-tool-disclosure-mount.js +6 -5
- package/dist/core/runner/prepare-turn-wiring.d.ts +33 -7
- package/dist/core/runner/prepare-turn-wiring.js +53 -17
- package/dist/core/runner/prepare-wiring-manifest.d.ts +42 -5
- package/dist/core/runner/prepare-wiring-manifest.js +81 -42
- package/dist/core/runner/prepare-workspace-restore.js +3 -2
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/reply-pricing.d.ts +31 -18
- package/dist/core/runner/reply-pricing.js +10 -15
- package/dist/core/runner/resume-admission.js +10 -15
- package/dist/core/runner/resume-apply.js +20 -9
- package/dist/core/runner/resume-checkpoint-screen.js +2 -4
- package/dist/core/runner/resume-internals-and-config.d.ts +12 -9
- package/dist/core/runner/resume-internals-and-config.js +37 -9
- package/dist/core/runner/resume-preflight.js +3 -3
- package/dist/core/runner/retired-runner-deps.js +3 -0
- package/dist/core/runner/rewind-files.js +6 -6
- package/dist/core/runner/run-attachment-seats.d.ts +1 -3
- package/dist/core/runner/run-attachment-seats.js +1 -6
- package/dist/core/runner/run-brain-sinks.d.ts +4 -7
- package/dist/core/runner/run-brain-sinks.js +7 -10
- package/dist/core/runner/run-clock-and-content.d.ts +8 -5
- package/dist/core/runner/run-clock-and-content.js +18 -3
- package/dist/core/runner/run-compaction-machinery.d.ts +8 -4
- package/dist/core/runner/run-compaction-machinery.js +4 -19
- package/dist/core/runner/run-git-lane.d.ts +8 -3
- package/dist/core/runner/run-git-lane.js +5 -3
- package/dist/core/runner/run-harness-handlers.d.ts +4 -1
- package/dist/core/runner/run-harness-handlers.js +70 -45
- package/dist/core/runner/run-identity-wiring.d.ts +6 -0
- package/dist/core/runner/run-identity-wiring.js +17 -8
- package/dist/core/runner/run-leg.d.ts +5 -2
- package/dist/core/runner/run-leg.js +156 -71
- package/dist/core/runner/run-notification-lane.d.ts +1 -1
- package/dist/core/runner/run-notification-lane.js +22 -10
- package/dist/core/runner/run-recovery-lanes.js +8 -6
- package/dist/core/runner/run-settle-and-teardown.d.ts +4 -0
- package/dist/core/runner/run-settle-and-teardown.js +77 -26
- package/dist/core/runner/run-stop-and-final-verify.js +46 -12
- package/dist/core/runner/run-telemetry-and-budget-seats.js +13 -28
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -2
- package/dist/core/runner/run-terminal-adoption.js +14 -9
- package/dist/core/runner/run-tool-mount-facts.js +5 -9
- package/dist/core/runner/run-turn-boundary.d.ts +3 -2
- package/dist/core/runner/run-turn-boundary.js +112 -106
- package/dist/core/runner/runtask.d.ts +28 -8
- package/dist/core/runner/runtask.js +132 -41
- package/dist/core/runner/session-file-state-replay.d.ts +5 -3
- package/dist/core/runner/session-file-state-replay.js +10 -3
- package/dist/core/runner/session-rule-policy.d.ts +3 -3
- package/dist/core/runner/session-verb-doors.d.ts +18 -3
- package/dist/core/runner/session-verb-doors.js +38 -6
- package/dist/core/runner/shell-env-withheld.d.ts +8 -5
- package/dist/core/runner/shell-env-withheld.js +4 -4
- package/dist/core/runner/side-call-account.d.ts +12 -8
- package/dist/core/runner/side-call-account.js +24 -15
- package/dist/core/runner/stream-halt-verbs.js +1 -0
- package/dist/core/runner/stream-mode-verb.js +2 -1
- package/dist/core/runner/stream-settle-backstop.js +4 -1
- package/dist/core/runner/stream-steer-verb.js +35 -19
- package/dist/core/runner/sub-agent-deny-lists.d.ts +47 -11
- package/dist/core/runner/sub-agent-deny-lists.js +140 -39
- package/dist/core/runner/teardown-bounded.d.ts +6 -0
- package/dist/core/runner/teardown-bounded.js +12 -7
- package/dist/core/runner/terminal-account.d.ts +2 -0
- package/dist/core/runner/terminal-account.js +6 -1
- package/dist/core/runner/tool-disclosure.js +2 -1
- package/dist/core/runner/tool-end-body.js +3 -1
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +1 -1
- package/dist/core/runner/tool-occurrence.d.ts +34 -9
- package/dist/core/runner/tool-occurrence.js +32 -21
- package/dist/core/runner/tool-progress-lane.d.ts +20 -5
- package/dist/core/runner/tool-progress-lane.js +27 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +15 -4
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/tool-table-view.js +1 -1
- package/dist/core/runner/turn-attachments.d.ts +44 -71
- package/dist/core/runner/turn-attachments.js +52 -104
- package/dist/core/runner/usage-accounting.d.ts +3 -2
- package/dist/core/runner/usage-accounting.js +3 -2
- package/dist/core/runner/void-verifier-pause.js +1 -1
- package/dist/core/runner-deps.d.ts +42 -158
- package/dist/core/runtime-caps.d.ts +16 -4
- package/dist/core/secret-env.d.ts +20 -3
- package/dist/core/secret-env.js +46 -23
- package/dist/core/sensitive-path-policy.d.ts +8 -0
- package/dist/core/sensitive-path-policy.js +10 -2
- package/dist/core/session-checkout.d.ts +32 -27
- package/dist/core/session-checkout.js +109 -61
- package/dist/core/session-log-transfer.js +2 -1
- package/dist/core/session-policy-store.d.ts +24 -11
- package/dist/core/session-policy-store.js +11 -2
- package/dist/core/session-store.d.ts +16 -2
- package/dist/core/session-store.js +43 -17
- package/dist/core/session.d.ts +31 -3
- package/dist/core/session.js +33 -2
- package/dist/core/shell-run-candidates.d.ts +20 -8
- package/dist/core/shell-run-candidates.js +44 -21
- package/dist/core/side-query.d.ts +17 -5
- package/dist/core/side-query.js +17 -14
- package/dist/core/skill-grant.js +2 -3
- package/dist/core/skills-directory.js +3 -66
- package/dist/core/snapshot-frame-seat.d.ts +8 -0
- package/dist/core/snapshot-frame-seat.js +24 -0
- package/dist/core/steer-replay.d.ts +19 -3
- package/dist/core/steer-replay.js +8 -1
- package/dist/core/store-contracts/background-agent-store-contract.d.ts +17 -2
- package/dist/core/store-contracts/background-agent-store-contract.js +131 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +63 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +213 -3
- package/dist/core/store-contracts/permission-rule-write-contract.js +24 -0
- package/dist/core/store-contracts/session-deletion-cascade-contract.d.ts +15 -0
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +288 -0
- package/dist/core/store-contracts/session-policy-store-contract.js +57 -36
- package/dist/core/store-contracts/session-repo-contract.js +130 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/session-store-contract.js +17 -0
- package/dist/core/store-contracts/task-list-store-contract.d.ts +32 -0
- package/dist/core/store-contracts/task-list-store-contract.js +240 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +41 -0
- package/dist/core/stub-env.d.ts +2 -2
- package/dist/core/stub-env.js +1 -0
- package/dist/core/synthetic-read-verdict.d.ts +38 -28
- package/dist/core/synthetic-read-verdict.js +19 -28
- package/dist/core/task-event.d.ts +171 -19
- package/dist/core/task-intake.d.ts +26 -0
- package/dist/core/task-intake.js +31 -0
- package/dist/core/task-limits.d.ts +8 -6
- package/dist/core/task-notification.d.ts +88 -8
- package/dist/core/task-notification.js +45 -5
- package/dist/core/task-registry-agent.d.ts +24 -7
- package/dist/core/task-registry-agent.js +51 -28
- package/dist/core/task-registry-monitor.js +16 -14
- package/dist/core/task-registry-shared.d.ts +177 -35
- package/dist/core/task-registry-shared.js +44 -17
- package/dist/core/task-registry-workflow.js +8 -5
- package/dist/core/task-registry-yield.d.ts +32 -0
- package/dist/core/task-registry-yield.js +85 -0
- package/dist/core/task-registry.d.ts +88 -10
- package/dist/core/task-registry.js +124 -33
- package/dist/core/task-result.d.ts +115 -31
- package/dist/core/task-spec-members.d.ts +140 -1
- package/dist/core/task-spec-members.js +23 -8
- package/dist/core/task-spec.d.ts +181 -51
- package/dist/core/task-spec.js +1 -1
- package/dist/core/task-stream.d.ts +12 -2
- package/dist/core/terminal-cause.d.ts +12 -4
- package/dist/core/thrown-value.d.ts +49 -7
- package/dist/core/thrown-value.js +38 -2
- package/dist/core/tool-catalog-entries.js +13 -3
- package/dist/core/tool-data-door.d.ts +7 -0
- package/dist/core/tool-data-door.js +13 -0
- package/dist/core/tool-face-lists.d.ts +25 -0
- package/dist/core/tool-face-lists.js +38 -0
- package/dist/core/tool-face-reader.d.ts +0 -10
- package/dist/core/tool-face-reader.js +5 -3
- package/dist/core/tool-list-grammar.d.ts +103 -0
- package/dist/core/tool-list-grammar.js +130 -0
- package/dist/core/tool-mount-facts.d.ts +47 -0
- package/dist/core/tool-mount-facts.js +50 -0
- package/dist/core/tool-mount-plan.d.ts +196 -0
- package/dist/core/tool-mount-plan.js +404 -0
- package/dist/core/tool-mount-static.d.ts +12 -0
- package/dist/core/tool-mount-static.js +174 -0
- package/dist/core/tool-name-aliases.d.ts +60 -2
- package/dist/core/tool-name-aliases.js +22 -2
- package/dist/core/tool-name-list.d.ts +3 -0
- package/dist/core/tool-name-readings.d.ts +4 -0
- package/dist/core/tool-name-readings.js +1 -0
- package/dist/core/tool-policy.d.ts +246 -51
- package/dist/core/tool-policy.js +165 -71
- package/dist/core/tool-registry.d.ts +4 -11
- package/dist/core/tool-registry.js +0 -3
- package/dist/core/tool-result-bytes.d.ts +94 -0
- package/dist/core/tool-result-bytes.js +34 -0
- package/dist/core/tool-result-store.d.ts +97 -13
- package/dist/core/tool-result-store.js +52 -4
- package/dist/core/tool-roster.d.ts +71 -10
- package/dist/core/tool-roster.js +71 -21
- package/dist/core/tool-search-setting.d.ts +7 -9
- package/dist/core/tool-search-setting.js +23 -7
- package/dist/core/tool-spec.d.ts +32 -2
- package/dist/core/tools.js +6 -20
- package/dist/core/trace.d.ts +63 -11
- package/dist/core/trace.js +19 -0
- package/dist/core/types.d.ts +8 -6
- package/dist/core/types.js +3 -1
- package/dist/core/unmatched-tool-names.d.ts +37 -0
- package/dist/core/unmatched-tool-names.js +18 -0
- package/dist/core/untrusted-egress.d.ts +16 -5
- package/dist/core/untrusted-egress.js +202 -32
- package/dist/core/untrusted-text.d.ts +29 -8
- package/dist/core/untrusted-text.js +6 -3
- package/dist/core/user-attachment.d.ts +129 -35
- package/dist/core/user-attachment.js +124 -57
- package/dist/core/user-row-origin.d.ts +63 -0
- package/dist/core/user-row-origin.js +61 -0
- package/dist/core/wiring-manifest.d.ts +161 -39
- package/dist/core/wiring-manifest.js +42 -6
- package/dist/core/workflow-run-store-contract.d.ts +11 -1
- package/dist/core/workflow-run-store-contract.js +60 -7
- package/dist/core/workflow-run-store.d.ts +61 -12
- package/dist/core/workflow-run-store.js +100 -15
- package/dist/core/workspace-snapshot.d.ts +10 -14
- package/dist/core/workspace-snapshot.js +3 -22
- package/dist/core/write-protect.d.ts +3 -5
- package/dist/core/write-protect.js +2 -4
- package/dist/engine/compaction/compaction.d.ts +3 -0
- package/dist/engine/compaction/compaction.js +4 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +15 -4
- package/dist/engine/execution-env/node-execution-env.js +80 -27
- package/dist/engine/harness/agent-harness.d.ts +143 -27
- package/dist/engine/harness/agent-harness.js +162 -74
- package/dist/engine/harness/types.d.ts +84 -13
- package/dist/engine/harness/types.js +21 -1
- package/dist/engine/llm/tool-turns.d.ts +4 -0
- package/dist/engine/llm/tool-turns.js +7 -2
- package/dist/engine/llm/types.d.ts +111 -24
- package/dist/engine/llm/types.js +69 -5
- package/dist/engine/llm/validation.js +2 -1
- package/dist/engine/loop/agent-loop.d.ts +39 -6
- package/dist/engine/loop/agent-loop.js +172 -82
- package/dist/engine/loop/types.d.ts +43 -4
- package/dist/engine/lsp/node-lsp-manager.d.ts +5 -3
- package/dist/engine/lsp/node-lsp-manager.js +14 -10
- package/dist/engine/session/import-validate.js +9 -0
- package/dist/engine/session/memory-repo.d.ts +8 -1
- package/dist/engine/session/memory-repo.js +20 -12
- package/dist/engine/session/repo-utils.d.ts +10 -0
- package/dist/engine/session/repo-utils.js +11 -5
- package/dist/engine/session/row-cells.d.ts +32 -0
- package/dist/engine/session/row-cells.js +25 -0
- package/dist/index.d.ts +63 -34
- package/dist/index.js +44 -21
- package/dist/internal/harness.d.ts +8 -6
- package/dist/internal/harness.js +6 -4
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/governance-baseline-validity.d.ts +7 -0
- package/dist/orchestration/governance-baseline-validity.js +33 -9
- package/dist/orchestration/run-workflow-tool.d.ts +2 -0
- package/dist/orchestration/run-workflow-tool.js +25 -12
- package/dist/orchestration/workflow-governance.d.ts +19 -4
- package/dist/orchestration/workflow-governance.js +30 -9
- package/dist/orchestration/workflow-primitives.d.ts +4 -1
- package/dist/orchestration/workflow-primitives.js +2 -2
- package/dist/orchestration/workflow-script-runner.d.ts +1 -1
- package/dist/orchestration/workflow-size-guideline.d.ts +1 -1
- package/dist/orchestration/workflow-types.d.ts +21 -12
- package/dist/orchestration/workflow-types.js +15 -4
- package/dist/orchestration/workflow.d.ts +37 -7
- package/dist/orchestration/workflow.js +81 -35
- package/dist/prompt-assembly/artifact-store.js +6 -9
- package/dist/prompt-assembly/assemble.d.ts +4 -10
- package/dist/prompt-assembly/assemble.js +1 -3
- package/dist/prompt-assembly/catalog/constitution.d.ts +0 -20
- package/dist/prompt-assembly/catalog/constitution.js +2 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +5 -3
- package/dist/prompt-assembly/catalog/engine.d.ts +108 -0
- package/dist/prompt-assembly/catalog/engine.js +19 -0
- package/dist/prompt-assembly/catalog/environment.d.ts +276 -0
- package/dist/prompt-assembly/catalog/environment.js +61 -0
- package/dist/prompt-assembly/catalog/index.d.ts +9 -2
- package/dist/prompt-assembly/catalog/index.js +73 -2
- package/dist/prompt-assembly/catalog/locales/index.d.ts +16 -0
- package/dist/prompt-assembly/catalog/locales/index.js +22 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.js +124 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.d.ts +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +120 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.js +442 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +15 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +50 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.js +163 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/role.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/role.js +148 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/team.d.ts +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/team.js +246 -0
- package/dist/prompt-assembly/catalog/role.js +3 -6
- package/dist/prompt-assembly/catalog/schema.d.ts +23 -1
- package/dist/prompt-assembly/catalog/schema.js +2 -0
- package/dist/prompt-assembly/composer.d.ts +6 -11
- package/dist/prompt-assembly/composer.js +7 -7
- package/dist/prompt-assembly/engine-text.d.ts +9 -0
- package/dist/prompt-assembly/engine-text.js +33 -0
- package/dist/prompt-assembly/event-registry.js +3 -3
- package/dist/prompt-assembly/explain.d.ts +1 -0
- package/dist/prompt-assembly/explain.js +1 -1
- package/dist/prompt-assembly/locale-review.d.ts +13 -0
- package/dist/prompt-assembly/locale-review.js +19 -0
- package/dist/prompt-assembly/overlay.d.ts +7 -3
- package/dist/prompt-assembly/overlay.js +27 -5
- package/dist/prompt-assembly/renderers.d.ts +4 -4
- package/dist/prompt-assembly/renderers.js +26 -17
- package/dist/prompt-assembly/role-base.d.ts +1 -1
- package/dist/prompt-assembly/select.d.ts +26 -5
- package/dist/prompt-assembly/select.js +25 -2
- package/dist/prompt-assembly/slots.d.ts +19 -0
- package/dist/prompt-assembly/slots.js +16 -0
- package/dist/prompt-assembly/sugar.d.ts +4 -7
- package/dist/prompt-assembly/sugar.js +1 -2
- package/dist/prompt-assembly/tool-catalog.d.ts +5 -1
- package/dist/prompt-assembly/tool-catalog.js +5 -1
- package/dist/prompt-assembly/turn-snapshot.d.ts +38 -10
- package/dist/prompt-assembly/turn-snapshot.js +43 -13
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/cowork.d.ts +6 -25
- package/dist/prompts/cowork.js +10 -12
- package/dist/prompts/default.d.ts +10 -32
- package/dist/prompts/default.js +37 -63
- package/dist/shell/lex.d.ts +39 -13
- package/dist/shell/lex.js +70 -30
- package/dist/stores/file/background-agent-store.d.ts +5 -0
- package/dist/stores/file/background-agent-store.js +35 -61
- package/dist/stores/file/checkpoint-store.d.ts +5 -3
- package/dist/stores/file/checkpoint-store.js +8 -10
- package/dist/stores/file/fs-atomic.d.ts +27 -70
- package/dist/stores/file/fs-atomic.js +52 -148
- package/dist/stores/file/index.d.ts +12 -0
- package/dist/stores/file/index.js +27 -2
- package/dist/stores/file/mailbox-store.d.ts +10 -1
- package/dist/stores/file/mailbox-store.js +40 -12
- package/dist/stores/file/permission-rule-adopt.js +5 -2
- package/dist/stores/file/permission-rule-store.d.ts +81 -20
- package/dist/stores/file/permission-rule-store.js +126 -33
- package/dist/stores/file/session-policy-store.d.ts +2 -2
- package/dist/stores/file/session-store.d.ts +21 -2
- package/dist/stores/file/session-store.js +27 -14
- package/dist/stores/file/task-list-store.js +23 -25
- package/dist/stores/file/tool-result-store.d.ts +45 -7
- package/dist/stores/file/tool-result-store.js +99 -36
- package/dist/stores/file/workflow-run-store.d.ts +1 -0
- package/dist/stores/file/workflow-run-store.js +14 -11
- package/dist/tools/artifact/artifact-tool.js +2 -0
- package/dist/tools/artifact/local-stub.js +6 -6
- package/dist/tools/fs/bash-program-position.d.ts +1 -2
- package/dist/tools/fs/bash-readonly-classifier.d.ts +35 -0
- package/dist/tools/fs/bash-readonly-classifier.js +50 -12
- package/dist/tools/fs/env-error-detail.d.ts +1 -0
- package/dist/tools/fs/env-error-detail.js +7 -0
- package/dist/tools/fs/fs-bash.d.ts +24 -6
- package/dist/tools/fs/fs-bash.js +73 -25
- package/dist/tools/fs/fs-pdf.js +6 -4
- package/dist/tools/fs/fs-read.d.ts +76 -31
- package/dist/tools/fs/fs-read.js +159 -79
- package/dist/tools/fs/fs-search-tools.d.ts +1 -1
- package/dist/tools/fs/fs-search-tools.js +3 -1
- package/dist/tools/fs/fs-shared.d.ts +59 -63
- package/dist/tools/fs/fs-shared.js +31 -18
- package/dist/tools/fs/fs-write.d.ts +13 -0
- package/dist/tools/fs/fs-write.js +69 -13
- package/dist/tools/fs/index.d.ts +19 -1
- package/dist/tools/fs/index.js +10 -2
- package/dist/tools/fs/pdf.js +10 -9
- package/dist/tools/fs/read-deny.js +4 -10
- package/dist/tools/fs/read-floor.d.ts +5 -4
- package/dist/tools/fs/removal-targets.d.ts +11 -5
- package/dist/tools/fs/removal-targets.js +62 -32
- package/dist/tools/fs/safety.d.ts +26 -19
- package/dist/tools/fs/safety.js +13 -8
- package/dist/tools/fs/search.d.ts +1 -1
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-bindings.d.ts +128 -26
- package/dist/tools/fs/shell-read-bindings.js +667 -139
- package/dist/tools/fs/shell-read-check.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +4 -1
- package/dist/tools/fs/shell-read-judge.js +5 -1
- package/dist/tools/fs/shell-read-plan.d.ts +4 -0
- package/dist/tools/fs/shell-read-plan.js +21 -19
- package/dist/tools/fs/shell-read-sourced.d.ts +4 -3
- package/dist/tools/fs/shell-read-sourced.js +18 -1
- package/dist/tools/fs/shell-read-start.d.ts +6 -6
- package/dist/tools/fs/shell-read-start.js +1 -6
- package/dist/tools/fs/shell-read-word.d.ts +4 -2
- package/dist/tools/fs/shell-read-word.js +7 -6
- package/dist/tools/fs/shell-read-workdir.d.ts +1 -1
- package/dist/tools/fs/shell-reentry-text.d.ts +24 -9
- package/dist/tools/fs/shell-reentry-text.js +50 -20
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +14 -4
- package/dist/tools/scheduler-tools.d.ts +5 -2
- package/dist/tools/scheduler-tools.js +8 -6
- package/dist/tools/task-list.d.ts +49 -20
- package/dist/tools/task-list.js +115 -35
- package/dist/tools/web.d.ts +13 -3
- package/dist/tools/web.js +17 -6
- package/dist/tools/worktree.d.ts +3 -2
- package/dist/tools/worktree.js +24 -25
- package/package.json +10 -3
- package/test/export-surface.snapshot.json +330 -32
- package/wire-changes/core-stores-sql@7.67.0.json +39 -0
- package/wire-changes/core@7.67.0.json +12578 -0
- package/wire-changes/mods-kernel@7.67.0.json +167 -0
- package/wire-changes/primitives@7.67.0.json +325 -0
- package/wire-changes/wiki-gate@7.67.0.json +1636 -0
- package/dist/brain/degrading.d.ts +0 -93
- package/dist/brain/degrading.js +0 -189
- package/dist/core/tool-conformance.d.ts +0 -20
- package/dist/core/tool-conformance.js +0 -37
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
|
-
import { MAILBOX_CONSUMED_ID_WINDOW, MAILBOX_DUPLICATE_RECORD_ID_CODE, MAILBOX_INVALID_PEER_META_CODE, MAILBOX_INVALID_DECISION_MOVE_CODE, MAILBOX_INVALID_RECORD_ID_CODE, MAILBOX_TOMBSTONED_RECIPIENT_CODE, mailboxRecipientLifecycleOf } from "../mailbox-store.js";
|
|
2
|
+
import { MAILBOX_CONSUMED_ID_WINDOW, MAILBOX_DUPLICATE_RECORD_ID_CODE, MAILBOX_ROW_MALFORMED_CODE, MAILBOX_INVALID_PEER_META_CODE, MAILBOX_INVALID_DECISION_MOVE_CODE, MAILBOX_INVALID_LEASE_OWNER_CODE, MAILBOX_INVALID_RECORD_ID_CODE, MAILBOX_TOMBSTONED_RECIPIENT_CODE, mailboxRecipientLifecycleOf } from "../mailbox-store.js";
|
|
3
3
|
import { beginContract } from "./contract-harness.js";
|
|
4
4
|
import { thrownText } from "../thrown-value.js";
|
|
5
5
|
import { PRINCIPAL_INBOX_HANDLE } from "../../agents/cross-session-ref.js";
|
|
@@ -21,7 +21,10 @@ async function withStores(mk, fn) {
|
|
|
21
21
|
s.close?.();
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
export async function mailboxStoreContract(mk, runAssertion) {
|
|
24
|
+
export async function mailboxStoreContract(mk, runAssertion, hooks) {
|
|
25
|
+
if (hooks !== undefined && hooks.plantRow === undefined && (hooks.unplantable === undefined || hooks.unplantable.trim() === "")) {
|
|
26
|
+
throw new TypeError("mailboxStoreContract: pass plantRow, or declare unplantable with the reason this backend keeps no bytes a foreign writer could damage");
|
|
27
|
+
}
|
|
25
28
|
const { run: runRaw, settle } = beginContract(runAssertion);
|
|
26
29
|
const run = (name, fn) => runRaw(name, () => withStores(mk, fn));
|
|
27
30
|
const S = MAILBOX_CONTRACT_SCOPE;
|
|
@@ -163,6 +166,74 @@ export async function mailboxStoreContract(mk, runAssertion) {
|
|
|
163
166
|
assert.equal(await s.append(S, "a1", rec("Y0")), 2, "次旧的那条仍在窗内");
|
|
164
167
|
assert.equal(await s.append(S, "a1", rec("X")), K + 2, "第 K + 1 条进窗,X 出窗:新记录");
|
|
165
168
|
});
|
|
169
|
+
run("replayOf:append 会不会是重放的只读问 —— 持有集 / 已收窗命中 ⇒ 首个 seq,新记录 ⇒ undefined,异记录 ⇒ 带码拒;问不写、不造箱、不耗 seq,坏消息以 append 的码拒", async (make) => {
|
|
170
|
+
const s = make();
|
|
171
|
+
const codeOf = async (p) => {
|
|
172
|
+
try {
|
|
173
|
+
await p;
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
catch (e) {
|
|
177
|
+
return e.code;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const x = rec("X");
|
|
181
|
+
assert.equal(await s.replayOf(S, "a1", x), undefined, "空 / 未知的箱:新记录");
|
|
182
|
+
assert.equal(await s.peekCount(S, "a1"), 0, "问不写");
|
|
183
|
+
assert.equal(await s.append(S, "a1", x), 1, "问过的箱照常铸 seq 1(问没耗 seq)");
|
|
184
|
+
assert.equal(await s.replayOf(S, "a1", { ...x, sentAt: 9_000 }), 1, "持有集命中:sentAt 不是面");
|
|
185
|
+
assert.equal(await s.replayOf(S, "a2", x), undefined, "同 id 在别的箱 = 别的记录");
|
|
186
|
+
assert.equal(await s.replayOf(S, "a1", rec("Z")), undefined, "箱里没有这身份:新记录");
|
|
187
|
+
assert.equal(await s.replayOf(S, "a1", msg("no identity")), undefined, "没说身份 = 每次都是新记录");
|
|
188
|
+
for (const changed of [{ content: "another" }, { from: "x" }, { hopChain: [] }, { peerMeta: undefined }]) {
|
|
189
|
+
assert.equal(await codeOf(s.replayOf(S, "a1", { ...x, ...changed })), MAILBOX_DUPLICATE_RECORD_ID_CODE, JSON.stringify(changed));
|
|
190
|
+
}
|
|
191
|
+
for (const bad of ["", 7, null]) {
|
|
192
|
+
const raw = JSON.parse(JSON.stringify({ id: bad, content: "c", sentAt: 1 }));
|
|
193
|
+
assert.equal(await codeOf(s.replayOf(S, "a1", raw)), MAILBOX_INVALID_RECORD_ID_CODE, String(bad));
|
|
194
|
+
}
|
|
195
|
+
assert.equal(await s.peekCount(S, "a1"), 1, "被拒的问零副作用");
|
|
196
|
+
await consume(s, "a1", "w1");
|
|
197
|
+
assert.equal(await s.replayOf(S, "a1", x), 1, "ack 之后进已收窗:仍答首个 seq");
|
|
198
|
+
assert.equal(await codeOf(s.replayOf(S, "a1", rec("X", "another body"))), MAILBOX_DUPLICATE_RECORD_ID_CODE, "窗内异记录同样带码拒");
|
|
199
|
+
assert.equal(await s.peekCount(S, "a1"), 0);
|
|
200
|
+
assert.equal(await s.append(S, "a1", x), 1, "append 与 replayOf 同一答案");
|
|
201
|
+
assert.equal(await s.append(S, "a1", msg("next")), 2, "问与重放都没耗 seq");
|
|
202
|
+
await s.drop(S, "a1");
|
|
203
|
+
assert.equal(await s.replayOf(S, "a1", x), undefined, "drop 清窗:问也看不见了");
|
|
204
|
+
});
|
|
205
|
+
run("replayOf 判箱键与 append 是同一只判官:同一 (scope, handle),两者要么都拒(同码)要么都受;受的键上不存在的箱答 undefined(问不拒、不造箱)", async (make) => {
|
|
206
|
+
const verdictOf = async (p) => {
|
|
207
|
+
try {
|
|
208
|
+
await p;
|
|
209
|
+
return "accepted";
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
const code = e.code;
|
|
213
|
+
return `refused:${typeof code === "string" ? code : "uncoded"}`;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const keys = [
|
|
217
|
+
["", "a1"],
|
|
218
|
+
[S, ""],
|
|
219
|
+
[S, "a\u0000b"],
|
|
220
|
+
["a\u0000b", "a1"],
|
|
221
|
+
[S, "."],
|
|
222
|
+
[S, ".."],
|
|
223
|
+
[S, "a/b"],
|
|
224
|
+
[S, "a b"],
|
|
225
|
+
["../x", "a1"],
|
|
226
|
+
[S, "nope"],
|
|
227
|
+
];
|
|
228
|
+
const x = rec("X");
|
|
229
|
+
for (const [scope, handle] of keys) {
|
|
230
|
+
const asked = await verdictOf(make().replayOf(scope, handle, x));
|
|
231
|
+
const written = await verdictOf(make().append(scope, handle, x));
|
|
232
|
+
assert.equal(asked, written, `replayOf 与 append 对 ${JSON.stringify([scope, handle])} 同判`);
|
|
233
|
+
if (written === "accepted")
|
|
234
|
+
assert.equal(await make().replayOf(scope, handle, x), undefined, `${JSON.stringify([scope, handle])} 是一把键:不存在的箱 ⇒ 新记录`);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
166
237
|
run("lease 窗内 append:后到消息在下次 claim 时可见(lease 只覆盖 claim 时刻快照)", async (make) => {
|
|
167
238
|
const s = make();
|
|
168
239
|
await s.append(S, "a1", msg("m1"));
|
|
@@ -338,12 +409,121 @@ export async function mailboxStoreContract(mk, runAssertion) {
|
|
|
338
409
|
]) {
|
|
339
410
|
assert.equal(await codeOf(s.moveDecision(S, "a1", seq, expect, next)), MAILBOX_INVALID_DECISION_MOVE_CODE, label);
|
|
340
411
|
}
|
|
412
|
+
for (const bad of [42, null, {}, ["w"]]) {
|
|
413
|
+
assert.equal(await codeOf(s.moveDecision(S, "a1", 1, undefined, "held", bad)), MAILBOX_INVALID_DECISION_MOVE_CODE, `holder ${JSON.stringify(bad)}`);
|
|
414
|
+
}
|
|
341
415
|
const snap = await s.claimLease(S, "a1", "w", 60_000, 10_000);
|
|
342
416
|
assert.equal(snap.messages[0].decision, undefined, "被拒的调用零副作用");
|
|
343
417
|
for (const [from, to] of [[undefined, "held"], ["held", "approved"], ["approved", "delivered"], ["delivered", "dropped"]]) {
|
|
344
|
-
assert.deepEqual(await s.moveDecision(S, "a1", 1, from, to), { ok: true }, `${String(from)} → ${to}`);
|
|
418
|
+
assert.deepEqual(await s.moveDecision(S, "a1", 1, from, to, "w"), { ok: true }, `${String(from)} → ${to}`);
|
|
345
419
|
}
|
|
346
420
|
});
|
|
421
|
+
run("#3694 / #3709 持租者名只有一种拼写:非空白、不超过 256 个字符、无控制字符、无格式字符(零宽 / 方向覆盖) —— claimLease 的 owner 与 moveDecision 的 holder 同读一只判官,先于任何副作用被拒(带各自的码)", async (make) => {
|
|
422
|
+
const s = make();
|
|
423
|
+
await s.append(S, "a1", msg("m1"));
|
|
424
|
+
const codeOf = async (p) => {
|
|
425
|
+
try {
|
|
426
|
+
await p;
|
|
427
|
+
return undefined;
|
|
428
|
+
}
|
|
429
|
+
catch (e) {
|
|
430
|
+
return e.code;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
const BAD = ["", " ", "\t\n", "w\n1", "w\u0007", "w\u0000", "\u0085", 42, null, {}, "n".repeat(257), "w\u200b1", "w\u202e1"];
|
|
434
|
+
for (const bad of BAD) {
|
|
435
|
+
assert.equal(await codeOf(s.claimLease(S, "a1", bad, 60_000, 10_000)), MAILBOX_INVALID_LEASE_OWNER_CODE, `owner ${JSON.stringify(bad)}`);
|
|
436
|
+
assert.equal(await codeOf(s.moveDecision(S, "a1", 1, undefined, "held", bad)), MAILBOX_INVALID_DECISION_MOVE_CODE, `holder ${JSON.stringify(bad)}`);
|
|
437
|
+
}
|
|
438
|
+
const snap = await s.claimLease(S, "a1", "w", 60_000, 10_000);
|
|
439
|
+
assert.ok(snap, "被拒的认领没有占住这个箱");
|
|
440
|
+
assert.equal(snap.messages.length, 1);
|
|
441
|
+
assert.equal(snap.messages[0].decision, undefined, "被拒的移动零副作用");
|
|
442
|
+
assert.ok(await s.claimLease(S, "a1", "w", 60_000, 20_000), "同一持租者重认领");
|
|
443
|
+
await s.append(S, "a2", msg("m2"));
|
|
444
|
+
assert.ok(await s.claimLease(S, "a2", "worker 7 · 甲", 60_000, 10_000), "带空格 / 标点 / 中文的名字是一个名字");
|
|
445
|
+
await s.append(S, "a4", msg("m4"));
|
|
446
|
+
assert.ok(await s.claimLease(S, "a4", "n".repeat(256), 60_000, 10_000), "恰好 256 个字符的名字是一个名字");
|
|
447
|
+
await s.append(S, "a3", msg("m3"));
|
|
448
|
+
assert.ok(await s.claimLease(S, "a3", "A", 60_000, 10_000));
|
|
449
|
+
for (const [from, to] of [[undefined, "held"], ["held", "approved"], ["approved", "delivered"]]) {
|
|
450
|
+
assert.deepEqual(await s.moveDecision(S, "a3", 1, from, to, "A"), { ok: true }, `A: ${String(from)} → ${to}`);
|
|
451
|
+
}
|
|
452
|
+
assert.equal(await codeOf(s.moveDecision(S, "a3", 1, "delivered", "dropped", "")), MAILBOX_INVALID_DECISION_MOVE_CODE, "空 holder 是被拒的调用,不是被围栏的调用");
|
|
453
|
+
assert.deepEqual(await s.moveDecision(S, "a3", 1, "delivered", "dropped", "A"), { ok: true }, "真持租者照常结清");
|
|
454
|
+
});
|
|
455
|
+
run("#2774 交出之后的出口只归持租者:delivered → dropped 与 ack 同一只租约围栏、与记录状态同一步判;前任持租者的迟到结清被拒", async (make) => {
|
|
456
|
+
const s = make();
|
|
457
|
+
await s.append(S, "a1", msg("m1"));
|
|
458
|
+
assert.ok(await s.claimLease(S, "a1", "A", 1_000, 10_000), "A 持租");
|
|
459
|
+
for (const [from, to] of [[undefined, "held"], ["held", "approved"], ["approved", "delivered"]]) {
|
|
460
|
+
assert.deepEqual(await s.moveDecision(S, "a1", 1, from, to, "A"), { ok: true }, `A: ${String(from)} → ${to}`);
|
|
461
|
+
}
|
|
462
|
+
const taken = await s.claimLease(S, "a1", "B", 60_000, 20_000);
|
|
463
|
+
assert.deepEqual(taken.messages.map((m) => m.decision), ["delivered"], "B 的快照里记录是 delivered");
|
|
464
|
+
assert.deepEqual(await s.moveDecision(S, "a1", 1, "delivered", "dropped", "A"), { ok: false, current: "delivered" }, "前任持租者(A)的结清被拒,记录不动");
|
|
465
|
+
assert.deepEqual(await s.moveDecision(S, "a1", 1, "delivered", "dropped"), { ok: false, current: "delivered" }, "不报持租者的一方结清不了");
|
|
466
|
+
assert.deepEqual(await s.moveDecision(S, "a1", 1, "delivered", "dropped", "nobody"), { ok: false, current: "delivered" }, "不持租的名字结清不了");
|
|
467
|
+
const still = await s.claimLease(S, "a1", "B", 60_000, 21_000);
|
|
468
|
+
assert.deepEqual(still.messages.map((m) => m.decision), ["delivered"], "被拒的结清零副作用");
|
|
469
|
+
assert.deepEqual(await s.moveDecision(S, "a1", 1, "delivered", "dropped", "B"), { ok: true }, "当前持租者(B)结清");
|
|
470
|
+
await s.append(S, "a2", msg("m2"));
|
|
471
|
+
assert.ok(await s.claimLease(S, "a2", "C", 1_000, 30_000));
|
|
472
|
+
await s.moveDecision(S, "a2", 1, undefined, "held", "C");
|
|
473
|
+
await s.moveDecision(S, "a2", 1, "held", "delivered", "C");
|
|
474
|
+
await s.append(S, "a3", msg("m3"));
|
|
475
|
+
assert.ok(await s.claimLease(S, "a3", "D", 60_000, 30_000));
|
|
476
|
+
await s.moveDecision(S, "a3", 1, undefined, "held", "D");
|
|
477
|
+
await s.moveDecision(S, "a3", 1, "held", "delivered", "D");
|
|
478
|
+
await s.releaseLease(S, "a3", "D");
|
|
479
|
+
assert.deepEqual(await s.moveDecision(S, "a3", 1, "delivered", "dropped", "D"), { ok: false, current: "delivered" }, "交还了租约的一方不再持有");
|
|
480
|
+
assert.deepEqual(await s.moveDecision(S, "a2", 1, "delivered", "dropped", "C"), { ok: true }, "过期未被接手的租约仍是 C 的");
|
|
481
|
+
});
|
|
482
|
+
run("#2774 人的决定不问租约:另一方持租时,不持租 / 报了别的名字的一方照样落 approve 与 deny", async (make) => {
|
|
483
|
+
const s = make();
|
|
484
|
+
await s.append(S, "a1", msg("m1"));
|
|
485
|
+
await s.append(S, "a1", msg("m2"));
|
|
486
|
+
assert.ok(await s.claimLease(S, "a1", "holder", 60_000, 10_000));
|
|
487
|
+
await s.moveDecision(S, "a1", 1, undefined, "held", "holder");
|
|
488
|
+
await s.moveDecision(S, "a1", 2, undefined, "held", "holder");
|
|
489
|
+
assert.deepEqual(await s.moveDecision(S, "a1", 1, "held", "approved"), { ok: true }, "不报持租者的 approve");
|
|
490
|
+
assert.deepEqual(await s.moveDecision(S, "a1", 2, "held", "denied", "someone-else"), { ok: true }, "报了别的名字的 deny(名字在这条边上不读)");
|
|
491
|
+
assert.deepEqual(await s.moveDecision(S, "a1", 1, "approved", "refused", "someone-else"), { ok: true }, "approved 的终局同样不问租约");
|
|
492
|
+
const snap = await s.claimLease(S, "a1", "holder", 60_000, 11_000);
|
|
493
|
+
assert.deepEqual(snap.messages.map((m) => [m.seq, m.decision]), [[1, "refused"], [2, "denied"]]);
|
|
494
|
+
});
|
|
495
|
+
const plantRow = hooks?.plantRow;
|
|
496
|
+
if (plantRow !== undefined) {
|
|
497
|
+
const SENTINEL = "planted-marker-1023";
|
|
498
|
+
const parked = (seq) => ({ seq, id: `r${seq}`, content: `message ${seq}`, sentAt: 100 + seq });
|
|
499
|
+
const damaged = [
|
|
500
|
+
["content retyped", { seq: 2, id: "r2", content: 7, sentAt: 102, from: SENTINEL }],
|
|
501
|
+
["hopChain not a list", { seq: 2, id: "r2", content: SENTINEL, sentAt: 102, hopChain: 42 }],
|
|
502
|
+
["sentAt missing", { seq: 2, id: "r2", content: SENTINEL }],
|
|
503
|
+
];
|
|
504
|
+
const codeOf = (e) => (typeof e === "object" && e !== null ? Reflect.get(e, "code") : undefined);
|
|
505
|
+
const refused = (e) => codeOf(e) === MAILBOX_ROW_MALFORMED_CODE && !thrownText(e).includes(SENTINEL);
|
|
506
|
+
for (const [what, bad] of damaged) {
|
|
507
|
+
run(`damaged record (${what}): delivery stops in front of it — the record before it is leased and acknowledged; nothing at or past it is leased, acknowledged, counted or moved (refused in the family code, quoting nothing planted); its id is not taken in as received`, async (make) => {
|
|
508
|
+
const s = await plantRow(make(), { scope: S, handle: "a1" }, [parked(1), bad, parked(3)]);
|
|
509
|
+
try {
|
|
510
|
+
const lease = await s.claimLease(S, "a1", "owner-1", 60_000, 1_000);
|
|
511
|
+
assert.deepEqual(lease?.messages.map((m) => m.seq), [1], "the record before it is leased, nothing at or past it");
|
|
512
|
+
assert.equal(await s.peekCount(S, "a1"), 1, "the count is the readable prefix");
|
|
513
|
+
await assert.rejects(s.ack(S, "a1", "owner-1", 3), refused, "an ack past it is refused");
|
|
514
|
+
assert.equal(await s.peekCount(S, "a1"), 1, "and nothing was consumed");
|
|
515
|
+
assert.deepEqual(await s.ack(S, "a1", "owner-1", 1), { acked: true });
|
|
516
|
+
assert.equal(await s.peekCount(S, "a1"), 0);
|
|
517
|
+
assert.equal(await s.claimLease(S, "a1", "owner-1", 60_000, 2_000), null, "the box stops in front of it");
|
|
518
|
+
await assert.rejects(s.moveDecision(S, "a1", 2, undefined, "held"), refused, "a decision move on it is refused");
|
|
519
|
+
await assert.rejects(s.append(S, "a1", { id: "r2", content: "message 2", sentAt: 102 }), (e) => codeOf(e) === MAILBOX_DUPLICATE_RECORD_ID_CODE && thrownText(e).includes("already holds"), "its id is still held — never answered as received");
|
|
520
|
+
}
|
|
521
|
+
finally {
|
|
522
|
+
s.close?.();
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
347
527
|
await settle();
|
|
348
528
|
}
|
|
349
529
|
export async function mailboxAckOwnershipContract(mk, runAssertion) {
|
|
@@ -486,6 +666,18 @@ export async function mailboxCrossProcessContract(hooks) {
|
|
|
486
666
|
const takeover = await local.claimLease(S, H, "cycle-local-2", 60_000, 30_000);
|
|
487
667
|
assert.deepEqual(takeover.messages.map((m) => m.seq), [3, 4], "过期租约的接管跨进程成立,seq 原样");
|
|
488
668
|
});
|
|
669
|
+
run("#2774 交出之后的出口跨进程只归持租者:本方交出后租约过期、对方进程接手,本方迟到的 delivered → dropped 被拒;对方的结清本方看得见", async (local, peer) => {
|
|
670
|
+
await local.append(S, H, msg("m1", 1));
|
|
671
|
+
assert.ok(await local.claimLease(S, H, "cycle-local", 1_000, 10_000));
|
|
672
|
+
assert.deepEqual(await local.moveDecision(S, H, 1, undefined, "held", "cycle-local"), { ok: true });
|
|
673
|
+
assert.deepEqual(await local.moveDecision(S, H, 1, "held", "delivered", "cycle-local"), { ok: true });
|
|
674
|
+
const taken = await peer.claimLease(S, H, "cycle-peer", 60_000, 20_000);
|
|
675
|
+
assert.deepEqual(taken.messages.map((m) => m.decision), ["delivered"], "对方接手时看到 delivered");
|
|
676
|
+
assert.deepEqual(await local.moveDecision(S, H, 1, "delivered", "dropped", "cycle-local"), { ok: false, current: "delivered" }, "对方进程写下的租约必须在本方的这一步里被读到");
|
|
677
|
+
assert.deepEqual(await peer.moveDecision(S, H, 1, "delivered", "dropped", "cycle-peer"), { ok: true }, "当前持租者结清");
|
|
678
|
+
const seen = await local.claimLease(S, H, "cycle-local-2", 60_000, 90_000);
|
|
679
|
+
assert.deepEqual(seen.messages.map((m) => m.decision), ["dropped"], "对方的结清本方看得见");
|
|
680
|
+
});
|
|
489
681
|
run("一方的 housekeeping 不丢另一方的 append:两进程各自反复压缩/重写期间交错写入 120 条,任一方视角都完整", async (local, peer) => {
|
|
490
682
|
const N = 60;
|
|
491
683
|
for (let i = 0; i < N; i++) {
|
|
@@ -526,6 +718,24 @@ export async function mailboxCrossProcessContract(hooks) {
|
|
|
526
718
|
}
|
|
527
719
|
assert.equal(code, MAILBOX_DUPLICATE_RECORD_ID_CODE);
|
|
528
720
|
});
|
|
721
|
+
run("replayOf 跨进程:一方 append(未收)与 append + ack(已收窗)的带 id 记录,另一方的 replayOf 都答首个 seq、零写;异记录 ⇒ 带码拒;未知记录 ⇒ undefined", async (local, peer) => {
|
|
722
|
+
const mk = (id, content = "status") => ({ id, from: "w", content, sentAt: 1_000, hopChain: ["h"], peerMeta: { kind: "peer_message", fromRoot: "root" } });
|
|
723
|
+
assert.equal(await local.append(S, H, mk("held-x")), 1);
|
|
724
|
+
assert.equal(await peer.replayOf(S, H, { ...mk("held-x"), sentAt: 5_000 }), 1, "对方进程看得见本方持有的记录");
|
|
725
|
+
const lease = await local.claimLease(S, H, "cycle-local", 60_000, 10_000);
|
|
726
|
+
assert.deepEqual(await local.ack(S, H, "cycle-local", lease.maxSeq), { acked: true });
|
|
727
|
+
assert.equal(await peer.replayOf(S, H, mk("held-x")), 1, "对方进程看得见本方收进窗的记录");
|
|
728
|
+
assert.equal(await peer.replayOf(S, H, mk("never-seen")), undefined);
|
|
729
|
+
assert.equal(await peer.peekCount(S, H), 0, "零写");
|
|
730
|
+
let code;
|
|
731
|
+
try {
|
|
732
|
+
await peer.replayOf(S, H, mk("held-x", "another"));
|
|
733
|
+
}
|
|
734
|
+
catch (e) {
|
|
735
|
+
code = e.code;
|
|
736
|
+
}
|
|
737
|
+
assert.equal(code, MAILBOX_DUPLICATE_RECORD_ID_CODE);
|
|
738
|
+
});
|
|
529
739
|
run("reap 与 drop 的 seq 语义跨进程:一方 reap 后另一方继续高水位;一方 drop 后另一方从 1 重铸", async (local, peer) => {
|
|
530
740
|
await peer.append(S, H, msg("old", 1_000));
|
|
531
741
|
assert.equal(await local.reap(S, 100_000, { maxAgeMs: 50_000 }), 1, "本方 reap 必须看见对方写的旧消息");
|
|
@@ -61,6 +61,30 @@ export async function permissionRuleWriteContract(hooks) {
|
|
|
61
61
|
assert.ok(tomb !== undefined, "the raw face must retain the tombstone a landed delete wrote");
|
|
62
62
|
assert.deepEqual({ behavior: tomb.behavior, rule: tomb.rule, scope: tomb.scope, removedDots: tomb.removedDots }, { behavior: IDENTITY.behavior, rule: IDENTITY.rule, scope: GLOBAL, removedDots: [a1.dot] }, "the retained tombstone must be the WHOLE one — a partial one identifies nothing");
|
|
63
63
|
});
|
|
64
|
+
run("a tombstone names a row that is already there and does not judge its scope; an add still must be a row the store can read back", async () => {
|
|
65
|
+
const malformed = { kind: "project", root: "relative/root" };
|
|
66
|
+
const part = await hooks.make();
|
|
67
|
+
const writer = part[PERMISSION_RULE_WRITER];
|
|
68
|
+
const held = (await part.list()).rev;
|
|
69
|
+
const gone = add("kit", 5);
|
|
70
|
+
const tomb = { ...tombstoneFor([gone], { actor: "kit", counter: 6 }), scope: malformed };
|
|
71
|
+
const landed = await writer.apply({ kind: "tighten-delete", tombstone: tomb }, { expectedRev: held });
|
|
72
|
+
assert.ok(!("conflict" in landed) && !("refused" in landed), "a tombstone naming a malformed durable scope must land — the row it removes is the row the read face dropped");
|
|
73
|
+
assertRevision(landed, "the malformed-scope tombstone landing");
|
|
74
|
+
const retained = (await part.list()).tombstones.find((t) => t.deletedBy.actor === "kit" && t.deletedBy.counter === 6);
|
|
75
|
+
assert.ok(retained !== undefined, "the store must retain the tombstone it landed");
|
|
76
|
+
assert.deepEqual(retained.scope, malformed, "the retained tombstone keeps the scope it named — that scope is the identity it matches by");
|
|
77
|
+
const rawBefore = await rawShape(part);
|
|
78
|
+
let threw = false;
|
|
79
|
+
try {
|
|
80
|
+
await writer.apply({ kind: "tighten-add", ...IDENTITY, scope: malformed, add: add("kit", 7) }, { expectedRev: (await part.list()).rev });
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
threw = true;
|
|
84
|
+
}
|
|
85
|
+
assert.equal(threw, true, "an add under a scope that is not a well-formed durable scope must be refused LOUDLY — a row the store cannot read back is never written");
|
|
86
|
+
assert.equal(await rawShape(part), rawBefore, "a refused add must move nothing — rows, tombstones or revision");
|
|
87
|
+
});
|
|
64
88
|
run("a delta whose kind is outside the union is REFUSED — not folded as the arm it resembles", async () => {
|
|
65
89
|
for (const [label, payload] of [
|
|
66
90
|
["① a legal tombstone under an unnamed kind", { kind: "tighten-purge", tombstone: tombstoneFor([add("kit", 1)], { actor: "kit", counter: 9 }) }],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RetentionCascadeStores } from "../retention.js";
|
|
2
|
+
import { type ContractAssertionRunner } from "./contract-harness.js";
|
|
3
|
+
/** The binding a host writes: given a set of stores, the call that deletes one session through them (`owner` is the session row's). */
|
|
4
|
+
type SessionDeletionCascadeCoordinator = (stores: RetentionCascadeStores) => (target: {
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
readonly owner: string | null;
|
|
7
|
+
readonly scope: string;
|
|
8
|
+
}) => Promise<unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* The full contract for a session-deletion coordinator against {@link RETENTION_CASCADE}. Every case drives its own fresh recording
|
|
11
|
+
* stores over its own scene, so a runner may interleave the cases; with no runner each case starts in order and the first failure
|
|
12
|
+
* rejects the call.
|
|
13
|
+
*/
|
|
14
|
+
export declare function sessionDeletionCascadeContract(coordinator: SessionDeletionCascadeCoordinator, runAssertion?: ContractAssertionRunner): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { strict as assert } from "node:assert";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { peerSessionBoxHandle } from "../../agents/peer-directory.js";
|
|
4
|
+
import { RETENTION_CASCADE, RETENTION_SESSION_TREE_STEPS } from "../retention.js";
|
|
5
|
+
import { beginContract } from "./contract-harness.js";
|
|
6
|
+
const endOf = (call) => call.end ?? Number.POSITIVE_INFINITY;
|
|
7
|
+
const lastEnd = (calls) => Math.max(...calls.map(endOf));
|
|
8
|
+
const firstStart = (calls) => Math.min(...calls.map((call) => call.start));
|
|
9
|
+
const HEALTHY = { adopt: "ok" };
|
|
10
|
+
function freshScene() {
|
|
11
|
+
const id = (what) => `kit-cascade-${what}-${randomUUID()}`;
|
|
12
|
+
return {
|
|
13
|
+
sessionId: id("session"),
|
|
14
|
+
owner: "kit-owner",
|
|
15
|
+
scope: "kit-scope",
|
|
16
|
+
fork: id("fork"),
|
|
17
|
+
other: id("other"),
|
|
18
|
+
run: id("run"),
|
|
19
|
+
otherRun: id("other-run"),
|
|
20
|
+
agent: id("agent"),
|
|
21
|
+
rosterAgent: id("roster-agent"),
|
|
22
|
+
otherRosterAgent: id("other-roster-agent"),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const READS = {
|
|
26
|
+
workflowRunStore: ["listByScope"],
|
|
27
|
+
backgroundAgentStore: ["listBySession"],
|
|
28
|
+
rosterStore: ["list"],
|
|
29
|
+
sessionStore: ["list", "headOf"],
|
|
30
|
+
};
|
|
31
|
+
const FENCE_PARTNERS = { retireRecipient: ["listRetiredRecipients"] };
|
|
32
|
+
function filtered(rows, opts, sessionOf) {
|
|
33
|
+
const query = typeof opts === "object" && opts !== null ? opts : {};
|
|
34
|
+
const kept = rows.filter((row) => (query.status === undefined || row.status === query.status) && (query.session === undefined || sessionOf === undefined || sessionOf(row) === query.session));
|
|
35
|
+
return typeof query.limit === "number" ? kept.slice(0, query.limit) : kept;
|
|
36
|
+
}
|
|
37
|
+
function answer(call, scene, variant) {
|
|
38
|
+
const { seat, verb, args } = call;
|
|
39
|
+
if (variant.failing === `${seat}.${verb}`)
|
|
40
|
+
throw new Error(`kit: ${seat}.${verb} fails in this case`);
|
|
41
|
+
switch (`${seat}.${verb}`) {
|
|
42
|
+
case "workflowRunStore.listByScope": {
|
|
43
|
+
const runs = [
|
|
44
|
+
{ id: scene.run, scope: scene.scope, originatingSessionId: scene.sessionId, status: "completed", phaseCount: 1, createdAt: 2 },
|
|
45
|
+
{ id: scene.otherRun, scope: scene.scope, originatingSessionId: scene.other, status: "completed", phaseCount: 1, createdAt: 1 },
|
|
46
|
+
];
|
|
47
|
+
return filtered(runs, args[1], (run) => run.originatingSessionId);
|
|
48
|
+
}
|
|
49
|
+
case "workflowRunStore.deleteBySession":
|
|
50
|
+
return args[0] === scene.sessionId ? [scene.run] : [];
|
|
51
|
+
case "workflowJournalStore.deleteRun":
|
|
52
|
+
case "backgroundAgentStore.delete":
|
|
53
|
+
case "mailboxStore.retireRecipient":
|
|
54
|
+
case "sessionStore.delete":
|
|
55
|
+
return true;
|
|
56
|
+
case "backgroundAgentStore.listBySession":
|
|
57
|
+
return args[1] === scene.sessionId
|
|
58
|
+
? filtered([{ handle: scene.agent, owner: scene.owner, sessionScoped: false, parentSessionId: scene.sessionId, rootSessionId: scene.sessionId, name: "kit-agent", status: "completed", spawnedAt: 1, updatedAt: 2, settledAt: 2, rev: 1 }], args[2])
|
|
59
|
+
: [];
|
|
60
|
+
case "mailboxStore.listRetiredRecipients":
|
|
61
|
+
return [];
|
|
62
|
+
case "rosterStore.list":
|
|
63
|
+
return [
|
|
64
|
+
{ name: "kit-agent", agentId: scene.rosterAgent, sessionId: scene.sessionId, createdAt: 1 },
|
|
65
|
+
{ name: "kit-other", agentId: scene.otherRosterAgent, sessionId: scene.other, createdAt: 1 },
|
|
66
|
+
];
|
|
67
|
+
case "checkpointStore.deleteSessionCheckpoints":
|
|
68
|
+
case "fileHistoryStore.deleteBySession":
|
|
69
|
+
return 1;
|
|
70
|
+
case "toolResultStore.deleteBySession":
|
|
71
|
+
return { deleted: 1, unattributable: 0 };
|
|
72
|
+
case "fileHistoryStore.adoptScope":
|
|
73
|
+
if (variant.adopt === "throws")
|
|
74
|
+
throw new Error("kit: the file-history carry throws in this case");
|
|
75
|
+
if (variant.adopt === "ok")
|
|
76
|
+
return { ok: true };
|
|
77
|
+
return { ok: false, error: { code: variant.adopt === "conflict" ? "conflict" : "adopt_failed", message: `kit: the carry answers ${variant.adopt}` } };
|
|
78
|
+
case "sessionStore.list": {
|
|
79
|
+
const after = args[0]?.after;
|
|
80
|
+
if (after !== undefined)
|
|
81
|
+
return [];
|
|
82
|
+
return [
|
|
83
|
+
{ sessionId: scene.fork, lastActiveAt: 3, forkedFrom: scene.sessionId },
|
|
84
|
+
{ sessionId: scene.sessionId, lastActiveAt: 2 },
|
|
85
|
+
{ sessionId: scene.other, lastActiveAt: 1 },
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
case "sessionStore.headOf":
|
|
89
|
+
return [scene.sessionId, scene.fork, scene.other].includes(String(args[0])) ? { owner: scene.owner, incarnation: undefined, leafId: null } : undefined;
|
|
90
|
+
default:
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function recorder(seat, verb, journal, clock, scene, variant) {
|
|
95
|
+
return async (...args) => {
|
|
96
|
+
const call = { seat, verb, args, start: ++clock.ticks, end: undefined };
|
|
97
|
+
journal.push(call);
|
|
98
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
99
|
+
try {
|
|
100
|
+
return answer(call, scene, variant);
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
call.end = ++clock.ticks;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function exemptSeat(seat, journal, clock) {
|
|
108
|
+
return new Proxy({}, {
|
|
109
|
+
get: (_target, key) => typeof key !== "string" || key === "then" || key === "retention"
|
|
110
|
+
? undefined
|
|
111
|
+
: (...args) => void journal.push({ seat, verb: key, args, start: ++clock.ticks, end: ++clock.ticks }),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function storeRowOf(seat) {
|
|
115
|
+
return RETENTION_CASCADE[seat];
|
|
116
|
+
}
|
|
117
|
+
const SEATS = Object.entries(RETENTION_CASCADE).flatMap(([key, row]) => ("heldBy" in row ? [] : [key]));
|
|
118
|
+
function recordingStores(journal, clock, scene, variant) {
|
|
119
|
+
const entries = SEATS.map((seat) => {
|
|
120
|
+
const row = storeRowOf(seat);
|
|
121
|
+
if ("exempt" in row)
|
|
122
|
+
return [seat, exemptSeat(seat, journal, clock)];
|
|
123
|
+
const verbs = new Set(READS[seat] ?? []);
|
|
124
|
+
for (const leg of RETENTION_SESSION_TREE_STEPS) {
|
|
125
|
+
if (leg.store !== seat)
|
|
126
|
+
continue;
|
|
127
|
+
verbs.add(leg.verb);
|
|
128
|
+
if (leg.fence !== undefined && variant.withoutFence !== true)
|
|
129
|
+
for (const v of [leg.fence, ...(FENCE_PARTNERS[leg.fence] ?? [])])
|
|
130
|
+
verbs.add(v);
|
|
131
|
+
}
|
|
132
|
+
const members = Object.fromEntries([...verbs].map((verb) => [verb, recorder(seat, verb, journal, clock, scene, variant)]));
|
|
133
|
+
return [seat, Object.assign({}, members)];
|
|
134
|
+
});
|
|
135
|
+
return Object.assign({}, Object.fromEntries(entries));
|
|
136
|
+
}
|
|
137
|
+
function labelsOf(legs) {
|
|
138
|
+
const seen = new Map();
|
|
139
|
+
return legs.map((leg) => {
|
|
140
|
+
const key = `${leg.store}.${leg.verb}`;
|
|
141
|
+
const n = seen.get(key) ?? 0;
|
|
142
|
+
seen.set(key, n + 1);
|
|
143
|
+
return `${key}#${n}`;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function names(value, key) {
|
|
147
|
+
if (typeof value === "string")
|
|
148
|
+
return value === key;
|
|
149
|
+
if (Array.isArray(value))
|
|
150
|
+
return value.some((v) => names(v, key));
|
|
151
|
+
if (typeof value === "object" && value !== null)
|
|
152
|
+
return Object.values(value).some((v) => names(v, key));
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
const ownerOf = (guard) => (typeof guard === "object" && guard !== null ? guard.owner : undefined);
|
|
156
|
+
function legReadings(scene) {
|
|
157
|
+
const s = scene.sessionId;
|
|
158
|
+
const box = peerSessionBoxHandle(s);
|
|
159
|
+
return {
|
|
160
|
+
"workflowJournalStore.deleteRun#0": (c) => c.args[0] === scene.run && c.args[1] === scene.scope,
|
|
161
|
+
"workflowRunStore.deleteBySession#0": (c) => c.args[0] === s && c.args[1] === scene.scope,
|
|
162
|
+
"mailboxStore.drop#0": (c) => c.args[0] === scene.scope && c.args[1] === scene.agent,
|
|
163
|
+
"backgroundAgentStore.delete#0": (c) => c.args[0] === scene.agent && c.args[1] === scene.scope,
|
|
164
|
+
"rosterStore.releaseAgent#0": (c) => c.args[0] === scene.rosterAgent,
|
|
165
|
+
"checkpointStore.deleteSessionCheckpoints#0": (c) => c.args[0] === s && ownerOf(c.args[1]) === scene.owner,
|
|
166
|
+
"toolResultStore.deleteBySession#0": (c) => c.args[0] === s,
|
|
167
|
+
"sessionPolicyStore.deleteBySession#0": (c) => c.args[0] === s,
|
|
168
|
+
"fileHistoryStore.adoptScope#0": (c) => c.args[0] === s && c.args[1] === scene.fork,
|
|
169
|
+
"fileHistoryStore.deleteBySession#0": (c) => c.args[0] === s,
|
|
170
|
+
"mailboxStore.drop#1": (c) => c.args[0] === scene.scope && c.args[1] === box,
|
|
171
|
+
"sessionStore.delete#0": (c) => c.args[0] === s && ownerOf(c.args[1]) === scene.owner,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function legCalls(journal, scene) {
|
|
175
|
+
const readings = legReadings(scene);
|
|
176
|
+
const labels = labelsOf(RETENTION_SESSION_TREE_STEPS);
|
|
177
|
+
return RETENTION_SESSION_TREE_STEPS.map((leg, i) => {
|
|
178
|
+
const label = labels[i];
|
|
179
|
+
const reads = readings[label];
|
|
180
|
+
assert.ok(reads !== undefined, `the kit has no reading of the table's session-tree leg ${label} (step ${leg.step}) — the kit is older than the table`);
|
|
181
|
+
const at = journal.flatMap((call, k) => (call.seat === leg.store && call.verb === leg.verb && reads(call) ? [k] : []));
|
|
182
|
+
return { label, leg, at, calls: at.map((k) => journal[k]) };
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function fenceCalls(journal) {
|
|
186
|
+
return RETENTION_SESSION_TREE_STEPS.flatMap((leg) => (leg.fence === undefined ? [] : journal.filter((call) => call.seat === leg.store && call.verb === leg.fence)));
|
|
187
|
+
}
|
|
188
|
+
async function drive(coordinator, variant, scene = freshScene()) {
|
|
189
|
+
const journal = [];
|
|
190
|
+
const del = coordinator(recordingStores(journal, { ticks: 0 }, scene, variant));
|
|
191
|
+
try {
|
|
192
|
+
await del({ sessionId: scene.sessionId, owner: scene.owner, scope: scene.scope });
|
|
193
|
+
return { journal, scene, rejected: undefined, ok: true };
|
|
194
|
+
}
|
|
195
|
+
catch (rejected) {
|
|
196
|
+
return { journal, scene, rejected, ok: false };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const describeJournal = (journal) => journal.map((c, k) => `${k}:${c.seat}.${c.verb}@${c.start}-${c.end ?? "open"}`).join(", ");
|
|
200
|
+
export async function sessionDeletionCascadeContract(coordinator, runAssertion) {
|
|
201
|
+
const { run, settle } = beginContract(runAssertion);
|
|
202
|
+
const destructive = new Set(RETENTION_SESSION_TREE_STEPS.flatMap((leg) => [`${leg.store}.${leg.verb}`, ...(leg.fence === undefined ? [] : [`${leg.store}.${leg.fence}`])]));
|
|
203
|
+
run("every session-tree leg of the table is called, with the keys the leg selects", async () => {
|
|
204
|
+
const { journal, scene, rejected, ok } = await drive(coordinator, HEALTHY);
|
|
205
|
+
assert.ok(ok, `the deletion rejected over healthy stores: ${String(rejected)}`);
|
|
206
|
+
for (const { label, leg, at } of legCalls(journal, scene)) {
|
|
207
|
+
assert.ok(at.length > 0, `leg ${label} (step ${leg.step}: ${leg.selects}) was never called — calls: ${describeJournal(journal)}`);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
run("every fence settles before the first step, each leg settles before the next begins, and the session row's leg is last — with the carry answering `ok` and `conflict`", async () => {
|
|
211
|
+
for (const carryAnswer of ["ok", "conflict"]) {
|
|
212
|
+
const { journal, scene, rejected, ok } = await drive(coordinator, { adopt: carryAnswer });
|
|
213
|
+
assert.ok(ok, `the deletion rejected when the carry answered ${carryAnswer}: ${String(rejected)}`);
|
|
214
|
+
const legs = legCalls(journal, scene);
|
|
215
|
+
const first = firstStart(legs.flatMap((l) => l.calls));
|
|
216
|
+
const fences = fenceCalls(journal);
|
|
217
|
+
const fenced = RETENTION_SESSION_TREE_STEPS.filter((leg) => leg.fence !== undefined);
|
|
218
|
+
assert.ok(fenced.length === 0 || fences.length > 0, `a store carrying the fence ${fenced.map((l) => `${l.store}.${l.fence}`).join(", ")} was never fenced — calls: ${describeJournal(journal)}`);
|
|
219
|
+
for (const fence of fences) {
|
|
220
|
+
assert.ok(endOf(fence) < first, `the fence ${fence.seat}.${fence.verb} had not settled when the first step began at tick ${first} (carry answering ${carryAnswer}) — calls: ${describeJournal(journal)}`);
|
|
221
|
+
assert.ok(fence.args[0] === scene.scope && fence.args[1] === peerSessionBoxHandle(scene.sessionId), `the fence ${fence.seat}.${fence.verb} names another box than the session's`);
|
|
222
|
+
}
|
|
223
|
+
for (let i = 1; i < legs.length; i++) {
|
|
224
|
+
const before = legs[i - 1];
|
|
225
|
+
const after = legs[i];
|
|
226
|
+
assert.ok(lastEnd(before.calls) < firstStart(after.calls), `leg ${before.label} (step ${before.leg.step}) had a call open after leg ${after.label} (step ${after.leg.step}) began (carry answering ${carryAnswer}) — calls: ${describeJournal(journal)}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
run("an exempt store seat receives no call, and no destructive call names another session's rows or the fork beyond its carry", async () => {
|
|
231
|
+
const { journal, scene, rejected, ok } = await drive(coordinator, HEALTHY);
|
|
232
|
+
assert.ok(ok, `the deletion rejected over healthy stores: ${String(rejected)}`);
|
|
233
|
+
for (const call of journal) {
|
|
234
|
+
const row = storeRowOf(call.seat);
|
|
235
|
+
assert.ok("legs" in row, `${call.seat} is exempt (${"exempt" in row ? row.exempt : ""}) and received ${call.verb}`);
|
|
236
|
+
if (!destructive.has(`${call.seat}.${call.verb}`))
|
|
237
|
+
continue;
|
|
238
|
+
for (const key of [scene.other, scene.otherRun, scene.otherRosterAgent]) {
|
|
239
|
+
assert.ok(!names(call.args, key), `${call.seat}.${call.verb} named another session's row ${key}`);
|
|
240
|
+
}
|
|
241
|
+
const carry = call.seat === "fileHistoryStore" && call.verb === "adoptScope" && call.args[1] === scene.fork && !names(call.args[0], scene.fork);
|
|
242
|
+
assert.ok(carry || !names(call.args, scene.fork), `${call.seat}.${call.verb} named the fork ${scene.fork} — a fork is named only as the file-history carry's target`);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
run("the session's file history is carried into its fork before it is deleted; a carry refused `conflict` counts as done", async () => {
|
|
246
|
+
for (const adopt of ["ok", "conflict"]) {
|
|
247
|
+
const { journal, scene, rejected, ok } = await drive(coordinator, { adopt });
|
|
248
|
+
assert.ok(ok, `the deletion rejected when the carry answered ${adopt}: ${String(rejected)}`);
|
|
249
|
+
const legs = legCalls(journal, scene);
|
|
250
|
+
const carried = legs.find((l) => l.leg.store === "fileHistoryStore" && l.leg.verb === "adoptScope");
|
|
251
|
+
const erased = legs.find((l) => l.leg.store === "fileHistoryStore" && l.leg.verb === "deleteBySession");
|
|
252
|
+
const row = legs.find((l) => l.leg.store === "sessionStore" && l.leg.verb === "delete");
|
|
253
|
+
assert.ok(carried !== undefined && carried.at.length > 0, `the session's history was never carried into its fork (carry answering ${adopt}) — calls: ${describeJournal(journal)}`);
|
|
254
|
+
assert.ok(erased !== undefined && erased.calls.length > 0 && lastEnd(carried.calls) < firstStart(erased.calls), `the session's history was not deleted after its carry settled (carry answering ${adopt}) — calls: ${describeJournal(journal)}`);
|
|
255
|
+
assert.ok(row !== undefined && row.at.length > 0, `the session row was not deleted when the carry answered ${adopt} — calls: ${describeJournal(journal)}`);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
run("a carry that fails any other way leaves the session's history and its row in place", async () => {
|
|
259
|
+
for (const adopt of ["failed", "throws"]) {
|
|
260
|
+
const { journal, scene } = await drive(coordinator, { adopt });
|
|
261
|
+
const left = journal.filter((c) => (c.seat === "fileHistoryStore" && c.verb === "deleteBySession" && c.args[0] === scene.sessionId) || (c.seat === "sessionStore" && c.verb === "delete" && c.args[0] === scene.sessionId));
|
|
262
|
+
assert.equal(left.length, 0, `the carry ${adopt === "failed" ? "answered a failure" : "threw"} and the session's ${left.map((c) => `${c.seat}.${c.verb}`).join(" and ")} still ran — calls: ${describeJournal(journal)}`);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
run("every call the coordinator makes, made to fail, leaves the session row — with the carry answering `ok` and `conflict` — and a repeat over healthy stores completes the cascade", async () => {
|
|
266
|
+
for (const adopt of ["ok", "conflict"]) {
|
|
267
|
+
const healthy = await drive(coordinator, { adopt });
|
|
268
|
+
assert.ok(healthy.ok, `the deletion rejected when the carry answered ${adopt}: ${String(healthy.rejected)}`);
|
|
269
|
+
const points = [...new Set(healthy.journal.map((c) => `${c.seat}.${c.verb}`))].filter((p) => p !== "sessionStore.delete");
|
|
270
|
+
for (const failing of points) {
|
|
271
|
+
const failed = await drive(coordinator, { adopt, failing }, healthy.scene);
|
|
272
|
+
const rowDeletes = failed.journal.filter((c) => c.seat === "sessionStore" && c.verb === "delete").length;
|
|
273
|
+
assert.ok(rowDeletes === 0, `${failing} failed (carry answering ${adopt}) and the session row was still deleted — calls: ${describeJournal(failed.journal)}`);
|
|
274
|
+
}
|
|
275
|
+
const repeat = await drive(coordinator, { adopt }, healthy.scene);
|
|
276
|
+
assert.ok(repeat.ok, `the repeat over healthy stores rejected (carry answering ${adopt}): ${String(repeat.rejected)}`);
|
|
277
|
+
for (const { label, at } of legCalls(repeat.journal, repeat.scene))
|
|
278
|
+
assert.ok(at.length > 0, `the repeat never called leg ${label} — calls: ${describeJournal(repeat.journal)}`);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
run("a mailbox without the recipient-lifecycle pair still has the session's box dropped", async () => {
|
|
282
|
+
const { journal, scene, rejected, ok } = await drive(coordinator, { adopt: "ok", withoutFence: true });
|
|
283
|
+
assert.ok(ok, `the deletion rejected over a mailbox without the pair: ${String(rejected)}`);
|
|
284
|
+
for (const { label, at } of legCalls(journal, scene))
|
|
285
|
+
assert.ok(at.length > 0, `leg ${label} was never called over a mailbox without the pair — calls: ${describeJournal(journal)}`);
|
|
286
|
+
});
|
|
287
|
+
await settle();
|
|
288
|
+
}
|