@sema-agent/core 7.70.0 → 7.71.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 +728 -0
- package/dist/agents/agent-transcript-tool.js +43 -19
- package/dist/agents/inherited-tool-pool.d.ts +5 -1
- package/dist/agents/inherited-tool-pool.js +6 -0
- package/dist/agents/retain-ledger.js +2 -0
- package/dist/agents/send-message-tool.d.ts +12 -1
- package/dist/agents/send-message-tool.js +47 -9
- package/dist/agents/subagent.js +31 -10
- package/dist/agents/tool-filter.js +1 -2
- package/dist/agents/verify.js +13 -2
- package/dist/agents/yield-adoption.js +11 -1
- package/dist/brain/claude-model-id.d.ts +11 -0
- package/dist/brain/claude-model-id.js +3 -1
- package/dist/config/catalog.js +10 -1
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.js +1 -0
- package/dist/core/allow-entry.js +1 -2
- package/dist/core/ask-origin.d.ts +55 -21
- package/dist/core/ask-origin.js +19 -11
- package/dist/core/ask-question.d.ts +4 -7
- package/dist/core/ask-question.js +2 -4
- package/dist/core/ask-unresolvable-notice.d.ts +17 -3
- package/dist/core/ask-unresolvable-notice.js +18 -4
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +2 -0
- package/dist/core/auto-compaction.d.ts +14 -4
- package/dist/core/auto-compaction.js +3 -2
- package/dist/core/auto-strip.js +2 -0
- package/dist/core/caller-text.d.ts +2 -33
- package/dist/core/caller-text.js +2 -23
- package/dist/core/caller-tool-name.js +1 -2
- package/dist/core/canonical-json.d.ts +9 -0
- package/dist/core/canonical-json.js +6 -0
- package/dist/core/checkpoint-features.d.ts +43 -80
- package/dist/core/checkpoint-features.js +10 -20
- package/dist/core/checkpoint-generation.d.ts +89 -19
- package/dist/core/checkpoint-generation.js +89 -14
- package/dist/core/checkpoint-queries.d.ts +95 -15
- package/dist/core/checkpoint-queries.js +108 -7
- package/dist/core/checkpoint-rekey.d.ts +2 -1
- package/dist/core/checkpoint-rekey.js +2 -2
- package/dist/core/checkpoint-requirements.d.ts +7 -6
- package/dist/core/checkpoint-requirements.js +2 -5
- package/dist/core/checkpoint-row-verdict.d.ts +3 -4
- package/dist/core/checkpoint-row-verdict.js +20 -41
- package/dist/core/checkpoint-store.d.ts +65 -41
- package/dist/core/checkpoint-store.js +28 -14
- package/dist/core/command-sandbox.d.ts +5 -3
- package/dist/core/command-sandbox.js +17 -9
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/declaration-words.d.ts +2 -1
- package/dist/core/declaration-words.js +13 -2
- package/dist/core/effective-path-target.d.ts +23 -0
- package/dist/core/effective-path-target.js +15 -1
- package/dist/core/engine-attestation.d.ts +5 -1
- package/dist/core/engine-attestation.js +1 -0
- package/dist/core/engine-capabilities.d.ts +14 -9
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +62 -32
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +1 -1
- package/dist/core/entries-not-applied.js +1 -0
- package/dist/core/file-history-store.d.ts +95 -11
- package/dist/core/file-history-store.js +117 -19
- package/dist/core/gate-fold.js +13 -7
- package/dist/core/gate-lanes.js +9 -9
- package/dist/core/governance-codes.d.ts +56 -7
- package/dist/core/governance-codes.js +105 -7
- package/dist/core/grant-holder.d.ts +53 -0
- package/dist/core/grant-holder.js +80 -0
- package/dist/core/hooks.d.ts +7 -3
- package/dist/core/hooks.js +2 -2
- package/dist/core/locked-config.d.ts +7 -1
- package/dist/core/locked-config.js +9 -2
- package/dist/core/mcp-call-meta.d.ts +52 -7
- package/dist/core/mcp-call-meta.js +21 -2
- package/dist/core/mcp-host-read.d.ts +1 -1
- package/dist/core/mcp-server-spec.d.ts +18 -0
- package/dist/core/mcp-server-spec.js +1 -0
- package/dist/core/mcp.js +2 -2
- package/dist/core/member-outcome.d.ts +22 -1
- package/dist/core/member-outcome.js +18 -6
- package/dist/core/memory-engine/delegation-settlement.js +5 -5
- package/dist/core/memory-engine/engine.js +19 -19
- package/dist/core/memory-engine/file-backend.d.ts +7 -2
- package/dist/core/memory-engine/file-backend.js +14 -12
- package/dist/core/memory-engine/frontmatter.js +1 -1
- package/dist/core/memory-engine/index.d.ts +1 -0
- package/dist/core/memory-engine/index.js +1 -0
- package/dist/core/memory-engine/layout.d.ts +34 -9
- package/dist/core/memory-engine/layout.js +36 -19
- package/dist/core/memory-engine/memory-deployment.js +8 -8
- package/dist/core/memory-engine/mount-failed-notice.d.ts +8 -5
- package/dist/core/memory-engine/mount-failed-notice.js +5 -2
- package/dist/core/mode-policy.d.ts +5 -0
- package/dist/core/mode-policy.js +6 -0
- package/dist/core/mods/host.d.ts +2 -1
- package/dist/core/mods/host.js +7 -6
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/index.js +1 -1
- package/dist/core/mods/kernel/registration.d.ts +5 -2
- package/dist/core/mods/kernel/registration.js +19 -3
- package/dist/core/mods/package.d.ts +12 -1
- package/dist/core/mods/package.js +36 -9
- package/dist/core/mods/stations.d.ts +7 -1
- package/dist/core/mods/stations.js +17 -3
- package/dist/core/mods/teammate-stations.d.ts +4 -1
- package/dist/core/mods/teammate-stations.js +1 -1
- package/dist/core/native-signal.d.ts +13 -0
- package/dist/core/native-signal.js +18 -0
- package/dist/core/park-resumability.d.ts +16 -14
- package/dist/core/park-resumability.js +9 -4
- package/dist/core/path-rule-binding.js +1 -1
- package/dist/core/permission-rule-model.d.ts +11 -5
- package/dist/core/permission-rule-model.js +5 -3
- package/dist/core/permission-rule-org.js +1 -1
- package/dist/core/permission-rule-provider.d.ts +5 -1
- package/dist/core/permission-rule-provider.js +6 -1
- package/dist/core/permission-rule-session.d.ts +35 -5
- package/dist/core/permission-rule-session.js +32 -1
- package/dist/core/permission-rule-store.d.ts +5 -1
- package/dist/core/permission-rule-store.js +28 -5
- package/dist/core/permission-rules.d.ts +2 -2
- package/dist/core/permission-rules.js +2 -3
- package/dist/core/principal-name.d.ts +12 -0
- package/dist/core/principal-name.js +6 -2
- package/dist/core/read-root-grant-screen.d.ts +7 -6
- package/dist/core/read-root-grant-screen.js +7 -8
- package/dist/core/remote-env.d.ts +42 -8
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +19 -4
- package/dist/core/resume-startup-cause.js +25 -6
- package/dist/core/rewind-conversation.d.ts +4 -0
- package/dist/core/rewrite-rejudge.d.ts +9 -1
- package/dist/core/rewrite-rejudge.js +11 -1
- package/dist/core/rule-offer-read.js +3 -2
- package/dist/core/runner/assemble-result.d.ts +21 -11
- package/dist/core/runner/assemble-result.js +24 -4
- package/dist/core/runner/boundary-reminders.d.ts +104 -0
- package/dist/core/runner/boundary-reminders.js +108 -0
- package/dist/core/runner/branch-writeback.d.ts +21 -7
- package/dist/core/runner/branch-writeback.js +44 -6
- package/dist/core/runner/command-sandbox-frame.js +2 -1
- package/dist/core/runner/compact-session.js +11 -4
- package/dist/core/runner/constraint-layers.d.ts +24 -5
- package/dist/core/runner/constraint-layers.js +21 -2
- package/dist/core/runner/continuation-gate.js +3 -1
- package/dist/core/runner/contracts.d.ts +83 -13
- package/dist/core/runner/cross-boundary-lane.js +2 -1
- package/dist/core/runner/delegation-owner.d.ts +246 -45
- package/dist/core/runner/delegation-owner.js +237 -63
- package/dist/core/runner/expire-settle.d.ts +17 -0
- package/dist/core/runner/expire-settle.js +8 -2
- package/dist/core/runner/file-history-request.d.ts +4 -3
- package/dist/core/runner/file-history-request.js +4 -1
- package/dist/core/runner/file-history-restore.d.ts +11 -3
- package/dist/core/runner/file-history-restore.js +11 -3
- package/dist/core/runner/gate-exit.d.ts +22 -1
- package/dist/core/runner/gate-exit.js +12 -14
- package/dist/core/runner/nested-memory-content.js +1 -1
- package/dist/core/runner/nested-memory-lane.d.ts +10 -2
- package/dist/core/runner/nested-memory-lane.js +29 -8
- package/dist/core/runner/own-model-money-door.d.ts +13 -0
- package/dist/core/runner/own-model-money-door.js +17 -0
- package/dist/core/runner/park-commit.d.ts +4 -2
- package/dist/core/runner/park-commit.js +2 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +4 -0
- package/dist/core/runner/permission-rule-lanes.js +7 -0
- package/dist/core/runner/person-path-rows.js +1 -1
- package/dist/core/runner/placement-fence.d.ts +8 -2
- package/dist/core/runner/placement-fence.js +8 -3
- package/dist/core/runner/policy-throw.d.ts +3 -2
- package/dist/core/runner/policy-throw.js +2 -2
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +23 -14
- package/dist/core/runner/prepare-acquire-reconcile.js +33 -15
- package/dist/core/runner/prepare-artifact.d.ts +14 -1
- package/dist/core/runner/prepare-artifact.js +7 -2
- package/dist/core/runner/prepare-ask-lane.d.ts +8 -0
- package/dist/core/runner/prepare-ask-lane.js +14 -5
- package/dist/core/runner/prepare-boundary-parks.js +5 -4
- package/dist/core/runner/prepare-config-doors.d.ts +9 -4
- package/dist/core/runner/prepare-config-doors.js +25 -8
- package/dist/core/runner/prepare-defer-classify.d.ts +8 -4
- package/dist/core/runner/prepare-defer-classify.js +6 -6
- package/dist/core/runner/prepare-execution-env.d.ts +4 -1
- package/dist/core/runner/prepare-execution-env.js +8 -3
- package/dist/core/runner/prepare-file-history.d.ts +26 -0
- package/dist/core/runner/prepare-file-history.js +15 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -3
- package/dist/core/runner/prepare-inherited-gate.js +9 -2
- package/dist/core/runner/prepare-leg-adoption.d.ts +2 -2
- package/dist/core/runner/prepare-park-ask.js +8 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +5 -0
- package/dist/core/runner/prepare-policy-chain.js +18 -7
- package/dist/core/runner/prepare-prompt-assembly.d.ts +3 -0
- package/dist/core/runner/prepare-prompt-assembly.js +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
- package/dist/core/runner/prepare-suspend-saga.js +19 -5
- package/dist/core/runner/prepare-task.d.ts +2 -5
- package/dist/core/runner/prepare-task.js +71 -26
- package/dist/core/runner/prepare-turn-wiring.js +7 -5
- package/dist/core/runner/prepare-workspace-restore.js +59 -28
- package/dist/core/runner/read-root-grant.d.ts +1 -0
- package/dist/core/runner/read-root-grant.js +1 -2
- package/dist/core/runner/resume-admission.d.ts +3 -0
- package/dist/core/runner/resume-admission.js +6 -4
- package/dist/core/runner/resume-apply.js +7 -5
- package/dist/core/runner/resume-claim.d.ts +2 -2
- package/dist/core/runner/resume-claim.js +4 -4
- package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
- package/dist/core/runner/resume-policy-outcome.js +6 -4
- package/dist/core/runner/resume-preflight.d.ts +3 -0
- package/dist/core/runner/resume-preflight.js +10 -3
- package/dist/core/runner/rewind-conversation.js +11 -4
- package/dist/core/runner/rewind-files.js +29 -14
- package/dist/core/runner/rewind-outcome.d.ts +27 -0
- package/dist/core/runner/rewind-outcome.js +14 -0
- package/dist/core/runner/run-attachment-seats.js +2 -1
- package/dist/core/runner/run-clock-and-content.js +2 -0
- package/dist/core/runner/run-identity-wiring.js +2 -0
- package/dist/core/runner/run-leg.js +11 -1
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -2
- package/dist/core/runner/run-settle-and-teardown.d.ts +4 -2
- package/dist/core/runner/run-settle-and-teardown.js +52 -40
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +5 -4
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +3 -3
- package/dist/core/runner/run-turn-boundary.js +7 -0
- package/dist/core/runner/runtask.d.ts +7 -4
- package/dist/core/runner/runtask.js +18 -9
- package/dist/core/runner/session-call-grant-station.d.ts +64 -0
- package/dist/core/runner/session-call-grant-station.js +119 -0
- package/dist/core/runner/session-file-state-replay.js +2 -2
- package/dist/core/runner/session-prompt-seats.d.ts +95 -0
- package/dist/core/runner/session-prompt-seats.js +62 -0
- package/dist/core/runner/session-rule-policy.js +1 -1
- package/dist/core/runner/session-write-ledger.d.ts +8 -0
- package/dist/core/runner/session-write-ledger.js +16 -0
- package/dist/core/runner/side-call-account.js +5 -1
- package/dist/core/runner/stop-tail-notice.d.ts +7 -0
- package/dist/core/runner/stop-tail-notice.js +23 -8
- package/dist/core/runner/stream-reap.js +4 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -1
- package/dist/core/runner/stream-settle-backstop.js +17 -18
- package/dist/core/runner/terminal-account.js +17 -8
- package/dist/core/runner/terminal-projection.d.ts +3 -2
- package/dist/core/runner/terminal-projection.js +1 -1
- package/dist/core/runner/tool-turn-repair-seat.d.ts +2 -2
- package/dist/core/runner/tool-turn-repair-seat.js +12 -7
- package/dist/core/runner/turn-attachments.d.ts +22 -1
- package/dist/core/runner/turn-attachments.js +20 -3
- package/dist/core/runner-deps.d.ts +6 -2
- package/dist/core/secret-env.d.ts +26 -6
- package/dist/core/secret-env.js +6 -6
- package/dist/core/session-call-grant-screen.d.ts +58 -0
- package/dist/core/session-call-grant-screen.js +18 -0
- package/dist/core/session-call-grant.d.ts +93 -0
- package/dist/core/session-call-grant.js +524 -0
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +8 -3
- package/dist/core/session-policy-store.d.ts +14 -0
- package/dist/core/session-policy-store.js +16 -2
- package/dist/core/session-store.d.ts +18 -1
- package/dist/core/session-store.js +20 -4
- package/dist/core/session.d.ts +36 -4
- package/dist/core/shared-artifact-reads.d.ts +93 -0
- package/dist/core/shared-artifact-reads.js +94 -0
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/skills-directory.d.ts +9 -45
- package/dist/core/skills-directory.js +9 -722
- package/dist/core/spend-account.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +22 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +363 -29
- package/dist/core/store-contracts/file-history-store-contract.d.ts +11 -3
- package/dist/core/store-contracts/file-history-store-contract.js +62 -2
- package/dist/core/store-contracts/grant-fixture.d.ts +52 -0
- package/dist/core/store-contracts/grant-fixture.js +84 -0
- package/dist/core/store-contracts/session-repo-contract.js +18 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -1
- package/dist/core/store-contracts/session-store-contract.js +211 -2
- package/dist/core/store-contracts/workflow-journal-store-contract.js +47 -8
- package/dist/core/suspend-lane-reasons.d.ts +13 -0
- package/dist/core/suspend-lane-reasons.js +5 -0
- package/dist/core/synthetic-read-verdict.d.ts +5 -3
- package/dist/core/synthetic-read-verdict.js +1 -1
- package/dist/core/task-limits.d.ts +15 -0
- package/dist/core/task-notification.d.ts +33 -7
- package/dist/core/task-notification.js +34 -9
- package/dist/core/task-registry-agent.d.ts +1 -1
- package/dist/core/task-registry-agent.js +18 -7
- package/dist/core/task-registry-shared.d.ts +29 -4
- package/dist/core/task-registry-shared.js +7 -0
- package/dist/core/task-registry.d.ts +21 -1
- package/dist/core/task-registry.js +36 -9
- package/dist/core/task-result.d.ts +55 -1
- package/dist/core/task-spec.d.ts +17 -3
- package/dist/core/terminal-cause.d.ts +68 -5
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.js +2 -1
- package/dist/core/tool-errors.js +1 -0
- package/dist/core/tool-list-grammar.d.ts +0 -47
- package/dist/core/tool-list-grammar.js +1 -75
- package/dist/core/tool-model-gate.d.ts +7 -11
- package/dist/core/tool-model-gate.js +5 -8
- package/dist/core/tool-name-aliases.js +2 -3
- package/dist/core/tool-name-readings.d.ts +4 -0
- package/dist/core/tool-name-readings.js +1 -0
- package/dist/core/tool-policy.d.ts +46 -4
- package/dist/core/tool-policy.js +47 -18
- package/dist/core/tool-result-store.d.ts +0 -24
- package/dist/core/tool-result-store.js +1 -36
- package/dist/core/tool-spec.d.ts +8 -4
- package/dist/core/untrusted-egress.js +2 -2
- package/dist/core/untrusted-text.d.ts +8 -0
- package/dist/core/untrusted-text.js +14 -0
- package/dist/core/user-attachment.d.ts +16 -1
- package/dist/core/user-attachment.js +42 -18
- package/dist/core/wiring-manifest.d.ts +4 -9
- package/dist/core/wiring-manifest.js +1 -1
- package/dist/core/workflow-journal-store.d.ts +55 -8
- package/dist/core/workflow-journal-store.js +34 -10
- package/dist/core/workflow-run-store-contract.js +56 -1
- package/dist/core/workflow-run-store.d.ts +43 -19
- package/dist/core/workflow-run-store.js +17 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
- package/dist/engine/execution-env/node-execution-env.js +4 -0
- package/dist/engine/harness/agent-harness.d.ts +10 -5
- package/dist/engine/harness/agent-harness.js +12 -4
- package/dist/engine/harness/types.d.ts +18 -0
- package/dist/engine/llm/tool-turns.d.ts +1 -1
- package/dist/engine/llm/types.d.ts +5 -4
- package/dist/engine/session/memory-repo.d.ts +15 -3
- package/dist/engine/session/memory-repo.js +21 -3
- package/dist/engine/session/memory-storage.d.ts +5 -0
- package/dist/engine/session/memory-storage.js +8 -3
- package/dist/engine/session/repo-utils.d.ts +9 -0
- package/dist/engine/session/repo-utils.js +14 -0
- package/dist/engine/session/storage-base.d.ts +20 -7
- package/dist/engine/session/storage-base.js +13 -1
- package/dist/index.d.ts +37 -19
- package/dist/index.js +30 -15
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +13 -1
- package/dist/orchestration/run-workflow-tool.js +101 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +309 -92
- package/dist/orchestration/workflow-park-adoption.js +588 -323
- package/dist/orchestration/workflow-tree-id.d.ts +66 -0
- package/dist/orchestration/workflow-tree-id.js +66 -0
- package/dist/orchestration/workflow-types.d.ts +90 -11
- package/dist/orchestration/workflow-types.js +10 -1
- package/dist/orchestration/workflow.d.ts +30 -4
- package/dist/orchestration/workflow.js +424 -114
- package/dist/prompt-assembly/catalog/constitution.js +5 -1
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +3 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +61 -22
- package/dist/prompt-assembly/catalog/environment.js +2 -2
- 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 +72 -44
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +5 -1
- package/dist/prompt-assembly/catalog/schema.js +2 -0
- package/dist/prompt-assembly/catalog/sections.js +3 -14
- package/dist/prompt-assembly/event-registry.js +2 -0
- package/dist/prompt-assembly/select.js +1 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +10 -7
- package/dist/prompt-assembly/tool-catalog.js +21 -7
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/default.d.ts +4 -1
- package/dist/prompts/default.js +6 -0
- package/dist/stores/file/checkpoint-store.d.ts +11 -10
- package/dist/stores/file/checkpoint-store.js +36 -10
- package/dist/stores/file/file-history-store.d.ts +6 -0
- package/dist/stores/file/file-history-store.js +21 -4
- package/dist/stores/file/fs-atomic.d.ts +1 -1
- package/dist/stores/file/index.d.ts +14 -4
- package/dist/stores/file/index.js +21 -5
- package/dist/stores/file/process-anchor.d.ts +9 -1
- package/dist/stores/file/session-policy-store.js +2 -17
- package/dist/stores/file/session-store.d.ts +27 -0
- package/dist/stores/file/session-store.js +81 -9
- package/dist/stores/file/workflow-journal-store.d.ts +14 -4
- package/dist/stores/file/workflow-journal-store.js +32 -24
- package/dist/stores/file/workflow-run-store.d.ts +15 -4
- package/dist/stores/file/workflow-run-store.js +76 -0
- package/dist/tools/artifact/artifact-tool.d.ts +10 -3
- package/dist/tools/artifact/artifact-tool.js +16 -1
- package/dist/tools/fs/bash-program-position.d.ts +10 -4
- package/dist/tools/fs/bash-program-position.js +11 -8
- package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -1
- package/dist/tools/fs/bash-readonly-classifier.js +9 -2
- package/dist/tools/fs/find-actions.d.ts +30 -16
- package/dist/tools/fs/find-actions.js +272 -19
- package/dist/tools/fs/fs-bash.js +8 -5
- package/dist/tools/fs/fs-shared.d.ts +0 -29
- package/dist/tools/fs/fs-shared.js +0 -5
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/read-deny.d.ts +6 -1
- package/dist/tools/fs/read-deny.js +6 -1
- package/dist/tools/fs/read-floor.d.ts +6 -0
- package/dist/tools/fs/read-floor.js +5 -1
- package/dist/tools/fs/removal-actions.d.ts +43 -0
- package/dist/tools/fs/removal-actions.js +25 -0
- package/dist/tools/fs/removal-targets.d.ts +2 -21
- package/dist/tools/fs/removal-targets.js +2 -3
- package/dist/tools/fs/safety.d.ts +37 -1
- package/dist/tools/fs/safety.js +52 -0
- package/dist/tools/fs/shell-climb.d.ts +46 -0
- package/dist/tools/fs/shell-climb.js +79 -0
- package/dist/tools/fs/shell-read-check.js +47 -19
- package/dist/tools/fs/shell-read-establish.js +36 -22
- package/dist/tools/fs/shell-read-judge.d.ts +10 -2
- package/dist/tools/fs/shell-read-judge.js +4 -4
- package/dist/tools/fs/shell-read-plan.d.ts +3 -0
- package/dist/tools/fs/shell-read-plan.js +1 -1
- package/dist/tools/fs/shell-read-workdir.js +3 -2
- package/dist/tools/fs/shell-read-write-targets.d.ts +4 -3
- package/dist/tools/fs/shell-read-write-targets.js +3 -0
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +169 -15
- package/wire-changes/core-stores-sql@7.71.0.json +40 -0
- package/wire-changes/core@7.71.0.json +5827 -0
- package/wire-changes/mods-kernel@7.71.0.json +52 -0
- package/wire-changes/primitives@7.71.0.json +473 -0
- package/wire-changes/wiki-gate@7.71.0.json +40 -0
- package/dist/core/frontmatter-fence.d.ts +0 -10
- package/dist/core/frontmatter-fence.js +0 -6
- package/dist/core/permission-rule-syntax.d.ts +0 -46
- package/dist/core/permission-rule-syntax.js +0 -52
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HolderJudge, HolderStoreKind } from "../checkpoint-generation.js";
|
|
2
|
+
/**
|
|
3
|
+
* The grant fixture a store contract binding hands the kit's holder cells (`grants`): holders minted against the SAME judge the
|
|
4
|
+
* binding's `composed` store was built with. A host mints them with its real encoding and run rows it controls (a run whose current
|
|
5
|
+
* leg it can move, a run it can end, a run row it can give a status word outside its live set); the in-tree bindings use
|
|
6
|
+
* {@link inMemoryGrantTable}.
|
|
7
|
+
* - `current()` — a grant naming its run's current leg, the run live: every write carrying it lands;
|
|
8
|
+
* - `replaced()` — the same run moved to another leg since the grant was given;
|
|
9
|
+
* - `ended()` — the grant's leg is still the run's last, but the run has ended;
|
|
10
|
+
* - `unknownStatus()` — the run row's status is a word outside the judge's live set (the judge must answer `false`: fail-closed);
|
|
11
|
+
* - `malformed` — a value no grant is encoded as (the judge throws; the write throws with it).
|
|
12
|
+
* Each function mints a fresh grant on each call (a run of its own), so cells never share a run.
|
|
13
|
+
*/
|
|
14
|
+
export interface ContractGrants {
|
|
15
|
+
current(): string;
|
|
16
|
+
replaced(): string;
|
|
17
|
+
ended(): string;
|
|
18
|
+
unknownStatus(): string;
|
|
19
|
+
readonly malformed: string;
|
|
20
|
+
/** Optional: end the run a `current()` holder named (as the host's own grant table would — a leg handed on, a run ended). Given, the
|
|
21
|
+
* kit proves the judgement is made afresh on every write: a holder that wrote while current is refused once retired (a store that
|
|
22
|
+
* remembers a holder's first answer passes every other cell). */
|
|
23
|
+
retire?(holder: string): void;
|
|
24
|
+
}
|
|
25
|
+
/** The three dead grants every holder cell runs over, each freshly minted, labelled for the cell's sentence. */
|
|
26
|
+
export declare function deadGrants(grants: ContractGrants): Array<readonly [label: string, holder: string]>;
|
|
27
|
+
/**
|
|
28
|
+
* THE reference grant table of the in-tree bindings: an in-memory run table and the judge over it, by the one sentence of
|
|
29
|
+
* {@link HolderJudge} — a holder is current exactly when it decodes ({@link decodeGrantHolder}; a value that does not throws
|
|
30
|
+
* `holder.malformed`), names a run the table holds, names that run's current leg, and the run's status is a live word (`running` or
|
|
31
|
+
* `parked`); a status outside that set answers `false`. Build the store under test with `holderIsCurrent`, and hand the kit `grants`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function inMemoryGrantTable(): {
|
|
34
|
+
readonly holderIsCurrent: HolderJudge;
|
|
35
|
+
readonly grants: ContractGrants;
|
|
36
|
+
};
|
|
37
|
+
/** The refusal a holder cell expects of a create-shaped write with a dead grant: `holder.superseded` (`isHolderSuperseded`). */
|
|
38
|
+
export declare function rejectsSuperseded(fn: () => unknown, what: string): Promise<void>;
|
|
39
|
+
/** A write carrying a malformed holder: the judge throws, and the write throws with it — anything but `holder.superseded` (a value no
|
|
40
|
+
* grant is encoded as is not a grant that ended; a layer that turns the judge's throw into a refusal hides a wiring fault). */
|
|
41
|
+
export declare function rejectsMalformed(fn: () => unknown, what: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* The holder binding of a store kit, judged before any holder cell runs: `undefined` when the binding judges no holder (no `composed`,
|
|
44
|
+
* no `grants`, and the bare store declares no `fence`); otherwise both must be given and the composed store must declare
|
|
45
|
+
* `{ holder: "writes" }` ({@link readStoreFence}: the retired `{ holder: true }` and every malformed form fail the cell, never skip it).
|
|
46
|
+
* A bare store declaring a fence beside no `composed` fails too: the holder cells are proven on the store as the deployment composes
|
|
47
|
+
* it — every wrapper included — because a wrapper is what silently drops a holder.
|
|
48
|
+
*/
|
|
49
|
+
export declare function holderBinding<S>(kind: HolderStoreKind, bareDeclares: boolean, composed: (() => S) | undefined, grants: ContractGrants | undefined): {
|
|
50
|
+
composed: () => S;
|
|
51
|
+
grants: ContractGrants;
|
|
52
|
+
} | undefined;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { strict as assert } from "node:assert";
|
|
2
|
+
import { decodeGrantHolder, encodeGrantHolder, isHolderSuperseded } from "../grant-holder.js";
|
|
3
|
+
import { readStoreFence } from "../checkpoint-generation.js";
|
|
4
|
+
export function deadGrants(grants) {
|
|
5
|
+
return [
|
|
6
|
+
["replaced", grants.replaced()],
|
|
7
|
+
["ended", grants.ended()],
|
|
8
|
+
["unknownStatus", grants.unknownStatus()],
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
const LIVE_STATUSES = new Set(["running", "parked"]);
|
|
12
|
+
export function inMemoryGrantTable() {
|
|
13
|
+
const runs = new Map();
|
|
14
|
+
let n = 0;
|
|
15
|
+
const run = (leg, status) => {
|
|
16
|
+
const taskId = `kit-run-${++n}`;
|
|
17
|
+
runs.set(taskId, { leg, status });
|
|
18
|
+
return taskId;
|
|
19
|
+
};
|
|
20
|
+
const holderIsCurrent = (holder) => {
|
|
21
|
+
const { taskId, legId } = decodeGrantHolder(holder);
|
|
22
|
+
const row = runs.get(taskId);
|
|
23
|
+
return row !== undefined && row.leg === legId && LIVE_STATUSES.has(row.status);
|
|
24
|
+
};
|
|
25
|
+
const grants = {
|
|
26
|
+
current: () => encodeGrantHolder({ taskId: run("leg-1", "running"), legId: "leg-1" }),
|
|
27
|
+
replaced: () => encodeGrantHolder({ taskId: run("leg-2", "running"), legId: "leg-1" }),
|
|
28
|
+
ended: () => encodeGrantHolder({ taskId: run("leg-1", "completed"), legId: "leg-1" }),
|
|
29
|
+
unknownStatus: () => encodeGrantHolder({ taskId: run("leg-1", "kit-status-outside-the-live-set"), legId: "leg-1" }),
|
|
30
|
+
malformed: "kit-not-a-grant",
|
|
31
|
+
retire: (holder) => {
|
|
32
|
+
const { taskId } = decodeGrantHolder(holder);
|
|
33
|
+
const row = runs.get(taskId);
|
|
34
|
+
if (row !== undefined)
|
|
35
|
+
runs.set(taskId, { leg: row.leg, status: "completed" });
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
return { holderIsCurrent, grants };
|
|
39
|
+
}
|
|
40
|
+
export async function rejectsSuperseded(fn, what) {
|
|
41
|
+
let thrown;
|
|
42
|
+
let threw = false;
|
|
43
|
+
try {
|
|
44
|
+
await fn();
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
thrown = err;
|
|
48
|
+
threw = true;
|
|
49
|
+
}
|
|
50
|
+
assert.ok(threw, `${what}: a write carrying a grant that is not current must be refused, got a result`);
|
|
51
|
+
if (!isHolderSuperseded(thrown))
|
|
52
|
+
assert.fail(`${what}: the refusal must be holder.superseded (holderSupersededError), got ${describeThrown(thrown)}`);
|
|
53
|
+
}
|
|
54
|
+
function describeThrown(thrown) {
|
|
55
|
+
return thrown instanceof Error ? `an ${thrown.constructor === Error ? "Error" : "error object"}` : typeof thrown;
|
|
56
|
+
}
|
|
57
|
+
export async function rejectsMalformed(fn, what) {
|
|
58
|
+
let thrown;
|
|
59
|
+
let threw = false;
|
|
60
|
+
try {
|
|
61
|
+
await fn();
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
thrown = err;
|
|
65
|
+
threw = true;
|
|
66
|
+
}
|
|
67
|
+
assert.ok(threw, `${what}: a write carrying a malformed holder must throw (the judge throws, the write throws with it), got a result`);
|
|
68
|
+
if (isHolderSuperseded(thrown))
|
|
69
|
+
assert.fail(`${what}: a malformed holder was answered holder.superseded — the judge's throw must reach the caller, not be read as a dead grant`);
|
|
70
|
+
}
|
|
71
|
+
export function holderBinding(kind, bareDeclares, composed, grants) {
|
|
72
|
+
if (!bareDeclares && composed === undefined && grants === undefined)
|
|
73
|
+
return undefined;
|
|
74
|
+
assert.ok(composed !== undefined && grants !== undefined, `a ${kind} store binding that judges holders hands the kit both \`composed\` (the store as the deployment composes it, every wrapper included) and \`grants\` (holders minted against that store's judge) — got ${composed === undefined ? "no composed" : "composed"} and ${grants === undefined ? "no grants" : "grants"}`);
|
|
75
|
+
return {
|
|
76
|
+
composed: () => {
|
|
77
|
+
const store = composed();
|
|
78
|
+
const fence = readStoreFence(kind, `the kit's composed ${kind} store`, store);
|
|
79
|
+
assert.ok(fence !== undefined, `the composed ${kind} store must declare \`fence = { holder: "writes" }\` — a wrapper that does not forward its inner store's declaration fences nothing`);
|
|
80
|
+
return store;
|
|
81
|
+
},
|
|
82
|
+
grants,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -510,6 +510,24 @@ export async function sessionRepoContract(make, runAssertion) {
|
|
|
510
510
|
await repo.delete({ id: A, createdAt: "" }, { row: now.head, log: sessionLogMarkOf(now.entries) });
|
|
511
511
|
assert.equal(await logIds(repo, A), undefined, "the row and log as read: deleted");
|
|
512
512
|
});
|
|
513
|
+
run("recordOwner (where the repo has it): a row recording no owner takes the name on the occupant its caller read, and nothing else of the row changes; a row recording a name is answered as read, unwritten; another occupant is refused conflict; a session opened before the write keeps appending to the row", async () => {
|
|
514
|
+
const repo = make();
|
|
515
|
+
if (repo.recordOwner === undefined || repo.headOf === undefined || cellsOf(repo) !== "engine")
|
|
516
|
+
return;
|
|
517
|
+
const sess = await repo.create({ id: A });
|
|
518
|
+
await sess.getStorage().appendEntry(SESSION_ENTRY("e1", null));
|
|
519
|
+
const before = (await repo.headOf(A));
|
|
520
|
+
assert.equal(before.owner, null, "a create naming no owner records none");
|
|
521
|
+
const otherOccupant = { row: { owner: null, incarnation: "kit-occupant" } };
|
|
522
|
+
assert.equal(await conflictOf(() => repo.recordOwner(A, "kit-alice", otherOccupant)), "conflict", "another occupant: not written");
|
|
523
|
+
assert.equal((await repo.headOf(A)).owner, null, "the refused write wrote nothing");
|
|
524
|
+
const claimed = await repo.recordOwner(A, "kit-alice", { row: { owner: null, ...(before.incarnation !== undefined ? { incarnation: before.incarnation } : {}) } });
|
|
525
|
+
assert.deepEqual(claimed, { ...before, owner: "kit-alice" }, "the head the write committed");
|
|
526
|
+
assert.deepEqual(await repo.recordOwner(A, "kit-bob", { row: { owner: null, ...(before.incarnation !== undefined ? { incarnation: before.incarnation } : {}) } }), claimed, "a row recording a name: answered as read");
|
|
527
|
+
await sess.getStorage().appendEntry(SESSION_ENTRY("e2", "e1"));
|
|
528
|
+
assert.deepEqual(await logIds(repo, A), ["e1", "e2"], "the session opened before the write appends to the row");
|
|
529
|
+
assert.deepEqual(await repo.headOf(A), { ...claimed, leafId: "e2" }, "the owner stays, the leaf follows the append");
|
|
530
|
+
});
|
|
513
531
|
run("TtlSessionStore over a repo whose host holds the occupant cells is refused at construction, coded config.invalid_argument and naming the missing occupant source — never a store whose every occupant comparison reads \"same\"", async () => {
|
|
514
532
|
const repo = make();
|
|
515
533
|
if (cellsOf(repo) === "engine")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type SessionStore } from "../session.js";
|
|
2
2
|
import { type ContractAssertionRunner } from "./contract-harness.js";
|
|
3
|
+
import { type ContractGrants } from "./grant-fixture.js";
|
|
3
4
|
/**
|
|
4
5
|
* The cross-backend contract for {@link SessionStore} as the interface states it TODAY — what a store must
|
|
5
6
|
* do so that the engine, a deployment's authorizer and a shell read the same answers off it whether the
|
|
@@ -30,6 +31,9 @@ import { type ContractAssertionRunner } from "./contract-harness.js";
|
|
|
30
31
|
* Also since 7.70.0: a stored prompt-epoch record that does not read is kept as written and changes nothing about the pin a reopened
|
|
31
32
|
* session answers — a store that wakes a bounded window answers `getEpochAnchor` with the nearest record below its floor that reads
|
|
32
33
|
* (`walkPromptEpochCarriers`). Whether a bounded store answers below its floor at all is not judged here.
|
|
34
|
+
* Since 7.71.0: `recordOwner` (reported as its own member, judged on a store with the ownership pair) — the claim of a row that records
|
|
35
|
+
* no owner records the claimant's name in one step only on the occupant it names, leaves a row that records a name as it is, gives one
|
|
36
|
+
* owner to two concurrent claims, refuses a name that is not one, and leaves every session handed out before it writing to the row.
|
|
33
37
|
*/
|
|
34
38
|
export interface SessionStoreContractHooks {
|
|
35
39
|
/** Delete `sessionId`'s session ROW through the backend's own deletion path (history and all), so that a later
|
|
@@ -56,11 +60,21 @@ export interface SessionStoreContractHooks {
|
|
|
56
60
|
/** Instead of `tokenlessRow`: why this store holds no row written before occupant tokens (a non-empty string — its occupant cell was
|
|
57
61
|
* never empty, say how); the cases that need such a row are reported absent. Given beside `tokenlessRow`, refused. */
|
|
58
62
|
noTokenlessRows?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The holder binding (the S-H cells), given together with {@link grants}: a FRESH store AS THE DEPLOYMENT COMPOSES IT — every wrapper
|
|
65
|
+
* included (a cache, a routing layer) — built with the judge `grants` mints its holders against. Bind the composition itself: a cell
|
|
66
|
+
* run on an inner store cannot see a wrapper, and a wrapper is what silently drops `SessionWriteOptions.holder` (or answers a row's
|
|
67
|
+
* occupant before the holder). {@link reopen} must accept the stores it returns. Required (both) for a binding whose `make()` store
|
|
68
|
+
* declares `fence`; absent with no `fence` ⇒ the holder cells are reported absent (`holder`).
|
|
69
|
+
*/
|
|
70
|
+
composed?: () => SessionStore;
|
|
71
|
+
/** The grant fixture of {@link composed} ({@link ContractGrants}: current / replaced / ended / unknownStatus / malformed). */
|
|
72
|
+
grants?: ContractGrants;
|
|
59
73
|
runAssertion?: ContractAssertionRunner;
|
|
60
74
|
/** Optional faces (plus the replica and tokenlessRow hooks, and `requireExisting` — absent = the store rejects the option, its other
|
|
61
75
|
* legal mode) a run verified or found absent; reported per judging case, after its assertions held. */
|
|
62
76
|
onOptionalMember?: (report: {
|
|
63
|
-
member: "requireExisting" | "forget" | "fork" | "list" | "noteTaskRun" | "listPlaced" | "placements" | "headOf" | "ownership" | "replica" | "tokenlessRow" | "openRefusedRow" | "logTransfer" | "delete" | "deleteUnreadable";
|
|
77
|
+
member: "requireExisting" | "forget" | "fork" | "list" | "noteTaskRun" | "listPlaced" | "placements" | "headOf" | "ownership" | "replica" | "tokenlessRow" | "openRefusedRow" | "logTransfer" | "delete" | "deleteUnreadable" | "holder" | "recordOwner";
|
|
64
78
|
status: "verified" | "absent";
|
|
65
79
|
}) => void;
|
|
66
80
|
}
|
|
@@ -5,10 +5,11 @@ import { SessionError, StoredSession, uuidv7 } from "../../internal/harness.js";
|
|
|
5
5
|
import { promptIdentityOf, walkPromptEpochCarriers } from "../../prompt-assembly/epoch.js";
|
|
6
6
|
import { textContentHashOf } from "../canonical-json.js";
|
|
7
7
|
import { SESSION_LIST_LIMITS, hasSessionFork, isSessionConflict, } from "../session.js";
|
|
8
|
-
import { readMember } from "../thrown-value.js";
|
|
8
|
+
import { readMember, thrownText } from "../thrown-value.js";
|
|
9
9
|
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
10
10
|
import { receiptRefusal, receiveOwnProperties } from "../own-property-receipt.js";
|
|
11
11
|
import { beginContract } from "./contract-harness.js";
|
|
12
|
+
import { deadGrants, holderBinding, rejectsMalformed, rejectsSuperseded } from "./grant-fixture.js";
|
|
12
13
|
const AT = "2026-10-18T00:00:00.000Z";
|
|
13
14
|
const AT_MS = Date.parse(AT);
|
|
14
15
|
const STAMP = { api: "openai-completions", provider: "contract-kit", model: "contract-kit-model" };
|
|
@@ -148,7 +149,8 @@ function assertActivityOrder(rows, newerToOlder, what) {
|
|
|
148
149
|
}
|
|
149
150
|
const HOOK_WORDS = { subject: "SessionStoreContractHooks", unit: "hook", moment: "at sessionStoreContract" };
|
|
150
151
|
const REQUIRED_HOOKS = ["deleteSession", "reopen"];
|
|
151
|
-
const OPTIONAL_HOOKS = ["replica", "tokenlessRow", "openRefusedRow", "runAssertion", "onOptionalMember"];
|
|
152
|
+
const OPTIONAL_HOOKS = ["replica", "tokenlessRow", "openRefusedRow", "composed", "runAssertion", "onOptionalMember"];
|
|
153
|
+
const GRANT_FIXTURE_FUNCTIONS = ["current", "replaced", "ended", "unknownStatus"];
|
|
152
154
|
function receiveHooks(make, hooks) {
|
|
153
155
|
if (typeof make !== "function")
|
|
154
156
|
throw receiptRefusal(`sessionStoreContract: make must be a function that returns a fresh SessionStore, got ${typeof make}`);
|
|
@@ -170,6 +172,21 @@ function receiveHooks(make, hooks) {
|
|
|
170
172
|
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
173
|
if (none !== undefined && readMember(got, "tokenlessRow") !== undefined)
|
|
172
174
|
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`);
|
|
175
|
+
const grants = readMember(got, "grants");
|
|
176
|
+
if (grants !== undefined) {
|
|
177
|
+
if (typeof grants !== "object" || grants === null)
|
|
178
|
+
throw receiptRefusal(`${HOOK_WORDS.subject}.grants must be a grant fixture record when present, got ${describeRejectedValue(grants)}`);
|
|
179
|
+
for (const name of GRANT_FIXTURE_FUNCTIONS)
|
|
180
|
+
if (typeof readMember(grants, name) !== "function")
|
|
181
|
+
throw receiptRefusal(`${HOOK_WORDS.subject}.grants.${name} must be a function minting a holder`);
|
|
182
|
+
if (typeof readMember(grants, "malformed") !== "string")
|
|
183
|
+
throw receiptRefusal(`${HOOK_WORDS.subject}.grants.malformed must be a string no grant is encoded as`);
|
|
184
|
+
const retire = readMember(grants, "retire");
|
|
185
|
+
if (retire !== undefined && typeof retire !== "function")
|
|
186
|
+
throw receiptRefusal(`${HOOK_WORDS.subject}.grants.retire must be a function when present`);
|
|
187
|
+
}
|
|
188
|
+
if ((grants === undefined) !== (readMember(got, "composed") === undefined))
|
|
189
|
+
throw receiptRefusal(`${HOOK_WORDS.subject} gives ${grants === undefined ? "composed without grants" : "grants without composed"} — the holder cells take both: the composed store and the holders minted against its judge`);
|
|
173
190
|
return got;
|
|
174
191
|
}
|
|
175
192
|
export function sessionStoreContract(make, hooks) {
|
|
@@ -211,6 +228,8 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
211
228
|
logTransfer: (s) => hasHead(s) && typeof s.logTransfer === "object" && s.logTransfer !== null,
|
|
212
229
|
delete: (s) => hasHead(s) && typeof s.delete === "function",
|
|
213
230
|
deleteUnreadable: (s) => hasHead(s) && typeof s.deleteUnreadable === "function",
|
|
231
|
+
holder: (s) => s.fence !== undefined || hooks.composed !== undefined,
|
|
232
|
+
recordOwner: (s) => hasOwnership(s) && typeof s.recordOwner === "function",
|
|
214
233
|
};
|
|
215
234
|
const FACE_OWED = {
|
|
216
235
|
tokenlessRow: (s) => s.durability === "durable" && hooks.noTokenlessRows === undefined
|
|
@@ -233,6 +252,98 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
233
252
|
for (const m of needs)
|
|
234
253
|
report(m, "verified");
|
|
235
254
|
});
|
|
255
|
+
const holderRun = (name, fn) => run(name, async (bare, open) => {
|
|
256
|
+
const binding = holderBinding("session", bare.fence !== undefined, hooks.composed, hooks.grants);
|
|
257
|
+
if (binding === undefined) {
|
|
258
|
+
report("holder", "absent");
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
await fn(await open(binding.composed()), binding.grants, open);
|
|
262
|
+
report("holder", "verified");
|
|
263
|
+
});
|
|
264
|
+
const heldSession = async (store) => {
|
|
265
|
+
const id = freshId();
|
|
266
|
+
const { session } = await store.acquire(id);
|
|
267
|
+
await append(session, userEntry("h0", null));
|
|
268
|
+
return { id, session };
|
|
269
|
+
};
|
|
270
|
+
holderRun("[holder] S-H0 through the composed store, a dead grant (replaced / ended / unknown status) is refused holder.superseded on an append and on a leaf move, and another fresh handle reads the log and the leaf unchanged", async (store, grants, open) => {
|
|
271
|
+
const { id, session } = await heldSession(store);
|
|
272
|
+
for (const [label, dead] of deadGrants(grants)) {
|
|
273
|
+
await rejectsSuperseded(() => append(session, userEntry(`x-${label}`, "h0"), { holder: dead }), `append (${label})`);
|
|
274
|
+
await rejectsSuperseded(() => session.getStorage().setLeafId(null, { holder: dead }), `setLeafId (${label})`);
|
|
275
|
+
}
|
|
276
|
+
assert.deepEqual(await entryIds(session), ["h0"], "the refused writes appended nothing");
|
|
277
|
+
const other = await open(hooks.reopen(store));
|
|
278
|
+
const again = (await other.acquire(id)).session;
|
|
279
|
+
assert.deepEqual(await entryIds(again), ["h0"], "a fresh handle reads the log unchanged");
|
|
280
|
+
assert.equal(await again.getStorage().getLeafId(), "h0", "a fresh handle reads the leaf unchanged");
|
|
281
|
+
});
|
|
282
|
+
holderRun("[holder] S-H1 a current grant lands: an append and a leaf move carrying it are written; no holder lands as before", async (store, grants) => {
|
|
283
|
+
const { session } = await heldSession(store);
|
|
284
|
+
await append(session, userEntry("h1", "h0"), { holder: grants.current() });
|
|
285
|
+
assert.equal(await session.getStorage().getLeafId(), "h1", "the append carrying the current grant landed");
|
|
286
|
+
await session.getStorage().setLeafId("h0", { holder: grants.current(), expectedLeafId: "h1" });
|
|
287
|
+
assert.equal(await session.getStorage().getLeafId(), "h0", "the leaf move carrying the current grant landed");
|
|
288
|
+
await append(session, userEntry("h2", "h0"), { expectedLeafId: "h0" });
|
|
289
|
+
assert.deepEqual(await pathIds(session), ["h0", "h2"], "the writes carrying the current grant and the one carrying none all landed");
|
|
290
|
+
if (grants.retire !== undefined) {
|
|
291
|
+
const h = grants.current();
|
|
292
|
+
await append(session, userEntry("h3", "h2"), { holder: h });
|
|
293
|
+
await session.getStorage().setLeafId("h2", { holder: h });
|
|
294
|
+
assert.equal(await session.getStorage().getLeafId(), "h2", "the warm leaf move landed");
|
|
295
|
+
grants.retire(h);
|
|
296
|
+
await rejectsSuperseded(() => append(session, userEntry("h4", "h2"), { holder: h }), "an append after the holder was retired");
|
|
297
|
+
await rejectsSuperseded(() => session.getStorage().setLeafId("h3", { holder: h }), "a leaf move after the holder was retired");
|
|
298
|
+
assert.equal(await session.getStorage().getLeafId(), "h2", "the refused leaf move moved nothing");
|
|
299
|
+
assert.equal((await entryIds(session)).includes("h4"), false, "the refused append wrote nothing");
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
holderRun("[holder] S-H3 a dead grant beside a stale expected leaf is answered holder.superseded, not conflict — the holder is judged first", async (store, grants) => {
|
|
303
|
+
const { session } = await heldSession(store);
|
|
304
|
+
for (const [label, dead] of deadGrants(grants)) {
|
|
305
|
+
await rejectsSuperseded(() => append(session, userEntry(`x-${label}`, "h0"), { holder: dead, expectedLeafId: "kit-stale-leaf" }), `append (${label})`);
|
|
306
|
+
await rejectsSuperseded(() => session.getStorage().setLeafId(null, { holder: dead, expectedLeafId: "kit-stale-leaf" }), `setLeafId (${label})`);
|
|
307
|
+
}
|
|
308
|
+
assert.deepEqual(await entryIds(session), ["h0"], "nothing was written");
|
|
309
|
+
});
|
|
310
|
+
holderRun("[holder] S-H3b on the composed store, a dead grant through a handle whose row was deleted and created again (another occupant) is still answered holder.superseded — append and leaf move", async (store, grants) => {
|
|
311
|
+
const { id, session } = await heldSession(store);
|
|
312
|
+
await hooks.deleteSession(store, id);
|
|
313
|
+
await store.acquire(id);
|
|
314
|
+
for (const [label, dead] of deadGrants(grants)) {
|
|
315
|
+
await rejectsSuperseded(() => append(session, userEntry(`x-${label}`, "h0"), { holder: dead }), `append (${label})`);
|
|
316
|
+
await rejectsSuperseded(() => session.getStorage().setLeafId(null, { holder: dead }), `setLeafId (${label})`);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
holderRun("[holder] S-H4 no holder: a write is judged exactly as before — it lands, and a stale expected leaf is the engine's conflict", async (store) => {
|
|
320
|
+
const { session } = await heldSession(store);
|
|
321
|
+
await append(session, userEntry("h1", "h0"), { expectedLeafId: "h0" });
|
|
322
|
+
await rejectsWithConflict(() => append(session, userEntry("h2", "h0"), { expectedLeafId: "h0" }), "a stale expected leaf");
|
|
323
|
+
assert.deepEqual(await pathIds(session), ["h0", "h1"]);
|
|
324
|
+
});
|
|
325
|
+
holderRun("[holder] S-H5 two handles on one row: a write refused for its dead grant leaves the other handle's view and its compare-and-set as they were", async (store, grants) => {
|
|
326
|
+
const { id, session } = await heldSession(store);
|
|
327
|
+
const second = (await store.acquire(id)).session;
|
|
328
|
+
for (const [label, dead] of deadGrants(grants)) {
|
|
329
|
+
await rejectsSuperseded(() => append(session, userEntry(`x-${label}`, "h0"), { holder: dead }), `append (${label})`);
|
|
330
|
+
}
|
|
331
|
+
await append(second, userEntry("h1", "h0"), { expectedLeafId: "h0" });
|
|
332
|
+
assert.deepEqual(await pathIds(second), ["h0", "h1"]);
|
|
333
|
+
});
|
|
334
|
+
holderRun("[holder] S-H6 a malformed holder: the judge throws, the write throws, and nothing was written", async (store, grants) => {
|
|
335
|
+
const { session } = await heldSession(store);
|
|
336
|
+
await rejectsMalformed(() => append(session, userEntry("x", "h0"), { holder: grants.malformed }), "append");
|
|
337
|
+
await rejectsMalformed(() => session.getStorage().setLeafId(null, { holder: grants.malformed }), "setLeafId");
|
|
338
|
+
assert.deepEqual(await entryIds(session), ["h0"]);
|
|
339
|
+
assert.equal(await session.getStorage().getLeafId(), "h0");
|
|
340
|
+
});
|
|
341
|
+
holderRun("[holder] S-H7 a run row whose status is outside the judge's live set is not held: an append and a leaf move are refused holder.superseded (fail-closed)", async (store, grants) => {
|
|
342
|
+
const { session } = await heldSession(store);
|
|
343
|
+
await rejectsSuperseded(() => append(session, userEntry("x", "h0"), { holder: grants.unknownStatus() }), "append");
|
|
344
|
+
await rejectsSuperseded(() => session.getStorage().setLeafId(null, { holder: grants.unknownStatus() }), "setLeafId");
|
|
345
|
+
assert.deepEqual(await entryIds(session), ["h0"]);
|
|
346
|
+
});
|
|
236
347
|
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
348
|
const dir = store.transcriptDirectory;
|
|
238
349
|
if (dir === undefined)
|
|
@@ -1144,6 +1255,104 @@ async function runSessionStoreContract(make, hooks) {
|
|
|
1144
1255
|
}
|
|
1145
1256
|
assert.deepEqual(await headOf(store, id), before, "admission changes only through a write of the row");
|
|
1146
1257
|
});
|
|
1258
|
+
const claimOf = (head) => ({ row: { owner: null, ...(head.incarnation !== undefined ? { incarnation: head.incarnation } : {}) } });
|
|
1259
|
+
faceRun("[recordOwner] a row that records no owner, claimed naming the occupant its caller read: the owner is recorded and nothing else of the row changes (its occupant, its log, its leaf); the answer is that head; it reads back after the cached view is dropped and on a store reopened over the same rows (a restart)", ["recordOwner"], async (store, open) => {
|
|
1260
|
+
const [registered, acquired] = [freshId(), freshId()];
|
|
1261
|
+
await store.register(registered, null);
|
|
1262
|
+
const held = await store.acquire(acquired);
|
|
1263
|
+
await append(held.session, userEntry("c1", null));
|
|
1264
|
+
for (const [id, what] of [[registered, "a row registered anonymous"], [acquired, "a row an acquire naming no owner created"]]) {
|
|
1265
|
+
const before = await gateHead(store, id, what);
|
|
1266
|
+
assert.equal(before.owner, null, `${what}: records no owner`);
|
|
1267
|
+
const answered = await store.recordOwner(id, "kit-alice", claimOf(before));
|
|
1268
|
+
assert.deepEqual(answered, { ...before, owner: "kit-alice" }, `${what}: the answer is the head the write committed — the owner recorded, the occupant and the leaf as they were`);
|
|
1269
|
+
assert.deepEqual(await headOf(store, id), answered, `${what}: the head read agrees`);
|
|
1270
|
+
}
|
|
1271
|
+
assert.deepEqual(await entryIds(await readBack(store, acquired)), ["c1"], "the log is the one the row held");
|
|
1272
|
+
await store.forget?.(acquired);
|
|
1273
|
+
assert.equal(await ownerOf(store, acquired, "after the cached view is dropped"), "kit-alice");
|
|
1274
|
+
const second = await open(hooks.reopen(store));
|
|
1275
|
+
assert.equal(await ownerOf(second, acquired, "on a reopened store"), "kit-alice", "the claim is a write of the row, not of an instance");
|
|
1276
|
+
assert.equal(await ownerOf(second, registered, "on a reopened store"), "kit-alice");
|
|
1277
|
+
});
|
|
1278
|
+
faceRun("[recordOwner] a row that records a name is left as it is, whatever the call carries — another principal's name, the same name: the answer is its head as read and nothing is written; a claim never changes an owner", ["recordOwner"], async (store) => {
|
|
1279
|
+
const id = freshId();
|
|
1280
|
+
await store.register(id, "kit-bob");
|
|
1281
|
+
const before = await gateHead(store, id, "an owned row");
|
|
1282
|
+
assert.deepEqual(await store.recordOwner(id, "kit-alice", claimOf(before)), before, "another principal's claim answers the owned head, unwritten");
|
|
1283
|
+
assert.deepEqual(await store.recordOwner(id, "kit-bob", claimOf(before)), before, "the owner's own claim changes nothing either");
|
|
1284
|
+
assert.deepEqual(await headOf(store, id), before, "the row still records its owner");
|
|
1285
|
+
});
|
|
1286
|
+
faceRun("[recordOwner] a claim naming another occupant than the row holds — the row deleted and created again under the id — is refused conflict with nothing written; an id with no row answers undefined and creates none", ["recordOwner"], async (store) => {
|
|
1287
|
+
const id = freshId();
|
|
1288
|
+
await store.acquire(id);
|
|
1289
|
+
const stale = await gateHead(store, id, "the first occupant");
|
|
1290
|
+
await hooks.deleteSession(store, id);
|
|
1291
|
+
await store.register(id, null);
|
|
1292
|
+
const now = await gateHead(store, id, "the second occupant");
|
|
1293
|
+
await assert.rejects(() => store.recordOwner(id, "kit-alice", claimOf(stale)), (err) => isSessionConflict(err), "a claim of an occupant the row no longer holds is refused conflict");
|
|
1294
|
+
assert.deepEqual(await headOf(store, id), now, "the row standing is untouched");
|
|
1295
|
+
const missing = freshId();
|
|
1296
|
+
assert.equal(await store.recordOwner(missing, "kit-alice", { row: { owner: null } }), undefined, "no row: undefined");
|
|
1297
|
+
assert.equal(await headOf(store, missing), undefined, "and no row was created");
|
|
1298
|
+
});
|
|
1299
|
+
faceRun("[recordOwner] two concurrent claims of one row by two principals: exactly one owner is recorded, and both answers name that one", ["recordOwner"], async (store) => {
|
|
1300
|
+
for (let round = 0; round < 4; round++) {
|
|
1301
|
+
const id = freshId();
|
|
1302
|
+
await store.register(id, null);
|
|
1303
|
+
const head = await gateHead(store, id, "an anonymous row");
|
|
1304
|
+
const settled = await Promise.allSettled([store.recordOwner(id, "kit-x", claimOf(head)), store.recordOwner(id, "kit-y", claimOf(head))]);
|
|
1305
|
+
const owners = settled.map((s) => (s.status === "fulfilled" ? s.value?.owner : `rejected: ${thrownText(s.reason)}`));
|
|
1306
|
+
const winner = await ownerOf(store, id, "the settled row");
|
|
1307
|
+
assert.ok(winner === "kit-x" || winner === "kit-y", `round ${round}: one of the two claims recorded its owner, got ${String(winner)}`);
|
|
1308
|
+
assert.deepEqual(owners, [winner, winner], `round ${round}: each claimant's answer names the one recorded owner — a claim that answers its own name over another's is two owners of one row`);
|
|
1309
|
+
}
|
|
1310
|
+
});
|
|
1311
|
+
faceRun("[recordOwner] an owner that is not a principal name — null, a blank string, one with a control character, a non-string — is refused config.invalid_argument before the row is read, nothing written", ["recordOwner"], async (store) => {
|
|
1312
|
+
const id = freshId();
|
|
1313
|
+
await store.register(id, null);
|
|
1314
|
+
const head = await gateHead(store, id, "an anonymous row");
|
|
1315
|
+
for (const bad of [null, "", " ", "kit\u0007bell", 7, undefined]) {
|
|
1316
|
+
await assert.rejects(() => Reflect.apply(store.recordOwner, store, [id, bad, claimOf(head)]), (err) => readMember(err, "code") === "config.invalid_argument", `owner ${describeRejectedValue(bad)} is refused config.invalid_argument`);
|
|
1317
|
+
}
|
|
1318
|
+
assert.deepEqual(await headOf(store, id), head, "the row still records no owner");
|
|
1319
|
+
});
|
|
1320
|
+
faceRun("[recordOwner] a session handed out for the row before the claim keeps writing to it: its appends land on the claimed row, the head follows them, and a store reopened over the same rows (a restart) serves the whole log under the recorded owner", ["recordOwner"], async (store, open) => {
|
|
1321
|
+
const id = freshId();
|
|
1322
|
+
const held = await store.acquire(id);
|
|
1323
|
+
await append(held.session, userEntry("before", null));
|
|
1324
|
+
const head = await gateHead(store, id, "an anonymous row");
|
|
1325
|
+
await store.recordOwner(id, "kit-alice", claimOf(head));
|
|
1326
|
+
await append(held.session, userEntry("after", "before"));
|
|
1327
|
+
assert.equal((await held.session.getMetadata()).owner ?? null, "kit-alice", "the session handed out before the claim answers the recorded owner");
|
|
1328
|
+
const now = await gateHead(store, id, "after an append through the held session");
|
|
1329
|
+
assert.deepEqual({ owner: now.owner, leafId: now.leafId }, { owner: "kit-alice", leafId: "after" }, "the append through the session held across the claim is the row's leaf");
|
|
1330
|
+
const served = (await store.acquire(id)).session;
|
|
1331
|
+
assert.deepEqual(await entryIds(served), ["before", "after"], "the store serves the row with both entries");
|
|
1332
|
+
assert.equal((await served.getMetadata()).owner ?? null, "kit-alice", "the session this store serves after the claim answers the recorded owner (its cached view follows the claim)");
|
|
1333
|
+
const second = await open(hooks.reopen(store));
|
|
1334
|
+
assert.deepEqual(await entryIds(await readBack(second, id)), ["before", "after"], "the append after the claim is in the row, not only in a cached view");
|
|
1335
|
+
assert.equal(await ownerOf(second, id, "on a reopened store"), "kit-alice");
|
|
1336
|
+
});
|
|
1337
|
+
faceRun("[recordOwner] a claim is not activity: the listing's order and every row's lastActiveAt are what they were before it", ["recordOwner", "list"], async (store) => {
|
|
1338
|
+
const [older, newer] = [freshId(), freshId()];
|
|
1339
|
+
await append((await store.acquire(older)).session, userEntry("o1", null));
|
|
1340
|
+
await new Promise((r) => setTimeout(r, 20));
|
|
1341
|
+
await append((await store.acquire(newer)).session, userEntry("n1", null));
|
|
1342
|
+
await store.touch(newer);
|
|
1343
|
+
const before = (await store.list({ includeUnowned: true, owner: "kit-alice" })).filter((r) => r.sessionId === older || r.sessionId === newer);
|
|
1344
|
+
await store.recordOwner(older, "kit-alice", claimOf(await gateHead(store, older, "the older row")));
|
|
1345
|
+
const after = (await store.list({ includeUnowned: true, owner: "kit-alice" })).filter((r) => r.sessionId === older || r.sessionId === newer);
|
|
1346
|
+
assert.deepEqual(after.map((r) => [r.sessionId, r.lastActiveAt]), before.map((r) => [r.sessionId, r.lastActiveAt]), "the claimed row keeps its place and its activity time");
|
|
1347
|
+
});
|
|
1348
|
+
faceRun("[recordOwner] no write that names no owner clears a name: on a row that records one, register(id, null) and acquire(id, { owner: null }) leave it as it was", ["recordOwner"], async (store) => {
|
|
1349
|
+
const id = freshId();
|
|
1350
|
+
await store.acquire(id);
|
|
1351
|
+
await store.recordOwner(id, "kit-alice", claimOf(await gateHead(store, id, "an anonymous row")));
|
|
1352
|
+
await store.register(id, null);
|
|
1353
|
+
await store.acquire(id, { owner: null });
|
|
1354
|
+
assert.equal(await ownerOf(store, id, "after writes naming no owner"), "kit-alice", "a claim is never undone by a write that names no owner");
|
|
1355
|
+
});
|
|
1147
1356
|
faceRun("[incarnation] a session created through acquire carries a token, and every later read of the row answers the same one", ["headOf", "requireExisting"], async (store) => {
|
|
1148
1357
|
const id = freshId();
|
|
1149
1358
|
await store.acquire(id);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
|
-
import { JOURNAL_INCOMPATIBLE_ERROR_CODE, JOURNAL_OVERSIZE_ERROR_CODE, MAX_JOURNAL_RESULT_BYTES, WORKFLOW_LAUNCH_CONFLICT_CODE, } from "../workflow-journal-store.js";
|
|
2
|
+
import { JOURNAL_INCOMPATIBLE_ERROR_CODE, JOURNAL_OVERSIZE_ERROR_CODE, MAX_JOURNAL_RESULT_BYTES, RESUME_CLAIM_REMAINING_MS_MAX, WORKFLOW_LAUNCH_CONFLICT_CODE, } from "../workflow-journal-store.js";
|
|
3
3
|
import { ANONYMOUS_SCOPE } from "../isolation-scope.js";
|
|
4
4
|
import { beginContract } from "./contract-harness.js";
|
|
5
5
|
const key = (ordinal) => `${ordinal}:h`;
|
|
@@ -38,6 +38,17 @@ export async function workflowJournalStoreContract(make, runAssertion) {
|
|
|
38
38
|
assert.deepEqual(entries[0], { callKey: key(0), result: completed(0, { result: "overwritten" }) });
|
|
39
39
|
assert.deepEqual(entries[1], { callKey: key(1), parked: parked(1) });
|
|
40
40
|
});
|
|
41
|
+
run("the STOPPED arm (since 7.71.0: a member a stop of its own ended) round-trips verbatim — the leg's whole result and who stopped it; a re-append per ordinal overwrites it like any arm", async () => {
|
|
42
|
+
const store = make();
|
|
43
|
+
const stoppedLeg = completed(1, { terminal: { kind: "failed", message: "workflow agent stopped by user" }, result: "partial" });
|
|
44
|
+
await store.append("run-1", "tenant-a", { callKey: key(0), result: completed(0) });
|
|
45
|
+
await store.append("run-1", "tenant-a", { callKey: key(1), stopped: { result: stoppedLeg, stoppedBy: "user" } });
|
|
46
|
+
await store.append("run-1", "tenant-a", { callKey: key(2), stopped: { result: stoppedLeg, stoppedBy: "parent" } });
|
|
47
|
+
await store.append("run-1", "tenant-a", { callKey: key(2), result: completed(2) });
|
|
48
|
+
const entries = await store.load("run-1", "tenant-a");
|
|
49
|
+
assert.deepEqual(entries[1], { callKey: key(1), stopped: { result: stoppedLeg, stoppedBy: "user" } });
|
|
50
|
+
assert.deepEqual(entries[2], { callKey: key(2), result: completed(2) });
|
|
51
|
+
});
|
|
41
52
|
run("scope wall: a cross-scope load is EMPTY — before and after the owner's own load, and after a refused cross-scope append — on both arms", async () => {
|
|
42
53
|
const store = make();
|
|
43
54
|
await store.append("run-1", "alice", { callKey: key(0), result: completed(0) });
|
|
@@ -207,26 +218,54 @@ export async function workflowJournalStoreContract(make, runAssertion) {
|
|
|
207
218
|
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
219
|
}
|
|
209
220
|
});
|
|
210
|
-
run("resume claims: a second run is refused while the first holds the claim (naming it, and
|
|
221
|
+
run("resume claims: a second run is refused while the first holds the claim (naming it, and how long it has left, where the store answers them); the holder's re-claim is granted; released, the claim is free", async () => {
|
|
211
222
|
const store = make();
|
|
212
223
|
if (typeof store.resumeClaim !== "function")
|
|
213
224
|
return;
|
|
214
225
|
assert.equal(typeof store.releaseResumeClaim, "function", "a store that takes resume claims gives them back (releaseResumeClaim)");
|
|
215
226
|
const a = { sourceRunId: "root-1", newRunId: "run-a", scope: "tenant-a" };
|
|
216
227
|
const b = { ...a, newRunId: "run-b" };
|
|
217
|
-
const
|
|
218
|
-
|
|
228
|
+
const remainingReads = (answer, what) => {
|
|
229
|
+
const r = answer.remainingMs;
|
|
230
|
+
if (r === undefined)
|
|
231
|
+
return;
|
|
232
|
+
assert.ok(typeof r === "number" && Number.isSafeInteger(r) && r >= 1 && r <= RESUME_CLAIM_REMAINING_MS_MAX, `${what}: remainingMs is a whole number of milliseconds from 1 to ${RESUME_CLAIM_REMAINING_MS_MAX} (read: ${String(r)})`);
|
|
233
|
+
};
|
|
234
|
+
const granted = await store.resumeClaim(a);
|
|
235
|
+
assert.equal(granted.granted, true);
|
|
236
|
+
remainingReads(granted, "a grant");
|
|
219
237
|
const refused = await store.resumeClaim(b);
|
|
220
238
|
assert.equal(refused.granted, false, "a second run's claim on a held key is refused");
|
|
221
239
|
if (refused.holder !== undefined)
|
|
222
240
|
assert.equal(refused.holder, "run-a", "a refusal that names a holder names the run that holds the claim");
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
assert.equal(
|
|
241
|
+
remainingReads(refused, "a refusal");
|
|
242
|
+
assert.ok(!Object.hasOwn(refused, "expiresAt") && !Object.hasOwn(granted, "expiresAt"), "an answer carries no expiresAt (retired in 7.71.0: a remaining time, never an instant of the store's clock)");
|
|
243
|
+
const again = await store.resumeClaim(a);
|
|
244
|
+
assert.equal(again.granted, true, "the holder's own re-claim is granted");
|
|
245
|
+
remainingReads(again, "the holder's re-claim");
|
|
227
246
|
await store.releaseResumeClaim(a);
|
|
228
247
|
assert.equal((await store.resumeClaim(b)).granted, true, "released, the claim is free");
|
|
229
248
|
await store.releaseResumeClaim(b);
|
|
230
249
|
});
|
|
250
|
+
run("resume claims: a key holding ':', '/' or a space is a claim like any other — a second run is refused, another such key is another claim, released it is free", async () => {
|
|
251
|
+
const store = make();
|
|
252
|
+
if (typeof store.resumeClaim !== "function")
|
|
253
|
+
return;
|
|
254
|
+
for (const key of ["team:run-1", "team/run-1", "team run-1"]) {
|
|
255
|
+
const a = { sourceRunId: key, newRunId: "run-a", scope: "tenant-a" };
|
|
256
|
+
const b = { ...a, newRunId: "run-b" };
|
|
257
|
+
assert.equal((await store.resumeClaim(a)).granted, true, `${key}: the first claim is granted`);
|
|
258
|
+
assert.equal((await store.resumeClaim(b)).granted, false, `${key}: a second run's claim is refused while the first holds it`);
|
|
259
|
+
await store.releaseResumeClaim(a);
|
|
260
|
+
assert.equal((await store.resumeClaim(b)).granted, true, `${key}: released, the claim is free`);
|
|
261
|
+
await store.releaseResumeClaim(b);
|
|
262
|
+
}
|
|
263
|
+
const one = { sourceRunId: "team:run-1", newRunId: "run-a", scope: "tenant-a" };
|
|
264
|
+
const other = { sourceRunId: "team:run-2", newRunId: "run-b", scope: "tenant-a" };
|
|
265
|
+
assert.equal((await store.resumeClaim(one)).granted, true);
|
|
266
|
+
assert.equal((await store.resumeClaim(other)).granted, true, "another such key is another claim");
|
|
267
|
+
await store.releaseResumeClaim(one);
|
|
268
|
+
await store.releaseResumeClaim(other);
|
|
269
|
+
});
|
|
231
270
|
await settle();
|
|
232
271
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a leg cannot suspend durably (`WiringManifest.suspendLane`) — every missing piece of the
|
|
3
|
+
* infrastructure the external causes (a scheduler's yield, a usage window, an env lifetime) and the opted-in
|
|
4
|
+
* task axes suspend on: no checkpoint store; tool-result offload into a volatile store; a per-task execution
|
|
5
|
+
* env in neither suspend target (not a remote env / no `capabilities.suspendable` declaration / a declared
|
|
6
|
+
* snapshot whose adapter lacks the restore surface). The type is derived from the frozen list. A leaf with no imports: a failed
|
|
7
|
+
* approval park names its word on `delegation.ask_unresolvable` (`detail.parkFailedReason`), and the notice's mint and the gate's deny
|
|
8
|
+
* exit read the set from here without loading the manifest's module graph (`wiring-manifest.ts` re-exports it).
|
|
9
|
+
*/
|
|
10
|
+
export declare const SUSPEND_LANE_REASONS: readonly ["no_checkpoint_store", "leg_not_resumable", "volatile_tool_results", "env_not_remote", "env_suspend_undeclared", "env_restore_incomplete"];
|
|
11
|
+
export type SuspendLaneReason = (typeof SUSPEND_LANE_REASONS)[number];
|
|
12
|
+
/** Membership test for {@link SuspendLaneReason} — the word rides a notice detail and a caller-supplied park answer. */
|
|
13
|
+
export declare function isSuspendLaneReason(v: unknown): v is SuspendLaneReason;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const SUSPEND_LANE_REASONS = Object.freeze(["no_checkpoint_store", "leg_not_resumable", "volatile_tool_results", "env_not_remote", "env_suspend_undeclared", "env_restore_incomplete"]);
|
|
2
|
+
const SUSPEND_LANE_REASON_SET = new Set(SUSPEND_LANE_REASONS);
|
|
3
|
+
export function isSuspendLaneReason(v) {
|
|
4
|
+
return SUSPEND_LANE_REASON_SET.has(v);
|
|
5
|
+
}
|
|
@@ -164,11 +164,13 @@ export interface SyntheticReadBudget {
|
|
|
164
164
|
deadlineAt?: number;
|
|
165
165
|
}
|
|
166
166
|
export type SyntheticReadJudge = (call: SyntheticReadCall, face: string, budget?: SyntheticReadBudget) => Promise<SyntheticReadVerdict>;
|
|
167
|
-
/** The path a served-read probe reads, and the face the run's roster gives `Read` (the face the model's own `Read` carries)
|
|
168
|
-
*
|
|
167
|
+
/** The path a served-read probe reads, and the face the run's roster gives `Read` (the face the model's own `Read` carries) —
|
|
168
|
+
* absent on a roster that mounts no `Read`: the probe then carries no face, as the read face's does, and every layer judges it as
|
|
169
|
+
* it judges a request with none (a deny-list reads the catalog's slot for the name, tighten-only). The request's other facts come
|
|
170
|
+
* from the judge's {@link SyntheticCallFacts}. */
|
|
169
171
|
export interface SyntheticServedReadCall {
|
|
170
172
|
file_path: string;
|
|
171
|
-
face
|
|
173
|
+
face?: ToolCallFace;
|
|
172
174
|
}
|
|
173
175
|
export type SyntheticServedReadJudge = (call: SyntheticServedReadCall, face: string, budget?: SyntheticReadBudget) => Promise<SyntheticWriteVerdict>;
|
|
174
176
|
export type SyntheticWriteJudge = (call: SyntheticWriteCall, face: string, budget?: SyntheticReadBudget) => Promise<SyntheticWriteVerdict>;
|
|
@@ -60,7 +60,7 @@ export function createSyntheticReadJudge(layers, facts = () => ({})) {
|
|
|
60
60
|
}
|
|
61
61
|
export function createSyntheticServedReadJudge(layers, facts) {
|
|
62
62
|
const judge = createProbeJudge(layers, "every");
|
|
63
|
-
return async (call, face, budget) => (await judge({ ...readProbeOf({ file_path: call.file_path }, face), ...callFactsSeat({ ...facts(), face: call.face }) }, budget)).verdict;
|
|
63
|
+
return async (call, face, budget) => (await judge({ ...readProbeOf({ file_path: call.file_path }, face), ...callFactsSeat({ ...facts(), ...(call.face !== undefined ? { face: call.face } : {}) }) }, budget)).verdict;
|
|
64
64
|
}
|
|
65
65
|
export function createSyntheticWriteJudge(layers, facts) {
|
|
66
66
|
const judge = createProbeJudge(layers, "every");
|