@exaudeus/workrail 3.12.0 → 3.14.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 (54) hide show
  1. package/dist/console/assets/{index-CRgjJiMS.js → index-EsSXrC_a.js} +11 -11
  2. package/dist/console/index.html +1 -1
  3. package/dist/di/container.js +8 -0
  4. package/dist/di/tokens.d.ts +1 -0
  5. package/dist/di/tokens.js +1 -0
  6. package/dist/infrastructure/session/HttpServer.js +2 -14
  7. package/dist/manifest.json +93 -53
  8. package/dist/mcp/boundary-coercion.d.ts +2 -0
  9. package/dist/mcp/boundary-coercion.js +73 -0
  10. package/dist/mcp/handler-factory.d.ts +1 -1
  11. package/dist/mcp/handler-factory.js +13 -6
  12. package/dist/mcp/handlers/v2-manage-workflow-source.d.ts +7 -0
  13. package/dist/mcp/handlers/v2-manage-workflow-source.js +50 -0
  14. package/dist/mcp/handlers/v2-workflow.d.ts +3 -0
  15. package/dist/mcp/handlers/v2-workflow.js +58 -0
  16. package/dist/mcp/output-schemas.d.ts +93 -0
  17. package/dist/mcp/output-schemas.js +8 -1
  18. package/dist/mcp/server.js +2 -0
  19. package/dist/mcp/tool-descriptions.js +20 -0
  20. package/dist/mcp/tools.js +6 -0
  21. package/dist/mcp/types/tool-description-types.d.ts +1 -1
  22. package/dist/mcp/types/tool-description-types.js +1 -0
  23. package/dist/mcp/types/workflow-tool-edition.d.ts +1 -1
  24. package/dist/mcp/types.d.ts +2 -0
  25. package/dist/mcp/v2/tool-registry.js +8 -0
  26. package/dist/mcp/v2/tools.d.ts +12 -0
  27. package/dist/mcp/v2/tools.js +7 -1
  28. package/dist/types/workflow-definition.d.ts +1 -0
  29. package/dist/v2/infra/in-memory/managed-source-store/index.d.ts +8 -0
  30. package/dist/v2/infra/in-memory/managed-source-store/index.js +33 -0
  31. package/dist/v2/infra/local/data-dir/index.d.ts +2 -0
  32. package/dist/v2/infra/local/data-dir/index.js +6 -0
  33. package/dist/v2/infra/local/managed-source-store/index.d.ts +15 -0
  34. package/dist/v2/infra/local/managed-source-store/index.js +164 -0
  35. package/dist/v2/ports/data-dir.port.d.ts +2 -0
  36. package/dist/v2/ports/managed-source-store.port.d.ts +25 -0
  37. package/dist/v2/ports/managed-source-store.port.js +2 -0
  38. package/package.json +2 -1
  39. package/spec/authoring-spec.json +9 -2
  40. package/spec/workflow.schema.json +418 -96
  41. package/workflows/adaptive-ticket-creation.json +276 -282
  42. package/workflows/document-creation-workflow.json +70 -191
  43. package/workflows/documentation-update-workflow.json +59 -309
  44. package/workflows/intelligent-test-case-generation.json +37 -212
  45. package/workflows/personal-learning-materials-creation-branched.json +1 -21
  46. package/workflows/presentation-creation.json +143 -308
  47. package/workflows/relocation-workflow-us.json +161 -535
  48. package/workflows/scoped-documentation-workflow.json +110 -181
  49. package/workflows/workflow-for-workflows.v2.json +72 -16
  50. package/workflows/CHANGELOG-bug-investigation.md +0 -298
  51. package/workflows/bug-investigation.agentic.json +0 -212
  52. package/workflows/bug-investigation.json +0 -112
  53. package/workflows/mr-review-workflow.agentic.json +0 -538
  54. package/workflows/mr-review-workflow.json +0 -277
@@ -1,538 +0,0 @@
1
- {
2
- "id": "mr-review-workflow-agentic",
3
- "name": "Adaptive MR Review Workflow (Agentic)",
4
- "version": "0.3.0",
5
- "description": "An adaptive agentic workflow for comprehensive code review. Adjusts rigor based on MR complexity (QUICK/STANDARD/THOROUGH modes) with parallel subagent delegation for context auditing, multi-perspective analysis, and triple validation gates.",
6
- "preconditions": [
7
- "User has the full code diff accessible (e.g., as text in a file).",
8
- "User has the MR title, purpose, and any relevant ticket numbers.",
9
- "The agent has access to file-reading tools."
10
- ],
11
- "clarificationPrompts": [
12
- "Provide the associated ticket ID(s)/link(s) and paste full text if possible.",
13
- "Provide links (or attach) any dev plan, design/architecture doc, or BRD relevant to this MR.",
14
- "Provide the code diff (paste content or give a file path)."
15
- ],
16
- "metaGuidance": [
17
- "The ultimate goal is to assist, not replace, a human reviewer. The human owns the final merge decision.",
18
- "All feedback should be constructive and actionable. Explain the 'why' behind suggestions.",
19
- "The goal is continuous improvement, not perfection. Approve changes that are 'better' to maintain velocity.",
20
- "Foster a blameless culture of collective ownership. The code is a shared asset.",
21
- "Use prefixes like 'Nit:' for non-blocking, minor suggestions to keep focus on important issues.",
22
- "Embrace small, single-purpose pull requests for faster, more thorough reviews.",
23
- "When citing issues, always try to provide specific file paths and line numbers from the diff.",
24
- "Maintain the persona of a helpful, collaborative senior engineer.",
25
- "DELEGATION: This workflow will explicitly tell you when to delegate to the WorkRail Executor. Do NOT delegate spontaneously - ONLY when the workflow says 'Delegate to the WorkRail Executor'.",
26
- "MODE-ADAPTIVE: After triage, you'll assess complexity and choose QUICK, STANDARD, or THOROUGH mode. Each mode has different delegation strategies.",
27
- "Auto-advance: after completing each step, immediately get the next step; only pause for explicit requireConfirmation or missing critical inputs.",
28
- "FunctionReferences are mandatory. When a step lists functionReferences, execute each in the listed order before producing chat output.",
29
- "FunctionReferences are conceptual (not MCP tools). 'Execute' means: read the function's definition and perform those actions using your available tools.",
30
- "Document I/O: create/update the file at reviewDocPath using file-writing tools. If the agent cannot write files, output the exact doc content.",
31
- "If a function requires inputs that are missing, state exactly what is missing and pause.",
32
- "discoverModulePatterns(): Compute moduleRoot; scan only moduleRoot to build patternCatalog.",
33
- "consolidatePatternFindings(): Compare changes to patternCatalog (scoped to moduleRoot).",
34
- "initReviewDoc(): Create live Markdown at project root; set reviewDocPath.",
35
- "upsertSection(): Upsert under a known section marker; never duplicate sections.",
36
- "appendChangedFileRow(): Append/update Changed Files table row.",
37
- "appendFinding(): Append finding under severity with path:line, rationale, optional diff.",
38
- "appendPatternResult(): Append Pattern Adherence row.",
39
- "appendMRComment(): Append copy-ready MR comment.",
40
- "logRevision(): Append timestamped message to the Revision Log."
41
- ],
42
- "steps": [
43
- {
44
- "id": "phase-0-triage",
45
- "title": "Phase 0: Triage & Review Focus",
46
- "prompt": "To begin the Merge Request review, please provide the full context below and classify the MR's complexity. This will tailor the depth of the review.\n\n**1. MR Context:**\n* **MR Title/Purpose:** [User provides the title and a brief description of its purpose.]\n* **Related Ticket(s):** [User provides ticket numbers or links.]\n* **Key Requirements/Acceptance Criteria:** [User lists key requirements from the ticket(s).]\n\n**2. Code Diff:**\n[User pastes the full `git diff` output or provides a path to a file containing the diff.]\n\n**3. Complexity Classification & Focus:**\n* **Classification:** Please choose one: **[Trivial]**, **[Standard]**, or **[High-Risk]**.\n* **PR Size:** Is this a small, focused change (<400 lines)? If not, does it have a single, clear purpose?\n* **Areas of Focus (Optional):** Are there specific areas you want me to pay close attention to? (e.g., 'performance implications', 'API design', 'data integrity').",
47
- "agentRole": "You are a code review coordinator and triage specialist with expertise in assessing merge request complexity and risk.",
48
- "guidance": [
49
- "**[Trivial]:** For minor fixes (typos, docs). This will run a condensed, single-phase review with minimal delegation.",
50
- "**[Standard]:** For typical features or bug fixes. Uses sequential delegation for validation.",
51
- "**[High-Risk]:** For major architectural changes or sensitive code. Uses parallel multi-perspective delegation for maximum rigor."
52
- ],
53
- "functionReferences": [
54
- "initReviewDoc()",
55
- "logRevision()"
56
- ],
57
- "requireConfirmation": true
58
- },
59
- {
60
- "id": "phase-0a-assess-mode",
61
- "title": "Phase 0A: Assess Complexity & Choose Mode",
62
- "prompt": "**ASSESS REVIEW COMPLEXITY & CHOOSE MODE**\n\nBased on the triage information, assess the review complexity and choose the appropriate mode.\n\n**COMPLEXITY ASSESSMENT:**\n\nReview the MR context:\n\n1. **Scope:** Files changed [count], Lines added/removed [count], Components touched [count]\n2. **Risk Factors:** Critical system? User-facing? Data/schema changes? Security implications?\n3. **Pattern Complexity:** New patterns introduced? Deviates from existing conventions?\n4. **Test Coverage:** Adequate tests included? Gap in coverage?\n\n**MODE DECISION CRITERIA:**\n\n**THOROUGH** (High-Risk - use if ANY true):\n- 10+ files OR 500+ lines changed\n- Touches critical systems (auth, payments, data)\n- Introduces new architectural patterns\n- Multiple complex components interacting\n- Security-sensitive changes\n\n**QUICK** (Trivial - use if ALL true):\n- <5 files AND <100 lines changed\n- Documentation, typos, or simple config changes\n- No logic changes\n- Well-understood, isolated change\n\n**STANDARD** (Otherwise): Middle ground between QUICK and THOROUGH\n\n**MAKE YOUR DECISION:**\n\nChoose: **QUICK**, **STANDARD**, or **THOROUGH**\n\nDocument in the review doc:\n```markdown\n## Review Mode: [QUICK/STANDARD/THOROUGH]\n**Rationale:** [Your reasoning based on criteria above]\n```\n\n**What Each Mode Means:**\n\n- **QUICK**: Minimal delegation, fast review, focus on obvious issues\n- **STANDARD**: Sequential context audit, standard analysis depth, single validation\n- **THOROUGH**: Parallel context audits, multi-perspective analysis, triple validation gate\n\n**Remember your choice** for later phases!",
63
- "agentRole": "You are assessing review complexity to choose the right level of rigor.",
64
- "requireConfirmation": false,
65
- "guidance": [
66
- "HONEST ASSESSMENT: Don't underestimate complexity for critical systems",
67
- "USE CRITERIA: Follow the decision rules based on MR characteristics",
68
- "DOCUMENT: Write your decision and rationale clearly",
69
- "REMEMBER: You'll adapt your approach in later phases based on this"
70
- ],
71
- "functionReferences": [
72
- "upsertSection()",
73
- "logRevision()"
74
- ]
75
- },
76
- {
77
- "id": "phase-1-context",
78
- "title": "Phase 1: Contextual Understanding & Confirmation",
79
- "prompt": "My goal is to ensure I fully understand the MR before the deep analysis. Based on the context you provided, I will perform the following tasks:\n\n1. **Summarize Goal:** Briefly summarize what I understand to be the primary goal and scope of this MR.\n2. **File Overview:** List all changed files (added, modified, deleted) and provide a one-sentence summary of the changes for each.\n3. **Initial Questions:** Formulate any immediate questions I have about the MR's purpose or requirements.\n4. **Confirmation Gate:** Does my summary accurately reflect the MR's goal? Please confirm before I proceed.\n\nI will also update the live review document with the Changed Files table and the Context summary.",
80
- "agentRole": "You are a thorough code review analyst specializing in requirement comprehension and change impact assessment.",
81
- "guidance": [
82
- "This is a critical sanity check. If the agent's summary is incorrect, correct it now.",
83
- "Doc writes: update only 'Context Summary' and 'Changed Files' sections.",
84
- "Ask any clarifying questions in chat only; do not write them into the doc.",
85
- "Do not create placeholders for issues in this step."
86
- ],
87
- "runCondition": {
88
- "var": "complexity",
89
- "not_equals": "Trivial"
90
- },
91
- "requireConfirmation": true,
92
- "functionReferences": [
93
- "upsertSection()",
94
- "appendChangedFileRow()",
95
- "logRevision()"
96
- ]
97
- },
98
- {
99
- "id": "phase-1a-llm-context-gathering",
100
- "title": "Phase 1a: Comprehensive Context Gathering",
101
- "prompt": "To perform a thorough review, I need you to provide source documents. In this step I will not search or analyze code—I'm waiting for your inputs. Please provide:\n\n1. **Ticket(s):** Link(s) and, if possible, paste the full text (requirements, acceptance criteria).\n2. **Dev/Design Docs:** Dev plan; design/architecture docs; any BRD/ADR/decision records relevant to this MR.\n3. **Technical Context:** If this change relies on other parts of the codebase, paste relevant code snippets or file contents.\n\nI will synthesize this information once received.\n\n**Confirmation & Gating:**\n- After you confirm that I have the right context (or explicitly instruct me to skip), I will proceed.\n- I will not proceed to deeper analysis until confirmed.",
102
- "agentRole": "You are a context-aware analyst ensuring you have all necessary information before starting a deep review.",
103
- "guidance": [
104
- "User-driven step: ask for ticket, dev plan, design/architecture docs.",
105
- "Do not search or analyze code in this step; wait for user inputs.",
106
- "Only after explicit confirmation or 'skip' proceed to next phase."
107
- ],
108
- "runCondition": {
109
- "var": "complexity",
110
- "not_equals": "Trivial"
111
- },
112
- "requireConfirmation": true
113
- },
114
- {
115
- "id": "phase-1b-familiarization",
116
- "title": "Phase 1b: Neighborhood, Call Graph, and Contracts Familiarization",
117
- "prompt": "Build a lightweight understanding of surrounding code to increase review accuracy.\n\nTasks:\n1) Neighborhood Map: For each changed file, list immediate neighbors in moduleRoot.\n2) Bounded Call Graph: For changed functions/classes, gather callers and callees up to 2 hops.\n3) Contracts & Invariants: List public symbols, API endpoints, DB/tables touched nearby.\n\nDoc-first: Upsert sections 'Neighborhood Map', 'Bounded Call Graph', and 'Contracts & Invariants' with concise tables/bullets.",
118
- "agentRole": "You are a codebase navigator building context around the change to improve downstream analysis.",
119
- "guidance": [
120
- "Initialize majorIssuesFound = false.",
121
- "Scope strictly to moduleRoot and changed files plus immediate neighbors.",
122
- "Cap per-file neighbors and graph size to avoid noise.",
123
- "Write full details to the live doc; in chat, keep output minimal."
124
- ],
125
- "runCondition": {
126
- "and": [
127
- {
128
- "var": "complexity",
129
- "not_equals": "Trivial"
130
- },
131
- {
132
- "or": [
133
- {
134
- "var": "contextGatheringComplete",
135
- "equals": true
136
- },
137
- {
138
- "var": "skipContextGathering",
139
- "equals": true
140
- }
141
- ]
142
- }
143
- ]
144
- },
145
- "functionReferences": [
146
- "upsertSection()",
147
- "logRevision()"
148
- ],
149
- "requireConfirmation": false
150
- },
151
- {
152
- "id": "phase-1c-context-audit",
153
- "title": "Phase 1c: Context Audit (Mode-Adaptive)",
154
- "prompt": "**AUDIT YOUR CONTEXT UNDERSTANDING BASED ON YOUR MODE**\n\n⚠️ **CHECK YOUR MODE** (from Phase 0A): QUICK, STANDARD, or THOROUGH?\n\n---\n\n**IF YOU CHOSE THOROUGH MODE:**\n\n**PARALLEL CONTEXT AUDIT**\n\n⚠️ **CRITICAL: Delegate to the WorkRail Executor TWICE SIMULTANEOUSLY, not sequentially.**\n\nYou've gathered context about the MR. Now get independent review of your understanding.\n\n**Delegation (Completeness Focus):**\n```\nPlease execute the 'Context Gathering Routine' workflow in audit mode.\n\nAudit Request:\nMISSION: Audit my MR context gathering for COMPLETENESS\n\nMY CONTEXT GATHERING:\n[Paste the Neighborhood Map, Call Graph, and Contracts sections from review doc]\n\nFOCUS: Completeness\n- Did I miss any critical files or components?\n- Are there important callers/callees I didn't trace?\n- Did I capture all relevant contracts and invariants?\n- What else should I have looked at?\n\nDELIVERABLE: Audit findings with specific gaps and recommendations\n```\n\n**Delegation (Depth Focus):**\n```\nPlease execute the 'Context Gathering Routine' workflow in audit mode.\n\nAudit Request:\nMISSION: Audit my MR context gathering for DEPTH\n\nMY CONTEXT GATHERING:\n[Paste the Neighborhood Map, Call Graph, and Contracts sections from review doc]\n\nFOCUS: Depth\n- Did I go deep enough in understanding the changes?\n- Did I understand WHY the code works this way, not just WHAT it does?\n- Should I have read implementations instead of just signatures?\n- What areas need deeper investigation?\n\nDELIVERABLE: Audit findings with areas needing deeper review\n```\n\n**SYNTHESIZE AUDIT FEEDBACK**\n\nReview both audit deliverables:\n1. Completeness audit: What did I miss?\n2. Depth audit: Where should I go deeper?\n\n**Synthesis Strategy:**\n- Common concerns: If both flag same area → High priority\n- Unique insights: Each may catch different gaps\n- Conflicting advice: Investigate to understand why\n\n**ITERATE IF NEEDED**\n\nBased on feedback, investigate further if significant gaps:\n- Run Context Gathering Routine again with different target\n- Trace additional call paths\n- Read implementations you skipped\n\n**UPDATE REVIEW DOC** with:\n- Audit findings synthesized\n- Additional context gathered\n- Final understanding of scope and impact\n\n---\n\n**IF YOU CHOSE STANDARD MODE:**\n\nUse single context audit:\n\n1. **Delegate to ONE Context Auditor:**\n ```\n Please execute the 'Context Gathering Routine' workflow in audit mode.\n \n Audit Request:\n MY CONTEXT GATHERING: [Your context sections]\n FOCUS: General review for both completeness and depth\n ```\n\n2. **Address gaps** if any significant ones found\n3. **Proceed** when satisfied\n\n---\n\n**IF YOU CHOSE QUICK MODE:**\n\nSkip context audit. Self-check:\n\n1. **Quick review**: Do I understand the change well enough?\n2. **Obvious gaps**: Am I missing anything critical?\n3. **Proceed** - don't over-analyze simple changes\n\n---",
155
- "agentRole": "You are getting independent review of your context understanding to ensure thorough analysis.",
156
- "requireConfirmation": false,
157
- "guidance": [
158
- "MODE: Adapt your approach based on your Phase 0A decision",
159
- "PARALLEL: In THOROUGH mode, delegate twice to WorkRail Executor SIMULTANEOUSLY",
160
- "DIVERSITY: Each auditor has different focus (completeness vs depth)",
161
- "SYNTHESIS: Combine both perspectives, address gaps",
162
- "ITERATE: Gather more context if significant gaps found"
163
- ],
164
- "runCondition": {
165
- "and": [
166
- {
167
- "var": "complexity",
168
- "not_equals": "Trivial"
169
- },
170
- {
171
- "or": [
172
- {
173
- "var": "contextGatheringComplete",
174
- "equals": true
175
- },
176
- {
177
- "var": "skipContextGathering",
178
- "equals": true
179
- }
180
- ]
181
- }
182
- ]
183
- },
184
- "functionReferences": [
185
- "upsertSection()",
186
- "logRevision()"
187
- ]
188
- },
189
- {
190
- "id": "phase-2-depth-analysis-loop",
191
- "type": "loop",
192
- "title": "Phase 2: Progressive Depth Analysis",
193
- "runCondition": {
194
- "and": [
195
- {
196
- "var": "complexity",
197
- "not_equals": "Trivial"
198
- },
199
- {
200
- "or": [
201
- {
202
- "var": "contextGatheringComplete",
203
- "equals": true
204
- },
205
- {
206
- "var": "skipContextGathering",
207
- "equals": true
208
- }
209
- ]
210
- }
211
- ]
212
- },
213
- "loop": {
214
- "type": "for",
215
- "count": 4,
216
- "maxIterations": 4,
217
- "iterationVar": "analysisDepth"
218
- },
219
- "body": [
220
- {
221
- "id": "discover-module-patterns",
222
- "title": "Discover Module Patterns (Depth 1)",
223
- "prompt": "Compute `moduleRoot` as the nearest common ancestor of changed files. Scan only within `moduleRoot` to gather exemplars (naming, DI, error handling, logging, test style, file layout). Exclude changed files from discovery. Produce `patternCatalog` and `patternExamples` in context.",
224
- "agentRole": "You are a codebase pattern scout building a concise pattern catalog for the current module.",
225
- "guidance": [
226
- "Scope strictly to `moduleRoot` discovered from changed files.",
227
- "Exclude changed files from discovery; use them only later for comparison.",
228
- "Require ≥2 occurrences across distinct files to qualify as a pattern.",
229
- "Capture 1–3 exemplars per validated pattern with file:line for the doc."
230
- ],
231
- "runCondition": {
232
- "var": "analysisDepth",
233
- "equals": 1
234
- },
235
- "functionReferences": [
236
- "discoverModulePatterns()"
237
- ],
238
- "requireConfirmation": false
239
- },
240
- {
241
- "id": "perform-analysis-pass",
242
- "title": "Analysis Pass {{analysisDepth}} of 4",
243
- "prompt": "Act as a Senior Staff Engineer. Your task is to review the code based on the checklist for the current analysis depth.\n\n**Current Depth: {{analysisDepth}}**\n\n**Checklist:**\n* **Depth 1 (Basic Scan):** Check for style guide violations, simple bugs, and common security vulnerabilities.\n* **Depth 2 (Standard Review):** Check for logical errors, edge cases, SOLID principles, and maintainability.\n* **Depth 3 (Deep Architectural Review):** Check for alignment with system architecture, performance, and dependencies.\n\n**Instructions:**\n1. **Summarize Focus:** State which depth level you are on.\n2. **Analyze:** Perform the review based on the checklist.\n3. **List Findings:** Document findings as 'Critical', 'Major', or 'Minor'.\n4. **Set Flag:** If you find 'Critical' or 'Major' issues, set `majorIssuesFound = true`.",
244
- "agentRole": "You are a Senior Staff Engineer performing a structured, multi-pass code review.",
245
- "guidance": [
246
- "At each depth, focus only on the items in that checklist.",
247
- "Use Chain-of-Thought reasoning; keep chat concise, write details to doc.",
248
- "Propose tiny diffs for the top 1–2 Major findings.",
249
- "Add matching ready-to-copy MR comments.",
250
- "Caps per pass: ≤2 patches; ≤3 MR comments."
251
- ],
252
- "runCondition": {
253
- "or": [
254
- {
255
- "var": "analysisDepth",
256
- "equals": 1
257
- },
258
- {
259
- "var": "analysisDepth",
260
- "equals": 2
261
- },
262
- {
263
- "var": "analysisDepth",
264
- "equals": 3
265
- }
266
- ]
267
- },
268
- "functionReferences": [
269
- "upsertSection()",
270
- "appendFinding()",
271
- "appendMRComment()",
272
- "logRevision()"
273
- ],
274
- "requireConfirmation": false
275
- },
276
- {
277
- "id": "perform-nit-hunt",
278
- "title": "Nit Hunt (Depth 4)",
279
- "prompt": "Perform a focused nit hunt on changed files and immediate neighbors. Be picky but objective.",
280
- "agentRole": "You are a meticulous reviewer surfacing small, high-signal improvements.",
281
- "guidance": [
282
- "Targets: naming clarity; readability; redundant comments; dead code; import order.",
283
- "Quotas: if majorIssuesFound==true aim 5–8; else aim 8–12; ≤3 per category.",
284
- "Add ready-to-copy MR comments for the top 3 nits."
285
- ],
286
- "runCondition": {
287
- "var": "analysisDepth",
288
- "equals": 4
289
- },
290
- "functionReferences": [
291
- "appendMRComment()",
292
- "upsertSection()",
293
- "logRevision()"
294
- ],
295
- "requireConfirmation": false
296
- }
297
- ]
298
- },
299
- {
300
- "id": "phase-2a-analysis-validation",
301
- "title": "Phase 2A: Analysis Validation (Mode-Adaptive)",
302
- "prompt": "**VALIDATE YOUR ANALYSIS BASED ON YOUR MODE**\n\n⚠️ **CHECK YOUR MODE** (from Phase 0A): QUICK, STANDARD, or THOROUGH?\n\n---\n\n**IF YOU CHOSE THOROUGH MODE:**\n\n**PARALLEL MULTI-PERSPECTIVE ANALYSIS VALIDATION**\n\n⚠️ **CRITICAL: Delegate to the WorkRail Executor THREE TIMES SIMULTANEOUSLY.**\n\nYou've completed your analysis. Now get multi-perspective validation.\n\n**Delegation 1 - Hypothesis Challenger (Challenge Findings):**\n```\nPlease execute the 'Hypothesis Challenge Routine' workflow at rigor=3.\n\nChallenge Request:\nFINDINGS: [Paste your Critical and Major findings from analysis]\n\nEVIDENCE: Read the review document sections on findings\n\nRIGOR: 3 (Thorough adversarial analysis)\n\nChallenge each finding:\n- Is this actually a problem?\n- Could I be misunderstanding the code's intent?\n- Are there false positives?\n- What evidence would contradict this finding?\n\nDELIVERABLE: Challenge results for each finding\n```\n\n**Delegation 2 - Hypothesis Challenger (Challenge Missing Issues):**\n```\nPlease execute the 'Hypothesis Challenge Routine' workflow at rigor=3.\n\nChallenge Request:\nMISSION: What issues might I have MISSED in my analysis?\n\nMY ANALYSIS:\n[Paste summary of what you checked and found]\n\nCONTEXT:\n- Changed files: [list]\n- Analysis depths completed: 1-4\n\nRIGOR: 3\n\nChallenge my coverage:\n- What categories of issues didn't I check?\n- Are there security concerns I might have missed?\n- Performance implications not considered?\n- Edge cases not explored?\n\nDELIVERABLE: Potential blind spots and missed issues\n```\n\n**Delegation 3 - Plan Analyzer (Validate Recommendations):**\n```\nPlease execute the 'Plan Analysis Routine' workflow.\n\nAnalysis Request:\nRECOMMENDATIONS: [Paste your proposed patches and suggestions]\n\nANALYZE:\n- Are the recommendations complete?\n- Do they follow project patterns?\n- Are there risks or unintended consequences?\n- Are they actionable and clear?\n\nDELIVERABLE: Validation of recommendations\n```\n\n**SYNTHESIZE ALL VALIDATION FEEDBACK**\n\nReview all three perspectives:\n1. Findings Challenge: Remove false positives, strengthen valid findings\n2. Coverage Challenge: Investigate missed areas if significant\n3. Recommendations Validation: Improve suggestions based on feedback\n\n**UPDATE REVIEW DOC** with validation results.\n\n---\n\n**IF YOU CHOSE STANDARD MODE:**\n\nSequential validation:\n\n1. **Self-review your findings**: Could any be false positives?\n2. **Delegate to ONE Hypothesis Challenger** (rigor=3):\n ```\n Please execute the 'Hypothesis Challenge Routine' workflow at rigor=3.\n \n Challenge Request:\n FINDINGS: [Your Critical/Major findings]\n RIGOR: 3\n \n Challenge each finding - is it valid?\n ```\n3. **Update findings** based on challenge results\n\n---\n\n**IF YOU CHOSE QUICK MODE:**\n\nSelf-validate:\n\n1. **Quick check**: Are my findings clearly valid?\n2. **Obvious misses**: Did I skip anything important?\n3. **Proceed** - don't over-validate simple reviews\n\n---",
303
- "agentRole": "You are validating your analysis findings with appropriate rigor based on review mode.",
304
- "requireConfirmation": false,
305
- "guidance": [
306
- "MODE: Adapt validation rigor based on your Phase 0A decision",
307
- "PARALLEL: In THOROUGH mode, delegate three times SIMULTANEOUSLY",
308
- "DIVERSITY: Three different validation angles (findings, coverage, recommendations)",
309
- "SYNTHESIS: Integrate all feedback, update findings",
310
- "FALSE POSITIVES: Remove findings that don't hold up to challenge"
311
- ],
312
- "runCondition": {
313
- "and": [
314
- {
315
- "var": "complexity",
316
- "not_equals": "Trivial"
317
- },
318
- {
319
- "or": [
320
- {
321
- "var": "contextGatheringComplete",
322
- "equals": true
323
- },
324
- {
325
- "var": "skipContextGathering",
326
- "equals": true
327
- }
328
- ]
329
- }
330
- ]
331
- },
332
- "functionReferences": [
333
- "upsertSection()",
334
- "logRevision()"
335
- ]
336
- },
337
- {
338
- "id": "consolidate-patterns",
339
- "title": "Consolidate Pattern Findings",
340
- "prompt": "Using `moduleRoot` and `patternCatalog`, compare the MR changes to validated patterns. Summarize adherence and deviations. Set `patternAppendixReady = true`.",
341
- "agentRole": "You are a senior engineer consolidating pattern adherence findings.",
342
- "guidance": [
343
- "Restrict to the module of the MR (`moduleRoot`).",
344
- "Do not treat changed code as patterns; match only against validated patterns.",
345
- "Produce 'Patterns' and 'Pattern Deviations' sections."
346
- ],
347
- "runCondition": {
348
- "var": "complexity",
349
- "not_equals": "Trivial"
350
- },
351
- "functionReferences": [
352
- "consolidatePatternFindings()",
353
- "appendPatternResult()",
354
- "upsertSection()",
355
- "logRevision()"
356
- ],
357
- "requireConfirmation": false
358
- },
359
- {
360
- "id": "phase-3-impact-analysis",
361
- "title": "Phase 3: Testing, Documentation & Impact Analysis",
362
- "prompt": "Assess the secondary impacts of this change.\n\n1. **Testing:** What tests are expected? Are new tests included? Coverage gaps?\n2. **Documentation:** Is new logic adequately commented? External docs affected?\n3. **Breaking Changes:** Could this break backward compatibility?\n\nDoc-first subsections:\n- Impacted User Flows\n- Affected Consumers\n- Test Gaps & Proposals",
363
- "agentRole": "You are a software quality engineer specializing in testing strategy and impact analysis.",
364
- "guidance": [
365
- "Assessing test coverage is critical. Lack of tests is often 'Major' or 'Critical'.",
366
- "Derive Impacted User Flows from Flow Anchors and HOT paths.",
367
- "List Affected Consumers (importers/API clients).",
368
- "Add test skeletons for top-risk flows/consumers.",
369
- "Add 2 ready-to-copy MR comments for highest-risk gaps."
370
- ],
371
- "runCondition": {
372
- "and": [
373
- {
374
- "var": "complexity",
375
- "not_equals": "Trivial"
376
- },
377
- {
378
- "or": [
379
- {
380
- "var": "contextGatheringComplete",
381
- "equals": true
382
- },
383
- {
384
- "var": "skipContextGathering",
385
- "equals": true
386
- }
387
- ]
388
- }
389
- ]
390
- },
391
- "functionReferences": [
392
- "upsertSection()",
393
- "appendMRComment()",
394
- "logRevision()"
395
- ],
396
- "requireConfirmation": false
397
- },
398
- {
399
- "id": "hygiene-and-inconsistencies",
400
- "title": "Hygiene & Inconsistencies Sweep",
401
- "prompt": "Perform a platform-agnostic hygiene sweep scoped to the current module and changed files:\n\n- Tests: disabled/skipped/focused tests; tests with no assertions\n- Comments: commented-out code; stale/misleading comments\n- TODO/FIXME/HACK/BUG: missing ticket/reference\n- Inconsistencies: naming/DI/logging divergences from local patterns\n\nConstraints: Total ≤10 items; ≤3 per category; dedupe; group by file.",
402
- "agentRole": "You are a pragmatic reviewer catching small but valuable quality issues.",
403
- "guidance": [
404
- "Scope strictly to moduleRoot and changed files plus neighbors.",
405
- "Write full details to the live doc; report counts in chat."
406
- ],
407
- "runCondition": {
408
- "var": "complexity",
409
- "not_equals": "Trivial"
410
- },
411
- "functionReferences": [
412
- "discoverHygieneSignals()",
413
- "consolidateHygieneFindings()",
414
- "appendHygieneFinding()",
415
- "appendMRComment()",
416
- "upsertSection()",
417
- "logRevision()"
418
- ],
419
- "requireConfirmation": false
420
- },
421
- {
422
- "id": "prepare-nit-appendix",
423
- "title": "Prepare Nit Appendix",
424
- "prompt": "Consolidate all non-blocking 'Nit:' items into a clean appendix.\n\nTasks:\n1. Aggregate `nitFindings` by file.\n2. Format each entry as: `filePath:line - short description`.\n3. Produce markdown in `nitAppendix`.\n4. Set `nitAppendixReady = true`.",
425
- "agentRole": "You are a meticulous note-taker consolidating non-blocking suggestions.",
426
- "guidance": [
427
- "Deterministic ordering: sort by file path → line → category.",
428
- "Caps: ≤15 total; ≤3 per category.",
429
- "Ensure at least 3 Nit MR comments exist overall."
430
- ],
431
- "runCondition": {
432
- "and": [
433
- {
434
- "var": "complexity",
435
- "not_equals": "Trivial"
436
- },
437
- {
438
- "or": [
439
- {
440
- "var": "contextGatheringComplete",
441
- "equals": true
442
- },
443
- {
444
- "var": "skipContextGathering",
445
- "equals": true
446
- }
447
- ]
448
- }
449
- ]
450
- },
451
- "functionReferences": [
452
- "appendMRComment()",
453
- "upsertSection()",
454
- "logRevision()"
455
- ],
456
- "requireConfirmation": false
457
- },
458
- {
459
- "id": "phase-4-final-validation",
460
- "title": "Phase 4: Final Validation (Mode-Adaptive)",
461
- "prompt": "**FINAL VALIDATION BASED ON YOUR MODE**\n\n⚠️ **CHECK YOUR MODE** (from Phase 0A): QUICK, STANDARD, or THOROUGH?\n\n---\n\n**IF YOU CHOSE THOROUGH MODE:**\n\n**TRIPLE VALIDATION GATE**\n\n⚠️ **CRITICAL: Spawn ALL THREE validators SIMULTANEOUSLY.**\n\nBefore finalizing your review, get three independent perspectives AT THE SAME TIME:\n\n**Validator 1 - Hypothesis Challenger (Overall Review Challenge):**\n```\nPlease execute the 'Hypothesis Challenge Routine' workflow at rigor=5.\n\nChallenge Request:\nREVIEW CONCLUSION: [Your overall assessment - approve/request changes/reject]\nFINDINGS SUMMARY: [Summary of Critical, Major, Minor issues found]\nRECOMMENDATION: [Your recommendation]\n\nRIGOR: 5 (Maximum adversarial review)\n\nTry to prove this review conclusion is WRONG:\n- Did I miss critical issues?\n- Am I being too harsh or too lenient?\n- Are my recommendations appropriate for the risk level?\n- Would another reviewer come to a different conclusion?\n\nDELIVERABLE: Adversarial challenge of review conclusion\n```\n\n**Validator 2 - Execution Simulator (Simulate Change Impact):**\n```\nPlease execute the 'Execution Simulation Routine' workflow.\n\nSimulation Request:\nMISSION: Simulate the impact of these changes in production\n\nCHANGES: [Summary of key changes in the MR]\nCONTEXT: [Relevant system context]\n\nSCENARIOS:\n1. Does the change work as intended in normal cases?\n2. How does it behave under edge cases?\n3. What could go wrong in production?\n4. Are there performance implications?\n\nDELIVERABLE: Simulation of change impact\n```\n\n**Validator 3 - Plan Analyzer (Validate Review Completeness):**\n```\nPlease execute the 'Plan Analysis Routine' workflow.\n\nAnalysis Request:\nREVIEW DOCUMENT: [Path to review document]\n\nANALYZE:\n- Is the review complete? (All required sections present?)\n- Are findings actionable? (Clear what author should do?)\n- Are MR comments ready to post? (Properly formatted?)\n- Does recommendation match findings? (Consistent?)\n\nDELIVERABLE: Review completeness validation\n```\n\n**FINAL SYNTHESIS - TRIPLE VALIDATION GATE:**\n\nReview all three perspectives:\n1. Review Challenge: Does my conclusion hold up?\n2. Impact Simulation: Did I properly assess risk?\n3. Completeness Check: Is the review document ready?\n\n**Quality Gate:**\n- ✅ ALL THREE give green light → Proceed to finalization\n- ⚠️ ONE raises concerns → Investigate and address\n- 🛑 TWO+ raise concerns → Revisit analysis phases\n\n**ONLY PROCEED if you have triple validation.**\n\n---\n\n**IF YOU CHOSE STANDARD MODE:**\n\nSequential validation:\n\n1. **Delegate to Hypothesis Challenger** (rigor=3):\n ```\n Please execute the 'Hypothesis Challenge Routine' workflow at rigor=3.\n \n Challenge Request:\n REVIEW CONCLUSION: [Your conclusion]\n RIGOR: 3\n \n Challenge my review - did I miss anything important?\n ```\n\n2. **Address concerns** if any raised\n3. **Proceed** if validation passes\n\n---\n\n**IF YOU CHOSE QUICK MODE:**\n\nSelf-validate:\n\n1. **Self-check**: Did I cover the basics?\n2. **Obvious misses**: Anything I should have caught?\n3. **Proceed** to finalization\n\n---",
462
- "agentRole": "You are performing final validation of your review with appropriate rigor.",
463
- "requireConfirmation": false,
464
- "guidance": [
465
- "MODE: Adapt validation rigor based on your Phase 0A decision",
466
- "PARALLEL: In THOROUGH mode, spawn all 3 validators SIMULTANEOUSLY",
467
- "TRIPLE GATE: ALL THREE must validate before proceeding in THOROUGH mode",
468
- "ITERATE: If 2+ raise concerns, revisit earlier phases",
469
- "COMPLETENESS: Ensure review document is ready for human reviewer"
470
- ],
471
- "runCondition": {
472
- "and": [
473
- {
474
- "var": "complexity",
475
- "not_equals": "Trivial"
476
- },
477
- {
478
- "or": [
479
- {
480
- "var": "contextGatheringComplete",
481
- "equals": true
482
- },
483
- {
484
- "var": "skipContextGathering",
485
- "equals": true
486
- }
487
- ]
488
- }
489
- ]
490
- },
491
- "functionReferences": [
492
- "upsertSection()",
493
- "logRevision()"
494
- ]
495
- },
496
- {
497
- "id": "finalize-review-document",
498
- "title": "Finalize Review Document",
499
- "prompt": "Finalize the live review document (no new analysis).\n\n**Branching by Mode:**\n\n**IF QUICK (Trivial):**\n1) Brief Executive Summary (1–2 lines) with 'Recommendation: Approve'.\n2) Light hygiene (≤2 items) on changed files.\n3) Quick Nit sweep.\n4) Update Header: set status=Final.\n5) Append 'Finalized trivial review' to Revision Log.\n\n**IF STANDARD or THOROUGH (Non-trivial):**\n1) Executive Summary (3 positives, 3 risks, final recommendation).\n2) Dedupe and sort Findings (Severity → File → Line).\n3) Ensure sections exist: Patterns, Pattern Deviations, Tests & Docs, Ideas, Nits, MR Comments.\n4) Ensure every Critical/Major finding has a curated MR comment.\n5) Update Header: set status=Final; include final counts and decision.\n6) Append 'Finalized document' to Revision Log.\n\n**For THOROUGH mode additionally:**\n- Include 'Validation Results' section with triple validation gate outcomes\n- Document confidence level based on validation feedback\n- Note any residual concerns from validators\n\nRecap (output.notesMarkdown): Summarize what you finalized — decision, key finding counts by severity, and the doc path.",
500
- "agentRole": "You are a facilitator ensuring the final document is complete, accurate, and consumable.",
501
- "guidance": [
502
- "Write full details to the live doc. Recap (output.notesMarkdown): Summarize what you finalized, key findings, recommendation, and the doc path.",
503
- "Ensure sections exist: 'Executive Summary', 'Decision Criteria', 'Risk Heatmap', 'Proposed Patches'.",
504
- "Executive Summary: 3 positives, 3 risks, decision & rationale.",
505
- "Decision Criteria checklist: Scope fit; Tests adequate; Pattern adherence; Performance; Backwards compat; Security.",
506
- "Risk Heatmap table: Risk | Area | Likelihood | Impact | Mitigation.",
507
- "Dedupe patches and MR comments; ensure every Critical/Major has an MR comment.",
508
- "Group MR comments by file; dedupe similar entries."
509
- ],
510
- "functionReferences": [
511
- "finalizeReviewDocument()",
512
- "upsertSection()",
513
- "discoverHygieneSignals()",
514
- "consolidateHygieneFindings()",
515
- "appendHygieneFinding()",
516
- "logRevision()"
517
- ],
518
- "requireConfirmation": false
519
- },
520
- {
521
- "id": "phase-5-handoff",
522
- "title": "Phase 5: Review Complete - Handoff",
523
- "prompt": "**REVIEW COMPLETE - HANDOFF TO HUMAN REVIEWER**\n\n⚠️ **CRITICAL BOUNDARY: This workflow is for REVIEW assistance only.**\n\nYour job was to:\n- ✅ Understand the MR context and scope\n- ✅ Analyze code at multiple depth levels\n- ✅ Identify issues (Critical, Major, Minor, Nits)\n- ✅ Validate pattern adherence\n- ✅ Assess test coverage and impact\n- ✅ Prepare actionable MR comments\n\nYour job is NOT to:\n- ❌ Make the final merge decision\n- ❌ Approve or reject the MR\n- ❌ Post comments directly (unless instructed)\n- ❌ Merge the code\n\n**HANDOFF SUMMARY:**\n\nProvide a final handoff to the human reviewer:\n\n```markdown\n# MR Review Handoff\n\n## Executive Summary\n- **MR**: [Title/ID]\n- **AI Recommendation**: [Approve/Request Changes/Reject]\n- **Confidence**: [High/Medium/Low based on mode and validation]\n- **Mode Used**: [QUICK/STANDARD/THOROUGH]\n\n## Key Findings\n- **Critical Issues**: [count] - [brief summary]\n- **Major Issues**: [count] - [brief summary]\n- **Minor Issues**: [count]\n- **Nits**: [count]\n\n## Review Document\n[Path to the full review document]\n\n## Ready-to-Post MR Comments\n[Count of prepared comments, ready to copy-paste]\n\n## Areas Needing Human Judgment\n- [Any areas where AI was uncertain]\n- [Trade-offs that need human decision]\n- [Context-dependent decisions]\n\n## Validation Summary (THOROUGH mode only)\n- Review Challenge: [Pass/Concerns]\n- Impact Simulation: [Pass/Concerns]\n- Completeness Check: [Pass/Concerns]\n\n## Next Steps for Human Reviewer\n1. Review the full document at [path]\n2. Verify Critical/Major findings\n3. Post MR comments (or modify as needed)\n4. Make final merge decision\n```\n\n**Before Finishing**: Is the review document complete and ready for the human reviewer to take action?",
524
- "agentRole": "You are completing your review assistance and handing off to the human reviewer with clear documentation.",
525
- "requireConfirmation": false,
526
- "guidance": [
527
- "BOUNDARY: Do NOT make the final merge decision",
528
- "HANDOFF: Create clear summary for human reviewer",
529
- "COMPLETENESS: Ensure all MR comments are ready to post",
530
- "CONFIDENCE: Be honest about areas of uncertainty",
531
- "ACTIONABLE: Human should be able to act immediately on your work"
532
- ],
533
- "functionReferences": [
534
- "logRevision()"
535
- ]
536
- }
537
- ]
538
- }