@massa-ai/codex-plugin 1.34.0 → 1.35.1

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 (39) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/package.json +1 -1
  3. package/skills/massa-ai/references/agent-orchestration.md +4 -0
  4. package/skills/massa-ai/references/artifact-persistence.md +46 -0
  5. package/skills/massa-ai/references/audit-report-io.md +50 -0
  6. package/skills/massa-ai/references/brownfield-mapping.md +22 -0
  7. package/skills/massa-ai/references/codebase-investigation.md +1 -1
  8. package/skills/massa-ai/references/discrimination-sensor.md +42 -0
  9. package/skills/massa-ai/references/implementation-delivery.md +17 -3
  10. package/skills/massa-ai/references/knowledge-verification-chain.md +25 -0
  11. package/skills/massa-ai/references/maestro/cloud.md +2 -0
  12. package/skills/massa-ai/references/maestro/fact-ledger.md +2 -0
  13. package/skills/massa-ai/references/maestro/patterns.md +7 -1
  14. package/skills/massa-ai/references/mobile-figma-matcher/core.md +13 -0
  15. package/skills/massa-ai/references/spec-driven/artifact-store.md +2 -32
  16. package/skills/massa-ai/references/spec-driven/design.md +1 -1
  17. package/skills/massa-ai/references/spec-driven/validate.md +9 -31
  18. package/skills/massa-ai/references/verification-ladder.md +16 -0
  19. package/skills/massa-ai/scripts/check_fix_closure.ts +335 -0
  20. package/skills/massa-ai/scripts/check_specs_delivered.ts +61 -15
  21. package/skills/massa-ai/scripts/validate_audit_report.ts +2 -1
  22. package/skills/massa-ai/workflows/architecture/architecture-fix.md +31 -19
  23. package/skills/massa-ai/workflows/bugs/bugs-fix.md +29 -16
  24. package/skills/massa-ai/workflows/code-quality/code-quality-fix.md +36 -21
  25. package/skills/massa-ai/workflows/debug.md +44 -15
  26. package/skills/massa-ai/workflows/design.md +2 -0
  27. package/skills/massa-ai/workflows/exploration.md +1 -16
  28. package/skills/massa-ai/workflows/feature.md +26 -4
  29. package/skills/massa-ai/workflows/general.md +28 -4
  30. package/skills/massa-ai/workflows/implementation/implementation-fix.md +25 -16
  31. package/skills/massa-ai/workflows/maestro/maestro-fix.md +25 -4
  32. package/skills/massa-ai/workflows/maestro/maestro.md +2 -0
  33. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-fix.md +51 -16
  34. package/skills/massa-ai/workflows/refactor.md +34 -3
  35. package/skills/massa-ai/workflows/requirements/requirements-fix.md +31 -17
  36. package/skills/massa-ai/workflows/security/security-fix.md +30 -17
  37. package/skills/massa-ai/workflows/spec-driven.md +6 -21
  38. package/skills/massa-ai/workflows/tests/tests-fix.md +33 -17
  39. package/skills/massa-ai/references/spec-driven/brownfield-mapping.md +0 -16
@@ -3,7 +3,7 @@ name: bugs-fix
3
3
  description: "Executes fixes from a saved bugs audit report; not for findings-only discovery, single known issues without a report, or broad product changes."
4
4
  license: MIT
5
5
  metadata:
6
- version: "1.1.0"
6
+ version: "1.2.0"
7
7
  ---
8
8
 
9
9
  ### Bugs Fix
@@ -12,7 +12,9 @@ Execute fixes from a bugs audit markdown report only.
12
12
 
13
13
  Load `references/project-context.md` (intake sweep) before the first substantive read.
14
14
 
15
- Before the first repository mutation, load `references/implementation-delivery.md` (delivery chain: worktree, atomic commits, PR, CI watch, merge gate) and `references/code-annotation.md` (doc blocks, rationale, test coverage). After two consecutive failed fixes on one symptom, stop editing and load `references/root-cause-scripts.md`.
15
+ Before the first repository mutation, load `references/implementation-delivery.md` (delivery chain: worktree, atomic commits, PR, CI watch, merge gate — its Stage 3 delivery-authorization scope covers one go-ahead through PR creation; force-push/deploy/merge stay separately gated) and `references/code-annotation.md` (doc blocks, rationale, test coverage). After two consecutive failed fixes on one symptom, stop editing and load `references/root-cause-scripts.md`.
16
+
17
+ **Isolation Gate — before the first file edit:** execute `references/implementation-delivery.md` Stage 0–1 now (fetch base, create the worktree + branch, work inside it) and record the worktree path + branch — or one of Stage 1's two legal skip reasons, verbatim — before any repository mutation.
16
18
 
17
19
  Not for findings-only bug discovery — route to `workflows/bugs/bugs-audit.md`. Not for one known broken behavior without an audit report — route to `workflows/debug.md`. Not for broad product/design changes — route to `workflows/spec-driven.md`.
18
20
 
@@ -24,6 +26,9 @@ Not for findings-only bug discovery — route to `workflows/bugs/bugs-audit.md`.
24
26
  - `references/verification-ladder.md` before non-trivial edits
25
27
  - `references/context-firewall.md` before inspecting large diffs, logs, snapshots, generated reports, or broad search output
26
28
  - `references/agent-orchestration.md` only for large/high-risk findings, disjoint implementation slices, or independent verification
29
+ - `references/discrimination-sensor.md` before closing any finding under the Mandatory Verification Fix Gate
30
+ - `references/knowledge-verification-chain.md` when the bug's root cause depends on an external library's or API's actual behavior
31
+ - `references/brownfield-mapping.md` (Minimum Bar only, Standard+ bug findings) when recall returns no hit for the bug's target and no gate command can be derived from the report's evidence
27
32
  3. `recall` -> load prior bug patterns, known regressions, fragile flows, accepted exceptions, testing conventions, and reusable verification recipes for the report target.
28
33
  4. Select the bugs audit report with execution focus:
29
34
  - 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.
@@ -52,7 +57,7 @@ Not for findings-only bug discovery — route to `workflows/bugs/bugs-audit.md`.
52
57
  - Prefer the smallest behavior-preserving fix: guard, validation, state update, ordering, await/async correction, persistence constraint, config default, or call-site contract alignment.
53
58
  - Add or update regression tests for the trigger path when feasible; include positive coverage so the fix does not over-block valid behavior.
54
59
  - Do not weaken tests, fixtures, snapshots, types, or public contracts to make the fix pass.
55
- 9. Use agent orchestration only when it improves signal. Dispatch per `references/agent-orchestration.md`:
60
+ 9. Use agent orchestration only when it improves signal, except independent verification of the bug fix, which is mandated at the tiers named in `references/agent-orchestration.md`'s Independent Verification Exception. Dispatch per `references/agent-orchestration.md`:
56
61
 
57
62
  > **Dispatch: `massa-ai-builder`** (role: `builder`) — charter `skills/agents/builder/SKILL.md`
58
63
  > - trigger: large/high-risk finding, disjoint implementation slice, or explicit subagent request
