Skip to content

feat(miner-governor): self-plagiarism throttle across the miner's own repos - #4972

Merged
loopover-orb[bot] merged 4 commits into
JSONbored:mainfrom
andriypolanski:feat/miner-governor-self-plagiarism-throttle-2345
Jul 11, 2026
Merged

feat(miner-governor): self-plagiarism throttle across the miner's own repos#4972
loopover-orb[bot] merged 4 commits into
JSONbored:mainfrom
andriypolanski:feat/miner-governor-self-plagiarism-throttle-2345

Conversation

@andriypolanski

Copy link
Copy Markdown
Contributor

Closes #2345

Summary

Adds a pure selfPlagiarismCheck() consulted before open_pr, comparing a prospective PR's diff fingerprint against the miner's own recent submission history. Near-duplicates across repos are throttled using the same claim-time / earliest-wins election as isDuplicateClusterWinnerByClaim. Denials are recorded to the governor ledger with the flagged prior submission referenced.

Changes

Area Change
packages/gittensory-engine/src/governor/self-plagiarism.ts selfPlagiarismCheck, fingerprintSimilarity, ledger event builder, config resolver
packages/gittensory-engine/src/miner-goal-spec.ts selfPlagiarism.similarityThreshold from .gittensory-miner.yml (default 0.85)
packages/gittensory-engine/src/index.ts Export self-plagiarism module
packages/gittensory-miner/lib/governor-open-pr.js evaluateOpenPrSelfPlagiarism — check + append-only ledger write
packages/gittensory-miner/docs/miner-goal-spec.md Document selfPlagiarism field
packages/gittensory-miner/schema/miner-goal-spec.schema.json JSON Schema for selfPlagiarism
.gittensory-miner.yml.example Document selfPlagiarism block
Tests self-plagiarism.test.ts, miner-governor-open-pr.test.ts, miner-goal-spec parser/doc updates

Behavior

  • Distinct PRallowed
  • Near-duplicate across repos (similarity ≥ threshold) when a prior claimed first → throttled + ledger row references matched prior
  • Missing candidate fingerprint or submittedAtdenied (fail closed)
  • Near-duplicate prior missing submittedAtdenied (ambiguous election)
  • Earliest near-duplicate claimantallowed (mirrors duplicate-cluster winner election)

Test plan

  • selfPlagiarismCheck — distinct PR passes
  • selfPlagiarismCheck — near-duplicate across repos throttled
  • selfPlagiarismCheck — missing/ambiguous fingerprint data fails closed
  • selfPlagiarismCheck — earliest claimant wins among near-duplicates
  • buildSelfPlagiarismGovernorLedgerEvent — references matched prior in payload
  • evaluateOpenPrSelfPlagiarism — persists throttled denial to governor ledger
  • parseMinerGoalSpec — parses and normalizes selfPlagiarism.similarityThreshold
  • Miner goal spec docs/schema/example include selfPlagiarism
  • npm run test:unit -- test/unit/self-plagiarism.test.ts test/unit/miner-governor-open-pr.test.ts test/unit/miner-goal-spec-doc.test.ts test/unit/miner-goal-spec-parser.test.ts
  • npm run test:ci (full gate before push)

