Skip to content

feat(deploykit): deliver a use: secret: entry as a FILE step at realize - #551

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/p07-secret-delivery
Nov 17, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/p07-secret-delivery

Conversation

@aitrawog

@aitrawog aitrawog commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The first producer of a FileStep — and the mechanism was already there.

DESIGN.md:2983 says "there is no get: a value reaches a consumer as a secret: need, never as text", and D-SEC-1 (:2511) says a secret "never enters the store, artifacts, labels, IR, state or output". Today that is violated by deploykit.InjectSecretsIntoPlans, which puts VALUES into OpStep.Op.Env so the heredoc renderer emits export KEY=value.

This compiles each use: secret: entry into a file delivery instead:

&FileStep{Source: src, Dest: dst, Mode: 0o600, CandyName: layer.GetName()}

and kit/walk.go's walkFile — which already ships — does the rest:

content, err := os.ReadFile(step.Source)                                  // the OPERATOR HOST, at realize
exec.PutFile(ctx, step.Dest, content, mode, isSystem(step.Scope))        // the VENUE

The IR carries only the two paths. The value never enters the plan, the ledger, a log or an artifact, so D-SEC-1 holds by construction rather than by care — and because PutFile is one method of the substrate-neutral DeployExecutor with every deploy target out-of-process on that same walk, one compiled step serves local, pod and vm.

Nothing produced a FileStep before this — measured, and it changed the proof

$ for r in spec sdk charly; do echo "$r: $(git -C $r grep -c 'FileStep{' origin/main -- '*.go')"; done
spec:   1     → spec/install_step_view.go:200 -- the WIRE DECODER, not an emitter
sdk:    0
charly: 3     → all *_test.go fixtures
$ grep -rln 'FileStep{' .worktrees/*/plugin-*/ --include='*.go'
(none)

So kit.walkFile has never been driven by a compiled plan in this tree. That is why the R7 proof below is at PLAN level — "a compiled step actually lands in the plan, before the candy's own steps" — and not merely "the compiler returns the right struct." A struct assertion would have proved nothing about whether the step reaches the plan at all.

The four decisions, and where each is visible

decision where
Position after extract, before the candy's own op steps slot 2.8 in install_build.go, so a task that reads dst finds it in place
Sorted by entry NAME so the plan is reproducible; the sort is one of the two planted failures below
Mode 0o600 a secret delivered world-readable is not delivered
Compile-time optional skip when optional-and-unreadable, error naming candy+entry when required-and-unreadable, error when src/dst is absent

And an unreachable use: block is an ERROR, not a silent skip. ErrUseBlockUnreachable wraps, so errors.Is classifies it; the message names the offending Go type and points at NewSpecCandyModel; and var _ secretUseCarrier = (*specCandyAdapter)(nil) pins the one production implementation at compile time. A silent skip on a secret delivery is the worst possible failure — the deployment starts without the key it needs and reports success. TestCompileSecretSteps_UnreachableUseBlockIsAnError proves the miss with a struct that embeds the reader interface (every method, no accessor).

The residual race is named in the code comment rather than hidden: the source is stated at compile and read at realize, so an optional entry whose file vanishes in between fails at realize instead of being skipped. That is spec#363 — FileStep has no optional, so the tolerance is decided one step early. It does not block the delivery, and the issue asks for the shape that would remove the second authority.

Producer-first, and the deletion that is NOT this module's

go.mod bumps github.com/opencharly/spec v0.2026320.2307 → v0.2026321.1215, the merge that made CandyUse.Secret a real map. Producer first, consumer second.

deploykit.InjectSecretsIntoPlans is untouched, deliberately. Its only caller is the out-of-tree candy/plugin-deploy-pod overlay (git -C sdk grep -rn 'InjectSecretsIntoPlans' origin/main → one definition, zero in-module callers; the call site is charly/.build/_candy/plugin-deploy-pod.v2026.274.2042/overlay.go:88). Deleting it here would break that plugin at its next pin bump. That deletion is the plugin's cutover leg, not this module's — producer-first, exactly as the rulebook orders it.

How tested

$ go build ./...     → rc=0
$ go vet ./...       → rc=0
$ go test ./...      → rc=0   0 failures, 21 packages ok
    go test ./deploykit/ -count=1 -v   → ok  12.489s
$ GOOS=linux GOARCH=amd64|arm64|arm|386 go build ./...   → rc=0 for all four
$ GOTOOLCHAIN=go1.26.8 GOSUMDB= golangci-lint run ./...  → 0 issues.
$ gofmt -l .         → (empty)

