@dommaker/harness 1.13.0 → 1.15.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 +18 -0
- package/README.md +4 -2
- package/dist/cli/commands/check.js +3 -3
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/constraints-disable.d.ts +48 -0
- package/dist/cli/commands/constraints-disable.d.ts.map +1 -0
- package/dist/cli/commands/constraints-disable.js +156 -0
- package/dist/cli/commands/constraints-disable.js.map +1 -0
- package/dist/cli/commands/constraints-pack-proposal.d.ts +1 -1
- package/dist/cli/commands/constraints-pack-proposal.js +1 -1
- package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
- package/dist/cli/commands/constraints-reactivate.js +4 -2
- package/dist/cli/commands/constraints-reactivate.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +14 -4
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +10 -6
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/constraints.d.ts +1 -1
- package/dist/cli/commands/constraints.js +1 -1
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +16 -1
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/knowledge-view.d.ts +3 -3
- package/dist/cli/commands/knowledge-view.js +4 -4
- package/dist/cli/commands/knowledge-view.js.map +1 -1
- package/dist/cli/commands/release.d.ts +2 -2
- package/dist/cli/commands/release.js +2 -2
- package/dist/cli/commands/sync-docs/agents-syncer.js +2 -4
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/head-gate.d.ts +34 -0
- package/dist/cli/commands/sync-docs/head-gate.d.ts.map +1 -0
- package/dist/cli/commands/sync-docs/head-gate.js +86 -0
- package/dist/cli/commands/sync-docs/head-gate.js.map +1 -0
- package/dist/cli/commands/sync-docs/index.d.ts +7 -0
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +51 -1
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/completion-checkers/contract-presence.d.ts +1 -1
- package/dist/completion-checkers/contract-presence.js +1 -1
- package/dist/core/app-constraints-loader.d.ts +5 -3
- package/dist/core/app-constraints-loader.d.ts.map +1 -1
- package/dist/core/app-constraints-loader.js +20 -7
- package/dist/core/app-constraints-loader.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +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 +5 -3
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +31 -10
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts +1 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +22 -9
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.js +7 -1
- 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 +41 -26
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.d.ts +4 -1
- package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.js +8 -11
- package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
- package/dist/core/constraints/checkers/index.d.ts +6 -6
- package/dist/core/constraints/checkers/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/index.js +16 -11
- package/dist/core/constraints/checkers/index.js.map +1 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts +34 -0
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-completion-without-verification.js +157 -0
- package/dist/core/constraints/checkers/no-completion-without-verification.js.map +1 -0
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts +14 -4
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js +134 -30
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.d.ts +16 -2
- package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.js +115 -15
- package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
- package/dist/core/constraints/checkers/templated/exec.d.ts +19 -0
- package/dist/core/constraints/checkers/templated/exec.d.ts.map +1 -0
- package/dist/core/constraints/checkers/templated/exec.js +124 -0
- package/dist/core/constraints/checkers/templated/exec.js.map +1 -0
- package/dist/core/constraints/checkers/templated/index.d.ts +1 -0
- package/dist/core/constraints/checkers/templated/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/index.js +3 -1
- package/dist/core/constraints/checkers/templated/index.js.map +1 -1
- package/dist/core/constraints/checkers/templates-registry.d.ts +2 -1
- package/dist/core/constraints/checkers/templates-registry.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templates-registry.js +3 -1
- package/dist/core/constraints/checkers/templates-registry.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +68 -7
- package/dist/core/constraints/checkers/types.d.ts.map +1 -1
- package/dist/core/constraints/checkers/types.js +52 -7
- package/dist/core/constraints/checkers/types.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +0 -17
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/definitions/guidelines.d.ts +1 -0
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
- package/dist/core/constraints/definitions/guidelines.js +5 -1
- package/dist/core/constraints/definitions/guidelines.js.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.d.ts +1 -0
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.js +8 -3
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
- package/dist/core/constraints/definitions.d.ts +8 -1
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +11 -1
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/git-evidence.d.ts +10 -0
- package/dist/core/constraints/git-evidence.d.ts.map +1 -1
- package/dist/core/constraints/git-evidence.js +2 -0
- package/dist/core/constraints/git-evidence.js.map +1 -1
- package/dist/core/constraints/index.d.ts +3 -1
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +8 -1
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/run-env.d.ts +3 -2
- package/dist/core/constraints/run-env.d.ts.map +1 -1
- package/dist/core/constraints/run-env.js +5 -4
- package/dist/core/constraints/run-env.js.map +1 -1
- package/dist/core/constraints/usage-report.d.ts +0 -5
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +3 -12
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/effective-constraints.d.ts +1 -1
- package/dist/core/effective-constraints.js +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/retired-constraints.d.ts +66 -0
- package/dist/core/retired-constraints.d.ts.map +1 -0
- package/dist/core/retired-constraints.js +52 -0
- package/dist/core/retired-constraints.js.map +1 -0
- package/dist/core/validators/checkpoint.d.ts +4 -2
- package/dist/core/validators/checkpoint.d.ts.map +1 -1
- package/dist/core/validators/checkpoint.js +4 -2
- package/dist/core/validators/checkpoint.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +2 -2
- package/dist/core/validators/passes-gate.d.ts.map +1 -1
- package/dist/core/validators/passes-gate.js +4 -3
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/gates/checker-gate.d.ts +8 -4
- package/dist/gates/checker-gate.d.ts.map +1 -1
- package/dist/gates/checker-gate.js +13 -6
- package/dist/gates/checker-gate.js.map +1 -1
- package/dist/gates/index.d.ts +1 -1
- package/dist/gates/index.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/dist/knowledge/audit-scoring.js +1 -1
- package/dist/knowledge/audit-scoring.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +2 -2
- package/dist/monitoring/trace-analyzer.js +2 -2
- package/dist/monitoring/traces.d.ts +1 -1
- package/dist/monitoring/traces.js +4 -4
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/pretool-use-hook.d.ts +1 -1
- package/dist/pretool-use-hook.d.ts.map +1 -1
- package/dist/pretool-use-hook.js +5 -5
- package/dist/pretool-use-hook.js.map +1 -1
- package/dist/release/integrity.d.ts +4 -4
- package/dist/release/integrity.js +4 -4
- package/dist/test-setup/mkdtemp-cleanup.js +1 -1
- package/dist/tools/definitions/core/notification/notify.yml +0 -1
- package/dist/tools/definitions/ext/browser/browser-close.yml +0 -1
- package/dist/tools/definitions/ext/browser/browser-start.yml +0 -1
- package/dist/tools/definitions/std/evolution/implement.yml +0 -1
- package/dist/tools/definitions/std/evolution/prioritize.yml +0 -1
- package/dist/tools/definitions/std/evolution/report-gap.yml +0 -1
- package/dist/tools/definitions/std/governance/aggregate-opinions.yml +0 -1
- package/dist/tools/definitions/std/governance/audit-task.yml +0 -1
- package/dist/tools/definitions/std/governance/cast-vote.yml +0 -1
- package/dist/tools/definitions/std/governance/create-voting-session.yml +0 -1
- package/dist/tools/definitions/std/governance/define-stance.yml +0 -1
- package/dist/tools/definitions/std/governance/impeach.yml +0 -1
- package/dist/tools/definitions/std/governance/multi-stance-review.yml +0 -1
- package/dist/tools/definitions/std/governance/rollback.yml +0 -1
- package/dist/tools/definitions/std/governance/stance-review.yml +0 -1
- package/dist/tools/definitions/std/governance/track-effect.yml +0 -1
- package/dist/tools/definitions/std/governance/vote-tally.yml +0 -1
- package/dist/tools/definitions/std/planning/split-batch.yml +0 -1
- package/dist/tools/definitions/std/planning/split-tasks.yml +0 -1
- package/dist/types/constraint.d.ts +32 -9
- 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 +7 -0
- package/dist/types/passes-gate.d.ts.map +1 -1
- package/dist/types/passes-gate.js +8 -0
- package/dist/types/passes-gate.js.map +1 -1
- package/dist/types/trace.d.ts +7 -0
- package/dist/types/trace.d.ts.map +1 -1
- package/dist/utils/detect-source-roots.d.ts +1 -1
- package/dist/utils/detect-source-roots.d.ts.map +1 -1
- package/dist/utils/detect-source-roots.js +2 -21
- package/dist/utils/detect-source-roots.js.map +1 -1
- package/package.json +1 -2
- package/src/CONTEXT.md +3 -3
- package/src/__tests__/app-constraints-loader.test.ts +86 -3
- package/src/__tests__/checker-extra.test.ts +110 -11
- package/src/__tests__/checker-primitives-sdk.test.ts +70 -0
- package/src/__tests__/checker.test.ts +16 -14
- package/src/__tests__/detect-source-roots.test.ts +5 -4
- package/src/__tests__/exec-checker-full-chain.test.ts +118 -0
- package/src/__tests__/iron-laws.test.ts +13 -20
- package/src/__tests__/no-studio-references.test.ts +54 -0
- package/src/__tests__/passes-gate-check.test.ts +1 -1
- package/src/__tests__/pretool-use-hook.test.ts +2 -2
- package/src/__tests__/public-exports.test.ts +6 -0
- package/src/__tests__/public-type-surface.test.ts +24 -2
- package/src/__tests__/public-value-surface.test.ts +5 -0
- package/src/__tests__/retired-constraints.test.ts +99 -0
- package/src/__tests__/skip-semantics.test.ts +16 -33
- package/src/__tests__/usage-report-public-export.test.ts +3 -3
- package/src/cli/commands/CONTEXT.md +7 -6
- package/src/cli/commands/__tests__/check-read-count.test.ts +3 -0
- package/src/cli/commands/__tests__/check-skip-output.test.ts +4 -4
- package/src/cli/commands/__tests__/check.test.ts +35 -6
- package/src/cli/commands/__tests__/constraints-disable.test.ts +229 -0
- package/src/cli/commands/__tests__/constraints-report-json-flag.test.ts +1 -1
- package/src/cli/commands/__tests__/constraints-report.test.ts +4 -4
- package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +1 -1
- package/src/cli/commands/__tests__/knowledge.test.ts +3 -3
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +4 -1
- package/src/cli/commands/__tests__/project-path-convention.test.ts +1 -1
- package/src/cli/commands/__tests__/spec-baseline-index-cap.test.ts +1 -1
- package/src/cli/commands/__tests__/sync-docs-agents.test.ts +1 -24
- package/src/cli/commands/__tests__/sync-docs-gate.test.ts +154 -0
- package/src/cli/commands/__tests__/sync-docs-table-layout.test.ts +1 -1
- package/src/cli/commands/__tests__/sync-docs.test.ts +3 -3
- package/src/cli/commands/check.ts +3 -3
- package/src/cli/commands/constraints-disable.ts +145 -0
- package/src/cli/commands/constraints-pack-proposal.ts +1 -1
- package/src/cli/commands/constraints-reactivate.ts +4 -2
- package/src/cli/commands/constraints-retire.ts +11 -8
- package/src/cli/commands/constraints.ts +1 -1
- package/src/cli/commands/definitions.ts +16 -1
- package/src/cli/commands/knowledge-view.ts +4 -4
- package/src/cli/commands/release.ts +2 -2
- package/src/cli/commands/sync-docs/agents-syncer.ts +2 -4
- package/src/cli/commands/sync-docs/head-gate.ts +87 -0
- package/src/cli/commands/sync-docs/index.ts +62 -1
- package/src/completion-checkers/contract-presence.ts +1 -1
- package/src/core/CONTEXT.md +9 -8
- package/src/core/app-constraints-loader.ts +23 -8
- package/src/core/constraints/__tests__/capabilities-reconcile.test.ts +1 -1
- package/src/core/constraints/__tests__/check-cache.test.ts +1 -1
- package/src/core/constraints/__tests__/collect-constraints.test.ts +42 -18
- package/src/core/constraints/__tests__/git-evidence.test.ts +20 -0
- package/src/core/constraints/__tests__/run-env.test.ts +9 -7
- package/src/core/constraints/__tests__/trace-injection.test.ts +8 -2
- package/src/core/constraints/capabilities-parser.ts +1 -1
- package/src/core/constraints/check-cache.ts +1 -1
- package/src/core/constraints/checker.ts +35 -12
- package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +21 -3
- package/src/core/constraints/checkers/__tests__/context-doc-sync.test.ts +20 -12
- package/src/core/constraints/checkers/__tests__/docs-freshness-degraded.test.ts +89 -0
- package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +4 -2
- package/src/core/constraints/checkers/__tests__/exec-checker.test.ts +99 -0
- package/src/core/constraints/checkers/__tests__/fixtures/public-repo-sanitization.mjs +40 -0
- package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +24 -3
- package/src/core/constraints/checkers/__tests__/input-contract.test.ts +135 -0
- package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +208 -0
- package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +127 -5
- package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +144 -21
- package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +6 -2
- package/src/core/constraints/checkers/capability-sync.ts +25 -11
- package/src/core/constraints/checkers/context-doc-sync.ts +8 -1
- package/src/core/constraints/checkers/docs-freshness.ts +44 -26
- package/src/core/constraints/checkers/governance-presence.ts +8 -9
- package/src/core/constraints/checkers/index.ts +23 -13
- package/src/core/constraints/checkers/no-completion-without-verification.ts +126 -0
- package/src/core/constraints/checkers/no-hardcoded-credentials.ts +153 -29
- package/src/core/constraints/checkers/no-test-simplification.ts +128 -17
- package/src/core/constraints/checkers/templated/exec.ts +138 -0
- package/src/core/constraints/checkers/templated/index.ts +1 -0
- package/src/core/constraints/checkers/templates-registry.ts +4 -2
- package/src/core/constraints/checkers/types.ts +107 -10
- package/src/core/constraints/context-builder.ts +0 -18
- package/src/core/constraints/definitions/guidelines.ts +5 -1
- package/src/core/constraints/definitions/iron-laws.ts +8 -3
- package/src/core/constraints/definitions.ts +11 -1
- package/src/core/constraints/doc-freshness/__tests__/runner.test.ts +3 -3
- package/src/core/constraints/git-evidence.ts +13 -0
- package/src/core/constraints/index.ts +22 -1
- package/src/core/constraints/run-env.ts +6 -5
- package/src/core/constraints/usage-report.ts +2 -12
- package/src/core/effective-constraints.ts +1 -1
- package/src/core/index.ts +16 -1
- package/src/core/retired-constraints.ts +77 -0
- package/src/core/validators/checkpoint.ts +4 -2
- package/src/core/validators/passes-gate.ts +4 -3
- package/src/gates/CONTEXT.md +3 -2
- package/src/gates/__tests__/checker-gate.test.ts +20 -3
- package/src/gates/checker-gate.ts +14 -7
- package/src/gates/index.ts +1 -1
- package/src/hooks/CONTEXT.md +2 -2
- package/src/index.ts +35 -3
- package/src/knowledge/CONTEXT.md +2 -2
- package/src/knowledge/__tests__/audit.test.ts +1 -1
- package/src/knowledge/__tests__/flywheel-metrics.test.ts +1 -1
- package/src/knowledge/audit-scoring.ts +1 -1
- package/src/monitoring/CONTEXT.md +2 -2
- package/src/monitoring/__tests__/skipped-lines-report.test.ts +2 -2
- package/src/monitoring/__tests__/traces.test.ts +1 -1
- package/src/monitoring/trace-analyzer.ts +2 -2
- package/src/monitoring/traces.ts +4 -4
- package/src/pretool-use-hook.ts +5 -5
- package/src/release/CONTEXT.md +3 -3
- package/src/release/integrity.ts +4 -4
- package/src/test-setup/__tests__/mkdtemp-cleanup.test.ts +1 -1
- package/src/test-setup/mkdtemp-cleanup.ts +1 -1
- package/src/tools/CONTEXT.md +3 -3
- package/src/tools/__tests__/registry.test.ts +3 -3
- package/src/tools/definitions/core/notification/notify.yml +0 -1
- package/src/tools/definitions/ext/browser/browser-close.yml +0 -1
- package/src/tools/definitions/ext/browser/browser-start.yml +0 -1
- package/src/tools/definitions/std/evolution/implement.yml +0 -1
- package/src/tools/definitions/std/evolution/prioritize.yml +0 -1
- package/src/tools/definitions/std/evolution/report-gap.yml +0 -1
- package/src/tools/definitions/std/governance/aggregate-opinions.yml +0 -1
- package/src/tools/definitions/std/governance/audit-task.yml +0 -1
- package/src/tools/definitions/std/governance/cast-vote.yml +0 -1
- package/src/tools/definitions/std/governance/create-voting-session.yml +0 -1
- package/src/tools/definitions/std/governance/define-stance.yml +0 -1
- package/src/tools/definitions/std/governance/impeach.yml +0 -1
- package/src/tools/definitions/std/governance/multi-stance-review.yml +0 -1
- package/src/tools/definitions/std/governance/rollback.yml +0 -1
- package/src/tools/definitions/std/governance/stance-review.yml +0 -1
- package/src/tools/definitions/std/governance/track-effect.yml +0 -1
- package/src/tools/definitions/std/governance/vote-tally.yml +0 -1
- package/src/tools/definitions/std/planning/split-batch.yml +0 -1
- package/src/tools/definitions/std/planning/split-tasks.yml +0 -1
- package/src/types/constraint.ts +35 -10
- package/src/types/passes-gate.ts +8 -0
- package/src/types/trace.ts +8 -0
- package/src/utils/detect-source-roots.ts +2 -20
- package/bin/harness-knowledge-track.sh +0 -47
- package/bin/harness-sensitive-check.sh +0 -67
- package/dist/core/constraints/checkers/iron-flags.d.ts +0 -12
- package/dist/core/constraints/checkers/iron-flags.d.ts.map +0 -1
- package/dist/core/constraints/checkers/iron-flags.js +0 -16
- package/dist/core/constraints/checkers/iron-flags.js.map +0 -1
- package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +0 -30
- package/src/core/constraints/checkers/iron-flags.ts +0 -17
- package/templates/nextjs-app/.github/workflows/ci.yml +0 -39
- package/templates/node-api/.github/workflows/ci.yml +0 -36
- package/templates/node-api/package.json +0 -23
- package/templates/node-api/src/index.ts +0 -2
- package/templates/node-api/tsconfig.json +0 -19
- package/templates/python-api/.github/workflows/ci.yml +0 -39
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* severity 显式模型(ADR-0029):
|
|
5
5
|
* - severity='error':检查失败立即抛出异常(block 模式)
|
|
6
6
|
* - severity='warning':检查失败记录警告
|
|
7
|
-
* 全部约束 kind='check'
|
|
7
|
+
* 全部约束 kind='check';channel='gate' 的约束必须带真实 checker(注册表闭环,
|
|
8
|
+
* ADR-0035),非 gate 条目(workflow/discipline)不进入检查分发。
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import {
|
|
@@ -15,13 +16,13 @@ import {
|
|
|
15
16
|
ConstraintViolationError,
|
|
16
17
|
} from '../../types/constraint';
|
|
17
18
|
import type { ExecutionTrace } from '../../types/trace';
|
|
18
|
-
import { CONSTRAINTS } from './definitions';
|
|
19
|
+
import { CONSTRAINTS, isGateConstraint } from './definitions';
|
|
19
20
|
import type { MergedConstraintsConfig } from '../../types/project-config';
|
|
20
21
|
import { matchesTrigger } from './triggers';
|
|
21
22
|
import { join, relative } from 'path';
|
|
22
23
|
import { CheckCache } from './check-cache';
|
|
23
24
|
import { findTsSourceFiles } from '../../utils/file-walk';
|
|
24
|
-
import { getConstraintCheck, buildCheckEnv, normalizeCheckOutcome, type CheckOutcome } from './checkers';
|
|
25
|
+
import { getConstraintCheck, buildCheckEnv, normalizeCheckOutcome, degradeForMissingInputs, type CheckOutcome } from './checkers';
|
|
25
26
|
import { createGitEvidence, type GitEvidence } from './git-evidence';
|
|
26
27
|
import { createRunEnv, type RunEnv } from './run-env';
|
|
27
28
|
|
|
@@ -100,8 +101,9 @@ export class ConstraintChecker {
|
|
|
100
101
|
severity: constraint.severity,
|
|
101
102
|
satisfied: true,
|
|
102
103
|
skipped: true,
|
|
104
|
+
skipReason: outcome.skipReason,
|
|
103
105
|
constraint,
|
|
104
|
-
message: `约束 ${constraint.id}
|
|
106
|
+
message: `约束 ${constraint.id} 跳过评估(${outcome.skipReason ?? '约定未采用或证据未接线'})`,
|
|
105
107
|
checkedAt: new Date(),
|
|
106
108
|
};
|
|
107
109
|
}
|
|
@@ -137,14 +139,16 @@ export class ConstraintChecker {
|
|
|
137
139
|
projectPath: context.projectPath,
|
|
138
140
|
sessionId: context.sessionId,
|
|
139
141
|
evidence: checkResult.evidence,
|
|
142
|
+
skipReason: checkResult.skipped ? checkResult.skipReason : undefined,
|
|
140
143
|
});
|
|
141
144
|
}
|
|
142
145
|
|
|
143
146
|
/**
|
|
144
147
|
* 检查约束前置条件(工单 21:分发至 checkers/ 注册表)
|
|
145
148
|
*
|
|
146
|
-
* 注册表闭环(ADR-0001
|
|
147
|
-
*
|
|
149
|
+
* 注册表闭环(ADR-0001,口径经 ADR-0035 收窄):channel='gate' 未注册 checker
|
|
150
|
+
* 直接抛错,不再有"未注册默认通过"路径;非 gate 条目在编排层分发前已过滤,
|
|
151
|
+
* 漏到这里说明编排层有洞,同样抛错而非静默通过。
|
|
148
152
|
*
|
|
149
153
|
* git 证据(stagedDiff/stagedDiffNames)单一来源 = GitEvidence adapter(#87):
|
|
150
154
|
* 一次 run 内调用方传同一实例即至多取证一次,run 外调用独占一份。
|
|
@@ -156,11 +160,18 @@ export class ConstraintChecker {
|
|
|
156
160
|
evidence?: GitEvidence,
|
|
157
161
|
runEnv?: RunEnv
|
|
158
162
|
): Promise<CheckOutcome> {
|
|
163
|
+
if (!isGateConstraint(constraint)) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`[harness] 约束 "${constraint.id}" (channel='${constraint.channel}') 不进入检查分发,` +
|
|
166
|
+
`编排层过滤缺失,拒绝静默通过。`
|
|
167
|
+
);
|
|
168
|
+
}
|
|
159
169
|
const impl = getConstraintCheck(constraint);
|
|
160
170
|
if (!impl) {
|
|
161
171
|
throw new Error(
|
|
162
|
-
`[harness] 约束 "${constraint.id}" (
|
|
163
|
-
`请在 checkers/
|
|
172
|
+
`[harness] 约束 "${constraint.id}" (channel='gate') 未注册 checker,拒绝静默通过。` +
|
|
173
|
+
`请在 checkers/ 注册实现;拦不住的纪律规则标 channel: discipline 登记(harness 不执行),` +
|
|
174
|
+
`流程承载的规则标 channel: workflow(ADR-0035)。`
|
|
164
175
|
);
|
|
165
176
|
}
|
|
166
177
|
|
|
@@ -175,8 +186,19 @@ export class ConstraintChecker {
|
|
|
175
186
|
relative(projectPath, f)
|
|
176
187
|
)
|
|
177
188
|
),
|
|
189
|
+
available: (input) => {
|
|
190
|
+
switch (input) {
|
|
191
|
+
case 'stagedDiff': return git.stagedDiffAvailable();
|
|
192
|
+
case 'stagedDiffNames': return git.changedFileNamesAvailable(true);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
178
195
|
}, runEnv);
|
|
179
196
|
|
|
197
|
+
// 输入契约(harness#182):checker 声明的输入环境给不了 → 带原因的 skipped,
|
|
198
|
+
// 不进入 evaluate(「检查器失效 ≠ 对象合规」,不再对空证据假 pass / 无声 skip)
|
|
199
|
+
const degraded = degradeForMissingInputs(impl, env);
|
|
200
|
+
if (degraded) return degraded;
|
|
201
|
+
|
|
180
202
|
return await impl.evaluate(env);
|
|
181
203
|
}
|
|
182
204
|
|
|
@@ -197,7 +219,7 @@ export class ConstraintChecker {
|
|
|
197
219
|
const constraints = this.getConstraints(customConfig);
|
|
198
220
|
|
|
199
221
|
const applicable = Object.values(constraints).filter(constraint =>
|
|
200
|
-
matchesTrigger(constraint, operations)
|
|
222
|
+
isGateConstraint(constraint) && matchesTrigger(constraint, operations)
|
|
201
223
|
);
|
|
202
224
|
|
|
203
225
|
return {
|
|
@@ -276,7 +298,8 @@ export class ConstraintChecker {
|
|
|
276
298
|
const operations = [context.operation, ...(context.extraTriggers ?? [])];
|
|
277
299
|
|
|
278
300
|
// 1. error 级: block 模式首个违规即抛;collect 模式全量收集
|
|
279
|
-
|
|
301
|
+
// (ADR-0035:channel 非 gate 的条目不进入检查分发,两级循环同口径过滤)
|
|
302
|
+
for (const constraint of Object.values(constraints).filter(c => c.severity === 'error' && isGateConstraint(c))) {
|
|
280
303
|
if (!matchesTrigger(constraint, operations)) continue;
|
|
281
304
|
|
|
282
305
|
const checkResult = await this.check(constraint, context, run, env);
|
|
@@ -292,7 +315,7 @@ export class ConstraintChecker {
|
|
|
292
315
|
}
|
|
293
316
|
|
|
294
317
|
// 2. warning 级: 记录警告
|
|
295
|
-
for (const constraint of Object.values(constraints).filter(c => c.severity === 'warning')) {
|
|
318
|
+
for (const constraint of Object.values(constraints).filter(c => c.severity === 'warning' && isGateConstraint(c))) {
|
|
296
319
|
if (!matchesTrigger(constraint, operations)) continue;
|
|
297
320
|
|
|
298
321
|
const checkResult = await this.check(constraint, context, run, env);
|
|
@@ -327,7 +350,7 @@ export class ConstraintChecker {
|
|
|
327
350
|
const constraints = this.getConstraints(customConfig);
|
|
328
351
|
const operations = [context.operation, ...(context.extraTriggers ?? [])];
|
|
329
352
|
|
|
330
|
-
for (const constraint of Object.values(constraints).filter(c => c.severity === 'error')) {
|
|
353
|
+
for (const constraint of Object.values(constraints).filter(c => c.severity === 'error' && isGateConstraint(c))) {
|
|
331
354
|
if (!matchesTrigger(constraint, operations)) continue;
|
|
332
355
|
|
|
333
356
|
const result = await this.check(constraint, context, run, env);
|
|
@@ -54,10 +54,13 @@ const evidenceText = (outcome: CheckOutcome): string =>
|
|
|
54
54
|
normalizeCheckOutcome(outcome).evidence.join('\n');
|
|
55
55
|
|
|
56
56
|
describe('capability_sync — skip 与文档格式门槛', () => {
|
|
57
|
-
it('无 CAPABILITIES.md → skip(ADR-0001
|
|
57
|
+
it('无 CAPABILITIES.md → 带原因的 skip(ADR-0001 存在性探测,有无变更都一样;harness#182)', async () => {
|
|
58
58
|
const dir = createProjectFixture({ name: 'cap-sync-none' });
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
for (const staged of [[], ['src/foo.ts']]) {
|
|
60
|
+
const outcome = normalizeCheckOutcome(await capabilitySync.evaluate(makeEnv(dir, staged)));
|
|
61
|
+
expect(outcome.skipped).toBe(true);
|
|
62
|
+
expect(outcome.skipReason).toContain('未采用 CAPABILITIES.md 约定');
|
|
63
|
+
}
|
|
61
64
|
});
|
|
62
65
|
|
|
63
66
|
it('散文文档(无表格)+ 有变更 → 放行(历史语义)', async () => {
|
|
@@ -88,6 +91,21 @@ describe('capability_sync — skip 与文档格式门槛', () => {
|
|
|
88
91
|
const dir = setupDir('empty-table-nosrc', `# Capabilities\n\n${TABLE_HEAD}`);
|
|
89
92
|
expect(passed(await capabilitySync.evaluate(makeEnv(dir, [])))).toBe(true);
|
|
90
93
|
});
|
|
94
|
+
|
|
95
|
+
it('staged 清单不可得(git 取证失败)→ 放行但带降级提示,不假「已核对」(harness#182)', async () => {
|
|
96
|
+
const dir = setupDir('diff-unavailable', `# C\n\n${TABLE_HEAD}| foo | src/foo.ts | foo |\n`, ['src/foo.ts']);
|
|
97
|
+
const context: ConstraintContext = { operation: 'commit', projectPath: dir };
|
|
98
|
+
const env = buildCheckEnv(context, {
|
|
99
|
+
stagedDiff: async () => '',
|
|
100
|
+
stagedDiffNames: async () => '',
|
|
101
|
+
srcScan: (root: string) => collectSourceFiles(dir, [root]),
|
|
102
|
+
available: () => false,
|
|
103
|
+
});
|
|
104
|
+
const outcome = normalizeCheckOutcome(await capabilitySync.evaluate(env));
|
|
105
|
+
expect(outcome.satisfied).toBe(true); // fail-open 保留
|
|
106
|
+
expect(outcome.skipped).toBe(false); // 全量扫描不依赖 git,不整体 skip
|
|
107
|
+
expect(outcome.evidence.join('\n')).toContain('增量检查降级');
|
|
108
|
+
});
|
|
91
109
|
});
|
|
92
110
|
|
|
93
111
|
describe('capability_sync — step1 增量覆盖(唯一判违规处,harness#119)', () => {
|
|
@@ -37,26 +37,32 @@ const CTX_FILES = (enabled: boolean, dirs?: string[]) =>
|
|
|
37
37
|
(dirs ? ` required_dirs: [${dirs.map(d => `'${d}'`).join(', ')}]\n` : '');
|
|
38
38
|
|
|
39
39
|
describe('context_doc_sync — skip 门槛(ADR-0001 存在性探测)', () => {
|
|
40
|
+
/** skip 形状统一断言(harness#182:skip 恒带原因) */
|
|
41
|
+
const expectSkip = async (dir: string, reason: string) => {
|
|
42
|
+
const outcome = normalizeCheckOutcome(await evaluate(dir));
|
|
43
|
+
expect(outcome.skipped).toBe(true);
|
|
44
|
+
expect(outcome.skipReason).toContain(reason);
|
|
45
|
+
};
|
|
46
|
+
|
|
40
47
|
it('无 .harness/config.yml → skip', async () => {
|
|
41
|
-
|
|
48
|
+
await expectSkip(setupDir('no-config', null), '未配置 governance.context_files');
|
|
42
49
|
});
|
|
43
50
|
|
|
44
51
|
it('配置无 governance.context_files → skip', async () => {
|
|
45
|
-
|
|
52
|
+
await expectSkip(setupDir('no-section', 'preset: standard\n'), '未配置 governance.context_files');
|
|
46
53
|
});
|
|
47
54
|
|
|
48
55
|
it('enabled: false → skip(facade 旧断言 satisfied:true 的真实语义)', async () => {
|
|
49
|
-
|
|
56
|
+
await expectSkip(setupDir('disabled', CTX_FILES(false, ['src'])), '未配置 governance.context_files');
|
|
50
57
|
});
|
|
51
58
|
|
|
52
|
-
it('enabled 但 required_dirs 缺失/非数组/空 → skip', async () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
).toBe('skip');
|
|
59
|
+
it('enabled 但 required_dirs 缺失/非数组/空 → skip(约定已立但无目标)', async () => {
|
|
60
|
+
await expectSkip(setupDir('no-dirs', CTX_FILES(true)), 'required_dirs 为空');
|
|
61
|
+
await expectSkip(setupDir('empty-dirs', CTX_FILES(true, [])), 'required_dirs 为空');
|
|
62
|
+
await expectSkip(
|
|
63
|
+
setupDir('bad-dirs', 'governance:\n context_files:\n enabled: true\n required_dirs: src\n'),
|
|
64
|
+
'required_dirs 为空'
|
|
65
|
+
);
|
|
60
66
|
});
|
|
61
67
|
});
|
|
62
68
|
|
|
@@ -77,6 +83,8 @@ describe('context_doc_sync — 判定', () => {
|
|
|
77
83
|
|
|
78
84
|
it('配置解析失败 → skip(不炸不报)', async () => {
|
|
79
85
|
const dir = setupDir('bad-yaml', 'governance: [\n broken: {{\n');
|
|
80
|
-
|
|
86
|
+
const outcome = normalizeCheckOutcome(await evaluate(dir));
|
|
87
|
+
expect(outcome.skipped).toBe(true);
|
|
88
|
+
expect(outcome.skipReason).toContain('未配置 governance.context_files');
|
|
81
89
|
});
|
|
82
90
|
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* docs_freshness fail-open 发声测试(harness#182)
|
|
3
|
+
*
|
|
4
|
+
* FreshnessRunner 异常此前被整体 try/catch 静默吞掉(连 warn 都没有)——
|
|
5
|
+
* error 级约束顶着「检查器失效」报「合规」。对齐 capability_sync 姿势:
|
|
6
|
+
* console.warn + pass + evidence(降级提示进结果面与 trace),本套件钉死该路径。
|
|
7
|
+
* 单独成文件:FreshnessRunner 需模块级 mock,与 docs-freshness.test.ts 的真 runner 用例隔离。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect, jest, beforeEach, afterEach } from '@jest/globals';
|
|
11
|
+
|
|
12
|
+
jest.mock('../../doc-freshness/runner', () => ({
|
|
13
|
+
FreshnessRunner: jest.fn(function () {
|
|
14
|
+
return {
|
|
15
|
+
runAll: () => {
|
|
16
|
+
throw new Error('runner boom');
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
import { docsFreshness } from '../docs-freshness';
|
|
23
|
+
import { buildCheckEnv, normalizeCheckOutcome } from '../types';
|
|
24
|
+
import { createProjectFixture } from '../../../../test-setup/project-fixture';
|
|
25
|
+
import type { ConstraintContext } from '../../../../types/constraint';
|
|
26
|
+
|
|
27
|
+
describe('docs_freshness — FreshnessRunner 异常 → fail-open 但发声', () => {
|
|
28
|
+
let warnSpy: jest.SpiedFunction<typeof console.warn>;
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
jest.restoreAllMocks();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('runner 抛错 → warn + pass + 降级证据行(不再静默吞错)', async () => {
|
|
39
|
+
// CHANGELOG 使存在性探测命中(进入 Step 2);版本一致,差异只来自 runner 异常
|
|
40
|
+
const dir = createProjectFixture({
|
|
41
|
+
name: 'docs-fresh-runner-boom',
|
|
42
|
+
files: {
|
|
43
|
+
'CHANGELOG.md': '## [1.0.0] - 2026-01-01\n\n- init\n',
|
|
44
|
+
'package.json': JSON.stringify({ name: 'x', version: '1.0.0' }),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const context: ConstraintContext = { operation: 'file_modification', projectPath: dir };
|
|
48
|
+
const env = buildCheckEnv(context, {
|
|
49
|
+
stagedDiff: async () => '',
|
|
50
|
+
stagedDiffNames: async () => '',
|
|
51
|
+
srcScan: () => [],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const outcome = normalizeCheckOutcome(await docsFreshness.evaluate(env));
|
|
55
|
+
|
|
56
|
+
expect(warnSpy).toHaveBeenCalled();
|
|
57
|
+
expect(outcome.skipped).toBe(false);
|
|
58
|
+
expect(outcome.satisfied).toBe(true); // fail-open 保留
|
|
59
|
+
expect(outcome.evidence.join('\n')).toContain('fail-open');
|
|
60
|
+
expect(outcome.evidence.join('\n')).toContain('runner boom');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('Step 1 取数异常不吞掉 Step 2:两条降级提示都进 evidence,warn 各发一次', async () => {
|
|
64
|
+
const dir = createProjectFixture({
|
|
65
|
+
name: 'docs-fresh-step1-boom',
|
|
66
|
+
files: {
|
|
67
|
+
'CAPABILITIES.md': '# Capabilities\n\n| 模块 | 文件 | 说明 |\n|------|------|------|\n| m | src/m.ts | m |\n',
|
|
68
|
+
'src/m.ts': 'export const x = 1;\n',
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
const context: ConstraintContext = { operation: 'file_modification', projectPath: dir };
|
|
72
|
+
const env = buildCheckEnv(context, {
|
|
73
|
+
stagedDiff: async () => '',
|
|
74
|
+
stagedDiffNames: async () => '',
|
|
75
|
+
srcScan: () => {
|
|
76
|
+
throw new Error('scan boom');
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const outcome = normalizeCheckOutcome(await docsFreshness.evaluate(env));
|
|
81
|
+
|
|
82
|
+
expect(warnSpy).toHaveBeenCalledTimes(2);
|
|
83
|
+
expect(outcome.satisfied).toBe(true);
|
|
84
|
+
const text = outcome.evidence.join('\n');
|
|
85
|
+
expect(text).toContain('文件表幽灵检查异常');
|
|
86
|
+
expect(text).toContain('scan boom');
|
|
87
|
+
expect(text).toContain('runner boom'); // Step 2 照跑(其异常独立发声)
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -42,9 +42,11 @@ function writeCap(dir: string, body: string): void {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
describe('docs_freshness — 存在性探测(ADR-0001)', () => {
|
|
45
|
-
it('无 CAPABILITIES.md/CHANGELOG/配置 → skip,不计 pass/fail', async () => {
|
|
45
|
+
it('无 CAPABILITIES.md/CHANGELOG/配置 → 带原因的 skip,不计 pass/fail(harness#182)', async () => {
|
|
46
46
|
const dir = setupProject('none', ['src/module.ts']);
|
|
47
|
-
|
|
47
|
+
const outcome = normalizeCheckOutcome(await docsFreshness.evaluate(makeEnv(dir)));
|
|
48
|
+
expect(outcome.skipped).toBe(true);
|
|
49
|
+
expect(outcome.skipReason).toContain('未采用文档新鲜度约定');
|
|
48
50
|
});
|
|
49
51
|
});
|
|
50
52
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* exec 模板(harness#181,ADR-0035 决策 3 探测器来源 exec 档)测试
|
|
3
|
+
*
|
|
4
|
+
* 执行协议:params.command 以 env.projectPath 为 cwd 执行,退出码 0 = 满足、非 0 = 违规,
|
|
5
|
+
* stdout/stderr 行进证据。保护面:超时即杀 + 输出截断(命令失控不拖死检查流程)。
|
|
6
|
+
* 范式同 templated-checkers.test.ts:测面是 ConstraintCheck.evaluate(env),
|
|
7
|
+
* exec 不吃 git 证据,env 经 buildCheckEnv(context, 'none') 构造。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect } from '@jest/globals';
|
|
11
|
+
import { execScript } from '../templated/exec';
|
|
12
|
+
import { TEMPLATES } from '../index';
|
|
13
|
+
import { buildCheckEnv, normalizeCheckOutcome, type CheckEnv, type CheckOutcome } from '../types';
|
|
14
|
+
import { createProjectFixture } from '../../../../test-setup/project-fixture';
|
|
15
|
+
import type { ConstraintContext } from '../../../../types/constraint';
|
|
16
|
+
|
|
17
|
+
function makeEnv(projectPath: string): CheckEnv {
|
|
18
|
+
const context: ConstraintContext = { operation: 'commit', projectPath };
|
|
19
|
+
return buildCheckEnv(context, 'none');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const passed = (outcome: CheckOutcome): boolean => normalizeCheckOutcome(outcome).satisfied;
|
|
23
|
+
const evidenceText = (outcome: CheckOutcome): string =>
|
|
24
|
+
normalizeCheckOutcome(outcome).evidence.join('\n');
|
|
25
|
+
|
|
26
|
+
describe('exec 模板注册与参数校验', () => {
|
|
27
|
+
it('已注册进 TEMPLATES', () => {
|
|
28
|
+
expect(TEMPLATES.get('exec')).toBe(execScript);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('validateParams:command 必填非空字符串', () => {
|
|
32
|
+
expect(execScript.validateParams({}).join()).toContain('command');
|
|
33
|
+
expect(execScript.validateParams({ command: '' }).join()).toContain('command');
|
|
34
|
+
expect(execScript.validateParams({ command: 1 }).join()).toContain('command');
|
|
35
|
+
expect(execScript.validateParams({ command: 'true' })).toEqual([]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('validateParams:timeoutMs 可选,须为正数且不超上限', () => {
|
|
39
|
+
expect(execScript.validateParams({ command: 'true', timeoutMs: '1' }).join()).toContain('timeoutMs');
|
|
40
|
+
expect(execScript.validateParams({ command: 'true', timeoutMs: 0 }).join()).toContain('timeoutMs');
|
|
41
|
+
expect(execScript.validateParams({ command: 'true', timeoutMs: -5 }).join()).toContain('timeoutMs');
|
|
42
|
+
expect(execScript.validateParams({ command: 'true', timeoutMs: 999_999_999 }).join()).toContain('timeoutMs');
|
|
43
|
+
expect(execScript.validateParams({ command: 'true', timeoutMs: 5000 })).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('exec evaluate', () => {
|
|
48
|
+
it('退出码 0 → 满足', async () => {
|
|
49
|
+
const dir = createProjectFixture({ name: 'exec-pass' });
|
|
50
|
+
const check = execScript.create('app_x', { command: 'node -e "process.exit(0)"' });
|
|
51
|
+
expect(passed(await check.evaluate(makeEnv(dir)))).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('非零退出 → 违规,证据含退出码与 stdout/stderr 行', async () => {
|
|
55
|
+
const dir = createProjectFixture({ name: 'exec-fail' });
|
|
56
|
+
const command = `node -e "console.log('out-line'); console.error('err-line'); process.exit(3)"`;
|
|
57
|
+
const outcome = await execScript.create('app_x', { command }).evaluate(makeEnv(dir));
|
|
58
|
+
expect(passed(outcome)).toBe(false);
|
|
59
|
+
const text = evidenceText(outcome);
|
|
60
|
+
expect(text).toContain('退出码 3');
|
|
61
|
+
expect(text).toContain('out-line');
|
|
62
|
+
expect(text).toContain('err-line');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('cwd = env.projectPath(脚本拿到的项目根即约束目标项目)', async () => {
|
|
66
|
+
const dir = createProjectFixture({ name: 'exec-cwd' });
|
|
67
|
+
const command = 'node -e "console.log(process.cwd()); process.exit(1)"';
|
|
68
|
+
const text = evidenceText(await execScript.create('app_x', { command }).evaluate(makeEnv(dir)));
|
|
69
|
+
expect(text).toContain(dir);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('超时 → 杀死进程并判违规(命令失控不拖死检查流程)', async () => {
|
|
73
|
+
const dir = createProjectFixture({ name: 'exec-timeout' });
|
|
74
|
+
const check = execScript.create('app_x', {
|
|
75
|
+
command: 'node -e "setInterval(() => {}, 1000)"',
|
|
76
|
+
timeoutMs: 500,
|
|
77
|
+
});
|
|
78
|
+
const outcome = await check.evaluate(makeEnv(dir));
|
|
79
|
+
expect(passed(outcome)).toBe(false);
|
|
80
|
+
expect(evidenceText(outcome)).toContain('超时');
|
|
81
|
+
}, 15000);
|
|
82
|
+
|
|
83
|
+
it('输出截断保护:超长 stdout/stderr 不整段进证据', async () => {
|
|
84
|
+
const dir = createProjectFixture({ name: 'exec-truncate' });
|
|
85
|
+
const command = `node -e "for (let i = 0; i < 2000; i++) console.log('line-' + i + '-'.repeat(50)); process.exit(1)"`;
|
|
86
|
+
const outcome = await execScript.create('app_x', { command }).evaluate(makeEnv(dir));
|
|
87
|
+
expect(passed(outcome)).toBe(false);
|
|
88
|
+
expect(evidenceText(outcome)).toContain('截断');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('命令不存在(shell 退出 127)→ 违规而非静默通过', async () => {
|
|
92
|
+
const dir = createProjectFixture({ name: 'exec-enoent' });
|
|
93
|
+
const outcome = await execScript
|
|
94
|
+
.create('app_x', { command: 'definitely-not-a-real-command-xyz' })
|
|
95
|
+
.evaluate(makeEnv(dir));
|
|
96
|
+
expect(passed(outcome)).toBe(false);
|
|
97
|
+
expect(evidenceText(outcome)).toContain('退出码 127');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 示例业务检查器(harness#181 验收示例):public-repo-sanitization
|
|
4
|
+
*
|
|
5
|
+
* 场景原型 = 下游消费方安全底线 public_repo_sanitization(ADR-0032 ①):公开发布仓的
|
|
6
|
+
* 受跟踪文本不得残留开发机现场绝对路径(/Users/<name>/、/home/<name>/),文档示例的
|
|
7
|
+
* 占位符形态(/Users/<you>/ 等尖括号段)豁免。
|
|
8
|
+
*
|
|
9
|
+
* 模板填不了的点:命中判定带豁免谓词,regex-scan「命中即违规」表达不了——正是
|
|
10
|
+
* ADR-0035 决策 3 的 exec 档场景。
|
|
11
|
+
*
|
|
12
|
+
* 协议(与 exec 模板约定):argv = 待扫文件(相对项目根;exec 模板以项目根为 cwd 执行);
|
|
13
|
+
* 命中逐条打印到 stdout 并 exit 1;干净 exit 0。业务知识不出业务仓:本脚本即业务判定本体。
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { readFileSync } from 'node:fs';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
|
|
19
|
+
const MACHINE_PATH = /\/(?:Users|home)\/([^/\s'"]+)\//g;
|
|
20
|
+
|
|
21
|
+
const hits = [];
|
|
22
|
+
for (const rel of process.argv.slice(2)) {
|
|
23
|
+
let content;
|
|
24
|
+
try {
|
|
25
|
+
content = readFileSync(join(process.cwd(), rel), 'utf-8');
|
|
26
|
+
} catch {
|
|
27
|
+
continue; // 文件不可读(已删除/二进制)→ 跳过
|
|
28
|
+
}
|
|
29
|
+
content.split('\n').forEach((line, i) => {
|
|
30
|
+
for (const m of line.matchAll(MACHINE_PATH)) {
|
|
31
|
+
if (m[1].startsWith('<')) continue; // 占位符豁免:/Users/<you>/
|
|
32
|
+
hits.push(`${rel}:${i + 1} 残留开发机现场路径 ${m[0]}`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (hits.length > 0) {
|
|
38
|
+
for (const hit of hits) console.log(hit);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* governance_presence 检查器旁测(
|
|
2
|
+
* governance_presence 检查器旁测(ADR 2026-08-21 落点模型)
|
|
3
3
|
*
|
|
4
4
|
* 在场守护:PRESERVE 只保「存在」不保「在场」——治理契约段被删除/掏空后
|
|
5
5
|
* sync-docs 重新生成会静默丢失,本 checker 在 harness check 时校验在场性。
|
|
@@ -59,8 +59,29 @@ describe('governance_presence checker', () => {
|
|
|
59
59
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
it('未采用 harness 治理(无 .harness/config.yml)→ skip', async () => {
|
|
63
|
-
|
|
62
|
+
it('未采用 harness 治理(无 .harness/config.yml)→ 带原因的 skip(harness#182)', async () => {
|
|
63
|
+
const outcome = normalizeCheckOutcome(await governancePresence.evaluate(makeEnv(tempDir)));
|
|
64
|
+
expect(outcome.skipped).toBe(true);
|
|
65
|
+
expect(outcome.skipReason).toContain('未采用 harness 治理');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('config.yml YAML 损坏 → 仍按「已采用」评估(harness#182:不再恰在配置出问题时闭嘴)', async () => {
|
|
69
|
+
fs.mkdirSync(path.join(tempDir, '.harness'), { recursive: true });
|
|
70
|
+
fs.writeFileSync(path.join(tempDir, '.harness', 'config.yml'), 'preset: [broken\n - {unclosed');
|
|
71
|
+
// 两处都没有治理契约 → fail(旧行为:解析抛错被吞 → 误判未采用 → skip)
|
|
72
|
+
const outcome = normalizeCheckOutcome(await governancePresence.evaluate(makeEnv(tempDir)));
|
|
73
|
+
expect(outcome.skipped).toBe(false);
|
|
74
|
+
expect(outcome.satisfied).toBe(false);
|
|
75
|
+
expect(outcome.evidence.join('\n')).toContain('治理契约');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('config.yml YAML 损坏 + AGENTS.md 有 PRESERVE:governance → pass(损坏配置不影响在场判定)', async () => {
|
|
79
|
+
fs.mkdirSync(path.join(tempDir, '.harness'), { recursive: true });
|
|
80
|
+
fs.writeFileSync(path.join(tempDir, '.harness', 'config.yml'), 'preset: [broken\n - {unclosed');
|
|
81
|
+
fs.writeFileSync(path.join(tempDir, 'AGENTS.md'), `# AGENTS.md\n\n${GOVERNANCE_BLOCK}\n`);
|
|
82
|
+
const outcome = normalizeCheckOutcome(await governancePresence.evaluate(makeEnv(tempDir)));
|
|
83
|
+
expect(outcome.skipped).toBe(false);
|
|
84
|
+
expect(outcome.satisfied).toBe(true);
|
|
64
85
|
});
|
|
65
86
|
|
|
66
87
|
it('新模型:AGENTS.md 有非空 PRESERVE:governance 段 → pass', async () => {
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 检查器输入契约测试(harness#182)
|
|
3
|
+
*
|
|
4
|
+
* 「检查器失效 ≠ 对象合规」的接缝锁定:
|
|
5
|
+
* - findMissingInputs:checker 声明的 needs 与环境供给比对(缺证据 / flag 未接线)
|
|
6
|
+
* - 编排层降级:git 取证失败 → 带原因的 skipped,不进入 evaluate(不再对空 diff 假 pass)
|
|
7
|
+
* - skipReason 落 ConstraintResult 与 ExecutionTrace(可统计的失效信号)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect } from '@jest/globals';
|
|
11
|
+
import { ConstraintChecker } from '../../checker';
|
|
12
|
+
import { createGitEvidence } from '../../git-evidence';
|
|
13
|
+
import {
|
|
14
|
+
buildCheckEnv,
|
|
15
|
+
findMissingInputs,
|
|
16
|
+
normalizeCheckOutcome,
|
|
17
|
+
type ConstraintCheck,
|
|
18
|
+
} from '../types';
|
|
19
|
+
import { noTestSimplification } from '../no-test-simplification';
|
|
20
|
+
import type { Constraint, ConstraintContext } from '../../../../types/constraint';
|
|
21
|
+
import type { MergedConstraintsConfig } from '../../../../types/project-config';
|
|
22
|
+
import type { ExecutionTrace } from '../../../../types/trace';
|
|
23
|
+
|
|
24
|
+
const NO_TEST_SIMPLIFICATION: Constraint = {
|
|
25
|
+
id: 'no_test_simplification',
|
|
26
|
+
kind: 'check',
|
|
27
|
+
severity: 'error',
|
|
28
|
+
rule: 'DO NOT DELETE TESTS',
|
|
29
|
+
message: '禁止简化测试绕过困难',
|
|
30
|
+
trigger: 'commit',
|
|
31
|
+
enforcement: 'restore-tests',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const CONTEXT: ConstraintContext = { operation: 'commit', projectPath: '/nonexistent' };
|
|
35
|
+
|
|
36
|
+
function envOf(context: ConstraintContext, available: Record<string, boolean>) {
|
|
37
|
+
return buildCheckEnv(context, {
|
|
38
|
+
stagedDiff: async () => '',
|
|
39
|
+
stagedDiffNames: async () => '',
|
|
40
|
+
srcScan: () => [],
|
|
41
|
+
available: (input) => available[input] ?? true,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe('findMissingInputs — needs 与环境供给比对', () => {
|
|
46
|
+
it('未声明 needs → 无缺项', () => {
|
|
47
|
+
expect(findMissingInputs({ id: 'x', evaluate: () => true }, envOf(CONTEXT, {}))).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('evidenceAvailable 报不可得 → 缺项自描述', () => {
|
|
51
|
+
const missing = findMissingInputs(noTestSimplification, envOf(CONTEXT, { stagedDiff: false }));
|
|
52
|
+
expect(missing).toEqual(['staged diff 不可得(git 取证失败或未接线)']);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('contextFlags 为 undefined → 缺项点名标志', () => {
|
|
56
|
+
const check: ConstraintCheck = {
|
|
57
|
+
id: 'flag-check',
|
|
58
|
+
needs: { contextFlags: ['hasFailingTest'] },
|
|
59
|
+
evaluate: () => true,
|
|
60
|
+
};
|
|
61
|
+
expect(findMissingInputs(check, envOf(CONTEXT, {}))).toEqual([
|
|
62
|
+
'证据标志 hasFailingTest 未接线',
|
|
63
|
+
]);
|
|
64
|
+
expect(
|
|
65
|
+
findMissingInputs(check, envOf({ ...CONTEXT, hasFailingTest: false }, {}))
|
|
66
|
+
).toEqual([]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('手写 env 未提供 evidenceAvailable → 按全部可得(旧形状兼容)', () => {
|
|
70
|
+
const env = buildCheckEnv(CONTEXT, {
|
|
71
|
+
stagedDiff: async () => '',
|
|
72
|
+
stagedDiffNames: async () => '',
|
|
73
|
+
srcScan: () => [],
|
|
74
|
+
});
|
|
75
|
+
expect(findMissingInputs(noTestSimplification, env)).toEqual([]);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('normalizeCheckOutcome — CheckSkip 归一', () => {
|
|
80
|
+
it('{ skip, reason } → skipped + skipReason,evidence 恒空(未评估不留证据行)', () => {
|
|
81
|
+
expect(normalizeCheckOutcome({ skip: true, reason: '输入不可得' })).toEqual({
|
|
82
|
+
satisfied: true,
|
|
83
|
+
skipped: true,
|
|
84
|
+
evidence: [],
|
|
85
|
+
skipReason: '输入不可得',
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/** 只含 no_test_simplification 的生效集:一次 run 一条 trace */
|
|
91
|
+
function onlyNoTestSimplification(): MergedConstraintsConfig {
|
|
92
|
+
return { constraints: { no_test_simplification: NO_TEST_SIMPLIFICATION }, disabled: [] };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
describe('编排层输入契约降级(git 取证失败 → 带原因的 skipped)', () => {
|
|
96
|
+
const throwingRunner = () => {
|
|
97
|
+
throw new Error('not a git repository');
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
it('git 失败 → skipped + skipReason,不阻断(fail-open 但不假 pass)', async () => {
|
|
101
|
+
const checker = new ConstraintChecker();
|
|
102
|
+
const git = createGitEvidence('/nonexistent', throwingRunner);
|
|
103
|
+
|
|
104
|
+
const result = await checker.check(NO_TEST_SIMPLIFICATION, CONTEXT, git);
|
|
105
|
+
|
|
106
|
+
expect(result.skipped).toBe(true);
|
|
107
|
+
expect(result.satisfied).toBe(true);
|
|
108
|
+
expect(result.skipReason).toContain('staged diff 不可得');
|
|
109
|
+
expect(result.message).toContain('staged diff 不可得');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('git 失败 → trace 记 result:skip 且携带 skipReason(失效可统计)', async () => {
|
|
113
|
+
const traces: ExecutionTrace[] = [];
|
|
114
|
+
const checker = new ConstraintChecker({ record: (t) => traces.push(t) });
|
|
115
|
+
const git = createGitEvidence('/nonexistent', throwingRunner);
|
|
116
|
+
|
|
117
|
+
const run = await checker.checkConstraints(CONTEXT, onlyNoTestSimplification(), git);
|
|
118
|
+
|
|
119
|
+
expect(run.passed).toBe(true);
|
|
120
|
+
expect(run.errors[0].skipped).toBe(true);
|
|
121
|
+
const trace = traces.find(t => t.constraintId === 'no_test_simplification')!;
|
|
122
|
+
expect(trace.result).toBe('skip');
|
|
123
|
+
expect(trace.skipReason).toContain('staged diff 不可得');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('git 正常 → 进入评估(对照:契约齐备不降级)', async () => {
|
|
127
|
+
const checker = new ConstraintChecker();
|
|
128
|
+
const git = createGitEvidence('/nonexistent', () => '');
|
|
129
|
+
|
|
130
|
+
const result = await checker.check(NO_TEST_SIMPLIFICATION, CONTEXT, git);
|
|
131
|
+
|
|
132
|
+
expect(result.skipped).toBeUndefined();
|
|
133
|
+
expect(result.satisfied).toBe(true);
|
|
134
|
+
});
|
|
135
|
+
});
|