← Back to Pull requests

Run builds that read a Sealed value on a Server Builder (SL9) #3302

Closed
unknown closed this pull request without merging on Oct 25, 2026 03:08 UTC
View on GitHub
unknown unknown commented on Oct 23, 2026 16:12 UTC
Author

SL9 of Sealed variables level A.

Summary

A build that reads a Sealed value now runs on a Server Builder, and only that Machine opens the value. GitHub Actions never receives one. The CLI's silent drop of Sealed build values (ruling 31) is gone: a Sealed value is either carried to the Server Builder or refused by name.

Who notices. Nobody, until an Organization turns on sealed variables. After that, a Service whose build reads a Sealed value builds on a Server even when its Preferred Builder is GitHub Actions, and the dashboard shows GitHub Actions disabled with "Uses sealed NPM_TOKEN". A Dockerfile reads the value with ARG NPM_TOKEN, like any variable, or with RUN --mount=type=secret,id=NPM_TOKEN,env=NPM_TOKEN to keep it out of the image's history. Railpack builds need no change.

sequenceDiagram
    participant S as Config Store
    participant W as Cloud worker
    participant C as CLI / runner
    participant M as Server Builder (ployzd)
    S->>S: GitSource.sealed = first variable reading a Sealed value
    S->>W: walk without GitHub when sealed
    W->>C: build on a Server
    C->>M: upload with private/sealed.json (ciphertext only)
    M->>M: open with this Machine's Sealing Key
    M->>M: 0600 files, BuildKit secret mounts, declared ARGs, output scrubbed
    M->>M: files removed on success, failure and cancel

builders::walk(sealed)
  sealed && Preferred Builder GitHub   -> Servers lead
  sealed && Build Order github-only    -> empty walk: "<svc>: Builds that read a sealed value run on your server. No other Builder in your Build Order can take it"
github_input
  built Service reads a Sealed value   -> conflict "NPM_TOKEN is sealed. Builds that read a sealed value run on your server."
  every other Service                  -> resolvedEnv keeps Text only
execute_local (CLI local, GitHub runner)
  target reads a Sealed value          -> "NPM_TOKEN is sealed. Builds that read a sealed value run on your server."

