@massa-ai/codex-plugin 1.56.0 → 1.58.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 (62) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/package.json +1 -1
  3. package/skills/agents/architecture-specialist/SKILL.md +1 -1
  4. package/skills/agents/audit-specialist/SKILL.md +1 -1
  5. package/skills/agents/builder/SKILL.md +1 -1
  6. package/skills/agents/context-curator/SKILL.md +1 -1
  7. package/skills/agents/designer/SKILL.md +1 -1
  8. package/skills/agents/documentation-agent/SKILL.md +1 -1
  9. package/skills/agents/furps-analyst/SKILL.md +1 -1
  10. package/skills/agents/investigator/SKILL.md +1 -1
  11. package/skills/agents/judge/SKILL.md +1 -1
  12. package/skills/agents/meta-judge/SKILL.md +1 -1
  13. package/skills/agents/mobile-specialist/SKILL.md +1 -1
  14. package/skills/agents/navigator/SKILL.md +1 -1
  15. package/skills/agents/plan-critic/SKILL.md +1 -1
  16. package/skills/agents/planner/SKILL.md +1 -1
  17. package/skills/agents/requirements-analyst/SKILL.md +1 -1
  18. package/skills/agents/reviewer/SKILL.md +1 -1
  19. package/skills/agents/test-engineer/SKILL.md +1 -1
  20. package/skills/agents/verification-agent/SKILL.md +1 -1
  21. package/skills/massa-ai/SKILL.md +2 -1
  22. package/skills/massa-ai/references/agent-orchestration.md +41 -4
  23. package/skills/massa-ai/references/audit-scope.md +1 -1
  24. package/skills/massa-ai/references/code-quality-lens.md +107 -0
  25. package/skills/massa-ai/references/code-reuse-scan.md +0 -1
  26. package/skills/massa-ai/references/implementation-delivery.md +6 -3
  27. package/skills/massa-ai/references/skill-architect/authoring-principles.md +37 -0
  28. package/skills/massa-ai/references/verification-ladder.md +2 -0
  29. package/skills/massa-ai/scripts/check_commit.ts +4 -1
  30. package/skills/massa-ai/scripts/ensure_worktree.ts +311 -0
  31. package/skills/massa-ai/scripts/resolve_scope.ts +263 -0
  32. package/skills/massa-ai/scripts/size_change.ts +227 -0
  33. package/skills/massa-ai/workflows/architecture/architecture-audit.md +1 -15
  34. package/skills/massa-ai/workflows/architecture/architecture-fix.md +1 -8
  35. package/skills/massa-ai/workflows/bugs/bugs-audit.md +1 -13
  36. package/skills/massa-ai/workflows/bugs/bugs-fix.md +1 -9
  37. package/skills/massa-ai/workflows/code-quality/code-quality-audit.md +3 -34
  38. package/skills/massa-ai/workflows/code-quality/code-quality-fix.md +3 -17
  39. package/skills/massa-ai/workflows/commit.md +6 -6
  40. package/skills/massa-ai/workflows/debug.md +2 -9
  41. package/skills/massa-ai/workflows/design.md +0 -6
  42. package/skills/massa-ai/workflows/exploration.md +0 -1
  43. package/skills/massa-ai/workflows/feature.md +2 -15
  44. package/skills/massa-ai/workflows/general.md +1 -16
  45. package/skills/massa-ai/workflows/implementation/implementation-audit.md +0 -1
  46. package/skills/massa-ai/workflows/implementation/implementation-fix.md +1 -15
  47. package/skills/massa-ai/workflows/judge-with-debate.md +0 -2
  48. package/skills/massa-ai/workflows/maestro/maestro-fix.md +1 -8
  49. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-audit.md +0 -6
  50. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-fix.md +1 -14
  51. package/skills/massa-ai/workflows/pr-review.md +0 -3
  52. package/skills/massa-ai/workflows/refactor.md +2 -9
  53. package/skills/massa-ai/workflows/refinement/furps-refinement.md +0 -1
  54. package/skills/massa-ai/workflows/requirements/requirements-audit.md +1 -13
  55. package/skills/massa-ai/workflows/requirements/requirements-fix.md +1 -8
  56. package/skills/massa-ai/workflows/security/security-audit.md +1 -13
  57. package/skills/massa-ai/workflows/security/security-fix.md +1 -9
  58. package/skills/massa-ai/workflows/skill-architect.md +7 -39
  59. package/skills/massa-ai/workflows/spec-driven.md +0 -11
  60. package/skills/massa-ai/workflows/tests/tests-audit.md +1 -13
  61. package/skills/massa-ai/workflows/tests/tests-fix.md +1 -8
  62. package/skills/massa-ai/workflows/to-prd.md +0 -1
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * size_change.ts - deterministic change sizing for the Verification Ladder.
4
+ *
5
+ * `references/verification-ladder.md` sizes work by changed files and changed
6
+ * LOC. Counting those by eye over a `git diff` is exactly the kind of
7
+ * arithmetic a model gets subtly wrong, and the whole ladder hangs off the
8
+ * answer. This reads `git diff --numstat` and reports the counts plus the
9
+ * SIZE FLOOR of the tier. Bun builtins only, zero dependencies, agent-agnostic.
10
+ *
11
+ * FLOOR, not tier. Size is only half of the ladder's rule. The other half is
12
+ * qualitative and invisible to a diff: unclear acceptance criteria, a new
13
+ * dependency, a migration, an irreversible operation, security/privacy/auth, a
14
+ * public compatibility surface, a cross-service contract, or an unresolved
15
+ * architecture decision. Any one of those escalates regardless of how small the
16
+ * diff is, so this script's answer is a lower bound the agent may raise and must
17
+ * never lower.
18
+ *
19
+ * Boundary reading: the ladder states Standard as "<=10 files or <=500 changed
20
+ * LOC" and Spec-driven as ">10 files, >500 changed LOC" — read literally, the
21
+ * two clauses overlap. This resolves the overlap by escalating: anything over
22
+ * either bound is Spec-driven. That is the safe direction (it over-verifies
23
+ * rather than under-verifies), and it matches how the rest of the Spec-driven
24
+ * bullet reads — a list of independent triggers, not a conjunction.
25
+ *
26
+ * Changed LOC is added + deleted, which is what the ladder's "changed LOC"
27
+ * means: a 100-line rewrite is 200 changed LOC, not 0.
28
+ *
29
+ * Usage:
30
+ * bun skills/massa-ai/scripts/size_change.ts # working tree vs HEAD
31
+ * bun skills/massa-ai/scripts/size_change.ts --staged # index vs HEAD
32
+ * bun skills/massa-ai/scripts/size_change.ts --range main..HEAD
33
+ * bun skills/massa-ai/scripts/size_change.ts --json
34
+ *
35
+ * Exit codes: 0 sized, 1 git failure, 2 usage error.
36
+ */
37
+
38
+ const USAGE =
39
+ "usage: size_change.ts [-h] [--staged | --range REV_RANGE] [--json] [--root ROOT]";
40
+ const HELP = `${USAGE}
41
+
42
+ Size a change set against the Verification Ladder's file/LOC bounds.
43
+
44
+ options:
45
+ -h, --help show this help message and exit
46
+ --staged size the index against HEAD (git diff --cached)
47
+ --range REV_RANGE size a revision range, e.g. main..HEAD
48
+ --json emit a JSON object instead of the text report
49
+ --root ROOT run git in this directory (default: cwd)`;
50
+
51
+ /** The ladder's numeric bounds. Changing one here changes the only place it is encoded. */
52
+ const QUICK_MAX_FILES = 3;
53
+ const QUICK_MAX_LOC = 200;
54
+ const STANDARD_MAX_FILES = 10;
55
+ const STANDARD_MAX_LOC = 500;
56
+
57
+ type Tier = "quick" | "standard" | "spec-driven";
58
+
59
+ interface Args {
60
+ staged: boolean;
61
+ range: string | null;
62
+ json: boolean;
63
+ root: string;
64
+ }
65
+
66
+ interface FileStat {
67
+ path: string;
68
+ added: number;
69
+ deleted: number;
70
+ binary: boolean;
71
+ }
72
+
73
+ interface Sizing {
74
+ mode: string;
75
+ files: number;
76
+ added: number;
77
+ deleted: number;
78
+ changedLoc: number;
79
+ binaryFiles: number;
80
+ tierFloor: Tier;
81
+ perFile: FileStat[];
82
+ }
83
+
84
+ function printUsageError(msg: string): void {
85
+ process.stderr.write(`${USAGE}\nsize_change.ts: error: ${msg}\n`);
86
+ }
87
+
88
+ function parseArgs(argv: string[]): Args | null {
89
+ const args: Args = { staged: false, range: null, json: false, root: "." };
90
+ for (let i = 0; i < argv.length; i++) {
91
+ const a = argv[i]!;
92
+ if (a === "-h" || a === "--help") {
93
+ console.log(HELP);
94
+ process.exit(0);
95
+ } else if (a === "--staged") {
96
+ args.staged = true;
97
+ } else if (a === "--json") {
98
+ args.json = true;
99
+ } else if (a === "--range" || a === "--root") {
100
+ if (i + 1 >= argv.length) {
101
+ printUsageError(`argument ${a}: expected one argument`);
102
+ return null;
103
+ }
104
+ const value = argv[++i]!;
105
+ if (a === "--range") args.range = value;
106
+ else args.root = value;
107
+ } else if (a.startsWith("--range=")) {
108
+ args.range = a.slice("--range=".length);
109
+ } else if (a.startsWith("--root=")) {
110
+ args.root = a.slice("--root=".length);
111
+ } else {
112
+ printUsageError(`unrecognized argument: ${a}`);
113
+ return null;
114
+ }
115
+ }
116
+ if (args.staged && args.range !== null) {
117
+ printUsageError("--staged and --range are mutually exclusive");
118
+ return null;
119
+ }
120
+ return args;
121
+ }
122
+
123
+ /** Runs git and returns stdout, or null when git itself failed. */
124
+ function git(root: string, gitArgs: string[]): string | null {
125
+ const proc = Bun.spawnSync(["git", ...gitArgs], { cwd: root, stdout: "pipe", stderr: "pipe" });
126
+ if (proc.exitCode !== 0) {
127
+ process.stderr.write(new TextDecoder().decode(proc.stderr));
128
+ return null;
129
+ }
130
+ return new TextDecoder().decode(proc.stdout);
131
+ }
132
+
133
+ /**
134
+ * Parses `git diff --numstat` output.
135
+ *
136
+ * A binary file is reported as `-\t-\tpath`: it has no line counts, so it
137
+ * contributes to the file count and to nothing else. Counting `-` as 0 silently
138
+ * would make a 40 MB asset look like a no-op change, which is why binaries are
139
+ * reported separately instead.
140
+ */
141
+ function parseNumstat(out: string): FileStat[] {
142
+ const stats: FileStat[] = [];
143
+ for (const line of out.split("\n")) {
144
+ if (!line.trim()) continue;
145
+ const parts = line.split("\t");
146
+ if (parts.length < 3) continue;
147
+ const [addedRaw, deletedRaw] = parts;
148
+ const binary = addedRaw === "-" || deletedRaw === "-";
149
+ stats.push({
150
+ // A rename is `old => new`; keep git's own rendering rather than guessing.
151
+ path: parts.slice(2).join("\t"),
152
+ added: binary ? 0 : Number(addedRaw),
153
+ deleted: binary ? 0 : Number(deletedRaw),
154
+ binary,
155
+ });
156
+ }
157
+ return stats;
158
+ }
159
+
160
+ /** The ladder's size floor. See the escalating boundary reading in the header. */
161
+ export function tierFloor(files: number, changedLoc: number): Tier {
162
+ if (files <= QUICK_MAX_FILES && changedLoc <= QUICK_MAX_LOC) return "quick";
163
+ if (files > STANDARD_MAX_FILES || changedLoc > STANDARD_MAX_LOC) return "spec-driven";
164
+ return "standard";
165
+ }
166
+
167
+ function size(args: Args): Sizing | null {
168
+ const diffArgs = args.range !== null
169
+ ? ["diff", "--numstat", args.range]
170
+ : args.staged
171
+ ? ["diff", "--numstat", "--cached"]
172
+ : ["diff", "--numstat", "HEAD"];
173
+ const out = git(args.root, diffArgs);
174
+ if (out === null) return null;
175
+
176
+ const perFile = parseNumstat(out);
177
+ const added = perFile.reduce((n, f) => n + f.added, 0);
178
+ const deleted = perFile.reduce((n, f) => n + f.deleted, 0);
179
+ const changedLoc = added + deleted;
180
+ return {
181
+ mode: args.range !== null ? `range ${args.range}` : args.staged ? "staged (index vs HEAD)" : "working tree vs HEAD",
182
+ files: perFile.length,
183
+ added,
184
+ deleted,
185
+ changedLoc,
186
+ binaryFiles: perFile.filter((f) => f.binary).length,
187
+ tierFloor: tierFloor(perFile.length, changedLoc),
188
+ perFile,
189
+ };
190
+ }
191
+
192
+ function report(s: Sizing): void {
193
+ console.log(`scope: ${s.mode}`);
194
+ console.log(`files: ${s.files}${s.binaryFiles ? ` (${s.binaryFiles} binary, no line counts)` : ""}`);
195
+ console.log(`changed LOC: ${s.changedLoc} (+${s.added} / -${s.deleted})`);
196
+ console.log(`tier floor: ${s.tierFloor}`);
197
+ console.log("");
198
+ for (const f of s.perFile) {
199
+ const counts = f.binary ? "binary" : `+${f.added}/-${f.deleted}`;
200
+ console.log(` ${counts.padEnd(12)} ${f.path}`);
201
+ }
202
+ console.log("");
203
+ console.log(
204
+ "This is a FLOOR. Raise it for unclear acceptance criteria, a new dependency,",
205
+ );
206
+ console.log(
207
+ "a migration, an irreversible operation, security/privacy/auth, public",
208
+ );
209
+ console.log(
210
+ "compatibility, a cross-service contract, or an unresolved architecture",
211
+ );
212
+ console.log("decision. Never lower it. See references/verification-ladder.md.");
213
+ }
214
+
215
+ function main(argv: string[]): number {
216
+ const args = parseArgs(argv);
217
+ if (args === null) return 2;
218
+ const s = size(args);
219
+ if (s === null) return 1;
220
+ if (args.json) console.log(JSON.stringify(s, null, 2));
221
+ else report(s);
222
+ return 0;
223
+ }
224
+
225
+ if (import.meta.main) {
226
+ process.exit(main(process.argv.slice(2)));
227
+ }
@@ -30,18 +30,7 @@ Findings-only: do not edit code unless the user separately asks for fixes.
30
30
  - `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
31
31
  3. `recall` -> load ADRs, architecture decisions, known boundaries, coupling patterns, accepted exceptions, project constraints, and prior rejected refactors for the target area.
32
32
  - Apply the Memory Freshness Gate from `references/audit-scope.md`; recalled exceptions are leads, not proof.
33
- 4. Establish the investigation scope before proceeding:
34
- - Modified files scope: use when the user says modified files, changed files, current changes, uncommitted changes, staged changes, or unstaged changes.
35
- - Explicit files/globs scope: use when the user names files, directories, or globs.
36
- - 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.
37
- - Branch comparison scope: use when the user names base/head branches, refs, or a branch diff.
38
- - Codebase area scope: use when the user names a path, module, package, bounded context, feature area, architecture question, or glob.
39
- - Symbol/class/function scope: use when the user names exported surfaces, classes, functions, adapters, interfaces, or dependency edges.
40
- - Feature/flow scope: use when the user names a runtime flow or cross-module feature.
41
- - Whole-repo scope: use only when the user explicitly asks for a whole-repo architecture audit.
42
- - Implementation parent scope: use only when `workflows/implementation/implementation-audit.md` invokes this workflow with a concrete implementation scope packet.
43
- - 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`.
44
- - Build the shared scope packet from `references/audit-scope.md` and carry it into the report.
33
+ 4. Establish the investigation scope: select the scope type and build the shared scope packet per `references/audit-scope.md`, which owns the supported scope types, the ask-when-vague rule, and the packet fields. Carry the packet into the report.
45
34
  5. Resolve the selected branch's mechanics (modified files, commit range, codebase area, explicit-files/branch/symbol/feature/whole-repo, or implementation parent scope) per `references/audit-scope.md` (Lens Audit Scope Resolution Procedure, Architecture row of Per-Lens Scope Deltas).
