Skip to content

feat(control-plane): real Neon + Hyperdrive driver for tenant database provisioning - #7939

Merged
loopover-orb[bot] merged 1 commit into
mainfrom
claude/control-plane-neon-driver
Jul 21, 2026
Merged

feat(control-plane): real Neon + Hyperdrive driver for tenant database provisioning#7939
loopover-orb[bot] merged 1 commit into
mainfrom
claude/control-plane-neon-driver

Conversation

@JSONbored

@JSONbored JSONbored commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #7653

Scope

Validation

  • git diff --check
  • npm run typecheck (root)
  • npm run control-plane:test — 55/55 passing (node --test, control-plane's own runner, not vitest).
  • npm run control-plane:coverage — 100% line/branch/function coverage on every file this PR touches or adds; the only residual gap (settlement-backend-driver.ts) is pre-existing and untouched by this PR.
  • npm audit --audit-level=moderate — pre-existing ambient advisories only, unrelated to this PR's dependencies (this PR adds none); audit.yml documents this as a scheduled, non-blocking check, not a per-PR gate.
  • No live Neon account or credentials anywhere in this repo — every test mocks globalThis.fetch with a strict ordered response queue (mirrors pagerduty-notify.test.ts's existing convention). A maintainer provisions a real Neon project/API key (NEON_API_KEY/NEON_PROJECT_ID) whenever ready to deploy for real; until then createTenantProvisioningDriver falls back to the plain fake.
  • New behavior has unit tests for every branch: fresh provision, multi-poll operation retry, a failed operation, a poll timeout, missing endpoint/password at both creation and idempotent-resolve time, non-ok HTTP responses, a body-less DELETE response, and driver-factory selection (both env vars present/absent, individually and together).

Safety

  • No secrets, tokens, or credentials committed anywhere — NEON_API_KEY is read from environment/config only, never hardcoded.
  • No visible UI changes.

Notes

Follow-up infra work on top of #7180 (provisioning core) and #7649/#7858 (the Neon branch-per-attempt decision this reuses). Endpoint paths/response shapes follow Neon's public v2 API docs as read at the time of writing — flagged in neon-database-driver.ts's header comment to verify against a live account before the first real deploy.

…e provisioning (#7653)

Implements provisionDatabase/dropDatabase for real against Neon (one Neon
branch + dedicated database/role per tenant, idempotent create/destroy,
operation polling to completion), composed onto the existing fake driver via
a new driver-factory so createContainer/injectSecrets stay untouched until
#7851/#7852 land their own real implementations. Widens
TenantProvisioningDriver's provisionDatabase to return connection details
instead of discarding them, threading the result through provisionTenant's
own return value.

Does not wire a Cloudflare Hyperdrive binding: control-plane has no
deployable service/wrangler.jsonc yet (#7654), so there's nowhere for one to
attach to today. Tests mock every Neon API call; no live credentials
anywhere in this repo.
@JSONbored JSONbored self-assigned this Jul 21, 2026
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.41%. Comparing base (4ef5bc3) to head (7a76581).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7939      +/-   ##
==========================================
- Coverage   91.79%   91.41%   -0.39%     
==========================================
  Files         733      735       +2     
  Lines       75133    75423     +290     
  Branches    22918    22950      +32     
==========================================
- Hits        68971    68946      -25     
- Misses       5083     5430     +347     
+ Partials     1079     1047      -32     
Flag Coverage Δ
control-plane 99.64% <100.00%> (+0.18%) ⬆️
shard-1 58.17% <ø> (-0.59%) ⬇️
shard-2 46.29% <ø> (-0.02%) ⬇️
shard-3 55.77% <ø> (-0.48%) ⬇️

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

Files with missing lines Coverage Δ
control-plane/src/driver-factory.ts 100.00% <100.00%> (ø)
control-plane/src/index.ts 100.00% <100.00%> (ø)
control-plane/src/neon-database-driver.ts 100.00% <100.00%> (ø)
control-plane/src/provisioning.ts 100.00% <100.00%> (ø)
control-plane/src/tenant-provisioning-driver.ts 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-21 20:05:48 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds a real Neon-backed provisionDatabase/dropDatabase driver plus a driver-factory for composing it onto the existing fake, and widens provisionDatabase's return type from void to DatabaseConnectionDetails end-to-end (interface → fake → provisioning.ts → all call-site tests). The idempotency model (find-by-derived-branch-name, reveal existing role's password on re-provision, cascade-delete branch on drop) is coherent and well-tested against a strict mocked fetch sequence covering both success and every documented failure mode (missing endpoint, missing password, failed operation, timeout, non-ok HTTP). The type widening is threaded consistently through every consumer shown in the diff with no orphaned callers, and the PR stays scoped to #7653's database-only slice as described, deliberately leaving createContainer/injectSecrets untouched.

Nits — 5 non-blocking
  • control-plane/src/neon-database-driver.ts:110 (findBranchByName) fetches only one page of `/branches`; if a Neon project accumulates enough branches to paginate, an existing tenant branch past the first page won't be found and re-provisioning could attempt to create a duplicate — worth confirming Neon's branch-list endpoint doesn't paginate by default or adding cursor handling.
  • Port 5432 is duplicated as a literal in both neon-database-driver.ts:131 and the fake driver in tenant-provisioning-driver.ts:146 — consider a shared constant.
  • control-plane/src/neon-database-driver.ts:107 (reveal_password lookup) throws a generic NeonApiError if an existing branch lacks the expected role name (e.g. created out-of-band) rather than a driver-specific message distinguishing that case from a transient failure.
  • The Neon API base URL is hardcoded as a module constant (neon-database-driver.ts:22) rather than sourced from env/config, though it is overridable via `apiBaseUrl` in tests — fine for now but worth a note if multi-region/staging Neon projects are ever needed.
  • Add a short comment or test asserting behavior when `findBranchByName` would need pagination, or confirm from Neon's docs that this endpoint returns all branches unpaginated for typical project sizes.

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 #7653
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: 21 registered-repo PR(s), 14 merged, 308 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 21 PR(s), 308 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: significant
Linked issue satisfaction

Addressed
The PR implements real provisionDatabase/dropDatabase against Neon's API (branch/role/database creation, idempotent re-provisioning via existing-branch lookup and password reveal, idempotent no-op teardown), threads real connection details through the driver interface, and adds a factory that selects the real driver via env vars while leaving the fake driver intact for tests, with realistic mocked

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, Ruby, Go, JavaScript, MDX, Shell, Solidity
  • Official Gittensor activity: 21 PR(s), 308 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
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
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 d9b8abc into main Jul 21, 2026
14 checks passed
@loopover-orb
loopover-orb Bot deleted the claude/control-plane-neon-driver branch July 21, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Real Postgres/Hyperdrive driver for control-plane's provisionDatabase/deprovisionDatabase

1 participant