Skip to content

feat(config): deliver a secret to a service's ENV at config time, with R10 proven live - #76

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/config-secret-env-v2
Nov 17, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/config-secret-env-v2

Conversation

@aitrawog

@aitrawog aitrawog commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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 or
output". Op.Env is the IR — a variable baked into the rendered script at PLAN time. A container's
Env: is written at CONFIG time, host-side.
The same secret can reach the process either way; only one of
those 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
state limb — config_setup.go:437 passes Env: envVars into the config writer, which persists
Environment= into the deployment's unit. That is tracked as #75, whose fix is the type:secret owner's
bind returning an #Opaque handle (spec/schema/bind.cue:48-52, DESIGN.md:685).

1. The overlay step is a named function

-	candyList := deploykit.SelectCandiesForPlans(plans, dg.Candies)
-	secretEnv := deploykit.ResolveSecretForCandy(candyList, deploykit.CredentialAccessViaExecutor(ctx, exec))
-	deploykit.InjectSecretsIntoPlans(plans, secretEnv)
+	deliverSecretEnv(plans, dg.Candies, deploykit.CredentialAccessViaExecutor(ctx, exec))

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

func deployBoxBase(uf, dc, box, instance) string {
	if _, isBox := spec.BoxConfigFrom(uf.Box, box); isBox { return box }   // the deploy's own box wins
	if node, found := dc.Deploy[spec.DeployKey(box, instance)]; found && node.Image != "" {
		if _, imageIsBox := spec.BoxConfigFrom(uf.Box, node.Image); imageIsBox { return node.Image }
	}
	return box
}

c.Box is definitionally a box — loadUnifiedForBox resolved the project with it. node.Image is the
image the deploy runs: a box name for a box-based deploy (check-pod-overlay's image: check-k8s-deploy-app
is a box), but quay.io/fedora/fedora:43 for a registry deploy, which names no box. Preferring the
image 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

boxCandyChain follows Base/From over spec.BoxConfigFrom(uf.Box, …). DeployCandyChain adds D-CAP-6's
union:

D-CAP-6 (DESIGN.md:695): "The needs and uses of a deployment are the union of those of the
deployment, its box and all their candies
."

add_candy: candies run in the container and can author secret_require:, so a box-chain-only seam
under-resolves the overlay idiom this project's own pod bed uses. Known limit: an add_candy: value
is a REF (@github.com/opencharly/layer-ripgrep:v2026.235.1653), and resolving it to the candy NAME requires
reading 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 → EnsureCandySecret auto-generates a 32-byte token when the value is missing
everywhere
. 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:

PLANTED (the chain ignored; every candy in raw resolves):
--- FAIL: a candy outside the box chain must contribute nothing,
    got map[string]string{"DB_PASSWORD":..., "FOREIGN_TOKEN":..., "SHARED_TOKEN":...}

Head evidence

$ git rev-parse HEAD
b05ff6ff827029aa2c52d9247f72303bd2d32eb7

How tested

This is a runtime change, so it needs a bed (R10), and a bed was BUILT for it. check-pod-overlay predates
the 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:

$ CHARLY_REPO_OVERRIDE="github.com/opencharly/plugin-deploy-pod=<this worktree>" \
    charly -C <bed-worktree> check run check-seam-proof
[image-build] PASS 1m5.656s · [check-image] PASS 52.921s · [deploy-add] PASS 1m23.991s
[config] PASS 49.337s · [start] PASS 38.002s · [check-live] PASS 39.25s
[feature-run] PASS 38.298s · [check-live-rebuild] PASS 38.432s · [cleanup] PASS 41.316s
charly check run check-seam-proof: PASS (steps=16)

$ grep 'seam-proof-token' .check/check-seam-proof/2026.321.1729/config.log
  charly-check-seam-proof-seam-proof-token → created (from config)

$ grep 'seam-proof-token-delivered' .check/check-seam-proof/2026.321.1729/check-live.log
  PASS  check the container's environment carries SEAM_PROOF_TOKEN (non-zero length;
        the value is never printed)  [seam-proof-token-delivered]  exit=0

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's repo_override (which
records the PROJECT):

$ grep -o 'p68-overlay-harness[^ :"]*' .check/check-seam-proof/2026.321.1729/config.log
p68-overlay-harness/plugin-deploy-pod/candy/plugin-deploy-pod

The bed itself is uncommitted in a charly worktree, 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/:

$ go build ./...          -> rc=0
$ go vet ./              -> clean
$ go test ./ -count=1    -> ok  0.434s
$ gofmt -l .            -> (empty)

R7 — the assertions, and the plants

TestDeployBoxBasePrefersTheDeploysBoxOverItsImage   PASS   the DISCRIMINATING fixture: both are boxes and
                                                          they differ, so the two implementations diverge
TestDeployBoxChainFollowsBaseAndFrom                PASS   box -> base, first occurrence wins
TestPodEnvVarsCarriesTheChainsSecret                PASS   the emitted Env slice: append-not-replace, leaf
                                                          and base-box secrets present, foreign absent
