Skip to content

feat(api): add a REST route + CLI mirror for loopover_evaluate_escalation#6805

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
davion-knight:feat-evaluate-escalation-mirror-v2
Jul 17, 2026
Merged

feat(api): add a REST route + CLI mirror for loopover_evaluate_escalation#6805
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
davion-knight:feat-evaluate-escalation-mirror-v2

Conversation

@davion-knight

Copy link
Copy Markdown
Contributor

What & why

loopover_evaluate_escalation had neither a REST route nor a CLI mirror — unlike its same-tier sibling loopover_check_slop_risk, which already has full parity (POST /v1/lint/slop-risk + an in-process stdio tool). Both are pure, source-free evaluators over caller-supplied data gated only by a tool rate limit, so the asymmetry was arbitrary.

Changes

  • POST /v1/loop/evaluate-escalation — placed directly beside /v1/lint/slop-risk and structured identically: parse with a schema mirroring the MCP tool's own evaluateEscalationShape, then delegate to the pure evaluateEscalation. The route adds no logic of its own — it decides; the caller wires the action.
  • loopover_evaluate_escalation stdio tool — computed in-process from @loopover/engine, exactly like the check_slop_risk sibling, rather than proxying over HTTP. Escalation checks therefore work fully offline with no API round-trip. Descriptor under "agent", matching the server's own MCP_TOOL_CATEGORIES.

Tests — cross-surface parity

The issue asks for "a test asserting output parity between the mirrored surfaces for identical input", so that's the backbone of both suites: for every precedence arm (killRequested > error/critical > abandoned/customerFlagged > degraded > none), the route and the stdio tool each return exactly what the pure evaluator returns. Parity holds by construction — all three surfaces call the same function — and these tests pin it against regression.

