From f90495f544c2e6e05cfb8f411ee7f13d4affe6f7 Mon Sep 17 00:00:00 2001 From: Chai Bot Date: Thu, 19 Nov 2026 13:10:00 +0000 Subject: [PATCH] fix(bugfix): scope verification to changed behavior and risk Select proportionate checks, reuse valid results, and require new regression coverage only where needed. Align the unattended coverage gate and direct workflow instructions without changing verification artifact paths. Assisted-by: Codex Signed-off-by: Chai Bot --- bugfix/README.md | 24 +++++++------- bugfix/SKILL.md | 2 +- bugfix/guidelines.md | 3 +- bugfix/skills/controller.md | 2 +- bugfix/skills/document.md | 7 ++-- bugfix/skills/test.md | 65 ++++++++++++++++++++----------------- bugfix/skills/unattended.md | 41 ++++++++++++----------- 7 files changed, 75 insertions(+), 69 deletions(-) diff --git a/bugfix/README.md b/bugfix/README.md index 14064bdb..e4698ce8 100644 --- a/bugfix/README.md +++ b/bugfix/README.md @@ -165,16 +165,16 @@ The Bug Fix Workflow follows this approach: ### Phase 5: Test (`/test`) -**Purpose**: Verify the fix and create regression tests. +**Purpose**: Verify the fix with change-proportionate checks and meaningful regression coverage. -- Create regression test that fails without fix, passes with fix -- Write comprehensive unit tests for modified code -- Run integration tests in realistic scenarios -- Execute full test suite to catch side effects -- Perform manual verification of original reproduction steps -- Check for performance or security impacts +- Inspect the diff and select the smallest useful existing checks +- Add or extend regression tests when warranted and existing coverage is insufficient +- For docs/configuration or no testable code path, use applicable content, schema, lint, render, or consumer checks +- Run wider suites, integration, manual, or performance checks when risk, repository requirements, or an explicit request justify them; preserve required security and generation checks +- Reuse results while tested inputs and environment are unchanged; rerun only checks affected by edits +- Record results, justified skips, and relevant unavailable checks honestly -**Output**: New test files + `.artifacts/bugfix/{issue}/verification.md` +**Output**: New or extended tests when needed + `.artifacts/bugfix/{issue}/verification.md` **When to use**: After implementing the fix. @@ -352,10 +352,10 @@ All workflow artifacts are organized in the `.artifacts/bugfix/{issue}/` directo ### Testing -- Regression tests are mandatory — every fix must include a test -- Test the test — verify it fails without the fix -- Run the full test suite, not just new tests -- Manual verification matters +- Add meaningful regression coverage when needed, not merely to change a test file +- Test new regression tests — verify they fail without the fix and pass with it +- Select checks proportionate to changed behavior and risk, honoring repository requirements +- Document skipped or unavailable checks without claiming they passed ### Documentation diff --git a/bugfix/SKILL.md b/bugfix/SKILL.md index d3d8c420..89575c05 100644 --- a/bugfix/SKILL.md +++ b/bugfix/SKILL.md @@ -1,6 +1,6 @@ --- name: bugfix -version: 0.10.0 +version: 0.11.0 description: >- Diagnostic and repair workflow that analyzes error logs, traces root causes, implements fixes, and verifies with regression tests. diff --git a/bugfix/guidelines.md b/bugfix/guidelines.md index afee157f..38f694c7 100644 --- a/bugfix/guidelines.md +++ b/bugfix/guidelines.md @@ -49,7 +49,8 @@ artifacts and published output from this workflow. ## Quality - Follow the project's existing coding standards and conventions -- Zero tolerance for test failures — fix them, don't skip them +- Investigate test failures with evidence; fix attributable regressions and + report unrelated failures or unavailable checks without claiming success ## Escalation diff --git a/bugfix/skills/controller.md b/bugfix/skills/controller.md index bf1f9c0f..0d0dd870 100644 --- a/bugfix/skills/controller.md +++ b/bugfix/skills/controller.md @@ -26,7 +26,7 @@ executing phases and handling transitions between them. Implement the minimal code change that resolves the root cause. 5. **Test** (`/test`) — `test.md` - Write regression tests, run the full suite, and verify the fix holds. + Verify the fix with change-proportionate checks and needed regression coverage. 6. **Review** (`/review`) — `review.md` Critically evaluate the fix and tests — look for gaps, regressions, and missed edge cases. diff --git a/bugfix/skills/document.md b/bugfix/skills/document.md index 544d17a3..1fc32a37 100644 --- a/bugfix/skills/document.md +++ b/bugfix/skills/document.md @@ -122,10 +122,9 @@ Use this format for the `## Title` section in `pr-description.md`: [Description of what was changed] ## Testing -- [X] Unit tests added -- [X] Integration tests pass -- [X] Manual verification complete -- [X] Full regression suite passes +[Applicable checks and results from verification.md, including reused coverage, +reasons for skipped checks, and any unavailable checks or unresolved failures. +Do not mark checks passed unless verified.] ## Files Changed - `path/to/file.go:123` - [description] diff --git a/bugfix/skills/test.md b/bugfix/skills/test.md index b44190ba..f85921c2 100644 --- a/bugfix/skills/test.md +++ b/bugfix/skills/test.md @@ -1,32 +1,37 @@ --- name: test -description: Verify a bug fix with comprehensive testing and create regression tests to prevent recurrence +description: Verify a bug fix with change-proportionate checks and meaningful regression coverage --- # Test & Verify Fix Skill -You are a thorough testing and verification specialist. Your mission is to verify that a bug fix works correctly and create comprehensive tests to prevent regression, ensuring the fix resolves the issue without introducing new problems. +Verify that the fix resolves the issue without introducing new problems, using checks proportionate to the changed behavior and risk. ## Your Role Systematically verify fixes and build test coverage that prevents recurrence. You will: -1. Create regression tests that prove the fix works -2. Run comprehensive unit and integration tests -3. Perform manual verification of the original reproduction steps -4. Validate performance and security impact +1. Inspect the diff, affected behavior, and repository validation requirements +2. Select the smallest useful existing checks and add regression coverage where needed +3. Expand verification only when risk or repository requirements justify it +4. Report results and meaningful gaps honestly ## Process -### Step 1: Create Regression Test +### Step 1: Select Checks and Regression Coverage -- Write a test that reproduces the original bug +- Inspect the diff and affected consumers; use the project's documented checks and test conventions +- Add or extend a meaningful regression test when changed behavior warrants it and existing coverage is insufficient +- For docs, configuration, or no testable code path, explain why no new test is needed; use applicable content, schema, lint, render, or consumer checks instead +- Reuse recorded results only while tested inputs and environment remain unchanged; after edits, rerun only affected checks +- Preserve repository-required security, authentication, tenant-isolation, release, generation, and safety checks +- When adding a regression test, reproduce the original bug - Verify the test **fails** without your fix (proves it catches the bug) - Verify the test **passes** with your fix (proves the fix works) - Use descriptive test names that reference the issue (e.g., `TestStatusUpdateRetry_Issue425`) - Follow project test conventions and patterns -### Step 2: Unit Testing +### Step 2: Targeted Unit Testing (When Applicable) - Test the specific functions/methods that were modified - Cover all code paths in the fix @@ -36,8 +41,9 @@ Systematically verify fixes and build test coverage that prevents recurrence. Yo - **Test all states/phases/conditions**: If the fix involves state-dependent logic, ensure tests cover ALL possible states, not just the common ones. For example, if fixing polling that stops on terminal phases, test all terminal phases (Stopped, Completed, Failed, Error), not just one or two. - **Test feature interactions**: If the fix involves multiple interacting features or configurations, test their combinations (e.g., pagination + polling together, not only separately) -### Step 3: Integration Testing +### Step 3: Integration Testing (When Justified) +- Run when affected component interactions, specific bug risk, repository requirements, or an explicit request warrant it - Test the fix in realistic scenarios with dependent components - Verify end-to-end behavior matches expectations - Test interactions with databases, APIs, or external systems @@ -45,21 +51,23 @@ Systematically verify fixes and build test coverage that prevents recurrence. Yo ### Step 4: Regression Testing -- Run the **entire** test suite to catch unintended side effects -- Verify no existing tests were broken by the changes +- Start with existing tests covering the changed behavior and affected consumers +- Run wider or full suites only for broad/shared blast radius, specific bug risk, repository-required contracts, or an explicit request +- Defer wider checks to CI only after verifying that CI covers them; do not assume it exists, is green, or will monitor and repair failures - If tests fail, investigate whether: - The test was wrong (update it) - The fix broke something (revise the fix) - Test needs updating due to intentional behavior change (document it) -### Step 5: Manual Verification +### Step 5: Manual Verification (When Justified) +- Use when automated checks do not establish the fix, or risk, repository requirements, or an explicit request warrant it - Manually execute the original reproduction steps from the reproduction report - Verify the expected behavior is now observed - Test related functionality to ensure no side effects - Test in multiple environments if applicable (dev, staging) -### Step 6: Performance Validation +### Step 6: Performance Validation (When Applicable) - If the fix touches performance-sensitive code, measure impact - Profile before/after if the bug was performance-related @@ -72,20 +80,21 @@ Systematically verify fixes and build test coverage that prevents recurrence. Yo - Check for common issues: SQL injection, XSS, CSRF, etc. - Ensure error messages don't leak sensitive information - Validate input handling and sanitization +- Focus on affected attack surfaces; run additional security checks when risk or repository requirements warrant them ### Step 8: Document Test Results -Create comprehensive test report at `.artifacts/bugfix/{issue}/verification.md` containing: +Write a concise report at `.artifacts/bugfix/{issue}/verification.md` containing applicable results: - **Test Summary**: Overview of testing performed -- **Regression Test**: Location and description of new test(s) -- **Unit Test Results**: Pass/fail status, coverage metrics +- **Regression Coverage**: Existing or new tests, or why no new test was needed +- **Unit Test Results**: Commands and pass/fail status, coverage metrics if collected - **Integration Test Results**: End-to-end validation results -- **Full Suite Results**: Status of all project tests +- **Wider Checks**: Results, or concise reasons for skipping; distinguish verified CI coverage from local results - **Manual Testing**: Steps performed and observations - **Performance Impact**: Before/after metrics (if applicable) - **Security Review**: Findings from security check -- **Known Limitations**: Any edge cases not fully addressed +- **Known Limitations**: Relevant unavailable checks, unresolved failures, and unverified behavior - **Recommendations**: Follow-up work or monitoring needed ### Step 9: Report Results to the User @@ -95,22 +104,21 @@ After writing `.artifacts/bugfix/{issue}/verification.md`: 1. **Tell the user where the file was written** — include the full path 2. **Summarize the results inline** — don't make the user open the file to find out what happened. Include at minimum: - Overall pass/fail status - - Number of tests run, passed, and failed - - Any new regression tests added (file and test name) + - Applicable checks and results; test counts when available + - Regression coverage added or reused, or why none was needed - Any failures or concerns that need attention - Recommended next steps (proceed to `/document`, revisit `/fix`, etc.) ## Output -- New test files in the project repository +- New or extended regression tests when needed - `.artifacts/bugfix/{issue}/verification.md` ## Best Practices -- **Regression tests are mandatory** — every bug fix must include a test that would catch recurrence +- **Meaningful coverage** — add tests for uncovered changed behavior, not just to change a test file - **Test the test** — verify your new test actually fails without the fix -- **Don't skip the full suite** — even if unit tests pass, integration might reveal issues -- **Manual testing matters** — automated tests don't always catch UX issues +- **Scale to risk** — full suites and manual checks are not automatic for every fix - **Document failed tests** — if tests fail, that's valuable information ## Error Handling @@ -119,21 +127,20 @@ If tests fail unexpectedly: - Determine if the failure is in the new test or an existing test - Check if the fix introduced a regression +- Gather evidence before attributing failures; compare with the unchanged baseline or inspect diagnostics. Do not label a failure unrelated merely to proceed, or fix unrelated bugs - **Classify before retrying**: is this a code bug (your fix is wrong) or an infrastructure error — a failure outside your test assertions that reproduces without your changes (e.g., envtest conflicts, connection timeouts) - Code bug: document the failure, revise the fix, and retry -- Infrastructure error: retry up to `max_retries` more times without returning to - `/fix`. If still failing, document what failed and why it's environmental, - then proceed to the next phase. +- Infrastructure error: retry only when conditions changed or evidence suggests a transient failure, up to `max_retries`, without returning to `/fix`. Otherwise document the blocker and supporting evidence before proceeding; never report an unavailable check as passed ## When This Phase Is Done Report your results: - How many tests were added and their results -- Whether the full test suite passes +- Which applicable checks passed, failed, were reused, skipped, or unavailable, and why - Where the verification report was written - Your proposed plan diff --git a/bugfix/skills/unattended.md b/bugfix/skills/unattended.md index e157bc81..2dbccb84 100644 --- a/bugfix/skills/unattended.md +++ b/bugfix/skills/unattended.md @@ -70,8 +70,8 @@ Run these phases in order. Read each skill from the same `skills/` directory: | Order | Phase | Skill file | Done signal | |-------|-------|------------|-------------| | 1 | `/diagnose` | `diagnose.md` | Root cause analysis written | -| 2 | `/fix` | `fix.md` | Code and test changes in working tree; implementation notes written | -| 3 | `/test` | `test.md` | All tests pass; verification report written | +| 2 | `/fix` | `fix.md` | Fix and needed coverage in working tree; implementation notes written | +| 3 | `/test` | `test.md` | Applicable checks pass or gaps documented; verification report written | | 4 | `/review` | `review.md` | Review findings written | | 5 | Lint | *(see below)* | Lint passes cleanly | | 6 | `/document` | `document.md` | Documentation artifacts written | @@ -107,15 +107,11 @@ unattended: ### /fix -- **Unit tests are mandatory.** You MUST modify or create at least one test - file (e.g., `*_test.go`, `test_*.py`, `*.test.js`, `*.spec.ts`). Add - tests that cover the changed behavior — both the happy path and the - specific bug scenario. Do not defer tests to a later step. The `/test` - phase will verify that test files were actually modified; if they weren't, - you will be sent back here. - **Exception:** If the project has no test framework or the bug is in - infrastructure/configuration where no testable code path exists, document - why tests were not added in implementation notes and proceed. +- **Regression coverage must be meaningful.** Add or extend tests for + changed behavior when warranted and existing coverage is insufficient, + following `test.md`. Document reused coverage or why no new test is + needed (e.g., docs/configuration or no testable code path) in implementation + notes, along with applicable alternative checks. - **Confidence threshold**: If you proceeded past a low-confidence diagnosis, the 80% escalation threshold from `guidelines.md` does not apply to the fix phase. Attempt the fix based on your best-effort diagnosis. The @@ -131,11 +127,10 @@ unattended: ### /test -**Gate check**: Before running tests, verify that you actually added or -modified at least one test file (e.g., `*_test.go`, `test_*.py`, -`*.test.js`, `*.spec.ts`). If no test files were modified, **stop and -return to /fix** — do not proceed. This gate-check return counts toward -the `/test` retry limit (`max_retries`). +**Gate check**: Verify coverage of the changed behavior or the documented +rationale for no new test, using `test.md` to select proportionate checks. +Return to `/fix` only for an actual coverage gap, not solely because no test +file changed; justified skips do not consume the retry budget. ### /document @@ -146,9 +141,11 @@ unresolved concerns so the human reviewer knows to look more carefully. ### Lint Run the project's lint and format checks after `/review` passes. +Use the smallest applicable documented scope unless the repository requires +broader checks. Reuse still-valid results as described in `test.md`. -**If `lint_command` is configured**: Run it, fix all issues, repeat until -it exits cleanly. +**If `lint_command` is configured**: Run it unless a still-valid result exists; +investigate failures and rerun affected checks after attributable fixes. **If `lint_command` is not configured**, detect it using this priority order: @@ -167,7 +164,8 @@ If no lint command can be detected by any of the above methods, skip this phase and note "lint: skipped (no linter detected)" in the completion report. -Fix all reported issues before proceeding. +Investigate failures as described in `test.md`; document unrelated or +unavailable checks with evidence rather than fixing unrelated bugs. ### Session Context @@ -214,8 +212,9 @@ Each retry loop is capped at `max_retries` (default: 3): (see `test.md` Error Handling). - **Code bug**: return to `/fix`, rework, re-run `/test`. Repeat up to `max_retries` times; if still failing, document and continue to `/review`. - - **Infrastructure error**: do NOT return to `/fix`. Retry `/test` up to - `max_retries` more times. If still failing, document and continue to `/review`. + - **Infrastructure error**: do NOT return to `/fix`. Retry only under the + conditions in `test.md`, up to `max_retries`; otherwise document the + failure and continue to `/review` without claiming validation passed. - `/review` verdict is "fix is inadequate" or finds CRITICAL/HIGH severity issues → return to `/fix`, revise, re-run `/test` and `/review` (both phases must pass on retry, since the review triggered the rework).