@aibyzero/cm-workflow 0.16.8 → 0.16.9
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/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +19 -0
- package/README.md +14 -3
- package/VERSION +1 -1
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +25 -1
- package/docs/next-steps.md +8 -2
- package/docs/user-guide.md +105 -5
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +111 -20
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +69 -22
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-core.mjs +9 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +951 -43
- package/runtime/js/cm-ai/effect-abandon-log.mjs +5 -2
- package/runtime/js/cm-ai/effect-contract.mjs +6 -1
- package/runtime/js/cm-ai/external-run-guard.mjs +18 -7
- package/runtime/js/cm-ai/host-check.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +11 -4
- package/runtime/js/cm-ai/host-documentation.mjs +53 -12
- package/runtime/js/cm-ai/host-project-execution.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +49 -4
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +44 -9
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-tool-bridge.mjs +40 -3
- package/runtime/js/cm-ai/operator-guidance.mjs +112 -3
- package/runtime/js/cm-ai/provider-review-observation.mjs +50 -0
- package/runtime/js/cm-ai/qa-resource-release.mjs +46 -0
- package/runtime/js/cm-ai/qa-round-budget.mjs +13 -0
- package/runtime/js/cm-ai/review-dispatch-limits.mjs +18 -0
- package/runtime/js/cm-ai/review-package.mjs +10 -1
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
- package/runtime/js/cm-ai/task-commit.mjs +39 -0
- package/runtime/js/cm-ai/task-runner.mjs +636 -65
- package/runtime/js/cm-ai/worker-claude-developer.mjs +9 -0
- package/runtime/js/cm-ai/worker-claude.mjs +10 -3
- package/runtime/js/cm-ai/worker-process-identity.mjs +43 -0
- package/runtime/js/cm-fix/execution.mjs +176 -48
- package/runtime/js/cm-fix/host.mjs +2 -1
- package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
- package/runtime/js/cm-fix/progress.mjs +13 -3
- package/runtime/js/cm-fix/protected-edits.mjs +10 -3
- package/runtime/js/cm-fix/repair.mjs +11 -3
- package/runtime/js/cm-fix/test-author.mjs +10 -3
- package/runtime/js/cm-idea/session.mjs +67 -4
- package/runtime/js/cm-prd/review-correction.mjs +10 -4
- package/runtime/js/cm-prd/session.mjs +43 -0
- package/runtime/js/cm-refactor/records.mjs +98 -8
- package/runtime/js/cm-refactor/workflow.mjs +79 -9
- package/runtime/js/cm-test/host.mjs +10 -3
- package/runtime/js/cm-test/session.mjs +45 -6
- package/runtime/js/notify-safe-read.mjs +49 -0
- package/runtime/js/notify-send.mjs +312 -0
- package/runtime/js/notify.mjs +137 -33
- package/runtime/js/policy-binding-compat.mjs +54 -0
- package/scripts/ci-test-shards.mjs +67 -0
- package/scripts/ci-test-shards.test.mjs +64 -0
- package/scripts/ci-test-weights.json +222 -0
- package/scripts/cm-ai-abandon-effect-position.test.mjs +70 -2
- package/scripts/cm-ai-answer-gap-dispatch.test.mjs +86 -0
- package/scripts/cm-ai-answer-gap-driver.test.mjs +51 -0
- package/scripts/cm-ai-answer-gap-fixture.mjs +96 -0
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +70 -0
- package/scripts/cm-ai-answer-gap-redo.test.mjs +103 -0
- package/scripts/cm-ai-batch-drive.mjs +55 -10
- package/scripts/cm-ai-batch-drive.test.mjs +65 -0
- package/scripts/cm-ai-batch-host.mjs +132 -13
- package/scripts/cm-ai-batch-host.test.mjs +255 -7
- package/scripts/cm-ai-batch-run-fixture.mjs +499 -0
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +38 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +7 -0
- package/scripts/cm-ai-batch-run-reschedule.test.mjs +17 -0
- package/scripts/cm-ai-batch-run.mjs +184 -22
- package/scripts/cm-ai-batch-run.test.mjs +21 -341
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +104 -0
- package/scripts/cm-ai-develop-call-timeout.test.mjs +153 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +4 -3
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
- package/scripts/cm-ai-drive.mjs +64 -22
- package/scripts/cm-ai-drive.test.mjs +29 -2
- package/scripts/cm-ai-host-cli-workflow.test.mjs +271 -0
- package/scripts/cm-ai-host-fixture.mjs +268 -0
- package/scripts/cm-ai-host-protected.test.mjs +251 -0
- package/scripts/cm-ai-host.mjs +27 -15
- package/scripts/cm-ai-host.test.mjs +17 -759
- package/scripts/cm-ai-light-modules.test.mjs +57 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
- package/scripts/cm-ai-protected-scope.test.mjs +7 -3
- package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +78 -11
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +56 -10
- package/scripts/cm-ai-review-dispatch-exit.test.mjs +475 -0
- package/scripts/cm-ai-review-failure.test.mjs +124 -13
- package/scripts/cm-ai-review-timeout.test.mjs +188 -10
- package/scripts/cm-ai-run.mjs +15 -6
- package/scripts/cm-ai-supersede.test.mjs +486 -41
- package/scripts/cm-check-drive-files.mjs +8 -0
- package/scripts/cm-check-drive.test.mjs +2 -5
- package/scripts/cm-check-runtime.sh +4 -2
- package/scripts/cm-claude-developer-worker.test.mjs +15 -0
- package/scripts/cm-claude-review-stream.test.mjs +21 -16
- package/scripts/cm-claude-review-synthetic.test.mjs +155 -0
- package/scripts/cm-claude-worker.test.mjs +18 -2
- package/scripts/cm-external-model-recovery.test.mjs +29 -3
- package/scripts/cm-fix-abandon.test.mjs +163 -10
- package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
- package/scripts/cm-fix-drive.mjs +25 -7
- package/scripts/cm-fix-host.mjs +8 -7
- package/scripts/cm-fix-review-budget.test.mjs +13 -0
- package/scripts/cm-fix-review-recovery.test.mjs +35 -0
- package/scripts/cm-host-answer-timeout.test.mjs +65 -0
- package/scripts/cm-host-call-kinds.test.mjs +28 -0
- package/scripts/cm-host-documentation.test.mjs +49 -0
- package/scripts/cm-host-qa-executor.test.mjs +22 -10
- package/scripts/cm-idea-answer-gaps.test.mjs +164 -0
- package/scripts/cm-idea-drive.mjs +49 -11
- package/scripts/cm-idea-drive.test.mjs +66 -0
- package/scripts/cm-idea-host.mjs +106 -16
- package/scripts/cm-init-answer-gaps.test.mjs +258 -0
- package/scripts/cm-init-drive.mjs +41 -7
- package/scripts/cm-init-host.mjs +61 -12
- package/scripts/cm-log-event.mjs +21 -10
- package/scripts/cm-notify-command.test.mjs +900 -0
- package/scripts/cm-notify-read-drift.test.mjs +205 -0
- package/scripts/cm-notify.mjs +469 -0
- package/scripts/cm-notify.test.mjs +221 -4
- package/scripts/cm-prd-answer-gaps.test.mjs +216 -0
- package/scripts/cm-prd-drive.mjs +18 -5
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +37 -4
- package/scripts/cm-prd-review-disposition.test.mjs +6 -1
- package/scripts/cm-prd-review-gate.mjs +56 -0
- package/scripts/cm-refactor-answer-gaps.test.mjs +206 -0
- package/scripts/cm-refactor-drive.mjs +52 -8
- package/scripts/cm-refactor-drive.test.mjs +44 -0
- package/scripts/cm-refactor-host.test.mjs +10 -6
- package/scripts/cm-release-smoke.sh +2 -0
- package/scripts/cm-test-answer-gaps.test.mjs +151 -0
- package/scripts/cm-test-drive.mjs +21 -5
- package/scripts/fixtures/claude-review-process.mjs +1 -1
- package/scripts/policy-binding-compat.test.mjs +99 -0
- package/scripts/scan-public-safety.py +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +27 -1
- package/skills/cm-ai/references/js-host-recovery.md +120 -8
- package/skills/cm-ai/references/js-host.md +14 -7
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/references/js-host.md +44 -5
- package/skills/cm-idea/references/js-host.md +27 -2
- package/skills/cm-init/references/js-host.md +16 -3
- package/skills/cm-notify/SKILL.md +34 -0
- package/skills/cm-prd/references/js-change-recovery.md +35 -1
- package/skills/cm-refactor/references/js-host.md +17 -0
- package/skills/cm-test/references/js-host.md +14 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {REVIEW_NEVER_STARTED_MANUAL_STEP,MAX_REVIEW_NOT_DISPATCHED_RETRIES as REDISPATCHES,MAX_REVIEW_NOT_DISPATCHED_EXTENSIONS as EXTENSIONS,
|
|
2
|
+
MAX_REVIEW_DENIAL_CONFIRMATIONS as DENIALS} from './review-dispatch-limits.mjs';
|
|
1
3
|
// Presentation only. Native pendingAction decides the available path; guidance
|
|
2
4
|
// never grants permission, changes retryability, or writes execution history.
|
|
3
5
|
const deliveryMessages={
|
|
@@ -10,6 +12,18 @@ const deliveryMessages={
|
|
|
10
12
|
develop_unchanged_after_review:['交付没有处理上一轮审查要求。','处理原审查 findings 后提供本轮修改'],
|
|
11
13
|
develop_requirement_missing:['交付后缺少要求保留的文件。','恢复 reason 指出的必要文件'],
|
|
12
14
|
bootstrap_verification_failed:['项目规则验证未通过。','根据规则验证证据修正草稿或检查环境'],
|
|
15
|
+
develop_answer_invalid:['开发应答未通过交付合同校验(如 application.note 过长),代码已保留、尚未进入审查。','按 reason 中的字段上限重新应答'],
|
|
16
|
+
develop_dispatch_failed:['开发请求在派发给会话之前失败(宿主自己的运行日志或角色配置出错),代码未改动。','修好 reason 指出的宿主环境'],
|
|
17
|
+
develop_interrupted:['宿主在本轮开发中途退出,中断已登记,盘上改动保留、尚未进入审查。','确认会话或 provider 进程已停止修改代码'],
|
|
18
|
+
develop_call_timeout:['开发应答超时、代码未改动。','先确认会话已不再修改代码;重发的请求须在宿主请求上限(默认 30 分钟)内应答,迟到应答仍被拒绝'],
|
|
19
|
+
};
|
|
20
|
+
// Q16/Q17: documentation_sync of the final task, after develop already answered.
|
|
21
|
+
const documentationMessages={
|
|
22
|
+
documentation_sync_answer_missing:['文档同步没有拿到应答(超时、断开或迟到)。开发应答已记录,不需要重新开发。','重发的文档同步须在宿主请求上限内应答,迟到应答仍被拒绝;'],
|
|
23
|
+
documentation_sync_answer_invalid:['文档同步的应答格式不合格。开发应答已记录,不需要重新开发。','只按合同应答 {"status":"completed"} 或 {"status":"blocked"};'],
|
|
24
|
+
documentation_sync_answer_blocked:['文档同步答复 blocked,文档没有同步完。开发应答已记录,不需要重新开发。','先按会话说明补齐或修正文档、解决阻碍;'],
|
|
25
|
+
documentation_sync_out_of_scope:['文档同步改了文档路径以外的文件(reason 列出路径),尚未进入审查。','先把这些文件还原到文档同步开始时的内容(宿主按存档摘要核对,没还原就拒绝;确需修改先走规格变更);'],
|
|
26
|
+
documentation_sync_interrupted:['宿主在文档同步中途退出,中断已登记。开发应答已记录,不需要重新开发。',''],
|
|
13
27
|
};
|
|
14
28
|
const explain=(summary,nextStep,operation=null,prerequisites=[])=>Object.freeze({
|
|
15
29
|
summary,nextStep,recoveryOperation:operation,prerequisites:Object.freeze(prerequisites),authorizationGranted:false,
|
|
@@ -29,15 +43,80 @@ export function operatorGuidance(result,{executionActive=false}={}){
|
|
|
29
43
|
if(state==='unknown'){
|
|
30
44
|
if(action==='abandon_effect'||action==='abandon_review'){
|
|
31
45
|
const review=action==='abandon_review';
|
|
32
|
-
return explain(review?'独立审查结果尚未确认。':'
|
|
33
|
-
'先核对原操作与磁盘结果,确认旧宿主及相关子进程已退出;符合原宿主条件时,再审计放弃这次操作。放弃不代表成功。'
|
|
46
|
+
return explain(review?'独立审查结果尚未确认。':'宿主在开发、审查或完成中途退出,这一步只登记了意图、没有结果。',
|
|
47
|
+
review?'先核对原操作与磁盘结果,确认旧宿主及相关子进程已退出;符合原宿主条件时,再审计放弃这次操作。放弃不代表成功。'
|
|
48
|
+
:result.documentationSyncPending===true
|
|
49
|
+
?'先确认旧宿主及相关子进程已退出、会话已停止修改文档(宿主按存档核对文档路径以外的文件与此刻的文档);再发送 abandon_effect 登记中断,运行转为 documentation_sync_interrupted,之后只重发文档同步、不重新开发,计入文档同步重发的 2 次上限。盘上改动保留并经检查与独立审查;登记中断不代表成功。'
|
|
50
|
+
:'先确认旧宿主及相关子进程已退出、会话已停止写入(provider 开发由宿主按存档记下的进程身份核对);再发送 abandon_effect 登记中断,运行从这一步的可重试阻断继续:开发重发本轮、未登记的审查重新派发、未写提交意图的完成重新复查。盘上改动保留并经检查与独立审查;登记中断不代表成功。',
|
|
34
51
|
action,['保留原配置、runId 和失败历史,以 --mode resume 启动',
|
|
35
52
|
review?'显式 --allow-abandon-review,并提供单行 reason':'显式 --allow-abandon-effect,并提供单行 reason',
|
|
36
53
|
'由原宿主核对可放弃条件;不得直接重跑或改写完成记录']);
|
|
37
54
|
}
|
|
55
|
+
// V5 (A33/A36): a no-verdict review end the host cannot prove safe to redispatch.
|
|
56
|
+
if(['review_process_unverified','review_observation_invalid','review_boundary_unverified','review_abandon_budget_exhausted'].includes(result.reviewAbandonRefusal))
|
|
57
|
+
return explain('独立审查没有结论,且宿主不能证明再派一次是安全的(reason 写明原因)。',
|
|
58
|
+
'按 reason 手工核对旧审查进程与原审查证据;本运行不再重派审查,确认后用 --supersede-reviewed-evidence 新建运行重做。',
|
|
59
|
+
null,['原运行记录保留,不改写','本运行留在盘上的改动需还原,或加 --accept-superseded-code-drift']);
|
|
38
60
|
return explain('执行结果尚未确认,不能判断这一步成功或失败。',
|
|
39
61
|
'只读核对原运行记录、进程及实际文件;当前没有已确认的直接重试入口,不新建运行绕过历史。');
|
|
40
62
|
}
|
|
63
|
+
// A review round that never started a reviewer (nothing ran, nothing to prove stopped).
|
|
64
|
+
if(action==='abandon_review'&&result.reviewDispatchConfirmRequired===true&&code==='permission_denied')
|
|
65
|
+
return explain('本轮独立审查的授权没有取得(被拒绝,或授权已失效),审查没有登记、没有派发、审查进程从未启动,不会有任何写入;宿主不会自动重试。',
|
|
66
|
+
'先查清是谁拒绝、为什么;确认现在可以授权后,用 --allow-abandon-review 恢复原运行并发送 abandon_review(单行 reason 写明依据)登记确认,再按原方式重新取得本轮独立审查授权,然后 advance。',
|
|
67
|
+
'abandon_review',['保留原配置、runId 与历史,以 --mode resume 启动','显式 --allow-abandon-review,并提供单行 reason',`每轮最多确认 ${DENIALS} 次,用满为 review_permission_denied_limit;每次重派前仍须新的审查授权`]);
|
|
68
|
+
if(action==='abandon_review'&&result.reviewDispatchConfirmRequired===true&&code==='review_not_dispatched_limit')
|
|
69
|
+
return explain(`本轮独立审查已登记 ${REDISPATCHES+1} 次,每次都在派发前作废(授权过期或派发时钟倒退),审查进程从未启动、没有写入;自动重派已用满。`,
|
|
70
|
+
`先查清宿主从授权到派发为何超过授权有效期(60 秒内)或本机时钟为何倒退,并修好;然后用 --allow-abandon-review 恢复原运行并发送 abandon_review(单行 reason 写明修好了什么)登记确认,再按原方式取得新的审查授权后 advance。本轮因此再多重派 ${REDISPATCHES} 次。`,
|
|
71
|
+
'abandon_review',['保留原配置、runId 与历史,以 --mode resume 启动','显式 --allow-abandon-review,并提供单行 reason',`每轮只能确认 ${EXTENSIONS} 次;再用满为 review_not_dispatched_limit,之后没有这个出口`]);
|
|
72
|
+
if(code==='review_not_dispatched_limit')return explain(`本轮独立审查已在派发前作废 ${REDISPATCHES*(1+EXTENSIONS)+1} 次、已确认延长 ${EXTENSIONS} 次,不再提供继续重派的操作;审查进程从未启动,也没有写入。`,
|
|
73
|
+
`先查清宿主从授权到派发为何超过授权有效期(60 秒内)或本机时钟为何倒退。${REVIEW_NEVER_STARTED_MANUAL_STEP}`,
|
|
74
|
+
null,['原运行记录保留,不改写','本运行留在盘上的改动需另存或还原,不要加 --accept-superseded-code-drift']);
|
|
75
|
+
if(state==='pending_review'&&action==='resume'&&['grant_expired','clock_invalid'].includes(code))return explain('本轮独立审查已登记,但派发前授权过期或派发时钟倒退,审查进程从未启动、没有结论。',
|
|
76
|
+
'恢复原运行,按原方式重新取得本轮独立审查的新的审查授权,再发送 advance;派发要在授权后 60 秒内完成。',
|
|
77
|
+
'advance',['保留原配置、runId 与历史,以 --mode resume 启动','不算审查轮次,不占调用与 effect 名额',`每轮最多重派 ${REDISPATCHES} 次,用满为 review_not_dispatched_limit,再确认 ${EXTENSIONS} 次后才能多重派 ${REDISPATCHES} 次`]);
|
|
78
|
+
if(code==='review_permission_denied_limit')return explain(`本轮独立审查的授权已被拒绝 ${DENIALS+1} 次、已确认重新授权 ${DENIALS} 次,不再提供重新授权的操作;审查从未启动,也没有写入。`,
|
|
79
|
+
`先查清授权为何一直被拒绝(宿主是否配了审查权限、授权是否在 60 秒内用完)。${REVIEW_NEVER_STARTED_MANUAL_STEP}`,
|
|
80
|
+
null,['原运行记录保留,不改写','本运行留在盘上的改动需另存或还原,不要加 --accept-superseded-code-drift']);
|
|
81
|
+
if(state==='pending_review'&&action==='resume'&&code==='permission_denied_confirmed')return explain('审查授权被拒绝的情况已由操作员确认,本轮可以重新申请授权;审查从未启动。',
|
|
82
|
+
'恢复原运行,按原方式重新取得本轮独立审查的新的审查授权(旧授权不复用),再发送 advance;仍被拒绝时需要再确认一次。',
|
|
83
|
+
'advance',['保留原配置、runId 与历史,以 --mode resume 启动','本轮独立审查授权须是新取得的','不算审查轮次,不占调用与 effect 名额']);
|
|
84
|
+
if(state==='blocked'&&action==='abandon_review')return explain('本轮独立审查第二次没有结论,本轮还剩 1 次无结论重派,但宿主不能证明原审查进程已停止。',
|
|
85
|
+
'先确认原审查进程(含子进程)已退出;再恢复原运行并发送 abandon_review 登记确认,之后 advance 重新取得授权并重派。不算审查轮次。',
|
|
86
|
+
'abandon_review',['保留原配置、runId 与历史,以 --mode resume 启动','显式 --allow-abandon-review,并提供单行 reason','用满 2 次后为 review_redispatch_limit']);
|
|
87
|
+
// Q16/Q17: the final task's documentation_sync failed after develop answered.
|
|
88
|
+
// R3: whatever the failure, the host cannot see whether the session still writes.
|
|
89
|
+
if(action==='develop_redo'&&Object.hasOwn(documentationMessages,code))return explain(`${documentationMessages[code][0]}宿主无法证明会话已停止修改文档。`,
|
|
90
|
+
`先确认会话已停止修改文档,${documentationMessages[code][1]}再恢复原运行并发送 develop_redo 写入确认,之后 advance 只重发文档同步。盘上的开发与文档改动保留,经检查和独立审查。`,
|
|
91
|
+
'develop_redo',['保留原配置、runId 与历史,以 --mode resume 启动','显式 --allow-develop-redo,并提供单行 reason','只重发文档同步,不重发开发;每运行最多 2 次']);
|
|
92
|
+
if(state==='blocked'&&action==='resume'&&Object.hasOwn(documentationMessages,code)){
|
|
93
|
+
const [summary,repair]=documentationMessages[code];
|
|
94
|
+
return explain(summary,`${repair}然后恢复原运行并发送 advance,只重发文档同步,复用已记录的开发应答,不重新开发。`,
|
|
95
|
+
'advance',['保留原配置、runId 与历史,以 --mode resume 启动','文档路径以外的文件须与文档同步开始时一致、文档须与确认停写时一致,否则拒绝','不占调用与 effect 名额;每运行最多 2 次,用满为 documentation_sync_retry_limit']);
|
|
96
|
+
}
|
|
97
|
+
if(code==='documentation_sync_retry_limit')return explain('文档同步重发已在本运行用满 2 次,不再重发。',
|
|
98
|
+
'先查清会话为何一直不应答、答复 blocked 或越界写文件;修好后按 reason 用 --supersede-reviewed-evidence 新建运行重做。',
|
|
99
|
+
null,['原运行记录保留,不改写','本运行留在盘上的改动需还原,或加 --accept-superseded-code-drift']);
|
|
100
|
+
if(action==='develop_redo')return explain('开发应答没有拿到(超时后代码已改动、会话断开或只回了 failed),会话可能仍在写文件。',
|
|
101
|
+
'先确认会话已停止修改代码;再恢复原运行并发送 develop_redo 写入确认,之后 advance 重发本轮开发。盘上改动保留,经检查和独立审查。',
|
|
102
|
+
'develop_redo',['保留原配置、runId 与历史,以 --mode resume 启动','显式 --allow-develop-redo,并提供单行 reason','不占调用与 effect 名额;每运行最多 2 次']);
|
|
103
|
+
if(state==='blocked'&&action==='resume'&&code==='develop_answer_missing')return explain('已确认会话停写,本轮开发等待重发。',
|
|
104
|
+
'恢复原运行并发送 advance,用新 effect id 重发本轮开发;盘上改动保留,经检查和独立审查。',
|
|
105
|
+
'advance',['保留原配置、runId 与历史,以 --mode resume 启动','确认原宿主已关闭,且本轮开发有原合同要求的授权']);
|
|
106
|
+
if(state==='blocked'&&action==='resume'&&code==='develop_out_of_scope')return explain('开发交付已落盘,但改动超出了任务 scope(reason 列出路径),尚未进入审查。',
|
|
107
|
+
'核对这些路径:会话越界写的就还原,你自己的改动就移出代码根,确需改动先走规格变更扩大 scope;然后恢复原运行并发送 advance,只重跑检查、验证预检与审查包,不重新开发。',
|
|
108
|
+
'advance',['保留原配置、runId 与历史,以 --mode resume 启动','不占开发调用与 effect 名额;每运行最多 2 次','不擅自删除用户改动']);
|
|
109
|
+
if(state==='blocked'&&action==='resume'&&['check_answer_missing','check_answer_invalid'].includes(code))
|
|
110
|
+
return explain(code==='check_answer_invalid'?'开发交付已落盘,但之后的检查或验证预检答复格式不合格。'
|
|
111
|
+
:'开发交付已落盘,但之后的检查或验证预检没有拿到应答(超时、断开或迟到)。',
|
|
112
|
+
'先确认上一次检查命令已停止;然后恢复原运行并发送 advance,只重跑检查、验证预检与审查包,不重新开发。',
|
|
113
|
+
'advance',['保留原配置、runId 与历史,以 --mode resume 启动','不占开发调用与 effect 名额;每运行最多 2 次','不会自动完成任务或消耗新的独立审查轮次']);
|
|
114
|
+
if(state==='blocked'&&action==='complete'&&code==='complete_commit_interrupted')return explain('宿主在写入任务完成提交意图后退出,tasks.md 可能已勾选也可能未勾选。',
|
|
115
|
+
'恢复原运行并发送 complete;宿主只按存档里的提交计划核对并收尾,不重新复查、不重新开发。tasks.md 或证据被改动时会拒绝并保留现场。',
|
|
116
|
+
'complete',['保留原配置、runId 与历史,以 --mode resume 启动','不能 abandon_effect,也不能新建运行替代']);
|
|
117
|
+
if(state==='blocked'&&action==='complete'&&code==='complete_recheck_failed')return explain('完成前复查没有正常结束(应答缺失或宿主在提交前出错),任务尚未勾选。',
|
|
118
|
+
'恢复原运行并发送 complete,重新复查并完成;不重新开发或审查。',
|
|
119
|
+
'complete',['原 run 与已审交接、范围和包绑定不变','task-commit-intent 尚未写入;每运行最多 2 次']);
|
|
41
120
|
if(state==='blocked'&&action==='resume'&&Object.hasOwn(deliveryMessages,code)){
|
|
42
121
|
const [summary,repair]=deliveryMessages[code];
|
|
43
122
|
return explain(summary,`${repair};然后恢复原运行并发送 advance,重做本轮交付和检查。`,
|
|
@@ -49,6 +128,21 @@ export function operatorGuidance(result,{executionActive=false}={}){
|
|
|
49
128
|
if(state==='blocked'&&action==='complete')return explain('完成前复核受阻,已有审查结论不能直接当作任务完成。',
|
|
50
129
|
'核对 reason 中的检查或文件变化;满足原完成条件后,在原运行发送 complete,不重新开发。',
|
|
51
130
|
'complete',['原 run 与已审交接、范围和包绑定不变','使用当前 packageDigest;由宿主重新核对完成条件']);
|
|
131
|
+
if(code==='review_redispatch_limit')return explain('本轮独立审查已无结论重派 2 次,不再重派;这不计为审查轮次。',
|
|
132
|
+
'先查清审查进程为何一直没有结论(登录、额度、网络或审查答复格式);修好后按 reason 用 --supersede-reviewed-evidence 新建运行重做。',
|
|
133
|
+
null,['原运行记录保留,不改写','本运行留在盘上的改动需还原,或加 --accept-superseded-code-drift']);
|
|
134
|
+
if(['check_answer_retry_limit','complete_recheck_limit','develop_redo_limit'].includes(code))
|
|
135
|
+
return explain('这一步的自动恢复已在本运行用满 2 次,不再重做。',
|
|
136
|
+
'先查清会话为何一直不应答或答复不合格(或宿主环境为何失败);修好后按 reason 用 --supersede-reviewed-evidence 新建运行重做。',
|
|
137
|
+
null,['原运行记录保留,不改写','本运行留在盘上的改动需还原,或加 --accept-superseded-code-drift']);
|
|
138
|
+
// Q06/Q07/Q11: a QA call that stopped as a whole.
|
|
139
|
+
if(state==='fixture_completed'&&code==='qa_execution_unknown')return explain('本轮 QA 没有正常结束(整轮超时、宿主中途退出、答复格式不合格,或浏览器请求超时后设备可能仍被会话占用)。',
|
|
140
|
+
'先确认上一轮的会话、浏览器或模拟器已停止、设备已空闲;再用原配置 --mode resume 加 --rerun-unknown-qa 重跑本轮。宿主拒绝时按拒绝码处理:含原始 FAIL、未解决的 [需确认] 或无法归因的旧记录的轮次不能替代,改用 --supersede-reviewed-evidence 新建运行。',
|
|
141
|
+
null,['保留原运行与 QA 日志,只追加不改写','因宿主或应答原因替代的轮次不占三轮预算']);
|
|
142
|
+
// Q15: the read-only documentation check answered blocked.
|
|
143
|
+
if(state==='fixture_completed'&&code==='documentation_sync_blocked')return explain('文档核对判定文档尚未同步(reason 写明缺什么)。',
|
|
144
|
+
'按 reason 补齐 README 或功能文档;文档核对只读、可重复,用原配置 --mode resume 重启宿主后再发 finish 重新核对(同一宿主进程内结论已缓存)。',
|
|
145
|
+
null,['不改写运行记录','补文档不需要重新开发或审查']);
|
|
52
146
|
if(code==='protected_scope')return explain('任务 scope 含项目规则或工作流文件,开发在派发前被拒绝,未写入任何文件。',
|
|
53
147
|
'本运行到此结束,原记录保留。从 scope 移除 reason 列出的路径,按原门禁用新 runId 新建运行;规则文件改动走 docs/js-workflow-control.md「项目规则文件的修改通道」。',
|
|
54
148
|
null,['不放宽受保护路径,开发者不能写这些文件','不改写原运行记录']);
|
|
@@ -70,14 +164,29 @@ export function guidanceText(result){
|
|
|
70
164
|
return `${guidance.summary} ${guidance.nextStep} ${guidance.prerequisites.join(';')}`.trim();
|
|
71
165
|
}
|
|
72
166
|
|
|
167
|
+
// Q24: in-run recovery operations the batch entry forwards to the stopped member
|
|
168
|
+
// (scripts/cm-ai-batch-run.mjs BATCH_MEMBER_ACTIONS), with what to confirm first.
|
|
169
|
+
const BATCH_RECOVERY={
|
|
170
|
+
develop_redo:['--allow-develop-redo','先确认会话已停止修改代码'],
|
|
171
|
+
abandon_effect:['--allow-abandon-effect','先确认旧宿主及相关子进程已退出、会话已停止写入'],
|
|
172
|
+
abandon_review:['--allow-abandon-review','先确认旧宿主与审查进程已退出'],
|
|
173
|
+
bootstrap_review_recover:['--allow-bootstrap-review-recovery','先核对当前规则文件、handoff 和原证据'],
|
|
174
|
+
};
|
|
73
175
|
// A member result is not a batch control surface. Keep unsupported single-run
|
|
74
176
|
// recovery operations out of batch instructions without changing pendingAction.
|
|
75
|
-
export function batchOperatorGuidance(result){
|
|
177
|
+
export function batchOperatorGuidance(result,{taskKey=null}={}){
|
|
76
178
|
const g=result?.guidance;if(!g)return null;
|
|
179
|
+
if(Object.hasOwn(BATCH_RECOVERY,g.recoveryOperation)){
|
|
180
|
+
const [flag,confirm]=BATCH_RECOVERY[g.recoveryOperation],target=taskKey??'FEATURE/TASK';
|
|
181
|
+
return explain(g.summary,`${confirm};关闭批次宿主,带 ${flag} ${target} 用同一批次配置重新启动,发送批次操作 ${g.recoveryOperation}(taskKey ${target}、单行 reason),之后 advance 继续本批次。`,
|
|
182
|
+
g.recoveryOperation,['保持原批次配置;批次只用这一项权限打开该成员运行,不跨成员','授权用一次即失效;批次 cancel 后不能再恢复']);
|
|
183
|
+
}
|
|
77
184
|
if(result.code==='spec_drift')return explain(g.summary,
|
|
78
185
|
'批次成员不能换绑规格;先按 reason 核对原批次可用出口,不直接重派。');
|
|
79
186
|
if(g.recoveryOperation==='advance')return explain(g.summary,
|
|
80
187
|
g.nextStep.replace('然后恢复原运行并发送 advance,重做本轮交付和检查。','然后从原批次入口发送 advance,重做本轮交付和检查。')
|
|
188
|
+
.replace('然后恢复原运行并发送 advance,只重跑','然后从原批次入口发送 advance,只重跑')
|
|
189
|
+
.replace('恢复原运行并发送 advance,用新 effect id','从原批次入口发送 advance,用新 effect id')
|
|
81
190
|
.replace('恢复原运行后,取得本轮绑定的独立审查授权,再发送 advance。','沿原批次续接,取得本轮绑定的独立审查授权,再发送 advance。'),
|
|
82
191
|
'advance',['保持原批次配置、身份和 PLAN;成员运行由批次宿主选择恢复','先确认原批次宿主已关闭;开发与审查仍需原合同授权']);
|
|
83
192
|
if(g.recoveryOperation==='complete')return explain(g.summary,
|
|
@@ -106,6 +106,56 @@ export const REVIEWER_PROVIDER_FAILURES=Object.freeze({
|
|
|
106
106
|
provider_failed:'reviewer_provider_failed',incomplete_result:'reviewer_exited',
|
|
107
107
|
missing_init:'reviewer_stream_unrecognized',unexpected_event:'reviewer_stream_unrecognized',
|
|
108
108
|
invalid_event:'reviewer_stream_unrecognized'});
|
|
109
|
+
// Reviewer boundary exits (unexpected_tool_or_content). The Claude worker appends
|
|
110
|
+
// a fixed, body-free summary of the rejected message to the base code; readers
|
|
111
|
+
// that predate it see one opaque failed code and keep the result unknown.
|
|
112
|
+
export const REVIEWER_REJECTION_CHECKS=Object.freeze(['empty_content','block_type','tool_attempt_limit',
|
|
113
|
+
'duplicate_tool_id','user_content','unknown_tool_result','tool_result_not_error']);
|
|
114
|
+
export function reviewerBoundaryExit(code){
|
|
115
|
+
if(typeof code!=='string'||code.length>256)return null;
|
|
116
|
+
if(code==='unexpected_tool_or_content')return {check:null,message:null,block:null,tool:null,isError:null};
|
|
117
|
+
if(!code.startsWith('unexpected_tool_or_content:'))return null;
|
|
118
|
+
let d;try{d=JSON.parse(code.slice('unexpected_tool_or_content:'.length));}catch{return null;}
|
|
119
|
+
if(!d||typeof d!=='object'||Array.isArray(d)||Object.keys(d).sort().join(',')!=='b,e,k,m,t')return null;
|
|
120
|
+
if(!REVIEWER_REJECTION_CHECKS.includes(d.k)||!['assistant','user'].includes(d.m))return null;
|
|
121
|
+
if(d.b!==null&&!(typeof d.b==='string'&&/^[A-Za-z_]{1,32}$/.test(d.b)))return null;
|
|
122
|
+
if(d.t!==null&&!(typeof d.t==='string'&&/^[A-Za-z0-9_.:-]{1,64}$/.test(d.t)))return null;
|
|
123
|
+
if(d.e!==null&&typeof d.e!=='boolean')return null;
|
|
124
|
+
return {check:d.k,message:d.m,block:d.b,tool:d.t,isError:d.e};
|
|
125
|
+
}
|
|
126
|
+
// Such an exit may be abandoned by the operator (never retried automatically)
|
|
127
|
+
// only when nothing was ever received from it: the process was observed closed,
|
|
128
|
+
// not by timeout, with no final message and no terminal, and the rejection is
|
|
129
|
+
// one that cannot have run a tool successfully (a user-role message that was
|
|
130
|
+
// not a tool result, empty content, or the attempt limit). A legacy code with
|
|
131
|
+
// no summary cannot tell these apart from a successful tool; it qualifies by
|
|
132
|
+
// compatibility decision only (nothing was ever accepted from it, and the
|
|
133
|
+
// operator abandons explicitly, once). A new record of a successful or
|
|
134
|
+
// unmatched tool result stays unknown, as before.
|
|
135
|
+
const ABANDONABLE_CHECKS=new Set(['user_content','empty_content','tool_attempt_limit']);
|
|
136
|
+
export function abandonableReviewerExit(observation){
|
|
137
|
+
const exit=reviewerBoundaryExit(observation?.result?.code);
|
|
138
|
+
if(exit===null||observation.result.status!=='failed')return false;
|
|
139
|
+
if(exit.check!==null&&!ABANDONABLE_CHECKS.has(exit.check))return false;
|
|
140
|
+
let stream;try{stream=eventStream(observation.events,new Set());}catch{return false;}
|
|
141
|
+
return stream.close!==null&&stream.close.timed_out===false&&!stream.hasResult&&stream.terminal===null;
|
|
142
|
+
}
|
|
143
|
+
// V5 (A33): other worker failures after which the reviewer process is proven
|
|
144
|
+
// gone and nothing usable was lost. The worker only reports these codes after it
|
|
145
|
+
// awaited its process-group cleanup (process_cleanup_unknown otherwise), so:
|
|
146
|
+
// spawn_failed with no event at all (nothing ever started), or an observed close
|
|
147
|
+
// that was not a timeout with no final message. An unparseable final message
|
|
148
|
+
// (invalid_output_json) has no conclusion to reconcile either. Tool or item
|
|
149
|
+
// boundary exits stay with abandonableReviewerExit; process_cleanup_unknown and
|
|
150
|
+
// any other code stay unknown.
|
|
151
|
+
const GONE_FAILURES=new Set(['spawn_failed','prompt_write_failed','output_limit','invalid_output_json','thread_mismatch','cli_diagnostic']);
|
|
152
|
+
export function reviewerGoneWithoutResult(observation){
|
|
153
|
+
const r=observation?.result;
|
|
154
|
+
if(r?.status!=='failed'||!GONE_FAILURES.has(r.code))return false;
|
|
155
|
+
let stream;try{stream=eventStream(observation.events,new Set());}catch{return false;}
|
|
156
|
+
if(r.code==='spawn_failed')return observation.events.length===0;
|
|
157
|
+
return stream.close!==null&&stream.close.timed_out===false&&(r.code==='invalid_output_json'||!stream.hasResult);
|
|
158
|
+
}
|
|
109
159
|
// A complete answer that breaks the written verdict contract can never become a
|
|
110
160
|
// receipt. It is retried under the same budget and its exact code is kept.
|
|
111
161
|
export const REVIEWER_VERDICT_FAILURES=Object.freeze(['contradictory_verdict','invalid_finding_path',
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Q13/Q26: a QA command resource recorded cleanup_failed (whole-round timeout,
|
|
2
|
+
// cancel, or a cleanup the checker could not confirm) keeps the run open: the
|
|
3
|
+
// log writer refuses abandonment, timed-out supersession, run_done and the
|
|
4
|
+
// batch handoff while it is unclosed. The host may close it only with proof:
|
|
5
|
+
// the cleanup_failed row names the command's process group (pid and start
|
|
6
|
+
// time, written by current executors) and that group is gone now. The released
|
|
7
|
+
// row carries the proof; rows without a recorded pid, or a group that is alive
|
|
8
|
+
// or cannot be checked (Windows, permission, unreadable start time), stay open.
|
|
9
|
+
// QA browser cases hold no resource rows: their device or browser state is the
|
|
10
|
+
// session's own report (cleanup), so there is no device lock to release here.
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import {spawnSync} from 'node:child_process';
|
|
13
|
+
import {fileURLToPath} from 'node:url';
|
|
14
|
+
import {scanRows} from './log-rows.mjs';
|
|
15
|
+
import {inspectWorkerGroup,validWorkerPid,validStartTime} from './worker-process-identity.mjs';
|
|
16
|
+
import {need} from './effect-contract.mjs';
|
|
17
|
+
|
|
18
|
+
const writer=fileURLToPath(new URL('../../../scripts/cm-log-event.py',import.meta.url));
|
|
19
|
+
|
|
20
|
+
export function inspectOpenQaResources({specsDir,runId}){
|
|
21
|
+
const last=new Map();
|
|
22
|
+
scanRows(path.join(specsDir,'运行日志.jsonl'),row=>{
|
|
23
|
+
if(row?.workflow==='cm-ai'&&row.event==='resource'&&row.run_id===runId&&typeof row.resource_id==='string')
|
|
24
|
+
last.set(row.resource_id,row);
|
|
25
|
+
});
|
|
26
|
+
return [...last.values()].filter(row=>['acquired','cleanup_failed'].includes(row.phase));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function releaseVerifiedQaResources({specsDir,codeProject,runId,runtime='codex',logHome=null,inspect=inspectWorkerGroup}){
|
|
30
|
+
const released=[],open=[];
|
|
31
|
+
for(const row of inspectOpenQaResources({specsDir,runId})){
|
|
32
|
+
const proof=row.phase==='cleanup_failed'&&row.resource_kind==='qa_command'&&validWorkerPid(row.pid)
|
|
33
|
+
&&validStartTime(row.process_start_time??null)?inspect({pid:row.pid,startTime:row.process_start_time??null}):null;
|
|
34
|
+
if(proof!=='gone'){open.push({resourceId:row.resource_id,phase:row.phase,verdict:proof??'unrecorded'});continue;}
|
|
35
|
+
const data={...(row.node?{node:row.node}:{}),...(row.feature?{feature:row.feature}:{}),...(row.task?{task:row.task}:{}),
|
|
36
|
+
resource_id:row.resource_id,resource_kind:row.resource_kind,released_by:'host_verified',
|
|
37
|
+
verification:'process_group_gone',pid:row.pid,process_start_time:row.process_start_time??null};
|
|
38
|
+
const result=spawnSync('python3',[writer,'--workflow','cm-ai','--event','resource','--phase','released',
|
|
39
|
+
'--runtime',runtime,'--project-root',codeProject,'--specs-dir',specsDir,'--run-id',runId,
|
|
40
|
+
'--detail','宿主核对 QA 命令进程组已退出,补记资源释放','--data-json',JSON.stringify(data)],
|
|
41
|
+
{timeout:10000,maxBuffer:1024*1024,...(logHome?{env:{...process.env,CM_WORKFLOW_LOG_HOME:logHome}}:{})});
|
|
42
|
+
need(!result.error&&result.status===0,'qa_resource_release_failed');
|
|
43
|
+
released.push(row.resource_id);
|
|
44
|
+
}
|
|
45
|
+
return {released,open};
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Q14: the N6 QA budget is three rounds of product evidence. A round that ended
|
|
2
|
+
// because of the host or the session's answer (no answer before the deadline or
|
|
3
|
+
// a host death, a host-judged evidence or environment gap, a session-declared
|
|
4
|
+
// BLOCKED) and was superseded for exactly that reason does not count; at most
|
|
5
|
+
// two such rounds are given back per run. Operator decisions (a declared
|
|
6
|
+
// environment failure, a configuration revision) and product FAILs still count.
|
|
7
|
+
export const QA_BASE_ROUNDS=3;
|
|
8
|
+
export const QA_EXTRA_ROUNDS=2;
|
|
9
|
+
export const QA_MAX_ROUNDS=QA_BASE_ROUNDS+QA_EXTRA_ROUNDS;
|
|
10
|
+
export const NON_PRODUCT_SUPERSESSIONS=Object.freeze(['host_request_timeout','host_evidence_problem']);
|
|
11
|
+
export const nonProductSupersession=reason=>NON_PRODUCT_SUPERSESSIONS.includes(reason);
|
|
12
|
+
// The highest round that may start once `freed` such supersessions are recorded.
|
|
13
|
+
export const qaRoundLimit=freed=>QA_BASE_ROUNDS+Math.min(QA_EXTRA_ROUNDS,freed);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Pure data shared by durable-runner-state.mjs and the light operator-guidance.mjs. No imports on
|
|
2
|
+
// purpose: operator-guidance is copied into partial runtimes (scripts/cm-check-drive.test.mjs), so it
|
|
3
|
+
// must not pull in the runner's dependency graph. scripts/cm-ai-light-modules.test.mjs guards that.
|
|
4
|
+
|
|
5
|
+
// A review that never started a reviewer (see durable-runner-state.mjs): bounds and limit codes.
|
|
6
|
+
export const MAX_REVIEW_NOT_DISPATCHED_RETRIES=2;
|
|
7
|
+
export const MAX_REVIEW_NOT_DISPATCHED_EXTENSIONS=1;
|
|
8
|
+
export const REVIEW_NOT_DISPATCHED_LIMIT_CODE='review_not_dispatched_limit';
|
|
9
|
+
export const MAX_REVIEW_DENIAL_CONFIRMATIONS=2;
|
|
10
|
+
export const REVIEW_DENIAL_LIMIT_CODE='review_permission_denied_limit';
|
|
11
|
+
// The only manual step left once a never-started review has no in-run exit: the review
|
|
12
|
+
// process never started, so there is no writer to wait for; cancel is accepted from this raw
|
|
13
|
+
// pending_review end and supersede accepts the cancelled run (reviewed-evidence-supersede.mjs).
|
|
14
|
+
// The external-run guard still refuses a strict prior run whose last review was voided
|
|
15
|
+
// before dispatch (strictPriorAttemptResolved), so that case has no new-run exit at all.
|
|
16
|
+
export const REVIEW_NEVER_STARTED_MANUAL_STEP='要继续这个任务:先用 cancel 取消本运行(审查从未启动,没有需要等待停下的写入方);另存或还原本运行留在盘上的代码改动;'
|
|
17
|
+
+'再用 --supersede-reviewed-evidence --supersede-reason 原因 新建运行重做。不要加 --accept-superseded-code-drift:那会把这些没审过的改动当成已有代码,新运行的审查看不到它们。'
|
|
18
|
+
+'原运行若是外部模型或执行策略运行,外部运行守卫可能拒绝同一代码根上的新运行(被派发前作废的审查记录仍带对账标记);守卫拒绝时本运行没有别的出口,保留运行记录与代码,把本 reason 交给维护者。';
|
|
@@ -874,7 +874,16 @@ export function verifyCompletionReviewPackage(options) {
|
|
|
874
874
|
const checkIdentities=checks=>checks.map(c=>c.kind==='visual'
|
|
875
875
|
?{id:c.id,kind:c.kind}
|
|
876
876
|
:{id:c.id,command:c.command});
|
|
877
|
-
|
|
877
|
+
// A42: the completion re-check answered with another check list (ids or
|
|
878
|
+
// commands) than the reviewed delivery. The code is unchanged, so this is a
|
|
879
|
+
// retryable re-check block that names the difference, not a terminal mismatch.
|
|
880
|
+
if(digest(checkIdentities(current.checks))!==digest(checkIdentities(v.reviewPackage.checks))){
|
|
881
|
+
const ids=checks=>checks.map(c=>String(c.id)).join(', ').slice(0,600)||'(无)';
|
|
882
|
+
const sameIds=ids(current.checks)===ids(v.reviewPackage.checks);
|
|
883
|
+
throw Object.assign(new Error(`completion_checks_changed: 完成复查的检查清单与审查包不一致(${sameIds
|
|
884
|
+
?`编号相同但命令不同:${ids(current.checks)}`:`审查包:${ids(v.reviewPackage.checks)};本次:${ids(current.checks)}`})。按审查包的检查清单原样重跑后再发送 complete`),
|
|
885
|
+
{code:'completion_checks_changed'});
|
|
886
|
+
}
|
|
878
887
|
const checkResults=checks=>checks.map(c=>c.kind==='visual'
|
|
879
888
|
?{outcome:c.outcome}
|
|
880
889
|
:{outcome:c.outcome,exitCode:c.exitCode});
|
|
@@ -121,7 +121,7 @@ export function prepareReviewedEvidenceSupersession({specsDir,codeProject,featur
|
|
|
121
121
|
if(first.version!==3)unavailable(`旧运行 ${entry.name} 的 journal 版本无法验证`);
|
|
122
122
|
const history=readRunnerHistory(snapshot.records,first.config,3);
|
|
123
123
|
if(history.pending){
|
|
124
|
-
const exit=history.pendingAbandonable?'abandon_effect':
|
|
124
|
+
const exit=history.pendingAbandonable||history.pendingInterruptible||history.pendingReviewExhausted?'abandon_effect':
|
|
125
125
|
history.pending.kind==='review'&&history.state.reviewInvocation?.registration
|
|
126
126
|
&&history.state.reviewInvocation.result===null?'abandon_review':'原运行恢复入口';
|
|
127
127
|
unavailable(`旧运行 ${entry.name} 的 ${history.pending.kind} effect 已中断且未结;先确认旧 host 和子进程已退出,再在原 run 上使用 ${exit},随后重新发起 supersede`);
|
|
@@ -176,6 +176,45 @@ function observeImage(owner,p) {
|
|
|
176
176
|
}catch{/* Unsafe/missing/changed target is observation conflict, not write authority. */}
|
|
177
177
|
return observation;
|
|
178
178
|
}
|
|
179
|
+
// A45: the host died after the commit intent and before its result. Only the
|
|
180
|
+
// journaled plan is followed. tasks.md already holding the planned bytes is the
|
|
181
|
+
// finished commit (observed_after). tasks.md still holding the exact bytes and
|
|
182
|
+
// revision the plan started from, every planned evidence revision unchanged and
|
|
183
|
+
// the reviewed code still in place (beforeRollForward) lets the planned rename
|
|
184
|
+
// finish now. Anything else is a conflict for a person; nothing is compensated.
|
|
185
|
+
export function recoverRunnerCommitImage(owner,intent,beforeRollForward){
|
|
186
|
+
need(typeof beforeRollForward==='function','invalid_input');
|
|
187
|
+
const observation=observeImage(owner,intent);
|
|
188
|
+
if(observation==='observed_after')return 'observed_after';
|
|
189
|
+
need(observation==='observed_before','commit_recovery_conflict');
|
|
190
|
+
const {plan,parent}=intent,{after}=planBytes(plan);
|
|
191
|
+
try{
|
|
192
|
+
need(equal(parentRevision(parent.path),parent),'snapshot_changed');
|
|
193
|
+
for(const e of plan.evidence)need(nativeRevision(e.path,readFile(e.path))===e.revision,'snapshot_changed');
|
|
194
|
+
need(nativeRevision(owner.tasksPath,readFile(owner.tasksPath))===plan.taskRevision,'snapshot_changed');
|
|
195
|
+
}catch{need(false,'commit_recovery_conflict');}
|
|
196
|
+
try{beforeRollForward();}catch{need(false,'commit_recovery_code_changed');}
|
|
197
|
+
// The interrupted writer's own temporary file: removed only while its bytes
|
|
198
|
+
// are a prefix of the planned image (it can be nothing else of ours).
|
|
199
|
+
const leftover=path.join(parent.path,intent.temporaryName);
|
|
200
|
+
try{const f=readFile(leftover);need(after.subarray(0,f.bytes.length).equals(f.bytes),'commit_recovery_conflict');fs.unlinkSync(leftover);}
|
|
201
|
+
catch(error){if(error.code==='commit_recovery_conflict')throw error;if(error.code!=='ENOENT')need(false,'commit_recovery_conflict');}
|
|
202
|
+
const temporary=path.join(parent.path,`.cm-task.${randomUUID()}.tmp`);let fd;
|
|
203
|
+
try{
|
|
204
|
+
fd=fs.openSync(temporary,fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|fs.constants.O_NOFOLLOW,0o600);
|
|
205
|
+
fs.writeFileSync(fd,after);fs.fchmodSync(fd,plan.mode);fs.fsyncSync(fd);fs.closeSync(fd);fd=undefined;
|
|
206
|
+
const written=readFile(temporary);need(written.bytes.equals(after)&&mode(written.stat)===plan.mode,'temporary_changed');
|
|
207
|
+
need(nativeRevision(owner.tasksPath,readFile(owner.tasksPath))===plan.taskRevision,'snapshot_changed');
|
|
208
|
+
fs.renameSync(temporary,owner.tasksPath);
|
|
209
|
+
const dir=fs.openSync(parent.path,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
|
|
210
|
+
try{fs.fsyncSync(dir);}finally{fs.closeSync(dir);}
|
|
211
|
+
}catch{
|
|
212
|
+
if(fd!==undefined)try{fs.closeSync(fd);}catch{/* retain unknown */}
|
|
213
|
+
need(false,'commit_unknown');
|
|
214
|
+
}
|
|
215
|
+
need(observeImage(owner,intent)==='observed_after','commit_unknown');
|
|
216
|
+
return 'observed_before_finished';
|
|
217
|
+
}
|
|
179
218
|
export function observeFixtureCommit(store) {
|
|
180
219
|
const owner=taskOwnerTarget(store);let h;
|
|
181
220
|
try{h=history(store,owner);}catch(error){if(error.code==='commit_missing')throw error;need(false,'commit_history_invalid');}
|