The cross-compile matrix is there because this module is consumed by every substrate; a build that passes on amd64 alone has not been tested against the targets it ships to.

R7 — and the REALIZE path, which is the one that earns the sentence

PLANTED A (the CompileSecretSteps call removed from BuildDeployPlan):
  --- FAIL: TestBuildDeployPlan_CarriesTheSecretDeliveryStep
      the plan carries 0 file steps, want 1 — the secret delivery never reached the plan

PLANTED B (the name sort reversed):
  --- FAIL: TestCompileSecretSteps_EmitsOneFileStepPerEntrySorted
      steps are not in entry-NAME order: "/run/lab/zzz" then "/run/lab/aaa"

RESTORED (byte-identical):
  --- PASS  all five —
      per-entry sorted steps with mode 0600;
      optional + missing source skips;
      required + missing source errors naming candy AND entry;
      an entry without `dst` errors;
      plan-level wiring, including that the FileStep precedes the first Op step.

Both plants are load-bearing: A proves the step reaches the plan, B proves the order is derived rather than incidental. A test that passes with the call removed would be testing the fixture, not the product.

But a plan-level proof is not a delivery proof, so kit/secret_delivery_realize_test.go goes the whole way — walkFile lives in package kit, so a package kit_test file can drive kit.WalkPlans with a recording DeployExecutor:

  1. a temp host file with known bytes,
  2. CompileSecretSteps on a candy whose use: secret: block came through NewSpecCandyModel,
  3. spec.StepsToView → the IR the deploy targets actually walk,
  4. kit.WalkPlans(ctx, recorder, …),
  5. assertions: the bytes land at Dest with mode 0600 and nothing else was written, and the bytes appear nowhere else — not in the plan, not in the serialized InstallPlanView a ledger or a log would record.
