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,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/license-compliance.md
|
|
3
|
+
source_version: 2.1.0
|
|
4
|
+
translation_version: 2.1.0
|
|
5
|
+
last_synced: 2026-06-10
|
|
6
|
+
source_hash: 8ac1763bd1a1
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 许可证合规标准
|
|
11
|
+
|
|
12
|
+
> **语言**: [English](../../../core/license-compliance.md) | [繁體中文](../../zh-TW/core/license-compliance.md) | 简体中文
|
|
13
|
+
|
|
14
|
+
> **版本**: 2.1.0 | **状态**: Active | **更新日期**: 2026-05-16
|
|
15
|
+
> **AI 优化版本**: `ai/standards/license-compliance.ai.yaml`
|
|
16
|
+
> **Agent Spec**: ASPEC-001 (cross-project/aspec/ASPEC-001-license-compliance-agent.md)
|
|
17
|
+
|
|
18
|
+
**Scope**: universal
|
|
19
|
+
|
|
20
|
+
## 概述
|
|
21
|
+
|
|
22
|
+
面向 AI 增强开发的完整许可证合规标准,涵盖通用 OSS 实践(Tier 1)以及针对 AI 生成代码的 AI 专属规则(Tier 2)。
|
|
23
|
+
|
|
24
|
+
## Tier 1 — 通用 OSS 合规实践
|
|
25
|
+
|
|
26
|
+
适用于所有项目,无论是否使用 AI。
|
|
27
|
+
|
|
28
|
+
| ID | 规则 | 级别 |
|
|
29
|
+
|----|------|------|
|
|
30
|
+
| REQ-001 | 许可证分类与允许列表(allowlist) | MUST |
|
|
31
|
+
| REQ-002 | CI 中的自动化许可证扫描 | MUST |
|
|
32
|
+
| REQ-003 | SBOM 生成(CycloneDX 1.5 或 SPDX 2.3) | MUST |
|
|
33
|
+
| REQ-004 | 许可证署名与 NOTICES 文件 | MUST |
|
|
34
|
+
| REQ-005 | 许可证违规整改(5 个工作日) | MUST |
|
|
35
|
+
| REQ-006 | 采用新技术时的许可证评审 | SHOULD |
|
|
36
|
+
|
|
37
|
+
### 许可证分级
|
|
38
|
+
|
|
39
|
+
| 分级 | 许可证 | 动作 |
|
|
40
|
+
|------|--------|------|
|
|
41
|
+
| APPROVED | MIT, Apache 2.0, BSD-2/3-Clause, ISC, CC0 | 自动批准 |
|
|
42
|
+
| REVIEW-REQUIRED | LGPL-2.1/3.0, MPL-2.0, CDDL | 采用前须法务评审 |
|
|
43
|
+
| PROHIBITED | GPL-2.0/3.0, AGPL-3.0, SSPL-1.0, BUSL-1.1 | 立即阻断 PR |
|
|
44
|
+
|
|
45
|
+
## Tier 2 — AI 专属规则
|
|
46
|
+
|
|
47
|
+
对生成代码的 AI Agent(VibeOps Generator Agent 及同等者)具有约束力。
|
|
48
|
+
|
|
49
|
+
| ID | 规则 | 严重度 |
|
|
50
|
+
|----|------|--------|
|
|
51
|
+
| LC-001 | 必须查询 SPDX ID | Blocking |
|
|
52
|
+
| LC-002 | 阻止列表(blocklist)自动阻断 | Blocking |
|
|
53
|
+
| LC-003 | 允许列表(allowlist)自动批准 | Informational |
|
|
54
|
+
| LC-004 | 灰名单(greylist)人工评审 | Review required |
|
|
55
|
+
| LC-005 | SBOM 强制生成 | Blocking |
|
|
56
|
+
| LC-006 | 版权相似度阈值(≥0.85 阻断) | Blocking |
|
|
57
|
+
| LC-007 | PII 模式检测 | Review required |
|
|
58
|
+
| LC-008 | EU AI Act 透明度标记 | Blocking |
|
|
59
|
+
| LC-009 | 客户策略上限 | Informational |
|
|
60
|
+
|
|
61
|
+
## v2.1.0 增强(XSPEC-193 Phase 2)
|
|
62
|
+
|
|
63
|
+
### ClearlyDefined API(LC-001)
|
|
64
|
+
|
|
65
|
+
- 主要许可证查询来源:`https://api.clearlydefined.io/definitions/{type}/{provider}/{namespace}/{name}/{revision}`
|
|
66
|
+
- 知名包的置信度 ≥ 0.95(score.total ≥ 80)
|
|
67
|
+
- 24h TTL LRU 缓存(cap=500)+ 404 negative cache
|
|
68
|
+
- Token bucket:10 req/s,burst 20
|
|
69
|
+
- 重试策略:5xx → exponential backoff × 3(200ms/1s/3s);429 → batch fallback
|
|
70
|
+
- DEC-064 缓存键隔离:`sha256(client_salt + ':' + purl)`
|
|
71
|
+
|
|
72
|
+
### AST PII 分析(LC-007)
|
|
73
|
+
|
|
74
|
+
- Tree-sitter 支持:TypeScript、JavaScript、Python
|
|
75
|
+
- 上下文分类:
|
|
76
|
+
- `hardcoded_value` → 严重度升级为 `critical`
|
|
77
|
+
- `comment` → 严重度降级为 `info`
|
|
78
|
+
- `schema_field` → 加注,严重度不变
|
|
79
|
+
- `// pii:ignore` pragma:抑制同一行的发现
|
|
80
|
+
- 可选字段:`PIIPattern.confidence`、`PIIPattern.ast_context`
|
|
81
|
+
- tree-sitter 不可用时优雅降级(graceful fallback)为 regex
|
|
82
|
+
|
|
83
|
+
### EmbeddingProvider 策略(LC-006)
|
|
84
|
+
|
|
85
|
+
- `provider='onnx-minilm'`:ONNX 本地推理(all-MiniLM-L6-v2)
|
|
86
|
+
- `provider='ollama-bge-m3'`:Ollama 本地 API(localhost:11434)
|
|
87
|
+
- `provider='jaccard'`:Jaccard token 相似度(Phase 1 基线,默认)
|
|
88
|
+
- 内存中的 snippet 索引(`buildSnippetIndex()`)按客户隔离(DEC-064 salt)
|
|
89
|
+
- 外部搜索:通过 `enableExternalSearch=true` opt-in(默认=false)
|
|
90
|
+
|
|
91
|
+
## 原则
|
|
92
|
+
|
|
93
|
+
| ID | 原则 |
|
|
94
|
+
|----|------|
|
|
95
|
+
| P-1 | SPDX 优先 — 所有许可证 ID 必须是 SPDX 标准 |
|
|
96
|
+
| P-2 | 独立评估者 — 与 Generator 使用不同的模型类别 |
|
|
97
|
+
| P-3 | 证据导向决策 — 每个阻断都附带可追溯的证据 |
|
|
98
|
+
| P-4 | 默认透明 — 必须有 EU AI Act Article 50 标记 |
|
|
99
|
+
| P-5 | 客户主权 — 策略可在 EULA §9 限制内定制 |
|
|
100
|
+
|
|
101
|
+
## 工具序列(XSPEC-193 §2)
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
1. dependency_reader
|
|
105
|
+
2. license_lookup ← ClearlyDefined API (v2.1.0)
|
|
106
|
+
3. license_blocklist_check
|
|
107
|
+
4. sbom_generator
|
|
108
|
+
5. pii_pattern_detector ← AST-enhanced (v2.1.0)
|
|
109
|
+
6. copyright_similarity_check ← EmbeddingProvider (v2.1.0)
|
|
110
|
+
7. eu_ai_act_classifier
|
|
111
|
+
8. transparency_marker
|
|
112
|
+
9. block_pr
|
|
113
|
+
10. suggest_alternative
|
|
114
|
+
11. escalate_to_human
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## 相关规格
|
|
118
|
+
|
|
119
|
+
- XSPEC-193 — License Compliance Agent 完整规格
|
|
120
|
+
- XSPEC-066 — Wave 3 Compliance Pack(v1.0.0 基线)
|
|
121
|
+
- DEC-063 — VibeOps 法务与合规策略
|
|
122
|
+
- DEC-064 — 客户 IP 隔离(cache salt)
|
|
123
|
+
- ASPEC-001 — License Compliance Agent SPEC(XSPEC-205 §REQ-2 格式)
|
|
124
|
+
|
|
125
|
+
## 变更记录
|
|
126
|
+
|
|
127
|
+
| 版本 | 日期 | 变更 |
|
|
128
|
+
|------|------|------|
|
|
129
|
+
| v1.0.0 | 2026-04-30 | 初版 — REQ-001~006 通用 OSS 实践 |
|
|
130
|
+
| v2.0.0 | 2026-05-14 | 新增 Tier 2 LC-001~009 AI 专属规则 |
|
|
131
|
+
| v2.1.0 | 2026-05-16 | ClearlyDefined API + AST PII + EmbeddingProvider + ASPEC-001 引用 |
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/llm-output-validation.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-06-10
|
|
6
|
+
source_hash: 8b7fc8543760
|
|
7
|
+
status: current
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# LLM 输出验证标准
|
|
11
|
+
|
|
12
|
+
> **语言**: [English](../../../core/llm-output-validation.md) | [繁體中文](../../zh-TW/core/llm-output-validation.md) | 简体中文
|
|
13
|
+
|
|
14
|
+
> 标准 ID:`llm-output-validation`
|
|
15
|
+
> 版本:v1.0.0
|
|
16
|
+
> 最后更新:2026-05-05
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 为什么需要 LLM 输出验证?
|
|
21
|
+
|
|
22
|
+
LLM 输出具有**不确定性**:同一个 prompt 在不同时间、不同模型版本下可能产生格式不一致的输出。如果不加以验证,这些输出可能在下游管线中造成静默失败(silent failure)——不是报错,而是用了一个错误的默认值或 `undefined`。
|
|
23
|
+
|
|
24
|
+
LLM 输出验证包含三个层次:
|
|
25
|
+
|
|
26
|
+
| 层次 | 问题 | 工具 |
|
|
27
|
+
|------|------|------|
|
|
28
|
+
| 结构验证 | 输出格式是否正确? | JSON Schema、Zod、Pydantic |
|
|
29
|
+
| 语义验证 | 声称的事实是否有依据? | NLI probe、Grounding check |
|
|
30
|
+
| 行为验证 | Agent 是否正确拒绝越界请求? | 红队语料库、拒绝评估 |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 一、Schema Contract Test(结构验证)
|
|
35
|
+
|
|
36
|
+
### 核心概念
|
|
37
|
+
|
|
38
|
+
每个 AI Agent 应声明一份 `output-schema.json`(JSON Schema 格式),并提供对应的 contract test。
|
|
39
|
+
|
|
40
|
+
**Contract test 的目的**:
|
|
41
|
+
- 确认 schema 本身是合法的 JSON Schema
|
|
42
|
+
- 确认 valid fixtures 通过验证
|
|
43
|
+
- 确认 invalid fixtures(缺少必填字段、类型错误、enum 违规)被拒绝
|
|
44
|
+
|
|
45
|
+
### 推荐目录结构
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
agents/<agent-name>/
|
|
49
|
+
output-schema.json ← JSON Schema 定義
|
|
50
|
+
__tests__/
|
|
51
|
+
contract.test.ts ← Contract test suite
|
|
52
|
+
__fixtures__/
|
|
53
|
+
valid.json ← 真實 LLM 輸出 golden fixture
|
|
54
|
+
invalid-missing-id.json ← 缺少必填欄位的 fixture
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### TypeScript 示例(使用 Ajv)
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import Ajv from "ajv"
|
|
61
|
+
import schema from "../output-schema.json"
|
|
62
|
+
import validFixture from "../__fixtures__/valid.json"
|
|
63
|
+
|
|
64
|
+
const ajv = new Ajv({ strict: false })
|
|
65
|
+
const validate = ajv.compile(schema)
|
|
66
|
+
|
|
67
|
+
// 測試 1:Schema 本身是合法的 JSON Schema
|
|
68
|
+
it("schema is valid JSON Schema", () => {
|
|
69
|
+
expect(ajv.validateSchema(schema)).toBe(true)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
// 測試 2:Valid fixture 通過驗證
|
|
73
|
+
it("valid fixture passes schema", () => {
|
|
74
|
+
expect(validate(validFixture)).toBe(true)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// 測試 3:空 object 被拒絕
|
|
78
|
+
it("empty object is rejected", () => {
|
|
79
|
+
expect(validate({})).toBe(false)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
// 測試 4:缺少 source_agent 被拒絕
|
|
83
|
+
it("object missing source_agent is rejected", () => {
|
|
84
|
+
const { source_agent, ...without } = validFixture
|
|
85
|
+
expect(validate(without)).toBe(false)
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Python 示例(使用 Pydantic)
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from pydantic import ValidationError
|
|
93
|
+
from your_module import AgentOutput
|
|
94
|
+
|
|
95
|
+
# 測試 valid fixture
|
|
96
|
+
valid_data = { "version": "1.0.0", "source_agent": "planner", ... }
|
|
97
|
+
output = AgentOutput(**valid_data) # 不拋出 exception
|
|
98
|
+
|
|
99
|
+
# 測試 invalid fixture
|
|
100
|
+
try:
|
|
101
|
+
AgentOutput(version="bad-format", source_agent="planner")
|
|
102
|
+
assert False, "Should have raised"
|
|
103
|
+
except ValidationError:
|
|
104
|
+
pass # 預期行為
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 二、幻觉检测(Semantic Validation)
|
|
110
|
+
|
|
111
|
+
### 什么是幻觉?
|
|
112
|
+
|
|
113
|
+
LLM 产生「听起来正确但实际上没有依据」的内容。例如:
|
|
114
|
+
- 虚构的 API 文档 URL
|
|
115
|
+
- 不存在的数据库字段名称
|
|
116
|
+
- 未在 context 中出现的 dependency 版本
|
|
117
|
+
|
|
118
|
+
### 检测策略
|
|
119
|
+
|
|
120
|
+
| 策略 | 适用场景 | 自动化程度 |
|
|
121
|
+
|------|---------|-----------|
|
|
122
|
+
| **Schema 结构化输出** | Agent 输出 JSON,enum 限制可能值 | 高(自动) |
|
|
123
|
+
| **Grounding Check** | RAG 系统,回答需引用 context | 中(需 NLI 模型) |
|
|
124
|
+
| **置信度标记** | Agent 在输出中包含 `confidence` 分数 | 中(需 prompt 设计) |
|
|
125
|
+
| **红队语料库** | 主动测试越界请求的拒绝行为 | 高(自动) |
|
|
126
|
+
|
|
127
|
+
### 幻觉率目标
|
|
128
|
+
|
|
129
|
+
| Agent 类型 | Schema 合规率 | 事实幻觉率 |
|
|
130
|
+
|-----------|-------------|----------|
|
|
131
|
+
| 结构化 JSON Agent | ≥ 99% | ≤ 5% |
|
|
132
|
+
| RAG Agent | ≥ 95% | ≤ 5% |
|
|
133
|
+
| 对话 Agent | ≥ 90% | ≤ 10% |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 三、Prompt 回归测试
|
|
138
|
+
|
|
139
|
+
### 何时需要跑 Prompt 回归测试?
|
|
140
|
+
|
|
141
|
+
- 修改任何 `agents/*/prompt.md`
|
|
142
|
+
- 模型版本升级(相同 prompt,不同 model)
|
|
143
|
+
- Schema 新增 required field
|
|
144
|
+
|
|
145
|
+
### 回归测试流程
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# 1. 修改前:用 temperature=0 記錄 golden output
|
|
149
|
+
ai-agent run planner --input fixtures/planner-input.json --temp 0 > golden.json
|
|
150
|
+
|
|
151
|
+
# 2. 修改後:重跑並比對
|
|
152
|
+
ai-agent run planner --input fixtures/planner-input.json --temp 0 > after.json
|
|
153
|
+
|
|
154
|
+
# 3. 用 contract test 驗證 after.json 仍符合 schema
|
|
155
|
+
npx vitest run agents/__tests__/contract.test.ts
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 四、质量门禁(Quality Gates)
|
|
161
|
+
|
|
162
|
+
| 门禁 | 阈值 | 强制程度 |
|
|
163
|
+
|------|------|---------|
|
|
164
|
+
| Schema 合规(CI) | 100% | Block merge |
|
|
165
|
+
| 空 object 拒绝(CI)| 100% | Block merge |
|
|
166
|
+
| Prompt 修改后回归(CI)| schema 合规维持 | Block merge |
|
|
167
|
+
| 幻觉率(pre-release)| ≤ 5% | Advisory |
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 五、工具推荐
|
|
172
|
+
|
|
173
|
+
| 工具 | 语言 | 用途 |
|
|
174
|
+
|------|------|------|
|
|
175
|
+
| [Ajv](https://ajv.js.org/) | TypeScript/JS | JSON Schema contract test |
|
|
176
|
+
| [Zod](https://zod.dev/) | TypeScript | Runtime type validation |
|
|
177
|
+
| [Pydantic](https://docs.pydantic.dev/) | Python | Schema + type validation |
|
|
178
|
+
| [DeepEval](https://deepeval.com/) | Python | LLM 幻觉率、faithfulness 评分 |
|
|
179
|
+
| [Ragas](https://docs.ragas.io/) | Python | RAG grounded answer rate |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 参考标准
|
|
184
|
+
|
|
185
|
+
- NIST AI RMF (AI 100-1, 2023) — AI 风险管理框架
|
|
186
|
+
- OWASP Top 10 for LLM Applications v1.1 — LLM01: Prompt Injection
|
|
187
|
+
- ISO/IEC 42001:2023 — AI 管理体系
|
|
188
|
+
- [UDS `security-testing.ai.yaml`](../../../core/security-testing.md) — SAST + DAST 集成
|
|
189
|
+
- [UDS `adversarial-test.ai.yaml`](../../../core/adversarial-test.md) — Prompt injection 红队标准
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
**Scope**: universal
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
source: ../../../core/logging-standards.md
|
|
3
|
-
source_version: 1.
|
|
4
|
-
translation_version: 1.
|
|
5
|
-
last_synced: 2026-
|
|
3
|
+
source_version: 1.4.0
|
|
4
|
+
translation_version: 1.4.0
|
|
5
|
+
last_synced: 2026-07-08
|
|
6
|
+
source_hash: 732277ef939f
|
|
6
7
|
status: current
|
|
7
8
|
---
|
|
8
9
|
|
|
9
|
-
> **语言**: [English](../../../core/logging-standards.md) |
|
|
10
|
+
> **语言**: [English](../../../core/logging-standards.md) | 简体中文
|
|
10
11
|
|
|
11
12
|
# 日志标准
|
|
12
13
|
|
|
13
|
-
**版本**: 1.
|
|
14
|
-
**最后更新**:
|
|
15
|
-
**适用范围**:
|
|
14
|
+
**版本**: 1.4.0
|
|
15
|
+
**最后更新**: 2026-06-17
|
|
16
|
+
**适用范围**: 所有软件项目
|
|
17
|
+
**范围**: universal
|
|
18
|
+
**行业标准**: RFC 5424, OpenTelemetry, W3C Trace Context
|
|
19
|
+
**参考**: [opentelemetry.io](https://opentelemetry.io/)
|
|
16
20
|
|
|
17
21
|
---
|
|
18
22
|
|
|
@@ -20,6 +24,81 @@ status: current
|
|
|
20
24
|
|
|
21
25
|
本标准定义日志记录的最佳实践,确保日志的一致性、结构化和可操作性。
|
|
22
26
|
|
|
27
|
+
## 强制事件(Mandatory Events)
|
|
28
|
+
|
|
29
|
+
> **关闭** UDS issue [#108](https://github.com/AsiaOstrich/universal-dev-standards/issues/108)(XSPEC-234)。本标准其余部分定义**如何**写一条日志(级别/字段/PII 脱敏/轮转);本节定义**何时必须写**——把「格式合规但实质沉默」的日志排除在外。
|
|
30
|
+
|
|
31
|
+
遵守所有格式规则、却**在关键时刻从不触发**的日志比没有日志还糟:它在事故发生时给人一种虚假的安全感。以下事件是**必须**写日志的 canonical 时机,每项声明 `when`/`must_log`/`must_NOT_log`/`level`/`rationale`。
|
|
32
|
+
|
|
33
|
+
### 为何需要(真实事故)
|
|
34
|
+
|
|
35
|
+
某次 PHP→.NET 迁移耗费 2 天诊断「发送失败、没有日志」,原因是**四层全部沉默**:
|
|
36
|
+
|
|
37
|
+
1. **负载均衡器将后端标记为 DOWN**(503)——health probe 超时;后端只记录了 probe 噪音,零业务事件。
|
|
38
|
+
2. **框架验证 reject**(如 ModelState/DTO 501)——校验框架在任何 handler 执行前就返回,**payload 从未被记录**。
|
|
39
|
+
3. **认证失败**只记录了「Account or password error」——**无 uid、无 source IP** → 无法排查。
|
|
40
|
+
4. **后台 worker 仍存活,但日志文件 0 字节**——没有机制检测到这种沉默。
|
|
41
|
+
|
|
42
|
+
以上都无法仅靠格式规则捕捉,强制事件补上这一缺口。
|
|
43
|
+
|
|
44
|
+
### 类目(9 个 canonical 事件)
|
|
45
|
+
|
|
46
|
+
| id | when(时机) | level | 核心必填字段(`must_log`) | `must_NOT_log` |
|
|
47
|
+
|----|------|-------|-----------------------------------|----------------|
|
|
48
|
+
| `application_startup` | 进程启动后、**接受请求前** | INFO | app_name, version, git_sha, environment, hostname, pid, listening_endpoints | secrets、完整连接字符串 |
|
|
49
|
+
| `request_received` | HTTP 中间件首次看到请求 | INFO / DEBUG | method, path, source_ip, request_id | request body、auth headers |
|
|
50
|
+
| `validation_failure` | schema / ModelState / DTO 验证被拒绝 | WARN | request_id, path, missing_fields[], payload_shape(仅字段名) | 字段**值**、PII |
|
|
51
|
+
| `authentication_failure` | 登录 / token 校验失败 | WARN | uid(尝试值), source_ip, failure_reason | password、token 值 |
|
|
52
|
+
| `outbound_call_start` | 发起对外 HTTP/RPC 调用 | INFO | target_url(host+path), request_id propagated, timeout_ms | credentials、bearer token |
|
|
53
|
+
| `outbound_call_complete` | 外部调用返回或失败 | INFO / WARN / ERROR | status_code **或** failure_phase(dns/tcp/tls/http), elapsed_ms, retries | 含 PII 的 response body |
|
|
54
|
+
| `business_event` | 状态变更类业务操作完成 | INFO | operation_name, actor, target ids, outcome | 完整 record payload、PII |
|
|
55
|
+
| `heartbeat` | 长时间运行的后台服务,≥ 1 次 / 60 秒 | INFO | service_name, queue_depth, items_processed_since_last_heartbeat | — |
|
|
56
|
+
| `shutdown` | 进程退出(正常或致命) | INFO / ERROR | app_name, signal/reason, uptime_seconds, pending_work_count | — |
|
|
57
|
+
|
|
58
|
+
每个事件的 `rationale` 都对应一个真实失效模式:`validation_failure` ⇒ 事故 #2(payload 未记录);`authentication_failure` 字段要求 ⇒ 事故 #3(无 uid/IP);`heartbeat` + 沉默检测 ⇒ 事故 #4(0 字节日志);`application_startup`/`shutdown` ⇒ 生命周期盲区;`outbound_call_*` ⇒「发送失败」却查不到调用痕迹。
|
|
59
|
+
|
|
60
|
+
### 场景
|
|
61
|
+
|
|
62
|
+
#### 场景:验证失败必须产生日志
|
|
63
|
+
|
|
64
|
+
- **GIVEN** API 端点收到缺少 `[Required]` 字段的 payload
|
|
65
|
+
- **WHEN** 框架在 handler 执行前自动 reject(如 400/501)
|
|
66
|
+
- **THEN** 必须写一条 WARN 日志,包含 `request_id`、`path`、`missing_fields[]`、`payload_shape`(仅字段名)
|
|
67
|
+
- **AND** 事后复盘可直接从日志重建失败原因
|
|
68
|
+
|
|
69
|
+
#### 场景:后台服务必须心跳(heartbeat)
|
|
70
|
+
|
|
71
|
+
- **GIVEN** worker 进程正在运行
|
|
72
|
+
- **WHEN** 60 秒内没有写入任何 INFO/WARN/ERROR
|
|
73
|
+
- **THEN** 必须写一条 `heartbeat` 日志,包含当前 queue depth 与自上次心跳以来的处理量
|
|
74
|
+
- **AND** 若连续 ≥ 2 倍心跳间隔(≥ 120 秒)未出现心跳,沉默检测器必须告警
|
|
75
|
+
|
|
76
|
+
### Compliant startup log 示例
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"timestamp": "2026-06-17T08:00:00.000Z",
|
|
81
|
+
"level": "INFO",
|
|
82
|
+
"message": "application_startup",
|
|
83
|
+
"event": "application_startup",
|
|
84
|
+
"app_name": "payment-service",
|
|
85
|
+
"version": "2.3.1",
|
|
86
|
+
"git_sha": "a1b2c3d",
|
|
87
|
+
"environment": "production",
|
|
88
|
+
"hostname": "pod-abc123",
|
|
89
|
+
"pid": 4711,
|
|
90
|
+
"listening_endpoints": ["0.0.0.0:8080", "0.0.0.0:9090/metrics"]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 后续规则
|
|
95
|
+
|
|
96
|
+
1. **访问日志分离**——health probe/liveness 流量不得污染业务事件日志。将 probe 路由至独立 sink/文件,避免其淹没或轮转掉业务事件(见事故 #1)。
|
|
97
|
+
2. **日志沉默检测 SLA**——服务应在连续 N 分钟无事件时告警,N ≤ 2 × `heartbeat` 间隔。缺少预期日志本身就是一种可告警条件(参见下方「Absence of Expected Logs」告警模式)。
|
|
98
|
+
3. **面向运维的日志可发现性**——返回给客户端的错误响应应携带 `request_id`,以便支持人员将用户报告的故障对应到后端日志,无需为查日志来回沟通。
|
|
99
|
+
|
|
100
|
+
> **交叉引用**:`heartbeat`/沉默检测与[日志文件轮转策略](#日志文件轮转策略)互补(0 字节/静默丢弃的日志是同一盲区的两个方向),并与 migration-assistant 的后台任务/副作用完整性互补(这些事件即是可观测的「已触发」证据)。
|
|
101
|
+
|
|
23
102
|
---
|
|
24
103
|
|
|
25
104
|
## 日志级别
|
|
@@ -311,6 +390,123 @@ tracestate: vendor=value
|
|
|
311
390
|
- [ ] 永不记录信用卡
|
|
312
391
|
- [ ] 已配置保留策略
|
|
313
392
|
|
|
393
|
+
### 轮转检查清单
|
|
394
|
+
|
|
395
|
+
- [ ] 已设置时间轮转(`rollingInterval: Day` 或同等配置)
|
|
396
|
+
- [ ] 已设置大小轮转,`rollOnFileSizeLimit: true`(或同等配置)
|
|
397
|
+
- [ ] 已显式配置 `fileSizeLimitBytes`(默认上限会造成危害)
|
|
398
|
+
- [ ] `retainedFileCountLimit` ≥ N×7,以覆盖窗口内的轮转文件
|
|
399
|
+
- [ ] 已定义 90% 大小 SOP:调查噪声根因,不要盲目提高上限
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## 日志文件轮转策略
|
|
404
|
+
|
|
405
|
+
### 轮转策略——必须同时设置两者
|
|
406
|
+
|
|
407
|
+
基于文件的日志接收器配置**必须**包含**两个**触发器:
|
|
408
|
+
|
|
409
|
+
1. **基于时间的轮转**(`rollingInterval: Day` 或同等配置)——按时间分区
|
|
410
|
+
2. **基于大小的轮转**,`rollOnFileSizeLimit: true`(或同等配置)——应对流量峰值
|
|
411
|
+
|
|
412
|
+
> **为何必须:** 大多数日志库默认带有静默的大小上限。当文件达到上限时,后续的日志写入会被**静默丢弃**——无任何警告或错误提示。应用程序继续运行,而半天的日志就此消失。同时显式设置两个触发器可避开这个陷阱。
|
|
413
|
+
|
|
414
|
+
### 生产环境中的默认上限危害
|
|
415
|
+
|
|
416
|
+
| 库 | 默认大小上限 | 达到上限时的行为 |
|
|
417
|
+
|---|---|---|
|
|
418
|
+
| Serilog File sink (.NET) | 1 GB | **静默停止写入**(`RollOnFileSizeLimit = false` 为默认值) |
|
|
419
|
+
| log4j RollingFileAppender | 未设置则无上限 | 同上——不轮转即丢弃 |
|
|
420
|
+
| Python `RotatingFileHandler` | 未设置 `maxBytes` 则无限 | 无限增长 |
|
|
421
|
+
| Winston `winston-daily-rotate-file` | 未设置 `maxSize` 则无上限 | 同上——不轮转即丢弃 |
|
|
422
|
+
|
|
423
|
+
若未显式配置基于大小的轮转,即是接受上述某种失败模式。
|
|
424
|
+
|
|
425
|
+
### 推荐初始值
|
|
426
|
+
|
|
427
|
+
| 参数 | 取值 | 说明 |
|
|
428
|
+
|---|---|---|
|
|
429
|
+
| `fileSizeLimitBytes` | 100 MB | 平衡:足够小以便编辑器打开,足够大以避免过多轮转 |
|
|
430
|
+
| `rollOnFileSizeLimit` | `true` | 达到上限时创建 `*-001.txt`、`*-002.txt`;**不要**丢弃 |
|
|
431
|
+
| `retainedFileCountLimit` | ≥ N×7(N = 每天最大预期轮转次数) | 避免过早删除窗口内的日志 |
|
|
432
|
+
|
|
433
|
+
### 各语言配置示例
|
|
434
|
+
|
|
435
|
+
**.NET / Serilog**(`appsettings.json`):
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
{
|
|
439
|
+
"Serilog": {
|
|
440
|
+
"WriteTo": [{
|
|
441
|
+
"Name": "File",
|
|
442
|
+
"Args": {
|
|
443
|
+
"path": "logs/app-.txt",
|
|
444
|
+
"rollingInterval": "Day",
|
|
445
|
+
"fileSizeLimitBytes": 104857600,
|
|
446
|
+
"rollOnFileSizeLimit": true,
|
|
447
|
+
"retainedFileCountLimit": 90
|
|
448
|
+
}
|
|
449
|
+
}]
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Python**(`logging.handlers`):
|
|
455
|
+
|
|
456
|
+
```python
|
|
457
|
+
from logging.handlers import RotatingFileHandler
|
|
458
|
+
|
|
459
|
+
handler = RotatingFileHandler(
|
|
460
|
+
filename="logs/app.log",
|
|
461
|
+
maxBytes=104857600, # 100 MB
|
|
462
|
+
backupCount=90 # 低基数时约保留 3 个月的轮转文件
|
|
463
|
+
)
|
|
464
|
+
# 如需时间+大小组合轮转,可组合使用 TimedRotatingFileHandler 并检查大小,
|
|
465
|
+
# 或使用第三方库如 concurrent-log-handler。
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**Java / log4j2**(`log4j2.xml`):
|
|
469
|
+
|
|
470
|
+
```xml
|
|
471
|
+
<RollingFile name="App" fileName="logs/app.log"
|
|
472
|
+
filePattern="logs/app-%d{yyyy-MM-dd}-%i.log.gz">
|
|
473
|
+
<PatternLayout pattern="%d %-5p %c{1.} - %m%n"/>
|
|
474
|
+
<Policies>
|
|
475
|
+
<TimeBasedTriggeringPolicy interval="1"/>
|
|
476
|
+
<SizeBasedTriggeringPolicy size="100 MB"/>
|
|
477
|
+
</Policies>
|
|
478
|
+
<DefaultRolloverStrategy max="90"/>
|
|
479
|
+
</RollingFile>
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
**Node / Winston**(`winston-daily-rotate-file`):
|
|
483
|
+
|
|
484
|
+
```javascript
|
|
485
|
+
import DailyRotateFile from "winston-daily-rotate-file";
|
|
486
|
+
|
|
487
|
+
new DailyRotateFile({
|
|
488
|
+
filename: "logs/app-%DATE%.log",
|
|
489
|
+
datePattern: "YYYY-MM-DD",
|
|
490
|
+
maxSize: "100m",
|
|
491
|
+
maxFiles: "90d"
|
|
492
|
+
});
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### 运营 SOP——调查根因,不要仅提高上限
|
|
496
|
+
|
|
497
|
+
若日志文件大小在预计当天结束时达到 `fileSizeLimitBytes` 的 ≥ 90%,**在提高上限之前先调查原因**。典型根因:
|
|
498
|
+
|
|
499
|
+
- 在 INFO 级别记录每次重试的嘈杂重试循环(应改为 WARN 摘要)
|
|
500
|
+
- 意外在生产环境启用的无限制 debug 日志
|
|
501
|
+
- 单个上游故障引发的堆栈跟踪洪流
|
|
502
|
+
- 健康探针 / sidecar 污染业务日志
|
|
503
|
+
|
|
504
|
+
提高上限只会掩盖底层噪声问题,并将下一次故障推迟到更远的未来。
|
|
505
|
+
|
|
506
|
+
### 失败模式参考(真实事故)
|
|
507
|
+
|
|
508
|
+
某生产 .NET Worker 仅使用 `rollingInterval: Day`(未设置大小限制,Serilog 默认 1 GB 上限),在 07:31 触达上限后静默丢弃了所有日志条目,直到 13:00+ 运维人员发现日志尾部已停止更新。连续 5 个日志文件均显示 `~1,073,741,8XX 字节`(= 1 GiB,Serilog 默认值)。半天的生产诊断数据就此丢失。同时设置 `fileSizeLimitBytes` 和 `rollOnFileSizeLimit: true` 本可在保留所有事件的情况下将文件轮转为 `worker-YYYYMMDD_001.txt`。
|
|
509
|
+
|
|
314
510
|
---
|
|
315
511
|
|
|
316
512
|
## 相关标准
|
|
@@ -324,6 +520,8 @@ tracestate: vendor=value
|
|
|
324
520
|
|
|
325
521
|
| 版本 | 日期 | 变更 |
|
|
326
522
|
|-----|------|------|
|
|
523
|
+
| 1.4.0 | 2026-06-17 | 新增:强制事件类目——9 个 canonical「何时必须写日志」事件(when/must_log/must_NOT_log/level/rationale)、验证失败 + heartbeat 场景、compliant startup 示例、后续规则(访问日志分离、沉默检测 SLA、request_id 可发现性)(XSPEC-234 / 关闭 issue #108) |
|
|
524
|
+
| 1.3.0 | 2026-05-26 | 新增:日志文件轮转策略——强制双触发器(时间 + 大小)轮转,含默认上限危害警告、各语言(.NET/Python/Java/Node)配置示例、运营 SOP(XSPEC-232 / 关闭 issue #111) |
|
|
327
525
|
| 1.2.0 | 2026-01-24 | 新增:OpenTelemetry 语义规范、可观测性三支柱整合、基于日志的告警、进阶关联模式 |
|
|
328
526
|
| 1.1.0 | 2026-01-05 | 新增:参考标准章节,包含 OWASP、RFC 5424、OpenTelemetry 和 12 Factor App |
|
|
329
527
|
| 1.0.0 | 2025-12-30 | 初始日志标准 |
|