Repository navigation
feat(prisma-cloud)!: a service's input document travels in its artifact, so it is no longer limited to a variable's 8 KB - #432
Conversation
…ct, not in a variable 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 c08e3b5 — posted 0 inline comment(s) this pass. Open findings: none Change walkthroughThis delta (on top of the already-reviewed artifact-as-source work) changes the Artifact packer and reader (artifact.ts): Target extension: Local target ( Tests: all fixture/expectation shapes updated (packing, determinism, path-change, hostile keys, descriptor records, emulator env materialization), the obsolete "inputDocument is not a string" reader test was removed to match the inverted contract, and a new test pins that a value passed to Docs: the boot-file example, decision, and alternatives in ADR-0065; ADR-0019's medium description; ADR-0056's env table and |
commit: |
… calling every failure a missing file Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…s nested JSON A Compute artifact's compute.bootstrap.json now holds the service's input document as a nested JSON value in `inputDocument`, not as a string that contains JSON. The string form was left over from the time the document lived in a variable. The nested value is readable in the file and needs no second parse. The packer and readComputeInputDocument take and return the value. run() receives the value and turns it into text in one place, for the environment input() reads, so input() and dev servers behave as before. The local target collects the document's platform variables from the value directly. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
main took ADR-0065 for the input document decision (#432), so the in-process deploy decision is renumbered ADR-0066 and every reference follows it. A test string the secret scanner flags is built from parts. 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]>
feat(prisma-cloud)!: a service's input document travels in its artifact, so it is no longer limited to a variable's 8 KB
At a glance
Take a service
shop.webwhose input is{ siteName: 'Shop', stripeKey }, wherestripeKeyis the platform secretSTRIPE_SECRET_KEY. At deploy, Composer serializes that input as one JSON text, the service's input document.Before this PR,
prisma deploywrites these environment variables for the service on the Prisma Cloud branch. The first one is the input document:After this PR, that variable is gone from the branch:
and the document is in the service's artifact, the tar the deploy uploads, as nested JSON in
compute.bootstrap.json:{ "moduleEntrypoint": "./main.mjs", "appEntrypoint": "./server.mjs", "address": "shop.web", "inputDocument": { "siteName": "Shop", "stripeKey": { "$platform": { "name": "STRIPE_SECRET_KEY", "secret": true } } } }Nothing an app's author writes changes.
service.input(),service.load()andservice.port()return what they returned before.What this PR changes
COMPOSER_<ADDRESS>_INPUTvariable left on the branch is ignored.The input document, and why it can be in the artifact
A service declares its input with a schema, and the app binds values to it. At deploy, Composer checks the binding against the schema and serializes the result as the input document. It holds the literals the author wrote, and a marker for each value that is only known when the service starts. A marker holds a variable's name, never its value. In the example above,
stripeKeyis the marker{"$platform":{"name":"STRIPE_SECRET_KEY","secret":true}}, and the service reads the secret itself from its environment at boot.So the input document is not a secret, and the deploy knows all of it before it creates anything on the platform. Those are the two conditions for writing a value into an artifact: the artifact is packed on the deploying machine before the deploy calls the platform, and it is uploaded and stored with the code.
serializeInput, which builds the document, refuses a secret's value in a binding.Until now the document was one environment variable per service. A variable's value is limited to 8 KB, and the document grows with every field a service declares.
What stays a variable
port, the only parameter a Compute service declares itselfprisma devthe local Compute emulator assigns each service its port and the local target writes that variable from it, so the artifact must not fix it.How the document reaches the service
Composer deploys a service through four hooks of its target:
provision,serialize,packageanddeploy.serializebuilds the input document as before and no longer creates aPrisma.EnvironmentVariablefor it (packages/1-prisma-cloud/1-extensions/target/src/descriptors/compute.ts).serialize's result topackage(packages/0-framework/1-core/core/src/control/deploy.ts). Core does not look inside it. The contract ofpackagesays it must not write a secret, or a value the deploy has not resolved, into the artifact.packagehands the document, as a JSON value, to the artifact packer, which writes it intocompute.bootstrap.jsonas the nested valueinputDocument(packages/1-prisma-cloud/0-lowering/lowering/src/compute/artifact.ts). The field can hold the input document and nothing else, and a service that declares no input has no such field. The artifact stays byte-for-byte deterministic.bootstrap.jsis constant code. It readscompute.bootstrap.jsonand passes the document to the service'srun(), which uses it in place of theCOMPOSER_<ADDRESS>_INPUTvariable. From there nothing changed.A deployment has triggers: values whose change makes the deploy replace it. Each variable a service reads is one, and the input document was one while it was a variable. It is not one now, and does not need to be. The artifact's file path contains a hash of its content. A changed input document changes the artifact, so the path changes, and a new path makes the deploy replace the deployment. An unchanged service produces the same bytes and is left alone.
The artifact is the document's only source
The first deploy with this change runs while the previous deploy's
COMPOSER_<ADDRESS>_INPUTvariable is still on the branch. The deploy deletes that variable only after it has created the new deployment, and Prisma Cloud copies the branch's variables into a deployment when the deployment is created. So the new deployment starts with the old document in its environment.It must not read it. When the artifact holds a document,
run()ignores that variable. The rule stays after the upgrade: a variable left behind for any reason must not win over the artifact.Under
prisma devprisma devruns the same hooks against the local target, the code that plays Prisma Cloud's part on the developer's machine.readComputeInputDocument).next dev, has no artifact. For it, the input document is still written as a variable in the local target's own store, so its environment is what it was before.Upgrading
COMPOSER_<ADDRESS>_INPUTvariables. Nothing is migrated and no value is written in two places.docs/guides/deploying.mdhas a section on this.Design records
One new decision record,
docs/design/90-decisions/ADR-0065-a-compute-services-input-document-travels-in-its-artifact.md, states the decision and its alternatives. The records, domain docs, glossary entry, guides and agent skill that said the input document is an environment variable on Prisma Cloud are rewritten in place to say what is true now.Tests
run(address, boot)with no document still reads the environment, which is what a test harness uses.prisma dev: on the real local emulator, a service that runs its artifact receives exactly the platform variables its document names, and a stale document in the local store changes nothing. A dev server receives its document and restarts when it changes.compute.bootstrap.json: returns the document as a JSON value, returns nothing when the field is absent, and fails for a file that is missing, is not JSON or is not an object.Checked by hand
Run on 2026-11-17 against Prisma Cloud and under
prisma dev, with a two-service app in which each service answers a request with a value frominput():ORIGIN,PORTandRPC_ACCEPTED_KEYSfor each service, with no_INPUT. Both services answer with their input. The uploaded artifact'scompute.bootstrap.jsonholdsinputDocument.COMPOSER_<ADDRESS>_INPUTvariable left on the branch on purpose, the service starts and does not read it.prisma dev, with one service running its artifact and one running a dev server. Both read their input, and editing an input restarts only the service that reads it.prisma devwith a stale document in the local store. For a service that runs its artifact, a stale input document written into the local store by hand is not read and is not in the service's environment, both when the artifact holds a document and when the service declares no input. A platform variable that only the stale document names is not given to the service. Nothing restarts when nothing changed.Alternatives considered
COMPOSER_keys incompute.bootstrap.json, laid over the environment at boot. It accepts keys that nothing may put there: every other value is a secret or is issued during the deploy, exceptport, which the local emulator has to be able to set. A later entry would silently shadow a variable with the same key. And the guarantee that no secret reaches the artifact would rest on which keys happen to be put in an open map, not on a field that can hold only the input document.compute.bootstrap.jsonas a string that contains JSON. That form was left over from the document having lived in a variable. A nested value is readable in the file and needs no second parse.port, and it has to stay where the local emulator can set it.Agent: mercury-79
🤖 Generated with Claude Code