Skip to content

feat(engine): add pickTopRankedOpportunities ranker helper#3326

Closed
kiannidev wants to merge 1 commit into
JSONbored:mainfrom
kiannidev:feat/engine-pick-top-ranked-opportunities
Closed

feat(engine): add pickTopRankedOpportunities ranker helper#3326
kiannidev wants to merge 1 commit into
JSONbored:mainfrom
kiannidev:feat/engine-pick-top-ranked-opportunities

Conversation

@kiannidev

Copy link
Copy Markdown
Contributor

Summary

  • Add pickTopRankedOpportunities(candidates, limit) to @jsonbored/gittensory-engine: ranks with the existing rankOpportunities ordering/tie-break rules, then returns the top N entries.
  • Non-finite or negative limits fail closed to an empty list; limit is truncated to a non-negative integer.
  • Export from the package barrel for miner/tool callers that need capped discovery output.

Why no linked issue

Small, self-contained engine helper — avoids every caller re-slicing rankOpportunities and duplicating limit sanitization. Pure data path; no CLI or hosted review wiring.

Conflict avoidance

Touches only packages/gittensory-engine/src/opportunity-ranker.ts, packages/gittensory-engine/src/index.ts (ranker export block), and ranker tests. Does not overlap open PRs touching miner CLI (#3314), enrichment analyzers (#3322#3324), src/queue/processors (#3255, #3288, #3315), signals (#3316), linear adapter (#3290), or docs/grafana.

Codecov patch

Vitest exercises every new branch (top-N slice, empty input, zero/negative/non-finite limits, tie-break preservation, barrel export). Local diff-cover reports 100% patch coverage on the ranker diff.

Test plan

  • npm run build --workspace @jsonbored/gittensory-engine
  • npm run build:miner
  • npx vitest run test/unit/opportunity-ranker.test.ts (52 tests)
  • diff-cover coverage/lcov.info --compare-branch=main --fail-under=99 → 100%
  • CI validate / validate-code / codecov patch+project / orb review agent

Made with Cursor

Expose a pure top-N wrapper over rankOpportunities so miners and tools
can cap discovery output without reimplementing ordering or tie-breaks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kiannidev kiannidev requested a review from JSONbored as a code owner July 5, 2026 02:48
@superagent-security

Copy link
Copy Markdown

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

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@kiannidev kiannidev marked this pull request as draft July 5, 2026 02:49
@gittensory-orb gittensory-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 1.25x multiplier. label Jul 5, 2026
@gittensory-orb

gittensory-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown

Caution

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

🛑 Gittensory review result - reject/close recommended

Review updated: 2026-07-05 02:47:43 UTC

4 files · 1 AI reviewer · 1 blocker · readiness 73/100 · CI failing · blocked

🛑 Suggested Action - Reject/Close

  • AI reviewers agree on a likely critical defect: test/unit/opportunity-ranker.test.ts:5 still references OpportunityRankInput after the import on test/unit/opportunity-ranker.test.ts:2 dropped it, which breaks TypeScript validation
  • restore the type import, e.g. ```ts import { rankOpportunityScore, rankOpportunities, pickTopRankedOpportunities, type OpportunityRankInput, } from "../../packages/gittensory-engine/src/opportunity-ranker"
  • ``` — Resolve the flagged defect, or override if the AI reviewers are mistaken, then re-run the gate.

Review summary
The helper itself is small and correctly delegates ordering/tie-breaking to rankOpportunities before slicing a sanitized limit. The public barrel export is wired, and the runtime tests cover the main behavior. However, the changed Vitest import removed the only visible OpportunityRankInput type import while the file still uses that type, so the test file no longer typechecks.

Blockers

  • test/unit/opportunity-ranker.test.ts:5 still references OpportunityRankInput after the import on test/unit/opportunity-ranker.test.ts:2 dropped it, which breaks TypeScript validation; restore the type import, e.g. ```ts import { rankOpportunityScore, rankOpportunities, pickTopRankedOpportunities, type OpportunityRankInput, } from "../../packages/gittensory-engine/src/opportunity-ranker"; ```
Nits — 5 non-blocking
  • nit: test/unit/opportunity-ranker.test.ts:158 documents that positive finite limits are truncated, but there is no test pinning a fractional value such as 2.9 -> 2.
  • nit: packages/gittensory-engine/test/opportunity-ranker.test.ts:116 only exercises non-finite limit rejection through the compiled public entrypoint, so the exported contract does not pin zero/negative/fractional limit handling even though those are part of the new helper contract.
  • Add a source-level assertion for truncation, e.g. test/unit/opportunity-ranker.test.ts:158 should include pickTopRankedOpportunities(candidates, 2.9) returning exactly two entries.
  • Mirror at least one zero or negative limit case in packages/gittensory-engine/test/opportunity-ranker.test.ts so the dist/index.js contract covers the fail-closed path callers will actually import.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.

Why this is blocked

  • test/unit/opportunity-ranker.test.ts:5 still references OpportunityRankInput after the import on test/unit/opportunity-ranker.test.ts:2 dropped it, which breaks TypeScript validation; restore the type import, e.g. ```ts import { rankOpportunityScore, rankOpportunities, pickTopRankedOpportunities, type OpportunityRankInput, } from "../../packages/gittensory-engine/src/opportunity-ranker"; ```

CI checks failing

  • validate
  • validate-code
Signal Result Evidence
Code review ❌ 1 blocker 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
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 (no linked issue context).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 1313 registered-repo PR(s), 629 merged, 49 issue(s).
Contributor context ✅ Confirmed Gittensor contributor kiannidev; Gittensor profile; 1313 PR(s), 49 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: kiannidev
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 1313 PR(s), 49 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Explain no-issue PR.
  • Await review-lane availability.
  • Refresh registry data or choose a registered active repo.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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

@gittensory-orb

gittensory-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown

Gittensory is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-code); AI reviewers agree on a likely critical defect: test/unit/opportunity-ranker.test.ts:5 still references OpportunityRankInput after the import on test/unit/opportunity-ranker.test.ts:2 dropped it, which breaks TypeScript validation; restore the type import, e.g. ```ts import { rankOpportunityScore, rankOpportunities, pickTopRankedOpportunities, type OpportunityRankInput, } from "../../packages/gittensory-engine/src/opportunity-ranker"; ```). 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.

@gittensory-orb gittensory-orb Bot closed this Jul 5, 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 1.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant