@dommaker/harness 1.9.0 → 1.11.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 +17 -0
- package/README.md +9 -12
- package/dist/cli/commands/check.d.ts +3 -3
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +41 -78
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/constraints-report.d.ts +2 -10
- package/dist/cli/commands/constraints-report.d.ts.map +1 -1
- package/dist/cli/commands/constraints-report.js +4 -57
- package/dist/cli/commands/constraints-report.js.map +1 -1
- package/dist/cli/commands/constraints-retire.d.ts +9 -23
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
- package/dist/cli/commands/constraints-retire.js +39 -121
- package/dist/cli/commands/constraints-retire.js.map +1 -1
- package/dist/cli/commands/constraints.d.ts +3 -8
- package/dist/cli/commands/constraints.d.ts.map +1 -1
- package/dist/cli/commands/constraints.js +8 -23
- package/dist/cli/commands/constraints.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js +7 -12
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/init.d.ts +0 -32
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +7 -149
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/report.d.ts.map +1 -1
- package/dist/cli/commands/report.js +14 -17
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/scaffold-templates.d.ts +1 -3
- package/dist/cli/commands/scaffold-templates.d.ts.map +1 -1
- package/dist/cli/commands/scaffold-templates.js +2 -53
- package/dist/cli/commands/scaffold-templates.js.map +1 -1
- package/dist/cli/commands/scaffold.d.ts +0 -2
- package/dist/cli/commands/scaffold.d.ts.map +1 -1
- package/dist/cli/commands/scaffold.js +0 -10
- package/dist/cli/commands/scaffold.js.map +1 -1
- package/dist/cli/commands/status.js +10 -10
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts +0 -2
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +4 -23
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +16 -4
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/checker.d.ts +15 -24
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +33 -72
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.d.ts +2 -1
- package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
- package/dist/core/constraints/checkers/governance-presence.js +4 -3
- package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
- package/dist/core/constraints/checkers/index.d.ts +1 -1
- package/dist/core/constraints/checkers/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/index.js +4 -8
- package/dist/core/constraints/checkers/index.js.map +1 -1
- package/dist/core/constraints/checkers/iron-flags.d.ts +3 -4
- package/dist/core/constraints/checkers/iron-flags.d.ts.map +1 -1
- package/dist/core/constraints/checkers/iron-flags.js +4 -5
- package/dist/core/constraints/checkers/iron-flags.js.map +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.js +1 -1
- package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +1 -1
- package/dist/core/constraints/checkers/types.js +1 -1
- package/dist/core/constraints/definitions/guidelines.d.ts +4 -4
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
- package/dist/core/constraints/definitions/guidelines.js +9 -25
- package/dist/core/constraints/definitions/guidelines.js.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.d.ts +4 -4
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.js +10 -81
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
- package/dist/core/constraints/definitions.d.ts +7 -9
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +13 -16
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/index.d.ts +2 -5
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +3 -13
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/injection-writer.d.ts +10 -38
- package/dist/core/constraints/injection-writer.d.ts.map +1 -1
- package/dist/core/constraints/injection-writer.js +17 -54
- package/dist/core/constraints/injection-writer.js.map +1 -1
- package/dist/core/constraints/run-env.d.ts +1 -10
- package/dist/core/constraints/run-env.d.ts.map +1 -1
- package/dist/core/constraints/run-env.js +1 -22
- package/dist/core/constraints/run-env.js.map +1 -1
- package/dist/core/constraints/usage-report.d.ts +6 -8
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +6 -11
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/effective-constraints.d.ts +12 -22
- package/dist/core/effective-constraints.d.ts.map +1 -1
- package/dist/core/effective-constraints.js +13 -30
- package/dist/core/effective-constraints.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -9
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +4 -42
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +16 -125
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/core/validators/passes-gate.d.ts +2 -2
- package/dist/core/validators/passes-gate.js +6 -6
- package/dist/core/validators/passes-gate.js.map +1 -1
- package/dist/index.d.ts +9 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -18
- package/dist/index.js.map +1 -1
- package/dist/knowledge/lint.d.ts +17 -0
- package/dist/knowledge/lint.d.ts.map +1 -1
- package/dist/knowledge/lint.js +52 -0
- package/dist/knowledge/lint.js.map +1 -1
- package/dist/knowledge/store.d.ts +7 -0
- package/dist/knowledge/store.d.ts.map +1 -1
- package/dist/knowledge/store.js +48 -13
- package/dist/knowledge/store.js.map +1 -1
- package/dist/knowledge/types.d.ts +5 -1
- package/dist/knowledge/types.d.ts.map +1 -1
- package/dist/knowledge/types.js +5 -1
- package/dist/knowledge/types.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +11 -12
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +4 -4
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +8 -8
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/presets/standard.d.ts +8 -10
- package/dist/presets/standard.d.ts.map +1 -1
- package/dist/presets/standard.js +10 -16
- package/dist/presets/standard.js.map +1 -1
- package/dist/types/constraint.d.ts +24 -35
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js +8 -7
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/passes-gate.d.ts +5 -5
- package/dist/types/passes-gate.d.ts.map +1 -1
- package/dist/types/project-config.d.ts +8 -66
- package/dist/types/project-config.d.ts.map +1 -1
- package/dist/types/project-config.js +3 -2
- package/dist/types/project-config.js.map +1 -1
- package/dist/types/trace.d.ts +8 -10
- package/dist/types/trace.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/CONTEXT.md +2 -2
- package/src/__tests__/checker-extra.test.ts +37 -61
- package/src/__tests__/checker.test.ts +10 -115
- package/src/__tests__/effective-constraints.test.ts +18 -83
- package/src/__tests__/iron-laws.test.ts +71 -90
- package/src/__tests__/passes-gate-check.test.ts +2 -2
- package/src/__tests__/project-config-loader-extra.test.ts +22 -123
- package/src/__tests__/project-config-loader.test.ts +5 -33
- package/src/__tests__/public-exports.test.ts +8 -7
- package/src/__tests__/public-type-surface.test.ts +7 -5
- package/src/__tests__/public-value-surface.test.ts +1 -7
- package/src/__tests__/skip-semantics.test.ts +21 -37
- package/src/__tests__/trace-analyzer-extra.test.ts +14 -14
- package/src/__tests__/trace-analyzer.test.ts +21 -21
- package/src/__tests__/trace-collector.test.ts +22 -22
- package/src/__tests__/traces.test.ts +27 -28
- package/src/__tests__/usage-report-public-export.test.ts +21 -0
- package/src/cli/commands/CONTEXT.md +12 -12
- package/src/cli/commands/__tests__/check-read-count.test.ts +4 -15
- package/src/cli/commands/__tests__/check-skip-output.test.ts +14 -14
- package/src/cli/commands/__tests__/check.test.ts +14 -31
- package/src/cli/commands/__tests__/constraints-report-json-flag.test.ts +101 -0
- package/src/cli/commands/__tests__/constraints-report.test.ts +12 -80
- package/src/cli/commands/__tests__/constraints-retire.test.ts +42 -231
- package/src/cli/commands/__tests__/init-governance-io.test.ts +12 -58
- package/src/cli/commands/__tests__/init-ondisk.test.ts +13 -21
- package/src/cli/commands/__tests__/init.test.ts +1 -16
- package/src/cli/commands/__tests__/numeric-flag-assembly.test.ts +1 -1
- package/src/cli/commands/__tests__/passes-gate-dead-options.test.ts +1 -1
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +2 -2
- package/src/cli/commands/__tests__/registry.test.ts +1 -1
- package/src/cli/commands/__tests__/report-extra.test.ts +4 -4
- package/src/cli/commands/__tests__/report.test.ts +1 -1
- package/src/cli/commands/__tests__/scaffold.test.ts +4 -14
- package/src/cli/commands/__tests__/status-analysis-wiring.test.ts +3 -3
- package/src/cli/commands/__tests__/status-extra.test.ts +14 -14
- package/src/cli/commands/__tests__/status.test.ts +12 -12
- package/src/cli/commands/__tests__/sync-docs-agents.test.ts +1 -1
- package/src/cli/commands/check.ts +43 -82
- package/src/cli/commands/constraints-report.ts +4 -59
- package/src/cli/commands/constraints-retire.ts +49 -154
- package/src/cli/commands/constraints.ts +11 -26
- package/src/cli/commands/definitions.ts +7 -12
- package/src/cli/commands/init.ts +8 -179
- package/src/cli/commands/report.ts +19 -23
- package/src/cli/commands/scaffold-templates.ts +1 -53
- package/src/cli/commands/scaffold.ts +0 -11
- package/src/cli/commands/status.ts +10 -10
- package/src/cli/commands/sync-docs/agents-syncer.ts +4 -25
- package/src/core/CONTEXT.md +9 -9
- package/src/core/constraints/__tests__/capability-counts.test.ts +5 -5
- package/src/core/constraints/__tests__/collect-constraints.test.ts +13 -8
- package/src/core/constraints/__tests__/git-evidence.test.ts +4 -7
- package/src/core/constraints/__tests__/injection-writer.test.ts +8 -61
- package/src/core/constraints/__tests__/run-env.test.ts +5 -34
- package/src/core/constraints/__tests__/trace-injection.test.ts +1 -1
- package/src/core/constraints/capabilities-parser.ts +17 -5
- package/src/core/constraints/checker.ts +39 -88
- package/src/core/constraints/checkers/__tests__/check-outcome.test.ts +5 -8
- package/src/core/constraints/checkers/__tests__/governance-presence.test.ts +1 -53
- package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +5 -25
- package/src/core/constraints/checkers/docs-freshness.ts +1 -1
- package/src/core/constraints/checkers/governance-presence.ts +4 -3
- package/src/core/constraints/checkers/index.ts +4 -10
- package/src/core/constraints/checkers/iron-flags.ts +3 -12
- package/src/core/constraints/checkers/no-test-simplification.ts +1 -1
- package/src/core/constraints/checkers/types.ts +1 -1
- package/src/core/constraints/definitions/guidelines.ts +8 -25
- package/src/core/constraints/definitions/iron-laws.ts +9 -82
- package/src/core/constraints/definitions.ts +14 -15
- package/src/core/constraints/index.ts +4 -19
- package/src/core/constraints/injection-writer.ts +16 -61
- package/src/core/constraints/run-env.ts +1 -33
- package/src/core/constraints/usage-report.ts +9 -16
- package/src/core/effective-constraints.ts +14 -45
- package/src/core/index.ts +3 -10
- package/src/core/project-config-loader.ts +20 -145
- package/src/core/validators/passes-gate.ts +6 -6
- package/src/failure/CONTEXT.md +1 -1
- package/src/hooks/__tests__/bootstrap.test.ts +3 -5
- package/src/index.ts +28 -18
- package/src/knowledge/CONTEXT.md +4 -3
- package/src/knowledge/__tests__/lint.test.ts +84 -0
- package/src/knowledge/__tests__/store.test.ts +70 -0
- package/src/knowledge/lint.ts +60 -1
- package/src/knowledge/store.ts +48 -11
- package/src/knowledge/types.ts +7 -1
- package/src/monitoring/CONTEXT.md +1 -1
- package/src/monitoring/__tests__/trace-file-anchoring.test.ts +1 -1
- package/src/monitoring/__tests__/traces.test.ts +22 -22
- package/src/monitoring/trace-analyzer.ts +12 -13
- package/src/monitoring/traces.ts +8 -8
- package/src/presets/__tests__/standard.test.ts +12 -16
- package/src/presets/standard.ts +14 -23
- package/src/types/__tests__/types.test.ts +3 -3
- package/src/types/constraint.ts +26 -40
- package/src/types/passes-gate.ts +5 -5
- package/src/types/project-config.ts +8 -77
- package/src/types/trace.ts +8 -11
- package/dist/cli/commands/posteval-plan.d.ts +0 -15
- package/dist/cli/commands/posteval-plan.d.ts.map +0 -1
- package/dist/cli/commands/posteval-plan.js +0 -86
- package/dist/cli/commands/posteval-plan.js.map +0 -1
- package/dist/core/constraints/agent-prompt-renderer.d.ts +0 -32
- package/dist/core/constraints/agent-prompt-renderer.d.ts.map +0 -1
- package/dist/core/constraints/agent-prompt-renderer.js +0 -55
- package/dist/core/constraints/agent-prompt-renderer.js.map +0 -1
- package/dist/core/constraints/checkers/no-bypass-checkpoint.d.ts +0 -6
- package/dist/core/constraints/checkers/no-bypass-checkpoint.d.ts.map +0 -1
- package/dist/core/constraints/checkers/no-bypass-checkpoint.js +0 -40
- package/dist/core/constraints/checkers/no-bypass-checkpoint.js.map +0 -1
- package/dist/core/constraints/definitions/prompts.d.ts +0 -12
- package/dist/core/constraints/definitions/prompts.d.ts.map +0 -1
- package/dist/core/constraints/definitions/prompts.js +0 -400
- package/dist/core/constraints/definitions/prompts.js.map +0 -1
- package/dist/core/constraints/injection-drift.d.ts +0 -61
- package/dist/core/constraints/injection-drift.d.ts.map +0 -1
- package/dist/core/constraints/injection-drift.js +0 -131
- package/dist/core/constraints/injection-drift.js.map +0 -1
- package/dist/core/constraints/injection-renderer.d.ts +0 -23
- package/dist/core/constraints/injection-renderer.d.ts.map +0 -1
- package/dist/core/constraints/injection-renderer.js +0 -44
- package/dist/core/constraints/injection-renderer.js.map +0 -1
- package/src/cli/commands/__tests__/check-drift.test.ts +0 -158
- package/src/cli/commands/__tests__/init-injection.test.ts +0 -466
- package/src/cli/commands/__tests__/posteval-plan.test.ts +0 -204
- package/src/cli/commands/posteval-plan.ts +0 -98
- package/src/core/constraints/__tests__/agent-prompt-renderer.test.ts +0 -129
- package/src/core/constraints/__tests__/injection-drift.test.ts +0 -247
- package/src/core/constraints/agent-prompt-renderer.ts +0 -67
- package/src/core/constraints/checkers/__tests__/no-bypass-checkpoint.test.ts +0 -76
- package/src/core/constraints/checkers/no-bypass-checkpoint.ts +0 -40
- package/src/core/constraints/definitions/prompts.ts +0 -414
- package/src/core/constraints/injection-drift.ts +0 -142
- package/src/core/constraints/injection-renderer.ts +0 -44
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ProjectConfigLoader 补充测试
|
|
3
|
+
*
|
|
4
|
+
* ADR-0029:custom 纯文本约束面(custom_constraints / getCustomConstraints /
|
|
5
|
+
* isConstraintRetired 的 custom 落点)已随文本注入层关停一并退役,相关用例移除。
|
|
3
6
|
*/
|
|
4
7
|
|
|
5
8
|
import { describe, it, expect, beforeAll, afterAll, jest } from '@jest/globals';
|
|
6
|
-
import { ProjectConfigLoader
|
|
9
|
+
import { ProjectConfigLoader } from '../core/project-config-loader';
|
|
7
10
|
import * as fs from 'fs';
|
|
8
11
|
import * as path from 'path';
|
|
9
12
|
import * as os from 'os';
|
|
@@ -27,7 +30,7 @@ describe('ProjectConfigLoader - 补充覆盖', () => {
|
|
|
27
30
|
});
|
|
28
31
|
|
|
29
32
|
describe('禁用约束', () => {
|
|
30
|
-
it('
|
|
33
|
+
it('未知 id 的禁用配置静默忽略(生效集不变)', () => {
|
|
31
34
|
fs.writeFileSync(
|
|
32
35
|
path.join(harnessDir, 'config.yml'),
|
|
33
36
|
`
|
|
@@ -43,69 +46,18 @@ constraints:
|
|
|
43
46
|
loader.load();
|
|
44
47
|
const merged = loader.mergeConstraints();
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
expect(merged.
|
|
49
|
+
// 未知 id 进 unknownIds 供诊断(filterEnabledEntries 历史口径:未知但 enabled:false 的 id 同时也进 disabled)
|
|
50
|
+
expect(merged.unknownIds).toContain('legacy_disabled_a');
|
|
51
|
+
expect(merged.unknownIds).toContain('legacy_disabled_b');
|
|
48
52
|
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('自定义约束层级', () => {
|
|
52
|
-
it('应该正确分类 iron_law 级别约束', () => {
|
|
53
|
-
fs.writeFileSync(
|
|
54
|
-
path.join(harnessDir, 'config.yml'),
|
|
55
|
-
`
|
|
56
|
-
custom_constraints:
|
|
57
|
-
my_iron_law:
|
|
58
|
-
rule: MY IRON LAW
|
|
59
|
-
message: Iron law message
|
|
60
|
-
level: iron_law
|
|
61
|
-
trigger: commit
|
|
62
|
-
`
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const loader = new ProjectConfigLoader(tempDir);
|
|
66
|
-
loader.load();
|
|
67
|
-
const merged = loader.mergeConstraints();
|
|
68
|
-
|
|
69
|
-
expect(merged.ironLaws['my_iron_law']).toBeDefined();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('默认应该分类为 guideline', () => {
|
|
73
|
-
fs.writeFileSync(
|
|
74
|
-
path.join(harnessDir, 'config.yml'),
|
|
75
|
-
`
|
|
76
|
-
custom_constraints:
|
|
77
|
-
my_guideline:
|
|
78
|
-
rule: MY GUIDELINE
|
|
79
|
-
message: Guideline message
|
|
80
|
-
trigger: commit
|
|
81
|
-
`
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const loader = new ProjectConfigLoader(tempDir);
|
|
85
|
-
loader.load();
|
|
86
|
-
const merged = loader.mergeConstraints();
|
|
87
|
-
|
|
88
|
-
expect(merged.guidelines['my_guideline']).toBeDefined();
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
53
|
|
|
92
|
-
|
|
93
|
-
it('应该透传 promptInjection 并进入注入段渲染', async () => {
|
|
54
|
+
it('内置 id 的禁用配置从生效集移除并进 disabled', () => {
|
|
94
55
|
fs.writeFileSync(
|
|
95
56
|
path.join(harnessDir, 'config.yml'),
|
|
96
57
|
`
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
message: Prompt rule message
|
|
101
|
-
level: guideline
|
|
102
|
-
trigger: commit
|
|
103
|
-
promptInjection: 我的自定义注入文本
|
|
104
|
-
my_silent_rule:
|
|
105
|
-
rule: MY SILENT RULE
|
|
106
|
-
message: No injection text
|
|
107
|
-
level: guideline
|
|
108
|
-
trigger: commit
|
|
58
|
+
constraints:
|
|
59
|
+
capability_sync:
|
|
60
|
+
enabled: false
|
|
109
61
|
`
|
|
110
62
|
);
|
|
111
63
|
|
|
@@ -113,16 +65,8 @@ custom_constraints:
|
|
|
113
65
|
loader.load();
|
|
114
66
|
const merged = loader.mergeConstraints();
|
|
115
67
|
|
|
116
|
-
|
|
117
|
-
expect(merged.
|
|
118
|
-
// 未定义 promptInjection 的自定义约束保持不注入(与内置无注入文本条目一致)
|
|
119
|
-
expect(merged.guidelines['my_silent_rule']?.promptInjection).toBeUndefined();
|
|
120
|
-
|
|
121
|
-
// 端到端:进入 CLAUDE.md 注入段渲染
|
|
122
|
-
const { renderConstraintsSection } = await import('../core/constraints/injection-renderer');
|
|
123
|
-
const section = renderConstraintsSection(Object.values(merged.guidelines), '0.0.0-test');
|
|
124
|
-
expect(section).toContain('- **my_prompt_rule**: 我的自定义注入文本');
|
|
125
|
-
expect(section).not.toContain('my_silent_rule');
|
|
68
|
+
expect(merged.disabled).toContain('capability_sync');
|
|
69
|
+
expect(merged.constraints['capability_sync']).toBeUndefined();
|
|
126
70
|
});
|
|
127
71
|
});
|
|
128
72
|
|
|
@@ -130,7 +74,7 @@ custom_constraints:
|
|
|
130
74
|
/**
|
|
131
75
|
* `isConstraintEnabled` / `getConstraintSource` 属 ADR-0022 型漏收:
|
|
132
76
|
* 除本文件与自身测试外双仓零消费者,生效集判定唯一来源是
|
|
133
|
-
* `mergeConstraints` → `getEffectiveConstraints
|
|
77
|
+
* `mergeConstraints` → `getEffectiveConstraints`,这两个查询函数是它的平行复印。
|
|
134
78
|
*/
|
|
135
79
|
it('isConstraintEnabled / getConstraintSource 已从类面删除', () => {
|
|
136
80
|
const loader = new ProjectConfigLoader(tempDir);
|
|
@@ -145,26 +89,6 @@ custom_constraints:
|
|
|
145
89
|
});
|
|
146
90
|
});
|
|
147
91
|
|
|
148
|
-
describe('isConstraintRetired(退役判定单点,harness#137)', () => {
|
|
149
|
-
it('config.yml enabled:false 即已退役,与 custom 条目无关', () => {
|
|
150
|
-
expect(isConstraintRetired(undefined, true)).toBe(true);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('custom 条目带 retired 元数据即已退役(studio#82 D6 落点在条目自身)', () => {
|
|
154
|
-
expect(isConstraintRetired({ retired: { at: '2026-08-08T12:00:00.000Z' } }, false)).toBe(true);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('两个落点都没命中 → 未退役', () => {
|
|
158
|
-
expect(isConstraintRetired(undefined, false)).toBe(false);
|
|
159
|
-
expect(isConstraintRetired({ retired: undefined }, false)).toBe(false);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('retired 段的假值(null / 空串)不算退役——mergeConstraints 用的是 truthiness', () => {
|
|
163
|
-
expect(isConstraintRetired({ retired: null }, false)).toBe(false);
|
|
164
|
-
expect(isConstraintRetired({ retired: '' }, false)).toBe(false);
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
92
|
describe('hasCustomConfig', () => {
|
|
169
93
|
it('无自定义配置应该返回 false', () => {
|
|
170
94
|
// 清空配置
|
|
@@ -179,15 +103,13 @@ custom_constraints:
|
|
|
179
103
|
expect(loader.hasCustomConfig()).toBe(false);
|
|
180
104
|
});
|
|
181
105
|
|
|
182
|
-
it('
|
|
106
|
+
it('有 constraints 段应该返回 true', () => {
|
|
183
107
|
fs.writeFileSync(
|
|
184
108
|
path.join(harnessDir, 'config.yml'),
|
|
185
109
|
`
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
message: Custom
|
|
190
|
-
trigger: commit
|
|
110
|
+
constraints:
|
|
111
|
+
capability_sync:
|
|
112
|
+
enabled: false
|
|
191
113
|
`
|
|
192
114
|
);
|
|
193
115
|
|
|
@@ -220,10 +142,8 @@ custom_constraints:
|
|
|
220
142
|
loader.load();
|
|
221
143
|
const merged = loader.mergeConstraints({ preset: 'relaxed' });
|
|
222
144
|
|
|
223
|
-
// relaxed 仅启用
|
|
224
|
-
expect(Object.keys(merged.
|
|
225
|
-
expect(Object.keys(merged.guidelines)).toHaveLength(2);
|
|
226
|
-
expect(Object.keys(merged.prompts ?? {})).toHaveLength(0);
|
|
145
|
+
// relaxed 仅启用 1 条 error 级 + 1 条 warning 级
|
|
146
|
+
expect(Object.keys(merged.constraints)).toHaveLength(2);
|
|
227
147
|
expect(merged.disabled.length).toBeGreaterThan(0);
|
|
228
148
|
});
|
|
229
149
|
|
|
@@ -249,25 +169,4 @@ custom_constraints:
|
|
|
249
169
|
}
|
|
250
170
|
});
|
|
251
171
|
});
|
|
252
|
-
|
|
253
|
-
describe('getCustomConstraints', () => {
|
|
254
|
-
it('应该返回自定义约束', () => {
|
|
255
|
-
fs.writeFileSync(
|
|
256
|
-
path.join(harnessDir, 'config.yml'),
|
|
257
|
-
`
|
|
258
|
-
custom_constraints:
|
|
259
|
-
get_custom_test:
|
|
260
|
-
rule: TEST
|
|
261
|
-
message: Test
|
|
262
|
-
trigger: commit
|
|
263
|
-
`
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
const loader = new ProjectConfigLoader(tempDir);
|
|
267
|
-
loader.load();
|
|
268
|
-
|
|
269
|
-
const customs = loader.getCustomConstraints();
|
|
270
|
-
expect(customs['get_custom_test']).toBeDefined();
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
});
|
|
172
|
+
});
|
|
@@ -32,23 +32,18 @@ describe('ProjectConfigLoader', () => {
|
|
|
32
32
|
const config = loader.load();
|
|
33
33
|
|
|
34
34
|
expect(config.preset).toBe('standard');
|
|
35
|
-
expect(config.custom_constraints_file).toBeDefined();
|
|
36
35
|
});
|
|
37
36
|
|
|
38
37
|
it('应该加载 config.yml', () => {
|
|
39
38
|
fs.writeFileSync(
|
|
40
39
|
path.join(harnessDir, 'config.yml'),
|
|
41
|
-
`
|
|
42
|
-
preset: custom
|
|
43
|
-
custom_constraints_file: my-constraints.yml
|
|
44
|
-
`
|
|
40
|
+
`preset: custom`
|
|
45
41
|
);
|
|
46
42
|
|
|
47
43
|
const loader = new ProjectConfigLoader(tempDir);
|
|
48
44
|
const config = loader.load();
|
|
49
45
|
|
|
50
46
|
expect(config.preset).toBe('custom');
|
|
51
|
-
expect(config.custom_constraints_file).toBe('my-constraints.yml');
|
|
52
47
|
});
|
|
53
48
|
});
|
|
54
49
|
|
|
@@ -59,29 +54,8 @@ custom_constraints_file: my-constraints.yml
|
|
|
59
54
|
|
|
60
55
|
const merged = loader.mergeConstraints();
|
|
61
56
|
|
|
62
|
-
expect(merged.
|
|
63
|
-
expect(merged.
|
|
64
|
-
expect(Object.keys(merged.ironLaws).length).toBeGreaterThan(0);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('应该加载自定义约束', () => {
|
|
68
|
-
fs.writeFileSync(
|
|
69
|
-
path.join(harnessDir, 'custom-constraints.yml'),
|
|
70
|
-
`
|
|
71
|
-
custom_rules:
|
|
72
|
-
my_rule:
|
|
73
|
-
rule: MY CUSTOM RULE
|
|
74
|
-
message: Custom message
|
|
75
|
-
level: guideline
|
|
76
|
-
trigger: commit
|
|
77
|
-
`
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const loader = new ProjectConfigLoader(tempDir);
|
|
81
|
-
loader.load();
|
|
82
|
-
|
|
83
|
-
const merged = loader.mergeConstraints();
|
|
84
|
-
expect(merged.custom).toBeDefined();
|
|
57
|
+
expect(merged.constraints).toBeDefined();
|
|
58
|
+
expect(Object.keys(merged.constraints).length).toBeGreaterThan(0);
|
|
85
59
|
});
|
|
86
60
|
});
|
|
87
61
|
|
|
@@ -96,8 +70,6 @@ custom_rules:
|
|
|
96
70
|
const config = loader.load();
|
|
97
71
|
|
|
98
72
|
expect(config.preset).toBe('minimal');
|
|
99
|
-
// 默认值应该保留
|
|
100
|
-
expect(config.custom_constraints_file).toBe('custom-constraints.yml');
|
|
101
73
|
});
|
|
102
74
|
});
|
|
103
75
|
|
|
@@ -113,10 +85,10 @@ custom_rules:
|
|
|
113
85
|
expect(() => loader.load()).toThrow();
|
|
114
86
|
});
|
|
115
87
|
|
|
116
|
-
it('
|
|
88
|
+
it('config.yml 只有无关键时 mergeConstraints 不崩溃', () => {
|
|
117
89
|
fs.writeFileSync(
|
|
118
90
|
path.join(harnessDir, 'config.yml'),
|
|
119
|
-
`
|
|
91
|
+
`preset: standard`
|
|
120
92
|
);
|
|
121
93
|
|
|
122
94
|
const loader = new ProjectConfigLoader(tempDir);
|
|
@@ -19,8 +19,8 @@ import * as path from 'path';
|
|
|
19
19
|
|
|
20
20
|
const EXPECTED_RUNTIME_EXPORTS = [
|
|
21
21
|
'AgentLifecycle',
|
|
22
|
-
'
|
|
23
|
-
'
|
|
22
|
+
'CANDIDATE_KIND_LABEL',
|
|
23
|
+
'CONSTRAINTS',
|
|
24
24
|
'CSOValidator',
|
|
25
25
|
'CheckCache',
|
|
26
26
|
'CheckpointValidator',
|
|
@@ -32,6 +32,7 @@ const EXPECTED_RUNTIME_EXPORTS = [
|
|
|
32
32
|
'DEFAULT_CLASSIFICATION_RULES',
|
|
33
33
|
'DEFAULT_COMMAND_BLACKLIST',
|
|
34
34
|
'DEFAULT_DECAY_CONFIG',
|
|
35
|
+
'DEFAULT_DIAGNOSE_THRESHOLDS',
|
|
35
36
|
'DEFAULT_FAILURE_LOG_FILE',
|
|
36
37
|
'DEFAULT_LEVEL_MAPPING',
|
|
37
38
|
'DEFAULT_NONCODE_GLOBS',
|
|
@@ -43,8 +44,6 @@ const EXPECTED_RUNTIME_EXPORTS = [
|
|
|
43
44
|
'FailureRecorder',
|
|
44
45
|
'FileKnowledgeStore',
|
|
45
46
|
'GATE_DEFINITIONS',
|
|
46
|
-
'GUIDELINES',
|
|
47
|
-
'IRON_LAWS',
|
|
48
47
|
'KnowledgeAudit',
|
|
49
48
|
'KnowledgeHealthScorer',
|
|
50
49
|
'KnowledgeIngest',
|
|
@@ -53,7 +52,6 @@ const EXPECTED_RUNTIME_EXPORTS = [
|
|
|
53
52
|
'KnowledgeLinter',
|
|
54
53
|
'KnowledgeQuery',
|
|
55
54
|
'PHASE_SUBJECT_RE',
|
|
56
|
-
'PROMPTS',
|
|
57
55
|
'PassesGate',
|
|
58
56
|
'PerformanceGate',
|
|
59
57
|
'ReferenceTracker',
|
|
@@ -71,11 +69,13 @@ const EXPECTED_RUNTIME_EXPORTS = [
|
|
|
71
69
|
'assertGateRegistryClosed',
|
|
72
70
|
'bootstrapHarness',
|
|
73
71
|
'bootstrapHarnessSync',
|
|
72
|
+
'buildConstraintsUsageReport',
|
|
74
73
|
'checkBeforeExecution',
|
|
75
74
|
'checkConstraint',
|
|
76
75
|
'checkConstraints',
|
|
77
76
|
'classifyCommitFiles',
|
|
78
77
|
'classifyError',
|
|
78
|
+
'collectUsageByConstraint',
|
|
79
79
|
'configureTraceCollector',
|
|
80
80
|
'createAnalyzer',
|
|
81
81
|
'createCheckerGate',
|
|
@@ -89,6 +89,7 @@ const EXPECTED_RUNTIME_EXPORTS = [
|
|
|
89
89
|
'createSecurityGate',
|
|
90
90
|
'createSpecAcceptanceGate',
|
|
91
91
|
'decisionFromResult',
|
|
92
|
+
'diagnoseRetireCandidates',
|
|
92
93
|
'extractCodeStructure',
|
|
93
94
|
'findConstraintsByTrigger',
|
|
94
95
|
'getAllConstraints',
|
|
@@ -108,9 +109,9 @@ const EXPECTED_RUNTIME_EXPORTS = [
|
|
|
108
109
|
'matchAnyGlob',
|
|
109
110
|
'matchGlob',
|
|
110
111
|
'migrateKnowledgeEntries',
|
|
112
|
+
'readProjectTraces',
|
|
113
|
+
'readProjectTracesReport',
|
|
111
114
|
'registeredGateCount',
|
|
112
|
-
'renderConstraintsByTrigger',
|
|
113
|
-
'renderConstraintsSection',
|
|
114
115
|
'resolveGlobs',
|
|
115
116
|
'runGates',
|
|
116
117
|
'sanitizeExternalContent',
|
|
@@ -145,9 +145,11 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
145
145
|
'ConstraintContext',
|
|
146
146
|
'ConstraintId',
|
|
147
147
|
'ConstraintKind',
|
|
148
|
-
'
|
|
148
|
+
'ConstraintSeverity',
|
|
149
149
|
'ConstraintResult',
|
|
150
150
|
'ConstraintTrigger',
|
|
151
|
+
'ConstraintUsageStats',
|
|
152
|
+
'ConstraintsUsageReport',
|
|
151
153
|
'ConsumptionEvent',
|
|
152
154
|
'ConsumptionMode',
|
|
153
155
|
'ContextAverages',
|
|
@@ -159,10 +161,10 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
159
161
|
'ContractGateConfig',
|
|
160
162
|
'ContractPresenceContext',
|
|
161
163
|
'ContractPresenceResult',
|
|
162
|
-
'CustomConstraintDefinition',
|
|
163
164
|
'DecayConfig',
|
|
164
165
|
'DecisionRecord',
|
|
165
166
|
'DeclarationInfo',
|
|
167
|
+
'DiagnoseThresholds',
|
|
166
168
|
'DirCountActual',
|
|
167
169
|
'DocDirCheck',
|
|
168
170
|
'DocFreshnessCheck',
|
|
@@ -215,7 +217,8 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
215
217
|
'QueryFilter',
|
|
216
218
|
'QueryResult',
|
|
217
219
|
'ReferenceRecord',
|
|
218
|
-
'
|
|
220
|
+
'RetireCandidate',
|
|
221
|
+
'RetireCandidateKind',
|
|
219
222
|
'ReviewGateConfig',
|
|
220
223
|
'SchemaLoader',
|
|
221
224
|
'SecurityGateConfig',
|
|
@@ -265,14 +268,13 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
265
268
|
'ConstraintContext',
|
|
266
269
|
'ConstraintId',
|
|
267
270
|
'ConstraintKind',
|
|
268
|
-
'
|
|
271
|
+
'ConstraintSeverity',
|
|
269
272
|
'ConstraintResult',
|
|
270
273
|
'ConstraintTrigger',
|
|
271
274
|
'ContextFilesResolution',
|
|
272
275
|
'EffectiveConfigLint',
|
|
273
276
|
'IronLawContext',
|
|
274
277
|
'PassesGateConfig',
|
|
275
|
-
'RenderConstraintsByTriggerOptions',
|
|
276
278
|
'RunEnv',
|
|
277
279
|
'RunTarget',
|
|
278
280
|
'SpecSchemaDefinition',
|
|
@@ -47,16 +47,12 @@ const ENTRY_SUBPATHS: string[] = Object.keys(EXPORTS_MAP);
|
|
|
47
47
|
/** 每个已发布子路径入口的值面全量清单。增删任一项即公共面 breaking,见文件头。 */
|
|
48
48
|
const PUBLISHED_ENTRY_VALUES: Record<string, string[]> = {
|
|
49
49
|
'./core': [
|
|
50
|
-
'
|
|
51
|
-
'CONSTRAINTS_START_MARKER',
|
|
50
|
+
'CONSTRAINTS',
|
|
52
51
|
'CSOValidator',
|
|
53
52
|
'CheckCache',
|
|
54
53
|
'CheckpointValidator',
|
|
55
54
|
'ConstraintChecker',
|
|
56
55
|
'ConstraintViolationError',
|
|
57
|
-
'GUIDELINES',
|
|
58
|
-
'IRON_LAWS',
|
|
59
|
-
'PROMPTS',
|
|
60
56
|
'PassesGate',
|
|
61
57
|
'ProjectConfigLoader',
|
|
62
58
|
'SpecValidator',
|
|
@@ -73,8 +69,6 @@ const PUBLISHED_ENTRY_VALUES: Record<string, string[]> = {
|
|
|
73
69
|
'getGovernanceConfig',
|
|
74
70
|
'lintEffectiveConfig',
|
|
75
71
|
'loadRawProjectConfig',
|
|
76
|
-
'renderConstraintsByTrigger',
|
|
77
|
-
'renderConstraintsSection',
|
|
78
72
|
'resolveContextFiles',
|
|
79
73
|
],
|
|
80
74
|
'./presets': [
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 覆盖:
|
|
5
5
|
* - 三条存在性探测(capability_sync / context_doc_sync / docs_freshness)有/无约定两路
|
|
6
|
-
* - flag
|
|
7
|
-
* -
|
|
6
|
+
* - flag 型 error 级约束 undefined → skip(显式 false 仍 fail,true 仍 pass)
|
|
7
|
+
* - error 级 skip 不阻断 checkConstraints
|
|
8
8
|
* - detectTrigger 代码文件 → 附加 code_implementation 推断
|
|
9
9
|
* - trace 记录 result: 'skip';TraceAnalyzer 的 pass/fail 率分母不计 skip
|
|
10
10
|
*/
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
|
|
13
13
|
import { ConstraintChecker } from '../core/constraints/checker';
|
|
14
14
|
import { detectTrigger, buildConstraintContext } from '../core/constraints/context-builder';
|
|
15
|
-
import {
|
|
15
|
+
import { CONSTRAINTS } from '../core/constraints/definitions';
|
|
16
16
|
import { TraceAnalyzer } from '../monitoring/trace-analyzer';
|
|
17
17
|
import type { Constraint, ConstraintContext } from '../types/constraint';
|
|
18
18
|
import type { ExecutionTrace } from '../types/trace';
|
|
@@ -26,10 +26,10 @@ const checker = new ConstraintChecker({ record: () => undefined });
|
|
|
26
26
|
|
|
27
27
|
function makeConstraint(
|
|
28
28
|
id: string,
|
|
29
|
-
|
|
29
|
+
severity: 'error' | 'warning',
|
|
30
30
|
trigger: string = 'commit'
|
|
31
31
|
): Constraint {
|
|
32
|
-
return { id, kind: 'check',
|
|
32
|
+
return { id, kind: 'check', severity, rule: 'TEST', message: 'test', trigger, enforcement: 'test' };
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
describe('skip 三态语义(ADR-0001)', () => {
|
|
@@ -58,7 +58,7 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
58
58
|
const dir = path.join(tempDir, 'cap-skip');
|
|
59
59
|
fs.mkdirSync(dir, { recursive: true });
|
|
60
60
|
|
|
61
|
-
const result = await checker.check(makeConstraint('capability_sync', '
|
|
61
|
+
const result = await checker.check(makeConstraint('capability_sync', 'warning'), {
|
|
62
62
|
operation: 'commit',
|
|
63
63
|
projectPath: dir,
|
|
64
64
|
} as ConstraintContext);
|
|
@@ -75,7 +75,7 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
75
75
|
// 散文文档(无表格)历史放行;此处只验证"进入评估"而非 skip
|
|
76
76
|
fs.writeFileSync(path.join(dir, 'CAPABILITIES.md'), '# Capabilities\n\n- Feature: test');
|
|
77
77
|
|
|
78
|
-
const result = await checker.check(makeConstraint('capability_sync', '
|
|
78
|
+
const result = await checker.check(makeConstraint('capability_sync', 'warning'), {
|
|
79
79
|
operation: 'commit',
|
|
80
80
|
projectPath: dir,
|
|
81
81
|
} as ConstraintContext);
|
|
@@ -92,7 +92,7 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
92
92
|
const dir = path.join(tempDir, 'ctx-skip');
|
|
93
93
|
fs.mkdirSync(dir, { recursive: true });
|
|
94
94
|
|
|
95
|
-
const result = await checker.check(makeConstraint('context_doc_sync', '
|
|
95
|
+
const result = await checker.check(makeConstraint('context_doc_sync', 'warning'), {
|
|
96
96
|
operation: 'module_modification',
|
|
97
97
|
projectPath: dir,
|
|
98
98
|
} as ConstraintContext);
|
|
@@ -114,7 +114,7 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
114
114
|
yaml.dump({ governance: { context_files: { enabled: true, required_dirs: ['src'] } } })
|
|
115
115
|
);
|
|
116
116
|
|
|
117
|
-
const result = await checker.check(makeConstraint('context_doc_sync', '
|
|
117
|
+
const result = await checker.check(makeConstraint('context_doc_sync', 'warning'), {
|
|
118
118
|
operation: 'module_modification',
|
|
119
119
|
projectPath: dir,
|
|
120
120
|
} as ConstraintContext);
|
|
@@ -131,7 +131,7 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
131
131
|
const dir = path.join(tempDir, 'fresh-skip');
|
|
132
132
|
fs.mkdirSync(dir, { recursive: true });
|
|
133
133
|
|
|
134
|
-
const result = await checker.check(makeConstraint('docs_freshness', '
|
|
134
|
+
const result = await checker.check(makeConstraint('docs_freshness', 'error', 'file_modification'), {
|
|
135
135
|
operation: 'file_modification',
|
|
136
136
|
projectPath: dir,
|
|
137
137
|
} as ConstraintContext);
|
|
@@ -150,7 +150,7 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
150
150
|
'# Capabilities\n\n| 模块 | 文件 | 说明 |\n|------|------|------|\n| ghost | src/ghost.ts | 不存在 |'
|
|
151
151
|
);
|
|
152
152
|
|
|
153
|
-
const result = await checker.check(makeConstraint('docs_freshness', '
|
|
153
|
+
const result = await checker.check(makeConstraint('docs_freshness', 'error', 'file_modification'), {
|
|
154
154
|
operation: 'file_modification',
|
|
155
155
|
projectPath: dir,
|
|
156
156
|
} as ConstraintContext);
|
|
@@ -162,9 +162,9 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
162
162
|
});
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
describe('flag
|
|
165
|
+
describe('flag 型 error 级约束:undefined → skip', () => {
|
|
166
166
|
it('hasVerificationEvidence undefined → skip;false → fail;true → pass', async () => {
|
|
167
|
-
const law =
|
|
167
|
+
const law = CONSTRAINTS['no_completion_without_verification'];
|
|
168
168
|
|
|
169
169
|
const skipped = await checker.check(law, { operation: 'code_implementation' });
|
|
170
170
|
expect(skipped.skipped).toBe(true);
|
|
@@ -185,33 +185,17 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
185
185
|
expect(passed.satisfied).toBe(true);
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
-
it('hasSingleTask / hasRequirement undefined → skip', async () => {
|
|
189
|
-
const single = await checker.check(IRON_LAWS['incremental_progress'], {
|
|
190
|
-
operation: 'code_implementation',
|
|
191
|
-
});
|
|
192
|
-
expect(single.skipped).toBe(true);
|
|
193
|
-
|
|
194
|
-
const req = await checker.check(IRON_LAWS['no_implementation_without_requirement'], {
|
|
195
|
-
operation: 'code_implementation',
|
|
196
|
-
});
|
|
197
|
-
expect(req.skipped).toBe(true);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
188
|
it('Iron Law skip 不阻断 checkConstraints', async () => {
|
|
201
|
-
//
|
|
189
|
+
// flag 未接线(CLI pre-commit 路径的典型形态)
|
|
202
190
|
const result = await checker.checkConstraints({
|
|
203
191
|
operation: 'code_implementation',
|
|
204
192
|
projectPath: path.join(tempDir, 'empty'),
|
|
205
193
|
});
|
|
206
194
|
|
|
207
195
|
expect(result.passed).toBe(true);
|
|
208
|
-
const skippedIds = result.
|
|
196
|
+
const skippedIds = result.errors.filter(r => r.skipped).map(r => r.id);
|
|
209
197
|
expect(skippedIds).toEqual(
|
|
210
|
-
expect.arrayContaining([
|
|
211
|
-
'no_completion_without_verification',
|
|
212
|
-
'incremental_progress',
|
|
213
|
-
'no_implementation_without_requirement',
|
|
214
|
-
])
|
|
198
|
+
expect.arrayContaining(['no_completion_without_verification'])
|
|
215
199
|
);
|
|
216
200
|
});
|
|
217
201
|
|
|
@@ -296,17 +280,17 @@ describe('skip 三态语义(ADR-0001)', () => {
|
|
|
296
280
|
|
|
297
281
|
const skipTraces = records.filter(t => t.result === 'skip');
|
|
298
282
|
expect(skipTraces.map(t => t.constraintId)).toEqual(
|
|
299
|
-
expect.arrayContaining(['
|
|
283
|
+
expect.arrayContaining(['no_completion_without_verification'])
|
|
300
284
|
);
|
|
301
285
|
});
|
|
302
286
|
|
|
303
287
|
it('TraceAnalyzer:skip 单独计数,不计入 pass/fail 率分母', () => {
|
|
304
288
|
const analyzer = new TraceAnalyzer(null as any);
|
|
305
289
|
const traces: ExecutionTrace[] = [
|
|
306
|
-
{ constraintId: 'c1',
|
|
307
|
-
{ constraintId: 'c1',
|
|
308
|
-
{ constraintId: 'c1',
|
|
309
|
-
{ constraintId: 'c1',
|
|
290
|
+
{ constraintId: 'c1', severity: 'error', timestamp: 1, result: 'pass' },
|
|
291
|
+
{ constraintId: 'c1', severity: 'error', timestamp: 2, result: 'skip' },
|
|
292
|
+
{ constraintId: 'c1', severity: 'error', timestamp: 3, result: 'skip' },
|
|
293
|
+
{ constraintId: 'c1', severity: 'error', timestamp: 4, result: 'fail' },
|
|
310
294
|
];
|
|
311
295
|
|
|
312
296
|
const [summary] = analyzer.summarize(traces);
|