Skip to content

Rjf/update codegen#518

Open
robfitzgerald wants to merge 14 commits into
mainfrom
rjf/update-codegen
Open

Rjf/update codegen#518
robfitzgerald wants to merge 14 commits into
mainfrom
rjf/update-codegen

Conversation

@robfitzgerald
Copy link
Copy Markdown
Collaborator

@robfitzgerald robfitzgerald commented Jun 3, 2026

i was reviewing the codegen crate and found that code changes in the core crate had broken the templates.

this PR rewrites the routee-compass-codegen crate so that the source template material is wired into the RouteE Compass codebase and therefore compiled. if any changes happen to the definitions for traversal/constraint/input plugin/output plugin traits, it will break the code in the codegen crate, forcing the developer to update those templates. this simplifies the task of ensuring that they remain up-to-date, relying on the developer to honor maintaining those files along with any changes to core trait APIs.

all template code avoids making references to the crate routee-compass-codegen so that, on fs copy, the files are internally linked and do not break references.

along the way,

  • i added codegen templates for Constraint, InputPlugin and OutputPlugin modules.
  • instead of offering users to decide if they want to use an engine.rs file for traversal/constraint models, we now only support generation with an engine.rs file, favoring a simpler codebase and being more opinionated.

each template module is flagged with #[allow_unused] to avoid sending warnings.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR rewrites the routee-compass-codegen crate to embed the codegen templates as real, compiled Rust modules (Traversal, Constraint, InputPlugin, OutputPlugin) and switches the CLI to a generic “copy selected template files” flow, so core API changes break compilation and force template updates.

Changes:

  • Replaced per-component generators with a unified generate_module that reads template source files from the crate and copies them into a new module directory.
  • Added compiled template modules for Traversal, Constraint, InputPlugin, and OutputPlugin (with stubbed todo!() implementations).
  • Updated the cargo compass CLI to support selecting which template files to copy (and added --force to more subcommands).

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
rust/routee-compass-codegen/Cargo.toml Adds dependencies needed for compiled templates (core/app crates, serde_json, thiserror).
rust/routee-compass-codegen/src/main.rs Updates CLI to use a file-list based generator flow and adds --force in more commands.
rust/routee-compass-codegen/src/generator/mod.rs Reorganizes generator module; adds component type + error + run module and includes templates with #[allow(unused)].
rust/routee-compass-codegen/src/generator/component_type.rs Adds component enum and template file retrieval from embedded source tree.
rust/routee-compass-codegen/src/generator/error.rs Introduces typed errors for template read failures.
rust/routee-compass-codegen/src/generator/run.rs Implements unified module generation + overwrite-protected file writing.
rust/routee-compass-codegen/src/generator/util.rs Removes old standalone write helper (functionality moved into run.rs).
rust/routee-compass-codegen/src/generator/traversal/mod.rs Adds compiled traversal template module layout/exports.
rust/routee-compass-codegen/src/generator/traversal/builder.rs Adds traversal builder template (compiled).
rust/routee-compass-codegen/src/generator/traversal/config.rs Adds traversal config template (compiled).
rust/routee-compass-codegen/src/generator/traversal/engine.rs Adds traversal engine template (compiled).
rust/routee-compass-codegen/src/generator/traversal/model.rs Adds traversal model template (compiled).
rust/routee-compass-codegen/src/generator/traversal/params.rs Adds traversal params template (compiled).
rust/routee-compass-codegen/src/generator/traversal/service.rs Adds traversal service template (compiled).
rust/routee-compass-codegen/src/generator/traversal.rs Removes old string-template generator implementation.
rust/routee-compass-codegen/src/generator/constraint/mod.rs Adds compiled constraint template module layout/exports and module docs.
rust/routee-compass-codegen/src/generator/constraint/builder.rs Adds constraint builder template (compiled).
rust/routee-compass-codegen/src/generator/constraint/config.rs Adds constraint config template (compiled).
rust/routee-compass-codegen/src/generator/constraint/engine.rs Adds constraint engine template (compiled).
rust/routee-compass-codegen/src/generator/constraint/model.rs Adds constraint model template (compiled).
rust/routee-compass-codegen/src/generator/constraint/params.rs Adds constraint params template (compiled).
rust/routee-compass-codegen/src/generator/constraint/service.rs Adds constraint service template (compiled).
rust/routee-compass-codegen/src/generator/constraint.rs Removes old placeholder constraint generator.
rust/routee-compass-codegen/src/generator/input_plugin/mod.rs Adds compiled input plugin template module layout/exports.
rust/routee-compass-codegen/src/generator/input_plugin/builder.rs Adds input plugin builder template (compiled).
rust/routee-compass-codegen/src/generator/input_plugin/config.rs Adds input plugin config template (compiled).
rust/routee-compass-codegen/src/generator/input_plugin/plugin.rs Adds input plugin implementation template (compiled).
rust/routee-compass-codegen/src/generator/input_plugin.rs Removes old placeholder input plugin generator.
rust/routee-compass-codegen/src/generator/output_plugin/mod.rs Adds compiled output plugin template module layout/exports.
rust/routee-compass-codegen/src/generator/output_plugin/builder.rs Adds output plugin builder template (compiled).
rust/routee-compass-codegen/src/generator/output_plugin/config.rs Adds output plugin config template (compiled).
rust/routee-compass-codegen/src/generator/output_plugin/plugin.rs Adds output plugin implementation template (compiled).
rust/routee-compass-codegen/src/generator/output_plugin.rs Removes old placeholder output plugin generator.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/routee-compass-codegen/src/generator/run.rs
Comment thread rust/routee-compass-codegen/src/generator/constraint/engine.rs
Comment thread rust/routee-compass-codegen/src/main.rs Outdated
Comment thread rust/routee-compass-codegen/src/main.rs Outdated
Comment thread rust/routee-compass-codegen/src/main.rs Outdated
Comment thread rust/routee-compass-codegen/src/main.rs Outdated
Comment thread rust/routee-compass-codegen/src/generator/constraint/mod.rs
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.

2 participants