Skip to content

fix(miner): scope deny-hook synthesis proposals by forge host, not bare repoFullName - #5595

Merged
JSONbored merged 1 commit into
mainfrom
forge-scope-deny-hook-synthesis
Jul 13, 2026
Merged

fix(miner): scope deny-hook synthesis proposals by forge host, not bare repoFullName#5595
JSONbored merged 1 commit into
mainfrom
forge-scope-deny-hook-synthesis

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Fifth and final store from #5563. Series: claim-ledger.js in #5576, portfolio-queue.js in #5583, run-state.js in #5585, governor-state.js's reputation table in #5591, claimNextBatch/migration-hardening follow-up in #5594.

Scope note carried from every PR in this series: full end-to-end forge-threading through the attempt/loop pipeline (attempt-cli.js, loop-cli.js never resolve apiBaseUrl for these stores' write paths at all today) remains a separate, pre-existing gap outside #5563's boundary — the schema-level collision risk (the actual defect #5563 tracks) is now fully closed across all 5 stores.

Closes #5563

Test plan

  • npx vitest run test/unit/miner-deny-hook-synthesis.test.ts — 13/13 passing, including a migration test, a cross-host coexistence test, a resolveEffectiveRules apiBaseUrl-threading test, and a regression test proving INSERT OR IGNORE drops a corrupted legacy row instead of crashing the migration
  • npx tsc --noEmit clean
  • npm run build:miner clean
  • npx vitest run test/unit/miner-*.test.ts — 1645/1645 passing
  • 100% patch coverage on touched lines/branches (verified via lcov diff against this PR's hunks)

…re repoFullName

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).
@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 0ea1161 Commit Preview URL

Branch Preview URL
Jul 13 2026, 07:50 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 (eb2880d) to head (0ea1161).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5595   +/-   ##
=======================================
  Coverage   95.01%   95.01%           
=======================================
  Files         573      573           
  Lines       45546    45560   +14     
  Branches    14661    14661           
=======================================
+ Hits        43277    43291   +14     
  Misses       1518     1518           
  Partials      751      751           
Flag Coverage Δ
shard-1 44.04% <0.00%> (-0.03%) ⬇️
shard-2 35.73% <100.00%> (+0.02%) ⬆️
shard-3 31.92% <0.00%> (-0.24%) ⬇️
shard-4 31.77% <0.00%> (-1.09%) ⬇️
shard-5 32.91% <0.00%> (+1.07%) ⬆️
shard-6 44.38% <0.00%> (+0.19%) ⬆️

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

Files with missing lines Coverage Δ
...ckages/gittensory-miner/lib/deny-hook-synthesis.js 94.26% <100.00%> (+0.56%) ⬆️
🚀 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 gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 13, 2026
@loopover-orb

loopover-orb Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-13 07:55:05 UTC

3 files · 1 AI reviewer · 1 blocker · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
This is the fifth and final store in the #5563 series, fixing a real primary-key collision where two forge hosts serving a same-named owner/repo could share one deny-rule-proposal row and its maintainer approval decision. The table rebuild in ensureDenyRuleProposalsForgeScope mirrors the exact pattern already used in run-state.js (manual column-presence-gated rebuild instead of the schema-version framework, since this file doesn't use applySchemaMigrations), and INSERT OR IGNORE correctly drops CHECK-violating legacy rows rather than aborting migration, consistent with the sibling PRs in this series. Column counts in the parameterized upsert (7 columns, 7 placeholders, 7 args in the correct order) line up correctly, and the new test suite exercises collision-avoidance, default backfill, options.apiBaseUrl threading, input validation, and both migration paths (clean and corrupt legacy rows).

Nits — 6 non-blocking
  • deny-hook-synthesis.js:299 listStatement selects repo_full_name/id/etc but not api_base_url — harmless since rowToProposal doesn't consume it, but worth a comment noting it's intentionally omitted so a future reader doesn't wonder why the scoping column isn't returned.
  • The PR description flags that attempt-cli.js/loop-cli.js never resolve apiBaseUrl for these stores' write paths today — worth confirming that's tracked as a follow-up issue rather than left implicit.
  • Consider linking the still-open end-to-end forge-threading gap (attempt-cli.js/loop-cli.js) to a tracked issue number if one exists, so it doesn't get lost across this 5-PR series.
  • The regression test for a CHECK-violating legacy row is a nice touch — consider adding a similar note in the module comment near ensureDenyRuleProposalsForgeScope pointing at that test for future maintainers touching this migration.
  • nit: packages/gittensory-miner/lib/deny-hook-synthesis.js:264 should wrap the table rebuild in an explicit transaction so an interruption between creating `deny_rule_proposals_v2`, dropping the old table, and renaming cannot strand a half-migrated local file.
  • 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.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
Signal Result Evidence
Code review ❌ 1 blocker 1 reviewer
Linked issue ✅ Linked #5563
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: 44 registered-repo PR(s), 36 merged, 379 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 44 PR(s), 379 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
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: not available
  • Official Gittensor activity: 44 PR(s), 379 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • 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.
[BETA] Chat with Gittensory

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

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

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 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

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 13, 2026
@JSONbored
JSONbored merged commit a7f2063 into main Jul 13, 2026
19 checks passed
@JSONbored
JSONbored deleted the forge-scope-deny-hook-synthesis branch July 13, 2026 08:00
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.

Scope local ledger keys by forge host, not bare repoFullName

1 participant