@massa-ai/cursor-plugin 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/.cursor-plugin/plugin.json +5 -0
  2. package/README.md +87 -0
  3. package/agents/massa-ai-architecture-specialist.md +65 -0
  4. package/agents/massa-ai-audit-specialist.md +81 -0
  5. package/agents/massa-ai-builder.md +67 -0
  6. package/agents/massa-ai-context-curator.md +67 -0
  7. package/agents/massa-ai-documentation-agent.md +65 -0
  8. package/agents/massa-ai-furps-analyst.md +71 -0
  9. package/agents/massa-ai-investigator.md +68 -0
  10. package/agents/massa-ai-mobile-specialist.md +82 -0
  11. package/agents/massa-ai-navigator.md +75 -0
  12. package/agents/massa-ai-plan-critic.md +90 -0
  13. package/agents/massa-ai-planner.md +65 -0
  14. package/agents/massa-ai-requirements-analyst.md +64 -0
  15. package/agents/massa-ai-reviewer.md +66 -0
  16. package/agents/massa-ai-test-engineer.md +66 -0
  17. package/agents/massa-ai-verification-agent.md +65 -0
  18. package/hooks/hooks.json +26 -0
  19. package/hooks/massa-ai-hook +298 -0
  20. package/install.sh +413 -0
  21. package/package.json +30 -0
  22. package/skills/agents/architecture-specialist/SKILL.md +69 -0
  23. package/skills/agents/audit-specialist/SKILL.md +85 -0
  24. package/skills/agents/builder/SKILL.md +71 -0
  25. package/skills/agents/context-curator/SKILL.md +71 -0
  26. package/skills/agents/documentation-agent/SKILL.md +69 -0
  27. package/skills/agents/furps-analyst/SKILL.md +74 -0
  28. package/skills/agents/investigator/SKILL.md +72 -0
  29. package/skills/agents/mobile-specialist/SKILL.md +86 -0
  30. package/skills/agents/navigator/SKILL.md +79 -0
  31. package/skills/agents/plan-critic/SKILL.md +93 -0
  32. package/skills/agents/planner/SKILL.md +69 -0
  33. package/skills/agents/requirements-analyst/SKILL.md +68 -0
  34. package/skills/agents/reviewer/SKILL.md +70 -0
  35. package/skills/agents/test-engineer/SKILL.md +70 -0
  36. package/skills/agents/verification-agent/SKILL.md +69 -0
  37. package/skills/def/SKILL.md +17 -0
  38. package/skills/find/SKILL.md +19 -0
  39. package/skills/graph/SKILL.md +16 -0
  40. package/skills/index/SKILL.md +19 -0
  41. package/skills/map/SKILL.md +24 -0
  42. package/skills/massa-ai/SKILL.md +315 -0
  43. package/skills/massa-ai/personas/README.md +35 -0
  44. package/skills/massa-ai/personas/ai-native-nodejs-cli-architect.md +76 -0
  45. package/skills/massa-ai/personas/catalog.json +157 -0
  46. package/skills/massa-ai/personas/context-skill-harness-engineer-architect.md +74 -0
  47. package/skills/massa-ai/personas/product-manager.md +67 -0
  48. package/skills/massa-ai/personas/senior-mobile-engineer.md +74 -0
  49. package/skills/massa-ai/personas/senior-mobile-qa-automation-engineer.md +75 -0
  50. package/skills/massa-ai/references/adr-authoring.md +189 -0
  51. package/skills/massa-ai/references/agent-orchestration.md +221 -0
  52. package/skills/massa-ai/references/architecture-coupling-lens.md +239 -0
  53. package/skills/massa-ai/references/architecture-deepening-lens.md +136 -0
  54. package/skills/massa-ai/references/architecture-domain-lens.md +186 -0
  55. package/skills/massa-ai/references/architecture-lenses.md +108 -0
  56. package/skills/massa-ai/references/audit-report-io.md +459 -0
  57. package/skills/massa-ai/references/audit-scope.md +103 -0
  58. package/skills/massa-ai/references/code-annotation.md +111 -0
  59. package/skills/massa-ai/references/codebase-investigation.md +96 -0
  60. package/skills/massa-ai/references/context-firewall.md +62 -0
  61. package/skills/massa-ai/references/conversation-feedback.md +104 -0
  62. package/skills/massa-ai/references/debug-diagnosis-loop.md +140 -0
  63. package/skills/massa-ai/references/decision-engine.md +73 -0
  64. package/skills/massa-ai/references/evidence-gate.md +53 -0
  65. package/skills/massa-ai/references/furps/analyst-role.md +49 -0
  66. package/skills/massa-ai/references/furps/checklist.md +92 -0
  67. package/skills/massa-ai/references/furps/intake.md +104 -0
  68. package/skills/massa-ai/references/furps/report-contract.md +140 -0
  69. package/skills/massa-ai/references/hook-enforcement.md +137 -0
  70. package/skills/massa-ai/references/implementation-delivery.md +101 -0
  71. package/skills/massa-ai/references/installation.md +110 -0
  72. package/skills/massa-ai/references/lessons.md +119 -0
  73. package/skills/massa-ai/references/maestro/artifacts-reports.md +69 -0
  74. package/skills/massa-ai/references/maestro/cli-device.md +65 -0
  75. package/skills/massa-ai/references/maestro/cloud.md +67 -0
  76. package/skills/massa-ai/references/maestro/config-env-output.md +76 -0
  77. package/skills/massa-ai/references/maestro/fact-ledger.md +71 -0
  78. package/skills/massa-ai/references/maestro/js-scripting.md +70 -0
  79. package/skills/massa-ai/references/maestro/mcp.md +59 -0
  80. package/skills/massa-ai/references/maestro/patterns.md +96 -0
  81. package/skills/massa-ai/references/maestro/selectors.md +91 -0
  82. package/skills/massa-ai/references/maestro/workspace-execution.md +81 -0
  83. package/skills/massa-ai/references/maestro/yaml-commands.md +203 -0
  84. package/skills/massa-ai/references/maestro.md +47 -0
  85. package/skills/massa-ai/references/mcp-tools.md +296 -0
  86. package/skills/massa-ai/references/memory-policy.md +103 -0
  87. package/skills/massa-ai/references/mobile-context.md +113 -0
  88. package/skills/massa-ai/references/mobile-diagnosis.md +106 -0
  89. package/skills/massa-ai/references/mobile-figma-matcher/ATTRIBUTION.md +5 -0
  90. package/skills/massa-ai/references/mobile-figma-matcher/android-compose.md +13 -0
  91. package/skills/massa-ai/references/mobile-figma-matcher/android-views.md +13 -0
  92. package/skills/massa-ai/references/mobile-figma-matcher/core.md +117 -0
  93. package/skills/massa-ai/references/mobile-figma-matcher/ios-swiftui.md +12 -0
  94. package/skills/massa-ai/references/mobile-figma-matcher/ios-uikit.md +12 -0
  95. package/skills/massa-ai/references/mobile-figma-matcher/kmp-compose-multiplatform.md +14 -0
  96. package/skills/massa-ai/references/mobile-figma-matcher/repository-detection.md +77 -0
  97. package/skills/massa-ai/references/naming-standards.md +47 -0
  98. package/skills/massa-ai/references/pr-task-fix.md +80 -0
  99. package/skills/massa-ai/references/project-context.md +76 -0
  100. package/skills/massa-ai/references/rfc/ATTRIBUTION.md +5 -0
  101. package/skills/massa-ai/references/rfc/discovery-and-sizing.md +120 -0
  102. package/skills/massa-ai/references/rfc/document-contract.md +85 -0
  103. package/skills/massa-ai/references/rfc/quality-and-lifecycle.md +101 -0
  104. package/skills/massa-ai/references/root-cause-scripts.md +97 -0
  105. package/skills/massa-ai/references/spec-driven/artifact-store.md +98 -0
  106. package/skills/massa-ai/references/spec-driven/code-analysis.md +119 -0
  107. package/skills/massa-ai/references/spec-driven/coding-principles.md +80 -0
  108. package/skills/massa-ai/references/spec-driven/context-limits.md +64 -0
  109. package/skills/massa-ai/references/spec-driven/design.md +257 -0
  110. package/skills/massa-ai/references/spec-driven/discuss.md +182 -0
  111. package/skills/massa-ai/references/spec-driven/execute.md +471 -0
  112. package/skills/massa-ai/references/spec-driven/lessons.md +5 -0
  113. package/skills/massa-ai/references/spec-driven/memory.md +214 -0
  114. package/skills/massa-ai/references/spec-driven/specify.md +283 -0
  115. package/skills/massa-ai/references/spec-driven/sub-agents.md +151 -0
  116. package/skills/massa-ai/references/spec-driven/tasks.md +494 -0
  117. package/skills/massa-ai/references/spec-driven/validate.md +397 -0
  118. package/skills/massa-ai/references/subagent-design.md +132 -0
  119. package/skills/massa-ai/references/synapse-policy.md +160 -0
  120. package/skills/massa-ai/references/tdd/calibrated-examples.md +54 -0
  121. package/skills/massa-ai/references/tdd/discovery-and-sizing.md +83 -0
  122. package/skills/massa-ai/references/tdd/document-contract.md +136 -0
  123. package/skills/massa-ai/references/tdd/quality-and-lifecycle.md +83 -0
  124. package/skills/massa-ai/references/the-fool/cognitive-bias-inventory.md +103 -0
  125. package/skills/massa-ai/references/the-fool/dialectic-synthesis.md +170 -0
  126. package/skills/massa-ai/references/the-fool/evidence-audit.md +202 -0
  127. package/skills/massa-ai/references/the-fool/mode-selection-guide.md +113 -0
  128. package/skills/massa-ai/references/the-fool/pre-mortem-analysis.md +200 -0
  129. package/skills/massa-ai/references/the-fool/red-team-adversarial.md +206 -0
  130. package/skills/massa-ai/references/the-fool/socratic-questioning.md +153 -0
  131. package/skills/massa-ai/references/ticket/atlassian-fix.md +130 -0
  132. package/skills/massa-ai/references/ticket/intake-and-sources.md +65 -0
  133. package/skills/massa-ai/references/ticket/templates-and-quality.md +129 -0
  134. package/skills/massa-ai/references/verification-ladder.md +62 -0
  135. package/skills/massa-ai/scripts/lessons.py +590 -0
  136. package/skills/massa-ai/workflows/adr.md +33 -0
  137. package/skills/massa-ai/workflows/architecture/architecture-audit.md +125 -0
  138. package/skills/massa-ai/workflows/architecture/architecture-fix.md +110 -0
  139. package/skills/massa-ai/workflows/bugs/bugs-audit.md +113 -0
  140. package/skills/massa-ai/workflows/bugs/bugs-fix.md +97 -0
  141. package/skills/massa-ai/workflows/code-quality/code-quality-audit.md +154 -0
  142. package/skills/massa-ai/workflows/code-quality/code-quality-fix.md +99 -0
  143. package/skills/massa-ai/workflows/commit.md +61 -0
  144. package/skills/massa-ai/workflows/debug.md +86 -0
  145. package/skills/massa-ai/workflows/design.md +54 -0
  146. package/skills/massa-ai/workflows/exploration.md +119 -0
  147. package/skills/massa-ai/workflows/feature.md +52 -0
  148. package/skills/massa-ai/workflows/general.md +46 -0
  149. package/skills/massa-ai/workflows/implementation/implementation-audit.md +87 -0
  150. package/skills/massa-ai/workflows/implementation/implementation-fix.md +90 -0
  151. package/skills/massa-ai/workflows/long-session.md +44 -0
  152. package/skills/massa-ai/workflows/maestro/maestro-audit.md +56 -0
  153. package/skills/massa-ai/workflows/maestro/maestro-fix.md +74 -0
  154. package/skills/massa-ai/workflows/maestro/maestro.md +68 -0
  155. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-audit.md +68 -0
  156. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-fix.md +74 -0
  157. package/skills/massa-ai/workflows/onboarding.md +23 -0
  158. package/skills/massa-ai/workflows/refactor.md +47 -0
  159. package/skills/massa-ai/workflows/refinement/furps-refinement.md +81 -0
  160. package/skills/massa-ai/workflows/requirements/requirements-audit.md +114 -0
  161. package/skills/massa-ai/workflows/requirements/requirements-fix.md +93 -0
  162. package/skills/massa-ai/workflows/rfc.md +55 -0
  163. package/skills/massa-ai/workflows/security/security-audit.md +113 -0
  164. package/skills/massa-ai/workflows/security/security-fix.md +97 -0
  165. package/skills/massa-ai/workflows/spec-driven.md +217 -0
  166. package/skills/massa-ai/workflows/tdd.md +71 -0
  167. package/skills/massa-ai/workflows/tests/tests-audit.md +114 -0
  168. package/skills/massa-ai/workflows/tests/tests-fix.md +96 -0
  169. package/skills/massa-ai/workflows/the-fool.md +82 -0
  170. package/skills/massa-ai/workflows/ticket.md +42 -0
  171. package/skills/persona-router/SKILL.md +158 -0
  172. package/skills/status/SKILL.md +15 -0
@@ -0,0 +1,125 @@
1
+ ### Architecture Audit
2
+
3
+ Use this workflow for findings-only audit of domain boundaries, bounded contexts, DDD strategic design, coupling, dependency health, architecture review, deepening opportunities, seams, adapters, module depth, and architecture-focused refactor planning in a concrete target: modified files, explicit files/globs, commit ranges, branch comparisons, modules/packages, symbols/classes/functions, feature/runtime flows, explicitly requested whole-repo scope, or an implementation scope packet supplied by `workflows/implementation/implementation-audit.md`.
4
+
5
+ Before the first substantive read, load `references/project-context.md` and run the project-context intake sweep for this repository.
6
+
7
+ Do not use this workflow for plain SOLID, Clean Code, KISS, YAGNI, DRY, or code smell scans; use `workflows/code-quality/code-quality-audit.md` for those.
8
+
9
+ This workflow is findings-only. Do not edit code unless the user separately asks for fixes.
10
+
11
+ 1. Resolve/reuse `workflowSessionId`: `architecture-[entity]`
12
+ 2. Load shared references:
13
+ - `references/codebase-investigation.md`
14
+ - `references/audit-scope.md`
15
+ - `references/architecture-lenses.md`
16
+ - `references/architecture-domain-lens.md` only when scope includes bounded contexts, subdomains, ubiquitous language, cohesion, or integration pattern claims
17
+ - `references/architecture-coupling-lens.md` only when scope includes dependencies, imports, service calls, shared schemas/models, persistence reach-through, co-change, or contract leakage
18
+ - `references/architecture-deepening-lens.md` only when scope includes module depth, seams, adapters, deletion tests, locality, testability, or AI-navigability
19
+ - `references/audit-report-io.md` before writing the final direct audit report
20
+ - `references/context-firewall.md` before inspecting large diffs, dependency graphs, generated reports, or broad search output
21
+ - `references/synapse-policy.md` when repeated massa-ai searches are expected
22
+ - `references/agent-orchestration.md` only for large scopes, explicit parallel/subagent requests, PR subagent invocation, isolated audit slices, or independent verification of high-impact findings
23
+ 3. `recall` -> load ADRs, architecture decisions, known boundaries, coupling patterns, accepted exceptions, project constraints, and prior rejected refactors for the target area.
24
+ - Apply the Memory Freshness Gate from `references/audit-scope.md`; recalled exceptions are leads, not proof.
25
+ 4. Establish the investigation scope before proceeding:
26
+ - Modified files scope: use when the user says modified files, changed files, current changes, uncommitted changes, staged changes, or unstaged changes.
27
+ - Explicit files/globs scope: use when the user names files, directories, or globs.
28
+ - Commit range scope: use when the user provides commits/ranges or asks for commits made by me, my branch commits, or architecture issues introduced by branch commits.
29
+ - Branch comparison scope: use when the user names base/head branches, refs, or a branch diff.
30
+ - Codebase area scope: use when the user names a path, module, package, bounded context, feature area, architecture question, or glob.
31
+ - Symbol/class/function scope: use when the user names exported surfaces, classes, functions, adapters, interfaces, or dependency edges.
32
+ - Feature/flow scope: use when the user names a runtime flow or cross-module feature.
33
+ - Whole-repo scope: use only when the user explicitly asks for a whole-repo architecture audit.
34
+ - Implementation parent scope: use only when `workflows/implementation/implementation-audit.md` invokes this workflow with a concrete implementation scope packet.
35
+ - If the target focus is missing, vague, or too broad, ask for a concrete target from the supported scope types in `references/audit-scope.md`.
36
+ - Build the shared scope packet from `references/audit-scope.md` and carry it into the report.
37
+ 5. For modified files scope:
38
+ - Include staged and unstaged tracked files from the working tree.
39
+ - Include untracked non-generated source, test, fixture, schema, config, and docs files only when they can affect architecture contracts or module boundaries.
40
+ - Exclude deleted files unless their deletion can break imports, exports, routing, migrations, config, tests, packaging, or architecture contracts.
41
+ - Exclude generated, dependency, build, log, cache, temporary, and secret paths per repo rules.
42
+ - Inspect diffs first, then only the surrounding code needed to understand architecture behavior.
43
+ 6. For commit range scope:
44
+ - If the user supplied explicit commits or a revision range, use that exact range.
45
+ - If the user asked for commits made by me, resolve author identity from `git config user.email`; if empty, use `git config user.name`.
46
+ - For branch-relative commit scopes, resolve the branch base from the upstream merge-base first, then fall back in order to `origin/main`, `origin/master`, `main`, and `master`.
47
+ - If the user asked for commits made by me, review branch-unique commits authored by the resolved identity.
48
+ - If no explicit range, required author identity, or branch base can be resolved, ask the user for the missing value before proceeding.
49
+ - Inspect changed files and diffs from those commits, then exported surfaces, references, dependency direction, tests, config, and ADRs only as needed.
50
+ 7. For codebase area scope:
51
+ - Require a concrete path, module, package, feature area, architecture question, or glob.
52
+ - If the target area is missing, ask for it before proceeding.
53
+ - Follow the shared retrieval order from `references/codebase-investigation.md` to find target modules, entry points, exported surfaces, references, semantic hotspots, tests, and adjacent config.
54
+ - If scope is broad, map only top-level modules first and ask or recommend a narrower second pass.
55
+ 8. For explicit files/globs, branch comparison, symbol/class/function, feature/flow, or explicitly requested whole-repo scope:
56
+ - Resolve the target with `references/audit-scope.md` and record the resolution method, base/head when relevant, resolved files, exclusions, and freshness timestamp.
57
+ - For symbol/class/function targets, verify definitions, references, dependency direction, exported surfaces, callers, tests, and ADRs only as needed for architecture claims.
58
+ - For feature/flow targets, map entry points through main transformations, contracts, and side effects before applying architecture lenses.
59
+ - If whole-repo scope is requested, map top-level modules first and report skipped depth checks rather than pretending exhaustive coverage.
60
+ 9. For implementation parent scope:
61
+ - Accept the exact scope packet from `implementation-audit`; do not broaden beyond resolved files, surrounding code, exported surfaces, references, config, tests, and ADRs needed to verify an architecture claim.
62
+ - Return compact findings to the parent implementation audit; do not write broad project memories unless explicitly assigned.
63
+ 10. Investigation pass:
64
+ - Call `get_architecture` with `id` (projectId) for the architecture-specific deep map: packages, entry points, routes, hotspots, communities, layers, and opt-in cycles (pass `aspects:["cycles"]` for Tarjan SCC over CALL edges). `get_architecture` is distinct from `project_map` (general overview: PageRank backbone + symbol counts) — use `get_architecture` for architecture-specific structure and `project_map` for the general overview. Both only count as evidence when the index is fresh for the current repository path and commit/worktree state; fall back to `search`/`get_references` and record reduced retrieval confidence when the index is stale or unavailable.
65
+ - Call `impact_analysis` with `project`, `projectPath`, and `scope` (unstaged/staged/committed/all) to assess the centrality-ranked blast radius of a change set. An empty diff returns an empty impact set (not an error).
66
+ - Apply the smallest relevant lens set from `references/architecture-lenses.md` and load detail references only when their evidence is needed:
67
+ - Domain lens: subdomains, bounded contexts, ubiquitous language, cohesion score, colliding concepts, cross-domain ownership, and integration pattern fit.
68
+ - Coupling lens: dependency graph, knowledge direction, integration strength, distance, volatility, balance table result, and contract health.
69
+ - Deepening lens: module/interface/seam/adapter vocabulary, shallow modules, deletion test, dependency category, locality, leverage, and interface-as-test-surface evidence.
70
+ - Use `search_definitions` and `get_references` to verify exported surfaces and dependency direction where needed.
71
+ - Capture positive architecture patterns when they materially disprove a concern, such as versioned contracts, anti-corruption layers, cohesive local coupling, or a deep interface that concentrates tests.
72
+ - For each candidate finding, record the concrete claim, source evidence, lens-specific evidence, impacted boundary or module, provisional severity, tradeoff, simplest sufficient direction, and what would disprove it.
73
+ 11. False-positive pass:
74
+ - Try to disprove every candidate before reporting it.
75
+ - Check ADRs, accepted exceptions, current domain docs, dependency direction, call paths, tests, package boundaries, framework constraints, git history when cheap, and prior rejected refactors.
76
+ - Treat recalled memories and standalone skill heuristics as leads, not proof.
77
+ - Do not report domain truth inferred only from code names as fact; mark it `suspect` or report the evidence gap.
78
+ - Do not report strong coupling as a defect when strength is local, stable, or cohesive and no change friction is shown.
79
+ - Do not recommend ports/adapters, service extraction, VSA migration, or new seams unless evidence shows real variation, volatility, external dependency pressure, or boundary friction.
80
+ - Drop candidates disproven by evidence, downgrade candidates with partial mitigation, and mark judgment-heavy conclusions as `suspect`.
81
+ - When you reject a refactor candidate, record its load-bearing reason in ruled-out candidates; if it is likely to be re-proposed, offer an ADR via `workflows/adr.md` so the rejection is not re-litigated next audit.
82
+ 12. Use agent orchestration only when it improves signal. Dispatch per `references/agent-orchestration.md`:
83
+
84
+ > **Dispatch: `massa-ai-architecture-specialist`** (role: `architecture-specialist`) — charter `skills/agents/architecture-specialist/SKILL.md`
85
+ > - trigger: large scope, explicit parallel/subagent request, PR subagent invocation, isolated audit slice, or independent verification of high-impact finding
86
+ > - scope: exact files/modules/boundaries in the audit target
87
+ > - permissions: read-only
88
+ > - inputs: shared scope packet; lens sub-mode (`domain` for bounded-context mapping, `coupling` for dependency-graph/strength/distance/volatility, `deepening` for module-depth opportunities); recalled ADRs and rejected refactors
89
+ > - sensors: `search_definitions` / `get_references` for exported surfaces and dependency direction; source inspection against current files
90
+ > - output: findings with lens-specific evidence, provisional severity, tradeoff, and what would disprove it
91
+ > - firewall: raw dependency graphs, generated reports, and broad search output summarized, not returned raw
92
+ > - memory: suggest-only; main agent persists accepted constraints/rejected refactors
93
+
94
+ > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
95
+ > - trigger: independent verification of a high-impact architecture finding
96
+ > - scope: the specific finding's claimed evidence and affected boundary/module
97
+ > - permissions: read-only
98
+ > - inputs: the candidate finding, its source evidence, ADRs, accepted exceptions, and the verification suggestion
99
+ > - sensors: deterministic command or artifact check that would falsify the finding
100
+ > - output: confirmed/disproven verdict with evidence; skipped-check reason if the sensor cannot run
101
+ > - firewall: raw logs/snapshots summarized
102
+ > - memory: suggest-only; main agent persists reusable verification recipes
103
+ 13. Severity rules (apply the countable threshold first, then the qualitative clause):
104
+ - `critical`: architecture issue likely causes data loss, auth/privacy break, production outage, irreversible corruption, OR affects >10 files; otherwise use the qualitative clause below.
105
+ - `high`: strong coupling with high volatility, boundary violation, dependency inversion break, or shallow module design likely to cause major change friction or regression.
106
+ - `medium`: meaningful but recoverable coupling, unclear boundary, missing seam, duplicated architecture rule, or module-depth issue with localized impact (<=10 affected files, recoverable).
107
+ - `low`: architecture hardening opportunity, low-impact naming/layering issue, incomplete evidence, or weakly supported concern.
108
+ 14. Final report:
109
+ - Findings first, ordered by severity.
110
+ - Each finding must use `ARCH-<N>` and include the canonical fields from `references/audit-report-io.md`: lens, boundary/module, tradeoff, dependency direction when relevant, severity, confidence, file/module, concrete evidence, impact, simplest sufficient fix, and verification suggestion.
111
+ - Mark uncertain or judgment-heavy conclusions as `suspect`.
112
+ - Do not relitigate ADR-backed decisions unless current evidence shows real friction worth reopening.
113
+ - Prefer merge, inline, move, or clarify-seam recommendations before adding new abstractions.
114
+ - Include lens-specific evidence in existing fields: domain findings should name language/cohesion/integration evidence; coupling findings should name strength/distance/volatility and dependency direction; deepening findings should name interface complexity, deletion-test result, dependency category, and test-surface impact.
115
+ - If no architecture findings are found, say that clearly and list scope checked plus skipped checks.
116
+ - Include ruled-out candidates when they were plausible enough to matter.
117
+ - Include scope checked, deterministic evidence or skipped-check notes, memory outcome, and residual risk.
118
+ - Include the Verification/Test Fidelity Checklist from `references/audit-report-io.md`; tie every `ARCH-*` finding or no-finding claim to deterministic sensors, commands/artifacts, results, validation assets, or skipped-check reasons. Model judgment alone cannot satisfy verification/testing all-clear.
119
+ - For direct top-level invocation, use the Plan Mode save rule and canonical report contract from `references/audit-report-io.md` for `audits/architecture/<YYYY-MM-DD architecture-audit>.md`.
120
+ - For implementation audit child invocation, return compact findings to the parent unless the parent explicitly requests saved audit artifacts.
121
+ 15. Persist only durable knowledge:
122
+ - Persist accepted architecture constraints, repeated coupling patterns, accepted exceptions, rejected refactors, or reusable verification recipes.
123
+ - Do not persist every one-off finding.
124
+ - Use required tags: `project:<projectId>`, `session:<workflowSessionId>`, `workflow:architecture-audit`, `entity:<entity>`, and one `memory:<tier>` tag.
125
+ 16. Complete the Evidence Gate from `references/evidence-gate.md`.
@@ -0,0 +1,110 @@
1
+ ### Architecture Fix
2
+
3
+ Use this workflow only to execute fixes from an architecture audit markdown report.
4
+
5
+ Before the first substantive read, load `references/project-context.md` and run the project-context intake sweep for this repository.
6
+
7
+ Before the first repository mutation, load `references/implementation-delivery.md` for worktree isolation, atomic commits, PR creation, CI watch, and the merge gate, and `references/code-annotation.md` for doc blocks, rationale comments, and test coverage on every created or updated unit. If two consecutive fix attempts fail on the same symptom, stop editing and load `references/root-cause-scripts.md`.
8
+
9
+ Do not use this workflow for findings-only architecture review; route that to `workflows/architecture/architecture-audit.md`. Do not use it for broad new design work with missing requirements; route that to `workflows/spec-driven.md`.
10
+
11
+ 1. Resolve/reuse `workflowSessionId`: `architecture-fix-[entity]`
12
+ 2. Load shared references:
13
+ - `references/audit-report-io.md` before any code change
14
+ - `references/architecture-lenses.md`
15
+ - `references/architecture-domain-lens.md` when executing domain or bounded-context findings
16
+ - `references/architecture-coupling-lens.md` when executing dependency, contract, or coupling findings
17
+ - `references/architecture-deepening-lens.md` when executing module-depth, seam, adapter, locality, or testability findings
18
+ - `references/lessons.md` to load confirmed project lessons
19
+ - `references/codebase-investigation.md` before changing unfamiliar modules
20
+ - `references/verification-ladder.md` before non-trivial edits
21
+ - `references/context-firewall.md` before inspecting large diffs, dependency graphs, generated reports, or broad search output
22
+ - `references/agent-orchestration.md` only for large/high-risk findings, disjoint implementation slices, or independent verification
23
+ 3. `recall` -> load ADRs, known boundaries, coupling patterns, accepted exceptions, rejected refactors, verification recipes, and project constraints for the report target.
24
+ 4. Select the architecture audit report with execution focus:
25
+ - Establish the report selector, target focus, and optional finding selector before selecting a report. Target focus can be a module, boundary, flow, files/globs, branch comparison, commit range, symbol/class/function, or explicit whole-repo target.
26
+ - If the user gives a path, read that exact markdown file.
27
+ - If the user asks for "latest" or gives no path, require a concrete target focus first; do not run the latest architecture report against an unspecified target.
28
+ - Select the latest `audits/architecture/<YYYY-MM-DD architecture-audit>.md` only after target focus is known, using `references/audit-report-io.md`.
29
+ - Stop if no report exists; do not infer findings from conversation history.
30
+ - Validate the report with `references/audit-report-io.md`: workflow, `ProjectId`, `Target`, `Target Focus`, scope, git base/head, required fields, `ARCH-` IDs, resolved files or material scope evidence, and current file/module evidence. Stop on invalid, stale, target-drifted, or ambiguous reports before editing.
31
+ 5. Extract actionable architecture findings:
32
+ - Keep findings with concrete `Lens`, `Boundary/Module`, `Tradeoff`, `Location`, `Evidence`, `Impact`, `Simplest Fix Direction`, and `Verification Suggestion`.
33
+ - Require lens-specific closure evidence: domain findings need language/ownership or integration evidence; coupling findings need strength/distance/volatility or dependency-direction evidence; deepening findings need deletion-test, seam, dependency-category, or test-surface evidence.
34
+ - Ignore ruled-out candidates and no-finding sections.
35
+ - Ignore `suspect` findings unless the user explicitly asks to address suspects or the report supplies a deterministic follow-up check that confirms them.
36
+ - If the user supplied finding IDs, extract only those IDs after validating they exist and match the current target focus.
37
+ - Rank by severity, dependency order, boundary blast radius, and ease of deterministic verification.
38
+ 6. Build an execution map before editing:
39
+ - Finding ID -> target modules, affected bounded context or seam, current dependency direction, desired dependency direction, behavior that must stay unchanged, validation assets, and rollback path.
40
+ - Split work when one report contains independent findings. Do not mix unrelated architecture moves in one edit loop.
41
+ 7. Size each finding with `references/verification-ladder.md`:
42
+ - Quick: local move/inline/rename/adapter clarification with small blast radius.
43
+ - Standard: multi-file behavior-preserving refactor, public API adjustment, package boundary change, or test impact; define characterization checks first.
44
+ - Spec-driven: migration, broad boundary redesign, new service boundary, unclear ownership, or user-visible behavior change; pause and route to `workflows/spec-driven.md` or ask for approval.
45
+ 8. Apply architecture fixing methods:
46
+ - Domain: align language and ownership, move misplaced concepts into the right bounded context, separate generic/supporting concerns from core domain logic, and preserve ubiquitous language in names.
47
+ - Coupling: reduce strength before distance; replace internal model sharing with explicit contracts, remove cross-boundary knowledge of internals, invert dependencies at stable seams, keep cohesive local coupling close, and avoid cycles.
48
+ - Deepening: delete shallow pass-through modules, merge split concepts when locality improves, deepen useful interfaces by hiding invariants and ordering, test through the interface, and clarify seams only where variation, dependency direction, external I/O, or test substitution justifies it.
49
+ - When a deepening candidate has two or more viable interface shapes, load the Interface Design Method from `references/architecture-deepening-lens.md` (Design It Twice) and pick by leverage and locality before editing.
50
+ - When you decide not to apply a reported refactor, record the load-bearing reason; if it is likely to recur, offer an ADR via `workflows/adr.md` so the rejection is not re-litigated.
51
+ - Prefer move, merge, inline, or clarify existing seams before adding new abstractions.
52
+ - Use ports/adapters or anti-corruption layers only when the report evidence shows real volatility, boundary pressure, external dependency pressure, model leakage, or at least two real adapters such as production plus test.
53
+ - Do not turn a local code-quality concern into an architecture migration; route broad new design, VSA migration, new service boundaries, or unclear ownership to `workflows/spec-driven.md`.
54
+ 9. Preserve behavior:
55
+ - Characterize current behavior before moving code with tests, static checks, import graphs, source inspection, or artifact snapshots.
56
+ - Keep public contracts stable unless the audit finding explicitly requires contract change.
57
+ - Update tests, docs, and imports only where required by the architecture fix.
58
+ 10. Use agent orchestration only when it improves signal. Dispatch per `references/agent-orchestration.md`:
59
+
60
+ > **Dispatch: `massa-ai-builder`** (role: `builder`) — charter `skills/agents/builder/SKILL.md`
61
+ > - trigger: large/high-risk finding, disjoint implementation slice, or explicit subagent request
62
+ > - scope: one isolated architecture finding with a disjoint write set
63
+ > - permissions: write (disjoint write set)
64
+ > - inputs: the finding ID, target modules, affected bounded context or seam, current/desired dependency direction, behavior that must stay unchanged, validation assets, rollback path
65
+ > - sensors: report's verification suggestion or equivalent deterministic command; static dependency-direction/import-cycle checks
66
+ > - output: implementation summary, commands run, test counts, deviations
67
+ > - firewall: raw diffs/logs summarized
68
+ > - memory: suggest-only; main agent persists reusable architecture patterns
69
+
70
+ > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
71
+ > - trigger: independent verification of a high-risk or multi-file architecture fix
72
+ > - scope: the fixed finding's dependency direction, tests, imports, and report claim closure
73
+ > - permissions: read-only
74
+ > - inputs: the finding, the applied fix, the verification suggestion, and validation assets
75
+ > - sensors: deterministic command (targeted tests, import-cycle check, dependency-direction check) and report claim closure check
76
+ > - output: confirmed/disproven closure verdict with evidence
77
+ > - firewall: raw test output/logs summarized
78
+ > - memory: suggest-only; main agent persists reusable verification recipes
79
+ 11. Verify each completed finding:
80
+ - If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
81
+ `python3 skills/massa-ai/scripts/lessons.py --root . add --feature "<slug>" --signal "<signal>" --source "<ref>" --text "<one terse lesson>"`
82
+ - Apply the Mandatory Verification Fix Gate from `references/verification-ladder.md`: run the report's Verification Suggestion or an equivalent deterministic command/artifact check for each selected finding or coherent group.
83
+ - A finding cannot be marked `fixed` when a target-relevant command or artifact check exists but was not attempted; if verification cannot run, mark it `blocked`, `deferred`, or `skipped` with an allowed skipped-check reason.
84
+ - Run the report's verification suggestion when available.
85
+ - Add static checks for dependency direction/import cycles when feasible.
86
+ - For domain findings, verify names, ownership, contracts, or tests reflect the intended ubiquitous language without inventing undocumented domain truth.
87
+ - For coupling findings, verify the risky edge was removed, weakened to a contract, moved closer, or explicitly documented as stable.
88
+ - For deepening findings, verify callers/tests use the intended interface and no new hypothetical seam was added without real variation.
89
+ - Run targeted tests or builds affected by moved boundaries.
90
+ - Record command/artifact, result, skipped reason or `none`, highest Verification Ladder level reached, validation assets protected, and residual risk.
91
+ 12. At completion, persist only durable knowledge:
92
+ - Accepted architecture constraints, new seams, rejected broad refactors, reusable dependency checks, or recurring coupling patterns after scoring with the Importance Calibration System.
93
+ - Use required tags: `project:<projectId>`, `session:<workflowSessionId>`, `workflow:architecture-fix`, `entity:<entity>`, and one `memory:<tier>` tag.
94
+ 13. Complete the Evidence Gate from `references/evidence-gate.md`.
95
+
96
+ ## Examples
97
+
98
+ User asks: "Use architecture-fix to fix the latest architecture audit for the billing boundary."
99
+
100
+ 1. Confirm target focus is `billing boundary`, then read the latest matching `audits/architecture/* architecture-audit.md`.
101
+ 2. Validate metadata, target focus, freshness, required fields, and current evidence before editing.
102
+ 3. Extract actionable findings and build a finding-by-finding execution map.
103
+ 4. Fix one boundary or coupling issue at a time.
104
+ 5. Verify dependency direction and behavior before moving to the next finding.
105
+
106
+ User asks: "Fix finding ARCH-2 from audits/architecture/2026-06-06 architecture-audit.md."
107
+
108
+ 1. Read the specified report and only execute `ARCH-2`.
109
+ 2. Preserve unaffected architecture findings for later.
110
+ 3. Report evidence for `ARCH-2` closure and residual risks.
@@ -0,0 +1,113 @@
1
+ ### Bugs Audit
2
+
3
+ Use this workflow for findings-only bug discovery in a concrete target: modified files, explicit files/globs, commit ranges, branch comparisons, modules/packages, symbols/classes/functions, feature/runtime flows, explicitly requested whole-repo scope, or an implementation scope packet supplied by `workflows/implementation/implementation-audit.md`.
4
+
5
+ Before the first substantive read, load `references/project-context.md` and run the project-context intake sweep for this repository.
6
+
7
+ Do not use this workflow to fix a known broken behavior; route that to `workflows/debug.md`. Do not use it for SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or overengineering analysis; route that to `workflows/code-quality/code-quality-audit.md`. For a multi-lens implementation review, route to `workflows/implementation/implementation-audit.md`. When invoked by implementation audit, this workflow is the Correctness lens only.
8
+
9
+ This workflow is findings-only. Do not edit code unless the user separately asks for fixes.
10
+
11
+ 1. Resolve/reuse `workflowSessionId`: `bugs-audit-[entity]`
12
+ 2. Load shared references:
13
+ - `references/codebase-investigation.md`
14
+ - `references/audit-scope.md`
15
+ - `references/audit-report-io.md` before writing the final direct audit report
16
+ - `references/context-firewall.md` before inspecting large diffs, logs, snapshots, generated reports, or broad search output
17
+ - `references/synapse-policy.md` when repeated massa-ai searches are expected
18
+ - `references/agent-orchestration.md` only for large scopes, explicit parallel/subagent requests, PR subagent invocation, or independent verification of high-impact findings
19
+ 3. `recall` -> load prior bug patterns, known regressions, project constraints, ADRs, fragile flows, and accepted exceptions for the target area.
20
+ - Apply the Memory Freshness Gate from `references/audit-scope.md`; recalled exceptions are leads, not proof.
21
+ 4. Establish the investigation scope before proceeding:
22
+ - Modified files scope: use when the user says modified files, changed files, current changes, uncommitted changes, staged changes, or unstaged changes.
23
+ - Explicit files/globs scope: use when the user names files, directories, or globs.
24
+ - Commit range scope: use when the user provides commits/ranges or asks for commits made by me, my branch commits, or bugs introduced by branch commits.
25
+ - Branch comparison scope: use when the user names base/head branches, refs, or a branch diff.
26
+ - Codebase area scope: use when the user names a path, module, package, feature area, service, or glob.
27
+ - Symbol/class/function scope: use when the user names public classes, functions, APIs, handlers, or exported surfaces.
28
+ - Feature/flow scope: use when the user names a runtime flow, user journey, or feature area.
29
+ - Whole-repo scope: use only when the user explicitly asks for a whole-repo bug audit.
30
+ - Implementation parent scope: use only when `workflows/implementation/implementation-audit.md` invokes this workflow with a concrete implementation scope packet.
31
+ - If the target focus is missing, vague, or too broad, ask for a concrete target from the supported scope types in `references/audit-scope.md`.
32
+ - Build or accept the shared scope packet from `references/audit-scope.md` and carry it into the report.
33
+ 5. For modified files scope:
34
+ - Include staged and unstaged tracked files from the working tree.
35
+ - Include untracked non-generated source, test, fixture, schema, config, and docs files only when they can affect runtime or validation behavior.
36
+ - Exclude deleted files unless their deletion can break imports, exports, routing, migrations, config, tests, or packaging.
37
+ - Exclude generated, dependency, build, log, cache, temporary, and secret paths per repo rules.
38
+ - Inspect diffs first, then only the surrounding code needed to understand behavior.
39
+ 6. For commit range scope:
40
+ - If the user supplied explicit commits or a revision range, use that exact range.
41
+ - If the user asked for commits made by me, resolve author identity from `git config user.email`; if empty, use `git config user.name`.
42
+ - For branch-relative commit scopes, resolve the branch base from the upstream merge-base first, then fall back in order to `origin/main`, `origin/master`, `main`, and `master`.
43
+ - If the user asked for commits made by me, review branch-unique commits authored by the resolved identity.
44
+ - If no explicit range, required author identity, or branch base can be resolved, ask the user for the missing value before proceeding.
45
+ - Inspect changed files and diffs from those commits, then surrounding code, callers, tests, and config only as needed.
46
+ 7. For codebase area scope:
47
+ - Require a concrete path, module, package, feature area, or glob.
48
+ - If the target area is missing, ask for it before proceeding.
49
+ - Follow the shared retrieval order from `references/codebase-investigation.md` to find entry points, public API, tests, and adjacent config.
50
+ 8. For explicit files/globs, branch comparison, symbol/class/function, feature/flow, or explicitly requested whole-repo scope:
51
+ - Resolve the target with `references/audit-scope.md` and record the resolution method, base/head when relevant, resolved files, exclusions, and freshness timestamp.
52
+ - For symbol/class/function targets, inspect definitions, callers, callees, tests, contracts, and config only as needed to verify likely bugs.
53
+ - For feature/flow targets, trace input -> transformation -> output through the named flow.
54
+ - If whole-repo scope is requested, map high-risk entry points first and report skipped depth checks rather than implying exhaustive review.
55
+ 9. For implementation parent scope:
56
+ - Accept the exact scope packet from `implementation-audit`; do not broaden beyond resolved files, surrounding code, callers, callees, tests, config, migrations, schemas, and public contracts needed to verify a correctness claim.
57
+ - Return compact Correctness findings to the parent implementation audit; do not write broad project memories unless explicitly assigned.
58
+ 10. Investigation pass. Dispatch `audit-specialist` per `references/agent-orchestration.md` when the scope justifies an isolated read-only subagent:
59
+
60
+ > **Dispatch: `massa-ai-audit-specialist`** (role: `audit-specialist`) — charter `skills/agents/audit-specialist/SKILL.md`
61
+ > - trigger: large scope, explicit parallel/subagent request, PR subagent invocation, or independent verification of high-impact finding
62
+ > - scope: the bugs audit target — files, diffs, suspicious paths
63
+ > - permissions: read-only
64
+ > - inputs: shared scope packet; `lens: bugs`; recalled regressions, known bug patterns, accepted exceptions
65
+ > - sensors: trace input -> transformation -> output; check diffs, callers/callees, tests, config, migrations; prioritize correctness bugs, crashes, data loss, security regressions, broken contracts, async/race issues
66
+ > - output: findings with bug category, location, evidence, trigger, severity, confidence, simplest fix direction, verification suggestion
67
+ > - firewall: raw diffs/logs/search output summarized, not returned raw
68
+ > - memory: suggest-only; main agent persists reusable bug patterns
69
+
70
+ - Trace input -> transformation -> output for each suspicious path.
71
+ - Check diffs, surrounding code, callers and callees, tests, config, migrations, schemas, and recalled project patterns.
72
+ - Prioritize correctness bugs, crashes, data loss, security regressions, broken contracts, async or race issues, validation or authorization gaps, persistence and migration bugs, environment/config issues, and behavior that contradicts tests or public API contracts.
73
+ - For each candidate finding, record the concrete claim, bug class, source evidence, impacted flow, trigger or repro path, root-cause hypothesis, regression risk, provisional severity, and what would disprove it.
74
+ 11. False-positive pass:
75
+ - Try to disprove every candidate before reporting it.
76
+ - Check guards, type checks, tests, feature flags, framework contracts, call paths, existing invariants, ADRs, and accepted exceptions.
77
+ - Use official docs or web research only when current external API or framework behavior matters.
78
+ - Drop candidates disproven by evidence, downgrade candidates with partial mitigation, and mark low-confidence findings explicitly.
79
+ 12. Severity rules (apply the countable threshold first, then the qualitative clause):
80
+ - `critical`: likely data loss, security bypass, production outage, irreversible corruption, auth/privacy break, OR affects >10 files; otherwise use the qualitative clause below.
81
+ - `high`: likely crash, major regression, broken core flow, incorrect persistence, missing required validation, or severe operational risk.
82
+ - `medium`: real edge-flow bug, recoverable incorrect behavior (<=10 affected files), flaky async/state risk, incomplete error handling, or meaningful test gap around changed logic.
83
+ - `low`: minor bug, low-impact incorrect behavior, defensive hardening opportunity, incomplete evidence, or weakly supported concern.
84
+ 13. Final report:
85
+ - Findings first, ordered by severity: `critical`, `high`, `medium`, `low`.
86
+ - Each finding must use `BUG-<N>` and include the canonical fields from `references/audit-report-io.md`: severity, confidence, file/line, evidence, bug class, impacted flow, trigger or repro path, root-cause hypothesis, regression risk, impact, simplest fix direction, and verification suggestion.
87
+ - If no bugs are found, say that clearly and list scope checked plus skipped checks.
88
+ - Include ruled-out candidates when they were plausible enough to matter.
89
+ - Include scope checked, deterministic evidence or skipped-check notes, memory outcome, and residual risk.
90
+ - Include the Verification/Test Fidelity Checklist from `references/audit-report-io.md`; tie every `BUG-*` finding or no-finding claim to deterministic sensors, commands/artifacts, results, validation assets, or skipped-check reasons. Model judgment alone cannot satisfy verification/testing all-clear.
91
+ - For direct top-level invocation, use the Plan Mode save rule and canonical report contract from `references/audit-report-io.md` for `audits/bugs/<YYYY-MM-DD bugs-audit>.md`.
92
+ - For implementation audit child invocation, return compact findings to the parent unless the parent explicitly requests saved audit artifacts.
93
+ 14. Persist only durable knowledge:
94
+ - Do not persist one-off findings.
95
+ - Persist repeated bug patterns, fragile project-specific flows, accepted exceptions, or reusable verification recipes after scoring with the Importance Calibration System.
96
+ - Use required tags: `project:<projectId>`, `session:<workflowSessionId>`, `workflow:bugs-audit`, `entity:<entity>`, and one `memory:<tier>` tag.
97
+ 15. Complete the Evidence Gate from `references/evidence-gate.md`.
98
+
99
+ ## Examples
100
+
101
+ User asks: "Find bugs in modified files."
102
+
103
+ 1. Use `workflowSessionId=bugs-audit-modified-files`.
104
+ 2. Scope to staged, unstaged, and relevant untracked files; exclude generated/dependency/build/log/cache/secret paths.
105
+ 3. Inspect diffs first, then surrounding code and tests for suspicious changes.
106
+ 4. Run a false-positive pass before reporting findings.
107
+
108
+ User asks: "Review commits made by me in this branch for bugs."
109
+
110
+ 1. Use `workflowSessionId=bugs-audit-branch-commits`.
111
+ 2. Resolve author from Git config and branch base from upstream or main/master fallback.
112
+ 3. Review only branch-unique commits authored by that identity.
113
+ 4. Report findings by severity with confidence, evidence, and verification suggestions.
@@ -0,0 +1,97 @@
1
+ ### Bugs Fix
2
+
3
+ Use this workflow only to execute fixes from a bugs audit markdown report.
4
+
5
+ Before the first substantive read, load `references/project-context.md` and run the project-context intake sweep for this repository.
6
+
7
+ Before the first repository mutation, load `references/implementation-delivery.md` for worktree isolation, atomic commits, PR creation, CI watch, and the merge gate, and `references/code-annotation.md` for doc blocks, rationale comments, and test coverage on every created or updated unit. If two consecutive fix attempts fail on the same symptom, stop editing and load `references/root-cause-scripts.md`.
8
+
9
+ Do not use this workflow for findings-only bug discovery; route that to `workflows/bugs/bugs-audit.md`. Do not use it for one known broken behavior without an audit report; route that to `workflows/debug.md`. Do not use it for broad product/design changes; route those to `workflows/spec-driven.md`.
10
+
11
+ 1. Resolve/reuse `workflowSessionId`: `bugs-fix-[entity]`
12
+ 2. Load shared references:
13
+ - `references/audit-report-io.md` before any code or test change
14
+ - `references/lessons.md` to load confirmed project lessons
15
+ - `references/codebase-investigation.md` before changing unfamiliar bug paths
16
+ - `references/verification-ladder.md` before non-trivial edits
17
+ - `references/context-firewall.md` before inspecting large diffs, logs, snapshots, generated reports, or broad search output
18
+ - `references/agent-orchestration.md` only for large/high-risk findings, disjoint implementation slices, or independent verification
19
+ 3. `recall` -> load prior bug patterns, known regressions, fragile flows, accepted exceptions, testing conventions, and reusable verification recipes for the report target.
20
+ 4. Select the bugs audit report with execution focus:
21
+ - Establish the report selector, target focus, and optional finding selector before selecting a report. Target focus can be a flow, module, files/globs, branch comparison, commit range, symbol/class/function, feature area, or explicit whole-repo target.
22
+ - If the user gives a path, read that exact markdown file.
23
+ - If the user asks for "latest" or gives no path, require a concrete target focus first; do not run the latest bugs report against an unspecified target.
24
+ - Select the latest `audits/bugs/<YYYY-MM-DD bugs-audit>.md` only after target focus is known, using `references/audit-report-io.md`.
25
+ - Stop if no report exists; do not infer findings from conversation history.
26
+ - Validate the report with `references/audit-report-io.md`: workflow, `ProjectId`, `Target`, `Target Focus`, scope, git base/head, required fields, `BUG-` IDs, resolved files or material scope evidence, and current file/line evidence. Stop on invalid, stale, target-drifted, or ambiguous reports before editing.
27
+ 5. Extract actionable bug findings:
28
+ - Keep findings with concrete `Bug Class`, `Impacted Flow`, `Trigger or Repro Path`, `Root Cause Hypothesis`, `Regression Risk`, `Location`, `Evidence`, `Simplest Fix Direction`, and `Verification Suggestion`.
29
+ - Ignore ruled-out candidates, no-finding sections, and low-confidence hardening ideas unless the user explicitly asks to include them.
30
+ - If the user supplied finding IDs, extract only those IDs after validating they exist and match the current target focus.
31
+ - Rank by severity, trigger likelihood, regression risk, dependency order, and verification cost.
32
+ 6. Build a bug-fix map before editing:
33
+ - Finding ID -> impacted flow, trigger/repro path, suspected root cause, expected behavior, current behavior, files likely affected, validation assets, and verification command.
34
+ - Group findings only when one small fix addresses the same root cause.
35
+ - Keep unrelated cleanup out of scope.
36
+ 7. Size each finding with `references/verification-ladder.md`:
37
+ - Quick: local guard, null/state fix, small validation correction, deterministic branch fix, config/default correction, or focused regression test.
38
+ - Standard: multi-file data-flow fix, persistence or async behavior change, public contract correction, migration-adjacent repair, or meaningful test impact; define repro and verification recipe first.
39
+ - Spec-driven: new behavior policy, broad design change, cross-boundary ownership decision, migration strategy, or unclear expected behavior; pause and route to `workflows/spec-driven.md` or ask for approval.
40
+ 8. Apply bug fixing methods:
41
+ - Reproduce or confirm the trigger first when feasible; otherwise prove the root-cause path from current source evidence.
42
+ - Trace input -> transformation -> output and fix the divergence point closest to the root cause.
43
+ - Preserve existing public contracts unless the report explicitly identifies them as the bug.
44
+ - Prefer the smallest behavior-preserving fix: guard, validation, state update, ordering, await/async correction, persistence constraint, config default, or call-site contract alignment.
45
+ - Add or update regression tests for the trigger path when feasible; include positive coverage so the fix does not over-block valid behavior.
46
+ - Do not weaken tests, fixtures, snapshots, types, or public contracts to make the fix pass.
47
+ 9. Use agent orchestration only when it improves signal. Dispatch per `references/agent-orchestration.md`:
48
+
49
+ > **Dispatch: `massa-ai-builder`** (role: `builder`) — charter `skills/agents/builder/SKILL.md`
50
+ > - trigger: large/high-risk finding, disjoint implementation slice, or explicit subagent request
51
+ > - scope: one isolated bug finding with a disjoint write set
52
+ > - permissions: write (disjoint write set)
53
+ > - inputs: the finding ID, repro path, root cause, and simplest fix direction
54
+ > - sensors: report's verification suggestion or equivalent deterministic command; repro path must fail before fix and pass after
55
+ > - output: implementation summary, commands run, test counts, deviations
56
+ > - firewall: raw diffs/logs summarized
57
+ > - memory: suggest-only; main agent persists reusable bug patterns
58
+
59
+ > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
60
+ > - trigger: independent verification of a high-risk bug fix
61
+ > - scope: the fixed finding's repro path, tests, and report claim closure
62
+ > - permissions: read-only
63
+ > - inputs: the finding, the applied fix, the verification suggestion, and validation assets
64
+ > - sensors: deterministic command (repro path, focused tests, inspection) and report claim closure
65
+ > - output: confirmed/disproven closure verdict with evidence
66
+ > - firewall: raw test output/logs summarized
67
+ > - memory: suggest-only; main agent persists reusable verification recipes
68
+ - Main agent owns report parsing, prioritization, memory writes, final synthesis, and Evidence Gate.
69
+ 10. Verify each completed finding:
70
+ - If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
71
+ `python3 skills/massa-ai/scripts/lessons.py --root . add --feature "<slug>" --signal "<signal>" --source "<ref>" --text "<one terse lesson>"`
72
+ - Apply the Mandatory Verification Fix Gate from `references/verification-ladder.md`: run the report's Verification Suggestion or an equivalent deterministic command/artifact check for each selected finding or coherent group.
73
+ - A finding cannot be marked `fixed` when a target-relevant command or artifact check exists but was not attempted; if verification cannot run, mark it `blocked`, `deferred`, or `skipped` with an allowed skipped-check reason.
74
+ - Run the report's verification suggestion when available.
75
+ - Run focused regression tests first, then relevant lint/type/build/test commands when feasible.
76
+ - Confirm validation assets were not weakened.
77
+ - Record command/artifact, result, skipped reason or `none`, highest Verification Ladder level reached, validation assets protected, and residual risk.
78
+ 11. At completion, persist only durable knowledge:
79
+ - Root causes, fragile project-specific flows, accepted exceptions, or reusable regression-test recipes after scoring with the Importance Calibration System.
80
+ - Use required tags: `project:<projectId>`, `session:<workflowSessionId>`, `workflow:bugs-fix`, `entity:<entity>`, and one `memory:<tier>` tag.
81
+ 12. Complete the Evidence Gate from `references/evidence-gate.md`.
82
+
83
+ ## Examples
84
+
85
+ User asks: "Use bugs-fix to fix latest audit findings for checkout persistence."
86
+
87
+ 1. Confirm target focus is `checkout persistence`, then read the latest matching `audits/bugs/* bugs-audit.md`.
88
+ 2. Validate metadata, target focus, freshness, required fields, and current evidence before editing.
89
+ 3. Confirm each trigger or root-cause path.
90
+ 4. Fix the smallest root-cause divergence and add regression coverage when feasible.
91
+ 5. Run focused verification and report skipped broader checks.
92
+
93
+ User asks: "Fix BUG-2 from audits/bugs/2026-06-07 bugs-audit.md."
94
+
95
+ 1. Read the specified report and only execute `BUG-2`.
96
+ 2. Preserve other bug findings for later.
97
+ 3. Report evidence for `BUG-2` closure and residual risks.