pgserve 2.1.3 → 2.2.1

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 (235) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +105 -1
  3. package/bin/autopg-wrapper.cjs +16 -0
  4. package/bin/pgserve-wrapper.cjs +32 -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 +14 -2
  27. package/scripts/postinstall.cjs +60 -0
  28. package/src/cli-config.cjs +310 -0
  29. package/src/cli-install.cjs +112 -11
  30. package/src/cli-restart.cjs +228 -0
  31. package/src/cli-ui.cjs +580 -0
  32. package/src/cluster.js +43 -38
  33. package/src/postgres.js +141 -19
  34. package/src/settings-loader.cjs +235 -0
  35. package/src/settings-migrate.cjs +212 -0
  36. package/src/settings-pg-args.cjs +146 -0
  37. package/src/settings-schema.cjs +422 -0
  38. package/src/settings-validator.cjs +416 -0
  39. package/src/settings-writer.cjs +288 -0
  40. package/src/upgrade/index.js +65 -0
  41. package/src/upgrade/runner.js +23 -0
  42. package/src/upgrade/steps/binary-cache-flush.js +67 -0
  43. package/src/upgrade/steps/consumer-signal.js +40 -0
  44. package/src/upgrade/steps/env-refresh.js +89 -0
  45. package/src/upgrade/steps/health-validate.js +53 -0
  46. package/src/upgrade/steps/plpgsql-resolve.js +66 -0
  47. package/src/upgrade/steps/port-reconcile.js +52 -0
  48. package/.claude/context/windows-debug.md +0 -119
  49. package/.genie/AGENTS.md +0 -15
  50. package/.genie/agents/README.md +0 -110
  51. package/.genie/agents/analyze.md +0 -176
  52. package/.genie/agents/forge.md +0 -290
  53. package/.genie/agents/garbage-cleaner.md +0 -324
  54. package/.genie/agents/garbage-collector.md +0 -596
  55. package/.genie/agents/github-issue-gc.md +0 -618
  56. package/.genie/agents/review.md +0 -380
  57. package/.genie/agents/semantic-analyzer/find-duplicates.md +0 -90
  58. package/.genie/agents/semantic-analyzer/find-orphans.md +0 -99
  59. package/.genie/agents/semantic-analyzer.md +0 -101
  60. package/.genie/agents/update.md +0 -182
  61. package/.genie/agents/wish.md +0 -357
  62. package/.genie/brainstorms/pgserve-v2/DESIGN.md +0 -174
  63. package/.genie/code/AGENTS.md +0 -694
  64. package/.genie/code/agents/audit/risk.md +0 -173
  65. package/.genie/code/agents/audit/security.md +0 -189
  66. package/.genie/code/agents/audit.md +0 -145
  67. package/.genie/code/agents/challenge.md +0 -230
  68. package/.genie/code/agents/change-reviewer.md +0 -295
  69. package/.genie/code/agents/code-garbage-collector.md +0 -425
  70. package/.genie/code/agents/code-quality.md +0 -410
  71. package/.genie/code/agents/commit-suggester.md +0 -255
  72. package/.genie/code/agents/commit.md +0 -124
  73. package/.genie/code/agents/consensus.md +0 -204
  74. package/.genie/code/agents/daily-standup.md +0 -722
  75. package/.genie/code/agents/docgen.md +0 -48
  76. package/.genie/code/agents/explore.md +0 -79
  77. package/.genie/code/agents/fix.md +0 -100
  78. package/.genie/code/agents/git/commit-advisory.md +0 -219
  79. package/.genie/code/agents/git/workflows/issue.md +0 -244
  80. package/.genie/code/agents/git/workflows/pr.md +0 -179
  81. package/.genie/code/agents/git/workflows/release.md +0 -460
  82. package/.genie/code/agents/git/workflows/report.md +0 -342
  83. package/.genie/code/agents/git.md +0 -432
  84. package/.genie/code/agents/implementor.md +0 -161
  85. package/.genie/code/agents/install.md +0 -515
  86. package/.genie/code/agents/issue-creator.md +0 -344
  87. package/.genie/code/agents/polish.md +0 -116
  88. package/.genie/code/agents/qa.md +0 -653
  89. package/.genie/code/agents/refactor.md +0 -294
  90. package/.genie/code/agents/release.md +0 -1129
  91. package/.genie/code/agents/roadmap.md +0 -885
  92. package/.genie/code/agents/tests.md +0 -557
  93. package/.genie/code/agents/tracer.md +0 -50
  94. package/.genie/code/agents/update/upstream-update.md +0 -85
  95. package/.genie/code/agents/update/versions/generic-update.md +0 -305
  96. package/.genie/code/agents/vibe.md +0 -1317
  97. package/.genie/code/spells/agent-configuration.md +0 -58
  98. package/.genie/code/spells/automated-rc-publishing.md +0 -106
  99. package/.genie/code/spells/branch-tracker-guidance.md +0 -28
  100. package/.genie/code/spells/debug.md +0 -320
  101. package/.genie/code/spells/emoji-naming-convention.md +0 -303
  102. package/.genie/code/spells/evidence-storage.md +0 -26
  103. package/.genie/code/spells/file-naming-rules.md +0 -35
  104. package/.genie/code/spells/forge-code-blueprints.md +0 -195
  105. package/.genie/code/spells/genie-integration.md +0 -153
  106. package/.genie/code/spells/publishing-protocol.md +0 -61
  107. package/.genie/code/spells/team-consultation-protocol.md +0 -284
  108. package/.genie/code/spells/tool-requirements.md +0 -20
  109. package/.genie/code/spells/triad-maintenance-protocol.md +0 -154
  110. package/.genie/code/teams/tech-council/council.md +0 -328
  111. package/.genie/code/teams/tech-council/jt.md +0 -352
  112. package/.genie/code/teams/tech-council/nayr.md +0 -305
  113. package/.genie/code/teams/tech-council/oettam.md +0 -375
  114. package/.genie/neurons/README.md +0 -193
  115. package/.genie/neurons/forge.md +0 -106
  116. package/.genie/neurons/genie.md +0 -63
  117. package/.genie/neurons/review.md +0 -106
  118. package/.genie/neurons/wish.md +0 -104
  119. package/.genie/product/README.md +0 -20
  120. package/.genie/product/cli-automation.md +0 -359
  121. package/.genie/product/environment.md +0 -60
  122. package/.genie/product/mission.md +0 -60
  123. package/.genie/product/roadmap.md +0 -44
  124. package/.genie/product/tech-stack.md +0 -34
  125. package/.genie/product/templates/context-template.md +0 -218
  126. package/.genie/product/templates/qa-done-report-template.md +0 -68
  127. package/.genie/product/templates/review-report-template.md +0 -89
  128. package/.genie/product/templates/wish-template.md +0 -120
  129. package/.genie/scripts/helpers/analyze-commit.js +0 -195
  130. package/.genie/scripts/helpers/bullet-counter.js +0 -194
  131. package/.genie/scripts/helpers/bullet-find.js +0 -289
  132. package/.genie/scripts/helpers/bullet-id.js +0 -244
  133. package/.genie/scripts/helpers/check-secrets.js +0 -237
  134. package/.genie/scripts/helpers/count-tokens.js +0 -200
  135. package/.genie/scripts/helpers/create-frontmatter.js +0 -456
  136. package/.genie/scripts/helpers/detect-markers.js +0 -293
  137. package/.genie/scripts/helpers/detect-todos.js +0 -267
  138. package/.genie/scripts/helpers/detect-unlabeled-blocks.js +0 -135
  139. package/.genie/scripts/helpers/embeddings.js +0 -344
  140. package/.genie/scripts/helpers/find-empty-sections.js +0 -158
  141. package/.genie/scripts/helpers/index.js +0 -319
  142. package/.genie/scripts/helpers/validate-frontmatter.js +0 -578
  143. package/.genie/scripts/helpers/validate-links.js +0 -207
  144. package/.genie/scripts/helpers/validate-paths.js +0 -373
  145. package/.genie/spells/README.md +0 -9
  146. package/.genie/spells/ace-protocol.md +0 -118
  147. package/.genie/spells/ask-one-at-a-time.md +0 -175
  148. package/.genie/spells/backup-analyzer.md +0 -542
  149. package/.genie/spells/blocker.md +0 -12
  150. package/.genie/spells/break-things-move-fast.md +0 -56
  151. package/.genie/spells/context-candidates.md +0 -72
  152. package/.genie/spells/context-critic.md +0 -51
  153. package/.genie/spells/defer-to-expertise.md +0 -278
  154. package/.genie/spells/delegate-dont-do.md +0 -292
  155. package/.genie/spells/error-investigation-protocol.md +0 -328
  156. package/.genie/spells/evidence-based-completion.md +0 -273
  157. package/.genie/spells/experiment.md +0 -65
  158. package/.genie/spells/file-creation-protocol.md +0 -229
  159. package/.genie/spells/forge-integration.md +0 -281
  160. package/.genie/spells/forge-orchestration.md +0 -514
  161. package/.genie/spells/gather-context.md +0 -18
  162. package/.genie/spells/global-health-check.md +0 -34
  163. package/.genie/spells/global-noop-roundtrip.md +0 -25
  164. package/.genie/spells/install-genie.md +0 -1232
  165. package/.genie/spells/install.md +0 -82
  166. package/.genie/spells/investigate-before-commit.md +0 -112
  167. package/.genie/spells/know-yourself.md +0 -288
  168. package/.genie/spells/learn.md +0 -828
  169. package/.genie/spells/mcp-diagnostic-protocol.md +0 -246
  170. package/.genie/spells/mcp-first.md +0 -124
  171. package/.genie/spells/multi-step-execution.md +0 -67
  172. package/.genie/spells/orchestration-boundary-protocol.md +0 -256
  173. package/.genie/spells/orchestrator-not-implementor.md +0 -189
  174. package/.genie/spells/prompt.md +0 -746
  175. package/.genie/spells/reflect.md +0 -404
  176. package/.genie/spells/routing-decision-matrix.md +0 -368
  177. package/.genie/spells/run-in-parallel.md +0 -12
  178. package/.genie/spells/session-state-updater-example.md +0 -196
  179. package/.genie/spells/session-state-updater.md +0 -220
  180. package/.genie/spells/track-long-running-tasks.md +0 -133
  181. package/.genie/spells/troubleshoot-infrastructure.md +0 -176
  182. package/.genie/spells/upgrade-genie.md +0 -415
  183. package/.genie/spells/url-presentation-protocol.md +0 -301
  184. package/.genie/spells/wish-initiation.md +0 -158
  185. package/.genie/spells/wish-issue-linkage.md +0 -410
  186. package/.genie/spells/wish-lifecycle.md +0 -100
  187. package/.genie/state/provider-status.json +0 -3
  188. package/.genie/state/version.json +0 -16
  189. package/.genie/wishes/canonical-pgserve-pm2-supervision/WISH.md +0 -290
  190. package/.genie/wishes/pgserve-v2/BRIEF-from-genie-pgserve.md +0 -99
  191. package/.genie/wishes/pgserve-v2/WISH.md +0 -442
  192. package/.genie/wishes/release-system-genie-pattern/WISH.md +0 -268
  193. package/.genie/wishes/release-system-genie-pattern/validation.md +0 -205
  194. package/.gitguardian.yaml +0 -29
  195. package/.gitguardianignore +0 -16
  196. package/.github/workflows/ci.yml +0 -122
  197. package/.github/workflows/release.yml +0 -289
  198. package/.github/workflows/version.yml +0 -228
  199. package/.husky/pre-commit +0 -2
  200. package/AGENTS.md +0 -433
  201. package/CLAUDE.md +0 -1
  202. package/Makefile +0 -285
  203. package/assets/icon.ico +0 -0
  204. package/bun.lock +0 -435
  205. package/bunfig.toml +0 -28
  206. package/ecosystem.config.cjs +0 -23
  207. package/eslint.config.js +0 -63
  208. package/examples/multi-tenant-demo.js +0 -104
  209. package/install.sh +0 -123
  210. package/knip.json +0 -9
  211. package/tests/audit.test.js +0 -189
  212. package/tests/backpressure.test.js +0 -167
  213. package/tests/benchmarks/runner.js +0 -1197
  214. package/tests/benchmarks/vector-generator.js +0 -368
  215. package/tests/cli-install.test.js +0 -322
  216. package/tests/control-db.test.js +0 -285
  217. package/tests/daemon-args.test.js +0 -86
  218. package/tests/daemon-control.test.js +0 -171
  219. package/tests/daemon-fingerprint-integration.test.js +0 -111
  220. package/tests/daemon-pr24-regression.test.js +0 -198
  221. package/tests/fingerprint.test.js +0 -263
  222. package/tests/fixtures/240-orphan-seed.sql +0 -30
  223. package/tests/multi-tenant.test.js +0 -374
  224. package/tests/orphan-cleanup.test.js +0 -390
  225. package/tests/pg-version-regex.test.js +0 -129
  226. package/tests/quick-bench.js +0 -135
  227. package/tests/router-handshake-retry.test.js +0 -119
  228. package/tests/router-handshake-watchdog.test.js +0 -110
  229. package/tests/sdk.test.js +0 -71
  230. package/tests/stale-postmaster-pid.test.js +0 -85
  231. package/tests/stress-test.js +0 -439
  232. package/tests/sync-perf-test.js +0 -150
  233. package/tests/tcp-listen.test.js +0 -368
  234. package/tests/tenancy.test.js +0 -403
  235. package/tests/wrapper-supervision.test.js +0 -107
