Skip to content

Commit c8cec49

Browse files
jamesadevineCopilot
andcommitted
refactor(compile): replace versioned migrations with detection-based codemods
Aligns with gh-aw's codemod model. The previous design (versioned chain + `schema-version` field on user front matter) leaked an internal compiler concern into user files. gh-aw — the project we explicitly say we're inspired by in AGENTS.md — uses 41 codemods with no version stamping; users never see a `schema-version` field. This refactor brings ado-aw to the same model while keeping our ergonomic compile-time autorewrite UX (gh-aw uses a separate `gh aw fix --write` command, we don't). Changes: - Drop FrontMatter.schema_version field, default_schema_version fn, and the SCHEMA_VERSION_KEY const. - Rename src/compile/migrations/ to src/compile/codemods/. Rename src/compile/migration_integration_test.rs to src/compile/codemod_integration_test.rs. Rename tests/migration_tests.rs to tests/codemod_tests.rs. Rename docs/migrations.md to docs/codemods.md (rewritten from scratch). - Replace Migration / MigrationContext / MigrationReport / AppliedMigration / MIGRATIONS with Codemod / CodemodContext / CodemodReport / AppliedCodemod / CODEMODS. - Codemod.apply signature changes from `fn(&mut Mapping, &Ctx) -> Result<()>` to `fn(&mut Mapping, &Ctx) -> Result<bool>` so each codemod reports whether it actually modified the mapping. - Simplify the runner: flat per-codemod loop, no version arithmetic, no contiguity checks, no overflow guards, no future-version rejection. - Drop hoist_schema_version from reconstruct_source — no schema-version field to hoist. - Update parse_markdown_detailed, compile_pipeline_inner, perform_source_rewrite_if_needed, check_pipeline, run_execute, and compile_all_pipelines to use the codemod types and reword their messages. - Helpers (take_key, insert_no_overwrite, rename_key, ConflictPolicy) are unchanged — they're as useful for codemods as they were for migrations. rename_key already returned Result<bool>, matching the new codemod contract. - Drop ~13 schema-version-specific tests (registry contiguity, future version, non-integer, etc.). Add 7 codemod-runner tests (empty registry, all-no-op, mixed, error context, idempotency). Black-box CLI tests reduced from 10 to 3 (deleted tests asserted on schema-version-specific behavior that no longer exists). PR #476 has not merged; this lands as a follow-up commit on the same branch so users never see the schema-version concept ship. All 1349 tests pass. PR title and body to be updated separately. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b3bdae6 commit c8cec49

15 files changed

Lines changed: 1021 additions & 1717 deletions

File tree

AGENTS.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ Every compiled pipeline runs as three sequential jobs:
6161
│ │ │ ├── safe_outputs.rs # Always-on SafeOutputs MCP extension
6262
│ │ │ ├── trigger_filters.rs # Trigger filter extension (gate evaluator delivery)
6363
│ │ │ └── tests.rs # Extension integration tests
64-
│ │ ├── migrations/ # Front-matter migrations (one file per version step)
65-
│ │ │ ├── mod.rs # Migration struct, MIGRATIONS registry, runner, CURRENT_SCHEMA_VERSION
64+
│ │ ├── codemods/ # Front-matter codemods (one file per transformation)
65+
│ │ │ ├── mod.rs # Codemod struct, CODEMODS registry, runner
6666
│ │ │ └── helpers.rs # take_key, insert_no_overwrite, rename_key, ConflictPolicy
67-
│ │ ├── migration_integration_test.rs # White-box rewrite-path tests (stub registry injection)
67+
│ │ ├── codemod_integration_test.rs # White-box rewrite-path tests (stub registry injection)
6868
│ │ └── types.rs # Front matter grammar and types
6969
│ ├── init.rs # Repository initialization for AI-first authoring
7070
│ ├── execute.rs # Stage 3 safe output execution
@@ -196,9 +196,10 @@ index to jump to the right page.
196196
- [`docs/filter-ir.md`](docs/filter-ir.md) — filter expression IR
197197
specification: `Fact`/`Predicate` types, three-pass compilation (lower →
198198
validate → codegen), gate step generation, adding new filter types.
199-
- [`docs/migrations.md`](docs/migrations.md) — front-matter migration
200-
framework: schema-version field, automatic source rewrite on
201-
breaking-change updates, contributor workflow for adding migrations.
199+
- [`docs/codemods.md`](docs/codemods.md) — front-matter codemod
200+
framework: detection-based transformations, automatic source
201+
rewrite on breaking-change updates, contributor workflow for
202+
adding codemods.
202203
- [`docs/local-development.md`](docs/local-development.md) — local development
203204
setup notes.
204205

0 commit comments

Comments
 (0)