codex-genesis-harness 0.1.1 → 0.1.4

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 (180) hide show
  1. package/.codebase/ARCHITECTURE_REVIEW_COMPLETE.md +216 -0
  2. package/.codebase/CURRENT_STATE.md +2 -0
  3. package/.codebase/DOMAIN_MODELS.md +5 -3
  4. package/.codebase/FILE_NAMING_CLARIFICATION.md +161 -0
  5. package/.codebase/HARNESS_COMPLETENESS_AUDIT.md +613 -0
  6. package/.codebase/IMPLEMENTATION_COMPLETE.md +429 -0
  7. package/.codebase/IMPLEMENTATION_HANDOFF.md +351 -0
  8. package/.codebase/IMPROVEMENTS_SUMMARY.md +419 -0
  9. package/.codebase/PHASE3_SKILLS_NAMING_COMPLETE.md +292 -0
  10. package/.codebase/PHASE_DEPENDENCY_MAP.md +486 -0
  11. package/.codebase/QUICK_START_SPEC_IMPACT.md +456 -0
  12. package/.codebase/README.md +139 -0
  13. package/.codebase/RECOVERY_POINTS.md +438 -0
  14. package/.codex/skills/genesis-api-sync/SKILL.md +354 -0
  15. package/.codex/skills/genesis-api-sync/agents/openai.yaml +7 -0
  16. package/.codex/skills/genesis-api-sync/checklists/api-sync-checklist.md +101 -0
  17. package/.codex/skills/genesis-api-sync/examples/example.md +68 -0
  18. package/.codex/skills/genesis-api-sync/templates/api-change-template.md +257 -0
  19. package/.codex/skills/genesis-debug-guide/SKILL.md +479 -0
  20. package/.codex/skills/genesis-debug-guide/agents/openai.yaml +7 -0
  21. package/.codex/skills/genesis-debug-guide/checklists/flaky-test-investigation.md +339 -0
  22. package/.codex/skills/genesis-debug-guide/checklists/production-bug-debug.md +210 -0
  23. package/.codex/skills/genesis-debug-guide/checklists/test-failure-debug.md +158 -0
  24. package/.codex/skills/genesis-debug-guide/examples/example.md +48 -0
  25. package/.codex/skills/genesis-debug-guide/observability/debug-commands.md +365 -0
  26. package/.codex/skills/genesis-debug-guide/playbooks/unit-test-failures.md +289 -0
  27. package/.codex/skills/genesis-debug-guide/templates/debug-investigation-log.md +288 -0
  28. package/.codex/skills/genesis-docs-automation/SKILL.md +1003 -0
  29. package/.codex/skills/genesis-docs-automation/agents/openai.yaml +7 -0
  30. package/.codex/skills/genesis-docs-automation/checklists/docs-validation.md +359 -0
  31. package/.codex/skills/genesis-docs-automation/checklists/spec-alignment.md +312 -0
  32. package/.codex/skills/genesis-docs-automation/examples/example.md +59 -0
  33. package/.codex/skills/genesis-docs-automation/observability/docs-tracking.md +382 -0
  34. package/.codex/skills/genesis-docs-automation/playbooks/auto-update-flow.md +851 -0
  35. package/.codex/skills/genesis-docs-automation/playbooks/changelog-generation.md +491 -0
  36. package/.codex/skills/genesis-docs-automation/templates/changelog-entry-template.md +187 -0
  37. package/.codex/skills/genesis-docs-automation/templates/handoff-template.md +297 -0
  38. package/.codex/skills/genesis-harness/SKILL.md +734 -82
  39. package/.codex/skills/genesis-harness/checklists/bug-fix-qa.md +169 -0
  40. package/.codex/skills/genesis-harness/checklists/new-feature-qa.md +157 -0
  41. package/.codex/skills/genesis-harness/checklists/refactor-qa.md +216 -0
  42. package/.codex/skills/genesis-harness/checklists/requirements-validation.md +211 -0
  43. package/.codex/skills/genesis-harness/resources/change-impact-matrix-template.md +204 -0
  44. package/.codex/skills/genesis-harness/resources/foundation-phase-template.md +131 -0
  45. package/.codex/skills/genesis-harness/resources/phase-00-foundation-template.md +76 -0
  46. package/.codex/skills/genesis-harness/resources/post-implementation-guide.md +347 -0
  47. package/.codex/skills/genesis-harness/scripts/check-architecture-boundaries.sh +23 -23
  48. package/.codex/skills/genesis-harness/scripts/check-docs-sync.sh +24 -24
  49. package/.codex/skills/genesis-harness/scripts/check-no-debug-logs.sh +21 -21
  50. package/.codex/skills/genesis-harness/scripts/check-required-planning-files.sh +46 -46
  51. package/.codex/skills/genesis-harness/scripts/check-spec-changelog.sh +24 -24
  52. package/.codex/skills/genesis-harness/scripts/check-task-tracking.sh +25 -25
  53. package/.codex/skills/genesis-harness/scripts/compact-context.sh +54 -0
  54. package/.codex/skills/genesis-harness/scripts/create-adr.sh +74 -74
  55. package/.codex/skills/genesis-harness/scripts/create-bug.sh +160 -160
  56. package/.codex/skills/genesis-harness/scripts/create-feature.sh +217 -217
  57. package/.codex/skills/genesis-harness/scripts/detect-stack.sh +26 -26
  58. package/.codex/skills/genesis-harness/scripts/init-planning.sh +750 -719
  59. package/.codex/skills/genesis-harness/scripts/list-changed-files.sh +12 -12
  60. package/.codex/skills/genesis-harness/scripts/offload-log.sh +72 -0
  61. package/.codex/skills/genesis-harness/scripts/run-verification.sh +47 -47
  62. package/.codex/skills/genesis-harness/scripts/run-verify-loop.sh +75 -0
  63. package/.codex/skills/genesis-harness/scripts/update-state.sh +33 -33
  64. package/.codex/skills/genesis-harness-engineering/SKILL.md +159 -0
  65. package/.codex/skills/genesis-harness-engineering/checklists/checklist.md +48 -0
  66. package/.codex/skills/genesis-harness-engineering/examples/example.md +57 -0
  67. package/.codex/skills/genesis-harness-engineering/playbooks/harness-evolution.md +99 -0
  68. package/.codex/skills/genesis-harness-engineering/templates/harness-change-template.md +37 -0
  69. package/.codex/skills/genesis-observability-automation/SKILL.md +382 -0
  70. package/.codex/skills/genesis-observability-automation/agents/openai.yaml +7 -0
  71. package/.codex/skills/genesis-observability-automation/examples/example.md +86 -0
  72. package/.codex/skills/genesis-performance-profiling/SKILL.md +510 -0
  73. package/.codex/skills/genesis-performance-profiling/agents/openai.yaml +6 -0
  74. package/.codex/skills/genesis-performance-profiling/checklists/optimization-verification.md +199 -0
  75. package/.codex/skills/genesis-performance-profiling/checklists/performance-baseline.md +183 -0
  76. package/.codex/skills/genesis-performance-profiling/examples/example.md +234 -0
  77. package/.codex/skills/genesis-performance-profiling/observability/performance-tracking.md +202 -0
  78. package/.codex/skills/genesis-performance-profiling/playbooks/load-testing-orchestration.md +593 -0
  79. package/.codex/skills/genesis-performance-profiling/playbooks/profiling-playbook.md +601 -0
  80. package/.codex/skills/genesis-performance-profiling/templates/load-test-config-template.md +428 -0
  81. package/.codex/skills/genesis-performance-profiling/templates/performance-report-template.md +238 -0
  82. package/.codex/skills/genesis-release-orchestration/SKILL.md +653 -0
  83. package/.codex/skills/genesis-release-orchestration/agents/openai.yaml +7 -0
  84. package/.codex/skills/genesis-release-orchestration/checklists/post-deployment-verification.md +274 -0
  85. package/.codex/skills/genesis-release-orchestration/checklists/pre-release-validation.md +220 -0
  86. package/.codex/skills/genesis-release-orchestration/examples/example.md +78 -0
  87. package/.codex/skills/genesis-release-orchestration/observability/release-tracking.md +253 -0
  88. package/.codex/skills/genesis-release-orchestration/playbooks/canary-deployment-orchestration.md +472 -0
  89. package/.codex/skills/genesis-release-orchestration/playbooks/semantic-versioning-automation.md +494 -0
  90. package/.codex/skills/genesis-release-orchestration/templates/deployment-strategy-template.md +303 -0
  91. package/.codex/skills/genesis-release-orchestration/templates/release-runbook-template.md +420 -0
  92. package/.codex/skills/genesis-research-first/SKILL.md +237 -0
  93. package/.codex/skills/genesis-research-first/agents/openai.yaml +7 -0
  94. package/.codex/skills/genesis-research-first/examples/example.md +85 -0
  95. package/.codex/skills/genesis-spec-propagation/SKILL.md +534 -0
  96. package/.codex/skills/genesis-spec-propagation/agents/openai.yaml +7 -0
  97. package/.codex/skills/genesis-spec-propagation/checklists/phase-update-verification.md +384 -0
  98. package/.codex/skills/genesis-spec-propagation/checklists/spec-change-detection.md +257 -0
  99. package/.codex/skills/genesis-spec-propagation/examples/example.md +63 -0
  100. package/.codex/skills/genesis-spec-propagation/observability/propagation-tracking.md +373 -0
  101. package/.codex/skills/genesis-spec-propagation/playbooks/breaking-change-propagation.md +692 -0
  102. package/.codex/skills/genesis-spec-propagation/playbooks/feature-change-propagation.md +434 -0
  103. package/.codex/skills/genesis-spec-propagation/templates/migration-guide-template.md +407 -0
  104. package/.codex/skills/spec-impact-engine/SKILL.md +504 -0
  105. package/.codex/skills/spec-impact-engine/agents/openai.yaml +7 -0
  106. package/.codex/skills/spec-impact-engine/detect-spec-changes.sh +262 -0
  107. package/.codex/skills/spec-impact-engine/examples/example.md +98 -0
  108. package/.codex/skills/spec-impact-engine/templates/impact-report.md +248 -0
  109. package/.codex/skills/spec-impact-engine/templates/migration-guide.md +223 -0
  110. package/.codex-plugin/plugin.json +1 -1
  111. package/README.EN.md +719 -0
  112. package/README.VI.md +712 -0
  113. package/README.md +261 -107
  114. package/VERSION +1 -1
  115. package/bin/genesis-harness.js +20 -11
  116. package/package.json +1 -1
  117. package/scripts/README.md +342 -0
  118. package/scripts/compact-context.sh +54 -0
  119. package/scripts/detect-changes.sh +152 -0
  120. package/scripts/install.sh +50 -41
  121. package/scripts/offload-log.sh +72 -0
  122. package/scripts/run-evals.sh +70 -43
  123. package/scripts/run-verify-loop.sh +75 -0
  124. package/scripts/uninstall.sh +52 -43
  125. package/scripts/verify.sh +165 -73
  126. package/.codex/skills/harness-engineering-skill/SKILL.md +0 -45
  127. package/.codex/skills/harness-engineering-skill/checklists/checklist.md +0 -8
  128. package/.codex/skills/harness-engineering-skill/examples/example.md +0 -4
  129. package/.codex/skills/harness-engineering-skill/templates/harness-change-template.md +0 -8
  130. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/SKILL.md +0 -0
  131. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/agents/openai.yaml +0 -0
  132. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/checklists/checklist.md +0 -0
  133. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/examples/example.md +0 -0
  134. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/templates/provider-contract-template.md +0 -0
  135. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/SKILL.md +0 -0
  136. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/agents/openai.yaml +0 -0
  137. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/checklists/checklist.md +0 -0
  138. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/examples/example.md +0 -0
  139. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/templates/api-contract-template.md +0 -0
  140. /package/.codex/skills/{architecture-skill → genesis-architecture}/SKILL.md +0 -0
  141. /package/.codex/skills/{architecture-skill → genesis-architecture}/agents/openai.yaml +0 -0
  142. /package/.codex/skills/{architecture-skill → genesis-architecture}/checklists/checklist.md +0 -0
  143. /package/.codex/skills/{architecture-skill → genesis-architecture}/examples/example.md +0 -0
  144. /package/.codex/skills/{architecture-skill → genesis-architecture}/templates/architecture-decision-template.md +0 -0
  145. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/SKILL.md +0 -0
  146. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/agents/openai.yaml +0 -0
  147. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/checklists/checklist.md +0 -0
  148. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/examples/example.md +0 -0
  149. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/templates/map-update-template.md +0 -0
  150. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/SKILL.md +0 -0
  151. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/agents/openai.yaml +0 -0
  152. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/checklists/checklist.md +0 -0
  153. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/examples/example.md +0 -0
  154. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/templates/design-spec-template.md +0 -0
  155. /package/.codex/skills/{docs-skill → genesis-docs}/SKILL.md +0 -0
  156. /package/.codex/skills/{docs-skill → genesis-docs}/agents/openai.yaml +0 -0
  157. /package/.codex/skills/{docs-skill → genesis-docs}/checklists/checklist.md +0 -0
  158. /package/.codex/skills/{docs-skill → genesis-docs}/examples/example.md +0 -0
  159. /package/.codex/skills/{docs-skill → genesis-docs}/templates/docs-update-template.md +0 -0
  160. /package/.codex/skills/{harness-engineering-skill → genesis-harness-engineering}/agents/openai.yaml +0 -0
  161. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/SKILL.md +0 -0
  162. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/agents/openai.yaml +0 -0
  163. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/checklists/checklist.md +0 -0
  164. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/examples/example.md +0 -0
  165. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/templates/orchestration-template.md +0 -0
  166. /package/.codex/skills/{planning-skill → genesis-planning}/SKILL.md +0 -0
  167. /package/.codex/skills/{planning-skill → genesis-planning}/agents/openai.yaml +0 -0
  168. /package/.codex/skills/{planning-skill → genesis-planning}/checklists/checklist.md +0 -0
  169. /package/.codex/skills/{planning-skill → genesis-planning}/examples/example.md +0 -0
  170. /package/.codex/skills/{planning-skill → genesis-planning}/templates/plan-template.md +0 -0
  171. /package/.codex/skills/{release-skill → genesis-release}/SKILL.md +0 -0
  172. /package/.codex/skills/{release-skill → genesis-release}/agents/openai.yaml +0 -0
  173. /package/.codex/skills/{release-skill → genesis-release}/checklists/checklist.md +0 -0
  174. /package/.codex/skills/{release-skill → genesis-release}/examples/example.md +0 -0
  175. /package/.codex/skills/{release-skill → genesis-release}/templates/release-checklist-template.md +0 -0
  176. /package/.codex/skills/{research-skill → genesis-research}/SKILL.md +0 -0
  177. /package/.codex/skills/{research-skill → genesis-research}/agents/openai.yaml +0 -0
  178. /package/.codex/skills/{research-skill → genesis-research}/checklists/checklist.md +0 -0
  179. /package/.codex/skills/{research-skill → genesis-research}/examples/example.md +0 -0
  180. /package/.codex/skills/{research-skill → genesis-research}/templates/research-note-template.md +0 -0
