hatch3r 1.7.1 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +37 -11
  2. package/agents/hatch3r-a11y-auditor.md +4 -0
  3. package/agents/hatch3r-architect.md +4 -0
  4. package/agents/hatch3r-ci-watcher.md +4 -0
  5. package/agents/hatch3r-context-rules.md +4 -0
  6. package/agents/hatch3r-creator.md +4 -0
  7. package/agents/hatch3r-dependency-auditor.md +4 -0
  8. package/agents/hatch3r-devops.md +4 -0
  9. package/agents/hatch3r-docs-writer.md +4 -0
  10. package/agents/hatch3r-fixer.md +4 -0
  11. package/agents/hatch3r-handoff-loader.md +243 -0
  12. package/agents/hatch3r-handoff-preparer.md +134 -0
  13. package/agents/hatch3r-implementer.md +4 -0
  14. package/agents/hatch3r-learnings-loader.md +4 -0
  15. package/agents/hatch3r-lint-fixer.md +4 -0
  16. package/agents/hatch3r-perf-profiler.md +8 -0
  17. package/agents/hatch3r-researcher.md +4 -0
  18. package/agents/hatch3r-reviewer.md +92 -0
  19. package/agents/hatch3r-security-auditor.md +24 -0
  20. package/agents/hatch3r-test-writer.md +4 -0
  21. package/agents/modes/requirements-elicitation.md +4 -1
  22. package/agents/modes/similar-implementation.md +6 -0
  23. package/agents/modes/user-flows.md +76 -0
  24. package/agents/shared/quality-charter.md +128 -0
  25. package/commands/hatch3r-board-fill.md +1 -0
  26. package/commands/hatch3r-create.md +2 -0
  27. package/commands/hatch3r-handoff.md +126 -0
  28. package/commands/hatch3r-pr-resolve.md +4 -0
  29. package/commands/hatch3r-quick-change.md +4 -2
  30. package/commands/hatch3r-workflow.md +2 -0
  31. package/dist/cli/index.js +2321 -460
  32. package/dist/cli/index.js.map +1 -1
  33. package/package.json +4 -2
  34. package/rules/hatch3r-accessibility-standards.md +21 -0
  35. package/rules/hatch3r-accessibility-standards.mdc +21 -0
  36. package/rules/hatch3r-agent-orchestration.md +9 -1
  37. package/rules/hatch3r-agent-orchestration.mdc +9 -1
  38. package/rules/hatch3r-ai-evals.md +158 -0
  39. package/rules/hatch3r-ai-evals.mdc +154 -0
  40. package/rules/hatch3r-ai-ux-patterns.md +131 -0
  41. package/rules/hatch3r-ai-ux-patterns.mdc +127 -0
  42. package/rules/hatch3r-api-design.md +67 -9
  43. package/rules/hatch3r-api-design.mdc +67 -9
  44. package/rules/hatch3r-api-versioning.md +119 -0
  45. package/rules/hatch3r-api-versioning.mdc +115 -0
  46. package/rules/hatch3r-auth-patterns.md +170 -0
  47. package/rules/hatch3r-auth-patterns.mdc +166 -0
  48. package/rules/hatch3r-component-conventions.md +30 -0
  49. package/rules/hatch3r-component-conventions.mdc +30 -0
  50. package/rules/hatch3r-container-hardening.md +131 -0
  51. package/rules/hatch3r-container-hardening.mdc +127 -0
  52. package/rules/hatch3r-contract-testing.md +117 -0
  53. package/rules/hatch3r-contract-testing.mdc +113 -0
  54. package/rules/hatch3r-deep-context.md +2 -0
  55. package/rules/hatch3r-deep-context.mdc +2 -0
  56. package/rules/hatch3r-dependency-management.md +73 -1
  57. package/rules/hatch3r-dependency-management.mdc +72 -0
  58. package/rules/hatch3r-design-system-detection.md +142 -0
  59. package/rules/hatch3r-design-system-detection.mdc +138 -0
  60. package/rules/hatch3r-event-schema-evolution.md +90 -0
  61. package/rules/hatch3r-event-schema-evolution.mdc +86 -0
  62. package/rules/hatch3r-handoff-readiness.md +45 -0
  63. package/rules/hatch3r-handoff-readiness.mdc +40 -0
  64. package/rules/hatch3r-i18n.md +13 -0
  65. package/rules/hatch3r-i18n.mdc +13 -0
  66. package/rules/hatch3r-migrations.md +61 -16
  67. package/rules/hatch3r-migrations.mdc +61 -16
  68. package/rules/hatch3r-observability-logging.md +1 -1
  69. package/rules/hatch3r-observability-logging.mdc +1 -1
  70. package/rules/hatch3r-observability-metrics.md +1 -1
  71. package/rules/hatch3r-observability-metrics.mdc +1 -1
  72. package/rules/hatch3r-observability-tracing-detail.md +1 -1
  73. package/rules/hatch3r-observability-tracing-detail.mdc +1 -1
  74. package/rules/hatch3r-observability-tracing.md +1 -1
  75. package/rules/hatch3r-observability-tracing.mdc +1 -1
  76. package/rules/hatch3r-observability.md +1 -0
  77. package/rules/hatch3r-observability.mdc +1 -0
  78. package/rules/hatch3r-operability.md +149 -0
  79. package/rules/hatch3r-operability.mdc +145 -0
  80. package/rules/hatch3r-passkey-server.md +181 -0
  81. package/rules/hatch3r-passkey-server.mdc +177 -0
  82. package/rules/hatch3r-progressive-delivery.md +120 -0
  83. package/rules/hatch3r-progressive-delivery.mdc +116 -0
  84. package/rules/hatch3r-resilience-patterns.md +154 -0
  85. package/rules/hatch3r-resilience-patterns.mdc +150 -0
  86. package/rules/hatch3r-secrets-management.md +29 -0
  87. package/rules/hatch3r-secrets-management.mdc +29 -0
  88. package/rules/hatch3r-testing.md +139 -43
  89. package/rules/hatch3r-testing.mdc +139 -43
  90. package/rules/hatch3r-ux-states-and-flows.md +149 -0
  91. package/rules/hatch3r-ux-states-and-flows.mdc +145 -0
  92. package/skills/hatch3r-a11y-audit/SKILL.md +14 -0
  93. package/skills/hatch3r-ai-feature/SKILL.md +134 -0
  94. package/skills/hatch3r-api-spec/SKILL.md +5 -0
  95. package/skills/hatch3r-architecture-review/SKILL.md +14 -0
  96. package/skills/hatch3r-bug-fix/SKILL.md +5 -0
  97. package/skills/hatch3r-ci-pipeline/SKILL.md +14 -0
  98. package/skills/hatch3r-cli-aichat/SKILL.md +84 -0
  99. package/skills/hatch3r-cli-ast-grep/SKILL.md +85 -0
  100. package/skills/hatch3r-cli-az-devops/SKILL.md +89 -0
  101. package/skills/hatch3r-cli-bat/SKILL.md +85 -0
  102. package/skills/hatch3r-cli-comby/SKILL.md +85 -0
  103. package/skills/hatch3r-cli-csvkit/SKILL.md +84 -0
  104. package/skills/hatch3r-cli-delta/SKILL.md +86 -0
  105. package/skills/hatch3r-cli-difftastic/SKILL.md +84 -0
  106. package/skills/hatch3r-cli-docker/SKILL.md +89 -0
  107. package/skills/hatch3r-cli-duckdb/SKILL.md +84 -0
  108. package/skills/hatch3r-cli-fd/SKILL.md +85 -0
  109. package/skills/hatch3r-cli-fzf/SKILL.md +84 -0
  110. package/skills/hatch3r-cli-gh/SKILL.md +90 -0
  111. package/skills/hatch3r-cli-glab/SKILL.md +89 -0
  112. package/skills/hatch3r-cli-jq/SKILL.md +85 -0
  113. package/skills/hatch3r-cli-lazygit/SKILL.md +78 -0
  114. package/skills/hatch3r-cli-llm/SKILL.md +84 -0
  115. package/skills/hatch3r-cli-miller/SKILL.md +84 -0
  116. package/skills/hatch3r-cli-mods/SKILL.md +84 -0
  117. package/skills/hatch3r-cli-overview/SKILL.md +60 -0
  118. package/skills/hatch3r-cli-playwright/SKILL.md +89 -0
  119. package/skills/hatch3r-cli-podman/SKILL.md +84 -0
  120. package/skills/hatch3r-cli-ripgrep/SKILL.md +85 -0
  121. package/skills/hatch3r-cli-rtk/SKILL.md +91 -0
  122. package/skills/hatch3r-cli-sd/SKILL.md +85 -0
  123. package/skills/hatch3r-cli-stagehand/SKILL.md +79 -0
  124. package/skills/hatch3r-cli-taplo/SKILL.md +84 -0
  125. package/skills/hatch3r-cli-xsv/SKILL.md +89 -0
  126. package/skills/hatch3r-cli-yq/SKILL.md +85 -0
  127. package/skills/hatch3r-cli-zstd/SKILL.md +85 -0
  128. package/skills/hatch3r-context-health/SKILL.md +14 -0
  129. package/skills/hatch3r-cost-tracking/SKILL.md +14 -0
  130. package/skills/hatch3r-customize/SKILL.md +14 -0
  131. package/skills/hatch3r-dep-audit/SKILL.md +14 -0
  132. package/skills/hatch3r-design-system-detect/SKILL.md +162 -0
  133. package/skills/hatch3r-feature/SKILL.md +2 -0
  134. package/skills/hatch3r-gh-agentic-workflows/SKILL.md +13 -0
  135. package/skills/hatch3r-handoff-prepare/SKILL.md +160 -0
  136. package/skills/hatch3r-handoff-resume/SKILL.md +171 -0
  137. package/skills/hatch3r-incident-response/SKILL.md +14 -0
  138. package/skills/hatch3r-issue-workflow/SKILL.md +5 -0
  139. package/skills/hatch3r-logical-refactor/SKILL.md +14 -0
  140. package/skills/hatch3r-migration/SKILL.md +14 -0
  141. package/skills/hatch3r-observability-verify/SKILL.md +133 -0
  142. package/skills/hatch3r-perf-audit/SKILL.md +14 -0
  143. package/skills/hatch3r-pr-creation/SKILL.md +14 -0
  144. package/skills/hatch3r-qa-validation/SKILL.md +18 -0
  145. package/skills/hatch3r-recipe/SKILL.md +14 -0
  146. package/skills/hatch3r-refactor/SKILL.md +14 -0
  147. package/skills/hatch3r-release/SKILL.md +14 -0
  148. package/skills/hatch3r-reliability-verify/SKILL.md +144 -0
  149. package/skills/hatch3r-ui-ux-verify/SKILL.md +136 -0
  150. package/skills/hatch3r-visual-refactor/SKILL.md +15 -1