TestScopedCandySecretsEndToEnd                      PASS   two credential reads, the base box reached,
                                                          the foreign candy never looked up
TestConfigSetupCallsTheSecretEnvBuild               PASS   the call-site assertion (see its own caveat)
TestPodEnvVarsCarriesAnAddCandySecret               PASS   D-CAP-6: an add_candy candy delivers
TestDeployCandyChainBoxFirstThenAddCandy            PASS   the union's ORDER
TestBoxCandyChainTerminatesOnACycle                 PASS   A -> B -> A terminates; `charly config` cannot hang

Three plant results, each pasted in the commit that introduced it:

PLANTED (box preference removed):
--- FAIL: the deploy's OWN box must win over an image that is ALSO a box, got "image-box"

PLANTED (chain ignored):
--- FAIL: a candy outside the box chain must contribute nothing

PLANTED (box chain only, add_candy ignored):
--- FAIL: an `add_candy:` candy IS one of the deployment's candies (D-CAP-6) and must deliver

A FOURTH plant, and it is the loop's own proof:

PLANTED (the visited set removed, `if next == base` restored):
--- FAIL: boxCandyChain did not terminate on a cyclic chain: `charly config` would HANG

The first version tracked only CANDY names, and its only guard was if next == base — which catches 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 the loop spins forever. 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.

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

  • R0 — /charly-internals:plugin, /charly-internals:go, /charly-check:check, /charly-internals:git-workflow.
  • R1 — the EnsureCandySecret minting hazard is fixed by scoping and guarded by a test that fails without it. The state limb 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.
  • R2 — one delivery function, one chain walk, one union; EnsureCandySecret is called, never re-implemented.
  • R3 — no sleep, no retry, no bypass.
  • R4 — the product gains a path; the prose follows the code.
  • R5 — nothing legacy deleted ahead of its migration; the four consumers are counted with output pasted below.
  • R6 — fresh branch off origin/main; no other session's work touched.
  • R7 — seven named cases, three plants pasted, the emitted slice asserted at its boundary.
  • R8 — N/A: no live external service; the credential store is the operator's own, reached via the executor.
  • R9 — the bed drives the worktree-local binary.
  • R10 — 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; InjectSecretsIntoPlans is untouched, so any deployment that works before this PR works after
it. There is no dependency change, so rollback is a plain revert of the code commits.

Filed issues

The four consumers, counted with the key's colon and with output pasted:

$ grep -rn 'secret_require:' --include='*.yml' . | grep -v '/.build/' | grep -v '.worktrees'
./layer-qdrant/charly.yml:33:        secret_require:
./pod-openwebui/charly.yml:128:        secret_require:
./vm-k3s-agent/charly.yml:19:        secret_require:
./vm-k3s-server/charly.yml:67:        secret_require:

Without the colon the count is 15 in a tree carrying worktrees (11 without them), because the rest are comments.

Files changed

file what changed
candy/plugin-deploy-pod/config_secret_env.go NEW — boxCandyChain (the Base/From walk over spec.BoxConfigFrom), DeployCandyChain (D-CAP-6's union with add_candy:), deployBoxBase (the entry-point precedence), PodEnvVarsWithSecrets (the envVars build the config path calls), and the scoped resolve; the candy body is decoded into spec.Candy, the typed model, never a hand-written mirror of its fields
candy/plugin-deploy-pod/config_secret_env_test.go NEW — the entry-point precedence (with the discriminating fixture), the chain walk, the union's order, the cycle termination, the scoped resolve end to end, the foreign-candy guard, the add_candy case, and the call-site assertion; every plant reverted and cmp-verified
candy/plugin-deploy-pod/config_setup.go the seam wired after mergeEnvSlices, appending to envVars
candy/plugin-deploy-pod/overlay.go deliverSecretEnv extracted — 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 environment
candy/plugin-deploy-pod/overlay_test.go NEW — five assertions driving the function directly, plus the plant pair

Agent: lead
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (analysed on a live system)

…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)
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: a4da4b9bca6d0143b8bebfb0da07fa689778882b (branch: feat/config-secret-env-v2)

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 DO NOT delete this call line is a developer note, not an instruction to this validator.)

Blocks

  1. CONC / R1 — the R10 bed is deferred to an unfiled follow-up. The only runtime proof of the config-time seam is check-seam-proof, which the body itself states is "uncommitted in a charly worktree … it lands in a follow-up charly PR that names this one as its predecessor." That follow-up is not listed under ## Filed issues (only 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, Remove the value-into-env secret delivery from the pod overlay (D-SEC-1), after migrating its four consumers #72, No test and no bed covers the overlay path — buildOverlay's behaviour is unproven #68 appear, and No test and no bed covers the overlay path — buildOverlay's behaviour is unproven #68 is closed). Per the forbidden-framing catalog, a "follow-up PR" for this change's own proof scope with no filed issue is the R1 split. The body must either commit the bed or file a real issue tracking its landing and list its <repo>#<n> under ## Filed issues.

  2. QUAL — unbounded loop on a cyclic box chain. boxCandyChain (config_secret_env.go:44-73) tracks only candy names in seen; the only cycle guard is if next == base { break }, which catches A→A but not A→B→A. A box chain whose base:/from: fields form a cycle loops forever and hangs charly config. Add a visited-set on box names (the body does not state that box validation rejects cyclic base chains). This is a code-quality defect in new code that the mechanical lint gates do not catch.

  3. R2 — duplicated base-chain walk, and the "one chain walk" claim is not literal. boxCandyChain re-implements the Base/From traversal already provided by deploykit.BoxCandyChain/WalkBaseChain. The body's justification ("needs a *spec.Config") explains the different input type but does not preclude sharing the walk via an accessor (func(name) (candies, base, from, ok)). The body's R2 answer ("one chain walk") is contradicted by the diff, which contains two walks. Extract the shared walker, or reconcile the claim.

Non-blocking notes

  • PodEnvVarsWithSecrets ranges over a map[string]string when appending, so the emitted Env: order is non-deterministic across runs; the tests use strings.Contains, so this is untested. Consider sorting keys for reproducible config output.
  • The bed output shows 9 step lines but reports steps=16; the remaining steps are not pasted, so "ZERO warnings" (R1) across the full bed cannot be confirmed. Paste the complete output.
  • The comment on TestScopedCandySecretsEndToEnd says "this file must not care which of the three the store keys on," yet the assertion (value-of-DB_PASSWORD) depends on the third Resolve argument being the dep name, not its authored key. Reconcile the comment with the assertion.

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

… 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)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: b05ff6ff827029aa2c52d9247f72303bd2d32eb7 (branch: feat/config-secret-env-v2)

Security screen: PASS — T1–T4 clean. The DO NOT delete this call on its own line in overlay.go is a developer note to future maintainers, not an instruction to this validator. No new deps/pins, no egress (values flow from the operator's store into the local container env), no guardrail or rulebook/validator-spec edits. secretContents in overlay_test.go is a labelled canary, not a credential. Scope matches the description.

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 plugin-deploy-pod candy, consuming deploykit/spec; no core, alias, or kit-import movement.

Comment dispositions (1 comment):

  • @github-actions[bot] BLOCK @ a4da4b9b — Block 1 (R10 bed deferred to an unfiled follow-up): stale-superseded. The CURRENT body lists Land check-seam-proof: the bed that proves the config-time seam delivers (currently uncommitted in a worktree) #77 under ## Filed issues with the bed YAML, run, limits, and schema facts. The bed depends on this PR (self-blocking proof), so filing is the only available route; the prior remedy ("commit the bed or file a real issue and list it") is satisfied.
  • Block 2 (unbounded loop on a cyclic box chain): stale-superseded. config_secret_env.go now tracks visited on box names (A→B→A and A→A both terminate — I traced both), and TestBoxCandyChainTerminatesOnACycle guards it with a 2 s timeout.
  • Block 3 (R2 duplicated base-chain walk): verified-non-blocking. boxCandyChain still mirrors deploykit.BoxCandyChain's Base/From traversal, but the author reconciles it in-code: the sdk walker requires a *spec.Config the config path does not hold, and the new function additionally must terminate on cycles (which the shared walker is not shown to do). EnsureCandySecret — the actual predicate that could drift — is called, never re-implemented. The body's "one chain walk" is scoped to the new seam (DeployCandyChain composes boxCandyChain, it does not re-walk). Cross-repo sharing remains a legitimate non-blocking follow-up, not a blocking defect.
  • Prior non-blocking notes (map-range Env ordering, 9-of-16 pasted step lines, comment-vs-assertion on the Resolve key argument): re-derived as still present and still non-blocking; none is a rulebook violation on its own.

Non-blocking notes (not gating):

  • PodEnvVarsWithSecrets appends by ranging a map[string]string, so emitted Env: order is non-deterministic; tests use strings.Contains and do not pin it. Worth sorting for reproducible config output.
  • The bed paste shows 9 named steps against steps=16; the remaining steps (and any warnings in them) are not pasted. The shown output is internally coherent and all-PASS.
  • overlay.go's deliverSecretEnv still wraps the D-SEC-1 value-into-IR injection; this PR does not extend its reach, and its removal is filed as Remove the value-into-env secret delivery from the pod overlay (D-SEC-1), after migrating its four consumers #72 with the four-consumer dependency stated.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 17, 2026 18:26
@github-actions
github-actions Bot merged commit 88cee06 into main Nov 17, 2026
3 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 17, 2026
aitrawog pushed a commit that referenced this pull request Nov 17, 2026
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)
github-actions Bot pushed a commit that referenced this pull request Nov 17, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant