@aibyzero/cm-workflow 0.18.0 → 0.20.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 (90) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/AGENTS.md +8 -0
  3. package/CHANGELOG.md +26 -0
  4. package/README.md +14 -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/package.json +1 -1
  10. package/runtime/js/autonomy.mjs +308 -0
  11. package/runtime/js/check-coverage.mjs +130 -0
  12. package/runtime/js/cm-ai/acceptance-contract.mjs +252 -0
  13. package/runtime/js/cm-ai/claude-developer-proposal.schema.json +18 -0
  14. package/runtime/js/cm-ai/cm-ai-admission.mjs +53 -12
  15. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +10 -6
  16. package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +8 -3
  17. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +1 -1
  18. package/runtime/js/cm-ai/codex-developer-output.schema.json +1 -1
  19. package/runtime/js/cm-ai/completion-summary.mjs +187 -0
  20. package/runtime/js/cm-ai/control-policy.mjs +3 -1
  21. package/runtime/js/cm-ai/delivery-evidence.mjs +173 -0
  22. package/runtime/js/cm-ai/developer-adapter.mjs +4 -0
  23. package/runtime/js/cm-ai/drive-core.mjs +8 -3
  24. package/runtime/js/cm-ai/durable-runner-state.mjs +2 -2
  25. package/runtime/js/cm-ai/gate-bridge.mjs +13 -1
  26. package/runtime/js/cm-ai/host-conversation-execution.mjs +26 -14
  27. package/runtime/js/cm-ai/host-progress.mjs +2 -1
  28. package/runtime/js/cm-ai/log-rows.mjs +3 -2
  29. package/runtime/js/cm-ai/operator-guidance.mjs +110 -4
  30. package/runtime/js/cm-ai/requirement-evidence.mjs +4 -2
  31. package/runtime/js/cm-ai/review-package.mjs +2 -2
  32. package/runtime/js/cm-ai/specification-material.mjs +57 -12
  33. package/runtime/js/cm-ai/task-runner.mjs +38 -13
  34. package/runtime/js/cm-ai/verification-auto.mjs +6 -4
  35. package/runtime/js/cm-prd/acceptance-preview.mjs +203 -0
  36. package/runtime/js/cm-prd/change.mjs +17 -1
  37. package/runtime/js/cm-prd/summary.mjs +5 -0
  38. package/runtime/js/node-test-selection.mjs +38 -0
  39. package/runtime/js/notify.mjs +17 -8
  40. package/runtime/js/run-analysis.mjs +153 -0
  41. package/runtime/js/session-boundary.mjs +17 -5
  42. package/runtime/js/session-handoff.mjs +5 -2
  43. package/runtime/js/specs-status.mjs +4 -3
  44. package/scripts/cm-acceptance-preview.mjs +26 -0
  45. package/scripts/cm-acceptance-preview.test.mjs +156 -0
  46. package/scripts/cm-ai-acceptance-contract.test.mjs +185 -0
  47. package/scripts/cm-ai-admission.mjs +10 -2
  48. package/scripts/cm-ai-admission.test.mjs +151 -1
  49. package/scripts/cm-ai-blockage.test.mjs +120 -0
  50. package/scripts/cm-ai-checklist-coverage.test.mjs +5 -2
  51. package/scripts/cm-ai-completion-summary.test.mjs +154 -0
  52. package/scripts/cm-ai-conversation-entry-ops.test.mjs +8 -2
  53. package/scripts/cm-ai-progress.test.mjs +7 -0
  54. package/scripts/cm-ai-project-qa-gate.test.mjs +55 -4
  55. package/scripts/cm-ai-run.test.mjs +23 -1
  56. package/scripts/cm-ai-spec-rebind.test.mjs +51 -15
  57. package/scripts/cm-ai-verification-auto.test.mjs +33 -8
  58. package/scripts/cm-ai-verification-gate.test.mjs +1 -1
  59. package/scripts/cm-autonomy-acceptance.test.mjs +212 -0
  60. package/scripts/cm-autonomy-review-r1.test.mjs +93 -0
  61. package/scripts/cm-autonomy.mjs +96 -0
  62. package/scripts/cm-autonomy.test.mjs +163 -0
  63. package/scripts/cm-check-runtime.sh +3 -1
  64. package/scripts/cm-delivery-evidence.mjs +59 -0
  65. package/scripts/cm-delivery-evidence.test.mjs +177 -0
  66. package/scripts/cm-drive-liveness.test.mjs +6 -0
  67. package/scripts/cm-driver-light-import.test.mjs +32 -0
  68. package/scripts/cm-mandatory-check-coverage.test.mjs +82 -0
  69. package/scripts/cm-node-test-selection.test.mjs +108 -0
  70. package/scripts/cm-notify-read-drift.test.mjs +6 -3
  71. package/scripts/cm-notify.test.mjs +6 -0
  72. package/scripts/cm-prd-completion.test.mjs +12 -0
  73. package/scripts/cm-prd-host.mjs +3 -1
  74. package/scripts/cm-prd-host.test.mjs +18 -1
  75. package/scripts/cm-prd-summary.test.mjs +19 -4
  76. package/scripts/cm-review-inventory.test.mjs +21 -6
  77. package/scripts/cm-run-analysis.mjs +21 -0
  78. package/scripts/cm-run-analysis.test.mjs +120 -0
  79. package/scripts/cm-start-check.mjs +128 -6
  80. package/scripts/cm-start-check.test.mjs +163 -3
  81. package/scripts/cm-usage-report.py +8 -3
  82. package/scripts/cm019-r1-contract.test.mjs +137 -0
  83. package/scripts/cm019-review-gates.test.mjs +97 -0
  84. package/scripts/validate-public-repo.py +3 -0
  85. package/skills/cm-ai/references/N3-execute-task.md +1 -1
  86. package/skills/cm-ai/references/js-host.md +31 -1
  87. package/skills/cm-prd/SKILL.md +3 -2
  88. package/skills/cm-prd/references/change-mode.md +3 -2
  89. package/skills/cm-prd/references/js-change-recovery.md +14 -0
  90. package/skills/cm-prd/references/js-host.md +1 -0