@@ -65,18 +70,6 @@ Not for findings-only bug discovery — route to `workflows/bugs/bugs-audit.md`.
65
70
  > - memory: suggest-only; main agent persists reusable bug patterns
66
71
  > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
67
72
 
68
- > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
69
- > - trigger: independent verification of a high-risk bug fix
70
- > - scope: the fixed finding's repro path, tests, and report claim closure
71
- > - permissions: read-only
72
- > - inputs: the finding, the applied fix, the verification suggestion, and validation assets
73
- > - sensors: deterministic command (repro path, focused tests, inspection) and report claim closure
74
- > - output: confirmed/disproven closure verdict with evidence
75
- > - firewall: raw test output/logs summarized
76
- > - memory: suggest-only; main agent persists reusable verification recipes
77
- > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
78
- - Main agent owns report parsing, prioritization, memory writes, final synthesis, and Evidence Gate.
79
-
80
73
  > **Dispatch: `massa-ai-reviewer`** (role: `reviewer`) — charter `skills/agents/reviewer/SKILL.md`
81
74
  > - trigger: implementation complete, before the verification gate — never optional
82
75
  > - scope: the fix's diff surface and its task/AC context
@@ -89,19 +82,36 @@ Not for findings-only bug discovery — route to `workflows/bugs/bugs-audit.md`.
89
82
  > - fallback: if the subagent is unavailable, run a standalone fresh-eyes review against this output contract and record the skipped-delegation reason
90
83
  > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
91
84
 
85
+ > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
86
+ > - trigger: mandatory at Standard+/Spec-driven bug-fix size or high/critical bug severity, per the Independent Verification Mandate tier gate in `references/verification-ladder.md`
87
+ > - scope: the fixed bug finding's repro path, regression tests, and report claim closure
88
+ > - permissions: read-only
89
+ > - inputs: the bug finding, the applied root-cause fix, the verification suggestion, and validation assets
90
+ > - sensors: deterministic command (repro path, focused regression tests, inspection) and report claim closure; discrimination sensor per `references/discrimination-sensor.md` (the divergence-point fix just applied)
91
+ > - output: confirmed/disproven bug-closure verdict with evidence
92
+ > - firewall: raw repro transcripts and test/log output summarized
93
+ > - memory: suggest-only; main agent persists bug-closure verification outcomes
94
+ > - fallback: if the subagent is unavailable, run a standalone fresh-eyes re-check of the bug-fix closure evidence against this output contract and record the skipped-delegation reason
95
+ > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
96
+ - Main agent owns report parsing, prioritization, memory writes, final synthesis, and Evidence Gate.
97
+
92
98
  10. Verify each completed finding:
93
99
  - If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
94
100
  `bun skills/massa-ai/scripts/lessons.ts --root . add --feature "<slug>" --signal "<signal>" --source "<ref>" --text "<one terse lesson>"`
95
101
  - 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.
96
102
  - 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.
97
103
  - Run the report's verification suggestion when available.
104
+ - The red→green reproduction proves the regression test catches this bug; the discrimination sensor proves that same assertion would also discriminate against a future wrong implementation — complementary, and both required at Standard+.
105
+ - At the tiers named in the verification-agent dispatch's trigger above, run the discrimination sensor per `references/discrimination-sensor.md` against the divergence-point fix; a surviving mutant marks the finding's closure row `blocked` and records the `surviving_mutant` lessons signal even when the reproduction test is green.
106
+ - The fix→re-verify cycle is capped per `references/verification-ladder.md`'s Bounded Fix→Re-verify Loop; this is a separate counter from the two-consecutive-failed-fixes breaker into `references/root-cause-scripts.md` above, which fires inside one iteration and neither consumes nor resets the loop count.
98
107
  - Run focused regression tests first, then relevant lint/type/build/test commands when feasible.
99
108
  - Confirm validation assets were not weakened.
100
109
  - Record command/artifact, result, skipped reason or `none`, highest Verification Ladder level reached, validation assets protected, and residual risk.
101
110
  11. At completion, persist only durable knowledge:
102
111
  - Root causes, fragile project-specific flows, accepted exceptions, or reusable regression-test recipes after scoring with the Importance Calibration System.
103
112
  - Use required tags: `project:<projectId>`, `session:<workflowSessionId>`, `workflow:bugs-fix`, `entity:<entity>`, and one `memory:<tier>` tag.
104
- 12. Complete the Evidence Gate from `references/evidence-gate.md`.
113
+ 12. Write the Fix Closure Report per `references/audit-report-io.md`'s Fix Closure Report Contract (`audits/bugs/<YYYY-MM-DD bugs-fix-closure>.md`), then run `bun skills/massa-ai/scripts/check_fix_closure.ts <closure.md> --family bugs` before Propose and the Evidence Gate — a non-zero exit blocks both. If no code-execution tool is available, run the same checks by reading the artifact (graceful degradation preserved).
114
+ 13. Complete the Evidence Gate from `references/evidence-gate.md`.
105
115
 
106
116
  ## Examples
107
117
 
@@ -118,3 +128,6 @@ User asks: "Fix BUG-2 from audits/bugs/2026-06-07 bugs-audit.md."
118
128
  1. Read the specified report and only execute `BUG-2`.
119
129
  2. Preserve other bug findings for later.
120
130
  3. Report evidence for `BUG-2` closure and residual risks.
131
+
132
+ <!-- validator anchors: "Independent Verification Exception", "the divergence-point fix just applied", "audits/bugs/<YYYY-MM-DD bugs-fix-closure>.md", "check_fix_closure.ts <closure.md> --family bugs", "The red→green reproduction proves the regression test catches this bug", "Bounded Fix→Re-verify Loop" -->
133
+
@@ -3,7 +3,7 @@ name: code-quality-fix
3
3
  description: "Executes fixes from a saved code quality audit report; not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, or overengineering analysis."
4
4
  license: MIT
5
5
  metadata:
6
- version: "1.1.0"
6
+ version: "1.2.0"
7
7
  ---
8
8
 
9
9
  ### Code Quality Fix
@@ -12,7 +12,9 @@ Execute fixes from a code quality audit markdown report only.
12
12
 
13
13
  Load `references/project-context.md` (intake sweep) before the first substantive read.
14
14
 
15
- Before the first repository mutation, load `references/implementation-delivery.md` (delivery chain: worktree, atomic commits, PR, CI watch, merge gate) and `references/code-annotation.md` (doc blocks, rationale, test coverage). After two consecutive failed fixes on one symptom, stop editing and load `references/root-cause-scripts.md`.
15
+ Before the first repository mutation, load `references/implementation-delivery.md` (delivery chain: worktree, atomic commits, PR, CI watch, merge gate — its Stage 3 delivery-authorization scope covers one go-ahead through PR creation; force-push/deploy/merge stay separately gated) and `references/code-annotation.md` (doc blocks, rationale, test coverage). After two consecutive failed fixes on one symptom, stop editing and load `references/root-cause-scripts.md`.
16
+
17
+ **Isolation Gate — before the first file edit:** execute `references/implementation-delivery.md` Stage 0–1 now (fetch base, create the worktree + branch, work inside it) and record the worktree path + branch — or one of Stage 1's two legal skip reasons, verbatim — before any repository mutation.
16
18
 
