Skip to content

refactor(secrets)!: remove the config secret backend; compute quadlet autostart as a capability - #212

Closed
atrawog wants to merge 2 commits into
mainfrom
feat/secret-backend-capability
Closed

atrawog wants to merge 2 commits into
mainfrom
feat/secret-backend-capability

Conversation

@atrawog

@atrawog atrawog commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Remove the config secret backend; compute quadlet autostart as a capability

The consumer half of opencharly/sdk#121, which must merge first (this PR's sdk gitlink
points at its head).

Encryption passphrases come from the environment, the system keyring via Secret Service, or a
forwarded GPG agent. Quadlet autostart is served by Secret Service alone — not because any
emitter checks for it by name, but because it is the backend that can unlock with no human running
a command. The supported set is an outcome of that property rather than a list the code carries.

Candy Change
plugin-deploy-pod computes the capability (resolveEncUnattendedUnlock) and threads it into BOTH QuadletConfig sites, replacing secretBackendIsKeyring()
plugin-settings secret_backend accepts only auto and keyring; config is rejected with a message naming what to use instead
plugin-secrets resolveSecretBackend normalizes through kit.NormalizeSecretBackend; the now-unreachable case "config" store selection deleted; five remediation hints stopped prescribing the removed value
plugin-doctor two InstallHints stopped prescribing it, and the now-unreachable "config file (explicit)" OK branch deleted
plugin-pod pluginResolveSecretBackend normalizes through the SAME helper, so the backend it reports and the backend that selects the store cannot diverge

The capability is asked only when a deploy has encrypted volumes. A deploy without them
autostarts unconditionally, so probing the credential store for it would be a pointless round trip
— and, on a locked keyring, a needless probe.

plugin-secrets' and plugin-pod's backend readers were an R3 duplicate pair — the latter's own
comment described itself as a verbatim mirror. They now share one helper.

A refuted premise: this is not a charly migrate change

The task specified that charly migrate must handle a host already carrying
secret_backend: config. It cannot. secret_backend lives in the runtime config
~/.config/charly/config.yml, while charly migrate processes the project charly.yml and the
per-host deploy overlay ~/.config/charly/charly.yml — a different file it never opens
(candy/plugin-migrate/command.go:54 → spec/spec/deployconfig.go:23). The precedent agrees: the
retired kdbx value was handled by a reject gate in the runtime-config loader.

This matters beyond bookkeeping. Rejecting the value in the settings setter alone would not
remove it from service — it also arrives from a pre-removal config file and from
CHARLY_SECRET_BACKEND, which no validator sees. Both readers therefore coerce it to auto, once,
with a notice. That guarantee is what makes sdk#121's deletion of the non-waiting mount branch
sound.

Coercion rather than rejection keeps an already-configured host working: auto still falls back to
the config file when no keyring is present, so nothing becomes unreachable. The operator loses only
the ability to pin charly to the plaintext store, which is the point of the removal.

One measured regression, disclosed rather than smoothed over

secret_backend: config was not purely vestigial — it was the only way to declare "this host has
no keyring, fail fast". On such a host with no passphrase stored, charly config mount used to
fail immediately. It now classifies as unavailable and polls to EncMountDeadline: 120.09s
measured
, then the same actionable error.

Bounded, and already what the default auto does on any keyring-less host — the pin was the only
opt-out. It surfaced as TestPluginEncMount_NoShortCircuit_WhenOneUnmounted going from 0.00s to
120.09s. If fast-fail should be preserved, that is a separate classification fix in
resolveStoreChain and does not belong in this cutover.

R10 acceptance — both affected beds, full sequence

charly check run check-enc-pod:      PASS (steps=13)
charly check run check-enc-port-pod: PASS (steps=13)

Each is the complete sequence — build → check image → deploy → config → start → check live →
fresh charly update destroy+rebuild → check live again → teardown — on the CalVer binary
built from this tree (charly version = 2026.216.2333, R9). Both encrypted-volume assertions
pass before AND after the rebuild:

PASS  check host-side `charly config status` reports the encrypted volume initialized AND mounted  [enc-status-mounted]  exit=0
PASS  check the FUSE-backed plain dir is bind-mounted into the container and writable            [enc-plain-writable]  exit=0
33 steps: 30 passed, 0 failed, 3 skipped

The quadlet emitted live for an encrypted deploy whose passphrase is in the credential store —
the unattended-capable arm, exactly as the capability predicts:

[Service]
Restart=always
ExecStartPre=.../bin/charly config mount check-enc-pod
TimeoutStartSec=0

[Install]
WantedBy=default.target

