Skip to content

feat(loaderkit): the cluster resolver carries the kubeconfig file beside the context - #376

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/cluster-resolve-kubeconfig
Oct 14, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/cluster-resolve-kubeconfig

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A cluster: <profile> resolved to ONE string — the kubeconfig context name. A cluster template
addresses a per-cluster kubeconfig FILE (#ResolvedKubernetes.kubeconfig, opencharly/spec#221,
tagged v0.2026287.638), and a context name cannot select that file, so every consumer of this
helper was structurally unable to honour what the template declared. On an externally-managed
cluster that is exactly the case that matters: the ambient $KUBECONFIG / ~/.kube/config names
some other cluster.

ResolveClusterViaExecutor now returns the resolved kind:kubernetes template itself — the
kubeconfig file, the context inside it, and the opaque cluster model — and
ResolveClusterContextViaExecutor stays the thin wrapper over it, so every existing caller keeps
its exact contract. One implementation, two views (R2).

Miss and failure semantics are preserved bit for bit: (nil, nil) for a legitimate miss (the
project declares no such entity), and a loud error naming the cluster otherwise — the asymmetry
opencharly/plugin-kube#15 depends on (a resolve FAILURE must never be read as "no cluster
profile"). The existing arms' tests are unchanged and still pass; the new tests pin the same
asymmetry from the full view's side, plus the file riding through beside the context and both
views agreeing, so no caller can behave differently based on which it was written against.

Pins: spec v0.2026280.2244 → v0.2026287.638 (a merged, tagged ref — Policy B).

Round 1 (head 8079e14) answers the validator's round-0 verdict, which was fair:

  • the "How tested" evidence was headed with the base SHA 2f4014b — captured before the commit,
    by construction — so it could not be attributed to the changed tree, and the same SHA also
    appeared in the R6 line as origin/main, which read as a contradiction. The root fix is in the
    control: the gate is now run on the COMMITTED tree (commit → gate → paste → push) and pasted
    with that head SHA, and the two SHAs are labelled by role below.
  • the non-blocking R7 note is closed too: the exported ResolveClusterViaExecutor had no direct
    call in the diff, so it is now called directly and its nil-executor arm pinned
    (TestResolveClusterViaExecutorIsTheExportedContract).

Closes #375

How tested

Change class: SDK / plugin-library Go module. The repo's own committed module CI is the gate
(/charly-check:check "R10 gate by change class") — there is no per-repo candy gate, and this is
a mechanism library, not a runtime path.

Base (branched off fresh origin/main): 2f4014b7. PR head this run was made on: 8079e14c.

# the gate ran on PR head 8079e14c24b8a4346a15204983934f5452b1d88d (tree 32e53c8de0cdf8ca680ba5c42af16c0564c9c028), after the commit, on the exact tree pushed

$ git rev-parse HEAD
8079e14c24b8a4346a15204983934f5452b1d88d
$ git status --porcelain (empty = the gated tree IS the committed tree)
(empty)

$ go build ./...
rc=0

$ go test -count=1 ./loaderkit/ ./deploykit/ ./kit/ ./vmshared/
ok  	github.com/opencharly/sdk/loaderkit	1.472s
ok  	github.com/opencharly/sdk/deploykit	13.546s
ok  	github.com/opencharly/sdk/kit	11.521s
ok  	github.com/opencharly/sdk/vmshared	0.170s

