@sema-agent/core 7.72.0 → 7.74.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 +565 -0
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +46 -2
- package/dist/agents/list-agents-tool.js +1 -1
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/retain-ledger.js +3 -3
- package/dist/agents/send-message-tool.js +5 -4
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +43 -12
- package/dist/agents/verify.js +23 -8
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.d.ts +42 -1
- package/dist/brain/anthropic.js +68 -13
- package/dist/brain/failover.d.ts +5 -0
- package/dist/brain/failover.js +51 -22
- package/dist/brain/model-lane.d.ts +12 -3
- package/dist/brain/model-lane.js +5 -5
- package/dist/brain/open-responses.js +7 -8
- package/dist/brain/openai.js +31 -24
- package/dist/brain/route-adjudicator.d.ts +33 -4
- package/dist/brain/route-adjudicator.js +49 -12
- package/dist/brain/stream-engine.js +166 -156
- package/dist/brain/stream-shared.d.ts +4 -3
- package/dist/brain/stream-shared.js +2 -2
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/allow-entry.js +4 -4
- package/dist/core/ask-class.d.ts +2 -2
- package/dist/core/ask-headline.d.ts +1 -1
- package/dist/core/ask-origin.d.ts +44 -4
- package/dist/core/ask-origin.js +29 -10
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/background-agent-store.d.ts +1 -0
- package/dist/core/background-agent-store.js +49 -8
- package/dist/core/checkpoint-features.d.ts +3 -2
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +9 -3
- package/dist/core/checkpoint-store.d.ts +26 -2
- package/dist/core/checkpoint-store.js +9 -2
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/cron.js +9 -1
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/deployment-shape.d.ts +7 -0
- package/dist/core/deployment-shape.js +19 -0
- package/dist/core/engine-capabilities.d.ts +13 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +41 -28
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/gate-fold.js +5 -4
- package/dist/core/gate-lanes.js +8 -12
- package/dist/core/gate-outcome.d.ts +8 -2
- package/dist/core/gate-outcome.js +10 -3
- package/dist/core/governance-codes.d.ts +14 -2
- package/dist/core/governance-codes.js +22 -6
- package/dist/core/hook-condition.d.ts +37 -0
- package/dist/core/hook-condition.js +567 -0
- package/dist/core/hooks.d.ts +5 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +18 -13
- package/dist/core/memory-engine/scope-contract.js +18 -18
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +25 -6
- package/dist/core/mode-policy.js +33 -8
- package/dist/core/model-seat.d.ts +8 -5
- package/dist/core/model-shell.d.ts +129 -0
- package/dist/core/model-shell.js +249 -0
- package/dist/core/mods/kernel/digest.d.ts +4 -0
- package/dist/core/mods/kernel/digest.js +5 -0
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +15 -6
- package/dist/core/mods/kernel/events.d.ts +21 -5
- package/dist/core/mods/kernel/events.js +19 -10
- package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
- package/dist/core/mods/kernel/hash-mirror.js +55 -0
- package/dist/core/mods/kernel/index.d.ts +1 -0
- package/dist/core/mods/kernel/index.js +1 -0
- package/dist/core/mods/kernel/package-reader.d.ts +48 -0
- package/dist/core/mods/kernel/package-reader.js +149 -0
- package/dist/core/mods/kernel/site-rules.d.ts +4 -0
- package/dist/core/mods/kernel/site-rules.js +13 -0
- package/dist/core/mods/package.d.ts +7 -3
- package/dist/core/mods/package.js +47 -80
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/parent-spec-seat.d.ts +13 -11
- package/dist/core/parent-spec-seat.js +13 -9
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +33 -5
- package/dist/core/permission-rule-org.js +13 -3
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/permission-rules.js +4 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retain-seat.d.ts +42 -0
- package/dist/core/retain-seat.js +76 -0
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rewind-refusal-codes.d.ts +8 -0
- package/dist/core/rewind-refusal-codes.js +12 -0
- package/dist/core/roles.d.ts +2 -2
- package/dist/core/roles.js +15 -1
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/rule-store-fault.d.ts +9 -7
- package/dist/core/rule-store-fault.js +8 -3
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/checkpoint-scope.d.ts +14 -3
- package/dist/core/runner/checkpoint-scope.js +16 -6
- package/dist/core/runner/compact-session.js +1 -1
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/contracts.d.ts +21 -5
- package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
- package/dist/core/runner/cross-boundary-lane.js +4 -0
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/gate-exit.d.ts +7 -0
- package/dist/core/runner/gate-exit.js +2 -1
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/model-lane-seat.d.ts +3 -0
- package/dist/core/runner/model-lane-seat.js +4 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +27 -16
- package/dist/core/runner/person-path-rows.js +93 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +13 -7
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
- package/dist/core/runner/prepare-hands-readface.js +15 -3
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
- package/dist/core/runner/prepare-inherited-gate.js +13 -5
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +42 -30
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -6
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-policy-outcome.js +5 -2
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
- package/dist/core/runner/role-seat-defaulted.js +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
- package/dist/core/runner/run-harness-handlers.js +4 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +5 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +6 -4
- package/dist/core/runner/shell-env-withheld.js +25 -3
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/sub-agent-deny-lists.js +9 -5
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +6 -1
- package/dist/core/runner/terminal-account.js +16 -1
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-not-executed.d.ts +27 -8
- package/dist/core/runner/tool-not-executed.js +22 -11
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner/write-protection-station.d.ts +1 -1
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +17 -10
- package/dist/core/secret-env.d.ts +61 -37
- package/dist/core/secret-env.js +49 -49
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.d.ts +40 -2
- package/dist/core/shell-read-silence.js +23 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +14 -7
- package/dist/core/task-notification.d.ts +96 -10
- package/dist/core/task-notification.js +135 -6
- package/dist/core/task-registry-agent.d.ts +1 -0
- package/dist/core/task-registry-agent.js +1 -1
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +40 -2
- package/dist/core/task-registry.js +80 -15
- package/dist/core/task-result.d.ts +18 -3
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +19 -3
- package/dist/core/task-spec.d.ts +48 -22
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-gate-phase.d.ts +6 -3
- package/dist/core/tool-gate-phase.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +8 -4
- package/dist/core/tool-mount-facts.js +7 -2
- package/dist/core/tool-mount-plan.d.ts +3 -1
- package/dist/core/tool-mount-plan.js +10 -3
- package/dist/core/tool-mount-static.d.ts +1 -1
- package/dist/core/tool-mount-static.js +4 -2
- package/dist/core/tool-result-store.d.ts +56 -3
- package/dist/core/tool-result-store.js +219 -25
- package/dist/core/tool-spec.d.ts +9 -2
- package/dist/core/trace.d.ts +3 -3
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +26 -20
- package/dist/core/wiring-manifest.js +7 -3
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
- package/dist/engine/execution-env/node-execution-env.js +227 -13
- package/dist/engine/harness/types.d.ts +49 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +13 -7
- package/dist/engine/llm/validation.d.ts +8 -1
- package/dist/engine/llm/validation.js +31 -2
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +34 -4
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +28 -9
- package/dist/index.js +22 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/goal.js +1 -1
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-primitives.js +10 -1
- package/dist/orchestration/workflow-script-runner.d.ts +2 -2
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +31 -7
- package/dist/orchestration/workflow.js +119 -57
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/shell/lex.d.ts +2 -2
- package/dist/shell/lex.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/fs/bash-model-shell.d.ts +23 -0
- package/dist/tools/fs/bash-model-shell.js +25 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
- package/dist/tools/fs/bash-readonly-classifier.js +3 -0
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/fs-bash.js +13 -11
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +4 -1
- package/dist/tools/fs/safety.js +4 -2
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +134 -22
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +21 -11
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +7 -3
- package/dist/tools/fs/shell-read-plan.js +8 -5
- package/dist/tools/fs/shell-read-word.d.ts +8 -0
- package/dist/tools/fs/shell-read-word.js +13 -4
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/monitor.js +12 -8
- package/dist/tools/scheduler-tools.d.ts +1 -0
- package/dist/tools/scheduler-tools.js +5 -2
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +192 -3
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/core@7.74.0.json +68 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/primitives@7.74.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core-stores-sql@7.74.0.json +143 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/core@7.74.0.json +2210 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/mods-kernel@7.74.0.json +421 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/primitives@7.74.0.json +174 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
- package/wire-changes/wiki-gate@7.74.0.json +145 -0
|
@@ -20,6 +20,7 @@ import { canonicalExpectedScopes, expectedScopesInvalid, firstOutsideExpectedSco
|
|
|
20
20
|
import { scanMemoryFileName, scanMemoryWrite } from "./scan.js";
|
|
21
21
|
import { admittingLandings, cutPerLanding, LandingsNeedAdmission, requireLandingsAdmitted } from "./landing-admission.js";
|
|
22
22
|
import { thrownText } from "../thrown-value.js";
|
|
23
|
+
import { deletionRecordFrom } from "./deletion-record.js";
|
|
23
24
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
24
25
|
import { optionKeys, receiveOptions } from "../own-property-receipt.js";
|
|
25
26
|
export { DEFAULT_MAX_ENTRY_DEPTH, MEMORY_INDEX_FILENAME, scanEntryFiles } from "./entry-scan.js";
|
|
@@ -1153,11 +1154,8 @@ export class FileMemoryEngineBackend {
|
|
|
1153
1154
|
}
|
|
1154
1155
|
resurrectionBackstopVerdict(id) {
|
|
1155
1156
|
const digest = this.deletedIdsDigestLocked();
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
if (digest.state === "damaged" || this.chainDegradedMarkerPresent())
|
|
1159
|
-
return "degraded";
|
|
1160
|
-
return "clear";
|
|
1157
|
+
const record = deletionRecordFrom({ deletedRev: digest.ids.has(id) ? null : undefined, sound: digest.state !== "damaged" && !this.chainDegradedMarkerPresent() });
|
|
1158
|
+
return record.kind === "deleted" ? "erased" : record.kind === "undecidable" ? "degraded" : "clear";
|
|
1161
1159
|
}
|
|
1162
1160
|
retrievalDeletedIds() {
|
|
1163
1161
|
return this.deletedIdsDigestLocked().ids;
|
|
@@ -3070,6 +3068,10 @@ export class FileMemoryEngineBackend {
|
|
|
3070
3068
|
}
|
|
3071
3069
|
}
|
|
3072
3070
|
}
|
|
3071
|
+
if (out.state === "complete" && this.chainDegradedMarkerPresent()) {
|
|
3072
|
+
out.state = "damaged";
|
|
3073
|
+
out.reason ??= `evidence chain carries durable degradation marker (${CHAIN_DEGRADED_FILE} — out-of-band tail truncation)`;
|
|
3074
|
+
}
|
|
3073
3075
|
if (this.auditJournalPending())
|
|
3074
3076
|
continue;
|
|
3075
3077
|
if (readControlFileOrAbsent(transfersPath, "transfer evidence log") !== rawBefore)
|
|
@@ -32,7 +32,7 @@ export declare function retireGoneProjections(rows: readonly ProjectionLedgerRow
|
|
|
32
32
|
/** What a mount says about the files it left: one line per file, by scope — the seat only, never content. The announcement
|
|
33
33
|
* renderer keeps an item to the inline label bound (160 characters), so the quoted seat is held to its room and what a person
|
|
34
34
|
* acts on comes before a cause (a seat name cut past that bound would take the rest of the line with it). Three arms, each
|
|
35
|
-
* saying what is true of it: a copy changed here (
|
|
35
|
+
* saying what is true of it: a copy changed here (not saved back if deleted, else delete the file), something else standing at the
|
|
36
36
|
* seat (nothing is asked of the person), a copy that could not be removed. */
|
|
37
37
|
export declare function retirementNotices(r: ProjectionRetirement): Map<string | undefined, string[]>;
|
|
38
38
|
/** The one wording of a ledger fault: unreadable at a mount (nothing removed — the notice is said before the record is written, so
|
|
@@ -82,7 +82,7 @@ export function retirementNotices(r) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
for (const row of r.changed)
|
|
85
|
-
say(row.scope, `${q(row.rel)}: gone from the store at this name, changed here since it was placed — kept;
|
|
85
|
+
say(row.scope, `${q(row.rel)}: gone from the store at this name, changed here since it was placed — kept; not saved back if deleted, else delete the file`);
|
|
86
86
|
for (const row of r.replaced)
|
|
87
87
|
say(row.scope, `${q(row.rel)}: the store places no entry at this name any more, and this file is now a different note — left as found`);
|
|
88
88
|
for (const { row, why } of r.failed)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
2
|
+
import { PROJECT_ID_REGEX, type ProjectSeat } from "../project-seat.js";
|
|
2
3
|
/** Per-segment cap, measured AFTER encoding. A conservative portability policy adopted as contract
|
|
3
4
|
* (research (d) recommendation — NOT a verified third-party hard limit; uuidv7 = 36 chars fits). */
|
|
4
5
|
export declare const SCOPE_SEGMENT_MAX_ENCODED = 64;
|
|
@@ -132,10 +133,8 @@ export declare function assertScopeContractPlacement(args: {
|
|
|
132
133
|
/** Repo-root marker file: minted once (by scaffold/deployment, NEVER by the engine), committed, and
|
|
133
134
|
* from then on the project's identity survives clone/copy/rename/machine/cloud-sandbox. */
|
|
134
135
|
export declare const PROJECT_MARKER_PATH = ".sema/project";
|
|
135
|
-
/**
|
|
136
|
-
|
|
137
|
-
* drift 锁对着这条(registry-core coreTypes 先例)。 */
|
|
138
|
-
export declare const PROJECT_ID_REGEX: RegExp;
|
|
136
|
+
/** The project id's one format (defined beside the project seat, `../project-seat.ts`). */
|
|
137
|
+
export { PROJECT_ID_REGEX };
|
|
139
138
|
/** Canonicalize a project UUID for equality comparisons across markers, declarations, and v2 write keys. */
|
|
140
139
|
export declare function normalizeProjectId(projectId: string): string;
|
|
141
140
|
/** Serialize a marker file body (scaffold-side helper; the engine itself never writes one). */
|
|
@@ -212,7 +211,7 @@ export declare function resolveProjectId(fs: ProjectMarkerFs, rootDir: string):
|
|
|
212
211
|
markerDir: string;
|
|
213
212
|
} | null>;
|
|
214
213
|
/** A leg's project identity. `marker` = the checkout's `.sema/project` (a declaration, when present,
|
|
215
|
-
* equals it); `declared` = `TaskSpec.
|
|
214
|
+
* equals it); `declared` = `TaskSpec.project.id` (or the seat its parent handed it) in a checkout that carries no marker. */
|
|
216
215
|
export interface SessionProject {
|
|
217
216
|
readonly id: string;
|
|
218
217
|
readonly source: "marker" | "declared";
|
|
@@ -224,6 +223,9 @@ export interface SessionProjectVerdict {
|
|
|
224
223
|
readonly root: string;
|
|
225
224
|
/** ABSENT = no marker and no declaration, or the marker could not be read ({@link markerFault} says why). */
|
|
226
225
|
readonly project?: SessionProject;
|
|
226
|
+
/** The leg's project SEAT: the verdict's id with the texts that belong to it ({@link resolveSessionProject} says which) — present
|
|
227
|
+
* iff {@link project} is. What the leg hands its children and what its project texts are read from. */
|
|
228
|
+
readonly seat?: ProjectSeat;
|
|
227
229
|
/** Why the marker could not be read (nested / corrupt / unreadable), on a leg that declared no project — reported by
|
|
228
230
|
* the caller, NOT thrown here: only a reader that consumes project identity refuses with it (memory v2 `proj:` /
|
|
229
231
|
* `userproj:` keys). A leg that DECLARED a project consumes it, so there the fault is thrown. */
|
|
@@ -238,16 +240,19 @@ export declare function projectMarkerUnreadableOf(fault: SessionProjectVerdict["
|
|
|
238
240
|
readonly markerPath?: string;
|
|
239
241
|
} | undefined;
|
|
240
242
|
/**
|
|
241
|
-
* The leg's ONE project-identity judge, called once per leg on the task root
|
|
242
|
-
*
|
|
243
|
-
*
|
|
243
|
+
* The leg's ONE project-identity judge, called once per leg on the task root, over seats already screened
|
|
244
|
+
* (`screenProjectSeat`, at the spec's read and at the internals' door). Precedence:
|
|
245
|
+
* 1. `declared` (`TaskSpec.project`): checked against any workspace marker (`config.project_identity_mismatch` on
|
|
246
|
+
* disagreement, the marker's own code on an unreadable marker).
|
|
244
247
|
* 2. The leg's own workspace marker (`.sema/project`): decides when present (`source: "marker"`), even over an
|
|
245
|
-
* inherited
|
|
246
|
-
*
|
|
247
|
-
* 3. `
|
|
248
|
-
*
|
|
248
|
+
* `inherited` seat; an unreadable marker on a leg with no `declared` yields `{ root, markerFault }` (no project verdict —
|
|
249
|
+
* identical to a root leg).
|
|
250
|
+
* 3. `inherited` (the seat a delegated child's parent handed it, on the trusted internals): its id is used ONLY when both (1)
|
|
251
|
+
* and (2) yield none (`source: "declared"`), never compared against the child's marker.
|
|
252
|
+
* The texts belong to the id: the verdict's {@link SessionProjectVerdict.seat} is `declared` whole; else `inherited` whole when its
|
|
253
|
+
* id is the verdict's id (no marker, or a marker naming that id); else the verdict's id alone.
|
|
249
254
|
*/
|
|
250
|
-
export declare function resolveSessionProject(fs: ProjectMarkerFs, taskRoot: string, declared:
|
|
255
|
+
export declare function resolveSessionProject(fs: ProjectMarkerFs, taskRoot: string, declared: ProjectSeat | undefined, inherited?: ProjectSeat): Promise<SessionProjectVerdict>;
|
|
251
256
|
/**
|
|
252
257
|
* Under `scopeContract: "v2"`, enforce project-identity consistency for a memory session against the leg's ONE
|
|
253
258
|
* verdict ({@link SessionProjectVerdict}): rethrow an unreadable-marker fault for sessions consuming project identity
|
|
@@ -4,8 +4,8 @@ import { err, FileError, ok } from "../../internal/harness.js";
|
|
|
4
4
|
import { performsIo } from "../remote-env.js";
|
|
5
5
|
import { thrownText } from "../thrown-value.js";
|
|
6
6
|
import { envErrorDetail } from "../../tools/fs/env-error-detail.js";
|
|
7
|
-
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
8
7
|
import { physicalPathOfExisting } from "../physical-path.js";
|
|
8
|
+
import { PROJECT_ID_REGEX } from "../project-seat.js";
|
|
9
9
|
function pathSegmentsDualFamily(p) {
|
|
10
10
|
return p.split(/[\\/]/).filter(Boolean);
|
|
11
11
|
}
|
|
@@ -198,7 +198,7 @@ export function assertScopeContractPlacement(args) {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
export const PROJECT_MARKER_PATH = ".sema/project";
|
|
201
|
-
export
|
|
201
|
+
export { PROJECT_ID_REGEX };
|
|
202
202
|
const UUID_RE = PROJECT_ID_REGEX;
|
|
203
203
|
export function normalizeProjectId(projectId) {
|
|
204
204
|
return projectId.toLowerCase();
|
|
@@ -354,11 +354,8 @@ export function projectMarkerUnreadableOf(fault) {
|
|
|
354
354
|
return undefined;
|
|
355
355
|
return d.reason === "repo_root_unreadable" || d.markerPath === undefined ? { reason: d.reason } : { reason: d.reason, markerPath: d.markerPath };
|
|
356
356
|
}
|
|
357
|
-
export async function resolveSessionProject(fs, taskRoot, declared,
|
|
358
|
-
|
|
359
|
-
throw identityError("config.project_id_invalid", `TaskSpec.projectId must be a project UUID (the id a \`.sema/project\` marker carries), got ${describeRejectedValue(declared)}; the leg is refused rather than filed under no project.`);
|
|
360
|
-
}
|
|
361
|
-
const declaredId = declared !== undefined ? normalizeProjectId(declared) : undefined;
|
|
357
|
+
export async function resolveSessionProject(fs, taskRoot, declared, inherited) {
|
|
358
|
+
const declaredId = declared !== undefined ? normalizeProjectId(declared.id) : undefined;
|
|
362
359
|
let marker;
|
|
363
360
|
try {
|
|
364
361
|
marker = await resolveProjectId(fs, taskRoot);
|
|
@@ -368,16 +365,19 @@ export async function resolveSessionProject(fs, taskRoot, declared, defaultProje
|
|
|
368
365
|
throw e;
|
|
369
366
|
return { root: taskRoot, markerFault: e };
|
|
370
367
|
}
|
|
371
|
-
if (marker !== null) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
`the leg is refused rather than filed under the wrong project. Declare the marker's id, or correct the marker.`, { kind: "mismatch", declared: declaredId, marker: marker.projectId, markerPath });
|
|
376
|
-
}
|
|
377
|
-
return { root: taskRoot, project: { id: marker.projectId, source: "marker" } };
|
|
368
|
+
if (marker !== null && declaredId !== undefined && declaredId !== marker.projectId) {
|
|
369
|
+
const markerPath = join(marker.markerDir, PROJECT_MARKER_PATH);
|
|
370
|
+
throw identityError("config.project_identity_mismatch", `TaskSpec.project.id declares ${declaredId}, but this checkout's project marker ${markerPath} carries ${marker.projectId} — ` +
|
|
371
|
+
`the leg is refused rather than filed under the wrong project. Declare the marker's id, or correct the marker.`, { kind: "mismatch", declared: declaredId, marker: marker.projectId, markerPath });
|
|
378
372
|
}
|
|
379
|
-
const
|
|
380
|
-
|
|
373
|
+
const verdict = marker !== null ? { id: marker.projectId, source: "marker" }
|
|
374
|
+
: declaredId !== undefined ? { id: declaredId, source: "declared" }
|
|
375
|
+
: inherited !== undefined ? { id: normalizeProjectId(inherited.id), source: "declared" }
|
|
376
|
+
: undefined;
|
|
377
|
+
if (verdict === undefined)
|
|
378
|
+
return { root: taskRoot };
|
|
379
|
+
const owner = declared ?? (inherited !== undefined && normalizeProjectId(inherited.id) === verdict.id ? inherited : undefined);
|
|
380
|
+
return { root: taskRoot, project: verdict, seat: Object.freeze({ ...owner, id: verdict.id }) };
|
|
381
381
|
}
|
|
382
382
|
export function assertMemoryProjectVerdict(sessionProject, scopes, writeScope) {
|
|
383
383
|
const consumesProjectIdentity = [...scopes, ...(writeScope !== null ? [writeScope] : [])]
|
|
@@ -393,10 +393,10 @@ export function assertMemoryProjectVerdict(sessionProject, scopes, writeScope) {
|
|
|
393
393
|
const verdict = sessionProject.project;
|
|
394
394
|
if (verdict === undefined) {
|
|
395
395
|
throw identityError("config.memory_project_identity", `memory scope contract v2: writeScope ${writeScope} targets projectId ${w.projectId}, ` +
|
|
396
|
-
`but this leg has no project verdict (no .sema/project marker and no TaskSpec.
|
|
396
|
+
`but this leg has no project verdict (no .sema/project marker and no TaskSpec.project) — refusing a project-scoped write without a project identity.`, { kind: "write_without_verdict", writeScope, writeProjectId: w.projectId });
|
|
397
397
|
}
|
|
398
398
|
if (normalizeProjectId(w.projectId) !== normalizeProjectId(verdict.id)) {
|
|
399
399
|
throw identityError("config.memory_project_identity", `memory scope contract v2: writeScope ${writeScope} targets projectId ${w.projectId}, ` +
|
|
400
|
-
`but this leg's project verdict (${verdict.source === "marker" ? "marker .sema/project" : "declared TaskSpec.
|
|
400
|
+
`but this leg's project verdict (${verdict.source === "marker" ? "marker .sema/project" : "declared TaskSpec.project.id"}) is ${verdict.id} — refusing a mis-addressed write.`, { kind: "write_project_mismatch", writeScope, writeProjectId: w.projectId, verdictProjectId: verdict.id, verdictSource: verdict.source });
|
|
401
401
|
}
|
|
402
402
|
}
|
|
@@ -3,13 +3,14 @@ import { screenInboundEntries } from "./data-plane.js";
|
|
|
3
3
|
import { scanMemoryFileName, scanMemoryWrite } from "./scan.js";
|
|
4
4
|
import { MAX_MEMORY_BYTES } from "../memory.js";
|
|
5
5
|
import { reconcileMemoryEntries } from "./sync.js";
|
|
6
|
+
import { memoryDeletionRecords } from "./deletion-record.js";
|
|
6
7
|
import { MEMORY_ORIGIN_CAUSES } from "./types.js";
|
|
7
8
|
import { directoryPinOf, landingPathOf } from "./layout.js";
|
|
8
9
|
import { egressText } from "../untrusted-egress.js";
|
|
9
10
|
import { REDACTION_MARKS, userinfoHolds } from "@sema-agent/primitives";
|
|
10
11
|
import { isReplicableScope } from "./scope-contract.js";
|
|
11
12
|
const DROP_THE_CURSOR = "drop the cursor to accept re-convergence from an empty baseline — entries changed on both sides are reported as conflicts, " +
|
|
12
|
-
"and entries deleted on one side since the last round come back from the other side";
|
|
13
|
+
"and entries deleted on one side since the last round come back from the other side unless that side's store records the deletion and reads it";
|
|
13
14
|
const REFUSAL_ROWS = {
|
|
14
15
|
scope: {
|
|
15
16
|
why: "a cursor is the baseline of one (scope, peer) partition",
|
|
@@ -38,8 +39,8 @@ const REFUSAL_ROWS = {
|
|
|
38
39
|
outs: () => [
|
|
39
40
|
"rebind — when this store holds the entries the baseline was taken over (the same store, moved to this root or bound before " +
|
|
40
41
|
"cursors carried a store), persist the cursor with its store set to this store's identity (memorySyncStoreOf) and sync again",
|
|
41
|
-
"clear — delete the cursor and sync from none, accepting that an entry deleted on either side since the last completed round " +
|
|
42
|
-
"comes back from the other side",
|
|
42
|
+
"clear — delete the cursor and sync from none, accepting that deletions without a baseline no longer cross and an entry deleted on either side since the last completed round " +
|
|
43
|
+
"comes back from the other side unless that side's store records the deletion and reads it (a recorded deletion blocks landing as a conflict and never deletes on the peer)",
|
|
43
44
|
],
|
|
44
45
|
},
|
|
45
46
|
"store-plane": {
|
|
@@ -444,7 +445,26 @@ export async function syncMemoryScope(opts) {
|
|
|
444
445
|
});
|
|
445
446
|
}
|
|
446
447
|
}
|
|
447
|
-
|
|
448
|
+
const heldIds = new Set(fetched.map((e) => e.id));
|
|
449
|
+
const unbaselined = resp.serverEntries.filter((e) => !rejected.has(e.id) && baseRevs[e.id] === undefined && !heldIds.has(e.id));
|
|
450
|
+
const deletionBlocked = new Set();
|
|
451
|
+
if (unbaselined.length > 0) {
|
|
452
|
+
const judged = reconcileMemoryEntries({}, [], unbaselined, { local: await memoryDeletionRecords(backend, unbaselined.map((e) => e.id), scope) });
|
|
453
|
+
for (const c of judged.conflicts) {
|
|
454
|
+
deletionBlocked.add(c.id);
|
|
455
|
+
const record = c.deletion?.record;
|
|
456
|
+
conflicts.push({
|
|
457
|
+
side: "local",
|
|
458
|
+
id: c.id,
|
|
459
|
+
reason: record?.kind === "undecidable"
|
|
460
|
+
? `deletion_record_unreadable: the center offers ${JSON.stringify(c.id)}, which this store does not hold, and whether this store deleted it cannot be read (${record.why}) — not brought back`
|
|
461
|
+
: `deleted_here: this store deleted ${JSON.stringify(c.id)}${c.baseRev !== undefined ? ` at rev ${JSON.stringify(c.baseRev)}` : ""} and the center offers it at rev ${JSON.stringify(c.remote?.rev)} — not brought back (re-judged next round; nothing deleted on the center)`,
|
|
462
|
+
...(c.remote?.rev !== undefined ? { currentRev: c.remote.rev } : {}),
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
const landable = (id) => !rejected.has(id) && !deletionBlocked.has(id);
|
|
467
|
+
for (const f of screenInboundEntries(resp.serverEntries.filter((e) => landable(e.id)))) {
|
|
448
468
|
rejected.add(f.id);
|
|
449
469
|
conflicts.push({
|
|
450
470
|
side: "local",
|
|
@@ -491,7 +511,7 @@ export async function syncMemoryScope(opts) {
|
|
|
491
511
|
}
|
|
492
512
|
const patches = [
|
|
493
513
|
...resp.serverEntries
|
|
494
|
-
.filter((e) =>
|
|
514
|
+
.filter((e) => landable(e.id))
|
|
495
515
|
.map((e) => {
|
|
496
516
|
const base = baseRevs[e.id];
|
|
497
517
|
return base !== undefined
|
|
@@ -514,7 +534,7 @@ export async function syncMemoryScope(opts) {
|
|
|
514
534
|
let nextCursor = cursor;
|
|
515
535
|
const warnings = [];
|
|
516
536
|
if (cursorAdvanced) {
|
|
517
|
-
const pulledRevById = new Map(resp.serverEntries.map((e) => [e.id, e.rev]));
|
|
537
|
+
const pulledRevById = new Map(resp.serverEntries.filter((e) => landable(e.id)).map((e) => [e.id, e.rev]));
|
|
518
538
|
const pushedRevById = new Map(request.entries.map((e) => [e.id, e.rev]));
|
|
519
539
|
const serverAppliedIds = new Set(resp.applied.filter((a) => a.op !== "delete").map((a) => a.id));
|
|
520
540
|
const disputedIds = new Set(resp.conflicts.map((c) => c.id));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MemoryEntry, ScoredMemoryEntry } from "./types.js";
|
|
2
|
+
import type { DeletionRecord } from "./deletion-record.js";
|
|
2
3
|
/**
|
|
3
4
|
* design/142 §3 — the per-replica per-scope sync cursor: the COMMON BASELINE a reconciliation run
|
|
4
5
|
* judges divergence against (`id → rev` as of the last completed sync round). This is a NEW
|
|
@@ -36,6 +37,20 @@ export interface MemorySyncConflict {
|
|
|
36
37
|
local?: MemoryEntry;
|
|
37
38
|
remote?: MemoryEntry;
|
|
38
39
|
baseRev?: string;
|
|
40
|
+
/** Present when no baseline answered for the id and the absent side's deletion record blocked it from landing on that
|
|
41
|
+
* side: `record` is that side's answer (`deleted` at any version — `baseRev` carries the deleted version when known —
|
|
42
|
+
* or `undecidable`). A deletion record never emits a delete for the other side. */
|
|
43
|
+
deletion?: {
|
|
44
|
+
side: "local" | "remote";
|
|
45
|
+
record: DeletionRecord;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Each side's deletion records for ids it does not hold (`memoryDeletionRecords`): consulted only for an id present on
|
|
49
|
+
* the other side with no baseline. A side whose records are not given is judged as holding none — the caller holding
|
|
50
|
+
* that side's store passes them (a client's push half leaves the peer's side to the peer, which judges it). */
|
|
51
|
+
export interface MemorySyncDeletions {
|
|
52
|
+
local?: ReadonlyMap<string, DeletionRecord>;
|
|
53
|
+
remote?: ReadonlyMap<string, DeletionRecord>;
|
|
39
54
|
}
|
|
40
55
|
export interface MemorySyncPlan {
|
|
41
56
|
/** Entries the LOCAL side should send to the peer (new here or changed-here-only). 独立轨 F8 —
|
|
@@ -77,10 +92,13 @@ export interface MemorySyncPlan {
|
|
|
77
92
|
* - changed on BOTH sides, or delete-on-one × edit-on-the-other → conflict (caller's ladder);
|
|
78
93
|
* - deleted on one side × UNCHANGED on the other → the delete propagates (deleteLocal/deleteRemote,
|
|
79
94
|
* CAS on baseRev: without this leg removals never cross and the plan livelocks);
|
|
80
|
-
* - present only on one side with NO baseline →
|
|
95
|
+
* - present only on one side with NO baseline → the absent side's deletion record ({@link MemorySyncDeletions}) decides
|
|
96
|
+
* only whether the id may land on that side: `never` (or omitted) ⇒ new entry → propagate; deleted (at any version)
|
|
97
|
+
* or `undecidable` ⇒ conflict carrying `deletion`, never a delete on the present side. Deletions cross only where a
|
|
98
|
+
* baseline exists;
|
|
81
99
|
* - absent on both but present in baseline → cleared (cursor cleanup).
|
|
82
100
|
*/
|
|
83
|
-
export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): MemorySyncPlan;
|
|
101
|
+
export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[], deletions?: MemorySyncDeletions): MemorySyncPlan;
|
|
84
102
|
/** The baseline to persist AFTER a sync round completes: every id both sides now agree on. The
|
|
85
103
|
* caller passes the POST-round entry sets (after applying push/pull and resolving conflicts). */
|
|
86
104
|
export declare function nextSyncBaseline(local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): Record<string, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function reconcileMemoryEntries(baseRevs, local, remote) {
|
|
1
|
+
export function reconcileMemoryEntries(baseRevs, local, remote, deletions) {
|
|
2
2
|
const plan = { push: [], pull: [], deleteLocal: [], deleteRemote: [], conflicts: [], cleared: [] };
|
|
3
3
|
const localById = new Map(local.map((e) => [e.id, e]));
|
|
4
4
|
const remoteById = new Map(remote.map((e) => [e.id, e]));
|
|
@@ -20,22 +20,23 @@ export function reconcileMemoryEntries(baseRevs, local, remote) {
|
|
|
20
20
|
plan.pull.push(r);
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
|
-
if (l !== undefined) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
if (l !== undefined || r !== undefined) {
|
|
24
|
+
const present = (l ?? r);
|
|
25
|
+
const side = l !== undefined ? { local: l } : { remote: r };
|
|
26
|
+
if (base !== undefined) {
|
|
27
|
+
if (present.rev !== base)
|
|
28
|
+
plan.conflicts.push({ id, ...side, baseRev: base });
|
|
29
|
+
else
|
|
30
|
+
(l !== undefined ? plan.deleteLocal : plan.deleteRemote).push({ id, baseRev: base });
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const absentSide = l !== undefined ? "remote" : "local";
|
|
34
|
+
const record = deletions?.[absentSide]?.get(id);
|
|
35
|
+
if (record === undefined || record.kind === "never")
|
|
36
|
+
(l !== undefined ? plan.push : plan.pull).push(present);
|
|
37
|
+
else
|
|
38
|
+
plan.conflicts.push({ id, ...side, ...(record.kind === "deleted" && record.rev !== undefined ? { baseRev: record.rev } : {}), deletion: { side: absentSide, record } });
|
|
39
|
+
}
|
|
39
40
|
continue;
|
|
40
41
|
}
|
|
41
42
|
plan.cleared.push(id);
|
|
@@ -163,11 +163,15 @@ export declare function createModeGatePolicy(modeRef: {
|
|
|
163
163
|
readonly current: PermissionMode;
|
|
164
164
|
}, seats: ModeGateSeats): ToolPolicy;
|
|
165
165
|
/**
|
|
166
|
-
* The mode a resumed leg REQUESTS: the re-passed spec's word, else the word the checkpoint row
|
|
167
|
-
* resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the
|
|
168
|
-
* pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the word
|
|
169
|
-
* (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the
|
|
170
|
-
*
|
|
166
|
+
* The mode a resumed leg REQUESTS. Without a mode the approval names: the re-passed spec's word, else the word the checkpoint row
|
|
167
|
+
* recorded — except where the resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the
|
|
168
|
+
* one answer the pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the resume's word, else to the
|
|
169
|
+
* word the leg had before it (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the
|
|
170
|
+
* leg's own default). A re-passed `plan` does not keep an approved plan open.
|
|
171
|
+
* The mode the person's approval names (`outcome.permissionMode`, the one the decided row records), on whatever row it decides: a
|
|
172
|
+
* tightening of that mode holds unconditionally; a widening holds only where the ceiling it is folded under is known — the parent's
|
|
173
|
+
* mode with the deployment's cap (the leg's ceilings fold it after). A leg with a parent whose mode this resume was not handed
|
|
174
|
+
* (`parentModeUnknown`) has no known ceiling: the widening is withheld and the leg requests the mode it would without it.
|
|
171
175
|
*/
|
|
172
176
|
export declare function modeRequestAfterResume(seat: PermissionMode | undefined, recorded: {
|
|
173
177
|
readonly permissionMode?: PermissionMode;
|
|
@@ -175,7 +179,18 @@ export declare function modeRequestAfterResume(seat: PermissionMode | undefined,
|
|
|
175
179
|
}, outcome: {
|
|
176
180
|
readonly gate: string;
|
|
177
181
|
readonly decision?: string;
|
|
178
|
-
|
|
182
|
+
readonly permissionMode?: PermissionMode;
|
|
183
|
+
} | undefined, parentModeUnknown?: true): PermissionMode | undefined;
|
|
184
|
+
/** The mode an approval named that {@link modeRequestAfterResume} withholds (a widening with no known ceiling), else `undefined` —
|
|
185
|
+
* the one fact a leg says when it does not take the mode a person approved. */
|
|
186
|
+
export declare function withheldApprovalMode(seat: PermissionMode | undefined, recorded: {
|
|
187
|
+
readonly permissionMode?: PermissionMode;
|
|
188
|
+
readonly prePlanMode?: PermissionMode;
|
|
189
|
+
}, outcome: {
|
|
190
|
+
readonly gate: string;
|
|
191
|
+
readonly decision?: string;
|
|
192
|
+
readonly permissionMode?: PermissionMode;
|
|
193
|
+
} | undefined, parentModeUnknown?: true): PermissionMode | undefined;
|
|
179
194
|
/**
|
|
180
195
|
* The permission MODE's door — two refusals in the pre-first-await stretch, each by name and never a fold back to
|
|
181
196
|
* absence (a mode a caller believes it declared must not silently run as another): a `permissionMode` outside
|
|
@@ -256,6 +271,7 @@ export interface PermissionModeFold {
|
|
|
256
271
|
* announced for a word nobody asked for — and the leg declares `default`. A word somebody asked for (the caller, a steer, the
|
|
257
272
|
* word a checkpoint recorded because the leg ran under it) folds as it always does, announced.
|
|
258
273
|
* A static answer: an arming that fails at run time (the classifier's leg cannot be built) is not foreseen here.
|
|
274
|
+
* A `requested`, `ceiling` or `whenUnset` outside its set is refused (`config.permission_mode_invalid`, `detail.field` names which).
|
|
259
275
|
*/
|
|
260
276
|
export declare function foldPermissionMode(input: PermissionModeFoldInput): PermissionModeFold;
|
|
261
277
|
/** `RunnerDeps.permissionModeWhenUnset` read: absent, or a start word — anything else is refused by name, never read as `default`. */
|
|
@@ -347,6 +363,9 @@ export declare class PermissionModeController {
|
|
|
347
363
|
* A decision read is what starts it; an observation that did would arm a leg earlier than its own gate, and so move
|
|
348
364
|
* who answers the leg's next ask. */
|
|
349
365
|
get observed(): PermissionMode;
|
|
366
|
+
/** The effective mode this leg would run under were `word` asked for now — the same fold ({@link foldPermissionMode}) over the
|
|
367
|
+
* same ceiling (observed) and arming facts, with `word` as the request; an observation: nothing is steered, armed or announced. */
|
|
368
|
+
armsAs(word: PermissionMode): PermissionMode;
|
|
350
369
|
/** The three-member answer as it stands right now. */
|
|
351
370
|
receipt(): PermissionModeReceipt;
|
|
352
371
|
private receiptOf;
|
package/dist/core/mode-policy.js
CHANGED
|
@@ -106,11 +106,17 @@ export function createModeGatePolicy(modeRef, seats) {
|
|
|
106
106
|
},
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
export function modeRequestAfterResume(seat, recorded, outcome) {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
export function modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) {
|
|
110
|
+
const approved = outcome !== undefined && outcome.decision !== "reject";
|
|
111
|
+
const unnamed = !approved || !approvalRequestsPlanExit(outcome.gate, recorded.permissionMode) ? (seat ?? recorded.permissionMode) : seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
|
|
112
|
+
const named = approved ? outcome.permissionMode : undefined;
|
|
113
|
+
if (named === undefined)
|
|
114
|
+
return unnamed;
|
|
115
|
+
return parentModeUnknown !== true || clampPermissionMode(named, unnamed ?? "default").effective === named ? named : unnamed;
|
|
116
|
+
}
|
|
117
|
+
export function withheldApprovalMode(seat, recorded, outcome, parentModeUnknown) {
|
|
118
|
+
const named = outcome !== undefined && outcome.decision !== "reject" ? outcome.permissionMode : undefined;
|
|
119
|
+
return named !== undefined && modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) !== named ? named : undefined;
|
|
114
120
|
}
|
|
115
121
|
export function refusePermissionModeDoors(spec) {
|
|
116
122
|
const mode = spec.permissionMode;
|
|
@@ -153,9 +159,21 @@ function autoModeArmFactOf(word, a) {
|
|
|
153
159
|
}
|
|
154
160
|
return { armed: true, reason: "armed" };
|
|
155
161
|
}
|
|
162
|
+
function refuseFoldModeWord(field, value, allowed) {
|
|
163
|
+
const e = new Error(`foldPermissionMode: ${field} must be one of ${allowed.map((w) => JSON.stringify(w)).join(", ")} when present (got ${describeRejectedValue(value)}) — omit it to leave it unset.`);
|
|
164
|
+
e.code = "config.permission_mode_invalid";
|
|
165
|
+
e.detail = { field };
|
|
166
|
+
throw e;
|
|
167
|
+
}
|
|
156
168
|
export function foldPermissionMode(input) {
|
|
157
|
-
const { requested, ceiling, arming } = input;
|
|
158
|
-
|
|
169
|
+
const { requested, ceiling, whenUnset, arming } = input;
|
|
170
|
+
if (requested !== undefined && !isPermissionMode(requested))
|
|
171
|
+
refuseFoldModeWord("requested", requested, PERMISSION_MODES);
|
|
172
|
+
if (ceiling !== undefined && !isPermissionMode(ceiling))
|
|
173
|
+
refuseFoldModeWord("ceiling", ceiling, PERMISSION_MODES);
|
|
174
|
+
if (whenUnset !== undefined && !PERMISSION_MODE_START_WORDS.includes(whenUnset))
|
|
175
|
+
refuseFoldModeWord("whenUnset", whenUnset, PERMISSION_MODE_START_WORDS);
|
|
176
|
+
const { effective: word, clamped } = ceiling === undefined ? { effective: requested ?? whenUnset ?? "default", clamped: false } : clampPermissionMode(requested, ceiling);
|
|
159
177
|
const base = requested !== undefined ? { requested } : {};
|
|
160
178
|
const autoMode = arming === undefined ? undefined : autoModeArmFactOf(word, arming);
|
|
161
179
|
const armed = autoMode !== undefined ? { autoMode } : {};
|
|
@@ -236,13 +254,20 @@ export class PermissionModeController {
|
|
|
236
254
|
const arming = this.arming;
|
|
237
255
|
if (effective === "auto" && !this.armedForAuto && arming?.armAuto !== undefined) {
|
|
238
256
|
this.armedForAuto = true;
|
|
239
|
-
void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) =>
|
|
257
|
+
void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) => {
|
|
258
|
+
this.armedForAuto = false;
|
|
259
|
+
this.faultSeat.notifyAsync(() => arming.onArmFault?.(e), "permissionMode.onArmFault");
|
|
260
|
+
});
|
|
240
261
|
}
|
|
241
262
|
return effective;
|
|
242
263
|
}
|
|
243
264
|
get observed() {
|
|
244
265
|
return this.receiptOf(true).effective;
|
|
245
266
|
}
|
|
267
|
+
armsAs(word) {
|
|
268
|
+
const ceiling = this.ceilingNow(true);
|
|
269
|
+
return foldPermissionMode({ requested: word, ...(ceiling !== undefined ? { ceiling } : {}), ...(this.whenUnset !== undefined ? { whenUnset: this.whenUnset } : {}), ...(this.arming !== undefined ? { arming: this.arming } : {}) }).receipt.effective;
|
|
270
|
+
}
|
|
246
271
|
receipt() {
|
|
247
272
|
return this.receiptOf(false);
|
|
248
273
|
}
|
|
@@ -97,14 +97,16 @@ export interface Brain {
|
|
|
97
97
|
* per-call identity the request is dispatched with (the `getApiKeyAndHeaders` result), so a seat can
|
|
98
98
|
* judge the exact request it is about to make. The engine's model lane asks it before EVERY hop it
|
|
99
99
|
* dispatches — the requested model first — and does not dispatch a hop it refuses (the walk moves on;
|
|
100
|
-
* no hop served ⇒ the requested model's refusal is the answer)
|
|
100
|
+
* no hop served ⇒ the requested model's refusal is the answer); a failover chain also asks each leg right
|
|
101
|
+
* before it sends that leg, and does not send a leg that does not go ahead. First-party brains implement it against
|
|
101
102
|
* their own config; the decorators (routing/failover/circuit-breaker) and the engine's model lane
|
|
102
103
|
* re-dispatch it the way their `stream` would. `undefined` = this brain cannot judge (a custom brain
|
|
103
104
|
* without the face) — callers must treat that as "no judgment", never as OK or as broken. A refusal is
|
|
104
105
|
* an `ok: false` verdict, never a throw (the first-party faces include the per-call key handed beside its
|
|
105
106
|
* lane's own key header, `route.credential_answer_conflict`). It answers SYNCHRONOUSLY. A throw, a Promise or
|
|
106
|
-
* any other answer that is not a verdict is a defect — the model lane
|
|
107
|
-
* it as the route refused (`route.judgment_failed`), a failover chain's face a throw as
|
|
107
|
+
* any other answer that is not a verdict is a defect — the model lane, a derived seat's pre-flight and a failover
|
|
108
|
+
* chain's ask before a leg read it as the route refused (`route.judgment_failed`), a failover chain's face a throw as
|
|
109
|
+
* that leg refused.
|
|
108
110
|
*
|
|
109
111
|
* The same law runs again inside the first-party brains' request build (single source, called
|
|
110
112
|
* twice): a broken pairing that skips the pre-flight still refuses loudly at the request instead
|
|
@@ -118,8 +120,9 @@ export interface Brain {
|
|
|
118
120
|
* only hop of a request with no chain, the first hop of a walk), `"fallback"` for a later hop of its chain. Present ONLY on that ask: a
|
|
119
121
|
* refusal answered to it means the call was not sent (save a request cancelled while it was judged: the Brain answers that one,
|
|
120
122
|
* aborted). Absent on every other ask (a read face such as `routePairingStatus`, a derived seat's pre-flight, a host's own check).
|
|
121
|
-
* The engine's one-target decorators hand it on as they hand on the second argument; a failover chain asks its legs without it
|
|
122
|
-
*
|
|
123
|
+
* The engine's one-target decorators hand it on as they hand on the second argument; a failover chain asks its legs without it, both
|
|
124
|
+
* when it judges for the chain and when it asks a leg right before sending it (the gateway does not know which hop of a walk it
|
|
125
|
+
* serves); a host's own decorator hands it on to be heard below it.
|
|
123
126
|
*/
|
|
124
127
|
export interface RouteJudgmentDispatch {
|
|
125
128
|
readonly hop: "requested" | "fallback";
|