@dommaker/harness 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +0 -2
- package/bin/harness.js +86 -32
- package/dist/cli/command-contract.d.ts +83 -0
- package/dist/cli/command-contract.d.ts.map +1 -0
- package/dist/cli/command-contract.js +66 -0
- package/dist/cli/command-contract.js.map +1 -0
- package/dist/cli/commands/acceptance.d.ts +3 -2
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +28 -24
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/analyze-sessions.d.ts +2 -1
- package/dist/cli/commands/analyze-sessions.d.ts.map +1 -1
- package/dist/cli/commands/analyze-sessions.js +25 -24
- package/dist/cli/commands/analyze-sessions.js.map +1 -1
- package/dist/cli/commands/check.d.ts +14 -2
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +104 -61
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/command.d.ts +5 -1
- package/dist/cli/commands/command.d.ts.map +1 -1
- package/dist/cli/commands/command.js +26 -17
- package/dist/cli/commands/command.js.map +1 -1
- package/dist/cli/commands/constraints-report.d.ts +2 -1
- package/dist/cli/commands/constraints-report.d.ts.map +1 -1
- package/dist/cli/commands/constraints-report.js +37 -33
- package/dist/cli/commands/constraints-report.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +6 -5
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +50 -52
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/constraints.d.ts +2 -1
- package/dist/cli/commands/constraints.d.ts.map +1 -1
- package/dist/cli/commands/constraints.js +10 -27
- package/dist/cli/commands/constraints.js.map +1 -1
- package/dist/cli/commands/contract.d.ts +3 -2
- package/dist/cli/commands/contract.d.ts.map +1 -1
- package/dist/cli/commands/contract.js +45 -42
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts +11 -11
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +27 -219
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/failure.d.ts +5 -4
- package/dist/cli/commands/failure.d.ts.map +1 -1
- package/dist/cli/commands/failure.js +31 -25
- package/dist/cli/commands/failure.js.map +1 -1
- package/dist/cli/commands/init.d.ts +7 -5
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +147 -211
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/knowledge.d.ts +17 -30
- package/dist/cli/commands/knowledge.d.ts.map +1 -1
- package/dist/cli/commands/knowledge.js +183 -273
- package/dist/cli/commands/knowledge.js.map +1 -1
- package/dist/cli/commands/passes-gate.d.ts +8 -2
- package/dist/cli/commands/passes-gate.d.ts.map +1 -1
- package/dist/cli/commands/passes-gate.js +44 -66
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/performance.d.ts +2 -1
- package/dist/cli/commands/performance.d.ts.map +1 -1
- package/dist/cli/commands/performance.js +20 -18
- package/dist/cli/commands/performance.js.map +1 -1
- package/dist/cli/commands/posteval-plan.d.ts +5 -1
- package/dist/cli/commands/posteval-plan.d.ts.map +1 -1
- package/dist/cli/commands/posteval-plan.js +26 -15
- package/dist/cli/commands/posteval-plan.js.map +1 -1
- package/dist/cli/commands/release.d.ts +6 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +69 -59
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/report.d.ts +2 -1
- package/dist/cli/commands/report.d.ts.map +1 -1
- package/dist/cli/commands/report.js +9 -5
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/review.d.ts +3 -2
- package/dist/cli/commands/review.d.ts.map +1 -1
- package/dist/cli/commands/review.js +33 -29
- package/dist/cli/commands/review.js.map +1 -1
- package/dist/cli/commands/sdd.d.ts +2 -1
- package/dist/cli/commands/sdd.d.ts.map +1 -1
- package/dist/cli/commands/sdd.js +7 -5
- package/dist/cli/commands/sdd.js.map +1 -1
- package/dist/cli/commands/security.d.ts +3 -2
- package/dist/cli/commands/security.d.ts.map +1 -1
- package/dist/cli/commands/security.js +29 -26
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts +2 -1
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +15 -11
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/spec.d.ts +7 -2
- package/dist/cli/commands/spec.d.ts.map +1 -1
- package/dist/cli/commands/spec.js +61 -51
- package/dist/cli/commands/spec.js.map +1 -1
- package/dist/cli/commands/status.d.ts +2 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +57 -53
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +5 -2
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +3 -2
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts +2 -1
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +68 -88
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts +6 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +14 -16
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/commands/update-user-model.d.ts +9 -3
- package/dist/cli/commands/update-user-model.d.ts.map +1 -1
- package/dist/cli/commands/update-user-model.js +56 -61
- package/dist/cli/commands/update-user-model.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +4 -3
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +28 -26
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/session-mining/transcript.d.ts +7 -1
- package/dist/cli/session-mining/transcript.d.ts.map +1 -1
- package/dist/cli/session-mining/transcript.js +21 -14
- package/dist/cli/session-mining/transcript.js.map +1 -1
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +19 -32
- package/dist/context/session-manager.js.map +1 -1
- package/dist/core/constraints/agent-prompt-renderer.d.ts.map +1 -1
- package/dist/core/constraints/agent-prompt-renderer.js +1 -4
- package/dist/core/constraints/agent-prompt-renderer.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +24 -7
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +32 -28
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/capabilities-reconcile.d.ts +67 -0
- package/dist/core/constraints/capabilities-reconcile.d.ts.map +1 -0
- package/dist/core/constraints/capabilities-reconcile.js +105 -0
- package/dist/core/constraints/capabilities-reconcile.js.map +1 -0
- package/dist/core/constraints/checker.d.ts +21 -43
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +68 -117
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts +20 -8
- package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +66 -77
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.d.ts +4 -2
- package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.js +13 -22
- package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.d.ts.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js +49 -66
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.d.ts +2 -2
- package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.js +7 -28
- package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
- package/dist/core/constraints/checkers/index.d.ts +2 -2
- package/dist/core/constraints/checkers/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/index.js +2 -1
- package/dist/core/constraints/checkers/index.js.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.js +4 -3
- package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +43 -4
- package/dist/core/constraints/checkers/types.d.ts.map +1 -1
- package/dist/core/constraints/checkers/types.js +33 -0
- package/dist/core/constraints/checkers/types.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts +15 -14
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +32 -96
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +2 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/git-evidence.d.ts +60 -0
- package/dist/core/constraints/git-evidence.d.ts.map +1 -0
- package/dist/core/constraints/git-evidence.js +88 -0
- package/dist/core/constraints/git-evidence.js.map +1 -0
- package/dist/core/constraints/injection-drift.d.ts +3 -20
- package/dist/core/constraints/injection-drift.d.ts.map +1 -1
- package/dist/core/constraints/injection-drift.js +10 -57
- package/dist/core/constraints/injection-drift.js.map +1 -1
- package/dist/core/constraints/injection-writer.d.ts +113 -0
- package/dist/core/constraints/injection-writer.d.ts.map +1 -0
- package/dist/core/constraints/injection-writer.js +228 -0
- package/dist/core/constraints/injection-writer.js.map +1 -0
- package/dist/core/constraints/usage-report.d.ts +22 -1
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +27 -20
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +32 -1
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +39 -9
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +15 -64
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +84 -222
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/core/validators/test-output.d.ts +58 -0
- package/dist/core/validators/test-output.d.ts.map +1 -0
- package/dist/core/validators/test-output.js +109 -0
- package/dist/core/validators/test-output.js.map +1 -0
- package/dist/failure/recorder.d.ts +6 -0
- package/dist/failure/recorder.d.ts.map +1 -1
- package/dist/failure/recorder.js +12 -8
- package/dist/failure/recorder.js.map +1 -1
- package/dist/gates/acceptance.d.ts +1 -48
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +6 -38
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/checker-gate.d.ts +2 -1
- package/dist/gates/checker-gate.d.ts.map +1 -1
- package/dist/gates/checker-gate.js +11 -13
- package/dist/gates/checker-gate.js.map +1 -1
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +10 -22
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +22 -61
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +13 -31
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +21 -53
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +14 -32
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +28 -5
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/gates/types.js +38 -1
- package/dist/gates/types.js.map +1 -1
- package/dist/hooks/bootstrap.d.ts +2 -0
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +5 -2
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit.d.ts +7 -2
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +59 -79
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/flywheel-metrics.d.ts +39 -0
- package/dist/knowledge/flywheel-metrics.d.ts.map +1 -0
- package/dist/knowledge/flywheel-metrics.js +47 -0
- package/dist/knowledge/flywheel-metrics.js.map +1 -0
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +4 -14
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +17 -14
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/ingest.d.ts.map +1 -1
- package/dist/knowledge/ingest.js +9 -4
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/migration.d.ts.map +1 -1
- package/dist/knowledge/migration.js +11 -8
- package/dist/knowledge/migration.js.map +1 -1
- package/dist/knowledge/reference-tracker.d.ts.map +1 -1
- package/dist/knowledge/reference-tracker.js +12 -9
- package/dist/knowledge/reference-tracker.js.map +1 -1
- package/dist/knowledge/store.d.ts +15 -0
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +59 -10
- package/dist/knowledge/store.js.map +1 -1
- package/dist/monitoring/context-tracker.d.ts.map +1 -1
- package/dist/monitoring/context-tracker.js +11 -20
- package/dist/monitoring/context-tracker.js.map +1 -1
- package/dist/monitoring/index.d.ts +1 -1
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/index.js +1 -2
- package/dist/monitoring/index.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +15 -0
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +19 -2
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +21 -2
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +38 -29
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/release/index.d.ts +2 -2
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +1 -5
- package/dist/release/index.js.map +1 -1
- package/dist/sdd/index-generator.js +10 -11
- package/dist/sdd/index-generator.js.map +1 -1
- package/dist/test-setup/project-fixture.d.ts +48 -0
- package/dist/test-setup/project-fixture.d.ts.map +1 -0
- package/dist/test-setup/project-fixture.js +106 -0
- package/dist/test-setup/project-fixture.js.map +1 -0
- package/dist/types/constraint.d.ts +8 -18
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js +6 -1
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/passes-gate.d.ts +10 -25
- package/dist/types/passes-gate.d.ts.map +1 -1
- package/dist/types/project-config.d.ts +1 -1
- package/dist/types/session.d.ts +6 -5
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/trace.d.ts +9 -0
- package/dist/types/trace.d.ts.map +1 -1
- package/dist/utils/exec.d.ts +10 -0
- package/dist/utils/exec.d.ts.map +1 -1
- package/dist/utils/exec.js +12 -0
- package/dist/utils/exec.js.map +1 -1
- package/dist/utils/file-walk.d.ts +9 -1
- package/dist/utils/file-walk.d.ts.map +1 -1
- package/dist/utils/file-walk.js +10 -1
- package/dist/utils/file-walk.js.map +1 -1
- package/dist/utils/frontmatter.d.ts +73 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +141 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/jsonl.d.ts +92 -0
- package/dist/utils/jsonl.d.ts.map +1 -0
- package/dist/utils/jsonl.js +166 -0
- package/dist/utils/jsonl.js.map +1 -0
- package/dist/utils/package-version.d.ts +16 -0
- package/dist/utils/package-version.d.ts.map +1 -0
- package/dist/utils/package-version.js +63 -0
- package/dist/utils/package-version.js.map +1 -0
- package/package.json +1 -1
- package/src/CONTEXT.md +8 -2
- package/src/__tests__/acceptance-gate.test.ts +3 -1
- package/src/__tests__/checker-extra.test.ts +7 -1218
- package/src/__tests__/context-files-resolution.test.ts +116 -0
- package/src/__tests__/effective-constraints.test.ts +10 -13
- package/src/__tests__/exec.test.ts +35 -1
- package/src/__tests__/layering.test.ts +152 -0
- package/src/__tests__/passes-gate-extra.test.ts +0 -145
- package/src/__tests__/passes-gate.test.ts +130 -101
- package/src/__tests__/skip-semantics.test.ts +5 -9
- package/src/cli/__tests__/command-contract.test.ts +170 -0
- package/src/cli/command-contract.ts +108 -0
- package/src/cli/commands/CONTEXT.md +23 -8
- package/src/cli/commands/__tests__/acceptance.test.ts +40 -33
- package/src/cli/commands/__tests__/analyze-sessions.test.ts +35 -29
- package/src/cli/commands/__tests__/bin-exit-mapping.test.ts +107 -0
- package/src/cli/commands/__tests__/check-drift.test.ts +27 -34
- package/src/cli/commands/__tests__/check-skip-output.test.ts +21 -24
- package/src/cli/commands/__tests__/check.test.ts +448 -378
- package/src/cli/commands/__tests__/command.test.ts +85 -70
- package/src/cli/commands/__tests__/constraints-report.test.ts +100 -71
- package/src/cli/commands/__tests__/constraints-retire.test.ts +152 -95
- package/src/cli/commands/__tests__/contract.test.ts +27 -34
- package/src/cli/commands/__tests__/failure.test.ts +31 -34
- package/src/cli/commands/__tests__/init-injection.test.ts +58 -28
- package/src/cli/commands/__tests__/init.test.ts +77 -48
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +108 -0
- package/src/cli/commands/__tests__/knowledge.test.ts +69 -43
- package/src/cli/commands/__tests__/passes-gate.test.ts +43 -45
- package/src/cli/commands/__tests__/performance.test.ts +22 -23
- package/src/cli/commands/__tests__/posteval-plan.test.ts +39 -38
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +157 -0
- package/src/cli/commands/__tests__/project-path-convention.test.ts +231 -0
- package/src/cli/commands/__tests__/registry.test.ts +75 -35
- package/src/cli/commands/__tests__/release.test.ts +209 -80
- package/src/cli/commands/__tests__/report-extra.test.ts +16 -16
- package/src/cli/commands/__tests__/report.test.ts +25 -25
- package/src/cli/commands/__tests__/review.test.ts +33 -31
- package/src/cli/commands/__tests__/security.test.ts +23 -27
- package/src/cli/commands/__tests__/spec-baseline-check.test.ts +20 -20
- package/src/cli/commands/__tests__/spec.test.ts +41 -29
- package/src/cli/commands/__tests__/status-extra.test.ts +18 -18
- package/src/cli/commands/__tests__/status-skipped-lines.test.ts +72 -0
- package/src/cli/commands/__tests__/status.test.ts +34 -34
- package/src/cli/commands/__tests__/sync-docs-agents.test.ts +77 -78
- package/src/cli/commands/__tests__/sync-docs.test.ts +72 -74
- package/src/cli/commands/__tests__/update-user-model.test.ts +97 -34
- package/src/cli/commands/__tests__/validate.test.ts +27 -29
- package/src/cli/commands/acceptance.ts +35 -24
- package/src/cli/commands/analyze-sessions.ts +25 -24
- package/src/cli/commands/check.ts +127 -66
- package/src/cli/commands/command.ts +30 -17
- package/src/cli/commands/constraints-report.ts +37 -34
- package/src/cli/commands/constraints-retire.ts +58 -55
- package/src/cli/commands/constraints.ts +10 -27
- package/src/cli/commands/contract.ts +51 -42
- package/src/cli/commands/definitions.ts +34 -227
- package/src/cli/commands/failure.ts +33 -26
- package/src/cli/commands/init.ts +166 -220
- package/src/cli/commands/knowledge.ts +192 -289
- package/src/cli/commands/passes-gate.ts +58 -68
- package/src/cli/commands/performance.ts +23 -18
- package/src/cli/commands/posteval-plan.ts +29 -15
- package/src/cli/commands/release.ts +70 -59
- package/src/cli/commands/report.ts +9 -5
- package/src/cli/commands/review.ts +39 -29
- package/src/cli/commands/sdd.ts +7 -5
- package/src/cli/commands/security.ts +35 -26
- package/src/cli/commands/spec-baseline-check.ts +16 -11
- package/src/cli/commands/spec.ts +66 -53
- package/src/cli/commands/status.ts +59 -53
- package/src/cli/commands/sync-docs/agents-syncer.ts +5 -2
- package/src/cli/commands/sync-docs/context-syncer.ts +3 -2
- package/src/cli/commands/sync-docs/index.ts +73 -100
- package/src/cli/commands/sync-docs/project-reader.ts +17 -18
- package/src/cli/commands/update-user-model.ts +64 -61
- package/src/cli/commands/validate.ts +31 -25
- package/src/cli/session-mining/__tests__/transcript.test.ts +118 -0
- package/src/cli/session-mining/transcript.ts +26 -8
- package/src/context/session-manager.ts +19 -33
- package/src/core/CONTEXT.md +10 -6
- package/src/core/constraints/__tests__/capabilities-reconcile.test.ts +200 -0
- package/src/core/constraints/__tests__/capability-counts.test.ts +94 -0
- package/src/core/constraints/__tests__/git-evidence.test.ts +208 -0
- package/src/core/constraints/__tests__/injection-drift.test.ts +3 -10
- package/src/core/constraints/__tests__/injection-writer.test.ts +231 -0
- package/src/core/constraints/__tests__/trace-injection.test.ts +71 -0
- package/src/core/constraints/__tests__/usage-report.test.ts +112 -0
- package/src/core/constraints/agent-prompt-renderer.ts +2 -6
- package/src/core/constraints/capabilities-parser.ts +53 -35
- package/src/core/constraints/capabilities-reconcile.ts +166 -0
- package/src/core/constraints/checker.ts +82 -133
- package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +273 -0
- package/src/core/constraints/checkers/__tests__/check-outcome.test.ts +176 -0
- package/src/core/constraints/checkers/__tests__/context-doc-sync.test.ts +77 -0
- package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +126 -0
- package/src/{__tests__ → core/constraints/checkers/__tests__}/governance-presence.test.ts +83 -9
- package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +50 -0
- package/src/core/constraints/checkers/__tests__/no-bypass-checkpoint.test.ts +76 -0
- package/src/{__tests__ → core/constraints/checkers/__tests__}/no-hardcoded-credentials.test.ts +4 -3
- package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +58 -0
- package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +153 -0
- package/src/core/constraints/checkers/capability-sync.ts +75 -96
- package/src/core/constraints/checkers/context-doc-sync.ts +15 -25
- package/src/core/constraints/checkers/docs-freshness.ts +54 -70
- package/src/core/constraints/checkers/governance-presence.ts +7 -25
- package/src/core/constraints/checkers/index.ts +9 -2
- package/src/core/constraints/checkers/no-test-simplification.ts +4 -3
- package/src/core/constraints/checkers/types.ts +60 -4
- package/src/core/constraints/context-builder.ts +39 -91
- package/src/core/constraints/doc-freshness/runner.ts +2 -1
- package/src/core/constraints/git-evidence.ts +120 -0
- package/src/core/constraints/injection-drift.ts +13 -60
- package/src/core/constraints/injection-writer.ts +212 -0
- package/src/core/constraints/usage-report.ts +36 -17
- package/src/core/index.ts +4 -2
- package/src/core/project-config-loader.ts +49 -9
- package/src/core/validators/__tests__/passes-gate.test.ts +2 -56
- package/src/core/validators/__tests__/test-output.test.ts +372 -0
- package/src/core/validators/passes-gate.ts +86 -248
- package/src/core/validators/test-output.ts +128 -0
- package/src/failure/__tests__/recorder.test.ts +168 -0
- package/src/failure/recorder.ts +12 -10
- package/src/gates/CONTEXT.md +7 -4
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +68 -0
- package/src/gates/__tests__/acceptance.test.ts +4 -86
- package/src/gates/__tests__/checker-gate.test.ts +24 -0
- package/src/gates/__tests__/effective-gates.test.ts +3 -8
- package/src/gates/__tests__/test-verdict-consistency.test.ts +140 -0
- package/src/gates/acceptance.ts +19 -84
- package/src/gates/checker-gate.ts +12 -15
- package/src/gates/command.ts +10 -16
- package/src/gates/contract.ts +22 -61
- package/src/gates/performance.ts +10 -22
- package/src/gates/review.ts +21 -41
- package/src/gates/security.ts +10 -22
- package/src/gates/types.ts +70 -5
- package/src/hooks/CONTEXT.md +1 -1
- package/src/hooks/bootstrap.ts +5 -2
- package/src/index.ts +0 -4
- package/src/knowledge/CONTEXT.md +8 -3
- package/src/knowledge/__tests__/audit-labels.test.ts +44 -0
- package/src/knowledge/__tests__/flywheel-metrics.test.ts +135 -0
- package/src/knowledge/__tests__/import.test.ts +44 -0
- package/src/knowledge/__tests__/index-generator.test.ts +53 -0
- package/src/knowledge/__tests__/ingest.test.ts +85 -0
- package/src/knowledge/__tests__/migration.test.ts +47 -0
- package/src/knowledge/__tests__/reference-tracker.test.ts +16 -0
- package/src/knowledge/__tests__/store.test.ts +194 -0
- package/src/knowledge/audit.ts +67 -71
- package/src/knowledge/flywheel-metrics.ts +71 -0
- package/src/knowledge/import.ts +4 -18
- package/src/knowledge/index-generator.ts +19 -14
- package/src/knowledge/ingest.ts +9 -4
- package/src/knowledge/migration.ts +11 -8
- package/src/knowledge/reference-tracker.ts +12 -8
- package/src/knowledge/store.ts +64 -11
- package/src/monitoring/CONTEXT.md +8 -3
- package/src/monitoring/__tests__/skipped-lines-report.test.ts +178 -0
- package/src/monitoring/__tests__/traces.test.ts +57 -0
- package/src/monitoring/context-tracker.ts +11 -23
- package/src/monitoring/index.ts +1 -1
- package/src/monitoring/trace-analyzer.ts +21 -2
- package/src/monitoring/traces.ts +39 -36
- package/src/release/CONTEXT.md +1 -0
- package/src/release/__tests__/barrel.test.ts +60 -0
- package/src/release/index.ts +2 -13
- package/src/sdd/__tests__/index-generator.test.ts +71 -0
- package/src/sdd/index-generator.ts +9 -9
- package/src/test-setup/__tests__/project-fixture.test.ts +178 -0
- package/src/test-setup/project-fixture.ts +87 -0
- package/src/tools/CONTEXT.md +6 -0
- package/src/tools/__tests__/registry.test.ts +221 -0
- package/src/types/__tests__/types.test.ts +4 -5
- package/src/types/constraint.ts +16 -27
- package/src/types/passes-gate.ts +10 -30
- package/src/types/project-config.ts +1 -1
- package/src/types/session.ts +5 -5
- package/src/types/trace.ts +10 -0
- package/src/utils/__tests__/frontmatter.test.ts +206 -0
- package/src/utils/__tests__/jsonl-skip-disposition.test.ts +175 -0
- package/src/utils/__tests__/jsonl.test.ts +187 -0
- package/src/utils/__tests__/package-version.test.ts +97 -0
- package/src/utils/exec.ts +15 -0
- package/src/utils/file-walk.ts +11 -2
- package/src/utils/frontmatter.ts +121 -0
- package/src/utils/jsonl.ts +167 -0
- package/src/utils/package-version.ts +27 -0
- package/dist/cli/commands/doc-freshness-check.d.ts +0 -53
- package/dist/cli/commands/doc-freshness-check.d.ts.map +0 -1
- package/dist/cli/commands/doc-freshness-check.js +0 -352
- package/dist/cli/commands/doc-freshness-check.js.map +0 -1
- package/dist/types/index.d.ts +0 -14
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -39
- package/dist/types/index.js.map +0 -1
- package/src/__tests__/long-running.test.ts +0 -17
- package/src/__tests__/passes-gate-extension.test.ts +0 -151
- package/src/cli/commands/__tests__/doc-freshness-check.test.ts +0 -168
- package/src/cli/commands/doc-freshness-check.ts +0 -386
- package/src/spec/CONTEXT.md +0 -11
- package/src/types/index.ts +0 -47
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* release barrel 导出面守卫(harness#92,ADR-0003 一致性收口)
|
|
3
|
+
*
|
|
4
|
+
* barrel 只再导出包根公开面:`getCriticalArtifacts` / `verifyReleaseArtifacts` /
|
|
5
|
+
* `ArtifactIntegrityResult`。构件清单助手(HARNESS_PACKAGE_NAME、
|
|
6
|
+
* EXTRA_CRITICAL_ARTIFACTS、deriveCriticalArtifacts、resolvePackageRoot +
|
|
7
|
+
* PackagePublishManifest、PackageExports 类型)属 integrity.ts 内部 seam,
|
|
8
|
+
* 唯一消费方 integrity.test.ts 直接 `from '../integrity'`,不经 barrel。
|
|
9
|
+
* 值面靠下面的运行时键集合断言;类型面无运行时痕迹,靠两条 @ts-expect-error
|
|
10
|
+
* 在编译期把关——barrel 一旦恢复再导出,指令失效即报错。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { describe, it, expect } from '@jest/globals';
|
|
14
|
+
import * as fs from 'fs';
|
|
15
|
+
import * as path from 'path';
|
|
16
|
+
import {
|
|
17
|
+
HARNESS_PACKAGE_NAME,
|
|
18
|
+
EXTRA_CRITICAL_ARTIFACTS,
|
|
19
|
+
deriveCriticalArtifacts,
|
|
20
|
+
resolvePackageRoot,
|
|
21
|
+
} from '../integrity';
|
|
22
|
+
import type { PackagePublishManifest as InternalManifest } from '../integrity';
|
|
23
|
+
// @ts-expect-error PackagePublishManifest 属 integrity.ts 内部类型,不经 barrel 导出(harness#92)
|
|
24
|
+
import type { PackagePublishManifest } from '../index';
|
|
25
|
+
// @ts-expect-error PackageExports 属 integrity.ts 内部类型,不经 barrel 导出(harness#92)
|
|
26
|
+
import type { PackageExports } from '../index';
|
|
27
|
+
|
|
28
|
+
describe('release barrel 导出面(harness#92)', () => {
|
|
29
|
+
it('barrel 运行时只再导出包根公开的两个函数', async () => {
|
|
30
|
+
const mod = await import('../index');
|
|
31
|
+
expect(Object.keys(mod).sort()).toEqual(['getCriticalArtifacts', 'verifyReleaseArtifacts']);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('barrel 导出面不含内部清单符号与清单类型名', async () => {
|
|
35
|
+
const mod = await import('../index');
|
|
36
|
+
for (const internal of [
|
|
37
|
+
'HARNESS_PACKAGE_NAME',
|
|
38
|
+
'EXTRA_CRITICAL_ARTIFACTS',
|
|
39
|
+
'deriveCriticalArtifacts',
|
|
40
|
+
'resolvePackageRoot',
|
|
41
|
+
'PackagePublishManifest',
|
|
42
|
+
'PackageExports',
|
|
43
|
+
]) {
|
|
44
|
+
expect(mod).not.toHaveProperty(internal);
|
|
45
|
+
}
|
|
46
|
+
// 两个清单类型只能在编译期证伪,此处消费导入名让上面的 @ts-expect-error 进入生效路径
|
|
47
|
+
const manifestFromBarrel = null as PackagePublishManifest | null;
|
|
48
|
+
const exportsFromBarrel = null as PackageExports | null;
|
|
49
|
+
expect([manifestFromBarrel, exportsFromBarrel]).toEqual([null, null]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('收回私有不等于删除:内部 seam 仍在 integrity.ts 就地可达', () => {
|
|
53
|
+
const manifest: InternalManifest = { name: HARNESS_PACKAGE_NAME };
|
|
54
|
+
expect(deriveCriticalArtifacts(manifest)).toEqual([]);
|
|
55
|
+
expect(EXTRA_CRITICAL_ARTIFACTS.length).toBeGreaterThan(0);
|
|
56
|
+
const pkgRoot = resolvePackageRoot(__dirname);
|
|
57
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(pkgRoot, 'package.json'), 'utf8'));
|
|
58
|
+
expect(pkg.name).toBe(HARNESS_PACKAGE_NAME);
|
|
59
|
+
});
|
|
60
|
+
});
|
package/src/release/index.ts
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
EXTRA_CRITICAL_ARTIFACTS,
|
|
4
|
-
deriveCriticalArtifacts,
|
|
5
|
-
resolvePackageRoot,
|
|
6
|
-
getCriticalArtifacts,
|
|
7
|
-
verifyReleaseArtifacts,
|
|
8
|
-
} from './integrity';
|
|
9
|
-
export type {
|
|
10
|
-
PackagePublishManifest,
|
|
11
|
-
PackageExports,
|
|
12
|
-
ArtifactIntegrityResult,
|
|
13
|
-
} from './integrity';
|
|
1
|
+
export { getCriticalArtifacts, verifyReleaseArtifacts } from './integrity';
|
|
2
|
+
export type { ArtifactIntegrityResult } from './integrity';
|
|
@@ -147,4 +147,75 @@ describe('SDDIndexGenerator', () => {
|
|
|
147
147
|
expect(result.entries[0].slug).toBe('alpha');
|
|
148
148
|
expect(result.entries[1].slug).toBe('zebra');
|
|
149
149
|
});
|
|
150
|
+
|
|
151
|
+
describe('frontmatter 收口(harness#89)', () => {
|
|
152
|
+
let errorSpy: jest.SpyInstance;
|
|
153
|
+
|
|
154
|
+
beforeEach(() => {
|
|
155
|
+
errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
afterEach(() => {
|
|
159
|
+
errorSpy.mockRestore();
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
function writeRaw(slug: string, raw: string): void {
|
|
163
|
+
const dir = path.join(sddDir, slug);
|
|
164
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
165
|
+
fs.writeFileSync(path.join(dir, 'requirement.md'), raw);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
it('未闭合:跳过并显式上报(收口前静默跳过)', () => {
|
|
169
|
+
writeRaw('broken-open', '---\nslug: broken-open\nstatus: done\ntitle: "断头"\n');
|
|
170
|
+
|
|
171
|
+
const result = new SDDIndexGenerator(tmpDir).regenerate();
|
|
172
|
+
|
|
173
|
+
expect(result.count).toBe(0);
|
|
174
|
+
expect(errorSpy).toHaveBeenCalledTimes(1);
|
|
175
|
+
expect(errorSpy.mock.calls[0][0]).toMatch(/\[harness\].*unterminated.*broken-open/);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('闭合行不完整(--- 后带内容):不再当闭合——上报并跳过(收口前会静默收录该条)', () => {
|
|
179
|
+
writeRaw('bad-close', '---\nslug: bad-close\nstatus: done\n---broken\n\n# 正文\n');
|
|
180
|
+
|
|
181
|
+
const result = new SDDIndexGenerator(tmpDir).regenerate();
|
|
182
|
+
|
|
183
|
+
expect(result.count).toBe(0);
|
|
184
|
+
expect(errorSpy).toHaveBeenCalledTimes(1);
|
|
185
|
+
expect(errorSpy.mock.calls[0][0]).toMatch(/\[harness\].*unterminated/);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('YAML 非法:跳过并上报 invalid-yaml(收口前静默跳过)', () => {
|
|
189
|
+
writeRaw('bad-yaml', '---\nslug: [1,\n---\n\n# 正文\n');
|
|
190
|
+
|
|
191
|
+
const result = new SDDIndexGenerator(tmpDir).regenerate();
|
|
192
|
+
|
|
193
|
+
expect(result.count).toBe(0);
|
|
194
|
+
expect(errorSpy).toHaveBeenCalledTimes(1);
|
|
195
|
+
expect(errorSpy.mock.calls[0][0]).toMatch(/\[harness\].*invalid-yaml/);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('缺 frontmatter 与空 meta:静默跳过(absent 是合法输入,不上报)', () => {
|
|
199
|
+
writeRaw('no-fm', '# 没有 frontmatter\n\n正文\n');
|
|
200
|
+
writeRaw('empty-meta', '---\n\n---\n\n# 空头\n');
|
|
201
|
+
|
|
202
|
+
const result = new SDDIndexGenerator(tmpDir).regenerate();
|
|
203
|
+
|
|
204
|
+
expect(result.count).toBe(0);
|
|
205
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('正文含 --- 分隔线不影响 meta 解析(sdd 只取 meta,body 有意忽略)', () => {
|
|
209
|
+
writeRaw(
|
|
210
|
+
'with-rules',
|
|
211
|
+
'---\nslug: with-rules\nstatus: done\ntitle: "带分隔线"\n---\n\n# 带分隔线\n\n---\n\n## 处置\n'
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
const result = new SDDIndexGenerator(tmpDir).regenerate();
|
|
215
|
+
|
|
216
|
+
expect(result.count).toBe(1);
|
|
217
|
+
expect(result.entries[0].title).toBe('带分隔线');
|
|
218
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
219
|
+
});
|
|
220
|
+
});
|
|
150
221
|
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as fs from 'fs';
|
|
6
6
|
import * as path from 'path';
|
|
7
|
-
import
|
|
7
|
+
import { splitFrontmatter } from '../utils/frontmatter';
|
|
8
8
|
|
|
9
9
|
const INDEX_FILENAME = '_index.md';
|
|
10
10
|
|
|
@@ -54,7 +54,7 @@ export class SDDIndexGenerator {
|
|
|
54
54
|
if (!fs.existsSync(reqPath)) continue;
|
|
55
55
|
|
|
56
56
|
const content = fs.readFileSync(reqPath, 'utf-8');
|
|
57
|
-
const fm = this.parseFrontmatter(content);
|
|
57
|
+
const fm = this.parseFrontmatter(reqPath, content);
|
|
58
58
|
if (!fm) continue;
|
|
59
59
|
|
|
60
60
|
// Skip stale SDDs
|
|
@@ -73,14 +73,14 @@ export class SDDIndexGenerator {
|
|
|
73
73
|
return entries;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
private parseFrontmatter(content: string): Record<string, unknown> | null {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return null;
|
|
76
|
+
private parseFrontmatter(filePath: string, content: string): Record<string, unknown> | null {
|
|
77
|
+
const fm = splitFrontmatter(content);
|
|
78
|
+
if (fm.state === 'ok') return fm.meta;
|
|
79
|
+
if (fm.state === 'malformed') {
|
|
80
|
+
// 统一口径(harness#89):损坏必须显式上报后跳过,不静默丢条目
|
|
81
|
+
console.error(`[harness] SDD 索引 frontmatter ${fm.reason}(${fm.detail}),已跳过 ${filePath}`);
|
|
83
82
|
}
|
|
83
|
+
return null;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
private sanitize(s: string): string {
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* project-fixture 构造 API 测试(架构评审 2026-09-02 候选11 / harness#90)
|
|
3
|
+
*
|
|
4
|
+
* 钉死三条契约:
|
|
5
|
+
* 1) 缺省根 = os.tmpdir(),`config` 槽位逐字节落 `.harness/config.yml`(不做 YAML 往返——
|
|
6
|
+
* 被检代码大量用例是畸形/脏配置,原样落盘是硬需求);
|
|
7
|
+
* 2) 非缺省根必须经 parentDir **显式**声明(cwd 锚定用例的前置约束,不隐式继承默认根);
|
|
8
|
+
* 3) 建出的根由 mkdtemp 劫持登记 = 用例结束自动清理,且 name 形状可被超龄兜底清扫识别。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, it, expect } from '@jest/globals';
|
|
12
|
+
import * as fs from 'fs';
|
|
13
|
+
import * as os from 'os';
|
|
14
|
+
import * as path from 'path';
|
|
15
|
+
import { createProjectFixture, writeProjectConfig, writeProjectTraces } from '../project-fixture';
|
|
16
|
+
import { isRegisteredTmpDir } from '../mkdtemp-cleanup';
|
|
17
|
+
import { DEFAULT_TRACE_FILE } from '../../types/trace';
|
|
18
|
+
|
|
19
|
+
/** mkdtemp-cleanup.ts 的超龄清扫签名(name 不合规的夹具目录漏网后永不被扫) */
|
|
20
|
+
const SWEEP_SIGNATURE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*-[A-Za-z0-9]{6}$/;
|
|
21
|
+
|
|
22
|
+
describe('createProjectFixture — 根与 config 槽位', () => {
|
|
23
|
+
it('缺省根在 os.tmpdir(),config 逐字节落 .harness/config.yml', () => {
|
|
24
|
+
const root = createProjectFixture({ name: 'pfx-default', config: 'preset: standard\n' });
|
|
25
|
+
|
|
26
|
+
expect(path.dirname(root)).toBe(os.tmpdir());
|
|
27
|
+
expect(fs.readFileSync(path.join(root, '.harness', 'config.yml'), 'utf-8')).toBe('preset: standard\n');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('省略 config → 不写 .harness/config.yml(存在性探测类用例依赖此语义)', () => {
|
|
31
|
+
const root = createProjectFixture({ name: 'pfx-no-config' });
|
|
32
|
+
|
|
33
|
+
expect(fs.existsSync(path.join(root, '.harness', 'config.yml'))).toBe(false);
|
|
34
|
+
expect(fs.existsSync(path.join(root, '.harness'))).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('config 为空字符串仍算声明(falsy 不得退化为“不写”)', () => {
|
|
38
|
+
const root = createProjectFixture({ name: 'pfx-empty-config', config: '' });
|
|
39
|
+
|
|
40
|
+
expect(fs.readFileSync(path.join(root, '.harness', 'config.yml'), 'utf-8')).toBe('');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('files 按相对路径落盘,父目录自动创建', () => {
|
|
44
|
+
const root = createProjectFixture({
|
|
45
|
+
name: 'pfx-files',
|
|
46
|
+
files: {
|
|
47
|
+
'src/core/foo.ts': 'export const x = 1;',
|
|
48
|
+
'src/CONTEXT.md': '# src\n',
|
|
49
|
+
'.harness/custom-constraints.yml': 'custom_constraints: {}\n',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
expect(fs.readFileSync(path.join(root, 'src/core/foo.ts'), 'utf-8')).toBe('export const x = 1;');
|
|
54
|
+
expect(fs.readFileSync(path.join(root, 'src/CONTEXT.md'), 'utf-8')).toBe('# src\n');
|
|
55
|
+
// 通用槽位不得踩 config 正本路径:两者共存时各写各的
|
|
56
|
+
expect(fs.readFileSync(path.join(root, '.harness/custom-constraints.yml'), 'utf-8')).toBe(
|
|
57
|
+
'custom_constraints: {}\n'
|
|
58
|
+
);
|
|
59
|
+
expect(fs.existsSync(path.join(root, '.harness/config.yml'))).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('config 与 files 同时声明 → 两侧都落盘', () => {
|
|
63
|
+
const root = createProjectFixture({
|
|
64
|
+
name: 'pfx-both',
|
|
65
|
+
config: 'preset: relaxed\n',
|
|
66
|
+
files: { 'CAPABILITIES.md': '# Capabilities\n' },
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(fs.readFileSync(path.join(root, '.harness/config.yml'), 'utf-8')).toBe('preset: relaxed\n');
|
|
70
|
+
expect(fs.readFileSync(path.join(root, 'CAPABILITIES.md'), 'utf-8')).toBe('# Capabilities\n');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('createProjectFixture — 显式 opt-out 根', () => {
|
|
75
|
+
it('parentDir 声明的根落在该父目录下,而非缺省 tmpdir', () => {
|
|
76
|
+
const parent = createProjectFixture({ name: 'pfx-parent' });
|
|
77
|
+
const root = createProjectFixture({ name: 'pfx-child', parentDir: parent });
|
|
78
|
+
|
|
79
|
+
expect(path.dirname(root)).toBe(parent);
|
|
80
|
+
expect(root.startsWith(path.join(parent, 'pfx-child-'))).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('parentDir: process.cwd() → 根落在仓库工作目录(cwd 锚定套件依赖的正是这条语义)', () => {
|
|
84
|
+
const root = createProjectFixture({ name: 'pfx-cwd-anchor', parentDir: process.cwd() });
|
|
85
|
+
try {
|
|
86
|
+
expect(path.dirname(root)).toBe(process.cwd());
|
|
87
|
+
expect(fs.existsSync(root)).toBe(true);
|
|
88
|
+
} finally {
|
|
89
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('opt-out 用例仍被 mkdtemp 劫持登记(自动清理不依赖调用方手动 rm)', () => {
|
|
94
|
+
const parent = createProjectFixture({ name: 'pfx-optout-parent' });
|
|
95
|
+
const root = createProjectFixture({ name: 'pfx-optout-child', parentDir: parent });
|
|
96
|
+
|
|
97
|
+
expect(isRegisteredTmpDir(root)).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('缺省根同样登记,且目录名符合超龄清扫签名(漏网目录可被兜底扫掉)', () => {
|
|
101
|
+
const root = createProjectFixture({ name: 'pfx-sweepable' });
|
|
102
|
+
|
|
103
|
+
expect(isRegisteredTmpDir(root)).toBe(true);
|
|
104
|
+
expect(SWEEP_SIGNATURE.test(path.basename(root))).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('name 形状不合规(大写/下划线/空)→ 抛错,不静默产出扫不掉的目录', () => {
|
|
108
|
+
expect(() => createProjectFixture({ name: 'Pfx-Bad' })).toThrow(/name/);
|
|
109
|
+
expect(() => createProjectFixture({ name: 'pfx_bad' })).toThrow(/name/);
|
|
110
|
+
expect(() => createProjectFixture({ name: '' })).toThrow(/name/);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('writeProjectConfig — config 落盘唯一正本', () => {
|
|
115
|
+
it('根下无 .harness 时自动建目录并写入', () => {
|
|
116
|
+
const root = createProjectFixture({ name: 'pfx-writer' });
|
|
117
|
+
|
|
118
|
+
writeProjectConfig(root, 'gates:\n order:\n - security\n');
|
|
119
|
+
|
|
120
|
+
expect(fs.readFileSync(path.join(root, '.harness', 'config.yml'), 'utf-8')).toBe(
|
|
121
|
+
'gates:\n order:\n - security\n'
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('已有 config 时覆盖写(用例内后续改配置不叠加旧内容)', () => {
|
|
126
|
+
const root = createProjectFixture({ name: 'pfx-rewrite', config: 'preset: standard\n' });
|
|
127
|
+
|
|
128
|
+
writeProjectConfig(root, 'preset: relaxed\n');
|
|
129
|
+
|
|
130
|
+
expect(fs.readFileSync(path.join(root, '.harness', 'config.yml'), 'utf-8')).toBe('preset: relaxed\n');
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('traces 槽位 / writeProjectTraces — trace 落盘正本(harness#108)', () => {
|
|
135
|
+
it('traces 槽位逐条落 DEFAULT_TRACE_FILE,缺省字段补齐(level/timestamp/result)', () => {
|
|
136
|
+
const root = createProjectFixture({
|
|
137
|
+
name: 'pfx-traces',
|
|
138
|
+
traces: [{ constraintId: 'c1', result: 'fail' }],
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const lines = fs.readFileSync(path.join(root, DEFAULT_TRACE_FILE), 'utf-8').trim().split('\n');
|
|
142
|
+
expect(lines).toHaveLength(1);
|
|
143
|
+
expect(JSON.parse(lines[0])).toEqual({
|
|
144
|
+
level: 'guideline',
|
|
145
|
+
timestamp: 1700000000000,
|
|
146
|
+
result: 'fail',
|
|
147
|
+
constraintId: 'c1',
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('traces 槽位缺省 → 不写 trace 文件(traceFileExists=false 用例依赖此语义)', () => {
|
|
152
|
+
const root = createProjectFixture({ name: 'pfx-no-traces' });
|
|
153
|
+
|
|
154
|
+
expect(fs.existsSync(path.join(root, DEFAULT_TRACE_FILE))).toBe(false);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('writeProjectTraces 空数组仍落空文件(traceFileExists=true、零记录语义)', () => {
|
|
158
|
+
const root = createProjectFixture({ name: 'pfx-empty-traces' });
|
|
159
|
+
|
|
160
|
+
writeProjectTraces(root, []);
|
|
161
|
+
|
|
162
|
+
expect(fs.existsSync(path.join(root, DEFAULT_TRACE_FILE))).toBe(true);
|
|
163
|
+
expect(fs.readFileSync(path.join(root, DEFAULT_TRACE_FILE), 'utf-8')).toBe('');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('writeProjectTraces 覆盖写:用例内重写不叠加旧记录', () => {
|
|
167
|
+
const root = createProjectFixture({
|
|
168
|
+
name: 'pfx-rewrite-traces',
|
|
169
|
+
traces: [{ constraintId: 'old' }],
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
writeProjectTraces(root, [{ constraintId: 'new' }]);
|
|
173
|
+
|
|
174
|
+
const lines = fs.readFileSync(path.join(root, DEFAULT_TRACE_FILE), 'utf-8').trim().split('\n');
|
|
175
|
+
expect(lines).toHaveLength(1);
|
|
176
|
+
expect(JSON.parse(lines[0]).constraintId).toBe('new');
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 测试项目夹具构造 API(架构评审 2026-09-02 候选11 / harness#90)
|
|
3
|
+
*
|
|
4
|
+
* 职责:建一个临时项目根并按声明落 fixture,替掉散在各测试套件的
|
|
5
|
+
* `mkdtempSync + mkdir('.harness') + writeFileSync('config.yml')` 手写组合。
|
|
6
|
+
*
|
|
7
|
+
* 设计口径(triage 裁决):
|
|
8
|
+
* - **语义声明**而非文件树声明:`config`/`traces` 是独立槽位(`.harness/config.yml`
|
|
9
|
+
* 与 `DEFAULT_TRACE_FILE` 的形状正本只有这里知道),其余文件走 `files` 相对路径。
|
|
10
|
+
* constraints/knowledge 槽位随后续票补。
|
|
11
|
+
* - `config` 只收字符串、原样落盘:被检代码大量用例是畸形/脏配置(`governance: [`、
|
|
12
|
+
* `required_dirs: [1, null]`、未知 preset 名),YAML 往返会把这些用例抹平。
|
|
13
|
+
* - 非缺省根必须经 `parentDir` **显式**声明:默认根统一为 tmpdir,
|
|
14
|
+
* 路径锚定生产代码的用例(cwd 锚定)靠 opt-out 保持原语义,不隐式继承。
|
|
15
|
+
* - 清理不在本模块做:根经 `fs.mkdtempSync` 创建,由 ./mkdtemp-cleanup 的劫持在
|
|
16
|
+
* afterAll 统一回收(setupFilesAfterEnv 已全局装载)。
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import * as fs from 'fs';
|
|
20
|
+
import * as os from 'os';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
import { DEFAULT_TRACE_FILE, type ExecutionTrace } from '../types/trace';
|
|
23
|
+
import { appendJsonl } from '../utils/jsonl';
|
|
24
|
+
|
|
25
|
+
/** config.yml 相对项目根的落点(全仓唯一处,测试与生产读取口径在此对齐) */
|
|
26
|
+
const CONFIG_REL = path.join('.harness', 'config.yml');
|
|
27
|
+
|
|
28
|
+
/** name 只允许小写字母数字与连字符——见 mkdtemp-cleanup 的超龄清扫签名,大写/下划线会让漏网目录永不被扫 */
|
|
29
|
+
const NAME_RE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
30
|
+
|
|
31
|
+
export interface ProjectFixtureDecl {
|
|
32
|
+
/** 用例标签,进入 mkdtemp 前缀(残留目录可定位到用例);小写连字符 */
|
|
33
|
+
name: string;
|
|
34
|
+
/** `.harness/config.yml` 内容,原样落盘;省略 = 不写该文件(未采用约定语义) */
|
|
35
|
+
config?: string;
|
|
36
|
+
/**
|
|
37
|
+
* trace 槽位(harness#108):落 `DEFAULT_TRACE_FILE` 的 JSONL 记录;
|
|
38
|
+
* 省略 = 不写该文件(traceFileExists=false 语义)。缺省字段补齐见 writeProjectTraces
|
|
39
|
+
*/
|
|
40
|
+
traces?: Partial<ExecutionTrace>[];
|
|
41
|
+
/** 其余文件:相对路径 → 内容,父目录自动创建 */
|
|
42
|
+
files?: Record<string, string>;
|
|
43
|
+
/** 显式 opt-out:临时根的父目录,缺省 `os.tmpdir()`;cwd 锚定用例传 `process.cwd()` */
|
|
44
|
+
parentDir?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** 写入(或覆盖)项目根的 `.harness/config.yml`——用例内后续改配置走这里,不再手拼路径 */
|
|
48
|
+
export function writeProjectConfig(projectRoot: string, content: string): void {
|
|
49
|
+
const target = path.join(projectRoot, CONFIG_REL);
|
|
50
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
51
|
+
fs.writeFileSync(target, content, 'utf-8');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 写入(或覆盖)项目根的 trace 文件——路径锚定生产正本 DEFAULT_TRACE_FILE,
|
|
56
|
+
* 序列化走生产写链 appendJsonl(harness#108:测试不再手拼路径与 JSONL 形状,
|
|
57
|
+
* 生产端改格式时测试随之失真可见而非静默脱节)。
|
|
58
|
+
*
|
|
59
|
+
* 缺省字段补齐 level/timestamp/result(与原各套件 writeTraces 的口径一致),
|
|
60
|
+
* 调用方按需覆盖。覆盖语义:先清空再逐条 append;空数组仍落空文件
|
|
61
|
+
* (traceFileExists=true、零记录)。
|
|
62
|
+
*/
|
|
63
|
+
export function writeProjectTraces(projectRoot: string, traces: Partial<ExecutionTrace>[]): void {
|
|
64
|
+
const target = path.join(projectRoot, DEFAULT_TRACE_FILE);
|
|
65
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
66
|
+
fs.writeFileSync(target, '', 'utf-8');
|
|
67
|
+
for (const t of traces) {
|
|
68
|
+
appendJsonl(target, { level: 'guideline', timestamp: 1700000000000, result: 'pass', ...t });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** 建临时项目根并落声明式 fixture,返回根路径 */
|
|
73
|
+
export function createProjectFixture(decl: ProjectFixtureDecl): string {
|
|
74
|
+
if (!NAME_RE.test(decl.name)) {
|
|
75
|
+
throw new Error(`project-fixture: name 必须是小写连字符标签(收到 "${decl.name}"),否则残留目录无法被超龄清扫识别`);
|
|
76
|
+
}
|
|
77
|
+
const parent = decl.parentDir ?? os.tmpdir();
|
|
78
|
+
const root = fs.mkdtempSync(path.join(parent, `${decl.name}-`));
|
|
79
|
+
if (decl.config !== undefined) writeProjectConfig(root, decl.config);
|
|
80
|
+
if (decl.traces !== undefined) writeProjectTraces(root, decl.traces);
|
|
81
|
+
for (const [rel, content] of Object.entries(decl.files ?? {})) {
|
|
82
|
+
const target = path.join(root, rel);
|
|
83
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
84
|
+
fs.writeFileSync(target, content, 'utf-8');
|
|
85
|
+
}
|
|
86
|
+
return root;
|
|
87
|
+
}
|
package/src/tools/CONTEXT.md
CHANGED
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
## 约定
|
|
14
14
|
- 工具定义目录路径由 paths 模块解析
|
|
15
15
|
- `definitions/` 为静态能力目录,构建时复制到 dist
|
|
16
|
+
- **yml 目录是正本、`registry.json` 是派生索引**(#91 裁决):二者一致性由 `__tests__/registry.test.ts`
|
|
17
|
+
按 ADR-0009 的 reconcile 形状守(双向集合对照 + 条目 path 指向存在的 yml + `name` 与 yml 内 `name` 一致)。
|
|
18
|
+
新增能力 = 先落 yml,再补 registry 条目,缺一即测试红。**不做 yml schema 校验**——那等于替 studio 定能力契约。
|
|
19
|
+
`rollback` 重名 ×2(std/deploy 与 std/governance)是既有事实,进豁免名单;重名是否合法另票裁决。
|
|
20
|
+
- `paths.ts` 单变方**不是**假 seam(#91 裁决):它是包根公开导出(`src/index.ts`,由 public-exports 测试钉住),
|
|
21
|
+
实际消费方是 studio 外部仓,本仓内无第二调用方属预期形状,留任
|
|
16
22
|
|
|
17
23
|
## 注意事项
|
|
18
24
|
- 旧工具注册表/核心工具/加载器/类型定义已随 H1(#40)删除,仅保留路径管理与能力目录
|