@fantasticit/sumi 0.7.6 → 0.9.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 +18 -17
- package/dist/adapters.d.ts +3 -0
- package/dist/adapters.js +30 -4
- package/dist/adapters.js.map +1 -1
- package/dist/agent-hooks.d.ts +4 -1
- package/dist/agent-hooks.js +157 -12
- package/dist/agent-hooks.js.map +1 -1
- package/dist/cli.js +41 -2
- package/dist/cli.js.map +1 -1
- package/dist/context.js +4 -4
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/instructions.js +3 -1
- package/dist/instructions.js.map +1 -1
- package/dist/trace.d.ts +16 -0
- package/dist/trace.js +30 -0
- package/dist/trace.js.map +1 -0
- package/dist/visualize-page.d.ts +1 -0
- package/dist/visualize-page.js +49 -0
- package/dist/visualize-page.js.map +1 -0
- package/dist/visualize.d.ts +5 -0
- package/dist/visualize.js +176 -0
- package/dist/visualize.js.map +1 -0
- package/node_modules/@sumi/create/dist/scaffold.js +6 -0
- package/node_modules/@sumi/create/dist/scaffold.js.map +1 -1
- package/node_modules/@sumi/create/package.json +1 -1
- package/node_modules/@sumi/create/template/AGENTS.md +2 -0
- package/node_modules/@sumi/create/template/control/config.yaml +2 -0
- package/node_modules/@sumi/create/template/control/flows/change.flow.yaml +6 -0
- package/node_modules/@sumi/create/template/control/flows/check.flow.yaml +24 -0
- package/node_modules/@sumi/create/template/control/rubrics/behavior.yaml +17 -0
- package/node_modules/@sumi/create/template/control/rubrics/business-impact.yaml +6 -0
- package/node_modules/@sumi/create/template/control/rubrics/omission.yaml +13 -0
- package/node_modules/@sumi/create/template/control/rules/development.md +61 -0
- package/node_modules/@sumi/create/template/init/AGENTS.md +2 -0
- package/node_modules/@sumi/create/template/init/control/flows/check.flow.yaml +2 -0
- package/node_modules/@sumi/kernel/dist/brief.d.ts +1 -0
- package/node_modules/@sumi/kernel/dist/brief.js +1 -0
- package/node_modules/@sumi/kernel/dist/brief.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/engine.js +1 -0
- package/node_modules/@sumi/kernel/dist/engine.js.map +1 -1
- package/node_modules/@sumi/kernel/package.json +2 -2
- package/node_modules/@sumi/plugin-sdk/README.md +2 -2
- 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 +6 -0
- package/node_modules/@sumi/plugin-sdk/dist/protocol.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/trace.d.ts +16 -0
- package/node_modules/@sumi/plugin-sdk/dist/trace.js +58 -0
- package/node_modules/@sumi/plugin-sdk/dist/trace.js.map +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/validate.js +15 -3
- 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/agent-rules.d.ts +5 -0
- package/node_modules/@sumi/plugins-core/dist/agent-rules.js +66 -0
- package/node_modules/@sumi/plugins-core/dist/agent-rules.js.map +1 -0
- package/node_modules/@sumi/plugins-core/dist/commands/agent-rules-before-edit.d.ts +1 -0
- package/node_modules/@sumi/plugins-core/dist/commands/agent-rules-before-edit.js +10 -0
- package/node_modules/@sumi/plugins-core/dist/commands/agent-rules-before-edit.js.map +1 -0
- package/node_modules/@sumi/plugins-core/dist/commands/agent-rules-prompt.d.ts +1 -0
- package/node_modules/@sumi/plugins-core/dist/commands/agent-rules-prompt.js +8 -0
- package/node_modules/@sumi/plugins-core/dist/commands/agent-rules-prompt.js.map +1 -0
- package/node_modules/@sumi/plugins-core/dist/plugins/agent-rules.d.ts +1 -0
- package/node_modules/@sumi/plugins-core/dist/plugins/agent-rules.js +19 -0
- package/node_modules/@sumi/plugins-core/dist/plugins/agent-rules.js.map +1 -0
- package/node_modules/@sumi/plugins-core/dist/plugins/test-affected.js +107 -15
- package/node_modules/@sumi/plugins-core/dist/plugins/test-affected.js.map +1 -1
- package/node_modules/@sumi/plugins-core/package.json +2 -2
- package/node_modules/@sumi/plugins-core/sumi-plugins.yaml +20 -0
- package/node_modules/@sumi/plugins-governance/README.md +3 -3
- package/node_modules/@sumi/plugins-governance/dist/checkout.d.ts +2 -0
- package/node_modules/@sumi/plugins-governance/dist/checkout.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report-check.js +2 -0
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report-check.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report.js +3 -3
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-report-sections.d.ts +6 -0
- package/node_modules/@sumi/plugins-governance/dist/pr-report-sections.js +13 -0
- package/node_modules/@sumi/plugins-governance/dist/pr-report-sections.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/pr-report-status.d.ts +1 -0
- package/node_modules/@sumi/plugins-governance/dist/pr-report-status.js +15 -12
- package/node_modules/@sumi/plugins-governance/dist/pr-report-status.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/instructions/push.md +1 -1
- package/node_modules/@sumi/plugins-governance/package.json +2 -2
- package/node_modules/@sumi/plugins-openspec/dist/impact-consistency.d.ts +11 -0
- package/node_modules/@sumi/plugins-openspec/dist/impact-consistency.js +67 -0
- package/node_modules/@sumi/plugins-openspec/dist/impact-consistency.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/plugins/impact-consistency.d.ts +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/plugins/impact-consistency.js +63 -0
- package/node_modules/@sumi/plugins-openspec/dist/plugins/impact-consistency.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/package.json +4 -2
- package/node_modules/@sumi/plugins-openspec/sumi-plugins.yaml +6 -0
- package/node_modules/@sumi/plugins-precedent/dist/candidates.d.ts +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/commands/context.js +6 -0
- package/node_modules/@sumi/plugins-precedent/dist/commands/context.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/commands/impact-submit.d.ts +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/commands/impact-submit.js +21 -0
- package/node_modules/@sumi/plugins-precedent/dist/commands/impact-submit.js.map +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact-candidates.d.ts +6 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact-candidates.js +51 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact-candidates.js.map +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact-state.d.ts +14 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact-state.js +60 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact-state.js.map +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact.d.ts +52 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact.js +253 -0
- package/node_modules/@sumi/plugins-precedent/dist/impact.js.map +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/index.d.ts +2 -0
- package/node_modules/@sumi/plugins-precedent/dist/index.js +2 -0
- package/node_modules/@sumi/plugins-precedent/dist/index.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/plugins/harvest.js +31 -5
- package/node_modules/@sumi/plugins-precedent/dist/plugins/harvest.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/plugins/impact.d.ts +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/plugins/impact.js +60 -0
- package/node_modules/@sumi/plugins-precedent/dist/plugins/impact.js.map +1 -0
- package/node_modules/@sumi/plugins-precedent/package.json +3 -3
- package/node_modules/@sumi/plugins-precedent/sumi-plugins.yaml +9 -0
- package/node_modules/@sumi/plugins-review/README.md +37 -11
- package/node_modules/@sumi/plugins-review/dist/commands/host-model-hook.d.ts +1 -0
- package/node_modules/@sumi/plugins-review/dist/commands/host-model-hook.js +15 -0
- package/node_modules/@sumi/plugins-review/dist/commands/host-model-hook.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/commands/model-recheck.d.ts +1 -0
- package/node_modules/@sumi/plugins-review/dist/commands/model-recheck.js +71 -0
- package/node_modules/@sumi/plugins-review/dist/commands/model-recheck.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/commands/submit.js +32 -67
- package/node_modules/@sumi/plugins-review/dist/commands/submit.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/model-execution.d.ts +30 -0
- package/node_modules/@sumi/plugins-review/dist/model-execution.js +188 -0
- package/node_modules/@sumi/plugins-review/dist/model-execution.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/model-independence.d.ts +11 -0
- package/node_modules/@sumi/plugins-review/dist/model-independence.js +23 -0
- package/node_modules/@sumi/plugins-review/dist/model-independence.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/independent-recheck.d.ts +1 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/independent-recheck.js +108 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/independent-recheck.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/rubric.js +120 -9
- package/node_modules/@sumi/plugins-review/dist/plugins/rubric.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/validation.d.ts +1 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/validation.js +35 -0
- package/node_modules/@sumi/plugins-review/dist/plugins/validation.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/recheck.d.ts +52 -0
- package/node_modules/@sumi/plugins-review/dist/recheck.js +154 -0
- package/node_modules/@sumi/plugins-review/dist/recheck.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/review-evidence.d.ts +3 -0
- package/node_modules/@sumi/plugins-review/dist/review-evidence.js +58 -0
- package/node_modules/@sumi/plugins-review/dist/review-evidence.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/review.d.ts +58 -1
- package/node_modules/@sumi/plugins-review/dist/review.js +175 -11
- package/node_modules/@sumi/plugins-review/dist/review.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/submission.d.ts +11 -0
- package/node_modules/@sumi/plugins-review/dist/submission.js +115 -0
- package/node_modules/@sumi/plugins-review/dist/submission.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/validation-receipt.d.ts +8 -0
- package/node_modules/@sumi/plugins-review/dist/validation-receipt.js +110 -0
- package/node_modules/@sumi/plugins-review/dist/validation-receipt.js.map +1 -0
- package/node_modules/@sumi/plugins-review/package.json +4 -3
- package/node_modules/@sumi/plugins-review/sumi-plugins.yaml +21 -0
- package/package.json +10 -10
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { definePlugin, result } from '@sumi/plugin-sdk';
|
|
4
|
+
import { stepValidation } from '../validation-receipt.js';
|
|
5
|
+
const safeId = (value) => typeof value === 'string' && value.split('/').every((part) => /^[a-zA-Z0-9_-]+$/.test(part));
|
|
6
|
+
await definePlugin((ctx) => {
|
|
7
|
+
const raw = ctx.config.suites;
|
|
8
|
+
if (!Array.isArray(raw) || !raw.length)
|
|
9
|
+
return result({ status: 'blocked', summary: '缺少 with.suites 关键验证清单' });
|
|
10
|
+
const suites = [];
|
|
11
|
+
for (const value of raw) {
|
|
12
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
13
|
+
return result({ status: 'blocked', summary: '关键验证清单条目格式无效' });
|
|
14
|
+
const suite = value;
|
|
15
|
+
if (!safeId(suite.id) || !safeId(suite.step) || typeof suite.required !== 'boolean')
|
|
16
|
+
return result({ status: 'blocked', summary: '关键验证条目需要合法 id、step 和布尔 required' });
|
|
17
|
+
if (suite.step === ctx.stepId || suites.some((item) => item.id === suite.id || item.step === suite.step))
|
|
18
|
+
return result({ status: 'blocked', summary: `关键验证条目重复或循环引用:${suite.id}` });
|
|
19
|
+
suites.push({ id: suite.id, step: suite.step, required: suite.required });
|
|
20
|
+
}
|
|
21
|
+
const entries = suites.map((suite) => ({ ...suite, ...stepValidation(ctx.runDir, suite.step) }));
|
|
22
|
+
mkdirSync(ctx.evidenceDir, { recursive: true });
|
|
23
|
+
writeFileSync(join(ctx.evidenceDir, 'validation.json'), JSON.stringify(entries, null, 2));
|
|
24
|
+
const incomplete = entries.filter((entry) => entry.required && entry.state !== 'pass');
|
|
25
|
+
const rows = entries.map((entry) => `| ${entry.id} | \`${entry.step}\` | ${entry.required ? '是' : '否'} | ${entry.state === 'pass' ? '已通过' : entry.state === 'fail' ? '失败' : '未验证'} | ${entry.summary.replace(/\s*\n\s*/g, ' ').replace(/\|/g, '\\|')} |`);
|
|
26
|
+
return result({
|
|
27
|
+
status: incomplete.length ? 'blocked' : 'pass',
|
|
28
|
+
summary: incomplete.length
|
|
29
|
+
? `${incomplete.length} 项必需关键验证没有通过:${incomplete.map((item) => item.id).join('、')}`
|
|
30
|
+
: `关键验证 ${entries.filter((entry) => entry.state === 'pass').length}/${entries.length} 项通过`,
|
|
31
|
+
checked: ctx.files,
|
|
32
|
+
report: ['### 关键验证', '', '| 验证 | 执行步骤 | 必需 | 本次结果 | 执行回执 |', '| --- | --- | --- | --- | --- |', ...rows].join('\n'),
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/plugins/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,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,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CACvN,CAAC;IACF,OAAO,MAAM,CAAC;QACZ,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;QAC9C,OAAO,EAAE,UAAU,CAAC,MAAM;YACxB,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,gBAAgB,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACnF,CAAC,CAAC,QAAQ,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,MAAM;QAC5F,OAAO,EAAE,GAAG,CAAC,KAAK;QAClB,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;KACpH,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Finding } from '@sumi/plugin-sdk';
|
|
2
|
+
import { type ModelIdentity, type ModelSource } from './model-execution.js';
|
|
3
|
+
import type { RecheckPolicy } from './model-independence.js';
|
|
4
|
+
export interface RecheckIdentity {
|
|
5
|
+
vendor: string;
|
|
6
|
+
model: string;
|
|
7
|
+
}
|
|
8
|
+
export interface RecheckFinding extends Finding {
|
|
9
|
+
identity: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RecheckRequest {
|
|
12
|
+
policy?: RecheckPolicy;
|
|
13
|
+
acceptedKey: string;
|
|
14
|
+
acceptedDigest: string;
|
|
15
|
+
contentDigest: string;
|
|
16
|
+
original: ModelSource | null;
|
|
17
|
+
reviewer: RecheckIdentity;
|
|
18
|
+
stepId: string;
|
|
19
|
+
findings: RecheckFinding[];
|
|
20
|
+
}
|
|
21
|
+
export interface RecheckVerdict {
|
|
22
|
+
findingId: string;
|
|
23
|
+
verdict: 'confirm' | 'reject';
|
|
24
|
+
reason: string;
|
|
25
|
+
}
|
|
26
|
+
export interface RecheckResult {
|
|
27
|
+
verdicts: RecheckVerdict[];
|
|
28
|
+
}
|
|
29
|
+
export interface AcceptedRecheck {
|
|
30
|
+
result: RecheckResult;
|
|
31
|
+
source: ModelIdentity | null;
|
|
32
|
+
}
|
|
33
|
+
/** 同一宿主会话可能容纳多个子代理,只有代理标识才能区分共享会话中的上下文。 */
|
|
34
|
+
export declare function recheckContext(original: ModelIdentity | null, reviewer: ModelIdentity | null): 'same' | 'different' | 'unverified';
|
|
35
|
+
/** 身份包含原序号,避免同规则、甚至字段完全相同的两条 finding 被合并。 */
|
|
36
|
+
export declare function buildRecheckRequest(input: Omit<RecheckRequest, 'findings'> & {
|
|
37
|
+
findings: Finding[];
|
|
38
|
+
}): RecheckRequest;
|
|
39
|
+
export declare function recheckKey(request: RecheckRequest): string;
|
|
40
|
+
/** 返回首个错误;null 表示每条原 finding 恰有一条有效结论。 */
|
|
41
|
+
export declare function validateRecheckResult(request: RecheckRequest, value: unknown): string | null;
|
|
42
|
+
export declare function writeRecheck(root: string, request: RecheckRequest, result: RecheckResult, ticket: string, source: ModelIdentity | null): void;
|
|
43
|
+
export declare function readRecheck(root: string, request: RecheckRequest): AcceptedRecheck | null;
|
|
44
|
+
/** 从同一次运行中读取原评审,并重新核对共享结果和模型来源。 */
|
|
45
|
+
export declare function loadOriginalRecheckInput(root: string, runDir: string, sourceStepId: string, allowMissingSource?: boolean): {
|
|
46
|
+
acceptedKey: string;
|
|
47
|
+
acceptedDigest: string;
|
|
48
|
+
contentDigest: string;
|
|
49
|
+
original: ModelSource | null;
|
|
50
|
+
stepId: string;
|
|
51
|
+
findings: Finding[];
|
|
52
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { filesDigest, readAccepted, resultDigest, reviewsDir } from './review.js';
|
|
5
|
+
import { readModelSource, wasHostModelEventConsumed } from './model-execution.js';
|
|
6
|
+
const digest = (value) => createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
7
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
/** 同一宿主会话可能容纳多个子代理,只有代理标识才能区分共享会话中的上下文。 */
|
|
9
|
+
export function recheckContext(original, reviewer) {
|
|
10
|
+
if (!original || !reviewer)
|
|
11
|
+
return 'unverified';
|
|
12
|
+
if (original.host !== reviewer.host || original.sessionId !== reviewer.sessionId)
|
|
13
|
+
return 'different';
|
|
14
|
+
if (original.agentId && reviewer.agentId)
|
|
15
|
+
return original.agentId === reviewer.agentId ? 'same' : 'different';
|
|
16
|
+
return 'unverified';
|
|
17
|
+
}
|
|
18
|
+
/** 身份包含原序号,避免同规则、甚至字段完全相同的两条 finding 被合并。 */
|
|
19
|
+
export function buildRecheckRequest(input) {
|
|
20
|
+
return {
|
|
21
|
+
...input,
|
|
22
|
+
findings: input.findings
|
|
23
|
+
.filter((finding) => finding.severity === 'error')
|
|
24
|
+
.map((finding, index) => ({ ...finding, identity: digest({ stepId: input.stepId, index, finding }) })),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function recheckKey(request) {
|
|
28
|
+
return digest(request);
|
|
29
|
+
}
|
|
30
|
+
/** 返回首个错误;null 表示每条原 finding 恰有一条有效结论。 */
|
|
31
|
+
export function validateRecheckResult(request, value) {
|
|
32
|
+
if (!isRecord(value) || !Array.isArray(value.verdicts))
|
|
33
|
+
return '结果必须包含 verdicts 数组';
|
|
34
|
+
const expected = new Set(request.findings.map((f) => f.identity));
|
|
35
|
+
if (!expected.size)
|
|
36
|
+
return '原评审没有可复核的失败 finding';
|
|
37
|
+
const seen = new Set();
|
|
38
|
+
for (const item of value.verdicts) {
|
|
39
|
+
if (!isRecord(item) || typeof item.findingId !== 'string')
|
|
40
|
+
return '复核结论缺少 findingId';
|
|
41
|
+
if (!expected.has(item.findingId))
|
|
42
|
+
return `多余 finding ${item.findingId}`;
|
|
43
|
+
if (seen.has(item.findingId))
|
|
44
|
+
return `重复 finding ${item.findingId}`;
|
|
45
|
+
seen.add(item.findingId);
|
|
46
|
+
if (item.verdict !== 'confirm' && item.verdict !== 'reject')
|
|
47
|
+
return `finding ${item.findingId} 的 verdict 无效`;
|
|
48
|
+
if (typeof item.reason !== 'string' || !item.reason.trim())
|
|
49
|
+
return `finding ${item.findingId} 缺少理由`;
|
|
50
|
+
}
|
|
51
|
+
for (const id of expected)
|
|
52
|
+
if (!seen.has(id))
|
|
53
|
+
return `缺少 finding ${id}`;
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function cacheDir(root) {
|
|
57
|
+
const dir = join(reviewsDir(root), 'rechecks');
|
|
58
|
+
mkdirSync(dir, { recursive: true });
|
|
59
|
+
return dir;
|
|
60
|
+
}
|
|
61
|
+
export function writeRecheck(root, request, result, ticket, source) {
|
|
62
|
+
const error = validateRecheckResult(request, result);
|
|
63
|
+
if (error)
|
|
64
|
+
throw new Error(error);
|
|
65
|
+
if (request.policy !== 'independent-context' && (!request.original || !source))
|
|
66
|
+
throw new Error('独立模型复核缺少宿主模型来源');
|
|
67
|
+
if (source && (source.vendor !== request.reviewer.vendor || source.model !== request.reviewer.model))
|
|
68
|
+
throw new Error('复核宿主模型与目标模型不一致');
|
|
69
|
+
if (request.policy === 'independent-context' && recheckContext(request.original, source) === 'same')
|
|
70
|
+
throw new Error('原评审与复核使用同一宿主上下文');
|
|
71
|
+
const key = recheckKey(request);
|
|
72
|
+
if (source && !wasHostModelEventConsumed(root, ticket, 'model-recheck', source))
|
|
73
|
+
throw new Error('复核来源未绑定已消耗的宿主事件');
|
|
74
|
+
writeFileSync(join(cacheDir(root), `${key}.json`), JSON.stringify({ key, ticket, source, result }, null, 2));
|
|
75
|
+
}
|
|
76
|
+
export function readRecheck(root, request) {
|
|
77
|
+
const key = recheckKey(request);
|
|
78
|
+
try {
|
|
79
|
+
const value = JSON.parse(readFileSync(join(cacheDir(root), `${key}.json`), 'utf8'));
|
|
80
|
+
if (!isRecord(value) ||
|
|
81
|
+
value.key !== key ||
|
|
82
|
+
validateRecheckResult(request, value.result) ||
|
|
83
|
+
typeof value.ticket !== 'string' ||
|
|
84
|
+
!/^[a-f0-9]{16}$/.test(value.ticket))
|
|
85
|
+
return null;
|
|
86
|
+
const source = value.source;
|
|
87
|
+
if (request.policy === 'independent-context') {
|
|
88
|
+
const ticket = JSON.parse(readFileSync(join(reviewsDir(root), 'recheck-tickets', `${value.ticket}.json`), 'utf8'));
|
|
89
|
+
if (!isRecord(ticket) || ticket.used !== true || ticket.key !== key || ticket.policy !== 'independent-context')
|
|
90
|
+
return null;
|
|
91
|
+
if (source === null)
|
|
92
|
+
return { result: value.result, source: null };
|
|
93
|
+
}
|
|
94
|
+
if (!isRecord(source) ||
|
|
95
|
+
source.vendor !== request.reviewer.vendor ||
|
|
96
|
+
source.model !== request.reviewer.model ||
|
|
97
|
+
typeof source.sessionId !== 'string' ||
|
|
98
|
+
(source.agentId !== undefined && (typeof source.agentId !== 'string' || !source.agentId || source.agentId.length > 512)) ||
|
|
99
|
+
typeof source.eventId !== 'string' ||
|
|
100
|
+
(source.host !== 'codex' && source.host !== 'claude' && source.host !== 'cursor') ||
|
|
101
|
+
source.assurance !== (source.host === 'claude' ? 'session-model' : 'tool-model'))
|
|
102
|
+
return null;
|
|
103
|
+
if (request.policy === 'independent-context' && recheckContext(request.original, source) === 'same')
|
|
104
|
+
return null;
|
|
105
|
+
if (!wasHostModelEventConsumed(root, value.ticket, 'model-recheck', source))
|
|
106
|
+
return null;
|
|
107
|
+
return { result: value.result, source: source };
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** 从同一次运行中读取原评审,并重新核对共享结果和模型来源。 */
|
|
114
|
+
export function loadOriginalRecheckInput(root, runDir, sourceStepId, allowMissingSource = false) {
|
|
115
|
+
if (!sourceStepId.split('/').every((part) => /^[a-zA-Z0-9_-]+$/.test(part)))
|
|
116
|
+
throw new Error('原评审步骤 ID 不合法');
|
|
117
|
+
const dir = join(runDir, sourceStepId);
|
|
118
|
+
let step;
|
|
119
|
+
let receipt;
|
|
120
|
+
try {
|
|
121
|
+
step = JSON.parse(readFileSync(join(dir, 'result.json'), 'utf8'));
|
|
122
|
+
receipt = JSON.parse(readFileSync(join(dir, 'accepted-review.json'), 'utf8'));
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
throw new Error('原评审尚未形成可复核的已采用结果');
|
|
126
|
+
}
|
|
127
|
+
if (step.id !== sourceStepId ||
|
|
128
|
+
step.use !== 'review/rubric' ||
|
|
129
|
+
step.state !== 'fail' ||
|
|
130
|
+
!Array.isArray(step.findings) ||
|
|
131
|
+
!Array.isArray(step.checked))
|
|
132
|
+
throw new Error('原步骤不是含失败 finding 的 rubric 评审');
|
|
133
|
+
if (!/^[a-f0-9]{64}$/.test(receipt.key) || !/^[a-f0-9]{64}$/.test(receipt.resultDigest))
|
|
134
|
+
throw new Error('原评审回执格式无效');
|
|
135
|
+
const accepted = readAccepted(root, receipt.key);
|
|
136
|
+
if (!accepted || resultDigest(accepted) !== receipt.resultDigest)
|
|
137
|
+
throw new Error('原评审回执与已接受结果不一致');
|
|
138
|
+
const fails = accepted.verdicts.filter((v) => v.verdict === 'fail');
|
|
139
|
+
if (fails.length !== step.findings.length ||
|
|
140
|
+
!fails.every((v) => step.findings.some((f) => f.rule.endsWith(`#${v.item}`) && f.message === v.reason && f.file === v.file && f.line === v.line)))
|
|
141
|
+
throw new Error('原评审 finding 与已接受结论不一致');
|
|
142
|
+
const original = readModelSource(root, receipt.key, accepted);
|
|
143
|
+
if (!original && !allowMissingSource)
|
|
144
|
+
throw new Error('原评审缺少代理宿主模型来源;请在已接入 hook 的代理会话中重新评审');
|
|
145
|
+
return {
|
|
146
|
+
acceptedKey: receipt.key,
|
|
147
|
+
acceptedDigest: receipt.resultDigest,
|
|
148
|
+
contentDigest: filesDigest(root, step.checked),
|
|
149
|
+
original,
|
|
150
|
+
stepId: sourceStepId,
|
|
151
|
+
findings: step.findings,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=recheck.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recheck.js","sourceRoot":"","sources":["../src/recheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAwC,MAAM,sBAAsB,CAAC;AA8CxH,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpG,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAE5I,2CAA2C;AAC3C,MAAM,UA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
+
import { stepValidation } from './validation-receipt.js';
|
|
5
|
+
const safeStep = (step) => step.split('/').every((part) => /^[a-zA-Z0-9_-]+$/.test(part));
|
|
6
|
+
export function loadValidation(runDir, stepId) {
|
|
7
|
+
if (!safeStep(stepId))
|
|
8
|
+
throw new Error('关键验证步骤 ID 无效');
|
|
9
|
+
let entries;
|
|
10
|
+
try {
|
|
11
|
+
entries = JSON.parse(readFileSync(join(runDir, stepId, 'validation.json'), 'utf8'));
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
throw new Error(`关键验证 ${stepId} 尚无本次运行回执`);
|
|
15
|
+
}
|
|
16
|
+
if (!Array.isArray(entries) ||
|
|
17
|
+
!entries.every((entry) => entry &&
|
|
18
|
+
typeof entry.id === 'string' &&
|
|
19
|
+
typeof entry.step === 'string' &&
|
|
20
|
+
typeof entry.required === 'boolean' &&
|
|
21
|
+
typeof entry.state === 'string' &&
|
|
22
|
+
typeof entry.summary === 'string' &&
|
|
23
|
+
(entry.executionDigest === undefined ||
|
|
24
|
+
(typeof entry.executionDigest === 'string' && /^[a-f0-9]{64}$/.test(entry.executionDigest))) &&
|
|
25
|
+
(entry.sourceDigest === undefined || (typeof entry.sourceDigest === 'string' && /^[a-f0-9]{64}$/.test(entry.sourceDigest)))))
|
|
26
|
+
throw new Error(`关键验证 ${stepId} 回执格式无效`);
|
|
27
|
+
const current = entries.map(({ id, step, required }) => ({
|
|
28
|
+
id,
|
|
29
|
+
step,
|
|
30
|
+
required,
|
|
31
|
+
...stepValidation(runDir, step),
|
|
32
|
+
}));
|
|
33
|
+
if (JSON.stringify(current) !== JSON.stringify(entries))
|
|
34
|
+
throw new Error(`关键验证 ${stepId} 的底层执行证据已变化`);
|
|
35
|
+
return entries;
|
|
36
|
+
}
|
|
37
|
+
export function loadPriorReview(root, runDir, stepId) {
|
|
38
|
+
if (!safeStep(stepId))
|
|
39
|
+
throw new Error('首轮评审步骤 ID 无效');
|
|
40
|
+
let step;
|
|
41
|
+
let receipt;
|
|
42
|
+
try {
|
|
43
|
+
step = JSON.parse(readFileSync(join(runDir, stepId, 'result.json'), 'utf8'));
|
|
44
|
+
receipt = JSON.parse(readFileSync(join(runDir, stepId, 'accepted-review.json'), 'utf8'));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
throw new Error(`首轮评审 ${stepId} 尚无已接受结果`);
|
|
48
|
+
}
|
|
49
|
+
if (step.id !== stepId || step.use !== 'review/rubric' || step.state !== 'pass')
|
|
50
|
+
throw new Error(`首轮评审 ${stepId} 尚未通过`);
|
|
51
|
+
if (!/^[a-f0-9]{64}$/.test(receipt.key ?? '') || !/^[a-f0-9]{64}$/.test(receipt.resultDigest ?? ''))
|
|
52
|
+
throw new Error('首轮评审回执格式无效');
|
|
53
|
+
const accepted = readAccepted(root, receipt.key);
|
|
54
|
+
if (!accepted || resultDigest(accepted) !== receipt.resultDigest || accepted.verdicts.some((verdict) => verdict.verdict !== 'pass'))
|
|
55
|
+
throw new Error('首轮评审回执与已接受的通过结论不一致');
|
|
56
|
+
return { stepId, key: receipt.key, resultDigest: receipt.resultDigest, verdicts: accepted.verdicts };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=review-evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-evidence.js","sourceRoot":"","sources":["../src/review-evidence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,YAAY,EAA6C,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,I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AAC,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;QACjG,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,GAAI,CAAC,CAAC;IAClD,IAAI,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,MAAM,CAAC;QACjI,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,GAAI,EAAE,YAAY,EAAE,OAAO,CAAC,YAAa,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACzG,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ImpactRecord } from '@sumi/plugins-precedent';
|
|
1
2
|
export interface RubricItem {
|
|
2
3
|
id: string;
|
|
3
4
|
question: string;
|
|
@@ -7,11 +8,18 @@ export interface RubricItem {
|
|
|
7
8
|
export interface Rubric {
|
|
8
9
|
id: string;
|
|
9
10
|
description?: string;
|
|
11
|
+
requireEvidence?: boolean;
|
|
12
|
+
areaDepth?: number;
|
|
10
13
|
items: RubricItem[];
|
|
11
14
|
}
|
|
12
15
|
export interface RequestItem extends RubricItem {
|
|
13
16
|
/** 本次评审该条目的文件范围。 */
|
|
14
17
|
files: string[];
|
|
18
|
+
/** 需要逐区说明核查证据的文件分组。 */
|
|
19
|
+
areas?: {
|
|
20
|
+
id: string;
|
|
21
|
+
files: string[];
|
|
22
|
+
}[];
|
|
15
23
|
}
|
|
16
24
|
export interface ReviewRequest {
|
|
17
25
|
key: string;
|
|
@@ -21,11 +29,40 @@ export interface ReviewRequest {
|
|
|
21
29
|
contentDigest: string;
|
|
22
30
|
repoRoot: string;
|
|
23
31
|
items: RequestItem[];
|
|
32
|
+
requireEvidence?: boolean;
|
|
33
|
+
impact?: ImpactRecord;
|
|
34
|
+
validationStep?: string;
|
|
35
|
+
validation?: ValidationEvidence[];
|
|
36
|
+
priorReview?: PriorReview;
|
|
37
|
+
}
|
|
38
|
+
export interface ValidationEvidence {
|
|
39
|
+
id: string;
|
|
40
|
+
step: string;
|
|
41
|
+
required: boolean;
|
|
42
|
+
state: string;
|
|
43
|
+
summary: string;
|
|
44
|
+
executionDigest?: string;
|
|
45
|
+
/** 同次运行的原始证据完整性;不进入跨运行复用键。 */
|
|
46
|
+
sourceDigest?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface PriorReview {
|
|
49
|
+
stepId: string;
|
|
50
|
+
key: string;
|
|
51
|
+
resultDigest: string;
|
|
52
|
+
verdicts: Verdict[];
|
|
24
53
|
}
|
|
25
54
|
export interface Verdict {
|
|
26
55
|
item: string;
|
|
27
56
|
verdict: 'pass' | 'fail';
|
|
28
57
|
reason: string;
|
|
58
|
+
evidence?: string;
|
|
59
|
+
/** 只引用本次关键验证回执中确实通过的 suite ID。 */
|
|
60
|
+
testEvidence?: string[];
|
|
61
|
+
areaEvidence?: {
|
|
62
|
+
area: string;
|
|
63
|
+
evidence: string;
|
|
64
|
+
}[];
|
|
65
|
+
uncertain?: boolean;
|
|
29
66
|
file?: string;
|
|
30
67
|
line?: number;
|
|
31
68
|
}
|
|
@@ -65,8 +102,19 @@ export declare function requestKey(parts: {
|
|
|
65
102
|
items: {
|
|
66
103
|
id: string;
|
|
67
104
|
files: string[];
|
|
105
|
+
areas?: {
|
|
106
|
+
id: string;
|
|
107
|
+
files: string[];
|
|
108
|
+
}[];
|
|
68
109
|
}[];
|
|
110
|
+
impact?: ImpactRecord;
|
|
111
|
+
requireEvidence?: boolean;
|
|
112
|
+
validationStep?: string;
|
|
113
|
+
validation?: ValidationEvidence[];
|
|
114
|
+
priorReview?: PriorReview;
|
|
69
115
|
}): string;
|
|
116
|
+
/** 每一条业务影响判断分别评审,避免一条笼统的通过结论掩盖遗漏。 */
|
|
117
|
+
export declare function impactRequestItems(record: ImpactRecord): RequestItem[];
|
|
70
118
|
export declare function reviewsDir(root: string): string;
|
|
71
119
|
/** 已接受结果的形状:verdicts 数组,每项含字符串 item 与 pass/fail。 */
|
|
72
120
|
export declare function isReviewResult(v: unknown): v is ReviewResult;
|
|
@@ -79,8 +127,17 @@ export interface ReviewCoverage {
|
|
|
79
127
|
items: {
|
|
80
128
|
id: string;
|
|
81
129
|
files: string[];
|
|
130
|
+
areas?: {
|
|
131
|
+
id: string;
|
|
132
|
+
files: string[];
|
|
133
|
+
}[];
|
|
82
134
|
}[];
|
|
83
135
|
blobs: Record<string, string>;
|
|
136
|
+
requireEvidence?: boolean;
|
|
137
|
+
validationStep?: string;
|
|
138
|
+
validation?: ValidationEvidence[];
|
|
139
|
+
testScopes?: Record<string, string>;
|
|
140
|
+
priorReview?: PriorReview;
|
|
84
141
|
}
|
|
85
142
|
/** 覆盖记录由准则摘要、条目文件与 blob 重算出的请求键;与记录的文件名不符时说明记录被改写或错配。 */
|
|
86
143
|
export declare function coverageKey(coverage: ReviewCoverage): string;
|
|
@@ -91,7 +148,7 @@ export declare function writeCoverage(root: string, key: string, coverage: Revie
|
|
|
91
148
|
* 用于已推送分支再推送时,门禁的增量范围复用工作区按配置基准(相对主干的全部改动)完成的评审。
|
|
92
149
|
* 不通过的结果不按覆盖复用(理由可能针对范围外的文件),仍按键精确匹配。
|
|
93
150
|
*/
|
|
94
|
-
export declare function findCoveringReview(root: string, rubricDigest: string, items: RequestItem[], blobs: Map<string, string>): {
|
|
151
|
+
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>): {
|
|
95
152
|
key: string;
|
|
96
153
|
result: ReviewResult;
|
|
97
154
|
} | null;
|