@aibyzero/cm-workflow 0.19.0 → 0.21.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.
Files changed (127) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/AGENTS.md +8 -0
  3. package/CHANGELOG.md +38 -0
  4. package/README.md +15 -1
  5. package/VERSION +1 -1
  6. package/docs/architecture.md +3 -0
  7. package/docs/cm-acceptance-completion.md +185 -0
  8. package/docs/installation.md +1 -1
  9. package/docs/js-workflow-control.md +1 -1
  10. package/docs/proposals/spec-amendment-tiers.md +100 -0
  11. package/package.json +1 -1
  12. package/runtime/js/acceptance-language.mjs +32 -0
  13. package/runtime/js/autonomy.mjs +168 -3
  14. package/runtime/js/check-coverage.mjs +130 -0
  15. package/runtime/js/cm-ai/acceptance-contract.mjs +257 -0
  16. package/runtime/js/cm-ai/checkpoint-package-material.mjs +13 -3
  17. package/runtime/js/cm-ai/claude-developer-proposal.schema.json +18 -0
  18. package/runtime/js/cm-ai/cm-ai-admission.mjs +49 -8
  19. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +10 -6
  20. package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +8 -3
  21. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +1 -1
  22. package/runtime/js/cm-ai/codex-developer-output.schema.json +1 -1
  23. package/runtime/js/cm-ai/codex-review-adapter.mjs +19 -3
  24. package/runtime/js/cm-ai/completion-summary.mjs +187 -0
  25. package/runtime/js/cm-ai/control-policy.mjs +3 -1
  26. package/runtime/js/cm-ai/delivery-evidence.mjs +173 -0
  27. package/runtime/js/cm-ai/developer-adapter.mjs +4 -0
  28. package/runtime/js/cm-ai/drive-core.mjs +15 -4
  29. package/runtime/js/cm-ai/durable-runner-state.mjs +10 -6
  30. package/runtime/js/cm-ai/effect-contract.mjs +8 -1
  31. package/runtime/js/cm-ai/execution-snapshot.mjs +4 -3
  32. package/runtime/js/cm-ai/execution-store-limits.mjs +3 -3
  33. package/runtime/js/cm-ai/execution-store.mjs +7 -4
  34. package/runtime/js/cm-ai/fix-code-association.mjs +27 -6
  35. package/runtime/js/cm-ai/gate-bridge.mjs +13 -1
  36. package/runtime/js/cm-ai/host-conversation-execution.mjs +26 -14
  37. package/runtime/js/cm-ai/host-progress.mjs +2 -1
  38. package/runtime/js/cm-ai/log-rows.mjs +3 -2
  39. package/runtime/js/cm-ai/operator-guidance.mjs +110 -4
  40. package/runtime/js/cm-ai/requirement-evidence.mjs +4 -2
  41. package/runtime/js/cm-ai/review-package.mjs +22 -8
  42. package/runtime/js/cm-ai/review-presentation.mjs +12 -5
  43. package/runtime/js/cm-ai/reviewed-deliveries.mjs +10 -7
  44. package/runtime/js/cm-ai/reviewed-integration.mjs +1 -1
  45. package/runtime/js/cm-ai/spec-amendment.mjs +535 -0
  46. package/runtime/js/cm-ai/specification-material.mjs +57 -12
  47. package/runtime/js/cm-ai/task-commit.mjs +4 -2
  48. package/runtime/js/cm-ai/task-runner.mjs +64 -22
  49. package/runtime/js/cm-ai/user-maintained-paths.mjs +68 -0
  50. package/runtime/js/cm-ai/verification-auto.mjs +6 -4
  51. package/runtime/js/cm-prd/acceptance-preview.mjs +203 -0
  52. package/runtime/js/cm-prd/change.mjs +52 -5
  53. package/runtime/js/cm-prd/self-check.mjs +36 -6
  54. package/runtime/js/cm-prd/session.mjs +8 -3
  55. package/runtime/js/cm-prd/summary.mjs +5 -0
  56. package/runtime/js/cm-prd/task-scope-record.mjs +13 -7
  57. package/runtime/js/node-test-selection.mjs +38 -0
  58. package/runtime/js/run-analysis.mjs +153 -0
  59. package/runtime/js/session-boundary.mjs +17 -5
  60. package/runtime/js/session-handoff.mjs +5 -2
  61. package/runtime/js/task-scope.mjs +4 -1
  62. package/runtime/test-contract.md +1 -0
  63. package/scripts/cm-acceptance-preview.mjs +26 -0
  64. package/scripts/cm-acceptance-preview.test.mjs +156 -0
  65. package/scripts/cm-ai-acceptance-contract.test.mjs +195 -0
  66. package/scripts/cm-ai-admission.mjs +8 -2
  67. package/scripts/cm-ai-admission.test.mjs +20 -4
  68. package/scripts/cm-ai-blockage.test.mjs +120 -0
  69. package/scripts/cm-ai-checklist-coverage.test.mjs +5 -2
  70. package/scripts/cm-ai-checkpoint-package-material.test.mjs +60 -6
  71. package/scripts/cm-ai-checkpoint-package-owner.test.mjs +1 -0
  72. package/scripts/cm-ai-completion-summary.test.mjs +154 -0
  73. package/scripts/cm-ai-conversation-entry-ops.test.mjs +8 -2
  74. package/scripts/cm-ai-develop-driver-gaps.test.mjs +1 -0
  75. package/scripts/cm-ai-drive.mjs +18 -11
  76. package/scripts/cm-ai-fix-later-delivery.test.mjs +2 -2
  77. package/scripts/cm-ai-later-delivery-feature.test.mjs +102 -0
  78. package/scripts/cm-ai-progress.test.mjs +7 -0
  79. package/scripts/cm-ai-project-qa-gate.test.mjs +55 -4
  80. package/scripts/cm-ai-review-input-limit.test.mjs +91 -0
  81. package/scripts/cm-ai-run.test.mjs +23 -1
  82. package/scripts/cm-ai-spec-rebind.test.mjs +51 -15
  83. package/scripts/cm-ai-user-maintained-paths.test.mjs +183 -0
  84. package/scripts/cm-ai-verification-auto.test.mjs +33 -8
  85. package/scripts/cm-ai-verification-gate.test.mjs +1 -1
  86. package/scripts/cm-autonomy-acceptance.test.mjs +212 -0
  87. package/scripts/cm-autonomy-review-r1.test.mjs +142 -0
  88. package/scripts/cm-autonomy.mjs +3 -1
  89. package/scripts/cm-autonomy.test.mjs +10 -9
  90. package/scripts/cm-check-runtime.sh +5 -2
  91. package/scripts/cm-delivery-evidence.mjs +59 -0
  92. package/scripts/cm-delivery-evidence.test.mjs +177 -0
  93. package/scripts/cm-drive-liveness.test.mjs +14 -0
  94. package/scripts/cm-driver-light-import.test.mjs +32 -0
  95. package/scripts/cm-fix-observation-task-id.test.mjs +49 -0
  96. package/scripts/cm-fix-review-storage.test.mjs +14 -4
  97. package/scripts/cm-journal-limit.test.mjs +69 -0
  98. package/scripts/cm-mandatory-check-coverage.test.mjs +82 -0
  99. package/scripts/cm-node-test-selection.test.mjs +108 -0
  100. package/scripts/cm-notify-read-drift.test.mjs +6 -3
  101. package/scripts/cm-prd-completion.test.mjs +49 -0
  102. package/scripts/cm-prd-drive.mjs +1 -1
  103. package/scripts/cm-prd-host.mjs +3 -1
  104. package/scripts/cm-prd-host.test.mjs +19 -2
  105. package/scripts/cm-prd-self-check-rules.test.mjs +23 -11
  106. package/scripts/cm-prd-self-check.test.mjs +24 -1
  107. package/scripts/cm-prd-summary.test.mjs +25 -4
  108. package/scripts/cm-review-inventory.test.mjs +25 -6
  109. package/scripts/cm-run-analysis.mjs +21 -0
  110. package/scripts/cm-run-analysis.test.mjs +120 -0
  111. package/scripts/cm-spec-amend.mjs +68 -0
  112. package/scripts/cm-spec-amend.test.mjs +510 -0
  113. package/scripts/cm-specs-status.test.mjs +6 -0
  114. package/scripts/cm-start-check.mjs +140 -53
  115. package/scripts/cm-start-check.test.mjs +139 -1
  116. package/scripts/cm-task-scope.test.mjs +3 -2
  117. package/scripts/cm-usage-report.py +8 -3
  118. package/scripts/cm019-r1-contract.test.mjs +137 -0
  119. package/scripts/cm019-review-gates.test.mjs +97 -0
  120. package/scripts/test-journal-limit-1mib.mjs +4 -0
  121. package/scripts/validate-public-repo.py +4 -0
  122. package/skills/cm-ai/references/N1-init.md +23 -1
  123. package/skills/cm-ai/references/js-host-qa-recovery.md +3 -2
  124. package/skills/cm-ai/references/js-host-recovery.md +2 -1
  125. package/skills/cm-ai/references/js-host.md +7 -2
  126. package/skills/cm-prd/references/js-change-recovery.md +2 -1
  127. package/skills/cm-prd/references/js-host.md +1 -0
