Dashboardopencode-loreSession 1AOzfqgyme4v

Session 1AOzfqgyme4v

Full ID: 1AOzfqgyme4vpnLY4
Messages: 63
Distillations: 6
Time range: 2026-09-16 23:45:41 — 2026-09-17 00:27:09

Conversation (63 messages)

Read-only focused code audit in /home/byk/Code/opencode-lore-embedding-runtime. Do not edit files or mutate VCS. Inspect current working-copy changes for native ONNX Runtime selection and native-to-WASM fallback only: packages/core/src/ort-native.ts, embedding-worker.ts, embedding-worker-types.ts, packages/gateway/script/bundle.ts, ort-platform-package.ts and relevant tests. Identify concrete correctness/security defects, unnecessary complexity, fallback loops, package-resolution boundary mistakes, platform/ABI mistakes, privacy leaks, and missing tests. Required invariants: native is preferred for SEA/vendor, development, tests, and supported npm targets; npm dist can fall back to single-thread WASM; missing or malformed native packages never throw; undeclared ancestor packages never resolve; vendored models are never purged/downloaded; fallback posts no free-form native error; unrelated missing files are never classified as a missing ML stack. Cite exact file:line and return concise PASS/CONCERN/MUST-FIX findings. Do not run full test suite, network, or any service. You may run focused read-only tests if needed. This is preliminary review, not final immutable-candidate review.