46
35
  6. Investigation pass:
47
36
  - 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` differs from `project_map` (general overview: PageRank backbone + symbol counts) — use `get_architecture` for architecture-specific structure, `project_map` for the general overview. Both count as evidence only when the index is fresh for the current repository path and commit/worktree state; otherwise fall back to `search`/`get_references` and record reduced retrieval confidence.
@@ -73,18 +62,15 @@ Findings-only: do not edit code unless the user separately asks for fixes.
73
62
  > - output: findings with lens-specific evidence, provisional severity, tradeoff, and what would disprove it
74
63
  > - firewall: raw dependency graphs, generated reports, and broad search output summarized, not returned raw
75
64
  > - memory: suggest-only; main agent persists accepted constraints/rejected refactors
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
65
 
78
66
  > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
79
67
  > - trigger: independent verification of a high-impact architecture finding
80
68
  > - scope: the specific finding's claimed evidence and affected boundary/module
81
- > - permissions: read-only
82
69
  > - inputs: the candidate finding, its source evidence, ADRs, accepted exceptions, and the verification suggestion
83
70
  > - sensors: deterministic command or artifact check that would falsify the finding
84
71
  > - output: confirmed/disproven verdict with evidence; skipped-check reason if the sensor cannot run
85
72
  > - firewall: raw logs/snapshots summarized
86
73
  > - memory: suggest-only; main agent persists reusable verification recipes
87
- > - 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
88
74
  9. Severity rules (apply the countable threshold first, then the qualitative clause):
89
75
  - `critical`: architecture issue likely causes data loss, auth/privacy break, production outage, irreversible corruption, OR affects >10 files; otherwise use the qualitative clause below.
90
76
  - `high`: strong coupling with high volatility, boundary violation, dependency inversion break, or shallow module design likely to cause major change friction or regression.
@@ -82,7 +82,6 @@ Not for findings-only architecture review — route to `workflows/architecture/a
82
82
  > - output: implementation summary, commands run, test counts, deviations