@@ -164,6 +164,24 @@
164
164
  "failed",
165
165
  null
166
166
  ]
167
+ },
168
+ "id": {
169
+ "type": [
170
+ "string",
171
+ "null"
172
+ ]
173
+ },
174
+ "evidenceType": {
175
+ "type": [
176
+ "string",
177
+ "null"
178
+ ]
179
+ },
180
+ "environment": {
181
+ "type": [
182
+ "string",
183
+ "null"
184
+ ]
167
185
  }
168
186
  }
169
187
  }
@@ -8,6 +8,7 @@ import {readSpecsStatus,writeSpecsStatus} from '../specs-status.mjs';
8
8
  import {readAutonomy,standingArchiveProblem} from '../autonomy.mjs';
9
9
  import {identifyApprovedBootstrapFeature} from './bootstrap-feature.mjs';
10
10
  import {buildManifest,verifyApprovedManifest} from '../../../scripts/cm-spec-manifest.mjs';
11
+ import {writeApprovalSnapshot,removeApprovalSnapshot,withApprovalLock} from './spec-amendment.mjs';
11
12
  import {outstandingFeatureQa,describeOutstandingQa} from './project-qa-gate.mjs';
12
13
  import {taskLines,taskDeclarations,approvedTaskGrammar,recordedTaskGrammar,TASK_GRAMMAR,SHARED_TASK_GRAMMAR,LEGACY_TASK_GRAMMAR,TASK_ID_SOURCE,isTaskId} from '../spec-task-line.mjs';
13
14
  export {identifyApprovedBootstrapFeature} from './bootstrap-feature.mjs';
