pulseed 0.5.3 → 0.6.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/README.md +13 -9
- package/dist/adapters/datasources/artifact-metric-datasource.d.ts +18 -0
- package/dist/adapters/datasources/artifact-metric-datasource.d.ts.map +1 -0
- package/dist/adapters/datasources/artifact-metric-datasource.js +592 -0
- package/dist/adapters/datasources/artifact-metric-datasource.js.map +1 -0
- package/dist/adapters/types/mcp.d.ts +6 -6
- package/dist/base/state/state-manager-goal-state.d.ts +40 -0
- package/dist/base/state/state-manager-goal-state.d.ts.map +1 -0
- package/dist/base/state/state-manager-goal-state.js +235 -0
- package/dist/base/state/state-manager-goal-state.js.map +1 -0
- package/dist/base/state/state-manager.d.ts +0 -5
- package/dist/base/state/state-manager.d.ts.map +1 -1
- package/dist/base/state/state-manager.js +27 -273
- package/dist/base/state/state-manager.js.map +1 -1
- package/dist/base/types/goal-activation.d.ts +37 -0
- package/dist/base/types/goal-activation.d.ts.map +1 -0
- package/dist/base/types/goal-activation.js +13 -0
- package/dist/base/types/goal-activation.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/interface/chat/chat-history.d.ts +129 -0
- package/dist/interface/chat/chat-history.d.ts.map +1 -1
- package/dist/interface/chat/chat-history.js +135 -0
- package/dist/interface/chat/chat-history.js.map +1 -1
- package/dist/interface/chat/chat-runner-command-helpers.d.ts +50 -0
- package/dist/interface/chat/chat-runner-command-helpers.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-command-helpers.js +189 -0
- package/dist/interface/chat/chat-runner-command-helpers.js.map +1 -0
- package/dist/interface/chat/chat-runner-commands.d.ts +82 -0
- package/dist/interface/chat/chat-runner-commands.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-commands.js +906 -0
- package/dist/interface/chat/chat-runner-commands.js.map +1 -0
- package/dist/interface/chat/chat-runner-event-bridge.d.ts +60 -0
- package/dist/interface/chat/chat-runner-event-bridge.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-event-bridge.js +377 -0
- package/dist/interface/chat/chat-runner-event-bridge.js.map +1 -0
- package/dist/interface/chat/chat-runner-routes.d.ts +67 -0
- package/dist/interface/chat/chat-runner-routes.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-routes.js +610 -0
- package/dist/interface/chat/chat-runner-routes.js.map +1 -0
- package/dist/interface/chat/chat-runner-runtime.d.ts +37 -0
- package/dist/interface/chat/chat-runner-runtime.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-runtime.js +236 -0
- package/dist/interface/chat/chat-runner-runtime.js.map +1 -0
- package/dist/interface/chat/chat-runner-state.d.ts +20 -0
- package/dist/interface/chat/chat-runner-state.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-state.js +157 -0
- package/dist/interface/chat/chat-runner-state.js.map +1 -0
- package/dist/interface/chat/chat-runner-support.d.ts +39 -0
- package/dist/interface/chat/chat-runner-support.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-support.js +170 -0
- package/dist/interface/chat/chat-runner-support.js.map +1 -0
- package/dist/interface/chat/chat-runner.d.ts +10 -153
- package/dist/interface/chat/chat-runner.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner.js +330 -2643
- package/dist/interface/chat/chat-runner.js.map +1 -1
- package/dist/interface/chat/chat-session-store.d.ts +32 -0
- package/dist/interface/chat/chat-session-store.d.ts.map +1 -1
- package/dist/interface/chat/chat-session-store.js +100 -10
- package/dist/interface/chat/chat-session-store.js.map +1 -1
- package/dist/interface/chat/cross-platform-session.d.ts.map +1 -1
- package/dist/interface/chat/cross-platform-session.js +15 -6
- package/dist/interface/chat/cross-platform-session.js.map +1 -1
- package/dist/interface/chat/event-subscriber.d.ts.map +1 -1
- package/dist/interface/chat/event-subscriber.js +61 -0
- package/dist/interface/chat/event-subscriber.js.map +1 -1
- package/dist/interface/chat/failure-recovery.d.ts +43 -1
- package/dist/interface/chat/failure-recovery.d.ts.map +1 -1
- package/dist/interface/chat/failure-recovery.js +259 -89
- package/dist/interface/chat/failure-recovery.js.map +1 -1
- package/dist/interface/chat/ingress-router.d.ts +2 -26
- package/dist/interface/chat/ingress-router.d.ts.map +1 -1
- package/dist/interface/chat/ingress-router.js +14 -88
- package/dist/interface/chat/ingress-router.js.map +1 -1
- package/dist/interface/chat/tend-command.d.ts.map +1 -1
- package/dist/interface/chat/tend-command.js +3 -0
- package/dist/interface/chat/tend-command.js.map +1 -1
- package/dist/interface/cli/cli-command-registry.d.ts.map +1 -1
- package/dist/interface/cli/cli-command-registry.js +19 -3
- package/dist/interface/cli/cli-command-registry.js.map +1 -1
- package/dist/interface/cli/commands/daemon-shared.d.ts +33 -0
- package/dist/interface/cli/commands/daemon-shared.d.ts.map +1 -0
- package/dist/interface/cli/commands/daemon-shared.js +152 -0
- package/dist/interface/cli/commands/daemon-shared.js.map +1 -0
- package/dist/interface/cli/commands/daemon.d.ts +2 -2
- package/dist/interface/cli/commands/daemon.d.ts.map +1 -1
- package/dist/interface/cli/commands/daemon.js +62 -127
- package/dist/interface/cli/commands/daemon.js.map +1 -1
- package/dist/interface/cli/commands/goal-read.d.ts.map +1 -1
- package/dist/interface/cli/commands/goal-read.js +10 -3
- package/dist/interface/cli/commands/goal-read.js.map +1 -1
- package/dist/interface/cli/commands/notify.d.ts.map +1 -1
- package/dist/interface/cli/commands/notify.js +7 -1
- package/dist/interface/cli/commands/notify.js.map +1 -1
- package/dist/interface/cli/commands/run.d.ts.map +1 -1
- package/dist/interface/cli/commands/run.js +29 -0
- package/dist/interface/cli/commands/run.js.map +1 -1
- package/dist/interface/cli/commands/runtime.d.ts +1 -1
- package/dist/interface/cli/commands/runtime.d.ts.map +1 -1
- package/dist/interface/cli/commands/runtime.js +407 -2
- package/dist/interface/cli/commands/runtime.js.map +1 -1
- package/dist/interface/cli/commands/schedule/history.d.ts.map +1 -1
- package/dist/interface/cli/commands/schedule/history.js +5 -1
- package/dist/interface/cli/commands/schedule/history.js.map +1 -1
- package/dist/interface/cli/commands/schedule.js +34 -4
- package/dist/interface/cli/commands/schedule.js.map +1 -1
- package/dist/interface/cli/data-source-bootstrap.d.ts.map +1 -1
- package/dist/interface/cli/data-source-bootstrap.js +25 -12
- package/dist/interface/cli/data-source-bootstrap.js.map +1 -1
- package/dist/interface/cli/setup.d.ts.map +1 -1
- package/dist/interface/cli/setup.js +14 -0
- package/dist/interface/cli/setup.js.map +1 -1
- package/dist/interface/cli/utils/loop-runner.d.ts.map +1 -1
- package/dist/interface/cli/utils/loop-runner.js +2 -1
- package/dist/interface/cli/utils/loop-runner.js.map +1 -1
- package/dist/interface/cli/utils.d.ts.map +1 -1
- package/dist/interface/cli/utils.js +8 -1
- package/dist/interface/cli/utils.js.map +1 -1
- package/dist/interface/tui/app.d.ts +4 -1
- package/dist/interface/tui/app.d.ts.map +1 -1
- package/dist/interface/tui/app.js +282 -11
- package/dist/interface/tui/app.js.map +1 -1
- package/dist/interface/tui/chat/suggestions.d.ts.map +1 -1
- package/dist/interface/tui/chat/suggestions.js +118 -4
- package/dist/interface/tui/chat/suggestions.js.map +1 -1
- package/dist/interface/tui/chat-surface.d.ts +2 -0
- package/dist/interface/tui/chat-surface.d.ts.map +1 -1
- package/dist/interface/tui/chat-surface.js +3 -0
- package/dist/interface/tui/chat-surface.js.map +1 -1
- package/dist/interface/tui/dashboard.d.ts +37 -1
- package/dist/interface/tui/dashboard.d.ts.map +1 -1
- package/dist/interface/tui/dashboard.js +264 -1
- package/dist/interface/tui/dashboard.js.map +1 -1
- package/dist/interface/tui/entry-approval.d.ts +8 -0
- package/dist/interface/tui/entry-approval.d.ts.map +1 -0
- package/dist/interface/tui/entry-approval.js +59 -0
- package/dist/interface/tui/entry-approval.js.map +1 -0
- package/dist/interface/tui/entry-daemon.d.ts +12 -0
- package/dist/interface/tui/entry-daemon.d.ts.map +1 -0
- package/dist/interface/tui/entry-daemon.js +74 -0
- package/dist/interface/tui/entry-daemon.js.map +1 -0
- package/dist/interface/tui/entry-deps.d.ts +24 -0
- package/dist/interface/tui/entry-deps.d.ts.map +1 -0
- package/dist/interface/tui/entry-deps.js +427 -0
- package/dist/interface/tui/entry-deps.js.map +1 -0
- package/dist/interface/tui/entry.d.ts +2 -4
- package/dist/interface/tui/entry.d.ts.map +1 -1
- package/dist/interface/tui/entry.js +11 -556
- package/dist/interface/tui/entry.js.map +1 -1
- package/dist/interface/tui/fullscreen-chat-render.d.ts +127 -0
- package/dist/interface/tui/fullscreen-chat-render.d.ts.map +1 -0
- package/dist/interface/tui/fullscreen-chat-render.js +667 -0
- package/dist/interface/tui/fullscreen-chat-render.js.map +1 -0
- package/dist/interface/tui/fullscreen-chat.d.ts +2 -111
- package/dist/interface/tui/fullscreen-chat.d.ts.map +1 -1
- package/dist/interface/tui/fullscreen-chat.js +4 -663
- package/dist/interface/tui/fullscreen-chat.js.map +1 -1
- package/dist/interface/tui/help-overlay.d.ts.map +1 -1
- package/dist/interface/tui/help-overlay.js +1 -1
- package/dist/interface/tui/help-overlay.js.map +1 -1
- package/dist/interface/tui/intent-recognizer.d.ts +8 -3
- package/dist/interface/tui/intent-recognizer.d.ts.map +1 -1
- package/dist/interface/tui/intent-recognizer.js +74 -68
- package/dist/interface/tui/intent-recognizer.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js +49 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-router.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-router.js +2 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-router.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.d.ts +2 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.js +31 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts +1 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.d.ts +1 -0
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js +36 -2
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.d.ts +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js +2 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.d.ts +19 -0
- package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.js +165 -14
- package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/core-phase-runner.d.ts +1 -1
- package/dist/orchestrator/execution/agent-loop/core-phase-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/core-phase-runner.js +10 -1
- package/dist/orchestrator/execution/agent-loop/core-phase-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.d.ts +2 -0
- package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.js +4 -0
- package/dist/orchestrator/execution/agent-loop/kaggle-training-benchmark.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/task-agent-loop-result.d.ts +8 -8
- package/dist/orchestrator/execution/reflection-generator.d.ts +1 -0
- package/dist/orchestrator/execution/reflection-generator.d.ts.map +1 -1
- package/dist/orchestrator/execution/reflection-generator.js +10 -1
- package/dist/orchestrator/execution/reflection-generator.js.map +1 -1
- package/dist/orchestrator/execution/task/task-context-enricher.d.ts +2 -0
- package/dist/orchestrator/execution/task/task-context-enricher.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-context-enricher.js +9 -4
- package/dist/orchestrator/execution/task/task-context-enricher.js.map +1 -1
- package/dist/orchestrator/execution/task/task-execution-helpers-internal.d.ts +5 -0
- package/dist/orchestrator/execution/task/task-execution-helpers-internal.d.ts.map +1 -0
- package/dist/orchestrator/execution/task/task-execution-helpers-internal.js +6 -0
- package/dist/orchestrator/execution/task/task-execution-helpers-internal.js.map +1 -0
- package/dist/orchestrator/execution/task/task-generation.d.ts +3 -1
- package/dist/orchestrator/execution/task/task-generation.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-generation.js +25 -5
- package/dist/orchestrator/execution/task/task-generation.js.map +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle-runner.d.ts +77 -0
- package/dist/orchestrator/execution/task/task-lifecycle-runner.d.ts.map +1 -0
- package/dist/orchestrator/execution/task/task-lifecycle-runner.js +188 -0
- package/dist/orchestrator/execution/task/task-lifecycle-runner.js.map +1 -0
- package/dist/orchestrator/execution/task/task-lifecycle.d.ts +17 -8
- package/dist/orchestrator/execution/task/task-lifecycle.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle.js +144 -187
- package/dist/orchestrator/execution/task/task-lifecycle.js.map +1 -1
- package/dist/orchestrator/execution/task/task-prompt-builder.d.ts +2 -1
- package/dist/orchestrator/execution/task/task-prompt-builder.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-prompt-builder.js +4 -2
- package/dist/orchestrator/execution/task/task-prompt-builder.js.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier-internal.d.ts +2 -0
- package/dist/orchestrator/execution/task/task-verifier-internal.d.ts.map +1 -0
- package/dist/orchestrator/execution/task/task-verifier-internal.js +2 -0
- package/dist/orchestrator/execution/task/task-verifier-internal.js.map +1 -0
- package/dist/orchestrator/execution/types/pipeline.d.ts +6 -6
- package/dist/orchestrator/goal/goal-negotiator.d.ts.map +1 -1
- package/dist/orchestrator/goal/goal-negotiator.js +23 -3
- package/dist/orchestrator/goal/goal-negotiator.js.map +1 -1
- package/dist/orchestrator/goal/types/goal.d.ts +282 -0
- package/dist/orchestrator/goal/types/goal.d.ts.map +1 -1
- package/dist/orchestrator/goal/types/goal.js +20 -0
- package/dist/orchestrator/goal/types/goal.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/contracts.d.ts +47 -3
- package/dist/orchestrator/loop/core-loop/contracts.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/contracts.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/decision-engine.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/decision-engine.js +4 -0
- package/dist/orchestrator/loop/core-loop/decision-engine.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/dream-review-checkpoint.d.ts +48 -0
- package/dist/orchestrator/loop/core-loop/dream-review-checkpoint.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/dream-review-checkpoint.js +377 -0
- package/dist/orchestrator/loop/core-loop/dream-review-checkpoint.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/evidence-ledger.js +1 -1
- package/dist/orchestrator/loop/core-loop/evidence-ledger.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.d.ts +7 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.js +43 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.d.ts +14 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.js +41 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel.d.ts +4 -2
- package/dist/orchestrator/loop/core-loop/iteration-kernel.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/iteration-kernel.js +507 -87
- package/dist/orchestrator/loop/core-loop/iteration-kernel.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-policy.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-policy.js +40 -5
- package/dist/orchestrator/loop/core-loop/phase-policy.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-runtime.d.ts +2 -0
- package/dist/orchestrator/loop/core-loop/phase-runtime.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-runtime.js +43 -2
- package/dist/orchestrator/loop/core-loop/phase-runtime.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-specs.d.ts +969 -2
- package/dist/orchestrator/loop/core-loop/phase-specs.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-specs.js +198 -0
- package/dist/orchestrator/loop/core-loop/phase-specs.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/public-research.d.ts +32 -0
- package/dist/orchestrator/loop/core-loop/public-research.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/public-research.js +112 -0
- package/dist/orchestrator/loop/core-loop/public-research.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-stall.d.ts +9 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-stall.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-stall.js +433 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-stall.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-wait.d.ts +11 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-wait.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-wait.js +176 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-wait.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle.d.ts +7 -15
- package/dist/orchestrator/loop/core-loop/task-cycle.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/task-cycle.js +17 -444
- package/dist/orchestrator/loop/core-loop/task-cycle.js.map +1 -1
- package/dist/orchestrator/loop/core-loop.d.ts +18 -5
- package/dist/orchestrator/loop/core-loop.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop.js +287 -17
- package/dist/orchestrator/loop/core-loop.js.map +1 -1
- package/dist/orchestrator/loop/loop-report-helper.d.ts.map +1 -1
- package/dist/orchestrator/loop/loop-report-helper.js +4 -0
- package/dist/orchestrator/loop/loop-report-helper.js.map +1 -1
- package/dist/orchestrator/loop/loop-result-types.d.ts +20 -1
- package/dist/orchestrator/loop/loop-result-types.d.ts.map +1 -1
- package/dist/orchestrator/loop/loop-result-types.js.map +1 -1
- package/dist/orchestrator/loop/post-loop-hooks.d.ts +1 -0
- package/dist/orchestrator/loop/post-loop-hooks.d.ts.map +1 -1
- package/dist/orchestrator/loop/post-loop-hooks.js +34 -1
- package/dist/orchestrator/loop/post-loop-hooks.js.map +1 -1
- package/dist/orchestrator/loop/run-policy.d.ts +10 -0
- package/dist/orchestrator/loop/run-policy.d.ts.map +1 -0
- package/dist/orchestrator/loop/run-policy.js +30 -0
- package/dist/orchestrator/loop/run-policy.js.map +1 -0
- package/dist/orchestrator/strategy/divergent-exploration.d.ts +37 -0
- package/dist/orchestrator/strategy/divergent-exploration.d.ts.map +1 -0
- package/dist/orchestrator/strategy/divergent-exploration.js +324 -0
- package/dist/orchestrator/strategy/divergent-exploration.js.map +1 -0
- package/dist/orchestrator/strategy/portfolio-manager.d.ts +3 -2
- package/dist/orchestrator/strategy/portfolio-manager.d.ts.map +1 -1
- package/dist/orchestrator/strategy/portfolio-manager.js +16 -11
- package/dist/orchestrator/strategy/portfolio-manager.js.map +1 -1
- package/dist/orchestrator/strategy/portfolio-rebalance.d.ts +1 -1
- package/dist/orchestrator/strategy/portfolio-rebalance.d.ts.map +1 -1
- package/dist/orchestrator/strategy/portfolio-rebalance.js +31 -9
- package/dist/orchestrator/strategy/portfolio-rebalance.js.map +1 -1
- package/dist/orchestrator/strategy/strategy-helpers.d.ts +108 -0
- package/dist/orchestrator/strategy/strategy-helpers.d.ts.map +1 -1
- package/dist/orchestrator/strategy/strategy-helpers.js +34 -2
- package/dist/orchestrator/strategy/strategy-helpers.js.map +1 -1
- package/dist/orchestrator/strategy/strategy-manager-base.d.ts +31 -2
- package/dist/orchestrator/strategy/strategy-manager-base.d.ts.map +1 -1
- package/dist/orchestrator/strategy/strategy-manager-base.js +93 -12
- package/dist/orchestrator/strategy/strategy-manager-base.js.map +1 -1
- package/dist/orchestrator/strategy/strategy-manager.d.ts +1 -11
- package/dist/orchestrator/strategy/strategy-manager.d.ts.map +1 -1
- package/dist/orchestrator/strategy/strategy-manager.js +78 -19
- package/dist/orchestrator/strategy/strategy-manager.js.map +1 -1
- package/dist/orchestrator/strategy/types/cross-portfolio.d.ts +2 -2
- package/dist/orchestrator/strategy/types/strategy.d.ts +364 -0
- package/dist/orchestrator/strategy/types/strategy.d.ts.map +1 -1
- package/dist/orchestrator/strategy/types/strategy.js +43 -0
- package/dist/orchestrator/strategy/types/strategy.js.map +1 -1
- package/dist/platform/dream/dream-activation.d.ts +1 -1
- package/dist/platform/dream/dream-consolidator/fs-metrics.d.ts +18 -0
- package/dist/platform/dream/dream-consolidator/fs-metrics.d.ts.map +1 -0
- package/dist/platform/dream/dream-consolidator/fs-metrics.js +130 -0
- package/dist/platform/dream/dream-consolidator/fs-metrics.js.map +1 -0
- package/dist/platform/dream/dream-consolidator.d.ts +4 -14
- package/dist/platform/dream/dream-consolidator.d.ts.map +1 -1
- package/dist/platform/dream/dream-consolidator.js +46 -166
- package/dist/platform/dream/dream-consolidator.js.map +1 -1
- package/dist/platform/dream/dream-event-workflows.d.ts +6 -6
- package/dist/platform/dream/dream-soil-sync.d.ts +1 -0
- package/dist/platform/dream/dream-soil-sync.d.ts.map +1 -1
- package/dist/platform/dream/dream-soil-sync.js +8 -1
- package/dist/platform/dream/dream-soil-sync.js.map +1 -1
- package/dist/platform/dream/dream-types.d.ts +94 -89
- package/dist/platform/dream/dream-types.d.ts.map +1 -1
- package/dist/platform/dream/dream-types.js +1 -0
- package/dist/platform/dream/dream-types.js.map +1 -1
- package/dist/platform/dream/playbook-memory.d.ts +4 -4
- package/dist/platform/drive/metric-history.d.ts +61 -0
- package/dist/platform/drive/metric-history.d.ts.map +1 -0
- package/dist/platform/drive/metric-history.js +206 -0
- package/dist/platform/drive/metric-history.js.map +1 -0
- package/dist/platform/drive/progress-predictor.d.ts +7 -0
- package/dist/platform/drive/progress-predictor.d.ts.map +1 -1
- package/dist/platform/drive/progress-predictor.js +23 -0
- package/dist/platform/drive/progress-predictor.js.map +1 -1
- package/dist/platform/drive/stall-detector/analysis.d.ts +5 -0
- package/dist/platform/drive/stall-detector/analysis.d.ts.map +1 -0
- package/dist/platform/drive/stall-detector/analysis.js +55 -0
- package/dist/platform/drive/stall-detector/analysis.js.map +1 -0
- package/dist/platform/drive/stall-detector/repetitive.d.ts +3 -0
- package/dist/platform/drive/stall-detector/repetitive.d.ts.map +1 -0
- package/dist/platform/drive/stall-detector/repetitive.js +72 -0
- package/dist/platform/drive/stall-detector/repetitive.js.map +1 -0
- package/dist/platform/drive/stall-detector/thresholds.d.ts +10 -0
- package/dist/platform/drive/stall-detector/thresholds.d.ts.map +1 -0
- package/dist/platform/drive/stall-detector/thresholds.js +61 -0
- package/dist/platform/drive/stall-detector/thresholds.js.map +1 -0
- package/dist/platform/drive/stall-detector.d.ts +5 -21
- package/dist/platform/drive/stall-detector.d.ts.map +1 -1
- package/dist/platform/drive/stall-detector.js +47 -201
- package/dist/platform/drive/stall-detector.js.map +1 -1
- package/dist/platform/drive/types/satisficing.d.ts +2 -2
- package/dist/platform/drive/types/stall.d.ts +4 -0
- package/dist/platform/drive/types/stall.d.ts.map +1 -1
- package/dist/platform/drive/types/stall.js +1 -0
- package/dist/platform/drive/types/stall.js.map +1 -1
- package/dist/platform/knowledge/knowledge-manager-agent-memory.d.ts +55 -0
- package/dist/platform/knowledge/knowledge-manager-agent-memory.d.ts.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-agent-memory.js +232 -0
- package/dist/platform/knowledge/knowledge-manager-agent-memory.js.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-internals.d.ts +10 -0
- package/dist/platform/knowledge/knowledge-manager-internals.d.ts.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-internals.js +43 -0
- package/dist/platform/knowledge/knowledge-manager-internals.js.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-store.d.ts +13 -0
- package/dist/platform/knowledge/knowledge-manager-store.d.ts.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-store.js +67 -0
- package/dist/platform/knowledge/knowledge-manager-store.js.map +1 -0
- package/dist/platform/knowledge/knowledge-manager.d.ts +6 -2
- package/dist/platform/knowledge/knowledge-manager.d.ts.map +1 -1
- package/dist/platform/knowledge/knowledge-manager.js +43 -344
- package/dist/platform/knowledge/knowledge-manager.js.map +1 -1
- package/dist/platform/knowledge/memory/memory-lifecycle-storage.d.ts +4 -0
- package/dist/platform/knowledge/memory/memory-lifecycle-storage.d.ts.map +1 -0
- package/dist/platform/knowledge/memory/memory-lifecycle-storage.js +106 -0
- package/dist/platform/knowledge/memory/memory-lifecycle-storage.js.map +1 -0
- package/dist/platform/knowledge/memory/memory-lifecycle.d.ts.map +1 -1
- package/dist/platform/knowledge/memory/memory-lifecycle.js +6 -112
- package/dist/platform/knowledge/memory/memory-lifecycle.js.map +1 -1
- package/dist/platform/knowledge/types/learning.d.ts +2 -2
- package/dist/platform/observation/capability-detector/prompts.d.ts +18 -0
- package/dist/platform/observation/capability-detector/prompts.d.ts.map +1 -0
- package/dist/platform/observation/capability-detector/prompts.js +80 -0
- package/dist/platform/observation/capability-detector/prompts.js.map +1 -0
- package/dist/platform/observation/capability-detector/recommendations.d.ts +5 -0
- package/dist/platform/observation/capability-detector/recommendations.d.ts.map +1 -0
- package/dist/platform/observation/capability-detector/recommendations.js +76 -0
- package/dist/platform/observation/capability-detector/recommendations.js.map +1 -0
- package/dist/platform/observation/capability-detector/types.d.ts +112 -0
- package/dist/platform/observation/capability-detector/types.d.ts.map +1 -0
- package/dist/platform/observation/capability-detector/types.js +75 -0
- package/dist/platform/observation/capability-detector/types.js.map +1 -0
- package/dist/platform/observation/capability-detector.d.ts +4 -9
- package/dist/platform/observation/capability-detector.d.ts.map +1 -1
- package/dist/platform/observation/capability-detector.js +12 -212
- package/dist/platform/observation/capability-detector.js.map +1 -1
- package/dist/platform/observation/context-provider/collector.d.ts +13 -0
- package/dist/platform/observation/context-provider/collector.d.ts.map +1 -0
- package/dist/platform/observation/context-provider/collector.js +259 -0
- package/dist/platform/observation/context-provider/collector.js.map +1 -0
- package/dist/platform/observation/context-provider/search-terms.d.ts +2 -0
- package/dist/platform/observation/context-provider/search-terms.d.ts.map +1 -0
- package/dist/platform/observation/context-provider/search-terms.js +24 -0
- package/dist/platform/observation/context-provider/search-terms.js.map +1 -0
- package/dist/platform/observation/context-provider/shared.d.ts +17 -0
- package/dist/platform/observation/context-provider/shared.d.ts.map +1 -0
- package/dist/platform/observation/context-provider/shared.js +87 -0
- package/dist/platform/observation/context-provider/shared.js.map +1 -0
- package/dist/platform/observation/context-provider.d.ts +3 -28
- package/dist/platform/observation/context-provider.d.ts.map +1 -1
- package/dist/platform/observation/context-provider.js +7 -395
- package/dist/platform/observation/context-provider.js.map +1 -1
- package/dist/platform/observation/data-source-adapter.d.ts +1 -0
- package/dist/platform/observation/data-source-adapter.d.ts.map +1 -1
- package/dist/platform/observation/data-source-adapter.js.map +1 -1
- package/dist/platform/observation/observation-datasource.d.ts.map +1 -1
- package/dist/platform/observation/observation-datasource.js +2 -0
- package/dist/platform/observation/observation-datasource.js.map +1 -1
- package/dist/platform/observation/types/data-source.d.ts +153 -9
- package/dist/platform/observation/types/data-source.d.ts.map +1 -1
- package/dist/platform/observation/types/data-source.js +13 -1
- package/dist/platform/observation/types/data-source.js.map +1 -1
- package/dist/platform/soil/compiled-memory-projections.d.ts +2 -0
- package/dist/platform/soil/compiled-memory-projections.d.ts.map +1 -1
- package/dist/platform/soil/compiled-memory-projections.js +59 -0
- package/dist/platform/soil/compiled-memory-projections.js.map +1 -1
- package/dist/platform/soil/contracts.d.ts +67 -67
- package/dist/platform/soil/importer.d.ts +6 -6
- package/dist/platform/soil/retriever.d.ts +25 -0
- package/dist/platform/soil/retriever.d.ts.map +1 -1
- package/dist/platform/soil/retriever.js +94 -5
- package/dist/platform/soil/retriever.js.map +1 -1
- package/dist/platform/soil/sqlite-repository-helpers.d.ts +80 -0
- package/dist/platform/soil/sqlite-repository-helpers.d.ts.map +1 -0
- package/dist/platform/soil/sqlite-repository-helpers.js +143 -0
- package/dist/platform/soil/sqlite-repository-helpers.js.map +1 -0
- package/dist/platform/soil/sqlite-repository-search.d.ts +8 -0
- package/dist/platform/soil/sqlite-repository-search.d.ts.map +1 -0
- package/dist/platform/soil/sqlite-repository-search.js +367 -0
- package/dist/platform/soil/sqlite-repository-search.js.map +1 -0
- package/dist/platform/soil/sqlite-repository-storage.d.ts +8 -0
- package/dist/platform/soil/sqlite-repository-storage.d.ts.map +1 -0
- package/dist/platform/soil/sqlite-repository-storage.js +278 -0
- package/dist/platform/soil/sqlite-repository-storage.js.map +1 -0
- package/dist/platform/soil/sqlite-repository.d.ts +1 -4
- package/dist/platform/soil/sqlite-repository.d.ts.map +1 -1
- package/dist/platform/soil/sqlite-repository.js +26 -820
- package/dist/platform/soil/sqlite-repository.js.map +1 -1
- package/dist/platform/soil/types.d.ts +8 -8
- package/dist/platform/time/deadline-finalization.d.ts +57 -0
- package/dist/platform/time/deadline-finalization.d.ts.map +1 -0
- package/dist/platform/time/deadline-finalization.js +136 -0
- package/dist/platform/time/deadline-finalization.js.map +1 -0
- package/dist/platform/time/execution-mode.d.ts +29 -0
- package/dist/platform/time/execution-mode.d.ts.map +1 -0
- package/dist/platform/time/execution-mode.js +84 -0
- package/dist/platform/time/execution-mode.js.map +1 -0
- package/dist/platform/traits/types/curiosity.d.ts +9 -9
- package/dist/platform/traits/types/guardrail.d.ts +6 -6
- package/dist/reporting/report-formatters.d.ts.map +1 -1
- package/dist/reporting/report-formatters.js +67 -2
- package/dist/reporting/report-formatters.js.map +1 -1
- package/dist/reporting/reporting-engine.d.ts.map +1 -1
- package/dist/reporting/reporting-engine.js +3 -1
- package/dist/reporting/reporting-engine.js.map +1 -1
- package/dist/reporting/reporting-types.d.ts +4 -0
- package/dist/reporting/reporting-types.d.ts.map +1 -1
- package/dist/reporting/types/report.d.ts +59 -0
- package/dist/reporting/types/report.d.ts.map +1 -1
- package/dist/reporting/types/report.js +9 -0
- package/dist/reporting/types/report.js.map +1 -1
- package/dist/runtime/command-dispatcher.d.ts +2 -0
- package/dist/runtime/command-dispatcher.d.ts.map +1 -1
- package/dist/runtime/command-dispatcher.js +16 -0
- package/dist/runtime/command-dispatcher.js.map +1 -1
- package/dist/runtime/confirmation-decision.d.ts +94 -0
- package/dist/runtime/confirmation-decision.d.ts.map +1 -0
- package/dist/runtime/confirmation-decision.js +109 -0
- package/dist/runtime/confirmation-decision.js.map +1 -0
- package/dist/runtime/control/daemon-runtime-control-executor.d.ts.map +1 -1
- package/dist/runtime/control/daemon-runtime-control-executor.js +31 -1
- package/dist/runtime/control/daemon-runtime-control-executor.js.map +1 -1
- package/dist/runtime/control/runtime-control-intent.d.ts +9 -1
- package/dist/runtime/control/runtime-control-intent.d.ts.map +1 -1
- package/dist/runtime/control/runtime-control-intent.js +82 -16
- package/dist/runtime/control/runtime-control-intent.js.map +1 -1
- package/dist/runtime/control/runtime-control-service.d.ts +35 -1
- package/dist/runtime/control/runtime-control-service.d.ts.map +1 -1
- package/dist/runtime/control/runtime-control-service.js +285 -5
- package/dist/runtime/control/runtime-control-service.js.map +1 -1
- package/dist/runtime/daemon/client.d.ts +12 -0
- package/dist/runtime/daemon/client.d.ts.map +1 -1
- package/dist/runtime/daemon/client.js +9 -0
- package/dist/runtime/daemon/client.js.map +1 -1
- package/dist/runtime/daemon/index.d.ts +1 -1
- package/dist/runtime/daemon/index.d.ts.map +1 -1
- package/dist/runtime/daemon/index.js +1 -1
- package/dist/runtime/daemon/index.js.map +1 -1
- package/dist/runtime/daemon/maintenance.d.ts +2 -10
- package/dist/runtime/daemon/maintenance.d.ts.map +1 -1
- package/dist/runtime/daemon/maintenance.js +14 -45
- package/dist/runtime/daemon/maintenance.js.map +1 -1
- package/dist/runtime/daemon/runner-bootstrap.d.ts +25 -0
- package/dist/runtime/daemon/runner-bootstrap.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-bootstrap.js +77 -0
- package/dist/runtime/daemon/runner-bootstrap.js.map +1 -0
- package/dist/runtime/daemon/runner-commands.d.ts +13 -9
- package/dist/runtime/daemon/runner-commands.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-commands.js +272 -21
- package/dist/runtime/daemon/runner-commands.js.map +1 -1
- package/dist/runtime/daemon/runner-goal-cycle.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-goal-cycle.js +62 -6
- package/dist/runtime/daemon/runner-goal-cycle.js.map +1 -1
- package/dist/runtime/daemon/runner-resident-curiosity.d.ts +12 -0
- package/dist/runtime/daemon/runner-resident-curiosity.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-resident-curiosity.js +155 -0
- package/dist/runtime/daemon/runner-resident-curiosity.js.map +1 -0
- package/dist/runtime/daemon/runner-resident-dream.d.ts +20 -0
- package/dist/runtime/daemon/runner-resident-dream.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-resident-dream.js +148 -0
- package/dist/runtime/daemon/runner-resident-dream.js.map +1 -0
- package/dist/runtime/daemon/runner-resident-proactive.d.ts +4 -0
- package/dist/runtime/daemon/runner-resident-proactive.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-resident-proactive.js +113 -0
- package/dist/runtime/daemon/runner-resident-proactive.js.map +1 -0
- package/dist/runtime/daemon/runner-resident-shared.d.ts +40 -0
- package/dist/runtime/daemon/runner-resident-shared.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-resident-shared.js +101 -0
- package/dist/runtime/daemon/runner-resident-shared.js.map +1 -0
- package/dist/runtime/daemon/runner-resident.d.ts +4 -68
- package/dist/runtime/daemon/runner-resident.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-resident.js +4 -506
- package/dist/runtime/daemon/runner-resident.js.map +1 -1
- package/dist/runtime/daemon/runner-runtime.d.ts +12 -0
- package/dist/runtime/daemon/runner-runtime.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-runtime.js +43 -0
- package/dist/runtime/daemon/runner-runtime.js.map +1 -0
- package/dist/runtime/daemon/runner-startup.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-startup.js +15 -6
- package/dist/runtime/daemon/runner-startup.js.map +1 -1
- package/dist/runtime/daemon/runner.d.ts +14 -23
- package/dist/runtime/daemon/runner.d.ts.map +1 -1
- package/dist/runtime/daemon/runner.js +40 -110
- package/dist/runtime/daemon/runner.js.map +1 -1
- package/dist/runtime/daemon/runtime-ownership.d.ts +9 -0
- package/dist/runtime/daemon/runtime-ownership.d.ts.map +1 -1
- package/dist/runtime/daemon/runtime-ownership.js +248 -1
- package/dist/runtime/daemon/runtime-ownership.js.map +1 -1
- package/dist/runtime/daemon/wait-deadline-resolver.d.ts +5 -2
- package/dist/runtime/daemon/wait-deadline-resolver.d.ts.map +1 -1
- package/dist/runtime/daemon/wait-deadline-resolver.js +55 -35
- package/dist/runtime/daemon/wait-deadline-resolver.js.map +1 -1
- package/dist/runtime/dream-sidecar-review.d.ts +92 -0
- package/dist/runtime/dream-sidecar-review.d.ts.map +1 -0
- package/dist/runtime/dream-sidecar-review.js +495 -0
- package/dist/runtime/dream-sidecar-review.js.map +1 -0
- package/dist/runtime/event/dispatcher.d.ts +0 -2
- package/dist/runtime/event/dispatcher.d.ts.map +1 -1
- package/dist/runtime/event/dispatcher.js +0 -4
- package/dist/runtime/event/dispatcher.js.map +1 -1
- package/dist/runtime/event/server-command-handler.d.ts +2 -4
- package/dist/runtime/event/server-command-handler.d.ts.map +1 -1
- package/dist/runtime/event/server-command-handler.js +36 -6
- package/dist/runtime/event/server-command-handler.js.map +1 -1
- package/dist/runtime/event/server-snapshot-reader.d.ts +15 -1
- package/dist/runtime/event/server-snapshot-reader.d.ts.map +1 -1
- package/dist/runtime/event/server-snapshot-reader.js +66 -2
- package/dist/runtime/event/server-snapshot-reader.js.map +1 -1
- package/dist/runtime/event/server-types.d.ts +7 -0
- package/dist/runtime/event/server-types.d.ts.map +1 -1
- package/dist/runtime/event/server.d.ts +5 -0
- package/dist/runtime/event/server.d.ts.map +1 -1
- package/dist/runtime/event/server.js +43 -11
- package/dist/runtime/event/server.js.map +1 -1
- package/dist/runtime/evidence-answer.d.ts +41 -0
- package/dist/runtime/evidence-answer.d.ts.map +1 -0
- package/dist/runtime/evidence-answer.js +366 -0
- package/dist/runtime/evidence-answer.js.map +1 -0
- package/dist/runtime/executor/goal-worker.d.ts +6 -2
- package/dist/runtime/executor/goal-worker.d.ts.map +1 -1
- package/dist/runtime/executor/goal-worker.js +7 -2
- package/dist/runtime/executor/goal-worker.js.map +1 -1
- package/dist/runtime/executor/loop-supervisor.d.ts +7 -0
- package/dist/runtime/executor/loop-supervisor.d.ts.map +1 -1
- package/dist/runtime/executor/loop-supervisor.js +72 -17
- package/dist/runtime/executor/loop-supervisor.js.map +1 -1
- package/dist/runtime/guardrails/backpressure-controller.d.ts +32 -0
- package/dist/runtime/guardrails/backpressure-controller.d.ts.map +1 -0
- package/dist/runtime/guardrails/backpressure-controller.js +88 -0
- package/dist/runtime/guardrails/backpressure-controller.js.map +1 -0
- package/dist/runtime/guardrails/circuit-breaker.d.ts +32 -0
- package/dist/runtime/guardrails/circuit-breaker.d.ts.map +1 -0
- package/dist/runtime/guardrails/circuit-breaker.js +88 -0
- package/dist/runtime/guardrails/circuit-breaker.js.map +1 -0
- package/dist/runtime/guardrails/guardrail-store.d.ts +23 -0
- package/dist/runtime/guardrails/guardrail-store.d.ts.map +1 -0
- package/dist/runtime/guardrails/guardrail-store.js +95 -0
- package/dist/runtime/guardrails/guardrail-store.js.map +1 -0
- package/dist/runtime/guardrails/index.d.ts +4 -0
- package/dist/runtime/guardrails/index.d.ts.map +1 -0
- package/dist/runtime/guardrails/index.js +4 -0
- package/dist/runtime/guardrails/index.js.map +1 -0
- package/dist/runtime/interactive-automation/browser-session-store.d.ts +43 -0
- package/dist/runtime/interactive-automation/browser-session-store.d.ts.map +1 -0
- package/dist/runtime/interactive-automation/browser-session-store.js +104 -0
- package/dist/runtime/interactive-automation/browser-session-store.js.map +1 -0
- package/dist/runtime/interactive-automation/failure-classifier.d.ts +12 -0
- package/dist/runtime/interactive-automation/failure-classifier.d.ts.map +1 -0
- package/dist/runtime/interactive-automation/failure-classifier.js +50 -0
- package/dist/runtime/interactive-automation/failure-classifier.js.map +1 -0
- package/dist/runtime/interactive-automation/index.d.ts +2 -0
- package/dist/runtime/interactive-automation/index.d.ts.map +1 -1
- package/dist/runtime/interactive-automation/index.js +2 -0
- package/dist/runtime/interactive-automation/index.js.map +1 -1
- package/dist/runtime/interactive-automation/providers/manus-browser.d.ts.map +1 -1
- package/dist/runtime/interactive-automation/providers/manus-browser.js +17 -1
- package/dist/runtime/interactive-automation/providers/manus-browser.js.map +1 -1
- package/dist/runtime/interactive-automation/types.d.ts +4 -0
- package/dist/runtime/interactive-automation/types.d.ts.map +1 -1
- package/dist/runtime/interactive-automation/types.js.map +1 -1
- package/dist/runtime/notification-routing.d.ts +45 -2
- package/dist/runtime/notification-routing.d.ts.map +1 -1
- package/dist/runtime/notification-routing.js +196 -79
- package/dist/runtime/notification-routing.js.map +1 -1
- package/dist/runtime/run-spec/confirmation.d.ts +34 -0
- package/dist/runtime/run-spec/confirmation.d.ts.map +1 -0
- package/dist/runtime/run-spec/confirmation.js +176 -0
- package/dist/runtime/run-spec/confirmation.js.map +1 -0
- package/dist/runtime/run-spec/derive.d.ts +284 -0
- package/dist/runtime/run-spec/derive.d.ts.map +1 -0
- package/dist/runtime/run-spec/derive.js +379 -0
- package/dist/runtime/run-spec/derive.js.map +1 -0
- package/dist/runtime/run-spec/index.d.ts +5 -0
- package/dist/runtime/run-spec/index.d.ts.map +1 -0
- package/dist/runtime/run-spec/index.js +5 -0
- package/dist/runtime/run-spec/index.js.map +1 -0
- package/dist/runtime/run-spec/store.d.ts +11 -0
- package/dist/runtime/run-spec/store.d.ts.map +1 -0
- package/dist/runtime/run-spec/store.js +36 -0
- package/dist/runtime/run-spec/store.js.map +1 -0
- package/dist/runtime/run-spec/types.d.ts +495 -0
- package/dist/runtime/run-spec/types.d.ts.map +1 -0
- package/dist/runtime/run-spec/types.js +87 -0
- package/dist/runtime/run-spec/types.js.map +1 -0
- package/dist/runtime/schedule/engine-cron-reflection.d.ts +31 -0
- package/dist/runtime/schedule/engine-cron-reflection.d.ts.map +1 -0
- package/dist/runtime/schedule/engine-cron-reflection.js +229 -0
- package/dist/runtime/schedule/engine-cron-reflection.js.map +1 -0
- package/dist/runtime/schedule/engine-execution.d.ts +48 -0
- package/dist/runtime/schedule/engine-execution.d.ts.map +1 -0
- package/dist/runtime/schedule/engine-execution.js +424 -0
- package/dist/runtime/schedule/engine-execution.js.map +1 -0
- package/dist/runtime/schedule/engine-heartbeat.d.ts +5 -0
- package/dist/runtime/schedule/engine-heartbeat.d.ts.map +1 -0
- package/dist/runtime/schedule/engine-heartbeat.js +104 -0
- package/dist/runtime/schedule/engine-heartbeat.js.map +1 -0
- package/dist/runtime/schedule/engine-layers.d.ts +4 -1
- package/dist/runtime/schedule/engine-layers.d.ts.map +1 -1
- package/dist/runtime/schedule/engine-layers.js +15 -229
- package/dist/runtime/schedule/engine-layers.js.map +1 -1
- package/dist/runtime/schedule/engine-mutations.d.ts +37 -0
- package/dist/runtime/schedule/engine-mutations.d.ts.map +1 -0
- package/dist/runtime/schedule/engine-mutations.js +263 -0
- package/dist/runtime/schedule/engine-mutations.js.map +1 -0
- package/dist/runtime/schedule/engine.d.ts +13 -39
- package/dist/runtime/schedule/engine.d.ts.map +1 -1
- package/dist/runtime/schedule/engine.js +65 -810
- package/dist/runtime/schedule/engine.js.map +1 -1
- package/dist/runtime/schedule/history.d.ts +20 -4
- package/dist/runtime/schedule/history.d.ts.map +1 -1
- package/dist/runtime/schedule/history.js +8 -0
- package/dist/runtime/schedule/history.js.map +1 -1
- package/dist/runtime/schedule/index.d.ts +1 -0
- package/dist/runtime/schedule/index.d.ts.map +1 -1
- package/dist/runtime/schedule/index.js +1 -0
- package/dist/runtime/schedule/index.js.map +1 -1
- package/dist/runtime/schedule/legacy-cron-migration.d.ts +9 -0
- package/dist/runtime/schedule/legacy-cron-migration.d.ts.map +1 -0
- package/dist/runtime/schedule/legacy-cron-migration.js +89 -0
- package/dist/runtime/schedule/legacy-cron-migration.js.map +1 -0
- package/dist/runtime/schedule/wait-projection.d.ts +6 -0
- package/dist/runtime/schedule/wait-projection.d.ts.map +1 -0
- package/dist/runtime/schedule/wait-projection.js +102 -0
- package/dist/runtime/schedule/wait-projection.js.map +1 -0
- package/dist/runtime/session-registry/registry-helpers.d.ts +34 -0
- package/dist/runtime/session-registry/registry-helpers.d.ts.map +1 -0
- package/dist/runtime/session-registry/registry-helpers.js +241 -0
- package/dist/runtime/session-registry/registry-helpers.js.map +1 -0
- package/dist/runtime/session-registry/registry.d.ts.map +1 -1
- package/dist/runtime/session-registry/registry.js +16 -243
- package/dist/runtime/session-registry/registry.js.map +1 -1
- package/dist/runtime/session-registry/types.d.ts +138 -130
- package/dist/runtime/session-registry/types.d.ts.map +1 -1
- package/dist/runtime/session-registry/types.js +2 -0
- package/dist/runtime/session-registry/types.js.map +1 -1
- package/dist/runtime/store/artifact-retention.d.ts +44 -0
- package/dist/runtime/store/artifact-retention.d.ts.map +1 -0
- package/dist/runtime/store/artifact-retention.js +263 -0
- package/dist/runtime/store/artifact-retention.js.map +1 -0
- package/dist/runtime/store/background-run-store.d.ts +1 -0
- package/dist/runtime/store/background-run-store.d.ts.map +1 -1
- package/dist/runtime/store/background-run-store.js +1 -0
- package/dist/runtime/store/background-run-store.js.map +1 -1
- package/dist/runtime/store/budget-store.d.ts +442 -0
- package/dist/runtime/store/budget-store.d.ts.map +1 -0
- package/dist/runtime/store/budget-store.js +318 -0
- package/dist/runtime/store/budget-store.js.map +1 -0
- package/dist/runtime/store/dream-checkpoints.d.ts +9 -0
- package/dist/runtime/store/dream-checkpoints.d.ts.map +1 -0
- package/dist/runtime/store/dream-checkpoints.js +16 -0
- package/dist/runtime/store/dream-checkpoints.js.map +1 -0
- package/dist/runtime/store/evaluator-results.d.ts +97 -0
- package/dist/runtime/store/evaluator-results.d.ts.map +1 -0
- package/dist/runtime/store/evaluator-results.js +355 -0
- package/dist/runtime/store/evaluator-results.js.map +1 -0
- package/dist/runtime/store/evidence-ledger.d.ts +5298 -0
- package/dist/runtime/store/evidence-ledger.d.ts.map +1 -0
- package/dist/runtime/store/evidence-ledger.js +1452 -0
- package/dist/runtime/store/evidence-ledger.js.map +1 -0
- package/dist/runtime/store/experiment-queue-store.d.ts +1164 -0
- package/dist/runtime/store/experiment-queue-store.d.ts.map +1 -0
- package/dist/runtime/store/experiment-queue-store.js +341 -0
- package/dist/runtime/store/experiment-queue-store.js.map +1 -0
- package/dist/runtime/store/health-store.d.ts.map +1 -1
- package/dist/runtime/store/health-store.js +6 -0
- package/dist/runtime/store/health-store.js.map +1 -1
- package/dist/runtime/store/index.d.ts +25 -2
- package/dist/runtime/store/index.d.ts.map +1 -1
- package/dist/runtime/store/index.js +13 -1
- package/dist/runtime/store/index.js.map +1 -1
- package/dist/runtime/store/metric-history.d.ts +10 -0
- package/dist/runtime/store/metric-history.d.ts.map +1 -0
- package/dist/runtime/store/metric-history.js +56 -0
- package/dist/runtime/store/metric-history.js.map +1 -0
- package/dist/runtime/store/operator-handoff-store.d.ts +179 -0
- package/dist/runtime/store/operator-handoff-store.d.ts.map +1 -0
- package/dist/runtime/store/operator-handoff-store.js +120 -0
- package/dist/runtime/store/operator-handoff-store.js.map +1 -0
- package/dist/runtime/store/postmortem-report.d.ts +485 -0
- package/dist/runtime/store/postmortem-report.d.ts.map +1 -0
- package/dist/runtime/store/postmortem-report.js +561 -0
- package/dist/runtime/store/postmortem-report.js.map +1 -0
- package/dist/runtime/store/reproducibility-manifest.d.ts +565 -0
- package/dist/runtime/store/reproducibility-manifest.d.ts.map +1 -0
- package/dist/runtime/store/reproducibility-manifest.js +392 -0
- package/dist/runtime/store/reproducibility-manifest.js.map +1 -0
- package/dist/runtime/store/research-evidence.d.ts +8 -0
- package/dist/runtime/store/research-evidence.d.ts.map +1 -0
- package/dist/runtime/store/research-evidence.js +15 -0
- package/dist/runtime/store/research-evidence.js.map +1 -0
- package/dist/runtime/store/runtime-operation-schemas.d.ts +80 -34
- package/dist/runtime/store/runtime-operation-schemas.d.ts.map +1 -1
- package/dist/runtime/store/runtime-operation-schemas.js +16 -1
- package/dist/runtime/store/runtime-operation-schemas.js.map +1 -1
- package/dist/runtime/store/runtime-paths.d.ts +25 -0
- package/dist/runtime/store/runtime-paths.d.ts.map +1 -1
- package/dist/runtime/store/runtime-paths.js +73 -0
- package/dist/runtime/store/runtime-paths.js.map +1 -1
- package/dist/runtime/store/runtime-schemas.d.ts +1934 -15
- package/dist/runtime/store/runtime-schemas.d.ts.map +1 -1
- package/dist/runtime/store/runtime-schemas.js +201 -0
- package/dist/runtime/store/runtime-schemas.js.map +1 -1
- package/dist/runtime/store/safe-pause-store.d.ts +28 -0
- package/dist/runtime/store/safe-pause-store.d.ts.map +1 -0
- package/dist/runtime/store/safe-pause-store.js +103 -0
- package/dist/runtime/store/safe-pause-store.js.map +1 -0
- package/dist/runtime/types/daemon.d.ts +234 -14
- package/dist/runtime/types/daemon.d.ts.map +1 -1
- package/dist/runtime/types/daemon.js +29 -2
- package/dist/runtime/types/daemon.js.map +1 -1
- package/dist/runtime/types/envelope.d.ts +10 -10
- package/dist/runtime/types/hook.d.ts +9 -9
- package/dist/runtime/types/notification.d.ts +6 -6
- package/dist/runtime/types/plugin.d.ts +2 -2
- package/dist/runtime/types/schedule.d.ts +162 -54
- package/dist/runtime/types/schedule.d.ts.map +1 -1
- package/dist/runtime/types/schedule.js +15 -1
- package/dist/runtime/types/schedule.js.map +1 -1
- package/dist/runtime/types/trigger.d.ts +2 -2
- package/dist/tools/automation/InteractiveAutomationTools.d.ts +10 -0
- package/dist/tools/automation/InteractiveAutomationTools.d.ts.map +1 -1
- package/dist/tools/automation/InteractiveAutomationTools.js +139 -8
- package/dist/tools/automation/InteractiveAutomationTools.js.map +1 -1
- package/dist/tools/builtin/exports.d.ts +2 -1
- package/dist/tools/builtin/exports.d.ts.map +1 -1
- package/dist/tools/builtin/exports.js +2 -1
- package/dist/tools/builtin/exports.js.map +1 -1
- package/dist/tools/builtin/factory.d.ts +7 -0
- package/dist/tools/builtin/factory.d.ts.map +1 -1
- package/dist/tools/builtin/factory.js +26 -3
- package/dist/tools/builtin/factory.js.map +1 -1
- package/dist/tools/fs/FileValidationTool/protected-path-policy.d.ts +1 -0
- package/dist/tools/fs/FileValidationTool/protected-path-policy.d.ts.map +1 -1
- package/dist/tools/fs/FileValidationTool/protected-path-policy.js +17 -4
- package/dist/tools/fs/FileValidationTool/protected-path-policy.js.map +1 -1
- package/dist/tools/fs/ListDirTool/ListDirTool.js +1 -1
- package/dist/tools/fs/ListDirTool/ListDirTool.js.map +1 -1
- package/dist/tools/kaggle/KaggleExperimentTools.d.ts +792 -8
- package/dist/tools/kaggle/KaggleExperimentTools.d.ts.map +1 -1
- package/dist/tools/kaggle/KaggleExperimentTools.js +284 -19
- package/dist/tools/kaggle/KaggleExperimentTools.js.map +1 -1
- package/dist/tools/kaggle/KaggleSubmissionTools.d.ts +18 -12
- package/dist/tools/kaggle/KaggleSubmissionTools.d.ts.map +1 -1
- package/dist/tools/kaggle/KaggleSubmissionTools.js +23 -4
- package/dist/tools/kaggle/KaggleSubmissionTools.js.map +1 -1
- package/dist/tools/kaggle/KaggleWorkspacePrepareTool.d.ts +28 -9
- package/dist/tools/kaggle/KaggleWorkspacePrepareTool.d.ts.map +1 -1
- package/dist/tools/kaggle/KaggleWorkspacePrepareTool.js +182 -4
- package/dist/tools/kaggle/KaggleWorkspacePrepareTool.js.map +1 -1
- package/dist/tools/kaggle/index.d.ts +1 -1
- package/dist/tools/kaggle/index.d.ts.map +1 -1
- package/dist/tools/kaggle/index.js +1 -1
- package/dist/tools/kaggle/index.js.map +1 -1
- package/dist/tools/kaggle/metrics.d.ts +845 -4
- package/dist/tools/kaggle/metrics.d.ts.map +1 -1
- package/dist/tools/kaggle/metrics.js +410 -1
- package/dist/tools/kaggle/metrics.js.map +1 -1
- package/dist/tools/kaggle/paths.d.ts.map +1 -1
- package/dist/tools/kaggle/paths.js +6 -0
- package/dist/tools/kaggle/paths.js.map +1 -1
- package/dist/tools/mutation/ConfigureNotificationRoutingTool/ConfigureNotificationRoutingTool.d.ts +6 -0
- package/dist/tools/mutation/ConfigureNotificationRoutingTool/ConfigureNotificationRoutingTool.d.ts.map +1 -1
- package/dist/tools/mutation/ConfigureNotificationRoutingTool/ConfigureNotificationRoutingTool.js +9 -2
- package/dist/tools/mutation/ConfigureNotificationRoutingTool/ConfigureNotificationRoutingTool.js.map +1 -1
- package/dist/tools/mutation/TaskCreateTool/TaskCreateTool.d.ts +4 -4
- package/dist/tools/network/McpStdioTool/McpStdioTool.d.ts +4 -4
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.d.ts.map +1 -1
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.js +23 -2
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.js.map +1 -1
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.d.ts.map +1 -1
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.js +24 -2
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.js.map +1 -1
- package/dist/tools/query/MemoryRecallTool/MemoryRecallTool.d.ts +2 -2
- package/dist/tools/query/SoilQueryTool/SoilQueryTool.d.ts.map +1 -1
- package/dist/tools/query/SoilQueryTool/SoilQueryTool.js +43 -9
- package/dist/tools/query/SoilQueryTool/SoilQueryTool.js.map +1 -1
- package/dist/tools/query/code-search-root.d.ts +8 -0
- package/dist/tools/query/code-search-root.d.ts.map +1 -0
- package/dist/tools/query/code-search-root.js +41 -0
- package/dist/tools/query/code-search-root.js.map +1 -0
- package/dist/tools/query/runtime-dream-review-tool.d.ts +34 -0
- package/dist/tools/query/runtime-dream-review-tool.d.ts.map +1 -0
- package/dist/tools/query/runtime-dream-review-tool.js +62 -0
- package/dist/tools/query/runtime-dream-review-tool.js.map +1 -0
- package/dist/tools/query/runtime-session-tools.d.ts +560 -0
- package/dist/tools/query/runtime-session-tools.d.ts.map +1 -0
- package/dist/tools/query/runtime-session-tools.js +1017 -0
- package/dist/tools/query/runtime-session-tools.js.map +1 -0
- package/dist/tools/runtime/LongRunningRuntimeTools.d.ts +821 -0
- package/dist/tools/runtime/LongRunningRuntimeTools.d.ts.map +1 -0
- package/dist/tools/runtime/LongRunningRuntimeTools.js +905 -0
- package/dist/tools/runtime/LongRunningRuntimeTools.js.map +1 -0
- package/dist/tools/schedule/CreateScheduleTool/CreateScheduleTool.d.ts +62 -32
- package/dist/tools/schedule/CreateScheduleTool/CreateScheduleTool.d.ts.map +1 -1
- package/dist/tools/schedule/UpdateScheduleTool/UpdateScheduleTool.d.ts +78 -44
- package/dist/tools/schedule/UpdateScheduleTool/UpdateScheduleTool.d.ts.map +1 -1
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.d.ts +1 -0
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.d.ts.map +1 -1
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.js +11 -0
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.js.map +1 -1
- package/dist/tools/system/ShellTool/ShellTool.d.ts.map +1 -1
- package/dist/tools/system/ShellTool/ShellTool.js +2 -1
- package/dist/tools/system/ShellTool/ShellTool.js.map +1 -1
- package/dist/tools/system/TestRunnerTool/TestRunnerTool.d.ts +4 -4
- package/dist/tools/types.d.ts +2 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/package.json +2 -1
- package/dist/base/types/cron.d.ts +0 -2
- package/dist/base/types/cron.d.ts.map +0 -1
- package/dist/base/types/cron.js +0 -3
- package/dist/base/types/cron.js.map +0 -1
- package/dist/runtime/cron-scheduler.d.ts +0 -13
- package/dist/runtime/cron-scheduler.d.ts.map +0 -1
- package/dist/runtime/cron-scheduler.js +0 -90
- package/dist/runtime/cron-scheduler.js.map +0 -1
- package/dist/runtime/types/cron.d.ts +0 -59
- package/dist/runtime/types/cron.d.ts.map +0 -1
- package/dist/runtime/types/cron.js +0 -13
- package/dist/runtime/types/cron.js.map +0 -1
|
@@ -0,0 +1,1452 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import * as fsp from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { createRuntimeStorePaths, ensureRuntimeStorePaths, } from "./runtime-paths.js";
|
|
6
|
+
import { summarizeEvidenceMetricTrends } from "./metric-history.js";
|
|
7
|
+
import { summarizeEvidenceEvaluatorResults, } from "./evaluator-results.js";
|
|
8
|
+
import { summarizeEvidenceResearchMemos, } from "./research-evidence.js";
|
|
9
|
+
import { summarizeEvidenceDreamCheckpoints, } from "./dream-checkpoints.js";
|
|
10
|
+
import { summarizeArtifactRetention, RuntimeArtifactRetentionClassSchema, } from "./artifact-retention.js";
|
|
11
|
+
export const RuntimeEvidenceOutcomeSchema = z.enum([
|
|
12
|
+
"improved",
|
|
13
|
+
"regressed",
|
|
14
|
+
"inconclusive",
|
|
15
|
+
"failed",
|
|
16
|
+
"blocked",
|
|
17
|
+
"continued",
|
|
18
|
+
]);
|
|
19
|
+
export const RuntimeEvidenceEntryKindSchema = z.enum([
|
|
20
|
+
"observation",
|
|
21
|
+
"strategy",
|
|
22
|
+
"task_generation",
|
|
23
|
+
"execution",
|
|
24
|
+
"verification",
|
|
25
|
+
"decision",
|
|
26
|
+
"metric",
|
|
27
|
+
"evaluator",
|
|
28
|
+
"research",
|
|
29
|
+
"dream_checkpoint",
|
|
30
|
+
"artifact",
|
|
31
|
+
"failure",
|
|
32
|
+
"other",
|
|
33
|
+
]);
|
|
34
|
+
export const RuntimeEvidenceArtifactRefSchema = z.object({
|
|
35
|
+
label: z.string().min(1),
|
|
36
|
+
path: z.string().min(1).optional(),
|
|
37
|
+
state_relative_path: z.string().min(1).optional(),
|
|
38
|
+
url: z.string().url().optional(),
|
|
39
|
+
kind: z.enum(["log", "metrics", "report", "diff", "url", "other"]).default("other"),
|
|
40
|
+
retention_class: RuntimeArtifactRetentionClassSchema.optional(),
|
|
41
|
+
size_bytes: z.number().int().nonnegative().optional(),
|
|
42
|
+
source: z.string().min(1).optional(),
|
|
43
|
+
dependency_refs: z.array(z.string().min(1)).optional(),
|
|
44
|
+
}).strict();
|
|
45
|
+
export const RuntimeEvidenceMetricSchema = z.object({
|
|
46
|
+
label: z.string().min(1),
|
|
47
|
+
value: z.union([z.string(), z.number(), z.boolean(), z.null()]).optional(),
|
|
48
|
+
unit: z.string().min(1).optional(),
|
|
49
|
+
direction: z.enum(["maximize", "minimize", "neutral"]).optional(),
|
|
50
|
+
confidence: z.number().min(0).max(1).optional(),
|
|
51
|
+
observed_at: z.string().datetime().optional(),
|
|
52
|
+
source: z.string().min(1).optional(),
|
|
53
|
+
summary: z.string().min(1).optional(),
|
|
54
|
+
}).strict();
|
|
55
|
+
export const RuntimeEvidenceCandidateDispositionSchema = z.enum(["retained", "promoted", "retired"]);
|
|
56
|
+
export const RuntimeEvidenceCandidateLineageSchema = z.object({
|
|
57
|
+
parent_candidate_id: z.string().min(1).optional(),
|
|
58
|
+
source_candidate_id: z.string().min(1).optional(),
|
|
59
|
+
source_strategy_id: z.string().min(1).optional(),
|
|
60
|
+
source_strategy: z.string().min(1).optional(),
|
|
61
|
+
strategy_family: z.string().min(1),
|
|
62
|
+
feature_lineage: z.array(z.string().min(1)).default([]),
|
|
63
|
+
model_lineage: z.array(z.string().min(1)).default([]),
|
|
64
|
+
config_lineage: z.array(z.string().min(1)).default([]),
|
|
65
|
+
seed_lineage: z.array(z.string().min(1)).default([]),
|
|
66
|
+
fold_lineage: z.array(z.string().min(1)).default([]),
|
|
67
|
+
postprocess_lineage: z.array(z.string().min(1)).default([]),
|
|
68
|
+
notes: z.string().min(1).optional(),
|
|
69
|
+
}).strict();
|
|
70
|
+
export const RuntimeEvidenceCandidateSimilaritySchema = z.object({
|
|
71
|
+
candidate_id: z.string().min(1),
|
|
72
|
+
similarity: z.number().min(0).max(1),
|
|
73
|
+
signal: z.enum(["declared", "lineage", "metric_correlation", "artifact_overlap", "other"]).default("declared"),
|
|
74
|
+
summary: z.string().min(1).optional(),
|
|
75
|
+
}).strict();
|
|
76
|
+
export const RuntimeEvidenceCandidateNearMissReasonSchema = z.enum([
|
|
77
|
+
"close_to_best",
|
|
78
|
+
"stability",
|
|
79
|
+
"novelty",
|
|
80
|
+
"weak_dimension_improvement",
|
|
81
|
+
"complementarity",
|
|
82
|
+
"ensemble_potential",
|
|
83
|
+
]);
|
|
84
|
+
export const RuntimeEvidenceCandidateNearMissSchema = z.object({
|
|
85
|
+
status: z.enum(["retained", "promoted", "rejected"]).default("retained"),
|
|
86
|
+
reason_to_keep: z.array(RuntimeEvidenceCandidateNearMissReasonSchema).min(1),
|
|
87
|
+
margin_to_best: z.number().min(0).optional(),
|
|
88
|
+
weak_dimensions: z.array(z.string().min(1)).default([]),
|
|
89
|
+
complementary_candidate_ids: z.array(z.string().min(1)).default([]),
|
|
90
|
+
follow_up: z.object({
|
|
91
|
+
title: z.string().min(1),
|
|
92
|
+
rationale: z.string().min(1),
|
|
93
|
+
target_dimensions: z.array(z.string().min(1)).default([]),
|
|
94
|
+
expected_evidence_gain: z.string().min(1).optional(),
|
|
95
|
+
}).strict().optional(),
|
|
96
|
+
evidence_refs: z.array(z.string().min(1)).default([]),
|
|
97
|
+
summary: z.string().min(1).optional(),
|
|
98
|
+
}).strict();
|
|
99
|
+
export const RuntimeEvidenceCandidateRecordSchema = z.object({
|
|
100
|
+
candidate_id: z.string().min(1),
|
|
101
|
+
label: z.string().min(1).optional(),
|
|
102
|
+
lineage: RuntimeEvidenceCandidateLineageSchema,
|
|
103
|
+
metrics: z.array(RuntimeEvidenceMetricSchema).default([]),
|
|
104
|
+
artifacts: z.array(RuntimeEvidenceArtifactRefSchema).default([]),
|
|
105
|
+
similarity: z.array(RuntimeEvidenceCandidateSimilaritySchema).default([]),
|
|
106
|
+
robustness: z.object({
|
|
107
|
+
stability_score: z.number().min(0).max(1).optional(),
|
|
108
|
+
diversity_score: z.number().min(0).max(1).optional(),
|
|
109
|
+
risk_penalty: z.number().min(0).max(1).optional(),
|
|
110
|
+
robust_score: z.number().min(0).max(1).optional(),
|
|
111
|
+
evidence_confidence: z.number().min(0).max(1).optional(),
|
|
112
|
+
repeated_evaluations: z.number().int().nonnegative().optional(),
|
|
113
|
+
mean_score: z.number().optional(),
|
|
114
|
+
max_score: z.number().optional(),
|
|
115
|
+
score_stddev: z.number().min(0).optional(),
|
|
116
|
+
fold_score_range: z.number().min(0).optional(),
|
|
117
|
+
seed_score_range: z.number().min(0).optional(),
|
|
118
|
+
weak_dimensions: z.array(z.string().min(1)).default([]),
|
|
119
|
+
provenance_refs: z.array(z.string().min(1)).default([]),
|
|
120
|
+
summary: z.string().min(1).optional(),
|
|
121
|
+
}).strict().optional(),
|
|
122
|
+
near_miss: RuntimeEvidenceCandidateNearMissSchema.optional(),
|
|
123
|
+
disposition: RuntimeEvidenceCandidateDispositionSchema.default("retained"),
|
|
124
|
+
disposition_reason: z.string().min(1).optional(),
|
|
125
|
+
produced_at: z.string().datetime().optional(),
|
|
126
|
+
}).strict();
|
|
127
|
+
export const RuntimeEvidenceEvaluatorSignalSchema = z.enum(["local", "external"]);
|
|
128
|
+
export const RuntimeEvidenceEvaluatorStatusSchema = z.enum([
|
|
129
|
+
"pending",
|
|
130
|
+
"ready",
|
|
131
|
+
"approval_required",
|
|
132
|
+
"submitted",
|
|
133
|
+
"passed",
|
|
134
|
+
"succeeded",
|
|
135
|
+
"completed",
|
|
136
|
+
"failed",
|
|
137
|
+
"regressed",
|
|
138
|
+
"blocked",
|
|
139
|
+
"unknown",
|
|
140
|
+
]);
|
|
141
|
+
export const RuntimeEvidenceEvaluatorPublishActionSchema = z.object({
|
|
142
|
+
id: z.string().min(1),
|
|
143
|
+
label: z.string().min(1),
|
|
144
|
+
tool_name: z.string().min(1).optional(),
|
|
145
|
+
payload_ref: z.string().min(1).optional(),
|
|
146
|
+
approval_required: z.literal(true).default(true),
|
|
147
|
+
status: z.enum(["approval_required", "approved", "submitted", "completed", "blocked"]).optional(),
|
|
148
|
+
}).strict();
|
|
149
|
+
export const RuntimeEvidenceEvaluatorValidationSchema = z.object({
|
|
150
|
+
status: z.enum(["pending", "passed", "failed", "blocked", "unknown"]).default("unknown"),
|
|
151
|
+
command: z.string().min(1).optional(),
|
|
152
|
+
summary: z.string().min(1).optional(),
|
|
153
|
+
}).strict();
|
|
154
|
+
export const RuntimeEvidenceEvaluatorProvenanceSchema = z.object({
|
|
155
|
+
kind: z.enum(["local_command", "external_url", "ci", "benchmark", "human_review", "other"]).default("other"),
|
|
156
|
+
command: z.string().min(1).optional(),
|
|
157
|
+
url: z.string().url().optional(),
|
|
158
|
+
run_id: z.string().min(1).optional(),
|
|
159
|
+
external_id: z.string().min(1).optional(),
|
|
160
|
+
raw_ref: z.string().min(1).optional(),
|
|
161
|
+
retrieved_at: z.string().datetime().optional(),
|
|
162
|
+
}).strict();
|
|
163
|
+
export const RuntimeEvidenceEvaluatorBudgetSchema = z.object({
|
|
164
|
+
policy_id: z.string().min(1).optional(),
|
|
165
|
+
max_attempts: z.number().int().positive().optional(),
|
|
166
|
+
used_attempts: z.number().int().nonnegative().optional(),
|
|
167
|
+
remaining_attempts: z.number().int().nonnegative(),
|
|
168
|
+
approval_required: z.boolean().default(true),
|
|
169
|
+
deadline_at: z.string().datetime().optional(),
|
|
170
|
+
phase: z.enum(["exploration", "consolidation", "finalization", "other"]).optional(),
|
|
171
|
+
portfolio_policy: z.object({
|
|
172
|
+
diversified_portfolio_required: z.boolean().default(false),
|
|
173
|
+
reserve_for_finalization: z.boolean().default(false),
|
|
174
|
+
min_strategy_families: z.number().int().positive().optional(),
|
|
175
|
+
}).strict().optional(),
|
|
176
|
+
}).strict();
|
|
177
|
+
export const RuntimeEvidenceEvaluatorCandidateSnapshotSchema = z.object({
|
|
178
|
+
evidence_entry_id: z.string().min(1).optional(),
|
|
179
|
+
primary_metric_label: z.string().min(1).optional(),
|
|
180
|
+
local_metrics: z.array(RuntimeEvidenceMetricSchema).default([]),
|
|
181
|
+
robust_selection: z.object({
|
|
182
|
+
raw_rank: z.number().int().positive().optional(),
|
|
183
|
+
robust_score: z.number().min(0).max(1).optional(),
|
|
184
|
+
stability_score: z.number().min(0).max(1).optional(),
|
|
185
|
+
diversity_score: z.number().min(0).max(1).optional(),
|
|
186
|
+
risk_penalty: z.number().min(0).max(1).optional(),
|
|
187
|
+
portfolio_role: z.enum(["raw_best", "robust_best", "safe", "aggressive", "diverse", "near_miss", "other"]).optional(),
|
|
188
|
+
}).strict().optional(),
|
|
189
|
+
summary: z.string().min(1).optional(),
|
|
190
|
+
}).strict();
|
|
191
|
+
export const RuntimeEvidenceEvaluatorCalibrationSchema = z.object({
|
|
192
|
+
mode: z.literal("calibration_only").default("calibration_only"),
|
|
193
|
+
use_for_selection: z.boolean().default(false),
|
|
194
|
+
direct_optimization_allowed: z.literal(false).default(false),
|
|
195
|
+
minimum_observations: z.number().int().positive().default(1),
|
|
196
|
+
conclusion: z.string().min(1).optional(),
|
|
197
|
+
}).strict();
|
|
198
|
+
export const RuntimeEvidenceEvaluatorObservationSchema = z.object({
|
|
199
|
+
evaluator_id: z.string().min(1),
|
|
200
|
+
signal: RuntimeEvidenceEvaluatorSignalSchema,
|
|
201
|
+
source: z.string().min(1),
|
|
202
|
+
candidate_id: z.string().min(1),
|
|
203
|
+
candidate_label: z.string().min(1).optional(),
|
|
204
|
+
artifact_labels: z.array(z.string().min(1)).optional(),
|
|
205
|
+
status: RuntimeEvidenceEvaluatorStatusSchema.default("unknown"),
|
|
206
|
+
score: z.union([z.string(), z.number(), z.boolean(), z.null()]).optional(),
|
|
207
|
+
score_label: z.string().min(1).optional(),
|
|
208
|
+
direction: z.enum(["maximize", "minimize", "neutral"]).optional(),
|
|
209
|
+
observed_at: z.string().datetime().optional(),
|
|
210
|
+
expected_score: z.union([z.string(), z.number(), z.boolean(), z.null()]).optional(),
|
|
211
|
+
expected_status: RuntimeEvidenceEvaluatorStatusSchema.optional(),
|
|
212
|
+
expectation_source: z.string().min(1).optional(),
|
|
213
|
+
validation: RuntimeEvidenceEvaluatorValidationSchema.optional(),
|
|
214
|
+
publish_action: RuntimeEvidenceEvaluatorPublishActionSchema.optional(),
|
|
215
|
+
provenance: RuntimeEvidenceEvaluatorProvenanceSchema.optional(),
|
|
216
|
+
budget: RuntimeEvidenceEvaluatorBudgetSchema.optional(),
|
|
217
|
+
candidate_snapshot: RuntimeEvidenceEvaluatorCandidateSnapshotSchema.optional(),
|
|
218
|
+
calibration: RuntimeEvidenceEvaluatorCalibrationSchema.optional(),
|
|
219
|
+
summary: z.string().min(1).optional(),
|
|
220
|
+
}).strict();
|
|
221
|
+
export const RuntimeEvidenceResearchSourceSchema = z.object({
|
|
222
|
+
url: z.string().url(),
|
|
223
|
+
title: z.string().min(1).optional(),
|
|
224
|
+
source_type: z.enum(["official_docs", "maintainer", "paper", "issue_thread", "example", "writeup", "other"]).default("other"),
|
|
225
|
+
provenance: z.enum(["quoted", "paraphrased", "summarized"]).default("summarized"),
|
|
226
|
+
relevance: z.string().min(1).optional(),
|
|
227
|
+
}).strict();
|
|
228
|
+
export const RuntimeEvidenceResearchFindingSchema = z.object({
|
|
229
|
+
finding: z.string().min(1),
|
|
230
|
+
source_urls: z.array(z.string().url()).min(1),
|
|
231
|
+
applicability: z.string().min(1),
|
|
232
|
+
risks_constraints: z.array(z.string().min(1)).default([]),
|
|
233
|
+
proposed_experiment: z.string().min(1),
|
|
234
|
+
expected_metric_impact: z.string().min(1),
|
|
235
|
+
fact_vs_adaptation: z.object({
|
|
236
|
+
facts: z.array(z.string().min(1)).default([]),
|
|
237
|
+
adaptation: z.string().min(1),
|
|
238
|
+
}).strict(),
|
|
239
|
+
}).strict();
|
|
240
|
+
export const RuntimeEvidenceResearchExternalActionSchema = z.object({
|
|
241
|
+
label: z.string().min(1),
|
|
242
|
+
reason: z.string().min(1),
|
|
243
|
+
approval_required: z.literal(true).default(true),
|
|
244
|
+
}).strict();
|
|
245
|
+
export const RuntimeEvidenceResearchMemoSchema = z.object({
|
|
246
|
+
trigger: z.enum(["plateau", "uncertainty", "knowledge_gap"]),
|
|
247
|
+
query: z.string().min(1),
|
|
248
|
+
summary: z.string().min(1),
|
|
249
|
+
sources: z.array(RuntimeEvidenceResearchSourceSchema).min(1),
|
|
250
|
+
findings: z.array(RuntimeEvidenceResearchFindingSchema).min(1),
|
|
251
|
+
candidate_playbook: z.object({
|
|
252
|
+
title: z.string().min(1),
|
|
253
|
+
steps: z.array(z.string().min(1)).default([]),
|
|
254
|
+
source_urls: z.array(z.string().url()).default([]),
|
|
255
|
+
}).strict().optional(),
|
|
256
|
+
untrusted_content_policy: z.literal("webpage_instructions_are_untrusted").default("webpage_instructions_are_untrusted"),
|
|
257
|
+
external_actions: z.array(RuntimeEvidenceResearchExternalActionSchema).default([]),
|
|
258
|
+
confidence: z.number().min(0).max(1).default(0.5),
|
|
259
|
+
}).strict();
|
|
260
|
+
export const RuntimeEvidenceDreamCheckpointTriggerSchema = z.enum([
|
|
261
|
+
"iteration",
|
|
262
|
+
"plateau",
|
|
263
|
+
"breakthrough",
|
|
264
|
+
"pre_finalization",
|
|
265
|
+
]);
|
|
266
|
+
export const RuntimeEvidenceDreamCheckpointMemoryRefSchema = z.object({
|
|
267
|
+
source_type: z.enum(["soil", "playbook", "runtime_evidence", "other"]),
|
|
268
|
+
ref: z.string().min(1).optional(),
|
|
269
|
+
summary: z.string().min(1),
|
|
270
|
+
authority: z.literal("advisory_only").default("advisory_only"),
|
|
271
|
+
relevance_score: z.number().min(0).max(1).optional(),
|
|
272
|
+
source_reliability: z.number().min(0).max(1).optional(),
|
|
273
|
+
recency_score: z.number().min(0).max(1).optional(),
|
|
274
|
+
prior_success_contribution: z.number().min(0).max(1).optional(),
|
|
275
|
+
retrieval: z.object({
|
|
276
|
+
kind: z.enum(["route_hit", "fallback_hit", "checkpoint", "manual", "unknown"]).default("unknown"),
|
|
277
|
+
score: z.number().min(0).max(1).optional(),
|
|
278
|
+
confidence: z.number().min(0).max(1).optional(),
|
|
279
|
+
}).strict().optional(),
|
|
280
|
+
ranking_trace: z.object({
|
|
281
|
+
score: z.number().min(0).max(1),
|
|
282
|
+
decision: z.enum(["admitted", "rejected"]),
|
|
283
|
+
reason: z.string().min(1),
|
|
284
|
+
}).strict().optional(),
|
|
285
|
+
}).strict();
|
|
286
|
+
export const RuntimeEvidenceDreamCheckpointStrategyCandidateSchema = z.object({
|
|
287
|
+
title: z.string().min(1),
|
|
288
|
+
rationale: z.string().min(1),
|
|
289
|
+
target_dimensions: z.array(z.string().min(1)).default([]),
|
|
290
|
+
expected_evidence_gain: z.string().min(1).optional(),
|
|
291
|
+
retry_reason: z.string().min(1).optional(),
|
|
292
|
+
failed_lineage_warning: z.object({
|
|
293
|
+
fingerprint: z.string().min(1),
|
|
294
|
+
count: z.number().int().positive(),
|
|
295
|
+
reason: z.string().min(1),
|
|
296
|
+
}).strict().optional(),
|
|
297
|
+
}).strict();
|
|
298
|
+
export const RuntimeEvidenceDreamCheckpointActiveHypothesisSchema = z.object({
|
|
299
|
+
hypothesis: z.string().min(1),
|
|
300
|
+
supporting_evidence_ref: z.string().min(1).optional(),
|
|
301
|
+
target_metric_or_dimension: z.string().min(1),
|
|
302
|
+
expected_next_observation: z.string().min(1),
|
|
303
|
+
status: z.enum(["active", "testing", "supported", "weakened"]).default("active"),
|
|
304
|
+
}).strict();
|
|
305
|
+
export const RuntimeEvidenceDreamCheckpointRejectedApproachSchema = z.object({
|
|
306
|
+
approach: z.string().min(1),
|
|
307
|
+
rejection_reason: z.string().min(1),
|
|
308
|
+
evidence_ref: z.string().min(1).optional(),
|
|
309
|
+
revisit_condition: z.string().min(1).optional(),
|
|
310
|
+
confidence: z.number().min(0).max(1).default(0.5),
|
|
311
|
+
}).strict();
|
|
312
|
+
export const RuntimeEvidenceDreamRunControlRecommendationSchema = z.object({
|
|
313
|
+
id: z.string().min(1).optional(),
|
|
314
|
+
action: z.enum([
|
|
315
|
+
"stay_current_mode",
|
|
316
|
+
"widen_exploration",
|
|
317
|
+
"consolidate_candidates",
|
|
318
|
+
"freeze_experiment_queue",
|
|
319
|
+
"enter_finalization",
|
|
320
|
+
"preserve_near_miss_candidates",
|
|
321
|
+
"retire_low_value_lineage",
|
|
322
|
+
"request_operator_approval",
|
|
323
|
+
]),
|
|
324
|
+
rationale: z.string().min(1),
|
|
325
|
+
evidence: z.array(z.object({
|
|
326
|
+
kind: z.enum(["metric", "artifact", "lineage", "task_history", "deadline", "external_feedback", "memory", "runtime_state"]),
|
|
327
|
+
ref: z.string().min(1).optional(),
|
|
328
|
+
summary: z.string().min(1),
|
|
329
|
+
}).strict()).min(1),
|
|
330
|
+
target_mode: z.enum(["exploration", "consolidation", "finalization"]).optional(),
|
|
331
|
+
target_strategy_family: z.string().min(1).optional(),
|
|
332
|
+
candidate_refs: z.array(z.string().min(1)).default([]),
|
|
333
|
+
lineage_refs: z.array(z.string().min(1)).default([]),
|
|
334
|
+
approval_required: z.boolean().default(false),
|
|
335
|
+
risk: z.enum(["low", "medium", "high"]).default("medium"),
|
|
336
|
+
confidence: z.number().min(0).max(1).default(0.5),
|
|
337
|
+
policy_decision: z.object({
|
|
338
|
+
disposition: z.enum(["auto_apply", "approval_required", "advisory_only"]),
|
|
339
|
+
reason: z.string().min(1),
|
|
340
|
+
}).strict().optional(),
|
|
341
|
+
}).strict();
|
|
342
|
+
export const RuntimeEvidenceDreamCheckpointSchema = z.object({
|
|
343
|
+
trigger: RuntimeEvidenceDreamCheckpointTriggerSchema,
|
|
344
|
+
summary: z.string().min(1),
|
|
345
|
+
current_goal: z.string().min(1),
|
|
346
|
+
active_dimensions: z.array(z.string().min(1)).default([]),
|
|
347
|
+
best_evidence_so_far: z.string().min(1).optional(),
|
|
348
|
+
recent_strategy_families: z.array(z.string().min(1)).default([]),
|
|
349
|
+
exhausted: z.array(z.string().min(1)).default([]),
|
|
350
|
+
promising: z.array(z.string().min(1)).default([]),
|
|
351
|
+
relevant_memories: z.array(RuntimeEvidenceDreamCheckpointMemoryRefSchema).default([]),
|
|
352
|
+
active_hypotheses: z.array(RuntimeEvidenceDreamCheckpointActiveHypothesisSchema).default([]),
|
|
353
|
+
rejected_approaches: z.array(RuntimeEvidenceDreamCheckpointRejectedApproachSchema).default([]),
|
|
354
|
+
next_strategy_candidates: z.array(RuntimeEvidenceDreamCheckpointStrategyCandidateSchema).default([]),
|
|
355
|
+
run_control_recommendations: z.array(RuntimeEvidenceDreamRunControlRecommendationSchema).optional(),
|
|
356
|
+
guidance: z.string().min(1),
|
|
357
|
+
uncertainty: z.array(z.string().min(1)).default([]),
|
|
358
|
+
context_authority: z.literal("advisory_only").default("advisory_only"),
|
|
359
|
+
confidence: z.number().min(0).max(1).default(0.5),
|
|
360
|
+
}).strict();
|
|
361
|
+
export const RuntimeEvidenceDivergentHypothesisSchema = z.object({
|
|
362
|
+
strategy_id: z.string().min(1).optional(),
|
|
363
|
+
hypothesis: z.string().min(1),
|
|
364
|
+
strategy_family: z.string().min(1),
|
|
365
|
+
role: z.enum(["exploitation", "adjacent_exploration", "divergent_exploration"]),
|
|
366
|
+
novelty_score: z.number().min(0).max(1),
|
|
367
|
+
similarity_to_recent_failures: z.number().min(0).max(1).default(0),
|
|
368
|
+
expected_cost: z.enum(["low", "medium", "high"]),
|
|
369
|
+
relationship_to_lineage: z.enum([
|
|
370
|
+
"current_best",
|
|
371
|
+
"neighbor",
|
|
372
|
+
"failed_lineage",
|
|
373
|
+
"different_mechanism",
|
|
374
|
+
"different_assumption",
|
|
375
|
+
"unknown",
|
|
376
|
+
]),
|
|
377
|
+
prior_evidence: z.string().min(1).optional(),
|
|
378
|
+
downrank_reason: z.string().min(1).optional(),
|
|
379
|
+
smoke_status: z.enum(["not_run", "promote", "defer", "retire"]).default("not_run"),
|
|
380
|
+
smoke_reason: z.string().min(1).optional(),
|
|
381
|
+
smoke_evidence_ref: z.string().min(1).optional(),
|
|
382
|
+
evidence_authority: z.literal("speculative_hypothesis").default("speculative_hypothesis"),
|
|
383
|
+
}).strict();
|
|
384
|
+
export const RuntimeEvidenceEntrySchema = z.object({
|
|
385
|
+
schema_version: z.literal("runtime-evidence-entry-v1"),
|
|
386
|
+
id: z.string().min(1),
|
|
387
|
+
occurred_at: z.string().datetime(),
|
|
388
|
+
kind: RuntimeEvidenceEntryKindSchema,
|
|
389
|
+
scope: z.object({
|
|
390
|
+
goal_id: z.string().min(1).optional(),
|
|
391
|
+
run_id: z.string().min(1).optional(),
|
|
392
|
+
task_id: z.string().min(1).optional(),
|
|
393
|
+
loop_index: z.number().int().nonnegative().optional(),
|
|
394
|
+
phase: z.string().min(1).optional(),
|
|
395
|
+
}).strict(),
|
|
396
|
+
hypothesis: z.string().min(1).optional(),
|
|
397
|
+
strategy: z.string().min(1).optional(),
|
|
398
|
+
task: z.object({
|
|
399
|
+
id: z.string().min(1).optional(),
|
|
400
|
+
description: z.string().min(1).optional(),
|
|
401
|
+
action: z.string().min(1).optional(),
|
|
402
|
+
primary_dimension: z.string().min(1).optional(),
|
|
403
|
+
}).strict().optional(),
|
|
404
|
+
verification: z.object({
|
|
405
|
+
command: z.string().min(1).optional(),
|
|
406
|
+
verdict: z.string().min(1).optional(),
|
|
407
|
+
confidence: z.number().min(0).max(1).optional(),
|
|
408
|
+
summary: z.string().min(1).optional(),
|
|
409
|
+
}).strict().optional(),
|
|
410
|
+
metrics: z.array(RuntimeEvidenceMetricSchema).default([]),
|
|
411
|
+
evaluators: z.array(RuntimeEvidenceEvaluatorObservationSchema).optional(),
|
|
412
|
+
research: z.array(RuntimeEvidenceResearchMemoSchema).optional(),
|
|
413
|
+
dream_checkpoints: z.array(RuntimeEvidenceDreamCheckpointSchema).optional(),
|
|
414
|
+
divergent_exploration: z.array(RuntimeEvidenceDivergentHypothesisSchema).optional(),
|
|
415
|
+
candidates: z.array(RuntimeEvidenceCandidateRecordSchema).optional(),
|
|
416
|
+
artifacts: z.array(RuntimeEvidenceArtifactRefSchema).default([]),
|
|
417
|
+
result: z.object({
|
|
418
|
+
status: z.string().min(1).optional(),
|
|
419
|
+
summary: z.string().min(1).optional(),
|
|
420
|
+
error: z.string().min(1).optional(),
|
|
421
|
+
}).strict().optional(),
|
|
422
|
+
outcome: RuntimeEvidenceOutcomeSchema.optional(),
|
|
423
|
+
decision_reason: z.string().min(1).optional(),
|
|
424
|
+
raw_refs: z.array(z.object({
|
|
425
|
+
kind: z.string().min(1),
|
|
426
|
+
id: z.string().min(1).optional(),
|
|
427
|
+
path: z.string().min(1).optional(),
|
|
428
|
+
state_relative_path: z.string().min(1).optional(),
|
|
429
|
+
url: z.string().url().optional(),
|
|
430
|
+
}).strict()).default([]),
|
|
431
|
+
summary: z.string().min(1).optional(),
|
|
432
|
+
}).strict().refine((entry) => entry.scope.goal_id || entry.scope.run_id, {
|
|
433
|
+
message: "goal_id or run_id is required",
|
|
434
|
+
path: ["scope"],
|
|
435
|
+
});
|
|
436
|
+
export class RuntimeEvidenceLedger {
|
|
437
|
+
paths;
|
|
438
|
+
constructor(runtimeRootOrPaths) {
|
|
439
|
+
this.paths =
|
|
440
|
+
typeof runtimeRootOrPaths === "string"
|
|
441
|
+
? createRuntimeStorePaths(runtimeRootOrPaths)
|
|
442
|
+
: runtimeRootOrPaths ?? createRuntimeStorePaths();
|
|
443
|
+
}
|
|
444
|
+
async ensureReady() {
|
|
445
|
+
await ensureRuntimeStorePaths(this.paths);
|
|
446
|
+
}
|
|
447
|
+
goalPath(goalId) {
|
|
448
|
+
return this.paths.evidenceGoalPath(goalId);
|
|
449
|
+
}
|
|
450
|
+
runPath(runId) {
|
|
451
|
+
return this.paths.evidenceRunPath(runId);
|
|
452
|
+
}
|
|
453
|
+
async append(input) {
|
|
454
|
+
const entry = RuntimeEvidenceEntrySchema.parse({
|
|
455
|
+
schema_version: "runtime-evidence-entry-v1",
|
|
456
|
+
id: input.id ?? randomUUID(),
|
|
457
|
+
occurred_at: input.occurred_at ?? new Date().toISOString(),
|
|
458
|
+
metrics: input.metrics ?? [],
|
|
459
|
+
evaluators: input.evaluators ?? [],
|
|
460
|
+
research: input.research ?? [],
|
|
461
|
+
dream_checkpoints: input.dream_checkpoints ?? [],
|
|
462
|
+
divergent_exploration: input.divergent_exploration ?? [],
|
|
463
|
+
candidates: input.candidates ?? [],
|
|
464
|
+
artifacts: input.artifacts ?? [],
|
|
465
|
+
raw_refs: input.raw_refs ?? [],
|
|
466
|
+
...input,
|
|
467
|
+
});
|
|
468
|
+
await this.ensureReady();
|
|
469
|
+
const targets = new Set();
|
|
470
|
+
if (entry.scope.goal_id)
|
|
471
|
+
targets.add(this.paths.evidenceGoalPath(entry.scope.goal_id));
|
|
472
|
+
if (entry.scope.run_id)
|
|
473
|
+
targets.add(this.paths.evidenceRunPath(entry.scope.run_id));
|
|
474
|
+
await Promise.all([...targets].map(async (target) => {
|
|
475
|
+
await fsp.mkdir(path.dirname(target), { recursive: true });
|
|
476
|
+
await fsp.appendFile(target, `${JSON.stringify(entry)}\n`, "utf8");
|
|
477
|
+
}));
|
|
478
|
+
await Promise.all([...targets].map(async (target) => {
|
|
479
|
+
await rebuildSummaryIndex(target, this.paths);
|
|
480
|
+
}));
|
|
481
|
+
return [entry];
|
|
482
|
+
}
|
|
483
|
+
async readByGoal(goalId) {
|
|
484
|
+
return readEvidenceFile(this.paths.evidenceGoalPath(goalId));
|
|
485
|
+
}
|
|
486
|
+
async readByRun(runId) {
|
|
487
|
+
return readEvidenceFile(this.paths.evidenceRunPath(runId));
|
|
488
|
+
}
|
|
489
|
+
async summarizeGoal(goalId) {
|
|
490
|
+
const manifests = await readReproducibilityManifests(this.paths, { goal_id: goalId });
|
|
491
|
+
const indexed = manifests.length === 0
|
|
492
|
+
? await readSummaryIndex(this.paths.evidenceGoalPath(goalId), { goal_id: goalId })
|
|
493
|
+
: null;
|
|
494
|
+
if (indexed)
|
|
495
|
+
return indexed.summary;
|
|
496
|
+
const read = await this.readByGoal(goalId);
|
|
497
|
+
const summary = summarizeEvidence({ goal_id: goalId }, read, manifests);
|
|
498
|
+
return summary;
|
|
499
|
+
}
|
|
500
|
+
async summarizeRun(runId) {
|
|
501
|
+
const manifests = await readReproducibilityManifests(this.paths, { run_id: runId });
|
|
502
|
+
const indexed = manifests.length === 0
|
|
503
|
+
? await readSummaryIndex(this.paths.evidenceRunPath(runId), { run_id: runId })
|
|
504
|
+
: null;
|
|
505
|
+
if (indexed)
|
|
506
|
+
return indexed.summary;
|
|
507
|
+
const read = await this.readByRun(runId);
|
|
508
|
+
const summary = summarizeEvidence({ run_id: runId }, read, manifests);
|
|
509
|
+
return summary;
|
|
510
|
+
}
|
|
511
|
+
async rebuildSummaryIndexForGoal(goalId) {
|
|
512
|
+
return rebuildSummaryIndex(this.paths.evidenceGoalPath(goalId), this.paths);
|
|
513
|
+
}
|
|
514
|
+
async rebuildSummaryIndexForRun(runId) {
|
|
515
|
+
return rebuildSummaryIndex(this.paths.evidenceRunPath(runId), this.paths);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
async function rebuildSummaryIndex(canonicalPath, paths) {
|
|
519
|
+
const scope = summaryScopeFromPath(canonicalPath);
|
|
520
|
+
const read = await readEvidenceFile(canonicalPath);
|
|
521
|
+
const manifests = await readReproducibilityManifests(paths, scope);
|
|
522
|
+
const summary = summarizeEvidence(scope, read, manifests);
|
|
523
|
+
await writeSummaryIndex(canonicalPath, summary);
|
|
524
|
+
return summary;
|
|
525
|
+
}
|
|
526
|
+
function summaryIndexPath(canonicalPath) {
|
|
527
|
+
return `${canonicalPath}.summary.json`;
|
|
528
|
+
}
|
|
529
|
+
function summaryScopeFromPath(canonicalPath) {
|
|
530
|
+
const basename = path.basename(canonicalPath, ".jsonl");
|
|
531
|
+
const decoded = decodeURIComponent(basename);
|
|
532
|
+
return canonicalPath.includes(`${path.sep}runs${path.sep}`) ? { run_id: decoded } : { goal_id: decoded };
|
|
533
|
+
}
|
|
534
|
+
async function readReproducibilityManifests(paths, scope) {
|
|
535
|
+
let fileNames;
|
|
536
|
+
try {
|
|
537
|
+
fileNames = await fsp.readdir(paths.reproducibilityManifestsDir);
|
|
538
|
+
}
|
|
539
|
+
catch (err) {
|
|
540
|
+
if (err.code === "ENOENT")
|
|
541
|
+
return [];
|
|
542
|
+
throw err;
|
|
543
|
+
}
|
|
544
|
+
const manifests = [];
|
|
545
|
+
for (const fileName of fileNames) {
|
|
546
|
+
if (!fileName.endsWith(".json"))
|
|
547
|
+
continue;
|
|
548
|
+
try {
|
|
549
|
+
const parsed = JSON.parse(await fsp.readFile(path.join(paths.reproducibilityManifestsDir, fileName), "utf8"));
|
|
550
|
+
if (parsed.schema_version !== "runtime-reproducibility-manifest-v1")
|
|
551
|
+
continue;
|
|
552
|
+
if (scope.goal_id && parsed.scope?.goal_id !== scope.goal_id)
|
|
553
|
+
continue;
|
|
554
|
+
if (scope.run_id && parsed.scope?.run_id !== scope.run_id)
|
|
555
|
+
continue;
|
|
556
|
+
manifests.push({
|
|
557
|
+
...parsed,
|
|
558
|
+
artifacts: Array.isArray(parsed.artifacts) ? parsed.artifacts.filter(isManifestArtifactRef) : [],
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
catch {
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return manifests;
|
|
566
|
+
}
|
|
567
|
+
function isManifestArtifactRef(value) {
|
|
568
|
+
return typeof value === "object"
|
|
569
|
+
&& value !== null
|
|
570
|
+
&& typeof value.label === "string";
|
|
571
|
+
}
|
|
572
|
+
async function readSummaryIndex(canonicalPath, expectedScope) {
|
|
573
|
+
let text;
|
|
574
|
+
try {
|
|
575
|
+
text = await fsp.readFile(summaryIndexPath(canonicalPath), "utf8");
|
|
576
|
+
}
|
|
577
|
+
catch (err) {
|
|
578
|
+
if (err.code === "ENOENT")
|
|
579
|
+
return null;
|
|
580
|
+
throw err;
|
|
581
|
+
}
|
|
582
|
+
try {
|
|
583
|
+
const parsed = JSON.parse(text);
|
|
584
|
+
if (parsed.schema_version !== "runtime-evidence-summary-index-v1")
|
|
585
|
+
return null;
|
|
586
|
+
if (parsed.summary.schema_version !== "runtime-evidence-summary-v1")
|
|
587
|
+
return null;
|
|
588
|
+
if (!isCurrentEvidenceSummaryShape(parsed.summary))
|
|
589
|
+
return null;
|
|
590
|
+
const stat = await fsp.stat(canonicalPath);
|
|
591
|
+
if (parsed.canonical_log_size !== stat.size)
|
|
592
|
+
return null;
|
|
593
|
+
if (parsed.canonical_log_mtime_ms !== stat.mtimeMs)
|
|
594
|
+
return null;
|
|
595
|
+
if (expectedScope.goal_id && parsed.summary.scope.goal_id !== expectedScope.goal_id)
|
|
596
|
+
return null;
|
|
597
|
+
if (expectedScope.run_id && parsed.summary.scope.run_id !== expectedScope.run_id)
|
|
598
|
+
return null;
|
|
599
|
+
return parsed;
|
|
600
|
+
}
|
|
601
|
+
catch {
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
function isCurrentEvidenceSummaryShape(summary) {
|
|
606
|
+
return Array.isArray(summary.candidate_lineages)
|
|
607
|
+
&& Array.isArray(summary.recommended_candidate_portfolio)
|
|
608
|
+
&& Array.isArray(summary.near_miss_candidates)
|
|
609
|
+
&& typeof summary.artifact_retention === "object"
|
|
610
|
+
&& summary.artifact_retention !== null
|
|
611
|
+
&& Array.isArray(summary.evaluator_summary.budgets)
|
|
612
|
+
&& Array.isArray(summary.evaluator_summary.calibration)
|
|
613
|
+
&& typeof summary.candidate_selection_summary === "object"
|
|
614
|
+
&& summary.candidate_selection_summary !== null;
|
|
615
|
+
}
|
|
616
|
+
async function writeSummaryIndex(canonicalPath, summary) {
|
|
617
|
+
const stat = await fsp.stat(canonicalPath);
|
|
618
|
+
const index = {
|
|
619
|
+
schema_version: "runtime-evidence-summary-index-v1",
|
|
620
|
+
generated_at: new Date().toISOString(),
|
|
621
|
+
canonical_log_path: canonicalPath,
|
|
622
|
+
canonical_log_size: stat.size,
|
|
623
|
+
canonical_log_mtime_ms: stat.mtimeMs,
|
|
624
|
+
summary,
|
|
625
|
+
};
|
|
626
|
+
await fsp.mkdir(path.dirname(canonicalPath), { recursive: true });
|
|
627
|
+
await fsp.writeFile(summaryIndexPath(canonicalPath), `${JSON.stringify(index)}\n`, "utf8");
|
|
628
|
+
}
|
|
629
|
+
async function readEvidenceFile(filePath) {
|
|
630
|
+
let text;
|
|
631
|
+
try {
|
|
632
|
+
text = await fsp.readFile(filePath, "utf8");
|
|
633
|
+
}
|
|
634
|
+
catch (err) {
|
|
635
|
+
if (err.code === "ENOENT") {
|
|
636
|
+
return { entries: [], warnings: [] };
|
|
637
|
+
}
|
|
638
|
+
throw err;
|
|
639
|
+
}
|
|
640
|
+
const entries = [];
|
|
641
|
+
const warnings = [];
|
|
642
|
+
const lines = text.split(/\r?\n/);
|
|
643
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
644
|
+
const line = lines[index];
|
|
645
|
+
if (!line?.trim())
|
|
646
|
+
continue;
|
|
647
|
+
try {
|
|
648
|
+
const parsed = RuntimeEvidenceEntrySchema.safeParse(JSON.parse(line));
|
|
649
|
+
if (parsed.success) {
|
|
650
|
+
entries.push(parsed.data);
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
warnings.push({
|
|
654
|
+
file: filePath,
|
|
655
|
+
line: index + 1,
|
|
656
|
+
message: parsed.error.issues.map((issue) => issue.message).join("; "),
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
catch (err) {
|
|
661
|
+
warnings.push({
|
|
662
|
+
file: filePath,
|
|
663
|
+
line: index + 1,
|
|
664
|
+
message: err instanceof Error ? err.message : String(err),
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return { entries, warnings };
|
|
669
|
+
}
|
|
670
|
+
function summarizeEvidence(scope, read, manifests = []) {
|
|
671
|
+
const entries = [...read.entries].sort((a, b) => a.occurred_at.localeCompare(b.occurred_at));
|
|
672
|
+
const newestFirst = [...entries].reverse();
|
|
673
|
+
const evaluatorSummary = summarizeEvidenceEvaluatorResults(entries);
|
|
674
|
+
return {
|
|
675
|
+
schema_version: "runtime-evidence-summary-v1",
|
|
676
|
+
generated_at: new Date().toISOString(),
|
|
677
|
+
scope,
|
|
678
|
+
total_entries: entries.length,
|
|
679
|
+
latest_strategy: newestFirst.find((entry) => entry.kind === "strategy" || Boolean(entry.strategy) || Boolean(entry.decision_reason)) ?? null,
|
|
680
|
+
best_evidence: chooseBestEvidence(newestFirst),
|
|
681
|
+
metric_trends: summarizeEvidenceMetricTrends(entries),
|
|
682
|
+
evaluator_summary: evaluatorSummary,
|
|
683
|
+
research_memos: summarizeEvidenceResearchMemos(entries),
|
|
684
|
+
dream_checkpoints: summarizeEvidenceDreamCheckpoints(entries),
|
|
685
|
+
divergent_exploration: entries
|
|
686
|
+
.flatMap((entry) => entry.divergent_exploration ?? [])
|
|
687
|
+
.slice(-10)
|
|
688
|
+
.reverse(),
|
|
689
|
+
candidate_lineages: summarizeCandidateLineages(entries),
|
|
690
|
+
recommended_candidate_portfolio: selectDiversifiedCandidatePortfolio(entries),
|
|
691
|
+
candidate_selection_summary: summarizeCandidateSelection(entries, evaluatorSummary),
|
|
692
|
+
near_miss_candidates: summarizeNearMissCandidates(entries),
|
|
693
|
+
artifact_retention: summarizeArtifactRetention(entries, { manifests }),
|
|
694
|
+
recent_failed_attempts: newestFirst
|
|
695
|
+
.filter((entry) => entry.outcome === "failed"
|
|
696
|
+
|| entry.outcome === "regressed"
|
|
697
|
+
|| entry.kind === "failure"
|
|
698
|
+
|| entry.result?.status === "failed"
|
|
699
|
+
|| entry.verification?.verdict === "fail")
|
|
700
|
+
.slice(0, 5),
|
|
701
|
+
failed_lineages: summarizeFailedLineages(entries),
|
|
702
|
+
recent_entries: newestFirst.slice(0, 10),
|
|
703
|
+
warnings: read.warnings,
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
export function selectDiversifiedCandidatePortfolio(entriesOldestFirst, options = {}) {
|
|
707
|
+
const limit = options.limit ?? 3;
|
|
708
|
+
if (limit <= 0)
|
|
709
|
+
return [];
|
|
710
|
+
const nearDuplicateSimilarity = options.nearDuplicateSimilarity ?? 0.85;
|
|
711
|
+
const primaryMetric = resolvePrimaryCandidateMetricKey(entriesOldestFirst);
|
|
712
|
+
const candidates = extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric)
|
|
713
|
+
.filter((context) => context.candidate.disposition !== "retired")
|
|
714
|
+
.sort(compareCandidateEvidenceContexts);
|
|
715
|
+
const selected = [];
|
|
716
|
+
const skipped = [];
|
|
717
|
+
for (const candidate of candidates) {
|
|
718
|
+
if (selected.length >= limit)
|
|
719
|
+
break;
|
|
720
|
+
const duplicateSignal = mostSimilarSelectedCandidate(candidate, selected);
|
|
721
|
+
if (duplicateSignal && duplicateSignal.similarity >= nearDuplicateSimilarity) {
|
|
722
|
+
skipped.push({ ...candidate, similarity_to_selected: duplicateSignal });
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
selected.push({
|
|
726
|
+
...candidate,
|
|
727
|
+
role: selected.length === 0 ? "top_metric" : "diverse_representative",
|
|
728
|
+
...(duplicateSignal ? { similarity_to_selected: duplicateSignal } : {}),
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
for (const candidate of skipped) {
|
|
732
|
+
if (selected.length >= limit)
|
|
733
|
+
break;
|
|
734
|
+
selected.push({
|
|
735
|
+
...candidate,
|
|
736
|
+
role: "lineage_representative",
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
return selected.map(toPortfolioSlot);
|
|
740
|
+
}
|
|
741
|
+
function summarizeCandidateSelection(entriesOldestFirst, evaluatorSummary) {
|
|
742
|
+
const primaryMetric = resolvePrimaryCandidateMetricKey(entriesOldestFirst);
|
|
743
|
+
const contexts = extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric)
|
|
744
|
+
.filter((context) => context.candidate.disposition !== "retired");
|
|
745
|
+
const rawRanked = [...contexts].sort(compareCandidateEvidenceContexts);
|
|
746
|
+
const scored = scoreCandidateSelectionContexts(rawRanked, evaluatorSummary?.calibration ?? []);
|
|
747
|
+
const ranked = [...scored].sort((a, b) => b.robust_score - a.robust_score || a.raw_rank - b.raw_rank);
|
|
748
|
+
const rawBest = scored.find((candidate) => candidate.raw_rank === 1) ?? null;
|
|
749
|
+
const robustBest = ranked[0] ?? null;
|
|
750
|
+
return {
|
|
751
|
+
primary_metric: primaryMetric,
|
|
752
|
+
raw_best: rawBest,
|
|
753
|
+
robust_best: robustBest,
|
|
754
|
+
ranked,
|
|
755
|
+
final_portfolio: {
|
|
756
|
+
safe: selectSafeCandidate(scored),
|
|
757
|
+
aggressive: rawBest,
|
|
758
|
+
diverse: selectDiverseCandidate(scored, robustBest),
|
|
759
|
+
},
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
function scoreCandidateSelectionContexts(rawRanked, calibration = []) {
|
|
763
|
+
const metricValues = rawRanked
|
|
764
|
+
.map((context) => context.metric?.value)
|
|
765
|
+
.filter((value) => typeof value === "number" && Number.isFinite(value));
|
|
766
|
+
const minMetric = metricValues.length > 0 ? Math.min(...metricValues) : 0;
|
|
767
|
+
const maxMetric = metricValues.length > 0 ? Math.max(...metricValues) : 0;
|
|
768
|
+
const rawBestFamily = rawRanked[0]?.candidate.lineage.strategy_family;
|
|
769
|
+
const allCandidates = rawRanked.map((context) => context.candidate);
|
|
770
|
+
return rawRanked.map((context, index) => {
|
|
771
|
+
const candidate = context.candidate;
|
|
772
|
+
const metricScore = normalizedMetricScore(context.metric, minMetric, maxMetric);
|
|
773
|
+
const stabilityScore = clamp01(candidate.robustness?.stability_score ?? context.metric?.confidence ?? 0.5);
|
|
774
|
+
const inferredDiversity = inferredDiversityScore(candidate, rawBestFamily, allCandidates);
|
|
775
|
+
const diversityScore = clamp01(candidate.robustness?.diversity_score === undefined
|
|
776
|
+
? inferredDiversity
|
|
777
|
+
: Math.min(candidate.robustness.diversity_score, inferredDiversity));
|
|
778
|
+
const riskPenalty = clamp01(candidate.robustness?.risk_penalty ?? inferredCandidateRiskPenalty(candidate));
|
|
779
|
+
const evidenceConfidence = clamp01(candidate.robustness?.evidence_confidence ?? context.metric?.confidence ?? 0.5);
|
|
780
|
+
const calibrationAdjustment = evaluatorCalibrationAdjustment(candidate.candidate_id, calibration);
|
|
781
|
+
const robustScore = clamp01(candidate.robustness?.robust_score
|
|
782
|
+
?? (metricScore * 0.45 + stabilityScore * 0.3 + diversityScore * 0.15 + evidenceConfidence * 0.1 - riskPenalty + calibrationAdjustment));
|
|
783
|
+
return {
|
|
784
|
+
candidate_id: candidate.candidate_id,
|
|
785
|
+
...(candidate.label ? { label: candidate.label } : {}),
|
|
786
|
+
strategy_family: candidate.lineage.strategy_family,
|
|
787
|
+
evidence_entry_id: context.entry_id,
|
|
788
|
+
raw_rank: index + 1,
|
|
789
|
+
...(context.metric ? { raw_metric: context.metric } : {}),
|
|
790
|
+
robust_score: roundScore(robustScore),
|
|
791
|
+
calibration_adjustment: roundScore(calibrationAdjustment),
|
|
792
|
+
metric_score: roundScore(metricScore),
|
|
793
|
+
stability_score: roundScore(stabilityScore),
|
|
794
|
+
diversity_score: roundScore(diversityScore),
|
|
795
|
+
risk_penalty: roundScore(riskPenalty),
|
|
796
|
+
evidence_confidence: roundScore(evidenceConfidence),
|
|
797
|
+
reasons: candidateSelectionReasons(candidate, {
|
|
798
|
+
metricScore,
|
|
799
|
+
stabilityScore,
|
|
800
|
+
diversityScore,
|
|
801
|
+
riskPenalty,
|
|
802
|
+
evidenceConfidence,
|
|
803
|
+
calibrationAdjustment,
|
|
804
|
+
}),
|
|
805
|
+
};
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
function evaluatorCalibrationAdjustment(candidateId, calibration) {
|
|
809
|
+
const relevant = calibration.filter((item) => item.candidate_id === candidateId
|
|
810
|
+
&& item.use_for_selection
|
|
811
|
+
&& item.direct_optimization_allowed === false);
|
|
812
|
+
if (relevant.length === 0)
|
|
813
|
+
return 0;
|
|
814
|
+
const average = relevant.reduce((sum, item) => sum + item.selection_adjustment, 0) / relevant.length;
|
|
815
|
+
if (relevant.length < Math.max(...relevant.map((item) => item.minimum_observations)))
|
|
816
|
+
return 0;
|
|
817
|
+
return Math.min(0.08, Math.max(-0.08, average));
|
|
818
|
+
}
|
|
819
|
+
function normalizedMetricScore(metric, minMetric, maxMetric) {
|
|
820
|
+
if (!metric)
|
|
821
|
+
return 0;
|
|
822
|
+
if (maxMetric === minMetric)
|
|
823
|
+
return 0.5;
|
|
824
|
+
const distance = metric.direction === "maximize"
|
|
825
|
+
? (metric.value - minMetric) / (maxMetric - minMetric)
|
|
826
|
+
: (maxMetric - metric.value) / (maxMetric - minMetric);
|
|
827
|
+
return clamp01(distance);
|
|
828
|
+
}
|
|
829
|
+
function inferredDiversityScore(candidate, rawBestFamily, allCandidates) {
|
|
830
|
+
if (!rawBestFamily)
|
|
831
|
+
return 0.5;
|
|
832
|
+
const highestSimilarity = highestKnownSimilarity(candidate, allCandidates);
|
|
833
|
+
const lineageBase = candidate.lineage.strategy_family !== rawBestFamily ? 0.75 : 0.45;
|
|
834
|
+
if (highestSimilarity > 0)
|
|
835
|
+
return clamp01(Math.min(lineageBase, 1 - highestSimilarity));
|
|
836
|
+
return lineageBase;
|
|
837
|
+
}
|
|
838
|
+
function highestKnownSimilarity(candidate, allCandidates) {
|
|
839
|
+
let highest = candidate.similarity.reduce((max, similarity) => Math.max(max, similarity.similarity), 0);
|
|
840
|
+
for (const other of allCandidates) {
|
|
841
|
+
if (other.candidate_id === candidate.candidate_id)
|
|
842
|
+
continue;
|
|
843
|
+
for (const similarity of other.similarity) {
|
|
844
|
+
if (similarity.candidate_id === candidate.candidate_id) {
|
|
845
|
+
highest = Math.max(highest, similarity.similarity);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return highest;
|
|
850
|
+
}
|
|
851
|
+
function inferredCandidateRiskPenalty(candidate) {
|
|
852
|
+
const lineageText = [
|
|
853
|
+
...candidate.lineage.config_lineage,
|
|
854
|
+
...candidate.lineage.postprocess_lineage,
|
|
855
|
+
].map(normalizeLineageText).join(" ");
|
|
856
|
+
if (lineageText.includes("manual") || lineageText.includes("threshold") || lineageText.includes("postprocess")) {
|
|
857
|
+
return 0.15;
|
|
858
|
+
}
|
|
859
|
+
if (lineageText.includes("calibration") || lineageText.includes("weight")) {
|
|
860
|
+
return 0.08;
|
|
861
|
+
}
|
|
862
|
+
return 0;
|
|
863
|
+
}
|
|
864
|
+
function candidateSelectionReasons(candidate, scores) {
|
|
865
|
+
const reasons = [];
|
|
866
|
+
if (scores.stabilityScore >= 0.8)
|
|
867
|
+
reasons.push("strong stability evidence");
|
|
868
|
+
if (scores.diversityScore >= 0.8)
|
|
869
|
+
reasons.push("diverse lineage");
|
|
870
|
+
if (scores.riskPenalty >= 0.15)
|
|
871
|
+
reasons.push("penalized for overfit-prone lineage or post-processing");
|
|
872
|
+
if (scores.metricScore >= 0.95)
|
|
873
|
+
reasons.push("top raw metric evidence");
|
|
874
|
+
if (scores.calibrationAdjustment > 0)
|
|
875
|
+
reasons.push("external feedback calibrates local validation upward");
|
|
876
|
+
if (scores.calibrationAdjustment < 0)
|
|
877
|
+
reasons.push("external feedback calibrates local validation downward");
|
|
878
|
+
if (candidate.robustness?.summary)
|
|
879
|
+
reasons.push(candidate.robustness.summary);
|
|
880
|
+
return reasons.length > 0 ? reasons : ["risk-adjusted candidate evidence"];
|
|
881
|
+
}
|
|
882
|
+
function selectSafeCandidate(candidates) {
|
|
883
|
+
return [...candidates].sort((a, b) => b.stability_score - a.stability_score
|
|
884
|
+
|| a.risk_penalty - b.risk_penalty
|
|
885
|
+
|| b.robust_score - a.robust_score
|
|
886
|
+
|| a.raw_rank - b.raw_rank)[0] ?? null;
|
|
887
|
+
}
|
|
888
|
+
function selectDiverseCandidate(candidates, robustBest) {
|
|
889
|
+
const robustFamily = robustBest?.strategy_family;
|
|
890
|
+
return [...candidates]
|
|
891
|
+
.filter((candidate) => !robustFamily || candidate.strategy_family !== robustFamily)
|
|
892
|
+
.filter((candidate) => candidate.diversity_score >= 0.5)
|
|
893
|
+
.sort((a, b) => b.diversity_score - a.diversity_score
|
|
894
|
+
|| b.robust_score - a.robust_score
|
|
895
|
+
|| a.raw_rank - b.raw_rank)[0] ?? null;
|
|
896
|
+
}
|
|
897
|
+
function summarizeNearMissCandidates(entriesOldestFirst) {
|
|
898
|
+
const primaryMetric = resolvePrimaryCandidateMetricKey(entriesOldestFirst);
|
|
899
|
+
const contexts = extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric)
|
|
900
|
+
.filter((context) => context.candidate.disposition !== "retired");
|
|
901
|
+
const rawRanked = [...contexts].sort(compareCandidateEvidenceContexts);
|
|
902
|
+
const rawBest = rawRanked[0] ?? null;
|
|
903
|
+
const scoredByCandidateId = new Map(scoreCandidateSelectionContexts(rawRanked).map((candidate) => [candidate.candidate_id, candidate]));
|
|
904
|
+
const result = [];
|
|
905
|
+
for (const context of rawRanked) {
|
|
906
|
+
if (!rawBest || context.candidate.candidate_id === rawBest.candidate.candidate_id)
|
|
907
|
+
continue;
|
|
908
|
+
const scored = scoredByCandidateId.get(context.candidate.candidate_id);
|
|
909
|
+
const reasons = nearMissReasonsForCandidate(context, rawBest, scored);
|
|
910
|
+
if (reasons.length === 0)
|
|
911
|
+
continue;
|
|
912
|
+
const nearMiss = context.candidate.near_miss;
|
|
913
|
+
if (nearMiss?.status === "rejected")
|
|
914
|
+
continue;
|
|
915
|
+
result.push({
|
|
916
|
+
candidate_id: context.candidate.candidate_id,
|
|
917
|
+
...(context.candidate.label ? { label: context.candidate.label } : {}),
|
|
918
|
+
strategy_family: context.candidate.lineage.strategy_family,
|
|
919
|
+
evidence_entry_id: context.entry_id,
|
|
920
|
+
occurred_at: context.occurred_at,
|
|
921
|
+
raw_rank: scored?.raw_rank ?? rawRanked.indexOf(context) + 1,
|
|
922
|
+
...(context.metric ? { raw_metric: context.metric } : {}),
|
|
923
|
+
raw_best_candidate_id: rawBest.candidate.candidate_id,
|
|
924
|
+
...nearMissMarginContext(context, rawBest, nearMiss),
|
|
925
|
+
reason_to_keep: reasons,
|
|
926
|
+
weak_dimensions: nearMiss?.weak_dimensions ?? context.candidate.robustness?.weak_dimensions ?? [],
|
|
927
|
+
complementary_candidate_ids: nearMiss?.complementary_candidate_ids ?? complementaryCandidateIds(context.candidate),
|
|
928
|
+
...(nearMiss?.follow_up ? { follow_up: nearMiss.follow_up } : {}),
|
|
929
|
+
...(context.candidate.disposition_reason ? { retained_reason: context.candidate.disposition_reason } : {}),
|
|
930
|
+
evidence_refs: nearMiss?.evidence_refs ?? context.candidate.robustness?.provenance_refs ?? [],
|
|
931
|
+
...(nearMiss?.summary ?? context.candidate.robustness?.summary
|
|
932
|
+
? { summary: nearMiss?.summary ?? context.candidate.robustness?.summary }
|
|
933
|
+
: {}),
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
return result.sort((a, b) => nearMissReasonRank(b.reason_to_keep) - nearMissReasonRank(a.reason_to_keep)
|
|
937
|
+
|| (b.raw_metric?.confidence ?? 0) - (a.raw_metric?.confidence ?? 0)
|
|
938
|
+
|| a.raw_rank - b.raw_rank).slice(0, 8);
|
|
939
|
+
}
|
|
940
|
+
function nearMissReasonsForCandidate(context, rawBest, scored) {
|
|
941
|
+
const explicit = context.candidate.near_miss?.reason_to_keep ?? [];
|
|
942
|
+
const reasons = new Set(explicit);
|
|
943
|
+
if (context.candidate.near_miss?.status === "retained" || context.candidate.near_miss?.status === "promoted") {
|
|
944
|
+
for (const reason of inferredNearMissReasons(context, rawBest, scored))
|
|
945
|
+
reasons.add(reason);
|
|
946
|
+
}
|
|
947
|
+
else if (context.candidate.near_miss) {
|
|
948
|
+
for (const reason of inferredNearMissReasons(context, rawBest, scored))
|
|
949
|
+
reasons.add(reason);
|
|
950
|
+
}
|
|
951
|
+
else if (isImplicitNearMiss(context, rawBest, scored)) {
|
|
952
|
+
for (const reason of inferredNearMissReasons(context, rawBest, scored))
|
|
953
|
+
reasons.add(reason);
|
|
954
|
+
}
|
|
955
|
+
return [...reasons];
|
|
956
|
+
}
|
|
957
|
+
function inferredNearMissReasons(context, rawBest, scored) {
|
|
958
|
+
const reasons = [];
|
|
959
|
+
const margin = candidateMetricMargin(context.metric, rawBest.metric);
|
|
960
|
+
if (margin !== null && isCloseToBestMargin(margin, rawBest.metric))
|
|
961
|
+
reasons.push("close_to_best");
|
|
962
|
+
if ((context.candidate.robustness?.stability_score ?? 0) >= 0.8)
|
|
963
|
+
reasons.push("stability");
|
|
964
|
+
if ((context.candidate.near_miss?.weak_dimensions.length ?? context.candidate.robustness?.weak_dimensions.length ?? 0) > 0) {
|
|
965
|
+
reasons.push("weak_dimension_improvement");
|
|
966
|
+
}
|
|
967
|
+
if (context.candidate.lineage.strategy_family !== rawBest.candidate.lineage.strategy_family
|
|
968
|
+
&& (scored?.diversity_score ?? inferredDiversityScore(context.candidate, rawBest.candidate.lineage.strategy_family, [context.candidate, rawBest.candidate])) >= 0.5) {
|
|
969
|
+
reasons.push("novelty");
|
|
970
|
+
}
|
|
971
|
+
if (complementaryCandidateIds(context.candidate).length > 0 || highestKnownSimilarity(context.candidate, [context.candidate, rawBest.candidate]) <= 0.5) {
|
|
972
|
+
reasons.push("complementarity");
|
|
973
|
+
}
|
|
974
|
+
const lineageText = [
|
|
975
|
+
...context.candidate.lineage.model_lineage,
|
|
976
|
+
...context.candidate.lineage.config_lineage,
|
|
977
|
+
...(context.candidate.near_miss?.summary ? [context.candidate.near_miss.summary] : []),
|
|
978
|
+
].map(normalizeLineageText).join(" ");
|
|
979
|
+
if (lineageText.includes("stack") || lineageText.includes("ensemble") || lineageText.includes("blend")) {
|
|
980
|
+
reasons.push("ensemble_potential");
|
|
981
|
+
}
|
|
982
|
+
return reasons;
|
|
983
|
+
}
|
|
984
|
+
function isImplicitNearMiss(context, rawBest, scored) {
|
|
985
|
+
if (context.candidate.disposition !== "retained" && context.candidate.disposition !== "promoted")
|
|
986
|
+
return false;
|
|
987
|
+
const margin = candidateMetricMargin(context.metric, rawBest.metric);
|
|
988
|
+
const close = margin !== null && isCloseToBestMargin(margin, rawBest.metric);
|
|
989
|
+
const weakDimension = (context.candidate.robustness?.weak_dimensions.length ?? 0) > 0;
|
|
990
|
+
const distinctFamily = context.candidate.lineage.strategy_family !== rawBest.candidate.lineage.strategy_family
|
|
991
|
+
&& (scored?.diversity_score ?? 0) >= 0.5;
|
|
992
|
+
return close || weakDimension || distinctFamily;
|
|
993
|
+
}
|
|
994
|
+
function nearMissMarginContext(context, rawBest, nearMiss) {
|
|
995
|
+
const margin = nearMiss?.margin_to_best ?? candidateMetricMargin(context.metric, rawBest.metric);
|
|
996
|
+
return margin === null || margin === undefined ? {} : { margin_to_raw_best: Math.round(margin * 1_000_000) / 1_000_000 };
|
|
997
|
+
}
|
|
998
|
+
function candidateMetricMargin(candidateMetric, bestMetric) {
|
|
999
|
+
if (!candidateMetric || !bestMetric || candidateMetric.direction !== bestMetric.direction)
|
|
1000
|
+
return null;
|
|
1001
|
+
const margin = candidateMetric.direction === "maximize"
|
|
1002
|
+
? bestMetric.value - candidateMetric.value
|
|
1003
|
+
: candidateMetric.value - bestMetric.value;
|
|
1004
|
+
return Number.isFinite(margin) ? Math.max(0, margin) : null;
|
|
1005
|
+
}
|
|
1006
|
+
function isCloseToBestMargin(margin, bestMetric) {
|
|
1007
|
+
if (!bestMetric)
|
|
1008
|
+
return false;
|
|
1009
|
+
const tolerance = Math.max(Math.abs(bestMetric.value) * 0.005, 0.001);
|
|
1010
|
+
return margin <= tolerance;
|
|
1011
|
+
}
|
|
1012
|
+
function complementaryCandidateIds(candidate) {
|
|
1013
|
+
const explicit = candidate.near_miss?.complementary_candidate_ids ?? [];
|
|
1014
|
+
if (explicit.length > 0)
|
|
1015
|
+
return explicit;
|
|
1016
|
+
return candidate.similarity
|
|
1017
|
+
.filter((similarity) => similarity.signal === "metric_correlation" && similarity.similarity <= 0.5)
|
|
1018
|
+
.map((similarity) => similarity.candidate_id);
|
|
1019
|
+
}
|
|
1020
|
+
function nearMissReasonRank(reasons) {
|
|
1021
|
+
const weights = {
|
|
1022
|
+
weak_dimension_improvement: 5,
|
|
1023
|
+
novelty: 4,
|
|
1024
|
+
complementarity: 4,
|
|
1025
|
+
ensemble_potential: 3,
|
|
1026
|
+
stability: 2,
|
|
1027
|
+
close_to_best: 1,
|
|
1028
|
+
};
|
|
1029
|
+
return reasons.reduce((score, reason) => score + weights[reason], 0);
|
|
1030
|
+
}
|
|
1031
|
+
function summarizeCandidateLineages(entriesOldestFirst) {
|
|
1032
|
+
const primaryMetric = resolvePrimaryCandidateMetricKey(entriesOldestFirst);
|
|
1033
|
+
const byFamily = new Map();
|
|
1034
|
+
for (const context of extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric)) {
|
|
1035
|
+
const family = context.candidate.lineage.strategy_family;
|
|
1036
|
+
byFamily.set(family, [...(byFamily.get(family) ?? []), context]);
|
|
1037
|
+
}
|
|
1038
|
+
return [...byFamily.entries()]
|
|
1039
|
+
.map(([strategyFamily, contexts]) => {
|
|
1040
|
+
const sorted = [...contexts].sort(compareCandidateEvidenceContexts);
|
|
1041
|
+
const best = sorted[0];
|
|
1042
|
+
const diversityNotes = new Set();
|
|
1043
|
+
for (const context of contexts) {
|
|
1044
|
+
for (const similarity of context.candidate.similarity) {
|
|
1045
|
+
if (similarity.similarity >= 0.85) {
|
|
1046
|
+
diversityNotes.add(`${context.candidate.candidate_id} near-duplicate of ${similarity.candidate_id}`);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
return {
|
|
1051
|
+
strategy_family: strategyFamily,
|
|
1052
|
+
candidate_ids: contexts.map((context) => context.candidate.candidate_id),
|
|
1053
|
+
retained_representative_ids: sorted
|
|
1054
|
+
.filter((context) => context.candidate.disposition === "retained" || context.candidate.disposition === "promoted")
|
|
1055
|
+
.map((context) => context.candidate.candidate_id)
|
|
1056
|
+
.slice(0, 3),
|
|
1057
|
+
promoted_ids: contexts
|
|
1058
|
+
.filter((context) => context.candidate.disposition === "promoted")
|
|
1059
|
+
.map((context) => context.candidate.candidate_id),
|
|
1060
|
+
retired_ids: contexts
|
|
1061
|
+
.filter((context) => context.candidate.disposition === "retired")
|
|
1062
|
+
.map((context) => context.candidate.candidate_id),
|
|
1063
|
+
...(best ? { best_candidate_id: best.candidate.candidate_id } : {}),
|
|
1064
|
+
...(best?.metric
|
|
1065
|
+
? {
|
|
1066
|
+
best_metric: {
|
|
1067
|
+
label: best.metric.label,
|
|
1068
|
+
value: best.metric.value,
|
|
1069
|
+
direction: best.metric.direction,
|
|
1070
|
+
},
|
|
1071
|
+
}
|
|
1072
|
+
: {}),
|
|
1073
|
+
diversity_notes: [...diversityNotes].slice(0, 5),
|
|
1074
|
+
};
|
|
1075
|
+
})
|
|
1076
|
+
.sort((a, b) => {
|
|
1077
|
+
const aMetric = a.best_metric;
|
|
1078
|
+
const bMetric = b.best_metric;
|
|
1079
|
+
if (aMetric && bMetric && aMetric.direction === bMetric.direction) {
|
|
1080
|
+
const delta = aMetric.direction === "maximize" ? bMetric.value - aMetric.value : aMetric.value - bMetric.value;
|
|
1081
|
+
if (delta !== 0)
|
|
1082
|
+
return delta;
|
|
1083
|
+
}
|
|
1084
|
+
if (aMetric && !bMetric)
|
|
1085
|
+
return -1;
|
|
1086
|
+
if (!aMetric && bMetric)
|
|
1087
|
+
return 1;
|
|
1088
|
+
return a.strategy_family.localeCompare(b.strategy_family);
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
function extractCandidateEvidenceContexts(entriesOldestFirst, primaryMetric) {
|
|
1092
|
+
const contexts = [];
|
|
1093
|
+
for (const entry of entriesOldestFirst) {
|
|
1094
|
+
for (const candidate of entry.candidates ?? []) {
|
|
1095
|
+
contexts.push({
|
|
1096
|
+
entry_id: entry.id,
|
|
1097
|
+
occurred_at: candidate.produced_at ?? entry.occurred_at,
|
|
1098
|
+
candidate,
|
|
1099
|
+
metric: candidateComparableMetric(candidate, primaryMetric),
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
return contexts;
|
|
1104
|
+
}
|
|
1105
|
+
function resolvePrimaryCandidateMetricKey(entriesOldestFirst) {
|
|
1106
|
+
const candidates = entriesOldestFirst.flatMap((entry) => entry.candidates ?? []);
|
|
1107
|
+
const byMetric = new Map();
|
|
1108
|
+
candidates.forEach((candidate, candidateIndex) => {
|
|
1109
|
+
const seenForCandidate = new Set();
|
|
1110
|
+
candidate.metrics.forEach((metric, metricIndex) => {
|
|
1111
|
+
if (typeof metric.value !== "number" || !Number.isFinite(metric.value))
|
|
1112
|
+
return;
|
|
1113
|
+
if (metric.direction !== "maximize" && metric.direction !== "minimize")
|
|
1114
|
+
return;
|
|
1115
|
+
const key = { label: metric.label, direction: metric.direction };
|
|
1116
|
+
const mapKey = `${key.label}:${key.direction}`;
|
|
1117
|
+
if (seenForCandidate.has(mapKey))
|
|
1118
|
+
return;
|
|
1119
|
+
seenForCandidate.add(mapKey);
|
|
1120
|
+
const existing = byMetric.get(mapKey);
|
|
1121
|
+
if (!existing) {
|
|
1122
|
+
byMetric.set(mapKey, {
|
|
1123
|
+
key,
|
|
1124
|
+
candidate_count: 1,
|
|
1125
|
+
position_sum: metricIndex,
|
|
1126
|
+
latest_index: candidateIndex,
|
|
1127
|
+
});
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
existing.candidate_count += 1;
|
|
1131
|
+
existing.position_sum += metricIndex;
|
|
1132
|
+
existing.latest_index = candidateIndex;
|
|
1133
|
+
});
|
|
1134
|
+
});
|
|
1135
|
+
return [...byMetric.values()].sort((a, b) => {
|
|
1136
|
+
const coverageDelta = b.candidate_count - a.candidate_count;
|
|
1137
|
+
if (coverageDelta !== 0)
|
|
1138
|
+
return coverageDelta;
|
|
1139
|
+
const localityDelta = Number(isLocalValidationMetricLabel(b.key.label)) - Number(isLocalValidationMetricLabel(a.key.label));
|
|
1140
|
+
if (localityDelta !== 0)
|
|
1141
|
+
return localityDelta;
|
|
1142
|
+
const positionDelta = a.position_sum / a.candidate_count - b.position_sum / b.candidate_count;
|
|
1143
|
+
if (positionDelta !== 0)
|
|
1144
|
+
return positionDelta;
|
|
1145
|
+
return b.latest_index - a.latest_index;
|
|
1146
|
+
})[0]?.key ?? null;
|
|
1147
|
+
}
|
|
1148
|
+
function isLocalValidationMetricLabel(label) {
|
|
1149
|
+
const normalized = normalizeLineageText(label);
|
|
1150
|
+
const externalHints = ["public", "private", "leaderboard", "external", "lb", "submission"];
|
|
1151
|
+
for (const hint of externalHints) {
|
|
1152
|
+
if (normalized === hint || normalized.includes(hint)) {
|
|
1153
|
+
return false;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
return true;
|
|
1157
|
+
}
|
|
1158
|
+
function candidateComparableMetric(candidate, primaryMetric) {
|
|
1159
|
+
for (const metric of candidate.metrics) {
|
|
1160
|
+
if (primaryMetric && (metric.label !== primaryMetric.label || metric.direction !== primaryMetric.direction))
|
|
1161
|
+
continue;
|
|
1162
|
+
if (typeof metric.value !== "number" || !Number.isFinite(metric.value))
|
|
1163
|
+
continue;
|
|
1164
|
+
if (metric.direction !== "maximize" && metric.direction !== "minimize")
|
|
1165
|
+
continue;
|
|
1166
|
+
return {
|
|
1167
|
+
label: metric.label,
|
|
1168
|
+
value: metric.value,
|
|
1169
|
+
direction: metric.direction,
|
|
1170
|
+
confidence: metric.confidence ?? 1,
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
return null;
|
|
1174
|
+
}
|
|
1175
|
+
function compareCandidateEvidenceContexts(a, b) {
|
|
1176
|
+
const metricDelta = compareCandidateMetrics(a.metric, b.metric);
|
|
1177
|
+
if (metricDelta !== 0)
|
|
1178
|
+
return metricDelta;
|
|
1179
|
+
const dispositionDelta = dispositionRank(b.candidate.disposition) - dispositionRank(a.candidate.disposition);
|
|
1180
|
+
if (dispositionDelta !== 0)
|
|
1181
|
+
return dispositionDelta;
|
|
1182
|
+
const confidenceDelta = (b.metric?.confidence ?? 0) - (a.metric?.confidence ?? 0);
|
|
1183
|
+
if (confidenceDelta !== 0)
|
|
1184
|
+
return confidenceDelta;
|
|
1185
|
+
return b.occurred_at.localeCompare(a.occurred_at);
|
|
1186
|
+
}
|
|
1187
|
+
function compareCandidateMetrics(a, b) {
|
|
1188
|
+
if (a && b && a.direction === b.direction) {
|
|
1189
|
+
const valueDelta = a.direction === "maximize" ? b.value - a.value : a.value - b.value;
|
|
1190
|
+
if (valueDelta !== 0)
|
|
1191
|
+
return valueDelta;
|
|
1192
|
+
}
|
|
1193
|
+
if (a && !b)
|
|
1194
|
+
return -1;
|
|
1195
|
+
if (!a && b)
|
|
1196
|
+
return 1;
|
|
1197
|
+
return 0;
|
|
1198
|
+
}
|
|
1199
|
+
function dispositionRank(disposition) {
|
|
1200
|
+
if (disposition === "promoted")
|
|
1201
|
+
return 2;
|
|
1202
|
+
if (disposition === "retained")
|
|
1203
|
+
return 1;
|
|
1204
|
+
return 0;
|
|
1205
|
+
}
|
|
1206
|
+
function mostSimilarSelectedCandidate(candidate, selected) {
|
|
1207
|
+
let best;
|
|
1208
|
+
for (const selectedCandidate of selected) {
|
|
1209
|
+
const similarity = similarityBetweenCandidates(candidate.candidate, selectedCandidate.candidate);
|
|
1210
|
+
if (!similarity)
|
|
1211
|
+
continue;
|
|
1212
|
+
if (!best || similarity.similarity > best.similarity)
|
|
1213
|
+
best = similarity;
|
|
1214
|
+
}
|
|
1215
|
+
return best;
|
|
1216
|
+
}
|
|
1217
|
+
function similarityBetweenCandidates(candidate, selected) {
|
|
1218
|
+
const direct = candidate.similarity.find((similarity) => similarity.candidate_id === selected.candidate_id);
|
|
1219
|
+
const inverse = selected.similarity.find((similarity) => similarity.candidate_id === candidate.candidate_id);
|
|
1220
|
+
if (direct && inverse)
|
|
1221
|
+
return direct.similarity >= inverse.similarity ? direct : inverse;
|
|
1222
|
+
if (direct)
|
|
1223
|
+
return direct;
|
|
1224
|
+
if (inverse) {
|
|
1225
|
+
return {
|
|
1226
|
+
...inverse,
|
|
1227
|
+
candidate_id: selected.candidate_id,
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
if (candidate.lineage.strategy_family === selected.lineage.strategy_family
|
|
1231
|
+
&& candidateLineageFingerprint(candidate) === candidateLineageFingerprint(selected)) {
|
|
1232
|
+
return {
|
|
1233
|
+
candidate_id: selected.candidate_id,
|
|
1234
|
+
similarity: 0.9,
|
|
1235
|
+
signal: "lineage",
|
|
1236
|
+
summary: "candidate shares strategy family and lineage fingerprint",
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
return undefined;
|
|
1240
|
+
}
|
|
1241
|
+
function candidateLineageFingerprint(candidate) {
|
|
1242
|
+
const lineage = candidate.lineage;
|
|
1243
|
+
return [
|
|
1244
|
+
lineage.strategy_family,
|
|
1245
|
+
...lineage.feature_lineage,
|
|
1246
|
+
...lineage.model_lineage,
|
|
1247
|
+
...lineage.config_lineage,
|
|
1248
|
+
...lineage.postprocess_lineage,
|
|
1249
|
+
].map(normalizeLineageText).filter(Boolean).join("|");
|
|
1250
|
+
}
|
|
1251
|
+
function toPortfolioSlot(context) {
|
|
1252
|
+
const candidate = context.candidate;
|
|
1253
|
+
return {
|
|
1254
|
+
candidate_id: candidate.candidate_id,
|
|
1255
|
+
...(candidate.label ? { label: candidate.label } : {}),
|
|
1256
|
+
strategy_family: candidate.lineage.strategy_family,
|
|
1257
|
+
role: context.role,
|
|
1258
|
+
evidence_entry_id: context.entry_id,
|
|
1259
|
+
occurred_at: context.occurred_at,
|
|
1260
|
+
...(context.metric ? { metric: context.metric } : {}),
|
|
1261
|
+
...(candidate.lineage.parent_candidate_id ? { parent_candidate_id: candidate.lineage.parent_candidate_id } : {}),
|
|
1262
|
+
...(candidate.lineage.source_candidate_id ? { source_candidate_id: candidate.lineage.source_candidate_id } : {}),
|
|
1263
|
+
...(candidate.lineage.source_strategy_id ? { source_strategy_id: candidate.lineage.source_strategy_id } : {}),
|
|
1264
|
+
disposition: candidate.disposition,
|
|
1265
|
+
...(candidate.disposition_reason ? { retained_reason: candidate.disposition_reason } : {}),
|
|
1266
|
+
...(context.similarity_to_selected ? { similarity_to_selected: context.similarity_to_selected } : {}),
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
function summarizeFailedLineages(entriesOldestFirst) {
|
|
1270
|
+
const lineages = new Map();
|
|
1271
|
+
for (const entry of entriesOldestFirst) {
|
|
1272
|
+
if (!isFailedEvidenceEntry(entry))
|
|
1273
|
+
continue;
|
|
1274
|
+
const fingerprintInput = failedLineageFingerprintInput(entry);
|
|
1275
|
+
const normalizedIdentityParts = [
|
|
1276
|
+
normalizeLineageText(fingerprintInput.strategy_family),
|
|
1277
|
+
normalizeLineageText(fingerprintInput.hypothesis),
|
|
1278
|
+
normalizeLineageText(fingerprintInput.primary_dimension),
|
|
1279
|
+
normalizeLineageText(fingerprintInput.task_action),
|
|
1280
|
+
].filter(Boolean);
|
|
1281
|
+
const normalizedFallbackParts = [normalizeLineageText(fingerprintInput.failure_reason)].filter(Boolean);
|
|
1282
|
+
const fingerprintParts = normalizedIdentityParts.length > 0 ? normalizedIdentityParts : normalizedFallbackParts;
|
|
1283
|
+
if (fingerprintParts.length === 0)
|
|
1284
|
+
continue;
|
|
1285
|
+
const fingerprint = fingerprintParts.join("|");
|
|
1286
|
+
const summary = entry.summary
|
|
1287
|
+
?? entry.result?.summary
|
|
1288
|
+
?? entry.verification?.summary
|
|
1289
|
+
?? entry.result?.error
|
|
1290
|
+
?? `${entry.kind} failed`;
|
|
1291
|
+
const existing = lineages.get(fingerprint);
|
|
1292
|
+
if (!existing) {
|
|
1293
|
+
lineages.set(fingerprint, {
|
|
1294
|
+
fingerprint,
|
|
1295
|
+
count: 1,
|
|
1296
|
+
first_seen_at: entry.occurred_at,
|
|
1297
|
+
last_seen_at: entry.occurred_at,
|
|
1298
|
+
...(fingerprintInput.strategy_family ? { strategy_family: fingerprintInput.strategy_family } : {}),
|
|
1299
|
+
...(fingerprintInput.hypothesis ? { hypothesis: fingerprintInput.hypothesis } : {}),
|
|
1300
|
+
...(fingerprintInput.primary_dimension ? { primary_dimension: fingerprintInput.primary_dimension } : {}),
|
|
1301
|
+
...(fingerprintInput.task_action ? { task_action: fingerprintInput.task_action } : {}),
|
|
1302
|
+
...(fingerprintInput.failure_reason ? { failure_reason: fingerprintInput.failure_reason } : {}),
|
|
1303
|
+
representative_entry_id: entry.id,
|
|
1304
|
+
representative_summary: summary,
|
|
1305
|
+
evidence_entry_ids: [entry.id],
|
|
1306
|
+
});
|
|
1307
|
+
continue;
|
|
1308
|
+
}
|
|
1309
|
+
existing.count += 1;
|
|
1310
|
+
existing.last_seen_at = entry.occurred_at;
|
|
1311
|
+
existing.representative_entry_id = entry.id;
|
|
1312
|
+
existing.representative_summary = summary;
|
|
1313
|
+
existing.evidence_entry_ids = [...existing.evidence_entry_ids, entry.id].slice(-5);
|
|
1314
|
+
}
|
|
1315
|
+
return [...lineages.values()]
|
|
1316
|
+
.sort((a, b) => b.count - a.count || b.last_seen_at.localeCompare(a.last_seen_at))
|
|
1317
|
+
.slice(0, 10);
|
|
1318
|
+
}
|
|
1319
|
+
function isFailedEvidenceEntry(entry) {
|
|
1320
|
+
return entry.outcome === "failed"
|
|
1321
|
+
|| entry.outcome === "regressed"
|
|
1322
|
+
|| entry.kind === "failure"
|
|
1323
|
+
|| entry.result?.status === "failed"
|
|
1324
|
+
|| entry.verification?.verdict === "fail";
|
|
1325
|
+
}
|
|
1326
|
+
function failedLineageFingerprintInput(entry) {
|
|
1327
|
+
const strategyFamily = entry.strategy ?? entry.task?.action;
|
|
1328
|
+
return {
|
|
1329
|
+
...(strategyFamily ? { strategy_family: strategyFamily } : {}),
|
|
1330
|
+
...(entry.hypothesis ? { hypothesis: entry.hypothesis } : {}),
|
|
1331
|
+
...(entry.task?.primary_dimension ? { primary_dimension: entry.task.primary_dimension } : {}),
|
|
1332
|
+
...(entry.task?.action ? { task_action: entry.task.action } : {}),
|
|
1333
|
+
...(entry.result?.error || entry.result?.summary || entry.verification?.summary
|
|
1334
|
+
? { failure_reason: entry.result?.error ?? entry.result?.summary ?? entry.verification?.summary }
|
|
1335
|
+
: {}),
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
function normalizeLineageText(value) {
|
|
1339
|
+
return value?.normalize("NFKC").toLocaleLowerCase().replace(/[^\p{Letter}\p{Number}]+/gu, " ").trim() ?? "";
|
|
1340
|
+
}
|
|
1341
|
+
function clamp01(value) {
|
|
1342
|
+
if (!Number.isFinite(value))
|
|
1343
|
+
return 0;
|
|
1344
|
+
return Math.min(1, Math.max(0, value));
|
|
1345
|
+
}
|
|
1346
|
+
function roundScore(value) {
|
|
1347
|
+
return Math.round(value * 1_000_000) / 1_000_000;
|
|
1348
|
+
}
|
|
1349
|
+
function chooseBestEvidence(entriesNewestFirst) {
|
|
1350
|
+
const metricBest = chooseBestMetricEvidence(entriesNewestFirst);
|
|
1351
|
+
if (metricBest)
|
|
1352
|
+
return metricBest;
|
|
1353
|
+
return chooseBestFallbackEvidence(entriesNewestFirst);
|
|
1354
|
+
}
|
|
1355
|
+
function chooseBestFallbackEvidence(entriesNewestFirst) {
|
|
1356
|
+
return entriesNewestFirst.find((entry) => entry.outcome === "improved")
|
|
1357
|
+
?? entriesNewestFirst.find((entry) => entry.verification?.verdict === "pass")
|
|
1358
|
+
?? entriesNewestFirst.find((entry) => entry.metrics.length > 0)
|
|
1359
|
+
?? entriesNewestFirst.find((entry) => entry.kind === "artifact")
|
|
1360
|
+
?? null;
|
|
1361
|
+
}
|
|
1362
|
+
function chooseBestMetricEvidence(entriesNewestFirst) {
|
|
1363
|
+
const primaryMetric = resolvePrimaryMetricKey(entriesNewestFirst);
|
|
1364
|
+
if (!primaryMetric)
|
|
1365
|
+
return null;
|
|
1366
|
+
const oldestFirst = [...entriesNewestFirst].reverse();
|
|
1367
|
+
const baseline = findComparableMetric(oldestFirst, primaryMetric)?.value;
|
|
1368
|
+
const candidates = entriesNewestFirst
|
|
1369
|
+
.map((entry) => {
|
|
1370
|
+
const metric = findComparableMetric([entry], primaryMetric);
|
|
1371
|
+
if (!metric)
|
|
1372
|
+
return null;
|
|
1373
|
+
return {
|
|
1374
|
+
entry,
|
|
1375
|
+
metric: metric.metric,
|
|
1376
|
+
value: metric.value,
|
|
1377
|
+
direction: metric.direction,
|
|
1378
|
+
primary_metric: primaryMetric,
|
|
1379
|
+
improvement_strength: baseline === undefined
|
|
1380
|
+
? 0
|
|
1381
|
+
: metric.direction === "maximize"
|
|
1382
|
+
? metric.value - baseline
|
|
1383
|
+
: baseline - metric.value,
|
|
1384
|
+
confidence: metric.metric.confidence ?? entry.verification?.confidence ?? 1,
|
|
1385
|
+
has_pass_verification: entry.verification?.verdict === "pass",
|
|
1386
|
+
has_artifact: entry.artifacts.length > 0 || entry.kind === "artifact",
|
|
1387
|
+
};
|
|
1388
|
+
})
|
|
1389
|
+
.filter((candidate) => Boolean(candidate));
|
|
1390
|
+
if (candidates.length === 0)
|
|
1391
|
+
return null;
|
|
1392
|
+
return candidates.sort(compareComparableEvidenceMetrics)[0]?.entry ?? null;
|
|
1393
|
+
}
|
|
1394
|
+
function resolvePrimaryMetricKey(entriesNewestFirst) {
|
|
1395
|
+
for (const entry of entriesNewestFirst) {
|
|
1396
|
+
const metric = findFirstDirectedNumericMetric(entry);
|
|
1397
|
+
if (metric?.direction === "maximize" || metric?.direction === "minimize") {
|
|
1398
|
+
return { label: metric.label, direction: metric.direction };
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return null;
|
|
1402
|
+
}
|
|
1403
|
+
function findComparableMetric(entries, key) {
|
|
1404
|
+
for (const entry of entries) {
|
|
1405
|
+
for (const metric of entry.metrics) {
|
|
1406
|
+
if (metric.label !== key.label || metric.direction !== key.direction)
|
|
1407
|
+
continue;
|
|
1408
|
+
const comparable = toComparableMetric(metric);
|
|
1409
|
+
if (comparable)
|
|
1410
|
+
return comparable;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
return null;
|
|
1414
|
+
}
|
|
1415
|
+
function findFirstDirectedNumericMetric(entry) {
|
|
1416
|
+
for (const metric of entry.metrics) {
|
|
1417
|
+
if (toComparableMetric(metric))
|
|
1418
|
+
return metric;
|
|
1419
|
+
}
|
|
1420
|
+
return null;
|
|
1421
|
+
}
|
|
1422
|
+
function toComparableMetric(metric) {
|
|
1423
|
+
if (typeof metric.value !== "number" || !Number.isFinite(metric.value))
|
|
1424
|
+
return null;
|
|
1425
|
+
if (metric.direction !== "maximize" && metric.direction !== "minimize")
|
|
1426
|
+
return null;
|
|
1427
|
+
return {
|
|
1428
|
+
metric,
|
|
1429
|
+
value: metric.value,
|
|
1430
|
+
direction: metric.direction,
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
function compareComparableEvidenceMetrics(a, b) {
|
|
1434
|
+
const direction = a.direction;
|
|
1435
|
+
const valueDelta = direction === "maximize" ? b.value - a.value : a.value - b.value;
|
|
1436
|
+
if (valueDelta !== 0)
|
|
1437
|
+
return valueDelta;
|
|
1438
|
+
const passDelta = Number(b.has_pass_verification) - Number(a.has_pass_verification);
|
|
1439
|
+
if (passDelta !== 0)
|
|
1440
|
+
return passDelta;
|
|
1441
|
+
const artifactDelta = Number(b.has_artifact) - Number(a.has_artifact);
|
|
1442
|
+
if (artifactDelta !== 0)
|
|
1443
|
+
return artifactDelta;
|
|
1444
|
+
const confidenceDelta = b.confidence - a.confidence;
|
|
1445
|
+
if (confidenceDelta !== 0)
|
|
1446
|
+
return confidenceDelta;
|
|
1447
|
+
const improvementDelta = b.improvement_strength - a.improvement_strength;
|
|
1448
|
+
if (improvementDelta !== 0)
|
|
1449
|
+
return improvementDelta;
|
|
1450
|
+
return b.entry.occurred_at.localeCompare(a.entry.occurred_at);
|
|
1451
|
+
}
|
|
1452
|
+
//# sourceMappingURL=evidence-ledger.js.map
|