kiokuko-dsh 0.2.7 → 0.2.9
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/PERMISSIONS.md +1 -1
- package/README.ja.md +38 -11
- package/README.ko.md +34 -3
- package/README.md +39 -13
- package/README.zh-CN.md +34 -3
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/dist/db/transaction.d.ts +2 -1
- package/dist/db/transaction.d.ts.map +1 -1
- package/dist/db/transaction.js +44 -7
- package/dist/db/transaction.js.map +1 -1
- package/dist/deep-planning-config.d.ts +32 -0
- package/dist/deep-planning-config.d.ts.map +1 -0
- package/dist/deep-planning-config.js +20 -0
- package/dist/deep-planning-config.js.map +1 -0
- package/dist/deep-thinker/core/contracts.d.ts +1 -29
- package/dist/deep-thinker/core/contracts.d.ts.map +1 -1
- package/dist/deep-thinker/core/contracts.js +2 -17
- package/dist/deep-thinker/core/contracts.js.map +1 -1
- package/dist/deep-thinker/memory-finalizer.d.ts.map +1 -1
- package/dist/deep-thinker/memory-finalizer.js +1 -114
- package/dist/deep-thinker/memory-finalizer.js.map +1 -1
- package/dist/deep-thinker/native-executor.d.ts.map +1 -1
- package/dist/deep-thinker/native-executor.js +3 -4
- package/dist/deep-thinker/native-executor.js.map +1 -1
- package/dist/deep-thinker/store.js +1 -2
- package/dist/deep-thinker/store.js.map +1 -1
- package/dist/dsh/agenticreplay-event-mapper.d.ts +1 -1
- package/dist/dsh/agenticreplay-event-mapper.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-event-mapper.js +5 -1
- package/dist/dsh/agenticreplay-event-mapper.js.map +1 -1
- package/dist/dsh/agenticreplay-files.d.ts +1 -0
- package/dist/dsh/agenticreplay-files.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-files.js +19 -2
- package/dist/dsh/agenticreplay-files.js.map +1 -1
- package/dist/dsh/agenticreplay-host.js +3 -3
- package/dist/dsh/agenticreplay-host.js.map +1 -1
- package/dist/dsh/agenticreplay-read-service.d.ts +20 -0
- package/dist/dsh/agenticreplay-read-service.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-read-service.js +27 -0
- package/dist/dsh/agenticreplay-read-service.js.map +1 -1
- package/dist/dsh/agenticreplay-recorder.d.ts +18 -12
- package/dist/dsh/agenticreplay-recorder.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-recorder.js +43 -13
- package/dist/dsh/agenticreplay-recorder.js.map +1 -1
- package/dist/dsh/agenticreplay-security.d.ts +1 -0
- package/dist/dsh/agenticreplay-security.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-security.js +84 -3
- package/dist/dsh/agenticreplay-security.js.map +1 -1
- package/dist/dsh/answer-review/coordinator.js +2 -1
- package/dist/dsh/answer-review/coordinator.js.map +1 -1
- package/dist/dsh/auto-memory-review.d.ts.map +1 -1
- package/dist/dsh/auto-memory-review.js +10 -193
- package/dist/dsh/auto-memory-review.js.map +1 -1
- package/dist/dsh/coding-workflow/contracts.d.ts +2 -0
- package/dist/dsh/coding-workflow/contracts.d.ts.map +1 -1
- package/dist/dsh/coding-workflow/contracts.js.map +1 -1
- package/dist/dsh/coding-workflow/intent.d.ts.map +1 -1
- package/dist/dsh/coding-workflow/intent.js +12 -4
- package/dist/dsh/coding-workflow/intent.js.map +1 -1
- package/dist/dsh/coding-workflow/service.d.ts +10 -81
- package/dist/dsh/coding-workflow/service.d.ts.map +1 -1
- package/dist/dsh/coding-workflow/service.js +52 -1
- package/dist/dsh/coding-workflow/service.js.map +1 -1
- package/dist/dsh/coding-workflow/store.d.ts +22 -0
- package/dist/dsh/coding-workflow/store.d.ts.map +1 -1
- package/dist/dsh/coding-workflow/store.js +51 -0
- package/dist/dsh/coding-workflow/store.js.map +1 -1
- package/dist/dsh/completion-verifiers.d.ts +6 -0
- package/dist/dsh/completion-verifiers.d.ts.map +1 -1
- package/dist/dsh/completion-verifiers.js.map +1 -1
- package/dist/dsh/composition.d.ts +2 -0
- package/dist/dsh/composition.d.ts.map +1 -1
- package/dist/dsh/composition.js +3 -0
- package/dist/dsh/composition.js.map +1 -1
- package/dist/dsh/config.d.ts +1 -1
- package/dist/dsh/config.d.ts.map +1 -1
- package/dist/dsh/config.js +3 -3
- package/dist/dsh/config.js.map +1 -1
- package/dist/dsh/core/host.d.ts.map +1 -1
- package/dist/dsh/core/host.js +159 -34
- package/dist/dsh/core/host.js.map +1 -1
- package/dist/dsh/core/tasks.d.ts +5 -2
- package/dist/dsh/core/tasks.d.ts.map +1 -1
- package/dist/dsh/core/tasks.js +124 -93
- package/dist/dsh/core/tasks.js.map +1 -1
- package/dist/dsh/decisions/request-intent.d.ts +114 -1
- package/dist/dsh/decisions/request-intent.d.ts.map +1 -1
- package/dist/dsh/decisions/request-intent.js +102 -18
- package/dist/dsh/decisions/request-intent.js.map +1 -1
- package/dist/dsh/execution-result.d.ts +1 -0
- package/dist/dsh/execution-result.d.ts.map +1 -1
- package/dist/dsh/execution-support.d.ts +2 -0
- package/dist/dsh/execution-support.d.ts.map +1 -1
- package/dist/dsh/execution-support.js +39 -4
- package/dist/dsh/execution-support.js.map +1 -1
- package/dist/dsh/existing-task-intake.d.ts +22 -0
- package/dist/dsh/existing-task-intake.d.ts.map +1 -0
- package/dist/dsh/existing-task-intake.js +46 -0
- package/dist/dsh/existing-task-intake.js.map +1 -0
- package/dist/dsh/finalization-request.d.ts +1 -1
- package/dist/dsh/finalization-request.d.ts.map +1 -1
- package/dist/dsh/finalization-request.js +1 -1
- package/dist/dsh/finalization-request.js.map +1 -1
- package/dist/dsh/guardrail/contracts.d.ts +85 -0
- package/dist/dsh/guardrail/contracts.d.ts.map +1 -0
- package/dist/dsh/guardrail/contracts.js +10 -0
- package/dist/dsh/guardrail/contracts.js.map +1 -0
- package/dist/dsh/guardrail/engine.d.ts +19 -0
- package/dist/dsh/guardrail/engine.d.ts.map +1 -0
- package/dist/dsh/guardrail/engine.js +178 -0
- package/dist/dsh/guardrail/engine.js.map +1 -0
- package/dist/dsh/guardrail/evidence.d.ts +16 -0
- package/dist/dsh/guardrail/evidence.d.ts.map +1 -0
- package/dist/dsh/guardrail/evidence.js +101 -0
- package/dist/dsh/guardrail/evidence.js.map +1 -0
- package/dist/dsh/guardrail/service.d.ts +27 -0
- package/dist/dsh/guardrail/service.d.ts.map +1 -0
- package/dist/dsh/guardrail/service.js +253 -0
- package/dist/dsh/guardrail/service.js.map +1 -0
- package/dist/dsh/host-adapter/admission.d.ts.map +1 -1
- package/dist/dsh/host-adapter/admission.js +143 -144
- package/dist/dsh/host-adapter/admission.js.map +1 -1
- package/dist/dsh/host-adapter/lifecycle.d.ts +1 -0
- package/dist/dsh/host-adapter/lifecycle.d.ts.map +1 -1
- package/dist/dsh/host-adapter/lifecycle.js +107 -77
- package/dist/dsh/host-adapter/lifecycle.js.map +1 -1
- package/dist/dsh/host-adapter/routing.d.ts.map +1 -1
- package/dist/dsh/host-adapter/routing.js +4 -4
- package/dist/dsh/host-adapter/routing.js.map +1 -1
- package/dist/dsh/host-adapter/turn-state.d.ts +4 -2
- package/dist/dsh/host-adapter/turn-state.d.ts.map +1 -1
- package/dist/dsh/host-adapter/turn-state.js +14 -7
- package/dist/dsh/host-adapter/turn-state.js.map +1 -1
- package/dist/dsh/host-adapter.d.ts.map +1 -1
- package/dist/dsh/host-adapter.js +125 -24
- package/dist/dsh/host-adapter.js.map +1 -1
- package/dist/dsh/intake-clarification.js +2 -2
- package/dist/dsh/intake-clarification.js.map +1 -1
- package/dist/dsh/intake-gate.js +6 -7
- package/dist/dsh/intake-gate.js.map +1 -1
- package/dist/dsh/legacy-session-codecs.d.ts +1 -0
- package/dist/dsh/legacy-session-codecs.d.ts.map +1 -1
- package/dist/dsh/legacy-session-codecs.js +831 -127
- package/dist/dsh/legacy-session-codecs.js.map +4 -4
- package/dist/dsh/lifecycle-memory.d.ts +66 -0
- package/dist/dsh/lifecycle-memory.d.ts.map +1 -0
- package/dist/dsh/lifecycle-memory.js +380 -0
- package/dist/dsh/lifecycle-memory.js.map +1 -0
- package/dist/dsh/lisp/candidate.d.ts +2 -2
- package/dist/dsh/lisp/ci.d.ts +2 -1
- package/dist/dsh/lisp/ci.d.ts.map +1 -1
- package/dist/dsh/lisp/ci.js +15 -2
- package/dist/dsh/lisp/ci.js.map +1 -1
- package/dist/dsh/lisp/contracts.d.ts +1 -18
- package/dist/dsh/lisp/contracts.d.ts.map +1 -1
- package/dist/dsh/lisp/contracts.js +1 -10
- package/dist/dsh/lisp/contracts.js.map +1 -1
- package/dist/dsh/lisp/files.d.ts +1 -1
- package/dist/dsh/lisp/files.d.ts.map +1 -1
- package/dist/dsh/lisp/files.js +17 -4
- package/dist/dsh/lisp/files.js.map +1 -1
- package/dist/dsh/lisp/hot-store.d.ts.map +1 -1
- package/dist/dsh/lisp/hot-store.js +4 -0
- package/dist/dsh/lisp/hot-store.js.map +1 -1
- package/dist/dsh/lisp/hot-tools.d.ts +2 -0
- package/dist/dsh/lisp/hot-tools.d.ts.map +1 -1
- package/dist/dsh/lisp/hot-tools.js +10 -0
- package/dist/dsh/lisp/hot-tools.js.map +1 -1
- package/dist/dsh/lisp/manager.d.ts +14 -1
- package/dist/dsh/lisp/manager.d.ts.map +1 -1
- package/dist/dsh/lisp/manager.js +238 -37
- package/dist/dsh/lisp/manager.js.map +1 -1
- package/dist/dsh/lisp/memory-verification.d.ts +5 -2
- package/dist/dsh/lisp/memory-verification.d.ts.map +1 -1
- package/dist/dsh/lisp/memory-verification.js +5 -1
- package/dist/dsh/lisp/memory-verification.js.map +1 -1
- package/dist/dsh/lisp/package-manager.d.ts +1 -1
- package/dist/dsh/lisp/package-manager.d.ts.map +1 -1
- package/dist/dsh/lisp/package-manager.js +10 -1
- package/dist/dsh/lisp/package-manager.js.map +1 -1
- package/dist/dsh/lisp/packages.d.ts +1 -1
- package/dist/dsh/lisp/packages.d.ts.map +1 -1
- package/dist/dsh/lisp/packages.js +15 -5
- package/dist/dsh/lisp/packages.js.map +1 -1
- package/dist/dsh/lisp/proposal-batch.d.ts +2 -0
- package/dist/dsh/lisp/proposal-batch.d.ts.map +1 -1
- package/dist/dsh/lisp/proposal-batch.js +17 -3
- package/dist/dsh/lisp/proposal-batch.js.map +1 -1
- package/dist/dsh/lisp/request-surface.d.ts +12 -0
- package/dist/dsh/lisp/request-surface.d.ts.map +1 -1
- package/dist/dsh/lisp/store.d.ts +2 -1
- package/dist/dsh/lisp/store.d.ts.map +1 -1
- package/dist/dsh/lisp/store.js +5 -1
- package/dist/dsh/lisp/store.js.map +1 -1
- package/dist/dsh/lisp/surface.d.ts.map +1 -1
- package/dist/dsh/lisp/surface.js +107 -13
- package/dist/dsh/lisp/surface.js.map +1 -1
- package/dist/dsh/lisp/task-authority.d.ts +29 -0
- package/dist/dsh/lisp/task-authority.d.ts.map +1 -0
- package/dist/dsh/lisp/task-authority.js +87 -0
- package/dist/dsh/lisp/task-authority.js.map +1 -0
- package/dist/dsh/lisp/worker.d.ts +3 -1
- package/dist/dsh/lisp/worker.d.ts.map +1 -1
- package/dist/dsh/lisp/worker.js +26 -4
- package/dist/dsh/lisp/worker.js.map +1 -1
- package/dist/dsh/lisp-config.d.ts +21 -0
- package/dist/dsh/lisp-config.d.ts.map +1 -0
- package/dist/dsh/lisp-config.js +13 -0
- package/dist/dsh/lisp-config.js.map +1 -0
- package/dist/dsh/memory-application.d.ts +3 -2
- package/dist/dsh/memory-application.d.ts.map +1 -1
- package/dist/dsh/memory-application.js +31 -22
- package/dist/dsh/memory-application.js.map +1 -1
- package/dist/dsh/model-handoff.d.ts.map +1 -1
- package/dist/dsh/model-handoff.js +2 -1
- package/dist/dsh/model-handoff.js.map +1 -1
- package/dist/dsh/models/service.d.ts.map +1 -1
- package/dist/dsh/models/service.js +13 -2
- package/dist/dsh/models/service.js.map +1 -1
- package/dist/dsh/models/vendor/opencode-codec.d.ts.map +1 -1
- package/dist/dsh/models/vendor/opencode-codec.js +71 -0
- package/dist/dsh/models/vendor/opencode-codec.js.map +1 -1
- package/dist/dsh/native-cancellation-observer.d.ts +13 -0
- package/dist/dsh/native-cancellation-observer.d.ts.map +1 -0
- package/dist/dsh/native-cancellation-observer.js +54 -0
- package/dist/dsh/native-cancellation-observer.js.map +1 -0
- package/dist/dsh/native-execution-ownership.d.ts +6 -0
- package/dist/dsh/native-execution-ownership.d.ts.map +1 -0
- package/dist/dsh/native-execution-ownership.js +34 -0
- package/dist/dsh/native-execution-ownership.js.map +1 -0
- package/dist/dsh/native-subagent.d.ts +2 -2
- package/dist/dsh/native-subagent.d.ts.map +1 -1
- package/dist/dsh/native-subagent.js +2 -3
- package/dist/dsh/native-subagent.js.map +1 -1
- package/dist/dsh/native-task-authority.d.ts +66 -0
- package/dist/dsh/native-task-authority.d.ts.map +1 -0
- package/dist/dsh/native-task-authority.js +220 -0
- package/dist/dsh/native-task-authority.js.map +1 -0
- package/dist/dsh/node-tap-summary.d.ts +1 -2
- package/dist/dsh/node-tap-summary.d.ts.map +1 -1
- package/dist/dsh/node-tap-summary.js +2 -24
- package/dist/dsh/node-tap-summary.js.map +1 -1
- package/dist/dsh/observation-pack/policy.d.ts +1 -0
- package/dist/dsh/observation-pack/policy.d.ts.map +1 -1
- package/dist/dsh/observation-pack/policy.js +3 -0
- package/dist/dsh/observation-pack/policy.js.map +1 -1
- package/dist/dsh/observation-pack/service.d.ts.map +1 -1
- package/dist/dsh/observation-pack/service.js +3 -1
- package/dist/dsh/observation-pack/service.js.map +1 -1
- package/dist/dsh/on-demand-intake.d.ts +28 -1
- package/dist/dsh/on-demand-intake.d.ts.map +1 -1
- package/dist/dsh/on-demand-intake.js +171 -10
- package/dist/dsh/on-demand-intake.js.map +1 -1
- package/dist/dsh/orchestration/execution-owner.js +1 -1
- package/dist/dsh/orchestration/execution-owner.js.map +1 -1
- package/dist/dsh/orchestration/managed-agent-executor.d.ts +12 -1
- package/dist/dsh/orchestration/managed-agent-executor.d.ts.map +1 -1
- package/dist/dsh/orchestration/managed-agent-executor.js +28 -2
- package/dist/dsh/orchestration/managed-agent-executor.js.map +1 -1
- package/dist/dsh/owned-completion-evidence.d.ts +11 -0
- package/dist/dsh/owned-completion-evidence.d.ts.map +1 -0
- package/dist/dsh/owned-completion-evidence.js +59 -0
- package/dist/dsh/owned-completion-evidence.js.map +1 -0
- package/dist/dsh/owned-execution.d.ts +28 -1
- package/dist/dsh/owned-execution.d.ts.map +1 -1
- package/dist/dsh/owned-execution.js +325 -101
- package/dist/dsh/owned-execution.js.map +1 -1
- package/dist/dsh/owned-read-owner.d.ts +6 -0
- package/dist/dsh/owned-read-owner.d.ts.map +1 -0
- package/dist/dsh/owned-read-owner.js +22 -0
- package/dist/dsh/owned-read-owner.js.map +1 -0
- package/dist/dsh/replay-memory-extract.d.ts +36 -0
- package/dist/dsh/replay-memory-extract.d.ts.map +1 -0
- package/dist/dsh/replay-memory-extract.js +192 -0
- package/dist/dsh/replay-memory-extract.js.map +1 -0
- package/dist/dsh/semantic-compaction/coordinator.d.ts.map +1 -1
- package/dist/dsh/semantic-compaction/coordinator.js +2 -1
- package/dist/dsh/semantic-compaction/coordinator.js.map +1 -1
- package/dist/dsh/session-bridge.d.ts +3 -0
- package/dist/dsh/session-bridge.d.ts.map +1 -1
- package/dist/dsh/session-bridge.js +22 -25
- package/dist/dsh/session-bridge.js.map +1 -1
- package/dist/dsh/session-history-compatibility.d.ts.map +1 -1
- package/dist/dsh/session-history-compatibility.js +15 -1
- package/dist/dsh/session-history-compatibility.js.map +1 -1
- package/dist/dsh/session-history-lookup.d.ts +1 -1
- package/dist/dsh/session-history-lookup.d.ts.map +1 -1
- package/dist/dsh/session-history-lookup.js +4 -3
- package/dist/dsh/session-history-lookup.js.map +1 -1
- package/dist/dsh/session-memory-finalizer.d.ts.map +1 -1
- package/dist/dsh/session-memory-finalizer.js +129 -117
- package/dist/dsh/session-memory-finalizer.js.map +1 -1
- package/dist/dsh/setup.d.ts +1 -1
- package/dist/dsh/setup.d.ts.map +1 -1
- package/dist/dsh/setup.js +1 -1
- package/dist/dsh/skill-prompts.json +1 -1
- package/dist/dsh/task-authority-context.d.ts +8 -0
- package/dist/dsh/task-authority-context.d.ts.map +1 -0
- package/dist/dsh/task-authority-context.js +28 -0
- package/dist/dsh/task-authority-context.js.map +1 -0
- package/dist/dsh/task-completion-host.d.ts +2 -1
- package/dist/dsh/task-completion-host.d.ts.map +1 -1
- package/dist/dsh/task-completion-host.js +17 -5
- package/dist/dsh/task-completion-host.js.map +1 -1
- package/dist/dsh/task-completion.d.ts +13 -0
- package/dist/dsh/task-completion.d.ts.map +1 -1
- package/dist/dsh/task-completion.js +23 -6
- package/dist/dsh/task-completion.js.map +1 -1
- package/dist/dsh/task-intake.d.ts.map +1 -1
- package/dist/dsh/task-intake.js +7 -16
- package/dist/dsh/task-intake.js.map +1 -1
- package/dist/dsh/task-source-history.d.ts +33 -0
- package/dist/dsh/task-source-history.d.ts.map +1 -0
- package/dist/dsh/task-source-history.js +62 -0
- package/dist/dsh/task-source-history.js.map +1 -0
- package/dist/dsh/task-state-host.d.ts +124 -0
- package/dist/dsh/task-state-host.d.ts.map +1 -0
- package/dist/dsh/task-state-host.js +403 -0
- package/dist/dsh/task-state-host.js.map +1 -0
- package/dist/dsh/task-state-surface.d.ts +8 -0
- package/dist/dsh/task-state-surface.d.ts.map +1 -0
- package/dist/dsh/task-state-surface.js +113 -0
- package/dist/dsh/task-state-surface.js.map +1 -0
- package/dist/dsh/task-state.d.ts +217 -0
- package/dist/dsh/task-state.d.ts.map +1 -0
- package/dist/dsh/task-state.js +315 -0
- package/dist/dsh/task-state.js.map +1 -0
- package/dist/dsh/tool-exposure-config.d.ts +12 -0
- package/dist/dsh/tool-exposure-config.d.ts.map +1 -0
- package/dist/dsh/tool-exposure-config.js +4 -0
- package/dist/dsh/tool-exposure-config.js.map +1 -0
- package/dist/dsh/tool-exposure.d.ts +2 -11
- package/dist/dsh/tool-exposure.d.ts.map +1 -1
- package/dist/dsh/tool-exposure.js +2 -2
- package/dist/dsh/tool-exposure.js.map +1 -1
- package/dist/dsh/tools.d.ts +2 -2
- package/dist/dsh/tools.d.ts.map +1 -1
- package/dist/dsh/tools.js +3 -2
- package/dist/dsh/tools.js.map +1 -1
- package/dist/enno-oduno/memory-verification.d.ts +2 -1
- package/dist/enno-oduno/memory-verification.d.ts.map +1 -1
- package/dist/enno-oduno/memory-verification.js +42 -30
- package/dist/enno-oduno/memory-verification.js.map +1 -1
- package/dist/enno-oduno/schemas.d.ts +1 -1
- package/dist/enno-oduno/store.d.ts +7 -0
- package/dist/enno-oduno/store.d.ts.map +1 -1
- package/dist/enno-oduno/store.js +42 -0
- package/dist/enno-oduno/store.js.map +1 -1
- package/dist/ledger/store.d.ts.map +1 -1
- package/dist/ledger/store.js +0 -5
- package/dist/ledger/store.js.map +1 -1
- package/dist/locale/en.json +1 -1
- package/dist/locale/ja.json +1 -1
- package/dist/locale/ko.json +1 -1
- package/dist/locale/zh-CN.json +1 -1
- package/dist/memory/application.js +1 -1
- package/dist/memory/application.js.map +1 -1
- package/dist/memory/auto-globalization.d.ts.map +1 -1
- package/dist/memory/auto-globalization.js +4 -82
- package/dist/memory/auto-globalization.js.map +1 -1
- package/dist/memory/evolution/contracts.d.ts +3 -1
- package/dist/memory/evolution/contracts.d.ts.map +1 -1
- package/dist/memory/evolution/contracts.js +1 -1
- package/dist/memory/evolution/contracts.js.map +1 -1
- package/dist/memory/evolution/store.d.ts +2 -1
- package/dist/memory/evolution/store.d.ts.map +1 -1
- package/dist/memory/evolution/store.js +75 -34
- package/dist/memory/evolution/store.js.map +1 -1
- package/dist/memory/evolution/worker.d.ts +1 -0
- package/dist/memory/evolution/worker.d.ts.map +1 -1
- package/dist/memory/evolution/worker.js +6 -18
- package/dist/memory/evolution/worker.js.map +1 -1
- package/dist/memory/explain.d.ts.map +1 -1
- package/dist/memory/explain.js +2 -2
- package/dist/memory/explain.js.map +1 -1
- package/dist/memory/forget.d.ts.map +1 -1
- package/dist/memory/forget.js +12 -3
- package/dist/memory/forget.js.map +1 -1
- package/dist/memory/hybrid-retrieval.d.ts.map +1 -1
- package/dist/memory/hybrid-retrieval.js +3 -0
- package/dist/memory/hybrid-retrieval.js.map +1 -1
- package/dist/memory/index-reasoning/service.d.ts.map +1 -1
- package/dist/memory/index-reasoning/service.js +5 -43
- package/dist/memory/index-reasoning/service.js.map +1 -1
- package/dist/memory/index-reasoning/worker.d.ts.map +1 -1
- package/dist/memory/index-reasoning/worker.js +1 -15
- package/dist/memory/index-reasoning/worker.js.map +1 -1
- package/dist/memory/lifecycle-cache.d.ts +12 -0
- package/dist/memory/lifecycle-cache.d.ts.map +1 -0
- package/dist/memory/lifecycle-cache.js +36 -0
- package/dist/memory/lifecycle-cache.js.map +1 -0
- package/dist/memory/lifecycle-database.d.ts +5 -0
- package/dist/memory/lifecycle-database.d.ts.map +1 -0
- package/dist/memory/lifecycle-database.js +32 -0
- package/dist/memory/lifecycle-database.js.map +1 -0
- package/dist/memory/lifecycle-global-state.d.ts +5 -0
- package/dist/memory/lifecycle-global-state.d.ts.map +1 -0
- package/dist/memory/lifecycle-global-state.js +23 -0
- package/dist/memory/lifecycle-global-state.js.map +1 -0
- package/dist/memory/lifecycle-global.d.ts +23 -0
- package/dist/memory/lifecycle-global.d.ts.map +1 -0
- package/dist/memory/lifecycle-global.js +56 -0
- package/dist/memory/lifecycle-global.js.map +1 -0
- package/dist/memory/lifecycle.d.ts +152 -0
- package/dist/memory/lifecycle.d.ts.map +1 -0
- package/dist/memory/lifecycle.js +152 -0
- package/dist/memory/lifecycle.js.map +1 -0
- package/dist/memory/replay-review.d.ts +90 -0
- package/dist/memory/replay-review.d.ts.map +1 -0
- package/dist/memory/replay-review.js +82 -0
- package/dist/memory/replay-review.js.map +1 -0
- package/dist/memory/replay-store.d.ts +14 -0
- package/dist/memory/replay-store.d.ts.map +1 -0
- package/dist/memory/replay-store.js +117 -0
- package/dist/memory/replay-store.js.map +1 -0
- package/dist/memory/review/adoption.d.ts.map +1 -1
- package/dist/memory/review/adoption.js +2 -106
- package/dist/memory/review/adoption.js.map +1 -1
- package/dist/memory/review/store.d.ts.map +1 -1
- package/dist/memory/review/store.js +9 -5
- package/dist/memory/review/store.js.map +1 -1
- package/dist/memory/review/worker.d.ts.map +1 -1
- package/dist/memory/review/worker.js +1 -7
- package/dist/memory/review/worker.js.map +1 -1
- package/dist/memory/scoped-memory.js +1 -1
- package/dist/memory/scoped-memory.js.map +1 -1
- package/dist/model-tools/contracts.d.ts +4 -4
- package/dist/model-tools/contracts.d.ts.map +1 -1
- package/dist/model-tools/contracts.js +1 -11
- package/dist/model-tools/contracts.js.map +1 -1
- package/dist/model-tools/names.d.ts +4 -0
- package/dist/model-tools/names.d.ts.map +1 -0
- package/dist/model-tools/names.js +13 -0
- package/dist/model-tools/names.js.map +1 -0
- package/docs/agenticreplay-recording.md +1 -1
- package/docs/code-intelligence.md +54 -119
- package/docs/dsh-plugin.md +86 -9
- package/docs/getting-started.md +10 -0
- package/docs/guardrail-licenses/Apache-2.0.txt +73 -0
- package/docs/guardrail-licenses/BSD-2-Clause.txt +9 -0
- package/docs/guardrail-licenses/COPYRIGHT-Rust.txt +34 -0
- package/docs/guardrail-licenses/COPYRIGHT-library.html +29357 -0
- package/docs/guardrail-licenses/ISC.txt +7 -0
- package/docs/guardrail-licenses/LICENSE-APACHE +176 -0
- package/docs/guardrail-licenses/LICENSE-MIT +25 -0
- package/docs/guardrail-licenses/LLVM-exception.txt +15 -0
- package/docs/guardrail-licenses/MIT.txt +9 -0
- package/docs/guardrail-licenses/NCSA.txt +29 -0
- package/docs/guardrail-licenses/README.md +7 -0
- package/docs/guardrail-licenses/Unicode-3.0.txt +39 -0
- package/docs/guardrail-licenses/libunwind-LICENSE.txt +311 -0
- package/docs/guardrail-licenses/manifest.json +71 -0
- package/docs/guardrail-licenses/musl-COPYRIGHT.txt +193 -0
- package/docs/guardrail.md +33 -0
- package/docs/lifecycle-memory.md +25 -0
- package/docs/lisp.md +33 -9
- package/docs/memory-evolution.md +6 -6
- package/docs/owned-execution.md +3 -3
- package/docs/replay-memory-review.md +26 -0
- package/docs/semantic-compaction.md +2 -0
- package/guardrail/aarch64-apple-darwin/kiokuko-guardrail +0 -0
- package/guardrail/aarch64-apple-darwin/manifest.json +71 -0
- package/guardrail/aarch64-unknown-linux-musl/kiokuko-guardrail +0 -0
- package/guardrail/aarch64-unknown-linux-musl/manifest.json +69 -0
- package/guardrail/manifest.json +204 -0
- package/guardrail/node-runner.mjs +37 -0
- package/guardrail/protocols/coding-routine.lisp +33 -0
- package/guardrail/x86_64-apple-darwin/kiokuko-guardrail +0 -0
- package/guardrail/x86_64-apple-darwin/manifest.json +71 -0
- package/guardrail/x86_64-unknown-linux-musl/kiokuko-guardrail +0 -0
- package/guardrail/x86_64-unknown-linux-musl/manifest.json +68 -0
- package/migrations/038_coding_admission.sql +19 -0
- package/migrations/039_memory_lifecycle.sql +336 -0
- package/migrations/040_task_state.sql +45 -0
- package/migrations/041_task_source_history.sql +88 -0
- package/migrations/042_evolution_source_epochs.sql +148 -0
- package/package.json +45 -27
- package/scripts/guardrail-artifacts.d.mts +13 -0
- package/scripts/guardrail-artifacts.mjs +136 -0
- package/skills/kiokuko-lisp/SKILL.md +1 -1
- package/skills/kiokuko-soul/SKILL.md +6 -6
|
@@ -17,7 +17,7 @@ import { EvolutionWorker } from '../memory/evolution/worker.js';
|
|
|
17
17
|
import { AutoGlobalizationWorker } from '../memory/auto-globalization.js';
|
|
18
18
|
import { DeepMemoryFinalizer } from '../deep-thinker/memory-finalizer.js';
|
|
19
19
|
import { DeepStore } from '../deep-thinker/store.js';
|
|
20
|
-
import { createHash } from 'node:crypto';
|
|
20
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
21
21
|
import { TransactionCommitUncertainError, withImmediateTransaction } from '../db/transaction.js';
|
|
22
22
|
import { KiokukoError } from '../errors.js';
|
|
23
23
|
import { recordEntryInTransaction } from '../memory/entries.js';
|
|
@@ -705,12 +705,64 @@ function repositoryId(database, workspace) {
|
|
|
705
705
|
throw new KiokukoError('INTEGRITY_ERROR', 'DSH finalization workspace has no repository binding');
|
|
706
706
|
return row.repositoryId;
|
|
707
707
|
}
|
|
708
|
+
function finalizationIdentity(job) {
|
|
709
|
+
return job.sourceEpoch === 1 ? `finalizer:${job.runId}` : `finalizer:${job.runId}:source:${job.sourceEpoch}`;
|
|
710
|
+
}
|
|
711
|
+
function storedFinalization(database, job) {
|
|
712
|
+
if (job.archived) {
|
|
713
|
+
const row = database.prepare('SELECT job_json FROM dsh_task_source_finalizations WHERE run_id=? AND source_epoch=?')
|
|
714
|
+
.get(job.runId, job.sourceEpoch);
|
|
715
|
+
return row ? JSON.parse(row.job_json) : undefined;
|
|
716
|
+
}
|
|
717
|
+
const row = database.prepare('SELECT * FROM dsh_memory_finalizations WHERE run_id=? AND source_epoch=?')
|
|
718
|
+
.get(job.runId, job.sourceEpoch);
|
|
719
|
+
return row;
|
|
720
|
+
}
|
|
721
|
+
function updateFinalization(database, job, fields) {
|
|
722
|
+
if (job.archived) {
|
|
723
|
+
const row = storedFinalization(database, job);
|
|
724
|
+
if (row)
|
|
725
|
+
database.prepare('UPDATE dsh_task_source_finalizations SET job_json=? WHERE run_id=? AND source_epoch=?')
|
|
726
|
+
.run(JSON.stringify({ ...row, ...fields }), job.runId, job.sourceEpoch);
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
const keys = Object.keys(fields);
|
|
730
|
+
if (keys.some(key => !/^[a-z_]+$/u.test(key)))
|
|
731
|
+
throw new Error('invalid_finalization_field');
|
|
732
|
+
database.prepare(`UPDATE dsh_memory_finalizations SET ${keys.map(key => `${key}=?`).join(',')} WHERE run_id=? AND source_epoch=?`)
|
|
733
|
+
.run(...Object.values(fields), job.runId, job.sourceEpoch);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
function assertFinalizationLease(database, job, now) {
|
|
737
|
+
const current = storedFinalization(database, job);
|
|
738
|
+
if (!current || current.status !== 'processing' || current.claim_nonce !== job.claimNonce || current.source_epoch !== job.sourceEpoch
|
|
739
|
+
|| current.dsh_session_id !== job.dshSessionId || typeof current.lease_until !== 'string' || current.lease_until <= now)
|
|
740
|
+
throw new KiokukoError('CONFLICT', 'DSH memory finalization source generation is no longer claimed');
|
|
741
|
+
if (!job.archived) {
|
|
742
|
+
assertMemoryLease(database, job.runId, job.claimNonce, now);
|
|
743
|
+
const run = database.prepare('SELECT COALESCE(task_owner_session_id,dsh_session_id) AS owner FROM ledger_runs WHERE run_id=?').get(job.runId);
|
|
744
|
+
if (run?.owner !== job.dshSessionId)
|
|
745
|
+
throw new KiokukoError('CONFLICT', 'DSH memory finalization source owner changed');
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
function archiveJob(row) {
|
|
749
|
+
return { archived: true, runId: String(row.run_id), workspace: String(row.workspace), dshSessionId: String(row.dsh_session_id),
|
|
750
|
+
sourceEpoch: Number(row.source_epoch), sourceGeneration: String(row.source_generation), sourceStartSeq: Number(row.source_start_seq), sourceEndSeq: Number(row.source_end_seq),
|
|
751
|
+
attemptCount: Number(row.attempt_count), scheduledAt: String(row.scheduled_at), inputMode: row.input_mode,
|
|
752
|
+
extractionVersion: row.extraction_version, evidenceSelectionVersion: row.evidence_selection_version,
|
|
753
|
+
memoryAdoptionVersion: row.memory_adoption_version, evidenceContractVersion: row.evidence_contract_version,
|
|
754
|
+
outcome: row.outcome, claimNonce: String(row.claim_nonce), leaseUntil: String(row.lease_until) };
|
|
755
|
+
}
|
|
708
756
|
export function bindDshRunLogStartInTransaction(database, input, now) {
|
|
709
757
|
const runId = validateIdentity(input.runId, 'runId');
|
|
710
758
|
const workspace = validateIdentity(input.workspace, 'workspace');
|
|
711
759
|
const sessionId = validateIdentity(input.dshSessionId, 'dshSessionId');
|
|
712
760
|
const sourceStartSeq = validatedSequence(input.sourceStartSeq, 'sourceStartSeq');
|
|
713
761
|
const sourceStartTurn = validatedTurn(input.sourceStartTurn, 'sourceStartTurn');
|
|
762
|
+
const preceding = database.prepare(`SELECT json_extract(job_json,'$.source_end_seq') AS sourceEndSeq FROM dsh_task_source_finalizations
|
|
763
|
+
WHERE run_id=? AND json_extract(job_json,'$.dsh_session_id')=? ORDER BY source_epoch DESC LIMIT 1`).get(runId, sessionId);
|
|
764
|
+
if (preceding && sourceStartSeq <= preceding.sourceEndSeq)
|
|
765
|
+
throw new KiokukoError('CONFLICT', 'Resumed log source overlaps an earlier finalized source range');
|
|
714
766
|
const existing = database.prepare(`
|
|
715
767
|
SELECT workspace, dsh_session_id AS dshSessionId,
|
|
716
768
|
source_start_seq AS sourceStartSeq, source_start_turn AS sourceStartTurn
|
|
@@ -815,14 +867,11 @@ export class DshMemoryFinalizer {
|
|
|
815
867
|
catch { /* optional enrichment never vetoes native work */ } }
|
|
816
868
|
async admitIndex(workspace, sessionId, envelope) { await this.#indexService?.admitIndex(workspace, sessionId, envelope); }
|
|
817
869
|
async admitConversationIndex(workspace, sessionId, envelope, assertCurrent) { await this.#indexService?.admitConversation(workspace, sessionId, envelope, assertCurrent); }
|
|
818
|
-
async indexCommand(sessionId, raw) {
|
|
870
|
+
async indexCommand(sessionId, raw) { return { recorded: false, workMayContinue: true, reason: 'post_task_memory_review_required' }; }
|
|
819
871
|
get lastDrainError() { return this.#lastDrainError; }
|
|
820
872
|
/** Recover a process-interrupted job once, then drain pending work in background. */
|
|
821
873
|
async start() {
|
|
822
|
-
|
|
823
|
-
throw new KiokukoError('SERVICE_UNAVAILABLE', 'DSH memory finalizer is closed');
|
|
824
|
-
this.#startup ??= this.#startOnce();
|
|
825
|
-
await this.#startup;
|
|
874
|
+
return; // Replaced by post-task native review; old pending jobs are not resumed.
|
|
826
875
|
}
|
|
827
876
|
async #startOnce() {
|
|
828
877
|
this.#configured = true;
|
|
@@ -835,6 +884,15 @@ export class DshMemoryFinalizer {
|
|
|
835
884
|
WHERE status IN ('processing', 'failed') AND COALESCE(last_error_code,'')<>'MEMORY_FORGOTTEN' AND attempt_count < ? AND capture_admission='ready' AND (claim_nonce IS NULL OR lease_until<=?)
|
|
836
885
|
`).run(this.#now(), this.#maximumAttempts, this.#now());
|
|
837
886
|
});
|
|
887
|
+
await this.#runtime.withDatabase(database => withImmediateTransaction(database, () => {
|
|
888
|
+
for (const item of database.prepare('SELECT job_json FROM dsh_task_source_finalizations').all()) {
|
|
889
|
+
const row = JSON.parse(item.job_json);
|
|
890
|
+
if (['processing', 'failed'].includes(String(row.status)) && row.last_error_code !== 'MEMORY_FORGOTTEN'
|
|
891
|
+
&& Number(row.attempt_count) < this.#maximumAttempts && row.capture_admission === 'ready'
|
|
892
|
+
&& (!row.claim_nonce || String(row.lease_until) <= this.#now()))
|
|
893
|
+
updateFinalization(database, archiveJob(row), { status: 'pending', claim_nonce: null, lease_until: null, updated_at: this.#now() });
|
|
894
|
+
}
|
|
895
|
+
}));
|
|
838
896
|
await this.#runtime.withDatabase(database => configureEvolution(database, this.#evolutionConfig.mode));
|
|
839
897
|
if (this.#closed)
|
|
840
898
|
return;
|
|
@@ -849,59 +907,15 @@ export class DshMemoryFinalizer {
|
|
|
849
907
|
}
|
|
850
908
|
/** Persist the first DSH turn boundary for a run before model execution continues. */
|
|
851
909
|
async bindRunStart(input) {
|
|
852
|
-
|
|
853
|
-
await this.#runtime.withDatabase((database) => withImmediateTransaction(database, () => {
|
|
854
|
-
bindDshRunLogStartInTransaction(database, input, now);
|
|
855
|
-
}));
|
|
910
|
+
return; // Optional memory cannot add a task-admission prerequisite.
|
|
856
911
|
}
|
|
857
912
|
/** Must be called inside the same transaction that terminalizes the run. */
|
|
858
913
|
scheduleInTransaction(database, input) {
|
|
859
|
-
|
|
860
|
-
const runId = validateIdentity(input.runId, 'runId');
|
|
861
|
-
const workspace = validateIdentity(input.workspace, 'workspace');
|
|
862
|
-
const sessionId = validateIdentity(input.dshSessionId, 'dshSessionId');
|
|
863
|
-
const sourceEndSeq = validatedSequence(input.sourceEndSeq, 'sourceEndSeq');
|
|
864
|
-
const existing = database.prepare('SELECT status FROM dsh_memory_finalizations WHERE run_id = ?')
|
|
865
|
-
.get(runId);
|
|
866
|
-
if (existing !== undefined)
|
|
867
|
-
return;
|
|
868
|
-
const boundary = database.prepare(`
|
|
869
|
-
SELECT source_start_seq AS sourceStartSeq
|
|
870
|
-
FROM dsh_run_log_boundaries
|
|
871
|
-
WHERE run_id = ? AND workspace = ? AND dsh_session_id = ?
|
|
872
|
-
`).get(runId, workspace, sessionId);
|
|
873
|
-
if (boundary === undefined)
|
|
874
|
-
throw new KiokukoError('INTEGRITY_ERROR', 'Completed DSH run has no bound log start');
|
|
875
|
-
if (sourceEndSeq < boundary.sourceStartSeq)
|
|
876
|
-
throw new KiokukoError('INTEGRITY_ERROR', 'Completed DSH run has a reversed log range');
|
|
877
|
-
const now = this.#now();
|
|
878
|
-
database.prepare(`
|
|
879
|
-
INSERT INTO dsh_memory_finalizations (
|
|
880
|
-
run_id, workspace, dsh_session_id, source_start_seq, source_end_seq,
|
|
881
|
-
status, attempt_count, input_mode, extraction_version, evidence_selection_version, memory_adoption_version, capture_admission, evidence_contract_version,
|
|
882
|
-
scheduled_at, updated_at
|
|
883
|
-
) VALUES (?, ?, ?, ?, ?, 'pending', 0, ?, ?, 2, ?, ?, 4, ?, ?)
|
|
884
|
-
`).run(runId, workspace, sessionId, boundary.sourceStartSeq, sourceEndSeq, this.#inputMode, this.#evolutionConfig.mode === 'off' ? 1 : 2, 2, capturePolicy(database, workspace, sessionId).mode === 'allowed' ? 'ready' : capturePolicy(database, workspace, sessionId).mode, now, now);
|
|
914
|
+
return; // No durable draft/finalization job before user review.
|
|
885
915
|
}
|
|
886
916
|
/** Schedule a background drain after the enclosing transaction commits. */
|
|
887
917
|
kick() {
|
|
888
|
-
|
|
889
|
-
return;
|
|
890
|
-
this.#autoGlobalWorker?.kick();
|
|
891
|
-
if (this.#drain !== undefined) {
|
|
892
|
-
this.#rerunRequested = true;
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
const operation = this.#drainPending();
|
|
896
|
-
this.#drain = operation;
|
|
897
|
-
void operation.catch((error) => { this.#lastDrainError = error; }).finally(() => {
|
|
898
|
-
if (this.#drain === operation)
|
|
899
|
-
this.#drain = undefined;
|
|
900
|
-
if (this.#rerunRequested && !this.#closed) {
|
|
901
|
-
this.#rerunRequested = false;
|
|
902
|
-
this.kick();
|
|
903
|
-
}
|
|
904
|
-
});
|
|
918
|
+
return; // Automatic derived-memory writes were replaced by exact human review.
|
|
905
919
|
}
|
|
906
920
|
/** Await currently queued work; intended for orderly shutdown and tests. */
|
|
907
921
|
async whenIdle() {
|
|
@@ -916,23 +930,27 @@ export class DshMemoryFinalizer {
|
|
|
916
930
|
}
|
|
917
931
|
/** Explicitly retry one contained failure without changing DSH session state. */
|
|
918
932
|
async retryFailed(runId) {
|
|
919
|
-
|
|
920
|
-
await this.#runtime.withDatabase((database) => {
|
|
921
|
-
database.prepare(`
|
|
922
|
-
UPDATE dsh_memory_finalizations
|
|
923
|
-
SET status = 'pending', updated_at = ?
|
|
924
|
-
WHERE run_id = ? AND status = 'failed' AND COALESCE(last_error_code,'')<>'MEMORY_FORGOTTEN' AND attempt_count < ? AND capture_admission='ready' AND NOT EXISTS(SELECT 1 FROM memory_capture_exclusions x WHERE x.workspace=dsh_memory_finalizations.workspace AND x.native_session_id=dsh_memory_finalizations.dsh_session_id)
|
|
925
|
-
`).run(this.#now(), checked, this.#maximumAttempts);
|
|
926
|
-
});
|
|
927
|
-
this.kick();
|
|
933
|
+
return; // A historical pending job does not carry approval of a shown revision.
|
|
928
934
|
}
|
|
929
935
|
async #claim() {
|
|
930
936
|
return this.#runtime.withDatabase((database) => withImmediateTransaction(database, () => {
|
|
937
|
+
// Old source segments are durable work, independent of the current task owner.
|
|
938
|
+
for (const item of database.prepare(`SELECT job_json FROM dsh_task_source_finalizations
|
|
939
|
+
WHERE json_extract(job_json,'$.status')='pending' ORDER BY run_id,source_epoch`).all()) {
|
|
940
|
+
const archived = JSON.parse(item.job_json), job = archiveJob(archived);
|
|
941
|
+
if (job.attemptCount >= this.#maximumAttempts || archived.capture_admission !== 'ready'
|
|
942
|
+
|| capturePolicy(database, job.workspace, job.dshSessionId).mode !== 'allowed')
|
|
943
|
+
continue;
|
|
944
|
+
const nonce = randomUUID(), until = new Date(Date.parse(this.#now()) + this.#timeoutMs + 30000).toISOString();
|
|
945
|
+
updateFinalization(database, job, { status: 'processing', attempt_count: job.attemptCount + 1, started_at: this.#now(),
|
|
946
|
+
claim_nonce: nonce, lease_until: until, last_error_code: null, last_error_message: null, updated_at: this.#now() });
|
|
947
|
+
return { ...job, attemptCount: job.attemptCount + 1, claimNonce: nonce, leaseUntil: until };
|
|
948
|
+
}
|
|
931
949
|
const row = database.prepare(`
|
|
932
|
-
SELECT run_id AS runId, workspace, dsh_session_id AS dshSessionId,
|
|
950
|
+
SELECT run_id AS runId, workspace, dsh_session_id AS dshSessionId, source_epoch AS sourceEpoch,
|
|
933
951
|
source_start_seq AS sourceStartSeq, source_end_seq AS sourceEndSeq,
|
|
934
952
|
attempt_count AS attemptCount, scheduled_at AS scheduledAt, input_mode AS inputMode, extraction_version AS extractionVersion, evidence_selection_version AS evidenceSelectionVersion, memory_adoption_version AS memoryAdoptionVersion, evidence_contract_version AS evidenceContractVersion,
|
|
935
|
-
(SELECT status FROM ledger_runs r WHERE r.run_id=dsh_memory_finalizations.run_id) AS outcome
|
|
953
|
+
COALESCE(source_outcome,(SELECT status FROM ledger_runs r WHERE r.run_id=dsh_memory_finalizations.run_id)) AS outcome
|
|
936
954
|
FROM dsh_memory_finalizations
|
|
937
955
|
WHERE status = 'pending' AND attempt_count < ? AND capture_admission='ready' AND NOT EXISTS(SELECT 1 FROM memory_capture_exclusions x WHERE x.workspace=dsh_memory_finalizations.workspace AND x.native_session_id=dsh_memory_finalizations.dsh_session_id) AND NOT EXISTS(SELECT 1 FROM memory_review_states m WHERE m.run_id=dsh_memory_finalizations.run_id AND m.lease_nonce IS NOT NULL AND m.lease_until>?)
|
|
938
956
|
ORDER BY scheduled_at, run_id
|
|
@@ -943,7 +961,7 @@ export class DshMemoryFinalizer {
|
|
|
943
961
|
const now = this.#now();
|
|
944
962
|
database.prepare(`INSERT OR IGNORE INTO memory_review_states(run_id,workspace,session_id,source_generation,admitted_after_seq,scanned_through_seq,scheduled_through_seq,reviewed_through_seq,terminal_outcome)
|
|
945
963
|
VALUES(?,?,?,?,?,?,?,?,?)`).run(row.runId, row.workspace, row.dshSessionId, `legacy:${row.dshSessionId}`, row.sourceStartSeq - 1, row.sourceStartSeq - 1, row.sourceStartSeq - 1, row.sourceStartSeq - 1, row.outcome);
|
|
946
|
-
const nonce = acquireMemoryLease(database, row.runId,
|
|
964
|
+
const nonce = acquireMemoryLease(database, row.runId, finalizationIdentity(row), now, this.#timeoutMs + 30000);
|
|
947
965
|
if (!nonce)
|
|
948
966
|
return undefined;
|
|
949
967
|
const until = reviewState(database, row.runId).lease_until;
|
|
@@ -973,7 +991,10 @@ export class DshMemoryFinalizer {
|
|
|
973
991
|
throw new KiokukoError('SERVICE_UNAVAILABLE', 'DSH LLM service is unavailable for memory finalization');
|
|
974
992
|
const { envelope } = prepared;
|
|
975
993
|
const base = buildFinalizationRequest(job, prepared, signal);
|
|
976
|
-
const
|
|
994
|
+
const observed = await this.#runtime.withDatabase(db => ownedRunEvidence(db, job.runId, job.dshSessionId));
|
|
995
|
+
const cited = new Set(reconciliation?.evidence.map(item => item.id) ?? []);
|
|
996
|
+
const execution = boundedOwnedEvidence(observed.filter(receipt => reconciliation ? cited.has(receipt.evidenceRef)
|
|
997
|
+
: prepared.evidence.includes(receipt.operationId)));
|
|
977
998
|
const built = execution.items.length ? { ...base, request: { ...base.request, messages: [...base.request.messages, { role: 'user', content: [{ type: 'text', text: JSON.stringify({ executionObservations: execution.items, omittedExecutionObservations: execution.omitted, policy: 'Host observations describe execution and source-bound checks. They do not verify generalized lessons. Failed, unknown, stale or previous-generation results are not current success. Preserve conditions and source versions in candidate memories.' }) }] }] } } : base;
|
|
978
999
|
let request = reconciliation ? { ...built.request, tools: [], system: `${built.request.system ?? ''}
|
|
979
1000
|
Override the legacy memory output format: return only schemaVersion 3 with memoryOperations and optional episode. Kinds: fact, decision, preference, lesson, reference. Use only the evidence IDs and existing entry IDs below. Operations: add(kind,title,body,evidenceIds), update(targetEntryId,expectedRevision,expectedContentHash,kind,title,body,evidenceIds), unchanged(targetEntryId,evidenceIds), defer(reason: ambiguous|conflict|insufficient_context,evidenceIds). Only editable candidates may be updated. Do not duplicate existing memories; preserve conditions and corrections. Assistant statements, quotes and recalled memory are not new evidence. Empty memoryOperations is valid.`,
|
|
@@ -1015,11 +1036,8 @@ Use schemaVersion 4 with memoryOperations and optional episode. Use only supplie
|
|
|
1015
1036
|
let finish;
|
|
1016
1037
|
await this.#runtime.withDatabase(database => withImmediateTransaction(database, () => {
|
|
1017
1038
|
assertCaptureAllowed(database, job.workspace, job.dshSessionId);
|
|
1018
|
-
|
|
1019
|
-
database
|
|
1020
|
-
const changed = database.prepare('SELECT changes() AS n').get().n;
|
|
1021
|
-
if (!changed)
|
|
1022
|
-
throw new Error('stale_finalizer_claim');
|
|
1039
|
+
assertFinalizationLease(database, job, this.#now());
|
|
1040
|
+
updateFinalization(database, job, { dispatched_at: this.#now() });
|
|
1023
1041
|
}));
|
|
1024
1042
|
for await (const value of abortableStream(this.#llm.stream(request), signal)) {
|
|
1025
1043
|
const chunk = record(value);
|
|
@@ -1105,18 +1123,18 @@ Use schemaVersion 4 with memoryOperations and optional episode. Use only supplie
|
|
|
1105
1123
|
if (job.memoryAdoptionVersion === 2) {
|
|
1106
1124
|
const evidence = await this.#reviewEvidence(job);
|
|
1107
1125
|
reconciliation = await this.#runtime.withDatabase(database => {
|
|
1108
|
-
const
|
|
1109
|
-
const range = { workspace: job.workspace, sessionId: job.dshSessionId, runId: job.runId, sourceGeneration:
|
|
1126
|
+
const generation = job.archived ? job.sourceGeneration : reviewState(database, job.runId).source_generation;
|
|
1127
|
+
const range = { workspace: job.workspace, sessionId: job.dshSessionId, runId: job.runId, sourceGeneration: generation, startSeq: job.sourceStartSeq, endSeq: job.sourceEndSeq };
|
|
1110
1128
|
return { range, evidence, ...memorySnapshots(database, range, evidence.map(e => e.text).join('\n'), job.evidenceContractVersion === 4) };
|
|
1111
1129
|
});
|
|
1112
1130
|
}
|
|
1113
1131
|
const extractEpisode = job.extractionVersion === 2 && await this.#runtime.withDatabase(database => evolutionSettings(database).mode !== 'off');
|
|
1114
1132
|
const requestJob = extractEpisode ? job : { ...job, extractionVersion: 1 };
|
|
1115
|
-
const bindingHash = canonicalContentHash({ runId: job.runId, sessionId: job.dshSessionId, digest: prepared.digest,
|
|
1133
|
+
const bindingHash = canonicalContentHash({ runId: job.runId, sourceEpoch: job.sourceEpoch, sessionId: job.dshSessionId, digest: prepared.digest,
|
|
1116
1134
|
evidence: reconciliation ? reviewManifest(reconciliation.evidence) : null, existing: reconciliation?.existing ?? null });
|
|
1117
|
-
const staged = await this.#runtime.withDatabase(db => db
|
|
1135
|
+
const staged = await this.#runtime.withDatabase(db => { assertFinalizationLease(db, job, this.#now()); return storedFinalization(db, job); });
|
|
1118
1136
|
let result;
|
|
1119
|
-
if (staged?.staged_binding_hash === bindingHash && staged.staged_capsule_json) {
|
|
1137
|
+
if (staged?.staged_binding_hash === bindingHash && typeof staged.staged_capsule_json === 'string') {
|
|
1120
1138
|
const cached = JSON.parse(staged.staged_capsule_json);
|
|
1121
1139
|
if (reconciliation) {
|
|
1122
1140
|
const parsed = (job.evidenceContractVersion === 4 ? FinalizerResultV4 : FinalizerResult).parse(JSON.parse(cached.capsuleJson));
|
|
@@ -1131,9 +1149,8 @@ Use schemaVersion 4 with memoryOperations and optional episode. Use only supplie
|
|
|
1131
1149
|
throw new KiokukoError('VALIDATION_ERROR', 'Memory extraction contains secret-bearing material');
|
|
1132
1150
|
await this.#runtime.withDatabase(db => withImmediateTransaction(db, () => {
|
|
1133
1151
|
assertCaptureAllowed(db, job.workspace, job.dshSessionId);
|
|
1134
|
-
|
|
1135
|
-
db
|
|
1136
|
-
.run(JSON.stringify({ capsuleJson: result.capsuleJson, usage: result.usage }), bindingHash, job.runId, job.claimNonce);
|
|
1152
|
+
assertFinalizationLease(db, job, this.#now());
|
|
1153
|
+
updateFinalization(db, job, { staged_capsule_json: JSON.stringify({ capsuleJson: result.capsuleJson, usage: result.usage }), staged_binding_hash: bindingHash });
|
|
1137
1154
|
}));
|
|
1138
1155
|
}
|
|
1139
1156
|
if (reconciliation) {
|
|
@@ -1154,14 +1171,8 @@ Use schemaVersion 4 with memoryOperations and optional episode. Use only supplie
|
|
|
1154
1171
|
const now = this.#now();
|
|
1155
1172
|
await this.#runtime.withDatabase((database) => withImmediateTransaction(database, () => {
|
|
1156
1173
|
assertCaptureAllowed(database, job.workspace, job.dshSessionId);
|
|
1157
|
-
|
|
1174
|
+
assertFinalizationLease(database, job, this.#now());
|
|
1158
1175
|
controller.signal.throwIfAborted();
|
|
1159
|
-
const current = database.prepare('SELECT status,claim_nonce FROM dsh_memory_finalizations WHERE run_id = ?')
|
|
1160
|
-
.get(job.runId);
|
|
1161
|
-
if (current?.status === 'completed')
|
|
1162
|
-
return;
|
|
1163
|
-
if (current?.status !== 'processing' || current.claim_nonce !== job.claimNonce)
|
|
1164
|
-
throw new KiokukoError('CONFLICT', 'DSH memory finalization job is no longer claimed');
|
|
1165
1176
|
const sourceRepositoryId = repositoryId(database, job.workspace);
|
|
1166
1177
|
const scope = buildStructuredScope({
|
|
1167
1178
|
visibility: 'project', retrievalScope: 'project-only', repositoryId: sourceRepositoryId,
|
|
@@ -1175,7 +1186,7 @@ Use schemaVersion 4 with memoryOperations and optional episode. Use only supplie
|
|
|
1175
1186
|
clientKind: 'dsh',
|
|
1176
1187
|
timestamp: now,
|
|
1177
1188
|
};
|
|
1178
|
-
const adopted = reconciliation && result.memoryOperations ? adoptMemories(database, { id:
|
|
1189
|
+
const adopted = reconciliation && result.memoryOperations ? adoptMemories(database, { id: finalizationIdentity(job), range: reconciliation.range, evidence: reconciliation.evidence, existing: reconciliation.existing, operations: result.memoryOperations, observe: false, now, actor: 'kiokuko-dsh-finalizer' }) : undefined;
|
|
1179
1190
|
const saved = adopted ? [...new Map(adopted.entries.map(e => [e.id, e])).values()] : result.capsule.memories.map((memory) => recordEntryInTransaction(database, {
|
|
1180
1191
|
workspace: job.workspace,
|
|
1181
1192
|
kind: memory.kind,
|
|
@@ -1193,29 +1204,32 @@ Use schemaVersion 4 with memoryOperations and optional episode. Use only supplie
|
|
|
1193
1204
|
}, { now }));
|
|
1194
1205
|
const executionReceipts = ownedRunEvidence(database, job.runId, job.dshSessionId);
|
|
1195
1206
|
for (const effect of database.prepare('SELECT entry_id,revision,operation_index FROM memory_review_effects WHERE job_id=? AND disposition IN (\'added\',\'updated\')')
|
|
1196
|
-
.all(
|
|
1207
|
+
.all(finalizationIdentity(job))) {
|
|
1197
1208
|
const operation = result.memoryOperations?.[effect.operation_index];
|
|
1198
1209
|
if (operation)
|
|
1199
1210
|
linkOwnedMemoryEvidence(database, { id: effect.entry_id, revision: effect.revision }, executionReceipts, operation.evidenceIds, { runId: job.runId, sessionId: job.dshSessionId, workspace: job.workspace });
|
|
1200
1211
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1212
|
+
if (job.archived) {
|
|
1213
|
+
const link = database.prepare('INSERT INTO dsh_task_source_entries(run_id,source_epoch,entry_id,ordinal,created_at) VALUES(?,?,?,?,?)');
|
|
1214
|
+
saved.forEach((entry, ordinal) => link.run(job.runId, job.sourceEpoch, entry.id, ordinal, now));
|
|
1215
|
+
}
|
|
1216
|
+
else {
|
|
1217
|
+
const link = database.prepare('INSERT INTO dsh_memory_finalization_entries(run_id,entry_id,ordinal,created_at) VALUES(?,?,?,?)');
|
|
1218
|
+
saved.forEach((entry, ordinal) => link.run(job.runId, entry.id, ordinal, now));
|
|
1219
|
+
}
|
|
1206
1220
|
if (episode && evolutionSettings(database).mode !== 'off') {
|
|
1207
1221
|
database.exec('SAVEPOINT evolution_episode');
|
|
1208
1222
|
try {
|
|
1209
1223
|
const evidence = [...(prepared.episodeEvidence ?? [])];
|
|
1210
1224
|
saveEpisode(database, {
|
|
1211
|
-
runId: job.runId, workspace: job.workspace, sessionId: job.dshSessionId,
|
|
1225
|
+
runId: job.runId, sourceEpoch: job.sourceEpoch, workspace: job.workspace, sessionId: job.dshSessionId,
|
|
1212
1226
|
start: job.sourceStartSeq, end: job.sourceEndSeq, logDigest: prepared.digest, outcome: job.outcome,
|
|
1213
1227
|
evidenceDigest: supportingEvidenceDigest(episode, evidence),
|
|
1214
1228
|
signature: episodeSignature(job.workspace, episode), draft: episode, evidence: evidenceReferences(evidence),
|
|
1215
1229
|
sources: saved.map(e => ({ entryId: e.id, revision: e.revision, hash: e.contentHash })),
|
|
1216
1230
|
...episodeSignals(episode, evidence),
|
|
1217
1231
|
}, now, evidence);
|
|
1218
|
-
scheduleEvolution(database, job.runId, { ...result.envelope, sessionId: job.dshSessionId }, now);
|
|
1232
|
+
scheduleEvolution(database, job.runId, { ...result.envelope, sessionId: job.dshSessionId }, now, job.sourceEpoch);
|
|
1219
1233
|
database.exec('RELEASE evolution_episode');
|
|
1220
1234
|
}
|
|
1221
1235
|
catch {
|
|
@@ -1224,21 +1238,18 @@ Use schemaVersion 4 with memoryOperations and optional episode. Use only supplie
|
|
|
1224
1238
|
episodeError = 'episode_persistence_rejected';
|
|
1225
1239
|
}
|
|
1226
1240
|
}
|
|
1227
|
-
|
|
1241
|
+
if (!job.archived)
|
|
1242
|
+
database.prepare("UPDATE memory_review_states SET handoff_status='finalizer_completed',lease_nonce=NULL,lease_until=NULL WHERE run_id=? AND lease_nonce=?").run(job.runId, job.claimNonce);
|
|
1228
1243
|
if (reconciliation && adopted?.held === 0) {
|
|
1229
|
-
database.prepare('UPDATE memory_review_jobs SET resolved_by=? WHERE run_id=? AND start_seq>=? AND end_seq<=?').run(
|
|
1230
|
-
|
|
1244
|
+
database.prepare('UPDATE memory_review_jobs SET resolved_by=? WHERE run_id=? AND session_id=? AND source_generation=? AND start_seq>=? AND end_seq<=?').run(finalizationIdentity(job), job.runId, job.dshSessionId, reconciliation.range.sourceGeneration, job.sourceStartSeq, job.sourceEndSeq);
|
|
1245
|
+
if (!job.archived)
|
|
1246
|
+
database.prepare('UPDATE memory_review_states SET reviewed_through_seq=max(reviewed_through_seq,?) WHERE run_id=?').run(job.sourceEndSeq, job.runId);
|
|
1231
1247
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
log_digest = ?, capsule_hash = ?, capsule_bytes = ?, provider = ?, model = ?,
|
|
1238
|
-
input_tokens = ?, output_tokens = ?, cache_read_tokens = ?, cache_write_tokens = ?,
|
|
1239
|
-
completed_at = ?, updated_at = ?
|
|
1240
|
-
WHERE run_id = ? AND status = 'processing'
|
|
1241
|
-
`).run(prepared.eventCount, prepared.digest, canonicalContentHash(JSON.parse(result.capsuleJson)), Buffer.byteLength(result.capsuleJson, 'utf8'), result.envelope.provider, result.envelope.model, result.usage.inputTokens ?? null, result.usage.outputTokens ?? null, result.usage.cacheReadTokens ?? null, result.usage.cacheWriteTokens ?? null, now, now, job.runId);
|
|
1248
|
+
updateFinalization(database, job, { status: 'completed', log_event_count: prepared.eventCount, log_digest: prepared.digest,
|
|
1249
|
+
capsule_hash: canonicalContentHash(JSON.parse(result.capsuleJson)), capsule_bytes: Buffer.byteLength(result.capsuleJson, 'utf8'),
|
|
1250
|
+
provider: result.envelope.provider, model: result.envelope.model, input_tokens: result.usage.inputTokens ?? null,
|
|
1251
|
+
output_tokens: result.usage.outputTokens ?? null, cache_read_tokens: result.usage.cacheReadTokens ?? null,
|
|
1252
|
+
cache_write_tokens: result.usage.cacheWriteTokens ?? null, completed_at: now, updated_at: now, ...(episodeError ? { episode_error: episodeError } : {}) });
|
|
1242
1253
|
}));
|
|
1243
1254
|
try {
|
|
1244
1255
|
await this.admitIndex(job.workspace, job.dshSessionId, prepared.envelope);
|
|
@@ -1260,15 +1271,16 @@ Use schemaVersion 4 with memoryOperations and optional episode. Use only supplie
|
|
|
1260
1271
|
const failure = boundedError(error);
|
|
1261
1272
|
try {
|
|
1262
1273
|
await this.#runtime.withDatabase((database) => {
|
|
1263
|
-
database
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1274
|
+
const current = storedFinalization(database, job);
|
|
1275
|
+
if (current?.status === 'processing' && current.claim_nonce === job.claimNonce)
|
|
1276
|
+
updateFinalization(database, job, { status: 'failed', claim_nonce: null, lease_until: null, last_error_code: failure.code, last_error_message: failure.code, updated_at: this.#now() });
|
|
1277
|
+
if (!job.archived) {
|
|
1278
|
+
database.prepare("UPDATE memory_review_states SET handoff_status='finalizer_failed' WHERE run_id=? AND lease_nonce=?").run(job.runId, job.claimNonce);
|
|
1279
|
+
releaseMemoryLease(database, job.runId, job.claimNonce);
|
|
1280
|
+
}
|
|
1281
|
+
if (current?.last_error_code === 'MEMORY_FORGOTTEN')
|
|
1282
|
+
updateFinalization(database, job, { input_tokens: attempt.usage.inputTokens ?? null,
|
|
1283
|
+
output_tokens: attempt.usage.outputTokens ?? null, cache_read_tokens: attempt.usage.cacheReadTokens ?? null, cache_write_tokens: attempt.usage.cacheWriteTokens ?? null });
|
|
1272
1284
|
});
|
|
1273
1285
|
}
|
|
1274
1286
|
catch (markError) {
|