Skip to content

feat(miner-manage): add a proactive decision-pack rebuild trigger on pr_outcome write (#4283) - #4478

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
nickmopen:feat/decision-pack-rebuild-on-pr-outcome
Jul 9, 2026
Merged

feat(miner-manage): add a proactive decision-pack rebuild trigger on pr_outcome write (#4283)#4478
JSONbored merged 1 commit into
JSONbored:mainfrom
nickmopen:feat/decision-pack-rebuild-on-pr-outcome

Conversation

@nickmopen

Copy link
Copy Markdown
Contributor

Closes #4283.

A contributor's decision pack currently only rebuilds when it's next requested and found older than DECISION_PACK_MAX_AGE_MS (~6h passive staleness check) — a PR closing doesn't trigger anything. This wires recordPrOutcome (the pull_request.closed handler behind pr_outcome) to proactively enqueue a rebuild for the PR author the moment a real outcome is recorded, so the pack refreshes within seconds instead of up to 6h later.

What's here

  • src/review/outcomes-wire.ts — after the pr_outcome row is written, call tryEnqueueDecisionPackRebuild(env, authorLogin) (src/services/decision-pack.ts:390) for the already-extracted authorLogin:
    • Best-effort + non-blocking (.catch) — an enqueue failure never affects pr_outcome recording (mirrors the caller's own .catch at processors.ts).
    • A non-authoritative self-close already returned above (anti-poisoning guard), so this only fires on real outcomes; an empty author login is skipped.
    • The ~6h passive check stays as the fallback ceiling — this only adds a proactive trigger, it doesn't remove the passive one.
  • Tests — merged close enqueues for the author (lowercased); self-close does not; a ghost/no-author-login PR does not; an enqueue failure never throws.

Validation (all confirmed locally)

  • Preflight (secret-scan + typecheck): pass.
  • codecov/patch: the new block is fully covered (lines and branches) via lcov.
  • Full suite: 12815 passed, 0 failed (no ripple on the webhook path).

…pr_outcome write (JSONbored#4283)

Today a contributor's decision pack only rebuilds when next REQUESTED and found older than
DECISION_PACK_MAX_AGE_MS (~6h passive check). This wires recordPrOutcome (the
pull_request.closed handler) to proactively enqueue a rebuild for the PR author the moment
a real outcome is recorded, so the pack refreshes within seconds instead of up to 6h later.

- outcomes-wire.ts: after the pr_outcome row is written, call tryEnqueueDecisionPackRebuild
  (src/services/decision-pack.ts) for the already-extracted authorLogin. Best-effort +
  non-blocking (.catch) so an enqueue failure never affects outcome recording; the
  non-authoritative self-close already returned above; empty author login is skipped. The
  ~6h passive check stays as the fallback ceiling — this only ADDS a proactive trigger.
- Tests: merged close enqueues for the author (lowercased); self-close does NOT; a
  ghost/no-author-login PR does NOT; an enqueue failure never throws.

Verified locally: preflight (secret-scan+typecheck) pass; codecov lcov new block fully
covered (lines+branches); full suite 12815 passed, 0 failed.
@nickmopen
nickmopen requested a review from JSONbored as a code owner July 9, 2026 21:22
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.02%. Comparing base (acfe54e) to head (e1b3cb6).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4478   +/-   ##
=======================================
  Coverage   94.02%   94.02%           
=======================================
  Files         420      420           
  Lines       37479    37482    +3     
  Branches    13692    13693    +1     
=======================================
+ Hits        35240    35243    +3     
  Misses       1583     1583           
  Partials      656      656           
Files with missing lines Coverage Δ
src/review/outcomes-wire.ts 89.05% <100.00%> (+0.24%) ⬆️
🚀 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 gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. labels Jul 9, 2026
@loopover-orb

loopover-orb Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-09 21:36:36 UTC

2 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): src/review/outcomes-wire.ts (matched src/review/outcomes-wire.ts).

Review summary
This wires recordPrOutcome to proactively enqueue a decision-pack rebuild for the PR author right after a pr_outcome row is recorded, replacing the passive 6h-only staleness check with a seconds-scale trigger while keeping the 6h check as a fallback ceiling. The change is narrow and correctly placed after the anti-poisoning self-close guard already returns, gated on a non-empty authorLogin, and wrapped in the same non-blocking .catch pattern the caller already uses in processors.ts. The added test mocks only tryEnqueueDecisionPackRebuild (not the surrounding webhook-payload logic), so the merged/self-close/no-author/enqueue-failure cases it exercises are real recordPrOutcome branches, not fabricated states.

Nits — 6 non-blocking
  • src/review/outcomes-wire.ts:351 — the `160` char-truncation length is a bare magic number; if this mirrors an existing constant elsewhere (e.g. the processors.ts .catch this comment says it mirrors), pull it from there instead of re-literaling it.
  • The issue (feat(miner-manage): invalidate/refresh the miner decision-pack on pr_outcome write, replacing the current ~6h debounce #4283) title says 'replacing the current ~6h debounce' but this PR keeps the 6h passive check as a fallback rather than removing/replacing it — worth a one-line note in the PR description on why additive-over-replacing was chosen, since it's a deviation from the linked issue's stated scope.
  • Can't verify from this diff whether tryEnqueueDecisionPackRebuild (src/services/decision-pack.ts:390) is itself idempotent/deduped — confirm a retried or duplicate `pull_request.closed` delivery for the same PR doesn't fan out redundant rebuild enqueues for the same author.
  • test/unit/miner-decision-pack-rebuild-trigger.test.ts only asserts the enqueue call args, not that a rejected enqueue still lets the function's own pr_outcome-recording work (DB writes) complete unaffected — consider also asserting the outcome row/audit event was written in the failure-path test for full end-to-end confidence.
  • Name the `160` slice length as a shared constant if one already exists for other console.warn/JSON.stringify error truncations in this file, per src/review/outcomes-wire.ts:351.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #4283
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: 162 registered-repo PR(s), 103 merged, 11 issue(s).
Contributor context ✅ Confirmed Gittensor contributor nickmopen; Gittensor profile; 162 PR(s), 11 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Linked issue satisfaction

Addressed
The PR adds a best-effort, non-blocking call to tryEnqueueDecisionPackRebuild(env, authorLogin) right after the pr_outcome row is written in recordPrOutcome, guarded by a non-empty authorLogin check, leaves DECISION_PACK_MAX_AGE_MS untouched as the passive fallback, and includes unit tests covering merged-close enqueue, self-close suppression, empty-login skip, and enqueue-failure non-propagation

Review context
  • Author: nickmopen
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 162 PR(s), 11 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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.

🟩 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

@JSONbored
JSONbored merged commit 2f7f0bf into JSONbored:main Jul 9, 2026
9 checks passed
@loopover-orb loopover-orb Bot removed the gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. label Jul 9, 2026
@JSONbored JSONbored added the gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

feat(miner-manage): invalidate/refresh the miner decision-pack on pr_outcome write, replacing the current ~6h debounce

2 participants