Skip to content

fix(k8s): the k8s config namespace reaches ChantConfig - #1405

Merged
lex00 merged 1 commit into
mainfrom
config-lexicon-keys
Aug 3, 2026
Merged

lex00 merged 1 commit into
mainfrom
config-lexicon-keys

Conversation

@lex00

@lex00 lex00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Closes #1370.

The k8s lexicon documents its cluster binding as a k8s key in chant.config.ts, and ChantConfig'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 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 only 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. 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]: unknown on ChantConfig. That 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, with satisfies ChantConfig
KIT_TSC=0

$ # a misspelled top-level key
error TS2561: 'lexicns' does not exist in type 'ChantConfig'. Did you mean to write 'lexicons'?

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.

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
lex00 merged commit eaec3fb into main Aug 3, 2026
5 checks passed
@lex00
lex00 deleted the config-lexicon-keys branch August 3, 2026 04:50
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.
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.

ChantConfig rejects the lexicon config keys its own docs tell you to write

1 participant