Repository navigation
Conversation
…ects a config change Maps each incompatible plan path (endpoint port, db major version) to the config.toml key or SUPABASE_*_PORT env var that set it, shows the saved and requested values, and suggests reverting it or running the stack's exact destroy command with a data-loss warning.
…mplete Always suggest the exact --stack-id destroy command instead of an unquoted --stack <name> that re-resolves against the caller's current workdir, carry structured per-change records (service, path, key, saved, requested) plus the recreate command on the JSON/stream-json error envelope via MachineErrorContext, and collect every incompatible member into one error instead of reporting only the first, deduplicating shared API port lines. Use the production planSupabaseComposition planner in the start handler's integration tests instead of a hand-rolled approximation, and derive the port-setting table and createCreations' env-override calls from one shared definition per port to prevent drift.
…name-the-changed-setting-and-the-fix-when-a-saved-stack
…in the stack error Same-major Postgres version differences and catalog-pinned artifact versions have no config.toml key or env var, so the incompatible-stack error no longer suggests reverting major_version or an editable setting for them: it names the full saved and requested builds, drops the revert sentence when nothing is editable, and explains the fix in plain language. Mixed rejections keep the revert advice for the editable keys only, with singular/plural grammar matching their count. destroyCommandFor now takes only the stack id (it never read the name) and is computed once per rejection, reused for both the error suggestion and the JSON/stream-json envelope's recreate_command. Move planSupabaseComposition's export from the main @supabase/stack/effect entrypoint to @supabase/stack/testing, since the CLI only needs it to build a realistic test double for its own composition plan.
There was a problem hiding this comment.
🤖 AI Review
Both independent reviews were available. Verified all five findings against the checked-out code and trusted conventions: one major rollback race, two minor concerns, and two nits. No findings overlapped.
Findings
| Severity | Location | Category | Sources | Claim |
|---|---|---|---|---|
| 🟠 MAJOR | packages/stack/src/StackHost.ts:584 |
concurrency |
codex | Startup rollback can overwrite mutations committed by an attaching client because RPC becomes available before startup can no longer fail. |
| 🟡 MINOR | packages/stack/src/StackHost.ts:584 |
error-handling |
codex | Restoration failures are silently discarded, so failed startup can leave changed endpoint intents or claims persisted without reporting that rollback failed. |
| 🟡 MINOR | packages/stack/src/StackHost.ts:511 |
correctness |
claude | An endpoint intent change can produce a port-change report whose from and to numbers are identical, including text such as api: 26199 → 26199 and a matching endpoint_changes entry. |
| ⚪ NIT | apps/cli/src/commands/experimental/stack/start/start.handler.ts:505 |
code-quality |
claude | A stopped existing stack that reaches the normal start path resolves requested creations twice, repeating Functions dotenv reads when Functions is enabled. |
| ⚪ NIT | packages/stack/src/composition/EndpointReplan.integration.test.ts:54 |
comments |
codex | The new test comment contains implementation audit-trail language and exceeds the trusted repository convention for concise fixture explanations. |
Stats
Claude findings: 2 · Codex findings: 3 · Confirmed: 5 · Refuted: 0 · Uncertain: 0
Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
…tart A rejected config change that mixed an editable key (e.g. a port) with a non-editable one (a catalog-pinned artifact or Postgres build) suggested reverting the editable key and dropped the non-editable change, but reverting it alone can't unblock start. Use the destroy-only wording whenever any non-editable change is present, and lead the change-list message with a sentence so it reads standalone in text output. Also document the `stack_changes`/`recreate_command` JSON contract and the intentional `--yes` omission, and make several integration-test assertions that lived inside `if (error instanceof StackCommandStartError)` fail loudly instead of passing vacuously for a different error type.
A changed endpoint on an otherwise-compatible instance now re-plans inside the stack package's own owner startup, while the new owner alone holds the stack's lease, instead of rejecting the start. It saves the updated endpoint intent as one document with the old port claim dropped, just before its own normal endpoint binding claims the requested port or a freshly chosen automatic one, reusing every check a live composition bind already applies. Any startup failure or interruption from that save onward restores the saved state and claims as they read before the re-plan. The CLI passes the requested creations into owner startup through a private file and reports each changed endpoint's old and new port in text, JSON, and stream-json output. A changed artifact version or PostgreSQL major version still fails before modifying the stopped composition.
… attach The saved document and its new endpoint claims now commit, and the rollback scope ends, before the owner serves RPC or publishes its holder, so a later startup failure can no longer undo an attached client's own change along with the re-plan. A restore failure now logs and appends recovery guidance to the original error instead of being swallowed, and an automatic re-plan that resolves back to its previous port is no longer reported as a change. The stopped-stack start handler also reuses the creations already resolved for the re-plan instead of reading the Functions dotenv a second time.
catchCause never ran on interruption, so an external interrupt landing after the prepared document saved but before the claim finished skipped the restore entirely, leaving the saved document with new intents and missing or partial claims. The commit now runs interruptibly under an uninterruptible mask whose restore attempt always runs on any unsuccessful exit, including interruption, and still only extends a genuine typed failure's message with recovery guidance when the restore itself also fails. Updates the ADR, package README, and start command's side-effects doc to describe the rollback as covering only the save-and-claim commit, which finishes before the owner serves RPC or publishes its holder; a later startup failure keeps the committed state and the next start reuses it.
525601f to
d5fc82b
Compare
# Conflicts: # apps/cli/src/commands/experimental/stack/start/SIDE_EFFECTS.md # apps/cli/src/commands/experimental/stack/start/start.handler.ts # apps/cli/src/commands/experimental/stack/start/start.integration.test.ts
# Conflicts: # packages/stack/src/effect.ts
…hanges-when-a-stopped-stack-starts
Coly010
left a comment
There was a problem hiding this comment.
Really nice to see the destroy-to-change-a-port trap go away. I ran it locally on a Docker stack next to develop, and the headline case, removing [api] port and changing the db port all behave as described.
Requesting changes mainly for the first point, the others are smaller and I'm happy to hear it if you'd rather split any of them out:
- the develop merge (3a70647) dropped the
annotateCurrentSpancalls #6935 added to start.handler.ts. Nothing tests them, so CI wouldn't catch it - an owner that's already alive (e.g. after
stack prepare) skips the re-plan, and the error points atstack destroy - re-adding an excluded service after a re-plan creates a second instance and orphans the old one
- a start that fails after the re-plan never reports the move on the retry
- small JSON nit on the
endpoint_changeslabel
otherwise, looks good to me!
# Conflicts: # packages/stack/src/composition/Supabase.native.integration.test.ts # packages/stack/src/effect.integration.test.ts
…rt conflicts Restore the start span annotations lost in a develop merge, rewrite a stopped excluded instance's endpoints so a later start reuses it, carry the port conflict from owner startup so the error names the config key, advise stop and start when a live owner meets changed ports, and list the endpoints keys each JSON endpoint change moved.
Coly010
left a comment
There was a problem hiding this comment.
Thanks for turning these around so quickly! I re-ran all three repros on 8380bd8 and they're fixed now. The excluded storage instance gets reused rather than duplicated, and the conflict error reads much better.
Approving so you're unblocked. Two small follow-ups inline on the stop/start advice, and I'd like the first one in before merge if you can
# Conflicts: # packages/stack/src/HostProcess.ts # packages/stack/src/effect.ts # packages/stack/src/internal/host-process.ts
…lans The composition planner marks incompatible entries whose only difference is the intents of endpoints both sides declare, and both the owner's re-plan and the live-owner start advice use that flag. An added or removed endpoint or a version change now gets the destroy advice, and the JSON error envelope omits recreate_command when stop and start is the remedy.
# Conflicts: # packages/stack/src/HostProcess.integration.test.ts
# Conflicts: # apps/cli/src/commands/experimental/stack/start/SIDE_EFFECTS.md
With
[experimental] stackenabled, changing a port inconfig.toml(including removing the fixed ports a legacysupabase initwrites) used to make the nextsupabase startfail with "The saved stack cannot adopt these changes". The only way out was to destroy the stack and lose its data. Now, when a stopped stack starts, it applies endpoint port changes and prints each one, for exampleapi: 54321 → 26199. JSON and stream-json output add anendpoint_changesarray to the success payload; each entry names the endpoint, theendpointskeys it moved (keys), and itsfrom/toport.config.tomlis the source of truth. The re-plan runs inside the stack owner's startup, while the owner holds the stack lease and before it binds any endpoints. It saves the requested endpoint intents, releases the changed endpoints' rows in the port registry (for example an old sticky automatic port), and claims the new ports through the owner's normal port acquisition, with the usual conflict and occupancy checks. Concurrent starts attach to the winning owner instead of racing it.[api] portmoves the stack to an automatic port instead of being silently ignored. A stopped service excluded during a re-plan has its endpoints rewritten when it is requested again, so the start reuses it and its data instead of creating a second instance.stack prepare: its error now suggestsstack stopthenstack startinstead ofstack destroy. Artifact-version and PostgreSQL major-version changes are still rejected.0600), short-lived file the owner deletes after reading, instead of its command line, so secrets don't appear in process listings.ADR 0017 is amended: saved ports stay stable unless the configuration deliberately changes them on a stopped stack.