17
19
  Not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or overengineering analysis — route to `workflows/code-quality/code-quality-audit.md`.
18
20
 
@@ -22,9 +24,12 @@ Not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or o
22
24
  - `references/lessons.md` to load confirmed project lessons
23
25
  - `references/codebase-investigation.md` before changing unfamiliar code
24
26
  - `references/verification-ladder.md` before non-trivial edits
27
+ - `references/discrimination-sensor.md` before closing a behavior-preservation finding at Standard+/Spec-driven size or high/critical severity, to size the mutation-target sensor against the transformed code
28
+ - `references/knowledge-verification-chain.md` when the fix direction depends on an external library or API's current behavior rather than in-repo convention
25
29
  - `references/naming-standards.md` before renaming identifiers, introducing domain vocabulary, or changing public contract names
26
30
  - `references/context-firewall.md` before inspecting large diffs, logs, generated reports, or broad search output
27
31
  - `references/agent-orchestration.md` only for large/high-risk findings, disjoint implementation slices, or independent verification
32
+ - `references/brownfield-mapping.md` (Minimum Bar) when a Standard+ finding's target has no recall hit and the report's evidence yields no derivable gate command
28
33
  3. `recall` -> load project style rules, accepted quality exceptions, testing conventions, prior anti-patterns, and verification recipes for the report target.
29
34
  4. Select the code quality audit report with execution focus:
30
35
  - Establish the report selector, target focus, and optional finding selector before selecting a report. Target focus can be a module, service layer, files/globs, branch comparison, commit range, symbol/class/function, feature/flow, or explicit whole-repo target.
@@ -59,7 +64,7 @@ Not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or o
59
64
  - Run or identify characterization tests before changing behavior-adjacent code.
60
65
  - Do not weaken tests, fixtures, snapshots, types, or public contracts to make cleanup pass.
61
66
  - Prefer small reversible edits; verify after each finding or coherent group.
62
- 10. Use agent orchestration only when it improves signal. Dispatch per `references/agent-orchestration.md`:
67
+ 10. Use agent orchestration only when it improves signal — except the verification-agent dispatch below, which `references/agent-orchestration.md`'s Independent Verification Exception mandates at the tiers named in its trigger regardless of signal improvement. Dispatch per `references/agent-orchestration.md`:
63
68
 
64
69
  > **Dispatch: `massa-ai-builder`** (role: `builder`) — charter `skills/agents/builder/SKILL.md`
65
70
  > - trigger: large/high-risk finding, disjoint implementation slice, or explicit subagent request
@@ -72,30 +77,31 @@ Not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or o
72
77
  > - memory: suggest-only; main agent persists reusable code-quality patterns
73
78
  > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
74
79
 
75
- > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
76
- > - trigger: independent verification of a high-risk code-quality fix
77
- > - scope: the fixed finding's behavior preservation, imports, tests, and report claim closure
78
- > - permissions: read-only
79
- > - inputs: the finding, the applied fix, the verification suggestion, and validation assets
80
- > - sensors: deterministic command (behavior-preservation check, import graph, tests) and report claim closure
81
- > - output: confirmed/disproven closure verdict with evidence
82
- > - firewall: raw test output/logs summarized
83
- > - memory: suggest-only; main agent persists reusable verification recipes
84
- > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
85
- - Main agent owns report parsing, prioritization, memory writes, final synthesis, and Evidence Gate.
86
-
87
80
  > **Dispatch: `massa-ai-reviewer`** (role: `reviewer`) — charter `skills/agents/reviewer/SKILL.md`
88
- > - trigger: implementation complete, before the verification gate — never optional
81
+ > - trigger: implementation of the CQ finding complete, before the verification gate — never optional
89
82
  > - scope: the fix's diff surface and its task/AC context
90
83
  > - permissions: read-only
91
- > - inputs: diff, acceptance context, recalled code-quality conventions
84
+ > - inputs: diff, CQ acceptance context, recalled code-quality conventions
92
85
  > - sensors: bugs, regressions, missing edge cases, smells introduced by the diff
93
- > - output: ranked findings, blocking vs advisory; blocking findings become fix items before verification runs
86
+ > - output: ranked findings, blocking vs advisory; blocking findings become CQ fix items before verification runs
94
87
  > - firewall: summarized findings only, never raw diff dumps
95
- > - memory: suggest-only; main agent persists
88
+ > - memory: suggest-only; main agent persists review outcomes for the code-quality fix
96
89
  > - fallback: if the subagent is unavailable, run a standalone fresh-eyes review against this output contract and record the skipped-delegation reason
97
90
  > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
98
91
 
92
+ > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
93
+ > - trigger: mandatory per the verification-ladder's Independent Verification Mandate at Standard+/Spec-driven finding size or high/critical severity; at Quick size the subagent hop is skipped and the standalone fresh-eyes check below runs instead
94
+ > - scope: the fixed finding's behavior-preservation claim over the moved/transformed code, its call sites/imports, and report claim closure
95
+ > - permissions: read-only
96
+ > - inputs: the finding, the applied fix, the verification suggestion, and validation assets
97
+ > - sensors: deterministic command (behavior-preservation check, import graph, characterization tests); discrimination sensor per `references/discrimination-sensor.md` (mutate the pre-fix moved/transformed code the behavior-preservation claim protects, never newly introduced code)
98
+ > - output: confirmed/disproven closure verdict with evidence
99
+ > - firewall: raw test output/logs summarized
100
+ > - memory: suggest-only; main agent persists code-quality verification outcomes
101
+ > - fallback: if the subagent is unavailable, run a standalone fresh-eyes re-check of the code-quality closure evidence against this output contract and record the skipped-delegation reason
102
+ > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
103
+ - Main agent owns report parsing, prioritization, memory writes, final synthesis, and Evidence Gate.
104
+
99
105
  11. Verify each completed finding:
100
106
  - If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
101
107
  `bun skills/massa-ai/scripts/lessons.ts --root . add --feature "<slug>" --signal "<signal>" --source "<ref>" --text "<one terse lesson>"`
@@ -106,10 +112,16 @@ Not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or o
106
112
  - Perform a focused diff review for touched identifiers and confirm generic names are either replaced with precise domain/role names or justified by narrow conventional scope.
107
113
  - Check validation assets were not weakened unless explicitly requested.
108
114
  - Record command/artifact, result, skipped reason or `none`, highest Verification Ladder level reached, validation assets protected, and residual risk.