@@ -1,220 +0,0 @@
1
- ---
2
- name: session-state-updater
3
- type: workflow
4
- genie:
5
- executor: CLAUDE_CODE
6
- background: false
7
- ---
8
-
9
- # Session State Updater Workflow
10
-
11
- **Purpose:** Systematically update SESSION-STATE.md, MASTER-PLAN.md, and USERCONTEXT.md from any agent or workflow.
12
-
13
- **Called by:** ANY agent/workflow via `!`npx automagik-genie run session-state-updater "..."`
14
-
15
- **Foreground mode:** No `--background` flag = blocks execution until complete
16
-
17
- ---
18
-
19
- ## Discovery Phase
20
-
21
- ### Input Parameters
22
-
23
- This workflow accepts a prompt string with the following parameters (space-separated or key=value):
24
-
25
- ```
26
- action=<started|in_progress|completed|waiting|paused>
27
- agent=<agent-name>
28
- session_id=<uuid>
29
- purpose="<description>"
30
- context="<optional-rich-data>"
31
- parent_session="<optional-parent-uuid>"
32
- branch="<optional-branch-name>"
33
- ```
34
-
35
- **Examples:**
36
- ```
37
- action=started agent=implementor session_id=abc123 purpose="Implement feature X" branch=feat/x
38
-
39
- action=in_progress agent=implementor session_id=abc123 context="files_modified:[src/x.ts,src/y.ts]"
40
-
41
- action=completed agent=implementor session_id=abc123 context="files_modified:[src/x.ts] tests_pass:true"
42
- ```
43
-
44
- ### Parse & Validate
45
-
46
- - Extract all key=value pairs from prompt
47
- - Validate `action` is one of: started, in_progress, completed, waiting, paused
48
- - Validate `session_id` is non-empty UUID format
49
- - Validate `agent` is recognized (implementor, tests, git, genie, learn, release, roadmap)
50
- - Parse `context` as structured data if provided
51
-
52
- ---
53
-
54
- ## Implementation Phase
55
-
56
- ### Step 1: Read Current State
57
-
58
- Read `.genie/SESSION-STATE.md` fully.
59
-
60
- Parse:
61
- - Active sessions section
62
- - Session history section
63
- - Any existing entry for this `session_id`
64
-
65
- ### Step 2: Update or Create Entry
66
-
67
- **If session already exists:**
68
- - Update status field
69
- - Update timestamp (Last Updated)
70
- - Append context data
71
- - Preserve created timestamp
72
-
73
- **If session is new:**
74
- - Create entry in "Active Sessions" section
75
- - Set:
76
- ```
77
- ### <Agent Name> - <Purpose>
78
- **Session ID:** `<session_id>`
79
- **Started:** <ISO timestamp>
80
- **Status:** <action>
81
- **Agent:** <agent-name>
82
- **Purpose:** <purpose>
83
- **Context:** <context>
84
- **Next:** [to be filled]
85
- ```
86
-
87
- ### Step 3: Handle State Transitions
88
-
89
- **started → active:**
90
- - Add to "Active Sessions"
91
- - Record start timestamp
92
-
93
- **in_progress → active:**
94
- - Update status
95
- - Keep in "Active Sessions"
96
-
97
- **completed → history:**
98
- - Move from "Active Sessions" to "Session History (Recent)"
99
- - Add completion timestamp
100
- - Preserve all context
101
-
102
- **waiting → paused:**
103
- - Keep in "Active Sessions"
104
- - Mark waiting status
105
- - Document reason in context
106
-
107
- ### Step 4: Update Parent/Child Relationships
108
-
109
- If `parent_session` provided:
110
- - Find parent entry
111
- - Add this session to parent's "Children:" list (if not already present)
112
- - Mark this entry with "Parent:" reference
113
-
114
- ### Step 5: Write Back
115
-
116
- 1. Format updated SESSION-STATE.md
117
- 2. Write to `.genie/SESSION-STATE.md`
118
- 3. Git add the file
119
- 4. Return success + summary
120
-
121
- ---
122
-
123
- ## Verification Phase
124
-
125
- ### Validation
126
-
127
- - [ ] SESSION-STATE.md is valid markdown
128
- - [ ] Session entry created/updated correctly
129
- - [ ] Parent-child relationships are bidirectional
130
- - [ ] Timestamps are ISO format (YYYY-MM-DD HH:MM UTC)
131
- - [ ] No duplicate session IDs
132
- - [ ] Entry matches requested action
133
-
134
- ### Output
135
-
136
- Return JSON response:
137
- ```json
138
- {
139
- "status": "success",
140
- "action": "started|updated|completed",
141
- "session_id": "<uuid>",
142
- "agent": "<agent-name>",
143
- "updated_files": ["SESSION-STATE.md"],
144
- "timestamp": "<ISO timestamp>",
145
- "message": "Session state updated successfully"
146
- }
147
- ```
148
-
149
- On failure:
150
- ```json
151
- {
152
- "status": "failed",
153
- "error": "<error message>",
154
- "details": "<debug info>"
155
- }
156
- ```
157
-
158
- ---
159
-
160
- ## Usage Pattern in Agents
161
-
162
- ### At Agent Start
163
-
164
- ```markdown
165
- # Implementor Agent
166
-
167
- !`npx automagik-genie run session-state-updater "action=started agent=implementor session_id=$SESSION_ID purpose=Implement\ Feature\ X branch=feat/x"`
168
-
169
- ## Work happens here...
170
- ```
171
-
172
- ### Mid-work Update
173
-
174
- ```markdown
175
- !`npx automagik-genie run session-state-updater "action=in_progress agent=implementor session_id=$SESSION_ID context=\"files_modified:[src/core.ts,src/utils.ts] tests_pass:false\""`
176
- ```
177
-
178
- ### On Completion
179
-
180
- ```markdown
181
- ## Results
182
-
183
- !`npx automagik-genie run session-state-updater "action=completed agent=implementor session_id=$SESSION_ID context=\"files_modified:[src/core.ts,src/utils.ts,test/core.test.ts] tests_pass:true done_report:.genie/wishes/feat-x/reports/done-implementor.md\""`
184
- ```
185
-
186
- ---
187
-
188
- ## Benefits
189
-
190
- **Eliminates:**
191
- - Manual SESSION-STATE.md updates
192
- - Stale session tracking
193
- - role-clarity-protocol guardrails (state always current)
194
- - Documentation bloat (knowledge transferred here)
195
-
196
- **Enables:**
197
- - Automatic state synchronization
198
- - Rich context capture at runtime
199
- - Parent-child workflow tracking
200
- - Complete session history
201
- - Foreground blocking (forces discipline)
202
-
203
- ---
204
-
205
- ## Technical Notes
206
-
207
- - **Foreground mode:** No `--background` flag ensures execution waits
208
- - **Markdown integration:** Called via `!` syntax from any agent/workflow
209
- - **Idempotent:** Safe to call multiple times (updates same entry)
210
- - **Transactional:** Entire state file updated atomically
211
- - **Git-aware:** Auto-stages updated file
212
-
213
- ---
214
-
215
- ## Future Extensions
216
-
217
- - Auto-cleanup old completed sessions (archive to history)
218
- - Webhook notifications on state changes
219
- - Analytics on session duration/completion rates
220
- - Integration with GitHub via issues/PRs
@@ -1,133 +0,0 @@
1
- ---
2
- name: Persistent Tracking Protocol
3
- description: Track all active agent sessions in SESSION-STATE.md for continuity
4
- ---
5
-
6
- # Persistent Tracking Protocol
7
-
8
- **Purpose:** SESSION-STATE.md enables collective intelligence with memory across restarts.
9
-
10
- **Requirements for SESSION-STATE.md:**
11
-
12
- 1. **Track all active agents:**
13
- ```markdown
14
- ### Git Agent - Feature Implementation
15
- **Session ID:** `abc123...`
16
- **Started:** 2025-10-17 16:00 UTC
17
- **Status:** active
18
- **Children:** issue workflow (def456), pr workflow (ghi789)
19
- **Purpose:** Create GitHub issues for feature XYZ
20
- **Context:** Branch feat/xyz, files modified: [list]
21
- **Next:** Create PR after issues created
22
- ```
23
-
24
- 2. **Parent-child relationships:**
25
- - Agent entry lists child workflow sessions
26
- - Clear which workflows belong to which agent
27
- - Prevents "orphaned children" after context reset
28
-
29
- 3. **Resume protocol:**
30
- - Base Genie reads SESSION-STATE.md on restart
31
- - Identifies active agents, presents status to user
32
- - User can resume any agent with `mcp__genie__resume`
33
- - Children resume automatically when parent resumes
34
-
35
- 4. **Completion tracking:**
36
- - Agents mark "completed" when work done
37
- - Children marked completed when parent completes
38
- - Completed sessions move to history section
39
- - Evidence preserved (Done Reports linked)
40
-
41
- **Session entry template (agent with workflows):**
42
- ```markdown
43
- ### [Agent Name] - [Context Description]
44
- **Session ID:** `abc123...`
45
- **Started:** YYYY-MM-DD HH:MM UTC
46
- **Status:** active | paused | completed
47
- **Children:** [workflow-name] (session-id), [workflow-name] (session-id)
48
- **Purpose:** [What this agent is working on]
49
- **Context:** [Key files, decisions, state]
50
- **Next:** [Next action when resumed]
51
- ```
52
-
53
- **Session entry template (workflow - child):**
54
- ```markdown
55
- ### [Workflow Name] (child of [Parent Agent])
56
- **Session ID:** `def456...`
57
- **Parent:** [Parent Agent] (abc123)
58
- **Started:** YYYY-MM-DD HH:MM UTC
59
- **Status:** active | completed
60
- **Purpose:** [Specific workflow task]
61
- **Context:** [Key operations, files]
62
- ```
63
-
64
- **Coordination rules:**
65
-
66
- **Before starting agent:**
67
- 1. Check SESSION-STATE.md for conflicts (same files, different agents)
68
- 2. Create session entry with "starting" status
69
- 3. Launch agent, capture session ID
70
- 4. Update entry with actual session ID and "active" status
71
-
72
- **When agent delegates to workflow:**
73
- 1. Launch workflow, capture session ID
74
- 2. Add workflow entry with parent reference
75
- 3. Update parent agent entry with child list
76
-
77
- **When work completes:**
78
- 1. Mark session "completed" in SESSION-STATE.md
79
- 2. Document outcomes, Done Report location
80
- 3. Move to history section
81
- 4. Children auto-complete when parent completes
82
-
83
- **No lost children rule:**
84
- - Every workflow session MUST have parent reference
85
- - SESSION-STATE.md cleaned regularly (move completed to history)
86
- - Never delete entries without documenting outcomes
87
-
88
- **Validation:**
89
- ```bash
90
- # Check SESSION-STATE.md structure
91
- grep -E "^### |^\*\*Session ID:|^\*\*Parent:" .genie/SESSION-STATE.md
92
-
93
- # Verify all children have parents
94
- # (manual check: every workflow entry has Parent: line)
95
-
96
- # Verify no orphans (workflows without active parents)
97
- # (manual check: compare child Parent: with active agent sessions)
98
- ```
99
-
100
- **Example: Git agent with workflows**
101
- ```markdown
102
- ## Active Sessions
103
-
104
- ### Git Agent - Feature XYZ Implementation
105
- **Session ID:** `git-xyz-abc123`
106
- **Started:** 2025-10-17 16:00 UTC
107
- **Status:** active
108
- **Children:**
109
- - issue workflow (issue-xyz-def456)
110
- - pr workflow (pr-xyz-ghi789)
111
- **Purpose:** Create GitHub issues and PR for feature XYZ
112
- **Context:**
113
- - Branch: feat/xyz
114
- - Files: src/feature.ts, tests/feature.test.ts
115
- - Issues created: #90, #91
116
- **Next:** Create PR after final issue created
117
-
118
- ### Issue Workflow (child of Git Agent)
119
- **Session ID:** `issue-xyz-def456`
120
- **Parent:** Git Agent (git-xyz-abc123)
121
- **Started:** 2025-10-17 16:05 UTC
122
- **Status:** completed
123
- **Purpose:** Create GitHub issue #90
124
- **Context:** Used bug-report template, populated all fields
125
-
126
- ### PR Workflow (child of Git Agent)
127
- **Session ID:** `pr-xyz-ghi789`
128
- **Parent:** Git Agent (git-xyz-abc123)
129
- **Started:** 2025-10-17 16:10 UTC
130
- **Status:** active
131
- **Purpose:** Create PR for feat/xyz
132
- **Context:** Collecting commit history, drafting description
133
- ```
@@ -1,176 +0,0 @@
1
- ---
2
- name: Troubleshoot Infrastructure (When Delegation Monitoring Fails)
3
- description: Protocol for diagnosing infrastructure issues vs actual agent failures. Check infrastructure first, never assume failure.
4
- ---
5
-
6
- # Troubleshoot Infrastructure - When Delegation Monitoring Fails
7
-
8
- ## Core Principle
9
-
10
- **Backend unreachable ≠ Agent stalled. Infrastructure issue ≠ Agent failure.**
11
-
12
- When delegation monitoring fails (can't view session, Forge unreachable, worktree inaccessible), diagnose infrastructure FIRST before assuming agent failed.
13
-
14
- ## The Anti-Pattern
15
-
16
- ❌ **Wrong Response:**
17
- 1. Forge MCP returns "backend unreachable"
18
- 2. Assume agent stalled or failed
19
- 3. Start implementing work yourself
20
- 4. Violate "Once Delegated, Never Duplicated"
21
-
22
- ✅ **Correct Response:**
23
- 1. Forge MCP returns error
24
- 2. Diagnose infrastructure systematically
25
- 3. Check if agent actually working (worktree check)
26
- 4. Report bug if infrastructure issue
27
- 5. Resume/restart if needed, NEVER duplicate
28
-
29
- ## Diagnostic Protocol
30
-
31
- ### Step 1: Check Forge Health
32
-
33
- **Test if Forge backend is responsive:**
34
- ```javascript
35
- mcp__forge__list_projects()
36
- ```
37
-
38
- **If this fails:**
39
- - Forge backend may be down
40
- - MCP connection issue
41
- - Network/Docker problem
42
-
43
- **Action:** Report infrastructure issue, don't assume agent failed
44
-
45
- ### Step 2: Check Task Status Directly
46
-
47
- **Even if view fails, try direct task query:**
48
- ```javascript
49
- mcp__forge__get_task(task_id="...")
50
- mcp__forge__get_task_attempt(attempt_id="...")
51
- ```
52
-
53
- **If this succeeds:**
54
- - Backend is working
55
- - View endpoint may have specific issue
56
- - Agent may be progressing fine
57
-
58
- **Action:** Use task status, not view, for monitoring
59
-
60
- ### Step 3: Check Worktree for Activity
61
-
62
- **Agent works in isolated worktree - check it directly:**
63
- ```bash
64
- # List all worktrees
65
- ls /var/tmp/automagik-forge/worktrees/
66
-
67
- # Navigate to specific worktree
68
- cd /var/tmp/automagik-forge/worktrees/<task-id-prefix>*
69
-
70
- # Check if agent has been committing
71
- git log --oneline -5
72
-
73
- # Check working directory status
74
- git status
75
-
76
- # Check recent activity
77
- ls -lt | head -10
78
- ```
79
-
80
- **If commits exist:**
81
- - Agent is working successfully!
82
- - Monitoring failed, but agent didn't
83
- - Infrastructure issue, not agent issue
84
-
85
- **Action:** Trust the worktree, report monitoring bug
86
-
87
- ### Step 4: Report Infrastructure Bugs
88
-
89
- **Don't silently work around infrastructure issues:**
90
- ```bash
91
- # Create GitHub issue for infrastructure problem
92
- gh issue create --title "Forge MCP view endpoint unreachable" \
93
- --body "Attempted to monitor task <id>, got error <msg>. Task status shows agent working, but can't view progress." \
94
- --label "bug,infrastructure"
95
- ```
96
-
97
- **Why:** Infrastructure bugs must be tracked and fixed, not silently tolerated
98
-
99
- ### Step 5: Resume or Restart (Never Duplicate)
100
-
101
- **If agent actually stalled (no worktree commits, task stuck):**
102
- ```javascript
103
- // Try resuming with follow-up
104
- mcp__genie__resume(sessionId="...", prompt="Status check - are you still working?")
105
-
106
- // Or restart task if truly stuck
107
- // But NEVER implement yourself in main workspace
108
- ```
109
-
110
- ## Real-World Example
111
-
112
- **Scenario:** Monitoring task b51db539 (update process fix)
113
-
114
- **What Happened:**
115
- 1. Master Genie delegates to fix agent via Forge
116
- 2. `mcp__genie__view(sessionId)` returns "backend unreachable"
117
- 3. Master Genie gets anxious about progress visibility
118
- 4. **VIOLATION:** Master Genie starts editing genie-cli.ts, init.ts
119
- 5. Meanwhile: fix agent already completed work in worktree
120
- 6. Result: Duplicate work, wasted 40 minutes, Amendment #4 violated
121
-
122
- **What Should Have Happened:**
123
- 1. Master Genie delegates to fix agent
124
- 2. `mcp__genie__view()` fails with "backend unreachable"
125
- 3. **Step 1:** Try `mcp__forge__list_projects()` → Works! Backend is fine
126
- 4. **Step 2:** Try `mcp__forge__get_task()` → Shows task in progress
127
- 5. **Step 3:** Check worktree:
128
- ```bash
129
- cd /var/tmp/automagik-forge/worktrees/b51d*
130
- git log --oneline -3
131
- # Shows: b8913b23 fix: Use workspace package version for update detection
132
- ```
133
- 6. **Discovery:** Agent completed work successfully! Monitoring failed, agent didn't.
134
- 7. **Step 4:** Report bug: "Genie MCP view endpoint unreachable while task running"
135
- 8. **Step 5:** No restart needed, agent succeeded. Merge worktree to main.
136
-
137
- **Time Saved:** 40 minutes of duplicate work avoided
138
-
139
- ## Checklist Before Assuming Agent Failed
140
-
141
- When delegation monitoring fails, check:
142
-
143
- - [ ] Did I try `list_projects()` to test Forge health?
144
- - [ ] Did I try `get_task()` instead of `view()`?
145
- - [ ] Did I check the worktree for commits?
146
- - [ ] Did I verify agent actually stalled vs monitoring failed?
147
- - [ ] Did I report infrastructure bug?
148
- - [ ] Am I about to violate "Once Delegated, Never Duplicated"?
149
-
150
- ## Why This Matters
151
-
152
- **Master Genie anxiety about progress visibility MUST NOT trigger implementation work.**
153
-
154
- Master Genie's role:
155
- - ✅ Monitor progress (when monitoring works)
156
- - ✅ Diagnose infrastructure issues
157
- - ✅ Report bugs
158
- - ✅ Coordinate next steps
159
- - ❌ Implement when anxious about visibility
160
- - ❌ Assume agent failed when infrastructure failed
161
- - ❌ Duplicate agent's work
162
-
163
- **Separation:** Infrastructure issues ≠ Agent failures. Diagnose correctly.
164
-
165
- ## Evidence
166
-
167
- **Learning #7 Origin:** `learn.md` lines 152-164
168
- **Learning #9 Origin:** `learn.md` lines 180-196
169
- **Real violation:** Bug #168, task b51db539, 2025-10-21
170
- **Analysis:** `/tmp/session-ultrathink-analysis.md` lines 108-126, 177-198, 294-312
171
-
172
- ## Related
173
-
174
- - `@.genie/spells/orchestration-boundary-protocol.md` - Once delegated, never duplicated
175
- - `@.genie/spells/orchestrator-not-implementor.md` - Role boundaries
176
- - `AGENTS.md` Amendment #4 - Orchestration boundary protocol