R1 on the first attempt, which failed at enc-status-mounted: the cause was not this change.
That step resolves charly from PATH and found the packaged /usr/bin/charly, whose own
freshness guard correctly refused to run against newer sources. Re-run with the worktree's bin/
on PATH — R9's rule that the binary under test must be the one invoked — it passes. Recorded
because the failure looked like a code defect and was not.

Coverage, each mutation-proven red before being cited

Mutation Result
capability returns a constant, never asking the credential store RED — 4 of 5 rows
capability ignores hasEncrypted (probes on every deploy) RED — the short-circuit row
settings validator accepts config again RED
resolveSecretBackend stops normalizing RED

TestResolveEncUnattendedUnlock counts credential-store calls, not just the return value — the
wiring assertion, because a capability that never asks would still return the right answer for two
rows by accident. That is the failure mode this PR's predecessor had.

Other gates

  • gofmt clean; charly core and sdk build and test green.
  • All 86 candy modules build under GOWORK=off — the sweep that has been vacuous before,
    because ./charly/... never compiles the candies.
  • golangci-lint — 0 issues on charly, sdk, and each changed candy.
  • R5 sweep run per submodule (git grep does not cross boundaries) over ., spec, sdk,
    plugins, docs, box/*: KeyringBackend, secretBackendIsKeyring, usesWaitingBackend and
    the secret_backend config prescriptions → zero hits outside CHANGELOG/.

Tests that pinned the removed backend

Several used secret_backend: config purely to force the config-file store deterministically. They
now reach it the way a headless host does — an auto probe against an unreachable session bus —
which is better isolation than the pin was. charly/credential_await_unlock_external_test.go does
the same, and its plugin subprocess inherits the arrangement.

Reported, not edited

Stale prose naming the removed backend survives in plugins/automation/skills/enc/SKILL.md,
plugins/build/skills/settings/SKILL.md, and two docs/ recipes — repositories a concurrent
teammate owns and this change is scoped out of. spec/hostenv/runtime_config.go's field comment
still lists "config"; fixing it means moving a gitlink that 87 go.mod files pin. Both need
a follow-up.

Branch note

fix/readme-straight also carries these two commits, but underneath eight unrelated docs commits.
This branch is the clean extraction off main so the cutover lands on its own, per the
one-cutover-per-PR rule. Every path touched here is byte-identical between the two.

Authored with Claude Code (Anthropic Claude Opus 5), fully tested and validated.

atrawog added 2 commits August 5, 2026 01:33
… autostart as a capability

The consumer half of the sdk change of the same name. Encryption passphrases come
from the environment, the system keyring via Secret Service, or a forwarded GPG
agent. Quadlet autostart is served by Secret Service alone -- not because any
emitter checks for it by name, but because it is the backend that can unlock with
no human running a command. The supported set is now an outcome of that property
rather than a list the code carries.

CHANGED:

  plugin-deploy-pod  computes the capability (resolveEncUnattendedUnlock) and
                     threads it into BOTH QuadletConfig sites, replacing
                     secretBackendIsKeyring(). Asked only when the deploy HAS
                     encrypted volumes -- otherwise it is a pointless credential
                     round trip, and on a locked keyring a needless probe
  plugin-settings    secret_backend accepts only auto and keyring; config is
                     rejected with a message naming what to use instead
  plugin-secrets     resolveSecretBackend normalizes through
                     kit.NormalizeSecretBackend; the now-unreachable config store
                     selection deleted; five remediation hints stopped
                     prescribing the removed value
  plugin-doctor      two InstallHints stopped prescribing it, and the
                     now-unreachable "config file (explicit)" OK branch deleted
  plugin-pod         pluginResolveSecretBackend normalizes through the SAME
                     helper, so the backend it reports and the backend that
                     selects the store cannot diverge (R3 -- the two were a
                     verbatim duplicate pair)

MIGRATION -- NOT via charly migrate. The brief specified charly migrate; the code
refutes it. secret_backend lives in the RUNTIME config ~/.config/charly/config.yml,
while charly migrate processes the project charly.yml and the per-host deploy
overlay ~/.config/charly/charly.yml -- a different file it never opens
(candy/plugin-migrate/command.go:54 -> spec/spec/deployconfig.go:23). The
migration belongs where the value is READ, which is also the only place that
catches the CHARLY_SECRET_BACKEND override no validator sees. Both readers coerce
to auto, once, with a notice. Nothing becomes unreachable -- auto still falls back
to the config file with no keyring present -- so an already-configured host keeps
resolving the credentials it has; it loses only the ability to PIN the plaintext
store.

BEHAVIOUR CHANGE, MEASURED: on such a host with no passphrase stored, charly
config mount used to fail immediately via the removed backend's fail-fast path. It
now classifies as unavailable and polls to EncMountDeadline -- 120.09s measured --
then fails with the same actionable error. Bounded, and already what the default
auto setting does on any keyring-less host; the pin was the only opt-out.

COVERAGE: TestResolveEncUnattendedUnlock asserts both arms plus the short-circuit
AND counts credential-store calls -- the wiring assertion, because a capability
that never asks would still return the right answer for two rows by accident.
TestSetConfigValue_SecretBackend asserts the rejection and that the message names
both supported values. TestResolveSecretBackendRemovedConfigCoercesToAuto and its
env-override sibling are the migration gates. Each mutation-proven red before
being cited: a capability returning a constant (4 rows fail), one ignoring
hasEncrypted (short-circuit row fails), a validator accepting config again, and a
resolveSecretBackend that stops normalizing.

TESTS THAT PINNED THE REMOVED BACKEND now reach the config store the way a
headless host does -- an auto probe against an unreachable session bus -- which is
better isolation than the pin was. That includes
charly/credential_await_unlock_external_test.go, whose plugin subprocess inherits
the arrangement. TestPluginEncMount_NoShortCircuit_WhenOneUnmounted is where the
regression above first surfaced (instant -> 120.09s); it now shrinks
EncMountDeadline rather than skipping the wait, so the retry path is still run.

GATES: gofmt clean; charly core + sdk build and test green; all 86 candy modules
build under GOWORK=off -- the sweep that has been vacuous before, because
./charly/... never compiles the candies; every changed candy tested individually;
golangci-lint 0 issues on charly, sdk and each changed candy.

R5 SELF-TEST, per submodule because git grep does not cross boundaries:
KeyringBackend, secretBackendIsKeyring, usesWaitingBackend and the
secret_backend-config prescriptions return ZERO hits outside CHANGELOG/ in the
superproject, spec, sdk and box/*.

NOT DONE HERE, reported not edited: stale prose in two plugins/ skills and two
docs/ recipes (another teammate owns those repos concurrently), and
spec/hostenv/runtime_config.go's field comment still listing "config" -- fixing it
means moving a gitlink that 87 go.mod files pin.

Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)
…n upward

The preceding commit shipped with "analysed on a live system", which was the
honest tier at the time: unit and mutation proofs only, with no bed run. The full
R10 sequence has since passed on BOTH disposable beds that exercise an
encrypted-volume quadlet, so the evidence now supports the higher tier and the
trailer should say so rather than under-claim.

  charly check run check-enc-pod:      PASS (steps=13)
  charly check run check-enc-port-pod: PASS (steps=13)

Each is the complete sequence -- build, check image, deploy, config, start, check
live, a FRESH `charly update` destroy+rebuild, check live again, teardown -- on
the CalVer binary built from this tree (charly version = 2026.216.2333, R9). Both
encrypted-volume assertions pass before AND after the rebuild, 30 passed / 0
failed / 3 skipped each time.

The quadlet emitted live for an encrypted deploy whose passphrase IS in the
credential store is the unattended-capable arm, exactly as the capability
predicts: TimeoutStartSec=0 and [Install] WantedBy=default.target.

R1 on the first attempt, which FAILED at the bed's host-side enc-status-mounted
step: the cause was not this change. That step resolves `charly` from PATH and
found the packaged /usr/bin/charly, whose own freshness guard correctly refused to
run against newer sources. Re-run with this worktree's bin/ on PATH -- R9's rule
that the binary under test must be the one invoked -- it passes. Recorded because
the failure looked like a code defect and was not.

Assisted-by: Claude Code Anthropic Claude Opus 5 (fully tested and validated)
@atrawog
atrawog marked this pull request as draft August 5, 2026 00:10
@atrawog

atrawog commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Do not validate — cancelled scope. The operator has ruled that secret_backend: config STAYS supported. The config-removal content in this PR is cancelled; the branch also carries a revert that must not land while sdk stays at origin/main. Converted to draft pending a decision to close.

@atrawog

atrawog commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the premise is disproven, so there is nothing here to rework.

This PR removed secret_backend: config. The operator has since ruled that config stays supported, with a warning whenever a passphrase is stored in cleartext — so the removal is cancelled outright.

The companion capability refactor (KeyringBackend → UnattendedUnlock) does not survive on its own merits either, and the argument against it came from this branch's own author: run across every backend value, its entire practical effect on a supported configuration is one row — it would grant autostart to a pinned-config deploy whose passphrase sits in cleartext. That is precisely the configuration the ruling asks to flag. origin/main is right.

With both cancelled, this branch is empty against origin/main. Per /charly-internals:git-workflow, a disproven premise is the stated exception to update, never close-and-recreate.

What survives as findings, none of it wasted — several of these are why the ruling landed where it did:

  • charly migrate was the wrong location for backend migration; secret_backend lives in the runtime config, which migrate never opens.
  • secret_backend: config was not vestigial — it is the only way a host declares no keyring here, fail fast. Removing it costs a measured 120.09s of polling.
  • secretBackendIsKeyring() and usesWaitingBackend are the same set duplicated across the sdk/candy boundary — a real R3 finding for a later batch.
  • usesWaitingBackend is not identical to an autostart-capability gate. It answers will the resolver wait?; they diverge on exactly config, where the key is obtainable but there is nothing to wait for. The landed code is right by near-miss, not by identity — recorded so nobody re-derives this change.
  • A latent bug on main: keyring-less host, default auto, no passphrase stored ⇒ unit enabled at boot, sits in start-pre to the deadline, fails every boot. Filed.

The branch content is reverted on the superproject side and proven on a live check-enc-pod run. Cleartext-storage warning starts fresh off origin/main.

@atrawog atrawog closed this Aug 5, 2026
@atrawog

atrawog commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Closed — recording the outcome.

Disproven premise: secret_backend: config stays supported, so the removal cannot land, and the paired sdk#121 is closed for the same reason.

Both cancelled commits are reverted on fix/readme-straight (e7af44a2) — 43abbaff (this PR's content) and cbf58115. Reverting only the first would have left the second's damage in place: it removed KeyringBackend: isKeyring from both QuadletConfig literals, so with sdk back at origin/main — where the field still gates WantedBy — they would have sat at zero value false and every encrypted deploy would have silently lost WantedBy=default.target, compiling clean.

Verified rather than asserted:

  • git diff origin/main over every affected path: 0 bytes
  • git grep -c 'KeyringBackend: isKeyring' -- candy: both files, one each
  • charly check run check-enc-pod: PASS (steps=13) on the reverted tree, including the fresh charly update rebuild
  • the emitted quadlet, captured directly because the bed's explicit charly start would not have caught a missing [Install]: TimeoutStartSec=0 and [Install] WantedBy=default.target both present

github-actions Bot pushed a commit that referenced this pull request Nov 19, 2026
…er-drop heads (#1219)

`./bin/charly task sync` — this repo's own pin verb, which advances EVERY pin
this repo declares — moved the two `box/*` gitlinks that were behind the ref
their own `.gitmodules` entries name:

    box/cachyos  7f0c6c15fe5d -> ba2c187a1626   (distro-cachyos main: #209's CDI VM-driver drop,
                                                #199, #211 and #212's pod-comfyui offload pins)
    box/fedora   01887aee5c9a -> e9696d3e85f8   (distro-fedora main: #129 and #131, the same
                                                VM-driver drop on the Fedora side)

The other three (`box/arch`, `box/debian`, `box/ubuntu`) were already at the
tips their `.gitmodules` declare. Both advances are fast-forwards onto merged
heads (`git -C box/cachyos merge-base --is-ancestor 7f0c6c15fe5d ba2c187a1626`
-> rc=0, and the same for fedora), so there is nothing to reconcile.

Control after the wave:

    currency: 0 of 5 pin(s) NOT current [5 cur]

What the `box/*` gitlinks actually govern here, measured rather than assumed
(#1218): the `cachyos` namespace is composed by the @github
TAG pin (`charly.yml:30`), so `charly box list boxes` exposes the tag's box
names and not one `-cdi` box — the distro beds are NOT what this moves. The
gitlink is what this repo's OWN gate reads: `charly/cue_kinds_corpus_test.go`
(the `../box/*/box/*/charly.yml` corpus), `charly/refs_sweep_test.go` and
`charly/build_test.go` (`LoadBuildConfigForBox` over this repo's production
box/cachyos distro config). That is where the corpus was run, and it passes on
the moved trees.

This is the hop that lets the umbrella's `charly:box/cachyos` and
`charly:box/fedora` edges become current — until it lands, both report
`blocked-by charly:box/...` (behind).

Agent: `edge-1182` · DeepSeek Harness session `a8d6ae4d-d0e0-4b37-8e6c-58081b9e6040`
Assisted-by: DeepSeek Harness ollama-cloud deepseek-v4.1-flash (fully tested and validated)
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