@alan512/experienceengine 0.1.2 → 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 +4 -8
- package/LICENSE +21 -0
- package/README.md +288 -95
- package/README.zh-CN.md +316 -65
- 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 +3 -0
- package/dist/adapters/codex/instruction-template.js +12 -0
- package/dist/adapters/codex/instruction-template.js.map +1 -0
- package/dist/adapters/codex/mcp-server.d.ts +59 -41
- package/dist/adapters/codex/mcp-server.js +177 -728
- 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 +672 -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 +23 -7
- 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 +88 -2
- package/dist/cli/commands/config.js.map +1 -1
- 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 +4 -28
- package/dist/cli/commands/doctor.js +156 -68
- 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 +4 -0
- package/dist/cli/commands/feedback.js.map +1 -1
- 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 +28 -0
- package/dist/cli/commands/init.js +432 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/inspect.d.ts +0 -0
- package/dist/cli/commands/inspect.js +271 -37
- package/dist/cli/commands/inspect.js.map +1 -1
- package/dist/cli/commands/install.d.ts +0 -0
- package/dist/cli/commands/install.js +9 -0
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/maintenance.d.ts +0 -0
- package/dist/cli/commands/maintenance.js +1 -1
- package/dist/cli/commands/maintenance.js.map +1 -1
- package/dist/cli/commands/mcp-server.d.ts +0 -0
- package/dist/cli/commands/mcp-server.js +4 -0
- package/dist/cli/commands/mcp-server.js.map +1 -1
- 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 +89 -7
- 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 +36 -9
- 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 +14 -0
- package/dist/cli/state-model.js +23 -0
- package/dist/cli/state-model.js.map +1 -0
- package/dist/config/config-schema.d.ts +209 -0
- package/dist/config/config-schema.js +168 -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 +22 -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 +91 -2
- package/dist/config/load-config.js.map +1 -1
- package/dist/config/path-resolver.d.ts +0 -1
- package/dist/config/path-resolver.js +0 -2
- package/dist/config/path-resolver.js.map +1 -1
- package/dist/config/runtime-env.d.ts +8 -0
- package/dist/config/runtime-env.js +14 -0
- package/dist/config/runtime-env.js.map +1 -0
- package/dist/config/secrets-store.d.ts +15 -0
- package/dist/config/secrets-store.js +56 -0
- package/dist/config/secrets-store.js.map +1 -0
- package/dist/config/settings-store.d.ts +29 -0
- package/dist/config/settings-store.js +55 -0
- package/dist/config/settings-store.js.map +1 -1
- package/dist/controller/candidate-retriever.d.ts +49 -2
- package/dist/controller/candidate-retriever.js +258 -125
- package/dist/controller/candidate-retriever.js.map +1 -1
- package/dist/controller/injection-renderer.d.ts +0 -0
- package/dist/controller/injection-renderer.js +52 -1
- package/dist/controller/injection-renderer.js.map +1 -1
- package/dist/controller/injection-scorecard.d.ts +2 -2
- package/dist/controller/injection-scorecard.js +47 -1
- 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 -2
- package/dist/controller/intervention-controller.js +339 -17
- package/dist/controller/intervention-controller.js.map +1 -1
- package/dist/controller/lexical-retriever.d.ts +14 -0
- package/dist/controller/lexical-retriever.js +117 -0
- package/dist/controller/lexical-retriever.js.map +1 -0
- package/dist/controller/model-reranker.d.ts +20 -0
- package/dist/controller/model-reranker.js +187 -0
- package/dist/controller/model-reranker.js.map +1 -0
- package/dist/controller/node-ranker.d.ts +0 -0
- package/dist/controller/node-ranker.js +1 -0
- package/dist/controller/node-ranker.js.map +1 -1
- 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 +8 -0
- package/dist/controller/query-rewrite.js +69 -0
- package/dist/controller/query-rewrite.js.map +1 -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 +27 -2
- package/dist/controller/trigger-evaluator.js +63 -3
- 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 +4 -0
- package/dist/distillation/experience-family.js +14 -0
- package/dist/distillation/experience-family.js.map +1 -0
- package/dist/distillation/host-llm.d.ts +1 -0
- package/dist/distillation/host-llm.js +5 -1
- package/dist/distillation/host-llm.js.map +1 -1
- package/dist/distillation/llm-distiller.d.ts +0 -0
- package/dist/distillation/llm-distiller.js +4 -0
- package/dist/distillation/llm-distiller.js.map +1 -1
- package/dist/distillation/merge-decider.d.ts +0 -0
- package/dist/distillation/merge-decider.js +4 -0
- package/dist/distillation/merge-decider.js.map +1 -1
- 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 +6 -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 +78 -9
- 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 +14 -2
- 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/{compiler → hybrid}/types.js +0 -0
- package/dist/{packs → hybrid}/types.js.map +1 -1
- 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 +2 -1
- package/dist/input/input-adapter.js.map +1 -1
- package/dist/input/outcome-resolver.d.ts +0 -0
- package/dist/input/outcome-resolver.js +5 -5
- package/dist/input/outcome-resolver.js.map +1 -1
- 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 +2 -0
- package/dist/input/tasktype-resolver.js.map +1 -1
- package/dist/input/tool-event-significance.d.ts +5 -0
- package/dist/input/tool-event-significance.js +7 -0
- package/dist/input/tool-event-significance.js.map +1 -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 +8 -2
- package/dist/install/claude-code-doctor.js +54 -9
- 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 +14 -0
- package/dist/install/claude-marketplace-state.js +47 -0
- package/dist/install/claude-marketplace-state.js.map +1 -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 +18 -0
- package/dist/install/codex-installer.js +91 -1
- package/dist/install/codex-installer.js.map +1 -1
- 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 -0
- package/dist/install/openclaw-installer.js +198 -31
- package/dist/install/openclaw-installer.js.map +1 -1
- package/dist/install/public-install.d.ts +14 -4
- package/dist/install/public-install.js +20 -7
- package/dist/install/public-install.js.map +1 -1
- 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 +3 -17
- package/dist/interaction/repo-summary.js +10 -27
- package/dist/interaction/repo-summary.js.map +1 -1
- package/dist/interaction/service.d.ts +59 -95
- package/dist/interaction/service.js +505 -266
- 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 -1
- package/dist/maintenance/scope-merge.js +0 -20
- package/dist/maintenance/scope-merge.js.map +1 -1
- 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 +148 -0
- package/dist/plugin/openclaw-plugin.js +98 -7
- package/dist/plugin/openclaw-plugin.js.map +1 -1
- package/dist/plugin/openclaw-routine-interaction.d.ts +7 -0
- package/dist/plugin/openclaw-routine-interaction.js +301 -0
- package/dist/plugin/openclaw-routine-interaction.js.map +1 -0
- 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 -6
- package/dist/runtime/service.js +427 -50
- 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 +37 -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 +8 -2
- package/dist/store/sqlite/repositories/candidate-repo.js.map +1 -1
- 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 +1 -0
- package/dist/store/sqlite/repositories/injection-repo.js +11 -0
- package/dist/store/sqlite/repositories/injection-repo.js.map +1 -1
- package/dist/store/sqlite/repositories/input-record-repo.d.ts +3 -0
- package/dist/store/sqlite/repositories/input-record-repo.js +35 -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 +62 -8
- 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 +2 -0
- package/dist/store/sqlite/repositories/task-run-repo.js +18 -2
- package/dist/store/sqlite/repositories/task-run-repo.js.map +1 -1
- package/dist/store/sqlite/schema.sql +49 -49
- package/dist/store/vector/api-embedding-provider.d.ts +2 -0
- package/dist/store/vector/api-embedding-provider.js +23 -19
- package/dist/store/vector/api-embedding-provider.js.map +1 -1
- package/dist/store/vector/embeddings.d.ts +1 -1
- package/dist/store/vector/embeddings.js +26 -5
- 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 +166 -47
- package/dist/types/domain.js +0 -0
- package/dist/types/domain.js.map +0 -0
- package/dist/types/plugin.d.ts +3 -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 +3 -3
- package/docs/releases/v0.1.3.md +95 -0
- package/docs/releases/v0.2.0.md +85 -0
- package/docs/user-guide.md +263 -133
- package/hooks/hooks.json +0 -0
- package/openclaw.plugin.json +81 -1
- package/package.json +25 -16
- package/plugins/claude-code-experienceengine/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code-experienceengine/.mcp.json +4 -3
- package/plugins/claude-code-experienceengine/hooks/hooks.json +0 -0
- package/plugins/claude-code-experienceengine/scripts/claude-hook.sh +30 -1
- package/plugins/claude-code-experienceengine/scripts/install-deps.sh +41 -6
- package/scripts/claude-plugin/claude-hook.sh +0 -0
- package/scripts/claude-plugin/install-deps.sh +0 -0
- package/dist/cli/commands/pack.d.ts +0 -1
- package/dist/cli/commands/pack.js +0 -321
- package/dist/cli/commands/pack.js.map +0 -1
- package/dist/compiler/agents-renderer.d.ts +0 -4
- package/dist/compiler/agents-renderer.js +0 -105
- package/dist/compiler/agents-renderer.js.map +0 -1
- package/dist/compiler/claude-renderer.d.ts +0 -2
- package/dist/compiler/claude-renderer.js +0 -40
- package/dist/compiler/claude-renderer.js.map +0 -1
- package/dist/compiler/codex-renderer.d.ts +0 -2
- package/dist/compiler/codex-renderer.js +0 -40
- package/dist/compiler/codex-renderer.js.map +0 -1
- package/dist/compiler/compiler.d.ts +0 -4
- package/dist/compiler/compiler.js +0 -87
- package/dist/compiler/compiler.js.map +0 -1
- package/dist/compiler/deployer.d.ts +0 -21
- package/dist/compiler/deployer.js +0 -64
- package/dist/compiler/deployer.js.map +0 -1
- package/dist/compiler/github-renderer.d.ts +0 -2
- package/dist/compiler/github-renderer.js +0 -63
- package/dist/compiler/github-renderer.js.map +0 -1
- package/dist/compiler/types.d.ts +0 -45
- package/dist/compiler/types.js.map +0 -1
- package/dist/interaction/pack-actions-service.d.ts +0 -59
- package/dist/interaction/pack-actions-service.js +0 -172
- package/dist/interaction/pack-actions-service.js.map +0 -1
- package/dist/packs/fs-registry.d.ts +0 -27
- package/dist/packs/fs-registry.js +0 -216
- package/dist/packs/fs-registry.js.map +0 -1
- package/dist/packs/index-sync.d.ts +0 -9
- package/dist/packs/index-sync.js +0 -54
- package/dist/packs/index-sync.js.map +0 -1
- package/dist/packs/types.d.ts +0 -55
- package/dist/packs/types.js +0 -2
- package/dist/store/sqlite/repositories/pack-repo.d.ts +0 -16
- package/dist/store/sqlite/repositories/pack-repo.js +0 -192
- package/dist/store/sqlite/repositories/pack-repo.js.map +0 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createHash, createHmac } from "node:crypto";
|
|
2
2
|
import { analyzeExperience } from "./experience-analyzer.js";
|
|
3
|
+
import { buildCandidateSignals } from "./candidate-signals.js";
|
|
3
4
|
import { dedupeCandidates } from "./node-deduper.js";
|
|
4
5
|
import { normalizeCandidate } from "./node-normalizer.js";
|
|
6
|
+
import { isSubstantiveToolEvent } from "../input/tool-event-significance.js";
|
|
7
|
+
import { deriveTaskManagementSignals } from "../experience-management/task-management-signals.js";
|
|
5
8
|
import { resolveDistillationResolution } from "../distillation/host-llm.js";
|
|
6
9
|
import { resolveGoogleAdcAccessToken } from "../distillation/providers/google-adc.js";
|
|
7
10
|
const DEFAULT_REQUEST_TIMEOUT_MS = 45_000;
|
|
@@ -34,11 +37,13 @@ Do not capture:
|
|
|
34
37
|
- routine success with no reusable signal
|
|
35
38
|
- repo-specific noise that would not help a later similar task
|
|
36
39
|
- generic advice with no concrete trigger or verification signal
|
|
40
|
+
- expression-layer edits that only refine wording, copy, labels, formatting, presentation, or inline notice phrasing
|
|
37
41
|
|
|
38
42
|
Use experience_kind = expectation_correction when:
|
|
39
43
|
- the first attempt technically worked or partially worked
|
|
40
44
|
- but the user corrected the direction, layer, behavior, quality bar, or verification order
|
|
41
45
|
- and the later direction produced a better or objectively supported result
|
|
46
|
+
- do not use expectation_correction for copy-only, wording-only, style-only, or presentation-only refinements
|
|
42
47
|
|
|
43
48
|
For expectation_correction candidates:
|
|
44
49
|
- you must include confidence_signal, correction_scope, correction_category, deviation_pattern, and corrected_constraint
|
|
@@ -69,6 +74,8 @@ candidate may also include:
|
|
|
69
74
|
- correction_category
|
|
70
75
|
- deviation_pattern
|
|
71
76
|
- corrected_constraint
|
|
77
|
+
- promotion_signal
|
|
78
|
+
- promotion_reason
|
|
72
79
|
- goal
|
|
73
80
|
- applicability_notes
|
|
74
81
|
- recommended_steps
|
|
@@ -87,6 +94,8 @@ const EXPECTATION_CORRECTION_REPAIR_PROMPT = `You are repairing a coding-experie
|
|
|
87
94
|
|
|
88
95
|
Decide whether the task should actually be stored as expectation_correction.
|
|
89
96
|
|
|
97
|
+
Use the provided correction_window as the semantic detection context. Only promote when the correction window shows a real directional correction and the evidence_gate shows objective support or user confirmation.
|
|
98
|
+
|
|
90
99
|
Return strict JSON:
|
|
91
100
|
- expectation_correction: boolean
|
|
92
101
|
- confidence_signal: confirmed_by_user | supported_by_objective_success | unconfirmed (required when true)
|
|
@@ -110,6 +119,87 @@ context_summary: "No user correction happened; this is a verification loop."
|
|
|
110
119
|
draft.compact_hint: "Run pnpm typecheck after each change."
|
|
111
120
|
output:
|
|
112
121
|
{"expectation_correction":false}`;
|
|
122
|
+
const EXPECTATION_CORRECTION_RESCUE_PROMPT = `You are rescuing a missed directional correction from a coding task.
|
|
123
|
+
|
|
124
|
+
The main learner rejected this task as not broadly reusable. You should only rescue it when the correction window and evidence gate show a real reusable expectation correction.
|
|
125
|
+
|
|
126
|
+
Return strict JSON:
|
|
127
|
+
- expectation_correction: boolean
|
|
128
|
+
- candidate: required only when expectation_correction=true
|
|
129
|
+
|
|
130
|
+
candidate must include:
|
|
131
|
+
- node_type: strategy | warning
|
|
132
|
+
- task_type
|
|
133
|
+
- trigger_pattern
|
|
134
|
+
- compact_hint
|
|
135
|
+
- success_signal
|
|
136
|
+
- evidence_summary
|
|
137
|
+
- experience_kind: expectation_correction
|
|
138
|
+
- confidence_signal: confirmed_by_user | supported_by_objective_success | unconfirmed
|
|
139
|
+
- validation_state: pending_reuse_validation
|
|
140
|
+
- correction_scope: task_local | repo_local | workflow_local | host_local | cross_repo_candidate
|
|
141
|
+
- correction_category: goal_interpretation | quality_bar | interaction_behavior | verification_order | implementation_boundary | style_constraint
|
|
142
|
+
- deviation_pattern
|
|
143
|
+
- corrected_constraint
|
|
144
|
+
|
|
145
|
+
Do not rescue:
|
|
146
|
+
- wording-only
|
|
147
|
+
- copy-only
|
|
148
|
+
- style-only
|
|
149
|
+
- presentation-only
|
|
150
|
+
- ordinary verification loops without a corrected direction`;
|
|
151
|
+
const EVIDENCE_DRIVEN_REVERSAL_REPAIR_PROMPT = `You are repairing a coding-experience draft for evidence-driven reversal.
|
|
152
|
+
|
|
153
|
+
Use the provided reversal_window as the semantic detection context. Only promote when:
|
|
154
|
+
- an earlier active hypothesis or direction existed
|
|
155
|
+
- later task evidence invalidated it
|
|
156
|
+
- the task pivoted to a replacement path
|
|
157
|
+
- later verification supported the replacement path
|
|
158
|
+
|
|
159
|
+
Return strict JSON:
|
|
160
|
+
- reversal_detected: boolean
|
|
161
|
+
- reversal_source: task_evidence (required when true)
|
|
162
|
+
- superseded_hypothesis: short sentence (required when true)
|
|
163
|
+
- replacement_constraint: short sentence (required when true)
|
|
164
|
+
- verification_evidence: short sentence (required when true)
|
|
165
|
+
- pivot_summary: short sentence (optional)
|
|
166
|
+
- correction_scope: task_local | repo_local | workflow_local | host_local | cross_repo_candidate (required when true)
|
|
167
|
+
- correction_category: goal_interpretation | quality_bar | interaction_behavior | verification_order | implementation_boundary | style_constraint (required when true)
|
|
168
|
+
- deviation_pattern: short sentence (required when true)
|
|
169
|
+
- corrected_constraint: short sentence (required when true)
|
|
170
|
+
|
|
171
|
+
Do not promote ordinary verification loops, confirmation of the same direction, or loose narrowing that did not overturn the original path.`;
|
|
172
|
+
const EVIDENCE_DRIVEN_REVERSAL_RESCUE_PROMPT = `You are rescuing a missed evidence-driven reversal from a coding task.
|
|
173
|
+
|
|
174
|
+
The main learner did not capture a reusable candidate. Rescue only when the reversal window shows:
|
|
175
|
+
- a prior active hypothesis
|
|
176
|
+
- stronger invalidating task evidence
|
|
177
|
+
- a pivot into a replacement path
|
|
178
|
+
- later validating evidence on the replacement path
|
|
179
|
+
|
|
180
|
+
Return strict JSON:
|
|
181
|
+
- reversal_detected: boolean
|
|
182
|
+
- reversal_source: task_evidence (required when true)
|
|
183
|
+
- superseded_hypothesis: short sentence (required when true)
|
|
184
|
+
- replacement_constraint: short sentence (required when true)
|
|
185
|
+
- verification_evidence: short sentence (required when true)
|
|
186
|
+
- pivot_summary: short sentence (optional)
|
|
187
|
+
- candidate: required only when reversal_detected=true
|
|
188
|
+
|
|
189
|
+
candidate must include:
|
|
190
|
+
- node_type: strategy | warning
|
|
191
|
+
- task_type
|
|
192
|
+
- trigger_pattern
|
|
193
|
+
- compact_hint
|
|
194
|
+
- success_signal
|
|
195
|
+
- evidence_summary
|
|
196
|
+
- experience_kind: expectation_correction
|
|
197
|
+
- confidence_signal: confirmed_by_user | supported_by_objective_success | unconfirmed
|
|
198
|
+
- validation_state: pending_reuse_validation
|
|
199
|
+
- correction_scope: task_local | repo_local | workflow_local | host_local | cross_repo_candidate
|
|
200
|
+
- correction_category: goal_interpretation | quality_bar | interaction_behavior | verification_order | implementation_boundary | style_constraint
|
|
201
|
+
- deviation_pattern
|
|
202
|
+
- corrected_constraint`;
|
|
113
203
|
const sha256Hex = (value) => createHash("sha256").update(value, "utf8").digest("hex");
|
|
114
204
|
const hmac = (key, value) => createHmac("sha256", key).update(value, "utf8").digest();
|
|
115
205
|
const toAmzDate = (date) => date.toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
@@ -139,6 +229,7 @@ const CONFIDENCE_SIGNALS = [
|
|
|
139
229
|
"supported_by_objective_success",
|
|
140
230
|
"unconfirmed"
|
|
141
231
|
];
|
|
232
|
+
const PROMOTION_SIGNALS = ["normal", "high_value"];
|
|
142
233
|
const VALIDATION_STATES = [
|
|
143
234
|
"pending_reuse_validation",
|
|
144
235
|
"validated_by_reuse",
|
|
@@ -163,7 +254,29 @@ const isConfidenceSignal = (value) => typeof value === "string" && CONFIDENCE_SI
|
|
|
163
254
|
const isValidationState = (value) => typeof value === "string" && VALIDATION_STATES.includes(value);
|
|
164
255
|
const isCorrectionScope = (value) => typeof value === "string" && CORRECTION_SCOPES.includes(value);
|
|
165
256
|
const isCorrectionCategory = (value) => typeof value === "string" && CORRECTION_CATEGORIES.includes(value);
|
|
257
|
+
const isPromotionSignal = (value) => typeof value === "string" && PROMOTION_SIGNALS.includes(value);
|
|
166
258
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
259
|
+
const hasSubstantiveLearningEvidence = (input) => input.tool_events.some((event) => isSubstantiveToolEvent(event));
|
|
260
|
+
const EXPRESSION_LAYER_PATTERN = /\b(wording|phrasing|copy|label|labels|notice|message|messages|tooltip|readme|documentation|docs|format|formatting|presentation|tone|style|styling|inline notice)\b/i;
|
|
261
|
+
const OBJECTIVE_VERIFICATION_PATTERN = /\b(test|probe|verify|verification|build|compile|lint|typecheck|doctor|assert|request|response|endpoint|routing|fixture|mock|integration)\b/i;
|
|
262
|
+
const looksLikeExpressionLayerOnlyTask = (input) => {
|
|
263
|
+
const text = [input.task_summary, input.context_summary, ...input.tool_events.map((event) => event.output_summary ?? "")]
|
|
264
|
+
.filter(Boolean)
|
|
265
|
+
.join("\n");
|
|
266
|
+
if (!EXPRESSION_LAYER_PATTERN.test(text)) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
return !OBJECTIVE_VERIFICATION_PATTERN.test(text);
|
|
270
|
+
};
|
|
271
|
+
const resolveEligibilityRejectionReason = (input) => {
|
|
272
|
+
if (!hasSubstantiveLearningEvidence(input)) {
|
|
273
|
+
return "insufficient substantive evidence: only edit or exploratory events were observed";
|
|
274
|
+
}
|
|
275
|
+
if (looksLikeExpressionLayerOnlyTask(input)) {
|
|
276
|
+
return "task stayed in expression-layer refinement: wording, copy, or presentation changes are recorded but not learned";
|
|
277
|
+
}
|
|
278
|
+
return undefined;
|
|
279
|
+
};
|
|
167
280
|
const isTransientProviderFailure = (error) => {
|
|
168
281
|
const message = error instanceof Error ? error.message : String(error);
|
|
169
282
|
return (/timed out/i.test(message) ||
|
|
@@ -224,9 +337,33 @@ const normalizeDraft = (candidate, input) => {
|
|
|
224
337
|
escalation_condition: pickString(candidate.escalation_condition),
|
|
225
338
|
evidence_summary: evidenceSummary,
|
|
226
339
|
retrieval_text: undefined,
|
|
340
|
+
promotion_signal: isPromotionSignal(candidate.promotion_signal) ? candidate.promotion_signal : undefined,
|
|
341
|
+
promotion_reason: pickString(candidate.promotion_reason),
|
|
227
342
|
source_kind: "system_derived"
|
|
228
343
|
});
|
|
229
344
|
};
|
|
345
|
+
const applyTaskManagementPromotionPolicy = (input, draft) => {
|
|
346
|
+
const signals = deriveTaskManagementSignals(input);
|
|
347
|
+
const preserveHighValue = signals.realDevLikely &&
|
|
348
|
+
(signals.bugFixLike ||
|
|
349
|
+
draft.experience_kind === "expectation_correction" ||
|
|
350
|
+
input.task_type === "bug_fix" ||
|
|
351
|
+
input.task_type === "config_debug" ||
|
|
352
|
+
input.task_type === "integration_fix");
|
|
353
|
+
if (draft.promotion_signal !== "high_value" || preserveHighValue) {
|
|
354
|
+
return draft;
|
|
355
|
+
}
|
|
356
|
+
const downgradeReason = signals.metaLike
|
|
357
|
+
? "downgraded from high_value because the task looked meta-like and still needs real-dev reuse evidence"
|
|
358
|
+
: signals.validationLike
|
|
359
|
+
? "downgraded from high_value because the task looked validation-heavy and still needs real-dev reuse evidence"
|
|
360
|
+
: draft.promotion_reason;
|
|
361
|
+
return {
|
|
362
|
+
...draft,
|
|
363
|
+
promotion_signal: "normal",
|
|
364
|
+
promotion_reason: downgradeReason
|
|
365
|
+
};
|
|
366
|
+
};
|
|
230
367
|
export class LlmLearningGate {
|
|
231
368
|
config;
|
|
232
369
|
options;
|
|
@@ -321,7 +458,7 @@ export class LlmLearningGate {
|
|
|
321
458
|
temperature: 0.1
|
|
322
459
|
};
|
|
323
460
|
}
|
|
324
|
-
buildExpectationCorrectionRepairBody(endpoint, input, draft, reason) {
|
|
461
|
+
buildExpectationCorrectionRepairBody(endpoint, input, draft, reason, directionalCorrection) {
|
|
325
462
|
const payload = JSON.stringify({
|
|
326
463
|
task_summary: input.task_summary,
|
|
327
464
|
task_type: input.task_type,
|
|
@@ -342,6 +479,15 @@ export class LlmLearningGate {
|
|
|
342
479
|
success_signal: draft.success_signal,
|
|
343
480
|
evidence_summary: draft.evidence_summary
|
|
344
481
|
},
|
|
482
|
+
correction_window: {
|
|
483
|
+
selected: directionalCorrection.detected,
|
|
484
|
+
snippets: directionalCorrection.snippets,
|
|
485
|
+
sources: directionalCorrection.sources
|
|
486
|
+
},
|
|
487
|
+
evidence_gate: {
|
|
488
|
+
objective_support: directionalCorrection.objective_support,
|
|
489
|
+
user_confirmation: directionalCorrection.user_confirmation
|
|
490
|
+
},
|
|
345
491
|
original_reason: reason
|
|
346
492
|
}, null, 2);
|
|
347
493
|
if (endpoint.kind === "anthropic") {
|
|
@@ -395,6 +541,245 @@ export class LlmLearningGate {
|
|
|
395
541
|
temperature: 0
|
|
396
542
|
};
|
|
397
543
|
}
|
|
544
|
+
buildExpectationCorrectionRescueBody(endpoint, input, reason, directionalCorrection) {
|
|
545
|
+
const payload = JSON.stringify({
|
|
546
|
+
task_summary: input.task_summary,
|
|
547
|
+
task_type: input.task_type,
|
|
548
|
+
context_summary: input.context_summary,
|
|
549
|
+
outcome_signal: input.outcome_signal,
|
|
550
|
+
tool_events: input.tool_events.map((event) => ({
|
|
551
|
+
tool_name: event.tool_name,
|
|
552
|
+
status: event.status,
|
|
553
|
+
error_signature: event.error_signature,
|
|
554
|
+
output_summary: event.output_summary
|
|
555
|
+
})),
|
|
556
|
+
correction_window: {
|
|
557
|
+
selected: directionalCorrection.detected,
|
|
558
|
+
snippets: directionalCorrection.snippets,
|
|
559
|
+
sources: directionalCorrection.sources
|
|
560
|
+
},
|
|
561
|
+
evidence_gate: {
|
|
562
|
+
objective_support: directionalCorrection.objective_support,
|
|
563
|
+
user_confirmation: directionalCorrection.user_confirmation
|
|
564
|
+
},
|
|
565
|
+
original_reason: reason
|
|
566
|
+
}, null, 2);
|
|
567
|
+
if (endpoint.kind === "anthropic") {
|
|
568
|
+
return {
|
|
569
|
+
model: endpoint.model,
|
|
570
|
+
max_tokens: 768,
|
|
571
|
+
system: EXPECTATION_CORRECTION_RESCUE_PROMPT,
|
|
572
|
+
messages: [{ role: "user", content: payload }],
|
|
573
|
+
temperature: 0
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
if (endpoint.kind === "gemini") {
|
|
577
|
+
return {
|
|
578
|
+
system_instruction: {
|
|
579
|
+
parts: [{ text: EXPECTATION_CORRECTION_RESCUE_PROMPT }]
|
|
580
|
+
},
|
|
581
|
+
contents: [
|
|
582
|
+
{
|
|
583
|
+
role: "user",
|
|
584
|
+
parts: [{ text: payload }]
|
|
585
|
+
}
|
|
586
|
+
],
|
|
587
|
+
generationConfig: {
|
|
588
|
+
temperature: 0,
|
|
589
|
+
responseMimeType: "application/json"
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
if (endpoint.kind === "bedrock") {
|
|
594
|
+
return {
|
|
595
|
+
system: [{ text: EXPECTATION_CORRECTION_RESCUE_PROMPT }],
|
|
596
|
+
messages: [
|
|
597
|
+
{
|
|
598
|
+
role: "user",
|
|
599
|
+
content: [{ text: payload }]
|
|
600
|
+
}
|
|
601
|
+
],
|
|
602
|
+
inferenceConfig: {
|
|
603
|
+
maxTokens: 768,
|
|
604
|
+
temperature: 0
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
model: endpoint.model,
|
|
610
|
+
response_format: { type: "json_object" },
|
|
611
|
+
messages: [
|
|
612
|
+
{ role: "system", content: EXPECTATION_CORRECTION_RESCUE_PROMPT },
|
|
613
|
+
{ role: "user", content: payload }
|
|
614
|
+
],
|
|
615
|
+
temperature: 0
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
buildEvidenceDrivenReversalRepairBody(endpoint, input, draft, reason, reversal) {
|
|
619
|
+
const payload = JSON.stringify({
|
|
620
|
+
task_summary: input.task_summary,
|
|
621
|
+
task_type: input.task_type,
|
|
622
|
+
context_summary: input.context_summary,
|
|
623
|
+
outcome_signal: input.outcome_signal,
|
|
624
|
+
tool_events: input.tool_events.map((event) => ({
|
|
625
|
+
tool_name: event.tool_name,
|
|
626
|
+
status: event.status,
|
|
627
|
+
error_signature: event.error_signature,
|
|
628
|
+
output_summary: event.output_summary
|
|
629
|
+
})),
|
|
630
|
+
draft: {
|
|
631
|
+
task_type: draft.task_type,
|
|
632
|
+
node_type: draft.node_type,
|
|
633
|
+
experience_kind: draft.experience_kind,
|
|
634
|
+
trigger_pattern: draft.trigger_pattern,
|
|
635
|
+
compact_hint: draft.compact_hint,
|
|
636
|
+
success_signal: draft.success_signal,
|
|
637
|
+
evidence_summary: draft.evidence_summary
|
|
638
|
+
},
|
|
639
|
+
reversal_window: {
|
|
640
|
+
selected: reversal.detected,
|
|
641
|
+
hypothesis_snippets: reversal.hypothesis_snippets,
|
|
642
|
+
invalidating_snippets: reversal.invalidating_snippets,
|
|
643
|
+
pivot_snippets: reversal.pivot_snippets,
|
|
644
|
+
replacement_snippets: reversal.replacement_snippets,
|
|
645
|
+
validating_snippets: reversal.validating_snippets
|
|
646
|
+
},
|
|
647
|
+
evidence_gate: {
|
|
648
|
+
prior_hypothesis: reversal.prior_hypothesis,
|
|
649
|
+
invalidating_evidence: reversal.invalidating_evidence,
|
|
650
|
+
validating_evidence: reversal.validating_evidence
|
|
651
|
+
},
|
|
652
|
+
original_reason: reason
|
|
653
|
+
}, null, 2);
|
|
654
|
+
if (endpoint.kind === "anthropic") {
|
|
655
|
+
return {
|
|
656
|
+
model: endpoint.model,
|
|
657
|
+
max_tokens: 640,
|
|
658
|
+
system: EVIDENCE_DRIVEN_REVERSAL_REPAIR_PROMPT,
|
|
659
|
+
messages: [{ role: "user", content: payload }],
|
|
660
|
+
temperature: 0
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
if (endpoint.kind === "gemini") {
|
|
664
|
+
return {
|
|
665
|
+
system_instruction: {
|
|
666
|
+
parts: [{ text: EVIDENCE_DRIVEN_REVERSAL_REPAIR_PROMPT }]
|
|
667
|
+
},
|
|
668
|
+
contents: [
|
|
669
|
+
{
|
|
670
|
+
role: "user",
|
|
671
|
+
parts: [{ text: payload }]
|
|
672
|
+
}
|
|
673
|
+
],
|
|
674
|
+
generationConfig: {
|
|
675
|
+
temperature: 0,
|
|
676
|
+
responseMimeType: "application/json"
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
if (endpoint.kind === "bedrock") {
|
|
681
|
+
return {
|
|
682
|
+
system: [{ text: EVIDENCE_DRIVEN_REVERSAL_REPAIR_PROMPT }],
|
|
683
|
+
messages: [
|
|
684
|
+
{
|
|
685
|
+
role: "user",
|
|
686
|
+
content: [{ text: payload }]
|
|
687
|
+
}
|
|
688
|
+
],
|
|
689
|
+
inferenceConfig: {
|
|
690
|
+
maxTokens: 640,
|
|
691
|
+
temperature: 0
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
return {
|
|
696
|
+
model: endpoint.model,
|
|
697
|
+
response_format: { type: "json_object" },
|
|
698
|
+
messages: [
|
|
699
|
+
{ role: "system", content: EVIDENCE_DRIVEN_REVERSAL_REPAIR_PROMPT },
|
|
700
|
+
{ role: "user", content: payload }
|
|
701
|
+
],
|
|
702
|
+
temperature: 0
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
buildEvidenceDrivenReversalRescueBody(endpoint, input, reason, reversal) {
|
|
706
|
+
const payload = JSON.stringify({
|
|
707
|
+
task_summary: input.task_summary,
|
|
708
|
+
task_type: input.task_type,
|
|
709
|
+
context_summary: input.context_summary,
|
|
710
|
+
outcome_signal: input.outcome_signal,
|
|
711
|
+
tool_events: input.tool_events.map((event) => ({
|
|
712
|
+
tool_name: event.tool_name,
|
|
713
|
+
status: event.status,
|
|
714
|
+
error_signature: event.error_signature,
|
|
715
|
+
output_summary: event.output_summary
|
|
716
|
+
})),
|
|
717
|
+
reversal_window: {
|
|
718
|
+
selected: reversal.detected,
|
|
719
|
+
hypothesis_snippets: reversal.hypothesis_snippets,
|
|
720
|
+
invalidating_snippets: reversal.invalidating_snippets,
|
|
721
|
+
pivot_snippets: reversal.pivot_snippets,
|
|
722
|
+
replacement_snippets: reversal.replacement_snippets,
|
|
723
|
+
validating_snippets: reversal.validating_snippets
|
|
724
|
+
},
|
|
725
|
+
evidence_gate: {
|
|
726
|
+
prior_hypothesis: reversal.prior_hypothesis,
|
|
727
|
+
invalidating_evidence: reversal.invalidating_evidence,
|
|
728
|
+
validating_evidence: reversal.validating_evidence
|
|
729
|
+
},
|
|
730
|
+
original_reason: reason
|
|
731
|
+
}, null, 2);
|
|
732
|
+
if (endpoint.kind === "anthropic") {
|
|
733
|
+
return {
|
|
734
|
+
model: endpoint.model,
|
|
735
|
+
max_tokens: 768,
|
|
736
|
+
system: EVIDENCE_DRIVEN_REVERSAL_RESCUE_PROMPT,
|
|
737
|
+
messages: [{ role: "user", content: payload }],
|
|
738
|
+
temperature: 0
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
if (endpoint.kind === "gemini") {
|
|
742
|
+
return {
|
|
743
|
+
system_instruction: {
|
|
744
|
+
parts: [{ text: EVIDENCE_DRIVEN_REVERSAL_RESCUE_PROMPT }]
|
|
745
|
+
},
|
|
746
|
+
contents: [
|
|
747
|
+
{
|
|
748
|
+
role: "user",
|
|
749
|
+
parts: [{ text: payload }]
|
|
750
|
+
}
|
|
751
|
+
],
|
|
752
|
+
generationConfig: {
|
|
753
|
+
temperature: 0,
|
|
754
|
+
responseMimeType: "application/json"
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
if (endpoint.kind === "bedrock") {
|
|
759
|
+
return {
|
|
760
|
+
system: [{ text: EVIDENCE_DRIVEN_REVERSAL_RESCUE_PROMPT }],
|
|
761
|
+
messages: [
|
|
762
|
+
{
|
|
763
|
+
role: "user",
|
|
764
|
+
content: [{ text: payload }]
|
|
765
|
+
}
|
|
766
|
+
],
|
|
767
|
+
inferenceConfig: {
|
|
768
|
+
maxTokens: 768,
|
|
769
|
+
temperature: 0
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
return {
|
|
774
|
+
model: endpoint.model,
|
|
775
|
+
response_format: { type: "json_object" },
|
|
776
|
+
messages: [
|
|
777
|
+
{ role: "system", content: EVIDENCE_DRIVEN_REVERSAL_RESCUE_PROMPT },
|
|
778
|
+
{ role: "user", content: payload }
|
|
779
|
+
],
|
|
780
|
+
temperature: 0
|
|
781
|
+
};
|
|
782
|
+
}
|
|
398
783
|
parseExpectationCorrectionRepair(content) {
|
|
399
784
|
const parsed = JSON.parse(content);
|
|
400
785
|
if (parsed.expectation_correction !== true) {
|
|
@@ -424,7 +809,112 @@ export class LlmLearningGate {
|
|
|
424
809
|
corrected_constraint: correctedConstraint
|
|
425
810
|
};
|
|
426
811
|
}
|
|
427
|
-
|
|
812
|
+
parseExpectationCorrectionRescue(content, input, directionalCorrection) {
|
|
813
|
+
const parsed = JSON.parse(content);
|
|
814
|
+
if (parsed.expectation_correction !== true) {
|
|
815
|
+
return undefined;
|
|
816
|
+
}
|
|
817
|
+
const rawCandidate = parsed.candidate && typeof parsed.candidate === "object"
|
|
818
|
+
? parsed.candidate
|
|
819
|
+
: undefined;
|
|
820
|
+
if (!rawCandidate) {
|
|
821
|
+
return undefined;
|
|
822
|
+
}
|
|
823
|
+
const draft = normalizeDraft(rawCandidate, input);
|
|
824
|
+
if (draft.experience_kind !== "expectation_correction" ||
|
|
825
|
+
!draft.correction_category ||
|
|
826
|
+
!draft.deviation_pattern ||
|
|
827
|
+
!draft.corrected_constraint) {
|
|
828
|
+
return undefined;
|
|
829
|
+
}
|
|
830
|
+
return {
|
|
831
|
+
draft,
|
|
832
|
+
directionalCorrectionSignal: {
|
|
833
|
+
...directionalCorrection,
|
|
834
|
+
semantic_detected: true,
|
|
835
|
+
correction_category: draft.correction_category,
|
|
836
|
+
deviation_pattern: draft.deviation_pattern,
|
|
837
|
+
corrected_constraint: draft.corrected_constraint
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
parseEvidenceDrivenReversalRepair(content) {
|
|
842
|
+
const parsed = JSON.parse(content);
|
|
843
|
+
if (parsed.reversal_detected !== true) {
|
|
844
|
+
return undefined;
|
|
845
|
+
}
|
|
846
|
+
const reversalSource = parsed.reversal_source === "task_evidence" ? "task_evidence" : undefined;
|
|
847
|
+
const supersededHypothesis = pickString(parsed.superseded_hypothesis);
|
|
848
|
+
const replacementConstraint = pickString(parsed.replacement_constraint);
|
|
849
|
+
const verificationEvidence = pickString(parsed.verification_evidence);
|
|
850
|
+
const pivotSummary = pickString(parsed.pivot_summary);
|
|
851
|
+
const correctionScope = isCorrectionScope(parsed.correction_scope) ? parsed.correction_scope : undefined;
|
|
852
|
+
const correctionCategory = isCorrectionCategory(parsed.correction_category) ? parsed.correction_category : undefined;
|
|
853
|
+
const deviationPattern = pickString(parsed.deviation_pattern);
|
|
854
|
+
const correctedConstraint = pickString(parsed.corrected_constraint);
|
|
855
|
+
if (!reversalSource ||
|
|
856
|
+
!supersededHypothesis ||
|
|
857
|
+
!replacementConstraint ||
|
|
858
|
+
!verificationEvidence ||
|
|
859
|
+
!correctionScope ||
|
|
860
|
+
!correctionCategory ||
|
|
861
|
+
!deviationPattern ||
|
|
862
|
+
!correctedConstraint) {
|
|
863
|
+
return undefined;
|
|
864
|
+
}
|
|
865
|
+
return {
|
|
866
|
+
reversal_detected: true,
|
|
867
|
+
reversal_source: reversalSource,
|
|
868
|
+
superseded_hypothesis: supersededHypothesis,
|
|
869
|
+
replacement_constraint: replacementConstraint,
|
|
870
|
+
verification_evidence: verificationEvidence,
|
|
871
|
+
pivot_summary: pivotSummary,
|
|
872
|
+
correction_scope: correctionScope,
|
|
873
|
+
correction_category: correctionCategory,
|
|
874
|
+
deviation_pattern: deviationPattern,
|
|
875
|
+
corrected_constraint: correctedConstraint
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
parseEvidenceDrivenReversalRescue(content, input, reversal) {
|
|
879
|
+
const parsed = JSON.parse(content);
|
|
880
|
+
if (parsed.reversal_detected !== true) {
|
|
881
|
+
return undefined;
|
|
882
|
+
}
|
|
883
|
+
const reversalSource = parsed.reversal_source === "task_evidence" ? "task_evidence" : undefined;
|
|
884
|
+
const supersededHypothesis = pickString(parsed.superseded_hypothesis);
|
|
885
|
+
const replacementConstraint = pickString(parsed.replacement_constraint);
|
|
886
|
+
const verificationEvidence = pickString(parsed.verification_evidence);
|
|
887
|
+
const pivotSummary = pickString(parsed.pivot_summary);
|
|
888
|
+
const rawCandidate = parsed.candidate && typeof parsed.candidate === "object"
|
|
889
|
+
? parsed.candidate
|
|
890
|
+
: undefined;
|
|
891
|
+
if (!rawCandidate || !reversalSource || !supersededHypothesis || !replacementConstraint || !verificationEvidence) {
|
|
892
|
+
return undefined;
|
|
893
|
+
}
|
|
894
|
+
const draft = normalizeDraft(rawCandidate, input);
|
|
895
|
+
if (draft.experience_kind !== "expectation_correction" ||
|
|
896
|
+
!draft.correction_category ||
|
|
897
|
+
!draft.deviation_pattern ||
|
|
898
|
+
!draft.corrected_constraint) {
|
|
899
|
+
return undefined;
|
|
900
|
+
}
|
|
901
|
+
return {
|
|
902
|
+
draft,
|
|
903
|
+
evidenceDrivenReversalSignal: {
|
|
904
|
+
...reversal,
|
|
905
|
+
semantic_detected: true,
|
|
906
|
+
reversal_source: reversalSource,
|
|
907
|
+
superseded_hypothesis: supersededHypothesis,
|
|
908
|
+
replacement_constraint: replacementConstraint,
|
|
909
|
+
verification_evidence: verificationEvidence,
|
|
910
|
+
pivot_summary: pivotSummary,
|
|
911
|
+
correction_category: draft.correction_category,
|
|
912
|
+
deviation_pattern: draft.deviation_pattern,
|
|
913
|
+
corrected_constraint: draft.corrected_constraint
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
async maybeRepairExpectationCorrection(endpoint, input, reason, draft, directionalCorrection) {
|
|
428
918
|
const hasCompleteExpectationCorrectionShape = draft.experience_kind === "expectation_correction" &&
|
|
429
919
|
Boolean(draft.confidence_signal &&
|
|
430
920
|
draft.validation_state &&
|
|
@@ -433,25 +923,156 @@ export class LlmLearningGate {
|
|
|
433
923
|
draft.deviation_pattern &&
|
|
434
924
|
draft.corrected_constraint);
|
|
435
925
|
if (input.outcome_signal !== "success" || hasCompleteExpectationCorrectionShape) {
|
|
436
|
-
return
|
|
926
|
+
return {
|
|
927
|
+
draft,
|
|
928
|
+
directionalCorrectionSignal: directionalCorrection?.detected ? directionalCorrection : undefined
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
if (!directionalCorrection?.detected ||
|
|
932
|
+
(!directionalCorrection.objective_support && !directionalCorrection.user_confirmation)) {
|
|
933
|
+
return {
|
|
934
|
+
draft,
|
|
935
|
+
directionalCorrectionSignal: directionalCorrection?.detected ? directionalCorrection : undefined
|
|
936
|
+
};
|
|
437
937
|
}
|
|
438
938
|
try {
|
|
439
|
-
const response = await this.postJsonWithRetry(this.buildRequestUrl(endpoint), endpoint, this.buildExpectationCorrectionRepairBody(endpoint, input, draft, reason));
|
|
939
|
+
const response = await this.postJsonWithRetry(this.buildRequestUrl(endpoint), endpoint, this.buildExpectationCorrectionRepairBody(endpoint, input, draft, reason, directionalCorrection));
|
|
440
940
|
if (!response.ok) {
|
|
441
|
-
return
|
|
941
|
+
return {
|
|
942
|
+
draft,
|
|
943
|
+
directionalCorrectionSignal: directionalCorrection
|
|
944
|
+
};
|
|
442
945
|
}
|
|
443
946
|
const content = await this.parseResponseContent(endpoint, response);
|
|
444
947
|
const repair = this.parseExpectationCorrectionRepair(content);
|
|
445
948
|
if (!repair) {
|
|
446
|
-
return
|
|
949
|
+
return {
|
|
950
|
+
draft,
|
|
951
|
+
directionalCorrectionSignal: directionalCorrection
|
|
952
|
+
};
|
|
447
953
|
}
|
|
448
|
-
return
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
954
|
+
return {
|
|
955
|
+
draft: normalizeCandidate({
|
|
956
|
+
...draft,
|
|
957
|
+
...repair
|
|
958
|
+
}),
|
|
959
|
+
directionalCorrectionSignal: {
|
|
960
|
+
...directionalCorrection,
|
|
961
|
+
semantic_detected: true,
|
|
962
|
+
correction_category: repair.correction_category,
|
|
963
|
+
deviation_pattern: repair.deviation_pattern,
|
|
964
|
+
corrected_constraint: repair.corrected_constraint
|
|
965
|
+
}
|
|
966
|
+
};
|
|
452
967
|
}
|
|
453
968
|
catch {
|
|
454
|
-
return
|
|
969
|
+
return {
|
|
970
|
+
draft,
|
|
971
|
+
directionalCorrectionSignal: directionalCorrection
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
async maybeRepairEvidenceDrivenReversal(endpoint, input, reason, draft, directionalCorrection, reversal) {
|
|
976
|
+
if (input.outcome_signal !== "success" ||
|
|
977
|
+
(directionalCorrection?.correction_source &&
|
|
978
|
+
directionalCorrection.correction_source !== "task_evidence" &&
|
|
979
|
+
directionalCorrection.detected) ||
|
|
980
|
+
!reversal?.detected ||
|
|
981
|
+
!reversal.prior_hypothesis ||
|
|
982
|
+
!reversal.invalidating_evidence ||
|
|
983
|
+
!reversal.validating_evidence) {
|
|
984
|
+
return {
|
|
985
|
+
draft,
|
|
986
|
+
evidenceDrivenReversalSignal: reversal?.detected ? reversal : undefined
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
try {
|
|
990
|
+
const response = await this.postJsonWithRetry(this.buildRequestUrl(endpoint), endpoint, this.buildEvidenceDrivenReversalRepairBody(endpoint, input, draft, reason, reversal));
|
|
991
|
+
if (!response.ok) {
|
|
992
|
+
return {
|
|
993
|
+
draft,
|
|
994
|
+
evidenceDrivenReversalSignal: reversal
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
const content = await this.parseResponseContent(endpoint, response);
|
|
998
|
+
const repair = this.parseEvidenceDrivenReversalRepair(content);
|
|
999
|
+
if (!repair) {
|
|
1000
|
+
return {
|
|
1001
|
+
draft,
|
|
1002
|
+
evidenceDrivenReversalSignal: reversal
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
return {
|
|
1006
|
+
draft: normalizeCandidate({
|
|
1007
|
+
...draft,
|
|
1008
|
+
experience_kind: "expectation_correction",
|
|
1009
|
+
confidence_signal: draft.confidence_signal ?? "supported_by_objective_success",
|
|
1010
|
+
validation_state: draft.validation_state ?? "pending_reuse_validation",
|
|
1011
|
+
correction_scope: repair.correction_scope,
|
|
1012
|
+
correction_category: repair.correction_category,
|
|
1013
|
+
deviation_pattern: repair.deviation_pattern,
|
|
1014
|
+
corrected_constraint: repair.corrected_constraint
|
|
1015
|
+
}),
|
|
1016
|
+
evidenceDrivenReversalSignal: {
|
|
1017
|
+
...reversal,
|
|
1018
|
+
semantic_detected: true,
|
|
1019
|
+
reversal_source: repair.reversal_source,
|
|
1020
|
+
superseded_hypothesis: repair.superseded_hypothesis,
|
|
1021
|
+
replacement_constraint: repair.replacement_constraint,
|
|
1022
|
+
verification_evidence: repair.verification_evidence,
|
|
1023
|
+
pivot_summary: repair.pivot_summary,
|
|
1024
|
+
correction_category: repair.correction_category,
|
|
1025
|
+
deviation_pattern: repair.deviation_pattern,
|
|
1026
|
+
corrected_constraint: repair.corrected_constraint
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
catch {
|
|
1031
|
+
return {
|
|
1032
|
+
draft,
|
|
1033
|
+
evidenceDrivenReversalSignal: reversal
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
async maybeRescueExpectationCorrection(endpoint, input, reason, directionalCorrection) {
|
|
1038
|
+
if (input.outcome_signal !== "success" ||
|
|
1039
|
+
!directionalCorrection?.detected ||
|
|
1040
|
+
(!directionalCorrection.objective_support && !directionalCorrection.user_confirmation)) {
|
|
1041
|
+
return undefined;
|
|
1042
|
+
}
|
|
1043
|
+
try {
|
|
1044
|
+
const response = await this.postJsonWithRetry(this.buildRequestUrl(endpoint), endpoint, this.buildExpectationCorrectionRescueBody(endpoint, input, reason, directionalCorrection));
|
|
1045
|
+
if (!response.ok) {
|
|
1046
|
+
return undefined;
|
|
1047
|
+
}
|
|
1048
|
+
const content = await this.parseResponseContent(endpoint, response);
|
|
1049
|
+
return this.parseExpectationCorrectionRescue(content, input, directionalCorrection);
|
|
1050
|
+
}
|
|
1051
|
+
catch {
|
|
1052
|
+
return undefined;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
async maybeRescueEvidenceDrivenReversal(endpoint, input, reason, directionalCorrection, reversal) {
|
|
1056
|
+
if (input.outcome_signal !== "success" ||
|
|
1057
|
+
(directionalCorrection?.correction_source &&
|
|
1058
|
+
directionalCorrection.correction_source !== "task_evidence" &&
|
|
1059
|
+
directionalCorrection.detected) ||
|
|
1060
|
+
!reversal?.detected ||
|
|
1061
|
+
!reversal.prior_hypothesis ||
|
|
1062
|
+
!reversal.invalidating_evidence ||
|
|
1063
|
+
!reversal.validating_evidence) {
|
|
1064
|
+
return undefined;
|
|
1065
|
+
}
|
|
1066
|
+
try {
|
|
1067
|
+
const response = await this.postJsonWithRetry(this.buildRequestUrl(endpoint), endpoint, this.buildEvidenceDrivenReversalRescueBody(endpoint, input, reason, reversal));
|
|
1068
|
+
if (!response.ok) {
|
|
1069
|
+
return undefined;
|
|
1070
|
+
}
|
|
1071
|
+
const content = await this.parseResponseContent(endpoint, response);
|
|
1072
|
+
return this.parseEvidenceDrivenReversalRescue(content, input, reversal);
|
|
1073
|
+
}
|
|
1074
|
+
catch {
|
|
1075
|
+
return undefined;
|
|
455
1076
|
}
|
|
456
1077
|
}
|
|
457
1078
|
async parseResponseContent(endpoint, response) {
|
|
@@ -571,6 +1192,15 @@ export class LlmLearningGate {
|
|
|
571
1192
|
source: "disabled"
|
|
572
1193
|
};
|
|
573
1194
|
}
|
|
1195
|
+
const ineligibleReason = resolveEligibilityRejectionReason(input);
|
|
1196
|
+
if (ineligibleReason) {
|
|
1197
|
+
return {
|
|
1198
|
+
worthCapturing: false,
|
|
1199
|
+
reason: ineligibleReason,
|
|
1200
|
+
drafts: [],
|
|
1201
|
+
source: "disabled"
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
574
1204
|
const resolution = this.resolveDistillation();
|
|
575
1205
|
if (this.config.distillationMode === "disabled" || resolution.distillationMode === "disabled") {
|
|
576
1206
|
return {
|
|
@@ -585,7 +1215,7 @@ export class LlmLearningGate {
|
|
|
585
1215
|
return {
|
|
586
1216
|
worthCapturing: fallback.accepted.length > 0,
|
|
587
1217
|
reason: fallback.accepted.length > 0 ? "captured by rule fallback" : "rule fallback rejected candidate",
|
|
588
|
-
drafts: fallback.accepted,
|
|
1218
|
+
drafts: fallback.accepted.map((draft) => applyTaskManagementPromotionPolicy(input, draft)),
|
|
589
1219
|
source: "rule"
|
|
590
1220
|
};
|
|
591
1221
|
}
|
|
@@ -598,7 +1228,30 @@ export class LlmLearningGate {
|
|
|
598
1228
|
const parsed = JSON.parse(content);
|
|
599
1229
|
const worthCapturing = parsed.worth_capturing === true;
|
|
600
1230
|
const reason = pickString(parsed.reason) ?? "no reason provided";
|
|
1231
|
+
const candidateSignals = buildCandidateSignals(input);
|
|
1232
|
+
const directionalCorrection = candidateSignals.directional_correction;
|
|
1233
|
+
const evidenceDrivenReversal = candidateSignals.evidence_driven_reversal;
|
|
601
1234
|
if (!worthCapturing) {
|
|
1235
|
+
const rescued = await this.maybeRescueExpectationCorrection(resolution.endpoint, input, reason, directionalCorrection);
|
|
1236
|
+
if (rescued) {
|
|
1237
|
+
return {
|
|
1238
|
+
worthCapturing: true,
|
|
1239
|
+
reason: `rescued directional correction: ${reason}`,
|
|
1240
|
+
drafts: dedupeCandidates([applyTaskManagementPromotionPolicy(input, rescued.draft)]),
|
|
1241
|
+
source: "llm",
|
|
1242
|
+
directionalCorrectionSignal: rescued.directionalCorrectionSignal
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
const rescuedReversal = await this.maybeRescueEvidenceDrivenReversal(resolution.endpoint, input, reason, directionalCorrection, evidenceDrivenReversal);
|
|
1246
|
+
if (rescuedReversal) {
|
|
1247
|
+
return {
|
|
1248
|
+
worthCapturing: true,
|
|
1249
|
+
reason: `rescued evidence-driven reversal: ${reason}`,
|
|
1250
|
+
drafts: dedupeCandidates([applyTaskManagementPromotionPolicy(input, rescuedReversal.draft)]),
|
|
1251
|
+
source: "llm",
|
|
1252
|
+
evidenceDrivenReversalSignal: rescuedReversal.evidenceDrivenReversalSignal
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
602
1255
|
return {
|
|
603
1256
|
worthCapturing: false,
|
|
604
1257
|
reason,
|
|
@@ -612,12 +1265,15 @@ export class LlmLearningGate {
|
|
|
612
1265
|
if (!rawCandidate) {
|
|
613
1266
|
throw new Error("Learning gate marked worth_capturing=true without a candidate payload");
|
|
614
1267
|
}
|
|
615
|
-
const
|
|
1268
|
+
const repaired = await this.maybeRepairExpectationCorrection(resolution.endpoint, input, reason, normalizeDraft(rawCandidate, input), directionalCorrection);
|
|
1269
|
+
const reversalRepaired = await this.maybeRepairEvidenceDrivenReversal(resolution.endpoint, input, reason, repaired.draft, directionalCorrection, evidenceDrivenReversal);
|
|
616
1270
|
return {
|
|
617
1271
|
worthCapturing: true,
|
|
618
1272
|
reason,
|
|
619
|
-
drafts: dedupeCandidates([draft]),
|
|
620
|
-
source: "llm"
|
|
1273
|
+
drafts: dedupeCandidates([applyTaskManagementPromotionPolicy(input, reversalRepaired.draft)]),
|
|
1274
|
+
source: "llm",
|
|
1275
|
+
directionalCorrectionSignal: repaired.directionalCorrectionSignal,
|
|
1276
|
+
evidenceDrivenReversalSignal: reversalRepaired.evidenceDrivenReversalSignal
|
|
621
1277
|
};
|
|
622
1278
|
}
|
|
623
1279
|
catch (error) {
|
|
@@ -625,7 +1281,7 @@ export class LlmLearningGate {
|
|
|
625
1281
|
return {
|
|
626
1282
|
worthCapturing: fallback.accepted.length > 0,
|
|
627
1283
|
reason: `llm gate failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
628
|
-
drafts: fallback.accepted,
|
|
1284
|
+
drafts: fallback.accepted.map((draft) => applyTaskManagementPromotionPolicy(input, draft)),
|
|
629
1285
|
source: "rule"
|
|
630
1286
|
};
|
|
631
1287
|
}
|