@dommaker/harness 1.3.0 → 1.5.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/CHANGELOG.md +20 -0
- package/README.md +0 -2
- package/bin/harness.js +86 -32
- package/dist/cli/command-contract.d.ts +83 -0
- package/dist/cli/command-contract.d.ts.map +1 -0
- package/dist/cli/command-contract.js +66 -0
- package/dist/cli/command-contract.js.map +1 -0
- package/dist/cli/commands/acceptance.d.ts +3 -2
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +28 -24
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/analyze-sessions.d.ts +2 -1
- package/dist/cli/commands/analyze-sessions.d.ts.map +1 -1
- package/dist/cli/commands/analyze-sessions.js +25 -24
- package/dist/cli/commands/analyze-sessions.js.map +1 -1
- package/dist/cli/commands/check.d.ts +14 -2
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +104 -61
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/command.d.ts +5 -1
- package/dist/cli/commands/command.d.ts.map +1 -1
- package/dist/cli/commands/command.js +26 -17
- package/dist/cli/commands/command.js.map +1 -1
- package/dist/cli/commands/constraints-report.d.ts +2 -1
- package/dist/cli/commands/constraints-report.d.ts.map +1 -1
- package/dist/cli/commands/constraints-report.js +37 -33
- package/dist/cli/commands/constraints-report.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +6 -5
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +50 -52
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/constraints.d.ts +2 -1
- package/dist/cli/commands/constraints.d.ts.map +1 -1
- package/dist/cli/commands/constraints.js +10 -27
- package/dist/cli/commands/constraints.js.map +1 -1
- package/dist/cli/commands/contract.d.ts +3 -2
- package/dist/cli/commands/contract.d.ts.map +1 -1
- package/dist/cli/commands/contract.js +45 -42
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts +11 -11
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +27 -219
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/failure.d.ts +5 -4
- package/dist/cli/commands/failure.d.ts.map +1 -1
- package/dist/cli/commands/failure.js +31 -25
- package/dist/cli/commands/failure.js.map +1 -1
- package/dist/cli/commands/init.d.ts +7 -5
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +147 -211
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/knowledge.d.ts +17 -30
- package/dist/cli/commands/knowledge.d.ts.map +1 -1
- package/dist/cli/commands/knowledge.js +183 -273
- package/dist/cli/commands/knowledge.js.map +1 -1
- package/dist/cli/commands/passes-gate.d.ts +8 -2
- package/dist/cli/commands/passes-gate.d.ts.map +1 -1
- package/dist/cli/commands/passes-gate.js +44 -66
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/performance.d.ts +2 -1
- package/dist/cli/commands/performance.d.ts.map +1 -1
- package/dist/cli/commands/performance.js +20 -18
- package/dist/cli/commands/performance.js.map +1 -1
- package/dist/cli/commands/posteval-plan.d.ts +5 -1
- package/dist/cli/commands/posteval-plan.d.ts.map +1 -1
- package/dist/cli/commands/posteval-plan.js +26 -15
- package/dist/cli/commands/posteval-plan.js.map +1 -1
- package/dist/cli/commands/release.d.ts +6 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +69 -59
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/report.d.ts +2 -1
- package/dist/cli/commands/report.d.ts.map +1 -1
- package/dist/cli/commands/report.js +9 -5
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/review.d.ts +3 -2
- package/dist/cli/commands/review.d.ts.map +1 -1
- package/dist/cli/commands/review.js +33 -29
- package/dist/cli/commands/review.js.map +1 -1
- package/dist/cli/commands/sdd.d.ts +2 -1
- package/dist/cli/commands/sdd.d.ts.map +1 -1
- package/dist/cli/commands/sdd.js +7 -5
- package/dist/cli/commands/sdd.js.map +1 -1
- package/dist/cli/commands/security.d.ts +3 -2
- package/dist/cli/commands/security.d.ts.map +1 -1
- package/dist/cli/commands/security.js +29 -26
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts +2 -1
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +15 -11
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/spec.d.ts +7 -2
- package/dist/cli/commands/spec.d.ts.map +1 -1
- package/dist/cli/commands/spec.js +61 -51
- package/dist/cli/commands/spec.js.map +1 -1
- package/dist/cli/commands/status.d.ts +2 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +57 -53
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +5 -2
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +3 -2
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts +2 -1
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +68 -88
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts +6 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +14 -16
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/commands/update-user-model.d.ts +9 -3
- package/dist/cli/commands/update-user-model.d.ts.map +1 -1
- package/dist/cli/commands/update-user-model.js +56 -61
- package/dist/cli/commands/update-user-model.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +4 -3
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +28 -26
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/session-mining/transcript.d.ts +7 -1
- package/dist/cli/session-mining/transcript.d.ts.map +1 -1
- package/dist/cli/session-mining/transcript.js +21 -14
- package/dist/cli/session-mining/transcript.js.map +1 -1
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +19 -32
- package/dist/context/session-manager.js.map +1 -1
- package/dist/core/constraints/agent-prompt-renderer.d.ts.map +1 -1
- package/dist/core/constraints/agent-prompt-renderer.js +1 -4
- package/dist/core/constraints/agent-prompt-renderer.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +24 -7
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +32 -28
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/capabilities-reconcile.d.ts +67 -0
- package/dist/core/constraints/capabilities-reconcile.d.ts.map +1 -0
- package/dist/core/constraints/capabilities-reconcile.js +105 -0
- package/dist/core/constraints/capabilities-reconcile.js.map +1 -0
- package/dist/core/constraints/checker.d.ts +21 -43
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +68 -117
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts +20 -8
- package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +66 -77
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.d.ts +4 -2
- package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.js +13 -22
- package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.d.ts.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js +49 -66
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.d.ts +2 -2
- package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.js +7 -28
- package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
- package/dist/core/constraints/checkers/index.d.ts +2 -2
- package/dist/core/constraints/checkers/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/index.js +2 -1
- package/dist/core/constraints/checkers/index.js.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.js +4 -3
- package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +43 -4
- package/dist/core/constraints/checkers/types.d.ts.map +1 -1
- package/dist/core/constraints/checkers/types.js +33 -0
- package/dist/core/constraints/checkers/types.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts +15 -14
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +32 -96
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +2 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/git-evidence.d.ts +60 -0
- package/dist/core/constraints/git-evidence.d.ts.map +1 -0
- package/dist/core/constraints/git-evidence.js +88 -0
- package/dist/core/constraints/git-evidence.js.map +1 -0
- package/dist/core/constraints/injection-drift.d.ts +3 -20
- package/dist/core/constraints/injection-drift.d.ts.map +1 -1
- package/dist/core/constraints/injection-drift.js +10 -57
- package/dist/core/constraints/injection-drift.js.map +1 -1
- package/dist/core/constraints/injection-writer.d.ts +113 -0
- package/dist/core/constraints/injection-writer.d.ts.map +1 -0
- package/dist/core/constraints/injection-writer.js +228 -0
- package/dist/core/constraints/injection-writer.js.map +1 -0
- package/dist/core/constraints/usage-report.d.ts +22 -1
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +27 -20
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +32 -1
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +39 -9
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +15 -64
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +84 -222
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/core/validators/test-output.d.ts +58 -0
- package/dist/core/validators/test-output.d.ts.map +1 -0
- package/dist/core/validators/test-output.js +109 -0
- package/dist/core/validators/test-output.js.map +1 -0
- package/dist/failure/recorder.d.ts +6 -0
- package/dist/failure/recorder.d.ts.map +1 -1
- package/dist/failure/recorder.js +12 -8
- package/dist/failure/recorder.js.map +1 -1
- package/dist/gates/acceptance.d.ts +1 -48
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +6 -38
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/checker-gate.d.ts +2 -1
- package/dist/gates/checker-gate.d.ts.map +1 -1
- package/dist/gates/checker-gate.js +11 -13
- package/dist/gates/checker-gate.js.map +1 -1
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +10 -22
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +22 -61
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +13 -31
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +21 -53
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +14 -32
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +28 -5
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/gates/types.js +38 -1
- package/dist/gates/types.js.map +1 -1
- package/dist/hooks/bootstrap.d.ts +2 -0
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +5 -2
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit.d.ts +7 -2
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +59 -79
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/flywheel-metrics.d.ts +39 -0
- package/dist/knowledge/flywheel-metrics.d.ts.map +1 -0
- package/dist/knowledge/flywheel-metrics.js +47 -0
- package/dist/knowledge/flywheel-metrics.js.map +1 -0
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +4 -14
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +17 -14
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +9 -4
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/migration.d.ts.map +1 -1
- package/dist/knowledge/migration.js +11 -8
- package/dist/knowledge/migration.js.map +1 -1
- package/dist/knowledge/reference-tracker.d.ts.map +1 -1
- package/dist/knowledge/reference-tracker.js +12 -9
- package/dist/knowledge/reference-tracker.js.map +1 -1
- package/dist/knowledge/store.d.ts +15 -0
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +59 -10
- package/dist/knowledge/store.js.map +1 -1
- package/dist/monitoring/context-tracker.d.ts.map +1 -1
- package/dist/monitoring/context-tracker.js +11 -20
- package/dist/monitoring/context-tracker.js.map +1 -1
- package/dist/monitoring/index.d.ts +1 -1
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/index.js +1 -2
- package/dist/monitoring/index.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +15 -0
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +19 -2
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +21 -2
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +38 -29
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/release/index.d.ts +2 -2
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +1 -5
- package/dist/release/index.js.map +1 -1
- package/dist/sdd/index-generator.js +10 -11
- package/dist/sdd/index-generator.js.map +1 -1
- package/dist/test-setup/project-fixture.d.ts +48 -0
- package/dist/test-setup/project-fixture.d.ts.map +1 -0
- package/dist/test-setup/project-fixture.js +106 -0
- package/dist/test-setup/project-fixture.js.map +1 -0
- package/dist/types/constraint.d.ts +8 -18
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js +6 -1
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/passes-gate.d.ts +10 -25
- package/dist/types/passes-gate.d.ts.map +1 -1
- package/dist/types/project-config.d.ts +1 -1
- package/dist/types/session.d.ts +6 -5
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/trace.d.ts +9 -0
- package/dist/types/trace.d.ts.map +1 -1
- package/dist/utils/exec.d.ts +10 -0
- package/dist/utils/exec.d.ts.map +1 -1
- package/dist/utils/exec.js +12 -0
- package/dist/utils/exec.js.map +1 -1
- package/dist/utils/file-walk.d.ts +9 -1
- package/dist/utils/file-walk.d.ts.map +1 -1
- package/dist/utils/file-walk.js +10 -1
- package/dist/utils/file-walk.js.map +1 -1
- package/dist/utils/frontmatter.d.ts +73 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +141 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/jsonl.d.ts +92 -0
- package/dist/utils/jsonl.d.ts.map +1 -0
- package/dist/utils/jsonl.js +166 -0
- package/dist/utils/jsonl.js.map +1 -0
- package/dist/utils/package-version.d.ts +16 -0
- package/dist/utils/package-version.d.ts.map +1 -0
- package/dist/utils/package-version.js +63 -0
- package/dist/utils/package-version.js.map +1 -0
- package/package.json +1 -1
- package/src/CONTEXT.md +8 -2
- package/src/__tests__/acceptance-gate.test.ts +3 -1
- package/src/__tests__/checker-extra.test.ts +7 -1218
- package/src/__tests__/context-files-resolution.test.ts +116 -0
- package/src/__tests__/effective-constraints.test.ts +10 -13
- package/src/__tests__/exec.test.ts +35 -1
- package/src/__tests__/layering.test.ts +152 -0
- package/src/__tests__/passes-gate-extra.test.ts +0 -145
- package/src/__tests__/passes-gate.test.ts +130 -101
- package/src/__tests__/skip-semantics.test.ts +5 -9
- package/src/cli/__tests__/command-contract.test.ts +170 -0
- package/src/cli/command-contract.ts +108 -0
- package/src/cli/commands/CONTEXT.md +23 -8
- package/src/cli/commands/__tests__/acceptance.test.ts +40 -33
- package/src/cli/commands/__tests__/analyze-sessions.test.ts +35 -29
- package/src/cli/commands/__tests__/bin-exit-mapping.test.ts +107 -0
- package/src/cli/commands/__tests__/check-drift.test.ts +27 -34
- package/src/cli/commands/__tests__/check-skip-output.test.ts +21 -24
- package/src/cli/commands/__tests__/check.test.ts +448 -378
- package/src/cli/commands/__tests__/command.test.ts +85 -70
- package/src/cli/commands/__tests__/constraints-report.test.ts +100 -71
- package/src/cli/commands/__tests__/constraints-retire.test.ts +152 -95
- package/src/cli/commands/__tests__/contract.test.ts +27 -34
- package/src/cli/commands/__tests__/failure.test.ts +31 -34
- package/src/cli/commands/__tests__/init-injection.test.ts +58 -28
- package/src/cli/commands/__tests__/init.test.ts +77 -48
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +108 -0
- package/src/cli/commands/__tests__/knowledge.test.ts +69 -43
- package/src/cli/commands/__tests__/passes-gate.test.ts +43 -45
- package/src/cli/commands/__tests__/performance.test.ts +22 -23
- package/src/cli/commands/__tests__/posteval-plan.test.ts +39 -38
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +157 -0
- package/src/cli/commands/__tests__/project-path-convention.test.ts +231 -0
- package/src/cli/commands/__tests__/registry.test.ts +75 -35
- package/src/cli/commands/__tests__/release.test.ts +209 -80
- package/src/cli/commands/__tests__/report-extra.test.ts +16 -16
- package/src/cli/commands/__tests__/report.test.ts +25 -25
- package/src/cli/commands/__tests__/review.test.ts +33 -31
- package/src/cli/commands/__tests__/security.test.ts +23 -27
- package/src/cli/commands/__tests__/spec-baseline-check.test.ts +20 -20
- package/src/cli/commands/__tests__/spec.test.ts +41 -29
- package/src/cli/commands/__tests__/status-extra.test.ts +18 -18
- package/src/cli/commands/__tests__/status-skipped-lines.test.ts +72 -0
- package/src/cli/commands/__tests__/status.test.ts +34 -34
- package/src/cli/commands/__tests__/sync-docs-agents.test.ts +77 -78
- package/src/cli/commands/__tests__/sync-docs.test.ts +72 -74
- package/src/cli/commands/__tests__/update-user-model.test.ts +97 -34
- package/src/cli/commands/__tests__/validate.test.ts +27 -29
- package/src/cli/commands/acceptance.ts +35 -24
- package/src/cli/commands/analyze-sessions.ts +25 -24
- package/src/cli/commands/check.ts +127 -66
- package/src/cli/commands/command.ts +30 -17
- package/src/cli/commands/constraints-report.ts +37 -34
- package/src/cli/commands/constraints-retire.ts +58 -55
- package/src/cli/commands/constraints.ts +10 -27
- package/src/cli/commands/contract.ts +51 -42
- package/src/cli/commands/definitions.ts +34 -227
- package/src/cli/commands/failure.ts +33 -26
- package/src/cli/commands/init.ts +166 -220
- package/src/cli/commands/knowledge.ts +192 -289
- package/src/cli/commands/passes-gate.ts +58 -68
- package/src/cli/commands/performance.ts +23 -18
- package/src/cli/commands/posteval-plan.ts +29 -15
- package/src/cli/commands/release.ts +70 -59
- package/src/cli/commands/report.ts +9 -5
- package/src/cli/commands/review.ts +39 -29
- package/src/cli/commands/sdd.ts +7 -5
- package/src/cli/commands/security.ts +35 -26
- package/src/cli/commands/spec-baseline-check.ts +16 -11
- package/src/cli/commands/spec.ts +66 -53
- package/src/cli/commands/status.ts +59 -53
- package/src/cli/commands/sync-docs/agents-syncer.ts +5 -2
- package/src/cli/commands/sync-docs/context-syncer.ts +3 -2
- package/src/cli/commands/sync-docs/index.ts +73 -100
- package/src/cli/commands/sync-docs/project-reader.ts +17 -18
- package/src/cli/commands/update-user-model.ts +64 -61
- package/src/cli/commands/validate.ts +31 -25
- package/src/cli/session-mining/__tests__/transcript.test.ts +118 -0
- package/src/cli/session-mining/transcript.ts +26 -8
- package/src/context/session-manager.ts +19 -33
- package/src/core/CONTEXT.md +10 -6
- package/src/core/constraints/__tests__/capabilities-reconcile.test.ts +200 -0
- package/src/core/constraints/__tests__/capability-counts.test.ts +94 -0
- package/src/core/constraints/__tests__/git-evidence.test.ts +208 -0
- package/src/core/constraints/__tests__/injection-drift.test.ts +3 -10
- package/src/core/constraints/__tests__/injection-writer.test.ts +231 -0
- package/src/core/constraints/__tests__/trace-injection.test.ts +71 -0
- package/src/core/constraints/__tests__/usage-report.test.ts +112 -0
- package/src/core/constraints/agent-prompt-renderer.ts +2 -6
- package/src/core/constraints/capabilities-parser.ts +53 -35
- package/src/core/constraints/capabilities-reconcile.ts +166 -0
- package/src/core/constraints/checker.ts +82 -133
- package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +273 -0
- package/src/core/constraints/checkers/__tests__/check-outcome.test.ts +176 -0
- package/src/core/constraints/checkers/__tests__/context-doc-sync.test.ts +77 -0
- package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +126 -0
- package/src/{__tests__ → core/constraints/checkers/__tests__}/governance-presence.test.ts +83 -9
- package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +50 -0
- package/src/core/constraints/checkers/__tests__/no-bypass-checkpoint.test.ts +76 -0
- package/src/{__tests__ → core/constraints/checkers/__tests__}/no-hardcoded-credentials.test.ts +4 -3
- package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +58 -0
- package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +153 -0
- package/src/core/constraints/checkers/capability-sync.ts +75 -96
- package/src/core/constraints/checkers/context-doc-sync.ts +15 -25
- package/src/core/constraints/checkers/docs-freshness.ts +54 -70
- package/src/core/constraints/checkers/governance-presence.ts +7 -25
- package/src/core/constraints/checkers/index.ts +9 -2
- package/src/core/constraints/checkers/no-test-simplification.ts +4 -3
- package/src/core/constraints/checkers/types.ts +60 -4
- package/src/core/constraints/context-builder.ts +39 -91
- package/src/core/constraints/doc-freshness/runner.ts +2 -1
- package/src/core/constraints/git-evidence.ts +120 -0
- package/src/core/constraints/injection-drift.ts +13 -60
- package/src/core/constraints/injection-writer.ts +212 -0
- package/src/core/constraints/usage-report.ts +36 -17
- package/src/core/index.ts +4 -2
- package/src/core/project-config-loader.ts +49 -9
- package/src/core/validators/__tests__/passes-gate.test.ts +2 -56
- package/src/core/validators/__tests__/test-output.test.ts +372 -0
- package/src/core/validators/passes-gate.ts +86 -248
- package/src/core/validators/test-output.ts +128 -0
- package/src/failure/__tests__/recorder.test.ts +168 -0
- package/src/failure/recorder.ts +12 -10
- package/src/gates/CONTEXT.md +7 -4
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +68 -0
- package/src/gates/__tests__/acceptance.test.ts +4 -86
- package/src/gates/__tests__/checker-gate.test.ts +24 -0
- package/src/gates/__tests__/effective-gates.test.ts +3 -8
- package/src/gates/__tests__/test-verdict-consistency.test.ts +140 -0
- package/src/gates/acceptance.ts +19 -84
- package/src/gates/checker-gate.ts +12 -15
- package/src/gates/command.ts +10 -16
- package/src/gates/contract.ts +22 -61
- package/src/gates/performance.ts +10 -22
- package/src/gates/review.ts +21 -41
- package/src/gates/security.ts +10 -22
- package/src/gates/types.ts +70 -5
- package/src/hooks/CONTEXT.md +1 -1
- package/src/hooks/bootstrap.ts +5 -2
- package/src/index.ts +0 -4
- package/src/knowledge/CONTEXT.md +8 -3
- package/src/knowledge/__tests__/audit-labels.test.ts +44 -0
- package/src/knowledge/__tests__/flywheel-metrics.test.ts +135 -0
- package/src/knowledge/__tests__/import.test.ts +44 -0
- package/src/knowledge/__tests__/index-generator.test.ts +53 -0
- package/src/knowledge/__tests__/ingest.test.ts +85 -0
- package/src/knowledge/__tests__/migration.test.ts +47 -0
- package/src/knowledge/__tests__/reference-tracker.test.ts +16 -0
- package/src/knowledge/__tests__/store.test.ts +194 -0
- package/src/knowledge/audit.ts +67 -71
- package/src/knowledge/flywheel-metrics.ts +71 -0
- package/src/knowledge/import.ts +4 -18
- package/src/knowledge/index-generator.ts +19 -14
- package/src/knowledge/ingest.ts +9 -4
- package/src/knowledge/migration.ts +11 -8
- package/src/knowledge/reference-tracker.ts +12 -8
- package/src/knowledge/store.ts +64 -11
- package/src/monitoring/CONTEXT.md +8 -3
- package/src/monitoring/__tests__/skipped-lines-report.test.ts +178 -0
- package/src/monitoring/__tests__/traces.test.ts +57 -0
- package/src/monitoring/context-tracker.ts +11 -23
- package/src/monitoring/index.ts +1 -1
- package/src/monitoring/trace-analyzer.ts +21 -2
- package/src/monitoring/traces.ts +39 -36
- package/src/release/CONTEXT.md +1 -0
- package/src/release/__tests__/barrel.test.ts +60 -0
- package/src/release/index.ts +2 -13
- package/src/sdd/__tests__/index-generator.test.ts +71 -0
- package/src/sdd/index-generator.ts +9 -9
- package/src/test-setup/__tests__/project-fixture.test.ts +178 -0
- package/src/test-setup/project-fixture.ts +87 -0
- package/src/tools/CONTEXT.md +6 -0
- package/src/tools/__tests__/registry.test.ts +221 -0
- package/src/types/__tests__/types.test.ts +4 -5
- package/src/types/constraint.ts +16 -27
- package/src/types/passes-gate.ts +10 -30
- package/src/types/project-config.ts +1 -1
- package/src/types/session.ts +5 -5
- package/src/types/trace.ts +10 -0
- package/src/utils/__tests__/frontmatter.test.ts +206 -0
- package/src/utils/__tests__/jsonl-skip-disposition.test.ts +175 -0
- package/src/utils/__tests__/jsonl.test.ts +187 -0
- package/src/utils/__tests__/package-version.test.ts +97 -0
- package/src/utils/exec.ts +15 -0
- package/src/utils/file-walk.ts +11 -2
- package/src/utils/frontmatter.ts +121 -0
- package/src/utils/jsonl.ts +167 -0
- package/src/utils/package-version.ts +27 -0
- package/dist/cli/commands/doc-freshness-check.d.ts +0 -53
- package/dist/cli/commands/doc-freshness-check.d.ts.map +0 -1
- package/dist/cli/commands/doc-freshness-check.js +0 -352
- package/dist/cli/commands/doc-freshness-check.js.map +0 -1
- package/dist/types/index.d.ts +0 -14
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -39
- package/dist/types/index.js.map +0 -1
- package/src/__tests__/long-running.test.ts +0 -17
- package/src/__tests__/passes-gate-extension.test.ts +0 -151
- package/src/cli/commands/__tests__/doc-freshness-check.test.ts +0 -168
- package/src/cli/commands/doc-freshness-check.ts +0 -386
- package/src/spec/CONTEXT.md +0 -11
- package/src/types/index.ts +0 -47
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* capability_sync 检查器旁测(ADR-0009 / 架构评审候选4)
|
|
3
|
+
*
|
|
4
|
+
* 测试面 = ConstraintCheck.evaluate(env):证据经 EvidenceProviders 注入,
|
|
5
|
+
* 不再绕 engine facade(checker.check)与真实 git staging。
|
|
6
|
+
* 自 checker-extra.test.ts 迁入并改写驱动方式;断言语义逐条保持。
|
|
7
|
+
* 项目根由 src/test-setup/project-fixture 声明式构造(回收仍走 mkdtemp-cleanup)。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect, jest } from '@jest/globals';
|
|
11
|
+
import { capabilitySync } from '../capability-sync';
|
|
12
|
+
import { buildCheckEnv, normalizeCheckOutcome, type CheckEnv, type CheckOutcome } from '../types';
|
|
13
|
+
import { collectSourceFiles } from '../../capabilities-reconcile';
|
|
14
|
+
import { createProjectFixture } from '../../../../test-setup/project-fixture';
|
|
15
|
+
import type { ConstraintContext } from '../../../../types/constraint';
|
|
16
|
+
|
|
17
|
+
const TABLE_HEAD = '| 模块 | 文件 | 说明 |\n|------|------|------|\n';
|
|
18
|
+
|
|
19
|
+
function setupDir(
|
|
20
|
+
name: string,
|
|
21
|
+
capContent: string,
|
|
22
|
+
files: string[] = [],
|
|
23
|
+
mode?: 'file' | 'module'
|
|
24
|
+
): string {
|
|
25
|
+
return createProjectFixture({
|
|
26
|
+
name: `cap-sync-${name}`,
|
|
27
|
+
config: mode ? `governance:\n capabilities:\n mode: ${mode}\n` : undefined,
|
|
28
|
+
files: {
|
|
29
|
+
'CAPABILITIES.md': capContent,
|
|
30
|
+
...Object.fromEntries(files.map(f => [f, 'export const x = 1;'])),
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** stub staged 清单;srcScan 缺省走真实 fs(与被检文件一致),传 scan 则按根覆写 */
|
|
36
|
+
function makeEnv(
|
|
37
|
+
projectPath: string,
|
|
38
|
+
staged: string[],
|
|
39
|
+
scan?: Record<string, string[]>
|
|
40
|
+
): CheckEnv {
|
|
41
|
+
const context: ConstraintContext = { operation: 'commit', projectPath };
|
|
42
|
+
return buildCheckEnv(context, {
|
|
43
|
+
stagedDiff: async () => '',
|
|
44
|
+
stagedDiffNames: async () => staged.join('\n'),
|
|
45
|
+
srcScan: (root: string) =>
|
|
46
|
+
scan ? scan[root] ?? [] : collectSourceFiles(projectPath, [root]),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** 判定归一:boolean 与 CheckDetail 两种返回形状统一断言(harness#119) */
|
|
51
|
+
const passed = (outcome: CheckOutcome): boolean => normalizeCheckOutcome(outcome).satisfied;
|
|
52
|
+
/** 证据行拼成单串,便于按路径断言 */
|
|
53
|
+
const evidenceText = (outcome: CheckOutcome): string =>
|
|
54
|
+
normalizeCheckOutcome(outcome).evidence.join('\n');
|
|
55
|
+
|
|
56
|
+
describe('capability_sync — skip 与文档格式门槛', () => {
|
|
57
|
+
it('无 CAPABILITIES.md → skip(ADR-0001 存在性探测,有无变更都一样)', async () => {
|
|
58
|
+
const dir = createProjectFixture({ name: 'cap-sync-none' });
|
|
59
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe('skip');
|
|
60
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, ['src/foo.ts']))).toBe('skip');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('散文文档(无表格)+ 有变更 → 放行(历史语义)', async () => {
|
|
64
|
+
const dir = setupDir('prose', '# Capabilities\n\n- Feature: test', ['feature.ts']);
|
|
65
|
+
expect(passed(await capabilitySync.evaluate(makeEnv(dir, ['feature.ts'])))).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('清单格式(计数行)→ 放行,计数由 sync-docs 维护', async () => {
|
|
69
|
+
const dir = setupDir('listing', '# Capabilities\n\n## CLI Commands (25)\ncheck, validate\n');
|
|
70
|
+
expect(passed(await capabilitySync.evaluate(makeEnv(dir, ['src/foo.ts'])))).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('有表格但零条目 + 有变更 → 不得放行(step1 拦下,证据点名变更文件)', async () => {
|
|
74
|
+
const dir = setupDir('empty-table', `# Capabilities\n\n${TABLE_HEAD}`);
|
|
75
|
+
const outcome = await capabilitySync.evaluate(makeEnv(dir, ['src/foo.ts']));
|
|
76
|
+
expect(passed(outcome)).toBe(false);
|
|
77
|
+
expect(evidenceText(outcome)).toContain('src/foo.ts');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('有表格但零条目 + 源码有文件 → 文档退化门拦下(不靠 step2 兜,harness#119)', async () => {
|
|
81
|
+
const dir = setupDir('empty-table-scan', `# Capabilities\n\n${TABLE_HEAD}`, ['src/foo.ts']);
|
|
82
|
+
const outcome = await capabilitySync.evaluate(makeEnv(dir, []));
|
|
83
|
+
expect(passed(outcome)).toBe(false);
|
|
84
|
+
expect(evidenceText(outcome)).toContain('零条目');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('有表格但零条目 + 源码无文件 → 放行(门限定「确有可登记对象」,不扩大 fail 面)', async () => {
|
|
88
|
+
const dir = setupDir('empty-table-nosrc', `# Capabilities\n\n${TABLE_HEAD}`);
|
|
89
|
+
expect(passed(await capabilitySync.evaluate(makeEnv(dir, [])))).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('capability_sync — step1 增量覆盖(唯一判违规处,harness#119)', () => {
|
|
94
|
+
const run = (dir: string, staged: string[]) =>
|
|
95
|
+
capabilitySync.evaluate(makeEnv(dir, staged, {}));
|
|
96
|
+
|
|
97
|
+
it('变更文件未被登记 → 失败,且证据点名该文件', async () => {
|
|
98
|
+
const dir = setupDir('step1-uncovered', `# C\n\n${TABLE_HEAD}| 旧 | old/module.ts | 旧 |\n`);
|
|
99
|
+
const outcome = await run(dir, ['new-module.ts']);
|
|
100
|
+
expect(passed(outcome)).toBe(false);
|
|
101
|
+
expect(evidenceText(outcome)).toContain('new-module.ts');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('变更文件按登记路径覆盖 → 通过', async () => {
|
|
105
|
+
const dir = setupDir('step1-covered', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
106
|
+
expect(passed(await run(dir, ['src/foo.ts']))).toBe(true);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('每个变更文件都必须被覆盖(every 而非 some)', async () => {
|
|
110
|
+
const dir = setupDir('step1-every', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
111
|
+
const outcome = await run(dir, ['src/foo.ts', 'scripts/bar.ts']);
|
|
112
|
+
expect(passed(outcome)).toBe(false);
|
|
113
|
+
expect(evidenceText(outcome)).toContain('scripts/bar.ts');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('后缀碰撞不覆盖:xfoo.ts 不被 foo.ts 条目覆盖', async () => {
|
|
117
|
+
const dir = setupDir('step1-endswith', `# C\n\n${TABLE_HEAD}| foo | foo.ts | foo |\n`);
|
|
118
|
+
expect(passed(await run(dir, ['web/xfoo.ts']))).toBe(false);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('子串误配不覆盖:docs/src/foo.tsx 不被 src/foo.ts 条目覆盖', async () => {
|
|
122
|
+
const dir = setupDir('step1-includes', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
123
|
+
expect(passed(await run(dir, ['docs/src/foo.tsx']))).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('basename 条目按路径边界后缀覆盖(src/foo.ts 被 foo.ts 覆盖)', async () => {
|
|
127
|
+
const dir = setupDir('step1-suffix-ok', `# C\n\n${TABLE_HEAD}| foo | foo.ts | foo |\n`);
|
|
128
|
+
expect(passed(await run(dir, ['src/foo.ts']))).toBe(true);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('测试文件与非代码变更不参与 step1', async () => {
|
|
132
|
+
const dir = setupDir('step1-noncode', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
133
|
+
expect(
|
|
134
|
+
passed(await run(dir, ['src/__tests__/foo.test.ts', 'docs/readme.md', 'package.json']))
|
|
135
|
+
).toBe(true);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe('capability_sync — step2 全量覆盖(file 模式:只提示,不判违规)', () => {
|
|
140
|
+
it('全部源文件已登记 → 通过且无提示', async () => {
|
|
141
|
+
const dir = setupDir(
|
|
142
|
+
'step2-ok',
|
|
143
|
+
`# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`,
|
|
144
|
+
['src/foo.ts']
|
|
145
|
+
);
|
|
146
|
+
const outcome = await capabilitySync.evaluate(makeEnv(dir, []));
|
|
147
|
+
expect(passed(outcome)).toBe(true);
|
|
148
|
+
expect(evidenceText(outcome)).toBe('');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('有未登记源文件 → 仍通过,但提示点名该文件(harness#119 归位)', async () => {
|
|
152
|
+
const dir = setupDir(
|
|
153
|
+
'step2-missing',
|
|
154
|
+
`# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`,
|
|
155
|
+
['src/foo.ts', 'src/unlisted.ts']
|
|
156
|
+
);
|
|
157
|
+
const outcome = await capabilitySync.evaluate(makeEnv(dir, []));
|
|
158
|
+
expect(passed(outcome)).toBe(true);
|
|
159
|
+
const evidence = evidenceText(outcome);
|
|
160
|
+
expect(evidence).toContain('src/unlisted.ts');
|
|
161
|
+
expect(evidence).toContain('仓库级漂移');
|
|
162
|
+
expect(evidence).toContain('sync-docs');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('basename 条目同样按边界后缀覆盖 step2(step1/step2 语义一致)', async () => {
|
|
166
|
+
const dir = setupDir(
|
|
167
|
+
'step2-basename',
|
|
168
|
+
`# C\n\n${TABLE_HEAD}| foo | foo.ts | foo |\n`,
|
|
169
|
+
['src/foo.ts']
|
|
170
|
+
);
|
|
171
|
+
expect(passed(await capabilitySync.evaluate(makeEnv(dir, [])))).toBe(true);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('不同路径同后缀文件不被误覆盖(lib/foo.ts 不覆盖 src/foo.ts)→ 记为漂移', async () => {
|
|
175
|
+
const dir = setupDir(
|
|
176
|
+
'step2-boundary',
|
|
177
|
+
`# C\n\n${TABLE_HEAD}| foo | lib/foo.ts | foo |\n`,
|
|
178
|
+
['src/foo.ts']
|
|
179
|
+
);
|
|
180
|
+
const outcome = await capabilitySync.evaluate(makeEnv(dir, []));
|
|
181
|
+
expect(passed(outcome)).toBe(true);
|
|
182
|
+
expect(evidenceText(outcome)).toContain('src/foo.ts');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('step1 优先:变更未登记时判违规,证据是变更文件而非仓库漂移清单', async () => {
|
|
186
|
+
const dir = setupDir(
|
|
187
|
+
'step1-beats-step2',
|
|
188
|
+
`# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`,
|
|
189
|
+
['src/foo.ts', 'src/drifted.ts']
|
|
190
|
+
);
|
|
191
|
+
const outcome = await capabilitySync.evaluate(makeEnv(dir, ['src/new.ts']));
|
|
192
|
+
expect(passed(outcome)).toBe(false);
|
|
193
|
+
expect(evidenceText(outcome)).toContain('src/new.ts');
|
|
194
|
+
expect(evidenceText(outcome)).not.toContain('src/drifted.ts');
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('漂移项超过 10 个 → 证据截断并给出全量查看入口', async () => {
|
|
198
|
+
const files = ['src/foo.ts', ...Array.from({ length: 12 }, (_, i) => `src/drift${i}.ts`)];
|
|
199
|
+
const dir = setupDir('step2-truncate', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`, files);
|
|
200
|
+
const outcome = await capabilitySync.evaluate(makeEnv(dir, []));
|
|
201
|
+
expect(passed(outcome)).toBe(true);
|
|
202
|
+
const lines = normalizeCheckOutcome(outcome).evidence;
|
|
203
|
+
expect(lines).toHaveLength(12); // 说明行 + 10 条 + 截断行
|
|
204
|
+
expect(lines[lines.length - 1]).toContain('另 2 项');
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe('capability_sync — module 模式(未覆盖聚合为目录形状)', () => {
|
|
209
|
+
it('目录条目覆盖源文件 → 通过', async () => {
|
|
210
|
+
const dir = setupDir(
|
|
211
|
+
'mod-covered',
|
|
212
|
+
`# C\n\n${TABLE_HEAD}| 核心 | src/core/ | 核心 |\n`,
|
|
213
|
+
['src/core/foo.ts', 'src/core/bar.ts'],
|
|
214
|
+
'module'
|
|
215
|
+
);
|
|
216
|
+
expect(passed(await capabilitySync.evaluate(makeEnv(dir, [])))).toBe(true);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('文件条目精确匹配也算覆盖', async () => {
|
|
220
|
+
const dir = setupDir(
|
|
221
|
+
'mod-file-entry',
|
|
222
|
+
`# C\n\n${TABLE_HEAD}| foo | src/core/foo.ts | foo |\n`,
|
|
223
|
+
['src/core/foo.ts'],
|
|
224
|
+
'module'
|
|
225
|
+
);
|
|
226
|
+
expect(passed(await capabilitySync.evaluate(makeEnv(dir, [])))).toBe(true);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('新目录未登记 → 不判违规,提示按目录聚合', async () => {
|
|
230
|
+
const dir = setupDir(
|
|
231
|
+
'mod-uncovered',
|
|
232
|
+
`# C\n\n${TABLE_HEAD}| 核心 | src/core/ | 核心 |\n`,
|
|
233
|
+
['src/core/foo.ts', 'src/newdir/bar.ts'],
|
|
234
|
+
'module'
|
|
235
|
+
);
|
|
236
|
+
const outcome = await capabilitySync.evaluate(makeEnv(dir, []));
|
|
237
|
+
expect(passed(outcome)).toBe(true);
|
|
238
|
+
const evidence = evidenceText(outcome);
|
|
239
|
+
expect(evidence).toContain('未登记模块目录');
|
|
240
|
+
expect(evidence).toContain('src/newdir/');
|
|
241
|
+
expect(evidence).not.toContain('src/newdir/bar.ts');
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('module 模式文件条目按边界后缀覆盖(step1/step2 同规则)', async () => {
|
|
245
|
+
const dir = setupDir(
|
|
246
|
+
'mod-suffix',
|
|
247
|
+
`# C\n\n${TABLE_HEAD}| foo | foo.ts | foo |\n`,
|
|
248
|
+
['src/foo.ts'],
|
|
249
|
+
'module'
|
|
250
|
+
);
|
|
251
|
+
expect(passed(await capabilitySync.evaluate(makeEnv(dir, [])))).toBe(true);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe('capability_sync — fail-open 可观测', () => {
|
|
256
|
+
it('证据读取异常时放行但输出 warn,且异常原因进 evidence', async () => {
|
|
257
|
+
const dir = setupDir('failopen', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
258
|
+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
259
|
+
const env: CheckEnv = {
|
|
260
|
+
...makeEnv(dir, []),
|
|
261
|
+
stagedDiffNames: async () => {
|
|
262
|
+
throw new Error('git boom');
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
const outcome = await capabilitySync.evaluate(env);
|
|
266
|
+
// fail-open 语义不变(仍不拦),但「因异常而通过」必须留痕:warn 只进本地 stderr
|
|
267
|
+
expect(passed(outcome)).toBe(true);
|
|
268
|
+
expect(evidenceText(outcome)).toContain('git boom');
|
|
269
|
+
expect(evidenceText(outcome)).toContain('fail-open');
|
|
270
|
+
expect(warnSpy).toHaveBeenCalled();
|
|
271
|
+
warnSpy.mockRestore();
|
|
272
|
+
});
|
|
273
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 检查结果证据通道测试(harness#119)
|
|
3
|
+
*
|
|
4
|
+
* 背景:checker 只回 `boolean | 'skip'`,fail 的具体原因(哪个文件没登记)在 CLI
|
|
5
|
+
* 与 trace 两头都无处落脚——capability_sync 连红 22 次而无人能说出红在哪。
|
|
6
|
+
* 本套件锁住新接缝:CheckDetail(pass + evidence)经 normalizeCheckOutcome
|
|
7
|
+
* 归一后,落到 ConstraintResult.evidence 与 ExecutionTrace.evidence。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect } from '@jest/globals';
|
|
11
|
+
import * as fs from 'fs';
|
|
12
|
+
import * as os from 'os';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { execFileSync } from 'child_process';
|
|
15
|
+
import { ConstraintChecker } from '../../checker';
|
|
16
|
+
import { normalizeCheckOutcome } from '../types';
|
|
17
|
+
import { createProjectFixture } from '../../../../test-setup/project-fixture';
|
|
18
|
+
import type { ExecutionTrace } from '../../../../types/trace';
|
|
19
|
+
import { ConstraintViolationError } from '../../../../types/constraint';
|
|
20
|
+
import type { Constraint, ConstraintResult } from '../../../../types/constraint';
|
|
21
|
+
import type { MergedConstraintsConfig } from '../../../../types/project-config';
|
|
22
|
+
|
|
23
|
+
const CAPABILITY_SYNC: Constraint = {
|
|
24
|
+
id: 'capability_sync',
|
|
25
|
+
kind: 'check',
|
|
26
|
+
level: 'guideline',
|
|
27
|
+
rule: 'CODE CHANGES MUST UPDATE CAPABILITIES.MD',
|
|
28
|
+
message: '核心模块变更必须同步功能清单',
|
|
29
|
+
trigger: ['module_modification'],
|
|
30
|
+
enforcement: 'update-capabilities',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** 声明式夹具(harness#90):CAPABILITIES.md + 源文件,无 git,staged 证据自然为空 */
|
|
34
|
+
function fixture(name: string, files: Record<string, string>): string {
|
|
35
|
+
return createProjectFixture({ name: `cap-sync-${name}`, files });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe('normalizeCheckOutcome — 三态 + 证据归一', () => {
|
|
39
|
+
it('boolean 兼容旧形状:true → satisfied / false → violated,evidence 空', () => {
|
|
40
|
+
expect(normalizeCheckOutcome(true)).toEqual({ satisfied: true, skipped: false, evidence: [] });
|
|
41
|
+
expect(normalizeCheckOutcome(false)).toEqual({ satisfied: false, skipped: false, evidence: [] });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("'skip' → skipped 且不记证据", () => {
|
|
45
|
+
expect(normalizeCheckOutcome('skip')).toEqual({ satisfied: true, skipped: true, evidence: [] });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('CheckDetail 透传 pass 与 evidence;缺省 evidence 归一为空数组', () => {
|
|
49
|
+
expect(normalizeCheckOutcome({ pass: false, evidence: ['a.ts'] })).toEqual({
|
|
50
|
+
satisfied: false,
|
|
51
|
+
skipped: false,
|
|
52
|
+
evidence: ['a.ts'],
|
|
53
|
+
});
|
|
54
|
+
expect(normalizeCheckOutcome({ pass: true })).toEqual({
|
|
55
|
+
satisfied: true,
|
|
56
|
+
skipped: false,
|
|
57
|
+
evidence: [],
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/** 只含 capability_sync 的生效集:一次 run 一条 trace,不牵动其他约束 */
|
|
63
|
+
function onlyCapabilitySync(): MergedConstraintsConfig {
|
|
64
|
+
return {
|
|
65
|
+
ironLaws: {},
|
|
66
|
+
guidelines: { capability_sync: CAPABILITY_SYNC },
|
|
67
|
+
prompts: {},
|
|
68
|
+
disabled: [],
|
|
69
|
+
custom: [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** 跑一次 checkConstraints,返回 capability_sync 的结果与它那条 trace */
|
|
74
|
+
async function runGuideline(dir: string): Promise<{
|
|
75
|
+
result: ConstraintResult;
|
|
76
|
+
trace: ExecutionTrace;
|
|
77
|
+
}> {
|
|
78
|
+
const traces: ExecutionTrace[] = [];
|
|
79
|
+
const checker = new ConstraintChecker({ record: (t) => traces.push(t) });
|
|
80
|
+
const run = await checker.checkConstraints(
|
|
81
|
+
{ operation: 'module_modification', projectPath: dir },
|
|
82
|
+
onlyCapabilitySync()
|
|
83
|
+
);
|
|
84
|
+
const result = run.guidelines.find(r => r.id === 'capability_sync')!;
|
|
85
|
+
const trace = traces.find(t => t.constraintId === 'capability_sync')!;
|
|
86
|
+
return { result, trace };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** 需要真 git 的用例专用手写根:夹具不建 git,而 staged 分区只能由真仓库产生 */
|
|
90
|
+
function gitProjectRoot(files: Record<string, string>): string {
|
|
91
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-evidence-git-'));
|
|
92
|
+
for (const [rel, content] of Object.entries(files)) {
|
|
93
|
+
const target = path.join(dir, rel);
|
|
94
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
95
|
+
fs.writeFileSync(target, content, 'utf-8');
|
|
96
|
+
}
|
|
97
|
+
execFileSync('git', ['init', '-q'], { cwd: dir });
|
|
98
|
+
execFileSync('git', ['config', 'user.email', 'fixture@example.com'], { cwd: dir });
|
|
99
|
+
execFileSync('git', ['config', 'user.name', 'Fixture'], { cwd: dir });
|
|
100
|
+
execFileSync('git', ['add', '.'], { cwd: dir });
|
|
101
|
+
execFileSync('git', ['commit', '-q', '-m', 'baseline'], { cwd: dir });
|
|
102
|
+
return dir;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
describe('capability_sync 证据经编排层落到 ConstraintResult 与 trace', () => {
|
|
106
|
+
it('满足但存在仓库级未登记文件 → satisfied=true,evidence 带路径,trace 记 pass', async () => {
|
|
107
|
+
const dir = fixture('hint', {
|
|
108
|
+
'CAPABILITIES.md': '| 模块 | 文件 | 说明 |\n|------|------|------|\n| foo | src/foo.ts | foo |\n',
|
|
109
|
+
'src/foo.ts': 'export const a = 1;\n',
|
|
110
|
+
'src/unlisted.ts': 'export const b = 2;\n',
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const { result, trace } = await runGuideline(dir);
|
|
114
|
+
|
|
115
|
+
expect(result.satisfied).toBe(true);
|
|
116
|
+
expect(result.skipped).toBeUndefined();
|
|
117
|
+
expect(result.evidence?.join('\n')).toContain('unlisted.ts');
|
|
118
|
+
expect(trace.result).toBe('pass');
|
|
119
|
+
expect(trace.evidence?.join('\n')).toContain('unlisted.ts');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('违规(staged 新文件未登记)→ satisfied=false,evidence 指出该文件,trace 记 fail', async () => {
|
|
123
|
+
const dir = gitProjectRoot({
|
|
124
|
+
'CAPABILITIES.md': '| 模块 | 文件 | 说明 |\n|------|------|------|\n| foo | src/foo.ts | foo |\n',
|
|
125
|
+
'src/foo.ts': 'export const a = 1;\n',
|
|
126
|
+
});
|
|
127
|
+
fs.writeFileSync(path.join(dir, 'src/brand-new.ts'), 'export const c = 3;\n');
|
|
128
|
+
execFileSync('git', ['add', '--', 'src/brand-new.ts'], { cwd: dir });
|
|
129
|
+
|
|
130
|
+
const { result, trace } = await runGuideline(dir);
|
|
131
|
+
|
|
132
|
+
expect(result.satisfied).toBe(false);
|
|
133
|
+
expect(result.evidence?.join('\n')).toContain('src/brand-new.ts');
|
|
134
|
+
expect(trace.result).toBe('fail');
|
|
135
|
+
expect(trace.evidence?.join('\n')).toContain('src/brand-new.ts');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('skip 不携带证据(未评估不得留下证据行)', async () => {
|
|
139
|
+
const dir = fixture('no-convention', { 'README.md': '# no capabilities convention\n' });
|
|
140
|
+
|
|
141
|
+
const { result, trace } = await runGuideline(dir);
|
|
142
|
+
|
|
143
|
+
expect(result.skipped).toBe(true);
|
|
144
|
+
expect(result.evidence).toBeUndefined();
|
|
145
|
+
expect(trace.result).toBe('skip');
|
|
146
|
+
expect(trace.evidence).toBeUndefined();
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('证据随铁律异常外溢(CLI catch 分支只打印 error.message)', () => {
|
|
151
|
+
it('ConstraintViolationError 文案带出证据行', () => {
|
|
152
|
+
const error = new ConstraintViolationError({
|
|
153
|
+
id: 'docs_freshness',
|
|
154
|
+
level: 'iron_law',
|
|
155
|
+
satisfied: false,
|
|
156
|
+
message: '文档新鲜度检查未通过',
|
|
157
|
+
evidence: ['CAPABILITIES.md 登记的条目不存在:', 'src/gone.ts'],
|
|
158
|
+
checkedAt: new Date(),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(error.message).toContain('文档新鲜度检查未通过');
|
|
162
|
+
expect(error.message).toContain('src/gone.ts');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('无证据时文案保持原样(旧消费方断言不受影响)', () => {
|
|
166
|
+
const error = new ConstraintViolationError({
|
|
167
|
+
id: 'no_test_simplification',
|
|
168
|
+
level: 'iron_law',
|
|
169
|
+
satisfied: false,
|
|
170
|
+
message: '禁止简化测试绕过困难',
|
|
171
|
+
checkedAt: new Date(),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
expect(error.message).toBe('禁止简化测试绕过困难');
|
|
175
|
+
});
|
|
176
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context_doc_sync 检查器旁测(架构评审候选4,ADR-0009 同模式)
|
|
3
|
+
*
|
|
4
|
+
* 测试面 = ConstraintCheck.evaluate(env):项目目录为真实 fs 临时目录,
|
|
5
|
+
* 证据经 buildCheckEnv 注入(本检查器只用 projectPath,证据走 'none')。
|
|
6
|
+
* 自 checker-extra.test.ts 迁入并告别 engine facade;三态收紧——
|
|
7
|
+
* facade 下 skip 表现为 satisfied:true,旁测直接钉 'skip'。
|
|
8
|
+
* 项目根由 src/test-setup/project-fixture 声明式构造(回收仍走 mkdtemp-cleanup)。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, it, expect } from '@jest/globals';
|
|
12
|
+
import { contextDocSync } from '../context-doc-sync';
|
|
13
|
+
import { buildCheckEnv } from '../types';
|
|
14
|
+
import { createProjectFixture } from '../../../../test-setup/project-fixture';
|
|
15
|
+
import type { ConstraintContext } from '../../../../types/constraint';
|
|
16
|
+
|
|
17
|
+
function setupDir(
|
|
18
|
+
name: string,
|
|
19
|
+
configYml: string | null,
|
|
20
|
+
contextMdDirs: string[] = []
|
|
21
|
+
): string {
|
|
22
|
+
return createProjectFixture({
|
|
23
|
+
name: `ctx-doc-sync-${name}`,
|
|
24
|
+
config: configYml ?? undefined,
|
|
25
|
+
files: Object.fromEntries(contextMdDirs.map(d => [`${d}/CONTEXT.md`, `# ${d}\n`])),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function evaluate(dir: string) {
|
|
30
|
+
const context: ConstraintContext = { operation: 'module_modification', projectPath: dir };
|
|
31
|
+
return contextDocSync.evaluate(buildCheckEnv(context, 'none'));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const CTX_FILES = (enabled: boolean, dirs?: string[]) =>
|
|
35
|
+
`governance:\n context_files:\n enabled: ${enabled}\n` +
|
|
36
|
+
(dirs ? ` required_dirs: [${dirs.map(d => `'${d}'`).join(', ')}]\n` : '');
|
|
37
|
+
|
|
38
|
+
describe('context_doc_sync — skip 门槛(ADR-0001 存在性探测)', () => {
|
|
39
|
+
it('无 .harness/config.yml → skip', async () => {
|
|
40
|
+
expect(await evaluate(setupDir('no-config', null))).toBe('skip');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('配置无 governance.context_files → skip', async () => {
|
|
44
|
+
expect(await evaluate(setupDir('no-section', 'preset: standard\n'))).toBe('skip');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('enabled: false → skip(facade 旧断言 satisfied:true 的真实语义)', async () => {
|
|
48
|
+
expect(await evaluate(setupDir('disabled', CTX_FILES(false, ['src'])))).toBe('skip');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('enabled 但 required_dirs 缺失/非数组/空 → skip', async () => {
|
|
52
|
+
expect(await evaluate(setupDir('no-dirs', CTX_FILES(true)))).toBe('skip');
|
|
53
|
+
expect(await evaluate(setupDir('empty-dirs', CTX_FILES(true, [])))).toBe('skip');
|
|
54
|
+
expect(
|
|
55
|
+
await evaluate(
|
|
56
|
+
setupDir('bad-dirs', 'governance:\n context_files:\n enabled: true\n required_dirs: src\n')
|
|
57
|
+
)
|
|
58
|
+
).toBe('skip');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('context_doc_sync — 判定', () => {
|
|
63
|
+
it('required_dirs 全部有 CONTEXT.md → pass', async () => {
|
|
64
|
+
const dir = setupDir('all-present', CTX_FILES(true, ['src', 'bin']), ['src', 'bin']);
|
|
65
|
+
expect(await evaluate(dir)).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('任一目录缺 CONTEXT.md → fail', async () => {
|
|
69
|
+
const dir = setupDir('one-missing', CTX_FILES(true, ['src', 'bin']), ['src']);
|
|
70
|
+
expect(await evaluate(dir)).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('配置解析失败 → skip(不炸不报)', async () => {
|
|
74
|
+
const dir = setupDir('bad-yaml', 'governance: [\n broken: {{\n');
|
|
75
|
+
expect(await evaluate(dir)).toBe('skip');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* docs_freshness 检查器旁测(ADR-0009 / 架构评审候选4)
|
|
3
|
+
*
|
|
4
|
+
* 测试面 = ConstraintCheck.evaluate(env)。幽灵判定走 capabilities-reconcile:
|
|
5
|
+
* 文件与目录条目都查(口径从严);无约定文件 → skip。
|
|
6
|
+
* 项目根由 src/test-setup/project-fixture 声明式构造(回收仍走 mkdtemp-cleanup)。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect } from '@jest/globals';
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import { docsFreshness } from '../docs-freshness';
|
|
13
|
+
import { buildCheckEnv, normalizeCheckOutcome, type CheckOutcome } from '../types';
|
|
14
|
+
import { collectSourceFiles } from '../../capabilities-reconcile';
|
|
15
|
+
import { createProjectFixture } from '../../../../test-setup/project-fixture';
|
|
16
|
+
import type { ConstraintContext } from '../../../../types/constraint';
|
|
17
|
+
|
|
18
|
+
const TABLE_HEAD = '| 模块 | 文件 | 说明 |\n|------|------|------|\n';
|
|
19
|
+
|
|
20
|
+
/** 证据行拼成单串,便于按路径断言(harness#119) */
|
|
21
|
+
const evidenceText = (outcome: CheckOutcome): string =>
|
|
22
|
+
normalizeCheckOutcome(outcome).evidence.join('\n');
|
|
23
|
+
|
|
24
|
+
function setupProject(name: string, files: string[]): string {
|
|
25
|
+
return createProjectFixture({
|
|
26
|
+
name: `docs-fresh-${name}`,
|
|
27
|
+
files: Object.fromEntries(files.map(f => [f, 'export const x = 1;'])),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function makeEnv(projectPath: string): ReturnType<typeof buildCheckEnv> {
|
|
32
|
+
const context: ConstraintContext = { operation: 'file_modification', projectPath };
|
|
33
|
+
return buildCheckEnv(context, {
|
|
34
|
+
stagedDiff: async () => '',
|
|
35
|
+
stagedDiffNames: async () => '',
|
|
36
|
+
srcScan: (root: string) => collectSourceFiles(projectPath, [root]),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function writeCap(dir: string, body: string): void {
|
|
41
|
+
fs.writeFileSync(path.join(dir, 'CAPABILITIES.md'), `# Capabilities\n\n${body}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
describe('docs_freshness — 存在性探测(ADR-0001)', () => {
|
|
45
|
+
it('无 CAPABILITIES.md/CHANGELOG/配置 → skip,不计 pass/fail', async () => {
|
|
46
|
+
const dir = setupProject('none', ['src/module.ts']);
|
|
47
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe('skip');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('docs_freshness — 幽灵判定(文档→代码方向)', () => {
|
|
52
|
+
it('散文文档(无表格)→ 通过', async () => {
|
|
53
|
+
const dir = setupProject('no-table', []);
|
|
54
|
+
writeCap(dir, 'No table here.');
|
|
55
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('登记的文件全部存在 → 通过', async () => {
|
|
59
|
+
const dir = setupProject('valid', ['src/old.ts', 'src/new.ts']);
|
|
60
|
+
writeCap(
|
|
61
|
+
dir,
|
|
62
|
+
`${TABLE_HEAD}| old | src/old.ts | old |\n| new | src/new.ts | new |`
|
|
63
|
+
);
|
|
64
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('登记的文件已删除 → 失败并点名条目', async () => {
|
|
68
|
+
const dir = setupProject('ghost-file', ['src/old.ts']);
|
|
69
|
+
writeCap(
|
|
70
|
+
dir,
|
|
71
|
+
`${TABLE_HEAD}| old | src/old.ts | old |\n| deleted | src/deleted.ts | deleted |`
|
|
72
|
+
);
|
|
73
|
+
const outcome = await docsFreshness.evaluate(makeEnv(dir));
|
|
74
|
+
expect(normalizeCheckOutcome(outcome).satisfied).toBe(false);
|
|
75
|
+
expect(evidenceText(outcome)).toContain('src/deleted.ts');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('登记的目录条目已消失 → 失败(ADR-0009 口径从严,文件+目录都查)', async () => {
|
|
79
|
+
const dir = setupProject('ghost-dir', ['src/core/foo.ts']);
|
|
80
|
+
writeCap(
|
|
81
|
+
dir,
|
|
82
|
+
`${TABLE_HEAD}| 核心 | src/core/ | 核心 |\n| 遗魂 | src/gone/ | 已删目录 |`
|
|
83
|
+
);
|
|
84
|
+
const outcome = await docsFreshness.evaluate(makeEnv(dir));
|
|
85
|
+
expect(normalizeCheckOutcome(outcome).satisfied).toBe(false);
|
|
86
|
+
expect(evidenceText(outcome)).toContain('src/gone/');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('登记的目录条目仍存在 → 通过', async () => {
|
|
90
|
+
const dir = setupProject('dir-alive', ['src/core/foo.ts']);
|
|
91
|
+
writeCap(dir, `${TABLE_HEAD}| 核心 | src/core/ | 核心 |`);
|
|
92
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('basename 碰撞场景:全路径幽灵即使同名文件存活仍被报出(2026-08-08 事故回归)', async () => {
|
|
96
|
+
const dir = setupProject('collision', ['src/agents/routes.ts']);
|
|
97
|
+
writeCap(
|
|
98
|
+
dir,
|
|
99
|
+
`${TABLE_HEAD}| routes | src/agents/routes.ts | 活 |\n| 旧路由 | src/agent-configs/routes.ts | 已删 |`
|
|
100
|
+
);
|
|
101
|
+
const outcome = await docsFreshness.evaluate(makeEnv(dir));
|
|
102
|
+
expect(normalizeCheckOutcome(outcome).satisfied).toBe(false);
|
|
103
|
+
expect(evidenceText(outcome)).toContain('src/agent-configs/routes.ts');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('docs_freshness — 内置 Runner 检查(changelog/context)', () => {
|
|
108
|
+
it('无 CHANGELOG 但有 CAPABILITIES.md 且条目健康 → 通过', async () => {
|
|
109
|
+
const dir = setupProject('runner-ok', ['src/module.ts']);
|
|
110
|
+
writeCap(dir, `${TABLE_HEAD}| module | src/module.ts | module |`);
|
|
111
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('CHANGELOG 版本与 package.json 漂移 → 失败', async () => {
|
|
115
|
+
const dir = setupProject('ver-drift', ['src/module.ts']);
|
|
116
|
+
writeCap(dir, `${TABLE_HEAD}| module | src/module.ts | module |`);
|
|
117
|
+
fs.writeFileSync(
|
|
118
|
+
path.join(dir, 'package.json'),
|
|
119
|
+
JSON.stringify({ name: 'x', version: '2.0.0' })
|
|
120
|
+
);
|
|
121
|
+
fs.writeFileSync(path.join(dir, 'CHANGELOG.md'), '## [1.0.0] - 2026-01-01\n\n- old\n');
|
|
122
|
+
const outcome = await docsFreshness.evaluate(makeEnv(dir));
|
|
123
|
+
expect(normalizeCheckOutcome(outcome).satisfied).toBe(false);
|
|
124
|
+
expect(evidenceText(outcome)).toContain('1.0.0 !== package.json 版本 2.0.0');
|
|
125
|
+
});
|
|
126
|
+
});
|