Skip to content

feat(calibration): self-host Postgres parity for every calibration surface + pg-capable maintainer CLIs - #8191

Merged
JSONbored merged 2 commits into
mainfrom
feat/selfhost-pg-calibration-parity
Jul 23, 2026
Merged

feat(calibration): self-host Postgres parity for every calibration surface + pg-capable maintainer CLIs#8191
JSONbored merged 2 commits into
mainfrom
feat/selfhost-pg-calibration-parity

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

What

Pins the #8082 calibration system against real Postgres (#8171): a PG_TEST_URL-gated integration suite (now part of the selfhost CI job) exercises every calibration surface through the selfhost shim, and the three maintainer CLIs gain a --pg driver.

The suite caught two real self-host bugs (fixed in pg-dialect.ts)

  • date(<expr>) reached Postgres untranslated: it 'works' via an implicit cast but returns a date-typed value node-pg parses into a JS Date, so every day-bucketed trend read (calibration trend, public accuracy/volume/reuse trends, stats) silently bucketed nothing on self-host. Now translated to a TEXT YYYY-MM-DD day, exactly what D1 returns.
  • Nested json_extract paths ($.comparison.verdict) were untranslated hard errors swallowed by the fail-safe reads — the persisted backtest runs were invisible to the trend. Now translated to jsonb #>>.

Because every one of these paths degrades silently, the suite asserts non-empty results, never just "didn't throw": capture writers (incl. raw-context metadata round-trip), threshold-backtest persistence, the calibration trend, the satisfaction-floor status surface, and the loosening loop's system_flags write path — all against a real Postgres 16.

CLI parity

