Skip to content

feat(miner-foundation): extract reward-risk scoring into gittensory-engine (#2281) - #3985

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
e11734937-beep:feat/reward-risk-engine-extract-2281
Jul 7, 2026
Merged

feat(miner-foundation): extract reward-risk scoring into gittensory-engine (#2281)#3985
JSONbored merged 2 commits into
JSONbored:mainfrom
e11734937-beep:feat/reward-risk-engine-extract-2281

Conversation

@e11734937-beep

Copy link
Copy Markdown
Contributor

Summary

Extracts the deterministic reward/risk reasoning signals out of src/signals/reward-risk.ts into packages/gittensory-engine/src/reward-risk.ts, so the gittensory-miner can rank candidate work locally with the same logic the maintainer-side gate computes. Moves buildRepoRewardRisk, buildContributorRewardRiskStrategy, buildMaintainerNoiseReport, buildPullRequestReviewability, rewardRiskFreshnessInternals, and every public type, and re-exports them from the engine barrel.

src/signals/reward-risk.ts becomes a shim that imports the engine implementation via its relative source path (../../packages/gittensory-engine/src/reward-risk.js) — matching the merged #2276/#2278/#2282 shims, not the published @jsonbored/gittensory-engine specifier — so no tsconfig path, vitest alias, or root dependency is introduced.

Closes #2281.

Why a wrapping shim instead of a pure re-export

Unlike the earlier self-contained extractions, reward-risk sits on top of the maintainer signal stack in src/signals/engine.ts (buildRoleContext, buildLaneAdvice, buildCollisionReport, buildQueueHealth, buildRepoFitRecommendation, buildContributorIntakeHealth, buildPullRequestReviewIntelligence) plus isFailingCheckSummary from src/signals/local-branch.ts. Those builders are not extracted yet and are far too large to port under the size cap, and the engine package must never import from src/. So the engine module takes them as an injected RewardRiskEngineDeps, and the shim binds the real src builders and threads them in — every existing importer keeps calling the four builders with their original signatures. Once those builders gain engine homes, a follow-up can drop the injection and collapse the shim back to a plain re-export.

The injected builders bind with no casts: their argument records are wider than (assignable to) the engine's mirror types, and their richer return types are covariantly assignable to the narrowed views the module reads. The engine-side types live in packages/gittensory-engine/src/types/reward-risk-types.ts (hand-kept mirrors, same pattern as predicted-gate-types.ts); the record mirrors are full verbatim copies because the reward-risk tests build those records as inline object literals. The real runtime objects pass straight through the injected builders, so behavior is identical to the pre-extraction file.

Coverage

Because the module is new to the engine package, codecov/patch measures every branch — including a handful of deterministic tie-break / defensive branches the pre-existing suite never exercised. test/unit/reward-risk-engine-branch-coverage.test.ts drives each of them (the fit.opportunities map, the analysisRank/topActions localeCompare/ACTION_RANK ties, the maintainer non-low-queue readiness score, both reviewChurnRisk tiers, and the equal-multiplier label sort). The one genuinely unreachable branch — the secondary action-rank presentation tie-break — is hoisted into its own statement and /* v8 ignore */-suppressed (the prior inline ignore did not suppress it). The engine module is now 100% branch / line / function.

Test plan

  • npm run typecheck (exit 0) — and again with packages/gittensory-engine/dist/ moved aside (resolves via source, not a stale build)
  • npm run test:coverage (11190 passed; engine reward-risk.ts 321/321 branches, 180/180 lines, 67/67 functions; shim 100%)
  • npm run ui:typecheck, npm run ui:lint (0 errors), npm run ui:test (71)
  • npm run rees:test (1189)
  • git diff --check clean

…ngine (JSONbored#2281)

Move the reward/risk reasoning signals into packages/gittensory-engine/src/reward-risk.ts
so the gittensory-miner can rank candidate work locally with the same logic the
maintainer-side gate computes.

Closes JSONbored#2281.
Add test/unit/reward-risk-engine-branch-coverage.test.ts driving the
deterministic tie-break / defensive branches the pre-existing suite never
exercised (now measured because the module is new to the engine package):
the fit.opportunities map, the analysisRank and topActions localeCompare/
ACTION_RANK ties, the maintainer non-low-queue readiness score, both
reviewChurnRisk tiers, and the equal-multiplier label sort.

Hoist the actions sort into its own statement so the deterministic secondary
action-rank tie-break can be v8-ignored (the prior inline /* v8 ignore next */
did not suppress the branch). Behavior is unchanged.
@e11734937-beep
e11734937-beep requested a review from JSONbored as a code owner July 7, 2026 08:41
@superagent-security

Copy link
Copy Markdown
Contributor

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

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 7, 2026
@loopover-orb

loopover-orb Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-07 08:52:25 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
The AI review returned non-blocking notes for this change but did not include a separate narrative summary. Review the nits below before deciding this PR.

Nits — 1 non-blocking
  • Split out the personalFit/bestFitLabels/broadDiffSignals fixes into a separate, clearly-labeled bugfix PR (or at minimum call them out individually in this PR's description) so reviewers can evaluate the behavior change on its own merits rather than rubber-stamping it as part of a mechanical move.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2281
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: 65 registered-repo PR(s), 35 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor e11734937-beep; Gittensor profile; 65 PR(s), 0 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: e11734937-beep
  • 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: 65 PR(s), 0 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

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.73%. Comparing base (6bf98e1) to head (83753bb).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3985      +/-   ##
==========================================
+ Coverage   93.71%   93.73%   +0.02%     
==========================================
  Files         373      374       +1     
  Lines       35047    35050       +3     
  Branches    12839    12839              
==========================================
+ Hits        32843    32853      +10     
+ Misses       1584     1583       -1     
+ Partials      620      614       -6     
Files with missing lines Coverage Δ
packages/gittensory-engine/src/reward-risk.ts 100.00% <100.00%> (ø)
src/signals/reward-risk.ts 100.00% <100.00%> (+2.78%) ⬆️
🚀 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 manual-review Gittensor contributor context label Jul 7, 2026
@JSONbored
JSONbored merged commit bf4e4fa into JSONbored:main Jul 7, 2026
9 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(miner-foundation): extract reward-risk scoring into gittensory-engine

2 participants