83
83
  > - firewall: raw diffs/logs summarized
84
84
  > - memory: suggest-only; main agent persists reusable architecture patterns
85
- > - 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
86
85
 
87
86
  > **Dispatch: `massa-ai-reviewer`** (role: `reviewer`) — charter `skills/agents/reviewer/SKILL.md`
88
87
  > - trigger: implementation of the architecture finding complete, before the verification gate — never optional
@@ -93,20 +92,16 @@ Not for findings-only architecture review — route to `workflows/architecture/a
93
92
  > - output: ranked findings, blocking vs advisory; blocking findings become architecture fix items before verification runs
94
93
  > - firewall: summarized findings only, never raw diff dumps
95
94
  > - memory: suggest-only; main agent persists review outcomes for the architecture fix
96
- > - fallback: if the subagent is unavailable, run a standalone fresh-eyes review against this output contract and record the skipped-delegation reason
97
- > - 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
95
 
99
96
  > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
100
97
  > - trigger: mandatory at Standard+/Spec-driven-sized findings or high/critical severity, per the Independent Verification Mandate in `references/verification-ladder.md`'s Mandatory Verification Fix Gate; Quick-tier findings take the fallback below instead
101
98
  > - scope: the fixed finding's dependency direction, seam/adapter shape, tests, imports, and report claim closure
102
- > - permissions: read-only
103
99
  > - inputs: the finding, the applied fix, the verification suggestion, dependency-direction/import-cycle evidence, and validation assets
104
100
  > - sensors: deterministic command (targeted tests, import-cycle check, dependency-direction check), report claim closure check; discrimination sensor per `references/discrimination-sensor.md` (mutate the fixed dependency direction, seam, or boundary contract in a scratch worktree)
105
101
  > - output: confirmed/disproven closure verdict with evidence, feeding the Fix Closure Report's Independent Verifier column
106
102
  > - firewall: raw test output/logs summarized
107
103
  > - memory: suggest-only; main agent persists architecture verification outcomes
108
104
  > - fallback: if the subagent is unavailable, run a standalone fresh-eyes re-check of the architecture closure evidence against this output contract and record the skipped-delegation reason
109
- > - 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
110
105
 
111
106
  11. Verify each completed finding:
112
107
  - If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
@@ -114,7 +109,7 @@ Not for findings-only architecture review — route to `workflows/architecture/a
114
109
  - 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.
