|
| 1 | +## BugCmd (Create Bug Report) |
| 2 | + |
| 3 | +```yaml |
| 4 | +--- |
| 5 | +description: Create a new BUG-<ASPECT>-XXX CANARY + actionable bug report from natural-language input; enforce best-practice bug reporting; no-mock/no-simulate |
| 6 | +command: BugCmd |
| 7 | +version: 1.0 |
| 8 | +subcommands: [bug] |
| 9 | +scripts: |
| 10 | + sh: .canary/scripts/create-bug.sh |
| 11 | +outputs: |
| 12 | + - bug_report_markdown: .canary/bugs/<BUG-ID>-<slug>/report.md |
| 13 | + - summary_json: STDOUT (unwrapped JSON; strict schema below) |
| 14 | +runtime_guarantees: |
| 15 | + no_mock_data: true |
| 16 | + no_simulation_of_results: true |
| 17 | + canary_logging: required_when(context_usage>=0.7 || on_milestones) |
| 18 | +defaults: |
| 19 | + bugs_root: .canary/bugs |
| 20 | + template_report: .canary/templates/bug-report-template.md |
| 21 | + id_lockfile: .canary/.bug.id.lock |
| 22 | + bug_id_regex: '^BUG-[A-Za-z]+-[0-9]{3}$' |
| 23 | + aspect_vocab: ["API","CLI","Engine","Storage","Security","Docs","Frontend","Data","Infra"] |
| 24 | + severity_vocab: ["S1-Critical","S2-High","S3-Medium","S4-Low"] |
| 25 | + priority_vocab: ["P0","P1","P2","P3"] |
| 26 | + status_vocab: ["OPEN","IN_PROGRESS","FIXED","VERIFIED","WONTFIX","DUPLICATE","NOTABUG","CANNOT_REPRO","BLOCKED"] |
| 27 | + repro_target_samples: 5 |
| 28 | +--- |
| 29 | +``` |
| 30 | + |
| 31 | +### 1) Inputs |
| 32 | + |
| 33 | +* **User Arguments (raw):** `$ARGUMENTS` — natural‑language defect report from user/agent. |
| 34 | + Optional flags: `--title "..."`, `--aspect <ASPECT>`, `--severity S1..S4`, `--priority P0..P3`, `--labels <csv>`, `--related <BUG-ID|REQ-ID>...`. |
| 35 | + **MANDATORY:** If `$ARGUMENTS` is empty → `ERROR_DESCRIPTION_REQUIRED()`. |
| 36 | + |
| 37 | +### 2) Preconditions & Resolution |
| 38 | + |
| 39 | +1. **Paths/Gate:** Ensure `bugs_root` & `template_report` exist → else `ERROR_PATH_MISSING(path)`. |
| 40 | +2. **Script/Gate:** Ensure `.canary/scripts/create-bug.sh` is executable → else `ERROR_SCRIPT_MISSING(path)`. |
| 41 | +3. **Aspect detection:** Classify to `aspect_vocab` using cues in input; if uncertain default **API** and record `aspect_confidence:"low"`. |
| 42 | +4. **Duplicate check (must run):** |
| 43 | + |
| 44 | + ```bash |
| 45 | + canary grep "<key terms from title/description>" |
| 46 | + ``` |
| 47 | + |
| 48 | + Identify candidate duplicates (same summary keywords; same files/stack; same component). If a high‑similarity existing BUG is found, return as `DUPLICATE_CANDIDATE` with links; **do not create a new ID** unless user insists. Bugzilla guidance: check for existing reports; one issue per bug. ([Bugzilla][1]) |
| 49 | +5. **ID generation (collision‑safe):** Acquire `id_lockfile`; scan `bugs_root` for `BUG-<ASPECT>-NNN`; pick next zero‑padded NNN; if dir exists, increment & retry; release lock. |
| 50 | + |
| 51 | +### 3) Planning & Parallelism |
| 52 | + |
| 53 | +Use a Work‑DAG with concurrency groups; **join** before shared writes (no speculative steps). |
| 54 | + |
| 55 | +* **CG‑1 Parse:** title, 5W’s (who/what/when/where/why), severity/priority hints, environment, logs. MoT recommends clear, audience‑appropriate storytelling with key elements. ([Ministry of Testing][2]) |
| 56 | +* **CG‑2 Deduplicate:** run `canary grep` and compute similarity. |
| 57 | +* **CG‑3 Create:** run script to scaffold folder + `report.md`. |
| 58 | +* **CG‑4 Author:** fill **report.md** sections (see §4) strictly from facts; **no speculation**; separate *Expected*/*Actual*; provide minimal reproducible steps and environment. Bugzilla emphasizes clear summary, precise steps, expected vs actual, and additional info. ([Bugzilla][1]) |
| 59 | +* **CG‑5 Register:** write CANARY token; update index if used (e.g., `.canary/bugs/index.md`). |
| 60 | + |
| 61 | +### 4) Behavior (must do; never simulate) |
| 62 | + |
| 63 | +* **Run the real script**; do **not** fabricate paths, line numbers, or IDs. |
| 64 | +* **One issue per bug**; split unrelated issues into separate BUG IDs. ([Bugzilla][1]) |
| 65 | +* **Required sections in `report.md` (exact headings):** |
| 66 | + |
| 67 | + 1. **Bug Summary** (≤ ~10 words, problem‑focused; not a solution). ([Bugzilla][1]) |
| 68 | + 2. **Environment** (app version/commit, OS & version, device, browser/version, locale, data/profile flags). |
| 69 | + 3. **Preconditions** (state/setup needed). |
| 70 | + 4. **Steps to Reproduce** (numbered, minimal but complete; include key interactions). ([Bugzilla][1]) |
| 71 | + 5. **Expected Result** / **Actual Result** (exact message, stack, screenshots/logs refs; facts ≠ speculation). ([Bugzilla][1]) |
| 72 | + 6. **Reproducibility** (e.g., `3/5` attempts; note “intermittent” & conditions). ([Bugzilla][1]) |
| 73 | + 7. **Scope & Impact** (user/business impact; data loss, security, perf). |
| 74 | + 8. **Regression/First‑Seen** (version/build range; suspected change / pushlog if known). ([Bugzilla][1]) |
| 75 | + 9. **Workarounds** (if any). |
| 76 | + 10. **Attachments** (sanitized logs, screenshots, reduced testcase URL/path). Bugzilla suggests reduced testcases for web issues. ([Bugzilla][1]) |
| 77 | + 11. **Related/Dependencies** (BUG/REQ links). |
| 78 | + 12. **Next Actions (Triage)** (owner/team, first fix ideas, test to add). |
| 79 | +* **Tone & brevity:** Be factual, avoid blame; right‑sized detail for dev audience; include visuals where useful. ([Ministry of Testing][2]) |
| 80 | + |
| 81 | +**CANARY token (paste into nearest code touchpoint or failing test):** |
| 82 | + |
| 83 | +```go |
| 84 | +// CANARY: BUG=BUG-<ASPECT>-NNN; TITLE="<ShortProblemSummary>"; |
| 85 | +// ASPECT=<ASPECT>; STATUS=OPEN; |
| 86 | +// SEVERITY=<S1|S2|S3|S4>; PRIORITY=<P0|P1|P2|P3>; |
| 87 | +// REPRO=<k>/<n>; UPDATED=<YYYY-MM-DD> |
| 88 | +``` |
| 89 | + |
| 90 | +### 5) CANARY Snapshot Protocol (compact; low‑token) |
| 91 | + |
| 92 | +Emit after **ID selection** and after **report write**: |
| 93 | + |
| 94 | +```bash |
| 95 | +canary log --kind state --data '{ |
| 96 | + "t":"<ISO8601>","s":"bug|id|write", |
| 97 | + "f":[[".canary/bugs/<BUG-ID>-<slug>/report.md",1,999]], |
| 98 | + "k":["bug:<BUG-ID>","title:<slug>","aspect:<ASPECT>","sev:<S#>","prio:<P#>","repro:<k>/<n>"], |
| 99 | + "fp":["<disproven assumption>"], # prior false positives to avoid retrying failures |
| 100 | + "iss":["<linked-REQ-IDs-or-n/a>"], |
| 101 | + "nx":["triage","assign","create failing test"] |
| 102 | +}' |
| 103 | +``` |
| 104 | + |
| 105 | +### 6) Output Contract (strict) |
| 106 | + |
| 107 | +Return artifacts **in order** (JSON **not** in code fences). |
| 108 | +**A. BUG_REPORT_MARKDOWN** — delimiters: |
| 109 | +`=== BUG_REPORT_MARKDOWN BEGIN ===` … `=== BUG_REPORT_MARKDOWN END ===` |
| 110 | + |
| 111 | +**B. SUMMARY_JSON (unwrapped) — schema** |
| 112 | + |
| 113 | +```json |
| 114 | +{ |
| 115 | + "ok": true, |
| 116 | + "bug_id": "BUG-API-123", |
| 117 | + "title": "Login fails on first attempt", |
| 118 | + "aspect": "API", |
| 119 | + "status": "OPEN", |
| 120 | + "severity": "S2-High", |
| 121 | + "priority": "P1", |
| 122 | + "repro": {"success": 3, "attempts": 5, "rate": 0.6}, |
| 123 | + "env": { |
| 124 | + "app_version": "v1.9.0+abcd123", |
| 125 | + "os": "macOS 14.5", |
| 126 | + "browser": "Chrome 128", |
| 127 | + "device": "MBP 14 M2", |
| 128 | + "locale": "en-US" |
| 129 | + }, |
| 130 | + "paths": { |
| 131 | + "dir": ".canary/bugs/BUG-API-123-login-fails", |
| 132 | + "report": ".canary/bugs/BUG-API-123-login-fails/report.md" |
| 133 | + }, |
| 134 | + "duplicates": [{"bug_id":"BUG-API-097","score":0.84,"reason":"same stack signature"}], |
| 135 | + "token_suggestion": "// CANARY: BUG=BUG-API-123; TITLE=\"Login fails on first attempt\"; ASPECT=API; STATUS=OPEN; SEVERITY=S2; PRIORITY=P1; REPRO=3/5; UPDATED=2025-10-18", |
| 136 | + "gates": { |
| 137 | + "one_issue_only": "pass|fail", |
| 138 | + "summary_short_problem_focused": "pass|fail", |
| 139 | + "steps_present": "pass|fail", |
| 140 | + "expected_actual_present": "pass|fail", |
| 141 | + "env_present": "pass|fail", |
| 142 | + "repro_present": "pass|fail", |
| 143 | + "privacy_sanitized": "pass|fail", |
| 144 | + "duplicate_checked": "pass|fail" |
| 145 | + }, |
| 146 | + "canary": { "emitted": true, "last_id": "<id-or-n/a>" } |
| 147 | +} |
| 148 | +``` |
| 149 | + |
| 150 | +### 7) Validation Gates (compute & report) |
| 151 | + |
| 152 | +* **One‑Issue Gate:** report addresses exactly one problem. ([Bugzilla][1]) |
| 153 | +* **Summary Gate:** ~10‑word, problem‑focused title. ([Bugzilla][1]) |
| 154 | +* **Steps Gate:** numbered, precise, minimal repro steps. ([Bugzilla][1]) |
| 155 | +* **Expected/Actual Gate:** both sections present; facts separated from speculation. ([Bugzilla][1]) |
| 156 | +* **Env Gate:** OS/browser/app version captured. ([Bugzilla][1]) |
| 157 | +* **Repro Gate:** `k/n` provided; note intermittent if needed. ([Bugzilla][1]) |
| 158 | +* **Attachments Gate:** logs/screenshots or reduced testcase linked when useful. ([Bugzilla][1]) |
| 159 | +* **Duplicate Gate:** similarity search run & recorded. |
| 160 | +* **Privacy Gate:** secrets scrubbed from logs/screens. |
| 161 | +* **Schema Gate:** `SUMMARY_JSON` conforms exactly. |
| 162 | + |
| 163 | +### 8) Failure Modes (return one + remediation) |
| 164 | + |
| 165 | +* `ERROR_DESCRIPTION_REQUIRED()` |
| 166 | +* `ERROR_PATH_MISSING(path)` |
| 167 | +* `ERROR_SCRIPT_MISSING(path)` |
| 168 | +* `ERROR_ID_COLLISION(bug_id)` |
| 169 | +* `ERROR_DUPLICATE_CANDIDATE(existing_bug_id,reason)` (suggest linking instead of creating) |
| 170 | +* `ERROR_REPORT_WRITE(path,reason)` |
| 171 | +* `ERROR_PARSE_OUTPUT(reason)` |
| 172 | + |
| 173 | +### 9) Quality Checklist (auto‑verify) |
| 174 | + |
| 175 | +* Real script executed (**no mocked creation**). |
| 176 | +* Title concise; steps reproducible; *Expected vs Actual* included; environment complete. ([Bugzilla][1]) |
| 177 | +* Visuals/logs attached when helpful; tone factual and audience‑appropriate. ([Ministry of Testing][2]) |
| 178 | +* Reduced testcase or regression window provided when applicable. ([Bugzilla][1]) |
| 179 | +* CANARY snapshots emitted as specified. |
| 180 | + |
| 181 | +### 10) Example HUMAN_TEXT (operator‑friendly; optional) |
| 182 | + |
| 183 | +``` |
| 184 | +=== HUMAN_TEXT BEGIN === |
| 185 | +Created BUG-API-123 — Login fails on first attempt |
| 186 | +Report: .canary/bugs/BUG-API-123-login-fails/report.md |
| 187 | +Next: assign owner, add failing test, link fix MR. |
| 188 | +=== HUMAN_TEXT END === |
| 189 | +``` |
| 190 | + |
| 191 | +### 11) Example `report.md` skeleton (WHAT happened; not HOW to fix) |
| 192 | + |
| 193 | +``` |
| 194 | +=== BUG_REPORT_MARKDOWN BEGIN === |
| 195 | +# BUG-API-123 — Login fails on first attempt |
| 196 | +
|
| 197 | +## Bug Summary |
| 198 | +Login fails on first attempt |
| 199 | +
|
| 200 | +## Environment |
| 201 | +App v1.9.0+abcd123 • macOS 14.5 • Chrome 128 • en-US |
| 202 | +
|
| 203 | +## Preconditions |
| 204 | +Fresh account; logged out; cookies enabled. |
| 205 | +
|
| 206 | +## Steps to Reproduce |
| 207 | +1) Open /login |
| 208 | +2) Enter valid email/password |
| 209 | +3) Click “Sign in” once |
| 210 | +
|
| 211 | +## Expected Result |
| 212 | +User is authenticated and redirected to /home. |
| 213 | +
|
| 214 | +## Actual Result |
| 215 | +HTTP 401 with message “invalid session token”. See logs: logs/api-2025-10-18T10:02Z.txt |
| 216 | +
|
| 217 | +## Reproducibility |
| 218 | +3/5 attempts; fails on first attempt only. |
| 219 | +
|
| 220 | +## Scope & Impact |
| 221 | +Blocks onboarding; revenue impact for first‑time users. |
| 222 | +
|
| 223 | +## Regression / First Seen |
| 224 | +First seen in v1.9.0; v1.8.3 unaffected. |
| 225 | +
|
| 226 | +## Workarounds |
| 227 | +Retry succeeds on second attempt. |
| 228 | +
|
| 229 | +## Attachments |
| 230 | +- Screenshot: artifacts/login-first-attempt-401.png |
| 231 | +- Logs: artifacts/api-401-excerpt.txt |
| 232 | +- Reduced testcase: artifacts/login-retry.html |
| 233 | +
|
| 234 | +## Related / Dependencies |
| 235 | +REQ: {{.ProjectKey}}-API-134 (UserOnboarding) |
| 236 | +
|
| 237 | +## Next Actions (Triage) |
| 238 | +Assign API team • Add failing test • Investigate session initialization race. |
| 239 | +=== BUG_REPORT_MARKDOWN END === |
| 240 | +``` |
0 commit comments