@sema-agent/core 7.69.1 → 7.70.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 +2477 -0
- package/dist/agents/agent-definition.d.ts +18 -0
- package/dist/agents/agent-definition.js +10 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -1
- package/dist/agents/agent-transcript-tool.js +2 -0
- package/dist/agents/cascade.d.ts +10 -0
- package/dist/agents/cascade.js +33 -5
- package/dist/agents/cc-peer-directory.d.ts +1 -1
- package/dist/agents/cc-peer-directory.js +2 -1
- package/dist/agents/child-model-seat.d.ts +1 -1
- package/dist/agents/composition-allowance.d.ts +63 -19
- package/dist/agents/composition-allowance.js +62 -45
- package/dist/agents/composition-placement.d.ts +22 -4
- package/dist/agents/composition-placement.js +10 -1
- package/dist/agents/cross-session-envelope.d.ts +4 -5
- package/dist/agents/cross-session-envelope.js +4 -5
- package/dist/agents/inherited-tool-pool.js +1 -2
- package/dist/agents/list-agents-tool.js +2 -1
- package/dist/agents/parked-resume-drive.d.ts +38 -0
- package/dist/agents/parked-resume-drive.js +57 -0
- package/dist/agents/peer-admission.js +4 -3
- package/dist/agents/peer-held-queue.d.ts +4 -2
- package/dist/agents/peer-held-queue.js +2 -1
- package/dist/agents/peer-session-drain.d.ts +2 -0
- package/dist/agents/peer-session-drain.js +49 -29
- package/dist/agents/repair-loop.js +15 -11
- package/dist/agents/retain-ledger.d.ts +71 -18
- package/dist/agents/retain-ledger.js +45 -13
- package/dist/agents/roster-store.d.ts +11 -3
- package/dist/agents/roster-store.js +6 -2
- package/dist/agents/send-message-tool.d.ts +2 -1
- package/dist/agents/send-message-tool.js +10 -7
- package/dist/agents/subagent.d.ts +24 -7
- package/dist/agents/subagent.js +256 -144
- package/dist/agents/tool-filter.js +1 -1
- package/dist/agents/verify.d.ts +4 -1
- package/dist/agents/verify.js +22 -16
- package/dist/agents/yield-adoption.js +2 -1
- package/dist/bench/metrics.js +2 -2
- package/dist/brain/anthropic.d.ts +2 -1
- package/dist/brain/anthropic.js +3 -3
- package/dist/brain/circuit-breaker.js +1 -1
- package/dist/brain/model-lane.d.ts +2 -1
- package/dist/brain/model-lane.js +22 -9
- package/dist/brain/open-responses.d.ts +77 -1
- package/dist/brain/open-responses.js +1 -1
- package/dist/brain/openai.d.ts +2 -1
- package/dist/brain/openai.js +3 -3
- package/dist/brain/reasoning.d.ts +8 -1
- package/dist/brain/reasoning.js +3 -0
- package/dist/brain/reference-model-traits.d.ts +13 -12
- package/dist/brain/reference-model-traits.js +11 -10
- package/dist/brain/request-route.d.ts +1 -1
- package/dist/brain/request-route.js +2 -2
- package/dist/brain/route-adjudicator.d.ts +72 -2
- package/dist/brain/route-adjudicator.js +210 -69
- package/dist/brain/route-conformance.js +35 -0
- package/dist/brain/routing.js +2 -2
- package/dist/brain/spend-meter.d.ts +56 -0
- package/dist/brain/spend-meter.js +263 -0
- package/dist/brain/stream-shared.d.ts +1 -1
- package/dist/brain/stream-shared.js +3 -1
- package/dist/core/a2a-bound-grant.d.ts +110 -0
- package/dist/core/a2a-bound-grant.js +83 -0
- package/dist/core/a2a-task-state.d.ts +153 -51
- package/dist/core/a2a-task-state.js +85 -45
- package/dist/core/a2a.d.ts +62 -14
- package/dist/core/a2a.js +298 -57
- package/dist/core/agent-config-dir.d.ts +53 -6
- package/dist/core/agent-config-dir.js +59 -6
- package/dist/core/agent-definition.d.ts +1 -1
- package/dist/core/agent-state.d.ts +10 -1
- package/dist/core/agent-state.js +11 -4
- package/dist/core/allow-entry.d.ts +80 -42
- package/dist/core/allow-entry.js +119 -61
- package/dist/core/allow-rule-shadow.d.ts +25 -3
- package/dist/core/allow-rule-shadow.js +7 -0
- package/dist/core/approval-object.js +2 -2
- package/dist/core/artifact-host.d.ts +109 -6
- package/dist/core/artifact-host.js +68 -0
- package/dist/core/ask-headline.d.ts +10 -9
- package/dist/core/ask-headline.js +9 -3
- package/dist/core/ask-origin.d.ts +88 -28
- package/dist/core/ask-origin.js +73 -43
- package/dist/core/ask-question.d.ts +76 -38
- package/dist/core/ask-question.js +151 -22
- package/dist/core/ask-unresolvable-notice.d.ts +66 -10
- package/dist/core/ask-unresolvable-notice.js +38 -14
- package/dist/core/auto-compaction.d.ts +3 -49
- package/dist/core/auto-compaction.js +3 -8
- package/dist/core/auto-mode-directive.d.ts +17 -5
- package/dist/core/auto-mode-directive.js +12 -3
- package/dist/core/auto-mode.d.ts +34 -5
- package/dist/core/auto-mode.js +43 -5
- package/dist/core/background-agent-store.d.ts +100 -11
- package/dist/core/background-agent-store.js +64 -6
- package/dist/core/background-shell.d.ts +9 -0
- package/dist/core/background-shell.js +10 -0
- package/dist/core/caller-text.d.ts +2 -2
- package/dist/core/caller-tool-name.d.ts +6 -0
- package/dist/core/caller-tool-name.js +2 -1
- package/dist/core/checkpoint-features.d.ts +38 -422
- package/dist/core/checkpoint-features.js +44 -0
- package/dist/core/checkpoint-queries.d.ts +14 -3
- package/dist/core/checkpoint-queries.js +9 -4
- package/dist/core/checkpoint-requirements.d.ts +69 -2
- package/dist/core/checkpoint-requirements.js +12 -2
- package/dist/core/checkpoint-row-verdict.d.ts +70 -17
- package/dist/core/checkpoint-row-verdict.js +75 -29
- package/dist/core/checkpoint-store.d.ts +75 -69
- package/dist/core/checkpoint-store.js +24 -22
- package/dist/core/classifier-unavailable-arm.d.ts +6 -1
- package/dist/core/classifier-unavailable-arm.js +8 -5
- package/dist/core/config-refusal-codes.d.ts +7 -5
- package/dist/core/config-refusal-codes.js +7 -2
- package/dist/core/config-refusal-input.d.ts +46 -0
- package/dist/core/config-refusal-input.js +62 -0
- package/dist/core/context-edit.d.ts +18 -1
- package/dist/core/context-edit.js +13 -2
- package/dist/core/context-guard.d.ts +60 -13
- package/dist/core/context-guard.js +77 -35
- package/dist/core/context-settings.d.ts +2 -1
- package/dist/core/context-settings.js +10 -6
- package/dist/core/corrupt-session-form.d.ts +97 -0
- package/dist/core/corrupt-session-form.js +54 -0
- package/dist/core/cross-boundary-taint.d.ts +3 -3
- package/dist/core/data-root.d.ts +32 -0
- package/dist/core/data-root.js +86 -0
- package/dist/core/decision-receipt.d.ts +2 -0
- package/dist/core/decision-receipt.js +3 -2
- package/dist/core/declaration-words.d.ts +37 -0
- package/dist/core/declaration-words.js +21 -0
- package/dist/core/delegation-frames.d.ts +76 -35
- package/dist/core/delegation-frames.js +21 -1
- package/dist/core/durable-sync.d.ts +9 -0
- package/dist/core/durable-sync.js +37 -0
- package/dist/core/engine-capabilities.d.ts +110 -3
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +259 -139
- package/dist/core/engine-notice.js +13 -19
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +22 -0
- package/dist/core/entries-not-applied.js +26 -0
- package/dist/core/exec-gate.d.ts +8 -1
- package/dist/core/exec-gate.js +24 -9
- package/dist/core/exec-outcome.d.ts +102 -0
- package/dist/core/exec-outcome.js +79 -0
- package/dist/core/existing-target.d.ts +45 -0
- package/dist/core/existing-target.js +54 -8
- package/dist/core/fast-tier-door.d.ts +2 -2
- package/dist/core/fast-tier-door.js +3 -3
- package/dist/core/file-history-store.d.ts +138 -19
- package/dist/core/file-history-store.js +124 -33
- package/dist/core/gate-fold.js +8 -1
- package/dist/core/gate-lanes.js +65 -38
- package/dist/core/gate-outcome.d.ts +3 -1
- package/dist/core/gate-outcome.js +7 -1
- package/dist/core/git-worktree-env.d.ts +25 -5
- package/dist/core/git-worktree-env.js +38 -13
- package/dist/core/governance-codes.d.ts +179 -40
- package/dist/core/governance-codes.js +450 -43
- package/dist/core/hands-band.d.ts +1 -1
- package/dist/core/hooks.d.ts +75 -13
- package/dist/core/hooks.js +4 -0
- package/dist/core/host-floor.d.ts +1 -1
- package/dist/core/host-floor.js +1 -1
- package/dist/core/identity-rekey.d.ts +2 -1
- package/dist/core/identity-rekey.js +5 -5
- package/dist/core/image-admission.d.ts +2 -2
- package/dist/core/image-admission.js +1 -1
- package/dist/core/isolation-scope.d.ts +42 -17
- package/dist/core/isolation-scope.js +12 -4
- package/dist/core/leg-identity.d.ts +17 -2
- package/dist/core/leg-identity.js +6 -1
- package/dist/core/locked-config.d.ts +86 -16
- package/dist/core/locked-config.js +100 -34
- package/dist/core/mailbox-store.d.ts +4 -0
- package/dist/core/mailbox-store.js +7 -0
- package/dist/core/mcp-failure.d.ts +13 -4
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-injection-drop.d.ts +30 -13
- package/dist/core/mcp-injection-drop.js +25 -7
- package/dist/core/mcp-leg-wait.d.ts +88 -0
- package/dist/core/mcp-leg-wait.js +100 -0
- package/dist/core/mcp-name-judge.js +1 -2
- package/dist/core/mcp-probe.d.ts +30 -1
- package/dist/core/mcp-probe.js +5 -3
- package/dist/core/mcp-read-bound.d.ts +51 -0
- package/dist/core/mcp-read-bound.js +49 -0
- package/dist/core/mcp-server-link.js +4 -3
- package/dist/core/mcp-server-spec.d.ts +97 -26
- package/dist/core/mcp-server-spec.js +51 -19
- package/dist/core/mcp-server-unavailable-notice.d.ts +15 -6
- package/dist/core/mcp-server-unavailable-notice.js +12 -11
- package/dist/core/mcp-stderr-lines.d.ts +69 -0
- package/dist/core/mcp-stderr-lines.js +333 -0
- package/dist/core/mcp.d.ts +32 -9
- package/dist/core/mcp.js +187 -44
- package/dist/core/member-outcome.d.ts +281 -0
- package/dist/core/member-outcome.js +293 -0
- package/dist/core/memory-engine/consolidation.js +3 -3
- package/dist/core/memory-engine/content-origin.js +5 -4
- package/dist/core/memory-engine/control-objects.js +6 -4
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +12 -5
- package/dist/core/memory-engine/dual-root.js +13 -7
- package/dist/core/memory-engine/engine.d.ts +27 -31
- package/dist/core/memory-engine/engine.js +103 -61
- package/dist/core/memory-engine/file-backend.d.ts +16 -3
- package/dist/core/memory-engine/file-backend.js +15 -20
- package/dist/core/memory-engine/index-copies.d.ts +8 -6
- package/dist/core/memory-engine/index-copies.js +2 -1
- package/dist/core/memory-engine/index.d.ts +3 -2
- package/dist/core/memory-engine/index.js +3 -2
- package/dist/core/memory-engine/layout.d.ts +166 -23
- package/dist/core/memory-engine/layout.js +235 -40
- package/dist/core/memory-engine/memory-backend-contract.js +20 -20
- package/dist/core/memory-engine/memory-deployment.d.ts +29 -16
- package/dist/core/memory-engine/memory-deployment.js +30 -20
- package/dist/core/memory-engine/mount-failed-notice.d.ts +64 -0
- package/dist/core/memory-engine/mount-failed-notice.js +50 -2
- package/dist/core/memory-engine/projection-ledger.d.ts +48 -0
- package/dist/core/memory-engine/projection-ledger.js +130 -0
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.js +1 -2
- package/dist/core/memory-engine/types.d.ts +10 -4
- package/dist/core/memory.js +3 -5
- package/dist/core/mode-policy.d.ts +82 -16
- package/dist/core/mode-policy.js +63 -29
- package/dist/core/model-seat.d.ts +13 -1
- package/dist/core/mods/classic-events.d.ts +13 -1
- package/dist/core/mods/dollar.js +2 -1
- package/dist/core/mods/extension-call.d.ts +3 -0
- package/dist/core/mods/extension-call.js +3 -0
- package/dist/core/mods/kernel/dispatch.d.ts +4 -0
- package/dist/core/mods/kernel/dispatch.js +3 -3
- package/dist/core/mods/kernel/events.d.ts +11 -3
- package/dist/core/mods/kernel/events.js +4 -4
- package/dist/core/mods/message-display.d.ts +6 -3
- package/dist/core/mods/message-display.js +13 -5
- package/dist/core/mods/stations.d.ts +8 -1
- package/dist/core/mods/stations.js +5 -3
- package/dist/core/mods/teammate-stations.d.ts +75 -0
- package/dist/core/mods/teammate-stations.js +108 -0
- package/dist/core/mounted-mcp.js +1 -2
- package/dist/core/namespaced-rule-name.d.ts +1 -1
- package/dist/core/namespaced-rule-name.js +1 -1
- package/dist/core/notice-fact.d.ts +28 -0
- package/dist/core/notice-fact.js +25 -0
- package/dist/core/owner-identity.d.ts +8 -3
- package/dist/core/owner-identity.js +6 -3
- package/dist/core/parent-spec-seat.d.ts +16 -6
- package/dist/core/parent-spec-seat.js +28 -6
- package/dist/core/park-resumability.d.ts +10 -5
- package/dist/core/park-resumability.js +3 -0
- package/dist/core/park-selfcheck.js +2 -1
- package/dist/core/peer-seat.d.ts +1 -2
- package/dist/core/permission-rule-consent.d.ts +50 -1
- package/dist/core/permission-rule-consent.js +121 -14
- package/dist/core/permission-rule-model.d.ts +135 -39
- package/dist/core/permission-rule-model.js +151 -24
- package/dist/core/permission-rule-org.d.ts +13 -0
- package/dist/core/permission-rule-org.js +8 -0
- package/dist/core/permission-rule-provider.d.ts +107 -7
- package/dist/core/permission-rule-provider.js +434 -29
- package/dist/core/permission-rule-session.js +3 -1
- package/dist/core/permission-rule-store.d.ts +19 -2
- package/dist/core/permission-rule-store.js +29 -10
- package/dist/core/permission-rule-sync.js +5 -2
- package/dist/core/permission-rules.js +8 -3
- package/dist/core/persisted-rule-arms.d.ts +10 -4
- package/dist/core/persisted-rule-arms.js +16 -11
- package/dist/core/persisted-rule-buckets.d.ts +66 -0
- package/dist/core/persisted-rule-buckets.js +57 -0
- package/dist/core/plan-review-facts.d.ts +33 -0
- package/dist/core/plan-review-facts.js +25 -0
- package/dist/core/prefix-declaration.d.ts +50 -0
- package/dist/core/prefix-declaration.js +13 -0
- package/dist/core/present-plan-tool.d.ts +13 -3
- package/dist/core/present-plan-tool.js +14 -3
- package/dist/core/pricing.d.ts +5 -1
- package/dist/core/pricing.js +8 -5
- package/dist/core/principal-name.d.ts +55 -5
- package/dist/core/principal-name.js +57 -16
- package/dist/core/process-identity.d.ts +11 -7
- package/dist/core/process-identity.js +26 -36
- package/dist/core/process-table.d.ts +67 -0
- package/dist/core/process-table.js +177 -0
- package/dist/core/protocol-http-auth.d.ts +75 -12
- package/dist/core/protocol-http-auth.js +223 -26
- package/dist/core/protocol-revocation.d.ts +29 -10
- package/dist/core/protocol-revocation.js +9 -5
- package/dist/core/read-only-shell.d.ts +1 -1
- package/dist/core/read-only-shell.js +1 -1
- package/dist/core/read-root-grant-screen.d.ts +17 -6
- package/dist/core/read-root-grant-screen.js +15 -5
- package/dist/core/reminder-mint.d.ts +6 -0
- package/dist/core/reminder-mint.js +13 -0
- package/dist/core/remote-env.d.ts +111 -3
- package/dist/core/remote-env.js +20 -0
- package/dist/core/request-copy-projection.js +97 -18
- package/dist/core/resource-limit-reasons.d.ts +52 -0
- package/dist/core/resource-limit-reasons.js +6 -0
- package/dist/core/resume-at-refusal.d.ts +10 -6
- package/dist/core/resume-at-refusal.js +2 -2
- package/dist/core/resume-config-judge.d.ts +3 -2
- package/dist/core/resume-config-judge.js +2 -1
- package/dist/core/resume-startup-cause.d.ts +18 -4
- package/dist/core/resume-startup-cause.js +30 -6
- package/dist/core/retention.d.ts +12 -2
- package/dist/core/retention.js +6 -1
- package/dist/core/retired-keys.d.ts +5 -0
- package/dist/core/retired-keys.js +12 -0
- package/dist/core/rewind-conversation.d.ts +54 -0
- package/dist/core/rewind-conversation.js +1 -0
- package/dist/core/roles.d.ts +61 -3
- package/dist/core/roles.js +81 -28
- package/dist/core/rule-lane-reads.d.ts +2 -1
- package/dist/core/rule-lane-reads.js +54 -29
- package/dist/core/rule-offer-read.js +5 -2
- package/dist/core/rule-owner.d.ts +6 -1
- package/dist/core/rule-owner.js +8 -2
- package/dist/core/rule-store-fault.d.ts +4 -2
- package/dist/core/rule-store-fault.js +4 -1
- package/dist/core/runner/advertised-writable-dirs.d.ts +17 -0
- package/dist/core/runner/advertised-writable-dirs.js +15 -9
- package/dist/core/runner/announce-once-ledger.js +12 -11
- package/dist/core/runner/assemble-result.d.ts +15 -6
- package/dist/core/runner/assemble-result.js +12 -5
- package/dist/core/runner/auto-strip-notice.d.ts +1 -1
- package/dist/core/runner/branch-window.d.ts +25 -2
- package/dist/core/runner/branch-window.js +47 -11
- package/dist/core/runner/chain-refusal-throw.d.ts +19 -0
- package/dist/core/runner/chain-refusal-throw.js +30 -0
- package/dist/core/runner/changes-git.d.ts +21 -0
- package/dist/core/runner/changes-git.js +291 -0
- package/dist/core/runner/changes-history.d.ts +80 -0
- package/dist/core/runner/changes-history.js +351 -0
- package/dist/core/runner/checkpoint-scope.d.ts +16 -8
- package/dist/core/runner/checkpoint-scope.js +6 -4
- package/dist/core/runner/child-tree.d.ts +31 -20
- package/dist/core/runner/child-tree.js +24 -9
- package/dist/core/runner/classifier-ladder.d.ts +4 -2
- package/dist/core/runner/classifier-ladder.js +14 -12
- package/dist/core/runner/clock-and-limits.d.ts +0 -3
- package/dist/core/runner/clock-and-limits.js +1 -2
- package/dist/core/runner/compact-session.js +19 -50
- package/dist/core/runner/compaction-restate.js +2 -1
- package/dist/core/runner/constraint-layers.d.ts +101 -0
- package/dist/core/runner/constraint-layers.js +96 -0
- package/dist/core/runner/construction-doors.js +2 -0
- package/dist/core/runner/content-ask-bindings.d.ts +3 -3
- package/dist/core/runner/continuation-gate.d.ts +8 -4
- package/dist/core/runner/continuation-gate.js +2 -0
- package/dist/core/runner/continues-from.d.ts +7 -0
- package/dist/core/runner/continues-from.js +9 -0
- package/dist/core/runner/contracts.d.ts +144 -44
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/denial-limit-arms.js +3 -4
- package/dist/core/runner/earlier-grammar-notice.js +5 -3
- package/dist/core/runner/env-capability-census.js +2 -1
- package/dist/core/runner/file-history-restore.d.ts +35 -9
- package/dist/core/runner/file-history-restore.js +36 -9
- package/dist/core/runner/finish-reason-seat.js +13 -4
- package/dist/core/runner/gate-exit.d.ts +8 -0
- package/dist/core/runner/gate-exit.js +36 -11
- package/dist/core/runner/halt-attribution.js +1 -1
- package/dist/core/runner/initial-run-state.d.ts +1 -1
- package/dist/core/runner/initial-run-state.js +2 -2
- package/dist/core/runner/left-as-is-seat.js +1 -1
- package/dist/core/runner/mcp-redial.d.ts +15 -4
- package/dist/core/runner/mcp-redial.js +53 -6
- package/dist/core/runner/memory-capture-optout.d.ts +7 -11
- package/dist/core/runner/memory-capture-optout.js +7 -4
- package/dist/core/runner/memory-phase-refusals.d.ts +19 -0
- package/dist/core/runner/memory-phase-refusals.js +18 -0
- package/dist/core/runner/messages-omitted-seat.d.ts +24 -1
- package/dist/core/runner/messages-omitted-seat.js +30 -9
- package/dist/core/runner/model-fallback-seat.d.ts +18 -5
- package/dist/core/runner/model-fallback-seat.js +29 -24
- package/dist/core/runner/model-lane-seat.d.ts +23 -1
- package/dist/core/runner/model-lane-seat.js +20 -2
- package/dist/core/runner/nested-memory-lane.d.ts +64 -57
- package/dist/core/runner/nested-memory-lane.js +310 -110
- package/dist/core/runner/park-commit.d.ts +26 -5
- package/dist/core/runner/park-commit.js +19 -8
- package/dist/core/runner/permission-rule-lanes.d.ts +5 -0
- package/dist/core/runner/permission-rule-lanes.js +44 -11
- package/dist/core/runner/person-path-rows.d.ts +124 -21
- package/dist/core/runner/person-path-rows.js +179 -20
- package/dist/core/runner/prefix-ledger.d.ts +57 -3
- package/dist/core/runner/prefix-ledger.js +98 -8
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +2 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +13 -65
- package/dist/core/runner/prepare-advisor.js +2 -1
- package/dist/core/runner/prepare-artifact.d.ts +4 -1
- package/dist/core/runner/prepare-artifact.js +3 -3
- package/dist/core/runner/prepare-ask-lane.d.ts +4 -0
- package/dist/core/runner/prepare-ask-lane.js +7 -5
- package/dist/core/runner/prepare-boundary-parks.js +9 -3
- package/dist/core/runner/prepare-caps-and-workflow.js +37 -25
- package/dist/core/runner/prepare-config-doors.d.ts +13 -14
- package/dist/core/runner/prepare-config-doors.js +121 -122
- package/dist/core/runner/prepare-context-lane.d.ts +32 -11
- package/dist/core/runner/prepare-context-lane.js +77 -48
- package/dist/core/runner/prepare-defer-classify.d.ts +12 -0
- package/dist/core/runner/prepare-defer-classify.js +29 -7
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -0
- package/dist/core/runner/prepare-delegation-surface.js +8 -4
- package/dist/core/runner/prepare-execution-env.d.ts +3 -0
- package/dist/core/runner/prepare-execution-env.js +10 -5
- package/dist/core/runner/prepare-file-history.js +4 -1
- package/dist/core/runner/prepare-gate-stations.d.ts +10 -0
- package/dist/core/runner/prepare-gate-stations.js +15 -6
- package/dist/core/runner/prepare-hands-readface.d.ts +28 -7
- package/dist/core/runner/prepare-hands-readface.js +83 -23
- package/dist/core/runner/prepare-inherited-gate.d.ts +20 -11
- package/dist/core/runner/prepare-inherited-gate.js +27 -16
- package/dist/core/runner/prepare-memory-engine-session.js +4 -2
- package/dist/core/runner/prepare-memory.d.ts +8 -1
- package/dist/core/runner/prepare-memory.js +37 -33
- package/dist/core/runner/prepare-offload-wrappers.d.ts +7 -7
- package/dist/core/runner/prepare-offload-wrappers.js +26 -17
- package/dist/core/runner/prepare-park-ask.d.ts +8 -11
- package/dist/core/runner/prepare-park-ask.js +11 -8
- package/dist/core/runner/prepare-policy-chain.d.ts +24 -1
- package/dist/core/runner/prepare-policy-chain.js +53 -28
- package/dist/core/runner/prepare-project-context.d.ts +4 -0
- package/dist/core/runner/prepare-project-context.js +9 -8
- package/dist/core/runner/prepare-prompt-assembly.js +2 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +2 -2
- package/dist/core/runner/prepare-protocol-tools.js +44 -24
- package/dist/core/runner/prepare-question-face.d.ts +4 -9
- package/dist/core/runner/prepare-question-face.js +8 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +7 -1
- package/dist/core/runner/prepare-suspend-saga.js +10 -4
- package/dist/core/runner/prepare-task.d.ts +2 -2
- package/dist/core/runner/prepare-task.js +141 -57
- package/dist/core/runner/prepare-tool-disclosure-mount.js +10 -5
- package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
- package/dist/core/runner/prepare-turn-wiring.js +10 -8
- package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -19
- package/dist/core/runner/prepare-wiring-manifest.js +17 -35
- package/dist/core/runner/prepare-workspace-restore.d.ts +4 -11
- package/dist/core/runner/prepare-workspace-restore.js +1 -14
- package/dist/core/runner/read-root-grant.d.ts +48 -13
- package/dist/core/runner/read-root-grant.js +53 -19
- package/dist/core/runner/read-session-changes.d.ts +9 -0
- package/dist/core/runner/read-session-changes.js +192 -0
- package/dist/core/runner/remote-env-retry.d.ts +4 -4
- package/dist/core/runner/resume-admission.d.ts +11 -7
- package/dist/core/runner/resume-admission.js +25 -15
- package/dist/core/runner/resume-apply.js +2 -1
- package/dist/core/runner/resume-checkpoint-screen.d.ts +7 -2
- package/dist/core/runner/resume-checkpoint-screen.js +32 -17
- package/dist/core/runner/resume-internals-and-config.d.ts +3 -0
- package/dist/core/runner/resume-internals-and-config.js +10 -7
- package/dist/core/runner/resume-policy-outcome.d.ts +4 -3
- package/dist/core/runner/resume-policy-outcome.js +2 -2
- package/dist/core/runner/retired-name-policy.d.ts +15 -0
- package/dist/core/runner/retired-name-policy.js +37 -0
- package/dist/core/runner/retired-runner-deps.js +3 -1
- package/dist/core/runner/rewind-conversation.d.ts +10 -0
- package/dist/core/runner/rewind-conversation.js +100 -0
- package/dist/core/runner/rewind-files.js +37 -20
- package/dist/core/runner/rewind-target.d.ts +28 -0
- package/dist/core/runner/rewind-target.js +58 -0
- package/dist/core/runner/role-resolution-table.d.ts +3 -16
- package/dist/core/runner/role-resolution-table.js +1 -3
- package/dist/core/runner/role-seat-defaulted.d.ts +14 -5
- package/dist/core/runner/role-seat-defaulted.js +17 -13
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -6
- package/dist/core/runner/rule-store-unreadable-notice.js +6 -4
- package/dist/core/runner/run-compaction-machinery.js +2 -2
- package/dist/core/runner/run-harness-handlers.js +43 -11
- package/dist/core/runner/run-identity-wiring.d.ts +2 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +19 -28
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/run-settle-and-teardown.js +32 -17
- package/dist/core/runner/run-stop-and-final-verify.js +66 -69
- package/dist/core/runner/run-telemetry-and-budget-seats.js +14 -8
- package/dist/core/runner/run-turn-boundary.js +3 -6
- package/dist/core/runner/runtask.d.ts +22 -16
- package/dist/core/runner/runtask.js +18 -8
- package/dist/core/runner/sandbox-network-seat.js +1 -1
- package/dist/core/runner/seat-model-doors.d.ts +6 -5
- package/dist/core/runner/seat-model-doors.js +4 -3
- package/dist/core/runner/session-file-state-replay.d.ts +47 -8
- package/dist/core/runner/session-file-state-replay.js +97 -11
- package/dist/core/runner/session-files-open.d.ts +64 -0
- package/dist/core/runner/session-files-open.js +33 -0
- package/dist/core/runner/session-read-file-states.d.ts +37 -41
- package/dist/core/runner/session-read-file-states.js +14 -6
- package/dist/core/runner/session-rule-policy.d.ts +5 -0
- package/dist/core/runner/session-rule-policy.js +16 -9
- package/dist/core/runner/session-verb-doors.d.ts +41 -4
- package/dist/core/runner/session-verb-doors.js +66 -11
- package/dist/core/runner/shared-read-classifier.d.ts +14 -3
- package/dist/core/runner/shared-read-classifier.js +14 -6
- package/dist/core/runner/shell-env-withheld.d.ts +4 -2
- package/dist/core/runner/shell-env-withheld.js +3 -2
- package/dist/core/runner/side-call-account.d.ts +47 -5
- package/dist/core/runner/side-call-account.js +37 -3
- package/dist/core/runner/skipped-rules-notice.d.ts +5 -5
- package/dist/core/runner/skipped-rules-notice.js +3 -3
- package/dist/core/runner/stream-settle-backstop.js +5 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +26 -7
- package/dist/core/runner/sub-agent-deny-lists.js +23 -15
- package/dist/core/runner/task-start-doors.d.ts +7 -3
- package/dist/core/runner/task-start-doors.js +72 -31
- package/dist/core/runner/terminal-account.js +14 -8
- package/dist/core/runner/terminal-projection.d.ts +3 -2
- package/dist/core/runner/terminal-projection.js +2 -2
- package/dist/core/runner/tool-defer-gate.d.ts +1 -1
- package/dist/core/runner/tool-end-body.d.ts +8 -1
- package/dist/core/runner/tool-end-body.js +4 -3
- package/dist/core/runner/tool-face-overlay.js +6 -4
- package/dist/core/runner/tool-result-media-seat.d.ts +2 -1
- package/dist/core/runner/tool-table-view.js +1 -1
- package/dist/core/runner/trim-stretch.d.ts +43 -0
- package/dist/core/runner/trim-stretch.js +34 -0
- package/dist/core/runner/turn-attachments.js +7 -2
- package/dist/core/runner/unreadable-person-rows.d.ts +39 -0
- package/dist/core/runner/unreadable-person-rows.js +20 -0
- package/dist/core/runner/verdict-refusal.d.ts +22 -7
- package/dist/core/runner/verdict-refusal.js +35 -3
- package/dist/core/runner/workspace-sync.d.ts +49 -0
- package/dist/core/runner/workspace-sync.js +170 -0
- package/dist/core/runner-deps.d.ts +57 -32
- package/dist/core/scheduler.d.ts +34 -14
- package/dist/core/secret-env.d.ts +168 -18
- package/dist/core/secret-env.js +291 -56
- package/dist/core/sensitive-path-policy.js +3 -2
- package/dist/core/session-changes.d.ts +260 -0
- package/dist/core/session-changes.js +40 -0
- package/dist/core/session-checkout.d.ts +87 -3
- package/dist/core/session-checkout.js +134 -6
- package/dist/core/session-log-transfer.js +13 -7
- package/dist/core/session-policy-store.d.ts +40 -12
- package/dist/core/session-policy-store.js +51 -25
- package/dist/core/session-store.d.ts +23 -10
- package/dist/core/session-store.js +40 -13
- package/dist/core/session.d.ts +56 -9
- package/dist/core/session.js +8 -1
- package/dist/core/shell-read-silence.d.ts +3 -3
- package/dist/core/shell-read-silence.js +3 -1
- package/dist/core/shell-run-candidates.d.ts +23 -6
- package/dist/core/shell-run-candidates.js +34 -11
- package/dist/core/skill-grant.d.ts +11 -6
- package/dist/core/skill-grant.js +23 -15
- package/dist/core/spend-account.d.ts +232 -0
- package/dist/core/spend-account.js +286 -0
- package/dist/core/store-contracts/background-agent-store-contract.js +85 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +6 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +60 -6
- package/dist/core/store-contracts/file-history-store-contract.js +4 -4
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +2 -1
- package/dist/core/store-contracts/mailbox-store-contract.js +22 -11
- package/dist/core/store-contracts/peer-directory-contract.js +8 -0
- package/dist/core/store-contracts/permission-rule-sync-contract.js +3 -3
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +23 -4
- package/dist/core/store-contracts/session-policy-store-contract.js +9 -0
- package/dist/core/store-contracts/session-repo-contract.js +38 -1
- package/dist/core/store-contracts/session-store-contract.d.ts +21 -2
- package/dist/core/store-contracts/session-store-contract.js +369 -5
- package/dist/core/store-contracts/tool-result-store-contract.js +8 -7
- package/dist/core/store-contracts/workflow-journal-store-contract.js +33 -0
- package/dist/core/task-event.d.ts +57 -53
- package/dist/core/task-limits.d.ts +15 -8
- package/dist/core/task-notification.d.ts +17 -12
- package/dist/core/task-notification.js +20 -9
- package/dist/core/task-registry-agent.d.ts +35 -30
- package/dist/core/task-registry-agent.js +102 -32
- package/dist/core/task-registry-monitor.js +2 -1
- package/dist/core/task-registry-shared.d.ts +83 -16
- package/dist/core/task-registry-shared.js +26 -7
- package/dist/core/task-registry-workflow.d.ts +9 -1
- package/dist/core/task-registry-workflow.js +11 -3
- package/dist/core/task-registry.d.ts +26 -27
- package/dist/core/task-registry.js +42 -12
- package/dist/core/task-result.d.ts +145 -35
- package/dist/core/task-spec-members.d.ts +21 -3
- package/dist/core/task-spec-members.js +11 -2
- package/dist/core/task-spec.d.ts +42 -45
- package/dist/core/task-start-judge.js +10 -3
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +30 -2
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-errors.js +1 -0
- package/dist/core/tool-face-reader.d.ts +3 -2
- package/dist/core/tool-gate-phase.d.ts +16 -0
- package/dist/core/tool-gate-phase.js +1 -0
- package/dist/core/tool-mount-plan.d.ts +7 -0
- package/dist/core/tool-mount-plan.js +25 -1
- package/dist/core/tool-mount-static.js +3 -2
- package/dist/core/tool-name-aliases.d.ts +81 -106
- package/dist/core/tool-name-aliases.js +60 -155
- package/dist/core/tool-name-readings.d.ts +2 -0
- package/dist/core/tool-name-readings.js +9 -1
- package/dist/core/tool-policy.d.ts +165 -60
- package/dist/core/tool-policy.js +105 -69
- package/dist/core/tool-registry.d.ts +2 -0
- package/dist/core/tool-registry.js +3 -0
- package/dist/core/tool-result-bytes.d.ts +27 -3
- package/dist/core/tool-result-bytes.js +53 -0
- package/dist/core/tool-result-store.d.ts +11 -4
- package/dist/core/tool-result-store.js +6 -2
- package/dist/core/tool-roster.d.ts +33 -22
- package/dist/core/tool-roster.js +28 -18
- package/dist/core/tool-spec-members.d.ts +12 -0
- package/dist/core/tool-spec-members.js +31 -0
- package/dist/core/tool-spec.d.ts +41 -28
- package/dist/core/trace.d.ts +21 -64
- package/dist/core/trace.js +2 -3
- package/dist/core/types.d.ts +7 -7
- package/dist/core/types.js +2 -2
- package/dist/core/unavailable-landing.d.ts +72 -0
- package/dist/core/unavailable-landing.js +18 -0
- package/dist/core/untrusted-egress.d.ts +27 -5
- package/dist/core/untrusted-egress.js +30 -8
- package/dist/core/usage-window-store.d.ts +11 -1
- package/dist/core/usage-window-store.js +5 -0
- package/dist/core/user-attachment.d.ts +74 -48
- package/dist/core/user-attachment.js +137 -69
- package/dist/core/user-row-origin.d.ts +10 -0
- package/dist/core/user-row-origin.js +6 -0
- package/dist/core/wiring-manifest.d.ts +94 -24
- package/dist/core/wiring-manifest.js +65 -13
- package/dist/core/workflow-journal-store.d.ts +16 -7
- package/dist/core/workflow-journal-store.js +34 -6
- package/dist/core/workflow-run-store-contract.js +102 -0
- package/dist/core/workflow-run-store.d.ts +95 -4
- package/dist/core/workflow-run-store.js +74 -11
- package/dist/engine/compaction/compaction.d.ts +15 -3
- package/dist/engine/compaction/compaction.js +29 -10
- package/dist/engine/execution-env/kill-tree.js +44 -49
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -1
- package/dist/engine/execution-env/node-execution-env.js +18 -11
- package/dist/engine/harness/agent-harness.d.ts +13 -0
- package/dist/engine/harness/agent-harness.js +16 -1
- package/dist/engine/harness/types.d.ts +100 -30
- package/dist/engine/harness/types.js +36 -4
- package/dist/engine/llm/rejected-images.js +1 -1
- package/dist/engine/llm/types.d.ts +22 -2
- package/dist/engine/llm/types.js +5 -2
- package/dist/engine/loop/agent-loop.js +43 -11
- package/dist/engine/loop/types.d.ts +11 -0
- package/dist/engine/session/import-validate.d.ts +9 -0
- package/dist/engine/session/import-validate.js +50 -9
- package/dist/engine/session/memory-repo.d.ts +5 -1
- package/dist/engine/session/memory-repo.js +8 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.js +1 -1
- package/dist/engine/session/repo-utils.d.ts +19 -12
- package/dist/engine/session/repo-utils.js +12 -7
- package/dist/engine/session/session.d.ts +30 -10
- package/dist/engine/session/session.js +52 -20
- package/dist/engine/session/storage-base.js +2 -2
- package/dist/fixtures/index.d.ts +3 -1
- package/dist/fixtures/index.js +3 -0
- package/dist/host-env.d.ts +17 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +83 -41
- package/dist/index.js +64 -30
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +5 -3
- package/dist/internal/harness.js +4 -3
- package/dist/internal/llm.d.ts +1 -1
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +40 -12
- package/dist/orchestration/run-workflow-tool.js +205 -102
- package/dist/orchestration/workflow-catalog.d.ts +254 -0
- package/dist/orchestration/workflow-catalog.js +702 -0
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-meta.d.ts +11 -1
- package/dist/orchestration/workflow-meta.js +48 -0
- package/dist/orchestration/workflow-observe.d.ts +8 -10
- package/dist/orchestration/workflow-observe.js +6 -1
- package/dist/orchestration/workflow-park-adoption.d.ts +71 -33
- package/dist/orchestration/workflow-park-adoption.js +153 -40
- package/dist/orchestration/workflow-requirements.d.ts +51 -0
- package/dist/orchestration/workflow-requirements.js +54 -0
- package/dist/orchestration/workflow-script-runner.d.ts +18 -0
- package/dist/orchestration/workflow-script-store.d.ts +19 -64
- package/dist/orchestration/workflow-script-store.js +1 -24
- package/dist/orchestration/workflow-types.d.ts +173 -41
- package/dist/orchestration/workflow-types.js +22 -4
- package/dist/orchestration/workflow.d.ts +56 -42
- package/dist/orchestration/workflow.js +654 -139
- package/dist/prompt-assembly/catalog/core-behavior.js +6 -2
- package/dist/prompt-assembly/catalog/engine.d.ts +36 -0
- package/dist/prompt-assembly/catalog/engine.js +4 -0
- package/dist/prompt-assembly/catalog/events.d.ts +16 -0
- package/dist/prompt-assembly/catalog/events.js +2 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +4 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +2 -2
- package/dist/prompt-assembly/catalog/mechanism.js +2 -2
- package/dist/prompt-assembly/catalog/schema.d.ts +5 -2
- package/dist/prompt-assembly/catalog/schema.js +1 -0
- package/dist/prompt-assembly/epoch.d.ts +26 -0
- package/dist/prompt-assembly/epoch.js +29 -0
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +1 -1
- package/dist/prompt-assembly/turn-snapshot.d.ts +1 -1
- package/dist/prompts/default.d.ts +2 -2
- package/dist/shell/lex.d.ts +10 -7
- package/dist/shell/lex.js +56 -6
- package/dist/stores/file/adoption/adopt.d.ts +12 -0
- package/dist/stores/file/adoption/adopt.js +78 -31
- package/dist/stores/file/adoption/marker.d.ts +48 -26
- package/dist/stores/file/adoption/marker.js +24 -11
- package/dist/stores/file/background-agent-store.d.ts +5 -0
- package/dist/stores/file/background-agent-store.js +26 -5
- package/dist/stores/file/data-root-declaration.js +2 -1
- package/dist/stores/file/descriptor-seat.d.ts +100 -0
- package/dist/stores/file/descriptor-seat.js +150 -0
- package/dist/stores/file/file-history-store.js +2 -1
- package/dist/stores/file/fs-atomic.d.ts +126 -78
- package/dist/stores/file/fs-atomic.js +313 -253
- package/dist/stores/file/index.d.ts +10 -1
- package/dist/stores/file/index.js +28 -16
- package/dist/stores/file/ledger-damage.js +6 -10
- package/dist/stores/file/lock-reading.d.ts +158 -0
- package/dist/stores/file/lock-reading.js +252 -0
- package/dist/stores/file/mailbox-store.d.ts +8 -5
- package/dist/stores/file/mailbox-store.js +23 -14
- package/dist/stores/file/permission-rule-adopt.js +11 -11
- package/dist/stores/file/permission-rule-store.d.ts +14 -3
- package/dist/stores/file/permission-rule-store.js +33 -37
- package/dist/stores/file/process-anchor.d.ts +85 -0
- package/dist/stores/file/process-anchor.js +392 -0
- package/dist/stores/file/session-policy-store.d.ts +18 -2
- package/dist/stores/file/session-policy-store.js +71 -5
- package/dist/stores/file/session-store.d.ts +19 -1
- package/dist/stores/file/session-store.js +51 -19
- package/dist/stores/file/shared-ledger.d.ts +3 -3
- package/dist/stores/file/task-list-store.js +1 -1
- package/dist/stores/file/tool-result-store.js +2 -1
- package/dist/stores/file/usage-window-store.js +1 -1
- package/dist/stores/file/workflow-journal-store.d.ts +5 -2
- package/dist/stores/file/workflow-journal-store.js +12 -25
- package/dist/stores/file/workflow-run-store.d.ts +5 -0
- package/dist/stores/file/workflow-run-store.js +19 -12
- package/dist/tools/artifact/artifact-text.d.ts +29 -11
- package/dist/tools/artifact/artifact-text.js +13 -6
- package/dist/tools/artifact/artifact-tool.d.ts +35 -5
- package/dist/tools/artifact/artifact-tool.js +240 -45
- package/dist/tools/artifact/conformance.d.ts +27 -5
- package/dist/tools/artifact/conformance.js +420 -45
- package/dist/tools/artifact/local-stub.d.ts +2 -2
- package/dist/tools/artifact/local-stub.js +29 -26
- package/dist/tools/fs/bash-failure-output.d.ts +64 -0
- package/dist/tools/fs/bash-failure-output.js +40 -0
- package/dist/tools/fs/bash-program-position.d.ts +7 -3
- package/dist/tools/fs/bash-program-position.js +9 -6
- package/dist/tools/fs/bash-readonly-classifier.d.ts +4 -3
- package/dist/tools/fs/bound-open.d.ts +9 -8
- package/dist/tools/fs/bound-open.js +6 -4
- package/dist/tools/fs/dead-cwd.d.ts +8 -0
- package/dist/tools/fs/dead-cwd.js +7 -7
- package/dist/tools/fs/file-read-check.d.ts +8 -6
- package/dist/tools/fs/file-read-check.js +8 -4
- package/dist/tools/fs/file-write-check.d.ts +14 -0
- package/dist/tools/fs/file-write-check.js +35 -0
- package/dist/tools/fs/find-actions.d.ts +186 -0
- package/dist/tools/fs/find-actions.js +538 -0
- package/dist/tools/fs/fs-bash.d.ts +6 -3
- package/dist/tools/fs/fs-bash.js +67 -60
- package/dist/tools/fs/fs-pdf.js +16 -5
- package/dist/tools/fs/fs-read.js +5 -3
- package/dist/tools/fs/fs-shared.d.ts +67 -3
- package/dist/tools/fs/fs-shared.js +70 -34
- package/dist/tools/fs/fs-write.d.ts +23 -3
- package/dist/tools/fs/fs-write.js +137 -33
- package/dist/tools/fs/index.d.ts +15 -2
- package/dist/tools/fs/index.js +8 -4
- package/dist/tools/fs/program-read-model.d.ts +17 -1
- package/dist/tools/fs/program-read-model.js +7 -2
- package/dist/tools/fs/program-read-model.rows.js +5 -1
- package/dist/tools/fs/read-deny-home.js +12 -5
- package/dist/tools/fs/read-floor.d.ts +16 -0
- package/dist/tools/fs/read-floor.js +10 -5
- package/dist/tools/fs/removal-targets.d.ts +22 -4
- package/dist/tools/fs/removal-targets.js +116 -6
- package/dist/tools/fs/safety.d.ts +2 -0
- package/dist/tools/fs/safety.js +9 -2
- package/dist/tools/fs/shell-read-bindings.d.ts +56 -7
- package/dist/tools/fs/shell-read-bindings.js +175 -26
- package/dist/tools/fs/shell-read-check.d.ts +11 -2
- package/dist/tools/fs/shell-read-check.js +31 -5
- package/dist/tools/fs/shell-read-command-environment.d.ts +56 -0
- package/dist/tools/fs/shell-read-command-environment.js +75 -0
- package/dist/tools/fs/shell-read-establish.js +62 -16
- package/dist/tools/fs/shell-read-judge.d.ts +52 -7
- package/dist/tools/fs/shell-read-judge.js +63 -21
- package/dist/tools/fs/shell-read-lost-walk.d.ts +19 -0
- package/dist/tools/fs/shell-read-lost-walk.js +35 -0
- package/dist/tools/fs/shell-read-plan.d.ts +4 -0
- package/dist/tools/fs/shell-read-plan.js +47 -13
- package/dist/tools/fs/shell-read-sourced.d.ts +4 -3
- package/dist/tools/fs/shell-read-sourced.js +28 -3
- package/dist/tools/fs/shell-read-start.d.ts +7 -0
- package/dist/tools/fs/shell-read-word.js +1 -0
- package/dist/tools/fs/shell-read-workdir.d.ts +9 -11
- package/dist/tools/fs/shell-read-workdir.js +20 -26
- package/dist/tools/fs/shell-read-write-targets.d.ts +13 -5
- package/dist/tools/fs/shell-read-write-targets.js +51 -9
- package/dist/tools/monitor.d.ts +2 -1
- package/dist/tools/monitor.js +2 -0
- package/dist/tools/scheduler-tools.d.ts +7 -4
- package/dist/tools/scheduler-tools.js +60 -20
- package/dist/tools/task-list.d.ts +11 -1
- package/dist/tools/task-list.js +187 -134
- package/dist/tools/todo.d.ts +1 -1
- package/dist/tools/worktree.js +10 -9
- package/package.json +6 -2
- package/test/export-surface.snapshot.json +592 -22
- package/wire-changes/core-stores-sql@7.68.7.json +39 -0
- package/wire-changes/core-stores-sql@7.70.0.json +414 -0
- package/wire-changes/core@7.68.7.json +140 -0
- package/wire-changes/core@7.70.0.json +14689 -0
- package/wire-changes/mods-kernel@7.68.7.json +39 -0
- package/wire-changes/mods-kernel@7.70.0.json +75 -0
- package/wire-changes/primitives@7.68.7.json +39 -0
- package/wire-changes/primitives@7.70.0.json +807 -0
- package/wire-changes/wiki-gate@7.68.7.json +39 -0
- package/wire-changes/wiki-gate@7.70.0.json +40 -0
- package/dist/core/cache-break-detector.d.ts +0 -98
- package/dist/core/cache-break-detector.js +0 -146
- package/dist/core/compaction-retired-members.d.ts +0 -12
- package/dist/core/compaction-retired-members.js +0 -22
- package/dist/core/loopback-host.d.ts +0 -18
- package/dist/core/loopback-host.js +0 -40
- package/dist/core/protocol-naming.d.ts +0 -95
- package/dist/core/protocol-naming.js +0 -70
- package/dist/core/protocol-table.d.ts +0 -88
- package/dist/core/protocol-table.js +0 -47
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
|
-
import {
|
|
2
|
+
import { statSync } from "node:fs";
|
|
3
|
+
import { isAbsolute } from "node:path";
|
|
4
|
+
import { SessionError, StoredSession, uuidv7 } from "../../internal/harness.js";
|
|
5
|
+
import { promptIdentityOf, walkPromptEpochCarriers } from "../../prompt-assembly/epoch.js";
|
|
6
|
+
import { textContentHashOf } from "../canonical-json.js";
|
|
3
7
|
import { SESSION_LIST_LIMITS, hasSessionFork, isSessionConflict, } from "../session.js";
|
|
4
8
|
import { readMember } from "../thrown-value.js";
|
|
9
|
+
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
5
10
|
import { receiptRefusal, receiveOwnProperties } from "../own-property-receipt.js";
|
|
6
11
|
import { beginContract } from "./contract-harness.js";
|
|
7
12
|
const AT = "2026-10-18T00:00:00.000Z";
|
|
@@ -21,6 +26,10 @@ function toolResultEntry(id, parentId, toolCallId) {
|
|
|
21
26
|
function compactionEntry(id, parentId, firstKeptEntryId) {
|
|
22
27
|
return { id, parentId, type: "compaction", timestamp: AT, summary: "summary of the turns above the floor", firstKeptEntryId, tokensBefore: 1000 };
|
|
23
28
|
}
|
|
29
|
+
function epochPin() {
|
|
30
|
+
const layers = { catalog: textContentHashOf("contract-kit catalog"), renderers: { kit: 1 }, binding: textContentHashOf("contract-kit binding") };
|
|
31
|
+
return { epoch: 1, identity: promptIdentityOf(layers), layers, activatedBy: "session_start" };
|
|
32
|
+
}
|
|
24
33
|
const freshId = () => uuidv7();
|
|
25
34
|
function placementFor(scope, handle = `a${uuidv7().slice(-12)}`) {
|
|
26
35
|
return { kind: "subagent", scope: scope ?? `kit-${uuidv7().slice(-12)}`, ...(handle !== null ? { handle } : {}) };
|
|
@@ -46,9 +55,14 @@ async function thrownBy(fn, what) {
|
|
|
46
55
|
}
|
|
47
56
|
assert.fail(`${what}: expected a refusal, got a result`);
|
|
48
57
|
}
|
|
49
|
-
|
|
58
|
+
function assertFormStated(err, expected, what) {
|
|
59
|
+
assert.equal(readMember(readMember(err, "detail"), "form"), expected, `${what}: a corrupt_session refusal must state its form — "${expected}" for this fault (SessionError's fourth argument)`);
|
|
60
|
+
}
|
|
61
|
+
async function rejectsWithCode(fn, code, what, form) {
|
|
50
62
|
const err = await thrownBy(fn, what);
|
|
51
63
|
assert.equal(readMember(err, "code"), code, `${what}: the refusal must carry code ${code}`);
|
|
64
|
+
if (form !== undefined)
|
|
65
|
+
assertFormStated(err, form, what);
|
|
52
66
|
}
|
|
53
67
|
function conflictMiss(err) {
|
|
54
68
|
if (isSessionConflict(err))
|
|
@@ -74,6 +88,7 @@ async function refusedAsLoop(storage, leafId, loopMembers, what) {
|
|
|
74
88
|
if ("path" in outcome)
|
|
75
89
|
assert.fail(`${what}: a parent chain that loops back on itself answered a path of ${outcome.path.length} entries instead of refusing`);
|
|
76
90
|
assert.equal(readMember(outcome.err, "code"), "corrupt_session", `${what}: the refusal must carry code corrupt_session`);
|
|
91
|
+
assertFormStated(outcome.err, "parent_loop", what);
|
|
77
92
|
const sentence = String(readMember(outcome.err, "message"));
|
|
78
93
|
assert.ok(loopMembers.some((id) => sentence.includes(id)), `${what}: the refusal must name an entry of the loop (${loopMembers.join(" / ")}), got "${sentence}"`);
|
|
79
94
|
}
|
|
@@ -97,6 +112,11 @@ async function ownerOf(store, sessionId, what) {
|
|
|
97
112
|
assert.ok(head !== undefined, `${what}: the row exists, so headOf must answer it`);
|
|
98
113
|
return head.owner;
|
|
99
114
|
}
|
|
115
|
+
async function gateHead(store, sessionId, what) {
|
|
116
|
+
const head = await headOf(store, sessionId);
|
|
117
|
+
assert.ok(head !== undefined, `${what}: the row exists, so headOf must answer it`);
|
|
118
|
+
return head;
|
|
119
|
+
}
|
|
100
120
|
async function tokenOf(store, sessionId, what) {
|
|
101
121
|
const head = await headOf(store, sessionId);
|
|
102
122
|
assert.ok(head !== undefined, `${what}: the row exists, so headOf must answer it`);
|
|
@@ -128,7 +148,7 @@ function assertActivityOrder(rows, newerToOlder, what) {
|
|
|
128
148
|
}
|
|
129
149
|
const HOOK_WORDS = { subject: "SessionStoreContractHooks", unit: "hook", moment: "at sessionStoreContract" };
|
|
130
150
|
const REQUIRED_HOOKS = ["deleteSession", "reopen"];
|
|
131
|
-
const OPTIONAL_HOOKS = ["replica", "runAssertion", "onOptionalMember"];
|
|
151
|
+
const OPTIONAL_HOOKS = ["replica", "tokenlessRow", "openRefusedRow", "runAssertion", "onOptionalMember"];
|
|
132
152
|
function receiveHooks(make, hooks) {
|
|
133
153
|
if (typeof make !== "function")
|
|
134
154
|
throw receiptRefusal(`sessionStoreContract: make must be a function that returns a fresh SessionStore, got ${typeof make}`);
|
|
@@ -145,6 +165,11 @@ function receiveHooks(make, hooks) {
|
|
|
145
165
|
if (hook !== undefined && typeof hook !== "function")
|
|
146
166
|
throw receiptRefusal(`${HOOK_WORDS.subject}.${name} must be a function when present, got ${typeof hook}`);
|
|
147
167
|
}
|
|
168
|
+
const none = readMember(got, "noTokenlessRows");
|
|
169
|
+
if (none !== undefined && (typeof none !== "string" || none.trim() === ""))
|
|
170
|
+
throw receiptRefusal(`${HOOK_WORDS.subject}.noTokenlessRows must say why the store holds no row written before occupant tokens (a non-empty string) when present, got ${describeRejectedValue(none)}`);
|
|
171
|
+
if (none !== undefined && readMember(got, "tokenlessRow") !== undefined)
|
|
172
|
+
throw receiptRefusal(`${HOOK_WORDS.subject} gives tokenlessRow and declares noTokenlessRows — a store holds such rows (the hook writes one) or says why it holds none, not both`);
|
|
148
173
|
return got;
|
|
149
174
|
}
|
|
150
175
|
export function sessionStoreContract(make, hooks) {
|
|
@@ -181,16 +206,25 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
181
206
|
headOf: hasHead,
|
|
182
207
|
ownership: hasOwnership,
|
|
183
208
|
replica: () => hooks.replica !== undefined,
|
|
209
|
+
tokenlessRow: () => hooks.tokenlessRow !== undefined,
|
|
210
|
+
openRefusedRow: () => hooks.openRefusedRow !== undefined,
|
|
184
211
|
logTransfer: (s) => hasHead(s) && typeof s.logTransfer === "object" && s.logTransfer !== null,
|
|
185
212
|
delete: (s) => hasHead(s) && typeof s.delete === "function",
|
|
186
213
|
deleteUnreadable: (s) => hasHead(s) && typeof s.deleteUnreadable === "function",
|
|
187
214
|
};
|
|
215
|
+
const FACE_OWED = {
|
|
216
|
+
tokenlessRow: (s) => s.durability === "durable" && hooks.noTokenlessRows === undefined
|
|
217
|
+
? `the store declares durability "durable" — its rows outlive a process, so rows written before occupant tokens may stand among them: give the tokenlessRow hook (write such a row), or say in noTokenlessRows why this store holds none`
|
|
218
|
+
: undefined,
|
|
219
|
+
};
|
|
188
220
|
const faceRun = (name, needs, fn) => run(name, async (store, open) => {
|
|
189
221
|
const missing = [];
|
|
190
222
|
for (const m of needs)
|
|
191
223
|
if (!(await FACE_PRESENT[m](store)))
|
|
192
224
|
missing.push(m);
|
|
193
225
|
if (missing.length > 0) {
|
|
226
|
+
const owed = missing.length === 1 ? FACE_OWED[missing[0]]?.(store) : undefined;
|
|
227
|
+
assert.ok(owed === undefined, owed);
|
|
194
228
|
for (const m of missing)
|
|
195
229
|
report(m, "absent");
|
|
196
230
|
return;
|
|
@@ -199,6 +233,16 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
199
233
|
for (const m of needs)
|
|
200
234
|
report(m, "verified");
|
|
201
235
|
});
|
|
236
|
+
run("[transcriptDirectory] absent, or an absolute path that is a directory once a session was written — the one directory the Runner's transcript gate guards", async (store) => {
|
|
237
|
+
const dir = store.transcriptDirectory;
|
|
238
|
+
if (dir === undefined)
|
|
239
|
+
return;
|
|
240
|
+
assert.equal(typeof dir, "string", "transcriptDirectory is a path string when present");
|
|
241
|
+
assert.ok(isAbsolute(dir), `transcriptDirectory ${JSON.stringify(dir)} is an absolute path`);
|
|
242
|
+
const written = await store.acquire(freshId());
|
|
243
|
+
await append(written.session, userEntry("t1", null));
|
|
244
|
+
assert.ok(statSync(dir).isDirectory(), `transcriptDirectory ${JSON.stringify(dir)} is a directory once a session was written`);
|
|
245
|
+
});
|
|
202
246
|
run("[acquire] acquire() with no id mints a fresh, empty session whose id is the one handed back; two calls are two sessions", async (store) => {
|
|
203
247
|
const first = await store.acquire();
|
|
204
248
|
assert.equal(typeof first.sessionId, "string");
|
|
@@ -302,7 +346,7 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
302
346
|
accepted = false;
|
|
303
347
|
}
|
|
304
348
|
if (accepted) {
|
|
305
|
-
await rejectsWithCode(() => session.getStorage().getPathToRoot("orphan"), "corrupt_session", "the path through an entry whose parent was never written");
|
|
349
|
+
await rejectsWithCode(() => session.getStorage().getPathToRoot("orphan"), "corrupt_session", "the path through an entry whose parent was never written", "parent_missing");
|
|
306
350
|
}
|
|
307
351
|
const head = (await session.getStorage().getPathToRoot("e1"))[0];
|
|
308
352
|
assert.ok(head.parentId === null || head.id === session.getStorage().getFloorId?.(), "a path's head is a root or the declared floor");
|
|
@@ -428,6 +472,41 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
428
472
|
assert.deepEqual(path.map((e) => e.id), written.slice(written.length - path.length), "the woken path is the written path, or its tail from the floor");
|
|
429
473
|
assert.deepEqual(await woken.buildContext(), context, "waking from the rows (bounded or whole) rebuilds the same context");
|
|
430
474
|
});
|
|
475
|
+
run("[rows] a stored epoch record that does not read never hides an older pin: a reopened session answers what the same log without it answers, woken whole or bounded, and the walk counts what it passed over", async (store, open) => {
|
|
476
|
+
const pin = epochPin();
|
|
477
|
+
const write = async (unreadable) => {
|
|
478
|
+
const id = freshId();
|
|
479
|
+
const { session } = await store.acquire(id);
|
|
480
|
+
await append(session, { id: "p1", parentId: null, type: "prompt_epoch", timestamp: AT, ...pin });
|
|
481
|
+
await append(session, userEntry("u1", "p1"));
|
|
482
|
+
await append(session, assistantEntry("a1", "u1"));
|
|
483
|
+
const x1 = unreadable
|
|
484
|
+
? { id: "x1", parentId: "a1", type: "prompt_epoch", timestamp: AT, ...pin, epoch: 2, identity: textContentHashOf("not the layers' digest") }
|
|
485
|
+
: { id: "x1", parentId: "a1", type: "session_info", timestamp: AT, name: "kit" };
|
|
486
|
+
await append(session, x1);
|
|
487
|
+
await append(session, userEntry("u2", "x1"));
|
|
488
|
+
await append(session, assistantEntry("a2", "u2"));
|
|
489
|
+
await append(session, compactionEntry("c1", "a2", "u2"));
|
|
490
|
+
await append(session, userEntry("u3", "c1"));
|
|
491
|
+
return id;
|
|
492
|
+
};
|
|
493
|
+
const withIt = await write(true);
|
|
494
|
+
const without = await write(false);
|
|
495
|
+
const second = await open(hooks.reopen(store));
|
|
496
|
+
const woken = (await readBack(second, withIt)).getStorage();
|
|
497
|
+
const control = (await readBack(second, without)).getStorage();
|
|
498
|
+
assert.deepEqual(await new StoredSession(woken).getPromptEpoch(), await new StoredSession(control).getPromptEpoch(), "a stored epoch record that does not read changes nothing about the pin the session answers — a store that wakes a bounded window answers getEpochAnchor with the nearest record below its floor whose record READS (walkPromptEpochCarriers' found.record), never the one that does not read");
|
|
499
|
+
const bounded = (woken.getFloorId?.() ?? null) !== null;
|
|
500
|
+
if (!bounded)
|
|
501
|
+
assert.deepEqual(await new StoredSession(control).getPromptEpoch(), { kind: "pin", descriptor: pin }, "a whole wake answers the pin its branch holds");
|
|
502
|
+
const path = await woken.getPathToRoot(await woken.getLeafId());
|
|
503
|
+
const heldAt = path.findIndex((e) => e.id === "x1");
|
|
504
|
+
assert.ok(heldAt >= 0 || bounded, "a whole wake holds every written entry — the record that does not read is stored as written, not dropped");
|
|
505
|
+
if (heldAt >= 0) {
|
|
506
|
+
const walked = await walkPromptEpochCarriers((below) => (below > 0 ? { entry: path[below - 1], seq: below - 1 } : undefined), path.length);
|
|
507
|
+
assert.deepEqual(walked.skipped, { count: 1, newestSeq: heldAt }, "the walk over the woken path passes over exactly the record that does not read, and names its position");
|
|
508
|
+
}
|
|
509
|
+
});
|
|
431
510
|
faceRun("[rows] forget drops only the cached view: the history survives and the next acquire reopens it", ["forget"], async (store) => {
|
|
432
511
|
const id = freshId();
|
|
433
512
|
await append((await store.acquire(id)).session, userEntry("e1", null));
|
|
@@ -449,6 +528,40 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
449
528
|
assert.deepEqual(await pathIds((await readBack(store, src))), ["e1", "e2", "s3"], "writes to the fork never reach the source");
|
|
450
529
|
assert.deepEqual(await pathIds((await readBack(store, forkedId))), ["e1", "e2", "f3"], "writes to the source never reach the fork");
|
|
451
530
|
});
|
|
531
|
+
faceRun("[fork] a fork given an id lands on that id; a second fork onto it is refused conflict and the row the first laid down is unchanged; of two forks onto one free id at once exactly one lands", ["fork"], async (store, open) => {
|
|
532
|
+
const src = freshId();
|
|
533
|
+
const source = (await store.acquire(src)).session;
|
|
534
|
+
await append(source, userEntry("e1", null));
|
|
535
|
+
await append(source, assistantEntry("e2", "e1"));
|
|
536
|
+
const target = freshId();
|
|
537
|
+
assert.equal(await store.fork(src, undefined, { id: target }), target, "a fork given an id lands on that id");
|
|
538
|
+
const forked = await readBack(store, target);
|
|
539
|
+
assert.deepEqual(await pathIds(forked), ["e1", "e2"], "the fork on the given id carries the source's committed history");
|
|
540
|
+
assert.equal((await forked.getMetadata()).forkedFrom, src, "the fork on the given id names its source");
|
|
541
|
+
await append(forked, userEntry("f3", "e2"));
|
|
542
|
+
const rowOf = async (s) => {
|
|
543
|
+
const m = await s.getMetadata();
|
|
544
|
+
const cells = [m.createdAt, m.owner ?? null, m.incarnation ?? null, m.forkedFrom ?? null, m.forkedFromIncarnation ?? null, m.placement ?? null];
|
|
545
|
+
return structuredClone([cells, await s.getStorage().getEntries()]);
|
|
546
|
+
};
|
|
547
|
+
const laidDown = await rowOf(forked);
|
|
548
|
+
await rejectsWithConflict(() => store.fork(src, undefined, { id: target }), "a second fork onto the id the first laid down");
|
|
549
|
+
const second = await open(hooks.reopen(store));
|
|
550
|
+
const after = await readBack(second, target);
|
|
551
|
+
assert.deepEqual(await pathIds(after), ["e1", "e2", "f3"], "the refused fork wrote nothing: the row keeps the log the first fork laid down and was written since");
|
|
552
|
+
assert.deepEqual(await rowOf(after), laidDown, "the refused fork wrote nothing: the row keeps every cell and every entry whole");
|
|
553
|
+
const other = freshId();
|
|
554
|
+
await append((await second.acquire(other)).session, userEntry("o1", null));
|
|
555
|
+
const raced = freshId();
|
|
556
|
+
const settled = await Promise.allSettled([second.fork(src, undefined, { id: raced }), second.fork(other, undefined, { id: raced })]);
|
|
557
|
+
const landed = settled.flatMap((s, i) => (s.status === "fulfilled" ? [i] : []));
|
|
558
|
+
assert.equal(landed.length, 1, "two forks onto one free id at once: exactly one lands");
|
|
559
|
+
const loser = settled[1 - landed[0]];
|
|
560
|
+
assert.equal(loser.status === "rejected" ? conflictMiss(loser.reason) : "it landed too", undefined, "and the other is refused the engine's session conflict");
|
|
561
|
+
const won = await readBack(await open(hooks.reopen(second)), raced);
|
|
562
|
+
assert.equal((await won.getMetadata()).forkedFrom, landed[0] === 0 ? src : other, "the row is the one fork that landed");
|
|
563
|
+
assert.deepEqual(await pathIds(won), landed[0] === 0 ? ["e1", "e2"] : ["o1"], "and holds that fork's history alone");
|
|
564
|
+
});
|
|
452
565
|
faceRun("[fork] fork of a missing source answers null and creates nothing", ["fork"], async (store) => {
|
|
453
566
|
const missing = freshId();
|
|
454
567
|
assert.equal(await store.fork(missing), null);
|
|
@@ -871,6 +984,12 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
871
984
|
assert.ok(whole.has(`${head.owner}|${head.incarnation}`), `a head read ${head.owner} with occupant ${head.incarnation}, a pair no generation of the row ever held`);
|
|
872
985
|
}
|
|
873
986
|
});
|
|
987
|
+
faceRun("[head] a row written before occupant tokens (the tokenlessRow hook) answers a head naming no occupant — no incarnation, not incarnation: null", ["headOf", "tokenlessRow"], async (store) => {
|
|
988
|
+
const id = freshId();
|
|
989
|
+
await hooks.tokenlessRow(store, id);
|
|
990
|
+
const head = await gateHead(store, id, "the row written before tokens");
|
|
991
|
+
assert.equal(head.incarnation, undefined, `a row with no occupant token answers a head with no incarnation (got ${describeRejectedValue(head.incarnation)}): a gate hands the head as it came to a write's expect.row, where an occupant that is not a token is no expectation — every move of the row is refused config.invalid_argument`);
|
|
992
|
+
});
|
|
874
993
|
faceRun("[ownership] register on an id with no row creates its row recording the owner — a string, or null for anonymous; a row an acquire naming no owner created records null", ["ownership"], async (store) => {
|
|
875
994
|
const [owned, anonymous, acquired] = [freshId(), freshId(), freshId()];
|
|
876
995
|
await store.register(owned, "kit-alice");
|
|
@@ -1259,6 +1378,209 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
1259
1378
|
await rejectsWithConflict(() => staging.commit({ owner: "kit-alice", decide }), "a commit whose destination another instance wrote while decide weighed it");
|
|
1260
1379
|
assert.deepEqual(await store.logTransfer.listEntryIds(id), ["e1", "e2"], "the other instance's write stands, and nothing of the staged log was written");
|
|
1261
1380
|
});
|
|
1381
|
+
faceRun("[transfer] a commit naming the row it judged (expect: { row: head }, the head its gate read) lands only on that row: the same row takes a replace and a keep and keeps its occupant, the leaf not judged; the id deleted and created again under the same (anonymous) owner (a replace or a keep), a row with no occupant named against a row holding one, and the id deleted — each refused conflict, decide never asked, nothing written", ["logTransfer"], async (store) => {
|
|
1382
|
+
const id = freshId();
|
|
1383
|
+
await append((await store.acquire(id)).session, userEntry("old1", null));
|
|
1384
|
+
const judged = await gateHead(store, id, "the row the committer judged");
|
|
1385
|
+
const same = await commitLog(store, id, { owner: null, expect: { row: judged } }, [userEntry("n1", null)]);
|
|
1386
|
+
assert.equal(same.outcome, "replaced");
|
|
1387
|
+
assert.equal(same.head.incarnation, judged.incarnation, "the commit landed on the row it named, and the row keeps its occupant");
|
|
1388
|
+
const kept = await commitLog(store, id, { owner: null, expect: { row: judged }, decide: () => "keep" }, [userEntry("n1", null)]);
|
|
1389
|
+
assert.equal(kept.outcome, "kept", "the head's leaf moved with the replace, and the leaf is not what the row expectation judges");
|
|
1390
|
+
const staging = store.logTransfer.beginReplace(id);
|
|
1391
|
+
await staging.append([userEntry("x1", null)]);
|
|
1392
|
+
await store.acquire(id);
|
|
1393
|
+
await hooks.deleteSession(store, id);
|
|
1394
|
+
await append((await store.acquire(id)).session, userEntry("y1", null));
|
|
1395
|
+
const now = await gateHead(store, id, "the row created again under the id");
|
|
1396
|
+
assert.notEqual(now.incarnation, judged.incarnation, "a row created again under the id is another occupant");
|
|
1397
|
+
let asked = false;
|
|
1398
|
+
const decide = (verdict) => () => {
|
|
1399
|
+
asked = true;
|
|
1400
|
+
return verdict;
|
|
1401
|
+
};
|
|
1402
|
+
await rejectsWithConflict(() => staging.commit({ owner: null, expect: { row: judged }, decide: decide("replace") }), "a commit naming the row the id held before it was deleted and created again");
|
|
1403
|
+
await rejectsWithConflict(() => commitLog(store, id, { owner: null, expect: { row: judged }, decide: decide("keep") }, [userEntry("y1", null)]), "a keep naming the row the id held before it was deleted and created again");
|
|
1404
|
+
await rejectsWithConflict(() => commitLog(store, id, { owner: null, expect: { row: { owner: null } }, decide: decide("replace") }, [userEntry("z1", null)]), "a commit expecting a row with no occupant token, onto a row holding one");
|
|
1405
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(id), ["y1"], "nothing of a refused commit landed on the new occupant");
|
|
1406
|
+
assert.equal(await tokenOf(store, id, "after the refused commits"), now.incarnation, "the new occupant's row stands as it was");
|
|
1407
|
+
await store.acquire(id);
|
|
1408
|
+
await hooks.deleteSession(store, id);
|
|
1409
|
+
await rejectsWithConflict(() => commitLog(store, id, { owner: null, expect: { row: now }, decide: decide("replace") }, [userEntry("z1", null)]), "a commit naming a row that was deleted");
|
|
1410
|
+
assert.equal(asked, false, "the relation is never judged for a row that is not the one the committer judged");
|
|
1411
|
+
assert.equal(await headOf(store, id), undefined, "a refused commit creates no row");
|
|
1412
|
+
});
|
|
1413
|
+
faceRun("[transfer] a commit naming no row (expect: { row: null }, its gate read none) lands only where the id still has none: it creates the row; a row created under the id since — the committer's own included — and a row that was there all along refuse it conflict, decide never asked, and that row stands", ["logTransfer"], async (store) => {
|
|
1414
|
+
const fresh = freshId();
|
|
1415
|
+
const created = await commitLog(store, fresh, { owner: null, expect: { row: null } }, [userEntry("c1", null)]);
|
|
1416
|
+
assert.equal(created.outcome, "replaced");
|
|
1417
|
+
assert.equal((await gateHead(store, fresh, "the row the commit created")).owner, null);
|
|
1418
|
+
const id = freshId();
|
|
1419
|
+
const staging = store.logTransfer.beginReplace(id);
|
|
1420
|
+
await staging.append([userEntry("x1", null)]);
|
|
1421
|
+
await store.acquire(id);
|
|
1422
|
+
let asked = false;
|
|
1423
|
+
const decide = () => {
|
|
1424
|
+
asked = true;
|
|
1425
|
+
return "replace";
|
|
1426
|
+
};
|
|
1427
|
+
await rejectsWithConflict(() => staging.commit({ owner: null, expect: { row: null }, decide }), "a commit expecting no row, onto a row of the committer's own created since its gate read none");
|
|
1428
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(id), [], "the row created since stands as it was");
|
|
1429
|
+
await rejectsWithConflict(() => commitLog(store, fresh, { owner: null, expect: { row: null }, decide }, [userEntry("z1", null)]), "a commit expecting no row, onto a row that is there");
|
|
1430
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(fresh), ["c1"]);
|
|
1431
|
+
assert.equal(asked, false, "the relation is never judged for a row the committer did not expect");
|
|
1432
|
+
});
|
|
1433
|
+
faceRun("[transfer] a commit naming the log its committer judged (expect.log, the log's mark as read) lands only on that log: an append since refuses it conflict, decide never asked, and the append stands; the mark read again lands", ["logTransfer"], async (store) => {
|
|
1434
|
+
const id = freshId();
|
|
1435
|
+
const held = (await store.acquire(id)).session;
|
|
1436
|
+
await append(held, userEntry("e1", null));
|
|
1437
|
+
const judged = { row: await gateHead(store, id, "the row the committer judged"), log: logMarkOf(await store.logTransfer.listEntryIds(id)) };
|
|
1438
|
+
const staging = store.logTransfer.beginReplace(id);
|
|
1439
|
+
await staging.append([userEntry("s1", null)]);
|
|
1440
|
+
await append(held, assistantEntry("e2", "e1"));
|
|
1441
|
+
let asked = false;
|
|
1442
|
+
const decide = () => {
|
|
1443
|
+
asked = true;
|
|
1444
|
+
return "replace";
|
|
1445
|
+
};
|
|
1446
|
+
await rejectsWithConflict(() => staging.commit({ owner: null, expect: judged, decide }), "a commit naming the log as its gate read it, onto that log appended since");
|
|
1447
|
+
assert.equal(asked, false);
|
|
1448
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(id), ["e1", "e2"], "the append stands, and nothing of the staged log was written");
|
|
1449
|
+
const again = { row: await gateHead(store, id, "the row read again"), log: logMarkOf(await store.logTransfer.listEntryIds(id)) };
|
|
1450
|
+
const done = await commitLog(store, id, { owner: null, expect: again }, [userEntry("s1", null)]);
|
|
1451
|
+
assert.equal(done.outcome, "replaced");
|
|
1452
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(id), ["s1"]);
|
|
1453
|
+
});
|
|
1454
|
+
faceRun("[transfer] the write law comes before the expected row: a placed row is refused placement_refused whatever row the commit names", ["logTransfer", "placements"], async (store) => {
|
|
1455
|
+
const id = freshId();
|
|
1456
|
+
await append((await store.acquire(id, { placement: placementFor() })).session, userEntry("p1", null));
|
|
1457
|
+
await rejectsWithCode(() => commitLog(store, id, { owner: null, expect: { row: { owner: null, incarnation: "kit-not-its-occupant" } } }, [userEntry("x1", null)]), "placement_refused", "a commit naming another occupant onto a placed row");
|
|
1458
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(id), ["p1"]);
|
|
1459
|
+
});
|
|
1460
|
+
faceRun("[transfer] the id deleted and created again through another instance while decide weighs it: a commit naming the row it judged is refused conflict and nothing lands on the new occupant — the row judged is the one the write lands on", ["logTransfer", "replica"], async (store, open) => {
|
|
1461
|
+
const id = freshId();
|
|
1462
|
+
const other = await open(hooks.replica(store));
|
|
1463
|
+
await store.acquire(id);
|
|
1464
|
+
const judged = await gateHead(store, id, "the row the committer judged");
|
|
1465
|
+
const staging = store.logTransfer.beginReplace(id);
|
|
1466
|
+
await staging.append([userEntry("s1", null)]);
|
|
1467
|
+
const decide = async () => {
|
|
1468
|
+
await other.acquire(id);
|
|
1469
|
+
await hooks.deleteSession(other, id);
|
|
1470
|
+
await other.acquire(id);
|
|
1471
|
+
return "replace";
|
|
1472
|
+
};
|
|
1473
|
+
await rejectsWithConflict(() => staging.commit({ owner: null, expect: { row: judged }, decide }), "a commit whose row another instance deleted and created again while decide weighed it");
|
|
1474
|
+
assert.notEqual(await tokenOf(other, id, "the row created again"), judged.incarnation);
|
|
1475
|
+
assert.deepEqual(await other.logTransfer.listEntryIds(id), [], "the new occupant's row holds nothing of the staged log");
|
|
1476
|
+
});
|
|
1477
|
+
faceRun("[transfer] a commit's row expectation is read as the commit's other members are: absent (or undefined) names none — a commit onto a row created again under the id lands, as it always did; a value not of the shape (not an object, a row neither the row nor null, an owner or occupant of the wrong kind, a log mark that is none) is refused config.invalid_argument, ends the staging and writes nothing", ["logTransfer"], async (store) => {
|
|
1478
|
+
const id = freshId();
|
|
1479
|
+
await store.acquire(id);
|
|
1480
|
+
const before = await gateHead(store, id, "the first occupant");
|
|
1481
|
+
await hooks.deleteSession(store, id);
|
|
1482
|
+
await store.acquire(id);
|
|
1483
|
+
const now = await tokenOf(store, id, "the row created again");
|
|
1484
|
+
for (const commit of [{ owner: null }, { owner: null, expect: undefined }]) {
|
|
1485
|
+
const done = await commitLog(store, id, commit, [userEntry("n1", null)]);
|
|
1486
|
+
assert.equal(done.outcome, "replaced", "no expectation: the commit lands on whichever row the id holds");
|
|
1487
|
+
assert.equal(done.head.incarnation, now);
|
|
1488
|
+
}
|
|
1489
|
+
assert.notEqual(now, before.incarnation);
|
|
1490
|
+
const shapes = [
|
|
1491
|
+
["null", null],
|
|
1492
|
+
["a string", "kit-head"],
|
|
1493
|
+
["a number", 7],
|
|
1494
|
+
["no row member", {}],
|
|
1495
|
+
["a row that is a string", { row: "kit-head" }],
|
|
1496
|
+
["an owner that is a number", { row: { owner: 7, incarnation: now } }],
|
|
1497
|
+
["no owner", { row: { incarnation: now } }],
|
|
1498
|
+
["an occupant that is a number", { row: { owner: null, incarnation: 7 } }],
|
|
1499
|
+
["a log mark of a negative length", { row: { owner: null, incarnation: now }, log: { length: -1, lastEntryId: null } }],
|
|
1500
|
+
];
|
|
1501
|
+
for (const [what, bad] of shapes) {
|
|
1502
|
+
const staging = store.logTransfer.beginReplace(id);
|
|
1503
|
+
await staging.append([userEntry("b1", null)]);
|
|
1504
|
+
await rejectsWithCode(() => Reflect.apply(staging.commit, staging, [{ owner: null, decide: () => "replace", expect: bad }]), "config.invalid_argument", `an expectation of ${what}`);
|
|
1505
|
+
await rejectsWithCode(() => staging.commit({ owner: null, decide: () => "replace" }), "invalid_session", "a staging after a commit refused for its expectation (the first commit call ends it)");
|
|
1506
|
+
}
|
|
1507
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(id), ["n1"], "a refused expectation writes nothing");
|
|
1508
|
+
});
|
|
1509
|
+
for (const [what, onAbsentId, build] of READER_ONLY_SHAPES) {
|
|
1510
|
+
faceRun(`[transfer] a commit's row expectation is read by the root's strict reading of it (readRowExpectationMember), and what that reading refuses is a bad argument: ${what} — refused config.invalid_argument, the staging ended, nothing written`, ["logTransfer"], async (store) => {
|
|
1511
|
+
const id = freshId();
|
|
1512
|
+
await append((await store.acquire(id)).session, userEntry("e1", null));
|
|
1513
|
+
const head = await gateHead(store, id, "the row the committer judged");
|
|
1514
|
+
const target = onAbsentId ? freshId() : id;
|
|
1515
|
+
const staging = store.logTransfer.beginReplace(target);
|
|
1516
|
+
await staging.append([userEntry("b1", null)]);
|
|
1517
|
+
await rejectsWithCode(() => Reflect.apply(staging.commit, staging, [{ owner: null, decide: () => "replace", expect: build(head, id) }]), "config.invalid_argument", `an expectation of ${what}`);
|
|
1518
|
+
await rejectsWithCode(() => staging.commit({ owner: null, decide: () => "replace" }), "invalid_session", "a staging after a commit refused for its expectation (the first commit call ends it)");
|
|
1519
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(id), ["e1"], "a refused expectation writes nothing");
|
|
1520
|
+
if (onAbsentId)
|
|
1521
|
+
assert.equal(await headOf(store, target), undefined, "a refused expectation creates no row");
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
faceRun("[transfer] a row written before occupant tokens (the tokenlessRow hook): a token named against it is refused conflict and nothing is written; a commit naming it as its gate read it ({ row: head }) lands and the row keeps no token", ["logTransfer", "tokenlessRow"], async (store) => {
|
|
1525
|
+
const id = freshId();
|
|
1526
|
+
await hooks.tokenlessRow(store, id);
|
|
1527
|
+
const head = await gateHead(store, id, "the row written before tokens");
|
|
1528
|
+
const before = await store.logTransfer.listEntryIds(id);
|
|
1529
|
+
await rejectsWithConflict(() => commitLog(store, id, { owner: head.owner, expect: { row: { owner: head.owner, incarnation: "kit-not-its-occupant" } } }, [userEntry("w1", null)]), "a commit naming a token, onto a row that holds none");
|
|
1530
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(id), before, "a refused commit writes nothing");
|
|
1531
|
+
const done = await commitLog(store, id, { owner: head.owner, expect: { row: head } }, [userEntry("l1", null)]);
|
|
1532
|
+
assert.equal(done.outcome, "replaced", "the head the gate read, passed as it came, names the row");
|
|
1533
|
+
assert.equal(done.head.incarnation, undefined, "a commit onto an existing row keeps its occupant cell: no token is invented");
|
|
1534
|
+
assert.deepEqual(await store.logTransfer.listEntryIds(id), ["l1"]);
|
|
1535
|
+
});
|
|
1536
|
+
faceRun("[transfer] two transfers onto one row, each naming the row it judged: neither lands on another occupant — each is replaced keeping it or refused conflict, at least one lands, and the row holds one staged log whole", ["logTransfer"], async (store) => {
|
|
1537
|
+
const id = freshId();
|
|
1538
|
+
await append((await store.acquire(id)).session, userEntry("old1", null));
|
|
1539
|
+
const judged = await gateHead(store, id, "the row both committers judged");
|
|
1540
|
+
const a = store.logTransfer.beginReplace(id);
|
|
1541
|
+
await a.append([userEntry("a1", null), assistantEntry("a2", "a1")]);
|
|
1542
|
+
const b = store.logTransfer.beginReplace(id);
|
|
1543
|
+
await b.append([userEntry("b1", null)]);
|
|
1544
|
+
const settled = await Promise.allSettled([a, b].map((s) => s.commit({ owner: null, expect: { row: judged }, decide: () => "replace" })));
|
|
1545
|
+
for (const s of settled) {
|
|
1546
|
+
if (s.status === "fulfilled")
|
|
1547
|
+
assert.equal(s.value.head.incarnation, judged.incarnation, "a commit that landed kept the occupant it named");
|
|
1548
|
+
else
|
|
1549
|
+
assert.equal(conflictMiss(s.reason), undefined, `a commit that did not land is the engine's conflict: ${conflictMiss(s.reason)}`);
|
|
1550
|
+
}
|
|
1551
|
+
assert.ok(settled.some((s) => s.status === "fulfilled"), "two commits onto the row both judged: at least one lands");
|
|
1552
|
+
const log = await store.logTransfer.listEntryIds(id);
|
|
1553
|
+
const holds = (want) => log !== null && log.length === want.length && want.every((entryId, i) => log[i] === entryId);
|
|
1554
|
+
assert.ok(holds(["a1", "a2"]) || holds(["b1"]), `the row holds one staged log whole (a1 a2, or b1), never a mix or the old log, got ${describeRejectedValue(log)}`);
|
|
1555
|
+
assert.equal(await tokenOf(store, id, "after both commits"), judged.incarnation);
|
|
1556
|
+
});
|
|
1557
|
+
faceRun("[transfer] a commit naming its row racing the id's deletion and creation again: whatever the order, the staged log never lands on a new occupant — when the deletion took the row, the commit landed before it (on the row it named) or was refused conflict; when it took nothing, the commit lands on the row it named", ["logTransfer"], async (store) => {
|
|
1558
|
+
const id = freshId();
|
|
1559
|
+
await append((await store.acquire(id)).session, userEntry("old1", null));
|
|
1560
|
+
const judged = await gateHead(store, id, "the row the committer judged");
|
|
1561
|
+
const staging = store.logTransfer.beginReplace(id);
|
|
1562
|
+
await staging.append([userEntry("s1", null)]);
|
|
1563
|
+
const recreate = (async () => {
|
|
1564
|
+
await store.acquire(id);
|
|
1565
|
+
await hooks.deleteSession(store, id);
|
|
1566
|
+
await store.acquire(id);
|
|
1567
|
+
})();
|
|
1568
|
+
const [commit] = await Promise.allSettled([staging.commit({ owner: null, expect: { row: judged }, decide: () => "replace" }), recreate]);
|
|
1569
|
+
await recreate;
|
|
1570
|
+
const now = await tokenOf(store, id, "the row after the race");
|
|
1571
|
+
const log = await store.logTransfer.listEntryIds(id);
|
|
1572
|
+
if (now !== judged.incarnation) {
|
|
1573
|
+
if (commit.status === "fulfilled")
|
|
1574
|
+
assert.equal(commit.value.head.incarnation, judged.incarnation, "a commit that landed, landed on the row it named");
|
|
1575
|
+
else
|
|
1576
|
+
assert.equal(conflictMiss(commit.reason), undefined, `a commit that did not land is the engine's conflict: ${conflictMiss(commit.reason)}`);
|
|
1577
|
+
assert.ok(log !== null && !log.includes("s1"), "the new occupant's row holds nothing of the staged log");
|
|
1578
|
+
}
|
|
1579
|
+
else {
|
|
1580
|
+
assert.equal(commit.status, "fulfilled", `the row the commit named still stands, so the commit lands: ${commit.status === "rejected" ? describeRejectedValue(readMember(commit.reason, "code")) : ""}`);
|
|
1581
|
+
assert.deepEqual(log, ["s1"], "the staged log is on the row the commit named");
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1262
1584
|
faceRun("[delete] only the owner's delete deletes: another owner's or an anonymous guard on an owned row, and an owner's guard on an anonymous row, answer false and leave the row; the right guard answers true, the id is gone, a repeat answers false, and a later create is a new occupant", ["delete", "ownership"], async (store) => {
|
|
1263
1585
|
const id = freshId();
|
|
1264
1586
|
await store.register(id, "kit-alice");
|
|
@@ -1286,6 +1608,18 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
1286
1608
|
}
|
|
1287
1609
|
assert.equal(await ownerOf(store, id, "after the refused deletes"), "kit-alice");
|
|
1288
1610
|
});
|
|
1611
|
+
faceRun("[delete] a row whose head reads and whose open is refused corrupt_session (the openRefusedRow hook) is judged on its head alone: another owner's guard answers false, its owner's answers true and the id answers nothing; the operator's delete, where present, answers false for it first (its head reads)", ["delete", "ownership", "openRefusedRow"], async (store) => {
|
|
1612
|
+
const id = freshId();
|
|
1613
|
+
await hooks.openRefusedRow(store, id, "kit-alice");
|
|
1614
|
+
const opened = await store.acquire(id).then(() => undefined, (err) => err);
|
|
1615
|
+
assert.equal(readMember(opened, "code"), "corrupt_session", "the hook's row: its open is refused corrupt_session");
|
|
1616
|
+
assert.equal(await ownerOf(store, id, "the hook's row"), "kit-alice", "the hook's row: its head reads");
|
|
1617
|
+
if (typeof store.deleteUnreadable === "function")
|
|
1618
|
+
assert.equal(await store.deleteUnreadable(id), false, "the head reads: not the operator's");
|
|
1619
|
+
assert.equal(await store.delete(id, { owner: "kit-bob" }), false, "another owner's guard deletes nothing");
|
|
1620
|
+
assert.equal(await store.delete(id, { owner: "kit-alice" }), true, "its owner's delete takes it: a deletion never reads the log");
|
|
1621
|
+
assert.equal(await headOf(store, id), undefined, "the row is gone");
|
|
1622
|
+
});
|
|
1289
1623
|
faceRun("[delete] a placed row is not deleted here: its deletion is release's", ["delete", "placements"], async (store) => {
|
|
1290
1624
|
const id = freshId();
|
|
1291
1625
|
await append((await store.acquire(id, { placement: placementFor() })).session, userEntry("p1", null));
|
|
@@ -1327,5 +1661,35 @@ async function streamIds(t, sessionId, opts) {
|
|
|
1327
1661
|
async function commitLog(store, sessionId, commit, entries) {
|
|
1328
1662
|
const staging = store.logTransfer.beginReplace(sessionId);
|
|
1329
1663
|
await staging.append(entries);
|
|
1330
|
-
return staging.commit({ owner: commit.owner, decide: commit.decide ?? (() => "replace") });
|
|
1664
|
+
return staging.commit({ owner: commit.owner, decide: commit.decide ?? (() => "replace"), ...(Object.hasOwn(commit, "expect") ? { expect: commit.expect } : {}) });
|
|
1665
|
+
}
|
|
1666
|
+
class KitRowObject {
|
|
1667
|
+
owner;
|
|
1668
|
+
incarnation;
|
|
1669
|
+
constructor(owner, incarnation) {
|
|
1670
|
+
this.owner = owner;
|
|
1671
|
+
this.incarnation = incarnation;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
const READER_ONLY_SHAPES = [
|
|
1675
|
+
["a row that is a class instance", false, (head) => ({ row: new KitRowObject(head.owner, head.incarnation) })],
|
|
1676
|
+
["a row carrying a key the type has not", false, (head, sessionId) => ({ row: { ...head, sessionId } })],
|
|
1677
|
+
["a row whose occupant its prototype supplies", false, (head) => ({ row: Object.assign(Object.create({ incarnation: head.incarnation }), { owner: head.owner }) })],
|
|
1678
|
+
[
|
|
1679
|
+
"a row whose occupant is an accessor that throws",
|
|
1680
|
+
false,
|
|
1681
|
+
(head) => ({
|
|
1682
|
+
row: {
|
|
1683
|
+
owner: head.owner,
|
|
1684
|
+
get incarnation() {
|
|
1685
|
+
throw new Error("kit: the accessor was run");
|
|
1686
|
+
},
|
|
1687
|
+
},
|
|
1688
|
+
}),
|
|
1689
|
+
],
|
|
1690
|
+
["row null beside the mark of a log with entries (a row that is not there holds none)", true, () => ({ row: null, log: { length: 1, lastEntryId: "e1" } })],
|
|
1691
|
+
];
|
|
1692
|
+
function logMarkOf(ids) {
|
|
1693
|
+
assert.ok(ids !== null, "the row exists, so its log is listed");
|
|
1694
|
+
return { length: ids.length, lastEntryId: ids.length === 0 ? null : ids[ids.length - 1] };
|
|
1331
1695
|
}
|
|
@@ -14,7 +14,7 @@ export async function toolResultStoreContract(make, runAssertion, onOptionalMemb
|
|
|
14
14
|
assert.equal((await store.get(ref)).content, "0123456789");
|
|
15
15
|
assert.equal(await store.get("tr_unknown"), undefined);
|
|
16
16
|
});
|
|
17
|
-
run("
|
|
17
|
+
run("unsafe refs are rejected at the WRITE by every backend; the read face degrades instead", async () => {
|
|
18
18
|
const store = make();
|
|
19
19
|
const NUL = String.fromCharCode(0);
|
|
20
20
|
const unsafe = ["", ".", "..", "a/b", "../escape", "dir\\ref", `tr_x${NUL}y`];
|
|
@@ -25,7 +25,7 @@ export async function toolResultStoreContract(make, runAssertion, onOptionalMemb
|
|
|
25
25
|
await store.put("tr_sess-1_call.7", "ok");
|
|
26
26
|
assert.equal((await store.get("tr_sess-1_call.7")).content, "ok");
|
|
27
27
|
});
|
|
28
|
-
run("
|
|
28
|
+
run("a ref the contract ACCEPTS round-trips on every backend (no backend is stricter than the rule)", async () => {
|
|
29
29
|
const store = make();
|
|
30
30
|
for (const ref of ["tr_sess_call:1", "tr_sess_call%2F1", "tr_sess_call 1", "tr_sess_日本語"]) {
|
|
31
31
|
await store.put(ref, `payload-${ref}`);
|
|
@@ -33,7 +33,7 @@ export async function toolResultStoreContract(make, runAssertion, onOptionalMemb
|
|
|
33
33
|
}
|
|
34
34
|
assert.equal((await store.get("tr_sess_call:1")).content, "payload-tr_sess_call:1");
|
|
35
35
|
});
|
|
36
|
-
run("
|
|
36
|
+
run("provenance: content+owner are one write; ownerOf answers; a different owner is a TYPED refusal; unowned rows stay unowned", async () => {
|
|
37
37
|
const store = make();
|
|
38
38
|
assert.equal(typeof store.ownerOf, "function", "a backend must implement ownerOf — a store that cannot say who owns a ref cannot back a host read face");
|
|
39
39
|
const ownerOf = (ref) => Promise.resolve(store.ownerOf(ref));
|
|
@@ -57,7 +57,7 @@ export async function toolResultStoreContract(make, runAssertion, onOptionalMemb
|
|
|
57
57
|
assert.equal((await store.get(unowned)).content, "bytes from a write site that stated no owner");
|
|
58
58
|
assert.equal(await ownerOf("tr_never~written"), undefined);
|
|
59
59
|
});
|
|
60
|
-
run("
|
|
60
|
+
run("identity: principal (null included) and isolationScope round-trip; anonymous ≠ none recorded; a different identity is a typed refusal; the engine's read judge reads the answer", async () => {
|
|
61
61
|
const store = make();
|
|
62
62
|
const ownerOf = (ref) => Promise.resolve(store.ownerOf(ref));
|
|
63
63
|
const named = { sessionId: "sess-A", principal: "kit-alice" };
|
|
@@ -165,7 +165,7 @@ export async function toolResultStoreContract(make, runAssertion, onOptionalMemb
|
|
|
165
165
|
}
|
|
166
166
|
assert.equal(identityReadVerdict(await Promise.resolve(store.ownerOf("tr_rk1~named")), { principal: "kit-bob", isolationScope: "kit-alice" }), "readable", "the person's own partition stays with the entry");
|
|
167
167
|
});
|
|
168
|
-
run("
|
|
168
|
+
run("deleteBySession (optional): four-state semantics when present; absence is REPORTED, not silently green", async () => {
|
|
169
169
|
const probe = make();
|
|
170
170
|
if (probe.deleteBySession === undefined) {
|
|
171
171
|
onOptionalMember?.({ member: "deleteBySession", status: "absent" });
|
|
@@ -311,8 +311,9 @@ export async function toolResultStoreContract(make, runAssertion, onOptionalMemb
|
|
|
311
311
|
});
|
|
312
312
|
};
|
|
313
313
|
const piece = Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
314
|
-
const
|
|
315
|
-
|
|
314
|
+
const refusal = new ToolResultBytesOverLimitError("r", piece.byteLength, 6);
|
|
315
|
+
const bound = await keepToolResultBytes({ store: refusing(refusal), sessionId: "sess-A" }, "c1", piece, "application/zip");
|
|
316
|
+
assert.deepEqual(bound, { bytes: 8, mimeType: "application/zip", notKept: "over_limit", limit: 6, saveError: refusal.message }, "the coded refusal is over_limit with the store's bound and its words");
|
|
316
317
|
const other = await keepToolResultBytes({ store: refusing(new Error("disk full")), sessionId: "sess-A" }, "c1", piece, "application/zip");
|
|
317
318
|
assert.deepEqual(other, { bytes: 8, mimeType: "application/zip", notKept: "store_failed", saveError: "disk full" }, "any other throw is store_failed with the store's text");
|
|
318
319
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
2
|
import { JOURNAL_INCOMPATIBLE_ERROR_CODE, JOURNAL_OVERSIZE_ERROR_CODE, MAX_JOURNAL_RESULT_BYTES, WORKFLOW_LAUNCH_CONFLICT_CODE, } from "../workflow-journal-store.js";
|
|
3
|
+
import { ANONYMOUS_SCOPE } from "../isolation-scope.js";
|
|
3
4
|
import { beginContract } from "./contract-harness.js";
|
|
4
5
|
const key = (ordinal) => `${ordinal}:h`;
|
|
5
6
|
const completed = (ordinal, over = {}) => ({
|
|
@@ -49,6 +50,15 @@ export async function workflowJournalStoreContract(make, runAssertion) {
|
|
|
49
50
|
assert.deepEqual(await store.load("run-1", "mallory"), []);
|
|
50
51
|
assert.deepEqual((await store.load("run-1", "alice")).map((e) => e.callKey), [key(0), key(1)]);
|
|
51
52
|
});
|
|
53
|
+
run("the anonymous working scope is a scope like any other: a run journaled under ANONYMOUS_SCOPE loads under no other name, and a run of a named scope does not load under it", async () => {
|
|
54
|
+
const store = make();
|
|
55
|
+
await store.append("run-anon", ANONYMOUS_SCOPE, { callKey: key(0), result: completed(0) });
|
|
56
|
+
await store.append("run-named", "alice", { callKey: key(0), result: completed(0) });
|
|
57
|
+
assert.deepEqual(await store.load("run-anon", "alice"), []);
|
|
58
|
+
assert.deepEqual(await store.load("run-named", ANONYMOUS_SCOPE), []);
|
|
59
|
+
assert.equal((await store.load("run-anon", ANONYMOUS_SCOPE)).length, 1);
|
|
60
|
+
assert.equal((await store.load("run-named", "alice")).length, 1);
|
|
61
|
+
});
|
|
52
62
|
run(`oversize RESULT arm ⇒ append rejects with code "${JOURNAL_OVERSIZE_ERROR_CODE}"; nothing journaled; the store stays usable`, async () => {
|
|
53
63
|
const store = make();
|
|
54
64
|
await store.append("run-1", "tenant-a", { callKey: key(0), result: completed(0) });
|
|
@@ -174,6 +184,29 @@ export async function workflowJournalStoreContract(make, runAssertion) {
|
|
|
174
184
|
await store.recordLaunch("run-fits", "tenant-a", fits);
|
|
175
185
|
assert.deepEqual(await store.loadLaunch("run-fits", "tenant-a"), fits);
|
|
176
186
|
});
|
|
187
|
+
run("a launch record holding values a JSON round trip changes is kept and answered in its storage form, and the same record written again is no conflict; one holding a value JSON cannot keep is refused and nothing is kept", async () => {
|
|
188
|
+
const store = make();
|
|
189
|
+
if (typeof store.recordLaunch !== "function" || typeof store.loadLaunch !== "function")
|
|
190
|
+
return;
|
|
191
|
+
const launch = { script: "return 1;", effectiveArgs: { topic: "t", note: undefined, zero: -0, list: [1, { gone: undefined }] }, callArgs: { name: "n", flag: undefined } };
|
|
192
|
+
const stored = { script: "return 1;", effectiveArgs: { topic: "t", zero: 0, list: [1, {}] }, callArgs: { name: "n" } };
|
|
193
|
+
await store.recordLaunch("run-1", "tenant-a", launch);
|
|
194
|
+
assert.deepEqual(await store.loadLaunch("run-1", "tenant-a"), stored, "the record is answered in its storage form: a member holding undefined absent, -0 as 0");
|
|
195
|
+
await store.recordLaunch("run-1", "tenant-a", structuredClone(launch));
|
|
196
|
+
await store.recordLaunch("run-1", "tenant-a", stored);
|
|
197
|
+
assert.deepEqual(await store.loadLaunch("run-1", "tenant-a"), stored);
|
|
198
|
+
await assert.rejects(store.recordLaunch("run-1", "tenant-a", { ...stored, effectiveArgs: { topic: "u" } }), (e) => e.code === WORKFLOW_LAUNCH_CONFLICT_CODE);
|
|
199
|
+
const scalar = { script: "return 1;", effectiveArgs: "just text", callArgs: {} };
|
|
200
|
+
await store.recordLaunch("run-2", "tenant-a", scalar);
|
|
201
|
+
assert.deepEqual(await store.loadLaunch("run-2", "tenant-a"), scalar);
|
|
202
|
+
const unkeepable = [["a number that is not finite", Number.NaN], ["an infinite number", Number.POSITIVE_INFINITY], ["a Date", new Date(0)], ["an undefined list element", [1, undefined]]];
|
|
203
|
+
for (const [i, [what, value]] of unkeepable.entries()) {
|
|
204
|
+
await assert.rejects(store.recordLaunch(`run-bad-${i}`, "tenant-a", { script: "return 1;", effectiveArgs: { v: value }, callArgs: {} }), `a launch record whose args hold ${what} is refused`);
|
|
205
|
+
assert.equal(await store.loadLaunch(`run-bad-${i}`, "tenant-a"), undefined, `nothing is kept for a launch record whose args hold ${what}`);
|
|
206
|
+
await assert.rejects(store.recordLaunch(`run-bad-c${i}`, "tenant-a", { script: "return 1;", callArgs: { v: value } }), `a launch record whose call arguments hold ${what} is refused`);
|
|
207
|
+
assert.equal(await store.loadLaunch(`run-bad-c${i}`, "tenant-a"), undefined, `nothing is kept for a launch record whose call arguments hold ${what}`);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
177
210
|
run("resume claims: a second run is refused while the first holds the claim (naming it, and its expiry, where the store answers them); the holder's re-claim is granted; released, the claim is free", async () => {
|
|
178
211
|
const store = make();
|
|
179
212
|
if (typeof store.resumeClaim !== "function")
|