@@ -216,6 +217,13 @@ function readFeature(specsDir,name){
216
217
  export function declaredAcceptanceIds(source){
217
218
  return new Set(source.split(/\r?\n/).map(line=>line.match(ACCEPTANCE)).filter(Boolean).map(match=>match[1]||match[2]));
218
219
  }
220
+ // 每条验收声明一行:{id, inapplicable}。紧跟编号写明 NOT_APPLICABLE(可隔冒号,如
221
+ // `- [ ] [AC-012] NOT_APPLICABLE:…(依据)`)的条目 inapplicable 为真;正文顺带提到的不算。
222
+ // 调用方自己决定围栏与同编号冲突的处理(Wue specs8 AC-012,2026-11-14)。
223
+ export function acceptanceDeclarations(source){
224
+ return source.split(/\r?\n/).map(line=>{const match=line.match(ACCEPTANCE);if(!match)return null;
225
+ return {id:match[1]||match[2],inapplicable:/^\s*[::]?\s*NOT_APPLICABLE(?=[\s::]|$)/.test(line.slice(match[0].length))};}).filter(Boolean);
226
+ }
219
227
 
220
228
  // Shared declaration grammar (spec-task-line.mjs), versioned by the approval.
221
229
  export function parseFeatureTaskText(source,{allowDependencyPunctuation=false,grammar=TASK_GRAMMAR}={}){
@@ -380,6 +388,19 @@ export function inspectCmAiAdmission(options){
380
388
  }
381
389
 
382
390
  // The CLI supplies every code project so no project can be skipped before writing.
391
+ // Shared by approval and its read-only preview; returns diagnostics only.
392
+ export function inspectTaskGrammarTransition(source,{grammar,fromLegacy=false}){
393
+ const parsed=parseFeatureTaskText(source,{allowDependencyPunctuation:true,grammar});
394
+ if(parsed.error)return {parsed,differing:[]};
395
+ if(!fromLegacy)return {parsed,differing:[]};
396
+ const view=version=>taskDeclarations(source,{grammar:version}).map(item=>({line:item.index+1,
397
+ key:`${item.id}\0${item.completed}\0${item.body.trim()}`,text:item.body.trim()}));
398
+ const legacy=view(LEGACY_TASK_GRAMMAR),current=view(grammar);
399
+ const legacyKeys=new Set(legacy.map(item=>item.key)),currentKeys=new Set(current.map(item=>item.key));
400
+ return {parsed,differing:[...current.filter(item=>!legacyKeys.has(item.key)),...legacy.filter(item=>!currentKeys.has(item.key))]
401
+ .sort((a,b)=>a.line-b.line)};
402
+ }
403
+
383
404
  export function approveCmAiSpecs(options){
384
405
  const projects=options.codeProjects??[options.codeProject];
385
406
  // The standing authorization (autonomy.mjs) stands in for the reply, and only for a bound change proposal.
@@ -425,7 +446,18 @@ export function approveCmAiSpecs(options){
425
446
  throw Object.assign(new Error('revision_changed_during_approval'),{code:'revision_changed_during_approval'});
426
447
  }};
427
448
  }
428
- try{
449
+ let specAmend;
450
+ // Runs under the approval lock shared with spec amendment re-binding. The decision
451
+ // rests on the status bytes validated above; it is void if another approval or
452
+ // publication replaced them since (inspect is re-run below for the rest).
453
+ const decidedStatus=status.bytes??null;
454
+ const write=()=>{
455
+ let now=null;
456
+ try{now=fs.readFileSync(path.join(specsDir,'.cm-specs-status'));}catch{}
457
+ if(!(decidedStatus===null?now===null:now!==null&&decidedStatus.equals(now)))
458
+ return refuse(bound?'revision_changed_during_approval':'spec_status_changed_during_approval');
459
+ if(inspect().some(item=>item.state!=='awaiting_spec_approval'||!allowed.has(item.reason)))
460
+ return refuse('spec_status_changed_during_approval');
429
461
  const discovered=discoverFeatures(specsDir);
430
462
  if(discovered.error)return refuse(discovered.error);
431
463
  // An approval binds a shared grammar (2 or 3) to every feature, including ones this change
@@ -446,27 +478,36 @@ export function approveCmAiSpecs(options){
446
478
  const grammar=status.kind==='valid'&&!fromLegacy?status.value.taskGrammar:SHARED_TASK_GRAMMAR;
447
479
  for(const name of discovered.names){
448
480
  const source=fs.readFileSync(path.join(specsDir,name,'tasks.md'),'utf8');
449
- const parsed=parseFeatureTaskText(source,{allowDependencyPunctuation:true,grammar});
481
+ const {parsed,differing}=inspectTaskGrammarTransition(source,{grammar,fromLegacy});
450
482
  if(parsed.error)return refuse('task_grammar_conflict',`${name}/tasks.md 第 ${parsed.detail.line} 行在新任务行语法下无效(${parsed.error}):`
451
483
  +`${parsed.detail.text}。此前的批准把它当作说明文字;把这类示例放进 \`\`\` 围栏或删去后再批准。`);
452
484
  if(!fromLegacy)continue;
453
- const view=grammar=>taskDeclarations(source,{grammar}).map(item=>({line:item.index+1,key:`${item.id}\0${item.completed}\0${item.body.trim()}`,text:item.body.trim()}));
454
- const legacy=view(LEGACY_TASK_GRAMMAR),current=view(grammar);
455
- const legacyKeys=new Set(legacy.map(item=>item.key)),currentKeys=new Set(current.map(item=>item.key));
456
- const differing=[...current.filter(item=>!legacyKeys.has(item.key)),...legacy.filter(item=>!currentKeys.has(item.key))]
457
- .sort((a,b)=>a.line-b.line);
458
485
  if(differing.length)return refuse('task_grammar_conflict',`${name}/tasks.md 在新任务行语法下任务集合会变化:`
459
486
  +differing.slice(0,5).map(item=>`第 ${item.line} 行 ${item.text}`).join(';')+`${differing.length>5?` 等 ${differing.length} 行`:''}`
460
487
  +'。此前的批准不把这些行当任务(或反之);是示例就放进 ``` 围栏或删去,是任务就改用英文冒号「:」写法后再批准。');
461
488
  }
462
489
  const specFiles=bound?bound.saved:buildManifest(specsDir),at=new Date().toISOString();
490
+ // Drop the previous round's snapshot first: if writing the new one fails,
491
+ // no older round or policy can stay in force.
492
+ removeApprovalSnapshot(specsDir);
463
493
  writeSpecsStatus(specsDir,{status:'approved',summaryDigest:status.value?.summaryDigest??null,at,
464
494
  features:discovered.names,specFiles,testCases:specFiles.filter(item=>item.path.endsWith('/test-cases.json')),
465
495
  approval:{response:approvalResponse,at},taskGrammar:grammar,
466
496
  ...(status.value&&Object.hasOwn(status.value,'revisionDigest')?{revisionDigest:status.value.revisionDigest}:{})},
467
497
  bound?{beforeRename:()=>bound.check()}:{});
498
+ // The snapshot only enables later reviewed corrections; failing to write it
499
+ // never undoes the human approval, it just leaves every change at tier 2.
500
+ try{specAmend={...writeApprovalSnapshot(specsDir,{features:discovered.names,specFiles,
501
+ approval:{response:approvalResponse,at},policy:options.specAmend===false?'off':'reviewed'}),snapshot:'written'};}
502
+ catch(error){specAmend={snapshot:'failed',reason:error.code??'spec_amend_snapshot_failed'};}
503
+ return null;
504
+ };
505
+ try{
506
+ if(typeof options._beforeApprovalLock==='function')options._beforeApprovalLock(); // test seam
507
+ const refused=withApprovalLock(specsDir,write);
508
+ if(refused)return refused;
468
509
  }catch(error){return refuse(error.code??error.message);}
469
- return {projectResults:inspect()};
510
+ return {projectResults:inspect(),specAmend};
470
511
  }
471
512
 
472
513
  function admissionFor(options,inProgressBootstrap=null){
@@ -15,6 +15,7 @@ import {REVIEWED_HANDOFF_HINT} from './host-handoff.mjs';
15
15
  import {readHostQaFixHandoff} from './host-qa-fix.mjs';
16
16
  import {readCloseoutPolicy,readCloseoutReport,closeoutSummary} from './knowledge-closeout.mjs';
17
17
  import {digest,freeze,hex,id,json,need,shape,text,validIdentity} from './effect-contract.mjs';
18
+ import {completionSummary,taskCompletion} from './completion-summary.mjs';
18
19
 
19
20
  const sameIdentity=(left,right)=>['repositoryId','runId','taskId','attempt'].every(key=>left[key]===right[key]);
20
21
  const sameTask=(left,right)=>['repositoryId','runId','taskId'].every(key=>left[key]===right[key]);
@@ -97,7 +98,7 @@ export const developFailureClass=status=>{
97
98
  };
98
99
  const summary=(operation,status,outcome)=>freeze({version:1,workflow:'cm-ai',operation:operation.operation,
99
100
  requestDigest:digest(operation),identity:status.identity,outcome,state:status.state,code:status.code??null,
100
- packageDigest:status.packageDigest??null,pendingAction:pendingAction(status),
101
+ packageDigest:status.packageDigest??null,pendingAction:pendingAction(status),completion:{task:taskCompletion(status)},
101
102
  ...(status.reviewReconciliation?{reviewReconciliation:status.reviewReconciliation}:{}),
102
103
  ...(status.effectiveScope?{effectiveScope:status.effectiveScope}:{}),
103
104
  ...(status.acceptedIntegrationDigest?{acceptedIntegrationDigest:status.acceptedIntegrationDigest}:{}),
@@ -218,7 +219,7 @@ const contextSummary=(operation,status,refresh)=>freeze({version:1,workflow:'cm-
218
219
  requestDigest:digest(operation),identity:status.identity,outcome:'refreshed',state:status.state,
219
220
  code:refresh.state==='complete'?'context_complete':'context_refreshed',packageDigest:status.packageDigest,
220
221
  pendingAction:refresh.state==='complete'?'finish':'start_next_task',nextTask:refresh.nextTask,
221
- contextDigest:refresh.contextDigest,contextFiles:refresh.contextFiles});
222
+ contextDigest:refresh.contextDigest,contextFiles:refresh.contextFiles,completion:{task:taskCompletion(status)}});
222
223
 
223
224
  function validateDocumentationResult(result,status,refresh,policy=null) {
224
225
  shape(result,['syncId','identity','packageDigest','contextDigest','status','reason','at',
@@ -877,13 +878,15 @@ export function createCmAiConversationEntry(options) {
877
878
  +'宿主只在运行日志记有该命令进程组身份且核对进程组已退出时补记释放;先结束残留进程后重发 run_finalize,记录里没有进程身份的旧资源需人工处理。'},'blocked');
878
879
  const input={specsDir:options.specsDir,codeProject:options.codeProject,feature:options.feature,identity,
879
880
  packageDigest:operation.packageDigest,contextDigest:refresh.contextDigest,
880
- documentationSyncId:documentation.syncId};
881
+ documentationSyncId:documentation.syncId,
882
+ scopeFeatures:[...new Set(refresh.contextFiles.filter(file=>file.scope==='specs'&&file.path.endsWith('/tasks.md'))
883
+ .map(file=>file.path.split('/')[0]))].sort()};
881
884
  if(Object.hasOwn(options,'qaLogHome'))input.logHome=options.qaLogHome;
882
885
  const result=recordCmAiRunDone(input);
883
886
  return freeze({version:1,workflow:'cm-ai',operation:operation.operation,requestDigest:digest(operation),identity,
884
887
  outcome:'finalized',state:'run_done',code:result.degraded?'run_done_degraded':'run_done',
885
888
  packageDigest:operation.packageDigest,pendingAction:'none',contextDigest:refresh.contextDigest,
886
- deduplicated:result.deduplicated,degraded:result.degraded,
889
+ deduplicated:result.deduplicated,degraded:result.degraded,completion:{task:taskCompletion(status)},
887
890
  ...closeoutSummary(knowledgeCloseout,documentation)});
888
891
  }
889
892
  need(['start','resume'].includes(operation.operation),'invalid_input');
@@ -927,8 +930,9 @@ export function createCmAiConversationEntry(options) {
927
930
  token=Symbol(operation.operation);inFlightHandles.add(token);
928
931
  }
929
932
  const routed=await route(operation);
930
- const guidance=operatorGuidance(routed,{executionActive:inFlightHandles.size>(token===null?0:1)});
931
- const result=guidance?freeze({...routed,guidance}):routed;
933
+ const projected={...routed,completion:completionSummary({specsDir:options.specsDir,feature:options.feature,result:routed})};
934
+ const guidance=operatorGuidance(projected,{executionActive:inFlightHandles.size>(token===null?0:1)});
935
+ const result=freeze({...projected,...(guidance?{guidance}:{})});
932
936
  if(!admissionReports.has(routed)&&(epoch===cancellationEpoch||operation.operation==='cancel'))projectHostResult({specsDir:options.specsDir,
933
937
  feature:options.feature,result,readCurrent:()=>runner.status()});
934
938
  return result;
@@ -40,15 +40,20 @@ function readResult(stdout,identity,specsDir) {
40
40
  export function recordCmAiRunDone(input) {
41
41
  const keys=['specsDir','codeProject','feature','identity','packageDigest','contextDigest','documentationSyncId'];
42
42
  if(input&&Object.hasOwn(input,'logHome'))keys.push('logHome');
43
+ if(input&&Object.hasOwn(input,'scopeFeatures'))keys.push('scopeFeatures');
43
44
  shape(input,keys);text(input.specsDir);text(input.codeProject);text(input.feature);validIdentity(input.identity);
44
45
  hex(input.packageDigest);hex(input.contextDigest);id(input.documentationSyncId);
46
+ if(Object.hasOwn(input,'scopeFeatures'))need(Array.isArray(input.scopeFeatures)&&input.scopeFeatures.length>0
47
+ &&new Set(input.scopeFeatures).size===input.scopeFeatures.length&&input.scopeFeatures.includes(input.feature)
48
+ &&input.scopeFeatures.every(name=>typeof name==='string'&&/^\d+\.[^/\\\x00-\x1f]+$/.test(name)),'invalid_input');
45
49
  need(validRunId(input.identity.runId),'invalid_run_id');
46
50
  statusTarget(input.specsDir);
47
51
  const data={node:'N8',feature:input.feature,task:input.identity.taskId,package_digest:input.packageDigest,
48
- context_digest:input.contextDigest,documentation_sync_id:input.documentationSyncId};
52
+ context_digest:input.contextDigest,documentation_sync_id:input.documentationSyncId,
53
+ ...(input.scopeFeatures?{scope_features:input.scopeFeatures,repository_id:input.identity.repositoryId,attempt:input.identity.attempt}:{})};
49
54
  const args=[writer,'--workflow','cm-ai','--event','run_done','--runtime','codex',
50
55
  '--project-root',input.codeProject,'--specs-dir',input.specsDir,'--run-id',input.identity.runId,
51
- '--detail','全部任务和文档同步已完成','--data-json',JSON.stringify(data)];
56
+ '--detail','本运行选定范围已通过收尾门禁;产品验收与部署另计','--data-json',JSON.stringify(data)];
52
57
  const options={timeout:10000,maxBuffer:MiB,killSignal:'SIGKILL'};
53
58
  if(Object.hasOwn(input,'logHome')){text(input.logHome);options.env={...process.env,CM_WORKFLOW_LOG_HOME:input.logHome};}
54
59
  let result;
@@ -61,7 +66,7 @@ export function recordCmAiRunDone(input) {
61
66
  catch{need(false,'run_finalize_unknown');}
62
67
  try {
63
68
  writeStatusProjection({specsDir:input.specsDir,feature:input.feature,identity:input.identity,node:'N8',
64
- state:'run_done',detail:'全部任务和文档同步已完成'});
69
+ state:'run_done',detail:'本运行选定范围已收尾;产品验收与部署未由本记录证明'});
65
70
  }catch{need(false,'run_finalize_unknown');}
66
71
  return Object.freeze({eventId:receipt.event_id,runId:receipt.run_id,
67
72
  deduplicated:receipt.deduplicated,degraded:receipt.degraded});
@@ -5,6 +5,6 @@
5
5
  "properties": {
6
6
  "outcome": {"type": "string", "enum": ["implemented", "blocked"]},
7
7
  "reason": {"type": ["string", "null"]},
8
- "requirements": {"type": ["array", "null"], "maxItems": 64, "items": {"type": "object", "additionalProperties": false, "required": ["requirement", "satisfied", "evidence", "run", "result"], "properties": {"requirement": {"type": "string"}, "satisfied": {"type": "boolean"}, "evidence": {"type": "string"}, "run": {"type": ["string", "null"], "enum": ["red", "baseline", null]}, "result": {"type": ["string", "null"], "enum": ["passed", "failed", null]}}}}
8
+ "requirements": {"type": ["array", "null"], "maxItems": 64, "items": {"type": "object", "additionalProperties": false, "required": ["requirement", "satisfied", "evidence", "run", "result", "id", "evidenceType", "environment"], "properties": {"requirement": {"type": "string"}, "satisfied": {"type": "boolean"}, "evidence": {"type": "string"}, "run": {"type": ["string", "null"], "enum": ["red", "baseline", null]}, "result": {"type": ["string", "null"], "enum": ["passed", "failed", null]}, "id": {"type": ["string", "null"]}, "evidenceType": {"type": ["string", "null"]}, "environment": {"type": ["string", "null"]}}}}
9
9
  }
10
10
  }
@@ -5,7 +5,7 @@
5
5
  "properties": {
6
6
  "outcome": {"type": "string", "enum": ["implemented", "blocked"]},
7
7
  "reason": {"type": ["string", "null"]},
8
- "requirements": {"type": ["array", "null"], "maxItems": 64, "items": {"type": "object", "additionalProperties": false, "required": ["requirement", "satisfied", "evidence", "run", "result"], "properties": {"requirement": {"type": "string"}, "satisfied": {"type": "boolean"}, "evidence": {"type": "string"}, "run": {"type": ["string", "null"], "enum": ["red", "baseline", null]}, "result": {"type": ["string", "null"], "enum": ["passed", "failed", null]}}}},
8
+ "requirements": {"type": ["array", "null"], "maxItems": 64, "items": {"type": "object", "additionalProperties": false, "required": ["requirement", "satisfied", "evidence", "run", "result", "id", "evidenceType", "environment"], "properties": {"requirement": {"type": "string"}, "satisfied": {"type": "boolean"}, "evidence": {"type": "string"}, "run": {"type": ["string", "null"], "enum": ["red", "baseline", null]}, "result": {"type": ["string", "null"], "enum": ["passed", "failed", null]}, "id": {"type": ["string", "null"]}, "evidenceType": {"type": ["string", "null"]}, "environment": {"type": ["string", "null"]}}}},
9
9
  "application": {
10
10
  "type": "object", "additionalProperties": false,
11
11
  "required": ["status", "note"],
@@ -65,11 +65,27 @@ export function buildCodexReviewPrompt(raw) {
65
65
  // Shared package/prompt contract; the trusted adapter selects the provider.
66
66
  export function buildReviewPrompt(raw,provider,executionPolicy=null) {
67
67
  const {request,reviewPackage}=readReviewerRequest(raw,provider);
68
- const data=json({reviewPackage,priorReview:request.payload.priorReview,
69
- ...(Object.hasOwn(request.payload,'supersededReview')?{supersededReview:request.payload.supersededReview}:{}),
68
+ return presentationPrompt(reviewPromptData(reviewPackage,request.payload),INSTRUCTIONS,executionPolicy,provider);
69
+ }
70
+ function reviewPromptData(reviewPackage,payload){
71
+ return json({reviewPackage,priorReview:payload.priorReview,
72
+ ...(Object.hasOwn(payload,'supersededReview')?{supersededReview:payload.supersededReview}:{}),
70
73
  examinedPaths:reviewPaths(reviewPackage),
71
74
  ...(reviewPackage.handoff?{handoffPath:reviewPackage.handoff.path}:{})},REQUEST_LIMIT);
72
- return presentationPrompt(data,INSTRUCTIONS,executionPolicy,provider);
75
+ }
76
+
77
+ // Whether the review prompt for this package (same data and presentation the review
78
+ // will send) fits the reviewer's input limit. Develop asks before it accepts a
79
+ // delivery: a package no reviewer can take must be refused there, not left as an
80
+ // unknown review the run cannot redo (Codex takes at most 1 MiB of input).
81
+ export function reviewInputFit({reviewPackage,payload,provider,executionPolicy=null}){
82
+ need(['codex','claude'].includes(provider),'review_request_invalid');
83
+ const limit=provider==='codex'?CODEX_INPUT_LIMIT:PROMPT_LIMIT;
84
+ try{
85
+ const prompt=presentationPrompt(reviewPromptData(readReviewPackage(reviewPackage),{priorReview:null,...payload}),
86
+ INSTRUCTIONS,executionPolicy,provider);
87
+ return {fits:true,bytes:Buffer.byteLength(prompt,'utf8'),limit};
88
+ }catch(error){if(error?.code==='limit_exceeded')return {fits:false,bytes:null,limit};throw error;}
73
89
  }
74
90
 
75
91
  export function buildCauseReviewPrompt(raw,provider,executionPolicy=null){
@@ -0,0 +1,187 @@
1
+ // Read-only completion projection. It neither authorizes a transition nor writes
2
+ // task state. The host supplies its already validated runner status; all wider
3
+ // claims come from the approved inventory and strictly bound latest QA evidence.
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import {verifyApprovedManifest} from '../../../scripts/cm-spec-manifest.mjs';
7
+ import {recordedTaskGrammar} from '../spec-task-line.mjs';
8
+ import {parseFeatureTaskText} from './cm-ai-admission.mjs';
9
+ import {findCmAiQaDecision,latestCmAiQaRun} from './cm-ai-qa-log.mjs';
10
+ import {readReviewSourceFiles} from './review-package.mjs';
11
+ import {readStableLogRows} from './log-rows.mjs';
12
+ import {readExecutionSnapshot} from './execution-snapshot.mjs';
13
+ import {readRunnerHistory} from './durable-runner-state.mjs';
14
+ import {digest,freeze,need} from './effect-contract.mjs';
15
+ import {deliveryProjection} from './delivery-evidence.mjs';
16
+
17
+ const unknown=reason=>({status:'unknown',reason,evidence:[]});
18
+ const sameIdentity=(a,b)=>a&&b&&['repositoryId','runId','taskId','attempt'].every(key=>a[key]===b[key]);
19
+ const blockedCodes=new Set(['correction_review_required','spec_drift']);
20
+ const safeCode=error=>typeof error?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(error.code)?error.code:'completion_evidence_unavailable';
21
+
22
+ // The receipt has already passed the owning runner's registration/replay gates.
23
+ // These checks prevent this display from accidentally pairing a previous receipt
24
+ // with a different task/attempt/candidate; they are not a new completion gate.
25
+ export function taskCompletion(status){
26
+ const receipt=status?.receipt,{receiptDigest,...body}=receipt??{};
27
+ const matched=receipt?.kind==='cm-review-receipt'&&sameIdentity(receipt.identity,status.identity)
28
+ &&receipt.packageDigest===status.packageDigest&&receiptDigest===digest(body);
29
+ const historicalCompleted=['fixture_completed','run_done'].includes(status?.state);
30
+ const blocked=blockedCodes.has(status?.code)||status?.state==='blocked';
31
+ const review=matched?{status:receipt.result?.verdict==='approved'?'passed':receipt.result?.verdict==='changes_requested'?'failed':'blocked',
32
+ evidence:[`receipt:${receiptDigest}`]}:unknown('registered_review_receipt_unavailable');
33
+ return {status:blocked?'blocked':status?.state==='unknown'?'unknown':historicalCompleted&&review.status==='passed'?'completed':historicalCompleted?'unknown':'pending',
34
+ historicalCompleted,review,reason:blocked?status.code:historicalCompleted&&review.status!=='passed'?'registered_review_receipt_unavailable':null,
35
+ evidence:matched?[`receipt:${receiptDigest}`,`package:${status.packageDigest}`]:[]};
36
+ }
37
+
38
+ const statKey=file=>{
39
+ try{const s=fs.lstatSync(file,{bigint:true});
40
+ need(!s.isSymbolicLink()&&s.isFile()&&s.nlink===1n,'completion_source_invalid');
41
+ return [s.dev,s.ino,s.mode,s.size,s.mtimeNs,s.ctimeNs].join(':');
42
+ }catch(error){if(error.code==='ENOENT')return null;throw error;}
43
+ };
44
+
45
+ export function completionSummary({specsDir,feature,result,task=result?.completion?.task??taskCompletion(result)}){
46
+ const identity=result?.identity??null,packageDigest=result?.packageDigest??null;
47
+ const binding={feature:feature??null,identity,packageDigest,runnerRevision:null};
48
+ const base={version:1,binding,task,feature:unknown('approved_inventory_unavailable'),
49
+ project:unknown('approved_inventory_unavailable'),run:unknown('run_done_evidence_unavailable'),
50
+ productAcceptance:unknown('external_owner_acceptance_not_recorded'),deployment:unknown('deployment_evidence_not_recorded')};
51
+ try{
52
+ need(typeof specsDir==='string'&&path.isAbsolute(specsDir)&&fs.realpathSync(specsDir)===specsDir,'completion_source_invalid');
53
+ const watched=new Map(),watch=file=>{if(!watched.has(file))watched.set(file,statKey(file));};
54
+ const snapshots=new Map(),histories=new Map();
55
+ const snapshotFor=who=>{
56
+ const key=digest({repositoryId:who.repositoryId,runId:who.runId});
57
+ watch(path.join(specsDir,'.reviews','.execution',who.runId,'state.json'));
58
+ if(!snapshots.has(key))snapshots.set(key,readExecutionSnapshot({specsRoot:specsDir,
59
+ identity:{repositoryId:who.repositoryId,runId:who.runId}}));
60
+ return snapshots.get(key);
61
+ };
62
+ const completedOwner=(who,candidate)=>{
63
+ const snapshot=snapshotFor(who);
64
+ if(!histories.has(snapshot.revision)){
65
+ const init=snapshot.records[0]?.payload;
66
+ histories.set(snapshot.revision,readRunnerHistory(snapshot.records,init.config,init.version));
67
+ }
68
+ const history=histories.get(snapshot.revision),state=history.state;
69
+ need(history.pending===null&&state.state==='fixture_completed'&&state.attempt===who.attempt
70
+ &&state.reviewPackage?.packageDigest===candidate&&sameIdentity(state.receipt?.identity,who),'completion_owner_changed');
71
+ return {snapshot,history};
72
+ };
73
+ const statusFile=path.join(specsDir,'.cm-specs-status');watch(statusFile);
74
+ let acceptanceProtection='unknown',boundSources=null;
75
+ if(identity?.runId){
76
+ watch(path.join(specsDir,'.reviews','.execution',identity.runId,'state.json'));
77
+ try{
78
+ const snapshot=snapshotFor(identity);binding.runnerRevision=snapshot.revision;
79
+ const baseline=snapshot.records[0]?.payload?.baseline;
80
+ if(baseline)acceptanceProtection=baseline.specification?.acceptanceContract?.version===1?'contract_v1':'legacy_unprotected';
81
+ if(baseline?.specification)boundSources=snapshot.records.findLast(item=>item.payload?.type==='specification-rebound')?.payload.record?.sources
82
+ ??baseline.specification.sources;
83
+ }catch{/* Missing legacy evidence stays unknown; no upgrade or journal write. */}
84
+ }
85
+ if(task.status==='completed')try{
86
+ const {history}=completedOwner(identity,packageDigest);
87
+ need(task.review.evidence.includes(`receipt:${history.state.receipt.receiptDigest}`),'completion_owner_changed');
88
+ }catch(error){task={...task,status:'unknown',reason:safeCode(error)};}
89
+ const approvalRecord=readReviewSourceFiles(specsDir,['.cm-specs-status'])[0];
90
+ const approval=JSON.parse(Buffer.from(approvalRecord.contentBase64,'base64').toString('utf8'));
91
+ need(approval.status==='approved'&&Array.isArray(approval.features)&&approval.features.length>0
92
+ &&new Set(approval.features).size===approval.features.length,'completion_inventory_invalid');
93
+ const manifest=verifyApprovedManifest(specsDir,statusFile);
94
+ if(boundSources!==null&&digest(boundSources)!==digest(manifest.filter(item=>item.path.startsWith(feature+'/'))))
95
+ task={...task,status:'blocked',reason:'spec_drift'};
96
+ const names=[...approval.features].sort();
97
+ need(digest(names)===digest([...new Set(manifest.map(row=>row.path.split('/')[0]))].sort()),'completion_inventory_invalid');
98
+ for(const row of manifest)watch(path.join(specsDir,row.path));
99
+ const log=path.join(specsDir,'运行日志.jsonl');watch(log);
100
+ const rows=watched.get(log)===null?[]:readStableLogRows(log,row=>row?.schema_version===1&&row.workflow==='cm-ai','completion_log_invalid',{maxBytes:32*1024*1024});
101
+ const latest=new Map();for(const row of rows)if(row.event==='qa'&&row.node==='N6')latest.set(row.feature,row);
102
+ const qaFor=(name,pending)=>{
103
+ const row=latest.get(name);if(!row)return unknown('qa_missing');
104
+ const qaIdentity={repositoryId:row.repository_id,runId:row.run_id,taskId:row.task,attempt:row.attempt};
105
+ const input={specsDir,feature:name,identity:qaIdentity,packageDigest:row.package_digest};
106
+ const evidence=[`运行日志.jsonl#${row.event_id??row.decision_id}`];
107
+ try{
108
+ if(name===feature&&(!identity||!packageDigest))return {...unknown('current_candidate_unavailable'),evidence,binding:input.identity,packageDigest:input.packageDigest};
109
+ if(name===feature)
110
+ need(sameIdentity(qaIdentity,identity)&&row.package_digest===packageDigest,'qa_candidate_changed');
111
+ watch(path.join(specsDir,'.reviews','.execution',qaIdentity.runId,'state.json'));
112
+ for(const item of rows)if(item.event==='test_run'&&item.run_id===qaIdentity.runId&&typeof item.report==='string')
113
+ watch(path.resolve(specsDir,item.report));
114
+ const decision=findCmAiQaDecision(input);need(decision?.decisionId===row.decision_id,'qa_decision_mismatch');
115
+ if(decision.status==='skipped')return {status:'skipped',reason:pending===0?'terminal_feature_qa_required':decision.reason,
116
+ evidence,binding:input.identity,packageDigest:input.packageDigest};
117
+ if(decision.status==='blocked')return {status:'blocked',reason:decision.reason,evidence,binding:input.identity,packageDigest:input.packageDigest};
118
+ const inspected=latestCmAiQaRun(input);
119
+ if(inspected===null)return {...unknown('qa_not_run'),evidence,binding:input.identity,packageDigest:input.packageDigest};
120
+ if(inspected.status==='passed'){
121
+ // A valid old QA round proves its bound candidate, not a later approved
122
+ // specification. Reuse the owner's original sources / explicit rebind.
123
+ let owner;
124
+ try{owner=completedOwner(qaIdentity,row.package_digest).snapshot;}
125
+ catch{return {...unknown('qa_specification_unavailable'),evidence,binding:input.identity,packageDigest:input.packageDigest};}
126
+ const baseline=owner.records[0]?.payload?.baseline,material=baseline?.specification;
127
+ if(!material)return {...unknown('qa_specification_unavailable'),evidence,binding:input.identity,packageDigest:input.packageDigest};
128
+ need(material.feature===name&&baseline.identity.taskId===qaIdentity.taskId,'qa_specification_mismatch');
129
+ const rebind=owner.records.findLast(item=>item.payload?.type==='specification-rebound')?.payload.record;
130
+ const sources=rebind?.sources??material.sources;
131
+ need(digest(sources)===digest(manifest.filter(item=>item.path.startsWith(name+'/'))),'qa_specification_changed');
132
+ }
133
+ return {status:inspected.status,reason:inspected.status==='passed'?null:`qa_${inspected.status}`,
134
+ evidence:[...evidence,`test_run:${inspected.testRunId}`],binding:input.identity,packageDigest:input.packageDigest};
135
+ }catch(error){const code=safeCode(error);return {status:code==='qa_result_incomplete'?'unknown':'blocked',reason:code,evidence,
136
+ binding:input.identity,packageDigest:input.packageDigest};}
137
+ };
138
+ const features=names.map(name=>{
139
+ const record=readReviewSourceFiles(specsDir,[`${name}/tasks.md`])[0];
140
+ const parsed=parseFeatureTaskText(Buffer.from(record.contentBase64,'base64').toString('utf8'),
141
+ {allowDependencyPunctuation:true,grammar:recordedTaskGrammar(approval.taskGrammar)});
142
+ need(!parsed.error,'completion_tasks_invalid');
143
+ const active=parsed.tasks.filter(item=>!item.dropped),completed=active.filter(item=>item.completed).length;
144
+ const pending=active.length-completed,qa=qaFor(name,pending);
145
+ const tasks={completed,total:active.length,pending,open:active.filter(item=>!item.completed).map(item=>item.id),
146
+ dropped:parsed.tasks.filter(item=>item.dropped).length,evidence:[`${name}/tasks.md#sha256=${record.sha256}`]};
147
+ return {name,status:pending>0?'pending':qa.status==='passed'?'passed':qa.status==='failed'?'failed':qa.status==='unknown'?'unknown':'blocked',tasks,qa};
148
+ });
149
+ const finalRow=rows.filter(row=>row.event==='run_done'&&row.node==='N8'&&row.feature===feature
150
+ &&(row.repository_id===identity?.repositoryId||row.repository_id===undefined)&&row.run_id===identity?.runId&&row.task===identity?.taskId
151
+ &&row.package_digest===packageDigest).at(-1);
152
+ const runEvidence=finalRow?[`运行日志.jsonl#${finalRow.event_id}`,`context:${finalRow.context_digest}`]:[];
153
+ const finalized=Boolean(finalRow&&typeof finalRow.documentation_sync_id==='string'
154
+ &&/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(finalRow.documentation_sync_id)&&/^[a-f0-9]{64}$/.test(finalRow.context_digest));
155
+ const legacyBinding=finalized&&finalRow.repository_id===undefined;
156
+ const currentBlocked=task.status==='blocked';
157
+ const currentUnknown=task.status==='unknown'&&task.historicalCompleted;
158
+ const scope=finalRow?.scope_features,scoped=Array.isArray(scope)?features.filter(item=>scope.includes(item.name)):[];
159
+ const scopeCurrent=scoped.length>0&&scoped.length===scope?.length&&scoped.every(item=>item.status==='passed');
160
+ const closeoutBlocked=['documentation_sync_blocked','project_qa_not_passed','qa_resources_open'].includes(result?.code);
161
+ const run={status:currentBlocked||closeoutBlocked?'blocked':currentUnknown||legacyBinding?'unknown':finalized?(scopeCurrent?'finalized':scope?'blocked':'unknown'):
162
+ result?.code==='documentation_synced'?'ready_to_finalize':'pending',
163
+ historicalFinalized:finalized,reason:currentBlocked?task.reason:closeoutBlocked?result.code:legacyBinding?'legacy_closeout_binding_unknown':currentUnknown?task.reason:
164
+ finalized?(scopeCurrent?null:scope?'scoped_acceptance_not_current':'legacy_closeout_scope_unknown'):'run_done_not_recorded',
165
+ scope:finalRow?.scope_features??null,evidence:runEvidence};
166
+ const allPassed=features.every(item=>item.status==='passed');
167
+ const fullCloseout=finalized&&!legacyBinding&&Array.isArray(finalRow.scope_features)&&digest([...finalRow.scope_features].sort())===digest(names);
168
+ const project={status:currentBlocked?'blocked':currentUnknown?'unknown':allPassed&&fullCloseout?'completed':allPassed?'ready_to_finalize':features.some(item=>item.status==='failed')?'failed':
169
+ features.some(item=>item.tasks.pending>0)?'pending':features.some(item=>item.status==='blocked')?'blocked':'unknown',
170
+ scope:names,features,completedFeatures:features.filter(item=>item.status==='passed').length,totalFeatures:features.length,
171
+ pendingTasks:features.reduce((sum,item)=>sum+item.tasks.pending,0),historicalFinalized:fullCloseout,
172
+ reason:currentBlocked||currentUnknown?task.reason:allPassed&&!fullCloseout?'full_project_closeout_not_recorded':null,
173
+ evidence:[`.cm-specs-status#sha256=${approvalRecord.sha256}`,...(fullCloseout?runEvidence:[])]};
174
+ const delivery=deliveryProjection({specsDir,feature,identity,packageDigest,specificationDigest:digest(manifest),
175
+ current:task.status==='completed',maxEvidenceBytes:8*1024*1024});
176
+ // Cross-file snapshot: do not compose earlier tasks with a later QA result.
177
+ verifyApprovedManifest(specsDir,statusFile);
178
+ need([...watched].every(([file,key])=>statKey(file)===key),'completion_snapshot_changed');
179
+ const snapshotDigest=digest({approval:approvalRecord.sha256,files:[...watched].map(([file,key])=>[path.relative(specsDir,file),key]),binding,delivery});
180
+ const selected=features.find(item=>item.name===feature)??unknown('feature_not_approved');
181
+ return freeze({...base,...delivery,task:{...task,acceptanceProtection},snapshotDigest,
182
+ feature:currentBlocked||currentUnknown?{...selected,status:currentBlocked?'blocked':'unknown',reason:task.reason}:selected,project,run});
183
+ }catch(error){const reason=safeCode(error);return freeze({...base,task:{...task,status:'unknown',reason},
184
+ feature:unknown(reason),project:unknown(reason),run:unknown(reason)});}
185
+ }
186
+
187
+ export {completionLines} from './operator-guidance.mjs';
@@ -9,7 +9,9 @@ export const CONTROL_RECOVERY_OPERATIONS=Object.freeze(['abandon_review','abando
9
9
  export const CONTROL_FIX_RECOVERY_OPERATIONS=Object.freeze(['abandon_step','abandon_review','rediagnose',
10
10
  'rerun_blocked_step','recover_final_review','reconcile_review']);
11
11
  // verification is optional so policies saved before it existed keep their exact
12
- // digest; absent means the same as disabled. precheck enables the delivery
12
+ // digest; absent means the same as disabled for legacy baselines. New baselines
13
+ // carry a mandatory acceptanceContract; disabled never disables that contract.
14
+ // precheck enables the delivery
13
15
  // verification gate for every launch of the run it is saved into; auto enables
14
16
  // the same gate answered by the host (verification-auto.mjs), for unattended runs.
15
17
  export function readControlPolicy(raw){