Skip to content

Commit 2ac4560

Browse files
jamesadevineCopilot
andcommitted
feat(compile): autorewrite front matter via versioned migration chain
Introduces a Django/Rails-style schema-version field on FrontMatter and a registered migration framework so breaking grammar changes auto-migrate existing user sources during compile rather than hard-failing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 842ba4b commit 2ac4560

12 files changed

Lines changed: 2485 additions & 27 deletions

File tree

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +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
66+
│ │ │ └── helpers.rs # take_key, insert_no_overwrite, rename_key, ConflictPolicy
67+
│ │ ├── migration_integration_test.rs # White-box rewrite-path tests (stub registry injection)
6468
│ │ └── types.rs # Front matter grammar and types
6569
│ ├── init.rs # Repository initialization for AI-first authoring
6670
│ ├── execute.rs # Stage 3 safe output execution
@@ -192,6 +196,9 @@ index to jump to the right page.
192196
- [`docs/filter-ir.md`](docs/filter-ir.md) — filter expression IR
193197
specification: `Fact`/`Predicate` types, three-pass compilation (lower →
194198
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.
195202
- [`docs/local-development.md`](docs/local-development.md) — local development
196203
setup notes.
197204

docs/extending.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ When extending the compiler:
99
1. **New CLI commands**: Add variants to the `Commands` enum in `main.rs`
1010
2. **New compile targets**: Implement the `Compiler` trait in a new file under `src/compile/`
1111
3. **New front matter fields**: Add fields to `FrontMatter` in `src/compile/types.rs`
12+
- **Breaking changes** (renames, removals, type changes, added required fields)
13+
require adding a migration under `src/compile/migrations/` in the same PR.
14+
See [`docs/migrations.md`](migrations.md).
1215
4. **New template markers**: Handle replacements in the target-specific compiler (e.g., `standalone.rs` or `onees.rs`)
1316
5. **New safe-output tools**: Add to `src/safeoutputs/` — implement `ToolResult`, `Executor`, register in `mod.rs`, `mcp.rs`, `execute.rs`
1417
6. **New first-class tools**: Create `src/tools/<name>/` with `mod.rs` and `extension.rs` (CompilerExtension impl). Add `execute.rs` if the tool has Stage 3 runtime logic. Extend `ToolsConfig` in `types.rs`, add collection in `collect_extensions()`

docs/front-matter.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The compiler expects markdown files with YAML front matter similar to gh-aw:
88

99
```markdown
1010
---
11+
schema-version: 1 # Optional: front-matter schema version (defaults to 1). The compiler bumps this in place when migrations apply during compilation. See docs/migrations.md.
1112
name: "name for this agent"
1213
description: "One line description for this agent"
1314
target: standalone # Optional: "standalone" (default) or "1es". See docs/targets.md.

0 commit comments

Comments
 (0)