← Back to Pull requests

Declare a public service in code with publicUrl(): a named hostname per environment, or the service's prisma.build URL #400

Closed
unknown closed this pull request without merging on Oct 29, 2026 20:27 UTC
View on GitHub
unknown unknown commented on Oct 29, 2026 19:49 UTC
Author

At a glance

An app now says in code which service the internet reaches, and at which hostname in each environment:

import { module, resolve } from '@prisma/composer';
import { publicUrl } from '@prisma/composer-prisma-cloud';

export default module('shop', ({ environment, provision }) => {
  const web = provision(webService);
  const url = resolve([environment.name], ([name]) =>
    name === 'production' ? 'shop.com' : publicUrl.prismaBuild());
  provision(publicUrl({ name: 'site', url, target: web.http }));
});

$ prisma deploy --environment pr-42
Address       Deployed
shop.web      compute-service cps_awd86…  https://awd86….ewr.prisma.build
shop.site     public-url      cps_awd86…  https://awd86….ewr.prisma.build

$ prisma dev
shop.site names the hostname shop.com. prisma dev ignores it and serves the service on its local URL.

In production the same code attaches shop.com to web as a custom domain.

What this PR changes

1. publicUrl({ name, url, target }), publicUrl.hostname(h) and publicUrl.prismaBuild() in @prisma/composer-prisma-cloud.
2. On Prisma Cloud, a named hostname becomes one custom domain on the target service, attached after the service's new deployment is live. publicUrl.prismaBuild() creates nothing and reports the service's existing prisma.build URL.
3. Both the deploy and prisma dev check every public URL's resolved url before any of the app's resources are created or changed. Two public URLs naming the same hostname fail the same check.
4. Under prisma dev, a named hostname creates nothing, and the session prints one warning per public URL that names one. To carry that warning, core's preflight input gains an optional warn, and the CLI's dev command gains a target-warning event.
5. The compute service's lowering adds its platform id, serviceId, to its outputs.
6. ADR-0060 now says a deploy never replaces a serving hostname with one that cannot serve yet. The guide, the agent skill and examples/env-param describe and use public URLs.

A public URL is a node wired to a service's HTTP interface

ADR-0060 decided that traffic from the internet reaches a service only through a public URL, a node in the graph that the author provisions where the hostname is decided. A service exposes an HTTP interface (expose: { http: rawHttpContract }). The public URL depends on that interface and exposes nothing, because nothing inside the graph calls it: its caller is the internet.

publicUrl() builds that node with core's resource(), using the support the previous slice added for a resource wired at construction (prisma/composer#396). So core learns nothing about public URLs. The node has one dependency, target, typed as a raw HTTP dependency, so wiring a public URL to an RPC or Postgres interface fails the type check. Its url is stored in the resource's props, where Load's second pass resolves a resolve() value per environment.

url takes one of two strategies, both plain objects so a resolve() callback can return them. publicUrl.hostname('shop.com') names a hostname; a bare string means the same. publicUrl.prismaBuild() means the service's own <id>.<region>.prisma.build hostname. Leaving url out throws. A hostname is trimmed, has one trailing dot dropped and is lowercased, and anything that is not a plain DNS name throws at construction: a scheme, a path, a port, a * label, or an IP address.

How a named hostname reaches Prisma Cloud today