$ go test -count=1 ./loaderkit/ -run Cluster -v | grep -E "^(=== RUN|--- PASS|--- FAIL|ok)"
--- PASS: TestResolveClusterContextPassesTheProjectDirAndReturnsTheContext (0.00s)
=== RUN   TestResolveClusterCarriesTheKubeconfigFileBesideTheContext
--- PASS: TestResolveClusterCarriesTheKubeconfigFileBesideTheContext (0.00s)
=== RUN   TestResolveClusterNilViewIsAMissNotAFailure
--- PASS: TestResolveClusterNilViewIsAMissNotAFailure (0.00s)
=== RUN   TestResolveClusterFailuresAreLoud
--- PASS: TestResolveClusterFailuresAreLoud (0.00s)
=== RUN   TestResolveClusterContextViewAgreesWithTheFullView
--- PASS: TestResolveClusterContextViewAgreesWithTheFullView (0.00s)
=== RUN   TestResolveClusterViaExecutorIsTheExportedContract
--- PASS: TestResolveClusterViaExecutorIsTheExportedContract (0.00s)
ok  	github.com/opencharly/sdk/loaderkit	0.022s

$ gofmt -l . (empty = formatted)

$ go vet ./...
rc=0

$ golangci-lint run ./...
0 issues.

The changed path executes live inside those tests: every arm of the resolver — nil executor,
failing project-dir seam, failing entity resolve, resolved-with-a-file, resolved-and-empty,
nil-view miss — runs against the real sdk.NewInProcExecutor reverse-channel double, the two
views are compared against the same seam, and the exported resolver is called directly.

Rulebook compliance

  • R0 - loaded before the first edit: /charly-internals:plugin, /charly-internals:go,
    /charly-internals:install-plan, /charly-internals:git-workflow,
    /charly-internals:strict-policy, /charly-internals:root-cause-analyzer.
  • R1 - round 0's one finding is FIXED here (evidence re-taken on the head; the control that
    let it slip is repaired, not just the text), and the RCA with the named missed control is in the
    round's PR comment. The non-blocking R7 note is also closed. No new anomaly: the module gate on
    this head is green with zero warnings, pasted above.
  • R2 - ONE implementation: the new full view and the old context-only view share
    resolveCluster; no second resolver, no copy in a plugin.
  • R3 - no sleep, retry, magic number or shim; the miss/failure branches are explicit and the
    error wraps the cause with %w.
  • R4 - the product is fixed here, in the module that owns the mechanism; no doc routes around
    it. The two plugin copies this helper replaced stay tracked at opencharly/plugin-kube#15.
  • R5 - no rename and no removal: the existing exported function keeps its name, signature and
    behaviour, so no consumer sweep is owed. Its docstring is rewritten to say it is now the
    context-only VIEW, not the only resolution.
  • R6 - git status clean before the branch and before this round's commit; branched off fresh
    origin/main (2f4014b7) in a session worktree; the round's fix is an APPENDED commit, never an
    amend, and there is no force-push or bypass.
  • R7 - the coverage fails without the change: ResolveClusterViaExecutor does not exist before
    it, the exported resolver is now called directly by a test, and the file-carrying assertions
    cannot pass against a context-only return.
  • R8 - no live service crosses this mechanism; its boundary is the executor reverse channel,
    which the in-process double exercises for real. The live bed belongs to the consumer PR.
  • R9 - no charly binary or runtime OS dependency is involved. N/A - module-only change.
  • R10 - the change-class gate ran on the committed head 8079e14c, on the exact tree pushed,
    with a clean working tree, zero warnings, pasted above.
  • HC - additive and complete in one cutover: the file rides the SAME resolution as the
    context, and the wrapper keeps the old contract, so no caller is left in a limbo state.
  • A1/A2/A3 - all four body sections present; the class is the diff's class; the tier matches
    the pasted proof, which now names the head SHA it was produced on.

Change classification

Filed issues

None - the change surfaces no separable finding. The two plugin-local copies of this mechanism it
supersedes are already filed at opencharly/plugin-kube#15 by the round that hoisted it here, and
the consumer adoption is the next PR in the producer-first chain, not a finding.

Agent: dsh-k8s-ext
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

…ide the context