115
110
  - Run the sensors at the mandate's own tier gate: dispatch the verification-agent block above at Standard+/Spec-driven size or high/critical severity; a Quick-tier finding runs its fallback fresh-eyes self-check instead — the hop is skippable, the check never is.
116
111
  - A surviving mutant on the discrimination sensor marks the finding's Closure Matrix row `blocked` and records a `surviving_mutant` signal via `references/lessons.md`.
117
- - The fix→re-verify loop is capped per `references/verification-ladder.md`'s Bounded Fix→Re-verify Loop; exhausting it also marks the row `blocked`. That cap counts re-verify cycles across the whole finding and is a different counter from the two-consecutive-failed-fixes breaker in this file's preamble, which fires inside a single edit iteration.
112
+ - The fix→re-verify loop is capped per `references/verification-ladder.md`'s Bounded Fix→Re-verify Loop; exhausting it also marks the row `blocked`.
118
113
  - 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.
119
114
  - Run the report's verification suggestion when available.
120
115
  - Add static checks for dependency direction/import cycles when feasible.
@@ -144,5 +139,3 @@ User asks: "Fix finding ARCH-2 from audits/architecture/2026-06-06 architecture-
144
139
  1. Read the specified report and only execute `ARCH-2`.
145
140
  2. Preserve unaffected architecture findings for later.
146
141
  3. Report evidence for `ARCH-2` closure and residual risks.
147
-
148
- <!-- validator anchors: Stage 3 delivery-authorization scope | Independent Verification Exception | surviving_mutant | Bounded Fix→Re-verify Loop | Fix Closure Report Contract | CONCERNS.md is satisfied by citation | graceful degradation preserved -->
@@ -26,18 +26,7 @@ Findings-only: do not edit code unless the user separately asks for fixes.
26
26
  - `references/agent-orchestration.md` only for large scopes, explicit parallel/subagent requests, PR subagent invocation, or independent verification of high-impact findings
27
27
  3. `recall` -> load prior bug patterns, known regressions, project constraints, ADRs, fragile flows, and accepted exceptions for the target area.
28
28
  - Apply the Memory Freshness Gate from `references/audit-scope.md`; recalled exceptions are leads, not proof.