PLANTED A (the step's Source corrupted, so the walk cannot read it):
  --- FAIL: TestACompiledSecretStepLandsTheFileAndOnlyThere
      WalkPlans: walk step "File" (candy=lab-signing): read file source /nonexistent/planted:
      open /nonexistent/planted: no such file or directory

PLANTED B (the value smuggled into an Op step's Env):
  --- FAIL: TestACompiledSecretStepLandsTheFileAndOnlyThere
      the secret VALUE is in the serialized plan — D-SEC-1: it never enters the IR, a label or a log

RESTORED:  --- PASS  both

Plant B is the assertion that earns the Summary's sentence. It is not "the bytes moved" — it is "the bytes are nowhere except the destination", which is D-SEC-1 as a property rather than a hope.

And TestTheSecretStepRefusesAnUnreadableSource pins the race spec#363 names: the source is present at compile (so a REQUIRED entry is accepted), then removed before the walk reads it — the walk FAILS rather than landing nothing and reporting success.

R10 honesty, premise and exit status pasted

$ grep -c 'disposable:' charly.yml
0
$ echo "grep_exit=$?"
grep_exit=1

opencharly/sdk is the mechanism-kit module: no disposable: target, no service, no binary. Its gate is the module suite, the cross-compile matrix and lint, all pasted. The grep exits 1 — no match is not a success.

Rulebook compliance

  • R0 — skills first; /charly-internals:go (the module's Go conventions), /charly-internals:install-plan (the InstallPlan/step IR this extends), /charly-internals:plugin (the provider/need model the use: secret: entry belongs to).
  • R1 — no new anomaly; the shape gap this exposes (FileStep has no optional) is filed as spec#363, with the residual race named in the code rather than smoothed over.
  • R2 — one authority for the tolerance: spec#363 exists precisely because optional is currently decided at compile time and belongs on the step. The adapter gains ONE accessor rather than widening spec.CandyReader, so there is still exactly one production implementation.
  • R3 — no workaround: no value is decrypted into an env var, no second decode of the authored document, no fallback path.
  • R4 — product before prose: what D-SEC-1 forbids is now unrepresentable in the plan rather than merely discouraged.
  • R5 — nothing is shadowed: the new path is additive, and the old one is deleted by the leg that owns it (the pod plugin), not silently left beside it.
  • R6 — a fresh branch off origin/main 78cf7c8; no other session's worktree touched.
  • R7 — two planted failures, both restored, both at plan level because no compiled FileStep had ever existed.
  • R8 — N/A: no service boundary.
  • R9 — no binary; the cross-compile matrix stands in for the build question this module actually has.
  • R10 — no disposable: target; premise and exit status pasted.

Change classification

Kind: a new compiler pass in sdk/deploykit plus a spec pin bump.

Breaking change + rollback: none. BuildDeployPlan gains a step at slot 2.8 for a candy that declares use: secret:; a candy that declares none compiles byte-identically (CompileSecretSteps returns nil for an absent CandyUse). spec.CandyReader is not widened — the accessor lives on deploykit's adapter. The pin bump moves to a merged spec tag. Rollback reverts the pin and removes the pass; nothing downstream reads the new steps yet, so the rollback is invisible to every current consumer.

Filed issues

Files changed

file what changed
deploykit/compile_secret_steps.go NEW — CompileSecretSteps lowers use: secret: entries to sorted, mode-0o600 FileSteps; compile-time optional with the residual race named
kit/secret_delivery_realize_test.go NEW — the REALIZE proof: a compiled step driven through kit.WalkPlans with a recording executor, asserting the bytes land at Dest at mode 0600 and appear NOWHERE else, not even in the serialized plan
deploykit/compile_secret_steps_test.go NEW — six tests: per-entry sorted steps, optional+missing skips, required+missing errors naming candy and entry, entry without dst errors, and the plan-level wiring that the step precedes the first Op step
deploykit/install_build.go slot 2.8, after extract and before the candy's own op steps
deploykit/spec_candy_adapter.go one CandyUse() accessor, so spec.CandyReader is not widened
go.mod the spec pin v0.2026320.2307 → v0.2026321.1215 (producer first)
go.sum the matching sums

Agent: lead
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)

…lize

P07 unit 2b. DESIGN.md:2983 — "there is no `get`: a value reaches a consumer as a `secret:`
need, never as text" — and D-SEC-1, DESIGN.md:2511 — "Secrets come only from the configured
backend; they never enter the store, artifacts, labels, IR, state or output."

The authored shape (`#SecretUse`: `src` a host path, `dst` a venue path, `optional`) is a
FILE→FILE delivery, and the IR already has the step that performs one: `spec.FileStep{Source,
Dest, Mode}` is realized by `kit.walkFile`, which reads `Source` on the OPERATOR host at realize
and `DeployExecutor.PutFile`s the bytes into the venue. The step carries the two PATHS and a
mode; the value never enters the plan, the ledger, a log line or an artifact, so D-SEC-1 holds by
construction rather than by care. One emitter serves every substrate: `PutFile` is one method of
the substrate-neutral `DeployExecutor`, and every deploy target is out-of-process over that same
walk — no per-substrate code, no per-substrate shape.

THIS IS THE FIRST PRODUCER OF A FileStep IN THE TREE. Until now the only non-test construction
was the wire decoder (`spec/install_step_view.go:200`); `git -C sdk grep -c 'FileStep{'
origin/main -- '*.go'` is 0, charly's hits are all `*_test.go`, and no checked-out plugin emits
one. So `kit.walkFile` has had no compiled-plan caller before this change, which is why the
wiring is proved end-to-end below rather than only at the compiler.

## The four decisions, implemented

1. `optional` is decided at COMPILE time, on the operator host where the source actually lives:
   an optional entry whose source is unreadable is skipped (DESIGN.md:735 — "the key is readable
   when the host had one"); a REQUIRED entry whose source is unreadable is an error naming the
   candy and the entry, so a typo cannot silently deliver nothing. THE RESIDUAL RACE IS NAMED IN
   THE CODE: the source is stat'ed at compile and read at realize, so an optional entry whose
   file disappears in between fails at realize instead of being skipped. Closing it needs an
   `optional` field on the File step, which is a wire-shape change and a separate unit.
2. Sorted by entry NAME, so a plan is reproducible compile to compile.
3. Mode `0o600` — a secret delivered world-readable is not delivered.
4. Position: slot 2.8 in `BuildDeployPlan`, AFTER `extract` and BEFORE the candy's own op steps,
   so a task that reads `dst` finds the file already in place.

## The accessor, and why it is not a reader-interface widening

`deploykit.specCandyAdapter` is the ONE production implementation of `spec.CandyReader`
(charly/layers.go wraps every candy through `deploykit.NewSpecCandyModel`), and it already holds
the raw `spec.CandyModel`. So the authored `use:` block is reached by one method on that one
type — `CandyUse()` — and a CandyModel that does not carry the authored model simply has no
`use:` entries to compile. `spec.CandyReader` is unchanged.

## Pin

`github.com/opencharly/spec` v0.2026320.2307 -> v0.2026321.1215 (the merge that made
`spec.CandyUse.Secret` a real map, opencharly/spec#360). Producer first, consumer second.

## R7, both halves, twice

    PLANTED A (the CompileSecretSteps call removed from BuildDeployPlan):
      --- FAIL: TestBuildDeployPlan_CarriesTheSecretDeliveryStep
          the plan carries 0 file steps, want 1 — the secret delivery never reached the plan
    PLANTED B (the name sort reversed):
      --- FAIL: TestCompileSecretSteps_EmitsOneFileStepPerEntrySorted
          steps are not in entry-NAME order: "/run/lab/zzz" then "/run/lab/aaa"
    RESTORED:
      --- PASS  all five (per-entry sorted steps with mode 0600; optional-and-missing skips;
                 required-and-missing errors naming candy+entry; entry without `dst` errors;
                 and the plan-level wiring plus its before-the-op-steps position)

## Not in this change, deliberately

`deploykit.InjectSecretsIntoPlans` (the value-into-`OpStep.Op.Env` mechanism) is untouched: its
only caller is the out-of-tree `plugin-pod` overlay, which switches to the steps compiled here
in its own release. Deleting it in this diff would break that plugin at its next pin bump, and
the cutover is producer-first.

Gates on the final tree: go build ./... rc=0, go vet ./... rc=0, go test ./... rc=0 with 0
failures across 21 packages, the cross-compile matrix (linux/amd64, arm64, arm, 386) all rc=0,
golangci-lint 0 issues, gofmt -l empty.

Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 29a838375a5dea8039a53f12d8e1d23cfc6b3b5d (branch: feat/p07-secret-delivery)

Change class: code — a new Go compiler pass in deploykit (sdk mechanism-kit module) plus a spec pin bump. No runtime bed / disposable target (honest: grep -c 'disposable:' charly.yml → 0, exit 1).

Blocks

  1. R1 / CONC(b) / R5 — the admitted D-SEC-1 violation is left in-tree with no filed issue. The body itself states "Today that is violated by deploykit.InjectSecretsIntoPlans, which puts VALUES into OpStep.Op.Env." That function is a value-into-env path that puts the secret into the IR — the exact thing D-SEC-1 forbids. The body defers its removal as "the plugin's cutover leg, not this module's" — a parking phrase with no filed issue under ## Filed issues (only spec#363/fix(deploykit)!: name a namespaced deploy's container from the split pair, not the dotted address #362/packagekit: variant packages cannot install over one another — the builder never emits Conflicts/Replaces/Provides for a variant family #348 are listed; none tracks removing InjectSecretsIntoPlans). Producer-first sequencing is legitimate, but R1/CONC require a surfaced non-blocking finding to be fixed in-tree or filed. Fix: file a real issue (e.g. opencharly/sdk#<n>) for the eventual in-module deletion of InjectSecretsIntoPlans, and update the R5 bullet (which currently claims the old path is "not silently left beside it" — it is). If the consumer plugin is already migrated, delete it in-tree instead.

  2. R7 / R10 / A2 — the "deliver at realize" behaviour is not proven; only the compiler is. The summary claims "one compiled step serves local, pod and vm," but the pasted proof is explicitly "at PLAN level" only. The body's own measurement (git -C sdk grep -c 'FileStep{' → 0) shows no FileStep has ever been constructed in sdk, so no sdk test drives walkFile with a compiled FileStep — the read-src/PutFile-to-dst delivery the PR claims is unexercised. Add an integration test that runs a compiled FileStep through the delivery path (a fake DeployExecutor asserting PutFile(dest, content, mode) args), or paste existing walkFile+FileStep coverage and explicitly bound the claim to "compiled into the plan" (drop "serves local, pod and vm"). Related: if delivery is unproven, the fully tested and validated tier (A3) overstates the change — align the tier with what the evidence actually shows.

Non-blocking notes

  • ## Filed issues lists spec#362 and spec#348, which do not appear to be findings surfaced by this diff; if they aren't, drop them so the section stays accurate.
  • secretUseCarrier is a type assertion: any CandyModel that is not *specCandyAdapter silently loses its use: secret: entries. Fine today (adapter is the sole production impl), but fragile — worth a defensive comment/error.
  • Agent: lead is not in the backtick/session form; coordination metadata only, not a finding.

Verdict: BLOCK


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

View action run

… only there

Second review round on #551. The claim "one compiled step serves local, pod and vm"
was written against a plan-level proof; this round makes it a realize proof, and closes the
silent-skip hole in the accessor.

## The realize proof (the review's block 2)

`walkFile` had never been driven by a compiled plan in this tree — this unit is the first producer
of a `spec.FileStep`, and the only other construction anywhere is the wire decoder. So the claim
was unproven at exactly the step that matters.

`kit/secret_delivery_realize_test.go` (new, package kit_test) goes the whole way: a temp host file
with known bytes, `deploykit.CompileSecretSteps`, `spec.StepsToView`, `kit.WalkPlans` against a
recording `DeployExecutor`, and then TWO assertions:

1. the bytes arrive at `Dest` with mode `0600`, and nothing else was written;
2. **the bytes appear NOWHERE ELSE** — not in the plan, not in the serialized `InstallPlanView`
   that a ledger or a log would record. That is the D-SEC-1 assertion: the delivery is "a value
   reaches its consumer as a file, never as text", and (1) alone would pass on a plan that also
   carried the value in an env var.

Both halves, planted and restored:

    PLANTED A (the step's Source corrupted — the walk cannot read it):
      --- FAIL: TestACompiledSecretStepLandsTheFileAndOnlyThere
          WalkPlans: walk step "File" (candy=lab-signing): read file source /nonexistent/planted:
          open /nonexistent/planted: no such file or directory
    PLANTED B (the value smuggled into an Op step's Env):
      --- FAIL: TestACompiledSecretStepLandsTheFileAndOnlyThere
          the secret VALUE is in the serialized plan — D-SEC-1: it never enters the IR, a label or a log
    RESTORED:
      --- PASS  both

`TestTheSecretStepRefusesAnUnreadableSource` pins the negative direction the race named in
spec#363 creates: the source exists at compile (so the compile accepts a required entry) and is
removed before the walk reads it — the walk must FAIL, not land nothing and report success.

## The accessor: a silent skip became a named error (the review's non-blocking note)

`CompileSecretSteps` reached the authored `use:` block through a structural assertion on
`secretUseCarrier`, and a CandyModel without it silently had no entries — the worst possible
silent loss, because the deployment starts without the key it needs and reports success.

Now:

- `ErrUseBlockUnreachable` is returned, naming the offending Go type and pointing at
  `deploykit.NewSpecCandyModel`; the error wraps, so `errors.Is` classifies it.
- `var _ secretUseCarrier = (*specCandyAdapter)(nil)` pins the one production implementation at
  compile time.
- `TestCompileSecretSteps_UnreachableUseBlockIsAnError` pins the choice with a model that has every
  reader method and no accessor (`notACarrier{ Cmd CandyModel }` embeds the interface).
- The doc records why a miss cannot happen on the production path (charly/layers.go is the
  scanner's only construction path, and the golden tool uses the same constructor) and what would
  break it (a caller that builds its own CandyModel).

## PR body corrections (for the next push)

`## Filed issues` is `spec#363` (the `optional` gap THIS diff surfaced) and `sdk#552` (the
`InjectSecretsIntoPlans` D-SEC-1 remainder, filed by the reviewer's finding). `spec#362` and
`spec#348` are removed: both are real, but neither was surfaced by this diff, and listing them
claims a provenance the section does not have.

Gates on the final tree: go build ./... rc=0, go vet ./... rc=0, go test ./... -count=1 rc=0 with 0
failures across 21 packages, the cross-compile matrix (linux/amd64, arm64, arm, 386) all rc=0,
golangci-lint 0 issues, gofmt -l empty.

Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 277560656c5957d9140ba7ecf56b1588eaea74ad (branch: feat/p07-secret-delivery)

Security screen: PASS — no scope mismatch, no secrets/exfiltration, no guardrail weakening (the change moves values out of the IR, strengthening D-SEC-1), no supply-chain risk beyond the first-party spec pin bump.

Checklist: All applicable rules PASS or NA.

Comment disposition: Prior bot BLOCK (head 29a8383) — stale-superseded. Both findings are resolved in the current diff: (1) InjectSecretsIntoPlans is now tracked by opencharly/sdk#552 under ## Filed issues, so it is no longer a "filed for later" parking phrase; (2) kit/secret_delivery_realize_test.go now drives kit.WalkPlans → DeployExecutor.PutFile with a recording executor, asserting the bytes land at Dest at mode 0600 and appear nowhere in the serialized plan — the realize proof that was missing. Its spec#362/#348 and silent-skip notes are also no longer present (accessor now errors with ErrUseBlockUnreachable; filed list is spec#363 + sdk#552 only). No surviving finding.

Core new behavior is load-bearing-tested (Planted A proves the step reaches the plan; the realize test fails if the read is broken or the value leaks into the IR); the delivery ordering is additionally guaranteed by the slot-2.8 placement in install_build.go, provable from the diff itself.

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 12:36
@github-actions
github-actions Bot merged commit 6fa84e9 into main Nov 17, 2026
8 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 17, 2026
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