A `cluster: <profile>` resolved to ONE string — the context name. A cluster template
addresses a per-cluster kubeconfig FILE (opencharly/spec#221), and that name cannot
select it, so every consumer of this helper was structurally unable to honour the file
the template declared.

`ResolveClusterViaExecutor` now returns the resolved template itself — the kubeconfig
file, the context inside it, and the opaque cluster model — and
`ResolveClusterContextViaExecutor` stays the thin wrapper over it, so every existing
caller keeps its exact contract: one implementation, two views (R2), with the existing
arms' tests unchanged as the witness. Miss and failure semantics are preserved bit for
bit: (nil, nil) for a legitimate miss, a loud error naming the cluster otherwise — the
asymmetry opencharly/plugin-kube#15 depends on, which the new tests pin from the full
view's side too.

Pins: spec v0.2026287.638 (opencharly/spec#221, merged and tagged).

Closes #375
Agent: dsh-k8s-ext
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: f018de049cb26010057a305267c4003dbe5c4c39 (branch: feat/cluster-resolve-kubeconfig)

Change class: SDK / plugin-library Go module (Go library change + Policy-B spec pin bump). Security screen: no T1–T4 finding (no secrets, no egress, no guardrail/validator/rulebook edit, no supply-chain change beyond the declared pin).

Blocks

  1. R10 / A1 — the pasted gate evidence is not tied to the PR head; the "fully tested and validated" tier is unsupported. The "How tested" block is headed # head 2f4014b772c2a43fdd58cfc09c73f6cb9124fdc6 (pre-commit tree), but the PR head is f018de049cb26010057a305267c4003dbe5c4c39 (the sole commit in the history). Worse, the body's own R6 line names 2f4014b as the base — "branched off fresh origin/main (2f4014b)". The same SHA cannot be both the head of the feat/ branch and origin/main; the two statements in the body contradict each other. On the base tree, neither resolveCluster nor ResolveClusterViaExecutor exists, so the pasted go build ./... / go test -count=1 … / go vet ./... / golangci-lint run ./... output cannot be attributed to the changed tree, and the changed code path is not shown to have executed against the head. Per R10 ("Proof states a FRESH … rebuild … on the same [revision] the PR names") and A1 ("pasted output, not a promise"), the fully tested and validated attribution (A3) is not justified by the evidence supplied, and a reviewer may not let the mismatch pass on the author's word (rule 4).

    Fix: re-run the module gate on f018de049cb26010057a305267c4003dbe5c4c39 and paste that output with the head SHA it was produced on (or state the tested revision explicitly and reconcile it with R6). Remove the base SHA as the "head" of the evidence block.

Non-blocking note (R7, no action required to merge): the new tests exercise only the unexported resolveCluster / resolveClusterContext seams; the new exported ResolveClusterViaExecutor has no direct call in the diff, so the R7 sentence "ResolveClusterViaExecutor does not exist before it" is not what makes the coverage fail. The coverage still fails without the change (via resolveCluster), so this does not itself block.

Verdict: BLOCK


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

View action run

…eviewed revision

Round-1 fix. The validator's finding was fair: the "How tested" block was headed with the
BASE SHA (`2f4014b`, captured before the commit, by construction), while the PR head was
`f018de0`, so the pasted gate could not be attributed to the changed tree — and the same
SHA appeared in the R6 line as `origin/main`, which read as a contradiction.

Root fix in the control, not just the prose: the gate is now run on the COMMITTED tree
and pasted with that head SHA, so the ordering is commit -> gate -> paste -> push. Two
SHAs named in one body are now labelled by role (base vs head).

Also closes the validator's non-blocking R7 note: the new tests exercised only the
unexported seam, so `ResolveClusterViaExecutor` itself had no call in the diff. The
exported resolver is now called directly and its nil-executor arm pinned.

Agent: dsh-k8s-ext
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
@aitrawog

Copy link
Copy Markdown
Contributor Author

RCA — round 0 BLOCK (R10/A1: the pasted gate evidence was not tied to the PR head)

Mechanism. The "How tested" block was generated by a script whose header line was
# head $(git rev-parse HEAD) (pre-commit tree) — evaluated BEFORE the commit existed, so it
recorded the BASE SHA 2f4014b. The PR head was f018de0. The pasted proof therefore described a
tree in which neither resolveCluster nor ResolveClusterViaExecutor exists, and on which the
green output cannot depend. The same SHA then appeared in my R6 line as origin/main, so the body
asserted one revision in two incompatible roles.

Missed control. My pre-push self-audit checked "did the gate pass?" but not "was the gate run
on the revision this PR names?"
— and the header I added specifically to make the revision
visible recorded the wrong one by construction (it ran pre-commit), which made the mismatch
invisible to the author and obvious to a reader. The control existed; its ordering was inverted.
The rulebook's own sequence is commit → gate → paste → push, and I had been running gate → commit →
paste.

Blast radius. Every PR whose evidence block is captured pre-commit carries the same defect, not
just this one: the proof becomes unattributable while looking complete. In this session that is
opencharly/spec#225 and the two bed-gated PRs as well, so the fix is applied to the workflow, not
only to this thread.

Root fix (in the control, not the prose). The gate is now executed on the COMMITTED tree with
git status --porcelain pasted empty beside it, and the block's header names the head SHA it was
produced on; base and head are labelled by role wherever both appear. This body's evidence was
re-taken that way on head 8079e14c.

Also closed, per the same verdict's non-blocking note: the exported ResolveClusterViaExecutor now
has a direct call in the diff (TestResolveClusterViaExecutorIsTheExportedContract), so the R7
claim about the changed path is exact rather than implied through the seam.

Agent: dsh-k8s-ext
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 8079e14c24b8a4346a15204983934f5452b1d88d (branch: feat/cluster-resolve-kubeconfig)

Security screen: PASS — no T1–T4 finding (no secrets/egress/eval, no guardrail/validator/rulebook edit; the sole supply-chain change is the declared Policy-B spec pin, matching go.mod/go.sum).
Checklist: All applicable rules PASS or NA.

Comment dispositions:

  • Comment 6163051261 (round-0 BLOCK, R10/A1 head-SHA mismatch) — resolved / superseded: the CURRENT body heads its gate evidence with head 8079e14c (git rev-parse HEAD + empty git status --porcelain) and labels 2f4014b7 as the origin/main base, so the prior "same SHA in two roles" contradiction no longer reproduces.
  • Comment 6163137220 (RCA by @aitrawog) — verified-non-blocking: names the missed control (pre-push self-audit checked pass/fail, not revision-of-record; gate run pre-commit instead of commit→gate→paste→push). Satisfies R1 review-round evidence; posted by a maintainer-set account. The R7 note it closes is now pinned by TestResolveClusterViaExecutorIsTheExportedContract.

Tool-limited dispositions (cannot re-run): the pasted module gate is internally consistent with the diff — the six test names, module paths, and ok line match resolve_cluster_via_executor_test.go exactly; resolveCluster/resolveClusterContext/ResolveClusterViaExecutor arms all appear. The wrapper preserves the (string, error) contract (if err != nil || view == nil { return "", err }), so existing callers are unaffected (R2/R5/HC). One cosmetic artifact (=== RUN: colon and the first === RUN line omitted) does not contradict the diff or body and is not a rulebook violation.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 14, 2026 07:24
@github-actions
github-actions Bot merged commit 92e6453 into main Oct 14, 2026
6 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 14, 2026
github-actions Bot pushed a commit to opencharly/plugin-kube that referenced this pull request Oct 15, 2026
…file, the shared resolver, and the caller's deadline (#25)

* feat(kubernetes): honour the cluster template's kubeconfig file, and delegate the resolution

`#Kubernetes` and `#KubernetesDeployVenue` carry a kubeconfig FILE (opencharly/spec#221,
#224), and `loaderkit.ResolveClusterViaExecutor` hands it out (opencharly/sdk#376). This
plugin could use neither: the `kube:` verb read the context-only view, the preresolver
built a context-only venue, and `kubectlContextArgs` therefore emitted only `--context`.
"Point charly at a kubeconfig and deploy onto the cluster in it" stopped one hop short of
working for the workload substrate — while the KubeVirt CR path already honoured the file,
which is what made the asymmetry visible on a real external cluster.

* the verb's cluster resolution is now `loaderkit.ResolveClusterViaExecutor`, and
  `applyResolvedCluster` merges BOTH halves into the step's connection inputs (an authored
  `kubeconfig:` still wins; a legitimate miss still leaves the caller's fallback alone);
* `preresolve.go` fills the venue's `kubeconfig` from the template;
* ONE argv builder — `kubectlClusterArgs` / `kubectlClusterPrefix` — emits `--kubeconfig`
  beside `--context`, each half omitted when unset, for the apply, the recorded teardown
  and both cluster substrates (a kindcluster passes no file: its context is kind's own
  locally generated kubeconfig).

R2/R5: the local `resolveKubeVerbCluster` copy is DELETED, not taught the new field — it was
the second occurrence the sdk hoisted in opencharly/sdk#338, and its arms' tests moved to
the sdk with it; what stays here is the wiring, now covered by
`TestApplyResolvedCluster` / `TestKubectlClusterArgs` / `TestKubectlClusterPrefix`. The
`plugin-kube:` candy prose that described the context-only resolution is corrected in the
same commit.

The five pre-existing `errcheck` findings in `kindcluster.go` and its test are fixed here
rather than filed: `golangci-lint run ./...` now reports 0 issues module-wide.

Pins: `spec v0.2026287.716` (the tag carrying #224), `sdk v0.2026287.726` (#376). NOT spec
v0.2026287.727: that tag carries #225, whose removal `sdk v0.2026287.726` still re-exports in
`vmshared/spec_aliases.go` — measured here, and exactly the scheduled break
opencharly/sdk#377 tracks. This plugin takes the removal on its own pin wave, after that.

Closes #23
Agent: dsh-k8s-ext
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

* fix(kube): the verb honours its caller's deadline, so a hung dial fails fast and names its phase

The kube op runs inside the host's RPC call and receives that call's context, but 20 client
call sites passed context.TODO() — an uncancellable, deadline-free context. A hung dial
therefore outlived the host's deadline, kept the plugin blocked on a call nothing could
cancel, and surfaced only as `verb "kube": rpc error: code = DeadlineExceeded` with no
phase named. Measured on a bed probe (#24).

dispatch now bounds the WHOLE op by the step's own timeout — one canonical defaultOpTimeout,
replacing four scattered parseTimeout(op.Timeout, ...) calls — nested inside the caller's
deadline, whichever is shorter, and threads it into all 13 methods and the addons helper.
The client is injectable, and a test asserts the context the verb hands its client carries
a deadline bounded by the step's timeout and by a tighter caller deadline alike; it FAILS
against context.TODO().

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

* fix(kube): every deadline routes through one helper, so the claim matches the diff

The review found the body describing an intent the diff did not implement: it said the scattered
parseTimeout calls had been replaced, but only the 120s ones actually had been. This makes that true
rather than softening the sentence — opTimeout(method, op) is now THE deadline of a kube op, with the
per-method defaults in a single methodTimeouts table (wait-* 120s, addons 180s, lb-external-ip 60s,
exactly as the in-tree Kong tags document), and every one of the four waiting methods calls it.
`grep -c 'parseTimeout(' methods.go` is 0, and the only call left in the package is inside the helper.

Also settles the go.sum discrepancy the same review flagged: `go list -m` selects spec
v0.2026287.716, nothing in the module graph requires v0.2026287.727, so that checksum was a stale entry
and `go mod tidy` prunes it here rather than leaving a version named nowhere.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

---------

Co-authored-by: Andreas Trawoeger <[email protected]>
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.

loaderkit: the cluster resolver must carry the kubeconfig FILE beside the context

2 participants