Commit f065e27
test: cover preset constitution seeding through init CLI (#3297)
* Fix preset-constitution-not-installed: use PresetResolver in constitution setup
Apply the remediation from the bug assessment on issue #3272.
Changes:
1. Modify ensure_constitution_from_template (init.py) to resolve the
constitution-template through the preset priority stack via
PresetResolver, instead of hardcoding the core template path. This
ensures a preset's replacement constitution-template is used when
seeding .specify/memory/constitution.md.
2. Reorder init flow: move ensure_constitution_from_template to after
the preset installation block so that 'specify init --preset' seeds
the memory file from the already-resolved template stack, not from
the generic template that existed before the preset arrived.
3. Add _maybe_reseed_constitution to PresetManager (presets/__init__.py):
a post-install hook that re-seeds .specify/memory/constitution.md
from the preset's constitution-template during 'specify preset add'
on an existing project, but only when the memory file still contains
generic placeholder tokens ([PROJECT_NAME] or [PRINCIPLE_1_NAME]).
Legitimately authored constitutions (no placeholder tokens) are never
overwritten.
4. Add regression tests covering both code paths (TestConstitutionReseedOnPresetInstall
and TestEnsureConstitutionFromTemplate in tests/test_presets.py).
Refs #3272
Assisted-by: GitHub Copilot (model: claude-sonnet-4.6, autonomous)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Harden preset constitution resolution
Use manifest-aware composed content, atomic safe writes, and conservative generic-template matching for constitution seeding and re-seeding.
Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 49891a32-bec4-462c-a7f2-6d6ec4eefcdb
* Limit preset CLI change to regression test
Remove accidental whole-file Ruff formatting introduced during conflict resolution so the PR contains only the intended end-to-end test.
Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 49891a32-bec4-462c-a7f2-6d6ec4eefcdb
* Make preset init test depend on init ordering
Disable preset-install lifecycle seeding in the regression test so it fails unless init materializes the constitution after registering the preset.
Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 49891a32-bec4-462c-a7f2-6d6ec4eefcdb
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Ben Buttigieg <70525+BenBtg@users.noreply.github.com>1 parent 2fb18c7 commit f065e27
1 file changed
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
227 | 287 | | |
228 | 288 | | |
229 | 289 | | |
| |||
0 commit comments