Skip to content

fix(templates): guard constitution command scope#3616

Open
BenBtg wants to merge 22 commits into
mainfrom
fix/896-constitution-scope-guard
Open

fix(templates): guard constitution command scope#3616
BenBtg wants to merge 22 commits into
mainfrom
fix/896-constitution-scope-guard

Conversation

@BenBtg

@BenBtg BenBtg commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

The constitution command could interpret mixed governance and implementation requests as permission to modify application artifacts. This adds an explicit governance-only scope guard, preserves out-of-scope intent as a suggested follow-up, and keeps follow-up wording integration-neutral so command-syntax behavior remains outside this fix.

Closes #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 .venv/bin/python -m pytest tests/integrations/test_integration_generic.py -q

AI Disclosure

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

This change and PR were authored autonomously on behalf of @BenBtg by GitHub Copilot (model: GPT-5.6 Sol).

Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 02f9e138-da58-4a60-93b9-eae659d2aa19
Copilot AI review requested due to automatic review settings July 21, 2026 17:37
@BenBtg
BenBtg requested a review from mnriem as a code owner July 21, 2026 17:37

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 safeguards to the constitution command.

Changes:

  • Defers implementation requests to suggested follow-up commands.
  • Adds regression coverage for the rendered guard.
Show a summary per file
File Description
templates/commands/constitution.md Adds scope and follow-up guidance.
tests/integrations/test_integration_generic.py Verifies rendered guard content.

Review details

Tip

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

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

Comment thread templates/commands/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: 02f9e138-da58-4a60-93b9-eae659d2aa19
Copilot AI review requested due to automatic review settings July 21, 2026 17:42

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: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread src/specify_cli/integrations/base.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: 02f9e138-da58-4a60-93b9-eae659d2aa19
Copilot AI review requested due to automatic review settings July 21, 2026 17:48
@BenBtg
BenBtg marked this pull request as draft July 21, 2026 17:48

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: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

Resolve generated command references with the active agent prefix instead of rewriting all slash-form text during post-processing.

Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 02f9e138-da58-4a60-93b9-eae659d2aa19
Copilot AI review requested due to automatic review settings July 22, 2026 13:15

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: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread src/specify_cli/integrations/base.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: 02f9e138-da58-4a60-93b9-eae659d2aa19
Copilot AI review requested due to automatic review settings July 22, 2026 13:23

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: 14/14 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment thread src/specify_cli/shared_infra.py Outdated
Comment thread templates/commands/constitution.md Outdated
Propagate dollar-style invocation prefixes when installing into projects without a default integration, and restrict constitution synchronization to Spec Kit-managed templates and commands.

Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 02f9e138-da58-4a60-93b9-eae659d2aa19
Copilot AI review requested due to automatic review settings July 22, 2026 13:30

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

Comments suppressed due to low confidence (1)

src/specify_cli/shared_infra.py:526

  • invoke_prefix is applied to token placeholders but not to the dynamic command helpers resolved immediately afterward. For Codex/ZCode installs, setup-tasks.sh and the prerequisite scripts therefore still embed /speckit-plan//speckit-specify even though $speckit-* is their native syntax. Pass the prefix through _resolve_dynamic_command_refs() and _format_speckit_command() as well, and add the dollar-style counterpart to the shared-script tests.
                    content = IntegrationBase.resolve_command_refs(
                        content, invoke_separator, invoke_prefix
                    )
                    content = _resolve_dynamic_command_refs(content, invoke_separator)
  • Files reviewed: 16/16 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread src/specify_cli/integrations/base.py Outdated
Use agent-native invocation prefixes in extension command registration and dynamic shared-script command hints.

Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 02f9e138-da58-4a60-93b9-eae659d2aa19
Copilot AI review requested due to automatic review settings July 22, 2026 13:37

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

Comments suppressed due to low confidence (1)

src/specify_cli/shared_infra.py:532

  • The native prefix is still not applied to the supported Python script variant. install_shared_infra(..., script_type="py") copies scripts/python/common.py unchanged, where format_speckit_command() hardcodes /; setup_tasks.py and check_prerequisites.py call it for their recovery hints. Thus Codex/ZCode projects initialized with --script py still print /speckit-* instead of $speckit-*. Propagate the prefix to the Python helper (or rewrite those calls during installation) and include py in the regression coverage.
                    content = _resolve_dynamic_command_refs(
                        content, invoke_separator, invoke_prefix
                    )
  • Files reviewed: 18/18 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread src/specify_cli/shared_infra.py Outdated

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: 20/20 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 02f9e138-da58-4a60-93b9-eae659d2aa19
Copilot AI review requested due to automatic review settings July 22, 2026 15:27

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: 20/20 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@BenBtg
BenBtg marked this pull request as ready for review July 22, 2026 17:01
@BenBtg
BenBtg requested a review from Copilot July 22, 2026 17:02

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: 20/20 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

BenBtg added 11 commits July 22, 2026 18:17
Limit synchronization to Spec Kit-managed files and describe deferred follow-ups without coupling the guard to agent-specific command syntax.

Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 02f9e138-da58-4a60-93b9-eae659d2aa19

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: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

Copilot AI review requested due to automatic review settings July 22, 2026 17:19

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

Comments suppressed due to low confidence (1)

templates/commands/constitution.md:36

  • This no longer renders a follow-up command in the integration's native syntax; it delegates syntax selection to the model. The generated constitution prompt therefore contains neither __SPECKIT_COMMAND_SPECIFY__ nor, for Codex/ZCode, the required $speckit-specify form, despite the PR description explicitly promising native $speckit-* rendering. Please restore a resolvable command-reference token and propagate each integration's invocation prefix through rendering, with rendered Codex/ZCode coverage.
4. Report the out-of-scope intent under **Suggested Follow-ups**, with the appropriate
   next command for the active integration (typically its specification command).
  • Files reviewed: 2/2 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

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