selfware 0.6.2

Your personal AI workshop — software you own, software that lasts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# Bug Investigation Workflow - Inspired by gstack's /investigate
# Systematic debugging workflow with structured root cause analysis
# For txn545/Qwen3.5-122B-A10B-NVFP4 with 262k context

version: "1.0"
name: bug_investigation
description: |
  Systematic bug investigation workflow based on gstack's /investigate skill.
  Structured debugging: Reproduce → Isolate → Diagnose → Fix → Verify.

metadata:
  author: "Selfware Engineering Team"
  tags: ["debugging", "investigation", "root-cause-analysis", "bug-fix"]

agents:
  # Incident Commander - Coordinates investigation
  incident_commander:
    model:
      provider: openai
      name: txn545/Qwen3.5-122B-A10B-NVFP4
      temperature: 0.3
      max_tokens: 8192
    role: |
      You are an incident commander managing bug investigation.
      You coordinate resources, set priorities, and ensure systematic analysis.
      You ask the right questions to focus the investigation.
    instruction: |
      Initiate structured bug investigation:
      
      1. Bug Intake Questions
         - What was observed? (symptoms)
         - When did it start? (timeline)
         - Where does it happen? (environment, user segment)
         - How often? (frequency, reproducibility)
         - What's the impact? (severity, affected users)
      
      2. Initial Triage
         - Severity assessment (P0/P1/P2/P3)
         - Related services/components
         - Recent changes that might have caused it
         - Quick mitigation options
      
      3. Investigation Plan
         - Assign specialists based on symptoms
         - Define success criteria
         - Set timeboxes for each phase
      
      Output: INCIDENT_REPORT.md with bug summary and investigation plan
    tools:
      - file_read
      - file_write
      - web_search
    output_key: incident_report

  # Reproduction Specialist - Makes bugs reproducible
  reproduction_specialist:
    model:
      provider: openai
      name: txn545/Qwen3.5-122B-A10B-NVFP4
      temperature: 0.2
      max_tokens: 8192
    role: |
      You specialize in reproducing bugs. You write minimal reproduction cases.
      You turn "it sometimes fails" into "run this command to see the error".
      "I SEE THE ISSUE" is your catchphrase when you find it.
    instruction: |
      Create minimal reproduction for the bug:
      
      1. Reproduction Steps
         - Exact sequence of actions
         - Required state/setup
         - Environment details
         - Test data needed
      
      2. Minimization
         - Remove irrelevant steps
         - Simplify test data
         - Identify minimal code path
         - Create automated reproduction script
      
      3. Variation Testing
         - Does it happen on different environments?
         - Does it happen with different data?
         - Edge cases that trigger it
         - Related but non-triggering cases
      
      4. Reproduction Script
         - Shell script or test case
         - Clear pass/fail criteria
         - Include in test suite as regression test
      
      Output: REPRODUCTION_CASE.md with steps and reproduction script
    tools:
      - file_read
      - file_write
      - shell
      - file_edit
    output_key: reproduction_case

  # Root Cause Analyzer - Finds the why
  root_cause_analyzer:
    model:
      provider: openai
      name: txn545/Qwen3.5-122B-A10B-NVFP4
      temperature: 0.2
      max_tokens: 8192
    role: |
      You are a root cause analysis expert. You don't just find where the bug is,
      you understand WHY it happened. You use 5 Whys, fault trees, and code analysis.
      You distinguish symptoms from causes.
    instruction: |
      Perform deep root cause analysis:
      
      1. Code Path Analysis
         - Trace execution from entry to failure
         - Identify state changes
         - Map data transformations
         - Find boundary crossings
      
      2. The 5 Whys
         - Why did the error occur? (direct cause)
         - Why did that happen? (contributing cause)
         - Why wasn't it caught? (detection gap)
         - Why was the code written this way? (design decision)
         - Why did the design allow this? (systemic cause)
      
      3. Fault Tree Analysis
         - Top event: The bug
         - AND gates: Multiple conditions required
         - OR gates: Any condition sufficient
         - Basic events: Root causes
      
      4. Contributing Factors
         - Code issues (logic, concurrency, etc.)
         - Process issues (review gaps, missing tests)
         - Environmental issues (config, dependencies)
         - Human factors (misunderstanding, time pressure)
      
      5. Evidence Collection
         - Log analysis
         - Stack traces
         - State dumps
         - Code diffs
      
      Output: ROOT_CAUSE_ANALYSIS.md with findings and evidence
    tools:
      - file_read
      - file_write
      - shell
      - grep
      - git_log
    output_key: root_cause_analysis

  # Fix Developer - Implements the solution
  fix_developer:
    model:
      provider: openai
      name: txn545/Qwen3.5-122B-A10B-NVFP4
      temperature: 0.2
      max_tokens: 8192
    role: |
      You fix bugs with surgical precision. You address the root cause, not symptoms.
      You write regression tests. You ensure fixes don't introduce new bugs.
      Your fixes are minimal and focused.
    instruction: |
      Develop and implement the fix:
      
      1. Solution Design
         - Address root cause (not symptom)
         - Consider multiple approaches
         - Evaluate trade-offs
         - Choose minimal, safe fix
      
      2. Implementation
         - Atomic commit with clear message
         - Document why the fix works
         - Add regression test
         - Update relevant documentation
      
      3. Testing Strategy
         - Unit test for the fix
         - Integration test for the scenario
         - Edge case coverage
         - Regression test in CI
      
      4. Safety Checks
         - Check for similar bugs elsewhere
         - Verify no side effects
         - Review dependent code
         - Performance impact assessment
      
      Output: FIX.md with implementation details and test results
    tools:
      - file_read
      - file_write
      - file_edit
      - shell
      - git
    output_key: fix_implementation

  # Verification Engineer - Confirms the fix
  verification_engineer:
    model:
      provider: openai
      name: txn545/Qwen3.5-122B-A10B-NVFP4
      temperature: 0.2
      max_tokens: 8192
    role: |
      You verify that bugs are truly fixed. You test the fix thoroughly.
      You ensure the fix works in production-like conditions.
      You sign off only when confident.
    instruction: |
      Verify the bug fix:
      
      1. Fix Verification
         - Run reproduction case → should pass now
         - Run regression tests
         - Check related functionality still works
         - Verify in staging/production-like environment
      
      2. Verification Matrix
         - Original failing case: PASS
         - Edge cases: PASS
         - Related scenarios: PASS
         - Performance: No regression
      
      3. Sign-off Checklist
         - [ ] Bug no longer reproduces
         - [ ] Regression test passes
         - [ ] No new warnings/errors
         - [ ] Documentation updated
         - [ ] Monitoring/alerting verified
      
      Output: VERIFICATION_REPORT.md with sign-off
    tools:
      - file_read
      - file_write
      - shell
      - browser_navigate
    output_key: verification_report

