@massa-ai/codex-plugin 1.29.0 → 1.31.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "massa-ai",
3
- "version": "1.29.0",
3
+ "version": "1.31.0",
4
4
  "description": "massa-ai — semantic code search, memory, and context compression for Codex",
5
5
  "author": {
6
6
  "name": "Luiz Massa",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massa-ai/codex-plugin",
3
- "version": "1.29.0",
3
+ "version": "1.31.0",
4
4
  "description": "massa-ai plugin for Codex — semantic code search, memory, and context compression",
5
5
  "files": [
6
6
  "agents",
@@ -46,7 +46,7 @@ Before reading any massa-ai file:
46
46
  Never pass `workflowSessionId` in that field. Use `synapse_task_begin`/`synapse_task_end`
47
47
  for task envelopes and `synapse_prefetch` to warm the buffer on file open.
48
48
  - Prefer the shared v2 retrieval order; fall back gracefully if the massa-ai
49
- server or Synapse is unavailable. The full tool surface includes 52 tools
49
+ server or Synapse is unavailable. The full tool surface includes 54 tools
50
50
  (see `references/mcp-tools.md`): indexing, search, symbol graph
51
51
  (`trace_path`, `impact_analysis`, `get_architecture`), memory CRUD
52
52
  (`remember`, `recall`, `memory_update`, `memory_delete`), checkpoints
@@ -166,6 +166,8 @@ current context already contains it.
166
166
  | `commit` | draft or create safe Conventional Commits with Jira branch prefixes and audit report exclusions | `workflows/commit.md` |
167
167
  | `the-fool` | direct challenge, red-team, pre-mortem, evidence audit | `workflows/the-fool.md` |
168
168
  | `judge-with-debate` | standalone multi-judge debate evaluation of user-supplied artifacts | `workflows/judge-with-debate.md` |
169
+ | `pr-review` | review a hosted GitHub PR / GitLab MR and post findings via `gh`/`glab` | `workflows/pr-review.md` |
170
+ | `discovery` | product brainstorming / problem-space thinking partner | `workflows/discovery.md` |
169
171
  | `to-prd` | turn the current conversation into a PRD without a new interview | `workflows/to-prd.md` |
170
172
  | `skill-architect` | design and build a new skill through structured conversation | `workflows/skill-architect.md` |
171
173
  | `furps-refinement` | FURPS+ refinement of a PRD and/or ADR before implementation, with The Fool pre-validation and DoR coverage | `workflows/refinement/furps-refinement.md` |
@@ -181,8 +183,8 @@ Deterministic routing precedence, first match wins:
181
183
 
182
184
  1. **Explicit route:** user names a massa-ai workflow, report family, saved finding type, or asks for a direct challenge.
183
185
  2. **Requested artifact:** ADR, RFC, TDD, Jira ticket, commit, session guide, audit report, implementation audit report, mobile Figma report, FURPS refinement report, PRD synthesized from the current conversation -> `to-prd` (explicit request only; refining an existing PRD stays `furps-refinement`), or new SKILL.md / skill design -> `skill-architect`.
184
- 3. **Target type:** broken behavior/error -> `debug`; saved audit finding -> matching `*-fix`; implementation scope review -> `implementation-audit`; Maestro E2E/device automation target -> `maestro`, `maestro-audit`, or child-only `maestro-fix` before generic tests workflows; security/privacy/auth finding -> security workflow; tests/flakes/coverage finding -> tests workflow; supplied Figma/screenshot mobile UI design -> `design`; mobile Figma compare/audit -> `mobile-figma-audit`; saved `MFM-*` findings -> `mobile-figma-fix`.
185
- 4. **Primary verb:** create/add/implement -> `feature` unless the concrete target is new Maestro flow work, which routes to `maestro`; restructure without behavior change -> `refactor`; inspect/understand only -> `exploration`; record selected decision -> `adr`; compare open options -> `rfc`; design settled implementation -> `tdd`; refine/quality-check an existing PRD or ADR document (not implementation auditing) -> `furps-refinement`.
186
+ 3. **Target type:** broken behavior/error -> `debug`; hosted PR/MR reference (number or URL) to review with posted findings -> `pr-review` (local working diff stays with audit routes); saved audit finding -> matching `*-fix`; implementation scope review -> `implementation-audit`; Maestro E2E/device automation target -> `maestro`, `maestro-audit`, or child-only `maestro-fix` before generic tests workflows; security/privacy/auth finding -> security workflow; tests/flakes/coverage finding -> tests workflow; supplied Figma/screenshot mobile UI design -> `design`; mobile Figma compare/audit -> `mobile-figma-audit`; saved `MFM-*` findings -> `mobile-figma-fix`.
187
+ 4. **Primary verb:** create/add/implement -> `feature` unless the concrete target is new Maestro flow work, which routes to `maestro`; restructure without behavior change -> `refactor`; inspect/understand only -> `exploration`; brainstorm/explore a product problem, idea, or direction with no concrete code target -> `discovery`; record selected decision -> `adr`; compare open options -> `rfc`; design settled implementation -> `tdd`; refine/quality-check an existing PRD or ADR document (not implementation auditing) -> `furps-refinement`.
186
188
  5. **Risk domain escalation:** migrations, irreversible operations, auth/privacy, cross-service contracts, public compatibility, or work over 10 files routes to `spec-driven` unless the user explicitly requests a narrower workflow and accepts the containment.
187
189
  6. **General fallback:** use `general` only after a one-line General fallback preflight names the specialized workflow considered, rejected reason, and why fallback does not change verification or mutation behavior.
188
190
 
@@ -100,9 +100,9 @@ behavior through MCP declarations and non-destructive runtime probes.
100
100
  - Preferred: `bash scripts/install-agents.sh --agent <host>` — the single writer
101
101
  of host MCP config (Claude Code, Claude Desktop, Codex, Cursor, OpenCode).
102
102
  Plugin installers call it; nothing else writes an MCP entry.
103
- - OpenCode: local MCP package via `bunx @massa-ai/mcp-client`, or
104
- `@massa-ai/opencode-plugin` (which registers tools in-process, so
105
- `install-agents.sh` skips the MCP entry when that plugin is present).
103
+ - OpenCode: `@massa-ai/opencode-plugin` is hooks-only (AD-017) and delegates
104
+ MCP registration to `install-agents.sh --agent opencode` on every install,
105
+ same as every other host no separate MCP step needed.
106
106
  - VS Code/Antigravity: `.vscode/mcp.json` or `./scripts/setup-vscode.sh`.
107
107
  - Docker: run the `mcp` service through `docker compose run --rm -i mcp`.
108
108
 
@@ -1,4 +1,4 @@
1
- # massa-ai Tool Contracts (52 Tools)
1
+ # massa-ai Tool Contracts (54 Tools)
2
2
 
3
3
  Load when exact MCP schemas, REST fallbacks, response modes, or
4
4
  polling rules are needed. Prefer the active tool declaration over copied
@@ -138,6 +138,8 @@ depends on exact content.
138
138
  |---|---|---|
139
139
  | `rename_project` | Rename a project identity transactionally | Req: `sourceProjectId`, `targetProjectId`. Default `dryRun=true`; apply with `dryRun=false` + `operationId` + `expectedPlanHash`. Administrative, not workflow-recurring. |
140
140
  | `merge_projects` | Merge one project identity into another | Req: `sourceProjectId`, `targetProjectId`. Same dryRun/planHash contract as `rename_project`. Administrative, not workflow-recurring. |
141
+ | `profile_list` | List shipped model profiles and each detected host's current profile + bundle version | No required args; optional `host` to scope to one. Offline — reads on-disk variant directories only, never the registry. |
142
+ | `profile_set` | Switch the installed massa-ai agents to a registry model profile | Req: `profile`. Optional `host` (default: every detected, supported host), `dryRun` (default `false`) to preview without writing. Local trust model — mutates installed agent files on the machine the MCP server runs on; a host session restart is required to take effect. |
141
143
 
142
144
  ## Retrieval Order
143
145
 
@@ -0,0 +1,236 @@
1
+ ---
2
+ name: discovery
3
+ description: "Product discovery and brainstorming workflow — act as a sharp product thinking partner to explore problem spaces, generate and stress-test ideas, and spar on strategy before anything is spec-ready, ending with a mandatory offer to synthesize the conversation into a PRD via the to-prd workflow. Use when the user wants to brainstorm a product problem, idea, opportunity, or direction with no concrete code target. Do NOT use for codebase understanding (exploration), converting a finished discussion into a PRD (to-prd), or any implementation work."
4
+ license: Apache-2.0
5
+ metadata:
6
+ version: "1.0.0"
7
+ ---
8
+
9
+ ### Discovery (Product Brainstorming)
10
+
11
+ Attribution: adapted from the `product-brainstorming` skill in
12
+ `anthropics/knowledge-work-plugins` (Apache-2.0). massa-ai session/memory
13
+ binding, router integration, and the to-prd handoff are additions.
14
+
15
+ Act as a sharp product thinking partner — the experienced PM (Product
16
+ Manager) or design lead who challenges assumptions, asks hard questions, and
17
+ pushes ideas further before anyone converges too early. The job is not to
18
+ generate deliverables; it is to think alongside the user: be opinionated,
19
+ push back, bring unexpected angles, and help them reach ideas they would not
20
+ have reached alone.
21
+
22
+ This is a read-only conversation workflow: it never mutates the repository
23
+ and writes no `.specs/` artifacts. Its only outputs are the conversation
24
+ itself, durable memories at Capture, and — on explicit acceptance — a routed
25
+ handoff to `to-prd`.
26
+
27
+ Load `references/project-context.md` (intake sweep) before the first
28
+ substantive read when the conversation touches an existing product or
29
+ codebase; product context grounds the brainstorm in what exists today.
30
+
31
+ ## Session And Memory
32
+
33
+ - `workflowSessionId`: `discovery-<entity>` (e.g., `discovery-onboarding-dropoff`),
34
+ stable for the whole conversation.
35
+ - Start with a budgeted `recall` (limit ≤ 3, minImportance ≥ 0.7, types
36
+ `critical`/`decision`/`pattern`): prior product decisions, rejected
37
+ directions, and known constraints for this problem area. Rejected
38
+ directions are recalled so they are not re-litigated — but a rejected idea
39
+ may be re-opened deliberately when the user brings new evidence.
40
+ - If the massa-ai server is unavailable, continue without recall and say so
41
+ once; discovery degrades gracefully — the conversation is the primary
42
+ medium, not the memory store.
43
+
44
+ ## Brainstorming Modes
45
+
46
+ Identify which mode fits the conversation and adapt; shift modes as the
47
+ conversation evolves.
48
+
49
+ ### Problem Exploration
50
+
51
+ Use when the user has a problem area but has not defined what to solve.
52
+ Understand the problem space before any solutions: ask who has this problem
53
+ and what they do about it today; map who is involved, what triggers it, and
54
+ the consequences of not solving it; distinguish symptoms from root causes —
55
+ keep asking "why" until something structural appears; surface adjacent
56
+ problems; ask how the problem varies across user segments. Strong questions:
57
+ "What happens if we do nothing — who suffers and how?", "Who has solved a
58
+ version of this in a different context?", "Is this a problem of awareness,
59
+ ability, or motivation?"
60
+
61
+ ### Solution Ideation
62
+
63
+ Use when the problem is well-defined and the goal is divergent thinking —
64
+ quantity over quality. Generate at least 5–7 distinct approaches before
65
+ evaluating any; vary them along scope (tweak vs big bet), approach (product
66
+ vs process vs policy), and timing (quick win vs long-term); include one
67
+ "do the opposite" option and one that removes something instead of adding.
68
+ Techniques: constraint removal (no technical/budget/political constraints,
69
+ then work back to feasible), analogies from other industries, inversion,
70
+ decomposition into subproblems, and user hat-switching (power user, brand
71
+ new user, admin, someone who hates the product).
72
+
73
+ ### Assumption Testing
74
+
75
+ Use when an idea exists and needs stress-testing before investment. List
76
+ every assumption the idea depends on — stated and unstated — across user,
77
+ problem, solution, business, feasibility, and adoption categories. For each:
78
+ how confident are we, on what evidence, and what would disprove it? Identify
79
+ the riskiest assumption — the one that kills the idea if wrong — and the
80
+ cheapest way to test it before building anything. Argue the strongest
81
+ possible case against the idea.
82
+
83
+ ### Strategy Exploration
84
+
85
+ Use for direction, positioning, or big bets rather than a specific feature.
86
+ Map the possible strategic moves, not just the obvious one; think in bets
87
+ (what are we betting on, the odds, the payoff); consider second-order
88
+ effects ("if we do X, what does that enable or foreclose?"); bring in
89
+ competitive response; think in timeframes (3 months vs 12 months vs 3
90
+ years).
91
+
92
+ ## Frameworks As Tools
93
+
94
+ Pull a framework in when it moves the conversation forward — never dump
95
+ frameworks or force the conversation through them as a checklist.
96
+
97
+ - **How Might We (HMW)**: "How might we [outcome] for [user] without
98
+ [constraint]?" Aim between too broad ("improve onboarding") and too narrow
99
+ (a disguised solution); generate 5–10 reframings — each opens a different
100
+ solution space.
101
+ - **Jobs-to-be-Done (JTBD)**: "When [situation], I want to [motivation] so I
102
+ can [outcome]." The job is stable while solutions change; emotional and
103
+ social jobs often outweigh functional ones. Ask "what did they fire to
104
+ hire this?" — it reveals the real competitive set.
105
+ - **Opportunity Solution Tree**: outcome → opportunities (evidence-backed
106
+ user needs) → multiple solutions per opportunity → cheapest experiment per
107
+ solution. One solution per opportunity means exploration stopped too
108
+ early; the tree is a living artifact.
109
+ - **First Principles Decomposition**: state the assumption, break it into
110
+ fundamental components, ask of each "law of physics or convention?", then
111
+ rebuild from only the fundamentals. Use when the team is stuck in
112
+ incremental thinking.
113
+ - **SCAMPER**: seven lenses on an existing product — Substitute, Combine,
114
+ Adapt, Modify (10x bigger/smaller/faster), Put to other use, Eliminate
115
+ ("would anyone notice?"), Reverse (flip the sequence or the default).
116
+ - **OODA Loop** (Observe–Orient–Decide–Act): a decision-tempo framework —
117
+ gather raw signals wide, make sense of them while challenging your own
118
+ orientation, choose a proportional reversible bet, act, and cycle. Use
119
+ when the conversation over-deliberates or keeps circling: orient with what
120
+ exists, decide, and let the next observation correct course.
121
+ - **Reverse Brainstorming**: invert the problem ("how could we make this
122
+ worse?"), generate freely — people find flaws more easily than fixes —
123
+ then reverse each worsening idea into the seed of a solution.
124
+
125
+ ## Session Rhythm
126
+
127
+ A good session opens up before it narrows down. Move through five stages;
128
+ name the stage transition when it helps the user follow.
129
+
130
+ 1. **Frame** — Set boundaries before generating ideas: what are we
131
+ exploring, why now, what is already known (research, data, feedback),
132
+ what are the constraints, and what would a great outcome from this
133
+ session look like? A poorly framed brainstorm produces ideas that connect
134
+ to nothing.
135
+ 2. **Diverge** — Generate many ideas without judgment; build on ideas rather
136
+ than shooting them down; follow tangents; push past the first 3–5 obvious
137
+ ideas; use the frameworks above to open new angles. Do not evaluate
138
+ feasibility here — that kills divergent thinking.
139
+ 3. **Provoke** — The sparring-partner stage: "What is the strongest argument
140
+ against this?", "Who would hate this and why?", "What are we not
141
+ seeing?", "What if the opposite were true?", "What is the 10x more
142
+ ambitious version?"
143
+ 4. **Converge** — Group ideas into themes; evaluate against user impact,
144
+ feasibility, strategic alignment, and evidence strength; identify the top
145
+ 2–3 directions; for each, name the biggest unknown and the cheapest way
146
+ to resolve it. If one idea excites the user, explore it even if risky —
147
+ the brainstorm is not the decision.
148
+ 5. **Capture** — Mandatory; a brainstorm with no capture never happened.
149
+ Record in conversation: the key ideas and why they are interesting, the
150
+ assumptions to test, the questions to research, the suggested next steps,
151
+ and what was explicitly set aside (interesting, but not now).
152
+
153
+ At Capture, persist the durable subset via `remember`: chosen directions
154
+ with their why and rejected directions with reasons as `decision`, reusable
155
+ framings or cross-session insights as `pattern` — tagged
156
+ `project:<projectId>`, `session:discovery-<entity>`, `workflow:discovery`,
157
+ `entity:<name>`, and a memory-tier tag. Persist only what transcends the
158
+ session; never fabricate memories to satisfy process. If the server is
159
+ unavailable, the capture summary in conversation is the record.
160
+
161
+ ## PRD Handoff (to-prd)
162
+
163
+ End every Capture with an explicit offer — this step is mandatory, the PRD
164
+ is not:
165
+
166
+ > "Want me to turn this into a PRD (Product Requirements Document)? I'd
167
+ > synthesize this conversation through the `to-prd` workflow — no new
168
+ > interview."
169
+
170
+ - **Accepted** → route to `workflows/to-prd.md`. The user's acceptance is
171
+ the explicit request `to-prd`'s routing requires. Carry the current
172
+ conversation context — Capture's output (chosen directions, assumptions,
173
+ set-asides) feeds the PRD's problem statement, decisions, and out-of-scope
174
+ sections directly; `to-prd` does not re-interview.
175
+ - **Declined** → the capture summary stays in conversation and the durable
176
+ memories from Capture remain the only persistence. Offer nothing else.
177
+
178
+ If discovery converged on nothing PRD-shaped (pure problem exploration, or
179
+ the session identified research as the next step), say so instead of
180
+ offering an empty PRD — name what research or evidence would make the next
181
+ discovery session converge.
182
+
183
+ ## Thinking-Partner Conduct
184
+
185
+ Do:
186
+
187
+ - **Be opinionated.** "I think approach B is stronger because…" beats a
188
+ pro/con list.
189
+ - **Challenge constructively.** "That assumes X — are we confident?", not
190
+ "that will not work."
191
+ - **Bring unexpected angles** — cross-industry analogies, counterexamples,
192
+ edge cases the user has not considered.
193
+ - **Match energy.** When the user is excited about an idea, explore it with
194
+ them before poking holes.
195
+ - **Ask the next question.** When the user finishes a thought, push
196
+ further: "and then what happens?"
197
+ - **Name the pattern.** When a common PM trap appears (solutioning too
198
+ early, scope creep, feature-parity thinking), name it directly.
199
+
200
+ Do not:
201
+
202
+ - Dump frameworks or work through them as a checklist.
203
+ - Generate a list and hand it over — brainstorming is a conversation, not a
204
+ deliverable.
205
+ - Agree with everything — a thinking partner who only validates is not one.
206
+ - Evaluate feasibility during divergence.
207
+ - Anchor on the first idea — when the user leads with a solution,
208
+ acknowledge it, then ask what else could solve the problem.
209
+ - Confuse brainstorming with decision-making — the brainstorm generates
210
+ options; the decision comes later with more data.
211
+
212
+ ## Anti-Patterns To Catch
213
+
214
+ - **Solutioning before framing**: "we should build X" before the problem is
215
+ defined — slow down, ask what user problem X solves and how we know.
216
+ - **The feature-parity trap**: "competitor has X, so we need X" is copying,
217
+ not brainstorming — ask what user need X serves and whether there is a
218
+ better way to serve it.
219
+ - **Anchoring on constraints**: "we can't because of Y" during divergence —
220
+ set constraints aside, explore freely, then price feasibility.
221
+ - **The one-idea brainstorm**: a solution presented as a brainstorm —
222
+ acknowledge it, then push for three alternatives.
223
+ - **Analysis paralysis**: long divergence with no convergence — prompt "if
224
+ you had to pick one direction right now, which and why?"
225
+ - **Brainstorming when you should be researching**: when the session circles
226
+ because nobody knows the answer, stop and name the research needed — some
227
+ questions need data, not ideation.
228
+
229
+ ## Completion
230
+
231
+ Discovery completes at Capture plus the PRD offer. Before claiming the
232
+ session complete, apply `references/evidence-gate.md`: the evidence here is
233
+ the capture summary (ideas, assumptions, next steps, set-asides), the memory
234
+ outcome (what was persisted or why persistence was skipped), and the
235
+ recorded PRD-offer disposition (accepted → to-prd, declined, or
236
+ not-PRD-shaped with the named research gap).
@@ -0,0 +1,246 @@
1
+ ---
2
+ name: pr-review
3
+ description: "Explicit-route workflow to review a hosted GitHub Pull Request or GitLab Merge Request across six dimensions — security, requirements, test coverage, architecture, regression, performance — using massa-ai roster subagents, then post inline comments plus one consolidated summary through the host CLI (gh or glab). Use when the user says review PR 128, review this MR, or code review this pull request. Do NOT use for local working-diff review (audit workflows), creating PRs, replying to review comments, or fixing CI."
4
+ license: CC-BY-4.0
5
+ metadata:
6
+ version: "1.0.0"
7
+ ---
8
+
9
+ Attribution: adapted from the `pr-review` skill by github.com/augusto-dmh
10
+ (TLC skills catalog), licensed CC-BY-4.0. Host abstraction (GitLab support),
11
+ massa-ai roster dispatches, memory/index/`.specs/` integration, and channel
12
+ discipline are this repository's additions; repository contracts win on any
13
+ conflict with the base.
14
+
15
+ ### PR Review
16
+
17
+ Use when the user explicitly asks to review a hosted PR (Pull Request, GitHub) or
18
+ MR (Merge Request, GitLab) — "review PR 128", "review this MR", "check pull request
19
+ 42". Explicit route only: never auto-trigger during coding. Local working-tree diff
20
+ review stays with the audit workflows and `massa-ai-reviewer`; this workflow exists
21
+ to **post findings back to the host**.
22
+
23
+ Load `references/project-context.md` (intake sweep) before the first substantive
24
+ read. Resolve `projectId` and `workflowSessionId` = `pr-review-<number>` per the
25
+ Core Contract, and run a budgeted `recall` (limit ≤ 3, minImportance ≥ 0.7) for
26
+ prior review conventions and known regression patterns.
27
+
28
+ ## Execution Contract (non-negotiable)
29
+
30
+ 1. **Orchestration-only.** The main agent never authors a review finding. It
31
+ gathers context, dispatches the review subagents, dedupes their returned
32
+ findings, and posts. Doing the review inline — even for a small diff — is a
33
+ failure of this workflow.
34
+ 2. **Comment-only, never destructive.** Forbidden in every circumstance:
35
+ `gh pr review --approve`, `gh pr review --request-changes`, `gh pr merge`,
36
+ `glab mr approve`, `glab mr revoke`, `glab mr merge`, and the raw
37
+ `POST …/approve` / `POST …/unapprove` endpoints. Posting notes or discussions
38
+ never approves — keep it that way. Never modify repository files.
39
+ 3. **Subagents never touch the host.** Review subagents are read-only and
40
+ host-agnostic: they receive the diff and context in their packet and return
41
+ findings in their reply block. Only the orchestrator executes `gh`/`glab`.
42
+ 4. **File-body posting.** Every multiline body is written to a temp file and
43
+ posted with the host's file-body mechanism (`--body-file` / `-F body=@file`).
44
+ Inlining a multiline `--body` string is the protocol's most common failure.
45
+ 5. **Ask, never guess.** No PR/MR reference in the request → ask for it. Host CLI
46
+ cannot resolve the reference → stop and surface the CLI error output.
47
+
48
+ ## Step 1 — Initialize
49
+
50
+ ### 1a. Resolve the host
51
+
52
+ Order: explicit user statement > CLI probe > git remote host. Probe with
53
+ `gh repo view` / `glab repo view` **exit status** (glab's no-remote error text is
54
+ not a documented stable string — never match on the message). Both probes fail →
55
+ stop and report which CLI is missing or unauthenticated (`gh auth status` /
56
+ `glab auth status`). Both succeed (mirrored repo) → ask the user which host to
57
+ review on; a posted comment is outward-facing. Record `HOST ∈ {github, gitlab}`.
58
+
59
+ ### 1b. PR/MR context (via the command map below)
60
+
61
+ Resolve repository identity, then fetch: title + body/description + source
62
+ branch, the head anchor (`{SHA}` on GitHub; the full `diff_refs`
63
+ `{base_sha, head_sha, start_sha}` triple on GitLab), the full diff, and the
64
+ changed-file list. Then load the existing inline-comment inventory as
65
+ `{id, path, line, body}` records — **page to completion** (GitLab discussions
66
+ default to 20 per page; pin `per_page=100` and loop) — used for dedupe,
67
+ `[RESOLVED]` replies, and threading.
68
+
69
+ ### 1c. Project discovery (the adaptive spine)
70
+
71
+ Probe the repository once and record a DISCOVERY MAP passed verbatim to every
72
+ subagent. Prefer evidence the project states over guesses; mark absences `none`.
73
+
74
+ ```
75
+ TEST: <command CI actually runs> | globs: <...> | unit vs e2e: <split | none>
76
+ REQS: tracker=<GH #42 | Jira KEY-123 | GitLab #42 | none> ; specs=<paths | none>
77
+ CONVENTIONS: <doc/skill paths that state rules | none-found>
78
+ REVIEW_SKILLS: <project-local review skill paths | none>
79
+ INDEX: <massa-ai retrieval state: fresh | stale | unavailable — CLI fallback>
80
+ ```
81
+
82
+ - **TEST**: the CI workflow config is authoritative; manifests are fallback.
83
+ - **REQS Track A (tracker)**: ticket key from branch name or PR/MR body —
84
+ `gh issue view {N} --json title,body` / `glab issue view {N} --output json`;
85
+ Jira only through an already-configured Atlassian MCP (never invent a host).
86
+ - **REQS Track B (in-repo)**: `.specs/project/FEATURES.json` and
87
+ `.specs/features/<slug>/{spec,tasks}.md` acceptance criteria matched by branch,
88
+ ticket, or feature stem; then `docs/`, ADR/RFC directories, `*-spec.md`.
89
+ - **CONVENTIONS/REVIEW_SKILLS**: `CONTRIBUTING*`, `ARCHITECTURE*`, `AGENTS.md`,
90
+ `CLAUDE.md`, `docs/**` convention files, `.claude/skills/`, `.cursor/skills/`.
91
+ - **INDEX**: `list_projects` freshness first; when fresh, `project_map` or
92
+ `get_architecture` for orientation and `impact_analysis` over the PR/MR diff
93
+ for centrality-ranked hotspots; `search` under `references/synapse-policy.md`
94
+ when two or more related searches are planned. Index results are leads until
95
+ confirmed against the diff — never evidence on their own. Server or index
96
+ unavailable → record it and continue per `references/graceful-degradation.md`.
97
+
98
+ ## Host Command Map
99
+
100
+ The orchestrator reads every host operation from this table. `{REPO}`/`{PR}` are
101
+ GitHub coordinates; `{MR}` is the GitLab IID; `:id` is glab's project placeholder
102
+ (resolved from the current repo's remote — 8 placeholders are documented:
103
+ `:branch :fullpath :group :id :namespace :repo :user :username`).
104
+
105
+ | Operation | GitHub (`gh`) | GitLab (`glab`) |
106
+ | --- | --- | --- |
107
+ | Identity | `gh repo view --json nameWithOwner -q .nameWithOwner` → `{REPO}` | `glab repo view --output json --jq .path_with_namespace` (project id: `--jq .id`) |
108
+ | Metadata | `gh pr view {PR} --json title,body,headRefName,headRefOid` → `{SHA}` | `glab mr view {MR} --output json` → `title`, `description`, `source_branch`, `sha`, `diff_refs.{base_sha,head_sha,start_sha}` |
109
+ | Full diff | `gh pr diff {PR}` | `glab mr diff {MR} --raw` |
110
+ | Changed files | `gh pr diff {PR} --name-only` | `glab api "projects/:id/merge_requests/{MR}/diffs?per_page=100&page={N}"` → `new_path`/`old_path`, page to completion |
111
+ | Existing comments | `gh api repos/{REPO}/pulls/{PR}/comments` | `glab api "projects/:id/merge_requests/{MR}/discussions?per_page=100&page={N}"` → note `id`, `position.new_path`, `position.new_line`, `body` |
112
+ | Inline comment | `gh api repos/{REPO}/pulls/{PR}/comments -F body=@body.md -f commit_id={SHA} -f path={path} -F line={N} -f side=RIGHT` | `glab api --method POST "projects/:id/merge_requests/{MR}/discussions" -F body=@body.md -f "position[position_type]=text" -f "position[base_sha]={base}" -f "position[head_sha]={head}" -f "position[start_sha]={start}" -f "position[new_path]={path}" -f "position[old_path]={old}" -F "position[new_line]={N}"` |
113
+ | Thread reply | `gh api repos/{REPO}/pulls/{PR}/comments/{COMMENT_ID}/replies -F body=@body.md` | `glab api --method POST "projects/:id/merge_requests/{MR}/discussions/{DISCUSSION_ID}/notes" -F body=@body.md` |
114
+ | Summary | `gh pr review {PR} --comment --body-file summary.md` | `glab api --method POST "projects/:id/merge_requests/{MR}/notes" -F body=@summary.md` |
115
+
116
+ Anchoring and flag semantics (load-bearing, verified against official docs):
117
+
118
+ - **GitHub `line={N}`** is the 1-based line number in the **head file** on side
119
+ `RIGHT` — count from the hunk header across added and context lines. A
120
+ diff-relative offset returns 422 or lands on the wrong line.
121
+ - **GitLab added line** ⇒ send `position[new_line]` and **omit** `old_line`
122
+ (removed line: the reverse; context line: both). `new_path` **and** `old_path`
123
+ are both required for `position_type=text` — take `old_path` from the `/diffs`
124
+ inventory, never assume it equals `new_path` (renames break that).
125
+ - **`-F`/`--field` expands `@file` and infers types on both CLIs; `-f`/
126
+ `--raw-field` does neither** — `-f body=@body.md` posts the literal string
127
+ `@body.md`. Use `-F` for bodies and line numbers, `-f` for plain strings.
128
+ glab's `-F` also switches the default method to POST.
129
+ - `glab mr note create` has experimental inline flags (`--file`, `--line`,
130
+ `--reply`) — GitLab marks them "might be unstable or removed at any time"; the
131
+ stable `glab api` paths above are the contract. A plain summary may also use
132
+ `glab mr note create {MR} < summary.md` (body from stdin).
133
+
134
+ ## Step 2 — Dispatch the review (two waves)
135
+
136
+ Six dimensions run as read-only roster dispatches under
137
+ `references/agent-orchestration.md` (wave cap 4 → wave 1 = rows 1–4, wave 2 =
138
+ rows 5–6). Each packet carries: the dimension row below, the DISCOVERY MAP, the
139
+ PR/MR intent (title/body/branch), the existing-comment inventory, the diff
140
+ trimmed to hunks relevant to the dimension per `references/context-firewall.md`,
141
+ the severity labels, and the reply contract.
142
+
143
+ | # | Dimension | Agent | Packet delta (lens / scope) | Marker `{type}` |
144
+ | --- | --- | --- | --- | --- |
145
+ | 1 | Security | `massa-ai-audit-specialist` | `lens: security` — secrets, authn/authz on new endpoints, injection, unsafe deserialization, PII in logs, permissive CORS, leaking payload fields | `security` |
146
+ | 2 | Requirements & DoD (Definition of Done) | `massa-ai-audit-specialist` | `lens: requirements` — score merged Track A + Track B criteria against the diff, evidence-or-zero: ✅ implemented (`path:line`) / 🟡 partial / ❌ missing; no source ⇒ report "requirements verification skipped" | `requirements` |
147
+ | 3 | Architecture & conventions | `massa-ai-audit-specialist` | `lens: architecture` — extract every explicit rule from the profile's CONVENTIONS/REVIEW_SKILLS docs into a numbered matrix, grade each changed file PASS/VIOLATION/N/A; no docs ⇒ minimal generic boundary sweep, stated | `architecture` |
148
+ | 4 | Performance | `massa-ai-audit-specialist` | `lens: performance` — only issues clearly visible in the diff: N+1 queries, unbounded fetches, per-row lazy I/O, sequential awaits of independent calls, loop-invariant recomputation, unbatched writes | `performance` |
149
+ | 5 | Test coverage | `massa-ai-audit-specialist` | `lens: performance`, scope: test coverage (the charter's lens set has no `tests` lens; `tests-audit.md` precedent) — new/changed behavior with no test, wrong level (unit vs integration), placement/naming vs profile TEST row, missing negative case, assertions that exercise but never assert | `tests` |
150
+ | 6 | Regression & hallucination | `massa-ai-reviewer` | diff review — unrelated deletions, references to symbols absent from the repo, wrong signature/arity, duplicated existing logic, weakened error handling or assertions, leftover TODO/stub, dead code | `regression` |
151
+
152
+ Consolidation check (≥ 5 subagents): recorded in the feature design — rows 4 and 5
153
+ share only the lens label, not a knowledge domain; they stay separate dispatches.
154
+
155
+ > **Dispatch: `massa-ai-audit-specialist`** (role: `audit-specialist`) — charter `skills/agents/audit-specialist/SKILL.md`
156
+ > - trigger: pr-review Step 2, dimension rows 1–5 (one dispatch per row)
157
+ > - scope: the PR/MR diff and surrounding context for one dimension row; never the whole repository
158
+ > - permissions: read-only; no host CLI calls, no posting
159
+ > - inputs: exact `projectId`, parent `workflowSessionId`, dimension row (lens + scope), DISCOVERY MAP, PR/MR intent, trimmed diff, existing-comment inventory, severity labels, reply contract
160
+ > - sensors: second-pass sweep — re-read the full trimmed diff, list every file/hunk not commented on, and state per file why it is clean for this dimension before returning
161
+ > - output: structured reply block — findings rows `{path, head-line, severity, marker type, title, body ≤ 6 lines, recommendation}` + exactly one positive highlight + files-swept-clean list; when uncertain a finding is real, withhold it (the source protocol's high-confidence bar, applied qualitatively)
162
+ > - firewall: raw diff/log/search output summarized, never returned raw
163
+ > - memory: suggest-only; the main agent persists durable outcomes
164
+ > - 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
165
+
166
+ > **Dispatch: `massa-ai-reviewer`** (role: `reviewer`) — charter `skills/agents/reviewer/SKILL.md`
167
+ > - trigger: pr-review Step 2, dimension row 6 (regression & hallucination)
168
+ > - scope: the full PR/MR diff against the repository's real symbol surface
169
+ > - permissions: read-only; no host CLI calls, no posting
170
+ > - inputs: exact `projectId`, parent `workflowSessionId`, dimension row 6, DISCOVERY MAP, PR/MR intent, full diff, existing-comment inventory, severity labels, reply contract
171
+ > - sensors: verify referenced symbols exist (`search_definitions`/`get_references` when INDEX is fresh, else grep); second-pass sweep as above
172
+ > - output: structured reply block — findings rows tagged `{unrelated-deletion | phantom-reference | wrong-signature | duplicate | weakened-check | dead-code}` + one positive highlight + files-swept-clean list; withhold uncertain findings
173
+ > - firewall: raw diff/log/search output summarized, never returned raw
174
+ > - memory: suggest-only; the main agent persists durable outcomes
175
+ > - 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
176
+
177
+ Severity labels (all dimensions): 🚨 Critical (bugs/logic errors that will fail) ·
178
+ 🔒 Security · ⚡ Performance · ⚠️ Warning (smells/maintainability) ·
179
+ 💡 Suggestion. A failed or unavailable dispatch is reported in the summary as a
180
+ skipped dimension with its reason — never silently dropped.
181
+
182
+ ## Step 3 — Post inline findings (orchestrator only)
183
+
184
+ For every returned finding, in order:
185
+
186
+ 1. **Dedupe**: drop it when an existing comment sits within ±3 lines of the same
187
+ path/line (inventory from 1b) or another dimension already produced the same
188
+ `{path, line}` finding (keep the higher severity; note both markers).
189
+ 2. **Resolve check**: when an existing comment's issue is fixed by this diff,
190
+ reply `[RESOLVED] This appears resolved by the recent changes.` on that thread
191
+ via the reply command (GitHub: the comment's `id`; GitLab: its
192
+ `discussion_id`).
193
+ 3. **Anchor**: only added (`+`) diff lines on the head revision, per the
194
+ anchoring semantics above. A finding with no `+` line to stand on goes to the
195
+ summary instead.
196
+ 4. **Body**: temp file, starting with the invisible marker
197
+ `<!-- pr-review:{type} -->`, then `[severity emoji] — [short title]`, the
198
+ evidence-grounded body, and a `**Recommendation:**` line. No AI/assistant/
199
+ tool attribution anywhere — write as a reviewer. Specific, actionable,
200
+ collegial; always explain why.
201
+ 5. **Post** with the inline-comment command for `HOST`.
202
+
203
+ ## Step 4 — Consolidated summary
204
+
205
+ Assemble from the reply blocks (no extra subagent) and post one summary via the
206
+ summary command:
207
+
208
+ ```markdown
209
+ ## 📋 PR Review Summary
210
+
211
+ | | |
212
+ |---|---|
213
+ | **Host / target** | {github PR #N | gitlab MR !N} @ {head sha} |
214
+ | **Dimensions** | 6 (Security · Requirements & DoD · Tests · Architecture · Regression · Performance) |
215
+ | **Detected runner** | {TEST row | none found} |
216
+ | **Requirements source** | {tracker / spec paths / none} |
217
+ | **Project refs loaded** | {CONVENTIONS + REVIEW_SKILLS rows} |
218
+ | **Findings** | {N} across {M} files |
219
+
220
+ ### 🔒 Security ({N}) / 🚨 Critical ({N}) / ⚡ Performance ({N}) / ⚠️ Warnings ({N}) / 💡 Suggestions ({N})
221
+ - [`path/file:L42`] Finding title — one line each, grouped by severity
222
+
223
+ ### 📋 Requirements
224
+ {✅/🟡/❌ rows from dimension 2, with `path:line` evidence}
225
+
226
+ ### 🔍 Files with no findings
227
+ - `path` — swept clean by {dimensions} (omit section when every logic file got a comment; config/lock/declaration files excluded)
228
+
229
+ ### ✅ Highlights
230
+ - one per dimension
231
+
232
+ > See inline comments for details. {Skipped dimensions/sensors with reasons, if any.}
233
+ ```
234
+
235
+ Zero findings overall → post "✅ No issues found across all review dimensions."
236
+ with the metadata table intact.
237
+
238
+ ## Completion
239
+
240
+ - Emit Conversation Feedback status updates at wave boundaries when that policy
241
+ is active; expand every abbreviation on first use in user-facing output.
242
+ - Persist durable outcomes only (recurring review pattern, confirmed project
243
+ convention) with the required memory tags; do not fabricate memories.
244
+ - Close with `references/evidence-gate.md`: counts posted vs deduped vs withheld,
245
+ skipped dimensions/sensors with reasons, and the summary URL/reference.
246
+ <!-- validator anchors: comment-only | added (+) diff lines | page to completion | two waves -->