@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
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { closeSync, existsSync, fstatSync } from "node:fs";
|
|
2
|
-
import { openSync, readdirSync, rmSync, utimesSync } from "./descriptor-seat.js";
|
|
1
|
+
import { closeSync, existsSync, fstatSync, statSync } from "node:fs";
|
|
2
|
+
import { openSync, readFileSync, readdirSync, rmSync, utimesSync } from "./descriptor-seat.js";
|
|
3
3
|
import { join, resolve as resolvePath } from "node:path";
|
|
4
|
-
import { BaseSessionStorage, StoredSession, SessionError, assertForkTarget, compareOccupants, forkRowCells, forkTargetTaken, frozenRow, getEntriesToFork, importRowCells, incarnationCell, leafIdAfterEntry, ownerCell, placementCellToWrite, readIncarnationCell, readOwnerCell, readPlacementCell, replayLossText, resolveLeafId, rowExpectationMissed, sessionHeadOf, sessionLogMarkOf, heldRowCells, heldRowMatches, readSessionRepoRowCells, uuidv7, validateEntriesForImport, } from "../../internal/harness.js";
|
|
4
|
+
import { BaseSessionStorage, StoredSession, SessionError, assertForkTarget, compareOccupants, forkRowCells, forkTargetTaken, frozenRow, getEntriesToFork, importRowCells, incarnationCell, leafIdAfterEntry, ownerCell, placementCellToWrite, readIncarnationCell, readOwnerCell, readPlacementCell, readRowExpectation, recordedOwnerCells, recordedOwnerName, replayLossText, resolveLeafId, rowExpectationMissed, sessionHeadOf, sessionLogMarkOf, heldRowCells, heldRowMatches, readSessionRepoRowCells, uuidv7, validateEntriesForImport, } from "../../internal/harness.js";
|
|
5
5
|
import { readUnreadableDeleteId, rowUnreadableNow } from "../../core/session.js";
|
|
6
6
|
import { canonicalStoreKey, AppendLog, atomicWriteFile, ensureDir, firstJsonlRecord, lastJsonlRecord, readJsonlRecords, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
|
|
7
7
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
8
8
|
import { assertAdoptionBootGate } from "./adoption/marker.js";
|
|
9
9
|
import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
|
|
10
|
+
import { joinHolderJudge, readHolderJudge } from "../../core/checkpoint-generation.js";
|
|
10
11
|
import { thrownText } from "../../core/thrown-value.js";
|
|
11
12
|
const SUFFIX = ".jsonl";
|
|
12
13
|
const SESSION_LINE_JUDGE = {
|
|
@@ -53,8 +54,8 @@ class FileSessionStorage extends BaseSessionStorage {
|
|
|
53
54
|
canonicalPath;
|
|
54
55
|
holders = new Set();
|
|
55
56
|
occupant;
|
|
56
|
-
constructor(log, meta, entries, canonicalPath, replayLoss) {
|
|
57
|
-
super(meta, entries, undefined, replayLoss !== undefined ? { replayLoss } : undefined);
|
|
57
|
+
constructor(log, meta, entries, canonicalPath, replayLoss, holderIsCurrent) {
|
|
58
|
+
super(meta, entries, undefined, { ...(replayLoss !== undefined ? { replayLoss } : {}), ...(holderIsCurrent !== undefined ? { holderIsCurrent } : {}) });
|
|
58
59
|
this.log = log;
|
|
59
60
|
this.canonicalPath = canonicalPath;
|
|
60
61
|
this.occupant = { incarnation: meta.incarnation };
|
|
@@ -69,6 +70,12 @@ class FileSessionStorage extends BaseSessionStorage {
|
|
|
69
70
|
closeLog() {
|
|
70
71
|
this.log.close();
|
|
71
72
|
}
|
|
73
|
+
adoptRecordedRow(log, metadata) {
|
|
74
|
+
const previous = this.log;
|
|
75
|
+
this.log = log;
|
|
76
|
+
previous.close();
|
|
77
|
+
this.adoptRecordedOwner(metadata);
|
|
78
|
+
}
|
|
72
79
|
isViewOf(row) {
|
|
73
80
|
return compareOccupants(this.occupant, row) === "same" && this.log.isFileAtPath();
|
|
74
81
|
}
|
|
@@ -76,18 +83,19 @@ class FileSessionStorage extends BaseSessionStorage {
|
|
|
76
83
|
this.log.append({ kind: "entry", entry }, true);
|
|
77
84
|
}
|
|
78
85
|
async appendEntry(entry, opts) {
|
|
79
|
-
this.assertExpectedLeaf(opts);
|
|
86
|
+
this.assertExpectedLeaf(opts, "appendEntry");
|
|
80
87
|
this.persistSync(entry);
|
|
81
88
|
this.recordEntry(entry);
|
|
82
89
|
}
|
|
83
90
|
async setLeafId(leafId, opts) {
|
|
84
|
-
this.assertExpectedLeaf(opts);
|
|
91
|
+
this.assertExpectedLeaf(opts, "setLeafId");
|
|
85
92
|
const entry = this.createLeafEntry(leafId);
|
|
86
93
|
this.persistSync(entry);
|
|
87
94
|
this.recordEntry(entry);
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
|
-
const FILE_SESSION_REPO_OPTION_KEYS = optionKeys()({ onCorruptRead: 0, rowCells: 0 });
|
|
97
|
+
const FILE_SESSION_REPO_OPTION_KEYS = optionKeys()({ onCorruptRead: 0, rowCells: 0, holderIsCurrent: 0 });
|
|
98
|
+
const authorityJudges = new WeakMap();
|
|
91
99
|
export class FileSessionRepo {
|
|
92
100
|
dir;
|
|
93
101
|
tmpDir;
|
|
@@ -95,10 +103,14 @@ export class FileSessionRepo {
|
|
|
95
103
|
joined = new Map();
|
|
96
104
|
disposed = false;
|
|
97
105
|
rowCells;
|
|
106
|
+
holderIsCurrent;
|
|
98
107
|
transcriptDirectory;
|
|
99
108
|
constructor(root, options) {
|
|
100
109
|
const opts = receiveOptions(options, "FileSessionRepo", FILE_SESSION_REPO_OPTION_KEYS);
|
|
101
110
|
this.rowCells = readSessionRepoRowCells("FileSessionRepo options", opts.rowCells);
|
|
111
|
+
this.holderIsCurrent = readHolderJudge("FileSessionRepo.holderIsCurrent", opts.holderIsCurrent);
|
|
112
|
+
if (this.holderIsCurrent !== undefined)
|
|
113
|
+
this.fence = Object.freeze({ holder: "writes" });
|
|
102
114
|
const at = resolvePath(root);
|
|
103
115
|
assertAdoptionBootGate(at, "FileSessionRepo");
|
|
104
116
|
this.dir = join(at, "sessions");
|
|
@@ -234,10 +246,16 @@ export class FileSessionRepo {
|
|
|
234
246
|
this.refuseRowAfterDispose(id);
|
|
235
247
|
return true;
|
|
236
248
|
}
|
|
249
|
+
assertJudgeJoins(id) {
|
|
250
|
+
const live = sharedSessionStorages.get(canonicalStoreKey(this.pathFor(id)))?.deref();
|
|
251
|
+
if (live !== undefined)
|
|
252
|
+
joinHolderJudge(authorityJudges, live, this.holderIsCurrent, "session", `FileSessionRepo: session ${id}`);
|
|
253
|
+
}
|
|
237
254
|
storage(meta, entries, loss) {
|
|
238
255
|
const { id } = meta;
|
|
239
256
|
const canonical = canonicalStoreKey(this.pathFor(id));
|
|
240
257
|
const live = sharedSessionStorages.get(canonical)?.deref();
|
|
258
|
+
this.assertJudgeJoins(id);
|
|
241
259
|
if (live !== undefined && live.isViewOf(meta)) {
|
|
242
260
|
live.addHolder(this);
|
|
243
261
|
this.joined.set(canonical, new WeakRef(live));
|
|
@@ -246,7 +264,8 @@ export class FileSessionRepo {
|
|
|
246
264
|
if (live !== undefined)
|
|
247
265
|
evictSharedSessionStorage(canonical);
|
|
248
266
|
const log = new AppendLog(this.pathFor(id));
|
|
249
|
-
const created = new FileSessionStorage(log, frozenRow({ ...meta, ...(meta.placement !== undefined ? { placement: { ...meta.placement } } : {}) }), entries, canonical, loss);
|
|
267
|
+
const created = new FileSessionStorage(log, frozenRow({ ...meta, ...(meta.placement !== undefined ? { placement: { ...meta.placement } } : {}) }), entries, canonical, loss, this.holderIsCurrent);
|
|
268
|
+
joinHolderJudge(authorityJudges, created, this.holderIsCurrent, "session", `FileSessionRepo: session ${id}`);
|
|
250
269
|
sharedSessionStorages.set(canonical, new WeakRef(created));
|
|
251
270
|
created.addHolder(this);
|
|
252
271
|
this.joined.set(canonical, new WeakRef(created));
|
|
@@ -274,6 +293,7 @@ export class FileSessionRepo {
|
|
|
274
293
|
const owner = ownerCell(options.owner ?? null);
|
|
275
294
|
const placement = placementCellToWrite(options.placement, id, Date.now());
|
|
276
295
|
const meta = heldRowCells(this.rowCells, { id, createdAt, ...(placement !== undefined ? { placement } : {}), ...incarnationCell(undefined), ...owner });
|
|
296
|
+
this.assertJudgeJoins(id);
|
|
277
297
|
linkNewRow(path, `${JSON.stringify({ kind: "meta", ...meta })}\n`, id, () => new SessionError("conflict", `session ${id} was created by another writer between this create's existence check and its write — refusing to replace or attach to that row`));
|
|
278
298
|
return new StoredSession(this.storage(meta, []));
|
|
279
299
|
}
|
|
@@ -394,6 +414,7 @@ export class FileSessionRepo {
|
|
|
394
414
|
for (const entry of forked) {
|
|
395
415
|
lines.push(JSON.stringify({ kind: "entry", entry }));
|
|
396
416
|
}
|
|
417
|
+
this.assertJudgeJoins(id);
|
|
397
418
|
linkNewRow(path, `${lines.join("\n")}\n`, id, () => forkTargetTaken(id));
|
|
398
419
|
return new StoredSession(this.storage(meta, [...forked]));
|
|
399
420
|
}
|
|
@@ -407,6 +428,7 @@ export class FileSessionRepo {
|
|
|
407
428
|
if (!heldRowMatches(this.rowCells, options?.expect, prior?.metadata, () => sessionLogMarkOf(prior.entries)))
|
|
408
429
|
throw rowExpectationMissed(sessionId, "import");
|
|
409
430
|
const meta = heldRowCells(this.rowCells, importRowCells(sessionId, owner, prior?.metadata, new Date().toISOString()));
|
|
431
|
+
this.assertJudgeJoins(sessionId);
|
|
410
432
|
evictSharedSessionStorage(canonicalStoreKey(this.pathFor(sessionId)));
|
|
411
433
|
const lines = [JSON.stringify({ kind: "meta", ...meta })];
|
|
412
434
|
for (const entry of validated) {
|
|
@@ -415,4 +437,54 @@ export class FileSessionRepo {
|
|
|
415
437
|
atomicWriteFile(this.tmpDir, this.pathFor(sessionId), `${lines.join("\n")}\n`);
|
|
416
438
|
return sessionHeadOf(meta, resolveLeafId(validated));
|
|
417
439
|
}
|
|
440
|
+
async recordOwner(sessionId, owner, expect) {
|
|
441
|
+
const name = recordedOwnerName(owner);
|
|
442
|
+
const prior = this.rowNow(sessionId);
|
|
443
|
+
if (prior === undefined)
|
|
444
|
+
return void readRowExpectation(expect);
|
|
445
|
+
this.refuseRowAfterDispose(sessionId);
|
|
446
|
+
const claimed = recordedOwnerCells(sessionId, name, prior.metadata, expect, () => heldRowMatches(this.rowCells, expect, prior.metadata, () => sessionLogMarkOf(prior.entries)));
|
|
447
|
+
if (claimed === undefined)
|
|
448
|
+
return prior.head;
|
|
449
|
+
this.assertJudgeJoins(sessionId);
|
|
450
|
+
const meta = heldRowCells(this.rowCells, claimed);
|
|
451
|
+
const path = this.pathFor(sessionId);
|
|
452
|
+
const canonical = canonicalStoreKey(path);
|
|
453
|
+
const live = sharedSessionStorages.get(canonical)?.deref();
|
|
454
|
+
const keep = live !== undefined && live.isViewOf(prior.metadata) ? live : undefined;
|
|
455
|
+
if (live !== undefined && keep === undefined)
|
|
456
|
+
evictSharedSessionStorage(canonical);
|
|
457
|
+
const held = readFileSync(path);
|
|
458
|
+
const headerEnd = held.indexOf(0x0a);
|
|
459
|
+
const header = (() => { try {
|
|
460
|
+
return JSON.parse((headerEnd < 0 ? held : held.subarray(0, headerEnd)).toString("utf8"));
|
|
461
|
+
}
|
|
462
|
+
catch {
|
|
463
|
+
return undefined;
|
|
464
|
+
} })();
|
|
465
|
+
if (header?.kind !== "meta")
|
|
466
|
+
throw new SessionError("storage", `session ${sessionId}'s log does not open with its header line — its owner is not recorded`);
|
|
467
|
+
const body = headerEnd < 0 ? Buffer.alloc(0) : held.subarray(headerEnd + 1);
|
|
468
|
+
const { atimeMs, mtimeMs } = statSync(path);
|
|
469
|
+
atomicWriteFile(this.tmpDir, path, Buffer.concat([Buffer.from(`${JSON.stringify({ kind: "meta", ...meta })}\n`, "utf8"), body]));
|
|
470
|
+
try {
|
|
471
|
+
utimesSync(path, atimeMs / 1000, mtimeMs / 1000);
|
|
472
|
+
}
|
|
473
|
+
catch {
|
|
474
|
+
}
|
|
475
|
+
if (keep !== undefined) {
|
|
476
|
+
let log;
|
|
477
|
+
try {
|
|
478
|
+
log = new AppendLog(path);
|
|
479
|
+
}
|
|
480
|
+
catch (err) {
|
|
481
|
+
evictSharedSessionStorage(canonical);
|
|
482
|
+
throw new SessionError("storage", `session ${sessionId}'s owner was recorded, but its open sessions could not be bound to the rewritten log: ${thrownText(err)}`, err instanceof Error ? err : undefined);
|
|
483
|
+
}
|
|
484
|
+
sessionStorageFinalizer.unregister(keep);
|
|
485
|
+
keep.adoptRecordedRow(log, frozenRow({ ...meta, ...(meta.placement !== undefined ? { placement: { ...meta.placement } } : {}) }));
|
|
486
|
+
sessionStorageFinalizer.register(keep, { canonical, log }, keep);
|
|
487
|
+
}
|
|
488
|
+
return sessionHeadOf(meta, prior.head.leafId);
|
|
489
|
+
}
|
|
418
490
|
}
|
|
@@ -110,13 +110,17 @@ export declare class FileWorkflowJournalStore implements WorkflowJournalStore {
|
|
|
110
110
|
* resolves to an empty journal (it cannot fork anything), so letting it share one claim key would only hand
|
|
111
111
|
* any tenant a denial-of-resume lever over another's runs. The scope is folded in as a digest rather than
|
|
112
112
|
* a sanitized literal so two distinct scopes can never collapse onto one filename by sanitization.
|
|
113
|
-
*
|
|
113
|
+
* The run id is the name when it is a path segment with no capital letter (`sanitizePathComponent` takes it — every id the engine
|
|
114
|
+
* mints); any other key — one a volume that folds case would file under another key's name (`Run-A` and `run-a`), or an older tree's
|
|
115
|
+
* root a host named with `:` or a space — is named by its digest behind a `%`, a character no path segment holds, so the two forms
|
|
116
|
+
* never meet, no two keys share a file on any volume, and every key is a claim the store records: the store keys by the id verbatim.
|
|
114
117
|
*/
|
|
115
118
|
private claimPathFor;
|
|
116
119
|
/**
|
|
117
|
-
* Read a claim file ONCE ({@link ClaimFile}): `undefined` when
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
+
* Read a claim file ONCE ({@link ClaimFile}): `undefined` when there is no file — nothing was judged, so nothing may be removed on
|
|
121
|
+
* the strength of this read; otherwise the exact bytes, and the claim they hold when they hold one (a truncated / malformed record
|
|
122
|
+
* holds none: takeable). A path that is there and cannot be read (a directory stands there, no permission, an I/O error) throws: a
|
|
123
|
+
* store failure, never read as "no claim" nor as somebody's.
|
|
120
124
|
*
|
|
121
125
|
* RB-356② — the raw bytes are the record's identity token. POSIX has no compare-and-delete, so the only way
|
|
122
126
|
* this store can check "the file I decided about is still the file on disk" immediately before removing one
|
|
@@ -174,6 +178,12 @@ export declare class FileWorkflowJournalStore implements WorkflowJournalStore {
|
|
|
174
178
|
* against anyone who got there first, so two processes racing on the same box (the shape the in-process
|
|
175
179
|
* `startWorkflow` guards cannot see — a shell restart resuming a run a still-live process is already
|
|
176
180
|
* resuming) produce exactly one winner.
|
|
181
|
+
*
|
|
182
|
+
* Every key is recorded ({@link claimPathFor}): a grant is a claim on disk, and a claim that cannot be recorded (the directory
|
|
183
|
+
* cannot be made, the publish fails, the claim path is there and cannot be read, the removal gate cannot be had) throws — a
|
|
184
|
+
* store failure, never a grant. Both answers say how long the claim has left by this process's clock when the answer is made
|
|
185
|
+
* (`resumeClaimRemainingMember`: none when it cannot be said); a re-claim by its holder does not renew the lease, and answers
|
|
186
|
+
* what is left of it.
|
|
177
187
|
*/
|
|
178
188
|
resumeClaim(input: ResumeClaimArgs): Promise<ResumeClaimAnswer>;
|
|
179
189
|
/** RB-242 — release ONLY a claim this `newRunId` still holds in this process ({@link heldHere}). A claim that is already gone
|
|
@@ -2,7 +2,7 @@ import { existsSync, statSync } from "node:fs";
|
|
|
2
2
|
import { mkdirSync, readFileSync, readdirSync, unlinkSync } from "./descriptor-seat.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { basename, join } from "node:path";
|
|
5
|
-
import { callKeyOrdinal, readWorkflowJournalEntry, launchRecordToKeepOrThrow, readLaunchRecordVerdict, assertLaunchRecordFits, sameLaunchRecord, WorkflowLaunchConflictError, WorkflowLaunchUnreadableError, WorkflowJournalIncompatibleError, } from "../../core/workflow-journal-store.js";
|
|
5
|
+
import { callKeyOrdinal, readWorkflowJournalEntry, launchRecordToKeepOrThrow, readLaunchRecordVerdict, assertLaunchRecordFits, sameLaunchRecord, WorkflowLaunchConflictError, WorkflowLaunchUnreadableError, WorkflowJournalIncompatibleError, resumeClaimRemainingMember, } from "../../core/workflow-journal-store.js";
|
|
6
6
|
import { processCensus, processFingerprint } from "../../core/process-identity.js";
|
|
7
7
|
import { AppendLog, readJsonlRecords } from "./fs-atomic.js";
|
|
8
8
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
@@ -245,9 +245,8 @@ export class FileWorkflowJournalStore {
|
|
|
245
245
|
log = new AppendLog(this.pathFor(runId));
|
|
246
246
|
this.logs.set(runId, log);
|
|
247
247
|
}
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
: { scope, ordinal: callKeyOrdinal(entry.callKey), callKey: entry.callKey, result: entry.result };
|
|
248
|
+
const head = { scope, ordinal: callKeyOrdinal(entry.callKey), callKey: entry.callKey };
|
|
249
|
+
const line = entry.parked !== undefined ? { ...head, parked: entry.parked } : entry.stopped !== undefined ? { ...head, stopped: entry.stopped } : { ...head, result: entry.result };
|
|
251
250
|
log.append(line, this.fsyncEnabled);
|
|
252
251
|
}
|
|
253
252
|
async load(runId, scope) {
|
|
@@ -272,15 +271,27 @@ export class FileWorkflowJournalStore {
|
|
|
272
271
|
}
|
|
273
272
|
claimPathFor(sourceRunId, scope) {
|
|
274
273
|
const scopeTag = createHash("sha256").update(scope).digest("hex").slice(0, 16);
|
|
275
|
-
|
|
274
|
+
let name;
|
|
275
|
+
try {
|
|
276
|
+
name = sanitizePathComponent(sourceRunId);
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
name = undefined;
|
|
280
|
+
}
|
|
281
|
+
if (name === undefined || /[A-Z]/.test(name)) {
|
|
282
|
+
name = `%${createHash("sha256").update(JSON.stringify(sourceRunId), "utf8").digest("hex").slice(0, 32)}`;
|
|
283
|
+
}
|
|
284
|
+
return join(this.claimsDir, `${name}.${scopeTag}.json`);
|
|
276
285
|
}
|
|
277
286
|
readClaimAt(path) {
|
|
278
287
|
let raw;
|
|
279
288
|
try {
|
|
280
289
|
raw = readFileSync(path, "utf8");
|
|
281
290
|
}
|
|
282
|
-
catch {
|
|
283
|
-
|
|
291
|
+
catch (err) {
|
|
292
|
+
if (err.code === "ENOENT")
|
|
293
|
+
return undefined;
|
|
294
|
+
throw err;
|
|
284
295
|
}
|
|
285
296
|
try {
|
|
286
297
|
const rec = JSON.parse(raw);
|
|
@@ -370,13 +381,7 @@ export class FileWorkflowJournalStore {
|
|
|
370
381
|
}
|
|
371
382
|
async resumeClaim(input) {
|
|
372
383
|
const { sourceRunId, newRunId, scope } = input;
|
|
373
|
-
|
|
374
|
-
try {
|
|
375
|
-
path = this.claimPathFor(sourceRunId, scope);
|
|
376
|
-
}
|
|
377
|
-
catch {
|
|
378
|
-
return { granted: true };
|
|
379
|
-
}
|
|
384
|
+
const path = this.claimPathFor(sourceRunId, scope);
|
|
380
385
|
mkdirSync(this.claimsDir, { recursive: true, mode: 0o700 });
|
|
381
386
|
this.sweepExpiredClaims();
|
|
382
387
|
const record = { sourceRunId, holder: newRunId, expiresAt: Date.now() + RESUME_CLAIM_TTL_MS, holderProcess: processFingerprint() };
|
|
@@ -384,7 +389,7 @@ export class FileWorkflowJournalStore {
|
|
|
384
389
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
385
390
|
try {
|
|
386
391
|
writeThenLink(path, payload);
|
|
387
|
-
return { granted: true };
|
|
392
|
+
return { granted: true, ...resumeClaimRemainingMember(record.expiresAt, Date.now()) };
|
|
388
393
|
}
|
|
389
394
|
catch (err) {
|
|
390
395
|
if (err.code !== "EEXIST")
|
|
@@ -394,28 +399,31 @@ export class FileWorkflowJournalStore {
|
|
|
394
399
|
if (read === undefined)
|
|
395
400
|
continue;
|
|
396
401
|
const existing = read.claim;
|
|
397
|
-
|
|
402
|
+
const now = Date.now();
|
|
403
|
+
if (existing !== undefined && claimBinds(existing, now)) {
|
|
404
|
+
const left = resumeClaimRemainingMember(existing.rec.expiresAt, now);
|
|
398
405
|
if (heldHere(existing, newRunId))
|
|
399
|
-
return { granted: true };
|
|
400
|
-
return { granted: false, holder: existing.rec.holder,
|
|
406
|
+
return { granted: true, ...left };
|
|
407
|
+
return { granted: false, holder: existing.rec.holder, ...left };
|
|
401
408
|
}
|
|
402
409
|
this.removeIfUnchanged(path, read.raw);
|
|
403
410
|
}
|
|
404
411
|
const winner = this.readClaimAt(path)?.claim;
|
|
405
|
-
const
|
|
412
|
+
const lastLook = Date.now();
|
|
413
|
+
const bound = winner !== undefined && claimBinds(winner, lastLook) ? winner : undefined;
|
|
406
414
|
if (bound !== undefined && heldHere(bound, newRunId))
|
|
407
|
-
return { granted: true };
|
|
408
|
-
return { granted: false, ...(bound !== undefined ? { holder: bound.rec.holder,
|
|
415
|
+
return { granted: true, ...resumeClaimRemainingMember(bound.rec.expiresAt, lastLook) };
|
|
416
|
+
return { granted: false, ...(bound !== undefined ? { holder: bound.rec.holder, ...resumeClaimRemainingMember(bound.rec.expiresAt, lastLook) } : {}) };
|
|
409
417
|
}
|
|
410
418
|
async releaseResumeClaim(input) {
|
|
411
|
-
|
|
419
|
+
const path = this.claimPathFor(input.sourceRunId, input.scope);
|
|
420
|
+
let read;
|
|
412
421
|
try {
|
|
413
|
-
|
|
422
|
+
read = this.readClaimAt(path);
|
|
414
423
|
}
|
|
415
424
|
catch {
|
|
416
425
|
return;
|
|
417
426
|
}
|
|
418
|
-
const read = this.readClaimAt(path);
|
|
419
427
|
const existing = read?.claim;
|
|
420
428
|
if (read === undefined || existing === undefined || !heldHere(existing, input.newRunId))
|
|
421
429
|
return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type WorkflowRunListByScopeOptions, type WorkflowRunStore, type WorkflowRunSummary, type WorkflowRunUpdateOptions } from "../../core/workflow-run-store.js";
|
|
1
|
+
import { type WorkflowRunListByScopeOptions, type WorkflowRunStore, type WorkflowRunSummary, type WorkflowRunUpdateExpect, type WorkflowRunUpdateOptions } from "../../core/workflow-run-store.js";
|
|
2
2
|
import type { WorkflowRun } from "../../orchestration/workflow.js";
|
|
3
3
|
import { type LedgerSpec } from "./shared-ledger.js";
|
|
4
4
|
import { type CorruptReadInfo } from "./corrupt-read-sink.js";
|
|
@@ -63,6 +63,19 @@ export declare class FileWorkflowRunStore implements WorkflowRunStore {
|
|
|
63
63
|
private readonly disclose;
|
|
64
64
|
private get runs();
|
|
65
65
|
constructor(root: string, options?: FileWorkflowRunStoreOptions);
|
|
66
|
+
/**
|
|
67
|
+
* The open's pass over the finished records an older engine wrote: each is given its tree id as `workflowTreeIdStampOf` answers it
|
|
68
|
+
* (the same rule, driven over the rows in hand), by the compare-and-set that answer names. A best-effort migration, never a
|
|
69
|
+
* condition of the open: a row that does not read is left as it is (its listing says so), a record whose line does not read whole
|
|
70
|
+
* stays without a tree id, and a write that fails or loses leaves that row without one — told on the store's disclosure seat
|
|
71
|
+
* (`onCorruptRead`, naming the run), and once for the whole open on the process's default notice seat
|
|
72
|
+
* (`store.tree_id_stamp_incomplete`, how many rows, how many stamps the closing compaction did not sync, and the first failure's
|
|
73
|
+
* code) — and the next open tries again. Synchronous,
|
|
74
|
+
* inside the construction: no other operation of this process runs between the read of a row and its write. The pass's appends are
|
|
75
|
+
* not synced one by one and start no compaction; the pass ends with one compaction, the one write that makes them durable (a crash
|
|
76
|
+
* before it loses only stamps, which the next open writes again — a stamp is the same on every pass).
|
|
77
|
+
*/
|
|
78
|
+
private stampTreeIds;
|
|
66
79
|
/** Serialize an op behind any in-flight op on the same id (the in-process per-id async mutex). */
|
|
67
80
|
private withLock;
|
|
68
81
|
/** Commit one ledger event (append + fsync) THEN flip the in-memory map (crash-safe ordering), then
|
|
@@ -70,9 +83,7 @@ export declare class FileWorkflowRunStore implements WorkflowRunStore {
|
|
|
70
83
|
private commit;
|
|
71
84
|
put(id: string, run: WorkflowRun): Promise<void>;
|
|
72
85
|
get(id: string): Promise<WorkflowRun | null>;
|
|
73
|
-
update(id: string, scope: string, run: WorkflowRun, expect?:
|
|
74
|
-
rev: number;
|
|
75
|
-
}, _opts?: WorkflowRunUpdateOptions): Promise<boolean>;
|
|
86
|
+
update(id: string, scope: string, run: WorkflowRun, expect?: WorkflowRunUpdateExpect, _opts?: WorkflowRunUpdateOptions): Promise<boolean>;
|
|
76
87
|
listByScope(scope: string, opts?: WorkflowRunListByScopeOptions): Promise<WorkflowRunSummary[]>;
|
|
77
88
|
reap(scope: string, now: number, opts?: {
|
|
78
89
|
maxAgeMs?: number;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { receiveRetentionPolicy } from "../../core/retention-policy.js";
|
|
2
2
|
import { assertDeletionSessionId } from "../../core/retention.js";
|
|
3
3
|
import { WorkflowRunStoreError, admitWorkflowRun, isTerminalWorkflowStatus, nextWorkflowRunOnUpdate, queryWorkflowRuns, readStoredWorkflowRun, workflowRunReapCandidates, workflowRunsDoomed, WORKFLOW_RUN_REAP_KNOBS, WORKFLOW_RUN_ROW_SHAPE, } from "../../core/workflow-run-store.js";
|
|
4
|
+
import { workflowTreeIdStampInHand } from "../../orchestration/workflow-tree-id.js";
|
|
5
|
+
import { readMember, thrownName } from "../../core/thrown-value.js";
|
|
6
|
+
import { deliverEngineNotice } from "../../core/engine-notice.js";
|
|
7
|
+
function failureCodeOf(err) {
|
|
8
|
+
const code = readMember(err, "code");
|
|
9
|
+
if (typeof code === "string" && /^[A-Za-z0-9_.-]{1,40}$/.test(code))
|
|
10
|
+
return code;
|
|
11
|
+
return thrownName(err) ?? typeof err;
|
|
12
|
+
}
|
|
4
13
|
import { ledgerPathsOf, SharedLedgerTable } from "./shared-ledger.js";
|
|
5
14
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
6
15
|
import { assertAdoptionBootGate } from "./adoption/marker.js";
|
|
@@ -56,6 +65,73 @@ export class FileWorkflowRunStore {
|
|
|
56
65
|
const sink = guardCorruptSink(opts.onCorruptRead);
|
|
57
66
|
this.disclose = sink === undefined ? undefined : (reason) => sink({ kind: "file", path: paths.ledgerPath, reason });
|
|
58
67
|
this.ledger = runLedgers.acquire({ ...paths, ...(sink !== undefined ? { onCorruptRead: sink } : {}) });
|
|
68
|
+
this.stampTreeIds(paths.ledgerPath);
|
|
69
|
+
}
|
|
70
|
+
stampTreeIds(ledgerPath) {
|
|
71
|
+
let stamped = 0;
|
|
72
|
+
let notStamped = 0;
|
|
73
|
+
let firstCode;
|
|
74
|
+
const failed = (err) => {
|
|
75
|
+
notStamped += 1;
|
|
76
|
+
firstCode ??= failureCodeOf(err);
|
|
77
|
+
};
|
|
78
|
+
for (const [id, raw] of [...this.runs]) {
|
|
79
|
+
let row;
|
|
80
|
+
try {
|
|
81
|
+
row = readStoredWorkflowRun(raw, { key: id });
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const scope = row.scope;
|
|
87
|
+
const answer = workflowTreeIdStampInHand(row, (up) => {
|
|
88
|
+
const r = this.runs.get(up);
|
|
89
|
+
if (r === undefined)
|
|
90
|
+
return null;
|
|
91
|
+
try {
|
|
92
|
+
const got = readStoredWorkflowRun(r, { key: up });
|
|
93
|
+
return got.scope === scope ? got : null;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return "unreadable";
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
if (typeof answer === "string" || answer.kind !== "stamp")
|
|
100
|
+
continue;
|
|
101
|
+
try {
|
|
102
|
+
const next = nextWorkflowRunOnUpdate(this.runs.get(id), id, scope, { ...row, treeId: answer.treeId }, answer.expect);
|
|
103
|
+
if (next === null)
|
|
104
|
+
throw new Error("the row moved before its write");
|
|
105
|
+
this.ledger.commit({ t: "update", id, run: next }, false, Number.POSITIVE_INFINITY);
|
|
106
|
+
stamped += 1;
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
failed(err);
|
|
110
|
+
this.disclose?.(`workflow run ${JSON.stringify(id)}: its tree id was not written at the store's open (${failureCodeOf(err)}) — the record stays without one, and the next open tries again`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
let notSynced = 0;
|
|
114
|
+
if (stamped > 0) {
|
|
115
|
+
try {
|
|
116
|
+
this.ledger.compact();
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
firstCode ??= failureCodeOf(err);
|
|
120
|
+
notSynced = stamped;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (notStamped > 0 || notSynced > 0) {
|
|
124
|
+
const code = firstCode ?? "unknown";
|
|
125
|
+
const said = [
|
|
126
|
+
...(notStamped > 0 ? [`${notStamped} finished workflow run record(s) were not given their tree id (the records read as before; the next open of this store tries again)`] : []),
|
|
127
|
+
...(notSynced > 0 ? [`the tree ids given to ${notSynced} record(s) are written but not synced (a crash before the store's next synced write loses them, and the open after it writes them again)`] : []),
|
|
128
|
+
];
|
|
129
|
+
deliverEngineNotice(undefined, {
|
|
130
|
+
code: "store.tree_id_stamp_incomplete",
|
|
131
|
+
message: `[sema] file store at ${ledgerPath}, at its open: ${said.join("; ")} — first failure: ${code}.`,
|
|
132
|
+
detail: { path: ledgerPath, notStamped, notSynced, code },
|
|
133
|
+
});
|
|
134
|
+
}
|
|
59
135
|
}
|
|
60
136
|
withLock(id, fn) {
|
|
61
137
|
return this.ledger.withLock(id, fn);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { type AssertAllKeysHandled, type PermissionMode } from "../../core/ask-origin.js";
|
|
12
12
|
import { type EngineNotice } from "../../core/engine-notice.js";
|
|
13
13
|
import type { SharedReadClassifier } from "../../core/runner/shared-read-classifier.js";
|
|
14
|
+
import type { ResolvedSharedArtifactReads } from "../../core/shared-artifact-reads.js";
|
|
14
15
|
import { type ArtifactCallBinding, type ArtifactHost, type ArtifactHostCapabilities } from "../../core/artifact-host.js";
|
|
15
16
|
import { type OnAsk } from "../../core/tool-policy.js";
|
|
16
17
|
import type { ToolSpec } from "../../core/types.js";
|
|
@@ -64,10 +65,10 @@ export interface ArtifactToolOptions {
|
|
|
64
65
|
/** The run's effective approver — the same frozen seat the tool gate resolves asks at (`frozenOnAsk` =
|
|
65
66
|
* `spec.onAsk ?? deps.onAsk`), riding the MOUNT dep under the same rule as the workflow mount's `parentOnAsk`: a core
|
|
66
67
|
* mount's execute ctx is minimal, so the seat never rides `ctx`. The shared-read consent gate resolves at it. Absent
|
|
67
|
-
* = the run has no ask face, and a shared read
|
|
68
|
-
* never silently delivered. */
|
|
68
|
+
* = the run has no ask face, and a shared read whose question the setting ({@link sharedReads}), the permission mode and
|
|
69
|
+
* auto mode's classifier all leave for a person is then REFUSED fail-closed (`artifact.refused`, content withheld) — never silently delivered. */
|
|
69
70
|
onAsk?: OnAsk;
|
|
70
|
-
/** The run's effective permission mode, read at each shared-read consent (a steer moves it). The consent ask is
|
|
71
|
+
/** The run's effective permission mode, read at each shared-read consent the setting does not answer (a steer moves it). The consent ask is
|
|
71
72
|
* arbitrated as the gate's asks are (class `artifact_shared_read`): `bypassPermissions` RELEASES the read — delivered,
|
|
72
73
|
* recorded on that call's result card (`details.released`, the gate's release record), told to nobody, and NOT
|
|
73
74
|
* remembered as an approval (a mode release is not a person's nod; a later `default` leg asks) — `dontAsk` refuses it,
|
|
@@ -78,6 +79,12 @@ export interface ArtifactToolOptions {
|
|
|
78
79
|
* for this call only (not remembered as a person's nod), a refusal withholds it with the classifier's reason, and a question it
|
|
79
80
|
* hands on goes to the approver. Absent ⇒ the approver is asked (the leg arms no classifier, or a host mounts the tool itself). */
|
|
80
81
|
classifySharedRead?: SharedReadClassifier;
|
|
82
|
+
/** The `sharedArtifactReads` setting as the leg resolved it — what `resolveSharedArtifactReads` returned, read once at mount.
|
|
83
|
+
* `allow` answers the tool's consent question on a shared target yes, wherever it is asked (`read`, `list_files`, `read_file`,
|
|
84
|
+
* a publish conflict's snapshot), with nobody asked under any permission mode; the call's result records it
|
|
85
|
+
* (`details.allowedBySetting: { setting: "sharedArtifactReads", layer }`) and no person's nod is remembered. Absent, or `ask`
|
|
86
|
+
* ⇒ the consent as described above. */
|
|
87
|
+
sharedReads?: ResolvedSharedArtifactReads;
|
|
81
88
|
}
|
|
82
89
|
/** Supporting files per publish (upstream cap); enforced in the schema AND in the body, for callers that bypass the schema. */
|
|
83
90
|
export declare const MAX_FILES_PER_PUBLISH = 255;
|
|
@@ -183,6 +183,9 @@ export function createArtifactTool(opts) {
|
|
|
183
183
|
}
|
|
184
184
|
export function assembleArtifactTool(opts, caps, onNotice) {
|
|
185
185
|
const { host, runId, taskId, sessionId, agentName, readLocalFile, onAsk, permissionMode, classifySharedRead } = opts;
|
|
186
|
+
const setting = opts.sharedReads;
|
|
187
|
+
const settingLayer = setting?.value === "allow" ? setting.decidedBy : undefined;
|
|
188
|
+
const settingAllows = settingLayer === "managed" || settingLayer === "user" ? settingLayer : undefined;
|
|
186
189
|
const binding = readArtifactCallBinding(opts.binding);
|
|
187
190
|
const versions = new Map();
|
|
188
191
|
const bindings = new Map();
|
|
@@ -194,6 +197,7 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
194
197
|
const consentInFlight = new Map();
|
|
195
198
|
const askedCalls = new Map();
|
|
196
199
|
const releasedCalls = new Map();
|
|
200
|
+
const settingCalls = new Set();
|
|
197
201
|
const activeTargets = new Map();
|
|
198
202
|
const ownerAccounts = new Map();
|
|
199
203
|
const hasAction = (a) => caps.actions.includes(a);
|
|
@@ -425,8 +429,11 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
425
429
|
if (snapshot !== "reread") {
|
|
426
430
|
const held = snapshot;
|
|
427
431
|
const withheld = url === undefined || judgeOwner(() => held.ownerIdentity, false, url, ctx) !== "mine" || (await filesOwnership(url, ctx)) !== undefined;
|
|
428
|
-
|
|
432
|
+
const unconsented = url !== undefined && sharedUrls.has(url) && !sharedReadApproved.has(url);
|
|
433
|
+
if (withheld || (unconsented && settingAllows === undefined))
|
|
429
434
|
snapshot = "reread";
|
|
435
|
+
else if (unconsented)
|
|
436
|
+
settingCalls.add(ctx.toolCallId);
|
|
430
437
|
}
|
|
431
438
|
if (snapshot !== "reread" && url !== undefined)
|
|
432
439
|
versions.set(url, out.currentVersion);
|
|
@@ -503,6 +510,10 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
503
510
|
const sharedReadConsent = (url, ref, ctx) => {
|
|
504
511
|
if (sharedReadApproved.has(url))
|
|
505
512
|
return Promise.resolve({ ok: true });
|
|
513
|
+
if (settingAllows !== undefined) {
|
|
514
|
+
settingCalls.add(ctx.toolCallId);
|
|
515
|
+
return Promise.resolve({ ok: true });
|
|
516
|
+
}
|
|
506
517
|
const title = ref?.title !== undefined ? ` (${inlineUntrusted(ref.title, 120)})` : "";
|
|
507
518
|
const version = ref !== undefined ? `, version ${inlineUntrusted(ref.version, 60)}` : "";
|
|
508
519
|
const question = `Read a shared artifact: ${inlineUntrusted(url, 300)}${title}${version} — an artifact another person shared with this user`;
|
|
@@ -688,6 +699,7 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
688
699
|
let result;
|
|
689
700
|
let released;
|
|
690
701
|
let asked;
|
|
702
|
+
let bySetting = false;
|
|
691
703
|
try {
|
|
692
704
|
result = await dispatch(action, a, ctx);
|
|
693
705
|
}
|
|
@@ -697,6 +709,7 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
697
709
|
releasedCalls.delete(ctx.toolCallId);
|
|
698
710
|
asked = askedCalls.get(ctx.toolCallId);
|
|
699
711
|
askedCalls.delete(ctx.toolCallId);
|
|
712
|
+
bySetting = settingCalls.delete(ctx.toolCallId);
|
|
700
713
|
if (target !== undefined) {
|
|
701
714
|
const left = activeTargets.get(target) - 1;
|
|
702
715
|
if (left > 0)
|
|
@@ -711,6 +724,8 @@ export function assembleArtifactTool(opts, caps, onNotice) {
|
|
|
711
724
|
result = { ...result, details: { ...(isRecord(result.details) ? result.details : {}), released } };
|
|
712
725
|
if (asked !== undefined && typeof result !== "string")
|
|
713
726
|
result = { ...result, details: { ...(isRecord(result.details) ? result.details : {}), asked } };
|
|
727
|
+
if (bySetting && settingAllows !== undefined && typeof result !== "string")
|
|
728
|
+
result = { ...result, details: { ...(isRecord(result.details) ? result.details : {}), allowedBySetting: { setting: "sharedArtifactReads", layer: settingAllows } } };
|
|
714
729
|
if (typeof result === "string" || result.isError !== true) {
|
|
715
730
|
breaker.clear();
|
|
716
731
|
return result;
|
|
@@ -148,8 +148,14 @@ export declare function programPositionRunsShell(pos: ProgramPosition, runsShell
|
|
|
148
148
|
/** Which decline, if any, this program position raises — ONE reading of the two facts above, so no consumer
|
|
149
149
|
* re-derives either. A refusal that says a SHELL runs is NOT one: it names what runs. */
|
|
150
150
|
export declare function shellScanDeclineOf(pos: ProgramPosition, acceptsStreamTarget: (basename: string) => boolean): ShellScanDecline | undefined;
|
|
151
|
-
/** ONE sentence per refusal kind, minted here and nowhere else
|
|
151
|
+
/** ONE sentence per refusal kind, minted here and nowhere else: the reason ({@link programPositionRefusalReason}) and the
|
|
152
|
+
* shared tail. */
|
|
152
153
|
export declare function programPositionRefusalSentence(refusal: ProgramPositionRefusal): string;
|
|
153
|
-
/** The
|
|
154
|
-
*
|
|
155
|
-
export declare function
|
|
154
|
+
/** The reason half of {@link programPositionRefusalSentence}: what the program position holds, without the tail — for an
|
|
155
|
+
* account that says what follows from it before the tail (the read station's). */
|
|
156
|
+
export declare function programPositionRefusalReason(refusal: ProgramPositionRefusal): string;
|
|
157
|
+
/** The reason a segment whose program the walk DECLINED carries, read off the segment's text — the program-position reader's own
|
|
158
|
+
* refusal, the stream fact, or that no program could be named: the read station's account of the segment, which says what
|
|
159
|
+
* follows from it and closes it. `quoted` puts the segment's text in front of the rest of the reason — the station's own budget
|
|
160
|
+
* for it (default: the text whole). */
|
|
161
|
+
export declare function declinedProgramReason(text: string, quoted?: (text: string, rest: string) => string): string;
|
|
@@ -200,31 +200,34 @@ export function shellScanDeclineOf(pos, acceptsStreamTarget) {
|
|
|
200
200
|
return argvReentryUnjudged(pos, acceptsStreamTarget) ? "stream_fed_operands" : undefined;
|
|
201
201
|
}
|
|
202
202
|
export function programPositionRefusalSentence(refusal) {
|
|
203
|
+
return `${programPositionRefusalReason(refusal)} ${NOT_AUTO_ALLOWED}`;
|
|
204
|
+
}
|
|
205
|
+
export function programPositionRefusalReason(refusal) {
|
|
203
206
|
switch (refusal.kind) {
|
|
204
207
|
case "option_at_program_position":
|
|
205
208
|
return refusal.endedBy !== undefined
|
|
206
|
-
? `"${refusal.endedBy} --" ends the options, and "${refusal.option}" after it is a name spelled like an option where the program it runs would be — which program runs is not read from such a word
|
|
207
|
-
: `"${refusal.owner}" is given the option "${refusal.option}" where the program it runs would be — which program runs is not readable without that word's option table
|
|
209
|
+
? `"${refusal.endedBy} --" ends the options, and "${refusal.option}" after it is a name spelled like an option where the program it runs would be — which program runs is not read from such a word`
|
|
210
|
+
: `"${refusal.owner}" is given the option "${refusal.option}" where the program it runs would be — which program runs is not readable without that word's option table`;
|
|
208
211
|
case "control_syntax_at_program_position":
|
|
209
|
-
return `"${refusal.owner}" is given shell control syntax ("${refusal.word}") where the program it runs would be
|
|
212
|
+
return `"${refusal.owner}" is given shell control syntax ("${refusal.word}") where the program it runs would be`;
|
|
210
213
|
case "wildcard_program_word":
|
|
211
|
-
return `the program word "${refusal.word}" carries an unquoted filename pattern, so the shell expands it against the filesystem and which program runs is not readable from the text
|
|
214
|
+
return `the program word "${refusal.word}" carries an unquoted filename pattern, so the shell expands it against the filesystem and which program runs is not readable from the text`;
|
|
212
215
|
default: {
|
|
213
216
|
const exhaustive = refusal;
|
|
214
217
|
return exhaustive;
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
220
|
}
|
|
218
|
-
export function
|
|
221
|
+
export function declinedProgramReason(text, quoted = (t, rest) => `"${t.trim()}"${rest}`) {
|
|
219
222
|
const lexed = lexShellText(text);
|
|
220
223
|
if (!("reject" in lexed) && lexed.segments[0] !== undefined) {
|
|
221
224
|
const pos = readProgramPosition(argvOf(lexed.segments[0]));
|
|
222
225
|
if (pos.refusal !== undefined)
|
|
223
|
-
return
|
|
226
|
+
return programPositionRefusalReason(pos.refusal);
|
|
224
227
|
if (pos.argvFromStdin) {
|
|
225
228
|
const runs = pos.program?.basename ?? "the program it runs";
|
|
226
|
-
return
|
|
229
|
+
return quoted(text, ` hands ${runs} its operands on its standard input, which this station does not read`);
|
|
227
230
|
}
|
|
228
231
|
}
|
|
229
|
-
return
|
|
232
|
+
return quoted(text, " runs a program this station cannot name");
|
|
230
233
|
}
|