Files
ruvnet__ruflo/scripts/audit-better-sqlite3-override.mjs
rUv bb34896656 fix: #2219 #2221 #2222 #2215 #2226 — memory/routing/statusline bug cluster (3.10.6) (#2227)
* fix: #2219 #2221 #2222 #2215 #2226 — memory/routing/statusline bug cluster (3.10.6)

Five reproducible bugs reported by external contributors (pacphi, casparml,
HF-teamdev), each verified against source and covered by a regression test.

#2219 (silent write loss, Node 24/26) — agentdb pins better-sqlite3 as an
  OPTIONAL dep at ^11.8.1, which has no Node 24/25/26 prebuild; the native
  build fails silently and AgentDB drops to a non-persistent backend. Override
  better-sqlite3 to >=12.8.0 (ships Node 20–26 prebuilds) in BOTH the root
  umbrella and the ruflo wrapper (#2112: root overrides don't reach the
  wrapper). New CI guard audit-better-sqlite3-override.mjs prevents regression.

#2226 (pattern store/search backend mismatch) — agentdb_pattern-store and
  agentdb_pattern-search hit disjoint backends, so stored patterns were never
  found. Two paths fixed: (a) when the ReasoningBank controller is present,
  bridgeSearchPatterns now reads LocalReasoningBank.findSimilar/getAll (the
  same backend store writes to); (b) when the controller is absent (the common
  real-world state), the memory-store-fallback search Tier-2 now hydrates entry
  content via getEntry — listEntries returns metadata only (see #2014), so the
  substring scan previously matched nothing.

#2222 (route feedback no-op) — `route feedback` applied the Q-update in memory
  but the CLI exits before the Q-learner's autoSaveInterval fires, so learning
  never persisted. Add an explicit awaited router.saveModel() after feedback.

#2221 (statusline shows V3.6 on global installs) — getPkgVersion() never probed
  the global npm root, so `npm i -g ruflo` fell back to the hard-coded default.
  Derive the global node_modules dir from process.execPath (no npm spawn) and
  probe it; covers nvm/mise and Windows layouts. Regenerated statusline.cjs.

#2215 (flashAttention contradictory state) — system_info emitted a hard-coded
  `flashAttention: false` while hooks_intelligence reported the live probe.
  system_info now runs the same getFlashAttention() probe as the authoritative
  path so the two tools can't disagree.

Tests: __tests__/bug-cluster-2219-2226.test.ts (5/5), statusline drift guard
still byte-identical (8/8), tsc clean, targeted sweep 120/120.

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(deps): #2219 — sync package-lock to better-sqlite3@12.10.0 override

npm ci validates lockfile against package.json; the override bumped the
resolved version but the committed lockfile still pinned 11.10.0, failing
'npm ci' in CI. Regenerated with --package-lock-only.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-29 08:52:31 -04:00

91 lines
3.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Static guard for ruvnet/ruflo#2219 — keep the `better-sqlite3` override
* pinned to a version that ships Node 24/25/26 prebuilds.
*
* Why: `agentdb` declares `better-sqlite3` as an OPTIONAL dependency at
* `^11.8.1`. better-sqlite3 11.8.1 has no prebuilt binary for Node 24/25/26,
* so on those runtimes the optional native build fails *silently* (optional
* deps never error) and AgentDB falls back to a non-persistent backend —
* users on Node 24/26 saw stores succeed but never persist (silent write
* loss). better-sqlite3 >=12.8.0 ships prebuilds for Node 20–26.
*
* Per the #2112 lesson, root overrides do NOT propagate to the published
* `ruflo` wrapper — the override MUST be present in BOTH the root umbrella
* (`package.json`) and the wrapper (`ruflo/package.json`). This guard asserts
* both carry `better-sqlite3 >= 12.8.0`. Wired into v3-ci.yml.
*
* Exit codes:
* 0 — both overrides present and satisfy >=12.8.0
* 1 — missing override, or a range that admits a Node-24/26-broken version
*/
import { readFileSync, existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join, resolve } from 'node:path';
import semver from 'semver';
const __dirname = dirname(fileURLToPath(import.meta.url));
const REPO_ROOT = resolve(__dirname, '..');
// The floor that has Node 24/25/26 prebuilds. Any override that could resolve
// below this re-opens the silent-write-loss on new Node majors.
const MIN_SAFE = '12.8.0';
const TARGETS = [
{ label: 'claude-flow (root umbrella)', path: 'package.json' },
{ label: 'ruflo (published wrapper)', path: 'ruflo/package.json' },
];
let failed = false;
for (const { label, path: rel } of TARGETS) {
const p = join(REPO_ROOT, rel);
if (!existsSync(p)) {
console.error(`✗ ${label}: ${rel} not found`);
failed = true;
continue;
}
let pkg;
try {
pkg = JSON.parse(readFileSync(p, 'utf8'));
} catch (e) {
console.error(`✗ ${label}: ${rel} is not valid JSON — ${e.message}`);
failed = true;
continue;
}
const range = pkg.overrides?.['better-sqlite3'];
if (!range) {
console.error(
`✗ ${label}: missing overrides["better-sqlite3"]. ` +
`Add "better-sqlite3": ">=${MIN_SAFE}" so agentdb's optional native ` +
`dep resolves to a version with Node 24/25/26 prebuilds (#2219).`,
);
failed = true;
continue;
}
// The minimum version the range can resolve to must be >= MIN_SAFE, so the
// override can never drop back to a Node-24/26-broken better-sqlite3.
const minOfRange = semver.minVersion(range);
if (!minOfRange || semver.lt(minOfRange, MIN_SAFE)) {
console.error(
`✗ ${label}: overrides["better-sqlite3"] = "${range}" can resolve below ` +
`${MIN_SAFE} (min ${minOfRange ?? 'unparseable'}). Node 24/25/26 need ` +
`>=${MIN_SAFE} prebuilds (#2219).`,
);
failed = true;
continue;
}
console.log(`✓ ${label}: better-sqlite3 override "${range}" (min ${minOfRange}) ≥ ${MIN_SAFE}`);
}
if (failed) {
console.error('\nbetter-sqlite3 override guard FAILED (#2219). See messages above.');
process.exit(1);
}
console.log('\n✓ better-sqlite3 override guard passed — Node 24/25/26 persistence protected.');
process.exit(0);