rookery-agent 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +467 -367
- package/docs/migration.md +88 -88
- package/docs/updates.md +112 -0
- package/package.json +11 -3
- package/packages/cli/dist/commands/config.js +2 -2
- package/packages/cli/dist/commands/doctor.d.ts.map +1 -1
- package/packages/cli/dist/commands/doctor.js +13 -9
- package/packages/cli/dist/commands/doctor.js.map +1 -1
- package/packages/cli/dist/commands/memory.js +1 -1
- package/packages/cli/dist/commands/org.d.ts +2 -2
- package/packages/cli/dist/commands/org.d.ts.map +1 -1
- package/packages/cli/dist/commands/org.js +19 -17
- package/packages/cli/dist/commands/org.js.map +1 -1
- package/packages/cli/dist/commands/serve.js +1 -1
- package/packages/cli/dist/commands/serve.js.map +1 -1
- package/packages/cli/dist/commands/shared.d.ts.map +1 -1
- package/packages/cli/dist/commands/shared.js +2 -1
- package/packages/cli/dist/commands/shared.js.map +1 -1
- package/packages/cli/dist/commands/tasks.d.ts.map +1 -1
- package/packages/cli/dist/commands/tasks.js +25 -11
- package/packages/cli/dist/commands/tasks.js.map +1 -1
- package/packages/cli/dist/commands/tools.js +1 -1
- package/packages/cli/dist/commands/tools.js.map +1 -1
- package/packages/cli/dist/index.js +13 -13
- package/packages/cli/dist/index.js.map +1 -1
- package/packages/cli/dist/repl.d.ts +12 -0
- package/packages/cli/dist/repl.d.ts.map +1 -1
- package/packages/cli/dist/repl.js +170 -16
- package/packages/cli/dist/repl.js.map +1 -1
- package/packages/cli/dist/tui/App.d.ts +7 -3
- package/packages/cli/dist/tui/App.d.ts.map +1 -1
- package/packages/cli/dist/tui/App.js +182 -16
- package/packages/cli/dist/tui/App.js.map +1 -1
- package/packages/cli/dist/tui/commands.d.ts +7 -0
- package/packages/cli/dist/tui/commands.d.ts.map +1 -1
- package/packages/cli/dist/tui/commands.js +70 -8
- package/packages/cli/dist/tui/commands.js.map +1 -1
- package/packages/cli/dist/tui/components/AssignmentsView.js +4 -4
- package/packages/cli/dist/tui/components/AssignmentsView.js.map +1 -1
- package/packages/cli/dist/tui/components/Banner.d.ts +11 -2
- package/packages/cli/dist/tui/components/Banner.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/Banner.js +7 -10
- package/packages/cli/dist/tui/components/Banner.js.map +1 -1
- package/packages/cli/dist/tui/components/CodeBlock.js +2 -2
- package/packages/cli/dist/tui/components/CodeBlock.js.map +1 -1
- package/packages/cli/dist/tui/components/InputBox.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/InputBox.js +4 -4
- package/packages/cli/dist/tui/components/InputBox.js.map +1 -1
- package/packages/cli/dist/tui/components/Logo.d.ts +56 -0
- package/packages/cli/dist/tui/components/Logo.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/Logo.js +50 -0
- package/packages/cli/dist/tui/components/Logo.js.map +1 -0
- package/packages/cli/dist/tui/components/Markdown.js +8 -8
- package/packages/cli/dist/tui/components/Markdown.js.map +1 -1
- package/packages/cli/dist/tui/components/Message.d.ts +1 -1
- package/packages/cli/dist/tui/components/Message.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/Message.js +5 -4
- package/packages/cli/dist/tui/components/Message.js.map +1 -1
- package/packages/cli/dist/tui/components/QuestionView.d.ts +29 -0
- package/packages/cli/dist/tui/components/QuestionView.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/QuestionView.js +53 -0
- package/packages/cli/dist/tui/components/QuestionView.js.map +1 -0
- package/packages/cli/dist/tui/components/SlashPalette.d.ts +5 -2
- package/packages/cli/dist/tui/components/SlashPalette.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/SlashPalette.js +2 -2
- package/packages/cli/dist/tui/components/SlashPalette.js.map +1 -1
- package/packages/cli/dist/tui/components/StatusLine.d.ts +0 -2
- package/packages/cli/dist/tui/components/StatusLine.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/StatusLine.js +8 -5
- package/packages/cli/dist/tui/components/StatusLine.js.map +1 -1
- package/packages/cli/dist/tui/components/ToolGroup.js +2 -2
- package/packages/cli/dist/tui/components/ToolGroup.js.map +1 -1
- package/packages/cli/dist/tui/components/WatchView.d.ts +21 -0
- package/packages/cli/dist/tui/components/WatchView.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/WatchView.js +36 -0
- package/packages/cli/dist/tui/components/WatchView.js.map +1 -0
- package/packages/cli/dist/tui/history.d.ts +20 -0
- package/packages/cli/dist/tui/history.d.ts.map +1 -0
- package/packages/cli/dist/tui/history.js +105 -0
- package/packages/cli/dist/tui/history.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useSlash.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useSlash.js +3 -2
- package/packages/cli/dist/tui/hooks/useSlash.js.map +1 -1
- package/packages/cli/dist/tui/hooks/useTurn.d.ts +58 -1
- package/packages/cli/dist/tui/hooks/useTurn.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useTurn.js +214 -36
- package/packages/cli/dist/tui/hooks/useTurn.js.map +1 -1
- package/packages/cli/dist/tui/hooks/useWatch.d.ts +52 -0
- package/packages/cli/dist/tui/hooks/useWatch.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useWatch.js +145 -0
- package/packages/cli/dist/tui/hooks/useWatch.js.map +1 -0
- package/packages/cli/dist/tui/inkTheme.d.ts +19 -0
- package/packages/cli/dist/tui/inkTheme.d.ts.map +1 -0
- package/packages/cli/dist/tui/inkTheme.js +81 -0
- package/packages/cli/dist/tui/inkTheme.js.map +1 -0
- package/packages/cli/dist/tui/theme.d.ts +39 -29
- package/packages/cli/dist/tui/theme.d.ts.map +1 -1
- package/packages/cli/dist/tui/theme.js +35 -25
- package/packages/cli/dist/tui/theme.js.map +1 -1
- package/packages/cli/dist/tui/types.d.ts +56 -3
- package/packages/cli/dist/tui/types.d.ts.map +1 -1
- package/packages/cli/dist/tui/types.js +85 -0
- package/packages/cli/dist/tui/types.js.map +1 -1
- package/packages/cli/dist/ui/modelNames.d.ts +51 -0
- package/packages/cli/dist/ui/modelNames.d.ts.map +1 -0
- package/packages/cli/dist/ui/modelNames.js +134 -0
- package/packages/cli/dist/ui/modelNames.js.map +1 -0
- package/packages/cli/dist/ui/render.d.ts.map +1 -1
- package/packages/cli/dist/ui/render.js +17 -8
- package/packages/cli/dist/ui/render.js.map +1 -1
- package/packages/cli/dist/ui/speech.js +5 -0
- package/packages/cli/dist/ui/speech.js.map +1 -1
- package/packages/cli/dist/ui/theme.d.ts +33 -9
- package/packages/cli/dist/ui/theme.d.ts.map +1 -1
- package/packages/cli/dist/ui/theme.js +33 -9
- package/packages/cli/dist/ui/theme.js.map +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/core/dist/agents/persona.d.ts.map +1 -1
- package/packages/core/dist/agents/persona.js +4 -1
- package/packages/core/dist/agents/persona.js.map +1 -1
- package/packages/core/dist/computer/accessibility.d.ts +78 -0
- package/packages/core/dist/computer/accessibility.d.ts.map +1 -0
- package/packages/core/dist/computer/accessibility.js +270 -0
- package/packages/core/dist/computer/accessibility.js.map +1 -0
- package/packages/core/dist/computer/assemblies.d.ts +17 -0
- package/packages/core/dist/computer/assemblies.d.ts.map +1 -0
- package/packages/core/dist/computer/assemblies.js +55 -0
- package/packages/core/dist/computer/assemblies.js.map +1 -0
- package/packages/core/dist/computer/browser-init.d.ts +9 -0
- package/packages/core/dist/computer/browser-init.d.ts.map +1 -0
- package/packages/core/dist/computer/browser-init.js +133 -0
- package/packages/core/dist/computer/browser-init.js.map +1 -0
- package/packages/core/dist/computer/cursor.d.ts +30 -0
- package/packages/core/dist/computer/cursor.d.ts.map +1 -0
- package/packages/core/dist/computer/cursor.js +30 -0
- package/packages/core/dist/computer/cursor.js.map +1 -0
- package/packages/core/dist/computer/mcp-server.js +524 -82
- package/packages/core/dist/computer/mcp-server.js.map +1 -1
- package/packages/core/dist/computer/powershell.d.ts +4 -0
- package/packages/core/dist/computer/powershell.d.ts.map +1 -1
- package/packages/core/dist/computer/powershell.js +471 -81
- package/packages/core/dist/computer/powershell.js.map +1 -1
- package/packages/core/dist/computer/screen-text.d.ts +82 -0
- package/packages/core/dist/computer/screen-text.d.ts.map +1 -0
- package/packages/core/dist/computer/screen-text.js +243 -0
- package/packages/core/dist/computer/screen-text.js.map +1 -0
- package/packages/core/dist/computer/sketch.d.ts +66 -0
- package/packages/core/dist/computer/sketch.d.ts.map +1 -0
- package/packages/core/dist/computer/sketch.js +540 -0
- package/packages/core/dist/computer/sketch.js.map +1 -0
- package/packages/core/dist/computer/tools.d.ts +8 -8
- package/packages/core/dist/computer/tools.d.ts.map +1 -1
- package/packages/core/dist/computer/tools.js +186 -31
- package/packages/core/dist/computer/tools.js.map +1 -1
- package/packages/core/dist/computer/validation.d.ts +555 -0
- package/packages/core/dist/computer/validation.d.ts.map +1 -0
- package/packages/core/dist/computer/validation.js +111 -0
- package/packages/core/dist/computer/validation.js.map +1 -0
- package/packages/core/dist/computer/windows-cursor.d.ts +14 -0
- package/packages/core/dist/computer/windows-cursor.d.ts.map +1 -0
- package/packages/core/dist/computer/windows-cursor.js +713 -0
- package/packages/core/dist/computer/windows-cursor.js.map +1 -0
- package/packages/core/dist/config.d.ts.map +1 -1
- package/packages/core/dist/config.js +284 -10
- package/packages/core/dist/config.js.map +1 -1
- package/packages/core/dist/cron/scheduler.d.ts +49 -3
- package/packages/core/dist/cron/scheduler.d.ts.map +1 -1
- package/packages/core/dist/cron/scheduler.js +268 -25
- package/packages/core/dist/cron/scheduler.js.map +1 -1
- package/packages/core/dist/cron/store.d.ts +19 -1
- package/packages/core/dist/cron/store.d.ts.map +1 -1
- package/packages/core/dist/cron/store.js +36 -8
- package/packages/core/dist/cron/store.js.map +1 -1
- package/packages/core/dist/external/claude-code.d.ts +4 -0
- package/packages/core/dist/external/claude-code.d.ts.map +1 -0
- package/packages/core/dist/external/claude-code.js +111 -0
- package/packages/core/dist/external/claude-code.js.map +1 -0
- package/packages/core/dist/external/discovery.d.ts +33 -0
- package/packages/core/dist/external/discovery.d.ts.map +1 -0
- package/packages/core/dist/external/discovery.js +144 -0
- package/packages/core/dist/external/discovery.js.map +1 -0
- package/packages/core/dist/external/homes.d.ts +26 -0
- package/packages/core/dist/external/homes.d.ts.map +1 -0
- package/packages/core/dist/external/homes.js +49 -0
- package/packages/core/dist/external/homes.js.map +1 -0
- package/packages/core/dist/external/shared.d.ts +201 -0
- package/packages/core/dist/external/shared.d.ts.map +1 -0
- package/packages/core/dist/external/shared.js +308 -0
- package/packages/core/dist/external/shared.js.map +1 -0
- package/packages/core/dist/gateway/policy.d.ts +100 -2
- package/packages/core/dist/gateway/policy.d.ts.map +1 -1
- package/packages/core/dist/gateway/policy.js +270 -6
- package/packages/core/dist/gateway/policy.js.map +1 -1
- package/packages/core/dist/index.d.ts +36 -10
- package/packages/core/dist/index.d.ts.map +1 -1
- package/packages/core/dist/index.js +64 -10
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/memory/db.d.ts +1 -1
- package/packages/core/dist/memory/db.d.ts.map +1 -1
- package/packages/core/dist/memory/db.js +741 -1
- package/packages/core/dist/memory/db.js.map +1 -1
- package/packages/core/dist/memory/dream/admission.d.ts +124 -0
- package/packages/core/dist/memory/dream/admission.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/admission.js +116 -0
- package/packages/core/dist/memory/dream/admission.js.map +1 -0
- package/packages/core/dist/memory/dream/candidate.d.ts +152 -0
- package/packages/core/dist/memory/dream/candidate.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/candidate.js +547 -0
- package/packages/core/dist/memory/dream/candidate.js.map +1 -0
- package/packages/core/dist/memory/dream/evaluate.d.ts +394 -0
- package/packages/core/dist/memory/dream/evaluate.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/evaluate.js +1032 -0
- package/packages/core/dist/memory/dream/evaluate.js.map +1 -0
- package/packages/core/dist/memory/dream/frame.d.ts +61 -0
- package/packages/core/dist/memory/dream/frame.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/frame.js +292 -0
- package/packages/core/dist/memory/dream/frame.js.map +1 -0
- package/packages/core/dist/memory/dream/label.d.ts +370 -0
- package/packages/core/dist/memory/dream/label.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/label.js +439 -0
- package/packages/core/dist/memory/dream/label.js.map +1 -0
- package/packages/core/dist/memory/dream/measure.d.ts +114 -0
- package/packages/core/dist/memory/dream/measure.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/measure.js +205 -0
- package/packages/core/dist/memory/dream/measure.js.map +1 -0
- package/packages/core/dist/memory/dream/policy.d.ts +21 -0
- package/packages/core/dist/memory/dream/policy.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/policy.js +157 -0
- package/packages/core/dist/memory/dream/policy.js.map +1 -0
- package/packages/core/dist/memory/dream/probe.d.ts +202 -0
- package/packages/core/dist/memory/dream/probe.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/probe.js +671 -0
- package/packages/core/dist/memory/dream/probe.js.map +1 -0
- package/packages/core/dist/memory/dream/promote.d.ts +312 -0
- package/packages/core/dist/memory/dream/promote.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/promote.js +528 -0
- package/packages/core/dist/memory/dream/promote.js.map +1 -0
- package/packages/core/dist/memory/dream/score.d.ts +103 -0
- package/packages/core/dist/memory/dream/score.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/score.js +334 -0
- package/packages/core/dist/memory/dream/score.js.map +1 -0
- package/packages/core/dist/memory/dream/slots.d.ts +193 -0
- package/packages/core/dist/memory/dream/slots.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/slots.js +0 -0
- package/packages/core/dist/memory/dream/slots.js.map +1 -0
- package/packages/core/dist/memory/dream/trajectory.d.ts +262 -0
- package/packages/core/dist/memory/dream/trajectory.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/trajectory.js +366 -0
- package/packages/core/dist/memory/dream/trajectory.js.map +1 -0
- package/packages/core/dist/memory/extractor.d.ts +7 -0
- package/packages/core/dist/memory/extractor.d.ts.map +1 -1
- package/packages/core/dist/memory/extractor.js +35 -12
- package/packages/core/dist/memory/extractor.js.map +1 -1
- package/packages/core/dist/memory/gate.d.ts +43 -7
- package/packages/core/dist/memory/gate.d.ts.map +1 -1
- package/packages/core/dist/memory/gate.js +91 -4
- package/packages/core/dist/memory/gate.js.map +1 -1
- package/packages/core/dist/memory/recall.d.ts +57 -0
- package/packages/core/dist/memory/recall.d.ts.map +1 -1
- package/packages/core/dist/memory/recall.js +60 -123
- package/packages/core/dist/memory/recall.js.map +1 -1
- package/packages/core/dist/memory/sleep.d.ts +131 -4
- package/packages/core/dist/memory/sleep.d.ts.map +1 -1
- package/packages/core/dist/memory/sleep.js +2384 -65
- package/packages/core/dist/memory/sleep.js.map +1 -1
- package/packages/core/dist/memory/store.d.ts +564 -10
- package/packages/core/dist/memory/store.d.ts.map +1 -1
- package/packages/core/dist/memory/store.js +1673 -102
- package/packages/core/dist/memory/store.js.map +1 -1
- package/packages/core/dist/org/controller.d.ts +282 -3
- package/packages/core/dist/org/controller.d.ts.map +1 -1
- package/packages/core/dist/org/controller.js +2334 -237
- package/packages/core/dist/org/controller.js.map +1 -1
- package/packages/core/dist/org/ponytail.d.ts +1 -1
- package/packages/core/dist/org/ponytail.js +1 -1
- package/packages/core/dist/org/project-mcp.d.ts +3 -3
- package/packages/core/dist/org/prompts.d.ts +41 -28
- package/packages/core/dist/org/prompts.d.ts.map +1 -1
- package/packages/core/dist/org/prompts.js +281 -94
- package/packages/core/dist/org/prompts.js.map +1 -1
- package/packages/core/dist/org/questions.d.ts +104 -0
- package/packages/core/dist/org/questions.d.ts.map +1 -0
- package/packages/core/dist/org/questions.js +136 -0
- package/packages/core/dist/org/questions.js.map +1 -0
- package/packages/core/dist/org/review.d.ts +100 -0
- package/packages/core/dist/org/review.d.ts.map +1 -0
- package/packages/core/dist/org/review.js +256 -0
- package/packages/core/dist/org/review.js.map +1 -0
- package/packages/core/dist/org/store.d.ts +249 -2
- package/packages/core/dist/org/store.d.ts.map +1 -1
- package/packages/core/dist/org/store.js +787 -13
- package/packages/core/dist/org/store.js.map +1 -1
- package/packages/core/dist/org/tools.d.ts +26 -2
- package/packages/core/dist/org/tools.d.ts.map +1 -1
- package/packages/core/dist/org/tools.js +352 -63
- package/packages/core/dist/org/tools.js.map +1 -1
- package/packages/core/dist/providers/catalogue.d.ts +1 -1
- package/packages/core/dist/providers/catalogue.d.ts.map +1 -1
- package/packages/core/dist/providers/catalogue.js +2 -2
- package/packages/core/dist/providers/catalogue.js.map +1 -1
- package/packages/core/dist/providers/claude-code.d.ts +18 -3
- package/packages/core/dist/providers/claude-code.d.ts.map +1 -1
- package/packages/core/dist/providers/claude-code.js +490 -40
- package/packages/core/dist/providers/claude-code.js.map +1 -1
- package/packages/core/dist/providers/claude-tui.d.ts +175 -0
- package/packages/core/dist/providers/claude-tui.d.ts.map +1 -0
- package/packages/core/dist/providers/claude-tui.js +683 -0
- package/packages/core/dist/providers/claude-tui.js.map +1 -0
- package/packages/core/dist/providers/codex-auth.d.ts +15 -0
- package/packages/core/dist/providers/codex-auth.d.ts.map +1 -0
- package/packages/core/dist/providers/codex-auth.js +127 -0
- package/packages/core/dist/providers/codex-auth.js.map +1 -0
- package/packages/core/dist/providers/codex-bridge.d.ts +58 -0
- package/packages/core/dist/providers/codex-bridge.d.ts.map +1 -0
- package/packages/core/dist/providers/codex-bridge.js +375 -0
- package/packages/core/dist/providers/codex-bridge.js.map +1 -0
- package/packages/core/dist/providers/codex-translate.d.ts +75 -0
- package/packages/core/dist/providers/codex-translate.d.ts.map +1 -0
- package/packages/core/dist/providers/codex-translate.js +383 -0
- package/packages/core/dist/providers/codex-translate.js.map +1 -0
- package/packages/core/dist/providers/model-gateway.d.ts +56 -0
- package/packages/core/dist/providers/model-gateway.d.ts.map +1 -0
- package/packages/core/dist/providers/model-gateway.js +119 -0
- package/packages/core/dist/providers/model-gateway.js.map +1 -0
- package/packages/core/dist/providers/process.d.ts +3 -1
- package/packages/core/dist/providers/process.d.ts.map +1 -1
- package/packages/core/dist/providers/process.js +3 -3
- package/packages/core/dist/providers/process.js.map +1 -1
- package/packages/core/dist/providers/profiles.d.ts +11 -0
- package/packages/core/dist/providers/profiles.d.ts.map +1 -0
- package/packages/core/dist/providers/profiles.js +28 -0
- package/packages/core/dist/providers/profiles.js.map +1 -0
- package/packages/core/dist/providers/provider-catalog.d.ts +72 -0
- package/packages/core/dist/providers/provider-catalog.d.ts.map +1 -0
- package/packages/core/dist/providers/provider-catalog.js +144 -0
- package/packages/core/dist/providers/provider-catalog.js.map +1 -0
- package/packages/core/dist/providers/quota.d.ts +40 -1
- package/packages/core/dist/providers/quota.d.ts.map +1 -1
- package/packages/core/dist/providers/quota.js +288 -25
- package/packages/core/dist/providers/quota.js.map +1 -1
- package/packages/core/dist/providers/registry.d.ts +46 -3
- package/packages/core/dist/providers/registry.d.ts.map +1 -1
- package/packages/core/dist/providers/registry.js +148 -13
- package/packages/core/dist/providers/registry.js.map +1 -1
- package/packages/core/dist/providers/router.d.ts +28 -0
- package/packages/core/dist/providers/router.d.ts.map +1 -0
- package/packages/core/dist/providers/router.js +88 -0
- package/packages/core/dist/providers/router.js.map +1 -0
- package/packages/core/dist/providers/user-settings-guard.d.ts +12 -0
- package/packages/core/dist/providers/user-settings-guard.d.ts.map +1 -0
- package/packages/core/dist/providers/user-settings-guard.js +130 -0
- package/packages/core/dist/providers/user-settings-guard.js.map +1 -0
- package/packages/core/dist/runtime.d.ts +140 -6
- package/packages/core/dist/runtime.d.ts.map +1 -1
- package/packages/core/dist/runtime.js +1312 -225
- package/packages/core/dist/runtime.js.map +1 -1
- package/packages/core/dist/skills/builtin.d.ts +34 -0
- package/packages/core/dist/skills/builtin.d.ts.map +1 -0
- package/packages/core/dist/skills/builtin.js +305 -0
- package/packages/core/dist/skills/builtin.js.map +1 -0
- package/packages/core/dist/skills/shelf.d.ts +30 -0
- package/packages/core/dist/skills/shelf.d.ts.map +1 -0
- package/packages/core/dist/skills/shelf.js +159 -0
- package/packages/core/dist/skills/shelf.js.map +1 -0
- package/packages/core/dist/skills/store.d.ts +66 -4
- package/packages/core/dist/skills/store.d.ts.map +1 -1
- package/packages/core/dist/skills/store.js +105 -18
- package/packages/core/dist/skills/store.js.map +1 -1
- package/packages/core/dist/skills/suggest.d.ts +21 -0
- package/packages/core/dist/skills/suggest.d.ts.map +1 -0
- package/packages/core/dist/skills/suggest.js +150 -0
- package/packages/core/dist/skills/suggest.js.map +1 -0
- package/packages/core/dist/tools/catalog.d.ts +1 -3
- package/packages/core/dist/tools/catalog.d.ts.map +1 -1
- package/packages/core/dist/tools/catalog.js +38 -26
- package/packages/core/dist/tools/catalog.js.map +1 -1
- package/packages/core/dist/tools/hub.d.ts +136 -10
- package/packages/core/dist/tools/hub.d.ts.map +1 -1
- package/packages/core/dist/tools/hub.js +418 -24
- package/packages/core/dist/tools/hub.js.map +1 -1
- package/packages/core/dist/turns/journal.d.ts +78 -0
- package/packages/core/dist/turns/journal.d.ts.map +1 -0
- package/packages/core/dist/turns/journal.js +104 -0
- package/packages/core/dist/turns/journal.js.map +1 -0
- package/packages/core/dist/types.d.ts +1598 -12
- package/packages/core/dist/types.d.ts.map +1 -1
- package/packages/core/dist/types.js.map +1 -1
- package/packages/core/dist/util/blocks.d.ts +41 -0
- package/packages/core/dist/util/blocks.d.ts.map +1 -0
- package/packages/core/dist/util/blocks.js +175 -0
- package/packages/core/dist/util/blocks.js.map +1 -0
- package/packages/core/dist/util/queue.d.ts +12 -0
- package/packages/core/dist/util/queue.d.ts.map +1 -1
- package/packages/core/dist/util/queue.js +16 -0
- package/packages/core/dist/util/queue.js.map +1 -1
- package/packages/core/dist/util/time.d.ts +39 -0
- package/packages/core/dist/util/time.d.ts.map +1 -0
- package/packages/core/dist/util/time.js +71 -0
- package/packages/core/dist/util/time.js.map +1 -0
- package/packages/core/package.json +1 -1
- package/packages/server/dist/auth.d.ts +14 -1
- package/packages/server/dist/auth.d.ts.map +1 -1
- package/packages/server/dist/auth.js +19 -0
- package/packages/server/dist/auth.js.map +1 -1
- package/packages/server/dist/context.d.ts +35 -1
- package/packages/server/dist/context.d.ts.map +1 -1
- package/packages/server/dist/context.js +28 -8
- package/packages/server/dist/context.js.map +1 -1
- package/packages/server/dist/gateways/attachments.d.ts +32 -0
- package/packages/server/dist/gateways/attachments.d.ts.map +1 -0
- package/packages/server/dist/gateways/attachments.js +167 -0
- package/packages/server/dist/gateways/attachments.js.map +1 -0
- package/packages/server/dist/gateways/markdown.d.ts +9 -0
- package/packages/server/dist/gateways/markdown.d.ts.map +1 -0
- package/packages/server/dist/gateways/markdown.js +170 -0
- package/packages/server/dist/gateways/markdown.js.map +1 -0
- package/packages/server/dist/gateways/push.d.ts +1 -1
- package/packages/server/dist/gateways/push.d.ts.map +1 -1
- package/packages/server/dist/gateways/push.js +347 -6
- package/packages/server/dist/gateways/push.js.map +1 -1
- package/packages/server/dist/gateways/telegram-api.d.ts +70 -1
- package/packages/server/dist/gateways/telegram-api.d.ts.map +1 -1
- package/packages/server/dist/gateways/telegram-api.js +140 -1
- package/packages/server/dist/gateways/telegram-api.js.map +1 -1
- package/packages/server/dist/gateways/telegram.d.ts +158 -1
- package/packages/server/dist/gateways/telegram.d.ts.map +1 -1
- package/packages/server/dist/gateways/telegram.js +1471 -78
- package/packages/server/dist/gateways/telegram.js.map +1 -1
- package/packages/server/dist/gateways/threads.d.ts +79 -0
- package/packages/server/dist/gateways/threads.d.ts.map +1 -0
- package/packages/server/dist/gateways/threads.js +279 -0
- package/packages/server/dist/gateways/threads.js.map +1 -0
- package/packages/server/dist/index.d.ts +2 -1
- package/packages/server/dist/index.d.ts.map +1 -1
- package/packages/server/dist/index.js +2 -1
- package/packages/server/dist/index.js.map +1 -1
- package/packages/server/dist/listeners/imap.d.ts +13 -0
- package/packages/server/dist/listeners/imap.d.ts.map +1 -0
- package/packages/server/dist/listeners/imap.js +0 -0
- package/packages/server/dist/listeners/imap.js.map +1 -0
- package/packages/server/dist/listeners/registry.d.ts +18 -0
- package/packages/server/dist/listeners/registry.d.ts.map +1 -0
- package/packages/server/dist/listeners/registry.js +88 -0
- package/packages/server/dist/listeners/registry.js.map +1 -0
- package/packages/server/dist/listeners/types.d.ts +55 -0
- package/packages/server/dist/listeners/types.d.ts.map +1 -0
- package/packages/server/dist/listeners/types.js +2 -0
- package/packages/server/dist/listeners/types.js.map +1 -0
- package/packages/server/dist/main.js +15 -1
- package/packages/server/dist/main.js.map +1 -1
- package/packages/server/dist/routes/chat.d.ts +7 -3
- package/packages/server/dist/routes/chat.d.ts.map +1 -1
- package/packages/server/dist/routes/chat.js +8 -17
- package/packages/server/dist/routes/chat.js.map +1 -1
- package/packages/server/dist/routes/config.d.ts.map +1 -1
- package/packages/server/dist/routes/config.js +39 -7
- package/packages/server/dist/routes/config.js.map +1 -1
- package/packages/server/dist/routes/cron.d.ts.map +1 -1
- package/packages/server/dist/routes/cron.js +65 -8
- package/packages/server/dist/routes/cron.js.map +1 -1
- package/packages/server/dist/routes/dream.d.ts +22 -0
- package/packages/server/dist/routes/dream.d.ts.map +1 -0
- package/packages/server/dist/routes/dream.js +152 -0
- package/packages/server/dist/routes/dream.js.map +1 -0
- package/packages/server/dist/routes/hooks.d.ts +18 -0
- package/packages/server/dist/routes/hooks.d.ts.map +1 -0
- package/packages/server/dist/routes/hooks.js +62 -0
- package/packages/server/dist/routes/hooks.js.map +1 -0
- package/packages/server/dist/routes/listeners.d.ts +10 -0
- package/packages/server/dist/routes/listeners.d.ts.map +1 -0
- package/packages/server/dist/routes/listeners.js +12 -0
- package/packages/server/dist/routes/listeners.js.map +1 -0
- package/packages/server/dist/routes/memories.d.ts.map +1 -1
- package/packages/server/dist/routes/memories.js +55 -3
- package/packages/server/dist/routes/memories.js.map +1 -1
- package/packages/server/dist/routes/org.d.ts.map +1 -1
- package/packages/server/dist/routes/org.js +284 -48
- package/packages/server/dist/routes/org.js.map +1 -1
- package/packages/server/dist/routes/profile.d.ts.map +1 -1
- package/packages/server/dist/routes/profile.js +6 -3
- package/packages/server/dist/routes/profile.js.map +1 -1
- package/packages/server/dist/routes/providers.d.ts.map +1 -1
- package/packages/server/dist/routes/providers.js +66 -7
- package/packages/server/dist/routes/providers.js.map +1 -1
- package/packages/server/dist/routes/questions.d.ts +45 -0
- package/packages/server/dist/routes/questions.d.ts.map +1 -0
- package/packages/server/dist/routes/questions.js +73 -0
- package/packages/server/dist/routes/questions.js.map +1 -0
- package/packages/server/dist/routes/sessions.d.ts.map +1 -1
- package/packages/server/dist/routes/sessions.js +26 -6
- package/packages/server/dist/routes/sessions.js.map +1 -1
- package/packages/server/dist/routes/sleep.d.ts.map +1 -1
- package/packages/server/dist/routes/sleep.js +71 -2
- package/packages/server/dist/routes/sleep.js.map +1 -1
- package/packages/server/dist/routes/terminals.d.ts +25 -0
- package/packages/server/dist/routes/terminals.d.ts.map +1 -0
- package/packages/server/dist/routes/terminals.js +35 -0
- package/packages/server/dist/routes/terminals.js.map +1 -0
- package/packages/server/dist/routes/tools.d.ts.map +1 -1
- package/packages/server/dist/routes/tools.js +140 -6
- package/packages/server/dist/routes/tools.js.map +1 -1
- package/packages/server/dist/routes/updates.d.ts +10 -0
- package/packages/server/dist/routes/updates.d.ts.map +1 -0
- package/packages/server/dist/routes/updates.js +22 -0
- package/packages/server/dist/routes/updates.js.map +1 -0
- package/packages/server/dist/routes/ws.d.ts +11 -5
- package/packages/server/dist/routes/ws.d.ts.map +1 -1
- package/packages/server/dist/routes/ws.js +162 -28
- package/packages/server/dist/routes/ws.js.map +1 -1
- package/packages/server/dist/schemas.d.ts +1125 -211
- package/packages/server/dist/schemas.d.ts.map +1 -1
- package/packages/server/dist/schemas.js +300 -12
- package/packages/server/dist/schemas.js.map +1 -1
- package/packages/server/dist/server.d.ts +7 -1
- package/packages/server/dist/server.d.ts.map +1 -1
- package/packages/server/dist/server.js +186 -3
- package/packages/server/dist/server.js.map +1 -1
- package/packages/server/dist/services/stream.d.ts +89 -5
- package/packages/server/dist/services/stream.d.ts.map +1 -1
- package/packages/server/dist/services/stream.js +9 -20
- package/packages/server/dist/services/stream.js.map +1 -1
- package/packages/server/dist/services/stt.d.ts +65 -0
- package/packages/server/dist/services/stt.d.ts.map +1 -0
- package/packages/server/dist/services/stt.js +306 -0
- package/packages/server/dist/services/stt.js.map +1 -0
- package/packages/server/dist/services/turns.d.ts +49 -0
- package/packages/server/dist/services/turns.d.ts.map +1 -0
- package/packages/server/dist/services/turns.js +138 -0
- package/packages/server/dist/services/turns.js.map +1 -0
- package/packages/server/dist/services/updates.d.ts +99 -0
- package/packages/server/dist/services/updates.d.ts.map +1 -0
- package/packages/server/dist/services/updates.js +316 -0
- package/packages/server/dist/services/updates.js.map +1 -0
- package/packages/server/package.json +1 -1
- package/packages/web/dist/app-icon.svg +2 -0
- package/packages/web/dist/apple-touch-icon.png +0 -0
- package/packages/web/dist/assets/abnfDiagram-O67JEVCF-B4qWcqra.js +1 -0
- package/packages/web/dist/assets/arc-CQult7TN.js +1 -0
- package/packages/web/dist/assets/architectureDiagram-NJMV4G6O-DFTRvl66.js +36 -0
- package/packages/web/dist/assets/blockDiagram-BEXU5L5S-TCFoK_k-.js +140 -0
- package/packages/web/dist/assets/c4Diagram-YGBWAQC7-i5_GqhJa.js +38 -0
- package/packages/web/dist/assets/channel-D_4EmqNR.js +1 -0
- package/packages/web/dist/assets/chunk-2Q5K7J3B-BK6I2wfW.js +1 -0
- package/packages/web/dist/assets/chunk-3FUC2YCW-Dw-TfKT0.js +2 -0
- package/packages/web/dist/assets/chunk-5VM5RSS4-AE_XRNTT.js +15 -0
- package/packages/web/dist/assets/chunk-GTNCS2PH-DO18WaaJ.js +88 -0
- package/packages/web/dist/assets/chunk-GWA4HPMP-3rdjszP_.js +1 -0
- package/packages/web/dist/assets/chunk-JWPE2WC7-C93LH2D0.js +1 -0
- package/packages/web/dist/assets/chunk-NETBCI7D-Dj7O3-H-.js +1 -0
- package/packages/web/dist/assets/chunk-WEXAMYUT-BRFvQUIn.js +1 -0
- package/packages/web/dist/assets/chunk-XXDRQBXY-CXx6HMbz.js +1 -0
- package/packages/web/dist/assets/classDiagram-v2-NBCMYWYE-BGXszxjn.js +217 -0
- package/packages/web/dist/assets/cose-bilkent-JH36ORCC-BAuXqkne.js +1 -0
- package/packages/web/dist/assets/cynefin-OW5HDTMX-plNzhY7J.js +178 -0
- package/packages/web/dist/assets/cynefinDiagram-VND7K2PF-DuPlljFS.js +62 -0
- package/packages/web/dist/assets/cytoscape.esm-Ix0LnXOy.js +331 -0
- package/packages/web/dist/assets/dagre-6A5THRUB-CXzwdR-6.js +4 -0
- package/packages/web/dist/assets/diagram-22UHCM2B-B7iv_V2D.js +200 -0
- package/packages/web/dist/assets/diagram-3UASUU5V-BMvi7gSi.js +24 -0
- package/packages/web/dist/assets/diagram-ATOU4E4O-NJ7EB5Qg.js +3 -0
- package/packages/web/dist/assets/diagram-CDSNMT55-DccMMNJ-.js +30 -0
- package/packages/web/dist/assets/diagram-MLGK6HIB-BbwGHK4g.js +24 -0
- package/packages/web/dist/assets/diagram-MPIPVDR6-BbSSZfM3.js +41 -0
- package/packages/web/dist/assets/draco_decoder-C32yEggz.wasm +0 -0
- package/packages/web/dist/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
- package/packages/web/dist/assets/draco_decoder-fzg4nYZr.js +34 -0
- package/packages/web/dist/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
- package/packages/web/dist/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
- package/packages/web/dist/assets/ebnfDiagram-ZINNZB2B-BBfPNM85.js +1 -0
- package/packages/web/dist/assets/elk-276RUBZZ-dM3Y1d2a.js +27 -0
- package/packages/web/dist/assets/erDiagram-OPXOYQCR-iWrUegxy.js +99 -0
- package/packages/web/dist/assets/flowDiagram-KWPJA3E3-B6DYlbkV.js +213 -0
- package/packages/web/dist/assets/ganttDiagram-FUAMR5RP-D7dSWZcC.js +292 -0
- package/packages/web/dist/assets/gitGraphDiagram-X574FWY7-DguFgcbW.js +106 -0
- package/packages/web/dist/assets/graph-Bn3Yngep.js +1 -0
- package/packages/web/dist/assets/index-B1QvSHA5.js +660 -0
- package/packages/web/dist/assets/index-zwMuaz90.css +32 -0
- package/packages/web/dist/assets/infoDiagram-VRGFBTTK-CuiuO3uo.js +2 -0
- package/packages/web/dist/assets/ishikawaDiagram-OU5B5YK6-wBS1_40m.js +70 -0
- package/packages/web/dist/assets/journeyDiagram-ZHPQQLJL-Bd1YE2gP.js +139 -0
- package/packages/web/dist/assets/kanban-definition-PNTS6WVX-BlQzv_X1.js +89 -0
- package/packages/web/dist/assets/katex-C5jXJg4s.js +257 -0
- package/packages/web/dist/assets/mermaid.core-p3CwmLUb.js +313 -0
- package/packages/web/dist/assets/mindmap-definition-NLK3R4M7-BlticnKl.js +96 -0
- package/packages/web/dist/assets/pegDiagram-GJSIUBJH-BbXsP47B.js +1 -0
- package/packages/web/dist/assets/pieDiagram-5QR66LMP-BooBSBug.js +39 -0
- package/packages/web/dist/assets/quadrantDiagram-O4NWA36T-CkXC6VCh.js +7 -0
- package/packages/web/dist/assets/railroadDiagram-XR7U4H2S-BphzYiW-.js +1 -0
- package/packages/web/dist/assets/requirementDiagram-PLB6GJNP-PWpD4zpQ.js +84 -0
- package/packages/web/dist/assets/sankeyDiagram-IPEJSGJF-5Qm39Vfz.js +40 -0
- package/packages/web/dist/assets/scene-D4LPicHk.js +4620 -0
- package/packages/web/dist/assets/sequenceDiagram-PO4LG4MO-DA673J_w.js +169 -0
- package/packages/web/dist/assets/sizeCapture-INFHLROL-1KsNwBhd.js +1 -0
- package/packages/web/dist/assets/stateDiagram-v2-GCMORJYK-D7O0UyHr.js +291 -0
- package/packages/web/dist/assets/swimlanes-2SLR337P-culFSb1R.js +1 -0
- package/packages/web/dist/assets/swimlanesDiagram-TC7HE7FX-kzTmK2BP.js +8 -0
- package/packages/web/dist/assets/timeline-definition-EJHVYXUP-6GIO5p-k.js +120 -0
- package/packages/web/dist/assets/usecaseDiagram-POWQR4AR-BAGHDBzZ.js +370 -0
- package/packages/web/dist/assets/vennDiagram-UO4OBE2U-PbtBvPRE.js +34 -0
- package/packages/web/dist/assets/wardleyDiagram-VNRHLVJA-9scbtDvX.js +78 -0
- package/packages/web/dist/assets/xychartDiagram-PMCCYNJV-C51PiF4p.js +7 -0
- package/packages/web/dist/draco/draco_decoder.js +33 -0
- package/packages/web/dist/draco/draco_decoder.wasm +0 -0
- package/packages/web/dist/draco/draco_wasm_wrapper.js +116 -0
- package/packages/web/dist/favicon-16.png +0 -0
- package/packages/web/dist/favicon-32.png +0 -0
- package/packages/web/dist/favicon-48.png +0 -0
- package/packages/web/dist/favicon.ico +0 -0
- package/packages/web/dist/favicon.svg +1 -1
- package/packages/web/dist/icon-192.png +0 -0
- package/packages/web/dist/icon-512.png +0 -0
- package/packages/web/dist/index.html +12 -4
- package/packages/web/dist/logo-light.svg +1 -1
- package/packages/web/dist/logo-mono.svg +2 -0
- package/packages/web/dist/logo-stacked-light.svg +2 -0
- package/packages/web/dist/logo-stacked.svg +2 -0
- package/packages/web/dist/logo-white.svg +2 -0
- package/packages/web/dist/logo.svg +1 -1
- package/packages/web/dist/mark-light.svg +1 -1
- package/packages/web/dist/mark-mono.svg +2 -0
- package/packages/web/dist/mark-small-light.svg +2 -0
- package/packages/web/dist/mark-small.svg +2 -0
- package/packages/web/dist/mark-white.svg +2 -0
- package/packages/web/dist/mark.svg +1 -1
- package/packages/web/dist/models/LICENSE.txt +5 -0
- package/packages/web/dist/models/brain.glb +0 -0
- package/packages/web/dist/site.webmanifest +23 -0
- package/packages/web/dist/wordmark-light.svg +2 -0
- package/packages/web/dist/wordmark.svg +2 -0
- package/packages/web/package.json +1 -1
- package/scripts/rookery.mjs +204 -122
- package/scripts/updater.mjs +227 -0
- package/packages/cli/dist/tui/components/Wordmark.d.ts +0 -35
- package/packages/cli/dist/tui/components/Wordmark.d.ts.map +0 -1
- package/packages/cli/dist/tui/components/Wordmark.js +0 -81
- package/packages/cli/dist/tui/components/Wordmark.js.map +0 -1
- package/packages/core/dist/agents/orchestrator.d.ts +0 -24
- package/packages/core/dist/agents/orchestrator.d.ts.map +0 -1
- package/packages/core/dist/agents/orchestrator.js +0 -88
- package/packages/core/dist/agents/orchestrator.js.map +0 -1
- package/packages/core/dist/agents/roles.d.ts +0 -21
- package/packages/core/dist/agents/roles.d.ts.map +0 -1
- package/packages/core/dist/agents/roles.js +0 -81
- package/packages/core/dist/agents/roles.js.map +0 -1
- package/packages/core/dist/agents/team.d.ts +0 -105
- package/packages/core/dist/agents/team.d.ts.map +0 -1
- package/packages/core/dist/agents/team.js +0 -623
- package/packages/core/dist/agents/team.js.map +0 -1
- package/packages/core/dist/providers/codex.d.ts +0 -10
- package/packages/core/dist/providers/codex.d.ts.map +0 -1
- package/packages/core/dist/providers/codex.js +0 -375
- package/packages/core/dist/providers/codex.js.map +0 -1
- package/packages/core/dist/tools/browser.d.ts +0 -20
- package/packages/core/dist/tools/browser.d.ts.map +0 -1
- package/packages/core/dist/tools/browser.js +0 -72
- package/packages/core/dist/tools/browser.js.map +0 -1
- package/packages/server/dist/routes/agents.d.ts +0 -5
- package/packages/server/dist/routes/agents.d.ts.map +0 -1
- package/packages/server/dist/routes/agents.js +0 -6
- package/packages/server/dist/routes/agents.js.map +0 -1
- package/packages/server/dist/routes/team.d.ts +0 -11
- package/packages/server/dist/routes/team.d.ts.map +0 -1
- package/packages/server/dist/routes/team.js +0 -36
- package/packages/server/dist/routes/team.js.map +0 -1
- package/packages/web/dist/assets/3d-force-graph-BPZmoydi.js +0 -1163
- package/packages/web/dist/assets/index-IBSTzK7-.js +0 -1255
- package/packages/web/dist/assets/index-qUXUui7W.css +0 -1
- package/packages/web/dist/assets/three-spritetext-B9ZIW7c-.js +0 -4
- package/packages/web/dist/assets/three.module-cmFfBtHS.js +0 -4228
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import { fetchFrame } from './frame.js';
|
|
2
|
+
import { resolvePolicy } from './policy.js';
|
|
3
|
+
import { measure } from './measure.js';
|
|
4
|
+
/**
|
|
5
|
+
* The night's grid probe (dream stage 1, AP10; concept 6.1, 5.5a, 3.3).
|
|
6
|
+
*
|
|
7
|
+
* Stage 1 needs no candidate writer: the first delivered answer to "is our
|
|
8
|
+
* retrieval any good?" is a fixed, declared grid of parameter placements
|
|
9
|
+
* scored against the incumbent over the recorded frames. Zero model calls,
|
|
10
|
+
* zero promotions, no policy_versions - the result is a number per placement
|
|
11
|
+
* plus a certificate of what that number is worth.
|
|
12
|
+
*
|
|
13
|
+
* Four contracts hold everywhere in this module:
|
|
14
|
+
*
|
|
15
|
+
* - It never writes to the bank. `fetchFrame` has no touch path at all and
|
|
16
|
+
* `measure` is pure, so `touch: false` is not a flag anyone could flip by
|
|
17
|
+
* accident - it is the absence of a write path (R6). The test that pins this
|
|
18
|
+
* compares `access_count` and `usefulness` of every row before and after a
|
|
19
|
+
* full probe, because a watcher that feeds the feedback loop it watches
|
|
20
|
+
* would be worse than no watcher.
|
|
21
|
+
* - It never throws. `ask` in sleep.ts never throws either; a phase that
|
|
22
|
+
* throws would be the first real throw site in the night block. Everything
|
|
23
|
+
* in here catches and reports into the result instead.
|
|
24
|
+
* - It runs on wall-clock budgets. "Zero model calls" is not "zero cost":
|
|
25
|
+
* the probe reads frames of 40-90 KB, JSON.parses them and drives 8-12
|
|
26
|
+
* placements over each, on the one synchronous connection the server uses.
|
|
27
|
+
* The overall deadline is `dream.maxEvalMs` (reported like modelCalls, R8);
|
|
28
|
+
* on top of that, no single frame may eat more than FRAME_TIME_LIMIT_MS -
|
|
29
|
+
* a monstrous frame is abstained, not allowed to starve the shared budget.
|
|
30
|
+
* - The first line of every entry point is the abort guard. There is no
|
|
31
|
+
* `#throwIfAborted` between the cycle-loop boundaries the probe is wedged
|
|
32
|
+
* into, so the probe carries its own.
|
|
33
|
+
*
|
|
34
|
+
* What the estimator is worth: with no label writer (stage 1), the night
|
|
35
|
+
* supplies an empty gain and every frame abstains with `no-reachable-label`.
|
|
36
|
+
* That is the honest number - machinery exercised, coverage reported as
|
|
37
|
+
* absent, and Phase 2's label sources turn it into a real one. The estimator
|
|
38
|
+
* is a lower bound (R2) even once labels exist; see the quotation at the head
|
|
39
|
+
* of dream/measure.ts.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* How many stored frames one night walks, oldest first (the store default).
|
|
43
|
+
* Above the limit the newest frames fall out of the pool - reported through
|
|
44
|
+
* `framesTotal`/`poolTruncated`, never hidden inside a smaller count.
|
|
45
|
+
*/
|
|
46
|
+
const FRAME_POOL_LIMIT = 500;
|
|
47
|
+
/**
|
|
48
|
+
* Inner sub-cap of `dream.maxEvalMs`: the processing of a single frame is cut
|
|
49
|
+
* off after this many milliseconds and the frame is abstained - no monstrous
|
|
50
|
+
* frame may eat the shared wall clock on its own (build plan, AP10).
|
|
51
|
+
*/
|
|
52
|
+
const FRAME_TIME_LIMIT_MS = 2000;
|
|
53
|
+
/** Cluster-bootstrap draws over sessions, percentile interval 2.5/97.5. */
|
|
54
|
+
const BOOTSTRAP_B = 2000;
|
|
55
|
+
/** Fixed seed: the interval must be reproducible, never per-run random. */
|
|
56
|
+
const BOOTSTRAP_SEED = 20260917;
|
|
57
|
+
/**
|
|
58
|
+
* Below this |delta| a sign flip between the frozen and the live world is not
|
|
59
|
+
* a finding. The concept's `dream.margin` key belongs to Phase 3's gate and
|
|
60
|
+
* has no reader in stage 1 (R16), so the probe carries the literal.
|
|
61
|
+
*/
|
|
62
|
+
const FRESHNESS_MARGIN = 0.02;
|
|
63
|
+
/** Mirrors the prefix `Store` writes corpus stamps under (store.ts, AP7). */
|
|
64
|
+
const CORPUS_STAMP_PREFIX = 'dream.corpus_stamp.';
|
|
65
|
+
/** Written by `reindex` and the bulk import (db.ts, AP1); read here. */
|
|
66
|
+
const CORPUS_INVALIDATED_KEY = 'dream.corpus_invalidated_at';
|
|
67
|
+
/** The grid the stage prescribes: at least 8, at most 12 placements. */
|
|
68
|
+
const GRID_MIN = 8;
|
|
69
|
+
const GRID_MAX = 12;
|
|
70
|
+
/** Every reason a frame can go unscored, zeroed - counted, never swallowed. */
|
|
71
|
+
const ABSTAIN_REASONS = [
|
|
72
|
+
'limit-out-of-box',
|
|
73
|
+
'seeds-capped',
|
|
74
|
+
'degraded-turn',
|
|
75
|
+
'frame-missing',
|
|
76
|
+
'corpus-drifted',
|
|
77
|
+
'corpus-invalidated',
|
|
78
|
+
'budget-changed',
|
|
79
|
+
'no-reachable-label',
|
|
80
|
+
'no-labelled-move',
|
|
81
|
+
'pipeline-mismatch',
|
|
82
|
+
'no-label-source',
|
|
83
|
+
'unfinished',
|
|
84
|
+
];
|
|
85
|
+
function emptyReasons() {
|
|
86
|
+
const reasons = {};
|
|
87
|
+
for (const reason of ABSTAIN_REASONS)
|
|
88
|
+
reasons[reason] = 0;
|
|
89
|
+
return reasons;
|
|
90
|
+
}
|
|
91
|
+
function addReasons(target, source) {
|
|
92
|
+
for (const reason of ABSTAIN_REASONS)
|
|
93
|
+
target[reason] += source[reason] ?? 0;
|
|
94
|
+
}
|
|
95
|
+
/** Clamp to a range, for dream keys read outside the patch schema (E21). */
|
|
96
|
+
function clampNumber(value, lo, hi) {
|
|
97
|
+
const safe = Number.isFinite(value) ? value : lo;
|
|
98
|
+
return Math.min(hi, Math.max(lo, safe));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The corpus stamp a frame was recorded under, read from `meta`. The prefix
|
|
102
|
+
* mirrors the writer in store.ts (AP7 owns it; this module only reads). An
|
|
103
|
+
* empty id - a frame recorded before any night stamped a fingerprint - and a
|
|
104
|
+
* corrupted row both return null: a stamp that cannot be read certifies
|
|
105
|
+
* nothing, and the drift check is waived rather than guessed.
|
|
106
|
+
*/
|
|
107
|
+
function stampById(store, id) {
|
|
108
|
+
if (!id)
|
|
109
|
+
return null;
|
|
110
|
+
const raw = store.getMeta(CORPUS_STAMP_PREFIX + id);
|
|
111
|
+
if (!raw)
|
|
112
|
+
return null;
|
|
113
|
+
try {
|
|
114
|
+
return JSON.parse(raw);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** When `reindex` or the bulk import last moved the corpus stamp (0 = never). */
|
|
121
|
+
function readInvalidatedAt(store) {
|
|
122
|
+
const raw = store.getMeta(CORPUS_INVALIDATED_KEY);
|
|
123
|
+
const value = raw === null ? 0 : Number(raw);
|
|
124
|
+
return Number.isFinite(value) ? value : 0;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The fixed placements, in fixed order. Deterministic and declared in this
|
|
128
|
+
* file (concept 6.1): weights at the box edges, the threshold in three steps,
|
|
129
|
+
* the hop weights in two, plus a few mixed vectors that name the strategies a
|
|
130
|
+
* real candidate would try - all relevance, all context, usage off. The first
|
|
131
|
+
* entry is always the incumbent, because the incumbent is always a candidate
|
|
132
|
+
* and runs in the same pass, never as a number from yesterday (concept 6.3).
|
|
133
|
+
*/
|
|
134
|
+
const GRID = [
|
|
135
|
+
{ w: 'incumbent', threshold: 'incumbent', hopEntity: 'incumbent', hopEdge: 'incumbent' },
|
|
136
|
+
{ w: 'lo', threshold: 'lo', hopEntity: 'lo', hopEdge: 'lo' },
|
|
137
|
+
{ w: 'lo', threshold: 'mid', hopEntity: 'hi', hopEdge: 'hi' },
|
|
138
|
+
{ w: 'hi', threshold: 'lo', hopEntity: 'lo', hopEdge: 'lo' },
|
|
139
|
+
{ w: 'hi', threshold: 'hi', hopEntity: 'hi', hopEdge: 'hi' },
|
|
140
|
+
{ w: 'relevance-heavy', threshold: 'mid', hopEntity: 'incumbent', hopEdge: 'incumbent' },
|
|
141
|
+
{ w: 'context-heavy', threshold: 'mid', hopEntity: 'incumbent', hopEdge: 'incumbent' },
|
|
142
|
+
{ w: 'incumbent', threshold: 'hi', hopEntity: 'incumbent', hopEdge: 'incumbent' },
|
|
143
|
+
{ w: 'incumbent', threshold: 'lo', hopEntity: 'hi', hopEdge: 'hi' },
|
|
144
|
+
{ w: 'incumbent', threshold: 'mid', hopEntity: 'hi', hopEdge: 'lo' },
|
|
145
|
+
{ w: 'mid', threshold: 'mid', hopEntity: 'mid', hopEdge: 'mid' },
|
|
146
|
+
{ w: 'usage-off', threshold: 'lo', hopEntity: 'lo', hopEdge: 'hi' },
|
|
147
|
+
];
|
|
148
|
+
function cornerValue(corner, interval, incumbent) {
|
|
149
|
+
if (corner === 'lo')
|
|
150
|
+
return interval[0];
|
|
151
|
+
if (corner === 'hi')
|
|
152
|
+
return interval[1];
|
|
153
|
+
if (corner === 'mid')
|
|
154
|
+
return (interval[0] + interval[1]) / 2;
|
|
155
|
+
// The recorded point, pulled back into the box it declared - a no-op for
|
|
156
|
+
// every box the recorder stretched over its realised policy.
|
|
157
|
+
return Math.min(interval[1], Math.max(interval[0], incumbent));
|
|
158
|
+
}
|
|
159
|
+
function weightVector(choice, box, policy) {
|
|
160
|
+
const w = box.w;
|
|
161
|
+
const p = policy.w;
|
|
162
|
+
const pick = (corner, interval, value) => cornerValue(corner, interval, value);
|
|
163
|
+
switch (choice) {
|
|
164
|
+
case 'incumbent':
|
|
165
|
+
return {
|
|
166
|
+
relevance: pick('incumbent', w.relevance, p.relevance),
|
|
167
|
+
importance: pick('incumbent', w.importance, p.importance),
|
|
168
|
+
recency: pick('incumbent', w.recency, p.recency),
|
|
169
|
+
usage: pick('incumbent', w.usage, p.usage),
|
|
170
|
+
};
|
|
171
|
+
case 'lo':
|
|
172
|
+
case 'hi':
|
|
173
|
+
case 'mid':
|
|
174
|
+
return {
|
|
175
|
+
relevance: pick(choice, w.relevance, p.relevance),
|
|
176
|
+
importance: pick(choice, w.importance, p.importance),
|
|
177
|
+
recency: pick(choice, w.recency, p.recency),
|
|
178
|
+
usage: pick(choice, w.usage, p.usage),
|
|
179
|
+
};
|
|
180
|
+
case 'relevance-heavy':
|
|
181
|
+
// Trust the text match, nothing else.
|
|
182
|
+
return { relevance: w.relevance[1], importance: w.importance[0], recency: w.recency[0], usage: w.usage[0] };
|
|
183
|
+
case 'context-heavy':
|
|
184
|
+
// Trust what the bank claims about itself over the query.
|
|
185
|
+
return { relevance: w.relevance[0], importance: w.importance[1], recency: w.recency[1], usage: w.usage[0] };
|
|
186
|
+
case 'usage-off':
|
|
187
|
+
// Close the usage channel entirely (H2 lives on it) and stay aggressive.
|
|
188
|
+
return { relevance: w.relevance[1], importance: w.importance[1], recency: (w.recency[0] + w.recency[1]) / 2, usage: w.usage[0] };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The fixed grid over one frame's declared box, around its recorded policy.
|
|
193
|
+
* `size` is `dream.gridSize`, clamped into the 8..12 the stage prescribes -
|
|
194
|
+
* a config that bypassed the patch schema (E21) cannot ask for a 2-placement
|
|
195
|
+
* grid or a 500-placement one. Every returned point sits inside the box by
|
|
196
|
+
* construction, so no placement can hit `limit-out-of-box` (that reason
|
|
197
|
+
* firing is a recorder error, concept 5.4 - the box promised closure).
|
|
198
|
+
*/
|
|
199
|
+
export function buildGrid(policy, box, size) {
|
|
200
|
+
const count = Number.isFinite(size) ? Math.min(GRID_MAX, Math.max(GRID_MIN, Math.round(size))) : 10;
|
|
201
|
+
const limit = Math.max(0, Math.min(policy.limit, box.limitMax));
|
|
202
|
+
return GRID.slice(0, count).map((spec) => ({
|
|
203
|
+
limit,
|
|
204
|
+
threshold: cornerValue(spec.threshold, box.threshold, policy.threshold),
|
|
205
|
+
hopEntity: cornerValue(spec.hopEntity, box.hopEntity, policy.hopEntity),
|
|
206
|
+
hopEdge: cornerValue(spec.hopEdge, box.hopEdge, policy.hopEdge),
|
|
207
|
+
w: weightVector(spec.w, box, policy),
|
|
208
|
+
}));
|
|
209
|
+
}
|
|
210
|
+
/* ----------------------------- corpus drift ----------------------------- */
|
|
211
|
+
/**
|
|
212
|
+
* Whether the document frequency of THIS frame's tokens moved further than
|
|
213
|
+
* `tolerance` between the stamp the frame was recorded under and `today`
|
|
214
|
+
* (R10, concept 3.3). bm25 is frozen in the frame and can never be
|
|
215
|
+
* revalidated, so the corpus is the only observable that correlates with a
|
|
216
|
+
* frame going stale - and this is the check on it, run against the
|
|
217
|
+
* once-per-night fingerprint, never inside a turn.
|
|
218
|
+
*
|
|
219
|
+
* A frame without a recorded stamp is waived, not condemned: before the first
|
|
220
|
+
* night there was nothing to stamp, and abstaining that entire pool would
|
|
221
|
+
* kill the very first probe. Frames older than a reindex or bulk import are
|
|
222
|
+
* `corpus-invalidated`, a different reason - never guessed here.
|
|
223
|
+
*
|
|
224
|
+
* A token one of the stamps never measured is unknown, not df 0: the nightly
|
|
225
|
+
* stamp covers only the tokens of its own pool, so a query token that entered
|
|
226
|
+
* the bank after the recording night moved nothing that was measured. Such a
|
|
227
|
+
* token falls out of the comparison - only tokens with a df on both sides
|
|
228
|
+
* count, and a frame with none of those is waived here, never condemned: a
|
|
229
|
+
* stamp that cannot be read certifies nothing (and the store writes measured
|
|
230
|
+
* zeros explicitly, so a missing key really is an unmeasured token).
|
|
231
|
+
*/
|
|
232
|
+
export function corpusDrifted(frame, today, tolerance, recorded) {
|
|
233
|
+
if (!recorded)
|
|
234
|
+
return false;
|
|
235
|
+
let worst = 0;
|
|
236
|
+
for (const token of frame.query.tokens) {
|
|
237
|
+
const then = recorded.df[token];
|
|
238
|
+
const now = today.df[token];
|
|
239
|
+
if (then === undefined || now === undefined)
|
|
240
|
+
continue;
|
|
241
|
+
// max(1, then): a token that went from 0 to 1 has moved as far as a
|
|
242
|
+
// token can - df 0 cannot halve, and dividing by 0 would say otherwise.
|
|
243
|
+
worst = Math.max(worst, Math.abs(now - then) / Math.max(1, then));
|
|
244
|
+
}
|
|
245
|
+
return worst > tolerance;
|
|
246
|
+
}
|
|
247
|
+
/* ------------------------- the cluster bootstrap ------------------------- */
|
|
248
|
+
/**
|
|
249
|
+
* Deterministic PRNG (mulberry32). The percentile interval must be
|
|
250
|
+
* reproducible across runs - a confidence interval that moves between two
|
|
251
|
+
* identical nights is noise dressed up as statistics.
|
|
252
|
+
*/
|
|
253
|
+
function mulberry32(seed) {
|
|
254
|
+
let a = seed >>> 0;
|
|
255
|
+
return () => {
|
|
256
|
+
a = (a + 0x6d2b79f5) | 0;
|
|
257
|
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
258
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
259
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Percentile interval (2.5/97.5) of the mean over a cluster bootstrap
|
|
264
|
+
* (concept 5.3): `clusterDeltas` holds the per-trace deltas grouped by
|
|
265
|
+
* SESSION - consecutive turns of one session share topic, bank cutout and
|
|
266
|
+
* entity neighbourhood, so bootstrapping over traces would understate the
|
|
267
|
+
* variance and let `ci_low > 0` fire on leakage. Each draw samples clusters
|
|
268
|
+
* with replacement and takes the mean of every delta of the drawn clusters;
|
|
269
|
+
* the reported interval is approximate, and the stage says so next to the
|
|
270
|
+
* number rather than in a footnote.
|
|
271
|
+
*/
|
|
272
|
+
export function bootstrapCi(clusterDeltas, b = BOOTSTRAP_B) {
|
|
273
|
+
const clusters = clusterDeltas.filter((cluster) => cluster.length > 0);
|
|
274
|
+
if (!clusters.length)
|
|
275
|
+
return null;
|
|
276
|
+
const random = mulberry32(BOOTSTRAP_SEED);
|
|
277
|
+
const means = [];
|
|
278
|
+
for (let draw = 0; draw < b; draw += 1) {
|
|
279
|
+
let sum = 0;
|
|
280
|
+
let count = 0;
|
|
281
|
+
for (let index = 0; index < clusters.length; index += 1) {
|
|
282
|
+
const cluster = clusters[Math.floor(random() * clusters.length)];
|
|
283
|
+
for (const delta of cluster) {
|
|
284
|
+
sum += delta;
|
|
285
|
+
count += 1;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
means.push(count ? sum / count : 0);
|
|
289
|
+
}
|
|
290
|
+
means.sort((x, y) => x - y);
|
|
291
|
+
const low = means[Math.min(means.length - 1, Math.floor(0.025 * means.length))];
|
|
292
|
+
const high = means[Math.max(0, Math.min(means.length - 1, Math.ceil(0.975 * means.length) - 1))];
|
|
293
|
+
return { low, high: Math.max(high, low) };
|
|
294
|
+
}
|
|
295
|
+
/* ---------------------------- the freshness test ---------------------------- */
|
|
296
|
+
/** What "the rows" of a frame are, for the frozen-versus-live comparison. */
|
|
297
|
+
function rowsSignature(frame) {
|
|
298
|
+
return JSON.stringify([
|
|
299
|
+
frame.hop1.map((row) => [row.id, row.relevance]),
|
|
300
|
+
frame.possibleSeeds,
|
|
301
|
+
frame.profile.map((row) => row.id),
|
|
302
|
+
]);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* The frame-ageing sensor (concept 5.5a): baseline and candidate run twice,
|
|
306
|
+
* once against the frozen frames and once against a FRESH `fetchFrame` with
|
|
307
|
+
* the same query text, the same owner and the same box. The live run is
|
|
308
|
+
* knowingly polluted - entity recounts, night-written edges, drifting
|
|
309
|
+
* importance all push both arms the same way - which is exactly why a sign
|
|
310
|
+
* FLIP means the ordering of the two policies is not robust against bank
|
|
311
|
+
* movement, the thing the bootstrap cannot see because it holds the bank
|
|
312
|
+
* fixed. A polluted number may serve as a comparator, never as a measurement.
|
|
313
|
+
*
|
|
314
|
+
* This function never writes: the fresh fetch goes through `fetchFrame`,
|
|
315
|
+
* which has no touch path at all (R6).
|
|
316
|
+
*/
|
|
317
|
+
export function freshnessCheck(store, entries, options) {
|
|
318
|
+
const report = {
|
|
319
|
+
frames: entries.length,
|
|
320
|
+
closedFrozen: 0,
|
|
321
|
+
closedLive: 0,
|
|
322
|
+
closedBoth: 0,
|
|
323
|
+
deltaFrozen: null,
|
|
324
|
+
deltaLive: null,
|
|
325
|
+
signAgree: null,
|
|
326
|
+
rowsDifferShare: 0,
|
|
327
|
+
abstainReasons: emptyReasons(),
|
|
328
|
+
frameTimeouts: 0,
|
|
329
|
+
entries: [],
|
|
330
|
+
};
|
|
331
|
+
// First line of work: the abort guard.
|
|
332
|
+
if (options.signal?.aborted)
|
|
333
|
+
return report;
|
|
334
|
+
const gain = options.gain;
|
|
335
|
+
const frozenDeltas = [];
|
|
336
|
+
const liveDeltas = [];
|
|
337
|
+
let rowsDiffer = 0;
|
|
338
|
+
let compared = 0;
|
|
339
|
+
for (const entry of entries) {
|
|
340
|
+
if (options.signal?.aborted)
|
|
341
|
+
break;
|
|
342
|
+
const now = Date.now();
|
|
343
|
+
if (options.deadline !== undefined && now > options.deadline)
|
|
344
|
+
break;
|
|
345
|
+
const frameDeadline = options.deadline !== undefined
|
|
346
|
+
? Math.min(options.deadline, now + FRAME_TIME_LIMIT_MS)
|
|
347
|
+
: now + FRAME_TIME_LIMIT_MS;
|
|
348
|
+
const payload = entry.frame.payload;
|
|
349
|
+
const policy = entry.trace.policySet.recall ??
|
|
350
|
+
resolvePolicy(store, options.config, entry.trace.owner, 'recall');
|
|
351
|
+
const grid = buildGrid(policy, payload.box, GRID_MIN);
|
|
352
|
+
const baseline = options.baseline ?? grid[0];
|
|
353
|
+
const candidate = options.candidate ?? grid[1];
|
|
354
|
+
// The live re-fetch. A MATCH the parser rejects degrades inside the
|
|
355
|
+
// frame (three worlds, not two); anything else that throws skips this
|
|
356
|
+
// frame's live side as `frame-missing` rather than breaking the night.
|
|
357
|
+
let fresh = null;
|
|
358
|
+
try {
|
|
359
|
+
fresh = fetchFrame(store, {
|
|
360
|
+
text: payload.query.text,
|
|
361
|
+
owner: payload.owner,
|
|
362
|
+
limit: payload.box.limitMax,
|
|
363
|
+
kinds: payload.box.kinds,
|
|
364
|
+
minImportance: payload.box.minImportance,
|
|
365
|
+
box: payload.box,
|
|
366
|
+
site: payload.site,
|
|
367
|
+
pipeline: payload.pipeline,
|
|
368
|
+
budgetChars: payload.budgetChars,
|
|
369
|
+
subject: payload.subject,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
fresh = null;
|
|
374
|
+
}
|
|
375
|
+
const differ = fresh !== null && rowsSignature(payload) !== rowsSignature(fresh);
|
|
376
|
+
if (fresh !== null) {
|
|
377
|
+
compared += 1;
|
|
378
|
+
if (differ)
|
|
379
|
+
rowsDiffer += 1;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
report.abstainReasons['frame-missing'] += 1;
|
|
383
|
+
}
|
|
384
|
+
const entryOut = {
|
|
385
|
+
frozen: entry.frame,
|
|
386
|
+
fresh,
|
|
387
|
+
rowsDiffer: differ,
|
|
388
|
+
frozenDelta: null,
|
|
389
|
+
liveDelta: null,
|
|
390
|
+
};
|
|
391
|
+
// A frame past its sub-cap is abstained: no monstrous frame may eat the
|
|
392
|
+
// shared wall clock on its own.
|
|
393
|
+
if (Date.now() > frameDeadline) {
|
|
394
|
+
report.frameTimeouts += 1;
|
|
395
|
+
report.entries.push(entryOut);
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
const frozenBase = measure(payload, baseline, gain, options.costWeight);
|
|
399
|
+
const frozenCand = measure(payload, candidate, gain, options.costWeight);
|
|
400
|
+
if (!frozenBase.ok)
|
|
401
|
+
report.abstainReasons[frozenBase.abstain] += 1;
|
|
402
|
+
if (!frozenCand.ok)
|
|
403
|
+
report.abstainReasons[frozenCand.abstain] += 1;
|
|
404
|
+
if (frozenBase.ok && frozenCand.ok) {
|
|
405
|
+
entryOut.frozenDelta = frozenCand.score - frozenBase.score;
|
|
406
|
+
report.closedFrozen += 1;
|
|
407
|
+
}
|
|
408
|
+
if (fresh) {
|
|
409
|
+
const liveBase = measure(fresh, baseline, gain, options.costWeight);
|
|
410
|
+
const liveCand = measure(fresh, candidate, gain, options.costWeight);
|
|
411
|
+
if (!liveBase.ok)
|
|
412
|
+
report.abstainReasons[liveBase.abstain] += 1;
|
|
413
|
+
if (!liveCand.ok)
|
|
414
|
+
report.abstainReasons[liveCand.abstain] += 1;
|
|
415
|
+
if (liveBase.ok && liveCand.ok) {
|
|
416
|
+
entryOut.liveDelta = liveCand.score - liveBase.score;
|
|
417
|
+
report.closedLive += 1;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if (entryOut.frozenDelta !== null && entryOut.liveDelta !== null) {
|
|
421
|
+
report.closedBoth += 1;
|
|
422
|
+
frozenDeltas.push(entryOut.frozenDelta);
|
|
423
|
+
liveDeltas.push(entryOut.liveDelta);
|
|
424
|
+
}
|
|
425
|
+
report.entries.push(entryOut);
|
|
426
|
+
}
|
|
427
|
+
const mean = (values) => values.length ? values.reduce((total, value) => total + value, 0) / values.length : null;
|
|
428
|
+
report.deltaFrozen = mean(frozenDeltas);
|
|
429
|
+
report.deltaLive = mean(liveDeltas);
|
|
430
|
+
report.rowsDifferShare = compared ? rowsDiffer / compared : 0;
|
|
431
|
+
if (report.deltaFrozen !== null && report.deltaLive !== null) {
|
|
432
|
+
if (Math.abs(report.deltaFrozen) <= FRESHNESS_MARGIN)
|
|
433
|
+
report.signAgree = null;
|
|
434
|
+
else {
|
|
435
|
+
const frozenSign = Math.sign(report.deltaFrozen);
|
|
436
|
+
const liveSign = Math.sign(report.deltaLive);
|
|
437
|
+
report.signAgree = frozenSign === liveSign ? 1 : 0;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return report;
|
|
441
|
+
}
|
|
442
|
+
function emptyProbeReport() {
|
|
443
|
+
return {
|
|
444
|
+
tracesSeen: 0,
|
|
445
|
+
frames: 0,
|
|
446
|
+
framesTotal: 0,
|
|
447
|
+
poolTruncated: false,
|
|
448
|
+
framesScored: 0,
|
|
449
|
+
placements: [],
|
|
450
|
+
abstainReasons: emptyReasons(),
|
|
451
|
+
invalidated: 0,
|
|
452
|
+
invalidatedAt: null,
|
|
453
|
+
corpusStampId: '',
|
|
454
|
+
evalMs: 0,
|
|
455
|
+
deadlineHit: false,
|
|
456
|
+
frameTimeouts: 0,
|
|
457
|
+
modelCalls: 0,
|
|
458
|
+
error: null,
|
|
459
|
+
freshness: null,
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
/** The budget the assistant turn renders with; mirrors runtime.ts (AP9). */
|
|
463
|
+
function expectedBudgetChars(config) {
|
|
464
|
+
return Math.floor(config.memory.contextBudget * 0.4);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Run the night's model-free evaluation: load the stored frames, score the
|
|
468
|
+
* declared grid against each frame's own incumbent, aggregate paired per
|
|
469
|
+
* trace, bootstrap over sessions, and run the freshness sensor over what
|
|
470
|
+
* passed the pre-checks. Nothing is promoted, nothing but the nightly corpus
|
|
471
|
+
* stamp is written (`corpusFingerprint`, the one meta write R10 prescribes),
|
|
472
|
+
* nothing is thrown - the result is numbers plus their certificates.
|
|
473
|
+
*
|
|
474
|
+
* The pre-checks fire in a fixed order, and the order is the contract: an
|
|
475
|
+
* unfinished trace first, then `corpus-invalidated` (older than a reindex or
|
|
476
|
+
* bulk import - never guessed as drift), then `corpus-drifted` against the
|
|
477
|
+
* night's fingerprint, then `budget-changed` against the config the turn
|
|
478
|
+
* would render with today. `no-label-source` does not fire here because
|
|
479
|
+
* stage 1 probes only the assistant's bank - the only owner whose replay
|
|
480
|
+
* phase can ever earn a correction label.
|
|
481
|
+
*/
|
|
482
|
+
export function runGridProbe(store, config, owner, runId, signal, options = {}) {
|
|
483
|
+
// The abort guard is the first line: there is no #throwIfAborted between
|
|
484
|
+
// the cycle-loop boundaries this call is wedged into (build plan, AP10).
|
|
485
|
+
if (signal.aborted)
|
|
486
|
+
return emptyProbeReport();
|
|
487
|
+
const startedAt = Date.now();
|
|
488
|
+
const state = emptyProbeReport();
|
|
489
|
+
try {
|
|
490
|
+
const dream = config.memory.dream;
|
|
491
|
+
const maxEvalMs = clampNumber(dream.maxEvalMs, 0, 3_600_000);
|
|
492
|
+
// One wall clock for the whole dream, not one per part (concept 6.1):
|
|
493
|
+
// where the night hands its own deadline down, that is the ceiling. A
|
|
494
|
+
// pool cut into pieces must not be able to buy itself a second budget,
|
|
495
|
+
// and the probe running its own copy of `maxEvalMs` was exactly that -
|
|
496
|
+
// it could legally spend the whole of it and leave the slot behind it
|
|
497
|
+
// starting past its deadline.
|
|
498
|
+
const handed = options.deadline;
|
|
499
|
+
const deadline = handed !== undefined && Number.isFinite(handed) ? handed : startedAt + maxEvalMs;
|
|
500
|
+
// A budget that is switched off, or one the caller has already spent, is
|
|
501
|
+
// a legitimate state and not an error: the probe reports nothing scored
|
|
502
|
+
// and the night carries on (the wall-clock test).
|
|
503
|
+
if (deadline <= startedAt) {
|
|
504
|
+
state.deadlineHit = true;
|
|
505
|
+
state.evalMs = Date.now() - startedAt;
|
|
506
|
+
return state;
|
|
507
|
+
}
|
|
508
|
+
const gain = options.gain ?? (() => 0);
|
|
509
|
+
const costWeight = clampNumber(dream.costWeight, 0, 1);
|
|
510
|
+
const tolerance = clampNumber(dream.corpusTolerance, 0, 10);
|
|
511
|
+
// Frames this very night wrote are not measuring material - a night
|
|
512
|
+
// never scores its own writes (in stage 1 it writes none, but the
|
|
513
|
+
// exclusion is the reason the run id is a parameter at all).
|
|
514
|
+
const pool = store.framesFor(owner, { limit: FRAME_POOL_LIMIT });
|
|
515
|
+
// Before anything that could throw: the pool cut must be visible even
|
|
516
|
+
// in a run that errors later. `framesFor` walks oldest first, so a pool
|
|
517
|
+
// at the limit has dropped the newest frames - the measurement covers
|
|
518
|
+
// fewer frames than exist, and the report says so instead of hiding it.
|
|
519
|
+
state.framesTotal = store.dreamFrameCount(owner);
|
|
520
|
+
state.poolTruncated = state.framesTotal > pool.length;
|
|
521
|
+
const entries = pool.filter((entry) => entry.trace.sleepRunId !== runId);
|
|
522
|
+
state.frames = entries.length;
|
|
523
|
+
state.tracesSeen = new Set(entries.map((entry) => entry.trace.id)).size;
|
|
524
|
+
// The night's one corpus fingerprint, over the tokens of its own frames
|
|
525
|
+
// (R10): the vocabulary scan walks the whole index, which is why it runs
|
|
526
|
+
// here and never inside a turn. It also becomes the stamp the next day's
|
|
527
|
+
// turns carry.
|
|
528
|
+
const corpus = store.corpusFingerprint(owner, [...new Set(entries.flatMap((entry) => entry.frame.payload.query.tokens))]);
|
|
529
|
+
state.corpusStampId = corpus.id;
|
|
530
|
+
const invalidatedAt = readInvalidatedAt(store);
|
|
531
|
+
const budget = expectedBudgetChars(config);
|
|
532
|
+
const preReasons = emptyReasons();
|
|
533
|
+
const eligible = [];
|
|
534
|
+
const clusters = [];
|
|
535
|
+
const grids = [];
|
|
536
|
+
const armsByFrame = [];
|
|
537
|
+
for (const entry of entries) {
|
|
538
|
+
if (signal.aborted)
|
|
539
|
+
break;
|
|
540
|
+
const now = Date.now();
|
|
541
|
+
if (now > deadline) {
|
|
542
|
+
state.deadlineHit = true;
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
const frameDeadline = Math.min(deadline, now + FRAME_TIME_LIMIT_MS);
|
|
546
|
+
const payload = entry.frame.payload;
|
|
547
|
+
let reason = null;
|
|
548
|
+
if (!entry.trace.finishedAt)
|
|
549
|
+
reason = 'unfinished';
|
|
550
|
+
else if (invalidatedAt > 0 && entry.frame.createdAt < invalidatedAt) {
|
|
551
|
+
reason = 'corpus-invalidated';
|
|
552
|
+
state.invalidated += 1;
|
|
553
|
+
}
|
|
554
|
+
else if (corpusDrifted(payload, corpus, tolerance, stampById(store, payload.corpusStampId))) {
|
|
555
|
+
reason = 'corpus-drifted';
|
|
556
|
+
}
|
|
557
|
+
else if (payload.pipeline === 'assistant' && payload.budgetChars !== budget) {
|
|
558
|
+
reason = 'budget-changed';
|
|
559
|
+
}
|
|
560
|
+
if (reason) {
|
|
561
|
+
preReasons[reason] += 1;
|
|
562
|
+
state.abstainReasons[reason] += 1;
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
eligible.push(entry);
|
|
566
|
+
clusters.push(entry.trace.sessionId ?? entry.trace.id);
|
|
567
|
+
const policy = entry.trace.policySet.recall ?? resolvePolicy(store, config, owner, 'recall');
|
|
568
|
+
const grid = buildGrid(policy, payload.box, dream.gridSize);
|
|
569
|
+
grids.push(grid);
|
|
570
|
+
const arms = [];
|
|
571
|
+
for (let index = 0; index < grid.length; index += 1) {
|
|
572
|
+
// The inner sub-cap: one frame may not eat the shared wall clock.
|
|
573
|
+
if (Date.now() > frameDeadline) {
|
|
574
|
+
state.frameTimeouts += 1;
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
const result = measure(payload, grid[index], gain, costWeight);
|
|
578
|
+
state.framesScored += 1;
|
|
579
|
+
if (!result.ok)
|
|
580
|
+
state.abstainReasons[result.abstain] += 1;
|
|
581
|
+
arms.push({ placement: index, result });
|
|
582
|
+
}
|
|
583
|
+
armsByFrame.push(arms);
|
|
584
|
+
}
|
|
585
|
+
// Aggregate per placement, paired against the incumbent of the SAME
|
|
586
|
+
// frame: both arms come from one grid, so a delta is a within-frame
|
|
587
|
+
// comparison and never a number against yesterday's incumbent.
|
|
588
|
+
const placementCount = grids[0]?.length ?? 0;
|
|
589
|
+
for (let index = 0; index < placementCount; index += 1) {
|
|
590
|
+
const ownReasons = emptyReasons();
|
|
591
|
+
addReasons(ownReasons, preReasons);
|
|
592
|
+
const deltas = [];
|
|
593
|
+
const coverages = [];
|
|
594
|
+
let closed = 0;
|
|
595
|
+
for (let entryIndex = 0; entryIndex < eligible.length; entryIndex += 1) {
|
|
596
|
+
const arms = armsByFrame[entryIndex] ?? [];
|
|
597
|
+
const arm = arms.find((candidate) => candidate.placement === index);
|
|
598
|
+
const base = arms.find((candidate) => candidate.placement === 0);
|
|
599
|
+
if (!arm || !base)
|
|
600
|
+
continue;
|
|
601
|
+
if (!arm.result.ok) {
|
|
602
|
+
ownReasons[arm.result.abstain] += 1;
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
coverages.push(arm.result.coverage);
|
|
606
|
+
if (base.result.ok) {
|
|
607
|
+
closed += 1;
|
|
608
|
+
if (index > 0) {
|
|
609
|
+
deltas.push({
|
|
610
|
+
cluster: clusters[entryIndex] ?? '',
|
|
611
|
+
value: arm.result.score - base.result.score,
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
const grouped = new Map();
|
|
617
|
+
for (const delta of deltas) {
|
|
618
|
+
const bucket = grouped.get(delta.cluster);
|
|
619
|
+
if (bucket)
|
|
620
|
+
bucket.push(delta.value);
|
|
621
|
+
else
|
|
622
|
+
grouped.set(delta.cluster, [delta.value]);
|
|
623
|
+
}
|
|
624
|
+
const ci = index === 0 || !deltas.length ? null : bootstrapCi([...grouped.values()]);
|
|
625
|
+
state.placements.push({
|
|
626
|
+
index,
|
|
627
|
+
incumbent: index === 0,
|
|
628
|
+
closed,
|
|
629
|
+
delta: index === 0
|
|
630
|
+
? closed > 0
|
|
631
|
+
? 0
|
|
632
|
+
: null
|
|
633
|
+
: deltas.length
|
|
634
|
+
? deltas.reduce((total, delta) => total + delta.value, 0) / deltas.length
|
|
635
|
+
: null,
|
|
636
|
+
ciLow: ci?.low ?? null,
|
|
637
|
+
ciHigh: ci?.high ?? null,
|
|
638
|
+
coverage: coverages.length
|
|
639
|
+
? coverages.reduce((total, value) => total + value, 0) / coverages.length
|
|
640
|
+
: null,
|
|
641
|
+
abstainReasons: ownReasons,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
// The freshness sensor over what passed the pre-checks, inside the same
|
|
645
|
+
// wall clock. Its default arms are each frame's own incumbent and first
|
|
646
|
+
// non-incumbent placement - deterministic, and in-box by construction.
|
|
647
|
+
if (eligible.length) {
|
|
648
|
+
state.freshness = freshnessCheck(store, eligible, {
|
|
649
|
+
config,
|
|
650
|
+
gain,
|
|
651
|
+
costWeight,
|
|
652
|
+
deadline,
|
|
653
|
+
signal,
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
if (Date.now() > deadline)
|
|
657
|
+
state.deadlineHit = true;
|
|
658
|
+
if (state.invalidated > 0 && invalidatedAt > 0)
|
|
659
|
+
state.invalidatedAt = invalidatedAt;
|
|
660
|
+
state.evalMs = Date.now() - startedAt;
|
|
661
|
+
return state;
|
|
662
|
+
}
|
|
663
|
+
catch (cause) {
|
|
664
|
+
// `ask` never throws and neither does the probe: an internal failure is
|
|
665
|
+
// reported, and the night goes on (the corrupted-payload test).
|
|
666
|
+
state.error = cause.message;
|
|
667
|
+
state.evalMs = Date.now() - startedAt;
|
|
668
|
+
return state;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
//# sourceMappingURL=probe.js.map
|