109
- 12. At completion, persist only durable knowledge:
115
+ - At the same Standard+/Spec-driven-or-high/critical tiers as the Independent Verification Mandate, run the discrimination sensor from `references/discrimination-sensor.md` against the pre-fix moved/transformed code the behavior-preservation claim protects; Quick mechanical transforms (rename, inline, delete) are exempt. A surviving mutant is an unproven preservation claim: strengthen the characterization test or close the row `blocked` and emit the `surviving_mutant` lessons signal — do not mark it `fixed`.
116
+ - When a survivor traces to cross-boundary coupling rather than a weak assertion, route it through this workflow's step 5 reclassification gate (bounded-context/dependency-direction/seam/module-depth invalidity check) to `workflows/architecture/architecture-fix.md` instead of forcing a local fix.
117
+ - The fix→re-verify cycle is capped per `references/verification-ladder.md`'s Bounded Fix→Re-verify Loop; exceeding the cap stops the finding at `Blocked` with evidence preserved. That cap is a separate counter from the two-consecutive-failed-fixes breaker in the preamble above — the breaker fires inside a single iteration and neither consumes nor resets the cap.
118
+ 12. Close out with the Fix Closure Report:
119
+ - Write the Fix Closure Report per `references/audit-report-io.md` (Fix Closure Report Contract) to `audits/code-quality/<YYYY-MM-DD code-quality-fix-closure>.md`, one Closure Matrix row per selected finding.
120
+ - Run `bun skills/massa-ai/scripts/check_fix_closure.ts <closure.md> --family code-quality` before Propose/Evidence Gate; a non-zero exit blocks Propose. If no code-execution tool is available, run the same checks by reading the artifact (graceful degradation preserved).
121
+ 13. At completion, persist only durable knowledge:
110
122
  - Repeated anti-patterns, accepted quality exceptions, project-specific refactoring recipes, or reusable checks after scoring with the Importance Calibration System.
111
123
  - Use required tags: `project:<projectId>`, `session:<workflowSessionId>`, `workflow:code-quality-fix`, `entity:<entity>`, and one `memory:<tier>` tag.
112
- 13. Complete the Evidence Gate from `references/evidence-gate.md`.
124
+ 14. Complete the Evidence Gate from `references/evidence-gate.md`.
113
125
 
114
126
  ## Examples
115
127
 
@@ -120,3 +132,6 @@ User asks: "Use code-quality-fix to fix latest findings for billing services."
120
132
  3. Execute confirmed non-suspect findings by severity and behavior risk.
121
133
  4. Prefer delete/inline/rename/extract before introducing new abstractions.
122
134
  5. Verify behavior and validation assets after each finding group.
135
+
136
+ <!-- validator anchors: references/discrimination-sensor.md; references/knowledge-verification-chain.md; references/brownfield-mapping.md; Independent Verification Exception; Fix Closure Report Contract; check_fix_closure.ts --family code-quality; Bounded Fix→Re-verify Loop; Stage 3 delivery-authorization scope -->
137
+
@@ -3,7 +3,7 @@ name: debug
3
3
  description: "Use this workflow for evidence-backed root-cause diagnosis of broken behavior, failures, regressions, or crashes; route new capabilities to feature and broad redesign to spec-driven."
4
4
  license: MIT
5
5
  metadata:
6
- version: "1.1.0"
6
+ version: "1.2.0"
7
7
  ---
8
8
 
9
9
  ### 🔴 Debug
@@ -14,6 +14,8 @@ Load `references/project-context.md` (intake sweep) before the first substantive
14
14
 
15
15
  Before the first repository mutation, load `references/implementation-delivery.md` (delivery chain: worktree, atomic commits, PR, CI watch, merge gate) and `references/code-annotation.md` (doc blocks, rationale, test coverage). After two consecutive failed fixes on one symptom, stop editing and load `references/root-cause-scripts.md`.
16
16
 
17
+ **Isolation Gate — before the first file edit:** execute `references/implementation-delivery.md` Stage 0–1 now (fetch base, create the worktree + branch, work inside it) and record the worktree path + branch — or one of Stage 1's two legal skip reasons, verbatim — before any repository mutation.
18
+
17
19
  1. Generate/reuse `workflowSessionId`: `debug-[entity]`
18
20
  2. Load shared references:
19
21
  - `references/codebase-investigation.md`
@@ -34,29 +36,33 @@ Before the first repository mutation, load `references/implementation-delivery.m
34
36
  `search.sessionId`.
35
37
  - For large files (>200 lines) or derived-value computation, call `execute_file` with `path`, `language`, and `code` to run analysis code over the file instead of loading the entire file into context. Respect the local-dev-only trust model (no untrusted-client exposure).
36
38
  - After opening a file for deep investigation, call `synapse_prefetch` with `id` (the `synapseSessionId`) and `filePath` to warm the Synapse buffer before the next search. Requires an existing `synapse_session` id.
37
- 6. Build or request a trustworthy feedback loop before editing:
39
+ 6. IF step 3's `recall` returned no hit for the debug target AND no `.specs/project/onboarding/` docs already exist for this codebase: run the brownfield Minimum Bar gate in `references/brownfield-mapping.md` — derive `TESTING.md` (feeds the feedback loop's gate commands in step 7) and `CONCERNS.md` (feeds the Hypothesis Board's ranking in step 9) under `.specs/project/onboarding/`. A fix that already looks Quick-sized may proceed on `TESTING.md` alone.
40
+ 7. Build or request a trustworthy feedback loop before editing:
38
41
  - Use the reproduction ladder in `references/debug-diagnosis-loop.md`: unit/CLI repro, integration/API repro, app/browser/device repro, then structured HITL.
39
42
  - IF no loop can run, record a skipped-reason enum from the debug reference and collect the strongest root-cause proof available
40
- 7. Reproduce and minimize the user-described failure without losing the original failure signal
41
- 8. Rank 3-5 falsifiable hypotheses before testing:
43
+ 8. Reproduce and minimize the user-described failure without losing the original failure signal
44
+ 9. Rank 3-5 falsifiable hypotheses before testing:
42
45
  - include evidence, prediction, probe, disproof criteria, and tested result
43
46
  - test one hypothesis at a time; instrument only to answer the current hypothesis
44
47
  - for flaky failures, measure and improve reproduction rate before root-cause guessing
45
- 9. Apply debugging heuristics (see `references/decision-engine.md`):
48
+ - When a hypothesis's disproof turns on external library/API behavior (a narrow case — most debug work is internal to this codebase), run the chain in `references/knowledge-verification-chain.md` before accepting or ruling out that hypothesis.
49
+ 10. Apply debugging heuristics (see `references/decision-engine.md`):
46
50
  - Trace data flow: input → transformation → output
47
51
  - Compare expected vs actual behavior
48
52
  - Check recent changes first
49
53
  - Minimize search space to relevant modules
50
54
  - For call/data-flow path tracing, call `trace_path` with `function_name` (or `qualifiedName`), `project`, `direction` (outbound/inbound/both), `mode` (calls/data_flow/cross_service/all), and `depth` to trace typed-edge BFS paths. `trace_path` only counts 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.
51
- 10. Size the fix before editing:
55
+ 11. Size the fix before editing:
52
56
  - Use the exact Quick, Standard, and Spec-driven thresholds in `references/verification-ladder.md`.
53
57
  - Refactor route applies only when the fix becomes behavior-preserving cleanup after the root cause is proven.
54
- 11. Define the verification recipe before changing code:
58
+ 12. Define the verification recipe before changing code:
55
59
  - reproduction or root-cause proof
56
60
  - commands, tests, or artifact checks that prove the fix
57
61
  - file-integrity checks for validation assets such as tests, specs, benchmarks, fixtures, and snapshots
58
- 12. Fix the divergence point closest to the root cause
59
- 13. Add regression coverage at the correct seam, or document why no valid regression seam exists
62
+ 13. Fix the divergence point closest to the root cause
63
+ 14. Add regression coverage at the correct seam, or document why no valid regression seam exists:
64
+ - (a) write the test first, asserting the exact previously-broken behavior at the divergence point
65
+ - (b) at Standard+, prove the coverage discriminates: run the sensor in `references/discrimination-sensor.md` against the just-fixed code; a surviving mutant means the regression test does not yet prove the fix
60
66
 
61
67
  > **Dispatch: `massa-ai-reviewer`** (role: `reviewer`) — charter `skills/agents/reviewer/SKILL.md`
62
68
  > - trigger: implementation complete, before the verification gate — never optional
@@ -70,19 +76,32 @@ Before the first repository mutation, load `references/implementation-delivery.m
70
76
  > - fallback: if the subagent is unavailable, run a standalone fresh-eyes review against this output contract and record the skipped-delegation reason
