Repository navigation
fix(deploykit): ONE rule for a candy secret's coordinate — EnsureCandySecret stops re-implementing it - #544
Conversation
…ySecret stops re-implementing it The package carried the coordinate rule TWICE: the exported `SecretKeyForDep` and an inline copy inside `EnsureCandySecret`, with a subtle difference between them (`idx >= 0` vs `idx > 0` on the override split). That duplication is exactly the seam #526 and opencharly/pod-openwebui#19 live in: a secret's coordinate is computed in more than one place, and the copies drift. `EnsureCandySecret` now calls `SecretKeyForDep`, so the rule has one implementation and the resolver and the rule cannot disagree. Behaviour is unchanged for every valid declaration (the build-time `validateSecretDeps` contract is `^charly/<service>/<key>$`, where the two predicates coincide). Tests pin the rule (no override, single-slash, multi-slash LAST-slash split, deeper service) AND the property that made the duplication dangerous: the coordinate the resolver QUERIES equals the coordinate the rule NAMES — mutation-verified by re-inlining the split, which the test catches with the exact mismatch. The third copy lives in opencharly/plugin-deploy-pod (`secretKeyForDep`); it follows producer-first once this tag exists. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS — no scope mismatch, no secrets/egress, no guardrail weakening, no supply-chain change, no self-modifying-security surface. Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…#66) opencharly/sdk#544 made `SecretKeyForDep` the ONE rule for a candy-declared secret's coordinate (explicit `key:` wins, everything before the LAST "/" is the service, otherwise the historical default). This repo carried the third copy of that rule — `secretKeyForDep` in `secret_migration.go`, with the same LAST-slash split and the same default. The copy is gone (R5): the three call sites now call `deploykit.SecretKeyForDep`, and the pin advances to the tag that exports it (`github.com/opencharly/sdk v0.2026309.1926 → v0.2026320.617`). Behaviour is identical — the two implementations agreed on every declaration the build-time validator accepts — so what changes is that a future coordinate change (opencharly/ pod-openwebui#19's per-deploy decision) has ONE place to move, not three. The doc comments that referenced `secretKeyForDep` by name now name the shared rule. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Summary
Head
bb43b43e7244bcb9e90046d00b10281d83fb280f, based onorigin/main9d43f04(0 behind, 1 ahead):2 files changed, 111 insertions(+), 8 deletions(-)—deploykit/secret_candy_resolve.goand one new test file.The package carried the coordinate rule twice.
SecretKeyForDepwas the exported rule, andEnsureCandySecretcarried an inline copy of the same predicate — with a subtle difference:idx >= 0in therule,
idx > 0in the copy. That duplication is the seam #526 andopencharly/pod-openwebui#19 both live in: a secret's coordinate is computed in more than one place, and the
copies drift apart — which is how a value gets written somewhere the resolver never reads.
Behaviour is unchanged for every valid declaration: the build-time contract (
validateSecretDeps) is^charly/<service>/<key>$, where the two predicates coincide, and a leading slash cannot appear. What changedis that there is now exactly ONE implementation, and the resolver and the rule cannot disagree.
How tested
The rule, as a table (
secret_coordinate_dep_test.go) — no override, single-slash, multi-slash with theLAST-slash split, and a deeper service:
The property the duplication endangered, mutation-verified. Re-inlining the split (drifting one side) makes
the agreement test fail with the exact mismatch, and the mutation is reverted before the final run:
The module's gates (this repo's
AGENTS.md):test -z "$(gofmt -l .)"clean,go vet ./...rc=0,go test -count=1 ./...all packages ok.Not run:
golangci-lintv2.13.2 is not installed here (CI's arm runs it on this PR), and no bed — everyconsumer still pins the previous SDK tag, so a consumer bed would exercise the OLD code and could only prove no
regression; the changed behaviour is the rule's own, proven above by unit + mutation.
Rulebook compliance
/charly-internals:pluginand/charly-internals:install-plan(this repo'sAGENTS.mdnames them) before editing; the change stays kind-blind inside
deploykit.one of the three copies and cites the third (
opencharly/plugin-deploy-pod'ssecretKeyForDep) asproducer-first follow-up rather than pretending the cutover is complete.
agreement rather than the wording.
in one place.
git status --shortwas empty before the branch; freshorigin/mainin a session worktree; themutation experiment was on my own tree and reverted; no force-push, no direct push, no bypass.
directly (the resolver queries the coordinate the rule names).
go build/go teston the worktree module.Change classification
Mechanism-library refactor (behaviour-preserving) + regression coverage. One function body and one test
file. No wire type, no schema, no plugin code, no new dependency. Gate:
gofmt/go vet/go test ./...on thistree, mutation-verified.
Breaking change + rollback: none — behaviour is identical for every declaration the build-time validator
accepts (the two predicates differ only for a leading-slash key, which
validateSecretDepsrejects at loadtime and which no declaration in the org carries). Rollback is a revert of the squash, which restores the
duplicate.
Filed issues
(its write-side half is fixed in sdk#543, and this removes the last sdk-side drift).
the default, only how many places compute it. The third copy (
opencharly/plugin-deploy-pod'ssecretKeyForDep) is the producer-first follow-up after this tag.A3 — attribution evidence
The runtime's own system message reads, verbatim:
Harness
DeepSeek Harness, modeldeepseek-v4.1-flash— the pair the footer names. Tierfully tested and validated: the module's gates ran on the committed tree, the coverage is mutation-proven,and the changed function's own property is asserted live by its tests.
Agent: charly
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)