Skip to content

fix: a target block configures a language, it doesn't replace the set - #59

Merged
Kinflou merged 2 commits into
mainfrom
fix/targets-configure-not-replace
Oct 12, 2026
Merged

Kinflou merged 2 commits into
mainfrom
fix/targets-configure-not-replace

Conversation

@Kinflou

@Kinflou Kinflou commented Oct 12, 2026

Copy link
Copy Markdown
Member

A congregation declaring rust#1.70.0 and typescript#5.0 generated rust
only, said nothing about typescript, and exited 0.

One line did it (gen_config.rs:255):

let base = if cfg.generate.targets.is_empty() { declared } else { targets };

An all-or-nothing switch. The moment one [[generate.target]] block existed —
and the reported case had exactly one, there only to redirect rust's output to
a sibling directory — every declared language without its own block was
dropped. Silently.

This contradicted the documentation. guide/codegen/generating-code.md
introduces the block as "one block per target you want to pin or override"
and lang_version as "defaults to what config.idp declared" — a block is
described throughout as settings for a language, never as the thing deciding
whether that language is generated. The code had diverged from its own docs,
so this is a bug fix, not a design change.

It also conflated two files with different owners: config.idp is committed
and says which languages the package is generated for; comline.toml is
consumer-owned and says where and how each lands.

The rule

  • The declared set is the base; blocks configure it by language
    (case-insensitive). A language with no block takes the [generate] defaults.
  • Several blocks for one language still give several outputs.
  • A block naming an undeclared language is an error naming the fix — silently
    ignoring a block someone wrote would be the same footgun inverted.
  • Nothing declared at all → the blocks are the set, so a comline.toml-only
    project still works.
  • [generate] only = ["rust"] narrows persistently; --target still narrows
    per run. An undeclared name in only is an error, so a typo can't quietly
    stop generating something.

Missing generators

The declared set is now reached on every run, so the missing-generator error
says what to do:

error: no generator for `python` (version `3.11.0`)
  help: this build of comline has no python generator. Install one that
        does, or narrow the set in comline.toml:
          [generate]
          only = [...]

The gen-* Cargo features are optional, so a binary lacking one is a normal
build — but declaring a language means meaning it, and only is how a
consumer says otherwise on purpose.

Verified on the reported project

config.idp declaring rust + typescript, with a rust-only block:

⚙️  language: rust, version: 1.70.0, mode: lib
     ../test-cl-rs/
     ├─ Cargo.toml
     └─ src/…
⚙️  language: typescript, version: 5.0, mode: code
     generated/typescript/
     └─ greeting.ts

Tests

No existing gen_config test combined a declared language with a block, so
none encoded the old behaviour and none needed changing — worth stating,
since it means the old semantics were never deliberately pinned down. Two
integration tests configured a python block against a fixture declaring only
rust; they now declare it, which is what a block requires.

cli only — no core, no generators, no cascade.

Kinflou added 2 commits October 13, 2026 04:00
A congregation declaring `rust#1.70.0` and `typescript#5.0` generated rust
only, said nothing about typescript, and exited 0.

One line did it:

    let base = if cfg.generate.targets.is_empty() { declared } else { targets };

An all-or-nothing switch. The moment one `[[generate.target]]` block existed -
and the reported case had exactly one, there only to redirect rust's output to
a sibling directory - every declared language without its own block was
dropped. Silently: no warning, no mention in the output, nothing.

This contradicted the documentation, which already described the intended
behaviour: the guide introduces the block as "one block per target you want to
pin or override" and `lang_version` as "defaults to what config.idp declared".
A block is described throughout as *settings for a language*, never as the
thing that decides whether that language is generated. The code had diverged
from its own docs.

It also conflated two files with different owners. `config.idp` is committed
and says which languages the package is generated for; `comline.toml` is
consumer-owned and says where and how each one lands. Deciding *whether* is
the congregation's call.

So the declared set is the base, and blocks configure it by language
(case-insensitively). A language with no block takes the `[generate]`
defaults. Several blocks for one language still give several outputs. A block
naming a language the congregation doesn't declare is an error that names the
fix - silently ignoring a block someone wrote would be the same footgun
inverted. With nothing declared at all, the blocks are the set, so a
`comline.toml`-only project still works.

`[generate] only = ["rust"]` narrows persistently, for a checkout that wants
fewer languages than the package offers; `--target` still narrows per run. A
name the congregation doesn't declare is an error there too, so a typo can't
quietly stop generating something.

That makes the declared set reachable on every run, so the missing-generator
error now says what to do about it: this build has no such generator, install
one that does or narrow with `only`. The `gen-*` Cargo features are optional,
so a binary lacking one is a normal build - but declaring a language means
meaning it, and `only` is the way to say otherwise on purpose.

No existing `gen_config` test combined a declared language with a block, so
none encoded the old behaviour and none needed changing. Two integration tests
configured a `python` block against a fixture declaring only rust; they now
declare it, which is what a block requires.
The `lib` mode work (#58) landed unformatted, turning CI's Lint job red on
main; this branch added more of the same. `cargo fmt --all` over the four
files it touched, no behaviour change.
@Kinflou
Kinflou merged commit f478af7 into main Oct 12, 2026
2 checks passed
@Kinflou
Kinflou deleted the fix/targets-configure-not-replace branch October 12, 2026 20:12
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