71
77
  > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
72
78
 
73
- 14. If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
79
+ > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
80
+ > - trigger: mandatory at Standard+/Spec-driven fix size, per the Independent Verification Mandate tier gate in `references/verification-ladder.md`; a Quick-tier fix takes the fallback below instead
81
+ > - scope: the fixed divergence point from step 13, its reproduction path, and the regression test added in step 14
82
+ > - permissions: read-only
83
+ > - inputs: the root cause, the reproduction evidence, the regression test, and the changed files — not spec acceptance criteria
84
+ > - sensors: re-run of the reproduction/feedback loop confirming the original failure signal no longer reproduces; discrimination sensor per `references/discrimination-sensor.md` (mutate the fixed code; the regression test must kill it)
85
+ > - output: confirmed/disproven root-cause-closure verdict with evidence
86
+ > - firewall: raw reproduction transcripts and logs summarized, never raw dumps
87
+ > - memory: suggest-only; main agent persists debug verification outcomes
88
+ > - fallback: if the subagent is unavailable, run a standalone fresh-eyes re-check of root cause, reproduction, and regression coverage, and record the skipped-delegation reason
89
+ > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
90
+
91
+ 15. If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
74
92
  `bun skills/massa-ai/scripts/lessons.ts --root . add --feature "<slug>" --signal "<signal>" --source "<ref>" --text "<one terse lesson>"`
75
- Rerun the original feedback loop, run the verification recipe, and remove temporary instrumentation unless intentionally retained as observability
76
- 15. Use `references/agent-orchestration.md` only for independent verification or isolated investigation branches
77
- 16. IF fix found:
93
+ Rerun the original feedback loop, run the verification recipe, and remove temporary instrumentation unless intentionally retained as observability. The fix → re-verify cycle is capped by `references/verification-ladder.md`'s Bounded Fix→Re-verify Loop; a reached cap stops the session `Blocked` with the evidence preserved. That cap counts re-verify cycles across the whole symptom and is a separate counter from the two-consecutive-failed-fixes breaker into `references/root-cause-scripts.md` named in this file's preamble — that breaker fires inside a single edit iteration and neither consumes nor resets the re-verify count.
94
+ 16. Use `references/agent-orchestration.md` for isolated investigation branches; the Standard+ verifier dispatch above is mandated by that reference's Independent Verification Exception, not merely loaded when it improves signal.
95
+ 17. IF fix found:
78
96
  - Persist the root cause via `remember` as a scored `decision` memory with `memory:semantic`
79
97
  - Persist the fix pattern via `remember` as a scored `pattern` memory with `memory:procedural`
80
98
  - If a prior debugging memory for this entity is now stale or contradicted by the fix, call `memory_update` with its `id` and the corrected `content` (re-embeds automatically)
81
- 17. IF NOT resolved:
99
+ 18. IF NOT resolved:
82
100
  - Persist what was ruled out via `remember` as a scored `conversation` memory with `memory:episodic`
83
101
  - Persist repeated failed tool loops as procedural cognition lessons only when they are reusable
84
102
  - Document remaining hypotheses for future sessions
85
- 18. Complete the Evidence Gate from `references/evidence-gate.md`
103
+ 19. At Standard+ size, serialize this file's Output Contract sections into `.specs/debug/<slug>/REPORT.md` and run `bun skills/massa-ai/scripts/check_specs_delivered.ts <slug> --kind debug` before the Evidence Gate; a non-zero exit blocks completion. If no code-execution tool is available, run the same checks by reading the artifact (graceful degradation preserved). See `references/artifact-persistence.md` for the canonical-store and precedence rules governing this artifact.
104
+ 20. Complete the Evidence Gate from `references/evidence-gate.md`
86
105
 
87
106
  ## Output Contract
88
107
 
