Skip to content

fix: guard constitution command against feature execution#3646

Draft
BenBtg wants to merge 3 commits into
mainfrom
benbtg-fix-896-constitution-scope-guard
Draft

fix: guard constitution command against feature execution#3646
BenBtg wants to merge 3 commits into
mainfrom
benbtg-fix-896-constitution-scope-guard

Conversation

@BenBtg

@BenBtg BenBtg commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

Mixed governance and feature directives can cause /speckit.constitution to modify application code while updating project governance. This adds an explicit scope guard to both the default and lean constitution prompts so non-governance intents are deferred to a conditional Next Actions section instead of executed.

The guard preserves constitution-driven dependent artifact updates and the existing user-controlled handoff. Native per-agent tool restrictions and guards for other commands remain separate follow-up work.

Fixes: #896

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest
  • Tested with a sample project (if applicable)
  • Ran targeted constitution and lean preset tests with .venv/bin/python -m pytest tests/test_presets.py -q -k 'constitution_commands_guard or TestLeanPreset'

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

Implemented and prepared on behalf of @BenBtg by GitHub Copilot (model: GPT-5.6 Sol, autonomous). Copilot reviewed issue #896, updated the prompts and regression tests, and ran the targeted test suite.

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
Copilot AI review requested due to automatic review settings July 22, 2026 13:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds governance-only scope guards to constitution commands, deferring feature requests to follow-up actions.

Changes:

  • Guards core and lean constitution prompts against non-governance work.
  • Adds regression assertions for guard wording.
  • Preserves constitution-dependent artifact synchronization.
Show a summary per file
File Description
templates/commands/constitution.md Adds the core scope guard and deferred actions.
presets/lean/commands/speckit.constitution.md Adds equivalent lean-preset protection.
tests/test_presets.py Verifies both prompts contain guard directives.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Medium

Comment thread templates/commands/constitution.md Outdated
Comment thread presets/lean/commands/speckit.constitution.md Outdated
Comment thread tests/test_presets.py Outdated
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
Copilot AI review requested due to automatic review settings July 22, 2026 13:26
@BenBtg

BenBtg commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review round in commit 02fd60c: deferred follow-up commands now use __SPECKIT_COMMAND_SPECIFY__ in both prompt sources, and the regression test requires the placeholder while remaining whitespace-tolerant. Targeted constitution and lean preset tests pass.

Posted on behalf of @BenBtg by GitHub Copilot (model: GPT-5.6 Sol, autonomous).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread presets/lean/commands/speckit.constitution.md Outdated
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
Copilot AI review requested due to automatic review settings July 22, 2026 13:28
@BenBtg

BenBtg commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the latest review in commit 9fd5b39: the lean guard now classifies every input part and defers every non-governance intent, while retaining feature and build categories as examples. The shared regression assertion now enforces this rule for both prompts.

Posted on behalf of @BenBtg by GitHub Copilot (model: GPT-5.6 Sol, autonomous).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constitution command: scope ambiguity allows unintended feature execution; add explicit guard

3 participants