@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,160 @@
1
+ # Synapse Policy
2
+
3
+ Load this reference when a task is expected to issue more than one
4
+ `search`, when parallel agents need isolated retrieval context, or when
5
+ Synapse compatibility/fallback behavior matters.
6
+
7
+ ## Two Session IDs
8
+
9
+ - `workflowSessionId`: stable, durable task identity used by recall, remember,
10
+ tags, reports, handoffs, and continuation packages.
11
+ - `synapseSessionId`: ephemeral ID returned by `synapse_session`; pass it
12
+ only as `search.sessionId`.
13
+
14
+ Never persist `synapseSessionId` as the task's durable session identity. A
15
+ resumed handoff reuses `workflowSessionId` and opens a fresh Synapse session.
16
+
17
+ ## Activation
18
+
19
+ - One-shot lookup: skip Synapse.
20
+ - Planned related `search` calls >= 2: create a Synapse session before the first search.
21
+ - Parallel subagents: each agent gets its own Synapse session while retaining
22
+ the parent/child `workflowSessionId` tags.
23
+ - Major focus shift: update task context through REST when available; otherwise
24
+ create a fresh Synapse session and let the prior session expire.
25
+
26
+ Default search budget inside a Synapse session:
27
+
28
+ - Summary discovery: `responseMode="summary"`, `maxResults=10`.
29
+ - Targeted deep reads: `responseMode="enriched"`, `maxResults=3`.
30
+ - Expanded deep reads: `maxResults=5` only when 4-5 exact files, symbols, or report finding IDs are already named.
31
+ - Do not use Synapse for a single recall, project map, exact file read, or one symbol lookup.
32
+
33
+ Server-side bounds that constrain the budget:
34
+
35
+ - Working-memory buffer holds **20 entries** by default. Priming or prefetching
36
+ more than that evicts the earlier ones — seed the few memories that matter,
37
+ not a whole recall page.
38
+ - Sessions expire after **1h**, sliding forward on every `synapse_get` or
39
+ recorded access.
40
+
41
+ Config knobs (env, read by the server, not by the agent):
42
+
43
+ | Env var | Default | Effect |
44
+ |---|---|---|
45
+ | `SYNAPSE_ENABLED` | `true` | Master kill switch; `false` bypasses the whole pipeline, and `search` behaves statelessly even when a `sessionId` is passed. |
46
+ | `SYNAPSE_ATTENTION_ENABLED` | `false` | Multi-signal attention re-ranker. **Off by default** — do not attribute re-ranking to Synapse unless it is on. |
47
+ | `LOG_LEVEL` | `info` | `debug` emits one pipeline log line per query (see Reading Pipeline Output). |
48
+
49
+ ## MCP-First Lifecycle
50
+
51
+ 1. Call `synapse_session` with explicit `agentId`, `workspaceId`,
52
+ one-sentence `taskContext`, and `ttlMs`. Omit `sessionId` so the server
53
+ generates a collision-free ID. Keep `agentId` stable across the whole task —
54
+ agent affinity needs one identity.
55
+ 2. Call `recall` using `workflowSessionId` and project/entity context.
56
+ 3. Open a task envelope with `synapse_task_begin` (`id` = the session id, plus a
57
+ one-sentence `taskContext`) before the task's searches.
58
+ 4. Prime the buffer when the adapter supports it, within the 20-entry bound.
59
+ 5. Pass the returned `synapseSessionId` as `sessionId` on every related
60
+ `search` call.
61
+ 6. Call `synapse_prefetch` right after deciding to open a specific file, so the
62
+ buffer is warm before the next search.
63
+ 7. After consuming a result, record its `memoryId` through the verified access
64
+ route when available.
65
+ 8. Close the task envelope with `synapse_task_end` when the task's work is done.
66
+ Update `taskContext` only when the *kind* of work changes, never per query.
67
+
68
+ Verified v2.0.2 adapter warnings:
69
+
70
+ - MCP prime exposes `{ id, results }`, but the installed adapter forwarded that
71
+ body unchanged to REST, which requires `{ entries }`, and returned HTTP 422.
72
+ - MCP access returned `Session not found or expired` for a live session that
73
+ REST could inspect and update; direct REST access with the same `memoryId`
74
+ succeeded.
75
+
76
+ Treat MCP prime and access as compatibility-sensitive. Do not retry the same
77
+ failing call; use REST or skip the optional step. Always use `memoryId` for
78
+ access recording. File-path-only access is unsupported until a runtime probe
79
+ proves adapter translation.
80
+
81
+ ## REST Lifecycle Fallback
82
+
83
+ Use REST only when `MASSA_AI_API_URL` is available and the operation is absent or
84
+ broken in MCP. Default local URL is `http://localhost:3333`.
85
+
86
+ If `MASSA_AI_API_KEY` is configured, send it as `x-api-key`. Never print, persist,
87
+ or place the key in memory, reports, status updates, command transcripts, or
88
+ committed files.
89
+
90
+ REST-only lifecycle operations:
91
+
92
+ | Operation | Route | Use |
93
+ |---|---|---|
94
+ | Inspect | `GET /api/v1/synapse/session/:id` | Confirm state or diagnose expiry. |
95
+ | Update focus | `PATCH /api/v1/synapse/session/:id` | Replace task context after a major focus shift. |
96
+ | Prime | `POST /api/v1/synapse/session/:id/prime` | Send `{ "entries": [...] }` when MCP priming fails. |
97
+ | Prefetch | `POST /api/v1/synapse/session/:id/prefetch` | Warm context for a file that will be investigated. |
98
+ | Close | `DELETE /api/v1/synapse/session/:id` | Free resources after completion when practical. |
99
+
100
+ REST prime entries require `id` and `content`; `score` and `metadata` are
101
+ optional. REST prefetch requires `filePath` and may include `symbols`, `chains`,
102
+ `maxResults`, `minImportance`, or `entries`.
103
+
104
+ ## Reading Pipeline Output
105
+
106
+ With `LOG_LEVEL=debug`, the server emits one structured line per Synapse-scoped
107
+ query. Use it to decide whether Synapse is helping or whether the query needs
108
+ refining — not as evidence about the codebase.
109
+
110
+ ```json
111
+ {
112
+ "before": 16, "after": 14,
113
+ "queryClass": "specific",
114
+ "intent": "decision",
115
+ "appliedFilters": ["buffer-hit","pre-gate","attention","chain","diversity","temporal","confidence-gate","spectrum","buffer-put"],
116
+ "flags": { "lowConfidence": false, "noStrongMatch": false, "definitiveMatch": true,
117
+ "spread": 0.31, "mean": 0.78, "confidence": 0.24 }
118
+ }
119
+ ```
120
+
121
+ | Signal | Reading |
122
+ |---|---|
123
+ | `appliedFilters` has `buffer-hit` | Buffer had warm results — priming/prefetch is paying off. |
124
+ | `appliedFilters` has `pre-gate` | Early raw-score filter cut noise before attention. |
125
+ | `appliedFilters` lacks `attention` | `SYNAPSE_ATTENTION_ENABLED=false`; task alignment did not re-rank. |
126
+ | `queryClass = "specific"` | Symbol-like query; confidence gate at 0.55. |
127
+ | `queryClass = "focused"` | Tech terms; gate at 0.40. |
128
+ | `queryClass = "broad"` | Exploratory; gate at 0.25. |
129
+ | `intent != "general"` | Chain inhibition modulated results by memory type. |
130
+ | `flags.definitiveMatch = true` | One dominant hit; the top result is trustworthy. |
131
+ | `flags.lowConfidence = true` | Results clustered — the query is ambiguous. Refine it; this is not a failure. |
132
+ | `flags.noStrongMatch = true` | Nothing crossed the threshold — the answer is probably not in the corpus. Fall back to source reads. |
133
+
134
+ ## Failure Policy
135
+
136
+ - Session creation fails: continue with stateless massa-ai search.
137
+ - Priming or access fails: use verified REST exactly once after recording the MCP failure mode; if REST fails or is unavailable, continue without priming/access.
138
+ - Search rejects `sessionId`: retry once without it and report the divergence.
139
+ - REST unavailable or unauthorized: stay MCP-only and let TTL expire.
140
+ - Session expires or disappears after server restart: create a new session; do
141
+ not reuse the old ID. Synapse state is ephemeral and process-local.
142
+ - Never reset or reindex a project to repair a Synapse-only failure.
143
+
144
+ ## Anti-Patterns
145
+
146
+ - Reusing one session across unrelated tasks: task-alignment, agent-affinity,
147
+ and buffer signals drift into noise. Open a fresh session per task.
148
+ - Updating `taskContext` after every query — the signal stops meaning anything.
149
+ - Priming hundreds of entries against a 20-entry buffer.
150
+ - Sending a different `agentId` per call.
151
+ - Passing `synapseSessionId` on a one-shot stateless lookup.
152
+ - Treating `flags.lowConfidence` as "search failed".
153
+ - Persisting `synapseSessionId` as the task's durable session identity.
154
+
155
+ ## Completion
156
+
157
+ Close the REST session when the endpoint is available and cleanup is cheap.
158
+ Otherwise rely on the explicit TTL. Report Synapse failures only when they
159
+ changed retrieval confidence, skipped expected behavior, or exposed a contract
160
+ regression.
@@ -0,0 +1,54 @@
1
+ # Calibrated Examples
2
+
3
+ The values below are starting reference values, not requirements. They are calibration anchors, not mandates. Treat every number as a starting-point reference to be confirmed against the project's own SLOs, load profile, and regulatory scope; override per project and record the override in the TDD. None of these tables restore a prescriptive count schema or a fixed section-count mandate.
4
+
5
+ Load this reference only when the TDD's conditional concerns (rollback, rollout, latency, compliance) apply and the team needs a concrete starting point. It complements `references/tdd/document-contract.md` (which owns the Conditional Concerns trigger table) by giving example budgets; it does not replace project-verified SLOs or legal obligations.
6
+
7
+ ## Rollback-Trigger Table
8
+
9
+ Calibration anchors, not mandates. Each row is a starting-point signal that typically warrants a rollback (or the documented forward-recovery equivalent); confirm thresholds against project telemetry before relying on them.
10
+
11
+ | Signal | Starting reference threshold | Action |
12
+ |---|---|---|
13
+ | Error-rate spike | error rate exceeds 2x the pre-rollout baseline for 5 consecutive minutes | rollback (or documented forward-recovery) |
14
+ | SLO burn | error-budget burn rate > 10x the normal burn rate over the rollout window | rollback (or documented forward-recovery) |
15
+ | Data-corruption signal | any confirmed write that violates a documented invariant (lost row, wrong field, orphaned reference) | rollback immediately and preserve forensic state |
16
+ | Latency regression | p95 latency exceeds 1.5x the pre-rollout p95 for the affected route | rollback (or documented forward-recovery) |
17
+ | Failed dependency | a critical dependency the rollout relies on is confirmed down | rollback (or pause rollout and contain) |
18
+
19
+ Rollback is not always technically possible; where it is not, the TDD must document forward recovery, containment, restore, or compensating actions instead of falsely promising reversibility (see `references/tdd/document-contract.md`).
20
+
21
+ ## Rollout Percentages Reference
22
+
23
+ Calibration anchors, not mandates. This is a common starting-point rollout curve with hold windows; pick the curve that matches the project's risk and reversibility, and record the chosen curve plus its stop conditions in the TDD.
24
+
25
+ | Stage | Starting reference traffic share | Hold window (reference) | Exit signal |
26
+ |---|---|---|---|
27
+ | Canary | 1% | observe one full business cycle or the project's monitoring window | telemetry within thresholds for the period |
28
+ | Early ramp | 10% | hold until stability signals hold | no rollback-trigger threshold hit |
29
+ | Mid ramp | 50% | hold until stability signals hold | no rollback-trigger threshold hit |
30
+ | General availability | 100% | post-release verification | rollout complete and verified |
31
+
32
+ Shorter or longer curves are valid when reversibility, blast radius, or regulatory review differ. State the actual curve used; do not copy this reference verbatim into a final document.
33
+
34
+ ## Latency Reference Values
35
+
36
+ Calibration anchors, not mandates. p50, p95, and p99 are standard percentile definitions; the example budgets are starting points only and must be replaced by project-verified SLOs.
37
+
38
+ - **p50 (median):** 50% of requests complete at or below this latency. Reference example budget for an interactive API route: 100 ms.
39
+ - **p95:** 95% of requests complete at or below this latency. Reference example budget for an interactive API route: 300 ms.
40
+ - **p99 (tail):** 99% of requests complete at or below this latency. Reference example budget for an interactive API route: 800 ms.
41
+
42
+ These example budgets fit a typical interactive user-facing API; batch, streaming, and background work have different profiles. Record the project's actual SLO targets and the measurement methodology (window, load, warm or cold) in the TDD rather than citing these reference numbers as if they were the project's budget.
43
+
44
+ ## Compliance Matrix
45
+
46
+ Calibration anchors, not mandates, and not legal advice. Verify applicability per project; do not claim compliance from generic controls. Each row names the kind of obligation a regime typically implies; it does not certify any system as compliant. Confirm applicability and specific obligations with the project's legal, security, or privacy owner before relying on any row.
47
+
48
+ | Regime | Typical obligation kind (verify per project) | Verification note |
49
+ |---|---|---|
50
+ | GDPR | lawful basis, data-subject rights, data minimization, cross-border transfer controls, breach notification | applicability depends on processing EU residents' personal data; confirm scope with privacy owner |
51
+ | PCI-DSS | cardholder-data protection, access control, logging, segmentation, vulnerability management | applicability depends on storing, processing, or transmitting cardholder data; confirm scope with security owner |
52
+ | LGPD | legal basis, data-subject rights, purpose limitation, international transfer, DPO accountability | applicability depends on processing Brazil personal data; confirm scope with privacy owner |
53
+
54
+ This matrix is a starting-point index, not a compliance attestation. Per `references/tdd/document-contract.md`, do not claim compliance from generic controls; identify each applicable obligation as verified, proposed, or unresolved.
@@ -0,0 +1,83 @@
1
+ # TDD Discovery And Sizing
2
+
3
+ Load this reference before source investigation, document sizing, or clarification questions for the TDD workflow.
4
+
5
+ ## Evidence Order
6
+
7
+ Use the narrowest authoritative source first:
8
+
9
+ 1. Current repository source, schemas, tests, configuration, and project instructions.
10
+ 2. Approved project RFCs, ADRs, TDDs, requirements, architecture documents, and tickets available in the workspace.
11
+ 3. Relevant current massa-ai memories, treated as evidence rather than authority.
12
+ 4. Official dependency or platform documentation when the design depends on external behavior.
13
+ 5. External research only when local and official sources cannot answer a material question and browsing is allowed.
14
+
15
+ Record the source of consequential claims. If sources conflict, prefer current source and explicitly approved artifacts, then stop for user resolution when authority remains ambiguous.
16
+
17
+ ## Testing And UI/UX Discovery
18
+
19
+ Before drafting implementation or verification sections:
20
+
21
+ - Inspect existing tests and build/source-set configuration before naming any test file location. For Android or Kotlin Multiplatform repositories, distinguish `commonTest`, `androidUnitTest`, `unitTest`, or the repository's actual equivalent from evidence.
22
+ - For each planned test, decide from source evidence whether the TDD should say `amplify in existing location: <path> (<sourceSet>)` or `create in <sourceSet>: <path>`.
23
+ - For UI/UX-affecting method, class, enum type, sealed type, mapper, state, or model changes, search references and list parallel rendering surfaces and mappers that consume the affected symbol.
24
+ - Before proposing string changes, grep or search for mappers that branch on the affected type and call `stringResource`; run a `Strings Audit` when that pattern exists.
25
+
26
+ ## Fact Discipline
27
+
28
+ Classify design inputs as:
29
+
30
+ - **Verified:** directly supported by current source or an authoritative document.
31
+ - **Inferred:** strongly implied by evidence; label the inference and its basis.
32
+ - **Proposed:** a design choice introduced by the TDD and awaiting review.
33
+ - **Unknown:** not discoverable from available evidence.
34
+
35
+ Never convert an inference or example into a project fact. Omit optional metadata when absent or mark it `TBD`; do not invent people, ticket links, dates other than the actual document date, system names, traffic numbers, SLAs, compliance obligations, estimates, or approvals.
36
+
37
+ ## Workflow Fit
38
+
39
+ - Use TDD when the direction is selected and implementation design remains.
40
+ - Use RFC when stakeholders still need options compared or the primary direction approved.
41
+ - Use ADR when one significant decision and its consequences need recording without a full implementation blueprint.
42
+ - Use spec-driven when the request spans requirements, design, tasks, and implementation or needs staged approval across those phases.
43
+ - Use feature, refactor, debug, or general for localized work that does not need a durable design artifact.
44
+
45
+ TDD readiness checklist:
46
+
47
+ - One product direction is selected.
48
+ - A named requirements source exists, such as user prompt, approved spec, ticket, ADR, RFC outcome, product doc, or current source contract.
49
+ - No unresolved API, data model, security/privacy, migration, rollout, public compatibility, or cross-service decision blocks implementation design.
50
+ - Required owners, decision deadlines, or explicit open questions are known for any non-blocking unknowns.
51
+
52
+ If any of the first three checks fail, route to RFC, ADR, spec-driven, or clarification before drafting the TDD.
53
+
54
+ ## Adaptive Depth
55
+
56
+ ### Compact
57
+
58
+ Use when all are true: <=3 files, <=200 changed LOC expected, one implementation path, no new public contract, no new dependency, no migration, no security/privacy boundary, and rollback is delete/revert-level. Include context, chosen design, affected files, tests, and completion criteria.
59
+
60
+ ### Standard
61
+
62
+ Use when any are true and High-Risk is false: 4-10 files, 201-500 changed LOC expected, multiple components in one ownership area, changed internal interface, new test surface, non-destructive dependency/config change, or one coordinated rollout path. Include relevant contracts, alternatives, rollout, observability, and ownership boundaries.
63
+
64
+ ### High-Risk
65
+
66
+ Use when any are true: authentication, authorization, privacy, regulated or sensitive data, irreversible operation, migration, cross-service contract, public compatibility, high availability, data-loss/outage risk, >10 files, >500 changed LOC expected, multiple teams/ownership areas, or unclear rollback. Require explicit threat/failure analysis, migration safety, rollout, rollback or forward-recovery strategy, and operational verification.
67
+
68
+ Do not use week-based project-size heuristics. Effort estimates are useful only when the user or project planning process requires them and evidence supports them; use ranges and assumptions rather than fabricated precision.
69
+
70
+ ## Clarification Policy
71
+
72
+ Inspect first, ask second. Ask only when the answer changes architecture, scope, a public contract, safety, rollout, or acceptance.
73
+
74
+ - Group at most three related questions per turn.
75
+ - Offer meaningful choices when alternatives are known; otherwise ask concise free-form questions.
76
+ - Ask in the user's language.
77
+ - Do not require owner, team, ticket, API, risk-count, or timeline fields merely to satisfy a template.
78
+ - If an unknown is non-blocking, record it in Open Questions with its decision deadline or owner when known.
79
+ - If a blocking unknown cannot be resolved, stop before claiming the design is decision-complete.
80
+
81
+ ## Language And Terminology
82
+
83
+ Write the TDD in the language of the user's request unless they specify another language. Preserve code identifiers, protocol names, product names, and established domain terms. Translate headings naturally rather than using a fixed translation table.
@@ -0,0 +1,136 @@
1
+ # TDD Document Contract
2
+
3
+ Load this reference when drafting or revising a TDD. Use the smallest set of sections that makes the design decision-complete; headings may be renamed to match the user's language and project conventions.
4
+
5
+ ## Core Sections
6
+
7
+ Every TDD must cover these concerns, though Compact documents may combine sections:
8
+
9
+ 1. **Title And Metadata:** status, actual created/updated dates, owner and related artifacts only when known.
10
+ 2. **Context And Current State:** existing behavior, affected domain, evidence inspected, and why the design is needed now.
11
+ 3. **Problem, Goals, And Non-Goals:** outcome, measurable acceptance where known, explicit scope, and excluded work.
12
+ 4. **Constraints And Assumptions:** technical, product, operational, organizational, compatibility, and regulatory constraints; label assumptions by evidence state.
13
+ 5. **Proposed Design:** component responsibilities, ownership boundaries, interactions, state transitions, data flow, and failure behavior.
14
+ 6. **Contracts And Data:** only relevant APIs, events, schemas, storage ownership, consistency, idempotency, concurrency, versioning, and error semantics.
15
+ 7. **Decisions And Rationale:** important selected approaches, alternatives rejected, trade-offs, consequences, and reversibility. Link a separate ADR when a decision deserves an independent durable record.
16
+ 8. **Risks And Mitigations:** concrete technical, delivery, operational, dependency, and adoption risks with impact, likelihood, detection, mitigation, and accepted residual risk where useful.
17
+ 9. **Verification Strategy:** acceptance criteria and the unit, integration, contract, end-to-end, migration, performance, security, or operational checks needed to prove them.
18
+ 10. **Implementation And Delivery Plan:** ordered phases, dependencies, ownership when known, verification gates, rollout sequence, and stop conditions. Avoid fictional estimates.
19
+ 11. **Decisions Revised During Implementation:** living-document log for decisions changed after implementation reveals new evidence.
20
+ 12. **Pre-Merge TDD Fidelity Check:** final checklist proving implementation still matches the TDD or documents intentional divergence.
21
+ 13. **Open Questions:** unresolved decisions that materially affect implementation, including owner or decision point when known.
22
+
23
+ ## Test Strategy Checklist
24
+
25
+ When a TDD includes downstream implementation work, the Verification Strategy must include a test file checklist table with these exact columns:
26
+
27
+ | Done | Test File | Source Set / Location | Action | Coverage Target | Gate Command |
28
+ |---|---|---|---|---|---|
29
+ | [ ] | `<path>` | `<sourceSet or repo equivalent>` | `amplify in existing location: <path> (<sourceSet>)` or `create in <sourceSet>: <path>` | `<behavior or risk>` | `<command>` |
30
+
31
+ Use the `Done` checkbox as a pre-merge gate. Before choosing a source set, inspect existing test files and source-set configuration. When a relevant test already exists, specify `amplify in existing location: <path> (<sourceSet>)`. Create a new test only after evidence supports the source set and path; write `create in <sourceSet>: <path>`. For Android or Kotlin Multiplatform projects, distinguish `commonTest`, `androidUnitTest`, `unitTest`, or the repository's actual equivalent from build configuration and existing tests rather than defaulting to a preferred source set.
32
+
33
+ ## Implementation Task Table
34
+
35
+ When a TDD includes downstream implementation work, the Implementation And Delivery Plan must include a reviewable task table with these exact columns:
36
+
37
+ | Order | PR Group | Layer | PR Size | Included Work | Dependencies | Verification Gate | Jira Key |
38
+ |---|---|---|---|---|---|---|---|
39
+
40
+ Use one row per reviewable PR group, not one row per incidental file change. A PR group must be independently buildable and testable, with no intermediate state that breaks tests, UI, migrations, public contracts, or required runtime behavior. If a group would be too large, split it into two or more groups; if tasks are too small, merge related small work only when the merged group remains independent and reviewable.
41
+
42
+ Use these PR sizes exactly:
43
+
44
+ - **Small:** `1-200 LOC / 1-3 files`. Prefer Small PRs, with a sweet spot under 50-100 LOC when practical.
45
+ - **Medium:** `201-500 LOC / 3-10 files`. Use Medium only when splitting further would break buildability, testability, UI coherence, or implementation dependency order.
46
+ - **Large:** `500+ LOC / 10+ files`. Treat Large as an exception and include explicit split, stacked PR, feature-flag, or other containment rationale in `Included Work` or `Dependencies`.
47
+
48
+ Order non-breaking groups by layer when applicable: `Data`, then `Domain`, then `Presentation/Navigation`. Data covers DTOs, DAOs, data sources, repositories, analytics, persistence, and data-layer interfaces. Domain covers use cases, models, mappers, configs, exceptions, monitoring, and business rules. Presentation/Navigation covers screens, views, view models, actions, states, routes, and navigation. When the target project uses different boundaries, map these labels to the closest repository terms and state the mapping before the table.
49
+
50
+ `Jira Key` must contain only a confirmed Jira key, `Not requested`, `Unavailable`, or `Pending`. Never invent ticket keys, links, owners, estimates, or approvals.
51
+
52
+ ## Parallel Rendering Surfaces
53
+
54
+ When a method, class, enum type, sealed type, mapper, state, or model affects UI/UX, include an affected surfaces checklist before finalizing scope:
55
+
56
+ | Done | Affected Symbol | Rendering Surface / Mapper | Consumption Path | Required Update | Verification |
57
+ |---|---|---|---|---|---|
58
+ | [ ] | `<method/class/enum/type>` | `<screen/composable/view/mapper>` | `<file or reference path>` | `<change or none>` | `<test or review gate>` |
59
+
60
+ Enumerate all discovered parallel rendering surfaces and mappers that consume the symbol. Mark a surface `none` only with evidence, such as reference search, mapper inspection, or platform/source-set ownership.
61
+
62
+ ## Strings Audit
63
+
64
+ Run a pre-TDD `Strings Audit` when mappers branch on a type and call `stringResource`. Record the branch condition, type values, string keys/resources, fallback behavior, localization impact, and affected rendering surfaces before proposing production or test work. If the repository has no matching mapper or no `stringResource` usage in scope, state that the audit was not applicable with the evidence used.
65
+
66
+ ## Decisions Revised During Implementation
67
+
68
+ Keep this section in every TDD that includes downstream implementation work. It starts empty in the draft and is updated as implementation reveals new facts; do not silently rewrite the original decision as if it was always known.
69
+
70
+ | Date | Original Decision | New Evidence | Revised Decision | Impact | Follow-up |
71
+ |---|---|---|---|---|---|
72
+ | `TBD` | `TBD` | `TBD` | `TBD` | `TBD` | `TBD` |
73
+
74
+ ## Pre-Merge TDD Fidelity Check
75
+ - [ ] All planned test files exist
76
+ - [ ] All planned production changes implemented
77
+ - [ ] Divergences documented with rationale
78
+ - [ ] Extra scope listed with justification
79
+ - [ ] Decision revisions noted
80
+
81
+ ## Conditional Concerns
82
+
83
+ Include a dedicated section or explicit subsection when evidence triggers it:
84
+
85
+ Security, privacy, migration, compatibility, and production-operability concerns are conditional by context but mandatory when their trigger applies.
86
+
87
+ | Trigger | Required concerns |
88
+ |---|---|
89
+ | Authentication, authorization, secrets, payments, PII, regulated data | threat boundaries, abuse cases, least privilege, data classification, retention/deletion, secret handling, auditability, compliance assumptions, security verification |
90
+ | Production behavior or customer-facing rollout | metrics, logs, traces, dashboards, alert conditions, ownership, rollout stages, rollback or forward-recovery triggers, post-release verification |
91
+ | Schema change, backfill, storage move, or protocol migration | compatibility window, expand/migrate/contract ordering, data validation, restartability, idempotency, dual-read/write risks, cutover, recovery, decommission criteria |
92
+ | External or cross-service integration | dependency ownership, versioning, timeout/retry/circuit behavior, rate limits, failure isolation, contract tests, degraded behavior |
93
+ | Public API, event, SDK, CLI, or persisted-format change | compatibility policy, versioning, deprecation, consumer migration, error semantics, rollout coordination |
94
+ | Performance or availability-sensitive path | workload assumptions, budgets or SLOs when known, capacity/scaling behavior, load and failure tests, bottlenecks, cost trade-offs |
95
+ | User-visible behavior | user flows, accessibility/localization impacts, analytics or success signals, release and support implications |
96
+ | Material alternative or hard-to-reverse choice | alternatives considered, decision criteria, why the selected approach wins, reversal cost |
97
+
98
+ Testing is never optional as a concern, but its depth scales to risk. Rollback is not always technically possible; document forward recovery, containment, restore, or compensating actions instead of falsely promising reversible migrations.
99
+
100
+ ## Detail Boundary
101
+
102
+ Include exact details when they are part of the contract or necessary to prevent incompatible implementations:
103
+
104
+ - endpoint methods, message/event names, request/response shapes, status and error semantics
105
+ - schema fields, ownership, constraints, indexes, consistency, retention, and migration invariants
106
+ - module or file boundaries when the current repository makes them stable and relevant
107
+ - algorithms, state machines, ordering, concurrency, idempotency, retry, and timeout behavior
108
+ - feature-flag, rollout, compatibility, and observability contracts
109
+
110
+ When the TDD proposes names for modules, states, events, schemas, fields, or public contract identifiers, follow `references/naming-standards.md`: use domain or precise role vocabulary supported by evidence, keep public/persisted compatibility explicit, and mark uncertain domain names as proposed rather than verified facts.
111
+
112
+ Exclude full production implementations, long command transcripts, decorative boilerplate, and framework syntax that does not express a durable constraint. Small pseudocode, tables, or schemas are acceptable when they clarify behavior better than prose.
113
+
114
+ ## High-Level vs Implementation
115
+
116
+ The durable design states what must hold; implementation detail records how the current codebase satisfies it. Durable design statements survive framework, library, and tooling changes; implementation detail belongs in the task table or inline task notes, not in the durable design prose. The following framework-migration litmus test separates the two.
117
+
118
+ Framework-migration litmus test: ask "If we change frameworks, does this statement still apply?" If yes, it is high-level design and belongs in the Proposed Design or Contracts And Data sections. If no, it is implementation detail and belongs in the implementation task table, not the durable design.
119
+
120
+ Worked pairs (BAD = implementation detail leaking into the durable design; GOOD = high-level design intent):
121
+
122
+ - BAD: "Use Spring's `@Transactional` on the service method." (Framework-specific; fails the litmus test.) GOOD: "The transfer must be atomic across both account writes; partial writes must roll back." (Survives a framework change; names the invariant.)
123
+ - BAD: "Expose the endpoint via a Retrofit `@POST` interface." (Library-specific; fails the litmus test.) GOOD: "The client submits the request over HTTPS with idempotency-key semantics; duplicate retries must not double-apply the operation." (Survives a client-library change; names the contract.)
124
+
125
+ Use implementation-detail statements freely in the task table's `Included Work` and verification gates; keep the durable design prose to statements that pass the litmus test.
126
+
127
+ ## Diagram Policy
128
+
129
+ Use diagrams for multi-component interactions, state transitions, deployment topology, or migration sequencing. Keep diagrams evidence-backed and consistent with the prose. A diagram is not mandatory when a table or short flow is clearer.
130
+
131
+ ## Anti-Fabrication Rules
132
+
133
+ - Do not insert example vendors, tools, endpoints, tables, metrics, thresholds, dates, or team names into the final document unless the project uses them or they are clearly labeled proposals.
134
+ - Do not mandate arbitrary counts such as three risks, three in-scope items, two paragraphs, or one API endpoint.
135
+ - Do not claim compliance from generic controls; identify applicable obligations as verified, proposed, or unresolved.
136
+ - Do not claim approval, completed reviews, configured alerts, tested rollback, or production readiness without evidence.
@@ -0,0 +1,83 @@
1
+ # TDD Quality And Lifecycle
2
+
3
+ Load this reference before challenging, finalizing, saving, or updating a TDD.
4
+
5
+ ## Quality Gate
6
+
7
+ The document is decision-complete only when an implementer can proceed without inventing architecture or contract decisions. Verify:
8
+
9
+ - The problem, goals, non-goals, scope, and constraints agree with approved product or RFC direction.
10
+ - Current-state claims and proposed changes are distinguishable and evidence-backed.
11
+ - Component ownership, interactions, data authority, contracts, and failure behavior are explicit where relevant.
12
+ - Important choices include rationale, trade-offs, consequences, and compatibility impact.
13
+ - Security, privacy, migration, production, integration, performance, and user-facing concerns are included when triggered.
14
+ - Risks include detection and concrete mitigation rather than generic warnings.
15
+ - Verification maps to goals, contracts, failure modes, and migration invariants.
16
+ - Verification includes a test file checklist with `Done`, `Test File`, `Source Set / Location`, `Action`, `Coverage Target`, and `Gate Command` when implementation work is planned.
17
+ - Planned tests specify `amplify in existing location: <path> (<sourceSet>)` for existing tests or `create in <sourceSet>: <path>` for new tests, backed by inspected source-set evidence such as `commonTest`, `androidUnitTest`, `unitTest`, or the repository's actual equivalent.
18
+ - Implementation phases are ordered by dependency and include gates, rollout, and stop conditions.
19
+ - Implementation task tables use the exact columns `Order`, `PR Group`, `Layer`, `PR Size`, `Included Work`, `Dependencies`, `Verification Gate`, and `Jira Key` when implementation work is planned.
20
+ - PR groups are independently buildable and testable. Small PRs are preferred, Medium PRs have a dependency or coherence reason, and Large PRs include split, stacked PR, feature-flag, or containment rationale.
21
+ - Non-breaking implementation groups are ordered Data, Domain, then Presentation/Navigation, or the TDD explicitly maps those labels to the repository's actual boundaries.
22
+ - Jira creation remains delegated to `workflows/ticket.md`; `Jira Key` contains only confirmed keys, `Not requested`, `Unavailable`, or `Pending`.
23
+ - UI/UX-affecting symbol changes include a parallel rendering surfaces and mappers checklist, or explicitly state why none apply.
24
+ - A `Strings Audit` is present when scoped mappers branch on a type and call `stringResource`, or the TDD records evidence that the audit was not applicable.
25
+ - `Decisions Revised During Implementation` is present for living implementation updates.
26
+ - `Pre-Merge TDD Fidelity Check` is present and all checkboxes are resolved before merge.
27
+ - Unknowns are explicit; no placeholder is presented as a decided fact.
28
+ - The document contains no fabricated approvals, estimates, metrics, vendors, or project details.
29
+
30
+ If a blocking item fails, revise the draft or ask the user. Non-blocking gaps remain visible under Open Questions.
31
+
32
+ ## Challenge Gate
33
+
34
+ Run the configured Plan Challenge Gate after the draft exists. For the default full TDD gate, prefer pre-mortem mode unless security/adversarial risk calls for red-team or source claims call for evidence audit.
35
+
36
+ Challenge at least:
37
+
38
+ - the assumption most likely to invalidate the design
39
+ - boundary, ownership, or dependency failures
40
+ - data-loss, compatibility, migration, and rollback/forward-recovery risks
41
+ - operational detection gaps and untestable success claims
42
+ - implementation sequencing that creates an unsafe intermediate state
43
+ - PR grouping that hides multiple independent outcomes, creates a Large PR without containment, or relies on fabricated Jira keys
44
+ - planned test files that are missing, assigned to unverified source sets, or not reflected in the pre-merge fidelity checklist
45
+ - UI/UX parallel rendering surfaces, mapper branches, or string resources that can drift from the production change
46
+
47
+ Revise valid critical or high findings before presentation. Keep accepted residual risks explicit.
48
+
49
+ ## Lifecycle
50
+
51
+ Use honest document states:
52
+
53
+ - **Draft:** design is being developed or has unresolved blocking review.
54
+ - **In Review:** decision-complete draft awaits named review or approval.
55
+ - **Approved:** use only after explicit human approval is available in the current context or authoritative project records.
56
+ - **Superseded:** retain a pointer to the replacement when project convention preserves design history.
57
+
58
+ When updating an existing TDD:
59
+
60
+ 1. Read the current document and its linked decisions.
61
+ 2. Identify what evidence or requirement changed.
62
+ 3. Preserve still-valid constraints and rationale.
63
+ 4. Add material implementation-time changes to `Decisions Revised During Implementation` instead of rewriting history.
64
+ 5. Reconcile the test file checklist, source-set actions, parallel rendering surfaces, `Strings Audit`, and `Pre-Merge TDD Fidelity Check`.
65
+ 6. Update the date and status honestly.
66
+ 7. Summarize material design changes and newly invalidated assumptions.
67
+
68
+ Do not silently replace an existing TDD, erase unresolved risks, or rewrite history to make the new design appear previously approved.
69
+
70
+ ## Artifact And Completion
71
+
72
+ Follow an explicit path or established repository convention. Otherwise use `docs/design/<entity>.md`. Create only directories required for the approved artifact.
73
+
74
+ Before completion:
75
+
76
+ 1. Check Markdown structure and local links.
77
+ 2. Validate Mermaid syntax when diagrams are present and tooling exists.
78
+ 3. Run repository-specific documentation or schema checks when available.
79
+ 4. Confirm stale statements or placeholders are not presented as final decisions.
80
+ 5. Persist only durable decisions after recall, deduplication, and scoring.
81
+ 6. Complete the shared Evidence Gate.
82
+
83
+ Report the artifact path and status, depth selected, conditional concerns included, challenge revisions, unresolved questions, deterministic checks, memory outcome, and residual risk.
@@ -0,0 +1,103 @@
1
+ # Cognitive Bias Inventory
2
+
3
+ Structured bias detection for use during every challenge pass. Integrates findings from Fasolo, Heard & Scopelliti (2025) and the DeBiasMe metacognitive framework.
4
+
5
+ ## Core Principle
6
+
7
+ Cognitive biases are not accusations — they are patterns in human reasoning that systematically distort judgment. The Fool's job is to flag when a bias may be influencing a decision, not to shame the user. Frame bias findings as: "This pattern is common in this type of decision, and here's how it might be affecting your reasoning."
8
+
9
+ ## When to Use This File
10
+
11
+ Read this file on every challenge pass, regardless of mode. After generating your mode-specific challenges, scan the user's reasoning against this inventory. Weave bias findings into your challenges — do not present them as a separate "bias report."
12
+
13
+ ## The Primary Bias Inventory
14
+
15
+ ### Decision-Making Biases
16
+
17
+ | Bias | Description | Detection Signal | Debiasing Technique |
18
+ |------|-------------|-----------------|---------------------|
19
+ | **Confirmation bias** | Seeking evidence that confirms existing belief | Only positive evidence cited; no counter-evidence considered | "What evidence would you need to see to change your mind?" |
20
+ | **Anchoring** | Over-relying on first piece of information | First estimate unchanged despite new data; round numbers dominate | "Generate your own estimate BEFORE looking at others" |
21
+ | **Sunk cost fallacy** | Continuing because of past investment | "We've already spent 6 months on this" as justification to continue | "If you were starting fresh today with no prior investment, would you choose this?" |
22
+ | **Status quo bias** | Preferring current state despite evidence for change | "It's always been this way" or "changing is risky" without quantifying | "What is the cost of NOT changing? Is doing nothing really free?" |
23
+ | **Overconfidence** | Overestimating the accuracy of one's predictions | Point estimates instead of ranges; no contingency planning | "Give me a confidence interval: what's the 10th and 90th percentile outcome?" |
24
+ | **Planning fallacy** | Underestimating time, cost, and risk of future actions | Best-case estimates presented as likely; no buffer for unknowns | "What happened the last 3 times you estimated something similar?" |
25
+
26
+ ### Social and Group Biases
27
+
28
+ | Bias | Description | Detection Signal | Debiasing Technique |
29
+ |------|-------------|-----------------|---------------------|
30
+ | **Groupthink** | Desire for conformity suppresses dissent | "The whole team agrees" with no documented dissent | "Was there a moment where someone almost disagreed? What stopped them?" |
31
+ | **Authority bias** | Deferring to authority regardless of evidence quality | "The CTO/architect/Google says so" as primary evidence | "If this proposal came from a junior engineer, would the evidence be sufficient?" |
32
+ | **Bandwagon effect** | "Everyone is doing it" as justification | Trend adoption without fitness assessment | "Is the reason everyone is doing it the same reason you should?" |
33
+ | **Survivorship bias** | Focusing on successes, ignoring failures | "All the successful companies do X" | "How many companies tried X and failed? What happened to them?" |
34
+
35
+ ### Information Processing Biases
36
+
37
+ | Bias | Description | Detection Signal | Debiasing Technique |
38
+ |------|-------------|-----------------|---------------------|
39
+ | **Availability heuristic** | Overweighting recent or vivid examples | Decision based on one memorable incident | "What does the base rate data say? Is this incident representative or exceptional?" |
40
+ | **Dunning-Kruger** | Overconfidence in unfamiliar domain | Confident claims about areas outside expertise | "How much experience does the team have with this specific technology at this scale?" |
41
+ | **Framing effect** | Decision changes based on how the question is framed | Positive framing hiding negatives (or vice versa) | "Reframe: instead of '90% success rate,' say '10% failure rate.' Does that change the decision?" |
42
+ | **Recency bias** | Overweighting recent events | Last quarter's incident driving architecture decisions | "Is this a trend or an outlier? What does the 12-month data show?" |
43
+ | **Narrative fallacy** | Creating a coherent story from random events | Clean cause-and-effect narrative with no uncertainty | "What parts of this story are we connecting retroactively?" |
44
+
45
+ ## Bias Detection Workflow
46
+
47
+ For each challenge pass, run this quick scan:
48
+
49
+ ### Step 1: Check the Evidence Chain
50
+
51
+ - Is evidence selectively presented? → **Confirmation bias**
52
+ - Is the first data point dominating the analysis? → **Anchoring**
53
+ - Is a single vivid example driving the decision? → **Availability heuristic**
54
+ - Is the source of evidence interested in the outcome? → **Authority bias** or **vendor bias**
55
+
56
+ ### Step 2: Check the Decision Frame
57
+
58
+ - Is past investment being used to justify continuing? → **Sunk cost fallacy**
59
+ - Is the status quo being treated as free? → **Status quo bias**
60
+ - Are estimates point values instead of ranges? → **Overconfidence**
61
+ - Is the timeline based on best-case? → **Planning fallacy**
62
+
63
+ ### Step 3: Check the Social Dynamics
64
+
65
+ - Did "everyone agree" suspiciously fast? → **Groupthink**
66
+ - Is a senior person's opinion treated as evidence? → **Authority bias**
67
+ - Is "industry trend" the primary justification? → **Bandwagon effect**
68
+ - Are only success stories referenced? → **Survivorship bias**
69
+
70
+ ## Bias Mitigation Techniques Summary
71
+
72
+ These are the gold-standard debiasing techniques (Fasolo et al. 2025, Nature Scientific Reports 2025):
73
+
74
+ | Technique | What It Does | When to Apply |
75
+ |-----------|-------------|---------------|
76
+ | **Reference class forecasting** | Use historical base rates instead of inside-view estimates | Any predictive claim or timeline estimate |
77
+ | **Pre-mortem** | Imagine failure first | Planning fallacy, overconfidence |
78
+ | **Red team / devil's advocate** | Structural dissent | Groupthink, confirmation bias |
79
+ | **Blind evaluation** | Strip names, titles, vendors from proposals | Authority bias, halo effect |
80
+ | **Probabilistic framing** | Force confidence intervals and probability ranges | Overconfidence, binary thinking |
81
+ | **Fresh-start framing** | "If starting today with no history, would you choose this?" | Sunk cost, status quo bias |
82
+ | **Inversion** | "What would guarantee failure?" | Confirmation bias, planning fallacy |
83
+ | **Seek disconfirming evidence** | Actively look for evidence AGAINST your position | Confirmation bias |
84
+ | **The Magic Question** | "What would it take to change your mind?" | All biases — tests commitment to evidence |
85
+
86
+ ## Integration with Modes
87
+
88
+ | Mode | Most Common Biases to Check |
89
+ |------|---------------------------|
90
+ | Socratic Questioning | Confirmation bias, framing effect, narrative fallacy |
91
+ | Dialectic Synthesis | Status quo bias, authority bias, groupthink |
92
+ | Pre-mortem Analysis | Planning fallacy, overconfidence, survivorship bias |
93
+ | Red Team | Availability heuristic, anchoring, Dunning-Kruger |
94
+ | Evidence Audit | Confirmation bias, survivorship bias, authority bias |
95
+
96
+ ## Anti-Patterns in Bias Communication
97
+
98
+ | Anti-Pattern | Problem | Better Approach |
99
+ |-------------|---------|-----------------|
100
+ | "You have confirmation bias" | Accusatory, triggers defensiveness | "I notice the evidence cited is all supportive — what does the counter-evidence look like?" |
101
+ | Listing 10 biases at once | Overwhelms, loses impact | Flag the 1-2 most relevant biases, woven into specific challenges |
102
+ | Using bias as a trump card | "You're biased therefore wrong" | Bias affects the reasoning process, not necessarily the conclusion |
103
+ | Naming the bias first | Academic tone alienates | Describe the pattern, then (optionally) name it |