@@ -0,0 +1,127 @@
1
+ ---
2
+ description: Container image hardening — digest pinning, distroless / Wolfi base, non-root user, SBOM-in-image, cosign signing + verification, multi-stage builds, CVE scanning
3
+ globs: ["**/Dockerfile*", "**/docker-compose*", "**/*.containerfile", "**/charts/**", "**/k8s/**", "**/kubernetes/**", "**/manifests/**"]
4
+ alwaysApply: false
5
+ ---
6
+ # Container Hardening
7
+
8
+ ## Base Image: Wolfi / Chainguard Images
9
+
10
+ The 2026 baseline for container images is Wolfi-OS via Chainguard Images — rebuilt nightly from source, granular per-package versions, no kernel, distroless philosophy. Distroless (Google) remains a valid fallback when Chainguard's commercial offering is out of scope.
11
+
12
+ - Pin every base image by digest, never by tag. Mutable tags (`latest`, `1`, `1.2`) are an attack vector — the registry can serve a different image under the same tag at any time.
13
+ - Example: `FROM cgr.dev/chainguard/node:latest@sha256:<64-hex-digest>` (the `latest` tag is acceptable only when paired with a `@sha256:` digest pin; the digest is the authority).
14
+ - Drift detection: a scheduled CI job re-resolves base-image tags and opens a PR when a newer digest publishes; reviewer inspects CVE delta before merging.
15
+
16
+ ## Multi-Stage Builds
17
+
18
+ Separate the builder from the runtime image. The builder carries the full toolchain (compilers, package managers, dev headers); the runtime carries only the produced artifact plus a distroless or Wolfi base.
19
+
20
+ - Builder stage: install build deps, compile, run tests. May be heavy.
21
+ - Runtime stage: `FROM cgr.dev/chainguard/static:latest@sha256:...` (for static binaries) or `cgr.dev/chainguard/node:latest@sha256:...` (for Node services). `COPY --from=builder` only the artifacts needed at runtime.
22
+ - Result: smaller image, fewer CVEs at runtime, no source code or build tools shipped to production.
23
+
24
+ ## Non-Root User
25
+
26
+ Production containers run as a non-root user. Root-in-container plus container-escape-CVE equals root-on-host.
27
+
28
+ - `USER 65532:65532` (the `nobody` UID on most distros) or a named non-root user declared in the Dockerfile.
29
+ - Kubernetes pod security: `runAsNonRoot: true`, `runAsUser: 65532`, `runAsGroup: 65532`, `readOnlyRootFilesystem: true`, `allowPrivilegeEscalation: false`, `capabilities.drop: [ALL]`.
30
+ - Writable paths use `emptyDir` or `persistentVolumeClaim` mounts, not the root filesystem.
31
+
32
+ ## No Shell, Minimal Binaries
33
+
34
+ Distroless `:nonroot` variants and Chainguard `static` images ship without `/bin/sh`. A compromised process cannot fall back to a shell for lateral movement.
35
+
36
+ - Production image set is `:nonroot` or `static`. Debug variants (`:debug`, `:debug-nonroot`) include `sh` and `busybox` and are pulled only for local troubleshooting.
37
+ - `kubectl debug --image=cgr.dev/chainguard/wolfi-base` provides ephemeral debug containers without baking shells into production images.
38
+
39
+ ## SBOM-in-Image
40
+
41
+ Every image carries a CycloneDX 1.6 SBOM, generated at build time and either embedded in the image or attached as an OCI artifact in the registry.
42
+
43
+ - Generation: `syft <image> -o cyclonedx-json` or BuildKit `--attest type=sbom`. Chainguard Images already ship with attached SBOMs.
44
+ - Attachment: `cosign attach sbom --sbom sbom.cdx.json <image>:<tag>` or BuildKit attestation in the OCI manifest.
45
+ - Deploy-time consumers fetch the SBOM via `cosign download sbom <image>` and match against the CVE feed before admission.
46
+
47
+ ## Image Signing — cosign
48
+
49
+ Every image is signed with cosign keyless mode via OIDC. Sigstore Fulcio issues a short-lived signing certificate scoped to the workflow identity; Rekor records the signature for tamper-evident audit.
50
+
51
+ - Sign in CI: `cosign sign --yes <registry>/<image>@<digest>`. Workflow grants `id-token: write` permission; no long-lived signing key.
52
+ - Verify at deploy: `cosign verify <image> --certificate-identity-regexp 'https://github\.com/org/repo/\.github/workflows/.*' --certificate-oidc-issuer https://token.actions.githubusercontent.com`.
53
+ - Admission enforcement: Sigstore Policy Controller (native admission with CUE or Rego), Kyverno (`verifyImages` rule), or OPA Gatekeeper + Ratify. Unsigned images rejected at admission, not just warned.
54
+
55
+ ## CVE Scanning in CI
56
+
57
+ Two scanners are run per image build: `trivy` for breadth (Wolfi advisory database, OS+language deps) and `grype` for Chainguard parity. Release is blocked on unpatched Critical or High CVEs without a documented suppression record.
58
+
59
+ - `trivy image --severity HIGH,CRITICAL --exit-code 1 <image>:<tag>` fails the job on any High/Critical.
60
+ - Periodic re-scan: a nightly job re-pulls each production image digest and rescans — newly-disclosed CVEs in already-deployed images surface here.
61
+ - Suppressions documented in `.trivyignore` with CVE ID, justification, expiry date, and owner. Expired suppressions fail the build.
62
+
63
+ ## Digest Pinning Everywhere
64
+
65
+ The same digest-not-tag rule extends beyond `FROM` lines to every place the image is referenced.
66
+
67
+ - Kubernetes manifests: `image: <registry>/<image>@sha256:<digest>` in Deployment, StatefulSet, Job, CronJob.
68
+ - Helm charts: `appVersion` references the digest; `image.tag` is the digest, not a semver tag.
69
+ - GitOps repos (Argo CD, Flux): the source of truth is the digest; image-update controllers (`flux image-update`) bump the digest on signed-image admission events.
70
+ - Pull policy: `imagePullPolicy: IfNotPresent` (digests are immutable so pull-once is safe); `Always` is only required when tags are used.
71
+
72
+ ## Reproducible Builds
73
+
74
+ Build inputs are pinned so the same `git checkout` produces the same image digest.
75
+
76
+ - `# syntax=docker/dockerfile:1.<minor>.<patch>` — pin to a specific BuildKit syntax version.
77
+ - Package installs pin versions: `apk add --no-cache nodejs=20.11.1-r0` (Wolfi/Alpine), `apt-get install -y nodejs=20.11.1*` (Debian).
78
+ - Deterministic `COPY` order: copy lockfile and install deps before copying source, so layer caching is stable.
79
+ - `SOURCE_DATE_EPOCH` set from git commit timestamp strips filesystem timestamps.
80
+ - Verify with `reproducible-containers/repro-build`: rebuild and compare digests; mismatches fail.
81
+
82
+ ## Secrets Handling in Images
83
+
84
+ Secrets never enter the image at build time. Runtime injection only.
85
+
86
+ - Forbidden: `COPY .env`, `ARG NPM_TOKEN`, `ENV API_KEY=...`. Build args persist in image history and are recoverable by anyone with image pull access.
87
+ - Build-time secrets (private registry tokens, SSH keys) use BuildKit `--mount=type=secret,id=<name>` — mounted at build, never persisted.
88
+ - Runtime secrets injected via container env (from Kubernetes Secret or vault sidecar), mounted file (CSI Secret Store driver), or IAM role / Workload Identity for cloud auth.
89
+
90
+ ## Health Checks
91
+
92
+ Every long-running container declares readiness, liveness, and startup probes. Cross-reference `rules/hatch3r-operability.md`.
93
+
94
+ - Dockerfile `HEALTHCHECK CMD <command>` for non-orchestrated deployments.
95
+ - Kubernetes `livenessProbe`, `readinessProbe`, `startupProbe` with HTTP, TCP, or exec checks. Startup probe allows slow boots (e.g., JVM warmup) without failing liveness during startup.
96
+ - Probe endpoints implemented at the application layer; `/healthz` (liveness), `/readyz` (readiness), `/startz` (startup) is the conventional split.
97
+
98
+ ## Image Size Budget
99
+
100
+ Runtime image targets under 200 MB compressed. Builds exceeding 500 MB compressed page the platform team for review.
101
+
102
+ - Strip debug symbols and source maps from production artifacts in the builder stage.
103
+ - Single-binary services (Go, Rust) target Chainguard `static` images — typical runtime under 20 MB.
104
+ - Multi-arch images do not multiply the size budget — each architecture is measured independently.
105
+
106
+ ## Verification Gate at Release
107
+
108
+ Every release pipeline executes the following gates before publish, all green:
109
+
110
+ - `cosign verify` against the workflow OIDC identity.
111
+ - `trivy image` and `grype` zero Critical, zero High (or all High suppressed with documented expiry).
112
+ - Image digest pinned in every consuming manifest (rejected if any `image:` line uses a tag without digest).
113
+ - Pod spec runs as non-root (`runAsNonRoot: true`), read-only root filesystem, dropped capabilities.
114
+ - SBOM attached and downloadable via `cosign download sbom`.
115
+
116
+ Cross-reference `agents/hatch3r-security-auditor.md` for runtime security audit; `agents/hatch3r-devops.md` for delivery integration; `rules/hatch3r-secrets-management.md` for OIDC trust-policy conditions; `rules/hatch3r-dependency-management.md` for SBOM tooling and SLSA provenance.
117
+
118
+ ## References
119
+
120
+ - Chainguard Images: https://edu.chainguard.dev/chainguard/chainguard-images/overview/
121
+ - Distroless: https://github.com/GoogleContainerTools/distroless
122
+ - Sigstore cosign: https://docs.sigstore.dev/cosign/overview/
123
+ - Sigstore Policy Controller: https://docs.sigstore.dev/policy-controller/overview/
124
+ - Kyverno image verification: https://kyverno.io/docs/policy-types/verify-images/sigstore/
125
+ - SLSA v1.0 spec: https://slsa.dev/spec/v1.0/
126
+ - Trivy: https://trivy.dev/latest/docs/target/container_image/
127
+ - CISA tj-actions advisory (CVE-2025-30066): https://www.cisa.gov/news-events/alerts/2025/03/18/supply-chain-compromise-third-party-github-action
@@ -0,0 +1,117 @@
1
+ ---
2
+ id: hatch3r-contract-testing
3
+ type: rule
4
+ description: Consumer-driven and spec-driven contract testing between services — Pact, Schemathesis, Dredd, pact-broker can-i-deploy gate
5
+ scope: "**/contracts/**,**/pacts/**,**/api/**,**/openapi*,**/asyncapi*,**/*.proto,**/__tests__/contract/**"
6
+ tags: [review, implementation]
7
+ quality_charter: agents/shared/quality-charter.md
8
+ cache_friendly: true
9
+ ---
10
+ # Contract Testing
11
+
12
+ Pairs `rules/hatch3r-api-design.md` (shape) and `rules/hatch3r-api-versioning.md` (lifecycle) with the verification gate that proves consumer-provider compatibility before deploy.
13
+
14
+ ## When To Use Contract Testing
15
+
16
+ - **Mandatory** for any cross-team service boundary — two services owned by different teams that exchange messages or RPCs.
17
+ - **Mandatory** for any service-to-service call across a deploy boundary (independent CI pipelines, independent release cadences).
18
+ - **Optional** for in-team boundaries where strong types + integration tests already prove the contract.
19
+ - **Not a substitute** for end-to-end tests — contract tests verify the protocol; E2E verifies the user flow.
20
+
21
+ ## Consumer-Driven Contract Testing (CDCT) — Pact
22
+
23
+ Pact is the de facto CDCT framework. The flow:
24
+
25
+ 1. **Consumer test:** consumer writes expectations (`given`/`uponReceiving`/`willRespondWith`); Pact records the interactions to a `.pact.json` file and runs the consumer test against an in-process mock provider.
26
+ 2. **Publish:** consumer CI publishes the Pact file to a Pact Broker / PactFlow instance with the consumer's git SHA + branch tag.
27
+ 3. **Provider verification:** provider CI runs `pact-verifier` against every Pact published against its name; replays each interaction against the real provider implementation and asserts the response matches.
28
+ 4. **Deploy gate:** `pact-broker can-i-deploy --pacticipant <service> --version <sha> --to-environment production` returns non-zero if any consumer's verification is failing for the version being deployed.
29
+
30
+ The `can-i-deploy` gate is the contract-testing equivalent of `npm test` — every production deploy passes it.
31
+
32
+ ## Bi-Directional Contract Testing (BDCT) — PactFlow
33
+
34
+ When the provider already publishes OpenAPI (or AsyncAPI) and runs self-verification (Dredd/Schemathesis), BDCT avoids the cost of provider Pact verification:
35
+
36
+ - Provider publishes its OpenAPI spec + self-verification results to PactFlow.
37
+ - Consumer publishes Pact as usual.
38
+ - PactFlow cross-verifies: every consumer expectation must match an OpenAPI operation; every operation field consumed must exist in the OpenAPI response schema.
39
+ - Use BDCT for high-traffic providers where running Pact verification on every consumer PR is expensive; reverts to CDCT if drift is detected between OpenAPI and live behavior.
40
+
41
+ ## Spec-Driven Contract Testing — Schemathesis
42
+
43
+ Schemathesis generates property-based tests from OpenAPI 3.0 / 3.1 (and GraphQL) schemas:
44
+
45
+ - Runs against the live provider implementation; fuzzes inputs based on the spec; asserts every response conforms to the documented schema, status codes, and headers.
46
+ - Catches drift between spec and implementation that CDCT alone misses (Pact only verifies the interactions consumers actually request).
47
+ - Published research (`schemathesis.readthedocs.io` benchmark studies) shows Schemathesis finds 1.4-4.5x more defects than Pact-alone on the same providers.
48
+ - Run on every provider PR; report property-based failures with reproducer URLs.
49
+
50
+ ## Other Tools
51
+
52
+ - **Dredd** — executable contracts from OpenAPI / API Blueprint; declarative happy-path verification. Use for simple cases where Schemathesis is overkill; legacy.
53
+ - **Hoverfly** — proxy-based service virtualization for stateful integration scenarios (record/replay). Useful when downstream dependencies cannot be mocked from a spec.
54
+
55
+ ## Coverage Policy
56
+
57
+ Every cross-service interaction is covered by:
58
+
59
+ 1. **Consumer side:** Pact test in the consumer's `__tests__/contract/` directory, published to the broker on every consumer PR.
60
+ 2. **Provider side:** Schemathesis property-based tests against the provider's OpenAPI spec, run on every provider PR.
61
+ 3. **Cross-verification:** `pact-verifier` (CDCT) or PactFlow BDCT replays consumer expectations against the provider implementation on every provider PR + consumer PR (matrix verification — provider PRs verify against every consumer's latest tag; consumer PRs verify against the provider's `main`).
62
+
63
+ GraphQL: consumers register persisted queries; the registry doubles as the contract — every operation in the manifest is verifiable against the schema via `graphql-inspector validate`.
64
+
65
+ gRPC: `buf breaking` catches protocol-level breaks; pact-protobuf-plugin or grpcurl-based provider verification catches behavior-level breaks.
66
+
67
+ ## `can-i-deploy` Gate
68
+
69
+ Every production deploy runs:
70
+
71
+ ```
72
+ pact-broker can-i-deploy \
73
+ --pacticipant <service-name> \
74
+ --version <git-sha> \
75
+ --to-environment production
76
+ ```
77
+
78
+ - Exit non-zero blocks the deploy via the CI gate.
79
+ - Failure messages list which consumer's verification is missing or failing — the deploy operator can read which contract is incompatible.
80
+ - Pair with PactFlow's `webhook` to trigger consumer verifications when the provider publishes a new tag.
81
+
82
+ ## Contract Evolution
83
+
84
+ - Providers **may** add fields freely; consumers ignore unknown fields by default (Pact + Schemathesis verify that expected fields are present, not that the response contains only those fields).
85
+ - Providers **may not** remove or rename fields without an RFC 9745 Deprecation + RFC 8594 Sunset cycle — cross-reference `rules/hatch3r-api-versioning.md` for the lifecycle.
86
+ - Consumers may add new expectations; the next provider verification run reveals whether the provider supports them.
87
+ - Pact files are immutable once published — never edit a published pact retroactively. Republish under a new consumer version.
88
+
89
+ ## Tooling Per Ecosystem
90
+
91
+ | Ecosystem | Consumer SDK | Provider verifier |
92
+ |-----------|--------------|-------------------|
93
+ | Node / TS | `@pact-foundation/pact` (pact-js) | `pact-js` verifier or `pact-cli` |
94
+ | Ruby | `pact` gem | `pact-provider-verifier` |
95
+ | JVM | `au.com.dius.pact:pact-jvm-consumer` | `pact-jvm-provider` |
96
+ | Go | `pact-go` | `pact-go verify` |
97
+ | Python | `pact-python` + Schemathesis (spec-driven) | `pact-python` verifier |
98
+ | Rust | `pact_consumer` / `pact_verifier` | `pact_verifier_cli` |
99
+ | .NET | `PactNet` | `PactNet.Verifier` |
100
+
101
+ Schemathesis is Python-only on the runner side but verifies any OpenAPI 3.x provider regardless of provider language.
102
+
103
+ ## Anti-Patterns
104
+
105
+ - **Never** mock provider responses in consumer unit tests bypassing Pact — defeats the purpose of CDCT.
106
+ - **Never** run consumer tests against the production provider — use the Pact mock; production data and contract drift get conflated.
107
+ - **Never** edit a published pact retroactively — republish under a new consumer version. The broker keeps the original immutable.
108
+ - **Never** skip `can-i-deploy` because "tests are green locally" — local Pact tests verify the mock, not the live provider.
109
+ - **Never** use only Schemathesis without Pact (or vice versa) — they catch different failure classes (drift vs incompatibility); both are required for full coverage.
110
+
111
+ ## References
112
+
113
+ - Pact — https://docs.pact.io
114
+ - PactFlow BDCT — https://docs.pactflow.io/docs/bi-directional-contract-testing
115
+ - Schemathesis — https://schemathesis.readthedocs.io
116
+ - `pact-broker can-i-deploy` — https://docs.pact.io/pact_broker/can_i_deploy
117
+ - Standard Webhooks (for webhook contract testing) — https://github.com/standard-webhooks/standard-webhooks
@@ -0,0 +1,113 @@
1
+ ---
2
+ description: Consumer-driven and spec-driven contract testing between services — Pact, Schemathesis, Dredd, pact-broker can-i-deploy gate
3
+ globs: ["**/contracts/**", "**/pacts/**", "**/api/**", "**/openapi*", "**/asyncapi*", "**/*.proto", "**/__tests__/contract/**"]
4
+ alwaysApply: false
5
+ ---
6
+ # Contract Testing
7
+
8
+ Pairs `rules/hatch3r-api-design.md` (shape) and `rules/hatch3r-api-versioning.md` (lifecycle) with the verification gate that proves consumer-provider compatibility before deploy.
9
+
10
+ ## When To Use Contract Testing
11
+
12
+ - **Mandatory** for any cross-team service boundary — two services owned by different teams that exchange messages or RPCs.
13
+ - **Mandatory** for any service-to-service call across a deploy boundary (independent CI pipelines, independent release cadences).
14
+ - **Optional** for in-team boundaries where strong types + integration tests already prove the contract.
15
+ - **Not a substitute** for end-to-end tests — contract tests verify the protocol; E2E verifies the user flow.
16
+
17
+ ## Consumer-Driven Contract Testing (CDCT) — Pact
18
+
19
+ Pact is the de facto CDCT framework. The flow:
20
+
21
+ 1. **Consumer test:** consumer writes expectations (`given`/`uponReceiving`/`willRespondWith`); Pact records the interactions to a `.pact.json` file and runs the consumer test against an in-process mock provider.
22
+ 2. **Publish:** consumer CI publishes the Pact file to a Pact Broker / PactFlow instance with the consumer's git SHA + branch tag.
23
+ 3. **Provider verification:** provider CI runs `pact-verifier` against every Pact published against its name; replays each interaction against the real provider implementation and asserts the response matches.
24
+ 4. **Deploy gate:** `pact-broker can-i-deploy --pacticipant <service> --version <sha> --to-environment production` returns non-zero if any consumer's verification is failing for the version being deployed.
25
+
26
+ The `can-i-deploy` gate is the contract-testing equivalent of `npm test` — every production deploy passes it.
27
+
28
+ ## Bi-Directional Contract Testing (BDCT) — PactFlow
29
+
30
+ When the provider already publishes OpenAPI (or AsyncAPI) and runs self-verification (Dredd/Schemathesis), BDCT avoids the cost of provider Pact verification:
31
+
32
+ - Provider publishes its OpenAPI spec + self-verification results to PactFlow.
33
+ - Consumer publishes Pact as usual.
34
+ - PactFlow cross-verifies: every consumer expectation must match an OpenAPI operation; every operation field consumed must exist in the OpenAPI response schema.
35
+ - Use BDCT for high-traffic providers where running Pact verification on every consumer PR is expensive; reverts to CDCT if drift is detected between OpenAPI and live behavior.
36
+
37
+ ## Spec-Driven Contract Testing — Schemathesis
38
+
39
+ Schemathesis generates property-based tests from OpenAPI 3.0 / 3.1 (and GraphQL) schemas:
40
+
41
+ - Runs against the live provider implementation; fuzzes inputs based on the spec; asserts every response conforms to the documented schema, status codes, and headers.
42
+ - Catches drift between spec and implementation that CDCT alone misses (Pact only verifies the interactions consumers actually request).
43
+ - Published research (`schemathesis.readthedocs.io` benchmark studies) shows Schemathesis finds 1.4-4.5x more defects than Pact-alone on the same providers.
44
+ - Run on every provider PR; report property-based failures with reproducer URLs.
45
+
46
+ ## Other Tools
47
+
48
+ - **Dredd** — executable contracts from OpenAPI / API Blueprint; declarative happy-path verification. Use for simple cases where Schemathesis is overkill; legacy.
49
+ - **Hoverfly** — proxy-based service virtualization for stateful integration scenarios (record/replay). Useful when downstream dependencies cannot be mocked from a spec.
50
+
51
+ ## Coverage Policy
52
+
53
+ Every cross-service interaction is covered by:
54
+
55
+ 1. **Consumer side:** Pact test in the consumer's `__tests__/contract/` directory, published to the broker on every consumer PR.
56
+ 2. **Provider side:** Schemathesis property-based tests against the provider's OpenAPI spec, run on every provider PR.
57
+ 3. **Cross-verification:** `pact-verifier` (CDCT) or PactFlow BDCT replays consumer expectations against the provider implementation on every provider PR + consumer PR (matrix verification — provider PRs verify against every consumer's latest tag; consumer PRs verify against the provider's `main`).
58
+
59
+ GraphQL: consumers register persisted queries; the registry doubles as the contract — every operation in the manifest is verifiable against the schema via `graphql-inspector validate`.
60
+
61
+ gRPC: `buf breaking` catches protocol-level breaks; pact-protobuf-plugin or grpcurl-based provider verification catches behavior-level breaks.
62
+
63
+ ## `can-i-deploy` Gate
64
+
65
+ Every production deploy runs:
66
+
67
+ ```
68
+ pact-broker can-i-deploy \
69
+ --pacticipant <service-name> \
70
+ --version <git-sha> \
71
+ --to-environment production
72
+ ```
73
+
74
+ - Exit non-zero blocks the deploy via the CI gate.
75
+ - Failure messages list which consumer's verification is missing or failing — the deploy operator can read which contract is incompatible.
76
+ - Pair with PactFlow's `webhook` to trigger consumer verifications when the provider publishes a new tag.
77
+
78
+ ## Contract Evolution
79
+
80
+ - Providers **may** add fields freely; consumers ignore unknown fields by default (Pact + Schemathesis verify that expected fields are present, not that the response contains only those fields).
81
+ - Providers **may not** remove or rename fields without an RFC 9745 Deprecation + RFC 8594 Sunset cycle — cross-reference `rules/hatch3r-api-versioning.md` for the lifecycle.
82
+ - Consumers may add new expectations; the next provider verification run reveals whether the provider supports them.
83
+ - Pact files are immutable once published — never edit a published pact retroactively. Republish under a new consumer version.
84
+
85
+ ## Tooling Per Ecosystem
86
+
87
+ | Ecosystem | Consumer SDK | Provider verifier |
88
+ |-----------|--------------|-------------------|
89
+ | Node / TS | `@pact-foundation/pact` (pact-js) | `pact-js` verifier or `pact-cli` |
90
+ | Ruby | `pact` gem | `pact-provider-verifier` |
91
+ | JVM | `au.com.dius.pact:pact-jvm-consumer` | `pact-jvm-provider` |
92
+ | Go | `pact-go` | `pact-go verify` |
93
+ | Python | `pact-python` + Schemathesis (spec-driven) | `pact-python` verifier |
94
+ | Rust | `pact_consumer` / `pact_verifier` | `pact_verifier_cli` |
95
+ | .NET | `PactNet` | `PactNet.Verifier` |
96
+
97
+ Schemathesis is Python-only on the runner side but verifies any OpenAPI 3.x provider regardless of provider language.
98
+
99
+ ## Anti-Patterns
100
+
101
+ - **Never** mock provider responses in consumer unit tests bypassing Pact — defeats the purpose of CDCT.
102
+ - **Never** run consumer tests against the production provider — use the Pact mock; production data and contract drift get conflated.
103
+ - **Never** edit a published pact retroactively — republish under a new consumer version. The broker keeps the original immutable.
104
+ - **Never** skip `can-i-deploy` because "tests are green locally" — local Pact tests verify the mock, not the live provider.
105
+ - **Never** use only Schemathesis without Pact (or vice versa) — they catch different failure classes (drift vs incompatibility); both are required for full coverage.
106
+
107
+ ## References
108
+
109
+ - Pact — https://docs.pact.io
110
+ - PactFlow BDCT — https://docs.pactflow.io/docs/bi-directional-contract-testing
111
+ - Schemathesis — https://schemathesis.readthedocs.io
112
+ - `pact-broker can-i-deploy` — https://docs.pact.io/pact_broker/can_i_deploy
113
+ - Standard Webhooks (for webhook contract testing) — https://github.com/standard-webhooks/standard-webhooks
@@ -51,6 +51,8 @@ Multi-file changes with clear scope. Run these researcher modes at `quick` depth
51
51
 
