@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
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import { notANameShape, readIncarnationCell, sameOccupant } from "../../engine/session/repo-utils.js";
|
|
2
|
+
import { readMember } from "../thrown-value.js";
|
|
3
|
+
import { principalNameOf, recordedPrincipalNameOf } from "../principal-name.js";
|
|
2
4
|
import { settleTeardownLeg, teardownLegBudget } from "./teardown-bounded.js";
|
|
3
5
|
import { gateWaitFailureOf, withGateTimeout } from "../gate-bounded-await.js";
|
|
4
6
|
import { runAbortedError } from "../terminal-cause.js";
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
return { bound:
|
|
7
|
+
export function delegationOwnerSeat(owner) {
|
|
8
|
+
const named = owner === null ? null : principalNameOf(owner);
|
|
9
|
+
if (named === undefined)
|
|
10
|
+
throw Object.assign(new Error(`delegationOwnerSeat: the owner must be a principal name or null (anonymous), got ${notANameShape(owner)}`), { code: "config.invalid_argument" });
|
|
11
|
+
return boundSeat(Object.freeze({ bound: true, owner: named }));
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
const ANSWERS_ONCE = new WeakSet();
|
|
14
|
+
function onceSeat(bind) {
|
|
12
15
|
let settled;
|
|
13
16
|
let inFlight;
|
|
14
|
-
const
|
|
15
|
-
const headOf = sessions.headOf;
|
|
16
|
-
if (typeof headOf !== "function")
|
|
17
|
-
return { bound: true, owner: null };
|
|
18
|
-
const [head, acquired] = await Promise.all([headOf.call(sessions, sessionId), acquiredIncarnation()]);
|
|
19
|
-
if (head === undefined)
|
|
20
|
-
return { bound: false, reason: `the session ${sessionId} this run acquired has no row any more` };
|
|
21
|
-
if (!sameOccupant(head.incarnation, acquired))
|
|
22
|
-
return { bound: false, reason: `the session ${sessionId} this run acquired now holds another occupant` };
|
|
23
|
-
return ownerCellReading(sessionId, head);
|
|
24
|
-
};
|
|
25
|
-
return {
|
|
17
|
+
const seat = Object.freeze({
|
|
26
18
|
read() {
|
|
27
19
|
if (settled !== undefined)
|
|
28
20
|
return Promise.resolve(settled);
|
|
@@ -35,18 +27,53 @@ export function ownRowDelegationOwner(sessions, sessionId, acquiredIncarnation)
|
|
|
35
27
|
});
|
|
36
28
|
return inFlight;
|
|
37
29
|
},
|
|
38
|
-
};
|
|
30
|
+
});
|
|
31
|
+
ANSWERS_ONCE.add(seat);
|
|
32
|
+
return seat;
|
|
33
|
+
}
|
|
34
|
+
function boundSeat(reading) {
|
|
35
|
+
const seat = Object.freeze({ read: () => Promise.resolve(reading) });
|
|
36
|
+
ANSWERS_ONCE.add(seat);
|
|
37
|
+
return seat;
|
|
38
|
+
}
|
|
39
|
+
export function answeringOnce(seat) {
|
|
40
|
+
return ANSWERS_ONCE.has(seat) ? seat : onceSeat(async () => seat.read());
|
|
41
|
+
}
|
|
42
|
+
function ownerCellReading(sessionId, head) {
|
|
43
|
+
const owner = head.owner;
|
|
44
|
+
if (owner === null)
|
|
45
|
+
return { bound: true, owner };
|
|
46
|
+
const name = recordedPrincipalNameOf(owner);
|
|
47
|
+
if (name !== undefined)
|
|
48
|
+
return { bound: true, owner: name };
|
|
49
|
+
if (typeof owner === "string")
|
|
50
|
+
return { bound: false, reason: `the session ${sessionId}'s row answers an owner cell that names nobody (${notANameShape(owner)})` };
|
|
51
|
+
return { bound: false, reason: `the session ${sessionId}'s row answers an owner that is neither a name nor anonymous (${owner === undefined ? "none" : typeof owner})` };
|
|
52
|
+
}
|
|
53
|
+
export function ownRowDelegationOwner(sessions, sessionId, acquiredIncarnation, declaredRoot) {
|
|
54
|
+
return onceSeat(async () => {
|
|
55
|
+
const headOf = sessions.headOf;
|
|
56
|
+
if (typeof headOf !== "function")
|
|
57
|
+
return { bound: true, owner: null };
|
|
58
|
+
const [head, acquired] = await Promise.all([headOf.call(sessions, sessionId), acquiredIncarnation()]);
|
|
59
|
+
if (head === undefined)
|
|
60
|
+
return { bound: false, reason: `the session ${sessionId} this run acquired has no row any more` };
|
|
61
|
+
if (!sameOccupant(head.incarnation, acquired))
|
|
62
|
+
return { bound: false, reason: `the session ${sessionId} this run acquired now holds another occupant` };
|
|
63
|
+
const reading = ownerCellReading(sessionId, head);
|
|
64
|
+
return reading.bound ? Object.freeze({ ...reading, root: Object.freeze({ ...(declaredRoot ?? { sessionId, incarnation: acquired }) }) }) : reading;
|
|
65
|
+
});
|
|
39
66
|
}
|
|
40
67
|
export const DELEGATION_OWNER_UNBOUND = "delegation.owner_unbound";
|
|
41
68
|
export function delegationOwnerUnbound(reason) {
|
|
42
69
|
return Object.assign(new Error(`the delegation tree's owner does not bind: ${reason}`), { code: DELEGATION_OWNER_UNBOUND });
|
|
43
70
|
}
|
|
44
71
|
export const DELEGATION_OWNER_MISMATCH = "delegation.owner_mismatch";
|
|
45
|
-
export async function
|
|
72
|
+
export async function delegatedTreeOwner(seat, signal) {
|
|
46
73
|
const tree = await settled(() => seat.read(), signal);
|
|
47
74
|
if (!tree.bound)
|
|
48
75
|
throw Object.assign(delegationOwnerUnbound(tree.reason), tree.fault !== undefined ? { cause: tree.fault } : {});
|
|
49
|
-
return
|
|
76
|
+
return { owner: tree.owner };
|
|
50
77
|
}
|
|
51
78
|
export function ownerToJudge(tree) {
|
|
52
79
|
return tree.owner ?? undefined;
|
|
@@ -55,68 +82,214 @@ export async function verifiedAtBirth(seat, signal) {
|
|
|
55
82
|
const tree = await delegationOwnerOf(seat, signal).catch(() => undefined);
|
|
56
83
|
return tree !== undefined && tree.bound && ownerToJudge(tree) === undefined;
|
|
57
84
|
}
|
|
58
|
-
export function judgedOwnerSeat(
|
|
59
|
-
return
|
|
85
|
+
export function judgedOwnerSeat(internals) {
|
|
86
|
+
return internals?.delegationOwner;
|
|
60
87
|
}
|
|
61
88
|
export function createForm(input) {
|
|
62
89
|
if (input.placement === undefined && input.owner === undefined)
|
|
63
90
|
return undefined;
|
|
64
91
|
return { ...(input.placement !== undefined ? { placement: input.placement } : {}), ...(input.owner !== undefined ? { owner: input.owner } : {}) };
|
|
65
92
|
}
|
|
66
|
-
export
|
|
93
|
+
export function claimUnavailable() {
|
|
94
|
+
return storeFault("config.invalid_session_store", "it records no owner, and the session store this deployment runs on has no conditional owner write (recordOwner) to record this tree's owner on it — a run with an owner runs on, or reads, a row that records none only after recording its owner there; give the deployment's session store recordOwner");
|
|
95
|
+
}
|
|
96
|
+
const OPEN = Object.freeze({ open: true, claimed: false });
|
|
97
|
+
const refused = (why) => ({ open: false, kind: "not_ours", why });
|
|
98
|
+
const storeFault = (code, why, fault) => ({ open: false, kind: "store", code, why, ...(fault !== undefined ? { fault } : {}) });
|
|
99
|
+
export function rowStoreFaultError(sessionId, verdict) {
|
|
100
|
+
return Object.assign(new Error(`the session row ${sessionId} could not be shown to record this delegation tree's owner: ${verdict.why}`), { code: verdict.code }, verdict.fault !== undefined ? { cause: verdict.fault } : {});
|
|
101
|
+
}
|
|
102
|
+
export async function judgeRowForTree(sessions, row, tree, signal) {
|
|
103
|
+
const { sessionId } = row;
|
|
104
|
+
if (!tree.bound)
|
|
105
|
+
return storeFault(DELEGATION_OWNER_UNBOUND, `the delegation tree's owner does not bind: ${tree.reason}`, tree.fault);
|
|
106
|
+
const owner = tree.owner;
|
|
107
|
+
if (owner === null && row.minted === true)
|
|
108
|
+
return OPEN;
|
|
109
|
+
const headOf = sessions.headOf;
|
|
110
|
+
if (typeof headOf !== "function")
|
|
111
|
+
return owner === null ? OPEN : storeFault("config.invalid_session_store", "the session store has no by-id read (headOf) to show it does — a store that records session owners answers headOf for the row");
|
|
112
|
+
const occupant = row.occupant;
|
|
113
|
+
let read;
|
|
67
114
|
try {
|
|
68
|
-
await
|
|
115
|
+
read = await boundedOwnerRead(() => Promise.all([Promise.resolve().then(() => headOf.call(sessions, sessionId)), occupant === undefined ? undefined : Promise.resolve().then(occupant)]), signal, "delegation owner read");
|
|
69
116
|
}
|
|
70
117
|
catch (err) {
|
|
71
|
-
|
|
72
|
-
|
|
118
|
+
if (ownerReadEnd(err) === "stopped")
|
|
119
|
+
throw runAbortedError();
|
|
120
|
+
return storeFault("storage", `the row could not be read back (${ownerReadEnd(err) === "unanswered" ? "the session store did not answer in time" : "the session store's read failed"})`, err);
|
|
121
|
+
}
|
|
122
|
+
const [head, held] = read;
|
|
123
|
+
if (head === undefined)
|
|
124
|
+
return occupant === undefined ? { open: true, claimed: false, head: null } : refused("the row is not there any more");
|
|
125
|
+
if (occupant !== undefined && !sameOccupant(head.incarnation, held))
|
|
126
|
+
return refused("the row now holds another occupant than the one this leg acquired");
|
|
127
|
+
if (head.owner !== null && recordedPrincipalNameOf(head.owner) === undefined)
|
|
128
|
+
return storeFault("storage", `its owner cell cannot be read (it holds ${notANameShape(head.owner)})`);
|
|
129
|
+
if (head.owner === owner)
|
|
130
|
+
return { open: true, claimed: false, head };
|
|
131
|
+
if (head.owner !== null)
|
|
132
|
+
return refused("it records another owner — a delegated leg never runs on, or reads, another principal's session");
|
|
133
|
+
if (owner === null || row.runsOn !== true)
|
|
134
|
+
return { open: true, claimed: false, head };
|
|
135
|
+
const recordOwner = sessions.recordOwner;
|
|
136
|
+
if (typeof recordOwner !== "function")
|
|
137
|
+
return claimUnavailable();
|
|
138
|
+
let answered;
|
|
139
|
+
try {
|
|
140
|
+
answered = await boundedOwnerRead(() => Promise.resolve().then(() => recordOwner.call(sessions, sessionId, owner, { row: { owner: null, ...(head.incarnation !== undefined ? { incarnation: head.incarnation } : {}) } })), signal, "delegation owner claim");
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
if (ownerReadEnd(err) === "stopped")
|
|
144
|
+
throw runAbortedError();
|
|
145
|
+
if (readMember(err, "code") === "conflict")
|
|
146
|
+
return refused("the row now holds another occupant than the one this leg acquired");
|
|
147
|
+
return storeFault("storage", `it records no owner, and this tree's owner could not be recorded on it (${ownerReadEnd(err) === "unanswered" ? "the session store did not answer in time — the outcome is unknown" : "the session store's write failed"})`, err);
|
|
73
148
|
}
|
|
149
|
+
if (answered === undefined)
|
|
150
|
+
return refused("the row is not there any more");
|
|
151
|
+
if (answered.owner !== owner || !sameOccupant(answered.incarnation, head.incarnation))
|
|
152
|
+
return refused("it records another owner — a delegated leg never runs on, or reads, another principal's session");
|
|
153
|
+
return { open: true, claimed: true, head: answered };
|
|
74
154
|
}
|
|
75
|
-
async function
|
|
76
|
-
const
|
|
77
|
-
const
|
|
155
|
+
export async function readJudgedRow(sessions, sessionId, verdict, read, signal) {
|
|
156
|
+
const judged = verdict.head;
|
|
157
|
+
const value = await read(await sessions.acquire(sessionId, { requireExisting: true }));
|
|
78
158
|
const headOf = sessions.headOf;
|
|
79
|
-
if (typeof headOf !== "function")
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return true;
|
|
159
|
+
if (judged === undefined || typeof headOf !== "function")
|
|
160
|
+
return { read: value };
|
|
161
|
+
let now;
|
|
162
|
+
try {
|
|
163
|
+
now = await boundedOwnerRead(() => Promise.resolve().then(() => headOf.call(sessions, sessionId)), signal, "delegation owner re-read");
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
if (ownerReadEnd(err) === "stopped")
|
|
167
|
+
throw runAbortedError();
|
|
168
|
+
return { refused: storeFault("storage", `the row could not be read back after the read (${ownerReadEnd(err) === "unanswered" ? "the session store did not answer in time" : "the session store's read failed"})`, err) };
|
|
169
|
+
}
|
|
170
|
+
if (judged !== null && now !== undefined && (now.owner ?? null) === (judged.owner ?? null) && sameOccupant(now.incarnation, judged.incarnation))
|
|
171
|
+
return { read: value };
|
|
172
|
+
await forgetHeld(sessions, sessionId);
|
|
173
|
+
return { refused: refused("the row is not the one judged — it changed hands, was laid down again, or was not there when it was judged") };
|
|
174
|
+
}
|
|
175
|
+
export async function judgeRowForSeat(sessions, row, seat, signal) {
|
|
176
|
+
return judgeRowForTree(sessions, row, await delegationOwnerOf(seat, signal), signal);
|
|
177
|
+
}
|
|
178
|
+
export async function birthTree(sessions, record, signal) {
|
|
179
|
+
const rootId = record.rootSessionId;
|
|
180
|
+
const rootIncarnation = record.rootSessionIncarnation;
|
|
181
|
+
const anonymous = { seat: ANONYMOUS_TREE, reading: ANONYMOUS_READING };
|
|
182
|
+
if (rootId === undefined || rootIncarnation === undefined)
|
|
183
|
+
return anonymous;
|
|
184
|
+
if (rootId === record.sessionId)
|
|
185
|
+
return { refused: "the agent's record names its own session as its tree's root — the tree it runs in cannot be read off the row it re-opens" };
|
|
107
186
|
const headOf = sessions.headOf;
|
|
108
187
|
if (typeof headOf !== "function")
|
|
109
|
-
return
|
|
188
|
+
return anonymous;
|
|
110
189
|
let head;
|
|
111
190
|
try {
|
|
112
|
-
head = await boundedOwnerRead(() => Promise.resolve().then(() => headOf.call(sessions,
|
|
191
|
+
head = await boundedOwnerRead(() => Promise.resolve().then(() => headOf.call(sessions, rootId)), signal, "delegation owner read");
|
|
113
192
|
}
|
|
114
193
|
catch (err) {
|
|
115
194
|
if (ownerReadEnd(err) === "stopped")
|
|
116
195
|
throw runAbortedError();
|
|
117
|
-
return
|
|
196
|
+
return { refused: "the tree it was started in does not bind: the row that names it could not be read", fault: err };
|
|
197
|
+
}
|
|
198
|
+
if (head === undefined || !sameOccupant(head.incarnation, rootIncarnation))
|
|
199
|
+
return anonymous;
|
|
200
|
+
const cell = ownerCellReading(rootId, head);
|
|
201
|
+
if (!cell.bound)
|
|
202
|
+
return { refused: `the tree it was started in does not bind: ${cell.reason}` };
|
|
203
|
+
const reading = Object.freeze({ ...cell, root: Object.freeze({ sessionId: rootId, incarnation: rootIncarnation }) });
|
|
204
|
+
return { seat: boundSeat(reading), reading };
|
|
205
|
+
}
|
|
206
|
+
const CYCLE_TREE_OF = new WeakMap();
|
|
207
|
+
export function holdCycleTree(claim, seat) {
|
|
208
|
+
CYCLE_TREE_OF.set(claim, seat);
|
|
209
|
+
}
|
|
210
|
+
export function heldCycleTree(claim) {
|
|
211
|
+
return CYCLE_TREE_OF.get(claim);
|
|
212
|
+
}
|
|
213
|
+
export async function revivalTreeSeat(sessions, records, claim, signal) {
|
|
214
|
+
let stored;
|
|
215
|
+
try {
|
|
216
|
+
stored = await records.get(claim.row.handle, claim.row.scope);
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
return { refused: "the agent's record could not be read again (the record store's read failed)", fault: err ?? "the record store's read failed" };
|
|
220
|
+
}
|
|
221
|
+
if (stored === null)
|
|
222
|
+
return { refused: "the agent's record is not there any more" };
|
|
223
|
+
const same = (k) => stored[k] === claim.row[k];
|
|
224
|
+
if (!same("sessionId") || !same("rootSessionId") || !same("rootSessionIncarnation") || !same("owner") || !same("scope")) {
|
|
225
|
+
return { refused: "the claim does not match the agent's record as the store holds it (other identity cells) — re-read the record and claim it again", identity: true };
|
|
226
|
+
}
|
|
227
|
+
if (stored.rev !== claim.rev)
|
|
228
|
+
return { refused: "the claim is no longer seated on the agent's record (another revision) — re-read the record and claim it again" };
|
|
229
|
+
if (claim.parked)
|
|
230
|
+
return birthTree(sessions, stored, signal);
|
|
231
|
+
const held = heldCycleTree(claim.row);
|
|
232
|
+
return held !== undefined
|
|
233
|
+
? { seat: held }
|
|
234
|
+
: { refused: "this revival does not carry the tree its message entry admitted it on (the claim handed to the delegation tool is not the object the entry handed out) — hand the request's row on as it was given" };
|
|
235
|
+
}
|
|
236
|
+
export function treeReaches(tree, caller) {
|
|
237
|
+
return tree.bound && caller.bound && (tree.owner === null || tree.owner === caller.owner);
|
|
238
|
+
}
|
|
239
|
+
export async function birthTreeAdmission(sessions, record, row, caller, signal) {
|
|
240
|
+
if (!caller.bound)
|
|
241
|
+
return storeFault(DELEGATION_OWNER_UNBOUND, `the delegation tree's owner does not bind: ${caller.reason}`, caller.fault);
|
|
242
|
+
const born = await birthTree(sessions, record, signal);
|
|
243
|
+
if ("refused" in born)
|
|
244
|
+
return storeFault(born.fault !== undefined ? "storage" : DELEGATION_OWNER_UNBOUND, `the tree this agent was started in cannot be read: ${born.refused}`, born.fault);
|
|
245
|
+
if (!treeReaches(born.reading, caller))
|
|
246
|
+
return refused("the agent was started in another principal's tree — a revival runs in the tree it was born in");
|
|
247
|
+
const verdict = await judgeRowForTree(sessions, row, born.reading, signal);
|
|
248
|
+
return verdict.open ? { open: true, tree: born.seat, row: verdict } : verdict;
|
|
249
|
+
}
|
|
250
|
+
export function recordedRootAnchor(ctx, tree) {
|
|
251
|
+
const linkage = ctx.rootSessionId ?? ctx.sessionId;
|
|
252
|
+
if (linkage === undefined)
|
|
253
|
+
return {};
|
|
254
|
+
const root = tree !== undefined && tree.bound ? tree.root : undefined;
|
|
255
|
+
return root !== undefined && root.sessionId === linkage && root.incarnation !== undefined ? { rootSessionId: linkage, rootSessionIncarnation: root.incarnation } : { rootSessionId: linkage };
|
|
256
|
+
}
|
|
257
|
+
const ANONYMOUS_READING = Object.freeze({ bound: true, owner: null });
|
|
258
|
+
const ANONYMOUS_TREE = boundSeat(ANONYMOUS_READING);
|
|
259
|
+
export async function judgeLegRow(sessions, held, leg, report) {
|
|
260
|
+
let verdict;
|
|
261
|
+
try {
|
|
262
|
+
verdict = await judgeRowForTree(sessions, { sessionId: held.sessionId, occupant: async () => (await held.session.getMetadata()).incarnation, minted: leg.minted, runsOn: true }, { bound: true, owner: leg.owner }, leg.signal);
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
await forgetHeld(sessions, held.sessionId, report);
|
|
266
|
+
throw err;
|
|
267
|
+
}
|
|
268
|
+
if (verdict.open)
|
|
269
|
+
return;
|
|
270
|
+
await forgetHeld(sessions, held.sessionId, report);
|
|
271
|
+
if (verdict.kind === "store")
|
|
272
|
+
throw rowStoreFaultError(held.sessionId, verdict);
|
|
273
|
+
throw Object.assign(new Error(`the session row ${held.sessionId} does not record this delegation tree's owner: ${verdict.why}`), { code: DELEGATION_OWNER_MISMATCH });
|
|
274
|
+
}
|
|
275
|
+
function forgetHeld(sessions, sessionId, report) {
|
|
276
|
+
return settleTeardownLeg(() => Promise.resolve(sessions.forget ? sessions.forget(sessionId) : undefined).catch(() => undefined), "forget (acquire-reconcile owner judgement leg)", report && ((e) => report(e, sessionId)));
|
|
277
|
+
}
|
|
278
|
+
export async function forkedRowNotOurs(sessions, forkedId, source) {
|
|
279
|
+
const drop = () => Promise.resolve(sessions.forget?.(forkedId)).catch(() => undefined);
|
|
280
|
+
let meta;
|
|
281
|
+
try {
|
|
282
|
+
meta = await (await sessions.acquire(forkedId, { requireExisting: true })).session.getMetadata();
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
await drop();
|
|
286
|
+
return `the forked session ${forkedId} could not be read (the session store's read failed) — nothing runs on it, and it is not released`;
|
|
287
|
+
}
|
|
288
|
+
if (meta.forkedFrom !== source.sessionId || (source.occupant !== null && !sameOccupant(meta.forkedFromIncarnation, source.occupant))) {
|
|
289
|
+
await drop();
|
|
290
|
+
return `the session ${forkedId} the store's fork answered is not a copy of this run's session as this run holds it — nothing runs on it, and it is not released`;
|
|
118
291
|
}
|
|
119
|
-
return
|
|
292
|
+
return undefined;
|
|
120
293
|
}
|
|
121
294
|
export function namesVerifiedSession(result) {
|
|
122
295
|
return result.sessionId !== "";
|
|
@@ -166,7 +339,8 @@ export function readRootOccupant(internals, onError, sessionId) {
|
|
|
166
339
|
const scope = typeof rawScope === "string" && rawScope !== "" ? rawScope : undefined;
|
|
167
340
|
if (scope === undefined && rawScope !== undefined && rawScope !== null)
|
|
168
341
|
disclose("rootSessionScope", `holds ${notANameShape(rawScope)} — read as no recorded box scope`);
|
|
169
|
-
|
|
342
|
+
const { delegationOwner, ...others } = rest;
|
|
343
|
+
return { ...others, ...(delegationOwner !== undefined ? { delegationOwner: answeringOnce(delegationOwner) } : {}), ...(rootSessionId !== undefined ? { rootSessionId } : {}), ...(placementRoot !== undefined ? { placementRoot } : {}), ...(token !== undefined ? { rootSessionIncarnation: token } : {}), ...(scope !== undefined ? { rootSessionScope: scope } : {}) };
|
|
170
344
|
}
|
|
171
345
|
function rootIdMember(member, raw) {
|
|
172
346
|
if (raw === undefined || raw === null)
|
|
@@ -22,6 +22,9 @@ export interface ExpireRowInput {
|
|
|
22
22
|
scope: string;
|
|
23
23
|
/** borrowed-readonly — the store the row lives in. */
|
|
24
24
|
store: CheckpointStore;
|
|
25
|
+
/** borrowed-readonly — the grant holder of the run the settle is issued in the name of (absent ⇒ a host's own settle carries none):
|
|
26
|
+
* one more precondition of the expire CAS, judged by the store; a holder it does not hold current loses like any settler. */
|
|
27
|
+
holder?: string | undefined;
|
|
25
28
|
/** borrowed-mutable — the Runner's same-Runner claims: this attempt opens its own with the CAS and closes it once the duty is decided. */
|
|
26
29
|
locallyClaimedTokens: LocalClaims;
|
|
27
30
|
/** borrowed-mutable — the Runner's parked-constraint registry: the token's entry is evicted once the row is expired. */
|
|
@@ -34,6 +37,20 @@ export interface ExpireRowInput {
|
|
|
34
37
|
}
|
|
35
38
|
/** Settle the row `expired`; `true` = this call won the CAS, `false` = another settler already had (the duty still runs if the row is expired). */
|
|
36
39
|
export declare function expireRowWithDuty(input: ExpireRowInput): Promise<boolean>;
|
|
40
|
+
/** The expire CAS a run issues in its own name: with the holder as the store's write option, or — no holder — the two-argument call as
|
|
41
|
+
* ever (a store written against the older interface sees exactly what it saw). */
|
|
42
|
+
export declare function expireCarrying(store: CheckpointStore, token: CheckpointToken, scope: string, holder: string | undefined): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* THE reading of a lost single-shot CAS that carried the run's holder (the resume's claim, the resume preflight's terminal expire): the
|
|
45
|
+
* row is still the one the caller validated — pending, the same row (scope), the same generation — so nothing moved it and what failed
|
|
46
|
+
* is the holder: the caller answers `holder.superseded` ({@link import("../grant-holder.js").holderSupersededError}). Anything else is
|
|
47
|
+
* the caller's own loss reading (a moved generation, a consumed row).
|
|
48
|
+
*/
|
|
49
|
+
export declare function lostToHolder(holder: string | undefined, loss: {
|
|
50
|
+
status: "pending" | "resolved" | "expired" | "absent";
|
|
51
|
+
rev: number | undefined;
|
|
52
|
+
sameRow: boolean;
|
|
53
|
+
}, validatedRev: number): boolean;
|
|
37
54
|
/**
|
|
38
55
|
* A settle attempt of this Runner LOST its CAS: read the row, and run the expired duty when it is `expired`. Answers what was seen —
|
|
39
56
|
* the row's status, `"absent"` (no row), or `undefined` (nothing held here to act on, or the read threw: said, record kept) — and
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { hasDestroy } from "../remote-env.js";
|
|
2
2
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
3
3
|
export async function expireRowWithDuty(input) {
|
|
4
|
-
const { token, scope, store, locallyClaimedTokens } = input;
|
|
4
|
+
const { token, scope, store, holder, locallyClaimedTokens } = input;
|
|
5
5
|
locallyClaimedTokens.open(token);
|
|
6
6
|
let won;
|
|
7
7
|
try {
|
|
8
|
-
won = await store
|
|
8
|
+
won = await expireCarrying(store, token, scope, holder);
|
|
9
9
|
}
|
|
10
10
|
catch (expireErr) {
|
|
11
11
|
locallyClaimedTokens.close(token);
|
|
@@ -19,6 +19,12 @@ export async function expireRowWithDuty(input) {
|
|
|
19
19
|
await runExpiredDuty(input);
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
|
+
export function expireCarrying(store, token, scope, holder) {
|
|
23
|
+
return holder !== undefined ? store.expire(token, scope, { holder }) : store.expire(token, scope);
|
|
24
|
+
}
|
|
25
|
+
export function lostToHolder(holder, loss, validatedRev) {
|
|
26
|
+
return holder !== undefined && loss.status === "pending" && loss.sameRow && loss.rev === validatedRev;
|
|
27
|
+
}
|
|
22
28
|
export async function settleLostRow(input) {
|
|
23
29
|
const { token, store, suspendedEnvReaps } = input;
|
|
24
30
|
const reap = suspendedEnvReaps.get(token);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The file-history REQUEST door and its bad-value doors — the pre-acquire half of the file-history phase (`prepare-file-history.ts`). */
|
|
2
|
-
import type
|
|
2
|
+
import { type FileHistoryRestoreOptions, type FileHistoryStore } from "../file-history-store.js";
|
|
3
3
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* The file-history REQUEST door: every refusal the request (`TaskSpec`) and the deployment's own seats decide
|
|
@@ -13,8 +13,9 @@ import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
|
13
13
|
export declare function resolveFileHistoryRequest(spec: Pick<TaskSpec, "resumeAt" | "resumeAtMode" | "restoreFiles" | "rewindFilesTo" | "fileHistory" | "unplacedHistoryRecordedUnder">, deps: Pick<RunnerDeps, "onTrackFailure" | "fileHistoryStore" | "fileHistoryCapture">): FileHistoryRequest;
|
|
14
14
|
/**
|
|
15
15
|
* THE reading of `unplacedHistoryRecordedUnder` (`TaskSpec` and `RewindFilesRequest` name it alike): a non-empty absolute path
|
|
16
|
-
* (in either path family)
|
|
17
|
-
*
|
|
16
|
+
* (in either path family), or the word {@link UNPLACED_AT_REWIND_ROOT} (the rewind's own root, resolved by the engine where the
|
|
17
|
+
* restore runs — {@link restoreOptionsAt}), on a request that restores files, else refused by name (`rewind.invalid_spec`) — on a
|
|
18
|
+
* request that restores nothing it would be read by no one, and a value that is neither is not a directory anything was recorded under.
|
|
18
19
|
*/
|
|
19
20
|
export declare function readRestoreOptions(value: unknown, restores: boolean, seat: "TaskSpec" | "Runner.rewindFiles"): FileHistoryRestoreOptions | undefined;
|
|
20
21
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UNPLACED_AT_REWIND_ROOT } from "../file-history-store.js";
|
|
1
2
|
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
2
3
|
import { relativeInEveryFamily } from "../../tools/fs/safety.js";
|
|
3
4
|
export function resolveFileHistoryRequest(spec, deps) {
|
|
@@ -34,8 +35,10 @@ export function readRestoreOptions(value, restores, seat) {
|
|
|
34
35
|
e.code = "rewind.invalid_spec";
|
|
35
36
|
throw e;
|
|
36
37
|
};
|
|
38
|
+
if (value === UNPLACED_AT_REWIND_ROOT)
|
|
39
|
+
return restores ? { unplacedHistoryRecordedUnder: value } : bad("is set on a run that restores no file (no rewindFilesTo, and no resumeAt with restoreFiles)");
|
|
37
40
|
if (typeof value !== "string" || value === "" || relativeInEveryFamily(value))
|
|
38
|
-
return bad(`must be a non-empty absolute path, got ${describeRejectedValue(value)}`);
|
|
41
|
+
return bad(`must be a non-empty absolute path or "${UNPLACED_AT_REWIND_ROOT}" (this rewind's own root), got ${describeRejectedValue(value)}`);
|
|
39
42
|
if (!restores)
|
|
40
43
|
return bad("is set on a run that restores no file (no rewindFilesTo, and no resumeAt with restoreFiles)");
|
|
41
44
|
return { unplacedHistoryRecordedUnder: value };
|
|
@@ -10,6 +10,8 @@ import type { ExecutionEnv } from "../../internal/harness.js";
|
|
|
10
10
|
import type { EngineNotice } from "../types.js";
|
|
11
11
|
import type { FileHistoryError, FileHistoryLeftAsIsFile, FileHistoryRestoreOptions, FileHistoryRestorePlan, FileHistoryRestoreResult, FileHistoryStore, RewindFilesResult } from "../file-history-store.js";
|
|
12
12
|
import type { SessionReadFileStates } from "./session-read-file-states.js";
|
|
13
|
+
import type { RewindOutcome } from "./rewind-outcome.js";
|
|
14
|
+
import type { TaskRewindSettlement } from "../terminal-cause.js";
|
|
13
15
|
/** A restore outcome a seat may accept: the ledger, with `failed` (the operation could not run) already refused —
|
|
14
16
|
* the out-of-run rewind's answer carries exactly this. */
|
|
15
17
|
export type AcceptedFileHistoryRestore = Extract<RewindFilesResult, {
|
|
@@ -40,11 +42,14 @@ export declare function settleFileHistoryRestore(input: {
|
|
|
40
42
|
root: string;
|
|
41
43
|
signal: AbortSignal | undefined;
|
|
42
44
|
readStates: Pick<SessionReadFileStates, "noteRestored"> | undefined;
|
|
43
|
-
/** The rewind's restore options (`unplacedHistoryRecordedUnder`), handed to the store as they are. */
|
|
45
|
+
/** The rewind's restore options (`unplacedHistoryRecordedUnder`), handed to the store as they are — the word `"rewind_root"` read as `root` ({@link restoreOptionsAt}). */
|
|
44
46
|
options: FileHistoryRestoreOptions | undefined;
|
|
45
47
|
/** Refuse before any file moves when the restore would refuse or fail one ({@link planFileHistoryRestore}) — a caller that does
|
|
46
48
|
* not accept a partial restore; a caller that reads the ledger itself leaves it off. */
|
|
47
49
|
wholeOrNothing: boolean;
|
|
50
|
+
/** The rewind's record of whether the tree moved ({@link RewindOutcome.moved}): written here once the restore asked the env what
|
|
51
|
+
* it asked — whatever the restore then answers, or if it throws; untouched when the restore is refused before it runs. */
|
|
52
|
+
outcome?: Pick<RewindOutcome, "moved">;
|
|
48
53
|
}): Promise<AcceptedFileHistoryRestore>;
|
|
49
54
|
/**
|
|
50
55
|
* What `rewind.restore_failed` carries on its coded `detail` (the error's own member, which a failed task's
|
|
@@ -58,14 +63,17 @@ export declare function settleFileHistoryRestore(input: {
|
|
|
58
63
|
* terminal's snapshot, which leaves an over-bound list out whole (`filesChangedCount` is the sentence's "applied N";
|
|
59
64
|
* `refusedCount` / `failedCount` are the lists' lengths); the files it left as they are (`leftAsIs`, each with its class, and
|
|
60
65
|
* `leftAsIsCount`) when there were any — never a cause of the failure. The counts are declared before the lists on purpose: see
|
|
61
|
-
* {@link restoreFailedError}.
|
|
66
|
+
* {@link restoreFailedError}. On `Runner.rewindFiles` only, `rewind` — whether the tree moved (`moved`) and `branch: "untouched"`
|
|
67
|
+
* ({@link TaskRewindSettlement}); a run states the same fact once, on its failed terminal (`terminal.rewind`), never in this detail.
|
|
62
68
|
*/
|
|
63
69
|
export type FileHistoryRestoreFailureDetail = Partial<Pick<FileHistoryError, "code" | "permanence">> & {
|
|
64
70
|
filesChangedCount: number;
|
|
65
71
|
refusedCount: number;
|
|
66
72
|
failedCount: number;
|
|
67
73
|
leftAsIsCount?: number;
|
|
68
|
-
} & Pick<FileHistoryRestoreResult, "refused" | "failed" | "files" | "leftAsIs"
|
|
74
|
+
} & Pick<FileHistoryRestoreResult, "refused" | "failed" | "files" | "leftAsIs"> & {
|
|
75
|
+
rewind?: TaskRewindSettlement;
|
|
76
|
+
};
|
|
69
77
|
/** The engine's judgment of a restore a run stopped on — nothing moved because its plan would refuse or fail a file (repeating the
|
|
70
78
|
* same rewind plans the same), or a write failed after the plan passed and the tree is partly restored (a repeat would write over
|
|
71
79
|
* any file a person changed since): `terminal` — do not send it again on its own; a person decides. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveTrackKey } from "../file-history-store.js";
|
|
2
|
-
import { planFileHistoryRestore, witnessEnvOf, withRewindFiles } from "../file-history-store.js";
|
|
2
|
+
import { planFileHistoryRestore, restoreMovedOf, restoreOptionsAt, witnessEnvOf, withRewindFiles } from "../file-history-store.js";
|
|
3
3
|
import { isGovernanceRetryClass } from "../governance-codes.js";
|
|
4
4
|
export async function settleFileHistoryRestore(input) {
|
|
5
5
|
const { store, sessionId, scope, target, env, root } = input;
|
|
@@ -12,8 +12,16 @@ export async function settleFileHistoryRestore(input) {
|
|
|
12
12
|
throw restoreFailedError({ ...planned, filesChanged: [], identicalSkipped: [] }, `rewind-files: restore to entry "${target}" was refused before any file moved — the restore would be PARTIAL. Nothing was written or deleted; the plan: ${fileHistoryRestoreLedgerLine(planned, true)}. Repeating the same rewind plans the same; a rewind that restores the rest and answers this ledger is Runner.rewindFiles, and a run spec that accepts a partial restore (acceptPartialRestore) does the same where its host offers that member.`, RUN_STOPPED_RESTORE);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
const witness = witnessEnvOf(env, plan.holds);
|
|
16
|
-
|
|
15
|
+
const witness = witnessEnvOf(env, plan.holds, plan.states);
|
|
16
|
+
let answered;
|
|
17
|
+
try {
|
|
18
|
+
answered = await store.restore(scope, target, witness.env, root, input.signal, restoreOptionsAt(input.options, root));
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
if (input.outcome !== undefined)
|
|
22
|
+
input.outcome.moved = restoreMovedOf(witness);
|
|
23
|
+
}
|
|
24
|
+
const restored = withRewindFiles(answered, witness, root);
|
|
17
25
|
input.readStates?.noteRestored(sessionId, restoredAbsPathsOf(restored, root));
|
|
18
26
|
if (restored.outcome !== "failed")
|
|
19
27
|
return restored;
|
|
@@ -26,9 +26,10 @@ import { type ClassifierAsked, type ClassifierDenyCause, type DeniedBy, type Gat
|
|
|
26
26
|
import type { AllowRuleClearance } from "../allow-rule-shadow.js";
|
|
27
27
|
import type { AutoModeClassifierRound } from "../auto-mode.js";
|
|
28
28
|
import type { ClassifierCategory } from "../classifier-category.js";
|
|
29
|
-
import { type Arbitration, type AskClass, type AskClassification, type AskFace, type AskOrigin, type AskOriginFacts } from "../ask-origin.js";
|
|
29
|
+
import { type UnansweredMint, type Arbitration, type AskClass, type AskClassification, type AskFace, type AskOrigin, type AskOriginFacts } from "../ask-origin.js";
|
|
30
30
|
import { type PermissionResult, type ResolvedAsk, type ToolCallRequest } from "../tool-policy.js";
|
|
31
31
|
import { type RewriteAccount } from "../rewrite-rejudge.js";
|
|
32
|
+
import { type SuspendLaneReason } from "../suspend-lane-reasons.js";
|
|
32
33
|
import type { SafeNotifier } from "../safe-notify.js";
|
|
33
34
|
import type { PermissionDeniedPayload, PreToolUseResult, ToolGateInput, ToolGateResult } from "../hooks.js";
|
|
34
35
|
/** The ask a gate pass settled, as the gate captured it at its resolution site: the settlement the
|
|
@@ -182,9 +183,26 @@ export declare function refusalWordsOf(gate: GateOutcome | undefined): {
|
|
|
182
183
|
* markers. A value the receipt refuses whole (a Proxy, a function, a Map in place of the arguments) is recorded as its marker.
|
|
183
184
|
*/
|
|
184
185
|
export declare function frozenInputSnapshot(input: unknown): unknown;
|
|
186
|
+
/** What the deny exit says about the park: an attempt that failed (its cause), or no attempt because the leg's "cannot hold a park" sentence
|
|
187
|
+
* alone made the delivery `close` (`GatePass.parkTargetGap`, quoted as the leg stated it — the Runner states its env's gap in the park closure's own sentence). */
|
|
188
|
+
export type ParkNote = {
|
|
189
|
+
readonly kind: "failed";
|
|
190
|
+
readonly cause: string;
|
|
191
|
+
readonly reason?: SuspendLaneReason;
|
|
192
|
+
} | {
|
|
193
|
+
readonly kind: "no_target";
|
|
194
|
+
readonly gap: string;
|
|
195
|
+
};
|
|
185
196
|
/** The way on a seat that is asked again offers, where the leg cannot hold a park and nobody could judge the call now: issuing it again
|
|
186
197
|
* asks again, and it runs if its approver — a person, or a declared approval policy — allows it then. Neither forbids nor promises a retry. */
|
|
187
198
|
export declare const RE_ASKED_WAY_ON = "nobody could judge it this time; issued again, it is asked again, and it runs if its approver allows it then";
|
|
199
|
+
/** The base sentence of a refusal for an ask nobody could answer, in the form its park state allows. The resolver minted it before this exit
|
|
200
|
+
* knew whether a durable park was attempted and failed (or held back because the leg cannot hold one), and recorded what it minted
|
|
201
|
+
* (`unanswered`, the decision's engine record); when the note speaks about the park, the base is minted again over the same question
|
|
202
|
+
* ({@link unresolvedAskDenialMessage}) so that only {@link withParkFailureCause}'s note does — what a later layer appended to it kept.
|
|
203
|
+
* A text that does not open with the sentence the record names (a binding's, a fold's own, a hook's, one a layer rewrote) is left as it is. The question's refusal is minted in its
|
|
204
|
+
* park state's form where it is refused (the gate's content route), so it needs nothing here. Not re-exported from `src/index.ts`. */
|
|
205
|
+
export declare function parkFailedBase(text: string, minted: UnansweredMint | undefined, park: ParkNote | undefined): string;
|
|
188
206
|
/** What one `classic.PreToolUse` screening came to: an answer the receipt took (`undefined` = no opinion), or the
|
|
189
207
|
* engine's fail-closed refusal of the call with its sentence (a handler that failed or broke the site's contract,
|
|
190
208
|
* or a cancel). */
|
|
@@ -379,6 +397,9 @@ export interface GatePass {
|
|
|
379
397
|
* exit — whatever the fallback chain then decides to say, it says it knowing the park was tried first.
|
|
380
398
|
* Writers: the three park sites. */
|
|
381
399
|
parkFailed: string | undefined;
|
|
400
|
+
/** borrowed-mutable — beside {@link parkFailed}: the failed attempt's infrastructure code (`ParkAttemptFailed.parkFailedReason`), when
|
|
401
|
+
* the attempt named one. Writers: the same park sites. */
|
|
402
|
+
parkFailedReason?: string | undefined;
|
|
382
403
|
/** borrowed-readonly — the leg's "cannot hold a park" sentence, `ToolGateInput.suspendTargetGap` read once at the gate's entry (`readSuspendTargetGap`). */
|
|
383
404
|
suspendTargetGap: string | undefined;
|
|
384
405
|
/** borrowed-mutable — that sentence, set when it ALONE made a delivery's word `close` (the judge read once more without it says `park`). Read at the
|