@alan512/experienceengine 0.1.3 → 0.2.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/.claude-plugin/marketplace.json +0 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.env.example +0 -0
- package/.mcp.json +0 -0
- package/LICENSE +0 -0
- package/README.md +196 -114
- package/README.zh-CN.md +230 -100
- package/dist/adapters/claude-code/event-store.d.ts +0 -0
- package/dist/adapters/claude-code/event-store.js +0 -0
- package/dist/adapters/claude-code/event-store.js.map +0 -0
- package/dist/adapters/claude-code/hook-normalizer.d.ts +0 -0
- package/dist/adapters/claude-code/hook-normalizer.js +0 -0
- package/dist/adapters/claude-code/hook-normalizer.js.map +0 -0
- package/dist/adapters/claude-code/runtime-projection.d.ts +0 -0
- package/dist/adapters/claude-code/runtime-projection.js +0 -0
- package/dist/adapters/claude-code/runtime-projection.js.map +0 -0
- package/dist/adapters/claude-code/session-store.d.ts +1 -0
- package/dist/adapters/claude-code/session-store.js +24 -1
- package/dist/adapters/claude-code/session-store.js.map +1 -1
- package/dist/adapters/codex/action-registry.d.ts +84 -0
- package/dist/adapters/codex/action-registry.js +277 -0
- package/dist/adapters/codex/action-registry.js.map +1 -0
- package/dist/adapters/codex/broker-tools.d.ts +114 -0
- package/dist/adapters/codex/broker-tools.js +130 -0
- package/dist/adapters/codex/broker-tools.js.map +1 -0
- package/dist/adapters/codex/instruction-template.d.ts +0 -0
- package/dist/adapters/codex/instruction-template.js +0 -0
- package/dist/adapters/codex/instruction-template.js.map +0 -0
- package/dist/adapters/codex/mcp-server.d.ts +21 -0
- package/dist/adapters/codex/mcp-server.js +103 -423
- package/dist/adapters/codex/mcp-server.js.map +1 -1
- package/dist/analyzer/candidate-signals.d.ts +3 -1
- package/dist/analyzer/candidate-signals.js +159 -0
- package/dist/analyzer/candidate-signals.js.map +1 -1
- package/dist/analyzer/experience-analyzer.d.ts +0 -0
- package/dist/analyzer/experience-analyzer.js +0 -0
- package/dist/analyzer/experience-analyzer.js.map +0 -0
- package/dist/analyzer/extraction-evidence.d.ts +0 -0
- package/dist/analyzer/extraction-evidence.js +0 -0
- package/dist/analyzer/extraction-evidence.js.map +0 -0
- package/dist/analyzer/llm-learning-gate.d.ts +12 -1
- package/dist/analyzer/llm-learning-gate.js +633 -16
- package/dist/analyzer/llm-learning-gate.js.map +1 -1
- package/dist/analyzer/node-deduper.d.ts +0 -0
- package/dist/analyzer/node-deduper.js +0 -0
- package/dist/analyzer/node-deduper.js.map +0 -0
- package/dist/analyzer/node-normalizer.d.ts +0 -0
- package/dist/analyzer/node-normalizer.js +0 -0
- package/dist/analyzer/node-normalizer.js.map +0 -0
- package/dist/analyzer/storage-gate.d.ts +0 -0
- package/dist/analyzer/storage-gate.js +0 -0
- package/dist/analyzer/storage-gate.js.map +0 -0
- package/dist/analyzer/strategy-extractor.d.ts +0 -0
- package/dist/analyzer/strategy-extractor.js +0 -0
- package/dist/analyzer/strategy-extractor.js.map +0 -0
- package/dist/analyzer/warning-extractor.d.ts +0 -0
- package/dist/analyzer/warning-extractor.js +0 -0
- package/dist/analyzer/warning-extractor.js.map +0 -0
- package/dist/cli/commands/backup.d.ts +0 -0
- package/dist/cli/commands/backup.js +0 -0
- package/dist/cli/commands/backup.js.map +0 -0
- package/dist/cli/commands/claude-hook.d.ts +0 -0
- package/dist/cli/commands/claude-hook.js +11 -4
- package/dist/cli/commands/claude-hook.js.map +1 -1
- package/dist/cli/commands/codex-mcp-server.d.ts +0 -0
- package/dist/cli/commands/codex-mcp-server.js +0 -0
- package/dist/cli/commands/codex-mcp-server.js.map +0 -0
- package/dist/cli/commands/codex.d.ts +60 -0
- package/dist/cli/commands/codex.js +188 -0
- package/dist/cli/commands/codex.js.map +1 -0
- package/dist/cli/commands/config.d.ts +0 -0
- package/dist/cli/commands/config.js +0 -0
- package/dist/cli/commands/config.js.map +0 -0
- package/dist/cli/commands/cool.d.ts +0 -0
- package/dist/cli/commands/cool.js +0 -0
- package/dist/cli/commands/cool.js.map +0 -0
- package/dist/cli/commands/disable.d.ts +0 -0
- package/dist/cli/commands/disable.js +0 -0
- package/dist/cli/commands/disable.js.map +0 -0
- package/dist/cli/commands/doctor.d.ts +0 -0
- package/dist/cli/commands/doctor.js +20 -0
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/enable.d.ts +0 -0
- package/dist/cli/commands/enable.js +0 -0
- package/dist/cli/commands/enable.js.map +0 -0
- package/dist/cli/commands/evaluate.d.ts +9 -3
- package/dist/cli/commands/evaluate.js +31 -5
- package/dist/cli/commands/evaluate.js.map +1 -1
- package/dist/cli/commands/export.d.ts +0 -0
- package/dist/cli/commands/export.js +0 -0
- package/dist/cli/commands/export.js.map +0 -0
- package/dist/cli/commands/feedback.d.ts +0 -0
- package/dist/cli/commands/feedback.js +0 -0
- package/dist/cli/commands/feedback.js.map +0 -0
- package/dist/cli/commands/import.d.ts +0 -0
- package/dist/cli/commands/import.js +0 -0
- package/dist/cli/commands/import.js.map +0 -0
- package/dist/cli/commands/init.d.ts +0 -0
- package/dist/cli/commands/init.js +21 -8
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/inspect.d.ts +0 -0
- package/dist/cli/commands/inspect.js +69 -1
- package/dist/cli/commands/inspect.js.map +1 -1
- package/dist/cli/commands/install.d.ts +0 -0
- package/dist/cli/commands/install.js +0 -0
- package/dist/cli/commands/install.js.map +0 -0
- package/dist/cli/commands/maintenance.d.ts +0 -0
- package/dist/cli/commands/maintenance.js +0 -0
- package/dist/cli/commands/maintenance.js.map +0 -0
- package/dist/cli/commands/mcp-server.d.ts +0 -0
- package/dist/cli/commands/mcp-server.js +0 -0
- package/dist/cli/commands/mcp-server.js.map +0 -0
- package/dist/cli/commands/models.d.ts +0 -0
- package/dist/cli/commands/models.js +0 -0
- package/dist/cli/commands/models.js.map +0 -0
- package/dist/cli/commands/repair.d.ts +0 -0
- package/dist/cli/commands/repair.js +3 -3
- package/dist/cli/commands/repair.js.map +1 -1
- package/dist/cli/commands/retire.d.ts +0 -0
- package/dist/cli/commands/retire.js +0 -0
- package/dist/cli/commands/retire.js.map +0 -0
- package/dist/cli/commands/rollback.d.ts +0 -0
- package/dist/cli/commands/rollback.js +0 -0
- package/dist/cli/commands/rollback.js.map +0 -0
- package/dist/cli/commands/stats.d.ts +0 -0
- package/dist/cli/commands/stats.js +0 -0
- package/dist/cli/commands/stats.js.map +0 -0
- package/dist/cli/commands/status.d.ts +0 -0
- package/dist/cli/commands/status.js +32 -0
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/upgrade.d.ts +0 -0
- package/dist/cli/commands/upgrade.js +0 -0
- package/dist/cli/commands/upgrade.js.map +0 -0
- package/dist/cli/dispatch.d.ts +0 -0
- package/dist/cli/dispatch.js +16 -4
- package/dist/cli/dispatch.js.map +1 -1
- package/dist/cli/index.d.ts +0 -0
- package/dist/cli/index.js.map +0 -0
- package/dist/cli/state-model.d.ts +0 -0
- package/dist/cli/state-model.js +0 -0
- package/dist/cli/state-model.js.map +0 -0
- package/dist/config/config-schema.d.ts +177 -0
- package/dist/config/config-schema.js +142 -1
- package/dist/config/config-schema.js.map +1 -1
- package/dist/config/default-config.d.ts +0 -0
- package/dist/config/default-config.js +19 -1
- package/dist/config/default-config.js.map +1 -1
- package/dist/config/load-config.d.ts +0 -0
- package/dist/config/load-config.js +72 -1
- package/dist/config/load-config.js.map +1 -1
- package/dist/config/path-resolver.d.ts +0 -0
- package/dist/config/path-resolver.js +0 -0
- package/dist/config/path-resolver.js.map +0 -0
- package/dist/config/runtime-env.d.ts +0 -0
- package/dist/config/runtime-env.js +0 -0
- package/dist/config/runtime-env.js.map +0 -0
- package/dist/config/secrets-store.d.ts +0 -0
- package/dist/config/secrets-store.js +0 -0
- package/dist/config/secrets-store.js.map +0 -0
- package/dist/config/settings-store.d.ts +19 -0
- package/dist/config/settings-store.js +11 -0
- package/dist/config/settings-store.js.map +1 -1
- package/dist/controller/candidate-retriever.d.ts +15 -1
- package/dist/controller/candidate-retriever.js +91 -137
- package/dist/controller/candidate-retriever.js.map +1 -1
- package/dist/controller/injection-renderer.d.ts +0 -0
- package/dist/controller/injection-renderer.js +0 -0
- package/dist/controller/injection-renderer.js.map +0 -0
- package/dist/controller/injection-scorecard.d.ts +2 -14
- package/dist/controller/injection-scorecard.js +29 -0
- package/dist/controller/injection-scorecard.js.map +1 -1
- package/dist/controller/inline-notice.d.ts +0 -0
- package/dist/controller/inline-notice.js +0 -0
- package/dist/controller/inline-notice.js.map +0 -0
- package/dist/controller/intervention-controller.d.ts +3 -15
- package/dist/controller/intervention-controller.js +217 -57
- package/dist/controller/intervention-controller.js.map +1 -1
- package/dist/controller/lexical-retriever.d.ts +0 -0
- package/dist/controller/lexical-retriever.js +0 -0
- package/dist/controller/lexical-retriever.js.map +0 -0
- package/dist/controller/model-reranker.d.ts +0 -0
- package/dist/controller/model-reranker.js +0 -0
- package/dist/controller/model-reranker.js.map +0 -0
- package/dist/controller/node-ranker.d.ts +0 -0
- package/dist/controller/node-ranker.js +0 -0
- package/dist/controller/node-ranker.js.map +0 -0
- package/dist/controller/policy-enricher.d.ts +10 -0
- package/dist/controller/policy-enricher.js +186 -0
- package/dist/controller/policy-enricher.js.map +1 -0
- package/dist/controller/query-rewrite.d.ts +0 -0
- package/dist/controller/query-rewrite.js +0 -0
- package/dist/controller/query-rewrite.js.map +0 -0
- package/dist/controller/retrieval-context.d.ts +3 -0
- package/dist/controller/retrieval-context.js +37 -0
- package/dist/controller/retrieval-context.js.map +1 -0
- package/dist/controller/second-opinion-gate.d.ts +41 -0
- package/dist/controller/second-opinion-gate.js +225 -0
- package/dist/controller/second-opinion-gate.js.map +1 -0
- package/dist/controller/trigger-evaluator.d.ts +4 -0
- package/dist/controller/trigger-evaluator.js +8 -2
- package/dist/controller/trigger-evaluator.js.map +1 -1
- package/dist/distillation/errors.d.ts +0 -0
- package/dist/distillation/errors.js +0 -0
- package/dist/distillation/errors.js.map +0 -0
- package/dist/distillation/experience-family.d.ts +0 -0
- package/dist/distillation/experience-family.js +0 -0
- package/dist/distillation/experience-family.js.map +0 -0
- package/dist/distillation/host-llm.d.ts +0 -0
- package/dist/distillation/host-llm.js +0 -0
- package/dist/distillation/host-llm.js.map +0 -0
- package/dist/distillation/llm-distiller.d.ts +0 -0
- package/dist/distillation/llm-distiller.js +0 -0
- package/dist/distillation/llm-distiller.js.map +0 -0
- package/dist/distillation/merge-decider.d.ts +0 -0
- package/dist/distillation/merge-decider.js +0 -0
- package/dist/distillation/merge-decider.js.map +0 -0
- package/dist/distillation/model-catalog.d.ts +0 -0
- package/dist/distillation/model-catalog.js +0 -0
- package/dist/distillation/model-catalog.js.map +0 -0
- package/dist/distillation/prompt-contract.d.ts +1 -1
- package/dist/distillation/prompt-contract.js +3 -1
- package/dist/distillation/prompt-contract.js.map +1 -1
- package/dist/distillation/providers/anthropic.d.ts +0 -0
- package/dist/distillation/providers/anthropic.js +0 -0
- package/dist/distillation/providers/anthropic.js.map +0 -0
- package/dist/distillation/providers/azure-openai.d.ts +0 -0
- package/dist/distillation/providers/azure-openai.js +0 -0
- package/dist/distillation/providers/azure-openai.js.map +0 -0
- package/dist/distillation/providers/baidu-qianfan.d.ts +0 -0
- package/dist/distillation/providers/baidu-qianfan.js +0 -0
- package/dist/distillation/providers/baidu-qianfan.js.map +0 -0
- package/dist/distillation/providers/bedrock.d.ts +0 -0
- package/dist/distillation/providers/bedrock.js +0 -0
- package/dist/distillation/providers/bedrock.js.map +0 -0
- package/dist/distillation/providers/dashscope.d.ts +0 -0
- package/dist/distillation/providers/dashscope.js +0 -0
- package/dist/distillation/providers/dashscope.js.map +0 -0
- package/dist/distillation/providers/deepseek.d.ts +0 -0
- package/dist/distillation/providers/deepseek.js +0 -0
- package/dist/distillation/providers/deepseek.js.map +0 -0
- package/dist/distillation/providers/gemini.d.ts +0 -0
- package/dist/distillation/providers/gemini.js +5 -1
- package/dist/distillation/providers/gemini.js.map +1 -1
- package/dist/distillation/providers/google-adc.d.ts +0 -0
- package/dist/distillation/providers/google-adc.js +0 -0
- package/dist/distillation/providers/google-adc.js.map +0 -0
- package/dist/distillation/providers/minimax.d.ts +0 -0
- package/dist/distillation/providers/minimax.js +0 -0
- package/dist/distillation/providers/minimax.js.map +0 -0
- package/dist/distillation/providers/moonshot.d.ts +0 -0
- package/dist/distillation/providers/moonshot.js +0 -0
- package/dist/distillation/providers/moonshot.js.map +0 -0
- package/dist/distillation/providers/openai-compatible-factory.d.ts +0 -0
- package/dist/distillation/providers/openai-compatible-factory.js +0 -0
- package/dist/distillation/providers/openai-compatible-factory.js.map +0 -0
- package/dist/distillation/providers/openai-compatible.d.ts +0 -0
- package/dist/distillation/providers/openai-compatible.js +0 -0
- package/dist/distillation/providers/openai-compatible.js.map +0 -0
- package/dist/distillation/providers/openai.d.ts +0 -0
- package/dist/distillation/providers/openai.js +0 -0
- package/dist/distillation/providers/openai.js.map +0 -0
- package/dist/distillation/providers/openrouter.d.ts +0 -0
- package/dist/distillation/providers/openrouter.js +0 -0
- package/dist/distillation/providers/openrouter.js.map +0 -0
- package/dist/distillation/providers/registry.d.ts +0 -0
- package/dist/distillation/providers/registry.js +0 -0
- package/dist/distillation/providers/registry.js.map +0 -0
- package/dist/distillation/providers/siliconflow.d.ts +0 -0
- package/dist/distillation/providers/siliconflow.js +0 -0
- package/dist/distillation/providers/siliconflow.js.map +0 -0
- package/dist/distillation/providers/tencent-hunyuan.d.ts +0 -0
- package/dist/distillation/providers/tencent-hunyuan.js +0 -0
- package/dist/distillation/providers/tencent-hunyuan.js.map +0 -0
- package/dist/distillation/providers/types.d.ts +0 -0
- package/dist/distillation/providers/types.js +0 -0
- package/dist/distillation/providers/types.js.map +0 -0
- package/dist/distillation/providers/volcengine-ark.d.ts +0 -0
- package/dist/distillation/providers/volcengine-ark.js +0 -0
- package/dist/distillation/providers/volcengine-ark.js.map +0 -0
- package/dist/distillation/providers/zhipu.d.ts +0 -0
- package/dist/distillation/providers/zhipu.js +0 -0
- package/dist/distillation/providers/zhipu.js.map +0 -0
- package/dist/distillation/queue-worker.d.ts +0 -0
- package/dist/distillation/queue-worker.js +22 -3
- package/dist/distillation/queue-worker.js.map +1 -1
- package/dist/distillation/types.d.ts +0 -0
- package/dist/distillation/types.js +0 -0
- package/dist/distillation/types.js.map +0 -0
- package/dist/evaluation/benchmark-report.d.ts +0 -0
- package/dist/evaluation/benchmark-report.js +0 -0
- package/dist/evaluation/benchmark-report.js.map +0 -0
- package/dist/evaluation/benchmark-summary.d.ts +0 -0
- package/dist/evaluation/benchmark-summary.js +0 -0
- package/dist/evaluation/benchmark-summary.js.map +0 -0
- package/dist/evaluation/codex-lifecycle-validation.d.ts +60 -0
- package/dist/evaluation/codex-lifecycle-validation.js +233 -0
- package/dist/evaluation/codex-lifecycle-validation.js.map +1 -0
- package/dist/evaluation/hybrid-phase1-rollout-summary.d.ts +63 -0
- package/dist/evaluation/hybrid-phase1-rollout-summary.js +108 -0
- package/dist/evaluation/hybrid-phase1-rollout-summary.js.map +1 -0
- package/dist/evaluation/hybrid-phase3-gate-metrics.d.ts +26 -0
- package/dist/evaluation/hybrid-phase3-gate-metrics.js +23 -0
- package/dist/evaluation/hybrid-phase3-gate-metrics.js.map +1 -0
- package/dist/evaluation/openclaw-baseline.d.ts +8 -0
- package/dist/evaluation/openclaw-baseline.js +27 -0
- package/dist/evaluation/openclaw-baseline.js.map +1 -1
- package/dist/evaluation/openclaw-scenarios.d.ts +0 -0
- package/dist/evaluation/openclaw-scenarios.js +0 -0
- package/dist/evaluation/openclaw-scenarios.js.map +0 -0
- package/dist/experience-management/governance-observability.d.ts +13 -0
- package/dist/experience-management/governance-observability.js +37 -0
- package/dist/experience-management/governance-observability.js.map +1 -0
- package/dist/experience-management/node-lifecycle-governance.d.ts +8 -0
- package/dist/experience-management/node-lifecycle-governance.js +80 -0
- package/dist/experience-management/node-lifecycle-governance.js.map +1 -0
- package/dist/experience-management/task-management-signals.d.ts +29 -0
- package/dist/experience-management/task-management-signals.js +148 -0
- package/dist/experience-management/task-management-signals.js.map +1 -0
- package/dist/feedback/automatic-attribution.d.ts +0 -0
- package/dist/feedback/automatic-attribution.js +0 -0
- package/dist/feedback/automatic-attribution.js.map +0 -0
- package/dist/feedback/feedback-manager.d.ts +4 -1
- package/dist/feedback/feedback-manager.js +11 -22
- package/dist/feedback/feedback-manager.js.map +1 -1
- package/dist/feedback/harm-detector.d.ts +0 -0
- package/dist/feedback/harm-detector.js +0 -0
- package/dist/feedback/harm-detector.js.map +0 -0
- package/dist/feedback/state-transition.d.ts +6 -1
- package/dist/feedback/state-transition.js +6 -3
- package/dist/feedback/state-transition.js.map +1 -1
- package/dist/feedback/stats-updater.d.ts +0 -0
- package/dist/feedback/stats-updater.js +0 -0
- package/dist/feedback/stats-updater.js.map +0 -0
- package/dist/hybrid/capsule-builder.d.ts +23 -0
- package/dist/hybrid/capsule-builder.js +114 -0
- package/dist/hybrid/capsule-builder.js.map +1 -0
- package/dist/hybrid/explain-provider-client.d.ts +19 -0
- package/dist/hybrid/explain-provider-client.js +34 -0
- package/dist/hybrid/explain-provider-client.js.map +1 -0
- package/dist/hybrid/postmortem-provider-client.d.ts +19 -0
- package/dist/hybrid/postmortem-provider-client.js +34 -0
- package/dist/hybrid/postmortem-provider-client.js.map +1 -0
- package/dist/hybrid/rollout.d.ts +9 -0
- package/dist/hybrid/rollout.js +49 -0
- package/dist/hybrid/rollout.js.map +1 -0
- package/dist/hybrid/router.d.ts +4 -0
- package/dist/hybrid/router.js +62 -0
- package/dist/hybrid/router.js.map +1 -0
- package/dist/hybrid/types.d.ts +140 -0
- package/dist/hybrid/types.js +2 -0
- package/dist/hybrid/types.js.map +1 -0
- package/dist/hybrid/validators.d.ts +5 -0
- package/dist/hybrid/validators.js +94 -0
- package/dist/hybrid/validators.js.map +1 -0
- package/dist/hybrid/worker-client.d.ts +61 -0
- package/dist/hybrid/worker-client.js +196 -0
- package/dist/hybrid/worker-client.js.map +1 -0
- package/dist/hybrid/workers/explain-decision-llm.d.ts +8 -0
- package/dist/hybrid/workers/explain-decision-llm.js +152 -0
- package/dist/hybrid/workers/explain-decision-llm.js.map +1 -0
- package/dist/hybrid/workers/explain-decision.d.ts +2 -0
- package/dist/hybrid/workers/explain-decision.js +40 -0
- package/dist/hybrid/workers/explain-decision.js.map +1 -0
- package/dist/hybrid/workers/postmortem-review-llm.d.ts +8 -0
- package/dist/hybrid/workers/postmortem-review-llm.js +398 -0
- package/dist/hybrid/workers/postmortem-review-llm.js.map +1 -0
- package/dist/hybrid/workers/postmortem-review.d.ts +2 -0
- package/dist/hybrid/workers/postmortem-review.js +66 -0
- package/dist/hybrid/workers/postmortem-review.js.map +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/index.js.map +0 -0
- package/dist/input/context-summary-adapter.d.ts +0 -0
- package/dist/input/context-summary-adapter.js +0 -0
- package/dist/input/context-summary-adapter.js.map +0 -0
- package/dist/input/input-adapter.d.ts +0 -0
- package/dist/input/input-adapter.js +0 -0
- package/dist/input/input-adapter.js.map +0 -0
- package/dist/input/outcome-resolver.d.ts +0 -0
- package/dist/input/outcome-resolver.js +0 -0
- package/dist/input/outcome-resolver.js.map +0 -0
- package/dist/input/scope-resolver.d.ts +0 -0
- package/dist/input/scope-resolver.js +0 -0
- package/dist/input/scope-resolver.js.map +0 -0
- package/dist/input/tasktype-resolver.d.ts +0 -0
- package/dist/input/tasktype-resolver.js +0 -0
- package/dist/input/tasktype-resolver.js.map +0 -0
- package/dist/input/tool-event-significance.d.ts +0 -0
- package/dist/input/tool-event-significance.js +0 -0
- package/dist/input/tool-event-significance.js.map +0 -0
- package/dist/install/claude-cli.d.ts +0 -0
- package/dist/install/claude-cli.js +0 -0
- package/dist/install/claude-cli.js.map +0 -0
- package/dist/install/claude-code-doctor.d.ts +1 -0
- package/dist/install/claude-code-doctor.js +20 -4
- package/dist/install/claude-code-doctor.js.map +1 -1
- package/dist/install/claude-code-installer.d.ts +0 -0
- package/dist/install/claude-code-installer.js +50 -1
- package/dist/install/claude-code-installer.js.map +1 -1
- package/dist/install/claude-marketplace-state.d.ts +0 -0
- package/dist/install/claude-marketplace-state.js +0 -0
- package/dist/install/claude-marketplace-state.js.map +0 -0
- package/dist/install/claude-runtime-target.d.ts +0 -0
- package/dist/install/claude-runtime-target.js +0 -0
- package/dist/install/claude-runtime-target.js.map +0 -0
- package/dist/install/codex-cli.d.ts +15 -0
- package/dist/install/codex-cli.js +55 -3
- package/dist/install/codex-cli.js.map +1 -1
- package/dist/install/codex-installer.d.ts +0 -0
- package/dist/install/codex-installer.js +0 -0
- package/dist/install/codex-installer.js.map +0 -0
- package/dist/install/codex-runtime-target.d.ts +0 -0
- package/dist/install/codex-runtime-target.js +0 -0
- package/dist/install/codex-runtime-target.js.map +0 -0
- package/dist/install/host-detection.d.ts +0 -0
- package/dist/install/host-detection.js +0 -0
- package/dist/install/host-detection.js.map +0 -0
- package/dist/install/openclaw-cli.d.ts +11 -0
- package/dist/install/openclaw-cli.js +0 -0
- package/dist/install/openclaw-cli.js.map +1 -1
- package/dist/install/openclaw-installer.d.ts +12 -7
- package/dist/install/openclaw-installer.js +197 -46
- package/dist/install/openclaw-installer.js.map +1 -1
- package/dist/install/public-install.d.ts +0 -0
- package/dist/install/public-install.js +0 -0
- package/dist/install/public-install.js.map +0 -0
- package/dist/install/registry-health.d.ts +0 -0
- package/dist/install/registry-health.js +0 -0
- package/dist/install/registry-health.js.map +0 -0
- package/dist/interaction/operational-actions-service.d.ts +0 -0
- package/dist/interaction/operational-actions-service.js +0 -0
- package/dist/interaction/operational-actions-service.js.map +0 -0
- package/dist/interaction/operational-service.d.ts +0 -0
- package/dist/interaction/operational-service.js +0 -0
- package/dist/interaction/operational-service.js.map +0 -0
- package/dist/interaction/repo-summary.d.ts +0 -0
- package/dist/interaction/repo-summary.js +0 -0
- package/dist/interaction/repo-summary.js.map +0 -0
- package/dist/interaction/service.d.ts +15 -0
- package/dist/interaction/service.js +174 -20
- package/dist/interaction/service.js.map +1 -1
- package/dist/interaction/state-artifact-service.d.ts +0 -0
- package/dist/interaction/state-artifact-service.js +0 -0
- package/dist/interaction/state-artifact-service.js.map +0 -0
- package/dist/maintenance/claude-validate-print.d.ts +0 -0
- package/dist/maintenance/claude-validate-print.js +0 -0
- package/dist/maintenance/claude-validate-print.js.map +0 -0
- package/dist/maintenance/embedding-smoke.d.ts +0 -0
- package/dist/maintenance/embedding-smoke.js +0 -0
- package/dist/maintenance/embedding-smoke.js.map +0 -0
- package/dist/maintenance/redistill-rule-nodes.d.ts +0 -0
- package/dist/maintenance/redistill-rule-nodes.js +0 -0
- package/dist/maintenance/redistill-rule-nodes.js.map +0 -0
- package/dist/maintenance/scope-merge.d.ts +0 -0
- package/dist/maintenance/scope-merge.js +0 -0
- package/dist/maintenance/scope-merge.js.map +0 -0
- package/dist/maintenance/warning-variant-cleanup.d.ts +0 -0
- package/dist/maintenance/warning-variant-cleanup.js +0 -0
- package/dist/maintenance/warning-variant-cleanup.js.map +0 -0
- package/dist/plugin/fixture-sanitizer.d.ts +0 -0
- package/dist/plugin/fixture-sanitizer.js +0 -0
- package/dist/plugin/fixture-sanitizer.js.map +0 -0
- package/dist/plugin/hooks/before-prompt-build.d.ts +1 -0
- package/dist/plugin/hooks/before-prompt-build.js +4 -1
- package/dist/plugin/hooks/before-prompt-build.js.map +1 -1
- package/dist/plugin/hooks/message-sent.d.ts +0 -0
- package/dist/plugin/hooks/message-sent.js +0 -0
- package/dist/plugin/hooks/message-sent.js.map +0 -0
- package/dist/plugin/hooks/tool-result-persist.d.ts +0 -0
- package/dist/plugin/hooks/tool-result-persist.js +0 -0
- package/dist/plugin/hooks/tool-result-persist.js.map +0 -0
- package/dist/plugin/openclaw-install-state.d.ts +39 -0
- package/dist/plugin/openclaw-install-state.js +24 -0
- package/dist/plugin/openclaw-install-state.js.map +1 -0
- package/dist/plugin/openclaw-plugin.d.ts +125 -0
- package/dist/plugin/openclaw-plugin.js +18 -7
- package/dist/plugin/openclaw-plugin.js.map +1 -1
- package/dist/plugin/openclaw-routine-interaction.d.ts +2 -1
- package/dist/plugin/openclaw-routine-interaction.js +12 -7
- package/dist/plugin/openclaw-routine-interaction.js.map +1 -1
- package/dist/plugin/openclaw-runtime-defaults.d.ts +16 -0
- package/dist/plugin/openclaw-runtime-defaults.js +16 -0
- package/dist/plugin/openclaw-runtime-defaults.js.map +1 -0
- package/dist/plugin/runtime-capture.d.ts +0 -0
- package/dist/plugin/runtime-capture.js +0 -0
- package/dist/plugin/runtime-capture.js.map +0 -0
- package/dist/plugin/runtime-helpers.d.ts +0 -0
- package/dist/plugin/runtime-helpers.js +0 -0
- package/dist/plugin/runtime-helpers.js.map +0 -0
- package/dist/runtime/service.d.ts +33 -5
- package/dist/runtime/service.js +408 -22
- package/dist/runtime/service.js.map +1 -1
- package/dist/store/logs/jsonl-logger.d.ts +0 -0
- package/dist/store/logs/jsonl-logger.js +0 -0
- package/dist/store/logs/jsonl-logger.js.map +0 -0
- package/dist/store/sqlite/db.d.ts +0 -0
- package/dist/store/sqlite/db.js +28 -0
- package/dist/store/sqlite/db.js.map +1 -1
- package/dist/store/sqlite/migrations.d.ts +0 -0
- package/dist/store/sqlite/migrations.js +0 -0
- package/dist/store/sqlite/migrations.js.map +0 -0
- package/dist/store/sqlite/repositories/candidate-repo.d.ts +0 -0
- package/dist/store/sqlite/repositories/candidate-repo.js +0 -0
- package/dist/store/sqlite/repositories/candidate-repo.js.map +0 -0
- package/dist/store/sqlite/repositories/distillation-job-repo.d.ts +0 -0
- package/dist/store/sqlite/repositories/distillation-job-repo.js +0 -0
- package/dist/store/sqlite/repositories/distillation-job-repo.js.map +0 -0
- package/dist/store/sqlite/repositories/hybrid-invocation-trace-repo.d.ts +11 -0
- package/dist/store/sqlite/repositories/hybrid-invocation-trace-repo.js +76 -0
- package/dist/store/sqlite/repositories/hybrid-invocation-trace-repo.js.map +1 -0
- package/dist/store/sqlite/repositories/hybrid-review-artifact-repo.d.ts +11 -0
- package/dist/store/sqlite/repositories/hybrid-review-artifact-repo.js +73 -0
- package/dist/store/sqlite/repositories/hybrid-review-artifact-repo.js.map +1 -0
- package/dist/store/sqlite/repositories/injection-repo.d.ts +0 -0
- package/dist/store/sqlite/repositories/injection-repo.js +0 -0
- package/dist/store/sqlite/repositories/injection-repo.js.map +0 -0
- package/dist/store/sqlite/repositories/input-record-repo.d.ts +1 -0
- package/dist/store/sqlite/repositories/input-record-repo.js +13 -0
- package/dist/store/sqlite/repositories/input-record-repo.js.map +1 -1
- package/dist/store/sqlite/repositories/node-repo.d.ts +3 -0
- package/dist/store/sqlite/repositories/node-repo.js +45 -6
- package/dist/store/sqlite/repositories/node-repo.js.map +1 -1
- package/dist/store/sqlite/repositories/outcome-record-repo.d.ts +0 -0
- package/dist/store/sqlite/repositories/outcome-record-repo.js +0 -0
- package/dist/store/sqlite/repositories/outcome-record-repo.js.map +0 -0
- package/dist/store/sqlite/repositories/review-event-repo.d.ts +0 -0
- package/dist/store/sqlite/repositories/review-event-repo.js +0 -0
- package/dist/store/sqlite/repositories/review-event-repo.js.map +0 -0
- package/dist/store/sqlite/repositories/scope-repo.d.ts +0 -0
- package/dist/store/sqlite/repositories/scope-repo.js +0 -0
- package/dist/store/sqlite/repositories/scope-repo.js.map +0 -0
- package/dist/store/sqlite/repositories/stats-repo.d.ts +0 -0
- package/dist/store/sqlite/repositories/stats-repo.js +0 -0
- package/dist/store/sqlite/repositories/stats-repo.js.map +0 -0
- package/dist/store/sqlite/repositories/task-run-repo.d.ts +0 -0
- package/dist/store/sqlite/repositories/task-run-repo.js +0 -0
- package/dist/store/sqlite/repositories/task-run-repo.js.map +0 -0
- package/dist/store/sqlite/schema.sql +40 -0
- package/dist/store/vector/api-embedding-provider.d.ts +0 -0
- package/dist/store/vector/api-embedding-provider.js +0 -0
- package/dist/store/vector/api-embedding-provider.js.map +0 -0
- package/dist/store/vector/embeddings.d.ts +0 -0
- package/dist/store/vector/embeddings.js +26 -8
- package/dist/store/vector/embeddings.js.map +1 -1
- package/dist/store/vector/lancedb.d.ts +0 -0
- package/dist/store/vector/lancedb.js +0 -0
- package/dist/store/vector/lancedb.js.map +0 -0
- package/dist/store/vector/local-provider.d.ts +0 -0
- package/dist/store/vector/local-provider.js +0 -0
- package/dist/store/vector/local-provider.js.map +0 -0
- package/dist/store/vector/node-index.d.ts +0 -0
- package/dist/store/vector/node-index.js +0 -0
- package/dist/store/vector/node-index.js.map +0 -0
- package/dist/store/vector/provider-types.d.ts +0 -0
- package/dist/store/vector/provider-types.js +0 -0
- package/dist/store/vector/provider-types.js.map +0 -0
- package/dist/types/analyzer.d.ts +0 -0
- package/dist/types/analyzer.js +0 -0
- package/dist/types/analyzer.js.map +0 -0
- package/dist/types/domain.d.ts +136 -1
- package/dist/types/domain.js +0 -0
- package/dist/types/domain.js.map +0 -0
- package/dist/types/plugin.d.ts +2 -1
- package/dist/types/plugin.js +0 -0
- package/dist/types/plugin.js.map +0 -0
- package/dist/types/storage.d.ts +0 -0
- package/dist/types/storage.js +0 -0
- package/dist/types/storage.js.map +0 -0
- package/dist/utils/clock.d.ts +0 -0
- package/dist/utils/clock.js +0 -0
- package/dist/utils/clock.js.map +0 -0
- package/dist/utils/errors.d.ts +0 -0
- package/dist/utils/errors.js +0 -0
- package/dist/utils/errors.js.map +0 -0
- package/dist/utils/hashing.d.ts +0 -0
- package/dist/utils/hashing.js +0 -0
- package/dist/utils/hashing.js.map +0 -0
- package/dist/utils/ids.d.ts +0 -0
- package/dist/utils/ids.js +0 -0
- package/dist/utils/ids.js.map +0 -0
- package/dist/utils/text.d.ts +0 -0
- package/dist/utils/text.js +0 -0
- package/dist/utils/text.js.map +0 -0
- package/dist/version/package-version.d.ts +0 -0
- package/dist/version/package-version.js +0 -0
- package/dist/version/package-version.js.map +0 -0
- package/dist/version/remote-release.d.ts +0 -0
- package/dist/version/remote-release.js +0 -0
- package/dist/version/remote-release.js.map +0 -0
- package/docs/releases/v0.1.0.md +0 -0
- package/docs/releases/v0.1.1.md +0 -0
- package/docs/releases/v0.1.2.md +0 -0
- package/docs/releases/v0.1.3.md +3 -2
- package/docs/releases/v0.2.0.md +85 -0
- package/docs/user-guide.md +39 -12
- package/hooks/hooks.json +0 -0
- package/openclaw.plugin.json +81 -1
- package/package.json +23 -15
- package/plugins/claude-code-experienceengine/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code-experienceengine/.mcp.json +0 -0
- package/plugins/claude-code-experienceengine/hooks/hooks.json +0 -0
- package/plugins/claude-code-experienceengine/scripts/claude-hook.sh +0 -0
- package/plugins/claude-code-experienceengine/scripts/install-deps.sh +1 -1
- package/scripts/claude-plugin/claude-hook.sh +0 -0
- package/scripts/claude-plugin/install-deps.sh +0 -0
package/dist/runtime/service.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LlmLearningGate } from "../analyzer/llm-learning-gate.js";
|
|
2
1
|
import { buildCandidateSignals } from "../analyzer/candidate-signals.js";
|
|
3
2
|
import { buildInjectionScorecard } from "../controller/injection-scorecard.js";
|
|
4
3
|
import { classifyFailureAttributionReason } from "../feedback/automatic-attribution.js";
|
|
@@ -6,13 +5,16 @@ import { applyFeedback } from "../feedback/feedback-manager.js";
|
|
|
6
5
|
import { detectHarm } from "../feedback/harm-detector.js";
|
|
7
6
|
import { createEmptyStats, updateStats } from "../feedback/stats-updater.js";
|
|
8
7
|
import { buildExperienceInput } from "../input/input-adapter.js";
|
|
8
|
+
import { buildRetrievalContext } from "../controller/retrieval-context.js";
|
|
9
9
|
import { resolveScope } from "../input/scope-resolver.js";
|
|
10
10
|
import { decideIntervention } from "../controller/intervention-controller.js";
|
|
11
11
|
import { renderInlineNotice } from "../controller/inline-notice.js";
|
|
12
|
+
import { applyGovernedNodeFeedback, deriveNodeOriginProfileForNode } from "../experience-management/node-lifecycle-governance.js";
|
|
13
|
+
import { resolveHybridRolloutState } from "../hybrid/rollout.js";
|
|
14
|
+
import { selectHybridRoute } from "../hybrid/router.js";
|
|
12
15
|
import { nowIso } from "../utils/clock.js";
|
|
13
16
|
import { createId, stableId } from "../utils/ids.js";
|
|
14
17
|
import { bootstrapDatabase, openDatabase, withTransaction } from "../store/sqlite/db.js";
|
|
15
|
-
import { DistillationQueueWorker } from "../distillation/queue-worker.js";
|
|
16
18
|
import { CandidateRepository } from "../store/sqlite/repositories/candidate-repo.js";
|
|
17
19
|
import { DistillationJobRepository } from "../store/sqlite/repositories/distillation-job-repo.js";
|
|
18
20
|
import { InputRecordRepository } from "../store/sqlite/repositories/input-record-repo.js";
|
|
@@ -23,9 +25,16 @@ import { ScopeRepository } from "../store/sqlite/repositories/scope-repo.js";
|
|
|
23
25
|
import { StatsRepository } from "../store/sqlite/repositories/stats-repo.js";
|
|
24
26
|
import { TaskRunRepository } from "../store/sqlite/repositories/task-run-repo.js";
|
|
25
27
|
import { InjectionRepository } from "../store/sqlite/repositories/injection-repo.js";
|
|
28
|
+
import { HybridInvocationTraceRepository } from "../store/sqlite/repositories/hybrid-invocation-trace-repo.js";
|
|
26
29
|
import { RuntimeCaptureWriter } from "../plugin/runtime-capture.js";
|
|
27
30
|
import { normalizeToolResult } from "../plugin/hooks/tool-result-persist.js";
|
|
28
31
|
import { extractToolResultsFromPayload } from "../plugin/runtime-helpers.js";
|
|
32
|
+
import { HybridReviewArtifactRepository } from "../store/sqlite/repositories/hybrid-review-artifact-repo.js";
|
|
33
|
+
const loadLlmLearningGate = async () => import("../analyzer/llm-learning-gate.js");
|
|
34
|
+
const loadDistillationQueueWorker = async () => import("../distillation/queue-worker.js");
|
|
35
|
+
const loadHybridWorkerClientModule = async () => import("../hybrid/worker-client.js");
|
|
36
|
+
const loadHybridCapsuleBuilder = async () => import("../hybrid/capsule-builder.js");
|
|
37
|
+
const loadHybridPostmortemProviderClient = async () => import("../hybrid/postmortem-provider-client.js");
|
|
29
38
|
const toEvidence = (input) => input.tool_events.map((event) => [event.tool_name, event.status, event.error_signature ?? event.output_summary]
|
|
30
39
|
.filter(Boolean)
|
|
31
40
|
.join(": "));
|
|
@@ -82,9 +91,57 @@ const buildCandidateSourceSignal = (input) => {
|
|
|
82
91
|
failure_signature: signals.failure_signature,
|
|
83
92
|
retry_count: signals.retry_count,
|
|
84
93
|
correction_signals: signals.correction_signals,
|
|
94
|
+
directional_correction: signals.directional_correction,
|
|
95
|
+
evidence_driven_reversal: signals.evidence_driven_reversal,
|
|
85
96
|
tool_event_summary: signals.tool_event_summary
|
|
86
97
|
};
|
|
87
98
|
};
|
|
99
|
+
const mergeDirectionalCorrectionIntoSourceSignal = (sourceSignal, draft) => {
|
|
100
|
+
const directionalCorrection = sourceSignal.directional_correction;
|
|
101
|
+
if (!directionalCorrection) {
|
|
102
|
+
return sourceSignal;
|
|
103
|
+
}
|
|
104
|
+
const semanticDetected = Boolean(draft.experience_kind === "expectation_correction" &&
|
|
105
|
+
draft.correction_category &&
|
|
106
|
+
draft.deviation_pattern &&
|
|
107
|
+
draft.corrected_constraint);
|
|
108
|
+
if (!semanticDetected) {
|
|
109
|
+
return sourceSignal;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
...sourceSignal,
|
|
113
|
+
directional_correction: {
|
|
114
|
+
...directionalCorrection,
|
|
115
|
+
semantic_detected: true,
|
|
116
|
+
correction_category: draft.correction_category,
|
|
117
|
+
deviation_pattern: draft.deviation_pattern,
|
|
118
|
+
corrected_constraint: draft.corrected_constraint
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
const mergeEvidenceDrivenReversalIntoSourceSignal = (sourceSignal, draft) => {
|
|
123
|
+
const reversal = sourceSignal.evidence_driven_reversal;
|
|
124
|
+
if (!reversal) {
|
|
125
|
+
return sourceSignal;
|
|
126
|
+
}
|
|
127
|
+
const semanticDetected = Boolean(draft.experience_kind === "expectation_correction" &&
|
|
128
|
+
draft.correction_category &&
|
|
129
|
+
draft.deviation_pattern &&
|
|
130
|
+
draft.corrected_constraint);
|
|
131
|
+
if (!semanticDetected) {
|
|
132
|
+
return sourceSignal;
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
...sourceSignal,
|
|
136
|
+
evidence_driven_reversal: {
|
|
137
|
+
...reversal,
|
|
138
|
+
semantic_detected: true,
|
|
139
|
+
correction_category: draft.correction_category,
|
|
140
|
+
deviation_pattern: draft.deviation_pattern,
|
|
141
|
+
corrected_constraint: draft.corrected_constraint
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
};
|
|
88
145
|
const summarizeRawCandidate = (sourceSignal) => {
|
|
89
146
|
const fragments = [...sourceSignal.tool_event_summary];
|
|
90
147
|
if (sourceSignal.failure_signature) {
|
|
@@ -104,9 +161,14 @@ const resolveCandidateKind = (input, sourceSignal) => {
|
|
|
104
161
|
}
|
|
105
162
|
return "failure";
|
|
106
163
|
};
|
|
107
|
-
const draftToCandidate = (draft, input, originRecordId, taskRunId) => {
|
|
164
|
+
const draftToCandidate = (draft, input, originRecordId, taskRunId, directionalCorrectionSignal, evidenceDrivenReversalSignal) => {
|
|
108
165
|
const timestamp = nowIso();
|
|
109
|
-
const
|
|
166
|
+
const baseSourceSignal = buildCandidateSourceSignal(input);
|
|
167
|
+
const sourceSignal = mergeEvidenceDrivenReversalIntoSourceSignal(mergeDirectionalCorrectionIntoSourceSignal({
|
|
168
|
+
...baseSourceSignal,
|
|
169
|
+
directional_correction: directionalCorrectionSignal ?? baseSourceSignal.directional_correction,
|
|
170
|
+
evidence_driven_reversal: evidenceDrivenReversalSignal ?? baseSourceSignal.evidence_driven_reversal
|
|
171
|
+
}, draft), draft);
|
|
110
172
|
const candidateId = stableId("candidate", [draft.scope_id, draft.task_type, draft.node_type, draft.compact_hint, originRecordId].join(":"));
|
|
111
173
|
return {
|
|
112
174
|
id: candidateId,
|
|
@@ -138,6 +200,7 @@ const candidateToInitialJob = (candidate, extractorProfile) => {
|
|
|
138
200
|
};
|
|
139
201
|
};
|
|
140
202
|
const mergeContext = (existing, incoming) => ({
|
|
203
|
+
host: incoming.host ?? existing?.host,
|
|
141
204
|
sessionId: incoming.sessionId ?? existing?.sessionId,
|
|
142
205
|
cwd: incoming.cwd ?? existing?.cwd,
|
|
143
206
|
userMessage: incoming.userMessage || existing?.userMessage || "",
|
|
@@ -186,6 +249,23 @@ const resolveDeliveryMode = (evaluationMode, holdoutRate, sessionId, taskSummary
|
|
|
186
249
|
delivered: true
|
|
187
250
|
};
|
|
188
251
|
};
|
|
252
|
+
const HYBRID_LIGHTWEIGHT_PATTERN = /\b(wording-only|wording only|copy-only|copy only|copy pass|inline notice wording|expression-layer refinement)\b/i;
|
|
253
|
+
const isLightweightHybridExcludedTask = (input) => HYBRID_LIGHTWEIGHT_PATTERN.test(`${input.task_summary} ${input.context_summary ?? ""}`);
|
|
254
|
+
export const decidePosttaskHybridRoute = (config, input, signals, rolloutKey = input.task_summary) => {
|
|
255
|
+
const rollout = resolveHybridRolloutState(config, rolloutKey);
|
|
256
|
+
return selectHybridRoute({
|
|
257
|
+
...signals,
|
|
258
|
+
explicitExplanationRequest: false,
|
|
259
|
+
existingConservativePathRequired: false,
|
|
260
|
+
lightweightOrExcludedTask: signals.lightweightOrExcludedTask || isLightweightHybridExcludedTask(input),
|
|
261
|
+
rolloutAllowsAsyncPostmortem: config.hybridAsyncPostmortemEnabled && rollout.hybridActive
|
|
262
|
+
}, {
|
|
263
|
+
enabled: config.hybridEnabled && rollout.hybridActive,
|
|
264
|
+
syncExplainEnabled: false,
|
|
265
|
+
asyncPostmortemEnabled: config.hybridAsyncPostmortemEnabled && rollout.hybridActive,
|
|
266
|
+
policyVersion: config.hybridRoutePolicyVersion
|
|
267
|
+
});
|
|
268
|
+
};
|
|
189
269
|
export class ExperienceRuntimeService {
|
|
190
270
|
config;
|
|
191
271
|
db;
|
|
@@ -202,12 +282,21 @@ export class ExperienceRuntimeService {
|
|
|
202
282
|
reviewEventRepo;
|
|
203
283
|
statsRepo;
|
|
204
284
|
injectionRepo;
|
|
205
|
-
|
|
206
|
-
|
|
285
|
+
hybridReviewArtifactRepo;
|
|
286
|
+
hybridTraceRepo;
|
|
287
|
+
runtimeOptions;
|
|
288
|
+
backgroundLearningEnabled;
|
|
289
|
+
hybridPosttaskEnabled;
|
|
290
|
+
distillationWorkerPromise;
|
|
291
|
+
learningGatePromise;
|
|
292
|
+
hybridWorkerClientPromise;
|
|
207
293
|
pendingLearningTasks = new Set();
|
|
208
294
|
captureWriter;
|
|
209
295
|
constructor(config, logger, runtimeOptions = {}) {
|
|
210
296
|
this.config = config;
|
|
297
|
+
this.runtimeOptions = runtimeOptions;
|
|
298
|
+
this.backgroundLearningEnabled = !runtimeOptions.disableBackgroundLearning;
|
|
299
|
+
this.hybridPosttaskEnabled = !runtimeOptions.disableHybridPosttask;
|
|
211
300
|
this.logger = logger ?? {};
|
|
212
301
|
this.db = openDatabase(config);
|
|
213
302
|
bootstrapDatabase(this.db);
|
|
@@ -221,8 +310,8 @@ export class ExperienceRuntimeService {
|
|
|
221
310
|
this.reviewEventRepo = new ReviewEventRepository(this.db);
|
|
222
311
|
this.statsRepo = new StatsRepository(this.db);
|
|
223
312
|
this.injectionRepo = new InjectionRepository(this.db);
|
|
224
|
-
this.
|
|
225
|
-
this.
|
|
313
|
+
this.hybridReviewArtifactRepo = new HybridReviewArtifactRepository(this.db);
|
|
314
|
+
this.hybridTraceRepo = new HybridInvocationTraceRepository(this.db);
|
|
226
315
|
this.captureWriter = new RuntimeCaptureWriter(config, this.logger);
|
|
227
316
|
}
|
|
228
317
|
getSession(sessionId) {
|
|
@@ -247,8 +336,9 @@ export class ExperienceRuntimeService {
|
|
|
247
336
|
session.toolEventKeys.add(key);
|
|
248
337
|
session.toolEvents.push(toolEvent);
|
|
249
338
|
}
|
|
250
|
-
|
|
251
|
-
|
|
339
|
+
// The shipped runtime path stays exact-scope-only in this rollout.
|
|
340
|
+
resolveExactScopeInjectableNodes(scopeId) {
|
|
341
|
+
return this.nodeRepo.listLiveInjectableByExactScope(scopeId);
|
|
252
342
|
}
|
|
253
343
|
recoverToolEvents(sessionId, payload) {
|
|
254
344
|
for (const toolResult of extractToolResultsFromPayload(payload)) {
|
|
@@ -301,8 +391,245 @@ export class ExperienceRuntimeService {
|
|
|
301
391
|
async waitForBackgroundLearning() {
|
|
302
392
|
await Promise.allSettled([...this.pendingLearningTasks]);
|
|
303
393
|
}
|
|
394
|
+
async getLearningGate() {
|
|
395
|
+
if (!this.backgroundLearningEnabled) {
|
|
396
|
+
return undefined;
|
|
397
|
+
}
|
|
398
|
+
this.learningGatePromise ??= loadLlmLearningGate().then(({ LlmLearningGate: LoadedLlmLearningGate }) => new LoadedLlmLearningGate(this.config, this.runtimeOptions));
|
|
399
|
+
return this.learningGatePromise;
|
|
400
|
+
}
|
|
401
|
+
async getDistillationWorker() {
|
|
402
|
+
if (!this.backgroundLearningEnabled) {
|
|
403
|
+
return undefined;
|
|
404
|
+
}
|
|
405
|
+
this.distillationWorkerPromise ??= loadDistillationQueueWorker().then(({ DistillationQueueWorker: LoadedDistillationQueueWorker }) => new LoadedDistillationQueueWorker(this.config, this.candidateRepo, this.jobRepo, this.nodeRepo, this.runtimeOptions));
|
|
406
|
+
return this.distillationWorkerPromise;
|
|
407
|
+
}
|
|
408
|
+
async getHybridWorkerClient() {
|
|
409
|
+
if (!this.hybridPosttaskEnabled) {
|
|
410
|
+
return undefined;
|
|
411
|
+
}
|
|
412
|
+
this.hybridWorkerClientPromise ??= loadHybridWorkerClientModule().then(({ HybridWorkerClient: LoadedHybridWorkerClient }) => new LoadedHybridWorkerClient({
|
|
413
|
+
explainDecisionEnabled: this.config.hybridEnabled && this.config.hybridSyncExplainEnabled,
|
|
414
|
+
postmortemReviewEnabled: this.config.hybridEnabled && this.config.hybridAsyncPostmortemEnabled,
|
|
415
|
+
postmortemReviewLlmEnabled: this.config.hybridEnabled
|
|
416
|
+
&& this.config.hybridAsyncPostmortemEnabled
|
|
417
|
+
&& this.config.hybridAsyncPostmortemLlmEnabled,
|
|
418
|
+
...this.runtimeOptions.hybridWorkerClientOptions
|
|
419
|
+
}));
|
|
420
|
+
return this.hybridWorkerClientPromise;
|
|
421
|
+
}
|
|
422
|
+
buildPostmortemArtifact(input) {
|
|
423
|
+
const timestamp = nowIso();
|
|
424
|
+
return {
|
|
425
|
+
id: createId("hybridreview"),
|
|
426
|
+
task_run_id: input.taskRun.id,
|
|
427
|
+
scope_id: input.taskRun.scope_id,
|
|
428
|
+
worker_task: "postmortem_review",
|
|
429
|
+
approval_class: input.result.approvalClass === "policy_gated" ? "policy_gated" : "review_artifact",
|
|
430
|
+
schema_version: this.config.hybridCapsuleSchemaVersion,
|
|
431
|
+
route_policy_version: input.routeDecision.policyVersion,
|
|
432
|
+
worker_profile_version: this.config.hybridPostmortemReviewProfileVersion,
|
|
433
|
+
recommendation: input.result.value.candidate_recommendation,
|
|
434
|
+
summary: input.result.value.review_artifact?.summary ?? input.result.value.reason,
|
|
435
|
+
payload: input.result.value,
|
|
436
|
+
created_at: timestamp,
|
|
437
|
+
updated_at: timestamp
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
applyPostmortemDeliveryRecommendation(node, recommendation) {
|
|
441
|
+
if (recommendation === "keep" || recommendation === "review") {
|
|
442
|
+
return node;
|
|
443
|
+
}
|
|
444
|
+
if (recommendation === "quarantine") {
|
|
445
|
+
return {
|
|
446
|
+
...node,
|
|
447
|
+
delivery_state: "quarantined",
|
|
448
|
+
quarantined_at: node.quarantined_at ?? nowIso(),
|
|
449
|
+
quarantine_reason: node.quarantine_reason ?? "postmortem_review"
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
if (node.delivery_state === "quarantined") {
|
|
453
|
+
return node;
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
...node,
|
|
457
|
+
delivery_state: node.delivery_state === "shadow_only" ? "shadow_only" : "conservative_only"
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
applyAcceptedPostmortemNodeReviews(input) {
|
|
461
|
+
const reviews = input.result.value.injected_node_reviews ?? [];
|
|
462
|
+
if (!reviews.length || input.taskRun.final_status === "cancelled") {
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
const allowedIds = new Set(input.experienceInput.injected_node_ids);
|
|
466
|
+
const existingEvents = this.reviewEventRepo.listByTaskRunId(input.taskRun.id);
|
|
467
|
+
let applied = false;
|
|
468
|
+
for (const review of reviews) {
|
|
469
|
+
if (!allowedIds.has(review.node_id) || review.confidence === "low") {
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
const current = this.nodeRepo.getById(review.node_id);
|
|
473
|
+
if (!current) {
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
const existingNodeEvents = existingEvents.filter((event) => event.node_id === review.node_id && event.source === "automatic");
|
|
477
|
+
const alreadyMarkedHelped = existingNodeEvents.some((event) => event.event_type === "mark_helped");
|
|
478
|
+
const alreadyMarkedHarmed = existingNodeEvents.some((event) => event.event_type === "mark_harmed");
|
|
479
|
+
let nextNode = current;
|
|
480
|
+
let feedbackEventType;
|
|
481
|
+
if (review.feedback_verdict === "helped" && !alreadyMarkedHelped) {
|
|
482
|
+
nextNode = applyGovernedNodeFeedback(nextNode, "helped", deriveNodeOriginProfileForNode(this.inputRepo, nextNode));
|
|
483
|
+
feedbackEventType = "mark_helped";
|
|
484
|
+
}
|
|
485
|
+
else if (review.feedback_verdict === "harmed" && !alreadyMarkedHarmed) {
|
|
486
|
+
nextNode = applyGovernedNodeFeedback(nextNode, "harmed", deriveNodeOriginProfileForNode(this.inputRepo, nextNode));
|
|
487
|
+
feedbackEventType = "mark_harmed";
|
|
488
|
+
}
|
|
489
|
+
const nodeAfterDelivery = this.applyPostmortemDeliveryRecommendation(nextNode, review.delivery_recommendation);
|
|
490
|
+
if (feedbackEventType
|
|
491
|
+
|| nodeAfterDelivery.delivery_state !== current.delivery_state
|
|
492
|
+
|| nodeAfterDelivery.state !== current.state
|
|
493
|
+
|| nodeAfterDelivery.helped_count !== current.helped_count
|
|
494
|
+
|| nodeAfterDelivery.harmed_count !== current.harmed_count
|
|
495
|
+
|| nodeAfterDelivery.last_feedback_verdict !== current.last_feedback_verdict) {
|
|
496
|
+
this.nodeRepo.upsert(nodeAfterDelivery);
|
|
497
|
+
applied = true;
|
|
498
|
+
}
|
|
499
|
+
if (feedbackEventType) {
|
|
500
|
+
this.reviewEventRepo.upsert({
|
|
501
|
+
id: createId("review"),
|
|
502
|
+
node_id: review.node_id,
|
|
503
|
+
task_run_id: input.taskRun.id,
|
|
504
|
+
event_type: feedbackEventType,
|
|
505
|
+
source: "automatic",
|
|
506
|
+
created_at: nowIso()
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
if (current.delivery_state !== "quarantined" && nodeAfterDelivery.delivery_state === "quarantined") {
|
|
510
|
+
this.reviewEventRepo.upsert({
|
|
511
|
+
id: createId("review"),
|
|
512
|
+
node_id: review.node_id,
|
|
513
|
+
task_run_id: input.taskRun.id,
|
|
514
|
+
event_type: "quarantine",
|
|
515
|
+
source: "automatic",
|
|
516
|
+
created_at: nowIso()
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return applied;
|
|
521
|
+
}
|
|
522
|
+
async persistHybridPostmortemArtifactAsync(input) {
|
|
523
|
+
if (!this.hybridPosttaskEnabled) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (this.hybridReviewArtifactRepo.getByTaskRunId(input.taskRun.id)) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const hybridWorkerClient = await this.getHybridWorkerClient();
|
|
530
|
+
if (!hybridWorkerClient) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const candidateSignals = buildCandidateSignals(input.experienceInput);
|
|
534
|
+
const [{ buildPostmortemReviewCapsule }, { resolveHybridPostmortemProviderEndpoint }] = await Promise.all([
|
|
535
|
+
loadHybridCapsuleBuilder(),
|
|
536
|
+
loadHybridPostmortemProviderClient()
|
|
537
|
+
]);
|
|
538
|
+
const capsule = buildPostmortemReviewCapsule({
|
|
539
|
+
schemaVersion: this.config.hybridCapsuleSchemaVersion,
|
|
540
|
+
routeDecision: input.routeDecision,
|
|
541
|
+
taskRun: input.taskRun,
|
|
542
|
+
outcomeSignal: input.experienceInput.outcome_signal,
|
|
543
|
+
triggers: {
|
|
544
|
+
directionalCorrectionPresent: candidateSignals.directional_correction?.detected === true
|
|
545
|
+
|| candidateSignals.evidence_driven_reversal?.detected === true,
|
|
546
|
+
injectedNodeInteractionPresent: input.experienceInput.injected_node_ids.length > 0,
|
|
547
|
+
retryOrInvalidationSignaturePresent: candidateSignals.retry_count > 0 || candidateSignals.evidence_driven_reversal?.invalidating_evidence === true,
|
|
548
|
+
meaningfulFailureSignaturePresent: Boolean(candidateSignals.failure_signature),
|
|
549
|
+
conservativeTransitionReviewWorthy: input.experienceInput.outcome_signal === "success" && input.experienceInput.injected_node_ids.length > 0
|
|
550
|
+
},
|
|
551
|
+
injectedNodes: input.experienceInput.injected_node_ids
|
|
552
|
+
.map((id) => this.nodeRepo.getById(id))
|
|
553
|
+
.filter((node) => Boolean(node)),
|
|
554
|
+
toolEvents: input.toolEvents
|
|
555
|
+
});
|
|
556
|
+
const providerResolution = this.config.hybridAsyncPostmortemLlmEnabled
|
|
557
|
+
? resolveHybridPostmortemProviderEndpoint(this.config)
|
|
558
|
+
: { status: "disabled", reason: "Phase 3 provider-backed postmortem review is disabled." };
|
|
559
|
+
const result = this.config.hybridAsyncPostmortemLlmEnabled && providerResolution.status === "unavailable"
|
|
560
|
+
? {
|
|
561
|
+
status: "fallback",
|
|
562
|
+
reason: "provider_unavailable"
|
|
563
|
+
}
|
|
564
|
+
: await hybridWorkerClient.runPostmortemReview(capsule, providerResolution.status === "configured"
|
|
565
|
+
? {
|
|
566
|
+
mode: "provider",
|
|
567
|
+
endpoint: providerResolution.endpoint
|
|
568
|
+
}
|
|
569
|
+
: undefined);
|
|
570
|
+
const timestamp = nowIso();
|
|
571
|
+
const persistAcceptedArtifact = result.status === "accepted"
|
|
572
|
+
&& input.rolloutMode !== "shadow"
|
|
573
|
+
&& (result.approvalClass === "review_artifact" || result.approvalClass === "policy_gated");
|
|
574
|
+
const appliedNodeWriteback = result.status === "accepted" && input.rolloutMode !== "shadow"
|
|
575
|
+
? this.applyAcceptedPostmortemNodeReviews({
|
|
576
|
+
taskRun: input.taskRun,
|
|
577
|
+
experienceInput: input.experienceInput,
|
|
578
|
+
result
|
|
579
|
+
})
|
|
580
|
+
: false;
|
|
581
|
+
this.hybridTraceRepo.upsert({
|
|
582
|
+
id: createId("hybridtrace"),
|
|
583
|
+
surface: "runtime",
|
|
584
|
+
session_id: input.taskRun.session_id,
|
|
585
|
+
scope_id: input.taskRun.scope_id,
|
|
586
|
+
worker_task: "postmortem_review",
|
|
587
|
+
route: input.routeDecision.route,
|
|
588
|
+
route_policy_version: input.routeDecision.policyVersion,
|
|
589
|
+
capsule_schema_version: this.config.hybridCapsuleSchemaVersion,
|
|
590
|
+
worker_profile_version: this.config.hybridAsyncPostmortemLlmEnabled
|
|
591
|
+
? this.config.hybridPostmortemModelProfileVersion
|
|
592
|
+
: this.config.hybridPostmortemReviewProfileVersion,
|
|
593
|
+
rollout_mode: input.rolloutMode,
|
|
594
|
+
rollout_reason: input.rolloutReason,
|
|
595
|
+
worker_ran: result.status !== "fallback" || result.reason !== "provider_unavailable",
|
|
596
|
+
validation_status: result.status === "accepted" ? "accepted" : "fallback",
|
|
597
|
+
output_action: persistAcceptedArtifact || appliedNodeWriteback ? "stored" : "rejected",
|
|
598
|
+
fallback_reason: result.status === "accepted" ? undefined : result.reason,
|
|
599
|
+
created_at: timestamp
|
|
600
|
+
});
|
|
601
|
+
if (result.status !== "accepted") {
|
|
602
|
+
this.logger.debug?.("experienceengine.hybrid_postmortem_skipped", {
|
|
603
|
+
taskRunId: input.taskRun.id,
|
|
604
|
+
reason: result.reason
|
|
605
|
+
});
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (persistAcceptedArtifact) {
|
|
609
|
+
this.hybridReviewArtifactRepo.upsert(this.buildPostmortemArtifact({
|
|
610
|
+
taskRun: input.taskRun,
|
|
611
|
+
result,
|
|
612
|
+
routeDecision: input.routeDecision
|
|
613
|
+
}));
|
|
614
|
+
}
|
|
615
|
+
}
|
|
304
616
|
async persistCandidatesAsync(input, originRecordId, taskRunId, sessionId) {
|
|
305
|
-
const
|
|
617
|
+
const learningGate = await this.getLearningGate();
|
|
618
|
+
if (!learningGate) {
|
|
619
|
+
if (taskRunId) {
|
|
620
|
+
const taskRun = this.taskRunRepo.getById(taskRunId);
|
|
621
|
+
if (taskRun) {
|
|
622
|
+
this.taskRunRepo.upsert({
|
|
623
|
+
...taskRun,
|
|
624
|
+
learning_status: "not_applicable",
|
|
625
|
+
learning_reason: "background learning disabled",
|
|
626
|
+
updated_at: nowIso()
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
const result = await learningGate.generateCandidateDrafts(input);
|
|
306
633
|
if (taskRunId) {
|
|
307
634
|
const taskRun = this.taskRunRepo.getById(taskRunId);
|
|
308
635
|
if (taskRun) {
|
|
@@ -327,7 +654,7 @@ export class ExperienceRuntimeService {
|
|
|
327
654
|
});
|
|
328
655
|
return;
|
|
329
656
|
}
|
|
330
|
-
const persistedCandidates = result.drafts.map((draft) => draftToCandidate(draft, input, originRecordId, taskRunId));
|
|
657
|
+
const persistedCandidates = result.drafts.map((draft) => draftToCandidate(draft, input, originRecordId, taskRunId, result.directionalCorrectionSignal, result.evidenceDrivenReversalSignal));
|
|
331
658
|
withTransaction(this.db, () => {
|
|
332
659
|
for (const candidate of persistedCandidates) {
|
|
333
660
|
this.candidateRepo.upsert(candidate);
|
|
@@ -342,7 +669,11 @@ export class ExperienceRuntimeService {
|
|
|
342
669
|
reason: result.reason
|
|
343
670
|
});
|
|
344
671
|
if (this.config.distillationAutoDrain) {
|
|
345
|
-
await this.
|
|
672
|
+
const distillationWorker = await this.getDistillationWorker();
|
|
673
|
+
if (!distillationWorker) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
await distillationWorker.drain().catch((error) => {
|
|
346
677
|
this.logger.error?.("experienceengine.distillation_drain_failed", {
|
|
347
678
|
sessionId,
|
|
348
679
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -362,7 +693,7 @@ export class ExperienceRuntimeService {
|
|
|
362
693
|
if (input.outcome_signal === "success") {
|
|
363
694
|
return {
|
|
364
695
|
nodeId: node.id,
|
|
365
|
-
eventType: "
|
|
696
|
+
eventType: "mark_uncertain"
|
|
366
697
|
};
|
|
367
698
|
}
|
|
368
699
|
if (detectHarm(input, node)) {
|
|
@@ -374,7 +705,10 @@ export class ExperienceRuntimeService {
|
|
|
374
705
|
return undefined;
|
|
375
706
|
})
|
|
376
707
|
.filter((value) => Boolean(value));
|
|
377
|
-
|
|
708
|
+
const originProfilesByNodeId = Object.fromEntries(touched.map((node) => {
|
|
709
|
+
return [node.id, deriveNodeOriginProfileForNode(this.inputRepo, node)];
|
|
710
|
+
}));
|
|
711
|
+
for (const node of applyFeedback(input, touched, attributionRecordId, { originProfilesByNodeId })) {
|
|
378
712
|
this.nodeRepo.upsert(node);
|
|
379
713
|
}
|
|
380
714
|
for (const event of automaticEvents) {
|
|
@@ -393,6 +727,7 @@ export class ExperienceRuntimeService {
|
|
|
393
727
|
const session = this.getSession(sessionId);
|
|
394
728
|
session.context = mergeContext(session.context, context);
|
|
395
729
|
const input = buildExperienceInput(session.context, session.toolEvents);
|
|
730
|
+
const retrievalContext = buildRetrievalContext(input, session.context);
|
|
396
731
|
const resolvedScope = resolveScope(session.context.cwd);
|
|
397
732
|
const existingScope = this.scopeRepo.getById(resolvedScope.scope_id);
|
|
398
733
|
if (existingScope?.is_disabled) {
|
|
@@ -410,6 +745,7 @@ export class ExperienceRuntimeService {
|
|
|
410
745
|
mode: "skip",
|
|
411
746
|
text: undefined,
|
|
412
747
|
notice: undefined,
|
|
748
|
+
retrievalContext,
|
|
413
749
|
input: {
|
|
414
750
|
...input,
|
|
415
751
|
scope_id: existingScope.scope_id,
|
|
@@ -418,8 +754,8 @@ export class ExperienceRuntimeService {
|
|
|
418
754
|
};
|
|
419
755
|
}
|
|
420
756
|
const stats = input.task_type !== "unknown" ? this.statsRepo.get(input.scope_id, input.task_type) : undefined;
|
|
421
|
-
const nodes = input.task_type !== "unknown" ? this.
|
|
422
|
-
const decision = await decideIntervention(input, nodes, stats, this.config.triggerThreshold, this.config.maxHints, this.config);
|
|
757
|
+
const nodes = input.task_type !== "unknown" ? this.resolveExactScopeInjectableNodes(input.scope_id) : [];
|
|
758
|
+
const decision = await decideIntervention(input, nodes, stats, this.config.triggerThreshold, this.config.maxHints, this.config, retrievalContext);
|
|
423
759
|
const selectedNodeIds = decision.selected.map((node) => node.id);
|
|
424
760
|
const delivery = resolveDeliveryMode(this.config.evaluationMode, this.config.holdoutRate, sessionId, input.task_summary, decision.mode !== "skip" && selectedNodeIds.length > 0);
|
|
425
761
|
session.injectedNodeIds = delivery.delivered ? selectedNodeIds : [];
|
|
@@ -466,6 +802,7 @@ export class ExperienceRuntimeService {
|
|
|
466
802
|
scorecard: decision.mode !== "skip" ? session.lastInjectionEvent?.scorecard : undefined,
|
|
467
803
|
deliveryMode: decision.mode !== "skip" ? delivery.deliveryMode : undefined,
|
|
468
804
|
delivered: decision.mode !== "skip" ? delivery.delivered : undefined,
|
|
805
|
+
retrievalContext,
|
|
469
806
|
input: {
|
|
470
807
|
...input,
|
|
471
808
|
injected_node_ids: session.injectedNodeIds
|
|
@@ -527,22 +864,71 @@ export class ExperienceRuntimeService {
|
|
|
527
864
|
input,
|
|
528
865
|
originRecordId: record.record_id,
|
|
529
866
|
taskRunId: taskRun.id,
|
|
530
|
-
sessionId
|
|
867
|
+
sessionId,
|
|
868
|
+
taskRun,
|
|
869
|
+
toolEvents: [...session.toolEvents]
|
|
531
870
|
};
|
|
532
871
|
});
|
|
533
872
|
this.sessions.delete(sessionId);
|
|
534
|
-
|
|
535
|
-
|
|
873
|
+
const rollout = resolveHybridRolloutState(this.config, `${sessionId}:${input.task_summary}`);
|
|
874
|
+
const hybridPosttaskRoute = decidePosttaskHybridRoute(this.config, input, {
|
|
875
|
+
taskStage: "posttask",
|
|
876
|
+
completedRun: true,
|
|
877
|
+
terminalOutcomeRecorded: true,
|
|
878
|
+
boundedPosttaskCapsuleAvailable: Boolean(input.task_summary),
|
|
879
|
+
postmortemAlreadyRecorded: learningTaskContext
|
|
880
|
+
? Boolean(this.hybridReviewArtifactRepo.getByTaskRunId(learningTaskContext.taskRun.id))
|
|
881
|
+
: false,
|
|
882
|
+
lightweightOrExcludedTask: false,
|
|
883
|
+
directionalCorrectionPresent: Boolean(learningTaskContext
|
|
884
|
+
? buildCandidateSignals(learningTaskContext.input).directional_correction?.detected
|
|
885
|
+
|| buildCandidateSignals(learningTaskContext.input).evidence_driven_reversal?.detected
|
|
886
|
+
: false),
|
|
887
|
+
injectedNodeInteractionPresent: input.injected_node_ids.length > 0,
|
|
888
|
+
retryOrInvalidationSignaturePresent: Boolean(learningTaskContext
|
|
889
|
+
? buildCandidateSignals(learningTaskContext.input).retry_count > 0
|
|
890
|
+
|| buildCandidateSignals(learningTaskContext.input).evidence_driven_reversal?.invalidating_evidence
|
|
891
|
+
: false),
|
|
892
|
+
meaningfulFailureSignaturePresent: Boolean(learningTaskContext
|
|
893
|
+
? buildCandidateSignals(learningTaskContext.input).failure_signature
|
|
894
|
+
: input.outcome_signal === "failure"),
|
|
895
|
+
conservativeTransitionReviewWorthy: false
|
|
896
|
+
}, `${sessionId}:${input.task_summary}`);
|
|
897
|
+
if (learningTaskContext && this.backgroundLearningEnabled) {
|
|
898
|
+
this.trackLearningTask((async () => {
|
|
899
|
+
await this.persistCandidatesAsync(learningTaskContext.input, learningTaskContext.originRecordId, learningTaskContext.taskRunId, learningTaskContext.sessionId);
|
|
900
|
+
if (hybridPosttaskRoute.route !== "ESCALATE_ASYNC_POSTMORTEM") {
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
const refreshedTaskRun = this.taskRunRepo.getById(learningTaskContext.taskRun.id) ?? learningTaskContext.taskRun;
|
|
904
|
+
await this.persistHybridPostmortemArtifactAsync({
|
|
905
|
+
taskRun: refreshedTaskRun,
|
|
906
|
+
experienceInput: learningTaskContext.input,
|
|
907
|
+
routeDecision: hybridPosttaskRoute,
|
|
908
|
+
toolEvents: learningTaskContext.toolEvents,
|
|
909
|
+
rolloutMode: rollout.effectiveMode,
|
|
910
|
+
rolloutReason: rollout.reason
|
|
911
|
+
});
|
|
912
|
+
})());
|
|
536
913
|
}
|
|
537
914
|
this.logger.info?.("experienceengine.finalize", {
|
|
538
915
|
sessionId,
|
|
539
916
|
taskType: input.task_type,
|
|
540
|
-
outcome: input.outcome_signal
|
|
917
|
+
outcome: input.outcome_signal,
|
|
918
|
+
hybridPosttaskRoute: hybridPosttaskRoute.route,
|
|
919
|
+
hybridPosttaskRouteReason: hybridPosttaskRoute.reasonCode,
|
|
920
|
+
hybridRoutePolicyVersion: hybridPosttaskRoute.policyVersion,
|
|
921
|
+
hybridRolloutMode: rollout.effectiveMode,
|
|
922
|
+
hybridRolloutReason: rollout.reason
|
|
541
923
|
});
|
|
542
924
|
return input;
|
|
543
925
|
}
|
|
544
926
|
async drainDistillationQueue(limit) {
|
|
545
|
-
|
|
927
|
+
const distillationWorker = await this.getDistillationWorker();
|
|
928
|
+
if (!distillationWorker) {
|
|
929
|
+
return 0;
|
|
930
|
+
}
|
|
931
|
+
return distillationWorker.drain(limit);
|
|
546
932
|
}
|
|
547
933
|
}
|
|
548
934
|
//# sourceMappingURL=service.js.map
|