@massa-ai/cursor-plugin 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/.cursor-plugin/plugin.json +5 -0
  2. package/README.md +87 -0
  3. package/agents/massa-ai-architecture-specialist.md +65 -0
  4. package/agents/massa-ai-audit-specialist.md +81 -0
  5. package/agents/massa-ai-builder.md +67 -0
  6. package/agents/massa-ai-context-curator.md +67 -0
  7. package/agents/massa-ai-documentation-agent.md +65 -0
  8. package/agents/massa-ai-furps-analyst.md +71 -0
  9. package/agents/massa-ai-investigator.md +68 -0
  10. package/agents/massa-ai-mobile-specialist.md +82 -0
  11. package/agents/massa-ai-navigator.md +75 -0
  12. package/agents/massa-ai-plan-critic.md +90 -0
  13. package/agents/massa-ai-planner.md +65 -0
  14. package/agents/massa-ai-requirements-analyst.md +64 -0
  15. package/agents/massa-ai-reviewer.md +66 -0
  16. package/agents/massa-ai-test-engineer.md +66 -0
  17. package/agents/massa-ai-verification-agent.md +65 -0
  18. package/hooks/hooks.json +26 -0
  19. package/hooks/massa-ai-hook +298 -0
  20. package/install.sh +413 -0
  21. package/package.json +30 -0
  22. package/skills/agents/architecture-specialist/SKILL.md +69 -0
  23. package/skills/agents/audit-specialist/SKILL.md +85 -0
  24. package/skills/agents/builder/SKILL.md +71 -0
  25. package/skills/agents/context-curator/SKILL.md +71 -0
  26. package/skills/agents/documentation-agent/SKILL.md +69 -0
  27. package/skills/agents/furps-analyst/SKILL.md +74 -0
  28. package/skills/agents/investigator/SKILL.md +72 -0
  29. package/skills/agents/mobile-specialist/SKILL.md +86 -0
  30. package/skills/agents/navigator/SKILL.md +79 -0
  31. package/skills/agents/plan-critic/SKILL.md +93 -0
  32. package/skills/agents/planner/SKILL.md +69 -0
  33. package/skills/agents/requirements-analyst/SKILL.md +68 -0
  34. package/skills/agents/reviewer/SKILL.md +70 -0
  35. package/skills/agents/test-engineer/SKILL.md +70 -0
  36. package/skills/agents/verification-agent/SKILL.md +69 -0
  37. package/skills/def/SKILL.md +17 -0
  38. package/skills/find/SKILL.md +19 -0
  39. package/skills/graph/SKILL.md +16 -0
  40. package/skills/index/SKILL.md +19 -0
  41. package/skills/map/SKILL.md +24 -0
  42. package/skills/massa-ai/SKILL.md +315 -0
  43. package/skills/massa-ai/personas/README.md +35 -0
  44. package/skills/massa-ai/personas/ai-native-nodejs-cli-architect.md +76 -0
  45. package/skills/massa-ai/personas/catalog.json +157 -0
  46. package/skills/massa-ai/personas/context-skill-harness-engineer-architect.md +74 -0
  47. package/skills/massa-ai/personas/product-manager.md +67 -0
  48. package/skills/massa-ai/personas/senior-mobile-engineer.md +74 -0
  49. package/skills/massa-ai/personas/senior-mobile-qa-automation-engineer.md +75 -0
  50. package/skills/massa-ai/references/adr-authoring.md +189 -0
  51. package/skills/massa-ai/references/agent-orchestration.md +221 -0
  52. package/skills/massa-ai/references/architecture-coupling-lens.md +239 -0
  53. package/skills/massa-ai/references/architecture-deepening-lens.md +136 -0
  54. package/skills/massa-ai/references/architecture-domain-lens.md +186 -0
  55. package/skills/massa-ai/references/architecture-lenses.md +108 -0
  56. package/skills/massa-ai/references/audit-report-io.md +459 -0
  57. package/skills/massa-ai/references/audit-scope.md +103 -0
  58. package/skills/massa-ai/references/code-annotation.md +111 -0
  59. package/skills/massa-ai/references/codebase-investigation.md +96 -0
  60. package/skills/massa-ai/references/context-firewall.md +62 -0
  61. package/skills/massa-ai/references/conversation-feedback.md +104 -0
  62. package/skills/massa-ai/references/debug-diagnosis-loop.md +140 -0
  63. package/skills/massa-ai/references/decision-engine.md +73 -0
  64. package/skills/massa-ai/references/evidence-gate.md +53 -0
  65. package/skills/massa-ai/references/furps/analyst-role.md +49 -0
  66. package/skills/massa-ai/references/furps/checklist.md +92 -0
  67. package/skills/massa-ai/references/furps/intake.md +104 -0
  68. package/skills/massa-ai/references/furps/report-contract.md +140 -0
  69. package/skills/massa-ai/references/hook-enforcement.md +137 -0
  70. package/skills/massa-ai/references/implementation-delivery.md +101 -0
  71. package/skills/massa-ai/references/installation.md +110 -0
  72. package/skills/massa-ai/references/lessons.md +119 -0
  73. package/skills/massa-ai/references/maestro/artifacts-reports.md +69 -0
  74. package/skills/massa-ai/references/maestro/cli-device.md +65 -0
  75. package/skills/massa-ai/references/maestro/cloud.md +67 -0
  76. package/skills/massa-ai/references/maestro/config-env-output.md +76 -0
  77. package/skills/massa-ai/references/maestro/fact-ledger.md +71 -0
  78. package/skills/massa-ai/references/maestro/js-scripting.md +70 -0
  79. package/skills/massa-ai/references/maestro/mcp.md +59 -0
  80. package/skills/massa-ai/references/maestro/patterns.md +96 -0
  81. package/skills/massa-ai/references/maestro/selectors.md +91 -0
  82. package/skills/massa-ai/references/maestro/workspace-execution.md +81 -0
  83. package/skills/massa-ai/references/maestro/yaml-commands.md +203 -0
  84. package/skills/massa-ai/references/maestro.md +47 -0
  85. package/skills/massa-ai/references/mcp-tools.md +296 -0
  86. package/skills/massa-ai/references/memory-policy.md +103 -0
  87. package/skills/massa-ai/references/mobile-context.md +113 -0
  88. package/skills/massa-ai/references/mobile-diagnosis.md +106 -0
  89. package/skills/massa-ai/references/mobile-figma-matcher/ATTRIBUTION.md +5 -0
  90. package/skills/massa-ai/references/mobile-figma-matcher/android-compose.md +13 -0
  91. package/skills/massa-ai/references/mobile-figma-matcher/android-views.md +13 -0
  92. package/skills/massa-ai/references/mobile-figma-matcher/core.md +117 -0
  93. package/skills/massa-ai/references/mobile-figma-matcher/ios-swiftui.md +12 -0
  94. package/skills/massa-ai/references/mobile-figma-matcher/ios-uikit.md +12 -0
  95. package/skills/massa-ai/references/mobile-figma-matcher/kmp-compose-multiplatform.md +14 -0
  96. package/skills/massa-ai/references/mobile-figma-matcher/repository-detection.md +77 -0
  97. package/skills/massa-ai/references/naming-standards.md +47 -0
  98. package/skills/massa-ai/references/pr-task-fix.md +80 -0
  99. package/skills/massa-ai/references/project-context.md +76 -0
  100. package/skills/massa-ai/references/rfc/ATTRIBUTION.md +5 -0
  101. package/skills/massa-ai/references/rfc/discovery-and-sizing.md +120 -0
  102. package/skills/massa-ai/references/rfc/document-contract.md +85 -0
  103. package/skills/massa-ai/references/rfc/quality-and-lifecycle.md +101 -0
  104. package/skills/massa-ai/references/root-cause-scripts.md +97 -0
  105. package/skills/massa-ai/references/spec-driven/artifact-store.md +98 -0
  106. package/skills/massa-ai/references/spec-driven/code-analysis.md +119 -0
  107. package/skills/massa-ai/references/spec-driven/coding-principles.md +80 -0
  108. package/skills/massa-ai/references/spec-driven/context-limits.md +64 -0
  109. package/skills/massa-ai/references/spec-driven/design.md +257 -0
  110. package/skills/massa-ai/references/spec-driven/discuss.md +182 -0
  111. package/skills/massa-ai/references/spec-driven/execute.md +471 -0
  112. package/skills/massa-ai/references/spec-driven/lessons.md +5 -0
  113. package/skills/massa-ai/references/spec-driven/memory.md +214 -0
  114. package/skills/massa-ai/references/spec-driven/specify.md +283 -0
  115. package/skills/massa-ai/references/spec-driven/sub-agents.md +151 -0
  116. package/skills/massa-ai/references/spec-driven/tasks.md +494 -0
  117. package/skills/massa-ai/references/spec-driven/validate.md +397 -0
  118. package/skills/massa-ai/references/subagent-design.md +132 -0
  119. package/skills/massa-ai/references/synapse-policy.md +160 -0
  120. package/skills/massa-ai/references/tdd/calibrated-examples.md +54 -0
  121. package/skills/massa-ai/references/tdd/discovery-and-sizing.md +83 -0
  122. package/skills/massa-ai/references/tdd/document-contract.md +136 -0
  123. package/skills/massa-ai/references/tdd/quality-and-lifecycle.md +83 -0
  124. package/skills/massa-ai/references/the-fool/cognitive-bias-inventory.md +103 -0
  125. package/skills/massa-ai/references/the-fool/dialectic-synthesis.md +170 -0
  126. package/skills/massa-ai/references/the-fool/evidence-audit.md +202 -0
  127. package/skills/massa-ai/references/the-fool/mode-selection-guide.md +113 -0
  128. package/skills/massa-ai/references/the-fool/pre-mortem-analysis.md +200 -0
  129. package/skills/massa-ai/references/the-fool/red-team-adversarial.md +206 -0
  130. package/skills/massa-ai/references/the-fool/socratic-questioning.md +153 -0
  131. package/skills/massa-ai/references/ticket/atlassian-fix.md +130 -0
  132. package/skills/massa-ai/references/ticket/intake-and-sources.md +65 -0
  133. package/skills/massa-ai/references/ticket/templates-and-quality.md +129 -0
  134. package/skills/massa-ai/references/verification-ladder.md +62 -0
  135. package/skills/massa-ai/scripts/lessons.py +590 -0
  136. package/skills/massa-ai/workflows/adr.md +33 -0
  137. package/skills/massa-ai/workflows/architecture/architecture-audit.md +125 -0
  138. package/skills/massa-ai/workflows/architecture/architecture-fix.md +110 -0
  139. package/skills/massa-ai/workflows/bugs/bugs-audit.md +113 -0
  140. package/skills/massa-ai/workflows/bugs/bugs-fix.md +97 -0
  141. package/skills/massa-ai/workflows/code-quality/code-quality-audit.md +154 -0
  142. package/skills/massa-ai/workflows/code-quality/code-quality-fix.md +99 -0
  143. package/skills/massa-ai/workflows/commit.md +61 -0
  144. package/skills/massa-ai/workflows/debug.md +86 -0
  145. package/skills/massa-ai/workflows/design.md +54 -0
  146. package/skills/massa-ai/workflows/exploration.md +119 -0
  147. package/skills/massa-ai/workflows/feature.md +52 -0
  148. package/skills/massa-ai/workflows/general.md +46 -0
  149. package/skills/massa-ai/workflows/implementation/implementation-audit.md +87 -0
  150. package/skills/massa-ai/workflows/implementation/implementation-fix.md +90 -0
  151. package/skills/massa-ai/workflows/long-session.md +44 -0
  152. package/skills/massa-ai/workflows/maestro/maestro-audit.md +56 -0
  153. package/skills/massa-ai/workflows/maestro/maestro-fix.md +74 -0
  154. package/skills/massa-ai/workflows/maestro/maestro.md +68 -0
  155. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-audit.md +68 -0
  156. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-fix.md +74 -0
  157. package/skills/massa-ai/workflows/onboarding.md +23 -0
  158. package/skills/massa-ai/workflows/refactor.md +47 -0
  159. package/skills/massa-ai/workflows/refinement/furps-refinement.md +81 -0
  160. package/skills/massa-ai/workflows/requirements/requirements-audit.md +114 -0
  161. package/skills/massa-ai/workflows/requirements/requirements-fix.md +93 -0
  162. package/skills/massa-ai/workflows/rfc.md +55 -0
  163. package/skills/massa-ai/workflows/security/security-audit.md +113 -0
  164. package/skills/massa-ai/workflows/security/security-fix.md +97 -0
  165. package/skills/massa-ai/workflows/spec-driven.md +217 -0
  166. package/skills/massa-ai/workflows/tdd.md +71 -0
  167. package/skills/massa-ai/workflows/tests/tests-audit.md +114 -0
  168. package/skills/massa-ai/workflows/tests/tests-fix.md +96 -0
  169. package/skills/massa-ai/workflows/the-fool.md +82 -0
  170. package/skills/massa-ai/workflows/ticket.md +42 -0
  171. package/skills/persona-router/SKILL.md +158 -0
  172. package/skills/status/SKILL.md +15 -0
@@ -0,0 +1,221 @@
1
+ # Agent Orchestration
2
+
3
+ Use this reference when a workflow benefits from isolated context, parallel work, or independent verification.
4
+
5
+ Load `references/context-firewall.md` first when the delegated work may involve verbose logs, snapshots, generated reports, external research, or broad source inspection.
6
+
7
+ Load `references/subagent-design.md` only when designing or revising reusable subagent roles, adding a new role to this file, or turning repeated delegated work into a stable role charter. Do not load it for ordinary one-off delegation.
8
+
9
+ ## Principle
10
+
11
+ The main agent is the orchestrator. It owns:
12
+
13
+ - workflow routing
14
+ - memory recall and persistence
15
+ - user questions and trade-off synthesis
16
+ - conversation feedback status updates
17
+ - final Evidence Gate
18
+ - final user-facing report
19
+
20
+ Subagents do bounded work only. Do not delegate everything.
21
+
22
+ ## Delegation Gates
23
+
24
+ Delegate only when all base requirements are true and at least one dispatch trigger is true.
25
+
26
+ Base requirements:
27
+
28
+ - The task is isolated, concrete, and has a clear output contract.
29
+ - The subagent can make progress without full conversation history.
30
+ - The work is parallelizable, context-heavy, or useful as independent verification.
31
+ - The task has deterministic sensors or concrete artifact checks.
32
+ - The write set is disjoint from other active agents when edits are allowed.
33
+
34
+ Dispatch triggers:
35
+
36
+ - User explicitly asks for subagents, delegation, parallel agent work, or independent review.
37
+ - The scope has >=2 independent slices with disjoint write sets.
38
+ - The scope touches >10 files, >500 LOC, or >2 modules.
39
+ - A high/critical audit finding needs independent verification.
40
+ - Verbose context would exceed the context-firewall thresholds and can be summarized independently.
41
+
42
+ Keep local when any are true:
43
+
44
+ - The next main-agent step is blocked on the result.
45
+ - The task needs unresolved user intent.
46
+ - The work is tightly coupled across many files without a clear owner.
47
+ - The subagent would only duplicate main-agent thinking.
48
+ - Platform policy does not permit spawning an agent for this request.
49
+
50
+ ## Plan Challenge Exception
51
+
52
+ Plan Challenge `plan-critic` is a standing policy exception to the normal dispatch triggers after a concrete plan exists. Always attempt a read-only `massa-ai-plan-critic` for both `depth: lite` and `depth: full` when subagent tooling is available and platform policy permits spawning. Normal base requirements still matter for packet quality: the critique must be bounded, read-only, and concrete, but it does not need to satisfy the ordinary dispatch triggers such as file count, module count, or explicit user delegation.
53
+
54
+ For all other roles, preserve the normal delegation gates above.
55
+
56
+ ## Name Resolution
57
+
58
+ Charters live at `skills/agents/<role>/SKILL.md`. Hosts register every charter
59
+ under the prefixed name `massa-ai-<role>` (Claude, Codex, Cursor, OpenCode all
60
+ use that prefix; `scripts/generate-subagent-artifacts.ts` emits it).
61
+
62
+ - **Dispatch under the prefixed host name**, never the bare role name. A bare
63
+ `subagent_type` does not resolve on any supported host.
64
+ - The bare role name is the registry key: use it in memory tags, capability
65
+ packets, and prose.
66
+ - Every dispatch block in a workflow carries the prefixed name inline so
67
+ dispatch never depends on this file being loaded.
68
+
69
+ If the named agent is unavailable for any reason — not registered, plugin not
70
+ installed, spawning forbidden by platform policy, or the host returns an unknown
71
+ `subagent_type` — do not retry under another name and do not invent one. Run the
72
+ delegated scope locally against the same output contract, and report the skipped
73
+ delegation with its reason in the Evidence Gate.
74
+
75
+ ## Roles
76
+
77
+ Use the role names in prompts and memory tags; use the host agent names to
78
+ dispatch.
79
+
80
+ Before adding a new reusable role, load `references/subagent-design.md` and write a bounded role charter. For one-off tasks, use an existing role plus the prompt contract below instead of inventing a new role.
81
+
82
+ | Role | Host agent name | Use For | Read/Write | Charter |
83
+ |---|---|---|---|---|
84
+ | `investigator` | `massa-ai-investigator` | Trace code paths, find entry points, summarize current behavior | read-only | `skills/agents/investigator/SKILL.md` |
85
+ | `navigator` | `massa-ai-navigator` | Answer "where is X / who calls Y" from the massa-ai index before reading files | read-only | `skills/agents/navigator/SKILL.md` |
86
+ | `implementer` → `builder` | `massa-ai-builder` | Execute one atomic task with a disjoint write set | write | `skills/agents/builder/SKILL.md` |
87
+ | `verifier` → `verification-agent` | `massa-ai-verification-agent` | Independently run sensors and inspect whether claims hold | read-only | `skills/agents/verification-agent/SKILL.md` |
88
+ | `domain-mapper` → `architecture-specialist` | `massa-ai-architecture-specialist` | Identify subdomains, bounded contexts, language conflicts, cohesion | read-only | `skills/agents/architecture-specialist/SKILL.md` (lens: `domain`) |
89
+ | `coupling-auditor` → `architecture-specialist` | `massa-ai-architecture-specialist` | Analyze strength, distance, volatility, and risky dependencies | read-only | `skills/agents/architecture-specialist/SKILL.md` (lens: `coupling`) |
90
+ | `deepening-architect` → `architecture-specialist` | `massa-ai-architecture-specialist` | Find shallow modules and deepening opportunities | read-only | `skills/agents/architecture-specialist/SKILL.md` (lens: `deepening`) |
91
+ | `audit-specialist` | `massa-ai-audit-specialist` | Findings-only audit through one selected `lens` | read-only | `skills/agents/audit-specialist/SKILL.md` |
92
+ | `plan-critic` | `massa-ai-plan-critic` | Stress-test a constructed plan using The Fool mode and return bounded critique | read-only | `skills/agents/plan-critic/SKILL.md` |
93
+ | `furps-analyst` | `massa-ai-furps-analyst` | Analyze one FURPS+ dimension of a PRD/ADR against the checklist and return structured findings | read-only | `skills/agents/furps-analyst/SKILL.md` |
94
+
95
+ The remaining charters — `planner`, `reviewer`, `context-curator`,
96
+ `requirements-analyst`, `test-engineer`, `documentation-agent`,
97
+ `mobile-specialist` — follow the same `massa-ai-<role>` convention and are
98
+ listed in the Agent Table of `skills/AGENTS.md`.
99
+
100
+ **Role mapping:** `investigator`→`investigator` (identical); `implementer`→`builder` (renamed); `verifier`→`verification-agent` (renamed, centralizes Verification Ladder); `domain-mapper`+`coupling-auditor`+`deepening-architect`→`architecture-specialist` (three roles folded into one specialist; the `lens` input field selects the sub-mode). Workflows dispatch the new agent names via named dispatch blocks; the old role names above are kept for traceability only.
101
+
102
+ ## Capability Packet
103
+
104
+ When dispatching a subagent, send a compact capability packet rather than a loose instruction. Include:
105
+
106
+ - role and purpose for this workflow
107
+ - trigger: why delegation is justified now
108
+ - exact scope: files, modules, diff, report finding, task IDs, or artifact
109
+ - permissions: read-only or write with disjoint ownership
110
+ - inputs: recalled facts, source pointers, constraints, and exclusions
111
+ - sensors: expected commands or concrete checks
112
+ - output: the exact output contract
113
+ - firewall: raw logs, diffs, snapshots, reports, or research that must be summarized
114
+ - memory boundary: whether the subagent may suggest memories and who persists them
115
+ - exact next step: what the main agent should do with the result
116
+
117
+ ## Prompt Contract
118
+
119
+ Every delegated task must include:
120
+
121
+ - exact `projectId`
122
+ - exact parent `workflowSessionId` or child session tag
123
+ - workflow name
124
+ - role name
125
+ - scope and file/module ownership
126
+ - facts already known
127
+ - what to avoid redoing
128
+ - allowed tools or mutation level
129
+ - deterministic validation expected
130
+ - context-firewall limit: what raw output must not be returned
131
+ - skipped-check policy and how to report unavailable sensors
132
+ - memory boundary: whether to suggest memories only or write none
133
+ - exact output format
134
+
135
+ ## Output Contract
136
+
137
+ Every subagent returns:
138
+
139
+ - Status: `Complete`, `Blocked`, or `Partial`
140
+ - Scope checked or files changed
141
+ - Evidence: command result, static finding, source location, or artifact inspected
142
+ - Findings or implementation summary
143
+ - Risks and skipped checks
144
+ - Exact next step
145
+
146
+ Subagents must summarize verbose research, logs, snapshots, diffs, search output,
147
+ and transcripts. The main agent should receive only evidence, findings, risk,
148
+ skipped checks, memory suggestions when allowed, and the next step, not raw dumps.
149
+
150
+ ## Conversation Feedback
151
+
152
+ Use `references/conversation-feedback.md` when subagent lifecycle visibility would help the user understand what is running. Keep status updates to 1-2 human-readable lines.
153
+
154
+ Use these labels for delegated work:
155
+
156
+ - `Agent Started` when a role is launched with scope and permission mode.
157
+ - `Agent Running` when waiting on a long-running role or reporting its current bounded task.
158
+ - `Agent Done` when the role returns usable evidence, findings, implementation, or verification.
159
+ - `Agent Blocked` when the role cannot complete its assigned scope.
160
+
161
+ Do not expose raw subagent prompts, raw logs, private reasoning, or full output dumps in feedback lines.
162
+
163
+ Example:
164
+
165
+ ```md
166
+ 🤖 [Agent Started] Verifier is checking the docs-only change set. Scope: massa-ai references and README.
167
+ 🤖 [Agent Done] Verifier found no stale references. Skipped checks: none.
168
+ ```
169
+
170
+ ## Plan-Critic Contract
171
+
172
+ Dispatch `massa-ai-plan-critic` only after a concrete plan exists. Dispatch it with the capability packet above and the standard output contract. The subagent receives the plan, scope, constraints, compact recalled facts/evidence, selected depth, selected The Fool mode only for full gates, known risks, verification recipe, parent identifiers, and context-firewall limits. It never receives full conversation context.
173
+
174
+ For `depth: lite`, the packet uses the low-risk checklist and does not include The Fool mode references. It returns:
175
+
176
+ - strongest low-risk challenges
177
+ - assumption most likely to fail
178
+ - deterministic check that would falsify success
179
+ - high-risk or broad-scope trigger found, if any
180
+ - `escalate_to_full: true|false`
181
+ - escalation reason
182
+
183
+ For `depth: full`, or after lite escalation, the main agent selects the mode, loads the relevant The Fool references, and dispatches a full packet. It returns:
184
+
185
+ - selected mode
186
+ - steelmanned thesis
187
+ - 3-5 strongest challenges
188
+ - severity: `critical`, `high`, `medium`, or `low`
189
+ - affected plan section
190
+ - evidence gap or assumption at risk
191
+ - required revision or accepted-risk framing
192
+ - confidence impact
193
+ - exact next step
194
+
195
+ The main agent owns final synthesis and applies the canonical Plan Challenge
196
+ Policy: the `<!-- massa-ai:bootstrap -->` block installed as `<host>/AGENTS.md`,
197
+ whose single source is `skills/AGENTS.md` in the product repo.
198
+
199
+ ## Memory Rules
200
+
201
+ - Main agent persists durable conclusions after synthesis.
202
+ - Subagents may suggest memory content but should not create broad project memories unless explicitly assigned.
203
+ - Use tags such as `agent:verifier` or `agent:domain-mapper` only when they improve retrieval.
204
+ - Do not persist one-off subagent chatter.
205
+
206
+ ## Synapse Isolation
207
+
208
+ For delegated tasks that expect repeated searches:
209
+
210
+ - create one ephemeral Synapse session per subagent
211
+ - pass only that agent's `synapseSessionId` to its `search` calls
212
+ - keep parent/child `workflowSessionId` values in memory tags and output packets
213
+ - never share one Synapse session across concurrent agents
214
+ - allow stateless fallback when session creation or adapter translation fails
215
+
216
+ ## Guardrails
217
+
218
+ - No self-evaluation: claims need deterministic sensors or concrete source evidence.
219
+ - No hidden scope expansion: subagents must not improve adjacent code.
220
+ - No context dragging: send only task-specific source pointers and constraints, and receive compact summaries only.
221
+ - No conflicting writes: parallel implementers need disjoint files or worktrees.
@@ -0,0 +1,239 @@
1
+ # Architecture Coupling Lens
2
+
3
+ Use this detail reference when an architecture audit or execution task needs dependency health, dependency direction, integration cost, or coupling reduction.
4
+
5
+ ## Contents
6
+
7
+ - Core Model
8
+ - Dependency Graph
9
+ - Strength Levels
10
+ - Symmetric Coupling
11
+ - Connascence Ladder
12
+ - Distance Levels
13
+ - Volatility Signals
14
+ - Balance Table
15
+ - Quantitative Anchors
16
+ - Pattern Strength Action Lookup
17
+ - Static Leads
18
+ - Positive Patterns
19
+ - Fix Direction
20
+
21
+ ## Core Model
22
+
23
+ Analyze coupling through three dimensions:
24
+
25
+ - Strength: what knowledge or behavior is shared
26
+ - Distance: how far apart the coupled modules are
27
+ - Volatility: how likely either side is to change
28
+
29
+ High strength is not automatically bad. Strong coupling can be cohesive when modules are close and change together. Risk rises when strong coupling crosses distance and volatile business behavior.
30
+
31
+ ## Dependency Graph
32
+
33
+ Map directed dependencies:
34
+
35
+ ```text
36
+ A -> B means A depends on B.
37
+ B is upstream and exposes knowledge to A.
38
+ A is downstream and absorbs upstream changes.
39
+ ```
40
+
41
+ For each relevant edge, record:
42
+
43
+ - caller/downstream module
44
+ - callee/upstream module
45
+ - dependency kind: import, DI, HTTP/gRPC, queue/event, shared DB, generated client, shared schema, test fixture
46
+ - exported surface or contract used
47
+ - whether the dependency crosses package, bounded context, service, team, or external-system distance
48
+
49
+ ## Strength Levels
50
+
51
+ Classify by strongest evidence:
52
+
53
+ - Intrusive: downstream reads internals not designed for integration, such as private fields, another service DB, internal config/file shape, reflection, monkey patching, or undocumented generated artifacts.
54
+ - Functional: modules must coordinate behavior, order, transaction, duplicated business rule, deployment, or state transitions.
55
+ - Model: upstream exposes internal domain model, enum meanings, field names, value semantics, tuple positions, or persistence schema as integration surface.
56
+ - Contract: upstream exposes integration-specific DTO, event, schema, facade, published language, or versioned protocol that hides internals.
57
+
58
+ ### Symmetric Coupling
59
+
60
+ A sub-degree of Functional coupling with no import edge: two modules
61
+ independently encode the same business rule, so changing the rule requires
62
+ editing both. It is the defect static import analysis most often misses.
63
+
64
+ Detection signals:
65
+
66
+ - the same predicate, threshold, mapping, or validation duplicated across modules
67
+ - comments like "update X when changing Y" or "keep in sync with"
68
+ - two validators, formatters, or mappers that must agree but share no type
69
+ - a bug fixed in one place that later recurs in the other
70
+
71
+ Treat as Functional strength regardless of distance. The fix is to extract the
72
+ shared rule to one owned location and reference it, not to add an import edge.
73
+
74
+ ## Connascence Ladder
75
+
76
+ Map the shared knowledge to a rung, weakest (most tolerable) to strongest.
77
+ Lower rungs are cheaper to change; higher rungs amplify distance and volatility.
78
+
79
+ | Rung | Connascence | Meaning |
80
+ |---|---|---|
81
+ | 1 | Name | depends only on an identifier; a rename propagates |
82
+ | 2 | Type | depends on a type or shape |
83
+ | 3 | Meaning | depends on an agreed value, convention, or format (magic numbers, date formats) |
84
+ | 4 | Position | depends on argument, field, or tuple order |
85
+ | 5 | Algorithm | depends on call order, timing, transaction, or duplicated logic |
86
+
87
+ Rungs 4-5 map to Functional/Intrusive strength; rungs 1-2 map to Contract
88
+ strength. Use the rung to justify the Fix Direction: collapse higher rungs into
89
+ named contracts or shared owned logic before widening distance.
90
+
91
+ ## Distance Levels
92
+
93
+ Use the closest common ownership point:
94
+
95
+ - same function or class
96
+ - same package or vertical slice
97
+ - same module/library
98
+ - different app/service
99
+ - external system or different team
100
+
101
+ Increase distance when deployment, ownership, or team coordination is separate.
102
+
103
+ ### Distance Scorecard
104
+
105
+ | Layer pair | Distance |
106
+ |---|---|
107
+ | same function or class | 0 |
108
+ | same package or vertical slice | 1 |
109
+ | same module or library | 2 |
110
+ | different app or service | 3 |
111
+ | external system or different team | 4 |
112
+
113
+ Conway's-Law bump: when the two sides are owned by different teams (even inside
114
+ one service), add 1 to the distance — coordination cost makes the coupling
115
+ behave like the next distance tier.
116
+
117
+ ## Volatility Signals
118
+
119
+ Prefer real evidence:
120
+
121
+ - Core or evolving business subdomain
122
+ - recent commits or co-change patterns
123
+ - TODO/FIXME clusters around behavior
124
+ - multiple API versions or migration code
125
+ - fragile tests, recurring regressions, or repeated audit findings
126
+ - user-provided roadmap pressure
127
+
128
+ If history is unavailable, mark volatility as inferred and lower confidence.
129
+
130
+ Turn "recent commits" into measured co-change (volatility by file):
131
+
132
+ ```bash
133
+ git log --since='3 months ago' --name-only --pretty=format: \
134
+ | grep -v '^$' | sort | uniq -c | sort -rn | head -30
135
+ ```
136
+
137
+ Co-change is evidence: files that move together repeatedly are coupled even
138
+ with no import edge. Two files in the top co-change set with no declared
139
+ dependency are an undeclared functional-coupling finding.
140
+
141
+ Override edge case: a Generic subdomain (auth, logging, storage plumbing) is
142
+ normally Low volatility. If that generic component is mid-migration or has
143
+ multiple in-repo versions, override it to High volatility for the duration —
144
+ generic-by-default never overrides measured churn.
145
+
146
+ ## Balance Table
147
+
148
+ Use this diagnosis table. The Severity column is the reproducible priority:
149
+ critical edges first, watch edges only if unstable, the rest are healthy or
150
+ low-cost.
151
+
152
+ | Strength | Distance | Volatility | Severity | Diagnosis |
153
+ |---|---|---|---|---|
154
+ | High | High | High | 🔴 Critical | Costly global change pressure; prioritize |
155
+ | High | High | Low | 🟡 Watch | Often acceptable if stable and documented |
156
+ | High | Low | High | 🟢 Cohesive | Usually cohesive: keep close or merge |
157
+ | High | Low | Low | 🟢 Fine | Usually fine |
158
+ | Low | High | High | 🟢 Healthy | Healthy loose coupling |
159
+ | Low | High | Low | 🟢 Healthy | Healthy or low-cost |
160
+ | Low | Low | High | 🟠 Inspect | Local complexity; inspect cohesion |
161
+ | Low | Low | Low | 🟢 Low | Low priority unless noisy |
162
+
163
+ ## Quantitative Anchors
164
+
165
+ Binary each dimension before reading the Balance Table so two auditors reach the
166
+ same cell.
167
+
168
+ | Dimension | 1 (High) | 0 (Low) |
169
+ |---|---|---|
170
+ | Strength (S) | Intrusive, Functional, or Model coupling | Contract coupling |
171
+ | Distance (D) | crosses service, team, or external boundary | same module or package |
172
+ | Volatility (V) | core/evolving subdomain or recent co-change | stable or generic |
173
+
174
+ Then:
175
+
176
+ ```text
177
+ BALANCE = (S XOR D) OR (NOT V)
178
+ MAINTENANCE_EFFORT = S * D * V
179
+ ```
180
+
181
+ - `BALANCE = 1` (balanced): the edge is acceptable — strength is local (S=0),
182
+ distance is local (D=0), or the edge is stable (V=0).
183
+ - `BALANCE = 0` (unbalanced): strong, distant, AND volatile — the highest-cost
184
+ edge; prioritize it.
185
+ - `MAINTENANCE_EFFORT` ranks unbalanced edges: it is 1 only in the single
186
+ strong+distant+volatile cell. Use it to order fixes when several edges tie.
187
+
188
+ These are scoring aids, not proof. A `BALANCE = 1` edge still warrants a finding
189
+ when concrete evidence shows real change friction.
190
+
191
+ ## Pattern Strength Action Lookup
192
+
193
+ Classify a concrete pattern, then act.
194
+
195
+ | # | Pattern | Strength | Action |
196
+ |---|---|---|---|
197
+ | 1 | downstream reads another module's private fields or internals | Intrusive | seal behind a contract; remove direct access |
198
+ | 2 | downstream queries another context's database | Intrusive | expose an owned API or anti-corruption layer |
199
+ | 3 | duplicated business predicate or rule in two modules | Functional (symmetric) | extract to one owned location |
200
+ | 4 | mandatory call ordering spread across callers | Functional | hide ordering behind one interface |
201
+ | 5 | shared transaction or state transitions across modules | Functional | co-locate or publish an explicit contract |
202
+ | 6 | upstream exposes persistence schema or enum as integration surface | Model | publish a versioned DTO or language |
203
+ | 7 | DTO mirrors a full domain object | Model | project to a use-case-specific DTO |
204
+ | 8 | dependency on field name, value, or tuple position | Model | wrap in a typed contract |
205
+ | 9 | versioned DTO, event, or schema hides internals | Contract | accept; document as stable |
206
+ | 10 | stable facade or anti-corruption layer translating vocabulary | Contract | accept; record as intentional |
207
+
208
+ ## Static Leads
209
+
210
+ Look for:
211
+
212
+ - direct reads of another module's database, config, or internal files
213
+ - imports from `internal`, `private`, generated, or persistence model paths across contexts
214
+ - duplicate business predicates, thresholds, mappings, or validation
215
+ - comments like "update X when changing Y"
216
+ - DTOs that mirror full domain or persistence objects
217
+ - mandatory call ordering spread across callers
218
+ - cycles, bidirectional imports, or dependency inversion breaks
219
+ - tests that require constructing far-away internals to exercise local behavior
220
+
221
+ ## Positive Patterns
222
+
223
+ Call out positive evidence when useful:
224
+
225
+ - use-case-specific DTOs or events
226
+ - versioned public contracts
227
+ - anti-corruption layers translating vocabulary
228
+ - stable facade that hides internal model churn
229
+ - dependency direction from volatile policy toward stable abstraction, not from stable core toward volatile detail
230
+
231
+ ## Fix Direction
232
+
233
+ Reduce strength before increasing distance:
234
+
235
+ - replace intrusive/model coupling with explicit contracts
236
+ - move tightly coupled volatile modules closer when they change together
237
+ - extract shared duplicated rule only when it is a real domain rule, not trivial repetition
238
+ - document accepted strong-stable integration instead of refactoring it
239
+ - avoid introducing ports/adapters unless there is real variation, test substitution, external dependency, or direction pressure
@@ -0,0 +1,136 @@
1
+ # Architecture Deepening Lens
2
+
3
+ Use this detail reference when an architecture audit or execution task needs module depth, seams, adapters, testability, locality, or AI-navigability analysis.
4
+
5
+ ## Contents
6
+
7
+ - Vocabulary
8
+ - Deepening Signals
9
+ - Deletion Test
10
+ - Dependency Categories
11
+ - Recommendation Template
12
+ - Interface Design Method
13
+ - Rejected Framings
14
+ - Seam Discipline
15
+ - Test Surface
16
+ - Fix Direction
17
+
18
+ ## Vocabulary
19
+
20
+ Use these terms exactly:
21
+
22
+ - Module: anything with an interface and an implementation.
23
+ - Interface: everything a caller must know, including types, invariants, ordering, errors, configuration, and performance.
24
+ - Implementation: code inside the module.
25
+ - Seam: where an interface lives and behavior can be varied without editing callers.
26
+ - Adapter: concrete thing satisfying an interface at a seam.
27
+ - Depth: leverage at the interface.
28
+ - Leverage: capability callers get per unit of interface learned.
29
+ - Locality: change, bugs, knowledge, and verification concentrated in one place.
30
+
31
+ Avoid using `boundary` for module seams; reserve bounded context language for the domain lens.
32
+
33
+ ## Deepening Signals
34
+
35
+ Flag candidates when evidence shows:
36
+
37
+ - module interface is nearly as complex as its implementation
38
+ - pass-through wrappers or one-use helpers add navigation cost
39
+ - one concept is split across many files without leverage
40
+ - callers must know ordering, invariants, config, or error modes that should be hidden
41
+ - tests reach past the interface into internals because the interface is the wrong shape
42
+ - extracted pure functions improve unit-test access but lose locality for real bugs
43
+ - seams exist only for hypothetical future adapters
44
+
45
+ ## Deletion Test
46
+
47
+ Ask what happens if the module is deleted:
48
+
49
+ - If complexity disappears, the module was likely shallow.
50
+ - If complexity spreads across callers, the module was probably earning its keep.
51
+ - If behavior becomes harder to verify through one surface, the module likely has useful depth.
52
+
53
+ Use this as evidence, not as a mechanical rule.
54
+
55
+ ## Dependency Categories
56
+
57
+ Classify dependencies before recommending seams:
58
+
59
+ - In-process: pure computation or in-memory state. Usually deepen by merging and testing through the new interface.
60
+ - Local-substitutable: dependency has a local test stand-in. Keep seam internal when possible and test the deep module with the stand-in.
61
+ - Remote but owned: own service across network. Define a port only when it keeps domain logic local and production/test adapters are both real.
62
+ - True external: third-party dependency. Inject a port and use mock/fake adapters for tests when behavior cannot be run locally.
63
+
64
+ ### Recommendation Template
65
+
66
+ For each dependency, state: Category → recommended seam → stand-in used in tests.
67
+
68
+ | Category | Recommended seam | Stand-in example |
69
+ |---|---|---|
70
+ | In-process | deepen by merging | none — test through the new interface |
71
+ | Local-substitutable | keep seam internal | in-memory fake |
72
+ | Remote but owned | port only if domain stays local | owned-service test adapter |
73
+ | True external | inject a port | PGLite (database), Stripe test mode (payment) |
74
+
75
+ A stand-in is required evidence before introducing a port: "inject a port for
76
+ Stripe, with the Stripe test-mode adapter as the production-shape stand-in" —
77
+ not "add a port because it is cleaner."
78
+
79
+ ## Interface Design Method
80
+
81
+ When a deepening candidate has two or more viable interface shapes, do not pick
82
+ one by instinct. Design it twice: draft two parallel implementations (two
83
+ sub-agents, or two sides authored yourself), each behind a different interface
84
+ against the same caller need, then choose by leverage and locality.
85
+
86
+ Four canned design constraints force distinct shapes:
87
+
88
+ 1. Minimal surface: hide every field and ordering the caller does not name.
89
+ 2. Batchable: one call serves many items, not one call per item.
90
+ 3. Policy-free: the interface states what, not how; no strategy leaks out.
91
+ 4. Substitutable: a second adapter can satisfy it without caller edits.
92
+
93
+ Load this method from `architecture-fix.md` or `refactor.md` only when a
94
+ candidate has >= 2 viable interface shapes; otherwise deepen directly.
95
+
96
+ ## Rejected Framings
97
+
98
+ Avoid these misreadings of depth; record the rejection so it is not re-litigated:
99
+
100
+ - Depth is NOT a lines-of-code ratio. A deep module can be tiny; a shallow
101
+ wrapper can be long. Padding an implementation to raise a "depth" metric is
102
+ exactly the anti-pattern this lens exists to find.
103
+ - Interface is NOT a language keyword (`interface`, `protocol`, `trait`). It is
104
+ everything a caller must know — types, invariants, ordering, errors.
105
+ - Seam is NOT a class boundary. Reserve `seam` for where behavior can vary
106
+ without editing callers; reserve bounded-context language for the domain lens.
107
+
108
+ ## Seam Discipline
109
+
110
+ - One adapter means a hypothetical seam. Two adapters means a real seam.
111
+ - Production plus test adapter can justify a seam when the dependency is remote or external.
112
+ - Internal seams can exist inside the implementation without becoming part of the module interface.
113
+ - Do not expose internal seams just because tests use them.
114
+ - Do not introduce ports/adapters to decorate one local concrete call.
115
+
116
+ ## Test Surface
117
+
118
+ The interface is the test surface:
119
+
120
+ - prefer behavior tests through the module interface
121
+ - delete or replace shallow-module tests once deep-module tests cover observable behavior
122
+ - tests should survive implementation refactors
123
+ - if tests must change for implementation-only movement, they are probably testing past the interface
124
+
125
+ ## Fix Direction
126
+
127
+ Prefer:
128
+
129
+ - delete shallow pass-through modules
130
+ - inline one-use abstractions
131
+ - merge split concepts when locality improves
132
+ - deepen a useful module by hiding invariants and ordering
133
+ - move validation and transformation behind the interface when callers should not know it
134
+ - add a seam only where variation, dependency direction, external I/O, or test substitution is real
135
+
136
+ Avoid broad rewrites, VSA migrations, or new service boundaries unless audit evidence shows current module shape blocks change or verification.