@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
|
@@ -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
|
+
});
|
package/src/{__tests__ → core/constraints/checkers/__tests__}/no-hardcoded-credentials.test.ts
RENAMED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* no_hardcoded_credentials
|
|
2
|
+
* no_hardcoded_credentials 检查器旁测(ADR-0001)
|
|
3
3
|
*
|
|
4
4
|
* 注意:测试夹具中的假凭证一律用字符串拼接构造,
|
|
5
5
|
* 避免本文件自身被凭证扫描(含 harness 自身 staged diff)命中。
|
|
6
|
+
* 测试面 = evaluate(env)(架构评审候选4,自 src/__tests__/ 就近迁入)。
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import { describe, it, expect } from '@jest/globals';
|
|
9
10
|
import {
|
|
10
11
|
noHardcodedCredentials,
|
|
11
12
|
containsHardcodedCredential,
|
|
12
|
-
} from '../
|
|
13
|
-
import type { CheckEnv } from '../
|
|
13
|
+
} from '../no-hardcoded-credentials';
|
|
14
|
+
import type { CheckEnv } from '../types';
|
|
14
15
|
|
|
15
16
|
function makeEnv(stagedDiff: string): CheckEnv {
|
|
16
17
|
return {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* no_test_simplification 检查器旁测(架构评审候选4,ADR-0009 同模式)
|
|
3
|
+
*
|
|
4
|
+
* 测试面 = ConstraintCheck.evaluate(env):判定只吃 stagedDiff 文本,
|
|
5
|
+
* 证据经 providers 注入(旧 facade 测用真实非 git 目录触发 IO 失败,
|
|
6
|
+
* 旁测直接让 provider 抛错表达同一语义)。自 checker-extra.test.ts 迁入。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect } from '@jest/globals';
|
|
10
|
+
import { noTestSimplification } from '../no-test-simplification';
|
|
11
|
+
import { buildCheckEnv } from '../types';
|
|
12
|
+
import type { ConstraintContext } from '../../../../types/constraint';
|
|
13
|
+
|
|
14
|
+
function evaluate(diff: string | (() => Promise<string>)) {
|
|
15
|
+
const context: ConstraintContext = { operation: 'test_creation', projectPath: '/nonexistent' };
|
|
16
|
+
const stagedDiff = typeof diff === 'function' ? diff : async () => diff;
|
|
17
|
+
return noTestSimplification.evaluate(
|
|
18
|
+
buildCheckEnv(context, {
|
|
19
|
+
stagedDiff,
|
|
20
|
+
stagedDiffNames: async () => '',
|
|
21
|
+
srcScan: () => [],
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('no_test_simplification', () => {
|
|
27
|
+
it('删除 test/it/describe → fail', async () => {
|
|
28
|
+
expect(await evaluate('--- a/x.test.ts\n+++ b/x.test.ts\n@@\n- test("gone", () => {});\n')).toBe(false);
|
|
29
|
+
expect(await evaluate('- it("gone", () => {});')).toBe(false);
|
|
30
|
+
expect(await evaluate('-describe("suite", () => {});')).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('删除 expect → fail', async () => {
|
|
34
|
+
expect(await evaluate('- expect(x).toBe(y);')).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('删除注释掉的 test → fail', async () => {
|
|
38
|
+
expect(await evaluate('- // test pending case')).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('仅新增/上下文行 → pass', async () => {
|
|
42
|
+
expect(
|
|
43
|
+
await evaluate('--- a/x.test.ts\n+++ b/x.test.ts\n@@\n+ test("added", () => {});\n expect(1).toBe(1);\n')
|
|
44
|
+
).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('空 diff → pass', async () => {
|
|
48
|
+
expect(await evaluate('')).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('git diff 失败 → 默认通过(fail-open,自 facade 测迁入)', async () => {
|
|
52
|
+
expect(
|
|
53
|
+
await evaluate(async () => {
|
|
54
|
+
throw new Error('not a git repository');
|
|
55
|
+
})
|
|
56
|
+
).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context_files 三态对照测试(工单 84)
|
|
3
|
+
*
|
|
4
|
+
* 同一组 fixture 同时跑 context_doc_sync 与 docs_freshness 两条约束,
|
|
5
|
+
* 钉死 triage 裁决口径:未配置 / enabled 但无目标 → 约束 checker 一律 skip
|
|
6
|
+
* (ADR-0001 存在性探测同构);enabled 且非空 → 两条约束按同一组 dirs
|
|
7
|
+
* 评估且判定一致。
|
|
8
|
+
*
|
|
9
|
+
* 附带 docs_freshness 评估段的行为变更钉子:enabled 但无目标 → skip,
|
|
10
|
+
* 不再静默放行(此前返回 true)。
|
|
11
|
+
* 项目根由 src/test-setup/project-fixture 声明式构造(回收仍走 mkdtemp-cleanup)。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, it, expect } from '@jest/globals';
|
|
15
|
+
import { contextDocSync } from '../context-doc-sync';
|
|
16
|
+
import { docsFreshness } from '../docs-freshness';
|
|
17
|
+
import { buildCheckEnv, normalizeCheckOutcome, type CheckOutcome } from '../types';
|
|
18
|
+
import { collectSourceFiles } from '../../capabilities-reconcile';
|
|
19
|
+
import { createProjectFixture } from '../../../../test-setup/project-fixture';
|
|
20
|
+
import type { ConstraintContext } from '../../../../types/constraint';
|
|
21
|
+
|
|
22
|
+
const TABLE_HEAD = '| 模块 | 文件 | 说明 |\n|------|------|------|\n';
|
|
23
|
+
|
|
24
|
+
interface Fixture {
|
|
25
|
+
configYml?: string;
|
|
26
|
+
contextMdDirs?: string[];
|
|
27
|
+
files?: string[];
|
|
28
|
+
capabilitiesBody?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function setupDir(name: string, fixture: Fixture = {}): string {
|
|
32
|
+
return createProjectFixture({
|
|
33
|
+
name: `three-state-${name}`,
|
|
34
|
+
config: fixture.configYml,
|
|
35
|
+
files: {
|
|
36
|
+
...Object.fromEntries((fixture.files ?? []).map(f => [f, 'export const x = 1;'])),
|
|
37
|
+
...Object.fromEntries((fixture.contextMdDirs ?? []).map(d => [`${d}/CONTEXT.md`, `# ${d}\n`])),
|
|
38
|
+
...(fixture.capabilitiesBody === undefined
|
|
39
|
+
? {}
|
|
40
|
+
: { 'CAPABILITIES.md': `# Capabilities\n\n${fixture.capabilitiesBody}` }),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const CTX_FILES = (enabled: boolean, dirs?: string[]) =>
|
|
46
|
+
`governance:\n context_files:\n enabled: ${enabled}\n` +
|
|
47
|
+
(dirs ? ` required_dirs: [${dirs.map(d => `'${d}'`).join(', ')}]\n` : '');
|
|
48
|
+
|
|
49
|
+
function evalContextDocSync(dir: string) {
|
|
50
|
+
const context: ConstraintContext = { operation: 'module_modification', projectPath: dir };
|
|
51
|
+
return contextDocSync.evaluate(buildCheckEnv(context, 'none'));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function evalDocsFreshness(dir: string) {
|
|
55
|
+
const context: ConstraintContext = { operation: 'file_modification', projectPath: dir };
|
|
56
|
+
return docsFreshness.evaluate(
|
|
57
|
+
buildCheckEnv(context, {
|
|
58
|
+
stagedDiff: async () => '',
|
|
59
|
+
stagedDiffNames: async () => '',
|
|
60
|
+
srcScan: (root: string) => collectSourceFiles(dir, [root]),
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** 三态判定(比较判定结论本身,不比较返回形状——harness#119 后 checker 可带回证据) */
|
|
66
|
+
function verdictOf(outcome: CheckOutcome): true | false | 'skip' {
|
|
67
|
+
const normalized = normalizeCheckOutcome(outcome);
|
|
68
|
+
return normalized.skipped ? 'skip' : normalized.satisfied;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 同一 fixture 上两条约束的判定必须一致(对照断言) */
|
|
72
|
+
async function expectBoth(dir: string, verdict: true | false | 'skip'): Promise<void> {
|
|
73
|
+
expect(verdictOf(await evalContextDocSync(dir))).toBe(verdict);
|
|
74
|
+
expect(verdictOf(await evalDocsFreshness(dir))).toBe(verdict);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
describe('context_files 三态对照 — context_doc_sync vs docs_freshness(工单 84)', () => {
|
|
78
|
+
it('未配置(无 config.yml)→ 双双 skip', async () => {
|
|
79
|
+
await expectBoth(setupDir('no-config'), 'skip');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('governance.context_files 段缺失 → 双双 skip', async () => {
|
|
83
|
+
await expectBoth(setupDir('no-section', { configYml: 'preset: standard\n' }), 'skip');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('enabled: false(约定未采用)→ 双双 skip', async () => {
|
|
87
|
+
await expectBoth(setupDir('disabled', { configYml: CTX_FILES(false, ['src']) }), 'skip');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('enabled 但 required_dirs 缺失(约定已立但无目标)→ 双双 skip', async () => {
|
|
91
|
+
await expectBoth(setupDir('no-dirs', { configYml: CTX_FILES(true) }), 'skip');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('enabled 但 required_dirs 为空数组 → 双双 skip', async () => {
|
|
95
|
+
await expectBoth(setupDir('empty-dirs', { configYml: CTX_FILES(true, []) }), 'skip');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('enabled 但 required_dirs 含非字符串项(脏配置)→ 双双 skip 而非抛错', async () => {
|
|
99
|
+
await expectBoth(
|
|
100
|
+
setupDir('dirty-dirs', {
|
|
101
|
+
configYml: 'governance:\n context_files:\n enabled: true\n required_dirs: [1, null]\n',
|
|
102
|
+
}),
|
|
103
|
+
'skip'
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('enabled 且非空 + CONTEXT.md 齐全 → 双双 pass(同一组 dirs 同一判定)', async () => {
|
|
108
|
+
await expectBoth(
|
|
109
|
+
setupDir('all-present', {
|
|
110
|
+
configYml: CTX_FILES(true, ['src', 'bin']),
|
|
111
|
+
contextMdDirs: ['src', 'bin'],
|
|
112
|
+
}),
|
|
113
|
+
true
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('enabled 且非空 + CONTEXT.md 缺失 → 双双 fail', async () => {
|
|
118
|
+
await expectBoth(
|
|
119
|
+
setupDir('missing-doc', { configYml: CTX_FILES(true, ['src', 'bin']) }),
|
|
120
|
+
false
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('docs_freshness 评估段 skip 行为变更(工单 84:约定已立但无目标不再静默放行)', () => {
|
|
126
|
+
it('doc_freshness.checks 已配 + enabled 但 required_dirs 缺失 → skip(原为 true)', async () => {
|
|
127
|
+
const dir = setupDir('checks-plus-empty', {
|
|
128
|
+
configYml:
|
|
129
|
+
'governance:\n doc_freshness:\n checks:\n - type: changelog_version\n context_files:\n enabled: true\n',
|
|
130
|
+
});
|
|
131
|
+
expect(await evalDocsFreshness(dir)).toBe('skip');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('enabled 但空 + CAPABILITIES.md 健康 → skip(原为 true)', async () => {
|
|
135
|
+
const dir = setupDir('caps-healthy', {
|
|
136
|
+
configYml: CTX_FILES(true),
|
|
137
|
+
files: ['src/module.ts'],
|
|
138
|
+
capabilitiesBody: `${TABLE_HEAD}| module | src/module.ts | module |`,
|
|
139
|
+
});
|
|
140
|
+
expect(await evalDocsFreshness(dir)).toBe('skip');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('enabled 但空 + CAPABILITIES.md 幽灵条目 → 仍 fail(Step 1 文件表判定不因 context_files 受影响)', async () => {
|
|
144
|
+
const dir = setupDir('caps-ghost', {
|
|
145
|
+
configYml: CTX_FILES(true),
|
|
146
|
+
files: ['src/old.ts'],
|
|
147
|
+
capabilitiesBody: `${TABLE_HEAD}| old | src/old.ts | 活 |\n| 遗魂 | src/gone/ | 已删 |`,
|
|
148
|
+
});
|
|
149
|
+
const outcome = await evalDocsFreshness(dir);
|
|
150
|
+
expect(verdictOf(outcome)).toBe(false);
|
|
151
|
+
expect(normalizeCheckOutcome(outcome).evidence.join('\n')).toContain('src/gone/');
|
|
152
|
+
});
|
|
153
|
+
});
|