Skip to content

feat(control-plane): add tenant provision orchestration with fake driver - #7539

Closed
jsdevninja wants to merge 1 commit into
JSONbored:mainfrom
jsdevninja:feat/control-plane-tenant-provisioning
Closed

feat(control-plane): add tenant provision orchestration with fake driver#7539
jsdevninja wants to merge 1 commit into
JSONbored:mainfrom
jsdevninja:feat/control-plane-tenant-provisioning

Conversation

@jsdevninja

@jsdevninja jsdevninja commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bootstrap a new repo-root control-plane/ package (mirroring review-enrichment/) hosting product-agnostic provisionTenant() / deprovisionTenant() orchestration.
  • Define TenantProvisioningDriver (create-container / provision-DB / inject-secrets + destroy/revoke) and an in-memory fake driver; secrets injection goes through a #7174-shaped TenantSecretBroker seam (no hand-rolled secrets path, no live Cloudflare/Postgres SDKs).
  • Wire control-plane:test into test:ci, add control-plane/ to wantedPaths (+ bundled focus-manifest parity), and cover create→exists→destroy→gone plus rollback / invalid-input / idempotent-absent branches.

Closes #7524

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:

  • New standalone control-plane/ package (like review-enrichment/): not under root Vitest/Codecov coverage.include. Ran npm --prefix control-plane test (13 pass) and npm run manifest:drift-check. Codecov patch does not numerically gate this tree — noted below. Remaining test:ci (including the new control-plane:test step) will run in CI.

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 — control-plane orchestration library only; no visible UI.