@@ -26,10 +26,73 @@ const documentationMessages={
26
26
  const explain=(summary,nextStep,operation=null,prerequisites=[])=>Object.freeze({
27
27
  summary,nextStep,recoveryOperation:operation,prerequisites:Object.freeze(prerequisites),authorizationGranted:false,
28
28
  });
29
+ const phases={verification_precheck_failed:['verification','验收要求核对'],
30
+ develop_checks_not_passed:['checks','开发检查'],checks_not_passed:['checks','旧完成检查'],
31
+ completion_checks_changed:['completion','完成前复查'],completion_package_changed:['completion','完成前复查'],
32
+ complete_recheck_failed:['completion','完成前复查'],complete_commit_interrupted:['completion','完成写入恢复'],
33
+ spec_drift:['specification','规格绑定核对']};
34
+ const reviewStops=new Set(['review_transport_timeout','review_provider_failed','review_verdict_invalid',
35
+ 'review_abandoned','review_redispatch_limit','review_blocked','review_limit']);
36
+ const safeLine=value=>typeof value==='string'&&!/[\x00-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/.test(value);
37
+ const clipDiagnostic=value=>{
38
+ let text='';for(const char of value){if(Buffer.byteLength(text+char)>1600)break;text+=char;}
39
+ const truncated=text.length!==value.length;
40
+ return {status:'recorded',source:'current_result.reason',text:text+(truncated?'…(完整原因见 result.reason)':''),truncated};
41
+ };
42
+ // Reasons are explanatory evidence, never a recovery permission. Display only
43
+ // host-formatted diagnostics for this code; arbitrary provider reasons stay out
44
+ // of the driver's human channel. Older checkpoints legitimately have no detail.
45
+ function diagnosticFor(result){
46
+ const {reason,code}=result;
47
+ if(safeLine(reason)&&reason.length<=8192){
48
+ if(['verification_precheck_failed','develop_checks_not_passed','checks_not_passed','completion_checks_changed'].includes(code)
49
+ &&reason.startsWith(code+':')&&reason.slice(code.length+1).trim())return clipDiagnostic(reason);
50
+ if(code==='spec_drift'&&/^(规格当前未处于|规格已重新批准,变更文件:|规格已变更:)/.test(reason))
51
+ return clipDiagnostic(reason.split(';')[0]); // Do not copy legacy launch flags into v2/batch guidance.
52
+ }
53
+ return {status:'unknown',source:null,text:'当前结果未记录可展示的具体缺项;请核对原运行证据,不推断其他检查已通过。',truncated:false};
54
+ }
55
+ const identityMatches=(a,b)=>a&&b&&['repositoryId','runId','taskId','attempt'].every(key=>a[key]===b[key]);
56
+ function validEvidenceFor(result){
57
+ const c=result.completion,items=[];
58
+ // A receipt's presence or a successful historical run is insufficient. Only
59
+ // the already validated, current snapshot projection can supply these claims.
60
+ if(/^[a-f0-9]{64}$/.test(c?.snapshotDigest??'')&&c?.binding?.runnerRevision
61
+ &&identityMatches(c.binding.identity,result.identity)&&c.binding.packageDigest===result.packageDigest
62
+ &&c.task?.status==='completed'&&!['spec_drift','correction_review_required'].includes(result.code)){
63
+ if(c.task.review?.status==='passed')for(const reference of c.task.review.evidence??[])
64
+ if(/^receipt:[a-f0-9]{64}$/.test(reference))items.push({kind:'task_review',reference});
65
+ if(c.feature?.status==='passed'&&c.feature.qa?.status==='passed')items.push({kind:'feature_qa',reference:'completion.feature.qa'});
66
+ }
67
+ return {status:items.length?'confirmed':'unknown',items:Object.freeze(items.map(Object.freeze)),
68
+ message:items.length?'仅列当前完成摘要已核对的证据;恢复动作仍须再次核对原条件。'
69
+ :'当前结果不足以确认哪些旧证据仍可复用;保留原记录,不将历史通过当作当前通过。'};
70
+ }
71
+ function blockageFor(result,guidance,{executionActive=false}={}){
72
+ const action=guidance.recoveryOperation;
73
+ const phase=executionActive?['in_flight','原操作执行中']:Object.hasOwn(phases,result.code)?phases[result.code]
74
+ :result.state==='pending_review'||reviewStops.has(result.code)||['abandon_review','reconcile_review'].includes(result.pendingAction)
75
+ ?['review','独立审查']:['unknown','阶段未确认'];
76
+ let checks='unknown',reviewCalls='unknown';
77
+ if(['abandon_effect','abandon_review','develop_redo'].includes(action)){checks='not_dispatched';reviewCalls='not_dispatched';}
78
+ else if(action==='complete'){checks=result.code==='complete_commit_interrupted'?'not_dispatched':'rerun';reviewCalls='not_dispatched';}
79
+ // advance may cross review -> completion/QA, or review -> next development
80
+ // attempt. Describe the whole operation, not only the phase where it starts.
81
+ else if(action==='advance'){checks='may_run';reviewCalls='may_dispatch';}
82
+ const decision=executionActive?'wait':action&&['abandon_effect','abandon_review','develop_redo','bootstrap_review_recover'].includes(action)
83
+ ||result.code==='spec_drift'&&result.pendingAction==='spec_rebind'?'required':action?'existing_conditions'
84
+ :['blocked','unknown'].includes(result.state)?'not_available':'unknown';
85
+ return Object.freeze({version:1,phase:Object.freeze({code:phase[0],label:phase[1]}),
86
+ detail:Object.freeze(diagnosticFor(result)),validEvidence:Object.freeze(validEvidenceFor(result)),
87
+ recovery:Object.freeze({operation:action,decision,checks,reviewCalls,
88
+ budget:'original_limits_apply',authorizationGranted:false}),
89
+ inspection:Object.freeze({readOnly:true,dispatchedCalls:0})});
90
+ }
91
+ const withBlockage=(result,guidance,options={})=>guidance?Object.freeze({...guidance,blockage:blockageFor(result,guidance,options)}):null;
29
92
  // Rendering context is private and ephemeral; it never enters results or journals.
30
93
  const guidanceContext=new WeakMap();
31
94
  export function operatorGuidance(result,options={}){
32
- const guidance=renderOperatorGuidance(result,options);
95
+ const guidance=withBlockage(result,renderOperatorGuidance(result,options),options);
33
96
  if(guidance)guidanceContext.set(guidance,{executionActive:options.executionActive===true,protocol:options.protocol??'legacy'});
34
97
  return guidance;
35
98
  }
@@ -161,14 +224,33 @@ function renderOperatorGuidance(result,{executionActive=false,protocol='legacy',
161
224
  '核对 code、reason 和原运行证据;保留已有文件与历史,不把通用阻塞当作重试许可。');
162
225
  return null;
163
226
  }
164
- // Only bounded static guidance is rendered, never raw provider output.
227
+ // Static instructions plus bounded host-formatted diagnostics; never raw
228
+ // provider output. The structured explanation does not authorize an operation.
165
229
  export function guidanceText(result){
166
230
  if(result?.workflow!=='cm-ai')return null;
167
231
  const guidance=result?.guidance;
168
- const bounded=value=>typeof value==='string'&&Buffer.byteLength(value,'utf8')<=2000&&!/[\r\n\0]/.test(value);
232
+ const bounded=value=>safeLine(value)&&Buffer.byteLength(value,'utf8')<=2000;
169
233
  if(!guidance||guidance.authorizationGranted!==false||!bounded(guidance.summary)||!bounded(guidance.nextStep)
170
234
  ||!Array.isArray(guidance.prerequisites)||guidance.prerequisites.length>8||!guidance.prerequisites.every(bounded))return null;
171
- return `${guidance.summary} ${guidance.nextStep} ${guidance.prerequisites.join(';')}`.trim();
235
+ const text=`${guidance.summary} ${guidance.nextStep} ${guidance.prerequisites.join(';')}`.trim();
236
+ const b=guidance.blockage;
237
+ if(!b||b.version!==1||!bounded(b.phase?.label)||!bounded(b.detail?.text)
238
+ ||!bounded(b.validEvidence?.message)||!Array.isArray(b.validEvidence?.items)||b.validEvidence.items.length>8
239
+ ||!b.validEvidence.items.every(item=>item&&['task_review','feature_qa'].includes(item.kind))
240
+ ||b.recovery?.authorizationGranted!==false)return text;
241
+ const checks={unknown:'检查是否重跑待核对',not_dispatched:'该恢复动作不直接运行检查',rerun:'将重新运行检查',
242
+ may_run:'推进可能跨阶段并运行检查或 QA'};
243
+ const review={unknown:'审查调用待核对',not_dispatched:'该恢复动作不直接派发审查',may_dispatch:'后续可能派发审查,仍受原授权与预算约束'};
244
+ const decisions={wait:'等待原操作,不重复派发',required:'需要用户按原入口确认具体恢复动作',
245
+ existing_conditions:'按原运行已有授权与前置条件核对',not_available:'当前没有已确认可直接发送的恢复操作',
246
+ unknown:'是否需要新决定,须核对上述原入口条件'};
247
+ if(!Object.hasOwn(checks,b.recovery.checks)||!Object.hasOwn(review,b.recovery.reviewCalls)
248
+ ||!Object.hasOwn(decisions,b.recovery.decision))return text;
249
+ const evidence=b.validEvidence.status==='confirmed'
250
+ ?`当前已核对证据:${b.validEvidence.items.map(item=>item.kind==='task_review'?'任务独立审查':item.kind==='feature_qa'?'功能 QA':'未知').join('、')}`
251
+ :'当前可复用证据:UNKNOWN';
252
+ return `${text}\n阶段:${b.phase.label}。门禁记录的缺项/原因:${b.detail.text}\n${evidence}。${b.validEvidence.message}`
253
+ +`\n恢复条件:${decisions[b.recovery.decision]};${checks[b.recovery.checks]};${review[b.recovery.reviewCalls]}。查询本身不派发调用,也不重置原预算。`;
172
254
  }
173
255
 
174
256
  // Q24: in-run recovery operations the batch entry forwards to the stopped member
@@ -182,6 +264,9 @@ const BATCH_RECOVERY={
182
264
  // A member result is not a batch control surface. Keep unsupported single-run
183
265
  // recovery operations out of batch instructions without changing pendingAction.
184
266
  export function batchOperatorGuidance(result,{taskKey=null,protocol='legacy'}={}){
267
+ return withBlockage(result,renderBatchOperatorGuidance(result,{taskKey,protocol}),guidanceContext.get(result?.guidance));
268
+ }
269
+ function renderBatchOperatorGuidance(result,{taskKey=null,protocol='legacy'}={}){
185
270
  const context=guidanceContext.get(result?.guidance);
186
271
  const g=context?operatorGuidance(result,{...context,protocol,surface:'batch'}):result?.guidance;
187
272
  if(!g)return null;
@@ -206,3 +291,24 @@ export function batchOperatorGuidance(result,{taskKey=null,protocol='legacy'}={}
206
291
  '批次入口不支持此成员恢复操作;先核对原成员运行与 reason,不通过 advance 重派或新建运行绕过。');
207
292
  return g;
208
293
  }
294
+
295
+ // Pure formatting shared by all drivers, including partial check-only runtimes.
296
+ export function deliveryLines(value){
297
+ return [['productAcceptance','产品人工验收'],['deployment','发布/部署']].map(([field,label])=>{
298
+ const section=value[field];if(!section?.environments?.length)return `${label}:UNKNOWN`;
299
+ return `${label}:`+section.environments.map(e=>`${e.environment} [${e.artifactSha256.slice(0,12)}] ${e.status==='recorded'?'声明已记录':e.status==='unknown'?'UNKNOWN':'STALE'}(${
300
+ field==='productAcceptance'?e.statement.outcome:`执行 ${e.statement.execution};部署后验证 ${e.statement.verification}`})`).join(';');
301
+ });
302
+ }
303
+
304
+ const label={completed:'已完成',passed:'PASS',failed:'FAIL',blocked:'BLOCKED',unknown:'UNKNOWN',pending:'未完成',
305
+ skipped:'SKIPPED',finalized:'已收尾',ready_to_finalize:'具备收尾条件,尚未收尾'};
306
+ export function completionLines(summary){
307
+ if(!summary||summary.version!==1)return [];
308
+ const feature=summary.feature,project=summary.project;
309
+ const protection={contract_v1:'冻结合同 v1',legacy_unprotected:'旧运行,未受新合同保护',unknown:'验收保护 UNKNOWN'}[summary.task.acceptanceProtection];
310
+ return [`完成范围:task ${summary.binding.identity?.taskId??'未知'} ${label[summary.task.status]??'UNKNOWN'}(独立审查 ${label[summary.task.review?.status]??'UNKNOWN'})${protection?`;${protection}`:''}`,
311
+ `功能 ${summary.binding.feature??'未知'}:任务 ${feature.tasks?`${feature.tasks.completed}/${feature.tasks.total}`:'UNKNOWN'};QA ${label[feature.qa?.status]??'UNKNOWN'};当前资格 ${label[feature.status]??'UNKNOWN'}`,
312
+ `项目批准范围:${project.totalFeatures===undefined?'UNKNOWN':`${project.completedFeatures}/${project.totalFeatures} 个功能通过,${project.pendingTasks} 个待办`};${label[project.status]??'UNKNOWN'}`,
313
+ `本运行收尾:${label[summary.run.status]??'UNKNOWN'};${deliveryLines(summary).join(';')}`];
314
+ }
@@ -27,12 +27,14 @@ export function readRequirementItems(raw,code='verification_precheck_invalid'){
27
27
  need(Array.isArray(raw)&&raw.length>0&&raw.length<=REQUIREMENT_ITEM_LIMIT,code);
28
28
  const items=raw.map(item=>{
29
29
  need(item!==null&&typeof item==='object'&&!Array.isArray(item),code);
30
- try{shape(item,['requirement','satisfied','evidence',...['run','result'].filter(key=>Object.hasOwn(item,key))]);}catch{need(false,code);}
30
+ try{shape(item,['requirement','satisfied','evidence',...['run','result','id','evidenceType','environment'].filter(key=>Object.hasOwn(item,key))]);}catch{need(false,code);}
31
31
  need(typeof item.satisfied==='boolean',code);
32
32
  boundedText(item.requirement,code);boundedText(item.evidence,code);
33
33
  const run=item.run??null,result=item.result??null;
34
34
  need(run===null||RUNS.has(run),code);need(result===null||RESULTS.has(result),code);
35
+ for(const key of ['id','evidenceType','environment'])if(item[key]!==undefined&&item[key]!==null)boundedText(item[key],code);
35
36
  return freeze({requirement:item.requirement,satisfied:item.satisfied,evidence:item.evidence,
37
+ ...Object.fromEntries(['id','evidenceType','environment'].filter(key=>item[key]!=null).map(key=>[key,item[key]])),
36
38
  ...(run===null?{}:{run}),...(result===null||run!=='baseline'?{}:{result})});
37
39
  });
38
40
  need(Buffer.byteLength(JSON.stringify(items),'utf8')<=REQUIREMENT_EVIDENCE_LIMIT,code);
@@ -68,7 +70,7 @@ export function readRequirementEvidence(entry){
68
70
  export function requirementReportProblem(raw){
69
71
  if(!Array.isArray(raw))return 'not a list';
70
72
  if(raw.length>REQUIREMENT_ITEM_LIMIT)return `more than ${REQUIREMENT_ITEM_LIMIT} items`;
71
- const known=['requirement','satisfied','evidence','run','result'];
73
+ const known=['requirement','satisfied','evidence','run','result','id','evidenceType','environment'];
72
74
  for(const [index,item] of raw.entries()){
73
75
  const at=`item ${index+1}`;
74
76
  if(item===null||typeof item!=='object'||Array.isArray(item))return `${at}: not an object`;
@@ -466,7 +466,7 @@ const sealed = (data,key) => {
466
466
  need(Buffer.byteLength(JSON.stringify(result))<=8*1024*1024,'limit_exceeded');
467
467
  return freeze(result);
468
468
  };
469
- export function captureReviewBaseline(options,legacy=false,policyVersion=2,baselinePolicy=null) {
469
+ export function captureReviewBaseline(options,legacy=false,policyVersion=2,baselinePolicy=null,acceptance=true) {
470
470
  const v=plain(options); keys(v,['root','identity','scope','requirements',
471
471
  ...['specsRoot','codeProjectPaths','bootstrapRequirements','specification','version','scopeRevisionPaths'].filter(key=>Object.hasOwn(v,key))]); identityCheck(v.identity);
472
472
  const version=v.version??2;need([1,2].includes(version));
@@ -480,7 +480,7 @@ export function captureReviewBaseline(options,legacy=false,policyVersion=2,basel
480
480
  if(Object.hasOwn(v,'specification')){
481
481
  keys(v.specification,['specsRoot','feature']);
482
482
  need(v.specification.specsRoot===v.specsRoot,'spec_drift');
483
- specification=captureSpecificationMaterial({...v.specification,taskId:v.identity.taskId});
483
+ specification=captureSpecificationMaterial({...v.specification,taskId:v.identity.taskId,acceptance});
484
484
  }
485
485
  const scope=paths(v.scope), requirements=requirementPaths(v.requirements,bootstrap!==null||specification!==null),root=rootPath(v.root);
486
486
  need(![...scope,...requirements].some(p=>inDependencyDirectory(p)||inCocoaPodsTree(root,p)),'excluded_snapshot_path');
@@ -8,6 +8,7 @@ import {taskLines,TASK_GRAMMAR,recordedTaskGrammar} from '../spec-task-line.mjs'
8
8
  import {readReviewSourceFiles,readReviewSourceExcerpt} from './review-package.mjs';
9
9
  import {json,need,shape,hex,id,freeze,digest} from './effect-contract.mjs';
10
10
  import {readExecutionSnapshot} from './execution-snapshot.mjs';
11
+ import {buildAcceptanceContract,readAcceptanceContract} from './acceptance-contract.mjs';
11
12
 
12
13
  const DESIGN_LIMIT=64*1024;
13
14
  const filenames=['requirements.md','design.md','tasks.md','test-cases.json'];
@@ -17,7 +18,10 @@ const featureName=value=>need(typeof value==='string'&&/^\d+\.[^/\\\x00-\x1f]+$/
17
18
  export function readSpecificationMaterial(raw,taskId){
18
19
  const v=json(raw,2*1024*1024);
19
20
  shape(v,['feature','task','acceptanceCriteria','designExcerpt','testCases','sources',
20
- ...['truncated','taskScopeDigest'].filter(key=>Object.hasOwn(v,key))]);
21
+ ...['truncated','taskScopeDigest','acceptanceContract'].filter(key=>Object.hasOwn(v,key))]);
22
+ if(Object.hasOwn(v,'acceptanceContract')){
23
+ readAcceptanceContract(v.acceptanceContract);need(v.acceptanceContract.taskId===taskId);
24
+ }
21
25
  if(Object.hasOwn(v,'taskScopeDigest'))hex(v.taskScopeDigest);
22
26
  featureName(v.feature);
23
27
  shape(v.task,['id','description',...(Object.hasOwn(v.task,'verification')?['verification']:[])]);
@@ -53,14 +57,14 @@ const TASK_ID_TOKEN=/(?<![A-Za-z0-9])T-[A-Za-z0-9][A-Za-z0-9._-]*/g;
53
57
  const indentOf=line=>/^[ \t]*/.exec(line)[0].length;
54
58
  const MENTIONS_TASK=/(?<![A-Za-z0-9])T-[A-Za-z0-9]/;
55
59
  const namesTask=(text,taskId)=>(text.match(TASK_ID_TOKEN)??[]).some(id=>id.replace(/[._-]+$/,'')===taskId);
56
- export function taskScopeText(tasks,taskId,grammar=TASK_GRAMMAR){
60
+ export function taskScopeText(tasks,taskId,grammar=TASK_GRAMMAR,includeHeadings=false){
57
61
  const kept=[];let owner=null,ownerIndent=0;
58
62
  for(const {body,fenced,declaration} of taskLines(tasks,{grammar})){
59
63
  if(!body.trim())continue;
60
64
  if(declaration){owner=declaration.id;ownerIndent=indentOf(body);}
61
65
  // Only lines indented under an item belong to it; a fence or heading at
62
66
  // its level ends it, leaving the rest to the shared/named rules below.
63
- else if(owner!==null&&!(indentOf(body)>ownerIndent&&!/^\s*#/.test(body)))owner=null;
67
+ else if(owner!==null&&!(indentOf(body)>ownerIndent&&(includeHeadings||!/^\s*#/.test(body))))owner=null;
64
68
  const dependency=fenced||declaration?null:body.match(DEPENDENCY);
65
69
  const belongs=declaration?declaration.id:owner??dependency?.[1]??null;
66
70
  if(namesTask(body,taskId)||belongs===taskId||belongs===null&&!MENTIONS_TASK.test(body))kept.push(body);
@@ -90,7 +94,41 @@ function verificationFor(source,taskId){
90
94
  return lines.join('\n');
91
95
  }
92
96
 
93
- export function captureSpecificationMaterial({specsRoot,feature,taskId}){
97
+ // Acceptance selection is narrower than the conservative rebind drift scope.
98
+ // A mention in another task, dependency, heading or version table is not an
99
+ // acceptance declaration for this task; only its own list body and children are.
100
+ export function taskAcceptanceText(tasks,taskId,grammar=TASK_GRAMMAR){
101
+ const kept=[];let owner=null,ownerIndent=0;
102
+ for(const {body,declaration} of taskLines(tasks,{grammar})){
103
+ if(declaration){owner=declaration.id;ownerIndent=indentOf(body);}
104
+ else if(body.trim()&&owner!==null&&indentOf(body)<=ownerIndent)owner=null;
105
+ if(owner===taskId&&body.trim())kept.push(body);
106
+ }
107
+ // The dedicated verification section is an explicit task-keyed declaration,
108
+ // unlike incidental mentions elsewhere in the document.
109
+ let level=null;
110
+ for(const body of tasks.split(/\r?\n/)){
111
+ const heading=/^\s*(#{1,6})\s+(.+)$/.exec(body);
112
+ if(heading){if(level!==null&&heading[1].length<=level)level=null;if(heading[2].includes('验证要求'))level=heading[1].length;continue;}
113
+ const key=/^\s*(?:[-*]\s+)?(T-[A-Za-z0-9][A-Za-z0-9._-]*)(?=[::\s])/.exec(body)?.[1];
114
+ if(level!==null&&key===taskId)kept.push(body);
115
+ }
116
+ return kept.join('\n');
117
+ }
118
+
119
+ // Draft previews and approved captures use exactly the same source selection.
120
+ // This pure projection carries no approval, filesystem access or execution.
121
+ export function buildTaskAcceptanceContract({texts,taskId,grammar=TASK_GRAMMAR}){
122
+ const tasks=normalizeRuntimeMarks(texts['tasks.md'],'tasks.md');
123
+ const requirements=normalizeRuntimeMarks(texts['requirements.md'],'requirements.md');
124
+ const cases=texts['test-cases.json']===undefined?[]:JSON.parse(texts['test-cases.json']).cases;
125
+ need(Array.isArray(cases)&&cases.every(item=>item&&Array.isArray(item.taskIds)),'acceptance_preview_cases_invalid');
126
+ const taskText=taskAcceptanceText(tasks,taskId,grammar);
127
+ return buildAcceptanceContract({taskId,taskText,explicitOnly:true,
128
+ requirementsText:requirements,testCases:cases.filter(item=>item.taskIds.includes(taskId))});
129
+ }
130
+
131
+ export function captureSpecificationMaterial({specsRoot,feature,taskId,acceptance=true}){
94
132
  try{
95
133
  featureName(feature);
96
134
  need(path.isAbsolute(specsRoot)&&fs.realpathSync(specsRoot)===specsRoot);
@@ -129,27 +167,33 @@ export function captureSpecificationMaterial({specsRoot,feature,taskId}){
129
167
  [...declaredAcceptanceIds(line)].map(id=>({id,text:line.trim()})));
130
168
  const cases=texts['test-cases.json']===undefined?[]:JSON.parse(texts['test-cases.json']).cases;
131
169
  need(Array.isArray(cases)&&cases.every(item=>item&&Array.isArray(item.taskIds)));
170
+ const acceptanceContract=acceptance?buildTaskAcceptanceContract({texts,taskId,grammar}):null;
132
171
  return readSpecificationMaterial({feature,task,acceptanceCriteria,designExcerpt:design.excerpt,
133
172
  ...(design.truncated?{truncated:true}:{}),testCases:cases.filter(item=>item.taskIds.includes(taskId)),sources,
134
- taskScopeDigest:taskScopeDigest(texts,taskId,grammar)},taskId);
173
+ taskScopeDigest:taskScopeDigest(texts,taskId,grammar),
174
+ ...(acceptanceContract?{acceptanceContract}:{})},taskId);
135
175
  }catch{throw Object.assign(new Error('spec_drift'),{code:'spec_drift'});}
136
176
  }
137
177
 
138
178
  // Material captured by older versions has no taskScopeDigest; compare a fresh
139
179
  // capture in the bound representation so their runs keep verifying.
140
180
  const asBound=(bound,current)=>{
141
- if(Object.hasOwn(bound,'taskScopeDigest'))return current;
142
- const {taskScopeDigest:unused,...legacy}=current;return legacy;
181
+ const result={...current};
182
+ for(const key of ['taskScopeDigest','acceptanceContract'])if(!Object.hasOwn(bound,key))delete result[key];
183
+ // Stored contracts are data in the original validated baseline, not executable
184
+ // parser rules. The source digests and all other material still compare below.
185
+ if(Object.hasOwn(bound,'acceptanceContract'))result.acceptanceContract=bound.acceptanceContract;
186
+ return result;
143
187
  };
144
188
  // Rebind eligibility, deliberately conservative: requirements.md and design.md
145
189
  // must be unchanged as whole files (acceptance items may span lines, and prose
146
190
  // can state requirements); in tasks.md and test-cases.json only other tasks'
147
191
  // items, dependency lines and cases may differ (taskScopeDigest). A run bound
148
192
  // before taskScopeDigest existed cannot prove that and is never rebindable.
149
- const CONTENT_FIELDS=['feature','task','acceptanceCriteria','designExcerpt','truncated','testCases','taskScopeDigest'];
193
+ const CONTENT_FIELDS=['feature','task','acceptanceCriteria','designExcerpt','truncated','testCases','taskScopeDigest','acceptanceContract'];
150
194
  const FIELD_NAMES={feature:'feature',task:'本任务描述/验证要求',acceptanceCriteria:'验收标准',
151
195
  designExcerpt:'设计摘录',truncated:'设计摘录',testCases:'本任务测试用例',
152
- taskScopeDigest:'tasks.md/test-cases.json 中本任务的条目、续行、依赖、用例或共用说明'};
196
+ taskScopeDigest:'tasks.md/test-cases.json 中本任务的条目、续行、依赖、用例或共用说明',acceptanceContract:'冻结的必验合同'};
153
197
  const WHOLE_FILES={'requirements.md':'requirements.md(整份核对,含验收标准续行与说明)','design.md':'design.md(整份核对)'};
154
198
 
155
199
  // Explicit, journaled rebind (task-runner rebindSpecification). It can only ever
@@ -194,7 +238,7 @@ const accepted=(baseline,captured)=>{
194
238
 
195
239
  export function verifySpecificationMaterial(baseline){
196
240
  const current=captureSpecificationMaterial({specsRoot:baseline.specificationRoot,
197
- feature:baseline.specification.feature,taskId:baseline.identity.taskId});
241
+ feature:baseline.specification.feature,taskId:baseline.identity.taskId,acceptance:false});
198
242
  need(accepted(baseline,current),'spec_drift');
199
243
  return baseline.specification;
200
244
  }
@@ -213,9 +257,10 @@ export function boundSpecificationMaterial(baseline,captured){
213
257
  export function inspectSpecificationDrift(baseline){
214
258
  let current;
215
259
  try{current=captureSpecificationMaterial({specsRoot:baseline.specificationRoot,
216
- feature:baseline.specification.feature,taskId:baseline.identity.taskId});}
260
+ feature:baseline.specification.feature,taskId:baseline.identity.taskId,acceptance:false});}
217
261
  catch{return freeze({approved:false,files:[],fields:[],rebindable:false});}
218
262
  if(accepted(baseline,current))return null;
263
+ current=asBound(baseline.specification,current);
219
264
  const bound=baseline.specification,before=new Map(bound.sources.map(row=>[row.path,row.sha256]));
220
265
  const after=new Map(current.sources.map(row=>[row.path,row.sha256]));
221
266
  const files=[...new Set([...before.keys(),...after.keys()])].filter(file=>before.get(file)!==after.get(file)).sort();
@@ -223,7 +268,7 @@ export function inspectSpecificationDrift(baseline){
223
268
  ...files.map(file=>WHOLE_FILES[file.split('/').at(-1)]).filter(Boolean),
224
269
  ...(before.size!==after.size?['test-cases.json 的有无']:[]),
225
270
  ...(Object.hasOwn(bound,'taskScopeDigest')?[]:['本运行由旧版本创建,未记录本任务段落摘要,无法证明其未变']),
226
- ...CONTENT_FIELDS.filter(field=>Object.hasOwn(bound,'taskScopeDigest')||field!=='taskScopeDigest')
271
+ ...CONTENT_FIELDS.filter(field=>!['taskScopeDigest','acceptanceContract'].includes(field)||Object.hasOwn(bound,field))
227
272
  .filter(field=>digest(current[field]??null)!==digest(bound[field]??null)).map(field=>FIELD_NAMES[field])])];
228
273
  return freeze({approved:true,files,fields,rebindable:fields.length===0,sources:current.sources});
229
274
  }
@@ -7,6 +7,7 @@ import {readExternalModels} from './external-models.mjs';
7
7
  import {beforeFirstQaRound,readQaConfigRevision} from './qa-config-revision.mjs';
8
8
  import {readCloseoutPolicy} from './knowledge-closeout.mjs';
9
9
  import {readQaAttachment} from './qa-attachment.mjs';
10
+ import {acceptanceProblems,encodeAcceptanceEvidence,acceptanceCoverage,describeAcceptanceProblems} from './acceptance-contract.mjs';
10
11
  // Trusted synthetic fixture host; explicit V2 supports isolated task-file writes.
11
12
  import { randomUUID } from 'node:crypto';
12
13
  import { types } from 'node:util';
@@ -17,7 +18,7 @@ import {verifySpecificationMaterial,boundSpecificationMaterial,inspectSpecificat
17
18
  readSpecificationRebind} from './specification-material.mjs';
18
19
  import { captureReviewBaseline, captureScopeRevisionSources, captureReviewInventory, compareReviewBaseline, createReviewPackage, verifyReviewPackage, verifyCompletionReviewPackage, validChecks, readReviewSourceFiles } from './review-package.mjs';
19
20
  import { digest,need,shape,id,text,json,freeze,arrayItems,validIdentity,validTaskLearningInput,validCallTimeout,requestFor,terminalFor,failureCode,
20
- JOURNAL_PAYLOAD_LIMIT,developCheckpointReserve,taskReviewScope,boundedReason } from './effect-contract.mjs';
21
+ JOURNAL_PAYLOAD_LIMIT,JOURNAL_REASON_LIMIT,developCheckpointReserve,taskReviewScope,boundedReason } from './effect-contract.mjs';
21
22
  import { reviewResult,reviewReceipt,boundReviewText,reviewPaths } from './review-runner.mjs';
22
23
  import { checkCompletion } from './gate-bridge.mjs';
23
24
  import { runnerPayload,runnerPayloadV3,readRunnerHistory,attemptBaseline,boundRunnerRecord,
@@ -177,7 +178,7 @@ export function createTaskRunner(options) {
177
178
  // only block: passing it grants nothing and never substitutes for that review.
178
179
  const verificationGate=options.verificationGate??null;
179
180
  // The latest satisfied gate's handoff entry; reset on every gate run.
180
- let requirementEvidence=null,hostReplayEvidence=null;
181
+ let requirementEvidence=null,hostReplayEvidence=null,acceptanceEvidence=null;
181
182
  need(verificationGate===null||typeof verificationGate==='function');
182
183
  if(taskMode)need(Object.hasOwn(options,'persistence'),'runner_completion');
183
184
  const config=json({root:options.root,identity:options.identity,scope:options.scope,requirements:options.requirements,
@@ -294,7 +295,7 @@ export function createTaskRunner(options) {
294
295
  const calls=[],cache=new Map(),session=restored?.session??randomUUID(),registered=new Map(),receipts=[];
295
296
  let state=reviewers.some(r=>r.allowed&&r.available)?'ready':'pending_review',code=null,attempt=1;
296
297
  let busy=false,pending=null,sequence=0,base=original,reviewPackage=null,currentChecks=null,workflowRunning=false;
297
- let reason=null,checkNewPaths=null;
298
+ let reason=null,checkNewPaths=null,verificationReason=null;
298
299
  let receipt=null,priorReview=null,cancelAfterCommit=false,workflowError=null,cancellationRequested=false,reviewInvocation=null;
299
300
  let learningResult=null;
300
301
  // Journaled supersession context: shown, never counted as a review verdict.
@@ -461,7 +462,7 @@ export function createTaskRunner(options) {
461
462
  const baseline=captureReviewBaseline({...configToBaseline(effectiveMetadata()),version:original.version,
462
463
  ...(Object.hasOwn(original,'specification')?{specification:{specsRoot:original.specificationRoot,feature:original.specification.feature}}:{})},
463
464
  !Object.hasOwn(original,'ignorePolicy'),original.ignorePolicy?.version??2,
464
- original.ignorePolicy?.version===2?original.ignorePolicy:null);
465
+ original.ignorePolicy?.version===2?original.ignorePolicy:null,Boolean(original.specification?.acceptanceContract));
465
466
  return splitDocumentationState(baseline.files,paths);
466
467
  }
467
468
  const documentationRefusal=(refusal,detail)=>Object.assign(new Error(refusal),{code:refusal,reason:{
@@ -716,7 +717,7 @@ export function createTaskRunner(options) {
716
717
  compareReviewBaseline(withBoundSpecification(captureReviewBaseline({...configToBaseline(effectiveMetadata()),version:original.version,
717
718
  ...(Object.hasOwn(original,'specification')?{specification:{specsRoot:original.specificationRoot,feature:original.specification.feature}}:{})},
718
719
  !Object.hasOwn(original,'ignorePolicy'),original.ignorePolicy?.version??2,
719
- original.ignorePolicy?.version===2?original.ignorePolicy:null)),original);
720
+ original.ignorePolicy?.version===2?original.ignorePolicy:null,Boolean(original.specification?.acceptanceContract))),original);
720
721
  }
721
722
  const specificationLive=(currentState,currentCode)=>Object.hasOwn(original,'specification')
722
723
  &&['develop','review','complete'].some(kind=>stageAllowed(kind,currentState,currentCode,priorReview?.verdict));
@@ -1167,25 +1168,48 @@ export function createTaskRunner(options) {
1167
1168
  return {files};
1168
1169
  }
1169
1170
  async function verificationSatisfied(checks) {
1170
- requirementEvidence=null;hostReplayEvidence=null;
1171
- if(verificationGate===null)return true;
1171
+ requirementEvidence=null;hostReplayEvidence=null;acceptanceEvidence=null;verificationReason=null;
1172
1172
  // The description carries hard requirements too ("also confirm X/Y/Z do not
1173
1173
  // regress", "do not modify A"), and a gate that reads only the verification
1174
1174
  // section lets exactly those through to the independent review. Both are
1175
1175
  // sent; neither is required to exist.
1176
1176
  const specification=Object.hasOwn(original,'specification')?verifySpecificationMaterial(original):null;
1177
+ const contract=specification?.acceptanceContract??null;
1178
+ if(verificationGate===null){
1179
+ if(contract)verificationReason='verification_precheck_failed: 冻结合同需要验证入口,当前宿主未提供 verificationGate';
1180
+ return contract===null;
1181
+ }
1177
1182
  const verification=specification?.task?.verification??null;
1178
1183
  const description=specification?.task?.description??null;
1179
1184
  const written=value=>typeof value==='string'&&value.trim().length>0;
1180
- if(!written(verification)&&!written(description))return true;
1185
+ if(!contract&&!written(verification)&&!written(description))return true;
1181
1186
  const verdict=json(await bounded(verificationGate,
1182
1187
  json({identity:{...config.identity,attempt},
1183
1188
  ...(written(description)?{description}:{}),
1184
- ...(written(verification)?{verification}:{}),checks,
1189
+ ...(written(verification)?{verification}:{}),...(contract?{acceptanceContract:contract}:{}),checks,
1185
1190
  ...(parsedHistory?.scopeRevisions?{scope:effectiveScope}: {})}),{baselineSnapshot:baselineSnapshot()}));
1186
- shape(verdict,['satisfied',...['items','hostRecord'].filter(key=>Object.hasOwn(verdict,key))]);
1191
+ shape(verdict,['satisfied',...['items','hostRecord','coverage','reason'].filter(key=>Object.hasOwn(verdict,key))]);
1187
1192
  need(typeof verdict.satisfied==='boolean','invalid_result');
1188
1193
  need(verdict.satisfied||!Object.hasOwn(verdict,'items')&&!Object.hasOwn(verdict,'hostRecord'),'invalid_result');
1194
+ if(Object.hasOwn(verdict,'reason')){
1195
+ need(!verdict.satisfied&&typeof verdict.reason==='string'
1196
+ &&verdict.reason.startsWith('verification_precheck_failed: ')
1197
+ &&verdict.reason.length<=JOURNAL_REASON_LIMIT&&!/[\x00-\x1f\x7f]/.test(verdict.reason),'invalid_result');
1198
+ verificationReason=verdict.reason;
1199
+ }
1200
+ if(contract){
1201
+ const coverage=acceptanceCoverage(contract,checks);
1202
+ const problems=verdict.satisfied?acceptanceProblems(contract,verdict.items,verdict.hostRecord??null):[];
1203
+ if(!coverage.satisfied)problems.push('mandatory checks missing or unverifiable: '+JSON.stringify(coverage));
1204
+ if(!verdict.satisfied||problems.length){
1205
+ if(problems.length)verificationReason=boundedReason('verification_precheck_failed: ',
1206
+ [...(verificationReason?[verificationReason.replace(/^verification_precheck_failed:\s*/, '')]:[]),
1207
+ ...describeAcceptanceProblems(contract,problems)]);
1208
+ return false;
1209
+ }
1210
+ acceptanceEvidence=encodeAcceptanceEvidence({contract,identity:{...config.identity,attempt},items:verdict.items,
1211
+ facts:verdict.hostRecord??null,coverage});
1212
+ }
1189
1213
  // The host's own replay record (host-replay.mjs) is a separate handoff entry.
1190
1214
  hostReplayEvidence=Object.hasOwn(verdict,'hostRecord')
1191
1215
  ?encodeHostReplayEvidence({identity:{...config.identity,attempt},facts:verdict.hostRecord}):null;
@@ -1240,7 +1264,7 @@ export function createTaskRunner(options) {
1240
1264
  async function hostDeliveryChecks(){
1241
1265
  currentChecks=await collectChecks();active();
1242
1266
  if(failedChecks(currentChecks).length){halt('blocked','develop_checks_not_passed',checkFailureReason(currentChecks,'develop_checks_not_passed'));return false;}
1243
- if(!await verificationSatisfied(currentChecks)){halt('blocked','verification_precheck_failed');return false;}
1267
+ if(!await verificationSatisfied(currentChecks)){halt('blocked','verification_precheck_failed',verificationReason);return false;}
1244
1268
  active();
1245
1269
  // unchangedSinceRejection builds a package too, so an empty delivery or a
1246
1270
  // deleted in-scope requirement surfaces there first and takes the same
@@ -1251,7 +1275,8 @@ export function createTaskRunner(options) {
1251
1275
  try{createHostHandoff({root:config.root,baseline:base,checks:currentChecks,
1252
1276
  handoffPath:completion.handoffs[attempt-1],evidence:[...journal.filter(row=>row.payload.type==='completion-rework-requested')
1253
1277
  .map(row=>'cm-completion-rework-v1: '+JSON.stringify({identity:{...config.identity,attempt:2},recordDigest:row.digest})),
1254
- ...(requirementEvidence===null?[]:[requirementEvidence]),...(hostReplayEvidence===null?[]:[hostReplayEvidence])]});}
1278
+ ...(requirementEvidence===null?[]:[requirementEvidence]),...(hostReplayEvidence===null?[]:[hostReplayEvidence]),
1279
+ ...(acceptanceEvidence===null?[]:[acceptanceEvidence])]});}
1255
1280
  catch(error){emptyDelivery(error);return false;}
1256
1281
  return true;
1257
1282
  }
@@ -1383,7 +1408,7 @@ export function createTaskRunner(options) {
1383
1408
  if(taskLearning?.hostHandoff!==true){
1384
1409
  currentChecks=await collectChecks();active();
1385
1410
  if(failedChecks(currentChecks).length){halt('blocked','develop_checks_not_passed',checkFailureReason(currentChecks,'develop_checks_not_passed'));return;}
1386
- if(!await verificationSatisfied(currentChecks)){halt('blocked','verification_precheck_failed');return;}
1411
+ if(!await verificationSatisfied(currentChecks)){halt('blocked','verification_precheck_failed',verificationReason);return;}
1387
1412
  active();
1388
1413
  let unchanged;
1389
1414
  try{unchanged=unchangedSinceRejection();}catch(error){emptyDelivery(error);return;}
@@ -8,18 +8,20 @@
8
8
  // run "red" needs the test-files-only run to have run and failed; run "baseline"
9
9
  // needs the baseline to have run (a run that could not start proves nothing) and,
10
10
  // with a result, to have that result. An untagged item is not a run claim here.
11
- // The same limit as the session-answered gate: coverage of every written
12
- // requirement, and the tagging of every run claim, are not proven.
11
+ // Legacy material has no expected set. New material supplies a frozen contract:
12
+ // coverage and run tags are checked against it before accepting any report.
13
+ // Neither mode proves arbitrary prose/physical evidence true; independent review remains.
14
+ import {acceptanceProblems} from './acceptance-contract.mjs';
13
15
  const ran=run=>run&&['passed','failed'].includes(run.outcome);
14
16
  const redFact=facts=>facts.status!=='replayed'?`未实跑(${facts.reason})`
15
17
  :facts.red.skipped?'tasks.md 未写测试文件,没有只放入测试文件的实跑'
16
18
  :`只放入测试文件时检查 ${facts.red.outcome}`;
17
19
 
18
20
  // report: the developer's items, null (absent) or 'invalid'. facts: replayDelivery's result.
19
- export function autoVerificationVerdict({report,facts}){
21
+ export function autoVerificationVerdict({report,facts,contract=null}){
20
22
  if(report===null)return {satisfied:false,unsatisfied:['开发结果没有逐条要求与证据(requirements)']};
21
23
  if(report==='invalid')return {satisfied:false,unsatisfied:['开发结果的逐条要求与证据(requirements)格式不合法']};
22
- const unsatisfied=[],replayed=facts.status==='replayed';
24
+ const unsatisfied=contract?acceptanceProblems(contract,report,facts):[],replayed=facts.status==='replayed';
23
25
  for(const item of report){
24
26
  if(item.satisfied!==true){unsatisfied.push(item.requirement);continue;}
25
27
  if(item.run==='red'&&!(replayed&&!facts.red.skipped&&facts.red.outcome==='failed'))