@@ -94,6 +113,12 @@ Before the first repository mutation, load `references/implementation-delivery.m
94
113
  - Prevention: regression test, monitor/runbook suggestion, and memory outcome
95
114
  - For mobile bugs: device matrix, platform parity, crash/log artifact, and impacted/unaffected platform validation
96
115
 
116
+ ## Failure Handling
117
+
118
+ - `.specs/debug/<slug>/` unwritable at Standard+: block the `REPORT.md` write and record the blocker; never substitute a memory write or chat summary for the canonical debug artifact.
119
+ - Fix → re-verify loop reaches the `references/verification-ladder.md` cap: stop the session `Blocked`, preserve the collected reproduction and verification evidence, and ask the user for direction.
120
+ - Discrimination sensor mutation on the fixed divergence point is not safely reversible: mark `Blocked` unless the verification-agent can show equivalent discrimination from an existing deterministic mutation fixture.
121
+
97
122
  ## Example
98
123
 
99
124
  User asks: "The login route returns 500 after deploy."
@@ -105,3 +130,7 @@ User asks: "The login route returns 500 after deploy."
105
130
  5. Trace request → auth middleware → session lookup → response, then fix the divergence point closest to the root cause.
106
131
  6. Define the verification recipe: rerun the original route check, add or update regression coverage at the failing seam, and confirm validation assets were not weakened.
107
132
  7. If root cause is a missing `DATABASE_URL`, persist via `remember`: a semantic decision memory for the root cause and a procedural pattern memory for the deploy-env verification command.
133
+ 8. At Standard+ size, dispatch `massa-ai-verification-agent` to independently re-run the reproduction against the `DATABASE_URL` fix and confirm the regression test kills a mutant on the restored connection check before closing.
134
+
135
+ <!-- validator anchors: brownfield Minimum Bar gate | references/knowledge-verification-chain.md | prove the coverage discriminates | Dispatch: `massa-ai-verification-agent` | Independent Verification Exception | Bounded Fix→Re-verify Loop | .specs/debug/<slug>/REPORT.md | check_specs_delivered.ts <slug> --kind debug | graceful degradation preserved | references/artifact-persistence.md | ## Failure Handling -->
136
+
@@ -14,6 +14,8 @@ Load `references/project-context.md` (intake sweep) before the first substantive
14
14
 
15
15
  Before the first repository mutation, load `references/implementation-delivery.md` (delivery chain: worktree, atomic commits, PR, CI watch, merge gate) and `references/code-annotation.md` (doc blocks, rationale, test coverage). After two consecutive failed fixes on one symptom, stop editing and load `references/root-cause-scripts.md`.
16
16
 
17
+ **Isolation Gate — before the first file edit:** execute `references/implementation-delivery.md` Stage 0–1 now (fetch base, create the worktree + branch, work inside it) and record the worktree path + branch — or one of Stage 1's two legal skip reasons, verbatim — before any repository mutation.
18
+
17
19
  Not for Flutter, React Native, web UI, generic Figma exploration, variable-only queries, or MCP troubleshooting.
18
20
 
19
21
  1. Resolve/reuse `workflowSessionId`: `design-[entity]`.
@@ -26,22 +26,7 @@ Write and search in the user's human language. Match the user's prompt language
26
26
 
27
27
  ## Knowledge Verification Chain
28
28
 
29
- When researching or resolving any technical question during exploration, follow this chain in strict order. Never skip steps.
30
-
31
- ```
32
- Step 1: Codebase → existing code, conventions, patterns already in use
33
- Step 2: Project docs (leads, not truth) → README, docs/, inline comments, .specs/project/STATE.md (Decisions) — verify against current source before relying
34
- Step 3: Context7 MCP → resolve library ID, then query for current API/patterns
35
- Step 4: Web search → official docs, reputable sources, community patterns
36
- Step 5: Flag as uncertain → "I'm not certain about X — here's my reasoning, but verify"
37
- ```
38
-
39
- - If a chain step's tool is unavailable (Context7 MCP not registered, no web
40
- access), record it as a skipped sensor with its reason and continue to the next
41
- step. An unavailable step is skipped, never silently treated as answered.
42
- - Never skip to Step 5 if Steps 1-4 are available.
43
- - Step 5 is always flagged uncertain — never presented as fact.
44
- - Never assume or fabricate. If no answer is found, say "I don't know" or "I couldn't find documentation for this". "I don't know" beats invention.
29
+ When researching or resolving any technical question during exploration, follow the 5-step chain in `references/knowledge-verification-chain.md` in strict order — codebase, project docs, Context7 MCP, web search, then flag-as-uncertain. Never skip steps, record an unavailable step as a skipped sensor with its reason, and never present Step 5 output as fact. "I don't know" beats invention.
45
30
 
46
31
  1. Resolve/reuse `projectId` and `workflowSessionId`: `explore-[entity]`.
47
32
  2. Load shared references:
@@ -3,7 +3,7 @@ name: feature
3
3
  description: "Use this workflow to add a new capability, screen, command, integration, or user-facing improvement with clear intent; route broken behavior to debug and broad work to spec-driven."
4
4
  license: MIT
5
5
  metadata:
6
- version: "1.1.0"
6
+ version: "1.2.0"
7
7
  ---
8
8
 
9
9
  ### 🟡 Feature
@@ -14,6 +14,8 @@ Load `references/project-context.md` (intake sweep) before the first substantive
14
14
 
15
15
  Before the first repository mutation, load `references/implementation-delivery.md` (delivery chain: worktree, atomic commits, PR, CI watch, merge gate) and `references/code-annotation.md` (doc blocks, rationale, test coverage). After two consecutive failed fixes on one symptom, stop editing and load `references/root-cause-scripts.md`.
16
16
 
17
+ **Isolation Gate — before the first file edit:** execute `references/implementation-delivery.md` Stage 0–1 now (fetch base, create the worktree + branch, work inside it) and record the worktree path + branch — or one of Stage 1's two legal skip reasons, verbatim — before any repository mutation.
18
+
17
19
  1. Resolve/reuse `projectId` and `workflowSessionId` (`feature-[entity]`)
18
20
  2. `recall` → load prior decisions and patterns for this area
19
21
  - Use the default recall budget: `limit <= 3`, `minImportance >= 0.7`, and `types=["critical","decision","pattern"]` unless the feature needs broader memory discovery.
@@ -26,6 +28,8 @@ Before the first repository mutation, load `references/implementation-delivery.m
26
28
  - `references/naming-standards.md` before writing or renaming code identifiers, public contract fields, tests, fixtures, or implementation-facing design names
27
29
  - `references/pr-task-fix.md` when the verification ladder trigger table applies
28
30
  - `references/lessons.md` when `.specs/lessons.json` exists, to load confirmed project lessons before sizing
31
+ - `references/knowledge-verification-chain.md` when the feature depends on an external library or API whose behavior is not already established from this codebase, running the 5-step chain (codebase → project docs → Context7 → web → flag-uncertain) before relying on that dependency's behavior
32
+ - `references/brownfield-mapping.md` (Minimum Bar only — CONCERNS.md + TESTING.md) when the feature touches an area this codebase does not already document; the full onboarding need stays the existing route-to-`workflows/spec-driven.md` boundary stated above for broad, ambiguous, or cross-boundary work, not a new escalation here
29
33
  4. For Android, iOS, KMP Compose Multiplatform UI, or work whose target matches the enumerated mobile-context trigger set (KMP, iOS, Android, native bridges, mobile lifecycle, offline/sync, permissions, push/background behavior, local persistence, or backend-mobile contracts), run the design-source intake gate from `references/mobile-context.md` (Design-Source Intake Gate) before implementation.
30
34
  5. Size the task before implementation:
31
35
  - Use the exact Quick, Standard, and Spec-driven thresholds in `references/verification-ladder.md`.
