@fantasticit/sumi 0.10.3 → 0.11.1
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 +4 -0
- package/dist/adapters.js +9 -2
- 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 +38 -1
- package/dist/agents.js.map +1 -1
- package/dist/bin.js +0 -0
- 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/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/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 +7 -3
- package/dist/vendor.js.map +1 -1
- package/node_modules/@sumi/create/package.json +2 -2
- 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 +7 -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 +6 -0
- package/node_modules/@sumi/kernel/dist/engine.js +84 -9
- 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/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 +4 -0
- 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 +16 -0
- package/node_modules/@sumi/plugin-sdk/dist/session-context.js +51 -11
- package/node_modules/@sumi/plugin-sdk/dist/session-context.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/shell.d.ts +27 -1
- package/node_modules/@sumi/plugin-sdk/dist/shell.js +430 -22
- package/node_modules/@sumi/plugin-sdk/dist/shell.js.map +1 -1
- 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 +11 -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 +39 -16
- package/node_modules/@sumi/plugins-core/dist/plugins/test-affected.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 +10 -2
- 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 +9 -0
- package/node_modules/@sumi/plugins-governance/dist/gate-cache.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/guard.js +261 -23
- package/node_modules/@sumi/plugins-governance/dist/guard.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.d.ts +2 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.js +19 -4
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/state.js +8 -2
- 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 +4 -3
- 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 +11 -6
- package/node_modules/@sumi/plugins-precedent/dist/after-edit-context.d.ts +2 -1
- package/node_modules/@sumi/plugins-precedent/dist/after-edit-context.js +124 -13
- 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 +9 -6
- package/node_modules/@sumi/plugins-precedent/dist/commands/on-prompt-context.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 +14 -0
- package/node_modules/@sumi/plugins-review/README.md +10 -0
- 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 +57 -42
- 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 -35
- package/node_modules/@sumi/plugins-review/dist/commands/submit.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/model-execution.d.ts +8 -3
- package/node_modules/@sumi/plugins-review/dist/model-execution.js +99 -33
- package/node_modules/@sumi/plugins-review/dist/model-execution.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/rubric.js +107 -36
- package/node_modules/@sumi/plugins-review/dist/plugins/rubric.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/recheck.js +18 -6
- 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 +34 -4
- package/node_modules/@sumi/plugins-review/dist/review.js +149 -29
- 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 +58 -7
- 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
|
@@ -17,6 +17,13 @@ plugins:
|
|
|
17
17
|
group: 上下文模式
|
|
18
18
|
label: beforeEdit
|
|
19
19
|
upgradeNotice: '编辑前 hook 已按默认 inject-once 开启;可设置 agentContext.beforeEdit: off 或本次进程 SUMI_BEFORE_EDIT=off 关闭。'
|
|
20
|
+
- path: agentContext.requireRead
|
|
21
|
+
values: [on, off]
|
|
22
|
+
default: on
|
|
23
|
+
event: beforeTool
|
|
24
|
+
group: 上下文模式
|
|
25
|
+
label: requireRead
|
|
26
|
+
upgradeNotice: '写入前要求本轮已读取上下文(sumi task --select 或 sumi context),默认开启;可设置 agentContext.requireRead: off 或本次进程 SUMI_REQUIRE_READ=off 关闭。'
|
|
20
27
|
- path: agentContext.onPrompt
|
|
21
28
|
values: [off, inject]
|
|
22
29
|
default: inject
|
|
@@ -32,6 +39,7 @@ plugins:
|
|
|
32
39
|
failure: open
|
|
33
40
|
when: { path: agentContext.beforeEdit, notEquals: off }
|
|
34
41
|
afterEdit: context-after-edit
|
|
42
|
+
afterEditShell: true
|
|
35
43
|
sessionStart: context-session-start
|
|
36
44
|
onPrompt: { command: context-on-prompt, when: { path: agentContext.onPrompt, notEquals: off } }
|
|
37
45
|
commands:
|
|
@@ -55,6 +63,12 @@ plugins:
|
|
|
55
63
|
requires: ['@sumi/plugins-governance']
|
|
56
64
|
commands:
|
|
57
65
|
- { name: impact-submit, argv: [node, ./dist/commands/impact-submit.js], description: 提交业务约束影响判断 }
|
|
66
|
+
- id: prec/context-read
|
|
67
|
+
version: 0.1.0
|
|
68
|
+
description: AI 会话改动项目前读取过任务上下文
|
|
69
|
+
kind: check
|
|
70
|
+
command: [node, ./dist/plugins/context-read.js]
|
|
71
|
+
timeout: 30
|
|
58
72
|
- id: prec/selftest
|
|
59
73
|
version: 0.1.0
|
|
60
74
|
description: 判例自检:登记了就一定可执行
|
|
@@ -59,6 +59,10 @@ items:
|
|
|
59
59
|
|
|
60
60
|
没有适用条目时步骤直接 `pass`。
|
|
61
61
|
|
|
62
|
+
准则文件顶层写 `enabled: false` 即停用该维度:评审直接通过、不派发,判例强制纳入的条目仍会评审;`sumi update` 不再改写它,约束清单不再列出。删除准则文件不能停用默认维度,`sumi update` 会补回。
|
|
63
|
+
|
|
64
|
+
约束清单只列出流程中 `review/rubric` 步骤实际使用的准则。漏检审查准则(以 `auditOf` 引用首轮)和停用的准则不列出;用 `sumi task --select` 明确选择的不受此限。
|
|
65
|
+
|
|
62
66
|
## 评审流程
|
|
63
67
|
|
|
64
68
|
1. **生成请求**:插件计算请求键(见下文)。没有可复用的已接受结果时,在步骤的证据目录写入 `review-request.json`,在共享状态目录写入一次性 ticket,步骤返回 `pending`,`next` 中给出一个 `dispatch-review` 动作:
|
|
@@ -114,6 +118,12 @@ items:
|
|
|
114
118
|
|
|
115
119
|
键不一致时,旧版简单准则请求仍可查找覆盖本次范围的已接受评审:同一准则内容,本次每个适用条目的文件都在原评审同一条目的文件列表内,内容一致且条目全部通过,才复用。绑定关键验证、首轮结果、逐区域或通过证据要求的请求禁止这种覆盖复用,只能精确匹配请求键;因此 PR 完整范围与推送增量范围不同可能需要分别评审。不通过的结果不按覆盖复用。覆盖记录与其键绑定:由记录内容重算的请求键必须等于记录的键,否则(以及记录或结果文件损坏时)跳过该记录。`sumi submit` 会核对请求键与 ticket 一致、由请求内容重算的键与准则摘要都未变,否则拒绝提交。
|
|
116
120
|
|
|
121
|
+
需要派发新评审时,插件找最近一份准则内容相同、范围覆盖本次文件的已接受结果,连同本次差异放进请求的 `incrementalReview`,供评审代理参考。参考结果可以含不通过的结论,但本次不再评审的条目必须都已通过。
|
|
122
|
+
|
|
123
|
+
修复轮可以沿用通过的条目:参考结果有不通过的条目、条目和文件范围完全不变、之后只改了不通过结论指向的文件时,通过的条目列在 `incrementalReview.carry` 中,派发说明只要求复评不通过的条目。提交结果可以省略沿用的条目,`sumi submit` 用参考结果中的结论补齐,补齐前核对参考结果中确有相同结论,否则拒绝提交。沿用有三个限制:沿用结论引用的测试回执本次必须仍然通过;参考结果中本身就是沿用来的条目不再沿用,即只延续一轮;核对漏检审查的独立性时,修复轮的提交者和被沿用结论的原评审者都要比较。
|
|
124
|
+
|
|
125
|
+
评审不通过时,同一条目累计 3 轮不通过,简报会给出 `ask-human`,请人决定:继续修复、在规格中写明支持范围后重新评审,或交给独立复核。每轮都冒出新反例时,自动修复不会收敛。只统计准则内容、基准和该条目文件范围都相同的结果;各 worktree 共用同一个状态目录,文件范围不同的其他分支不计入。
|
|
126
|
+
|
|
117
127
|
已接受的结果保存在共享状态目录(`git rev-parse --git-common-dir` 下的 `sumi/`)中:
|
|
118
128
|
|
|
119
129
|
| 路径 | 内容 |
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** 人可复制的命令:Windows 明确使用 PowerShell,避免 cmd.exe 把标签中的 & 当作新命令。 */
|
|
2
|
+
export function shellCommand(argv, platform = process.platform) {
|
|
3
|
+
if (platform === 'win32')
|
|
4
|
+
return `& ${argv.map((arg) => `'${arg.replaceAll("'", "''")}'`).join(' ')}`;
|
|
5
|
+
return argv.map((arg) => (/^[A-Za-z0-9_./:@=-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`)).join(' ');
|
|
6
|
+
}
|
|
7
|
+
export function runInstruction(platform = process.platform) {
|
|
8
|
+
return platform === 'win32' ? '请在 PowerShell 中运行' : '请运行';
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=command-hint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-hint.js","sourceRoot":"","sources":["../src/command-hint.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,UAAU,YAAY,CAAC,IAAc,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ;IACtE,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACtG,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ;IACxD,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5D,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { readContextInput } from '@sumi/plugin-sdk';
|
|
4
|
-
import { loadRubric, neutralSourceGlobs, resolveRubricScopes, scopeMatcher } from '../review.js';
|
|
4
|
+
import { activeRubrics, loadRubric, neutralSourceGlobs, resolveRubricScopes, scopeMatcher } from '../review.js';
|
|
5
5
|
/** 约束查询:范围命中给定路径的评审条目(没有范围的条目对所有路径生效)。 */
|
|
6
6
|
const { repoRoot, paths, select, catalog: wantCatalog, diagnose } = await readContextInput();
|
|
7
7
|
const dir = join(repoRoot, 'control', 'rubrics');
|
|
@@ -9,6 +9,7 @@ const items = [];
|
|
|
9
9
|
const catalog = [];
|
|
10
10
|
const diagnostics = [];
|
|
11
11
|
let usesBusinessZone = false;
|
|
12
|
+
const active = activeRubrics(repoRoot);
|
|
12
13
|
for (const file of existsSync(dir)
|
|
13
14
|
? readdirSync(dir)
|
|
14
15
|
.filter((f) => f.endsWith('.yaml'))
|
|
@@ -16,6 +17,11 @@ for (const file of existsSync(dir)
|
|
|
16
17
|
: []) {
|
|
17
18
|
const id = file.replace(/\.yaml$/, '');
|
|
18
19
|
const loaded = loadRubric(repoRoot, id).rubric;
|
|
20
|
+
const explicit = select?.some((ref) => ref === `rubric:${id}` || ref.startsWith(`rubric:${id}#`));
|
|
21
|
+
// 停用、流程未引用或只作漏检审查的准则不是开发约束;流程无法读取时全部列出
|
|
22
|
+
const inUse = (active ? active.has(id) : true) && loaded.enabled !== false;
|
|
23
|
+
if (!explicit && !inUse)
|
|
24
|
+
continue;
|
|
19
25
|
usesBusinessZone ||= loaded.items.some((item) => item.scope?.includes('zone:business'));
|
|
20
26
|
let rubric = loaded;
|
|
21
27
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/commands/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAsB,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/commands/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,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@@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { guardCommandArgs, writeFileAtomic } from '@sumi/plugin-sdk';
|
|
4
|
-
import {
|
|
4
|
+
import { hasHostModelEventRecord, markHostModelEventConsumed, restoreHostModelEvent, verifyHostModelEvent, withHostModelEventLock, } from '../model-execution.js';
|
|
5
5
|
import { compareVerifiedModels } from '../model-independence.js';
|
|
6
6
|
import { buildRecheckRequest, loadOriginalRecheckInput, recheckContext, recheckKey, validateRecheckResult, writeRecheck, } from '../recheck.js';
|
|
7
7
|
import { reviewsDir } from '../review.js';
|
|
@@ -21,48 +21,63 @@ try {
|
|
|
21
21
|
const ticketPath = join(reviewsDir(root), 'recheck-tickets', `${ticketId}.json`);
|
|
22
22
|
if (!existsSync(ticketPath))
|
|
23
23
|
throw new Error('ticket 不存在');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
24
|
+
withHostModelEventLock(root, ticketId, () => {
|
|
25
|
+
const ticket = JSON.parse(readFileSync(ticketPath, 'utf8'));
|
|
26
|
+
if (ticket.ticket !== ticketId || ticket.runId !== runId || ticket.stepId !== stepId || ticket.used)
|
|
27
|
+
throw new Error('ticket 不匹配或已使用');
|
|
28
|
+
if (typeof ticket.runDir !== 'string' || typeof ticket.source !== 'string' || !ticket.reviewer || typeof ticket.resultPath !== 'string')
|
|
29
|
+
throw new Error('ticket 格式无效');
|
|
30
|
+
const policy = ticket.policy ?? 'different-model';
|
|
31
|
+
if (policy !== 'different-model' && policy !== 'different-vendor' && policy !== 'independent-context')
|
|
32
|
+
throw new Error('复核策略无效');
|
|
33
|
+
const original = loadOriginalRecheckInput(root, ticket.runDir, ticket.source, policy === 'independent-context');
|
|
34
|
+
if (policy !== 'independent-context') {
|
|
35
|
+
const independent = compareVerifiedModels(original.original, ticket.reviewer, undefined, policy);
|
|
36
|
+
if (!independent.independent)
|
|
37
|
+
throw new Error(independent.reason);
|
|
38
|
+
}
|
|
39
|
+
const expected = buildRecheckRequest({ ...original, reviewer: ticket.reviewer, ...(policy !== 'different-model' ? { policy } : {}) });
|
|
40
|
+
if (recheckKey(expected) !== ticket.key)
|
|
41
|
+
throw new Error('复核输入已变化,请重新运行流程');
|
|
42
|
+
const supplied = JSON.parse(readFileSync(ticket.requestPath, 'utf8'));
|
|
43
|
+
if (recheckKey(supplied) !== ticket.key)
|
|
44
|
+
throw new Error('复核请求与 ticket 不一致');
|
|
45
|
+
const response = JSON.parse(readFileSync(ticket.resultPath, 'utf8'));
|
|
46
|
+
const error = validateRecheckResult(expected, response);
|
|
47
|
+
if (error)
|
|
48
|
+
throw new Error(`复核结果不合法:${error}`);
|
|
49
|
+
let identity = null;
|
|
50
|
+
try {
|
|
51
|
+
identity = verifyHostModelEvent(root, ticketId, 'model-recheck');
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (policy !== 'independent-context' || hasHostModelEventRecord(root, ticketId))
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
if (identity && (identity.vendor !== ticket.reviewer.vendor || identity.model !== ticket.reviewer.model))
|
|
58
|
+
throw new Error('复核结果提交者的宿主模型与目标模型不一致');
|
|
59
|
+
if (policy === 'independent-context' && recheckContext(original.original, identity) === 'same')
|
|
60
|
+
throw new Error('原评审与复核使用同一宿主上下文');
|
|
61
|
+
const current = loadOriginalRecheckInput(root, ticket.runDir, ticket.source, policy === 'independent-context');
|
|
62
|
+
if (recheckKey(buildRecheckRequest({ ...current, reviewer: ticket.reviewer, ...(policy !== 'different-model' ? { policy } : {}) })) !==
|
|
63
|
+
ticket.key)
|
|
64
|
+
throw new Error('提交期间被评审内容发生变化');
|
|
65
|
+
writeFileAtomic(ticketPath, JSON.stringify({ ...ticket, used: true }, null, 2));
|
|
66
|
+
let marked = false;
|
|
67
|
+
try {
|
|
68
|
+
if (identity) {
|
|
69
|
+
markHostModelEventConsumed(root, ticketId, 'model-recheck', identity);
|
|
70
|
+
marked = true;
|
|
71
|
+
}
|
|
72
|
+
writeRecheck(root, expected, response, ticketId, identity);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
writeFileAtomic(ticketPath, JSON.stringify(ticket, null, 2));
|
|
76
|
+
if (identity && marked)
|
|
77
|
+
restoreHostModelEvent(root, ticketId, 'model-recheck', identity);
|
|
54
78
|
throw error;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
throw new Error('复核结果提交者的宿主模型与目标模型不一致');
|
|
58
|
-
if (policy === 'independent-context' && recheckContext(original.original, identity) === 'same')
|
|
59
|
-
throw new Error('原评审与复核使用同一宿主上下文');
|
|
60
|
-
const current = loadOriginalRecheckInput(root, ticket.runDir, ticket.source, policy === 'independent-context');
|
|
61
|
-
if (recheckKey(buildRecheckRequest({ ...current, reviewer: ticket.reviewer, ...(policy !== 'different-model' ? { policy } : {}) })) !==
|
|
62
|
-
ticket.key)
|
|
63
|
-
throw new Error('提交期间被评审内容发生变化');
|
|
64
|
-
writeRecheck(root, expected, response, ticketId, identity);
|
|
65
|
-
writeFileAtomic(ticketPath, JSON.stringify({ ...ticket, used: true }, null, 2));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
66
81
|
process.stdout.write('独立复核结果已接受,请重新运行流程\n');
|
|
67
82
|
}
|
|
68
83
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-recheck.js","sourceRoot":"","sources":["../../src/commands/model-recheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,
|
|
1
|
+
{"version":3,"file":"model-recheck.js","sourceRoot":"","sources":["../../src/commands/model-recheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,UAAU,EACV,qBAAqB,EACrB,YAAY,GAIb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB1C,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AACpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,gBAAgB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,4DAA4D,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACrH,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,QAAQ,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAA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CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAC/H,MAAM,CAAC,GAAG;YAEV,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QACnC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAChF,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC;YACH,IAAI,QAAQ,EAAE,CAAC;gBACb,0BAA0B,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;gBACtE,MAAM,GAAG,IAAI,CAAC;YAChB,CAAC;YACD,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAyB,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC9E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7D,IAAI,QAAQ,IAAI,MAAM;gBAAE,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;YACzF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAC9C,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -1,57 +1,114 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
1
2
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { guardCommandArgs, projectSumiCommand } from '@sumi/plugin-sdk';
|
|
5
|
+
import { runInstruction, shellCommand } from '../command-hint.js';
|
|
6
|
+
import { markHostModelEventConsumed, restoreHostModelEvent, verifyHostModelEvent, withHostModelEventLock } from '../model-execution.js';
|
|
7
|
+
import { priorContext } from '../review-evidence.js';
|
|
8
|
+
import { isReviewResult, readAccepted, resultDigest, validateReviewResult } from '../review.js';
|
|
9
|
+
import { acceptSubmission, prepareSubmission, withCarried } from '../submission.js';
|
|
7
10
|
const root = process.env.SUMI_ROOT ?? process.cwd();
|
|
8
11
|
const args = process.argv.slice(2);
|
|
9
12
|
guardCommandArgs(args, { usage: '用法:sumi submit <run-id> <step-id> --ticket <ticket>', options: ['ticket'] });
|
|
10
13
|
const ti = args.indexOf('--ticket');
|
|
11
14
|
const ticketId = ti >= 0 ? args[ti + 1] : undefined;
|
|
12
15
|
const [runId, stepId] = args.filter((_, i) => i !== ti && i !== ti + 1);
|
|
16
|
+
function readPriorRun() {
|
|
17
|
+
if (!/^r\d{17}-[a-f0-9]{6}$/.test(runId ?? ''))
|
|
18
|
+
return undefined;
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(readFileSync(join(root, '.sumi', 'runs', runId, 'result.json'), 'utf8'));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function fullRerunCommand(priorRun) {
|
|
27
|
+
const argv = projectSumiCommand('run', priorRun?.flow ?? 'check');
|
|
28
|
+
if (priorRun?.tier)
|
|
29
|
+
argv.push('--tier', priorRun.tier);
|
|
30
|
+
if (priorRun?.all)
|
|
31
|
+
argv.push('--all');
|
|
32
|
+
if (priorRun?.base)
|
|
33
|
+
argv.push('--base', priorRun.base);
|
|
34
|
+
for (const [key, value] of Object.entries(priorRun?.labels ?? {}))
|
|
35
|
+
argv.push('--label', `${key}=${value}`);
|
|
36
|
+
return shellCommand(argv);
|
|
37
|
+
}
|
|
13
38
|
function reject(message) {
|
|
14
|
-
|
|
39
|
+
const rerun = /已变化|被改写|不一致/.test(message) ? `;${runInstruction()} ${fullRerunCommand(readPriorRun())}` : '';
|
|
40
|
+
process.stderr.write(`提交被拒绝:${message}${rerun}\n`);
|
|
15
41
|
process.exit(1);
|
|
16
42
|
}
|
|
17
43
|
if (!runId || !stepId || !ticketId)
|
|
18
44
|
reject('用法:sumi submit <run-id> <step-id> --ticket <ticket>');
|
|
19
45
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
46
|
+
withHostModelEventLock(root, ticketId, () => {
|
|
47
|
+
const prepared = prepareSubmission(root, runId, stepId, ticketId);
|
|
48
|
+
let value;
|
|
49
|
+
try {
|
|
50
|
+
value = JSON.parse(readFileSync(prepared.ticket.resultPath, 'utf8'));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new Error('结果文件不是合法 JSON');
|
|
54
|
+
}
|
|
55
|
+
value = withCarried(root, prepared.request, value);
|
|
56
|
+
const errors = validateReviewResult(prepared.request, value);
|
|
57
|
+
if (errors.length)
|
|
58
|
+
throw new Error(errors.join(';'));
|
|
59
|
+
if (!isReviewResult(value))
|
|
60
|
+
throw new Error('结果格式不合法');
|
|
61
|
+
// 普通提交保持兼容:只有真实宿主事件存在时,才附加可供独立复核使用的来源。
|
|
62
|
+
// 要求模型来源的评审在写入任何结果之前拒绝:票据保持未使用,修好宿主 hook 后可用同一票据重新提交。
|
|
63
|
+
let identity = null;
|
|
64
|
+
try {
|
|
65
|
+
identity = verifyHostModelEvent(root, ticketId, 'submit');
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (prepared.request.requireModelSource)
|
|
69
|
+
throw new Error(`本评审要求宿主模型来源:${error.message}。请在已接入 sumi hook 的代理会话中重新执行这条 submit 命令`);
|
|
70
|
+
}
|
|
71
|
+
const prior = prepared.request.priorReview;
|
|
72
|
+
if (prior && identity) {
|
|
73
|
+
const priorAccepted = readAccepted(root, prior.key);
|
|
74
|
+
if (!priorAccepted || resultDigest(priorAccepted) !== prior.resultDigest)
|
|
75
|
+
throw new Error('首轮评审结果已变化,请重新运行漏检审查');
|
|
76
|
+
if (priorContext(root, prior.key, priorAccepted, identity) === 'same')
|
|
77
|
+
throw new Error('漏检审查与首轮评审是同一代理上下文,请使用全新子代理');
|
|
78
|
+
}
|
|
79
|
+
let marked = false;
|
|
80
|
+
try {
|
|
81
|
+
if (identity) {
|
|
82
|
+
markHostModelEventConsumed(root, ticketId, 'submit', identity);
|
|
83
|
+
marked = true;
|
|
84
|
+
}
|
|
85
|
+
acceptSubmission(prepared, value, identity);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (identity && marked) {
|
|
89
|
+
const current = JSON.parse(readFileSync(prepared.ticketPath, 'utf8'));
|
|
90
|
+
if (!current.used) {
|
|
91
|
+
restoreHostModelEvent(root, ticketId, 'submit', identity);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const priorRun = readPriorRun();
|
|
98
|
+
let canTryResume = false;
|
|
22
99
|
try {
|
|
23
|
-
|
|
100
|
+
const [command, ...checkArgs] = projectSumiCommand('resume', runId, '--check');
|
|
101
|
+
canTryResume = spawnSync(command, checkArgs, { cwd: root, encoding: 'utf8', windowsHide: true, timeout: 30_000 }).status === 0;
|
|
24
102
|
}
|
|
25
103
|
catch {
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
const errors = validateReviewResult(prepared.request, value);
|
|
29
|
-
if (errors.length)
|
|
30
|
-
throw new Error(errors.join(';'));
|
|
31
|
-
if (!isReviewResult(value))
|
|
32
|
-
throw new Error('结果格式不合法');
|
|
33
|
-
// 普通提交保持兼容:只有真实宿主事件存在时,才附加可供独立复核使用的来源。
|
|
34
|
-
// 要求模型来源的评审在写入任何结果之前拒绝:票据保持未使用,修好宿主 hook 后可用同一票据重新提交。
|
|
35
|
-
let identity = null;
|
|
36
|
-
try {
|
|
37
|
-
identity = verifyHostModelEvent(root, ticketId, 'submit');
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (prepared.request.requireModelSource)
|
|
41
|
-
throw new Error(`本评审要求宿主模型来源:${error.message}。请在已接入 sumi hook 的代理会话中重新执行这条 submit 命令`);
|
|
104
|
+
// 无法核验输入时给完整重跑命令。
|
|
42
105
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const original = readModelSource(root, prior.key, { verdicts: prior.verdicts });
|
|
46
|
-
if (recheckContext(original, identity) === 'same')
|
|
47
|
-
throw new Error('漏检审查与首轮评审是同一代理上下文,请使用全新子代理');
|
|
106
|
+
if (canTryResume) {
|
|
107
|
+
process.stdout.write(`评审结果已接受,${runInstruction()} ${shellCommand(projectSumiCommand('resume', runId))}\n`);
|
|
48
108
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
markHostModelEventConsumed(root, ticketId);
|
|
52
|
-
writeModelSource(root, prepared.request.key, accepted, ticketId, identity);
|
|
109
|
+
else {
|
|
110
|
+
process.stdout.write(`评审结果已接受;原运行不可安全续接,${runInstruction()} ${fullRerunCommand(priorRun)}\n`);
|
|
53
111
|
}
|
|
54
|
-
process.stdout.write('评审结果已接受,请重新运行流程\n');
|
|
55
112
|
}
|
|
56
113
|
catch (error) {
|
|
57
114
|
reject(error.message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../src/commands/submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"submit.js","sourceRoot":"","sources":["../../src/commands/submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACv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E,CAAC;IAChC,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAI,CAAC;QACH,MAAM,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,GAAG,kBAAkB,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAC/E,YAAY,GAAG,SAAS,CAAC,OAAQ,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IAClI,CAAC;IAAC,MAAM,CAAC;QACP,kBAAkB;IACpB,CAAC;IACD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,cAAc,EAAE,IAAI,YAAY,CAAC,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IAC7G,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,cAAc,EAAE,IAAI,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChG,CAAC;AACH,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -19,16 +19,21 @@ interface HostEvent extends ModelIdentity {
|
|
|
19
19
|
issuedAt: number;
|
|
20
20
|
conflict?: boolean;
|
|
21
21
|
}
|
|
22
|
+
/** 将同一 ticket 的 hook 事件与提交串行化,避免并发写入覆盖已消耗的来源。 */
|
|
23
|
+
export declare function withHostModelEventLock<T>(root: string, ticket: string, work: () => T): T;
|
|
24
|
+
export declare const hasHostModelEventRecord: (root: string, ticket: string) => boolean;
|
|
22
25
|
export declare function canonicalModelId(value: unknown): string | null;
|
|
23
26
|
/** 只采纳代理宿主 hook 的结构化事件,不执行第三方模型适配器。 */
|
|
24
27
|
export declare function observeHostModelEvent(root: string, value: unknown, now?: number): void;
|
|
25
28
|
/** ticket 必须有最近的宿主工具事件;一份事件只能被一次提交消耗。 */
|
|
26
29
|
export declare function consumeHostModelEvent(root: string, ticket: string, action: HostEvent['action'], now?: number): ModelIdentity;
|
|
27
|
-
/** 标记 ticket
|
|
28
|
-
export declare function markHostModelEventConsumed(root: string, ticket: string): void;
|
|
30
|
+
/** 标记 ticket 的宿主事件已被消耗;调用方须持有该 ticket 的锁。 */
|
|
31
|
+
export declare function markHostModelEventConsumed(root: string, ticket: string, action: HostEvent['action'], identity: ModelIdentity, now?: number): void;
|
|
32
|
+
/** 提交落盘失败且 ticket 未消耗时,允许同一宿主事件重试;调用方须持锁。 */
|
|
33
|
+
export declare function restoreHostModelEvent(root: string, ticket: string, action: HostEvent['action'], identity: ModelIdentity): void;
|
|
29
34
|
/** 校验 ticket 绑定的宿主事件并返回模型身份,不消耗事件。 */
|
|
30
35
|
export declare function verifyHostModelEvent(root: string, ticket: string, action: HostEvent['action'], now?: number): ModelIdentity;
|
|
31
36
|
export declare function wasHostModelEventConsumed(root: string, ticket: string, action: HostEvent['action'], identity: ModelIdentity): boolean;
|
|
32
|
-
export declare function writeModelSource(root: string, key: string, result: ReviewResult, ticket: string, identity: ModelIdentity): void;
|
|
37
|
+
export declare function writeModelSource(root: string, key: string, result: ReviewResult, ticket: string, identity: ModelIdentity): () => void;
|
|
33
38
|
export declare function readModelSource(root: string, key: string, result: ReviewResult): ModelSource | null;
|
|
34
39
|
export {};
|