@sema-agent/core 7.57.0 → 7.59.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 +1161 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +89 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +20 -7
- package/dist/core/allow-entry.js +18 -9
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +2 -2
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-store.d.ts +85 -23
- package/dist/core/checkpoint-store.js +31 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +99 -9
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +7 -4
- package/dist/core/gate-lanes.js +19 -6
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +35 -4
- package/dist/core/hooks.js +17 -11
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +20 -3
- package/dist/core/locked-config.js +40 -3
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +117 -15
- package/dist/core/mcp-failure.js +71 -3
- package/dist/core/mcp-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-link.d.ts +27 -3
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +16 -20
- package/dist/core/mcp.js +112 -55
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +12 -9
- package/dist/core/mods/kernel/events.d.ts +6 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +9 -1
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +33 -12
- package/dist/core/mods/stations.js +45 -11
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +13 -4
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +248 -0
- package/dist/core/peer-seat.js +439 -0
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +20 -3
- package/dist/core/present-plan-tool.js +48 -4
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +38 -0
- package/dist/core/rewrite-rejudge.js +42 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +33 -21
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +30 -8
- package/dist/core/runner/gate-exit.js +15 -8
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +3 -1
- package/dist/core/runner/prepare-config-doors.d.ts +8 -5
- package/dist/core/runner/prepare-config-doors.js +14 -10
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +8 -0
- package/dist/core/runner/prepare-delegation-surface.js +16 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +11 -3
- package/dist/core/runner/prepare-hands-readface.js +9 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +26 -37
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
- package/dist/core/runner/prepare-policy-chain.js +18 -15
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +11 -3
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.js +28 -13
- package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -1
- package/dist/core/runner/prepare-wiring-manifest.js +4 -3
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +5 -3
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +42 -29
- package/dist/core/runner/run-notification-lane.js +3 -0
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +2 -1
- package/dist/core/runner/tool-occurrence.d.ts +5 -2
- package/dist/core/runner/tool-occurrence.js +4 -3
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +3 -3
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +9 -10
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +86 -24
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +20 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +92 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +7 -1
- package/dist/core/task-spec.d.ts +49 -1
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +11 -1
- package/dist/core/tool-catalog-entries.js +1 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +18 -6
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +24 -23
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +30 -2
- package/dist/engine/harness/agent-harness.js +43 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +56 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +30 -10
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +11 -22
- package/dist/index.d.ts +29 -16
- package/dist/index.js +21 -11
- package/dist/internal/harness-types.d.ts +2 -2
- package/dist/internal/harness.d.ts +3 -2
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +7 -3
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +61 -16
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +26 -9
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +149 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
package/dist/core/skill-grant.js
CHANGED
|
@@ -5,7 +5,7 @@ import { inlineUntrusted } from "./untrusted-text.js";
|
|
|
5
5
|
import { boundInputHashOf } from "./canonical-json.js";
|
|
6
6
|
import { NOT_BINDABLE } from "./skill-grant-binding.js";
|
|
7
7
|
import { readToolNameList } from "./tool-name-list.js";
|
|
8
|
-
import { allowingRows,
|
|
8
|
+
import { allowingRows, strippedInAuto, compileAllowList, readRuleEntry, inertEntryPhrase, judgeAllowEntries, nonListValueLabel, renderListEntry, spelledListEntry } from "./allow-entry.js";
|
|
9
9
|
export const SKILL_GRANT_ORIGINS = Object.freeze(["model", "user", "inherited"]);
|
|
10
10
|
const FROZEN_SKILL_GRANT_ORIGINS = new Set(["model", "inherited"]);
|
|
11
11
|
export function skillNamedBy(args, skills) {
|
|
@@ -120,21 +120,21 @@ export function skillAllowDecision(hit, updatedInput) {
|
|
|
120
120
|
}
|
|
121
121
|
const CARD_ENTRIES_MAX = 10;
|
|
122
122
|
const CARD_ENTRY_MAX_CHARS = 120;
|
|
123
|
-
export function skillActivationQuestion(skill, mode, roster) {
|
|
123
|
+
export function skillActivationQuestion(skill, mode, allShell, roster) {
|
|
124
124
|
const head = `Execute skill: ${inlineUntrusted(skill.name, 200)}`;
|
|
125
|
-
const granting = compileSkillGrant(skill, "model", roster).rows.filter((r) => r.behavior === "allow" && !(
|
|
125
|
+
const granting = compileSkillGrant(skill, "model", roster).rows.filter((r) => r.behavior === "allow" && !strippedInAuto(r.compiled, undefined, mode, allShell));
|
|
126
126
|
if (granting.length === 0)
|
|
127
127
|
return head;
|
|
128
128
|
const shown = granting.slice(0, CARD_ENTRIES_MAX).map((r) => inlineUntrusted(r.entry, CARD_ENTRY_MAX_CHARS));
|
|
129
129
|
const rest = granting.length - shown.length;
|
|
130
130
|
return `${head}\nApproving also lets these tools be used without asking for the rest of this run: ${shown.join(", ")}${rest > 0 ? ` and ${rest} more` : ""}`;
|
|
131
131
|
}
|
|
132
|
-
export function skillSeatReader(skills, mounted) {
|
|
132
|
+
export function skillSeatReader(skills, allShell, mounted) {
|
|
133
133
|
if (skills.length === 0)
|
|
134
134
|
return undefined;
|
|
135
135
|
return (args, mode) => {
|
|
136
136
|
const skill = skillNamedBy(args, skills);
|
|
137
|
-
return skill !== undefined && declaresSkillLists(skill) ? { seat: "passthrough", question: skillActivationQuestion(skill, mode, mounted?.()) } : undefined;
|
|
137
|
+
return skill !== undefined && declaresSkillLists(skill) ? { seat: "passthrough", question: skillActivationQuestion(skill, mode, allShell, mounted?.()) } : undefined;
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
export function skillGateWiring(opts) {
|
|
@@ -233,7 +233,7 @@ export class SkillGrantTable {
|
|
|
233
233
|
}
|
|
234
234
|
lane(ctx) {
|
|
235
235
|
return {
|
|
236
|
-
allowing: (req, mode) => judge(allowingRows(this.rowsHeld, req, mode), req, "allow", ctx),
|
|
236
|
+
allowing: (req, mode) => judge(allowingRows(this.rowsHeld, req, mode, ctx.classifyAllShell === true), req, "allow", ctx),
|
|
237
237
|
denying: (req) => judge(this.rowsHeld, req, "deny", ctx) ?? this.activationRefused(req),
|
|
238
238
|
};
|
|
239
239
|
}
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
* steer under its key — the parked queue (`appendPendingSteer`) and the live verb's accepted-input domain — and that
|
|
4
4
|
* one answer feeds the replay decision, the refusal's machine-readable `detail.differs` and its sentence.
|
|
5
5
|
*
|
|
6
|
-
* Both seats compare the record the CALLER sent (text, trusted, tier, actor) — never the delivered bytes: the live
|
|
6
|
+
* Both seats compare the record the CALLER sent (text, trusted, tier, actor, run origin) — never the delivered bytes: the live
|
|
7
7
|
* delivery folds `trusted` (the framing) and the actor (the speaker label) into its payload, so comparing payloads
|
|
8
8
|
* would report one changed facet as two.
|
|
9
9
|
*/
|
|
10
10
|
import type { ActorAssertion } from "../internal/llm.js";
|
|
11
11
|
import { type SystemInjectionPriority } from "./task-notification.js";
|
|
12
|
+
import type { RunOrigin } from "./run-origin.js";
|
|
12
13
|
/** The facets a steer's replay identity is made of, in the order a refusal lists them. Closed. */
|
|
13
|
-
export declare const STEER_REPLAY_FACETS: readonly ["text", "trusted", "priority", "actor"];
|
|
14
|
+
export declare const STEER_REPLAY_FACETS: readonly ["text", "trusted", "priority", "actor", "runOrigin"];
|
|
14
15
|
export type SteerReplayFacet = (typeof STEER_REPLAY_FACETS)[number];
|
|
15
16
|
/** What a seat remembers a steer by: the caller's own statement, as validated. The parked entry and the live park
|
|
16
17
|
* record both are this shape. An absent `priority` reads as `"next"` ({@link steerPriorityOf}). */
|
|
@@ -19,6 +20,7 @@ export interface SteerReplayRecord {
|
|
|
19
20
|
readonly trusted: boolean;
|
|
20
21
|
readonly priority?: SystemInjectionPriority;
|
|
21
22
|
readonly actor?: ActorAssertion;
|
|
23
|
+
readonly runOrigin?: RunOrigin;
|
|
22
24
|
}
|
|
23
25
|
/** The facets `repeat` differs from `held` in, in {@link STEER_REPLAY_FACETS} order. Empty = the idempotent replay. */
|
|
24
26
|
export declare function steerReplayDiffers(held: SteerReplayRecord, repeat: SteerReplayRecord): SteerReplayFacet[];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { steerPriorityOf } from "./task-notification.js";
|
|
2
|
-
export const STEER_REPLAY_FACETS = Object.freeze(["text", "trusted", "priority", "actor"]);
|
|
2
|
+
export const STEER_REPLAY_FACETS = Object.freeze(["text", "trusted", "priority", "actor", "runOrigin"]);
|
|
3
3
|
const FACET_IS_SAME = {
|
|
4
4
|
text: (a, b) => a.text === b.text,
|
|
5
5
|
trusted: (a, b) => a.trusted === b.trusted,
|
|
6
6
|
priority: (a, b) => steerPriorityOf(a) === steerPriorityOf(b),
|
|
7
7
|
actor: (a, b) => a.actor?.id === b.actor?.id && a.actor?.hostAsserted === b.actor?.hostAsserted && a.actor?.issuer === b.actor?.issuer,
|
|
8
|
+
runOrigin: (a, b) => a.runOrigin === b.runOrigin,
|
|
8
9
|
};
|
|
9
10
|
export function steerReplayDiffers(held, repeat) {
|
|
10
11
|
return STEER_REPLAY_FACETS.filter((facet) => !FACET_IS_SAME[facet](held, repeat));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
2
|
import { STALE_RUNNING_REAP_ATTRIBUTION, } from "../background-agent-store.js";
|
|
3
|
+
import { CLAMP_SEATS, CLAMP_SET } from "../child-clamp-seats.js";
|
|
3
4
|
import { beginContract } from "./contract-harness.js";
|
|
4
5
|
export const BACKGROUND_AGENT_CONTRACT_SCOPE = "tenant-A";
|
|
5
6
|
function record(over = {}) {
|
|
@@ -72,6 +73,32 @@ export async function backgroundAgentStoreContract(mk, runAssertion) {
|
|
|
72
73
|
assert.deepEqual(afterCas.admittedOrgScopes, ["org:acme"]);
|
|
73
74
|
assert.equal(afterCas.admittedOrgWriteScope, null);
|
|
74
75
|
});
|
|
76
|
+
run("the birth floor round-trips verbatim — `{}` stays `{}`, ABSENT stays absent, a CAS carries it", async (make) => {
|
|
77
|
+
const store = make();
|
|
78
|
+
const restricting = Object.fromEntries(CLAMP_SEATS.flatMap((seat) => {
|
|
79
|
+
const row = CLAMP_SET[seat];
|
|
80
|
+
if (row.law !== "restricting")
|
|
81
|
+
return [];
|
|
82
|
+
const field = row.field;
|
|
83
|
+
return [[seat, field === undefined ? row.value : { [field]: row.value }]];
|
|
84
|
+
}));
|
|
85
|
+
const floor = { ...restricting, readDenyPatterns: [".ssh", { pattern: "Secrets", caseSensitive: true }] };
|
|
86
|
+
await store.put(record({ handle: "a1", policyFloor: floor }));
|
|
87
|
+
assert.deepEqual((await held(store, "a1")).policyFloor, floor);
|
|
88
|
+
await store.put(record({ handle: "a2", policyFloor: {} }));
|
|
89
|
+
assert.deepEqual((await held(store, "a2")).policyFloor, {}, "an empty floor is a statement — it must not read back absent");
|
|
90
|
+
await store.put(record({ handle: "a3" }));
|
|
91
|
+
const untouched = await held(store, "a3");
|
|
92
|
+
assert.equal(untouched.policyFloor, undefined, "a row that states no floor must not read back with one");
|
|
93
|
+
for (const handle of ["a1", "a2"]) {
|
|
94
|
+
const before = await held(store, handle);
|
|
95
|
+
assert.equal(await store.update(handle, S, { ...before, status: "completed", settledAt: 2_000 }, { rev: before.rev }), true, `a CAS on a floor-bearing row (${handle}) must land`);
|
|
96
|
+
const after = await held(store, handle);
|
|
97
|
+
assert.equal(after.status, "completed");
|
|
98
|
+
assert.equal(after.rev, before.rev + 1);
|
|
99
|
+
assert.deepEqual(after.policyFloor, before.policyFloor, `a CAS update must carry the floor it did not change (${handle})`);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
75
102
|
run("put refuses a scopeless row (a row with no tenant partition would be world-readable)", async (make) => {
|
|
76
103
|
const store = make();
|
|
77
104
|
await assert.rejects(store.put(record({ scope: "" })), "an empty scope must be refused loudly, not stored");
|
|
@@ -308,7 +308,7 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
308
308
|
const stored = (await store.get(bitless.token)).pendingAction;
|
|
309
309
|
assert.equal("hasBidiControls" in stored, false, "projection backfill must not write back to the row");
|
|
310
310
|
});
|
|
311
|
-
run("the approval object's members: a row's identity + face group and its targets (capabilityId/contractId/shapeDigest/implementationRevision + family/pathTarget/hostTarget/names + targets + targetReads + engineMounted) survive the round-trip verbatim; an absent group stays absent", async () => {
|
|
311
|
+
run("the approval object's members: a row's identity + face group and its targets (capabilityId/contractId/shapeDigest/implementationRevision + family/pathTarget/hostTarget/names + targets + targetReads + engineMounted + declarationDigest) survive the round-trip verbatim; an absent group stays absent", async () => {
|
|
312
312
|
const store = make();
|
|
313
313
|
const carried = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "id-carried" });
|
|
314
314
|
const group = {
|
|
@@ -322,6 +322,7 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
322
322
|
targets: { protective: "/srv/work/out.txt", declared: "/srv/work/out.txt" },
|
|
323
323
|
targetReads: { ["0123456789abcdef".repeat(4)]: "fedcba9876543210".repeat(4) },
|
|
324
324
|
engineMounted: true,
|
|
325
|
+
declarationDigest: "0123456789abcdef".repeat(4),
|
|
325
326
|
};
|
|
326
327
|
Object.assign(carried.pendingAction, group);
|
|
327
328
|
const bare = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "id-bare" });
|
|
@@ -332,7 +333,7 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
332
333
|
assert.deepEqual(back[k], v, `the row's ${k} must survive the round-trip verbatim (a whitelisting serializer that drops it makes every resume-edit recheck judge by the catalog's slot for the NAME)`);
|
|
333
334
|
const bareBack = (await store.get(bare.token)).pendingAction;
|
|
334
335
|
for (const k of Object.keys(group))
|
|
335
|
-
assert.equal(k in bareBack, false, `an absent ${k} must stay OMITTED (a
|
|
336
|
+
assert.equal(k in bareBack, false, `an absent ${k} must stay OMITTED (a row without its tool member binds no tool, never a partial one)`);
|
|
336
337
|
const fetchRow = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "id-host" });
|
|
337
338
|
Object.assign(fetchRow.pendingAction, { ...group, family: "web", pathTarget: undefined, targets: undefined, hostTarget: { param: "url" } });
|
|
338
339
|
delete fetchRow.pendingAction.pathTarget;
|
|
@@ -429,6 +430,23 @@ export async function checkpointStoreContract(make, runAssertion, options = {})
|
|
|
429
430
|
const bareBack = (await store.get(bare.token));
|
|
430
431
|
assert.equal("requires" in bareBack || "requirementsDigest" in bareBack, false, "a row without a list or digest must stay without (never [] / null / \"\")");
|
|
431
432
|
});
|
|
433
|
+
run("run origin: a row's `state.runOrigin` survives the round-trip verbatim and rides the listing; absent stays absent; a word outside the set is kept on the row and reads as absent in the listing", async () => {
|
|
434
|
+
const store = make();
|
|
435
|
+
const member = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "ro-member" });
|
|
436
|
+
Object.assign(member.state, { runOrigin: "scheduled" });
|
|
437
|
+
const absent = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "ro-absent" });
|
|
438
|
+
const bogus = createCheckpointFixture({ token: mintCheckpointToken(), sessionId: "ro-bogus" });
|
|
439
|
+
Object.assign(bogus.state, { runOrigin: "weekly" });
|
|
440
|
+
for (const cp of [member, absent, bogus])
|
|
441
|
+
await store.put(cp.token, cp);
|
|
442
|
+
const byId = new Map((await store.listByScope("tenant-a")).map((s) => [s.sessionId, s]));
|
|
443
|
+
assert.equal((await store.get(member.token)).state.runOrigin, "scheduled", "the row's runOrigin must survive the round-trip verbatim");
|
|
444
|
+
assert.equal(byId.get("ro-member")?.runOrigin, "scheduled", "the listing must echo the row's runOrigin");
|
|
445
|
+
assert.equal("runOrigin" in (await store.get(absent.token)).state, false, "an absent runOrigin must stay OMITTED on the row, never a fabricated member");
|
|
446
|
+
assert.equal("runOrigin" in byId.get("ro-absent"), false, "absent must project the key OMITTED, not null / empty");
|
|
447
|
+
assert.equal((await store.get(bogus.token)).state.runOrigin, "weekly", "a word outside the set must be kept on the row verbatim");
|
|
448
|
+
assert.equal("runOrigin" in byId.get("ro-bogus"), false, "a word outside the closed set must read as absent in the listing, never project verbatim");
|
|
449
|
+
});
|
|
432
450
|
run("decider pair: a policy-decided allow resolves like a person's — its `policy_allowed` record (party `policy`, the attribution) round-trips verbatim on the resolved winner and as the execution record; the same record is already_recorded, a person's record for that row conflicts", async () => {
|
|
433
451
|
const store = make();
|
|
434
452
|
const cp = createCheckpointFixture();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
|
-
import { MAILBOX_INVALID_PEER_META_CODE, MAILBOX_INVALID_DECISION_MOVE_CODE, MAILBOX_TOMBSTONED_RECIPIENT_CODE } from "../mailbox-store.js";
|
|
2
|
+
import { MAILBOX_DUPLICATE_RECORD_ID_CODE, MAILBOX_INVALID_PEER_META_CODE, MAILBOX_INVALID_DECISION_MOVE_CODE, MAILBOX_INVALID_RECORD_ID_CODE, MAILBOX_TOMBSTONED_RECIPIENT_CODE } from "../mailbox-store.js";
|
|
3
3
|
import { beginContract } from "./contract-harness.js";
|
|
4
4
|
import { PRINCIPAL_INBOX_HANDLE } from "../../agents/cross-session-ref.js";
|
|
5
5
|
import { mintCrossPrincipalRecord } from "../../agents/org-delivery-gate.js";
|
|
@@ -50,6 +50,36 @@ export async function mailboxStoreContract(mk, runAssertion) {
|
|
|
50
50
|
await s.ack(S, "a1", "w3", 1);
|
|
51
51
|
assert.equal(await s.append(S, "a1", msg("m2")), 2);
|
|
52
52
|
});
|
|
53
|
+
run("记录身份:箱持有同 id 时 append = 同记录回原 seq 零写 / 异记录点名拒;坏 id 零副作用拒;id 往返;ack 后 id 自由", async (make) => {
|
|
54
|
+
const s = make();
|
|
55
|
+
const codeOf = async (p) => {
|
|
56
|
+
try {
|
|
57
|
+
await p;
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
return e.code;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const rec = { id: "frame-1", from: "w", content: "m1", sentAt: 1000, hopChain: ["h"], peerMeta: { kind: "peer_message", fromRoot: "root" } };
|
|
65
|
+
assert.equal(await s.append(S, "a1", rec), 1);
|
|
66
|
+
assert.equal(await s.append(S, "a1", { ...rec, sentAt: 5000 }), 1, "同记录再写(写入时刻不同)= 重放,回原 seq");
|
|
67
|
+
assert.equal(await s.peekCount(S, "a1"), 1, "重放零写");
|
|
68
|
+
for (const changed of [{ content: "m1'" }, { from: "x" }, { hopChain: [] }, { peerMeta: undefined }]) {
|
|
69
|
+
assert.equal(await codeOf(s.append(S, "a1", { ...rec, ...changed })), MAILBOX_DUPLICATE_RECORD_ID_CODE, JSON.stringify(changed));
|
|
70
|
+
}
|
|
71
|
+
for (const bad of ["", 7, null]) {
|
|
72
|
+
const raw = JSON.parse(JSON.stringify({ id: bad, content: "c", sentAt: 1 }));
|
|
73
|
+
assert.equal(await codeOf(s.append(S, "a1", raw)), MAILBOX_INVALID_RECORD_ID_CODE, String(bad));
|
|
74
|
+
}
|
|
75
|
+
assert.equal(await s.peekCount(S, "a1"), 1, "被拒的调用零副作用");
|
|
76
|
+
assert.equal(await s.append(S, "a1", msg("plain")), 2, "无 id = 新记录");
|
|
77
|
+
assert.equal(await s.append(S, "a2", rec), 1, "同 id 在别的箱 = 别的记录");
|
|
78
|
+
const lease = await s.claimLease(S, "a1", "w1", 60_000, 10_000);
|
|
79
|
+
assert.deepEqual(lease.messages.map((m) => m.id), ["frame-1", undefined], "id 往返,缺席仍缺席");
|
|
80
|
+
await s.ack(S, "a1", "w1", lease.maxSeq);
|
|
81
|
+
assert.equal(await s.append(S, "a1", rec), 3, "箱只为它持有的记录作答:ack 后同 id 是新记录");
|
|
82
|
+
});
|
|
53
83
|
run("lease 窗内 append:后到消息在下次 claim 时可见(lease 只覆盖 claim 时刻快照)", async (make) => {
|
|
54
84
|
const s = make();
|
|
55
85
|
await s.append(S, "a1", msg("m1"));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert";
|
|
2
|
+
import { sessionLogMarkOf } from "../../internal/harness.js";
|
|
2
3
|
import { TtlSessionStore } from "../session-store.js";
|
|
3
4
|
import { beginContract } from "./contract-harness.js";
|
|
4
5
|
const SESSION_ENTRY = (id, parentId) => ({
|
|
@@ -142,7 +143,7 @@ export async function sessionRepoContract(make, runAssertion) {
|
|
|
142
143
|
assert.equal((await again.getMetadata()).incarnation, token, "and the same occupant");
|
|
143
144
|
assert.equal((await (await repo.open({ id: A, createdAt: "" })).getMetadata()).owner, "kit-x");
|
|
144
145
|
});
|
|
145
|
-
run("fork records the owner its options name in the fork row, else (absent or null) the source row's; importEntries onto an existing row keeps its metadata whole, onto an absent id records the importer", async () => {
|
|
146
|
+
run("fork records the owner its options name in the fork row, else (absent or null) the source row's; importEntries onto an existing row keeps its metadata whole and lands only when the row is the importer's (another owner's, or an owned row by an anonymous import, is refused conflict with nothing written), onto an absent id records the importer", async () => {
|
|
146
147
|
const repo = make();
|
|
147
148
|
const src = await repo.create({ id: A, owner: "kit-alice" });
|
|
148
149
|
await src.getStorage().appendEntry(SESSION_ENTRY("e1", null));
|
|
@@ -155,15 +156,28 @@ export async function sessionRepoContract(make, runAssertion) {
|
|
|
155
156
|
if (repo.importEntries === undefined)
|
|
156
157
|
return;
|
|
157
158
|
const token = (await src.getMetadata()).incarnation;
|
|
158
|
-
await repo.
|
|
159
|
+
const logOf = async (id) => (await (await repo.open({ id, createdAt: "" })).getStorage().getEntries()).map((e) => e.id);
|
|
160
|
+
const refusedAsConflict = async (owner, what) => {
|
|
161
|
+
let code;
|
|
162
|
+
try {
|
|
163
|
+
await repo.importEntries(A, owner, [SESSION_ENTRY("x1", null)]);
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
code = err?.code;
|
|
167
|
+
}
|
|
168
|
+
assert.equal(code, "conflict", `${what}: an import lands only on the importer's row`);
|
|
169
|
+
assert.deepEqual(await logOf(A), ["e1"], `${what}: a refused import writes nothing`);
|
|
170
|
+
};
|
|
171
|
+
await refusedAsConflict("kit-carol", "an import by another principal");
|
|
172
|
+
await refusedAsConflict(undefined, "an import with no principal onto an owned row");
|
|
173
|
+
await repo.importEntries(A, "kit-alice", [SESSION_ENTRY("n1", null)]);
|
|
159
174
|
const imported = await (await repo.open({ id: A, createdAt: "" })).getMetadata();
|
|
175
|
+
assert.deepEqual(await logOf(A), ["n1"], "the owner's import replaces the log");
|
|
160
176
|
assert.equal(imported.owner, "kit-alice", "the owner is recorded only by the write that creates the row: an import never re-stamps it");
|
|
161
177
|
assert.equal(imported.incarnation, token, "the log is replaced, not the occupant");
|
|
162
|
-
await repo.importEntries(A, undefined, []);
|
|
163
|
-
assert.equal((await (await repo.open({ id: A, createdAt: "" })).getMetadata()).owner, "kit-alice", "an import with no principal never makes an owned row anonymous");
|
|
164
178
|
const cells = (m) => [m.createdAt, m.forkedFrom, m.forkedFromIncarnation, m.incarnation, m.owner, JSON.stringify(m.placement)];
|
|
165
179
|
const forkRow = await (await repo.open({ id: B, createdAt: "" })).getMetadata();
|
|
166
|
-
await repo.importEntries(B, "kit-
|
|
180
|
+
await repo.importEntries(B, "kit-bob", [SESSION_ENTRY("e1", null)]);
|
|
167
181
|
assert.deepEqual(cells(await (await repo.open({ id: B, createdAt: "" })).getMetadata()), cells(forkRow), "the log is replaced, never the row: a fork row keeps its creation time and its lineage");
|
|
168
182
|
const E = "0198fa00-0000-7000-8000-00000000000e";
|
|
169
183
|
await repo.importEntries(E, "kit-carol", [SESSION_ENTRY("e1", null)]);
|
|
@@ -218,6 +232,99 @@ export async function sessionRepoContract(make, runAssertion) {
|
|
|
218
232
|
store.dispose();
|
|
219
233
|
}
|
|
220
234
|
});
|
|
235
|
+
const conflictOf = async (write) => {
|
|
236
|
+
try {
|
|
237
|
+
await write();
|
|
238
|
+
}
|
|
239
|
+
catch (err) {
|
|
240
|
+
return err?.code;
|
|
241
|
+
}
|
|
242
|
+
return "resolved";
|
|
243
|
+
};
|
|
244
|
+
const logIds = async (repo, id) => {
|
|
245
|
+
try {
|
|
246
|
+
return (await (await repo.open({ id, createdAt: "" })).getStorage().getEntries()).map((e) => e.id);
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
run("importEntries answers the head its write committed — the same head a head read answers right after it", async () => {
|
|
253
|
+
const repo = make();
|
|
254
|
+
if (repo.importEntries === undefined || repo.headOf === undefined)
|
|
255
|
+
return;
|
|
256
|
+
const fresh = await repo.importEntries(A, "kit-alice", [SESSION_ENTRY("e1", null), SESSION_ENTRY("e2", "e1")]);
|
|
257
|
+
assert.deepEqual(fresh, await repo.headOf(A), "an import onto an absent id answers the new row's head");
|
|
258
|
+
assert.equal(fresh.leafId, "e2");
|
|
259
|
+
const again = await repo.importEntries(A, "kit-alice", [SESSION_ENTRY("n1", null)]);
|
|
260
|
+
assert.deepEqual(again, await repo.headOf(A), "an import onto the importer's row answers that row's head after the write");
|
|
261
|
+
assert.equal(again.incarnation, fresh.incarnation, "the same occupant");
|
|
262
|
+
});
|
|
263
|
+
run("readRow (where the repo answers it): no row ⇒ undefined; a row ⇒ its metadata, its whole log oldest-first and the head a head read answers, of one row", async () => {
|
|
264
|
+
const repo = make();
|
|
265
|
+
if (repo.readRow === undefined)
|
|
266
|
+
return;
|
|
267
|
+
assert.equal(await repo.readRow(A), undefined);
|
|
268
|
+
const sess = await repo.create({ id: A, owner: "kit-alice" });
|
|
269
|
+
await sess.getStorage().appendEntry(SESSION_ENTRY("e1", null));
|
|
270
|
+
await sess.getStorage().appendEntry(SESSION_ENTRY("e2", "e1"));
|
|
271
|
+
const row = await repo.readRow(A);
|
|
272
|
+
assert.ok(row !== undefined);
|
|
273
|
+
assert.equal(row.metadata.owner, "kit-alice");
|
|
274
|
+
assert.deepEqual(row.entries.map((e) => e.id), ["e1", "e2"]);
|
|
275
|
+
if (repo.headOf !== undefined)
|
|
276
|
+
assert.deepEqual(row.head, await repo.headOf(A), "the head of the row read is the head read's");
|
|
277
|
+
if (repo.exportEntries !== undefined)
|
|
278
|
+
assert.deepEqual(row.entries, await repo.exportEntries(A), "the log of the row read is the export's");
|
|
279
|
+
});
|
|
280
|
+
run("a conditional import lands only on the row it expects: the row and log as read ⇒ written; after an append, a delete, a delete and create again, or with no row expected while one stands ⇒ conflict, nothing written", async () => {
|
|
281
|
+
const repo = make();
|
|
282
|
+
if (repo.readRow === undefined || repo.importEntries === undefined)
|
|
283
|
+
return;
|
|
284
|
+
const sess = await repo.create({ id: A, owner: "kit-alice" });
|
|
285
|
+
await sess.getStorage().appendEntry(SESSION_ENTRY("e1", null));
|
|
286
|
+
const read = (await repo.readRow(A));
|
|
287
|
+
const asRead = { row: read.head, log: sessionLogMarkOf(read.entries) };
|
|
288
|
+
await sess.getStorage().appendEntry(SESSION_ENTRY("e2", "e1"));
|
|
289
|
+
assert.equal(await conflictOf(() => repo.importEntries(A, "kit-alice", [SESSION_ENTRY("x1", null)], { expect: asRead })), "conflict", "an append since the read: the log is not the one read");
|
|
290
|
+
assert.deepEqual(await logIds(repo, A), ["e1", "e2"], "the refused import wrote nothing");
|
|
291
|
+
assert.equal(await conflictOf(() => repo.importEntries(A, "kit-alice", [SESSION_ENTRY("x1", null)], { expect: { row: null } })), "conflict", "no row expected, a row stands");
|
|
292
|
+
const now = (await repo.readRow(A));
|
|
293
|
+
await repo.importEntries(A, "kit-alice", [SESSION_ENTRY("n1", null)], { expect: { row: now.head, log: sessionLogMarkOf(now.entries) } });
|
|
294
|
+
assert.deepEqual(await logIds(repo, A), ["n1"], "the row and log as read: written");
|
|
295
|
+
const before = (await repo.readRow(A));
|
|
296
|
+
await repo.delete({ id: A, createdAt: "" });
|
|
297
|
+
assert.equal(await conflictOf(() => repo.importEntries(A, "kit-alice", [SESSION_ENTRY("x1", null)], { expect: { row: before.head } })), "conflict", "the row was deleted since the read");
|
|
298
|
+
assert.equal(await logIds(repo, A), undefined, "and no row was created");
|
|
299
|
+
await repo.create({ id: A, owner: "kit-alice" });
|
|
300
|
+
assert.equal(await conflictOf(() => repo.importEntries(A, "kit-alice", [SESSION_ENTRY("x1", null)], { expect: { row: before.head } })), "conflict", "the row was created again: another occupant, same owner");
|
|
301
|
+
assert.deepEqual(await logIds(repo, A), [], "the new row's log is untouched");
|
|
302
|
+
const noShape = { row: before.head, log: "a mark of no shape" };
|
|
303
|
+
await assert.rejects(() => repo.importEntries(A, "kit-alice", [SESSION_ENTRY("x1", null)], { expect: noShape }), TypeError, "an expectation of no shape is refused, never read as none");
|
|
304
|
+
assert.deepEqual(await logIds(repo, A), [], "and wrote nothing");
|
|
305
|
+
});
|
|
306
|
+
run("a conditional delete removes only the row it expects: another occupant or no row ⇒ conflict, nothing removed; an occupant-only expectation survives an append, an expectation binding the log does not", async () => {
|
|
307
|
+
const repo = make();
|
|
308
|
+
if (repo.readRow === undefined)
|
|
309
|
+
return;
|
|
310
|
+
const sess = await repo.create({ id: A, owner: "kit-alice" });
|
|
311
|
+
await sess.getStorage().appendEntry(SESSION_ENTRY("e1", null));
|
|
312
|
+
const read = (await repo.readRow(A));
|
|
313
|
+
await sess.getStorage().appendEntry(SESSION_ENTRY("e2", "e1"));
|
|
314
|
+
assert.equal(await conflictOf(() => repo.delete({ id: A, createdAt: "" }, { row: read.head, log: sessionLogMarkOf(read.entries) })), "conflict", "the log bound and appended to since: not deleted");
|
|
315
|
+
assert.deepEqual(await logIds(repo, A), ["e1", "e2"]);
|
|
316
|
+
await repo.delete({ id: A, createdAt: "" });
|
|
317
|
+
await repo.create({ id: A, owner: "kit-alice" });
|
|
318
|
+
assert.equal(await conflictOf(() => repo.delete({ id: A, createdAt: "" }, { row: read.head })), "conflict", "another occupant under the id: not deleted");
|
|
319
|
+
assert.deepEqual(await logIds(repo, A), [], "the new occupant stands");
|
|
320
|
+
const current = (await repo.readRow(A));
|
|
321
|
+
await (await repo.open({ id: A, createdAt: "" })).getStorage().appendEntry(SESSION_ENTRY("f1", null));
|
|
322
|
+
await repo.delete({ id: A, createdAt: "" }, { row: current.head });
|
|
323
|
+
assert.equal(await logIds(repo, A), undefined, "the occupant expected, appended to since: deleted (an append does not make it another row)");
|
|
324
|
+
assert.equal(await conflictOf(() => repo.delete({ id: A, createdAt: "" }, { row: current.head })), "conflict", "no row: an occupant expected is not there");
|
|
325
|
+
const noShape = { row: undefined };
|
|
326
|
+
await assert.rejects(() => repo.delete({ id: A, createdAt: "" }, noShape), TypeError, "an expectation of no shape is refused, never read as none");
|
|
327
|
+
});
|
|
221
328
|
run("the store over a repo answers headOf exactly when the repo does: present ⇒ the repo's own answer; absent ⇒ no headOf on the store, which still works", async () => {
|
|
222
329
|
const repo = make();
|
|
223
330
|
const store = new TtlSessionStore({ repo });
|
|
@@ -20,6 +20,9 @@ import { type ContractAssertionRunner } from "./contract-harness.js";
|
|
|
20
20
|
*
|
|
21
21
|
* Semantics since @sema-agent/core 7.56.0: the list reads the store's rows (a reopened store lists them), pages by the
|
|
22
22
|
* `(lastActiveAt, sessionId)` keyset, filters by the row's owner, and refuses a bad query through `readSessionListQuery`.
|
|
23
|
+
* Since 7.57.0: the write faces — `logTransfer` (one write law: a commit lands only on the committer's row, keeps an existing row's
|
|
24
|
+
* occupant, refuses a placed row, passes every entry through the import gate, writes nothing on any refusal) and the owner-guarded
|
|
25
|
+
* `delete` — and a cached view is served only while it holds the row's leaf as well as its occupant.
|
|
23
26
|
*/
|
|
24
27
|
export interface SessionStoreContractHooks {
|
|
25
28
|
/** Delete `sessionId`'s session ROW through the backend's own deletion path (history and all), so that a later
|
|
@@ -38,7 +41,7 @@ export interface SessionStoreContractHooks {
|
|
|
38
41
|
/** Optional faces (plus the replica hook, and `requireExisting` — absent = the store rejects the option, its other
|
|
39
42
|
* legal mode) a run verified or found absent; reported per judging case, after its assertions held. */
|
|
40
43
|
onOptionalMember?: (report: {
|
|
41
|
-
member: "requireExisting" | "forget" | "fork" | "list" | "noteTaskRun" | "listPlaced" | "placements" | "headOf" | "ownership" | "replica";
|
|
44
|
+
member: "requireExisting" | "forget" | "fork" | "list" | "noteTaskRun" | "listPlaced" | "placements" | "headOf" | "ownership" | "replica" | "logTransfer" | "delete";
|
|
42
45
|
status: "verified" | "absent";
|
|
43
46
|
}) => void;
|
|
44
47
|
}
|