Dashboard › opencode-lore › Distillation
cc4beca8-0fa9-4d3d-900e-b06219d1c964["lore_tm_v1_tDkpNnyWzh-cQyVri99-7zk2mn3NogMjZQ-mzO1bvFw","lore_tm_v1_zi5wCLN91FYP5PAmE8QRomNDAwg9UKmN3RNSL6_PR7s","lore_tm_v1_QhJTf4C5_nHUJqkzwOY4piERFt9qlU8MLTKOpSXf6I0","lore_tm_v1_diI6QunAxErUo966Ji3bTlMGCmSfixWVh7LSsCQWln0","lore_tm_v1_RIFovwx8hm2C2GQKue07t-lGO5qPLObjSNYVRUrbqAU","lore_tm_v1_Oyp9RF4qdYiWKb8AKcsXlzvAN6jO_reiLothkOQMY9M"]
Date: Sep 16, 2026
packages/core/src/cgroup-memory.ts and packages/core/test/cgroup-memory.test.ts; modified packages/core/src/embedding/local.ts, packages/core/src/embedding/pool.ts, packages/core/src/embedding-cap.ts, packages/core/src/embedding-worker-types.ts, packages/core/src/embedding-worker.ts, packages/core/src/embedding.ts, packages/core/src/ort-native.ts, packages/core/test/embedding-cap.test.ts, packages/core/test/embedding-pool-memory.test.ts, packages/core/test/embedding-pool.test.ts, packages/core/test/embedding-worker-types.test.ts, packages/core/test/ort-native.test.ts, packages/gateway/script/bundle.ts, packages/gateway/script/ort-platform-package.ts, packages/gateway/test/bundle-exports.test.ts, and packages/gateway/test/ort-platform-package.test.ts./proc/self/cgroup and /proc/self/mountinfo for each memory-headroom check so a worker is never admitted from a stale cgroup directory or a cached discovery miss.undefined, except that the cgroup v2 root may omit memory.current, memory.high, and memory.max when the mount root and hierarchy root are both /.packages/core/src/cgroup-memory.ts defines resolveLinuxCgroupMemoryFiles() and readLinuxCgroupMemoryHeadroomBytes(). It supports cgroup v1 (memory.usage_in_bytes, memory.limit_in_bytes) and v2 (memory.current, memory.high, memory.max), computes the minimum finite max(0, limit - usage) across the selected cgroup and its ancestors, and returns undefined on malformed or unsafe data.packages/core/src/cgroup-memory.ts decodes procfs octal escapes, rejects non-absolute paths, NUL bytes, and .. components, normalizes paths with node:path posix, prefers an explicit cgroup v1 memory controller on hybrid v1/v2 hosts, chooses the deepest matching direct mount root, and accepts a namespaced host-side mount interpretation only when exactly one candidate is available.packages/core/src/cgroup-memory.ts parses byte usage only as nonnegative safe integers. Limits accept decimal values or "max"; numeric limits above Number.MAX_SAFE_INTEGER are treated as Number.POSITIVE_INFINITY.8192 tokens (LOCAL_MAX_CHARS = MODEL_MAX_TOKENS * 4).EMBED_ATTENTION_BYTES_PER_TOKEN_SQ = 120, EMBED_WORKER_RESIDENT_RESERVE_BYTES = 1536 * 1024 * 1024, and EMBED_POOL_ABS_MAX = 8; the memory model includes an O(L²) attention peak and always allows at least the primary worker.packages/core/src/embedding/local.ts now derives container-aware free memory through clampFreeToContainerLimit(raw, constrainedMemoryLimit(), availableMemoryHeadroom()). constrainedMemoryLimit() uses process.constrainedMemory() and normalizes unknown, unsupported, unconstrained, nonfinite, or nonpositive values to 0.availableMemoryHeadroom() in packages/core/src/embedding/local.ts combines readLinuxCgroupMemoryHeadroomBytes(), process.constrainedMemory(), and, on Node, process.availableMemory(). Bun deliberately does not trust process.availableMemory() because its implementation currently aliases host freemem() inside constrained cgroups; failures or missing runtime APIs fall back through resolveMemoryHeadroom().packages/core/src/embedding/local.ts uses key lore:embedding_cap in kv_meta, storing JSON fields cap, freeMemBytes, and optional positive knownBadCap. Writes use INSERT INTO kv_meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = ?; malformed or unavailable state is treated as absent, and persistence failures are best-effort.packages/core/src/embedding/local.ts sets EMBED_REPROBE_INTERVAL_MS = 5 * 60_000; computeInitialEmbedCap() divides container-aware free memory by Math.max(1, memDivisor) and calls reconcileEmbedCap() with the persisted cap, memoryModelEmbedCap(free), and persisted knownBadCap.safeLocalTruncate() limits local embedding text to LOCAL_MAX_CHARS = MODEL_MAX_TOKENS * 4 and backs up one UTF-16 code unit when the boundary would split a high-surrogate/low-surrogate pair.isMissingLocalStackError() in packages/core/src/embedding-worker-types.ts classifies the optional local stack as absent only when an error contains both a module-resolution signal (ERR_MODULE_NOT_FOUND, “Cannot find module/package”, or “Could not locate the bindings file”) and a reference to @huggingface/transformers, onnxruntime, or sharp; unrelated missing model files are not misclassified.isNativeOrtLoadError() requires both a native ONNX Runtime artifact reference (onnxruntime_binding.node, an ONNX Runtime .so/.dylib/.dll, or OrtGetApiBase) and a load-failure signal such as ERR_DLOPEN_FAILED, invalid ELF/Mach-O/Win32, truncated file, missing shared library/image/module, undefined/missing symbol, or dlopen.shouldRequestWasmRespawn(usedNative, isVendored, errorMessage, fileLooksIntact) returns true only when native ORT was used, the model is not vendored, the model file looks structurally intact, and isCorruptModelError(errorMessage) detects a parse/deserialization failure. This handles the npm bundle under Bun where native onnxruntime-node can fail with “protobuf parsing failed” on an intact approximately 137 MB model; genuinely truncated models still follow purge and re-download.shouldPostPerRequestError(initFailed, wasmRespawnRequested) returns !initFailed && !wasmRespawnRequested. It suppresses duplicate per-request errors after ensurePipeline() has posted init-error, and prevents a WASM-respawn request from being rejected and dropped before respawnForWasm() can resubmit it.RuntimeError, posted OOM errors, and “is not a function” callable-pipeline failures as fatal. The primary callable-pattern fix remains a typeof pipe !== "function" construction-time guard in packages/core/src/embedding-worker.ts, covering @huggingface/transformers callable instances under esbuild CJS with Node v24.