52
52
  Present findings to the user inline. Proceed after answers are received — no separate confirmation checkpoint required.
53
53
 
54
+ **Tier 2 confirmation gate.** Before invoking Phase 2, the orchestrator lists any unresolved scope, acceptance, or constraint questions and asks the user to confirm or answer via the platform-native question tool (`agents/shared/user-question-protocol.md`). The orchestrator does not proceed under default-if-no-response for Tier 2 unless the question is single-option-reversible.
55
+
54
56
  ### Tier 3 — Deep
55
57
 
56
58
  Cross-module features, architectural changes, multi-layer implementations, or tasks with high ambiguity. Run these researcher modes at `deep` depth:
@@ -46,6 +46,8 @@ Multi-file changes with clear scope. Run these researcher modes at `quick` depth
46
46
 
47
47
  Present findings to the user inline. Proceed after answers are received — no separate confirmation checkpoint required.
48
48
 
49
+ **Tier 2 confirmation gate.** Before invoking Phase 2, the orchestrator lists any unresolved scope, acceptance, or constraint questions and asks the user to confirm or answer via the platform-native question tool (`agents/shared/user-question-protocol.md`). The orchestrator does not proceed under default-if-no-response for Tier 2 unless the question is single-option-reversible.
50
+
49
51
  ### Tier 3 — Deep
