@fantasticit/sumi 0.14.4 → 0.14.5
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/dist/context-providers.js +1 -3
- package/dist/context-providers.js.map +1 -1
- package/dist/launcher.cjs +209 -155
- package/node_modules/@sumi/create/package.json +2 -2
- package/node_modules/@sumi/create/template/control/flows/change.flow.yaml +1 -1
- package/node_modules/@sumi/create/template/control/flows/check.flow.yaml +5 -0
- package/node_modules/@sumi/create/template/control/flows/checkpoint.flow.yaml +8 -0
- package/node_modules/@sumi/create/template/control/rubrics/slice.yaml +14 -0
- package/node_modules/@sumi/create/template/init/control/flows/change.flow.yaml +1 -1
- package/node_modules/@sumi/create/template/init/control/flows/check.flow.yaml +21 -0
- package/node_modules/@sumi/kernel/dist/config.d.ts +1 -6
- package/node_modules/@sumi/kernel/dist/config.js +5 -16
- package/node_modules/@sumi/kernel/dist/config.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/engine.js +5 -1
- package/node_modules/@sumi/kernel/dist/engine.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/flow.d.ts +1 -0
- package/node_modules/@sumi/kernel/dist/flow.js +9 -1
- package/node_modules/@sumi/kernel/dist/flow.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/plan.d.ts +2 -0
- package/node_modules/@sumi/kernel/dist/plan.js +8 -1
- package/node_modules/@sumi/kernel/dist/plan.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/registry.d.ts +2 -3
- package/node_modules/@sumi/kernel/dist/registry.js +5 -6
- package/node_modules/@sumi/kernel/dist/registry.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/runtime.d.ts +11 -0
- package/node_modules/@sumi/kernel/dist/runtime.js +34 -2
- package/node_modules/@sumi/kernel/dist/runtime.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/step-cache.js +1 -0
- package/node_modules/@sumi/kernel/dist/step-cache.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/step.d.ts +1 -0
- package/node_modules/@sumi/kernel/dist/step.js +1 -0
- package/node_modules/@sumi/kernel/dist/step.js.map +1 -1
- package/node_modules/@sumi/kernel/package.json +2 -2
- package/node_modules/@sumi/plugin-sdk/README.md +8 -0
- package/node_modules/@sumi/plugin-sdk/dist/html-page.d.ts +10 -2
- package/node_modules/@sumi/plugin-sdk/dist/html-page.js +14 -5
- package/node_modules/@sumi/plugin-sdk/dist/html-page.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/index.d.ts +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/index.js +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/index.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/protocol.d.ts +4 -0
- package/node_modules/@sumi/plugin-sdk/dist/protocol.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/scenario-selection.d.ts +20 -0
- package/node_modules/@sumi/plugin-sdk/dist/scenario-selection.js +18 -0
- package/node_modules/@sumi/plugin-sdk/dist/scenario-selection.js.map +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/validate.js +5 -0
- 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/dist/commands/context-impact.js +1 -3
- package/node_modules/@sumi/plugins-core/dist/commands/context-impact.js.map +1 -1
- package/node_modules/@sumi/plugins-core/package.json +2 -2
- package/node_modules/@sumi/plugins-governance/README.md +16 -1
- package/node_modules/@sumi/plugins-governance/dist/boundary-form.d.ts +18 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-form.js +97 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-form.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary.js +1 -1
- package/node_modules/@sumi/plugins-governance/dist/boundary.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/gate.js +0 -3
- package/node_modules/@sumi/plugins-governance/dist/commands/gate.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report.js +4 -0
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/run-policy.js +1 -3
- package/node_modules/@sumi/plugins-governance/dist/commands/run-policy.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/extensions.d.ts +2 -0
- package/node_modules/@sumi/plugins-governance/dist/extensions.js +32 -0
- package/node_modules/@sumi/plugins-governance/dist/extensions.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/plugins/size-budget.d.ts +1 -0
- package/node_modules/@sumi/plugins-governance/dist/plugins/size-budget.js +4 -0
- package/node_modules/@sumi/plugins-governance/dist/plugins/size-budget.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.js +23 -12
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/protected.d.ts +2 -0
- package/node_modules/@sumi/plugins-governance/dist/protected.js +4 -0
- package/node_modules/@sumi/plugins-governance/dist/protected.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/size-budget.d.ts +2 -0
- package/node_modules/@sumi/plugins-governance/dist/size-budget.js +73 -0
- package/node_modules/@sumi/plugins-governance/dist/size-budget.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/upgrade-command.js +12 -5
- package/node_modules/@sumi/plugins-governance/dist/upgrade-command.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/view-page.d.ts +1 -0
- package/node_modules/@sumi/plugins-governance/dist/view-page.js +19 -18
- package/node_modules/@sumi/plugins-governance/dist/view-page.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/instructions/boundary.md +1 -1
- package/node_modules/@sumi/plugins-governance/package.json +4 -4
- package/node_modules/@sumi/plugins-governance/sumi-plugins.yaml +6 -0
- package/node_modules/@sumi/plugins-openspec/README.md +36 -12
- package/node_modules/@sumi/plugins-openspec/dist/checkpoint-hook.d.ts +4 -0
- package/node_modules/@sumi/plugins-openspec/dist/checkpoint-hook.js +34 -0
- package/node_modules/@sumi/plugins-openspec/dist/checkpoint-hook.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/checkpoint-after-edit.d.ts +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/checkpoint-after-edit.js +9 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/checkpoint-after-edit.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/pr-dependencies.d.ts +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/pr-dependencies.js +10 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/pr-dependencies.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/size-groups.d.ts +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/size-groups.js +12 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/size-groups.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/slice-record.d.ts +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/slice-record.js +28 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/slice-record.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/index.d.ts +3 -0
- package/node_modules/@sumi/plugins-openspec/dist/index.js +3 -0
- package/node_modules/@sumi/plugins-openspec/dist/index.js.map +1 -1
- package/node_modules/@sumi/plugins-openspec/dist/plugins/change-tasks.js +7 -2
- package/node_modules/@sumi/plugins-openspec/dist/plugins/change-tasks.js.map +1 -1
- package/node_modules/@sumi/plugins-openspec/dist/plugins/planner.js +35 -0
- package/node_modules/@sumi/plugins-openspec/dist/plugins/planner.js.map +1 -1
- package/node_modules/@sumi/plugins-openspec/dist/slice-check.d.ts +3 -0
- package/node_modules/@sumi/plugins-openspec/dist/slice-check.js +13 -0
- package/node_modules/@sumi/plugins-openspec/dist/slice-check.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/slice-ledger.d.ts +19 -0
- package/node_modules/@sumi/plugins-openspec/dist/slice-ledger.js +179 -0
- package/node_modules/@sumi/plugins-openspec/dist/slice-ledger.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/slice.d.ts +2 -0
- package/node_modules/@sumi/plugins-openspec/dist/slice.js +134 -0
- package/node_modules/@sumi/plugins-openspec/dist/slice.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/task-groups.d.ts +12 -0
- package/node_modules/@sumi/plugins-openspec/dist/task-groups.js +21 -0
- package/node_modules/@sumi/plugins-openspec/dist/task-groups.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/upgrade-command.d.ts +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/upgrade-command.js +7 -0
- package/node_modules/@sumi/plugins-openspec/dist/upgrade-command.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/package.json +8 -4
- package/node_modules/@sumi/plugins-openspec/sumi-plugins.yaml +26 -0
- package/node_modules/@sumi/plugins-precedent/package.json +3 -3
- package/node_modules/@sumi/plugins-review/README.md +8 -0
- package/node_modules/@sumi/plugins-review/dist/batch-request.d.ts +4 -0
- package/node_modules/@sumi/plugins-review/dist/batch-request.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/checkpoint.d.ts +6 -0
- package/node_modules/@sumi/plugins-review/dist/checkpoint.js +76 -0
- package/node_modules/@sumi/plugins-review/dist/checkpoint.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/commands/preflight.js +0 -2
- package/node_modules/@sumi/plugins-review/dist/commands/preflight.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/commands/submit.js +14 -6
- package/node_modules/@sumi/plugins-review/dist/commands/submit.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/dispatch.d.ts +1 -0
- package/node_modules/@sumi/plugins-review/dist/dispatch.js +19 -12
- package/node_modules/@sumi/plugins-review/dist/dispatch.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/checkpoint-save.d.ts +1 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/checkpoint-save.js +4 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/checkpoint-save.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/checkpoint.d.ts +1 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/checkpoint.js +4 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/checkpoint.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/dispatch.js +15 -3
- package/node_modules/@sumi/plugins-review/dist/plugins/dispatch.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/validation.js +2 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/validation.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/preflight.js +17 -19
- package/node_modules/@sumi/plugins-review/dist/preflight.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/review-evidence.d.ts +2 -2
- package/node_modules/@sumi/plugins-review/dist/review-evidence.js +24 -12
- package/node_modules/@sumi/plugins-review/dist/review-evidence.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/review-scope.d.ts +3 -0
- package/node_modules/@sumi/plugins-review/dist/review-scope.js +25 -0
- package/node_modules/@sumi/plugins-review/dist/review-scope.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/review-slices.d.ts +13 -0
- package/node_modules/@sumi/plugins-review/dist/review-slices.js +59 -0
- package/node_modules/@sumi/plugins-review/dist/review-slices.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/review.d.ts +62 -22
- package/node_modules/@sumi/plugins-review/dist/review.js +252 -78
- package/node_modules/@sumi/plugins-review/dist/review.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/rubric-check.d.ts +3 -1
- package/node_modules/@sumi/plugins-review/dist/rubric-check.js +174 -53
- package/node_modules/@sumi/plugins-review/dist/rubric-check.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/startup-context.js +3 -2
- package/node_modules/@sumi/plugins-review/dist/startup-context.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/submission.js +75 -41
- package/node_modules/@sumi/plugins-review/dist/submission.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/submit-continuation.d.ts +2 -0
- package/node_modules/@sumi/plugins-review/dist/submit-continuation.js +143 -0
- package/node_modules/@sumi/plugins-review/dist/submit-continuation.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/support-scope.d.ts +2 -0
- package/node_modules/@sumi/plugins-review/dist/support-scope.js +15 -0
- package/node_modules/@sumi/plugins-review/dist/support-scope.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/tickets.d.ts +2 -0
- package/node_modules/@sumi/plugins-review/dist/tickets.js +41 -3
- package/node_modules/@sumi/plugins-review/dist/tickets.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/upgrade-flow-plan.js +27 -0
- package/node_modules/@sumi/plugins-review/dist/upgrade-flow-plan.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/upgrade.js +10 -1
- package/node_modules/@sumi/plugins-review/dist/upgrade.js.map +1 -1
- package/node_modules/@sumi/plugins-review/package.json +6 -6
- package/node_modules/@sumi/plugins-review/sumi-plugins.yaml +12 -0
- package/package.json +10 -10
|
@@ -7,6 +7,27 @@ import { configFile, GIT_MAX_BUFFER, gitPaths, isSourceFile, isToolConfig, withF
|
|
|
7
7
|
import { stateDir } from '@sumi/plugins-governance';
|
|
8
8
|
import picomatch from 'picomatch';
|
|
9
9
|
import { parse } from 'yaml';
|
|
10
|
+
export const REVIEW_KEY_VERSION = 2;
|
|
11
|
+
/** 定义与实际文件分别绑定,便于按条目核对内容及投影范围。 */
|
|
12
|
+
export function itemContents(rubricDigest, items, blobs, context = {}) {
|
|
13
|
+
return Object.fromEntries(items.map((item) => {
|
|
14
|
+
const impact = context.impact?.items.find((_entry, index) => item.id === `impact-${index + 1}`);
|
|
15
|
+
const definition = sha256(JSON.stringify({
|
|
16
|
+
rubricDigest,
|
|
17
|
+
id: item.id,
|
|
18
|
+
question: item.question,
|
|
19
|
+
pass: item.pass,
|
|
20
|
+
scope: item.scope,
|
|
21
|
+
boundaryDigest: context.boundaryDigest,
|
|
22
|
+
impact,
|
|
23
|
+
obligations: item.obligationTargets,
|
|
24
|
+
}));
|
|
25
|
+
return [item.id, { definition, key: itemContentKey(definition, item, blobs) }];
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
function itemContentKey(definition, item, blobs) {
|
|
29
|
+
return sha256(JSON.stringify({ definition, files: digestOfBlobs(item.files, blobs), areas: item.areas }));
|
|
30
|
+
}
|
|
10
31
|
export function ticketRunDir(ticket) {
|
|
11
32
|
let dir = dirname(ticket.requestPath);
|
|
12
33
|
for (const _ of ticket.stepId.split('/'))
|
|
@@ -213,19 +234,55 @@ export function applicableItems(rubric, files, forced) {
|
|
|
213
234
|
}
|
|
214
235
|
return out;
|
|
215
236
|
}
|
|
216
|
-
|
|
237
|
+
/** 只绑定首轮适用结论与有效解除项,来源快照仍在采用和提交时单独校验。 */
|
|
238
|
+
function priorReviewDigest(prior) {
|
|
217
239
|
return sha256(JSON.stringify({
|
|
240
|
+
verdicts: [...prior.verdicts].sort((a, b) => a.item.localeCompare(b.item)),
|
|
241
|
+
resolved: [...(prior.resolved ?? [])].sort(),
|
|
242
|
+
}, (_key, value) => isRecord(value) ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b))) : value));
|
|
243
|
+
}
|
|
244
|
+
export function requestKey(parts) {
|
|
245
|
+
if (parts.keyVersion !== undefined) {
|
|
246
|
+
if (parts.keyVersion !== REVIEW_KEY_VERSION || !parts.itemContents)
|
|
247
|
+
throw new Error('评审内容键版本或条目内容证据无效');
|
|
248
|
+
const items = parts.slice ? parts.items.filter((item) => parts.slice.reviewItems.includes(item.id)) : parts.items;
|
|
249
|
+
return sha256(JSON.stringify({
|
|
250
|
+
version: REVIEW_KEY_VERSION,
|
|
251
|
+
rubricDigest: parts.rubricDigest,
|
|
252
|
+
items,
|
|
253
|
+
itemContents: Object.fromEntries(items.map((item) => [item.id, parts.itemContents[item.id]])),
|
|
254
|
+
requireEvidence: parts.requireEvidence === true,
|
|
255
|
+
requireModelSource: parts.requireModelSource === true,
|
|
256
|
+
priorReviewDigest: parts.priorReview ? priorReviewDigest(parts.priorReview) : undefined,
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
// 无版本请求沿用旧算法,供旧完整提交与历史结果读取。
|
|
260
|
+
const partial = Boolean(parts.slice && parts.itemContents && parts.slice.reviewItems.length < parts.slice.applicableItems.length);
|
|
261
|
+
const items = partial ? parts.items.filter((item) => parts.slice.reviewItems.includes(item.id)) : parts.items;
|
|
262
|
+
const contents = partial ? Object.fromEntries(items.map((item) => [item.id, parts.itemContents[item.id]])) : parts.itemContents;
|
|
263
|
+
if (partial)
|
|
264
|
+
return sha256(JSON.stringify({
|
|
265
|
+
rubricDigest: parts.rubricDigest,
|
|
266
|
+
items,
|
|
267
|
+
itemContents: contents,
|
|
268
|
+
boundaryDigest: parts.boundaryDigest,
|
|
269
|
+
requireEvidence: parts.requireEvidence,
|
|
270
|
+
requireModelSource: parts.requireModelSource,
|
|
271
|
+
priorReviewDigest: parts.priorReview ? priorReviewDigest(parts.priorReview) : undefined,
|
|
272
|
+
}));
|
|
273
|
+
const identity = {
|
|
218
274
|
// 内容摘要覆盖被评审文件的内容;基准只影响"评审哪些文件",已由 items 的文件列表体现,因此不进键,
|
|
219
275
|
// 这样推送门禁(基准可能是空树或远端旧 OID)能复用工作区完成的评审。
|
|
220
276
|
rubricDigest: parts.rubricDigest,
|
|
221
|
-
...(
|
|
277
|
+
...(contents ? { itemContents: contents } : {}),
|
|
278
|
+
...(parts.itemContents ? { boundaryDigest: parts.boundaryDigest } : parts.supportScope ? { supportScope: parts.supportScope } : {}),
|
|
222
279
|
contentDigest: parts.contentDigest,
|
|
223
|
-
items: parts.items.map((i) => ({ id: i.id, files: i.files, ...(i.areas ? { areas: i.areas } : {}) })),
|
|
224
|
-
...(parts.impact ? { impact: parts.impact } : {}),
|
|
225
|
-
...(parts.requireEvidence ? { requireEvidence:
|
|
226
|
-
...(parts.requireModelSource ? { requireModelSource:
|
|
227
|
-
...(parts.validationStep ? { validationStep: parts.validationStep } : {}),
|
|
228
|
-
...(parts.validation
|
|
280
|
+
items: parts.itemContents ? items : items.map((i) => ({ id: i.id, files: i.files, ...(i.areas ? { areas: i.areas } : {}) })),
|
|
281
|
+
...(parts.impact ? { impact: parts.itemContents ? parts.impact.items : parts.impact } : {}),
|
|
282
|
+
...(parts.requireEvidence ? { requireEvidence: parts.requireEvidence } : {}),
|
|
283
|
+
...(parts.requireModelSource ? { requireModelSource: parts.requireModelSource } : {}),
|
|
284
|
+
...(!parts.itemContents && parts.validationStep ? { validationStep: parts.validationStep } : {}),
|
|
285
|
+
...(!parts.itemContents && parts.validation
|
|
229
286
|
? {
|
|
230
287
|
validation: parts.validation.map(({ id, step, required, state, summary, executionDigest }) => ({
|
|
231
288
|
id,
|
|
@@ -236,9 +293,14 @@ export function requestKey(parts) {
|
|
|
236
293
|
})),
|
|
237
294
|
}
|
|
238
295
|
: {}),
|
|
239
|
-
...(parts.priorReview
|
|
296
|
+
...(parts.priorReview
|
|
297
|
+
? parts.itemContents
|
|
298
|
+
? { priorReviewDigest: priorReviewDigest(parts.priorReview) }
|
|
299
|
+
: { priorReview: parts.priorReview }
|
|
300
|
+
: {}),
|
|
240
301
|
...(parts.incrementalReview ? { incrementalReview: parts.incrementalReview } : {}),
|
|
241
|
-
}
|
|
302
|
+
};
|
|
303
|
+
return sha256(JSON.stringify(identity));
|
|
242
304
|
}
|
|
243
305
|
/** 每一条业务影响判断分别评审,避免一条笼统的通过结论掩盖遗漏。 */
|
|
244
306
|
export function impactRequestItems(record) {
|
|
@@ -304,30 +366,27 @@ export function currentLineage(root) {
|
|
|
304
366
|
head: head.status === 0 ? head.stdout.trim() : '',
|
|
305
367
|
};
|
|
306
368
|
}
|
|
307
|
-
/**
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
function
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if (!ancestors.has(recorded.head))
|
|
319
|
-
ancestors.set(recorded.head, spawnSync('git', ['merge-base', '--is-ancestor', recorded.head, current.head], { cwd: root, windowsHide: true }).status === 0);
|
|
320
|
-
return ancestors.get(recorded.head);
|
|
369
|
+
/** 开发线只隔离轮次历史,历史改写不改变分支或 detached worktree 的身份。 */
|
|
370
|
+
function onCurrentLine(recorded, current) {
|
|
371
|
+
return Boolean(recorded && current && recorded.line === current.line);
|
|
372
|
+
}
|
|
373
|
+
function isCoverageItem(value, hasItemContents) {
|
|
374
|
+
return (isRecord(value) &&
|
|
375
|
+
typeof value.id === 'string' &&
|
|
376
|
+
isStrings(value.files) &&
|
|
377
|
+
(!hasItemContents || (typeof value.question === 'string' && typeof value.pass === 'string')) &&
|
|
378
|
+
(value.areas === undefined ||
|
|
379
|
+
(Array.isArray(value.areas) && value.areas.every((area) => isRecord(area) && typeof area.id === 'string' && isStrings(area.files)))));
|
|
321
380
|
}
|
|
322
381
|
function isCoverage(v) {
|
|
323
382
|
return (isRecord(v) &&
|
|
324
383
|
typeof v.rubricDigest === 'string' &&
|
|
384
|
+
(v.keyVersion === undefined || (v.keyVersion === REVIEW_KEY_VERSION && v.itemContents !== undefined)) &&
|
|
385
|
+
(v.itemContents === undefined ||
|
|
386
|
+
(isRecord(v.itemContents) &&
|
|
387
|
+
Object.values(v.itemContents).every((entry) => isRecord(entry) && typeof entry.definition === 'string' && typeof entry.key === 'string'))) &&
|
|
325
388
|
Array.isArray(v.items) &&
|
|
326
|
-
v.items.every((
|
|
327
|
-
typeof i.id === 'string' &&
|
|
328
|
-
isStrings(i.files) &&
|
|
329
|
-
(i.areas === undefined ||
|
|
330
|
-
(Array.isArray(i.areas) && i.areas.every((a) => isRecord(a) && typeof a.id === 'string' && isStrings(a.files))))) &&
|
|
389
|
+
v.items.every((item) => isCoverageItem(item, v.itemContents !== undefined)) &&
|
|
331
390
|
isRecord(v.blobs) &&
|
|
332
391
|
Object.values(v.blobs).every((b) => typeof b === 'string') &&
|
|
333
392
|
(v.contents === undefined || (isRecord(v.contents) && Object.values(v.contents).every((c) => typeof c === 'string'))) &&
|
|
@@ -362,6 +421,20 @@ function isCoverage(v) {
|
|
|
362
421
|
export function coverageKey(coverage) {
|
|
363
422
|
const files = [...new Set(coverage.items.flatMap((i) => i.files))];
|
|
364
423
|
return requestKey({
|
|
424
|
+
keyVersion: coverage.keyVersion,
|
|
425
|
+
slice: coverage.slice,
|
|
426
|
+
boundaryDigest: coverage.boundaryDigest,
|
|
427
|
+
impact: coverage.impact,
|
|
428
|
+
...(coverage.itemContents
|
|
429
|
+
? {
|
|
430
|
+
itemContents: coverage.keyVersion === REVIEW_KEY_VERSION
|
|
431
|
+
? itemContents(coverage.rubricDigest, coverage.items, coverage.blobs, {
|
|
432
|
+
boundaryDigest: coverage.boundaryDigest,
|
|
433
|
+
impact: coverage.impact,
|
|
434
|
+
})
|
|
435
|
+
: coverage.itemContents,
|
|
436
|
+
}
|
|
437
|
+
: {}),
|
|
365
438
|
rubricDigest: coverage.rubricDigest,
|
|
366
439
|
supportScope: coverage.supportScope,
|
|
367
440
|
contentDigest: digestOfBlobs(files, coverage.blobs),
|
|
@@ -393,7 +466,17 @@ function testRows(raw, expected) {
|
|
|
393
466
|
return null;
|
|
394
467
|
}
|
|
395
468
|
}
|
|
469
|
+
export function incompleteValidations(entries = []) {
|
|
470
|
+
return entries.filter((entry) => entry.required && entry.state !== 'pass');
|
|
471
|
+
}
|
|
396
472
|
function validationCovered(source, target, targetScopes) {
|
|
473
|
+
// 条目内容键的验证证据由本次运行读取并校验,旧执行摘要不限制内容复用。
|
|
474
|
+
if (target.itemContents)
|
|
475
|
+
return (source.requireEvidence === target.requireEvidence &&
|
|
476
|
+
source.requireModelSource === target.requireModelSource &&
|
|
477
|
+
(source.priorReview ? priorReviewDigest(source.priorReview) : undefined) ===
|
|
478
|
+
(target.priorReview ? priorReviewDigest(target.priorReview) : undefined) &&
|
|
479
|
+
incompleteValidations(target.validation).length === 0);
|
|
397
480
|
if (source.requireEvidence !== target.requireEvidence ||
|
|
398
481
|
source.requireModelSource !== target.requireModelSource ||
|
|
399
482
|
source.validationStep !== target.validationStep ||
|
|
@@ -518,6 +601,14 @@ export function reviewContents(root, blobs) {
|
|
|
518
601
|
}
|
|
519
602
|
return contents;
|
|
520
603
|
}
|
|
604
|
+
function itemCovered(coverage, item, blobs, identity) {
|
|
605
|
+
const reviewed = coverage.items.find((entry) => entry.id === item.id);
|
|
606
|
+
return Boolean(reviewed &&
|
|
607
|
+
(!identity || coverage.itemContents?.[item.id]?.definition === identity.definition) &&
|
|
608
|
+
item.files.every((file) => reviewed.files.includes(file) && coverage.blobs[file] === blobs.get(file)) &&
|
|
609
|
+
(!item.areas ||
|
|
610
|
+
item.areas.every((area) => reviewed.areas?.some((old) => old.id === area.id && area.files.every((file) => old.files.includes(file))))));
|
|
611
|
+
}
|
|
521
612
|
/**
|
|
522
613
|
* 找一份覆盖本次范围的已接受评审:同一准则内容,本次每个适用条目的文件都在该评审同一条目的范围内,
|
|
523
614
|
* 且这些文件的内容与评审时一致,该评审的这些条目全部通过。
|
|
@@ -525,11 +616,14 @@ export function reviewContents(root, blobs) {
|
|
|
525
616
|
* 不通过的结果不按覆盖复用(理由可能针对范围外的文件),仍按键精确匹配。
|
|
526
617
|
*/
|
|
527
618
|
export function findCoveringReview(root, rubricDigest, items, blobs, constraints = {}, targetScopes = {}) {
|
|
619
|
+
let passing = null;
|
|
528
620
|
for (const key of coverageCandidates(root).sort()) {
|
|
529
621
|
// 形状不对的记录跳过,单个坏文件不影响其他评审
|
|
530
622
|
const accepted = readAccepted(root, key);
|
|
531
623
|
const coverage = coverageForAccepted(root, key, accepted);
|
|
532
|
-
if (!isCoverage(coverage) ||
|
|
624
|
+
if (!isCoverage(coverage) ||
|
|
625
|
+
(constraints.keyVersion !== undefined && coverage.keyVersion !== constraints.keyVersion) ||
|
|
626
|
+
coverage.rubricDigest !== rubricDigest)
|
|
533
627
|
continue;
|
|
534
628
|
// 记录必须与其键绑定:由记录内容重算的请求键等于文件名,且该键有已接受结果
|
|
535
629
|
if (coverageKey(coverage) !== key)
|
|
@@ -537,26 +631,127 @@ export function findCoveringReview(root, rubricDigest, items, blobs, constraints
|
|
|
537
631
|
const sourceFiles = [...new Set(coverage.items.flatMap((i) => i.files))];
|
|
538
632
|
if (Object.keys(coverage.blobs).length !== sourceFiles.length || sourceFiles.some((f) => !Object.hasOwn(coverage.blobs, f)))
|
|
539
633
|
continue;
|
|
540
|
-
|
|
541
|
-
|
|
634
|
+
// 新条目身份只核对本次采用的文件;来源记录的完整性仍由 coverageKey 核验。
|
|
635
|
+
const checkedFiles = constraints.itemContents ? [...new Set(items.flatMap((item) => item.files))] : sourceFiles;
|
|
636
|
+
const current = fileBlobs(root, checkedFiles);
|
|
637
|
+
if (checkedFiles.some((f) => current.get(f) !== coverage.blobs[f]))
|
|
542
638
|
continue;
|
|
543
|
-
|
|
639
|
+
const sameBoundary = constraints.itemContents
|
|
640
|
+
? coverage.boundaryDigest === constraints.boundaryDigest
|
|
641
|
+
: coverage.supportScope === constraints.supportScope;
|
|
642
|
+
if (!sameBoundary || !validationCovered(coverage, constraints, targetScopes))
|
|
544
643
|
continue;
|
|
545
|
-
const covered = items.every((item) =>
|
|
546
|
-
const reviewed = coverage.items.find((i) => i.id === item.id);
|
|
547
|
-
return (reviewed &&
|
|
548
|
-
item.files.every((f) => reviewed.files.includes(f) && coverage.blobs[f] === blobs.get(f)) &&
|
|
549
|
-
(!item.areas ||
|
|
550
|
-
item.areas.every((area) => reviewed.areas?.some((a) => a.id === area.id && area.files.every((f) => a.files.includes(f))))));
|
|
551
|
-
});
|
|
644
|
+
const covered = items.every((item) => itemCovered(coverage, item, blobs, constraints.itemContents?.[item.id]));
|
|
552
645
|
if (!covered)
|
|
553
646
|
continue;
|
|
554
647
|
if (accepted &&
|
|
555
648
|
items.every((item) => {
|
|
556
649
|
const verdict = accepted.verdicts.find((v) => v.item === item.id);
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
650
|
+
if (!verdict)
|
|
651
|
+
return false;
|
|
652
|
+
if (isBlocking(verdict))
|
|
653
|
+
return Boolean(constraints.itemContents && coverage.itemContents?.[item.id]?.key === constraints.itemContents[item.id]?.key);
|
|
654
|
+
if (constraints.requireEvidence && !verdict.evidence?.trim())
|
|
655
|
+
return false;
|
|
656
|
+
return (!item.areas || item.areas.every((area) => verdict.areaEvidence?.some((entry) => entry.area === area.id && entry.evidence.trim())));
|
|
657
|
+
})) {
|
|
658
|
+
if (items.some((item) => accepted.verdicts.some((verdict) => verdict.item === item.id && isBlocking(verdict))))
|
|
659
|
+
return { key, result: accepted };
|
|
660
|
+
passing ??= { key, result: accepted };
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return passing;
|
|
664
|
+
}
|
|
665
|
+
/** 来源选择逐项进行,保留原始接受快照;索引或最近一次来源不决定复用资格。 */
|
|
666
|
+
export function findItemReviews(root, request, blobs, targetScopes, usable, unresolved) {
|
|
667
|
+
const selected = new Map();
|
|
668
|
+
for (const key of coverageCandidates(root).sort()) {
|
|
669
|
+
const accepted = readAccepted(root, key);
|
|
670
|
+
const coverage = coverageForAccepted(root, key, accepted);
|
|
671
|
+
if (!accepted || !isCoverage(coverage) || !coverage.itemContents)
|
|
672
|
+
continue;
|
|
673
|
+
if (coverage.keyVersion !== request.keyVersion || coverage.rubricDigest !== request.rubricDigest || coverageKey(coverage) !== key)
|
|
674
|
+
continue;
|
|
675
|
+
if (coverage.boundaryDigest !== request.boundaryDigest || !validationCovered(coverage, request, targetScopes) || !usable(key, accepted))
|
|
676
|
+
continue;
|
|
677
|
+
for (const item of request.items) {
|
|
678
|
+
const identity = coverage.itemContents[item.id];
|
|
679
|
+
if (!identity || identity.definition !== request.itemContents?.[item.id]?.definition)
|
|
680
|
+
continue;
|
|
681
|
+
if (!itemCovered(coverage, item, blobs, request.itemContents?.[item.id]))
|
|
682
|
+
continue;
|
|
683
|
+
const verdict = accepted.verdicts.find((entry) => entry.item === item.id);
|
|
684
|
+
if (!verdict)
|
|
685
|
+
continue;
|
|
686
|
+
// 失败只按完全相同的条目内容采用;窄投影不能把范围外的问题带入本次。
|
|
687
|
+
if (isBlocking(verdict) && identity.key !== request.itemContents?.[item.id]?.key)
|
|
688
|
+
continue;
|
|
689
|
+
if (isBlocking(verdict) && !unresolved(key, accepted, item.id))
|
|
690
|
+
continue;
|
|
691
|
+
if (request.requireEvidence && (typeof verdict.evidence !== 'string' || !verdict.evidence.trim()))
|
|
692
|
+
continue;
|
|
693
|
+
if (verdict.testEvidence?.some((id) => !request.validation?.some((entry) => entry.id === id && entry.state === 'pass')))
|
|
694
|
+
continue;
|
|
695
|
+
if (!isBlocking(verdict) &&
|
|
696
|
+
item.areas?.some((area) => !verdict.areaEvidence?.some((entry) => entry.area === area.id && entry.evidence.trim())))
|
|
697
|
+
continue;
|
|
698
|
+
const origin = itemReviewOrigin(root, key, accepted, item);
|
|
699
|
+
if (!origin || !usable(origin.key, origin.result))
|
|
700
|
+
continue;
|
|
701
|
+
const old = selected.get(item.id);
|
|
702
|
+
if (old && isBlocking(old.verdict) && !isBlocking(verdict))
|
|
703
|
+
continue;
|
|
704
|
+
if (old && isBlocking(old.verdict) === isBlocking(verdict) && (old.result.acceptedAt ?? 0) >= (accepted.acceptedAt ?? 0))
|
|
705
|
+
continue;
|
|
706
|
+
selected.set(item.id, origin);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return selected;
|
|
710
|
+
}
|
|
711
|
+
/** 组合回执只引用真实接受快照,不创建新的评审事实或丢失逐项来源。 */
|
|
712
|
+
export function readSelectedReview(root, key, sources) {
|
|
713
|
+
if (!sources)
|
|
714
|
+
return readAccepted(root, key);
|
|
715
|
+
const verdicts = [];
|
|
716
|
+
for (const [id, source] of Object.entries(sources)) {
|
|
717
|
+
const accepted = readAccepted(root, source.key);
|
|
718
|
+
if (!accepted || resultDigest(accepted) !== source.resultDigest)
|
|
719
|
+
return null;
|
|
720
|
+
if (!accepted.coverage || coverageKey(accepted.coverage) !== source.key)
|
|
721
|
+
return null;
|
|
722
|
+
const verdict = accepted.verdicts.find((entry) => entry.item === id);
|
|
723
|
+
if (!verdict)
|
|
724
|
+
return null;
|
|
725
|
+
verdicts.push(verdict);
|
|
726
|
+
}
|
|
727
|
+
return { verdicts };
|
|
728
|
+
}
|
|
729
|
+
export function projectVerdict(verdict, item) {
|
|
730
|
+
if (!item.areas || !verdict.areaEvidence)
|
|
731
|
+
return verdict;
|
|
732
|
+
return { ...verdict, areaEvidence: verdict.areaEvidence.filter((area) => item.areas.some((target) => target.id === area.area)) };
|
|
733
|
+
}
|
|
734
|
+
/** 连续沿用仍指向真正作出该项判断的接受快照,不能把中间轮提交者当成原评审者。 */
|
|
735
|
+
export function itemReviewOrigin(root, key, accepted, item) {
|
|
736
|
+
const seen = new Set();
|
|
737
|
+
let source = { key, result: accepted };
|
|
738
|
+
while (!seen.has(source.key)) {
|
|
739
|
+
seen.add(source.key);
|
|
740
|
+
const verdict = source.result.verdicts.find((entry) => entry.item === item.id);
|
|
741
|
+
if (!verdict)
|
|
742
|
+
return null;
|
|
743
|
+
const carried = source.result.coverage?.incrementalReview;
|
|
744
|
+
if (!carried?.carry?.includes(item.id))
|
|
745
|
+
return { ...source, verdict };
|
|
746
|
+
const reference = carried.itemSources?.[item.id];
|
|
747
|
+
const nextKey = reference?.key ?? carried.key;
|
|
748
|
+
const next = readAccepted(root, nextKey);
|
|
749
|
+
if (!next || (reference && resultDigest(next) !== reference.resultDigest))
|
|
750
|
+
return null;
|
|
751
|
+
const original = next.verdicts.find((entry) => entry.item === item.id);
|
|
752
|
+
if (!original || JSON.stringify(projectVerdict(original, item)) !== JSON.stringify(projectVerdict(verdict, item)))
|
|
753
|
+
return null;
|
|
754
|
+
source = { key: nextKey, result: next };
|
|
560
755
|
}
|
|
561
756
|
return null;
|
|
562
757
|
}
|
|
@@ -655,10 +850,9 @@ function verifiedPatch(root, file, raw, after) {
|
|
|
655
850
|
* 把可信的旧结论(含失败结论)作为新一轮评审上下文;复评仍必须提交绑定当前内容的新结果。
|
|
656
851
|
* 当前条目可以包含旧评审范围之外的新文件(差异以基准为起点,仅限同一基准的来源);已在旧范围内却属于别的条目或区域的文件
|
|
657
852
|
* 没有被该条目看过,不能只给增量,退回完整评审。
|
|
658
|
-
*
|
|
659
|
-
* 携带的通过结论引用的验证在本次必须仍为通过。
|
|
853
|
+
* 这里只提供增量正文;条目是否沿用由内容身份独立决定。
|
|
660
854
|
*/
|
|
661
|
-
export function findIncrementalReview(root, rubricDigest, items, current, base,
|
|
855
|
+
export function findIncrementalReview(root, rubricDigest, items, current, base, declaredScope, boundaryDigest) {
|
|
662
856
|
const files = [...new Set(items.flatMap((item) => item.files))].sort();
|
|
663
857
|
const dir = reviewsDir(root);
|
|
664
858
|
const modified = new Map(coverageCandidates(root).map((key) => {
|
|
@@ -670,15 +864,19 @@ export function findIncrementalReview(root, rubricDigest, items, current, base,
|
|
|
670
864
|
}
|
|
671
865
|
}));
|
|
672
866
|
const keys = [...modified.keys()].sort((a, b) => modified.get(b) - modified.get(a) || b.localeCompare(a));
|
|
673
|
-
//
|
|
867
|
+
// 增量参考只取当前开发线;按条目内容复用可以使用同仓库共享状态的其他来源。
|
|
674
868
|
const line = currentLineage(root);
|
|
675
|
-
const
|
|
676
|
-
for (const key of keys) {
|
|
869
|
+
const candidates = keys.map((key) => {
|
|
677
870
|
const accepted = readAccepted(root, key);
|
|
678
871
|
const source = coverageForAccepted(root, key, accepted);
|
|
679
|
-
|
|
872
|
+
return { key, accepted, source, sameLine: onCurrentLine(isCoverage(source) ? source.lineage : undefined, line) };
|
|
873
|
+
});
|
|
874
|
+
for (const { key, accepted, source, sameLine } of candidates) {
|
|
875
|
+
if (!isCoverage(source) || source.rubricDigest !== rubricDigest)
|
|
680
876
|
continue;
|
|
681
|
-
if (
|
|
877
|
+
if (boundaryDigest !== undefined ? source.boundaryDigest !== boundaryDigest : source.supportScope !== declaredScope)
|
|
878
|
+
continue;
|
|
879
|
+
if (coverageKey(source) !== key || !sameLine)
|
|
682
880
|
continue;
|
|
683
881
|
const seen = (file) => Object.hasOwn(source.blobs, file);
|
|
684
882
|
const unseenBy = (scope, list) => list.some((file) => seen(file) && !scope?.includes(file));
|
|
@@ -701,6 +899,7 @@ export function findIncrementalReview(root, rubricDigest, items, current, base,
|
|
|
701
899
|
return verdict && (!isBlocking(verdict) || items.some((i) => i.id === item.id));
|
|
702
900
|
}))
|
|
703
901
|
continue;
|
|
902
|
+
const verdicts = accepted.verdicts.filter((verdict) => items.some((item) => item.id === verdict.item));
|
|
704
903
|
const diffs = [];
|
|
705
904
|
let size = 0;
|
|
706
905
|
try {
|
|
@@ -723,45 +922,20 @@ export function findIncrementalReview(root, rubricDigest, items, current, base,
|
|
|
723
922
|
}
|
|
724
923
|
if (!diffs.length)
|
|
725
924
|
continue;
|
|
726
|
-
|
|
727
|
-
const carry = carriedItems(source, items, verdicts, diffs, validation);
|
|
728
|
-
return { key, verdicts, diffs, ...(carry.length ? { carry } : {}) };
|
|
925
|
+
return { key, verdicts, diffs };
|
|
729
926
|
}
|
|
730
927
|
return null;
|
|
731
928
|
}
|
|
732
|
-
const scopeOf = (item) => JSON.stringify({ id: item.id, files: item.files, areas: item.areas ?? null });
|
|
733
|
-
/** 修复轮可携带的通过条目:范围与来源一致、来源有失败条目、变化的文件全部是失败结论定位的文件。 */
|
|
734
|
-
function carriedItems(source, items, verdicts, diffs, validation) {
|
|
735
|
-
const failed = verdicts.filter(isBlocking);
|
|
736
|
-
if (!failed.length || source.items.length !== items.length)
|
|
737
|
-
return [];
|
|
738
|
-
const sameScope = items.every((item) => {
|
|
739
|
-
const old = source.items.find((entry) => entry.id === item.id);
|
|
740
|
-
return old && scopeOf(old) === scopeOf(item);
|
|
741
|
-
});
|
|
742
|
-
if (!sameScope)
|
|
743
|
-
return [];
|
|
744
|
-
const failedFiles = new Set(failed.flatMap((verdict) => [verdict.file, ...(verdict.files ?? [])]));
|
|
745
|
-
if (!diffs.every((diff) => Object.hasOwn(source.blobs, diff.file) && failedFiles.has(diff.file)))
|
|
746
|
-
return [];
|
|
747
|
-
const passing = (id) => validation?.some((entry) => entry.id === id && entry.state === 'pass') ?? false;
|
|
748
|
-
// 只携带来源本轮实际评审过的结论:来源自己携带的条目不再沿用,避免跨多轮累积未复核的差异
|
|
749
|
-
const carriedBySource = new Set(source.incrementalReview?.carry ?? []);
|
|
750
|
-
return verdicts
|
|
751
|
-
.filter((verdict) => !isBlocking(verdict) && !carriedBySource.has(verdict.item) && (verdict.testEvidence ?? []).every(passing))
|
|
752
|
-
.map((verdict) => verdict.item);
|
|
753
|
-
}
|
|
754
929
|
/** 同一分支、基准与准则的结论按接受时间排列,沿用现有覆盖键与开发线归档。 */
|
|
755
930
|
export function reviewHistory(root, rubricDigest, base) {
|
|
756
931
|
const current = currentLineage(root);
|
|
757
|
-
const ancestors = new Map();
|
|
758
932
|
return coverageCandidates(root)
|
|
759
933
|
.flatMap((key) => {
|
|
760
934
|
const accepted = readAccepted(root, key);
|
|
761
935
|
const coverage = coverageForAccepted(root, key, accepted);
|
|
762
936
|
if (!accepted || !isCoverage(coverage) || coverage.rubricDigest !== rubricDigest || (coverage.base ?? null) !== base)
|
|
763
937
|
return [];
|
|
764
|
-
if (coverageKey(coverage) !== key || !onCurrentLine(
|
|
938
|
+
if (coverageKey(coverage) !== key || !onCurrentLine(coverage.lineage, current))
|
|
765
939
|
return [];
|
|
766
940
|
return [{ key, result: accepted, time: accepted.acceptedAt ?? statSync(join(reviewsDir(root), `${key}.json`)).mtimeMs }];
|
|
767
941
|
})
|