Skip to content

feat(miner): add a pr-outcomes CLI for the hosted contributor outcome history#7998

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
michiot05:feat/miner-pr-outcomes-cli
Jul 22, 2026
Merged

feat(miner): add a pr-outcomes CLI for the hosted contributor outcome history#7998
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
michiot05:feat/miner-pr-outcomes-cli

Conversation

@michiot05

Copy link
Copy Markdown
Contributor

Summary

  • Closes Wire a real AMS-side consumer of ORB's hosted GET /v1/contributors/:login/pr-outcomes #7658: adds a real loopover-miner pr-outcomes --miner-login <login> [--limit <n>] [--json] CLI command that calls the hosted GET /v1/contributors/:login/pr-outcomes (the multi-tenant-safe, public-safe outcome source behind src/signals/contributor-pr-outcomes.ts) and prints the result — CLI only, per the issue's explicit scope (no MCP tool, no miner-ui surface).
  • packages/loopover-miner/lib/pr-outcomes-cli.ts follows tenant-cli.ts's structural template (exported parse function + injectable fetchImpl/session options + fail-loud non-2xx handling) and the package's established backend-call posture: the loopover-mcp session + API URL resolution from resolveLoopoverBackendSession (feat(miner): consume ORB's live gate thresholds in self-review-context.js when available #6487), a Bearer-authed GET, and cli-error.ts's shared failure shape. --miner-login matches attempt/loop's existing flag convention; --limit is validated to the route's own 1–100 integer contract client-side.
  • Dispatch lives in lib/cli.ts's runCli (now async; the bin fallback awaits it) rather than as another bin/loopover-miner.ts branch: the bin dispatcher is subprocess-only-executed and genuinely Codecov-graded (see the packages/loopover-miner/bin note in vitest.config.ts's coverage.include), so dispatching in the in-process-tested foundation module keeps the command's entire path measurable — the dispatch itself is covered by a real test instead of adding permanently-uncovered bin lines. printHelp documents the command.
  • Tests (test/unit/miner-pr-outcomes-cli.test.ts, mirroring the package's *-cli.test.ts conventions, all HTTP via injected/stubbed fetch — no live network): parse validation (login required/valueless, limit range/integer, unknown option, stray positional), text and --json rendering including the null-pullNumber arm, ?limit forwarding + login URL-encoding, bearer-header assertion, no-session fail-loud (real resolver against an empty temp config dir), non-2xx and thrown-fetch failure paths, the default-global-fetch arm, and the runCli dispatch itself. The two existing runCli unknown-command tests now await the async signature; the help test pins the new usage line.

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 a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

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:

  • None skipped — the full npm run test:ci gate was run from the repo root (it includes every check above plus the drift and miner-pack checks) and passed, followed by npm audit --audit-level=moderate. The audit reports pre-existing advisories already present on main's dependency tree (fast-uri, and @hono/node-server transitively under @modelcontextprotocol/sdk / @cloudflare/codemode / agents) — this PR changes no dependencies, and those advisories are already being addressed by the open Renovate updates.

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.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

Not applicable — miner CLI surface only; no visible UI, frontend, docs, or extension change.

Notes

  • The endpoint's own auth is untouched and does the enforcement (requireContributorAccess: a session may only read its own login's outcomes); the CLI sends the operator's existing loopover-mcp session token and fails loud with the loopover-mcp login hint when none exists.
  • Scope boundaries respected per the issue: merged-outcomes only (the endpoint's current contract), no MCP tool, no miner-ui route, no new endpoint, no changes to src/**.
  • The one changed bin/loopover-miner.ts line (awaiting the now-async runCli fallback) carries a v8 ignore note matching the file's documented subprocess-only-execution status; the behavior it guards is covered in-process via lib/cli.ts's dispatch test.

… history

Closes JSONbored#7658. Adds 'loopover-miner pr-outcomes --miner-login <login>
[--limit <n>] [--json]' calling the hosted
GET /v1/contributors/:login/pr-outcomes with the existing loopover-mcp
session posture (resolveLoopoverBackendSession, JSONbored#6487), following
tenant-cli's structural template (exported parse fn, injectable fetch,
fail-loud non-2xx). Dispatch lives in lib/cli.ts's now-async runCli so the
whole path stays in-process-coverable (the bin dispatcher is
subprocess-only-executed; see vitest.config.ts's coverage note); printHelp
documents the command. Tests mock all HTTP per the package's *-cli.test
conventions.
@michiot05
michiot05 requested a review from JSONbored as a code owner July 22, 2026 04:27
@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:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 22, 2026
@loopover-orb

loopover-orb Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-22 04:32:08 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds a new `pr-outcomes` CLI command that mirrors the package's established `resolveLoopoverBackendSession` + injectable-fetch pattern (per `tenant-cli.ts`), with argv parsing, text/JSON rendering, and a dispatch change in `lib/cli.ts` that makes `runCli` async. The implementation is correct and well-tested: parse validation, limit range checks, null-`pullNumber` rendering, URL-encoding, bearer header, no-session/non-2xx/thrown-fetch failure paths, and the bin-fallback await are all covered. The `runCli` signature change (sync -> async) is a breaking API change for the exported function, but the diff shows the one caller (`bin/loopover-miner.ts`) and the test file were both updated to await it, so it's consistently threaded through.

Nits — 5 non-blocking
  • The external brief's '400'/'200' magic-number flags are noise here — 200 in `text.slice(0, 200)` (pr-outcomes-cli.ts) is a reasonable truncation bound and needs no named constant.
  • `console.log` calls in `runPrOutcomesCli` (pr-outcomes-cli.ts:133,135) are the command's actual intended output, not debug leftovers — the brief's 'debug leftovers' flag is a false positive.
  • Making `runCli` async (lib/cli.ts) is a breaking signature change for any other consumer of this exported function beyond the one bin/test caller shown — confirm no other in-repo or published caller depends on the old synchronous return.
  • `renderPrOutcomesText` (pr-outcomes-cli.ts) has no handling for an empty `outcomes` array beyond the summary line, which is fine here since the payload's `summary` presumably already conveys that, but consider a test for the zero-outcomes case for text (not just JSON) rendering.
  • Add a text-mode test for an empty `outcomes` array to pin down the summary-only rendering (test/unit/miner-pr-outcomes-cli.test.ts currently only exercises the empty-outcomes case under JSON encoding of the limit query).

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7658
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: 8 registered-repo PR(s), 1 merged, 2 issue(s).
Contributor context ✅ Confirmed Gittensor contributor michiot05; Gittensor profile; 8 PR(s), 2 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds a real `pr-outcomes` CLI command in packages/loopover-miner that calls GET /v1/contributors/:login/pr-outcomes for the miner's own configured login, mirrors an existing *-cli.ts pattern (tenant-cli.ts), and includes tests mocking the HTTP call with no live network access, matching the issue's deliverables and boundaries (CLI only, merged-outcomes scope).

Review context
  • Author: michiot05
  • 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: 8 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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver 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.

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

@loopover-orb
loopover-orb Bot merged commit 24ddd19 into JSONbored:main Jul 22, 2026
10 checks passed
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 58 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.57%. Comparing base (050f8cb) to head (43281f8).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
packages/loopover-miner/lib/pr-outcomes-cli.ts 0.00% 55 Missing ⚠️
packages/loopover-miner/lib/cli.ts 0.00% 3 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (99.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7998      +/-   ##
==========================================
- Coverage   91.91%   88.57%   -3.35%     
==========================================
  Files         739       97     -642     
  Lines       75876    22002   -53874     
  Branches    23023     3808   -19215     
==========================================
- Hits        69745    19489   -50256     
+ Misses       5038     2335    -2703     
+ Partials     1093      178     -915     
Flag Coverage Δ
shard-1 0.00% <0.00%> (-58.91%) ⬇️
shard-2 0.00% <0.00%> (-47.51%) ⬇️
shard-3 0.00% <0.00%> (-55.32%) ⬇️

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

Files with missing lines Coverage Δ
packages/loopover-miner/bin/loopover-miner.ts 0.00% <ø> (ø)
packages/loopover-miner/lib/cli.ts 0.00% <0.00%> (-80.00%) ⬇️
packages/loopover-miner/lib/pr-outcomes-cli.ts 0.00% <0.00%> (ø)

... and 643 files with indirect coverage changes

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wire a real AMS-side consumer of ORB's hosted GET /v1/contributors/:login/pr-outcomes

1 participant