@@ -38,13 +42,14 @@ Before the first repository mutation, load `references/implementation-delivery.m
38
42
  8. Establish the verification recipe before Standard edits and before Quick edits that touch validation assets, including file-integrity checks for tests, specs, benchmarks, fixtures, and snapshots used as validation assets
39
43
  - Include a focused naming review when the feature introduces or renames identifiers. New names should use domain or precise role vocabulary, and public/persisted names should not change without explicit compatibility handling.
40
44
  9. For mobile features, capture the mobile context packet, choose shared vs platform-specific boundaries, state platform parity expectations, and include the cheapest relevant mobile verification sensor from `references/mobile-context.md`
41
- 10. Use `references/agent-orchestration.md` only for isolated implementation slices or independent verification
42
- 11. Capture 1-5 testable acceptance criteria in the conversation before implementation starts, or reference an existing spec artifact (e.g. `.specs/features/<slug>/spec.md`) when one already states them. These captured acceptance criteria are the anchor the verification step below checks outcomes against.
45
+ 10. Use `references/agent-orchestration.md` for isolated implementation slices; independent verification is not merely an optional signal-improving choice here — the Independent Verification Exception in that reference mandates a separate verifier at Standard tier and above (dispatch block after PR-group implementation, below)
46
+ 11. Capture 1-5 testable acceptance criteria in the conversation before implementation starts, or reference an existing spec artifact (e.g. `.specs/features/<slug>/spec.md`) when one already states them. These captured acceptance criteria are the anchor the verification step below checks outcomes against. Persist them per tier per `references/artifact-persistence.md`: Quick work writes `.specs/quick/NNN-slug/TASK.md` (plus `SUMMARY.md` at completion); Standard tier and above write `.specs/features/<slug>/spec.md` and, once verified, `validation.md`, reusing spec-driven's shape so `validate_state.ts` and the delivery Stage 3.5 gate work unmodified. An unwritable artifact location blocks the workflow rather than proceeding silently.
43
47
  12. Implement the feature by PR group when `references/pr-task-fix.md` applies:
44
48
  - Order non-breaking groups by Data, Domain, then Presentation/Navigation, mapping those labels to repository boundaries when needed.
45
49
  - Validate each group with the verification recipe before committing.
46
50
  - Invoke `workflows/commit.md` for each verified group; do not duplicate commit staging, message, audit-exclusion, or Jira-prefix rules in this workflow.
47
51
  - When every group has a confirmed Jira key, follow the optional stacked branch flow in `references/pr-task-fix.md` (Jira-Key Stacked Branches).
52
+ - All PR groups decomposed under this feature share one feature-level delivery go-ahead: no individual group seeks or receives its own Stage 3 sign-off — see `references/implementation-delivery.md` Stage 3.
48
53
 
49
54
  > **Dispatch: `massa-ai-reviewer`** (role: `reviewer`) — charter `skills/agents/reviewer/SKILL.md`
50
55
  > - trigger: implementation complete, before the verification gate — never optional
@@ -58,10 +63,27 @@ Before the first repository mutation, load `references/implementation-delivery.m
58
63
  > - fallback: if the subagent is unavailable, run a standalone fresh-eyes review against this output contract and record the skipped-delegation reason
59
64
  > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
60
65
 
61
- 13. Run the verification recipe and check outcomes against the captured acceptance criteria from step 11, not only against a generic verification recipe; report skipped checks explicitly. If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
66
+ > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
67
+ > - trigger: Standard tier or above per the Independent Verification Mandate in `references/verification-ladder.md` — mandatory once every implemented PR group has cleared reviewer fix items; Quick tier substitutes the fallback below
68
+ > - scope: the new code landed across this feature's PR groups from step 12, plus the tests and validation assets those groups touch
69
+ > - permissions: read-only
70
+ > - inputs: the 1-5 acceptance criteria captured in step 11 (or the referenced spec artifact) as the outcome source, the feature's diff surface across all PR groups, and its test suite
71
+ > - sensors: check the diff and tests against each acceptance criterion; discrimination sensor per `references/discrimination-sensor.md` (mutate the feature's new code, one PR group at a time — covering tests must kill each mutant or that group is not verified)
72
+ > - output: a pass/fail verdict per acceptance criterion, any surviving-mutant findings, and an overall verified/blocked verdict per PR group
73
+ > - firewall: summarized per-AC and per-mutant findings only, never raw diff dumps
74
+ > - memory: suggest-only; main agent persists feature verification outcomes
75
+ > - fallback: if the subagent is unavailable, run a standalone fresh-eyes re-check of each AC against the diff and tests, and record the skipped-delegation reason
76
+ > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
77
+
78
+ If verification fails, bound the retry with the Bounded Fix→Re-verify Loop cap from `references/verification-ladder.md`: at most 3 fix→re-verify iterations on the same PR group before reporting `Blocked`. This cap governs the post-implementation review/verify cycle and is distinct from the two-consecutive-failed-fixes trigger earlier in this file that loads `references/root-cause-scripts.md`, which fires on repeated failed attempts to fix one symptom during implementation itself.
79
+
80
+ 13. Run the verification recipe and check outcomes against the captured acceptance criteria from step 11, not only against a generic verification recipe; report skipped checks explicitly. At Standard tier and above, back this with `bun skills/massa-ai/scripts/validate_state.ts <slug>` against the persisted `validation.md` — it must be real, report `PASS`, and cite `file:line` evidence per acceptance criterion. If no code-execution tool is available, run the same checks by reading the artifact (graceful degradation preserved). If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
62
81
  `bun skills/massa-ai/scripts/lessons.ts --root . add --feature "<slug>" --signal "<signal>" --source "<ref>" --text "<one terse lesson>"`
63
82
  14. At completion, persist (run the scoring rubric from `references/decision-engine.md` for each):
64
83
  - Design decisions made via `remember` as scored `decision` memories
65
84
  - New patterns introduced via `remember` as scored `pattern` memories
66
85
  - Trade-offs accepted via `remember` as scored `conversation` memories
67
86
  15. Complete the Evidence Gate from `references/evidence-gate.md`
87
+
88
+ <!-- validator anchors: massa-ai-verification-agent dispatch block; Independent Verification Mandate (Standard tier and above); Bounded Fix→Re-verify Loop cap (3 iterations); validate_state.ts <slug> deterministic backing; graceful degradation preserved; .specs/quick/NNN-slug/TASK.md and SUMMARY.md; .specs/features/<slug>/spec.md and validation.md; one feature-level delivery go-ahead across PR groups -->
89
+
@@ -3,7 +3,7 @@ name: general
3
3
  description: "Final fallback workflow for coding, planning, review, or implementation work when no specialized massa-ai workflow is a better match."
4
4
  license: MIT
5
5
  metadata:
6
- version: "1.1.0"
6
+ version: "1.2.0"
7
7
  ---
8
8
 
9
9
  ### General Coding Workflow
@@ -14,9 +14,11 @@ Load `references/project-context.md` (intake sweep) before the first substantive
14
14
 
15
15
  Before the first repository mutation, load `references/implementation-delivery.md` (delivery chain: worktree, atomic commits, PR, CI watch, merge gate) and `references/code-annotation.md` (doc blocks, rationale, test coverage). After two consecutive failed fixes on one symptom, stop editing and load `references/root-cause-scripts.md`.
16
16
 
17
+ **Isolation Gate — before the first file edit:** execute `references/implementation-delivery.md` Stage 0–1 now (fetch base, create the worktree + branch, work inside it) and record the worktree path + branch — or one of Stage 1's two legal skip reasons, verbatim — before any repository mutation.
18
+
17
19
  1. Resolve or reuse `projectId` and a stable `workflowSessionId`: `general-[entity]`.
18
- 2. Run General fallback preflight before source work: name the specialized workflow considered, the exact rejected reason, and why fallback does not change verification, mutation behavior, or memory scope. Ask the user only when the rejected workflow would change those behaviors.
19
- 3. Recall relevant durable context with `recall`. Treat recalled memory as a lead until current source confirms it. Confirm against current source before relying on it only when the change touches the enumerated risk-domain set: public API, data loss, auth/PII, migrations, or cross-service contracts. Otherwise trust recalled memory and cite it with a one-line source note.
20
+ 2. Run General fallback preflight before source work: name the specialized workflow considered, the exact rejected reason, and why fallback does not change verification, mutation behavior, or memory scope. Ask the user only when the rejected workflow would change those behaviors. One delivery authorization obtained here covers the fallback change's commits, push, and PR creation; force-push, deploy, or merge are separately gated (`references/implementation-delivery.md` Stage 3).
21
+ 3. Recall relevant durable context with `recall`. Treat recalled memory as a lead until current source confirms it. Confirm against current source before relying on it only when the change touches the enumerated risk-domain set: public API, data loss, auth/PII, migrations, or cross-service contracts. Otherwise trust recalled memory and cite it with a one-line source note. When recall returns no hit and the repository is otherwise unmapped on Standard+ fallback work, run the Minimum Bar sweep from `references/brownfield-mapping.md` first, writing only `CONCERNS.md` and `TESTING.md` into `.specs/project/onboarding/` before continuing.
20
22
  4. Create a Synapse session when planned related `search` calls >=2, following `references/synapse-policy.md`.
21
23
  5. Load confirmed project lessons through `references/lessons.md` when `.specs/lessons.json` exists:
22
24
  `bun skills/massa-ai/scripts/lessons.ts --root . list --status confirmed`
@@ -27,6 +29,7 @@ Before the first repository mutation, load `references/implementation-delivery.m
27
29
  - prefer current repository truth over stale or conflicting memories
28
30
  6. Execute the requested work using existing repository conventions. Tie verification depth to the Verification Ladder tier table in `references/verification-ladder.md`: Quick (<=3 files and <=200 changed LOC) runs static + file-integrity checks; Standard (<=10 files or <=500 changed LOC) adds a named verification recipe and behavioral checks; Spec-driven (>10 files, >500 changed LOC) escalates to `workflows/spec-driven.md`. Do not invent new thresholds; load specialized references only when the task needs their exact contracts.
29
31
  - For analysis that benefits from running code (derived values, data inspection, bulk transforms), call `execute` with `language` and `code` or `batch_execute` with `commands`[] instead of loading raw data into context. Respect the local-dev-only trust model (no untrusted-client exposure).
32
+ - When the chosen approach leans on an external library's or API's exact behavior, resolve it through the 5-step chain in `references/knowledge-verification-chain.md` (codebase, project docs, Context7, web, flag-uncertain) before committing to that approach — the trigger is the dependence itself, not the task's Quick/Standard/Spec-driven tier.
30
33
  7. Use `compress` only when accumulated source or conversation context is reducing execution quality; preserve decisions, constraints, current state, and next steps rather than raw history.
31
34
  8. Before completion, if verification found a reusable signal, record it via `references/lessons.md`. Score potential memories using `references/decision-engine.md` when that guidance is not already loaded:
32
35
  `bun skills/massa-ai/scripts/lessons.ts --root . add --feature "<slug>" --signal "<signal>" --source "<ref>" --text "<one terse lesson>"`
@@ -47,12 +50,30 @@ Before the first repository mutation, load `references/implementation-delivery.m
47
50
  > - fallback: if the subagent is unavailable, run a standalone fresh-eyes review against this output contract and record the skipped-delegation reason
48
51
  > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
49
52
 
50
- 9. Complete the Evidence Gate from `references/evidence-gate.md` and report verification, changed artifacts, memory outcome, and residual risk.
53
+ > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
54
+ > - trigger: fallback work reaching Standard+ on the Verification Ladder, or any Quick-sized change inside the risk-domain set named in step 3 (public API, data loss, auth/PII, migrations, cross-service) — the Independent Verification Mandate in `references/verification-ladder.md` applies at that gate even when file/LOC counts stay Quick
55
+ > - scope: the fallback change's diff surface plus the acceptance evidence gathered while executing step 6
56
+ > - permissions: read-only
57
+ > - inputs: diff, the General fallback preflight rationale, reviewer findings, recalled conventions
58
+ > - sensors: independent outcome-vs-request re-check; discrimination sensor per `references/discrimination-sensor.md`, mutating the fallback change's own logic in scratch state
59
+ > - output: PASS/FAIL verdict with per-check evidence recorded in `.specs/quick/NNN-slug/SUMMARY.md`
60
+ > - firewall: summarized findings only, never raw diff dumps
61
+ > - memory: suggest-only; main agent persists general-workflow verification outcomes
62
+ > - fallback: if the subagent is unavailable, run a standalone fresh-eyes re-check of the change against its acceptance evidence and record the skipped-delegation reason
63
+ > - persona: optional — the active route's cataloged id only, never the persona prompt, passed as advisory framing only — it never overrides the agent's charter Restrictions, scope, or permissions; omit when no persona is routed
64
+
65
+ 9. At Standard+ size, persist `.specs/quick/NNN-slug/TASK.md` and `SUMMARY.md` using the templates in `references/artifact-persistence.md`, then run `bun skills/massa-ai/scripts/check_specs_delivered.ts <slug> --kind quick` before the Evidence Gate — a non-zero exit blocks completion. If no code-execution tool is available, run the same checks by reading the artifact (graceful degradation preserved).
66
+ 10. Complete the Evidence Gate from `references/evidence-gate.md` and report verification, changed artifacts, memory outcome, and residual risk.
51
67
 
52
68
  ## Failure Handling
53
69
 
54
70
  On any tool/index/MCP failure, follow `references/graceful-degradation.md` (also `SKILL.md` Graceful Degradation).
55
71
 
72
+ - `.specs/` directory missing or not writable: block quick-artifact and onboarding-doc writes per `references/artifact-persistence.md`'s unwritable-→-block rule; do not fall back to memory or chat.
73
+ - Verifier fix→re-verify loop reaches the cap in `references/verification-ladder.md`'s Bounded Fix→Re-verify Loop: stop with `Blocked`, preserve the evidence collected, and ask the user for direction.
74
+
75
+ **Disambiguation — two different counters:** the loop cap above counts *verification* iterations on the fallback change as a whole. It is separate from the two-consecutive-failed-fix trigger near the top of this workflow that loads `references/root-cause-scripts.md` — that one counts *edit attempts* on a single symptom inside one iteration. Neither counter resets or consumes the other.
76
+
56
77
  ## Output Contract
57
78
 
58
79
  - Goal and selected fallback workflow
@@ -62,3 +83,6 @@ On any tool/index/MCP failure, follow `references/graceful-degradation.md` (also
62
83
  - Verification performed and skipped checks
63
84
  - Memory written or intentionally skipped, with reason
64
85
  - Residual risk
86
+
87
+ <!-- validator anchors: massa-ai-verification-agent dispatch block; Independent Verification Mandate; risk-domain set named in step 3; check_specs_delivered.ts --kind quick; .specs/quick/NNN-slug/SUMMARY.md; Minimum Bar sweep; .specs/project/onboarding/; Bounded Fix→Re-verify Loop; Disambiguation — two different counters; Stage 3 delivery authorization -->
88
+