50
52
 
51
53
  Cross-module features, architectural changes, multi-layer implementations, or tasks with high ambiguity. Run these researcher modes at `deep` depth:
@@ -3,7 +3,7 @@ id: hatch3r-dependency-management
3
3
  type: rule
4
4
  description: Lockfile discipline, CVE scanning, transitive dependency audits, major version upgrade protocol, and bundle-size impact gates for package manifests
5
5
  scope: "**/package.json,**/package-lock.json,**/yarn.lock,**/pnpm-lock.yaml,**/Cargo.toml,**/Cargo.lock,**/requirements*.txt,**/pyproject.toml,**/go.mod,**/go.sum,**/Gemfile*"
6
- tags: [maintenance]
6
+ tags: [maintenance, security]
7
7
  quality_charter: agents/shared/quality-charter.md
8
8
  cache_friendly: true
9
9
  ---
@@ -30,3 +30,75 @@ cache_friendly: true
30
30
  - Review changelogs and migration guides before upgrading major versions. Never blindly bump major versions and assume backward compatibility.
31
31
  - Run the full test suite after any dependency upgrade, including integration tests. A passing unit test suite does not guarantee compatibility with upgraded peer dependencies.
32
32
  - When upgrading a shared dependency used across multiple modules, upgrade all consumers in the same PR to avoid version skew within the monorepo or project.
