@fantasticit/sumi 0.10.2 → 0.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/README.md +5 -1
- package/dist/adapters.d.ts +15 -0
- package/dist/adapters.js +137 -9
- package/dist/adapters.js.map +1 -1
- package/dist/agent-hooks.js +32 -4
- package/dist/agent-hooks.js.map +1 -1
- package/dist/agents.js +53 -3
- package/dist/agents.js.map +1 -1
- package/dist/cli.js +42 -7
- package/dist/cli.js.map +1 -1
- package/dist/config-text.d.ts +7 -0
- package/dist/config-text.js +54 -0
- package/dist/config-text.js.map +1 -0
- package/dist/constraint-list.d.ts +20 -0
- package/dist/constraint-list.js +41 -0
- package/dist/constraint-list.js.map +1 -0
- package/dist/context.js +14 -2
- package/dist/context.js.map +1 -1
- package/dist/doctor-wiring.d.ts +12 -0
- package/dist/doctor-wiring.js +59 -0
- package/dist/doctor-wiring.js.map +1 -0
- package/dist/file-snapshot.d.ts +16 -0
- package/dist/file-snapshot.js +56 -0
- package/dist/file-snapshot.js.map +1 -0
- package/dist/hook-routing.d.ts +22 -0
- package/dist/hook-routing.js +95 -0
- package/dist/hook-routing.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/instructions.js +7 -5
- package/dist/instructions.js.map +1 -1
- package/dist/run-stats.d.ts +52 -0
- package/dist/run-stats.js +150 -0
- package/dist/run-stats.js.map +1 -0
- package/dist/task.js +5 -2
- package/dist/task.js.map +1 -1
- package/dist/vendor.js +12 -30
- package/dist/vendor.js.map +1 -1
- package/node_modules/@sumi/create/dist/scaffold.js +5 -7
- package/node_modules/@sumi/create/dist/scaffold.js.map +1 -1
- package/node_modules/@sumi/create/package.json +2 -1
- package/node_modules/@sumi/create/template/AGENTS.md +3 -0
- package/node_modules/@sumi/create/template/control/flows/check.flow.yaml +6 -1
- package/node_modules/@sumi/create/template/control/rubrics/behavior.yaml +1 -1
- package/node_modules/@sumi/create/template/control/rubrics/domain.yaml +1 -1
- package/node_modules/@sumi/create/template/control/rubrics/omission.yaml +1 -1
- package/node_modules/@sumi/create/template/control/rules/development.md +8 -0
- package/node_modules/@sumi/create/template/init/AGENTS.md +3 -0
- package/node_modules/@sumi/kernel/README.md +9 -8
- package/node_modules/@sumi/kernel/dist/brief.d.ts +1 -0
- package/node_modules/@sumi/kernel/dist/brief.js +6 -0
- package/node_modules/@sumi/kernel/dist/brief.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/engine.d.ts +7 -1
- package/node_modules/@sumi/kernel/dist/engine.js +94 -11
- package/node_modules/@sumi/kernel/dist/engine.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/flow.d.ts +2 -0
- package/node_modules/@sumi/kernel/dist/flow.js +3 -0
- package/node_modules/@sumi/kernel/dist/flow.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/index.d.ts +1 -0
- package/node_modules/@sumi/kernel/dist/index.js +1 -0
- package/node_modules/@sumi/kernel/dist/index.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/record.d.ts +7 -0
- package/node_modules/@sumi/kernel/dist/record.js +2 -0
- package/node_modules/@sumi/kernel/dist/record.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/registry.js +1 -0
- package/node_modules/@sumi/kernel/dist/registry.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/resume.d.ts +9 -0
- package/node_modules/@sumi/kernel/dist/resume.js +171 -0
- package/node_modules/@sumi/kernel/dist/resume.js.map +1 -0
- package/node_modules/@sumi/kernel/dist/scope.d.ts +2 -0
- package/node_modules/@sumi/kernel/dist/scope.js +6 -2
- package/node_modules/@sumi/kernel/dist/scope.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/step-cache.d.ts +21 -1
- package/node_modules/@sumi/kernel/dist/step-cache.js +151 -15
- package/node_modules/@sumi/kernel/dist/step-cache.js.map +1 -1
- package/node_modules/@sumi/kernel/package.json +2 -2
- package/node_modules/@sumi/plugin-sdk/README.md +6 -2
- package/node_modules/@sumi/plugin-sdk/dist/files.d.ts +7 -0
- package/node_modules/@sumi/plugin-sdk/dist/files.js +17 -0
- package/node_modules/@sumi/plugin-sdk/dist/files.js.map +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/index.d.ts +3 -0
- package/node_modules/@sumi/plugin-sdk/dist/index.js +3 -0
- package/node_modules/@sumi/plugin-sdk/dist/index.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/protocol.d.ts +30 -4
- package/node_modules/@sumi/plugin-sdk/dist/protocol.js +28 -0
- package/node_modules/@sumi/plugin-sdk/dist/protocol.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/session-context.d.ts +26 -0
- package/node_modules/@sumi/plugin-sdk/dist/session-context.js +80 -11
- package/node_modules/@sumi/plugin-sdk/dist/session-context.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/shell.d.ts +54 -0
- package/node_modules/@sumi/plugin-sdk/dist/shell.js +635 -0
- package/node_modules/@sumi/plugin-sdk/dist/shell.js.map +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/snapshot.d.ts +8 -0
- package/node_modules/@sumi/plugin-sdk/dist/snapshot.js +18 -3
- package/node_modules/@sumi/plugin-sdk/dist/snapshot.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/source-files.d.ts +4 -0
- package/node_modules/@sumi/plugin-sdk/dist/source-files.js +11 -0
- package/node_modules/@sumi/plugin-sdk/dist/source-files.js.map +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/validate.js +14 -4
- package/node_modules/@sumi/plugin-sdk/dist/validate.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/package.json +1 -1
- package/node_modules/@sumi/plugins-core/README.md +12 -2
- package/node_modules/@sumi/plugins-core/dist/agent-rules.js +4 -10
- package/node_modules/@sumi/plugins-core/dist/agent-rules.js.map +1 -1
- package/node_modules/@sumi/plugins-core/dist/dependency-impact.d.ts +5 -4
- package/node_modules/@sumi/plugins-core/dist/dependency-impact.js +151 -49
- package/node_modules/@sumi/plugins-core/dist/dependency-impact.js.map +1 -1
- package/node_modules/@sumi/plugins-core/dist/plugins/coverage.js +9 -2
- package/node_modules/@sumi/plugins-core/dist/plugins/coverage.js.map +1 -1
- package/node_modules/@sumi/plugins-core/dist/plugins/lint.js +3 -2
- package/node_modules/@sumi/plugins-core/dist/plugins/lint.js.map +1 -1
- package/node_modules/@sumi/plugins-core/dist/plugins/test-affected.js +48 -32
- package/node_modules/@sumi/plugins-core/dist/plugins/test-affected.js.map +1 -1
- package/node_modules/@sumi/plugins-core/dist/test-scope.d.ts +2 -2
- package/node_modules/@sumi/plugins-core/dist/test-scope.js +13 -6
- package/node_modules/@sumi/plugins-core/dist/test-scope.js.map +1 -1
- package/node_modules/@sumi/plugins-core/instructions/bugfix.md +3 -3
- package/node_modules/@sumi/plugins-core/package.json +2 -2
- package/node_modules/@sumi/plugins-core/sumi-plugins.yaml +11 -3
- package/node_modules/@sumi/plugins-governance/dist/checkout.d.ts +8 -0
- package/node_modules/@sumi/plugins-governance/dist/checkout.js +18 -2
- package/node_modules/@sumi/plugins-governance/dist/checkout.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/gate.js +16 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/gate.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report.js +3 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/gate-cache.d.ts +3 -1
- package/node_modules/@sumi/plugins-governance/dist/gate-cache.js +16 -14
- package/node_modules/@sumi/plugins-governance/dist/gate-cache.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/guard.d.ts +0 -2
- package/node_modules/@sumi/plugins-governance/dist/guard.js +258 -90
- package/node_modules/@sumi/plugins-governance/dist/guard.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.d.ts +4 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.js +38 -9
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/state.js +5 -4
- package/node_modules/@sumi/plugins-governance/dist/state.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/workspace-runs.d.ts +21 -0
- package/node_modules/@sumi/plugins-governance/dist/workspace-runs.js +68 -0
- package/node_modules/@sumi/plugins-governance/dist/workspace-runs.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/instructions/push.md +6 -4
- package/node_modules/@sumi/plugins-governance/package.json +2 -2
- package/node_modules/@sumi/plugins-openspec/package.json +4 -4
- package/node_modules/@sumi/plugins-precedent/README.md +12 -7
- package/node_modules/@sumi/plugins-precedent/dist/after-edit-context.d.ts +5 -2
- package/node_modules/@sumi/plugins-precedent/dist/after-edit-context.js +188 -29
- package/node_modules/@sumi/plugins-precedent/dist/after-edit-context.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/commands/before-edit-context.js +4 -2
- package/node_modules/@sumi/plugins-precedent/dist/commands/before-edit-context.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/commands/on-prompt-context.js +16 -11
- package/node_modules/@sumi/plugins-precedent/dist/commands/on-prompt-context.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/commands/session-start-context.d.ts +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/commands/session-start-context.js +6 -0
- package/node_modules/@sumi/plugins-precedent/dist/commands/session-start-context.js.map +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact-state.js +5 -4
- package/node_modules/@sumi/plugins-precedent/dist/impact-state.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/plugins/context-read.d.ts +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/plugins/context-read.js +42 -0
- package/node_modules/@sumi/plugins-precedent/dist/plugins/context-read.js.map +1 -0
- package/node_modules/@sumi/plugins-precedent/package.json +3 -3
- package/node_modules/@sumi/plugins-precedent/sumi-plugins.yaml +18 -2
- package/node_modules/@sumi/plugins-review/README.md +13 -1
- package/node_modules/@sumi/plugins-review/dist/command-hint.d.ts +3 -0
- package/node_modules/@sumi/plugins-review/dist/command-hint.js +10 -0
- package/node_modules/@sumi/plugins-review/dist/command-hint.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/commands/context.js +7 -1
- package/node_modules/@sumi/plugins-review/dist/commands/context.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/commands/model-recheck.js +59 -44
- package/node_modules/@sumi/plugins-review/dist/commands/model-recheck.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/commands/submit.js +92 -31
- package/node_modules/@sumi/plugins-review/dist/commands/submit.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/dispute.d.ts +1 -1
- package/node_modules/@sumi/plugins-review/dist/dispute.js +4 -10
- package/node_modules/@sumi/plugins-review/dist/dispute.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/model-execution.d.ts +10 -1
- package/node_modules/@sumi/plugins-review/dist/model-execution.js +107 -29
- package/node_modules/@sumi/plugins-review/dist/model-execution.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/independent-recheck.js +2 -2
- package/node_modules/@sumi/plugins-review/dist/plugins/independent-recheck.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/rubric.js +120 -38
- package/node_modules/@sumi/plugins-review/dist/plugins/rubric.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/recheck.d.ts +1 -1
- package/node_modules/@sumi/plugins-review/dist/recheck.js +22 -9
- package/node_modules/@sumi/plugins-review/dist/recheck.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/review-evidence.d.ts +7 -1
- package/node_modules/@sumi/plugins-review/dist/review-evidence.js +44 -2
- package/node_modules/@sumi/plugins-review/dist/review-evidence.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/review.d.ts +42 -7
- package/node_modules/@sumi/plugins-review/dist/review.js +170 -48
- package/node_modules/@sumi/plugins-review/dist/review.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/submission.d.ts +8 -1
- package/node_modules/@sumi/plugins-review/dist/submission.js +61 -8
- package/node_modules/@sumi/plugins-review/dist/submission.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/upgrade-flow-plan.js +9 -0
- package/node_modules/@sumi/plugins-review/dist/upgrade-flow-plan.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/upgrade.js +25 -5
- package/node_modules/@sumi/plugins-review/dist/upgrade.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/validation-receipt.js +3 -0
- package/node_modules/@sumi/plugins-review/dist/validation-receipt.js.map +1 -1
- package/node_modules/@sumi/plugins-review/package.json +5 -5
- package/package.json +10 -10
- package/dist/trace.d.ts +0 -16
- package/dist/trace.js +0 -30
- package/dist/trace.js.map +0 -1
- package/node_modules/@sumi/create/dist/bin.d.ts +0 -2
- package/node_modules/@sumi/create/dist/bin.js +0 -52
- package/node_modules/@sumi/create/dist/bin.js.map +0 -1
- package/node_modules/@sumi/plugins-core/dist/tool-batches.d.ts +0 -11
- package/node_modules/@sumi/plugins-core/dist/tool-batches.js +0 -41
- package/node_modules/@sumi/plugins-core/dist/tool-batches.js.map +0 -1
- package/node_modules/@sumi/plugins-governance/dist/hooks.d.ts +0 -2
- package/node_modules/@sumi/plugins-governance/dist/hooks.js +0 -4
- package/node_modules/@sumi/plugins-governance/dist/hooks.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ImpactRecord } from '@sumi/plugins-precedent';
|
|
2
|
+
import type { ModelSource } from './model-execution.js';
|
|
2
3
|
export interface RubricItem {
|
|
3
4
|
id: string;
|
|
4
5
|
question: string;
|
|
@@ -8,6 +9,8 @@ export interface RubricItem {
|
|
|
8
9
|
export interface Rubric {
|
|
9
10
|
id: string;
|
|
10
11
|
description?: string;
|
|
12
|
+
/** false 时项目停用该维度:评审步骤直接通过,约束查询不列出。 */
|
|
13
|
+
enabled?: boolean;
|
|
11
14
|
requireEvidence?: boolean;
|
|
12
15
|
areaDepth?: number;
|
|
13
16
|
items: RubricItem[];
|
|
@@ -30,6 +33,8 @@ export interface ReviewRequest {
|
|
|
30
33
|
repoRoot: string;
|
|
31
34
|
items: RequestItem[];
|
|
32
35
|
requireEvidence?: boolean;
|
|
36
|
+
/** 结论必须带有与票据绑定的宿主模型来源(独立复核的原评审需要);缺来源的结果不接受、不复用。 */
|
|
37
|
+
requireModelSource?: boolean;
|
|
33
38
|
impact?: ImpactRecord;
|
|
34
39
|
validationStep?: string;
|
|
35
40
|
validation?: ValidationEvidence[];
|
|
@@ -43,6 +48,8 @@ export interface IncrementalReview {
|
|
|
43
48
|
file: string;
|
|
44
49
|
patch: string;
|
|
45
50
|
}[];
|
|
51
|
+
/** 修复轮只改了失败结论定位的文件时,沿用来源结论、不再复评的通过条目。 */
|
|
52
|
+
carry?: string[];
|
|
46
53
|
}
|
|
47
54
|
export interface ValidationEvidence {
|
|
48
55
|
id: string;
|
|
@@ -59,6 +66,8 @@ export interface PriorReview {
|
|
|
59
66
|
key: string;
|
|
60
67
|
resultDigest: string;
|
|
61
68
|
verdicts: Verdict[];
|
|
69
|
+
/** 原判 fail、经独立复核并获人工裁决解除的条目;漏检审查不再争论这些条目,原结论保留。 */
|
|
70
|
+
resolved?: string[];
|
|
62
71
|
}
|
|
63
72
|
export interface Verdict {
|
|
64
73
|
item: string;
|
|
@@ -77,6 +86,10 @@ export interface Verdict {
|
|
|
77
86
|
}
|
|
78
87
|
export interface ReviewResult {
|
|
79
88
|
verdicts: Verdict[];
|
|
89
|
+
/** 新提交把来源与覆盖证据和结论写在同一个原子文件中;旧结果仍可读取独立记录。 */
|
|
90
|
+
acceptedTicket?: string;
|
|
91
|
+
modelSource?: ModelSource;
|
|
92
|
+
coverage?: ReviewCoverage;
|
|
80
93
|
}
|
|
81
94
|
export interface Ticket {
|
|
82
95
|
ticket: string;
|
|
@@ -90,8 +103,14 @@ export interface Ticket {
|
|
|
90
103
|
/** 项目配置中的区域(区域名 → glob 列表);没有配置文件或没有 zones 时为空,YAML 无法解析时抛错(由调用方处理)。 */
|
|
91
104
|
export declare function projectZones(root: string): Record<string, string[]>;
|
|
92
105
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
106
|
+
* 流程中作为开发约束的准则:项目流程目录下任一流程的 review/rubric 步骤引用、且该步骤不是 auditOf 漏检审查。
|
|
107
|
+
* 没有流程目录或流程无法解析时返回 null,由调用方退回全部准则。
|
|
108
|
+
*/
|
|
109
|
+
export declare function activeRubrics(root: string): Set<string> | null;
|
|
110
|
+
/**
|
|
111
|
+
* 登记在中立区、不属于 business 区域、却包含已跟踪源码文件的 glob。接入时未识别的源码目录会被登记为中立区,
|
|
112
|
+
* 使用 `zone:business` 的维度评审因此不会覆盖它们。与接入时的区域登记口径一致,不计工具配置、隐藏目录下的文件
|
|
113
|
+
* (任意层级,如 .storybook、docs/.vitepress,接入时不当作源码)与项目 exclude 的文件。配置无法读取或不在 git 仓库中时为空。
|
|
95
114
|
*/
|
|
96
115
|
export declare function neutralSourceGlobs(root: string): string[];
|
|
97
116
|
/**
|
|
@@ -133,6 +152,7 @@ export declare function requestKey(parts: {
|
|
|
133
152
|
}[];
|
|
134
153
|
impact?: ImpactRecord;
|
|
135
154
|
requireEvidence?: boolean;
|
|
155
|
+
requireModelSource?: boolean;
|
|
136
156
|
validationStep?: string;
|
|
137
157
|
validation?: ValidationEvidence[];
|
|
138
158
|
priorReview?: PriorReview;
|
|
@@ -146,7 +166,7 @@ export declare function isReviewResult(v: unknown): v is ReviewResult;
|
|
|
146
166
|
/** 读取已接受结果;不存在、不是合法 JSON 或形状不对时为 null(视为没有结果,需重新评审)。 */
|
|
147
167
|
export declare function readAccepted(root: string, key: string): ReviewResult | null;
|
|
148
168
|
export declare function writeAccepted(root: string, key: string, result: ReviewResult): void;
|
|
149
|
-
/**
|
|
169
|
+
/** 已接受评审的覆盖范围:新结果内嵌此证据,独立文件用于枚举候选键与兼容旧结果。 */
|
|
150
170
|
export interface ReviewCoverage {
|
|
151
171
|
rubricDigest: string;
|
|
152
172
|
items: {
|
|
@@ -163,6 +183,7 @@ export interface ReviewCoverage {
|
|
|
163
183
|
/** 评审时的基准;不进键。只有同一基准的记录才能证明"不在旧范围内的文件"当时与基准一致。 */
|
|
164
184
|
base?: string | null;
|
|
165
185
|
requireEvidence?: boolean;
|
|
186
|
+
requireModelSource?: boolean;
|
|
166
187
|
validationStep?: string;
|
|
167
188
|
validation?: ValidationEvidence[];
|
|
168
189
|
testScopes?: Record<string, string>;
|
|
@@ -177,7 +198,14 @@ export declare function writeCoverage(root: string, key: string, coverage: Revie
|
|
|
177
198
|
* 来源改变后仍能找回同一内容已接受的结论(含失败结论及绑定其键的裁决),不会重新派发评审。
|
|
178
199
|
*/
|
|
179
200
|
export declare function writeIncrementalAlias(root: string, request: ReviewRequest): void;
|
|
180
|
-
/**
|
|
201
|
+
/** 枚举同一基础键的已接受增量结果快照;失败优先,调用方再核验模型来源。 */
|
|
202
|
+
export declare function readIncrementalCandidates(root: string, baseKey: string): {
|
|
203
|
+
key: string;
|
|
204
|
+
result: ReviewResult;
|
|
205
|
+
}[];
|
|
206
|
+
/** 兼容只需要键的调用方。 */
|
|
207
|
+
export declare function readIncrementalAliases(root: string, baseKey: string): string[];
|
|
208
|
+
/** 兼容单键调用方;严格来源策略应遍历全部候选并跳过来源失效的结果。 */
|
|
181
209
|
export declare function readIncrementalAlias(root: string, baseKey: string): string | null;
|
|
182
210
|
export declare function reviewContents(root: string, blobs: Map<string, string>): Record<string, string>;
|
|
183
211
|
/**
|
|
@@ -186,16 +214,23 @@ export declare function reviewContents(root: string, blobs: Map<string, string>)
|
|
|
186
214
|
* 用于已推送分支再推送时,门禁的增量范围复用工作区按配置基准(相对主干的全部改动)完成的评审。
|
|
187
215
|
* 不通过的结果不按覆盖复用(理由可能针对范围外的文件),仍按键精确匹配。
|
|
188
216
|
*/
|
|
189
|
-
export declare function findCoveringReview(root: string, rubricDigest: string, items: RequestItem[], blobs: Map<string, string>, constraints?: Pick<ReviewRequest, 'validationStep' | 'validation' | 'priorReview' | 'requireEvidence'>, targetScopes?: Record<string, string>): {
|
|
217
|
+
export declare function findCoveringReview(root: string, rubricDigest: string, items: RequestItem[], blobs: Map<string, string>, constraints?: Pick<ReviewRequest, 'validationStep' | 'validation' | 'priorReview' | 'requireEvidence' | 'requireModelSource'>, targetScopes?: Record<string, string>): {
|
|
190
218
|
key: string;
|
|
191
219
|
result: ReviewResult;
|
|
192
220
|
} | null;
|
|
193
221
|
/**
|
|
194
|
-
*
|
|
222
|
+
* 把可信的旧结论(含失败结论)作为新一轮评审上下文;复评仍必须提交绑定当前内容的新结果。
|
|
195
223
|
* 当前条目可以包含旧评审范围之外的新文件(差异以基准为起点,仅限同一基准的来源);已在旧范围内却属于别的条目或区域的文件
|
|
196
224
|
* 没有被该条目看过,不能只给增量,退回完整评审。
|
|
225
|
+
* 来源有失败条目、条目范围不变且之后只改了失败结论定位的文件时,通过条目随请求携带(carry),只复评失败条目;
|
|
226
|
+
* 携带的通过结论引用的验证在本次必须仍为通过。
|
|
227
|
+
*/
|
|
228
|
+
export declare function findIncrementalReview(root: string, rubricDigest: string, items: RequestItem[], current: Map<string, string>, base: string | null, validation?: ValidationEvidence[]): IncrementalReview | null;
|
|
229
|
+
/**
|
|
230
|
+
* 同一准则内容、同一基准、同一条目文件范围下,各条目被判 fail 的已接受结果数(每份结果是一轮评审)。
|
|
231
|
+
* 共享状态目录由各 worktree 共用;按条目文件范围区分不同分支的改动,范围不同的结果不计入。
|
|
197
232
|
*/
|
|
198
|
-
export declare function
|
|
233
|
+
export declare function failRounds(root: string, rubricDigest: string, base: string | null, items: RequestItem[]): Map<string, number>;
|
|
199
234
|
export declare function resultDigest(result: ReviewResult): string;
|
|
200
235
|
export declare function ticketsDir(root: string): string;
|
|
201
236
|
/** 校验评审结果:覆盖全部适用条目,verdict 合法,fail 条目带文件定位。返回错误列表。 */
|
|
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
|
-
import { configFile, GIT_MAX_BUFFER, gitPaths } from '@sumi/plugin-sdk';
|
|
6
|
+
import { configFile, GIT_MAX_BUFFER, gitPaths, isSourceFile, isToolConfig, writeFileAtomic } from '@sumi/plugin-sdk';
|
|
7
7
|
import { stateDir } from '@sumi/plugins-governance';
|
|
8
8
|
import picomatch from 'picomatch';
|
|
9
9
|
import { parse } from 'yaml';
|
|
@@ -11,34 +11,60 @@ const sha256 = (text) => createHash('sha256').update(text).digest('hex');
|
|
|
11
11
|
const ZONE_PREFIX = 'zone:';
|
|
12
12
|
/** 项目配置中的区域(区域名 → glob 列表);没有配置文件或没有 zones 时为空,YAML 无法解析时抛错(由调用方处理)。 */
|
|
13
13
|
export function projectZones(root) {
|
|
14
|
+
return zonesOf(readConfig(root));
|
|
15
|
+
}
|
|
16
|
+
function readConfig(root) {
|
|
14
17
|
const file = configFile(root);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
return file ? parse(readFileSync(join(root, file), 'utf8')) : null;
|
|
19
|
+
}
|
|
20
|
+
const globList = (value) => (Array.isArray(value) ? value.filter((g) => typeof g === 'string') : []);
|
|
21
|
+
function zonesOf(config) {
|
|
22
|
+
const zones = config?.zones;
|
|
18
23
|
if (!zones || typeof zones !== 'object' || Array.isArray(zones))
|
|
19
24
|
return {};
|
|
20
25
|
return Object.fromEntries(Object.entries(zones).filter((entry) => Array.isArray(entry[1]) && entry[1].every((g) => typeof g === 'string')));
|
|
21
26
|
}
|
|
22
|
-
/** 源码文件(与 core/test-affected 的源码分类一致)。 */
|
|
23
|
-
const SOURCE = /\.(?:[cm]?[jt]sx?|vue|svelte|astro|css|scss|sass|less|styl)$/;
|
|
24
|
-
/** 工具配置(vite.config.ts、eslint.config.mjs 等)不是业务源码,与接入时的区域登记一致。 */
|
|
25
|
-
const TOOL_CONFIG = /\.config\.[cm]?[jt]s$/;
|
|
26
27
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
28
|
+
* 流程中作为开发约束的准则:项目流程目录下任一流程的 review/rubric 步骤引用、且该步骤不是 auditOf 漏检审查。
|
|
29
|
+
* 没有流程目录或流程无法解析时返回 null,由调用方退回全部准则。
|
|
30
|
+
*/
|
|
31
|
+
export function activeRubrics(root) {
|
|
32
|
+
try {
|
|
33
|
+
const flows = readConfig(root)?.flows;
|
|
34
|
+
const dir = join(root, typeof flows === 'string' ? flows : 'control/flows');
|
|
35
|
+
if (!existsSync(dir))
|
|
36
|
+
return null;
|
|
37
|
+
const used = new Set();
|
|
38
|
+
for (const file of readdirSync(dir).filter((name) => name.endsWith('.flow.yaml'))) {
|
|
39
|
+
const flow = parse(readFileSync(join(dir, file), 'utf8'));
|
|
40
|
+
if (!Array.isArray(flow?.steps))
|
|
41
|
+
return null;
|
|
42
|
+
for (const step of flow.steps) {
|
|
43
|
+
if (step?.use !== 'review/rubric' || typeof step.with?.rubric !== 'string' || step.with.auditOf !== undefined)
|
|
44
|
+
continue;
|
|
45
|
+
used.add(step.with.rubric);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return used;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 登记在中立区、不属于 business 区域、却包含已跟踪源码文件的 glob。接入时未识别的源码目录会被登记为中立区,
|
|
56
|
+
* 使用 `zone:business` 的维度评审因此不会覆盖它们。与接入时的区域登记口径一致,不计工具配置、隐藏目录下的文件
|
|
57
|
+
* (任意层级,如 .storybook、docs/.vitepress,接入时不当作源码)与项目 exclude 的文件。配置无法读取或不在 git 仓库中时为空。
|
|
29
58
|
*/
|
|
30
59
|
export function neutralSourceGlobs(root) {
|
|
31
60
|
try {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
return [];
|
|
35
|
-
const config = parse(readFileSync(join(root, file), 'utf8'));
|
|
36
|
-
const neutral = Array.isArray(config?.neutral) ? config.neutral.filter((g) => typeof g === 'string') : [];
|
|
37
|
-
const business = Array.isArray(config?.zones?.business) ? config.zones.business.filter((g) => typeof g === 'string') : [];
|
|
61
|
+
const config = readConfig(root);
|
|
62
|
+
const neutral = globList(config?.neutral);
|
|
38
63
|
if (!neutral.length)
|
|
39
64
|
return [];
|
|
40
|
-
const inBusiness = scopeMatcher(business);
|
|
41
|
-
const
|
|
65
|
+
const inBusiness = scopeMatcher(zonesOf(config).business ?? []);
|
|
66
|
+
const excluded = scopeMatcher(globList(config?.exclude));
|
|
67
|
+
const sources = gitPaths(root, ['ls-files']).filter((path) => isSourceFile(path) && !isToolConfig(path) && !/(?:^|\/)\./.test(path) && !inBusiness(path) && !excluded(path));
|
|
42
68
|
return neutral.filter((glob) => {
|
|
43
69
|
const match = picomatch(glob, { dot: true });
|
|
44
70
|
return sources.some((path) => match(path));
|
|
@@ -159,6 +185,7 @@ export function requestKey(parts) {
|
|
|
159
185
|
items: parts.items.map((i) => ({ id: i.id, files: i.files, ...(i.areas ? { areas: i.areas } : {}) })),
|
|
160
186
|
...(parts.impact ? { impact: parts.impact } : {}),
|
|
161
187
|
...(parts.requireEvidence ? { requireEvidence: true } : {}),
|
|
188
|
+
...(parts.requireModelSource ? { requireModelSource: true } : {}),
|
|
162
189
|
...(parts.validationStep ? { validationStep: parts.validationStep } : {}),
|
|
163
190
|
...(parts.validation
|
|
164
191
|
? {
|
|
@@ -214,7 +241,7 @@ export function readAccepted(root, key) {
|
|
|
214
241
|
return isReviewResult(value) ? value : null;
|
|
215
242
|
}
|
|
216
243
|
export function writeAccepted(root, key, result) {
|
|
217
|
-
|
|
244
|
+
writeFileAtomic(join(reviewsDir(root), `${key}.json`), JSON.stringify(result, null, 2));
|
|
218
245
|
}
|
|
219
246
|
function isCoverage(v) {
|
|
220
247
|
return (isRecord(v) &&
|
|
@@ -230,6 +257,7 @@ function isCoverage(v) {
|
|
|
230
257
|
(v.contents === undefined || (isRecord(v.contents) && Object.values(v.contents).every((c) => typeof c === 'string'))) &&
|
|
231
258
|
(v.base === undefined || v.base === null || typeof v.base === 'string') &&
|
|
232
259
|
(v.requireEvidence === undefined || v.requireEvidence === true) &&
|
|
260
|
+
(v.requireModelSource === undefined || v.requireModelSource === true) &&
|
|
233
261
|
(v.validationStep === undefined || typeof v.validationStep === 'string') &&
|
|
234
262
|
(v.validation === undefined ||
|
|
235
263
|
(Array.isArray(v.validation) &&
|
|
@@ -261,6 +289,7 @@ export function coverageKey(coverage) {
|
|
|
261
289
|
contentDigest: digestOfBlobs(files, coverage.blobs),
|
|
262
290
|
items: coverage.items,
|
|
263
291
|
requireEvidence: coverage.requireEvidence,
|
|
292
|
+
requireModelSource: coverage.requireModelSource,
|
|
264
293
|
validationStep: coverage.validationStep,
|
|
265
294
|
validation: coverage.validation,
|
|
266
295
|
priorReview: coverage.priorReview,
|
|
@@ -288,6 +317,7 @@ function testRows(raw, expected) {
|
|
|
288
317
|
}
|
|
289
318
|
function validationCovered(source, target, targetScopes) {
|
|
290
319
|
if (source.requireEvidence !== target.requireEvidence ||
|
|
320
|
+
source.requireModelSource !== target.requireModelSource ||
|
|
291
321
|
source.validationStep !== target.validationStep ||
|
|
292
322
|
JSON.stringify(source.priorReview) !== JSON.stringify(target.priorReview))
|
|
293
323
|
return false;
|
|
@@ -318,7 +348,7 @@ function coverageDir(root) {
|
|
|
318
348
|
return dir;
|
|
319
349
|
}
|
|
320
350
|
export function writeCoverage(root, key, coverage) {
|
|
321
|
-
|
|
351
|
+
writeFileAtomic(join(coverageDir(root), `${key}.json`), JSON.stringify(coverage));
|
|
322
352
|
}
|
|
323
353
|
function incrementalAliasDir(root) {
|
|
324
354
|
const dir = join(reviewsDir(root), 'incremental');
|
|
@@ -333,17 +363,65 @@ export function writeIncrementalAlias(root, request) {
|
|
|
333
363
|
if (!request.incrementalReview)
|
|
334
364
|
return;
|
|
335
365
|
const { incrementalReview: _, ...parts } = request;
|
|
336
|
-
|
|
366
|
+
writeFileAtomic(join(incrementalAliasDir(root), `${requestKey(parts)}.json`), JSON.stringify({ key: request.key }));
|
|
367
|
+
}
|
|
368
|
+
/** 枚举同一基础键的已接受增量结果快照;失败优先,调用方再核验模型来源。 */
|
|
369
|
+
export function readIncrementalCandidates(root, baseKey) {
|
|
370
|
+
const failing = [];
|
|
371
|
+
const passing = [];
|
|
372
|
+
for (const key of coverageCandidates(root).sort()) {
|
|
373
|
+
const accepted = readAccepted(root, key);
|
|
374
|
+
const coverage = coverageForAccepted(root, key, accepted);
|
|
375
|
+
if (!isCoverage(coverage) || !coverage.incrementalReview || coverageKey(coverage) !== key)
|
|
376
|
+
continue;
|
|
377
|
+
if (coverageKey({ ...coverage, incrementalReview: undefined }) !== baseKey)
|
|
378
|
+
continue;
|
|
379
|
+
// 不同增量来源可能并发提交,文件时间不是原子采用顺序;任何未解除的失败结论都优先。
|
|
380
|
+
if (!accepted)
|
|
381
|
+
continue;
|
|
382
|
+
if (accepted.verdicts.some((verdict) => verdict.verdict === 'fail'))
|
|
383
|
+
failing.push({ key, result: accepted });
|
|
384
|
+
else
|
|
385
|
+
passing.push({ key, result: accepted });
|
|
386
|
+
}
|
|
387
|
+
return [...failing, ...passing];
|
|
388
|
+
}
|
|
389
|
+
/** 兼容只需要键的调用方。 */
|
|
390
|
+
export function readIncrementalAliases(root, baseKey) {
|
|
391
|
+
return readIncrementalCandidates(root, baseKey).map((candidate) => candidate.key);
|
|
337
392
|
}
|
|
338
|
-
/**
|
|
393
|
+
/** 兼容单键调用方;严格来源策略应遍历全部候选并跳过来源失效的结果。 */
|
|
339
394
|
export function readIncrementalAlias(root, baseKey) {
|
|
340
|
-
|
|
341
|
-
|
|
395
|
+
return readIncrementalAliases(root, baseKey)[0] ?? null;
|
|
396
|
+
}
|
|
397
|
+
/** 新格式以结果内嵌证据为准;旧格式继续读取独立覆盖文件。 */
|
|
398
|
+
function coverageForAccepted(root, key, accepted) {
|
|
399
|
+
if (!accepted)
|
|
342
400
|
return null;
|
|
343
|
-
|
|
344
|
-
|
|
401
|
+
if (accepted.coverage !== undefined)
|
|
402
|
+
return accepted.coverage;
|
|
403
|
+
try {
|
|
404
|
+
return readJson(join(coverageDir(root), `${key}.json`));
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
345
407
|
return null;
|
|
346
|
-
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/** 已接受结果是提交点,独立索引写入失败时仍可从内嵌证据发现新结果。 */
|
|
411
|
+
function coverageCandidates(root) {
|
|
412
|
+
const keys = new Set();
|
|
413
|
+
try {
|
|
414
|
+
for (const name of readdirSync(coverageDir(root)))
|
|
415
|
+
if (/^[0-9a-f]{64}\.json$/.test(name))
|
|
416
|
+
keys.add(name.slice(0, -5));
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
// 独立索引损坏时仍从已接受结果枚举新格式候选键。
|
|
420
|
+
}
|
|
421
|
+
for (const name of readdirSync(reviewsDir(root)))
|
|
422
|
+
if (/^[0-9a-f]{64}\.json$/.test(name))
|
|
423
|
+
keys.add(name.slice(0, -5));
|
|
424
|
+
return [...keys];
|
|
347
425
|
}
|
|
348
426
|
const isBlob = (value) => /^[0-9a-f]{40,64}$/.test(value);
|
|
349
427
|
export function reviewContents(root, blobs) {
|
|
@@ -370,16 +448,13 @@ export function reviewContents(root, blobs) {
|
|
|
370
448
|
* 不通过的结果不按覆盖复用(理由可能针对范围外的文件),仍按键精确匹配。
|
|
371
449
|
*/
|
|
372
450
|
export function findCoveringReview(root, rubricDigest, items, blobs, constraints = {}, targetScopes = {}) {
|
|
373
|
-
const
|
|
374
|
-
for (const name of readdirSync(dir)
|
|
375
|
-
.filter((n) => n.endsWith('.json'))
|
|
376
|
-
.sort()) {
|
|
451
|
+
for (const key of coverageCandidates(root).sort()) {
|
|
377
452
|
// 形状不对的记录跳过,单个坏文件不影响其他评审
|
|
378
|
-
const
|
|
453
|
+
const accepted = readAccepted(root, key);
|
|
454
|
+
const coverage = coverageForAccepted(root, key, accepted);
|
|
379
455
|
if (!isCoverage(coverage) || coverage.rubricDigest !== rubricDigest)
|
|
380
456
|
continue;
|
|
381
457
|
// 记录必须与其键绑定:由记录内容重算的请求键等于文件名,且该键有已接受结果
|
|
382
|
-
const key = name.slice(0, -'.json'.length);
|
|
383
458
|
if (coverageKey(coverage) !== key)
|
|
384
459
|
continue;
|
|
385
460
|
const sourceFiles = [...new Set(coverage.items.flatMap((i) => i.files))];
|
|
@@ -399,7 +474,6 @@ export function findCoveringReview(root, rubricDigest, items, blobs, constraints
|
|
|
399
474
|
});
|
|
400
475
|
if (!covered)
|
|
401
476
|
continue;
|
|
402
|
-
const accepted = readAccepted(root, key);
|
|
403
477
|
// 返回完整结果:需人工确认的准则按该评审的键与结果摘要绑定,工作区已完成的确认在门禁同样有效
|
|
404
478
|
if (accepted && items.every((item) => accepted.verdicts.find((v) => v.item === item.id)?.verdict === 'pass'))
|
|
405
479
|
return { key, result: accepted };
|
|
@@ -498,29 +572,28 @@ function verifiedPatch(root, file, raw, after) {
|
|
|
498
572
|
return patch;
|
|
499
573
|
}
|
|
500
574
|
/**
|
|
501
|
-
*
|
|
575
|
+
* 把可信的旧结论(含失败结论)作为新一轮评审上下文;复评仍必须提交绑定当前内容的新结果。
|
|
502
576
|
* 当前条目可以包含旧评审范围之外的新文件(差异以基准为起点,仅限同一基准的来源);已在旧范围内却属于别的条目或区域的文件
|
|
503
577
|
* 没有被该条目看过,不能只给增量,退回完整评审。
|
|
578
|
+
* 来源有失败条目、条目范围不变且之后只改了失败结论定位的文件时,通过条目随请求携带(carry),只复评失败条目;
|
|
579
|
+
* 携带的通过结论引用的验证在本次必须仍为通过。
|
|
504
580
|
*/
|
|
505
|
-
export function findIncrementalReview(root, rubricDigest, items, current, base) {
|
|
581
|
+
export function findIncrementalReview(root, rubricDigest, items, current, base, validation) {
|
|
506
582
|
const files = [...new Set(items.flatMap((item) => item.files))].sort();
|
|
507
|
-
const
|
|
508
|
-
const modified = (file) => {
|
|
583
|
+
const modified = (key) => {
|
|
509
584
|
try {
|
|
510
|
-
return statSync(join(
|
|
585
|
+
return statSync(join(reviewsDir(root), `${key}.json`)).mtimeMs;
|
|
511
586
|
}
|
|
512
587
|
catch {
|
|
513
588
|
return 0;
|
|
514
589
|
}
|
|
515
590
|
};
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const source = readJson(join(dir, name));
|
|
591
|
+
const keys = coverageCandidates(root).sort((a, b) => modified(b) - modified(a) || b.localeCompare(a));
|
|
592
|
+
for (const key of keys) {
|
|
593
|
+
const accepted = readAccepted(root, key);
|
|
594
|
+
const source = coverageForAccepted(root, key, accepted);
|
|
521
595
|
if (!isCoverage(source) || source.rubricDigest !== rubricDigest)
|
|
522
596
|
continue;
|
|
523
|
-
const key = name.slice(0, -5);
|
|
524
597
|
if (coverageKey(source) !== key)
|
|
525
598
|
continue;
|
|
526
599
|
const seen = (file) => Object.hasOwn(source.blobs, file);
|
|
@@ -536,8 +609,10 @@ export function findIncrementalReview(root, rubricDigest, items, current, base)
|
|
|
536
609
|
continue;
|
|
537
610
|
if (!files.some(seen))
|
|
538
611
|
continue;
|
|
539
|
-
|
|
540
|
-
|
|
612
|
+
// 失败结论只在其条目仍在本次请求中时作为“是否修好”的上下文;本次不再评审的条目必须全部通过
|
|
613
|
+
const verdictOf = (id) => accepted?.verdicts.find((v) => v.item === id)?.verdict;
|
|
614
|
+
if (!accepted ||
|
|
615
|
+
!source.items.every((item) => verdictOf(item.id) === 'pass' || (verdictOf(item.id) && items.some((i) => i.id === item.id))))
|
|
541
616
|
continue;
|
|
542
617
|
const diffs = [];
|
|
543
618
|
let size = 0;
|
|
@@ -561,10 +636,57 @@ export function findIncrementalReview(root, rubricDigest, items, current, base)
|
|
|
561
636
|
}
|
|
562
637
|
if (!diffs.length)
|
|
563
638
|
continue;
|
|
564
|
-
|
|
639
|
+
const verdicts = accepted.verdicts.filter((verdict) => items.some((item) => item.id === verdict.item));
|
|
640
|
+
const carry = carriedItems(source, items, verdicts, diffs, validation);
|
|
641
|
+
return { key, verdicts, diffs, ...(carry.length ? { carry } : {}) };
|
|
565
642
|
}
|
|
566
643
|
return null;
|
|
567
644
|
}
|
|
645
|
+
const scopeOf = (item) => JSON.stringify({ id: item.id, files: item.files, areas: item.areas ?? null });
|
|
646
|
+
/** 修复轮可携带的通过条目:范围与来源一致、来源有失败条目、变化的文件全部是失败结论定位的文件。 */
|
|
647
|
+
function carriedItems(source, items, verdicts, diffs, validation) {
|
|
648
|
+
const failed = verdicts.filter((verdict) => verdict.verdict === 'fail');
|
|
649
|
+
if (!failed.length || source.items.length !== items.length)
|
|
650
|
+
return [];
|
|
651
|
+
const sameScope = items.every((item) => {
|
|
652
|
+
const old = source.items.find((entry) => entry.id === item.id);
|
|
653
|
+
return old && scopeOf(old) === scopeOf(item);
|
|
654
|
+
});
|
|
655
|
+
if (!sameScope)
|
|
656
|
+
return [];
|
|
657
|
+
const failedFiles = new Set(failed.map((verdict) => verdict.file));
|
|
658
|
+
if (!diffs.every((diff) => Object.hasOwn(source.blobs, diff.file) && failedFiles.has(diff.file)))
|
|
659
|
+
return [];
|
|
660
|
+
const passing = (id) => validation?.some((entry) => entry.id === id && entry.state === 'pass') ?? false;
|
|
661
|
+
// 只携带来源本轮实际评审过的结论:来源自己携带的条目不再沿用,避免跨多轮累积未复核的差异
|
|
662
|
+
const carriedBySource = new Set(source.incrementalReview?.carry ?? []);
|
|
663
|
+
return verdicts
|
|
664
|
+
.filter((verdict) => verdict.verdict === 'pass' && !carriedBySource.has(verdict.item) && (verdict.testEvidence ?? []).every(passing))
|
|
665
|
+
.map((verdict) => verdict.item);
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* 同一准则内容、同一基准、同一条目文件范围下,各条目被判 fail 的已接受结果数(每份结果是一轮评审)。
|
|
669
|
+
* 共享状态目录由各 worktree 共用;按条目文件范围区分不同分支的改动,范围不同的结果不计入。
|
|
670
|
+
*/
|
|
671
|
+
export function failRounds(root, rubricDigest, base, items) {
|
|
672
|
+
const counts = new Map();
|
|
673
|
+
for (const key of coverageCandidates(root)) {
|
|
674
|
+
const accepted = readAccepted(root, key);
|
|
675
|
+
const coverage = coverageForAccepted(root, key, accepted);
|
|
676
|
+
if (!accepted || !isCoverage(coverage) || coverage.rubricDigest !== rubricDigest || (coverage.base ?? null) !== base)
|
|
677
|
+
continue;
|
|
678
|
+
if (coverageKey(coverage) !== key)
|
|
679
|
+
continue;
|
|
680
|
+
for (const item of items) {
|
|
681
|
+
const reviewed = coverage.items.find((entry) => entry.id === item.id);
|
|
682
|
+
if (!reviewed || JSON.stringify(reviewed.files) !== JSON.stringify(item.files))
|
|
683
|
+
continue;
|
|
684
|
+
if (accepted.verdicts.some((verdict) => verdict.item === item.id && verdict.verdict === 'fail'))
|
|
685
|
+
counts.set(item.id, (counts.get(item.id) ?? 0) + 1);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
return counts;
|
|
689
|
+
}
|
|
568
690
|
export function resultDigest(result) {
|
|
569
691
|
return sha256(JSON.stringify(result));
|
|
570
692
|
}
|