Skip to content

feat(health): expose SQLite backup acknowledgment as a Prometheus gauge - #3462

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
bohdansolovie:feat/health-backup-acknowledged-gauge-2089-v2
Jul 5, 2026
Merged

feat(health): expose SQLite backup acknowledgment as a Prometheus gauge#3462
JSONbored merged 2 commits into
JSONbored:mainfrom
bohdansolovie:feat/health-backup-acknowledged-gauge-2089-v2

Conversation

@bohdansolovie

Copy link
Copy Markdown
Contributor

Summary

Fixes #2089

  • Add backupAcknowledgedGaugeValue() in health.ts, mirroring sqliteBackupAdvisory (1 on Postgres or when acknowledged, 0 when the advisory fires)
  • Register gittensory_backup_acknowledged at boot in server.ts alongside the other gauges
  • Add metric metadata and unit tests for all three input combinations
  • Regenerate selfhost-env-reference.ts after server.ts edits

Test plan

  • npm run selfhost:env-reference:check
  • Unit tests in test/unit/selfhost-health.test.ts cover SQLite unacknowledged (0), SQLite acknowledged (1), and Postgres (1)
  • CI validate-code

Made with Cursor

Fixes JSONbored#2089 — operators can alert on gittensory_backup_acknowledged instead of relying on boot logs alone.

Co-authored-by: Cursor <cursoragent@cursor.com>
@bohdansolovie
bohdansolovie requested a review from JSONbored as a code owner July 5, 2026 08:02
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-05 08:25:07 UTC

6 files · 1 AI reviewer · no blockers · readiness 80/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): src/selfhost/health.ts (matched src/selfhost/**), src/selfhost/metrics.ts (matched src/selfhost/**).

Review summary
The PR cleanly exposes the existing SQLite backup advisory state as a Prometheus gauge and keeps the runtime value tied to the same `sqliteBackupAdvisory` predicate, so the metric should stay consistent with the boot warning. The server registration captures the same boot-time options that produce the warning, which is appropriate because the backing env/config does not change during process lifetime. Metadata and unit coverage cover the three meaningful input combinations plus rendered metric output, and the generated env-reference churn is consistent with the `server.ts` line shifts.

Nits — 3 non-blocking
  • nit: `src/selfhost/health.ts:153` implements the metric by checking `sqliteBackupAdvisory(opts) === null`, which is nicely DRY but couples a numeric metric to a string-producing presentation helper; if the advisory later grows a non-safety warning, this gauge will silently inherit that semantics change.
  • Consider extracting a shared predicate in `src/selfhost/health.ts`, for example `sqliteBackupAdvisoryWouldFire(opts): boolean`, then have both `sqliteBackupAdvisory` and `backupAcknowledgedGaugeValue` call it so the metric stays tied to the boolean condition rather than the advisory string/null contract.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2089
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 287 registered-repo PR(s), 177 merged, 9 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bohdansolovie; Gittensor profile; 287 PR(s), 9 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Review context
  • Author: bohdansolovie
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 287 PR(s), 9 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Await review-lane availability.
  • Refresh registry data or choose a registered active repo.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (65de78e) to head (8b8842a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3462   +/-   ##
=======================================
  Coverage   93.01%   93.01%           
=======================================
  Files         297      297           
  Lines       31038    31039    +1     
  Branches    11319    11320    +1     
=======================================
+ Hits        28870    28871    +1     
  Misses       1513     1513           
  Partials      655      655           
Files with missing lines Coverage Δ
src/selfhost/health.ts 100.00% <100.00%> (ø)
src/selfhost/metrics.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 5, 2026
Covers the Prometheus registration path Orb flagged as untested on JSONbored#3462.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JSONbored
JSONbored merged commit c2ae12f into JSONbored:main Jul 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

feat(health): count boot-time SQLite backup advisory as a metric, not just a log line

2 participants