universal-dev-standards 5.17.0 → 6.0.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/bin/uds.js +13 -135
- package/bundled/ai/standards/acceptance-criteria-traceability.ai.yaml +13 -4
- package/bundled/ai/standards/accessibility-standards.ai.yaml +1 -1
- package/bundled/ai/standards/ai-response-navigation.ai.yaml +15 -2
- package/bundled/ai/standards/api-design-standards.ai.yaml +27 -4
- package/bundled/ai/standards/behavior-snapshot.ai.yaml +86 -9
- package/bundled/ai/standards/checkin-standards.ai.yaml +2 -2
- package/bundled/ai/standards/code-review.ai.yaml +2 -2
- package/bundled/ai/standards/context-aware-loading.ai.yaml +3 -3
- package/bundled/ai/standards/data-migration-testing.ai.yaml +79 -3
- package/bundled/ai/standards/deprecation-standards.ai.yaml +10 -2
- package/bundled/ai/standards/developer-memory.ai.yaml +4 -3
- package/bundled/ai/standards/flow-based-testing.ai.yaml +2 -2
- package/bundled/ai/standards/forward-derivation-standards.ai.yaml +26 -2
- package/bundled/ai/standards/full-coverage-testing.ai.yaml +34 -2
- package/bundled/ai/standards/git-worktree.ai.yaml +3 -3
- package/bundled/ai/standards/logging.ai.yaml +97 -3
- package/bundled/ai/standards/mock-boundary.ai.yaml +48 -2
- package/bundled/ai/standards/model-provenance.ai.yaml +297 -0
- package/bundled/ai/standards/model-selection.ai.yaml +11 -2
- package/bundled/ai/standards/observability-standards.ai.yaml +10 -0
- package/bundled/ai/standards/performance-standards.ai.yaml +46 -1
- package/bundled/ai/standards/pii-classification.ai.yaml +15 -1
- package/bundled/ai/standards/pipeline-security-gates.ai.yaml +10 -0
- package/bundled/ai/standards/privacy-standards.ai.yaml +2 -2
- package/bundled/ai/standards/project-context-memory.ai.yaml +2 -2
- package/bundled/ai/standards/refactoring-standards.ai.yaml +68 -3
- package/bundled/ai/standards/resource-cost-boundary.ai.yaml +279 -0
- package/bundled/ai/standards/reverse-engineering-standards.ai.yaml +55 -2
- package/bundled/ai/standards/security-testing.ai.yaml +13 -2
- package/bundled/ai/standards/skill-standard-alignment-check.ai.yaml +37 -2
- package/bundled/ai/standards/user-journey-testing.ai.yaml +107 -0
- package/bundled/ai/standards/verification-oracle.ai.yaml +278 -0
- package/bundled/ai/standards/versioning.ai.yaml +32 -38
- package/bundled/core/acceptance-criteria-traceability.md +15 -5
- package/bundled/core/accessibility-standards.md +8 -4
- package/bundled/core/ai-friendly-architecture.md +1 -1
- package/bundled/core/ai-response-navigation.md +31 -3
- package/bundled/core/anti-sycophancy-prompting.md +1 -1
- package/bundled/core/api-design-standards.md +92 -7
- package/bundled/core/audit-trail.md +119 -0
- package/bundled/core/behavior-snapshot.md +94 -7
- package/bundled/core/browser-compatibility-standards.md +15 -2
- package/bundled/core/checkin-standards.md +9 -2
- package/bundled/core/code-review-checklist.md +10 -2
- package/bundled/core/container-image-standards.md +97 -0
- package/bundled/core/context-aware-loading.md +2 -2
- package/bundled/core/cost-budget-test.md +1 -1
- package/bundled/core/cross-flow-regression.md +3 -2
- package/bundled/core/data-contract.md +104 -0
- package/bundled/core/data-migration-testing.md +90 -0
- package/bundled/core/data-pipeline.md +113 -0
- package/bundled/core/deprecation-standards.md +16 -2
- package/bundled/core/developer-memory.md +13 -8
- package/bundled/core/documentation-writing-standards.md +1 -1
- package/bundled/core/error-code-standards.md +4 -3
- package/bundled/core/flaky-test-management.md +1 -1
- package/bundled/core/flow-based-testing.md +3 -3
- package/bundled/core/forward-derivation-standards.md +33 -5
- package/bundled/core/full-coverage-testing.md +72 -0
- package/bundled/core/git-worktree.md +4 -4
- package/bundled/core/guides/performance-guide.md +1 -1
- package/bundled/core/guides/security-guide.md +1 -1
- package/bundled/core/health-check-standards.md +2 -2
- package/bundled/core/iac-design-principles.md +97 -0
- package/bundled/core/incident-response.md +119 -0
- package/bundled/core/license-compliance.md +2 -0
- package/bundled/core/logging-standards.md +78 -2
- package/bundled/core/mock-boundary.md +54 -2
- package/bundled/core/model-provenance.md +181 -0
- package/bundled/core/model-selection.md +27 -2
- package/bundled/core/packaging-standards.md +1 -0
- package/bundled/core/performance-standards.md +96 -2
- package/bundled/core/pii-classification.md +148 -0
- package/bundled/core/pipeline-security-gates.md +22 -2
- package/bundled/core/postmortem-standards.md +2 -0
- package/bundled/core/prd-standards.md +91 -0
- package/bundled/core/privacy-standards.md +14 -3
- package/bundled/core/product-metrics-standards.md +100 -0
- package/bundled/core/project-context-memory.md +8 -2
- package/bundled/core/prompt-regression.md +1 -1
- package/bundled/core/refactoring-standards.md +44 -3
- package/bundled/core/replay-test.md +1 -1
- package/bundled/core/resource-cost-boundary.md +180 -0
- package/bundled/core/reverse-engineering-standards.md +66 -2
- package/bundled/core/runbook.md +113 -0
- package/bundled/core/schema-evolution.md +105 -0
- package/bundled/core/secret-management-standards.md +110 -0
- package/bundled/core/security-testing.md +26 -2
- package/bundled/core/self-review-protocol.md +2 -2
- package/bundled/core/skill-standard-alignment-check.md +53 -0
- package/bundled/core/slo-sli.md +109 -0
- package/bundled/core/smoke-test.md +1 -1
- package/bundled/core/tech-debt-standards.md +1 -1
- package/bundled/core/test-data-standards.md +2 -2
- package/bundled/core/user-journey-testing.md +102 -0
- package/bundled/core/user-story-mapping.md +96 -0
- package/bundled/core/verification-oracle.md +167 -0
- package/bundled/core/versioning.md +133 -109
- package/bundled/locales/COVERAGE.md +84 -73
- package/bundled/locales/zh-CN/CHANGELOG.md +71 -6
- package/bundled/locales/zh-CN/CLAUDE.md +1 -1
- package/bundled/locales/zh-CN/README.md +22 -9
- package/bundled/locales/zh-CN/SECURITY.md +1 -1
- package/bundled/locales/zh-CN/adoption/DAILY-WORKFLOW-GUIDE.md +2 -2
- package/bundled/locales/zh-CN/core/acceptance-criteria-traceability.md +4 -6
- package/bundled/locales/zh-CN/core/accessibility-standards.md +1 -1
- package/bundled/locales/zh-CN/core/adversarial-test.md +226 -0
- package/bundled/locales/zh-CN/core/agent-behavior-discipline.md +187 -0
- package/bundled/locales/zh-CN/core/ai-response-navigation.md +32 -6
- package/bundled/locales/zh-CN/core/anti-sycophancy-prompting.md +1 -1
- package/bundled/locales/zh-CN/core/api-design-standards.md +1 -1
- package/bundled/locales/zh-CN/core/behavior-snapshot.md +335 -0
- package/bundled/locales/zh-CN/core/browser-compatibility-standards.md +229 -0
- package/bundled/locales/zh-CN/core/cd-deployment-strategies.md +135 -0
- package/bundled/locales/zh-CN/core/chaos-injection-tests.md +130 -0
- package/bundled/locales/zh-CN/core/checkin-standards.md +1 -1
- package/bundled/locales/zh-CN/core/code-review-checklist.md +1 -1
- package/bundled/locales/zh-CN/core/container-security.md +535 -0
- package/bundled/locales/zh-CN/core/context-aware-loading.md +1 -1
- package/bundled/locales/zh-CN/core/contract-testing-standards.md +191 -0
- package/bundled/locales/zh-CN/core/cost-budget-test.md +86 -0
- package/bundled/locales/zh-CN/core/cross-flow-regression.md +199 -0
- package/bundled/locales/zh-CN/core/data-migration-testing.md +217 -0
- package/bundled/locales/zh-CN/core/deployment-standards.md +328 -9
- package/bundled/locales/zh-CN/core/deprecation-standards.md +1 -1
- package/bundled/locales/zh-CN/core/developer-memory.md +2 -2
- package/bundled/locales/zh-CN/core/disaster-recovery-drill.md +87 -0
- package/bundled/locales/zh-CN/core/documentation-structure.md +1 -1
- package/bundled/locales/zh-CN/core/documentation-writing-standards.md +1 -1
- package/bundled/locales/zh-CN/core/error-code-standards.md +2 -2
- package/bundled/locales/zh-CN/core/feature-manifest-standard.md +222 -0
- package/bundled/locales/zh-CN/core/flaky-test-management.md +87 -0
- package/bundled/locales/zh-CN/core/flow-based-testing.md +284 -0
- package/bundled/locales/zh-CN/core/forward-derivation-standards.md +3 -4
- package/bundled/locales/zh-CN/core/full-coverage-testing.md +197 -0
- package/bundled/locales/zh-CN/core/git-worktree.md +1 -1
- package/bundled/locales/zh-CN/core/governance-layer.md +160 -0
- package/bundled/locales/zh-CN/core/guides/performance-guide.md +515 -0
- package/bundled/locales/zh-CN/core/guides/security-guide.md +494 -0
- package/bundled/locales/zh-CN/core/knowledge-graph-memory.md +128 -0
- package/bundled/locales/zh-CN/core/license-compliance.md +129 -0
- package/bundled/locales/zh-CN/core/llm-output-validation.md +192 -0
- package/bundled/locales/zh-CN/core/logging-standards.md +130 -8
- package/bundled/locales/zh-CN/core/mock-boundary.md +109 -0
- package/bundled/locales/zh-CN/core/model-selection.md +28 -5
- package/bundled/locales/zh-CN/core/mutation-testing.md +106 -0
- package/bundled/locales/zh-CN/core/no-cicd-deployment.md +219 -0
- package/bundled/locales/zh-CN/core/packaging-standards.md +76 -5
- package/bundled/locales/zh-CN/core/pipeline-security-gates.md +126 -0
- package/bundled/locales/zh-CN/core/policy-as-code-testing.md +203 -0
- package/bundled/locales/zh-CN/core/privacy-standards.md +1 -1
- package/bundled/locales/zh-CN/core/project-context-memory.md +1 -1
- package/bundled/locales/zh-CN/core/prompt-regression.md +88 -0
- package/bundled/locales/zh-CN/core/property-based-testing.md +87 -0
- package/bundled/locales/zh-CN/core/release-quality-manifest.md +207 -0
- package/bundled/locales/zh-CN/core/release-readiness-gate.md +193 -0
- package/bundled/locales/zh-CN/core/replay-test.md +102 -0
- package/bundled/locales/zh-CN/core/reverse-engineering-standards.md +46 -1
- package/bundled/locales/zh-CN/core/rollback-standards.md +120 -0
- package/bundled/locales/zh-CN/core/sast-advanced.md +309 -0
- package/bundled/locales/zh-CN/core/secure-op.md +328 -0
- package/bundled/locales/zh-CN/core/security-testing.md +96 -0
- package/bundled/locales/zh-CN/core/self-review-protocol.md +167 -0
- package/bundled/locales/zh-CN/core/server-ops-security.md +507 -0
- package/bundled/locales/zh-CN/core/smoke-test.md +79 -0
- package/bundled/locales/zh-CN/core/spec-driven-development.md +39 -3
- package/bundled/locales/zh-CN/core/supply-chain-attestation.md +131 -0
- package/bundled/locales/zh-CN/core/versioning.md +1 -1
- package/bundled/locales/zh-CN/docs/CHEATSHEET.md +31 -6
- package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +61 -34
- package/bundled/locales/zh-CN/docs/MIGRATION-v6.md +88 -0
- package/bundled/locales/zh-CN/docs/USAGE-MODES-COMPARISON.md +2 -2
- package/bundled/locales/zh-CN/docs/USER-MANUAL.md +14 -14
- package/bundled/locales/zh-CN/docs/specs/system/memory-adoption-strategy.md +105 -0
- package/bundled/locales/zh-CN/docs/user/FAQ.md +132 -0
- package/bundled/locales/zh-CN/docs/user/GETTING-STARTED.md +144 -0
- package/bundled/locales/zh-CN/docs/user/GLOSSARY.md +178 -0
- package/bundled/locales/zh-CN/docs/user/README.md +70 -0
- package/bundled/locales/zh-CN/docs/user/TROUBLESHOOTING.md +190 -0
- package/bundled/locales/zh-CN/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +1 -1
- package/bundled/locales/zh-CN/integrations/github-copilot/README.md +1 -1
- package/bundled/locales/zh-CN/integrations/github-copilot/skills-mapping.md +3 -3
- package/bundled/locales/zh-CN/integrations/opencode/skills-mapping.md +3 -3
- package/bundled/locales/zh-CN/methodologies/guides/sdd-guide.md +836 -0
- package/bundled/locales/zh-CN/options/changelog/auto-generated.md +166 -0
- package/bundled/locales/zh-CN/options/changelog/keep-a-changelog.md +140 -0
- package/bundled/locales/zh-CN/options/code-review/automated-review.md +214 -0
- package/bundled/locales/zh-CN/options/code-review/pair-programming.md +166 -0
- package/bundled/locales/zh-CN/options/code-review/pr-review.md +167 -0
- package/bundled/locales/zh-CN/options/documentation/api-docs.md +191 -0
- package/bundled/locales/zh-CN/options/documentation/markdown-docs.md +150 -0
- package/bundled/locales/zh-CN/options/documentation/wiki-style.md +131 -0
- package/bundled/locales/zh-CN/options/project-structure/kotlin.md +144 -0
- package/bundled/locales/zh-CN/options/project-structure/php.md +168 -0
- package/bundled/locales/zh-CN/options/project-structure/ruby.md +156 -0
- package/bundled/locales/zh-CN/options/project-structure/rust.md +136 -0
- package/bundled/locales/zh-CN/options/project-structure/swift.md +165 -0
- package/bundled/locales/zh-CN/options/testing/contract-testing.md +237 -0
- package/bundled/locales/zh-CN/options/testing/industry-pyramid.md +200 -0
- package/bundled/locales/zh-CN/options/testing/istqb-framework.md +144 -0
- package/bundled/locales/zh-CN/options/testing/performance-testing.md +251 -0
- package/bundled/locales/zh-CN/options/testing/security-testing.md +192 -0
- package/bundled/locales/zh-CN/skills/README.md +89 -126
- package/bundled/locales/zh-CN/skills/ac-coverage/SKILL.md +5 -7
- package/bundled/locales/zh-CN/skills/adr-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/agents/code-architect.md +263 -0
- package/bundled/locales/zh-CN/skills/agents/doc-writer.md +410 -0
- package/bundled/locales/zh-CN/skills/agents/reviewer.md +357 -0
- package/bundled/locales/zh-CN/skills/agents/spec-analyst.md +410 -0
- package/bundled/locales/zh-CN/skills/agents/test-specialist.md +368 -0
- package/bundled/locales/zh-CN/skills/ai-collaboration-standards/SKILL.md +2 -2
- package/bundled/locales/zh-CN/skills/ai-friendly-architecture/SKILL.md +2 -2
- package/bundled/locales/zh-CN/skills/ai-instruction-standards/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/atdd-assistant/acceptance-criteria-guide.md +1 -1
- package/bundled/locales/zh-CN/skills/atdd-assistant/atdd-workflow.md +3 -4
- package/bundled/locales/zh-CN/skills/audit-assistant/SKILL.md +2 -2
- package/bundled/locales/zh-CN/skills/bdd-assistant/guide.md +1 -2
- package/bundled/locales/zh-CN/skills/brainstorm-assistant/SKILL.md +109 -13
- package/bundled/locales/zh-CN/skills/brainstorm-assistant/guide.md +30 -8
- package/bundled/locales/zh-CN/skills/checkin-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/ci-cd-assistant/SKILL.md +50 -0
- package/bundled/locales/zh-CN/skills/code-review-assistant/SKILL.md +5 -5
- package/bundled/locales/zh-CN/skills/commands/ac-coverage.md +1 -1
- package/bundled/locales/zh-CN/skills/commands/atdd.md +3 -3
- package/bundled/locales/zh-CN/skills/commands/bdd.md +2 -2
- package/bundled/locales/zh-CN/skills/commands/brainstorm.md +26 -17
- package/bundled/locales/zh-CN/skills/commands/{review.md → code-review.md} +4 -4
- package/bundled/locales/zh-CN/skills/commands/derive-all.md +1 -1
- package/bundled/locales/zh-CN/skills/commands/derive-atdd.md +1 -1
- package/bundled/locales/zh-CN/skills/commands/derive-bdd.md +2 -3
- package/bundled/locales/zh-CN/skills/commands/derive-tdd.md +1 -1
- package/bundled/locales/zh-CN/skills/commands/derive.md +1 -1
- package/bundled/locales/zh-CN/skills/commands/dev-workflow.md +2 -2
- package/bundled/locales/zh-CN/skills/commands/methodology.md +4 -4
- package/bundled/locales/zh-CN/skills/commands/pr.md +1 -1
- package/bundled/locales/zh-CN/skills/commands/tdd.md +1 -1
- package/bundled/locales/zh-CN/skills/commit-standards/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/contract-test-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/dev-methodology/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/dev-methodology/create-methodology.md +456 -0
- package/bundled/locales/zh-CN/skills/dev-methodology/guide.md +6 -6
- package/bundled/locales/zh-CN/skills/dev-methodology/runtime.md +296 -0
- package/bundled/locales/zh-CN/skills/dev-workflow-guide/SKILL.md +5 -5
- package/bundled/locales/zh-CN/skills/docs-generator/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/e2e-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/incident-response-assistant/SKILL.md +2 -2
- package/bundled/locales/zh-CN/skills/journey-test-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/logging-guide/SKILL.md +146 -142
- package/bundled/locales/zh-CN/skills/migration-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/observability-assistant/guide.md +1 -1
- package/bundled/locales/zh-CN/skills/pr-automation-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/project-discovery/guide.md +2 -2
- package/bundled/locales/zh-CN/skills/reverse-engineer/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/runbook-assistant/guide.md +1 -1
- package/bundled/locales/zh-CN/skills/security-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/skill-builder/SKILL.md +3 -3
- package/bundled/locales/zh-CN/skills/slo-assistant/guide.md +1 -1
- package/bundled/locales/zh-CN/skills/spec-derivation/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/spec-derivation/guide.md +8 -9
- package/bundled/locales/zh-CN/skills/spec-driven-dev/SKILL.md +2 -2
- package/bundled/locales/zh-CN/skills/sweep/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/tdd-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-CN/skills/testing-guide/SKILL.md +2 -2
- package/bundled/locales/zh-CN/skills/testing-guide/testing-theory.md +2298 -0
- package/bundled/locales/zh-CN/skills/workflows/README.md +451 -0
- package/bundled/locales/zh-TW/CHANGELOG.md +71 -6
- package/bundled/locales/zh-TW/CLAUDE.md +1 -1
- package/bundled/locales/zh-TW/MAINTENANCE.md +25 -2
- package/bundled/locales/zh-TW/README.md +22 -9
- package/bundled/locales/zh-TW/SECURITY.md +1 -1
- package/bundled/locales/zh-TW/adoption/DAILY-WORKFLOW-GUIDE.md +2 -2
- package/bundled/locales/zh-TW/ai/standards/versioning.ai.yaml +8 -48
- package/bundled/locales/zh-TW/core/acceptance-criteria-traceability.md +4 -6
- package/bundled/locales/zh-TW/core/accessibility-standards.md +1 -1
- package/bundled/locales/zh-TW/core/adversarial-test.md +226 -0
- package/bundled/locales/zh-TW/core/agent-behavior-discipline.md +187 -0
- package/bundled/locales/zh-TW/core/ai-response-navigation.md +32 -6
- package/bundled/locales/zh-TW/core/anti-sycophancy-prompting.md +1 -1
- package/bundled/locales/zh-TW/core/api-design-standards.md +91 -9
- package/bundled/locales/zh-TW/core/audit-trail.md +110 -0
- package/bundled/locales/zh-TW/core/behavior-snapshot.md +335 -0
- package/bundled/locales/zh-TW/core/browser-compatibility-standards.md +1 -0
- package/bundled/locales/zh-TW/core/cd-deployment-strategies.md +135 -0
- package/bundled/locales/zh-TW/core/chaos-injection-tests.md +130 -0
- package/bundled/locales/zh-TW/core/checkin-standards.md +1 -1
- package/bundled/locales/zh-TW/core/code-review-checklist.md +1 -1
- package/bundled/locales/zh-TW/core/container-image-standards.md +93 -0
- package/bundled/locales/zh-TW/core/container-security.md +535 -0
- package/bundled/locales/zh-TW/core/cost-budget-test.md +86 -0
- package/bundled/locales/zh-TW/core/cross-flow-regression.md +1 -0
- package/bundled/locales/zh-TW/core/data-contract.md +101 -0
- package/bundled/locales/zh-TW/core/data-migration-testing.md +217 -0
- package/bundled/locales/zh-TW/core/data-pipeline.md +105 -0
- package/bundled/locales/zh-TW/core/deployment-standards.md +363 -25
- package/bundled/locales/zh-TW/core/deprecation-standards.md +17 -4
- package/bundled/locales/zh-TW/core/developer-memory.md +2 -2
- package/bundled/locales/zh-TW/core/disaster-recovery-drill.md +87 -0
- package/bundled/locales/zh-TW/core/documentation-writing-standards.md +1 -1
- package/bundled/locales/zh-TW/core/error-code-standards.md +2 -2
- package/bundled/locales/zh-TW/core/feature-manifest-standard.md +222 -0
- package/bundled/locales/zh-TW/core/flaky-test-management.md +87 -0
- package/bundled/locales/zh-TW/core/flow-based-testing.md +284 -0
- package/bundled/locales/zh-TW/core/forward-derivation-standards.md +3 -4
- package/bundled/locales/zh-TW/core/full-coverage-testing.md +250 -0
- package/bundled/locales/zh-TW/core/git-worktree.md +1 -1
- package/bundled/locales/zh-TW/core/guides/performance-guide.md +515 -0
- package/bundled/locales/zh-TW/core/guides/security-guide.md +494 -0
- package/bundled/locales/zh-TW/core/iac-design-principles.md +90 -0
- package/bundled/locales/zh-TW/core/incident-response.md +111 -0
- package/bundled/locales/zh-TW/core/license-compliance.md +129 -0
- package/bundled/locales/zh-TW/core/llm-output-validation.md +192 -0
- package/bundled/locales/zh-TW/core/logging-standards.md +208 -4
- package/bundled/locales/zh-TW/core/mock-boundary.md +161 -0
- package/bundled/locales/zh-TW/core/model-provenance.md +173 -0
- package/bundled/locales/zh-TW/core/model-selection.md +28 -5
- package/bundled/locales/zh-TW/core/mutation-testing.md +106 -0
- package/bundled/locales/zh-TW/core/no-cicd-deployment.md +219 -0
- package/bundled/locales/zh-TW/core/packaging-standards.md +76 -5
- package/bundled/locales/zh-TW/core/performance-standards.md +84 -5
- package/bundled/locales/zh-TW/core/pii-classification.md +102 -0
- package/bundled/locales/zh-TW/core/pipeline-security-gates.md +126 -0
- package/bundled/locales/zh-TW/core/policy-as-code-testing.md +203 -0
- package/bundled/locales/zh-TW/core/prd-standards.md +88 -0
- package/bundled/locales/zh-TW/core/privacy-standards.md +1 -1
- package/bundled/locales/zh-TW/core/product-metrics-standards.md +96 -0
- package/bundled/locales/zh-TW/core/project-context-memory.md +1 -1
- package/bundled/locales/zh-TW/core/prompt-regression.md +88 -0
- package/bundled/locales/zh-TW/core/property-based-testing.md +87 -0
- package/bundled/locales/zh-TW/core/refactoring-standards.md +43 -6
- package/bundled/locales/zh-TW/core/release-quality-manifest.md +207 -0
- package/bundled/locales/zh-TW/core/replay-test.md +102 -0
- package/bundled/locales/zh-TW/core/resource-cost-boundary.md +175 -0
- package/bundled/locales/zh-TW/core/reverse-engineering-standards.md +64 -5
- package/bundled/locales/zh-TW/core/rollback-standards.md +120 -0
- package/bundled/locales/zh-TW/core/runbook.md +110 -0
- package/bundled/locales/zh-TW/core/sast-advanced.md +309 -0
- package/bundled/locales/zh-TW/core/schema-evolution.md +98 -0
- package/bundled/locales/zh-TW/core/secret-management-standards.md +101 -0
- package/bundled/locales/zh-TW/core/secure-op.md +328 -0
- package/bundled/locales/zh-TW/core/security-testing.md +96 -0
- package/bundled/locales/zh-TW/core/self-review-protocol.md +2 -2
- package/bundled/locales/zh-TW/core/server-ops-security.md +507 -0
- package/bundled/locales/zh-TW/core/slo-sli.md +108 -0
- package/bundled/locales/zh-TW/core/smoke-test.md +79 -0
- package/bundled/locales/zh-TW/core/spec-driven-development.md +19 -11
- package/bundled/locales/zh-TW/core/supply-chain-attestation.md +131 -0
- package/bundled/locales/zh-TW/core/user-journey-testing.md +111 -0
- package/bundled/locales/zh-TW/core/user-story-mapping.md +94 -0
- package/bundled/locales/zh-TW/core/verification-oracle.md +159 -0
- package/bundled/locales/zh-TW/core/versioning.md +112 -112
- package/bundled/locales/zh-TW/docs/CHEATSHEET.md +31 -6
- package/bundled/locales/zh-TW/docs/DEV-WORKFLOW-MAPPING.md +6 -6
- package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +61 -34
- package/bundled/locales/zh-TW/docs/MIGRATION-v6.md +88 -0
- package/bundled/locales/zh-TW/docs/USAGE-MODES-COMPARISON.md +2 -2
- package/bundled/locales/zh-TW/docs/USER-MANUAL.md +14 -14
- package/bundled/locales/zh-TW/docs/specs/system/memory-adoption-strategy.md +105 -0
- package/bundled/locales/zh-TW/docs/user/FAQ.md +132 -0
- package/bundled/locales/zh-TW/docs/user/GETTING-STARTED.md +144 -0
- package/bundled/locales/zh-TW/docs/user/GLOSSARY.md +178 -0
- package/bundled/locales/zh-TW/docs/user/README.md +70 -0
- package/bundled/locales/zh-TW/docs/user/TROUBLESHOOTING.md +190 -0
- package/bundled/locales/zh-TW/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +1 -1
- package/bundled/locales/zh-TW/integrations/github-copilot/README.md +1 -1
- package/bundled/locales/zh-TW/integrations/github-copilot/skills-mapping.md +3 -3
- package/bundled/locales/zh-TW/integrations/opencode/skills-mapping.md +3 -3
- package/bundled/locales/zh-TW/methodologies/guides/sdd-guide.md +523 -26
- package/bundled/locales/zh-TW/options/changelog/auto-generated.md +166 -0
- package/bundled/locales/zh-TW/options/changelog/keep-a-changelog.md +140 -0
- package/bundled/locales/zh-TW/options/code-review/automated-review.md +214 -0
- package/bundled/locales/zh-TW/options/code-review/pair-programming.md +166 -0
- package/bundled/locales/zh-TW/options/code-review/pr-review.md +167 -0
- package/bundled/locales/zh-TW/options/documentation/api-docs.md +191 -0
- package/bundled/locales/zh-TW/options/documentation/markdown-docs.md +150 -0
- package/bundled/locales/zh-TW/options/documentation/wiki-style.md +131 -0
- package/bundled/locales/zh-TW/options/project-structure/kotlin.md +144 -0
- package/bundled/locales/zh-TW/options/project-structure/php.md +168 -0
- package/bundled/locales/zh-TW/options/project-structure/ruby.md +156 -0
- package/bundled/locales/zh-TW/options/project-structure/rust.md +136 -0
- package/bundled/locales/zh-TW/options/project-structure/swift.md +165 -0
- package/bundled/locales/zh-TW/options/testing/contract-testing.md +237 -0
- package/bundled/locales/zh-TW/options/testing/industry-pyramid.md +200 -0
- package/bundled/locales/zh-TW/options/testing/istqb-framework.md +144 -0
- package/bundled/locales/zh-TW/options/testing/performance-testing.md +251 -0
- package/bundled/locales/zh-TW/options/testing/security-testing.md +192 -0
- package/bundled/locales/zh-TW/skills/README.md +91 -128
- package/bundled/locales/zh-TW/skills/ac-coverage/SKILL.md +4 -6
- package/bundled/locales/zh-TW/skills/adr-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/agents/code-architect.md +263 -0
- package/bundled/locales/zh-TW/skills/agents/doc-writer.md +410 -0
- package/bundled/locales/zh-TW/skills/agents/reviewer.md +357 -0
- package/bundled/locales/zh-TW/skills/agents/spec-analyst.md +410 -0
- package/bundled/locales/zh-TW/skills/agents/test-specialist.md +368 -0
- package/bundled/locales/zh-TW/skills/ai-collaboration-standards/SKILL.md +2 -2
- package/bundled/locales/zh-TW/skills/ai-friendly-architecture/SKILL.md +2 -2
- package/bundled/locales/zh-TW/skills/ai-instruction-standards/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/atdd-assistant/SKILL.md +2 -0
- package/bundled/locales/zh-TW/skills/atdd-assistant/acceptance-criteria-guide.md +1 -1
- package/bundled/locales/zh-TW/skills/atdd-assistant/atdd-workflow.md +3 -4
- package/bundled/locales/zh-TW/skills/audit-assistant/SKILL.md +2 -2
- package/bundled/locales/zh-TW/skills/bdd-assistant/SKILL.md +2 -0
- package/bundled/locales/zh-TW/skills/bdd-assistant/guide.md +1 -2
- package/bundled/locales/zh-TW/skills/brainstorm-assistant/SKILL.md +110 -14
- package/bundled/locales/zh-TW/skills/brainstorm-assistant/guide.md +31 -7
- package/bundled/locales/zh-TW/skills/checkin-assistant/SKILL.md +3 -1
- package/bundled/locales/zh-TW/skills/ci-cd-assistant/SKILL.md +50 -0
- package/bundled/locales/zh-TW/skills/code-review-assistant/SKILL.md +7 -5
- package/bundled/locales/zh-TW/skills/commands/ac-coverage.md +1 -1
- package/bundled/locales/zh-TW/skills/commands/atdd.md +3 -3
- package/bundled/locales/zh-TW/skills/commands/bdd.md +2 -2
- package/bundled/locales/zh-TW/skills/commands/brainstorm.md +26 -17
- package/bundled/locales/zh-TW/skills/commands/{review.md → code-review.md} +5 -5
- package/bundled/locales/zh-TW/skills/commands/derive-all.md +1 -1
- package/bundled/locales/zh-TW/skills/commands/derive-atdd.md +1 -1
- package/bundled/locales/zh-TW/skills/commands/derive-bdd.md +2 -3
- package/bundled/locales/zh-TW/skills/commands/derive-tdd.md +1 -1
- package/bundled/locales/zh-TW/skills/commands/derive.md +1 -1
- package/bundled/locales/zh-TW/skills/commands/dev-workflow.md +2 -2
- package/bundled/locales/zh-TW/skills/commands/methodology.md +4 -4
- package/bundled/locales/zh-TW/skills/commands/pr.md +1 -1
- package/bundled/locales/zh-TW/skills/commands/tdd.md +1 -1
- package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/contract-test-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/dev-methodology/create-methodology.md +456 -0
- package/bundled/locales/zh-TW/skills/dev-methodology/guide.md +5 -5
- package/bundled/locales/zh-TW/skills/dev-methodology/runtime.md +296 -0
- package/bundled/locales/zh-TW/skills/dev-workflow-guide/SKILL.md +5 -5
- package/bundled/locales/zh-TW/skills/docs-generator/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/e2e-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/incident-response-assistant/SKILL.md +2 -2
- package/bundled/locales/zh-TW/skills/logging-guide/SKILL.md +29 -27
- package/bundled/locales/zh-TW/skills/migration-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/pr-automation-assistant/SKILL.md +3 -1
- package/bundled/locales/zh-TW/skills/project-discovery/guide.md +2 -2
- package/bundled/locales/zh-TW/skills/reverse-engineer/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/security-assistant/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/spec-derivation/guide.md +7 -8
- package/bundled/locales/zh-TW/skills/spec-driven-dev/SKILL.md +2 -2
- package/bundled/locales/zh-TW/skills/sweep/SKILL.md +1 -1
- package/bundled/locales/zh-TW/skills/tdd-assistant/SKILL.md +3 -1
- package/bundled/locales/zh-TW/skills/testing-guide/SKILL.md +2 -2
- package/bundled/locales/zh-TW/skills/testing-guide/testing-theory.md +2298 -0
- package/bundled/locales/zh-TW/skills/workflows/README.md +451 -0
- package/bundled/skills/README.md +1 -1
- package/bundled/skills/ac-coverage/SKILL.md +17 -7
- package/bundled/skills/adr-assistant/SKILL.md +1 -1
- package/bundled/skills/agents/code-architect.md +1 -1
- package/bundled/skills/agents/doc-writer.md +1 -1
- package/bundled/skills/agents/reviewer.md +2 -2
- package/bundled/skills/agents/spec-analyst.md +1 -1
- package/bundled/skills/agents/test-specialist.md +1 -1
- package/bundled/skills/ai-collaboration-standards/SKILL.md +2 -2
- package/bundled/skills/ai-friendly-architecture/SKILL.md +2 -2
- package/bundled/skills/ai-instruction-standards/SKILL.md +1 -1
- package/bundled/skills/atdd-assistant/SKILL.md +7 -0
- package/bundled/skills/atdd-assistant/acceptance-criteria-guide.md +1 -1
- package/bundled/skills/atdd-assistant/atdd-workflow.md +6 -8
- package/bundled/skills/audit-assistant/SKILL.md +2 -2
- package/bundled/skills/bdd-assistant/SKILL.md +7 -0
- package/bundled/skills/bdd-assistant/guide.md +1 -2
- package/bundled/skills/brainstorm-assistant/SKILL.md +133 -11
- package/bundled/skills/brainstorm-assistant/guide.md +33 -5
- package/bundled/skills/checkin-assistant/SKILL.md +8 -1
- package/bundled/skills/ci-cd-assistant/SKILL.md +57 -0
- package/bundled/skills/code-review-assistant/SKILL.md +15 -8
- package/bundled/skills/commands/COMMAND-FAMILY-OVERVIEW.md +2 -2
- package/bundled/skills/commands/COMMAND-INDEX.json +3 -3
- package/bundled/skills/commands/README.md +2 -2
- package/bundled/skills/commands/ac-coverage.md +1 -1
- package/bundled/skills/commands/atdd.md +2 -2
- package/bundled/skills/commands/bdd.md +2 -2
- package/bundled/skills/commands/brainstorm.md +25 -14
- package/bundled/skills/commands/{review.md → code-review.md} +6 -6
- package/bundled/skills/commands/derive-all.md +1 -1
- package/bundled/skills/commands/derive-atdd.md +1 -1
- package/bundled/skills/commands/derive-bdd.md +2 -3
- package/bundled/skills/commands/derive-tdd.md +1 -1
- package/bundled/skills/commands/derive.md +1 -1
- package/bundled/skills/commands/dev-workflow.md +1 -1
- package/bundled/skills/commands/journey-test.md +45 -0
- package/bundled/skills/commands/methodology.md +4 -4
- package/bundled/skills/commands/pr.md +1 -1
- package/bundled/skills/commands/skill-builder.md +42 -0
- package/bundled/skills/commands/tdd.md +1 -1
- package/bundled/skills/dev-methodology/create-methodology.md +1 -1
- package/bundled/skills/dev-methodology/guide.md +1 -1
- package/bundled/skills/dev-methodology/runtime.md +1 -1
- package/bundled/skills/dev-workflow-guide/SKILL.md +3 -3
- package/bundled/skills/dev-workflow-guide/workflow-phases.md +3 -3
- package/bundled/skills/docs-generator/SKILL.md +3 -3
- package/bundled/skills/incident-response-assistant/SKILL.md +2 -2
- package/bundled/skills/logging-guide/SKILL.md +38 -2
- package/bundled/skills/migration-assistant/SKILL.md +226 -0
- package/bundled/skills/observability-assistant/SKILL.md +74 -0
- package/bundled/skills/pr-automation-assistant/SKILL.md +5 -1
- package/bundled/skills/project-discovery/guide.md +2 -2
- package/bundled/skills/push/SKILL.md +1 -1
- package/bundled/skills/release-standards/SKILL.md +19 -5
- package/bundled/skills/security-assistant/SKILL.md +1 -1
- package/bundled/skills/skill-builder/SKILL.md +1 -1
- package/bundled/skills/spec-derivation/guide.md +3 -4
- package/bundled/skills/spec-driven-dev/SKILL.md +2 -2
- package/bundled/skills/sweep/SKILL.md +1 -1
- package/bundled/skills/tdd-assistant/SKILL.md +8 -1
- package/bundled/skills/testing-guide/SKILL.md +1 -1
- package/bundled/skills/testing-guide/testing-theory.md +1 -1
- package/bundled/skills/workflows/README.md +2 -2
- package/package.json +3 -3
- package/src/commands/audit.js +30 -9
- package/src/commands/config.js +33 -2
- package/src/commands/hitl.js +14 -1
- package/src/commands/init.js +110 -58
- package/src/commands/quickstart.js +1 -2
- package/src/commands/release.js +51 -6
- package/src/commands/run-intent.js +9 -0
- package/src/commands/spec-split.js +27 -2
- package/src/commands/update.js +22 -6
- package/src/config/ai-agent-paths.js +3 -1
- package/src/i18n/messages.js +3 -102
- package/src/missions/MissionManager.js +44 -12
- package/src/utils/build-manifest.js +35 -3
- package/src/utils/friction-detector.js +71 -22
- package/src/utils/health-checker.js +29 -2
- package/src/utils/transaction.js +111 -0
- package/src/utils/version-promote.js +16 -0
- package/standards-registry.json +58 -146
- package/bundled/ai/standards/agent-communication-protocol.ai.yaml +0 -42
- package/bundled/ai/standards/agent-dispatch.ai.yaml +0 -42
- package/bundled/ai/standards/branch-completion.ai.yaml +0 -44
- package/bundled/ai/standards/change-batching-standards.ai.yaml +0 -44
- package/bundled/ai/standards/execution-history.ai.yaml +0 -42
- package/bundled/ai/standards/pipeline-integration-standards.ai.yaml +0 -42
- package/bundled/ai/standards/workflow-enforcement.ai.yaml +0 -44
- package/bundled/ai/standards/workflow-state-protocol.ai.yaml +0 -43
- package/src/commands/flow.js +0 -260
- package/src/commands/start.js +0 -372
- package/src/commands/sweep.js +0 -151
- package/src/commands/workflow.js +0 -681
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/contract-testing-standards.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-10
|
|
6
|
+
source_hash: b2b6acbac739
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 契约测试标准(Contract Testing Standards)
|
|
11
|
+
|
|
12
|
+
> **语言**: [English](../../../core/contract-testing-standards.md) | [繁體中文](../../zh-TW/core/contract-testing-standards.md) | 简体中文
|
|
13
|
+
|
|
14
|
+
**版本**:1.0.0
|
|
15
|
+
**最后更新**:2026-05-05
|
|
16
|
+
**适用范围**:具有 API 消费者(服务对服务、前端对后端、公开 API)的项目
|
|
17
|
+
**范围**:universal
|
|
18
|
+
**行业标准**:消费者驱动契约测试(Consumer-Driven Contract Testing, CDCT)、Pact Specification v3
|
|
19
|
+
**参考资料**:[pact.io](https://docs.pact.io/)、[Spring Cloud Contract](https://spring.io/projects/spring-cloud-contract)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 目的
|
|
24
|
+
|
|
25
|
+
契约测试(Contract testing)验证 provider(API 服务器)与其 consumer(客户端)对于确切接口 —— 请求格式、响应 schema 与状态码 —— 达成共识,且无需双方同时部署。
|
|
26
|
+
|
|
27
|
+
若缺少契约测试:
|
|
28
|
+
- Provider 的变更会在 production 中悄悄破坏 consumer
|
|
29
|
+
- 服务之间的集成测试需要完整环境
|
|
30
|
+
- API 版本决策在缺乏实际使用证据的情况下做出
|
|
31
|
+
|
|
32
|
+
本标准将消费者驱动契约测试正式化为一道**发布门禁**(`release-readiness-gate.md` 中的 Dimension 4,Tier-3)。
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 消费者驱动契约流程
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Consumer 撰写交互预期
|
|
40
|
+
↓
|
|
41
|
+
Consumer 将契约发布至 Pact Broker
|
|
42
|
+
↓
|
|
43
|
+
Provider CI 获取 consumer 契约
|
|
44
|
+
↓
|
|
45
|
+
Provider 验证自身能否满足每一笔交互
|
|
46
|
+
↓
|
|
47
|
+
Pact Broker 记录:can-i-deploy 结果
|
|
48
|
+
↓
|
|
49
|
+
发布门禁:provider 部署前所有 consumer 契约必须 GREEN
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 契约涵盖范围
|
|
55
|
+
|
|
56
|
+
一份契约涵盖:
|
|
57
|
+
|
|
58
|
+
| 元素 | 是否必须指定 | 备注 |
|
|
59
|
+
|---------|-------------|-------|
|
|
60
|
+
| 请求方法(Request method) | 是 | GET / POST / PUT / PATCH / DELETE |
|
|
61
|
+
| 请求路径(Request path) | 是 | 包含路径参数(path params) |
|
|
62
|
+
| 请求头(Request headers) | 仅必要者 | 不要过度指定可选请求头 |
|
|
63
|
+
| 请求 body schema | 是(针对写入操作) | schema 层级,而非字面值 |
|
|
64
|
+
| 响应状态(Response status) | 是 | 所有预期的状态码 |
|
|
65
|
+
| 响应 body schema | 是 | schema 层级;使用 matcher 而非字面值 |
|
|
66
|
+
| 响应头(Response headers) | 仅必要者 | 例如 `Content-Type` |
|
|
67
|
+
|
|
68
|
+
**宁可不足指定,也不要过度指定。** 只断言 consumer 实际使用到的部分。
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 向后兼容窗口
|
|
73
|
+
|
|
74
|
+
| 发布类型 | 兼容性要求 |
|
|
75
|
+
|-------------|--------------------------|
|
|
76
|
+
| Patch | 100% 向后兼容;不预期有契约变更 |
|
|
77
|
+
| Minor | N-1 consumer 契约版本仍须通过 |
|
|
78
|
+
| Major | 需要弃用期;通知 consumer;旧契约归档 |
|
|
79
|
+
|
|
80
|
+
**破坏性变更政策**:若任何活跃的 consumer 契约呈红色,provider 不得部署(MAY NOT deploy)。破坏性变更需要:
|
|
81
|
+
1. 采用仅新增(additive-only)变更的新 provider 版本
|
|
82
|
+
2. Consumer 迁移至新版本
|
|
83
|
+
3. 旧契约明确标记弃用并归档
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 发布门禁准则
|
|
88
|
+
|
|
89
|
+
| 准则 | 硬性下限 | 警告区间 |
|
|
90
|
+
|-----------|-------------|-----------|
|
|
91
|
+
| 所有活跃的 consumer 契约 | 100% 绿灯 | —(二元:全有或全无) |
|
|
92
|
+
| N-1 向后兼容 | 100% 绿灯 | — |
|
|
93
|
+
| 弃用契约清理 | 旧契约于 30 天内归档 | > 30 天 = WARN |
|
|
94
|
+
|
|
95
|
+
Pact Broker 中的 `can-i-deploy` 命令封装了这道门禁:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pact-broker can-i-deploy \
|
|
99
|
+
--pacticipant <provider-service> \
|
|
100
|
+
--version <version> \
|
|
101
|
+
--to-environment production
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
退出码(Exit code)0 = PASS;非零 = FAIL(阻断发布)。
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 实现指引
|
|
109
|
+
|
|
110
|
+
### Consumer 端
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Pact consumer test (TypeScript example)
|
|
114
|
+
const interaction = {
|
|
115
|
+
state: "user 42 exists",
|
|
116
|
+
uponReceiving: "a request for user 42",
|
|
117
|
+
withRequest: {
|
|
118
|
+
method: "GET",
|
|
119
|
+
path: "/users/42",
|
|
120
|
+
headers: { Accept: "application/json" },
|
|
121
|
+
},
|
|
122
|
+
willRespondWith: {
|
|
123
|
+
status: 200,
|
|
124
|
+
headers: { "Content-Type": "application/json" },
|
|
125
|
+
body: like({ // schema matcher, not literal
|
|
126
|
+
id: integer(),
|
|
127
|
+
name: string(),
|
|
128
|
+
email: email(),
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Provider 端
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Provider verification in CI
|
|
138
|
+
PACT_BROKER_BASE_URL=https://pact-broker.internal \
|
|
139
|
+
PACT_PROVIDER_VERSION=$GIT_SHA \
|
|
140
|
+
npm run test:pact:provider
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Pact Broker 标签
|
|
144
|
+
|
|
145
|
+
| 标签 | 意义 |
|
|
146
|
+
|-----|---------|
|
|
147
|
+
| `main` | main 分支的最新版本 |
|
|
148
|
+
| `production` | 目前部署于 production 的版本 |
|
|
149
|
+
| `<feature-branch>` | 功能分支契约(暂时性) |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 反模式
|
|
154
|
+
|
|
155
|
+
- **测试整个 API 表面** —— 只测试 consumer 实际使用的部分;过度指定会造成不必要的契约中断
|
|
156
|
+
- **字面值比对** —— 使用 schema matcher(`like()`、`eachLike()`、`integer()`)而非精确值;契约应能容忍实际数据的合理变化
|
|
157
|
+
- **跳过 provider 验证** —— 发布 consumer 契约却不进行 provider 验证,代表该契约毫无强制效力
|
|
158
|
+
- **未执行 `can-i-deploy`** —— 只检查个别契约状态并不足够;`can-i-deploy` 会评估整个部署矩阵
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 与其他标准的关系
|
|
163
|
+
|
|
164
|
+
- **`api-design-standards.md`** —— 契约测试强制执行 API 设计中所声明的向后兼容保证
|
|
165
|
+
- **`release-readiness-gate.md`** —— Dimension 4(Tier-3:当存在 API consumer 时适用)
|
|
166
|
+
- **`integration-testing.md`** —— 契约测试补足但不取代集成测试
|
|
167
|
+
- **`versioning.md`** —— 语义化版本与上述向后兼容窗口互相关联
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 另见
|
|
172
|
+
|
|
173
|
+
- [Pact 文档](https://docs.pact.io/)
|
|
174
|
+
- [Can I Deploy](https://docs.pact.io/pact_broker/can_i_deploy)
|
|
175
|
+
- [消费者驱动契约(Consumer-Driven Contracts)](https://martinfowler.com/articles/consumerDrivenContracts.html) —— Martin Fowler
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 版本历史
|
|
180
|
+
|
|
181
|
+
| 版本 | 日期 | 变更 |
|
|
182
|
+
|---------|------|---------|
|
|
183
|
+
| 1.0.0 | 2026-05-05 | 初版发布:消费者驱动契约流程、向后兼容窗口、发布门禁准则 |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 授权
|
|
188
|
+
|
|
189
|
+
本标准依 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授权发布。
|
|
190
|
+
|
|
191
|
+
**来源**:[universal-dev-standards](https://github.com/AsiaOstrich/universal-dev-standards)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/cost-budget-test.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-10
|
|
6
|
+
source_hash: 19cf2a8cd706
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 成本预算测试标准
|
|
11
|
+
|
|
12
|
+
> **Language**: [English](../../../core/cost-budget-test.md) | [繁體中文](../../zh-TW/core/cost-budget-test.md) | 简体中文
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 概述
|
|
17
|
+
|
|
18
|
+
调用 LLM API 的 AI 代理系统,若 pipeline 陷入失控循环、遭遇非预期的 token 爆炸,或预算阈值配置错误,成本可能迅速累积。成本预算测试用于验证 zone 分类器、阈值常量与 pipeline 预算保护机制在每个边界上的正确性。
|
|
19
|
+
|
|
20
|
+
## Zone 分类
|
|
21
|
+
|
|
22
|
+
大多数 AI 代理 token 预算系统将使用率比例划分为多个 zone。zone 之间的边界是差一错误(off-by-one error)风险最高的地方。
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// 使用 TOKEN_BUDGET 常量(而非魔术数字)进行 Vitest 边界测试
|
|
26
|
+
import { classifyTokenZone, TOKEN_BUDGET } from "../types/index.js"
|
|
27
|
+
import { describe, it, expect } from "vitest"
|
|
28
|
+
|
|
29
|
+
describe("TokenBudgetZone classification boundaries", () => {
|
|
30
|
+
it.each([
|
|
31
|
+
[0.0, "safe", "zero usage"],
|
|
32
|
+
[TOKEN_BUDGET.WARNING_THRESHOLD - 0.01, "safe", "just below WARNING"],
|
|
33
|
+
[TOKEN_BUDGET.WARNING_THRESHOLD, "warning", "exactly at WARNING"],
|
|
34
|
+
[TOKEN_BUDGET.DANGER_THRESHOLD - 0.01, "warning", "just below DANGER"],
|
|
35
|
+
[TOKEN_BUDGET.DANGER_THRESHOLD, "danger", "exactly at DANGER"],
|
|
36
|
+
[TOKEN_BUDGET.BLOCKING_THRESHOLD - 0.01,"danger", "just below BLOCKING"],
|
|
37
|
+
[TOKEN_BUDGET.BLOCKING_THRESHOLD, "blocking", "exactly at BLOCKING"],
|
|
38
|
+
[1.0, "blocking", "fully exhausted"],
|
|
39
|
+
])("ratio=%f → %s (%s)", (ratio, expected) => {
|
|
40
|
+
expect(classifyTokenZone(ratio)).toBe(expected)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it("returns 'blocking' for ratio > 1.0 (over-budget)", () => {
|
|
44
|
+
expect(classifyTokenZone(1.5)).toBe("blocking")
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Pipeline 预算配置测试
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import type { PipelineBudgetConfig } from "../types/index.js"
|
|
53
|
+
|
|
54
|
+
describe("PipelineBudgetConfig semantics", () => {
|
|
55
|
+
it("warningThreshold defaults should be 0-1 range", () => {
|
|
56
|
+
const config: PipelineBudgetConfig = {
|
|
57
|
+
maxCostPerRun: 1.0,
|
|
58
|
+
maxCostPerDay: 10.0,
|
|
59
|
+
warningThreshold: 0.8,
|
|
60
|
+
autoDowngrade: true,
|
|
61
|
+
}
|
|
62
|
+
expect(config.warningThreshold).toBeGreaterThan(0)
|
|
63
|
+
expect(config.warningThreshold).toBeLessThan(1)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 测试项目
|
|
69
|
+
|
|
70
|
+
| 测试类别 | 原因 |
|
|
71
|
+
|---------|------|
|
|
72
|
+
| 精确边界值(WARNING/DANGER/BLOCKING) | 差一错误容易潜藏于此 |
|
|
73
|
+
| 每个边界以下的值 | 确认低一级的 zone 正确 |
|
|
74
|
+
| 使用率为零 | 干净初始状态 |
|
|
75
|
+
| 比例 > 1.0 | 超出预算时仍应触发阻断 |
|
|
76
|
+
| 所有 TOKEN_BUDGET 常量均被引用 | 防止突变测试存活 |
|
|
77
|
+
|
|
78
|
+
## 相关标准
|
|
79
|
+
|
|
80
|
+
- [突变测试标准](../../../core/mutation-testing.md) — 未有测试覆盖的常量容易在突变测试中存活
|
|
81
|
+
- [测试标准](../../../core/testing-standards.md) — 整体测试金字塔
|
|
82
|
+
- [LLM 输出验证](../../../core/llm-output-validation.md) — 输出层预算约束
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
**Scope**: universal
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/cross-flow-regression.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-10
|
|
6
|
+
source_hash: ac618caf6d7f
|
|
7
|
+
status: stale
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 跨流程回归(Cross-Flow Regression)
|
|
11
|
+
|
|
12
|
+
> **语言**:[English](../../../core/cross-flow-regression.md) | [繁體中文](../../zh-TW/core/cross-flow-regression.md) | 简体中文
|
|
13
|
+
|
|
14
|
+
**版本**:1.0.0
|
|
15
|
+
**最后更新**:2026-05-05
|
|
16
|
+
**适用范围**:所有具有多个 user flow 或业务流程的软件项目
|
|
17
|
+
**Scope**:universal
|
|
18
|
+
**业界标准**:ISTQB Advanced Test Analyst(Regression Test Strategy)
|
|
19
|
+
**参考资料**:`core/flow-based-testing.md`、`core/testing-standards.md`
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 目的
|
|
24
|
+
|
|
25
|
+
本标准定义跨流程回归测试(cross-flow regression testing)——验证对某一个 flow 的修改不会破坏其他 flow,并确保**多个 flow 的组合**在依序执行时行为正确。
|
|
26
|
+
|
|
27
|
+
### 与 `flow-based-testing.md` 的界线
|
|
28
|
+
|
|
29
|
+
| 标准 | 范围 | 它能捕捉的问题 |
|
|
30
|
+
|----------|-------|----------------|
|
|
31
|
+
| `flow-based-testing.md`(Multi-Gate Model) | 单一 flow:Decision Points、Terminal States、Decision Table | flow 内部的分支覆盖缺口 |
|
|
32
|
+
| **本标准** | 多个 flow:交互、共享状态、依序组合 | flow 之间的污染、累积状态 bug、跨 flow 的回归 |
|
|
33
|
+
|
|
34
|
+
这两者是互补而非重叠的关系。一个项目两者都需要。
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 为何跨流程 bug 与众不同
|
|
39
|
+
|
|
40
|
+
flow 内部测试(Multi-Gate)能证明「Login」处理了全部 7 种 terminal state。但它无法检测:
|
|
41
|
+
|
|
42
|
+
- **状态污染(State contamination)**:在一次失败的「Create Order」(FAIL_QUOTA_EXCEEDED)之后,quota 计数器遭到破坏 → 即使 quota 已重置,下一次「Create Order」尝试仍然失败
|
|
43
|
+
- **共享资源冲突(Shared resource conflicts)**:「Report Generation」与「Data Export」同时执行时,破坏了共用的临时目录
|
|
44
|
+
- **依序依赖(Sequential dependency)**:「Cancel Subscription」成功,但后续的「Reactivate」flow 假设订阅仍然存在 → NullPointerException
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 跨流程测试套件定义
|
|
49
|
+
|
|
50
|
+
### Tier-1:Critical User Journeys(CUJ,关键用户旅程)
|
|
51
|
+
|
|
52
|
+
Critical User Journeys 是横跨 ≥ 2 个 flow 的端到端序列,代表核心业务价值路径。每一次 release 都必须包含一套 CUJ regression suite。
|
|
53
|
+
|
|
54
|
+
**CUJ 识别**:
|
|
55
|
+
1. 列出所有 flow(来自 requirement-template §2.4)
|
|
56
|
+
2. 找出共享状态或常被依序执行的 pair/triple(成对/三组组合)
|
|
57
|
+
3. 标记业务关键的组合(purchase、onboarding、authentication + 下游流程)
|
|
58
|
+
|
|
59
|
+
**CUJ 覆盖率要求**:
|
|
60
|
+
|
|
61
|
+
| 指标 | Tier-2 门槛(默认) | Tier-1 关键路径 |
|
|
62
|
+
|--------|--------------------------|---------------------|
|
|
63
|
+
| CUJ 通过率 | ≥ 95% | 100% |
|
|
64
|
+
| 业务关键 flow 组合 | 100% | 100% |
|
|
65
|
+
|
|
66
|
+
### Tier-2:flow 变更时的回归
|
|
67
|
+
|
|
68
|
+
当任何 flow 的 §2.4(Decision Points、Terminal States)被修改时,整套 CUJ suite 必须重新执行——而不只是执行被修改 flow 的测试。触发逻辑:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# In CI: detect flow spec changes
|
|
72
|
+
changed_flows=$(git diff origin/main... --name-only | grep -E "requirement-template|SPEC.*\.md")
|
|
73
|
+
if [ -n "$changed_flows" ]; then
|
|
74
|
+
npm run test:cross-flow-regression
|
|
75
|
+
fi
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Tier-3:并行与共享资源测试
|
|
79
|
+
|
|
80
|
+
针对具有并行用户操作的项目:
|
|
81
|
+
- 两位用户同时执行相同的 flow
|
|
82
|
+
- Flow A 与 Flow B 共用一个写入资源
|
|
83
|
+
- 长时间运行的 flow(异步)与短 flow 的结果交互
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 测试结构
|
|
88
|
+
|
|
89
|
+
跨流程回归测试采用跨 flow 的**依序状态穿引(sequential state threading)**(延伸自 `flow-based-testing.md` 的 `ctx` 模式):
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
describe("CUJ: Register → Verify Email → Create First Order", () => {
|
|
93
|
+
const ctx: {
|
|
94
|
+
userId?: string
|
|
95
|
+
token?: string
|
|
96
|
+
orderId?: string
|
|
97
|
+
} = {}
|
|
98
|
+
|
|
99
|
+
// Flow 1: Register
|
|
100
|
+
it("Flow-1 Step 1: Register new user", async () => {
|
|
101
|
+
ctx.userId = await registerUser({ email: testEmail, plan: "trial" })
|
|
102
|
+
expect(ctx.userId).toBeDefined()
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
// Flow 2: Email Verification (depends on Flow 1 output)
|
|
106
|
+
it("Flow-2 Step 1: Verify email token", async () => {
|
|
107
|
+
const token = await getEmailToken(ctx.userId!)
|
|
108
|
+
ctx.token = await verifyEmail(token)
|
|
109
|
+
expect(ctx.token).toBeDefined()
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// Flow 3: Create Order (depends on Flow 2 auth token)
|
|
113
|
+
it("Flow-3 Step 1: Create first order", async () => {
|
|
114
|
+
ctx.orderId = await createOrder(ctx.token!, orderPayload)
|
|
115
|
+
expect(ctx.orderId).toMatch(/^ord-/)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
// Cross-flow verification: order state reflects trial plan limits
|
|
119
|
+
it("Cross-flow: Trial plan quota enforced on first order", async () => {
|
|
120
|
+
const order = await getOrder(ctx.token!, ctx.orderId!)
|
|
121
|
+
expect(order.quota_applied).toBe("trial")
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 跨流程失败隔离
|
|
127
|
+
|
|
128
|
+
当一个跨流程测试失败时,失败信息必须指出是**哪一个 flow** 引入了状态破坏:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// BAD: generic assertion
|
|
132
|
+
expect(result).toBe("success")
|
|
133
|
+
|
|
134
|
+
// GOOD: includes flow context
|
|
135
|
+
expect(result).toBe("success") // Flow-3 depends on Flow-2 token being valid
|
|
136
|
+
// If this fails, check Flow-2 email verification output
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 与 Release Gate 的集成
|
|
142
|
+
|
|
143
|
+
跨流程回归是 `release-readiness-gate.md` 中的 **Dimension 6**(Tier-2)。
|
|
144
|
+
|
|
145
|
+
### 触发条件
|
|
146
|
+
|
|
147
|
+
| 触发时机 | 范围 |
|
|
148
|
+
|---------|-------|
|
|
149
|
+
| 每一个 release candidate | 整套 CUJ suite |
|
|
150
|
+
| 修改任何 flow §2.4 的 PR | 整套 CUJ suite(merge 前) |
|
|
151
|
+
| 部署至 staging 后 | CUJ 的 smoke 子集 |
|
|
152
|
+
| 部署至 production 后 | 仅关键路径 CUJ(canary) |
|
|
153
|
+
|
|
154
|
+
### Sign-off 的证据
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
| 6 | Cross-flow Regression | PASS | CUJ suite: 47/47 passed; 0 flow-interaction failures | QA Lead |
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### WARN 门槛
|
|
161
|
+
|
|
162
|
+
- CUJ 通过率 ≥ 95% 但 < 100% → WARN,并需记录具体失败的 CUJ 并完成 root-cause(根因分析)
|
|
163
|
+
- CUJ 通过率 < 95% → FAIL(release 被封锁)
|
|
164
|
+
- 业务关键组合失败 → FAIL,无论整体通过率如何
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 反模式(Anti-Patterns)
|
|
169
|
+
|
|
170
|
+
- **只在 CI 缓慢时才跑跨流程测试**——依定义,它们必须在每一个 release candidate 上执行
|
|
171
|
+
- **孤立地测试每个 flow 却称之为「regression」**——flow 的孤立测试已由 Multi-Gate 涵盖;跨流程测试必须具备 flow 之间的状态依赖关系
|
|
172
|
+
- **在不相关的 `describe` 块间复用同一个 `ctx` 对象**——每个 CUJ 都需要干净、隔离的 `ctx`;CUJ 之间的污染会掩盖 bug
|
|
173
|
+
- **失败信息中缺乏 flow 归属(attribution)**——跨流程失败难以调试;务必指出是哪个上游 flow 产生了被破坏的状态
|
|
174
|
+
- **把 CUJ 失败当成 flaky(不稳定)**——跨流程状态 bug 是确定性的;「flaky」的跨流程测试几乎都是共享状态破坏的征兆
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## 与其他标准的关系
|
|
179
|
+
|
|
180
|
+
- **`flow-based-testing.md`** —— flow 内部的 gate(跨流程的前置条件)
|
|
181
|
+
- **`testing-standards.md`** —— testing pyramid 中的 regression 层
|
|
182
|
+
- **`release-readiness-gate.md`** —— Dimension 6(Tier-2)
|
|
183
|
+
- **`e2e-testing.md`** —— CUJ 测试通常在 E2E 或 System Test 层级执行
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 版本历史
|
|
188
|
+
|
|
189
|
+
| 版本 | 日期 | 变更 |
|
|
190
|
+
|---------|------|---------|
|
|
191
|
+
| 1.0.0 | 2026-05-05 | 初版发布:CUJ 定义、依序状态穿引、release gate 标准、Tier-1/2/3 分类 |
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 授权
|
|
196
|
+
|
|
197
|
+
本标准依 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授权发布。
|
|
198
|
+
|
|
199
|
+
**来源**:[universal-dev-standards](https://github.com/AsiaOstrich/universal-dev-standards)
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/data-migration-testing.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-28
|
|
6
|
+
source_hash: 990309b5e8b1
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 数据迁移测试
|
|
11
|
+
|
|
12
|
+
> **Language**: [English](../../../core/data-migration-testing.md) | [繁體中文](../../zh-TW/core/data-migration-testing.md) | 简体中文
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 概述
|
|
17
|
+
|
|
18
|
+
数据库模式迁移(schema migration)是高风险操作:它以难以轻易恢复的方式改变持久化数据,除非存在经过测试的回滚路径。完整的迁移测试套件需验证三个维度——正确性(up 可干净应用)、安全性(down 能还原状态),以及健壮性(应用两次无害)。
|
|
19
|
+
|
|
20
|
+
## 需求摘要
|
|
21
|
+
|
|
22
|
+
| ID | 规则 | 理由 |
|
|
23
|
+
|----|------|------|
|
|
24
|
+
| REQ-DMT-001 | 每个迁移都必须有 up 测试 | 未验证的迁移会损坏生产环境模式 |
|
|
25
|
+
| REQ-DMT-002 | 每个具备 down 函数的迁移都必须有回滚测试 | 未测试的回滚在事故期间会失败 |
|
|
26
|
+
| REQ-DMT-003 | 对同一迁移应用两次不得失败 | CI 重试可能触发重复应用 |
|
|
27
|
+
| REQ-DMT-004 | 变更数据的迁移必须包含数据保存测试 | 模式正确性 ≠ 数据正确性 |
|
|
28
|
+
| REQ-DMT-005 | 每个测试必须使用隔离数据库 | 共享状态会导致非确定性失败 |
|
|
29
|
+
| REQ-DMT-006 | 跨编码或跨数据库引擎的迁移必须包含字节层编码转换测试 | 「看起来相等」会掩盖 codepoint/normalization/collation 的损坏 |
|
|
30
|
+
| REQ-DMT-007 | business-critical 数据的迁移必须包含聚合不变量测试 | 逐行抽样会错过分布层级的偏移 |
|
|
31
|
+
|
|
32
|
+
## 测试结构
|
|
33
|
+
|
|
34
|
+
### 隔离
|
|
35
|
+
|
|
36
|
+
每个迁移测试都在隔离的数据库上执行——无论是内存数据库(SQLite `:memory:`)还是全新的 Docker 容器(PostgreSQL)。绝对不要对共享的开发或预发布数据库执行迁移测试。
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// 正确:每个测试文件使用隔离的内存数据库
|
|
40
|
+
const db = new Database(':memory:')
|
|
41
|
+
await applyBaseline(db)
|
|
42
|
+
|
|
43
|
+
// 错误:测试共享一个开发数据库
|
|
44
|
+
const db = openDatabase(process.env.DATABASE_URL)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Up 测试
|
|
48
|
+
|
|
49
|
+
将迁移应用到基准模式,并断言预期的应用后状态。
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
it('adds email column to users table', async () => {
|
|
53
|
+
await migrate.up(db)
|
|
54
|
+
const columns = db.prepare("PRAGMA table_info(users)").all()
|
|
55
|
+
expect(columns.map(c => c.name)).toContain('email')
|
|
56
|
+
})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Down 测试(回滚)
|
|
60
|
+
|
|
61
|
+
先应用 up,再应用 down,并断言模式回到迁移前的状态。
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
it('rollback removes email column', async () => {
|
|
65
|
+
await migrate.up(db)
|
|
66
|
+
await migrate.down(db)
|
|
67
|
+
const columns = db.prepare("PRAGMA table_info(users)").all()
|
|
68
|
+
expect(columns.map(c => c.name)).not.toContain('email')
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 幂等性测试
|
|
73
|
+
|
|
74
|
+
应用迁移两次,第二次应用不得抛出异常。
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
it('applying migration twice is safe', async () => {
|
|
78
|
+
await migrate.up(db)
|
|
79
|
+
await expect(migrate.up(db)).resolves.not.toThrow()
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 数据保存测试
|
|
84
|
+
|
|
85
|
+
在迁移前先插入数据行,在迁移后断言数据完整性。
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
it('preserves existing user rows', async () => {
|
|
89
|
+
db.prepare("INSERT INTO users (id, name) VALUES (1, 'Alice')").run()
|
|
90
|
+
await migrate.up(db)
|
|
91
|
+
const user = db.prepare("SELECT * FROM users WHERE id = 1").get()
|
|
92
|
+
expect(user.name).toBe('Alice')
|
|
93
|
+
})
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 编码转换测试
|
|
97
|
+
|
|
98
|
+
当字符串「看起来相等」时,模式层与数据行层的测试都会通过——但底层的字节可能已被跨编码或跨引擎的搬移(UTF-8 → UTF-16/`NVARCHAR`、`VARCHAR` → `NVARCHAR`、隐含的 collation 变更)悄悄损坏。跨编码或跨数据库引擎的迁移**必须**在**字节/codepoint/normalization** 层断言相等,而非显示层。
|
|
99
|
+
|
|
100
|
+
要断言的内容:
|
|
101
|
+
|
|
102
|
+
- **字节/codepoint 等同**——迁移后的值具有相同的 Unicode codepoint(且在目标以 UTF-16 储存时,具有预期的单元数),而不只是相同的渲染字形。
|
|
103
|
+
- **Normalization 形式**——NFC vs NFD:`"é"`(U+00E9)与 `"e"+◌́`(U+0065 U+0301)渲染相同但字节序列不同;断言形式被保留(或被刻意正规化)。
|
|
104
|
+
- **多字节边界**——在来源依**字符**上限截断的值,不得在目标被依**字节**上限截断(一个 4 字节的 emoji 必须能存活于 `NVARCHAR(n)` 栏位)。
|
|
105
|
+
- **CJK/emoji/组合字**——明确测试辅助平面 codepoint(emoji、罕用 CJK)与组合序列;surrogate-pair 与 collation-folding 的缺陷就藏在这里。
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
it('preserves bytes across UTF-8 -> target encoding (no display-only equality)', async () => {
|
|
109
|
+
// 混合 BMP CJK、一个辅助平面 emoji,以及一个 NFD 组合序列
|
|
110
|
+
const samples = [
|
|
111
|
+
'繁體中文', // CJK (BMP)
|
|
112
|
+
'😀 family 👨👩👧', // emoji 含 ZWJ 序列(辅助平面)
|
|
113
|
+
'é' // NFD:'e' + 组合锐音符(渲染如 'é')
|
|
114
|
+
]
|
|
115
|
+
samples.forEach((s, i) =>
|
|
116
|
+
db.prepare('INSERT INTO notes (id, body) VALUES (?, ?)').run(i, s))
|
|
117
|
+
|
|
118
|
+
await migrate.up(db)
|
|
119
|
+
|
|
120
|
+
samples.forEach((expected, i) => {
|
|
121
|
+
const row = db.prepare('SELECT body FROM notes WHERE id = ?').get(i) as { body: string }
|
|
122
|
+
// ❌ 反模式:expect(row.body).toBe(expected) // 即使部分损坏,只要两者渲染相同就会通过
|
|
123
|
+
// ✅ 在字节与 codepoint 层断言:
|
|
124
|
+
expect(Buffer.from(row.body, 'utf8')).toEqual(Buffer.from(expected, 'utf8'))
|
|
125
|
+
expect([...row.body]).toEqual([...expected]) // 逐 codepoint 比对
|
|
126
|
+
expect(row.body.normalize('NFC')).toBe(expected.normalize('NFC')) // 明确的正规化意图
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> **反模式**:只对解码后的字符串断言 `expect(actual).toBe(expected)`。两个不同的字节/normalization 序列可解码为*看起来*相同的字形,因此显示层断言会通过,而储存的字节(以及任何下游的 `LIKE`/unique-key/collation 行为)却已损坏。
|
|
132
|
+
|
|
133
|
+
### 聚合不变量测试
|
|
134
|
+
|
|
135
|
+
数据行抽样能证明个别数据行存活;它**无法**证明*分布*存活。填充有代表性的数据集,在迁移**前**对 business-critical 栏位撷取聚合不变量,并在迁移**后**断言其不变。这与 post-cutover 生产对账所用的 oracle 相同(聚合相等跨越 cutover 边界),只是在迁移测试期就跑。
|
|
136
|
+
|
|
137
|
+
要撷取的不变量:`COUNT(*)`、`SUM(money_column)`、`COUNT(DISTINCT key)`,以及依业务维度(如 status 或 period)分组的内容 `checksum`(例如哈希总和)。
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
it('preserves aggregate invariants over financial data', async () => {
|
|
141
|
+
seedRepresentativeOrders(db) // 各种 status、金额、币别
|
|
142
|
+
|
|
143
|
+
const invariantQuery = `
|
|
144
|
+
SELECT status,
|
|
145
|
+
COUNT(*) AS cnt,
|
|
146
|
+
SUM(amount_cents) AS total_cents,
|
|
147
|
+
COUNT(DISTINCT customer_id) AS distinct_customers
|
|
148
|
+
FROM orders
|
|
149
|
+
GROUP BY status
|
|
150
|
+
ORDER BY status`
|
|
151
|
+
const before = db.prepare(invariantQuery).all()
|
|
152
|
+
|
|
153
|
+
await migrate.up(db)
|
|
154
|
+
|
|
155
|
+
const after = db.prepare(invariantQuery).all()
|
|
156
|
+
// 分布必须完全一致——而非只是「还有一些数据行存在」
|
|
157
|
+
expect(after).toEqual(before)
|
|
158
|
+
})
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> 因为聚合把整张表收敛成几个数字,一个不符的 `SUM`/`COUNT` 就能标出偏移;而逐行抽样——只检查你刚好挑到的数据行——会完全错过它。
|
|
162
|
+
|
|
163
|
+
## 跨方言迁移:SQLite → SQL Server 风险表
|
|
164
|
+
|
|
165
|
+
当迁移同时改变数据库引擎(不只模式)时,来源与目标方言在型别语义、比较与排序上会分歧。下表每一项分歧都是数据可能悄悄改变意义之处,也是上述编码与聚合测试(以及 reverse-engineering-standards.md 中非 HTTP 隐含规则扫描)的 derive 清单输入。
|
|
166
|
+
|
|
167
|
+
| 风险点 | SQLite | SQL Server | 迁移须验 |
|
|
168
|
+
|---|---|---|---|
|
|
169
|
+
| **型别系统** | 动态型别(值层 type affinity) | 静态/强型别 | 每栏宣告型别;扫描 SQLite 容忍的越界/混型别值 |
|
|
170
|
+
| **布尔** | 通常存成 `0/1` 整数 | `BIT` | `0/1` ↔ `BIT` 对映;NULL 布尔的处理 |
|
|
171
|
+
| **日期时间** | 常存为 `TEXT`/`REAL`/`INTEGER` | `datetime2`/`datetimeoffset` | 格式解析、时区处理、精度截断 |
|
|
172
|
+
| **自增主键** | `AUTOINCREMENT` | `IDENTITY` | 既有 id 连续性;正确的 seed/reseed 值 |
|
|
173
|
+
| **大小写/collation** | `LIKE` 预设大小写不敏感;`NOCASE` | 由栏位 collation 决定 | 对齐 collation;检查 unique-key 折叠冲突 |
|
|
174
|
+
| **NULL 排序** | NULL 排最前(最小) | 依设定而定 | `ORDER BY` 结果顺序不变量跨引擎 |
|
|
175
|
+
| **浮点精度** | `REAL` | `float`/`decimal` | 金额/精确值改用 `decimal` 避免舍入误差 |
|
|
176
|
+
| **字符串拼接** | `\|\|` | `+`/`CONCAT` | 改写查询;对齐 NULL 拼接语义 |
|
|
177
|
+
| **分页** | `LIMIT`/`OFFSET` | `OFFSET .. FETCH`/`TOP` | 改写 + 保证稳定排序键以取得确定性分页 |
|
|
178
|
+
|
|
179
|
+
> 每个「查询改写/语义差异」格也可能藏一条**隐含业务规则**——把本表喂入反向工程的隐含规则扫描阶段。
|
|
180
|
+
|
|
181
|
+
## 工具
|
|
182
|
+
|
|
183
|
+
### SQLite / Drizzle ORM
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import Database from 'better-sqlite3'
|
|
187
|
+
import { drizzle } from 'drizzle-orm/better-sqlite3'
|
|
188
|
+
import { migrate } from 'drizzle-orm/better-sqlite3/migrator'
|
|
189
|
+
|
|
190
|
+
const sqlite = new Database(':memory:')
|
|
191
|
+
const db = drizzle(sqlite)
|
|
192
|
+
await migrate(db, { migrationsFolder: './drizzle' })
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### PostgreSQL
|
|
196
|
+
|
|
197
|
+
使用 `testcontainers` 为每个测试套件启动一个全新的 PostgreSQL 容器。容器在套件结束后销毁,确保隔离性。
|
|
198
|
+
|
|
199
|
+
## 反模式
|
|
200
|
+
|
|
201
|
+
- **对共享数据库进行测试** — 造成跨测试污染、不可重复的构建结果
|
|
202
|
+
- **跳过 down 迁移测试** — 回滚在生产事故中失败
|
|
203
|
+
- **事后编写迁移测试且未预先填充数据** — 完全遗漏数据保存的缺陷
|
|
204
|
+
- **提交迁移却没有对应的测试** — 迁移在进入生产前完全未被测试
|
|
205
|
+
- **只对解码后的值断言字符串相等** — 即使字节、normalization 形式或 codepoint 在跨编码/跨引擎变更中已损坏,显示层相等仍会通过
|
|
206
|
+
- **仅以数据行抽样验证跨引擎迁移** — 分布层级的偏移(错误的 `SUM`/`COUNT`/`DISTINCT`)会逃过任何刚好错过受影响数据行的抽样
|
|
207
|
+
|
|
208
|
+
## 参见
|
|
209
|
+
|
|
210
|
+
- `database-standards.ai.yaml` — 模式设计原则
|
|
211
|
+
- `testing.ai.yaml` — 通用测试结构与金字塔
|
|
212
|
+
- `verification-evidence.ai.yaml` — 审计证据需求
|
|
213
|
+
- `behavior-snapshot.ai.yaml` — 同样的「别只比看起来相等」原则,作用于 oracle/序列化层,而非 DB 存储层
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
**Scope**: universal
|