Visitar URL original
Add lifecycle hooks to the bug workflow by rohanz · Pull Request #4878 · github/spec-kit · GitHub
Skip to content

Add lifecycle hooks to the bug workflow - #4878

Merged
mnriem merged 5 commits into
github:mainfrom
rohanz:feat/4799-bug-hook-events
Oct 8, 2026
Merged

mnriem merged 5 commits into
github:mainfrom
rohanz:feat/4799-bug-hook-events

Conversation

@rohanz

@rohanz rohanz commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Description

Extensions could register hooks for the bug workflow. The assess, fix and test commands never check for them.

This PR adds both before and after hooks to all three of those commands, following the existing core command pattern. Before-hooks run only after prerequisites are resolved, and after-hooks run only after the relevant report is written up. The hook events, and their timing, are all documented.

Closes #4799

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests - 9,841 passed, 264 skipped
  • Tested with a sample project (if applicable)

The full suite ran in the candidate checkout's virtual env, with:
env -u FORCE_COLOR UV_NO_SYNC=1 uv run --no-sync python -m pytest tests -q

Live agent tests

Claude Code 2.1.294, using Fable 5.1 at medium effort, ran assess → fix → test on a deliberately broken sample project, both with and without hooks.

All six mandatory hooks executed in the expected order. Logs verified that before-hooks ran before the work and after-hooks ran after report creation. Both workflows corrected the bug and passed the sample tests.

In one assessment run, the agent omitted the optional-hook offer and incorrectly claimed it had shown it. Mandatory hooks still executed correctly.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure:
Codex CLI (GPT-6.1 Sol, medium reasoning effort) and Claude Code (Fable 5.1, medium effort) were used for implementation, documentation, tests, automated review. Claude code also ran the sample project workflows, with Codex checking recorded results. Agents worked autonomously on tasks I requested. Reviewed code myself.

rohanz and others added 2 commits October 8, 2026 09:54
The bundled bug extension's assess, fix, and test commands did not check
`.specify/extensions.yml` for hooks, so a manifest registering
`before_bug_assess` passed validation but the hook never fired. Add the
standard pre- and post-execution hook blocks used by the core commands to
all three bug commands, defining `before_bug_assess`/`after_bug_assess`,
`before_bug_fix`/`after_bug_fix`, and `before_bug_test`/`after_bug_test`.

Pre-hooks run after slug resolution and prerequisites so `BUG_SLUG` and
`BUG_DIR` are available from the command context; the assess command
ensures `BUG_DIR` exists before checking hooks. Post-hooks run after each
report is written and before the completion report. The blocks keep the
core semantics: mandatory hooks are invoked and awaited, optional hooks are
presented, disabled and conditional hooks are handled as in core, an
unreadable extensions.yml is reported rather than skipped silently, and
behavior is unchanged when no hooks are registered. The bug extension still
registers no hooks of its own.

Document the six events in the extension API reference, the development
and user guide event catalogs, the bug extension README, and the agentic
bug-fix reference. Add text-contract tests that pin hook placement,
context, core semantics, the assess ordering, and the documentation; they
fail on main and pass with this change. Hook execution remains
prompt-driven, so these tests prove the prompt contract, not that a given
agent runs the hook.

Closes github#4799

Assisted-by: Codex CLI (model: GPT-6.1 Sol, autonomous)
Assisted-by: Claude Code (model: Claude Fable 5.1, autonomous)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Follow-up to the bug-command lifecycle hook events, addressing review
findings on the prompt text and the supporting test:

- Dedent the "Report back" bullets in the three command templates now
  that the step is a top-level Completion Report section, and separate
  them from the lead-in with a blank line.
- Reword the hook-context sentences in the templates, bug README,
  Extension API Reference, and agentic-bugfix docs: hooks are prompts
  run in the same session that reuse the already-stated BUG_SLUG,
  BUG_DIR and (for post-hooks) the written report from the
  conversation; no variables are injected.
