Repository navigation
feat(config): deliver a secret to a service's ENV at config time, with R10 proven live - #76
Conversation
…h R10 proven live Clean re-cut of #74, which was auto-closed at the 5-BLOCK threshold. Its thread is closed and is NOT reopened -- the validator's own rule is "open a clean pull request from a fresh branch and thread". This branch is `feat/config-secret-env-v2` off `origin/main`, and the diff is the same five files, verified independently here. WHAT THIS DOES. A secret reaches a service's environment at CONFIG time, host-side, without ever entering the plan. `Op.Env` is a variable baked into the rendered script at PLAN time, which is the IR; a container's `Env:` is written at config time. DESIGN.md:2511 (D-SEC-1) forbids the value entering "the store, artifacts, labels, the IR, state or output", and this change removes it from the IR. WHAT IT DOES NOT DO, and the body says so. It does not satisfy D-SEC-1's `state` limb: config_setup.go passes Env: envVars into the config writer, which persists Environment= into the deployment's unit. That is filed as #75, whose fix is the type owner's `bind` returning an #Opaque handle (spec/schema/bind.cue:48-52, DESIGN.md:685). THREE CORRECTIONS THIS BRANCH CARRIES that #74's review rounds produced: 1. the entry point is the deploy's BOX, not the image it runs -- `node.Image` is a box name for a box-based deploy but a registry ref for a registry one, and preferring it started the walk from a ref that resolves to nothing; 2. the D-CAP-6 union includes the deploy's `add_candy:` list, because those candies run in the container and can author secret_require:; 3. the candy body is decoded into spec.Candy, the typed model, never a hand-written mirror of its fields. THE HAZARD. ResolveSecretForCandy -> EnsureCandySecret MINTS a 32-byte token when the value is missing everywhere, so an unscoped resolve at config time would mint and persist credentials for candies outside this box's chain -- invisible until an operator found foreign secrets in their store. Scoped by construction, and guarded by a test that fails without the scope. R10. A bed was BUILT for this change: check-seam-proof, PASS, steps=16, config logging "charly-check-seam-proof-seam-proof-token -> created (from config)" and the container check passing on the token's LENGTH (the value is never printed). The bed is uncommitted in a charly worktree and lands in a follow-up PR that names this one. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (analysed on a live system)
Review — BLOCKHead SHA: Change class: runtime (Go code in a candy) — requires fresh-rebuild bed proof under R10. Security screen: PASS — no secret exfiltration (values flow from the operator's store into the local container env, no egress), no new dependencies/pins, no guardrail weakening, no description↔code scope mismatch. (The Blocks
Non-blocking notes
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
… bed's landing is filed Two review findings. The second is a REAL BUG in new code that the lint gates cannot catch. QUAL -- UNBOUNDED LOOP. `boxCandyChain` tracked only CANDY names in `seen`, and its only cycle guard was `if next == base`, which catches the self-loop `A -> A` but NOT `A -> B -> A`. A two-box cycle revisits boxes whose candies are already collected, so the candy-level set never fires and `charly config` HANGS. Fixed with a visited set on BOX NAMES. The gate for a malformed manifest is validation's; THIS function's obligation is to terminate, because a config command that hangs is worse than one that reports a bad chain. PLANTED (the visited set removed): --- FAIL: boxCandyChain did not terminate on a cyclic chain: `charly config` would HANG TestBoxCandyChainTerminatesOnACycle runs the walk in a goroutine with a 2s deadline, so a regression FAILS rather than hanging the suite. CONC/R1 -- THE BED WAS AN UNFILED FOLLOW-UP. The body said the R10 bed "lands in a follow-up charly PR", and that follow-up had no issue. Filed as #77, which carries the bed's YAML, its run (PASS, steps=16), the three limits its description bears, and the four schema facts it cost. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (analysed on a live system)
Review — PASSHead SHA: Security screen: PASS — T1–T4 clean. The Checklist: All applicable rules PASS or NA (R0–R10, A1–A3, PIL/ADE/SDD, CONC, HC, ARCH, DISP, QUAL, COORD). Placement: CORRECT — all changes are inside the Comment dispositions (1 comment):
Non-blocking notes (not gating):
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
The review is right on both halves, and the second half is the sharper one: the pasted red-first did
not correspond to the committed test.
WHAT WAS WRONG. `secret_state_leak_test.go` built its own
envVars := []string{"EXISTING=kept"}
and asserted the probe value was absent from the rendered text. That assertion could NEVER fail:
the probe value is consumed by `CollectCandySecretAccepts` (which returns references) and by
`EnsureBoxChainSecrets` (which returns names), so it never reached the hand-built slice. A test
whose subject is a literal the test itself wrote is not a test of the code -- it is a test of the
literal. And the failure quoted in the body came from a DIFFERENT version of the file, which is why
it showed an `Environment=` line the committed test could not produce.
WHAT IT ASSERTS NOW. The property that actually keeps the value out is the return SHAPE.
`EnsureBoxChainSecrets` returns secret NAMES; a name never contains `=` and a `KEY=VALUE` pair does.
Three tests, each able to fail:
TestEnsureBoxChainSecretsReturnsNamesNotPairs the result is a name, not a pair, and carries no
probe value
TestTheUnitEnvironmentCarriesNoSecretPair builds the Config's Env from the ensure's RESULT --
what the writer does -- renders the unit, and asserts
no `Environment=SEAM_PROOF_TOKEN=`
TestTheRenderedUnitCarriesTheSecretReference... the reference half: `Secret=...` is emitted, so
delivery still has its carrier
THE RED-FIRST, from THESE tests. Plant: make the ensure return `dep.Name+"="+v` again, the #76 shape.
PLANTED: the ensure returns pairs again
--- FAIL: TestEnsureBoxChainSecretsReturnsNamesNotPairs (0.00s)
--- FAIL: TestTheUnitEnvironmentCarriesNoSecretPair (0.00s)
secret_state_leak_test.go:95: the unit's Environment= carries the secret -- the ensure
returned a pair:
# charly-check-seam-proof.container (generated by charly config)
Restored, and the whole suite is green:
$ go test ./... -> ok github.com/opencharly/plugin-deploy-pod/candy/plugin-deploy-pod 0.368s
The plant also failed the two pre-existing box-chain tests, which is the point: the shape change is
visible from every direction, not only from the one the new test looks.
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
…e delivery that leaked it (#80) * fix(config): keep a secret's value out of the pod unit, deliver it by reference (#75) D-SEC-1 (DESIGN.md:2511) forbids a secret entering "the store, artifacts, labels, the IR, state or output". `state` is listed separately from the IR, and the pod config writer persists the container's `Env:` into the unit file, so `Environment=NAME=<value>` in a quadlet was the value written down, once per deployment. WHAT WAS WRONG. #76 added `PodEnvVarsWithSecrets`, which appended each box-chain `secret_require:`/`secret_accept:` value to the config writer's env slice. The value was already delivered by the label path: the image's `ai.opencharly.secret_require` label (sdk/deploykit/render_prep.go:338) reaches `CollectCandySecretAccepts`, which sets `CollectedSecret.Env = dep.Name` (sdk/deploykit/secret_provision.go:317), `ProvisionPodmanSecrets` creates the podman secret, and the unit already carried `Secret=<name>,type=env,target=<VAR>` (sdk/deploykit/quadlet.go:188). The env append was a second copy of the same delivery whose only effect was to persist the value. WHAT THIS DOES. The seam keeps the half that is uniquely its own, ENSURING a required secret that is missing everywhere (the documented auto-generation, scoped to the deploy's box chain so no foreign candy is minted), and runs it BEFORE provisioning, so a value a first `charly config` mints is the one provisioned. It returns NAMES, never values, so the caller has nothing to write into state. Delivery is the podman-secret reference, which podman resolves at REALIZE. EVIDENCE. `TestTheRenderedUnitCarriesTheSecretReferenceAndNoValue` renders the unit and asserts both halves. On the un-changed tree it failed with `Environment=SEAM_PROOF_TOKEN=p75-state-leak-probe-9f2c` beside the `Secret=` line; it passes after this change. `TestConfigSetupCallsTheSecretEnsure` pins the call, its ORDER before provisioning, and the absence of the retired env write. Refs #75. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (syntax check only) * test(config): the leak test could not fail, and now it can The review is right on both halves, and the second half is the sharper one: the pasted red-first did not correspond to the committed test. WHAT WAS WRONG. `secret_state_leak_test.go` built its own envVars := []string{"EXISTING=kept"} and asserted the probe value was absent from the rendered text. That assertion could NEVER fail: the probe value is consumed by `CollectCandySecretAccepts` (which returns references) and by `EnsureBoxChainSecrets` (which returns names), so it never reached the hand-built slice. A test whose subject is a literal the test itself wrote is not a test of the code -- it is a test of the literal. And the failure quoted in the body came from a DIFFERENT version of the file, which is why it showed an `Environment=` line the committed test could not produce. WHAT IT ASSERTS NOW. The property that actually keeps the value out is the return SHAPE. `EnsureBoxChainSecrets` returns secret NAMES; a name never contains `=` and a `KEY=VALUE` pair does. Three tests, each able to fail: TestEnsureBoxChainSecretsReturnsNamesNotPairs the result is a name, not a pair, and carries no probe value TestTheUnitEnvironmentCarriesNoSecretPair builds the Config's Env from the ensure's RESULT -- what the writer does -- renders the unit, and asserts no `Environment=SEAM_PROOF_TOKEN=` TestTheRenderedUnitCarriesTheSecretReference... the reference half: `Secret=...` is emitted, so delivery still has its carrier THE RED-FIRST, from THESE tests. Plant: make the ensure return `dep.Name+"="+v` again, the #76 shape. PLANTED: the ensure returns pairs again --- FAIL: TestEnsureBoxChainSecretsReturnsNamesNotPairs (0.00s) --- FAIL: TestTheUnitEnvironmentCarriesNoSecretPair (0.00s) secret_state_leak_test.go:95: the unit's Environment= carries the secret -- the ensure returned a pair: # charly-check-seam-proof.container (generated by charly config) Restored, and the whole suite is green: $ go test ./... -> ok github.com/opencharly/plugin-deploy-pod/candy/plugin-deploy-pod 0.368s The plant also failed the two pre-existing box-chain tests, which is the point: the shape change is visible from every direction, not only from the one the new test looks. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * refactor(config): finish the rename sweep -- zero mentions of the old identifier The cherry-pick onto this branch carried the fix and the test rewrite but not the sweep commit, so two test functions still embedded ScopedCandySecrets and the doc comment still named scopedCandySecrets. R5 requires the sweep in the same change, proven by a claim-keyed grep: $ grep -rn 'ScopedCandySecrets\|scopedCandySecrets' candy/plugin-deploy-pod/*.go (no matches) go test ./... -> ok 0.402s. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * chore(review): R1 and Filed issues now say the same thing R1 said 'Nothing filed' while ## Filed issues listed opencharly/spec#370 for the same finding. They cannot both be true, and the Filed-issues section is the one that matches the tree. R1 now says the spike's finding is FILED, not parked, and gives the reason it is separable: this change is correct and complete without it, because the state limb is closed by deleting a duplicate rather than by the bind wire. Body first, event second. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * chore(review): the pasted grep has five call sites, and the prose now says five The rebuttal's own output counted five and its prose said four. config_setup.go:390 and :423 are two arms; config_setup_helpers.go:1151, :1154, :1155 are the AMD-GPU path; :1160 is the definition. A count that does not match the output pasted beside it is the defect this whole line of work is about, and I made it inside the rebuttal of a count finding. Body first, event second. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated) --------- Co-authored-by: aitrawog <dsh-opencharly@local>
feat(config): deliver a secret to a service's ENV at config time, with R10 proven live
Clean re-cut of #74 (auto-closed at the 5-BLOCK threshold; its thread is closed and is not
reopened). The diff is the same five files, verified independently on a fresh branch off
origin/main.Summary
A secret reaches a service's ENVIRONMENT without ever entering the plan — and the overlay path it
replaces is a named, testable function instead of three inline calls.
DESIGN.md:2511(D-SEC-1) forbids a secret entering "the store, artifacts, labels, the IR, state oroutput".
Op.Envis the IR — a variable baked into the rendered script at PLAN time. A container'sEnv:is written at CONFIG time, host-side. The same secret can reach the process either way; only one ofthose paths puts it in the IR.
Stated without inflation: this PR takes the value out of the IR. It does not satisfy D-SEC-1's
statelimb —config_setup.go:437passesEnv: envVarsinto the config writer, which persistsEnvironment=into the deployment's unit. That is tracked as #75, whose fix is thetype:secretowner'sbindreturning an#Opaquehandle (spec/schema/bind.cue:48-52,DESIGN.md:685).1. The overlay step is a named function
A byte-for-byte MOVE, with identical suite results before and after. It exists so a harness can drive the
function rather than observe a plan set: the plant fails at the code path that would ship the call.
2. The entry point — the deploy's BOX, not the image it runs
c.Boxis definitionally a box —loadUnifiedForBoxresolved the project with it.node.Imageis theimage the deploy runs: a box name for a box-based deploy (
check-pod-overlay'simage: check-k8s-deploy-appis a box), but
quay.io/fedora/fedora:43for a registry deploy, which names no box. Preferring theimage started the walk from a ref that resolves to nothing and silently delivered no secrets.
3. The chain walk, the union, and the scoped resolve
boxCandyChainfollowsBase/Fromoverspec.BoxConfigFrom(uf.Box, …).DeployCandyChainadds D-CAP-6'sunion:
add_candy:candies run in the container and can authorsecret_require:, so a box-chain-only seamunder-resolves the overlay idiom this project's own pod bed uses. Known limit: an
add_candy:valueis a REF (
@github.com/opencharly/layer-ripgrep:v2026.235.1653), and resolving it to the candy NAME requiresreading that repo's manifest — which the config-time seam does not yet do. The union is contract-correct and
not yet effective for ref-form overlays; that is part of #75's scope.
4. The hazard this PR is really about
ResolveSecretForCandy→EnsureCandySecretauto-generates a 32-byte token when the value is missingeverywhere. An unscoped resolve at config time would mint and persist credentials for candies outside this
box's chain — a side effect on the operator's credential store, triggered by
charly config.That failure would be invisible until an operator found foreign secrets in their store. So it gets a test:
Head evidence
How tested
This is a runtime change, so it needs a bed (R10), and a bed was BUILT for it.
check-pod-overlaypredatesthe seam and has no
secret_require:candy in its chain — it proves the tree realizes with the seam present,not that the seam delivers. So delivery is proven by its own bed,
check-seam-proof:The changed path RAN, and its output is pasted. The check asserts the token's LENGTH only — a bed log
is output, and D-SEC-1 lists output.
And the plugin that RAN is named in the step log's path, not in
summary.yml'srepo_override(whichrecords the PROJECT):
The bed itself is uncommitted in a
charlyworktree, because it depends on this PR. Its landing is filed as #77 — the follow-up is a tracked issue, not a phrase.Unit gates in
candy/plugin-deploy-pod/:R7 — the assertions, and the plants
Three plant results, each pasted in the commit that introduced it:
A FOURTH plant, and it is the loop's own proof:
The first version tracked only CANDY names, and its only guard was
if next == base— which catchesA -> Abut notA -> B -> A. A two-box cycle revisits boxes whose candies are already collected, so the candy-level set never fires and the loop spins forever. The gate for a malformed manifest is validation's; this function's obligation is to terminate, because aconfigcommand that hangs is worse than one that reports a bad chain.Three fixtures, three lessons — plus a fourth about loops. Each of the first two passed against the implementation it was written to
catch until the fixture was made discriminating; the third could only fail once the overlay candy was
reachable only through
add_candy:. A fixture whose branches agree cannot test a choice between them,and a fixture built from the implementation's expectations inherits its blind spot.
Rulebook compliance
/charly-internals:plugin,/charly-internals:go,/charly-check:check,/charly-internals:git-workflow.EnsureCandySecretminting hazard is fixed by scoping and guarded by a test that fails without it. Thestatelimb is filed as D-SEC-1's state limb: the config-time seam persists a secret as Environment=; the fix is the type owner's bind returning a HANDLE #75, not parked. The union's ref-resolution limit is stated in §3 and named in D-SEC-1's state limb: the config-time seam persists a secret as Environment=; the fix is the type owner's bind returning a HANDLE #75.EnsureCandySecretis called, never re-implemented.origin/main; no other session's work touched.check-seam-proof, PASS,steps=16, on the committed tree, with the plugin's provenance quoted from the step log.Change classification
Kind: three new files, one call site, and one extracted function — no manifest, pin or dependency
changes.
Breaking change + rollback: none — the seam ADDS an environment value that four services already receive by
a slower route;
InjectSecretsIntoPlansis untouched, so any deployment that works before this PR works afterit. There is no dependency change, so rollback is a plain revert of the code commits.
Filed issues
check-seam-proofPASSES and its run is pasted above, but it is uncommitted incharly's worktree because it depends on this seam. The issue carries the YAML, the run, the three limits itsdescription:bears, and the four schema facts the bed cost. A change's own proof scope is not an unfiled follow-up.statelimb. The seam removes the value from the IR; the config writer still persists it asEnvironment=in the deployment's unit, andstateis listed separately from the IR. The fix is thetype:secretowner'sbindreturning an#Opaquehandle (spec/schema/bind.cue:48-52,DESIGN.md:685). It also owns theadd_candy:ref→name resolution named in §3.secret_require:services migrate onto this seam first, thenInjectSecretsIntoPlansgoes. Deleting ahead of a working env seam is exactly the regression feat(pod): stop injecting secret VALUES into plan env — the plan carries the FileStep #69 recorded.The four consumers, counted with the key's colon and with output pasted:
Without the colon the count is 15 in a tree carrying worktrees (11 without them), because the rest are comments.
Files changed
candy/plugin-deploy-pod/config_secret_env.goboxCandyChain(the Base/From walk overspec.BoxConfigFrom),DeployCandyChain(D-CAP-6's union withadd_candy:),deployBoxBase(the entry-point precedence),PodEnvVarsWithSecrets(the envVars build the config path calls), and the scoped resolve; the candy body is decoded intospec.Candy, the typed model, never a hand-written mirror of its fieldscandy/plugin-deploy-pod/config_secret_env_test.gocmp-verifiedcandy/plugin-deploy-pod/config_setup.gomergeEnvSlices, appending toenvVarscandy/plugin-deploy-pod/overlay.godeliverSecretEnvextracted — a byte-for-byte move of the three calls; and its delivery contract corrected: D-SEC-1 forbids the value entering the PLAN, not the process's environmentcandy/plugin-deploy-pod/overlay_test.goAgent: lead
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (analysed on a live system)