codex-genesis-harness 0.1.0 → 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.
- package/.codebase/API_CONTRACTS.md +12 -0
- package/.codebase/ARCHITECTURE.md +6 -0
- package/.codebase/ARCHITECTURE_REVIEW_COMPLETE.md +216 -0
- package/.codebase/CURRENT_STATE.md +8 -0
- package/.codebase/DEPENDENCY_GRAPH.md +14 -0
- package/.codebase/DOMAIN_MODELS.md +10 -0
- package/.codebase/EVOLUTION_PLAN.md +35 -0
- package/.codebase/FILE_NAMING_CLARIFICATION.md +161 -0
- package/.codebase/HARNESS_COMPLETENESS_AUDIT.md +613 -0
- package/.codebase/IMPLEMENTATION_COMPLETE.md +429 -0
- package/.codebase/IMPLEMENTATION_HANDOFF.md +351 -0
- package/.codebase/IMPROVEMENTS_SUMMARY.md +419 -0
- package/.codebase/KNOWN_PROBLEMS.md +6 -0
- package/.codebase/MODULE_INDEX.md +13 -0
- package/.codebase/PHASE3_SKILLS_NAMING_COMPLETE.md +292 -0
- package/.codebase/PHASE_DEPENDENCY_MAP.md +486 -0
- package/.codebase/PIPELINE_FLOW.md +14 -0
- package/.codebase/QUICK_START_SPEC_IMPACT.md +456 -0
- package/.codebase/README.md +139 -0
- package/.codebase/RECOVERY_POINTS.md +438 -0
- package/.codebase/TEST_MATRIX.md +11 -0
- package/.codebase/UI_ROUTES.md +4 -0
- package/.codebase/context/backend-summary.md +4 -0
- package/.codebase/context/frontend-summary.md +4 -0
- package/.codebase/context/pipeline-summary.md +4 -0
- package/.codebase/context/providers-summary.md +4 -0
- package/.codebase/context/render-summary.md +4 -0
- package/.codebase/context/tests-summary.md +4 -0
- package/.codex/skills/genesis-ai-provider/SKILL.md +46 -0
- package/.codex/skills/genesis-ai-provider/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-ai-provider/checklists/checklist.md +9 -0
- package/.codex/skills/genesis-ai-provider/examples/example.md +4 -0
- package/.codex/skills/genesis-ai-provider/templates/provider-contract-template.md +9 -0
- package/.codex/skills/genesis-api-contract/SKILL.md +46 -0
- package/.codex/skills/genesis-api-contract/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-api-contract/checklists/checklist.md +8 -0
- package/.codex/skills/genesis-api-contract/examples/example.md +4 -0
- package/.codex/skills/genesis-api-contract/templates/api-contract-template.md +4 -0
- package/.codex/skills/genesis-api-sync/SKILL.md +354 -0
- package/.codex/skills/genesis-api-sync/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-api-sync/checklists/api-sync-checklist.md +101 -0
- package/.codex/skills/genesis-api-sync/examples/example.md +68 -0
- package/.codex/skills/genesis-api-sync/templates/api-change-template.md +257 -0
- package/.codex/skills/genesis-architecture/SKILL.md +46 -0
- package/.codex/skills/genesis-architecture/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-architecture/checklists/checklist.md +8 -0
- package/.codex/skills/genesis-architecture/examples/example.md +4 -0
- package/.codex/skills/genesis-architecture/templates/architecture-decision-template.md +14 -0
- package/.codex/skills/genesis-codebase-map/SKILL.md +46 -0
- package/.codex/skills/genesis-codebase-map/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-codebase-map/checklists/checklist.md +7 -0
- package/.codex/skills/genesis-codebase-map/examples/example.md +4 -0
- package/.codex/skills/genesis-codebase-map/templates/map-update-template.md +8 -0
- package/.codex/skills/genesis-debug-guide/SKILL.md +479 -0
- package/.codex/skills/genesis-debug-guide/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-debug-guide/checklists/flaky-test-investigation.md +339 -0
- package/.codex/skills/genesis-debug-guide/checklists/production-bug-debug.md +210 -0
- package/.codex/skills/genesis-debug-guide/checklists/test-failure-debug.md +158 -0
- package/.codex/skills/genesis-debug-guide/examples/example.md +48 -0
- package/.codex/skills/genesis-debug-guide/observability/debug-commands.md +365 -0
- package/.codex/skills/genesis-debug-guide/playbooks/unit-test-failures.md +289 -0
- package/.codex/skills/genesis-debug-guide/templates/debug-investigation-log.md +288 -0
- package/.codex/skills/genesis-design-spec/SKILL.md +46 -0
- package/.codex/skills/genesis-design-spec/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-design-spec/checklists/checklist.md +7 -0
- package/.codex/skills/genesis-design-spec/examples/example.md +4 -0
- package/.codex/skills/genesis-design-spec/templates/design-spec-template.md +9 -0
- package/.codex/skills/genesis-docs/SKILL.md +46 -0
- package/.codex/skills/genesis-docs/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-docs/checklists/checklist.md +7 -0
- package/.codex/skills/genesis-docs/examples/example.md +4 -0
- package/.codex/skills/genesis-docs/templates/docs-update-template.md +8 -0
- package/.codex/skills/genesis-docs-automation/SKILL.md +1003 -0
- package/.codex/skills/genesis-docs-automation/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-docs-automation/checklists/docs-validation.md +359 -0
- package/.codex/skills/genesis-docs-automation/checklists/spec-alignment.md +312 -0
- package/.codex/skills/genesis-docs-automation/examples/example.md +59 -0
- package/.codex/skills/genesis-docs-automation/observability/docs-tracking.md +382 -0
- package/.codex/skills/genesis-docs-automation/playbooks/auto-update-flow.md +851 -0
- package/.codex/skills/genesis-docs-automation/playbooks/changelog-generation.md +491 -0
- package/.codex/skills/genesis-docs-automation/templates/changelog-entry-template.md +187 -0
- package/.codex/skills/genesis-docs-automation/templates/handoff-template.md +297 -0
- package/.codex/skills/genesis-harness/SKILL.md +1418 -0
- package/.codex/skills/genesis-harness/agents/openai.yaml +9 -0
- package/.codex/skills/genesis-harness/checklists/bug-fix-qa.md +169 -0
- package/.codex/skills/genesis-harness/checklists/checklist.md +10 -0
- package/.codex/skills/genesis-harness/checklists/new-feature-qa.md +157 -0
- package/.codex/skills/genesis-harness/checklists/refactor-qa.md +216 -0
- package/.codex/skills/genesis-harness/checklists/requirements-validation.md +211 -0
- package/.codex/skills/genesis-harness/examples/example.md +4 -0
- package/.codex/skills/genesis-harness/resources/change-impact-matrix-template.md +204 -0
- package/.codex/skills/genesis-harness/resources/foundation-phase-template.md +131 -0
- package/.codex/skills/genesis-harness/resources/phase-00-foundation-template.md +76 -0
- package/.codex/skills/genesis-harness/resources/post-implementation-guide.md +347 -0
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/check-architecture-boundaries.sh +23 -23
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/check-docs-sync.sh +24 -24
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/check-no-debug-logs.sh +21 -21
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/check-required-planning-files.sh +46 -46
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/check-spec-changelog.sh +24 -24
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/check-task-tracking.sh +25 -25
- package/.codex/skills/genesis-harness/scripts/compact-context.sh +54 -0
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/create-adr.sh +74 -74
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/create-bug.sh +160 -160
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/create-feature.sh +217 -217
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/detect-stack.sh +26 -26
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/init-planning.sh +750 -719
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/list-changed-files.sh +12 -12
- package/.codex/skills/genesis-harness/scripts/offload-log.sh +72 -0
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/run-verification.sh +47 -47
- package/.codex/skills/genesis-harness/scripts/run-verify-loop.sh +75 -0
- package/.codex/skills/{project-genesis-harness → genesis-harness}/scripts/update-state.sh +33 -33
- package/.codex/skills/genesis-harness/templates/harness-workflow-template.md +10 -0
- package/.codex/skills/genesis-harness-engineering/SKILL.md +159 -0
- package/.codex/skills/genesis-harness-engineering/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-harness-engineering/checklists/checklist.md +48 -0
- package/.codex/skills/genesis-harness-engineering/examples/example.md +57 -0
- package/.codex/skills/genesis-harness-engineering/playbooks/harness-evolution.md +99 -0
- package/.codex/skills/genesis-harness-engineering/templates/harness-change-template.md +37 -0
- package/.codex/skills/genesis-new-design/SKILL.md +95 -0
- package/.codex/skills/genesis-new-design/agents/openai.yaml +4 -0
- package/.codex/skills/genesis-new-design/checklists/checklist.md +8 -0
- package/.codex/skills/genesis-new-design/examples/example.md +4 -0
- package/.codex/skills/genesis-new-design/templates/new-design-template.md +9 -0
- package/.codex/skills/genesis-observability-automation/SKILL.md +382 -0
- package/.codex/skills/genesis-observability-automation/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-observability-automation/examples/example.md +86 -0
- package/.codex/skills/genesis-performance-profiling/SKILL.md +510 -0
- package/.codex/skills/genesis-performance-profiling/agents/openai.yaml +6 -0
- package/.codex/skills/genesis-performance-profiling/checklists/optimization-verification.md +199 -0
- package/.codex/skills/genesis-performance-profiling/checklists/performance-baseline.md +183 -0
- package/.codex/skills/genesis-performance-profiling/examples/example.md +234 -0
- package/.codex/skills/genesis-performance-profiling/observability/performance-tracking.md +202 -0
- package/.codex/skills/genesis-performance-profiling/playbooks/load-testing-orchestration.md +593 -0
- package/.codex/skills/genesis-performance-profiling/playbooks/profiling-playbook.md +601 -0
- package/.codex/skills/genesis-performance-profiling/templates/load-test-config-template.md +428 -0
- package/.codex/skills/genesis-performance-profiling/templates/performance-report-template.md +238 -0
- package/.codex/skills/genesis-pipeline-orchestration/SKILL.md +46 -0
- package/.codex/skills/genesis-pipeline-orchestration/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-pipeline-orchestration/checklists/checklist.md +12 -0
- package/.codex/skills/genesis-pipeline-orchestration/examples/example.md +4 -0
- package/.codex/skills/genesis-pipeline-orchestration/templates/orchestration-template.md +12 -0
- package/.codex/skills/genesis-planning/SKILL.md +46 -0
- package/.codex/skills/genesis-planning/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-planning/checklists/checklist.md +8 -0
- package/.codex/skills/genesis-planning/examples/example.md +4 -0
- package/.codex/skills/genesis-planning/templates/plan-template.md +11 -0
- package/.codex/skills/genesis-release/SKILL.md +46 -0
- package/.codex/skills/genesis-release/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-release/checklists/checklist.md +8 -0
- package/.codex/skills/genesis-release/examples/example.md +4 -0
- package/.codex/skills/genesis-release/templates/release-checklist-template.md +9 -0
- package/.codex/skills/genesis-release-orchestration/SKILL.md +653 -0
- package/.codex/skills/genesis-release-orchestration/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-release-orchestration/checklists/post-deployment-verification.md +274 -0
- package/.codex/skills/genesis-release-orchestration/checklists/pre-release-validation.md +220 -0
- package/.codex/skills/genesis-release-orchestration/examples/example.md +78 -0
- package/.codex/skills/genesis-release-orchestration/observability/release-tracking.md +253 -0
- package/.codex/skills/genesis-release-orchestration/playbooks/canary-deployment-orchestration.md +472 -0
- package/.codex/skills/genesis-release-orchestration/playbooks/semantic-versioning-automation.md +494 -0
- package/.codex/skills/genesis-release-orchestration/templates/deployment-strategy-template.md +303 -0
- package/.codex/skills/genesis-release-orchestration/templates/release-runbook-template.md +420 -0
- package/.codex/skills/genesis-research/SKILL.md +46 -0
- package/.codex/skills/genesis-research/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-research/checklists/checklist.md +7 -0
- package/.codex/skills/genesis-research/examples/example.md +4 -0
- package/.codex/skills/genesis-research/templates/research-note-template.md +9 -0
- package/.codex/skills/genesis-research-first/SKILL.md +237 -0
- package/.codex/skills/genesis-research-first/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-research-first/examples/example.md +85 -0
- package/.codex/skills/genesis-spec-propagation/SKILL.md +534 -0
- package/.codex/skills/genesis-spec-propagation/agents/openai.yaml +7 -0
- package/.codex/skills/genesis-spec-propagation/checklists/phase-update-verification.md +384 -0
- package/.codex/skills/genesis-spec-propagation/checklists/spec-change-detection.md +257 -0
- package/.codex/skills/genesis-spec-propagation/examples/example.md +63 -0
- package/.codex/skills/genesis-spec-propagation/observability/propagation-tracking.md +373 -0
- package/.codex/skills/genesis-spec-propagation/playbooks/breaking-change-propagation.md +692 -0
- package/.codex/skills/genesis-spec-propagation/playbooks/feature-change-propagation.md +434 -0
- package/.codex/skills/genesis-spec-propagation/templates/migration-guide-template.md +407 -0
- package/.codex/skills/genesis-upgrade-design/SKILL.md +97 -0
- package/.codex/skills/genesis-upgrade-design/agents/openai.yaml +4 -0
- package/.codex/skills/genesis-upgrade-design/checklists/checklist.md +8 -0
- package/.codex/skills/genesis-upgrade-design/examples/example.md +4 -0
- package/.codex/skills/genesis-upgrade-design/templates/upgrade-design-template.md +9 -0
- package/.codex/skills/spec-impact-engine/SKILL.md +504 -0
- package/.codex/skills/spec-impact-engine/agents/openai.yaml +7 -0
- package/.codex/skills/spec-impact-engine/detect-spec-changes.sh +262 -0
- package/.codex/skills/spec-impact-engine/examples/example.md +98 -0
- package/.codex/skills/spec-impact-engine/templates/impact-report.md +248 -0
- package/.codex/skills/spec-impact-engine/templates/migration-guide.md +223 -0
- package/.codex/skills/ui-ux-test-skill/SKILL.md +46 -0
- package/.codex/skills/ui-ux-test-skill/agents/openai.yaml +7 -0
- package/.codex/skills/ui-ux-test-skill/checklists/checklist.md +8 -0
- package/.codex/skills/ui-ux-test-skill/examples/example.md +4 -0
- package/.codex/skills/ui-ux-test-skill/templates/playwright-test-template.md +4 -0
- package/.codex-plugin/plugin.json +13 -11
- package/README.EN.md +719 -0
- package/README.VI.md +712 -0
- package/README.md +318 -181
- package/VERSION +1 -1
- package/bin/genesis-harness.js +133 -79
- package/contracts/agents/CharacterBibleAgent/error.json +1 -0
- package/contracts/agents/CharacterBibleAgent/example.json +1 -0
- package/contracts/agents/CharacterBibleAgent/request.json +1 -0
- package/contracts/agents/CharacterBibleAgent/response.json +1 -0
- package/contracts/agents/CharacterBibleAgent/schema.json +1 -0
- package/contracts/agents/ImageGenerationAgent/error.json +1 -0
- package/contracts/agents/ImageGenerationAgent/example.json +1 -0
- package/contracts/agents/ImageGenerationAgent/request.json +1 -0
- package/contracts/agents/ImageGenerationAgent/response.json +1 -0
- package/contracts/agents/ImageGenerationAgent/schema.json +1 -0
- package/contracts/agents/PipelineOrchestrator/error.json +1 -0
- package/contracts/agents/PipelineOrchestrator/example.json +1 -0
- package/contracts/agents/PipelineOrchestrator/request.json +1 -0
- package/contracts/agents/PipelineOrchestrator/response.json +1 -0
- package/contracts/agents/PipelineOrchestrator/schema.json +1 -0
- package/contracts/agents/PromptGenerationAgent/error.json +1 -0
- package/contracts/agents/PromptGenerationAgent/example.json +1 -0
- package/contracts/agents/PromptGenerationAgent/request.json +1 -0
- package/contracts/agents/PromptGenerationAgent/response.json +1 -0
- package/contracts/agents/PromptGenerationAgent/schema.json +1 -0
- package/contracts/agents/RenderAgent/error.json +1 -0
- package/contracts/agents/RenderAgent/example.json +1 -0
- package/contracts/agents/RenderAgent/request.json +1 -0
- package/contracts/agents/RenderAgent/response.json +1 -0
- package/contracts/agents/RenderAgent/schema.json +1 -0
- package/contracts/agents/ScenePlanningAgent/error.json +1 -0
- package/contracts/agents/ScenePlanningAgent/example.json +1 -0
- package/contracts/agents/ScenePlanningAgent/request.json +1 -0
- package/contracts/agents/ScenePlanningAgent/response.json +1 -0
- package/contracts/agents/ScenePlanningAgent/schema.json +1 -0
- package/contracts/agents/ScreenplayAgent/error.json +1 -0
- package/contracts/agents/ScreenplayAgent/example.json +1 -0
- package/contracts/agents/ScreenplayAgent/request.json +1 -0
- package/contracts/agents/ScreenplayAgent/response.json +1 -0
- package/contracts/agents/ScreenplayAgent/schema.json +1 -0
- package/contracts/agents/StoryAnalysisAgent/error.json +1 -0
- package/contracts/agents/StoryAnalysisAgent/example.json +1 -0
- package/contracts/agents/StoryAnalysisAgent/request.json +1 -0
- package/contracts/agents/StoryAnalysisAgent/response.json +1 -0
- package/contracts/agents/StoryAnalysisAgent/schema.json +1 -0
- package/contracts/agents/SubtitleGenerationAgent/error.json +1 -0
- package/contracts/agents/SubtitleGenerationAgent/example.json +1 -0
- package/contracts/agents/SubtitleGenerationAgent/request.json +1 -0
- package/contracts/agents/SubtitleGenerationAgent/response.json +1 -0
- package/contracts/agents/SubtitleGenerationAgent/schema.json +1 -0
- package/contracts/agents/VoiceGenerationAgent/error.json +1 -0
- package/contracts/agents/VoiceGenerationAgent/example.json +1 -0
- package/contracts/agents/VoiceGenerationAgent/request.json +1 -0
- package/contracts/agents/VoiceGenerationAgent/response.json +1 -0
- package/contracts/agents/VoiceGenerationAgent/schema.json +1 -0
- package/contracts/api/README.md +4 -0
- package/contracts/api/endpoint-template/error.json +7 -0
- package/contracts/api/endpoint-template/example.json +11 -0
- package/contracts/api/endpoint-template/request.json +7 -0
- package/contracts/api/endpoint-template/response.json +6 -0
- package/contracts/api/endpoint-template/schema.json +9 -0
- package/contracts/events/README.md +4 -0
- package/contracts/events/event-template/error.json +4 -0
- package/contracts/events/event-template/example.json +6 -0
- package/contracts/events/event-template/request.json +6 -0
- package/contracts/events/event-template/response.json +3 -0
- package/contracts/events/event-template/schema.json +8 -0
- package/contracts/ui/README.md +4 -0
- package/contracts/ui/screen-template/error.json +4 -0
- package/contracts/ui/screen-template/example.json +7 -0
- package/contracts/ui/screen-template/request.json +4 -0
- package/contracts/ui/screen-template/response.json +4 -0
- package/contracts/ui/screen-template/schema.json +8 -0
- package/fixtures/agents/agent-fixture-template.md +14 -0
- package/fixtures/api/api-fixture-template.md +14 -0
- package/fixtures/images/image-fixture-template.md +14 -0
- package/fixtures/pipeline/pipeline-fixture-template.md +14 -0
- package/fixtures/render/render-fixture-template.md +14 -0
- package/fixtures/tts/tts-fixture-template.md +14 -0
- package/fixtures/videos/video-fixture-template.md +14 -0
- package/observability/agent-runs/agent-run-template.md +22 -0
- package/observability/decision-logs/decision-log-template.md +18 -0
- package/observability/failures/failure-template.md +18 -0
- package/package.json +8 -2
- package/playwright/e2e/e2e-template.md +4 -0
- package/playwright/fixtures/ui-fixture-template.md +4 -0
- package/playwright/smoke/smoke-template.md +4 -0
- package/playwright/visual/visual-regression-template.md +4 -0
- package/scripts/README.md +342 -0
- package/scripts/compact-context.sh +54 -0
- package/scripts/detect-changes.sh +152 -0
- package/scripts/install.sh +103 -69
- package/scripts/offload-log.sh +72 -0
- package/scripts/run-evals.sh +118 -52
- package/scripts/run-verify-loop.sh +75 -0
- package/scripts/uninstall.sh +81 -52
- package/scripts/verify.sh +380 -109
- package/tests/contracts/contract-template.test.md +10 -0
- package/tests/fixtures/fixture-index.md +4 -0
- package/tests/integration/integration-template.test.md +4 -0
- package/tests/unit/unit-template.test.md +4 -0
- package/.codex/skills/project-genesis-harness/SKILL.md +0 -727
- package/.codex/skills/project-genesis-harness/agents/openai.yaml +0 -9
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/references/planning-schema.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/references/quality-rubric.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/references/research-rubric.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/references/workflows.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/agents-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/api-docs-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/architecture-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/audit-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/bug-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/check-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/conventions-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/decision-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/design-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/escalation-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/feature-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/integrations-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/journeys-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/lessons-learned-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/observability-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/phase-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/pitfalls-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/planning-tree-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/project-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/quality-score-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/requirements-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/research-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/review-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/spec-changelog-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/stack-template.md +0 -0
- /package/.codex/skills/{project-genesis-harness → genesis-harness}/resources/verification-template.md +0 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Optimization Verification Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist when verifying that a performance optimization is correct, safe, and effective. Run this end-to-end after every optimization implementation — never ship a performance fix without completing all gates.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Pre-Optimization State Capture
|
|
8
|
+
|
|
9
|
+
### Mandatory — complete BEFORE implementing any optimization
|
|
10
|
+
|
|
11
|
+
- [ ] **Before-baseline captured and stored.** Path: `observability/baselines/before-[date]-[ticket].json`. This file is immutable — do NOT overwrite after implementation starts.
|
|
12
|
+
- [ ] **Bottleneck evidence documented.** The `BOTTLENECK_ANALYSIS.md` has been written with specific function names, call counts, and evidence (flame graph, heap snapshot, query plan). Vague bottlenecks ("the API is slow") are NOT acceptable.
|
|
13
|
+
- [ ] **Git branch created.** Optimization work happens on a dedicated branch. Never optimize on `main` directly.
|
|
14
|
+
- [ ] **Rollback plan documented.** In `OPTIMIZATION_RECOMMENDATIONS.md`, under the bottleneck entry, there is a rollback procedure (e.g., feature flag disable, migration revert command, previous Docker image tag).
|
|
15
|
+
- [ ] **Adjacent system state known.** Confirm which other services call the service being optimized. Know which upstream/downstream endpoints could be affected.
|
|
16
|
+
- [ ] **Database schema snapshot taken** (if DB changes are part of the optimization). Record table sizes, index list, and current query plans for all affected queries.
|
|
17
|
+
- [ ] **Feature flag prepared** (for high-risk optimizations). If the optimization changes behavior (not just performance), wrap it in a feature flag that can be disabled without a deployment.
|
|
18
|
+
|
|
19
|
+
### State snapshot commands
|
|
20
|
+
Run these and save outputs alongside the before-baseline:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Service info
|
|
24
|
+
git log --oneline -5 > state-snapshot/git-log.txt
|
|
25
|
+
docker inspect service-name > state-snapshot/docker-inspect.json
|
|
26
|
+
|
|
27
|
+
# Database state
|
|
28
|
+
psql -c "SELECT tablename, pg_size_pretty(pg_total_relation_size(tablename::regclass)) FROM pg_tables WHERE schemaname='public' ORDER BY pg_total_relation_size(tablename::regclass) DESC;" > state-snapshot/table-sizes.txt
|
|
29
|
+
psql -c "SELECT indexname, tablename, pg_size_pretty(pg_relation_size(indexname::regclass)) FROM pg_indexes WHERE schemaname='public';" > state-snapshot/indexes.txt
|
|
30
|
+
|
|
31
|
+
# Current query plans for affected queries
|
|
32
|
+
psql -c "EXPLAIN ANALYZE SELECT ..." > state-snapshot/query-plan-before.txt
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Optimization Implementation Checklist
|
|
38
|
+
|
|
39
|
+
### Code quality gates
|
|
40
|
+
- [ ] **Change is minimal and focused.** The PR diff touches only the files necessary for this specific bottleneck. No unrelated refactors bundled in the same PR.
|
|
41
|
+
- [ ] **Unit tests written for the optimization.** If caching was added, there are tests for cache hit, cache miss, and cache invalidation. If a query was changed, there are tests for the new query results.
|
|
42
|
+
- [ ] **Existing tests still pass.** Run the full test suite: `npm test` / `pytest` / `go test ./...`. Zero test failures allowed.
|
|
43
|
+
- [ ] **No new linter errors.** Run `eslint` / `flake8` / `golangci-lint`.
|
|
44
|
+
- [ ] **Memory management verified** (for caching optimizations). Cache has a maximum size limit. Cache has a TTL or eviction policy. Unbounded caches are NOT acceptable.
|
|
45
|
+
- [ ] **Error handling preserved.** The optimization does not swallow errors or change error behavior. All original error paths still return correct HTTP status codes.
|
|
46
|
+
- [ ] **Concurrency safety checked** (for shared state optimizations). Thread safety / mutex locking reviewed. Race conditions verified absent (`go test -race` for Go; ThreadSanitizer for C/C++).
|
|
47
|
+
|
|
48
|
+
### Database optimization gates
|
|
49
|
+
- [ ] **New indexes created with `CONCURRENTLY`** to avoid table locks in production.
|
|
50
|
+
```sql
|
|
51
|
+
CREATE INDEX CONCURRENTLY idx_users_tenant_status ON users(tenant_id, status, created_at);
|
|
52
|
+
```
|
|
53
|
+
- [ ] **EXPLAIN ANALYZE run on optimized query** to confirm index is being used (not a sequential scan).
|
|
54
|
+
- [ ] **Query result correctness verified.** The optimized query returns the same results as the original query. Run a diff of outputs on representative data sets.
|
|
55
|
+
- [ ] **Migration is reversible.** The `down` migration correctly reverts all schema changes.
|
|
56
|
+
- [ ] **No N+1 queries introduced.** If ORM eager loading was added, verify it does not over-fetch (loading too many related records).
|
|
57
|
+
|
|
58
|
+
### Caching optimization gates
|
|
59
|
+
- [ ] **Cache key includes all relevant dimensions.** If results vary by tenant, the cache key includes tenant ID. If results vary by user role, the cache key includes role.
|
|
60
|
+
- [ ] **Cache invalidation is correct.** When the underlying data changes (write operation), cache is invalidated within defined TTL or immediately.
|
|
61
|
+
- [ ] **Thundering herd protection.** For high-traffic cache misses, implement lock-based cache warming (only one request populates the cache; others wait) to avoid a flood of DB queries on cache miss.
|
|
62
|
+
- [ ] **Cache TTL is appropriate.** TTL matches the acceptable staleness of the data (e.g., user profile: 5 min is fine; real-time stock price: 0 ms TTL, no cache).
|
|
63
|
+
- [ ] **Cache metrics are instrumented.** `cache_hits`, `cache_misses`, and `cache_evictions` counters are exported to monitoring.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Post-Optimization Validation Gates
|
|
68
|
+
|
|
69
|
+
### Gate 1: Functional correctness (run FIRST — before any performance testing)
|
|
70
|
+
- [ ] Run integration test suite against the optimized service. All tests pass.
|
|
71
|
+
- [ ] Run manual smoke test against staging: hit the optimized endpoint manually and verify response body is correct.
|
|
72
|
+
- [ ] If the optimization changed query behavior, compare a sample of API responses (before vs after) to confirm no data differences.
|
|
73
|
+
|
|
74
|
+
### Gate 2: Performance improvement confirmation
|
|
75
|
+
Run 5 after-baseline measurement runs (same protocol as before-baseline):
|
|
76
|
+
|
|
77
|
+
- [ ] **p95 latency improved** by ≥ 10% vs before-baseline.
|
|
78
|
+
- Before p95: ___ ms → After p95: ___ ms → Delta: ___%
|
|
79
|
+
- ✅ PASS if delta ≥ 10% improvement | ❌ FAIL if delta < 10% or regressed
|
|
80
|
+
- [ ] **Throughput not degraded**: After RPS ≥ 95% of before RPS.
|
|
81
|
+
- Before RPS: ___ → After RPS: ___ → Delta: ___%
|
|
82
|
+
- ✅ PASS if delta ≥ -5% | ❌ FAIL if throughput decreased > 5%
|
|
83
|
+
- [ ] **Error rate not increased**: After error rate ≤ before error rate.
|
|
84
|
+
- Before: ___% → After: ___%
|
|
85
|
+
- ✅ PASS if no increase | ❌ FAIL if increased
|
|
86
|
+
- [ ] **Memory growth not increased**: After memory delta ≤ before memory delta + 10 MB.
|
|
87
|
+
- Before delta: ___ MB → After delta: ___ MB
|
|
88
|
+
- ✅ PASS if within acceptable range | ❌ FAIL if memory growth increased
|
|
89
|
+
|
|
90
|
+
### Gate 3: SLO compliance (all targets must be met)
|
|
91
|
+
- [ ] p50 ≤ SLA target: ___ ms
|
|
92
|
+
- [ ] p95 ≤ SLA target: ___ ms
|
|
93
|
+
- [ ] p99 ≤ SLA target: ___ ms
|
|
94
|
+
- [ ] Throughput ≥ minimum: ___ RPS
|
|
95
|
+
- [ ] Error rate ≤ SLA target: ___%
|
|
96
|
+
|
|
97
|
+
### Gate 4: Stability (no flakiness)
|
|
98
|
+
- [ ] All 5 after-baseline runs show variance < 15% for p95. (Consistent improvement, not a one-off lucky run.)
|
|
99
|
+
- [ ] Run a 10-minute mini-soak test at 50% peak concurrency. Memory does not grow > 25 MB over this period.
|
|
100
|
+
- [ ] No error rate spikes observed during the soak test.
|
|
101
|
+
|
|
102
|
+
### Gate 5: Adjacent endpoint regression check
|
|
103
|
+
- [ ] Run full regression detection (all in-scope endpoints, not just the optimized one).
|
|
104
|
+
- `REGRESSION_SUMMARY.json` shows 0 regressions on adjacent endpoints.
|
|
105
|
+
- If any adjacent endpoint regressed: STOP, investigate before proceeding.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Go/No-Go Performance Criteria by Tier
|
|
110
|
+
|
|
111
|
+
### Web API (synchronous REST endpoints)
|
|
112
|
+
|
|
113
|
+
| Criterion | Go threshold | No-Go threshold |
|
|
114
|
+
|-----------|-------------|-----------------|
|
|
115
|
+
| p95 latency | ≤ 200 ms | > 300 ms |
|
|
116
|
+
| p99 latency | ≤ 500 ms | > 1000 ms |
|
|
117
|
+
| Throughput | ≥ 500 RPS per instance | < 300 RPS per instance |
|
|
118
|
+
| Error rate | < 0.1% | > 0.5% |
|
|
119
|
+
| Memory growth (5 min) | < 20 MB | > 50 MB |
|
|
120
|
+
|
|
121
|
+
**Decision**: ALL criteria must be Go. One No-Go criterion blocks the optimization deployment.
|
|
122
|
+
|
|
123
|
+
### Batch Job (async/scheduled processing)
|
|
124
|
+
|
|
125
|
+
| Criterion | Go threshold | No-Go threshold |
|
|
126
|
+
|-----------|-------------|-----------------|
|
|
127
|
+
| Job completion time | ≤ defined SLA per batch | > 2× SLA |
|
|
128
|
+
| Records processed/sec | ≥ baseline × 0.95 | < baseline × 0.80 |
|
|
129
|
+
| Memory peak | < 2 GB | > 4 GB |
|
|
130
|
+
| Error rate | < 1% | > 5% |
|
|
131
|
+
| CPU utilization | < 80% avg | > 95% sustained |
|
|
132
|
+
|
|
133
|
+
### Real-Time Services (WebSocket, streaming, event-driven)
|
|
134
|
+
|
|
135
|
+
| Criterion | Go threshold | No-Go threshold |
|
|
136
|
+
|-----------|-------------|-----------------|
|
|
137
|
+
| Message latency p95 | ≤ 50 ms | > 100 ms |
|
|
138
|
+
| Message latency p99 | ≤ 100 ms | > 200 ms |
|
|
139
|
+
| Throughput | ≥ 1000 events/sec per instance | < 500 events/sec |
|
|
140
|
+
| Error rate | < 0.01% | > 0.1% |
|
|
141
|
+
| Memory growth (30 min) | < 50 MB | > 200 MB |
|
|
142
|
+
|
|
143
|
+
### Database Layer (query optimization)
|
|
144
|
+
|
|
145
|
+
| Criterion | Go threshold | No-Go threshold |
|
|
146
|
+
|-----------|-------------|-----------------|
|
|
147
|
+
| Query p95 | ≤ 10 ms (indexed) | > 50 ms |
|
|
148
|
+
| Sequential scans eliminated | 100% of targeted queries | Any targeted query still scanning |
|
|
149
|
+
| Index usage confirmed | EXPLAIN ANALYZE shows Index Scan | Seq Scan remains |
|
|
150
|
+
| Replication lag | < 100 ms | > 1 s |
|
|
151
|
+
| Connection pool wait | < 5 ms | > 50 ms |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Rollback Trigger Conditions
|
|
156
|
+
|
|
157
|
+
Initiate rollback IMMEDIATELY if any of the following occur in production after deployment:
|
|
158
|
+
|
|
159
|
+
### Automatic rollback triggers (CI/CD can execute without human approval)
|
|
160
|
+
- Error rate exceeds 1% for more than 2 consecutive minutes.
|
|
161
|
+
- p95 latency exceeds 2× the before-baseline value for more than 3 minutes.
|
|
162
|
+
- Service health check (`/health` or `/readiness`) starts failing.
|
|
163
|
+
- Memory RSS exceeds 90% of container limit.
|
|
164
|
+
- Database connection pool wait time exceeds 500 ms.
|
|
165
|
+
|
|
166
|
+
### Human-reviewed rollback triggers (escalate to on-call, decision within 5 min)
|
|
167
|
+
- p95 latency exceeds 1.5× before-baseline for more than 5 minutes.
|
|
168
|
+
- Error rate between 0.5% and 1% sustained for > 5 minutes.
|
|
169
|
+
- New exception type appearing in logs at high frequency (> 100/min).
|
|
170
|
+
- Database slow query log showing new queries > 5 seconds.
|
|
171
|
+
- External dependency (payment provider, auth service) reporting increased error rates correlated with the deployment.
|
|
172
|
+
|
|
173
|
+
### Rollback procedure
|
|
174
|
+
```bash
|
|
175
|
+
# Option 1: Kubernetes rollout undo
|
|
176
|
+
kubectl rollout undo deployment/service-name
|
|
177
|
+
|
|
178
|
+
# Option 2: Feature flag disable (no deployment required)
|
|
179
|
+
curl -X PATCH https://flagd-host/flags/perf-optimization-001 \
|
|
180
|
+
-d '{"enabled": false}'
|
|
181
|
+
|
|
182
|
+
# Option 3: Database migration revert
|
|
183
|
+
npm run migrate:down -- --to=<previous-migration-id>
|
|
184
|
+
# Or:
|
|
185
|
+
psql -f migrations/revert-<optimization>.sql
|
|
186
|
+
|
|
187
|
+
# Verify rollback
|
|
188
|
+
kubectl rollout status deployment/service-name
|
|
189
|
+
curl https://service/health
|
|
190
|
+
# Run smoke test
|
|
191
|
+
k6 run --vus 1 --duration 30s smoke-test.js
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Post-rollback actions
|
|
195
|
+
- [ ] Confirm error rate returned to pre-optimization baseline within 5 minutes.
|
|
196
|
+
- [ ] Confirm p95 latency returned to pre-optimization baseline within 5 minutes.
|
|
197
|
+
- [ ] Create incident report documenting: what regressed, what was rolled back, when, by whom.
|
|
198
|
+
- [ ] Add to `OPTIMIZATION_RECOMMENDATIONS.md` under the failed optimization: "ATTEMPTED [date] — ROLLED BACK. Reason: [root cause]. Next attempt: [redesign notes]."
|
|
199
|
+
- [ ] Schedule post-mortem within 24 hours if production impact was > 5 minutes.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Performance Baseline Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist every time you capture a performance baseline. Complete every item in order. Do not skip items — each gate exists because a skipped step has caused a bad baseline in the past.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Pre-Baseline: Environment Isolation
|
|
8
|
+
|
|
9
|
+
### Infrastructure isolation
|
|
10
|
+
- [ ] **Test environment is NOT shared with production traffic.** Confirm with ops/SRE that no production routes to this environment.
|
|
11
|
+
- [ ] **No deployments are in progress.** Deployments during baseline capture invalidate results. Check CI/CD pipeline status.
|
|
12
|
+
- [ ] **No scheduled jobs running.** Check cron schedules and batch job queues. Postpone or disable non-critical jobs for the duration.
|
|
13
|
+
- [ ] **Auto-scaling is DISABLED or pinned.** If the environment auto-scales, pin to a fixed instance count for the test. Note the pinned count.
|
|
14
|
+
- [ ] **Horizontal pod count is stable.** For Kubernetes: confirm `kubectl get pods` shows all pods Running and Ready. No pending restarts.
|
|
15
|
+
- [ ] **Database is not under maintenance.** Confirm no vacuum, reindex, or backup jobs scheduled during the test window.
|
|
16
|
+
- [ ] **External dependencies are stubbed or consistent.** Third-party APIs (payment, email, SMS) should be mocked or pointed at their own stable sandbox. Document which ones are mocked.
|
|
17
|
+
|
|
18
|
+
### Resource baseline snapshot
|
|
19
|
+
Before starting any test traffic, record current resource state:
|
|
20
|
+
- [ ] CPU utilization < 5% (idle baseline). Command: `top -bn1 | grep "Cpu(s)"`
|
|
21
|
+
- [ ] Available memory > 70% of total. Command: `free -m`
|
|
22
|
+
- [ ] Disk I/O idle. Command: `iostat -x 1 5`
|
|
23
|
+
- [ ] Network utilization < 10 Mbps (background noise). Command: `iftop` or `nethogs`
|
|
24
|
+
- [ ] Database connection pool: active connections < 20% of max. Command: `SELECT count(*) FROM pg_stat_activity WHERE state = 'active';`
|
|
25
|
+
- [ ] No alerts firing in monitoring stack (Grafana/Datadog). Check alert manager before starting.
|
|
26
|
+
|
|
27
|
+
### Tool installation verification
|
|
28
|
+
- [ ] **k6 installed and correct version** (≥ 0.45): `k6 version`
|
|
29
|
+
- [ ] **Artillery installed** (if using): `artillery --version`
|
|
30
|
+
- [ ] **Locust installed** (if using): `locust --version`
|
|
31
|
+
- [ ] **wrk2 or hey available** (for quick smoke latency): `wrk --version` or `hey --version`
|
|
32
|
+
- [ ] **Language profiler available**:
|
|
33
|
+
- Node.js: `clinic --version` or verify `--prof` flag works.
|
|
34
|
+
- Python: `py-spy --version`
|
|
35
|
+
- Go: `go tool pprof` available
|
|
36
|
+
- [ ] **jq installed** for JSON result parsing: `jq --version`
|
|
37
|
+
- [ ] **Prometheus metrics endpoint reachable**: `curl http://service-host:9090/metrics | head -20`
|
|
38
|
+
|
|
39
|
+
### Authentication and connectivity
|
|
40
|
+
- [ ] **Test API tokens are valid and not expiring during the test.** Check token TTL — should be > test duration + 30 min buffer.
|
|
41
|
+
- [ ] **All target endpoints reachable from test runner.** Run `curl -s -o /dev/null -w "%{http_code}" http://target-host/api/health` for each endpoint.
|
|
42
|
+
- [ ] **DNS resolves correctly from test runner.** Run `dig target-host` and confirm A record.
|
|
43
|
+
- [ ] **TLS certificate is valid** (not expired): `echo | openssl s_client -connect target-host:443 2>/dev/null | openssl x509 -noout -dates`
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Baseline Measurement Protocol
|
|
48
|
+
|
|
49
|
+
### What to measure
|
|
50
|
+
|
|
51
|
+
For every endpoint in scope, capture the following metrics in each run:
|
|
52
|
+
|
|
53
|
+
| Metric | Description | Unit | How to capture |
|
|
54
|
+
|--------|-------------|------|----------------|
|
|
55
|
+
| `p50_ms` | Median response time | milliseconds | k6 `http_req_duration{p:50}` |
|
|
56
|
+
| `p95_ms` | 95th percentile response time | milliseconds | k6 `http_req_duration{p:95}` |
|
|
57
|
+
| `p99_ms` | 99th percentile response time | milliseconds | k6 `http_req_duration{p:99}` |
|
|
58
|
+
| `throughput_rps` | Requests per second at peak | req/s | k6 `http_reqs` counter ÷ duration |
|
|
59
|
+
| `error_rate_pct` | HTTP 4xx/5xx rate | percentage | k6 `http_req_failed` rate |
|
|
60
|
+
| `memory_start_mb` | Process heap at test start | megabytes | Prometheus `process_resident_memory_bytes` |
|
|
61
|
+
| `memory_end_mb` | Process heap at test end | megabytes | Prometheus `process_resident_memory_bytes` |
|
|
62
|
+
| `memory_delta_mb` | Heap growth during test | megabytes | `memory_end - memory_start` |
|
|
63
|
+
| `cpu_avg_pct` | Average CPU utilization during test | percentage | Prometheus `process_cpu_seconds_total` rate |
|
|
64
|
+
| `db_query_p95_ms` | Database query 95th percentile | milliseconds | `pg_stat_statements` or slow query log |
|
|
65
|
+
| `connection_pool_wait_ms` | Connection pool wait time | milliseconds | App-level metrics or APM |
|
|
66
|
+
|
|
67
|
+
### How many runs
|
|
68
|
+
|
|
69
|
+
| Situation | Minimum runs | Notes |
|
|
70
|
+
|-----------|-------------|-------|
|
|
71
|
+
| Initial baseline | 5 runs | Discard first (JIT warm-up). Average remaining 4. |
|
|
72
|
+
| Daily CI check | 3 runs | Acceptable for regression gating if environment is consistent. |
|
|
73
|
+
| Before/after comparison | 5 runs each | Must use identical conditions. Run same day if possible. |
|
|
74
|
+
| After major optimization | 5 runs | Document before re-running to confirm stability. |
|
|
75
|
+
| Incident reproduction | 1 run (controlled) | Enough to confirm reproduction; document variance. |
|
|
76
|
+
|
|
77
|
+
### Run protocol
|
|
78
|
+
1. **Warm-up run** (discard): 30% of peak concurrency for 2 minutes. Do NOT record results.
|
|
79
|
+
2. **Wait 1 minute** for connection pools and caches to settle after warm-up.
|
|
80
|
+
3. **Measurement run 1**: Full peak concurrency for minimum 5 minutes. Record results.
|
|
81
|
+
4. **Wait 2 minutes** between runs to let pools drain and metrics settle.
|
|
82
|
+
5. **Measurement runs 2-N**: Repeat steps 3-4.
|
|
83
|
+
6. **Post-run snapshot**: Record memory and CPU after all runs complete (check for drift).
|
|
84
|
+
|
|
85
|
+
### Variance check
|
|
86
|
+
After all runs: compute variance. If p95 variance > 30% across runs, the baseline is unreliable.
|
|
87
|
+
- Do NOT average an unreliable baseline.
|
|
88
|
+
- Investigate the source of variance (see Recovery Workflow in SKILL.md).
|
|
89
|
+
- Re-run after fixing the root cause.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Load Test Design Checklist
|
|
94
|
+
|
|
95
|
+
### Traffic model design
|
|
96
|
+
- [ ] **Traffic distribution matches production**. Do not send 100% to one endpoint. Use production access log analysis to determine realistic split. Example: `GET /api/users` = 40%, `GET /api/products` = 30%, `POST /api/orders` = 20%, other = 10%.
|
|
97
|
+
- [ ] **Payload sizes match production**. Test with representative payloads (median size from logs). Do not use tiny toy payloads.
|
|
98
|
+
- [ ] **Read/write ratio matches production**. If production is 80% reads / 20% writes, the load test must reflect this.
|
|
99
|
+
- [ ] **Think time is included** for user-simulation tests (not API microbenchmarks). Add 1–5 second pauses between user actions to simulate real user behavior.
|
|
100
|
+
- [ ] **Session state is realistic**. If production users have sessions with history (shopping carts, multi-step forms), simulate stateful user journeys.
|
|
101
|
+
- [ ] **Geographic distribution considered**. If production traffic comes from multiple regions, ensure test runner location is not the only factor reducing latency (test from multiple regions for global services).
|
|
102
|
+
|
|
103
|
+
### Load test stages
|
|
104
|
+
Every load test must include these stages:
|
|
105
|
+
|
|
106
|
+
| Stage | Duration | Concurrency | Purpose |
|
|
107
|
+
|-------|----------|-------------|---------|
|
|
108
|
+
| Smoke | 1 min | 1 VU | Verify endpoint responds without errors at all |
|
|
109
|
+
| Ramp-up | 2 min | 0 → target VUs | Simulate organic traffic growth; avoid cold-start spikes |
|
|
110
|
+
| Peak | 5-30 min | Target VUs | Measure steady-state performance at expected load |
|
|
111
|
+
| Stress (optional) | 5 min | 2× target VUs | Find breaking point and graceful degradation behavior |
|
|
112
|
+
| Ramp-down | 1 min | Target → 0 VUs | Verify graceful connection drain |
|
|
113
|
+
| Soak (optional) | 30 min | 50% target VUs | Detect memory leaks, connection pool exhaustion, drift |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Regression Threshold Definitions
|
|
118
|
+
|
|
119
|
+
Use these thresholds to classify measurement deltas as REGRESSION / STABLE / IMPROVEMENT.
|
|
120
|
+
|
|
121
|
+
### Latency thresholds
|
|
122
|
+
|
|
123
|
+
| Tier | SLA target | Regression if p95 increases by | Improvement if p95 decreases by |
|
|
124
|
+
|------|-----------|-------------------------------|--------------------------------|
|
|
125
|
+
| Real-time (WebSocket, streaming) | < 50 ms | > 10% | > 5% |
|
|
126
|
+
| Web API (synchronous REST) | < 200 ms | > 20% | > 10% |
|
|
127
|
+
| Internal service (microservice call) | < 100 ms | > 15% | > 10% |
|
|
128
|
+
| Background job (async processing) | < 5000 ms | > 30% | > 15% |
|
|
129
|
+
| Batch processing | < 60 s | > 25% | > 20% |
|
|
130
|
+
|
|
131
|
+
### Throughput thresholds
|
|
132
|
+
|
|
133
|
+
| Tier | Regression if RPS decreases by | Improvement if RPS increases by |
|
|
134
|
+
|------|-------------------------------|--------------------------------|
|
|
135
|
+
| Web API | > 15% | > 10% |
|
|
136
|
+
| Internal service | > 20% | > 15% |
|
|
137
|
+
| Batch job | > 25% | > 20% |
|
|
138
|
+
|
|
139
|
+
### Error rate thresholds (absolute, not relative)
|
|
140
|
+
|
|
141
|
+
| Tier | SLA target | Flag as CRITICAL if | Flag as WARNING if |
|
|
142
|
+
|------|-----------|--------------------|--------------------|
|
|
143
|
+
| Payment / financial | < 0.01% | > 0.05% | > 0.01% |
|
|
144
|
+
| Web API (standard) | < 0.1% | > 0.5% | > 0.1% |
|
|
145
|
+
| Internal service | < 0.5% | > 1% | > 0.5% |
|
|
146
|
+
| Background job | < 1% | > 5% | > 1% |
|
|
147
|
+
|
|
148
|
+
### Memory growth thresholds
|
|
149
|
+
|
|
150
|
+
| Duration | Acceptable growth | Warning | Leak suspected |
|
|
151
|
+
|----------|------------------|---------|----------------|
|
|
152
|
+
| 5 min test | < 20 MB | 20-50 MB | > 50 MB |
|
|
153
|
+
| 30 min soak | < 50 MB | 50-100 MB | > 100 MB |
|
|
154
|
+
| 1 hour soak | < 100 MB | 100-200 MB | > 200 MB |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Post-Optimization Validation Gates
|
|
159
|
+
|
|
160
|
+
After implementing any optimization, ALL of the following gates must pass before declaring success:
|
|
161
|
+
|
|
162
|
+
### Gate 1: Improvement confirmation
|
|
163
|
+
- [ ] After-baseline p95 is ≥ 10% lower than before-baseline p95 (meaningful improvement, not noise).
|
|
164
|
+
- [ ] After-baseline throughput is NOT lower than before-baseline throughput (optimization didn't trade throughput for latency).
|
|
165
|
+
- [ ] After-baseline error rate is NOT higher than before-baseline error rate.
|
|
166
|
+
- [ ] After-baseline memory delta is NOT higher than before-baseline memory delta.
|
|
167
|
+
|
|
168
|
+
### Gate 2: SLO compliance
|
|
169
|
+
- [ ] All endpoints pass their defined p95 SLA target (not just "better than before").
|
|
170
|
+
- [ ] Error rate is below SLA threshold.
|
|
171
|
+
- [ ] Throughput meets minimum RPS target.
|
|
172
|
+
|
|
173
|
+
### Gate 3: Stability
|
|
174
|
+
- [ ] Run 3 after-baseline measurements; variance < 15% across runs (optimization is stable, not flaky).
|
|
175
|
+
- [ ] Memory does not grow unboundedly over a 10-minute post-optimization soak test.
|
|
176
|
+
|
|
177
|
+
### Gate 4: Regression check on adjacent endpoints
|
|
178
|
+
- [ ] Run regression detection on ALL endpoints in scope, not just the optimized one. Confirm no adjacent regressions were introduced.
|
|
179
|
+
|
|
180
|
+
### Gate 5: Documentation
|
|
181
|
+
- [ ] `PERF_LOG.md` updated with before/after comparison.
|
|
182
|
+
- [ ] `OPTIMIZATION_RECOMMENDATIONS.md` marked as implemented with date and commit SHA.
|
|
183
|
+
- [ ] `PERF_BASELINE.json` updated with new after-baseline (old baseline archived, not deleted).
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Worked Example: Profiling a Slow /api/users Endpoint
|
|
2
|
+
|
|
3
|
+
**Scenario**: The `GET /api/users` endpoint in the `users-api` service is taking 450 ms at p95. The SLA target is 200 ms. A customer support ticket reports "the user list is very slow." The team suspects a database issue.
|
|
4
|
+
|
|
5
|
+
This example walks through the complete cycle: baseline → profile → identify → fix → verify.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Step 1: Capture Baseline
|
|
10
|
+
|
|
11
|
+
**Environment**: staging-isolated (no production traffic, background CPU < 2%)
|
|
12
|
+
**Version**: users-api v1.4.1 (commit: `abc1234`)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Run k6 baseline (5 runs, discard first)
|
|
16
|
+
k6 run \
|
|
17
|
+
--env BASE_URL=https://api.staging.example.com \
|
|
18
|
+
--env AUTH_TOKEN=$STAGING_TOKEN \
|
|
19
|
+
--vus 50 --duration 5m \
|
|
20
|
+
baseline-check.js
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Baseline results (averaged across 4 runs):**
|
|
24
|
+
|
|
25
|
+
| Endpoint | p50 ms | p95 ms | p99 ms | RPS | Error % | SLA | Status |
|
|
26
|
+
|----------|--------|--------|--------|-----|---------|-----|--------|
|
|
27
|
+
| GET /api/users | 180 | **450** | 920 | 68 | 0.04 | 200 ms | ❌ FAIL |
|
|
28
|
+
| GET /api/users/:id | 15 | 55 | 120 | 312 | 0.01 | 200 ms | ✅ PASS |
|
|
29
|
+
| POST /api/orders | 90 | 185 | 380 | 145 | 0.05 | 300 ms | ✅ PASS |
|
|
30
|
+
|
|
31
|
+
**Finding**: Only `GET /api/users` is failing SLA. Other endpoints are fine. This narrows the scope.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Step 2: Identify Bottleneck Type
|
|
36
|
+
|
|
37
|
+
**CPU check during load test:**
|
|
38
|
+
```bash
|
|
39
|
+
# During the 5-min load test, check CPU
|
|
40
|
+
top -bn1 | grep "Cpu(s)"
|
|
41
|
+
# us=18.3% sy=2.1% id=78.5% — CPU is NOT the bottleneck (only 20% used)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Memory check:**
|
|
45
|
+
```bash
|
|
46
|
+
# Memory at start vs end
|
|
47
|
+
# Start: 256 MB RSS, End: 261 MB — only +5 MB, no leak
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**DB query analysis:**
|
|
51
|
+
```sql
|
|
52
|
+
SELECT query, calls, total_time/calls AS avg_ms, rows/calls AS avg_rows
|
|
53
|
+
FROM pg_stat_statements
|
|
54
|
+
ORDER BY avg_ms DESC
|
|
55
|
+
LIMIT 5;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Results:
|
|
59
|
+
```
|
|
60
|
+
query calls avg_ms avg_rows
|
|
61
|
+
SELECT * FROM users WHERE tenant_id=$1 50 385.2 8500
|
|
62
|
+
SELECT * FROM profiles WHERE user_id=$1 4250 0.8 1.0
|
|
63
|
+
SELECT * FROM users WHERE tenant_id=$1 ... 50 380.1 8500
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Finding**: The `SELECT * FROM users WHERE tenant_id=$1` query is taking **385 ms** on average — that's **85% of the total response time (450 ms)**. And there are also 4,250 calls to `SELECT * FROM profiles WHERE user_id=$1` for just 50 parent queries → **classic N+1 pattern**.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Step 3: Deep Analysis
|
|
71
|
+
|
|
72
|
+
```sql
|
|
73
|
+
-- Run EXPLAIN ANALYZE on the slow query
|
|
74
|
+
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
|
|
75
|
+
SELECT u.*, p.avatar_url, p.bio
|
|
76
|
+
FROM users u
|
|
77
|
+
WHERE u.tenant_id = 1
|
|
78
|
+
ORDER BY u.created_at DESC
|
|
79
|
+
LIMIT 50;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Output:
|
|
83
|
+
```
|
|
84
|
+
Limit (cost=45234.56..45234.69 rows=50 width=248) (actual time=385.123..385.145 rows=50 loops=1)
|
|
85
|
+
-> Sort (cost=45234.56..47484.56 rows=900000 width=248) (actual time=385.111..385.125 rows=50 loops=1)
|
|
86
|
+
Sort Key: created_at DESC
|
|
87
|
+
Sort Method: external merge Disk: 32768kB ← sorting 32 MB to disk!
|
|
88
|
+
-> Seq Scan on users (cost=0..20234.00 rows=900000 width=248) (actual time=0.034..120.456 rows=8500 loops=1)
|
|
89
|
+
Filter: (tenant_id = 1)
|
|
90
|
+
Rows Removed by Filter: 841500 ← scanning 850K rows, only 8500 match!
|
|
91
|
+
Planning Time: 0.452 ms
|
|
92
|
+
Execution Time: 385.312 ms
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Root cause identified:**
|
|
96
|
+
1. **Sequential scan on 850,000 rows** to find 8,500 belonging to `tenant_id=1`. No index on `tenant_id`.
|
|
97
|
+
2. **Sort to disk (32 MB)** because there's no index on `created_at` to support the sort.
|
|
98
|
+
3. **N+1 pattern**: Application makes 1 query for users list, then 1 query per user for their profile (50 users = 51 total queries).
|
|
99
|
+
|
|
100
|
+
**Check indexes:**
|
|
101
|
+
```sql
|
|
102
|
+
SELECT indexname FROM pg_indexes WHERE tablename = 'users';
|
|
103
|
+
-- Output: pk_users (primary key only)
|
|
104
|
+
-- Missing: index on tenant_id, index on created_at
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Step 4: Implement Fix
|
|
110
|
+
|
|
111
|
+
**Fix 1: Add missing index** (migration file: `20260531-add-users-tenant-index.sql`)
|
|
112
|
+
```sql
|
|
113
|
+
-- Non-blocking index creation (CONCURRENTLY means no table lock)
|
|
114
|
+
CREATE INDEX CONCURRENTLY idx_users_tenant_created
|
|
115
|
+
ON users(tenant_id, created_at DESC);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Fix 2: Fix N+1 ORM query** (file: `src/routes/users.js`)
|
|
119
|
+
```javascript
|
|
120
|
+
// BEFORE (N+1 pattern):
|
|
121
|
+
const users = await User.findAll({
|
|
122
|
+
where: { tenant_id: req.tenantId, status: req.query.status },
|
|
123
|
+
order: [['created_at', 'DESC']],
|
|
124
|
+
limit: req.query.limit || 20,
|
|
125
|
+
});
|
|
126
|
+
// Then for each user: SELECT * FROM profiles WHERE user_id=$1
|
|
127
|
+
|
|
128
|
+
// AFTER (single JOIN query):
|
|
129
|
+
const users = await User.findAll({
|
|
130
|
+
where: { tenant_id: req.tenantId, status: req.query.status },
|
|
131
|
+
order: [['created_at', 'DESC']],
|
|
132
|
+
limit: req.query.limit || 20,
|
|
133
|
+
include: [{
|
|
134
|
+
model: Profile,
|
|
135
|
+
attributes: ['avatar_url', 'bio'],
|
|
136
|
+
required: false, // LEFT JOIN so users without profiles still appear
|
|
137
|
+
}],
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Verify fix with EXPLAIN ANALYZE:**
|
|
142
|
+
```sql
|
|
143
|
+
EXPLAIN (ANALYZE, BUFFERS)
|
|
144
|
+
SELECT u.*, p.avatar_url, p.bio
|
|
145
|
+
FROM users u
|
|
146
|
+
LEFT JOIN profiles p ON u.id = p.user_id
|
|
147
|
+
WHERE u.tenant_id = 1
|
|
148
|
+
ORDER BY u.created_at DESC
|
|
149
|
+
LIMIT 50;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Output after index:
|
|
153
|
+
```
|
|
154
|
+
Limit (cost=0.57..189.23 rows=50 width=248) (actual time=0.089..0.456 rows=50 loops=1)
|
|
155
|
+
-> Index Scan using idx_users_tenant_created on users u ← Index Scan (not Seq Scan!)
|
|
156
|
+
Index Cond: (tenant_id = 1)
|
|
157
|
+
(... hash join with profiles ...)
|
|
158
|
+
Execution Time: 1.234 ms ← 385ms → 1.2ms (99.7% improvement!)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Step 5: Capture After-Baseline
|
|
164
|
+
|
|
165
|
+
Deploy the fix to staging and re-run the baseline:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
k6 run \
|
|
169
|
+
--env BASE_URL=https://api.staging.example.com \
|
|
170
|
+
--env AUTH_TOKEN=$STAGING_TOKEN \
|
|
171
|
+
--vus 50 --duration 5m \
|
|
172
|
+
baseline-check.js
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**After-baseline results (averaged across 4 runs):**
|
|
176
|
+
|
|
177
|
+
| Endpoint | Before p95 | After p95 | Delta | Delta % | SLA | Status |
|
|
178
|
+
|----------|-----------|----------|-------|---------|-----|--------|
|
|
179
|
+
| GET /api/users | 450 ms | **42 ms** | -408 ms | **-90.7%** | 200 ms | ✅ PASS |
|
|
180
|
+
| GET /api/users/:id | 55 ms | 53 ms | -2 ms | -3.6% | 200 ms | ✅ PASS |
|
|
181
|
+
| POST /api/orders | 185 ms | 187 ms | +2 ms | +1.1% | 300 ms | ✅ PASS |
|
|
182
|
+
|
|
183
|
+
**Verification queries:**
|
|
184
|
+
```sql
|
|
185
|
+
-- N+1 pattern gone — profiles query should no longer appear
|
|
186
|
+
SELECT query, calls FROM pg_stat_statements
|
|
187
|
+
WHERE query LIKE '%profiles WHERE user_id%'
|
|
188
|
+
ORDER BY calls DESC;
|
|
189
|
+
-- Result: 0 rows (query no longer exists!)
|
|
190
|
+
|
|
191
|
+
-- Main query is now fast
|
|
192
|
+
SELECT query, calls, total_time/calls AS avg_ms
|
|
193
|
+
FROM pg_stat_statements
|
|
194
|
+
WHERE query LIKE '%users WHERE tenant_id%'
|
|
195
|
+
ORDER BY avg_ms DESC;
|
|
196
|
+
-- Result: avg_ms = 1.2 ms (was 385 ms — 99.7% improvement)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Outcome Summary
|
|
202
|
+
|
|
203
|
+
| Metric | Before | After | Improvement |
|
|
204
|
+
|--------|--------|-------|-------------|
|
|
205
|
+
| p50 latency | 180 ms | 18 ms | -90.0% |
|
|
206
|
+
| p95 latency | 450 ms | 42 ms | -90.7% |
|
|
207
|
+
| p99 latency | 920 ms | 95 ms | -89.7% |
|
|
208
|
+
| Throughput | 68 RPS | 489 RPS | +619% |
|
|
209
|
+
| DB queries per request | 51 (N+1) | 1 (JOIN) | -98% |
|
|
210
|
+
| DB query time | 385 ms | 1.2 ms | -99.7% |
|
|
211
|
+
|
|
212
|
+
**Code changes**: 1 SQL migration file + 3 lines of ORM change.
|
|
213
|
+
**Time to fix**: 2 hours (1 hour profiling, 1 hour implementing + verifying).
|
|
214
|
+
**SLA compliance**: ✅ PASS (42 ms vs 200 ms SLA target — 79% margin).
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## PERF_LOG.md Entry for This Cycle
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
---
|
|
222
|
+
date: 2026-05-31
|
|
223
|
+
version: 1.4.2
|
|
224
|
+
commit: def5678
|
|
225
|
+
environment: staging-isolated
|
|
226
|
+
test_type: optimization
|
|
227
|
+
triggered_by: Customer complaint (support ticket SUP-1234)
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
Fixed N+1 ORM query and added missing index on users(tenant_id, created_at).
|
|
231
|
+
GET /api/users p95 improved from 450 ms to 42 ms (90.7% improvement).
|
|
232
|
+
SLA target of 200 ms now comfortably met with 79% margin.
|
|
233
|
+
No adjacent endpoint regressions detected.
|
|
234
|
+
```
|