29
- 4. Establish the investigation scope before proceeding:
30
- - Modified files scope: use when the user says modified files, changed files, current changes, uncommitted changes, staged changes, or unstaged changes.
31
- - Explicit files/globs scope: use when the user names files, directories, or globs.
32
- - 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.
33
- - Branch comparison scope: use when the user names base/head branches, refs, or a branch diff.
34
- - Codebase area scope: use when the user names a path, module, package, feature area, service, or glob.
35
- - Symbol/class/function scope: use when the user names public classes, functions, APIs, handlers, or exported surfaces.
36
- - Feature/flow scope: use when the user names a runtime flow, user journey, or feature area.
37
- - Whole-repo scope: use only when the user explicitly asks for a whole-repo bug audit.
38
- - Implementation parent scope: use only when `workflows/implementation/implementation-audit.md` invokes this workflow with a concrete implementation scope packet.
39
- - 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`.
40
- - Build or accept the shared scope packet from `references/audit-scope.md` and carry it into the report.
29
+ 4. Establish the investigation scope: select the scope type and build or accept the shared scope packet per `references/audit-scope.md`, which owns the supported scope types, the ask-when-vague rule, and the packet fields. Carry the packet into the report.
41
30
  5. Resolve the selected branch's mechanics (modified files, commit range, codebase area, explicit-files/branch/symbol/feature/whole-repo, or implementation parent scope) per `references/audit-scope.md` (Lens Audit Scope Resolution Procedure, Bugs row of Per-Lens Scope Deltas).
42
31
  6. Investigation pass. Dispatch `audit-specialist` per `references/agent-orchestration.md` when the scope justifies an isolated read-only subagent:
43
32
 
@@ -50,7 +39,6 @@ Findings-only: do not edit code unless the user separately asks for fixes.
50
39
  > - output: findings with bug category, location, evidence, trigger, severity, confidence, simplest fix direction, verification suggestion
51
40
  > - firewall: raw diffs/logs/search output summarized, not returned raw
52
41
  > - memory: suggest-only; main agent persists reusable bug patterns
53
- > - 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
54
42
 
55
43
  - Trace input -> transformation -> output for each suspicious path.
56
44
  - Check diffs, surrounding code, callers and callees, tests, config, migrations, schemas, and recalled project patterns.
@@ -71,7 +71,6 @@ Not for findings-only bug discovery — route to `workflows/bugs/bugs-audit.md`.
71
71
  > - output: implementation summary, commands run, test counts, deviations
72
72
  > - firewall: raw diffs/logs summarized
73
73
  > - memory: suggest-only; main agent persists reusable bug patterns
74
- > - 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
75
74
 
76
75
  > **Dispatch: `massa-ai-reviewer`** (role: `reviewer`) — charter `skills/agents/reviewer/SKILL.md`
77
76
  > - trigger: implementation complete, before the verification gate — never optional
@@ -82,20 +81,16 @@ Not for findings-only bug discovery — route to `workflows/bugs/bugs-audit.md`.
82
81
  > - output: ranked findings, blocking vs advisory; blocking findings become fix items before verification runs
83
82
  > - firewall: summarized findings only, never raw diff dumps
84
83
  > - memory: suggest-only; main agent persists
85
- > - fallback: if the subagent is unavailable, run a standalone fresh-eyes review against this output contract and record the skipped-delegation reason
86
- > - 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
87
84
 
88
85
  > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
89
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`
90
87
  > - scope: the fixed bug finding's repro path, regression tests, and report claim closure
91
- > - permissions: read-only
92
88
  > - inputs: the bug finding, the applied root-cause fix, the verification suggestion, and validation assets
93
89
  > - 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)
94
90
  > - output: confirmed/disproven bug-closure verdict with evidence
95
91
  > - firewall: raw repro transcripts and test/log output summarized
96
92
  > - memory: suggest-only; main agent persists bug-closure verification outcomes
97
93
  > - 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
98
- > - 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
99
94
  - Main agent owns report parsing, prioritization, memory writes, final synthesis, and Evidence Gate.
100
95
 
101
96
  10. Verify each completed finding:
@@ -106,7 +101,7 @@ Not for findings-only bug discovery — route to `workflows/bugs/bugs-audit.md`.
106
101
  - Run the report's verification suggestion when available.
107
102
  - 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+.
108
103
  - 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.
109
- - 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.
104
+ - The fix→re-verify cycle is capped per `references/verification-ladder.md`'s Bounded Fix→Re-verify Loop.
110
105
  - Run focused regression tests first, then relevant lint/type/build/test commands when feasible.
111
106
  - Confirm validation assets were not weakened.
112
107
  - Record command/artifact, result, skipped reason or `none`, highest Verification Ladder level reached, validation assets protected, and residual risk.
@@ -131,6 +126,3 @@ User asks: "Fix BUG-2 from audits/bugs/2026-06-07 bugs-audit.md."
131
126
  1. Read the specified report and only execute `BUG-2`.
132
127
  2. Preserve other bug findings for later.
133
128
  3. Report evidence for `BUG-2` closure and residual risks.
134
-
135
- <!-- 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" -->
136
-
@@ -28,18 +28,7 @@ Findings-only: do not edit code unless the user separately asks for fixes.
28
28
  - `references/agent-orchestration.md` only for large scopes, explicit parallel/subagent requests, PR subagent invocation, or independent verification of high-impact findings
29
29
  3. `recall` -> load project style rules, ADRs, prior quality decisions, accepted extension points, repeated anti-patterns, and accepted exceptions for the target area.
30
30
  - Apply the Memory Freshness Gate from `references/audit-scope.md`; recalled exceptions are leads, not proof.
