@dommaker/harness 1.8.1 → 1.10.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 +16 -0
- package/README.md +10 -13
- 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.js +2 -2
- 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 +0 -2
- package/dist/cli/commands/scaffold-templates.d.ts.map +1 -1
- package/dist/cli/commands/scaffold-templates.js +2 -37
- 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/cli/commands/sync-docs/capabilities-syncer.d.ts +22 -0
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +113 -8
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +36 -4
- package/dist/cli/commands/sync-docs/index.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 +5 -7
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +5 -10
- 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/hooks/bootstrap.d.ts +9 -12
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +9 -31
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/hooks/index.d.ts +5 -7
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +4 -10
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +9 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -23
- package/dist/index.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 +3 -3
- 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 +31 -11
- package/src/__tests__/public-type-surface.test.ts +2 -13
- 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/cli/commands/CONTEXT.md +12 -9
- 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.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 +12 -20
- package/src/cli/commands/__tests__/init.test.ts +0 -11
- package/src/cli/commands/__tests__/project-path-anchoring.test.ts +2 -2
- package/src/cli/commands/__tests__/registry.test.ts +39 -3
- 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/__tests__/sync-docs-table-layout.test.ts +259 -0
- 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 +2 -2
- package/src/cli/commands/init.ts +8 -179
- package/src/cli/commands/report.ts +19 -23
- package/src/cli/commands/scaffold-templates.ts +1 -37
- 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/cli/commands/sync-docs/capabilities-syncer.ts +139 -9
- package/src/cli/commands/sync-docs/index.ts +41 -4
- 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 +8 -15
- 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/CONTEXT.md +12 -22
- package/src/hooks/__tests__/bootstrap.test.ts +24 -75
- package/src/hooks/bootstrap.ts +9 -48
- package/src/hooks/index.ts +5 -20
- package/src/index.ts +9 -31
- 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/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/dist/hooks/config.d.ts +0 -30
- package/dist/hooks/config.d.ts.map +0 -1
- package/dist/hooks/config.js +0 -34
- package/dist/hooks/config.js.map +0 -1
- package/dist/hooks/pipeline.d.ts +0 -54
- package/dist/hooks/pipeline.d.ts.map +0 -1
- package/dist/hooks/pipeline.js +0 -173
- package/dist/hooks/pipeline.js.map +0 -1
- package/dist/hooks/registry.d.ts +0 -70
- package/dist/hooks/registry.d.ts.map +0 -1
- package/dist/hooks/registry.js +0 -141
- package/dist/hooks/registry.js.map +0 -1
- package/dist/hooks/types.d.ts +0 -113
- package/dist/hooks/types.d.ts.map +0 -1
- package/dist/hooks/types.js +0 -9
- package/dist/hooks/types.js.map +0 -1
- package/src/__tests__/hooks-pipeline.test.ts +0 -201
- package/src/cli/commands/__tests__/check-drift.test.ts +0 -158
- package/src/cli/commands/__tests__/init-injection.test.ts +0 -466
- 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
- package/src/hooks/__tests__/config.test.ts +0 -19
- package/src/hooks/__tests__/pipeline.test.ts +0 -195
- package/src/hooks/__tests__/registry.test.ts +0 -115
- package/src/hooks/config.ts +0 -33
- package/src/hooks/pipeline.ts +0 -202
- package/src/hooks/registry.ts +0 -166
- package/src/hooks/types.ts +0 -120
|
@@ -145,7 +145,7 @@ 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
151
|
'ConsumptionEvent',
|
|
@@ -159,7 +159,6 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
159
159
|
'ContractGateConfig',
|
|
160
160
|
'ContractPresenceContext',
|
|
161
161
|
'ContractPresenceResult',
|
|
162
|
-
'CustomConstraintDefinition',
|
|
163
162
|
'DecayConfig',
|
|
164
163
|
'DecisionRecord',
|
|
165
164
|
'DeclarationInfo',
|
|
@@ -170,7 +169,6 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
170
169
|
'DocRegexCountCheck',
|
|
171
170
|
'DocsSyncConfig',
|
|
172
171
|
'EffectiveConfigLint',
|
|
173
|
-
'EffectiveHook',
|
|
174
172
|
'ErrorClassificationRule',
|
|
175
173
|
'ErrorClassifierConfig',
|
|
176
174
|
'EventHandler',
|
|
@@ -189,12 +187,6 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
189
187
|
'GovernanceConfig',
|
|
190
188
|
'GrepCountActual',
|
|
191
189
|
'HarnessBootstrap',
|
|
192
|
-
'HookConfig',
|
|
193
|
-
'HookDefinition',
|
|
194
|
-
'HookErrorStrategy',
|
|
195
|
-
'HookExecutionRecord',
|
|
196
|
-
'HookPhase',
|
|
197
|
-
'HookResult',
|
|
198
190
|
'ImportInfo',
|
|
199
191
|
'IndexEntry',
|
|
200
192
|
'IngestOptions',
|
|
@@ -217,13 +209,11 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
217
209
|
'PerformanceGateConfig',
|
|
218
210
|
'PerformanceThresholds',
|
|
219
211
|
'PhaseFormatResult',
|
|
220
|
-
'PipelineResult',
|
|
221
212
|
'ProjectConfig',
|
|
222
213
|
'QueryBudget',
|
|
223
214
|
'QueryFilter',
|
|
224
215
|
'QueryResult',
|
|
225
216
|
'ReferenceRecord',
|
|
226
|
-
'RenderConstraintsByTriggerOptions',
|
|
227
217
|
'ReviewGateConfig',
|
|
228
218
|
'SchemaLoader',
|
|
229
219
|
'SecurityGateConfig',
|
|
@@ -273,14 +263,13 @@ const PUBLISHED_ENTRY_TYPES: Record<string, string[]> = {
|
|
|
273
263
|
'ConstraintContext',
|
|
274
264
|
'ConstraintId',
|
|
275
265
|
'ConstraintKind',
|
|
276
|
-
'
|
|
266
|
+
'ConstraintSeverity',
|
|
277
267
|
'ConstraintResult',
|
|
278
268
|
'ConstraintTrigger',
|
|
279
269
|
'ContextFilesResolution',
|
|
280
270
|
'EffectiveConfigLint',
|
|
281
271
|
'IronLawContext',
|
|
282
272
|
'PassesGateConfig',
|
|
283
|
-
'RenderConstraintsByTriggerOptions',
|
|
284
273
|
'RunEnv',
|
|
285
274
|
'RunTarget',
|
|
286
275
|
'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);
|
|
@@ -41,8 +41,8 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
41
41
|
describe('趋势计算', () => {
|
|
42
42
|
it('少于 10 条记录应该返回 stable', () => {
|
|
43
43
|
const traces: ExecutionTrace[] = [
|
|
44
|
-
{ constraintId: 'test',
|
|
45
|
-
{ constraintId: 'test',
|
|
44
|
+
{ constraintId: 'test', severity: 'error', timestamp: 1000, result: 'pass' },
|
|
45
|
+
{ constraintId: 'test', severity: 'error', timestamp: 2000, result: 'pass' },
|
|
46
46
|
];
|
|
47
47
|
|
|
48
48
|
const summaries = analyzer.summarize(traces);
|
|
@@ -53,10 +53,10 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
53
53
|
// 创建 15 条记录,前半段通过率低,后半段高 → rising
|
|
54
54
|
const traces: ExecutionTrace[] = [];
|
|
55
55
|
for (let i = 0; i < 8; i++) {
|
|
56
|
-
traces.push({ constraintId: 'test',
|
|
56
|
+
traces.push({ constraintId: 'test', severity: 'error', timestamp: 1000 + i * 100, result: 'fail' });
|
|
57
57
|
}
|
|
58
58
|
for (let i = 8; i < 15; i++) {
|
|
59
|
-
traces.push({ constraintId: 'test',
|
|
59
|
+
traces.push({ constraintId: 'test', severity: 'error', timestamp: 1000 + i * 100, result: 'pass' });
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const summaries = analyzer.summarize(traces);
|
|
@@ -67,10 +67,10 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
67
67
|
describe('compareWithPrevious', () => {
|
|
68
68
|
it('应该计算环比变化', () => {
|
|
69
69
|
const current: any[] = [
|
|
70
|
-
{ constraintId: 'test', passRate: 0.8, failRate: 0.2,
|
|
70
|
+
{ constraintId: 'test', passRate: 0.8, failRate: 0.2, severity: 'error' },
|
|
71
71
|
];
|
|
72
72
|
const previous: any[] = [
|
|
73
|
-
{ constraintId: 'test', passRate: 0.6, failRate: 0.4,
|
|
73
|
+
{ constraintId: 'test', passRate: 0.6, failRate: 0.4, severity: 'error' },
|
|
74
74
|
];
|
|
75
75
|
|
|
76
76
|
const result = analyzer.compareWithPrevious(current, previous);
|
|
@@ -81,7 +81,7 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
81
81
|
|
|
82
82
|
it('无历史数据应该不设置变化', () => {
|
|
83
83
|
const current: any[] = [
|
|
84
|
-
{ constraintId: 'new_test', passRate: 0.8, failRate: 0.2,
|
|
84
|
+
{ constraintId: 'new_test', passRate: 0.8, failRate: 0.2, severity: 'error' },
|
|
85
85
|
];
|
|
86
86
|
const previous: any[] = [];
|
|
87
87
|
|
|
@@ -94,7 +94,7 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
94
94
|
describe('saveSummary/loadSummary', () => {
|
|
95
95
|
it('应该保存和加载汇总', () => {
|
|
96
96
|
const summaries: any[] = [
|
|
97
|
-
{ constraintId: 'test', passRate: 0.8, failRate: 0.2,
|
|
97
|
+
{ constraintId: 'test', passRate: 0.8, failRate: 0.2, severity: 'error', totalChecks: 10 },
|
|
98
98
|
];
|
|
99
99
|
|
|
100
100
|
analyzer.saveSummary(summaries);
|
|
@@ -120,7 +120,7 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
120
120
|
it('应该运行小时汇总', () => {
|
|
121
121
|
// 写入一些 traces
|
|
122
122
|
const traces: ExecutionTrace[] = [
|
|
123
|
-
{ constraintId: 'hourly_test',
|
|
123
|
+
{ constraintId: 'hourly_test', severity: 'error', timestamp: Date.now(), result: 'pass' },
|
|
124
124
|
];
|
|
125
125
|
collector.record(traces[0]);
|
|
126
126
|
|
|
@@ -137,7 +137,7 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
137
137
|
for (let i = 0; i < 20; i++) {
|
|
138
138
|
traces.push({
|
|
139
139
|
constraintId: 'daily_test',
|
|
140
|
-
|
|
140
|
+
severity: 'error',
|
|
141
141
|
timestamp: Date.now() - i * 1000,
|
|
142
142
|
result: i < 15 ? 'fail' : 'pass', // 75% 失败率
|
|
143
143
|
});
|
|
@@ -155,7 +155,7 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
155
155
|
const summaries: any[] = [
|
|
156
156
|
{
|
|
157
157
|
constraintId: 'report_test',
|
|
158
|
-
|
|
158
|
+
severity: 'error',
|
|
159
159
|
passRate: 0.8,
|
|
160
160
|
failRate: 0.2,
|
|
161
161
|
totalChecks: 100,
|
|
@@ -180,7 +180,7 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
180
180
|
describe('analyzeConstraint', () => {
|
|
181
181
|
it('应该分析特定约束', () => {
|
|
182
182
|
const traces: ExecutionTrace[] = [
|
|
183
|
-
{ constraintId: 'specific_test',
|
|
183
|
+
{ constraintId: 'specific_test', severity: 'error', timestamp: Date.now(), result: 'pass' },
|
|
184
184
|
];
|
|
185
185
|
traces.forEach(t => collector.record(t));
|
|
186
186
|
|
|
@@ -201,10 +201,10 @@ describe('TraceAnalyzer - 补充覆盖', () => {
|
|
|
201
201
|
|
|
202
202
|
const traces: ExecutionTrace[] = [];
|
|
203
203
|
for (let i = 0; i < 6; i++) {
|
|
204
|
-
traces.push({ constraintId: 'rising_fail',
|
|
204
|
+
traces.push({ constraintId: 'rising_fail', severity: 'error', timestamp: 1000 + i * 100, result: 'fail' });
|
|
205
205
|
}
|
|
206
206
|
for (let i = 6; i < 14; i++) {
|
|
207
|
-
traces.push({ constraintId: 'rising_fail',
|
|
207
|
+
traces.push({ constraintId: 'rising_fail', severity: 'error', timestamp: 1000 + i * 100, result: 'pass' });
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
const summaries = customAnalyzer.summarize(traces);
|
|
@@ -39,9 +39,9 @@ describe('TraceAnalyzer', () => {
|
|
|
39
39
|
describe('summarize', () => {
|
|
40
40
|
it('应该生成统计汇总', () => {
|
|
41
41
|
const traces: ExecutionTrace[] = [
|
|
42
|
-
{ constraintId: 'test1',
|
|
43
|
-
{ constraintId: 'test1',
|
|
44
|
-
{ constraintId: 'test2',
|
|
42
|
+
{ constraintId: 'test1', severity: 'error', timestamp: 1000, result: 'pass' },
|
|
43
|
+
{ constraintId: 'test1', severity: 'error', timestamp: 2000, result: 'fail' },
|
|
44
|
+
{ constraintId: 'test2', severity: 'warning', timestamp: 3000, result: 'pass' },
|
|
45
45
|
];
|
|
46
46
|
|
|
47
47
|
const summaries = analyzer.summarize(traces);
|
|
@@ -51,9 +51,9 @@ describe('TraceAnalyzer', () => {
|
|
|
51
51
|
|
|
52
52
|
it('应该计算通过率', () => {
|
|
53
53
|
const traces: ExecutionTrace[] = [
|
|
54
|
-
{ constraintId: 'test',
|
|
55
|
-
{ constraintId: 'test',
|
|
56
|
-
{ constraintId: 'test',
|
|
54
|
+
{ constraintId: 'test', severity: 'error', timestamp: 1000, result: 'pass' },
|
|
55
|
+
{ constraintId: 'test', severity: 'error', timestamp: 2000, result: 'pass' },
|
|
56
|
+
{ constraintId: 'test', severity: 'error', timestamp: 3000, result: 'fail' },
|
|
57
57
|
];
|
|
58
58
|
|
|
59
59
|
const summaries = analyzer.summarize(traces);
|
|
@@ -64,8 +64,8 @@ describe('TraceAnalyzer', () => {
|
|
|
64
64
|
|
|
65
65
|
it('应该计算失败率', () => {
|
|
66
66
|
const traces: ExecutionTrace[] = [
|
|
67
|
-
{ constraintId: 'test',
|
|
68
|
-
{ constraintId: 'test',
|
|
67
|
+
{ constraintId: 'test', severity: 'error', timestamp: 1000, result: 'fail' },
|
|
68
|
+
{ constraintId: 'test', severity: 'error', timestamp: 2000, result: 'fail' },
|
|
69
69
|
];
|
|
70
70
|
|
|
71
71
|
const summaries = analyzer.summarize(traces);
|
|
@@ -83,10 +83,10 @@ describe('TraceAnalyzer', () => {
|
|
|
83
83
|
describe('detectAnomalies', () => {
|
|
84
84
|
it('应该检测失败率异常', () => {
|
|
85
85
|
const traces: ExecutionTrace[] = [
|
|
86
|
-
{ constraintId: 'test',
|
|
87
|
-
{ constraintId: 'test',
|
|
88
|
-
{ constraintId: 'test',
|
|
89
|
-
{ constraintId: 'test',
|
|
86
|
+
{ constraintId: 'test', severity: 'warning', timestamp: 1000, result: 'fail' },
|
|
87
|
+
{ constraintId: 'test', severity: 'warning', timestamp: 2000, result: 'fail' },
|
|
88
|
+
{ constraintId: 'test', severity: 'warning', timestamp: 3000, result: 'fail' },
|
|
89
|
+
{ constraintId: 'test', severity: 'warning', timestamp: 4000, result: 'pass' },
|
|
90
90
|
];
|
|
91
91
|
|
|
92
92
|
const summaries = analyzer.summarize(traces);
|
|
@@ -97,8 +97,8 @@ describe('TraceAnalyzer', () => {
|
|
|
97
97
|
|
|
98
98
|
it('正常数据应该无异常', () => {
|
|
99
99
|
const traces: ExecutionTrace[] = [
|
|
100
|
-
{ constraintId: 'test',
|
|
101
|
-
{ constraintId: 'test',
|
|
100
|
+
{ constraintId: 'test', severity: 'error', timestamp: 1000, result: 'pass' },
|
|
101
|
+
{ constraintId: 'test', severity: 'error', timestamp: 2000, result: 'pass' },
|
|
102
102
|
];
|
|
103
103
|
|
|
104
104
|
const summaries = analyzer.summarize(traces);
|
|
@@ -111,9 +111,9 @@ describe('TraceAnalyzer', () => {
|
|
|
111
111
|
describe('groupByConstraint', () => {
|
|
112
112
|
it('应该按约束 ID 分组', () => {
|
|
113
113
|
const traces: ExecutionTrace[] = [
|
|
114
|
-
{ constraintId: 'a',
|
|
115
|
-
{ constraintId: 'b',
|
|
116
|
-
{ constraintId: 'a',
|
|
114
|
+
{ constraintId: 'a', severity: 'error', timestamp: 1000, result: 'pass' },
|
|
115
|
+
{ constraintId: 'b', severity: 'error', timestamp: 2000, result: 'pass' },
|
|
116
|
+
{ constraintId: 'a', severity: 'error', timestamp: 3000, result: 'pass' },
|
|
117
117
|
];
|
|
118
118
|
|
|
119
119
|
// 通过 summarize 间接验证分组
|
|
@@ -140,9 +140,9 @@ describe('TraceAnalyzer', () => {
|
|
|
140
140
|
describe('模块级纯函数', () => {
|
|
141
141
|
it('summarizeTraces 不构造 collector 即可汇总,skip 不进 pass/fail 分母', () => {
|
|
142
142
|
const traces: ExecutionTrace[] = [
|
|
143
|
-
{ constraintId: 'pure',
|
|
144
|
-
{ constraintId: 'pure',
|
|
145
|
-
{ constraintId: 'pure',
|
|
143
|
+
{ constraintId: 'pure', severity: 'error', timestamp: 1000, result: 'pass' },
|
|
144
|
+
{ constraintId: 'pure', severity: 'error', timestamp: 2000, result: 'fail' },
|
|
145
|
+
{ constraintId: 'pure', severity: 'error', timestamp: 3000, result: 'skip' },
|
|
146
146
|
];
|
|
147
147
|
|
|
148
148
|
const summaries = summarizeTraces(traces);
|
|
@@ -160,7 +160,7 @@ describe('TraceAnalyzer', () => {
|
|
|
160
160
|
// failRate 6/14 ≈ 0.43 且趋势上升:默认阈值 0.5 不触发,0.3 触发
|
|
161
161
|
const summary: TraceSummary = {
|
|
162
162
|
constraintId: 'param_threshold',
|
|
163
|
-
|
|
163
|
+
severity: 'error',
|
|
164
164
|
timeRange: { start: 1000, end: 2400 },
|
|
165
165
|
totalChecks: 14,
|
|
166
166
|
passCount: 8,
|
|
@@ -36,8 +36,8 @@ describe('TraceCollector', () => {
|
|
|
36
36
|
describe('record', () => {
|
|
37
37
|
it('应该记录 trace', () => {
|
|
38
38
|
const trace: ExecutionTrace = {
|
|
39
|
-
constraintId: '
|
|
40
|
-
|
|
39
|
+
constraintId: 'no_test_simplification',
|
|
40
|
+
severity: 'error',
|
|
41
41
|
timestamp: Date.now(),
|
|
42
42
|
result: 'pass',
|
|
43
43
|
};
|
|
@@ -45,7 +45,7 @@ describe('TraceCollector', () => {
|
|
|
45
45
|
collector.record(trace);
|
|
46
46
|
|
|
47
47
|
const content = fs.readFileSync(traceFile, 'utf-8');
|
|
48
|
-
expect(content).toContain('
|
|
48
|
+
expect(content).toContain('no_test_simplification');
|
|
49
49
|
expect(content).toContain('pass');
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -57,7 +57,7 @@ describe('TraceCollector', () => {
|
|
|
57
57
|
|
|
58
58
|
disabledCollector.record({
|
|
59
59
|
constraintId: 'test',
|
|
60
|
-
|
|
60
|
+
severity: 'error',
|
|
61
61
|
timestamp: Date.now(),
|
|
62
62
|
result: 'pass',
|
|
63
63
|
});
|
|
@@ -69,13 +69,13 @@ describe('TraceCollector', () => {
|
|
|
69
69
|
it('应该追加多条记录', () => {
|
|
70
70
|
collector.record({
|
|
71
71
|
constraintId: 'test1',
|
|
72
|
-
|
|
72
|
+
severity: 'error',
|
|
73
73
|
timestamp: Date.now(),
|
|
74
74
|
result: 'pass',
|
|
75
75
|
});
|
|
76
76
|
collector.record({
|
|
77
77
|
constraintId: 'test2',
|
|
78
|
-
|
|
78
|
+
severity: 'warning',
|
|
79
79
|
timestamp: Date.now(),
|
|
80
80
|
result: 'fail',
|
|
81
81
|
});
|
|
@@ -88,7 +88,7 @@ describe('TraceCollector', () => {
|
|
|
88
88
|
|
|
89
89
|
describe('recordPass', () => {
|
|
90
90
|
it('应该记录通过 trace', () => {
|
|
91
|
-
collector.recordPass('
|
|
91
|
+
collector.recordPass('no_test_simplification', 'error');
|
|
92
92
|
|
|
93
93
|
const traces = collector.read();
|
|
94
94
|
expect(traces.length).toBe(1);
|
|
@@ -98,7 +98,7 @@ describe('TraceCollector', () => {
|
|
|
98
98
|
|
|
99
99
|
describe('recordFail', () => {
|
|
100
100
|
it('应该记录失败 trace', () => {
|
|
101
|
-
collector.recordFail('
|
|
101
|
+
collector.recordFail('no_test_simplification', 'error');
|
|
102
102
|
|
|
103
103
|
const traces = collector.read();
|
|
104
104
|
expect(traces.length).toBe(1);
|
|
@@ -110,13 +110,13 @@ describe('TraceCollector', () => {
|
|
|
110
110
|
it('应该返回所有 traces', () => {
|
|
111
111
|
collector.record({
|
|
112
112
|
constraintId: 'test1',
|
|
113
|
-
|
|
113
|
+
severity: 'error',
|
|
114
114
|
timestamp: 1000,
|
|
115
115
|
result: 'pass',
|
|
116
116
|
});
|
|
117
117
|
collector.record({
|
|
118
118
|
constraintId: 'test2',
|
|
119
|
-
|
|
119
|
+
severity: 'warning',
|
|
120
120
|
timestamp: 2000,
|
|
121
121
|
result: 'fail',
|
|
122
122
|
});
|
|
@@ -128,19 +128,19 @@ describe('TraceCollector', () => {
|
|
|
128
128
|
it('应该按时间范围过滤', () => {
|
|
129
129
|
collector.record({
|
|
130
130
|
constraintId: 'test1',
|
|
131
|
-
|
|
131
|
+
severity: 'error',
|
|
132
132
|
timestamp: 1000,
|
|
133
133
|
result: 'pass',
|
|
134
134
|
});
|
|
135
135
|
collector.record({
|
|
136
136
|
constraintId: 'test2',
|
|
137
|
-
|
|
137
|
+
severity: 'error',
|
|
138
138
|
timestamp: 2000,
|
|
139
139
|
result: 'pass',
|
|
140
140
|
});
|
|
141
141
|
collector.record({
|
|
142
142
|
constraintId: 'test3',
|
|
143
|
-
|
|
143
|
+
severity: 'error',
|
|
144
144
|
timestamp: 3000,
|
|
145
145
|
result: 'pass',
|
|
146
146
|
});
|
|
@@ -155,18 +155,18 @@ describe('TraceCollector', () => {
|
|
|
155
155
|
it('应该按约束层级过滤', () => {
|
|
156
156
|
collector.record({
|
|
157
157
|
constraintId: 'test1',
|
|
158
|
-
|
|
158
|
+
severity: 'error',
|
|
159
159
|
timestamp: 1000,
|
|
160
160
|
result: 'pass',
|
|
161
161
|
});
|
|
162
162
|
collector.record({
|
|
163
163
|
constraintId: 'test2',
|
|
164
|
-
|
|
164
|
+
severity: 'warning',
|
|
165
165
|
timestamp: 2000,
|
|
166
166
|
result: 'pass',
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
-
const traces = collector.read({
|
|
169
|
+
const traces = collector.read({ severity: 'error' });
|
|
170
170
|
expect(traces.length).toBe(1);
|
|
171
171
|
});
|
|
172
172
|
});
|
|
@@ -176,13 +176,13 @@ describe('TraceCollector', () => {
|
|
|
176
176
|
const now = Date.now();
|
|
177
177
|
collector.record({
|
|
178
178
|
constraintId: 'old',
|
|
179
|
-
|
|
179
|
+
severity: 'error',
|
|
180
180
|
timestamp: now - 25 * 60 * 60 * 1000, // 25 小时前
|
|
181
181
|
result: 'pass',
|
|
182
182
|
});
|
|
183
183
|
collector.record({
|
|
184
184
|
constraintId: 'recent',
|
|
185
|
-
|
|
185
|
+
severity: 'error',
|
|
186
186
|
timestamp: now - 1 * 60 * 60 * 1000, // 1 小时前
|
|
187
187
|
result: 'pass',
|
|
188
188
|
});
|
|
@@ -197,13 +197,13 @@ describe('TraceCollector', () => {
|
|
|
197
197
|
it('应该按约束 ID 过滤', () => {
|
|
198
198
|
collector.record({
|
|
199
199
|
constraintId: 'no_bypass',
|
|
200
|
-
|
|
200
|
+
severity: 'error',
|
|
201
201
|
timestamp: 1000,
|
|
202
202
|
result: 'pass',
|
|
203
203
|
});
|
|
204
204
|
collector.record({
|
|
205
205
|
constraintId: 'other_constraint',
|
|
206
|
-
|
|
206
|
+
severity: 'warning',
|
|
207
207
|
timestamp: 2000,
|
|
208
208
|
result: 'pass',
|
|
209
209
|
});
|
|
@@ -218,13 +218,13 @@ describe('TraceCollector', () => {
|
|
|
218
218
|
it('应该返回统计信息', () => {
|
|
219
219
|
collector.record({
|
|
220
220
|
constraintId: 'test1',
|
|
221
|
-
|
|
221
|
+
severity: 'error',
|
|
222
222
|
timestamp: 1000,
|
|
223
223
|
result: 'pass',
|
|
224
224
|
});
|
|
225
225
|
collector.record({
|
|
226
226
|
constraintId: 'test2',
|
|
227
|
-
|
|
227
|
+
severity: 'error',
|
|
228
228
|
timestamp: 2000,
|
|
229
229
|
result: 'fail',
|
|
230
230
|
});
|