@dommaker/harness 1.3.0 → 1.4.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 +8 -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 +76 -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 +29 -214
- 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 +21 -15
- package/dist/cli/commands/knowledge.d.ts.map +1 -1
- package/dist/cli/commands/knowledge.js +214 -199
- 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 +2 -1
- package/dist/cli/commands/update-user-model.d.ts.map +1 -1
- package/dist/cli/commands/update-user-model.js +31 -45
- 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 +64 -115
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts +4 -3
- package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +29 -69
- 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 +37 -63
- 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/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 +2 -2
- 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.map +1 -1
- package/dist/gates/checker-gate.js +6 -11
- 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 +0 -18
- package/dist/types/constraint.d.ts.map +1 -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/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 +7 -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 +142 -106
- 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 +22 -7
- 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 +101 -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 +378 -382
- 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 +169 -0
- package/src/cli/commands/__tests__/registry.test.ts +69 -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 +62 -33
- 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 +88 -65
- 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 +36 -222
- package/src/cli/commands/failure.ts +33 -26
- package/src/cli/commands/init.ts +166 -220
- package/src/cli/commands/knowledge.ts +225 -203
- 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 +33 -45
- 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 +9 -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 +75 -130
- package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +214 -0
- package/src/core/constraints/checkers/__tests__/context-doc-sync.test.ts +77 -0
- package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +117 -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 +145 -0
- package/src/core/constraints/checkers/capability-sync.ts +29 -88
- package/src/core/constraints/checkers/context-doc-sync.ts +15 -25
- package/src/core/constraints/checkers/docs-freshness.ts +40 -69
- package/src/core/constraints/checkers/governance-presence.ts +7 -25
- package/src/core/constraints/checkers/no-test-simplification.ts +4 -3
- package/src/core/constraints/checkers/types.ts +2 -2
- 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 +6 -3
- 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__/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 +8 -7
- 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 +0 -25
- 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/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,214 @@
|
|
|
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, type CheckEnv } 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
|
+
describe('capability_sync — skip 与文档格式门槛', () => {
|
|
51
|
+
it('无 CAPABILITIES.md → skip(ADR-0001 存在性探测,有无变更都一样)', async () => {
|
|
52
|
+
const dir = createProjectFixture({ name: 'cap-sync-none' });
|
|
53
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe('skip');
|
|
54
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, ['src/foo.ts']))).toBe('skip');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('散文文档(无表格)+ 有变更 → 放行(历史语义)', async () => {
|
|
58
|
+
const dir = setupDir('prose', '# Capabilities\n\n- Feature: test', ['feature.ts']);
|
|
59
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, ['feature.ts']))).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('清单格式(计数行)→ 放行,计数由 sync-docs 维护', async () => {
|
|
63
|
+
const dir = setupDir('listing', '# Capabilities\n\n## CLI Commands (25)\ncheck, validate\n');
|
|
64
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, ['src/foo.ts']))).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('有表格但零条目 + 有变更 → 不得放行', async () => {
|
|
68
|
+
const dir = setupDir('empty-table', `# Capabilities\n\n${TABLE_HEAD}`);
|
|
69
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, ['src/foo.ts']))).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('有表格但零条目 + 源码有文件 → step2 不得放行', async () => {
|
|
73
|
+
const dir = setupDir('empty-table-scan', `# Capabilities\n\n${TABLE_HEAD}`, ['src/foo.ts']);
|
|
74
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('capability_sync — step1 增量覆盖', () => {
|
|
79
|
+
const run = (dir: string, staged: string[]) =>
|
|
80
|
+
capabilitySync.evaluate(makeEnv(dir, staged, {}));
|
|
81
|
+
|
|
82
|
+
it('变更文件未被登记 → 失败', async () => {
|
|
83
|
+
const dir = setupDir('step1-uncovered', `# C\n\n${TABLE_HEAD}| 旧 | old/module.ts | 旧 |\n`);
|
|
84
|
+
expect(await run(dir, ['new-module.ts'])).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('变更文件按登记路径覆盖 → 通过', async () => {
|
|
88
|
+
const dir = setupDir('step1-covered', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
89
|
+
expect(await run(dir, ['src/foo.ts'])).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('每个变更文件都必须被覆盖(every 而非 some)', async () => {
|
|
93
|
+
const dir = setupDir('step1-every', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
94
|
+
expect(await run(dir, ['src/foo.ts', 'scripts/bar.ts'])).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('后缀碰撞不覆盖:xfoo.ts 不被 foo.ts 条目覆盖', async () => {
|
|
98
|
+
const dir = setupDir('step1-endswith', `# C\n\n${TABLE_HEAD}| foo | foo.ts | foo |\n`);
|
|
99
|
+
expect(await run(dir, ['web/xfoo.ts'])).toBe(false);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('子串误配不覆盖:docs/src/foo.tsx 不被 src/foo.ts 条目覆盖', async () => {
|
|
103
|
+
const dir = setupDir('step1-includes', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
104
|
+
expect(await run(dir, ['docs/src/foo.tsx'])).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('basename 条目按路径边界后缀覆盖(src/foo.ts 被 foo.ts 覆盖)', async () => {
|
|
108
|
+
const dir = setupDir('step1-suffix-ok', `# C\n\n${TABLE_HEAD}| foo | foo.ts | foo |\n`);
|
|
109
|
+
expect(await run(dir, ['src/foo.ts'])).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('测试文件与非代码变更不参与 step1', async () => {
|
|
113
|
+
const dir = setupDir('step1-noncode', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
114
|
+
expect(
|
|
115
|
+
await run(dir, ['src/__tests__/foo.test.ts', 'docs/readme.md', 'package.json'])
|
|
116
|
+
).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('capability_sync — step2 全量覆盖(file 模式)', () => {
|
|
121
|
+
it('全部源文件已登记 → 通过', async () => {
|
|
122
|
+
const dir = setupDir(
|
|
123
|
+
'step2-ok',
|
|
124
|
+
`# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`,
|
|
125
|
+
['src/foo.ts']
|
|
126
|
+
);
|
|
127
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('有未登记源文件 → 失败', async () => {
|
|
131
|
+
const dir = setupDir(
|
|
132
|
+
'step2-missing',
|
|
133
|
+
`# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`,
|
|
134
|
+
['src/foo.ts', 'src/unlisted.ts']
|
|
135
|
+
);
|
|
136
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe(false);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('basename 条目同样按边界后缀覆盖 step2(step1/step2 语义一致)', async () => {
|
|
140
|
+
const dir = setupDir(
|
|
141
|
+
'step2-basename',
|
|
142
|
+
`# C\n\n${TABLE_HEAD}| foo | foo.ts | foo |\n`,
|
|
143
|
+
['src/foo.ts']
|
|
144
|
+
);
|
|
145
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe(true);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('不同路径同后缀文件不被误覆盖(lib/foo.ts 不覆盖 src/foo.ts)', async () => {
|
|
149
|
+
const dir = setupDir(
|
|
150
|
+
'step2-boundary',
|
|
151
|
+
`# C\n\n${TABLE_HEAD}| foo | lib/foo.ts | foo |\n`,
|
|
152
|
+
['src/foo.ts']
|
|
153
|
+
);
|
|
154
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe(false);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('capability_sync — module 模式(未覆盖聚合为目录形状)', () => {
|
|
159
|
+
it('目录条目覆盖源文件 → 通过', async () => {
|
|
160
|
+
const dir = setupDir(
|
|
161
|
+
'mod-covered',
|
|
162
|
+
`# C\n\n${TABLE_HEAD}| 核心 | src/core/ | 核心 |\n`,
|
|
163
|
+
['src/core/foo.ts', 'src/core/bar.ts'],
|
|
164
|
+
'module'
|
|
165
|
+
);
|
|
166
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe(true);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('文件条目精确匹配也算覆盖', async () => {
|
|
170
|
+
const dir = setupDir(
|
|
171
|
+
'mod-file-entry',
|
|
172
|
+
`# C\n\n${TABLE_HEAD}| foo | src/core/foo.ts | foo |\n`,
|
|
173
|
+
['src/core/foo.ts'],
|
|
174
|
+
'module'
|
|
175
|
+
);
|
|
176
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe(true);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('新目录未登记 → 失败', async () => {
|
|
180
|
+
const dir = setupDir(
|
|
181
|
+
'mod-uncovered',
|
|
182
|
+
`# C\n\n${TABLE_HEAD}| 核心 | src/core/ | 核心 |\n`,
|
|
183
|
+
['src/core/foo.ts', 'src/newdir/bar.ts'],
|
|
184
|
+
'module'
|
|
185
|
+
);
|
|
186
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe(false);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('module 模式文件条目按边界后缀覆盖(step1/step2 同规则)', async () => {
|
|
190
|
+
const dir = setupDir(
|
|
191
|
+
'mod-suffix',
|
|
192
|
+
`# C\n\n${TABLE_HEAD}| foo | foo.ts | foo |\n`,
|
|
193
|
+
['src/foo.ts'],
|
|
194
|
+
'module'
|
|
195
|
+
);
|
|
196
|
+
expect(await capabilitySync.evaluate(makeEnv(dir, []))).toBe(true);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe('capability_sync — fail-open 可观测', () => {
|
|
201
|
+
it('证据读取异常时放行但输出 warn', async () => {
|
|
202
|
+
const dir = setupDir('failopen', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`);
|
|
203
|
+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
204
|
+
const env: CheckEnv = {
|
|
205
|
+
...makeEnv(dir, []),
|
|
206
|
+
stagedDiffNames: async () => {
|
|
207
|
+
throw new Error('git boom');
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
expect(await capabilitySync.evaluate(env)).toBe(true);
|
|
211
|
+
expect(warnSpy).toHaveBeenCalled();
|
|
212
|
+
warnSpy.mockRestore();
|
|
213
|
+
});
|
|
214
|
+
});
|
|
@@ -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,117 @@
|
|
|
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, jest } from '@jest/globals';
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import { docsFreshness } from '../docs-freshness';
|
|
13
|
+
import { buildCheckEnv } 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
|
+
function setupProject(name: string, files: string[]): string {
|
|
21
|
+
return createProjectFixture({
|
|
22
|
+
name: `docs-fresh-${name}`,
|
|
23
|
+
files: Object.fromEntries(files.map(f => [f, 'export const x = 1;'])),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function makeEnv(projectPath: string): ReturnType<typeof buildCheckEnv> {
|
|
28
|
+
const context: ConstraintContext = { operation: 'file_modification', projectPath };
|
|
29
|
+
return buildCheckEnv(context, {
|
|
30
|
+
stagedDiff: async () => '',
|
|
31
|
+
stagedDiffNames: async () => '',
|
|
32
|
+
srcScan: (root: string) => collectSourceFiles(projectPath, [root]),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function writeCap(dir: string, body: string): void {
|
|
37
|
+
fs.writeFileSync(path.join(dir, 'CAPABILITIES.md'), `# Capabilities\n\n${body}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe('docs_freshness — 存在性探测(ADR-0001)', () => {
|
|
41
|
+
it('无 CAPABILITIES.md/CHANGELOG/配置 → skip,不计 pass/fail', async () => {
|
|
42
|
+
const dir = setupProject('none', ['src/module.ts']);
|
|
43
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe('skip');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('docs_freshness — 幽灵判定(文档→代码方向)', () => {
|
|
48
|
+
it('散文文档(无表格)→ 通过', async () => {
|
|
49
|
+
const dir = setupProject('no-table', []);
|
|
50
|
+
writeCap(dir, 'No table here.');
|
|
51
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('登记的文件全部存在 → 通过', async () => {
|
|
55
|
+
const dir = setupProject('valid', ['src/old.ts', 'src/new.ts']);
|
|
56
|
+
writeCap(
|
|
57
|
+
dir,
|
|
58
|
+
`${TABLE_HEAD}| old | src/old.ts | old |\n| new | src/new.ts | new |`
|
|
59
|
+
);
|
|
60
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(true);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('登记的文件已删除 → 失败并点名条目', async () => {
|
|
64
|
+
const dir = setupProject('ghost-file', ['src/old.ts']);
|
|
65
|
+
writeCap(
|
|
66
|
+
dir,
|
|
67
|
+
`${TABLE_HEAD}| old | src/old.ts | old |\n| deleted | src/deleted.ts | deleted |`
|
|
68
|
+
);
|
|
69
|
+
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
70
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(false);
|
|
71
|
+
expect(errSpy).toHaveBeenCalledWith(expect.stringContaining('src/deleted.ts'));
|
|
72
|
+
errSpy.mockRestore();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('登记的目录条目已消失 → 失败(ADR-0009 口径从严,文件+目录都查)', async () => {
|
|
76
|
+
const dir = setupProject('ghost-dir', ['src/core/foo.ts']);
|
|
77
|
+
writeCap(
|
|
78
|
+
dir,
|
|
79
|
+
`${TABLE_HEAD}| 核心 | src/core/ | 核心 |\n| 遗魂 | src/gone/ | 已删目录 |`
|
|
80
|
+
);
|
|
81
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(false);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('登记的目录条目仍存在 → 通过', async () => {
|
|
85
|
+
const dir = setupProject('dir-alive', ['src/core/foo.ts']);
|
|
86
|
+
writeCap(dir, `${TABLE_HEAD}| 核心 | src/core/ | 核心 |`);
|
|
87
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('basename 碰撞场景:全路径幽灵即使同名文件存活仍被报出(2026-08-08 事故回归)', async () => {
|
|
91
|
+
const dir = setupProject('collision', ['src/agents/routes.ts']);
|
|
92
|
+
writeCap(
|
|
93
|
+
dir,
|
|
94
|
+
`${TABLE_HEAD}| routes | src/agents/routes.ts | 活 |\n| 旧路由 | src/agent-configs/routes.ts | 已删 |`
|
|
95
|
+
);
|
|
96
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('docs_freshness — 内置 Runner 检查(changelog/context)', () => {
|
|
101
|
+
it('无 CHANGELOG 但有 CAPABILITIES.md 且条目健康 → 通过', async () => {
|
|
102
|
+
const dir = setupProject('runner-ok', ['src/module.ts']);
|
|
103
|
+
writeCap(dir, `${TABLE_HEAD}| module | src/module.ts | module |`);
|
|
104
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('CHANGELOG 版本与 package.json 漂移 → 失败', async () => {
|
|
108
|
+
const dir = setupProject('ver-drift', ['src/module.ts']);
|
|
109
|
+
writeCap(dir, `${TABLE_HEAD}| module | src/module.ts | module |`);
|
|
110
|
+
fs.writeFileSync(
|
|
111
|
+
path.join(dir, 'package.json'),
|
|
112
|
+
JSON.stringify({ name: 'x', version: '2.0.0' })
|
|
113
|
+
);
|
|
114
|
+
fs.writeFileSync(path.join(dir, 'CHANGELOG.md'), '## [1.0.0] - 2026-01-01\n\n- old\n');
|
|
115
|
+
expect(await docsFreshness.evaluate(makeEnv(dir))).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* governance_presence
|
|
2
|
+
* governance_presence 检查器旁测(studio #302,ADR 2026-08-21 落点模型)
|
|
3
3
|
*
|
|
4
4
|
* 在场守护:PRESERVE 只保「存在」不保「在场」——治理契约段被删除/掏空后
|
|
5
5
|
* sync-docs 重新生成会静默丢失,本 checker 在 harness check 时校验在场性。
|
|
6
|
+
* 测试面 = evaluate(env)(架构评审候选4,自 src/__tests__/ 就近迁入)。
|
|
7
|
+
* 根由 src/test-setup/project-fixture 构造;本套件是 cwd 锚定用例,经
|
|
8
|
+
* parentDir: process.cwd() **显式** opt-out 保持原语义(harness#90 前置约束)。
|
|
6
9
|
*/
|
|
7
10
|
|
|
8
11
|
import { describe, it, expect, beforeEach, afterEach, jest } from '@jest/globals';
|
|
@@ -12,8 +15,10 @@ import {
|
|
|
12
15
|
governancePresence,
|
|
13
16
|
hasGovernancePreserveBlock,
|
|
14
17
|
hasClaudeGovernance,
|
|
15
|
-
} from '../
|
|
16
|
-
import
|
|
18
|
+
} from '../governance-presence';
|
|
19
|
+
import { detectInjectionDrift } from '../../injection-drift';
|
|
20
|
+
import { createProjectFixture, writeProjectConfig } from '../../../../test-setup/project-fixture';
|
|
21
|
+
import type { CheckEnv } from '../types';
|
|
17
22
|
|
|
18
23
|
function makeEnv(projectPath: string): CheckEnv {
|
|
19
24
|
return {
|
|
@@ -39,13 +44,13 @@ describe('governance_presence checker', () => {
|
|
|
39
44
|
let tempDir: string;
|
|
40
45
|
let errorSpy: jest.SpiedFunction<typeof console.error>;
|
|
41
46
|
|
|
42
|
-
const writeConfig = () =>
|
|
43
|
-
fs.mkdirSync(path.join(tempDir, '.harness'), { recursive: true });
|
|
44
|
-
fs.writeFileSync(path.join(tempDir, '.harness', 'config.yml'), 'preset: standard\n');
|
|
45
|
-
};
|
|
47
|
+
const writeConfig = () => writeProjectConfig(tempDir, 'preset: standard\n');
|
|
46
48
|
|
|
47
49
|
beforeEach(() => {
|
|
48
|
-
tempDir =
|
|
50
|
+
tempDir = createProjectFixture({
|
|
51
|
+
name: 'temp-test-gov-presence',
|
|
52
|
+
parentDir: process.cwd(),
|
|
53
|
+
});
|
|
49
54
|
errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
50
55
|
});
|
|
51
56
|
|
|
@@ -70,6 +75,12 @@ describe('governance_presence checker', () => {
|
|
|
70
75
|
expect(await governancePresence.evaluate(makeEnv(tempDir))).toBe(true);
|
|
71
76
|
});
|
|
72
77
|
|
|
78
|
+
it('旧模型豁免:CLAUDE.md 标题双空格变体也认(宽松谓词,fail-open)→ pass', async () => {
|
|
79
|
+
writeConfig();
|
|
80
|
+
fs.writeFileSync(path.join(tempDir, 'CLAUDE.md'), '# CLAUDE.md\n\n## Governance Rules\n\n条款\n');
|
|
81
|
+
expect(await governancePresence.evaluate(makeEnv(tempDir))).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
|
|
73
84
|
it('旧模型豁免:CLAUDE.md 有 HARNESS_CONSTRAINTS 标记 → pass', async () => {
|
|
74
85
|
writeConfig();
|
|
75
86
|
fs.writeFileSync(path.join(tempDir, 'CLAUDE.md'), '<!-- HARNESS_CONSTRAINTS_START -->\nx\n');
|
|
@@ -107,7 +118,10 @@ describe('hasGovernancePreserveBlock / hasClaudeGovernance 判定函数', () =>
|
|
|
107
118
|
let tempDir: string;
|
|
108
119
|
|
|
109
120
|
beforeEach(() => {
|
|
110
|
-
tempDir =
|
|
121
|
+
tempDir = createProjectFixture({
|
|
122
|
+
name: 'temp-test-gov-helpers',
|
|
123
|
+
parentDir: process.cwd(),
|
|
124
|
+
});
|
|
111
125
|
});
|
|
112
126
|
|
|
113
127
|
afterEach(() => {
|
|
@@ -126,4 +140,64 @@ describe('hasGovernancePreserveBlock / hasClaudeGovernance 判定函数', () =>
|
|
|
126
140
|
fs.writeFileSync(p, `<!-- PRESERVE:governance -->\n条款一\n<!-- /PRESERVE:governance -->\n`);
|
|
127
141
|
expect(hasGovernancePreserveBlock(p)).toBe(true);
|
|
128
142
|
});
|
|
143
|
+
|
|
144
|
+
it('结束标记嵌在行中 = 畸形块 → false(显式收紧,#83:按契约丢失报警)', () => {
|
|
145
|
+
const p = path.join(tempDir, 'AGENTS.md');
|
|
146
|
+
fs.writeFileSync(
|
|
147
|
+
p,
|
|
148
|
+
'<!-- PRESERVE:governance -->\n条款一 <!-- /PRESERVE:governance --> 尾注\n'
|
|
149
|
+
);
|
|
150
|
+
expect(hasGovernancePreserveBlock(p)).toBe(false);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('governance_presence × detectInjectionDrift 同 fixture 一致性(#83)', () => {
|
|
155
|
+
let tempDir: string;
|
|
156
|
+
|
|
157
|
+
const writeConfig = () => writeProjectConfig(tempDir, 'preset: standard\n');
|
|
158
|
+
|
|
159
|
+
beforeEach(() => {
|
|
160
|
+
tempDir = createProjectFixture({
|
|
161
|
+
name: 'temp-test-gov-consistency',
|
|
162
|
+
parentDir: process.cwd(),
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
afterEach(() => {
|
|
167
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('双空格标题:presence 认在场(pass),drift 严格计数 0 不报重复——两层不再互相矛盾', async () => {
|
|
171
|
+
writeConfig();
|
|
172
|
+
fs.writeFileSync(path.join(tempDir, 'CLAUDE.md'), '# CLAUDE.md\n\n## Governance Rules\n\n条款\n');
|
|
173
|
+
|
|
174
|
+
expect(await governancePresence.evaluate(makeEnv(tempDir))).toBe(true);
|
|
175
|
+
const drift = detectInjectionDrift(tempDir);
|
|
176
|
+
expect(drift.notInjected).toBe(true);
|
|
177
|
+
expect(drift.duplicateHeading).toBe(false);
|
|
178
|
+
expect(drift.hasDrift).toBe(false);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('精确拼写单标题:presence pass,drift 不报重复', async () => {
|
|
182
|
+
writeConfig();
|
|
183
|
+
fs.writeFileSync(path.join(tempDir, 'CLAUDE.md'), '# CLAUDE.md\n\n## Governance Rules\n\n条款\n');
|
|
184
|
+
|
|
185
|
+
expect(await governancePresence.evaluate(makeEnv(tempDir))).toBe(true);
|
|
186
|
+
const drift = detectInjectionDrift(tempDir);
|
|
187
|
+
expect(drift.notInjected).toBe(true);
|
|
188
|
+
expect(drift.duplicateHeading).toBe(false);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('精确拼写双标题:presence 认在场,drift 报重复章节(计数是 drift 的独立职责)', async () => {
|
|
192
|
+
writeConfig();
|
|
193
|
+
fs.writeFileSync(
|
|
194
|
+
path.join(tempDir, 'CLAUDE.md'),
|
|
195
|
+
'# CLAUDE.md\n\n## Governance Rules\n\n甲\n\n## Governance Rules\n\n乙\n'
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
expect(await governancePresence.evaluate(makeEnv(tempDir))).toBe(true);
|
|
199
|
+
const drift = detectInjectionDrift(tempDir);
|
|
200
|
+
expect(drift.notInjected).toBe(true);
|
|
201
|
+
expect(drift.duplicateHeading).toBe(true);
|
|
202
|
+
});
|
|
129
203
|
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 铁律层 flag 检查旁测(架构评审候选4,ADR-0009 同模式)
|
|
3
|
+
*
|
|
4
|
+
* 三个 flag 铁律均为 contextEvidenceFlag 构造,真实 bug 面 = 读错上下文字段
|
|
5
|
+
* 与三态语义(undefined→skip / false→fail / true→pass)。直接喂不同字段组合
|
|
6
|
+
* 钉死映射,不再经 engine facade(旧测在 skip-semantics/checker.test 间接打)。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect } from '@jest/globals';
|
|
10
|
+
import {
|
|
11
|
+
noCompletionWithoutVerification,
|
|
12
|
+
incrementalProgress,
|
|
13
|
+
noImplementationWithoutRequirement,
|
|
14
|
+
} from '../iron-flags';
|
|
15
|
+
import { buildCheckEnv } from '../types';
|
|
16
|
+
import type { ConstraintContext } from '../../../../types/constraint';
|
|
17
|
+
|
|
18
|
+
const evaluate = (
|
|
19
|
+
check: { evaluate: (env: any) => unknown },
|
|
20
|
+
ctx: Partial<ConstraintContext>
|
|
21
|
+
) => check.evaluate(buildCheckEnv({ ...ctx, operation: 'code_implementation' }, 'none'));
|
|
22
|
+
|
|
23
|
+
describe('iron flags — 三态与字段映射', () => {
|
|
24
|
+
it('no_completion_without_verification → 读 hasVerificationEvidence', async () => {
|
|
25
|
+
expect(await evaluate(noCompletionWithoutVerification, {})).toBe('skip');
|
|
26
|
+
expect(await evaluate(noCompletionWithoutVerification, { hasVerificationEvidence: false })).toBe(false);
|
|
27
|
+
expect(await evaluate(noCompletionWithoutVerification, { hasVerificationEvidence: true })).toBe(true);
|
|
28
|
+
// 相邻字段不串台:hasTest 不能顶替
|
|
29
|
+
expect(await evaluate(noCompletionWithoutVerification, { hasTest: true })).toBe('skip');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('incremental_progress → 读 hasSingleTask', async () => {
|
|
33
|
+
expect(await evaluate(incrementalProgress, {})).toBe('skip');
|
|
34
|
+
expect(await evaluate(incrementalProgress, { hasSingleTask: false })).toBe(false);
|
|
35
|
+
expect(await evaluate(incrementalProgress, { hasSingleTask: true })).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('no_implementation_without_requirement → 读 hasRequirement', async () => {
|
|
39
|
+
expect(await evaluate(noImplementationWithoutRequirement, {})).toBe('skip');
|
|
40
|
+
expect(await evaluate(noImplementationWithoutRequirement, { hasRequirement: false })).toBe(false);
|
|
41
|
+
expect(await evaluate(noImplementationWithoutRequirement, { hasRequirement: true })).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('三 flag 各自独立判定(组合上下文互不影响)', async () => {
|
|
45
|
+
const ctx: Partial<ConstraintContext> = { hasVerificationEvidence: true, hasSingleTask: false };
|
|
46
|
+
expect(await evaluate(noCompletionWithoutVerification, ctx)).toBe(true);
|
|
47
|
+
expect(await evaluate(incrementalProgress, ctx)).toBe(false);
|
|
48
|
+
expect(await evaluate(noImplementationWithoutRequirement, ctx)).toBe('skip');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* no_bypass_checkpoint 检查器旁测(架构评审候选4,ADR-0009 同模式)
|
|
3
|
+
*
|
|
4
|
+
* 测试面 = ConstraintCheck.evaluate(env):判定只读 env.context.changedFiles
|
|
5
|
+
* 的文件内容,无需 git staging(旧 facade 测用真实 git add 属多余 fixture)。
|
|
6
|
+
* 自 checker-extra.test.ts 迁入并补齐 BYPASS_PATTERNS 全表用例。
|
|
7
|
+
* 违规样例字符串一律拼接构造,避免本文件被该检查器自身命中。
|
|
8
|
+
* 项目根由 src/test-setup/project-fixture 声明式构造(回收仍走 mkdtemp-cleanup)。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, it, expect } from '@jest/globals';
|
|
12
|
+
import * as os from 'os';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { noBypassCheckpoint } from '../no-bypass-checkpoint';
|
|
15
|
+
import { buildCheckEnv } from '../types';
|
|
16
|
+
import { createProjectFixture } from '../../../../test-setup/project-fixture';
|
|
17
|
+
import type { ConstraintContext } from '../../../../types/constraint';
|
|
18
|
+
|
|
19
|
+
/** 与 BYPASS_PATTERNS 对齐的违规样例(拼接构造,源文本不含完整模式串) */
|
|
20
|
+
const VIOLATIONS: Array<[string, string]> = [
|
|
21
|
+
['jest/vitest skip 调用', 'test.' + 'skip("skipped", () => {});'],
|
|
22
|
+
['bypass 标志赋值', 'config.byp' + 'ass = true;'],
|
|
23
|
+
['skip 选项', '{ run: { skip' + ': true } }'],
|
|
24
|
+
['显式 bypass 注释', '# bypa' + 'ss checkpoint for perf'],
|
|
25
|
+
['行注释 skip', 'code(); // ' + 'skip this for now'],
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
function writeTemp(name: string, content: string): string {
|
|
29
|
+
const root = createProjectFixture({
|
|
30
|
+
name: `no-bypass-${name}`,
|
|
31
|
+
files: { 'subject.ts': content },
|
|
32
|
+
});
|
|
33
|
+
return path.join(root, 'subject.ts');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function evaluate(changedFiles: string[]) {
|
|
37
|
+
const context: ConstraintContext = {
|
|
38
|
+
operation: 'code_implementation',
|
|
39
|
+
projectPath: process.cwd(),
|
|
40
|
+
changedFiles,
|
|
41
|
+
};
|
|
42
|
+
return noBypassCheckpoint.evaluate(buildCheckEnv(context, 'none'));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe('no_bypass_checkpoint', () => {
|
|
46
|
+
it('无变更文件 → pass(默认放行)', async () => {
|
|
47
|
+
expect(await evaluate([])).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
for (const [label, content] of VIOLATIONS) {
|
|
51
|
+
it(`命中 bypass 模式(${label})→ fail`, async () => {
|
|
52
|
+
expect(await evaluate([writeTemp('hit', content)])).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
it('干净测试文件 → pass(旧 facade 对照用例)', async () => {
|
|
57
|
+
expect(
|
|
58
|
+
await evaluate([writeTemp('clean', 'test("clean", () => { expect(1).toBe(1); });')])
|
|
59
|
+
).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('变更文件已删除(不在 fs)→ 跳过该文件继续', async () => {
|
|
63
|
+
expect(await evaluate([path.join(os.tmpdir(), 'no-bypass-gone', 'ghost.ts')])).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('文件不可读(目录当文件)→ 忽略不炸', async () => {
|
|
67
|
+
const dir = createProjectFixture({ name: 'no-bypass-dir' });
|
|
68
|
+
expect(await evaluate([dir])).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('多文件任一命中即 fail', async () => {
|
|
72
|
+
const clean = writeTemp('multi-clean', 'export const x = 1;');
|
|
73
|
+
const dirty = writeTemp('multi-dirty', VIOLATIONS[0][1]);
|
|
74
|
+
expect(await evaluate([clean, dirty])).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
});
|