Skip to content

feat(api): add tenant-scoped installation health and repair (#7661) - #8069

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
milosde111:feat/tenant-installation-selfservice-7661
Jul 22, 2026
Merged

feat(api): add tenant-scoped installation health and repair (#7661)#8069
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
milosde111:feat/tenant-installation-selfservice-7661

Conversation

@milosde111

Copy link
Copy Markdown
Contributor

Summary

  • Add tenant-scoped /v1/app/installations health/repair/refresh siblings of the operator-only /v1/installations* routes, reusing /v1/app/maintainer-dashboard's exact loadControlPanelAccessScope pattern so a non-operator session only sees/acts on their own installations.
  • Enforce ownership before the refresh side effect; operators / static API identities keep whole-fleet access (scope === null).
  • Prove cross-tenant isolation in integration tests (tenant A cannot read or repair tenant B), including 401/403/400/404 branches and the account-login scope arm.
  • Rate-limit the new refresh path as expensive, matching the operator route.

Closes #7661

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:

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

N/A — API-only tenant scoping; no visible UI change.

Notes

…health and repair (JSONbored#7661)

Introduces new tenant-scoped routes under `/v1/app/installations*` for managing installation health and repair. These routes allow tenants to view and repair their own installations while restricting access to others' installations. The implementation includes:

- GET `/v1/app/installations`: Lists installations and their health for the authenticated tenant.
- GET `/v1/app/installations/:id/health`: Retrieves health information for a specific installation.
- GET `/v1/app/installations/:id/repair`: Initiates a repair for a specific installation.
- POST `/v1/app/installations/:id/repair/refresh`: Refreshes the health status of a specific installation.

Additionally, a new middleware function `resolveAppInstallationScope` is added to enforce access control based on tenant roles. Comprehensive integration tests have been added to ensure proper functionality and access restrictions.
@milosde111
milosde111 requested a review from JSONbored as a code owner July 22, 2026 18:28
@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 18:37:32 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds tenant-scoped `/v1/app/installations*` siblings to the operator-only installation health/repair routes, gating each on a new `resolveAppInstallationScope` helper that mirrors `/v1/app/maintainer-dashboard`'s `loadControlPanelAccessScope` pattern, and enforces ownership via `installationRecordInScope` before any refresh side effect. The scoping logic and route wiring are correct and traceable: operators/static identities get `scope === null` (whole fleet), sessions get filtered by installation id or account login, and the refresh route checks ownership on the existing health record before calling `refreshInstallationHealthForInstallation`. The new route is also correctly added to the `expensive` rate-limit class and the integration test suite explicitly proves cross-tenant isolation across all four routes and their error branches.

Nits — 3 non-blocking
  • src/api/routes.ts:2654-2711 — HTTP status codes (400/403/404) are repeated as inline literals across all four handlers instead of named constants; not a big deal here since the surrounding codebase does the same, but worth being consistent with.
  • The long-file smell on src/api/routes.ts (now ~6700+ lines) predates this PR but this diff adds another ~90 lines to it — consider whether future installation-scope routes should move to a dedicated module.
  • Consider extracting the four repeated `Number.isFinite(installationId)` + health-lookup + `installationRecordInScope` checks in the health/repair/repair-refresh handlers into one shared helper, since the three handlers duplicate nearly identical guard sequences (src/api/routes.ts:2662-2711).

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 #7661, #8006
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 (2 linked issues).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 229 registered-repo PR(s), 156 merged, 4 issue(s).
Contributor context ✅ Confirmed Gittensor contributor milosde111; Gittensor profile; 229 PR(s), 4 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: significant
Linked issue satisfaction

Addressed
The PR adds tenant-scoped `/v1/app/installations*` read/repair/refresh routes that reuse `loadControlPanelAccessScope` from control-panel-roles.ts exactly as the issue's maintainer-dashboard pattern requires, enforces ownership before the refresh side effect, and includes integration tests explicitly proving tenant A cannot read or repair tenant B's installation. All three deliverables (scoped rea

Review context
  • Author: milosde111
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, TypeScript, Cuda, HTML, MDX, Python, Rust
  • Official Gittensor activity: 229 PR(s), 4 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 <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> 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 a3dc73e into JSONbored:main Jul 22, 2026
10 checks passed
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.39%. Comparing base (b788945) to head (b39bc25).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8069      +/-   ##
==========================================
+ Coverage   91.82%   95.39%   +3.56%     
==========================================
  Files         734        2     -732     
  Lines       75023     2648   -72375     
  Branches    23040      888   -22152     
==========================================
- Hits        68889     2526   -66363     
+ Misses       5034       27    -5007     
+ Partials     1100       95    -1005     
Flag Coverage Δ
rees ?
shard-1 31.87% <100.00%> (-22.40%) ⬇️
shard-2 44.10% <8.33%> (-8.47%) ⬇️
shard-3 69.67% <8.33%> (+14.56%) ⬆️

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

Files with missing lines Coverage Δ
src/api/routes.ts 95.22% <100.00%> (+0.09%) ⬆️
src/auth/rate-limit.ts 99.13% <ø> (ø)

... and 732 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.

Add tenant self-service for installation health/repair (currently operator-only)

1 participant