@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,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* command 命令测试
|
|
3
|
+
*
|
|
4
|
+
* 判定经返回值断言(架构评审候选7):退出码不再靠 spyOn(process,'exit'),
|
|
5
|
+
* 输出文本走注入 captureIO。
|
|
3
6
|
*/
|
|
4
7
|
|
|
5
8
|
import { executeCommand } from '../command';
|
|
6
9
|
import { createCommandGate, getCommandRiskLevel } from '../../../gates';
|
|
10
|
+
import { captureIO, type CapturingIO } from '../../command-contract';
|
|
7
11
|
|
|
8
12
|
jest.mock('../../../gates', () => ({
|
|
9
13
|
createCommandGate: jest.fn(),
|
|
@@ -25,125 +29,136 @@ jest.mock('chalk', () => ({
|
|
|
25
29
|
const mockCreateGate = createCommandGate as jest.MockedFunction<typeof createCommandGate>;
|
|
26
30
|
const mockGetRisk = getCommandRiskLevel as jest.MockedFunction<typeof getCommandRiskLevel>;
|
|
27
31
|
|
|
32
|
+
function mockGate(check: jest.Mock): void {
|
|
33
|
+
mockCreateGate.mockReturnValue({ check } as any);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** 从捕获输出里取第一条可解析为该形状的 JSON 行 */
|
|
37
|
+
function parseJsonLine(lines: string[], predicate: (parsed: any) => boolean): any {
|
|
38
|
+
for (const line of lines.join('\n').split('\n\n')) {
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(line);
|
|
41
|
+
if (predicate(parsed)) return parsed;
|
|
42
|
+
} catch { /* 非 JSON 行 */ }
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
28
47
|
describe('command command', () => {
|
|
29
|
-
let
|
|
30
|
-
let errorSpy: jest.SpyInstance;
|
|
31
|
-
let exitSpy: jest.SpyInstance;
|
|
48
|
+
let io: CapturingIO;
|
|
32
49
|
|
|
33
50
|
beforeEach(() => {
|
|
34
51
|
jest.clearAllMocks();
|
|
35
|
-
|
|
36
|
-
errorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
37
|
-
exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => undefined as never);
|
|
38
|
-
process.exitCode = 0;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
afterEach(() => {
|
|
42
|
-
consoleSpy.mockRestore();
|
|
43
|
-
errorSpy.mockRestore();
|
|
44
|
-
exitSpy.mockRestore();
|
|
45
|
-
process.exitCode = 0;
|
|
52
|
+
io = captureIO();
|
|
46
53
|
});
|
|
47
54
|
|
|
48
55
|
describe('--list', () => {
|
|
49
|
-
it('
|
|
50
|
-
await executeCommand(undefined, { list: true });
|
|
51
|
-
|
|
52
|
-
expect(
|
|
53
|
-
expect(
|
|
54
|
-
expect(
|
|
56
|
+
it('按类别分组列出规则并返回 ok', async () => {
|
|
57
|
+
const result = await executeCommand(undefined, { list: true }, io);
|
|
58
|
+
|
|
59
|
+
expect(result).toEqual({ kind: 'ok' });
|
|
60
|
+
expect(io.outText()).toContain('命令黑名单规则');
|
|
61
|
+
expect(io.outLines()).toEqual(
|
|
62
|
+
expect.arrayContaining([expect.stringContaining('[destructive]'), expect.stringContaining('[database]')]),
|
|
63
|
+
);
|
|
55
64
|
});
|
|
56
65
|
|
|
57
|
-
it('
|
|
58
|
-
await executeCommand(undefined, { list: true, json: true });
|
|
66
|
+
it('--json 列出规则数组', async () => {
|
|
67
|
+
const result = await executeCommand(undefined, { list: true, json: true }, io);
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
expect(jsonCall).toBeTruthy();
|
|
64
|
-
const parsed = JSON.parse(jsonCall[0]);
|
|
65
|
-
expect(parsed).toHaveLength(2);
|
|
69
|
+
expect(result).toEqual({ kind: 'ok' });
|
|
70
|
+
expect(parseJsonLine(io.outLines(), Array.isArray)).toHaveLength(2);
|
|
66
71
|
});
|
|
67
72
|
});
|
|
68
73
|
|
|
69
74
|
describe('no command', () => {
|
|
70
|
-
it('
|
|
71
|
-
const
|
|
72
|
-
mockCreateGate.mockReturnValue({ check: mockCheck } as any);
|
|
75
|
+
it('缺参数:usage-error + 原因,并提示用法', async () => {
|
|
76
|
+
const result = await executeCommand(undefined, {}, io);
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
expect(result).toEqual({
|
|
79
|
+
kind: 'usage-error',
|
|
80
|
+
reason: expect.stringContaining('缺少要检查的命令参数'),
|
|
81
|
+
});
|
|
82
|
+
expect(io.errText()).toContain('请提供要检查的命令');
|
|
83
|
+
expect(io.outText()).toBe('');
|
|
78
84
|
});
|
|
79
85
|
});
|
|
80
86
|
|
|
81
87
|
describe('default mode', () => {
|
|
82
|
-
it('
|
|
83
|
-
|
|
84
|
-
mockCreateGate.mockReturnValue({ check: mockCheck } as any);
|
|
88
|
+
it('放行:ok,打印 ✓', async () => {
|
|
89
|
+
mockGate(jest.fn().mockResolvedValue({ passed: true, message: 'OK' }));
|
|
85
90
|
|
|
86
|
-
await executeCommand('safe-cmd', {});
|
|
91
|
+
const result = await executeCommand('safe-cmd', {}, io);
|
|
87
92
|
|
|
88
|
-
expect(
|
|
93
|
+
expect(result).toEqual({ kind: 'ok' });
|
|
94
|
+
expect(io.outText()).toContain('✓');
|
|
89
95
|
});
|
|
90
96
|
|
|
91
|
-
it('
|
|
92
|
-
|
|
93
|
-
mockCreateGate.mockReturnValue({ check: mockCheck } as any);
|
|
97
|
+
it('拒绝:fail + 裁决原因,打印 ✗', async () => {
|
|
98
|
+
mockGate(jest.fn().mockResolvedValue({ passed: false, message: 'Blocked' }));
|
|
94
99
|
|
|
95
|
-
await executeCommand('rm -rf /', {});
|
|
100
|
+
const result = await executeCommand('rm -rf /', {}, io);
|
|
96
101
|
|
|
97
|
-
expect(
|
|
98
|
-
expect(
|
|
102
|
+
expect(result).toEqual({ kind: 'fail', reason: expect.stringContaining('Blocked') });
|
|
103
|
+
expect(io.outText()).toContain('✗');
|
|
99
104
|
});
|
|
100
105
|
|
|
101
|
-
it('
|
|
102
|
-
|
|
103
|
-
mockCreateGate.mockReturnValue({ check: mockCheck } as any);
|
|
106
|
+
it('--json 输出裁决详情', async () => {
|
|
107
|
+
mockGate(jest.fn().mockResolvedValue({ passed: true, message: 'OK', details: {} }));
|
|
104
108
|
|
|
105
|
-
await executeCommand('cmd', { json: true });
|
|
109
|
+
await executeCommand('cmd', { json: true }, io);
|
|
106
110
|
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
expect(parseJsonLine(io.outLines(), (p: any) => p.command === 'cmd')).toEqual({
|
|
112
|
+
command: 'cmd',
|
|
113
|
+
passed: true,
|
|
114
|
+
message: 'OK',
|
|
115
|
+
details: {},
|
|
109
116
|
});
|
|
110
|
-
expect(jsonCall).toBeTruthy();
|
|
111
117
|
});
|
|
112
118
|
});
|
|
113
119
|
|
|
114
120
|
describe('--level', () => {
|
|
115
|
-
it('
|
|
121
|
+
it('low:ok,打印等级', async () => {
|
|
116
122
|
mockGetRisk.mockReturnValue('low');
|
|
117
|
-
|
|
118
|
-
mockCreateGate.mockReturnValue({ check: mockCheck } as any);
|
|
123
|
+
mockGate(jest.fn().mockResolvedValue({ passed: true, message: 'OK' }));
|
|
119
124
|
|
|
120
|
-
await executeCommand('safe-cmd', { level: true });
|
|
125
|
+
const result = await executeCommand('safe-cmd', { level: true }, io);
|
|
121
126
|
|
|
122
|
-
expect(
|
|
123
|
-
expect(
|
|
127
|
+
expect(result).toEqual({ kind: 'ok' });
|
|
128
|
+
expect(io.outText()).toContain('low');
|
|
124
129
|
});
|
|
125
130
|
|
|
126
|
-
it('
|
|
131
|
+
it('high:fail + 等级原因(严重级条件式译成 kind)', async () => {
|
|
127
132
|
mockGetRisk.mockReturnValue('high');
|
|
133
|
+
mockGate(jest.fn().mockResolvedValue({ passed: true, message: 'OK' }));
|
|
134
|
+
|
|
135
|
+
const result = await executeCommand('rm -rf /', { level: true }, io);
|
|
136
|
+
|
|
137
|
+
expect(result).toEqual({ kind: 'fail', reason: expect.stringContaining('risk level is high') });
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('high 等级不再执行黑名单裁决分支', async () => {
|
|
128
141
|
const mockCheck = jest.fn().mockResolvedValue({ passed: true, message: 'OK' });
|
|
129
|
-
|
|
142
|
+
mockGetRisk.mockReturnValue('high');
|
|
143
|
+
mockGate(mockCheck);
|
|
130
144
|
|
|
131
|
-
await executeCommand('rm -rf /', { level: true });
|
|
145
|
+
const result = await executeCommand('rm -rf /', { level: true }, io);
|
|
132
146
|
|
|
133
|
-
|
|
147
|
+
// 历史行为:--level 命中即退出,不再打印 pass/fail 行
|
|
148
|
+
expect(result.kind).toBe('fail');
|
|
149
|
+
expect(io.outText()).not.toContain('✓');
|
|
134
150
|
});
|
|
135
151
|
|
|
136
|
-
it('
|
|
152
|
+
it('--json 输出等级', async () => {
|
|
137
153
|
mockGetRisk.mockReturnValue('medium');
|
|
138
|
-
|
|
139
|
-
mockCreateGate.mockReturnValue({ check: mockCheck } as any);
|
|
154
|
+
mockGate(jest.fn().mockResolvedValue({ passed: true, message: 'OK' }));
|
|
140
155
|
|
|
141
|
-
await executeCommand('cmd', { level: true, json: true });
|
|
156
|
+
await executeCommand('cmd', { level: true, json: true }, io);
|
|
142
157
|
|
|
143
|
-
|
|
144
|
-
|
|
158
|
+
expect(parseJsonLine(io.outLines(), (p: any) => p.level !== undefined)).toEqual({
|
|
159
|
+
level: 'medium',
|
|
160
|
+
command: 'cmd',
|
|
145
161
|
});
|
|
146
|
-
expect(jsonCall).toBeTruthy();
|
|
147
162
|
});
|
|
148
163
|
});
|
|
149
164
|
});
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import * as fs from 'fs';
|
|
11
|
-
import
|
|
11
|
+
import { captureIO, type CapturingIO } from '../../command-contract';
|
|
12
12
|
import * as path from 'path';
|
|
13
13
|
import type { ExecutionTrace } from '../../../types/trace';
|
|
14
14
|
import {
|
|
@@ -17,43 +17,24 @@ import {
|
|
|
17
17
|
readProjectTraces,
|
|
18
18
|
} from '../../../core/constraints/usage-report';
|
|
19
19
|
import { constraintsReport, renderExportMarkdown } from '../constraints-report';
|
|
20
|
-
|
|
21
|
-
function makeTmpProject(): string {
|
|
22
|
-
return fs.mkdtempSync(path.join(os.tmpdir(), 'harness-report-test-'));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function writeTraces(root: string, traces: Partial<ExecutionTrace>[]): void {
|
|
26
|
-
const dir = path.join(root, '.harness', 'logs');
|
|
27
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
28
|
-
const lines = traces.map(t =>
|
|
29
|
-
JSON.stringify({
|
|
30
|
-
level: 'guideline',
|
|
31
|
-
timestamp: 1700000000000,
|
|
32
|
-
result: 'pass',
|
|
33
|
-
...t,
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
fs.writeFileSync(path.join(dir, 'traces.log'), lines.join('\n') + '\n', 'utf-8');
|
|
37
|
-
}
|
|
20
|
+
import { createProjectFixture, writeProjectTraces } from '../../../test-setup/project-fixture';
|
|
38
21
|
|
|
39
22
|
/** 生成 N 条同结果 trace */
|
|
40
23
|
function tracesOf(id: string, result: ExecutionTrace['result'], n: number, startTs = 1700000000000): Partial<ExecutionTrace>[] {
|
|
41
24
|
return Array.from({ length: n }, (_, i) => ({ constraintId: id, result, timestamp: startTs + i * 1000 }));
|
|
42
25
|
}
|
|
43
26
|
|
|
44
|
-
let logSpy: jest.SpyInstance;
|
|
45
|
-
|
|
46
27
|
beforeEach(() => {
|
|
47
|
-
logSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
48
28
|
});
|
|
49
29
|
|
|
50
|
-
|
|
51
|
-
|
|
30
|
+
let io: CapturingIO;
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
io = captureIO();
|
|
52
33
|
});
|
|
53
34
|
|
|
54
35
|
describe('buildConstraintsUsageReport', () => {
|
|
55
36
|
it('无 trace 文件:生效集 check 约束全部列出且 total=0,全部判为零触发候选', () => {
|
|
56
|
-
const root =
|
|
37
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
57
38
|
const report = buildConstraintsUsageReport(root);
|
|
58
39
|
|
|
59
40
|
expect(report.traceFileExists).toBe(false);
|
|
@@ -72,8 +53,7 @@ describe('buildConstraintsUsageReport', () => {
|
|
|
72
53
|
});
|
|
73
54
|
|
|
74
55
|
it('空 trace 文件:与无文件一致,但 traceFileExists=true', () => {
|
|
75
|
-
const root =
|
|
76
|
-
writeTraces(root, []);
|
|
56
|
+
const root = createProjectFixture({ name: 'harness-report-test', traces: [] });
|
|
77
57
|
const report = buildConstraintsUsageReport(root);
|
|
78
58
|
|
|
79
59
|
expect(report.traceFileExists).toBe(true);
|
|
@@ -82,8 +62,8 @@ describe('buildConstraintsUsageReport', () => {
|
|
|
82
62
|
});
|
|
83
63
|
|
|
84
64
|
it('含 skip 的统计:skip 不计入 fail 率分母,首次/最近时间正确', () => {
|
|
85
|
-
const root =
|
|
86
|
-
|
|
65
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
66
|
+
writeProjectTraces(root, [
|
|
87
67
|
...tracesOf('no_hardcoded_credentials', 'pass', 3, 1700000000000),
|
|
88
68
|
...tracesOf('no_hardcoded_credentials', 'fail', 1, 1700000100000),
|
|
89
69
|
...tracesOf('no_hardcoded_credentials', 'skip', 2, 1700000200000),
|
|
@@ -104,7 +84,7 @@ describe('buildConstraintsUsageReport', () => {
|
|
|
104
84
|
});
|
|
105
85
|
|
|
106
86
|
it('坏行容错:单行 JSON 损坏不影响其他行统计', () => {
|
|
107
|
-
const root =
|
|
87
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
108
88
|
const dir = path.join(root, '.harness', 'logs');
|
|
109
89
|
fs.mkdirSync(dir, { recursive: true });
|
|
110
90
|
fs.writeFileSync(
|
|
@@ -116,8 +96,8 @@ describe('buildConstraintsUsageReport', () => {
|
|
|
116
96
|
});
|
|
117
97
|
|
|
118
98
|
it('四类候选诊断:零触发/不可评估(flag)/不可评估(探测)/高噪/零拦截', () => {
|
|
119
|
-
const root =
|
|
120
|
-
|
|
99
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
100
|
+
writeProjectTraces(root, [
|
|
121
101
|
// 不可评估(flag 未接线):全部 skip
|
|
122
102
|
...tracesOf('no_completion_without_verification', 'skip', 3),
|
|
123
103
|
// 不可评估(存在性探测未命中):全部 skip
|
|
@@ -156,8 +136,10 @@ describe('buildConstraintsUsageReport', () => {
|
|
|
156
136
|
});
|
|
157
137
|
|
|
158
138
|
it('阈值可配:放宽零拦截样本阈值后 10 次全 pass 也成为候选', () => {
|
|
159
|
-
const root =
|
|
160
|
-
|
|
139
|
+
const root = createProjectFixture({
|
|
140
|
+
name: 'harness-report-test',
|
|
141
|
+
traces: tracesOf('no_hardcoded_credentials', 'pass', 10),
|
|
142
|
+
});
|
|
161
143
|
|
|
162
144
|
const strict = buildConstraintsUsageReport(root);
|
|
163
145
|
expect(strict.candidates.find(c => c.id === 'no_hardcoded_credentials')).toBeUndefined();
|
|
@@ -179,13 +161,10 @@ describe('buildConstraintsUsageReport', () => {
|
|
|
179
161
|
});
|
|
180
162
|
|
|
181
163
|
it('配置健康:config.yml 中未知 id 进入 unknownIds', () => {
|
|
182
|
-
const root =
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
'constraints:\n ghost_constraint:\n enabled: false\n',
|
|
187
|
-
'utf-8'
|
|
188
|
-
);
|
|
164
|
+
const root = createProjectFixture({
|
|
165
|
+
name: 'harness-report-test',
|
|
166
|
+
config: 'constraints:\n ghost_constraint:\n enabled: false\n',
|
|
167
|
+
});
|
|
189
168
|
const report = buildConstraintsUsageReport(root);
|
|
190
169
|
expect(report.lint.unknownIds).toContain('ghost_constraint');
|
|
191
170
|
});
|
|
@@ -193,18 +172,15 @@ describe('buildConstraintsUsageReport', () => {
|
|
|
193
172
|
|
|
194
173
|
describe('constraintsReport CLI', () => {
|
|
195
174
|
it('console 输出包含统计表、候选、注入清单、unknownIds 提示', async () => {
|
|
196
|
-
const root =
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
'utf-8'
|
|
202
|
-
);
|
|
203
|
-
writeTraces(root, tracesOf('no_hardcoded_credentials', 'pass', 3));
|
|
175
|
+
const root = createProjectFixture({
|
|
176
|
+
name: 'harness-report-test',
|
|
177
|
+
config: 'constraints:\n ghost_constraint:\n enabled: false\n',
|
|
178
|
+
traces: tracesOf('no_hardcoded_credentials', 'pass', 3),
|
|
179
|
+
});
|
|
204
180
|
|
|
205
|
-
await constraintsReport({ projectPath: root });
|
|
181
|
+
await constraintsReport({ projectPath: root }, io);
|
|
206
182
|
|
|
207
|
-
const output =
|
|
183
|
+
const output = io.outText();
|
|
208
184
|
expect(output).toContain('约束使用报告');
|
|
209
185
|
expect(output).toContain('no_hardcoded_credentials');
|
|
210
186
|
expect(output).toContain('total=3');
|
|
@@ -214,14 +190,14 @@ describe('constraintsReport CLI', () => {
|
|
|
214
190
|
});
|
|
215
191
|
|
|
216
192
|
it('--export 缺省路径:写入 .harness/reports/constraints-<YYYYMMDD>.md 且内容脱敏', async () => {
|
|
217
|
-
const root =
|
|
218
|
-
|
|
193
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
194
|
+
writeProjectTraces(root, [
|
|
219
195
|
...tracesOf('no_bypass_checkpoint', 'fail', 20),
|
|
220
196
|
// projectPath 字段进 trace,但不得进 export
|
|
221
197
|
{ constraintId: 'no_bypass_checkpoint', result: 'fail', projectPath: root, timestamp: 1700001000000 },
|
|
222
198
|
]);
|
|
223
199
|
|
|
224
|
-
await constraintsReport({ projectPath: root, export: true });
|
|
200
|
+
await constraintsReport({ projectPath: root, export: true }, io);
|
|
225
201
|
|
|
226
202
|
const date = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
|
227
203
|
const exportPath = path.join(root, '.harness', 'reports', `constraints-${date}.md`);
|
|
@@ -237,19 +213,19 @@ describe('constraintsReport CLI', () => {
|
|
|
237
213
|
expect(content).not.toContain('projectPath');
|
|
238
214
|
|
|
239
215
|
// 打印了导出路径
|
|
240
|
-
const output =
|
|
216
|
+
const output = io.outText();
|
|
241
217
|
expect(output).toContain(exportPath);
|
|
242
218
|
});
|
|
243
219
|
|
|
244
220
|
it('--export 指定文件:写到给定路径', async () => {
|
|
245
|
-
const root =
|
|
246
|
-
await constraintsReport({ projectPath: root, export: 'my-report.md' });
|
|
221
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
222
|
+
await constraintsReport({ projectPath: root, export: 'my-report.md' }, io);
|
|
247
223
|
expect(fs.existsSync(path.join(root, 'my-report.md'))).toBe(true);
|
|
248
224
|
});
|
|
249
225
|
|
|
250
226
|
it('renderExportMarkdown:无候选时显式标注', () => {
|
|
251
|
-
const root =
|
|
252
|
-
|
|
227
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
228
|
+
writeProjectTraces(root, [
|
|
253
229
|
// 所有 check 约束给少量健康数据(低于一切阈值)
|
|
254
230
|
...buildConstraintsUsageReport(root).stats.flatMap(s => tracesOf(s.id, 'pass', 5)),
|
|
255
231
|
]);
|
|
@@ -262,6 +238,59 @@ describe('constraintsReport CLI', () => {
|
|
|
262
238
|
});
|
|
263
239
|
});
|
|
264
240
|
|
|
241
|
+
describe('constraintsReport 坏行数透传(harness#100)', () => {
|
|
242
|
+
/** 直接落原始行(含坏行)——writeProjectTraces 只写合法记录,构造不出损坏 fixture */
|
|
243
|
+
function writeRawTraces(root: string, lines: string[]): void {
|
|
244
|
+
const dir = path.join(root, '.harness', 'logs');
|
|
245
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
246
|
+
fs.writeFileSync(path.join(dir, 'traces.log'), lines.join('\n') + '\n', 'utf-8');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const healthyTrace = (id: string) =>
|
|
250
|
+
JSON.stringify({ constraintId: id, level: 'iron_law', timestamp: 1700000000000, result: 'pass' });
|
|
251
|
+
const BAD = '{"constraintId":"ghost","broken';
|
|
252
|
+
|
|
253
|
+
it('坏行 fixture:文本输出出现坏行数提示,--json 报告体带 skippedLines', async () => {
|
|
254
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
255
|
+
writeRawTraces(root, [healthyTrace('no_hardcoded_credentials'), BAD, BAD]);
|
|
256
|
+
|
|
257
|
+
await constraintsReport({ projectPath: root }, io);
|
|
258
|
+
expect(io.outText()).toContain('2 行损坏');
|
|
259
|
+
|
|
260
|
+
const jsonIo = captureIO();
|
|
261
|
+
await constraintsReport({ projectPath: root, json: true }, jsonIo);
|
|
262
|
+
expect(JSON.parse(jsonIo.outText()).skippedLines).toBe(2);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('traceFileExists=true 且无损坏:零噪声(无坏行提示,既有文案不变)', async () => {
|
|
266
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
267
|
+
writeRawTraces(root, [healthyTrace('no_hardcoded_credentials')]);
|
|
268
|
+
|
|
269
|
+
await constraintsReport({ projectPath: root }, io);
|
|
270
|
+
|
|
271
|
+
const output = io.outText();
|
|
272
|
+
expect(output).toContain('约束使用报告');
|
|
273
|
+
expect(output).not.toContain('损坏');
|
|
274
|
+
expect(output).not.toContain('trace 文件不存在');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('--export 摘要同样带坏行数(脱敏:只报条数,不报路径与坏行内容)', async () => {
|
|
278
|
+
const dirty = createProjectFixture({ name: 'harness-report-test' });
|
|
279
|
+
writeRawTraces(dirty, [healthyTrace('no_hardcoded_credentials'), BAD]);
|
|
280
|
+
await constraintsReport({ projectPath: dirty, export: 'report.md' }, captureIO());
|
|
281
|
+
|
|
282
|
+
const dirtyMd = fs.readFileSync(path.join(dirty, 'report.md'), 'utf-8');
|
|
283
|
+
expect(dirtyMd).toContain('1 行损坏');
|
|
284
|
+
expect(dirtyMd).not.toContain(BAD);
|
|
285
|
+
expect(dirtyMd).not.toContain(dirty);
|
|
286
|
+
|
|
287
|
+
const clean = createProjectFixture({ name: 'harness-report-test' });
|
|
288
|
+
writeRawTraces(clean, [healthyTrace('no_hardcoded_credentials')]);
|
|
289
|
+
await constraintsReport({ projectPath: clean, export: 'report.md' }, captureIO());
|
|
290
|
+
expect(fs.readFileSync(path.join(clean, 'report.md'), 'utf-8')).not.toContain('损坏');
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
265
294
|
describe('constraintsReport 注入漂移小节(ADR-0001 决策 7)', () => {
|
|
266
295
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
267
296
|
const realVersion = require('../../../../package.json').version as string;
|
|
@@ -274,7 +303,7 @@ describe('constraintsReport 注入漂移小节(ADR-0001 决策 7)', () => {
|
|
|
274
303
|
};
|
|
275
304
|
|
|
276
305
|
it('有漂移:输出条目级差异(缺失/多余)与修复指引', async () => {
|
|
277
|
-
const root =
|
|
306
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
278
307
|
writeSyncedClaudeMd(root, '0.0.1-old');
|
|
279
308
|
const claudeMdPath = path.join(root, 'CLAUDE.md');
|
|
280
309
|
const content = fs.readFileSync(claudeMdPath, 'utf-8');
|
|
@@ -282,9 +311,9 @@ describe('constraintsReport 注入漂移小节(ADR-0001 决策 7)', () => {
|
|
|
282
311
|
const editedLine = originalLine.replace(/: .+$/, ': 手工篡改');
|
|
283
312
|
fs.writeFileSync(claudeMdPath, content.replace(originalLine, editedLine), 'utf-8');
|
|
284
313
|
|
|
285
|
-
await constraintsReport({ projectPath: root });
|
|
314
|
+
await constraintsReport({ projectPath: root }, io);
|
|
286
315
|
|
|
287
|
-
const output =
|
|
316
|
+
const output = io.outText();
|
|
288
317
|
expect(output).toContain('注入漂移');
|
|
289
318
|
expect(output).toContain('版本漂移');
|
|
290
319
|
expect(output).toContain('0.0.1-old');
|
|
@@ -294,34 +323,34 @@ describe('constraintsReport 注入漂移小节(ADR-0001 决策 7)', () => {
|
|
|
294
323
|
});
|
|
295
324
|
|
|
296
325
|
it('重复章节:输出重复章节提示', async () => {
|
|
297
|
-
const root =
|
|
326
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
298
327
|
writeSyncedClaudeMd(root);
|
|
299
328
|
fs.appendFileSync(path.join(root, 'CLAUDE.md'), '\n## Governance Rules\n\n旧版遗留\n', 'utf-8');
|
|
300
329
|
|
|
301
|
-
await constraintsReport({ projectPath: root });
|
|
330
|
+
await constraintsReport({ projectPath: root }, io);
|
|
302
331
|
|
|
303
|
-
const output =
|
|
332
|
+
const output = io.outText();
|
|
304
333
|
expect(output).toContain('重复章节');
|
|
305
334
|
});
|
|
306
335
|
|
|
307
336
|
it('无漂移:小节显示无漂移', async () => {
|
|
308
|
-
const root =
|
|
337
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
309
338
|
writeSyncedClaudeMd(root);
|
|
310
339
|
|
|
311
|
-
await constraintsReport({ projectPath: root });
|
|
340
|
+
await constraintsReport({ projectPath: root }, io);
|
|
312
341
|
|
|
313
|
-
const output =
|
|
342
|
+
const output = io.outText();
|
|
314
343
|
expect(output).toContain('注入漂移');
|
|
315
344
|
expect(output).toContain('无漂移');
|
|
316
345
|
});
|
|
317
346
|
|
|
318
347
|
it('未注入(无标记段):一句话提示,不算漂移', async () => {
|
|
319
|
-
const root =
|
|
348
|
+
const root = createProjectFixture({ name: 'harness-report-test' });
|
|
320
349
|
fs.writeFileSync(path.join(root, 'CLAUDE.md'), '# Test Project\n', 'utf-8');
|
|
321
350
|
|
|
322
|
-
await constraintsReport({ projectPath: root });
|
|
351
|
+
await constraintsReport({ projectPath: root }, io);
|
|
323
352
|
|
|
324
|
-
const output =
|
|
353
|
+
const output = io.outText();
|
|
325
354
|
expect(output).toContain('未注入');
|
|
326
355
|
});
|
|
327
356
|
});
|