Repository navigation
feat!: declare the Prisma Cloud variables your services read with variable() in the app root; envSecret() and envParam() are removed - #431
Conversation
…tect and principal engineer Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…natives; plan and design match it Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…a value from a root input field or a platform variable node Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…no open findings Fixes the factual errors a code check found, moves build mechanics out of the design, and applies review rounds 4 to 6: an appRoot() body reports a bad option on a platform variable node, and prisma dev pauses rebuilds when the app's platform variable reads change. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…an provision valueResource() builds a resource node that holds a secret or param source under a core-only key. In an appRoot() body, provision() returns a frozen copy of that source whose origin records the node's address and whose id, not enumerable, is the address. A module() body cannot provision one: the compiler shows that only appRoot() can, and Load refuses one that a cast got past the types. The graph gains valueReads, which lists each service that reads a value resource's value and where in its binding, through any number of module inputs. Every secret value resource is in the graph's secret sources, named by the node itself when no service reads it, so its value is a known secret. The duplicate-id error now names the module by its address and the node already at the id, and says to pass an id. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
A value resource is lowered through its descriptor like every resource, but it deploys nothing. An empty line for it in the deploy report would read as something Composer deployed, so the deploy leaves it out of the report. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…plicate-id error names both nodes valueReads now walks a binding with the existing sourcesByPath walker, which guards against cycles only, so one object bound at two keys gives a read at each. Param reads reuse pointersIn. The duplicate-id error names the node already at the id and the node that takes it too. The OnlyInAppRoot text no longer names a target's concept. The check that proves a value resource holds a source with an origin hands that origin to provisionedValue(), so its unreachable error is gone. Doc comments on internal code are removed, and the provision() cast reasons say what the one implementation serves and returns. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ages name no target concept Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…rm variable node
The app root provisions a plain platform variable with variable({ name }) and a platform secret with variable.secret({ name }). Each checks the name with the same rules as envSecret(), and its empty-name message shows the call with an options object. The node is a platform-variable value resource whose default provision id is the name in camel case, and its value is a plain or a secret source whose payload carries the name.
secretName() and paramName() also read the name of a node value, so a node works wherever an envSecret() or a per-key envParam() works.
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…criptor that creates nothing, and is not sent to the application topology prismaCloud().nodes registers platform-variable, so the deploy walk and registry coverage look the node up like every other resource. Its lowering returns no outputs and no entities. The application topology leaves out every value resource: the platform has no node kind for it, and Composer owns nothing it names. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…rm variable node value A plain or secret node value stays in place in the binding and is written as a $platform marker with the variable name, and secret: true for a secret. A plain node in per-key params writes the same pointer row a per-key envParam() writes. A schema failure on a field that reads a node now ends by naming the variable, and an array position that reads an unset plain node names it. The absentSecrets option also leaves out a plain node named in it, so preflight can tell whether the service needs it. Its rename to absentVariables waits for the removal of envSecret(). Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…red twice, read two ways, or bound as a service's whole input Two platform variable nodes with one name fail, naming both, and say which is plain and which is a secret when they differ. A plain node and a root input field the root's body passes on, with one name, fail: the name would be both a value services read at boot and a value the deploy reads. A secret node and such a field are already refused by core's Load. A node value bound as a service's whole input fails. The check for an envParam() and a root input field with one name stays until envParam() is removed. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…able nodes, including nodes no service reads Preflight finds plain and secret node names from the same walk of each service's binding, and a plain node in a per-key param, then checks each has a row with slice 2's rules. A node no service reads is listed once, named by the node, also when a module receives it. The prisma dev preflight still reads only secrets from the walk; it fills plain nodes in a later change. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…er resource A value resource needs a descriptor in its extension, found by its type with no special case, as a platform variable node needs its descriptor in prismaCloud().nodes. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… as a lowering must The descriptor the previous commit's test registers returned undefined, which the package's type check refuses. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…er requires The formatter rewraps lines and sorts imports. One test reads the deployment triggers without an optional chain the linter calls unsafe. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Both the authoring side and the deploy side import it, like the envSecret() module beside it. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…able The test that names every node type the extension registers did not list the platform variable descriptor. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…platform variables, and rule 1 names every node with the name A value resource of another extension was treated as a platform variable, so preflight would have looked for its row and the graph check called it one. The target now selects its nodes by extension and type, and refuses one of its nodes whose props hold no name instead of skipping it. Rule 1 named only the first two nodes when three or more shared a name, so the user fixed one and met the error again. It now names every node, says how many, and which are plain and which are secrets. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…nvalid-input error, and writes array positions as the serializer does Preflight's requirement check reused the schema message with that line appended, so the list of variables a service needs held a sentence that repeated the list. The line is now added only where the input is refused as invalid, at deploy and in preflight. It writes the field as list[1], as the serializer's other errors do, not list.1. Doc comments this change and the last made untrue are corrected on the public secretName() and paramName(), and removed from internal functions and options. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…riable node The whole-lowering test now checks the deploy report holds only the two services. The triggers test is renamed for what it checks: which node rows each deployment's triggers hold. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…pe, and the one-node-per-name error names every node Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…iable texts, and the local providers receive them
LocalTargetDescriptor.preflight now returns DevPreflightResult, { payload, plainVariableText }, exported beside LocalTargetDescriptor. LocalTargetProvidersInput and localTargetProviders() gain plainVariableText beside configurationKeyText, which stays until envParam() is removed.
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ariable's text from the app configuration For each plain node a service reads, the dev preflight reads the app configuration under the variable's name once. Text is returned in plainVariableText and fingerprinted for its readers. An unset or empty value is left out of the input document when an input field reads it, and is judged as a per-key param when a param reads it. A value that is not text stops dev, naming the node and every service that reads it. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…y pointers from the plain platform variable texts A secret marker still takes its text from the named secrets. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…iable texts in the app configuration file
The app configuration file gains the top-level member plainVariableText. prisma dev keeps the texts from the preflight it runs at start and writes them on the first converge and on every rebuild; deploy and destroy write {}. A file without the member is refused. Each text is checked against the known secrets before the file is written, and a text that holds a secret's value fails with CONFIG.SECRET_AS_PLAIN_VALUE, naming the platform variable. The dev stack passes the texts to the local providers.
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…s pauses prisma dev until it restarts After a rebuild's Load, prisma dev compares the reads (reader, resource and site) and each read value resource's address with its props against the same sets at start, using only core's graph. On a difference it does not converge, emits value-reads-changed once with the nodes whose reads were only added, only removed, or changed, and pauses rebuilds, as a changed value already does. Reordering provision() calls changes neither set. The previous commit's execute-dev.ts already calls valueReadsChange(); this commit adds it, the event, its warning and the tests, including the tests that run executeDev through a first converge and a rebuild. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…does, as main's tests now do Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…low from its code findings Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
A source built without a label is named "a source". The unread
reader is { kind: 'unread', node }, with no one-value nodeKind.
paramManifest() and secretSourceManifest() are removed: nothing
outside core used them. The two-sources param message reads plainly,
comments the branch touched are cut, and the tests pin the whole
pointer refusal and the module-call diagnostic.
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
A local target whose dev preflight returns a payload string, or nothing, now stops prisma dev with a message that names the extension and says to upgrade it, instead of a TypeError or a silently dropped payload. A test shows that a secret value resource no binding reads is redacted from every output, and the unread reader has no nodeKind. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…d the review's target findings ComputeSerialized.pointers, pointerVersion(s) and the local target's pointedVariables become platformVariables and platformVariableVersion(s): they hold the names and versions of the platform variables a service's input document names, not pointers. The serializer writes one binding path, so the schema-failure note reads list.1 like every other message. Its secret-box and deploy-validation messages are plain sentences. Tests pin per-reader trigger members under prisma dev, a literal per-key param adding no trigger member, and the whole not-a-platform-variable text. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…iable to the web service Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
… from the rename Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
✅ Gizmo reviewed dad369d — posted 0 inline comment(s) this pass. Open findings: none Change walkthroughThis delta hardens the squatter setup in the stale- What changed. The squatter Fit with the codebase. The retry mirrors the same defensive style the production allocator uses in postgres-main.ts (fresh picks per attempt, registry exclusions refreshed each round, bounded retries). Failed attempts record no server record, so they claim no ports afterward, and the |
commit: |
…e TypeScript writes paths with forward slashes Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
There was a problem hiding this comment.
New findings: none · trace
Still open from previous reviews: 🔴 2 critical
…to the secret scanner Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ain when another process claims it first The test scans the machine's @prisma/dev server records, picks the lowest free port from 51300 that no record claims, and starts a squatter server on it. @prisma/dev scans the records again inside the start. In CI, turbo runs @internal/prisma-cloud's tests at the same time, and its local-target-current test runs a real Postgres emulator that creates databases on the lowest free port from 51300 too. When that emulator records 51300 between the test's scan and @prisma/dev's scan, the start is refused with PortBelongsToAnotherServerError. The refused start keeps the name's lock for the life of the process, so the retry uses a new name. The refused name is not deleted: deleting a lock this process still holds makes proper-lockfile throw from a timer. It has no server.json, so it claims no ports. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Brings in #431: the app root declares each platform variable with variable(), and envSecret() and envParam() are removed. The in-process deploy keeps passing values to lower(); the secret refusal now covers main's plain platform variable text for prisma dev. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
main now holds the deploy work as merged (#405), platform variables declared with variable() (#431) and the input document in the artifact (#432). Files the early deploy draft on this branch shared with #405 take main's version. prisma dev keeps converging in the prisma process: plain platform variable text and named secrets reach the local target as values, the secret refusal runs before each converge, and no app configuration file is written for dev. The documents are main's. The dev changes to them are re-applied once the reload design is final. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
This changes how an app says which Prisma Cloud environment variables its services read. Here is one app's root file, before and after:
Nothing changes on Prisma Cloud. The variable keeps its name, the operator still sets it with
prisma project env add, and the service still reads it when it boots. A deploy with the variable unset still stops before anything is created:The decision
A platform variable is an environment variable on Prisma Cloud that the operator sets and a service reads at boot. After this change:
variable({ name })for a plain value orvariable.secret({ name })for a secret. Both come from@prisma/composer-prisma-cloud.provision()returns the variable's value, and the root passes it to whatever needs it.appRoot(). The same call inside amodule()does not compile.envSecret()andenvParam()are removed, withsecretName()andparamName(). This is a breaking change; the migration guide is below.That leaves exactly two ways for an operator's value to reach an app:
provision(variable({ name }))in the rootconfigadapters inprisma.config.ts, by default the deploying shellinputschemaWhy
envSecret('NAME')andenvParam('NAME')could be written in any binding, in any module. That caused three problems.envSecret('API_KEY')took that name in every app that used it, and two such modules could collide with no way for the app's author to fix it.envParam()meant two different things. In a service'sinputit was a value the deploy read from the shell, which a field of the root'sinputalready does. In a service'sparamsit was a value read from the platform at boot.How it works
Each part builds on the one before.
1. Declaring a variable gives you its value
fromstands for the text the variable will hold at boot. The root's code cannot read it; it can only pass it on. The declaration is also an entry in the app's graph, with an address like any service or database:shop.emailFrom, the variable's name in camel case. Pass{ id }toprovision()to choose another.2. The value goes into a field of a service's or a module's input
A plain value fits a field the schema wraps in
field(). A secret fits asecretString()field, and the service receives it in a box that prints as[REDACTED]. Binding a plain value to a secret field, or a secret to a plain one, does not compile.To reach a service inside a module, the module declares a field in its own input and passes it on:
So a reusable module never names a platform variable. It says what it needs, and the app decides which variable supplies it.
3. Only the root can declare one, and the compiler says so
Inside a
module()body,provision(variable({ name: 'OTHER' }))fails to compile:A root still written
module('shop', …)is still accepted as a root, but it must becomeappRoot('shop', …)to declare a variable.4. A value cannot go where the deploy needs a number or a fact
A platform variable's value does not exist until the service boots. So it cannot be used where the deploy itself needs the value:
params. On a compute service that meansport. The deploy tells Prisma Cloud which port to route to before the service exists, soporttakes a number written in the code or a field of the root'sinput. Binding it to a variable does not compile.resolve()dependency, or a resource's props, such as a public URL's hostname.envParam()could be bound toportbefore this change. It compiled, and the service failed at boot whenever the variable was set, because the variable's text is not a number.5. Three mistakes are refused before anything is created
Right after the app is loaded, and before the deploy contacts Prisma Cloud:
The platform variable "EMAIL_FROM" is declared twice in the app root, by "shop.emailFrom" and "shop.sender". Declare each platform variable once and pass its value to every module that needs it.input.Two variables whose names give the same address, such as
EMAIL_FROMandEMAIL__FROM, fail with an error that names both and says to passid.6. The deploy creates nothing for a variable, and checks that it is set
A declaration creates no resource on Prisma Cloud and has no line in the deploy report. The deploy does not read or write the variable's value. As before this change, it checks that each variable has a value in the environment being deployed:
7.
prisma devplays the platform's partThere is no Prisma Cloud locally, so
prisma devsupplies the values from the two adapter lists inprisma.config.ts: a plain variable from theconfigadapters and a secret from thesecretsadapters, each under the variable's name. Both lists default to the shell. A required variable with no value stopsprisma devbefore any service starts, and so does a plain value that is not text.8. The loaded app lists who reads what
The graph that
Loadreturns has a new list,valueReads. Each entry names a service, the variable declaration it reads, and the field of the service's input that reads it. Tests and tools can use it without deploying.Migration guide
1.
envSecret('X')becomesvariable.secret({ name: 'X' })in the root. This is the before and after at the top. If theenvSecret()was written inside a module, move it to the root, give the module asecretString()field in its input, and pass the value down.2.
envParam('X')in a service'sinputbecomes a field of the root'sinput. The deploy still reads the value from theconfigadapters, by default the shell.For a value that may be unset, declare the field optional:
'GREETING?': 'string'. If theenvParam()was aresolve()dependency or in a resource's props, use the root field there:resolve([input.X], …).3.
envParam('X')in a service'sparamsbecomes a number or a field of the root'sinput. It could only bindport.Leave
portout to use 3000.4. A root written with
module()becomesappRoot()if it declares a platform variable.appRoot()takes nodepsand noexpose.5. Tests that called
secretName()to find which variable a binding reads use the graph instead: find the entry ingraph.valueReads, take the node at itsresourcefromgraph.nodes, and readprops.name.Internal Prisma apps call the removed functions: the deploy apps in
prisma/streams, and the apps inprisma/asks,prisma/programandprisma/pdp-control-plane.prisma/skillsandprisma/webdocument them. Each moves when it upgrades Composer.Also in this pull request
prisma project env add … --role preview --branch 'staging', which theprismaCLI refuses. It now suggests--branch 'staging'alone. This was already wrong onmain.examples/env-paramis nowexamples/root-input, package@prisma/example-root-input. It shows a value the deploy reads through a field of the root'sinput.prisma devpauses rebuilds when the app's variable reads change, and says to restart. The values are worked out once at start, so a read added later would have none. See the known limit below.For authors of extensions
valueResource()and recognised withisValueResource(). A platform variable declaration is one. Only anappRoot()body can provision one.paramSource()no longer takesconfigurationKey, andParamBindingsaccepts no source. A service's param takes a literal or a value the deploy has.AppConfigurationReadhas noconfigurationKeyText.preflightreturns the new typeDevPreflightResult,{ payload, plainVariableText }.prisma devrefuses a local target that returns the old shape, with a message that names the extension and says to upgrade it.LocalTargetProvidersInput.configurationKeyTextis nowplainVariableText.localTargetProviders()and the CLI'sprepareSecondProcess()take it.paramManifest()andsecretSourceManifest()are removed. Nothing used them once the old functions went.prisma devhas a new event,value-reads-changed, which the CLI prints as a warning.Reading the diff
About 190 files change. Most are tests, examples and documents that moved off the removed functions.
packages/0-framework/1-core/core/src): the value resource and whatprovision()returns for it innode.ts,value.tsandload-module.ts; the list of reads inresolve-values.ts.packages/1-prisma-cloud/1-extensions/target/src):platform-variable.tsis the two constructors;graph-check.tsis the three refusals;preflight.tsandlocal-target/preflight.tsare the deploy's andprisma dev's checks.packages/0-framework/3-tooling/cli/src):app-configuration-file.tsandoperations/execute-dev.tscarry plain values to the local services;dev/value-reads-change.tsis the rebuild check.docs/guides/building-an-app.md.How it was checked
prismaCLI accepts both.examples/root-inputdeploys, and its smoke script passes.prisma devreceives its values. A required variable with no value, and a value that is not text, each stop it before any service starts.Known limits
inputfields the root passes on. Composer cannot list the fields a schema declares. A field the root declares and never uses reaches no service, so nothing reads the name two ways, but nothing refuses the app either.prisma dev, an edit tomodule.tsis not picked up by the check that pauses rebuilds.prisma devkeeps the copy of the app's modules it loaded at start. So after an edit that adds a variable, the rebuild fails with an existing error, "the second process built a different graph", and the fix is to restartprisma dev. This is howprisma devtreats every edit that adds or removes a service or resource today; it is not new here.Alternatives considered
envSecret()andenvParam(), deprecated. There would be two ways to name one variable, and an inlineenvSecret()would still be missing from the list of declarations. Every known caller is inside Prisma.envSecret().envParam()in a service'sinputduplicates a field of the root'sinput, and inparamsit could only bindport, where it failed at boot.field(type('string'), { env: 'EMAIL_FROM' }). A value the operator must set is part of what the app is made of, so it is declared in the graph beside the services and databases.port. The deploy needs the port before the service exists, so it would route to 3000 while the service read the variable. Whether a compute service's port should be set throughparamsat all is not decided; it is recorded in.drive/projects/platform-variables/deferred.md.provision()return{ id, value }. Returning the value itself, withidon it, lets a binding read{ from, deliveryCredential }, asgeneratedParam()andserviceOrigin()already do.prisma dev, so an added read needs no restart. Left for later: it is a change to the dev loop, not to platform variables.Agent: gavroche-74
🤖 Generated with Claude Code