33
+
34
+ ## npm Trusted Publishing (OIDC)
35
+
36
+ For libraries published to npm, configure an npm Trusted Publisher with GitHub OIDC. The publishing workflow exchanges a per-run JWT for short-lived publish credentials — no long-lived `NPM_TOKEN` in secrets. Provenance attestations are auto-generated and signed by Sigstore Fulcio with the inclusion record in Rekor.
37
+
38
+ - Requirements: npm CLI >=11.5.1, Node >=22.14.0, `repository` field set in `package.json` (provenance validation fails without it).
39
+ - Workflow grants `id-token: write` permission at the job level.
40
+ - Remove `NPM_TOKEN` from repository and organization secrets after migrating to trusted publishing.
41
+ - PyPI, crates.io, and RubyGems offer equivalent OIDC trusted publishing — migrate at least one ecosystem per release pipeline.
42
+
43
+ ## Provenance Flag for Non-Trusted Publishing
44
+
45
+ When trusted publishing is not yet enabled, publish with `npm publish --provenance`. The flag activates Sigstore-signed provenance even with token auth.
46
+
47
+ - Verify provenance: `npm view <pkg> --json | jq .dist.attestations` returns Sigstore attestation URLs; the npm package page renders a Provenance section.
48
+ - Consumers verify on install: `npm audit signatures` walks the attestation chain and confirms Rekor inclusion.
49
+
50
+ ## SBOM Generation
51
+
52
+ Every release artifact ships a CycloneDX 1.6 or SPDX 3.0.1 SBOM, committed as a release asset and signed with the same Sigstore identity that signed the artifact. CycloneDX 1.6 is ECMA-424 ratified and broadly supported (Syft, Trivy, cdxgen, GitLab native). SPDX 3.0.1 is the BSI TR-03183-2 / EU CRA baseline.
53
+
54
+ - Tooling baseline: `npm sbom --sbom-format=cyclonedx` (npm 10+), `cdxgen` (broad ecosystem coverage including Python, Java, Rust, Go), `syft` (containers + source repos).
55
+ - CI step generates SBOM on every release tag and uploads as a release asset.
56
+ - PR-time SBOM diff (`cyclonedx-cli diff` or `syft diff`) blocks PRs that introduce unexpected new transitive dependencies; reviewer approves the diff alongside the source diff.
57
+
58
+ ## SLSA v1.0 / v1.1 Build Provenance
59
+
60
+ Target SLSA Build L3 for production release artifacts: ephemeral hosted runner, isolated builder identity, signed in-toto provenance, transparency log inclusion. SLSA v1.1 (April 2025) is incremental on the Build track — v1.0 L3 artifacts also meet v1.1 L3.
61
+
62
+ - GitHub Actions implementation: `slsa-framework/slsa-github-generator` (language-agnostic generators for npm, container, generic artifact).
63
+ - Deploy-time verification: `slsa-verifier` CLI confirms provenance, builder identity allow-list, and source-repo match before the artifact is consumed.
64
+ - Pin the generator action to a 40-char commit SHA per the action-pinning policy below.
65
+
66
+ ## Malicious-Package Detection Beyond `npm audit`
67
+
68
+ `npm audit` only flags published CVEs. The 2025-2026 incident class — Shai-Hulud (Sep-Nov 2025), Axios 1.14.1 maintainer hijack (Mar 2026), Mini-Shai-Hulud (May 2026), DevTap typosquat (Apr-May 2026) — never reaches a CVE filing. Layer install-time behavioral detection on top of `npm audit`:
69
+
70
+ - Pre-install behavioral scan: `socket.dev`, `snyk`, or `osv-scanner` against the lockfile in CI. `npq` adds a pre-install gate at the developer workstation.
71
+ - pnpm `minimumReleaseAge: 72` (3 days, raise to 7 for high-trust projects) blocks consumption of brand-new versions until the typosquat / maintainer-hijack window closes.
72
+ - Disable lifecycle scripts in CI: `.npmrc` sets `ignore-scripts=true`; pnpm uses `strictDepBuilds: true` plus `allowBuilds: [explicit-list]`.
73
+ - GitHub `dependency-review-action` on every PR blocks new dependencies with known advisories or disallowed licenses.
74
+
75
+ ## Lockfile Policy
76
+
77
+ - Lockfile committed to the repository: `package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`. Multi-language repos commit the per-ecosystem lockfile (`Cargo.lock`, `poetry.lock`, `go.sum`, `Gemfile.lock`).
78
+ - CI installs from the lockfile only: `npm ci`, `yarn install --frozen-lockfile`, `pnpm install --frozen-lockfile`, `cargo build --locked`. Drift fails the build.
79
+ - `lockfile-lint` enforces registry allow-list and integrity-hash presence on every entry. Run in CI alongside install.
80
+ - Lockfile diffs receive the same review scrutiny as source diffs — reviewers inspect new transitive entries and version jumps.
81
+ - Renovate or Dependabot configured with grouped weekly updates: one PR per ecosystem per week for non-security updates; security updates open immediately.
82
+
83
+ ## License Compliance
84
+
85
+ - Allow-list (default): MIT, Apache-2.0, ISC, BSD-2-Clause, BSD-3-Clause, MPL-2.0, CC0-1.0. Project policy may extend.
86
+ - Deny-list (default): GPL-2.0, GPL-3.0, AGPL-3.0, AGPL-3.0-or-later, SSPL-1.0, Commons Clause. AGPL triggers copyleft on network use — it is the SaaS landmine.
87
+ - Override requires documented business justification in the PR description plus security/legal sign-off.
88
+ - CI gate per ecosystem: `license-checker --onlyAllow "MIT;Apache-2.0;ISC;BSD-2-Clause;BSD-3-Clause;MPL-2.0;CC0-1.0"` (Node), `pip-licenses --allow-only` (Python), `cargo-license` (Rust). CI fails on detection of a denied license in direct or transitive deps.
89
+
90
+ ## Pinned GitHub Action SHAs
91
+
92
+ Every action `uses:` line references a 40-character commit SHA, never a tag (`@v3`, `@main`, `@v44.5.1`). Tags are mutable; SHAs are not.
93
+
94
+ - CVE-2025-30066 (tj-actions/changed-files, March 2025) compromised 23,000+ repositories — the attacker mutated existing version tags to point to a malicious commit that dumped secrets to workflow logs. Root cause: compromised PAT on `reviewdog/action-setup` (CVE-2025-30154). Tag pinning would not have prevented this; SHA pinning would have.
95
+ - Annotate the SHA with the version: `uses: actions/checkout@<40-char-sha> # v4.2.2`.
96
+ - Dependabot configured with `package-ecosystem: github-actions` updates SHAs while preserving the version comment. Renovate equivalent: `pinDigests: true`.
97
+ - CI rejects PRs that introduce tag references via a linter step (e.g., `pinact` or a custom regex check).
98
+
99
+ ## OSV.dev and GHSA Feeds
100
+
101
+ - `osv-scanner` runs on every PR and nightly against the lockfile. OSV.dev (Google) is the polyglot 2026 aggregator: npm, PyPI, crates.io, Maven, Go modules, RubyGems, Packagist, NuGet — single schema across all.
102
+ - GitHub Security Advisories (GHSA) remain the npm-ecosystem authoritative feed; `npm audit` and OSV both consume GHSA.
103
+ - NVD provides CPE-keyed CVE records for OS and language-stdlib vulnerabilities.
104
+ - Renovate `vulnerabilityAlerts: { enabled: true }` plus `osvVulnerabilityAlerts: true` produce auto-PRs that force-update to fixed versions and bypass the normal cooldown for security fixes. Pair with auto-merge for patch-level fixes when tests pass.
@@ -26,3 +26,75 @@ alwaysApply: false
26
26
  - Review changelogs and migration guides before upgrading major versions. Never blindly bump major versions and assume backward compatibility.
