Skip to content

feat(composer): add branch domains and guard destructive deploys - #383

Draft
sorenbs wants to merge 6 commits into
mainfrom
feat/environment-custom-domains
Draft

sorenbs wants to merge 6 commits into
mainfrom
feat/environment-custom-domains

Conversation

@sorenbs

@sorenbs sorenbs commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Purpose of change

Declare Composer custom domains by actual branch name, finish DNS setup in Console, and require explicit approval before destructive deployment changes.

The broader declaration, branch flag and consent design remains under review in Will’s review. This PR stays draft pending that decision.

What's changed and why

In the composer section of prisma.config.ts:

prismaCloud({
  domains: {
    main: { 'shop.web': ['example.com'] },
    staging: { 'shop.web': ['staging.example.com'] },
  },
})
  • Service keys are full addresses such as shop.web, including the deployed app name (also when overridden with --name). Domain resources use that same full address. Branch keys are exact platform names. A default deploy reads the current default branch name; neither main nor production is an alias. Modules stay independent of their environment, unlisted branches inherit no domains, and changing the default never moves hostnames.
  • Use prisma deploy module.ts --branch staging. Keep --stage as a deprecated alias, reject both together, and preserve branch IDs and existing deploy state. Programmatic deploys accept branch with the same compatibility alias.
  • Attach domains after promotion. Missing TXT ownership, missing routing DNS or a Cloudflare proxy that prevents registration produces Setup required, a prefilled Console link, the API’s setup hint when available, and the generated app URL. Later deploys retry setup and reuse Console-completed bindings. Conflicts, quotas and API outages remain errors.
  • A shared guard checks the entire engine plan before apply. Domain removal, service renames, database or bucket replacement, and container teardown require approval on every branch. The plan shows the resolved target and warns about parent cascades, including externally managed bindings. Ordinary Compute code-version replacement stays automatic.
  • Use the CLI's explicit-consent prompt, or --confirm <plan-token> after reviewing the refusal in CI. --yes cannot approve it. Programmatic deploy/destroy return DEPLOY.DESTRUCTIVE_APPROVAL_REQUIRED with failure.meta.plan, accept destructiveApproval, and support an explicit approveDestructivePlan callback. A retry replans and rejects stale approval before any planned changes run.
  • Keep Node and Bun execution working, and give concurrent runs separate guarded entrypoints. CI cleanup explicitly approves only its current run's named test project. The command family's static import graph stays free of Alchemy and Effect.
  • Platform PR #5796 preserves pinned branches and branches with domain bindings during Git deletion and idle cleanup. It returns removal guidance and blocks stale GitHub Actions OIDC credentials from recreating deleted previews. Remove declared bindings before apps and branches through the confirmed plan; ordinary convergence preserves Console-only bindings, and parent-deletion warnings cover their cascade.
  • Include ADR-0058, its earlier-decision amendments, the public guide and the installed agent skill in this PR. Domain purchase and DNS-zone ownership keep their own lifetimes; Composer never needs registrar credentials or cancels domains during teardown.

Rollout and limits

Deploy platform branch protection #5796, TXT verification #5785, and Console setup #5792 before releasing these Composer packages. Expected setup outcomes are HTTP 422 domain-ownership-required, HTTP 400 domain-dns-required and HTTP 400 domain-cloudflare-proxy; unrelated errors still fail deployment. The companion rollout plan is in #5792. No schema, secrets, infrastructure, or workflow YAML changes are needed. Apps without domain declarations make no domain requests.

The guard checks resource lifecycle actions, not SQL migrations. Container setup, missing environment-variable seeding and deploy-attempt recording happen before the resource plan. Default-deployment teardown attempts to remove the empty project; the platform keeps it if another branch still has resources. Parent cascades are warned about rather than enumerating externally managed children.

Testing notes / Before-after

