Skip to content

generate: map encodings in comline.toml (core#120 B3) - #105

Merged
Kinflou merged 3 commits into
mainfrom
encodings/consumer-mappings
Oct 31, 2026
Merged

Kinflou merged 3 commits into
mainfrom
encodings/consumer-mappings

Conversation

@Kinflou

@Kinflou Kinflou commented Oct 31, 2026

Copy link
Copy Markdown
Member

Step B3 of core#120, the CLI's half.

comline.toml

[generate]
encodings = { "com.acme.lines@1" = "acme::LinesFraming" }

[[generate.target]]
language = "typescript"
encodings = { "com.acme.lines@1" = { type = "LinesFraming", package = "acme-encodings", version = "^0.2.0" } }
  • An entry is the type alone, or { type, package, version } with package/version optional and unknown keys refused.
  • A target's entries override [generate]'s by canonical name, so jsonrpc@1 in one and json-rpc in the other are the same entry.
  • comline new's template mentions the key.

generate

  • Gathers the FrozenUnit::Encodings the package and its dependencies declare, plus official::units(), and fills GenerateRequest.encodings with comline_codegen::encodings::fill, the resolver the playground will share (codegen: resolve encodings to a target's mappings (core#120 B3) generation#88).
  • Precedence: comline.toml, then the declaring package's map, then an error. The error only fires for an encoding the package uses, and names the encoding, the language and the comline.toml syntax.

Pins: generation b116831, comline-rust 650c684 (ComlineProject/comline-rust#80) and comline-typescript 765fc2d (ComlineProject/comline-typescript#92), in the fixture generators as well. cargo tree -d shows one copy of each comline crate.

Byte-identical: chat_project, simple_project and validated_project, each also declaring typescript#5.0, generated in code and lib for rust and typescript by main and by this branch: diff -r over the 39 files is empty.

Tests

  • a_dependencys_framing_generates_its_mapped_type: app depends on acme, which declares com.acme.lines@1. The generated code uses acme's suggestion, then [generate]'s mapping, then the target's over it.
  • an_unmapped_dependency_framing_is_an_error_naming_it: acme suggests a TypeScript class only, so the rust target fails with the error and writes nothing.
  • an_unknown_framing_is_an_error: the cli#81 case, a framing nothing declares, fails before anything is generated.
  • a_bad_comline_toml_encoding_entry_is_refused, plus a unit test for the merge.
  • cargo test, cargo fmt --check and both clippy runs pass locally.

Merge last: after ComlineProject/generation#88, then ComlineProject/comline-rust#80 and ComlineProject/comline-typescript#92.

Kinflou added 3 commits October 31, 2026 22:19
[generate] and [[generate.target]] take
encodings = { "<name>" = "<type>" | { type, package, version } },
the target's over the section's by canonical name. generate gathers the
encodings the package and its dependencies declare, with the official
ones, and fills GenerateRequest.encodings through
comline_codegen::encodings::fill: comline.toml's mapping, else the
declaring package's suggestion, else an error naming the encoding, the
language and the comline.toml syntax, for an encoding the package uses.

Pins generation b116831, comline-rust 650c684 and comline-typescript
765fc2d (the encodings-mapping branches), the fixture generators too.
Generated output for chat_project, simple_project and validated_project
is byte-identical to main's, Rust and TypeScript, code and lib.
…d-encoding error; pin comline-rust 0e5c60e
@Kinflou
Kinflou merged commit bb40ec7 into main Oct 31, 2026
2 checks passed
@Kinflou
Kinflou deleted the encodings/consumer-mappings branch October 31, 2026 14:46
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