Skip to content

feat(miner-foundation): extract duplicate-winner adjudication into gittensory-engine (#2278) - #3870

Merged
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
philluiz2323:feat/duplicate-winner-engine-extract-2278
Jul 6, 2026
Merged

feat(miner-foundation): extract duplicate-winner adjudication into gittensory-engine (#2278)#3870
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
philluiz2323:feat/duplicate-winner-engine-extract-2278

Conversation

@philluiz2323

Copy link
Copy Markdown
Contributor

Summary

  • Ports the duplicate-cluster election logic (isDuplicateClusterWinner, isDuplicateClusterWinnerByClaim, resolveDuplicateClusterWinnerNumber, DuplicateClaimMember) from src/signals/duplicate-winner.ts into packages/gittensory-engine/src/duplicate-winner.ts, following the same extraction pattern already established by feat(miner-foundation): extract scoring preview/model into gittensory-engine (#2282) #3849 (scoring preview/model) and other miner-foundation engine extractions.
  • src/signals/duplicate-winner.ts is now a thin re-export shim over @jsonbored/gittensory-engine, so the maintainer gate and the miner's own soft-claim adjudication (a later Phase-0 issue) share one versioned election rule instead of drifting apart.
  • The existing 41-test suite (test/unit/duplicate-winner.test.ts) passes unmodified against the new shim.
  • Added packages/gittensory-engine/test/duplicate-winner.test.ts, mirroring the engine package's own node:test convention, covering the barrel re-export and the full election-order logic (claim-time precedence, PR-number tie-break, fail-closed on missing/invalid timestamps, createdAt precedence, resolveDuplicateClusterWinnerNumber's winner/loser/empty/null cases).
  • No root package.json change needed: like feat(miner-foundation): extract scoring preview/model into gittensory-engine (#2282) #3849, root src/ resolves @jsonbored/gittensory-engine through the existing npm workspace symlink without adding it as an explicit dependency.

Closes #2278

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • test/unit/duplicate-winner.test.ts (41/41) and test/unit/queue.test.ts (606/606, the heaviest consumer of this module via src/queue/processors.ts) pass in full. The unsharded npm run test:coverage run surfaces 95 pre-existing failures across 35 files (e.g. selfhost-image-deploy.test.ts, workflow-runner-labels.test.ts) that are local-Windows-only artifacts (CRLF checkout line endings, Windows shell/Docker-CLI behavior differences) — verified by reproducing them identically on the commit immediately before this one, before any of this PR's changes existed. None touch duplicate-winner, signals, queue, or the engine package.
  • npm run test:mcp-pack, npm run ui:lint, npm run ui:typecheck, npm run ui:build fail locally for the same reason (Windows spawnSync("npm", ...) PATH resolution without shell: true, and repo-wide CRLF-vs-LF prettier/eslint noise across apps/gittensory-ui/**) — none of which this PR touches. These run on Linux in CI where the underlying scripts resolve normally.
  • The changed file src/signals/duplicate-winner.ts is now a pure re-export with 0 coverable lines/branches per coverage/lcov.info, so it trivially satisfies codecov/patch. The new logic in packages/gittensory-engine/src/duplicate-winner.ts is outside src/** and therefore outside the Codecov patch-coverage scope (per vitest.config.ts's coverage.include), but is fully covered by the new dedicated engine-package test file regardless.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. (N/A — no auth/session/CORS changes in this PR.)
  • API/OpenAPI/MCP behavior is updated and tested where needed. (N/A — no API/OpenAPI/MCP surface changed.)
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. (N/A — no UI changes.)
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots. (N/A — no visible UI changes.)
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs. (N/A — no docs/changelog updates needed for this internal refactor.)

Notes

…ttensory-engine (JSONbored#2278)

Ports the duplicate-cluster election logic (isDuplicateClusterWinner,
isDuplicateClusterWinnerByClaim, resolveDuplicateClusterWinnerNumber) into
packages/gittensory-engine/src/duplicate-winner.ts so the maintainer gate
and the miner's own soft-claim adjudication share one versioned election
rule instead of drifting apart. src/signals/duplicate-winner.ts is now a
thin re-export shim; the existing 41-test suite passes unmodified against
it. Adds a dedicated engine-package test file mirroring the package's own
node:test convention.
@philluiz2323
philluiz2323 requested a review from JSONbored as a code owner July 6, 2026 21:33
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.53%. Comparing base (7d145f0) to head (aa27bae).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3870   +/-   ##
=======================================
  Coverage   93.53%   93.53%           
=======================================
  Files         336      336           
  Lines       33281    33281           
  Branches    12175    12175           
=======================================
  Hits        31128    31128           
  Misses       1528     1528           
  Partials      625      625           
Files with missing lines Coverage Δ
packages/gittensory-engine/src/duplicate-winner.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.

…urce path

CI's fresh npm ci does not link @jsonbored/gittensory-engine into root
node_modules since root package.json never declares it as a dependency
(matching the JSONbored#2282 scoring-preview extraction, which deliberately avoids
that edge by importing the engine module via its relative source path
instead of the published package specifier). Switches the shim to the
same pattern so typecheck and ui:build resolve the module on a clean
checkout instead of only via a locally stale workspace symlink.
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 6, 2026
@loopover-orb

loopover-orb Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Tip

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

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-06 21:51:44 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a straightforward, mechanical extraction: the duplicate-winner election logic (isDuplicateClusterWinner, isDuplicateClusterWinnerByClaim, resolveDuplicateClusterWinnerNumber, DuplicateClaimMember) moves byte-for-byte into packages/gittensory-engine/src/duplicate-winner.ts, and src/signals/duplicate-winner.ts becomes a thin re-export shim importing the same symbol set via relative source path, matching the established #2282/#3849 extraction pattern. Diffing the moved function bodies confirms no logic changed, which is consistent with the claim that the existing 41-test suite passes unmodified against the shim. New engine-side tests cover the barrel re-export and the full election-order behavior (claim-time precedence, createdAt precedence, PR-number tiebreak, fail-closed cases), and the PR closes the linked extraction issue #2278.

Nits — 4 non-blocking
  • packages/gittensory-engine/test/duplicate-winner.test.ts imports from "../dist/index.js" rather than the TS source, so the test only proves anything if the package is rebuilt before `test:coverage` runs — worth a one-line confirmation that the build step precedes this test in CI, matching whatever the other engine test files already rely on.
  • The module doc comments in packages/gittensory-engine/src/duplicate-winner.ts are quite long relative to the ~50-line implementation; not asking for a trim since it mirrors the existing verbose-doc convention in this file's predecessor, but future extractions could tighten this.
  • src/signals/duplicate-winner.ts imports the engine module by relative source path (`../../packages/gittensory-engine/src/duplicate-winner`) instead of the published `@​jsonbored/gittensory-engine` specifier — consistent with the feat(miner-foundation): extract scoring preview/model modules into gittensory-engine #2282 precedent per the comment, but worth confirming this is the durable convention rather than a temporary workaround, since it couples `src/` directly to the engine package's internal file layout.
  • Confirm CI's test:coverage step rebuilds packages/gittensory-engine/dist before running packages/gittensory-engine/test/duplicate-winner.test.ts, since that test imports from dist rather than src.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2278
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: 958 registered-repo PR(s), 555 merged, 112 issue(s).
Contributor context ✅ Confirmed Gittensor contributor philluiz2323; Gittensor profile; 958 PR(s), 112 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: philluiz2323
  • 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: 958 PR(s), 112 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 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 685e2c5 into JSONbored:main Jul 6, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(miner-foundation): extract duplicate-winner adjudication into gittensory-engine

1 participant