fix(selfhost): widen GitHub-native id columns to bigint on Postgres - #5060
Conversation
…ranch #5036's codecov/patch flagged one partial branch in processors.ts: matchedCommand === "ask" || matchedCommand === "chat" ? command.unrecognizedText : undefined. The 3 existing #4596 integration tests only ever reroute to "blockers", so the true side (rerouting to ask/chat specifically) was never exercised -- meaning the one behavior that actually matters here (does the contributor's original free text survive the reroute into the command's own question field, instead of silently dropping it) was untested.
Every migrations/*.sql column storing a raw GitHub-native numeric id (installation, account/user, check-run, comment) is declared bare INTEGER -- fine on SQLite/D1 (a type-affinity hint that already stores any 64-bit value), but a real 4-byte column on the self-host Postgres backend. GitHub's comment ids are already past 2^31, confirmed live on edge-nl-01 via a "value out of range for type integer" insert failure on github_agent_command_answers. widenGithubIdColumnsToBigint mirrors the existing tuneGithubRateLimitObservationsAutovacuum pattern: a Postgres-only, idempotent ALTER batch run unconditionally after migrations on every boot, never touching the original (SQLite/D1-correct) migration files. Closes #5059
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5060 +/- ##
=======================================
Coverage 94.13% 94.13%
=======================================
Files 465 465
Lines 39542 39542
Branches 14431 14431
=======================================
+ Hits 37222 37223 +1
Misses 1664 1664
+ Partials 656 655 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-11 11:52:09 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 2 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 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.
|
Summary
migrations/*.sqlcolumn storing a raw GitHub-native numeric id (installation, account/user, check-run, comment) is declared bareINTEGER-- correct on SQLite/D1 (a type-affinity hint, already stores any 64-bit value), but a real, enforced 4-byte column on the self-host Postgres backend.value "4945217685" is out of range for type integeron agithub_agent_command_answersinsert from a real@gittensory chatdispatch.widenGithubIdColumnsToBigint(src/selfhost/pg-adapter.ts) mirrors the existingtuneGithubRateLimitObservationsAutovacuumpattern exactly: a Postgres-only, idempotentALTER COLUMN ... TYPE bigintbatch across every affected table, run unconditionally after migrations on every boot. Never touches the original migration files (correct as written for SQLite/D1) -- purely additive.BEGIN; ...; ROLLBACK;) before being written into code. One originally-planned table,orb_installations, turned out to have been dropped by a later migration (fix(ci): isolate GitHub write token to release job #60, retiring that pipeline) -- caught this way rather than shipping a statement that would have silently sunk the whole batch (Postgres runs a multi-statement simple-query string as one implicit transaction, so a single unknown-relation error would have rolled back every other ALTER too).Closes #5059
Test plan
npm run typecheck-- cleantest/unit/selfhost-pg-adapter-github-id-widening.test.ts) mirroring the sibling autovacuum-tuning test file's exact shape -- mockedD1Database.exec(), no real Postgres needednpm run test:coverage(full, unsharded) -- 719 files / 14210 tests passed, 0 failuresnpm run test:ci(full gate) -- greennpm audit --audit-level=moderate-- 0 vulnerabilitiesALTERstatements dry-run validated against the live edge-nl-01 Postgres schema before mergesrc/selfhost/pg-adapter.tsandsrc/server.tsare both incodecov.yml's ignore list (Postgres runtime adapter / self-host process entry) -- patch-coverage gate does not block on this PR