27
27
  - Run the full test suite after any dependency upgrade, including integration tests. A passing unit test suite does not guarantee compatibility with upgraded peer dependencies.
28
28
  - When upgrading a shared dependency used across multiple modules, upgrade all consumers in the same PR to avoid version skew within the monorepo or project.
29
+
30
+ ## npm Trusted Publishing (OIDC)
31
+
32
+ For libraries published to npm, configure an npm Trusted Publisher with GitHub OIDC. The publishing workflow exchanges a per-run JWT for short-lived publish credentials — no long-lived `NPM_TOKEN` in secrets. Provenance attestations are auto-generated and signed by Sigstore Fulcio with the inclusion record in Rekor.
33
+
34
+ - Requirements: npm CLI >=11.5.1, Node >=22.14.0, `repository` field set in `package.json` (provenance validation fails without it).
35
+ - Workflow grants `id-token: write` permission at the job level.
36
+ - Remove `NPM_TOKEN` from repository and organization secrets after migrating to trusted publishing.
37
+ - PyPI, crates.io, and RubyGems offer equivalent OIDC trusted publishing — migrate at least one ecosystem per release pipeline.
38
+
39
+ ## Provenance Flag for Non-Trusted Publishing
40
+
41
+ When trusted publishing is not yet enabled, publish with `npm publish --provenance`. The flag activates Sigstore-signed provenance even with token auth.
42
+
43
+ - Verify provenance: `npm view <pkg> --json | jq .dist.attestations` returns Sigstore attestation URLs; the npm package page renders a Provenance section.
44
+ - Consumers verify on install: `npm audit signatures` walks the attestation chain and confirms Rekor inclusion.
45
+
46
+ ## SBOM Generation
47
+
48
+ Every release artifact ships a CycloneDX 1.6 or SPDX 3.0.1 SBOM, committed as a release asset and signed with the same Sigstore identity that signed the artifact. CycloneDX 1.6 is ECMA-424 ratified and broadly supported (Syft, Trivy, cdxgen, GitLab native). SPDX 3.0.1 is the BSI TR-03183-2 / EU CRA baseline.
49
+
50
+ - Tooling baseline: `npm sbom --sbom-format=cyclonedx` (npm 10+), `cdxgen` (broad ecosystem coverage including Python, Java, Rust, Go), `syft` (containers + source repos).
51
+ - CI step generates SBOM on every release tag and uploads as a release asset.
52
+ - PR-time SBOM diff (`cyclonedx-cli diff` or `syft diff`) blocks PRs that introduce unexpected new transitive dependencies; reviewer approves the diff alongside the source diff.
53
+
54
+ ## SLSA v1.0 / v1.1 Build Provenance
55
+
56
+ Target SLSA Build L3 for production release artifacts: ephemeral hosted runner, isolated builder identity, signed in-toto provenance, transparency log inclusion. SLSA v1.1 (April 2025) is incremental on the Build track — v1.0 L3 artifacts also meet v1.1 L3.
57
+
58
+ - GitHub Actions implementation: `slsa-framework/slsa-github-generator` (language-agnostic generators for npm, container, generic artifact).
59
+ - Deploy-time verification: `slsa-verifier` CLI confirms provenance, builder identity allow-list, and source-repo match before the artifact is consumed.
60
+ - Pin the generator action to a 40-char commit SHA per the action-pinning policy below.
61
+
62
+ ## Malicious-Package Detection Beyond `npm audit`
63
+
64
+ `npm audit` only flags published CVEs. The 2025-2026 incident class — Shai-Hulud (Sep-Nov 2025), Axios 1.14.1 maintainer hijack (Mar 2026), Mini-Shai-Hulud (May 2026), DevTap typosquat (Apr-May 2026) — never reaches a CVE filing. Layer install-time behavioral detection on top of `npm audit`:
65
+
66
+ - Pre-install behavioral scan: `socket.dev`, `snyk`, or `osv-scanner` against the lockfile in CI. `npq` adds a pre-install gate at the developer workstation.
67
+ - pnpm `minimumReleaseAge: 72` (3 days, raise to 7 for high-trust projects) blocks consumption of brand-new versions until the typosquat / maintainer-hijack window closes.
68
+ - Disable lifecycle scripts in CI: `.npmrc` sets `ignore-scripts=true`; pnpm uses `strictDepBuilds: true` plus `allowBuilds: [explicit-list]`.
69
+ - GitHub `dependency-review-action` on every PR blocks new dependencies with known advisories or disallowed licenses.
70
+
71
+ ## Lockfile Policy
72
+
73
+ - Lockfile committed to the repository: `package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`. Multi-language repos commit the per-ecosystem lockfile (`Cargo.lock`, `poetry.lock`, `go.sum`, `Gemfile.lock`).
74
+ - CI installs from the lockfile only: `npm ci`, `yarn install --frozen-lockfile`, `pnpm install --frozen-lockfile`, `cargo build --locked`. Drift fails the build.
75
+ - `lockfile-lint` enforces registry allow-list and integrity-hash presence on every entry. Run in CI alongside install.
76
+ - Lockfile diffs receive the same review scrutiny as source diffs — reviewers inspect new transitive entries and version jumps.
77
+ - Renovate or Dependabot configured with grouped weekly updates: one PR per ecosystem per week for non-security updates; security updates open immediately.
78
+
79
+ ## License Compliance
80
+
81
+ - Allow-list (default): MIT, Apache-2.0, ISC, BSD-2-Clause, BSD-3-Clause, MPL-2.0, CC0-1.0. Project policy may extend.
82
+ - Deny-list (default): GPL-2.0, GPL-3.0, AGPL-3.0, AGPL-3.0-or-later, SSPL-1.0, Commons Clause. AGPL triggers copyleft on network use — it is the SaaS landmine.
83
+ - Override requires documented business justification in the PR description plus security/legal sign-off.
84
+ - CI gate per ecosystem: `license-checker --onlyAllow "MIT;Apache-2.0;ISC;BSD-2-Clause;BSD-3-Clause;MPL-2.0;CC0-1.0"` (Node), `pip-licenses --allow-only` (Python), `cargo-license` (Rust). CI fails on detection of a denied license in direct or transitive deps.
85
+
86
+ ## Pinned GitHub Action SHAs
87
+
88
+ Every action `uses:` line references a 40-character commit SHA, never a tag (`@v3`, `@main`, `@v44.5.1`). Tags are mutable; SHAs are not.
89
+
90
+ - CVE-2025-30066 (tj-actions/changed-files, March 2025) compromised 23,000+ repositories — the attacker mutated existing version tags to point to a malicious commit that dumped secrets to workflow logs. Root cause: compromised PAT on `reviewdog/action-setup` (CVE-2025-30154). Tag pinning would not have prevented this; SHA pinning would have.
91
+ - Annotate the SHA with the version: `uses: actions/checkout@<40-char-sha> # v4.2.2`.
92
+ - Dependabot configured with `package-ecosystem: github-actions` updates SHAs while preserving the version comment. Renovate equivalent: `pinDigests: true`.
93
+ - CI rejects PRs that introduce tag references via a linter step (e.g., `pinact` or a custom regex check).
94
+
95
+ ## OSV.dev and GHSA Feeds
96
+
97
+ - `osv-scanner` runs on every PR and nightly against the lockfile. OSV.dev (Google) is the polyglot 2026 aggregator: npm, PyPI, crates.io, Maven, Go modules, RubyGems, Packagist, NuGet — single schema across all.
98
+ - GitHub Security Advisories (GHSA) remain the npm-ecosystem authoritative feed; `npm audit` and OSV both consume GHSA.
99
+ - NVD provides CPE-keyed CVE records for OS and language-stdlib vulnerabilities.
100
+ - Renovate `vulnerabilityAlerts: { enabled: true }` plus `osvVulnerabilityAlerts: true` produce auto-PRs that force-update to fixed versions and bypass the normal cooldown for security fixes. Pair with auto-merge for patch-level fixes when tests pass.