Dashboard › opencode-lore › Session 0LnjbITh535W
0LnjbITh535WSWg78Perform a read-only adversarial correctness and security review of ONLY the native ONNX runtime selection/fallback/packaging 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/ort-native.ts, embedding-worker-types.ts native loader classification, embedding-worker.ts fallback boundary, packages/gateway/script/bundle.ts and ort-platform-package.ts, and related ort-native, embedding-worker-types, bundle-exports, ort-platform-package tests. Inspect actual current source. Focus on dependency-scope escapes, symlinks/path containment, target/libc/format validation, malformed addon handling, unrelated error misclassification, one-shot WASM fallback, CJS/Bun ESM parity, and generated artifact freshness. Check regressions exercise real pre-fix conditions. Return substantive PASS/CONCERN/MUST-FIX findings with exact file:line and 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>
<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: ...
No files found
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 ...
<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": ...
<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. ...
<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. ...
<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. ...
Found 26 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 136: function isNativeOrtLoadError(msg: string): boolean {
Line 184: * a model-parse failure warrants an `init-needs-wasm` respawn (#1379). */
Line 233: if (!vendorModel && usedNativeBinding && isNativeOrtLoadError(msg)) {
Line 239: post({ type: "init-needs-wasm", error: msg });
Line 285: post({ type: "init-needs-wasm", error: msg });
Line 389: // forceWasm (#1379): a prior native worker loaded the addon but couldn't
Line 394: const nativePath = forceWasm
Line 412: // forceWasm). ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding-worker.ts</path> <type>file</type> <content> 650: 651: // isOomError and isWasmFatalError are imported from embedding-worker-types.ts 652: // (shared with the main thread to prevent classification drift). 653: 654: // transformers.js' sessionRun() (models.js) wraps `session.run` in a try/catch 655: // that, on ANY inference error, does two console.error() calls before 656: // re-throwing: the error message, and a dump of every input tensor INCLUDING 657: // its `.data` — for us that's `input_ids`/`attention_mask`/`token_type_ids`, 658: // thousands of token IDs (~21K values at the 8192-token cap). A memory-driven 659: // OOM is an EXPECTED, recovered event here (the main thread drives the ×0.7 cap 660: // backoff + fresh-heap respawn), so that dump is pure journal noise, emitted 661: // 1–2× per cold start. It is NOT gated by ORT's logSeverityLevel (it's 662: // transformers.js, not the ORT C++ logger — ...
<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). ...
<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. ...
<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, ...
Found 100 matches (more matches available)
/home/byk/Code/opencode-lore-embedding-runtime/.craft.yml:
Line 51: # gateway's optionalDependencies pin these exact versions; npm's os/cpu gating
Line 52: # installs only the matching one. See ort-platform-package.ts / ort-npm-plugin.ts.
/home/byk/Code/opencode-lore-embedding-runtime/.github/workflows/ci.yml:
Line 499: # pack all 6 and inject them as optionalDependencies into the gateway
/home/byk/Code/opencode-lore-embedding-runtime/.github/actions/lint/copilot-sdk/package-lock.json:
Line 24: "optionalDependencies": {
Line 448: "optionalDependencies": {
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/ort-native.test.ts:
Line 144: "@loreai/onnxruntime-linux-x64",
Line 208: optionalDependencies: {
Line 225: optionalDependencies: {
Line 258: optionalDependencies: {
/home/byk/Code/opencode-lore-embedding-runtime/pnpm-lock.yaml:
Line 139: ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/.craft.yml</path> <type>file</type> <content> 1: minVersion: '2.21.1' 2: changelog: 3: policy: auto 4: versioning: 5: policy: auto 6: # Custom version bump script — bypasses craft's built-in npm-based auto-bumping 7: # which fails on our `workspace:*` deps. See scripts/bump-version.sh for details. 8: preReleaseCommand: bash scripts/bump-version.sh 9: statusProvider: 10: name: github 11: config: 12: contexts: 13: # Must match the check-run names from ci.yml that produce release artifacts. 14: # Update these if you rename the jobs. 15: - "test" 16: - "Generate Release Patches" 17: artifactProvider: 18: name: github 19: config: 20: artifacts: 21: # CI workflow uploads three artifact groups on release branches: 22: # npm-tarball — workspace .tgz files for npm publish 23: # release-binaries — gzipped standalone CLI binaries + checksums 24: # release-patches — ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/.github/workflows/ci.yml</path> <type>file</type> <content> 450: 451: - name: Upload staging artifact 452: if: github.ref == 'refs/heads/main' && github.event_name == 'push' 453: uses: actions/upload-artifact@v7 454: with: 455: name: sea-staging 456: path: packages/gateway/.sea-staging/ 457: # .sea-staging is a dot-prefixed (hidden) directory 458: include-hidden-files: true 459: 460: # ----------------------------------------------------------------- 461: # Release: build all packages + pack tarballs + multi-platform binaries 462: # ----------------------------------------------------------------- 463: - name: Build all packages 464: if: startsWith(github.ref, 'refs/heads/release/') 465: run: pnpm run build 466: 467: # Pack each workspace package into its own tarball. ...
<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. ...
<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 ...
<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>
1030: "enable local embeddings, or set search.embeddings.provider in .lore.json " +
1031: "to a remote provider (voyage/openai) with the matching API key.",
1032: );
1033: }
1034: } else {
1035: // A potentially transient failure (e.g. a model read that raced a
1036: // concurrent writer during a multi-instance restart, momentary memory
1037: // pressure). Retry a FRESH worker after a cooldown rather than disabling
1038: // local embeddings for the whole process lifetime; only give up (latch)
1039: // once the retry budget is exhausted.
1040: localEmbeddingState.initFailures++;
1041: localEmbeddingState.initFailureGeneration++;
1042: if (localEmbeddingState.initFailures >= LOCAL_INIT_MAX_ATTEMPTS) {
1043: latchLocalProvider("transient-init-exhausted");
1044: ...
Found 21 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-worker-types.test.ts:
Line 360: // The request that tripped `init-needs-wasm` is rejected by ensurePipeline
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-wasm-fallback.test.ts:
Line 22: // native worker reports `init-needs-wasm` (it loaded the ONNX addon but couldn't
Line 110: it("respawns forcing WASM and re-submits the in-flight request on init-needs-wasm", async () => {
Line 118: // First worker spawned WITHOUT forceWasm (prefers native).
Line 119: expect(spawns[0].init.forceWasm ?? false).toBe(false);
Line 125: type: "init-needs-wasm",
Line 130: // A fresh worker was spawned WITH forceWasm, and the native one terminated.
Line 132: expect(spawns[1].init.forceWasm).toBe(true);
Line 151: it("keeps forceWasm sticky across a later OOM respawn", async () => {
Line 160: type: "init-needs-wasm",
Line ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-wasm-fallback.test.ts</path>
<type>file</type>
<content>
1: import { afterEach, beforeEach, describe, expect, it } from "vitest";
2: import { EventEmitter } from "node:events";
3: import type { Worker } from "node:worker_threads";
4: import {
5: embed,
6: isAvailable,
7: LocalProviderUnavailableError,
8: _persistEmbedCap,
9: _resetLocalProviderProbe,
10: _resetProviderShutdownTrackingForTest,
11: _restoreProvider,
12: _saveAndClearProvider,
13: _setConstrainedMemoryForTest,
14: _setContainerFreeForTest,
15: _setTestWorkerFactory,
16: shutdownProvider,
17: } from "../src/embedding";
18: import { EMBED_OOM_EXIT_CODE } from "../src/embedding-worker-types";
19: import type { WorkerInitData } from "../src/embedding-worker-types";
20:
21: // Exercises the native→WASM fallback lifecycle in LocalProvider (#1379): when a
22: // native worker reports `init-needs-wasm` (it loaded the ONNX ...
<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. ...
<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 ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/script/vendor-ort-native.ts</path>
<type>file</type>
<content>
1: /**
2: * Vendor the native `onnxruntime-node` runtime for every build target.
3: *
4: * The SEA (fossilize) binary has no `node_modules`, so `onnxruntime-node`'s
5: * `binding.js` — which does `require("../bin/napi-v<N>/<platform>/<arch>/
6: * onnxruntime_binding.node")` — can't find its native addon inside the binary.
7: * Instead we embed the addon + its shared libraries as SEA assets (one set per
8: * target) and extract them at runtime (see `native-loader.cjs`, which sets
9: * `globalThis.__LORE_ORT_BINDING_PATH__`, the path the patched `binding.js`
10: * requires — see `ort-native-plugin.ts`).
11: *
12: * Unlike `sqlite-vec` (whose per-platform binaries live in separate npm
13: * packages), `onnxruntime-node` ships EVERY platform's binaries in one package
14: * under `bin/napi-v<N>/<platform>/<arch>/`. ...
diff --git a/packages/core/src/embedding-worker-types.ts b/packages/core/src/embedding-worker-types.ts
index 143f0d4fde..39969218a5 100644
--- a/packages/core/src/embedding-worker-types.ts
+++ b/packages/core/src/embedding-worker-types.ts
@@ -223,6 +223,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 not found|specified module could not be found|undefined symbol|symbol not found|\bdlopen\b/i.test(
+ msg,
+ );
+}
+
/**
* Decide whether a failed pipeline init should ask the main thread to respawn
...
diff --git a/packages/core/test/embedding-worker-types.test.ts b/packages/core/test/embedding-worker-types.test.ts
index 4761c51853..08c899a386 100644
--- a/packages/core/test/embedding-worker-types.test.ts
+++ b/packages/core/test/embedding-worker-types.test.ts
@@ -5,6 +5,7 @@
isOomError,
isWasmFatalError,
isCorruptModelError,
+ isNativeOrtLoadError,
isTransformersInferenceDumpLine,
looksLikeIntactOnnxFile,
MIN_ONNX_FILE_BYTES,
@@ -78,6 +79,27 @@
});
});
+describe("isNativeOrtLoadError", () => {
+ test.each([
+ "Error [ERR_DLOPEN_FAILED]: onnxruntime_binding.node: invalid ELF header",
+ "onnxruntime_binding.node: file too short",
+ "libonnxruntime.so.1: cannot open shared object file",
+ "onnxruntime_binding.node: undefined symbol: OrtGetApiBase",
+ ])("matches a native ONNX Runtime loader failure: %s", (msg) => {
+ expect(isNativeOrtLoadError(msg)).toBe(true);
+ });
+
+ test.each([
+ "lore-native-probe-stop",
+ "Could not locate ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/dist</path> <type>directory</type> <entries> bin.cjs embedding-worker.cjs embedding-worker.js index.bun.js index.cjs index.cjs.map index.d.cts ort-wasm-simd-threaded.mjs ort-wasm-simd-threaded.wasm vector-worker.cjs vector-worker.js (11 entries) </entries>
2026-09-16 12:16:59.667703248 +0000 packages/gateway/dist/index.cjs 2026-09-16 12:16:50.760765826 +0000 packages/gateway/dist/index.bun.js 2026-09-16 12:16:51.522760473 +0000 packages/gateway/dist/embedding-worker.cjs 2026-09-16 12:16:52.004757087 +0000 packages/gateway/dist/embedding-worker.js 2026-09-16 09:29:20.242828474 +0000 packages/core/src/ort-native.ts 2026-09-16 09:47:45.134255901 +0000 packages/core/src/embedding-worker.ts 2026-09-15 17:19:16.469808146 +0000 packages/gateway/script/bundle.ts 2026-09-15 15:47:01.337117096 +0000 packages/gateway/package.json e3287ccf1edac222c5fade64a7420551aaaac06c1d14087022e4017c770cde2e packages/gateway/dist/index.cjs 498d2e325388f604ac6e225ffea8318aec8a42193057916bf6f5f32d18b593b5 packages/gateway/dist/index.bun.js eb0ccfc5ef503b0351675b9e5d86579f8152fbfae7c1786aa909f3bbb2f93915 packages/gateway/dist/embedding-worker.cjs e02912f98b6bf4c74f539311093ad08fcb3c2e152f86170d580d6dddf7902025 ...
Found 25 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/bundle-exports.test.ts:
Line 221: `const originalDlopen = process.dlopen;\n` +
Line 222: `process.dlopen = function (module, filename, ...args) {\n` +
Line 225: ` throw new Error("onnxruntime_binding.node: file too short");\n` +
Line 275: error: expect.stringContaining("file too short"),
Line 352: `const originalDlopen = process.dlopen;\n` +
Line 353: `process.dlopen = function (...args) {\n` +
/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/exit.test.ts:
Line 46: // Default: FFI "succeeds" — dlopen returns the stub, _exit is a no-op.
Line 70: return { dlopen: ffiDlopen, FFIType: { int: 0, void: 0 } };
Line 124: test("under Bun when FFI dlopen throws: falls back to process.exit", async () => {
Line 126: throw new Error("dlopen failed");
Line 172: test("under ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/local.ts</path>
<type>file</type>
<content>
420: const route = (rawLine: string): void => {
421: let line = "";
422: const end = rawLine.endsWith("\r") ? rawLine.length - 1 : rawLine.length;
423: for (let i = 0; i < end && line.length < WORKER_DIAGNOSTIC_MAX_CHARS; i++) {
424: const code = rawLine.charCodeAt(i);
425: if (
426: code <= 0x08 ||
427: code === 0x0b ||
428: code === 0x0c ||
429: (code >= 0x0e && code <= 0x1f) ||
430: code === 0x7f
431: ) {
432: continue;
433: }
434: line += rawLine[i];
435: }
436: if (!line) return;
437:
438: const now = Date.now();
439: if (now - windowStartedAt >= WORKER_DIAGNOSTIC_WINDOW_MS) {
440: if (suppressed > 0) {
441: logDiagnostic(
442: `embedding worker ${source}: suppressed ${suppressed} noisy diagnostic line(s)`,
443: ...
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/embedding/local.ts</path>
<type>file</type>
<content>
380:
381: /** For tests: install the worker factory seam above (null clears it). */
382: export function _setTestWorkerFactory(
383: factory:
384: | ((
385: data: WorkerInitData,
386: entrypoint: string | URL,
387: options: EmbeddingWorkerSpawnOptions,
388: ) => import("node:worker_threads").Worker)
389: | null,
390: ): void {
391: testWorkerFactory = factory;
392: }
393:
394: const WORKER_DIAGNOSTIC_MAX_CHARS = 2_000;
395: const WORKER_DIAGNOSTIC_WINDOW_MS = 60_000;
396: const WORKER_DIAGNOSTIC_LINES_PER_WINDOW = 20;
397:
398: function drainEmbeddingWorkerStream(
399: stream: import("node:stream").Readable | null | undefined,
400: source: "stdout" | "stderr",
401: ): void {
402: if (!stream) return; // Test doubles created before the owned-stdio contract. ...
Found 14 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-worker-types.test.ts:
Line 85: "onnxruntime_binding.node: file too short",
Line 360: // The request that tripped `init-needs-wasm` is rejected by ensurePipeline
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/embedding-wasm-fallback.test.ts:
Line 22: // native worker reports `init-needs-wasm` (it loaded the ONNX addon but couldn't
Line 110: it("respawns forcing WASM and re-submits the in-flight request on init-needs-wasm", async () => {
Line 125: type: "init-needs-wasm",
Line 160: type: "init-needs-wasm",
Line 183: it("treats a second init-needs-wasm (WASM also fails) as a genuine init failure — no respawn loop", async () => {
Line 192: type: "init-needs-wasm",
Line 200: type: "init-needs-wasm",
Line 211: it("stays available and re-submits when the native worker emits the full real protocol (init-needs-wasm + ...
/home/byk/.volta/bin/bun
1.3.14
{"hasReport":true,"hasGetReport":"function","glibcVersionRuntime":"2.39","platform":"linux","arch":"x64"}
/home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/package.json
<path>/home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/bin</path> <type>directory</type> <entries> napi-v6/ (1 entries) </entries>
<path>/home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/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>
/usr/bin/bash: line 1: python: command not found
/home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node 2.14 ["2.2","2.4","2.14"] /home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime.so.1 2.27 ["2.2","2.3","2.4","2.6","2.14","2.16","2.17","2.26","2.27"]
No files found
Ripgrep JSON record exceeded 65536 bytes
diff --git a/packages/core/src/embedding/local.ts b/packages/core/src/embedding/local.ts
index 5c5e7e600f..73b8f4a2fa 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 ...
Found 23 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/ort-platform-package.test.ts:
Line 13: import { ORT_NATIVE_TARGETS } from "../../core/src/ort-native";
Line 30: expect(ORT_NATIVE_TARGETS).toEqual(expected);
Line 31: expect(new Set(ORT_NATIVE_TARGETS).size).toBe(ORT_NATIVE_TARGETS.length);
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/test/ort-native.test.ts:
Line 14: ORT_NATIVE_TARGETS,
Line 17: ortNativePackageName,
Line 19: resolveNativeOrtBindingPath,
Line 74: const publishedName = ortNativePackageName("linux-x64");
Line 118: return resolveNativeOrtBindingPath(workerPath, ORT_VERSION, runtime);
Line 143: expect(ortNativePackageName("linux-x64")).toBe(
Line 146: expect(ortNativePackageName()).toBe(
Line 153: expect(ORT_NATIVE_TARGETS).toEqual([
Line 160: expect(new Set(ORT_NATIVE_TARGETS).size).toBe(ORT_NATIVE_TARGETS.length);
Line 165: ...
<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. ...
packages/gateway/dist/embedding-worker.cjs {"bytes":581816,"unresolvedDefine":false,"manifestField":true,"glibc":true,"version":true,"loadClassifier":true,"wasmMessage":true}
packages/gateway/dist/embedding-worker.js {"bytes":581495,"unresolvedDefine":false,"manifestField":true,"glibc":true,"version":true,"loadClassifier":true,"wasmMessage":true}
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules</path> <type>directory</type> <entries> .bin/ @loreai/ @sentry/ @streamparser/ @stricli/ @supabase/ @types/ ai-tokenizer/ binpatch/ fossilize/ google-auth-library/ jsonc-parser/ onnxruntime-node/ p-limit/ qrcode-terminal/ semver/ sqlite-vec/ tar/ undici/ (19 entries) </entries>
/home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node GLIBCXX 3.4.21 /home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node CXXABI 1.3.9 /home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime.so.1 GLIBCXX 3.4.22 /home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime.so.1 CXXABI 1.3.11
{"file":"/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","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","string":"Error: /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"}
{"file":"/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/package.json","name":"Error","code":"ERR_DLOPEN_FAILED","message":"/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/package.json: invalid ELF header","string":"Error: ...
<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": ...
<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. ...
/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 2.17 ["2.17"] /home/byk/Code/opencode-lore-embedding-runtime/node_modules/.pnpm/onnxruntime-node@1.27.0/node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/libonnxruntime.so.1 2.27 ["2.17","2.27"]
Found 1 matches /home/byk/Code/opencode-lore-embedding-runtime/quality/COMPLETENESS_REPORT.md: Line 43: - **Embedding fallback** (REQ-001): `packages/core/src/embedding.ts` — WASM backend fallback when native ONNX unavailable. Covered by test_embedding_fallback_recovery + Group 10.
{
"newestSource": {
"ms": 1789559359907.697,
"path": "packages/core/src/embedding/pool.ts"
},
"artifacts": [
{
"path": "packages/gateway/dist/index.cjs",
"ms": 1789561019667.7034
},
{
"path": "packages/gateway/dist/index.bun.js",
"ms": 1789561010760.7659
}
],
"oldestArtifactMs": 1789561010760.7659,
"fresh": true
}
RUN v4.1.8 /home/byk/Code/opencode-lore-embedding-runtime
Test Files 4 passed (4)
Tests 125 passed (125)
Start at 13:43:31
Duration 4.55s (transform 1.64s, setup 1.89s, import 3.74s, tests 1.60s, environment 1ms)
{"message":"/pkg/onnxruntime_binding.node: failed to map segment from shared object","classified":false}
{"message":"C:\\pkg\\onnxruntime_binding.node is not a valid Win32 application.","classified":false}
{"message":"/pkg/libonnxruntime.so.1: version `GLIBC_2.28` not found","classified":false}
{"message":"/pkg/onnxruntime_binding.node: wrong ELF class: ELFCLASS32","classified":false}
Found 13 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/log.ts:
Line 39: import { redactCredentialHeaderAssignments } from "./credential-headers";
Line 175: export function redactSensitiveLogText(value: string): string {
Line 176: return redactCredentialHeaderAssignments(value, LOG_FILTERED)
Line 208: redactSensitiveLogText(
Line 218: function sanitizedError(error: Error): Error {
Line 219: const copy = new Error(redactSensitiveLogText(error.message));
Line 221: if (error.stack) copy.stack = redactSensitiveLogText(error.stack);
Line 464: export function info(...args: unknown[]): void {
Line 465: const msg = redactSensitiveLogText(formatArgs(args));
Line 474: const msg = redactSensitiveLogText(formatArgs(args));
Line 490: const msg = redactSensitiveLogText(formatArgs(args));
Line 498: const msg = redactSensitiveLogText(formatArgs(args));
Line 504: if (err) sink?.captureException(sanitizedError(err));
<path>/home/byk/Code/opencode-lore-embedding-runtime/packages/core/src/log.ts</path>
<type>file</type>
<content>
160: for (const a of args) {
161: if (a instanceof Error) return a;
162: }
163: return undefined;
164: }
165:
166: const LOG_FILTERED = "[Filtered]";
167: const LOG_SENSITIVE_KEY = String.raw`(?:proxy[\s._-]*authorization|authorization|x[\s._-]*api[\s._-]*key|api[\s._-]*key|(?:api|access|auth|bearer|client|consumer|identity|private|refresh|security|subscription)[\s._-]*(?:id|key|secret|token)|ocp[\s._-]*apim[\s._-]*subscription[\s._-]*key|cf[\s._-]*access[\s._-]*client[\s._-]*id|set[\s._-]*cookie|(?:[a-z0-9]+[\s._-]+)*signatures?|token|secret|password|passwd|passphrase|credentials?|cookies?)`;
168:
169: /**
170: * Redact practical credential/header forms before text reaches stderr, an
171: * external sink, or persistent storage. ...
No files found
Found 3 matches
/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/bundle-exports.test.ts:
Line 287: "%s rejects a malformed native addon before loading the WASM fallback",
Line 330: optionalDependencies: { [platformPackageName]: version },
/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/test/ort-platform-package.test.ts:
Line 19: // embeddings (resolve throws → WASM fallback). This binds both sides.
scoped-files-match-candidate 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 | ...
packages/core/src/embedding-worker.ts:232-242 discards Error.code and classifies only err.message. Yet packages/core/src/embedding-worker-types.ts:227-235 expects ERR_DLOPEN_FAILED inside that message. Node stores it separately in error.code.
Common failures return false, including:
failed to map segment from shared objectnot a valid Win32 applicationversion 'GLIBC_…' not foundwrong ELF classThese failures produce init-error, so the worker retries native instead of taking the one-shot WASM fallback. The test at packages/core/test/embedding-worker-types.test.ts:82-100 embeds [ERR_DLOPEN_FAILED] in a synthetic message and does not reproduce the real error shape.
Pass the structured error code to the classifier and add Linux, macOS, Windows, noexec, and version-mismatch cases.
packages/gateway/test/bundle-exports.test.ts:60-62,114-123 determines freshness using only:
dist/index.cjsdist/index.bun.jsThe new regressions read and execute embedding-worker.cjs and embedding-worker.js at :185-413. If either worker is stale while both index bundles are current, the suite skips rebuilding and tests the wrong bytes. Include both workers—and preferably every asserted generated artifact—in the freshness set.
The binding containment guard is at packages/core/src/ort-native.ts:157-160. The only escape test, packages/core/test/ort-native.test.ts:422-438, symlinks the entire bin directory, which is already rejected at ort-native.ts:271-272. Removing the binding-level guard would leave that test green.
Add escaped onnxruntime_binding.node symlinks with an otherwise-contained bin tree for both workspace and published-package routes. ...
Date: September 16, 2026 * 🟡 (13:40) Native-load probe for `/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` failed with `ERR_DLOPEN_FAILED`: `cannot open shared object file: No such file or directory`. * 🟡 (13:40) Probe attempting to load `/home/byk/Code/opencode-lore-embedd…
Date: September 16, 2026 * 🔴 (13:38) User showed `/home/byk/Code/opencode-lore-embedding-runtime/packages/gateway/node_modules` contains exactly 19 entries: `.bin/`, `@loreai/`, `@sentry/`, `@streamparser/`, `@stricli/`, `@supabase/`, `@types/`, `ai-tokenizer/`, `binpatch/`, `fossilize/`, `google-auth-library/`, `jsonc-parser/`, `onnxruntime-node/`, `p-limit/`, `qrcode-terminal/`, `semver/`, `sq…
Date: September 16, 2026 * 🔴 (13:30) User showed gateway build artifact timestamps and SHA-256 hashes: `packages/gateway/dist/index.cjs` timestamp `2026-09-16 12:16:59.667703248 +0000`, hash `e3287ccf1edac222c5fade64a7420551aaaac06c1d14087022e4017c770cde2e`; `packages/gateway/dist/index.bun.js` timestamp `2026-09-16 12:16:50.760765826 +0000`, hash `498d2e325388f604ac6e225ffea8318aec8a42193057916…
Date: September 16, 2026 * 🔴 (13:29) User added `isNativeOrtLoadError` coverage in `packages/core/test/embedding-worker-types.test.ts` for native ONNX Runtime loader failures including `Error [ERR_DLOPEN_FAILED]: onnxruntime_binding.node: invalid ELF header`, `onnxruntime_binding.node: file too short`, `libonnxruntime.so.1: cannot open shared object file`, and `onnxruntime_binding.node: undefine…
Date: September 16, 2026 * 🔴 (13:28) User documented that the gateway bundle regression test builds its bundle on demand in `beforeAll`, so it always runs against a freshly built bundle rather than a stale pre-existing artifact. * 🔴 (13:28) User documented a bundle-freshness guard comparing source modification times with `packages/gateway/dist/index.cjs` and the Bun bundle artifact, ensuring as…
Date: September 16, 2026 * 🔴 (13:27) User documented worker entrypoint resolution in `packages/core/src/embedding/local.ts`: CommonJS uses `__filename`, which is always defined; ESM uses `import.meta.url`. * 🔴 (13:27) User documented that the gateway CommonJS bundle produced by `script/bundle.ts` always defines the relevant `import.meta` compatibility value; a shim keeps the source natural. * �…
Date: September 16, 2026 * 🔴 (13:26) User asserted that `resolveNativeOrtBindingPath` returns `null` and never throws when native ONNX Runtime packages are absent. * 🔴 (13:26) User asserted that native ONNX Runtime resolution never resolves an undeclared ancestor workspace package. * 🔴 (13:26) User asserted that native thread-cap defaults never throw and return either a valid cap or no overrid…
Date: September 16, 2026 * 🔴 (13:26) User stated the Node-only `undici@7` path is never bundled or evaluated under Bun; the Bun path uses Bun-native `fetch` and never touches `undici`. * 🔴 (13:26) User stated `undici` is safe as a `devDependency` only because its import is Node-only and lazy, so the Bun path never imports it; if the Bun path ever imports `undici`, it must become a runtime depen…
Date: September 16, 2026 * 🔴 (13:25) User stated the WASM heap never shrinks: after the first oversized allocation grows the heap, every smaller retry in the same worker also fails; real recovery requires replacing or respawning the worker. * 🔴 (13:25) User stated native ONNX Runtime load-error classification must be narrowly scoped so an unrelated resolution error, such as a missing model file…
Date: September 16, 2026 * 🔴 (13:24) User stated Lore tests use a temporary SQLite database through `packages/core/test/setup.ts` and must never use the production database at `~/.local/share/lore/lore.db`. * 🔴 (13:24) User stated releases use Sentry Craft through GitHub Actions; versions and `CHANGELOG.md` must never be edited manually because Craft handles both automatically. * 🔴 (13:24) Use…
Date: September 16, 2026 * 🔴 (13:23) User stated that `jj` never fails on conflict; after `rebase`, `new`, or `squash`, conflicts are recorded in the resulting commit and must be checked with `jj st`, resolved by manually editing files, and verified cleared with another `jj st`. * 🔴 (13:23) User stated that repositories containing `.jj/` must use `jj` rather than `git` for mutations, including …
Date: September 16, 2026 * 🔴 [requested-review] (13:21) User requested a read-only adversarial correctness and security review of ONLY the native ONNX runtime selection/fallback/packaging slice in `/home/byk/Code/opencode-lore-embedding-runtime` at current Jujutsu change `tmzmtlss`. * 🔴 (13:21) User constrained the review: do not edit files, mutate VCS, use the network, or run production servic…