Repository navigation
fix(k8s): a read failure names the cluster context it read; the binding block typechecks (#1488, #1455) - #1610
Merged
Merged
Conversation
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.
…ected (#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
added a commit
that referenced
this pull request
Aug 9, 2026
… publish gate (#1616) The release recipe rewrites @intentius/* peerDependencies to the new version but left optionalDependencies alone, so lexicons/k8s kept @intentius/chant-k8s-client at ^0.42.1 across the 0.44.0 bump. Under 0.x semver that range excludes the workspace's 0.44.0, npm nests the published 0.42.1, and publish.yml's test job typechecks the lexicon against a client missing contextLabel (#1610) and preferredGroupVersions (#1609) — which is exactly how the chant-v0.44.0 publish run died before publishing anything. Pins the dep to ^0.44.0 now and teaches the recipe to rewrite @intentius/* optionalDependencies (a literal "*" stays untouched) so the next lockstep bump carries it.
lex00
added a commit
that referenced
this pull request
Aug 10, 2026
…e live wire (#1625) From behold#192: a Flux-deployed k8s project declares no metadata.namespace (the controller stamps targetNamespace at apply), so the live read scopes to the context's default namespace, finds nothing, and correctly reports absence — painting weeks-old running infrastructure pending. Every layer is spec-correct; the report cannot explain itself. The observation envelope now carries an optional queried map — the resolved address each read was issued against, keyed by entity name. Purely additive: classification still reads only resources/unobserved and the #1089 tri-state does not shift. The map is the only record an OBSERVED-ABSENT entity gets (absence is spelled 'in neither map'), and unobserved entries carry the address inline as UnobservedEntity.queried. - k8s-client grows pathFor(ref): the exact request path read() would GET, namespace defaulting made visible; undefined when discovery does not serve the kind. - The k8s reader resolves the address before each read and stamps it on every verdict; the observeEntities harness accepts queried on all three EntityObservation variants for the other native observers. - lifecycle diff --live --json emits resources.queried per lexicon and queried per unobserved row; the human report shows 'web [queried /apis/apps/v1/namespaces/default/deployments/web]' on missing and unobserved lines. lifecycle plan carries the same address per change-set entry (a create's address is the one the provider confirmed absent). - The #1610 context note now LEADS the unobserved detail instead of trailing it: consumers truncate a reason to its first line / ~160 chars, and a note appended after a long error vanished exactly when it mattered. Closes #1620
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1488. Closes #1455.
Both issues were mostly resolved on main already — #1507 made a declared
binding a selection rather than an ambient-policed check, and #1405/#1344
gave the k8s lexicon its
configSchemaand theChantConfigaugmentation.This PR lands what each issue still asked for.
#1488 — read failures name the cluster they read
What #1507 left open is the issue's second ask: a
read-failedwith nomention of which cluster was read. That is the exact scenario the report
opens with when no binding is declared — another project's k3d cluster takes
the ambient context and the estate goes grey with nothing to go on.
The fix sits at the client-construction seam.
createK8sClientstamps acontext note onto every API and transport failure it throws — the resolved
context name plus how it was selected — and
classifyApiFailureappends itto the unobserved detail after the one-line cap, so it survives truncation.
The connector (
defaultK8sConnector) supplies the selection story:context "prod-eks" (bound by k8s.profiles.prod.context)context "k3d-kubemicrovm-local" (ambient; no k8s.profiles.local binding)context "prod-eks" (explicit --context)Every read path —
describeResources, deep observe, the discovery-drivenruntime sweep, the
chant kubeverbs, the Op activities — already buildsits client through
defaultK8sConnectorand classifies throughclassifyApiFailure, so no caller needed touching. GCP observation moved toREST in #1209 and no longer shares the kubectl path.
The issue's exact message shape included what the profile declares when it
disagrees with ambient; since #1507 that disagreement cannot occur — a
declared context is used, so a failure against it names the bound context,
and the ambient phrasing appears only when nothing is declared. A bound
context absent from the kubeconfig still refuses with the context name and
the
k8s.profiles.<env>.contextbinding (KubeConfigError, from #1507),never by falling back to ambient — covered by existing tests.
Also retires the doc comments in
config.ts,kube/connect.tsandkube/get.tsthat still described the pre-#1507 mismatch refusal.#1455 — the binding block typechecks, proven
The augmentation, schema and
configSchemawiring the issue asks for landedwith #1405/#1344, but the k8s lexicon lacked the guard the forgejo lexicon
carries.
config-augmentation.test.tsnow holds the issue's reproductionverbatim under
satisfies ChantConfig(root import, as reported), plusschema cases for the namespace's most expensive typos:
profileandcontxtare rejected rather than silently leaving the environment unbound —which is precisely the setup that produced #1488.
Sweep: other lexicons
Per the issue's closing question, checked every lexicon for a
*ChantConfigexported for a key core does not carry. Three lexicons own config
namespaces — k8s, temporal, forgejo — and all three declare
configSchemaplus the module augmentation. The aws lexicon reads
ChantConfig.stacks,which core itself declares (#1161). The helm lexicon reads the k8s
namespace through
resolveClusterTargetbut owns no namespace and exportsno config type. Nothing else needed the pattern, so there is no third
commit.
Verification
npx vitest run lexicons/k8s/src packages/k8s-client/src packages/core/src/kubectl-context.test.ts packages/core/src/lexicon-config.test.ts— 1330 passed, 1 skippednpm run build -w @intentius/chant-k8s-client— cleannpm run build -w @intentius/chant-lexicon-k8s— cleanjust build(core tsc) — clean