The old architecture used a monolithic main() with a custom arg parser, an event-emitter-based runtime, and a plugin system for optional features.
This PR rewrites the CLI and internal architecture to be modular, extensible, and built around a registry of interchangeable components.
Introduce a registry system (internal/registry) for marshalers, codecs, and engines, with BFS-based conversion path resolution.
Add type-erased adapter layer (internal/cli) with Repr, Engine, Process, Marshaler, and Conversion interfaces wrapping generic pkg/ types.
Replace the event-emitter-based Runtime with a simpler Engine/Process model (pkg/engine).
Add generic Codec[T, U] and Marshaler[T] interfaces (pkg/codec).
Merge saccharine/token sub-package into saccharine and rename scanner functions from parse* to scan*.
Make saccharine-to-lambda conversion bidirectional (encode and decode).
Add lambda.Marshaler and saccharine.Marshaler implementing codec.Marshaler.
Remove old infrastructure: pkg/runtime, pkg/expr, internal/plugins, internal/statistics.
Add make lint target and update golangci-lint config.
Decisions
Cobra was chosen for the CLI framework to support nested subcommands and standard flag handling.
The registry uses BFS to find conversion paths between representations, allowing multi-hop conversions without hardcoding routes.
Type erasure via cli.Repr (wrapping any) enables the registry to work with heterogeneous types while keeping pkg/ generics type-safe.
The old plugin/event system was removed entirely rather than adapted, since the new Process model can support hooks differently in the future.
Benefits
Subcommands make the CLI self-documenting and easier to extend with new functionality.
The registry pattern decouples representations, conversions, and engines, making it trivial to add new ones.
BFS conversion routing means adding a single codec automatically enables transitive conversions.
Simpler Engine/Process model reduces complexity compared to the event-emitter runtime.
Consolidating the token sub-package reduces import depth and package sprawl.
Checklist
Code follows conventional commit format.
Branch follows naming convention (<type>/<description>). Always use underscores.
Tests pass (if applicable).
Documentation updated (if applicable).
## Description
The old architecture used a monolithic `main()` with a custom arg parser, an event-emitter-based runtime, and a plugin system for optional features.
This PR rewrites the CLI and internal architecture to be modular, extensible, and built around a registry of interchangeable components.
- Replace custom CLI arg parsing with Cobra subcommands (`convert`, `reduce`, `engine list`).
- Introduce a registry system (`internal/registry`) for marshalers, codecs, and engines, with BFS-based conversion path resolution.
- Add type-erased adapter layer (`internal/cli`) with `Repr`, `Engine`, `Process`, `Marshaler`, and `Conversion` interfaces wrapping generic `pkg/` types.
- Replace the event-emitter-based `Runtime` with a simpler `Engine`/`Process` model (`pkg/engine`).
- Add generic `Codec[T, U]` and `Marshaler[T]` interfaces (`pkg/codec`).
- Merge `saccharine/token` sub-package into `saccharine` and rename scanner functions from `parse*` to `scan*`.
- Make saccharine-to-lambda conversion bidirectional (encode and decode).
- Add `lambda.Marshaler` and `saccharine.Marshaler` implementing `codec.Marshaler`.
- Remove old infrastructure: `pkg/runtime`, `pkg/expr`, `internal/plugins`, `internal/statistics`.
- Add `make lint` target and update golangci-lint config.
### Decisions
- Cobra was chosen for the CLI framework to support nested subcommands and standard flag handling.
- The registry uses BFS to find conversion paths between representations, allowing multi-hop conversions without hardcoding routes.
- Type erasure via `cli.Repr` (wrapping `any`) enables the registry to work with heterogeneous types while keeping `pkg/` generics type-safe.
- The old plugin/event system was removed entirely rather than adapted, since the new `Process` model can support hooks differently in the future.
## Benefits
- Subcommands make the CLI self-documenting and easier to extend with new functionality.
- The registry pattern decouples representations, conversions, and engines, making it trivial to add new ones.
- BFS conversion routing means adding a single codec automatically enables transitive conversions.
- Simpler `Engine`/`Process` model reduces complexity compared to the event-emitter runtime.
- Consolidating the `token` sub-package reduces import depth and package sprawl.
## Checklist
- [x] Code follows conventional commit format.
- [x] Branch follows naming convention (`<type>/<description>`). Always use underscores.
- [ ] Tests pass (if applicable).
- [ ] Documentation updated (if applicable).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description
The old architecture used a monolithic
main()with a custom arg parser, an event-emitter-based runtime, and a plugin system for optional features.This PR rewrites the CLI and internal architecture to be modular, extensible, and built around a registry of interchangeable components.
convert,reduce,engine list).internal/registry) for marshalers, codecs, and engines, with BFS-based conversion path resolution.internal/cli) withRepr,Engine,Process,Marshaler, andConversioninterfaces wrapping genericpkg/types.Runtimewith a simplerEngine/Processmodel (pkg/engine).Codec[T, U]andMarshaler[T]interfaces (pkg/codec).saccharine/tokensub-package intosaccharineand rename scanner functions fromparse*toscan*.lambda.Marshalerandsaccharine.Marshalerimplementingcodec.Marshaler.pkg/runtime,pkg/expr,internal/plugins,internal/statistics.make linttarget and update golangci-lint config.Decisions
cli.Repr(wrappingany) enables the registry to work with heterogeneous types while keepingpkg/generics type-safe.Processmodel can support hooks differently in the future.Benefits
Engine/Processmodel reduces complexity compared to the event-emitter runtime.tokensub-package reduces import depth and package sprawl.Checklist
<type>/<description>). Always use underscores.