workflows:
  # Full investigation - systematic debugging
  full_investigation:
    type: sequential
    description: "Complete bug investigation from report to verified fix"
    steps:
      # Phase 1: Triage and plan
      - delegate: incident_commander
        input:
          bug_report: "{{bug_report}}"
          output_file: "INCIDENT_REPORT.md"
      
      # Phase 2: Make it reproducible
      - delegate: reproduction_specialist
        input:
          incident_report: "INCIDENT_REPORT.md"
          output_file: "REPRODUCTION_CASE.md"
      
      # Phase 3: Find root cause
      - delegate: root_cause_analyzer
        input:
          reproduction_case: "REPRODUCTION_CASE.md"
          output_file: "ROOT_CAUSE_ANALYSIS.md"
      
      # Phase 4: Fix it
      - delegate: fix_developer
        input:
          root_cause: "ROOT_CAUSE_ANALYSIS.md"
          output_file: "FIX.md"
      
      # Phase 5: Verify
      - delegate: verification_engineer
        input:
          fix_doc: "FIX.md"
          output_file: "VERIFICATION_REPORT.md"

  # Quick debug - fast path for simple bugs
  quick_debug:
    type: sequential
    description: "Fast debugging for straightforward issues"
    steps:
      - delegate: reproduction_specialist
        input:
          mode: "quick"
      - delegate: fix_developer
        input:
          mode: "quick"
      - delegate: verification_engineer
        input:
          mode: "quick"

  # Root cause only - analysis without fix
  analyze_only:
    type: sequential
    description: "Root cause analysis for complex issues"
    steps:
      - delegate: incident_commander
        input:
          mode: "triage_only"
      - delegate: reproduction_specialist
        input:
          mode: "minimal"
      - delegate: root_cause_analyzer
        input:
          output_file: "ROOT_CAUSE_ANALYSIS.md"

  # Regression hunter - find similar bugs
  regression_hunt:
    type: sequential
    description: "Find similar bugs across codebase"
    steps:
      - delegate: root_cause_analyzer
        input:
          mode: "pattern_search"
      - delegate: fix_developer
        input:
          mode: "batch_fix"
      - delegate: verification_engineer
        input:
          mode: "batch_verify"

  # War room - parallel investigation for P0s
  war_room:
    type: parallel
    description: "All-hands parallel investigation for critical bugs"
    steps:
      - parallel:
          branches:
            - delegate: reproduction_specialist
              input:
                priority: "P0"
            - delegate: root_cause_analyzer
              input:
                priority: "P0"
            - delegate: fix_developer
              input:
                mode: "exploratory"
      - delegate: incident_commander
        input:
          mode: "coordinate"

state:
  fields:
    - name: incident_report
      type: string
      description: "Path to INCIDENT_REPORT.md"
    
    - name: reproduction_case
      type: string
      description: "Path to REPRODUCTION_CASE.md"
    
    - name: root_cause_analysis
      type: string
      description: "Path to ROOT_CAUSE_ANALYSIS.md"
    
    - name: fix_implementation
      type: string
      description: "Path to FIX.md"
    
    - name: verification_report
      type: string
      description: "Path to VERIFICATION_REPORT.md"
    
    - name: severity
      type: string
      description: "Bug severity (P0/P1/P2/P3)"
      default: "P2"
    
    - name: fix_verified
      type: boolean
      description: "Whether fix has been verified"
      default: false
    
    - name: regression_test_added
      type: boolean
      description: "Whether regression test was added"
      default: false

telemetry:
  enabled: true
  metrics:
    - inference_latency
    - token_usage
    - investigation_time
    - bug_severity_distribution
  export:
    type: file
    path: "./logs/bug_investigation_telemetry.jsonl"

guardrails:
  - name: require_reproduction
    type: pre_agent
    condition:
      language: rust
      content: |
        // Ensure we have reproduction before attempting fix
        if args.agent_name == "fix_developer" {
          args.state.reproduction_case.is_some()
        } else {
          true
        }
    on_violation: warn
  
  - name: verify_before_close
    type: post_workflow
    condition:
      language: rust
      content: |
        // Require verification before considering done
        args.state.fix_verified || args.workflow_name != "full_investigation"
    on_violation: warn
  
  - name: require_regression_test
    type: post_agent
    condition:
      language: rust
      content: |
        // Require regression test for P0/P1 bugs
        let is_high_severity = args.state.severity == "P0" || args.state.severity == "P1";
        let is_fixer = args.agent_name == "fix_developer";
        !is_high_severity || !is_fixer || args.output.contains("regression test")
    on_violation: warn