Repository navigation
fix(k8s): the k8s config namespace reaches ChantConfig - #1405
Merged
Merged
Conversation
The lexicon documents its cluster binding as a `k8s` key in
chant.config.ts, and `ChantConfig`'s Zod schema is `.passthrough()`, so it
has always been accepted at runtime. The type side was missing, so the
documented snippet compiled only until someone added `satisfies
ChantConfig` — which every example project writes, and which is the only
thing type-checking the rest of the file:
error TS2353: Object literal may only specify known properties,
and 'k8s' does not exist in type 'ChantConfig'.
kubemicrovm-ops was carrying `ChantConfig & { k8s?: K8sChantConfig }` to
get its config checked at all.
The mechanism already existed: forgejo augments ChantConfig from its own
package (#1344) and temporal does the same. k8s was the one that did not,
which is why the snippet in its own doc comment omits `satisfies` — the
example was written around the gap rather than showing it.
Declaration merging rather than an index signature on ChantConfig, which
was the other option and a bad one: `[key: string]: unknown` accepts every
key and so stops catching a typo like `lexicns`, which is most of what the
interface is for. Verified both halves against a real consumer — the
documented snippet now compiles with `satisfies ChantConfig`, and a
misspelled top-level key still errors with a suggestion.
The compile-time guard is the same one forgejo carries, in the source
rather than in a test, because the root tsconfig excludes test files and a
compile-time claim asserted in one is checked by nothing.
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.
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 #1370.
The k8s lexicon documents its cluster binding as a
k8skey inchant.config.ts, andChantConfig's Zod schema is.passthrough(), so it has always worked at runtime. The type side was missing, so the documented snippet compiled only until someone addedsatisfies ChantConfig— which every example project writes, and which is the only thing type-checking the rest of the file.kubemicrovm-ops was carrying
ChantConfig & { k8s?: K8sChantConfig }to get its config checked at all.The mechanism already existed
forgejo augments
ChantConfigfrom its own package (#1344), and temporal does the same. k8s was the only one that did not — which is why the snippet in its own doc comment omitssatisfies: the example was written around the gap rather than showing it. So this is narrower than the issue framed it, and the fix is one lexicon following an established pattern.Why not an index signature
The other option was
[key: string]: unknownonChantConfig. That accepts every key and so stops catching a typo likelexicns, which is most of what the interface is for.Verified both halves against a real consumer:
1104 k8s lexicon tests pass. The compile-time guard is forgejo's, in the source rather than a test — the root tsconfig excludes test files, so a compile-time claim asserted in one is checked by nothing.