@aibyzero/cm-workflow 0.16.8 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +31 -0
- package/README.md +22 -3
- package/VERSION +1 -1
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/cm-control-policy-v2.md +331 -0
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +3 -3
- package/docs/human-correction.md +5 -5
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +119 -78
- package/docs/next-steps.md +19 -2
- package/docs/untested-branches.md +2 -3
- 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 +103 -68
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +79 -27
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/control-policy.mjs +111 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +11 -8
- package/runtime/js/cm-ai/drive-core.mjs +9 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +883 -69
- 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/gate-bridge.mjs +4 -4
- package/runtime/js/cm-ai/host-check.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +33 -24
- 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 +53 -9
- package/runtime/js/cm-ai/host-qa-policy.mjs +63 -21
- package/runtime/js/cm-ai/host-review-authority.mjs +2 -2
- package/runtime/js/cm-ai/host-review-file.mjs +1 -1
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-tool-bridge.mjs +43 -3
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +21 -10
- package/runtime/js/cm-ai/host.mjs +1 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +89 -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-package.mjs +26 -5
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +1 -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 +629 -121
- 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-init/review-evidence.mjs +3 -1
- package/runtime/js/cm-prd/review-correction.mjs +10 -4
- package/runtime/js/cm-prd/review-host.mjs +1 -1
- package/runtime/js/cm-prd/review-publication.mjs +5 -3
- 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 +80 -10
- 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 +313 -0
- package/runtime/js/notify.mjs +164 -37
- package/runtime/js/policy-binding-compat.mjs +55 -0
- package/runtime/review.md +52 -7
- package/runtime/task-gates.md +107 -9
- 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 +71 -10
- 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 +89 -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 +98 -34
- package/scripts/cm-ai-batch-drive.test.mjs +124 -16
- package/scripts/cm-ai-batch-host.mjs +167 -29
- package/scripts/cm-ai-batch-host.test.mjs +303 -31
- package/scripts/cm-ai-batch-run-fixture.mjs +452 -0
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +26 -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 +213 -25
- package/scripts/cm-ai-batch-run.test.mjs +21 -341
- package/scripts/cm-ai-bootstrap-flow.test.mjs +1 -7
- package/scripts/cm-ai-bootstrap.test.mjs +2 -3
- package/scripts/cm-ai-control-launch.test.mjs +219 -0
- package/scripts/cm-ai-control-policy.test.mjs +124 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +270 -0
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +97 -0
- package/scripts/cm-ai-develop-call-timeout.test.mjs +146 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +37 -23
- package/scripts/cm-ai-direct-review.test.mjs +348 -0
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +54 -25
- package/scripts/cm-ai-drive.mjs +142 -58
- package/scripts/cm-ai-drive.test.mjs +70 -84
- package/scripts/cm-ai-fix-integration.test.mjs +3 -5
- package/scripts/cm-ai-fix-later-delivery.test.mjs +3 -6
- package/scripts/cm-ai-fix-run-delivery.test.mjs +3 -6
- package/scripts/cm-ai-host-cli-workflow.test.mjs +267 -0
- package/scripts/cm-ai-host-fixture.mjs +296 -0
- package/scripts/cm-ai-host-protected.test.mjs +253 -0
- package/scripts/cm-ai-host.mjs +122 -100
- package/scripts/cm-ai-host.test.mjs +35 -776
- package/scripts/cm-ai-launch-diagnostics.test.mjs +5 -3
- package/scripts/cm-ai-legacy-history.test.mjs +53 -0
- package/scripts/cm-ai-light-modules.test.mjs +54 -0
- package/scripts/cm-ai-multi-root.test.mjs +4 -4
- package/scripts/cm-ai-nested-execution.test.mjs +16 -19
- package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
- package/scripts/cm-ai-progress.test.mjs +10 -8
- package/scripts/cm-ai-project-qa-gate.test.mjs +37 -10
- package/scripts/cm-ai-protected-scope.test.mjs +8 -5
- package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +1 -9
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +12 -9
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +95 -13
- package/scripts/cm-ai-qa-fixed-log.test.mjs +41 -0
- package/scripts/cm-ai-qa-recovery-args.test.mjs +7 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +59 -14
- package/scripts/cm-ai-review-drift-precedence.test.mjs +1 -1
- package/scripts/cm-ai-review-failure.test.mjs +137 -32
- package/scripts/cm-ai-review-timeout-config.test.mjs +3 -1
- package/scripts/cm-ai-review-timeout.test.mjs +132 -67
- package/scripts/cm-ai-run.mjs +91 -28
- package/scripts/cm-ai-run.test.mjs +11 -38
- package/scripts/cm-ai-selection-guard.test.mjs +2 -2
- package/scripts/cm-ai-session-chain.test.mjs +18 -15
- package/scripts/cm-ai-spec-rebind.test.mjs +14 -18
- package/scripts/cm-ai-supersede.test.mjs +489 -51
- package/scripts/cm-blocked-reason.test.mjs +2 -3
- package/scripts/cm-capability-gate.test.mjs +33 -1
- 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 +23 -5
- package/scripts/cm-controlled-correction.test.mjs +469 -0
- package/scripts/cm-external-batch-host.test.mjs +30 -11
- package/scripts/cm-external-model-host.test.mjs +1 -1
- package/scripts/cm-external-model-recovery.test.mjs +32 -12
- package/scripts/cm-external-qa-fix.test.mjs +1 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +6 -24
- 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 +36 -1
- 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 +23 -12
- package/scripts/cm-host-qa-policy.test.mjs +43 -16
- package/scripts/cm-host-review-authority.test.mjs +0 -31
- 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-knowledge-closeout.test.mjs +3 -3
- package/scripts/cm-log-event.mjs +21 -10
- package/scripts/cm-notify-command.test.mjs +936 -0
- package/scripts/cm-notify-read-drift.test.mjs +270 -0
- package/scripts/cm-notify.mjs +481 -0
- package/scripts/cm-notify.test.mjs +312 -23
- package/scripts/cm-patrol.test.mjs +3 -2
- 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-task-gate-correction.test.mjs +69 -16
- package/scripts/cm-task-gate.mjs +368 -34
- package/scripts/cm-task-gate.py +2 -0
- package/scripts/cm-task-gate.test.mjs +252 -4
- package/scripts/cm-test-answer-gaps.test.mjs +151 -0
- package/scripts/cm-test-drive.mjs +21 -5
- package/scripts/fixtures/bootstrap-review-runner.mjs +1 -7
- package/scripts/fixtures/claude-review-process.mjs +1 -1
- package/scripts/fixtures/native-gate-fixture.mjs +18 -0
- package/scripts/policy-binding-compat.test.mjs +103 -0
- package/scripts/scan-public-safety.py +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/SKILL.md +8 -6
- package/skills/cm-ai/references/N3-execute-task.md +17 -2
- package/skills/cm-ai/references/N4-review.md +11 -21
- package/skills/cm-ai/references/N5-mark-done.md +1 -1
- package/skills/cm-ai/references/N6-qa-eval.md +49 -21
- package/skills/cm-ai/references/js-host-modes.md +35 -14
- package/skills/cm-ai/references/js-host-qa-recovery.md +85 -11
- package/skills/cm-ai/references/js-host-recovery.md +181 -21
- package/skills/cm-ai/references/js-host.md +76 -32
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/SKILL.md +12 -0
- 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 +17 -4
- package/skills/cm-notify/SKILL.md +34 -0
- package/skills/cm-prd/references/js-change-recovery.md +35 -1
- package/skills/cm-prd/references/js-host.md +1 -1
- package/skills/cm-refactor/SKILL.md +12 -0
- package/skills/cm-refactor/references/js-host.md +17 -0
- package/skills/cm-test/references/js-host.md +14 -1
|
@@ -316,7 +316,7 @@ export function reviewSpecsPath(root,specsRoot) {
|
|
|
316
316
|
need(root!==specsRoot&&!root.startsWith(specsRoot+path.sep),'overlapping_roots');
|
|
317
317
|
return specsRoot.startsWith(root+path.sep)?filePath(path.relative(root,specsRoot).split(path.sep).join('/')):null;
|
|
318
318
|
}
|
|
319
|
-
function snapshot(root,specsPath=null,projectPaths=null,retainedPaths=[],selected=null,policy=null) {
|
|
319
|
+
function snapshot(root,specsPath=null,projectPaths=null,retainedPaths=[],selected=null,policy=null,inventoryOnly=false) {
|
|
320
320
|
if(specsPath!==null){
|
|
321
321
|
const target=path.join(root,specsPath);
|
|
322
322
|
need(fs.realpathSync(target)===target&&fs.lstatSync(target).isDirectory(),'unsupported_path');
|
|
@@ -324,9 +324,9 @@ function snapshot(root,specsPath=null,projectPaths=null,retainedPaths=[],selecte
|
|
|
324
324
|
const files=[],seen=new Set(); let total=0,materialBytes=0,materialCount=0,visitedSpecs=false;
|
|
325
325
|
function add(p,s){
|
|
326
326
|
if(!s.isFile()||s.isSymbolicLink()||s.nlink!==1)throw diagnostic('unsupported_file',p);
|
|
327
|
-
const includeContent
|
|
328
|
-
const countLimit=selected===null?FILE_COUNT:INVENTORY_COUNT;
|
|
329
|
-
const byteLimit=selected===null?SNAPSHOT_LIMIT:INVENTORY_LIMIT;
|
|
327
|
+
const includeContent=!inventoryOnly&&(selected===null||materialPath(p,selected));
|
|
328
|
+
const countLimit=selected===null&&!inventoryOnly?FILE_COUNT:INVENTORY_COUNT;
|
|
329
|
+
const byteLimit=selected===null&&!inventoryOnly?SNAPSHOT_LIMIT:INVENTORY_LIMIT;
|
|
330
330
|
if(files.length>=countLimit)throw diagnostic('limit_exceeded',p,`file count > ${countLimit}`);
|
|
331
331
|
if(total+s.size>byteLimit)throw diagnostic('limit_exceeded',p,`inventory bytes > ${byteLimit}`);
|
|
332
332
|
if(includeContent&&materialCount>=FILE_COUNT)
|
|
@@ -354,7 +354,14 @@ function snapshot(root,specsPath=null,projectPaths=null,retainedPaths=[],selecte
|
|
|
354
354
|
try { names=fs.readdirSync(path.join(root,rel)).sort(); } catch { fail('read_failed'); }
|
|
355
355
|
for(const name of names) {
|
|
356
356
|
const p=rel ? rel+'/'+name : name;
|
|
357
|
+
// Compatibility evidence is outside the code inventory: only the code
|
|
358
|
+
// root's own .reviews and the specs subtree. A nested directory that
|
|
359
|
+
// merely shares the name is ordinary code and stays in the inventory.
|
|
360
|
+
// Existing JS snapshots retain their historical selection and record shape.
|
|
357
361
|
let s; try { s=fs.lstatSync(path.join(root,p)); } catch { fail('read_failed'); }
|
|
362
|
+
if(inventoryOnly&&p==='.reviews'&&p!==specsPath){
|
|
363
|
+
need(s.isDirectory()&&!s.isSymbolicLink(),'unsupported_path');continue;
|
|
364
|
+
}
|
|
358
365
|
// Linked worktrees use a regular .git pointer file instead of a directory.
|
|
359
366
|
// Treat both as Git metadata, never read/follow the pointer or traverse it.
|
|
360
367
|
// Scope and requirement paths still cannot select any .git entry.
|
|
@@ -874,7 +881,16 @@ export function verifyCompletionReviewPackage(options) {
|
|
|
874
881
|
const checkIdentities=checks=>checks.map(c=>c.kind==='visual'
|
|
875
882
|
?{id:c.id,kind:c.kind}
|
|
876
883
|
:{id:c.id,command:c.command});
|
|
877
|
-
|
|
884
|
+
// A42: the completion re-check answered with another check list (ids or
|
|
885
|
+
// commands) than the reviewed delivery. The code is unchanged, so this is a
|
|
886
|
+
// retryable re-check block that names the difference, not a terminal mismatch.
|
|
887
|
+
if(digest(checkIdentities(current.checks))!==digest(checkIdentities(v.reviewPackage.checks))){
|
|
888
|
+
const ids=checks=>checks.map(c=>String(c.id)).join(', ').slice(0,600)||'(无)';
|
|
889
|
+
const sameIds=ids(current.checks)===ids(v.reviewPackage.checks);
|
|
890
|
+
throw Object.assign(new Error(`completion_checks_changed: 完成复查的检查清单与审查包不一致(${sameIds
|
|
891
|
+
?`编号相同但命令不同:${ids(current.checks)}`:`审查包:${ids(v.reviewPackage.checks)};本次:${ids(current.checks)}`})。按审查包的检查清单原样重跑后再发送 complete`),
|
|
892
|
+
{code:'completion_checks_changed'});
|
|
893
|
+
}
|
|
878
894
|
const checkResults=checks=>checks.map(c=>c.kind==='visual'
|
|
879
895
|
?{outcome:c.outcome}
|
|
880
896
|
:{outcome:c.outcome,exitCode:c.exitCode});
|
|
@@ -915,3 +931,8 @@ export function readReviewBaseline(raw) {
|
|
|
915
931
|
export function readReviewPackage(raw) {
|
|
916
932
|
const value=plain(raw);validPackage(value);return freeze(value);
|
|
917
933
|
}
|
|
934
|
+
|
|
935
|
+
// Reuse the same bounded scanner and two-sided stable policy for compatibility
|
|
936
|
+
// inventories; the default snapshot mode above is unchanged for JS callers.
|
|
937
|
+
export {snapshot,rootPath,stableIgnorePolicy,stablePublicPolicy,stableSnapshotPolicy,
|
|
938
|
+
comparableFiles,validateStablePolicy,filePath,INVENTORY_COUNT,INVENTORY_LIMIT};
|
|
@@ -64,7 +64,7 @@ export function fixReviewedAt(specsRoot,evidence){
|
|
|
64
64
|
// Journals without a registered V3 review have no order and never qualify.
|
|
65
65
|
export function approvedReviewAt(state){
|
|
66
66
|
const registration=state?.reviewInvocation?.registration;
|
|
67
|
-
return registration&®istration.
|
|
67
|
+
return registration&®istration.binding?.packageDigest===state.reviewPackage?.packageDigest
|
|
68
68
|
&&Number.isSafeInteger(registration.registeredAt)?registration.registeredAt:null;
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -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');}
|