What ships.

  • Store. GitSource.sealed, the sealed walk, the github_input refusal and strip, EnvironmentView.sealed (row IDs of browser-sealed variables).

  • CLI. The store_runner failure line. Capture of private/sealed.json, compose build.secrets, Railpack mounts, and the names of Sealed values a Dockerfile declares as ARG (private/sealed-args.json, names only). The local refusal.

  • ployz-build and ployzd. Opening on the Machine. Secret files and the Sealed ARG compose override in one Drop guard. Railpack prepare with mounts only. Scrubbed output.

  • Dashboard. The Preferred Builder line.

  • Docs. docs/user/builds/where-builds-run.md, and "Read a sealed value" in docs/user/builds/railpack-and-dockerfiles.md: ARG first, then the secret mount and PLOYZ_SEALED_HASH.
  • Bets

  • 6, Machine-local authority. The choice it changed: the Builder Machine opens build values with its own Sealing Key, instead of the CLI or Cloud passing plaintext build args.

  • 7, Cloud drives, never owns. The choice it changed: Cloud picks the Builder from GitSource.sealed and never sees the value. github_input carries Text only.

  • 10, Client-first, daemon when forced. The choice it changed: opening moves into the daemon's Build RPC, because the value can't leave the Machine.
  • Build RPC scope

    Stays Operator. Cloud drives builds as Operator. The opened value never returns over the RPC. It lives in 0600 files inside the upload root, and output is scrubbed. A Cloud that crafts a recipe to print or exfiltrate a value is the active-Cloud gap level A accepts (Appendix C). Dropping to a narrower scope buys nothing while the recipe stays caller-authored.

    Compat

    One deletable place: crates/ployz/src/sealed_compat.rs gains the ployz.build.sealed.v1 check, called once from prepare.rs, so the Builder pick skips a Machine that can't open build values. It joins SL10's deletion list. Without it an old daemon still fails closed (Railpack rejects the unknown field, and a Dockerfile recipe points at a secret file the old daemon never writes).

    EnvironmentView.sealed is a new fact the Store gives the dashboard: the row IDs of variables the browser sealed. It is omitted when empty, so a read with no such variable serializes as on trunk. An old Store never sends it, and the dashboard reads a missing list as empty: no row is sealed and GitHub Actions stays enabled, exactly as on trunk. The Store reaches Cloud through the in-process @ployz/sdk addon, so the two ship in one build and the old-Store case only arises across a rollback. It is the permanent fact the Preferred Builder line reads, not a mixed-version shim, so it stays off SL10's deletion list.

    A CLI from before SL9 that builds from a Store-resolved env still drops Sealed build values without a word, as ruling 31 described. Nothing on the Store or daemon refuses it: an old CLI ignores GitSource.sealed. It stays closed while sealedVariables is off, and SL10 must keep it closed before the flag turns on.

    Known gaps

  • A Template that reads another Service's Sealed value routes to a Server with no dashboard line. The line reads only the Service's own variables (R-c).

  • A ployzd killed mid-solve leaves the opened files in that slot's upload directory on the Builder until the slot is next cleaned. The Drop guard covers success, failure, cancel and a retained Unknown root, but not a hard kill. The files are on the Machine that holds the Sealing Key.

  • Changing a Sealed value doesn't rerun a cached secret mount step unless the Dockerfile declares ARG PLOYZ_SEALED_HASH above it. This matches Docker's own secret mounts. An ARG step and Railpack builds rerun.

  • A value read with ARG is in the image's history, as Docker records every build arg a step uses. The image stays on the user's Servers. The docs point to the secret mount for a value that must stay out of history.

  • Buildx provenance metadata is off for a Build that passes a Sealed ARG, because buildx records build arg values in it. Other Builds keep it.

  • A value read with ARG also stays, on the Server, in BuildKit's build history until its GC (48 hours and outside the newest 50 records), in the image inspect output the Builder reads back, and in a multi-platform Build's per-platform archive. Each is a copy of what the image already holds, readable only with the Docker socket. The secret mount leaves none of them.

  • A sealed value under 6 bytes that a build step prints bare reaches the build log unscrubbed. With ARG it also shows in the RUN step's name, since BuildKit expands args there. The scrub matches a value that short only as NAME=value, as it does in runtime logs.
  • Sealed values as Dockerfile ARGs (ruling 40)

    Ruling 40 replaces ruling 38, which refused ARG <sealed name>. The operator asked for what Railway does. Railway passes a sealed variable to a Dockerfile build like any other variable, and the Dockerfile opts in with ARG NAME. Sealing changes who can see a value, not whether a build can read it.

  • The CLI finds the Sealed names the captured Dockerfile declares as ARG and writes only those names to private/sealed-args.json. With no Sealed value it reads and writes nothing new.

  • The Server Builder opens the values and writes them into a 0600 compose override under private/sealed/, with $ escaped as for captured args. Bake reads it through --file. No value reaches the upload, the captured recipe, bake --print, or a command line. The override is created and removed with the secret files.

  • Buildx records build arg values in its provenance metadata, so a Build with the override sets BUILDX_METADATA_PROVENANCE=disabled. A Build without one runs with trunk's environment and bake arguments.

  • Level A holds. Plaintext exists on the Server and in the image, which stays on the user's Servers. GitHub Actions never gets a Sealed value.
  • The secret mount stays, unchanged. The Docker receipt below shows why. A value read with ARG lands in docker history, and a mounted value doesn't.

    Dockerfile cache (ruling 39, mount only)

    A changed ARG value already misses the cache, so ruling 39 now covers only the secret mount. A mount step stays cached when its value changes. For every Dockerfile target that reads a Sealed value, Ployz passes PLOYZ_SEALED_HASH, a hash of the ciphertext fingerprints, as a build arg. BuildKit ignores an undeclared arg, so the default is a cache hit. A Dockerfile opts into a rerun by adding ARG PLOYZ_SEALED_HASH above the mounting RUN. History then shows the hash and never the value.

    My call under ruling 40 is to keep PLOYZ_SEALED_HASH unchanged. It was already wired in, it is opt-in, and it costs nothing. Removing it would leave the mount path with no way to rerun.

    Two alternatives were rejected. Rewriting the uploaded Dockerfile would add parser-directive, continuation and heredoc surface just for a cache nicety. --no-cache would lose the cache on every build, which is worse than trunk.

    Legacy output changes

    Two changes reach a Build with no Sealed value, both in ployz-build/src/solve.rs:

  • A progress vertex with no name now parses instead of being dropped.

  • The 64 KiB cut of a line with no newline no longer splits a UTF-8 character. incomplete_tail also holds back a trailing byte run that is invalid but looks incomplete. The joined text is the same. Only the point where one output event ends and the next begins moves.
  • Evidence

    Focused checks at the head, run by each round's delegate and rerun after its changes.

    | Check | Result |
    |---|---|
    | cargo fmt --check | ok |
    | clippy -p ployz-build -p ployz -p ployz-core -p ployz-store --all-targets -D warnings (macOS; ployzd is Linux-only, CI covers it) | ok |
    | nextest -p ployz-store (build, git, sealed, deployment) | 186 passed (fix round 1) |
    | nextest -p ployz (build, store_runner, sealed, prepare, preparation) | all pass but two macOS-only failures that also fail at base: reserved_characters_are_refused, ignored_special_files_do_not_enter_capture |
    | -p ployz-build on Linux (cargo test) | 68 passed, plus host_policy 11 |
    | ployzd on Linux (--lib build::, sealed_env) | 39 and 16 passed |
    | real-wait lint | exit 0 |
    | dashboard vitest store-variables, typecheck, oxlint on changed files | ok |

    Docker receipts (#[ignore] tests in ployz-build/src/tests.rs, run on Linux with dummy values):

  • Mount, ruling 39. With no ARG line, a changed value is a cache hit. With ARG PLOYZ_SEALED_HASH, a changed value reruns the mounting RUN, and an unchanged value is a hit. No unconsumed build-arg warning. Neither docker history nor bake --print contains plaintext.

  • ARG, ruling 40. /token.sha matches. A changed value reruns the step. The upload root is gone after the build, and nothing under the capture holds plaintext. docker history holds the value, which is why the docs still offer the mount.
  • On trunk, a legacy ARG NPM_TOKEN lands in history twice.

    Live lanes ran on one Boat Machine against a throwaway verify-dashboard Store, with sealedVariables set only on that Store's test Org ada. Values were sealed with the SL6 sealer to the Cluster public key and written through POST /api/config/write, because browser sealing (#3304) isn't on this branch. Every "0 matches" covers ployz up output, ployz logs --build and the dashboard Build panel. Evidence is in /tmp/swarm-3302/verify-r{1,2,3}/.

    | Lane | Last run | Result |
    |---|---|---|
    | routes-to-server | r2 (a7f6e2948) | Preferred Builder GitHub. Unsealed skips GitHub. Sealed builds on machine-1 with no workflow lookup. A second Service with no sealed value of its own routes as before. The dashboard shows "GitHub Actions · Uses sealed NPM_TOKEN", disabled. r3 couldn't run it (Store booted without FAKE_GITHUB); nothing on its path changed since r2 |
    | github-only | r2 | "app: Builds that read a sealed value run on your server. No other Builder in your Build Order can take it." Nothing builds, and GitHub gets no dispatch |
    | railpack-setting-refused | r1 (e0158bcda) | "RAILPACK_BUILD_CMD is sealed. Railpack settings can't be sealed." 0 matches |
    | dockerfile-arg | r3 (89cd41d23) | /token.sha matches. 0 matches in output, a full Store pg_dump, and 14 ps -eo args samples taken during the build. Bake reads private/sealed/args.compose.yaml (0600) by path. The RUN step name shows [secret NPM_TOKEN]. History holds the value, as expected |
    | arg-and-mount | r3 | Both hashes match. The mount value matches 0 times in history and inspect |
    | arg-value-changes | r3 | A new value reruns the ARG step, and the new hash matches |
    | dockerfile-secret | r3 | /token.sha matches. 0 matches, including docker history --no-trunc and docker image inspect |
    | split-output, split-output-prefix | r3 | A value split at the 64 KiB cut, and a 7-byte prefix held across a 3s pause, match 0 times. Non-secret bytes arrive intact |
    | late-output | r3 | The held NPM_TOKEN=[secret NPM_TOKEN] line arrives after its step ends. BuildKit kills a step's backgrounded writer, so output after completion is proved by unit tests only |
    | multibyte | r3 | Valid UTF-8, 0 replacement characters, 0 matches. The invalid-byte case is unit-proved only |
    | plain output intact | r3 | Done arrives whole, with no marker |
    | railpack-reads-value | r3 | The hash matches. 0 matches in history, inspect and the build log |
    | no-secret-files | r3 | No private/sealed/* or args.compose.yaml remains after success, a failed mount build, or a failed ARG build |

    Provenance is off only for ARG builds: the "resolving provenance" step appears in mount-only builds and not in ARG builds.

    core/crates/ployz-sdk/tests/node_connect.js fails on macOS at c914040b8 too (ERR_DLOPEN_FAILED). /var is a symlink to /private/var, so its require.cache key misses the resolved addon path. With TMPDIR=$(realpath "$TMPDIR") it passes 7/7 at both base and head. This PR doesn't touch ployz-sdk.

    Rebase. Rebased onto c3277a38d, after SL5 #3098, SL7 #3304 and SL5b #3335. Four conflicts, all two additions side by side: rpc_catalog.rs and tests/capabilities.rs keep BRIDGE_IPV6_CAPABILITY and BUILD_SEALED_CAPABILITY; store-variables.ts and its test keep SL7's sealing writer and firstBrowserSealed. At 2a1471319: fmt, the real-wait lint, ployz-core --test capabilities 4/4, scrub 13/13, clippy -D warnings on ployz-build, ployz, ployz-store and ployz-core lib, dashboard typecheck, oxlint and store-variables 14/14, nextest ployz-store 75/75 and ployz 131/131 on macOS, and on Linux ployz-build sealed 12+1, ployzd build:: 39/39 and sealed_env 16/16, plus the two ployz tests that fail on macOS only. ployz-core's lib-test clippy fails on macOS on trunk too (release_mirror.rs helpers used only on Linux).

    Review

  • Interrogate rounds 1 to 3 (claude-opus-5-5 medium, gpt-6.1-sol high) on the whole change and then each fix diff. Fix rounds closed the split StepOutput leak, the Railpack setting gap, the Store resolving where trunk didn't, unreadable progress lines in sealed Builds, and a character split at a step's completion.

  • Ruling 40 got its own round. It found no plaintext in the upload, recipe, command line, Store or scrubbed output. Its copies-on-the-Server findings are in Known gaps.

  • The "Uses sealed NAME" line under the Builder field belongs to SL10 with the Secret badge copy (root ruling A7b). This PR keeps it on the disabled GitHub Actions option only.
  • Merge Danger

    Door: two-way

    Everything is behind sealedVariables, which stays off. A Service with no Sealed value builds, routes and uploads as on trunk.

    Blast Radius: builds

    A routing or capture regression would hit every Git build, so the legacy byte-for-byte checks are the ones to watch.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: nick-potts Review duration: 2096m
    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 #3302"
    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%
    Repository