@dommaker/harness 1.7.0 → 1.8.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 +37 -0
- package/bin/harness.js +17 -1
- package/dist/agents/index.d.ts +6 -2
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +6 -16
- package/dist/agents/index.js.map +1 -1
- package/dist/cli/commands/__tests__/gate-decision.d.ts +18 -0
- package/dist/cli/commands/__tests__/gate-decision.d.ts.map +1 -0
- package/dist/cli/commands/__tests__/gate-decision.js +26 -0
- package/dist/cli/commands/__tests__/gate-decision.js.map +1 -0
- package/dist/cli/commands/acceptance.d.ts.map +1 -1
- package/dist/cli/commands/acceptance.js +17 -28
- package/dist/cli/commands/acceptance.js.map +1 -1
- package/dist/cli/commands/check.d.ts +11 -3
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +26 -11
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/command.d.ts +0 -1
- package/dist/cli/commands/command.d.ts.map +1 -1
- package/dist/cli/commands/command.js +8 -6
- package/dist/cli/commands/command.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +36 -57
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/contract.d.ts.map +1 -1
- package/dist/cli/commands/contract.js +36 -42
- package/dist/cli/commands/contract.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts +2 -0
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +11 -6
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/failure.d.ts.map +1 -1
- package/dist/cli/commands/failure.js +16 -2
- package/dist/cli/commands/failure.js.map +1 -1
- package/dist/cli/commands/init.d.ts +14 -8
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +172 -364
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/knowledge-view.d.ts +90 -0
- package/dist/cli/commands/knowledge-view.d.ts.map +1 -0
- package/dist/cli/commands/knowledge-view.js +198 -0
- package/dist/cli/commands/knowledge-view.js.map +1 -0
- package/dist/cli/commands/knowledge.d.ts +137 -52
- package/dist/cli/commands/knowledge.d.ts.map +1 -1
- package/dist/cli/commands/knowledge.js +534 -400
- package/dist/cli/commands/knowledge.js.map +1 -1
- package/dist/cli/commands/passes-gate.d.ts +4 -1
- package/dist/cli/commands/passes-gate.d.ts.map +1 -1
- package/dist/cli/commands/passes-gate.js +11 -2
- package/dist/cli/commands/passes-gate.js.map +1 -1
- package/dist/cli/commands/performance.d.ts.map +1 -1
- package/dist/cli/commands/performance.js +19 -31
- package/dist/cli/commands/performance.js.map +1 -1
- package/dist/cli/commands/report.d.ts.map +1 -1
- package/dist/cli/commands/report.js +2 -1
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/review.d.ts.map +1 -1
- package/dist/cli/commands/review.js +13 -25
- package/dist/cli/commands/review.js.map +1 -1
- package/dist/cli/commands/scaffold-templates.d.ts +73 -0
- package/dist/cli/commands/scaffold-templates.d.ts.map +1 -0
- package/dist/cli/commands/scaffold-templates.js +424 -0
- package/dist/cli/commands/scaffold-templates.js.map +1 -0
- package/dist/cli/commands/scaffold.d.ts +105 -0
- package/dist/cli/commands/scaffold.d.ts.map +1 -0
- package/dist/cli/commands/scaffold.js +263 -0
- package/dist/cli/commands/scaffold.js.map +1 -0
- package/dist/cli/commands/security.d.ts.map +1 -1
- package/dist/cli/commands/security.js +22 -24
- package/dist/cli/commands/security.js.map +1 -1
- package/dist/cli/commands/spec-baseline-check.d.ts +43 -0
- package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
- package/dist/cli/commands/spec-baseline-check.js +109 -34
- package/dist/cli/commands/spec-baseline-check.js.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.d.ts +21 -2
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +112 -28
- package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +86 -27
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts +24 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js +33 -7
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +0 -16
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +2 -97
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/gate-command.d.ts +37 -0
- package/dist/cli/gate-command.d.ts.map +1 -0
- package/dist/cli/gate-command.js +64 -0
- package/dist/cli/gate-command.js.map +1 -0
- package/dist/completion-checkers/index.d.ts +1 -1
- package/dist/completion-checkers/index.d.ts.map +1 -1
- package/dist/completion-checkers/index.js +0 -15
- package/dist/completion-checkers/index.js.map +1 -1
- package/dist/context/knowledge-injector.d.ts +4 -2
- package/dist/context/knowledge-injector.d.ts.map +1 -1
- package/dist/context/knowledge-injector.js +13 -6
- package/dist/context/knowledge-injector.js.map +1 -1
- package/dist/core/constraints/agent-prompt-renderer.js +2 -2
- package/dist/core/constraints/agent-prompt-renderer.js.map +1 -1
- package/dist/core/constraints/capabilities-reconcile.d.ts +20 -0
- package/dist/core/constraints/capabilities-reconcile.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-reconcile.js +26 -4
- package/dist/core/constraints/capabilities-reconcile.js.map +1 -1
- package/dist/core/constraints/check-cache.d.ts +1 -1
- package/dist/core/constraints/check-cache.js +1 -1
- package/dist/core/constraints/checker.d.ts +8 -3
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +30 -19
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts +3 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +17 -24
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.d.ts +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.js +9 -6
- 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 +24 -30
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.js +10 -4
- package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +10 -6
- package/dist/core/constraints/checkers/types.d.ts.map +1 -1
- package/dist/core/constraints/checkers/types.js +7 -3
- package/dist/core/constraints/checkers/types.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts +11 -10
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +31 -27
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/context-reconcile.d.ts +75 -0
- package/dist/core/constraints/context-reconcile.d.ts.map +1 -0
- package/dist/core/constraints/context-reconcile.js +161 -0
- package/dist/core/constraints/context-reconcile.js.map +1 -0
- package/dist/core/constraints/doc-freshness/runner.d.ts +7 -0
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +8 -3
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/git-evidence.js +1 -1
- package/dist/core/constraints/git-evidence.js.map +1 -1
- package/dist/core/constraints/injection-drift.d.ts +7 -2
- package/dist/core/constraints/injection-drift.d.ts.map +1 -1
- package/dist/core/constraints/injection-drift.js +13 -7
- package/dist/core/constraints/injection-drift.js.map +1 -1
- package/dist/core/constraints/run-env.d.ts +92 -0
- package/dist/core/constraints/run-env.d.ts.map +1 -0
- package/dist/core/constraints/run-env.js +175 -0
- package/dist/core/constraints/run-env.js.map +1 -0
- package/dist/core/constraints/triggers.d.ts +22 -0
- package/dist/core/constraints/triggers.d.ts.map +1 -0
- package/dist/core/constraints/triggers.js +31 -0
- package/dist/core/constraints/triggers.js.map +1 -0
- package/dist/core/effective-constraints.d.ts +13 -4
- package/dist/core/effective-constraints.d.ts.map +1 -1
- package/dist/core/effective-constraints.js +16 -6
- package/dist/core/effective-constraints.js.map +1 -1
- package/dist/core/effective-set.d.ts +8 -15
- package/dist/core/effective-set.d.ts.map +1 -1
- package/dist/core/effective-set.js +7 -12
- package/dist/core/effective-set.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +39 -17
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +51 -122
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/validators/check-handlers/http.d.ts +2 -2
- package/dist/core/validators/check-handlers/http.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/http.js +12 -7
- package/dist/core/validators/check-handlers/http.js.map +1 -1
- package/dist/failure/classifier.d.ts +1 -1
- package/dist/failure/classifier.d.ts.map +1 -1
- package/dist/failure/classifier.js +8 -8
- package/dist/failure/classifier.js.map +1 -1
- package/dist/failure/index.d.ts +2 -1
- package/dist/failure/index.d.ts.map +1 -1
- package/dist/failure/index.js +9 -17
- package/dist/failure/index.js.map +1 -1
- package/dist/failure/recorder.d.ts +1 -1
- package/dist/failure/recorder.d.ts.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 +3 -2
- package/dist/gates/checker-gate.js.map +1 -1
- package/dist/gates/command.d.ts +10 -4
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +36 -62
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +0 -4
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/definitions.d.ts +2 -1
- package/dist/gates/definitions.d.ts.map +1 -1
- package/dist/gates/definitions.js +6 -5
- package/dist/gates/definitions.js.map +1 -1
- package/dist/gates/index.d.ts +0 -4
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js +1 -6
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +0 -4
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/runner.d.ts +1 -1
- package/dist/gates/runner.js +1 -1
- package/dist/gates/security.d.ts +1 -1
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +5 -6
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +14 -17
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/gates/types.js.map +1 -1
- package/dist/hooks/bootstrap.d.ts +6 -4
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +25 -13
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/hooks/config.d.ts +6 -2
- package/dist/hooks/config.d.ts.map +1 -1
- package/dist/hooks/config.js +5 -1
- package/dist/hooks/config.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +0 -15
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/pipeline.d.ts.map +1 -1
- package/dist/hooks/pipeline.js +2 -4
- package/dist/hooks/pipeline.js.map +1 -1
- package/dist/hooks/registry.d.ts +11 -8
- package/dist/hooks/registry.d.ts.map +1 -1
- package/dist/hooks/registry.js +22 -7
- package/dist/hooks/registry.js.map +1 -1
- package/dist/hooks/types.d.ts +23 -7
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit-scoring.d.ts +87 -0
- package/dist/knowledge/audit-scoring.d.ts.map +1 -0
- package/dist/knowledge/audit-scoring.js +470 -0
- package/dist/knowledge/audit-scoring.js.map +1 -0
- package/dist/knowledge/audit.d.ts +11 -59
- package/dist/knowledge/audit.d.ts.map +1 -1
- package/dist/knowledge/audit.js +47 -522
- package/dist/knowledge/audit.js.map +1 -1
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/import.js +2 -0
- package/dist/knowledge/import.js.map +1 -1
- package/dist/knowledge/index-generator.d.ts.map +1 -1
- package/dist/knowledge/index-generator.js +4 -5
- package/dist/knowledge/index-generator.js.map +1 -1
- package/dist/knowledge/index.d.ts +3 -2
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +3 -16
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/ingest.js +1 -1
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lifecycle.d.ts.map +1 -1
- package/dist/knowledge/lifecycle.js +4 -2
- package/dist/knowledge/lifecycle.js.map +1 -1
- package/dist/knowledge/migration.d.ts +3 -0
- package/dist/knowledge/migration.d.ts.map +1 -1
- package/dist/knowledge/migration.js +8 -2
- package/dist/knowledge/migration.js.map +1 -1
- package/dist/knowledge/query.d.ts +6 -0
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js +8 -2
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/reference-tracker.d.ts.map +1 -1
- package/dist/knowledge/reference-tracker.js +4 -6
- package/dist/knowledge/reference-tracker.js.map +1 -1
- package/dist/knowledge/store.d.ts +22 -16
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +53 -12
- package/dist/knowledge/store.js.map +1 -1
- package/dist/knowledge/tree-walker.d.ts +19 -0
- package/dist/knowledge/tree-walker.d.ts.map +1 -0
- package/dist/knowledge/tree-walker.js +30 -0
- package/dist/knowledge/tree-walker.js.map +1 -0
- package/dist/knowledge/types.d.ts +16 -0
- package/dist/knowledge/types.d.ts.map +1 -1
- package/dist/monitoring/traces.d.ts +5 -3
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +19 -5
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/test-setup/jsonl-fake-fs.d.ts +30 -0
- package/dist/test-setup/jsonl-fake-fs.d.ts.map +1 -0
- package/dist/test-setup/jsonl-fake-fs.js +49 -0
- package/dist/test-setup/jsonl-fake-fs.js.map +1 -0
- package/dist/tools/index.d.ts +4 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +7 -15
- package/dist/tools/index.js.map +1 -1
- package/dist/types/checkpoint.d.ts +5 -0
- package/dist/types/checkpoint.d.ts.map +1 -1
- package/dist/types/project-config.d.ts +18 -0
- package/dist/types/project-config.d.ts.map +1 -1
- package/dist/types/trace.d.ts +13 -4
- package/dist/types/trace.d.ts.map +1 -1
- package/dist/types/trace.js +4 -3
- package/dist/types/trace.js.map +1 -1
- package/dist/utils/exec.d.ts +4 -27
- package/dist/utils/exec.d.ts.map +1 -1
- package/dist/utils/exec.js +4 -94
- package/dist/utils/exec.js.map +1 -1
- package/dist/utils/jsonl.d.ts +17 -7
- package/dist/utils/jsonl.d.ts.map +1 -1
- package/dist/utils/jsonl.js +144 -17
- package/dist/utils/jsonl.js.map +1 -1
- package/dist/utils/numeric-flag.d.ts +44 -0
- package/dist/utils/numeric-flag.d.ts.map +1 -0
- package/dist/utils/numeric-flag.js +62 -0
- package/dist/utils/numeric-flag.js.map +1 -0
- package/package.json +1 -1
- package/src/CONTEXT.md +5 -2
- package/src/__tests__/acceptance-gate.test.ts +7 -4
- package/src/__tests__/checker-extra.test.ts +3 -2
- package/src/__tests__/checker.test.ts +4 -3
- package/src/__tests__/checkpoint.test.ts +26 -9
- package/src/__tests__/context-files-resolution.test.ts +29 -15
- package/src/__tests__/contract-gate.test.ts +19 -40
- package/src/__tests__/error-classifier.test.ts +1 -1
- package/src/__tests__/exec.test.ts +45 -107
- package/src/__tests__/failure-recorder.test.ts +7 -5
- package/src/__tests__/hooks-pipeline.test.ts +34 -47
- package/src/__tests__/layering.test.ts +217 -25
- package/src/__tests__/passes-gate.test.ts +9 -4
- package/src/__tests__/performance-gate.test.ts +3 -15
- package/src/__tests__/project-config-loader-extra.test.ts +31 -57
- package/src/__tests__/project-config-loader.test.ts +6 -3
- package/src/__tests__/public-exports.test.ts +0 -1
- package/src/__tests__/public-type-surface.test.ts +5 -4
- package/src/__tests__/public-value-surface.test.ts +182 -0
- package/src/__tests__/review-gate.test.ts +4 -6
- package/src/__tests__/security-gate.test.ts +5 -20
- package/src/__tests__/skip-semantics.test.ts +5 -3
- package/src/__tests__/spec-validator.test.ts +3 -2
- package/src/__tests__/sub-barrels-explicit.test.ts +87 -0
- package/src/__tests__/test-fixture-hygiene.test.ts +53 -0
- package/src/__tests__/trace-analyzer-extra.test.ts +5 -3
- package/src/__tests__/trace-analyzer.test.ts +5 -3
- package/src/__tests__/trace-collector.test.ts +5 -3
- package/src/agents/index.ts +13 -2
- package/src/cli/__tests__/gate-command.test.ts +162 -0
- package/src/cli/commands/CONTEXT.md +29 -5
- package/src/cli/commands/__tests__/acceptance.test.ts +24 -25
- package/src/cli/commands/__tests__/bin-exit-mapping.test.ts +15 -0
- package/src/cli/commands/__tests__/check-drift.test.ts +42 -1
- package/src/cli/commands/__tests__/check-read-count.test.ts +167 -0
- package/src/cli/commands/__tests__/check-skip-output.test.ts +4 -1
- package/src/cli/commands/__tests__/check.test.ts +43 -36
- package/src/cli/commands/__tests__/command-gate-dead-options.test.ts +60 -0
- package/src/cli/commands/__tests__/command.test.ts +33 -17
- package/src/cli/commands/__tests__/constraints-retire.test.ts +52 -0
- package/src/cli/commands/__tests__/context-syncer.test.ts +141 -0
- package/src/cli/commands/__tests__/contract.test.ts +20 -20
- package/src/cli/commands/__tests__/failure.test.ts +5 -4
- package/src/cli/commands/__tests__/gate-decision.ts +30 -0
- package/src/cli/commands/__tests__/init-dead-options.test.ts +50 -0
- package/src/cli/commands/__tests__/init-governance-io.test.ts +139 -0
- package/src/cli/commands/__tests__/init-injection.test.ts +3 -3
- package/src/cli/commands/__tests__/init-ondisk.test.ts +867 -0
- package/src/cli/commands/__tests__/init.test.ts +82 -6
- package/src/cli/commands/__tests__/knowledge-audit-threshold.test.ts +146 -0
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +1 -1
- package/src/cli/commands/__tests__/knowledge-tone-mapping.test.ts +244 -0
- package/src/cli/commands/__tests__/knowledge-view.test.ts +839 -0
- package/src/cli/commands/__tests__/knowledge.test.ts +33 -15
- package/src/cli/commands/__tests__/numeric-flag-assembly.test.ts +368 -0
- package/src/cli/commands/__tests__/performance.test.ts +19 -21
- package/src/cli/commands/__tests__/posteval-plan.test.ts +5 -3
- package/src/cli/commands/__tests__/pre-push-hook.test.ts +181 -0
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +95 -2
- package/src/cli/commands/__tests__/project-path-convention.test.ts +103 -25
- package/src/cli/commands/__tests__/registry.test.ts +2 -0
- package/src/cli/commands/__tests__/report.test.ts +23 -1
- package/src/cli/commands/__tests__/review.test.ts +10 -17
- package/src/cli/commands/__tests__/scaffold.test.ts +505 -0
- package/src/cli/commands/__tests__/security-default-scan.test.ts +75 -0
- package/src/cli/commands/__tests__/security.test.ts +21 -24
- package/src/cli/commands/__tests__/spec-baseline-check.test.ts +3 -2
- package/src/cli/commands/__tests__/spec-baseline-index-cap.test.ts +131 -0
- package/src/cli/commands/__tests__/spec-baseline-read-count.test.ts +325 -0
- package/src/cli/commands/__tests__/sync-docs-agents.test.ts +19 -4
- package/src/cli/commands/__tests__/sync-docs-context-drift.test.ts +232 -0
- package/src/cli/commands/__tests__/sync-docs-module-order.test.ts +111 -0
- package/src/cli/commands/__tests__/sync-docs-read-count.test.ts +192 -0
- package/src/cli/commands/__tests__/sync-docs.test.ts +3 -2
- package/src/cli/commands/__tests__/validate.test.ts +1 -48
- package/src/cli/commands/acceptance.ts +24 -29
- package/src/cli/commands/check.ts +40 -17
- package/src/cli/commands/command.ts +9 -8
- package/src/cli/commands/constraints-retire.ts +57 -70
- package/src/cli/commands/contract.ts +44 -47
- package/src/cli/commands/definitions.ts +12 -6
- package/src/cli/commands/failure.ts +16 -3
- package/src/cli/commands/init.ts +242 -389
- package/src/cli/commands/knowledge-view.ts +224 -0
- package/src/cli/commands/knowledge.ts +643 -448
- package/src/cli/commands/passes-gate.ts +12 -3
- package/src/cli/commands/performance.ts +31 -38
- package/src/cli/commands/report.ts +3 -2
- package/src/cli/commands/review.ts +22 -28
- package/src/cli/commands/scaffold-templates.ts +406 -0
- package/src/cli/commands/scaffold.ts +302 -0
- package/src/cli/commands/security.ts +27 -23
- package/src/cli/commands/spec-baseline-check.ts +158 -33
- package/src/cli/commands/sync-docs/__tests__/context-export-surface.test.ts +102 -0
- package/src/cli/commands/sync-docs/__tests__/module-descriptions.test.ts +196 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +137 -31
- package/src/cli/commands/sync-docs/index.ts +103 -28
- package/src/cli/commands/sync-docs/project-reader.ts +51 -7
- package/src/cli/commands/validate.ts +1 -104
- package/src/cli/gate-command.ts +87 -0
- package/src/completion-checkers/index.ts +10 -1
- package/src/context/CONTEXT.md +2 -1
- package/src/context/__tests__/knowledge-injector.test.ts +27 -0
- package/src/context/__tests__/session-manager.test.ts +19 -12
- package/src/context/knowledge-injector.ts +14 -7
- package/src/core/CONTEXT.md +10 -7
- package/src/core/__tests__/effective-set.test.ts +36 -60
- package/src/core/constraints/__tests__/context-reconcile.test.ts +246 -0
- package/src/core/constraints/__tests__/run-env.test.ts +377 -0
- package/src/core/constraints/__tests__/triggers.test.ts +70 -0
- package/src/core/constraints/agent-prompt-renderer.ts +1 -1
- package/src/core/constraints/capabilities-reconcile.ts +28 -4
- package/src/core/constraints/check-cache.ts +1 -1
- package/src/core/constraints/checker.ts +30 -14
- package/src/core/constraints/checkers/__tests__/context-doc-sync.test.ts +8 -3
- package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +16 -7
- package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +2 -1
- package/src/core/constraints/checkers/capability-sync.ts +27 -28
- package/src/core/constraints/checkers/context-doc-sync.ts +9 -7
- package/src/core/constraints/checkers/docs-freshness.ts +28 -33
- package/src/core/constraints/checkers/governance-presence.ts +10 -6
- package/src/core/constraints/checkers/types.ts +14 -8
- package/src/core/constraints/context-builder.ts +35 -26
- package/src/core/constraints/context-reconcile.ts +200 -0
- package/src/core/constraints/doc-freshness/__tests__/runner.test.ts +25 -0
- package/src/core/constraints/doc-freshness/runner.ts +18 -4
- package/src/core/constraints/git-evidence.ts +1 -1
- package/src/core/constraints/injection-drift.ts +19 -8
- package/src/core/constraints/run-env.ts +207 -0
- package/src/core/constraints/triggers.ts +33 -0
- package/src/core/effective-constraints.ts +17 -6
- package/src/core/effective-set.ts +8 -24
- package/src/core/index.ts +2 -0
- package/src/core/project-config-loader.ts +54 -102
- package/src/core/validators/__tests__/http-retry-sleep.test.ts +231 -0
- package/src/core/validators/check-handlers/http.ts +18 -7
- package/src/failure/CONTEXT.md +2 -1
- package/src/failure/classifier.ts +2 -2
- package/src/failure/index.ts +14 -2
- package/src/failure/recorder.ts +1 -1
- package/src/gates/CONTEXT.md +13 -7
- package/src/gates/__tests__/checker-gate.test.ts +1 -1
- package/src/gates/__tests__/command-single-predicate.test.ts +135 -0
- package/src/gates/__tests__/command.test.ts +8 -15
- package/src/gates/__tests__/contract.test.ts +5 -5
- package/src/gates/__tests__/gate-interface.test.ts +0 -17
- package/src/gates/__tests__/performance.test.ts +0 -13
- package/src/gates/__tests__/review.test.ts +0 -1
- package/src/gates/__tests__/runner.test.ts +1 -1
- package/src/gates/__tests__/security-default-scan.test.ts +97 -0
- package/src/gates/__tests__/security.test.ts +0 -13
- package/src/gates/checker-gate.ts +3 -2
- package/src/gates/command.ts +51 -74
- package/src/gates/contract.ts +0 -5
- package/src/gates/definitions.ts +6 -5
- package/src/gates/index.ts +0 -5
- package/src/gates/performance.ts +1 -6
- package/src/gates/runner.ts +1 -1
- package/src/gates/security.ts +9 -11
- package/src/gates/types.ts +20 -23
- package/src/hooks/CONTEXT.md +10 -9
- package/src/hooks/__tests__/bootstrap.test.ts +29 -6
- package/src/hooks/__tests__/pipeline.test.ts +28 -17
- package/src/hooks/__tests__/registry.test.ts +51 -3
- package/src/hooks/bootstrap.ts +35 -15
- package/src/hooks/config.ts +6 -2
- package/src/hooks/index.ts +10 -1
- package/src/hooks/pipeline.ts +4 -6
- package/src/hooks/registry.ts +31 -12
- package/src/hooks/types.ts +24 -7
- package/src/index.ts +1 -2
- package/src/knowledge/CONTEXT.md +14 -7
- package/src/knowledge/__tests__/audit-labels.test.ts +8 -5
- package/src/knowledge/__tests__/audit-scoring.test.ts +230 -0
- package/src/knowledge/__tests__/audit-write-count.test.ts +131 -0
- package/src/knowledge/__tests__/audit.test.ts +291 -208
- package/src/knowledge/__tests__/doctor.test.ts +3 -2
- package/src/knowledge/__tests__/ingest.test.ts +3 -2
- package/src/knowledge/__tests__/lifecycle.test.ts +57 -2
- package/src/knowledge/__tests__/migration.test.ts +35 -6
- package/src/knowledge/__tests__/query.test.ts +3 -2
- package/src/knowledge/__tests__/reference-tracker.test.ts +23 -2
- package/src/knowledge/__tests__/store.test.ts +149 -4
- package/src/knowledge/__tests__/tree-walker.test.ts +132 -0
- package/src/knowledge/audit-scoring.ts +589 -0
- package/src/knowledge/audit.ts +55 -599
- package/src/knowledge/import.ts +2 -0
- package/src/knowledge/index-generator.ts +4 -6
- package/src/knowledge/index.ts +27 -2
- package/src/knowledge/ingest.ts +1 -1
- package/src/knowledge/lifecycle.ts +5 -2
- package/src/knowledge/migration.ts +8 -2
- package/src/knowledge/query.ts +8 -1
- package/src/knowledge/reference-tracker.ts +5 -7
- package/src/knowledge/store.ts +75 -16
- package/src/knowledge/tree-walker.ts +29 -0
- package/src/knowledge/types.ts +19 -0
- package/src/monitoring/CONTEXT.md +5 -2
- package/src/monitoring/__tests__/context-tracker.test.ts +16 -8
- package/src/monitoring/__tests__/trace-file-anchoring.test.ts +80 -0
- package/src/monitoring/traces.ts +19 -5
- package/src/release/CONTEXT.md +1 -1
- package/src/release/__tests__/integrity.test.ts +21 -12
- package/src/test-setup/__tests__/jsonl-fake-fs.test.ts +98 -0
- package/src/test-setup/jsonl-fake-fs.ts +59 -0
- package/src/tools/index.ts +5 -1
- package/src/types/checkpoint.ts +6 -0
- package/src/types/project-config.ts +21 -0
- package/src/types/trace.ts +14 -4
- package/src/utils/__tests__/file-walk.test.ts +3 -2
- package/src/utils/__tests__/jsonl-bounded-read.test.ts +106 -0
- package/src/utils/__tests__/jsonl-skip-disposition.test.ts +10 -6
- package/src/utils/__tests__/jsonl.test.ts +61 -14
- package/src/utils/__tests__/numeric-flag.test.ts +80 -0
- package/src/utils/__tests__/package-version.test.ts +2 -2
- package/src/utils/exec.ts +4 -64
- package/src/utils/jsonl.ts +159 -20
- package/src/utils/numeric-flag.ts +64 -0
- package/dist/failure/types.d.ts +0 -9
- package/dist/failure/types.d.ts.map +0 -1
- package/dist/failure/types.js +0 -25
- package/dist/failure/types.js.map +0 -1
- package/dist/gates/effective-gates.d.ts +0 -30
- package/dist/gates/effective-gates.d.ts.map +0 -1
- package/dist/gates/effective-gates.js +0 -81
- package/dist/gates/effective-gates.js.map +0 -1
- package/src/failure/types.ts +0 -9
- package/src/gates/__tests__/effective-gates.test.ts +0 -77
- package/src/gates/effective-gates.ts +0 -99
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 已发布子路径值面全量冻结闸(ADR-0022 追记第 5 条收口)
|
|
3
|
+
*
|
|
4
|
+
* 补齐 `public-type-surface.test.ts` 的另一半:那道闸按 `package.json` 的 `exports` 逐入口冻
|
|
5
|
+
* 结了**类型面**,但值面(运行时导出)只有包根一处被 `public-exports.test.ts` 钉住——
|
|
6
|
+
* `Object.keys(await import('../index'))` 只看得到 `.` 一个入口。于是「这个函数不在公开面上、
|
|
7
|
+
* 删它非 breaking」这类定级断言在子路径入口仍无闸可跑,只能靠人工逐条附「各入口源文件 +
|
|
8
|
+
* 已发布产物 `.d.ts`」双证据(能防这一次,防不了下一次)。
|
|
9
|
+
*
|
|
10
|
+
* 落闸前实测的洞(五个入口的运行时键集合 106/29/4/4/24):`./core` 有 7 个值导出、
|
|
11
|
+
* `./presets` 有 4 个(即该入口全部)不在包根清单里——删掉它们当前**零测试变红**。
|
|
12
|
+
* `./gates` 与 `./context` 的值导出恰好是包根的子集,删除会经 `src/index.ts` 的 barrel 链
|
|
13
|
+
* 撞上包根那条闸,但红名报的是 `.`、不是真正被删的那个入口——定级时照样得再人肉查一遍。
|
|
14
|
+
*
|
|
15
|
+
* 口径与类型面闸一致:**公开面 = `exports` 映射,不是只有包根**,入口清单从 `exports` 派生
|
|
16
|
+
* 而非硬编码,新增子路径未登记冻结清单即红。分工:
|
|
17
|
+
* - `.` 的值面仍由 `public-exports.test.ts` 冻结(本闸刻意不重复钉——同一个入口两份清单
|
|
18
|
+
* 必然漂移,且那条判定要逐字保留),本闸只管四个子路径;「两边都不漏」由登记闸与委派闸各钉一条。
|
|
19
|
+
* - 类型面归 `public-type-surface.test.ts`,含导出写法白名单(堵 `export *` 与入口内联类型
|
|
20
|
+
* 声明)。值面按运行时事实枚举,无按名字扫描漏算之虞,故本闸不重复那道写法检查。
|
|
21
|
+
*
|
|
22
|
+
* 本闸走运行时 `import`:值面的事实只有模块加载后才是真的(`Object.keys` 读到的正是 tsc
|
|
23
|
+
* 产物出厂的那批键)。它与类型面改动互不影响——`public-exports.test.ts` 的编译期钉在类型面
|
|
24
|
+
* 被改时会让那个套件「failed to run」(实测向 `src/index.ts` 注一条 `export type { DynamicTask }`
|
|
25
|
+
* 得 TS2578),本闸在同一注入下 7 项照跑且全绿,值面的清单 diff 不会被类型面的编译期钉连带抹掉。
|
|
26
|
+
*
|
|
27
|
+
* 冻结清单不手抄:四子路径 + 包根的 `src` 侧 ts-jest 运行时键与各自 tsc 产物
|
|
28
|
+
* (`dist/**\/index.js`)逐入口 `Object.keys` 对撞,106/29/4/4/24 全部逐字一致。改动入口清单
|
|
29
|
+
* 文件时同步改本文件对应条目,diff 即 PR 评审材料;增删符号属公共面 breaking,须按
|
|
30
|
+
* ADR-0003/0022 走发布级别裁决。
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import * as fs from 'fs';
|
|
34
|
+
import * as path from 'path';
|
|
35
|
+
|
|
36
|
+
const REPO_ROOT = path.join(__dirname, '../..');
|
|
37
|
+
|
|
38
|
+
/** 包根值面的既有归属,见文件头分工。 */
|
|
39
|
+
const PACKAGE_ROOT_SUBPATH = '.';
|
|
40
|
+
|
|
41
|
+
const EXPORTS_MAP = JSON.parse(
|
|
42
|
+
fs.readFileSync(path.join(REPO_ROOT, 'package.json'), 'utf-8'),
|
|
43
|
+
).exports as Record<string, unknown>;
|
|
44
|
+
|
|
45
|
+
const ENTRY_SUBPATHS: string[] = Object.keys(EXPORTS_MAP);
|
|
46
|
+
|
|
47
|
+
/** 每个已发布子路径入口的值面全量清单。增删任一项即公共面 breaking,见文件头。 */
|
|
48
|
+
const PUBLISHED_ENTRY_VALUES: Record<string, string[]> = {
|
|
49
|
+
'./core': [
|
|
50
|
+
'CONSTRAINTS_END_MARKER',
|
|
51
|
+
'CONSTRAINTS_START_MARKER',
|
|
52
|
+
'CSOValidator',
|
|
53
|
+
'CheckCache',
|
|
54
|
+
'CheckpointValidator',
|
|
55
|
+
'ConstraintChecker',
|
|
56
|
+
'ConstraintViolationError',
|
|
57
|
+
'GUIDELINES',
|
|
58
|
+
'IRON_LAWS',
|
|
59
|
+
'PROMPTS',
|
|
60
|
+
'PassesGate',
|
|
61
|
+
'ProjectConfigLoader',
|
|
62
|
+
'SpecValidator',
|
|
63
|
+
'checkBeforeExecution',
|
|
64
|
+
'checkConstraint',
|
|
65
|
+
'checkConstraints',
|
|
66
|
+
'constraintChecker',
|
|
67
|
+
'createPassesGate',
|
|
68
|
+
'findConstraintsByTrigger',
|
|
69
|
+
'getAllConstraints',
|
|
70
|
+
'getCapabilitiesMode',
|
|
71
|
+
'getConstraint',
|
|
72
|
+
'getEffectiveConstraints',
|
|
73
|
+
'getGovernanceConfig',
|
|
74
|
+
'lintEffectiveConfig',
|
|
75
|
+
'loadRawProjectConfig',
|
|
76
|
+
'renderConstraintsByTrigger',
|
|
77
|
+
'renderConstraintsSection',
|
|
78
|
+
'resolveContextFiles',
|
|
79
|
+
],
|
|
80
|
+
'./presets': [
|
|
81
|
+
'PRESETS_BY_NAME',
|
|
82
|
+
'RELAXED_PRESET',
|
|
83
|
+
'STANDARD_PRESET',
|
|
84
|
+
'STRICT_PRESET',
|
|
85
|
+
],
|
|
86
|
+
'./context': [
|
|
87
|
+
'KnowledgeInjector',
|
|
88
|
+
'SessionManager',
|
|
89
|
+
'TokenBudget',
|
|
90
|
+
'TokenEstimator',
|
|
91
|
+
],
|
|
92
|
+
'./gates': [
|
|
93
|
+
'CommandGate',
|
|
94
|
+
'ContractGate',
|
|
95
|
+
'DEFAULT_COMMAND_BLACKLIST',
|
|
96
|
+
'GATE_DEFINITIONS',
|
|
97
|
+
'PerformanceGate',
|
|
98
|
+
'ReviewGate',
|
|
99
|
+
'SecurityGate',
|
|
100
|
+
'SpecAcceptanceGate',
|
|
101
|
+
'assertGateRegistryClosed',
|
|
102
|
+
'createCheckerGate',
|
|
103
|
+
'createCommandGate',
|
|
104
|
+
'createContractGate',
|
|
105
|
+
'createPerformanceGate',
|
|
106
|
+
'createReviewGate',
|
|
107
|
+
'createSecurityGate',
|
|
108
|
+
'createSpecAcceptanceGate',
|
|
109
|
+
'decisionFromResult',
|
|
110
|
+
'getCommandGate',
|
|
111
|
+
'getCommandRiskLevel',
|
|
112
|
+
'getGate',
|
|
113
|
+
'isCommandAllowed',
|
|
114
|
+
'listRegisteredGates',
|
|
115
|
+
'registeredGateCount',
|
|
116
|
+
'runGates',
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** exports 子路径 → 承载它的显式清单源文件。形态对不上返回 null,由映射闸 fail-loud。 */
|
|
121
|
+
function sourceFileForSubpath(subpath: string): string | null {
|
|
122
|
+
if (subpath === PACKAGE_ROOT_SUBPATH) return 'src/index.ts';
|
|
123
|
+
const rest = subpath.replace(/^\.\//, '');
|
|
124
|
+
return /^[a-z][a-z0-9-]*$/.test(rest) ? `src/${rest}/index.ts` : null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** 同上,但产 ts-jest 可解析的相对说明符(本包未自引用发布名,只能按源码路径 import)。 */
|
|
128
|
+
function moduleSpecifierForSubpath(subpath: string): string | null {
|
|
129
|
+
const rel = sourceFileForSubpath(subpath);
|
|
130
|
+
if (rel === null) return null;
|
|
131
|
+
return `../${rel.replace(/^src\//, '').replace(/\.ts$/, '')}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function runtimeKeysOf(subpath: string): Promise<string[]> {
|
|
135
|
+
const specifier = moduleSpecifierForSubpath(subpath);
|
|
136
|
+
expect(specifier).not.toBeNull();
|
|
137
|
+
const mod: Record<string, unknown> = await import(specifier as string);
|
|
138
|
+
return Object.keys(mod).sort();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
describe('已发布子路径值面全量冻结(ADR-0022 追记 5)', () => {
|
|
142
|
+
it('exports 的每个子路径都映射到存在的显式清单源文件(新增子路径不得绕过本闸)', () => {
|
|
143
|
+
const unmapped = ENTRY_SUBPATHS.filter((sub) => {
|
|
144
|
+
const rel = sourceFileForSubpath(sub);
|
|
145
|
+
return rel === null || !fs.existsSync(path.join(REPO_ROOT, rel));
|
|
146
|
+
});
|
|
147
|
+
expect(unmapped).toEqual([]);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('冻结清单覆盖除包根外的全部已发布子路径(新增入口须先登记清单)', () => {
|
|
151
|
+
expect(Object.keys(PUBLISHED_ENTRY_VALUES).sort()).toEqual(
|
|
152
|
+
ENTRY_SUBPATHS.filter((sub) => sub !== PACKAGE_ROOT_SUBPATH).sort(),
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('包根值面确有既有归属(本闸委派 `.`,两边都不钉即公共面失控)', () => {
|
|
157
|
+
const sibling = fs.readFileSync(path.join(__dirname, 'public-exports.test.ts'), 'utf-8');
|
|
158
|
+
expect(sibling).toContain('Object.keys(mod)');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
for (const sub of ENTRY_SUBPATHS) {
|
|
162
|
+
if (sub === PACKAGE_ROOT_SUBPATH) continue; // 委派给 public-exports.test.ts,见文件头
|
|
163
|
+
if (moduleSpecifierForSubpath(sub) === null) continue; // 映射闸已负责红,此处不重复报
|
|
164
|
+
const frozen = PUBLISHED_ENTRY_VALUES[sub];
|
|
165
|
+
if (frozen === undefined) continue; // 未登记入口由登记闸负责红,此处不重复报
|
|
166
|
+
|
|
167
|
+
describe(`入口点 ${sub}`, () => {
|
|
168
|
+
it('运行时导出键集合与冻结清单逐字一致(增删即 breaking,需发布级别裁决)', async () => {
|
|
169
|
+
const actual = await runtimeKeysOf(sub);
|
|
170
|
+
// 解析塌掉不得退化成空集合假绿;冻结清单自身不得有重复项(重复 + 缺失会互相抵掉 diff)
|
|
171
|
+
expect(actual.length).toBeGreaterThan(0);
|
|
172
|
+
expect(new Set(frozen).size).toBe(frozen.length);
|
|
173
|
+
expect({
|
|
174
|
+
entry: sub,
|
|
175
|
+
missing: frozen.filter((key) => !actual.includes(key)),
|
|
176
|
+
extra: actual.filter((key) => !frozen.includes(key)),
|
|
177
|
+
}).toEqual({ entry: sub, missing: [], extra: [] });
|
|
178
|
+
expect(actual.length).toBe(frozen.length);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
});
|
|
@@ -4,16 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
|
|
6
6
|
import { ReviewGate } from '../gates/review';
|
|
7
|
-
import {
|
|
7
|
+
import { rmSync, writeFileSync, mkdtempSync } from 'fs';
|
|
8
8
|
import { join } from 'path';
|
|
9
|
+
import { tmpdir } from 'os';
|
|
9
10
|
import { execSync } from 'child_process';
|
|
10
11
|
|
|
11
12
|
describe('ReviewGate', () => {
|
|
12
|
-
|
|
13
|
+
let tempDir: string;
|
|
13
14
|
let gate: ReviewGate;
|
|
14
15
|
|
|
15
16
|
beforeAll(() => {
|
|
16
|
-
|
|
17
|
+
tempDir = mkdtempSync(join(tmpdir(), 'temp-test-review-gate-'));
|
|
17
18
|
gate = new ReviewGate({ minReviewers: 1, requireApproval: true });
|
|
18
19
|
|
|
19
20
|
// 初始化 git
|
|
@@ -40,7 +41,6 @@ describe('ReviewGate', () => {
|
|
|
40
41
|
describe('check', () => {
|
|
41
42
|
it('本地模式应该返回警告', async () => {
|
|
42
43
|
const result = await gate.check({
|
|
43
|
-
projectId: 'test-project',
|
|
44
44
|
projectPath: tempDir,
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -53,7 +53,6 @@ describe('ReviewGate', () => {
|
|
|
53
53
|
const relaxedGate = new ReviewGate({ requireApproval: false });
|
|
54
54
|
|
|
55
55
|
const result = await relaxedGate.check({
|
|
56
|
-
projectId: 'test-project',
|
|
57
56
|
projectPath: tempDir,
|
|
58
57
|
});
|
|
59
58
|
|
|
@@ -82,7 +81,6 @@ describe('ReviewGate', () => {
|
|
|
82
81
|
describe('checkLocalGit', () => {
|
|
83
82
|
it('应该检查 git 状态', async () => {
|
|
84
83
|
const result = await gate.check({
|
|
85
|
-
projectId: 'test-project',
|
|
86
84
|
projectPath: tempDir,
|
|
87
85
|
});
|
|
88
86
|
|
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
|
|
6
6
|
import { SecurityGate } from '../gates/security';
|
|
7
|
-
import {
|
|
7
|
+
import { rmSync, writeFileSync, mkdtempSync } from 'fs';
|
|
8
8
|
import { join } from 'path';
|
|
9
|
+
import { tmpdir } from 'os';
|
|
9
10
|
|
|
10
11
|
describe('SecurityGate', () => {
|
|
11
|
-
|
|
12
|
+
let tempDir: string;
|
|
12
13
|
let gate: SecurityGate;
|
|
13
14
|
|
|
14
15
|
beforeAll(() => {
|
|
15
|
-
|
|
16
|
+
tempDir = mkdtempSync(join(tmpdir(), 'temp-test-security-gate-'));
|
|
16
17
|
|
|
17
18
|
// 创建 package.json(无漏洞)
|
|
18
19
|
writeFileSync(join(tempDir, 'package.json'), JSON.stringify({
|
|
@@ -20,7 +21,7 @@ describe('SecurityGate', () => {
|
|
|
20
21
|
dependencies: {},
|
|
21
22
|
}));
|
|
22
23
|
|
|
23
|
-
gate = new SecurityGate({
|
|
24
|
+
gate = new SecurityGate({ severityThreshold: 'high' });
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
afterAll(() => {
|
|
@@ -32,22 +33,9 @@ describe('SecurityGate', () => {
|
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
describe('scan', () => {
|
|
35
|
-
it('禁用时应该返回通过', async () => {
|
|
36
|
-
const disabledGate = new SecurityGate({ enabled: false });
|
|
37
|
-
|
|
38
|
-
const result = await disabledGate.scan({
|
|
39
|
-
projectId: 'test-project',
|
|
40
|
-
projectPath: tempDir,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
expect(result.passed).toBe(true);
|
|
44
|
-
expect(result.message).toContain('安全门禁已禁用');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
36
|
// 跳过:依赖真实 npm audit 结果,需要 mock 重构
|
|
48
37
|
it.skip('应该运行 npm audit', async () => {
|
|
49
38
|
const result = await gate.scan({
|
|
50
|
-
projectId: 'test-project',
|
|
51
39
|
projectPath: tempDir,
|
|
52
40
|
});
|
|
53
41
|
|
|
@@ -57,7 +45,6 @@ describe('SecurityGate', () => {
|
|
|
57
45
|
|
|
58
46
|
it.skip('应该返回漏洞分析', async () => {
|
|
59
47
|
const result = await gate.scan({
|
|
60
|
-
projectId: 'test-project',
|
|
61
48
|
projectPath: tempDir,
|
|
62
49
|
});
|
|
63
50
|
|
|
@@ -70,7 +57,6 @@ describe('SecurityGate', () => {
|
|
|
70
57
|
describe('severityThreshold', () => {
|
|
71
58
|
it.skip('high 阈值应该检查 critical + high', async () => {
|
|
72
59
|
const result = await gate.scan({
|
|
73
|
-
projectId: 'test-project',
|
|
74
60
|
projectPath: tempDir,
|
|
75
61
|
});
|
|
76
62
|
|
|
@@ -89,7 +75,6 @@ describe('SecurityGate', () => {
|
|
|
89
75
|
describe('analyzeResult', () => {
|
|
90
76
|
it.skip('应该解析 npm audit JSON 或返回 passed', async () => {
|
|
91
77
|
const result = await gate.scan({
|
|
92
|
-
projectId: 'test-project',
|
|
93
78
|
projectPath: tempDir,
|
|
94
79
|
});
|
|
95
80
|
|
|
@@ -18,6 +18,7 @@ import type { Constraint, ConstraintContext } from '../types/constraint';
|
|
|
18
18
|
import type { ExecutionTrace } from '../types/trace';
|
|
19
19
|
import * as fs from 'fs';
|
|
20
20
|
import * as path from 'path';
|
|
21
|
+
import * as os from 'os';
|
|
21
22
|
import { execSync } from 'child_process';
|
|
22
23
|
|
|
23
24
|
/** 套件共用 checker:显式 no-op 记录器(trace 断言的用例自带记录器实例) */
|
|
@@ -32,10 +33,10 @@ function makeConstraint(
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
describe('skip 三态语义(ADR-0001)', () => {
|
|
35
|
-
|
|
36
|
+
let tempDir: string;
|
|
36
37
|
|
|
37
38
|
beforeAll(() => {
|
|
38
|
-
fs.
|
|
39
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'temp-test-skip-semantics-'));
|
|
39
40
|
execSync('git init', { cwd: tempDir });
|
|
40
41
|
execSync('git config user.email "test@test.com"', { cwd: tempDir });
|
|
41
42
|
execSync('git config user.name "Test"', { cwd: tempDir });
|
|
@@ -227,9 +228,10 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
227
228
|
});
|
|
228
229
|
|
|
229
230
|
describe('detectTrigger 补 code_implementation 推断', () => {
|
|
230
|
-
|
|
231
|
+
let triggerDir: string;
|
|
231
232
|
|
|
232
233
|
beforeAll(() => {
|
|
234
|
+
triggerDir = path.join(tempDir, 'trigger-probe');
|
|
233
235
|
// src/ 下有已提交 .ts 文件 → detectSourceRoots 命中 'src'
|
|
234
236
|
fs.mkdirSync(path.join(triggerDir, 'src'), { recursive: true });
|
|
235
237
|
fs.writeFileSync(path.join(triggerDir, 'src', 'existing.ts'), 'export const x = 1;');
|
|
@@ -6,13 +6,14 @@ import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
|
|
|
6
6
|
import { SpecValidator } from '../core/spec/validator';
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import * as path from 'path';
|
|
9
|
+
import * as os from 'os';
|
|
9
10
|
|
|
10
11
|
describe('SpecValidator', () => {
|
|
11
|
-
|
|
12
|
+
let tempDir: string;
|
|
12
13
|
let validator: SpecValidator;
|
|
13
14
|
|
|
14
15
|
beforeAll(() => {
|
|
15
|
-
fs.
|
|
16
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'temp-test-spec-'));
|
|
16
17
|
validator = SpecValidator.getInstance();
|
|
17
18
|
});
|
|
18
19
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 子 barrel 显式清单闸(harness#137,判据同 ADR-0003 / ADR-0022)
|
|
3
|
+
*
|
|
4
|
+
* ADR-0003 的「禁 export *」此前只钉到五个 `exports` 入口(`public-type-surface.test.ts`
|
|
5
|
+
* 的写法白名单闸),子目录 `index.ts` 的星号再导出不受管——星号让「这个 barrel 到底
|
|
6
|
+
* 对外给了什么」无法按名字回答,同名遮蔽(两个 `types.ts` 撞名)也在此处静默发生。
|
|
7
|
+
* 本闸把它扩到 src 下全部 barrel:**逐文件、逐条**登记豁免,未登记的 `export *` 即红。
|
|
8
|
+
*
|
|
9
|
+
* 与两道公共面闸的分工:入口清单(`src/index.ts` 等五个)由 `public-type-surface.test.ts`
|
|
10
|
+
* 与 `public-value-surface.test.ts` 逐字冻结,本闸不重复钉入口,只管**入口之外**的目录级
|
|
11
|
+
* barrel;新增子 barrel 星号由本闸管住。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import * as fs from 'fs';
|
|
15
|
+
import * as path from 'path';
|
|
16
|
+
|
|
17
|
+
const SRC_DIR = path.join(__dirname, '..');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 已核无星号的 barrel 若日后引入 `export *`,需要在这里登记理由。
|
|
21
|
+
* 当前为空:harness#137 已把 8 处目录级星号全部改成显式清单(`failure/types.ts` 那处
|
|
22
|
+
* 是兼容再导出 shim,随票删除而非改写清单)。
|
|
23
|
+
*/
|
|
24
|
+
const STAR_EXEMPTIONS: Record<string, string> = {};
|
|
25
|
+
|
|
26
|
+
/** 收集 src 下所有目录级 barrel(`<dir>/index.ts`),不含 `__tests__` 内的测试辅助文件 */
|
|
27
|
+
function listBarrels(dir: string, out: string[] = []): string[] {
|
|
28
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
29
|
+
const full = path.join(dir, entry.name);
|
|
30
|
+
if (!entry.isDirectory() || entry.name === '__tests__') continue;
|
|
31
|
+
const indexTs = path.join(full, 'index.ts');
|
|
32
|
+
if (fs.existsSync(indexTs)) out.push(indexTs);
|
|
33
|
+
listBarrels(full, out);
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 行首 `export *` / `export type *` / `export * as ns`(去注释后判定) */
|
|
39
|
+
const STAR_EXPORT_RE = /^export\s+(?:type\s+\*)\s*|^export\s+\*/;
|
|
40
|
+
|
|
41
|
+
function stripComments(code: string): string {
|
|
42
|
+
return code.replace(/\/\*[\s\S]*?\*\//g, '').replace(/^\s*\/\/.*$/gm, '');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function starExports(barrel: string): string[] {
|
|
46
|
+
const text = stripComments(fs.readFileSync(barrel, 'utf-8'));
|
|
47
|
+
return text
|
|
48
|
+
.split('\n')
|
|
49
|
+
.map(line => line.trim())
|
|
50
|
+
.filter(line => STAR_EXPORT_RE.test(line));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
describe('子 barrel 显式清单(harness#137)', () => {
|
|
54
|
+
const barrels = [path.join(SRC_DIR, 'index.ts'), ...listBarrels(SRC_DIR)];
|
|
55
|
+
|
|
56
|
+
it('扫到了 barrel(扫空即说明遍历失效,不得假绿)', () => {
|
|
57
|
+
expect(barrels.length).toBeGreaterThan(5);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('src 下每个目录 barrel 都不含 `export *`(豁免须逐条登记理由)', () => {
|
|
61
|
+
const offenders = barrels
|
|
62
|
+
.map(barrel => ({
|
|
63
|
+
barrel: path.relative(SRC_DIR, barrel),
|
|
64
|
+
stars: starExports(barrel),
|
|
65
|
+
}))
|
|
66
|
+
.filter(entry => entry.stars.length > 0 && !STAR_EXEMPTIONS[entry.barrel]);
|
|
67
|
+
expect(offenders).toEqual([]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('豁免登记是死账:登记过却已无星号的条目须撤销(防豁免面只增不减)', () => {
|
|
71
|
+
const stale = Object.keys(STAR_EXEMPTIONS).filter(
|
|
72
|
+
rel => !starExports(path.join(SRC_DIR, rel)).length
|
|
73
|
+
);
|
|
74
|
+
expect(stale).toEqual([]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('failure/types.ts 兼容再导出 shim 已删除(转发链第三跳收口)', () => {
|
|
78
|
+
// 正本在 src/types/failure.ts(工单 14 归位),原模块路径经双仓核实无引用方
|
|
79
|
+
expect(fs.existsSync(path.join(SRC_DIR, 'failure', 'types.ts'))).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('failure barrel 直连类型正本,不再经 shim 中转', () => {
|
|
83
|
+
const text = stripComments(fs.readFileSync(path.join(SRC_DIR, 'failure', 'index.ts'), 'utf-8'));
|
|
84
|
+
expect(text).toContain("from '../types/failure'");
|
|
85
|
+
expect(text).not.toMatch(/from '\.\/types'/);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 测试夹具卫生闸(harness#145)
|
|
3
|
+
*
|
|
4
|
+
* 钉住一件事:`__tests__` 里的文件系统夹具根一律经 `fs.mkdtempSync` 取每轮唯一目录,
|
|
5
|
+
* 不得再出现「cwd 下固定名 temp-test 目录」这种夹具形状。
|
|
6
|
+
*
|
|
7
|
+
* 固定名的危害:同一 checkout 的两个并发 jest 进程共享该路径,一方的 afterAll rmSync
|
|
8
|
+
* 会删掉另一方在用的夹具(表现为像产品 bug 的 flaky);被 kill 的运行还会留下目录,
|
|
9
|
+
* 下一轮从脏夹具起步。唯一后缀(mkdtemp 前缀以 `-` 结尾)从根上消掉这两条。
|
|
10
|
+
*
|
|
11
|
+
* 只判「名字是否唯一」,不判「落在哪个父目录」:cwd 锚定行为本身是被测语义的套件
|
|
12
|
+
* (injection-writer / init-injection / parentDir opt-out)留在 cwd 是有意为之。
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, it, expect } from '@jest/globals';
|
|
16
|
+
import * as fs from 'fs';
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
|
|
19
|
+
/** 固定名夹具形状:cwd 拼一个字面量 temp-test 目录名,且该名字不以 `-` 结尾(非 mkdtemp 前缀) */
|
|
20
|
+
const FIXED_FIXTURE_RE = /(?:path\.)?join\(\s*process\.cwd\(\)\s*,\s*(['"])temp-test-([^'"]*)\1\s*\)/g;
|
|
21
|
+
|
|
22
|
+
function collectTestFiles(dir: string, out: string[] = []): string[] {
|
|
23
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
24
|
+
if (entry.name === 'node_modules' || entry.name === 'dist' || entry.name === 'coverage') continue;
|
|
25
|
+
const full = path.join(dir, entry.name);
|
|
26
|
+
if (entry.isDirectory()) collectTestFiles(full, out);
|
|
27
|
+
else if (entry.name.endsWith('.test.ts')) out.push(full);
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('测试夹具卫生(#145)', () => {
|
|
33
|
+
const repoRoot = path.join(__dirname, '..', '..');
|
|
34
|
+
const files = collectTestFiles(repoRoot);
|
|
35
|
+
|
|
36
|
+
it('扫描面非空(防止 glob 失效把闸扫成空集)', () => {
|
|
37
|
+
expect(files.length).toBeGreaterThan(100);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('__tests__ 内不存在固定名 temp-test-* 夹具目录', () => {
|
|
41
|
+
const offenders: string[] = [];
|
|
42
|
+
for (const file of files) {
|
|
43
|
+
fs.readFileSync(file, 'utf-8').split('\n').forEach((line, idx) => {
|
|
44
|
+
FIXED_FIXTURE_RE.lastIndex = 0;
|
|
45
|
+
let m: RegExpExecArray | null;
|
|
46
|
+
while ((m = FIXED_FIXTURE_RE.exec(line)) !== null) {
|
|
47
|
+
if (!m[2].endsWith('-')) offenders.push(`${path.relative(repoRoot, file)}:${idx + 1}: ${line.trim()}`);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
expect(offenders).toEqual([]);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -7,16 +7,18 @@ import { TraceAnalyzer, createAnalyzer } from '../monitoring/trace-analyzer';
|
|
|
7
7
|
import { TraceCollector } from '../monitoring/traces';
|
|
8
8
|
import * as fs from 'fs';
|
|
9
9
|
import * as path from 'path';
|
|
10
|
+
import * as os from 'os';
|
|
10
11
|
import type { ExecutionTrace } from '../types/trace';
|
|
11
12
|
|
|
12
13
|
describe('TraceAnalyzer - 补充覆盖', () => {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
let tempDir: string;
|
|
15
|
+
let logFile: string;
|
|
15
16
|
let collector: TraceCollector;
|
|
16
17
|
let analyzer: TraceAnalyzer;
|
|
17
18
|
|
|
18
19
|
beforeAll(() => {
|
|
19
|
-
fs.
|
|
20
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'temp-test-analyzer-extra-'));
|
|
21
|
+
logFile = path.join(tempDir, 'traces.log');
|
|
20
22
|
fs.writeFileSync(logFile, '');
|
|
21
23
|
});
|
|
22
24
|
|
|
@@ -11,16 +11,18 @@ import {
|
|
|
11
11
|
import { TraceCollector } from '../monitoring/traces';
|
|
12
12
|
import * as fs from 'fs';
|
|
13
13
|
import * as path from 'path';
|
|
14
|
+
import * as os from 'os';
|
|
14
15
|
import type { ExecutionTrace, TraceSummary } from '../types/trace';
|
|
15
16
|
|
|
16
17
|
describe('TraceAnalyzer', () => {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
let tempDir: string;
|
|
19
|
+
let logFile: string;
|
|
19
20
|
let collector: TraceCollector;
|
|
20
21
|
let analyzer: TraceAnalyzer;
|
|
21
22
|
|
|
22
23
|
beforeAll(() => {
|
|
23
|
-
fs.
|
|
24
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'temp-test-analyzer-'));
|
|
25
|
+
logFile = path.join(tempDir, 'traces.log');
|
|
24
26
|
fs.writeFileSync(logFile, '');
|
|
25
27
|
collector = new TraceCollector({ traceFile: logFile, enabled: true });
|
|
26
28
|
analyzer = new TraceAnalyzer(collector);
|
|
@@ -6,15 +6,17 @@ import { describe, it, expect, beforeAll, afterAll, beforeEach } from '@jest/glo
|
|
|
6
6
|
import { TraceCollector } from '../monitoring/traces';
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import * as path from 'path';
|
|
9
|
+
import * as os from 'os';
|
|
9
10
|
import type { ExecutionTrace } from '../types/trace';
|
|
10
11
|
|
|
11
12
|
describe('TraceCollector', () => {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
let tempDir: string;
|
|
14
|
+
let traceFile: string;
|
|
14
15
|
let collector: TraceCollector;
|
|
15
16
|
|
|
16
17
|
beforeAll(() => {
|
|
17
|
-
fs.
|
|
18
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'temp-test-traces-'));
|
|
19
|
+
traceFile = path.join(tempDir, 'traces.log');
|
|
18
20
|
});
|
|
19
21
|
|
|
20
22
|
afterAll(() => {
|
package/src/agents/index.ts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Agents 模块导出(ADR-0003:显式清单,禁 export *,harness#137)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type {
|
|
6
|
+
AgentStatus,
|
|
7
|
+
AgentConfig,
|
|
8
|
+
AgentState,
|
|
9
|
+
AgentEvent,
|
|
10
|
+
FallbackStrategy,
|
|
11
|
+
} from './types';
|
|
12
|
+
export { AgentLifecycle } from './lifecycle';
|
|
13
|
+
export type { EventHandler } from './lifecycle';
|