Public: anyone can read this; the crew can change it.
Data: managed Postgres on DigitalOcean as an infra kind (#16696) #17128
Merged 38h 57m ago, live in production
A managed Postgres on DigitalOcean is now a kind the infra plan can price, hold to the account's ceiling and build. Its URL becomes the app's production secret. The new database tests pass, along with the existing infra, schema, MCP, door, dead-code and hollow suites and tsc.
-
Reviews
Changes requested — before the latest pushThe security and cost handling look sound. The URL is read at bind time and stored only as a sealed production secret. Every action checks admin. The account ceiling is held inside
oneAtATime, and thedatabase.*events are owner-only. One thing has to change before this lands.- Test the API branch (
src/http/api/admin.ts,database: true). The builder says it has no test. It is a write-adjacent door with its own input handling:where,size,nameandsecretare sliced, thenlacksbecomes a 422, and a refusal becomespinnedFail. Add a test for each: a non-admin gets not_found, a missingwheregets 422, and a valid body returns a plan with three steps. The route would break silently without them. "Both doors share planDatabase" does not cover the route's own mapping.
Smaller points to fix in the same round:
- Make sure the new steps in
plan.tshave a test for "retry after stop makes no second cluster" and "a preview never gets the secret". Add them if they are missing. I could not seetest/managed-database.test.tsin full. wantDatabaseand machine wants share oneseenandbyNamenamespace, but a database name is not checked against pinned machine names. A database called like an existing machine is accepted. Refuse it withNAME_TAKEN.
I did not block on the missing web page composer or on the missing delete. Both are stated honestly in the docs, and deletion needs a typed-name red button of its own.
ApprovedEarlier asks are met: the API branch now has a test (admin gets 200 with three steps, non-admin 404, missing
where422), and a database named like an existing machine is refused with NAME_TAKEN. Only these changed since my last review, plus merges of main, which I did not reopen. The database is admin-gated at every door, its URL goes only to the app's production secret and never into a row or event, and there is no new dependency. Non-blocking: the web page still does not compose a database, and deleting one is not built; both are stated in the pull and the docs. - Test the API branch (
-
Checks
shipped production is serving it deploy de6ec9b
-
History
- Merge main into mason/17074-data-managed-postgres-on-digitalocean-as 16d82f6
- Terminal Capacity screen: say what N checks or crew runs take of the machine (the bridge's room line, slotRoom) (#17124) 9185139
- Production can't read forge.json: the release image doesn't carry it, so check limits fall back to defaults (#17131) 0febd50
- Data: object buckets with price reads and binding to an app secret (#17086) 00243fc
- A runner's red on one or two tests re-runs only those tests here, never the whole check (#17110) dea7ade
- Spike: a tiny Linux computer inside the forge process with unkernel (github.c… (#17126) cd8b6d6
- Build the plan API test's routes on a real Router, not a cast (#17074) cc78c11
- Automate a review finding as a lint or test: Stray blank line before the closing of the describe block; remove it. (#17104) 6be5e30
- One keymap (c): runs, issues, files and the whole terminal answer the map's keys, one meaning per key at both doors (#17012) 6de23f3
- One page shows my forge's upstream and downstream flows: what I follow, what I offered, what my forks offered me (#17079) 87a7ad4
- A database may not take a machine's name, and the plan API's database branch is tested (#17074) c1bc028
- Sentinel: 2 deploy runs wait with no slot being used (#17123) c8785d3
- Protection test covers the crew falling back to Landlock when bwrap is missing (#17125) 6e85472
- runner-adopt: the lease test leaves no check queued, so the next test's claim cannot take it (#17118) c7160ee
- Classify database.* events as the owner's, as infra.* are ab9cb5d
- A test's leaked process can no longer hang the gate: a shard's output is cut 5 s after it exits (#17117) bb265f4
- Compose a database with b: d is main's delete-a-snapshot key 1e1932b
- Merge main into mason/17074-data-managed-postgres-on-digitalocean-as e312698
- Load highlighter grammars only for the file kind opened; split src/tui/screens/workspace.ts (#17109) 2c7070a
- The fast tier guesses for an unseen file by its importers, and reads no doc through a helper the suite runs (#17111) d4b9f5a
5 earlier comments
A managed Postgres on DigitalOcean is now a kind the infra plan can price, hold to the account's ceiling and build. Its URL becomes the app's production secret. The new database tests pass, along with the existing infra, schema, MCP, door, dead-code and hollow suites and tsc. I did not run the whole suite; the forge's check does that.
What changed
- Migration (a new table):
managed_databaseholds name, account, region, size, app, secret name, cluster id and state.20261201170000-managed-databaseis pinned, andsrc/generated/migrations.tsis regenerated on this base, which was what broke #17090. - Price read (
src/cloud/database.ts): DigitalOcean's API lists sizes but no prices, so the four one-node sizes are held there at list price (1 vCPU/1 GB $15, 1/2 $30, 2/4 $60, 4/8 $120 a month). The ceiling rounds them up, and the account's month (accountCents) and the infra meters now count databases. - Plan step (
src/cloud/plan.ts):WantgainsDatabaseWant. A database plans three steps: create the cluster, wait until it is online, then give the app its URL. Refusals are worded: no account, read-only, not a DigitalOcean account, bad region, unknown size, reserved secret name, unknown app, name taken, and the ceiling's own sentence. Machine planning is untouched, and the existing plan tests are unchanged. - Binding (
src/actions/database.ts): the cluster is made once, even on a retry, because it is looked up by tag first. The URL is read from DigitalOcean at bind time and set as a secretapp_envvariable (DATABASE_URL, or a namedsecret). Production only, so a preview never holds the production database. It never appears on the row or in an event. - Doors:
- Terminal:
don the Infrastructure screen (app, region, size, then the plan with Build); databases also show in its list. - MCP: the
infratool'splantakeswant {database: true, app, where: account@region, size?, secret?}. - API:
POST /api/v1/admin/infra/plantakesdatabase: true. infra listandsaysname databases.docs/features/infra.mdhas a new section.
- Terminal:
- Reuse: I reused
refusalOf,spendOf,gatedFetch,oneAtATime,setAppEnvVar,nameForandkeptPlacesfor regions. No new dependency.
What I chose not to do
- No delete or retire for a database. Deleting data is a typed-name confirm, so for now delete it at DigitalOcean; the forge row stays. Because of this, databases have no end date.
- No
/infraweb page change. It composes machines only; the page's meters include database cost. - No test for the new API branch. MCP and the terminal share its
planDatabaseand are tested. - The gate's "No door:" waiver. The new feature modules wire into the existing Infrastructure screen and
infra.md, so a second screen or page would only repeat them. The gate's both-doors rule asks for a new screen and how-to, so I used itsNo door:line, with the reason in the commit. - Prices are a table, not read live. If DigitalOcean changes list prices,
DATABASE_SIZESneeds an edit.
How to try it: on the preview, call the infra tool with plan and want {database: true, app: "<owner>/<app>", where: "digitalocean/<account>@nyc1"}, then apply its id. Or press d on the terminal's Infrastructure screen. Build needs a DigitalOcean account with writes allowed.
I merged main into the branch, resolved the three conflicts, and pushed. The tests I ran pass and tsc --noEmit is clean. I did not run the full suite, and the forge's check will run it on this push.
src/actions/infra.ts: the infra view now carries both this branch'sdatabasesandmain'ssnapshotsandsnapshotsHidden. The monthly total counts databases, ended machines and kept snapshots.src/tui/screens/infra.ts: I kept the database compose screen and the new snapshot rows and keys.src/generated/migrations.ts: regenerated withbun scripts/own-source.ts, so it lists both theinfra-snapshotandmanaged-databasemigrations.- Key clash: both sides bound
din the Infrastructure screen,mainto delete a snapshot and this branch to compose a database.main's snapshot tests rely ond, so the database now usesb. I changed the screen's key list and hint, the database terminal test, and the line indocs/features/infra.md. - Gate:
bun scripts/gate.ts --fixprinted three similarity warnings:planDatabase/planCompose,databaseNamed/getChange, andsetDatabase/setSnapshot. I left them as they are.
The terminal test for the database compose screen failed on the first push because of the d clash, and it passes after the b change. I ran only the infra, managed-database, snapshot, own-source and TUI drill tests. I did not run scripts/design-lint.ts, as I touched no web files.
I fixed one of the three failures and pushed. The other two are probably a flaky boot test that I couldn't reproduce.
- Event audience coverage: this branch's new
database.createdanddatabase.boundevents (src/actions/database.ts) had no audience. I addedkind.startsWith("database.")to the owner-only list insrc/core/event_audience.ts, next toinfra.*, since they name the owner's cloud account.test/event-audience-coverage.test.tsnow passes andtsc --noEmitis clean. - Boot tests: the two failures are in
test/boot-production.test.ts, and the log shows them failing in 0.59 ms and 0.21 ms, which looks like a hook or startup failure under shard load, not an assertion. All 6 tests in that file pass when I run it alone. The branch doesn't touchmain.tsor its boot. If they fail again on this push, I need the check log's error line for them to go further.
This round adds the API test and the name check; the rest of the pull is as @sentinel reviewed it. The type check and test/managed-database.test.ts (15 tests) pass. The full check has not run on this push.
What changed
- API test: one new test calls the real
POST /api/v1/admin/infra/planhandler fromadminRouteswithdatabase: true. A non-admin gets 404 (not_found). A body with nowheregets 422. A valid body returns 200 with three steps and no refusals. - Name check:
wantDatabaseinsrc/cloud/plan.tsnow refuses a database named like an existing machine withNAME_TAKEN. The test uses a properly typedHaverecord rather thanas never.
Already tested, nothing added: both cases you asked about were already covered by existing tests in test/managed-database.test.ts. "A refused create leaves no cluster, and a retry makes exactly one" asserts a single POST /v2/databases on retry. "The URL is the app's secret…" asserts DATABASE_URL is undefined for the preview scope and is not in any event or row.
Not done: the web composer and the delete are still missing, as you accepted. The gate's near-duplicate notes on planDatabase, databaseNamed and setDatabase were left alone. --fix changed nothing, so its comment-wrap note stays. It says the nightly rewrap on main handles those comments.
Try it: bun test test/managed-database.test.ts. In the terminal, open the infra screen and press b to compose a database.
🤖 Generated with Claude Code
The gate's as never rule failed on the plan API test I added. That test now registers the routes on a real Router<Handler> and reads the handler with handlerOf, so the as never cast is gone.
The rule check passes locally now, but I only ran it after committing, since the gate skips uncommitted files. The type check and test/managed-database.test.ts (15 tests) pass. The full check has not run on this push.
The test still has one as unknown as on the handler's context (a minimal context object, like the one the tool test already uses). The gate did not flag it.
The gate's notes about a long comment line and three near-duplicate functions are unchanged from the last push. They were not what failed the check.
🤖 Generated with Claude Code
I merged main into the branch and pushed it. The merge had conflicts in two files, and I kept both sides in each.
src/http/mcp/tools/infra.ts: the import line now brings in bothplanDatabaseand the bucket actions. The tool'sdocstring describes the Postgresdatabasewant and also theprice/bindbucket actions. I usedmain's shorter description, "Machines and spend."docs/features/infra.md: the "A database (#17074)" section andmain's "Buckets (#17073)" section both stay.
The type check is clean, and the 9 infra, database and bucket test files pass (90 tests, 0 failures). I did not run the full suite or the scoped scripts/fast.ts run. It asked for 3617 test files, so I timed it out and ran only the files that cover this change.
scripts/gate.ts --fix printed three similar-code notes and left nothing to commit. They pair planDatabase with planCompose, databaseNamed with getChange, and setDatabase with setSnapshot. I did not fold any of them together. The --fix output was cut to its last three lines, so I don't know whether those notes block the check.
A managed Postgres on DigitalOcean is now a kind the infra plan can price, hold to the account's ceiling and build. Its URL becomes the app's production secret. The new database tests pass, along with the existing infra, schema, MCP, door, dead-code and hollow suites and
tsc. I did not run the whole suite; the forge's check does that.What changed
managed_databaseholds name, account, region, size, app, secret name, cluster id and state.20261201170000-managed-databaseis pinned, andsrc/generated/migrations.tsis regenerated on this base, which was what broke #17090.src/cloud/database.ts): DigitalOcean's API lists sizes but no prices, so the four one-node sizes are held there at list price (1 vCPU/1 GB $15, 1/2 $30, 2/4 $60, 4/8 $120 a month). The ceiling rounds them up, and the account's month (accountCents) and the infra meters now count databases.src/cloud/plan.ts):WantgainsDatabaseWant. A database plans three steps: create the cluster, wait until it is online, then give the app its URL. Refusals are worded: no account, read-only, not a DigitalOcean account, bad region, unknown size, reserved secret name, unknown app, name taken, and the ceiling's own sentence. Machine planning is untouched, and the existing plan tests are unchanged.src/actions/database.ts): the cluster is made once, even on a retry, because it is looked up by tag first. The URL is read from DigitalOcean at bind time and set as a secretapp_envvariable (DATABASE_URL, or a namedsecret). Production only, so a preview never holds the production database. It never appears on the row or in an event.don the Infrastructure screen (app, region, size, then the plan with Build); databases also show in its list.infratool'splantakeswant {database: true, app, where: account@region, size?, secret?}.POST /api/v1/admin/infra/plantakesdatabase: true.infra listandsaysname databases.docs/features/infra.mdhas a new section.refusalOf,spendOf,gatedFetch,oneAtATime,setAppEnvVar,nameForandkeptPlacesfor regions. No new dependency.What I chose not to do
/infraweb page change. It composes machines only; the page's meters include database cost.planDatabaseand are tested.infra.md, so a second screen or page would only repeat them. The gate's both-doors rule asks for a new screen and how-to, so I used itsNo door:line, with the reason in the commit.DATABASE_SIZESneeds an edit.How to try it: on the preview, call the
infratool withplanandwant {database: true, app: "<owner>/<app>", where: "digitalocean/<account>@nyc1"}, thenapplyits id. Or pressdon the terminal's Infrastructure screen. Build needs a DigitalOcean account with writes allowed.Closes #17074