@vellumai/assistant 0.11.9 → 0.11.10-dev.202609091114.7b6342c
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/ARCHITECTURE.md +2 -2
- package/Dockerfile +6 -12
- package/docs/architecture/memory.md +17 -9
- package/docs/guardian-request-flow.md +7 -4
- package/docs/runbook-trusted-contacts.md +13 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +3 -1
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +3 -1
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
- package/node_modules/@vellumai/gateway-client/src/gateway-ipc-contracts.ts +72 -0
- package/node_modules/@vellumai/service-contracts/package.json +3 -1
- package/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
- package/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
- package/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
- package/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
- package/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
- package/openapi.yaml +729 -63
- package/package.json +1 -1
- package/src/__tests__/agent-loop-mutable-latest-user-message.test.ts +19 -21
- package/src/__tests__/assistant-event-hub-machine-name.test.ts +40 -0
- package/src/__tests__/assistant-event-hub.test.ts +45 -0
- package/src/__tests__/cli-memory-v2-reembed-skills.test.ts +0 -1
- package/src/__tests__/compactor-assistant-tail-preview.test.ts +111 -0
- package/src/__tests__/compactor-tail-resolution.test.ts +116 -0
- package/src/__tests__/computer-use-native-history.test.ts +30 -0
- package/src/__tests__/computer-use-window-schema.test.ts +24 -0
- package/src/__tests__/config-get-vision-flag.test.ts +36 -0
- package/src/__tests__/config-loader-validation-reset-notice.test.ts +47 -15
- package/src/__tests__/context-search-conversations-source.test.ts +27 -5
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +189 -195
- package/src/__tests__/conversation-agent-loop.test.ts +690 -50
- package/src/__tests__/conversation-fork-crud.test.ts +132 -45
- package/src/__tests__/conversation-fork-retrospective.test.ts +9 -7
- package/src/__tests__/conversation-lifecycle.test.ts +684 -10
- package/src/__tests__/conversation-pairing.test.ts +10 -9
- package/src/__tests__/conversation-runtime-assembly.test.ts +288 -1
- package/src/__tests__/conversation-surfaces-history-restored-completion.test.ts +21 -4
- package/src/__tests__/conversation-surfaces-point-at-budget.test.ts +150 -0
- package/src/__tests__/conversation-surfaces-point-at-capability.test.ts +161 -0
- package/src/__tests__/copy-composer-tc-templates.test.ts +2 -2
- package/src/__tests__/credential-security-invariants.test.ts +1 -0
- package/src/__tests__/delivered-post-record.test.ts +107 -0
- package/src/__tests__/guardian-action-service-scope.test.ts +53 -0
- package/src/__tests__/guardian-question-mode.test.ts +88 -138
- package/src/__tests__/headless-browser-mode.test.ts +63 -13
- package/src/__tests__/heartbeat-disk-pressure.test.ts +2 -0
- package/src/__tests__/heartbeat-service.test.ts +118 -27
- package/src/__tests__/host-cu-proxy.test.ts +159 -1
- package/src/__tests__/host-proxy-interface.test.ts +15 -0
- package/src/__tests__/host-proxy-preactivation.test.ts +61 -0
- package/src/__tests__/injector-chain.test.ts +3 -3
- package/src/__tests__/injector-registry-order-guard.test.ts +1 -1
- package/src/__tests__/injector-v3-suppression.test.ts +587 -45
- package/src/__tests__/llm-schema.test.ts +70 -2
- package/src/__tests__/logger.test.ts +33 -32
- package/src/__tests__/mcp-config-secret-boundary.test.ts +2 -0
- package/src/__tests__/memory-config-file-parity.test.ts +18 -0
- package/src/__tests__/memory-retrieval-hook.test.ts +53 -3
- package/src/__tests__/messages-read-boundary-guard.test.ts +0 -1
- package/src/__tests__/messaging-send-tool.test.ts +251 -128
- package/src/__tests__/messaging-shared.test.ts +19 -0
- package/src/__tests__/notification-decision-fallback.test.ts +98 -76
- package/src/__tests__/notification-decision-strategy.test.ts +10 -38
- package/src/__tests__/notification-events-source-context-probe.test.ts +211 -0
- package/src/__tests__/openai-responses-prompt-cache.test.ts +7 -2
- package/src/__tests__/openai-responses-provider.test.ts +42 -0
- package/src/__tests__/outlook-messaging-provider.test.ts +9 -0
- package/src/__tests__/platform-callback-registration.test.ts +162 -3
- package/src/__tests__/plugin-api-webhook-url.test.ts +66 -4
- package/src/__tests__/plugin-import-boundary-guard.test.ts +1 -0
- package/src/__tests__/pricing.test.ts +29 -0
- package/src/__tests__/prompt-cache-cross-turn-stability.test.ts +63 -3
- package/src/__tests__/scheduler-result-notification.test.ts +209 -0
- package/src/__tests__/strip-memory-injections.test.ts +75 -27
- package/src/__tests__/tool-approval-seed-content-blocks.test.ts +4 -13
- package/src/acp/auto-install.test.ts +35 -1
- package/src/acp/resolve-agent.test.ts +3 -3
- package/src/agent/loop.ts +116 -45
- package/src/api/constants/personality-sliders.test.ts +21 -0
- package/src/api/constants/personality-sliders.ts +64 -0
- package/src/api/events/contact-record-request.ts +16 -4
- package/src/api/events/contact-request.ts +10 -1
- package/src/api/index.ts +12 -0
- package/src/api/responses/memory-v3-selection-log.ts +64 -13
- package/src/api/surfaces.ts +6 -5
- package/src/background-wake/next-wake.test.ts +13 -0
- package/src/background-wake/next-wake.ts +4 -2
- package/src/calls/__tests__/voice-session-bridge.test.ts +166 -0
- package/src/calls/__tests__/voice-turn-sight-hold.test.ts +301 -0
- package/src/calls/voice-session-bridge.ts +162 -1
- package/src/calls/voice-triage-escalate.ts +1 -1
- package/src/channels/types.ts +14 -0
- package/src/cli/__tests__/catalog-search-help.test.ts +1 -0
- package/src/cli/__tests__/contacts-address-prompt-cli.test.ts +701 -0
- package/src/cli/__tests__/contacts-record-prompt-cli.test.ts +276 -15
- package/src/cli/__tests__/roadmap-cli.test.ts +313 -0
- package/src/cli/__tests__/run-assistant-command.ts +59 -20
- package/src/cli/commands/__tests__/conversations-slack.test.ts +12 -0
- package/src/cli/commands/__tests__/plugins-search.test.ts +81 -0
- package/src/cli/commands/config.help.ts +3 -1
- package/src/cli/commands/contacts.help.ts +179 -12
- package/src/cli/commands/contacts.ts +442 -47
- package/src/cli/commands/memory/worker.ts +1 -1
- package/src/cli/commands/platform/__tests__/credits-format.test.ts +152 -0
- package/src/cli/commands/platform/__tests__/credits.test.ts +20 -0
- package/src/cli/commands/platform/credits-format.ts +108 -0
- package/src/cli/commands/platform/index.help.ts +33 -11
- package/src/cli/commands/platform/index.ts +7 -18
- package/src/cli/commands/plugins.help.ts +4 -1
- package/src/cli/commands/plugins.ts +2 -1
- package/src/cli/commands/roadmap.help.ts +171 -0
- package/src/cli/commands/roadmap.ts +358 -0
- package/src/cli/index.help.ts +2 -0
- package/src/cli/lib/__tests__/cli-output.test.ts +5 -0
- package/src/cli/lib/cli-output.ts +6 -6
- package/src/cli/program.ts +2 -0
- package/src/config/__tests__/webhook-routing.test.ts +42 -0
- package/src/config/acp-defaults.test.ts +3 -3
- package/src/config/acp-defaults.ts +5 -5
- package/src/config/bundled-skills/acp/SKILL.md +8 -11
- package/src/config/bundled-skills/computer-use/SKILL.md +21 -0
- package/src/config/bundled-skills/computer-use/TOOLS.json +6 -0
- package/src/config/bundled-skills/contacts/SKILL.md +61 -11
- package/src/config/bundled-skills/messaging/SKILL.md +2 -0
- package/src/config/bundled-skills/messaging/TOOLS.json +4 -4
- package/src/config/bundled-skills/messaging/tools/messaging-send.ts +160 -36
- package/src/config/bundled-skills/messaging/tools/shared.ts +6 -0
- package/src/config/bundled-skills/schedule/SKILL.md +10 -2
- package/src/config/bundled-skills/screen-annotation/SKILL.md +80 -0
- package/src/config/bundled-skills/screen-annotation/TOOLS.json +73 -0
- package/src/config/bundled-skills/screen-annotation/tools/screen-annotation.test.ts +74 -0
- package/src/config/bundled-skills/screen-annotation/tools/screen-clear-marks.ts +33 -0
- package/src/config/bundled-skills/screen-annotation/tools/screen-point-at.ts +25 -0
- package/src/config/env-registry.ts +2 -0
- package/src/config/feature-flag-registry.json +39 -7
- package/src/config/input-modalities.test.ts +71 -0
- package/src/config/input-modalities.ts +95 -0
- package/src/config/loader.ts +2 -0
- package/src/config/schemas/__tests__/memory-v3.test.ts +58 -15
- package/src/config/schemas/heartbeat.ts +3 -3
- package/src/config/schemas/llm.ts +47 -10
- package/src/config/schemas/memory-storage.test.ts +39 -0
- package/src/config/schemas/memory-storage.ts +21 -0
- package/src/config/schemas/memory-v3.ts +73 -46
- package/src/config/schemas/services.ts +18 -0
- package/src/config/webhook-routing.ts +12 -2
- package/src/context/compactor.ts +12 -13
- package/src/context/strip-injections.ts +29 -25
- package/src/context/token-estimator.ts +2 -2
- package/src/daemon/__tests__/embedding-reconcile.test.ts +77 -0
- package/src/daemon/__tests__/lifecycle-embedding-reconcile.test.ts +3 -0
- package/src/daemon/__tests__/turn-actor.test.ts +68 -0
- package/src/daemon/conversation-agent-loop-handlers.ts +152 -22
- package/src/daemon/conversation-agent-loop.ts +19 -3
- package/src/daemon/conversation-messaging.ts +3 -2
- package/src/daemon/conversation-runtime-assembly.ts +191 -69
- package/src/daemon/conversation-surfaces.ts +32 -62
- package/src/daemon/conversation.ts +153 -46
- package/src/daemon/embedding-reconcile.ts +64 -1
- package/src/daemon/handlers/config-embeddings.ts +31 -0
- package/src/daemon/host-cu-proxy.ts +66 -50
- package/src/daemon/host-cu-target.ts +139 -0
- package/src/daemon/host-proxy-preactivation.ts +29 -1
- package/src/daemon/mcp-reload-service.ts +6 -0
- package/src/daemon/providers-setup.ts +5 -26
- package/src/daemon/trust-context.ts +1 -1
- package/src/daemon/turn-actor.ts +46 -0
- package/src/heartbeat/heartbeat-service.ts +72 -13
- package/src/inbound/platform-callback-registration.ts +77 -11
- package/src/inbound/pod-webhook-claim.ts +35 -0
- package/src/inbound/velay-webhooks-gate.ts +20 -0
- package/src/ipc/gateway-client.ts +91 -0
- package/src/live-voice/__tests__/live-voice-photo.test.ts +174 -0
- package/src/live-voice/__tests__/live-voice-session-guardian.test.ts +127 -0
- package/src/live-voice/__tests__/live-voice-session-telemetry.test.ts +42 -2
- package/src/live-voice/__tests__/live-voice-sight-frame.test.ts +81 -0
- package/src/live-voice/__tests__/protocol.test.ts +67 -0
- package/src/live-voice/live-voice-connection.ts +14 -1
- package/src/live-voice/live-voice-photo.ts +109 -4
- package/src/live-voice/live-voice-session-manager.ts +10 -1
- package/src/live-voice/live-voice-session.ts +196 -31
- package/src/live-voice/protocol.ts +134 -1
- package/src/mcp/__tests__/reload-signal-emission.test.ts +54 -0
- package/src/mcp/__tests__/reload-signal.test.ts +57 -0
- package/src/mcp/__tests__/startup.test.ts +150 -0
- package/src/mcp/reload-signal.ts +50 -0
- package/src/mcp/startup.ts +101 -0
- package/src/messaging/providers/outlook/adapter.ts +2 -13
- package/src/messaging/providers/outlook/client.ts +13 -1
- package/src/messaging/providers/outlook/types.ts +3 -0
- package/src/messaging/providers/telegram-bot/adapter.ts +9 -2
- package/src/messaging/providers/telegram-bot/client.ts +8 -2
- package/src/messaging/providers/whatsapp/adapter.ts +9 -2
- package/src/messaging/providers/whatsapp/client.ts +8 -2
- package/src/notifications/AGENTS.md +5 -0
- package/src/notifications/README.md +21 -7
- package/src/notifications/__tests__/assistant-reply-producer.test.ts +3 -10
- package/src/notifications/__tests__/background-failure-signal.test.ts +96 -0
- package/src/notifications/__tests__/broadcaster.test.ts +171 -7
- package/src/notifications/__tests__/decision-engine.test.ts +79 -6
- package/src/notifications/__tests__/edit-notification.test.ts +59 -0
- package/src/notifications/__tests__/resolve-visible-in-source.test.ts +96 -0
- package/src/notifications/__tests__/schedule-result-producer.test.ts +397 -0
- package/src/notifications/access-request-copy.ts +5 -5
- package/src/notifications/approval-card-data.ts +29 -13
- package/src/notifications/assistant-reply-producer.ts +0 -4
- package/src/notifications/background-failure-signal.ts +13 -1
- package/src/notifications/broadcaster.ts +65 -2
- package/src/notifications/conversation-pairing.ts +263 -155
- package/src/notifications/copy-composer.ts +38 -22
- package/src/notifications/decision-engine.ts +89 -61
- package/src/notifications/delivered-post-record.ts +81 -0
- package/src/notifications/deliveries-store.ts +8 -1
- package/src/notifications/edit-notification.ts +16 -0
- package/src/notifications/events-store.ts +68 -2
- package/src/notifications/guardian-question-mode.ts +24 -232
- package/src/notifications/home-feed-side-effect.ts +1 -0
- package/src/notifications/notification-utils.ts +13 -5
- package/src/notifications/resolve-visible-in-source.ts +56 -0
- package/src/notifications/schedule-result-producer.ts +275 -0
- package/src/notifications/signal.ts +5 -0
- package/src/oauth/__tests__/seed-providers-managed.test.ts +82 -0
- package/src/oauth/seed-providers.ts +201 -3
- package/src/onboarding/onboarding-events-store.ts +14 -8
- package/src/persistence/conversation-crud.ts +68 -19
- package/src/persistence/embeddings/embedding-backend.test.ts +162 -0
- package/src/persistence/embeddings/embedding-backend.ts +148 -11
- package/src/persistence/embeddings/embedding-gemini.test.ts +328 -9
- package/src/persistence/embeddings/embedding-gemini.ts +211 -27
- package/src/persistence/embeddings/embedding-openai.test.ts +113 -0
- package/src/persistence/embeddings/embedding-openai.ts +55 -4
- package/src/persistence/embeddings/embedding-types.test.ts +24 -0
- package/src/persistence/embeddings/embedding-types.ts +25 -1
- package/src/persistence/job-utils.ts +6 -2
- package/src/persistence/message-metadata.ts +20 -0
- package/src/persistence/migrations/283-memory-v3-selections-message-id-and-sections.ts +2 -1
- package/src/persistence/migrations/376-notification-deliveries-canonical-message-id.ts +37 -0
- package/src/persistence/schema/memory-injection.ts +31 -9
- package/src/persistence/schema/notifications.ts +8 -0
- package/src/persistence/steps.ts +2 -0
- package/src/plugin-api/index.ts +2 -1
- package/src/plugin-api/vision-support.test.ts +81 -0
- package/src/plugin-api/vision-support.ts +57 -10
- package/src/plugin-api/webhook-url.ts +18 -4
- package/src/plugins/AGENTS.md +1 -1
- package/src/plugins/defaults/channel/injectors.ts +3 -1
- package/src/plugins/defaults/injector-order.ts +2 -2
- package/src/plugins/defaults/memory/AGENTS.md +263 -30
- package/src/plugins/defaults/memory/__tests__/conversation-memory-orphan-sweep.test.ts +4 -0
- package/src/plugins/defaults/memory/__tests__/conversation-memory-purge.test.ts +6 -0
- package/src/plugins/defaults/memory/__tests__/db-memory-attach.test.ts +9 -3
- package/src/plugins/defaults/memory/__tests__/memory-log-stores-degraded.test.ts +3 -7
- package/src/plugins/defaults/memory/__tests__/relocated-memory-test-rows.ts +18 -0
- package/src/plugins/defaults/memory/context-search/sources/conversations.ts +16 -2
- package/src/plugins/defaults/memory/conversation-memory-purge.ts +2 -0
- package/src/plugins/defaults/memory/fork-conversation-memory.ts +13 -13
- package/src/plugins/defaults/memory/graph/__tests__/conversation-graph-memory-v2-routing.test.ts +19 -12
- package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +17 -15
- package/src/plugins/defaults/memory/graph-topology/build-memory-graph.ts +1 -1
- package/src/plugins/defaults/memory/hooks/__tests__/post-compact.test.ts +121 -0
- package/src/plugins/defaults/memory/hooks/init.ts +10 -0
- package/src/plugins/defaults/memory/hooks/injection-metadata.ts +100 -0
- package/src/plugins/defaults/memory/hooks/post-compact.ts +19 -7
- package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +11 -83
- package/src/plugins/defaults/memory/injectors.ts +4 -4
- package/src/plugins/defaults/memory/job-handlers.ts +4 -1
- package/src/plugins/defaults/memory/jobs/__tests__/embed-concept-page.test.ts +1 -0
- package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +11 -3
- package/src/plugins/defaults/memory/memory-db.ts +4 -0
- package/src/plugins/defaults/memory/memory-marker.ts +28 -17
- package/src/plugins/defaults/memory/src/__tests__/memory-v2-simulate-route.test.ts +0 -1
- package/src/plugins/defaults/memory/src/__tests__/memory-worker-routes.test.ts +20 -0
- package/src/plugins/defaults/memory/src/memory-item-routes.test.ts +0 -1
- package/src/plugins/defaults/memory/src/memory-worker-routes.ts +3 -1
- package/src/plugins/defaults/memory/substrate/__tests__/cli-command-store.test.ts +1 -1
- package/src/plugins/defaults/memory/substrate/__tests__/consolidation-job.test.ts +66 -0
- package/src/plugins/defaults/memory/substrate/__tests__/injected-block-slugs.test.ts +345 -0
- package/src/plugins/defaults/memory/substrate/__tests__/page-index.test.ts +0 -1
- package/src/plugins/defaults/memory/substrate/__tests__/prompts-consolidation.test.ts +170 -1
- package/src/plugins/defaults/memory/substrate/__tests__/reembed-job.test.ts +1 -0
- package/src/plugins/defaults/memory/substrate/capability-slugs.ts +53 -0
- package/src/plugins/defaults/memory/substrate/cli-command-store.ts +4 -18
- package/src/plugins/defaults/memory/substrate/consolidation-job.ts +40 -1
- package/src/plugins/defaults/memory/substrate/ingest.ts +11 -9
- package/src/plugins/defaults/memory/substrate/injected-block-slugs.ts +426 -42
- package/src/plugins/defaults/memory/substrate/page-index.ts +5 -4
- package/src/plugins/defaults/memory/substrate/prompts/consolidation.ts +127 -14
- package/src/plugins/defaults/memory/substrate/skill-store.ts +1 -18
- package/src/plugins/defaults/memory/v2/__tests__/backfill-jobs.test.ts +1 -0
- package/src/plugins/defaults/memory/v2/__tests__/injection.test.ts +2 -8
- package/src/plugins/defaults/memory/v2/__tests__/router.test.ts +0 -1
- package/src/plugins/defaults/memory/v2/injection.ts +4 -4
- package/src/plugins/defaults/memory/v3/__tests__/capabilities.test.ts +16 -0
- package/src/plugins/defaults/memory/v3/__tests__/carry-integration.test.ts +1004 -319
- package/src/plugins/defaults/memory/v3/__tests__/dense.test.ts +227 -4
- package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +836 -263
- package/src/plugins/defaults/memory/v3/__tests__/live-integration.test.ts +65 -38
- package/src/plugins/defaults/memory/v3/__tests__/maintain-job.test.ts +354 -3
- package/src/plugins/defaults/memory/v3/__tests__/orchestrate.test.ts +688 -104
- package/src/plugins/defaults/memory/v3/__tests__/overlong-sections.test.ts +109 -0
- package/src/plugins/defaults/memory/v3/__tests__/page-content.test.ts +144 -0
- package/src/plugins/defaults/memory/v3/__tests__/plugin-schema.test.ts +534 -0
- package/src/plugins/defaults/memory/v3/__tests__/pool-log-store.test.ts +449 -0
- package/src/plugins/defaults/memory/v3/__tests__/pool-select.test.ts +265 -27
- package/src/plugins/defaults/memory/v3/__tests__/render-injection.test.ts +34 -117
- package/src/plugins/defaults/memory/v3/__tests__/section-dense-store.test.ts +491 -4
- package/src/plugins/defaults/memory/v3/__tests__/section-needle.test.ts +124 -1
- package/src/plugins/defaults/memory/v3/__tests__/sections.test.ts +264 -4
- package/src/plugins/defaults/memory/v3/__tests__/selection-log-store.test.ts +560 -22
- package/src/plugins/defaults/memory/v3/__tests__/shadow-integration.test.ts +40 -33
- package/src/plugins/defaults/memory/v3/__tests__/shadow-plugin.test.ts +718 -63
- package/src/plugins/defaults/memory/v3/__tests__/types.test.ts +83 -2
- package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
- package/src/plugins/defaults/memory/v3/capabilities.ts +90 -14
- package/src/plugins/defaults/memory/v3/card.test.ts +15 -16
- package/src/plugins/defaults/memory/v3/card.ts +16 -15
- package/src/plugins/defaults/memory/v3/dense.ts +10 -0
- package/src/plugins/defaults/memory/v3/ever-injected-store.test.ts +643 -140
- package/src/plugins/defaults/memory/v3/ever-injected-store.ts +462 -212
- package/src/plugins/defaults/memory/v3/hot-set.test.ts +2 -2
- package/src/plugins/defaults/memory/v3/injector.ts +366 -278
- package/src/plugins/defaults/memory/v3/learned-edges.test.ts +2 -2
- package/src/plugins/defaults/memory/v3/maintain-job.ts +299 -73
- package/src/plugins/defaults/memory/v3/orchestrate.ts +327 -214
- package/src/plugins/defaults/memory/v3/overlong-sections.ts +83 -0
- package/src/plugins/defaults/memory/v3/page-content.ts +72 -92
- package/src/plugins/defaults/memory/v3/plugin-schema.ts +346 -0
- package/src/plugins/defaults/memory/v3/pool-log-store.ts +291 -0
- package/src/plugins/defaults/memory/v3/pool-select.test.ts +2 -2
- package/src/plugins/defaults/memory/v3/pool-select.ts +160 -60
- package/src/plugins/defaults/memory/v3/prune.test.ts +1042 -329
- package/src/plugins/defaults/memory/v3/prune.ts +433 -270
- package/src/plugins/defaults/memory/v3/rare-term-lane.test.ts +269 -0
- package/src/plugins/defaults/memory/v3/rare-term-lane.ts +141 -0
- package/src/plugins/defaults/memory/v3/render-injection.ts +43 -82
- package/src/plugins/defaults/memory/v3/section-dense-store.ts +316 -28
- package/src/plugins/defaults/memory/v3/section-needle.ts +145 -11
- package/src/plugins/defaults/memory/v3/sections.ts +103 -16
- package/src/plugins/defaults/memory/v3/selection-log-store.ts +243 -78
- package/src/plugins/defaults/memory/v3/shadow-plugin.ts +189 -68
- package/src/plugins/defaults/memory/v3/tuning-profile.ts +6 -0
- package/src/plugins/defaults/memory/v3/types.ts +169 -23
- package/src/plugins/defaults/memory/v3-eval/__tests__/eval-packets.test.ts +21 -4
- package/src/plugins/defaults/memory/v3-eval/eval-packets.ts +77 -26
- package/src/plugins/types.ts +14 -0
- package/src/providers/__tests__/connection-model-compat.test.ts +1 -0
- package/src/providers/__tests__/provider-secret-catalog.test.ts +4 -0
- package/src/providers/__tests__/xml-tool-call-salvage.test.ts +172 -0
- package/src/providers/inline-audio-support.test.ts +34 -0
- package/src/providers/inline-audio-support.ts +27 -0
- package/src/providers/model-catalog.ts +102 -0
- package/src/providers/openai/__tests__/chat-completions-extra-body.test.ts +51 -0
- package/src/providers/openai/__tests__/chat-completions-provider-xml-salvage.test.ts +291 -0
- package/src/providers/openai/chat-completions-provider.ts +114 -14
- package/src/providers/openai/codex-models.ts +1 -0
- package/src/providers/openai/responses-provider.ts +65 -15
- package/src/providers/opencode/client.test.ts +24 -0
- package/src/providers/opencode/client.ts +6 -1
- package/src/providers/provider-secret-catalog.ts +11 -1
- package/src/providers/retry.ts +6 -0
- package/src/providers/vellum/client.ts +14 -1
- package/src/providers/vellum/personality-directions.test.ts +163 -0
- package/src/providers/vellum/personality-directions.ts +120 -0
- package/src/providers/xml-tool-call-salvage.ts +212 -0
- package/src/runtime/AGENTS.md +7 -2
- package/src/runtime/__tests__/background-job-runner.test.ts +115 -0
- package/src/runtime/__tests__/guardian-form-registry.test.ts +0 -32
- package/src/runtime/__tests__/host-observe.test.ts +44 -0
- package/src/runtime/assistant-event-hub.ts +14 -9
- package/src/runtime/auth/__tests__/guard-tests.test.ts +1 -4
- package/src/runtime/auth/__tests__/route-policy.test.ts +65 -0
- package/src/runtime/auth/same-actor.ts +4 -3
- package/src/runtime/background-job-runner.ts +10 -0
- package/src/runtime/channel-reply-delivery.ts +1 -162
- package/src/runtime/guardian-action-service.ts +20 -1
- package/src/runtime/host-observe.ts +56 -6
- package/src/runtime/http-server.ts +35 -0
- package/src/runtime/outbound-post-reconciliation.ts +183 -0
- package/src/runtime/routes/__tests__/contact-address-prompt-route.test.ts +231 -0
- package/src/runtime/routes/__tests__/contact-record-prompt-route.test.ts +59 -3
- package/src/runtime/routes/__tests__/guardian-form-routes.test.ts +85 -0
- package/src/runtime/routes/__tests__/heartbeat-routes.test.ts +24 -0
- package/src/runtime/routes/__tests__/platform-credits-routes.test.ts +239 -0
- package/src/runtime/routes/__tests__/roadmap-routes.test.ts +469 -0
- package/src/runtime/routes/__tests__/watch-routes.test.ts +70 -1
- package/src/runtime/routes/__tests__/webhook-routes.test.ts +83 -0
- package/src/runtime/routes/contact-prompt-routes.ts +177 -28
- package/src/runtime/routes/conversation-query-routes.ts +53 -11
- package/src/runtime/routes/events-routes.ts +13 -3
- package/src/runtime/routes/guardian-action-routes.ts +7 -0
- package/src/runtime/routes/guardian-form-routes.ts +6 -4
- package/src/runtime/routes/heartbeat-routes.ts +41 -53
- package/src/runtime/routes/index.ts +2 -2
- package/src/runtime/routes/integrations/a2a.ts +12 -3
- package/src/runtime/routes/integrations/vercel.ts +13 -3
- package/src/runtime/routes/platform-routes.ts +175 -23
- package/src/runtime/routes/roadmap-routes.ts +744 -0
- package/src/runtime/routes/watch-routes.ts +50 -0
- package/src/runtime/routes/webhook-routes.ts +24 -2
- package/src/runtime/web-presence.ts +13 -9
- package/src/schedule/__tests__/schedule-timezone.test.ts +21 -3
- package/src/schedule/__tests__/worker-mcp-tools.test.ts +88 -0
- package/src/schedule/schedule-timezone.ts +25 -0
- package/src/schedule/scheduler.ts +19 -0
- package/src/schedule/worker.ts +119 -2
- package/src/telemetry/__tests__/live-voice-funnel.test.ts +32 -0
- package/src/telemetry/live-voice-funnel.ts +33 -0
- package/src/tools/acp/list-agents.test.ts +1 -1
- package/src/tools/browser/__tests__/browser-status.test.ts +3 -0
- package/src/tools/browser/browser-execution.ts +117 -53
- package/src/tools/browser/browser-status-constants.ts +6 -6
- package/src/tools/capability-offer.test.ts +87 -0
- package/src/tools/capability-offer.ts +93 -0
- package/src/tools/computer-use/definitions.ts +6 -0
- package/src/tools/computer-use/skill-proxy-bridge.ts +10 -0
- package/src/tools/terminal/safe-env.ts +2 -0
- package/src/watch/__tests__/watch-retro.test.ts +11 -10
- package/src/watch/__tests__/watch-session-manager.test.ts +75 -1
- package/src/watch/watch-retro.ts +10 -9
- package/src/watch/watch-session-manager.ts +17 -0
- package/src/runtime/routes/__tests__/sight-frame-routes.test.ts +0 -487
- package/src/runtime/routes/sight-frame-routes.ts +0 -136
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
afterEach,
|
|
3
|
+
beforeEach,
|
|
4
|
+
describe,
|
|
5
|
+
expect,
|
|
6
|
+
mock,
|
|
7
|
+
setSystemTime,
|
|
8
|
+
test,
|
|
9
|
+
} from "bun:test";
|
|
2
10
|
|
|
3
11
|
import type { AssistantConfig } from "../../../../../config/types.js";
|
|
4
12
|
import type { Section } from "../types.js";
|
|
@@ -25,6 +33,8 @@ const embedState = {
|
|
|
25
33
|
// the section cache treats it as a miss.
|
|
26
34
|
geminiTaskType: undefined as string | undefined,
|
|
27
35
|
geminiDimensions: undefined as number | undefined,
|
|
36
|
+
customBaseUrl: undefined as string | undefined,
|
|
37
|
+
customDimensions: undefined as number | undefined,
|
|
28
38
|
};
|
|
29
39
|
mock.module(
|
|
30
40
|
"../../../../../persistence/embeddings/embedding-backend.js",
|
|
@@ -56,6 +66,42 @@ mock.module(
|
|
|
56
66
|
}
|
|
57
67
|
return extras;
|
|
58
68
|
},
|
|
69
|
+
customCacheExtras: () => {
|
|
70
|
+
const extras: string[] = [];
|
|
71
|
+
if (embedState.customBaseUrl) {
|
|
72
|
+
extras.push(`url=${embedState.customBaseUrl}`);
|
|
73
|
+
}
|
|
74
|
+
if (embedState.customDimensions != null) {
|
|
75
|
+
extras.push(`dim=${embedState.customDimensions}`);
|
|
76
|
+
}
|
|
77
|
+
return extras;
|
|
78
|
+
},
|
|
79
|
+
durableEmbeddingCacheExtras: (
|
|
80
|
+
_config: unknown,
|
|
81
|
+
provider: string | null,
|
|
82
|
+
) => {
|
|
83
|
+
if (provider === "gemini") {
|
|
84
|
+
const extras: string[] = [];
|
|
85
|
+
if (embedState.geminiTaskType) {
|
|
86
|
+
extras.push(`task=${embedState.geminiTaskType}`);
|
|
87
|
+
}
|
|
88
|
+
if (embedState.geminiDimensions != null) {
|
|
89
|
+
extras.push(`dim=${embedState.geminiDimensions}`);
|
|
90
|
+
}
|
|
91
|
+
return extras;
|
|
92
|
+
}
|
|
93
|
+
if (provider === "custom") {
|
|
94
|
+
const extras: string[] = [];
|
|
95
|
+
if (embedState.customBaseUrl) {
|
|
96
|
+
extras.push(`url=${embedState.customBaseUrl}`);
|
|
97
|
+
}
|
|
98
|
+
if (embedState.customDimensions != null) {
|
|
99
|
+
extras.push(`dim=${embedState.customDimensions}`);
|
|
100
|
+
}
|
|
101
|
+
return extras;
|
|
102
|
+
}
|
|
103
|
+
return [];
|
|
104
|
+
},
|
|
59
105
|
}),
|
|
60
106
|
);
|
|
61
107
|
|
|
@@ -159,6 +205,7 @@ const state = {
|
|
|
159
205
|
// Programmed `scroll` pages, consumed in order; each `scroll` call shifts one.
|
|
160
206
|
scrollPages: [] as ScrollPage[],
|
|
161
207
|
scrollCalls: [] as Array<{ limit: number; offset: unknown }>,
|
|
208
|
+
scrollThrows: null as Error | null,
|
|
162
209
|
};
|
|
163
210
|
|
|
164
211
|
class MockQdrantClient {
|
|
@@ -208,6 +255,9 @@ class MockQdrantClient {
|
|
|
208
255
|
params: { limit: number; offset?: unknown },
|
|
209
256
|
): Promise<ScrollPage> {
|
|
210
257
|
state.scrollCalls.push({ limit: params.limit, offset: params.offset });
|
|
258
|
+
if (state.scrollThrows) {
|
|
259
|
+
throw state.scrollThrows;
|
|
260
|
+
}
|
|
211
261
|
return state.scrollPages.shift() ?? { points: [], next_page_offset: null };
|
|
212
262
|
}
|
|
213
263
|
}
|
|
@@ -219,22 +269,55 @@ mock.module("@qdrant/js-client-rest", () => ({
|
|
|
219
269
|
// Records the checkpoint clears `ensureSectionCollection` performs when it
|
|
220
270
|
// (re)creates an empty collection, so tests can assert the embed high-water is
|
|
221
271
|
// reset (which sends the next maintain pass down its full-corpus re-embed path).
|
|
222
|
-
|
|
272
|
+
// `ops` is the write log in order (`set:<key>` / `delete:<key>`), so the
|
|
273
|
+
// chunker-version tests can assert which write lands first.
|
|
274
|
+
const checkpointState = {
|
|
275
|
+
deletes: [] as string[],
|
|
276
|
+
ops: [] as string[],
|
|
277
|
+
values: new Map<string, string>(),
|
|
278
|
+
// Keys whose read or write throws, so the chunker-version tests can fail a
|
|
279
|
+
// transition part-way through and assert what the hold does with it.
|
|
280
|
+
throwOnGet: null as string | null,
|
|
281
|
+
throwOnSet: null as string | null,
|
|
282
|
+
};
|
|
223
283
|
mock.module("../../../../../persistence/checkpoints.js", () => ({
|
|
224
|
-
getMemoryCheckpoint: () =>
|
|
225
|
-
|
|
284
|
+
getMemoryCheckpoint: (key: string) => {
|
|
285
|
+
if (checkpointState.throwOnGet === key) {
|
|
286
|
+
throw new Error(`checkpoint read failed: ${key}`);
|
|
287
|
+
}
|
|
288
|
+
return checkpointState.values.get(key) ?? null;
|
|
289
|
+
},
|
|
290
|
+
setMemoryCheckpoint: (key: string, value: string) => {
|
|
291
|
+
if (checkpointState.throwOnSet === key) {
|
|
292
|
+
throw new Error(`checkpoint write failed: ${key}`);
|
|
293
|
+
}
|
|
294
|
+
checkpointState.ops.push(`set:${key}`);
|
|
295
|
+
checkpointState.values.set(key, value);
|
|
296
|
+
},
|
|
226
297
|
deleteMemoryCheckpoint: (key: string) => {
|
|
227
298
|
checkpointState.deletes.push(key);
|
|
299
|
+
checkpointState.ops.push(`delete:${key}`);
|
|
300
|
+
checkpointState.values.delete(key);
|
|
228
301
|
},
|
|
229
302
|
}));
|
|
230
303
|
|
|
231
304
|
const {
|
|
232
305
|
ensureSectionCollection,
|
|
233
306
|
upsertSections,
|
|
307
|
+
warmSectionEmbeddings,
|
|
308
|
+
WARM_SECTIONS_PER_CALL,
|
|
234
309
|
deleteSectionsForArticle,
|
|
235
310
|
listSectionArticles,
|
|
236
311
|
SECTION_COLLECTION,
|
|
312
|
+
commitSectionEmbedHighWater,
|
|
313
|
+
ensureSectionChunkerVersion,
|
|
314
|
+
holdSectionDenseReadsUntilRebuilt,
|
|
315
|
+
sectionDenseReadsHeld,
|
|
316
|
+
settleSectionDenseReadHold,
|
|
237
317
|
MAINTAIN_EMBED_HIGH_WATER_KEY,
|
|
318
|
+
SECTION_CHUNKER_VERSION,
|
|
319
|
+
SECTION_CHUNKER_VERSION_KEY,
|
|
320
|
+
SECTION_REBUILD_PENDING_KEY,
|
|
238
321
|
_resetSectionDenseStoreForTests,
|
|
239
322
|
} = await import("../section-dense-store.js");
|
|
240
323
|
|
|
@@ -266,6 +349,7 @@ function resetState(): void {
|
|
|
266
349
|
state.deleteCollectionCalls.length = 0;
|
|
267
350
|
state.scrollPages.length = 0;
|
|
268
351
|
state.scrollCalls.length = 0;
|
|
352
|
+
state.scrollThrows = null;
|
|
269
353
|
embedState.calls.length = 0;
|
|
270
354
|
embedState.dim = 4;
|
|
271
355
|
embedState.statusProvider = "local";
|
|
@@ -274,9 +358,14 @@ function resetState(): void {
|
|
|
274
358
|
embedState.embedModel = "test-model";
|
|
275
359
|
embedState.geminiTaskType = undefined;
|
|
276
360
|
embedState.geminiDimensions = undefined;
|
|
361
|
+
embedState.customBaseUrl = undefined;
|
|
362
|
+
embedState.customDimensions = undefined;
|
|
277
363
|
cacheState.store.clear();
|
|
278
364
|
cacheState.reads.length = 0;
|
|
279
365
|
checkpointState.deletes.length = 0;
|
|
366
|
+
checkpointState.ops.length = 0;
|
|
367
|
+
checkpointState.throwOnGet = null;
|
|
368
|
+
checkpointState.throwOnSet = null;
|
|
280
369
|
_resetSectionDenseStoreForTests();
|
|
281
370
|
}
|
|
282
371
|
|
|
@@ -548,6 +637,58 @@ describe("memory v3 section-dense-store — embedding cache", () => {
|
|
|
548
637
|
);
|
|
549
638
|
});
|
|
550
639
|
|
|
640
|
+
test("warmSectionEmbeddings embeds every miss across pages in one backend call, and the per-page upserts then serve from cache", async () => {
|
|
641
|
+
state.collectionExists = true;
|
|
642
|
+
const alice = [
|
|
643
|
+
section("people/alice", 0, "alice lead text"),
|
|
644
|
+
section("people/alice", 1, "alice section one"),
|
|
645
|
+
];
|
|
646
|
+
const bob = [section("people/bob", 0, "bob lead text")];
|
|
647
|
+
|
|
648
|
+
await warmSectionEmbeddings(CONFIG, [...alice, ...bob]);
|
|
649
|
+
expect(embedState.calls).toEqual([
|
|
650
|
+
["alice lead text", "alice section one", "bob lead text"],
|
|
651
|
+
]);
|
|
652
|
+
expect(state.upsertCalls).toHaveLength(0);
|
|
653
|
+
|
|
654
|
+
await upsertSections(CONFIG, alice);
|
|
655
|
+
await upsertSections(CONFIG, bob);
|
|
656
|
+
// No further backend call: both pages rebuilt their points from the cache.
|
|
657
|
+
expect(embedState.calls).toHaveLength(1);
|
|
658
|
+
expect(state.upsertCalls).toHaveLength(2);
|
|
659
|
+
expect(
|
|
660
|
+
state.upsertCalls.flatMap((c) => c.points).map((p) => p.vector),
|
|
661
|
+
).toEqual(
|
|
662
|
+
[
|
|
663
|
+
embedState.calls[0]!.map((_t, i) =>
|
|
664
|
+
Array.from({ length: embedState.dim }, (_v, j) => (i + 1) * (j + 1)),
|
|
665
|
+
),
|
|
666
|
+
].flat(),
|
|
667
|
+
);
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
test("warmSectionEmbeddings bounds each backend call to WARM_SECTIONS_PER_CALL sections", async () => {
|
|
671
|
+
state.collectionExists = true;
|
|
672
|
+
const count = WARM_SECTIONS_PER_CALL * 2 + 1;
|
|
673
|
+
const sections = Array.from({ length: count }, (_v, i) =>
|
|
674
|
+
section(`page-${Math.floor(i / 10)}`, i % 10, `text ${i}`),
|
|
675
|
+
);
|
|
676
|
+
|
|
677
|
+
await warmSectionEmbeddings(CONFIG, sections);
|
|
678
|
+
|
|
679
|
+
expect(embedState.calls.map((c) => c.length)).toEqual([
|
|
680
|
+
WARM_SECTIONS_PER_CALL,
|
|
681
|
+
WARM_SECTIONS_PER_CALL,
|
|
682
|
+
1,
|
|
683
|
+
]);
|
|
684
|
+
expect(embedState.calls.flat()).toEqual(sections.map((s) => s.text));
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
test("warmSectionEmbeddings with no sections makes no backend call", async () => {
|
|
688
|
+
await warmSectionEmbeddings(CONFIG, []);
|
|
689
|
+
expect(embedState.calls).toHaveLength(0);
|
|
690
|
+
});
|
|
691
|
+
|
|
551
692
|
test("a changed section text re-embeds (content hash differs)", async () => {
|
|
552
693
|
state.collectionExists = true;
|
|
553
694
|
|
|
@@ -666,6 +807,48 @@ describe("memory v3 section-dense-store — embedding cache", () => {
|
|
|
666
807
|
expect(embedState.calls).toHaveLength(1);
|
|
667
808
|
expect(state.upsertCalls).toHaveLength(2);
|
|
668
809
|
});
|
|
810
|
+
|
|
811
|
+
test("a custom endpoint change re-embeds unchanged text (cache miss)", async () => {
|
|
812
|
+
state.collectionExists = true;
|
|
813
|
+
embedState.statusProvider = "custom";
|
|
814
|
+
embedState.statusModel = "text-embedding-3-small";
|
|
815
|
+
embedState.embedProvider = "custom";
|
|
816
|
+
embedState.embedModel = "text-embedding-3-small";
|
|
817
|
+
embedState.customBaseUrl = "http://127.0.0.1:4000/v1";
|
|
818
|
+
|
|
819
|
+
await upsertSections(CONFIG, [
|
|
820
|
+
section("people/alice", 0, "alice lead text"),
|
|
821
|
+
]);
|
|
822
|
+
expect(embedState.calls).toHaveLength(1);
|
|
823
|
+
|
|
824
|
+
embedState.customBaseUrl = "http://127.0.0.1:4001/v1";
|
|
825
|
+
|
|
826
|
+
await upsertSections(CONFIG, [
|
|
827
|
+
section("people/alice", 0, "alice lead text"),
|
|
828
|
+
]);
|
|
829
|
+
|
|
830
|
+
expect(embedState.calls).toEqual([
|
|
831
|
+
["alice lead text"],
|
|
832
|
+
["alice lead text"],
|
|
833
|
+
]);
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
test("an unchanged custom endpoint still serves from cache", async () => {
|
|
837
|
+
state.collectionExists = true;
|
|
838
|
+
embedState.statusProvider = "custom";
|
|
839
|
+
embedState.statusModel = "text-embedding-3-small";
|
|
840
|
+
embedState.embedProvider = "custom";
|
|
841
|
+
embedState.embedModel = "text-embedding-3-small";
|
|
842
|
+
embedState.customBaseUrl = "http://127.0.0.1:4000/v1";
|
|
843
|
+
|
|
844
|
+
const sections = [section("people/alice", 0, "alice lead text")];
|
|
845
|
+
|
|
846
|
+
await upsertSections(CONFIG, sections);
|
|
847
|
+
await upsertSections(CONFIG, sections);
|
|
848
|
+
|
|
849
|
+
expect(embedState.calls).toHaveLength(1);
|
|
850
|
+
expect(state.upsertCalls).toHaveLength(2);
|
|
851
|
+
});
|
|
669
852
|
});
|
|
670
853
|
|
|
671
854
|
describe("memory v3 section-dense-store — delete", () => {
|
|
@@ -759,3 +942,307 @@ describe("memory v3 section-dense-store — listSectionArticles", () => {
|
|
|
759
942
|
expect(articles).toEqual([]);
|
|
760
943
|
});
|
|
761
944
|
});
|
|
945
|
+
|
|
946
|
+
describe("memory v3 section-dense-store: chunker version guard", () => {
|
|
947
|
+
const reset = () => {
|
|
948
|
+
resetState();
|
|
949
|
+
checkpointState.values.clear();
|
|
950
|
+
checkpointState.ops.length = 0;
|
|
951
|
+
};
|
|
952
|
+
afterEach(() => {
|
|
953
|
+
setSystemTime();
|
|
954
|
+
});
|
|
955
|
+
const HIGH_WATER = "1700000000000";
|
|
956
|
+
const STORED_POINT = { id: "1", payload: { article: "page-a" } };
|
|
957
|
+
const PROBE = [{ limit: 1, offset: undefined }];
|
|
958
|
+
|
|
959
|
+
test("a recorded older version marks the rebuild pending before it clears the high-water, then records the version", async () => {
|
|
960
|
+
reset();
|
|
961
|
+
checkpointState.values.set(SECTION_CHUNKER_VERSION_KEY, "1");
|
|
962
|
+
checkpointState.values.set(MAINTAIN_EMBED_HIGH_WATER_KEY, HIGH_WATER);
|
|
963
|
+
|
|
964
|
+
expect(await ensureSectionChunkerVersion()).toBe(true);
|
|
965
|
+
// The marker is the only signal that survives the reset, so it lands first.
|
|
966
|
+
expect(checkpointState.ops).toEqual([
|
|
967
|
+
`set:${SECTION_REBUILD_PENDING_KEY}`,
|
|
968
|
+
`delete:${MAINTAIN_EMBED_HIGH_WATER_KEY}`,
|
|
969
|
+
`set:${SECTION_CHUNKER_VERSION_KEY}`,
|
|
970
|
+
]);
|
|
971
|
+
expect(checkpointState.values.get(SECTION_CHUNKER_VERSION_KEY)).toBe(
|
|
972
|
+
String(SECTION_CHUNKER_VERSION),
|
|
973
|
+
);
|
|
974
|
+
// A recorded high-water already says "stale": the collection is not probed.
|
|
975
|
+
expect(state.scrollCalls).toEqual([]);
|
|
976
|
+
|
|
977
|
+
// A later check sees the recorded version, writes nothing, and keeps
|
|
978
|
+
// reporting the rebuild pending until a clean pass commits.
|
|
979
|
+
checkpointState.values.set(MAINTAIN_EMBED_HIGH_WATER_KEY, "1700000001000");
|
|
980
|
+
checkpointState.ops.length = 0;
|
|
981
|
+
expect(await ensureSectionChunkerVersion()).toBe(true);
|
|
982
|
+
expect(checkpointState.ops).toEqual([]);
|
|
983
|
+
expect(checkpointState.values.get(MAINTAIN_EMBED_HIGH_WATER_KEY)).toBe(
|
|
984
|
+
"1700000001000",
|
|
985
|
+
);
|
|
986
|
+
commitSectionEmbedHighWater(1700000002000);
|
|
987
|
+
expect(await ensureSectionChunkerVersion()).toBe(false);
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
test("an install that predates the version key (high-water present, no version) rebuilds once", async () => {
|
|
991
|
+
reset();
|
|
992
|
+
checkpointState.values.set(MAINTAIN_EMBED_HIGH_WATER_KEY, HIGH_WATER);
|
|
993
|
+
|
|
994
|
+
expect(await ensureSectionChunkerVersion()).toBe(true);
|
|
995
|
+
expect(checkpointState.deletes).toEqual([MAINTAIN_EMBED_HIGH_WATER_KEY]);
|
|
996
|
+
expect(checkpointState.values.has(MAINTAIN_EMBED_HIGH_WATER_KEY)).toBe(
|
|
997
|
+
false,
|
|
998
|
+
);
|
|
999
|
+
expect(checkpointState.values.get(SECTION_REBUILD_PENDING_KEY)).toBe("1");
|
|
1000
|
+
// Pending until the rebuild pass commits; a second check forces nothing new.
|
|
1001
|
+
expect(await ensureSectionChunkerVersion()).toBe(true);
|
|
1002
|
+
expect(checkpointState.deletes).toEqual([MAINTAIN_EMBED_HIGH_WATER_KEY]);
|
|
1003
|
+
commitSectionEmbedHighWater(1700000002000);
|
|
1004
|
+
expect(await ensureSectionChunkerVersion()).toBe(false);
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
test("a matching version writes nothing; a fresh install (empty collection) records the version without a rebuild", async () => {
|
|
1008
|
+
reset();
|
|
1009
|
+
checkpointState.values.set(
|
|
1010
|
+
SECTION_CHUNKER_VERSION_KEY,
|
|
1011
|
+
String(SECTION_CHUNKER_VERSION),
|
|
1012
|
+
);
|
|
1013
|
+
checkpointState.values.set(MAINTAIN_EMBED_HIGH_WATER_KEY, HIGH_WATER);
|
|
1014
|
+
expect(await ensureSectionChunkerVersion()).toBe(false);
|
|
1015
|
+
expect(checkpointState.ops).toEqual([]);
|
|
1016
|
+
expect(state.scrollCalls).toEqual([]);
|
|
1017
|
+
|
|
1018
|
+
reset();
|
|
1019
|
+
// No version, no high-water, no marker: the collection decides, and an
|
|
1020
|
+
// empty one is a fresh install.
|
|
1021
|
+
expect(await ensureSectionChunkerVersion()).toBe(false);
|
|
1022
|
+
expect(state.scrollCalls).toEqual(PROBE);
|
|
1023
|
+
expect(checkpointState.ops).toEqual([`set:${SECTION_CHUNKER_VERSION_KEY}`]);
|
|
1024
|
+
expect(checkpointState.values.has(SECTION_REBUILD_PENDING_KEY)).toBe(false);
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
test("a forced rebuild marks the rebuild pending; committing the pass's high-water clears the marker", async () => {
|
|
1028
|
+
reset();
|
|
1029
|
+
checkpointState.values.set(SECTION_CHUNKER_VERSION_KEY, "1");
|
|
1030
|
+
checkpointState.values.set(MAINTAIN_EMBED_HIGH_WATER_KEY, HIGH_WATER);
|
|
1031
|
+
|
|
1032
|
+
expect(await ensureSectionChunkerVersion()).toBe(true);
|
|
1033
|
+
expect(checkpointState.values.get(SECTION_REBUILD_PENDING_KEY)).toBe("1");
|
|
1034
|
+
|
|
1035
|
+
commitSectionEmbedHighWater(1700000002000);
|
|
1036
|
+
expect(checkpointState.values.get(MAINTAIN_EMBED_HIGH_WATER_KEY)).toBe(
|
|
1037
|
+
"1700000002000",
|
|
1038
|
+
);
|
|
1039
|
+
expect(checkpointState.values.has(SECTION_REBUILD_PENDING_KEY)).toBe(false);
|
|
1040
|
+
expect(checkpointState.deletes).toEqual([
|
|
1041
|
+
MAINTAIN_EMBED_HIGH_WATER_KEY,
|
|
1042
|
+
SECTION_REBUILD_PENDING_KEY,
|
|
1043
|
+
]);
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
test("a transition interrupted after the marker (high-water still present, version unrecorded) is finished by the next process with the hold on", async () => {
|
|
1047
|
+
reset();
|
|
1048
|
+
// The state a crash between the two transition writes leaves behind.
|
|
1049
|
+
checkpointState.values.set(SECTION_CHUNKER_VERSION_KEY, "1");
|
|
1050
|
+
checkpointState.values.set(SECTION_REBUILD_PENDING_KEY, "1");
|
|
1051
|
+
checkpointState.values.set(MAINTAIN_EMBED_HIGH_WATER_KEY, HIGH_WATER);
|
|
1052
|
+
|
|
1053
|
+
// The fresh process holds reads and forces the rebuild: the high-water is
|
|
1054
|
+
// gone, the marker stays, the version is now on record.
|
|
1055
|
+
expect(await holdSectionDenseReadsUntilRebuilt()).toBe(true);
|
|
1056
|
+
expect(sectionDenseReadsHeld()).toBe(true);
|
|
1057
|
+
expect(checkpointState.values.has(MAINTAIN_EMBED_HIGH_WATER_KEY)).toBe(
|
|
1058
|
+
false,
|
|
1059
|
+
);
|
|
1060
|
+
expect(checkpointState.values.get(SECTION_REBUILD_PENDING_KEY)).toBe("1");
|
|
1061
|
+
expect(checkpointState.values.get(SECTION_CHUNKER_VERSION_KEY)).toBe(
|
|
1062
|
+
String(SECTION_CHUNKER_VERSION),
|
|
1063
|
+
);
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
test("a transition interrupted after the reset (marker set, high-water absent, version unrecorded) keeps the hold without probing the collection", async () => {
|
|
1067
|
+
reset();
|
|
1068
|
+
checkpointState.values.set(SECTION_CHUNKER_VERSION_KEY, "1");
|
|
1069
|
+
checkpointState.values.set(SECTION_REBUILD_PENDING_KEY, "1");
|
|
1070
|
+
|
|
1071
|
+
expect(await holdSectionDenseReadsUntilRebuilt()).toBe(true);
|
|
1072
|
+
expect(state.scrollCalls).toEqual([]);
|
|
1073
|
+
expect(checkpointState.values.get(SECTION_REBUILD_PENDING_KEY)).toBe("1");
|
|
1074
|
+
expect(checkpointState.values.get(SECTION_CHUNKER_VERSION_KEY)).toBe(
|
|
1075
|
+
String(SECTION_CHUNKER_VERSION),
|
|
1076
|
+
);
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
test("a version-less store with no high-water or marker but points in the collection is stale, not fresh", async () => {
|
|
1080
|
+
reset();
|
|
1081
|
+
// No version, no high-water, no marker, yet points in the collection: an
|
|
1082
|
+
// install whose passes never committed cleanly. Nothing on the ledger
|
|
1083
|
+
// says "stale", so the collection probe has to.
|
|
1084
|
+
state.scrollPages = [{ points: [STORED_POINT], next_page_offset: null }];
|
|
1085
|
+
|
|
1086
|
+
expect(await holdSectionDenseReadsUntilRebuilt()).toBe(true);
|
|
1087
|
+
expect(sectionDenseReadsHeld()).toBe(true);
|
|
1088
|
+
expect(state.scrollCalls).toEqual(PROBE);
|
|
1089
|
+
expect(checkpointState.values.get(SECTION_REBUILD_PENDING_KEY)).toBe("1");
|
|
1090
|
+
expect(checkpointState.values.get(SECTION_CHUNKER_VERSION_KEY)).toBe(
|
|
1091
|
+
String(SECTION_CHUNKER_VERSION),
|
|
1092
|
+
);
|
|
1093
|
+
// The rebuild pass's commit releases the hold as usual.
|
|
1094
|
+
commitSectionEmbedHighWater(1700000002000);
|
|
1095
|
+
expect(sectionDenseReadsHeld()).toBe(false);
|
|
1096
|
+
expect(await ensureSectionChunkerVersion()).toBe(false);
|
|
1097
|
+
});
|
|
1098
|
+
|
|
1099
|
+
test("a collection probe that fails holds reads as indeterminate; the retried check finds the stale points, marks the rebuild, kicks it, and the commit releases", async () => {
|
|
1100
|
+
reset();
|
|
1101
|
+
setSystemTime(new Date("2026-01-01T00:00:00Z"));
|
|
1102
|
+
state.scrollThrows = new Error("qdrant unreachable");
|
|
1103
|
+
const kicks: number[] = [];
|
|
1104
|
+
|
|
1105
|
+
// No version, no high-water, no marker: only the probe can say whether
|
|
1106
|
+
// the points are stale, and it cannot run. Held, nothing written, and
|
|
1107
|
+
// the check still owed.
|
|
1108
|
+
expect(
|
|
1109
|
+
await holdSectionDenseReadsUntilRebuilt(() => kicks.push(kicks.length)),
|
|
1110
|
+
).toBe(true);
|
|
1111
|
+
expect(sectionDenseReadsHeld()).toBe(true);
|
|
1112
|
+
expect(checkpointState.ops).toEqual([]);
|
|
1113
|
+
expect(kicks).toEqual([]);
|
|
1114
|
+
// Already held: a later lane init in this process starts nothing new.
|
|
1115
|
+
expect(await holdSectionDenseReadsUntilRebuilt()).toBe(false);
|
|
1116
|
+
|
|
1117
|
+
// Qdrant recovers with points built by the previous chunker. Inside the
|
|
1118
|
+
// cooldown the read path leaves the check alone.
|
|
1119
|
+
state.scrollThrows = null;
|
|
1120
|
+
state.scrollPages = [{ points: [STORED_POINT], next_page_offset: null }];
|
|
1121
|
+
expect(await settleSectionDenseReadHold()).toBe(true);
|
|
1122
|
+
expect(state.scrollCalls).toEqual(PROBE);
|
|
1123
|
+
|
|
1124
|
+
// Past it, the retried check completes the transition the init check
|
|
1125
|
+
// could not: marker first, high-water reset, version recorded, and the
|
|
1126
|
+
// rebuild kicked through the callback lane init registered.
|
|
1127
|
+
setSystemTime(new Date("2026-01-01T00:01:00Z"));
|
|
1128
|
+
expect(await settleSectionDenseReadHold()).toBe(true);
|
|
1129
|
+
expect(state.scrollCalls).toEqual([...PROBE, ...PROBE]);
|
|
1130
|
+
expect(checkpointState.ops).toEqual([
|
|
1131
|
+
`set:${SECTION_REBUILD_PENDING_KEY}`,
|
|
1132
|
+
`delete:${MAINTAIN_EMBED_HIGH_WATER_KEY}`,
|
|
1133
|
+
`set:${SECTION_CHUNKER_VERSION_KEY}`,
|
|
1134
|
+
]);
|
|
1135
|
+
expect(kicks).toEqual([0]);
|
|
1136
|
+
|
|
1137
|
+
// Held for the rebuild now, so the marker governs the release.
|
|
1138
|
+
expect(sectionDenseReadsHeld()).toBe(true);
|
|
1139
|
+
commitSectionEmbedHighWater(1700000002000);
|
|
1140
|
+
expect(sectionDenseReadsHeld()).toBe(false);
|
|
1141
|
+
expect(await settleSectionDenseReadHold()).toBe(false);
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
test("a retried check that fails again keeps the hold and re-arms the cooldown, and overlapping reads share one retry", async () => {
|
|
1145
|
+
reset();
|
|
1146
|
+
setSystemTime(new Date("2026-01-01T00:00:00Z"));
|
|
1147
|
+
state.scrollThrows = new Error("qdrant unreachable");
|
|
1148
|
+
|
|
1149
|
+
expect(await holdSectionDenseReadsUntilRebuilt()).toBe(true);
|
|
1150
|
+
|
|
1151
|
+
setSystemTime(new Date("2026-01-01T00:01:00Z"));
|
|
1152
|
+
expect(
|
|
1153
|
+
await Promise.all([
|
|
1154
|
+
settleSectionDenseReadHold(),
|
|
1155
|
+
settleSectionDenseReadHold(),
|
|
1156
|
+
]),
|
|
1157
|
+
).toEqual([true, true]);
|
|
1158
|
+
// One retry for both reads, and it failed: still held, nothing written,
|
|
1159
|
+
// and the next minute is waited out before another probe.
|
|
1160
|
+
expect(state.scrollCalls).toEqual([...PROBE, ...PROBE]);
|
|
1161
|
+
expect(sectionDenseReadsHeld()).toBe(true);
|
|
1162
|
+
expect(await settleSectionDenseReadHold()).toBe(true);
|
|
1163
|
+
expect(state.scrollCalls).toHaveLength(2);
|
|
1164
|
+
expect(checkpointState.ops).toEqual([]);
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
test("a fresh install whose probe fails is held until the retried check records the version, then reads open with nothing pending", async () => {
|
|
1168
|
+
reset();
|
|
1169
|
+
setSystemTime(new Date("2026-01-01T00:00:00Z"));
|
|
1170
|
+
state.scrollThrows = new Error("qdrant unreachable");
|
|
1171
|
+
const kicks: number[] = [];
|
|
1172
|
+
|
|
1173
|
+
expect(
|
|
1174
|
+
await holdSectionDenseReadsUntilRebuilt(() => kicks.push(kicks.length)),
|
|
1175
|
+
).toBe(true);
|
|
1176
|
+
expect(sectionDenseReadsHeld()).toBe(true);
|
|
1177
|
+
|
|
1178
|
+
// The probe finds the collection empty once it can run: a fresh install,
|
|
1179
|
+
// recorded as such, with nothing to rebuild and nothing to kick.
|
|
1180
|
+
state.scrollThrows = null;
|
|
1181
|
+
setSystemTime(new Date("2026-01-01T00:01:00Z"));
|
|
1182
|
+
expect(await settleSectionDenseReadHold()).toBe(false);
|
|
1183
|
+
expect(sectionDenseReadsHeld()).toBe(false);
|
|
1184
|
+
expect(checkpointState.ops).toEqual([`set:${SECTION_CHUNKER_VERSION_KEY}`]);
|
|
1185
|
+
expect(checkpointState.values.has(SECTION_REBUILD_PENDING_KEY)).toBe(false);
|
|
1186
|
+
expect(kicks).toEqual([]);
|
|
1187
|
+
expect(await ensureSectionChunkerVersion()).toBe(false);
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
test("a version check that fails after writing the marker holds dense reads, and the retried check finishes the transition", async () => {
|
|
1191
|
+
reset();
|
|
1192
|
+
setSystemTime(new Date("2026-01-01T00:00:00Z"));
|
|
1193
|
+
checkpointState.values.set(SECTION_CHUNKER_VERSION_KEY, "1");
|
|
1194
|
+
checkpointState.values.set(MAINTAIN_EMBED_HIGH_WATER_KEY, HIGH_WATER);
|
|
1195
|
+
checkpointState.throwOnSet = SECTION_CHUNKER_VERSION_KEY;
|
|
1196
|
+
const kicks: number[] = [];
|
|
1197
|
+
|
|
1198
|
+
expect(
|
|
1199
|
+
await holdSectionDenseReadsUntilRebuilt(() => kicks.push(kicks.length)),
|
|
1200
|
+
).toBe(true);
|
|
1201
|
+
expect(sectionDenseReadsHeld()).toBe(true);
|
|
1202
|
+
// The marker landed before the failure, so the durable state says stale,
|
|
1203
|
+
// while the failed write left the old version on record.
|
|
1204
|
+
expect(checkpointState.values.get(SECTION_REBUILD_PENDING_KEY)).toBe("1");
|
|
1205
|
+
expect(checkpointState.values.get(SECTION_CHUNKER_VERSION_KEY)).toBe("1");
|
|
1206
|
+
expect(kicks).toEqual([]);
|
|
1207
|
+
|
|
1208
|
+
// The ledger takes writes again: the retried check repeats the
|
|
1209
|
+
// transition (the marker already says stale, so no probe), records the
|
|
1210
|
+
// version, and kicks the rebuild the marker names.
|
|
1211
|
+
checkpointState.throwOnSet = null;
|
|
1212
|
+
setSystemTime(new Date("2026-01-01T00:01:00Z"));
|
|
1213
|
+
expect(await settleSectionDenseReadHold()).toBe(true);
|
|
1214
|
+
expect(checkpointState.values.get(SECTION_CHUNKER_VERSION_KEY)).toBe(
|
|
1215
|
+
String(SECTION_CHUNKER_VERSION),
|
|
1216
|
+
);
|
|
1217
|
+
expect(state.scrollCalls).toEqual([]);
|
|
1218
|
+
expect(kicks).toEqual([0]);
|
|
1219
|
+
commitSectionEmbedHighWater(1700000002000);
|
|
1220
|
+
expect(sectionDenseReadsHeld()).toBe(false);
|
|
1221
|
+
});
|
|
1222
|
+
|
|
1223
|
+
test("a version check that fails while the marker cannot be read holds dense reads until the ledger answers", async () => {
|
|
1224
|
+
reset();
|
|
1225
|
+
setSystemTime(new Date("2026-01-01T00:00:00Z"));
|
|
1226
|
+
checkpointState.values.set(SECTION_CHUNKER_VERSION_KEY, "1");
|
|
1227
|
+
checkpointState.throwOnGet = SECTION_REBUILD_PENDING_KEY;
|
|
1228
|
+
|
|
1229
|
+
expect(await holdSectionDenseReadsUntilRebuilt()).toBe(true);
|
|
1230
|
+
expect(sectionDenseReadsHeld()).toBe(true);
|
|
1231
|
+
|
|
1232
|
+
// The marker reads again, absent, with no high-water and an empty
|
|
1233
|
+
// collection: nothing pending, and the retried check opens reads.
|
|
1234
|
+
checkpointState.throwOnGet = null;
|
|
1235
|
+
setSystemTime(new Date("2026-01-01T00:01:00Z"));
|
|
1236
|
+
expect(await settleSectionDenseReadHold()).toBe(false);
|
|
1237
|
+
expect(sectionDenseReadsHeld()).toBe(false);
|
|
1238
|
+
expect(checkpointState.values.get(SECTION_CHUNKER_VERSION_KEY)).toBe(
|
|
1239
|
+
String(SECTION_CHUNKER_VERSION),
|
|
1240
|
+
);
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
test("a fresh install's version record marks nothing pending", async () => {
|
|
1244
|
+
reset();
|
|
1245
|
+
expect(await ensureSectionChunkerVersion()).toBe(false);
|
|
1246
|
+
expect(checkpointState.values.has(SECTION_REBUILD_PENDING_KEY)).toBe(false);
|
|
1247
|
+
});
|
|
1248
|
+
});
|