Skip to content

fix: a declared cluster binding is used, not policed against ambient (#1488) - #1507

Merged
lex00 merged 1 commit into
mainfrom
fix/1488-bind-declared-context
Aug 5, 2026
Merged

lex00 merged 1 commit into
mainfrom
fix/1488-bind-declared-context

Conversation

@lex00

@lex00 lex00 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

resolveClusterTarget resolved k8s.profiles..context but then compared
it against the ambient kubectl context and refused on mismatch — so any
k3d cluster another project created mid-session stole the current-context
and turned a healthy estate grey, with read-failed as the only
explanation from behold's seat. The normal state of a laptop with two
projects on it, as #1488 puts it.

The binding is a selection, not a check: when declared, the resolver now
returns it unconditionally and every read/write passes it explicitly to
the typed client. Ambient never enters the picture. A bound context the
kubeconfig does not have still fails with an error naming the context and
the k8s.profiles..context binding (the client's existing
KubeConfigError) — never by falling back to ambient.

ClusterBindingMismatchError stays exported: the resolver no longer throws
it, but the kube/* read paths still catch it (a custom connector may
throw it to get NOT-OBSERVED classification).

Verified on fountain-ops, the reporting project, read-only with the
ambient context deliberately left on the wrong cluster:
before — statuses {"neutral":11}, refusal on stderr;
after — statuses {"good":11,"runtime":4}, ambient untouched.

Core 4026/4026; k8s suites green except the pre-existing #1476/#1419
local ungenerated-table failures, byte-identical on main.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01HDqbe9YwXqqpF7VxFp1Drx

…1488)

resolveClusterTarget resolved k8s.profiles.<env>.context but then compared
it against the ambient kubectl context and refused on mismatch — so any
k3d cluster another project created mid-session stole the current-context
and turned a healthy estate grey, with `read-failed` as the only
explanation from behold's seat. The normal state of a laptop with two
projects on it, as #1488 puts it.

The binding is a selection, not a check: when declared, the resolver now
returns it unconditionally and every read/write passes it explicitly to
the typed client. Ambient never enters the picture. A bound context the
kubeconfig does not have still fails with an error naming the context and
the k8s.profiles.<env>.context binding (the client's existing
KubeConfigError) — never by falling back to ambient.

ClusterBindingMismatchError stays exported: the resolver no longer throws
it, but the kube/* read paths still catch it (a custom connector may
throw it to get NOT-OBSERVED classification).

Verified on fountain-ops, the reporting project, read-only with the
ambient context deliberately left on the wrong cluster:
before — statuses {"neutral":11}, refusal on stderr;
after  — statuses {"good":11,"runtime":4}, ambient untouched.

Core 4026/4026; k8s suites green except the pre-existing #1476/#1419
local ungenerated-table failures, byte-identical on main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDqbe9YwXqqpF7VxFp1Drx
@lex00
lex00 merged commit 8118657 into main Aug 5, 2026
5 checks passed
@lex00
lex00 deleted the fix/1488-bind-declared-context branch August 5, 2026 22:30
lex00 added a commit that referenced this pull request Aug 9, 2026
…ng block typechecks (#1488, #1455) (#1610)

* fix(k8s): read failures name the cluster context they read (#1488)

resolveClusterTarget stopped policing ambient in #1507 — a declared
binding is used, not checked — but a read that still fails said nothing
about which cluster it talked to. The reporting scenario: no binding
declared, another project's k3d cluster steals the ambient context, and
every declared resource goes grey with a bare read-failed.

The typed client now stamps a context note onto every API and transport
failure at construction — context name plus how it was selected — and
classifyApiFailure appends it to the unobserved detail after the one-line
cap, so it never truncates away. The connector supplies the selection
story: 'bound by k8s.profiles.<env>.context', 'ambient; no
k8s.profiles.<env> binding', or 'explicit --context'. Every read path
(describeResources, deep observe, the runtime sweep, kube verbs, Op
activities) classifies through the same seam, so none of them needed
touching.

Also retires the stale pre-#1507 doc comments that still described the
ambient-mismatch refusal.

* test(k8s): the cluster-binding block typechecks and its typos are rejected (#1455)

The augmentation and schema #1455 asks for landed with #1405/#1344 —
config.ts declares 'k8s' on ChantConfig, config-schema.ts is the runtime
half, plugin.ts wires it as configSchema — but nothing proved the issue's
reproduction compiles, and the k8s lexicon lacked the config-augmentation
guard the forgejo lexicon carries. Port it: the reproduction verbatim
under satisfies ChantConfig, plus schema cases for the failure the
namespace most cares about — an unknown key ('profile', 'contxt') is
rejected rather than silently leaving the environment unbound, which is
exactly the wrong-cluster setup #1488 hit.
@lex00 lex00 mentioned this pull request Nov 20, 2026
78 of 84 tasks
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