31
- 4. Establish the investigation scope before proceeding:
32
- - Modified files scope: use when the user says modified files, changed files, current changes, uncommitted changes, staged changes, or unstaged changes.
33
- - Explicit files/globs scope: use when the user names files, directories, or globs.
34
- - Commit range scope: use when the user provides commits/ranges or asks for commits made by me, my branch commits, or quality issues introduced by branch commits.
35
- - Branch comparison scope: use when the user names base/head branches, refs, or a branch diff.
36
- - Codebase area scope: use when the user names a path, module, package, feature area, service layer, or glob.
37
- - Symbol/class/function scope: use when the user names public classes, functions, interfaces, helpers, or exported surfaces.
38
- - Feature/flow scope: use when the user names a runtime flow or feature area.
39
- - Whole-repo scope: use only when the user explicitly asks for a whole-repo code quality audit.
40
- - Implementation parent scope: use only when `workflows/implementation/implementation-audit.md` invokes this workflow with a concrete implementation scope packet.
41
- - 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`.
42
- - Build the shared scope packet from `references/audit-scope.md` and carry it into the report.
31
+ 4. Establish the investigation scope: select the scope type and build the shared scope packet per `references/audit-scope.md`, which owns the supported scope types, the ask-when-vague rule, and the packet fields. Carry the packet into the report.
43
32
  5. Resolve the selected branch's mechanics (modified files, commit range, codebase area, explicit-files/branch/symbol/feature/whole-repo, or implementation parent scope) per `references/audit-scope.md` (Lens Audit Scope Resolution Procedure, Code Quality row of Per-Lens Scope Deltas).
44
33
  6. Input rules:
45
34
  - SOLID inputs: non-test source files only.
@@ -64,7 +53,6 @@ Findings-only: do not edit code unless the user separately asks for fixes.
64
53
  > - output: findings with smell category, location, evidence, severity, confidence, and simplest fix direction
65
54
  > - firewall: raw diffs/logs/search output summarized, not returned raw
66
55
  > - memory: suggest-only; main agent persists reusable code-quality patterns
67
- > - 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
68
56
 
69
57
  - Do not delegate every check by default; avoid duplicate source reading when one main-agent pass is cheaper.
70
58
  - Subagents may suggest memory content, but the main agent decides what durable knowledge to persist.
@@ -76,7 +64,7 @@ Findings-only: do not edit code unless the user separately asks for fixes.
76
64
  - Magic values: repeated strings, event names, timeouts, numeric thresholds, status codes.
77
65
  - Generic names: `data`, `info`, `result`, `value`, `temp`, `manager`, `handler`, `helper` without useful qualification, using `references/naming-standards.md` to filter conventional short-scope or framework-required names.
78
66
  - Long parameter lists: more than 3-4 positional parameters.
79
- - File shape: flag multi-subject files (unrelated exported surfaces bundled together) and any file over ~600 lines, regardless of subject count — it crowds out working context for the rest of the task (see `references/coding-guidelines.md` "File shape for agent readers"). Do NOT flag a single-subject file for line count alone below that bound.
67
+ - File shape: apply the File Shape rule in `references/code-quality-lens.md`.
80
68
  - Needlessly indirect code: pass-through wrappers, one-use abstractions, helper layers with no behavior, factories/builders that only hide one constructor call.
81
69
  - Speculative surfaces: unused options, future-oriented hooks, extension points with one implementation, exported APIs with no evidence of use.
82
70
  - Complexity without payoff: deep nesting, miniature state machines, or polymorphism where a direct branch or data map would preserve clarity.
@@ -84,26 +72,7 @@ Findings-only: do not edit code unless the user separately asks for fixes.
84
72
  - Android/KMP Compose recomposition leads: `@Composable`, `remember`, `rememberSaveable`, `derivedStateOf`, `LaunchedEffect`, `DisposableEffect`, `SideEffect`, `produceState`, `snapshotFlow`, `mutableStateOf`, `SnapshotStateList`, stability annotations/config, Compose compiler reports, Compose UI tests, and screenshot tests.
85
73
  9. Investigation pass:
86
74
  - Use summary/enriched search, symbol tools, and targeted file reads to inspect target modules, semantic hotspots, public classes, interfaces, functions, and exported API surface.
87
- - Apply SOLID checks to non-test source only:
88
- - Single Responsibility: flag classes/modules bundling distinct concern groups, such as validation plus persistence or formatting plus dispatch, only when separating them yields an externally-findable named unit (locatable by search or grep from outside the file) or measurably reduces change risk — never on concern-count or size alone.
89
- - Open/Closed: flag caller-side switches or if/else chains on type tags where adding a variant requires modifying existing files.
90
- - Liskov: flag subtypes that throw where the base does not, ignore required methods, or narrow the base contract.
91
- - Interface Segregation: flag interfaces that force implementors to define unused methods.
92
- - Dependency Inversion: flag hardcoded `new ConcreteType()` inside class bodies where abstraction or injection would be natural.
93
- - Apply Clean Code checks to test and non-test source:
94
- - Magic values: meaningful bare literals should be named constants, especially repeated strings, timeouts, thresholds, and event names.
95
- - Function does more than one thing: split only when the result yields an externally-findable named unit (locatable by search or grep from outside the file) or measurably reduces change risk; never split on size or "more than one thing" alone.
96
- - Unqualified generic names: flag vague names without domain or role qualification.
97
- - What-comments: flag comments that restate code; keep only why comments for constraints, workarounds, or non-obvious invariants.
98
- - Half-finished surfaces: flag exported TODOs, stubs, placeholder returns, and "implement later" code.
99
- - Long parameter lists: flag more than 3-4 positional parameters; suggest an options object.
100
- - Apply KISS/YAGNI/DRY checks:
101
- - KISS: flag abstractions, layers, indirection, or control flow that raise cognitive load without clearly improving readability, correctness, or constraint handling. Call out premature generalization, deep call chains, excessive configuration, and clever patterns that obscure intent. Prefer straightforward, explicit code a new reader can follow end-to-end: inline trivial abstractions, collapse unnecessary layers, choose boring solutions unless complexity is justified (real variability, hard constraints, or measured bottlenecks). When weighing whether to split instead of inline, apply the same discoverability-or-change-risk criterion used for the split lead above.
102
- - YAGNI: flag speculative features, extension points, and generic infrastructure with no concrete caller, requirement, or near-term use. Call out "just in case" hooks, over-parameterization, unused toggles, and frameworks introduced ahead of need. Prefer implementing only what current use cases demand, structured to evolve when real requirements appear. Defer generalization until duplication or constraints force it, and remove dead or unused paths aggressively.
103
- - DRY: flag duplicated logic, data transformations, or domain rules repeated without a strong reason (e.g., performance isolation or explicit decoupling). Highlight copy-paste patterns, parallel conditionals, and repeated constants that raise maintenance cost or inconsistency risk. Recommend consolidation into a single source of truth when it improves clarity and reduces bugs, but avoid over-abstraction that harms readability or adds indirection for trivial reuse.
104
- - Prefer delete, inline, or merge recommendations over replacement abstractions when simpler code preserves behavior.
105
- - Require usage evidence before calling a surface unnecessary; if evidence is incomplete, mark the item `suspect`.
106
- - Do not recommend ports, adapters, bounded contexts, new service/module boundaries, or VSA migration from this workflow; hand those to architecture-audit.
75
+ - Apply the SOLID, Clean Code, KISS/YAGNI/DRY and Standing Rules sections of `references/code-quality-lens.md`. Use their Flag-when column here; the Fix-direction column belongs to `workflows/code-quality/code-quality-fix.md` and is not an audit output. Report only what the lens's Split Criterion supports.
107
76
  - For Android Jetpack Compose and KMP Compose Multiplatform code, apply recomposition quality checks from `references/mobile-context.md`:
108
77
  - Excessive recomposition risk: unstable parameters, mutable collections or mutable models crossing composable boundaries, expensive work in composition, unremembered lambdas/objects, inappropriate `derivedStateOf`, broad state reads, and backwards writes after state reads.
109
78
  - Missing recomposition or stale UI risk: non-observable mutation, missing or wrong `remember`/effect keys, stale captured lambdas that need `rememberUpdatedState`, incorrect stability annotations, and risky stability configuration entries that can make UX updates fail to happen.
@@ -54,14 +54,8 @@ Not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or o
54
54
  - Quick: rename, inline, delete unused speculation, extract constant, collapse trivial wrapper, or local parameter-object change.
55
55
  - Standard: multi-file consolidation, shared behavior cleanup, public helper contract change, or meaningful test impact; define characterization checks first.
56
56
  - Spec-driven: broad redesign, unclear behavior, cross-boundary migration, or user-visible behavior change; pause and route to `workflows/spec-driven.md` or ask for approval.
57
- 8. Apply code quality fixing methods:
58
- - SOLID: separate mixed responsibilities only when the split yields an externally-findable named unit (locatable by search or grep from outside the file) or reduces change risk; replace caller-side type switches with polymorphism or data maps only when new variants are real; preserve base contracts; narrow fat interfaces; inject dependencies when hardcoded concretes block testing or substitution.
59
- - Clean Code: name domain concepts precisely using `references/naming-standards.md`, replace repeated magic values with named constants, split functions only when the result yields an externally-findable named unit (locatable by search or grep from outside the file) or measurably reduces change risk — never split on size or "more than one thing" alone — remove code-restating comments, finish or delete stubs, and convert long positional parameter lists to options objects when it improves call-site clarity.
60
- - KISS: inline shallow helpers, collapse needless layers, choose direct control flow over clever indirection, and remove configuration that hides rather than expresses behavior. When choosing whether to split instead of inline, apply the same discoverability-or-change-risk criterion used for the Clean Code split direction above.
61
- - YAGNI: delete unused extension points, future hooks, unused options, one-implementation factories, and speculative public APIs when usage evidence is absent.
62
- - DRY: consolidate duplicated domain rules or transformations into one clear source of truth, but avoid abstractions that make trivial duplication harder to read.
63
- - AI-slop cleanup: remove generic wrappers, fabricated-looking abstractions, one-call factories, code-restating comments, and unused configurability when current usage evidence does not justify them.
64
- - Do not introduce ports, adapters, bounded contexts, new service/module boundaries, or VSA-style folder migration to satisfy a code-quality finding.
57
+ 8. Apply the Fix-direction column of `references/code-quality-lens.md` (SOLID, Clean Code, KISS/YAGNI/DRY) plus its Standing Rules, which include the architecture boundary this workflow must not cross. Every extraction decision — and every decision to inline instead — goes through that file's Split Criterion.
58
+ - Fix only what the audit report confirmed. A lens rule the report did not raise is not an invitation to widen the diff.
65
59
  9. Preserve behavior:
66
60
  - Run or identify characterization tests before changing behavior-adjacent code.
67
61
  - Do not weaken tests, fixtures, snapshots, types, or public contracts to make cleanup pass.
@@ -77,7 +71,6 @@ Not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or o
77
71
  > - output: implementation summary, commands run, test counts, deviations
78
72
  > - firewall: raw diffs/logs summarized
79
73
  > - memory: suggest-only; main agent persists reusable code-quality patterns
80
- > - 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
81
74
 
82
75
  > **Dispatch: `massa-ai-reviewer`** (role: `reviewer`) — charter `skills/agents/reviewer/SKILL.md`
83
76
  > - trigger: implementation of the CQ finding complete, before the verification gate — never optional
@@ -88,20 +81,16 @@ Not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or o
88
81
  > - output: ranked findings, blocking vs advisory; blocking findings become CQ fix items before verification runs
89
82
  > - firewall: summarized findings only, never raw diff dumps
90
83
  > - memory: suggest-only; main agent persists review outcomes for the code-quality fix
91
- > - fallback: if the subagent is unavailable, run a standalone fresh-eyes review against this output contract and record the skipped-delegation reason
92
- > - 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
93
84
 
94
85
  > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
95
86
  > - 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
96
87
  > - scope: the fixed finding's behavior-preservation claim over the moved/transformed code, its call sites/imports, and report claim closure
97
- > - permissions: read-only
98
88
  > - inputs: the finding, the applied fix, the verification suggestion, and validation assets
99
89
  > - 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)
100
90
  > - output: confirmed/disproven closure verdict with evidence
101
91
  > - firewall: raw test output/logs summarized
102
92
  > - memory: suggest-only; main agent persists code-quality verification outcomes
103
93
  > - 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
104
- > - 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
105
94
  - Main agent owns report parsing, prioritization, memory writes, final synthesis, and Evidence Gate.
106
95
 
107
96
  11. Verify each completed finding:
@@ -116,7 +105,7 @@ Not for findings-only SOLID, Clean Code, KISS, YAGNI, DRY, maintainability, or o
116
105
  - Record command/artifact, result, skipped reason or `none`, highest Verification Ladder level reached, validation assets protected, and residual risk.
117
106
  - 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`.
