feat: add template version management #63

Merged
Charon merged 1 commit from feat/template-version-management into main 2026-02-24 13:25:33 +00:00
Member

Summary

  • Add plan_template_versions table that snapshots YAML template content when a plan is created, so future edits to template files never affect existing plans
  • Plans now reference their template version via template_version_id (nullable FK), with version number also stored in metadata
  • Deduplication: identical template content reuses the same version row (matched by SHA-256 hash), so unchanged templates do not accumulate rows
  • New PlanTemplateVersion model with findOrCreateFromTemplate() and historyFor() class methods
  • PlanTemplateService gains getVersionHistory(slug) and getVersion(slug, version) to query stored versions
  • 25 new tests in TemplateVersionManagementTest

Changes

File Change
Migrations/0001_01_01_000006_add_template_versions.php New migration
Models/PlanTemplateVersion.php New model
Models/AgentPlan.php Add template_version_id fillable + relationship
Services/PlanTemplateService.php Snapshot version on create; add history/retrieval methods
tests/Feature/TemplateVersionManagementTest.php New test suite
TODO.md Mark FEAT-003 complete

Test plan

  • TemplateVersionManagementTest -- all 25 cases pass
  • Existing PlanTemplateServiceTest -- no regressions

Closes #35

Generated with Claude Code

## Summary - Add `plan_template_versions` table that snapshots YAML template content when a plan is created, so future edits to template files never affect existing plans - Plans now reference their template version via `template_version_id` (nullable FK), with version number also stored in `metadata` - Deduplication: identical template content reuses the same version row (matched by SHA-256 hash), so unchanged templates do not accumulate rows - New `PlanTemplateVersion` model with `findOrCreateFromTemplate()` and `historyFor()` class methods - `PlanTemplateService` gains `getVersionHistory(slug)` and `getVersion(slug, version)` to query stored versions - 25 new tests in `TemplateVersionManagementTest` ## Changes | File | Change | |------|--------| | `Migrations/0001_01_01_000006_add_template_versions.php` | New migration | | `Models/PlanTemplateVersion.php` | New model | | `Models/AgentPlan.php` | Add `template_version_id` fillable + relationship | | `Services/PlanTemplateService.php` | Snapshot version on create; add history/retrieval methods | | `tests/Feature/TemplateVersionManagementTest.php` | New test suite | | `TODO.md` | Mark FEAT-003 complete | ## Test plan - [ ] `TemplateVersionManagementTest` -- all 25 cases pass - [ ] Existing `PlanTemplateServiceTest` -- no regressions Closes #35 Generated with Claude Code
Charon force-pushed feat/template-version-management from 474f96ee5f to 0e7b617551 2026-02-24 13:25:23 +00:00 Compare
Charon merged commit 80c778cb08 into main 2026-02-24 13:25:33 +00:00
Charon deleted branch feat/template-version-management 2026-02-24 13:25:33 +00:00
This repo is archived. You cannot comment on pull requests.
No description provided.