Dashboard › opencode-lore › Session 1dqSHs2bdFQf
1dqSHs2bdFQf4Oq2OPerform a read-only adversarial correctness review of ONLY the embedding memory admission/cgroup slice in /home/byk/Code/opencode-lore-embedding-runtime at current Jujutsu change tmzmtlss. Do not edit files, mutate VCS, use network, or run production services. Scope: packages/core/src/cgroup-memory.ts, embedding-cap.ts, embedding/local.ts memory helpers, embedding/pool.ts growth/admission, and their tests (cgroup-memory, embedding-cap, embedding-pool, embedding-pool-memory). Inspect actual current source. Focus on cgroup v1/v2 hierarchy/mount selection/namespaces/cache refresh, fail-closed unknown headroom, monotonic clamp, primary sizing, in-flight worker reservations, constructor ceiling recovery, races and arithmetic. Check whether regressions exercise real pre-fix conditions. Return substantive PASS/CONCERN/MUST-FIX findings with exact file:line and a final MERGE or DO-NOT-MERGE. No changes.
<skill_content name="jj-guide"> # Skill: jj-guide # jj Guide for AI Agents Jujutsu (jj) is a Git-compatible VCS with mutable commits, automatic snapshotting, no staging area, and first-class conflicts. This skill teaches you how to use it safely from a non-interactive agent environment. If `.jj/` exists in the repo root, this is a jj repo. **Use `jj` commands, not `git`.** In a colocated repo (`.jj/` *and* `.git/`), git tools can read the state, but mutations should go through `jj` so the operation log stays consistent. ## Critical Rules - **NEVER** use interactive flags (`-i`, `--interactive`). TUI prompts hang in agent environments. This applies to `jj split -i`, `jj squash -i`, `jj commit -i`, `jj resolve`, `jj diffedit`, etc. - **ALWAYS** pass `-m "msg"` when describing/committing. Without `-m`, an editor opens and hangs. - **VERIFY** mutations with `jj st` and `jj log` after `squash`, `abandon`, `rebase`, `restore`, `commit`. ...
<path>/home/byk/Code/opencode-lore-embedding-runtime</path> <type>directory</type> <entries> .craft.yml .git .github/ .gitignore .jj/ .lore.md .oxfmtrc.json .oxlintrc.json AGENTS.md CHANGELOG.md codecov.yml LICENSE node_modules/ package.json packages/ patches/ pnpm-lock.yaml pnpm-workspace.yaml quality/ README.md scripts/ stryker.config.mjs supabase/ tsconfig.base.json tsconfig.json vitest.config.ts vitest.evals.config.ts vitest.mutation.config.ts (28 entries) </entries>
No files found
<path>/home/byk/Code/opencode-lore-embedding-runtime/AGENTS.md</path> <type>file</type> <content> 1: <!-- This section is maintained by the coding agent via lore (https://github.com/BYK/loreai) --> 2: ## Long-term Knowledge 3: 4: For long-term knowledge entries managed by [lore](https://github.com/BYK/loreai) (gotchas, patterns, decisions, architecture), see [`.lore.md`](.lore.md) in the project root. 5: <!-- End lore-managed section --> 6: 7: ## Review 8: 9: See [`quality/REVIEW.md`](quality/REVIEW.md) for the review heuristics and workflow — regression-test discipline, adversarial-order state setup, fan-out registry coverage, recurring bug-class batteries, and the two-reviewer rule. Every non-trivial PR requires an adversarial correctness review before merge. 10: 11: # Project Overview 12: 13: Lore is a **three-tier memory architecture** for AI coding agents. ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/quality/REVIEW.md</path> <type>file</type> <content> 1: # Review Heuristics — Lore 2: 3: This document codifies the review bar for pull requests. It exists because 4: adversarial review has repeatedly caught correctness bugs that a green test 5: suite missed — skip/early-return branches, lifecycle sequences, and fan-out 6: registry gaps. Institutionalizing these patterns so they compound. 7: 8: The review workflow (§6) is referenced from AGENTS.md. 9: 10: --- 11: 12: ## 1. Regression-test discipline 13: 14: Every adversarial-review finding that surfaces a defect **must** land a 15: deterministic regression test in the same PR. The test: 16: - fails on the base branch (proving it reproduces the bug), 17: - passes on the fix (proving the fix works), 18: - drives the *real* precondition, not an artificially-constructed state (e.g. ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "lore-monorepo",
3: "private": true,
4: "type": "module",
5: "license": "FSL-1.1-Apache-2.0",
6: "description": "Monorepo root for Lore — three-tier memory architecture",
7: "main": "./packages/opencode/src/index.ts",
8: "exports": {
9: ".": "./packages/opencode/src/index.ts"
10: },
11: "packageManager": "pnpm@10.28.0",
12: "volta": {
13: "node": "24.16.0",
14: "pnpm": "10.28.0"
15: },
16: "pnpm": {
17: "onlyBuiltDependencies": [
18: "esbuild",
19: "onnxruntime-node",
20: "sharp"
21: ],
22: "overrides": {
23: "basic-ftp": "5.3.1",
24: "ip-address": "10.2.0",
25: "fast-xml-parser": "5.7.3",
26: "@huggingface/hub": "2.11.0",
27: "onnxruntime-node": "1.27.0",
28: "yaml": ">=2.8.3",
29: "esbuild": ">=0.28.1",
30: "@opentelemetry/core": ">=2.8.0",
31: ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "@loreai/core",
3: "version": "0.40.0",
4: "type": "module",
5: "license": "FSL-1.1-Apache-2.0",
6: "description": "Shared memory engine for Lore — three-tier storage, distillation, gradient context management",
7: "main": "./dist/node/index.js",
8: "types": "./dist/node/index.d.ts",
9: "exports": {
10: ".": {
11: "types": "./dist/types/index.d.ts",
12: "development": "./src/index.ts",
13: "bun": "./dist/bun/index.js",
14: "default": "./dist/node/index.js"
15: }
16: },
17: "imports": {
18: "#db/driver": {
19: "bun": "./src/db/driver.bun.ts",
20: "default": "./src/db/driver.node.ts"
21: }
22: },
23: "scripts": {
24: "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.eval.json",
25: "build": "tsx script/build.ts"
26: },
27: "dependencies": {
28: "@hpke/core": ...
Working copy changes: A packages/core/src/cgroup-memory.ts M packages/core/src/embedding/local.ts M packages/core/src/embedding/pool.ts M packages/core/src/embedding-cap.ts M packages/core/src/embedding-worker-types.ts M packages/core/src/embedding-worker.ts M packages/core/src/embedding.ts M packages/core/src/ort-native.ts A packages/core/test/cgroup-memory.test.ts M packages/core/test/embedding-cap.test.ts M packages/core/test/embedding-pool-memory.test.ts M packages/core/test/embedding-pool.test.ts M packages/core/test/embedding-worker-types.test.ts M packages/core/test/ort-native.test.ts M packages/gateway/script/bundle.ts M packages/gateway/script/ort-platform-package.ts M packages/gateway/test/bundle-exports.test.ts M packages/gateway/test/ort-platform-package.test.ts Working copy (@) : tmzmtlss e6d0f1ed fix/embedding-runtime-admission | fix(core): correct embedding runtime selection and admission Parent commit (@-): pxrvwsvv 2cbf4006 main | feat(cch): add seeds for Claude Code ...
tmzmtlsspstnppsrlpmuulsywurmlnqu e6d0f1edc8504c79ef3a6baacb1d74e4908e116b parents: pxrvwsvvkmpoxnsqmrkwrnlqvvkoltwz 2cbf40060c67df229731cf1b9e34d5bf22ec2145 description: fix(core): correct embedding runtime selection and admission conflict: false empty: false pxrvwsvvkmpoxnsqmrkwrnlqvvkoltwz 2cbf40060c67df229731cf1b9e34d5bf22ec2145 parents: xpzmsyowwmzsorxottxynvnwlqrykyuo e977b4b1da8f8197c3238466d41de0bccd8eb054 description: feat(cch): add seeds for Claude Code up to 2.1.272 (#1780) conflict: false empty: false
packages/core/src/cgroup-memory.ts 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/cgroup-memory.test.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 packages/gateway/test/ort-platform-package.test.ts packages/core/src/cgroup-memory.ts | 205 +++++++++ packages/core/src/embedding/local.ts | 44 +- packages/core/src/embedding/pool.ts | 18 +- packages/core/src/embedding-cap.ts | 77 ...
63ee4287e8fa794a661519a52a493edf6dba857a33b5da39b33bc0e40d7950da -
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/cgroup-memory.ts</path>
<type>file</type>
<content>
1: import { readFileSync } from "node:fs";
2: import { posix } from "node:path";
3:
4: interface CgroupMembership {
5: version: 1 | 2;
6: path: string;
7: }
8:
9: interface CgroupMemoryFiles {
10: version: 1 | 2;
11: directory: string;
12: mountPoint: string;
13: root: string;
14: }
15:
16: type ReadTextFile = (path: string) => string;
17:
18: function readTextFile(path: string): string {
19: return readFileSync(path, "utf8");
20: }
21:
22: function decodeProcPath(value: string): string | null {
23: const decoded = value.replace(/\\([0-7]{3})/g, (_match, octal: string) =>
24: String.fromCharCode(Number.parseInt(octal, 8)),
25: );
26: if (!decoded.startsWith("/") || decoded.includes("\0")) return null;
27: if (decoded.split("/").includes("..")) return null;
28: return posix.normalize(decoded);
29: }
30:
31: function ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding-cap.ts</path> <type>file</type> <content> 1: /** 2: * Adaptive token-cap math for local ONNX embedding inference. 3: * 4: * Local inference OOMs on long inputs: the O(L²) attention tensor for a long 5: * sequence blows the WASM heap, and because WASM linear memory never shrinks, 6: * an in-process retry cannot recover. We instead cap the input sequence length 7: * up-front and adapt that cap to the host — start from a memory-aware estimate, 8: * and on each OOM lower the cap ×0.7 and respawn the worker on a fresh heap. 9: * 10: * This module holds the pure, dependency-free math so it can be unit-tested in 11: * isolation. The stateful pieces (persistence, worker lifecycle, telemetry) 12: * live in embedding.ts. 13: */ 14: 15: /** Floor token cap. ...
Found 50 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/local.ts:
Line 3: import { freemem } from "node:os";
Line 4: import { readLinuxCgroupMemoryHeadroomBytes } from "../cgroup-memory";
Line 13: clampFreeToContainerLimit,
Line 14: memoryModelEmbedCap,
Line 87: * The process's cgroup memory LIMIT in bytes (not free-within-limit), or `0` if unconstrained / unknown
Line 88: * / unsupported by the runtime. `process.constrainedMemory()` is libuv-backed (cgroup v1 + v2, no
Line 89: * hard-coded paths) and returns `0` when unconstrained; it is present in both Node (≥18.15) and Bun.
Line 91: export function constrainedMemoryLimit(): number {
Line 93: const fn = (process as { constrainedMemory?: () => number })
Line 94: .constrainedMemory;
Line 99: export function availableMemoryHeadroom(): number | undefined {
Line 109: const constrained = constrainedMemoryLimit();
Line 112: ? ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/local.ts</path>
<type>file</type>
<content>
1: /** Local ONNX embedding worker lifecycle. */
2:
3: import { freemem } from "node:os";
4: import { readLinuxCgroupMemoryHeadroomBytes } from "../cgroup-memory";
5: import { db } from "../db";
6: import * as log from "../log";
7: import { vendorModelInfo } from "../embedding-vendor";
8: import { nativeIntraOpThreads } from "../ort-native";
9: import {
10: MIN_EMBED_TOKENS,
11: MODEL_MAX_TOKENS,
12: backoffEmbedCap,
13: clampFreeToContainerLimit,
14: memoryModelEmbedCap,
15: reconcileEmbedCap,
16: reprobeEmbedCap,
17: resolveMemoryHeadroom,
18: shouldReprobeEmbedCap,
19: type PersistedEmbedCap,
20: } from "../embedding-cap";
21: import {
22: EMBED_OOM_EXIT_CODE,
23: isMissingLocalStackError,
24: isWasmFatalError,
25: type EmbedRequest,
26: type WorkerInbound,
27: type WorkerOutbound,
28: type WorkerInitData,
29: } from ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/local.ts</path>
<type>file</type>
<content>
500: worker: import("node:worker_threads").Worker,
501: ): void {
502: drainEmbeddingWorkerStream(worker.stdout, "stdout");
503: drainEmbeddingWorkerStream(worker.stderr, "stderr");
504: }
505:
506: /** True iff the local provider has been probed and found broken. */
507: export function localProviderKnownUnavailable(): boolean {
508: return localEmbeddingState.failureCause !== null;
509: }
510:
511: /** Local embedding provider using @huggingface/transformers with nomic-embed-text-v1.5 by default. */
512: export class LocalProvider implements EmbeddingProvider {
513: // With inference off the main thread, large batches no longer block
514: // the event loop. 256 maximises throughput per round-trip to the
515: // worker. ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/local.ts</path>
<type>file</type>
<content>
1120: error instanceof Error
1121: ? error.message
1122: : "embedding worker died during WASM resubmit";
1123: this.handleInitError(errorMsg);
1124: return;
1125: }
1126: }
1127: this.updateWorkerRef();
1128: }
1129:
1130: private trackRetiredWorkerTermination(worker: ShutdownableWorker): void {
1131: void this.retiredWorkers.retireOnce(worker, async () => {
1132: await worker.terminate();
1133: });
1134: }
1135:
1136: private async settleRetiredWorkers(timeoutMs: number): Promise<void> {
1137: await this.retiredWorkers.settle({
1138: timeoutMs,
1139: timeoutMessage:
1140: "retired embedding worker did not settle before shutdown deadline",
1141: failureMessage: "embedding worker termination was not confirmed",
1142: });
1143: }
1144:
1145: ...
Found 39 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/pool.ts:
Line 4: import { freemem } from "node:os";
Line 18: LocalProviderUnavailableError,
Line 23: LocalProvider,
Line 25: clearLocalProviderLatch,
Line 82: provider: LocalProvider;
Line 158: class EmbeddingWorkerRetryCooldownError extends LocalProviderUnavailableError {
Line 169: * A pool of {@link LocalProvider} workers so concurrent embeds run in parallel instead of serializing
Line 177: private readonly ceiling: number;
Line 179: private readonly retiredWorkers = new OwnedRetirements<LocalProvider>();
Line 197: // Deterministic test override — bypass the memory gate entirely.
Line 198: this.ceiling = Math.max(
Line 204: // honor an explicit config/env ceiling (clamped like the prod branch),
Line 206: this.ceiling = Math.max(
Line 211: this.ceiling = Math.min(
Line 226: throw new ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/pool.ts</path>
<type>file</type>
<content>
1: /** Host-owned queue and pool for local embedding workers. */
2:
3: import { createHash } from "node:crypto";
4: import { freemem } from "node:os";
5: import { config } from "../config";
6: import * as log from "../log";
7: import {
8: DEFAULT_MAX_EMBED_POOL,
9: EMBED_POOL_ABS_MAX,
10: PER_WORKER_MEM_BUDGET_BYTES,
11: clampFreeToContainerLimit,
12: } from "../embedding-cap";
13: import {
14: EmbeddingQueueCapacityError,
15: EmbeddingRequestAbortedError,
16: EmbeddingWorkerWatchdogError,
17: type EmbeddingProvider,
18: LocalProviderUnavailableError,
19: WORKER_SHUTDOWN_TIMEOUT_MS,
20: isRecallEmbed,
21: } from "./contract";
22: import {
23: LocalProvider,
24: availableMemoryHeadroom,
25: clearLocalProviderLatch,
26: constrainedMemoryLimit,
27: localEmbeddingState,
28: } from "./local";
29: import { OwnedRetirements } from ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/pool.ts</path>
<type>file</type>
<content>
500:
501: private pruneTokenBatchCheckpoints(now = Date.now()): void {
502: const retained = [...this.tokenBatchCheckpoints.entries()]
503: .filter(([, checkpoint]) => {
504: if (now - checkpoint.updatedAt <= COMPLETED_EMBED_REUSE_MS) return true;
505: checkpoint.vectors = [];
506: return false;
507: })
508: .sort((a, b) => a[1].updatedAt - b[1].updatedAt);
509: this.tokenBatchCheckpoints.clear();
510: for (const [key, checkpoint] of retained.slice(
511: -MAX_COMPLETED_EMBED_RESULTS,
512: )) {
513: this.tokenBatchCheckpoints.set(key, checkpoint);
514: }
515: for (const [, checkpoint] of retained.slice(
516: 0,
517: -MAX_COMPLETED_EMBED_RESULTS,
518: )) {
519: checkpoint.vectors = [];
520: }
521: }
522:
523: /** Consume one interrupted call's successful ...
Added regular file packages/core/src/cgroup-memory.ts:
1: import { readFileSync } from "node:fs";
2: import { posix } from "node:path";
3:
4: interface CgroupMembership {
5: version: 1 | 2;
6: path: string;
7: }
8:
9: interface CgroupMemoryFiles {
10: version: 1 | 2;
11: directory: string;
12: mountPoint: string;
13: root: string;
14: }
15:
16: type ReadTextFile = (path: string) => string;
17:
18: function readTextFile(path: string): string {
19: return readFileSync(path, "utf8");
20: }
21:
22: function decodeProcPath(value: string): string | null {
23: const decoded = value.replace(/\\([0-7]{3})/g, (_match, octal: string) =>
24: String.fromCharCode(Number.parseInt(octal, 8)),
25: );
26: if (!decoded.startsWith("/") || decoded.includes("\0")) return null;
27: ...
Date: Sep 16, 2026 * 🟡 (13:27) Added regular file `packages/core/src/cgroup-memory.ts`; it imports `readFileSync` from `node:fs` and `posix` from `node:path`, defines `CgroupMembership` (`version: 1 | 2`, `path`), `CgroupMemoryFiles` (`version: 1 | 2`, `directory`, `mountPoint`, `root`), `ReadTextFile`, `readTextFile(path)`, and `decodeProcPath(value)`. * 🔴 (13:27) User requires available-memor…
Date: Sep 16, 2026 * 🔴 (13:25) User specified worker-entrypoint runtime handling in `packages/core/src/embedding/local.ts`: CommonJS uses `__filename` because it is always defined there; ESM uses `import.meta.url`, with the bundle shim keeping the source natural. * 🔴 (13:25) User stated the deterministic fake-worker seam in `packages/core/src/embedding/local.ts` is for tests and is never set in…
Date: Sep 16, 2026 * 🟡 (13:24) `packages/core/package.json` defines `@loreai/core` version `0.40.0`, type `module`, license `FSL-1.1-Apache-2.0`, description “Shared memory engine for Lore — three-tier storage, distillation, gradient context management,” public npm access, author `BYK`, and repository `git+https://github.com/BYK/loreai.git` under `packages/core`. * 🟡 (13:24) `@loreai/core` expo…
Date: Sep 16, 2026 * 🔴 (13:23) User’s Jujutsu workflow states that `jj` never fails on conflict; `rebase`/`new`/`squash` records conflicts in the resulting commit, after which `jj st` must be checked and files resolved manually rather than with interactive `jj resolve`. * 🔴 (13:23) User requires `jj` rather than `git` for mutations when `.jj/` exists; `/home/byk/Code/opencode-lore-embedding-run…
Date: Sep 16, 2026 * 🔴 [requested-review] (13:22) User requested a read-only adversarial correctness review of ONLY the embedding memory admission/cgroup slice in `/home/byk/Code/opencode-lore-embedding-runtime` at current Jujutsu change `tmzmtlss`. * 🔴 (13:22) User constrained the review: inspect actual current source; do not edit files, mutate VCS, use the network, or run production services.…