Before: Composer had no domain declaration, guided setup, canonical branch flag or destructive-change guard. After: branch-specific hostnames finish setup in Console, and omission cannot silently remove a serving binding or durable resource.

  • Root format, build (39 tasks), type checks (80 tasks plus scripts), lint, dependency/architecture lint, cast ratchet, skill packaging and command-family static graph checks pass after the Cloudflare compatibility fix.
  • Full touched-package suites after the fix: lowering 219, Prisma Cloud target 476, docs website 9. Coverage includes the exact HTTP status/code pairs, reporting the Cloudflare hint, ignoring malformed hints, clearing stale hints after Console setup, and promotion ordering across repeated deployments.
  • Earlier full verification after resolving current-main addressing conflicts: core 259, local target 58, internal CLI 322 (one platform-specific skip), public CLI 6, and repository scripts 247. No new changes touch these packages.
  • Real Alchemy plan/state tests cover whole-plan refusal without writes on default and named branches, approved removal, service rename, replacement, teardown, stale state/target/input approvals, unresolved output fingerprints, and resumed cleanup of interrupted replacements.
  • Native Node and Bun children with durable local engine state verify refusal makes no provider writes and an exact-token retry completes; the Bun fixture imports Bun-specific code. Windows reproduction commands use native path separators.
  • Domain tests cover branch-name lookup, full service addresses (shop.web), promotion ordering, repeated pending setup, Console-completed bindings, invalid/duplicate declarations and unexpected HTTP errors. Console browser verification and embedded screenshots remain in the companion PR.

@prisma-gizmo

prisma-gizmo Bot commented Oct 23, 2026

Copy link
Copy Markdown

⏸️ Gizmo skipped the automatic review of 3d6b71b because this pull request is a draft. It will review automatically once the PR is marked ready for review.

  • Check this box to request a one-time review of the current commit.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@prisma/composer@383
npm i https://pkg.pr.new/@prisma/composer-cli@383
npm i https://pkg.pr.new/@prisma/composer-prisma-cloud@383

commit: e4126b8

@sorenbs sorenbs changed the title feat(prisma-cloud): manage custom domains by branch feat(composer): add branch domains and guard destructive deploys Oct 23, 2026

@wmadden-electric wmadden-electric 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.

Thanks for this, Søren. The goal is right: say in code which hostname serves which part of the app on each environment, and never fail a deploy because DNS isn't set up yet. Working through it, though, we found it touches several design problems at once. We'd like to solve those first, so we're requesting changes here and proposing a replacement design.

What we're proposing instead

// prisma.config.ts
composer({ extensions: [prismaCloud(), nodeBuild()], state: prismaState(), config: [dotenv()] })

// module.ts
export default module('shop', { input: type({ 'SITE_HOSTNAME?': 'string' }) },
  ({ input, provision }) => {
    const web = provision(webService, { deps: { auth: auth.rpc } });
    provision(ingress({ name: 'site', hostname: input.SITE_HOSTNAME, target: web.http }));
  });
# .env.production
SITE_HOSTNAME=www.myapp.com
  • A hostname is declared next to the service it routes to, as an ingress() node in the graph. The ingress points at the service's exposed HTTP port, and the service knows nothing about its domains.
  • Per-stage values come from configuration providers named in prisma.config.ts (dotenv() first). The root module's input schema validates them. A stage that sets no hostname, such as a PR preview, gets a generated hostname.
  • On the platform, an ingress becomes a record of its own on the Branch. It exists before DNS is set up, survives promotes, and is found again by its logicalId. Your Console setup link (prisma/pdp-control-plane#5792) and TXT ownership proof (prisma/pdp-control-plane#5785) fit straight into this.

Why not this PR's approach

  • The domains map in the Prisma Cloud options puts application settings in the config file, and it names services by strings that nothing keeps in sync with the graph. The config file is meant to say which extensions and state store a deploy uses, and nothing about the app itself.
  • Renaming --stage to --branch. "Stage" is Composer's target-neutral word for an environment. It also covers local dev, which never has a Branch. We've recorded this in ADR-0059 (#385).
  • The destructive-plan check is a real need, but it isn't specific to domains. Losing a domain is like losing a database or any other part of the topology. We'd like it designed as general "ask before losing data" consent, separately, rather than through a plan-hash token on this path.

Where to look and comment

  • Composer design, ADRs 0060–0062 plus a Prisma Cloud ingress doc: #386
  • The platform's ingress record, ADR 015: prisma/pdp-control-plane#5795
  • Stage terminology, ADR-0059: #385

Your feedback on those would be really valuable, especially on the platform proposal, since you know the domain flow best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants