-
Notifications
You must be signed in to change notification settings - Fork 7
feat(db-tools): provision_database no longer touches Postgres #1863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ import { | |
| provisionEnvVars, | ||
| } from '../provision-database/env-file'; | ||
| import { loadProvisionManifest } from '../provision-database/manifest'; | ||
| import { applySqlFixups } from '../provision-database/pg-fixups'; | ||
| import { selectProvisionRequest } from '../provision-database/preset-match'; | ||
| import { requestDatabaseProvision } from '../provision-database/request-database'; | ||
| import { type ProvisionOverlay, resolveProvisionModules } from '../provision-database/resolve'; | ||
|
|
@@ -62,7 +61,6 @@ export type ProvisionDatabaseDetails = { | |
| databaseId?: string; | ||
| databaseName?: string; | ||
| ownerId?: string; | ||
| fixupNote?: string; | ||
| /** True when an existing live binding was kept — nothing changed. */ | ||
| skipped?: boolean; | ||
| }; | ||
|
|
@@ -93,7 +91,7 @@ export const provisionDatabaseTool: HarnessTool< | |
| name: 'provision_database', | ||
| label: 'Provision database', | ||
| description: | ||
| 'Bootstrap a new Constructive database for the project under your account: provision the standard module set, enable membership defaults, and write credentials (DATABASE_ID, ACCESS_TOKEN, etc.) to the project .env. Run this ONCE before any schema/record tools. If the project is already bound to a live database under the signed-in account it skips; if the bound database no longer exists on this backend (refreshed/deleted) or belongs to a different account, pass reprovision: true to mint a fresh one (old keys archived in .env, old database kept; rebuild the schema afterwards).', | ||
| 'Bootstrap a new Constructive database for the project under your account: provision the standard module set and write credentials (DATABASE_ID, ACCESS_TOKEN, etc.) to the project .env. Run this ONCE before any schema/record tools. If the project is already bound to a live database under the signed-in account it skips; if the bound database no longer exists on this backend (refreshed/deleted) or belongs to a different account, pass reprovision: true to mint a fresh one (old keys archived in .env, old database kept; rebuild the schema afterwards).', | ||
| promptSnippet: | ||
| 'provision_database: one-time bootstrap of the project database (owner + modules + .env). Run before describe_schema/provision_blueprint. Skips when the existing binding is live under the signed-in account; reprovision: true replaces a dead or foreign-account binding (archives old keys, never deletes the old db). Gated.', | ||
| parameters: ProvisionDatabaseZod, | ||
|
|
@@ -239,8 +237,6 @@ export const provisionDatabaseTool: HarnessTool< | |
| ); | ||
| } | ||
|
|
||
| const physicalDb = process.env.CONSTRUCTIVE_DB || 'constructive'; | ||
|
|
||
| // Provision on the API endpoint: requestDatabase claims a warm-pool | ||
| // database when the resolved module set matches a cataloged preset | ||
| // (near-instant) and cold-provisions asynchronously otherwise; the ticket | ||
|
|
@@ -268,10 +264,6 @@ export const provisionDatabaseTool: HarnessTool< | |
| return fail(`Database provisioning failed: ${detail}.${nameTakenHint}`); | ||
| } | ||
|
|
||
| // Enable membership defaults + naming settings at the SQL level. Best-effort: | ||
| // provisioning already succeeded, so a fixup failure is a warning, not an error. | ||
| const fixup = await applySqlFixups({ databaseName, physicalDb }); | ||
|
|
||
| // Persist the binding to the project .env (upsert, preserving other keys). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 bug · high Membership-defaults fixup deleted without replacement Deleting 📋 Prompt for AI AgentsRestore the guarantee that agentic/db-tools/src/provision-database/pg-fixups.ts previously provided: after provisioning, |
||
| const merged = mergeEnv( | ||
| existing, | ||
|
|
@@ -301,7 +293,7 @@ export const provisionDatabaseTool: HarnessTool< | |
| hasBinding && params.reprovision | ||
| ? ' Previous binding archived in .env (old database kept); rebuild the schema with provision_blueprint + run_codegen.' | ||
| : ''; | ||
| const message = `Provisioned database "${databaseName}" (ID: ${databaseId}). Credentials written to .env. ${fixup.note}${prewarmNote}${reprovisionNote}`; | ||
| const message = `Provisioned database "${databaseName}" (ID: ${databaseId}). Credentials written to .env.${prewarmNote}${reprovisionNote}`; | ||
| return { | ||
| content: [{ type: 'text', text: message }], | ||
| details: { | ||
|
|
@@ -310,7 +302,6 @@ export const provisionDatabaseTool: HarnessTool< | |
| databaseId, | ||
| databaseName, | ||
| ownerId, | ||
| fixupNote: fixup.note, | ||
| }, | ||
| }; | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 bug · high
Strict
app_publiclookup loses its naming-settings guaranteeresolveSchemaIdnow returnsschema-unresolvedunless a logical schema namedapp_publicexists (agentic/db-tools/src/context.ts:348), but this PR also deletedpg-fixups.ts, the only code that setconstructive.simple_schema_names/schema_use_underscores— which, per that file's own comment, is what makesprovision_blueprintcreateapp_publicinstead of a hyphenated<db>-<hex>-app-publicschema. No replacement exists in the provision request path (request-database.tssends only a preset/module list). If the backend still applies the old naming default, provisioning succeeds but every tool gated onresolveProjectContextfails withschema-unresolved; previously the resolver fell back topublic/any first schema and kept working. Legacy databases kept by the reprovision path (old database preserved) cannot resolve at all under the strict filter.📋 Prompt for AI Agents
In agentic/db-tools, reconcile the strict
app_publicrequirement inresolveSchemaId(agentic/db-tools/src/context.ts lines 341-364) with the removal of provision-database/pg-fixups.ts. The deleted fixup setconstructive.simple_schema_namesandconstructive.schema_use_underscoressoprovision_blueprintcreated anapp_publicschema. Either move that guarantee into the provisioning request path (agentic/db-tools/src/provision-database/request-database.ts or a preset flag in presets.ts) or add a documented fallback inresolveSchemaIdwhenapp_publicis absent (with a legacy-naming reason pointing to reprovision). Update agentic/db-tools/tests/context.test.ts to cover the chosen behavior.