Repository navigation
feat(prisma-cloud)!: a service’s COMPOSER_ keys are sent with its deployment, and a deploy writes no variable rows - #451
Draft
wmadden-electric wants to merge 15 commits into
Draft
wmadden-electric wants to merge 15 commits into
wmadden-electric wants to merge 15 commits into
Conversation
…s with its deployment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…n its service The platform is adding a variables field to the create-deployment request: a string sets a key, null deletes it, and a key not sent keeps its stored value. Neither @distilled.cloud/prisma nor @alchemy.run/prisma knows it yet, so both are patched with pnpm patch at the pinned versions. Prisma.Deployment gains a variables prop. It is sent only on create and recorded as a salted hash. A changed, unresolved or newly declared map replaces the deployment, because an update creates no deployment and the values would never reach the platform. The same change, as source diffs against the upstream repositories, is under .drive/projects/variable-groups-compat/slices/upstream for the upstream pull requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…ment, and a deploy writes no variable rows Every key a service reads at boot is sent in the variables of its create-deployment request, as its value or as null, so a value an earlier deploy stored, such as a streams key whose last consumer is gone, is deleted. A per-service SentKeys record in deploy state holds every key name ever sent, and each one this deploy no longer sends goes as null. A service with more than 50 variables is refused before anything changes. The deployment still waits for its producers, and its triggers keep only the platform variable timestamps. The key-clash preflight check is deleted: with no rows written, two rows cannot collide. On the first deploy with this version each deployment is replaced once and Alchemy deletes the old rows. A row whose platform record no longer matches deploy state is dropped from state with a warning naming its key, so it cannot fail every later deploy. reserve, which only prisma dev runs, keeps writing local rows for a dev server, never for a null, and fails outside the local application. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
… the deployment and replace nothing when unchanged The real-engine harness covers an unchanged redeploy, a changed value, a removed dependency's keys sent as null on that deploy and later ones, the streams key, producer ordering, the 50-variable refusal, no write to /v1/environment-variables, and the upgrade from rows: one replacement per service even with unchanged triggers, rows deleted afterwards, an interrupted upgrade, a row already gone, and a mismatched row dropped with a warning. Provider-level tests drive the patched Prisma.Deployment. Tests that asserted on rows now assert on variables, and the key-clash tests are deleted with the check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
… boots with its deployment's variables The local Prisma.Deployment provider builds a service's environment from its variables prop, leaving out a key sent as null, in place of env.json. The emulator's port is still laid over the service's own port key, and the platform variables still come from the app configuration and secrets. A changed variables prop is a changed prop, so a changed value, an added key and a key turned to null restart exactly the service that reads it. A dev server keeps reading the rows reserve writes to env.json, scoped to its own address. The converge test runs the real engine, the local providers and a real Compute emulator, and covers restarts, the dev server's rows, and a service switching between the two modes in both directions. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…eflight pull request words them The same text as on feat/preflight-reads-resolved-variables, so the two branches merge cleanly; the next commit corrects what this branch makes false. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…e variables ADR-0069 records the decision: what is sent, why every key boot reads is a value or null, the SentKeys record and the ways of deleting keys that were rejected, the limit of 50, what deploy state holds, the dev server's rows, the first deploy of an existing app, and that going back to an older Composer is not supported. ADR-0048, ADR-0065, ADR-0041, ADR-0057, ADR-0056, ADR-0032 and ADR-0039 are rewritten in place where they described rows, the row ordering edge, trigger members that repeated values, or the key-clash check. The lowering, build reporting, platform model, config params, local dev and core model docs, the glossary, and the deploying and running-locally guides follow. The design and the deferred list record what was built differently and what is left. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…rkspace patches A pnpm patch applies only to this workspace's install. A user who installs @prisma/composer-prisma-cloud gets the unpatched @alchemy.run/prisma, which drops a deployment's variables without an error, so every service would boot without its COMPOSER_ keys while the deploy reports success. check:patched-dependencies fails when a published package, or a workspace package it installs, depends at run time on a package in pnpm.patchedDependencies. It runs in the CI Lint job and before publishing. It fails on this branch until both upstream packages release the variables field and the patches are removed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
… the deployment The variables doc comment now says the values are stored on the App and outlive the deployment, and that every Deployment of one App writes the same store. The helper that reads a recorded hash, used for triggers and variables alike, is persistedHash. The proposed upstream diff is regenerated from the same source. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
… 50-variable refusal as DEPLOY.SERVICE_VARIABLE_LIMIT SentKeys is SentVariableNames (type PrismaCloud.SentVariableNames, role sent-variable-names), so it does not read as credentials; no release has written it to deploy state. ComputeSerialized carries bootVariables, every key boot reads, and requestVariables, what the create-deployment request carries with a null for each name Composer no longer sends. The provider wrapper is providerForDeletingOldVariableRows. The refusal of a service with more than 50 values is a structured error with code DEPLOY.SERVICE_VARIABLE_LIMIT, naming the service, the count and the limit, and saying that no resource has been created, changed or deleted. Stale comments are cut, three single-file exports are private, the ordering test checks the consumer's deployment, and a test shows that the deploy after a name stops being sent replaces nothing. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…lease conditions, stated as they are ADR-0069 and the deploying guide say a user can change a service's variables in Console and that Composer sets its own keys again on every deploy that creates a deployment; that a key losing its value in the upgrade deploy is still read from its old row; and that the 50-variable refusal comes before any resource is created, changed or deleted but after the topology is replaced. ADR-0044 registers DEPLOY.SERVICE_VARIABLE_LIMIT. ADR-0064 has a service scope. The data model gives the platform's real order of steps and source. The glossary and core model lose lines this branch made wrong. The plan records that slice 3 merges after slice 2 and what must happen before it is ready. Touched prose is one paragraph per line. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…ngine failure Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…ckages wait for it too The check now reads every declared patch (package.json, pnpm-workspace.yaml and the lockfile) and walks each published package's run-time install through pnpm-lock.yaml, so a patched package that only a third-party dependency pulls in is found. A workspace package that is only a devDependency is bundled, and its imports are inlined unless the published package lists them, so the walk skips it. The pull-request preview workflow runs the check before publishing to pkg.pr.new, because a preview install gets no pnpm patch either. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…isma dev prisma dev refuses the same service, as a deploy would. Its why no longer claims the branch's topology was replaced and a build recorded, which only a deploy does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
… deployed After one deploy with this version, deploy state holds a PrismaCloud.SentVariableNames resource per service, and Alchemy stops while planning when no provider is registered for a type in state, so an older Composer fails before changing anything. ADR-0069, the guide, the index and the design say so, and the Console workaround is gone. The guide says how the 50-variable refusal reaches the user today, ADR-0044 says prisma dev raises it too, and the plan states the merge order once and adds the real-platform checks before the pull request is ready. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
|
⏸️ Gizmo skipped the automatic review of a1d1835 because this pull request is a draft. It will review automatically once the PR is marked ready for review.
|
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A deploy of a service that reads a database and exposes an RPC interface sends one create-deployment request for it, with the service's own configuration in the body:
It makes no
POSTorPATCHto/v1/environment-variables. Before this change the same deploy wrote one variable row per key, as a branch override on a preview environment and as a row in the production class on production.This is a draft, and three of its checks are red on purpose. See "Before this can merge".
What changes
COMPOSER_keys travel with its deployment. They go in thevariablesfield of the create-deployment request, where the platform stores them on that service. Keys keep their names, so nothing changes in how a service boots.null. A key that is left out keeps its stored value, so a key the service should no longer have must be deleted explicitly. A streams service that loses its last consumer is deployed with its key asnulland refuses to boot, as it does today.PrismaCloud.SentVariableNames, keeps for each service every key name Composer has sent. A name no longer sent goes out asnull. It holds names, never values.prisma dev, a service that runs its artifact takes its keys from its deployment'svariables. A service that runs a dev server has no deployment, so it keeps reading rows fromenv.json.For Ty: the interface this is built against
variableson the create-deployment request: key to string, ornullto delete.nullfor a key that is not stored being accepted and doing nothing. Composer sends one for every optional value that is not set, on every deploy.patches/@alchemy.run__prisma@…, which is the only place that builds the request.What an existing app sees on its first deploy with this version
Before this can merge
variablesin production. Until thenDeploy, verify, destroyis red: the request schema rejects unknown fields.@alchemy.run/prismaand@distilled.cloud/prismarelease the field. Until then both carry it aspnpmpatches underpatches/. Patches are not published with Composer, and the unpatched provider ignoresvariables: a release from this branch would deploy every service without its database URL, port and keys, and report success. So this pull request adds a check,pnpm check:patched-dependencies, that fails while any run-time dependency of a published package is patched. It fails here today, inLintand inPublish preview, and passes once Composer depends on the real releases. The proposed upstream changes are in.drive/projects/variable-groups-compat/slices/upstream/.How it was checked
nullon that deploy and the next; the upgrade from state written by today's code; an interrupted upgrade; a mismatched row. Each test was seen to fail with its behaviour removed.variablesinto rows so the real platform could run the services. Fresh production and preview deploys wrote no rows and every service answered; an unchanged redeploy created no deployment; removing a generated value redeployed only its service; an app deployed with the published 0.39.0 was upgraded with each deployment replaced once and all 22 old rows deleted after the old deployments stopped; services were watched for 12 minutes afterwards and kept answering; deleting a row a running service needs did not affect it. What this cannot show is that services run on stored service variables; item 4 above covers that.Known limits
DEPLOY.SERVICE_VARIABLE_LIMIT, but the CLI reports any failed plan asDEPLOY.ENGINE_FAILED, so the user sees that headline with the real message beneath it. Fixing it is a change to the framework's CLI and is recorded as later work.Alternatives considered
This is the third of three pull requests that make Composer work with variable groups. The decision is recorded in ADR-0069. The design is in
.drive/projects/variable-groups-compat/design.md.Agent: democritus-22
🤖 Generated with Claude Code