- Clarify the assess guardrail for unintelligible reports: still write
  assessment.md with verdict `invalid`, run the Mandatory
  Post-Execution Hooks, then stop after the Completion Report.
- Rename the hook-registration test to
  test_bug_hook_event_names_are_accepted_and_registered, parametrize it
  over all six events, and document that manifest validation has no
  event-name allow-list, so this is an acceptance guard rather than
  regression evidence.

The Pre-Execution Checks and Mandatory Post-Execution Hooks blocks
otherwise remain verbatim copies of the core lifecycle contract,
including their fenced-block style. Hook execution remains
prompt-driven.

Refs github#4799

Assisted-by: Codex CLI (model: GPT-6.1 Sol, autonomous)
Assisted-by: Claude Code (model: Claude Fable 5.1, autonomous)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@rohanz
rohanz requested a review from mnriem as a code owner October 8, 2026 11:19
Keep the bundled catalog and manifest aligned so installed extensions receive the changes and the version guard passes.

Assisted-by: Codex (model: GPT-6.1 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.

🟡 Changes recommended

The bugfix bundle still pins bug extension 1.0.0, causing bundle installation to reject the new 1.0.1 manifest.

1 open finding
What changed in this PR

Adds lifecycle hooks around the bundled bug workflow’s assess, fix, and test commands.

Changes:

  • Adds six before/after hook events.
  • Documents hook timing and configuration.
  • Adds prompt-contract tests and bumps the extension to 1.0.1.
File Description
tests/​extensions/​bug/​test_bug_hooks.py Tests hook placement and semantics.
extensions/​EXTENSION-USER-GUIDE.md Lists bug hook events.
extensions/​EXTENSION-DEVELOPMENT-GUIDE.md Documents extension hook points.
extensions/​EXTENSION-API-REFERENCE.md Defines event timing and context.
extensions/​catalog.json Bumps the catalog version.
extensions/​bug/​README.md Adds hook usage documentation.
extensions/​bug/​extension.yml Bumps the manifest version.
extensions/​bug/​commands/​speckit.bug.test.md Adds verification hooks.
extensions/​bug/​commands/​speckit.bug.fix.md Adds remediation hooks.
extensions/​bug/​commands/​speckit.bug.assess.md Adds assessment hooks.
docs/​reference/​agentic-bugfix.md Documents workflow hook support.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread extensions/catalog.json
@mnriem

mnriem commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback and fix test & lint errors

Update the extension pin and bundle release metadata so the built-in bundle installs the shipped extension instead of rejecting the version mismatch.

Assisted-by: Codex (model: GPT-6.1 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.

🟢 Approval recommended

Hook contracts, documentation, version pins, and focused tests consistently satisfy the linked issue’s acceptance criteria.

1 open finding

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@mnriem

mnriem commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

@rohanz

rohanz commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Updated the bugfix bundle’s extension pin and bundle version/catalog metadata in 6327c8a. All CI checks now pass.

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.

🟡 Changes recommended

The assessment command changes invalid-report behavior even when no hooks are registered, contrary to the stated acceptance criterion.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread extensions/bug/commands/speckit.bug.assess.md Outdated
@mnriem

mnriem commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

Restore the existing invalid-report guardrail and make ingestion stop before report creation or post-hooks. Document that before-hooks can already have run and pin the prompt contract.

Assisted-by: Codex (model: GPT-6.1 Sol, autonomous)
@rohanz

rohanz commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in fd494a1. Unintelligible reports stop without creating an assessment or running after-hooks. Added regression coverage and checked sample workflows with and without hooks. Local checks passed; the latest CI runs are awaiting approval.

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.

🟢 Approval recommended

The implementation matches the requested lifecycle timing, preserves established hook semantics, and includes focused contract coverage.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@mnriem
mnriem merged commit f545e4c into github:main Oct 8, 2026
15 checks passed
@mnriem

mnriem commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

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.

[Feature]: Hook events for the bundled bug extension commands

3 participants