Skip to content

Commit 19be9bb

Browse files
mnriemCopilot
andcommitted
fix(presets): ship constitution-sync in wheel, clarify scope guard, assert composition
Address review feedback on #3873: - pyproject.toml: force-include presets/constitution-sync into the wheel's core_pack so `_locate_bundled_preset` resolves it in a released install; the bundled advertisement was otherwise unshippable. - tests/contract/test_wheel_bundled_presets.py: new contract test asserting every bundled preset in presets/catalog.json is force-included (guards lean too). - commands/speckit.constitution.md: explicitly state the propagation section supersedes the core Scope Guard, which otherwise says dependent templates are not modified here. - tests/test_presets.py: assert resolve_content substitutes {CORE_TEMPLATE} and the effective command embeds both the core body and the sync pass. Assisted-by: GitHub Copilot (model: Claude Opus 4.8, supervised) Co-authored-by: Copilot App <[email protected]> Copilot-Session: afa7c1d2-147b-4f62-a6fc-a2cc824cfa3e
1 parent 9ac293d commit 19be9bb

4 files changed

Lines changed: 80 additions & 0 deletions

File tree

‎presets/constitution-sync/commands/speckit.constitution.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ handoffs:
1111

1212
## Constitution Template Sync
1313

14+
> **This section supersedes the "Scope Guard" above for template and command propagation.**
15+
> The core Scope Guard states that dependent templates and commands "are not modified here" —
16+
> that restriction is intentionally lifted by this preset. Propagating amended guidance into the
17+
> project's own dependent scaffolds and installed command files (as described below) **is in
18+
> scope** whenever this preset is installed. The Scope Guard's other constraints still apply:
19+
> do not implement features, generate application code, or touch artifacts unrelated to the
20+
> constitution/template workflow.
21+
1422
After you have written the updated constitution above, perform a consistency propagation pass
1523
so the dependent artifacts reflect the amended principles:
1624

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ packages = ["src/specify_cli"]
4949
"workflows/speckit" = "specify_cli/core_pack/workflows/speckit"
5050
# Bundled presets (installable via `specify preset add <name>` or `specify init --preset <name>`)
5151
"presets/lean" = "specify_cli/core_pack/presets/lean"
52+
"presets/constitution-sync" = "specify_cli/core_pack/presets/constitution-sync"
5253
# Community bundle catalog snapshot (used for offline discovery)
5354
"bundles/catalog.community.json" = "specify_cli/core_pack/bundles/catalog.community.json"
5455

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Contract tests: every bundled preset must ship inside the wheel's core_pack.
2+
3+
``specify preset add <id>`` resolves a bundled preset via
4+
``specify_cli._assets._locate_bundled_preset``, which checks the wheel's
5+
``specify_cli/core_pack/presets/<id>/`` directory first. Any preset marked
6+
``bundled: true`` in ``presets/catalog.json`` must therefore be force-included
7+
at build time; otherwise the released wheel advertises a bundled preset it does
8+
not actually ship, and ``specify preset add <id>`` falls through and reports the
9+
preset as missing.
10+
"""
11+
12+
from __future__ import annotations
13+
14+
import json
15+
import tomllib
16+
from pathlib import Path
17+
18+
REPO_ROOT = Path(__file__).parents[2]
19+
20+
21+
def _force_include() -> dict[str, str]:
22+
with (REPO_ROOT / "pyproject.toml").open("rb") as pyproject_file:
23+
pyproject = tomllib.load(pyproject_file)
24+
return pyproject["tool"]["hatch"]["build"]["targets"]["wheel"]["force-include"]
25+
26+
27+
def _bundled_preset_ids() -> list[str]:
28+
catalog = json.loads((REPO_ROOT / "presets" / "catalog.json").read_text())
29+
return sorted(
30+
preset_id
31+
for preset_id, entry in catalog["presets"].items()
32+
if entry.get("bundled")
33+
)
34+
35+
36+
def test_every_bundled_preset_is_force_included():
37+
force_include = _force_include()
38+
bundled = _bundled_preset_ids()
39+
40+
assert bundled, "expected at least one bundled preset in presets/catalog.json"
41+
for preset_id in bundled:
42+
assert force_include.get(f"presets/{preset_id}") == (
43+
f"specify_cli/core_pack/presets/{preset_id}"
44+
), f"bundled preset '{preset_id}' is missing from the wheel force-include list"
45+
46+
47+
def test_constitution_sync_is_bundled_and_shipped():
48+
# Explicit regression guard: constitution-sync was advertised as bundled
49+
# before it was added to the wheel force-include list.
50+
assert "constitution-sync" in _bundled_preset_ids()
51+
assert _force_include()["presets/constitution-sync"] == (
52+
"specify_cli/core_pack/presets/constitution-sync"
53+
)

‎tests/test_presets.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12549,3 +12549,21 @@ def test_wrap_composes_over_core_constitution(self, project_dir):
1254912549
assert layers[0]["strategy"] == "wrap"
1255012550
assert any("constitution-sync" in str(layer["path"]) for layer in layers)
1255112551
assert layers[-1]["source"] == "core (bundled)"
12552+
12553+
def test_resolved_content_embeds_core_and_sync_pass(self, project_dir):
12554+
"""resolve_content substitutes {CORE_TEMPLATE} so the effective command
12555+
contains both the bundled core body and the propagation pass."""
12556+
manager = PresetManager(project_dir)
12557+
manager.install_from_directory(self.PRESET_DIR, "0.15.0")
12558+
12559+
resolver = PresetResolver(project_dir)
12560+
content = resolver.resolve_content("speckit.constitution", "command")
12561+
assert content is not None
12562+
# {CORE_TEMPLATE} must be replaced, not left literal.
12563+
assert "{CORE_TEMPLATE}" not in content
12564+
# Core body is present (distinctive core-only heading).
12565+
assert "## Scope Guard" in content
12566+
# The wrapper's propagation pass is present and supersedes the guard.
12567+
assert "## Constitution Template Sync" in content
12568+
assert "supersedes the \"Scope Guard\" above" in content
12569+
assert "plan-template.md" in content

0 commit comments

Comments
 (0)