Skip to content

feat(miner-governor): self-reputation throttle from own outcome history - #4969

Closed
davion-knight wants to merge 1 commit into
JSONbored:mainfrom
davion-knight:feat-self-reputation-throttle
Closed

feat(miner-governor): self-reputation throttle from own outcome history#4969
davion-knight wants to merge 1 commit into
JSONbored:mainfrom
davion-knight:feat-self-reputation-throttle

Conversation

@davion-knight

Copy link
Copy Markdown
Contributor

Adds the pure calculator the Governor consults before an open_pr/file_issue action (#2346) — the self-reputation half of the miner-governor wave.

What this adds

selfReputationThrottle(history, thresholds) in packages/gittensory-engine/src/governor/reputation-throttle.ts (mirrors the sibling governor/rate-limit.ts calculator style — pure, deterministic, heavily input-normalized):

  • Reads the miner's own recent terminal outcomes on one repo (decided = merged+closed+rejected, unfavorable = human-closed/gate-rejected) — local-only, never shared/cross-fleet data.
  • Returns a cadenceFactor in [minCadenceFactor, 1]: a clean ratio runs at full cadence; as the unfavorable ratio rises from throttleAtRatio to floorAtRatio the factor interpolates linearly down to the floor; a recovering ratio measurably restores cadence — never a hard permanent ban.
  • Fails OPEN below minSampleSize decided outcomes, so a brand-new miner or new repo is never falsely throttled (documented + tested).
  • resolveSelfReputationThresholds(partial) merges a .gittensory-miner.yml override over conservative defaults, normalizing every field (clamps ratios, floors the sample size, keeps the throttle band well-formed).
  • selfReputationThrottleLedgerEvent(...) shapes a decision as a governor-ledger event recording the triggering unfavorableRatio.

Pure/deterministic — no IO, Date, or randomness (the engine's contract). The enforcement wiring into the Governor chokepoint is the separate companion issue; this is the scored calculator + tests.

Validation

  • New suite test/unit/reputation-throttle.test.ts (12 tests): clean track record → full cadence, degrading ratio → measurable throttle, at/above floor → pinned to floor, insufficient history → fail-open, recovering ratio restores cadence, unfavorable clamped to decided, malformed/non-finite thresholds normalized, and both ledger-event branches. 100% branch coverage (24/24) verified locally (v8).
  • npm run engine-parity:drift-check → ok. Typechecks clean; prettier-clean.

Closes #2346

Add the pure calculator the Governor consults before an open_pr/file_issue action (JSONbored#2346):
selfReputationThrottle reads the miner's OWN recent terminal outcomes on a repo (merged vs.
human-closed/gate-rejected) and degrades that repo's submission cadence as the unfavorable
ratio rises past a configured threshold — a linear cadence factor from 1 down to a floor, so a
recovering ratio restores cadence (never a hard permanent ban). Fails OPEN below a minimum
sample size so a new miner/new repo is never falsely throttled; local-only history, no shared
data. Ships with conservative defaults + a resolve helper for .gittensory-miner.yml overrides
and a governor-ledger event builder that records the triggering ratio.

Closes JSONbored#2346
@davion-knight
davion-knight requested a review from JSONbored as a code owner July 11, 2026 04:46
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.26%. Comparing base (b94589c) to head (079b799).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4969   +/-   ##
=======================================
  Coverage   94.26%   94.26%           
=======================================
  Files         448      449    +1     
  Lines       38900    38931   +31     
  Branches    14172    14185   +13     
=======================================
+ Hits        36669    36700   +31     
  Misses       1574     1574           
  Partials      657      657           
Flag Coverage Δ
shard-1 46.79% <3.22%> (-0.04%) ⬇️
shard-2 33.45% <3.22%> (+0.13%) ⬆️
shard-3 31.13% <3.22%> (-0.28%) ⬇️
shard-4 33.13% <3.22%> (-0.03%) ⬇️
shard-5 33.57% <3.22%> (+0.04%) ⬆️
shard-6 45.21% <100.00%> (-0.04%) ⬇️

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

Files with missing lines Coverage Δ
...tensory-engine/src/governor/reputation-throttle.ts 100.00% <100.00%> (ø)
🚀 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 11, 2026
@loopover-orb

loopover-orb Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-11 06:32:55 UTC

3 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · dirty

⏸️ Suggested Action - Manual Review

Review summary
This PR adds a small, pure, side-effect-free cadence calculator (`selfReputationThrottle` + `resolveSelfReputationThresholds` + `selfReputationThrottleLedgerEvent`) mirroring the existing `governor/rate-limit.ts` style, exported through the engine barrel, with 12 well-targeted unit tests covering fail-open, clean, mid-band interpolation, floor-pinning, clamping, and both ledger-event branches. The interpolation math and threshold normalization (band-well-formedness, NaN fallback, clamping) are correct and each branch traced in the diff has a matching assertion in the test file. No enforcement wiring is added in this PR (explicitly deferred), so blast radius is limited to a new unused-until-wired export.

Nits — 5 non-blocking
  • packages/gittensory-engine/src/index.ts reformats several unrelated existing export blocks (resolvePlanOverallStatus, computeLaneFit, MIN_QUERY_CHARS/buildIssueRagQuery) alongside the new export — these are pure Prettier-style line-wrap changes (confirmed against the full file content, the symbols are still exported, not removed), but bundling unrelated formatting churn into a feature PR makes the diff noisier than it needs to be; consider running the formatter only on the touched region or as a separate commit.
  • The four threshold defaults in reputation-throttle.ts:25-28 (5, 0.5, 0.9, 0.1) are documented via JSDoc but not named as individual constants — fine as-is given the doc comments, but if `.gittensory-miner.yml` docs will reference these numbers by name later, consider promoting them.
  • Confirm the PR description/labels explicitly link feat(miner-governor): self-reputation throttle from own outcome history #2346 as the issue this closes — the file header and test names reference it, but per repo convention every contributor PR should carry a clear, checkable issue link (the automated brief flagged this linkage as only 'partial').
  • Since the enforcement wiring is a separate companion issue, consider adding a one-line note in the PR description pointing at that follow-up issue number so reviewers can track when this calculator actually gets consulted by the Governor.
  • packages/gittensory-engine/src/index.ts: split the incidental reformatting hunks out of this diff to keep the review surface focused on the new file.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2346
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: 115 registered-repo PR(s), 80 merged, 2 issue(s).
Contributor context ✅ Confirmed Gittensor contributor davion-knight; Gittensor profile; 115 PR(s), 2 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
Review context
  • Author: davion-knight
  • 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: 115 PR(s), 2 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

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 11, 2026
@loopover-orb

loopover-orb Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Gittensory is closing this pull request on the maintainer's behalf (conflicts with the base branch — resolve and open a fresh PR). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(miner-governor): self-reputation throttle from own outcome history

1 participant