@namzu/sdk 38.2.1 → 39.0.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 +700 -0
- package/dist/advisory/executor.d.ts +10 -1
- package/dist/advisory/executor.d.ts.map +1 -1
- package/dist/advisory/executor.js +5 -26
- package/dist/advisory/executor.js.map +1 -1
- package/dist/advisory/history.d.ts +9 -0
- package/dist/advisory/history.d.ts.map +1 -0
- package/dist/advisory/history.js +120 -0
- package/dist/advisory/history.js.map +1 -0
- package/dist/advisory/index.d.ts +1 -1
- package/dist/advisory/index.d.ts.map +1 -1
- package/dist/advisory/index.js.map +1 -1
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +3 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/runAgent.d.ts +10 -0
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +3 -0
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/compaction/manual.d.ts +6 -0
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +21 -2
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/summary.d.ts.map +1 -1
- package/dist/compaction/summary.js +4 -1
- package/dist/compaction/summary.js.map +1 -1
- package/dist/config/runtime.js +2 -2
- package/dist/config/runtime.js.map +1 -1
- package/dist/contracts/schemas.js +1 -1
- package/dist/contracts/schemas.js.map +1 -1
- package/dist/eval/harness-protection.d.ts +18 -0
- package/dist/eval/harness-protection.d.ts.map +1 -0
- package/dist/eval/harness-protection.js +58 -0
- package/dist/eval/harness-protection.js.map +1 -0
- package/dist/eval/harness-verification.d.ts +6 -1
- package/dist/eval/harness-verification.d.ts.map +1 -1
- package/dist/eval/harness-verification.js +19 -2
- package/dist/eval/harness-verification.js.map +1 -1
- package/dist/eval/index.d.ts +1 -0
- package/dist/eval/index.d.ts.map +1 -1
- package/dist/eval/index.js.map +1 -1
- package/dist/manager/resident/activity.d.ts +50 -0
- package/dist/manager/resident/activity.d.ts.map +1 -0
- package/dist/manager/resident/activity.js +125 -0
- package/dist/manager/resident/activity.js.map +1 -0
- package/dist/manager/resident/agenda.d.ts +13 -1
- package/dist/manager/resident/agenda.d.ts.map +1 -1
- package/dist/manager/resident/agenda.js +40 -5
- package/dist/manager/resident/agenda.js.map +1 -1
- package/dist/manager/resident/consumption.d.ts +104 -0
- package/dist/manager/resident/consumption.d.ts.map +1 -0
- package/dist/manager/resident/consumption.js +233 -0
- package/dist/manager/resident/consumption.js.map +1 -0
- package/dist/manager/resident/evidence-recall.d.ts +24 -0
- package/dist/manager/resident/evidence-recall.d.ts.map +1 -0
- package/dist/manager/resident/evidence-recall.js +295 -0
- package/dist/manager/resident/evidence-recall.js.map +1 -0
- package/dist/manager/resident/history-disk.d.ts +10 -0
- package/dist/manager/resident/history-disk.d.ts.map +1 -0
- package/dist/manager/resident/history-disk.js +50 -0
- package/dist/manager/resident/history-disk.js.map +1 -0
- package/dist/manager/resident/history.d.ts +79 -0
- package/dist/manager/resident/history.d.ts.map +1 -0
- package/dist/manager/resident/history.js +203 -0
- package/dist/manager/resident/history.js.map +1 -0
- package/dist/manager/resident/initiative.d.ts.map +1 -1
- package/dist/manager/resident/initiative.js +11 -3
- package/dist/manager/resident/initiative.js.map +1 -1
- package/dist/manager/resident/learning-cycle.d.ts +131 -0
- package/dist/manager/resident/learning-cycle.d.ts.map +1 -0
- package/dist/manager/resident/learning-cycle.js +306 -0
- package/dist/manager/resident/learning-cycle.js.map +1 -0
- package/dist/manager/resident/learning-observation.d.ts +80 -0
- package/dist/manager/resident/learning-observation.d.ts.map +1 -0
- package/dist/manager/resident/learning-observation.js +22 -0
- package/dist/manager/resident/learning-observation.js.map +1 -0
- package/dist/manager/resident/learning-store.d.ts +106 -0
- package/dist/manager/resident/learning-store.d.ts.map +1 -0
- package/dist/manager/resident/learning-store.js +598 -0
- package/dist/manager/resident/learning-store.js.map +1 -0
- package/dist/manager/resident/learning.d.ts +246 -3
- package/dist/manager/resident/learning.d.ts.map +1 -1
- package/dist/manager/resident/learning.js +96 -6
- package/dist/manager/resident/learning.js.map +1 -1
- package/dist/manager/resident/outbox.d.ts +4 -4
- package/dist/manager/resident/store.d.ts +37 -4
- package/dist/manager/resident/store.d.ts.map +1 -1
- package/dist/manager/resident/store.js +27 -3
- package/dist/manager/resident/store.js.map +1 -1
- package/dist/manager/resident/tool-evidence.d.ts +71 -0
- package/dist/manager/resident/tool-evidence.d.ts.map +1 -0
- package/dist/manager/resident/tool-evidence.js +285 -0
- package/dist/manager/resident/tool-evidence.js.map +1 -0
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +6 -0
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +5 -3
- package/dist/plugin/loader.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +2 -0
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/prompt/index.d.ts +2 -0
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/index.js +1 -0
- package/dist/prompt/index.js.map +1 -1
- package/dist/prompt/resident-learning.d.ts +19 -0
- package/dist/prompt/resident-learning.d.ts.map +1 -0
- package/dist/prompt/resident-learning.js +125 -0
- package/dist/prompt/resident-learning.js.map +1 -0
- package/dist/prompt/resident-step.d.ts +8 -1
- package/dist/prompt/resident-step.d.ts.map +1 -1
- package/dist/prompt/resident-step.js +65 -4
- package/dist/prompt/resident-step.js.map +1 -1
- package/dist/provider/collect-chat-completion.d.ts +2 -1
- package/dist/provider/collect-chat-completion.d.ts.map +1 -1
- package/dist/provider/collect-chat-completion.js +7 -6
- package/dist/provider/collect-chat-completion.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +2 -1
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/stream-text.d.ts +16 -0
- package/dist/provider/stream-text.d.ts.map +1 -0
- package/dist/provider/stream-text.js +51 -0
- package/dist/provider/stream-text.js.map +1 -0
- package/dist/public-runtime.d.ts +13 -3
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +12 -3
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +2 -0
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +2 -0
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +15 -3
- package/dist/public-types.d.ts.map +1 -1
- package/dist/run/LimitChecker.js +3 -3
- package/dist/run/LimitChecker.js.map +1 -1
- package/dist/run/evidence-query.d.ts +41 -0
- package/dist/run/evidence-query.d.ts.map +1 -0
- package/dist/run/evidence-query.js +270 -0
- package/dist/run/evidence-query.js.map +1 -0
- package/dist/run/evidence-recall.d.ts +99 -0
- package/dist/run/evidence-recall.d.ts.map +1 -0
- package/dist/run/evidence-recall.js +633 -0
- package/dist/run/evidence-recall.js.map +1 -0
- package/dist/run/index.d.ts +2 -0
- package/dist/run/index.d.ts.map +1 -1
- package/dist/run/index.js +1 -0
- package/dist/run/index.js.map +1 -1
- package/dist/run/json-claim-verifier.d.ts +83 -0
- package/dist/run/json-claim-verifier.d.ts.map +1 -0
- package/dist/run/json-claim-verifier.js +200 -0
- package/dist/run/json-claim-verifier.js.map +1 -0
- package/dist/run/preparation-context-error.d.ts +10 -0
- package/dist/run/preparation-context-error.d.ts.map +1 -0
- package/dist/run/preparation-context-error.js +15 -0
- package/dist/run/preparation-context-error.js.map +1 -0
- package/dist/run-query/index.d.ts +3 -1
- package/dist/run-query/index.d.ts.map +1 -1
- package/dist/runtime/query/callback-inference.d.ts +8 -0
- package/dist/runtime/query/callback-inference.d.ts.map +1 -0
- package/dist/runtime/query/callback-inference.js +89 -0
- package/dist/runtime/query/callback-inference.js.map +1 -0
- package/dist/runtime/query/checkpoint.d.ts +4 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +13 -0
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/events.d.ts +1 -0
- package/dist/runtime/query/events.d.ts.map +1 -1
- package/dist/runtime/query/events.js +18 -0
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +7 -1
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +38 -7
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/file-evidence-context.d.ts +5 -0
- package/dist/runtime/query/file-evidence-context.d.ts.map +1 -0
- package/dist/runtime/query/file-evidence-context.js +64 -0
- package/dist/runtime/query/file-evidence-context.js.map +1 -0
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +4 -0
- package/dist/runtime/query/guard.js.map +1 -1
- package/dist/runtime/query/index.d.ts +10 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +39 -24
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +9 -31
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +231 -93
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.d.ts +2 -1
- package/dist/runtime/query/iteration/phases/advisory.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +2 -1
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +2 -1
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +3 -0
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts +2 -1
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts.map +1 -1
- package/dist/runtime/query/iteration/provider-rejected-image.js +5 -2
- package/dist/runtime/query/iteration/provider-rejected-image.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts +4 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +22 -8
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts +18 -33
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +59 -42
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +4 -4
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +10 -9
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/sandbox-lifecycle.d.ts.map +1 -1
- package/dist/runtime/query/sandbox-lifecycle.js +4 -0
- package/dist/runtime/query/sandbox-lifecycle.js.map +1 -1
- package/dist/runtime/query/tool-output-budget.d.ts +10 -6
- package/dist/runtime/query/tool-output-budget.d.ts.map +1 -1
- package/dist/runtime/query/tool-output-budget.js +54 -12
- package/dist/runtime/query/tool-output-budget.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +3 -1
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +4 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts +3 -0
- package/dist/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +28 -0
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/store/evidence/compaction-archive.d.ts +109 -0
- package/dist/store/evidence/compaction-archive.d.ts.map +1 -0
- package/dist/store/evidence/compaction-archive.js +125 -0
- package/dist/store/evidence/compaction-archive.js.map +1 -0
- package/dist/store/evidence/compaction-provenance.d.ts +7 -0
- package/dist/store/evidence/compaction-provenance.d.ts.map +1 -0
- package/dist/store/evidence/compaction-provenance.js +49 -0
- package/dist/store/evidence/compaction-provenance.js.map +1 -0
- package/dist/store/evidence/compaction-text.d.ts +16 -0
- package/dist/store/evidence/compaction-text.d.ts.map +1 -0
- package/dist/store/evidence/compaction-text.js +51 -0
- package/dist/store/evidence/compaction-text.js.map +1 -0
- package/dist/store/evidence/disk.d.ts +11 -0
- package/dist/store/evidence/disk.d.ts.map +1 -0
- package/dist/store/evidence/disk.js +367 -0
- package/dist/store/evidence/disk.js.map +1 -0
- package/dist/store/evidence/format.d.ts +25 -0
- package/dist/store/evidence/format.d.ts.map +1 -0
- package/dist/store/evidence/format.js +115 -0
- package/dist/store/evidence/format.js.map +1 -0
- package/dist/store/evidence/index-page.d.ts +208 -0
- package/dist/store/evidence/index-page.d.ts.map +1 -0
- package/dist/store/evidence/index-page.js +262 -0
- package/dist/store/evidence/index-page.js.map +1 -0
- package/dist/store/evidence/io.d.ts +24 -0
- package/dist/store/evidence/io.d.ts.map +1 -0
- package/dist/store/evidence/io.js +69 -0
- package/dist/store/evidence/io.js.map +1 -0
- package/dist/store/evidence/linked.d.ts +9 -0
- package/dist/store/evidence/linked.d.ts.map +1 -0
- package/dist/store/evidence/linked.js +314 -0
- package/dist/store/evidence/linked.js.map +1 -0
- package/dist/store/evidence/passages.d.ts +15 -0
- package/dist/store/evidence/passages.d.ts.map +1 -0
- package/dist/store/evidence/passages.js +72 -0
- package/dist/store/evidence/passages.js.map +1 -0
- package/dist/store/evidence/record-chain.d.ts +42 -0
- package/dist/store/evidence/record-chain.d.ts.map +1 -0
- package/dist/store/evidence/record-chain.js +111 -0
- package/dist/store/evidence/record-chain.js.map +1 -0
- package/dist/store/evidence/search-input.d.ts +21 -0
- package/dist/store/evidence/search-input.d.ts.map +1 -0
- package/dist/store/evidence/search-input.js +44 -0
- package/dist/store/evidence/search-input.js.map +1 -0
- package/dist/store/evidence/selection.d.ts +9 -0
- package/dist/store/evidence/selection.d.ts.map +1 -0
- package/dist/store/evidence/selection.js +17 -0
- package/dist/store/evidence/selection.js.map +1 -0
- package/dist/store/evidence/source-kind.d.ts +11 -0
- package/dist/store/evidence/source-kind.d.ts.map +1 -0
- package/dist/store/evidence/source-kind.js +26 -0
- package/dist/store/evidence/source-kind.js.map +1 -0
- package/dist/store/evidence/source-text.d.ts +51 -0
- package/dist/store/evidence/source-text.d.ts.map +1 -0
- package/dist/store/evidence/source-text.js +213 -0
- package/dist/store/evidence/source-text.js.map +1 -0
- package/dist/store/evidence/types.d.ts +162 -0
- package/dist/store/evidence/types.d.ts.map +1 -0
- package/dist/store/evidence/types.js +2 -0
- package/dist/store/evidence/types.js.map +1 -0
- package/dist/store/memory/disk.d.ts +2 -0
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +2 -1
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/run/disk.d.ts +10 -0
- package/dist/store/run/disk.d.ts.map +1 -1
- package/dist/store/run/disk.js +87 -7
- package/dist/store/run/disk.js.map +1 -1
- package/dist/store/run/memory.d.ts +1 -0
- package/dist/store/run/memory.d.ts.map +1 -1
- package/dist/store/run/memory.js +10 -0
- package/dist/store/run/memory.js.map +1 -1
- package/dist/store/run/tool-executions.d.ts +13 -0
- package/dist/store/run/tool-executions.d.ts.map +1 -0
- package/dist/store/run/tool-executions.js +99 -0
- package/dist/store/run/tool-executions.js.map +1 -0
- package/dist/store/session/index.d.ts +2 -0
- package/dist/store/session/index.d.ts.map +1 -1
- package/dist/store/session/index.js +1 -0
- package/dist/store/session/index.js.map +1 -1
- package/dist/store/session/sqlite.d.ts +57 -0
- package/dist/store/session/sqlite.d.ts.map +1 -0
- package/dist/store/session/sqlite.js +430 -0
- package/dist/store/session/sqlite.js.map +1 -0
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -5
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/write-file.js +2 -2
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/defineTool.d.ts +2 -1
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +1 -1
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/file-read-tracker.d.ts.map +1 -1
- package/dist/tools/file-read-tracker.js +12 -3
- package/dist/tools/file-read-tracker.js.map +1 -1
- package/dist/tools/resident-history.d.ts +10 -0
- package/dist/tools/resident-history.d.ts.map +1 -0
- package/dist/tools/resident-history.js +80 -0
- package/dist/tools/resident-history.js.map +1 -0
- package/dist/tools/resident-tool-evidence.d.ts +5 -0
- package/dist/tools/resident-tool-evidence.d.ts.map +1 -0
- package/dist/tools/resident-tool-evidence.js +57 -0
- package/dist/tools/resident-tool-evidence.js.map +1 -0
- package/dist/types/advisory/config.d.ts +7 -0
- package/dist/types/advisory/config.d.ts.map +1 -1
- package/dist/types/agent/reactive.d.ts +1 -0
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +9 -9
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +1 -1
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/hitl/index.d.ts +4 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +16 -2
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +8 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +2 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +4 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/run/answer-review.d.ts +34 -3
- package/dist/types/run/answer-review.d.ts.map +1 -1
- package/dist/types/run/config.d.ts +3 -0
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/entity.d.ts +7 -0
- package/dist/types/run/entity.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +31 -8
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/run/prepare-step.d.ts +53 -8
- package/dist/types/run/prepare-step.d.ts.map +1 -1
- package/dist/types/run/store.d.ts +29 -4
- package/dist/types/run/store.d.ts.map +1 -1
- package/dist/types/run/store.js +0 -28
- package/dist/types/run/store.js.map +1 -1
- package/dist/types/tool/index.d.ts +15 -1
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/utils/await-with-abort.d.ts +8 -0
- package/dist/utils/await-with-abort.d.ts.map +1 -0
- package/dist/utils/await-with-abort.js +28 -0
- package/dist/utils/await-with-abort.js.map +1 -0
- package/dist/utils/evidence-time.d.ts +3 -0
- package/dist/utils/evidence-time.d.ts.map +1 -0
- package/dist/utils/evidence-time.js +10 -0
- package/dist/utils/evidence-time.js.map +1 -0
- package/dist/utils/evidence-tokens.d.ts +13 -0
- package/dist/utils/evidence-tokens.d.ts.map +1 -0
- package/dist/utils/evidence-tokens.js +29 -0
- package/dist/utils/evidence-tokens.js.map +1 -0
- package/package.json +1 -1
- package/src/advisory/executor.ts +15 -30
- package/src/advisory/history.ts +126 -0
- package/src/advisory/index.ts +5 -1
- package/src/agents/ReactiveAgent.ts +3 -0
- package/src/agents/runAgent.ts +14 -1
- package/src/compaction/manual.ts +30 -2
- package/src/compaction/summary.ts +4 -1
- package/src/config/runtime.ts +2 -2
- package/src/contracts/schemas.ts +1 -1
- package/src/eval/harness-protection.ts +79 -0
- package/src/eval/harness-verification.ts +31 -1
- package/src/eval/index.ts +1 -0
- package/src/manager/resident/activity.ts +187 -0
- package/src/manager/resident/agenda.ts +59 -5
- package/src/manager/resident/consumption.ts +311 -0
- package/src/manager/resident/evidence-recall.ts +363 -0
- package/src/manager/resident/history-disk.ts +63 -0
- package/src/manager/resident/history.ts +312 -0
- package/src/manager/resident/initiative.ts +13 -3
- package/src/manager/resident/learning-cycle.ts +499 -0
- package/src/manager/resident/learning-observation.ts +39 -0
- package/src/manager/resident/learning-store.ts +813 -0
- package/src/manager/resident/learning.ts +132 -8
- package/src/manager/resident/store.ts +31 -3
- package/src/manager/resident/tool-evidence.ts +412 -0
- package/src/manager/run/persistence.ts +6 -0
- package/src/plugin/loader.ts +8 -3
- package/src/prompt/coding-agent-doctrine.ts +2 -0
- package/src/prompt/index.ts +2 -0
- package/src/prompt/resident-learning.ts +143 -0
- package/src/prompt/resident-step.ts +83 -3
- package/src/provider/collect-chat-completion.ts +7 -6
- package/src/provider/fallback.ts +2 -1
- package/src/provider/stream-text.ts +56 -0
- package/src/public-runtime.ts +30 -0
- package/src/public-tools.ts +3 -0
- package/src/public-types.ts +98 -0
- package/src/run/LimitChecker.ts +3 -3
- package/src/run/evidence-query.ts +333 -0
- package/src/run/evidence-recall.ts +854 -0
- package/src/run/index.ts +11 -0
- package/src/run/json-claim-verifier.ts +298 -0
- package/src/run/preparation-context-error.ts +16 -0
- package/src/run-query/index.ts +1 -1
- package/src/runtime/query/callback-inference.ts +94 -0
- package/src/runtime/query/checkpoint.ts +14 -0
- package/src/runtime/query/events.ts +22 -0
- package/src/runtime/query/executor.ts +51 -9
- package/src/runtime/query/file-evidence-context.ts +65 -0
- package/src/runtime/query/guard.ts +2 -0
- package/src/runtime/query/index.ts +49 -25
- package/src/runtime/query/iteration/index.ts +269 -86
- package/src/runtime/query/iteration/phases/advisory.ts +3 -0
- package/src/runtime/query/iteration/phases/context.ts +2 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +3 -0
- package/src/runtime/query/iteration/provider-rejected-image.ts +6 -1
- package/src/runtime/query/iteration/stream-turn.ts +35 -8
- package/src/runtime/query/resume-pending.ts +65 -40
- package/src/runtime/query/review-policy.ts +13 -9
- package/src/runtime/query/sandbox-lifecycle.ts +3 -0
- package/src/runtime/query/tool-output-budget.ts +65 -13
- package/src/runtime/query/tooling.ts +7 -1
- package/src/scheduler/completion-inbox.ts +26 -0
- package/src/store/evidence/compaction-archive.ts +139 -0
- package/src/store/evidence/compaction-provenance.ts +52 -0
- package/src/store/evidence/compaction-text.ts +61 -0
- package/src/store/evidence/disk.ts +461 -0
- package/src/store/evidence/format.ts +126 -0
- package/src/store/evidence/index-page.ts +292 -0
- package/src/store/evidence/io.ts +95 -0
- package/src/store/evidence/linked.ts +365 -0
- package/src/store/evidence/passages.ts +88 -0
- package/src/store/evidence/record-chain.ts +108 -0
- package/src/store/evidence/search-input.ts +62 -0
- package/src/store/evidence/selection.ts +25 -0
- package/src/store/evidence/source-kind.ts +36 -0
- package/src/store/evidence/source-text.ts +285 -0
- package/src/store/evidence/types.ts +177 -0
- package/src/store/memory/disk.ts +4 -1
- package/src/store/run/disk.ts +110 -8
- package/src/store/run/memory.ts +10 -0
- package/src/store/run/tool-executions.ts +112 -0
- package/src/store/session/index.ts +2 -0
- package/src/store/session/sqlite.ts +584 -0
- package/src/tools/builtins/job.ts +4 -5
- package/src/tools/builtins/write-file.ts +2 -2
- package/src/tools/defineTool.ts +4 -2
- package/src/tools/file-read-tracker.ts +8 -2
- package/src/tools/resident-history.ts +86 -0
- package/src/tools/resident-tool-evidence.ts +68 -0
- package/src/types/advisory/config.ts +7 -0
- package/src/types/agent/reactive.ts +1 -0
- package/src/types/authorization/index.ts +2 -2
- package/src/types/hitl/index.ts +4 -0
- package/src/types/message/index.ts +20 -0
- package/src/types/provider/chat.ts +2 -0
- package/src/types/provider/stream.ts +4 -0
- package/src/types/run/answer-review.ts +34 -3
- package/src/types/run/config.ts +3 -0
- package/src/types/run/entity.ts +7 -0
- package/src/types/run/events.ts +31 -8
- package/src/types/run/prepare-step.ts +59 -8
- package/src/types/run/store.ts +35 -4
- package/src/types/tool/index.ts +19 -1
- package/src/utils/await-with-abort.ts +26 -0
- package/src/utils/evidence-time.ts +9 -0
- package/src/utils/evidence-tokens.ts +32 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
2
|
import { z } from 'zod'
|
|
3
|
+
import {
|
|
4
|
+
type HarnessProtectionPlan,
|
|
5
|
+
normalizeHarnessProtection,
|
|
6
|
+
} from '../../eval/harness-protection.js'
|
|
3
7
|
import {
|
|
4
8
|
type HarnessVerificationBatch,
|
|
5
9
|
reviewHarnessCandidate,
|
|
@@ -17,14 +21,45 @@ export const residentLearningEvidenceSchema = z.object({
|
|
|
17
21
|
/** @experimental Host provenance for a correction, evaluated activation or rollback. */
|
|
18
22
|
export type ResidentLearningEvidence = Readonly<z.infer<typeof residentLearningEvidenceSchema>>
|
|
19
23
|
|
|
24
|
+
const sourceSchema = z.object({ key: label, revision: label })
|
|
25
|
+
/** @experimental Host-owned source identity and revision; neither is a model assertion. */
|
|
26
|
+
export type ResidentLearningSource = Readonly<z.infer<typeof sourceSchema>>
|
|
27
|
+
|
|
28
|
+
const sourcesSchema = z
|
|
29
|
+
.array(sourceSchema)
|
|
30
|
+
.min(1)
|
|
31
|
+
.max(8)
|
|
32
|
+
.superRefine((sources, context) => {
|
|
33
|
+
if (new Set(sources.map((source) => source.key)).size !== sources.length)
|
|
34
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: 'Duplicate learning source keys.' })
|
|
35
|
+
})
|
|
36
|
+
.transform((sources) => sources.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0)))
|
|
37
|
+
|
|
20
38
|
const candidateSchema = z.object({
|
|
21
39
|
name,
|
|
40
|
+
/** Omitted means ordinary task guidance; exploration policies require explicit projection. */
|
|
41
|
+
purpose: z.enum(['task', 'exploration']).optional(),
|
|
22
42
|
description: z.string().trim().min(1).max(1_000),
|
|
23
43
|
body: z.string().trim().min(1).max(4_000),
|
|
44
|
+
/** Optional dependencies whose revisions must still match before projection. */
|
|
45
|
+
sources: sourcesSchema.optional(),
|
|
24
46
|
})
|
|
25
47
|
|
|
26
48
|
/** @experimental Instructional guidance only; never executable assets or tool permissions. */
|
|
27
|
-
export type ResidentSkillCandidate = Readonly<z.infer<typeof candidateSchema>>
|
|
49
|
+
export type ResidentSkillCandidate = Readonly<Omit<z.infer<typeof candidateSchema>, 'sources'>> & {
|
|
50
|
+
readonly sources?: readonly ResidentLearningSource[]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Internal canonical snapshot, including immutable source bindings. */
|
|
54
|
+
export function normalizeResidentSkill(input: ResidentSkillCandidate): ResidentSkillCandidate {
|
|
55
|
+
const candidate = candidateSchema.parse(input)
|
|
56
|
+
return Object.freeze({
|
|
57
|
+
...candidate,
|
|
58
|
+
...(candidate.sources
|
|
59
|
+
? { sources: Object.freeze(candidate.sources.map((source) => Object.freeze(source))) }
|
|
60
|
+
: {}),
|
|
61
|
+
})
|
|
62
|
+
}
|
|
28
63
|
|
|
29
64
|
const learnedSkillSchema = candidateSchema.extend({
|
|
30
65
|
hash: digest,
|
|
@@ -35,11 +70,21 @@ const learnedSkillSchema = candidateSchema.extend({
|
|
|
35
70
|
evidenceDigest: digest,
|
|
36
71
|
verificationTasks: z.number().int().min(5).max(64),
|
|
37
72
|
confirmationTasks: z.number().int().min(5).max(64),
|
|
73
|
+
/** Absent only on historical activations made before protection was required. */
|
|
74
|
+
protection: z
|
|
75
|
+
.object({
|
|
76
|
+
verificationTasks: z.number().int().min(1).max(63),
|
|
77
|
+
confirmationTasks: z.number().int().min(1).max(63),
|
|
78
|
+
planDigest: digest,
|
|
79
|
+
})
|
|
80
|
+
.optional(),
|
|
38
81
|
}),
|
|
39
82
|
})
|
|
40
83
|
|
|
41
84
|
/** @experimental Immutable evaluated content and evidence identity. */
|
|
42
|
-
export type ResidentLearnedSkill = Readonly<z.infer<typeof learnedSkillSchema>>
|
|
85
|
+
export type ResidentLearnedSkill = Readonly<Omit<z.infer<typeof learnedSkillSchema>, 'sources'>> & {
|
|
86
|
+
readonly sources?: readonly ResidentLearningSource[]
|
|
87
|
+
}
|
|
43
88
|
|
|
44
89
|
export const residentLearningSchema = z
|
|
45
90
|
.object({
|
|
@@ -104,6 +149,8 @@ export interface ResidentProfileUpdate {
|
|
|
104
149
|
|
|
105
150
|
/** @experimental Recorded paired runs; hosts own execution, scoring and independent attribution. */
|
|
106
151
|
export interface ResidentSkillEvaluation {
|
|
152
|
+
/** Host-owned task selection fixed before generating the candidate. */
|
|
153
|
+
readonly protection: HarnessProtectionPlan
|
|
107
154
|
readonly verification: HarnessVerificationBatch
|
|
108
155
|
readonly confirmation?: HarnessVerificationBatch
|
|
109
156
|
}
|
|
@@ -128,8 +175,16 @@ export function freezeResidentLearning(input: ResidentLearningState): ResidentLe
|
|
|
128
175
|
state.skills.map((skill) =>
|
|
129
176
|
Object.freeze({
|
|
130
177
|
...skill,
|
|
178
|
+
...(skill.sources
|
|
179
|
+
? { sources: Object.freeze(skill.sources.map((source) => Object.freeze(source))) }
|
|
180
|
+
: {}),
|
|
131
181
|
evidence: Object.freeze(skill.evidence),
|
|
132
|
-
verification: Object.freeze(
|
|
182
|
+
verification: Object.freeze({
|
|
183
|
+
...skill.verification,
|
|
184
|
+
...(skill.verification.protection
|
|
185
|
+
? { protection: Object.freeze(skill.verification.protection) }
|
|
186
|
+
: {}),
|
|
187
|
+
}),
|
|
133
188
|
}),
|
|
134
189
|
),
|
|
135
190
|
),
|
|
@@ -214,11 +269,19 @@ export function reviseResidentProfile(
|
|
|
214
269
|
})
|
|
215
270
|
}
|
|
216
271
|
|
|
217
|
-
/** @experimental Bind evaluation to
|
|
272
|
+
/** @experimental Bind evaluation to normalized content and any declared source dependencies. */
|
|
218
273
|
export function hashResidentSkill(input: ResidentSkillCandidate): string {
|
|
219
274
|
const candidate = candidateSchema.parse(input)
|
|
220
275
|
return createHash('sha256')
|
|
221
|
-
.update(
|
|
276
|
+
.update(
|
|
277
|
+
JSON.stringify([
|
|
278
|
+
candidate.name,
|
|
279
|
+
candidate.description,
|
|
280
|
+
candidate.body,
|
|
281
|
+
...(candidate.sources ? [candidate.sources] : []),
|
|
282
|
+
...(candidate.purpose === 'exploration' ? [{ purpose: candidate.purpose }] : []),
|
|
283
|
+
]),
|
|
284
|
+
)
|
|
222
285
|
.digest('hex')
|
|
223
286
|
}
|
|
224
287
|
|
|
@@ -229,9 +292,13 @@ export function promoteResidentSkill(
|
|
|
229
292
|
evaluation: ResidentSkillEvaluation,
|
|
230
293
|
inputEvidence: ResidentLearningEvidence,
|
|
231
294
|
): ResidentLearningState {
|
|
295
|
+
const protection = normalizeHarnessProtection(evaluation.protection)
|
|
232
296
|
const candidate = candidateSchema.parse(input)
|
|
233
297
|
const hash = hashResidentSkill(candidate)
|
|
234
|
-
const
|
|
298
|
+
const baseline = current?.skills.find((s) => s.name === candidate.name)
|
|
299
|
+
if (baseline && (baseline.purpose ?? 'task') !== (candidate.purpose ?? 'task'))
|
|
300
|
+
throw new Error('A skill cannot change learning purpose; use a distinct skill name.')
|
|
301
|
+
const baselineHash = baseline?.hash ?? 'none'
|
|
235
302
|
const evidence = evidenceFor(current, inputEvidence)
|
|
236
303
|
for (const batch of [evaluation.verification, evaluation.confirmation]) {
|
|
237
304
|
if (!batch) continue
|
|
@@ -252,7 +319,11 @@ export function promoteResidentSkill(
|
|
|
252
319
|
throw new Error('Inconsistent recorded skill evaluation outcome.')
|
|
253
320
|
}
|
|
254
321
|
}
|
|
255
|
-
const review = reviewHarnessCandidate(
|
|
322
|
+
const review = reviewHarnessCandidate(
|
|
323
|
+
evaluation.verification,
|
|
324
|
+
evaluation.confirmation,
|
|
325
|
+
protection,
|
|
326
|
+
)
|
|
256
327
|
if (review.decision !== 'accept')
|
|
257
328
|
throw new Error(`Resident skill promotion ${review.decision}: ${review.reason}`)
|
|
258
329
|
const skill: ResidentLearnedSkill = {
|
|
@@ -262,9 +333,16 @@ export function promoteResidentSkill(
|
|
|
262
333
|
verification: {
|
|
263
334
|
baselineHash,
|
|
264
335
|
candidateHash: hash,
|
|
265
|
-
evidenceDigest: createHash('sha256')
|
|
336
|
+
evidenceDigest: createHash('sha256')
|
|
337
|
+
.update(JSON.stringify({ ...evaluation, protection }))
|
|
338
|
+
.digest('hex'),
|
|
266
339
|
verificationTasks: review.verification.tasks.length,
|
|
267
340
|
confirmationTasks: review.confirmation?.tasks.length ?? 0,
|
|
341
|
+
protection: {
|
|
342
|
+
verificationTasks: protection.verification.length,
|
|
343
|
+
confirmationTasks: protection.confirmation.length,
|
|
344
|
+
planDigest: createHash('sha256').update(JSON.stringify(protection)).digest('hex'),
|
|
345
|
+
},
|
|
268
346
|
},
|
|
269
347
|
}
|
|
270
348
|
const next = base(current, evidence)
|
|
@@ -298,6 +376,10 @@ export function restoreResidentSkill(
|
|
|
298
376
|
export interface ResidentLearningProjectionOptions {
|
|
299
377
|
readonly maxChars: number
|
|
300
378
|
readonly skillNames: readonly string[]
|
|
379
|
+
/** Defaults to task guidance. Exploration policies never enter ordinary task context. */
|
|
380
|
+
readonly purpose?: 'task' | 'exploration'
|
|
381
|
+
/** Fresh host observations for this projection; absent/mismatched dependencies withhold guidance. */
|
|
382
|
+
readonly sources?: readonly ResidentLearningSource[]
|
|
301
383
|
}
|
|
302
384
|
|
|
303
385
|
/** @experimental Omitted entries are counted; no partial skill instruction is emitted. */
|
|
@@ -306,6 +388,11 @@ export interface ResidentLearningProjection {
|
|
|
306
388
|
readonly revision: number | null
|
|
307
389
|
readonly includedSkills: readonly string[]
|
|
308
390
|
readonly omitted: number
|
|
391
|
+
readonly withheldSkills: readonly {
|
|
392
|
+
readonly name: string
|
|
393
|
+
readonly reason: 'changed-source' | 'unverified-source' | 'different-purpose'
|
|
394
|
+
readonly sourceKeys: readonly string[]
|
|
395
|
+
}[]
|
|
309
396
|
}
|
|
310
397
|
|
|
311
398
|
/** @experimental Bounded context data; never registers tools, loads files or executes a skill. */
|
|
@@ -316,17 +403,27 @@ export function projectResidentLearning(
|
|
|
316
403
|
if (!Number.isSafeInteger(options.maxChars) || options.maxChars < 0 || options.maxChars > 64_000)
|
|
317
404
|
throw new TypeError('Resident learning context requires maxChars between 0 and 64000.')
|
|
318
405
|
const selected = z.array(name).max(16).parse(options.skillNames)
|
|
406
|
+
const purpose = z.enum(['task', 'exploration']).parse(options.purpose ?? 'task')
|
|
319
407
|
if (new Set(selected).size !== selected.length) throw new Error('Duplicate selected skill names.')
|
|
408
|
+
const sources = z
|
|
409
|
+
.array(sourceSchema)
|
|
410
|
+
.max(128)
|
|
411
|
+
.parse(options.sources ?? [])
|
|
412
|
+
if (new Set(sources.map((source) => source.key)).size !== sources.length)
|
|
413
|
+
throw new Error('Duplicate observed learning source keys.')
|
|
414
|
+
const observed = new Map(sources.map((source) => [source.key, source.revision]))
|
|
320
415
|
if (!current)
|
|
321
416
|
return Object.freeze({
|
|
322
417
|
text: '',
|
|
323
418
|
revision: null,
|
|
324
419
|
includedSkills: Object.freeze([]),
|
|
325
420
|
omitted: selected.length,
|
|
421
|
+
withheldSkills: Object.freeze([]),
|
|
326
422
|
})
|
|
327
423
|
const state = freezeResidentLearning(current)
|
|
328
424
|
const pieces: string[] = []
|
|
329
425
|
const includedSkills: string[] = []
|
|
426
|
+
const withheldSkills: ResidentLearningProjection['withheldSkills'][number][] = []
|
|
330
427
|
let omitted = 0
|
|
331
428
|
let length = 0
|
|
332
429
|
const add = (value: unknown): boolean => {
|
|
@@ -348,6 +445,32 @@ export function projectResidentLearning(
|
|
|
348
445
|
omitted++
|
|
349
446
|
continue
|
|
350
447
|
}
|
|
448
|
+
if ((skill.purpose ?? 'task') !== purpose) {
|
|
449
|
+
omitted++
|
|
450
|
+
withheldSkills.push(
|
|
451
|
+
Object.freeze({
|
|
452
|
+
name: skill.name,
|
|
453
|
+
reason: 'different-purpose',
|
|
454
|
+
sourceKeys: Object.freeze([]),
|
|
455
|
+
}),
|
|
456
|
+
)
|
|
457
|
+
continue
|
|
458
|
+
}
|
|
459
|
+
const mismatched =
|
|
460
|
+
skill.sources?.filter((source) => observed.get(source.key) !== source.revision) ?? []
|
|
461
|
+
if (mismatched.length) {
|
|
462
|
+
omitted++
|
|
463
|
+
withheldSkills.push(
|
|
464
|
+
Object.freeze({
|
|
465
|
+
name: skill.name,
|
|
466
|
+
reason: mismatched.some((source) => observed.has(source.key))
|
|
467
|
+
? 'changed-source'
|
|
468
|
+
: 'unverified-source',
|
|
469
|
+
sourceKeys: Object.freeze(mismatched.map((source) => source.key)),
|
|
470
|
+
}),
|
|
471
|
+
)
|
|
472
|
+
continue
|
|
473
|
+
}
|
|
351
474
|
if (
|
|
352
475
|
add({
|
|
353
476
|
kind: 'evaluated-guidance',
|
|
@@ -365,5 +488,6 @@ export function projectResidentLearning(
|
|
|
365
488
|
revision: state.revision,
|
|
366
489
|
includedSkills: Object.freeze(includedSkills),
|
|
367
490
|
omitted,
|
|
491
|
+
withheldSkills: Object.freeze(withheldSkills),
|
|
368
492
|
})
|
|
369
493
|
}
|
|
@@ -11,6 +11,17 @@ import { asTenantId } from '../../utils/id.js'
|
|
|
11
11
|
|
|
12
12
|
const text = z.string().trim().min(1).max(8_000)
|
|
13
13
|
const time = z.number().int().nonnegative().safe()
|
|
14
|
+
const MAX_WAKE_EVIDENCE_CHARS = 16_000
|
|
15
|
+
const wakeEvidence = z
|
|
16
|
+
.array(z.object({ reason: text, receivedAt: time }).readonly())
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(16, 'Resident has 16 pending wake inputs; process them before adding more.')
|
|
19
|
+
.refine(
|
|
20
|
+
(entries) =>
|
|
21
|
+
entries.reduce((total, entry) => total + entry.reason.length, 0) <= MAX_WAKE_EVIDENCE_CHARS,
|
|
22
|
+
'Resident wake evidence exceeds 16000 characters; process pending evidence before adding more.',
|
|
23
|
+
)
|
|
24
|
+
.readonly()
|
|
14
25
|
export const residentDecisionSchema = z.discriminatedUnion('kind', [
|
|
15
26
|
z.object({ kind: z.literal('wait'), summary: text, wakeAt: time.nullable() }),
|
|
16
27
|
z.object({ kind: z.literal('complete'), summary: text }),
|
|
@@ -32,6 +43,8 @@ export const residentStateSchema = z
|
|
|
32
43
|
phase: z.enum(['waiting', 'running', 'complete', 'blocked']),
|
|
33
44
|
wakeAt: time.nullable(),
|
|
34
45
|
reason: text,
|
|
46
|
+
/** Accepted wake inputs, in commit order, retained until this step settles. */
|
|
47
|
+
wakeEvidence: wakeEvidence.optional(),
|
|
35
48
|
summary: text.nullable(),
|
|
36
49
|
claimId: z.string().uuid().nullable(),
|
|
37
50
|
})
|
|
@@ -48,6 +61,12 @@ export const residentStateSchema = z
|
|
|
48
61
|
message: 'Only waiting state may have a wake time.',
|
|
49
62
|
})
|
|
50
63
|
}
|
|
64
|
+
if (state.wakeEvidence && state.phase !== 'waiting' && state.phase !== 'running') {
|
|
65
|
+
context.addIssue({
|
|
66
|
+
code: z.ZodIssueCode.custom,
|
|
67
|
+
message: 'Only waiting or unresolved running work may retain wake evidence.',
|
|
68
|
+
})
|
|
69
|
+
}
|
|
51
70
|
})
|
|
52
71
|
|
|
53
72
|
/** @experimental Persisted identity and one pursuit, independent of a conversation. */
|
|
@@ -88,7 +107,7 @@ export class ResidentConflictError extends Error {
|
|
|
88
107
|
*/
|
|
89
108
|
export class DiskResidentStore implements ResidentStore {
|
|
90
109
|
private readonly records = new DiskRevisionRecordStore<ResidentState>(
|
|
91
|
-
defineSchema({ kind: 'resident', current:
|
|
110
|
+
defineSchema({ kind: 'resident', current: 2, migrations: { 1: (record) => record } }),
|
|
92
111
|
'resident store',
|
|
93
112
|
(record) => record.revision,
|
|
94
113
|
)
|
|
@@ -207,8 +226,11 @@ export function settleResidentState(
|
|
|
207
226
|
if (outcome.kind === 'wait' && outcome.wakeAt !== null && outcome.wakeAt <= now)
|
|
208
227
|
throw new Error('A scheduled continuation must be in the future.')
|
|
209
228
|
if (state.phase !== 'running') throw new Error('Resident has no admitted step to settle.')
|
|
229
|
+
// Admission alone is not acknowledgment: an interrupted step retains every
|
|
230
|
+
// input. Only successful exact-claim settlement consumes the captured batch.
|
|
231
|
+
const { wakeEvidence: _consumed, ...settled } = state
|
|
210
232
|
return {
|
|
211
|
-
...
|
|
233
|
+
...settled,
|
|
212
234
|
phase: outcome.kind === 'wait' ? 'waiting' : outcome.kind,
|
|
213
235
|
wakeAt: outcome.kind === 'wait' ? outcome.wakeAt : null,
|
|
214
236
|
summary: outcome.summary,
|
|
@@ -225,5 +247,11 @@ export function wakeResidentState(
|
|
|
225
247
|
time.parse(now)
|
|
226
248
|
const evidence = text.parse(reason)
|
|
227
249
|
if (state.phase !== 'waiting') throw new Error('Only a waiting resident can be woken.')
|
|
228
|
-
|
|
250
|
+
// Never evict an accepted input to admit another. Backpressure leaves both
|
|
251
|
+
// the durable state and its revision untouched, so the sender can retry later.
|
|
252
|
+
const pending = wakeEvidence.parse([
|
|
253
|
+
...(state.wakeEvidence ?? []),
|
|
254
|
+
{ reason: evidence, receivedAt: now },
|
|
255
|
+
])
|
|
256
|
+
return { ...state, wakeAt: now, reason: evidence, wakeEvidence: pending }
|
|
229
257
|
}
|