Notes

  • Analogues: packages/loopover-engine/src/miner/coding-agent-driver.ts (CodingAgentDriver + createFakeCodingAgentDriver); review-enrichment/ package skeleton; src/orb/broker.ts #7174 secret_type generalization for the inject-secrets broker seam.
  • Explicitly does not call Cloudflare Containers or provision real Postgres — fake/in-memory driver only, per issue hard constraint.
  • Codecov: control-plane/** is outside root coverage.include (same convention as review-enrichment/ / apps/**); package tests enforce the lifecycle acceptance criteria instead.

@jsdevninja
jsdevninja requested a review from JSONbored as a code owner July 20, 2026 21:11
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.47%. Comparing base (37e7f86) to head (2a96ad2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7539   +/-   ##
=======================================
  Coverage   88.47%   88.47%           
=======================================
  Files         720      720           
  Lines       75733    75733           
  Branches    22547    22548    +1     
=======================================
  Hits        67008    67008           
  Misses       7679     7679           
  Partials     1046     1046           
Flag Coverage Δ
shard-1 33.03% <ø> (-0.01%) ⬇️
shard-2 36.85% <ø> (ø)
shard-3 25.66% <ø> (ø)
shard-4 38.88% <ø> (ø)
shard-5 34.21% <ø> (ø)
shard-6 36.22% <ø> (ø)

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

Files with missing lines Coverage Δ
src/config/loopover-repo-focus-manifest.ts 100.00% <ø> (ø)

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

loopover-orb Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - reject/close recommended

Review updated: 2026-07-20 21:25:07 UTC

21 files · 1 AI reviewer · 1 blocker · CI green · clean

🛑 Suggested Action - Reject/Close

Review summary
This PR bootstraps a self-contained `control-plane/` package with a fake `TenantProvisioningDriver`, provision/deprovision orchestration with rollback-on-failure, and a fake secret-broker seam, wired into `test:ci` and the focus manifest — closing #7524. The provision path (create→DB→secrets with rollback) is correctly traced and tested, but `deprovisionTenant` silently no-ops and reports success whenever the caller doesn't have prior in-memory handles, contradicting its own doc comment.

Blockers

  • control-plane/src/deprovision-tenant.ts:33-67 — when `options.provisioned` is omitted, the `if (provisioned)` block is skipped entirely and the function never calls `driver.revokeSecrets`/`destroyDatabase`/`destroyContainer`; it just returns `{state: "gone", alreadyAbsent: true}` unconditionally, contradicting the JSDoc/type comment ('the driver is asked to destroy using best-effort absent-tolerant calls') — a caller that lost its in-memory handles (e.g. after a restart) will get a false 'gone' result while the container/database/secrets are still live, and the added test (`feat(control-plane): provisionTenant()/deprovisionTenant() orchestration behind an injectable driver interface (fake driver only) #7524: deprovision without provisioned handles reports alreadyAbsent`) only asserts the trivially-true no-op outcome rather than that the driver was actually asked to clean up.
Nits — 5 non-blocking
  • control-plane/src/deprovision-tenant.ts:38-65 repeats the same try/catch-wrap-rethrow shape three times for secrets/database/container — worth factoring into a small helper given the external nesting-depth flag at line 51 (depth 5).
  • control-plane/src/fake-tenant-provisioning-driver.ts revokeSecrets has a redundant duplicated `broker.revokeEnrollment` call in both branches of the `if` — could be deduped to one call followed by a conditional `secretsByTenant.delete`.
  • control-plane/README.md correctly flags the coverage exemption but the deprovision-without-handles gap above means the package's own advertised idempotent-destroy guarantee is only partially true — worth calling out until it's fixed or the type is made non-optional.
  • Either make `DeprovisionTenantOptions.provisioned` required (forcing callers to look up handles before calling) or, if lookup-by-tenant-only is meant to be supported, add driver methods to resolve existing container/database/secret ids by `TenantRef` so the 'no provisioned' path can genuinely query and destroy live state instead of assuming absence.
  • Add a test where the fake driver already has a container/database for a tenant and `deprovisionTenant` is called without `provisioned` handles, asserting the resources are NOT silently left behind (or that the function throws/warns instead of claiming `alreadyAbsent: true`).

Why this is blocked

  • control-plane/src/deprovision-tenant.ts:33-67 — when `options.provisioned` is omitted, the `if (provisioned)` block is skipped entirely and the function never calls `driver.revokeSecrets`/`destroyDatabase`/`destroyContainer`; it just returns `{state: "gone", alreadyAbsent: true}` unconditionally, contradicting the JSDoc/type comment ('the driver is asked to destroy using best-effort absent-tolerant calls') — a caller that lost its in-memory handles (e.g. after a restart) will get a false 'gone' result while the container/database/secrets are still live, and the added test (`feat(control-plane): provisionTenant()/deprovisionTenant() orchestration behind an injectable driver interface (fake driver only) #7524: deprovision without provisioned handles reports alreadyAbsent`) only asserts the trivially-true no-op outcome rather than that the driver was actually asked to clean up.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. control-plane/src/deprovision-tenant.ts:33-67 — when \`options.provisioned\` is omitted, the \`if \(provisioned\)\` block is skipped entirely and the function never calls \`driver.revokeSecrets\`/\`destroyDatabase\`/\`destroyContainer\`; it just returns \`\{state: "gone", alreadyAbsent: true\}\` unconditionally, contradicting the JSDoc/type comment \('the driver is asked to destroy using best-effort absent-tolerant calls'\) — a caller that lost its in-memory handles \(e.g. after a restart\) will get a false 'gone' result while the container/database/secrets are still live, and the added test \(\`\#7524: deprovision without provisioned handles reports alreadyAbsent\`\) only asserts the trivially-true no-op outcome rather than that the driver was actually asked to clean up.

Decision drivers

  • ❌ Code review — 1 blocker (1 reviewer)
  • ❌ Gate result — Blocking (Repo-configured hard blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7524
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: 198 registered-repo PR(s), 124 merged, 38 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jsdevninja; Gittensor profile; 198 PR(s), 38 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR bootstraps a control-plane/ package mirroring review-enrichment/, defines a TenantProvisioningDriver interface with create-container/provision-DB/inject-secrets (and matching destroy/revoke) steps, implements product-agnostic provisionTenant()/deprovisionTenant() orchestration against that interface only, and provides an in-memory fake driver plus fake secret broker exercised via create→exi

Review context
  • Author: jsdevninja
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, Swift, C, CSS, MDX, Python, TypeScript, Vue
  • Official Gittensor activity: 198 PR(s), 38 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 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (AI reviewers agree on a likely critical defect: control-plane/src/deprovision-tenant.ts:33-67 — when `options.provisioned` is omitted, the `if (provisioned)` block is skipped entirely and the function never calls `driver.revokeSecrets`/`destroyDatabase`/`destroyContainer`; it just returns `{state: "gone", alreadyAbsent: true}` unconditionally, contradicting the JSDoc/type comment ('the driver is asked to destroy using best-effort absent-tolerant calls') — a caller that lost its in-memory handles (e.g. after a restart) will get a false 'gone' result while the container/database/secrets are still live, and the added test (`#7524: deprovision without provisioned handles reports alreadyAbsent`) only asserts the trivially-true no-op outcome rather than that the driver was actually asked to clean up.). 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.

feat(control-plane): provisionTenant()/deprovisionTenant() orchestration behind an injectable driver interface (fake driver only)

1 participant