@sema-agent/core 7.70.0 → 7.71.1
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 +740 -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 +21 -7
- 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 +69 -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 +39 -21
- package/dist/index.js +32 -17
- 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 +173 -15
- package/wire-changes/core-stores-sql@7.71.0.json +40 -0
- package/wire-changes/core-stores-sql@7.71.1.json +40 -0
- package/wire-changes/core@7.71.0.json +5827 -0
- package/wire-changes/core@7.71.1.json +118 -0
- package/wire-changes/mods-kernel@7.71.0.json +52 -0
- package/wire-changes/mods-kernel@7.71.1.json +40 -0
- package/wire-changes/primitives@7.71.0.json +473 -0
- package/wire-changes/primitives@7.71.1.json +40 -0
- package/wire-changes/wiki-gate@7.71.0.json +40 -0
- package/wire-changes/wiki-gate@7.71.1.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
|
@@ -10,6 +10,9 @@ export function spendNodeMint(parent, member) {
|
|
|
10
10
|
export function spendParentOf(parent, member) {
|
|
11
11
|
if (parent === undefined)
|
|
12
12
|
return undefined;
|
|
13
|
+
if (typeof parent !== "object" || parent === null) {
|
|
14
|
+
throw Object.assign(new Error(`${member} must be a { seat, link } pair or be left out (got ${describeRejectedValue(parent)}).`), { code: "config.invalid_argument", detail: { field: member } });
|
|
15
|
+
}
|
|
13
16
|
const seat = parent.seat;
|
|
14
17
|
const link = parent.link;
|
|
15
18
|
const account = spendAccountOf(seat);
|
|
@@ -2,7 +2,10 @@ import { type Checkpoint, type CheckpointStore, type CheckpointSummary, type Res
|
|
|
2
2
|
import type { GateOutcome } from "../gate-outcome.js";
|
|
3
3
|
import { type CheckpointFields } from "../pause-registry.js";
|
|
4
4
|
import { type ContractAssertionRunner } from "./contract-harness.js";
|
|
5
|
-
|
|
5
|
+
import { type ContractGrants } from "./grant-fixture.js";
|
|
6
|
+
/** Build a {@link Checkpoint} fixture: the content given, stamped by the mint's own stamp (the row format, its reader-requirement
|
|
7
|
+
* words and digest — a row with no stated format is one the row judge refuses as a retired seat). A case that edits the row after
|
|
8
|
+
* this reads it as the store would hand back an edited row. `createdAt` is FIXED (not wall-clock) so summary projections
|
|
6
9
|
* are deterministic and cross-backend byte-comparable; override via `over` for ordering tests. */
|
|
7
10
|
export declare function createCheckpointFixture(over?: Partial<CheckpointFields>): Checkpoint;
|
|
8
11
|
/** The canonical `policy_ask allow` outcome the contract resolves with. Declared as the NARROW
|
|
@@ -30,13 +33,28 @@ export declare const POLICY_ALLOW: Extract<ResumeOutcome, {
|
|
|
30
33
|
export declare function checkpointStoreContract(make: () => CheckpointStore, runAssertion?: ContractAssertionRunner,
|
|
31
34
|
/** `sessionHeads` = the map the binding's stores read their session heads from (their `deleteSessionCheckpoints` guard): the kit writes
|
|
32
35
|
* the heads its delete case needs into it. Required only to judge a store that offers `deleteSessionCheckpoints`.
|
|
33
|
-
* `
|
|
34
|
-
*
|
|
36
|
+
* `composed` + `grants` = the holder binding (the C-H cells): `composed()` returns a FRESH, empty store AS THE DEPLOYMENT COMPOSES IT —
|
|
37
|
+
* every wrapper included (a park-commit observer, a forwarding layer) — built with the judge `grants` mints its holders against
|
|
38
|
+
* ({@link ContractGrants}). Bind the composition itself, the function the deployment's startup calls: a cell run on the bare store
|
|
39
|
+
* cannot see a wrapper, and a wrapper is what silently drops a holder (a `put` / `setPendingSteer` / `expire` forwarded without its
|
|
40
|
+
* last argument, a `resolve` that forwards `rev` and drops `expect.holder`). Required (both) for a store that declares `fence`.
|
|
41
|
+
* `onOptionalMember` = told, per holder cell, whether the cell's `claimTerminal` arms ran (`verified`) or were skipped because the
|
|
42
|
+
* composed store does not implement `claimTerminal` (`absent`), and whether the cell itself ran (`holder`: `verified`) or asserted
|
|
43
|
+
* nothing because the binding judges no holders (`holder`: `absent` — no `fence`, no `composed`, no `grants`), and whether the
|
|
44
|
+
* store answers the overdue face's age backstop (`listOverdue.maxAgeMs`) and the session face's run axis (`listBySession.axis`) — or
|
|
45
|
+
* refuses a query carrying the member (`absent`: the cell judges it no further; ignoring the member is red, never `absent`). (`holders`, the set of current holders this kit took before the grant
|
|
46
|
+
* fixture, is retired and refused by name.) */
|
|
35
47
|
options?: {
|
|
36
48
|
readonly sessionHeads?: Map<string, {
|
|
37
49
|
readonly owner: string | null;
|
|
38
50
|
}>;
|
|
39
|
-
readonly
|
|
51
|
+
readonly composed?: () => CheckpointStore;
|
|
52
|
+
readonly grants?: ContractGrants;
|
|
53
|
+
readonly onOptionalMember?: (report: {
|
|
54
|
+
member: "claimTerminal" | "holder" | "listOverdue.maxAgeMs" | "listBySession.axis";
|
|
55
|
+
status: "verified" | "absent";
|
|
56
|
+
cell: string;
|
|
57
|
+
}) => void;
|
|
40
58
|
}): Promise<void>;
|
|
41
59
|
/** Seed the canonical listByScope fixture into `store` and return the sorted summaries. Compare the
|
|
42
60
|
* result against {@link EXPECTED_LISTBYSCOPE_SUMMARIES} (deep equality) to prove the backend's
|
|
@@ -3,14 +3,19 @@ import { executionVerdict } from "../checkpoint-execution-record.js";
|
|
|
3
3
|
import { MAX_PENDING_STEER_ENTRIES, checkpointIndexFacts, mintCheckpointToken, readPendingSteerQueue, summarizeCheckpoint, } from "../checkpoint-store.js";
|
|
4
4
|
import { RESOURCE_LIMIT_REASONS } from "../resource-limit-reasons.js";
|
|
5
5
|
import { ANONYMOUS_SCOPE } from "../isolation-scope.js";
|
|
6
|
+
import { checkpointRunSessionOf, isCheckpointRowUnreadable } from "../checkpoint-queries.js";
|
|
6
7
|
import { judgeCheckpointRow } from "../checkpoint-row-verdict.js";
|
|
8
|
+
import { stampCheckpointRequirements } from "../checkpoint-requirements.js";
|
|
7
9
|
import { memberPresent } from "../own-property-receipt.js";
|
|
8
10
|
import { checkpointFrom } from "../pause-registry.js";
|
|
9
11
|
import { beginContract } from "./contract-harness.js";
|
|
12
|
+
import { deadGrants, holderBinding, rejectsMalformed, rejectsSuperseded } from "./grant-fixture.js";
|
|
13
|
+
import { receiptRefusal } from "../own-property-receipt.js";
|
|
14
|
+
import { checkpointRevOf } from "../checkpoint-generation.js";
|
|
10
15
|
const unhashedCall = (call) => call;
|
|
11
16
|
export function createCheckpointFixture(over = {}) {
|
|
12
17
|
const token = over.token ?? mintCheckpointToken();
|
|
13
|
-
return checkpointFrom({
|
|
18
|
+
return stampCheckpointRequirements(checkpointFrom({
|
|
14
19
|
token,
|
|
15
20
|
scope: "tenant-a",
|
|
16
21
|
sessionId: "sess-1",
|
|
@@ -33,12 +38,14 @@ export function createCheckpointFixture(over = {}) {
|
|
|
33
38
|
status: "pending",
|
|
34
39
|
createdAt: 1_700_000_000_000,
|
|
35
40
|
...over,
|
|
36
|
-
});
|
|
41
|
+
}), "structured-clone");
|
|
37
42
|
}
|
|
38
|
-
function
|
|
43
|
+
function fixtureWithState(over, state) {
|
|
39
44
|
const cp = createCheckpointFixture(over);
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
return stampCheckpointRequirements({ ...cp, state: { ...cp.state, ...state } }, "structured-clone");
|
|
46
|
+
}
|
|
47
|
+
function damagedWriteFaceFixture(over) {
|
|
48
|
+
return fixtureWithState(over, { writeFace: { face: "neither" } });
|
|
42
49
|
}
|
|
43
50
|
export const ALLOW = {
|
|
44
51
|
gate: "policy_ask",
|
|
@@ -58,6 +65,9 @@ export const POLICY_ALLOWED = Object.freeze({
|
|
|
58
65
|
});
|
|
59
66
|
export const POLICY_ALLOW = { ...ALLOW, hostDecision: { decidedBy: "policy", approver: "unattended_class_answer" }, gateOutcome: POLICY_ALLOWED };
|
|
60
67
|
export async function checkpointStoreContract(make, runAssertion, options = {}) {
|
|
68
|
+
if (Object.prototype.hasOwnProperty.call(options, "holders")) {
|
|
69
|
+
throw receiptRefusal("checkpointStoreContract: the `holders` option is retired — bind the holder cells with `composed` (the store as the deployment composes it) and `grants` (current / replaced / ended / unknownStatus / malformed holders minted against its judge)");
|
|
70
|
+
}
|
|
61
71
|
const { run, settle } = beginContract(runAssertion);
|
|
62
72
|
run("kit prerequisites: reopen/recordExecutionOutcome/setPendingSteer/listByScope are implemented (REQUIRED by this kit)", async () => {
|
|
63
73
|
const probe = make();
|
|
@@ -541,10 +551,14 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
541
551
|
});
|
|
542
552
|
run("requirement list: a v10 row's `requires` survives the round-trip verbatim (the whole array, in its order) beside its version; a row without one stays without", async () => {
|
|
543
553
|
const store = make();
|
|
544
|
-
const listed = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "rq-list", version: 10, requires: ["binding", "hands_coordinates", "requirements_digest"], requirementsDigest: "a".repeat(64) }
|
|
545
|
-
const bare = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "rq-none" });
|
|
546
|
-
|
|
554
|
+
const listed = { ...createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "rq-list" }), version: 10, requires: ["binding", "hands_coordinates", "requirements_digest"], requirementsDigest: "a".repeat(64) };
|
|
555
|
+
const { requires: _list, requirementsDigest: _digest, ...bare } = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "rq-none" });
|
|
556
|
+
const newer = { ...createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "rq-newer" }), version: 11 };
|
|
557
|
+
const older = { ...bare, token: mintCheckpointToken(), sessionId: "rq-older", version: 9 };
|
|
558
|
+
for (const cp of [listed, bare, newer, older])
|
|
547
559
|
await store.put(cp.token, cp);
|
|
560
|
+
assert.equal((await store.get(newer.token)).version, 11, "a newer row's version must survive the round-trip");
|
|
561
|
+
assert.equal((await store.get(older.token)).version, 9, "a row below the format must keep its version");
|
|
548
562
|
const back = (await store.get(listed.token));
|
|
549
563
|
assert.equal(back.version, 10, "the frozen stamp must survive the round-trip");
|
|
550
564
|
assert.deepEqual(back.requires, ["binding", "hands_coordinates", "requirements_digest"], "the requirement list must survive the round-trip as the same array, in the same order");
|
|
@@ -750,6 +764,180 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
750
764
|
await assert.rejects(store.listBySession(bad), (e) => e.code === "config.invalid_argument", `refused loudly: ${JSON.stringify(bad)}`);
|
|
751
765
|
}
|
|
752
766
|
});
|
|
767
|
+
const isInvalidArgument = (e) => e.code === "config.invalid_argument";
|
|
768
|
+
run("listOverdue age backstop (when offered; a store that refuses `maxAgeMs` is reported absent): a pending row with no deadline is overdue once createdAt + maxAgeMs <= cutoff and sorts at that instant, a row's own deadline outranks the backstop, no backstop = never, a bad backstop refused", async () => {
|
|
769
|
+
const cell = "listOverdue.maxAgeMs";
|
|
770
|
+
const store = make();
|
|
771
|
+
if (store.listOverdue === undefined)
|
|
772
|
+
return;
|
|
773
|
+
const rows = [
|
|
774
|
+
createCheckpointFixture({ token: "ag-1499", createdAt: 1_499 }),
|
|
775
|
+
createCheckpointFixture({ token: "ag-1500", createdAt: 1_500 }),
|
|
776
|
+
createCheckpointFixture({ token: "ag-1501", createdAt: 1_501 }),
|
|
777
|
+
createCheckpointFixture({ token: "ag-dl", createdAt: 0, deadline: 2_000 }),
|
|
778
|
+
createCheckpointFixture({ token: "ag-far", createdAt: 0, deadline: 9_000 }),
|
|
779
|
+
createCheckpointFixture({ token: "ag-res", createdAt: 0 }),
|
|
780
|
+
createCheckpointFixture({ token: "ag-b", createdAt: 0, gate: { kind: "resource_limit", reason: "turns" }, pendingAction: { kind: "resource_limit", reason: "turns" } }),
|
|
781
|
+
];
|
|
782
|
+
for (const cp of rows)
|
|
783
|
+
await store.put(cp.token, cp);
|
|
784
|
+
await store.resolve("ag-res", "tenant-a", ALLOW);
|
|
785
|
+
const tokensOf = (page) => page.rows.map((r) => r.token);
|
|
786
|
+
let aged;
|
|
787
|
+
try {
|
|
788
|
+
aged = await store.listOverdue({ cutoff: 2_000, facet: "A", maxAgeMs: 500 });
|
|
789
|
+
}
|
|
790
|
+
catch (e) {
|
|
791
|
+
if (!isInvalidArgument(e))
|
|
792
|
+
throw e;
|
|
793
|
+
options.onOptionalMember?.({ member: "listOverdue.maxAgeMs", status: "absent", cell });
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
assert.deepEqual(tokensOf(aged), ["ag-1499", "ag-1500", "ag-dl"], "(the instant, token) ascending: createdAt + maxAgeMs for a row with no deadline, the deadline for one with one; one past the cutoff, a resolved row, and an old row whose own deadline is ahead are not overdue");
|
|
797
|
+
assert.deepEqual(tokensOf(await store.listOverdue({ cutoff: 2_000, facet: "A" })), ["ag-dl"], "no backstop: a row with no deadline is never overdue");
|
|
798
|
+
assert.deepEqual(tokensOf(await store.listOverdue({ cutoff: 2_000, facet: "B", maxAgeMs: 0 })), ["ag-b"], "the backstop reads each facet's rows (maxAgeMs 0 = created at or before the cutoff)");
|
|
799
|
+
const first = await store.listOverdue({ cutoff: 2_000, facet: "A", maxAgeMs: 500, limit: 1 });
|
|
800
|
+
assert.deepEqual(tokensOf(first), ["ag-1499"]);
|
|
801
|
+
assert.deepEqual(first.next, { deadline: 1_999, token: "ag-1499" }, "the cursor's deadline is the instant the row sorts at");
|
|
802
|
+
assert.deepEqual(tokensOf(await store.listOverdue({ cutoff: 2_000, facet: "A", maxAgeMs: 500, after: first.next })), ["ag-1500", "ag-dl"], "the cursor resumes in the backstop's order");
|
|
803
|
+
for (const bad of [-1, Number.NaN, Number.POSITIVE_INFINITY, "500", null]) {
|
|
804
|
+
const query = { cutoff: 2_000, facet: "A", maxAgeMs: bad };
|
|
805
|
+
await assert.rejects(store.listOverdue(query), isInvalidArgument, `refused loudly: maxAgeMs ${String(bad)}`);
|
|
806
|
+
}
|
|
807
|
+
options.onOptionalMember?.({ member: "listOverdue.maxAgeMs", status: "verified", cell });
|
|
808
|
+
});
|
|
809
|
+
run("listBySession run axis (when offered; a store that refuses `axis: \"run\"` is reported absent): the rows whose run session is the id — a cascade rung's and a repair restart's card under their host's, a verifier's card under its own — another session's row never, a row whose leg does not read left out (or refused at put, laying no row down)", async () => {
|
|
810
|
+
const cell = "listBySession.axis";
|
|
811
|
+
const store = make();
|
|
812
|
+
if (store.listBySession === undefined)
|
|
813
|
+
return;
|
|
814
|
+
const base = createCheckpointFixture();
|
|
815
|
+
const withLeg = (token, sessionId, createdAt, compositionLeg) => createCheckpointFixture({ token: token, sessionId, createdAt, state: { ...base.state, ...(compositionLeg !== undefined ? { compositionLeg } : {}) } });
|
|
816
|
+
const rows = [
|
|
817
|
+
withLeg("ra-host", "host-1", 1),
|
|
818
|
+
withLeg("ra-rung", "rung-1", 2, { entry: "cascade", leg: 0, hostSessionId: "host-1" }),
|
|
819
|
+
withLeg("ra-verify", "verifier-1", 3, { entry: "verify", leg: 1, hostSessionId: "host-1" }),
|
|
820
|
+
withLeg("ra-restart", "restart-1", 4, { entry: "repair", leg: 2, hostSessionId: "host-1" }),
|
|
821
|
+
withLeg("ra-other", "rung-2", 5, { entry: "cascade", leg: 0, hostSessionId: "host-2" }),
|
|
822
|
+
withLeg("ra-broken", "host-1", 6, { entry: "cascade", leg: 0, hostSessionId: "" }),
|
|
823
|
+
withLeg("ra-restart-broken", "restart-2", 7, { entry: "repair", leg: 2, hostSessionId: "" }),
|
|
824
|
+
];
|
|
825
|
+
const refused = new Set();
|
|
826
|
+
for (const cp of rows) {
|
|
827
|
+
try {
|
|
828
|
+
await store.put(cp.token, cp);
|
|
829
|
+
}
|
|
830
|
+
catch (e) {
|
|
831
|
+
if (checkpointRunSessionOf(cp) !== undefined)
|
|
832
|
+
throw e;
|
|
833
|
+
assert.equal(await store.get(cp.token), null, `the refused put of the ${cp.sessionId} row laid no row down`);
|
|
834
|
+
refused.add(cp.token);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
const tokensOf = (page) => page.rows.map((r) => r.checkpoint.token);
|
|
838
|
+
const held = (tokens) => tokens.filter((t) => !refused.has(t));
|
|
839
|
+
let runPage;
|
|
840
|
+
try {
|
|
841
|
+
runPage = await store.listBySession({ sessionId: "host-1", axis: "run" });
|
|
842
|
+
}
|
|
843
|
+
catch (e) {
|
|
844
|
+
if (!isInvalidArgument(e))
|
|
845
|
+
throw e;
|
|
846
|
+
options.onOptionalMember?.({ member: "listBySession.axis", status: "absent", cell });
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
assert.deepEqual(tokensOf(runPage), ["ra-host", "ra-rung", "ra-restart"], "the host's own row, its rung's and its restart's card; the verifier's card is not the host's run's; a row whose leg names no host is attributable to no run");
|
|
850
|
+
assert.deepEqual(tokensOf(await store.listBySession({ sessionId: "host-1" })), held(["ra-host", "ra-broken"]), "the session axis (absent = the row's own session) is unchanged");
|
|
851
|
+
assert.deepEqual(tokensOf(await store.listBySession({ sessionId: "host-1", axis: "session" })), held(["ra-host", "ra-broken"]));
|
|
852
|
+
assert.deepEqual(tokensOf(await store.listBySession({ sessionId: "rung-1", axis: "run" })), [], "a rung's card is not its own session's run");
|
|
853
|
+
assert.deepEqual(tokensOf(await store.listBySession({ sessionId: "verifier-1", axis: "run" })), ["ra-verify"], "a verifier's card is redeemed in its own session");
|
|
854
|
+
assert.deepEqual(tokensOf(await store.listBySession({ sessionId: "restart-1", axis: "run" })), [], "a restart's card is not its own session's run");
|
|
855
|
+
assert.deepEqual(tokensOf(await store.listBySession({ sessionId: "restart-2", axis: "run" })), [], "a restart whose leg names no host is no run's, not its own session's");
|
|
856
|
+
assert.deepEqual(tokensOf(await store.listBySession({ sessionId: "restart-2" })), held(["ra-restart-broken"]), "its own session's page lists it exactly when the store holds it — a refused put lists nothing");
|
|
857
|
+
const firstRun = await store.listBySession({ sessionId: "host-1", axis: "run", order: "newest", limit: 2 });
|
|
858
|
+
assert.deepEqual(tokensOf(firstRun), ["ra-restart", "ra-rung"], "the axis pages like the session axis");
|
|
859
|
+
assert.ok(firstRun.next !== undefined, "a cut run page carries the next cursor");
|
|
860
|
+
const secondRun = await store.listBySession({ sessionId: "host-1", axis: "run", order: "newest", limit: 2, after: firstRun.next });
|
|
861
|
+
assert.deepEqual(tokensOf(secondRun), ["ra-host"], "the cursor resumes the run page after its last row");
|
|
862
|
+
assert.equal(secondRun.next, undefined, "the run page's last page carries no cursor");
|
|
863
|
+
for (const cp of rows) {
|
|
864
|
+
assert.equal(checkpointIndexFacts(cp).runSessionId, checkpointRunSessionOf(cp) ?? null, "the index column is the axis's one function (null = no run)");
|
|
865
|
+
}
|
|
866
|
+
const badAxis = { sessionId: "host-1", axis: "host" };
|
|
867
|
+
await assert.rejects(store.listBySession(badAxis), isInvalidArgument, "an axis outside the two words is refused");
|
|
868
|
+
options.onOptionalMember?.({ member: "listBySession.axis", status: "verified", cell });
|
|
869
|
+
});
|
|
870
|
+
run("get: a row filed under the token that does not read as a row is refused — CheckpointError checkpoint.invalid_outcome / requirements_damaged, never null, never answered — and every other row is answered as stored, its damage the row judge's (a listing's unreadable row included)", async () => {
|
|
871
|
+
const store = make();
|
|
872
|
+
const refusedTyped = (e) => isCheckpointRowUnreadable(e);
|
|
873
|
+
const damaged = [
|
|
874
|
+
["a scope that is not a string", (cp) => Reflect.set(cp, "scope", 7)],
|
|
875
|
+
["a status that is not a string", (cp) => Reflect.set(cp, "status", null)],
|
|
876
|
+
["another token member", (cp) => Reflect.set(cp, "token", "gt-elsewhere")],
|
|
877
|
+
];
|
|
878
|
+
for (const [i, [what, damage]] of damaged.entries()) {
|
|
879
|
+
const token = `gt-${i}`;
|
|
880
|
+
const cp = createCheckpointFixture({ token });
|
|
881
|
+
damage(cp);
|
|
882
|
+
let held = true;
|
|
883
|
+
try {
|
|
884
|
+
await store.put(token, cp);
|
|
885
|
+
}
|
|
886
|
+
catch {
|
|
887
|
+
held = false;
|
|
888
|
+
}
|
|
889
|
+
let answered;
|
|
890
|
+
let refusal;
|
|
891
|
+
try {
|
|
892
|
+
answered = await store.get(token);
|
|
893
|
+
}
|
|
894
|
+
catch (e) {
|
|
895
|
+
refusal = e;
|
|
896
|
+
}
|
|
897
|
+
if (refusal !== undefined)
|
|
898
|
+
assert.ok(refusedTyped(refusal), `get refuses a held row with ${what} by the typed refusal (CheckpointError checkpoint.invalid_outcome / requirements_damaged)`);
|
|
899
|
+
else
|
|
900
|
+
assert.ok(!held && answered === null, `get answers a row with ${what} only by refusing it (held: ${held}; answered ${answered === null ? "null" : "a value"})`);
|
|
901
|
+
}
|
|
902
|
+
const unregistered = createCheckpointFixture({ token: "gt-gate", sessionId: "gt-session" });
|
|
903
|
+
Reflect.set(unregistered.gate, "kind", "no_such_gate");
|
|
904
|
+
await store.put(unregistered.token, unregistered);
|
|
905
|
+
const answered = await store.get(unregistered.token);
|
|
906
|
+
assert.ok(answered !== null, "a row whose member the shape table refuses is answered by get");
|
|
907
|
+
assert.notEqual(judgeCheckpointRow(answered).kind, "ok", "the row judge reads it damaged");
|
|
908
|
+
const offWord = createCheckpointFixture({ token: "gt-status", sessionId: "gt-status-session" });
|
|
909
|
+
Reflect.set(offWord, "status", "archived");
|
|
910
|
+
let offHeld = true;
|
|
911
|
+
try {
|
|
912
|
+
await store.put(offWord.token, offWord);
|
|
913
|
+
}
|
|
914
|
+
catch {
|
|
915
|
+
offHeld = false;
|
|
916
|
+
}
|
|
917
|
+
const offBack = await store.get(offWord.token);
|
|
918
|
+
if (!offHeld)
|
|
919
|
+
assert.equal(offBack, null, "a store that refused to hold the row holds nothing");
|
|
920
|
+
else
|
|
921
|
+
assert.equal(offBack?.status, "archived", "a held row whose status is a string none of the three words is answered as stored");
|
|
922
|
+
if (store.listBySession !== undefined) {
|
|
923
|
+
const listed = (await store.listBySession({ sessionId: "gt-session" })).rows;
|
|
924
|
+
assert.deepEqual(listed.map((r) => r.kind), ["unreadable"], "the listing answers the same row unreadable — the consumer that takes its token to get meets the judge's damaged verdict");
|
|
925
|
+
}
|
|
926
|
+
const old = { ...createCheckpointFixture({ token: "gt-old", sessionId: "gt-old-session" }), version: 5 };
|
|
927
|
+
await store.put(old.token, old);
|
|
928
|
+
const oldBack = await store.get(old.token);
|
|
929
|
+
assert.ok(oldBack !== null, "a row below the format is answered by get, not refused");
|
|
930
|
+
assert.equal(oldBack.version, 5, "answered as stored");
|
|
931
|
+
const oldVerdict = judgeCheckpointRow(oldBack);
|
|
932
|
+
assert.deepEqual(oldVerdict, judgeCheckpointRow(old), "its verdict is the row judge's on the row as written");
|
|
933
|
+
assert.notEqual(oldVerdict.kind, "ok", "and the judge does not resume it");
|
|
934
|
+
if (store.listByScope !== undefined) {
|
|
935
|
+
const oldListed = (await store.listByScope(old.scope)).find((s) => s.token === old.token);
|
|
936
|
+
assert.ok(oldListed !== undefined, "the listing lists it");
|
|
937
|
+
assert.deepEqual(oldListed.rowVerdict, oldVerdict, "the listing's verdict and the judge's of get's answer are one answer");
|
|
938
|
+
}
|
|
939
|
+
assert.equal(await store.get("gt-none"), null, "no row = null");
|
|
940
|
+
});
|
|
753
941
|
run("deleteSessionCheckpoints (when offered): every row of the session, in any status, only when the session row exists and its owner equals the guard's (null-safe); otherwise nothing is deleted and the answer is 0", async () => {
|
|
754
942
|
const store = make();
|
|
755
943
|
if (store.deleteSessionCheckpoints === undefined)
|
|
@@ -788,26 +976,174 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
788
976
|
}
|
|
789
977
|
assert.ok((await store.get(bystander.token)) !== null, "a refused guard deletes nothing");
|
|
790
978
|
});
|
|
791
|
-
|
|
792
|
-
const
|
|
793
|
-
|
|
979
|
+
const holderRun = (name, fn) => run(name, async () => {
|
|
980
|
+
const bare = make();
|
|
981
|
+
const binding = holderBinding("checkpoint", bare.fence !== undefined, options.composed, options.grants);
|
|
982
|
+
if (binding === undefined) {
|
|
983
|
+
options.onOptionalMember?.({ member: "holder", status: "absent", cell: name });
|
|
794
984
|
return;
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
985
|
+
}
|
|
986
|
+
await fn(binding.composed(), binding.grants);
|
|
987
|
+
options.onOptionalMember?.({ member: "holder", status: "verified", cell: name });
|
|
988
|
+
});
|
|
989
|
+
const rowNow = async (store, token) => {
|
|
990
|
+
const row = await store.get(token);
|
|
991
|
+
assert.ok(row !== null, "the row is still there");
|
|
992
|
+
return [row.status, checkpointRevOf(row)];
|
|
993
|
+
};
|
|
994
|
+
const steerCountOf = async (store, token) => readPendingSteerQueue((await store.get(token)).state).length;
|
|
995
|
+
const claimArms = async (cell, store, arms) => {
|
|
996
|
+
if (store.claimTerminal === undefined) {
|
|
997
|
+
options.onOptionalMember?.({ member: "claimTerminal", status: "absent", cell });
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
await arms();
|
|
1001
|
+
options.onOptionalMember?.({ member: "claimTerminal", status: "verified", cell });
|
|
1002
|
+
};
|
|
1003
|
+
holderRun("C-H0 grant holder, through the composed store: a dead grant (replaced / ended / unknown status) is refused on every write — put and setPendingSteer throw holder.superseded, expire and resolve lose, each claimTerminal arm loses (when the store implements claimTerminal) — and every row re-reads exactly as it was", async (store, grants) => {
|
|
1004
|
+
for (const [label, dead] of deadGrants(grants)) {
|
|
1005
|
+
const fresh = createCheckpointFixture();
|
|
1006
|
+
await rejectsSuperseded(() => store.put(fresh.token, fresh, { holder: dead }), `put (${label})`);
|
|
1007
|
+
assert.equal(await store.get(fresh.token), null, `put (${label}): the refused put laid no row down`);
|
|
1008
|
+
const cp = createCheckpointFixture();
|
|
800
1009
|
await store.put(cp.token, cp);
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
assert.
|
|
1010
|
+
const before = structuredClone(await store.get(cp.token));
|
|
1011
|
+
const unchanged = async (what) => assert.deepEqual(await store.get(cp.token), before, `${what}: the row re-reads exactly as it was`);
|
|
1012
|
+
await rejectsSuperseded(() => store.setPendingSteer(cp.token, cp.scope, { text: "kit steer", trusted: false }, { holder: dead }), `setPendingSteer (${label})`);
|
|
1013
|
+
await unchanged(`setPendingSteer (${label})`);
|
|
1014
|
+
assert.equal(await store.expire(cp.token, cp.scope, { holder: dead }), false, `expire (${label}) loses`);
|
|
1015
|
+
await unchanged(`expire (${label})`);
|
|
1016
|
+
assert.equal(await store.resolve(cp.token, cp.scope, ALLOW, { rev: 0, holder: dead }), false, `resolve (${label}) loses — a store that forwards rev and drops expect.holder wins it here`);
|
|
1017
|
+
await unchanged(`resolve (${label})`);
|
|
1018
|
+
await claimArms("C-H0", store, async () => {
|
|
1019
|
+
assert.deepEqual(await store.claimTerminal(cp.token, cp.scope, { kind: "resolve", outcome: ALLOW, expect: { rev: 0, holder: dead } }), { claimed: false, current: { status: "pending", rev: 0 } }, `claimTerminal resolve arm (${label})`);
|
|
1020
|
+
await unchanged(`claimTerminal resolve arm (${label})`);
|
|
1021
|
+
assert.deepEqual(await store.claimTerminal(cp.token, cp.scope, { kind: "expire", expect: { holder: dead } }), { claimed: false, current: { status: "pending", rev: 0 } }, `claimTerminal expire arm (${label})`);
|
|
1022
|
+
await unchanged(`claimTerminal expire arm (${label})`);
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
holderRun("C-H1 grant holder: a put carrying a dead grant lays no row down — get(token) is null", async (store, grants) => {
|
|
1027
|
+
for (const [label, dead] of deadGrants(grants)) {
|
|
1028
|
+
const cp = createCheckpointFixture();
|
|
1029
|
+
await rejectsSuperseded(() => store.put(cp.token, cp, { holder: dead }), `put (${label})`);
|
|
1030
|
+
assert.equal(await store.get(cp.token), null, `put (${label})`);
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
holderRun("C-H2 grant holder: a current grant lands on every write — put, setPendingSteer, expire, resolve (and both claimTerminal arms, when implemented); no holder lands as before", async (store, grants) => {
|
|
1034
|
+
const cp = createCheckpointFixture();
|
|
1035
|
+
await store.put(cp.token, cp, { holder: grants.current() });
|
|
1036
|
+
assert.equal((await store.get(cp.token))?.status, "pending", "put with the current grant lands");
|
|
1037
|
+
assert.equal(await store.setPendingSteer(cp.token, cp.scope, { text: "kit steer", trusted: false }, { holder: grants.current() }), true);
|
|
1038
|
+
assert.equal(await steerCountOf(store, cp.token), 1, "setPendingSteer with the current grant appends");
|
|
1039
|
+
assert.equal(await store.resolve(cp.token, cp.scope, ALLOW, { rev: 0, holder: grants.current() }), true, "resolve with the current grant wins");
|
|
1040
|
+
assert.deepEqual(await rowNow(store, cp.token), ["resolved", 1], "the resolve landed");
|
|
1041
|
+
const heldWinner = (await store.get(cp.token))?.resolvedOutcome;
|
|
1042
|
+
const ex = createCheckpointFixture();
|
|
1043
|
+
await store.put(ex.token, ex);
|
|
1044
|
+
assert.equal(await store.expire(ex.token, ex.scope, { holder: grants.current() }), true, "expire with the current grant wins");
|
|
1045
|
+
assert.equal((await store.get(ex.token))?.status, "expired", "the expire landed");
|
|
1046
|
+
const plain = createCheckpointFixture();
|
|
1047
|
+
await store.put(plain.token, plain);
|
|
1048
|
+
assert.equal(await store.resolve(plain.token, plain.scope, ALLOW, { rev: 0 }), true, "no holder: the CAS is as before");
|
|
1049
|
+
assert.deepEqual(await rowNow(store, plain.token), ["resolved", 1], "no holder: the resolve landed");
|
|
1050
|
+
const plainWinner = (await store.get(plain.token))?.resolvedOutcome;
|
|
1051
|
+
assert.notEqual(plainWinner, undefined, "the resolve with no holder recorded its decision winner");
|
|
1052
|
+
assert.deepEqual(heldWinner, plainWinner, "the resolve carrying the current grant recorded the same decision winner as the one carrying none");
|
|
1053
|
+
await claimArms("C-H2", store, async () => {
|
|
1054
|
+
const [r, e] = [createCheckpointFixture(), createCheckpointFixture()];
|
|
1055
|
+
await store.put(r.token, r);
|
|
1056
|
+
await store.put(e.token, e);
|
|
1057
|
+
assert.deepEqual(await store.claimTerminal(r.token, r.scope, { kind: "resolve", outcome: ALLOW, expect: { rev: 0, holder: grants.current() } }), { claimed: true });
|
|
1058
|
+
assert.deepEqual(await rowNow(store, r.token), ["resolved", 1], "the claim's resolve landed");
|
|
1059
|
+
assert.deepEqual(await store.claimTerminal(e.token, e.scope, { kind: "expire", expect: { holder: grants.current() } }), { claimed: true });
|
|
1060
|
+
assert.equal((await store.get(e.token))?.status, "expired", "the claim's expire landed");
|
|
1061
|
+
});
|
|
1062
|
+
if (grants.retire !== undefined) {
|
|
1063
|
+
const h = grants.current();
|
|
1064
|
+
const first = createCheckpointFixture();
|
|
1065
|
+
await store.put(first.token, first, { holder: h });
|
|
1066
|
+
assert.equal(await store.setPendingSteer(first.token, first.scope, { text: "warm", trusted: false }, { holder: h }), true);
|
|
1067
|
+
const warmExpire = createCheckpointFixture();
|
|
1068
|
+
await store.put(warmExpire.token, warmExpire);
|
|
1069
|
+
assert.equal(await store.expire(warmExpire.token, warmExpire.scope, { holder: h }), true);
|
|
1070
|
+
const warmResolve = createCheckpointFixture();
|
|
1071
|
+
await store.put(warmResolve.token, warmResolve);
|
|
1072
|
+
assert.equal(await store.resolve(warmResolve.token, warmResolve.scope, ALLOW, { rev: 0, holder: h }), true);
|
|
1073
|
+
assert.deepEqual(await rowNow(store, warmResolve.token), ["resolved", 1], "the warm resolve landed");
|
|
1074
|
+
grants.retire(h);
|
|
1075
|
+
const second = createCheckpointFixture();
|
|
1076
|
+
await rejectsSuperseded(() => store.put(second.token, second, { holder: h }), "put after the holder was retired");
|
|
1077
|
+
assert.equal(await store.get(second.token), null, "the refused put laid no row down");
|
|
1078
|
+
await rejectsSuperseded(() => store.setPendingSteer(first.token, first.scope, { text: "late", trusted: false }, { holder: h }), "setPendingSteer after the holder was retired");
|
|
1079
|
+
assert.equal(await store.expire(first.token, first.scope, { holder: h }), false, "expire after the holder was retired");
|
|
1080
|
+
assert.equal(await store.resolve(first.token, first.scope, ALLOW, { rev: 0, holder: h }), false, "resolve after the holder was retired");
|
|
806
1081
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
1082
|
+
});
|
|
1083
|
+
holderRun("C-H3 grant holder: setPendingSteer carrying a dead grant throws holder.superseded and leaves the queue as it was", async (store, grants) => {
|
|
1084
|
+
const cp = createCheckpointFixture();
|
|
1085
|
+
await store.put(cp.token, cp);
|
|
1086
|
+
assert.equal(await store.setPendingSteer(cp.token, cp.scope, { text: "first", trusted: false }), true);
|
|
1087
|
+
for (const [label, dead] of deadGrants(grants)) {
|
|
1088
|
+
await rejectsSuperseded(() => store.setPendingSteer(cp.token, cp.scope, { text: `late ${label}`, trusted: false }, { holder: dead }), `setPendingSteer (${label})`);
|
|
1089
|
+
assert.deepEqual(readPendingSteerQueue((await store.get(cp.token)).state).map((s) => s.text), ["first"], `setPendingSteer (${label}): the queue is unchanged`);
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
holderRun("C-H4 grant holder: expire carrying a dead grant answers false with the row pending at its generation; claimTerminal's expire arm (when implemented) answers claimed:false, current pending at that rev", async (store, grants) => {
|
|
1093
|
+
for (const [label, dead] of deadGrants(grants)) {
|
|
1094
|
+
const cp = createCheckpointFixture();
|
|
1095
|
+
await store.put(cp.token, cp);
|
|
1096
|
+
assert.equal(await store.expire(cp.token, cp.scope, { holder: dead }), false, `expire (${label})`);
|
|
1097
|
+
assert.deepEqual(await rowNow(store, cp.token), ["pending", 0], `expire (${label})`);
|
|
1098
|
+
await claimArms("C-H4", store, async () => {
|
|
1099
|
+
assert.deepEqual(await store.claimTerminal(cp.token, cp.scope, { kind: "expire", expect: { holder: dead } }), { claimed: false, current: { status: "pending", rev: 0 } }, `claimTerminal expire arm (${label})`);
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
holderRun("C-H5 grant holder: resolve carrying a dead grant loses with the row pending at the generation the caller read (claimTerminal's resolve arm, when implemented, answers that reading)", async (store, grants) => {
|
|
1104
|
+
for (const [label, dead] of deadGrants(grants)) {
|
|
1105
|
+
const cp = createCheckpointFixture();
|
|
1106
|
+
await store.put(cp.token, cp);
|
|
1107
|
+
assert.equal(await store.resolve(cp.token, cp.scope, ALLOW, { rev: 0, holder: dead }), false, `resolve (${label})`);
|
|
1108
|
+
assert.deepEqual(await rowNow(store, cp.token), ["pending", 0], `resolve (${label}): the row is untouched by the lost CAS`);
|
|
1109
|
+
await claimArms("C-H5", store, async () => {
|
|
1110
|
+
assert.deepEqual(await store.claimTerminal(cp.token, cp.scope, { kind: "resolve", outcome: ALLOW, expect: { rev: 0, holder: dead } }), { claimed: false, current: { status: "pending", rev: 0 } }, `claimTerminal resolve arm (${label})`);
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1114
|
+
holderRun("C-H6 grant holder: a malformed holder makes every write throw (the judge throws) and moves no row", async (store, grants) => {
|
|
1115
|
+
const bad = grants.malformed;
|
|
1116
|
+
const fresh = createCheckpointFixture();
|
|
1117
|
+
await rejectsMalformed(() => store.put(fresh.token, fresh, { holder: bad }), "put");
|
|
1118
|
+
assert.equal(await store.get(fresh.token), null, "put: no row laid down");
|
|
1119
|
+
const cp = createCheckpointFixture();
|
|
1120
|
+
await store.put(cp.token, cp);
|
|
1121
|
+
const before = structuredClone(await store.get(cp.token));
|
|
1122
|
+
const unchanged = async (what) => assert.deepEqual(await store.get(cp.token), before, `${what}: the row re-reads exactly as it was`);
|
|
1123
|
+
await rejectsMalformed(() => store.setPendingSteer(cp.token, cp.scope, { text: "kit steer", trusted: false }, { holder: bad }), "setPendingSteer");
|
|
1124
|
+
await unchanged("setPendingSteer");
|
|
1125
|
+
await rejectsMalformed(() => store.expire(cp.token, cp.scope, { holder: bad }), "expire");
|
|
1126
|
+
await unchanged("expire");
|
|
1127
|
+
await rejectsMalformed(() => store.resolve(cp.token, cp.scope, ALLOW, { rev: 0, holder: bad }), "resolve");
|
|
1128
|
+
await unchanged("resolve");
|
|
1129
|
+
await claimArms("C-H6", store, async () => {
|
|
1130
|
+
await rejectsMalformed(() => store.claimTerminal(cp.token, cp.scope, { kind: "resolve", outcome: ALLOW, expect: { rev: 0, holder: bad } }), "claimTerminal resolve arm");
|
|
1131
|
+
await unchanged("claimTerminal resolve arm");
|
|
1132
|
+
await rejectsMalformed(() => store.claimTerminal(cp.token, cp.scope, { kind: "expire", expect: { holder: bad } }), "claimTerminal expire arm");
|
|
1133
|
+
await unchanged("claimTerminal expire arm");
|
|
1134
|
+
});
|
|
1135
|
+
});
|
|
1136
|
+
holderRun("C-H7 grant holder: a run row whose status is outside the judge's live set is not held — put and setPendingSteer refuse, expire and resolve lose (fail-closed)", async (store, grants) => {
|
|
1137
|
+
const fresh = createCheckpointFixture();
|
|
1138
|
+
await rejectsSuperseded(() => store.put(fresh.token, fresh, { holder: grants.unknownStatus() }), "put");
|
|
1139
|
+
assert.equal(await store.get(fresh.token), null, "put: no row laid down");
|
|
1140
|
+
const cp = createCheckpointFixture();
|
|
1141
|
+
await store.put(cp.token, cp);
|
|
1142
|
+
await rejectsSuperseded(() => store.setPendingSteer(cp.token, cp.scope, { text: "kit steer", trusted: false }, { holder: grants.unknownStatus() }), "setPendingSteer");
|
|
1143
|
+
assert.equal(await store.expire(cp.token, cp.scope, { holder: grants.unknownStatus() }), false, "expire");
|
|
1144
|
+
assert.equal(await store.resolve(cp.token, cp.scope, ALLOW, { rev: 0, holder: grants.unknownStatus() }), false, "resolve");
|
|
1145
|
+
assert.deepEqual(await rowNow(store, cp.token), ["pending", 0], "the row did not move");
|
|
1146
|
+
assert.equal(await steerCountOf(store, cp.token), 0, "the queue did not move");
|
|
811
1147
|
});
|
|
812
1148
|
run("identity re-key: the member is carried, and a plan over an empty store is an empty plan", async () => {
|
|
813
1149
|
const store = make();
|
|
@@ -816,8 +1152,7 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
816
1152
|
});
|
|
817
1153
|
run("identity re-key: leave re-files the identity cells in place at the next generation — the index facts, both listings and the scope a CAS is judged in follow; a stale generation loses; a second leave finds nothing", async () => {
|
|
818
1154
|
const store = make();
|
|
819
|
-
const cp =
|
|
820
|
-
cp.state.legScope = "alice";
|
|
1155
|
+
const cp = fixtureWithState({ scope: "alice", principal: "alice", durableApproval: { scope: "alice" }, sessionId: "rekey-1" }, { legScope: "alice" });
|
|
821
1156
|
await store.put(cp.token, cp);
|
|
822
1157
|
const move = { fromPrincipal: "alice", toPrincipal: "bob", scopes: [{ fromScope: "alice", toScope: "bob" }] };
|
|
823
1158
|
assert.deepEqual(await store.rekeyIdentity({ ...move, mode: "plan" }), { kind: "plan", rows: 1, conflicting: 0, unpairedScopeRows: 0 });
|
|
@@ -836,8 +1171,7 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
836
1171
|
});
|
|
837
1172
|
run("identity re-key: the candidate pre-screen misses no cell — a resource slice filed under a scope that is no name, and a row only its recorded partition holds", async () => {
|
|
838
1173
|
const store = make();
|
|
839
|
-
const slice =
|
|
840
|
-
slice.state.legScope = "alice";
|
|
1174
|
+
const slice = fixtureWithState({ scope: "res\nscope", principal: "carol", durableApproval: { scope: "alice" }, sessionId: "rekey-slice" }, { legScope: "alice" });
|
|
841
1175
|
const partition = createCheckpointFixture({ scope: "tenant-x", principal: "carol", isolationScope: "alice", sessionId: "rekey-partition" });
|
|
842
1176
|
for (const row of [slice, partition])
|
|
843
1177
|
await store.put(row.token, row);
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { type FileHistoryStore } from "../file-history-store.js";
|
|
1
|
+
import { type FileHistoryLimitSource, type FileHistoryStore } from "../file-history-store.js";
|
|
2
2
|
import { type ContractAssertionRunner } from "./contract-harness.js";
|
|
3
3
|
export declare function fileHistoryStoreContract(make: () => FileHistoryStore, runAssertion?: ContractAssertionRunner, onOptionalMember?: (report: {
|
|
4
|
-
member: "blobExchange" | "readBoundaries";
|
|
4
|
+
member: "blobExchange" | "readBoundaries" | "sizeLimit";
|
|
5
5
|
status: "verified" | "absent";
|
|
6
|
-
}) => void
|
|
6
|
+
}) => void,
|
|
7
|
+
/** The binding's bounded store, for the `too_large` cell: `capped()` returns a FRESH, empty store that refuses one stored copy over
|
|
8
|
+
* `bytes` (a whole number, 2 or more) and names `source` as where the bound comes from — the bundled stores' `maxBlobBytes`
|
|
9
|
+
* (`store_option`), or a backend's own bound (`backend`). Absent ⇒ the cell is reported `sizeLimit: absent`. */
|
|
10
|
+
limits?: {
|
|
11
|
+
readonly capped: () => FileHistoryStore;
|
|
12
|
+
readonly bytes: number;
|
|
13
|
+
readonly source: FileHistoryLimitSource;
|
|
14
|
+
}): Promise<void>;
|
|
@@ -38,7 +38,15 @@ function envWithFailingRead(inner, fail) {
|
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
const NAMES_A_FAULT = { track_failed: true, snapshot_failed: true, restore_failed: true, adopt_failed: true, unsupported_format: true, not_found: false, conflict: false, aborted: false };
|
|
41
|
+
const NAMES_A_FAULT = { track_failed: true, snapshot_failed: true, restore_failed: true, adopt_failed: true, unsupported_format: true, too_large: true, not_found: false, conflict: false, aborted: false };
|
|
42
|
+
function assertTooLarge(answer, limit, what) {
|
|
43
|
+
assert.equal(answer.ok, false, `${what}: over the bound is refused`);
|
|
44
|
+
const error = answer.error;
|
|
45
|
+
assert.equal(error?.code, "too_large", `${what}: the refusal's code`);
|
|
46
|
+
assert.equal(error?.permanence, "terminal", `${what}: no retry makes the same bytes fit`);
|
|
47
|
+
assert.deepEqual(error?.limit, { bytes: limit.bytes, source: limit.source }, `${what}: the refusal names the bound and where it comes from`);
|
|
48
|
+
assertPermanenceWord(error, what);
|
|
49
|
+
}
|
|
42
50
|
function assertPermanenceWord(error, what) {
|
|
43
51
|
const p = error?.permanence;
|
|
44
52
|
assert.ok(p === undefined || isGovernanceRetryClass(p), `${what}: permanence must be absent or a GovernanceRetryClass word, got ${typeof p === "string" ? `"${p}"` : typeof p}`);
|
|
@@ -57,8 +65,60 @@ async function withTree(fn) {
|
|
|
57
65
|
await rm(dir, { recursive: true, force: true });
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
|
-
export async function fileHistoryStoreContract(make, runAssertion, onOptionalMember) {
|
|
68
|
+
export async function fileHistoryStoreContract(make, runAssertion, onOptionalMember, limits) {
|
|
61
69
|
const { run, settle } = beginContract(runAssertion);
|
|
70
|
+
run("too_large (when the binding declares a bound): one stored copy of exactly the bound is kept, one byte over is refused — counted in bytes, a multi-byte character across the bound included — at trackEdit, snapshot (a later file of the boundary over it), blobExchange.put and importHistory, with the bound and its source and nothing of the call committed; absence is REPORTED", async () => {
|
|
71
|
+
if (limits === undefined) {
|
|
72
|
+
onOptionalMember?.({ member: "sizeLimit", status: "absent" });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const n = limits.bytes;
|
|
76
|
+
const limit = { bytes: n, source: limits.source };
|
|
77
|
+
assert.ok(Number.isSafeInteger(n) && n >= 2, "the binding's bound is a whole number of bytes, 2 or more");
|
|
78
|
+
await withTree(async (dir, env) => {
|
|
79
|
+
const store = limits.capped();
|
|
80
|
+
const exact = "a".repeat(n);
|
|
81
|
+
const over = "a".repeat(n + 1);
|
|
82
|
+
const across = `${"a".repeat(n - 1)}é`;
|
|
83
|
+
await writeFile(join(dir, "a-first.txt"), "b");
|
|
84
|
+
await writeFile(join(dir, "exact.txt"), exact);
|
|
85
|
+
await writeFile(join(dir, "over.txt"), over);
|
|
86
|
+
await writeFile(join(dir, "across.txt"), across);
|
|
87
|
+
assert.deepEqual(await store.trackEdit("sc", join(dir, "a-first.txt"), env, dir), { ok: true, minted: true });
|
|
88
|
+
assert.deepEqual(await store.trackEdit("sc", join(dir, "exact.txt"), env, dir), { ok: true, minted: true }, "a copy of exactly the bound is kept");
|
|
89
|
+
assertTooLarge(await store.trackEdit("sc", join(dir, "over.txt"), env, dir), limit, "trackEdit, one byte over");
|
|
90
|
+
assertTooLarge(await store.trackEdit("sc", join(dir, "across.txt"), env, dir), limit, "trackEdit, a two-byte character across the bound");
|
|
91
|
+
assert.deepEqual(await store.trackEdit("sc", join(dir, "over.txt"), env, dir).then((r) => r.ok), false, "nothing was recorded: the next touch is a first touch again, refused again");
|
|
92
|
+
assert.deepEqual(await store.snapshot("sc", "b0", env, dir), { ok: true }, "a boundary of copies at or under the bound is committed");
|
|
93
|
+
await writeFile(join(dir, "a-first.txt"), "c");
|
|
94
|
+
await writeFile(join(dir, "exact.txt"), over);
|
|
95
|
+
assertTooLarge(await store.snapshot("sc", "b1", env, dir), limit, "snapshot whose later file grew past the bound");
|
|
96
|
+
assert.equal((await store.restore("sc", "b1", env, dir)).error?.code, "not_found", "the refused boundary was never committed");
|
|
97
|
+
const exchange = fileHistoryBlobExchangeOf(store);
|
|
98
|
+
if (exchange !== undefined) {
|
|
99
|
+
const bytes = new TextEncoder().encode(over);
|
|
100
|
+
const hash = createHash("sha256").update(bytes).digest("hex");
|
|
101
|
+
assertTooLarge(await exchange.put(hash, bytes), limit, "blobExchange.put");
|
|
102
|
+
assert.deepEqual([...(await exchange.has([hash]))], [], "a refused put stores nothing");
|
|
103
|
+
const fits = new TextEncoder().encode(`${"c".repeat(n - 1)}d`);
|
|
104
|
+
assert.deepEqual(await exchange.put(createHash("sha256").update(fits).digest("hex"), fits), { ok: true }, "blobExchange.put of exactly the bound is kept");
|
|
105
|
+
}
|
|
106
|
+
if (store.importHistory !== undefined) {
|
|
107
|
+
const envelopeOf = (hash) => wireEnvelope({
|
|
108
|
+
formatVersion: "file-history/1",
|
|
109
|
+
tracked: [{ relOrAbsPath: "big.txt", keyKind: "root-relative", keyFamily: "posix", baseAvailable: true, versions: [{ version: 1, blobHash: hash, backupTime: "t" }] }],
|
|
110
|
+
boundaries: [{ entryId: "i0", files: [{ relOrAbsPath: "big.txt", version: 1 }] }],
|
|
111
|
+
});
|
|
112
|
+
const bytes = new TextEncoder().encode("h".repeat(n + 1));
|
|
113
|
+
const hash = createHash("sha256").update(bytes).digest("hex");
|
|
114
|
+
assertTooLarge(await store.importHistory("imp", envelopeOf(hash), async () => bytes), { bytes: n, source: limits.source }, "importHistory of a blob over the bound");
|
|
115
|
+
assert.equal((await store.restore("imp", "i0", env, dir)).error?.code, "not_found", "nothing of the refused import was published");
|
|
116
|
+
const fits = new TextEncoder().encode(`${"f".repeat(n - 1)}g`);
|
|
117
|
+
assert.deepEqual(await store.importHistory("imp2", envelopeOf(createHash("sha256").update(fits).digest("hex")), async () => fits), { ok: true }, "importHistory of a blob of exactly the bound is published");
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
onOptionalMember?.({ member: "sizeLimit", status: "verified" });
|
|
121
|
+
});
|
|
62
122
|
run("blobExchange (optional member group): read as one group; put checks the address and stores nothing it refuses; has answers from the index; get round-trips; absence is REPORTED", async () => {
|
|
63
123
|
const exchange = fileHistoryBlobExchangeOf(make());
|
|
64
124
|
if (exchange === undefined) {
|