Skip to content

fix: preserve diagnostic runtime and failure facts - #1145

Merged
bcdonadio merged 1 commit into
mainfrom
fix/1122-1124-diagnostic-boundaries
Sep 7, 2026
Merged

bcdonadio merged 1 commit into
mainfrom
fix/1122-1124-diagnostic-boundaries

Conversation

@bcdonadio

Copy link
Copy Markdown
Contributor

Summary

Preserve the three distinct diagnostic boundaries reported after Feature #619: worker startup on early Node 22, SQLite pool observations across timeouts, and known backend identity in route error responses.

Motivation / Why

A source worker could exit before sending IPC results because its sanitized launch omitted runtime feature flags. A stalled SQLite diagnostic discarded independently observed pool counts. Unexpected stats-route failures also replaced the known SQLite/PostgreSQL backend with unavailable.

The fixes preserve the child's explicit environment/argument boundary, return pool counters only after publication witnesses authenticate, and keep exception payloads out of responses. These were candidate-only findings at the S5 freeze fc81b371; Feature #619 subsequently merged in PR #1103, and each defect was verified on the follow-up's main-branch base.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Chore / infra / config
  • Documentation

Release-note title

fix: preserve diagnostic runtime and failure facts

Testing done

Validation: 161 focused acceptance tests and 312 tests across 15 direct integration files passed; typecheck, lint, build/runtime/package verification passed. Real source-worker tests (6/6) and a compiled-worker SQL roundtrip passed under Node 22.22.2. The exact Node 22.12 runtime was unavailable; explicit fork-argument assertions cover its required SQLite/type-stripping flags. Complete coverage remains the fresh exact-head CI gate.

Three independent acceptance rows:

Bug Acceptance
#1122 Both fork modes use explicit source/compiled flags and keep the empty child environment without inheriting preloads.
#1123 Stalled SQLite probes retain safe pool counts after matching witnesses, discard them on changed/refused publication, and preserve caller-owned resources.
#1124 Both stats routes preserve known backends on sanitized generic failures, retain structured diagnostic failures, and report unavailable when no backend is known.

Start review with the worker launch arguments, then the collector's pre-await pool capture and timeout witness guard, and finally the two route fallback branches. Relevant end-user guidance and a patch Changeset accompany the fixes.

Related issues

Closes #1122
Closes #1123
Closes #1124

Checklist

  • DB access only via getLcmConnection()/closeLcmConnection() — no direct DatabaseSync
  • New connections set PRAGMA journal_mode=WAL and PRAGMA foreign_keys=ON
  • No implicit any — all types explicit
  • collectStats() not called in request handlers or hot paths
  • New routes have tests in test/daemon/routes/
  • Multi-step writes use transactions
  • Schema migrations are additive only
  • Relevant local tests pass: pnpm exec vitest run <test-files>
  • Fresh exact-head CI passes pnpm run test:ci with 100% line, branch, function, and statement coverage
  • Dependency changes use exact versions and update pnpm-lock.yaml; pnpm install --frozen-lockfile succeeds

No new routes, connections, schema writes, or dependencies are introduced. Existing Codecov component ownership remains unchanged. The existing stats handlers continue to call collectStats(); this fix changes only their generic error response.

Run SQLite diagnostic workers with explicit source and compiled flags so the
minimum Node 22.12 runtime can execute either asset without inheriting parent
arguments or environment.

Capture safe SQLite pool counts before bounded reads, retain them only after
witness reauthentication, and keep failed route snapshots tied to the
configured backend.

Signed-off-by: Bernardo Donadio <[email protected]>
Copilot AI lite review requested due to automatic review settings September 7, 2026 03:08
@bcdonadio bcdonadio self-assigned this Sep 7, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-07T03:16:33.481025Z ca4502e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes correctly preserve the intended diagnostic boundaries and are backed by targeted tests and documentation updates without introducing unsafe error serialization or resource-ownership regressions.

Pull request overview

This PR fixes regressions introduced after Feature #619 by preserving three diagnostic “fact boundaries” across failures/timeouts: Node runtime flags needed for TypeScript SQLite workers on early Node 22, independently observed SQLite pool counters across bounded timeouts (when publication still authenticates), and the known configured backend identity in sanitized stats-route fallback responses.

Changes:

  • Ensure SQLite diagnostic child processes receive explicit Node execArgv flags based on whether the worker asset is TypeScript (.ts) or compiled JavaScript (.js), while still using an empty child environment.
  • Preserve independently observed SQLite pool counters across timeouts only when publication witness re-authenticates, and avoid leaking per-connection paths.
  • Keep the configured backend identity in stats / stats --pool generic error fallbacks without serializing exception payloads.
File summaries
File Description
src/db/diagnostic-sqlite.ts Adds execArgv selection so TS workers run with required Node flags while keeping isolated env/exec args.
src/storage/diagnostics.ts Captures SQLite pool counters pre-await, returns them only after witness re-check on timeout, and avoids exposing connection paths.
src/daemon/routes/stats.ts Preserves known backend identity in sanitized fallback diagnostics.
src/daemon/routes/pool-stats.ts Preserves known backend identity in sanitized fallback diagnostics.
test/db/diagnostic-sqlite-lifecycle.test.ts Adds assertions covering worker path selection and per-mode execArgv isolation for both fork modes.
test/storage/diagnostics.test.ts Adds coverage for SQLite pool counter retention/discard rules across stalls/timeouts and redaction expectations.
test/daemon/routes/persistence-read-boundaries.test.ts Verifies route fallbacks retain configured backend identity across sanitized failures.
docs/development.md Documents the explicit diagnostic worker launch flags and the empty-env/no-preload boundary.
docs/cli.md Documents SQLite pool counter retention semantics and backend identity preservation on unexpected route failures.
.changeset/steady-diagnostics-boundaries.md Adds a patch changeset describing the diagnostic boundary fixes.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@bcdonadio
bcdonadio merged commit 6a18f63 into main Sep 7, 2026
22 checks passed
@bcdonadio
bcdonadio deleted the fix/1122-1124-diagnostic-boundaries branch September 7, 2026 03:14
@bcdonadio bcdonadio added this to the Hardening Target 2 milestone Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants