pgserve 2.1.3 → 2.2.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 (228) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +105 -1
  3. package/bin/autopg-wrapper.cjs +16 -0
  4. package/bin/pgserve-wrapper.cjs +31 -6
  5. package/bin/postgres-server.js +56 -0
  6. package/console/README.md +131 -0
  7. package/console/api.js +173 -0
  8. package/console/app.jsx +483 -0
  9. package/console/colors_and_type.css +227 -0
  10. package/console/components.jsx +167 -0
  11. package/console/console.css +1666 -0
  12. package/console/data.jsx +350 -0
  13. package/console/index.html +31 -0
  14. package/console/screens/databases.jsx +5 -0
  15. package/console/screens/health.jsx +5 -0
  16. package/console/screens/ingress.jsx +5 -0
  17. package/console/screens/optimizer.jsx +5 -0
  18. package/console/screens/rlm-sim.jsx +5 -0
  19. package/console/screens/rlm-trace.jsx +5 -0
  20. package/console/screens/security.jsx +5 -0
  21. package/console/screens/settings.jsx +611 -0
  22. package/console/screens/sql.jsx +5 -0
  23. package/console/screens/sync.jsx +5 -0
  24. package/console/screens/tables.jsx +5 -0
  25. package/console/tweaks-panel.jsx +425 -0
  26. package/package.json +11 -1
  27. package/src/cli-config.cjs +310 -0
  28. package/src/cli-install.cjs +98 -11
  29. package/src/cli-restart.cjs +228 -0
  30. package/src/cli-ui.cjs +580 -0
  31. package/src/cluster.js +43 -38
  32. package/src/postgres.js +141 -19
  33. package/src/settings-loader.cjs +235 -0
  34. package/src/settings-migrate.cjs +212 -0
  35. package/src/settings-pg-args.cjs +146 -0
  36. package/src/settings-schema.cjs +422 -0
  37. package/src/settings-validator.cjs +416 -0
  38. package/src/settings-writer.cjs +288 -0
  39. package/.claude/context/windows-debug.md +0 -119
  40. package/.genie/AGENTS.md +0 -15
  41. package/.genie/agents/README.md +0 -110
  42. package/.genie/agents/analyze.md +0 -176
  43. package/.genie/agents/forge.md +0 -290
  44. package/.genie/agents/garbage-cleaner.md +0 -324
  45. package/.genie/agents/garbage-collector.md +0 -596
  46. package/.genie/agents/github-issue-gc.md +0 -618
  47. package/.genie/agents/review.md +0 -380
  48. package/.genie/agents/semantic-analyzer/find-duplicates.md +0 -90
  49. package/.genie/agents/semantic-analyzer/find-orphans.md +0 -99
  50. package/.genie/agents/semantic-analyzer.md +0 -101
  51. package/.genie/agents/update.md +0 -182
  52. package/.genie/agents/wish.md +0 -357
  53. package/.genie/brainstorms/pgserve-v2/DESIGN.md +0 -174
  54. package/.genie/code/AGENTS.md +0 -694
  55. package/.genie/code/agents/audit/risk.md +0 -173
  56. package/.genie/code/agents/audit/security.md +0 -189
  57. package/.genie/code/agents/audit.md +0 -145
  58. package/.genie/code/agents/challenge.md +0 -230
  59. package/.genie/code/agents/change-reviewer.md +0 -295
  60. package/.genie/code/agents/code-garbage-collector.md +0 -425
  61. package/.genie/code/agents/code-quality.md +0 -410
  62. package/.genie/code/agents/commit-suggester.md +0 -255
  63. package/.genie/code/agents/commit.md +0 -124
  64. package/.genie/code/agents/consensus.md +0 -204
  65. package/.genie/code/agents/daily-standup.md +0 -722
  66. package/.genie/code/agents/docgen.md +0 -48
  67. package/.genie/code/agents/explore.md +0 -79
  68. package/.genie/code/agents/fix.md +0 -100
  69. package/.genie/code/agents/git/commit-advisory.md +0 -219
  70. package/.genie/code/agents/git/workflows/issue.md +0 -244
  71. package/.genie/code/agents/git/workflows/pr.md +0 -179
  72. package/.genie/code/agents/git/workflows/release.md +0 -460
  73. package/.genie/code/agents/git/workflows/report.md +0 -342
  74. package/.genie/code/agents/git.md +0 -432
  75. package/.genie/code/agents/implementor.md +0 -161
  76. package/.genie/code/agents/install.md +0 -515
  77. package/.genie/code/agents/issue-creator.md +0 -344
  78. package/.genie/code/agents/polish.md +0 -116
  79. package/.genie/code/agents/qa.md +0 -653
  80. package/.genie/code/agents/refactor.md +0 -294
  81. package/.genie/code/agents/release.md +0 -1129
  82. package/.genie/code/agents/roadmap.md +0 -885
  83. package/.genie/code/agents/tests.md +0 -557
  84. package/.genie/code/agents/tracer.md +0 -50
  85. package/.genie/code/agents/update/upstream-update.md +0 -85
  86. package/.genie/code/agents/update/versions/generic-update.md +0 -305
  87. package/.genie/code/agents/vibe.md +0 -1317
  88. package/.genie/code/spells/agent-configuration.md +0 -58
  89. package/.genie/code/spells/automated-rc-publishing.md +0 -106
  90. package/.genie/code/spells/branch-tracker-guidance.md +0 -28
  91. package/.genie/code/spells/debug.md +0 -320
  92. package/.genie/code/spells/emoji-naming-convention.md +0 -303
  93. package/.genie/code/spells/evidence-storage.md +0 -26
  94. package/.genie/code/spells/file-naming-rules.md +0 -35
  95. package/.genie/code/spells/forge-code-blueprints.md +0 -195
  96. package/.genie/code/spells/genie-integration.md +0 -153
  97. package/.genie/code/spells/publishing-protocol.md +0 -61
  98. package/.genie/code/spells/team-consultation-protocol.md +0 -284
  99. package/.genie/code/spells/tool-requirements.md +0 -20
  100. package/.genie/code/spells/triad-maintenance-protocol.md +0 -154
  101. package/.genie/code/teams/tech-council/council.md +0 -328
  102. package/.genie/code/teams/tech-council/jt.md +0 -352
  103. package/.genie/code/teams/tech-council/nayr.md +0 -305
  104. package/.genie/code/teams/tech-council/oettam.md +0 -375
  105. package/.genie/neurons/README.md +0 -193
  106. package/.genie/neurons/forge.md +0 -106
  107. package/.genie/neurons/genie.md +0 -63
  108. package/.genie/neurons/review.md +0 -106
  109. package/.genie/neurons/wish.md +0 -104
  110. package/.genie/product/README.md +0 -20
  111. package/.genie/product/cli-automation.md +0 -359
  112. package/.genie/product/environment.md +0 -60
  113. package/.genie/product/mission.md +0 -60
  114. package/.genie/product/roadmap.md +0 -44
  115. package/.genie/product/tech-stack.md +0 -34
  116. package/.genie/product/templates/context-template.md +0 -218
  117. package/.genie/product/templates/qa-done-report-template.md +0 -68
  118. package/.genie/product/templates/review-report-template.md +0 -89
  119. package/.genie/product/templates/wish-template.md +0 -120
  120. package/.genie/scripts/helpers/analyze-commit.js +0 -195
  121. package/.genie/scripts/helpers/bullet-counter.js +0 -194
  122. package/.genie/scripts/helpers/bullet-find.js +0 -289
  123. package/.genie/scripts/helpers/bullet-id.js +0 -244
  124. package/.genie/scripts/helpers/check-secrets.js +0 -237
  125. package/.genie/scripts/helpers/count-tokens.js +0 -200
  126. package/.genie/scripts/helpers/create-frontmatter.js +0 -456
  127. package/.genie/scripts/helpers/detect-markers.js +0 -293
  128. package/.genie/scripts/helpers/detect-todos.js +0 -267
  129. package/.genie/scripts/helpers/detect-unlabeled-blocks.js +0 -135
  130. package/.genie/scripts/helpers/embeddings.js +0 -344
  131. package/.genie/scripts/helpers/find-empty-sections.js +0 -158
  132. package/.genie/scripts/helpers/index.js +0 -319
  133. package/.genie/scripts/helpers/validate-frontmatter.js +0 -578
  134. package/.genie/scripts/helpers/validate-links.js +0 -207
  135. package/.genie/scripts/helpers/validate-paths.js +0 -373
  136. package/.genie/spells/README.md +0 -9
  137. package/.genie/spells/ace-protocol.md +0 -118
  138. package/.genie/spells/ask-one-at-a-time.md +0 -175
  139. package/.genie/spells/backup-analyzer.md +0 -542
  140. package/.genie/spells/blocker.md +0 -12
  141. package/.genie/spells/break-things-move-fast.md +0 -56
  142. package/.genie/spells/context-candidates.md +0 -72
  143. package/.genie/spells/context-critic.md +0 -51
  144. package/.genie/spells/defer-to-expertise.md +0 -278
  145. package/.genie/spells/delegate-dont-do.md +0 -292
  146. package/.genie/spells/error-investigation-protocol.md +0 -328
  147. package/.genie/spells/evidence-based-completion.md +0 -273
  148. package/.genie/spells/experiment.md +0 -65
  149. package/.genie/spells/file-creation-protocol.md +0 -229
  150. package/.genie/spells/forge-integration.md +0 -281
  151. package/.genie/spells/forge-orchestration.md +0 -514
  152. package/.genie/spells/gather-context.md +0 -18
  153. package/.genie/spells/global-health-check.md +0 -34
  154. package/.genie/spells/global-noop-roundtrip.md +0 -25
  155. package/.genie/spells/install-genie.md +0 -1232
  156. package/.genie/spells/install.md +0 -82
  157. package/.genie/spells/investigate-before-commit.md +0 -112
  158. package/.genie/spells/know-yourself.md +0 -288
  159. package/.genie/spells/learn.md +0 -828
  160. package/.genie/spells/mcp-diagnostic-protocol.md +0 -246
  161. package/.genie/spells/mcp-first.md +0 -124
  162. package/.genie/spells/multi-step-execution.md +0 -67
  163. package/.genie/spells/orchestration-boundary-protocol.md +0 -256
  164. package/.genie/spells/orchestrator-not-implementor.md +0 -189
  165. package/.genie/spells/prompt.md +0 -746
  166. package/.genie/spells/reflect.md +0 -404
  167. package/.genie/spells/routing-decision-matrix.md +0 -368
  168. package/.genie/spells/run-in-parallel.md +0 -12
  169. package/.genie/spells/session-state-updater-example.md +0 -196
  170. package/.genie/spells/session-state-updater.md +0 -220
  171. package/.genie/spells/track-long-running-tasks.md +0 -133
  172. package/.genie/spells/troubleshoot-infrastructure.md +0 -176
  173. package/.genie/spells/upgrade-genie.md +0 -415
  174. package/.genie/spells/url-presentation-protocol.md +0 -301
  175. package/.genie/spells/wish-initiation.md +0 -158
  176. package/.genie/spells/wish-issue-linkage.md +0 -410
  177. package/.genie/spells/wish-lifecycle.md +0 -100
  178. package/.genie/state/provider-status.json +0 -3
  179. package/.genie/state/version.json +0 -16
  180. package/.genie/wishes/canonical-pgserve-pm2-supervision/WISH.md +0 -290
  181. package/.genie/wishes/pgserve-v2/BRIEF-from-genie-pgserve.md +0 -99
  182. package/.genie/wishes/pgserve-v2/WISH.md +0 -442
  183. package/.genie/wishes/release-system-genie-pattern/WISH.md +0 -268
  184. package/.genie/wishes/release-system-genie-pattern/validation.md +0 -205
  185. package/.gitguardian.yaml +0 -29
  186. package/.gitguardianignore +0 -16
  187. package/.github/workflows/ci.yml +0 -122
  188. package/.github/workflows/release.yml +0 -289
  189. package/.github/workflows/version.yml +0 -228
  190. package/.husky/pre-commit +0 -2
  191. package/AGENTS.md +0 -433
  192. package/CLAUDE.md +0 -1
  193. package/Makefile +0 -285
  194. package/assets/icon.ico +0 -0
  195. package/bun.lock +0 -435
  196. package/bunfig.toml +0 -28
  197. package/ecosystem.config.cjs +0 -23
  198. package/eslint.config.js +0 -63
  199. package/examples/multi-tenant-demo.js +0 -104
  200. package/install.sh +0 -123
  201. package/knip.json +0 -9
  202. package/scripts/test-bun-self-heal.sh +0 -163
  203. package/scripts/test-npx.sh +0 -60
  204. package/tests/audit.test.js +0 -189
  205. package/tests/backpressure.test.js +0 -167
  206. package/tests/benchmarks/runner.js +0 -1197
  207. package/tests/benchmarks/vector-generator.js +0 -368
  208. package/tests/cli-install.test.js +0 -322
  209. package/tests/control-db.test.js +0 -285
  210. package/tests/daemon-args.test.js +0 -86
  211. package/tests/daemon-control.test.js +0 -171
  212. package/tests/daemon-fingerprint-integration.test.js +0 -111
  213. package/tests/daemon-pr24-regression.test.js +0 -198
  214. package/tests/fingerprint.test.js +0 -263
  215. package/tests/fixtures/240-orphan-seed.sql +0 -30
  216. package/tests/multi-tenant.test.js +0 -374
  217. package/tests/orphan-cleanup.test.js +0 -390
  218. package/tests/pg-version-regex.test.js +0 -129
  219. package/tests/quick-bench.js +0 -135
  220. package/tests/router-handshake-retry.test.js +0 -119
  221. package/tests/router-handshake-watchdog.test.js +0 -110
  222. package/tests/sdk.test.js +0 -71
  223. package/tests/stale-postmaster-pid.test.js +0 -85
  224. package/tests/stress-test.js +0 -439
  225. package/tests/sync-perf-test.js +0 -150
  226. package/tests/tcp-listen.test.js +0 -368
  227. package/tests/tenancy.test.js +0 -403
  228. package/tests/wrapper-supervision.test.js +0 -107
@@ -1,58 +0,0 @@
1
- ---
2
- name: Agent Configuration Standards
3
- description: Declare permissionMode: default for agents that write files
4
- genie:
5
- executor: [CLAUDE_CODE, CODEX, OPENCODE]
6
- forge:
7
- CLAUDE_CODE:
8
- model: sonnet
9
- CODEX: {}
10
- OPENCODE: {}
11
- ---
12
-
13
- # Agent Configuration Standards
14
-
15
- ## File Write Permissions
16
-
17
- **Rule:** All agents requiring file write access MUST explicitly declare `permissionMode: default` in their frontmatter.
18
-
19
- **Context:** Discovered 2025-10-13 when Claude agents with `executor: claude` were unable to write files. Permission prompts auto-skipped because stdin was hardcoded to `'ignore'` during process spawn, making `permissionMode: acceptEdits` completely non-functional.
20
-
21
- **Why this matters:**
22
- - Default executor config doesn't grant write access
23
- - Without explicit `permissionMode: default`, agents silently fail on file operations
24
- - Background spell (`background: true`) requires the same permission declaration
25
-
26
- **Agent categories:**
27
-
28
- **Implementation agents** (REQUIRE `permissionMode: default`):
29
- - Core delivery: `implementor`, `tests`, `polish`, `refactor`, `git`
30
- - Infrastructure: `install`, `learn`, `commit`, `review`
31
- - Workflow orchestrators: `wish`, `plan`, `forge`, `vibe`, `qa`
32
-
33
- **Analysis agents** (READ-ONLY, no permissionMode needed):
34
- - `analyze`, `audit`, `debug`, `genie`, `prompt`
35
-
36
- **Configuration hierarchy:**
37
- 1. **Agent frontmatter** (highest priority) ← Use this level
38
- 2. Config override (`.genie/cli/config.yaml:48`)
39
- 3. Executor default (`claude.ts:13`)
40
-
41
- **Implementation example:**
42
- ```yaml
43
- ```
44
-
45
- **Validation:**
46
- ```bash
47
- # Check all implementation agents have permissionMode
48
- grep -L "permissionMode:" .genie/agents/{implementor,tests,polish,refactor,git,install,learn,commit}.md
49
- # Should return empty (all agents have the setting)
50
-
51
- # Test file write capability (via MCP, not CLI)
52
- # Use mcp__genie__run with agent="implementor" and prompt="Create test file at /tmp/test.txt"
53
- # Should create file without permission prompts
54
- ```
55
-
56
- **Future work:** Issue #35 tracks interactive permission system for foreground/background pause-and-resume approval workflow.
57
-
58
- **Root cause reference:** Debug session `292942e0-07d1-4448-8d5e-74db8acc8c5b` identified stdin configuration at `src/cli/cli-core/handlers/shared.ts:391` (historical reference).
@@ -1,106 +0,0 @@
1
- ---
2
- name: Automated RC Publishing
3
- description: RC releases are AUTOMATIC on main commits - never suggest manual bumps
4
- genie:
5
- executor: [CLAUDE_CODE, CODEX, OPENCODE]
6
- forge:
7
- CLAUDE_CODE:
8
- model: sonnet
9
- CODEX: {}
10
- OPENCODE: {}
11
- ---
12
-
13
- # Automated RC Publishing Protocol
14
-
15
-
16
- ## 🔴 CRITICAL RULE: Forget Manual RC Bumps
17
-
18
- **The Automated Workflow:**
19
- ```
20
- Commit pushed to main
21
-
22
- GitHub Actions detects push
23
-
24
- Auto-bump: rc.N → rc.N+1
25
-
26
- Auto-publish: npm publish @latest
27
-
28
- Auto-release: GitHub release created
29
- ```
30
-
31
- ## ✅ Correct Behavior
32
-
33
- **When work is complete:**
34
- 1. Commit changes to main (or merge PR to main)
35
- 2. Push to origin: `git push`
36
- 3. **STOP** - GitHub Actions handles everything else
37
- 4. Verify: `npm view automagik-genie@latest version`
38
-
39
- **What to say:**
40
- - ✅ "Ready to commit and push?"
41
- - ✅ "This will trigger automatic RC publish"
42
- - ✅ "Push to main to release"
43
-
44
- **What NOT to say:**
45
- - ❌ "Ready to bump?"
46
- - ❌ "Ready to publish?"
47
- - ❌ "Run `pnpm bump:rc`"
48
- - ❌ "Let me create the release"
49
-
50
- ## ❌ Anti-Patterns
51
-
52
- **NEVER suggest these for routine releases:**
53
- - `pnpm bump:rc` (only for manual testing/local work)
54
- - `pnpm bump:patch/minor/major` (only for version transitions)
55
- - Manual `npm publish`
56
- - Manual GitHub release creation
57
-
58
- ## 🎯 When bump.cjs IS Used
59
-
60
- **Only for starting NEW version cycles:**
61
- - `pnpm bump:patch` → 2.4.2 → 2.4.3-rc.1
62
- - `pnpm bump:minor` → 2.4.2 → 2.5.0-rc.1
63
- - `pnpm bump:major` → 2.4.2 → 3.0.0-rc.1
64
-
65
- **Use case:** Major feature complete, ready for new version series
66
-
67
- ## 📋 Recognition Patterns
68
-
69
- **When user says:**
70
- - "Is this ready to ship?"
71
- - "Should we release this?"
72
- - "Time to publish?"
73
-
74
- **Respond with:**
75
- - "Yes, commit and push to main. GitHub Actions will auto-publish the next RC."
76
-
77
- **NOT:**
78
- - ~~"Yes, run `pnpm bump:rc` to create the release."~~
79
-
80
- ## 🔗 Related
81
-
82
- - Amendment #6: Automated Publishing (AGENTS.md:239-284)
83
- - Amendment #7: Auto-Sync Before Push (AGENTS.md:286-327)
84
- - scripts/bump.cjs: Version transition tool (not for routine RCs)
85
-
86
- ## 📊 Evidence
87
-
88
- **First violation:** 2025-10-23
89
- - Context: Master Genie version sync fix
90
- - What happened: Said "Ready to commit?" implying manual RC bump needed
91
- - Reality: Commit to main triggers automatic RC publish
92
- - Learning: Remove manual bump suggestions from routine workflow
93
-
94
- ## 🧠 Mental Model
95
-
96
- **OLD (Pre-Automation):**
97
- ```
98
- Write code → Manual bump → Manual publish → Manual release
99
- ```
100
-
101
- **NEW (Current):**
102
- ```
103
- Write code → Commit to main → ✨ Automation handles rest ✨
104
- ```
105
-
106
- **Remember:** We automated ourselves out of manual RC management. Trust the automation.
@@ -1,28 +0,0 @@
1
- ---
2
- name: Branch & Tracker Guidance
3
- description: Use dedicated branches for medium/large changes, track IDs in wishes
4
- genie:
5
- executor: [CLAUDE_CODE, CODEX, OPENCODE]
6
- forge:
7
- CLAUDE_CODE:
8
- model: sonnet
9
- CODEX: {}
10
- OPENCODE: {}
11
- ---
12
-
13
- # Branch & Tracker Guidance
14
-
15
- **Branch strategy:**
16
- - **Dedicated branch** (`feat/<wish-slug>`) for medium/large changes.
17
- - **Existing branch** only with documented rationale (wish status log).
18
- - **Micro-task** for tiny updates; track in wish status and commit advisory.
19
-
20
- **Tracker management:**
21
- - Tracker IDs (from forge execution output) should be logged in the wish markdown once assigned. Capture them immediately after forge reports IDs.
22
-
23
- A common snippet:
24
-
25
- ```
26
- ### Tracking
27
- - Forge task: FORGE-123
28
- ```
@@ -1,320 +0,0 @@
1
- ---
2
- name: Debug (Systematic Investigation with Confidence Scoring)
3
- description: Generate 5 hypotheses → narrow to 3 → present with confidence scores
4
- genie:
5
- executor: [CLAUDE_CODE, CODEX, OPENCODE]
6
- forge:
7
- CLAUDE_CODE:
8
- model: sonnet
9
- CODEX: {}
10
- OPENCODE: {}
11
- ---
12
-
13
- # 🧞🐛 Debug - Evidence-Based Investigation with Confidence Scoring
14
-
15
- ## Core Teaching
16
-
17
- **New Pattern:** Debug must generate AT LEAST 5 different possibilities for root cause, narrow down to top 3 based on evidence, and present to user with confidence scores (0-100%).
18
-
19
- **Confidence Scoring:** Adapted from review agent's wish analytics matrix—every hypothesis must have evidence-backed confidence score.
20
-
21
- ## When to Use This Spell
22
-
23
- **Triggers:**
24
- - ✅ Bug reported (by user, QA, or automated systems)
25
- - ✅ Unexpected behavior needs investigation
26
- - ✅ System failure requiring root cause analysis
27
- - ✅ Performance degradation
28
- - ✅ Test failures
29
- - ✅ User complaints about functionality
30
-
31
- **Do NOT Use For:**
32
- - ❌ Creative brainstorming (use diverse-options spell instead)
33
- - ❌ Feature requests (use planning workflow)
34
- - ❌ General questions (use direct response)
35
-
36
- ## Debug Workflow (New Pattern)
37
-
38
- ### Phase 1: Evidence Collection (Discovery)
39
- **Goal:** Gather symptoms, reproduce issue, capture environment
40
-
41
- **Activities:**
42
- 1. Review user report / QA feedback / error logs
43
- 2. Reproduce issue with exact steps
44
- 3. Capture environment (runtime versions, git branch, dependencies)
45
- 4. Document expected vs actual behavior
46
- 5. Collect artifacts (screenshots, logs, diffs, metrics)
47
- 6. Check related code areas via @ notation
48
- 7. Review recent changes (git log) for potential regression
49
-
50
- **Output:** Investigation report with evidence at:
51
- - Wish-related: `.genie/wishes/<slug>/reports/{seq}-{context}-debug.md`
52
- - Standalone: `.genie/reports/debug/{seq}-{context}-debug.md`
53
-
54
- **Checkpoints:**
55
- - [ ] Issue reproduced with exact steps
56
- - [ ] Artifacts captured (logs, screenshots, command outputs)
57
- - [ ] Environment snapshot documented
58
- - [ ] Expected vs actual behavior documented
59
- - [ ] Recent changes reviewed
60
-
61
- ### Phase 2: Hypothesis Generation (5+ Possibilities)
62
- **Goal:** Generate AT LEAST 5 distinct hypotheses for root cause
63
-
64
- **Method:** Deliberately explore different possibility dimensions:
65
- 1. **Code Logic Error** (bug in implementation)
66
- 2. **State Management Issue** (timing, race condition, stale state)
67
- 3. **Dependency Problem** (version mismatch, missing dependency)
68
- 4. **Environment Issue** (config, permissions, resources)
69
- 5. **User Misunderstanding** (expected behavior, not a bug)
70
- 6. **Design Flaw** (architecture limitation)
71
- 7. **Integration Failure** (API contract, data format)
72
-
73
- **Anti-Pattern:** Generating 5 variations of the same hypothesis (e.g., "typo in line 10", "typo in line 12", "typo in line 15")
74
-
75
- **Correct Pattern:** Generate 5 DISTINCT categories of possibility, then investigate which has evidence
76
-
77
- ### Phase 3: Evidence-Based Narrowing (5 → 3)
78
- **Goal:** Eliminate hypotheses lacking evidence, narrow to top 3
79
-
80
- **Activities:**
81
- 1. Test each hypothesis systematically
82
- 2. Gather evidence for/against each
83
- 3. Eliminate hypotheses contradicted by evidence
84
- 4. Score remaining hypotheses by confidence
85
-
86
- **Elimination Criteria:**
87
- - ❌ Contradicted by evidence (logs, tests, reproduction)
88
- - ❌ Cannot reproduce in controlled environment
89
- - ❌ Would affect other areas but doesn't
90
- - ❌ Timeline doesn't match (introduced before/after bug appeared)
91
-
92
- **Confidence Calculation (Evidence-Based):**
93
- ```
94
- Base confidence: 0%
95
-
96
- Evidence modifiers:
97
- + Direct observation in logs/output (+30%)
98
- + Reproducible in isolation (+25%)
99
- + File:line pinpointed (+20%)
100
- + Matches known pattern (+15%)
101
- + Explained by recent change (+15%)
102
- + Confirmed by test (+20%)
103
- + Alternative hypotheses eliminated (+10% each)
104
-
105
- Max: 100%
106
- ```
107
-
108
- ### Phase 4: Confidence-Scored Presentation
109
- **Goal:** Present top 3 hypotheses with confidence scores, evidence, and recommended action
110
-
111
- **Format:**
112
- ```markdown
113
- ## Top 3 Hypotheses (Evidence-Based)
114
-
115
- ### 🥇 Hypothesis 1: <name> (Confidence: XX%)
116
- **Root Cause:** <description>
117
- **Evidence:**
118
- - <evidence 1>
119
- - <evidence 2>
120
- **Location:** <file:line if known>
121
- **Fix Approach:** <minimal fix description>
122
- **Regression Check:** <how to verify fix>
123
-
124
- ### 🥈 Hypothesis 2: <name> (Confidence: XX%)
125
- **Root Cause:** <description>
126
- **Evidence:**
127
- - <evidence 1>
128
- - <evidence 2>
129
- **Location:** <file:line if known>
130
- **Fix Approach:** <minimal fix description>
131
- **Regression Check:** <how to verify fix>
132
-
133
- ### 🥉 Hypothesis 3: <name> (Confidence: XX%)
134
- **Root Cause:** <description>
135
- **Evidence:**
136
- - <evidence 1>
137
- - <evidence 2>
138
- **Location:** <file:line if known>
139
- **Fix Approach:** <minimal fix description>
140
- **Regression Check:** <how to verify fix>
141
- ```
142
-
143
- ## Confidence Levels & Resolution Paths
144
-
145
- **90-100% (Certain):**
146
- - Root cause pinpointed with evidence
147
- - File:line identified
148
- - Fix validated locally
149
- - **Action:** Quick fix (minimal change + regression check)
150
-
151
- **70-89% (High Confidence):**
152
- - Strong evidence for hypothesis
153
- - Location area identified (not exact line)
154
- - Fix approach clear
155
- - **Action:** Quick fix OR full workflow (based on complexity)
156
-
157
- **50-69% (Medium Confidence):**
158
- - Some evidence supports hypothesis
159
- - Multiple areas could be involved
160
- - Fix requires investigation
161
- - **Action:** Full workflow (/plan → /wish → /forge → /review)
162
-
163
- **30-49% (Low Confidence):**
164
- - Weak evidence, multiple competing hypotheses
165
- - Root cause unclear
166
- - Needs deeper investigation
167
- - **Action:** Report bug for team discussion, continue investigation
168
-
169
- **0-29% (Very Low Confidence):**
170
- - Insufficient evidence
171
- - Cannot reproduce reliably
172
- - May not be a bug
173
- - **Action:** Report bug with "needs investigation" label, gather more context
174
-
175
- ## Resolution Options (Inherited from Original Debug Agent)
176
-
177
- After presenting top 3 hypotheses with confidence scores, offer resolution paths:
178
-
179
- **Option 1: 🐛 Report Bug**
180
- - **When:** Issue needs tracking, affects others, requires discussion (any confidence level)
181
- - **Action:** File GitHub issue with investigation summary
182
- - **Output:**
183
- - Report: `.genie/reports/debug/bug-report-<slug>-<timestamp>.md` (or in wish if related)
184
- - GitHub issue created via `gh issue create`
185
-
186
- **Option 2: 🔧 Quick Fix**
187
- - **When:** Confidence ≥70%, fix is obvious, minimal, low-risk (high confidence only)
188
- - **Action:** Implement directly or delegate to implementor
189
- - **Output:** Minimal change with regression check
190
-
191
- **Option 3: 📋 Full Workflow**
192
- - **When:** Confidence 50-89%, fix requires design/testing/multiple components
193
- - **Action:** Create plan → wish → forge → review
194
- - **Output:** Structured delivery with QA gates
195
-
196
- ## Severity Tags (Inherited from Review Agent)
197
-
198
- Apply severity to each hypothesis based on impact:
199
-
200
- - 🔴 **CRITICAL** – Security flaw, crashes, data loss, production down
201
- - 🟠 **HIGH** – Major functionality broken, affects many users, performance degradation
202
- - 🟡 **MEDIUM** – Feature partially broken, workaround exists, affects some users
203
- - 🟢 **LOW** – Minor issue, cosmetic, edge case, low impact
204
-
205
- ## Example: Debug in Action
206
-
207
- **Issue:** "MCP server crashes when listing tasks"
208
-
209
- **Phase 1: Evidence Collection**
210
- - Reproduced: `genie` command → crashes with "Connection refused"
211
- - Environment: Node v22.16.0, Ubuntu 22.04, genie v2.4.2-rc.92
212
- - Logs: `ECONNREFUSED 127.0.0.1:3000`
213
- - Recent changes: MCP server refactor (commit abc123)
214
-
215
- **Phase 2: Hypothesis Generation (5 possibilities)**
216
- 1. **Port conflict** – Another process using port 3000
217
- 2. **Server startup failure** – MCP server not starting correctly
218
- 3. **Race condition** – Client connects before server ready
219
- 4. **Config error** – Wrong port in client config
220
- 5. **Dependency issue** – Missing MCP dependencies
221
-
222
- **Phase 3: Evidence-Based Narrowing (5 → 3)**
223
- - ✅ Port 3000 is available (`lsof -i :3000` shows nothing) ❌ Hypothesis 1 eliminated
224
- - ✅ Server logs show "Failed to start: EADDRINUSE" ✅ Hypothesis 2 supported (+30%)
225
- - ✅ No timing issues observed, always fails ❌ Hypothesis 3 eliminated
226
- - ✅ Config shows correct port 3000 ✅ Hypothesis 4 partially supported
227
- - ✅ `npm ls` shows all deps installed ❌ Hypothesis 5 eliminated
228
-
229
- **Phase 4: Top 3 Hypotheses with Confidence Scores**
230
-
231
- ### 🥇 Hypothesis 1: Server Fails to Release Port on Shutdown (Confidence: 75%)
232
- **Root Cause:** Previous server instance not cleanly terminated, port still held
233
- **Evidence:**
234
- - Error: "EADDRINUSE" indicates port already bound
235
- - Consistent failure (not intermittent)
236
- - Recent refactor changed shutdown logic (commit abc123)
237
- **Location:** `packages/session-service/src/server.ts:45-60` (shutdown handler)
238
- **Fix Approach:** Add proper cleanup in shutdown handler + kill orphaned processes on startup
239
- **Regression Check:** `genie` → quit → `genie` → should start successfully
240
-
241
- ### 🥈 Hypothesis 2: Port Hardcoded Instead of Dynamic Allocation (Confidence: 60%)
242
- **Root Cause:** Port 3000 hardcoded, conflicts with other dev tools
243
- **Evidence:**
244
- - Port is always 3000 (no dynamic allocation)
245
- - Common dev port (many tools use 3000)
246
- - Config has port, but might be ignored
247
- **Location:** `packages/session-service/src/config.ts:12` (port definition)
248
- **Fix Approach:** Use dynamic port allocation (0) or environment variable override
249
- **Regression Check:** Start server, verify connects on any available port
250
-
251
- ### 🥉 Hypothesis 3: Missing Error Handling in Connection Logic (Confidence: 45%)
252
- **Root Cause:** Client doesn't retry or wait for server startup
253
- **Evidence:**
254
- - Immediate failure (no retry logic visible)
255
- - Error message is raw ECONNREFUSED (not user-friendly)
256
- **Location:** `packages/genie-cli/src/mcp-client.ts:23` (connection logic)
257
- **Fix Approach:** Add retry logic with exponential backoff + better error message
258
- **Regression Check:** Force delay in server startup, verify client waits/retries
259
-
260
- **Recommendation:** Start with Hypothesis 1 (75% confidence, highest severity) → Quick Fix path
261
-
262
- **Choose option (1/2/3):**
263
- 1. Report Bug (track for team discussion)
264
- 2. Quick Fix (implement hypothesis 1 fix)
265
- 3. Full Workflow (comprehensive server refactor)
266
-
267
- ## Never Do
268
-
269
- - ❌ Generate <5 hypotheses (always explore at least 5 distinct possibilities)
270
- - ❌ Present hypotheses without confidence scores
271
- - ❌ Assign confidence scores without evidence
272
- - ❌ Skip narrowing step (always 5 → 3, not 5 → 1)
273
- - ❌ Present variations as distinct hypotheses (must be different root causes)
274
- - ❌ Implement fixes without user approval
275
- - ❌ Close investigation with "cannot reproduce" without exhausting options
276
- - ❌ File bug reports without concrete evidence
277
-
278
- ## Success Criteria
279
-
280
- - ✅ Generated at least 5 distinct hypotheses (different root cause categories)
281
- - ✅ Narrowed to top 3 based on evidence
282
- - ✅ Each hypothesis has confidence score (0-100%) with evidence
283
- - ✅ Each hypothesis has file:line if known, fix approach, regression check
284
- - ✅ Severity tag applied (🔴🟠🟡🟢)
285
- - ✅ Resolution options presented (1/2/3) with recommendation
286
- - ✅ Evidence artifacts saved in appropriate location
287
- - ✅ Investigation report follows evidence template
288
-
289
- ## Meta-Awareness
290
-
291
- **This spell teaches me:**
292
- - Always generate ≥5 distinct hypotheses (explore possibility space)
293
- - Use evidence to narrow (not intuition alone)
294
- - Confidence scores must be evidence-backed (not guesses)
295
- - Present top 3 with scores so user can make informed decision
296
- - Adapted review agent's scoring methodology for debugging context
297
-
298
- **Evidence:**
299
- - Teaching session 2025-10-23
300
- - Review agent has wish analytics matrix with confidence scoring
301
- - User requested: "at least five different possibilities, narrow down to three, present with score rate"
302
-
303
- ## Integration with Review Agent Pattern
304
-
305
- **Borrowed Concepts:**
306
- - Evidence-based scoring (every point must have artifact reference)
307
- - Checkpoint system (discovery → implementation → verification)
308
- - Severity tagging (🔴🟠🟡🟢)
309
- - Confidence levels (explicit, not implied)
310
- - Verdict format (structured decision with recommendation)
311
-
312
- **Debug-Specific Adaptations:**
313
- - 5 → 3 hypothesis funnel (vs review's 100-point matrix)
314
- - Confidence as percentage (0-100%) vs review's scoring buckets
315
- - Hypothesis exploration (vs review's audit)
316
- - Root cause focus (vs review's completion audit)
317
-
318
- ---
319
-
320
- **Result:** When Code collective needs debugging, this spell provides systematic investigation with evidence-backed confidence scoring. Users get top 3 hypotheses with clear scores, enabling informed decisions about resolution path.