backtest-corpus-export, backtest-track-record, and backfill-calibration-corpus accept --pg <conn> (bare --pg falls back to DATABASE_URL, mirroring the selfhost stack's own driver pick; without --pg, D1 stays the default — the env var never silently switches drivers). The pg path reuses createPgAdapter, so the SQL and the idempotency contracts are byte-identical to the Worker's; pure cores untouched. The backfill's confidence projection now coerces the TEXT that ->> returns instead of type-gating it. Corpus manifests name the database only, never connection-string credentials.

Verified end-to-end against a live Postgres: dry-run report → idempotent apply → checksummed corpus export → track-record read. Docs page gains a self-hosting section.

Validation

Full npm run test:ci green locally with PG_TEST_URL set (both pg suites ran for real, 1118 test files); 100% branch coverage on the touched src/selfhost/pg-dialect.ts lines.

Closes #8171

Comment thread .github/workflows/selfhost.yml Outdated
@superagent-security superagent-security Bot added the pr:flagged PR flagged for review by security analysis. label Jul 23, 2026
@JSONbored JSONbored self-assigned this Jul 23, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui 6ada01a Commit Preview URL

Branch Preview URL
Jul 23 2026, 10:51 AM

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 5.69kB (0.08%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
loopover-ui 7.39MB 5.69kB (0.08%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: loopover-ui

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/add-scalar-classes-BEFXL-Xv.js (New) 2.17MB 2.17MB 100.0% 🚀
assets/tanstack-vendor-B5E0Mw3G.js (New) 739.41kB 739.41kB 100.0% 🚀
assets/docs.fumadocs-spike-api-reference-gNRr5tSU.js (New) 442.92kB 442.92kB 100.0% 🚀
assets/AgentScalarChatInterface.vue-Bg3lzU6o.js (New) 201.71kB 201.71kB 100.0% 🚀
assets/modal-5Orn6OwO.js (New) 184.38kB 184.38kB 100.0% 🚀
assets/client-akdGdFzJ.js (New) 146.06kB 146.06kB 100.0% 🚀
assets/maintainer-panel-DX9s_VhY.js (New) 78.99kB 78.99kB 100.0% 🚀
assets/ui-vendor-Cq0hpH0V.js (New) 57.04kB 57.04kB 100.0% 🚀
assets/routes-CGkeb7Yk.js (New) 34.98kB 34.98kB 100.0% 🚀
assets/owner-panel-DeIGxWX3.js (New) 27.36kB 27.36kB 100.0% 🚀
assets/app-D2Z8O4W1.js (New) 25.7kB 25.7kB 100.0% 🚀
assets/app.runs-7bkWogW7.js (New) 23.56kB 23.56kB 100.0% 🚀
assets/miner-panel--bxnGYX1.js (New) 20.28kB 20.28kB 100.0% 🚀
assets/backtest-calibration-TKigdVya.js (New) 20.23kB 20.23kB 100.0% 🚀
assets/api._op-BAQR-L_n.js (New) 17.57kB 17.57kB 100.0% 🚀
assets/self-hosting-docs-audit-DPop5QlX.js (New) 16.61kB 16.61kB 100.0% 🚀
assets/app.index-tVjQC5cc.js (New) 15.62kB 15.62kB 100.0% 🚀
assets/docs._slug-CPZ5_BpD.js (New) 15.22kB 15.22kB 100.0% 🚀
assets/playground-panel-B5kART-f.js (New) 14.49kB 14.49kB 100.0% 🚀
assets/app.audit-CXZkzSdn.js (New) 10.11kB 10.11kB 100.0% 🚀
assets/app.config-generator-8iGenh5M.js (New) 10.09kB 10.09kB 100.0% 🚀
assets/extension-BCQUODMn.js (New) 10.04kB 10.04kB 100.0% 🚀
assets/fairness-DgVr3aR6.js (New) 8.34kB 8.34kB 100.0% 🚀
assets/maintainers-B6u5gPft.js (New) 8.09kB 8.09kB 100.0% 🚀
assets/miners-CHU0dj98.js (New) 7.91kB 7.91kB 100.0% 🚀
assets/agents-BCK957V-.js (New) 7.8kB 7.8kB 100.0% 🚀
assets/commands-panel-ZDcHWktm.js (New) 6.65kB 6.65kB 100.0% 🚀
assets/maintainer-workflow-mArRMbjT.js (New) 6.52kB 6.52kB 100.0% 🚀
assets/roadmap-B-7GEgTK.js (New) 6.33kB 6.33kB 100.0% 🚀
assets/digest-panel-BOYaK4OU.js (New) 6.18kB 6.18kB 100.0% 🚀
assets/repos._owner._repo.quality-Op965Xyn.js (New) 6.14kB 6.14kB 100.0% 🚀
assets/docs.index-ChUEh1uZ.js (New) 5.73kB 5.73kB 100.0% 🚀
assets/docs-nav-mU_OqEnL.js (New) 5.53kB 5.53kB 100.0% 🚀
assets/api.index-DhyoKH5s.js (New) 4.7kB 4.7kB 100.0% 🚀
assets/docs-yL-98rTJ.js (New) 2.7kB 2.7kB 100.0% 🚀
assets/api-HAz1YM97.js (New) 2.69kB 2.69kB 100.0% 🚀
assets/docs-page-D9xFWdzC.js (New) 2.1kB 2.1kB 100.0% 🚀
assets/table-CqBV7EFC.js (New) 1.75kB 1.75kB 100.0% 🚀
assets/app.workbench-DaQkhT7k.js (New) 1.58kB 1.58kB 100.0% 🚀
assets/session-DVa6QQSi.js (New) 1.45kB 1.45kB 100.0% 🚀
assets/tooltip-DPgFUOmo.js (New) 1.45kB 1.45kB 100.0% 🚀
assets/tabs-TaoMgHJI.js (New) 1.39kB 1.39kB 100.0% 🚀
assets/app.repos-BWaPafzS.js (New) 1.07kB 1.07kB 100.0% 🚀
assets/input-A4xxembx.js (New) 796 bytes 796 bytes 100.0% 🚀
assets/file-cog-DXcKtGDO.js (New) 758 bytes 758 bytes 100.0% 🚀
assets/app.maintainer-DtvuOHeZ.js (New) 502 bytes 502 bytes 100.0% 🚀
assets/sparkles-CVm9qI5Q.js (New) 494 bytes 494 bytes 100.0% 🚀
assets/app.owner-D6E-VqtZ.js (New) 474 bytes 474 bytes 100.0% 🚀
assets/app.commands-BwX4SI-f.js (New) 455 bytes 455 bytes 100.0% 🚀
assets/app.playground-B_wCwjAZ.js (New) 442 bytes 442 bytes 100.0% 🚀
assets/reveal-hpNFrQgX.js (New) 442 bytes 442 bytes 100.0% 🚀
assets/index-WsIC1Tcy.js (New) 438 bytes 438 bytes 100.0% 🚀
assets/app.digest-LzZNWaj0.js (New) 430 bytes 430 bytes 100.0% 🚀
assets/eye-off-DtljPjaD.js (New) 430 bytes 430 bytes 100.0% 🚀
assets/app.miner-Bl7W7XjS.js (New) 422 bytes 422 bytes 100.0% 🚀
assets/key-round-CPt4qxv4.js (New) 355 bytes 355 bytes 100.0% 🚀
assets/bot-PUS0nEwp.js (New) 328 bytes 328 bytes 100.0% 🚀
assets/trash-2-dmSpCC3-.js (New) 328 bytes 328 bytes 100.0% 🚀
assets/save-CAtvrG_P.js (New) 327 bytes 327 bytes 100.0% 🚀
assets/git-pull-request-arrow-CLEfxAjA.js (New) 321 bytes 321 bytes 100.0% 🚀
assets/wrench-C13D2uGJ.js (New) 303 bytes 303 bytes 100.0% 🚀
assets/list-checks-CvVuR9zC.js (New) 279 bytes 279 bytes 100.0% 🚀
assets/shield-B0HP-i3z.js (New) 272 bytes 272 bytes 100.0% 🚀
assets/workflow-DOV6oOqI.js (New) 265 bytes 265 bytes 100.0% 🚀
assets/compass-Cruemh2E.js (New) 251 bytes 251 bytes 100.0% 🚀
assets/history-BX1Nq27R.js (New) 237 bytes 237 bytes 100.0% 🚀
assets/activity-BW0yyWGR.js (New) 234 bytes 234 bytes 100.0% 🚀
assets/message-square-CgdU3nxu.js (New) 233 bytes 233 bytes 100.0% 🚀
assets/lock-ox3pXMQW.js (New) 206 bytes 206 bytes 100.0% 🚀
assets/rotate-cw-DbyvpSMY.js (New) 201 bytes 201 bytes 100.0% 🚀
assets/play-BL-l7GP8.js (New) 190 bytes 190 bytes 100.0% 🚀
assets/circle-check-BOMxcAjv.js (New) 178 bytes 178 bytes 100.0% 🚀
assets/search-CFiXa82M.js (New) 174 bytes 174 bytes 100.0% 🚀
assets/circle-DbCDAhMi.js (New) 130 bytes 130 bytes 100.0% 🚀
assets/add-scalar-classes-BhI3IvhW.js (Deleted) -2.17MB 0 bytes -100.0% 🗑️
assets/tanstack-vendor-DkoUveDM.js (Deleted) -739.41kB 0 bytes -100.0% 🗑️
assets/docs.fumadocs-spike-api-reference-Dxt1Y9lD.js (Deleted) -442.92kB 0 bytes -100.0% 🗑️
assets/AgentScalarChatInterface.vue-DTAazoyL.js (Deleted) -201.71kB 0 bytes -100.0% 🗑️
assets/modal-Bf_Zpm3T.js (Deleted) -184.38kB 0 bytes -100.0% 🗑️
assets/client-ddSpzg2m.js (Deleted) -146.06kB 0 bytes -100.0% 🗑️
assets/maintainer-panel-4P_YZwUh.js (Deleted) -78.99kB 0 bytes -100.0% 🗑️
assets/ui-vendor-z3Updml2.js (Deleted) -57.04kB 0 bytes -100.0% 🗑️
assets/routes-BR4CRaYB.js (Deleted) -34.98kB 0 bytes -100.0% 🗑️
assets/owner-panel-zoJh4hoL.js (Deleted) -27.36kB 0 bytes -100.0% 🗑️
assets/app-CJ3KjKH2.js (Deleted) -25.7kB 0 bytes -100.0% 🗑️
assets/app.runs-BtUfGM_D.js (Deleted) -23.56kB 0 bytes -100.0% 🗑️
assets/miner-panel-NYQZozdd.js (Deleted) -20.28kB 0 bytes -100.0% 🗑️
assets/api._op-BRYi9R6D.js (Deleted) -17.57kB 0 bytes -100.0% 🗑️
assets/self-hosting-docs-audit-OPoeBFlk.js (Deleted) -16.61kB 0 bytes -100.0% 🗑️
assets/app.index-C2ji5Xif.js (Deleted) -15.62kB 0 bytes -100.0% 🗑️
assets/docs._slug-CAaMdFW3.js (Deleted) -15.22kB 0 bytes -100.0% 🗑️
assets/backtest-calibration-DCMstYSV.js (Deleted) -14.54kB 0 bytes -100.0% 🗑️
assets/playground-panel-IDepM8TS.js (Deleted) -14.49kB 0 bytes -100.0% 🗑️
assets/app.audit-CuaxN99L.js (Deleted) -10.11kB 0 bytes -100.0% 🗑️
assets/app.config-generator-C8Bl3-d_.js (Deleted) -10.09kB 0 bytes -100.0% 🗑️
assets/extension-BjO9X9NR.js (Deleted) -10.04kB 0 bytes -100.0% 🗑️
assets/fairness-Cwxieb7f.js (Deleted) -8.34kB 0 bytes -100.0% 🗑️
assets/maintainers-CmDQ4jNk.js (Deleted) -8.09kB 0 bytes -100.0% 🗑️
assets/miners-CpzkQbSi.js (Deleted) -7.91kB 0 bytes -100.0% 🗑️
assets/agents-hcezP3XR.js (Deleted) -7.8kB 0 bytes -100.0% 🗑️
assets/commands-panel-Jo1THXis.js (Deleted) -6.65kB 0 bytes -100.0% 🗑️
assets/maintainer-workflow-DD23sLZx.js (Deleted) -6.52kB 0 bytes -100.0% 🗑️
assets/roadmap-B71kAesr.js (Deleted) -6.33kB 0 bytes -100.0% 🗑️
assets/digest-panel-VhYEq89W.js (Deleted) -6.18kB 0 bytes -100.0% 🗑️
assets/repos._owner._repo.quality-B6gpAzAt.js (Deleted) -6.14kB 0 bytes -100.0% 🗑️
assets/docs.index-BeV2GpjD.js (Deleted) -5.73kB 0 bytes -100.0% 🗑️
assets/docs-nav-heAGhHxR.js (Deleted) -5.53kB 0 bytes -100.0% 🗑️
assets/api.index-CiqCPlOu.js (Deleted) -4.7kB 0 bytes -100.0% 🗑️
assets/docs-DVtsa2NP.js (Deleted) -2.7kB 0 bytes -100.0% 🗑️
assets/api-DPNUjGHf.js (Deleted) -2.69kB 0 bytes -100.0% 🗑️
assets/docs-page-BTQxvtqk.js (Deleted) -2.1kB 0 bytes -100.0% 🗑️
assets/table-COi6zBD0.js (Deleted) -1.75kB 0 bytes -100.0% 🗑️
assets/app.workbench-CG5cd3Uh.js (Deleted) -1.58kB 0 bytes -100.0% 🗑️
assets/session-DoKDWDP2.js (Deleted) -1.45kB 0 bytes -100.0% 🗑️
assets/tooltip-CXoKwQU9.js (Deleted) -1.45kB 0 bytes -100.0% 🗑️
assets/tabs-DjauiZEL.js (Deleted) -1.39kB 0 bytes -100.0% 🗑️
assets/app.repos-CL0YfLi3.js (Deleted) -1.07kB 0 bytes -100.0% 🗑️
assets/input-k7g6PPV9.js (Deleted) -796 bytes 0 bytes -100.0% 🗑️
assets/file-cog-JhMEEoFM.js (Deleted) -758 bytes 0 bytes -100.0% 🗑️
assets/app.maintainer-CeTBmcZ_.js (Deleted) -502 bytes 0 bytes -100.0% 🗑️
assets/sparkles-Bahr8PuY.js (Deleted) -494 bytes 0 bytes -100.0% 🗑️
assets/app.owner-BatTQR_7.js (Deleted) -474 bytes 0 bytes -100.0% 🗑️
assets/app.commands-BAW7Cicy.js (Deleted) -455 bytes 0 bytes -100.0% 🗑️
assets/app.playground-U0HkTBiT.js (Deleted) -442 bytes 0 bytes -100.0% 🗑️
assets/reveal-BRL7MSXQ.js (Deleted) -442 bytes 0 bytes -100.0% 🗑️
assets/index-Bbr7ozVK.js (Deleted) -438 bytes 0 bytes -100.0% 🗑️
assets/app.digest-Bke0zaBp.js (Deleted) -430 bytes 0 bytes -100.0% 🗑️
assets/eye-off-DiTKHtqi.js (Deleted) -430 bytes 0 bytes -100.0% 🗑️
assets/app.miner-DR9dCohC.js (Deleted) -422 bytes 0 bytes -100.0% 🗑️
assets/key-round-D8lpBD0H.js (Deleted) -355 bytes 0 bytes -100.0% 🗑️
assets/bot-CtuyDQ2E.js (Deleted) -328 bytes 0 bytes -100.0% 🗑️
assets/trash-2-SDJOxpk2.js (Deleted) -328 bytes 0 bytes -100.0% 🗑️
assets/save-ALrslo9p.js (Deleted) -327 bytes 0 bytes -100.0% 🗑️
assets/git-pull-request-arrow-EpOpiQB9.js (Deleted) -321 bytes 0 bytes -100.0% 🗑️
assets/wrench-yv8GoAJx.js (Deleted) -303 bytes 0 bytes -100.0% 🗑️
assets/list-checks-qGNtZBjj.js (Deleted) -279 bytes 0 bytes -100.0% 🗑️
assets/shield-DkATb6Jc.js (Deleted) -272 bytes 0 bytes -100.0% 🗑️
assets/workflow-B-f2WWvQ.js (Deleted) -265 bytes 0 bytes -100.0% 🗑️
assets/compass-Bea1UrrN.js (Deleted) -251 bytes 0 bytes -100.0% 🗑️
assets/history-FAOhbQA4.js (Deleted) -237 bytes 0 bytes -100.0% 🗑️
assets/activity-Bm01L1bs.js (Deleted) -234 bytes 0 bytes -100.0% 🗑️
assets/message-square-CKeqbxhA.js (Deleted) -233 bytes 0 bytes -100.0% 🗑️
assets/lock-C3JtoRFs.js (Deleted) -206 bytes 0 bytes -100.0% 🗑️
assets/rotate-cw-C3qsPd46.js (Deleted) -201 bytes 0 bytes -100.0% 🗑️
assets/play-CktU5t01.js (Deleted) -190 bytes 0 bytes -100.0% 🗑️
assets/circle-check-CRJjqdQ2.js (Deleted) -178 bytes 0 bytes -100.0% 🗑️
assets/search-83Q37kfG.js (Deleted) -174 bytes 0 bytes -100.0% 🗑️
assets/circle-CVxTi9dh.js (Deleted) -130 bytes 0 bytes -100.0% 🗑️

@superagent-security

Copy link
Copy Markdown
Contributor

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

@superagent-security superagent-security Bot removed the pr:flagged PR flagged for review by security analysis. label Jul 23, 2026
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.07%. Comparing base (9d021ad) to head (6ada01a).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8191   +/-   ##
=======================================
  Coverage   92.07%   92.07%           
=======================================
  Files         771      771           
  Lines       77942    77943    +1     
  Branches    23545    23546    +1     
=======================================
+ Hits        71767    71768    +1     
  Misses       5062     5062           
  Partials     1113     1113           
Flag Coverage Δ
shard-1 54.82% <100.00%> (-3.67%) ⬇️
shard-2 51.58% <0.00%> (+1.82%) ⬆️
shard-3 56.35% <0.00%> (+1.51%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/selfhost/pg-dialect.ts 100.00% <100.00%> (ø)

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

loopover-orb Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-23 10:13:53 UTC

10 files · 1 AI reviewer · no blockers · CI failing · blocked

🛑 Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): .github/workflows/selfhost.yml (matched .github/workflows/**).

Review summary
This PR pins the #8082 calibration system to real Postgres and fixes two genuine self-host correctness bugs in pg-dialect.ts: date() was returning a JS Date object instead of the TEXT day D1 returns (silently zeroing every trend bucket), and nested json_extract paths were untranslated hard errors swallowed by fail-safe reads. Both fixes are traced to the actual root-cause layer (the dialect translator, not a downstream symptom) and are pinned by both a unit suite (selfhost-pg-dialect.test.ts) and a new real-Postgres integration suite (selfhost-pg-calibration.test.ts) that asserts non-empty results rather than merely 'didn't throw' — the right test posture for silently-degrading paths. The three CLI --pg additions and the backfill's toFiniteNumber coercion (Postgres ->> always returns text) are consistent, mirror the selfhost stack's own DATABASE_URL fallback, and correctly reuse createPgAdapter rather than a second SQL implementation.

Nits — 7 non-blocking
  • scripts/backtest-corpus-export.ts:181, scripts/backtest-track-record.ts:93, and scripts/backfill-calibration-corpus.ts (run()) each define a near-identical local pgQuery/execute wrapper around openPgDatabase — worth folding into pg-cli.ts to avoid the triplication.
  • The nested json_extract regex in src/selfhost/pg-dialect.ts:72 nests a quantifier inside a quantified group, but since the inner character class excludes the literal '.' separator, there's no actual catastrophic-backtracking hazard here, and the input is developer-authored SQL text, not attacker-controlled — flagged externally as ReDoS but not a real risk on this path.
  • scripts/pg-cli.ts:43's OID `20` for the int8 type parser is unexplained at the call site; a named constant (or a comment, which the sibling test files already have) would help future readers.
  • Consolidate the repeated pgQuery/execute helper (scripts/backtest-corpus-export.ts, backtest-track-record.ts, backfill-calibration-corpus.ts) into scripts/pg-cli.ts as a shared exported function.
  • Consider naming the int8 OID constant in scripts/pg-cli.ts:43 (e.g. `const PG_OID_INT8 = 20`) to match the inline comment's intent.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.

CI checks failing

  • validate
  • validate-tests (1)
  • validate-tests (2)

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ⚠️ Gate result — Not blocking (Advisory; not blocking this PR.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8171
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 ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 14 registered-repo PR(s), 14 merged, 260 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 14 PR(s), 260 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: significant
Linked issue satisfaction

Addressed
The PR adds a PG_TEST_URL-gated integration suite covering capture writers, backtest persistence, calibration trend, satisfaction-floor status, and the loosening loop's system_flags, wired into the selfhost CI workflow against real Postgres, plus fixes two real dialect bugs (date() and nested json_extract) found by that suite. It also adds a shared pg-cli.ts thin-IO wrapper reused by all three CLI

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, Ruby, Go, JavaScript, MDX, Shell, Solidity
  • Official Gittensor activity: 14 PR(s), 260 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before /
before /
after /
after /
/ mobile before / (mobile)
before / (mobile)
after / (mobile)
after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

Scroll preview
Route Before (production) After (this PR's preview)
/ before / (scroll)
before / (scroll)
after / (scroll)
after / (scroll)

A short scroll-through clip (desktop) — click either thumbnail to open the full animation. Evidence for scroll-linked behavior a single screenshot can't show.

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 23, 2026
@JSONbored
JSONbored force-pushed the feat/selfhost-pg-calibration-parity branch from c67337e to 294d343 Compare July 23, 2026 10:33
…rface + pg-capable maintainer CLIs

Pins #8082's calibration system against real Postgres (#8171): a PG_TEST_URL-gated
integration suite exercises the capture writers (incl. raw-context metadata),
threshold-backtest persistence, the calibration trend, the satisfaction-floor
status surface, and the loosening loop's system_flags write path through the
selfhost shim — asserting non-empty results, since every one of these paths
degrades silently on a dialect gap.

The suite caught two real self-host bugs, both fixed in pg-dialect:
- date(<expr>) reached Postgres as a date-typed value node-pg parses into a JS
  Date, so every day-bucketed trend read bucketed nothing; now translated to a
  TEXT day like SQLite returns.
- nested json_extract paths ($.comparison.verdict) were untranslated hard
  errors swallowed by fail-safe reads; now translated to jsonb #>>.

The three maintainer CLIs (corpus export, track record, backfill) accept --pg
(bare --pg falls back to DATABASE_URL, mirroring the selfhost stack's own
driver pick) and reuse createPgAdapter — same dialect translation as the
deployed Worker, pure cores untouched. The backfill wrapper's confidence
projection now coerces the text ->> returns instead of type-gating it. Verified
end-to-end against a real Postgres: dry-run report, idempotent apply, checksummed
export (manifest names the database, never credentials), track-record read.

Closes #8171
…waway password

The scanner flagged the literal in the test step. It is deliberately not a
repository secret — the service container is job-scoped, localhost-only, and
holds synthetic rows — but the credential now lives in ONE documented job-level
env var consumed by both the service definition and the test step, so the two
can never drift and the intent is explicit at the definition site.
@JSONbored
JSONbored force-pushed the feat/selfhost-pg-calibration-parity branch from 294d343 to 6ada01a Compare July 23, 2026 10:49
@JSONbored
JSONbored merged commit f5993e8 into main Jul 23, 2026
18 checks passed
@JSONbored
JSONbored deleted the feat/selfhost-pg-calibration-parity branch July 23, 2026 11:05
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calibration: self-host Postgres parity — verify every calibration surface on the pg shim + pg-capable corpus/track-record/backfill CLIs

1 participant