Skip to content

Lexicon contract: per-lexicon config namespaces are undeclared, unvalidated, and untypeable #1344

Closed

Description

@lex00

Part of the lexicon contract epic (#1340).

The defect

Three lexicons own a top-level chant.config.ts key, all documented for users, none declared anywhere in the contract:

Lexicon Namespace Read at
k8s k8s.profiles.<env>.context core/src/kubectl-context.ts:129 (config.k8s as K8sConfigShape)
temporal temporal.profiles core/src/cli/handlers/run-client.ts:119 (config.temporal as Record<string, unknown>)
forgejo forgejo.runnerLabels, forgejo.actionsRoot lexicons/forgejo/src/serializer.ts:24 (config?.forgejo)

Core itself reaches into two of them with as casts.

ChantConfigSchema is .passthrough(), so at runtime any key is accepted and a typo (runnerLabel) is silently ignored — the dialect just uses defaults. The ChantConfig interface is closed, so the documented forgejo example does not compile:

error TS2353: Object literal may only specify known properties,
and 'forgejo' does not exist in type 'ChantConfig'.

Three lexicons, three workarounds: temporal exports its own widened TemporalChantConfig, k8s's docs drop satisfies, forgejo's docs keep satisfies ChantConfig and are wrong.

Into the contract

A lexicon may own the config namespace named after it, and says so:

  1. A contract member — e.g. configSchema?: ZodType or configNamespace?(), declaring the shape of config[plugin.name].
  2. Validation — core validates a declared namespace instead of passing everything through, so a typo is an error rather than a silent default. Namespaces of lexicons that declare nothing keep today's passthrough.
  3. Typing — one supported way to write a typed config with lexicon keys, replacing the three ad-hoc workarounds. Whatever the mechanism (declaration merging, a generic ChantConfig<L>, an exported helper), the documented examples must compile.
  4. A check that a lexicon reading config[name] declares it.

Done when

  • Namespace ownership is declared, not assumed
  • An unknown key inside a declared namespace fails rather than defaulting
  • The k8s, temporal, and forgejo doc examples typecheck as written
  • Core's two as casts read a typed value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions