Dashboard › opencode-lore › Distillation
c06c3655-a81e-4259-8180-6dc60d382379["lore_tm_v1_7pKkkplGM1DSMiw8fbQV0wVT8eo4XEErnR4yBn8I214","lore_tm_v1_RpDL9ZVaog01mAeHTSdfHVmXtkEnRMx5LbxjOQk7FKc","lore_tm_v1_fWs4urbRDreii7AezE3HHuwnkGEJV8c2RSEPGVI3sbg"]
Date: Sep 17, 2026
resolveMemoryHeadroom always accepts finite Node headroom without a hard limit.clampFreeToContainerLimit never raises the figure: it is monotonic and can only reduce memory use.packages/core/src/embedding/local.ts that imports readLinuxCgroupMemoryHeadroomBytes from ../cgroup-memory and resolveMemoryHeadroom from ../embedding-cap._setAvailableMemoryForTest(bytes: number | null) and availableMemoryHeadroom() in packages/core/src/embedding/local.ts; the latter combines constrainedMemoryLimit(), Linux cgroup headroom, and process.availableMemory() through resolveMemoryHeadroom.availableMemoryHeadroom() design treats Bun specially because Bun’s implementation currently aliases host freemem() inside a constrained cgroup, while Node’s libuv implementation is process-limit-aware.containerFreeBytes() in packages/core/src/embedding/local.ts to call clampFreeToContainerLimit(raw, constrainedMemoryLimit(), availableMemoryHeadroom()).PER_WORKER_MEM_BUDGET_BYTES to internal MODELED_WORKER_MEM_BUDGET_BYTES; it remains EMBED_MODEL_BASELINE_BYTES + EMBED_ATTENTION_BYTES_PER_TOKEN_SQ * EMBED_POOL_BUDGET_REF_TOKENS * EMBED_POOL_BUDGET_REF_TOKENS, described as the model plus a 2048-token attention estimate and used as a lower bound for pool admission.memory.high while leaving memory.max unlimited, so an absent hard limit does not imply unconstrained available memory.0, 256 * MB, 4 * GB, 12 * GB, and 128 * GB, and available-memory values over 0, 32 * MB, 2 * GB, and 64 * GB, requiring every clamped result for 6 * GB host-free memory to remain at most 6 * GB.resolveMemoryHeadroom tests, including the expectation resolveMemoryHeadroom(12 * GB, undefined, 2 * GB) === 2 * GB and a case titled "always accepts finite Node headroom without a hard limit"._setAvailableMemoryForTest, _persistEmbedCap(8192, 0), and fake-worker scenarios involving embed(["alpha"], "query"), embed(["second"], "query"), and fakes[0].completeNext().packages/core/src/cgroup-memory.ts, which reads /proc and cgroup data using readFileSync, models cgroup membership as version 1 | 2, and safely decodes octal-escaped proc paths while rejecting non-absolute paths, NUL characters, and .. path components.parseCgroupMemberships() logic makes a cgroup v1 memory-controller membership authoritative on hybrid v1/v2 hosts, even when malformed or unavailable, because falling through to v2 would account against the wrong hierarchy.resolveLinuxCgroupMemoryFileCandidates() parses mountinfo, matches cgroup2 for v2 or a cgroup mount with the memory super-option for v1, handles cgroup namespaces, prefers direct candidates, and sorts direct candidates by descending root-path length.Math.max(0, limit - usage), and retains the minimum candidate across applicable boundaries.memory.current, memory.high, and memory.max, but requires every descendant boundary to remain readable so sibling usage is never subtracted from the wrong scope./proc/self/cgroup and /proc/self/mountinfo after accounting; if either changed during the operation, it returns undefined rather than admitting work based on stale process membership or mounts.undefined on read, parsing, hierarchy-traversal, or consistency errors.