c_agri_trade/.agents/skills/up-defect-fix/SKILL.md

3.9 KiB

name description
up-defect-fix Review code from the current iteration and fix approved defects one at a time, including real-runtime API and browser-E2E portal findings, escalating to a Change Request whenever the root cause turns out to be an incomplete or wrong requirement rather than a coding mistake. Use this after up-code-generate has produced a story's implementation, during code review, QA, or UAT of the current iteration. This is Stage 14 (Construction) of the UP-AI v1.0 Process (00_prompts/AI_Native_Unified_Process_v1.md).

up-defect-fix — Stage 14 (Construction, per iteration)

Objective

Review and fix defects for the current iteration's code, and correctly distinguish a coding bug (fix in code, done) from a requirements gap (the FR/UC itself was incomplete or wrong — must be raised as a CR-xxx, not just patched).

When to invoke

  • After up-code-generate produces a story's implementation, as part of code review.
  • During QA or UAT of the current iteration, for any defect logged against iteration code.

Read first

  • defect_register.md / code_review_log.md (iteration-scoped)
  • Related source code
  • Related functional-reqs.md (the FR the defect's story implements)
  • Related TC-xxx test cases
  • Current iteration's iteration_surface_matrix.md

Procedure

Fix the next approved defect from the defect register.

Pick the first defect with Status = "Approved for Fix." Fix only that defect.

Rules:

  1. Do not introduce unrelated changes or refactor unrelated files.
  2. Preserve existing behavior unless the defect requires correction.
  3. Add a targeted regression test to prevent recurrence (coordinate with up-test-model-generate), then run the regression suite scoped to the affected UC-xxx/FR-xxx via scripts/run_tests.sh --scope uc-xxx before closing the defect.
  4. Update documentation if behavior changes.
  5. Update traceability if requirement coverage changes.
  6. If the defect exposes an unimplemented frontend/API/data/integration/runtime surface, update the surface matrix and treat it as a blocking integration finding until implemented or explicitly deferred by CR-xxx/DEC-xxx.
  7. Anti-Placeholder & Superficiality Defects: If code review, static analysis, or gate checks reveal that code, tests, or documentation were superficially implemented (e.g. placeholder stubs, zero-row workbooks, missing Bruno collections), classify this as a blocking defect. Such items cannot be bypassed or marked 'Delivered' until concrete implementation and dense verification evidence are supplied.

Before closing the defect, classify the root cause:

  • If the root cause is a coding error (logic bug, missed edge case the requirement already specified) → fix in code as normal.
  • If the root cause is that the requirement itself was incomplete, ambiguous, or wrong — do not just fix the code. Raise CR-xxx via up-change-request-impact, citing the FR-xxx/UC-xxx that needs correction, get its impact analyzed and approved, and only then apply the code fix alongside the requirement correction.

For the defect fix, provide: Defect ID, root cause, files changed, fix implemented, tests added/updated, verification steps, regression risk, requirement references.

Output expected

Code fix; updated defect register and traceability entries; a CR-xxx if the defect was requirements-rooted.

Exit criteria

Defect closed with root cause documented; real-runtime/API/browser-E2E regression evidence added where applicable; the affected surface matrix row is current; if requirements-rooted, the linked CR-xxx shows disposition Approved/Re-baselined/Verified.

Sample invocation

"Run up-defect-fix for DEF-002 (order status transitions to CANCELLED from an invalid state) — check whether this is a code bug or whether UC-003's status FSM itself is missing this transition rule."

Previous: up-code-generate. Next: up-traceability-gate (Gate 14.1). If requirements-rooted: up-change-request-impact.