Skip to content

Commit 8c816fa

Browse files
authored
fix: guard constitution command against feature execution (#3646)
* fix: guard constitution command scope Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: be3f0d7d-2774-4ba2-b741-efbb4870148a * fix: render deferred command per integration Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: be3f0d7d-2774-4ba2-b741-efbb4870148a * fix: defer all lean non-governance intents Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: be3f0d7d-2774-4ba2-b741-efbb4870148a
1 parent fb7dc0c commit 8c816fa

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

presets/lean/commands/speckit.constitution.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ description: Create or update the project constitution.
88
$ARGUMENTS
99
```
1010

11+
## Scope Guard
12+
13+
This command's own work is limited to creating or updating the project constitution and
14+
propagating constitution-driven changes to dependent Spec Kit artifacts.
15+
16+
- Classify every part of the user input as constitution content or a separate non-governance
17+
intent. Feature implementation, code generation, refactoring, build, and deployment requests
18+
are examples of non-governance intents.
19+
- You **MUST NOT** execute any non-governance intent. Defer each one to `Next Actions`.
20+
- You **MUST NOT** create, modify, or delete application source files or other artifacts
21+
unrelated to the constitution workflow.
22+
- If an instruction could be either constitution content or a non-governance intent, ask for
23+
clarification before making changes.
24+
- After updating the constitution, list each deferred intent in a `Next Actions` section with an
25+
appropriate follow-up Spec Kit command, such as `__SPECKIT_COMMAND_SPECIFY__`, but do not
26+
invoke it.
27+
- Omit `Next Actions` when there are no non-governance intents.
28+
1129
## Outline
1230

1331
1. Create or update the project constitution and store it in `.specify/memory/constitution.md`.

templates/commands/constitution.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ $ARGUMENTS
1414

1515
You **MUST** consider the user input before proceeding (if not empty).
1616

17+
## Scope Guard
18+
19+
This command's own work is limited to updating the project constitution and propagating
20+
constitution-driven changes to the dependent artifacts identified in this command.
21+
22+
- Classify every part of the user input as either constitution content or a separate,
23+
non-governance intent.
24+
- If the input includes feature implementation, code generation, refactoring, building, or
25+
deployment requests, you **MUST NOT** execute them. Extract them as deferred intents instead.
26+
- You **MUST NOT** create, modify, or delete application source files, feature routes,
27+
components, tests, deployment files, or other artifacts unrelated to the constitution
28+
workflow and its required propagation.
29+
- If it is unclear whether an instruction is constitution content, ask for clarification before
30+
making changes.
31+
- After completing the constitution update, include a `Next Actions` section for each deferred
32+
intent. List the original intent and suggest the appropriate follow-up Spec Kit command, such
33+
as `__SPECKIT_COMMAND_SPECIFY__`, without invoking it.
34+
- If there are no non-governance intents, omit the `Next Actions` section.
35+
1736
## Pre-Execution Checks
1837

1938
**Check for extension hooks (before constitution update)**:
@@ -104,6 +123,7 @@ Follow this execution flow:
104123
- New version and bump rationale.
105124
- Any files flagged for manual follow-up.
106125
- Suggested commit message (e.g., `docs: amend constitution to vX.Y.Z (principle additions + governance update)`).
126+
- A `Next Actions` section for any deferred non-governance intents.
107127
108128
Formatting & Style Requirements:
109129

tests/test_presets.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5381,6 +5381,9 @@ def test_disable_corrupted_registry_entry(self, project_dir, pack_dir):
53815381

53825382

53835383
LEAN_PRESET_DIR = Path(__file__).parent.parent / "presets" / "lean"
5384+
CORE_CONSTITUTION_COMMAND = (
5385+
Path(__file__).parent.parent / "templates" / "commands" / "constitution.md"
5386+
)
53845387

53855388
LEAN_COMMAND_NAMES = [
53865389
"speckit.specify",
@@ -5391,6 +5394,31 @@ def test_disable_corrupted_registry_entry(self, project_dir, pack_dir):
53915394
]
53925395

53935396

5397+
@pytest.mark.parametrize(
5398+
"command_path",
5399+
[
5400+
CORE_CONSTITUTION_COMMAND,
5401+
LEAN_PRESET_DIR / "commands" / "speckit.constitution.md",
5402+
],
5403+
ids=["core", "lean"],
5404+
)
5405+
def test_constitution_commands_guard_against_non_governance_work(command_path):
5406+
"""Constitution commands defer non-governance work instead of executing it."""
5407+
content = command_path.read_text()
5408+
lower_content = content.lower()
5409+
normalized_content = " ".join(lower_content.split())
5410+
5411+
assert "## Scope Guard" in content
5412+
assert "**MUST NOT**" in content
5413+
assert "Classify every part" in content
5414+
assert "application source files" in content
5415+
assert "non-governance intent" in content
5416+
assert "`Next Actions`" in content
5417+
assert "__SPECKIT_COMMAND_SPECIFY__" in content
5418+
assert "omit" in lower_content
5419+
assert "do not invoke it" in normalized_content or "without invoking it" in normalized_content
5420+
5421+
53945422
class TestLeanPreset:
53955423
"""Tests for the lean preset that ships with the repo."""
53965424

0 commit comments

Comments
 (0)