The platform's record for a hostname that exists before DNS (the RoutingUrl) is not built yet; that is a later slice. Until then a named hostname lowers to Alchemy's existing Prisma.CustomDomain. Two consequences follow from how that resource and the platform behave:

  • The platform refuses a custom domain on a service with no live deployment. The custom domain's app is taken from the service's Deployment output, not its App, so Alchemy creates the domain only after the promote. That is why the compute lowering now outputs serviceId.

  • The platform refuses a hostname whose ownership TXT record or CNAME is missing. The deploy fails with Alchemy's error. With the Alchemy version pinned today that error is Prisma Management API request failed (domain-ownership-required); alchemy-run/alchemy#2698 makes it name the record, and Composer picks that up with a version bump.
  • The hostname is part of the custom domain's Alchemy resource id (shop.site.domain.shop.com). Changing a public URL's hostname is then a new resource plus the removal of the old one. Alchemy runs every create before it deletes anything a program no longer declares, and a failed create stops the run. So if the platform refuses the new hostname, the deploy fails and the old one keeps serving. With the node's address alone as the id, Alchemy refuses any hostname change outright.

    That is the rule Will set for this project, now recorded in ADR-0060: a deploy never replaces a serving hostname with one that cannot serve yet. Removing the public URL, or switching it to publicUrl.prismaBuild(), is an explicit choice and goes through. When the RoutingUrl arrives, a hostname change updates the row in place and the platform accepts an unready hostname, so the project plan has that slice check the rule explicitly.

    Two limits stay until later slices, and the guide states both:

  • A named hostname works only in production. The Alchemy release that lets a custom domain attach on any Branch (alchemy-run/alchemy#2696, merged) has not shipped. Elsewhere, use publicUrl.prismaBuild().

  • Moving a hostname to another service takes two deploys. Alchemy refuses to move a custom domain between services. The hostname does not serve in between.
  • prisma dev

    Local dev runs the same lowering against local providers (ADR-0041). A new local custom-domain provider records the hostname and calls nothing. The extension's dev preflight warns once per public URL that names a hostname; the warning travels through the new optional warn on core's preflight input and a target-warning dev event. Deploy passes no warn.

    Tests

  • Construction and types. public-url.test.ts and public-url.test-d.ts cover the node's shape, the missing url, a table of invalid hostnames in all three forms, and the type error for a non-HTTP target.

  • Lowering. control-lowering.test.ts checks that each strategy lowers as described, including a resolve() value of each kind and a public URL on a module's forwarded interface. It checks the custom domain's id and that its app comes from the Deployment.

  • The apply engine. public-url-apply.test.ts runs Alchemy's real apply engine and the real Prisma.CustomDomain provider against a fake Management API. It proves four things:

  • - a refused hostname fails the deploy;
    - a refused hostname change sends no delete, and the old domain stays;
    - an accepted change creates the new domain before deleting the old one;
    - moving a hostname to another service is refused.
  • Preflight checks. Both preflights fail on a resolved url that is not a hostname or strategy, and on a duplicate hostname, before calling the platform or writing dev state.

  • Local dev. The local custom-domain provider calls nothing, on a create and on a hostname change. The dev warning is printed once per hostname public URL, and the CLI reports it as a warning.

  • Live, against Prisma Cloud. examples/env-param deployed to production and to a preview; its smoke test checks the public-url entity. The application topology read back from both Branches lists the public URL with its edge from the service's HTTP interface. A production deploy naming an unprepared hostname failed with the platform's ownership error, and production kept serving. prisma dev printed the warning and served the service. The record is in .drive/projects/public-urls/slices/p1-public-url/qa.md.
  • Alternatives considered

  • Check the hostname's DNS and ownership records in Composer before the deploy. The platform's verification route gives the exact TXT record. But the CNAME target is derived from the service's endpoint, which does not exist before a first deploy. And the check would be thrown away when the RoutingUrl makes an unready hostname a normal state.

  • Let a deploy with an unready hostname succeed now. That is the project's goal, and it arrives with the RoutingUrl. Prisma.CustomDomain cannot exist without both records, so doing it now would mean skipping the domain and asking for a redeploy, which is also throwaway.

  • The node's address alone as the custom domain's resource id. It matches the other resources, but Alchemy then refuses every hostname change. The RoutingUrl returns to the address alone, and the plan records that its switch drops the old custom domain from state without deleting it.
  • Agent: hermione-26

    🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: wmadden Review duration: 37m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #400"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%