universal-dev-standards 5.17.0 → 6.1.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/options/commit-message/bilingual.ai.yaml +19 -1
- 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 +3 -3
- 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/documentation-writing-standards.ai.yaml +1 -1
- 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/frontend-design-standards.ai.yaml +33 -3
- 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/push-standards.ai.yaml +14 -3
- package/bundled/ai/standards/refactoring-standards.ai.yaml +68 -3
- package/bundled/ai/standards/requirement-engineering.ai.yaml +42 -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/self-review-protocol.ai.yaml +15 -10
- 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-evidence.ai.yaml +88 -5
- 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 +10 -3
- 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 +2 -2
- package/bundled/core/error-code-standards.md +4 -3
- package/bundled/core/feature-discovery-standards.md +191 -0
- 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/frontend-design-standards.md +93 -4
- 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/multi-environment-e2e-testing.md +195 -0
- 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/push-standards.md +82 -0
- package/bundled/core/refactoring-standards.md +44 -3
- package/bundled/core/replay-test.md +1 -1
- package/bundled/core/requirement-engineering.md +2 -2
- 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 +15 -10
- 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-evidence.md +170 -10
- package/bundled/core/verification-oracle.md +167 -0
- package/bundled/core/versioning.md +133 -109
- package/bundled/locales/COVERAGE.md +94 -77
- package/bundled/locales/zh-CN/CHANGELOG.md +94 -6
- package/bundled/locales/zh-CN/CLAUDE.md +1 -1
- package/bundled/locales/zh-CN/MAINTENANCE.md +42 -661
- package/bundled/locales/zh-CN/README.md +25 -12
- package/bundled/locales/zh-CN/SECURITY.md +2 -2
- package/bundled/locales/zh-CN/adoption/DAILY-WORKFLOW-GUIDE.md +2 -2
- package/bundled/locales/zh-CN/ai/options/commit-message/bilingual.ai.yaml +6 -1
- 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 +239 -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 +200 -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/frontend-design-standards.md +1 -1
- package/bundled/locales/zh-CN/core/full-coverage-testing.md +269 -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 +131 -0
- package/bundled/locales/zh-CN/core/llm-output-validation.md +192 -0
- package/bundled/locales/zh-CN/core/logging-standards.md +205 -7
- package/bundled/locales/zh-CN/core/mock-boundary.md +161 -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 +77 -5
- package/bundled/locales/zh-CN/core/pipeline-security-gates.md +146 -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/requirement-engineering.md +1 -1
- 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 +113 -0
- package/bundled/locales/zh-CN/core/self-review-protocol.md +172 -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/verification-evidence.md +252 -41
- package/bundled/locales/zh-CN/core/versioning.md +1 -1
- package/bundled/locales/zh-CN/docs/CHEATSHEET.md +36 -7
- package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +71 -53
- 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/commit-message/bilingual.md +10 -3
- 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 +115 -17
- package/bundled/locales/zh-CN/skills/brainstorm-assistant/guide.md +37 -12
- 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 +169 -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 +94 -6
- package/bundled/locales/zh-TW/CLAUDE.md +1 -1
- package/bundled/locales/zh-TW/MAINTENANCE.md +51 -4
- package/bundled/locales/zh-TW/README.md +25 -12
- package/bundled/locales/zh-TW/SECURITY.md +2 -2
- package/bundled/locales/zh-TW/adoption/DAILY-WORKFLOW-GUIDE.md +2 -2
- package/bundled/locales/zh-TW/ai/options/commit-message/bilingual.ai.yaml +6 -1
- 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/frontend-design-standards.md +1 -1
- 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 +131 -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 +77 -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 +146 -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/requirement-engineering.md +1 -1
- 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 +113 -0
- package/bundled/locales/zh-TW/core/self-review-protocol.md +18 -13
- 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-evidence.md +260 -31
- 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 +36 -7
- package/bundled/locales/zh-TW/docs/DEV-WORKFLOW-MAPPING.md +6 -6
- package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +71 -53
- 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/commit-message/bilingual.md +10 -3
- 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 +116 -18
- package/bundled/locales/zh-TW/skills/brainstorm-assistant/guide.md +38 -11
- 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 +52 -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 +139 -15
- package/bundled/skills/brainstorm-assistant/guide.md +39 -8
- 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 +13 -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 +4 -4
- 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 +168 -75
- 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 +61 -149
- 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,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/policy-as-code-testing.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-10
|
|
6
|
+
source_hash: 80f3b5726ad3
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Policy as Code 測試標準
|
|
11
|
+
|
|
12
|
+
> **Language**: [English](../../../core/policy-as-code-testing.md) | 繁體中文
|
|
13
|
+
|
|
14
|
+
> 標準 ID:`policy-as-code-testing`
|
|
15
|
+
> 版本:v1.0.0
|
|
16
|
+
> 最後更新:2026-05-05
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 為什麼需要測試 Policy as Code?
|
|
21
|
+
|
|
22
|
+
OPA(Open Policy Agent)的 Rego policy 控制 AI Agent 能否執行生產環境操作。**未測試的 policy = 靜默的安全漏洞。**
|
|
23
|
+
|
|
24
|
+
Policy as Code 的特殊風險:
|
|
25
|
+
1. **邊界條件難以推理**:`reversible: false` + `target_env: "prod"` 組合是否觸發?
|
|
26
|
+
2. **型別錯誤只在執行時爆發**:`array.concat()` 用在 set 型別 → 靜默失效
|
|
27
|
+
3. **Fail-Open 風險**:評估失敗若回傳 `allow: true`,攻擊者可觸發未定義路徑
|
|
28
|
+
4. **Policy 改動回歸**:新增一條 rule 可能意外放行原本被擋的案例
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 一、OPA 測試框架
|
|
33
|
+
|
|
34
|
+
### 測試規則格式
|
|
35
|
+
|
|
36
|
+
```rego
|
|
37
|
+
# 檔案命名:<policy_module>_test.rego
|
|
38
|
+
# Package:<policy_package>_test
|
|
39
|
+
package governance.guardian.forbidden_patterns_test
|
|
40
|
+
|
|
41
|
+
import future.keywords.if
|
|
42
|
+
|
|
43
|
+
# 正向測試:規則應觸發(assert rule fires)
|
|
44
|
+
test_drop_database_is_forbidden if {
|
|
45
|
+
data.governance.guardian.forbidden_patterns.has_forbidden_pattern with input as {
|
|
46
|
+
"plan": [{"command_type": "sql", "command": "DROP DATABASE prod_main", "reversible": false}]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# 負向測試:規則不應觸發(assert rule does NOT fire)
|
|
51
|
+
test_safe_select_is_not_forbidden if {
|
|
52
|
+
not data.governance.guardian.forbidden_patterns.has_forbidden_pattern with input as {
|
|
53
|
+
"plan": [{"command_type": "sql", "command": "SELECT * FROM users LIMIT 10", "reversible": true}]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 執行方式
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# OPA 已安裝時
|
|
62
|
+
opa test src/guardian/policies/ -v
|
|
63
|
+
|
|
64
|
+
# 透過 Docker(不需安裝 OPA)
|
|
65
|
+
docker run --rm \
|
|
66
|
+
-v "$(pwd)/src/guardian/policies:/policies:ro" \
|
|
67
|
+
openpolicyagent/opa:latest-static \
|
|
68
|
+
test /policies -v
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 二、每個 Policy Module 的最低測試要求
|
|
74
|
+
|
|
75
|
+
| 類型 | 最少案例 | 說明 |
|
|
76
|
+
|------|---------|------|
|
|
77
|
+
| ALLOW cases | 2 | 應該通過的正常操作 |
|
|
78
|
+
| DENY cases | 3 | 應該被攔截的危險操作 |
|
|
79
|
+
| Boundary cases | 1 | 邊界條件(如 reversible=true vs. false)|
|
|
80
|
+
| Integration(main policy)| 2 | 整合 main.rego 的允許 + 拒絕路徑 |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 三、Policy Module 設計原則
|
|
85
|
+
|
|
86
|
+
### 3.1 Fail-Closed 預設
|
|
87
|
+
|
|
88
|
+
```rego
|
|
89
|
+
# main.rego 必須包含以下預設
|
|
90
|
+
default allow = false
|
|
91
|
+
|
|
92
|
+
allow if {
|
|
93
|
+
not data.governance.guardian.forbidden_patterns.has_forbidden_pattern
|
|
94
|
+
not data.governance.guardian.env_policy.prod_violation
|
|
95
|
+
not data.governance.guardian.logic_constraints.has_logic_violation
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
任何 `undefined` 評估結果都應回傳 DENY,不能回傳 ALLOW。
|
|
100
|
+
|
|
101
|
+
### 3.2 使用 Set(不要 array.concat)
|
|
102
|
+
|
|
103
|
+
OPA ≥ 0.40 的型別系統嚴格區分 array 和 set。`violations` partial rule 是 set 型別,**不可用 `array.concat()`**。
|
|
104
|
+
|
|
105
|
+
```rego
|
|
106
|
+
# ✅ 正確:partial set rule 集合 violations
|
|
107
|
+
deny_reasons[r] if { r := data.governance.guardian.forbidden_patterns.violations[_] }
|
|
108
|
+
deny_reasons[r] if { r := data.governance.guardian.env_policy.violations[_] }
|
|
109
|
+
deny_reasons[r] if { r := data.governance.guardian.logic_constraints.violations[_] }
|
|
110
|
+
|
|
111
|
+
# ❌ 錯誤:array.concat 用在 set 上 → rego_type_error
|
|
112
|
+
# deny_reasons := array.concat(violations1, violations2)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 3.3 禁止解析自由文字欄位
|
|
116
|
+
|
|
117
|
+
Policy 決策**不得依賴** `intent`、`description`、`annotation` 等使用者可控文字欄位。
|
|
118
|
+
|
|
119
|
+
```rego
|
|
120
|
+
# ❌ 危險:解析 intent 欄位 → Prompt Injection 攻擊面(OWASP LLM01)
|
|
121
|
+
allow if { contains(input.intent, "EMERGENCY") }
|
|
122
|
+
|
|
123
|
+
# ✅ 安全:只使用結構化欄位
|
|
124
|
+
allow if {
|
|
125
|
+
input.target_env != "prod"
|
|
126
|
+
every step in input.plan { step.reversible == true }
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 3.4 一個 Module 管一個關注點
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
policies/
|
|
134
|
+
forbidden_patterns.rego ← 禁止指令模式
|
|
135
|
+
forbidden_patterns_test.rego
|
|
136
|
+
env_policy.rego ← 環境特定規則(prod 保護)
|
|
137
|
+
env_policy_test.rego
|
|
138
|
+
logic_constraints.rego ← 邏輯一致性(stop+start 用 restart)
|
|
139
|
+
logic_constraints_test.rego
|
|
140
|
+
risk_gate.rego ← 風險分數閾值
|
|
141
|
+
risk_gate_test.rego
|
|
142
|
+
main.rego ← 整合所有 module,Fail-Closed
|
|
143
|
+
main_test.rego ← 整合測試
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 四、CI 整合
|
|
149
|
+
|
|
150
|
+
### GitHub Actions 步驟
|
|
151
|
+
|
|
152
|
+
```yaml
|
|
153
|
+
- name: Test OPA Rego Policies
|
|
154
|
+
run: |
|
|
155
|
+
docker run --rm \
|
|
156
|
+
-v "${{ github.workspace }}/src/guardian/policies:/policies:ro" \
|
|
157
|
+
openpolicyagent/opa:latest-static \
|
|
158
|
+
test /policies -v
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### npm script
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"test:policy": "docker run --rm -v \"$(pwd)/src/guardian/policies:/policies:ro\" openpolicyagent/opa:latest-static test /policies -v"
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 五、品質閘門
|
|
172
|
+
|
|
173
|
+
| 閘門 | 閾值 | 強制程度 |
|
|
174
|
+
|------|------|---------|
|
|
175
|
+
| OPA 測試通過率(CI) | 100%(所有 test_ rule 通過)| Block merge |
|
|
176
|
+
| Root policy Fail-Closed | `default allow = false` 存在 | Block merge |
|
|
177
|
+
| 每個 policy module 有 _test.rego | 每個 .rego 有對應測試 | Advisory |
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 六、反模式(Anti-patterns)
|
|
182
|
+
|
|
183
|
+
| 反模式 | 問題 | 正確做法 |
|
|
184
|
+
|--------|------|---------|
|
|
185
|
+
| `array.concat()` 用在 violations(set 型)| OPA 型別錯誤 | 改用 partial set rule |
|
|
186
|
+
| Root policy 缺少 `default allow = false` | Fail-Open 漏洞 | 加入 default |
|
|
187
|
+
| Intent 欄位參與安全決策 | Prompt Injection 攻擊面 | 只用結構化欄位 |
|
|
188
|
+
| 只測試 DENY(無 ALLOW 測試)| 無法偵測過度限制 | 加入 ALLOW 案例 |
|
|
189
|
+
| _test.rego 只在本機跑,不在 CI | policy 改動無安全網 | CI 加 `opa test` step |
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 參考標準
|
|
194
|
+
|
|
195
|
+
- [OPA Testing Guide](https://www.openpolicyagent.org/docs/latest/policy-testing/)
|
|
196
|
+
- NIST SP 800-204C — Attribute-based Access Control
|
|
197
|
+
- [UDS `secure-op.ai.yaml`](../../../core/secure-op.md) — AI Agent 安全操作六大支柱
|
|
198
|
+
- [UDS `adversarial-test.ai.yaml`](../../../core/adversarial-test.md) — 對抗性測試(OWASP LLM01)
|
|
199
|
+
- [UDS `container-security.ai.yaml`](../../../core/container-security.md) — 容器安全(OPA Sidecar 部署)
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
**Scope**: universal
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/prd-standards.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-17
|
|
6
|
+
source_hash: 3addb642ee83
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 產品需求文件(PRD)標準
|
|
11
|
+
|
|
12
|
+
> **Language**: [English](../../../core/prd-standards.md) | 繁體中文
|
|
13
|
+
|
|
14
|
+
> **版本**: 1.0.0 | **狀態**: Active | **更新日期**: 2026-06-17
|
|
15
|
+
> **AI 最佳化版本**: `ai/standards/prd-standards.ai.yaml`
|
|
16
|
+
> **規格**: XSPEC-069(cross-project/specs/XSPEC-069-uds-product-layer-pack.md)
|
|
17
|
+
|
|
18
|
+
## 概觀
|
|
19
|
+
|
|
20
|
+
本標準定義**產品需求文件(PRD)**的結構、內容要求與生命週期治理。涵蓋五大必備
|
|
21
|
+
PRD 段落、從 PRD 需求銜接至可追溯 user story,以及 kickoff 後變更的修訂政策。確保
|
|
22
|
+
產品意圖能以可量化成功標準清楚傳達給工程、設計與利害關係人。
|
|
23
|
+
|
|
24
|
+
本標準屬於**產品層標準包**(XSPEC-069)。PRD 是工程需求的*上游*:PRD → user story
|
|
25
|
+
→ requirement。它銜接 `requirement-engineering`(需求的工程視角),並消費
|
|
26
|
+
`product-metrics-standards` 作為成功指標。
|
|
27
|
+
|
|
28
|
+
> **範圍**:本標準定義 *PRD 產物*(段落、追溯性、修訂政策)。這是 UDS 的產品層邊緣
|
|
29
|
+
> (依 XSPEC-070 `standard-admission-criteria`)——需求的工程視角仍留在
|
|
30
|
+
> `requirement-engineering`。
|
|
31
|
+
|
|
32
|
+
## 需求
|
|
33
|
+
|
|
34
|
+
| ID | 規則 | 等級 |
|
|
35
|
+
|----|------|------|
|
|
36
|
+
| REQ-001 | PRD 五大段落(問題、persona、成功指標、範圍、限制) | MUST |
|
|
37
|
+
| REQ-002 | PRD → user story 銜接(INVEST、可追溯至成功指標) | MUST |
|
|
38
|
+
| REQ-003 | 修訂政策(kickoff 後的正式變更流程) | MUST |
|
|
39
|
+
|
|
40
|
+
### REQ-001 — PRD 五大段落
|
|
41
|
+
|
|
42
|
+
每份 PRD MUST 依序包含五段落:(1) **Problem Statement**——以可觀察詞語描述使用者
|
|
43
|
+
痛點/機會,並盡量附量化資料;(2) **Target User / Persona**——誰受影響,引用具名
|
|
44
|
+
persona(≥1 主要、≥1 次要)含角色、情境與目標;(3) **Success Metrics**——2~4 個可
|
|
45
|
+
量化結果,各含現況 baseline、目標值與量測方法;(4) **Scope In / Out**——明確列出
|
|
46
|
+
包含與排除(排除項可引用未來 PRD);(5) **Constraints**——技術、法規、時間、預算或
|
|
47
|
+
相依性限制。
|
|
48
|
+
|
|
49
|
+
### REQ-002 — PRD 至 User Story 銜接
|
|
50
|
+
|
|
51
|
+
每個 PRD 需求 MUST 拆解為一個以上 user story,遵循 `requirement-engineering` 的
|
|
52
|
+
INVEST 原則。每個由 PRD 衍生的 story MUST 可追溯至至少一個 PRD 成功指標;無法連結
|
|
53
|
+
的 story MUST 在進 backlog 前標記供 PM 審視。追溯連結(PRD 段落 ID → user story ID
|
|
54
|
+
→ 成功指標)MUST 維護於 backlog 工具或 PRD 中的矩陣。
|
|
55
|
+
|
|
56
|
+
### REQ-003 — 修訂政策
|
|
57
|
+
|
|
58
|
+
開發 kickoff 會議後請求的 PRD 變更 MUST 遵循正式流程:(1) 以理由與影響評估記錄
|
|
59
|
+
提案變更;(2) 取得 PM、Tech Lead 與 Design Lead 的簽核;(3) 評估範圍影響——新增
|
|
60
|
+
範圍須將對應項目移出範圍或調整時程;(4) 更新版本歷史,含日期、作者、變更摘要與
|
|
61
|
+
核准者。kickoff 後修改卻無版本歷史的 PRD 視為不合規。輕微編輯變更(錯字、排版)
|
|
62
|
+
豁免簽核。
|
|
63
|
+
|
|
64
|
+
## 反樣態
|
|
65
|
+
|
|
66
|
+
- PRD 無可量化成功指標(僅質性目標,如「改善 UX」)。
|
|
67
|
+
- 範圍蔓延而無變更紀錄:sprint 中途新增需求且未記錄核准。
|
|
68
|
+
- 解法優先(solution-first)的 PRD:在確立使用者問題前先描述實作細節。
|
|
69
|
+
- 無明確的 out-of-scope 段落,導致開發期間的邊界爭議。
|
|
70
|
+
- 開發開始後才定義成功指標,使其無法驗證。
|
|
71
|
+
|
|
72
|
+
## 與既有標準的整合
|
|
73
|
+
|
|
74
|
+
- **`requirement-engineering`**——PRD 需求拆解為 INVEST user story。
|
|
75
|
+
- **`product-metrics-standards`**——PRD 成功指標取自指標階層。
|
|
76
|
+
- **`user-story-mapping`**——PRD 範圍實現為 story map 與 MVP 切片。
|
|
77
|
+
- **`acceptance-criteria-traceability`**——story 帶有可追溯回 PRD 指標的 AC。
|
|
78
|
+
|
|
79
|
+
## 相關規格
|
|
80
|
+
|
|
81
|
+
- XSPEC-069 — UDS 產品層標準包(本標準來源)
|
|
82
|
+
- XSPEC-070 — 治理 meta 標準(`standard-admission-criteria` 邊緣審視)
|
|
83
|
+
|
|
84
|
+
## 變更紀錄
|
|
85
|
+
|
|
86
|
+
| 版本 | 日期 | 變更 |
|
|
87
|
+
|------|------|------|
|
|
88
|
+
| v1.0.0 | 2026-06-17 | 初版——REQ-001~003:五大段落、PRD→story 銜接、修訂政策(XSPEC-069) |
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/product-metrics-standards.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-17
|
|
6
|
+
source_hash: e37a44aefd92
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 產品指標框架標準
|
|
11
|
+
|
|
12
|
+
> **Language**: [English](../../../core/product-metrics-standards.md) | 繁體中文
|
|
13
|
+
|
|
14
|
+
> **版本**: 1.0.0 | **狀態**: Active | **更新日期**: 2026-06-17
|
|
15
|
+
> **AI 最佳化版本**: `ai/standards/product-metrics-standards.ai.yaml`
|
|
16
|
+
> **規格**: XSPEC-069(cross-project/specs/XSPEC-069-uds-product-layer-pack.md)
|
|
17
|
+
|
|
18
|
+
## 概觀
|
|
19
|
+
|
|
20
|
+
本標準定義團隊如何**選擇、結構化與治理產品指標**。涵蓋框架選用矩陣(成長型用
|
|
21
|
+
AARRR、體驗型用 HEART、平台型用自訂北極星)、北極星準則、三層指標階層(北極星 →
|
|
22
|
+
L1 driver → L2 diagnostic),以及拒絕與營收/留存脫鉤指標的反虛榮(anti-vanity)
|
|
23
|
+
規則。使團隊圍繞能驅動有意義產品決策的指標對齊,而非活動追蹤。
|
|
24
|
+
|
|
25
|
+
本標準屬於**產品層標準包**(XSPEC-069)。其追蹤要求連接 SRE 可觀測性基本元件
|
|
26
|
+
(`observability-standards`、`slo-sli`)。
|
|
27
|
+
|
|
28
|
+
> **範圍**:本標準定義*指標選擇與治理*。具體分析工具(Amplitude/Mixpanel)屬採用者
|
|
29
|
+
> 的選擇。服務層級可靠性指標置於 `slo-sli`;此處為產品結果視角。
|
|
30
|
+
|
|
31
|
+
## 需求
|
|
32
|
+
|
|
33
|
+
| ID | 規則 | 等級 |
|
|
34
|
+
|----|------|------|
|
|
35
|
+
| REQ-001 | 框架選用矩陣(AARRR / HEART / 自訂北極星) | MUST |
|
|
36
|
+
| REQ-002 | 北極星準則(leading、可量測、actionable、可解釋) | MUST |
|
|
37
|
+
| REQ-003 | 指標階層(最多三層) | MUST |
|
|
38
|
+
| REQ-004 | 反虛榮規則 | MUST |
|
|
39
|
+
|
|
40
|
+
### REQ-001 — 框架選用矩陣
|
|
41
|
+
|
|
42
|
+
團隊 MUST 依產品類型選擇主要指標框架:**成長型產品**(消費 app、市集、病毒式產品)
|
|
43
|
+
→ **AARRR**(Acquisition、Activation、Retention、Referral、Revenue);**體驗型
|
|
44
|
+
產品**(生產力工具、B2B SaaS)→ **HEART**(Happiness、Engagement、Adoption、
|
|
45
|
+
Retention、Task Success);**平台型產品**(開發者平台、API)→ 反映平台價值的
|
|
46
|
+
**自訂北極星**,並視情況以 AARRR 或 HEART 元件補充。框架選用 MUST 記載於 PRD 或
|
|
47
|
+
產品策略文件。
|
|
48
|
+
|
|
49
|
+
### REQ-002 — 北極星準則
|
|
50
|
+
|
|
51
|
+
每個產品 MUST 定義恰好一個北極星指標,滿足全部四項準則:(1) **Leading
|
|
52
|
+
indicator**——預測未來業務健康而非量測過去結果;(2) **可量測且可追蹤**——可由可得
|
|
53
|
+
資料以既定頻率(週/月)計算;(3) **團隊可施力**——產品團隊有直接槓桿可影響;
|
|
54
|
+
(4) **一句話可解釋**。北極星 MUST 於每年產品規劃週期審視並再確認。
|
|
55
|
+
|
|
56
|
+
### REQ-003 — 指標階層
|
|
57
|
+
|
|
58
|
+
團隊 MUST 將指標結構化為至多三層階層。**Level 1(北極星)**:一個代表整體產品價值
|
|
59
|
+
的指標。**Level 2(L1 driver)**:3~5 個直接影響北極星的指標,各具文件化的因果
|
|
60
|
+
假設。**Level 3(L2 diagnostic)**:解釋 L1 driver 變動的 per-feature/per-team
|
|
61
|
+
指標(每個 driver 最多 3 個)。超過三層的指標為 PROHIBITED——代表量測碎片化而非
|
|
62
|
+
聚焦。
|
|
63
|
+
|
|
64
|
+
### REQ-004 — 反虛榮規則
|
|
65
|
+
|
|
66
|
+
團隊 MUST 在將任何指標加入官方儀表板前套用反虛榮測試。若某指標可在營收與留存持平
|
|
67
|
+
或下降時上升,即測試失敗;此類指標 MUST NOT 出現於官方產品審視或作為功能成功標準。
|
|
68
|
+
常見失敗:總註冊用戶(無活躍篩選)、原始 pageview(無 session 品質篩選)、總 API
|
|
69
|
+
呼叫(無唯一活躍客戶篩選)、媒體提及、無 activation 的下載數。當虛榮指標於營運監控
|
|
70
|
+
有用時,MUST 明確標示為「operational indicator, not success metric」。
|
|
71
|
+
|
|
72
|
+
## 反樣態
|
|
73
|
+
|
|
74
|
+
- 將虛榮指標(總註冊、原始 pageview)作為主要成功指標追蹤。
|
|
75
|
+
- 未定義北極星——團隊各自最佳化不同局部指標,造成失準。
|
|
76
|
+
- 團隊指標衝突,一隊的最佳化損害另一隊的指標。
|
|
77
|
+
- 指標階層深於三層——複雜而無洞見。
|
|
78
|
+
- 每季變更北極星,妨礙年對年趨勢分析。
|
|
79
|
+
|
|
80
|
+
## 與既有標準的整合
|
|
81
|
+
|
|
82
|
+
- **`prd-standards`**——PRD 成功指標取自此階層。
|
|
83
|
+
- **`observability-standards` / `slo-sli`**——產品指標的*追蹤*複用 SRE 指標/可觀測
|
|
84
|
+
性基本元件;可靠性 SLO 仍留在 `slo-sli`。
|
|
85
|
+
- **`user-story-mapping`**——story 驗收條件對應北極星 driver。
|
|
86
|
+
|
|
87
|
+
## 相關規格
|
|
88
|
+
|
|
89
|
+
- XSPEC-069 — UDS 產品層標準包(本標準來源)
|
|
90
|
+
- XSPEC-063 — SRE 標準包(`observability-standards`、`slo-sli`)
|
|
91
|
+
|
|
92
|
+
## 變更紀錄
|
|
93
|
+
|
|
94
|
+
| 版本 | 日期 | 變更 |
|
|
95
|
+
|------|------|------|
|
|
96
|
+
| v1.0.0 | 2026-06-17 | 初版——REQ-001~004:框架矩陣、北極星準則、指標階層、反虛榮規則(XSPEC-069) |
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/prompt-regression.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-10
|
|
6
|
+
source_hash: 25070d0b8a98
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Prompt 回歸測試標準
|
|
11
|
+
|
|
12
|
+
> **語言**: [English](../../../core/prompt-regression.md) | 繁體中文
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 概述
|
|
17
|
+
|
|
18
|
+
AI 代理的 prompt 即程式碼。未預期的變更會悄悄降低代理行為品質,卻不會觸發型別錯誤或單元測試失敗。Prompt 回歸測試利用 SHA-256 黃金校驗和(golden checksum)偵測任何修改,強制開發者明確確認並記錄每次 prompt 變更。
|
|
19
|
+
|
|
20
|
+
## 為什麼要使用校驗和
|
|
21
|
+
|
|
22
|
+
- 僅有 diff 不能阻擋 CI 流程——校驗和可以
|
|
23
|
+
- Prompt 是大型 Markdown 檔案;細微的編輯(空白字元、標點符號)都可能改變模型行為
|
|
24
|
+
- 校驗和更新 + 說明註解會建立每次 prompt 變更原因的稽核軌跡
|
|
25
|
+
|
|
26
|
+
## 實作方式
|
|
27
|
+
|
|
28
|
+
### 1. 計算初始校驗和
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
for f in agents/*/prompt.md; do
|
|
32
|
+
echo -n "$f: "
|
|
33
|
+
sha256sum "$f" | cut -d' ' -f1
|
|
34
|
+
done
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. 黃金校驗和測試(Vitest)
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
41
|
+
import { createHash } from "crypto"
|
|
42
|
+
import { readFileSync } from "fs"
|
|
43
|
+
import { join } from "path"
|
|
44
|
+
import { describe, it, expect } from "vitest"
|
|
45
|
+
|
|
46
|
+
// 僅在 prompt 變更為刻意行為時才更新這些值。
|
|
47
|
+
// 在同一行加上說明 WHY prompt 發生變更的註解。
|
|
48
|
+
const GOLDEN_CHECKSUMS: Record<string, string> = {
|
|
49
|
+
architect: "98017d39b0e48cda88b796687d21e0f884c810805e534453a23b7ad935e4a5ef",
|
|
50
|
+
builder: "5c2acda3e48dae771c61f55d3a5b0d5ac7383870054ef71e757714e367c50031",
|
|
51
|
+
// ... 所有代理
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe("Agent prompt regression (XSPEC-162)", () => {
|
|
55
|
+
for (const [agent, expected] of Object.entries(GOLDEN_CHECKSUMS)) {
|
|
56
|
+
it(`agents/${agent}/prompt.md checksum matches golden`, () => {
|
|
57
|
+
const filePath = join(__dirname, "..", "..", "agents", agent, "prompt.md")
|
|
58
|
+
const content = readFileSync(filePath)
|
|
59
|
+
const actual = createHash("sha256").update(content).digest("hex")
|
|
60
|
+
expect(actual, `Prompt for '${agent}' changed unexpectedly. If intentional, update GOLDEN_CHECKSUMS with a comment.`).toBe(expected)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. CI 整合
|
|
67
|
+
|
|
68
|
+
校驗和測試作為標準 `npm run test:coverage` 閘門的一部分執行(已透過 XSPEC-156 強制執行)。不需要額外的 CI 步驟。
|
|
69
|
+
|
|
70
|
+
### 4. 更新校驗和
|
|
71
|
+
|
|
72
|
+
當 prompt 變更為刻意行為時:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// 之前:
|
|
76
|
+
architect: "98017d39...", // updated 2026-05-05: added Guardian policy XSPEC-160 reference
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
說明註解是必填的。在程式碼審查時,應拒絕未附說明註解即更新校驗和的 PR。
|
|
80
|
+
|
|
81
|
+
## 相關標準
|
|
82
|
+
|
|
83
|
+
- [LLM 輸出驗證](../../../core/llm-output-validation.md) — schema 層級驗證
|
|
84
|
+
- [對抗性測試](../../../core/adversarial-test.md) — 紅隊語料庫
|
|
85
|
+
- [測試標準](../../../core/testing-standards.md) — 整體測試金字塔
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
**Scope**: universal
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/property-based-testing.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-10
|
|
6
|
+
source_hash: 13f5eba04aef
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Property-Based Testing 標準
|
|
11
|
+
|
|
12
|
+
> **Language**: [English](../../../core/property-based-testing.md) | 繁體中文
|
|
13
|
+
|
|
14
|
+
## 概述
|
|
15
|
+
|
|
16
|
+
基於範例的測試只能驗證開發者想得到的案例。Property-based testing 反轉了這個思路:你定義一個不變量(「分數永遠介於 0 到 100 之間」),框架會產生數百個輸入來嘗試推翻它。當找到失敗的輸入時,框架會將其縮減(shrink)為最小反例。
|
|
17
|
+
|
|
18
|
+
## 使用時機
|
|
19
|
+
|
|
20
|
+
| 使用 Property 測試 | 使用範例測試 |
|
|
21
|
+
|-------------------|------------------|
|
|
22
|
+
| 純數學函式 | 複雜業務邏輯 |
|
|
23
|
+
| 解析器 / 序列化器 | 整合路徑 |
|
|
24
|
+
| 分數截斷 / 四捨五入 | UI 行為 |
|
|
25
|
+
| 雜湊 / 編碼 | 資料庫操作 |
|
|
26
|
+
| 安全驗證器 | 外部 API 呼叫 |
|
|
27
|
+
|
|
28
|
+
## 工具:fast-check(TypeScript)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install --save-dev fast-check
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import fc from "fast-check"
|
|
36
|
+
import { describe, it, expect } from "vitest"
|
|
37
|
+
import { classifyTokenZone, TOKEN_BUDGET } from "../types/index.js"
|
|
38
|
+
|
|
39
|
+
describe("classifyTokenZone property: result is always a valid zone", () => {
|
|
40
|
+
it("for any ratio in [0, 2], returns a valid TokenBudgetZone", () => {
|
|
41
|
+
fc.assert(
|
|
42
|
+
fc.property(
|
|
43
|
+
fc.float({ min: 0, max: 2, noNaN: true }),
|
|
44
|
+
(ratio) => {
|
|
45
|
+
const zone = classifyTokenZone(ratio)
|
|
46
|
+
return ["safe", "warning", "danger", "blocking"].includes(zone)
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
{ numRuns: 1000 }
|
|
50
|
+
)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Guardian scoreReviewable 屬性
|
|
56
|
+
|
|
57
|
+
需要測試的關鍵不變量:
|
|
58
|
+
|
|
59
|
+
| 屬性 | 說明 |
|
|
60
|
+
|----------|-------------|
|
|
61
|
+
| **範圍截斷** | `score` 永遠在 `[0, 100]` 範圍內 |
|
|
62
|
+
| **確定性** | 相同輸入永遠產生相同分數 |
|
|
63
|
+
| **單調性** | 對相同操作,prod > staging > dev |
|
|
64
|
+
| **非負性** | `breakdown` 的值全部 >= 0 |
|
|
65
|
+
|
|
66
|
+
## 反例縮減(Counterexample Shrinking)
|
|
67
|
+
|
|
68
|
+
當 fast-check 找到失敗案例時,會自動縮減:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Original failure: { target_env: "prod", command: "rm -rf /tmp/xyz123...", ... }
|
|
72
|
+
Shrunk to: { target_env: "prod", command: "rm", ... }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
從錯誤訊息中儲存 seed 以便重現:
|
|
76
|
+
```typescript
|
|
77
|
+
fc.assert(property, { seed: 1234567890 })
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 相關標準
|
|
81
|
+
|
|
82
|
+
- [Mutation Testing 標準](mutation-testing.md) — PBT 的互補
|
|
83
|
+
- [測試標準](testing-standards.md) — 整體測試金字塔
|
|
84
|
+
- [Adversarial Test 標準](adversarial-test.md) — 以安全為導向的 fuzzing
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
**Scope**: universal
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
source: ../../../core/refactoring-standards.md
|
|
3
|
-
source_version: 2.
|
|
4
|
-
translation_version: 2.
|
|
5
|
-
last_synced: 2026-
|
|
3
|
+
source_version: 2.2.0
|
|
4
|
+
translation_version: 2.2.0
|
|
5
|
+
last_synced: 2026-07-01
|
|
6
6
|
status: current
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -10,8 +10,8 @@ status: current
|
|
|
10
10
|
|
|
11
11
|
> **語言**: [English](../../../core/refactoring-standards.md) | 繁體中文
|
|
12
12
|
|
|
13
|
-
**版本**: 2.
|
|
14
|
-
**最後更新**: 2026-
|
|
13
|
+
**版本**: 2.2.0
|
|
14
|
+
**最後更新**: 2026-07-01
|
|
15
15
|
**適用性**: 所有軟體專案
|
|
16
16
|
**範圍**: 通用 (Universal)
|
|
17
17
|
|
|
@@ -64,10 +64,46 @@ status: current
|
|
|
64
64
|
|
|
65
65
|
---
|
|
66
66
|
|
|
67
|
+
## 語意重複與 Copy-Drift(語意重複)
|
|
68
|
+
|
|
69
|
+
文字重複(textual duplication)指標只能抓到逐字複製,卻抓不到更危險的情況:**同一個 domain fact 在多處被重複實作**。當這些實作不是逐字相同時(改寫過的分類邏輯、同一條公式在一處對一處錯、把 total 與它彙總的 rows 分開儲存),它們會通過靜態分析,然後**各自獨立地漂移**,產生看似無關、實則同源的一叢 bug。
|
|
70
|
+
|
|
71
|
+
### 反模式:Copy-Drift
|
|
72
|
+
|
|
73
|
+
Copy-Drift 發生於下列任一情況:
|
|
74
|
+
|
|
75
|
+
- 單一 domain fact(分類、規則、計算)被**在多個 call site 重複實作**,而非由單一共用單元計算;或
|
|
76
|
+
- **derived value 被持久化**(stored aggregate、counter、denormalized 欄位)**卻無與來源綁定的強制關係**,使每條 write path 都能各自更新它。
|
|
77
|
+
|
|
78
|
+
因為這些 copy 並非逐字相同,文字重複工具一個都抓不到。漂移會在稍後以不一致的形式浮現:list view 與 detail view 對不上、stored counter 因某條更新路徑的 decrement/rollback 分支被略過或被註解掉而重複計數、或同一條公式在不同模組給出不同答案。
|
|
79
|
+
|
|
80
|
+
### 模式:Single Source of Truth / Derive-Don't-Duplicate
|
|
81
|
+
|
|
82
|
+
- **每個 fact 只有一個單元**:把每個 domain fact 抽成**唯一**的 classifier / calculator / resolver;所有 call site 都呼叫它——不重實作、不改寫。
|
|
83
|
+
- **優先 derive,不要 store**:優先在 read 時計算,而非持久化第二份 copy;永遠被 derive 的值不會漂移。
|
|
84
|
+
- **若 aggregate 一定要存**,把它當成 detail rows 的 **projection**,並在**單一 choke point**(例如 `SaveChanges` interceptor,或單一共用 `recompute()` 函式)重算,讓**每一條** write path(含 async job 與 failure write-back)都走同一個重算路徑而保持一致。**絕不**讓個別 path 對 stored aggregate 做 incremental `col = col + delta` 調整;incremental 調整正是 decrement/rollback 分支被略過、counter 發生漂移的原因。
|
|
85
|
+
- **用測試鎖定**:用 **golden test** 鎖定 single source of truth,並加一個 **architecture test**——若規則在別處被重新定義就 fail,讓未來的 copy 在 CI 被擋下,而非在 production 才發現。
|
|
86
|
+
|
|
87
|
+
### 遷移推論——Intentional-Divergence Registry(刻意偏離登記)
|
|
88
|
+
|
|
89
|
+
當新系統**刻意**偏離 legacy 行為時,必須登記——否則未來某次「修正」會靜默地把它回退掉。port 過程中常見的情況:legacy *函式*回傳 X,但 legacy *pipeline* 在下游把它調和成 Y;port 把這個調和折進單一單元,讓函式直接回傳 Y。
|
|
90
|
+
|
|
91
|
+
- 把每個刻意偏離登記在 **intentional-divergence registry**(legacy 行為、new 行為、rationale、所屬 fact)。
|
|
92
|
+
- 用 **golden test** 鎖定 new 行為,讓未來「修正」回 legacy 會讓 build fail。
|
|
93
|
+
- 把 registry 餵給對 legacy 的任何 **differential test**,使該偏離被視為**預期**而非 regression。
|
|
94
|
+
|
|
95
|
+
### 給採用者的註記
|
|
96
|
+
|
|
97
|
+
- per-function 的 legacy-vs-new diffing 只產出**候選**,非裁決;每個候選都要對照**整條** legacy pipeline(下游可能已調和該差異)裁決後,才能稱為 bug。
|
|
98
|
+
- 用 programmatic / token-based 方式抽取 legacy 函式本體(不要手抄),避免在調查抄寫錯誤時又重新引入抄寫錯誤。
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
67
102
|
## 相關標準
|
|
68
103
|
|
|
69
104
|
- [重構指南](guides/refactoring-guide.md) - 詳細模式與教學
|
|
70
|
-
- [測試標準](testing-standards.md)
|
|
105
|
+
- [測試標準](testing-standards.md) - golden test 與 architecture test 鎖定 single source of truth
|
|
106
|
+
- [測試治理](test-governance.md) - 在 CI 治理語意重複與 intentional-divergence 檢查
|
|
71
107
|
- [程式碼審查清單](code-review-checklist.md)
|
|
72
108
|
|
|
73
109
|
---
|
|
@@ -76,6 +112,7 @@ status: current
|
|
|
76
112
|
|
|
77
113
|
| 版本 | 日期 | 變更 |
|
|
78
114
|
|------|------|------|
|
|
115
|
+
| 2.2.0 | 2026-07-01 | 新增「語意重複與 Copy-Drift」(issue #142):Copy-Drift 反模式、Single Source of Truth / Derive-Don't-Duplicate 模式、Intentional-Divergence Registry 遷移推論。 |
|
|
79
116
|
| 2.0.0 | 2026-01-29 | **重大重構**:拆分為規則(本文件)和指南(refactoring-guide.md)。 |
|
|
80
117
|
| 1.0.0 | 2025-12-15 | 初始版本 |
|
|
81
118
|
|