@aibyzero/cm-workflow 0.16.7 → 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 +37 -0
- package/README.md +39 -3
- package/VERSION +1 -1
- package/assets/readme/workflow-recovery-detailed.png +0 -0
- package/assets/readme/workflow-stages-detailed.png +0 -0
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +61 -4
- package/docs/next-steps.md +8 -2
- package/docs/user-guide.md +204 -0
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
- package/runtime/js/cm-ai/cm-ai-admission.mjs +3 -1
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +138 -26
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +142 -21
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-core.mjs +26 -4
- 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/execution-store.mjs +4 -2
- 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 +86 -17
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +44 -9
- package/runtime/js/cm-ai/host-session.mjs +47 -7
- package/runtime/js/cm-ai/host-tool-bridge.mjs +55 -6
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +4 -2
- 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-deliveries.mjs +29 -6
- 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/cause-package.mjs +37 -8
- package/runtime/js/cm-fix/diagnosis.mjs +43 -0
- package/runtime/js/cm-fix/execution.mjs +356 -187
- package/runtime/js/cm-fix/host.mjs +2 -1
- package/runtime/js/cm-fix/investigation.mjs +25 -9
- package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
- package/runtime/js/cm-fix/progress.mjs +15 -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-run.mjs +26 -0
- package/runtime/js/notify-safe-read.mjs +49 -0
- package/runtime/js/notify-send.mjs +312 -0
- package/runtime/js/notify.mjs +492 -0
- package/runtime/js/policy-binding-compat.mjs +54 -0
- package/runtime/model-efficiency.md +17 -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 +189 -22
- package/scripts/cm-ai-batch-run.test.mjs +22 -334
- 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 +68 -23
- package/scripts/cm-ai-drive.test.mjs +37 -2
- package/scripts/cm-ai-fix-run-delivery.test.mjs +138 -0
- 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 +28 -16
- 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-project-qa-gate.test.mjs +71 -4
- 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 +127 -8
- 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 +249 -10
- package/scripts/cm-fix-cause-package.test.mjs +33 -0
- package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
- package/scripts/cm-fix-drive.mjs +34 -8
- package/scripts/cm-fix-host.mjs +8 -7
- package/scripts/cm-fix-rediagnosis.test.mjs +71 -4
- 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 +143 -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 +49 -12
- 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 +685 -0
- package/scripts/cm-patrol.mjs +83 -0
- package/scripts/cm-patrol.test.mjs +161 -0
- 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/cm-token-report.mjs +497 -0
- package/scripts/cm-token-report.test.mjs +346 -0
- 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/SKILL.md +7 -3
- package/skills/cm-ai/references/N6-qa-eval.md +2 -2
- package/skills/cm-ai/references/js-host-modes.md +90 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +136 -0
- package/skills/cm-ai/references/js-host-recovery.md +311 -0
- package/skills/cm-ai/references/js-host.md +76 -331
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/SKILL.md +2 -0
- package/skills/cm-fix/references/js-host.md +56 -10
- 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/SKILL.md +2 -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
|
@@ -2,21 +2,26 @@
|
|
|
2
2
|
// same specs root. A delivery counts only after its own journal replays through
|
|
3
3
|
// the runner grammar to a committed fixture_completed state: its review package
|
|
4
4
|
// (and any accepted QA-fix packages) then describe reviewed before->after file
|
|
5
|
-
// transitions.
|
|
5
|
+
// transitions. A standalone cm-fix run counts the same way once its own owner
|
|
6
|
+
// replays it to its normal completed closeout: its independently approved final
|
|
7
|
+
// review package is the transition. This grants nothing, never repairs, and
|
|
8
|
+
// never opens a writer.
|
|
6
9
|
import fs from 'node:fs';
|
|
7
10
|
import path from 'node:path';
|
|
8
11
|
import {readExecutionSnapshot} from './execution-snapshot.mjs';
|
|
9
12
|
import {readRunnerHistory} from './durable-runner-state.mjs';
|
|
13
|
+
import {inspectFixCompletionHistory} from '../cm-fix/execution.mjs';
|
|
10
14
|
import {deliveredAfter,deliveryStep} from './fix-code-association.mjs';
|
|
11
15
|
import {digest,need} from './effect-contract.mjs';
|
|
12
16
|
|
|
13
17
|
const RUN_ID=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
14
18
|
const cache=new Map();
|
|
15
19
|
|
|
16
|
-
function readDelivery(specsRoot,identity){
|
|
20
|
+
function readDelivery(specsRoot,identity,read={}){
|
|
17
21
|
try{
|
|
18
22
|
const snapshot=readExecutionSnapshot({specsRoot,identity});
|
|
19
23
|
const init=snapshot.records[0]?.payload;
|
|
24
|
+
if(init?.workflow==='cm-fix-stages-v1'){read.fix=true;return readFixDelivery(specsRoot,identity,init.configuration);}
|
|
20
25
|
if(init?.protocol!=='cm-task-runner'||init.type!=='init'||![2,3].includes(init.version))return null;
|
|
21
26
|
const history=readRunnerHistory(snapshot.records,init.config,init.version);
|
|
22
27
|
const state=history.state;
|
|
@@ -29,6 +34,18 @@ function readDelivery(specsRoot,identity){
|
|
|
29
34
|
...history.acceptedFixes.map(item=>({pkg:item.evidence.reviewPackage,reviewedAt:fixReviewedAt(specsRoot,item.evidence)}))])});
|
|
30
35
|
}catch{return null;}
|
|
31
36
|
}
|
|
37
|
+
// A standalone cm-fix run in this specs root, read through its own owner's
|
|
38
|
+
// read-only replay and completion projection: only a run whose approved final
|
|
39
|
+
// review of the exact package was closed by task_done and run_done qualifies
|
|
40
|
+
// (never a running, abandoned, cancelled or escalated one). A QA-fix child is
|
|
41
|
+
// its parent's delivery, through the parent's acceptance, never its own; a bare
|
|
42
|
+
// archive lives outside any specs root.
|
|
43
|
+
function readFixDelivery(specsRoot,identity,configuration){
|
|
44
|
+
if(Object.hasOwn(configuration??{},'qaSource')||configuration?.archiveMode!==undefined)return null;
|
|
45
|
+
const {identity:fixIdentity,evidence}=inspectFixCompletionHistory({specsRoot,identity});
|
|
46
|
+
return Object.freeze({runId:identity.runId,root:fs.realpathSync(configuration.reproduction.cwd),taskId:fixIdentity.taskId,
|
|
47
|
+
packages:Object.freeze([{pkg:evidence.reviewPackage,reviewedAt:fixReviewedAt(specsRoot,evidence)}])});
|
|
48
|
+
}
|
|
32
49
|
// A QA fix package's durable review time: the final review registration its
|
|
33
50
|
// completion evidence cites, read from the fix child's own store, for exactly
|
|
34
51
|
// that package. Anything else has no time and never orders.
|
|
@@ -51,11 +68,17 @@ export function approvedReviewAt(state){
|
|
|
51
68
|
&&Number.isSafeInteger(registration.registeredAt)?registration.registeredAt:null;
|
|
52
69
|
}
|
|
53
70
|
|
|
71
|
+
const statVersion=stat=>stat?[stat.dev,stat.ino,stat.size,stat.mtimeMs,stat.ctimeMs].join(':'):null;
|
|
72
|
+
// A cm-fix run completes through its closeout rows in the run log, not its
|
|
73
|
+
// journal, so its entry also follows the log's version.
|
|
74
|
+
function logVersion(specsRoot){try{return statVersion(fs.lstatSync(path.join(specsRoot,'运行日志.jsonl')));}catch{return null;}}
|
|
54
75
|
function cachedDelivery(specsRoot,repositoryId,runId,stat){
|
|
55
|
-
const slot=[specsRoot,repositoryId,runId].join('\0');
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
const slot=[specsRoot,repositoryId,runId].join('\0'),version=statVersion(stat),hit=cache.get(slot);
|
|
77
|
+
if(hit?.version===version&&(!hit.fix||hit.log===logVersion(specsRoot)))return hit.delivery;
|
|
78
|
+
// Read the log version first: an append during the read is seen next time.
|
|
79
|
+
const log=logVersion(specsRoot),read={fix:false},delivery=readDelivery(specsRoot,{repositoryId,runId},read);
|
|
80
|
+
cache.set(slot,{version,fix:read.fix,log,delivery});
|
|
81
|
+
return delivery;
|
|
59
82
|
}
|
|
60
83
|
|
|
61
84
|
// Resolve recorded steps to the real, completed, later reviewed packages of the
|
|
@@ -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');}
|