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,173 +0,0 @@
1
- ---
2
- name: risk
3
- description: General risk assessment and mitigation planning
4
- genie:
5
- executor:
6
- - CLAUDE_CODE
7
- - CODEX
8
- - OPENCODE
9
- background: false
10
- forge:
11
- CLAUDE_CODE:
12
- model: sonnet
13
- dangerously_skip_permissions: true
14
- CODEX:
15
- model: gpt-5-codex
16
- sandbox: danger-full-access
17
- OPENCODE:
18
- model: opencode/glm-4.6
19
- ---
20
-
21
- # Risk Audit Workflow
22
- **Extends universal audit framework with general risk assessment patterns.**
23
-
24
- @.genie/code/agents/audit.md
25
-
26
- ---
27
-
28
- ## Risk Audit Mode
29
-
30
- ### When to Use
31
- Use this workflow to enumerate top risks for an initiative, assess impact and likelihood with evidence, and propose concrete mitigations.
32
-
33
- ### Operating Framework
34
- ```
35
- <task_breakdown>
36
- 1. [Discovery] Map initiative scope, constraints, dependencies, failure modes
37
- 2. [Implementation] Enumerate risks, assess impact × likelihood, design mitigations with ownership
38
- 3. [Verification] Rank risks by severity, document residual risk, deliver action plan + confidence verdict
39
- </task_breakdown>
40
- ```
41
-
42
- ### Auto-Context Loading with @ Pattern
43
- Use @ symbols to automatically load initiative context before risk analysis:
44
-
45
- ```
46
- Scope: Production migration to Kubernetes
47
-
48
- @docs/architecture/deployment-strategy.md
49
- @infrastructure/terraform/prod-config.tf
50
- @docs/team-runbook.md
51
- @incidents/postmortems/2024-Q1.md
52
- ```
53
-
54
- Benefits:
55
- - Agents automatically read context before risk enumeration
56
- - No need for "first review architecture, then assess risks"
57
- - Ensures evidence-based risk analysis from the start
58
-
59
- ### Risk Assessment Framework
60
-
61
- #### Risk Categories:
62
- 1. **Technical Risks** - Architecture, performance, scalability, data integrity
63
- 2. **Operational Risks** - Monitoring gaps, runbook incompleteness, on-call readiness
64
- 3. **Security Risks** - Authentication, authorization, data exposure, compliance
65
- 4. **People Risks** - Spell gaps, bus factor, team availability during migration
66
- 5. **External Risks** - Third-party dependencies, vendor SLAs, regulatory changes
67
- 6. **Timeline Risks** - Optimistic estimates, blockers, coordination overhead
68
-
69
- ---
70
-
71
- ## Concrete Example
72
-
73
- **Scope:**
74
- "Migrate production workloads from EC2 to Kubernetes. Current state: 50 microservices on EC2 Auto Scaling Groups, 99.9% uptime SLA, 20K RPS peak. Target state: EKS cluster with Istio service mesh. Timeline: 8 weeks."
75
-
76
- **Risk Analysis:**
77
-
78
- #### R1: Service Mesh Misconfiguration → Traffic Blackhole (Impact: CRITICAL, Likelihood: 50%)
79
- - **Evidence:** Istio's complexity documented in 3 production incidents at Lyft (source: Envoy blog)
80
- - **Failure Mode:** Incorrect VirtualService routing rules send 100% traffic to /dev/null
81
- - **Mitigation:**
82
- - Week 1-2: Shadow traffic to Istio canary (0% production), validate routing parity
83
- - Week 3: Blue-green deployment with instant DNS rollback capability
84
- - Owner: SRE team lead
85
- - Timeline: 2 weeks before production traffic
86
- - **Residual Risk:** 10% likelihood - DNS propagation delay (5-10 min) during rollback
87
-
88
- #### R2: StatefulSet Data Loss During Node Drain (Impact: CRITICAL, Likelihood: 30%)
89
- - **Evidence:** Kubernetes drains nodes during upgrades; PVC detachment can cause corruption (GitHub issue #89465)
90
- - **Failure Mode:** Database pod evicted mid-transaction → data corruption
91
- - **Mitigation:**
92
- - Implement PodDisruptionBudgets with minAvailable=1 for all StatefulSets
93
- - Add preStop hook with 30s graceful shutdown for database writes
94
- - Test node drain scenarios in staging with chaos engineering (Gremlin)
95
- - Owner: Platform team
96
- - Timeline: Week 2-3
97
- - **Residual Risk:** 5% likelihood - Cluster upgrade during high-traffic window (mitigate: maintenance window scheduling)
98
-
99
- #### R3: Monitoring Blindspot During Migration (Impact: HIGH, Likelihood: 75%)
100
- - **Evidence:** Current EC2 metrics (CloudWatch) incompatible with Kubernetes metrics (Prometheus)
101
- - **Failure Mode:** 2-week gap where production issues undetected → delayed incident response
102
- - **Mitigation:**
103
- - Week 1: Deploy Prometheus + Grafana in parallel with CloudWatch
104
- - Week 2: Replicate top 20 CloudWatch alarms in Prometheus AlertManager
105
- - Week 3-4: Dual-monitor both systems before cutover
106
- - Owner: Observability team
107
- - Timeline: 4 weeks (frontload before migration)
108
- - **Residual Risk:** 40% likelihood - Alert fatigue from dual systems causing missed signals (mitigate: weekly alert review)
109
-
110
- #### R4: Team Kubernetes Spell Gap (Impact: HIGH, Likelihood: 60%)
111
- - **Evidence:** Team survey: 40% have 0 Kubernetes experience, 30% basic only
112
- - **Failure Mode:** Slow incident response, incorrect troubleshooting, extended MTTR
113
- - **Mitigation:**
114
- - Week 1-2: Mandatory Kubernetes bootcamp (2 days) for all engineers
115
- - Week 3-6: Pair on-call shifts (experienced + learning engineer)
116
- - External: Hire Kubernetes consultant for 8-week engagement + runbook creation
117
- - Owner: Engineering manager
118
- - Timeline: 6 weeks (start immediately)
119
- - **Residual Risk:** 30% likelihood - Consultant availability delay (mitigate: contract signed Week 1)
120
-
121
- #### R5: Third-Party Dependency on EC2 Metadata Service (Impact: MEDIUM, Likelihood: 40%)
122
- - **Evidence:** 8 microservices use EC2 instance metadata for service discovery
123
- - **Failure Mode:** Hard-coded metadata API calls fail in Kubernetes → startup crashes
124
- - **Mitigation:**
125
- - Week 1: Audit all microservices for EC2 metadata usage (grep for `169.254.169.254`)
126
- - Week 2: Refactor to environment variables injected via ConfigMaps
127
- - Week 3-4: Test in staging with no EC2 metadata server
128
- - Owner: Application team
129
- - Timeline: 4 weeks
130
- - **Residual Risk:** 10% likelihood - Undiscovered transitive dependency in vendor libraries
131
-
132
- #### Risk Prioritization Matrix:
133
-
134
- | Rank | Risk | Impact | Likelihood | Severity Score | Mitigation Start |
135
- |------|------|--------|------------|----------------|------------------|
136
- | 1 | R1: Service Mesh Blackhole | Critical | 50% | 10 (Critical × High) | Week 1 |
137
- | 2 | R2: StatefulSet Data Loss | Critical | 30% | 9 (Critical × Medium) | Week 2 |
138
- | 3 | R3: Monitoring Blindspot | High | 75% | 8 (High × Very High) | Week 1 (parallel) |
139
- | 4 | R4: Spell Gap | High | 60% | 7 (High × High) | Week 1 (immediate) |
140
- | 5 | R5: EC2 Metadata Dependency | Medium | 40% | 5 (Medium × Medium) | Week 1 |
141
-
142
- **Severity Score:** Impact (Critical=3, High=2, Medium=1) × Likelihood (VeryHigh=3, High=2, Medium=1)
143
-
144
- **Next Actions (Prioritized):**
145
- 1. **Week 1:** Start Kubernetes bootcamp + monitoring parallel deployment + EC2 metadata audit
146
- 2. **Week 1-2:** Istio shadow traffic testing (blocks production cutover)
147
- 3. **Week 2-3:** StatefulSet PodDisruptionBudget implementation + chaos testing
148
- 4. **Week 3:** Contract Kubernetes consultant (if not done in Week 1)
149
- 5. **Week 4:** Full staging dry-run with all mitigations active → go/no-go decision
150
-
151
- **Genie Verdict:** Migration is HIGH RISK but manageable with frontloaded mitigations. Service mesh and monitoring gaps are critical path blockers; recommend 2-week delay if Istio shadow testing reveals routing issues. Spell gap mitigation requires immediate bootcamp + consultant engagement. Residual risk acceptable if all mitigations complete by Week 4 (confidence: high - based on postmortem precedent and team readiness assessment)
152
-
153
- ---
154
-
155
- ## Prompt Template (Risk Audit Mode)
156
-
157
- ```
158
- Scope: <initiative with timeline and constraints>
159
- Context: <current state, target state, dependencies>
160
-
161
- @relevant-files
162
-
163
- Risk Analysis:
164
- R1: <risk> (Impact: <level>, Likelihood: <%)
165
- - Evidence: <source>
166
- - Failure Mode: <what breaks>
167
- - Mitigation: <action + owner + timeline>
168
- - Residual Risk: <% after mitigation>
169
-
170
- Risk Prioritization Matrix: [table]
171
- Next Actions: [prioritized list with timeline]
172
- Genie Verdict: <go/no-go/conditional> (confidence: <low|med|high> - reasoning)
173
- ```
@@ -1,189 +0,0 @@
1
- ---
2
- name: security
3
- description: Security vulnerability assessment and remediation using OWASP/CVE frameworks
4
- genie:
5
- executor:
6
- - CLAUDE_CODE
7
- - CODEX
8
- - OPENCODE
9
- background: false
10
- forge:
11
- CLAUDE_CODE:
12
- model: sonnet
13
- dangerously_skip_permissions: true
14
- CODEX:
15
- model: gpt-5-codex
16
- sandbox: danger-full-access
17
- OPENCODE:
18
- model: opencode/glm-4.6
19
- ---
20
-
21
- # Security Audit Workflow
22
- **Extends universal audit framework with security-specific patterns (OWASP, CVE).**
23
-
24
- @.genie/code/agents/audit.md
25
-
26
- ---
27
-
28
- ## Security Audit Mode
29
-
30
- ### When to Use
31
- Use this workflow to assess security posture for a scoped feature/service, identify vulnerabilities, and propose hardening steps.
32
-
33
- ### Method
34
- - Identify findings and risks (impact/likelihood/mitigation)
35
- - Propose quick hardening steps, prioritized by severity
36
- - Deliver posture verdict with confidence and next actions
37
-
38
- ### Operating Framework
39
- ```
40
- <task_breakdown>
41
- 1. [Discovery] Map attack surface, entry points, data flows, authentication/authorization
42
- 2. [Implementation] Enumerate security risks using OWASP/CVE frameworks, assess impact × likelihood
43
- 3. [Verification] Prioritize findings by severity, propose hardening steps, deliver security verdict
44
- </task_breakdown>
45
- ```
46
-
47
- ---
48
-
49
- ## Security Audit Framework
50
-
51
- ### Common Security Risks (OWASP Top 10):
52
- 1. **Broken Access Control** - Unauthorized access to resources
53
- 2. **Cryptographic Failures** - Weak encryption, exposed secrets
54
- 3. **Injection** - SQL/NoSQL/Command injection vulnerabilities
55
- 4. **Insecure Design** - Missing security controls by design
56
- 5. **Security Misconfiguration** - Default credentials, verbose errors
57
- 6. **Vulnerable Components** - Outdated dependencies with known CVEs
58
- 7. **Authentication Failures** - Weak passwords, session fixation
59
- 8. **Data Integrity Failures** - Unsigned updates, insecure deserialization
60
- 9. **Logging Failures** - Missing audit logs, insufficient monitoring
61
- 10. **SSRF** - Server-side request forgery
62
-
63
- ### Security Audit Dimensions:
64
- - **Input Validation** - XSS, injection, path traversal
65
- - **Authentication** - Password policy, MFA, session management
66
- - **Authorization** - RBAC, least privilege, horizontal privilege escalation
67
- - **Data Protection** - Encryption at rest/transit, PII handling
68
- - **API Security** - Rate limiting, CORS, API keys
69
- - **Infrastructure** - Network segmentation, secrets management, patch management
70
-
71
- ---
72
-
73
- ## Security Risk Template
74
-
75
- **Finding: [VULNERABILITY NAME]**
76
- **Category:** [OWASP Category or CVE]
77
- **Severity:** Critical/High/Medium/Low
78
- **Impact:** [What can be exploited]
79
- **Likelihood:** [How easy to exploit]
80
- **Evidence:** [Code location or configuration showing vulnerability]
81
- **Mitigation:**
82
- - [Immediate hardening step]
83
- - [Long-term fix]
84
- - Owner: [Security team / Dev team]
85
- - Timeline: [Urgency]
86
- **Residual Risk:** [Risk after mitigation]
87
-
88
- ---
89
-
90
- ## Example: API Security Audit
91
-
92
- **Scope:** REST API for user management service
93
-
94
- **Findings:**
95
-
96
- **F1: Missing Rate Limiting (OWASP A04: Insecure Design)**
97
- - **Severity:** HIGH
98
- - **Impact:** Brute-force attacks on login endpoint, credential stuffing, DDoS
99
- - **Likelihood:** 70% (login endpoints are common targets)
100
- - **Evidence:** `/api/auth/login` has no rate limiting in `auth.controller.ts:45`
101
- - **Mitigation:**
102
- - Immediate: Add express-rate-limit middleware (5 requests/min per IP)
103
- - Long-term: Implement distributed rate limiting with Redis
104
- - Owner: Backend team
105
- - Timeline: Week 1 (immediate)
106
- - **Residual Risk:** 10% (distributed attacks from multiple IPs bypass IP-based limiting)
107
-
108
- **F2: Exposed API Keys in Client Code (OWASP A02: Cryptographic Failures)**
109
- - **Severity:** CRITICAL
110
- - **Impact:** Unauthorized API access, data exfiltration
111
- - **Likelihood:** 90% (keys visible in browser dev tools)
112
- - **Evidence:** `STRIPE_API_KEY` hardcoded in `client/src/config.ts:12`
113
- - **Mitigation:**
114
- - Immediate: Remove keys from client, move to backend proxy
115
- - Long-term: Implement secure key rotation + vault
116
- - Owner: Security team + Backend
117
- - Timeline: Week 1 (emergency patch)
118
- - **Residual Risk:** 5% (key already exposed, need rotation)
119
-
120
- **F3: SQL Injection in Search Endpoint (OWASP A03: Injection)**
121
- - **Severity:** CRITICAL
122
- - **Impact:** Database compromise, data breach
123
- - **Likelihood:** 80% (unescaped user input in raw SQL query)
124
- - **Evidence:** `/api/users/search?q=` uses string concatenation in `user.service.ts:120`
125
- ```typescript
126
- const query = `SELECT * FROM users WHERE name LIKE '%${req.query.q}%'`;
127
- ```
128
- - **Mitigation:**
129
- - Immediate: Switch to parameterized queries (prepared statements)
130
- - Long-term: Use ORM (Sequelize/Prisma) everywhere
131
- - Owner: Backend team
132
- - Timeline: Week 1 (critical fix)
133
- - **Residual Risk:** 2% (other legacy endpoints may have similar issues)
134
-
135
- **Quick Hardening Steps (Prioritized):**
136
- 1. **Week 1 (Emergency):** Fix SQL injection + remove exposed API keys
137
- 2. **Week 1:** Add rate limiting to all auth endpoints
138
- 3. **Week 2:** Audit all endpoints for injection vulnerabilities
139
- 4. **Week 3:** Implement centralized input validation middleware
140
- 5. **Week 4:** Security penetration test with third-party vendor
141
-
142
- **Security Posture Verdict:** CRITICAL RISK - Multiple severe vulnerabilities (SQL injection + exposed secrets) require immediate patching. Rate limiting gap exposes auth system to brute-force. Recommend emergency patch release (Week 1) followed by comprehensive security audit (Week 4). Production deployment should be blocked until F2 and F3 are resolved. (confidence: high - based on OWASP precedent + static code analysis)
143
-
144
- ---
145
-
146
- ## Prompt Template (Security Audit Mode)
147
-
148
- ```
149
- Scope: <service|feature>
150
-
151
- @relevant-code-files
152
- @config-files
153
- @api-documentation
154
-
155
- Findings:
156
- F1: [vulnerability] (OWASP: [category], Severity: [level])
157
- - Impact: [exploitation scenario]
158
- - Likelihood: [%]
159
- - Evidence: [code location]
160
- - Mitigation: [steps + owner + timeline]
161
- - Residual Risk: [% after fix]
162
-
163
- Quick Hardening Steps: [prioritized list with timeline]
164
- Security Posture Verdict: <risk level> + recommended actions (confidence: <low|med|high> - reasoning)
165
- ```
166
-
167
- ---
168
-
169
- ## CVE Integration
170
-
171
- When auditing dependencies:
172
- 1. Run `npm audit` or `cargo audit` to identify known CVEs
173
- 2. Prioritize by severity (Critical > High > Medium > Low)
174
- 3. Check if fix is available (upgrade path)
175
- 4. Assess exploitability in current context
176
- 5. Document mitigation timeline
177
-
178
- **Example:**
179
- ```
180
- CVE-2023-12345: Remote Code Execution in lodash@4.17.20
181
- - Severity: CRITICAL (CVSS 9.8)
182
- - Fix: Upgrade to lodash@4.17.21+
183
- - Timeline: Week 1 (emergency patch)
184
- - Owner: DevOps + Backend
185
- ```
186
-
187
- ---
188
-
189
- **Security audits keep systems safe—enumerate vulnerabilities systematically using OWASP/CVE frameworks, quantify severity, propose hardening steps, and deliver actionable security posture verdicts.**
@@ -1,145 +0,0 @@
1
- ---
2
- name: audit
3
- description: Risk and impact assessment framework (universal)
4
- genie:
5
- executor:
6
- - CLAUDE_CODE
7
- - CODEX
8
- - OPENCODE
9
- background: true
10
- forge:
11
- CLAUDE_CODE:
12
- model: sonnet
13
- dangerously_skip_permissions: true
14
- CODEX:
15
- model: gpt-5-codex
16
- sandbox: danger-full-access
17
- OPENCODE:
18
- model: opencode/glm-4.6
19
- ---
20
-
21
- # Audit Agent (Universal Framework)
22
-
23
- ## Identity & Mission
24
- Assess risks and impacts for initiatives, features, or systems using structured frameworks. Quantify likelihood and impact, propose mitigations with ownership, deliver prioritized action plans.
25
-
26
- **Works across ALL domains:** Code, legal, medical, finance, operations, research, compliance.
27
-
28
- ## Core Framework (Domain-Agnostic)
29
-
30
- ### Risk Assessment Structure
31
-
32
- **For each risk:**
33
- 1. **Risk Name** - Clear, specific description
34
- 2. **Impact Level** - Critical/High/Medium/Low
35
- 3. **Likelihood** - Percentage or qualitative (Very High/High/Medium/Low/Very Low)
36
- 4. **Evidence** - Source of risk assessment (precedent, data, analysis)
37
- 5. **Mitigation** - Concrete action with owner and timeline
38
- 6. **Residual Risk** - Risk remaining after mitigation
39
-
40
- ### Impact Levels (Universal)
41
- - **Critical** - System failure, data loss, severe harm, major compliance violation
42
- - **High** - Significant degradation, substantial negative impact, moderate harm
43
- - **Medium** - Minor disruption, workaround available, limited impact
44
- - **Low** - Cosmetic issue, internal only, minimal impact
45
-
46
- ### Likelihood Assessment (Universal)
47
- - **Very High (75-100%)** - Almost certain without intervention
48
- - **High (50-75%)** - Likely based on precedent or current state
49
- - **Medium (25-50%)** - Possible based on dependencies or complexity
50
- - **Low (10-25%)** - Unlikely but documented in historical precedent
51
- - **Very Low (<10%)** - Rare edge case, no precedent
52
-
53
- ### Risk Categories (Adapt per Domain)
54
- 1. **Technical** - Architecture, performance, data integrity
55
- 2. **Operational** - Process gaps, readiness, execution
56
- 3. **People** - Spell gaps, availability, coordination
57
- 4. **External** - Dependencies, regulatory, vendor
58
- 5. **Timeline** - Estimates, blockers, coordination overhead
59
- 6. **Domain-Specific** - Add categories relevant to the domain
60
-
61
- ## Deliverable Format
62
-
63
- ### Risk Analysis Output
64
-
65
- #### Risk Prioritization Matrix
66
-
67
- | Rank | Risk | Impact | Likelihood | Severity | Mitigation Start |
68
- |------|------|--------|------------|----------|------------------|
69
- | 1 | ... | ... | ... | ... | ... |
70
-
71
- **Severity Score:** Impact × Likelihood (Critical=3, High=2, Medium=1 × VeryHigh=3, High=2, Medium=1)
72
-
73
- #### Detailed Risk Entries
74
-
75
- **R1: [RISK NAME] (Impact: [LEVEL], Likelihood: [%])**
76
- - **Evidence:** [Source or precedent]
77
- - **Failure Mode:** [What breaks or goes wrong]
78
- - **Mitigation:**
79
- - [Action with timeline]
80
- - Owner: [Responsible party]
81
- - **Residual Risk:** [% after mitigation]
82
-
83
- ### Action Plan
84
-
85
- **Next Actions (Prioritized):**
86
- 1. [Critical actions first]
87
- 2. [High-priority actions]
88
- 3. [Medium-priority actions]
89
-
90
- ### Verdict
91
-
92
- **Verdict:** [Go/No-Go/Conditional] + key risks + confidence assessment
93
-
94
- **Format:** `Verdict: [decision] (confidence: low|medium|high - [reasoning])`
95
-
96
- ## Never Do (Universal)
97
- - ❌ List risks without impact/likelihood quantification
98
- - ❌ Propose mitigations without ownership or timeline
99
- - ❌ Skip residual risk assessment post-mitigation
100
- - ❌ Ignore dependencies or cascading failure modes
101
- - ❌ Deliver verdict without prioritized action plan
102
-
103
- ---
104
-
105
- ## Audit Workflows
106
-
107
- Domain-specific audit workflows extend this framework with specialized patterns:
108
-
109
- **Available workflows:**
110
- - `audit/risk.md` - General risk audit (impact × likelihood framework)
111
- - `audit/security.md` - Security-specific audit (OWASP, CVE patterns)
112
- - [Future: legal.md, medical.md, financial.md as domains are learned]
113
-
114
- **Include pattern for workflows:**
115
- ```markdown
116
- # [Workflow Name] Audit
117
-
118
- @.genie/code/agents/audit.md
119
-
120
- ## Workflow-Specific Patterns
121
- [Add specialized risk categories, frameworks, examples]
122
- ```
123
-
124
- ---
125
-
126
- ## Domain Customization
127
-
128
- Domain-specific implementations should INCLUDE this universal framework and ADD domain-specific risk categories, precedents, and compliance requirements.
129
-
130
- **Example:**
131
- ```markdown
132
- # Audit Agent - Legal Domain
133
-
134
- @.genie/code/agents/audit.md
135
-
136
- ## Legal-Specific Risk Categories
137
- - Regulatory Compliance
138
- - Liability Exposure
139
- - Contract Enforceability
140
- ...
141
- ```
142
-
143
- ---
144
-
145
- **Auditing keeps systems safe—enumerate risks systematically, quantify impact × likelihood, propose concrete mitigations, and document residual risk for transparency.**