forgecraft-mcp 1.4.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +67 -0
- package/README.md +527 -525
- package/dist/analyzers/anchors/anchor-loader.d.ts +47 -0
- package/dist/analyzers/anchors/anchor-loader.d.ts.map +1 -0
- package/dist/analyzers/anchors/anchor-loader.js +113 -0
- package/dist/analyzers/anchors/anchor-loader.js.map +1 -0
- package/dist/analyzers/anti-pattern.d.ts.map +1 -1
- package/dist/analyzers/anti-pattern.js +38 -26
- package/dist/analyzers/anti-pattern.js.map +1 -1
- package/dist/analyzers/completeness-helpers.d.ts +5 -0
- package/dist/analyzers/completeness-helpers.d.ts.map +1 -1
- package/dist/analyzers/completeness-helpers.js +17 -0
- package/dist/analyzers/completeness-helpers.js.map +1 -1
- package/dist/analyzers/completeness.d.ts.map +1 -1
- package/dist/analyzers/completeness.js +4 -4
- package/dist/analyzers/completeness.js.map +1 -1
- package/dist/analyzers/gs-scorer.d.ts +3 -1
- package/dist/analyzers/gs-scorer.d.ts.map +1 -1
- package/dist/analyzers/gs-scorer.js +5 -2
- package/dist/analyzers/gs-scorer.js.map +1 -1
- package/dist/analyzers/package-json.d.ts.map +1 -1
- package/dist/analyzers/package-json.js +194 -34
- package/dist/analyzers/package-json.js.map +1 -1
- package/dist/analyzers/scorers/composable-scorer.d.ts +4 -2
- package/dist/analyzers/scorers/composable-scorer.d.ts.map +1 -1
- package/dist/analyzers/scorers/composable-scorer.js +50 -2
- package/dist/analyzers/scorers/composable-scorer.js.map +1 -1
- package/dist/analyzers/scorers/executable-scorer.d.ts +3 -2
- package/dist/analyzers/scorers/executable-scorer.d.ts.map +1 -1
- package/dist/analyzers/scorers/executable-scorer.js +64 -4
- package/dist/analyzers/scorers/executable-scorer.js.map +1 -1
- package/dist/analyzers/scorers/scorer-utils.d.ts +5 -3
- package/dist/analyzers/scorers/scorer-utils.d.ts.map +1 -1
- package/dist/analyzers/scorers/scorer-utils.js +34 -9
- package/dist/analyzers/scorers/scorer-utils.js.map +1 -1
- package/dist/analyzers/scorers/self-describing-scorer.d.ts +7 -4
- package/dist/analyzers/scorers/self-describing-scorer.d.ts.map +1 -1
- package/dist/analyzers/scorers/self-describing-scorer.js +17 -18
- package/dist/analyzers/scorers/self-describing-scorer.js.map +1 -1
- package/dist/cli/help.js +51 -51
- package/dist/disciplines/catalog.d.ts +16 -0
- package/dist/disciplines/catalog.d.ts.map +1 -0
- package/dist/disciplines/catalog.js +196 -0
- package/dist/disciplines/catalog.js.map +1 -0
- package/dist/disciplines/runner.d.ts +13 -0
- package/dist/disciplines/runner.d.ts.map +1 -0
- package/dist/disciplines/runner.js +35 -0
- package/dist/disciplines/runner.js.map +1 -0
- package/dist/registry/composer.d.ts.map +1 -1
- package/dist/registry/composer.js +9 -4
- package/dist/registry/composer.js.map +1 -1
- package/dist/registry/loader-tag.d.ts.map +1 -1
- package/dist/registry/loader-tag.js +1 -0
- package/dist/registry/loader-tag.js.map +1 -1
- package/dist/registry/remote-gates.js +1 -1
- package/dist/registry/remote-gates.js.map +1 -1
- package/dist/registry/renderer-skeletons.js +92 -92
- package/dist/registry/sentinel-renderer.js +299 -20
- package/dist/registry/sentinel-renderer.js.map +1 -1
- package/dist/sentinel/detect.d.ts +41 -0
- package/dist/sentinel/detect.d.ts.map +1 -0
- package/dist/sentinel/detect.js +122 -0
- package/dist/sentinel/detect.js.map +1 -0
- package/dist/sentinel/write.d.ts +54 -0
- package/dist/sentinel/write.d.ts.map +1 -0
- package/dist/sentinel/write.js +75 -0
- package/dist/sentinel/write.js.map +1 -0
- package/dist/shared/cnt-health.d.ts +16 -0
- package/dist/shared/cnt-health.d.ts.map +1 -1
- package/dist/shared/cnt-health.js +55 -8
- package/dist/shared/cnt-health.js.map +1 -1
- package/dist/shared/config.d.ts +14 -0
- package/dist/shared/config.d.ts.map +1 -1
- package/dist/shared/config.js +45 -0
- package/dist/shared/config.js.map +1 -1
- package/dist/shared/gs-score-logger.js +6 -6
- package/dist/shared/hook-installer.d.ts +58 -0
- package/dist/shared/hook-installer.d.ts.map +1 -0
- package/dist/shared/hook-installer.js +316 -0
- package/dist/shared/hook-installer.js.map +1 -0
- package/dist/shared/project-gates-helpers.d.ts +9 -0
- package/dist/shared/project-gates-helpers.d.ts.map +1 -1
- package/dist/shared/project-gates-helpers.js +35 -0
- package/dist/shared/project-gates-helpers.js.map +1 -1
- package/dist/shared/types/config.d.ts +7 -1
- package/dist/shared/types/config.d.ts.map +1 -1
- package/dist/shared/types/gates.d.ts +34 -0
- package/dist/shared/types/gates.d.ts.map +1 -1
- package/dist/shared/types/project.d.ts +68 -2
- package/dist/shared/types/project.d.ts.map +1 -1
- package/dist/shared/types/project.js +1 -0
- package/dist/shared/types/project.js.map +1 -1
- package/dist/shared/types/templates.d.ts +8 -1
- package/dist/shared/types/templates.d.ts.map +1 -1
- package/dist/shared/types/verify.d.ts +51 -1
- package/dist/shared/types/verify.d.ts.map +1 -1
- package/dist/shared/types/verify.js +37 -1
- package/dist/shared/types/verify.js.map +1 -1
- package/dist/tools/add-hook.d.ts.map +1 -1
- package/dist/tools/add-hook.js +8 -1
- package/dist/tools/add-hook.js.map +1 -1
- package/dist/tools/add-module.js +123 -123
- package/dist/tools/advice-registry.d.ts.map +1 -1
- package/dist/tools/advice-registry.js +108 -18
- package/dist/tools/advice-registry.js.map +1 -1
- package/dist/tools/advise-session-advisor.d.ts +16 -0
- package/dist/tools/advise-session-advisor.d.ts.map +1 -0
- package/dist/tools/advise-session-advisor.js +89 -0
- package/dist/tools/advise-session-advisor.js.map +1 -0
- package/dist/tools/advise-session-signals.d.ts +21 -0
- package/dist/tools/advise-session-signals.d.ts.map +1 -0
- package/dist/tools/advise-session-signals.js +113 -0
- package/dist/tools/advise-session-signals.js.map +1 -0
- package/dist/tools/advise-session.d.ts +22 -0
- package/dist/tools/advise-session.d.ts.map +1 -0
- package/dist/tools/advise-session.js +31 -0
- package/dist/tools/advise-session.js.map +1 -0
- package/dist/tools/analyze-harness.d.ts +18 -0
- package/dist/tools/analyze-harness.d.ts.map +1 -0
- package/dist/tools/analyze-harness.js +298 -0
- package/dist/tools/analyze-harness.js.map +1 -0
- package/dist/tools/audit.d.ts.map +1 -1
- package/dist/tools/audit.js +19 -0
- package/dist/tools/audit.js.map +1 -1
- package/dist/tools/change-request.d.ts +53 -0
- package/dist/tools/change-request.d.ts.map +1 -0
- package/dist/tools/change-request.js +395 -0
- package/dist/tools/change-request.js.map +1 -0
- package/dist/tools/check-cascade-contracts.d.ts +13 -0
- package/dist/tools/check-cascade-contracts.d.ts.map +1 -1
- package/dist/tools/check-cascade-contracts.js +73 -2
- package/dist/tools/check-cascade-contracts.js.map +1 -1
- package/dist/tools/check-cascade-report.js +64 -64
- package/dist/tools/check-cascade-steps.d.ts +3 -0
- package/dist/tools/check-cascade-steps.d.ts.map +1 -1
- package/dist/tools/check-cascade-steps.js +104 -15
- package/dist/tools/check-cascade-steps.js.map +1 -1
- package/dist/tools/check-cascade.d.ts +4 -3
- package/dist/tools/check-cascade.d.ts.map +1 -1
- package/dist/tools/check-cascade.js +30 -12
- package/dist/tools/check-cascade.js.map +1 -1
- package/dist/tools/check-derivation-chain.d.ts +37 -0
- package/dist/tools/check-derivation-chain.d.ts.map +1 -0
- package/dist/tools/check-derivation-chain.js +418 -0
- package/dist/tools/check-derivation-chain.js.map +1 -0
- package/dist/tools/check-spec-consistency.d.ts +25 -0
- package/dist/tools/check-spec-consistency.d.ts.map +1 -0
- package/dist/tools/check-spec-consistency.js +339 -0
- package/dist/tools/check-spec-consistency.js.map +1 -0
- package/dist/tools/check-t4.d.ts +54 -0
- package/dist/tools/check-t4.d.ts.map +1 -0
- package/dist/tools/check-t4.js +305 -0
- package/dist/tools/check-t4.js.map +1 -0
- package/dist/tools/close-cycle.d.ts +11 -0
- package/dist/tools/close-cycle.d.ts.map +1 -1
- package/dist/tools/close-cycle.js +364 -4
- package/dist/tools/close-cycle.js.map +1 -1
- package/dist/tools/cnt-add-routing.d.ts +31 -0
- package/dist/tools/cnt-add-routing.d.ts.map +1 -0
- package/dist/tools/cnt-add-routing.js +99 -0
- package/dist/tools/cnt-add-routing.js.map +1 -0
- package/dist/tools/configure-mcp.d.ts.map +1 -1
- package/dist/tools/configure-mcp.js +52 -2
- package/dist/tools/configure-mcp.js.map +1 -1
- package/dist/tools/consolidate-status.d.ts +31 -0
- package/dist/tools/consolidate-status.d.ts.map +1 -1
- package/dist/tools/consolidate-status.js +105 -0
- package/dist/tools/consolidate-status.js.map +1 -1
- package/dist/tools/executable-gates.d.ts +52 -0
- package/dist/tools/executable-gates.d.ts.map +1 -0
- package/dist/tools/executable-gates.js +333 -0
- package/dist/tools/executable-gates.js.map +1 -0
- package/dist/tools/extract-adrs-from-spec.d.ts +33 -0
- package/dist/tools/extract-adrs-from-spec.d.ts.map +1 -0
- package/dist/tools/extract-adrs-from-spec.js +410 -0
- package/dist/tools/extract-adrs-from-spec.js.map +1 -0
- package/dist/tools/extract-adrs-history.d.ts +47 -0
- package/dist/tools/extract-adrs-history.d.ts.map +1 -0
- package/dist/tools/extract-adrs-history.js +265 -0
- package/dist/tools/extract-adrs-history.js.map +1 -0
- package/dist/tools/forgecraft-dispatch-extended.d.ts.map +1 -1
- package/dist/tools/forgecraft-dispatch-extended.js +137 -0
- package/dist/tools/forgecraft-dispatch-extended.js.map +1 -1
- package/dist/tools/forgecraft-dispatch.d.ts.map +1 -1
- package/dist/tools/forgecraft-dispatch.js +16 -0
- package/dist/tools/forgecraft-dispatch.js.map +1 -1
- package/dist/tools/forgecraft-schema-params.d.ts +174 -2
- package/dist/tools/forgecraft-schema-params.d.ts.map +1 -1
- package/dist/tools/forgecraft-schema-params.js +197 -0
- package/dist/tools/forgecraft-schema-params.js.map +1 -1
- package/dist/tools/forgecraft-schema.d.ts +179 -7
- package/dist/tools/forgecraft-schema.d.ts.map +1 -1
- package/dist/tools/forgecraft-schema.js +37 -0
- package/dist/tools/forgecraft-schema.js.map +1 -1
- package/dist/tools/generate-adr.js +6 -6
- package/dist/tools/generate-adr.js.map +1 -1
- package/dist/tools/generate-decision.d.ts +77 -0
- package/dist/tools/generate-decision.d.ts.map +1 -0
- package/dist/tools/generate-decision.js +162 -0
- package/dist/tools/generate-decision.js.map +1 -0
- package/dist/tools/generate-env-probe.d.ts +49 -0
- package/dist/tools/generate-env-probe.d.ts.map +1 -0
- package/dist/tools/generate-env-probe.js +365 -0
- package/dist/tools/generate-env-probe.js.map +1 -0
- package/dist/tools/generate-harness.d.ts +53 -0
- package/dist/tools/generate-harness.d.ts.map +1 -0
- package/dist/tools/generate-harness.js +395 -0
- package/dist/tools/generate-harness.js.map +1 -0
- package/dist/tools/generate-roadmap.d.ts +1 -1
- package/dist/tools/generate-roadmap.d.ts.map +1 -1
- package/dist/tools/generate-roadmap.js +38 -4
- package/dist/tools/generate-roadmap.js.map +1 -1
- package/dist/tools/generate-session-prompt.d.ts +3 -3
- package/dist/tools/generate-session-prompt.d.ts.map +1 -1
- package/dist/tools/generate-session-prompt.js +9 -1
- package/dist/tools/generate-session-prompt.js.map +1 -1
- package/dist/tools/generate-slo-probe.d.ts +53 -0
- package/dist/tools/generate-slo-probe.d.ts.map +1 -0
- package/dist/tools/generate-slo-probe.js +366 -0
- package/dist/tools/generate-slo-probe.js.map +1 -0
- package/dist/tools/layer-status-gates.d.ts +24 -0
- package/dist/tools/layer-status-gates.d.ts.map +1 -0
- package/dist/tools/layer-status-gates.js +151 -0
- package/dist/tools/layer-status-gates.js.map +1 -0
- package/dist/tools/layer-status.d.ts +126 -0
- package/dist/tools/layer-status.d.ts.map +1 -0
- package/dist/tools/layer-status.js +647 -0
- package/dist/tools/layer-status.js.map +1 -0
- package/dist/tools/list.d.ts.map +1 -1
- package/dist/tools/list.js +9 -5
- package/dist/tools/list.js.map +1 -1
- package/dist/tools/postcondition-coverage.d.ts +57 -0
- package/dist/tools/postcondition-coverage.d.ts.map +1 -0
- package/dist/tools/postcondition-coverage.js +256 -0
- package/dist/tools/postcondition-coverage.js.map +1 -0
- package/dist/tools/probe-runners.d.ts +21 -0
- package/dist/tools/probe-runners.d.ts.map +1 -0
- package/dist/tools/probe-runners.js +246 -0
- package/dist/tools/probe-runners.js.map +1 -0
- package/dist/tools/probe-templates.d.ts +27 -0
- package/dist/tools/probe-templates.d.ts.map +1 -0
- package/dist/tools/probe-templates.js +279 -0
- package/dist/tools/probe-templates.js.map +1 -0
- package/dist/tools/propose-session.d.ts +28 -0
- package/dist/tools/propose-session.d.ts.map +1 -0
- package/dist/tools/propose-session.js +333 -0
- package/dist/tools/propose-session.js.map +1 -0
- package/dist/tools/refresh-output.js +14 -14
- package/dist/tools/review-stubs.d.ts +29 -0
- package/dist/tools/review-stubs.d.ts.map +1 -0
- package/dist/tools/review-stubs.js +173 -0
- package/dist/tools/review-stubs.js.map +1 -0
- package/dist/tools/roadmap-builder.d.ts +49 -1
- package/dist/tools/roadmap-builder.d.ts.map +1 -1
- package/dist/tools/roadmap-builder.js +210 -5
- package/dist/tools/roadmap-builder.js.map +1 -1
- package/dist/tools/run-env-probe.d.ts +57 -0
- package/dist/tools/run-env-probe.d.ts.map +1 -0
- package/dist/tools/run-env-probe.js +270 -0
- package/dist/tools/run-env-probe.js.map +1 -0
- package/dist/tools/run-harness.d.ts +52 -0
- package/dist/tools/run-harness.d.ts.map +1 -0
- package/dist/tools/run-harness.js +279 -0
- package/dist/tools/run-harness.js.map +1 -0
- package/dist/tools/run-slo-probe.d.ts +50 -0
- package/dist/tools/run-slo-probe.d.ts.map +1 -0
- package/dist/tools/run-slo-probe.js +281 -0
- package/dist/tools/run-slo-probe.js.map +1 -0
- package/dist/tools/scaffold-spec-stubs.js +115 -115
- package/dist/tools/scaffold-templates.js +62 -62
- package/dist/tools/scaffold-writer.d.ts.map +1 -1
- package/dist/tools/scaffold-writer.js +9 -0
- package/dist/tools/scaffold-writer.js.map +1 -1
- package/dist/tools/score-rubric.d.ts +19 -0
- package/dist/tools/score-rubric.d.ts.map +1 -0
- package/dist/tools/score-rubric.js +411 -0
- package/dist/tools/score-rubric.js.map +1 -0
- package/dist/tools/session-prompt-builders.d.ts +20 -0
- package/dist/tools/session-prompt-builders.d.ts.map +1 -1
- package/dist/tools/session-prompt-builders.js +78 -5
- package/dist/tools/session-prompt-builders.js.map +1 -1
- package/dist/tools/session-prompt-sections.d.ts +4 -2
- package/dist/tools/session-prompt-sections.d.ts.map +1 -1
- package/dist/tools/session-prompt-sections.js +22 -10
- package/dist/tools/session-prompt-sections.js.map +1 -1
- package/dist/tools/setup-artifact-writers.d.ts +69 -4
- package/dist/tools/setup-artifact-writers.d.ts.map +1 -1
- package/dist/tools/setup-artifact-writers.js +681 -5
- package/dist/tools/setup-artifact-writers.js.map +1 -1
- package/dist/tools/setup-cnt-builders.d.ts.map +1 -1
- package/dist/tools/setup-cnt-builders.js +162 -34
- package/dist/tools/setup-cnt-builders.js.map +1 -1
- package/dist/tools/setup-monitoring.d.ts +41 -0
- package/dist/tools/setup-monitoring.d.ts.map +1 -0
- package/dist/tools/setup-monitoring.js +364 -0
- package/dist/tools/setup-monitoring.js.map +1 -0
- package/dist/tools/setup-phase1.d.ts.map +1 -1
- package/dist/tools/setup-phase1.js +14 -1
- package/dist/tools/setup-phase1.js.map +1 -1
- package/dist/tools/setup-phase2.d.ts +14 -0
- package/dist/tools/setup-phase2.d.ts.map +1 -1
- package/dist/tools/setup-phase2.js +130 -3
- package/dist/tools/setup-phase2.js.map +1 -1
- package/dist/tools/setup-project.d.ts +8 -0
- package/dist/tools/setup-project.d.ts.map +1 -1
- package/dist/tools/setup-project.js +52 -2
- package/dist/tools/setup-project.js.map +1 -1
- package/dist/tools/spec-parser-tags.d.ts.map +1 -1
- package/dist/tools/spec-parser-tags.js +1 -0
- package/dist/tools/spec-parser-tags.js.map +1 -1
- package/dist/tools/verify-formatter.d.ts.map +1 -1
- package/dist/tools/verify-formatter.js +15 -1
- package/dist/tools/verify-formatter.js.map +1 -1
- package/dist/tools/verify.d.ts.map +1 -1
- package/dist/tools/verify.js +3 -0
- package/dist/tools/verify.js.map +1 -1
- package/package.json +98 -89
- package/templates/analytics/instructions.yaml +37 -37
- package/templates/analytics/mcp-servers.yaml +11 -11
- package/templates/analytics/structure.yaml +25 -25
- package/templates/api/harness/uc-template.hurl +20 -0
- package/templates/api/instructions.yaml +231 -231
- package/templates/api/mcp-servers.yaml +22 -22
- package/templates/api/nfr.yaml +23 -23
- package/templates/api/review.yaml +103 -103
- package/templates/api/structure.yaml +34 -34
- package/templates/api/verification.yaml +132 -132
- package/templates/cli/instructions.yaml +31 -31
- package/templates/cli/mcp-servers.yaml +11 -11
- package/templates/cli/review.yaml +53 -53
- package/templates/cli/structure.yaml +16 -16
- package/templates/data-lineage/instructions.yaml +28 -28
- package/templates/data-lineage/mcp-servers.yaml +22 -22
- package/templates/data-pipeline/instructions.yaml +84 -84
- package/templates/data-pipeline/mcp-servers.yaml +13 -13
- package/templates/data-pipeline/nfr.yaml +39 -39
- package/templates/data-pipeline/structure.yaml +23 -23
- package/templates/docs-manifest.yaml +227 -0
- package/templates/fintech/hooks.yaml +55 -55
- package/templates/fintech/instructions.yaml +112 -112
- package/templates/fintech/mcp-servers.yaml +13 -13
- package/templates/fintech/nfr.yaml +46 -46
- package/templates/fintech/playbook.yaml +210 -210
- package/templates/fintech/verification.yaml +239 -239
- package/templates/game/harness/uc-template.sim.ts +29 -0
- package/templates/game/instructions.yaml +289 -289
- package/templates/game/mcp-servers.yaml +38 -38
- package/templates/game/nfr.yaml +64 -64
- package/templates/game/playbook.yaml +214 -214
- package/templates/game/review.yaml +97 -97
- package/templates/game/structure.yaml +67 -67
- package/templates/game/verification.yaml +174 -174
- package/templates/healthcare/instructions.yaml +42 -42
- package/templates/healthcare/mcp-servers.yaml +13 -13
- package/templates/healthcare/nfr.yaml +47 -47
- package/templates/hipaa/instructions.yaml +41 -41
- package/templates/hipaa/mcp-servers.yaml +13 -13
- package/templates/infra/instructions.yaml +104 -104
- package/templates/infra/mcp-servers.yaml +20 -20
- package/templates/infra/nfr.yaml +46 -46
- package/templates/infra/review.yaml +65 -65
- package/templates/infra/structure.yaml +25 -25
- package/templates/library/instructions.yaml +36 -36
- package/templates/library/mcp-servers.yaml +20 -20
- package/templates/library/review.yaml +56 -56
- package/templates/library/structure.yaml +19 -19
- package/templates/medallion-architecture/instructions.yaml +41 -41
- package/templates/medallion-architecture/mcp-servers.yaml +22 -22
- package/templates/ml/instructions.yaml +85 -85
- package/templates/ml/mcp-servers.yaml +11 -11
- package/templates/ml/nfr.yaml +39 -39
- package/templates/ml/structure.yaml +25 -25
- package/templates/ml/verification.yaml +156 -156
- package/templates/mobile/instructions.yaml +44 -44
- package/templates/mobile/mcp-servers.yaml +11 -11
- package/templates/mobile/nfr.yaml +49 -49
- package/templates/mobile/structure.yaml +27 -27
- package/templates/mobile/verification.yaml +121 -121
- package/templates/observability-xray/instructions.yaml +40 -40
- package/templates/observability-xray/mcp-servers.yaml +15 -15
- package/templates/realtime/instructions.yaml +42 -42
- package/templates/realtime/mcp-servers.yaml +13 -13
- package/templates/soc2/instructions.yaml +41 -41
- package/templates/soc2/mcp-servers.yaml +24 -24
- package/templates/social/instructions.yaml +43 -43
- package/templates/social/mcp-servers.yaml +24 -24
- package/templates/state-machine/instructions.yaml +42 -42
- package/templates/state-machine/mcp-servers.yaml +11 -11
- package/templates/tools-registry.yaml +164 -164
- package/templates/universal/claude-md-blocks/layer-navigation.md +20 -0
- package/templates/universal/claude-md-blocks/nfr-contracts.md +22 -0
- package/templates/universal/hooks.yaml +879 -723
- package/templates/universal/instructions.yaml +1692 -1692
- package/templates/universal/mcp-servers.yaml +50 -50
- package/templates/universal/nfr.yaml +197 -197
- package/templates/universal/reference.yaml +326 -326
- package/templates/universal/review.yaml +204 -204
- package/templates/universal/skills.yaml +262 -262
- package/templates/universal/structure.yaml +67 -67
- package/templates/universal/verification.yaml +416 -416
- package/templates/web-next/hooks.yaml +114 -0
- package/templates/web-next/instructions.yaml +106 -0
- package/templates/web-react/harness/uc-template.spec.ts +35 -0
- package/templates/web-react/hooks.yaml +156 -44
- package/templates/web-react/instructions.yaml +296 -207
- package/templates/web-react/mcp-servers.yaml +20 -20
- package/templates/web-react/nfr.yaml +27 -27
- package/templates/web-react/review.yaml +94 -94
- package/templates/web-react/structure.yaml +46 -46
- package/templates/web-react/verification.yaml +126 -126
- package/templates/web-static/hooks.yaml +85 -0
- package/templates/web-static/instructions.yaml +204 -115
- package/templates/web-static/mcp-servers.yaml +20 -20
- package/templates/web3/instructions.yaml +44 -44
- package/templates/web3/mcp-servers.yaml +11 -11
- package/templates/web3/verification.yaml +159 -159
- package/templates/zero-trust/instructions.yaml +41 -41
- package/templates/zero-trust/mcp-servers.yaml +15 -15
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
tag: ANALYTICS
|
|
2
|
-
section: instructions
|
|
3
|
-
blocks:
|
|
4
|
-
- id: analytics-architecture
|
|
5
|
-
tier: recommended
|
|
6
|
-
title: "Analytics & Data Warehouse Standards"
|
|
7
|
-
content: |
|
|
8
|
-
## Analytics & Data Warehouse Standards
|
|
9
|
-
|
|
10
|
-
### Architecture — Separation of Concerns
|
|
11
|
-
Operational database and analytical database are SEPARATE systems. Never run analytical
|
|
12
|
-
queries against your production OLTP database.
|
|
13
|
-
|
|
14
|
-
### Event Collection — Instrument Everything
|
|
15
|
-
- Every significant user action and system event emits a structured event.
|
|
16
|
-
- Events are immutable, append-only, timestamped, and include context.
|
|
17
|
-
- Event schema versioned — schema registry or embedded version field.
|
|
18
|
-
- Events flow through a pipeline: collect → validate → enrich → store → aggregate.
|
|
19
|
-
- NO direct writes to analytical store from application code.
|
|
20
|
-
|
|
21
|
-
### Aggregation Layers
|
|
22
|
-
Raw events are for debugging and backfilling. Everything else reads from aggregations.
|
|
23
|
-
|
|
24
|
-
| Layer | Granularity | Refresh | Use Case |
|
|
25
|
-
|-------|------------|---------|----------|
|
|
26
|
-
| Real-time | Per-event or 1-min | Streaming | Live dashboards, alerts |
|
|
27
|
-
| Hourly | 1-hour buckets | Scheduled | Operational dashboards |
|
|
28
|
-
| Daily | 1-day buckets | Nightly | Business reports, KPIs |
|
|
29
|
-
| Weekly/Monthly | Week/month | Scheduled | Executive reporting |
|
|
30
|
-
|
|
31
|
-
### Reporting
|
|
32
|
-
- Dashboards read ONLY from aggregated views.
|
|
33
|
-
- Three tiers: Operational (real-time), Tactical (daily), Strategic (weekly/monthly).
|
|
34
|
-
|
|
35
|
-
### Signals & Prediction
|
|
36
|
-
- Signals are pre-computed and stored, not computed on-demand.
|
|
37
|
-
- Every signal has: value, confidence, computed_at, TTL/expiry.
|
|
1
|
+
tag: ANALYTICS
|
|
2
|
+
section: instructions
|
|
3
|
+
blocks:
|
|
4
|
+
- id: analytics-architecture
|
|
5
|
+
tier: recommended
|
|
6
|
+
title: "Analytics & Data Warehouse Standards"
|
|
7
|
+
content: |
|
|
8
|
+
## Analytics & Data Warehouse Standards
|
|
9
|
+
|
|
10
|
+
### Architecture — Separation of Concerns
|
|
11
|
+
Operational database and analytical database are SEPARATE systems. Never run analytical
|
|
12
|
+
queries against your production OLTP database.
|
|
13
|
+
|
|
14
|
+
### Event Collection — Instrument Everything
|
|
15
|
+
- Every significant user action and system event emits a structured event.
|
|
16
|
+
- Events are immutable, append-only, timestamped, and include context.
|
|
17
|
+
- Event schema versioned — schema registry or embedded version field.
|
|
18
|
+
- Events flow through a pipeline: collect → validate → enrich → store → aggregate.
|
|
19
|
+
- NO direct writes to analytical store from application code.
|
|
20
|
+
|
|
21
|
+
### Aggregation Layers
|
|
22
|
+
Raw events are for debugging and backfilling. Everything else reads from aggregations.
|
|
23
|
+
|
|
24
|
+
| Layer | Granularity | Refresh | Use Case |
|
|
25
|
+
|-------|------------|---------|----------|
|
|
26
|
+
| Real-time | Per-event or 1-min | Streaming | Live dashboards, alerts |
|
|
27
|
+
| Hourly | 1-hour buckets | Scheduled | Operational dashboards |
|
|
28
|
+
| Daily | 1-day buckets | Nightly | Business reports, KPIs |
|
|
29
|
+
| Weekly/Monthly | Week/month | Scheduled | Executive reporting |
|
|
30
|
+
|
|
31
|
+
### Reporting
|
|
32
|
+
- Dashboards read ONLY from aggregated views.
|
|
33
|
+
- Three tiers: Operational (real-time), Tactical (daily), Strategic (weekly/monthly).
|
|
34
|
+
|
|
35
|
+
### Signals & Prediction
|
|
36
|
+
- Signals are pre-computed and stored, not computed on-demand.
|
|
37
|
+
- Every signal has: value, confidence, computed_at, TTL/expiry.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
tag: ANALYTICS
|
|
2
|
-
section: mcp-servers
|
|
3
|
-
servers:
|
|
4
|
-
- name: chrome-devtools
|
|
5
|
-
description: "Chrome DevTools integration for debugging, profiling, and network inspection"
|
|
6
|
-
command: npx
|
|
7
|
-
args: ["-y", "@anthropic/chrome-devtools-mcp@latest"]
|
|
8
|
-
tags: [WEB-REACT, WEB-STATIC, ANALYTICS]
|
|
9
|
-
category: devtools
|
|
10
|
-
tier: recommended
|
|
11
|
-
url: "https://github.com/anthropics/anthropic-quickstarts/tree/main/chrome-devtools-mcp"
|
|
1
|
+
tag: ANALYTICS
|
|
2
|
+
section: mcp-servers
|
|
3
|
+
servers:
|
|
4
|
+
- name: chrome-devtools
|
|
5
|
+
description: "Chrome DevTools integration for debugging, profiling, and network inspection"
|
|
6
|
+
command: npx
|
|
7
|
+
args: ["-y", "@anthropic/chrome-devtools-mcp@latest"]
|
|
8
|
+
tags: [WEB-REACT, WEB-STATIC, ANALYTICS]
|
|
9
|
+
category: devtools
|
|
10
|
+
tier: recommended
|
|
11
|
+
url: "https://github.com/anthropics/anthropic-quickstarts/tree/main/chrome-devtools-mcp"
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
tag: ANALYTICS
|
|
2
|
-
section: structure
|
|
3
|
-
language: typescript
|
|
4
|
-
entries:
|
|
5
|
-
- path: src/analytics/events
|
|
6
|
-
type: directory
|
|
7
|
-
description: "Event type definitions, emitter, validator"
|
|
8
|
-
- path: src/analytics/events/schema.ts
|
|
9
|
-
type: file
|
|
10
|
-
description: "Typed, versioned event definitions"
|
|
11
|
-
- path: src/analytics/events/emitter.ts
|
|
12
|
-
type: file
|
|
13
|
-
description: "Event emission interface"
|
|
14
|
-
- path: src/analytics/pipeline
|
|
15
|
-
type: directory
|
|
16
|
-
description: "Event collection, processing, dead-letter"
|
|
17
|
-
- path: src/analytics/aggregations
|
|
18
|
-
type: directory
|
|
19
|
-
description: "Aggregation definitions and scheduling"
|
|
20
|
-
- path: src/analytics/signals
|
|
21
|
-
type: directory
|
|
22
|
-
description: "Pre-computed signal service"
|
|
23
|
-
- path: src/analytics/dashboards
|
|
24
|
-
type: directory
|
|
25
|
-
description: "Dashboard config as code"
|
|
1
|
+
tag: ANALYTICS
|
|
2
|
+
section: structure
|
|
3
|
+
language: typescript
|
|
4
|
+
entries:
|
|
5
|
+
- path: src/analytics/events
|
|
6
|
+
type: directory
|
|
7
|
+
description: "Event type definitions, emitter, validator"
|
|
8
|
+
- path: src/analytics/events/schema.ts
|
|
9
|
+
type: file
|
|
10
|
+
description: "Typed, versioned event definitions"
|
|
11
|
+
- path: src/analytics/events/emitter.ts
|
|
12
|
+
type: file
|
|
13
|
+
description: "Event emission interface"
|
|
14
|
+
- path: src/analytics/pipeline
|
|
15
|
+
type: directory
|
|
16
|
+
description: "Event collection, processing, dead-letter"
|
|
17
|
+
- path: src/analytics/aggregations
|
|
18
|
+
type: directory
|
|
19
|
+
description: "Aggregation definitions and scheduling"
|
|
20
|
+
- path: src/analytics/signals
|
|
21
|
+
type: directory
|
|
22
|
+
description: "Pre-computed signal service"
|
|
23
|
+
- path: src/analytics/dashboards
|
|
24
|
+
type: directory
|
|
25
|
+
description: "Dashboard config as code"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# L2 Harness: {{uc_id}} — {{uc_title}}
|
|
2
|
+
# Actor: {{actor}}
|
|
3
|
+
# Precondition: {{precondition}}
|
|
4
|
+
# Postcondition: {{postcondition}}
|
|
5
|
+
#
|
|
6
|
+
# This is a behavioral harness probe. A failure is a specification violation.
|
|
7
|
+
# Implement the main flow steps from the use case below.
|
|
8
|
+
|
|
9
|
+
# Step 1: [precondition setup if needed]
|
|
10
|
+
# POST http://{{host}}/api/auth/login
|
|
11
|
+
# ...
|
|
12
|
+
|
|
13
|
+
# Step 2: [primary action]
|
|
14
|
+
# TODO: implement UC main flow as HTTP sequence
|
|
15
|
+
GET http://{{host}}/api/endpoint
|
|
16
|
+
Authorization: Bearer {{token}}
|
|
17
|
+
|
|
18
|
+
HTTP 200
|
|
19
|
+
[Asserts]
|
|
20
|
+
# jsonpath "$.field" == "expected_value"
|
|
@@ -1,231 +1,231 @@
|
|
|
1
|
-
tag: API
|
|
2
|
-
section: instructions
|
|
3
|
-
blocks:
|
|
4
|
-
- id: api-standards
|
|
5
|
-
tier: recommended
|
|
6
|
-
title: "API Service Standards"
|
|
7
|
-
content: |
|
|
8
|
-
## API Standards
|
|
9
|
-
|
|
10
|
-
### Contract First
|
|
11
|
-
- Define OpenAPI/JSON Schema spec before implementing endpoints.
|
|
12
|
-
- Generate types from spec — don't manually duplicate.
|
|
13
|
-
- Spec is the source of truth. Implementation must match.
|
|
14
|
-
|
|
15
|
-
### Design Rules
|
|
16
|
-
- Version from day one: /api/v1/...
|
|
17
|
-
- Proper HTTP semantics: GET reads, POST creates, PUT replaces, PATCH updates, DELETE removes.
|
|
18
|
-
- Pagination on ALL list endpoints. Never return unbounded results.
|
|
19
|
-
- Consistent response envelope: { data, meta, errors }.
|
|
20
|
-
- Async operations return job ID + polling endpoint, not blocking results.
|
|
21
|
-
- Rate limiting on all public endpoints.
|
|
22
|
-
|
|
23
|
-
### Validation
|
|
24
|
-
- Input validation at API boundary — reject malformed requests before they reach services.
|
|
25
|
-
- Use schema validation (Pydantic, Zod, Joi) not manual if-checks.
|
|
26
|
-
- Validate request body, query params, path params, and headers.
|
|
27
|
-
- Return 422 with specific field errors, not generic 400.
|
|
28
|
-
|
|
29
|
-
### Authentication & Authorization
|
|
30
|
-
- Auth middleware/guards at router level, not checked inside handlers.
|
|
31
|
-
- Role-based or policy-based access control via decorators/middleware.
|
|
32
|
-
- Never trust client-sent user identity — always verify from token/session.
|
|
33
|
-
|
|
34
|
-
### Database & Migrations
|
|
35
|
-
- Schema changes managed through migration files (Prisma Migrate, Knex, Flyway, Alembic).
|
|
36
|
-
- Every migration must be reversible (up + down). Test rollbacks.
|
|
37
|
-
- Never modify a deployed migration — create a new one.
|
|
38
|
-
- Seed data separate from migrations. Test seeds run in CI.
|
|
39
|
-
|
|
40
|
-
### Security (OWASP Top 10)
|
|
41
|
-
- **Injection**: Parameterized queries only. No string concatenation for SQL, commands, or LDAP.
|
|
42
|
-
- **Broken Auth**: Rate-limit login attempts. Enforce strong passwords. Rotate tokens.
|
|
43
|
-
- **Sensitive Data Exposure**: Encrypt at rest (AES-256). Never log PII, tokens, or passwords.
|
|
44
|
-
- **XXE/XSS**: Sanitize all user-generated HTML. Content-Security-Policy headers on all responses.
|
|
45
|
-
- **Broken Access Control**: Enforce ownership checks — users can't access other users' resources.
|
|
46
|
-
- **Security Misconfiguration**: No default credentials. No verbose error messages in production.
|
|
47
|
-
Security headers: X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy.
|
|
48
|
-
- **CSRF**: Token-based protection on all state-changing endpoints (unless using SameSite cookies + bearer tokens).
|
|
49
|
-
- **Audit logging**: Log WHO did WHAT, WHEN, to WHICH resource. Separate from application logs.
|
|
50
|
-
Immutable. Retained per compliance requirements.
|
|
51
|
-
|
|
52
|
-
### Graceful Shutdown
|
|
53
|
-
- Handle SIGTERM: stop accepting new requests, drain in-flight requests, close DB connections, exit.
|
|
54
|
-
- Kubernetes: readiness probe fails immediately, liveness continues during drain.
|
|
55
|
-
- Shutdown timeout configurable (default: 30s). Force exit after timeout.
|
|
56
|
-
|
|
57
|
-
- id: api-stack-constraints
|
|
58
|
-
tier: core
|
|
59
|
-
title: "API Stack Constraints"
|
|
60
|
-
content: |
|
|
61
|
-
## API Stack Constraints — Approved Dependency Choices
|
|
62
|
-
|
|
63
|
-
These are the **approved libraries for this API project**.
|
|
64
|
-
Every choice has a banned alternative with a concrete reason.
|
|
65
|
-
If you reach for a banned alternative, stop and use the approved one instead.
|
|
66
|
-
Rationale is stated so you understand the constraint — not so you can argue around it.
|
|
67
|
-
|
|
68
|
-
{{#if language_is_typescript}}
|
|
69
|
-
### TypeScript API — Required Packages
|
|
70
|
-
|
|
71
|
-
| Concern | Use | Do NOT use | Reason |
|
|
72
|
-
|---|---|---|---|
|
|
73
|
-
| **Password hashing** | `argon2@^0.31` | `bcrypt`, `bcryptjs` | `bcrypt` requires a native module (`@mapbox/node-pre-gyp`) that pulls in an old `tar` CVE chain. `argon2` is pure JS, faster, OWASP-preferred. |
|
|
74
|
-
| **HTTP framework** | `express@^4` or `fastify@^4` | `restify`, `hapi@<21`, `koa` alone | `restify` is unmaintained. `hapi` is fine at `^21+` only. |
|
|
75
|
-
| **Input validation** | `zod@^3` | `joi` alone, `express-validator` alone | `zod` infers TypeScript types natively — no separate type declaration needed. |
|
|
76
|
-
| **JWT** | `jsonwebtoken@^9` | `jwt-simple` (abandoned), `jsonwebtoken@<9` | Security fixes landed in v9. `jwt-simple` has no active maintainer. |
|
|
77
|
-
| **ORM / query builder** | `@prisma/client@^5` or `kysely@^0.27` | `typeorm`, `sequelize` | `typeorm` uses decorators (not type-safe), slow migrations. `sequelize` has weak TypeScript support. |
|
|
78
|
-
| **Logger** | `pino@^9` | `winston` alone, `console.log` in prod | `pino` is 5–10× faster than `winston` and outputs structured JSON natively. `console.log` is not structured. |
|
|
79
|
-
| **HTTP client (outbound)** | `undici@^6` or native `fetch` (Node 18+) | `axios` for Node ≥18 | Native `fetch` is available; `axios` adds bundle weight and a dependency surface for a built-in feature. |
|
|
80
|
-
| **ESLint** | `@typescript-eslint/eslint-plugin@^8` | `@typescript-eslint@^5` or `^6` | `^6` has a known CVE via old `minimatch` transitive dep. `^8` is the current stable. |
|
|
81
|
-
|
|
82
|
-
**npm audit policy**: `npm audit` must return zero `high` or `critical` findings before the
|
|
83
|
-
first commit. If a dependency introduces a high/critical CVE, replace it with an alternative
|
|
84
|
-
from this table or open an ADR documenting the exception with mitigation.
|
|
85
|
-
{{/if}}
|
|
86
|
-
|
|
87
|
-
{{#if language_is_python}}
|
|
88
|
-
### Python API — Required Packages
|
|
89
|
-
|
|
90
|
-
| Concern | Use | Do NOT use | Reason |
|
|
91
|
-
|---|---|---|---|
|
|
92
|
-
| **Web framework** | `fastapi@^0.110` | `flask` for new async APIs | Flask has no native `async` request handling at the framework level — blocks on every request without extra extensions. |
|
|
93
|
-
| **Validation** | `pydantic@^2` | `pydantic@^1` | v2 is 5–50× faster. v1 is not maintained for new projects. Breaking API — pin to `^2`. |
|
|
94
|
-
| **Password hashing** | `argon2-cffi@^23` | `hashlib` for passwords, `MD5/SHA256` for passwords | `hashlib` is not a KDF — it is trivially reversible with a GPU. `argon2` wins OWASP Password Hashing Competition. |
|
|
95
|
-
| **JWT** | `PyJWT@^2.8` or `python-jose[cryptography]@^3.3` | `python-jwt` (unmaintained), `itsdangerous` alone | `python-jwt` has no active maintainer. `itsdangerous` is for URL-safe tokens, not JWT. |
|
|
96
|
-
| **ORM** | `sqlalchemy@^2.0` with `asyncpg` | `sqlalchemy@^1.x` | v2 has a fundamentally better async story and type-annotated query API. |
|
|
97
|
-
| **HTTP client** | `httpx@^0.27` | `requests` in async code | `requests` is sync-only — it will block the asyncio event loop. |
|
|
98
|
-
| **Logger** | `structlog@^24` | bare `logging` module in production | Unstructured log lines are not machine-parseable. `structlog` wraps `logging` with structured output. |
|
|
99
|
-
| **Linting** | `ruff@^0.4` | `flake8` + `isort` + `black` separately | `ruff` replaces all three with one tool 10–100× faster. No reason to run them separately. |
|
|
100
|
-
|
|
101
|
-
**pip audit policy**: `pip audit` must return zero `high` or `critical` findings before the
|
|
102
|
-
first commit. If a dependency introduces a high/critical CVE, replace it or open an ADR.
|
|
103
|
-
{{/if}}
|
|
104
|
-
|
|
105
|
-
- id: api-deployment
|
|
106
|
-
tier: recommended
|
|
107
|
-
title: "API Deployment & Hosting"
|
|
108
|
-
content: |
|
|
109
|
-
## API Deployment
|
|
110
|
-
|
|
111
|
-
### Container-Based (Production)
|
|
112
|
-
- Multi-stage Dockerfile: builder stage (install + compile) → runtime stage (minimal image, non-root).
|
|
113
|
-
- Pin base image digests, not just tags. Scan images for CVEs in CI (Trivy, Grype).
|
|
114
|
-
- Push to container registry (ECR, GCR, GHCR) on every merge to main.
|
|
115
|
-
- Orchestrate with Kubernetes, ECS, or Cloud Run. Define resource limits for every container.
|
|
116
|
-
|
|
117
|
-
### PaaS / Quick Deploy
|
|
118
|
-
- **Railway**: Git-push deploy with auto-detected Dockerfile or Nixpacks. Ideal for staging and side projects.
|
|
119
|
-
- **Render**: Free tier + auto-deploy from Git. Native cron jobs, managed Postgres.
|
|
120
|
-
- **Fly.io**: Edge deployment with Firecracker VMs. Good for low-latency APIs. `fly deploy` from CI.
|
|
121
|
-
- All PaaS platforms: use platform env vars for secrets, connect managed DB add-ons, enable auto-sleep
|
|
122
|
-
for non-production to control cost.
|
|
123
|
-
|
|
124
|
-
### Environment Management
|
|
125
|
-
- One Dockerfile, many environments. Same image runs in dev, staging, prod.
|
|
126
|
-
- Health check endpoint (`/health`) returns: status, version, uptime, dependency connectivity.
|
|
127
|
-
- Database connection pooling configured per environment (dev: 5, staging: 20, prod: 50+).
|
|
128
|
-
- Migrations run automatically on deploy (pre-deploy hook or init container). Never manually.
|
|
129
|
-
|
|
130
|
-
- id: api-testing
|
|
131
|
-
tier: recommended
|
|
132
|
-
title: "API-Specific Testing Requirements"
|
|
133
|
-
content: |
|
|
134
|
-
## API-Specific Testing Requirements
|
|
135
|
-
|
|
136
|
-
### Contract / Consumer-Driven Contract (CDC) — Mandatory
|
|
137
|
-
CDC is not optional for API projects. The consumer writes the pact file; the provider verifies it in CI before deployment. API breakage that passes all provider-side tests but fails consumers is the exact class of defect CDC prevents.
|
|
138
|
-
- Use Pact or Spring Cloud Contract.
|
|
139
|
-
- Pact broker (self-hosted or pactflow.io) stores pact files and verification results.
|
|
140
|
-
- Provider verification runs in CI on every build — a failed verification blocks deployment.
|
|
141
|
-
- CDC covers request schema, response schema, status codes, and error shapes. It does not cover load or security — those are separate gates.
|
|
142
|
-
|
|
143
|
-
### API / Subcutaneous Tests as Primary Integration Layer
|
|
144
|
-
The subcutaneous layer (HTTP requests to a running server with real DB and stubbed external deps) is the primary integration verification surface for API projects. Unit tests verify logic; subcutaneous tests verify contracts.
|
|
145
|
-
- Use Supertest (Node) or httpx/pytest (Python) against a locally started server instance.
|
|
146
|
-
- Stub external services with WireMock, msw, or responses (Python). Never call real external APIs in CI.
|
|
147
|
-
- Every public endpoint has a subcutaneous test for: 200 happy path, 4xx validation rejection, 401/403 auth enforcement, and at least one edge case.
|
|
148
|
-
|
|
149
|
-
### DAST at Staging — Mandatory
|
|
150
|
-
Dynamic application security testing is required before every production promotion. OWASP ZAP minimum.
|
|
151
|
-
- Run ZAP active scan against the staging environment as a post-deploy CI step.
|
|
152
|
-
- Define an acceptable risk threshold in the spec: which finding severities are blocking (High = always blocking; Medium/Low = tracked, not blocking by default).
|
|
153
|
-
- ZAP scan configuration committed to the repo (`zap-config.yaml`). Not a one-off manual step.
|
|
154
|
-
|
|
155
|
-
### Rate Limiting and Throttling in Integration Layer
|
|
156
|
-
- Rate limit behavior must be covered in the subcutaneous integration suite, not just documented.
|
|
157
|
-
- Test: normal traffic (no throttle), burst traffic (trigger rate limit, receive 429), retry-after header present and correct.
|
|
158
|
-
- Test quota exhaustion and quota reset behavior for API-key-based limits.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
### Scaling
|
|
162
|
-
- Horizontal scaling by default. No in-memory session state — use Redis or DB.
|
|
163
|
-
- Auto-scaling rules based on CPU + request queue depth, not just CPU alone.
|
|
164
|
-
- Database read replicas for read-heavy workloads. Connection pooler (PgBouncer) in front of Postgres.
|
|
165
|
-
|
|
166
|
-
- id: api-smoke-testing
|
|
167
|
-
tier: recommended
|
|
168
|
-
title: "API Smoke Testing (Post-Deploy)"
|
|
169
|
-
content: |
|
|
170
|
-
## API Smoke Testing
|
|
171
|
-
|
|
172
|
-
### Required: Playwright APIRequestContext (no browser overhead)
|
|
173
|
-
Tag all smoke tests `@smoke` for isolated execution:
|
|
174
|
-
```
|
|
175
|
-
npx playwright test --config playwright.smoke.config.ts --grep @smoke
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
Minimum smoke suite for every API:
|
|
179
|
-
- **Health check**: `GET /health` → 200, body includes `status: ok` and `version`
|
|
180
|
-
- **Auth**: primary login endpoint with valid credentials → token returned
|
|
181
|
-
- **Primary read**: one representative `GET` → 200, response envelope validates
|
|
182
|
-
- **Primary write**: one representative `POST` → 2xx, verify with follow-up `GET`
|
|
183
|
-
- **404 shape**: non-existent resource → 404, error envelope matches spec contract
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
// tests/smoke/api.smoke.ts
|
|
187
|
-
import { test, expect } from '@playwright/test';
|
|
188
|
-
|
|
189
|
-
test('@smoke health check', async ({ request }) => {
|
|
190
|
-
const res = await request.get('/health');
|
|
191
|
-
expect(res.ok()).toBeTruthy();
|
|
192
|
-
const body = await res.json();
|
|
193
|
-
expect(body).toMatchObject({ status: 'ok' });
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
test('@smoke auth returns token', async ({ request }) => {
|
|
197
|
-
const res = await request.post('/api/v1/auth/login', {
|
|
198
|
-
data: {
|
|
199
|
-
email: process.env['SMOKE_USER'],
|
|
200
|
-
password: process.env['SMOKE_PASSWORD'],
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
expect(res.status()).toBe(200);
|
|
204
|
-
const body = await res.json();
|
|
205
|
-
expect(typeof body.token ?? body.data?.token).toBe('string');
|
|
206
|
-
});
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
```typescript
|
|
210
|
-
// playwright.smoke.config.ts
|
|
211
|
-
import { defineConfig } from '@playwright/test';
|
|
212
|
-
export default defineConfig({
|
|
213
|
-
use: { baseURL: process.env['PLAYWRIGHT_BASE_URL'] ?? 'http://localhost:3000' },
|
|
214
|
-
testMatch: '**/*.smoke.ts',
|
|
215
|
-
retries: 1,
|
|
216
|
-
timeout: 10_000,
|
|
217
|
-
});
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Smoke tests run against the **deployed staging URL** only (`PLAYWRIGHT_BASE_URL` env var).
|
|
221
|
-
They never run against localhost in CI — that is the integration suite's job.
|
|
222
|
-
|
|
223
|
-
CI integration (post-deploy step):
|
|
224
|
-
```yaml
|
|
225
|
-
- name: Smoke Tests
|
|
226
|
-
run: npx playwright test --config playwright.smoke.config.ts
|
|
227
|
-
env:
|
|
228
|
-
PLAYWRIGHT_BASE_URL: ${{ env.STAGING_URL }}
|
|
229
|
-
SMOKE_USER: ${{ secrets.SMOKE_USER }}
|
|
230
|
-
SMOKE_PASSWORD: ${{ secrets.SMOKE_PASSWORD }}
|
|
231
|
-
```
|
|
1
|
+
tag: API
|
|
2
|
+
section: instructions
|
|
3
|
+
blocks:
|
|
4
|
+
- id: api-standards
|
|
5
|
+
tier: recommended
|
|
6
|
+
title: "API Service Standards"
|
|
7
|
+
content: |
|
|
8
|
+
## API Standards
|
|
9
|
+
|
|
10
|
+
### Contract First
|
|
11
|
+
- Define OpenAPI/JSON Schema spec before implementing endpoints.
|
|
12
|
+
- Generate types from spec — don't manually duplicate.
|
|
13
|
+
- Spec is the source of truth. Implementation must match.
|
|
14
|
+
|
|
15
|
+
### Design Rules
|
|
16
|
+
- Version from day one: /api/v1/...
|
|
17
|
+
- Proper HTTP semantics: GET reads, POST creates, PUT replaces, PATCH updates, DELETE removes.
|
|
18
|
+
- Pagination on ALL list endpoints. Never return unbounded results.
|
|
19
|
+
- Consistent response envelope: { data, meta, errors }.
|
|
20
|
+
- Async operations return job ID + polling endpoint, not blocking results.
|
|
21
|
+
- Rate limiting on all public endpoints.
|
|
22
|
+
|
|
23
|
+
### Validation
|
|
24
|
+
- Input validation at API boundary — reject malformed requests before they reach services.
|
|
25
|
+
- Use schema validation (Pydantic, Zod, Joi) not manual if-checks.
|
|
26
|
+
- Validate request body, query params, path params, and headers.
|
|
27
|
+
- Return 422 with specific field errors, not generic 400.
|
|
28
|
+
|
|
29
|
+
### Authentication & Authorization
|
|
30
|
+
- Auth middleware/guards at router level, not checked inside handlers.
|
|
31
|
+
- Role-based or policy-based access control via decorators/middleware.
|
|
32
|
+
- Never trust client-sent user identity — always verify from token/session.
|
|
33
|
+
|
|
34
|
+
### Database & Migrations
|
|
35
|
+
- Schema changes managed through migration files (Prisma Migrate, Knex, Flyway, Alembic).
|
|
36
|
+
- Every migration must be reversible (up + down). Test rollbacks.
|
|
37
|
+
- Never modify a deployed migration — create a new one.
|
|
38
|
+
- Seed data separate from migrations. Test seeds run in CI.
|
|
39
|
+
|
|
40
|
+
### Security (OWASP Top 10)
|
|
41
|
+
- **Injection**: Parameterized queries only. No string concatenation for SQL, commands, or LDAP.
|
|
42
|
+
- **Broken Auth**: Rate-limit login attempts. Enforce strong passwords. Rotate tokens.
|
|
43
|
+
- **Sensitive Data Exposure**: Encrypt at rest (AES-256). Never log PII, tokens, or passwords.
|
|
44
|
+
- **XXE/XSS**: Sanitize all user-generated HTML. Content-Security-Policy headers on all responses.
|
|
45
|
+
- **Broken Access Control**: Enforce ownership checks — users can't access other users' resources.
|
|
46
|
+
- **Security Misconfiguration**: No default credentials. No verbose error messages in production.
|
|
47
|
+
Security headers: X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy.
|
|
48
|
+
- **CSRF**: Token-based protection on all state-changing endpoints (unless using SameSite cookies + bearer tokens).
|
|
49
|
+
- **Audit logging**: Log WHO did WHAT, WHEN, to WHICH resource. Separate from application logs.
|
|
50
|
+
Immutable. Retained per compliance requirements.
|
|
51
|
+
|
|
52
|
+
### Graceful Shutdown
|
|
53
|
+
- Handle SIGTERM: stop accepting new requests, drain in-flight requests, close DB connections, exit.
|
|
54
|
+
- Kubernetes: readiness probe fails immediately, liveness continues during drain.
|
|
55
|
+
- Shutdown timeout configurable (default: 30s). Force exit after timeout.
|
|
56
|
+
|
|
57
|
+
- id: api-stack-constraints
|
|
58
|
+
tier: core
|
|
59
|
+
title: "API Stack Constraints"
|
|
60
|
+
content: |
|
|
61
|
+
## API Stack Constraints — Approved Dependency Choices
|
|
62
|
+
|
|
63
|
+
These are the **approved libraries for this API project**.
|
|
64
|
+
Every choice has a banned alternative with a concrete reason.
|
|
65
|
+
If you reach for a banned alternative, stop and use the approved one instead.
|
|
66
|
+
Rationale is stated so you understand the constraint — not so you can argue around it.
|
|
67
|
+
|
|
68
|
+
{{#if language_is_typescript}}
|
|
69
|
+
### TypeScript API — Required Packages
|
|
70
|
+
|
|
71
|
+
| Concern | Use | Do NOT use | Reason |
|
|
72
|
+
|---|---|---|---|
|
|
73
|
+
| **Password hashing** | `argon2@^0.31` | `bcrypt`, `bcryptjs` | `bcrypt` requires a native module (`@mapbox/node-pre-gyp`) that pulls in an old `tar` CVE chain. `argon2` is pure JS, faster, OWASP-preferred. |
|
|
74
|
+
| **HTTP framework** | `express@^4` or `fastify@^4` | `restify`, `hapi@<21`, `koa` alone | `restify` is unmaintained. `hapi` is fine at `^21+` only. |
|
|
75
|
+
| **Input validation** | `zod@^3` | `joi` alone, `express-validator` alone | `zod` infers TypeScript types natively — no separate type declaration needed. |
|
|
76
|
+
| **JWT** | `jsonwebtoken@^9` | `jwt-simple` (abandoned), `jsonwebtoken@<9` | Security fixes landed in v9. `jwt-simple` has no active maintainer. |
|
|
77
|
+
| **ORM / query builder** | `@prisma/client@^5` or `kysely@^0.27` | `typeorm`, `sequelize` | `typeorm` uses decorators (not type-safe), slow migrations. `sequelize` has weak TypeScript support. |
|
|
78
|
+
| **Logger** | `pino@^9` | `winston` alone, `console.log` in prod | `pino` is 5–10× faster than `winston` and outputs structured JSON natively. `console.log` is not structured. |
|
|
79
|
+
| **HTTP client (outbound)** | `undici@^6` or native `fetch` (Node 18+) | `axios` for Node ≥18 | Native `fetch` is available; `axios` adds bundle weight and a dependency surface for a built-in feature. |
|
|
80
|
+
| **ESLint** | `@typescript-eslint/eslint-plugin@^8` | `@typescript-eslint@^5` or `^6` | `^6` has a known CVE via old `minimatch` transitive dep. `^8` is the current stable. |
|
|
81
|
+
|
|
82
|
+
**npm audit policy**: `npm audit` must return zero `high` or `critical` findings before the
|
|
83
|
+
first commit. If a dependency introduces a high/critical CVE, replace it with an alternative
|
|
84
|
+
from this table or open an ADR documenting the exception with mitigation.
|
|
85
|
+
{{/if}}
|
|
86
|
+
|
|
87
|
+
{{#if language_is_python}}
|
|
88
|
+
### Python API — Required Packages
|
|
89
|
+
|
|
90
|
+
| Concern | Use | Do NOT use | Reason |
|
|
91
|
+
|---|---|---|---|
|
|
92
|
+
| **Web framework** | `fastapi@^0.110` | `flask` for new async APIs | Flask has no native `async` request handling at the framework level — blocks on every request without extra extensions. |
|
|
93
|
+
| **Validation** | `pydantic@^2` | `pydantic@^1` | v2 is 5–50× faster. v1 is not maintained for new projects. Breaking API — pin to `^2`. |
|
|
94
|
+
| **Password hashing** | `argon2-cffi@^23` | `hashlib` for passwords, `MD5/SHA256` for passwords | `hashlib` is not a KDF — it is trivially reversible with a GPU. `argon2` wins OWASP Password Hashing Competition. |
|
|
95
|
+
| **JWT** | `PyJWT@^2.8` or `python-jose[cryptography]@^3.3` | `python-jwt` (unmaintained), `itsdangerous` alone | `python-jwt` has no active maintainer. `itsdangerous` is for URL-safe tokens, not JWT. |
|
|
96
|
+
| **ORM** | `sqlalchemy@^2.0` with `asyncpg` | `sqlalchemy@^1.x` | v2 has a fundamentally better async story and type-annotated query API. |
|
|
97
|
+
| **HTTP client** | `httpx@^0.27` | `requests` in async code | `requests` is sync-only — it will block the asyncio event loop. |
|
|
98
|
+
| **Logger** | `structlog@^24` | bare `logging` module in production | Unstructured log lines are not machine-parseable. `structlog` wraps `logging` with structured output. |
|
|
99
|
+
| **Linting** | `ruff@^0.4` | `flake8` + `isort` + `black` separately | `ruff` replaces all three with one tool 10–100× faster. No reason to run them separately. |
|
|
100
|
+
|
|
101
|
+
**pip audit policy**: `pip audit` must return zero `high` or `critical` findings before the
|
|
102
|
+
first commit. If a dependency introduces a high/critical CVE, replace it or open an ADR.
|
|
103
|
+
{{/if}}
|
|
104
|
+
|
|
105
|
+
- id: api-deployment
|
|
106
|
+
tier: recommended
|
|
107
|
+
title: "API Deployment & Hosting"
|
|
108
|
+
content: |
|
|
109
|
+
## API Deployment
|
|
110
|
+
|
|
111
|
+
### Container-Based (Production)
|
|
112
|
+
- Multi-stage Dockerfile: builder stage (install + compile) → runtime stage (minimal image, non-root).
|
|
113
|
+
- Pin base image digests, not just tags. Scan images for CVEs in CI (Trivy, Grype).
|
|
114
|
+
- Push to container registry (ECR, GCR, GHCR) on every merge to main.
|
|
115
|
+
- Orchestrate with Kubernetes, ECS, or Cloud Run. Define resource limits for every container.
|
|
116
|
+
|
|
117
|
+
### PaaS / Quick Deploy
|
|
118
|
+
- **Railway**: Git-push deploy with auto-detected Dockerfile or Nixpacks. Ideal for staging and side projects.
|
|
119
|
+
- **Render**: Free tier + auto-deploy from Git. Native cron jobs, managed Postgres.
|
|
120
|
+
- **Fly.io**: Edge deployment with Firecracker VMs. Good for low-latency APIs. `fly deploy` from CI.
|
|
121
|
+
- All PaaS platforms: use platform env vars for secrets, connect managed DB add-ons, enable auto-sleep
|
|
122
|
+
for non-production to control cost.
|
|
123
|
+
|
|
124
|
+
### Environment Management
|
|
125
|
+
- One Dockerfile, many environments. Same image runs in dev, staging, prod.
|
|
126
|
+
- Health check endpoint (`/health`) returns: status, version, uptime, dependency connectivity.
|
|
127
|
+
- Database connection pooling configured per environment (dev: 5, staging: 20, prod: 50+).
|
|
128
|
+
- Migrations run automatically on deploy (pre-deploy hook or init container). Never manually.
|
|
129
|
+
|
|
130
|
+
- id: api-testing
|
|
131
|
+
tier: recommended
|
|
132
|
+
title: "API-Specific Testing Requirements"
|
|
133
|
+
content: |
|
|
134
|
+
## API-Specific Testing Requirements
|
|
135
|
+
|
|
136
|
+
### Contract / Consumer-Driven Contract (CDC) — Mandatory
|
|
137
|
+
CDC is not optional for API projects. The consumer writes the pact file; the provider verifies it in CI before deployment. API breakage that passes all provider-side tests but fails consumers is the exact class of defect CDC prevents.
|
|
138
|
+
- Use Pact or Spring Cloud Contract.
|
|
139
|
+
- Pact broker (self-hosted or pactflow.io) stores pact files and verification results.
|
|
140
|
+
- Provider verification runs in CI on every build — a failed verification blocks deployment.
|
|
141
|
+
- CDC covers request schema, response schema, status codes, and error shapes. It does not cover load or security — those are separate gates.
|
|
142
|
+
|
|
143
|
+
### API / Subcutaneous Tests as Primary Integration Layer
|
|
144
|
+
The subcutaneous layer (HTTP requests to a running server with real DB and stubbed external deps) is the primary integration verification surface for API projects. Unit tests verify logic; subcutaneous tests verify contracts.
|
|
145
|
+
- Use Supertest (Node) or httpx/pytest (Python) against a locally started server instance.
|
|
146
|
+
- Stub external services with WireMock, msw, or responses (Python). Never call real external APIs in CI.
|
|
147
|
+
- Every public endpoint has a subcutaneous test for: 200 happy path, 4xx validation rejection, 401/403 auth enforcement, and at least one edge case.
|
|
148
|
+
|
|
149
|
+
### DAST at Staging — Mandatory
|
|
150
|
+
Dynamic application security testing is required before every production promotion. OWASP ZAP minimum.
|
|
151
|
+
- Run ZAP active scan against the staging environment as a post-deploy CI step.
|
|
152
|
+
- Define an acceptable risk threshold in the spec: which finding severities are blocking (High = always blocking; Medium/Low = tracked, not blocking by default).
|
|
153
|
+
- ZAP scan configuration committed to the repo (`zap-config.yaml`). Not a one-off manual step.
|
|
154
|
+
|
|
155
|
+
### Rate Limiting and Throttling in Integration Layer
|
|
156
|
+
- Rate limit behavior must be covered in the subcutaneous integration suite, not just documented.
|
|
157
|
+
- Test: normal traffic (no throttle), burst traffic (trigger rate limit, receive 429), retry-after header present and correct.
|
|
158
|
+
- Test quota exhaustion and quota reset behavior for API-key-based limits.
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### Scaling
|
|
162
|
+
- Horizontal scaling by default. No in-memory session state — use Redis or DB.
|
|
163
|
+
- Auto-scaling rules based on CPU + request queue depth, not just CPU alone.
|
|
164
|
+
- Database read replicas for read-heavy workloads. Connection pooler (PgBouncer) in front of Postgres.
|
|
165
|
+
|
|
166
|
+
- id: api-smoke-testing
|
|
167
|
+
tier: recommended
|
|
168
|
+
title: "API Smoke Testing (Post-Deploy)"
|
|
169
|
+
content: |
|
|
170
|
+
## API Smoke Testing
|
|
171
|
+
|
|
172
|
+
### Required: Playwright APIRequestContext (no browser overhead)
|
|
173
|
+
Tag all smoke tests `@smoke` for isolated execution:
|
|
174
|
+
```
|
|
175
|
+
npx playwright test --config playwright.smoke.config.ts --grep @smoke
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Minimum smoke suite for every API:
|
|
179
|
+
- **Health check**: `GET /health` → 200, body includes `status: ok` and `version`
|
|
180
|
+
- **Auth**: primary login endpoint with valid credentials → token returned
|
|
181
|
+
- **Primary read**: one representative `GET` → 200, response envelope validates
|
|
182
|
+
- **Primary write**: one representative `POST` → 2xx, verify with follow-up `GET`
|
|
183
|
+
- **404 shape**: non-existent resource → 404, error envelope matches spec contract
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
// tests/smoke/api.smoke.ts
|
|
187
|
+
import { test, expect } from '@playwright/test';
|
|
188
|
+
|
|
189
|
+
test('@smoke health check', async ({ request }) => {
|
|
190
|
+
const res = await request.get('/health');
|
|
191
|
+
expect(res.ok()).toBeTruthy();
|
|
192
|
+
const body = await res.json();
|
|
193
|
+
expect(body).toMatchObject({ status: 'ok' });
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('@smoke auth returns token', async ({ request }) => {
|
|
197
|
+
const res = await request.post('/api/v1/auth/login', {
|
|
198
|
+
data: {
|
|
199
|
+
email: process.env['SMOKE_USER'],
|
|
200
|
+
password: process.env['SMOKE_PASSWORD'],
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
expect(res.status()).toBe(200);
|
|
204
|
+
const body = await res.json();
|
|
205
|
+
expect(typeof body.token ?? body.data?.token).toBe('string');
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// playwright.smoke.config.ts
|
|
211
|
+
import { defineConfig } from '@playwright/test';
|
|
212
|
+
export default defineConfig({
|
|
213
|
+
use: { baseURL: process.env['PLAYWRIGHT_BASE_URL'] ?? 'http://localhost:3000' },
|
|
214
|
+
testMatch: '**/*.smoke.ts',
|
|
215
|
+
retries: 1,
|
|
216
|
+
timeout: 10_000,
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Smoke tests run against the **deployed staging URL** only (`PLAYWRIGHT_BASE_URL` env var).
|
|
221
|
+
They never run against localhost in CI — that is the integration suite's job.
|
|
222
|
+
|
|
223
|
+
CI integration (post-deploy step):
|
|
224
|
+
```yaml
|
|
225
|
+
- name: Smoke Tests
|
|
226
|
+
run: npx playwright test --config playwright.smoke.config.ts
|
|
227
|
+
env:
|
|
228
|
+
PLAYWRIGHT_BASE_URL: ${{ env.STAGING_URL }}
|
|
229
|
+
SMOKE_USER: ${{ secrets.SMOKE_USER }}
|
|
230
|
+
SMOKE_PASSWORD: ${{ secrets.SMOKE_PASSWORD }}
|
|
231
|
+
```
|