gateway · 2026-09-16 23:45:41
result
<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`. ...
gateway · 2026-09-16 23:46:51
result
<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>
gateway · 2026-09-16 23:46:54
result
<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. ...
gateway · 2026-09-16 23:46:58
result
<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. ...
gateway · 2026-09-16 23:50:43
result
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-wasm-fallback.test.ts
M packages/core/test/embedding-worker-stdio.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 8888d203 fix/embedding-runtime-admission | fix(core): correct embedding runtime ...
gateway · 2026-09-16 23:50:54
result
diff --git a/packages/core/src/embedding-worker-types.ts b/packages/core/src/embedding-worker-types.ts
index 143f0d4fde..391e219dc7 100644
--- a/packages/core/src/embedding-worker-types.ts
+++ b/packages/core/src/embedding-worker-types.ts
@@ -99,8 +99,6 @@
  */
 export interface InitNeedsWasm {
   type: "init-needs-wasm";
-  /** The underlying native model-load error, for diagnostics. */
-  error: string;
 }
 
 export type WorkerOutbound =
@@ -223,6 +221,18 @@
   return /@huggingface\/transformers|onnxruntime|\bsharp\b/i.test(msg);
 }
 
+/** Detect a selected native ONNX Runtime addon that could not be loaded. */
+export function isNativeOrtLoadError(msg: string): boolean {
+  const nativeRuntime =
+    /onnxruntime_binding\.node|libonnxruntime(?:_providers_[\w-]+)?\.(?:so(?:\.\d+)*|dylib|dll)|\bOrtGetApiBase\b/i.test(
+      msg,
+    );
+  if (!nativeRuntime) return false;
+  return /ERR_DLOPEN_FAILED|invalid (?:ELF|Mach-O|Win32)|file too short|cannot open shared object file|image ...
gateway · 2026-09-16 23:51:17
result
diff --git a/packages/core/test/embedding-wasm-fallback.test.ts b/packages/core/test/embedding-wasm-fallback.test.ts
index fe95b8538b..3c7de4b224 100644
--- a/packages/core/test/embedding-wasm-fallback.test.ts
+++ b/packages/core/test/embedding-wasm-fallback.test.ts
@@ -17,6 +17,7 @@
 } from "../src/embedding";
 import { EMBED_OOM_EXIT_CODE } from "../src/embedding-worker-types";
 import type { WorkerInitData } from "../src/embedding-worker-types";
+import { registerSink } from "../src/log";
 
 // Exercises the native→WASM fallback lifecycle in LocalProvider (#1379): when a
 // native worker reports `init-needs-wasm` (it loaded the ONNX addon but couldn't
@@ -27,6 +28,13 @@
 
 type EmbedMsg = { type: string; id: number; maxTokens: number };
 
+const NOOP_LOG_SINK = {
+  info() {},
+  warn() {},
+  error() {},
+  captureException() {},
+};
+
 class FakeWorker extends EventEmitter {
   readonly posted: EmbedMsg[] = [];
   terminated = false;
@@ -97,6 +105,7 @@
   });
 
   afterEach(() ...
gateway · 2026-09-16 23:51:37
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/ort-native.ts</path>
<type>file</type>
<content>
1: /**
2:  * Runtime resolution of the native ONNX Runtime addon shipped as a per-platform
3:  * npm package (`@loreai/onnxruntime-<os>-<arch>`), the esbuild distribution
4:  * model. See `packages/gateway/script/ort-platform-package.ts` for the build /
5:  * publish side — the package name computed here MUST match the names published
6:  * there (both are pinned to the literal `@loreai/onnxruntime-<os>-<arch>` shape
7:  * by tests on each side).
8:  *
9:  * The npm gateway worker bundle uses this to prefer native ONNX Runtime over the
10:  * bundled WASM fallback. Published packages resolve the platform package that
11:  * npm installed through `optionalDependencies`; source workspaces resolve the
12:  * gateway's direct `onnxruntime-node` dependency. Both routes are npm-12-safe
13:  * and require no postinstall download. ...
gateway · 2026-09-16 23:51:45
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding-worker.ts</path>
<type>file</type>
<content>
1: /**
2:  * Embedding worker thread — runs ONNX inference via @huggingface/transformers
3:  * off the main thread.
4:  *
5:  * This file is the entry point for a `node:worker_threads` Worker spawned by
6:  * `LocalProvider` in `embedding.ts`. It owns the transformers.js pipeline
7:  * and processes embed requests sequentially from a priority queue. Moving
8:  * inference here keeps the main thread's event loop free — HTTP requests,
9:  * SSE streams, and session APIs are no longer blocked during embedding.
10:  *
11:  * Communication uses `parentPort` message passing with structured clone.
12:  * Float32Array vectors are sent back directly (Bun preserves identity).
13:  *
14:  * The worker applies Nomic's recommended post-processing:
15:  *   1. Mean pooling (via pipeline option)
16:  *   2. Layer normalization
17:  *   3. ...
gateway · 2026-09-16 23:51:55
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding-worker.ts</path>
<type>file</type>
<content>
498: /**
499:  * Delete the cached model directory for `modelId` so transformers.js re-downloads
500:  * it on the next pipeline() call. Used to recover from a corrupt / truncated
501:  * download. Returns true if a cache directory was found and removed (i.e. a retry
502:  * is worthwhile), false otherwise (nothing to purge → retrying would be futile).
503:  *
504:  * Only safe in npm mode: the HF cache lives under `env.cacheDir` and the model
505:  * resolves to `<cacheDir>/<modelId>/`. Never called for vendored binaries.
506:  */
507: async function purgeCachedModel(): Promise<boolean> {
508:   try {
509:     const { env } = await import("@huggingface/transformers");
510:     const cacheDir = (env as { cacheDir?: string }).cacheDir;
511:     const modelDir = resolveModelCacheDir(cacheDir, modelId);
512:     if (!modelDir) return false;
513:     const { rm, ...
gateway · 2026-09-16 23:52:03
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding-worker-types.ts</path>
<type>file</type>
<content>
1: /**
2:  * Shared message types for the embedding worker thread.
3:  *
4:  * The embedding worker (`embedding-worker.ts`) runs ONNX inference via
5:  * `@huggingface/transformers` in a separate `node:worker_threads` Worker
6:  * so the main thread's event loop stays free during inference. This file
7:  * defines the message protocol between the main thread (`LocalProvider`
8:  * in `embedding.ts`) and the worker.
9:  *
10:  * Imported by both sides — keep this file free of runtime dependencies.
11:  */
12: 
13: // ---------------------------------------------------------------------------
14: // Main thread → Worker
15: // ---------------------------------------------------------------------------
16: 
17: /** Request an embedding batch. */
18: export interface EmbedRequest {
19:   type: "embed";
20:   /** Monotonic request ID for correlating responses. ...
gateway · 2026-09-16 23:52:16
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/script/bundle.ts</path>
<type>file</type>
<content>
1: /**
2:  * Bundle @loreai/gateway into a self-contained CJS package for npm/npx.
3:  *
4:  * Produces:
5:  *   dist/index.cjs — single CJS bundle (gateway + core + all JS deps)
6:  *   dist/bin.cjs   — thin CLI wrapper with Node.js version check
7:  *
8:  * Everything is bundled except:
9:  *   - node:* built-ins (resolved at runtime)
10:  *
11:  * Source code is pure Node.js — no `Bun.*` polyfill layer is needed.
12:  * (xxHash64 lives in src/xxhash.ts as a standalone module since there is
13:  * no Node.js equivalent of `Bun.hash.xxHash64`.)
14:  *
15:  * Debug IDs are injected into the JS + sourcemap after bundling for Sentry
16:  * source map resolution. When SENTRY_AUTH_TOKEN is set, sourcemaps are
17:  * uploaded to Sentry and then deleted (they shouldn't ship to users). ...
gateway · 2026-09-16 23:52:33
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/script/ort-platform-package.ts</path>
<type>file</type>
<content>
1: /**
2:  * Generate per-platform npm packages that carry the native `onnxruntime-node`
3:  * addon + its shared libraries — the esbuild distribution model (see
4:  * `@esbuild/<os>-<arch>`), replicated for ONNX Runtime.
5:  *
6:  * WHY: the `@loreai/gateway` npm bundle ships a self-contained WASM ONNX runtime
7:  * so that dist-only installs (AUR, vendored `dist/`) work with zero
8:  * `node_modules` (#763). But WASM is single-threaded and 2.7–4.1× slower than
9:  * native (#999), and every normal `npm i` / plugin install DOES have a
10:  * `node_modules`. We can't just depend on `onnxruntime-node` directly: its
11:  * native binary arrives via a **postinstall download** from GitHub releases,
12:  * which npm 12 will stop running automatically and which fails in offline / air-
13:  * gapped / proxied installs. ...
gateway · 2026-09-16 23:52:55
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/package.json</path>
<type>file</type>
<content>
1: {
2:   "name": "@loreai/gateway",
3:   "version": "0.40.0",
4:   "type": "module",
5:   "license": "FSL-1.1-Apache-2.0",
6:   "description": "Lore as a transparent LLM proxy — context management for any AI coding client",
7:   "main": "./dist/index.cjs",
8:   "types": "./dist/index.d.cts",
9:   "exports": {
10:     ".": {
11:       "types": "./dist/index.d.cts",
12:       "bun": "./dist/index.bun.js",
13:       "require": "./dist/index.cjs",
14:       "default": "./dist/index.cjs"
15:     }
16:   },
17:   "bin": {
18:     "lore": "./dist/bin.cjs",
19:     "lore-gateway": "./dist/bin.cjs"
20:   },
21:   "scripts": {
22:     "typecheck": "tsc --noEmit",
23:     "build": "tsx script/build.ts",
24:     "bundle": "tsx script/bundle.ts",
25:     "build:binary": "tsx script/build.ts --binary",
26:     "build:binary:sea": "tsx script/build-binary-sea.ts",
27:     "start": ...
gateway · 2026-09-16 23:53:01
result
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/script/ort-npm-plugin.ts:
  Line 3:  * Runtime backends and pick at runtime — native `onnxruntime-node` when the

  Line 4:  * per-platform `@loreai/onnxruntime-<os>-<arch>` package is installed, else the

  Line 5:  * bundled WASM `onnxruntime-web` (the dist-only fallback, #763).

  Line 7:  * How: the bundled `onnxruntime-node` specifier is replaced with a tiny runtime

  Line 8:  * SHIM that re-exports either the real native module or onnxruntime-web based on

  Line 17:  * `import * as ONNX_NODE from 'onnxruntime-node'` eagerly, and onnxruntime-node's

  Line 19:  * in the real onnxruntime-node when the addon path is set, so binding.js never

  Line 24:  *   2. `onnxruntime-node` → runtime shim (native-or-web).

  Line 25:  *   3. `onnxruntime-web` → its Node WASM entry (for transformers' own — unused

  Line 27:  *   4. Patch the real onnxruntime-node binding.js addon ...
gateway · 2026-09-16 23:53:13
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/script/ort-npm-plugin.ts</path>
<type>file</type>
<content>
1: /**
2:  * esbuild plugin for the npm gateway's embedding-worker bundles: ship BOTH ONNX
3:  * Runtime backends and pick at runtime — native `onnxruntime-node` when the
4:  * per-platform `@loreai/onnxruntime-<os>-<arch>` package is installed, else the
5:  * bundled WASM `onnxruntime-web` (the dist-only fallback, #763).
6:  *
7:  * How: the bundled `onnxruntime-node` specifier is replaced with a tiny runtime
8:  * SHIM that re-exports either the real native module or onnxruntime-web based on
9:  * `globalThis.__LORE_ORT_BINDING_PATH__` (set by the worker before it imports
10:  * transformers). This matters because transformers.js selects its backend as:
11:  *   Symbol.for('onnxruntime') override → else IS_NODE_ENV → ONNX_NODE → else web
12:  * Only the IS_NODE_ENV branch registers the "cpu" device, and it uses ONNX_NODE. ...
gateway · 2026-09-16 23:53:44
result
Found 31 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding-worker.ts:
  Line 46: // WorkerInitData.forceWasm). Set by the main thread only when respawning after a

  Line 47: // native worker posted `init-needs-wasm` (#1379). Default false = prefer native.

  Line 48: const forceWasm = init.forceWasm ?? false;

  Line 49: // Snapshot of the host's stderr-silence state (see WorkerInitData). When true,

  Line 50: // every diagnostic below stays off stderr so it can't corrupt the host's TUI.

  Line 51: const stderrSilenced = init.stderrSilenced ?? false;

  Line 184:  *  a model-parse failure warrants an `init-needs-wasm` respawn (#1379). */

  Line 234:           if (!stderrSilenced) {

  Line 237:           post({ type: "init-needs-wasm" });

  Line 256:           // Gate diagnostics on the host's stderr-silence flag (see

  Line 276:               // through its logger rather than inherited process stdout.

  Line 277:               if ...
gateway · 2026-09-16 23:53:54
result
Found 29 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding-worker.ts:
  Line 46: // WorkerInitData.forceWasm). Set by the main thread only when respawning after a

  Line 47: // native worker posted `init-needs-wasm` (#1379). Default false = prefer native.

  Line 48: const forceWasm = init.forceWasm ?? false;

  Line 184:  *  a model-parse failure warrants an `init-needs-wasm` respawn (#1379). */

  Line 237:           post({ type: "init-needs-wasm" });

  Line 280:               post({ type: "init-needs-wasm" });

  Line 384:       // forceWasm (#1379): a prior native worker loaded the addon but couldn't

  Line 389:       const nativePath = forceWasm

  Line 407:   // forceWasm). Every other path — dev/test (real onnxruntime-node), the SEA

  Line 410:   // This drives the init-needs-wasm respawn decision in ensurePipeline (#1379). ...
gateway · 2026-09-16 23:53:58
result
<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 ...
gateway · 2026-09-16 23:54:03
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/local.ts</path>
<type>file</type>
<content>
360:   log.info(
361:     "self-heal: re-probing a previously-latched local embedding provider " +
362:       "(a fresh worker retries init on the next embed; re-latches if it fails again)",
363:   );
364:   return true;
365: }
366: 
367: type EmbeddingWorkerSpawnOptions =
368:   import("node:worker_threads").WorkerOptions & {
369:     /** Virtual filename used by the SEA eval worker's CJS require shim. */
370:     filename?: string;
371:   };
372: 
373: let testWorkerFactory:
374:   | ((
375:       data: WorkerInitData,
376:       entrypoint: string | URL,
377:       options: EmbeddingWorkerSpawnOptions,
378:     ) => import("node:worker_threads").Worker)
379:   | null = null;
380: 
381: /** For tests: install the worker factory seam above (null clears it). ...
gateway · 2026-09-16 23:54:09
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/local.ts</path>
<type>file</type>
<content>
730:         // Any other non-zero exit is a genuine fatal crash — latch the
731:         // provider broken so future ensureWorker() calls fast-fail instead of
732:         // respawning a worker that will just crash again (event-storm guard).
733:         if (code !== 0 && !workerErrorHandled && !this.closing) {
734:           if (!this.workerInitError) {
735:             this.workerInitError = `embedding worker exited with code ${code}`;
736:             log.error(this.workerInitError, new Error(this.workerInitError));
737:           }
738:           latchLocalProvider("terminal");
739:         }
740:         for (const [, p] of this.pendingRequests) {
741:           p.reject(
742:             new LocalProviderUnavailableError(
743:               this.workerInitError ?? ...
gateway · 2026-09-16 23:55:02
result
{"runtime":"node","report":"function","glibc":"2.39"}
{"runtime":"bun","report":"function","glibc":"2.39"}
gateway · 2026-09-16 23:55:24
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/script/vendor-ort-native.ts</path>
<type>file</type>
<content>
60: 
61: /** The SEA asset key for one of a target's native files. `native-loader.cjs`
62:  *  recomputes the same key from `process.platform`/`process.arch` at runtime,
63:  *  so keep the two in sync. Filenames are flat (no path separators) so a simple
64:  *  `ort-<target>-<file>` key is unambiguous. */
65: export function ortAssetKey(target: VendorTarget, file: string): string {
66:   return `ort-${target}-${file}`;
67: }
68: 
69: /** Resolve onnxruntime-node's package root (it's a transitive dep via
70:  *  @huggingface/transformers, and a devDependency of the gateway/core). */
71: function ortNodeDir(): string {
72:   const pjPath = require.resolve("onnxruntime-node/package.json", {
73:     paths: [packageDir, join(repoRoot, "packages/core")],
74:   });
75:   return dirname(pjPath);
76: }
77: 
78: /** onnxruntime-node's resolved version (keeps ...
gateway · 2026-09-16 23:59:48
result
No files found
gateway · 2026-09-17 00:00:00
result
No files found
gateway · 2026-09-17 00:00:09
result
File not found: /home/byk/Code/opencode-lore-embedding-runtime/node_modules/onnxruntime-node
gateway · 2026-09-17 00:00:22
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules/onnxruntime-node</path>
<type>directory</type>
<entries>
bin/
dist/
lib/
package.json
README.md
script/

(6 entries)
</entries>
gateway · 2026-09-17 00:00:47
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules/onnxruntime-node/bin</path>
<type>directory</type>
<entries>
napi-v6/

(1 entries)
</entries>
gateway · 2026-09-17 00:01:01
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules/onnxruntime-node/bin/napi-v6</path>
<type>directory</type>
<entries>
darwin/
linux/
win32/

(3 entries)
</entries>
gateway · 2026-09-17 00:01:12
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules/onnxruntime-node/bin/napi-v6/darwin/arm64</path>
<type>directory</type>
<entries>
libonnxruntime.1.27.0.dylib
libonnxruntime.1.dylib
onnxruntime_binding.node

(3 entries)
</entries>
gateway · 2026-09-17 00:01:23
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules/onnxruntime-node/bin/napi-v6/win32/x64</path>
<type>directory</type>
<entries>
DirectML.dll
dxcompiler.dll
dxil.dll
onnxruntime_binding.node
onnxruntime.dll

(5 entries)
</entries>
gateway · 2026-09-17 00:01:47
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules/onnxruntime-node/bin/napi-v6/linux/arm64</path>
<type>directory</type>
<entries>
libonnxruntime.so.1
onnxruntime_binding.node

(2 entries)
</entries>
gateway · 2026-09-17 00:01:53
result
{"name":"Error","code":"ERR_DLOPEN_FAILED","message":"/home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/onnxruntime_binding.node: cannot open shared object file: No such file or directory"}
gateway · 2026-09-17 00:02:08
result
Found 99 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/cross-project-gating.test.ts:
  Line 6: // Two unrelated real projects. PROJ_A owns a cross-project-marked entry; we


/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/blob-select.test.ts:
  Line 399:       query: "unrelated query",

  Line 507:       query: "SIGNAL unrelated coding objective",

  Line 533:       query: "SIGNAL unrelated coding objective",

  Line 558:       query: "SIGNAL unrelated",

  Line 580:       query: "SIGNAL unrelated",


/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/contradiction.test.ts:
  Line 368:   it("does not judge topically-unrelated pairs (below the similarity floor)", async () => {

  Line 369:     const P = "/test/contra/detect-unrelated";


/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/agents-file.test.ts:
  Line 1992:     // A custom path has no twin → never strips an unrelated file. ...
gateway · 2026-09-17 00:02:16
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-optional-stack.test.ts</path>
<type>file</type>
<content>
1: import { execFileSync } from "node:child_process";
2: import { readFileSync } from "node:fs";
3: import { EventEmitter } from "node:events";
4: import { createRequire } from "node:module";
5: import { fileURLToPath } from "node:url";
6: import type { Worker } from "node:worker_threads";
7: import { afterEach, beforeEach, describe, expect, it, test, vi } from "vitest";
8: import {
9:   computeInitRetryDelayMs,
10:   embed,
11:   isAvailable,
12:   runStartupBackfill,
13:   LocalProviderUnavailableError,
14:   _getLocalInitRetryAtForTest,
15:   _markLocalProviderUnavailable,
16:   _resetLocalProviderProbe,
17:   _restoreProvider,
18:   _saveAndClearProvider,
19:   _setLocalInitCooldownMsForTest,
20:   _setTestWorkerFactory,
21: } from "../src/embedding";
22: import { isMissingLocalStackError } from "../src/embedding-worker-types";
23: import { ...
gateway · 2026-09-17 00:02:37
result
Found 37 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-wasm-fallback.test.ts:
  Line 127:     // First worker spawned WITHOUT forceWasm (prefers native).

  Line 128:     expect(spawns[0].init.forceWasm ?? false).toBe(false);

  Line 138:     // A fresh worker was spawned WITH forceWasm, and the native one terminated.

  Line 140:     expect(spawns[1].init.forceWasm).toBe(true);

  Line 203:   it("keeps forceWasm sticky across a later OOM respawn", async () => {

  Line 216:     expect(spawns[1].init.forceWasm).toBe(true);

  Line 223:     expect(spawns[2].init.forceWasm).toBe(true);

  Line 298:     expect(spawns[1].init.forceWasm).toBe(true);


/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-vendor.test.ts:
  Line 12:   vendorModelInfo,

  Line 19: // LORE_LOCAL_MODEL_PATH (set by CI to point at the vendored model cache) would

  Line 20: // override vendorModelInfo(), so we clear it for the duration of these tests. ...
gateway · 2026-09-17 00:02:43
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-worker-types.test.ts</path>
<type>file</type>
<content>
200:   test("worker inline predicate body matches the canonical function", () => {
201:     // Extract the isTransformersInferenceDumpLine body from each source and
202:     // compare whitespace-normalized (robust to formatting). Guards against the
203:     // matching LOGIC drifting (e.g. startsWith→includes, dropping the typeof
204:     // guard) even when the prefix DATA is unchanged.
205:     const bodyOf = (src: string): string => {
206:       const m = src.match(
207:         /function isTransformersInferenceDumpLine\(arg: unknown\): boolean \{([\s\S]*?)\n\}/,
208:       );
209:       expect(
210:         m,
211:         "isTransformersInferenceDumpLine not found (worker or canonical)",
212:       ).not.toBeNull();
213:       return (m?.[1] ?? "").replace(/\s+/g, " ").trim();
214:     };
215:     const workerBody = bodyOf(workerSrc);
216:     ...
gateway · 2026-09-17 00:02:49
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-worker-types.test.ts</path>
<type>file</type>
<content>
1: import { readFileSync } from "node:fs";
2: import { fileURLToPath } from "node:url";
3: import { describe, expect, test } from "vitest";
4: import {
5:   isOomError,
6:   isWasmFatalError,
7:   isCorruptModelError,
8:   isNativeOrtLoadError,
9:   isTransformersInferenceDumpLine,
10:   looksLikeIntactOnnxFile,
11:   MIN_ONNX_FILE_BYTES,
12:   resolveModelCacheDir,
13:   shouldHealCorruptModel,
14:   shouldPostPerRequestError,
15:   shouldRequestWasmRespawn,
16:   TRANSFORMERS_INFERENCE_DUMP_PREFIXES,
17: } from "../src/embedding-worker-types";
18: 
19: describe("isCorruptModelError", () => {
20:   test("matches the real truncated-download error observed in production", () => {
21:     // The exact message observed when a 137MB model only downloaded ~87MB.
22:     const msg =
23:       "Load model from /home/byk/.../onnx/model_quantized.onnx ...
gateway · 2026-09-17 00:02:55
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/ort-native.test.ts</path>
<type>file</type>
<content>
1: import {
2:   mkdirSync,
3:   mkdtempSync,
4:   realpathSync,
5:   rmSync,
6:   symlinkSync,
7:   writeFileSync,
8: } from "node:fs";
9: import { tmpdir } from "node:os";
10: import { dirname, join } from "node:path";
11: import { describe, expect, test } from "vitest";
12: import {
13:   ORT_NATIVE_BINDING_FILE,
14:   ORT_NATIVE_TARGETS,
15:   type NativeOrtRuntime,
16:   nativeIntraOpThreads,
17:   ortNativePackageName,
18:   ortPlatformTarget,
19:   resolveNativeOrtBindingPath,
20: } from "../src/ort-native";
21: 
22: const ORT_VERSION = "1.27.0";
23: const GATEWAY_VERSION = "9.9.9";
24: const LINUX_RUNTIME: NativeOrtRuntime = {
25:   platform: "linux",
26:   arch: "x64",
27:   glibcVersionRuntime: "2.39",
28: };
29: 
30: function writeJson(path: string, value: unknown): void {
31:   mkdirSync(dirname(path), { recursive: true });
32:   writeFileSync(path, ...
gateway · 2026-09-17 00:03:17
result
<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": ...
gateway · 2026-09-17 00:03:24
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/script/build.ts</path>
<type>file</type>
<content>
1: /**
2:  * Build @loreai/core into publishable ESM bundles.
3:  *
4:  * Two targets:
5:  * - dist/node/index.js — uses node:sqlite (for Pi extension, ACP server, etc.)
6:  * - dist/bun/index.js  — uses bun:sqlite  (for OpenCode plugin)
7:  *
8:  * esbuild resolves the `#db/driver` subpath import map per target via
9:  * `conditions: ["node"]` or `conditions: ["bun"]`.
10:  *
11:  * TypeScript declarations (.d.ts) are emitted separately by `tsc` below.
12:  * esbuild alone can't produce declarations.
13:  *
14:  * The build runs under Node (via tsx, e.g. `pnpm run build`) — it does not
15:  * require the Bun runtime. esbuild is a plain npm package, so the build is
16:  * runtime-agnostic; the dist/bun target is produced via esbuild's
17:  * `conditions: ["bun"]`, not by running under Bun. ...
gateway · 2026-09-17 00:03:42
result
Found 12 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/ort-native.ts:
  Line 201: export function resolveNativeOrtBindingPath(

  Line 312: export function nativeIntraOpThreads(


/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding-worker.ts:
  Line 66:  * `nativeIntraOpThreads()` and passed in — the worker runs as raw .ts and can't

  Line 67:  * value-import `ort-native` (see the classifier note below). Applied on the

  Line 391:         : (await import("./ort-native")).resolveNativeOrtBindingPath(

  Line 456:   // (nativeIntraOpThreads() → WorkerInitData.intraOpThreads; the worker runs as

  Line 457:   // raw .ts and can't value-import ort-native — see maxTokens above), a strict


/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding-worker-types.ts:
  Line 457:    *  via `nativeIntraOpThreads()` (the worker runs as raw .ts and can't

  Line 458:    *  value-import `ort-native` — same constraint as the ...
gateway · 2026-09-17 00:04:53
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules/onnxruntime-node/bin/napi-v6/linux/x64</path>
<type>directory</type>
<entries>
libonnxruntime_providers_cuda.so
libonnxruntime_providers_shared.so
libonnxruntime_providers_tensorrt.so
libonnxruntime.so.1
onnxruntime_binding.node

(5 entries)
</entries>
gateway · 2026-09-17 00:05:03
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/script/pack-ort-npm.ts</path>
<type>file</type>
<content>
1: /**
2:  * Release packaging for the per-platform native ONNX Runtime packages
3:  * (`@loreai/onnxruntime-<os>-<arch>`) + wiring them into the gateway tarball as
4:  * `optionalDependencies`. Run by CI's "Pack tarballs" step on release branches,
5:  * AFTER the workspace tarballs are packed. See ort-platform-package.ts (the
6:  * esbuild-style per-platform model) and ort-npm-plugin.ts (the runtime that
7:  * prefers them over WASM).
8:  *
9:  * Steps, all at the release version (CRAFT_NEW_VERSION):
10:  *   1. Generate the per-platform packages and `npm pack` each into the tarball dir
11:  *      → `loreai-onnxruntime-<target>-<version>.tgz` (Craft publishes them via a
12:  *      dedicated npm target keyed on that name).
13:  *   2. ...
gateway · 2026-09-17 00:05:21
result
diff --git a/packages/core/src/embedding/local.ts b/packages/core/src/embedding/local.ts
index 5c5e7e600f..32f4307b4d 100644
--- a/packages/core/src/embedding/local.ts
+++ b/packages/core/src/embedding/local.ts
@@ -1,6 +1,7 @@
 /** Local ONNX embedding worker lifecycle. */
 
 import { freemem } from "node:os";
+import { readLinuxCgroupMemoryHeadroomBytes } from "../cgroup-memory";
 import { db } from "../db";
 import * as log from "../log";
 import { vendorModelInfo } from "../embedding-vendor";
@@ -13,6 +14,7 @@
   memoryModelEmbedCap,
   reconcileEmbedCap,
   reprobeEmbedCap,
+  resolveMemoryHeadroom,
   shouldReprobeEmbedCap,
   type PersistedEmbedCap,
 } from "../embedding-cap";
@@ -76,6 +78,11 @@
   testHostFreememBytes = bytes;
 }
 
+let testAvailableMemoryBytes: number | null = null;
+export function _setAvailableMemoryForTest(bytes: number | null): void {
+  testAvailableMemoryBytes = bytes;
+}
+
 /**
  * The process's cgroup memory LIMIT in bytes (not free-within-limit), or ...
gateway · 2026-09-17 00:05:45
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-worker-stdio.test.ts</path>
<type>file</type>
<content>
1: import { EventEmitter, once } from "node:events";
2: import { PassThrough } from "node:stream";
3: import type { Worker, WorkerOptions } from "node:worker_threads";
4: import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5: import {
6:   embed,
7:   _resetLocalProviderProbe,
8:   _restoreProvider,
9:   _saveAndClearProvider,
10:   _setTestWorkerFactory,
11: } from "../src/embedding";
12: import { isStderrSilenced, registerSink, silenceStderr } from "../src/log";
13: 
14: const NOOP_LOG_SINK = {
15:   info() {},
16:   warn() {},
17:   error() {},
18:   captureException() {},
19: };
20: 
21: type EmbedMessage = { type: string; id?: number };
22: 
23: class OutputWorker extends EventEmitter {
24:   readonly stdout = new PassThrough({ highWaterMark: 64 });
25:   readonly stderr = new PassThrough({ highWaterMark: 64 });
26: 
27:   ...
gateway · 2026-09-17 00:06:10
result
Found 1 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-shutdown.test.ts:
  Line 5:  * single-threaded ONNX batch and never emit "exit", which used to hang process
gateway · 2026-09-17 00:06:40
result
Version symbols section '.gnu.version' contains 471 entries:
 Addr: 0x000000000000a5a0  Offset: 0x0000a5a0  Link: 3 (.dynsym)
  000:   0 (*local*)       2 (GLIBCXX_3.4)   1 (*global*)      1 (*global*)   
  004:   3 (CXXABI_1.3.5)   2 (GLIBCXX_3.4)   2 (GLIBCXX_3.4)   1 (*global*)   
  008:   1 (*global*)      1 (*global*)      1 (*global*)      4 (GLIBCXX_3.4.21) 
  00c:   1 (*global*)      2 (GLIBCXX_3.4)   5 (GLIBCXX_3.4.11)    4 (GLIBCXX_3.4.21) 
  010:   4 (GLIBCXX_3.4.21)    2 (GLIBCXX_3.4)   1 (*global*)      1 (*global*)   
  014:   2 (GLIBCXX_3.4)   2 (GLIBCXX_3.4)   1 (*global*)      6 (CXXABI_1.3) 
  018:   4 (GLIBCXX_3.4.21)    7 (GLIBC_2.2.5)   7 (GLIBC_2.2.5)   7 (GLIBC_2.2.5)
  01c:   1 (*global*)      6 (CXXABI_1.3)    4 (GLIBCXX_3.4.21)    4 (GLIBCXX_3.4.21) 
  020:   1 (*global*)      2 (GLIBCXX_3.4)   2 (GLIBCXX_3.4)   1 (*global*)   
  024:   8 (CXXABI_1.3.8)   7 (GLIBC_2.2.5)   7 (GLIBC_2.2.5)   8 (CXXABI_1.3.8)
  028:   1 (*global*)      6 (CXXABI_1.3)    9 ...
gateway · 2026-09-17 00:07:45
result
{"unrelatedMissingFile":true,"wrongElfClass":false,"wrongNativeExports":false,"versionedDylib":false,"windowsDll":false}
gateway · 2026-09-17 00:08:18
result
Found 5 matches
/home/byk/Code/opencode-lore-embedding-runtime/.craft.yml:
  Line 48:   # Native ONNX Runtime per-platform packages (@loreai/onnxruntime-<os>-<arch>),

  Line 54:     id: onnxruntime-native

  Line 57:     includeNames: /^loreai-onnxruntime-.*\.tgz$/


/home/byk/Code/opencode-lore-embedding-runtime/.github/workflows/ci.yml:
  Line 498:           # Native ONNX Runtime per-platform packages (@loreai/onnxruntime-<os>-<arch>):


/home/byk/Code/opencode-lore-embedding-runtime/.github/actions/lint/action.yml:
  Line 124:         ort=$(node -p "require('onnxruntime-node/package.json').version" 2>/dev/null || echo "na")
gateway · 2026-09-17 00:08:39
result
Found 3 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/bundle-exports.test.ts:
  Line 190:       expect(content).toContain("loreOrtNodeVersion");

  Line 347:             loreOrtNodeVersion: ortVersion,


/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/ort-platform-package.test.ts:
  Line 84:       expect(pkg.loreOrtNodeVersion).toBe(ortNodeVersion());
gateway · 2026-09-17 00:10:48
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/.github/workflows/ci.yml</path>
<type>file</type>
<content>
470:       #
471:       # We use `pnpm pack` (not `npm pack`) because pnpm automatically rewrites
472:       # `workspace:*` dependency specifiers to the actual version being packed.
473:       # `npm pack` leaves the literal "workspace:*" in the tarball's
474:       # package.json which breaks installs.
475:       #
476:       # We also mirror @loreai/opencode → opencode-lore by repacking with the
477:       # package name swapped. Both tarballs have identical content; the two
478:       # names are published in parallel so existing users keep working.
479:       - name: Pack tarballs
480:         if: startsWith(github.ref, 'refs/heads/release/')
481:         run: |
482:           mkdir -p dist-tarballs
483:           for pkg in packages/core packages/opencode packages/pi packages/gateway; do
484:             echo "Packing $pkg"
485:             (cd "$pkg" && pnpm pack ...
gateway · 2026-09-17 00:12:15
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/ort-platform-package.test.ts</path>
<type>file</type>
<content>
1: import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
2: import { tmpdir } from "node:os";
3: import { join } from "node:path";
4: import { afterAll, describe, expect, test } from "vitest";
5: import {
6:   buildOrtPlatformPackages,
7:   ORT_NPM_PLATFORMS,
8:   ORT_PACKAGE_BINDING_SUBPATH,
9:   ortPackageName,
10:   ortPlatformTarget,
11: } from "../script/ort-platform-package";
12: import { ortNodeVersion } from "../script/vendor-ort-native";
13: import { ORT_NATIVE_TARGETS } from "../../core/src/ort-native";
14: 
15: // The per-platform ORT packages are found at runtime via
16: //   require.resolve(`${ortPackageName(ortPlatformTarget())}/${ORT_PACKAGE_BINDING_SUBPATH}`)
17: // so the (process.platform, process.arch) → package-name derivation MUST match
18: // the names/os/cpu the generator publishes, or a platform silently ...
gateway · 2026-09-17 00:13:36
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules/onnxruntime-node/bin/napi-v6/win32/arm64</path>
<type>directory</type>
<entries>
DirectML.dll
dxcompiler.dll
dxil.dll
onnxruntime_binding.node
onnxruntime.dll

(5 entries)
</entries>
gateway · 2026-09-17 00:14:42
result
(no output)
gateway · 2026-09-17 00:16:21
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/bundle-exports.test.ts</path>
<type>file</type>
<content>
1: /**
2:  * Smoke test for the npm bundle artifacts.
3:  *
4:  * Verifies that:
5:  * - Every file referenced by package.json `files` and `exports` exists
6:  * - The CJS Node bundle uses node:sqlite (not bun:sqlite)
7:  * - @loreai/core is inlined (not externalized) in the Bun bundle (#1027)
8:  *
9:  * These assert on the built `dist/` artifacts. A bundle build runs immediately
10:  * before vitest under `pnpm test` (root `pretest` hook) and `pnpm run
11:  * test:coverage` (its own `bundle &&` chain, used by CI) — but NOT for
12:  * `vitest --watch`, IDE test runners, or a direct `vitest run`. After pulling a
13:  * change to the bundle's inputs (e.g. ...
gateway · 2026-09-17 00:19:34
result
 RUN  v4.1.8 /home/byk/Code/opencode-lore-embedding-runtime


 Test Files  3 passed (3)
      Tests  118 passed (118)
   Start at  00:19:35
   Duration  2.67s (transform 2.22s, setup 2.51s, import 740ms, tests 1.16s, environment 0ms)

gateway · 2026-09-17 00:20:45
result
 RUN  v4.1.8 /home/byk/Code/opencode-lore-embedding-runtime


 Test Files  2 passed (2)
      Tests  11 passed (11)
   Start at  00:20:46
   Duration  2.31s (transform 1.59s, setup 1.31s, import 739ms, tests 1.98s, environment 0ms)

gateway · 2026-09-17 00:21:51
result
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-wasm-fallback.test.ts
M packages/core/test/embedding-worker-stdio.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 8888d203 fix/embedding-runtime-admission | fix(core): correct embedding runtime ...
gateway · 2026-09-17 00:23:20
result
Found 87 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/cache-stability.e2e.test.ts:
  Line 514:     // worker offload, so pinning no longer hinges on embedding-worker readiness.

  Line 569:         // embedding-worker readiness and cosine asymmetry (flaky under load).


/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/bundle-exports.test.ts:
  Line 185:   test.each(["embedding-worker.cjs", "embedding-worker.js"])(

  Line 196:   test.each(["embedding-worker.cjs", "embedding-worker.js"])(

  Line 293:   test.each(["embedding-worker.cjs", "embedding-worker.js"])(


/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/src/server.ts:
  Line 812:   // Wire embedding-worker OOM backoff/latch events to Sentry. Idempotent: the


/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/src/cli/sea-entry.ts:
  Line 12:  *   `globalThis.__LORE_WORKER_SOURCE__` so `embedding.ts` can

  Line 58:   (globalThis as Record<string, ...
gateway · 2026-09-17 00:25:05
result
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-wasm-fallback.test.ts</path>
<type>file</type>
<content>
110:     _setContainerFreeForTest(null);
111:     _setConstrainedMemoryForTest(null);
112:     _resetLocalProviderProbe();
113:     _resetProviderShutdownTrackingForTest();
114:     _restoreProvider(savedProvider);
115:     if (savedVoyage !== undefined) process.env.VOYAGE_API_KEY = savedVoyage;
116:     if (savedOpenAI !== undefined) process.env.OPENAI_API_KEY = savedOpenAI;
117:   });
118: 
119:   it("respawns forcing WASM and re-submits the in-flight request on init-needs-wasm", async () => {
120:     _persistEmbedCap(8192, 0);
121:     const spawns = installFakeWorkers();
122: 
123:     const promise = embed(["hello world"], "query");
124:     await flush();
125: 
126:     expect(spawns).toHaveLength(1);
127:     // First worker spawned WITHOUT forceWasm (prefers native).
128:     expect(spawns[0].init.forceWasm ?? false).toBe(false);
129:     ...
gateway · 2026-09-17 00:27:09

Findings

  • MUST-FIX — fallback availability and backend selection are conflated. embedding-worker.ts:370-403 runs native resolution only when both WASM siblings exist, while embedding-worker.ts:405-412 treats every non-WASM path as native. In development/tests, a native load failure therefore posts init-needs-wasm (:233-240), but forceWasm has no effect without those siblings. The replacement worker repeats the native attempt before the one-shot guard stops it at embedding/local.ts:662-686. Conversely, one missing WASM artifact prevents an otherwise valid npm native package from being selected.

  • MUST-FIX — malformed or ABI-incompatible addons bypass fallback and leak raw diagnostics. ort-native.ts:150-172 checks only four magic bytes, not CPU, ABI, or addon exports. embedding-worker.ts:232 then discards structured error.code; the classifier at embedding-worker-types.ts:224-234 misses real forms such as wrong ELF class, versioned libonnxruntime.1.dylib, unprefixed onnxruntime.dll, and a valid but wrong addon exposing no listSupportedBackends. These cases become raw init-error messages at embedding-worker.ts:322-328, then enter logs and caller errors through embedding/local.ts:922-975. Existing tests cover only plain text and file too short.

  • MUST-FIX — unrelated missing files are classified as a missing ML stack. embedding-worker-types.ts:215-222 searches the whole error for onnxruntime, sharp, or transformers. For example, Cannot find module /tmp/onnxruntime-cache/unrelated.json returns true. A require stack mentioning ONNX has the same problem. embedding/local.ts:925-940 then permanently latches the provider as “not installed.” The negative test at embedding-optional-stack.test.ts:65-72 omits every package-name substring, so it does not protect this invariant.

  • CONCERN — required integration coverage is incomplete.

    • ort-native.test.ts:22-118 hardcodes a positive Linux/x64 fixture; no ...
gpt-5.6-sol · 2026-09-17 00:27:09 · ~757 tokens

Distillations (6)

Gen 0 2026-09-17 02:00:16 · 1563 tokens

Date: Sep 16, 2026 * 🔴 (23:53) `/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/script/ort-npm-plugin.ts` implements npm-runtime backend selection: it prefers native `onnxruntime-node` when the matching `@loreai/onnxruntime-<os>-<arch>` package is installed and otherwise uses bundled `onnxruntime-web` as the dist-only WASM fallback for issue `#763`. * 🔴 (23:53) `/home/byk/Code/o…

Gen 0 2026-09-17 01:53:15 · 1825 tokens

Date: Sep 16, 2026 * 🔴 (23:52) User stated the WASM heap never shrinks: once the first oversized allocation grows the heap, every later attempt inherits it; recovery must respawn the worker with a fresh heap at a lower token cap. * 🔴 (23:52) User stated native ONNX Runtime module/binary error classification is deliberately narrow so an unrelated resolution error, such as a missing model file, i…

Gen 0 2026-09-17 01:33:16 · 111 tokens

Date: Sep 16, 2026 * 🔴 (23:51) User stated embedding execution switched to native ONNX Runtime because it scales with CPU cores. * 🔴 (23:52) User stated the cached-model purge path is never called for vendored binaries; it applies only when the model resolves to `<cacheDir>/<modelId>/`. * 🔴 (23:52) User requires token truncation to never exceed the configured maximum; texts shorter than the co…

Gen 0 2026-09-17 01:02:21 · 593 tokens

Date: Sep 16, 2026 * 🔴 (23:51) User requires the native-to-WASM fallback signal to never log untrusted fields. * 🔴 (23:51) User requires free-form worker diagnostics to never be forwarded to logs or sinks. * 🔴 (23:51) User requires `resolveNativeOrtBindingPath` to return `null` and never throw when the native package is absent. * 🔴 (23:51) User requires native package resolution to return `nu…

Gen 0 2026-09-17 00:45:12 · 1475 tokens

Date: Sep 16, 2026 * 🔴 (23:50) User’s regression-test discipline requires every adversarial-review defect to land a deterministic regression test in the same PR: it must fail on the base branch, pass on the fix, and drive the real precondition rather than an artificially constructed state. * 🔴 (23:50) User’s guard-test standard: deleting the guard must make its test fail; a test that still pass…

Gen 0 2026-09-17 00:30:21 · 968 tokens

Date: Sep 16, 2026 * 🔴 [requested-review] (23:45) User requested a read-only, focused code audit in `/home/byk/Code/opencode-lore-embedding-runtime` of current working-copy changes for native ONNX Runtime selection and native-to-WASM fallback only. * 🔴 (23:45) User directed that the audit must not edit files or mutate VCS. * 🔴 (23:45) Audit scope: `packages/core/src/ort-native.ts`, `embedding-…