feat(miner-governor): late-binding freshness check before open_pr fires (#3007)#5112
Conversation
…es (#3007) Adds checkSubmissionFreshness: a final, read-only check immediately before open_pr spec construction, complementing the claim-time check. Checks the miner's own claim-ledger status first (local, free) before spending a network round-trip on the live issue/PR snapshot, aborting before the Governor chokepoint is ever invoked for a stale candidate: - claim_superseded: the local claim row is missing or not active - issue_closed: the live issue snapshot shows it closed - already_addressed: another author already has an open or merged PR referencing the issue (the miner's own referencing PRs don't count) - live_state_unavailable: the injected fetch failed or threw -- fails closed, never treated as "no evidence of staleness, so proceed" Logs the abort reason to the event ledger (not every check, matching the issue's own "log the abort reason" wording); the fresh path never writes. This is a standalone, composable unit -- the freshness check, prepareOpenPrSubmission (#2337), and the Governor chokepoint are separate, sequentially-composed steps a future real call site wires together, not nested calls. Closes #3007.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | b52a53a | Commit Preview URL Branch Preview URL |
Jul 11 2026, 03:55 PM |
|
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 #5112 +/- ##
=======================================
Coverage 94.21% 94.21%
=======================================
Files 470 470
Lines 39743 39743
Branches 14506 14506
=======================================
Hits 37442 37442
Misses 1645 1645
Partials 656 656
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-11 15:57:36 UTC
✅ Suggested Action - Approve/Merge
Review summary Blockers
Nits — 6 non-blocking
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk 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.
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.
|
|
An AI reviewer flagged a likely defect, but its confidence was below this repository's configured close-confidence floor, so this is held for a maintainer to confirm instead of closing automatically. Resolve the flagged defect (see the review notes), or ask a maintainer to override. |
…itively pr.authorLogin !== minerLogin was a strict comparison, so a miner's own referencing PR authored as e.g. "Miner-Bot" while candidate.minerLogin is configured as "miner-bot" was misclassified as already_addressed by another author -- GitHub logins are case-insensitive for identity, but different API responses can echo back different casing. Normalize both sides before comparing, and guard against a non-string authorLogin (ignored rather than crashing or false-flagging). Found by AI review on the original PR.
|
Fixed the case-sensitivity bug (author-login comparison now normalizes both sides before comparing, plus a non-string guard) — pushed in b52a53a. On the second blocker (no call site wires this in yet): that's now addressed by #5118, which is open and imports `checkSubmissionFreshness` directly as the first stage of the real `runMinerAttempt` pipeline (freshness → submission-gate → Governor chokepoint → open_pr construction/execution). #5118 depends on this PR's commit (currently carries it via cherry-pick until this merges), so the wiring genuinely exists — it's just in the next PR rather than this one, matching the same "standalone unit now, real call site next" sequencing this package's other PRs in this batch have used (#2336→#2337, #2340's chokepoint→its own callers). |
Summary
Closes #3007.
Adds
checkSubmissionFreshness(packages/gittensory-miner/lib/submission-freshness-check.js): a final, read-only check immediately beforeopen_prspec construction, complementing (not replacing) the existing claim-time check. A soft-claim made at the start of a long create/iterate loop can go stale — the issue may have been closed, fixed by another contributor, or the claim itself superseded/expired in the interim.Note on this PR's history: this issue was previously closed by #3754, an unrelated PR (PHP gRPC stub classification) that cited this issue number to satisfy the linked-issue gate requirement without implementing the actual feature. Reopened and implemented for real here.
claim_superseded(local claim row missing or not active),issue_closed,already_addressed(another author already has an open or merged PR referencing the issue — the miner's own referencing PRs don't count),live_state_unavailable(the injected fetch failed or threw — fails closed, never treated as "no evidence of staleness, so proceed").prepareOpenPrSubmission(maintainer: wire the submission-gate trigger into the harness driving loop #2337), and the Governor chokepoint are separate, sequentially-composed steps a future real call site (tracked separately) wires together — not nested calls.Scope
.d.ts+ package.json build-script entry + 1 test file.CONTRIBUTING.md.Validation
npm run typecheck— clean.node --checkon the new file + fullpackages/gittensory-minerbuild script (56 files) — all pass.npx vitest run test/unit/miner-submission-freshness-check.test.ts— 13/13 passing, covering every deliverable: fresh-claim-proceeds, closed-issue abort, duplicate-PR-exists abort (both open and merged, from another author), self-authored referencing PRs not counted, closed referencing PRs not counted, claim-superseded (missing row and non-active row, both without ever calling the live-state fetch), live-state-unavailable on both a null return and a thrown error, a defensively-missingreferencingPrskey, and fail-closed validation on every malformed candidate/dependency field.npx vitest run test/unit/miner-submission-freshness-check.test.ts --coverage --coverage.include="packages/gittensory-miner/lib/submission-freshness-check.js"→ 100% stmts/branches/funcs/lines (39/39, 47/47, 4/4, 30/30).npm audit --audit-level=moderate— no dependency changes.Safety