@@ -0,0 +1,510 @@
1
+ ---
2
+ name: genesis-performance-profiling
3
+ description: "Automate performance baseline measurement, profiling playbook generation, load test orchestration, and before/after regression comparison. Use when performance matters or regressions are suspected."
4
+ ---
5
+
6
+ # genesis-performance-profiling
7
+
8
+ ## Purpose
9
+
10
+ The `genesis-performance-profiling` skill automates the full lifecycle of performance engineering for software systems. It captures quantified baselines (p50/p95/p99 latency, throughput, error rate, memory), generates language-specific profiling playbooks (Node.js, Python, Go), produces load test configurations for k6, Artillery, and Locust, performs before/after regression detection with statistical confidence, and generates prioritized optimization recommendations.
11
+
12
+ This skill transforms performance work from ad-hoc investigation into a repeatable, evidence-based engineering discipline. Every phase produces artifacts that feed the next, creating a closed loop of measure → profile → optimize → validate.
13
+
14
+ **Core philosophy**: You cannot optimize what you have not measured. You cannot trust improvements without a before/after comparison against a stable baseline. Every performance claim must be backed by data captured under controlled conditions.
15
+
16
+ ---
17
+
18
+ ## When to use
19
+
20
+ Use `genesis-performance-profiling` when:
21
+
22
+ - A new service or endpoint is approaching production and you need an established baseline before the first release.
23
+ - A pull request introduces changes to hot paths (database queries, serialization, caching, network calls) and regression detection is required before merge.
24
+ - Users or monitors are reporting latency increases, timeout spikes, or memory growth over time.
25
+ - You are planning a scaling event (traffic surge, new region, batch job expansion) and need to know current headroom.
26
+ - A post-mortem identified a performance incident and you need to reproduce, measure, and fix the root cause with evidence.
27
+ - Sprint planning includes performance-related tickets and you need load test specifications, thresholds, and acceptance criteria defined before implementation starts.
28
+ - You are evaluating competing implementation strategies (e.g., Redis vs in-process cache) and need a fair comparison under realistic load.
29
+ - Continuous integration pipelines need performance gates (p95 < N ms) enforced automatically on every merge.
30
+ - An SLA or SLO is at risk and you need to quantify how far off the system currently is.
31
+
32
+ ---
33
+
34
+ ## When NOT to use
35
+
36
+ Do NOT use `genesis-performance-profiling` when:
37
+
38
+ - The system under test has no stable environment for isolation. Running profiling against shared staging with random background noise produces unreliable baselines. Fix the environment first.
39
+ - The feature is a pure UI or purely declarative config change with no server-side hot path impact. Use `genesis-ui-ux-test` instead.
40
+ - You need to profile security properties (rate limiting correctness, auth bypass). Use the API contract skill for correctness, not this skill.
41
+ - You only need a one-off micro-benchmark of a single pure function with no I/O. Use language-native benchmarking (e.g., `go test -bench`) directly without this skill's overhead.
42
+ - The codebase is in early prototype stage (< 20% of features implemented). Premature optimization at this stage wastes engineering time. Use this skill after the architecture stabilizes.
43
+ - You do not yet have a definition of "acceptable performance" (SLA/SLO targets). Run `genesis-planning` first to establish targets, then return to this skill.
44
+
45
+ ---
46
+
47
+ ## Inputs required
48
+
49
+ Before invoking this skill, gather or confirm the following inputs:
50
+
51
+ ### Environment inputs
52
+ - **Target environment URL or host**: The base URL or hostname of the system under test (e.g., `https://api.staging.example.com`).
53
+ - **Environment isolation confirmation**: Is the environment isolated from production traffic? Is background load minimal and stable?
54
+ - **Deployment version / commit SHA**: Exact version being profiled so results can be correlated to code.
55
+
56
+ ### Endpoint / workload definition
57
+ - **Endpoint list**: All endpoints or operations to include in the baseline (method + path + example payload).
58
+ - **Realistic request payload samples**: Representative inputs (not trivial or edge-case payloads that bypass real code paths).
59
+ - **Authentication credentials / tokens**: Valid test credentials for authenticated endpoints.
60
+ - **Concurrency target**: Expected concurrent users or requests per second in production (used to size load test).
61
+
62
+ ### Performance targets (SLO inputs)
63
+ - **p50 latency target** (e.g., ≤ 50 ms): Median response time acceptable in production.
64
+ - **p95 latency target** (e.g., ≤ 200 ms): 95th percentile threshold (the primary SLA boundary for most web APIs).
65
+ - **p99 latency target** (e.g., ≤ 500 ms): 99th percentile threshold (used for SLO error budget).
66
+ - **Throughput target** (e.g., ≥ 500 req/s): Minimum acceptable requests per second at peak.
67
+ - **Error rate target** (e.g., < 0.1%): Maximum acceptable HTTP 4xx/5xx error rate.
68
+ - **Memory growth limit** (e.g., < 50 MB over 10 min): Acceptable heap growth under sustained load (used for leak detection).
69
+
70
+ ### Toolchain inputs
71
+ - **Language/runtime**: Node.js, Python, Go, Java, etc. (determines which profiling tools to invoke).
72
+ - **Load test tool preference**: k6, Artillery, or Locust (if none specified, default to k6).
73
+ - **Monitoring stack**: Prometheus + Grafana, Datadog, CloudWatch, etc. (used to correlate metrics).
74
+ - **Database type** (if applicable): PostgreSQL, MySQL, MongoDB, Redis (used for query analysis phase).
75
+
76
+ ### Regression detection inputs (for before/after comparison)
77
+ - **Baseline artifact path**: Path to previously captured `PERF_BASELINE.json` (for regression checks).
78
+ - **Regression threshold**: Percentage increase that constitutes a regression (default: p95 increase > 20% = regression flag).
79
+
80
+ ---
81
+
82
+ ## Outputs required
83
+
84
+ This skill produces the following artifacts, stored in the project's `observability/` or specified output directory:
85
+
86
+ ### Phase 1 outputs
87
+ - `PERF_BASELINE.json`: Machine-readable baseline with all metrics per endpoint (p50, p95, p99, throughput, error rate, memory snapshots).
88
+ - `PERF_BASELINE_REPORT.md`: Human-readable baseline summary with context (environment, version, date, conditions).
89
+
90
+ ### Phase 2 outputs
91
+ - `profiling-playbook.md`: Step-by-step profiling instructions customized to the detected language/runtime.
92
+ - `profile-results/`: Directory containing raw profiling output (flame graphs, heap snapshots, pprof files).
93
+ - `BOTTLENECK_ANALYSIS.md`: Ranked list of identified bottlenecks with evidence (function names, call counts, CPU %, memory allocation sites).
94
+
95
+ ### Phase 3 outputs
96
+ - `load-test-config.yml` or `load-test-script.js`: Load test configuration file for the chosen tool (k6/Artillery/Locust).
97
+ - `load-test-results/`: Directory with raw result CSVs and summary JSON from each load test run.
98
+ - `LOAD_TEST_REPORT.md`: Summarized load test report with pass/fail against thresholds.
99
+
100
+ ### Phase 4 outputs
101
+ - `REGRESSION_REPORT.md`: Before/after comparison table with regression flags. Includes statistical confidence note (sample size, variance).
102
+ - `REGRESSION_SUMMARY.json`: Machine-readable diff of all metrics for CI gate consumption.
103
+
104
+ ### Phase 5 outputs
105
+ - `OPTIMIZATION_RECOMMENDATIONS.md`: Prioritized list of optimization actions, each with: bottleneck evidence, recommended fix, estimated impact tier (High/Medium/Low), implementation complexity (Easy/Medium/Hard), and validation method.
106
+ - Updated `PERF_LOG.md`: Running log of all performance measurements appended with the new run.
107
+
108
+ ---
109
+
110
+ ## Required tests
111
+
112
+ Before this skill is considered complete for a project, the following tests must pass:
113
+
114
+ ### Baseline capture tests
115
+ - [ ] `test/perf/baseline-capture.test.js`: Verifies that baseline capture runs against target endpoints and produces valid `PERF_BASELINE.json` with all required metric fields.
116
+ - [ ] `test/perf/baseline-schema.test.js`: Validates `PERF_BASELINE.json` schema (p50, p95, p99, throughput, error_rate, timestamp, environment, version all present and typed correctly).
117
+ - [ ] `test/perf/baseline-isolation.test.js`: Verifies environment has < 5% background load before baseline capture begins (pre-flight check).
118
+
119
+ ### Load test tests
120
+ - [ ] `test/perf/load-test-config-valid.test.js`: Validates generated load test config is syntactically correct and has all required stages (ramp-up, peak, ramp-down).
121
+ - [ ] `test/perf/load-test-thresholds.test.js`: Verifies that generated thresholds match the provided SLO inputs.
122
+ - [ ] `test/perf/load-test-execution.test.js`: Smoke test run (10 VUs, 30 seconds) completes without tool error.
123
+
124
+ ### Regression detection tests
125
+ - [ ] `test/perf/regression-detection.test.js`: Given two baseline JSONs (before/after), correctly identifies regressions above the threshold and produces accurate `REGRESSION_REPORT.md`.
126
+ - [ ] `test/perf/regression-false-positive.test.js`: Verifies that metric changes within natural variance (< 5% difference) are NOT flagged as regressions.
127
+
128
+ ### Profiling tests
129
+ - [ ] `test/perf/profiling-playbook-valid.test.js`: Verifies that the generated profiling playbook contains valid shell commands for the detected language runtime.
130
+
131
+ ### Contract fixtures
132
+ All tests must pass against fixtures in `fixtures/performance/`:
133
+ - `baseline-expected.json`
134
+ - `regression-detection-expected.json`
135
+ - `load-test-config-expected.json`
136
+
137
+ ---
138
+
139
+ ## Required fixtures
140
+
141
+ Create and maintain the following fixtures in `fixtures/performance/`:
142
+
143
+ ### `baseline-expected.json`
144
+ Complete baseline capture with realistic p50/p95/p99 numbers across multiple endpoints. Must include memory snapshot at t=0 and t=end.
145
+
146
+ ### `regression-detection-expected.json`
147
+ Two baseline snapshots (before/after) with:
148
+ - One endpoint showing p95 regression (> 20% increase).
149
+ - One endpoint showing improvement.
150
+ - One endpoint within natural variance (no flag).
151
+ Expected output: regression report with correct flag count.
152
+
153
+ ### `load-test-config-expected.json`
154
+ Generated k6 script config with:
155
+ - Three stages: ramp-up (0→100 VUs over 2 min), peak (100 VUs for 5 min), ramp-down (100→0 VUs over 1 min).
156
+ - Thresholds matching SLO inputs.
157
+ - Custom metrics: `http_req_duration`, `http_req_failed`.
158
+
159
+ ---
160
+
161
+ ## Required contract updates
162
+
163
+ When this skill modifies public inputs or outputs, update the following contracts:
164
+
165
+ - `contracts/performance/baseline-schema.contract.json`: JSON Schema for `PERF_BASELINE.json` structure. Update when new metric fields are added.
166
+ - `contracts/performance/regression-report.contract.json`: JSON Schema for `REGRESSION_SUMMARY.json`. Update when regression detection logic changes.
167
+ - `contracts/performance/load-test-config.contract.json`: JSON Schema for generated load test config. Update when new test tool templates are added.
168
+
169
+ Contract update checklist:
170
+ 1. Bump the contract `version` field.
171
+ 2. Update `changed_at` to current ISO timestamp.
172
+ 3. Add a `changelog` entry describing the change.
173
+ 4. Re-run fixture tests against updated contract.
174
+ 5. Update `REGRESSION_SUMMARY.json` format if fields change.
175
+
176
+ ---
177
+
178
+ ## Required codebase map updates
179
+
180
+ After completing a profiling cycle, update the following codebase memory files:
181
+
182
+ ### `.codebase/CURRENT_STATE.md`
183
+ - Add entry: `Performance baseline captured: [date] [version] [environment]`.
184
+ - Update architecture score if optimizations improved structural quality.
185
+
186
+ ### `.codebase/MODULE_INDEX.md`
187
+ - Add entries for any new scripts added to `scripts/perf/`.
188
+ - Document new fixture files in `fixtures/performance/`.
189
+
190
+ ### `observability/PERF_LOG.md`
191
+ Append new run entry in standard format (see `observability/performance-tracking.md` for format).
192
+
193
+ ---
194
+
195
+ ## Token saving rules
196
+
197
+ To minimize token usage when running this skill:
198
+
199
+ 1. **Read only relevant files**: Do not load all source files. Identify hot paths from profiling data first, then read only those files.
200
+ 2. **Summarize baselines, don't embed raw data**: When referencing baseline metrics in planning, cite p95 values only — do not paste full JSON into prompts.
201
+ 3. **Reuse existing load test configs**: If a load test config exists for the endpoint, diff it against requirements rather than regenerating from scratch.
202
+ 4. **Profile incrementally**: Do not re-profile functions that have not changed since the last baseline. Use the bottleneck list to scope work.
203
+ 5. **Batch fixture comparisons**: Compare all endpoint regressions in a single diff pass, not one endpoint at a time.
204
+ 6. **Skip phase 2 for green baselines**: If all metrics pass SLO targets in phase 1, skip profiling (phase 2) and go straight to phase 5 optimization recommendations (which may be "no action needed").
205
+ 7. **Cache authentication tokens**: Reuse the same auth token across all load test stages rather than re-authenticating per request.
206
+ 8. **Compress profile output**: Store only flame graph SVGs and summary CSVs, not raw `.cpuprofile` binary files, in the repository.
207
+
208
+ ---
209
+
210
+ ## Acceptance criteria
211
+
212
+ A performance profiling cycle is COMPLETE and ACCEPTED when ALL of the following are true:
213
+
214
+ ### Baseline
215
+ - [ ] `PERF_BASELINE.json` exists with non-zero values for all required metric fields.
216
+ - [ ] Baseline was captured in an isolated environment with background load < 5%.
217
+ - [ ] At least 3 measurement runs were averaged to reduce variance.
218
+ - [ ] Environment version (commit SHA or image tag) is recorded in the baseline.
219
+
220
+ ### Load test
221
+ - [ ] Load test ran for at least 5 minutes at peak concurrency.
222
+ - [ ] All stages (ramp-up, peak, ramp-down) completed without tool errors.
223
+ - [ ] Results are stored in `load-test-results/` with timestamp.
224
+
225
+ ### Regression detection
226
+ - [ ] `REGRESSION_REPORT.md` correctly identifies all regressions above threshold.
227
+ - [ ] No false positives (changes within 5% variance are not flagged).
228
+ - [ ] Report is machine-readable via `REGRESSION_SUMMARY.json`.
229
+
230
+ ### Profiling (if triggered)
231
+ - [ ] At least one bottleneck is identified with function-level evidence (not just "the service is slow").
232
+ - [ ] Each bottleneck has a proposed fix in `OPTIMIZATION_RECOMMENDATIONS.md`.
233
+
234
+ ### Optimization (if implemented)
235
+ - [ ] A new baseline was captured after optimization.
236
+ - [ ] The after-baseline shows measurable improvement vs the before-baseline.
237
+ - [ ] The improvement is documented in `PERF_LOG.md`.
238
+
239
+ ### CI gate
240
+ - [ ] `REGRESSION_SUMMARY.json` is machine-readable and integrated into the CI pipeline.
241
+ - [ ] Builds fail automatically when p95 regression > threshold.
242
+
243
+ ---
244
+
245
+ ## Common mistakes
246
+
247
+ ### Mistake 1: Profiling in production
248
+ **Problem**: Running CPU profiling or heap snapshots in production introduces latency and risk.
249
+ **Fix**: Always profile in an isolated staging environment that mirrors production configuration.
250
+
251
+ ### Mistake 2: Single-run baselines
252
+ **Problem**: A single measurement run captures noise, not signal. Network jitter, GC pauses, and JIT warm-up skew results.
253
+ **Fix**: Run at least 3 baseline passes and average results. Discard the first run (warm-up). Use p95/p99, not mean.
254
+
255
+ ### Mistake 3: Profiling the wrong thing
256
+ **Problem**: Profiling the entire application when only one endpoint is slow wastes time and produces noisy flame graphs.
257
+ **Fix**: Use the baseline to identify the slowest endpoints first (sort by p95 descending), then profile only those hot paths.
258
+
259
+ ### Mistake 4: Load testing with unrealistic traffic patterns
260
+ **Problem**: Sending 100% of traffic to one endpoint when production is a mix of 30 endpoints produces misleading results.
261
+ **Fix**: Model the load test scenario from production access logs. Use realistic request distribution (Pareto principle: 20% of endpoints often account for 80% of traffic).
262
+
263
+ ### Mistake 5: Ignoring memory leak signals in short tests
264
+ **Problem**: Running load tests for < 2 minutes misses memory leaks that only manifest over time (accumulating closures, growing caches).
265
+ **Fix**: Include a "soak test" stage of at least 10 minutes with steady load to capture memory growth rate.
266
+
267
+ ### Mistake 6: Conflating p95 improvement with mean improvement
268
+ **Problem**: Reporting "average latency improved by 30%" while p95 (the SLA boundary) barely moved or got worse.
269
+ **Fix**: Always report and compare p50, p95, and p99 separately. Optimize for the tail (p95/p99), not the mean.
270
+
271
+ ### Mistake 7: Not recording environment conditions in baseline
272
+ **Problem**: A baseline captured with 50 MB cache warm gives very different numbers than one captured cold. Can't compare across sessions without context.
273
+ **Fix**: Record CPU/memory resource levels, cache state, database row count, and any background jobs running at baseline capture time.
274
+
275
+ ### Mistake 8: Missing ramp-up in load tests
276
+ **Problem**: Sending peak traffic instantly (cold start) causes artificial spikes that don't reflect production behavior.
277
+ **Fix**: Always include a ramp-up stage (e.g., 0 → peak VUs over 2 minutes) to simulate realistic connection pool warm-up.
278
+
279
+ ### Mistake 9: Treating any regression as a blocker without context
280
+ **Problem**: A p95 regression of 2 ms on an endpoint with a 500 ms SLA target is noise, not a regression.
281
+ **Fix**: Define regression thresholds as percentages relative to the SLA budget. A 20% increase on a 10 ms target is significant; a 1% increase on a 500 ms target is not.
282
+
283
+ ### Mistake 10: Skipping the after-baseline
284
+ **Problem**: Implementing optimizations without re-measuring leaves no evidence the optimization worked.
285
+ **Fix**: Always capture a new baseline after optimization. Update `PERF_LOG.md` with before/after values. Never claim performance improved without measurement.
286
+
287
+ ---
288
+
289
+ ## Recovery workflow
290
+
291
+ Use this workflow when performance profiling encounters errors or produces unexpected results:
292
+
293
+ ### Recovery 1: Load test tool fails to start
294
+ ```
295
+ Symptom: k6/Artillery/Locust exits immediately with error.
296
+ Step 1: Check tool is installed at correct version (k6 >= 0.45, Artillery >= 2.0).
297
+ Step 2: Validate config syntax (k6: k6 run --dry-run config.js; Artillery: artillery validate config.yml).
298
+ Step 3: Test connectivity to target host with curl before running load test.
299
+ Step 4: Check for firewall rules blocking the test runner's outbound connections.
300
+ Step 5: Reduce concurrency to 1 VU and retry to isolate whether issue is concurrency or connectivity.
301
+ ```
302
+
303
+ ### Recovery 2: Baseline metrics are wildly variable (high variance)
304
+ ```
305
+ Symptom: p95 varies by > 50% across runs (e.g., 100 ms in run 1, 300 ms in run 2).
306
+ Step 1: Check for background jobs running on the test environment (cron jobs, backups, deployments).
307
+ Step 2: Check database connection pool exhaustion (look for connection wait time in DB metrics).
308
+ Step 3: Increase warm-up period (run 5 min of steady traffic before capturing baseline).
309
+ Step 4: Check if JVM/Node.js JIT is still warming up (first 60 seconds of traffic is noisiest).
310
+ Step 5: If variance persists, capture median of 5 runs instead of 3. Document the high variance in the baseline.
311
+ ```
312
+
313
+ ### Recovery 3: Regression detected but no code changes were made
314
+ ```
315
+ Symptom: After baseline shows regression vs before baseline, but the diff shows no relevant code changes.
316
+ Step 1: Compare environment conditions: CPU allocation, memory, database size, cache state between runs.
317
+ Step 2: Check if a dependency was upgraded between runs (package-lock.json or go.sum diff).
318
+ Step 3: Check database table growth (more rows = slower full scans; verify EXPLAIN ANALYZE results).
319
+ Step 4: Check if infrastructure auto-scaling reduced instance count (same RPS on fewer resources = regression).
320
+ Step 5: Re-run both baselines in identical conditions on the same day to confirm regression is real.
321
+ ```
322
+
323
+ ### Recovery 4: Profiling tool does not produce useful output
324
+ ```
325
+ Symptom: Flame graph is flat (no clear hot path), heap snapshot shows no obvious leak.
326
+ Step 1: Verify the profiler is attached to the correct process PID (not a child/worker process).
327
+ Step 2: For Node.js cluster mode: attach profiler to worker processes, not the master.
328
+ Step 3: Increase profiling duration (minimum 60 seconds under load for meaningful CPU profile).
329
+ Step 4: Check if the bottleneck is I/O-bound (not CPU-bound): CPU profile will show idle time. Switch to async call tracing.
330
+ Step 5: For memory leaks: take heap snapshots at t=0, t=5min, t=10min and compare object counts, not just total size.
331
+ ```
332
+
333
+ ### Recovery 5: Load test results do not match production incident
334
+ ```
335
+ Symptom: Load test shows p95 = 50 ms but production incident showed p95 = 2000 ms.
336
+ Step 1: Compare concurrency: production may have had 10x more concurrent users than the test.
337
+ Step 2: Compare payload size: test may be using small payloads while production had large uploads/responses.
338
+ Step 3: Check for database connection pool limits (not hit in test but hit in production).
339
+ Step 4: Check for third-party API calls that are mocked in test but real in production (external payment APIs, etc.).
340
+ Step 5: Replay production traffic logs (not synthetic load) using a tool like GoReplay or Shadowtraffic.
341
+ ```
342
+
343
+ ### Recovery 6: Optimization made things worse
344
+ ```
345
+ Symptom: After-baseline shows p95 regression compared to before-baseline.
346
+ Step 1: Revert the optimization immediately (git revert).
347
+ Step 2: Re-run baseline to confirm revert restored original performance.
348
+ Step 3: Analyze the optimization failure: cache invalidation bug? Race condition? Increased serialization overhead?
349
+ Step 4: Profile the regressed version specifically to find the new bottleneck introduced.
350
+ Step 5: Redesign the optimization addressing the root cause. Add a unit test for the scenario that failed.
351
+ ```
352
+
353
+ ---
354
+
355
+ ## Workflow Detail: Phase-by-Phase Execution
356
+
357
+ ### Phase 1: Performance Baseline Capture
358
+
359
+ **Goal**: Establish a quantified, reproducible performance baseline before any optimization work.
360
+
361
+ **Step 1.1 — Environment validation**
362
+ ```bash
363
+ # Check environment isolation
364
+ curl -s http://target-host/health | jq .
365
+ # Verify background CPU < 5%
366
+ top -bn1 | grep "Cpu(s)"
367
+ # Check memory free
368
+ free -m
369
+ ```
370
+
371
+ **Step 1.2 — Warm-up run (discard results)**
372
+ Run 2 minutes of moderate traffic (30% of peak concurrency) to warm up:
373
+ - JVM/V8 JIT compiler caches
374
+ - Database connection pools
375
+ - OS-level TCP connection reuse
376
+ - CDN/cache layer
377
+
378
+ **Step 1.3 — Measurement runs (3× minimum)**
379
+
380
+ For each run, capture:
381
+
382
+ | Metric | Tool | Sample command |
383
+ |--------|------|----------------|
384
+ | p50 latency | k6 / wrk | `k6 run --vus 50 --duration 5m script.js` |
385
+ | p95 latency | k6 / wrk | Included in k6 output (`http_req_duration{p:95}`) |
386
+ | p99 latency | k6 / wrk | Included in k6 output (`http_req_duration{p:99}`) |
387
+ | Throughput (req/s) | k6 / wrk | `http_reqs` counter ÷ duration |
388
+ | Error rate | k6 | `http_req_failed` rate |
389
+ | Memory (heap) | process metrics | Prometheus `process_resident_memory_bytes` |
390
+ | CPU % | process metrics | Prometheus `process_cpu_seconds_total` |
391
+ | DB query time | pg_stat_statements | `total_time / calls` |
392
+
393
+ **Step 1.4 — Aggregate and store**
394
+
395
+ Average the 3 runs (discard outliers > 2σ from mean):
396
+ ```json
397
+ {
398
+ "version": "1.4.2",
399
+ "commit": "abc1234",
400
+ "environment": "staging-isolated",
401
+ "captured_at": "2026-05-31T10:00:00Z",
402
+ "conditions": {
403
+ "background_cpu_pct": 2.1,
404
+ "available_memory_mb": 3840,
405
+ "db_row_count": 150000,
406
+ "cache_state": "warm"
407
+ },
408
+ "endpoints": {
409
+ "GET /api/users": {
410
+ "p50_ms": 45,
411
+ "p95_ms": 180,
412
+ "p99_ms": 420,
413
+ "throughput_rps": 312,
414
+ "error_rate_pct": 0.02,
415
+ "memory_start_mb": 256,
416
+ "memory_end_mb": 261
417
+ }
418
+ }
419
+ }
420
+ ```
421
+
422
+ ### Phase 2: Profiling Playbook Generation
423
+
424
+ **Goal**: Identify the exact code-level bottlenecks causing elevated latency or memory growth.
425
+
426
+ **Decision tree: which profiling type to use**
427
+
428
+ ```
429
+ Is p95 > SLA target?
430
+ YES → Is CPU consistently > 70%?
431
+ YES → CPU profiling (flame graph)
432
+ NO → Is memory growing over time?
433
+ YES → Memory profiling (heap snapshot)
434
+ NO → Is DB query time > 50% of response time?
435
+ YES → Query analysis (EXPLAIN ANALYZE, slow query log)
436
+ NO → Network I/O analysis (connection pooling, DNS, TLS handshake)
437
+ NO → No profiling needed. Proceed to Phase 5 (recommendations: maintain current state).
438
+ ```
439
+
440
+ See `playbooks/profiling-playbook.md` for tool-specific instructions.
441
+
442
+ ### Phase 3: Load Test Config Generation
443
+
444
+ **Goal**: Generate a reproducible, parameterized load test that can be run in CI and by any team member.
445
+
446
+ The generated config must define:
447
+ - **Smoke test** (1 VU, 1 min): Verify endpoint responds without errors.
448
+ - **Load test** (target concurrency, 10 min): Verify system handles expected traffic.
449
+ - **Stress test** (2× target concurrency, 5 min): Find the breaking point.
450
+ - **Soak test** (target concurrency, 30 min): Detect memory leaks and connection pool exhaustion.
451
+
452
+ See `playbooks/load-testing-orchestration.md` for complete configs.
453
+
454
+ ### Phase 4: Before/After Comparison + Regression Detection
455
+
456
+ **Goal**: Quantify the impact of changes (optimizations, refactors, dependency upgrades) relative to the captured baseline.
457
+
458
+ **Algorithm:**
459
+ ```
460
+ For each endpoint E:
461
+ For each metric M in {p50, p95, p99, throughput, error_rate}:
462
+ delta_pct = (after[E][M] - before[E][M]) / before[E][M] × 100
463
+
464
+ If M is latency:
465
+ If delta_pct > regression_threshold_pct: REGRESSION
466
+ If delta_pct < -improvement_threshold_pct: IMPROVEMENT
467
+ Else: STABLE
468
+
469
+ If M is throughput:
470
+ If delta_pct < -regression_threshold_pct: REGRESSION (throughput decreased)
471
+ If delta_pct > improvement_threshold_pct: IMPROVEMENT
472
+ Else: STABLE
473
+
474
+ If M is error_rate:
475
+ If after[E][M] > error_rate_slo: REGRESSION
476
+ Else: STABLE
477
+ ```
478
+
479
+ Default thresholds:
480
+ - Latency regression: p95 increased > 20%.
481
+ - Throughput regression: throughput decreased > 15%.
482
+ - Error rate regression: error rate > 0.1%.
483
+ - Improvement threshold: > 10% improvement (must be > natural variance of 5%).
484
+
485
+ ### Phase 5: Optimization Recommendation Generation
486
+
487
+ **Goal**: Produce a prioritized, actionable list of optimizations ranked by expected impact vs implementation effort.
488
+
489
+ **Recommendation template:**
490
+
491
+ ```markdown
492
+ ### [BOTTLENECK-001] Slow database query on /api/users (N+1 pattern)
493
+
494
+ **Evidence**: EXPLAIN ANALYZE shows sequential scan on `users` table (150,000 rows).
495
+ DB query time = 145 ms (81% of total response time).
496
+ Identified via: slow query log + pg_stat_statements.
497
+
498
+ **Recommended fix**: Add composite index on (tenant_id, status, created_at).
499
+ Fix N+1 ORM query pattern: use eager loading (`include: ['profile']`).
500
+
501
+ **Estimated impact**: HIGH — Expected p95 improvement: 100–140 ms (55–78% reduction).
502
+
503
+ **Implementation complexity**: EASY — Index creation: 1 migration file.
504
+ ORM fix: 3 lines of code change.
505
+
506
+ **Validation method**: Re-run baseline after migration. Confirm p95 ≤ 80 ms.
507
+ Run regression-detection phase against new baseline.
508
+
509
+ **Risk**: Index creation on large table requires `CREATE INDEX CONCURRENTLY` to avoid table lock.
510
+ ```
@@ -0,0 +1,6 @@
1
+ interface:
2
+ display_name: "Performance Profiling Skill"
3
+ short_description: "Automate performance baseline, profiling, and load testing"
4
+ default_prompt: "Use $genesis-performance-profiling to establish baseline and identify bottlenecks."
5
+ policy:
6
+ allow_implicit_invocation: false