feat(db): report the SQLite driver and its durability on the DB health check - #10652
Merged
diegosouzapw merged 1 commit intoAug 20, 2026
Merged
Conversation
…h check
`DbHealthCheckResult` said whether the data was consistent but never which
engine was serving it. The driver cascade logs its choice once at startup and
`omniroute doctor` checks whether the better-sqlite3 native binary loads on
disk from its own process — neither answers what the running server is on, and
the two can disagree (a bundler that rewrites the runtime require makes the
native driver fail to resolve inside the server while a fresh CLI resolves it
fine, leaving the server silently on the sql.js WASM fallback).
`driver.degraded` carries exactly one meaning: writes are not durably backed by
the database file. Two situations qualify — the sql.js WASM fallback, and an
in-memory database, which `getDbInstance()` opens in cloud/build mode through
the NATIVE cascade, so the driver name alone would read as healthy while
nothing is persisted.
The field is informative only: `isHealthy` stays defined by `issues`, so no
existing check changes verdict. It reaches the authenticated `GET/POST
/api/db/health` and the loopback-only `omniroute_db_health_check` MCP tool,
which already serialize the whole result.
Also corrects the DATABASE_GUIDE health-check section, which documented a
`{status, checks: {...}}` payload this endpoint has never returned
(`orphaned_artifacts` and `table_sizes` have no source match anywhere). Its
unterminated code fence left every fabricated-docs claim below it unscanned;
closing the fence surfaced `SQLITE_FULL`, a SQLite result code the gate reads
as an env var, now allowlisted alongside the other prose-documented error codes.
Owner
|
Reviewed #10652. Verified all 3 red checks on this run (Fast Quality Gates, Unit Tests fast-path 2/4 and 3/4) are pre-existing base-red on release/v3.8.50 — reproduced the same compression/omniglyph failures on a clean base checkout with none of this PR's changes applied. Ran the PR's own tests (db-health-driver.test.ts 5/5, db-health-check.test.ts 10/10) plus eslint on the touched files — all clean. Confirmed the driver type is derived from the adapter's closed union (no drift risk) and that both consumers (/api/db/health, omniroute_db_health_check MCP tool) already serialize the whole result object, so no additional wiring was needed. Looks merge-ready. |
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…h check (diegosouzapw#10652) Merged — validated together with a batch of related maxmad64bis PRs in one combined worktree (typecheck:core clean, complexity/cognitive-complexity/file-size/changelog gates green, focused tests passing). Thanks for the contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DbHealthCheckResultnow reports which SQLite driver served the checked database, and whetherthat database's writes are durable:
"driver": { "name": "sql.js", "degraded": true }.driverFactorylogs the chosen driver once at startup;omniroute doctorchecks whether the better-sqlite3 native binary loads on disk, from its ownprocess; and the payload of the endpoint whose job is DB health carried no driver field.
Per fix(db): preserve runtime driver require in webpack standalone bundles #10552, a standalone bundle can rewrite the runtime
requireso the native driver fails toresolve inside the server while a fresh CLI resolves it fine — the server then runs on the
sql.js WASM fallback while
doctorreports green.degradedhas exactly one meaning: writes are not durably backed by the database file. Twocases qualify — the sql.js WASM fallback, and an in-memory database, which
getDbInstance()opens in cloud/build mode through the native cascade, so the driver name alone would read
as healthy while nothing is persisted.
isHealthystays defined byissues, so no existing check changes verdict.database than the one inspected.
Also corrects the
DATABASE_GUIDEhealth-check section, which documented a{status, checks: {...}}payload this endpoint has never returned (orphaned_artifactsandtable_sizeshave no source match in the repository). Its unterminated code fence left everyfabricated-docs claim below it unscanned; closing it surfaced
SQLITE_FULL— a SQLite resultcode quoted in prose, read by the gate as an env var — now allowlisted next to the other
prose-documented error codes.
Related Issues
Validation
npm run lintThe single typecheck error is already tracked on the base and lives in a file this PR does not
touch.
Tests Added Or Updated
tests/unit/db-health-driver.test.ts(new, 5 tests):describeDbDriverflags sql.js asdegraded, flags every driver as degraded for
:memory:, and leaves the three native driversundegraded on a file-backed database;
runDbHealthCheckagainst a real database reports adriver equal to the adapter's own
db.driver; and an in-memory database opened through thesame
tryOpenSynccascade the cloud/build path uses really reportsname === ":memory:".Coverage Notes
src/:describeDbDriver()(pure, all branches covered) and the single constructionsite of
DbHealthCheckResult, covered by the real-database test above.Reviewer Notes
DbHealthCheckResultgains one required field. It has a single producer, and both consumers(
/api/db/health,omniroute_db_health_check) serialize the whole result, so no furtherwiring is needed.
driveris nested rather than two flat fields so the two facts stay grouped and a laterpersistencerefinement needs no third root field — happy to flatten it for consistency withthe surrounding style.
isHealthy: a database on sql.js still works, and turning workinginstallations red would change an existing check's verdict inside an observability change.
getDriverInfo()/setDriverInfo()insrc/lib/db/core.tsanswer a different question — howbetter-sqlite3 was resolved, not which driver is serving — and have no production caller.
Left untouched; removing or reviving them belongs in its own PR.
check-fabricated-docsallowlist entry is a pre-existing false positive that the brokenfence had been hiding, not a new violation: the unmodified file passes the gate, and the same
file with only the missing fence closed fails on
SQLITE_FULL.healthCheck.tscome from the repository's ownlint-stagedPrettier pass — the committed file predates the current formatting on thoselines.