Skip to content

fix(nix): packaged opencode closure does not provide libstdc++/zlib for the native-onnx embeddings backend flipped in #1690 #1727

Closed

Description

@dezren39

Finding

PR #1559 (native in-process embeddings backend, step 2 of #1554) recorded a loader-path requirement and made it a precondition for the step-3 flip:

The native bindings this loads (onnxruntime-node's .node, and sharp's, which transformers loads transitively) need libstdc++ (libstdc++.so.6) and zlib (libz.so.1) on the process loader path. … The packaged server's nix closure must provide libstdc++/libz on the loader path before step 3 flips the registration to native.

Step 3 has now flipped the registration (PR #1690, merged 2026-11-05), but the packaged nix closure still does not provide either library, and no open issue tracks this packaging item (#1689 step 4 covers sidecar retirement / HTTP-path removal / docs only).

Evidence (verified on current main 13ab3dc5c2d51fa35ff0273e18f5ef647eca83db, 2026-11-05)

  • packages/core/src/embeddings.ts (~line 132): EMBEDDING_MODELS[0] registration is backend: { kind: "native-onnx", snapshotEnv: "LOCAL_EMBED_SNAPSHOT", … } — the native backend is now the default for the local model.
  • packages/core/src/embeddings-native.ts header (Packaging note) still states in the present tense: "the packaged server's nix closure must provide them" (libstdc++ / libz).
  • nix/opencode.nix:99: the packaged binary's wrapper sets --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ wayland ]} on Linux — wayland only; no stdenv.cc.cc.lib (libstdc++), no zlib.
  • flake.nix (~line 87): stdenv.cc.cc.lib appears only in the devShell LD_LIBRARY_PATH (for @parcel/watcher) — that does not reach the packaged server. No nix file under nix/ mentions libstdc++, zlib, or onnx.
  • PR feat(core): flip embeddings registration to native-onnx backend (#1554 step 3) #1690's verification was a laptop dev-shell run ("LD_LIBRARY_PATH per embeddings-native.ts header") with the sidecar stopped — the packaged binary was not exercised. In a bare environment the failure mode per feat(core): native in-process embeddings backend behind the registry (#1554 step 2) #1559 is loud but total for embeddings: Embeddings.UnavailableError: libstdc++.so.6: cannot open shared object file.

Source PRs: #1559 (merge adc454beeb, the finding) and #1690 (the flip). This is a pr-diff-review finding from reviewing #1559's diff/body against current main.

Why it matters

The default embeddings registration now depends on native bindings whose loader requirements the shipped package does not satisfy. Anyone running the packaged opencode (the nix build is the fleet's deployment route) risks embeddings failing on first use — after the :18752 sidecar is retired in step 4 (#1689), there will be no fallback path left.

Acceptance criteria

  • The packaged nix build (nix/opencode.nix) is exercised end-to-end for embeddings: the built opencode binary answers an embeddings round-trip (index + query) with the model snapshot present, with no dev-shell LD_LIBRARY_PATH and no :18752 sidecar running — OR the failure is reproduced and recorded here.
  • If it fails: the wrapper/closure provides libstdc++ (stdenv.cc.cc.lib) and zlib on the loader path (e.g. added to the wrapProgram LD_LIBRARY_PATH in nix/opencode.nix), and the round-trip above passes with the built binary.
  • The packaging note in packages/core/src/embeddings-native.ts is updated to match the resolved state.

agent-note:v1
Agent: pr-diff-review-b
state: filed

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued task in the Supabase agent queue
    app/corePackage: core (pkgs/ or apps/ in this repo)
    on Nov 5, 2026
  2. dezren39 commented on Nov 5, 2026

    @dezren39
    Author

    agent-note:v1
    Agent: pr-diff-review-b
    state: filed
    note: Filed from PR diff review lane B (run 2026-11-05 03:18 CST) reviewing PR #1559 (merge adc454b) against current main 13ab3dc: #1559 made the packaged nix closure providing libstdc++/zlib a precondition for the step-3 flip; PR #1690 flipped EMBEDDING_MODELS[0] to native-onnx, but nix/opencode.nix:99 wraps LD_LIBRARY_PATH with wayland only and no open issue covered the packaging item (#1689 is sidecar retirement only). Enqueued as a repo-task/v1 triage packet in repo-health-opencode-pilot.

  3. added
    work/assignedAn agent holds this item via the queue (claimed task)
    queue/claimedA queue worker has claimed the task for this item
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 5, 2026
  4. dezren39 commented on Nov 5, 2026

    @dezren39
    Author

    agent-note:v1
    Agent: repo-worker-opencode (task 9976, lane opencode-a, direct)
    state: picked up
    Verified issue open, no held/user-owned/do-not-merge/do-not-auto-edit labels, no competing open PR. Working the nix packaging fix on the laptop in a dedicated worktree; CI-first verification.

  5. dezren39 commented on Nov 5, 2026

    @dezren39
    Author

    agent-note:v1
    Agent: repo-worker-opencode (task 9976, lane opencode-a, direct)
    state: parked — PR opened, awaiting Codex review + built-binary verification

    PR: #1739 (branch queue/9976-1727-nix-libstdcpp-zlib, commit 32601e9)

    • nix/opencode.nix: Linux wrapper LD_LIBRARY_PATH now includes stdenv.cc.cc.lib + zlib alongside wayland.
    • embeddings-native.ts packaging note updated to the resolved state.
      Verified: nix eval drvPath OK for x86_64-linux / aarch64-linux / aarch64-darwin; evaluated wrapper path resolves to gcc-16.2.0-lib (libstdc++.so.6 present) and zlib-1.3.2 (libz.so.1 present).
      Remaining before merge: disposition any Codex findings on the PR, and the built-binary embeddings round-trip from the acceptance criteria. Issue stays open.
  6. 7 remaining items

  7. removed
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 5, 2026
  8. dezren39 commented on Nov 5, 2026

    @dezren39
    Author

    Triage (task 9976, lane opencode-a, re-claimed this shift): CONFIRMED and PARTIALLY RESOLVED — closure fix already merged; only the built-binary verification remains.

    Re-verified this shift against fresh GitHub state:

    Remaining acceptance (the only open item): exercise the packaged nix build end-to-end for embeddings — the built opencode binary answers an embeddings round-trip (index + query) with the model snapshot present, with no dev-shell LD_LIBRARY_PATH and no :18752 sidecar running. That verification is enqueued as a separate queue task this shift (dedupe key repo-health:v1:fix:developing-today/opencode:issue:1727 (task 10747)), to run on the laptop under the fleet build lock / on CI — not on the sandbox. If the round-trip passes, this issue closes with that evidence; if it fails, the failure is recorded here and routed back to a fix.

    Triaged by: lane opencode-a, task 9976 — closure fix verified merged (PR #1739); round-trip verification enqueued separately

  9. added
    queue/queuedHas a queued task in the Supabase agent queue
    and removed
    queue/claimedA queue worker has claimed the task for this item
    on Nov 5, 2026
  10. developing-today commented on Nov 5, 2026

    @developing-today

    Verification result (queue task 10747, lane opencode-a, 2026-11-05): the packaged-binary embeddings round-trip does NOT pass yet. #1727 stays open; the exact failure chain is recorded here and a fix task is enqueued.

    What was run:

    1. Packaged build. Current main does not build at all on the laptop's Bun 1.4.4 — the node_modules derivation fails parsing the committed solid-js patch (the fix(ci): Solid test suites break on Bun ≥1.4.3 — jsxDEV not found in solid-js production build; CONTRIBUTING's 'Bun 1.3 or newer' is false for tests #1698 defect). Building from the fix(ci): Solid test suites break on Bun ≥1.4.3 — jsxDEV not found in solid-js production build; CONTRIBUTING's 'Bun 1.3 or newer' is false for tests #1698 WIP branch instead (regenerated patch + the x86_64-linux node_modules FOD hash updated to the measured value, branch queue/10024-1698-solid-bun @ 57db6c3, which includes PR fix(nix): provide libstdc++/zlib for native-onnx embeddings in packaged opencode #1739's closure fix) succeeds: /nix/store/k938cnzzqka9nkf3pkvfg3w10brkm928-opencode-2.0.30+57db6c3.
    2. Round-trip conditions, per this issue's acceptance: the built binary only, scrubbed environment (no LD_LIBRARY_PATH, no dev shell), the model snapshot present at the default HF cache dir, and the :18752 sidecar verified not listening. opencode serve came up; POST /v1/embeddings for local-embed/snowflake-arctic-embed-m-v2.0 returned 502:
      libonnxruntime.so.1: cannot open shared object file: No such file or directory
    3. Diagnostic (not part of the acceptance run): with only the onnxruntime-node bin dir from the node_modules store path added to LD_LIBRARY_PATH, the failure advances to the next native dependency — Could not load the "sharp" module using the linux-x64 runtime (the transitive sharp load embeddings-native.ts's header warns about).

    Conclusion: PR #1739's libstdc++/zlib closure is necessary but not sufficient — in the bun-compiled packaged binary, onnxruntime's own shared library is not resolvable and sharp's native binding does not load at all. The remaining work is in the CLI build/packaging (how onnxruntime-node's and sharp's native assets are made resolvable in the compiled binary), routed to a dedicated fix task from #1727's queue entry. Dev-shell behaviour is unaffected.

    Recorded by: lane opencode-a, task 10747

  11. added
    queue/claimedA queue worker has claimed the task for this item
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 5, 2026
  12. added a commit that references this issue on Nov 5, 2026
  13. developing-today commented on Nov 5, 2026

    @developing-today

    Resolved — PR #1786 merged as f9b94d8, and the packaged-binary round-trip now passes exactly as this issue's acceptance specifies: built binary only, scrubbed environment (no LD_LIBRARY_PATH, no dev shell), snapshot present at the default HF cache dir, :18752 sidecar verified not listening. POST /v1/embeddings returned three 768-dim unit-norm vectors in 1.2s (prompt_tokens 58); cosine(document, related query) 0.7227 vs cosine(document, unrelated text) 0.2112.

    The three gaps fixed (each was hiding the next): libonnxruntime.so.1 now ships under lib/onnxruntime in the nix package and is on the wrapper's loader path; transformers' static sharp import is rewritten to the Node bundle's throwing stub in the compiled build (image inputs only — text never reaches it); and transformers' runtime createRequire of onnxruntime-node is rewritten to a static require the bundler resolves.

    Completed by: lane opencode-a, tasks 10747 (verification) and 10792 (fix)

  14. removed
    queue/claimedA queue worker has claimed the task for this item
    work/assignedAn agent holds this item via the queue (claimed task)
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/corePackage: core (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/pr-diff-reviewFiled by the pr-diff-review jobtask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions