Skip to content

fix(deploykit): ONE rule for a candy secret's coordinate — EnsureCandySecret stops re-implementing it - #544

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/one-coordinate-rule
Nov 16, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/one-coordinate-rule

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

Head bb43b43e7244bcb9e90046d00b10281d83fb280f, based on origin/main 9d43f04 (0 behind, 1 ahead):
2 files changed, 111 insertions(+), 8 deletions(-) — deploykit/secret_candy_resolve.go and one new test file.

The package carried the coordinate rule twice. SecretKeyForDep was the exported rule, and
EnsureCandySecret carried an inline copy of the same predicate — with a subtle difference: idx >= 0 in the
rule, idx > 0 in the copy. That duplication is the seam #526 and
opencharly/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.

-	service, key := "charly/secret", dep.Name
-	if dep.Key != "" {
-		if idx := strings.LastIndex(dep.Key, "/"); idx > 0 {
-			service = dep.Key[:idx]
-			key = dep.Key[idx+1:]
-		}
-	}
+	service, key := SecretKeyForDep(dep)

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 changed
is 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 the
LAST-slash split, and a deeper service:

$ go test -count=1 -run 'TestSecretKeyForDep|TestEnsureCandySecret' -v ./deploykit/
--- PASS: TestSecretKeyForDep_OneRule                                  (4 sub-cases)
--- PASS: TestEnsureCandySecret_QueriesTheSameCoordinate
--- PASS: TestEnsureCandySecret_EnvVarOverrideKeepsTheCoordinate
--- PASS: TestEnsureCandySecret_PresentInStore
--- PASS: TestEnsureCandySecret_RequiredMissingAutoGenerates
--- PASS: TestEnsureCandySecret_IdempotentAcrossCalls
--- PASS: TestEnsureCandySecret_OptionalMissingReturnsEmpty
--- PASS: TestEnsureCandySecret_CustomKeyRoutesToOverride

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:

$ # EnsureCandySecret back to `service, key := "charly/secret", dep.Name`
--- FAIL: TestEnsureCandySecret_QueriesTheSameCoordinate
    secret_coordinate_dep_test.go:77: EnsureCandySecret(OPENROUTER_API_KEY) queried
        ("charly/secret", "OPENROUTER_API_KEY"), but the rule names ("charly", "api-key")
    secret_coordinate_dep_test.go:77: EnsureCandySecret(QDRANT__SERVICE__API_KEY) queried
        ("charly/secret", "QDRANT__SERVICE__API_KEY"), but the rule names ("charly/api-key", "qdrant")

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-lint v2.13.2 is not installed here (CI's arm runs it on this PR), and no bed — every
consumer 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

  • R0 — loaded /charly-internals:plugin and /charly-internals:install-plan (this repo's AGENTS.md
    names them) before editing; the change stays kind-blind inside deploykit.
  • R1 — the finding is the duplication the goal already names (sdk#526 / pod-openwebui#19); this PR removes
    one of the three copies and cites the third (opencharly/plugin-deploy-pod's secretKeyForDep) as
    producer-first follow-up rather than pretending the cutover is complete.
  • R2 — this IS the R2 change: two implementations of one rule become one, and the test asserts the
    agreement rather than the wording.
  • R3 — no workaround: the copy is deleted, not shadowed.
  • R4 — no docs are bent; the prose in the org already describes the coordinate and the code now matches it
    in one place.
  • R5 — the deleted copy is gone from this package; the third lives in another repo and is named.
  • R6 — git status --short was empty before the branch; fresh origin/main in a session worktree; the
    mutation experiment was on my own tree and reverted; no force-push, no direct push, no bypass.
  • R7 — the coverage fails without the change (mutation pasted) and the changed path's property is asserted
    directly (the resolver queries the coordinate the rule names).
  • R8 — no live service boundary.
  • R9 — no charly binary involved; go build/go test on the worktree module.
  • R10 — the change class is below, with what a mechanism-library change can prove here.

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 this
tree, 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 validateSecretDeps rejects at load
time and which no declaration in the org carries). Rollback is a revert of the squash, which restores the
duplicate.

Filed issues

A3 — attribution evidence

The runtime's own system message reads, verbatim:

You are a coding agent powered by the deepseek-v4.1-flash model.

Harness DeepSeek Harness, model deepseek-v4.1-flash — the pair the footer names. Tier
fully 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)

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

Copy link
Copy Markdown

Review — PASS

Head SHA: bb43b43e7244bcb9e90046d00b10281d83fb280f (branch: fix/one-coordinate-rule)

Security screen: PASS — no scope mismatch, no secrets/egress, no guardrail weakening, no supply-chain change, no self-modifying-security surface.
Checklist: All applicable rules PASS or NA. Diff↔body consistent: strings import removal matches the deleted inline copy; the pasted mutation failure at secret_coordinate_dep_test.go:77 matches the actual t.Errorf line and the two override deps (the no-override case correctly stays green); the 4 sub-cases and test names reconcile with the new file plus the pre-existing EnsureCandySecret tests. Bed is correctly omitted (a consumer bed would exercise the old pinned tag — the R10 "bed that never exercises the touched path" principle); changed path is executed live by unit + mutation. Attribution footer present and consistent with the quoted model. ## Filed issues present; the third cross-repo copy is tracked under the umbrella sdk#526. No comments to disposition.
Placement: CORRECT — consolidation stays inside deploykit (sdk mechanism kit); no new core coupling, no alias file, no capability pulled into core.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 16, 2026 06:16
@github-actions
github-actions Bot merged commit 0428173 into main Nov 16, 2026
8 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 16, 2026
github-actions Bot pushed a commit to opencharly/plugin-deploy-pod that referenced this pull request Nov 16, 2026
…#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)
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