@sema-agent/core 7.68.4 → 7.69.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 +1625 -0
- package/dist/agents/agent-definition.d.ts +32 -3
- package/dist/agents/agent-definition.js +39 -1
- package/dist/agents/agent-transcript-tool.js +16 -5
- package/dist/agents/cascade.js +9 -6
- package/dist/agents/cc-uds-peer-channel.js +2 -1
- package/dist/agents/cumulative-stats.d.ts +3 -1
- package/dist/agents/cumulative-stats.js +4 -1
- package/dist/agents/delegation-review-faces.d.ts +35 -0
- package/dist/agents/delegation-review-faces.js +26 -0
- package/dist/agents/inherited-tool-pool.d.ts +4 -2
- package/dist/agents/list-agents-tool.d.ts +8 -19
- package/dist/agents/list-agents-tool.js +19 -34
- package/dist/agents/peer-directory.js +3 -2
- package/dist/agents/peer-held-queue.d.ts +6 -1
- package/dist/agents/peer-held-queue.js +10 -1
- package/dist/agents/peer-idle.d.ts +3 -1
- package/dist/agents/peer-idle.js +4 -4
- package/dist/agents/peer-session-drain.d.ts +9 -1
- package/dist/agents/peer-session-drain.js +185 -116
- package/dist/agents/repair-loop.js +12 -8
- package/dist/agents/retain-ledger.d.ts +122 -58
- package/dist/agents/retain-ledger.js +48 -21
- package/dist/agents/root-session-lane.d.ts +17 -0
- package/dist/agents/root-session-lane.js +9 -0
- package/dist/agents/send-message-tool.js +44 -31
- package/dist/agents/subagent-steps.d.ts +0 -11
- package/dist/agents/subagent-steps.js +1 -14
- package/dist/agents/subagent-transcript-placement.d.ts +4 -3
- package/dist/agents/subagent.d.ts +19 -8
- package/dist/agents/subagent.js +250 -207
- package/dist/agents/tool-filter.d.ts +31 -1
- package/dist/agents/tool-filter.js +28 -4
- package/dist/agents/verifier-independence.js +3 -2
- package/dist/agents/verify.d.ts +5 -1
- package/dist/agents/verify.js +10 -6
- package/dist/agents/yield-adoption.d.ts +17 -0
- package/dist/agents/yield-adoption.js +22 -2
- package/dist/brain/anthropic.js +42 -14
- package/dist/brain/claude-model-id.d.ts +36 -0
- package/dist/brain/claude-model-id.js +44 -0
- package/dist/brain/failover.js +14 -3
- package/dist/brain/fast-mode.d.ts +272 -0
- package/dist/brain/fast-mode.js +130 -0
- package/dist/brain/media-degrade.d.ts +5 -0
- package/dist/brain/media-degrade.js +1 -0
- package/dist/brain/model-capability.d.ts +122 -18
- package/dist/brain/model-capability.js +84 -7
- package/dist/brain/model-lane.d.ts +40 -16
- package/dist/brain/model-lane.js +97 -39
- package/dist/brain/model-presets.d.ts +4 -1
- package/dist/brain/model-presets.js +10 -1
- package/dist/brain/open-responses.js +37 -14
- package/dist/brain/openai.js +27 -15
- package/dist/brain/provider-dialect.d.ts +9 -0
- package/dist/brain/provider-dialect.js +4 -0
- package/dist/brain/provider-message.d.ts +2 -2
- package/dist/brain/provider-message.js +8 -8
- package/dist/brain/reasoning-request.d.ts +19 -0
- package/dist/brain/reasoning-request.js +8 -4
- package/dist/brain/reasoning-stamp.d.ts +3 -2
- package/dist/brain/reasoning.d.ts +8 -4
- package/dist/brain/reasoning.js +4 -3
- package/dist/brain/reference-model-traits.d.ts +59 -0
- package/dist/brain/reference-model-traits.js +46 -0
- package/dist/brain/request-params.js +1 -0
- package/dist/brain/route-adjudicator.d.ts +107 -106
- package/dist/brain/route-adjudicator.js +217 -51
- package/dist/brain/route-conformance.d.ts +6 -4
- package/dist/brain/routing.d.ts +2 -1
- package/dist/brain/routing.js +21 -5
- package/dist/brain/status-sink.d.ts +52 -10
- package/dist/brain/stream-engine.d.ts +68 -11
- package/dist/brain/stream-engine.js +512 -93
- package/dist/brain/stream-shared.d.ts +34 -8
- package/dist/brain/stream-shared.js +20 -7
- package/dist/brain/usage-reading.d.ts +15 -0
- package/dist/brain/usage-reading.js +18 -5
- package/dist/core/a2a.js +28 -21
- package/dist/core/advisor-verdict.d.ts +5 -4
- package/dist/core/advisor-verdict.js +2 -2
- package/dist/core/agent-definition.d.ts +4 -1
- package/dist/core/agent-state.d.ts +25 -2
- package/dist/core/agent-state.js +50 -3
- package/dist/core/allow-entry.d.ts +6 -6
- package/dist/core/allow-entry.js +27 -25
- package/dist/core/ask-headline.d.ts +28 -16
- package/dist/core/ask-headline.js +18 -8
- package/dist/core/ask-origin.d.ts +105 -30
- package/dist/core/ask-origin.js +40 -11
- package/dist/core/ask-question.d.ts +9 -1
- package/dist/core/ask-question.js +3 -0
- package/dist/core/ask-unresolvable-notice.d.ts +10 -2
- package/dist/core/ask-unresolvable-notice.js +5 -2
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +1 -0
- package/dist/core/auto-compaction.d.ts +4 -4
- package/dist/core/auto-compaction.js +4 -3
- package/dist/core/auto-mode-directive.d.ts +30 -60
- package/dist/core/auto-mode-directive.js +36 -38
- package/dist/core/auto-mode.d.ts +40 -9
- package/dist/core/auto-mode.js +20 -5
- package/dist/core/background-agent-store.d.ts +87 -1
- package/dist/core/background-agent-store.js +72 -1
- package/dist/core/background-shell.d.ts +3 -0
- package/dist/core/background-shell.js +1 -0
- package/dist/core/cache-break-detector.js +1 -1
- package/dist/core/caller-text.d.ts +27 -8
- package/dist/core/caller-text.js +47 -1
- package/dist/core/checkpoint-features.d.ts +17 -9
- package/dist/core/checkpoint-identity.d.ts +53 -0
- package/dist/core/checkpoint-identity.js +29 -0
- package/dist/core/checkpoint-queries.d.ts +4 -3
- package/dist/core/checkpoint-queries.js +5 -3
- package/dist/core/checkpoint-rekey.d.ts +70 -0
- package/dist/core/checkpoint-rekey.js +107 -0
- package/dist/core/checkpoint-requirements.d.ts +65 -10
- package/dist/core/checkpoint-requirements.js +47 -13
- package/dist/core/checkpoint-row-verdict.d.ts +5 -3
- package/dist/core/checkpoint-row-verdict.js +37 -4
- package/dist/core/checkpoint-store.d.ts +71 -5
- package/dist/core/checkpoint-store.js +38 -7
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/classifier-category.d.ts +25 -0
- package/dist/core/classifier-category.js +93 -0
- package/dist/core/classifier-unavailable-arm.d.ts +62 -8
- package/dist/core/classifier-unavailable-arm.js +19 -2
- package/dist/core/command-sandbox-dispatch.d.ts +14 -2
- package/dist/core/command-sandbox.d.ts +209 -28
- package/dist/core/command-sandbox.js +195 -20
- package/dist/core/config-refusal-codes.d.ts +41 -1
- package/dist/core/config-refusal-codes.js +16 -0
- package/dist/core/context-edit.d.ts +2 -1
- package/dist/core/context-edit.js +2 -1
- package/dist/core/context-settings.js +5 -4
- package/dist/core/cross-boundary-taint.d.ts +15 -1
- package/dist/core/cross-boundary-taint.js +6 -0
- package/dist/core/delegation-frames.d.ts +36 -6
- package/dist/core/delegation-frames.js +3 -0
- package/dist/core/delegation-name.d.ts +10 -4
- package/dist/core/delegation-name.js +53 -23
- package/dist/core/engine-attestation.d.ts +10 -2
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-capabilities.d.ts +40 -3
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +197 -90
- package/dist/core/engine-notice.js +29 -1
- package/dist/core/engine-version.d.ts +1 -0
- package/dist/core/engine-version.js +1 -0
- package/dist/core/extension-call-id.d.ts +4 -0
- package/dist/core/extension-call-id.js +8 -0
- package/dist/core/fast-tier-door.d.ts +36 -0
- package/dist/core/fast-tier-door.js +65 -0
- package/dist/core/file-history-store.d.ts +343 -67
- package/dist/core/file-history-store.js +320 -93
- package/dist/core/frame-settlement.d.ts +4 -0
- package/dist/core/frame-settlement.js +5 -0
- package/dist/core/gate-fold.js +13 -4
- package/dist/core/gate-lanes.js +27 -20
- package/dist/core/gate-outcome.d.ts +87 -11
- package/dist/core/gate-outcome.js +94 -4
- package/dist/core/git-worktree-env.d.ts +29 -10
- package/dist/core/git-worktree-env.js +31 -12
- package/dist/core/governance-codes.d.ts +232 -7
- package/dist/core/governance-codes.js +195 -6
- package/dist/core/hooks.d.ts +27 -16
- package/dist/core/hooks.js +84 -82
- package/dist/core/host-floor.d.ts +2 -8
- package/dist/core/host-floor.js +6 -42
- package/dist/core/identity-rekey.d.ts +275 -0
- package/dist/core/identity-rekey.js +198 -0
- package/dist/core/image-admission.d.ts +7 -4
- package/dist/core/image-admission.js +24 -11
- package/dist/core/isolation-scope.d.ts +12 -0
- package/dist/core/isolation-scope.js +4 -0
- package/dist/core/leg-identity.d.ts +32 -2
- package/dist/core/leg-identity.js +16 -2
- package/dist/core/locked-config.d.ts +26 -6
- package/dist/core/locked-config.js +31 -14
- package/dist/core/loopback-host.d.ts +18 -0
- package/dist/core/loopback-host.js +40 -0
- package/dist/core/mcp-connection-pool.d.ts +57 -33
- package/dist/core/mcp-connection-pool.js +47 -23
- package/dist/core/mcp-failure.d.ts +41 -19
- package/dist/core/mcp-failure.js +14 -8
- package/dist/core/mcp-host-read.js +5 -4
- package/dist/core/mcp-host-seat.js +3 -2
- package/dist/core/mcp-name-judge.js +2 -1
- package/dist/core/mcp-server-link.js +2 -1
- package/dist/core/mcp-server-spec.js +2 -2
- package/dist/core/mcp-server-unavailable-notice.d.ts +26 -16
- package/dist/core/mcp-server-unavailable-notice.js +25 -4
- package/dist/core/mcp.d.ts +15 -9
- package/dist/core/mcp.js +46 -34
- package/dist/core/memory-engine/consolidation-driver.js +8 -8
- package/dist/core/memory-engine/consolidation-write-gate.js +3 -2
- package/dist/core/memory-engine/engine.js +9 -9
- package/dist/core/memory-engine/layout.d.ts +6 -5
- package/dist/core/memory-engine/layout.js +1 -1
- package/dist/core/memory.d.ts +5 -0
- package/dist/core/memory.js +3 -0
- package/dist/core/model-fallbacks.d.ts +13 -7
- package/dist/core/model-fallbacks.js +5 -3
- package/dist/core/model-receipt.d.ts +15 -0
- package/dist/core/model-receipt.js +54 -1
- package/dist/core/model-seat.d.ts +17 -15
- package/dist/core/mods/agent-stations.js +5 -4
- package/dist/core/mods/extension-call.d.ts +0 -4
- package/dist/core/mods/extension-call.js +0 -8
- package/dist/core/mods/host.d.ts +18 -0
- package/dist/core/mods/host.js +7 -0
- package/dist/core/mods/kernel/events.d.ts +12 -0
- package/dist/core/mods/kernel/events.js +18 -9
- package/dist/core/mods/kernel/registration.d.ts +13 -0
- package/dist/core/mods/kernel/registration.js +34 -1
- package/dist/core/mods/message-display.js +1 -1
- package/dist/core/mods/package.js +3 -3
- package/dist/core/mods/prompt-submit.js +2 -2
- package/dist/core/mods/session-append.js +3 -3
- package/dist/core/mods/session-compact.js +5 -5
- package/dist/core/mods/session-receive.js +3 -3
- package/dist/core/mods/session-send.js +3 -3
- package/dist/core/mods/stations.d.ts +8 -5
- package/dist/core/mods/stations.js +13 -12
- package/dist/core/mods/tool-call.js +12 -12
- package/dist/core/mounted-mcp.d.ts +10 -1
- package/dist/core/mounted-mcp.js +4 -0
- package/dist/core/output-style.d.ts +14 -8
- package/dist/core/output-style.js +6 -6
- package/dist/core/own-property-receipt.js +3 -5
- package/dist/core/owner-identity.d.ts +68 -0
- package/dist/core/owner-identity.js +39 -0
- package/dist/core/parent-spec-seat.d.ts +5 -1
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-resumability.js +2 -2
- package/dist/core/park-selfcheck.js +15 -4
- package/dist/core/peer-seat.d.ts +37 -11
- package/dist/core/peer-seat.js +35 -9
- package/dist/core/permission-rule-model.d.ts +5 -0
- package/dist/core/permission-rule-model.js +27 -6
- package/dist/core/permission-rules.d.ts +42 -5
- package/dist/core/permission-rules.js +74 -10
- package/dist/core/persisted-rule-arms.d.ts +8 -6
- package/dist/core/persisted-rule-arms.js +13 -20
- package/dist/core/physical-path.d.ts +12 -8
- package/dist/core/physical-path.js +24 -14
- package/dist/core/present-plan-tool.js +2 -1
- package/dist/core/pricing.d.ts +65 -8
- package/dist/core/pricing.js +51 -0
- package/dist/core/prompt-section-seat.js +6 -5
- package/dist/core/protocol-http-auth.d.ts +87 -10
- package/dist/core/protocol-http-auth.js +155 -23
- package/dist/core/reminder-mint.d.ts +4 -0
- package/dist/core/reminder-mint.js +1 -0
- package/dist/core/remote-env.d.ts +46 -1
- package/dist/core/remote-env.js +2 -0
- package/dist/core/resume-at-refusal.d.ts +47 -0
- package/dist/core/resume-at-refusal.js +9 -0
- package/dist/core/resume-startup-cause.d.ts +8 -3
- package/dist/core/resume-startup-cause.js +3 -1
- package/dist/core/retired-keys.d.ts +4 -0
- package/dist/core/retired-keys.js +4 -0
- package/dist/core/roles.d.ts +11 -5
- package/dist/core/roles.js +14 -3
- package/dist/core/rule-store-fault.d.ts +8 -1
- package/dist/core/rule-store-fault.js +5 -0
- package/dist/core/runner/advisor-instructions.d.ts +12 -12
- package/dist/core/runner/advisor-instructions.js +7 -24
- package/dist/core/runner/announce-once-ledger.d.ts +23 -8
- package/dist/core/runner/announce-once-ledger.js +69 -18
- package/dist/core/runner/assemble-result.d.ts +9 -0
- package/dist/core/runner/assemble-result.js +3 -2
- package/dist/core/runner/auto-strip-notice.js +1 -1
- package/dist/core/runner/branch-window.js +5 -3
- package/dist/core/runner/call-hook-stations.d.ts +3 -0
- package/dist/core/runner/call-hook-stations.js +4 -3
- package/dist/core/runner/caller-roster.js +2 -1
- package/dist/core/runner/capability-withheld-seat.js +47 -5
- package/dist/core/runner/classifier-ladder.d.ts +48 -8
- package/dist/core/runner/classifier-ladder.js +88 -38
- package/dist/core/runner/clock-and-limits.d.ts +13 -2
- package/dist/core/runner/clock-and-limits.js +11 -8
- package/dist/core/runner/command-sandbox-frame.d.ts +56 -0
- package/dist/core/runner/command-sandbox-frame.js +107 -0
- package/dist/core/runner/compact-session.d.ts +3 -1
- package/dist/core/runner/compact-session.js +16 -10
- package/dist/core/runner/compaction-call-options.d.ts +2 -2
- package/dist/core/runner/compaction-restate.d.ts +4 -4
- package/dist/core/runner/compaction-restate.js +3 -1
- package/dist/core/runner/construction-doors.js +9 -0
- package/dist/core/runner/continuation-gate.d.ts +39 -0
- package/dist/core/runner/continuation-gate.js +42 -0
- package/dist/core/runner/continues-from.d.ts +57 -0
- package/dist/core/runner/continues-from.js +76 -0
- package/dist/core/runner/contracts.d.ts +133 -55
- package/dist/core/runner/credential-refusal-seat.js +31 -12
- package/dist/core/runner/cross-boundary-lane.d.ts +2 -2
- package/dist/core/runner/cross-boundary-lane.js +26 -13
- package/dist/core/runner/delegation-owner.d.ts +99 -9
- package/dist/core/runner/delegation-owner.js +107 -4
- package/dist/core/runner/denial-limit-arms.js +13 -12
- package/dist/core/runner/derived-route-fallback.d.ts +15 -19
- package/dist/core/runner/derived-route-fallback.js +4 -4
- package/dist/core/runner/earlier-grammar-notice.d.ts +6 -0
- package/dist/core/runner/earlier-grammar-notice.js +9 -0
- package/dist/core/runner/end-of-run.d.ts +26 -13
- package/dist/core/runner/end-of-run.js +43 -12
- package/dist/core/runner/env-capability-census.js +2 -1
- package/dist/core/runner/execution-record.d.ts +4 -2
- package/dist/core/runner/execution-record.js +1 -1
- package/dist/core/runner/fast-mode-seat.d.ts +89 -0
- package/dist/core/runner/fast-mode-seat.js +215 -0
- package/dist/core/runner/file-history-restore.d.ts +52 -14
- package/dist/core/runner/file-history-restore.js +50 -8
- package/dist/core/runner/forward-sink.js +2 -2
- package/dist/core/runner/gate-exit.d.ts +41 -3
- package/dist/core/runner/gate-exit.js +55 -10
- package/dist/core/runner/git-leg-delivery.js +6 -3
- package/dist/core/runner/git-status-frame.d.ts +33 -25
- package/dist/core/runner/git-status-frame.js +54 -36
- package/dist/core/runner/halt-attribution.js +2 -2
- package/dist/core/runner/hook-progress-lane.d.ts +26 -0
- package/dist/core/runner/hook-progress-lane.js +72 -0
- package/dist/core/runner/initial-run-state.js +2 -2
- package/dist/core/runner/language-frame.d.ts +10 -8
- package/dist/core/runner/language-frame.js +7 -11
- package/dist/core/runner/left-as-is-seat.d.ts +20 -0
- package/dist/core/runner/left-as-is-seat.js +11 -0
- package/dist/core/runner/leg-receipt.d.ts +38 -0
- package/dist/core/runner/leg-receipt.js +22 -0
- package/dist/core/runner/listing-fold.d.ts +4 -3
- package/dist/core/runner/listing-fold.js +5 -5
- package/dist/core/runner/listing-replay.d.ts +41 -0
- package/dist/core/runner/listing-replay.js +75 -0
- package/dist/core/runner/main-call-account.d.ts +2 -1
- package/dist/core/runner/main-call-account.js +18 -5
- package/dist/core/runner/mcp-redial.d.ts +4 -2
- package/dist/core/runner/mcp-redial.js +3 -0
- package/dist/core/runner/memory-consolidation-driver.js +3 -2
- package/dist/core/runner/model-fallback-seat.d.ts +12 -9
- package/dist/core/runner/model-fallback-seat.js +24 -20
- package/dist/core/runner/nested-memory-lane.d.ts +16 -8
- package/dist/core/runner/nested-memory-lane.js +64 -53
- package/dist/core/runner/permission-rule-lanes.d.ts +4 -3
- package/dist/core/runner/permission-rule-lanes.js +2 -0
- package/dist/core/runner/person-path-rows.js +1 -1
- package/dist/core/runner/placement-fence.js +2 -2
- package/dist/core/runner/policy-throw.d.ts +3 -3
- package/dist/core/runner/policy-throw.js +7 -5
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +7 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +9 -5
- package/dist/core/runner/prepare-advisor.d.ts +3 -0
- package/dist/core/runner/prepare-advisor.js +2 -2
- package/dist/core/runner/prepare-artifact.d.ts +7 -2
- package/dist/core/runner/prepare-artifact.js +18 -7
- package/dist/core/runner/prepare-ask-lane.d.ts +7 -0
- package/dist/core/runner/prepare-ask-lane.js +4 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +9 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +28 -20
- package/dist/core/runner/prepare-config-doors.d.ts +13 -3
- package/dist/core/runner/prepare-config-doors.js +35 -24
- package/dist/core/runner/prepare-context-lane.d.ts +3 -4
- package/dist/core/runner/prepare-context-lane.js +12 -15
- package/dist/core/runner/prepare-defer-classify.d.ts +12 -0
- package/dist/core/runner/prepare-defer-classify.js +5 -2
- package/dist/core/runner/prepare-delegation-surface.d.ts +10 -8
- package/dist/core/runner/prepare-delegation-surface.js +6 -7
- package/dist/core/runner/prepare-execution-env.d.ts +46 -4
- package/dist/core/runner/prepare-execution-env.js +47 -18
- package/dist/core/runner/prepare-file-history.d.ts +4 -1
- package/dist/core/runner/prepare-file-history.js +8 -9
- package/dist/core/runner/prepare-gate-stations.d.ts +17 -9
- package/dist/core/runner/prepare-gate-stations.js +22 -38
- package/dist/core/runner/prepare-hands-readface.d.ts +13 -9
- package/dist/core/runner/prepare-hands-readface.js +26 -35
- package/dist/core/runner/prepare-inherited-gate.d.ts +9 -2
- package/dist/core/runner/prepare-inherited-gate.js +10 -9
- package/dist/core/runner/prepare-leg-adoption.d.ts +36 -0
- package/dist/core/runner/prepare-leg-adoption.js +24 -0
- package/dist/core/runner/prepare-listings.d.ts +3 -0
- package/dist/core/runner/prepare-listings.js +2 -2
- package/dist/core/runner/prepare-lsp.d.ts +0 -3
- package/dist/core/runner/prepare-lsp.js +1 -2
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +5 -5
- package/dist/core/runner/prepare-offload-wrappers.js +5 -5
- package/dist/core/runner/prepare-park-ask.d.ts +9 -2
- package/dist/core/runner/prepare-park-ask.js +5 -3
- package/dist/core/runner/prepare-policy-chain.d.ts +20 -5
- package/dist/core/runner/prepare-policy-chain.js +32 -26
- package/dist/core/runner/prepare-prompt-assembly.d.ts +11 -2
- package/dist/core/runner/prepare-prompt-assembly.js +6 -3
- package/dist/core/runner/prepare-prompt-inputs.d.ts +3 -3
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-protocol-tools.d.ts +9 -4
- package/dist/core/runner/prepare-protocol-tools.js +11 -11
- package/dist/core/runner/prepare-run-refs.d.ts +7 -0
- package/dist/core/runner/prepare-run-refs.js +6 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
- package/dist/core/runner/prepare-suspend-saga.js +5 -2
- package/dist/core/runner/prepare-task.d.ts +1 -30
- package/dist/core/runner/prepare-task.js +111 -147
- package/dist/core/runner/prepare-turn-wiring.d.ts +10 -3
- package/dist/core/runner/prepare-turn-wiring.js +7 -4
- package/dist/core/runner/prepare-wiring-manifest.d.ts +12 -3
- package/dist/core/runner/prepare-wiring-manifest.js +21 -17
- package/dist/core/runner/prompt-block.js +2 -2
- package/dist/core/runner/prompt-suggestions.d.ts +3 -8
- package/dist/core/runner/prompt-suggestions.js +4 -1
- package/dist/core/runner/reply-pricing.d.ts +8 -4
- package/dist/core/runner/reply-pricing.js +6 -5
- package/dist/core/runner/resume-admission.js +2 -0
- package/dist/core/runner/resume-apply.js +4 -4
- package/dist/core/runner/resume-checkpoint-screen.d.ts +23 -2
- package/dist/core/runner/resume-checkpoint-screen.js +34 -27
- package/dist/core/runner/resume-preflight.js +3 -3
- package/dist/core/runner/rewind-files.js +21 -14
- package/dist/core/runner/role-resolution-table.d.ts +10 -7
- package/dist/core/runner/role-resolution-table.js +8 -7
- package/dist/core/runner/role-seat-defaulted.js +2 -2
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +4 -2
- package/dist/core/runner/rule-store-unreadable-notice.js +21 -7
- package/dist/core/runner/run-attachment-seats.js +8 -15
- package/dist/core/runner/run-brain-sinks.js +1 -0
- package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
- package/dist/core/runner/run-compaction-machinery.js +2 -3
- package/dist/core/runner/run-harness-handlers.d.ts +2 -2
- package/dist/core/runner/run-harness-handlers.js +18 -5
- package/dist/core/runner/run-identity-wiring.js +11 -9
- package/dist/core/runner/run-leg.js +33 -12
- package/dist/core/runner/run-notification-lane.d.ts +4 -1
- package/dist/core/runner/run-notification-lane.js +21 -8
- package/dist/core/runner/run-recovery-lanes.js +1 -1
- package/dist/core/runner/run-settle-and-teardown.d.ts +6 -1
- package/dist/core/runner/run-settle-and-teardown.js +30 -32
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -1
- package/dist/core/runner/run-stop-and-final-verify.js +12 -49
- package/dist/core/runner/run-telemetry-and-budget-seats.js +29 -10
- package/dist/core/runner/run-terminal-adoption.js +5 -2
- package/dist/core/runner/run-turn-boundary.js +13 -11
- package/dist/core/runner/runtask.d.ts +16 -7
- package/dist/core/runner/runtask.js +51 -30
- package/dist/core/runner/sandbox-network-seat.d.ts +52 -0
- package/dist/core/runner/sandbox-network-seat.js +40 -0
- package/dist/core/runner/seat-model-doors.d.ts +16 -0
- package/dist/core/runner/seat-model-doors.js +13 -0
- package/dist/core/runner/session-file-state-replay.d.ts +20 -0
- package/dist/core/runner/session-file-state-replay.js +17 -5
- package/dist/core/runner/session-read-file-states.d.ts +37 -0
- package/dist/core/runner/session-read-file-states.js +19 -0
- package/dist/core/runner/session-rule-policy.d.ts +2 -1
- package/dist/core/runner/session-rule-policy.js +3 -2
- package/dist/core/runner/session-verb-doors.js +2 -1
- package/dist/core/runner/session-write-ledger.d.ts +5 -1
- package/dist/core/runner/session-write-ledger.js +19 -5
- package/dist/core/runner/shared-read-classifier.d.ts +48 -0
- package/dist/core/runner/shared-read-classifier.js +33 -0
- package/dist/core/runner/shell-env-withheld.d.ts +6 -3
- package/dist/core/runner/shell-env-withheld.js +25 -0
- package/dist/core/runner/side-call-account.d.ts +30 -2
- package/dist/core/runner/side-call-account.js +38 -5
- package/dist/core/runner/skipped-rules-notice.d.ts +43 -0
- package/dist/core/runner/skipped-rules-notice.js +49 -0
- package/dist/core/runner/steering-preview.js +1 -1
- package/dist/core/runner/stop-tail-notice.d.ts +40 -0
- package/dist/core/runner/stop-tail-notice.js +35 -0
- package/dist/core/runner/stream-halt-verbs.js +1 -1
- package/dist/core/runner/stream-mode-verb.d.ts +11 -4
- package/dist/core/runner/stream-mode-verb.js +19 -7
- package/dist/core/runner/stream-settle-backstop.js +3 -1
- package/dist/core/runner/stream-steer-verb.js +4 -3
- package/dist/core/runner/synthetic-tools.d.ts +11 -11
- package/dist/core/runner/synthetic-tools.js +17 -20
- package/dist/core/runner/task-start-doors.d.ts +86 -0
- package/dist/core/runner/task-start-doors.js +108 -0
- package/dist/core/runner/teardown-bounded.d.ts +5 -5
- package/dist/core/runner/teardown-bounded.js +6 -6
- package/dist/core/runner/terminal-account.d.ts +3 -2
- package/dist/core/runner/terminal-account.js +5 -3
- package/dist/core/runner/tool-disclosure.js +8 -9
- package/dist/core/runner/tool-end-body.d.ts +2 -0
- package/dist/core/runner/tool-end-body.js +1 -0
- package/dist/core/runner/tool-face-overlay.js +1 -0
- package/dist/core/runner/tool-occurrence.d.ts +22 -24
- package/dist/core/runner/tool-occurrence.js +9 -15
- package/dist/core/runner/tool-progress-lane.js +1 -1
- package/dist/core/runner/tool-result-media-seat.d.ts +7 -4
- package/dist/core/runner/tool-result-media-seat.js +16 -4
- package/dist/core/runner/tool-table-view.d.ts +7 -1
- package/dist/core/runner/tool-table-view.js +1 -1
- package/dist/core/runner/tool-turn-repair-seat.d.ts +22 -2
- package/dist/core/runner/tool-turn-repair-seat.js +23 -5
- package/dist/core/runner/turn-attachments.d.ts +74 -148
- package/dist/core/runner/turn-attachments.js +153 -223
- package/dist/core/runner/usage-accounting.d.ts +15 -0
- package/dist/core/runner/usage-accounting.js +12 -4
- package/dist/core/runner/verdict-refusal.d.ts +45 -0
- package/dist/core/runner/verdict-refusal.js +39 -0
- package/dist/core/runner/write-protection-station.d.ts +5 -0
- package/dist/core/runner/write-protection-station.js +6 -6
- package/dist/core/runner-deps.d.ts +15 -5
- package/dist/core/runtime-caps.d.ts +5 -3
- package/dist/core/secret-env.d.ts +19 -14
- package/dist/core/secret-env.js +19 -12
- package/dist/core/session-checkout.d.ts +18 -1
- package/dist/core/session-checkout.js +23 -8
- package/dist/core/session-log-transfer.js +2 -2
- package/dist/core/session-policy-store.d.ts +220 -31
- package/dist/core/session-policy-store.js +333 -47
- package/dist/core/session-reconcile.d.ts +12 -0
- package/dist/core/session-reconcile.js +1 -1
- package/dist/core/session-store.d.ts +5 -3
- package/dist/core/session-store.js +11 -11
- package/dist/core/session.d.ts +31 -22
- package/dist/core/session.js +3 -2
- package/dist/core/shared-memory/normalize.js +2 -1
- package/dist/core/side-query.d.ts +4 -0
- package/dist/core/side-query.js +7 -4
- package/dist/core/spec-contract.d.ts +4 -2
- package/dist/core/store-contracts/background-agent-store-contract.js +149 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +55 -0
- package/dist/core/store-contracts/contract-kit-version.d.ts +4 -4
- package/dist/core/store-contracts/file-history-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/file-history-store-contract.js +282 -22
- package/dist/core/store-contracts/session-policy-store-contract.js +202 -0
- package/dist/core/store-contracts/session-store-contract.js +48 -14
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +128 -0
- package/dist/core/store-contracts/workflow-journal-store-contract.js +90 -1
- package/dist/core/swappable-deps.d.ts +16 -0
- package/dist/core/swappable-deps.js +61 -1
- package/dist/core/synthetic-read-verdict.d.ts +23 -0
- package/dist/core/synthetic-read-verdict.js +43 -18
- package/dist/core/task-event.d.ts +123 -50
- package/dist/core/task-intake.d.ts +21 -5
- package/dist/core/task-intake.js +29 -3
- package/dist/core/task-limits.d.ts +3 -1
- package/dist/core/task-notification.d.ts +171 -59
- package/dist/core/task-notification.js +162 -104
- package/dist/core/task-registry-agent.d.ts +12 -0
- package/dist/core/task-registry-agent.js +23 -9
- package/dist/core/task-registry-shared.d.ts +4 -2
- package/dist/core/task-registry-shared.js +1 -1
- package/dist/core/task-registry-workflow.js +8 -5
- package/dist/core/task-registry.d.ts +16 -1
- package/dist/core/task-registry.js +35 -23
- package/dist/core/task-result.d.ts +127 -10
- package/dist/core/task-spec-members.d.ts +5 -2
- package/dist/core/task-spec-members.js +9 -5
- package/dist/core/task-spec.d.ts +31 -12
- package/dist/core/task-start-judge.d.ts +41 -0
- package/dist/core/task-start-judge.js +26 -0
- package/dist/core/task-stream.d.ts +12 -1
- package/dist/core/terminal-cause.d.ts +23 -9
- package/dist/core/tool-catalog-entries.js +6 -5
- package/dist/core/tool-face-lists.d.ts +3 -2
- package/dist/core/tool-face-lists.js +6 -0
- package/dist/core/tool-face-reader.d.ts +3 -2
- package/dist/core/tool-face-reader.js +2 -2
- package/dist/core/tool-face.d.ts +27 -3
- package/dist/core/tool-face.js +2 -2
- package/dist/core/tool-model-gate.js +14 -13
- package/dist/core/tool-mount-facts.d.ts +16 -3
- package/dist/core/tool-mount-facts.js +10 -0
- package/dist/core/tool-mount-plan.d.ts +79 -10
- package/dist/core/tool-mount-plan.js +79 -24
- package/dist/core/tool-mount-static.d.ts +52 -6
- package/dist/core/tool-mount-static.js +82 -28
- package/dist/core/tool-name-aliases.js +1 -1
- package/dist/core/tool-policy.d.ts +25 -5
- package/dist/core/tool-policy.js +8 -6
- package/dist/core/tool-registry.d.ts +12 -2
- package/dist/core/tool-registry.js +9 -2
- package/dist/core/tool-result-budget.d.ts +2 -2
- package/dist/core/tool-result-bytes.d.ts +28 -9
- package/dist/core/tool-result-bytes.js +7 -5
- package/dist/core/tool-result-store.d.ts +310 -38
- package/dist/core/tool-result-store.js +325 -30
- package/dist/core/tool-roster.d.ts +20 -8
- package/dist/core/tool-roster.js +16 -6
- package/dist/core/tool-search-setting.js +2 -2
- package/dist/core/tool-spec.d.ts +10 -10
- package/dist/core/types.d.ts +5 -5
- package/dist/core/types.js +2 -2
- package/dist/core/unc-spelling.d.ts +114 -3
- package/dist/core/unc-spelling.js +110 -0
- package/dist/core/untrusted-egress.d.ts +82 -10
- package/dist/core/untrusted-egress.js +102 -9
- package/dist/core/untrusted-text.d.ts +28 -0
- package/dist/core/untrusted-text.js +67 -3
- package/dist/core/user-attachment.d.ts +18 -3
- package/dist/core/user-attachment.js +37 -31
- package/dist/core/user-row-origin.d.ts +22 -0
- package/dist/core/user-row-origin.js +15 -0
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +2 -12
- package/dist/core/wiring-manifest.d.ts +124 -30
- package/dist/core/wiring-manifest.js +59 -17
- package/dist/core/workflow-journal-store.d.ts +186 -16
- package/dist/core/workflow-journal-store.js +156 -1
- package/dist/core/workflow-run-store-contract.js +82 -1
- package/dist/core/workflow-run-store.d.ts +40 -4
- package/dist/core/workflow-run-store.js +9 -2
- package/dist/core/workspace-snapshot.d.ts +4 -1
- package/dist/core/workspace-snapshot.js +1 -1
- package/dist/engine/compaction/compaction.d.ts +3 -3
- package/dist/engine/compaction/compaction.js +16 -18
- package/dist/engine/execution-env/node-execution-env.d.ts +14 -6
- package/dist/engine/execution-env/node-execution-env.js +49 -14
- package/dist/engine/harness/agent-harness.d.ts +17 -7
- package/dist/engine/harness/agent-harness.js +66 -16
- package/dist/engine/harness/types.d.ts +31 -2
- package/dist/engine/harness/types.js +14 -1
- package/dist/engine/llm/tool-turns.d.ts +19 -2
- package/dist/engine/llm/tool-turns.js +29 -2
- package/dist/engine/llm/types.d.ts +103 -22
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/loop/agent-loop.d.ts +18 -9
- package/dist/engine/loop/agent-loop.js +115 -24
- package/dist/engine/loop/types.d.ts +14 -6
- package/dist/engine/lsp/node-lsp-manager.d.ts +6 -4
- package/dist/engine/lsp/node-lsp-manager.js +22 -21
- package/dist/engine/session/import-validate.js +2 -0
- package/dist/engine/session/repo-utils.d.ts +13 -7
- package/dist/engine/session/repo-utils.js +9 -4
- package/dist/index.d.ts +48 -27
- package/dist/index.js +38 -20
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/goal.js +1 -1
- package/dist/orchestration/governance-baseline-validity.d.ts +20 -5
- package/dist/orchestration/governance-baseline-validity.js +87 -16
- package/dist/orchestration/run-workflow-tool.d.ts +15 -12
- package/dist/orchestration/run-workflow-tool.js +757 -331
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-observe.d.ts +22 -2
- package/dist/orchestration/workflow-observe.js +20 -9
- package/dist/orchestration/workflow-park-adoption.d.ts +380 -0
- package/dist/orchestration/workflow-park-adoption.js +617 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +6 -8
- package/dist/orchestration/workflow-size-guideline.js +12 -14
- package/dist/orchestration/workflow-types.d.ts +97 -17
- package/dist/orchestration/workflow-types.js +39 -8
- package/dist/orchestration/workflow.d.ts +70 -26
- package/dist/orchestration/workflow.js +495 -199
- package/dist/prompt-assembly/artifact.js +4 -3
- package/dist/prompt-assembly/assemble.d.ts +2 -0
- package/dist/prompt-assembly/assemble.js +4 -1
- package/dist/prompt-assembly/bands.d.ts +3 -0
- package/dist/prompt-assembly/bands.js +6 -0
- package/dist/prompt-assembly/catalog/constitution.d.ts +1 -1
- package/dist/prompt-assembly/catalog/constitution.js +74 -9
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +5 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +46 -9
- package/dist/prompt-assembly/catalog/engine.d.ts +110 -5
- package/dist/prompt-assembly/catalog/engine.js +13 -0
- package/dist/prompt-assembly/catalog/events.d.ts +852 -0
- package/dist/prompt-assembly/catalog/events.js +62 -0
- package/dist/prompt-assembly/catalog/index.js +2 -1
- package/dist/prompt-assembly/catalog/locales/index.d.ts +2 -2
- package/dist/prompt-assembly/catalog/locales/index.js +4 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.js +53 -1
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +45 -9
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +12 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +57 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +56 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.js +8 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/role.js +37 -9
- package/dist/prompt-assembly/catalog/mechanism.d.ts +427 -0
- package/dist/prompt-assembly/catalog/mechanism.js +62 -0
- package/dist/prompt-assembly/catalog/memory.d.ts +3 -3
- package/dist/prompt-assembly/catalog/memory.js +12 -3
- package/dist/prompt-assembly/catalog/modes.d.ts +2 -2
- package/dist/prompt-assembly/catalog/modes.js +7 -1
- package/dist/prompt-assembly/catalog/role.d.ts +1 -1
- package/dist/prompt-assembly/catalog/role.js +43 -14
- package/dist/prompt-assembly/catalog/schema.d.ts +43 -20
- package/dist/prompt-assembly/catalog/schema.js +17 -6
- package/dist/prompt-assembly/catalog/sections.d.ts +1 -1
- package/dist/prompt-assembly/catalog/sections.js +20 -12
- package/dist/prompt-assembly/composer.d.ts +3 -0
- package/dist/prompt-assembly/composer.js +11 -5
- package/dist/prompt-assembly/engine-text.d.ts +14 -4
- package/dist/prompt-assembly/engine-text.js +18 -9
- package/dist/prompt-assembly/event-registry.d.ts +38 -31
- package/dist/prompt-assembly/event-registry.js +185 -25
- package/dist/prompt-assembly/explain.d.ts +24 -0
- package/dist/prompt-assembly/explain.js +11 -0
- package/dist/prompt-assembly/locale-review.js +3 -2
- package/dist/prompt-assembly/overlay.d.ts +25 -7
- package/dist/prompt-assembly/overlay.js +68 -14
- package/dist/prompt-assembly/select.d.ts +4 -3
- package/dist/prompt-assembly/select.js +10 -2
- package/dist/prompt-assembly/sugar.d.ts +3 -2
- package/dist/prompt-assembly/sugar.js +2 -2
- package/dist/prompt-assembly/tool-catalog.js +3 -2
- package/dist/prompt-assembly/turn-snapshot.d.ts +1 -0
- package/dist/prompt-assembly/turn-snapshot.js +1 -0
- package/dist/prompt-assembly/types.d.ts +3 -4
- package/dist/prompts/default.d.ts +6 -45
- package/dist/prompts/default.js +3 -21
- package/dist/stores/file/adoption/adopt.d.ts +13 -3
- package/dist/stores/file/adoption/adopt.js +90 -95
- package/dist/stores/file/adoption/marker.d.ts +2 -1
- package/dist/stores/file/background-agent-store.d.ts +61 -0
- package/dist/stores/file/background-agent-store.js +64 -15
- package/dist/stores/file/checkpoint-store.d.ts +30 -2
- package/dist/stores/file/checkpoint-store.js +72 -23
- package/dist/stores/file/file-history-store.d.ts +13 -7
- package/dist/stores/file/file-history-store.js +170 -46
- package/dist/stores/file/fs-atomic.d.ts +57 -2
- package/dist/stores/file/fs-atomic.js +116 -48
- package/dist/stores/file/index.d.ts +2 -0
- package/dist/stores/file/index.js +2 -0
- package/dist/stores/file/ledger-damage.d.ts +87 -0
- package/dist/stores/file/ledger-damage.js +103 -0
- package/dist/stores/file/session-policy-store.d.ts +36 -4
- package/dist/stores/file/session-policy-store.js +177 -6
- package/dist/stores/file/shared-ledger.d.ts +123 -11
- package/dist/stores/file/shared-ledger.js +113 -18
- package/dist/stores/file/tool-result-store.d.ts +30 -1
- package/dist/stores/file/tool-result-store.js +60 -6
- package/dist/stores/file/workflow-journal-store.d.ts +73 -26
- package/dist/stores/file/workflow-journal-store.js +195 -32
- package/dist/stores/file/workflow-run-store.d.ts +47 -2
- package/dist/stores/file/workflow-run-store.js +17 -14
- package/dist/tools/artifact/artifact-tool.d.ts +9 -6
- package/dist/tools/artifact/artifact-tool.js +76 -40
- package/dist/tools/fs/env-error-detail.d.ts +11 -0
- package/dist/tools/fs/env-error-detail.js +13 -2
- package/dist/tools/fs/fs-bash.js +30 -21
- package/dist/tools/fs/fs-pdf.d.ts +1 -1
- package/dist/tools/fs/fs-pdf.js +2 -2
- package/dist/tools/fs/fs-read.js +4 -4
- package/dist/tools/fs/fs-shared.d.ts +26 -9
- package/dist/tools/fs/fs-shared.js +12 -6
- package/dist/tools/fs/fs-write.d.ts +6 -4
- package/dist/tools/fs/fs-write.js +24 -18
- package/dist/tools/fs/pattern-kill-guard.js +2 -1
- package/dist/tools/fs/pdf.d.ts +8 -0
- package/dist/tools/fs/pdf.js +10 -0
- package/dist/tools/fs/program-read-model.d.ts +4 -0
- package/dist/tools/fs/program-read-model.rows.js +3 -3
- package/dist/tools/fs/read-floor.d.ts +11 -9
- package/dist/tools/fs/read-floor.js +7 -10
- package/dist/tools/fs/removal-targets.d.ts +4 -3
- package/dist/tools/fs/removal-targets.js +27 -9
- package/dist/tools/fs/safety.d.ts +29 -107
- package/dist/tools/fs/safety.js +16 -118
- package/dist/tools/fs/shell-read-check.d.ts +4 -2
- package/dist/tools/fs/shell-read-check.js +6 -2
- package/dist/tools/fs/shell-read-environment.d.ts +10 -2
- package/dist/tools/fs/shell-read-environment.js +20 -11
- package/dist/tools/fs/shell-read-judge.d.ts +19 -7
- package/dist/tools/fs/shell-read-judge.js +9 -3
- package/dist/tools/fs/shell-reentry-text.d.ts +8 -0
- package/dist/tools/fs/shell-reentry-text.js +56 -0
- package/dist/tools/monitor.js +7 -5
- package/dist/tools/scheduler-tools.d.ts +39 -1
- package/dist/tools/scheduler-tools.js +84 -35
- package/dist/tools/task-list.d.ts +12 -4
- package/dist/tools/task-list.js +10 -7
- package/dist/tools/web.d.ts +2 -8
- package/dist/tools/web.js +5 -5
- package/dist/tools/worktree.js +18 -15
- package/package.json +6 -3
- package/test/export-surface.snapshot.json +344 -14
- package/wire-changes/core-stores-sql@7.68.5.json +39 -0
- package/wire-changes/core-stores-sql@7.69.0.json +39 -0
- package/wire-changes/core@7.68.5.json +141 -0
- package/wire-changes/core@7.69.0.json +9561 -0
- package/wire-changes/mods-kernel@7.68.5.json +39 -0
- package/wire-changes/mods-kernel@7.69.0.json +80 -0
- package/wire-changes/primitives@7.68.5.json +39 -0
- package/wire-changes/primitives@7.69.0.json +79 -0
- package/wire-changes/wiki-gate@7.68.5.json +39 -0
- package/wire-changes/wiki-gate@7.69.0.json +39 -0
|
@@ -2,8 +2,8 @@ import { strict as assert } from "node:assert";
|
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { chmod, mkdtemp, mkdir, rm, stat, symlink, writeFile, readFile } from "node:fs/promises";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { fileHistoryBlobExchangeOf, fileHistoryParentIdentTravels } from "../file-history-store.js";
|
|
5
|
+
import { isAbsolute, join } from "node:path";
|
|
6
|
+
import { fileHistoryBlobExchangeOf, fileHistoryParentIdentTravels, planFileHistoryRestore } from "../file-history-store.js";
|
|
7
7
|
import { isGovernanceRetryClass } from "../governance-codes.js";
|
|
8
8
|
import { physicalPathOfAsync } from "../physical-path.js";
|
|
9
9
|
import { NodeExecutionEnv } from "../../internal/harness.js";
|
|
@@ -82,6 +82,100 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
82
82
|
assert.deepEqual([...((await exchange.get(hash)) ?? [])], [...bytes], "get round-trips the bytes");
|
|
83
83
|
onOptionalMember?.({ member: "blobExchange", status: "verified" });
|
|
84
84
|
});
|
|
85
|
+
run("readBoundaries (optional seat): a boundary never made and a reaped one read null, a committed one reads its tracked set with each entry's target, and no env is needed; absence is REPORTED", async () => {
|
|
86
|
+
const probe = make();
|
|
87
|
+
if (typeof probe.readBoundaries !== "function") {
|
|
88
|
+
onOptionalMember?.({ member: "readBoundaries", status: "absent" });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
await withTree(async (dir, env) => {
|
|
92
|
+
const store = make();
|
|
93
|
+
assert.deepEqual(await readOneBoundary(store, "sc", "never-made"), { ok: true, boundary: null }, "a boundary never made reads null");
|
|
94
|
+
await writeFile(join(dir, "f.txt"), "one");
|
|
95
|
+
assert.deepEqual(await store.trackEdit("sc", join(dir, "f.txt"), env, dir), { ok: true, minted: true });
|
|
96
|
+
assert.deepEqual(await store.snapshot("sc", "b1", env, dir), { ok: true });
|
|
97
|
+
assert.deepEqual(await store.snapshot("sc", "b2", env, dir), { ok: true });
|
|
98
|
+
const read = await readOneBoundary(store, "sc", "b1");
|
|
99
|
+
assert.ok(read.ok && read.boundary !== null, JSON.stringify(read));
|
|
100
|
+
assert.deepEqual(read.boundary.entries.map((e) => [e.key, e.keyDesc.kind, e.target.kind, "version" in e.target ? e.target.version : null, "hash" in e.target ? e.target.hash : null]), [["f.txt", "root-relative", "bytes", 1, createHash("sha256").update("one").digest("hex")]]);
|
|
101
|
+
assert.deepEqual(await store.reap("sc", ["b2"]), 1);
|
|
102
|
+
assert.deepEqual(await readOneBoundary(store, "sc", "b1"), { ok: true, boundary: null }, "a reaped boundary reads null, as its restore answers not_found");
|
|
103
|
+
assert.equal((await store.restore("sc", "b1", env, dir)).error?.code, "not_found");
|
|
104
|
+
});
|
|
105
|
+
onOptionalMember?.({ member: "readBoundaries", status: "verified" });
|
|
106
|
+
});
|
|
107
|
+
run("readBoundaries answers a batch as its ids asked alone: [b1, b2, never made, reaped, b1] holds four keys — one per distinct id, an id asked twice is one key — each valued as that id's batch of one", async () => {
|
|
108
|
+
await withTree(async (dir, env) => {
|
|
109
|
+
const store = make();
|
|
110
|
+
if (typeof store.readBoundaries !== "function")
|
|
111
|
+
return;
|
|
112
|
+
await writeFile(join(dir, "f.txt"), "f0");
|
|
113
|
+
assert.deepEqual(await store.trackEdit("sc", join(dir, "f.txt"), env, dir), { ok: true, minted: true });
|
|
114
|
+
assert.deepEqual(await store.snapshot("sc", "b0", env, dir), { ok: true });
|
|
115
|
+
assert.deepEqual(await store.snapshot("sc", "b1", env, dir), { ok: true });
|
|
116
|
+
await writeFile(join(dir, "f.txt"), "f1");
|
|
117
|
+
assert.deepEqual(await store.snapshot("sc", "b2", env, dir), { ok: true });
|
|
118
|
+
assert.deepEqual(await store.reap("sc", ["b1", "b2"]), 1);
|
|
119
|
+
const batch = await store.readBoundaries("sc", ["b1", "b2", "never-made", "b0", "b1"]);
|
|
120
|
+
assert.ok(batch.ok, JSON.stringify(batch));
|
|
121
|
+
assert.deepEqual([...batch.boundaries.keys()].sort(), ["b0", "b1", "b2", "never-made"]);
|
|
122
|
+
for (const id of ["b1", "b2", "never-made", "b0"])
|
|
123
|
+
assert.deepEqual(batch.boundaries.get(id), await readOneBoundary(store, "sc", id), `${id}: the batch answers it as it is answered alone`);
|
|
124
|
+
assert.deepEqual([batch.boundaries.get("b0"), batch.boundaries.get("never-made")], [{ ok: true, boundary: null }, { ok: true, boundary: null }]);
|
|
125
|
+
assert.notDeepEqual(batch.boundaries.get("b1"), batch.boundaries.get("b2"), "two live boundaries read their own versions");
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
run("readBoundaries on an empty list answers an empty map (and a scope with no history answers null for every id)", async () => {
|
|
129
|
+
const store = make();
|
|
130
|
+
if (typeof store.readBoundaries !== "function")
|
|
131
|
+
return;
|
|
132
|
+
assert.deepEqual(await store.readBoundaries("sc", []), { ok: true, boundaries: new Map() });
|
|
133
|
+
assert.deepEqual(await store.readBoundaries("no-history", ["a", "b"]), { ok: true, boundaries: new Map([["a", { ok: true, boundary: null }], ["b", { ok: true, boundary: null }]]) });
|
|
134
|
+
});
|
|
135
|
+
run("readBoundaries agrees with restore (implication form): bytes h ⇒ converged to h; absent ⇒ converged to absent; base_unavailable ⇔ refused base_unavailable; frozen ⇔ left frozen_history — on a boundary before and after files were created, tracked late, and tracked with no capturable base", async () => {
|
|
136
|
+
await withTree(async (dir, env) => {
|
|
137
|
+
const store = make();
|
|
138
|
+
if (typeof store.readBoundaries !== "function")
|
|
139
|
+
return;
|
|
140
|
+
await writeFile(join(dir, "f.txt"), "f0");
|
|
141
|
+
await writeFile(join(dir, "h.txt"), "h0");
|
|
142
|
+
await writeFile(join(dir, "u.txt"), "u0");
|
|
143
|
+
assert.deepEqual(await store.trackEdit("sc", join(dir, "f.txt"), env, dir), { ok: true, minted: true });
|
|
144
|
+
assert.deepEqual(await store.snapshot("sc", "b1", env, dir), { ok: true });
|
|
145
|
+
await writeFile(join(dir, "f.txt"), "f1");
|
|
146
|
+
assert.deepEqual(await store.trackEdit("sc", join(dir, "g.txt"), env, dir), { ok: true, minted: true });
|
|
147
|
+
await writeFile(join(dir, "g.txt"), "g1");
|
|
148
|
+
assert.deepEqual(await store.trackEdit("sc", join(dir, "h.txt"), env, dir), { ok: true, minted: true });
|
|
149
|
+
await writeFile(join(dir, "h.txt"), "h1");
|
|
150
|
+
const hostile = envWithFailingRead(env, async () => ({ ok: false, error: { code: "unknown", message: "pristine unreadable" } }));
|
|
151
|
+
const marked = await store.trackEdit("sc", join(dir, "u.txt"), hostile, dir);
|
|
152
|
+
await writeFile(join(dir, "u.txt"), "u1");
|
|
153
|
+
assert.deepEqual(await store.snapshot("sc", "b2", env, dir), { ok: true });
|
|
154
|
+
await writeFile(join(dir, "f.txt"), "f-drift");
|
|
155
|
+
await rm(join(dir, "g.txt"));
|
|
156
|
+
const atB2 = await boundaryAgreesWithRestore(store, "sc", "b2", env, dir);
|
|
157
|
+
assert.deepEqual(atB2.violations, [], JSON.stringify(atB2));
|
|
158
|
+
const atB1 = await boundaryAgreesWithRestore(store, "sc", "b1", env, dir);
|
|
159
|
+
assert.deepEqual(atB1.violations, [], JSON.stringify(atB1));
|
|
160
|
+
assert.deepEqual(atB1.kinds, marked.ok ? ["absent", "base_unavailable", "bytes", "bytes"] : ["absent", "bytes", "bytes"]);
|
|
161
|
+
assert.deepEqual(atB2.kinds, marked.ok ? ["bytes", "bytes", "bytes", "bytes"] : ["bytes", "bytes", "bytes"]);
|
|
162
|
+
if (store.importHistory === undefined)
|
|
163
|
+
return;
|
|
164
|
+
await mkdir(join(dir, "real"), { recursive: true, mode: 0o700 });
|
|
165
|
+
await writeFile(join(dir, "real", "z.txt"), "z-0");
|
|
166
|
+
await symlink(join(dir, "real"), join(dir, "inl"));
|
|
167
|
+
const zHash = createHash("sha256").update("z-0").digest("hex");
|
|
168
|
+
const envelope = wireEnvelope({
|
|
169
|
+
formatVersion: "file-history/1",
|
|
170
|
+
tracked: [{ relOrAbsPath: "inl/z.txt", keyKind: "root-relative", keyFamily: "posix", baseAvailable: true, versions: [{ version: 1, blobHash: zHash, backupTime: "t" }] }],
|
|
171
|
+
boundaries: [{ entryId: "z0", files: [{ relOrAbsPath: "inl/z.txt", version: 1 }] }],
|
|
172
|
+
});
|
|
173
|
+
assert.deepEqual(await store.importHistory("fz", envelope, async () => new TextEncoder().encode("z-0")), { ok: true });
|
|
174
|
+
assert.deepEqual(await store.snapshot("fz", "z1", env, dir), { ok: true }, "the first boundary records the place: the real directory, not the key's");
|
|
175
|
+
const frozen = await boundaryAgreesWithRestore(store, "fz", "z1", env, dir);
|
|
176
|
+
assert.deepEqual([frozen.violations, frozen.kinds], [[], ["frozen"]], JSON.stringify(frozen));
|
|
177
|
+
});
|
|
178
|
+
});
|
|
85
179
|
run("absent everything: canRestore=false, restore=failed/not_found with an empty ledger, reap=0 — and none of it throws", async () => {
|
|
86
180
|
await withTree(async (dir, env) => {
|
|
87
181
|
const store = make();
|
|
@@ -484,8 +578,9 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
484
578
|
await writeFile(join(dirB, "sub", "f.txt"), "EDITED");
|
|
485
579
|
const envB = new NodeExecutionEnv({ cwd: dirB });
|
|
486
580
|
const r = await store.restore("sc", "b1", envB, dirB);
|
|
487
|
-
assert.equal(r.outcome, "
|
|
488
|
-
assert.deepEqual(r.refused
|
|
581
|
+
assert.equal(r.outcome, "complete", `the under-root version recorded outside this root is left as it is, not refused, got ${JSON.stringify(r)}`);
|
|
582
|
+
assert.deepEqual(r.refused, []);
|
|
583
|
+
assert.deepEqual((r.leftAsIs ?? []).map((f) => [f.path, f.class]), [["sub/f.txt", "recorded_outside_root"]], "the under-root key is root-relative and its version records dirA, outside dirB");
|
|
489
584
|
assert.equal(await readFile(join(dirB, "sub", "f.txt"), "utf8"), "EDITED", "the CURRENT root's same-named file is not written");
|
|
490
585
|
assert.equal(await readFile(join(dirA, "sub", "f.txt"), "utf8"), "EDITED", "the OLD root is not written either (the key was rel, not absolute)");
|
|
491
586
|
assert.equal(await readFile(outsideFile, "utf8"), "P-outside-root", "an outside-root key is verbatim-absolute — it restores where it was captured, root move or not");
|
|
@@ -802,7 +897,7 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
802
897
|
assert.equal(r.modeNotPreserved, 1, "…and the count says so — the honest-absence law, in the ledger");
|
|
803
898
|
});
|
|
804
899
|
});
|
|
805
|
-
run("restore preflight (§7 E5/E4, slice 3): an in-root ancestor swapped for a link OUT of the root is REFUSED per file, a whole-root move
|
|
900
|
+
run("restore preflight (§7 E5/E4, slice 3): an in-root ancestor swapped for a link OUT of the root is REFUSED per file, a whole-root move leaves the file as it is (recorded outside the new root; the version restores where it was recorded), a version recorded under a directory inside the root it is handed is refused as recorded elsewhere, and the rest of the set converges either way", async () => {
|
|
806
901
|
await withTree(async (dir, env) => {
|
|
807
902
|
const store = make();
|
|
808
903
|
const outside = await mkdtemp(join(tmpdir(), "fh-kit-outside-"));
|
|
@@ -839,10 +934,9 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
839
934
|
await mkdir(join(newRoot, "d"), { recursive: true });
|
|
840
935
|
await writeFile(join(newRoot, "d", "f.txt"), "new-root-own");
|
|
841
936
|
const r = await store.restore("sc", "b1", newEnv, newRoot);
|
|
842
|
-
assert.equal(r.outcome, "
|
|
843
|
-
assert.deepEqual(r.refused
|
|
844
|
-
|
|
845
|
-
assert.ok(under === undefined || under === join(oldRoot, "d"), `recordedUnder names the directory the version was recorded under: ${under}`);
|
|
937
|
+
assert.equal(r.outcome, "complete", `a version recorded under a directory outside this root is left as it is, never re-pointed or refused: ${JSON.stringify(r)}`);
|
|
938
|
+
assert.deepEqual(r.refused, []);
|
|
939
|
+
assert.deepEqual((r.leftAsIs ?? []).map((f) => [f.path, f.class, f.place]), [["d/f.txt", "recorded_outside_root", join(oldRoot, "d")]], "the row names the directory the version was recorded under");
|
|
846
940
|
assert.deepEqual(r.filesChanged, []);
|
|
847
941
|
assert.equal(await readFile(join(newRoot, "d", "f.txt"), "utf8"), "new-root-own", "the new root's file is not written");
|
|
848
942
|
assert.equal(await readFile(join(oldRoot, "d", "f.txt"), "utf8"), "old-root-edited", "nor the old root's");
|
|
@@ -851,6 +945,20 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
851
945
|
assert.equal(await readFile(join(oldRoot, "d", "f.txt"), "utf8"), "pristine");
|
|
852
946
|
});
|
|
853
947
|
});
|
|
948
|
+
await withTree(async (r, env) => {
|
|
949
|
+
const store = make();
|
|
950
|
+
const below = join(r, "x");
|
|
951
|
+
await mkdir(below, { recursive: true, mode: 0o700 });
|
|
952
|
+
await writeFile(join(below, "f.txt"), "pristine");
|
|
953
|
+
assert.deepEqual(await store.trackEdit("sc", join(below, "f.txt"), env, below), { ok: true, minted: true });
|
|
954
|
+
assert.deepEqual(await store.snapshot("sc", "b1", env, below), { ok: true });
|
|
955
|
+
await writeFile(join(below, "f.txt"), "edited-below");
|
|
956
|
+
const r2 = await store.restore("sc", "b1", env, r);
|
|
957
|
+
assert.equal(r2.outcome, "partial", JSON.stringify(r2));
|
|
958
|
+
assert.deepEqual([r2.refused.map((f) => [f.path, f.class]), r2.leftAsIs ?? []], [[["f.txt", "recorded_elsewhere"]], []]);
|
|
959
|
+
assert.equal(await readFile(join(below, "f.txt"), "utf8"), "edited-below");
|
|
960
|
+
assert.equal(await existsAt(join(r, "f.txt")), false, "nothing is created at the root's own key path");
|
|
961
|
+
});
|
|
854
962
|
});
|
|
855
963
|
run("K1 one relative name, two files: a boundary taken under another root re-reads each tracked file where it was recorded, never the same-named file it was handed", async () => {
|
|
856
964
|
await withTree(async (r, env) => {
|
|
@@ -914,6 +1022,80 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
914
1022
|
});
|
|
915
1023
|
});
|
|
916
1024
|
});
|
|
1025
|
+
run("K3 one key law: a trackEdit of a path through a link keys the file by its real path — out of the root, the outside file's absolute key (it does not travel; a rewind restores it there); inside it, the real relative name — and the retraction with the proof read names the same record", async () => {
|
|
1026
|
+
await withTree(async (outside) => {
|
|
1027
|
+
await writeFile(join(outside, "o.txt"), "o-0");
|
|
1028
|
+
await withTree(async (r, plain) => {
|
|
1029
|
+
const store = make();
|
|
1030
|
+
await mkdir(join(r, "real"), { recursive: true, mode: 0o700 });
|
|
1031
|
+
await writeFile(join(r, "real", "g.txt"), "g-0");
|
|
1032
|
+
await symlink(outside, join(r, "lnk"));
|
|
1033
|
+
await symlink(join(r, "real"), join(r, "inl"));
|
|
1034
|
+
assert.deepEqual(await store.trackEdit("sc", join(r, "lnk", "o.txt"), plain, r), { ok: true, minted: true });
|
|
1035
|
+
assert.deepEqual(await store.trackEdit("sc", join(outside, "o.txt"), plain, r), { ok: true, minted: false }, "the outside file by its real path is the same entry");
|
|
1036
|
+
assert.deepEqual(await store.trackEdit("sc", join(r, "inl", "g.txt"), plain, r), { ok: true, minted: true });
|
|
1037
|
+
assert.deepEqual(await store.trackEdit("sc", join(r, "real", "g.txt"), plain, r), { ok: true, minted: false }, "the inside file by its real path is the same entry");
|
|
1038
|
+
assert.deepEqual(await store.trackEdit("sc", join(r, "lnk", "new.txt"), plain, r), { ok: true, minted: true });
|
|
1039
|
+
assert.deepEqual(await store.annulTrack("sc", join(r, "lnk", "new.txt"), r, { env: plain }), { ok: true });
|
|
1040
|
+
assert.deepEqual(await store.trackEdit("sc", join(outside, "new.txt"), plain, r), { ok: true, minted: true }, "the retraction removed the record the touch through the link made");
|
|
1041
|
+
assert.deepEqual(await store.annulTrack("sc", join(outside, "new.txt"), r), { ok: true });
|
|
1042
|
+
assert.deepEqual(await store.snapshot("sc", "b1", plain, r), { ok: true });
|
|
1043
|
+
if (store.exportHistory !== undefined) {
|
|
1044
|
+
const e = await store.exportHistory("sc");
|
|
1045
|
+
assert.ok(e.ok && e.history !== null, JSON.stringify(e));
|
|
1046
|
+
assert.deepEqual([e.history.tracked.map((t) => t.relOrAbsPath), e.history.absoluteEntriesOmitted, e.history.frozenEntryKeys], [["real/g.txt"], 1, undefined]);
|
|
1047
|
+
}
|
|
1048
|
+
await writeFile(join(outside, "o.txt"), "o-1");
|
|
1049
|
+
await rm(join(r, "lnk"));
|
|
1050
|
+
const res = await store.restore("sc", "b1", plain, r);
|
|
1051
|
+
assert.deepEqual([res.outcome, res.leftAsIs], ["complete", undefined], JSON.stringify(res));
|
|
1052
|
+
assert.equal(await readFile(join(outside, "o.txt"), "utf8"), "o-0", "restored where the file is");
|
|
1053
|
+
});
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
run("K4 an entry recorded through a link on its key's path is frozen: a key imported through a link inside the root, once a boundary has recorded its place, is never read by a boundary again, a restore leaves it as it is and lists it in `leftAsIs` with the class `frozen_history` (outcome unaffected, nothing written), and an export leaves it out and names its key", async () => {
|
|
1057
|
+
await withTree(async (r, plain) => {
|
|
1058
|
+
const store = make();
|
|
1059
|
+
if (store.importHistory === undefined)
|
|
1060
|
+
return;
|
|
1061
|
+
await mkdir(join(r, "real"), { recursive: true, mode: 0o700 });
|
|
1062
|
+
await writeFile(join(r, "real", "g.txt"), "g-0");
|
|
1063
|
+
await symlink(join(r, "real"), join(r, "inl"));
|
|
1064
|
+
const hash = createHash("sha256").update("g-0").digest("hex");
|
|
1065
|
+
const envelope = wireEnvelope({
|
|
1066
|
+
formatVersion: "file-history/1",
|
|
1067
|
+
tracked: [{ relOrAbsPath: "inl/g.txt", keyKind: "root-relative", keyFamily: "posix", baseAvailable: true, versions: [{ version: 1, blobHash: hash, backupTime: "t" }] }],
|
|
1068
|
+
boundaries: [{ entryId: "b0", files: [{ relOrAbsPath: "inl/g.txt", version: 1 }] }],
|
|
1069
|
+
});
|
|
1070
|
+
assert.deepEqual(await store.importHistory("sc", envelope, async () => new TextEncoder().encode("g-0")), { ok: true });
|
|
1071
|
+
assert.deepEqual(await store.snapshot("sc", "b1", plain, r), { ok: true }, "the first boundary records the place: the real directory, not the key's");
|
|
1072
|
+
await writeFile(join(r, "real", "g.txt"), "g-1");
|
|
1073
|
+
const seen = [];
|
|
1074
|
+
const env = new Proxy(plain, {
|
|
1075
|
+
get(target, prop, receiver) {
|
|
1076
|
+
const value = Reflect.get(target, prop, receiver);
|
|
1077
|
+
if (typeof value !== "function")
|
|
1078
|
+
return value;
|
|
1079
|
+
const fn = value;
|
|
1080
|
+
return (...args) => {
|
|
1081
|
+
if ((prop === "readBinaryFile" || prop === "readTextFile" || prop === "readTextLines" || prop === "openBound" || prop === "writeFile" || prop === "writeFileGuarded" || prop === "remove") && typeof args[0] === "string")
|
|
1082
|
+
seen.push(`${String(prop)} ${args[0]}`);
|
|
1083
|
+
return fn.apply(target, args);
|
|
1084
|
+
};
|
|
1085
|
+
},
|
|
1086
|
+
});
|
|
1087
|
+
assert.deepEqual(await store.snapshot("sc", "b2", env, r), { ok: true });
|
|
1088
|
+
const res = await store.restore("sc", "b1", env, r);
|
|
1089
|
+
assert.deepEqual([res.outcome, res.filesChanged, res.refused, res.leftAsIs?.map((f) => [f.path, f.class, f.place])], ["complete", [], [], [["inl/g.txt", "frozen_history", join(r, "real")]]], JSON.stringify(res));
|
|
1090
|
+
assert.deepEqual(seen, [], "neither the boundary nor the restore reads or writes the frozen file");
|
|
1091
|
+
assert.equal(await readFile(join(r, "real", "g.txt"), "utf8"), "g-1");
|
|
1092
|
+
if (store.exportHistory !== undefined) {
|
|
1093
|
+
const e = await store.exportHistory("sc");
|
|
1094
|
+
assert.ok(e.ok && e.history !== null, JSON.stringify(e));
|
|
1095
|
+
assert.deepEqual([e.history.tracked.map((t) => t.relOrAbsPath), e.history.frozenEntryKeys], [[], ["inl/g.txt"]]);
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
});
|
|
917
1099
|
run("W1 a second file whose root-relative name another directory's file already keys is tracked under its own absolute key, and a rewind restores it where it was recorded", async () => {
|
|
918
1100
|
await withTree(async (a, envA) => {
|
|
919
1101
|
await withTree(async (b, envB) => {
|
|
@@ -937,6 +1119,29 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
937
1119
|
});
|
|
938
1120
|
});
|
|
939
1121
|
});
|
|
1122
|
+
run("FC the key choice after a carry: a fork whose carried history keys A's f.txt, handed B, edits B's own f.txt — a first touch of its own under its absolute key, restored at B (W1 holds the same choice within one session; this cell holds it across adoptScope, which must carry each version's place)", async () => {
|
|
1123
|
+
await withTree(async (a, envA) => {
|
|
1124
|
+
await withTree(async (b, envB) => {
|
|
1125
|
+
const store = make();
|
|
1126
|
+
await writeFile(join(a, "f.txt"), "a-0");
|
|
1127
|
+
await writeFile(join(b, "f.txt"), "b-0");
|
|
1128
|
+
assert.deepEqual(await store.trackEdit("src", join(a, "f.txt"), envA, a), { ok: true, minted: true });
|
|
1129
|
+
assert.deepEqual(await store.snapshot("src", "b1", envA, a), { ok: true });
|
|
1130
|
+
await writeFile(join(a, "f.txt"), "a-1");
|
|
1131
|
+
assert.deepEqual(await store.adoptScope("src", "fork"), { ok: true });
|
|
1132
|
+
assert.deepEqual(await store.snapshot("fork", "b2", envB, b), { ok: true });
|
|
1133
|
+
assert.deepEqual(await store.trackEdit("fork", join(b, "f.txt"), envB, b), { ok: true, minted: true }, "after a carry, the second file is still a first touch of its own (the carried entry's place is another directory)");
|
|
1134
|
+
assert.deepEqual(await store.trackEdit("fork", join(b, "g.txt"), envB, b), { ok: true, minted: true });
|
|
1135
|
+
await writeFile(join(b, "f.txt"), "b-1");
|
|
1136
|
+
await writeFile(join(b, "g.txt"), "b-g");
|
|
1137
|
+
const r = await store.restore("fork", "b2", envB, b);
|
|
1138
|
+
assert.equal(r.outcome, "complete", JSON.stringify(r));
|
|
1139
|
+
assert.equal(await readFile(join(b, "f.txt"), "utf8"), "b-0", "B's own edit is restored at B");
|
|
1140
|
+
assert.equal(await existsAt(join(b, "g.txt")), false, "B's created file is removed");
|
|
1141
|
+
assert.equal(await readFile(join(a, "f.txt"), "utf8"), "a-1", "A's file is not written by the fork's rewind");
|
|
1142
|
+
});
|
|
1143
|
+
});
|
|
1144
|
+
});
|
|
940
1145
|
run("a version that records no directory (an older engine's row) is refused place_unrecorded, unless the rewind names the directory such versions were recorded under — then the one place comparison judges it", async () => {
|
|
941
1146
|
await withTree(async (dir, env) => {
|
|
942
1147
|
const src = make();
|
|
@@ -957,7 +1162,7 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
957
1162
|
assert.equal(await readFile(join(dir, "f.txt"), "utf8"), "edited");
|
|
958
1163
|
await withTree(async (elsewhere) => {
|
|
959
1164
|
const named = await src.restore("old", "b1", env, dir, undefined, { unplacedHistoryRecordedUnder: elsewhere });
|
|
960
|
-
assert.deepEqual(named.refused.map((f) => [f.path, f.class]), [["f.txt", "
|
|
1165
|
+
assert.deepEqual([named.refused, (named.leftAsIs ?? []).map((f) => [f.path, f.class])], [[], [["f.txt", "recorded_outside_root"]]], `a named directory that is not this one is the same comparison (outside this root: left as it is): ${JSON.stringify(named)}`);
|
|
961
1166
|
assert.equal(await readFile(join(dir, "f.txt"), "utf8"), "edited");
|
|
962
1167
|
});
|
|
963
1168
|
const here = await src.restore("old", "b1", env, dir, undefined, { unplacedHistoryRecordedUnder: dir });
|
|
@@ -992,23 +1197,21 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
992
1197
|
}
|
|
993
1198
|
});
|
|
994
1199
|
});
|
|
995
|
-
run("
|
|
1200
|
+
run("the planned restore (a rewind's preview: this store's `restore` on a view that writes nothing) lists exactly the files a restore WOULD change with their line arithmetic; an already-converged tracked set plans nothing; no boundary at all is the restore's own not_found — never an empty plan", async () => {
|
|
996
1201
|
await withTree(async (dir, env) => {
|
|
997
1202
|
const store = make();
|
|
998
|
-
|
|
999
|
-
return;
|
|
1203
|
+
const plan = (entryId) => planFileHistoryRestore(store, { scope: "sc", entryId, env, root: dir });
|
|
1000
1204
|
await writeFile(join(dir, "edited.txt"), "one\ntwo\nthree\n");
|
|
1001
1205
|
await writeFile(join(dir, "untouched.txt"), "same\n");
|
|
1002
1206
|
assert.deepEqual(await store.trackEdit("sc", join(dir, "edited.txt"), env, dir), { ok: true, minted: true });
|
|
1003
1207
|
assert.deepEqual(await store.trackEdit("sc", join(dir, "untouched.txt"), env, dir), { ok: true, minted: true });
|
|
1004
1208
|
assert.deepEqual(await store.snapshot("sc", "b1", env, dir), { ok: true });
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1209
|
+
const none = await plan("no-such-boundary");
|
|
1210
|
+
assert.deepEqual([none.restore.outcome, none.restore.error?.code, none.restore.files], ["failed", "not_found", []]);
|
|
1211
|
+
const quiet = (await plan("b1")).diffStats;
|
|
1008
1212
|
assert.deepEqual({ filesChanged: quiet.filesChanged, insertions: quiet.insertions, deletions: quiet.deletions }, { filesChanged: [], insertions: 0, deletions: 0 });
|
|
1009
1213
|
await writeFile(join(dir, "edited.txt"), "one\nTWO\nthree\nfour\n");
|
|
1010
|
-
const preview = await
|
|
1011
|
-
assert.notEqual(preview, null);
|
|
1214
|
+
const preview = (await plan("b1")).diffStats;
|
|
1012
1215
|
assert.deepEqual(preview.filesChanged, [key(dir, join(dir, "edited.txt"))], "an unchanged tracked file is not a change");
|
|
1013
1216
|
assert.deepEqual({ insertions: preview.insertions, deletions: preview.deletions }, { insertions: 1, deletions: 2 });
|
|
1014
1217
|
const restored = await store.restore("sc", "b1", env, dir);
|
|
@@ -1016,16 +1219,73 @@ export async function fileHistoryStoreContract(make, runAssertion, onOptionalMem
|
|
|
1016
1219
|
await chmod(join(dir, "edited.txt"), 0o600);
|
|
1017
1220
|
if (((await stat(join(dir, "edited.txt"))).mode & 0o7777) !== 0o600)
|
|
1018
1221
|
return;
|
|
1019
|
-
const modePreview = await
|
|
1020
|
-
assert.
|
|
1021
|
-
assert.deepEqual(modePreview.filesChanged, [key(dir, join(dir, "edited.txt"))], "a mode-only restoration is a change the preview must list");
|
|
1222
|
+
const modePreview = (await plan("b1")).diffStats;
|
|
1223
|
+
assert.deepEqual(modePreview.filesChanged, [key(dir, join(dir, "edited.txt"))], "a mode-only restoration is a change the plan must list");
|
|
1022
1224
|
assert.deepEqual({ insertions: modePreview.insertions, deletions: modePreview.deletions }, { insertions: 0, deletions: 0 }, "…and it moves no lines");
|
|
1023
1225
|
const modeRestored = await store.restore("sc", "b1", env, dir);
|
|
1024
|
-
assert.deepEqual(modeRestored.filesChanged, modePreview.filesChanged, "
|
|
1226
|
+
assert.deepEqual(modeRestored.filesChanged, modePreview.filesChanged, "plan and operation agree on the mode-only arm too");
|
|
1025
1227
|
});
|
|
1026
1228
|
});
|
|
1027
1229
|
await settle();
|
|
1028
1230
|
}
|
|
1231
|
+
async function readOneBoundary(store, scope, entryId) {
|
|
1232
|
+
const batch = await store.readBoundaries(scope, [entryId]);
|
|
1233
|
+
assert.ok(batch.ok, `readBoundaries(${scope}, [${entryId}]) could not answer: ${JSON.stringify(batch)}`);
|
|
1234
|
+
assert.deepEqual([...batch.boundaries.keys()], [entryId], "a batch of one holds that id and nothing else");
|
|
1235
|
+
return batch.boundaries.get(entryId);
|
|
1236
|
+
}
|
|
1237
|
+
async function boundaryAgreesWithRestore(store, scope, entryId, env, dir) {
|
|
1238
|
+
const read = await readOneBoundary(store, scope, entryId);
|
|
1239
|
+
if (!read.ok || read.boundary === null)
|
|
1240
|
+
return { violations: [`readBoundaries(${entryId}) answered ${JSON.stringify(read)}`], kinds: [] };
|
|
1241
|
+
const entries = read.boundary.entries;
|
|
1242
|
+
const targetOf = new Map(entries.map((e) => [e.key, e.target]));
|
|
1243
|
+
const plan = (await planFileHistoryRestore(store, { scope, entryId, env, root: dir })).restore;
|
|
1244
|
+
const restored = await store.restore(scope, entryId, env, dir);
|
|
1245
|
+
const converged = new Set([...restored.filesChanged, ...restored.identicalSkipped]);
|
|
1246
|
+
const refusedBase = new Set(plan.refused.filter((r) => r.class === "base_unavailable").map((r) => r.path));
|
|
1247
|
+
const leftFrozen = new Set((plan.leftAsIs ?? []).filter((r) => r.class === "frozen_history").map((r) => r.path));
|
|
1248
|
+
const failed = new Set(plan.failed.map((r) => r.path));
|
|
1249
|
+
const violations = [];
|
|
1250
|
+
const at = (k) => (isAbsolute(k) ? k : join(dir, k));
|
|
1251
|
+
for (const { key: k, target } of entries) {
|
|
1252
|
+
switch (target.kind) {
|
|
1253
|
+
case "bytes": {
|
|
1254
|
+
const bytes = converged.has(k) ? await readFile(at(k)).catch(() => undefined) : undefined;
|
|
1255
|
+
if (bytes === undefined || createHash("sha256").update(bytes).digest("hex") !== target.hash)
|
|
1256
|
+
violations.push(`${k}: bytes ${target.hash.slice(0, 8)} but the restore did not converge it there`);
|
|
1257
|
+
break;
|
|
1258
|
+
}
|
|
1259
|
+
case "absent":
|
|
1260
|
+
if (!converged.has(k) || (await existsAt(at(k))))
|
|
1261
|
+
violations.push(`${k}: absent but the restore did not converge it to absent`);
|
|
1262
|
+
break;
|
|
1263
|
+
case "base_unavailable":
|
|
1264
|
+
if (!refusedBase.has(k))
|
|
1265
|
+
violations.push(`${k}: base_unavailable but the restore did not refuse it base_unavailable`);
|
|
1266
|
+
break;
|
|
1267
|
+
case "frozen":
|
|
1268
|
+
if (!leftFrozen.has(k))
|
|
1269
|
+
violations.push(`${k}: frozen but the restore did not leave it frozen_history`);
|
|
1270
|
+
break;
|
|
1271
|
+
case "record_missing":
|
|
1272
|
+
if (!failed.has(k))
|
|
1273
|
+
violations.push(`${k}: record_missing but the restore did not fail it`);
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
for (const k of refusedBase)
|
|
1278
|
+
if (targetOf.get(k)?.kind !== "base_unavailable")
|
|
1279
|
+
violations.push(`${k}: refused base_unavailable but read ${targetOf.get(k)?.kind ?? "no entry"}`);
|
|
1280
|
+
for (const k of leftFrozen)
|
|
1281
|
+
if (targetOf.get(k)?.kind !== "frozen")
|
|
1282
|
+
violations.push(`${k}: left frozen_history but read ${targetOf.get(k)?.kind ?? "no entry"}`);
|
|
1283
|
+
const named = [...plan.filesChanged, ...plan.identicalSkipped, ...plan.refused.map((r) => r.path), ...plan.failed.map((r) => r.path), ...(plan.leftAsIs ?? []).map((r) => r.path)];
|
|
1284
|
+
for (const k of named)
|
|
1285
|
+
if (!targetOf.has(k))
|
|
1286
|
+
violations.push(`${k}: the restore names it, the seat did not read it`);
|
|
1287
|
+
return { violations, kinds: entries.map((e) => e.target.kind).sort() };
|
|
1288
|
+
}
|
|
1029
1289
|
function key(root, absPath) {
|
|
1030
1290
|
return absPath.slice(root.length + 1).replace(/\\/g, "/");
|
|
1031
1291
|
}
|
|
@@ -9,6 +9,11 @@ const B = "KitToolB";
|
|
|
9
9
|
const fresh = () => `kit-2151-${randomUUID()}`;
|
|
10
10
|
const declared = (rules) => ({ ...rules, grammar: G });
|
|
11
11
|
const replayed = (row) => ({ ...row, grammar: row.grammar ?? 0 });
|
|
12
|
+
const pair = () => {
|
|
13
|
+
const id = randomUUID();
|
|
14
|
+
return { from: `kit-rekey-from-${id}`, to: `kit-rekey-to-${id}` };
|
|
15
|
+
};
|
|
16
|
+
const owner = (principal) => ({ kind: "principal", principal });
|
|
12
17
|
const isLoosenRefusal = (e) => e instanceof SessionPolicyError && e.code === "loosen_forbidden";
|
|
13
18
|
const isGrammarRequired = (e) => e instanceof SessionPolicyError && e.code === "grammar_required";
|
|
14
19
|
async function partOf(store, sessionId) {
|
|
@@ -147,5 +152,202 @@ export async function sessionPolicyStoreContract(make, runAssertion) {
|
|
|
147
152
|
assert.equal(row?.rev, stored.rev);
|
|
148
153
|
assert.deepEqual(row?.toolDeny, [A]);
|
|
149
154
|
});
|
|
155
|
+
run("rekeyPrincipal is a member; a plan over an owner with no rows is empty, and so is a move onto the same principal", async () => {
|
|
156
|
+
const store = make();
|
|
157
|
+
const { from } = pair();
|
|
158
|
+
assert.equal(typeof store.rekeyPrincipal, "function");
|
|
159
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: `${from}-elsewhere`, mode: "plan" }), { kind: "plan", rows: 0, conflicting: 0 });
|
|
160
|
+
const sid = fresh();
|
|
161
|
+
await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
162
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: from, mode: "plan" }), { kind: "plan", rows: 0, conflicting: 0 });
|
|
163
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: from, mode: "arrive" }), { kind: "done", mode: "arrive", rows: 0 });
|
|
164
|
+
});
|
|
165
|
+
run("plan → arrive → leave re-files the row: arrive leaves the source rules in place, the target reads them at the row's own stamp, leave erases the source and a second plan finds nothing left", async () => {
|
|
166
|
+
const store = make();
|
|
167
|
+
const { from, to } = pair();
|
|
168
|
+
const sid = fresh();
|
|
169
|
+
await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
170
|
+
const source = await store.putRules(sid, from, declared({ toolDeny: [A, B] }));
|
|
171
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "plan" }), { kind: "plan", rows: 1, conflicting: 0 });
|
|
172
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" }), { kind: "done", mode: "arrive", rows: 1 });
|
|
173
|
+
assert.deepEqual((await store.getRules(sid, from))?.toolDeny, [A, B], "arrive moves no source rule");
|
|
174
|
+
const arrived = await store.getRules(sid, to);
|
|
175
|
+
assert.deepEqual(arrived?.toolDeny, [A, B]);
|
|
176
|
+
assert.equal(arrived?.rev, source.rev, "a target with no mark takes the row's own stamp");
|
|
177
|
+
assert.equal(arrived?.gen ?? 0, source.gen ?? 0);
|
|
178
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "leave" }), { kind: "done", mode: "leave", rows: 1 });
|
|
179
|
+
assert.equal(await store.getRules(sid, from), null);
|
|
180
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "plan" }), { kind: "plan", rows: 0, conflicting: 0 });
|
|
181
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "leave" }), { kind: "done", mode: "leave", rows: 0 });
|
|
182
|
+
assert.equal((await store.getRules(sid, to))?.rev, source.rev);
|
|
183
|
+
});
|
|
184
|
+
run("after leave the source key's next write climbs past the row that left and opens a new lineage", async () => {
|
|
185
|
+
const store = make();
|
|
186
|
+
const { from, to } = pair();
|
|
187
|
+
const sid = fresh();
|
|
188
|
+
await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
189
|
+
const source = await store.putRules(sid, from, declared({ toolDeny: [A, B] }));
|
|
190
|
+
await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" });
|
|
191
|
+
await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "leave" });
|
|
192
|
+
const again = await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
193
|
+
assert.ok(again.rev > source.rev, `rev ${again.rev} must climb past ${source.rev}`);
|
|
194
|
+
assert.ok((again.gen ?? 0) > (source.gen ?? 0), "the erase step opened the next lineage");
|
|
195
|
+
});
|
|
196
|
+
run("a target row that is not this move's arrival makes arrive a conflict with nothing written — equal rules included", async () => {
|
|
197
|
+
const store = make();
|
|
198
|
+
const { from, to } = pair();
|
|
199
|
+
const sid = fresh();
|
|
200
|
+
const source = await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
201
|
+
const target = await store.putRules(sid, to, declared({ toolDeny: [A] }));
|
|
202
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "plan" }), { kind: "plan", rows: 1, conflicting: 1 });
|
|
203
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" }), { kind: "conflict", mode: "arrive", rows: 1, conflicting: 1 });
|
|
204
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "leave" }), { kind: "done", mode: "leave", rows: 0 });
|
|
205
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "withdraw" }), { kind: "done", mode: "withdraw", rows: 0 });
|
|
206
|
+
const s = await store.getRules(sid, from);
|
|
207
|
+
const t = await store.getRules(sid, to);
|
|
208
|
+
assert.equal(s?.rev, source.rev);
|
|
209
|
+
assert.equal(t?.rev, target.rev);
|
|
210
|
+
assert.deepEqual([s?.toolDeny, t?.toolDeny], [[A], [A]]);
|
|
211
|
+
});
|
|
212
|
+
run("withdraw erases the arrival and clears the record: the source rules stay, leave then erases nothing, and a later arrive lands above the withdrawn lineage", async () => {
|
|
213
|
+
const store = make();
|
|
214
|
+
const { from, to } = pair();
|
|
215
|
+
const sid = fresh();
|
|
216
|
+
await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
217
|
+
const source = await store.putRules(sid, from, declared({ toolDeny: [A, B] }));
|
|
218
|
+
await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" });
|
|
219
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "withdraw" }), { kind: "done", mode: "withdraw", rows: 1 });
|
|
220
|
+
assert.equal(await store.getRules(sid, to), null);
|
|
221
|
+
const kept = await store.getRules(sid, from);
|
|
222
|
+
assert.equal(kept?.rev, source.rev);
|
|
223
|
+
assert.deepEqual(kept?.toolDeny, [A, B]);
|
|
224
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "leave" }), { kind: "done", mode: "leave", rows: 0 }, "the record is gone");
|
|
225
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" }), { kind: "done", mode: "arrive", rows: 1 });
|
|
226
|
+
const again = await store.getRules(sid, to);
|
|
227
|
+
assert.ok(again !== null && again.rev > source.rev && (again.gen ?? 0) > (source.gen ?? 0), "the second arrival lands above the withdrawn one, in a new lineage");
|
|
228
|
+
});
|
|
229
|
+
run("an ordinary write of the source after arrive drops the record: leave keeps that row, and a plan reports it", async () => {
|
|
230
|
+
const store = make();
|
|
231
|
+
const { from, to } = pair();
|
|
232
|
+
const sid = fresh();
|
|
233
|
+
await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
234
|
+
await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" });
|
|
235
|
+
await store.putRules(sid, from, declared({ toolDeny: [A, B] }));
|
|
236
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "leave" }), { kind: "done", mode: "leave", rows: 0 });
|
|
237
|
+
assert.deepEqual((await store.getRules(sid, from))?.toolDeny, [A, B], "the confirmed write is not lost");
|
|
238
|
+
assert.deepEqual(await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "plan" }), { kind: "plan", rows: 1, conflicting: 1 });
|
|
239
|
+
});
|
|
240
|
+
run("the counters: a target whose lineage was erased raises the arrival to its next write, and a mark-only source raises the target's floor", async () => {
|
|
241
|
+
const store = make();
|
|
242
|
+
if (store.deleteBySession === undefined)
|
|
243
|
+
return;
|
|
244
|
+
const { from, to } = pair();
|
|
245
|
+
const sid = fresh();
|
|
246
|
+
for (const deny of [[A], [A, B], [B]])
|
|
247
|
+
await store.putRules(sid, to, declared({ toolDeny: deny }));
|
|
248
|
+
await store.deleteBySession(sid);
|
|
249
|
+
const source = await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
250
|
+
await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" });
|
|
251
|
+
const arrived = await store.getRules(sid, to);
|
|
252
|
+
assert.equal(arrived?.rev, 4, "the per-position maximum of the row's (1, 0) and the target's next write");
|
|
253
|
+
assert.ok((arrived?.gen ?? 0) > (source.gen ?? 0), "the arrival opens the target's next lineage, never one it erased");
|
|
254
|
+
const markOnly = fresh();
|
|
255
|
+
for (const deny of [[A], [A, B], [B]])
|
|
256
|
+
await store.putRules(markOnly, from, declared({ toolDeny: deny }));
|
|
257
|
+
await store.deleteBySession(markOnly);
|
|
258
|
+
await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" });
|
|
259
|
+
const first = await store.putRules(markOnly, to, declared({ toolDeny: [A] }));
|
|
260
|
+
assert.ok(first.rev > 3 && (first.gen ?? 0) >= 1, `the target's first write (${first.rev}, ${first.gen}) climbs past the source's mark`);
|
|
261
|
+
});
|
|
262
|
+
run("a floor a mark-only source raised over a live target row outlives the target's next write: the erase after it opens a lineage above every one the source wore", async () => {
|
|
263
|
+
const store = make();
|
|
264
|
+
if (store.deleteBySession === undefined)
|
|
265
|
+
return;
|
|
266
|
+
const { from, to } = pair();
|
|
267
|
+
const sid = fresh();
|
|
268
|
+
let worn = 0;
|
|
269
|
+
for (const deny of [[A], [B]]) {
|
|
270
|
+
worn = Math.max(worn, (await store.putRules(sid, from, declared({ toolDeny: deny }))).gen ?? 0);
|
|
271
|
+
await store.deleteBySession(sid);
|
|
272
|
+
}
|
|
273
|
+
await store.putRules(sid, to, declared({ toolDeny: [A] }));
|
|
274
|
+
await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" });
|
|
275
|
+
await store.putRules(sid, to, declared({ toolDeny: [A, B] }));
|
|
276
|
+
await store.deleteBySession(sid);
|
|
277
|
+
const again = await store.putRules(sid, to, declared({ toolDeny: [A] }));
|
|
278
|
+
assert.ok((again.gen ?? 0) > worn, `the target's lineage after its erase (${again.gen}) must be above every lineage the source wore (${worn})`);
|
|
279
|
+
});
|
|
280
|
+
run("a withdrawn lineage is never handed to a later arrival", async () => {
|
|
281
|
+
const store = make();
|
|
282
|
+
if (store.deleteBySession === undefined)
|
|
283
|
+
return;
|
|
284
|
+
const { from, to } = pair();
|
|
285
|
+
const other = `${from}-c`;
|
|
286
|
+
const sid = fresh();
|
|
287
|
+
await store.putRules(sid, to, declared({ toolDeny: [A] }));
|
|
288
|
+
for (let i = 0; i < 5; i++) {
|
|
289
|
+
await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
290
|
+
await store.putRules(sid, other, declared({ toolDeny: [A] }));
|
|
291
|
+
await store.deleteBySession(sid);
|
|
292
|
+
}
|
|
293
|
+
for (let i = 0; i < 5; i++)
|
|
294
|
+
await store.putRules(sid, from, declared({ toolDeny: i % 2 === 0 ? [A, B] : [A] }));
|
|
295
|
+
for (let i = 0; i < 15; i++)
|
|
296
|
+
await store.putRules(sid, other, declared({ toolDeny: i % 2 === 0 ? [A, B] : [A] }));
|
|
297
|
+
const a = await store.getRules(sid, from);
|
|
298
|
+
const c = await store.getRules(sid, other);
|
|
299
|
+
assert.equal(a?.gen, c?.gen, "the two sources share one lineage number");
|
|
300
|
+
await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "arrive" });
|
|
301
|
+
const withdrawn = await store.getRules(sid, to);
|
|
302
|
+
await store.rekeyPrincipal({ from: owner(from), toPrincipal: to, mode: "withdraw" });
|
|
303
|
+
await store.rekeyPrincipal({ from: owner(other), toPrincipal: to, mode: "arrive" });
|
|
304
|
+
const later = await store.getRules(sid, to);
|
|
305
|
+
assert.ok(withdrawn !== null && later !== null);
|
|
306
|
+
assert.notEqual(later.gen ?? 0, withdrawn.gen ?? 0, "the later arrival must not continue the withdrawn lineage");
|
|
307
|
+
});
|
|
308
|
+
run("the input is read before anything else: a malformed one is a TypeError and nothing is written", async () => {
|
|
309
|
+
const store = make();
|
|
310
|
+
const unchecked = store;
|
|
311
|
+
const { from, to } = pair();
|
|
312
|
+
const sid = fresh();
|
|
313
|
+
await store.putRules(sid, from, declared({ toolDeny: [A] }));
|
|
314
|
+
const bad = [
|
|
315
|
+
undefined,
|
|
316
|
+
{ from: owner(from), toPrincipal: to },
|
|
317
|
+
{ from: owner(from), toPrincipal: to, mode: "apply" },
|
|
318
|
+
{ from: owner(from), toPrincipal: to, mode: "plan", dryRun: true },
|
|
319
|
+
{ from: { kind: "principal", principal: " " }, toPrincipal: to, mode: "arrive" },
|
|
320
|
+
{ from: owner(from), toPrincipal: "", mode: "arrive" },
|
|
321
|
+
];
|
|
322
|
+
for (const input of bad)
|
|
323
|
+
await assert.rejects(unchecked.rekeyPrincipal(input), TypeError, JSON.stringify(input) ?? "undefined");
|
|
324
|
+
assert.equal(await store.getRules(sid, to), null);
|
|
325
|
+
assert.deepEqual((await store.getRules(sid, from))?.toolDeny, [A]);
|
|
326
|
+
});
|
|
327
|
+
run("a write declaring an earlier grammar is stored in that grammar — the stamp is the grammar the judge read the entries in, on a fresh key and over a row", async () => {
|
|
328
|
+
const store = make();
|
|
329
|
+
const sid = fresh();
|
|
330
|
+
const first = await store.putRules(sid, OWNER, { toolDeny: [A], grammar: 4 }, { operator: true });
|
|
331
|
+
assert.equal(first.grammar, 4);
|
|
332
|
+
const over = await store.putRules(sid, OWNER, { toolDeny: [A, B], grammar: 4 }, { expectedRev: first.rev });
|
|
333
|
+
assert.equal(over.grammar, 4);
|
|
334
|
+
const row = await store.getRules(sid, OWNER);
|
|
335
|
+
assert.equal(row?.grammar, 4);
|
|
336
|
+
assert.deepEqual(row?.toolDeny, [A, B]);
|
|
337
|
+
});
|
|
338
|
+
run("a non-operator write declaring a grammar older than the stored rules it is compared against is refused `grammar_older_than_rules`, nothing written", async () => {
|
|
339
|
+
const store = make();
|
|
340
|
+
const sid = fresh();
|
|
341
|
+
const stored = await store.putRules(sid, OWNER, declared({ toolDeny: [A] }), { operator: true });
|
|
342
|
+
await assert.rejects(store.putRules(sid, OWNER, { toolDeny: [A, B], grammar: G - 1 }, { expectedRev: stored.rev }), (e) => {
|
|
343
|
+
if (!(e instanceof SessionPolicyError && e.code === "grammar_older_than_rules"))
|
|
344
|
+
return false;
|
|
345
|
+
assert.deepEqual({ declared: e.detail.declaredGrammar, rules: e.detail.rulesGrammar }, { declared: G - 1, rules: G });
|
|
346
|
+
return true;
|
|
347
|
+
});
|
|
348
|
+
const row = await store.getRules(sid, OWNER);
|
|
349
|
+
assert.equal(row?.rev, stored.rev);
|
|
350
|
+
assert.deepEqual(row?.toolDeny, [A]);
|
|
351
|
+
});
|
|
150
352
|
await settle();
|
|
151
353
|
}
|