The CLI test runs against a black-holed API URL (http://127.0.0.1:1), which proves the in-process claim: a residual round-trip would fail every case. Plus zod/400 rejection on both surfaces.

100% line and branch coverage on the new route lines, measured against the changed-line set. No OpenAPI entry — consistent with its /v1/lint/slop-risk sibling, which has none.

Resubmit of #6784, which the gate closed for CI failing on test/unit/selfhost-grafana-dashboard.test.ts — a suite this PR never touches. It was failing on main itself at the time (verified on a clean upstream/main worktree). #6785 has since fixed it; this branch is rebased past that fix and the suite now passes here.

Closes #6754

…tion

loopover_evaluate_escalation had neither a REST route nor a CLI mirror, unlike its same-tier sibling
loopover_check_slop_risk, which already has full parity (POST /v1/lint/slop-risk + an in-process stdio
tool). Both are pure, source-free evaluators over caller-supplied data gated only by a tool rate
limit, so the asymmetry was arbitrary.

Adds POST /v1/loop/evaluate-escalation directly beside /v1/lint/slop-risk and structured identically:
parse with a schema mirroring the MCP tool's own evaluateEscalationShape, then delegate to the pure
evaluateEscalation. The route adds no logic -- it decides; the caller wires the action.

Adds the loopover_evaluate_escalation stdio tool, computed IN-PROCESS from @loopover/engine exactly
like the check_slop_risk sibling rather than proxying over HTTP, so escalation checks work fully
offline with no API round-trip. Descriptor added under the "agent" category, matching the server's own
MCP_TOOL_CATEGORIES.

Tests assert cross-surface PARITY per the issue's requirement: for every precedence arm
(killRequested > error/critical > abandoned/customerFlagged > degraded > none) both the route and the
stdio tool return exactly what the pure evaluator returns for identical input. The CLI test runs
against a black-holed API URL, proving the tool never round-trips. Plus zod/400 rejection on both
surfaces. 100% line and branch coverage on the new route lines.

Closes JSONbored#6754
@davion-knight
davion-knight requested a review from JSONbored as a code owner July 17, 2026 07:19
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6805   +/-   ##
=======================================
  Coverage   93.63%   93.63%           
=======================================
  Files         683      683           
  Lines       68148    68154    +6     
  Branches    18703    18704    +1     
=======================================
+ Hits        63812    63818    +6     
  Misses       3350     3350           
  Partials      986      986           
Flag Coverage Δ
shard-1 43.63% <33.33%> (-0.01%) ⬇️
shard-2 36.85% <33.33%> (+0.12%) ⬆️
shard-3 32.73% <100.00%> (-0.03%) ⬇️
shard-4 34.20% <33.33%> (+0.40%) ⬆️
shard-5 31.56% <33.33%> (-0.26%) ⬇️
shard-6 45.71% <33.33%> (+0.04%) ⬆️

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

Files with missing lines Coverage Δ
src/api/routes.ts 94.68% <100.00%> (+0.01%) ⬆️

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 17, 2026
@loopover-orb

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-17 07:31:28 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds a REST route and CLI/stdio mirror for loopover_evaluate_escalation, following the exact same pattern as the existing loopover_check_slop_risk sibling — both surfaces delegate to the same pure evaluateEscalation function with a schema mirroring the MCP tool's own evaluateEscalationShape. The implementation is straightforward and well-tested with cross-surface parity tests, precedence-arm coverage, offline-proof (black-holed API URL) for the CLI tool, and 400-rejection tests on both surfaces. There is one clear defect: a mangled comment line in the test file left over from an editing mistake.

Nits — 5 non-blocking
  • test/unit/mcp-tool-rename-aliases.test.ts has a corrupted comment line `// (#// (feat(mcp): register loopover-mcp maintain queue/approve/reject/pause/resume/set-level/precision as MCP tools (CLI-only today) #6152 registered the 5 maintain-surface tools...` — leftover artifact from an edit that wasn't cleaned up, should be removed.
  • src/api/routes.ts:3238 (per external brief) introduces the literal 400 for the error status code, consistent with the sibling route above it, so no new convention issue, but a shared constant would reduce repetition across all these mirror routes.
  • The PR description claims this is a resubmit of feat(api): add a REST route + CLI mirror for loopover_evaluate_escalation #6784 closed for an unrelated CI failure — worth confirming the linked issue REST + CLI mirror for loopover_evaluate_escalation #6754 is fully satisfied (the external brief flags 'partial' coverage) since only the REST+CLI mirror is delivered, not any additional scope implied by the issue.
  • Clean up the duplicated/corrupted comment in test/unit/mcp-tool-rename-aliases.test.ts:8 before merge.
  • Consider extracting a shared zod schema/helper for evaluateEscalationShape since it's now duplicated verbatim in three places (src/mcp/server.ts, packages/loopover-mcp/bin/loopover-mcp.js, src/api/routes.ts) — a future change to the shape risks silent drift between surfaces.

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 #6754
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High 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: 178 registered-repo PR(s), 112 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor davion-knight; Gittensor profile; 178 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff adds the requested POST /v1/loop/evaluate-escalation route delegating to the pure evaluateEscalation function, registers a matching loopover_evaluate_escalation stdio/CLI tool computed in-process, and includes unit tests asserting parity between the REST and CLI surfaces for identical inputs across all precedence arms plus 400-rejection tests.

Review context
  • Author: davion-knight
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Rust
  • Official Gittensor activity: 178 PR(s), 0 issue(s).
  • Related work: Titles/paths share 8 meaningful terms. (issue #6744, issue #6754)
  • Related work: Titles/paths share 8 meaningful terms. (issue #6743, issue #6754)
  • Related work: Titles/paths share 8 meaningful terms. (issue #6747, issue #6754)
  • Additional title-only matches omitted; title-only overlap does not block.
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 2 steps in the Signals table above.
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

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 f8d1628 into JSONbored:main Jul 17, 2026
16 checks passed
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.

REST + CLI mirror for loopover_evaluate_escalation

1 participant