Notes

  • Composes with the Governor open_pr chokepoint (maintainer: wire the fail-closed Governor chokepoint before every write action #2340) — this issue delivers the pure check + ledger recording helper, not the full chokepoint.
  • Threshold is configurable via .gittensory-miner.ymlselfPlagiarism.similarityThreshold; built-in default is 0.85.
  • Rationale vocabulary stays consistent with duplicate-cluster signals (near_duplicate_self_plagiarism).

Test plan

  • Unit tests for check, ledger event builder, governor open_pr integration, and goal-spec parsing
  • npm run test:ci

@andriypolanski
andriypolanski marked this pull request as draft July 11, 2026 05:30
@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 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

Tip

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

✅ Gittensory review result - approve/merge recommended

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

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This adds a pure, deterministic self-plagiarism throttle (`selfPlagiarismCheck`) that Jaccard-compares a prospective PR's diff fingerprint against the miner's own recent submission history, reusing the existing claim-time election from `isDuplicateClusterWinnerByClaim` so exactly one near-duplicate claimant survives; it wires config through `.gittensory-miner.yml`'s new `selfPlagiarism.similarityThreshold` (default 0.85) and records verdicts to the governor ledger via `evaluateOpenPrSelfPlagiarism`. The fail-closed handling of missing/ambiguous fingerprint and timing data is correct and thoroughly exercised, including several deliberately-forced edge cases (threshold-0 zero-similarity tie, `resolveDuplicateClusterWinnerNumber` returning null) that are genuinely reachable, not fabricated. The PR closes #2345, stays scoped to the stated feature, and ships matching schema/docs/example updates alongside real integration tests that exercise the actual sqlite-backed governor ledger rather than mocks.

Nits — 5 non-blocking
  • `selfPlagiarismCheck` doesn't restrict comparison to a *different* repo despite the docs/PR title framing this as throttling duplication 'across repos' — a same-repo resubmission after a closed/rejected PR (e.g. addressing review feedback) would also be flagged as a near-duplicate unless the caller pre-filters `recentOwnSubmissions`; worth confirming the intended caller-side filtering for `governor-open-pr.js:evaluateOpenPrSelfPlagiarism`.
  • codecov/patch reports below the 99% target (73.80% and 98.82% across the listed runs) — worth checking which changed branches in `self-plagiarism.ts` or `miner-goal-spec.ts` are under-covered before merge.
  • `validate-code` and `validate` are in the FAILED CI list with no visible cause in this diff; confirm these aren't type/lint regressions from the new `governor/self-plagiarism.ts` module before merge.
  • In `buildSelfPlagiarismGovernorLedgerEvent` (self-plagiarism.ts), the `matched` prior used in the ledger payload is `bestMatch` (highest-similarity prior) rather than the actual election winner from `resolveDuplicateClusterWinnerNumber` when they diverge — the fallback chain finds a submission matching `winner`'s number only if `bestMatch` is undefined, so the referenced 'flagged prior' in a ledger row could differ from the true cluster winner in a three-way tie; consider a comment clarifying this is intentional (most-similar, not necessarily earliest).
  • Add a short comment on `selfPlagiarismCheck` (self-plagiarism.ts:126) clarifying whether `recentOwnSubmissions` is expected to be pre-filtered to cross-repo entries only, since the current implementation is repo-agnostic.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2345
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: 140 registered-repo PR(s), 95 merged, 25 issue(s).
Contributor context ✅ Confirmed Gittensor contributor andriypolanski; Gittensor profile; 140 PR(s), 25 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: moderate — The diff adds a scoped, well-tested governor safeguard (self-plagiarism throttle) tied to a specific linked issue, reusing existing duplicate-winner election logic rather than reinventing it, which is a meaningful but narrow addition to the governor's open_pr chokepoint.
Review context
  • Author: andriypolanski
  • 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: 140 PR(s), 25 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 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.27%. Comparing base (b94589c) to head (2ebcc8f).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4972      +/-   ##
==========================================
+ Coverage   94.26%   94.27%   +0.01%     
==========================================
  Files         448      449       +1     
  Lines       38900    38985      +85     
  Branches    14172    14211      +39     
==========================================
+ Hits        36669    36754      +85     
  Misses       1574     1574              
  Partials      657      657              
Flag Coverage Δ
shard-1 46.94% <87.05%> (+0.11%) ⬆️
shard-2 33.21% <2.35%> (-0.11%) ⬇️
shard-3 31.48% <10.58%> (+0.06%) ⬆️
shard-4 33.08% <2.35%> (-0.07%) ⬇️
shard-5 33.56% <42.35%> (+0.02%) ⬆️
shard-6 45.19% <20.00%> (-0.06%) ⬇️

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

Files with missing lines Coverage Δ
.../gittensory-engine/src/governor/self-plagiarism.ts 100.00% <100.00%> (ø)
packages/gittensory-engine/src/miner-goal-spec.ts 97.91% <100.00%> (+0.26%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andriypolanski andriypolanski changed the title feat(miner-governor): self-plagiarism throttle across the miner's own… feat(miner-governor): self-plagiarism throttle across the miner's own repos Jul 11, 2026

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit f0fa765 into JSONbored:main Jul 11, 2026
17 checks passed
@loopover-orb loopover-orb Bot added gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. and removed 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
@JSONbored JSONbored 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. and removed gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 11, 2026
@andriypolanski
andriypolanski deleted the feat/miner-governor-self-plagiarism-throttle-2345 branch July 16, 2026 15:12
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.

Development

Successfully merging this pull request may close these issues.

feat(miner-governor): self-plagiarism throttle across the miner's own repos

2 participants