@dommaker/harness 1.15.0 → 1.16.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 +12 -0
- package/bin/harness.js +6 -0
- package/dist/cli/command-contract.d.ts +4 -4
- package/dist/cli/command-contract.d.ts.map +1 -1
- package/dist/cli/commands/command.d.ts.map +1 -1
- package/dist/cli/commands/command.js +5 -5
- package/dist/cli/commands/command.js.map +1 -1
- package/dist/cli/commands/constraints-disable.d.ts +7 -11
- package/dist/cli/commands/constraints-disable.d.ts.map +1 -1
- package/dist/cli/commands/constraints-disable.js +8 -80
- package/dist/cli/commands/constraints-disable.js.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.d.ts +7 -20
- package/dist/cli/commands/constraints-pack-proposal.d.ts.map +1 -1
- package/dist/cli/commands/constraints-pack-proposal.js +21 -129
- package/dist/cli/commands/constraints-pack-proposal.js.map +1 -1
- package/dist/cli/commands/constraints-reactivate.d.ts +8 -20
- package/dist/cli/commands/constraints-reactivate.d.ts.map +1 -1
- package/dist/cli/commands/constraints-reactivate.js +11 -105
- package/dist/cli/commands/constraints-reactivate.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +11 -67
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +18 -195
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/constraints.d.ts +6 -9
- package/dist/cli/commands/constraints.d.ts.map +1 -1
- package/dist/cli/commands/constraints.js +7 -21
- package/dist/cli/commands/constraints.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +4 -19
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/knowledge.js +1 -1
- package/dist/cli/commands/knowledge.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/scaffold-templates.d.ts +7 -0
- package/dist/cli/commands/scaffold-templates.d.ts.map +1 -1
- package/dist/cli/commands/scaffold-templates.js +21 -1
- package/dist/cli/commands/scaffold-templates.js.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.d.ts +13 -0
- package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/context-syncer.js +30 -0
- 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 +30 -4
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.d.ts +5 -0
- package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +7 -0
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/gate-command.js +1 -1
- package/dist/cli/gate-command.js.map +1 -1
- package/dist/completion-checkers/glob-match.d.ts +1 -1
- package/dist/completion-checkers/glob-match.d.ts.map +1 -1
- package/dist/completion-checkers/glob-match.js +3 -38
- package/dist/completion-checkers/glob-match.js.map +1 -1
- package/dist/context/index.d.ts +2 -3
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/knowledge-injector.d.ts.map +1 -1
- package/dist/context/knowledge-injector.js +3 -4
- package/dist/context/knowledge-injector.js.map +1 -1
- package/dist/context/session-manager.d.ts +0 -6
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +0 -9
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +0 -24
- package/dist/context/types.d.ts.map +1 -1
- package/dist/core/config-files.d.ts +21 -0
- package/dist/core/config-files.d.ts.map +1 -0
- package/dist/core/config-files.js +75 -0
- package/dist/core/config-files.js.map +1 -0
- package/dist/core/constraint-lifecycle.d.ts +127 -0
- package/dist/core/constraint-lifecycle.d.ts.map +1 -0
- package/dist/core/constraint-lifecycle.js +306 -0
- package/dist/core/constraint-lifecycle.js.map +1 -0
- package/dist/core/constraints/checker.d.ts +9 -1
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +18 -0
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts +6 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.js +17 -1
- package/dist/core/constraints/checkers/no-completion-without-verification.js.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts +0 -2
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js +0 -5
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js +1 -1
- package/dist/core/constraints/checkers/templated/file-exists.js.map +1 -1
- package/dist/core/constraints/checkers/templated/glob.d.ts +2 -3
- package/dist/core/constraints/checkers/templated/glob.d.ts.map +1 -1
- package/dist/core/constraints/checkers/templated/glob.js +4 -40
- package/dist/core/constraints/checkers/templated/glob.js.map +1 -1
- package/dist/core/constraints/construction-sites.d.ts +56 -0
- package/dist/core/constraints/construction-sites.d.ts.map +1 -0
- package/dist/core/constraints/construction-sites.js +75 -0
- package/dist/core/constraints/construction-sites.js.map +1 -0
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js +3 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/index.d.ts +0 -2
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +1 -4
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/meta.d.ts +18 -0
- package/dist/core/constraints/meta.d.ts.map +1 -0
- package/dist/core/constraints/meta.js +31 -0
- package/dist/core/constraints/meta.js.map +1 -0
- package/dist/core/constraints/pack-proposal.d.ts +66 -0
- package/dist/core/constraints/pack-proposal.d.ts.map +1 -0
- package/dist/core/constraints/pack-proposal.js +181 -0
- package/dist/core/constraints/pack-proposal.js.map +1 -0
- package/dist/core/constraints/usage-report.d.ts +3 -1
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +3 -1
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/effective-constraints.d.ts +6 -6
- package/dist/core/effective-constraints.d.ts.map +1 -1
- package/dist/core/effective-constraints.js +6 -6
- package/dist/core/effective-constraints.js.map +1 -1
- package/dist/core/index.d.ts +3 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -6
- package/dist/core/index.js.map +1 -1
- package/dist/core/validators/check-handlers/command.d.ts.map +1 -1
- package/dist/core/validators/check-handlers/command.js +42 -4
- package/dist/core/validators/check-handlers/command.js.map +1 -1
- package/dist/gates/checker-gate.d.ts +2 -1
- package/dist/gates/checker-gate.d.ts.map +1 -1
- package/dist/gates/checker-gate.js +2 -1
- package/dist/gates/checker-gate.js.map +1 -1
- package/dist/gates/command.d.ts +3 -20
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +2 -35
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/definitions.d.ts +1 -1
- package/dist/gates/definitions.d.ts.map +1 -1
- package/dist/gates/definitions.js +1 -1
- package/dist/gates/definitions.js.map +1 -1
- package/dist/gates/index.d.ts +6 -40
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js +5 -79
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/registry.js +1 -1
- package/dist/gates/registry.js.map +1 -1
- package/dist/gates/types.d.ts +10 -3
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/index.d.ts +16 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -64
- package/dist/index.js.map +1 -1
- package/dist/knowledge/index.d.ts +1 -3
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +3 -5
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/query.d.ts +1 -1
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js +12 -15
- package/dist/knowledge/query.js.map +1 -1
- package/dist/knowledge/token-estimate.d.ts +14 -0
- package/dist/knowledge/token-estimate.d.ts.map +1 -0
- package/dist/knowledge/token-estimate.js +31 -0
- package/dist/knowledge/token-estimate.js.map +1 -0
- package/dist/monitoring/analyzer-base.d.ts +0 -8
- package/dist/monitoring/analyzer-base.d.ts.map +1 -1
- package/dist/monitoring/analyzer-base.js +0 -20
- package/dist/monitoring/analyzer-base.js.map +1 -1
- package/dist/monitoring/index.d.ts +2 -7
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/index.js +2 -9
- package/dist/monitoring/index.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +0 -4
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +0 -9
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +14 -10
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +41 -45
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/pretool-use-hook.js +2 -2
- package/dist/release/integrity.d.ts.map +1 -1
- package/dist/release/integrity.js +0 -2
- package/dist/release/integrity.js.map +1 -1
- package/dist/test-setup/jsonl-fake-fs.d.ts +1 -1
- package/dist/test-setup/jsonl-fake-fs.js +1 -1
- package/dist/utils/glob-match.d.ts +10 -0
- package/dist/utils/glob-match.d.ts.map +1 -0
- package/dist/utils/glob-match.js +47 -0
- package/dist/utils/glob-match.js.map +1 -0
- package/dist/utils/jsonl.d.ts +1 -1
- package/dist/utils/jsonl.js +1 -1
- package/dist/utils/yaml-edit.d.ts +26 -0
- package/dist/utils/yaml-edit.d.ts.map +1 -0
- package/dist/utils/yaml-edit.js +98 -0
- package/dist/utils/yaml-edit.js.map +1 -0
- package/package.json +2 -2
- package/src/CONTEXT.md +13 -6
- package/src/__tests__/acceptance-gate.test.ts +2 -4
- package/src/__tests__/effective-constraints.test.ts +16 -0
- package/src/__tests__/layering.test.ts +2 -3
- package/src/__tests__/no-studio-references.test.ts +13 -5
- package/src/__tests__/pretool-use-hook.test.ts +3 -3
- package/src/__tests__/public-exports.test.ts +195 -41
- package/src/__tests__/public-type-surface.test.ts +25 -65
- package/src/__tests__/public-value-surface.test.ts +13 -36
- package/src/__tests__/trace-analyzer-extra.test.ts +1 -13
- package/src/agents/CONTEXT.md +4 -4
- package/src/cli/__tests__/gate-command.test.ts +1 -1
- package/src/cli/command-contract.ts +4 -4
- package/src/cli/commands/CONTEXT.md +4 -4
- package/src/cli/commands/__tests__/command.test.ts +2 -2
- package/src/cli/commands/__tests__/knowledge-view.test.ts +1 -1
- package/src/cli/commands/__tests__/project-path-convention.test.ts +3 -35
- package/src/cli/commands/__tests__/sync-docs-construction-sites.test.ts +175 -0
- package/src/cli/commands/__tests__/validate.test.ts +49 -0
- package/src/cli/commands/command.ts +2 -1
- package/src/cli/commands/constraints-disable.ts +8 -59
- package/src/cli/commands/constraints-pack-proposal.ts +26 -121
- package/src/cli/commands/constraints-reactivate.ts +22 -113
- package/src/cli/commands/constraints-retire.ts +29 -269
- package/src/cli/commands/constraints.ts +6 -30
- package/src/cli/commands/init.ts +5 -19
- package/src/cli/commands/knowledge.ts +1 -1
- package/src/cli/commands/release.ts +2 -2
- package/src/cli/commands/scaffold-templates.ts +23 -0
- package/src/cli/commands/security.ts +1 -1
- package/src/cli/commands/sync-docs/__tests__/construction-site-count.test.ts +49 -0
- package/src/cli/commands/sync-docs/context-syncer.ts +43 -1
- package/src/cli/commands/sync-docs/index.ts +41 -5
- package/src/cli/commands/sync-docs/project-reader.ts +5 -0
- package/src/cli/commands/validate.ts +7 -0
- package/src/cli/gate-command.ts +1 -1
- package/src/completion-checkers/CONTEXT.md +3 -3
- package/src/completion-checkers/glob-match.ts +3 -35
- package/src/context/CONTEXT.md +5 -8
- package/src/context/__tests__/knowledge-injector.test.ts +21 -2
- package/src/context/__tests__/session-manager.test.ts +0 -7
- package/src/context/index.ts +1 -5
- package/src/context/knowledge-injector.ts +3 -4
- package/src/context/session-manager.ts +0 -10
- package/src/context/types.ts +0 -20
- package/src/core/CONTEXT.md +10 -5
- package/src/core/__tests__/config-files.test.ts +88 -0
- package/src/core/__tests__/constraint-lifecycle.test.ts +255 -0
- package/src/core/__tests__/constraints-meta.test.ts +26 -0
- package/src/core/__tests__/pack-proposal.test.ts +95 -0
- package/src/core/config-files.ts +39 -0
- package/src/core/constraint-lifecycle.ts +435 -0
- package/src/core/constraints/__tests__/check-cache.test.ts +0 -7
- package/src/core/constraints/__tests__/collect-constraints.test.ts +25 -0
- package/src/core/constraints/__tests__/construction-sites.test.ts +147 -0
- package/src/core/constraints/__tests__/context-reconcile.test.ts +16 -16
- package/src/core/constraints/__tests__/trace-injection.test.ts +14 -15
- package/src/core/constraints/__tests__/usage-report.test.ts +9 -0
- package/src/core/constraints/checker.ts +20 -1
- package/src/core/constraints/checkers/__tests__/no-completion-without-verification.test.ts +22 -3
- package/src/core/constraints/checkers/__tests__/no-hardcoded-credentials.test.ts +56 -41
- package/src/core/constraints/checkers/no-completion-without-verification.ts +16 -1
- package/src/core/constraints/checkers/no-hardcoded-credentials.ts +0 -5
- package/src/core/constraints/checkers/templated/file-exists.ts +1 -1
- package/src/core/constraints/checkers/templated/glob.ts +3 -36
- package/src/core/constraints/construction-sites.ts +95 -0
- package/src/core/constraints/doc-freshness/runner.ts +4 -1
- package/src/core/constraints/index.ts +0 -4
- package/src/core/constraints/meta.ts +40 -0
- package/src/core/constraints/pack-proposal.ts +179 -0
- package/src/core/constraints/usage-report.ts +3 -1
- package/src/core/effective-constraints.ts +6 -6
- package/src/core/index.ts +0 -15
- package/src/core/validators/__tests__/command-success-output.test.ts +56 -0
- package/src/core/validators/check-handlers/command.ts +44 -4
- package/src/gates/CONTEXT.md +20 -13
- package/src/gates/__tests__/acceptance-types-single-source.test.ts +7 -6
- package/src/gates/__tests__/acceptance.test.ts +3 -5
- package/src/gates/__tests__/command.test.ts +1 -13
- package/src/gates/__tests__/decision.test.ts +35 -0
- package/src/gates/checker-gate.ts +2 -1
- package/src/gates/command.ts +4 -38
- package/src/gates/definitions.ts +2 -2
- package/src/gates/index.ts +8 -95
- package/src/gates/registry.ts +1 -1
- package/src/gates/types.ts +11 -3
- package/src/hooks/CONTEXT.md +1 -1
- package/src/index.ts +50 -95
- package/src/knowledge/CONTEXT.md +6 -4
- package/src/knowledge/__tests__/token-estimate.test.ts +54 -0
- package/src/knowledge/index.ts +1 -3
- package/src/knowledge/query.ts +13 -14
- package/src/knowledge/token-estimate.ts +27 -0
- package/src/monitoring/CONTEXT.md +6 -8
- package/src/monitoring/__tests__/prune-trace-logs.test.ts +76 -0
- package/src/monitoring/__tests__/traces.test.ts +1 -17
- package/src/monitoring/analyzer-base.ts +0 -18
- package/src/monitoring/index.ts +2 -7
- package/src/monitoring/trace-analyzer.ts +0 -8
- package/src/monitoring/traces.ts +51 -51
- package/src/pretool-use-hook.ts +2 -2
- package/src/release/CONTEXT.md +1 -1
- package/src/release/__tests__/integrity.test.ts +3 -5
- package/src/release/integrity.ts +0 -2
- package/src/test-setup/jsonl-fake-fs.ts +1 -1
- package/src/utils/__tests__/glob-match.test.ts +52 -0
- package/src/utils/__tests__/jsonl-skip-disposition.test.ts +0 -1
- package/src/utils/__tests__/yaml-edit.test.ts +62 -0
- package/src/utils/glob-match.ts +41 -0
- package/src/utils/jsonl.ts +1 -1
- package/src/utils/yaml-edit.ts +67 -0
- package/dist/context/token-budget.d.ts +0 -115
- package/dist/context/token-budget.d.ts.map +0 -1
- package/dist/context/token-budget.js +0 -200
- package/dist/context/token-budget.js.map +0 -1
- package/dist/gates/runner.d.ts +0 -30
- package/dist/gates/runner.d.ts.map +0 -1
- package/dist/gates/runner.js +0 -38
- package/dist/gates/runner.js.map +0 -1
- package/dist/knowledge/primitives/code-structure.d.ts +0 -37
- package/dist/knowledge/primitives/code-structure.d.ts.map +0 -1
- package/dist/knowledge/primitives/code-structure.js +0 -185
- package/dist/knowledge/primitives/code-structure.js.map +0 -1
- package/dist/monitoring/context-tracker.d.ts +0 -38
- package/dist/monitoring/context-tracker.d.ts.map +0 -1
- package/dist/monitoring/context-tracker.js +0 -153
- package/dist/monitoring/context-tracker.js.map +0 -1
- package/dist/tools/definitions/core/code/fingerprint.sh +0 -273
- package/dist/tools/definitions/core/code/fingerprint.yml +0 -72
- package/dist/tools/definitions/core/code/parse.yml +0 -68
- package/dist/tools/definitions/core/code/register-language.sh +0 -475
- package/dist/tools/definitions/core/code/register-language.yml +0 -74
- package/dist/tools/definitions/core/docker/build.yml +0 -73
- package/dist/tools/definitions/core/docker/run.yml +0 -81
- package/dist/tools/definitions/core/file/copy.yml +0 -88
- package/dist/tools/definitions/core/file/read.yml +0 -69
- package/dist/tools/definitions/core/file/write.yml +0 -75
- package/dist/tools/definitions/core/git/branch.yml +0 -61
- package/dist/tools/definitions/core/git/cleanup-worktree.yml +0 -50
- package/dist/tools/definitions/core/git/clone.yml +0 -69
- package/dist/tools/definitions/core/git/commit.yml +0 -65
- package/dist/tools/definitions/core/git/push.yml +0 -79
- package/dist/tools/definitions/core/git/worktree.yml +0 -96
- package/dist/tools/definitions/core/notification/notify.sh +0 -152
- package/dist/tools/definitions/core/notification/notify.yml +0 -59
- package/dist/tools/definitions/core/npm/build.yml +0 -75
- package/dist/tools/definitions/core/npm/install.yml +0 -58
- package/dist/tools/definitions/core/npm/test.yml +0 -75
- package/dist/tools/definitions/core/validation/check-reuse.yml +0 -170
- package/dist/tools/definitions/core/validation/validate-handlers.yml +0 -118
- package/dist/tools/definitions/core/validation/validate-readme-stats.yml +0 -155
- package/dist/tools/definitions/core/validation/validate-yaml-syntax.yml +0 -134
- package/dist/tools/definitions/ext/browser/browser-automate.sh +0 -255
- package/dist/tools/definitions/ext/browser/browser-automate.yml +0 -166
- package/dist/tools/definitions/ext/browser/browser-close.sh +0 -104
- package/dist/tools/definitions/ext/browser/browser-close.yml +0 -54
- package/dist/tools/definitions/ext/browser/browser-mcp-debug.sh +0 -682
- package/dist/tools/definitions/ext/browser/browser-mcp-debug.yml +0 -167
- package/dist/tools/definitions/ext/browser/browser-start.sh +0 -101
- package/dist/tools/definitions/ext/browser/browser-start.yml +0 -61
- package/dist/tools/definitions/registry.json +0 -795
- package/dist/tools/definitions/std/README.md +0 -350
- package/dist/tools/definitions/std/analysis/analyze-codebase.yml +0 -72
- package/dist/tools/definitions/std/analysis/analyze-diff.yml +0 -182
- package/dist/tools/definitions/std/analysis/analyze-git-diff.yml +0 -70
- package/dist/tools/definitions/std/analysis/analyze-impact.yml +0 -78
- package/dist/tools/definitions/std/analysis/analyze-requirements.yml +0 -105
- package/dist/tools/definitions/std/analysis/brainstorm-options.yml +0 -106
- package/dist/tools/definitions/std/analysis/build-graph.yml +0 -154
- package/dist/tools/definitions/std/analysis/clarify-requirements.yml +0 -90
- package/dist/tools/definitions/std/analysis/detect-context.yml +0 -109
- package/dist/tools/definitions/std/analysis/detect-layers.yml +0 -125
- package/dist/tools/definitions/std/analysis/generate-tour.yml +0 -102
- package/dist/tools/definitions/std/analysis/search-enhance.yml +0 -105
- package/dist/tools/definitions/std/backlog/add.yml +0 -51
- package/dist/tools/definitions/std/backlog/decide.yml +0 -39
- package/dist/tools/definitions/std/backlog/github-sync.yml +0 -161
- package/dist/tools/definitions/std/backlog/list.yml +0 -53
- package/dist/tools/definitions/std/backlog/load.yml +0 -46
- package/dist/tools/definitions/std/backlog/resolve.yml +0 -37
- package/dist/tools/definitions/std/backlog/update.yml +0 -42
- package/dist/tools/definitions/std/bugfix/diagnose.yml +0 -68
- package/dist/tools/definitions/std/bugfix/fix.yml +0 -66
- package/dist/tools/definitions/std/bugfix/verify.yml +0 -69
- package/dist/tools/definitions/std/constraint/check-decomposition.yml +0 -103
- package/dist/tools/definitions/std/constraint/check-feature-list.yml +0 -77
- package/dist/tools/definitions/std/constraint/check-progress.yml +0 -97
- package/dist/tools/definitions/std/constraint/generate-report.yml +0 -147
- package/dist/tools/definitions/std/deploy/commit-push.yml +0 -33
- package/dist/tools/definitions/std/deploy/deploy-backend.yml +0 -37
- package/dist/tools/definitions/std/deploy/deploy-frontend.yml +0 -37
- package/dist/tools/definitions/std/deploy/rollback.yml +0 -148
- package/dist/tools/definitions/std/design/analyze-architecture-impact.yml +0 -113
- package/dist/tools/definitions/std/design/design-api.yml +0 -55
- package/dist/tools/definitions/std/design/design-architecture.yml +0 -97
- package/dist/tools/definitions/std/design/design-db.yml +0 -81
- package/dist/tools/definitions/std/design/generate-spec.yml +0 -182
- package/dist/tools/definitions/std/development/develop-api.yml +0 -85
- package/dist/tools/definitions/std/development/develop-backend.yml +0 -88
- package/dist/tools/definitions/std/development/develop-frontend.yml +0 -87
- package/dist/tools/definitions/std/development/develop-shared-types.yml +0 -74
- package/dist/tools/definitions/std/development/develop-task.yml +0 -122
- package/dist/tools/definitions/std/development/develop-tests.yml +0 -76
- package/dist/tools/definitions/std/development/execute-batch.yml +0 -152
- package/dist/tools/definitions/std/development/fix-issues.yml +0 -100
- package/dist/tools/definitions/std/development/implement-task.yml +0 -124
- package/dist/tools/definitions/std/development/review-fix-cycle.yml +0 -232
- package/dist/tools/definitions/std/evolution/implement.yml +0 -124
- package/dist/tools/definitions/std/evolution/prioritize.yml +0 -111
- package/dist/tools/definitions/std/evolution/report-gap.yml +0 -165
- package/dist/tools/definitions/std/file/read.yml +0 -21
- package/dist/tools/definitions/std/governance/aggregate-opinions.sh +0 -201
- package/dist/tools/definitions/std/governance/aggregate-opinions.yml +0 -78
- package/dist/tools/definitions/std/governance/audit-task.yml +0 -177
- package/dist/tools/definitions/std/governance/cast-vote.yml +0 -128
- package/dist/tools/definitions/std/governance/collect-issues.yml +0 -16
- package/dist/tools/definitions/std/governance/create-signed-document.yml +0 -23
- package/dist/tools/definitions/std/governance/create-voting-session.yml +0 -100
- package/dist/tools/definitions/std/governance/define-stance.sh +0 -243
- package/dist/tools/definitions/std/governance/define-stance.yml +0 -81
- package/dist/tools/definitions/std/governance/generate-review-report.yml +0 -23
- package/dist/tools/definitions/std/governance/impeach.yml +0 -178
- package/dist/tools/definitions/std/governance/multi-stance-review.yml +0 -153
- package/dist/tools/definitions/std/governance/prepare-artifact.yml +0 -20
- package/dist/tools/definitions/std/governance/review-spec-approval.yml +0 -262
- package/dist/tools/definitions/std/governance/rollback.yml +0 -185
- package/dist/tools/definitions/std/governance/stance-review.yml +0 -148
- package/dist/tools/definitions/std/governance/track-effect.yml +0 -198
- package/dist/tools/definitions/std/governance/vote-tally.yml +0 -143
- package/dist/tools/definitions/std/patch/execute.yml +0 -51
- package/dist/tools/definitions/std/planning/generate-tasks.yml +0 -36
- package/dist/tools/definitions/std/planning/load-tasks.yml +0 -44
- package/dist/tools/definitions/std/planning/split-batch.yml +0 -480
- package/dist/tools/definitions/std/planning/split-tasks.yml +0 -358
- package/dist/tools/definitions/std/planning/update-tasks.yml +0 -51
- package/dist/tools/definitions/std/planning/validate-tasks.yml +0 -46
- package/dist/tools/definitions/std/project/decide-next-workflow.yml +0 -38
- package/dist/tools/definitions/std/project/load-state.yml +0 -31
- package/dist/tools/definitions/std/project/save-state.yml +0 -32
- package/dist/tools/definitions/std/quality/check-quality.yml +0 -241
- package/dist/tools/definitions/std/quality/debug-systematic.yml +0 -163
- package/dist/tools/definitions/std/quality/handle-feedback.yml +0 -108
- package/dist/tools/definitions/std/quality/review-code.yml +0 -128
- package/dist/tools/definitions/std/quality/review-spec.yml +0 -140
- package/dist/tools/definitions/std/quality/review-task.yml +0 -190
- package/dist/tools/definitions/std/quality/run-tests.yml +0 -80
- package/dist/tools/definitions/std/quick/analyze.yml +0 -56
- package/dist/tools/definitions/std/quick/implement.yml +0 -67
- package/dist/tools/definitions/std/quick/verify.yml +0 -71
- package/dist/tools/definitions/std/verification/verify_completion.yml +0 -113
- package/dist/tools/definitions/std/verification/wait-condition.yml +0 -107
- package/dist/tools/index.d.ts +0 -5
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -10
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/paths.d.ts +0 -9
- package/dist/tools/paths.d.ts.map +0 -1
- package/dist/tools/paths.js +0 -51
- package/dist/tools/paths.js.map +0 -1
- package/src/__tests__/token-budget.test.ts +0 -252
- package/src/context/__tests__/token-budget.test.ts +0 -258
- package/src/context/token-budget.ts +0 -222
- package/src/gates/__tests__/runner.test.ts +0 -81
- package/src/gates/runner.ts +0 -57
- package/src/knowledge/primitives/__tests__/code-structure-degrade.test.ts +0 -24
- package/src/knowledge/primitives/__tests__/code-structure.test.ts +0 -120
- package/src/knowledge/primitives/code-structure.ts +0 -185
- package/src/monitoring/__tests__/context-tracker.test.ts +0 -180
- package/src/monitoring/context-tracker.ts +0 -136
- package/src/tools/CONTEXT.md +0 -24
- package/src/tools/__tests__/registry.test.ts +0 -221
- package/src/tools/definitions/core/code/fingerprint.sh +0 -273
- package/src/tools/definitions/core/code/fingerprint.yml +0 -72
- package/src/tools/definitions/core/code/parse.yml +0 -68
- package/src/tools/definitions/core/code/register-language.sh +0 -475
- package/src/tools/definitions/core/code/register-language.yml +0 -74
- package/src/tools/definitions/core/docker/build.yml +0 -73
- package/src/tools/definitions/core/docker/run.yml +0 -81
- package/src/tools/definitions/core/file/copy.yml +0 -88
- package/src/tools/definitions/core/file/read.yml +0 -69
- package/src/tools/definitions/core/file/write.yml +0 -75
- package/src/tools/definitions/core/git/branch.yml +0 -61
- package/src/tools/definitions/core/git/cleanup-worktree.yml +0 -50
- package/src/tools/definitions/core/git/clone.yml +0 -69
- package/src/tools/definitions/core/git/commit.yml +0 -65
- package/src/tools/definitions/core/git/push.yml +0 -79
- package/src/tools/definitions/core/git/worktree.yml +0 -96
- package/src/tools/definitions/core/notification/notify.sh +0 -152
- package/src/tools/definitions/core/notification/notify.yml +0 -59
- package/src/tools/definitions/core/npm/build.yml +0 -75
- package/src/tools/definitions/core/npm/install.yml +0 -58
- package/src/tools/definitions/core/npm/test.yml +0 -75
- package/src/tools/definitions/core/validation/check-reuse.yml +0 -170
- package/src/tools/definitions/core/validation/validate-handlers.yml +0 -118
- package/src/tools/definitions/core/validation/validate-readme-stats.yml +0 -155
- package/src/tools/definitions/core/validation/validate-yaml-syntax.yml +0 -134
- package/src/tools/definitions/ext/browser/browser-automate.sh +0 -255
- package/src/tools/definitions/ext/browser/browser-automate.yml +0 -166
- package/src/tools/definitions/ext/browser/browser-close.sh +0 -104
- package/src/tools/definitions/ext/browser/browser-close.yml +0 -54
- package/src/tools/definitions/ext/browser/browser-mcp-debug.sh +0 -682
- package/src/tools/definitions/ext/browser/browser-mcp-debug.yml +0 -167
- package/src/tools/definitions/ext/browser/browser-start.sh +0 -101
- package/src/tools/definitions/ext/browser/browser-start.yml +0 -61
- package/src/tools/definitions/registry.json +0 -795
- package/src/tools/definitions/std/README.md +0 -350
- package/src/tools/definitions/std/analysis/analyze-codebase.yml +0 -72
- package/src/tools/definitions/std/analysis/analyze-diff.yml +0 -182
- package/src/tools/definitions/std/analysis/analyze-git-diff.yml +0 -70
- package/src/tools/definitions/std/analysis/analyze-impact.yml +0 -78
- package/src/tools/definitions/std/analysis/analyze-requirements.yml +0 -105
- package/src/tools/definitions/std/analysis/brainstorm-options.yml +0 -106
- package/src/tools/definitions/std/analysis/build-graph.yml +0 -154
- package/src/tools/definitions/std/analysis/clarify-requirements.yml +0 -90
- package/src/tools/definitions/std/analysis/detect-context.yml +0 -109
- package/src/tools/definitions/std/analysis/detect-layers.yml +0 -125
- package/src/tools/definitions/std/analysis/generate-tour.yml +0 -102
- package/src/tools/definitions/std/analysis/search-enhance.yml +0 -105
- package/src/tools/definitions/std/backlog/add.yml +0 -51
- package/src/tools/definitions/std/backlog/decide.yml +0 -39
- package/src/tools/definitions/std/backlog/github-sync.yml +0 -161
- package/src/tools/definitions/std/backlog/list.yml +0 -53
- package/src/tools/definitions/std/backlog/load.yml +0 -46
- package/src/tools/definitions/std/backlog/resolve.yml +0 -37
- package/src/tools/definitions/std/backlog/update.yml +0 -42
- package/src/tools/definitions/std/bugfix/diagnose.yml +0 -68
- package/src/tools/definitions/std/bugfix/fix.yml +0 -66
- package/src/tools/definitions/std/bugfix/verify.yml +0 -69
- package/src/tools/definitions/std/constraint/check-decomposition.yml +0 -103
- package/src/tools/definitions/std/constraint/check-feature-list.yml +0 -77
- package/src/tools/definitions/std/constraint/check-progress.yml +0 -97
- package/src/tools/definitions/std/constraint/generate-report.yml +0 -147
- package/src/tools/definitions/std/deploy/commit-push.yml +0 -33
- package/src/tools/definitions/std/deploy/deploy-backend.yml +0 -37
- package/src/tools/definitions/std/deploy/deploy-frontend.yml +0 -37
- package/src/tools/definitions/std/deploy/rollback.yml +0 -148
- package/src/tools/definitions/std/design/analyze-architecture-impact.yml +0 -113
- package/src/tools/definitions/std/design/design-api.yml +0 -55
- package/src/tools/definitions/std/design/design-architecture.yml +0 -97
- package/src/tools/definitions/std/design/design-db.yml +0 -81
- package/src/tools/definitions/std/design/generate-spec.yml +0 -182
- package/src/tools/definitions/std/development/develop-api.yml +0 -85
- package/src/tools/definitions/std/development/develop-backend.yml +0 -88
- package/src/tools/definitions/std/development/develop-frontend.yml +0 -87
- package/src/tools/definitions/std/development/develop-shared-types.yml +0 -74
- package/src/tools/definitions/std/development/develop-task.yml +0 -122
- package/src/tools/definitions/std/development/develop-tests.yml +0 -76
- package/src/tools/definitions/std/development/execute-batch.yml +0 -152
- package/src/tools/definitions/std/development/fix-issues.yml +0 -100
- package/src/tools/definitions/std/development/implement-task.yml +0 -124
- package/src/tools/definitions/std/development/review-fix-cycle.yml +0 -232
- package/src/tools/definitions/std/evolution/implement.yml +0 -124
- package/src/tools/definitions/std/evolution/prioritize.yml +0 -111
- package/src/tools/definitions/std/evolution/report-gap.yml +0 -165
- package/src/tools/definitions/std/file/read.yml +0 -21
- package/src/tools/definitions/std/governance/aggregate-opinions.sh +0 -201
- package/src/tools/definitions/std/governance/aggregate-opinions.yml +0 -78
- package/src/tools/definitions/std/governance/audit-task.yml +0 -177
- package/src/tools/definitions/std/governance/cast-vote.yml +0 -128
- package/src/tools/definitions/std/governance/collect-issues.yml +0 -16
- package/src/tools/definitions/std/governance/create-signed-document.yml +0 -23
- package/src/tools/definitions/std/governance/create-voting-session.yml +0 -100
- package/src/tools/definitions/std/governance/define-stance.sh +0 -243
- package/src/tools/definitions/std/governance/define-stance.yml +0 -81
- package/src/tools/definitions/std/governance/generate-review-report.yml +0 -23
- package/src/tools/definitions/std/governance/impeach.yml +0 -178
- package/src/tools/definitions/std/governance/multi-stance-review.yml +0 -153
- package/src/tools/definitions/std/governance/prepare-artifact.yml +0 -20
- package/src/tools/definitions/std/governance/review-spec-approval.yml +0 -262
- package/src/tools/definitions/std/governance/rollback.yml +0 -185
- package/src/tools/definitions/std/governance/stance-review.yml +0 -148
- package/src/tools/definitions/std/governance/track-effect.yml +0 -198
- package/src/tools/definitions/std/governance/vote-tally.yml +0 -143
- package/src/tools/definitions/std/patch/execute.yml +0 -51
- package/src/tools/definitions/std/planning/generate-tasks.yml +0 -36
- package/src/tools/definitions/std/planning/load-tasks.yml +0 -44
- package/src/tools/definitions/std/planning/split-batch.yml +0 -480
- package/src/tools/definitions/std/planning/split-tasks.yml +0 -358
- package/src/tools/definitions/std/planning/update-tasks.yml +0 -51
- package/src/tools/definitions/std/planning/validate-tasks.yml +0 -46
- package/src/tools/definitions/std/project/decide-next-workflow.yml +0 -38
- package/src/tools/definitions/std/project/load-state.yml +0 -31
- package/src/tools/definitions/std/project/save-state.yml +0 -32
- package/src/tools/definitions/std/quality/check-quality.yml +0 -241
- package/src/tools/definitions/std/quality/debug-systematic.yml +0 -163
- package/src/tools/definitions/std/quality/handle-feedback.yml +0 -108
- package/src/tools/definitions/std/quality/review-code.yml +0 -128
- package/src/tools/definitions/std/quality/review-spec.yml +0 -140
- package/src/tools/definitions/std/quality/review-task.yml +0 -190
- package/src/tools/definitions/std/quality/run-tests.yml +0 -80
- package/src/tools/definitions/std/quick/analyze.yml +0 -56
- package/src/tools/definitions/std/quick/implement.yml +0 -67
- package/src/tools/definitions/std/quick/verify.yml +0 -71
- package/src/tools/definitions/std/verification/verify_completion.yml +0 -113
- package/src/tools/definitions/std/verification/wait-condition.yml +0 -107
- package/src/tools/index.ts +0 -5
- package/src/tools/paths.ts +0 -15
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 约束变更面库函数(harness#198):retire / reactivate / disable
|
|
3
|
+
*
|
|
4
|
+
* 三个执行函数自 cli 命令模块原样搬入 core 并上公共 barrel——签名(位置参数)与
|
|
5
|
+
* 返回的状态联合类型逐字不变,CLI 命令改为调用本模块的薄壳。下游消费方
|
|
6
|
+
* 不再直读直写 `.harness/config.yml`。
|
|
7
|
+
*
|
|
8
|
+
* 语义(与搬家前一致,详见各函数):
|
|
9
|
+
* - retire:永久退役——config.yml `enabled:false` + `retired` 墓碑 + 知识沉淀;
|
|
10
|
+
* 裸 disabled 条目会被接管补墓碑+沉淀(ADR-0032 决策 6.6)
|
|
11
|
+
* - reactivate:撤销退休——删墓碑段回生效集 + 写复活沉淀(不改历史,ADR-0032 决策 6.5)
|
|
12
|
+
* - disable:裸禁用——`enabled:false` 无墓碑无沉淀;retired 墓碑不动
|
|
13
|
+
*
|
|
14
|
+
* 知识沉淀写口是**注入 seam**(harness#88 分层纪律:core 不 value-import 知识层):
|
|
15
|
+
* retire/reactivate 经 `options.openKnowledgeStore` 工厂取写口,缺省(未注入)只落
|
|
16
|
+
* config.yml、不写沉淀——与 ConstraintChecker 的 unwired 实例同一纪律,组合根
|
|
17
|
+
* (CLI 命令、下游编排侧)负责接线。
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import * as fs from 'fs';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
import { getConstraint } from './constraints/definitions';
|
|
23
|
+
import { ProjectConfigLoader } from './project-config-loader';
|
|
24
|
+
import { isRetiredTombstone } from './retired-constraints';
|
|
25
|
+
import { loadAppConstraints } from './app-constraints-loader';
|
|
26
|
+
import { getEffectiveConstraints } from './effective-constraints';
|
|
27
|
+
import type { RunTarget } from './constraints/run-env';
|
|
28
|
+
import type { Constraint } from '../types/constraint';
|
|
29
|
+
import type { KnowledgeEntry } from '../knowledge/types';
|
|
30
|
+
import type { CommandIO } from '../cli/command-contract';
|
|
31
|
+
import { setYamlEntry, removeYamlEntry } from '../utils/yaml-edit';
|
|
32
|
+
import { collectUsageByConstraint, readProjectTraces } from './constraints/usage-report';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 知识沉淀写口(注入 seam):`FileKnowledgeStore` 结构化满足。
|
|
36
|
+
* 经工厂注入(`openKnowledgeStore`)而非实例——写口只在真正落沉淀时开启,
|
|
37
|
+
* unknown_id / already_retired 等路径零副作用。
|
|
38
|
+
*/
|
|
39
|
+
export interface LifecycleKnowledgeSink {
|
|
40
|
+
save(entry: KnowledgeEntry): void;
|
|
41
|
+
getBaseDir(): string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface RetireExecuteOptions {
|
|
45
|
+
/** 退役原因(可空) */
|
|
46
|
+
reason?: string;
|
|
47
|
+
/** 注入当前时间(测试用) */
|
|
48
|
+
now?: Date;
|
|
49
|
+
/**
|
|
50
|
+
* 历史签名保留(harness#198 搬家前是知识库路径解析的透参,解析早已不消费它);
|
|
51
|
+
* 知识写口改由 `openKnowledgeStore` 注入,本字段在 core 内不被读取
|
|
52
|
+
*/
|
|
53
|
+
io?: CommandIO;
|
|
54
|
+
/**
|
|
55
|
+
* 知识沉淀写口工厂(harness#88 注入纪律)。注入 = 退休时写 `constraint-retired-<id>`
|
|
56
|
+
* 沉淀(consumptionMode: 'signal');缺省 = 只落 config.yml 墓碑,不写沉淀
|
|
57
|
+
*/
|
|
58
|
+
openKnowledgeStore?: () => LifecycleKnowledgeSink;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type RetireStatus = 'retired' | 'already_retired' | 'unknown_id';
|
|
62
|
+
|
|
63
|
+
export interface RetireResult {
|
|
64
|
+
id: string;
|
|
65
|
+
status: RetireStatus;
|
|
66
|
+
/** 是否 severity='error'(交互模式据此追加确认) */
|
|
67
|
+
isError: boolean;
|
|
68
|
+
stats: { total: number; fail: number; failRate: number };
|
|
69
|
+
/** KnowledgeStore 条目 id(status='retired' 且注入了写口时存在) */
|
|
70
|
+
knowledgeEntryId?: string;
|
|
71
|
+
/** 退役记录实际落盘的知识库根(status='retired' 且注入了写口时存在,harness#177) */
|
|
72
|
+
knowledgeBaseDir?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface RetireTargetInfo {
|
|
76
|
+
severity: Constraint['severity'];
|
|
77
|
+
description?: string;
|
|
78
|
+
rule?: string;
|
|
79
|
+
message?: string;
|
|
80
|
+
/** 约束来源(ADR-0033):app 层退休沉淀条目 tags 加 source:app */
|
|
81
|
+
source?: Constraint['source'];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 查找约束定义(内置 definitions + 应用层 constraints.yml,ADR-0033)
|
|
86
|
+
*
|
|
87
|
+
* loader 由调用方给(一次退役一份观察面,见 retireConstraint):本函数只读它的装载结果,
|
|
88
|
+
* 不再自造 ProjectConfigLoader。应用层查找经 target 参数(项目根路径或观察面),
|
|
89
|
+
* 不传 = 只查内置(历史行为)。
|
|
90
|
+
*/
|
|
91
|
+
export function findRetireTarget(id: string, target?: RunTarget): RetireTargetInfo | undefined {
|
|
92
|
+
const builtIn = getConstraint(id);
|
|
93
|
+
if (builtIn) {
|
|
94
|
+
return {
|
|
95
|
+
severity: builtIn.severity,
|
|
96
|
+
description: builtIn.description,
|
|
97
|
+
rule: builtIn.rule,
|
|
98
|
+
message: builtIn.message,
|
|
99
|
+
source: 'builtin',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (target !== undefined) {
|
|
103
|
+
const app = loadAppConstraints(target).find(c => c.id === id);
|
|
104
|
+
if (app) {
|
|
105
|
+
return {
|
|
106
|
+
severity: app.severity,
|
|
107
|
+
description: app.description,
|
|
108
|
+
rule: app.rule,
|
|
109
|
+
message: app.message,
|
|
110
|
+
source: 'app',
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 写知识沉淀条目(consumptionMode: 'signal')
|
|
119
|
+
*
|
|
120
|
+
* 写口由调用方注入(harness#88);条目 id 由本函数按 `<prefix>-<id>` 构造并返回,
|
|
121
|
+
* 落盘根取写口自报的 baseDir。
|
|
122
|
+
*/
|
|
123
|
+
function saveLifecycleKnowledge(
|
|
124
|
+
sink: LifecycleKnowledgeSink,
|
|
125
|
+
entryId: string,
|
|
126
|
+
title: string,
|
|
127
|
+
contentLines: (string | undefined)[],
|
|
128
|
+
tags: string[],
|
|
129
|
+
iso: string
|
|
130
|
+
): { entryId: string; baseDir: string } {
|
|
131
|
+
const entry: KnowledgeEntry = {
|
|
132
|
+
id: entryId,
|
|
133
|
+
type: 'decision',
|
|
134
|
+
title,
|
|
135
|
+
content: contentLines.filter((l): l is string => l !== undefined).join('\n'),
|
|
136
|
+
maturity: 'verified',
|
|
137
|
+
layer: 'project',
|
|
138
|
+
created: iso,
|
|
139
|
+
lastReferenced: iso,
|
|
140
|
+
contributors: [],
|
|
141
|
+
projects: [],
|
|
142
|
+
tags,
|
|
143
|
+
applicablePhases: [],
|
|
144
|
+
sourceReferences: [{ timestamp: iso }],
|
|
145
|
+
referencedBy: [],
|
|
146
|
+
executionResults: [],
|
|
147
|
+
consumptionMode: 'signal',
|
|
148
|
+
origin: 'human',
|
|
149
|
+
};
|
|
150
|
+
sink.save(entry);
|
|
151
|
+
return { entryId, baseDir: sink.getBaseDir() };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** 退休沉淀条目(约束规则原文 + 退役原因 + 历史统计) */
|
|
155
|
+
function saveRetireKnowledge(
|
|
156
|
+
sink: LifecycleKnowledgeSink,
|
|
157
|
+
id: string,
|
|
158
|
+
target: RetireTargetInfo,
|
|
159
|
+
reason: string,
|
|
160
|
+
stats: { total: number; fail: number; failRate: number },
|
|
161
|
+
iso: string
|
|
162
|
+
): { entryId: string; baseDir: string } {
|
|
163
|
+
return saveLifecycleKnowledge(
|
|
164
|
+
sink,
|
|
165
|
+
`constraint-retired-${id}`,
|
|
166
|
+
`约束退役:${id}`,
|
|
167
|
+
[
|
|
168
|
+
`# 约束退役:${id}`,
|
|
169
|
+
'',
|
|
170
|
+
'## 规则原文',
|
|
171
|
+
'',
|
|
172
|
+
target.description ? `description: ${target.description}` : undefined,
|
|
173
|
+
target.rule ? `rule: ${target.rule}` : undefined,
|
|
174
|
+
target.message ? `message: ${target.message}` : undefined,
|
|
175
|
+
'',
|
|
176
|
+
'## 退役原因',
|
|
177
|
+
'',
|
|
178
|
+
reason || '(未填写)',
|
|
179
|
+
'',
|
|
180
|
+
'## 历史统计',
|
|
181
|
+
'',
|
|
182
|
+
`- total: ${stats.total}`,
|
|
183
|
+
`- fail: ${stats.fail}`,
|
|
184
|
+
`- failRate: ${Math.round(stats.failRate * 100)}%`,
|
|
185
|
+
'',
|
|
186
|
+
`退役日期: ${iso}`,
|
|
187
|
+
],
|
|
188
|
+
// ADR-0033:应用层退休沉淀带 source:app 标签(内置条目不加,历史形状不动)
|
|
189
|
+
[
|
|
190
|
+
'constraint-retired',
|
|
191
|
+
`constraint:${id}`,
|
|
192
|
+
`severity:${target.severity}`,
|
|
193
|
+
...(target.source === 'app' ? ['source:app'] : []),
|
|
194
|
+
],
|
|
195
|
+
iso
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** 复活沉淀条目(不改历史:旧 `constraint-retired-<id>` 沉淀原样保留,复活原因单独成条) */
|
|
200
|
+
function saveReactivateKnowledge(
|
|
201
|
+
sink: LifecycleKnowledgeSink,
|
|
202
|
+
id: string,
|
|
203
|
+
target: RetireTargetInfo,
|
|
204
|
+
reason: string,
|
|
205
|
+
iso: string
|
|
206
|
+
): { entryId: string; baseDir: string } {
|
|
207
|
+
return saveLifecycleKnowledge(
|
|
208
|
+
sink,
|
|
209
|
+
`constraint-reactivated-${id}`,
|
|
210
|
+
`约束复活:${id}`,
|
|
211
|
+
[
|
|
212
|
+
`# 约束复活:${id}`,
|
|
213
|
+
'',
|
|
214
|
+
`原退役沉淀:constraint-retired-${id}(不改历史,原条目保留)`,
|
|
215
|
+
'',
|
|
216
|
+
'## 规则原文',
|
|
217
|
+
'',
|
|
218
|
+
target.description ? `description: ${target.description}` : undefined,
|
|
219
|
+
target.rule ? `rule: ${target.rule}` : undefined,
|
|
220
|
+
target.message ? `message: ${target.message}` : undefined,
|
|
221
|
+
'',
|
|
222
|
+
'## 复活原因',
|
|
223
|
+
'',
|
|
224
|
+
reason || '(未填写)',
|
|
225
|
+
'',
|
|
226
|
+
`复活日期: ${iso}`,
|
|
227
|
+
],
|
|
228
|
+
['constraint-reactivated', `constraint:${id}`, `severity:${target.severity}`],
|
|
229
|
+
iso
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 执行单条约束退役(纯执行逻辑,无交互)
|
|
235
|
+
*
|
|
236
|
+
* 不存在的 id / 已退役的 id 通过 status 返回,由调用方提示。
|
|
237
|
+
* 知识沉淀只在注入 `openKnowledgeStore` 时落盘(见模块头注入纪律)。
|
|
238
|
+
*/
|
|
239
|
+
export function retireConstraint(
|
|
240
|
+
projectRoot: string,
|
|
241
|
+
id: string,
|
|
242
|
+
options: RetireExecuteOptions = {}
|
|
243
|
+
): RetireResult {
|
|
244
|
+
const now = options.now ?? new Date();
|
|
245
|
+
const iso = now.toISOString();
|
|
246
|
+
const reason = options.reason ?? '';
|
|
247
|
+
|
|
248
|
+
// 一次退役一份观察面(ADR-0023 决策 2):定义查找与 already_retired 判定共用这一份装载结果。
|
|
249
|
+
const loader = new ProjectConfigLoader(projectRoot);
|
|
250
|
+
loader.load();
|
|
251
|
+
|
|
252
|
+
const target = findRetireTarget(id, projectRoot);
|
|
253
|
+
const emptyStats = { total: 0, fail: 0, failRate: 0 };
|
|
254
|
+
if (!target) {
|
|
255
|
+
return { id, status: 'unknown_id', isError: false, stats: emptyStats };
|
|
256
|
+
}
|
|
257
|
+
const isError = target.severity === 'error';
|
|
258
|
+
|
|
259
|
+
// 已退役保护:只认 retired 墓碑(ADR-0032 决策 6.6,票 02 断点 6)——
|
|
260
|
+
// 裸 enabled:false 是"禁用"不是"退休",落到下面正常退休流程:覆写墓碑 + 补写沉淀,
|
|
261
|
+
// 不让一次裸 disable 吞掉 retire 的知识沉淀。判定谓词唯一实现 = isRetiredTombstone。
|
|
262
|
+
const existing = loader.getConfig().constraints?.[id] as { enabled?: boolean; retired?: unknown } | undefined;
|
|
263
|
+
if (isRetiredTombstone(existing)) {
|
|
264
|
+
return { id, status: 'already_retired', isError, stats: emptyStats };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// 历史统计(来自 traces.log)
|
|
268
|
+
// 计数去向:兼容包装 readProjectTraces() 丢计数(harness#100)——落盘的 retire stats 只计
|
|
269
|
+
// 合法记录,把坏行数写进 RetireResult.stats 属形状变更不在本票;本函数按契约「纯执行无交互」
|
|
270
|
+
// 不打印,告知由两条命令入口各自负责(runRetireInteractive 顶部 / constraintsRetire 的 --yes 分支)
|
|
271
|
+
const usage = collectUsageByConstraint(readProjectTraces(projectRoot)).get(id);
|
|
272
|
+
const evaluated = usage ? usage.total - usage.skip : 0;
|
|
273
|
+
const stats = {
|
|
274
|
+
total: usage?.total ?? 0,
|
|
275
|
+
fail: usage?.fail ?? 0,
|
|
276
|
+
failRate: evaluated > 0 ? (usage!.fail / evaluated) : 0,
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// 1. 落盘退役(config.yml enabled:false + retired 段,原文保留)
|
|
280
|
+
const retiredMeta = { at: iso, reason, stats };
|
|
281
|
+
setYamlEntry(
|
|
282
|
+
path.join(projectRoot, '.harness', 'config.yml'),
|
|
283
|
+
'config.yml',
|
|
284
|
+
'constraints',
|
|
285
|
+
id,
|
|
286
|
+
{ enabled: false, retired: retiredMeta }
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
// 2. 知识沉淀(注入 seam:缺省不写,见模块头)
|
|
290
|
+
if (!options.openKnowledgeStore) {
|
|
291
|
+
return { id, status: 'retired', isError, stats };
|
|
292
|
+
}
|
|
293
|
+
const { entryId: knowledgeEntryId, baseDir: knowledgeBaseDir } = saveRetireKnowledge(
|
|
294
|
+
options.openKnowledgeStore(),
|
|
295
|
+
id,
|
|
296
|
+
target,
|
|
297
|
+
reason,
|
|
298
|
+
stats,
|
|
299
|
+
iso
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
id,
|
|
304
|
+
status: 'retired',
|
|
305
|
+
isError,
|
|
306
|
+
stats,
|
|
307
|
+
knowledgeEntryId,
|
|
308
|
+
knowledgeBaseDir,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface ReactivateExecuteOptions {
|
|
313
|
+
/** 复活原因(可空) */
|
|
314
|
+
reason?: string;
|
|
315
|
+
/** 注入当前时间(测试用) */
|
|
316
|
+
now?: Date;
|
|
317
|
+
/** 历史签名保留(同 RetireExecuteOptions.io;core 内不被读取) */
|
|
318
|
+
io?: CommandIO;
|
|
319
|
+
/** 知识沉淀写口工厂(同 RetireExecuteOptions.openKnowledgeStore;缺省不写复活沉淀) */
|
|
320
|
+
openKnowledgeStore?: () => LifecycleKnowledgeSink;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export type ReactivateStatus = 'reactivated' | 'not_retired' | 'unknown_id';
|
|
324
|
+
|
|
325
|
+
export interface ReactivateResult {
|
|
326
|
+
id: string;
|
|
327
|
+
status: ReactivateStatus;
|
|
328
|
+
/** KnowledgeStore 条目 id(status='reactivated' 且注入了写口时存在) */
|
|
329
|
+
knowledgeEntryId?: string;
|
|
330
|
+
/** 复活记录实际落盘的知识库根(status='reactivated' 且注入了写口时存在) */
|
|
331
|
+
knowledgeBaseDir?: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* 执行单条约束复活(纯执行逻辑,无交互)
|
|
336
|
+
*
|
|
337
|
+
* 复活 = 撤销退休:删 config.yml `constraints.<id>` 墓碑段(约束回生效集),
|
|
338
|
+
* 注入写口时同时写 `constraint-reactivated-<id>` 新条目(不改历史)。
|
|
339
|
+
* 不存在的 id / 无 retired 墓碑的 id 通过 status 返回,由调用方提示。
|
|
340
|
+
*/
|
|
341
|
+
export function reactivateConstraint(
|
|
342
|
+
projectRoot: string,
|
|
343
|
+
id: string,
|
|
344
|
+
options: ReactivateExecuteOptions = {}
|
|
345
|
+
): ReactivateResult {
|
|
346
|
+
const now = options.now ?? new Date();
|
|
347
|
+
const iso = now.toISOString();
|
|
348
|
+
|
|
349
|
+
const target = findRetireTarget(id, projectRoot);
|
|
350
|
+
if (!target) {
|
|
351
|
+
return { id, status: 'unknown_id' };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// 只认 retired 墓碑:裸 disable 与未配置一律 not_retired(与 retire 的幂等口径对偶,
|
|
355
|
+
// 判定谓词唯一实现 = isRetiredTombstone)
|
|
356
|
+
const loader = new ProjectConfigLoader(projectRoot);
|
|
357
|
+
loader.load();
|
|
358
|
+
const existing = loader.getConfig().constraints?.[id] as { enabled?: boolean; retired?: unknown } | undefined;
|
|
359
|
+
if (!isRetiredTombstone(existing)) {
|
|
360
|
+
return { id, status: 'not_retired' };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// 1. 删 config.yml constraints.<id> 墓碑段(恢复 = 回生效集)
|
|
364
|
+
removeYamlEntry(path.join(projectRoot, '.harness', 'config.yml'), 'constraints', id);
|
|
365
|
+
|
|
366
|
+
// 2. 知识沉淀(注入 seam:缺省不写,见模块头)
|
|
367
|
+
if (!options.openKnowledgeStore) {
|
|
368
|
+
return { id, status: 'reactivated' };
|
|
369
|
+
}
|
|
370
|
+
const { entryId: knowledgeEntryId, baseDir: knowledgeBaseDir } = saveReactivateKnowledge(
|
|
371
|
+
options.openKnowledgeStore(),
|
|
372
|
+
id,
|
|
373
|
+
target,
|
|
374
|
+
options.reason ?? '',
|
|
375
|
+
iso
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
return { id, status: 'reactivated', knowledgeEntryId, knowledgeBaseDir };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export type DisableStatus =
|
|
382
|
+
| 'disabled'
|
|
383
|
+
| 'already_disabled'
|
|
384
|
+
| 'already_retired'
|
|
385
|
+
| 'unknown_id'
|
|
386
|
+
| 'verify_failed';
|
|
387
|
+
|
|
388
|
+
export interface DisableResult {
|
|
389
|
+
id: string;
|
|
390
|
+
status: DisableStatus;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* 执行单条约束裸禁用(纯执行逻辑,无交互)
|
|
395
|
+
*
|
|
396
|
+
* 裸禁用 = config.yml `constraints.<id>.enabled:false`,无 retired 墓碑、无知识沉淀
|
|
397
|
+
* (墓碑与沉淀是 retire 专有语义)。写后验证生效集已缩小,失败回滚备份。
|
|
398
|
+
* 不存在的 id / 已禁用 / 已退役的 id 通过 status 返回,由调用方提示。
|
|
399
|
+
*/
|
|
400
|
+
export function disableConstraint(projectRoot: string, id: string): DisableResult {
|
|
401
|
+
const target = findRetireTarget(id, projectRoot);
|
|
402
|
+
if (!target) {
|
|
403
|
+
return { id, status: 'unknown_id' };
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// 幂等口径(ADR-0032 决策 6.6):retired 墓碑优先判定——disable 不动墓碑不吞退休语义;
|
|
407
|
+
// 裸 enabled:false 即已禁用。判定谓词唯一实现 = isRetiredTombstone
|
|
408
|
+
const loader = new ProjectConfigLoader(projectRoot);
|
|
409
|
+
loader.load();
|
|
410
|
+
const existing = loader.getConfig().constraints?.[id] as { enabled?: boolean; retired?: unknown } | undefined;
|
|
411
|
+
if (isRetiredTombstone(existing)) {
|
|
412
|
+
return { id, status: 'already_retired' };
|
|
413
|
+
}
|
|
414
|
+
if (existing?.enabled === false) {
|
|
415
|
+
return { id, status: 'already_disabled' };
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// 1. 落盘裸禁用(config.yml enabled:false,无 retired 段;同文件其他条目不动)
|
|
419
|
+
const configPath = path.join(projectRoot, '.harness', 'config.yml');
|
|
420
|
+
const backup = fs.existsSync(configPath) ? fs.readFileSync(configPath, 'utf-8') : null;
|
|
421
|
+
setYamlEntry(configPath, 'config.yml', 'constraints', id, { enabled: false });
|
|
422
|
+
|
|
423
|
+
// 2. 写后验证:生效集必须已缩小(与下游 applier 同一纪律),失败回滚备份
|
|
424
|
+
try {
|
|
425
|
+
if (getEffectiveConstraints(projectRoot).some(c => c.id === id)) {
|
|
426
|
+
throw new Error('constraint still present in effective set after disable');
|
|
427
|
+
}
|
|
428
|
+
} catch {
|
|
429
|
+
if (backup !== null) fs.writeFileSync(configPath, backup, 'utf-8');
|
|
430
|
+
else fs.rmSync(configPath, { force: true });
|
|
431
|
+
return { id, status: 'verify_failed' };
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return { id, status: 'disabled' };
|
|
435
|
+
}
|
|
@@ -8,13 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { CheckCache } from '../check-cache';
|
|
11
|
-
import { CheckCache as PublicCheckCache } from '../../../index';
|
|
12
|
-
|
|
13
|
-
describe('公开导出(根 barrel)', () => {
|
|
14
|
-
test('CheckCache 经 src/index.ts 公开导出', () => {
|
|
15
|
-
expect(PublicCheckCache).toBe(CheckCache);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
11
|
|
|
19
12
|
describe('CheckCache', () => {
|
|
20
13
|
beforeEach(() => {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
|
|
10
10
|
import { ConstraintChecker } from '../checker';
|
|
11
|
+
import { collectConstraints as publicCollectConstraints } from '../../../index';
|
|
11
12
|
import type { ConstraintContext, ConstraintResult } from '../../../types/constraint';
|
|
12
13
|
import * as fs from 'fs';
|
|
13
14
|
import * as path from 'path';
|
|
@@ -95,3 +96,27 @@ describe('collectConstraints(收集模式,不抛)', () => {
|
|
|
95
96
|
expect(result.errors.every((r: ConstraintResult) => r.satisfied)).toBe(true);
|
|
96
97
|
});
|
|
97
98
|
});
|
|
99
|
+
|
|
100
|
+
describe('包根公共出口 collectConstraints(harness#194,不抛出口上公共面)', () => {
|
|
101
|
+
it('从包根可导入且为函数', () => {
|
|
102
|
+
expect(typeof publicCollectConstraints).toBe('function');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('error 级违规不抛:违规照进 errors、passed=false、全量跑完', async () => {
|
|
106
|
+
const result = await publicCollectConstraints({
|
|
107
|
+
...VIOLATING,
|
|
108
|
+
extraTriggers: ['test_creation'],
|
|
109
|
+
});
|
|
110
|
+
expect(result.passed).toBe(false);
|
|
111
|
+
const ids = result.errors.map((r: ConstraintResult) => r.id);
|
|
112
|
+
expect(ids).toContain('no_completion_without_verification');
|
|
113
|
+
expect(ids).toContain('no_test_simplification');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('options 签名与 checkConstraints 同形:onTrace 走 options 对象逐条回调', async () => {
|
|
117
|
+
const traced: ConstraintResult[] = [];
|
|
118
|
+
const result = await publicCollectConstraints(CLEAN, { onTrace: (r) => traced.push(r) });
|
|
119
|
+
expect(result.passed).toBe(true);
|
|
120
|
+
expect(traced.length).toBe(result.errors.length + result.warnings.length);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* construction-sites 判定纯函数测试(harness#202 / ADR-0039)
|
|
3
|
+
*
|
|
4
|
+
* 钉三件事:
|
|
5
|
+
* 1. 标记解析——`<!-- sync-docs:construction-sites X = N -->`(可选 `include: tests`),
|
|
6
|
+
* 无标记散文与畸形标记不判;
|
|
7
|
+
* 2. 计数口径——只数 `new X(`(含一层泛型实参)直构造,工厂封装调用不算;
|
|
8
|
+
* 3. 判定——期望数与采集数不符即漂移,点名类名/期望/实际。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
parseConstructionSiteMarkers,
|
|
13
|
+
tallyConstructionSites,
|
|
14
|
+
reconcileConstructionSites,
|
|
15
|
+
} from '../construction-sites';
|
|
16
|
+
|
|
17
|
+
describe('parseConstructionSiteMarkers', () => {
|
|
18
|
+
it('解析基本标记', () => {
|
|
19
|
+
const markers = parseConstructionSiteMarkers(
|
|
20
|
+
'# doc\n\n- 构造点一处\n<!-- sync-docs:construction-sites FileKnowledgeStore = 1 -->\n'
|
|
21
|
+
);
|
|
22
|
+
expect(markers).toEqual([{ className: 'FileKnowledgeStore', expected: 1, includeTests: false }]);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('解析 include: tests 选项', () => {
|
|
26
|
+
const markers = parseConstructionSiteMarkers(
|
|
27
|
+
'<!-- sync-docs:construction-sites Widget = 3 include: tests -->'
|
|
28
|
+
);
|
|
29
|
+
expect(markers).toEqual([{ className: 'Widget', expected: 3, includeTests: true }]);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('同一份文档可带多个标记', () => {
|
|
33
|
+
const markers = parseConstructionSiteMarkers(
|
|
34
|
+
[
|
|
35
|
+
'<!-- sync-docs:construction-sites Foo = 1 -->',
|
|
36
|
+
'散文',
|
|
37
|
+
'<!-- sync-docs:construction-sites Bar = 2 include: tests -->',
|
|
38
|
+
].join('\n')
|
|
39
|
+
);
|
|
40
|
+
expect(markers).toEqual([
|
|
41
|
+
{ className: 'Foo', expected: 1, includeTests: false },
|
|
42
|
+
{ className: 'Bar', expected: 2, includeTests: true },
|
|
43
|
+
]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('无标记的散文不判(含普通 HTML 注释)', () => {
|
|
47
|
+
expect(parseConstructionSiteMarkers('# doc\n\n- 仓内构造点两处\n<!-- 普通注释 -->\n')).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('畸形标记不判(缺数字 / 未知选项 / 缺类名)', () => {
|
|
51
|
+
expect(parseConstructionSiteMarkers('<!-- sync-docs:construction-sites Foo = -->')).toEqual([]);
|
|
52
|
+
expect(parseConstructionSiteMarkers('<!-- sync-docs:construction-sites Foo = 1 include: docs -->')).toEqual([]);
|
|
53
|
+
expect(parseConstructionSiteMarkers('<!-- sync-docs:construction-sites = 1 -->')).toEqual([]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('tallyConstructionSites', () => {
|
|
58
|
+
it('数 `new X(` 直构造出现次数', () => {
|
|
59
|
+
const tally = tallyConstructionSites(
|
|
60
|
+
'const a = new Widget();\nconst b = new Widget({ x: 1 });\n'
|
|
61
|
+
);
|
|
62
|
+
expect(tally.get('Widget')).toBe(2);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('一层泛型实参的构造也算(new Map<string, boolean>())', () => {
|
|
66
|
+
const tally = tallyConstructionSites('const m = new Map<string, boolean>();\n');
|
|
67
|
+
expect(tally.get('Map')).toBe(1);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('工厂封装调用不算构造点', () => {
|
|
71
|
+
const tally = tallyConstructionSites(
|
|
72
|
+
'const s = openKnowledgeStore({}, io);\nconst w = createWidget();\n'
|
|
73
|
+
);
|
|
74
|
+
expect(tally.size).toBe(0);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('标识符边界:new FooBar( 不算 Foo', () => {
|
|
78
|
+
const tally = tallyConstructionSites('const x = new FooBar();\n');
|
|
79
|
+
expect(tally.get('Foo')).toBeUndefined();
|
|
80
|
+
expect(tally.get('FooBar')).toBe(1);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('new 与类名间允许空白', () => {
|
|
84
|
+
const tally = tallyConstructionSites('const x = new Widget ();\n');
|
|
85
|
+
expect(tally.get('Widget')).toBe(1);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('多类名同文分别计数', () => {
|
|
89
|
+
const tally = tallyConstructionSites('new A(); new B(); new A();\n');
|
|
90
|
+
expect(tally.get('A')).toBe(2);
|
|
91
|
+
expect(tally.get('B')).toBe(1);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('reconcileConstructionSites', () => {
|
|
96
|
+
it('计数一致 → 无漂移', () => {
|
|
97
|
+
const { drift } = reconcileConstructionSites({
|
|
98
|
+
markers: [{ className: 'Widget', expected: 2, includeTests: false }],
|
|
99
|
+
countFor: () => 2,
|
|
100
|
+
});
|
|
101
|
+
expect(drift).toEqual([]);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('计数不符 → 漂移点名类名/期望/实际', () => {
|
|
105
|
+
const { drift } = reconcileConstructionSites({
|
|
106
|
+
markers: [{ className: 'Widget', expected: 2, includeTests: false }],
|
|
107
|
+
countFor: () => 5,
|
|
108
|
+
});
|
|
109
|
+
expect(drift).toEqual([{ className: 'Widget', expected: 2, actual: 5, includeTests: false }]);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('countFor 收到标记的 includeTests 口径', () => {
|
|
113
|
+
const seen: Array<[string, boolean]> = [];
|
|
114
|
+
reconcileConstructionSites({
|
|
115
|
+
markers: [
|
|
116
|
+
{ className: 'A', expected: 1, includeTests: false },
|
|
117
|
+
{ className: 'B', expected: 1, includeTests: true },
|
|
118
|
+
],
|
|
119
|
+
countFor: (className, includeTests) => {
|
|
120
|
+
seen.push([className, includeTests]);
|
|
121
|
+
return 1;
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
expect(seen).toEqual([
|
|
125
|
+
['A', false],
|
|
126
|
+
['B', true],
|
|
127
|
+
]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('多标记混合:只报不符的', () => {
|
|
131
|
+
const { drift } = reconcileConstructionSites({
|
|
132
|
+
markers: [
|
|
133
|
+
{ className: 'Ok', expected: 1, includeTests: false },
|
|
134
|
+
{ className: 'Bad', expected: 3, includeTests: false },
|
|
135
|
+
],
|
|
136
|
+
countFor: (className) => (className === 'Ok' ? 1 : 0),
|
|
137
|
+
});
|
|
138
|
+
expect(drift).toEqual([{ className: 'Bad', expected: 3, actual: 0, includeTests: false }]);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('空标记列表 → 零漂移且不碰 countFor', () => {
|
|
142
|
+
const countFor = jest.fn(() => 0);
|
|
143
|
+
const { drift } = reconcileConstructionSites({ markers: [], countFor });
|
|
144
|
+
expect(drift).toEqual([]);
|
|
145
|
+
expect(countFor).not.toHaveBeenCalled();
|
|
146
|
+
});
|
|
147
|
+
});
|