@sema-agent/core 7.67.3 → 7.68.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 +1516 -0
- package/README.md +18 -9
- package/README.zh-CN.md +16 -8
- package/dist/agents/agent-definition.d.ts +1 -1
- package/dist/agents/agent-definition.js +4 -1
- package/dist/agents/cascade.d.ts +2 -2
- package/dist/agents/cascade.js +3 -1
- package/dist/agents/cumulative-stats.d.ts +2 -1
- package/dist/agents/cumulative-stats.js +4 -1
- package/dist/agents/list-agents-tool.d.ts +30 -0
- package/dist/agents/list-agents-tool.js +45 -3
- package/dist/agents/peer-admission.d.ts +2 -2
- package/dist/agents/peer-session-drain.d.ts +2 -0
- package/dist/agents/peer-session-drain.js +1 -0
- package/dist/agents/repair-loop.js +3 -1
- package/dist/agents/retain-ledger.d.ts +61 -8
- package/dist/agents/retain-ledger.js +25 -3
- package/dist/agents/roster-store.d.ts +4 -2
- package/dist/agents/send-message-tool.d.ts +1 -1
- package/dist/agents/send-message-tool.js +20 -15
- package/dist/agents/subagent-steps.js +2 -10
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +106 -76
- package/dist/agents/tool-filter.d.ts +20 -11
- package/dist/agents/tool-filter.js +8 -4
- package/dist/agents/verify.d.ts +3 -1
- package/dist/agents/verify.js +2 -0
- package/dist/brain/anthropic.js +4 -4
- package/dist/brain/open-responses.js +3 -1
- package/dist/brain/openai.js +3 -1
- package/dist/brain/reasoning-request.d.ts +73 -19
- package/dist/brain/reasoning-request.js +164 -72
- package/dist/brain/reasoning-stamp.d.ts +26 -0
- package/dist/brain/reasoning-stamp.js +10 -0
- package/dist/brain/reasoning.d.ts +95 -162
- package/dist/brain/reasoning.js +31 -86
- package/dist/brain/route-adjudicator.d.ts +9 -7
- package/dist/brain/route-adjudicator.js +12 -10
- package/dist/brain/status-sink.d.ts +19 -64
- package/dist/brain/status-sink.js +5 -21
- package/dist/brain/stream-engine.d.ts +11 -2
- package/dist/brain/stream-engine.js +10 -0
- package/dist/core/a2a.d.ts +17 -5
- package/dist/core/a2a.js +11 -3
- package/dist/core/allow-entry.d.ts +35 -15
- package/dist/core/allow-entry.js +47 -60
- package/dist/core/ask-headline.d.ts +68 -0
- package/dist/core/ask-headline.js +23 -0
- package/dist/core/ask-origin.d.ts +36 -8
- package/dist/core/ask-origin.js +17 -10
- package/dist/core/ask-question.d.ts +34 -7
- package/dist/core/ask-question.js +10 -1
- package/dist/core/ask-unresolvable-notice.d.ts +7 -0
- package/dist/core/ask-unresolvable-notice.js +9 -3
- package/dist/core/auto-strip.d.ts +53 -0
- package/dist/core/auto-strip.js +76 -0
- package/dist/core/background-agent-store.d.ts +45 -5
- package/dist/core/background-agent-store.js +69 -15
- package/dist/core/background-shell.d.ts +2 -2
- package/dist/core/caller-text.js +2 -2
- package/dist/core/canonical-json.d.ts +13 -0
- package/dist/core/canonical-json.js +7 -0
- package/dist/core/checkpoint-features.d.ts +66 -20
- package/dist/core/checkpoint-features.js +12 -1
- package/dist/core/checkpoint-generation.d.ts +1 -1
- package/dist/core/checkpoint-queries.d.ts +1 -1
- package/dist/core/checkpoint-queries.js +4 -1
- package/dist/core/checkpoint-requirements.d.ts +25 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -0
- package/dist/core/checkpoint-row-verdict.js +4 -0
- package/dist/core/checkpoint-store.d.ts +66 -38
- package/dist/core/checkpoint-store.js +15 -6
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +1 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/delegation-frames.d.ts +9 -12
- package/dist/core/delegation-frames.js +9 -8
- package/dist/core/engine-capabilities.d.ts +21 -8
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +147 -34
- package/dist/core/engine-notice.js +27 -16
- package/dist/core/engine-storage-backend.d.ts +2 -1
- package/dist/core/env-budget.js +3 -3
- package/dist/core/env-knob-announce.d.ts +10 -10
- package/dist/core/env-knob-announce.js +3 -6
- package/dist/core/file-history-store.d.ts +29 -4
- package/dist/core/file-history-store.js +13 -0
- package/dist/core/frame-settlement.d.ts +2 -1
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +56 -49
- package/dist/core/governance-codes.d.ts +39 -3
- package/dist/core/governance-codes.js +61 -3
- package/dist/core/hooks.d.ts +29 -11
- package/dist/core/hooks.js +5 -2
- package/dist/core/human-input-projection.js +3 -3
- package/dist/core/input-author.d.ts +17 -3
- package/dist/core/input-author.js +15 -3
- package/dist/core/leg-identity.d.ts +10 -28
- package/dist/core/leg-identity.js +1 -21
- package/dist/core/lsp.d.ts +18 -13
- package/dist/core/lsp.js +30 -22
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/mailbox-store.js +4 -4
- package/dist/core/mcp-connection-pool.d.ts +93 -4
- package/dist/core/mcp-connection-pool.js +104 -1
- package/dist/core/mcp-failure.d.ts +38 -12
- package/dist/core/mcp-failure.js +9 -13
- package/dist/core/mcp-probe.d.ts +4 -3
- package/dist/core/mcp-server-link.d.ts +4 -2
- package/dist/core/mcp-server-link.js +4 -5
- package/dist/core/mcp-server-spec.d.ts +3 -3
- package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
- package/dist/core/mcp-server-unavailable-notice.js +18 -4
- package/dist/core/mcp.d.ts +40 -6
- package/dist/core/mcp.js +39 -13
- package/dist/core/memory-engine/content-origin.js +2 -2
- package/dist/core/memory-engine/control-objects.d.ts +2 -4
- package/dist/core/memory-engine/control-objects.js +2 -10
- package/dist/core/memory-engine/delegation-settlement.js +6 -1
- package/dist/core/memory-engine/dual-root.js +3 -0
- package/dist/core/memory-engine/engine.d.ts +6 -4
- package/dist/core/memory-engine/engine.js +32 -29
- package/dist/core/memory-engine/file-backend.d.ts +20 -5
- package/dist/core/memory-engine/file-backend.js +21 -31
- package/dist/core/memory-engine/frontmatter.d.ts +2 -0
- package/dist/core/memory-engine/frontmatter.js +4 -0
- package/dist/core/memory-engine/layout.d.ts +114 -20
- package/dist/core/memory-engine/layout.js +340 -22
- package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
- package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
- package/dist/core/memory-engine/mount-failed-notice.js +43 -10
- package/dist/core/memory-engine/sync-client.js +4 -5
- package/dist/core/model-fallbacks.d.ts +5 -1
- package/dist/core/model-fallbacks.js +3 -3
- package/dist/core/model-receipt.d.ts +2 -1
- package/dist/core/model-receipt.js +12 -1
- package/dist/core/mods/kernel/dispatch.d.ts +2 -2
- package/dist/core/mods/kernel/dispatch.js +14 -6
- package/dist/core/mods/kernel/events.d.ts +8 -5
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/registration.d.ts +9 -0
- package/dist/core/mods/package.js +1 -1
- package/dist/core/mods/session-append.d.ts +4 -2
- package/dist/core/mods/session-append.js +3 -0
- package/dist/core/mods/stations.d.ts +7 -11
- package/dist/core/mods/stations.js +4 -7
- package/dist/core/mods/tool-call.d.ts +10 -8
- package/dist/core/mods/tool-call.js +15 -18
- package/dist/core/mounted-mcp.d.ts +0 -4
- package/dist/core/mounted-mcp.js +1 -1
- package/dist/core/park-noun.d.ts +24 -0
- package/dist/core/park-noun.js +21 -0
- package/dist/core/park-resumability.d.ts +60 -0
- package/dist/core/park-resumability.js +30 -0
- package/dist/core/permission-rule-provider.d.ts +24 -2
- package/dist/core/permission-rule-provider.js +11 -8
- package/dist/core/permission-rule-store.d.ts +8 -1
- package/dist/core/permission-rule-store.js +2 -3
- package/dist/core/permission-rules.d.ts +2 -1
- package/dist/core/permission-rules.js +8 -4
- package/dist/core/persisted-rule-arms.d.ts +3 -0
- package/dist/core/persisted-rule-arms.js +2 -1
- package/dist/core/present-plan-tool.d.ts +47 -3
- package/dist/core/present-plan-tool.js +62 -4
- package/dist/core/principal-name.d.ts +1 -1
- package/dist/core/principal-name.js +5 -5
- package/dist/core/process-identity.js +10 -5
- package/dist/core/protocol-http-auth.d.ts +20 -14
- package/dist/core/protocol-http-auth.js +70 -50
- package/dist/core/read-only-shell.js +9 -5
- package/dist/core/redaction-marks.d.ts +4 -26
- package/dist/core/redaction-marks.js +9 -21
- package/dist/core/remote-env.d.ts +43 -16
- package/dist/core/remote-env.js +1 -1
- package/dist/core/request-copy-projection.d.ts +1 -1
- package/dist/core/request-copy-projection.js +40 -50
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +35 -18
- package/dist/core/resume-startup-cause.js +13 -10
- package/dist/core/retention.d.ts +167 -25
- package/dist/core/retention.js +100 -20
- package/dist/core/roles.d.ts +6 -0
- package/dist/core/roles.js +11 -5
- package/dist/core/rule-lane-reads.d.ts +3 -0
- package/dist/core/rule-lane-reads.js +5 -1
- package/dist/core/rule-store-fault.d.ts +70 -0
- package/dist/core/rule-store-fault.js +102 -0
- package/dist/core/runner/advertised-writable-dirs.js +16 -31
- package/dist/core/runner/announce-once-ledger.d.ts +19 -2
- package/dist/core/runner/announce-once-ledger.js +24 -2
- package/dist/core/runner/assemble-result.d.ts +6 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/auto-strip-notice.d.ts +36 -0
- package/dist/core/runner/auto-strip-notice.js +59 -0
- package/dist/core/runner/branch-window.d.ts +3 -0
- package/dist/core/runner/branch-window.js +37 -0
- package/dist/core/runner/caller-roster.d.ts +8 -3
- package/dist/core/runner/capability-withheld-seat.js +3 -9
- package/dist/core/runner/clock-and-limits.d.ts +22 -1
- package/dist/core/runner/clock-and-limits.js +30 -0
- package/dist/core/runner/contracts.d.ts +58 -35
- package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
- package/dist/core/runner/credential-refusal-seat.js +47 -0
- package/dist/core/runner/cross-boundary-lane.js +6 -4
- package/dist/core/runner/decide-continuation.js +1 -1
- package/dist/core/runner/file-history-restore.d.ts +53 -2
- package/dist/core/runner/file-history-restore.js +29 -10
- package/dist/core/runner/forward-sink.d.ts +14 -1
- package/dist/core/runner/forward-sink.js +14 -12
- package/dist/core/runner/gate-exit.d.ts +8 -7
- package/dist/core/runner/gate-exit.js +13 -13
- package/dist/core/runner/git-status-frame.js +2 -4
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/main-call-account.d.ts +3 -1
- package/dist/core/runner/main-call-account.js +5 -3
- package/dist/core/runner/mcp-redial.d.ts +2 -5
- package/dist/core/runner/mcp-redial.js +2 -2
- package/dist/core/runner/nested-memory-content.d.ts +7 -1
- package/dist/core/runner/nested-memory-content.js +73 -13
- package/dist/core/runner/nested-memory-lane.d.ts +44 -19
- package/dist/core/runner/nested-memory-lane.js +152 -76
- package/dist/core/runner/park-commit.js +3 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
- package/dist/core/runner/permission-rule-lanes.js +29 -3
- package/dist/core/runner/person-path-rows.d.ts +3 -11
- package/dist/core/runner/person-path-rows.js +21 -24
- package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
- package/dist/core/runner/prepare-artifact.d.ts +1 -1
- package/dist/core/runner/prepare-artifact.js +20 -14
- package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
- package/dist/core/runner/prepare-ask-lane.js +6 -5
- package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
- package/dist/core/runner/prepare-boundary-parks.js +27 -24
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -24
- package/dist/core/runner/prepare-config-doors.js +58 -41
- package/dist/core/runner/prepare-context-lane.d.ts +2 -2
- package/dist/core/runner/prepare-context-lane.js +3 -5
- package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
- package/dist/core/runner/prepare-defer-classify.js +1 -1
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +3 -2
- package/dist/core/runner/prepare-file-history.d.ts +62 -26
- package/dist/core/runner/prepare-file-history.js +117 -46
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
- package/dist/core/runner/prepare-gate-stations.js +6 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
- package/dist/core/runner/prepare-hands-readface.js +8 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
- package/dist/core/runner/prepare-inherited-gate.js +6 -6
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +1 -1
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-park-ask.d.ts +10 -3
- package/dist/core/runner/prepare-park-ask.js +7 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
- package/dist/core/runner/prepare-policy-chain.js +18 -13
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +5 -3
- package/dist/core/runner/prepare-prompt-assembly.js +2 -1
- package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
- package/dist/core/runner/prepare-protocol-tools.js +7 -7
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-run-refs.d.ts +7 -2
- package/dist/core/runner/prepare-run-refs.js +8 -7
- package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
- package/dist/core/runner/prepare-suspend-saga.js +4 -3
- package/dist/core/runner/prepare-task.js +66 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
- package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
- package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
- package/dist/core/runner/prepare-turn-wiring.js +1 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
- package/dist/core/runner/prepare-wiring-manifest.js +14 -6
- package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
- package/dist/core/runner/prepare-workspace-restore.js +15 -6
- package/dist/core/runner/remote-env-retry.d.ts +3 -3
- package/dist/core/runner/restore-seat.d.ts +41 -0
- package/dist/core/runner/restore-seat.js +38 -0
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +4 -3
- package/dist/core/runner/resume-checkpoint-screen.js +2 -1
- package/dist/core/runner/resume-internals-and-config.js +2 -1
- package/dist/core/runner/resume-preflight.js +2 -1
- package/dist/core/runner/rewind-files.js +22 -6
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
- package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
- package/dist/core/runner/run-brain-sinks.d.ts +3 -6
- package/dist/core/runner/run-brain-sinks.js +6 -6
- package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +2 -1
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.js +20 -12
- package/dist/core/runner/run-leg.js +31 -72
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -4
- package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
- package/dist/core/runner/run-reasoning-seat.js +13 -18
- package/dist/core/runner/run-settle-and-teardown.js +13 -9
- package/dist/core/runner/run-terminal-adoption.js +4 -8
- package/dist/core/runner/run-turn-boundary.js +6 -3
- package/dist/core/runner/runtask.d.ts +9 -4
- package/dist/core/runner/runtask.js +29 -22
- package/dist/core/runner/session-rule-policy.d.ts +11 -1
- package/dist/core/runner/shell-env-withheld.js +2 -7
- package/dist/core/runner/side-call-account.d.ts +5 -6
- package/dist/core/runner/side-call-account.js +2 -2
- package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
- package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
- package/dist/core/runner/stream-settle-backstop.js +4 -6
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +4 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
- package/dist/core/runner/sub-agent-deny-lists.js +7 -4
- package/dist/core/runner/teardown-bounded.d.ts +7 -0
- package/dist/core/runner/teardown-bounded.js +7 -0
- package/dist/core/runner/terminal-account.js +41 -13
- package/dist/core/runner/terminal-projection.d.ts +1 -5
- package/dist/core/runner/tool-end-body.d.ts +9 -3
- package/dist/core/runner/tool-end-body.js +6 -3
- package/dist/core/runner/tool-output-projection.d.ts +13 -4
- package/dist/core/runner/tool-output-projection.js +10 -14
- package/dist/core/runner/turn-attachments.d.ts +3 -2
- package/dist/core/runner/turn-attachments.js +12 -5
- package/dist/core/runner-deps.d.ts +6 -6
- package/dist/core/runtime-caps.d.ts +2 -1
- package/dist/core/secret-env.d.ts +20 -3
- package/dist/core/secret-env.js +13 -15
- package/dist/core/session-checkout.d.ts +115 -15
- package/dist/core/session-checkout.js +435 -136
- package/dist/core/session-policy-store.js +21 -3
- package/dist/core/session-reconcile.js +1 -0
- package/dist/core/session-store.js +2 -0
- package/dist/core/session.d.ts +11 -1
- package/dist/core/shell-run-candidates.d.ts +1 -0
- package/dist/core/shell-run-candidates.js +1 -1
- package/dist/core/shutdown-debug.d.ts +6 -5
- package/dist/core/shutdown-debug.js +5 -1
- package/dist/core/skill-grant.js +4 -1
- package/dist/core/skills-directory.js +5 -3
- package/dist/core/spec-contract.d.ts +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
- package/dist/core/store-contracts/file-history-store-contract.js +26 -2
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
- package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
- package/dist/core/store-contracts/task-list-store-contract.js +28 -1
- package/dist/core/task-event.d.ts +48 -27
- package/dist/core/task-notification.d.ts +15 -9
- package/dist/core/task-notification.js +12 -0
- package/dist/core/task-registry-agent.d.ts +24 -22
- package/dist/core/task-registry-agent.js +65 -46
- package/dist/core/task-registry-shared.d.ts +17 -5
- package/dist/core/task-registry.d.ts +17 -6
- package/dist/core/task-registry.js +6 -1
- package/dist/core/task-result.d.ts +71 -25
- package/dist/core/task-spec-members.d.ts +0 -1
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +60 -52
- package/dist/core/task-stream.d.ts +45 -12
- package/dist/core/terminal-cause.d.ts +45 -8
- package/dist/core/terminal-cause.js +5 -0
- package/dist/core/tool-card-bound.d.ts +32 -0
- package/dist/core/tool-card-bound.js +33 -0
- package/dist/core/tool-catalog-entries.d.ts +9 -0
- package/dist/core/tool-catalog-entries.js +48 -0
- package/dist/core/tool-errors.d.ts +4 -3
- package/dist/core/tool-face.d.ts +3 -3
- package/dist/core/tool-mount-facts.d.ts +3 -2
- package/dist/core/tool-mount-facts.js +1 -1
- package/dist/core/tool-mount-static.js +7 -5
- package/dist/core/tool-policy.d.ts +21 -19
- package/dist/core/tool-policy.js +5 -6
- package/dist/core/tool-registry.d.ts +3 -1
- package/dist/core/tool-registry.js +15 -1
- package/dist/core/tool-result-store.d.ts +9 -3
- package/dist/core/tool-result-store.js +14 -1
- package/dist/core/tool-roster.d.ts +6 -0
- package/dist/core/tool-roster.js +18 -0
- package/dist/core/tool-spec.d.ts +17 -8
- package/dist/core/trace.d.ts +35 -31
- package/dist/core/types.d.ts +2 -2
- package/dist/core/untrusted-egress.d.ts +10 -9
- package/dist/core/untrusted-egress.js +9 -9
- package/dist/core/untrusted-text.d.ts +0 -18
- package/dist/core/untrusted-text.js +7 -3
- package/dist/core/user-attachment.d.ts +9 -6
- package/dist/core/user-attachment.js +12 -10
- package/dist/core/user-row-origin.d.ts +44 -25
- package/dist/core/user-row-origin.js +30 -20
- package/dist/core/wiring-manifest.d.ts +26 -7
- package/dist/core/wiring-manifest.js +14 -11
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
- package/dist/engine/execution-env/node-execution-env.js +127 -67
- package/dist/engine/harness/agent-harness.d.ts +4 -5
- package/dist/engine/harness/agent-harness.js +2 -7
- package/dist/engine/harness/types.d.ts +51 -19
- package/dist/engine/harness/types.js +28 -1
- package/dist/engine/llm/types.d.ts +26 -14
- package/dist/engine/llm/types.js +2 -2
- package/dist/engine/loop/agent-loop.d.ts +2 -2
- package/dist/engine/loop/agent-loop.js +51 -275
- package/dist/engine/loop/types.d.ts +0 -18
- package/dist/engine/session/import-validate.d.ts +3 -0
- package/dist/engine/session/import-validate.js +34 -2
- package/dist/engine/session/repo-utils.d.ts +42 -4
- package/dist/engine/session/repo-utils.js +33 -5
- package/dist/engine/session/session.d.ts +41 -14
- package/dist/engine/session/session.js +96 -25
- package/dist/index.d.ts +21 -16
- package/dist/index.js +16 -10
- package/dist/orchestration/run-spec.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +12 -9
- package/dist/orchestration/run-workflow-tool.js +15 -19
- package/dist/orchestration/workflow-governance.js +13 -21
- package/dist/orchestration/workflow-observe.d.ts +4 -3
- package/dist/orchestration/workflow-primitives.d.ts +1 -1
- package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
- package/dist/orchestration/workflow-record-artifact.js +32 -0
- package/dist/orchestration/workflow-script-store.d.ts +9 -0
- package/dist/orchestration/workflow-script-store.js +20 -1
- package/dist/orchestration/workflow-types.d.ts +33 -3
- package/dist/orchestration/workflow.d.ts +24 -14
- package/dist/orchestration/workflow.js +52 -23
- package/dist/prompt-assembly/artifact.js +4 -8
- package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
- package/dist/prompt-assembly/catalog/engine.js +30 -0
- package/dist/prompt-assembly/catalog/index.d.ts +1 -1
- package/dist/prompt-assembly/catalog/index.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
- package/dist/prompt-assembly/epoch.js +6 -8
- package/dist/prompt-assembly/turn-snapshot.js +8 -9
- package/dist/stores/file/background-agent-store.js +5 -6
- package/dist/stores/file/checkpoint-store.d.ts +0 -4
- package/dist/stores/file/checkpoint-store.js +7 -3
- package/dist/stores/file/file-history-store.d.ts +8 -0
- package/dist/stores/file/file-history-store.js +72 -0
- package/dist/stores/file/fs-atomic.js +17 -12
- package/dist/stores/file/index.js +11 -5
- package/dist/stores/file/mailbox-store.js +13 -4
- package/dist/stores/file/permission-rule-store.js +14 -13
- package/dist/stores/file/shared-ledger.d.ts +4 -0
- package/dist/stores/file/shared-ledger.js +4 -0
- package/dist/stores/file/task-list-store.js +12 -3
- package/dist/stores/file/workflow-run-store.js +1 -0
- package/dist/tools/fs/bash-program-position.d.ts +4 -2
- package/dist/tools/fs/bash-program-position.js +1 -1
- package/dist/tools/fs/bash-readonly-classifier.js +1 -1
- package/dist/tools/fs/bound-open.d.ts +97 -0
- package/dist/tools/fs/bound-open.js +103 -0
- package/dist/tools/fs/containment-face.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.d.ts +7 -1
- package/dist/tools/fs/fs-pdf.js +31 -23
- package/dist/tools/fs/fs-read.d.ts +24 -17
- package/dist/tools/fs/fs-read.js +84 -53
- package/dist/tools/fs/fs-shared.d.ts +14 -12
- package/dist/tools/fs/fs-shared.js +5 -4
- package/dist/tools/fs/fs-write.d.ts +2 -2
- package/dist/tools/fs/fs-write.js +20 -12
- package/dist/tools/fs/index.d.ts +4 -4
- package/dist/tools/fs/index.js +2 -2
- package/dist/tools/fs/notebook.d.ts +1 -1
- package/dist/tools/fs/pdf.d.ts +12 -3
- package/dist/tools/fs/pdf.js +22 -9
- package/dist/tools/fs/read-deny-home.d.ts +3 -2
- package/dist/tools/fs/read-deny-home.js +8 -11
- package/dist/tools/fs/safety.d.ts +3 -2
- package/dist/tools/fs/shell-read-check.js +10 -9
- package/dist/tools/monitor.d.ts +6 -5
- package/dist/tools/task-list.d.ts +16 -6
- package/dist/tools/task-list.js +4 -0
- package/dist/tools/web.d.ts +9 -1
- package/dist/tools/web.js +8 -3
- package/dist/tools/worktree.d.ts +7 -5
- package/dist/tools/worktree.js +4 -3
- package/package.json +4 -3
- package/test/export-surface.snapshot.json +93 -7
- package/wire-changes/core-stores-sql@7.68.0.json +39 -0
- package/wire-changes/core@7.68.0.json +4257 -0
- package/wire-changes/mods-kernel@7.68.0.json +129 -0
- package/wire-changes/primitives@7.68.0.json +253 -0
- package/wire-changes/wiki-gate@7.68.0.json +39 -0
- package/dist/core/runner/credential-origin-seat.d.ts +0 -2
- package/dist/core/runner/credential-origin-seat.js +0 -20
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { closeSync, constants as fsConstants, copyFileSync, existsSync, fstatSync, fsyncSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync, utimesSync, writeFileSync, writeSync } from "node:fs";
|
|
1
|
+
import { closeSync, constants as fsConstants, copyFileSync, existsSync, fstatSync, fsyncSync, ftruncateSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync, utimesSync, writeFileSync, writeSync } from "node:fs";
|
|
2
2
|
const { O_WRONLY, O_RDONLY, O_CREAT, O_NOFOLLOW, O_NONBLOCK, O_EXCL } = fsConstants;
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
|
-
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
5
|
+
import { basename, dirname, isAbsolute, join, parse, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { MEMORY_GOVERNANCE_DOC_NAMES, MEMORY_ORIGIN_CAUSES } from "./types.js";
|
|
7
7
|
import { parseEntryFile } from "./frontmatter.js";
|
|
8
8
|
import { openExclusiveTemp } from "../exclusive-temp.js";
|
|
9
9
|
import { physicalPathOf, physicalPathOfExisting, priorCallerCasedPathOf } from "../physical-path.js";
|
|
10
|
+
import { anchorAtLinkDir } from "../../engine/execution-env/symlink-chain.js";
|
|
10
11
|
import { sensitiveRowOf } from "../sensitive-path-policy.js";
|
|
11
|
-
import { thrownLabel, thrownText } from "../thrown-value.js";
|
|
12
|
+
import { readMember, thrownLabel, thrownText } from "../thrown-value.js";
|
|
12
13
|
import { egressText } from "../untrusted-egress.js";
|
|
13
14
|
import { optionKeys, receiveMembers } from "../own-property-receipt.js";
|
|
14
|
-
const REANCHOR_OPTION_KEYS = optionKeys()({ controlDir: 0, onIncident: 0 });
|
|
15
|
+
const REANCHOR_OPTION_KEYS = optionKeys()({ controlDir: 0, expectedFrom: 0, onIncident: 0 });
|
|
15
16
|
const ANNOUNCEMENT_OPTION_KEYS = optionKeys()({ supersedesPrefix: 0 });
|
|
16
17
|
const SCOPES_FILE = "scopes.json";
|
|
17
18
|
export const CURSORS_FILE = "cursors.json";
|
|
@@ -191,6 +192,214 @@ export function lookupProjectIdHint(configRoot, repoRoot) {
|
|
|
191
192
|
export function deriveControlPlaneDir(configRoot, key) {
|
|
192
193
|
return join(configRoot, deriveDirKey(key), CONTROL_PLANE_DIR);
|
|
193
194
|
}
|
|
195
|
+
function pathUnderRoot(root, dir) {
|
|
196
|
+
const rel = relative(resolve(root), resolve(dir));
|
|
197
|
+
return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel) ? rel : undefined;
|
|
198
|
+
}
|
|
199
|
+
function adoptPlaneMovedWithRoot(configRoot, dir) {
|
|
200
|
+
const rel = pathUnderRoot(configRoot, dir);
|
|
201
|
+
if (rel === undefined)
|
|
202
|
+
return;
|
|
203
|
+
const toDir = deriveControlPlaneDir(configRoot, dir);
|
|
204
|
+
const travelled = planesTravelledWith(configRoot, dir, rel, toDir);
|
|
205
|
+
if (travelled.length === 0)
|
|
206
|
+
return;
|
|
207
|
+
if (travelled.length > 1)
|
|
208
|
+
throw controlPlaneSplitRefusal(dir, { planes: travelled.map(planeKeyOf), documents: [] });
|
|
209
|
+
const fromDir = travelled[0];
|
|
210
|
+
assertStoreRootsNotSensitive(dir, toDir);
|
|
211
|
+
if (moveWholePlane(fromDir, toDir))
|
|
212
|
+
return;
|
|
213
|
+
mergeTravelledPlane(dir, fromDir, toDir);
|
|
214
|
+
}
|
|
215
|
+
function planeKeyOf(controlDir) {
|
|
216
|
+
return basename(dirname(controlDir));
|
|
217
|
+
}
|
|
218
|
+
function planesTravelledWith(configRoot, dir, rel, toDir) {
|
|
219
|
+
const tail = slugifyPath(`${sep}${rel}`);
|
|
220
|
+
let keys;
|
|
221
|
+
try {
|
|
222
|
+
keys = readdirSync(configRoot);
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
if (err.code === "ENOENT")
|
|
226
|
+
return [];
|
|
227
|
+
throw new ControlPlaneCorruptError(`the memory engine root ${configRoot} could not be listed (${err.code ?? thrownLabel(err)}) — whether the control plane of ${dir} travelled there with a moved root cannot be established, so the store was not opened`, { cause: err });
|
|
228
|
+
}
|
|
229
|
+
const found = [];
|
|
230
|
+
for (const key of keys) {
|
|
231
|
+
if (key === planeKeyOf(toDir) || !key.endsWith(tail))
|
|
232
|
+
continue;
|
|
233
|
+
const plane = join(configRoot, key, CONTROL_PLANE_DIR);
|
|
234
|
+
let anchor;
|
|
235
|
+
try {
|
|
236
|
+
const st = lstatOrAbsent(plane);
|
|
237
|
+
if (st === undefined || !st.isDirectory())
|
|
238
|
+
continue;
|
|
239
|
+
anchor = readStoreRootAnchor(plane, dir);
|
|
240
|
+
}
|
|
241
|
+
catch (err) {
|
|
242
|
+
if (err.code === "ENOTDIR")
|
|
243
|
+
continue;
|
|
244
|
+
throw new ControlPlaneCorruptError(`the memory control plane ${key} under the engine root ${configRoot} may have travelled there for ${dir}, but it cannot be read (${err instanceof ControlPlaneCorruptError ? "its root anchor is damaged or unreadable" : (err.code ?? thrownLabel(err))}) — whether it holds this store's records (capture opt-outs among them) cannot be established, so the store was not opened; repair or remove that plane's root anchor, then reopen`, { cause: err });
|
|
245
|
+
}
|
|
246
|
+
if (anchor === undefined)
|
|
247
|
+
continue;
|
|
248
|
+
const had = resolve(anchor.spelling);
|
|
249
|
+
if (deriveDirKey(had) !== key || !had.endsWith(`${sep}${rel}`))
|
|
250
|
+
continue;
|
|
251
|
+
const wasUnder = [had.slice(0, had.length - rel.length - 1)];
|
|
252
|
+
if (anchor.realpath.endsWith(`${sep}${rel}`))
|
|
253
|
+
wasUnder.push(anchor.realpath.slice(0, anchor.realpath.length - rel.length - 1));
|
|
254
|
+
if ([anchor.realpath, had, ...wasUnder].every(nothingStandsAt))
|
|
255
|
+
found.push(plane);
|
|
256
|
+
}
|
|
257
|
+
return found.sort();
|
|
258
|
+
}
|
|
259
|
+
function moveWholePlane(fromDir, toDir) {
|
|
260
|
+
const held = () => existsSync(toDir) && subtreeHasFiles(toDir);
|
|
261
|
+
try {
|
|
262
|
+
if (!held()) {
|
|
263
|
+
ensureDirExists(dirname(toDir));
|
|
264
|
+
let outcome = tryAdoptByRename(fromDir, toDir);
|
|
265
|
+
if (!outcome.ok && (outcome.code === "EEXIST" || outcome.code === "ENOTEMPTY") && !subtreeHasFiles(toDir) && pruneFilelessDirTree(toDir)) {
|
|
266
|
+
outcome = tryAdoptByRename(fromDir, toDir);
|
|
267
|
+
}
|
|
268
|
+
if (!outcome.ok && !nothingStandsAt(fromDir) && !held())
|
|
269
|
+
throw travelledPlaneRefusal(fromDir, toDir, outcome.code ?? thrownLabel(outcome.error), outcome.error);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
throw err instanceof ControlPlaneCorruptError ? err : travelledPlaneRefusal(fromDir, toDir, err.code ?? thrownLabel(err), err);
|
|
274
|
+
}
|
|
275
|
+
if (!nothingStandsAt(fromDir))
|
|
276
|
+
return false;
|
|
277
|
+
removeEmptyKeyDir(fromDir);
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
function removeEmptyKeyDir(fromDir) {
|
|
281
|
+
try {
|
|
282
|
+
rmdirSync(dirname(fromDir));
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function travelledPlaneRefusal(fromDir, toDir, why, cause) {
|
|
288
|
+
return new ControlPlaneCorruptError(`the memory control plane that moved with the engine root (${fromDir}) could not be moved to ${toDir}, where the store's directory is keyed now (${why}) — a new one opened there would drop what it records (capture opt-outs, the ledger, quarantine), so the store was not opened; move the directory by hand while nothing has the store open, then reopen`, { cause });
|
|
289
|
+
}
|
|
290
|
+
function heldThere(src, dst) {
|
|
291
|
+
const there = lstatOrAbsent(dst);
|
|
292
|
+
if (there === undefined)
|
|
293
|
+
return "absent";
|
|
294
|
+
const here = lstatOrAbsent(src);
|
|
295
|
+
if (here === undefined)
|
|
296
|
+
return "same";
|
|
297
|
+
return here.isFile() && there.isFile() && readFileSync(src).equals(readFileSync(dst)) ? "same" : "differs";
|
|
298
|
+
}
|
|
299
|
+
function bringOver(fromDir, toDir, rel) {
|
|
300
|
+
const src = join(fromDir, rel);
|
|
301
|
+
const dst = join(toDir, rel);
|
|
302
|
+
try {
|
|
303
|
+
const here = lstatOrAbsent(src);
|
|
304
|
+
if (here === undefined)
|
|
305
|
+
return "same";
|
|
306
|
+
if (!here.isFile())
|
|
307
|
+
return "differs";
|
|
308
|
+
ensureDirExists(dirname(dst));
|
|
309
|
+
try {
|
|
310
|
+
linkSync(src, dst);
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
if (err.code === "ENOENT" && nothingStandsAt(src))
|
|
314
|
+
return "same";
|
|
315
|
+
if (err.code !== "EEXIST")
|
|
316
|
+
throw err;
|
|
317
|
+
const held = heldThere(src, dst);
|
|
318
|
+
if (held === "differs")
|
|
319
|
+
return held;
|
|
320
|
+
}
|
|
321
|
+
rmSync(src, { force: true });
|
|
322
|
+
return "absent";
|
|
323
|
+
}
|
|
324
|
+
catch (err) {
|
|
325
|
+
throw travelledPlaneRefusal(fromDir, toDir, `${rel}: ${err.code ?? thrownLabel(err)}`, err);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function isOneTimeRecord(rel) {
|
|
329
|
+
if (rel.length === 1)
|
|
330
|
+
return rel[0] === STORE_IDENTITY_FILE;
|
|
331
|
+
return rel.length === 2 && Object.values(FILE_CONTROL_OBJECT_DIRS).includes(rel[0]);
|
|
332
|
+
}
|
|
333
|
+
function isTransientControlEntry(rel) {
|
|
334
|
+
const [top] = rel;
|
|
335
|
+
if (top === undefined)
|
|
336
|
+
return false;
|
|
337
|
+
if (rel.length === 1)
|
|
338
|
+
return top.startsWith(ATOMIC_WRITE_TMP_PREFIX) || top.startsWith(LINK_PROBE_PREFIX);
|
|
339
|
+
return isTransientControlDir(top);
|
|
340
|
+
}
|
|
341
|
+
function isTransientControlDir(name) {
|
|
342
|
+
return name === CONTROL_OBJECT_STAGE_DIR || name.endsWith(".lock") || name.includes(`.lock${LOCK_TOMB_INFIX}`);
|
|
343
|
+
}
|
|
344
|
+
function controlPlaneItems(dir, under = []) {
|
|
345
|
+
const out = [];
|
|
346
|
+
for (const e of readdirSync(join(dir, ...under), { withFileTypes: true }).sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {
|
|
347
|
+
if (e.isDirectory())
|
|
348
|
+
out.push(...controlPlaneItems(dir, [...under, e.name]));
|
|
349
|
+
else
|
|
350
|
+
out.push([...under, e.name]);
|
|
351
|
+
}
|
|
352
|
+
return out;
|
|
353
|
+
}
|
|
354
|
+
function mergeTravelledPlane(dir, fromDir, toDir) {
|
|
355
|
+
let items;
|
|
356
|
+
try {
|
|
357
|
+
items = controlPlaneItems(fromDir).filter((rel) => !isTransientControlEntry(rel) && !(rel.length === 1 && rel[0] === ROOT_ANCHOR_FILE));
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
if (nothingStandsAt(fromDir))
|
|
361
|
+
return;
|
|
362
|
+
throw travelledPlaneRefusal(fromDir, toDir, err.code ?? thrownLabel(err), err);
|
|
363
|
+
}
|
|
364
|
+
const split = [];
|
|
365
|
+
for (const rel of items.filter(isOneTimeRecord))
|
|
366
|
+
if (bringOver(fromDir, toDir, join(...rel)) === "differs")
|
|
367
|
+
split.push(join(...rel));
|
|
368
|
+
const rest = items.filter((rel) => !isOneTimeRecord(rel)).map((rel) => join(...rel));
|
|
369
|
+
for (const rel of rest) {
|
|
370
|
+
let held;
|
|
371
|
+
try {
|
|
372
|
+
held = heldThere(join(fromDir, rel), join(toDir, rel));
|
|
373
|
+
}
|
|
374
|
+
catch (err) {
|
|
375
|
+
throw travelledPlaneRefusal(fromDir, toDir, `${rel}: ${err.code ?? thrownLabel(err)}`, err);
|
|
376
|
+
}
|
|
377
|
+
if (held === "differs")
|
|
378
|
+
split.push(rel);
|
|
379
|
+
}
|
|
380
|
+
if (split.length > 0)
|
|
381
|
+
throw controlPlaneSplitRefusal(dir, { planes: [planeKeyOf(toDir), planeKeyOf(fromDir)], documents: split.sort() });
|
|
382
|
+
for (const rel of rest)
|
|
383
|
+
if (bringOver(fromDir, toDir, rel) === "differs")
|
|
384
|
+
throw controlPlaneSplitRefusal(dir, { planes: [planeKeyOf(toDir), planeKeyOf(fromDir)], documents: [rel] });
|
|
385
|
+
try {
|
|
386
|
+
renameSync(join(fromDir, ROOT_ANCHOR_FILE), join(toDir, ROOT_ANCHOR_FILE));
|
|
387
|
+
}
|
|
388
|
+
catch (err) {
|
|
389
|
+
if (err.code !== "ENOENT")
|
|
390
|
+
throw travelledPlaneRefusal(fromDir, toDir, `${ROOT_ANCHOR_FILE}: ${err.code ?? thrownLabel(err)}`, err);
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
for (const e of readdirSync(fromDir, { withFileTypes: true })) {
|
|
394
|
+
if (e.isDirectory() ? isTransientControlDir(e.name) : isTransientControlEntry([e.name]))
|
|
395
|
+
rmSync(join(fromDir, e.name), { recursive: true, force: true });
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
catch {
|
|
399
|
+
}
|
|
400
|
+
pruneFilelessDirTree(fromDir);
|
|
401
|
+
removeEmptyKeyDir(fromDir);
|
|
402
|
+
}
|
|
194
403
|
export function deriveRepoControlPlaneDir(configRoot, repoRoot) {
|
|
195
404
|
return join(configRoot, deriveRepoKey(repoRoot), CONTROL_PLANE_DIR);
|
|
196
405
|
}
|
|
@@ -198,12 +407,17 @@ export function effectiveControlRootOf(dir, opts = {}) {
|
|
|
198
407
|
const pinned = opts.pinnedBy?.controlPlaneRoot;
|
|
199
408
|
if (typeof pinned === "string" && pinned !== "")
|
|
200
409
|
return pinned;
|
|
201
|
-
if (opts.controlDir !== undefined)
|
|
410
|
+
if (opts.controlDir !== undefined) {
|
|
411
|
+
const configRoot = dirname(dirname(opts.controlDir));
|
|
412
|
+
if (deriveControlPlaneDir(configRoot, dir) === opts.controlDir)
|
|
413
|
+
adoptPlaneMovedWithRoot(configRoot, dir);
|
|
202
414
|
return opts.controlDir;
|
|
415
|
+
}
|
|
203
416
|
const configRoot = resolveMemoryEngineRoot();
|
|
204
417
|
const control = deriveControlPlaneDir(configRoot, dir);
|
|
205
418
|
assertStoreRootsNotSensitive(dir, control);
|
|
206
419
|
adoptCanonicalKeyedControlDir(configRoot, dir, opts.onIncident);
|
|
420
|
+
adoptPlaneMovedWithRoot(configRoot, dir);
|
|
207
421
|
return control;
|
|
208
422
|
}
|
|
209
423
|
export function resolveMemoryEngineRoot(explicit) {
|
|
@@ -753,18 +967,20 @@ export function isContainedIn(root, child) {
|
|
|
753
967
|
const c = canonicalize(child);
|
|
754
968
|
return c === r || c.startsWith(`${r}${sep}`);
|
|
755
969
|
}
|
|
756
|
-
export const STORE_FORM_REFUSAL_CODES = Object.freeze(["memory.target_outside_store", "memory.scope_home_not_directory", "memory.control_plane_links_unsupported", "memory.control_plane_strays", "memory.store_root_sensitive"]);
|
|
970
|
+
export const STORE_FORM_REFUSAL_CODES = Object.freeze(["memory.target_outside_store", "memory.scope_home_not_directory", "memory.control_plane_links_unsupported", "memory.control_plane_strays", "memory.store_root_sensitive", "memory.control_plane_split"]);
|
|
757
971
|
export const TARGET_OUTSIDE_STORE = "memory.target_outside_store";
|
|
758
972
|
export const SCOPE_HOME_NOT_DIRECTORY = "memory.scope_home_not_directory";
|
|
759
973
|
export const CONTROL_PLANE_LINKS_UNSUPPORTED = "memory.control_plane_links_unsupported";
|
|
760
974
|
export const CONTROL_PLANE_STRAYS = "memory.control_plane_strays";
|
|
761
975
|
export const STORE_ROOT_SENSITIVE = "memory.store_root_sensitive";
|
|
976
|
+
export const CONTROL_PLANE_SPLIT = "memory.control_plane_split";
|
|
762
977
|
export const SCOPE_HOME_FORMS = Object.freeze(["symlink", "file", "other"]);
|
|
763
978
|
const SCOPE_HOME_FORM_PHRASE = {
|
|
764
979
|
symlink: "a symbolic link",
|
|
765
980
|
file: "a regular file",
|
|
766
981
|
other: "a special file",
|
|
767
982
|
};
|
|
983
|
+
export const TARGET_OUTSIDE_STORE_REASONS = Object.freeze(["act_outside", "root_moved", "root_gone", "root_reanchored"]);
|
|
768
984
|
const STORE_ROOT_WORDS = {
|
|
769
985
|
store: { what: "memory store root", remedy: "point the memory engine root (memoryEngineDir, or the file backend's directory) at a directory outside it" },
|
|
770
986
|
control_plane: { what: "memory control plane", remedy: "point the data root (AGENT_DATA_DIR, or the backend's controlDir) at a directory outside it" },
|
|
@@ -776,14 +992,27 @@ function storeFormRefusal(code, sentence, detail) {
|
|
|
776
992
|
e.detail = detail;
|
|
777
993
|
return e;
|
|
778
994
|
}
|
|
995
|
+
export function storeFormRefusalReadingOf(thrown) {
|
|
996
|
+
const code = readMember(thrown, "code");
|
|
997
|
+
if (typeof code !== "string" || !STORE_FORM_REFUSAL_CODES.includes(code))
|
|
998
|
+
return undefined;
|
|
999
|
+
if (code !== TARGET_OUTSIDE_STORE)
|
|
1000
|
+
return { code: code };
|
|
1001
|
+
const outsideReason = readMember(readMember(thrown, "detail"), "outsideReason");
|
|
1002
|
+
return typeof outsideReason === "string" && TARGET_OUTSIDE_STORE_REASONS.includes(outsideReason) ? { code, outsideReason: outsideReason } : undefined;
|
|
1003
|
+
}
|
|
779
1004
|
export function storeActRefusal(act, path) {
|
|
780
|
-
return storeFormRefusal(TARGET_OUTSIDE_STORE, `${act} was refused — its directory resolves outside the store root; not performed`, { path });
|
|
1005
|
+
return storeFormRefusal(TARGET_OUTSIDE_STORE, `${act} was refused — its directory resolves outside the store root; not performed`, { path, outsideReason: "act_outside" });
|
|
781
1006
|
}
|
|
1007
|
+
const PERSONAL_STORE_DIRS = "for a deployment's personal store, `personal/memory` and `personal/.engine` under the memory engine root";
|
|
782
1008
|
export function storeRootMovedRefusal(path, anchor) {
|
|
783
|
-
return storeFormRefusal(TARGET_OUTSIDE_STORE,
|
|
1009
|
+
return storeFormRefusal(TARGET_OUTSIDE_STORE, `the store root now resolves to a different directory than the one its control plane records, and the store holds memory — refused, nothing in the store was written; put the directory back where it was, or, if the store was moved on purpose, re-anchor it where it is now: call reanchorMemoryStoreRoot with the store's directory and { controlDir: its control plane directory } (${PERSONAL_STORE_DIRS}), then reopen`, { path, outsideReason: "root_moved", controlDir: anchor.controlDir, recorded: anchor.recorded, now: anchor.now });
|
|
1010
|
+
}
|
|
1011
|
+
export function storeRootReanchoredRefusal(path, anchor) {
|
|
1012
|
+
return storeFormRefusal(TARGET_OUTSIDE_STORE, `the store is anchored to another directory than the one this session opened it at — refused, nothing in the store was written; the store needs nothing: open a new session, which opens the store where it is anchored now`, { path, outsideReason: "root_reanchored", controlDir: anchor.controlDir, recorded: anchor.recorded, now: anchor.now });
|
|
784
1013
|
}
|
|
785
1014
|
export function storeRootAbsentRefusal(path, anchor) {
|
|
786
|
-
return storeFormRefusal(TARGET_OUTSIDE_STORE,
|
|
1015
|
+
return storeFormRefusal(TARGET_OUTSIDE_STORE, `the store root no longer exists where its control plane records it — refused, nothing in the store was written; put the directory back, or, if the store was moved on purpose, call reanchorMemoryStoreRoot with its new directory and { controlDir: its control plane directory }; to start over in place, create the directory again and call reanchorMemoryStoreRoot with it and the same control plane directory; then reopen (${PERSONAL_STORE_DIRS})`, { path, outsideReason: "root_gone", controlDir: anchor.controlDir, recorded: anchor.recorded, now: anchor.now });
|
|
787
1016
|
}
|
|
788
1017
|
export function scopeHomeRefusal(form, path) {
|
|
789
1018
|
return storeFormRefusal(SCOPE_HOME_NOT_DIRECTORY, `a scope home must be a real directory, but this one is ${SCOPE_HOME_FORM_PHRASE[form]} — refused (fail-closed); put the real directory back`, { path, form });
|
|
@@ -797,12 +1026,25 @@ export function storeRootSensitiveRefusal(of, path, row) {
|
|
|
797
1026
|
}
|
|
798
1027
|
export function controlPlaneStraysRefusal(path, strays) {
|
|
799
1028
|
const named = [...strays.docs.map((d) => `the ${d} document`), ...Object.entries(strays.objects).map(([kind, n]) => `${n} ${kind} entr${n === 1 ? "y" : "ies"}`)];
|
|
800
|
-
return storeFormRefusal(CONTROL_PLANE_STRAYS, `the memory backend carries its own governance store, and the engine's control plane still holds that store's records from before (${named.join(", ")}) — they would be read by nobody, so the engine is not opened and nothing was written; adopt them into the carrier first (adoptReplicaControlPlane
|
|
1029
|
+
return storeFormRefusal(CONTROL_PLANE_STRAYS, `the memory backend carries its own governance store, and the engine's control plane still holds that store's records from before (${named.join(", ")}) — they would be read by nobody, so the engine is not opened and nothing was written; adopt them into the carrier first (call adoptReplicaControlPlane with the engine's control plane directory and the backend's governance store; it removes each record it hands over), then reopen`, { path });
|
|
1030
|
+
}
|
|
1031
|
+
export function controlPlaneSplitRefusal(path, split) {
|
|
1032
|
+
const sentence = split.documents.length === 0
|
|
1033
|
+
? `more than one control plane under the memory engine root records this store under a path it had before the engine root moved (the directories ${split.planes.join(", ")}) — refused, nothing was moved; keep the one that holds the store's records, remove the others while nothing has the store open, then reopen`
|
|
1034
|
+
: `this store's control plane stands in two places since the engine root moved — the directory ${split.planes[0]}, at its key now, and ${split.planes[1]}, under the path it had — and both hold ${split.documents.join(", ")} with different contents — refused; the records written once that are not named (capture opt-outs among them) were brought over already, nothing else was moved; for each record named, keep the one you want in ${split.planes[0]} and remove the other from ${split.planes[1]}, then reopen`;
|
|
1035
|
+
return storeFormRefusal(CONTROL_PLANE_SPLIT, sentence, { path });
|
|
801
1036
|
}
|
|
802
1037
|
export function landingPathOf(p) {
|
|
803
1038
|
return landingPathWithin(resolve(p), 0);
|
|
804
1039
|
}
|
|
805
1040
|
const MAX_LANDING_LINK_HOPS = 40;
|
|
1041
|
+
function withoutTrailingSeparators(p) {
|
|
1042
|
+
const floor = parse(p).root.length;
|
|
1043
|
+
let end = p.length;
|
|
1044
|
+
while (end > floor && (p[end - 1] === "/" || (sep === "\\" && p[end - 1] === "\\")))
|
|
1045
|
+
end--;
|
|
1046
|
+
return p.slice(0, end);
|
|
1047
|
+
}
|
|
806
1048
|
function landingPathWithin(normalized, hops) {
|
|
807
1049
|
try {
|
|
808
1050
|
return physicalPathOf(normalized);
|
|
@@ -820,14 +1062,22 @@ function landingPathWithin(normalized, hops) {
|
|
|
820
1062
|
e.code = "ELOOP";
|
|
821
1063
|
throw e;
|
|
822
1064
|
}
|
|
823
|
-
|
|
1065
|
+
const target = withoutTrailingSeparators(readlinkSync(cur));
|
|
1066
|
+
const anchored = isAbsolute(target) ? target : anchorAtLinkDir(dirname(cur), target, sep);
|
|
1067
|
+
return landingPathWithin([...tail].reverse().reduce((at, part) => anchorAtLinkDir(at, part, sep), anchored), hops + 1);
|
|
824
1068
|
}
|
|
825
1069
|
if (st !== undefined)
|
|
826
|
-
return
|
|
1070
|
+
return join(physicalPathOf(cur), ...[...tail].reverse());
|
|
827
1071
|
const parent = dirname(cur);
|
|
828
1072
|
if (parent === cur)
|
|
829
1073
|
return normalized;
|
|
830
|
-
|
|
1074
|
+
const name = basename(cur);
|
|
1075
|
+
if (name === ".." || name === ".") {
|
|
1076
|
+
const e = new Error(`ENOENT: no such file or directory, resolving ${normalized}`);
|
|
1077
|
+
e.code = "ENOENT";
|
|
1078
|
+
throw e;
|
|
1079
|
+
}
|
|
1080
|
+
tail.push(name);
|
|
831
1081
|
cur = parent;
|
|
832
1082
|
}
|
|
833
1083
|
}
|
|
@@ -895,10 +1145,22 @@ function readStoreRootAnchor(controlDir, dir) {
|
|
|
895
1145
|
function controlPlaneHoldsStore(controlDir) {
|
|
896
1146
|
return lstatOrAbsent(join(controlDir, SCOPES_FILE)) !== undefined || lstatOrAbsent(join(controlDir, LEDGER_FILE)) !== undefined;
|
|
897
1147
|
}
|
|
1148
|
+
const ANCHOR_GUARDS_NOTHING = Symbol("anchor guards nothing");
|
|
1149
|
+
function nothingStandsAt(path) {
|
|
1150
|
+
try {
|
|
1151
|
+
return lstatOrAbsent(path) === undefined;
|
|
1152
|
+
}
|
|
1153
|
+
catch {
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
898
1157
|
function judgeAgainstAnchor(dir, controlDir, anchor) {
|
|
899
1158
|
const now = landingPathOf(dir);
|
|
900
|
-
if (now !== anchor.realpath)
|
|
1159
|
+
if (now !== anchor.realpath) {
|
|
1160
|
+
if (!storeHoldsRecord(dir, controlDir) && nothingStandsAt(anchor.realpath))
|
|
1161
|
+
return ANCHOR_GUARDS_NOTHING;
|
|
901
1162
|
throw storeRootMovedRefusal(dir, { controlDir, recorded: anchor.realpath, now });
|
|
1163
|
+
}
|
|
902
1164
|
if (lstatOrAbsent(now) === undefined && controlPlaneHoldsStore(controlDir))
|
|
903
1165
|
throw storeRootAbsentRefusal(dir, { controlDir, recorded: anchor.realpath, now });
|
|
904
1166
|
return now;
|
|
@@ -927,24 +1189,33 @@ export function assertStoreRootsNotSensitive(dir, controlDir) {
|
|
|
927
1189
|
export function anchorStoreRoot(dir, controlDir, opts = {}) {
|
|
928
1190
|
assertStoreRootsNotSensitive(dir, controlDir);
|
|
929
1191
|
const anchor = readStoreRootAnchor(controlDir, dir);
|
|
930
|
-
|
|
931
|
-
|
|
1192
|
+
const judged = anchor !== undefined ? judgeAgainstAnchor(dir, controlDir, anchor) : undefined;
|
|
1193
|
+
if (typeof judged === "string")
|
|
1194
|
+
return judged;
|
|
932
1195
|
ensureDirExists(controlDir);
|
|
933
1196
|
const lock = join(controlDir, `${ROOT_ANCHOR_FILE}.lock`);
|
|
934
1197
|
const token = acquireSidecarLock(lock, { onDeadline: "throw" });
|
|
935
1198
|
try {
|
|
936
1199
|
const raced = readStoreRootAnchor(controlDir, dir);
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1200
|
+
const racedJudged = raced !== undefined ? judgeAgainstAnchor(dir, controlDir, raced) : undefined;
|
|
1201
|
+
if (typeof racedJudged === "string")
|
|
1202
|
+
return racedJudged;
|
|
1203
|
+
const reading = raced !== undefined ? "rerecord" : absentAnchorReading(controlPlaneHoldsStore(controlDir));
|
|
940
1204
|
if (reading === "refuse")
|
|
941
1205
|
throw damagedAnchorError(controlDir, dir, "absent, while the control plane holds a store");
|
|
1206
|
+
const overMemory = reading === "record" && treeHoldsRecord(dir, "memory");
|
|
942
1207
|
ensureDirExists(dir);
|
|
943
1208
|
const realpath = landingPathOf(dir);
|
|
944
1209
|
writeStoreRootAnchor(controlDir, lock, token, { v: 1, realpath, spelling: dir, recordedAt: (opts.now ?? Date.now)() });
|
|
945
1210
|
if (reading === "backfill") {
|
|
946
1211
|
discloseLayoutIncident(opts.onIncident, "memory.root_anchor_backfilled", `memory store root anchor recorded for a store that had none: ${dir} resolves to ${realpath} (control plane ${controlDir}) — from now on the store opens only there; where the root resolved before this open cannot be told`);
|
|
947
1212
|
}
|
|
1213
|
+
else if (reading === "rerecord") {
|
|
1214
|
+
discloseLayoutIncident(opts.onIncident, "memory.root_anchor_rerecorded", `memory store root anchor recorded again: ${dir} now resolves to ${realpath}, not to ${raced?.realpath ?? "(unreadable)"} its control plane ${controlDir} had recorded; nothing stands at the old root any more and the store held no memory — only what opening or reading it leaves — so there was nothing to guard; from now on the store opens at ${realpath}`);
|
|
1215
|
+
}
|
|
1216
|
+
else if (overMemory) {
|
|
1217
|
+
discloseLayoutIncident(opts.onIncident, "memory.control_plane_new_over_memory", `memory store opened for the first time over a directory that already holds memory (${dir}); what the engine keeps beside it — capture opt-outs, the ledger of committed entries, quarantined files — starts empty at ${controlDir}. If the directory was copied or cloned here, nothing needs doing. If it was moved here or its configured path changed, what was kept beside it before is still under the memory engine root, in the folder named after its earlier path, and is not read: to keep it, capture opt-outs included, stop the service, replace ${controlDir} with that folder's .engine directory, and start again`);
|
|
1218
|
+
}
|
|
948
1219
|
return realpath;
|
|
949
1220
|
}
|
|
950
1221
|
finally {
|
|
@@ -1169,11 +1440,18 @@ export async function reanchorMemoryStoreRoot(dir, opts = {}) {
|
|
|
1169
1440
|
try {
|
|
1170
1441
|
const token = acquireSidecarLock(lock, { onDeadline: "throw" });
|
|
1171
1442
|
try {
|
|
1443
|
+
let unreadable = false;
|
|
1172
1444
|
try {
|
|
1173
1445
|
from = readStoreRootAnchor(controlDir, dir)?.realpath;
|
|
1174
1446
|
}
|
|
1175
1447
|
catch {
|
|
1176
1448
|
from = undefined;
|
|
1449
|
+
unreadable = true;
|
|
1450
|
+
}
|
|
1451
|
+
if (o.expectedFrom !== undefined && from !== o.expectedFrom) {
|
|
1452
|
+
throw reanchorRefusal(from !== undefined
|
|
1453
|
+
? `the store's anchor records ${from}, not ${o.expectedFrom} — the root you confirmed is not the one recorded, so nothing was recorded; read the store's refusal again and confirm the root it names (control plane ${controlDir})`
|
|
1454
|
+
: `the store's anchor ${unreadable ? "cannot be read" : "is absent"}, so it cannot be shown to record ${o.expectedFrom} — nothing was recorded; to replace a damaged anchor, call reanchorMemoryStoreRoot without expectedFrom (control plane ${controlDir})`);
|
|
1177
1455
|
}
|
|
1178
1456
|
try {
|
|
1179
1457
|
assertStoreTxnLockOwnership(controlDir, txn.token);
|
|
@@ -1343,10 +1621,10 @@ function readForVerification(path, maxBytes) {
|
|
|
1343
1621
|
closeSync(fd);
|
|
1344
1622
|
}
|
|
1345
1623
|
}
|
|
1346
|
-
export function restoreContainedBaseline(path, committed, leftOnPlane) {
|
|
1624
|
+
export function restoreContainedBaseline(path, committed, leftOnPlane, mode) {
|
|
1347
1625
|
try {
|
|
1348
1626
|
if (leftOnPlane === undefined || readForVerification(path, Buffer.byteLength(leftOnPlane) + 1) !== leftOnPlane) {
|
|
1349
|
-
return writeFileNoReplace(path, committed);
|
|
1627
|
+
return writeFileNoReplace(path, committed, mode);
|
|
1350
1628
|
}
|
|
1351
1629
|
writeFileNoFollow(path, committed);
|
|
1352
1630
|
return "written";
|
|
@@ -1528,8 +1806,34 @@ export async function keepCopiesBeforeOverwrite(text, keep, reread) {
|
|
|
1528
1806
|
export const ATOMIC_WRITE_TMP_PREFIX = ".tmp-";
|
|
1529
1807
|
export const LINK_PROBE_PREFIX = ".link-probe-";
|
|
1530
1808
|
export const LOCK_TOMB_INFIX = ".stale-";
|
|
1809
|
+
export const STORE_IDENTITY_FILE = "store-identity.json";
|
|
1810
|
+
export function readStoreIdentity(controlDir) {
|
|
1811
|
+
const path = join(controlDir, STORE_IDENTITY_FILE);
|
|
1812
|
+
let raw;
|
|
1813
|
+
try {
|
|
1814
|
+
raw = readFileSync(path, "utf8");
|
|
1815
|
+
}
|
|
1816
|
+
catch (err) {
|
|
1817
|
+
const code = err.code;
|
|
1818
|
+
if (code === "ENOENT")
|
|
1819
|
+
return undefined;
|
|
1820
|
+
throw new ControlPlaneCorruptError(`store identity could not be read (${code ?? "io error"}) at ${path} — a read failure is not absence (fail-closed); fix the filesystem fault and retry`, { cause: err });
|
|
1821
|
+
}
|
|
1822
|
+
let parsed;
|
|
1823
|
+
try {
|
|
1824
|
+
parsed = JSON.parse(raw);
|
|
1825
|
+
}
|
|
1826
|
+
catch {
|
|
1827
|
+
throw new ControlPlaneCorruptError(`store identity is unparseable: ${path}`);
|
|
1828
|
+
}
|
|
1829
|
+
const rec = parsed;
|
|
1830
|
+
if (!rec || typeof rec !== "object" || rec.v !== 1 || typeof rec.storeId !== "string" || rec.storeId.length === 0) {
|
|
1831
|
+
throw new ControlPlaneCorruptError(`store identity has the wrong shape: ${path}`);
|
|
1832
|
+
}
|
|
1833
|
+
return rec.storeId;
|
|
1834
|
+
}
|
|
1531
1835
|
export const STORE_OPEN_ARTIFACTS = Object.freeze({
|
|
1532
|
-
files: Object.freeze([ROOT_ANCHOR_FILE, SCOPES_FILE, `${SCOPES_FILE}.journal
|
|
1836
|
+
files: Object.freeze([ROOT_ANCHOR_FILE, SCOPES_FILE, `${SCOPES_FILE}.journal`, STORE_IDENTITY_FILE]),
|
|
1533
1837
|
filePrefixes: Object.freeze([ATOMIC_WRITE_TMP_PREFIX, LINK_PROBE_PREFIX]),
|
|
1534
1838
|
lockDirs: Object.freeze([`${ROOT_ANCHOR_FILE}.lock`, `${SCOPES_FILE}.lock`, STORE_TXN_LOCK_DIR]),
|
|
1535
1839
|
memoryFilePrefixes: Object.freeze([CASEFOLD_PROBE_PREFIX]),
|
|
@@ -1562,6 +1866,11 @@ function namedArtifactFault(memoryDir, controlDir, name) {
|
|
|
1562
1866
|
}
|
|
1563
1867
|
readScopesRecord(controlDir);
|
|
1564
1868
|
}
|
|
1869
|
+
else if (name === STORE_IDENTITY_FILE) {
|
|
1870
|
+
if (!absentOrRegularFile(join(controlDir, name)))
|
|
1871
|
+
return new ControlPlaneCorruptError(`memory store file ${join(controlDir, name)} is no regular file the store identity can be read from (a pipe, a device, a directory, or a link that leads nowhere) — the store's identity cannot be checked, so nothing in the store was opened`);
|
|
1872
|
+
readStoreIdentity(controlDir);
|
|
1873
|
+
}
|
|
1565
1874
|
return undefined;
|
|
1566
1875
|
}
|
|
1567
1876
|
catch (err) {
|
|
@@ -2670,6 +2979,15 @@ function isLatchOnlyTxn(txn) {
|
|
|
2670
2979
|
return txn.rows.some((row) => row.kind === "latch-only");
|
|
2671
2980
|
}
|
|
2672
2981
|
export const IMPORT_RECEIPTS_DIR = "import-receipts";
|
|
2982
|
+
export const FILE_CONTROL_OBJECT_DIRS = Object.freeze({
|
|
2983
|
+
pollution: SESSION_POLLUTION_DIR,
|
|
2984
|
+
"import-receipt": IMPORT_RECEIPTS_DIR,
|
|
2985
|
+
quarantine: QUARANTINE_DIR,
|
|
2986
|
+
hold: "hold",
|
|
2987
|
+
"clearance-custody": "origin-clearance-custody",
|
|
2988
|
+
capture: SESSION_CAPTURE_OPTOUT_DIR,
|
|
2989
|
+
});
|
|
2990
|
+
export const CONTROL_OBJECT_STAGE_DIR = ".control-object-stage";
|
|
2673
2991
|
export function importLatchTxnId(bundleHash) {
|
|
2674
2992
|
return `import:${bundleHash}`;
|
|
2675
2993
|
}
|
|
@@ -69,14 +69,16 @@ export interface MemoryDeployment {
|
|
|
69
69
|
* set exactly when its mount holds a record: a file under `<engine root>/personal/.engine` or
|
|
70
70
|
* `<engine root>/personal/memory` other than the named artifacts an open or a read leaves, matched at that place
|
|
71
71
|
* and by that name only (`*` = any rest of the name): control plane top level, files `root-anchor.json` ·
|
|
72
|
-
* `scopes.json` · `scopes.json.journal` · `.tmp-*` · `.link-probe-*`; control plane top level, directories as whole trees
|
|
72
|
+
* `scopes.json` · `scopes.json.journal` · `store-identity.json` · `.tmp-*` · `.link-probe-*`; control plane top level, directories as whole trees
|
|
73
73
|
* `root-anchor.json.lock` · `scopes.json.lock` · `txn.lock` · `root-anchor.json.lock.stale-*` ·
|
|
74
74
|
* `scopes.json.lock.stale-*` · `txn.lock.stale-*`; memory directory top level, files `.casefold-probe-*`. A
|
|
75
75
|
* directory that cannot be read, for any reason but absence (a link that leads nowhere, at it or above it, is no
|
|
76
|
-
* absence), counts as holding one, and so does an anchor, a scope registry
|
|
77
|
-
* damaged (a link, no regular file, unreadable, not JSON or out of shape). Opening, reading
|
|
78
|
-
*
|
|
79
|
-
*
|
|
76
|
+
* absence), counts as holding one, and so does an anchor, a scope registry, a registry journal or a store identity that
|
|
77
|
+
* stands there damaged (a link, no regular file, unreadable, not JSON or out of shape). Opening, reading (an export that
|
|
78
|
+
* mints the store's identity included) and a refused request add no store — so does the session status read with a host
|
|
79
|
+
* capture carrier, which opens the personal store and leaves its anchor and empty directories — and every deployment
|
|
80
|
+
* object over one engine root answers the same. A store in the set that cannot be
|
|
81
|
+
* opened — the damaged anchor, scope registry, registry journal or store identity that put it there is one such cause: the census and the
|
|
80
82
|
* open read the same fault — is not a store of the list: the call throws `ControlPlaneCorruptError` (a bare system error is carried by one
|
|
81
83
|
* that names its errno, the original as its `cause`), and the session status answers that plane
|
|
82
84
|
* `optOutSource: "fault"`.
|
|
@@ -8,17 +8,29 @@
|
|
|
8
8
|
* `(code, detail.sessionId)`, once per session; the phase mints once per prepared leg whose mount failed.
|
|
9
9
|
*
|
|
10
10
|
* `scopes` is what the task asked to mount — every read scope and the write scope when it is a further one (the whole span failed, not
|
|
11
|
-
* one scope's mount), `cause` the closed set below
|
|
12
|
-
* never the thrown text and never a path (a store-form refusal's `detail.path` stays on the operator's lane).
|
|
11
|
+
* one scope's mount), `cause` the closed set below, and `outsideReason` exactly when `cause` is `memory.target_outside_store` (which case
|
|
12
|
+
* of it the refusal named) — never the thrown text and never a path (a store-form refusal's `detail.path` stays on the operator's lane).
|
|
13
13
|
*/
|
|
14
14
|
import type { EngineNotice } from "../types.js";
|
|
15
|
-
import { type StoreFormRefusalCode } from "./layout.js";
|
|
15
|
+
import { type StoreFormRefusalCode, type StoreFormRefusalReading, type TargetOutsideStoreReason } from "./layout.js";
|
|
16
16
|
/** Why the store did not mount: the store-form refusal's own code when the mount was refused for the store's physical form, else `"unclassified"`. */
|
|
17
17
|
export type MemoryMountFailedCause = StoreFormRefusalCode | "unclassified";
|
|
18
|
-
/** The
|
|
19
|
-
|
|
18
|
+
/** The code whose cases the person hears apart — the one reading of the family that carries a case word. */
|
|
19
|
+
type OutsideCode = Extract<StoreFormRefusalReading, {
|
|
20
|
+
readonly outsideReason: TargetOutsideStoreReason;
|
|
21
|
+
}>["code"];
|
|
22
|
+
/** What a mount failure reports: its cause, and — exactly when the cause is the code with cases — which case the refusal named. */
|
|
23
|
+
export type MemoryMountFailedReading = {
|
|
24
|
+
readonly cause: Exclude<MemoryMountFailedCause, OutsideCode>;
|
|
25
|
+
} | {
|
|
26
|
+
readonly cause: OutsideCode;
|
|
27
|
+
readonly outsideReason: TargetOutsideStoreReason;
|
|
28
|
+
};
|
|
29
|
+
/** What a mount failure reports, read once from the thrown value through the family's one reader ({@link storeFormRefusalReadingOf});
|
|
30
|
+
* anything that reading does not name is `"unclassified"`. */
|
|
31
|
+
export declare function memoryMountFailedReadingOf(thrown: unknown): MemoryMountFailedReading;
|
|
20
32
|
export declare function memoryMountFailedNotice(input: {
|
|
21
33
|
sessionId: string;
|
|
22
34
|
scopes: readonly string[];
|
|
23
|
-
|
|
24
|
-
}
|
|
35
|
+
} & MemoryMountFailedReading): EngineNotice;
|
|
36
|
+
export {};
|