@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
|
@@ -7,20 +7,102 @@ export function checkpointOccMatches(cp, expect) {
|
|
|
7
7
|
export function checkpointClaimRevOf(read) {
|
|
8
8
|
return checkpointRevOf(read) + 1;
|
|
9
9
|
}
|
|
10
|
-
export function
|
|
11
|
-
if (
|
|
10
|
+
export function readHolderJudge(subject, value) {
|
|
11
|
+
if (value === undefined || typeof value === "function")
|
|
12
|
+
return value;
|
|
13
|
+
const e = new Error(`${subject} must be a function (the deployment's synchronous grant judge) when given (got ${value === null ? "null" : `a ${typeof value}`})`);
|
|
14
|
+
e.code = "config.invalid_argument";
|
|
15
|
+
throw e;
|
|
16
|
+
}
|
|
17
|
+
export function joinHolderJudge(judges, authority, judge, kind, what) {
|
|
18
|
+
const mine = judge ?? null;
|
|
19
|
+
if (!judges.has(authority)) {
|
|
20
|
+
judges.set(authority, mine);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const theirs = judges.get(authority) ?? null;
|
|
24
|
+
if (theirs === mine)
|
|
25
|
+
return;
|
|
26
|
+
const said = (j) => (j === null ? "no holder judge" : "a holder judge");
|
|
27
|
+
throw storeRefusal(kind, `${what}: this store joins an authority already built with ${theirs === null || mine === null ? said(theirs) : "another holder judge"}, but it brings ${theirs === null || mine === null ? said(mine) : "a different function"} — the judge belongs to the shared authority, so every store over it must be built with the same judge (one function object, or none beside none); nothing was joined.`);
|
|
28
|
+
}
|
|
29
|
+
const STORE_CODE = { checkpoint: "config.invalid_checkpoint_store", session: "config.invalid_session_store" };
|
|
30
|
+
function storeRefusal(kind, message) {
|
|
31
|
+
const e = new Error(message);
|
|
32
|
+
e.code = STORE_CODE[kind];
|
|
33
|
+
return e;
|
|
34
|
+
}
|
|
35
|
+
export function holderJudgedCurrent(holder, holderIsCurrent, kind) {
|
|
36
|
+
if (holder === undefined)
|
|
12
37
|
return true;
|
|
13
38
|
if (holderIsCurrent === undefined)
|
|
14
39
|
return false;
|
|
15
|
-
const answer = holderIsCurrent(
|
|
40
|
+
const answer = holderIsCurrent(holder);
|
|
16
41
|
if (typeof answer !== "boolean") {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
e.code = "config.invalid_checkpoint_store";
|
|
20
|
-
throw e;
|
|
42
|
+
const said = answer === null ? "null" : typeof answer === "object" ? "an object (an async judge answers a promise)" : `a ${typeof answer}`;
|
|
43
|
+
throw storeRefusal(kind, `the ${kind} store's \`holderIsCurrent\` judge must answer \`true\` or \`false\` synchronously (it answered ${said}) — any other answer is a wiring error, not a judgement; the write did not run and nothing was written. Make the judge a synchronous read of the grant table.`);
|
|
21
44
|
}
|
|
22
45
|
return answer === true;
|
|
23
46
|
}
|
|
47
|
+
export function checkpointHolderMatches(expect, holderIsCurrent) {
|
|
48
|
+
return holderJudgedCurrent(expect?.holder, holderIsCurrent, "checkpoint");
|
|
49
|
+
}
|
|
50
|
+
const FENCE_KEYS = new Set(["holder", "requireHolder"]);
|
|
51
|
+
export function readStoreFence(kind, seat, store) {
|
|
52
|
+
let fence;
|
|
53
|
+
try {
|
|
54
|
+
fence = store === null || store === undefined ? undefined : store.fence;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
throw storeRefusal(kind, `${seat}: the store's \`fence\` declaration could not be read (its accessor threw) — a declaration that does not answer is no declaration; fix the store.`);
|
|
58
|
+
}
|
|
59
|
+
if (fence === undefined)
|
|
60
|
+
return undefined;
|
|
61
|
+
const refuse = (what) => {
|
|
62
|
+
throw storeRefusal(kind, `${seat}: the store's \`fence\` declaration ${what} — a store that judges the holder of every write it is handed that carries one declares \`fence = { holder: "writes" }\` (optionally \`requireHolder: true\`), and a store that judges none declares nothing.`);
|
|
63
|
+
};
|
|
64
|
+
if (fence === null || typeof fence !== "object")
|
|
65
|
+
return refuse("is not an object");
|
|
66
|
+
let holder;
|
|
67
|
+
let requireHolder;
|
|
68
|
+
let keys;
|
|
69
|
+
let isArray;
|
|
70
|
+
try {
|
|
71
|
+
isArray = Array.isArray(fence);
|
|
72
|
+
keys = Reflect.ownKeys(fence).map(String);
|
|
73
|
+
holder = fence.holder;
|
|
74
|
+
requireHolder = fence.requireHolder;
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return refuse("could not be read (an accessor threw)");
|
|
78
|
+
}
|
|
79
|
+
if (isArray)
|
|
80
|
+
return refuse("is not an object");
|
|
81
|
+
if (holder === true)
|
|
82
|
+
return refuse("is the retired `{ holder: true }`, which promised the holder of `resolve` alone; the one declaration is now `holder: \"writes\"` — the store judges the holder on every write (session append and leaf move; card put, steer, expire and resolve), and a store declaring the old value is refused rather than trusted with writes it never judged");
|
|
83
|
+
if (holder !== "writes")
|
|
84
|
+
return refuse(`has \`holder\` ${typeof holder === "string" ? "set to another word" : holder === undefined ? "missing" : `of type ${holder === null ? "null" : typeof holder}`}, not "writes"`);
|
|
85
|
+
if (requireHolder !== undefined && typeof requireHolder !== "boolean")
|
|
86
|
+
return refuse(`has \`requireHolder\` of type ${requireHolder === null ? "null" : typeof requireHolder}, not a boolean`);
|
|
87
|
+
const stray = keys.filter((k) => !FENCE_KEYS.has(k));
|
|
88
|
+
if (stray.length > 0)
|
|
89
|
+
return refuse(`carries ${stray.length === 1 ? "a member" : "members"} it does not take (${stray.map((k) => JSON.stringify(k)).join(", ")})`);
|
|
90
|
+
return Object.freeze(requireHolder === true ? { holder: "writes", requireHolder: true } : { holder: "writes" });
|
|
91
|
+
}
|
|
92
|
+
export function assertStoreJudgesHolder(kind, seat, store, holder, startedBy) {
|
|
93
|
+
if (store === undefined)
|
|
94
|
+
return undefined;
|
|
95
|
+
const fence = readStoreFence(kind, seat, store);
|
|
96
|
+
const named = kind === "checkpoint" ? "CheckpointStore" : "SessionStore";
|
|
97
|
+
if (holder === undefined) {
|
|
98
|
+
if (fence?.requireHolder !== true || startedBy === "engine")
|
|
99
|
+
return fence;
|
|
100
|
+
throw storeRefusal(kind, `${seat}: the wired ${named} declares \`requireHolder: true\` — this store requires every run or verb the host starts to carry a grant holder, and this one carries none, so it was refused before anything was written. Pass the grant the run acts under as \`RunInternals.holder\` (a session verb: the request's \`holder\`).`);
|
|
101
|
+
}
|
|
102
|
+
if (fence !== undefined)
|
|
103
|
+
return fence;
|
|
104
|
+
throw storeRefusal(kind, `${seat}: the run carries a grant holder, but the wired ${named} does not declare \`fence = { holder: "writes" }\` — a store that does not judge the holder on its writes would ignore it, and the fence would hold nothing. Wire a store that judges holders (the in-tree stores take \`holderIsCurrent\`) or stop passing one.`);
|
|
105
|
+
}
|
|
24
106
|
export function assertHolderValue(holder) {
|
|
25
107
|
if (holder === undefined || (typeof holder === "string" && holder !== ""))
|
|
26
108
|
return;
|
|
@@ -29,10 +111,3 @@ export function assertHolderValue(holder) {
|
|
|
29
111
|
e.code = "config.invalid_argument";
|
|
30
112
|
throw e;
|
|
31
113
|
}
|
|
32
|
-
export function assertCheckpointStoreJudgesHolder(seat, store, holder) {
|
|
33
|
-
if (holder === undefined || store === undefined || store.fence?.holder === true)
|
|
34
|
-
return;
|
|
35
|
-
const e = new Error(`${seat}: the run carries a claim holder, but the wired CheckpointStore does not declare \`fence = { holder: true }\` — a store that does not judge the holder in its resolve would ignore it, and the fence would hold nothing. Wire a store that judges holders (the in-tree stores take \`holderIsCurrent\`) or stop passing one.`);
|
|
36
|
-
e.code = "config.invalid_checkpoint_store";
|
|
37
|
-
throw e;
|
|
38
|
-
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Checkpoint, CheckpointSummary, CheckpointToken } from "./checkpoint-store.js";
|
|
2
|
+
import { CheckpointError } from "./checkpoint-features.js";
|
|
2
3
|
import { facetOf, type GateKind } from "./pause-registry.js";
|
|
3
4
|
/**
|
|
4
5
|
* The page bounds of the two listing faces: a query without `limit` reads `default` rows, an explicit `limit` is an integer in
|
|
@@ -24,7 +25,8 @@ export interface CheckpointPage<R, C> {
|
|
|
24
25
|
/** Pass it as the next query's `after`. The store mints it from its own order key; a caller never builds one. */
|
|
25
26
|
readonly next?: C;
|
|
26
27
|
}
|
|
27
|
-
/** The order key of an overdue page: the
|
|
28
|
+
/** The order key of an overdue page: the instant the row is overdue at ({@link checkpointOverdueAt}: its deadline, or under an age
|
|
29
|
+
* backstop its `createdAt` plus the backstop; `-Infinity` for a value that is not a finite number), then its token. */
|
|
28
30
|
export interface CheckpointOverdueCursor {
|
|
29
31
|
readonly deadline: number;
|
|
30
32
|
readonly token: CheckpointToken;
|
|
@@ -43,6 +45,12 @@ export interface CheckpointOverdueQuery {
|
|
|
43
45
|
after?: CheckpointOverdueCursor;
|
|
44
46
|
/** At most this many rows, an integer in 1..{@link CHECKPOINT_LIST_LIMITS}`.overdue.max`; absent = the default. */
|
|
45
47
|
limit?: number;
|
|
48
|
+
/**
|
|
49
|
+
* The age backstop, in ms (a safe integer, 0 or more — a finite `createdAt` plus it stays finite): a pending row that carries no deadline is overdue once its `createdAt` plus
|
|
50
|
+
* this has passed the cutoff, and sorts at that instant — {@link checkpointOverdueAt}, the one rule. A row that carries a deadline is
|
|
51
|
+
* judged by its deadline alone. Absent = a row with no deadline is never overdue.
|
|
52
|
+
*/
|
|
53
|
+
maxAgeMs?: number;
|
|
46
54
|
}
|
|
47
55
|
/** The order key of a session page: the row's `createdAt` (`-Infinity` for one that is not a finite number), then its token. */
|
|
48
56
|
export interface CheckpointSessionCursor {
|
|
@@ -59,6 +67,13 @@ export interface CheckpointSessionCursor {
|
|
|
59
67
|
export interface CheckpointSessionQuery {
|
|
60
68
|
/** The session id (non-empty). */
|
|
61
69
|
sessionId: string;
|
|
70
|
+
/**
|
|
71
|
+
* Which session of a row `sessionId` names: `"session"` (absent) = the row's own {@link Checkpoint.sessionId}, the session a resume
|
|
72
|
+
* continues; `"run"` = the session of the run the row's card is on, {@link checkpointRunSessionOf} — a cascade rung's and a repair restart's
|
|
73
|
+
* card belong to their host's run, every other card to its own session. A row whose run session cannot be read is attributable to no run:
|
|
74
|
+
* left out of a `"run"` page and disclosed.
|
|
75
|
+
*/
|
|
76
|
+
axis?: "session" | "run";
|
|
62
77
|
/** Only the rows filed in this scope. */
|
|
63
78
|
scope?: string;
|
|
64
79
|
/** Only the rows in this status. Absent = every status. */
|
|
@@ -75,14 +90,16 @@ export interface CheckpointSessionQuery {
|
|
|
75
90
|
limit?: number;
|
|
76
91
|
}
|
|
77
92
|
/**
|
|
78
|
-
* One row of a session page. `row` is a readable row (its members match the query and every member the face judged is well
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
93
|
+
* One row of a session page. `row` is a readable row (its members match the query and every member the face judged is well formed). `unreadable`
|
|
94
|
+
* is a row of THIS session that matches every filter the store could judge but whose stored shape the face cannot read — a token member other than
|
|
95
|
+
* the key it is filed under, a scope that is not a string, a status outside the three words, a gate with no registered kind, a pending action with
|
|
96
|
+
* no kind, a tool approval with no tool call id, a `createdAt` that is not a finite number, a state that is not an object: it is answered rather
|
|
97
|
+
* than skipped (an unreadable row is not an absent one) and rather than failing the page (one damaged row does not hide the readable rows beside
|
|
98
|
+
* it). A consumer that takes its token to `get` never meets a card it can resume: `get` refuses a row that does not decode as a row at all
|
|
99
|
+
* ({@link storedCheckpointRowRefusal}: its token, scope or status), and answers any other row as stored — the row judge (`judgeCheckpointRow`)
|
|
100
|
+
* answers it `damaged`, and a resume refuses it before anything is consumed; one exception: a status string none of the three words is handed back
|
|
101
|
+
* and the row judge answers it `ok` — the readers of the status read it as no longer pending (a resume `already_resolved`, the decision judge
|
|
102
|
+
* `not_pending`; KL-5246-b). The store discloses it through its own seat. Its `token` is the key the store files it under.
|
|
86
103
|
*/
|
|
87
104
|
export type CheckpointRowRead = {
|
|
88
105
|
readonly kind: "row";
|
|
@@ -117,10 +134,13 @@ export interface CheckpointOverdueQueryReading {
|
|
|
117
134
|
readonly facet: CheckpointFacet;
|
|
118
135
|
readonly after?: CheckpointOverdueCursor;
|
|
119
136
|
readonly limit: number;
|
|
137
|
+
readonly maxAgeMs?: number;
|
|
120
138
|
}
|
|
121
|
-
/** {@link readCheckpointSessionQuery}'s answer: the members as read, the default order and limit filled in
|
|
139
|
+
/** {@link readCheckpointSessionQuery}'s answer: the members as read, the default order and limit filled in (an absent `axis` is the
|
|
140
|
+
* session axis). */
|
|
122
141
|
export interface CheckpointSessionQueryReading {
|
|
123
142
|
readonly sessionId: string;
|
|
143
|
+
readonly axis?: "session" | "run";
|
|
124
144
|
readonly scope?: string;
|
|
125
145
|
readonly status?: CheckpointRowStatus;
|
|
126
146
|
readonly gateKinds?: readonly GateKind[];
|
|
@@ -182,6 +202,60 @@ export declare function checkpointDeadlinePassed(deadline: number | null | undef
|
|
|
182
202
|
* `Number.MIN_SAFE_INTEGER`, past every cutoff. Never the reverse: reading such a row as "no deadline" would keep it pending forever.
|
|
183
203
|
*/
|
|
184
204
|
export declare function checkpointDeadlineColumn(deadline: number | null | undefined): number | null;
|
|
205
|
+
/**
|
|
206
|
+
* The instant a pending row is overdue at, for {@link CheckpointOverdueQuery}: its deadline when it carries one (as stored — a value
|
|
207
|
+
* that is not a finite number is past every cutoff, {@link checkpointDeadlinePassed}); else, under an age backstop (`maxAgeMs`), its
|
|
208
|
+
* `createdAt` plus the backstop (a `createdAt` that is not a finite number answers `NaN`: past every cutoff, sorted first — the
|
|
209
|
+
* deadline rule's reason: a bound nobody can evaluate would keep the row pending forever); else `undefined`, never overdue. The overdue
|
|
210
|
+
* face judges and orders by this one value. A backend with columns answers it as `deadline <= cutoff OR (deadline IS NULL AND
|
|
211
|
+
* (created_at IS NULL OR created_at + maxAgeMs <= cutoff))`, ordered by `COALESCE(deadline, created_at + maxAgeMs, -9007199254740991)`
|
|
212
|
+
* then token — the deadline column already holds `Number.MIN_SAFE_INTEGER` for a deadline that is not a finite number, so both damaged
|
|
213
|
+
* forms share that key and the token breaks the tie, as the `-Infinity` key does here.
|
|
214
|
+
*/
|
|
215
|
+
export declare function checkpointOverdueAt(row: {
|
|
216
|
+
readonly deadline?: unknown;
|
|
217
|
+
readonly createdAt?: unknown;
|
|
218
|
+
}, maxAgeMs: number | undefined): number | null | undefined;
|
|
219
|
+
/**
|
|
220
|
+
* THE RUN AXIS of a checkpoint row — the session of the run that redeems its card: the leg's `hostSessionId` when the row records a
|
|
221
|
+
* composition leg whose entry {@link RUN_SESSION_OF_ENTRY} reads as the host's (a cascade rung, a repair restart), else the row's own
|
|
222
|
+
* `sessionId` (a verifier's card, and every row that records no leg). Pure, total, reads only the row's own two members. `undefined` =
|
|
223
|
+
* the row is attributable to no run: its `sessionId` is not a string, its `state` is not an object, or the leg it records is not a
|
|
224
|
+
* readable leg (not an object, an entry outside the set, a host entry whose host session is not a non-empty string). Not
|
|
225
|
+
* `workSessionOfLeg` (where a leg STANDS — a verifier stands in its implementation's tree, yet its card is its own). The session
|
|
226
|
+
* listing's `axis: "run"` and the index column {@link import("./checkpoint-store.js").CheckpointIndexFacts.runSessionId} read it.
|
|
227
|
+
*/
|
|
228
|
+
export declare function checkpointRunSessionOf(row: {
|
|
229
|
+
readonly sessionId: unknown;
|
|
230
|
+
readonly state: unknown;
|
|
231
|
+
}): string | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* The one refusal of a stored checkpoint row nothing can read as a row — `CheckpointError` code `checkpoint.invalid_outcome`,
|
|
234
|
+
* `detail.reason` `requirements_damaged`, the message one of the two row-damaged sentences (picked by `standing`, below) then `diagnostic` (which names what was wrong by
|
|
235
|
+
* its shape, never a stored value). The row judge answers a row it cannot read with it, and `CheckpointStore.get` throws it for a row
|
|
236
|
+
* it cannot hand back ({@link storedCheckpointRowRefusal}); a backend that decodes stored bytes (a SQL store) throws it when the bytes
|
|
237
|
+
* do not decode at all, with its own diagnostic (`"the stored bytes are not JSON"`). `thrownName` = what was thrown while reading.
|
|
238
|
+
* `standing` = what the refuser can read of the row's status: `"pending"` (it READ `pending`; the row judge's own throw arm,
|
|
239
|
+
* `readRowTotal` in checkpoint-row-verdict.ts, passes it without reading the status — KL-4748-a) opens with the row-damaged sentence
|
|
240
|
+
* (the row stays pending, nothing was consumed); `"unknown"` (a settled status, one that does not read, or bytes that do not decode —
|
|
241
|
+
* the default) opens with {@link CHECKPOINT_ROW_UNCONFIRMED_SENTENCE}, which claims neither: such a row may have been decided and its
|
|
242
|
+
* action may already have run, so the sentence never tells a reader to start the task again.
|
|
243
|
+
*/
|
|
244
|
+
export declare function checkpointRowUnreadable(diagnostic: string, standing?: "pending" | "unknown", thrownName?: string): CheckpointError;
|
|
245
|
+
/** Is `e` the refusal {@link checkpointRowUnreadable} mints (a row nothing can read) — the one test an engine reader of `get` uses to
|
|
246
|
+
* tell it from a store that could not be reached. */
|
|
247
|
+
export declare function isCheckpointRowUnreadable(e: unknown): boolean;
|
|
248
|
+
/**
|
|
249
|
+
* `CheckpointStore.get`'s judgment of the row filed under `key`: `undefined` = hand it back as stored; else the refusal `get` throws —
|
|
250
|
+
* {@link checkpointRowUnreadable} for a value that is not a row of this table's `rowKey` segment (not an object; its token, scope or
|
|
251
|
+
* status not a string — the segment the file store's replay drops a row by), or whose token member is not `key` (it would be answered
|
|
252
|
+
* as another token's row); a member whose read throws is refused too. Any other damage (a status string none of the three words
|
|
253
|
+
* included) is not `get`'s to judge: the row is answered, and the row judge reads it. Total. The refusal opens with the pending sentence
|
|
254
|
+
* only for a refused row whose status reads `pending` and that records no execution outcome (the judge's `execution_recorded` fact: such
|
|
255
|
+
* a row's action may have run); any other — settled, a status that does not read, an outcome recorded — opens with the unconfirmed one
|
|
256
|
+
* (`standing` of the mint), and the diagnostic names the stored status when it is one of the three words.
|
|
257
|
+
*/
|
|
258
|
+
export declare function storedCheckpointRowRefusal(key: string, row: unknown): CheckpointError | undefined;
|
|
185
259
|
/** A row's members as the listing faces read them: each read once and widened to `unknown`, since the stored shape is what is judged
|
|
186
260
|
* (a row came back from storage; its type says what was written, not what is there). */
|
|
187
261
|
interface RowMembers {
|
|
@@ -211,7 +285,7 @@ type ShapeMembers = Pick<RowMembers, "gate" | "pendingAction" | "state" | "creat
|
|
|
211
285
|
* this table and no shape test of their own, so over these members no face answers `ok` for a row another cannot read. The gate a
|
|
212
286
|
* record of a registered gate kind; the pending action a record of a registered pending kind — the one the gate's kind pairs with in
|
|
213
287
|
* the pause registry — a tool approval carrying a tool call id and, when it carries the identity of its tool, a capability id of the form
|
|
214
|
-
* the engine mints ({@link isSha16}: the park mints it from the roster row, never by another route); the state a record, whose leg task id (the summary's agent id reads it) is absent or a string — the task id as the leg minted it, a blank one included; `createdAt` a finite number; `deadline` absent or a finite number; the resource ledger absent or a record
|
|
288
|
+
* the engine mints ({@link isSha16}: the park mints it from the roster row, never by another route); the state a record, whose leg task id (the summary's agent id reads it) is absent or a string — the task id as the leg minted it, a blank one included — and whose workspace handle (the resume leg's one reading of where its workspace is) is absent or carries its three required members as strings ({@link workspaceHandleShape}); `createdAt` a finite number; `deadline` absent or a finite number; the resource ledger absent or a record
|
|
215
289
|
* (the summary reads its spend); the checkpoint id absent or a non-blank string (the summary echoes it and names the row by it: an
|
|
216
290
|
* empty one, or one of whitespace alone, names no row, and no writer mints one); the synchronous-child block (the parent session and task and the tree's root
|
|
217
291
|
* session and its occupant) each absent or a non-blank string of the same kind. Each entry names the member by its shape, never a particular value; `undefined`
|
|
@@ -229,6 +303,10 @@ export interface RowMemberProblem {
|
|
|
229
303
|
* refusal and the checkpoint shape table's sentence (one text: the judge's sentence table reads it from here). An earlier release's
|
|
230
304
|
* intact row that this release reads differently is not this row: it is `reading_changed`, with its own sentence. */
|
|
231
305
|
export declare const CHECKPOINT_ROW_DAMAGED_SENTENCE = "This engine cannot resume this checkpoint: its content does not read the way it was recorded when it was parked \u2014 it was changed or lost in storage. The checkpoint stays pending and nothing was consumed. Expire it, then start the task again.";
|
|
306
|
+
/** The fixed sentence of a stored row a store's `get` refuses when the row does not read as pending — its status is settled, or does
|
|
307
|
+
* not read, or its bytes do not decode: the row cannot be read, and whether it was settled and whether the action it approved has
|
|
308
|
+
* run cannot be confirmed from it. A pending row keeps {@link CHECKPOINT_ROW_DAMAGED_SENTENCE}. */
|
|
309
|
+
export declare const CHECKPOINT_ROW_UNCONFIRMED_SENTENCE = "This engine cannot read this checkpoint row: its stored content does not read as a row, so whether it was already settled \u2014 and whether the action it approved has already run \u2014 cannot be confirmed from it. The action may already have run: check what became of it before deciding whether to run the work again \u2014 running it again may repeat it.";
|
|
232
310
|
/**
|
|
233
311
|
* THE CHECKPOINT ROW'S SHAPE TABLE, three named segments, each face judging the segments it reads (`rowShapeReader`, row-shape.ts):
|
|
234
312
|
* - `rowKey` — what the file replay files a row under: a string token, scope and status (the replay's row judge, and an event's
|
|
@@ -249,7 +327,8 @@ export declare const CHECKPOINT_ROW_SHAPE: import("./row-shape.js").RowShapeRead
|
|
|
249
327
|
export declare function rowMemberProblem(cp: Checkpoint): RowMemberProblem | undefined;
|
|
250
328
|
/**
|
|
251
329
|
* The overdue page over a store's rows (`[key, row]` pairs — the key is the authoritative token): pending ∧
|
|
252
|
-
* {@link checkpointDeadlinePassed}
|
|
330
|
+
* {@link checkpointDeadlinePassed} of {@link checkpointOverdueAt} (the deadline, else the age backstop) ∧ `facetOf(gate) === facet`,
|
|
331
|
+
* after the cursor, ordered (that instant's key, token) ascending — the cursor's `deadline` is that key — filled up
|
|
253
332
|
* to `limit` with the rows whose summary `project` mints. A candidate the face cannot place (its sessionId, then the `placement` segment of {@link CHECKPOINT_ROW_SHAPE}: no string
|
|
254
333
|
* session id, a token other than its key, no readable scope, status or gate kind — the facet reads them) is left out and disclosed
|
|
255
334
|
* (`disclose` gets one sentence per such row, on every call) and the page fills on from the next candidate. Every other row is
|
|
@@ -260,11 +339,12 @@ export declare function rowMemberProblem(cp: Checkpoint): RowMemberProblem | und
|
|
|
260
339
|
*/
|
|
261
340
|
export declare function selectOverduePage(rows: Iterable<readonly [string, Checkpoint]>, query: CheckpointOverdueQueryReading, project: (cp: Checkpoint) => CheckpointSummary, disclose?: (sentence: string) => void): CheckpointPage<CheckpointSummary, CheckpointOverdueCursor>;
|
|
262
341
|
/**
|
|
263
|
-
* The session page over a store's rows (`[key, row]` pairs — the key is the authoritative token): the session's rows
|
|
264
|
-
* the query's members, after the cursor, ordered (createdAt key, token) in the query's order, cut at `limit` before anything is
|
|
342
|
+
* The session page over a store's rows (`[key, row]` pairs — the key is the authoritative token): the session's rows — by the query's
|
|
343
|
+
* `axis`, the rows whose own session is it, or whose run session ({@link checkpointRunSessionOf}) is — narrowed by the query's members, after the cursor, ordered (createdAt key, token) in the query's order, cut at `limit` before anything is
|
|
265
344
|
* copied (`clone` runs for the page's readable rows only). A filter that reads a damaged member cannot exclude the row, so a row of
|
|
266
345
|
* this session that no readable filter excludes and that carries damage is answered `unreadable` (and disclosed); a row whose
|
|
267
|
-
* session id is not a string is attributable to no session — left out and disclosed
|
|
346
|
+
* session id is not a string is attributable to no session — left out and disclosed, as is, on the run axis, a row whose run session
|
|
347
|
+
* cannot be read. `next` is present exactly when more rows
|
|
268
348
|
* match after the page.
|
|
269
349
|
*/
|
|
270
350
|
export declare function selectSessionPage(rows: Iterable<readonly [string, Checkpoint]>, query: CheckpointSessionQueryReading, clone: (cp: Checkpoint) => Checkpoint, disclose?: (sentence: string) => void): CheckpointPage<CheckpointRowRead, CheckpointSessionCursor>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
|
+
import { CheckpointError } from "./checkpoint-features.js";
|
|
3
|
+
import { boundedThrownName } from "./thrown-value.js";
|
|
2
4
|
import { checkpointRowLabel, readGateIdentity } from "./checkpoint-identity.js";
|
|
3
5
|
import { facetOf, isGateKind, isPendingKind, PAUSE_REGISTRY } from "./pause-registry.js";
|
|
4
6
|
import { callerKey } from "./caller-text.js";
|
|
@@ -7,14 +9,15 @@ import { principalNameFault, RECORDED_PRINCIPAL_NAME_SPELLING, recordedPrincipal
|
|
|
7
9
|
import { isSha16 } from "./canonical-json.js";
|
|
8
10
|
import { readUnreadableDeleteId, rowUnreadableAt } from "./session.js";
|
|
9
11
|
import { isRowCorrupt, isString, pair, required, rowShapeReader } from "./row-shape.js";
|
|
12
|
+
import { frozenHandleCopy } from "./remote-env.js";
|
|
10
13
|
export const CHECKPOINT_LIST_LIMITS = Object.freeze({
|
|
11
14
|
overdue: Object.freeze({ default: 100, max: 500 }),
|
|
12
15
|
session: Object.freeze({ default: 100, max: 100 }),
|
|
13
16
|
});
|
|
14
17
|
const FACETS = ["A", "B", "-"];
|
|
15
18
|
const STATUSES = ["pending", "resolved", "expired"];
|
|
16
|
-
const OVERDUE_MEMBERS = ["cutoff", "facet", "after", "limit"];
|
|
17
|
-
const SESSION_MEMBERS = ["sessionId", "scope", "status", "gateKinds", "toolCallId", "createdSince", "order", "after", "limit"];
|
|
19
|
+
const OVERDUE_MEMBERS = ["cutoff", "facet", "after", "limit", "maxAgeMs"];
|
|
20
|
+
const SESSION_MEMBERS = ["sessionId", "axis", "scope", "status", "gateKinds", "toolCallId", "createdSince", "order", "after", "limit"];
|
|
18
21
|
function receiveQuery(raw, subject, face, members) {
|
|
19
22
|
if (typeof raw !== "object" || raw === null)
|
|
20
23
|
throw receiptRefusal(`${face}: the query must be an object, got ${raw === null ? "null" : typeof raw}`);
|
|
@@ -67,19 +70,25 @@ export function readCheckpointOverdueQuery(raw) {
|
|
|
67
70
|
throw receiptRefusal("CheckpointOverdueQuery.cutoff must be a finite number (epoch ms)");
|
|
68
71
|
if (!FACETS.includes(facet))
|
|
69
72
|
throw receiptRefusal(`CheckpointOverdueQuery.facet must be one of ${FACETS.map((f) => JSON.stringify(f)).join(" / ")}`);
|
|
73
|
+
const { maxAgeMs } = got;
|
|
74
|
+
if (maxAgeMs !== undefined && (typeof maxAgeMs !== "number" || !Number.isSafeInteger(maxAgeMs) || maxAgeMs < 0))
|
|
75
|
+
throw receiptRefusal("CheckpointOverdueQuery.maxAgeMs must be a whole number of milliseconds, 0 or more, when present");
|
|
70
76
|
return {
|
|
71
77
|
cutoff,
|
|
72
78
|
facet: facet,
|
|
73
79
|
...(after !== undefined ? { after: readCursor(after, "CheckpointOverdueQuery", "deadline", face) } : {}),
|
|
74
80
|
limit: readLimit(got.limit, "CheckpointOverdueQuery", CHECKPOINT_LIST_LIMITS.overdue),
|
|
81
|
+
...(maxAgeMs !== undefined ? { maxAgeMs } : {}),
|
|
75
82
|
};
|
|
76
83
|
}
|
|
77
84
|
export function readCheckpointSessionQuery(raw) {
|
|
78
85
|
const face = "CheckpointStore.listBySession";
|
|
79
86
|
const got = receiveQuery(raw, "CheckpointSessionQuery", face, SESSION_MEMBERS);
|
|
80
|
-
const { sessionId, scope, status, gateKinds, toolCallId, createdSince, order, after } = got;
|
|
87
|
+
const { sessionId, axis, scope, status, gateKinds, toolCallId, createdSince, order, after } = got;
|
|
81
88
|
if (typeof sessionId !== "string" || sessionId === "")
|
|
82
89
|
throw receiptRefusal("CheckpointSessionQuery.sessionId must be a non-empty string");
|
|
90
|
+
if (axis !== undefined && axis !== "session" && axis !== "run")
|
|
91
|
+
throw receiptRefusal('CheckpointSessionQuery.axis must be "session" or "run" when present');
|
|
83
92
|
if (scope !== undefined && typeof scope !== "string")
|
|
84
93
|
throw receiptRefusal(`CheckpointSessionQuery.scope must be a string when present, got ${typeof scope}`);
|
|
85
94
|
if (status !== undefined && !STATUSES.includes(status))
|
|
@@ -93,6 +102,7 @@ export function readCheckpointSessionQuery(raw) {
|
|
|
93
102
|
const kinds = gateKinds === undefined ? undefined : readGateKinds(gateKinds);
|
|
94
103
|
return {
|
|
95
104
|
sessionId,
|
|
105
|
+
...(axis !== undefined ? { axis: axis } : {}),
|
|
96
106
|
...(scope !== undefined ? { scope } : {}),
|
|
97
107
|
...(status !== undefined ? { status: status } : {}),
|
|
98
108
|
...(kinds !== undefined ? { gateKinds: kinds } : {}),
|
|
@@ -145,6 +155,77 @@ export function checkpointDeadlineColumn(deadline) {
|
|
|
145
155
|
return null;
|
|
146
156
|
return typeof deadline === "number" && Number.isFinite(deadline) ? deadline : Number.MIN_SAFE_INTEGER;
|
|
147
157
|
}
|
|
158
|
+
export function checkpointOverdueAt(row, maxAgeMs) {
|
|
159
|
+
const deadline = row.deadline;
|
|
160
|
+
if (deadline !== undefined)
|
|
161
|
+
return typeof deadline === "number" ? deadline : null;
|
|
162
|
+
if (maxAgeMs === undefined)
|
|
163
|
+
return undefined;
|
|
164
|
+
return isFiniteNumber(row.createdAt) ? row.createdAt + maxAgeMs : Number.NaN;
|
|
165
|
+
}
|
|
166
|
+
const RUN_SESSION_OF_ENTRY = Object.freeze({ cascade: "host", verify: "own", repair: "host" });
|
|
167
|
+
export function checkpointRunSessionOf(row) {
|
|
168
|
+
try {
|
|
169
|
+
return runSessionReading(row);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function runSessionReading(row) {
|
|
176
|
+
const own = row.sessionId;
|
|
177
|
+
if (typeof own !== "string" || !isRecord(row.state))
|
|
178
|
+
return undefined;
|
|
179
|
+
const leg = Object.prototype.hasOwnProperty.call(row.state, "compositionLeg") ? row.state.compositionLeg : undefined;
|
|
180
|
+
if (leg === undefined)
|
|
181
|
+
return own;
|
|
182
|
+
if (!isRecord(leg))
|
|
183
|
+
return undefined;
|
|
184
|
+
const entry = leg.entry;
|
|
185
|
+
if (typeof entry !== "string" || !Object.prototype.hasOwnProperty.call(RUN_SESSION_OF_ENTRY, entry))
|
|
186
|
+
return undefined;
|
|
187
|
+
if (RUN_SESSION_OF_ENTRY[entry] === "own")
|
|
188
|
+
return own;
|
|
189
|
+
const host = leg.hostSessionId;
|
|
190
|
+
return typeof host === "string" && host !== "" ? host : undefined;
|
|
191
|
+
}
|
|
192
|
+
export function checkpointRowUnreadable(diagnostic, standing = "unknown", thrownName) {
|
|
193
|
+
const message = `${standing === "pending" ? CHECKPOINT_ROW_DAMAGED_SENTENCE : CHECKPOINT_ROW_UNCONFIRMED_SENTENCE} Diagnostic: ${diagnostic}`;
|
|
194
|
+
return thrownName === undefined
|
|
195
|
+
? new CheckpointError("checkpoint.invalid_outcome", message, { reason: "requirements_damaged" })
|
|
196
|
+
: new CheckpointError("checkpoint.invalid_outcome", message, { reason: "requirements_damaged", thrownName: thrownName });
|
|
197
|
+
}
|
|
198
|
+
export function isCheckpointRowUnreadable(e) {
|
|
199
|
+
try {
|
|
200
|
+
return e instanceof CheckpointError && e.code === "checkpoint.invalid_outcome" && e.detail?.reason === "requirements_damaged";
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
export function storedCheckpointRowRefusal(key, row) {
|
|
207
|
+
let why;
|
|
208
|
+
let status;
|
|
209
|
+
let pending = false;
|
|
210
|
+
try {
|
|
211
|
+
const answer = CHECKPOINT_ROW_SHAPE.read(row, { key }, ["rowKey"]);
|
|
212
|
+
status = isRecord(row) ? row.status : undefined;
|
|
213
|
+
pending = status === "pending" && row.executionOutcome === undefined;
|
|
214
|
+
if (isRowCorrupt(answer))
|
|
215
|
+
why = `the row filed under the token does not read as a row (${answer.member}: ${answer.why})`;
|
|
216
|
+
else if (row.token !== key)
|
|
217
|
+
why = "the row filed under the token carries another token member";
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
return checkpointRowUnreadable("the row filed under the token could not be read (a member threw when read)", "unknown", boundedThrownName(e));
|
|
221
|
+
}
|
|
222
|
+
if (why === undefined)
|
|
223
|
+
return undefined;
|
|
224
|
+
if (pending)
|
|
225
|
+
return checkpointRowUnreadable(`${why}.`, "pending");
|
|
226
|
+
const recorded = status === "pending" ? " It records an execution outcome." : "";
|
|
227
|
+
return checkpointRowUnreadable(`${why}. Its stored status is ${isStatusWord(status) ? `"${status}"` : "not one of the three words"}.${recorded}`, "unknown");
|
|
228
|
+
}
|
|
148
229
|
function orderKey(value) {
|
|
149
230
|
return typeof value === "number" && Number.isFinite(value) ? value : -Infinity;
|
|
150
231
|
}
|
|
@@ -159,6 +240,15 @@ const isStatusWord = (v) => STATUSES.some((s) => s === v);
|
|
|
159
240
|
const isFiniteNumber = (v) => typeof v === "number" && Number.isFinite(v);
|
|
160
241
|
const isAbsentOrNonBlankString = (v) => v === undefined || (typeof v === "string" && v.trim() !== "");
|
|
161
242
|
const gateShape = (m) => (isGateKind(memberOf(m.gate, "kind")) ? undefined : "its gate is not an object of a registered gate kind");
|
|
243
|
+
function workspaceHandleShape(handle) {
|
|
244
|
+
if (handle === undefined)
|
|
245
|
+
return undefined;
|
|
246
|
+
if (!isRecord(handle))
|
|
247
|
+
return "its state's workspace handle is not an object";
|
|
248
|
+
const copy = frozenHandleCopy(handle);
|
|
249
|
+
const missing = ["sandboxId", "provider", "mountPath"].find((member) => typeof copy[member] !== "string");
|
|
250
|
+
return missing === undefined ? undefined : `its state's workspace handle names no ${missing} string`;
|
|
251
|
+
}
|
|
162
252
|
const ROW_MEMBER_SHAPES = Object.freeze([
|
|
163
253
|
["gate", gateShape],
|
|
164
254
|
[
|
|
@@ -180,7 +270,11 @@ const ROW_MEMBER_SHAPES = Object.freeze([
|
|
|
180
270
|
],
|
|
181
271
|
[
|
|
182
272
|
"state",
|
|
183
|
-
(m) => !isRecord(m.state)
|
|
273
|
+
(m) => !isRecord(m.state)
|
|
274
|
+
? "its state is not an object"
|
|
275
|
+
: !((id) => id === undefined || typeof id === "string")(memberOf(m.state, "legTaskId"))
|
|
276
|
+
? "its state's leg task id is not a string"
|
|
277
|
+
: workspaceHandleShape(memberOf(m.state, "workspaceHandle")),
|
|
184
278
|
],
|
|
185
279
|
["createdAt", (m) => (isFiniteNumber(m.createdAt) ? undefined : "its createdAt is not a finite number")],
|
|
186
280
|
["deadline", (m) => (m.deadline === undefined || isFiniteNumber(m.deadline) ? undefined : "its deadline is not a finite number")],
|
|
@@ -192,6 +286,7 @@ const ROW_MEMBER_SHAPES = Object.freeze([
|
|
|
192
286
|
["rootSessionIncarnation", (m) => (isAbsentOrNonBlankString(m.rootSessionIncarnation) ? undefined : "its root session incarnation is not a non-blank string")],
|
|
193
287
|
]);
|
|
194
288
|
export const CHECKPOINT_ROW_DAMAGED_SENTENCE = "This engine cannot resume this checkpoint: its content does not read the way it was recorded when it was parked — it was changed or lost in storage. The checkpoint stays pending and nothing was consumed. Expire it, then start the task again.";
|
|
289
|
+
export const CHECKPOINT_ROW_UNCONFIRMED_SENTENCE = "This engine cannot read this checkpoint row: its stored content does not read as a row, so whether it was already settled — and whether the action it approved has already run — cannot be confirmed from it. The action may already have run: check what became of it before deciding whether to run the work again — running it again may repeat it.";
|
|
195
290
|
const asShapeMembers = (row) => row;
|
|
196
291
|
export const CHECKPOINT_ROW_SHAPE = rowShapeReader({
|
|
197
292
|
family: "checkpoint",
|
|
@@ -247,7 +342,8 @@ export function selectOverduePage(rows, query, project, disclose) {
|
|
|
247
342
|
const hits = [];
|
|
248
343
|
for (const [token, cp] of rows) {
|
|
249
344
|
const m = membersOf(token, cp);
|
|
250
|
-
|
|
345
|
+
const overdueAt = checkpointOverdueAt(m, query.maxAgeMs);
|
|
346
|
+
if (m.status !== "pending" || !checkpointDeadlinePassed(overdueAt, query.cutoff))
|
|
251
347
|
continue;
|
|
252
348
|
const damage = typeof m.sessionId !== "string" ? "its sessionId is not a string" : damageOf(m, ["placement"]);
|
|
253
349
|
if (damage !== undefined) {
|
|
@@ -256,7 +352,7 @@ export function selectOverduePage(rows, query, project, disclose) {
|
|
|
256
352
|
}
|
|
257
353
|
if (facetOf(m.gate) !== query.facet)
|
|
258
354
|
continue;
|
|
259
|
-
const key = orderKey(
|
|
355
|
+
const key = orderKey(overdueAt);
|
|
260
356
|
if (query.after !== undefined && !afterCursor(key, token, { key: query.after.deadline, token: query.after.token }, true))
|
|
261
357
|
continue;
|
|
262
358
|
hits.push({ key, token, cp, m });
|
|
@@ -291,7 +387,12 @@ export function selectSessionPage(rows, query, clone, disclose) {
|
|
|
291
387
|
disclose?.(`${rowName(m)}: its sessionId is not a string — no session listing can attribute it, so it is left out`);
|
|
292
388
|
continue;
|
|
293
389
|
}
|
|
294
|
-
|
|
390
|
+
const keyed = query.axis === "run" ? checkpointRunSessionOf(m) : m.sessionId;
|
|
391
|
+
if (keyed === undefined) {
|
|
392
|
+
disclose?.(`${rowName(m)}: its run session cannot be read (its state or its composition leg does not read) — no run listing can attribute it, so it is left out`);
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (keyed !== query.sessionId)
|
|
295
396
|
continue;
|
|
296
397
|
if (query.scope !== undefined && typeof m.scope === "string" && m.scope !== query.scope)
|
|
297
398
|
continue;
|
|
@@ -64,7 +64,8 @@ export declare function checkpointRekeySelects(row: Checkpoint, map: IdentityRek
|
|
|
64
64
|
* whose principal moves without a pair for it records the partition it keeps;
|
|
65
65
|
* 4. the stamps follow their own judge ({@link judgeCheckpointRequirements}, asked of the row before the write): stamps that
|
|
66
66
|
* match are recomputed by the mint's stamp; stamps that do not are left as they are; a row below the stamped format
|
|
67
|
-
* (
|
|
67
|
+
* (one its judge refuses as a retired seat) gains none and keeps its version — re-stamping it would make an earlier
|
|
68
|
+
* release's row read as this format's;
|
|
68
69
|
* 5. `rev` = the handed row's + 1.
|
|
69
70
|
*/
|
|
70
71
|
export declare function rekeyCheckpointRow(row: Checkpoint, map: IdentityRekeyMap, fidelity: StoreFidelity): CheckpointRekeyVerdict;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { judgeCheckpointRow } from "./checkpoint-row-verdict.js";
|
|
2
2
|
import { judgeCheckpointRequirements, stampCheckpointRequirements } from "./checkpoint-requirements.js";
|
|
3
|
-
import {
|
|
3
|
+
import { checkpointVersionOf, MAX_SUPPORTED_CHECKPOINT_VERSION } from "./checkpoint-features.js";
|
|
4
4
|
import { checkpointRevOf } from "./checkpoint-generation.js";
|
|
5
5
|
import { isolationScopeRecordOf } from "./isolation-scope.js";
|
|
6
6
|
import { isPlainRecord } from "./mods/kernel/receive.js";
|
|
@@ -94,7 +94,7 @@ export function rekeyCheckpointRow(row, map, fidelity) {
|
|
|
94
94
|
delete next.isolationScope;
|
|
95
95
|
Object.assign(next, isolationScopeRecordOf({ ...(value !== undefined ? { isolationScope: value } : {}), ...(principal !== undefined ? { principal } : {}) }));
|
|
96
96
|
}
|
|
97
|
-
const stamped = stampsMatch && checkpointVersionOf(row) >=
|
|
97
|
+
const stamped = stampsMatch && checkpointVersionOf(row) >= MAX_SUPPORTED_CHECKPOINT_VERSION ? stampCheckpointRequirements(next, fidelity) : next;
|
|
98
98
|
return { kind: "rekeyed", row: { ...stamped, rev: checkpointRevOf(row) + 1 }, partitionLeft: partition?.kind === "rekeyed" && partition.partitionLeft };
|
|
99
99
|
}
|
|
100
100
|
function stampsJudgedOk(row) {
|
|
@@ -11,8 +11,8 @@ export declare const REQUIREMENT_WORDS: readonly ["resource", "binding", "token"
|
|
|
11
11
|
export type RequirementWord = (typeof REQUIREMENT_WORDS)[number];
|
|
12
12
|
/** Runtime twin of {@link RequirementWord}. */
|
|
13
13
|
export declare function isRequirementWord(word: unknown): word is RequirementWord;
|
|
14
|
-
/** Every feature
|
|
15
|
-
export type FeatureWordsAreRequirementWords = AssertAllKeysHandled<Exclude<Exclude<CheckpointFeature, "
|
|
14
|
+
/** Every feature of the feature table is a word (`requirements` is the frame). */
|
|
15
|
+
export type FeatureWordsAreRequirementWords = AssertAllKeysHandled<Exclude<Exclude<CheckpointFeature, "requirements">, RequirementWord>>;
|
|
16
16
|
/** What one persisted member owes the reader. The row digest covers every member a decision reads — a word member
|
|
17
17
|
* (a capability the reader must have) or a `digest` member (one every admitted reader already reads); a `mutable`
|
|
18
18
|
* member is rewritten after the mint by the store's own transitions, so the static digest cannot hold it; an
|
|
@@ -1175,9 +1175,9 @@ export type CheckpointRequirementsVerdict = {
|
|
|
1175
1175
|
readonly why: string;
|
|
1176
1176
|
};
|
|
1177
1177
|
/**
|
|
1178
|
-
* Judge a row's requirement list and digest against this engine and against the row's content, before the claim
|
|
1179
|
-
*
|
|
1180
|
-
* -
|
|
1178
|
+
* Judge a row's requirement list and digest against this engine and against the row's content, before the claim — every row it is
|
|
1179
|
+
* handed read as a row of the format (v10):
|
|
1180
|
+
* - the list must be an array of strings; a word this engine lacks ⇒ `lacking` (a newer row); the digest's word
|
|
1181
1181
|
* must be declared (every v10 mint writes it); the words this engine knows must EQUAL the recomputed words, but for a
|
|
1182
1182
|
* recomputed word an earlier engine's mint left off ({@link EarlierReading}: every member carrying it agrees on its record); the
|
|
1183
1183
|
* digest must EQUAL the recomputed digest — a lost member, a lost element, a changed value is damage.
|
|
@@ -1187,7 +1187,8 @@ export type CheckpointRequirementsVerdict = {
|
|
|
1187
1187
|
* digest), is exactly the row that engine wrote ⇒ `ok` where every member read under its earlier reading agrees, else `earlier`
|
|
1188
1188
|
* (this engine reads it differently). Anything else that does not match — a word declared and not carried, a word no earlier
|
|
1189
1189
|
* reading explains, a digest that differs under both readings — is `damaged`.
|
|
1190
|
-
*
|
|
1190
|
+
* The row judge asks it only of a row at the format: one above is refused by the version ceiling, one below by the floor
|
|
1191
|
+
* (checkpoint-row-verdict.ts). Reads `requires` and the digest once each.
|
|
1191
1192
|
*/
|
|
1192
1193
|
export declare function judgeCheckpointRequirements(cp: Checkpoint): CheckpointRequirementsVerdict;
|
|
1193
1194
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { canonicalize, MAX_DEPTH, UNCANONICALIZABLE } from "./canonical-json.js";
|
|
3
|
-
import {
|
|
3
|
+
import { encodeAtFidelity, MAX_SUPPORTED_CHECKPOINT_VERSION } from "./checkpoint-features.js";
|
|
4
4
|
import { memberPresent } from "./own-property-receipt.js";
|
|
5
5
|
import { identityHoldsNoServerName } from "./tool-roster.js";
|
|
6
6
|
export const REQUIREMENT_WORDS = Object.freeze([
|
|
@@ -353,7 +353,7 @@ function presentMembersOf(record) {
|
|
|
353
353
|
}
|
|
354
354
|
export function stampCheckpointRequirements(row, fidelity) {
|
|
355
355
|
const omitted = presentMembersOf(row);
|
|
356
|
-
const { requirementsDigest: _stale, ...framed } = { ...omitted, ...(typeof omitted.state === "object" && omitted.state !== null ? { state: presentMembersOf(omitted.state) } : {}), version:
|
|
356
|
+
const { requirementsDigest: _stale, ...framed } = { ...omitted, ...(typeof omitted.state === "object" && omitted.state !== null ? { state: presentMembersOf(omitted.state) } : {}), version: MAX_SUPPORTED_CHECKPOINT_VERSION };
|
|
357
357
|
const stored = encodeAtFidelity(fidelity, framed);
|
|
358
358
|
const held = (stored.ok ? stored.value : framed);
|
|
359
359
|
const got = stored.ok ? digestOrUnencodable(held) : { at: { path: "(row)", kind: "codec" } };
|
|
@@ -365,11 +365,8 @@ export function judgeAsStored(cp, fidelity) {
|
|
|
365
365
|
return stored.ok ? judgeCheckpointRequirements(stored.value) : { kind: "damaged", why: unencodableWhy({ path: "(row)", kind: "codec" }) };
|
|
366
366
|
}
|
|
367
367
|
export function judgeCheckpointRequirements(cp) {
|
|
368
|
-
const version = checkpointVersionOf(cp);
|
|
369
368
|
const declared = Reflect.get(cp, "requires");
|
|
370
369
|
const digest = Reflect.get(cp, "requirementsDigest");
|
|
371
|
-
if (version < CHECKPOINT_FEATURES.requirements.version)
|
|
372
|
-
return declared === undefined && digest === undefined ? { kind: "ok" } : { kind: "damaged", why: `a v${version} row carries a requirement list or digest no release of that version wrote` };
|
|
373
370
|
if (!Array.isArray(declared))
|
|
374
371
|
return { kind: "damaged", why: declared === undefined ? "the v10 row carries no requirement list" : "the requirement list is not a list" };
|
|
375
372
|
const said = [];
|