Skip to content

fix(miner): scope governor_reputation_history by forge host, not bare repoFullName - #5591

Merged
JSONbored merged 1 commit into
mainfrom
forge-scope-governor-reputation
Jul 13, 2026
Merged

fix(miner): scope governor_reputation_history by forge host, not bare repoFullName#5591
JSONbored merged 1 commit into
mainfrom
forge-scope-governor-reputation

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • governor_reputation_history's repo_full_name TEXT PRIMARY KEY let two forge hosts (github.com vs. a GitHub Enterprise host, De-hardcode discovery from gittensory's own conventions #4784) serving a same-named owner/repo share one reputation-history row.
  • Rebuilds the constraint to PRIMARY KEY (api_base_url, repo_full_name), following governor-state.js's existing idempotent-ALTER convention (ensurePauseColumns) rather than introducing the applySchemaMigrations framework into this file for the first time.
  • Uses INSERT OR IGNORE for the copy step (a corrupted legacy row violating the rebuilt table's NOT NULL columns is dropped, not a migration-aborting crash), regression-tested the same way as run-state.js's Scope local ledger keys by forge host, not bare repoFullName #5563 fix in fix(miner): scope run-state by forge host, not bare repoFullName #5585.
  • Threads an optional apiBaseUrl through loadReputationHistory/saveReputationHistory. These have no real callers yet (attempt-runner.js's own comments note this governor input isn't wired into the attempt pipeline yet), so there's no CLI surface or call site to thread through — this is purely the storage-layer fix, mirroring openClaimLedgerReadOnly's scaffold-only precedent.

Fourth of 5 stores from #5563 (claim-ledger.js in #5576, portfolio-queue.js in #5583, run-state.js in #5585; deny-hook-synthesis.js remains).

Test plan

  • npx vitest run test/unit/miner-governor-state.test.ts — 34/34 passing, including a migration test, a cross-host coexistence test, an idempotent-reopen test, and a regression test proving INSERT OR IGNORE drops a corrupted legacy row instead of crashing the migration (mutation-tested: reverted the fix, confirmed the new test fails with the expected constraint error, restored and reconfirmed green)
  • npx tsc --noEmit clean
  • 100% patch coverage on touched lines/branches (verified via lcov diff against this PR's hunks)

… repoFullName

repo_full_name TEXT PRIMARY KEY let two forge hosts (github.com vs. a
GitHub Enterprise host, #4784) serving a same-named owner/repo share one
reputation-history row. Rebuild the constraint to
PRIMARY KEY (api_base_url, repo_full_name), following governor-state.js's
existing idempotent-ALTER convention (ensurePauseColumns) rather than
introducing the applySchemaMigrations framework into this file for the
first time -- a full PRIMARY KEY rebuild still needs the create-new/copy/
drop/rename dance, just gated by a column-presence check instead of a
version stamp.

Uses INSERT OR IGNORE for the copy step (a corrupted legacy row violating
the rebuilt table's NOT NULL columns is dropped, not a migration-aborting
crash), regression-tested the same way as run-state.js's #5563 fix.

Threads an optional apiBaseUrl through loadReputationHistory/
saveReputationHistory. loadReputationHistory/saveReputationHistory have no
real callers yet (attempt-runner.js's own comments note this governor
input isn't wired into the attempt pipeline yet), so there is no CLI
surface or call site to thread through -- this is purely the storage-layer
fix, mirroring openClaimLedgerReadOnly's scaffold-only precedent.

Advances #5563 (governor_reputation_history of 5 affected stores;
claim-ledger.js landed in #5576, portfolio-queue.js in #5583, run-state.js
in #5585; deny-hook-synthesis.js remains).
@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

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 1d869b6 Commit Preview URL

Branch Preview URL
Jul 13 2026, 07:37 AM

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.01%. Comparing base (b1d3e8d) to head (1d869b6).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5591   +/-   ##
=======================================
  Coverage   95.01%   95.01%           
=======================================
  Files         573      573           
  Lines       45534    45547   +13     
  Branches    14680    14680           
=======================================
+ Hits        43263    43278   +15     
+ Misses       1520     1518    -2     
  Partials      751      751           
Flag Coverage Δ
shard-1 44.04% <45.00%> (-0.01%) ⬇️
shard-2 35.71% <100.00%> (+0.03%) ⬆️
shard-3 31.93% <0.00%> (-0.24%) ⬇️
shard-4 31.77% <45.00%> (-1.07%) ⬇️
shard-5 32.92% <0.00%> (+1.07%) ⬆️
shard-6 44.40% <45.00%> (+0.21%) ⬆️

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

Files with missing lines Coverage Δ
packages/gittensory-miner/lib/governor-state.js 93.45% <100.00%> (+3.03%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored self-assigned this Jul 13, 2026
@JSONbored
JSONbored merged commit 968a838 into main Jul 13, 2026
19 checks passed
@JSONbored
JSONbored deleted the forge-scope-governor-reputation branch July 13, 2026 07:44
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 13, 2026
JSONbored added a commit that referenced this pull request Jul 13, 2026
…re repoFullName (#5595)

deny_rule_proposals' PRIMARY KEY (repo_full_name, id) let two forge hosts
(github.com vs. a GitHub Enterprise host, #4784) serving a same-named
owner/repo share one proposal row (and its maintainer approval decision).
Rebuild the constraint to PRIMARY KEY (api_base_url, repo_full_name, id).

This file has no schema-version framework of its own (unlike the
package's other local stores) -- it uses a raw DatabaseSync connection, no
applySchemaMigrations. Follows governor-state.js's idempotent
column-presence-gated rebuild convention instead of introducing a new
framework dependency here for the first time. Uses INSERT OR IGNORE for
the copy step, matching the fix already applied to every other #5563
migration in this epic: a legacy row with an already-invalid status value
(this store's own CHECK-constrained schema already rejects those) is
dropped, not a migration-aborting crash.

Threads an optional apiBaseUrl through refreshProposals/listProposals/
setProposalStatus/resolveEffectiveRules. initDenyHookSynthesisStore has no
real callers yet (feeds the consumption surface #2343 will eventually wire
into evaluateDenyHooks; this store owns derivation + audit, not live hook
interception), so there is no CLI surface or call site to thread through --
purely the storage-layer fix, mirroring governor_reputation_history's
scaffold-only precedent.

Closes #5563 (5th and final store: claim-ledger.js in #5576,
portfolio-queue.js in #5583, run-state.js in #5585, governor-state.js in
#5591, plus the claimNextBatch/migration hardening follow-up in #5594).
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.

Development

Successfully merging this pull request may close these issues.

1 participant