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,535 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/container-security.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-10
|
|
6
|
+
source_hash: a1badc590927
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 容器安全標準
|
|
11
|
+
|
|
12
|
+
> **語言**:[English](../../../core/container-security.md) | 繁體中文
|
|
13
|
+
|
|
14
|
+
> **版本**:v1.0.0 | **更新日期**:2026-05-04 | **分類**:security
|
|
15
|
+
>
|
|
16
|
+
> AI 最佳化格式:`ai/standards/container-security.ai.yaml`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 概覽
|
|
21
|
+
|
|
22
|
+
本標準涵蓋容器與 Kubernetes 環境的完整安全要求,適用於所有使用 Docker 或 K8s 部署的服務,尤其針對 **AI Agent 生產環境**(採用層)提供特化規則。
|
|
23
|
+
|
|
24
|
+
### 六大安全域
|
|
25
|
+
|
|
26
|
+
| 域 | 說明 |
|
|
27
|
+
|----|------|
|
|
28
|
+
| [映像強化](#1-映像強化-image-hardening) | distroless/alpine base、non-root USER、multi-stage build |
|
|
29
|
+
| [Registry 安全](#2-registry-安全-registry-security) | 私有 Registry、Cosign/Notary 簽章、immutable tag、Trivy |
|
|
30
|
+
| [Runtime 安全](#3-runtime-安全-runtime-security) | read-only rootfs、drop ALL capabilities、seccompProfile |
|
|
31
|
+
| [Secrets 管理](#4-secrets-管理-secrets-management) | 禁止 ENV 傳 secret、K8s Secrets、Vault |
|
|
32
|
+
| [網路策略](#5-網路策略-network-policy) | K8s NetworkPolicy default-deny、AI Agent 出站白名單 |
|
|
33
|
+
| [供應鏈安全](#6-供應鏈安全-supply-chain) | SBOM、digest pin、Sigstore keyless、lockfile 驗證 |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 1. 映像強化(Image Hardening)
|
|
38
|
+
|
|
39
|
+
### 1.1 Base Image 選擇
|
|
40
|
+
|
|
41
|
+
**優先使用**(依安全性排序):
|
|
42
|
+
|
|
43
|
+
| Base Image | 適用場景 | 大小 |
|
|
44
|
+
|------------|---------|------|
|
|
45
|
+
| `gcr.io/distroless/static-debian12` | 靜態二進位(Go) | ~2 MB |
|
|
46
|
+
| `gcr.io/distroless/base-debian12` | 動態連結二進位 | ~20 MB |
|
|
47
|
+
| `gcr.io/distroless/nodejs20-debian12` | Node.js 應用 | ~120 MB |
|
|
48
|
+
| `alpine:3.19` | 需要 shell 的建置場景 | ~7 MB |
|
|
49
|
+
|
|
50
|
+
**禁止**:
|
|
51
|
+
- `ubuntu:latest`、`debian:latest`(浮動 tag + 龐大 attack surface)
|
|
52
|
+
- 以 `latest` tag 指定任何 base image
|
|
53
|
+
- 在 final stage 使用含完整套件管理器的映像
|
|
54
|
+
|
|
55
|
+
### 1.2 Dockerfile 最佳實踐
|
|
56
|
+
|
|
57
|
+
```dockerfile
|
|
58
|
+
# ── 建置階段 ──────────────────────────────────────
|
|
59
|
+
FROM node:20-alpine AS builder
|
|
60
|
+
WORKDIR /app
|
|
61
|
+
COPY package-lock.json package.json ./
|
|
62
|
+
RUN npm ci --only=production # 只安裝 production 依賴
|
|
63
|
+
|
|
64
|
+
COPY src/ ./src/
|
|
65
|
+
RUN npm run build
|
|
66
|
+
|
|
67
|
+
# ── 最終階段(distroless)────────────────────────
|
|
68
|
+
FROM gcr.io/distroless/nodejs20-debian12@sha256:<digest>
|
|
69
|
+
WORKDIR /app
|
|
70
|
+
|
|
71
|
+
# 只複製必要檔案
|
|
72
|
+
COPY --from=builder /app/dist ./dist
|
|
73
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
74
|
+
|
|
75
|
+
# 強制 non-root(UID 1000)
|
|
76
|
+
USER 1000
|
|
77
|
+
|
|
78
|
+
EXPOSE 3000
|
|
79
|
+
CMD ["dist/index.js"]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**規則摘要**:
|
|
83
|
+
|
|
84
|
+
- `multi-stage build`:建置工具不進入 final image
|
|
85
|
+
- `USER 1000`:final stage 必須設定非 root 使用者
|
|
86
|
+
- `RUN` 禁止在 final stage 執行套件安裝
|
|
87
|
+
- `COPY` 只複製特定檔案;禁止 `COPY . .` 於 final stage
|
|
88
|
+
- base image 固定 digest(`@sha256:<digest>`),非 tag
|
|
89
|
+
|
|
90
|
+
### 1.3 Kubernetes SecurityContext
|
|
91
|
+
|
|
92
|
+
```yaml
|
|
93
|
+
# Pod 層級
|
|
94
|
+
spec:
|
|
95
|
+
securityContext:
|
|
96
|
+
runAsNonRoot: true
|
|
97
|
+
runAsUser: 1000
|
|
98
|
+
fsGroup: 1000
|
|
99
|
+
seccompProfile:
|
|
100
|
+
type: RuntimeDefault
|
|
101
|
+
|
|
102
|
+
containers:
|
|
103
|
+
- name: ai-agent
|
|
104
|
+
securityContext:
|
|
105
|
+
allowPrivilegeEscalation: false
|
|
106
|
+
readOnlyRootFilesystem: true
|
|
107
|
+
capabilities:
|
|
108
|
+
drop: ["ALL"]
|
|
109
|
+
add: [] # 只在有明確需求時加入,並文件化理由
|
|
110
|
+
# AppArmor(Kubernetes annotation)
|
|
111
|
+
# annotations:
|
|
112
|
+
# container.apparmor.security.beta.kubernetes.io/ai-agent: runtime/default
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 2. Registry 安全(Registry Security)
|
|
118
|
+
|
|
119
|
+
### 2.1 私有 Registry 要求
|
|
120
|
+
|
|
121
|
+
- **生產環境禁止**使用 Docker Hub 公開映像(未驗證來源)
|
|
122
|
+
- 必須使用私有 Registry:GHCR、ECR、GCR、Harbor 等
|
|
123
|
+
- Registry 存取使用 Service Account + RBAC(不用個人帳號密碼)
|
|
124
|
+
|
|
125
|
+
### 2.2 Tag 策略
|
|
126
|
+
|
|
127
|
+
| 環境 | 要求 |
|
|
128
|
+
|------|------|
|
|
129
|
+
| 開發 | `<branch>-<git-sha>` |
|
|
130
|
+
| Staging | `<semver>-rc.<N>` |
|
|
131
|
+
| 生產 | `<semver>`(e.g., `v1.2.3`)+ digest pin |
|
|
132
|
+
|
|
133
|
+
**禁止**:生產 Deployment 使用 `latest` tag。
|
|
134
|
+
|
|
135
|
+
### 2.3 映像簽章(Cosign)
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# 建置後簽章
|
|
139
|
+
IMAGE_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' myimage)
|
|
140
|
+
cosign sign "${IMAGE_DIGEST}"
|
|
141
|
+
|
|
142
|
+
# 驗證(在 CI 或 Admission Controller)
|
|
143
|
+
cosign verify \
|
|
144
|
+
--certificate-identity-regexp="https://github.com/org/repo/.*" \
|
|
145
|
+
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
|
|
146
|
+
"${IMAGE_DIGEST}"
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 2.4 Trivy 弱點掃描 Gate
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# CI 強制 gate:critical 或 high CVE → 阻擋推送
|
|
153
|
+
trivy image \
|
|
154
|
+
--exit-code 1 \
|
|
155
|
+
--severity CRITICAL,HIGH \
|
|
156
|
+
--ignore-unfixed \
|
|
157
|
+
myimage:v1.2.3
|
|
158
|
+
|
|
159
|
+
# 周期性掃描(已部署映像)
|
|
160
|
+
trivy image --format json --output trivy-report.json myimage@sha256:<digest>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**SLA**:
|
|
164
|
+
|
|
165
|
+
| 嚴重度 | 允許推送 | 修補期限 |
|
|
166
|
+
|--------|---------|---------|
|
|
167
|
+
| Critical | 否 | 立即修補 |
|
|
168
|
+
| High | 否 | 24 小時內 |
|
|
169
|
+
| Medium | 是 | 7 天內 |
|
|
170
|
+
| Low | 是 | 下次維護窗口 |
|
|
171
|
+
|
|
172
|
+
> **Trial / Community Edition 強制啟用**:避免 supply chain compromise,所有版本均強制 Trivy gate。
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 3. Runtime 安全(Runtime Security)
|
|
177
|
+
|
|
178
|
+
### 3.1 禁止項目
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
# 以下設定禁止用於生產環境
|
|
182
|
+
securityContext:
|
|
183
|
+
privileged: true # 禁止
|
|
184
|
+
spec:
|
|
185
|
+
hostNetwork: true # 禁止(除非有書面需求核准)
|
|
186
|
+
hostPID: true # 禁止
|
|
187
|
+
hostIPC: true # 禁止
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 3.2 Seccomp Profile
|
|
191
|
+
|
|
192
|
+
```yaml
|
|
193
|
+
# Pod 層級啟用 RuntimeDefault
|
|
194
|
+
spec:
|
|
195
|
+
securityContext:
|
|
196
|
+
seccompProfile:
|
|
197
|
+
type: RuntimeDefault # 封鎖 300+ 危險 syscall
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
若服務需要自訂 syscall 清單,使用 `Localhost` profile 並維護 seccomp JSON 文件。
|
|
201
|
+
|
|
202
|
+
### 3.3 Writable Volume 策略
|
|
203
|
+
|
|
204
|
+
| 用途 | 允許掛載類型 |
|
|
205
|
+
|------|------------|
|
|
206
|
+
| 應用程式資料 | PersistentVolumeClaim |
|
|
207
|
+
| 暫存檔案 | `emptyDir`(限 /tmp) |
|
|
208
|
+
| Audit Log | hostPath(append-only partition)|
|
|
209
|
+
| Secret | K8s Secret volume mount |
|
|
210
|
+
|
|
211
|
+
**禁止**:將 `emptyDir` 用作 audit log 存放位置(重啟後資料消失)。
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 4. Secrets 管理(Secrets Management)
|
|
216
|
+
|
|
217
|
+
### 4.1 禁止模式
|
|
218
|
+
|
|
219
|
+
```dockerfile
|
|
220
|
+
# ❌ 禁止:Secret 硬編碼在映像中
|
|
221
|
+
ENV API_KEY=sk-abc123
|
|
222
|
+
|
|
223
|
+
# ❌ 禁止:Secret 在 build ARG(會殘留 layer)
|
|
224
|
+
ARG DATABASE_PASSWORD
|
|
225
|
+
RUN configure --password=$DATABASE_PASSWORD
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
```yaml
|
|
229
|
+
# ❌ 禁止:Secret 以明文存 ConfigMap
|
|
230
|
+
apiVersion: v1
|
|
231
|
+
kind: ConfigMap
|
|
232
|
+
data:
|
|
233
|
+
api_key: "sk-real-key" # 禁止
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### 4.2 允許模式
|
|
237
|
+
|
|
238
|
+
**Staging:K8s Secret + Volume Mount**
|
|
239
|
+
|
|
240
|
+
```yaml
|
|
241
|
+
# K8s Secret(base64 encoded)
|
|
242
|
+
apiVersion: v1
|
|
243
|
+
kind: Secret
|
|
244
|
+
metadata:
|
|
245
|
+
name: ai-agent-secrets
|
|
246
|
+
type: Opaque
|
|
247
|
+
data:
|
|
248
|
+
anthropic-api-key: <base64-encoded-value>
|
|
249
|
+
---
|
|
250
|
+
# Pod 掛載
|
|
251
|
+
spec:
|
|
252
|
+
containers:
|
|
253
|
+
- name: ai-agent
|
|
254
|
+
volumeMounts:
|
|
255
|
+
- name: secrets
|
|
256
|
+
mountPath: /run/secrets
|
|
257
|
+
readOnly: true
|
|
258
|
+
volumes:
|
|
259
|
+
- name: secrets
|
|
260
|
+
secret:
|
|
261
|
+
secretName: ai-agent-secrets
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**生產:Vault Agent Injector(推薦)**
|
|
265
|
+
|
|
266
|
+
```yaml
|
|
267
|
+
# 使用 Vault annotation 自動注入 secret
|
|
268
|
+
spec:
|
|
269
|
+
template:
|
|
270
|
+
metadata:
|
|
271
|
+
annotations:
|
|
272
|
+
vault.hashicorp.com/agent-inject: "true"
|
|
273
|
+
vault.hashicorp.com/role: "ai-agent"
|
|
274
|
+
vault.hashicorp.com/agent-inject-secret-api-key: "secret/ai-agent/anthropic"
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### 4.3 AI Agent 特殊規則
|
|
278
|
+
|
|
279
|
+
- LLM API 金鑰(Anthropic、OpenAI)**必須**透過 mounted secret volume 注入,不得使用 ENV
|
|
280
|
+
- Guardian OPA policy 檔案**不是** secret,使用 ConfigMap 即可
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## 5. 網路策略(Network Policy)
|
|
285
|
+
|
|
286
|
+
### 5.1 Default Deny 基準策略
|
|
287
|
+
|
|
288
|
+
```yaml
|
|
289
|
+
# 每個 namespace 必須先套用 default-deny
|
|
290
|
+
apiVersion: networking.k8s.io/v1
|
|
291
|
+
kind: NetworkPolicy
|
|
292
|
+
metadata:
|
|
293
|
+
name: default-deny-all
|
|
294
|
+
namespace: ai-agent
|
|
295
|
+
spec:
|
|
296
|
+
podSelector: {} # 套用到所有 Pod
|
|
297
|
+
policyTypes:
|
|
298
|
+
- Ingress
|
|
299
|
+
- Egress
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### 5.2 AI Agent 出站白名單
|
|
303
|
+
|
|
304
|
+
```yaml
|
|
305
|
+
apiVersion: networking.k8s.io/v1
|
|
306
|
+
kind: NetworkPolicy
|
|
307
|
+
metadata:
|
|
308
|
+
name: ai-agent-egress-allowlist
|
|
309
|
+
namespace: ai-agent
|
|
310
|
+
spec:
|
|
311
|
+
podSelector:
|
|
312
|
+
matchLabels:
|
|
313
|
+
app: ai-agent
|
|
314
|
+
policyTypes:
|
|
315
|
+
- Egress
|
|
316
|
+
egress:
|
|
317
|
+
# DNS(必須)
|
|
318
|
+
- ports:
|
|
319
|
+
- protocol: UDP
|
|
320
|
+
port: 53
|
|
321
|
+
- protocol: TCP
|
|
322
|
+
port: 53
|
|
323
|
+
# Anthropic API
|
|
324
|
+
- to:
|
|
325
|
+
- ipBlock:
|
|
326
|
+
cidr: 0.0.0.0/0 # 實際部署時替換為 Anthropic IP range
|
|
327
|
+
ports:
|
|
328
|
+
- protocol: TCP
|
|
329
|
+
port: 443
|
|
330
|
+
# kube-dns / CoreDNS
|
|
331
|
+
- to:
|
|
332
|
+
- namespaceSelector:
|
|
333
|
+
matchLabels:
|
|
334
|
+
kubernetes.io/metadata.name: kube-system
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**允許出站端點清單**:
|
|
338
|
+
|
|
339
|
+
| 端點 | 協定 | 埠 | 用途 |
|
|
340
|
+
|------|------|-----|------|
|
|
341
|
+
| `api.anthropic.com` | HTTPS | 443 | Claude LLM API |
|
|
342
|
+
| `api.openai.com` | HTTPS | 443 | OpenAI LLM API |
|
|
343
|
+
| `bedrock.*.amazonaws.com` | HTTPS | 443 | AWS Bedrock |
|
|
344
|
+
| CoreDNS | UDP/TCP | 53 | DNS 解析 |
|
|
345
|
+
|
|
346
|
+
### 5.3 Guardian OPA Sidecar 部署
|
|
347
|
+
|
|
348
|
+
```yaml
|
|
349
|
+
# Guardian 作為 sidecar container(同 Pod)
|
|
350
|
+
spec:
|
|
351
|
+
containers:
|
|
352
|
+
- name: ai-agent
|
|
353
|
+
image: ai-agent/runtime:v1.2.3@sha256:<digest>
|
|
354
|
+
# ...
|
|
355
|
+
- name: guardian-opa
|
|
356
|
+
image: openpolicyagent/opa:latest-rootless@sha256:<digest>
|
|
357
|
+
args:
|
|
358
|
+
- run
|
|
359
|
+
- --server
|
|
360
|
+
- --addr=localhost:8181
|
|
361
|
+
- /policies
|
|
362
|
+
volumeMounts:
|
|
363
|
+
- name: opa-policies
|
|
364
|
+
mountPath: /policies
|
|
365
|
+
readOnly: true
|
|
366
|
+
volumes:
|
|
367
|
+
- name: opa-policies
|
|
368
|
+
configMap:
|
|
369
|
+
name: guardian-opa-policies
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## 6. 供應鏈安全(Supply Chain)
|
|
375
|
+
|
|
376
|
+
### 6.1 SBOM 生成
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
# 使用 Syft 生成 CycloneDX 格式 SBOM
|
|
380
|
+
syft myimage:v1.2.3 -o cyclonedx-json > sbom-v1.2.3.json
|
|
381
|
+
|
|
382
|
+
# 使用 Trivy 生成 SPDX 格式 SBOM
|
|
383
|
+
trivy image --format spdx-json --output sbom.spdx.json myimage:v1.2.3
|
|
384
|
+
|
|
385
|
+
# 附加到 OCI Registry(Cosign)
|
|
386
|
+
cosign attach sbom --sbom sbom-v1.2.3.json myimage@sha256:<digest>
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### 6.2 Digest Pinning
|
|
390
|
+
|
|
391
|
+
```dockerfile
|
|
392
|
+
# ✅ 正確:使用 digest 固定
|
|
393
|
+
FROM gcr.io/distroless/nodejs20-debian12@sha256:abc123...
|
|
394
|
+
|
|
395
|
+
# ❌ 錯誤:浮動 tag
|
|
396
|
+
FROM gcr.io/distroless/nodejs20-debian12:latest
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
```yaml
|
|
400
|
+
# ✅ 正確:K8s Deployment 使用 digest
|
|
401
|
+
spec:
|
|
402
|
+
containers:
|
|
403
|
+
- image: myregistry.io/ai-agent:v1.2.3@sha256:def456...
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### 6.3 Sigstore Keyless Signing(GitHub Actions)
|
|
407
|
+
|
|
408
|
+
```yaml
|
|
409
|
+
# .github/workflows/build-push.yml
|
|
410
|
+
- name: Sign container image
|
|
411
|
+
uses: sigstore/cosign-installer@v3
|
|
412
|
+
- name: Sign
|
|
413
|
+
run: |
|
|
414
|
+
cosign sign --yes \
|
|
415
|
+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}
|
|
416
|
+
env:
|
|
417
|
+
COSIGN_EXPERIMENTAL: "true" # Keyless (OIDC)
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### 6.4 各語言 Lockfile 驗證
|
|
421
|
+
|
|
422
|
+
**Node.js**:
|
|
423
|
+
```bash
|
|
424
|
+
# 使用 npm ci(嚴格 lockfile)
|
|
425
|
+
npm ci --only=production
|
|
426
|
+
|
|
427
|
+
# 不允許
|
|
428
|
+
npm install # 可能更新 lockfile
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
**Python**:
|
|
432
|
+
```bash
|
|
433
|
+
# 使用 hash 驗證
|
|
434
|
+
pip install --require-hashes -r requirements.txt
|
|
435
|
+
|
|
436
|
+
# 生成(使用 pip-tools)
|
|
437
|
+
pip-compile --generate-hashes requirements.in -o requirements.txt
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**Go**:
|
|
441
|
+
```bash
|
|
442
|
+
# 驗證 go.sum 完整性
|
|
443
|
+
go mod verify
|
|
444
|
+
|
|
445
|
+
# 下載並驗證
|
|
446
|
+
GONOSUMCHECK="" GOFLAGS="-mod=mod" go mod download
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
---
|
|
450
|
+
|
|
451
|
+
## AI Agent 特殊考量
|
|
452
|
+
|
|
453
|
+
本節補充 AI Agent(採用層)相關的容器安全特化要求:
|
|
454
|
+
|
|
455
|
+
### 強制要求
|
|
456
|
+
|
|
457
|
+
| 項目 | 要求 | 說明 |
|
|
458
|
+
|------|------|------|
|
|
459
|
+
| Container UID | 1000(非 root) | LLM 呼叫流程不得以 root 執行 |
|
|
460
|
+
| 出站白名單 | api.anthropic.com / api.openai.com / bedrock.*.amazonaws.com | NetworkPolicy 明確允許 |
|
|
461
|
+
| Guardian OPA Sidecar | 同 Pod 或同 namespace | 才能實施 Veto 決策 |
|
|
462
|
+
| Audit Log Volume | append-only partition | 禁止 emptyDir;重啟後不可消失 |
|
|
463
|
+
| LLM API Key 注入 | Mounted secret volume | 禁止 ENV 注入 |
|
|
464
|
+
| Trivy Gate | 強制(含 Trial/Community) | 避免 supply chain compromise |
|
|
465
|
+
|
|
466
|
+
### Audit Log Volume 配置
|
|
467
|
+
|
|
468
|
+
```yaml
|
|
469
|
+
# ✅ 正確:hostPath 指向 append-only partition
|
|
470
|
+
volumes:
|
|
471
|
+
- name: audit-log
|
|
472
|
+
hostPath:
|
|
473
|
+
path: /var/log/ai-agent/audit # 需事先 chattr +a
|
|
474
|
+
type: DirectoryOrCreate
|
|
475
|
+
|
|
476
|
+
# ❌ 錯誤:emptyDir(重啟消失)
|
|
477
|
+
volumes:
|
|
478
|
+
- name: audit-log
|
|
479
|
+
emptyDir: {}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
在宿主機設定 append-only:
|
|
483
|
+
```bash
|
|
484
|
+
# 設定目錄為 append-only(需 root)
|
|
485
|
+
chattr +a /var/log/ai-agent/audit
|
|
486
|
+
lsattr /var/log/ai-agent/audit # 驗證 a 屬性
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
## 合規對映表
|
|
492
|
+
|
|
493
|
+
| 標準 | 章節 | 對映到本標準 |
|
|
494
|
+
|------|------|------------|
|
|
495
|
+
| ISO/IEC 27001:2022 | A.8.9 Configuration Management | Image Hardening、Runtime Security |
|
|
496
|
+
| ISO/IEC 27001:2022 | A.8.12 Data Leakage Prevention | Secrets Management |
|
|
497
|
+
| ISO/IEC 27001:2022 | A.8.20 Networks Security | Network Policy |
|
|
498
|
+
| ISO/IEC 27001:2022 | A.8.22 Web Filtering | Network Policy 出站白名單 |
|
|
499
|
+
| ISO/IEC 27001:2022 | A.8.8 Technical Vulnerabilities | Registry Security(Trivy)|
|
|
500
|
+
| ISO/IEC 27001:2022 | A.8.24 Use of Cryptography | Secrets Management |
|
|
501
|
+
| NIST SP 800-190 | §4.1 Image Vulnerabilities | Image Hardening |
|
|
502
|
+
| NIST SP 800-190 | §4.2 Image Configuration Defects | Registry Security |
|
|
503
|
+
| NIST SP 800-190 | §4.3 Container Runtime Vulnerabilities | Runtime Security |
|
|
504
|
+
| NIST SP 800-190 | §4.4 Image and Registry Vulnerabilities | Supply Chain |
|
|
505
|
+
| NIST SP 800-190 | §4.5 Host OS Vulnerabilities | Supply Chain |
|
|
506
|
+
| CIS Docker Benchmark v1.6 | §4 Container Images | Image Hardening |
|
|
507
|
+
| CIS Docker Benchmark v1.6 | §5 Container Runtime | Runtime Security |
|
|
508
|
+
| CIS Kubernetes Benchmark v1.8 | §5.3 Network Policies | Network Policy |
|
|
509
|
+
| SLSA Framework | Level 2+ provenance | Supply Chain |
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
## 快速檢查清單
|
|
514
|
+
|
|
515
|
+
```
|
|
516
|
+
□ Base image 固定 digest(不用 tag)
|
|
517
|
+
□ Multi-stage build;只 COPY 產物到 final stage
|
|
518
|
+
□ Final stage:USER 1000(non-root)
|
|
519
|
+
□ securityContext:runAsNonRoot、readOnlyRootFilesystem、allowPrivilegeEscalation:false
|
|
520
|
+
□ capabilities.drop: [ALL]
|
|
521
|
+
□ seccompProfile:RuntimeDefault
|
|
522
|
+
□ Trivy scan:0 critical、0 high,才可推送
|
|
523
|
+
□ Image 已簽章(Cosign / Notary v2)
|
|
524
|
+
□ SBOM 已生成(CycloneDX 或 SPDX)
|
|
525
|
+
□ Dockerfile 無 ENV secret、無 build-arg secret
|
|
526
|
+
□ K8s Secret 或 Vault 注入 secret(非 ENV)
|
|
527
|
+
□ NetworkPolicy:default-deny + 明確 allow
|
|
528
|
+
□ AI Agent egress:allowlist(Anthropic、OpenAI、Bedrock)
|
|
529
|
+
□ Guardian OPA Sidecar:同 Pod 或同 namespace
|
|
530
|
+
□ Audit log volume:append-only partition(非 emptyDir)
|
|
531
|
+
□ Lockfile 固定(npm ci / pip --require-hashes / go mod verify)
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
**Scope**: universal
|
|
@@ -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: 88b78e9c7e7c
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 成本預算測試標準
|
|
11
|
+
|
|
12
|
+
> **Language**: [English](../../../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
|