feat(stack): prepare slim resources on demand - #6250
Conversation
|
Automated review triage is complete for this batch. Fixed:
Deliberately deferred:
This is the final automated-fix pass for this PR. The remaining items need human product and architecture review rather than another mechanical review loop. |
|
Final automated-review disposition:
This is the final automated-review pass. The remaining recorded deferrals are unchanged; the PR is ready for human review. |
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase/cli/supabase@5da95a1542b68571ca5ddc04b3e00904cbd58fd1Preview package for commit |
There was a problem hiding this comment.
💡 Codex Review
cli/packages/stack/src/BinaryResolver.ts
Lines 726 to 731 in 05b8067
When two processes repair the same incomplete cache, both can fail the initial rename and observe the destination as incomplete; if one publishes after the other's check, this unconditional removal deletes the newly complete directory that the winner may already have returned to a starting service. That produces intermittent missing executables despite successful resolution. Use a cross-process lock or a replacement protocol that cannot remove a destination after another contender has published it.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8372805bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the cache-publication finding from review 4976855133 in 4d31f6c. Invalid-destination repair now takes an atomic cross-process publication claim and revalidates the destination under that claim before removing anything. Private staging and the uncontended atomic-rename path remain unchanged. A deterministic resolver integration scenario covers a stale repairer observing another resolver publish and verifies that the winner is reused rather than replaced. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d31f6c4aa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5f1603bf1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 066c466b66
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
cli/packages/stack/src/services/postgres-init.ts
Lines 113 to 116 in ac4cb18
If initial native initialization is interrupted or a migration fails after initial-schema.sql creates the authenticator role, the next start takes this branch and skips every remaining init script and migration. The one-shot can then report success against a partially initialized database, leaving later services to fail on missing schema objects until the data directory is deleted; detect completion using a marker written only after the entire migration sequence succeeds rather than an early-created role.
cli/packages/stack/src/services/postgres-init.ts
Lines 92 to 93 in ac4cb18
When cacheRoot contains whitespace, the generated shell expands this composite psql command as multiple words, so native Postgres initialization tries to execute only the path prefix and fails. The later init_flags and migrate_flags strings also append unquoted SQL paths, causing the same splitting for every -f argument; invoke the quoted executable separately and preserve migration paths as shell-safe arguments or arrays.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…3-stack-prepare-slim-resources-safely-on-demand-or-upfront # Conflicts: # packages/stack/src/Stack.unit.test.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 213f057a33
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b2cb6382c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed798cf19b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9f7309865
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05ced50120
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f109e34a01
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
avallete
left a comment
There was a problem hiding this comment.
The architecture holds: checksum-before-extract, exact-identity cleanup, omitted-mode fallback order, and name-only docker exec secrets.
Requesting changes on remaining start/attach/secret/port issues. Inline comments cover the ones I want fixed. The rest was checked on 1f3a1431a and is listed below so it is not silently dropped.
Please address
- Attach can still skip the mode check on first launch (reply on the existing thread).
- Native fallback still strips an explicit
edgeRuntime(e.g.functions devon a Docker-less host). - Native
postgres-initnever writesapp.settings.jwt_secret. docker runstill puts JWT/passwords on argv (envArgs).resolveConfigtreats schema-defaultinspectorPortas exact; the managed plan does not.functions devcold start can fail after the claim whenconfig.tomlomits the key.- process-compose graceful stop can run cleanup twice.
- Control status timeout is treated as “no owner”.
- Interrupt during
allocateManagedPortsleaks claims. - Leaf
chownof the Postgres bind mount does not fix root-owned parent dirs on Linux Docker (reply on the existing thread).
Seen, not requesting a change
- PID-reuse leaving a live-looking port claim: real, but already deferred on the existing thread. Not re-opening.
- Recursive
chownof persisted PGDATA: the leaf chown is the intended first-init fix. Migrating a Docker-UID tree is a different product decision. - Empty
init-scriptsglob still committingcli_init: the bash is real, but it needs a published cache whosemigrationsdir exists with no scripts. Completeness only checks the directory; official bundles plus checksum-before-extract make this a mispackaged-cache path, not a normal start. - Cache repair
fs.remove(cacheDir)under a repairer-only lock: path isversion/target, not full identity. Adjacent to the publication-lock / identity item already deferred. - DX leftovers (duplicated docker-only sets, hand-rolled
isNotFound, EffectrunSyncin listeners, tautological tests): mechanical, not merge-blocking.
Checked and dropped
- “Every default
functions devcold start fails”: the omitted-key bug above is real. Blast radius is not —supabase initwritesinspector_port = 8083, andsupabase startdoes not setinspectorPort. - Replay native init on pre-
cli_initdata dirs: matches the stated no-legacy-migration policy for unpublished managed state. /usr/local/bin/entry.shcrash-looping GHCR Postgres: catalog image isghcr.io/supabase/cli; docker e2e starts through that entrypoint; CI is green.createStack({ storage: {} })must auto-strip Docker-only services: explicit enable should fail on native, not be removed. DefaultcreateStack()already leaves those off.- JWT on
docker execargv: already fixed (-e KEY+ServiceDef.env). Remaining leak isdocker run/envArgsabove. - Streaming zstd, 24h publication-lock reclaim, legacy
formatVersion/autolaunch migration: already deferred; not re-raising.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 441c767d4e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5da95a1542
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
@supabase/stackruntime core Effect-native across Node and Bun, with Promise adapters only at the public non-Effect edgeoff,lazy, andeagerpreparation policies with dependency closure, bounded concurrency, coalesced work, and deterministic disposalContext
Direct and managed stacks now share one service graph, preparation pipeline, port allocator, proxy, and process lifecycle. Direct callers own a scoped in-process handle. Managed callers use a detached supervisor with one durable document and one loopback control owner; CLI handlers delegate to that facade instead of maintaining PID-based liveness or parallel metadata.
When mode is omitted, selection prefers a usable Docker or Podman runtime. If neither is usable on a supported host, the first launch selects native mode and disables Docker-only services before port planning or managed state acquisition. Explicit native and Docker choices remain strict, preparation never falls back across modes, and a managed stack pins its selected runtime after ownership is acquired. Changing modes requires deleting and recreating that private managed stack state.
Preparation is driven by the service catalog. Eager resources are prepared during stack start, lazy resources use the same activation path as proxy and programmatic callers, and concurrent requests join the same owned work. Native archives are verified before extraction, decompressed through an interruptible callback boundary, validated for the current host, post-processed with checked exit codes, and published from private staging through atomic rename. Docker services resolve one canonical GHCR image and retry only classified transient pull failures.
Port allocation owns bound sockets until each runtime consumer takes over. Explicit ports remain exact; automatic managed assignments remain sticky and are coordinated with per-user claims. Managed control uses a deterministic sequence of eight loopback candidates, read-only probes never claim ownership, and mutations fail closed when no unambiguous owner or free candidate exists.
Native mode currently supports Postgres, Auth, and PostgREST. Docker-only services remain container-backed. On Linux, Docker Postgres performs only the required image setup as root and then drops to the host UID before touching bind-mounted data. Database bootstrap is a resumable observable one-shot dependency, and cleanup is scoped to exact owned containers, ports, processes, and auto-managed paths.
The managed document and identity markers are private unreleased state. This change intentionally implements the current model directly without legacy migration or compatibility adapters, while preserving fail-loud ownership and destructive-cleanup safeguards.