mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-17 04:12:17 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
49 lines
2.1 KiB
TypeScript
49 lines
2.1 KiB
TypeScript
// Shared guard for unit tests that construct a real better-sqlite3 Database as a
|
|
// test fixture (e.g. seeding a legacy on-disk schema before exercising the
|
|
// migration runner). better-sqlite3 is a native addon: production and CI load
|
|
// it fine, but some sandboxes/dev boxes ship a system glibc older than the
|
|
// prebuilt binary requires (e.g. "GLIBC_2.29 not found"), so `new Database(...)`
|
|
// throws ERR_DLOPEN_FAILED at fixture-construction time. That is an environment
|
|
// limitation, NOT a defect in the code under test — the OmniRoute runtime itself
|
|
// cascades to node:sqlite/sql.js when better-sqlite3 can't load, so the app keeps
|
|
// working; only tests that reach for better-sqlite3 DIRECTLY (to build a
|
|
// driver-specific fixture) are affected.
|
|
//
|
|
// Tests import `betterSqlite3Available` to decide whether to run or to skip with
|
|
// a clear, documented reason. In CI (where better-sqlite3 loads) the tests run
|
|
// normally; only the constrained sandbox skips them.
|
|
//
|
|
// Usage:
|
|
// import { betterSqlite3Available, BETTER_SQLITE3_SKIP_REASON } from "./_helpers/betterSqlite3Availability";
|
|
// const canUseBetterSqlite3 = betterSqlite3Available();
|
|
// test("...", { skip: canUseBetterSqlite3 ? false : BETTER_SQLITE3_SKIP_REASON }, () => { ... });
|
|
|
|
import { createRequire } from "node:module";
|
|
|
|
export const BETTER_SQLITE3_SKIP_REASON =
|
|
"better-sqlite3 native addon cannot load in this environment (e.g. system " +
|
|
"glibc older than the prebuilt binary requires — 'GLIBC_2.29 not found'). " +
|
|
"This is a sandbox/environment limitation, not a code defect: the runtime " +
|
|
"cascades to node:sqlite/sql.js, and CI runs this test with a working " +
|
|
"better-sqlite3.";
|
|
|
|
let cached: boolean | null = null;
|
|
|
|
/**
|
|
* Returns true when a real better-sqlite3 Database can be constructed in the
|
|
* current environment. Result is memoized. Never throws.
|
|
*/
|
|
export function betterSqlite3Available(): boolean {
|
|
if (cached !== null) return cached;
|
|
try {
|
|
const require = createRequire(import.meta.url);
|
|
const Database = require("better-sqlite3");
|
|
const db = new Database(":memory:");
|
|
db.close();
|
|
cached = true;
|
|
} catch {
|
|
cached = false;
|
|
}
|
|
return cached;
|
|
}
|