Dashboard › opencode-lore › Distillation
8d8e4b54-2965-478e-80d2-06587af1eb71["lore_tm_v1_awZMXI_PuiAa3L9j87N9RQ-en4_cyT2BKHbduTrJRCw","lore_tm_v1_6MQXaoq2wrPQiFjD7OZfwthpA7bCIg-53o51uzEpX2E","lore_tm_v1_BYC1pSyd_blCdDOnPvc5rX6rck8qj5MSt2DSoRQM6PI","lore_tm_v1_LEcStqAZT062EpHo2cddTQpKsCh4XhZxMCypbnU2AO4"]
Date: Sep 17, 2026
packages/core/src/embedding/local.ts now imports readLinuxCgroupMemoryHeadroomBytes from ../cgroup-memory and resolveMemoryHeadroom from ../embedding-cap.packages/core/src/embedding/local.ts adds test override testAvailableMemoryBytes: number | null and exported helper _setAvailableMemoryForTest(bytes: number | null).packages/core/src/embedding/local.ts calls resolveMemoryHeadroom(constrained, linuxHeadroom, fn()), combining constrained-memory state, Linux cgroup headroom, and Node/libuv available-memory reporting.SIGKILL, so the normal Γ0.7 cap backoff cannot protect this path.free memory / pool ceiling; (2) re-clamp maxTokens against current free memory on every request rather than relying only on the construction-time cap.LocalEmbeddingProvider.embed() in packages/core/src/embedding/local.ts, each EmbedRequest.maxTokens is set through this.effectiveMaxTokens() so memory consumed by sibling workers and live sessions can lower the cap before dispatch.packages/core/src/embedding/local.ts also recalculates every pending requestβs p.payload.maxTokens through this.effectiveMaxTokens() immediately before resubmitting it to the fresh worker.packages/core/test/embedding-cap-persistence.test.ts covers lore:embedding_cap persistence: 1. absent row returns null; 2. _persistEmbedCap(1234) round-trips cap 1234 and records positive freeMemBytes; 3. writes 1000 then 500 use ON CONFLICT and retain 500; 4. corrupt value "not-json{" returns null without throwing; 5. JSON missing required fields returns null; 6. _persistEmbedCap(1000, 4 * 1024 * 1024 * 1024, 3000) round-trips knownBadCap=3000; 7. knownBadCap is omitted for both the default and explicit 0; 8. persisted non-positive 0 or nonnumeric "x" knownBadCap values are ignored.packages/core/test/embedding-pool-memory.test.ts, using CapturingWorker to snapshot exact per-request EmbedMsg payloads because production payloads are mutated in place during OOM resubmission.packages/core/test/embedding-pool-memory.test.ts resets _setTestWorkerFactory, _setEmbedPoolSizeForTest, _setPoolFreememForTest, _setContainerFreeForTest, _setAvailableMemoryForTest, _setConstrainedMemoryForTest, and the local provider probe after each test; it also preserves and restores VOYAGE_API_KEY, OPENAI_API_KEY, and the prior provider.8192 with freeMemBytes=0, sets pool ceiling 2 and free memory 6 * GB, then verifies the posted cap equals memoryModelEmbedCap((6 * GB) / 2) and is strictly below memoryModelEmbedCap(6 * GB).8192, sets pool ceiling 1, container free memory 64 * GB, constrained memory 12 * GB, and available memory Number.NaN; it verifies unknown constrained primary-worker headroom forces maxTokens to MIN_EMBED_TOKENS.8192, sets pool ceiling 1, container free memory 64 * GB, constrained memory 0, and available memory Number.NaN; it verifies failed cgroup accounting without a hard limit also forces maxTokens to MIN_EMBED_TOKENS.6 * GB to 2 * GB between requests, and verifies the first and second caps equal memoryModelEmbedCap(6 * GB) and memoryModelEmbedCap(2 * GB) respectively, with the second strictly lower.16 * GB, drops free memory to 2 * GB, emits worker exit code EMBED_OOM_EXIT_CODE, and verifies the replacement worker receives the same request ID with maxTokens=memoryModelEmbedCap(2 * GB), strictly below backoffEmbedCap(first.maxTokens); this pins current-memory clamping on the native-SIGKILL retry path rather than relying only on Γ0.7 backoff.