feat(api): wire internal decision/calibration routes, drop duplicate handleParity - #6216
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
…handleParity Register the two fully-built-but-never-routed ops handlers as operator read endpoints alongside the existing /v1/internal/* reads, and resolve the parity-handler duplication flagged in the issue: - GET /v1/internal/decision -> handleInternalDecision (per-target decision trail) - GET /v1/internal/calibration -> handleInternalCalibration (confidence calibration) Both gate on INTERNAL_JOB_TOKEN via the /v1/internal/* middleware, which the handlers' own requireInternalAuth re-checks. The project namespace comes from GITHUB_APP_SLUG (fallback loopover), matching operator-dashboard's config. The handlers' logic is unchanged - routing only. handleParity (src/review/stats.ts) is a confirmed duplicate of parity-wire.ts's canonical, registered /v1/internal/parity readiness feed (both wrap computeGateParity + isParityCutoverReady). It had zero callers and no route, so it is removed along with its orphaned unit tests rather than left as dead code. Closes JSONbored#6166
8b92a32 to
2205d15
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6216 +/- ##
==========================================
- Coverage 95.32% 95.32% -0.01%
==========================================
Files 596 596
Lines 47109 47098 -11
Branches 15015 15009 -6
==========================================
- Hits 44907 44896 -11
Misses 1477 1477
Partials 725 725
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-15 22:50:56 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk 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.
Full command reference: https://gittensory.aethereal.dev/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.
|
Summary
Wires the two genuinely-missing operator read endpoints into
src/api/routes.tsand resolves the parity-handler duplication flagged in the issue:handleInternalDecision→GET /v1/internal/decision?repo=<owner/repo>&number=<n>[&kind=pull_request|issue]— the decision trail (row state + cached terminalGateDecision+ audit log) for one review target.handleInternalCalibration→GET /v1/internal/calibration— confidence-vs-outcome calibration + recommended floor.handleParity(src/review/stats.ts) — removed as a confirmed duplicate (see Notes).Both new routes sit alongside the existing
/v1/internal/*operator reads (ops/stats,parity,predicted-agreement) and use the same access-control convention: the/v1/internal/*middleware bearer-gates onINTERNAL_JOB_TOKEN, and the handlers' ownrequireInternalAuthre-checks that same token (one logical gate). The handlers' logic is unchanged — this is routing only. Theprojectnamespace is resolved fromGITHUB_APP_SLUG(fallbackloopover), matchingoperator-dashboard.ts's existing config.Closes #6166
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #6166).Validation
git diff --checknpm run typechecknpm run test:coverage— new registrations covered 100% (statements + the slug|| "loopover"fallback branch) bytest/unit/routes-internal-decision-calibration.test.ts.npm run test:workersnpm run ui:openapi:check(+selfhost:env-reference:check,cf-typegen:check,docs:drift-check,command-reference:check)npm audit --audit-level=moderateloopoverslug fallback.The sibling
/v1/internal/parityand/v1/internal/ops/statsreads are not listed in the hand-authored OpenAPI spec, so these two follow that same pattern and add no OpenAPI drift.Safety
login|actor|reward|payout|trust|wallet|hotkey).Notes
handleParitywas a confirmed duplicate and is removed (as the issue requested for the true-duplicate case). BothhandleParity(src/review/stats.ts) andcomputeParityReadiness(src/review/parity-wire.ts) wrap the same core (computeGateParity+isParityCutoverReady) to serve the/internal/paritycutover-readiness feed.parity-wire.tsis the canonical production implementation: it is the one actually registered (GET /v1/internal/parity, gated by the/v1/internal/*INTERNAL_JOB_TOKENmiddleware + theLOOPOVER_REVIEW_PARITY_AUDITflag) and the writer half (recordNativeGateDecision).handleParitywas a reviewbot-port-era variant (bearer-gated byLOOPOVER_REVIEW_STATS_TOKEN, CORS-open, per-project scope) with zero production callers and no route — dead code superseded byparity-wire.ts. Removing it (and its now-orphaned unit tests) resolves the duplication instead of leaving it wired to nothing; all remainingstats.tsexports (computeStats,handleStats) keep the shared helpers/imports in use.