Skip to content

feat(api): mirror loopover_propose_action to REST and the CLI - #6956

Closed
real-venus wants to merge 1 commit into
JSONbored:mainfrom
real-venus:feat/propose-action-rest-cli-mirror-6744
Closed

feat(api): mirror loopover_propose_action to REST and the CLI#6956
real-venus wants to merge 1 commit into
JSONbored:mainfrom
real-venus:feat/propose-action-rest-cli-mirror-6744

Conversation

@real-venus

Copy link
Copy Markdown
Contributor

Summary

The loopover_propose_action MCP tool stages a new pending agent action for later maintainer approval
(it never auto-executes). REST already had the list side (GET .../agent/pending-actions) and the
decision side (POST .../agent/pending-actions/:id/:decision), both CLI-mirrored — but no way to
create a staged action over REST/CLI. This completes the create/list/decide trio.

  • POST /v1/repos/:owner/:repo/agent/pending-actions — a plain create route, requireRepoWriteAccess-gated
    exactly like its sibling decision route. It mirrors the proposeAction MCP handler verbatim: resolve the
    repo's installation (409 app_not_installed if the App isn't installed), pin the staged action to the PR's
    current head SHA (the same force-push freshness guard proposeAction sets, fix(mcp): gittensory_propose_action stages actions with no expectedHeadSha, disabling the force-push guard #2255), then
    createPendingAgentActionIfAbsent at auto_with_approval. It returns the identical
    { created, action: { id, actionClass, pullNumber, status, reason } } shape the tool returns, and only
    stages
    an action — it never executes one. A zod schema mirroring proposeActionShape (minus the
    path-param owner/repo) rejects a malformed body with 400 invalid_propose_action_request.
  • loopover-mcp maintain propose <action-class> <pull-number> — the CLI subcommand, alongside the
    existing status/queue/approve/reject. Posts to the bare create path, supports
    --reason/--label/--review-body/--merge-method/--close-comment + --json, validates the action class
    (the 7-value propose set, incl. review_state_label) and pull number before any request, and sanitizes
    every API-echoed field on the plain-text path.

Like every sibling agent/pending-actions route, it is deliberately omitted from the OpenAPI spec.

Closes #6744

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • 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 (Closes #6744).

Validation

  • npm run typecheck
  • npm run build:mcp (node --check)
  • npm run command-reference:check / npm run ui:openapi — no diff (local maintain subcommands aren't in the generated command catalog; mirror routes aren't in the OpenAPI spec)
  • git diff --check
  • npx vitest run test/unit/routes-agent-approval.test.ts test/unit/mcp-cli-maintain.test.ts (66 passing)
  • Verified 100% statement + branch coverage on every changed line in src/api/routes.ts (the only Codecov-measured file in this diff) via coverage-final.json — every optional-param branch (present/absent), the head-SHA pin (present/absent), the schema-reject, and the not-installed arm.

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. — the CLI runs every API-echoed field through sanitizePlainTextTerminalOutput; --json stays raw (JSON.stringify escapes control chars).
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — the route is requireRepoWriteAccess-gated like the decision route; a non-maintainer session gets 401/403 (tested), and the coarse-allowlist comment is updated to reflect the new write-gated POST on the shared path.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — new route tested for parity + every branch; deliberately no OpenAPI entry (matches all sibling pending-actions routes).
  • No visible UI changes (REST route + CLI subcommand only), so no UI Evidence section is required.
  • Public docs/changelogs: --help documents the new subcommand; no changelog edited.

Notes

  • No new business logic or decision surface: the route reuses the same pure createPendingAgentActionIfAbsent
    path the MCP tool calls, with the same write gate and head-SHA pinning. It stages for approval only —
    execution stays exclusively on the existing accept path.
  • The action-class enum is kept as a dedicated 7-value PROPOSE_ACTION_CLASSES in the CLI (a superset of the
    autonomy-configurable set-level list, adding review_state_label) so propose accepts exactly what the
    route + MCP tool accept.

…red#6744)

Add POST /v1/repos/:owner/:repo/agent/pending-actions and a `maintain propose`
CLI subcommand, completing the create/list/decide trio the approval queue only
had list/decide for.

The route is write-gated (requireRepoWriteAccess) like its sibling decision
route and mirrors the loopover_propose_action MCP tool: same head-SHA pinning
(JSONbored#2255) and the same { created, action } shape. It only STAGES an
auto_with_approval action for a maintainer to accept/reject later; it never
executes one. Like the sibling pending-actions routes it is not in the OpenAPI
spec. The CLI subcommand posts to the bare create path and sanitizes every
API-echoed field on the plain-text path.
@real-venus
real-venus requested a review from JSONbored as a code owner July 17, 2026 15:31
@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 17, 2026
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 15.00000% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.02%. Comparing base (8fa47d1) to head (b6514bb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/api/routes.ts 15.00% 17 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (8fa47d1) and HEAD (b6514bb). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (8fa47d1) HEAD (b6514bb)
shard-6 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6956      +/-   ##
==========================================
- Coverage   93.71%   87.02%   -6.70%     
==========================================
  Files         685      685              
  Lines       68373    68392      +19     
  Branches    18729    18737       +8     
==========================================
- Hits        64074    59516    -4558     
- Misses       3302     7186    +3884     
- Partials      997     1690     +693     
Flag Coverage Δ
shard-1 43.74% <10.00%> (-0.02%) ⬇️
shard-2 36.78% <10.00%> (-0.03%) ⬇️
shard-3 32.74% <10.00%> (+<0.01%) ⬆️
shard-4 34.60% <10.00%> (-0.02%) ⬇️
shard-5 32.12% <15.00%> (-0.02%) ⬇️
shard-6 ?

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

Files with missing lines Coverage Δ
src/api/routes.ts 59.18% <15.00%> (-35.62%) ⬇️

... and 117 files with indirect coverage changes

@loopover-orb

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-17 15:38:57 UTC

5 files · 1 AI reviewer · no blockers · CI failing · blocked

🛑 Suggested Action - Fix Blockers

Review summary
This PR adds the create side of the pending-actions approval queue over REST (POST /v1/repos/:owner/:repo/agent/pending-actions) and mirrors it into the CLI's `maintain propose` subcommand, closing #6744 and completing the create/list/decide trio. The implementation mirrors the existing proposeAction MCP handler closely: same requireRepoWriteAccess gate, same head-SHA pinning via expectedHeadSha, same createPendingAgentActionIfAbsent idempotency, and the same response shape as the decision route. Tests cover the happy path, idempotency, missing-installation 409, schema-invalid 400s, and the write-access boundary, and the CLI test verifies the bare POST path plus pre-request validation of action class and pull number.

Nits — 5 non-blocking
  • src/api/routes.ts:505-509 use bare numeric literals (500, 60000) duplicated from other schemas in the file (e.g. intakeIdeaShape) rather than shared constants, though this matches existing local convention.
  • The propose route resolves the PR via getPullRequest but doesn't validate pullNumber against the repo's actual open PRs before staging — if pr is undefined (PR not synced yet), expectedHeadSha is simply omitted, which is documented/tested behavior but worth a one-line comment confirming that's intentional (already partially covered).
  • PROPOSE_ACTION_CLASSES and MAINTAIN_ACTION_CLASSES in loopover-mcp.js are near-duplicate arrays differing only by review_state_label; a shared base array with a spread could avoid future drift, though the code comments already flag the intentional separation.
  • Consider extracting the 500/60000 length limits in proposePendingActionSchema into named constants shared with intakeIdeaShape-style schemas for readability.
  • The CLI help text and error message enumerations (PROPOSE_ACTION_CLASSES) are duplicated in three places (schema, CLI validation, help text) — worth a single source of truth if this list changes again.

CI checks failing

  • codecov/patch — 15.00% of diff hit (target 99.00%)
  • validate
  • validate-tests (6)

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 #6744
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: 167 registered-repo PR(s), 90 merged, 20 issue(s).
Contributor context ✅ Confirmed Gittensor contributor real-venus; Gittensor profile; 167 PR(s), 20 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds the POST /v1/repos/:owner/:repo/agent/pending-actions create route with head-SHA pinning and requireRepoWriteAccess gating, plus the maintain propose CLI subcommand, matching the issue's two deliverables and precedent pattern, with accompanying unit tests for both surfaces.

Review context
  • Author: real-venus
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript, JavaScript, Python, Rust, CSS, MDX, Svelte, Swift
  • Official Gittensor activity: 167 PR(s), 20 issue(s).
  • Related work: Titles/paths share 6 meaningful terms. (PR #6955)
  • Related work: Titles/paths share 8 meaningful terms. (issue #6735, issue #6747)
  • Related work: Titles/paths share 8 meaningful terms. (issue #6735, issue #6742)
  • 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 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (CI is failing (codecov/patch, validate, validate-tests (6))). 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.

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_propose_action

1 participant