118
107
  - 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.
119
- - 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.
108
+ - 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.
120
109
  12. Close out with the Fix Closure Report:
121
110
  - 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.
122
111
  - 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).
@@ -134,6 +123,3 @@ User asks: "Use code-quality-fix to fix latest findings for billing services."
134
123
  3. Execute confirmed non-suspect findings by severity and behavior risk.
135
124
  4. Prefer delete/inline/rename/extract before introducing new abstractions.
136
125
  5. Verify behavior and validation assets after each finding group.
137
-
138
- <!-- 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 -->
139
-
@@ -35,15 +35,15 @@ Not for Jira ticket creation, release notes, changelogs, PR descriptions, or his
35
35
  - any Markdown basename matching `*-audit.md`
36
36
  - If any excluded file is already staged, stop before committing and report the exact paths. Do not unstage user-selected files unless the user explicitly asks.
37
37
  7. Never stage everything through a shortcut, never commit all tracked modifications automatically, and never reset, checkout, amend, squash, rebase, or rewrite history unless the user separately requests that exact operation.
38
- 8. Draft the commit message using caveman-commit rules:
39
- - Conventional Commits format: `<type>(<scope>): <imperative summary>`, with scope optional.
40
- - Type precedence when multiple apply: `fix`, `feat`, `perf`, `refactor`, `test`, `docs`, `build`, `ci`, `style`, `chore`, `revert`. Use `revert` only when the commit's primary purpose is reverting an earlier change.
41
- - Subject is imperative, has no trailing period, targets 50 characters when practical, and has hard cap 72 characters including any Jira prefix.
38
+ 8. Draft the commit message in Conventional Commits format — `<type>(<scope>): <imperative summary>`, scope optional — then validate it deterministically:
39
+ - Shape, allowed type, description casing, trailing period, the optional `[<KEY>] ` Jira prefix, and the `!`/`BREAKING CHANGE:` pairing are all checked by `bun skills/massa-ai/scripts/check_commit.ts --message "<msg>"`. Run it on every drafted message. A non-zero exit blocks the commit; fix the message and re-run rather than committing past it.
40
+ - The script cannot choose between two defensible types, so type precedence stays a judgment call: `fix`, `feat`, `perf`, `refactor`, `test`, `docs`, `build`, `ci`, `style`, `chore`, `revert`. Use `revert` only when the commit's primary purpose is reverting an earlier change.
41
+ - The script's 72-character check is a warning; treat it as a hard cap including any Jira prefix, and target 50 characters when practical.
42
42
  - With a Jira key, prefix the subject exactly as `[<KEY>] `, for example `[SA-142] fix(auth): reject expired tokens`.
43
- - Match existing project capitalization after the colon when current history or nearby commits make it clear.
43
+ - The description after the colon is lowercase — the script errors on an uppercase first letter, so this overrides any surrounding history that capitalizes.
44
44
  - Body is required for breaking changes, migrations, security fixes, reverts, linked issues, or rationale not inferable from the diff. Wrap body lines at 72 characters.
45
45
  - Do not include AI attribution unless the repository explicitly requires an attribution trailer.
46
- 9. If committing, run the commit with the exact drafted message only after the final staged-path audit report exclusion check passes. If the commit fails, report the exact failure and leave staging untouched.
46
+ 9. If committing, run the commit with the exact drafted message only after `check_commit.ts` exits zero and the final staged-path audit report exclusion check passes. If the commit fails, report the exact failure and leave staging untouched.
47
47
  10. Complete `references/evidence-gate.md`, including branch key detection result, staged path policy, excluded audit Markdown paths, command outcome, skipped checks, memory outcome, and residual risk.
48
48
 
49
49
  ## Failure Handling
@@ -25,7 +25,7 @@ Before the first repository mutation, load `references/implementation-delivery.m
25
25
  - `references/debug-diagnosis-loop.md`
26
26
  - `references/mobile-diagnosis.md` when the bug target involves KMP, iOS, Android, native bridges, devices, simulators/emulators, or mobile lifecycle
27
27
  - `references/verification-ladder.md` before Quick/Standard/Spec-driven sizing or applying fixes
28
- - `references/context-firewall.md` before inspecting logs, traces, snapshots, or generated output that meet its threshold table (a single source/log/doc block >200 lines, >20 KB, or >50 search hits)
28
+ - `references/context-firewall.md` before inspecting logs, traces, snapshots, or generated output that meet its threshold table
29
29
  - `references/lessons.md` when `.specs/lessons.json` exists, to load confirmed project lessons before diagnosis
30
30
  3. `recall` → load prior debugging attempts for this entity
31
31
  4. IF prior attempts exist:
@@ -76,24 +76,20 @@ Before the first repository mutation, load `references/implementation-delivery.m
76
76
  > - output: ranked findings, blocking vs advisory; blocking findings become fix items before verification runs
77
77
  > - firewall: summarized findings only, never raw diff dumps
78
78
  > - memory: suggest-only; main agent persists
79
- > - fallback: if the subagent is unavailable, run a standalone fresh-eyes review against this output contract and record the skipped-delegation reason
80
- > - 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
81
79
 
82
80
  > **Dispatch: `massa-ai-verification-agent`** (role: `verification-agent`) — charter `skills/agents/verification-agent/SKILL.md`
83
81
  > - 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
84
82
  > - scope: the fixed divergence point from step 13, its reproduction path, and the regression test added in step 14
85
- > - permissions: read-only
86
83
  > - inputs: the root cause, the reproduction evidence, the regression test, and the changed files — not spec acceptance criteria
87
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)
88
85
  > - output: confirmed/disproven root-cause-closure verdict with evidence
89
86
  > - firewall: raw reproduction transcripts and logs summarized, never raw dumps
90
87
  > - memory: suggest-only; main agent persists debug verification outcomes
91
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
92
- > - 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
93
89
 
94
90
  15. If verification found a reusable signal (`ac_gap`, `surviving_mutant`, `spec_precision_gap`, `spec_deviation`, `gate_fail`), record it via `references/lessons.md`:
95
91
  `bun skills/massa-ai/scripts/lessons.ts --root . add --feature "<slug>" --signal "<signal>" --source "<ref>" --text "<one terse lesson>"`
96
- 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.
92
+ 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.
97
93
  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.
98
94
  17. IF fix found:
99
95
  - Persist the root cause via `remember` as a scored `decision` memory with `memory:semantic`
@@ -134,6 +130,3 @@ User asks: "The login route returns 500 after deploy."
134
130
  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.
135
131
  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.
136
132
  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.
137
-
138
- <!-- 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 -->
139
-