@aibyzero/cm-workflow 0.21.7 → 0.25.1
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 +64 -0
- package/README.md +15 -1
- package/VERSION +1 -1
- package/docs/architecture.md +9 -0
- package/docs/cm-acceptance-completion.md +3 -1
- package/docs/cm-control-policy-v2.md +35 -3
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +1 -0
- package/docs/human-correction.md +1 -1
- package/docs/installation.md +63 -19
- package/docs/js-workflow-control.md +67 -31
- package/docs/next-steps.md +10 -0
- package/docs/runtime-failover.md +2 -2
- package/docs/user-guide.md +1 -1
- package/package.json +1 -1
- package/runtime/js/cm-ai/batch-location.mjs +14 -0
- package/runtime/js/cm-ai/batch-plan.mjs +6 -2
- package/runtime/js/cm-ai/claude-probe-diagnosis.mjs +21 -0
- package/runtime/js/cm-ai/claude-review-stream.mjs +20 -7
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -2
- package/runtime/js/cm-ai/cm-ai-admission.mjs +9 -3
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +51 -8
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +30 -4
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -4
- package/runtime/js/cm-ai/delivery-evidence.mjs +3 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +15 -1
- package/runtime/js/cm-ai/drive-core.mjs +50 -6
- package/runtime/js/cm-ai/drive-next-step.mjs +61 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +85 -23
- package/runtime/js/cm-ai/execution-snapshot.mjs +5 -2
- package/runtime/js/cm-ai/execution-store.mjs +21 -3
- package/runtime/js/cm-ai/external-run-guard.mjs +9 -1
- package/runtime/js/cm-ai/host-check.mjs +4 -2
- package/runtime/js/cm-ai/host-conversation-execution.mjs +29 -2
- package/runtime/js/cm-ai/host-handoff.mjs +7 -0
- package/runtime/js/cm-ai/host-progress.mjs +18 -0
- package/runtime/js/cm-ai/host-qa-executor.mjs +47 -15
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +24 -14
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +1 -1
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/operator-guidance.mjs +126 -2
- package/runtime/js/cm-ai/project-qa-gate.mjs +13 -2
- package/runtime/js/cm-ai/provider-review-observation.mjs +7 -3
- package/runtime/js/cm-ai/qa-plan-notes.mjs +106 -0
- package/runtime/js/cm-ai/review-continuation.mjs +102 -0
- package/runtime/js/cm-ai/review-evidence-file.mjs +11 -0
- package/runtime/js/cm-ai/review-package.mjs +25 -4
- package/runtime/js/cm-ai/review-presentation.mjs +31 -14
- package/runtime/js/cm-ai/review-runner.mjs +5 -4
- package/runtime/js/cm-ai/review-verdict-rules.mjs +7 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +30 -1
- package/runtime/js/cm-ai/task-commit-codec.mjs +11 -1
- package/runtime/js/cm-ai/task-commit.mjs +7 -4
- package/runtime/js/cm-ai/task-owner.mjs +5 -2
- package/runtime/js/cm-ai/task-runner.mjs +343 -52
- package/runtime/js/cm-ai/worker-claude-developer.mjs +3 -1
- package/runtime/js/cm-ai/worker-claude.mjs +5 -1
- package/runtime/js/cm-check/host.mjs +13 -3
- package/runtime/js/cm-fix/diagnosis.mjs +16 -3
- package/runtime/js/cm-fix/execution.mjs +47 -9
- package/runtime/js/cm-fix/finish.mjs +9 -1
- package/runtime/js/cm-fix/step-timing.mjs +222 -0
- package/runtime/js/cm-idea/session.mjs +22 -3
- package/runtime/js/cm-init/review-evidence.mjs +20 -7
- package/runtime/js/cm-prd/ai-draft.mjs +260 -0
- package/runtime/js/cm-prd/analysis.mjs +27 -9
- package/runtime/js/cm-prd/change.mjs +29 -8
- package/runtime/js/cm-prd/failed-correction.mjs +24 -4
- package/runtime/js/cm-prd/narrow-review.mjs +63 -3
- package/runtime/js/cm-prd/review-channels.mjs +5 -0
- package/runtime/js/cm-prd/review-correction.mjs +65 -5
- package/runtime/js/cm-prd/review-disposition.mjs +10 -1
- package/runtime/js/cm-prd/review-publication.mjs +2 -1
- package/runtime/js/cm-prd/self-check.mjs +121 -9
- package/runtime/js/cm-prd/session.mjs +55 -13
- package/runtime/js/cm-prd/summary.mjs +34 -6
- package/runtime/js/cm-prd/task-scope-record.mjs +40 -15
- package/runtime/js/cm-refactor/records.mjs +82 -11
- package/runtime/js/cm-refactor/workflow.mjs +3 -1
- package/runtime/js/executor-version.mjs +81 -0
- package/runtime/js/python-log-writer.mjs +15 -0
- package/runtime/js/run-analysis.mjs +136 -11
- package/runtime/logging.md +6 -0
- package/runtime/review.md +2 -1
- package/scripts/ci-test-weights.json +1 -0
- package/scripts/cm-ai-admission.mjs +27 -1
- package/scripts/cm-ai-admission.test.mjs +34 -2
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +3 -2
- package/scripts/cm-ai-batch-drive.mjs +54 -17
- package/scripts/cm-ai-batch-drive.test.mjs +123 -6
- package/scripts/cm-ai-batch-host.mjs +64 -11
- package/scripts/cm-ai-batch-host.test.mjs +23 -3
- package/scripts/cm-ai-batch-location.test.mjs +22 -1
- package/scripts/cm-ai-batch-merge.mjs +102 -0
- package/scripts/cm-ai-batch-plan.mjs +55 -2
- package/scripts/cm-ai-batch-plan.test.mjs +228 -6
- package/scripts/cm-ai-batch-run-fixture.mjs +239 -15
- package/scripts/cm-ai-batch-run-parallel.test.mjs +23 -1
- package/scripts/cm-ai-batch-run.mjs +437 -34
- package/scripts/cm-ai-batch-session-member.test.mjs +85 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +23 -2
- package/scripts/cm-ai-completion-summary.test.mjs +2 -1
- package/scripts/cm-ai-control-v2-drive.test.mjs +39 -9
- package/scripts/cm-ai-direct-review.test.mjs +1 -1
- package/scripts/cm-ai-disk-edits.test.mjs +229 -0
- package/scripts/cm-ai-drive-next-step.test.mjs +191 -0
- package/scripts/cm-ai-drive.mjs +66 -14
- package/scripts/cm-ai-drive.test.mjs +13 -3
- package/scripts/cm-ai-host-cli-workflow.test.mjs +4 -2
- package/scripts/cm-ai-host.mjs +20 -9
- package/scripts/cm-ai-host.test.mjs +12 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +132 -1
- package/scripts/cm-ai-project-qa-gate.test.mjs +26 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -0
- package/scripts/cm-ai-review-continuation.test.mjs +335 -0
- package/scripts/cm-ai-review-failure.test.mjs +13 -10
- package/scripts/cm-ai-review-timeout.test.mjs +1 -1
- package/scripts/cm-ai-run.mjs +42 -11
- package/scripts/cm-ai-run.test.mjs +26 -0
- package/scripts/cm-ai-supersede.test.mjs +10 -2
- package/scripts/cm-capability-gate.test.mjs +1 -1
- package/scripts/cm-check-host.test.mjs +54 -0
- package/scripts/cm-check-runtime.sh +27 -15
- package/scripts/cm-check-update.mjs +83 -8
- package/scripts/cm-check-update.test.mjs +114 -1
- package/scripts/cm-claude-developer-worker.test.mjs +29 -1
- package/scripts/cm-claude-managed-preflight.test.mjs +126 -0
- package/scripts/cm-claude-probe.test.mjs +5 -0
- package/scripts/cm-claude-review-stream.test.mjs +4 -1
- package/scripts/cm-claude-worker.test.mjs +29 -0
- package/scripts/cm-codex-prompt-input.test.mjs +2 -1
- package/scripts/cm-developer-self-review.test.mjs +27 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +4 -3
- package/scripts/cm-efficiency-response.test.mjs +2 -1
- package/scripts/cm-executor-version-draft.test.mjs +251 -0
- package/scripts/cm-executor-version-entries.test.mjs +93 -0
- package/scripts/cm-executor-version-prd.test.mjs +154 -0
- package/scripts/cm-executor-version-records.test.mjs +256 -0
- package/scripts/cm-executor-version.test.mjs +250 -0
- package/scripts/cm-external-model-host.test.mjs +6 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +1 -1
- package/scripts/cm-fix-closeout-preflight.test.mjs +123 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +5 -1
- package/scripts/cm-fix-drive.mjs +7 -2
- package/scripts/cm-fix-drive.test.mjs +45 -0
- package/scripts/cm-fix-entry.mjs +5 -2
- package/scripts/cm-fix-frozen-baseline.test.mjs +50 -0
- package/scripts/cm-fix-host.mjs +9 -2
- package/scripts/cm-fix-review-preflight.mjs +2 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +19 -0
- package/scripts/cm-fix-test-extension.test.mjs +30 -2
- package/scripts/cm-host-check.test.mjs +12 -0
- package/scripts/cm-host-qa-executor.test.mjs +172 -1
- package/scripts/cm-host-qa-policy.test.mjs +55 -1
- package/scripts/cm-idea-drive.mjs +5 -2
- package/scripts/cm-idea-entry.mjs +5 -2
- package/scripts/cm-idea-host.mjs +3 -1
- package/scripts/cm-init-drive.mjs +8 -5
- package/scripts/cm-init-entry.mjs +5 -2
- package/scripts/cm-init-host.mjs +6 -2
- package/scripts/cm-log-event.mjs +10 -2
- package/scripts/cm-log-event.test.mjs +29 -0
- package/scripts/cm-prd-ai-draft-fixture.mjs +18 -0
- package/scripts/cm-prd-ai-draft.test.mjs +505 -0
- package/scripts/cm-prd-answer-gaps.test.mjs +110 -5
- package/scripts/cm-prd-completion.test.mjs +67 -4
- package/scripts/cm-prd-design-phase.test.mjs +48 -13
- package/scripts/cm-prd-drive.mjs +91 -21
- package/scripts/cm-prd-drive.test.mjs +126 -4
- package/scripts/cm-prd-entry.mjs +5 -2
- package/scripts/cm-prd-host.mjs +89 -20
- package/scripts/cm-prd-host.test.mjs +17 -8
- package/scripts/cm-prd-narrow-review.test.mjs +49 -1
- package/scripts/cm-prd-review-disposition.test.mjs +94 -1
- package/scripts/cm-prd-review-gate.mjs +13 -5
- package/scripts/cm-prd-review-publication.test.mjs +34 -0
- package/scripts/cm-prd-self-check-rules.test.mjs +175 -10
- package/scripts/cm-prd-self-check.test.mjs +1 -1
- package/scripts/cm-refactor-drive.mjs +10 -4
- package/scripts/cm-refactor-entry.mjs +5 -2
- package/scripts/cm-refactor-host.mjs +3 -1
- package/scripts/cm-release-smoke.sh +3 -2
- package/scripts/cm-run-analysis.test.mjs +373 -1
- package/scripts/cm-skill-hints-autowire.test.mjs +1 -1
- package/scripts/cm-skill-hints-exam.mjs +3 -1
- package/scripts/cm-skill-hints-install.test.mjs +1 -1
- package/scripts/cm-skill-hints.mjs +106 -10
- package/scripts/cm-skill-hints.test.mjs +162 -6
- package/scripts/cm-skill-judge.mjs +2 -1
- package/scripts/cm-task-gate.mjs +88 -18
- package/scripts/cm-task-scope.test.mjs +1 -1
- package/scripts/cm-test-drive.mjs +13 -8
- package/scripts/cm-test-entry.mjs +5 -2
- package/scripts/cm-test-host.mjs +3 -1
- package/scripts/cm-upgrade-compat-batch.test.mjs +62 -9
- package/scripts/cm-workflow-config.test.mjs +8 -3
- package/scripts/fixtures/fresh-completion-checks.mjs +8 -0
- package/scripts/fixtures/prd-review-gate-python-oracle.py +10 -1
- package/scripts/policy-binding-compat.test.mjs +3 -2
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/shell-pipe-early-exit.test.mjs +96 -0
- package/scripts/test-cm-prd-review-gate.py +55 -0
- package/scripts/test-shell-compat.sh +7 -5
- package/skills/cm-ai/SKILL.md +1 -1
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N4-review.md +2 -2
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/js-host-recovery.md +5 -1
- package/skills/cm-ai/references/js-host.md +17 -8
- package/skills/cm-check/SKILL.md +3 -0
- package/skills/cm-fix/references/isolated-review.md +1 -1
- package/skills/cm-fix/references/js-host.md +20 -0
- package/skills/cm-fix/references/test-extension.md +1 -1
- package/skills/cm-prd/SKILL.md +8 -6
- package/skills/cm-prd/references/ai-draft.md +81 -0
- package/skills/cm-prd/references/change-mode.md +2 -0
- package/skills/cm-prd/references/greenfield.md +2 -0
- package/skills/cm-prd/references/js-change-recovery.md +2 -2
- package/skills/cm-prd/references/js-host.md +9 -6
- package/skills/cm-prd/references/light-mode.md +19 -0
- package/skills/cm-prd/references/requirement-grilling.md +2 -0
- package/skills/cm-prd/references/spec-self-check.md +1 -0
- package/skills/cm-prd/references/summary-card.md +1 -0
- package/templates/auto-update/cm-update.sh +2 -2
|
@@ -13,7 +13,7 @@ import {readCmInitSource} from '../cm-init/draft-inspection.mjs';
|
|
|
13
13
|
import {writeReviewEvidence} from '../cm-ai/review-evidence-file.mjs';
|
|
14
14
|
import {need,json,shape,digest} from '../cm-ai/effect-contract.mjs';
|
|
15
15
|
import {inspectPrdNarrowState,narrowPublicState,narrowNames,narrowCorrectionBytes,recordPrdNarrowReview,
|
|
16
|
-
PRD_NARROW_MAX_ROUNDS} from './narrow-review.mjs';
|
|
16
|
+
recordPrdNarrowUserDecision,narrowAcceptedRisks,PRD_NARROW_MAX_ROUNDS} from './narrow-review.mjs';
|
|
17
17
|
const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
18
18
|
const archiveBytes=value=>Buffer.from('# Original review correction proposal\n\nNot review approval or completion. Private host-attested material.\n```json\n'
|
|
19
19
|
+JSON.stringify(value)+'\n```\n');
|
|
@@ -38,10 +38,43 @@ function inspectProposal(specs,review,proposal){
|
|
|
38
38
|
}else{
|
|
39
39
|
const mechanics=checkPrdDraftMechanics({draftDigest:digest(after),features:[{directory:feature,name,documents}]},
|
|
40
40
|
prdTaskScopeOptions(specs,feature));
|
|
41
|
-
need(mechanics.status==='mechanical_subset_passed','prd_correction_mechanics_failed');
|
|
41
|
+
try{need(mechanics.status==='mechanical_subset_passed','prd_correction_mechanics_failed');}
|
|
42
|
+
catch(error){
|
|
43
|
+
// Rule code, feature and file only: never the proposed content (dogfood 2026-12-01 问题 7).
|
|
44
|
+
error.failedChecks=mechanics.findings.map(item=>({feature:item.feature,code:item.code,
|
|
45
|
+
...(typeof item.reason?.field==='string'?{field:item.reason.field}:{})}));
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
42
48
|
}
|
|
43
49
|
return {after,plan};
|
|
44
50
|
}
|
|
51
|
+
const originalArchive=(stage,feature)=>`.reviews/prd-${feature.replace(/^\d+\./,'')}-${stage}-correction.md`;
|
|
52
|
+
// Read-only pre-check for drivers: the same proposal inspection prd_correct runs before any write
|
|
53
|
+
// (same review, prdTaskScopeOptions and mechanics). Reports refusal codes and file names, never content.
|
|
54
|
+
export function previewPrdCorrectionProposal({specs,stage,feature,proposal}){
|
|
55
|
+
const review=narrowCorrectionReview({specs,stage,feature})??inspectPrdFindings({specs,stage,feature});
|
|
56
|
+
try{inspectProposal(specs,review,proposal);}
|
|
57
|
+
catch(error){
|
|
58
|
+
if(typeof error?.code!=='string')throw error;
|
|
59
|
+
return json({status:'refused',reason:error.code,...(error.failedChecks?{failedChecks:error.failedChecks}:{})});
|
|
60
|
+
}
|
|
61
|
+
return json({status:'passed'});
|
|
62
|
+
}
|
|
63
|
+
// A recorded original prd_correct answer the host refused may be discarded and asked again only while
|
|
64
|
+
// no correction archive exists (it is written before any spec write, so nothing on disk changed) and
|
|
65
|
+
// the recorded answer still fails the same inspection. A passing answer is replayed, never re-asked.
|
|
66
|
+
export function assertPrdCorrectionRefused({specs,stage,feature,proposal}){
|
|
67
|
+
need(readCmInitSource(specs,originalArchive(stage,feature))===null,'prd_correction_recovery_required');
|
|
68
|
+
const review=inspectPrdFindings({specs,stage,feature});
|
|
69
|
+
need(review.gate.outcome==='resume_disposition'&&review.verdict!=='blocked','prd_correction_recovery_required');
|
|
70
|
+
// Only the mechanics' own verdict on the proposal (failedChecks is attached there and nowhere else);
|
|
71
|
+
// a check that could not run or another refusal path never qualifies (review r1 A2).
|
|
72
|
+
let refused=false;
|
|
73
|
+
try{inspectProposal(specs,review,json(proposal,256*1024));}
|
|
74
|
+
catch(error){refused=error?.code==='prd_correction_mechanics_failed'&&Array.isArray(error.failedChecks)&&error.failedChecks.length>0;}
|
|
75
|
+
need(refused,'prd_correction_recovery_required');
|
|
76
|
+
return 'prd_correction_mechanics_failed';
|
|
77
|
+
}
|
|
45
78
|
|
|
46
79
|
export function createPrdCorrectionOwner({correct}){
|
|
47
80
|
need(typeof correct==='function','prd_correction_host_required');const attempts=new Set();
|
|
@@ -233,8 +266,32 @@ export function assertPrdNarrowDispositionReady({specs,feature,pendingSplit=null
|
|
|
233
266
|
const found=narrowFound({specs,feature,pendingSplit,designSha256});need(found,'prd_narrow_requires_original_correction');
|
|
234
267
|
const status=found.state.phase.status;
|
|
235
268
|
need(status!=='awaiting_user_decision','prd_narrow_awaiting_user_decision');
|
|
236
|
-
|
|
237
|
-
|
|
269
|
+
// The user's recorded accept-risks decision releases like an approval; its blockers go to the summary.
|
|
270
|
+
need(status==='approved'||status==='user_accepted','prd_narrow_review_pending');
|
|
271
|
+
const acceptedRisks=narrowAcceptedRisks(found.state);
|
|
272
|
+
return {used:true,designPath:designPath(feature),originalDecisions:found.value.plan.decisions,acceptedRisks,
|
|
273
|
+
...(acceptedRisks?{decisionSha256:found.state.userDecisionSha256}:{})};
|
|
274
|
+
}
|
|
275
|
+
export function recordPrdNarrowUserDecisionHost({specs,feature,packageDigest,input,authorContextId,writeEnabled}){
|
|
276
|
+
assertPrdBatchActive(specs,[feature]);
|
|
277
|
+
const found=narrowFound({specs,feature});need(found,'prd_narrow_requires_original_correction');
|
|
278
|
+
need(found.value.review.gate.outcome==='resume_disposition','prd_narrow_closed');
|
|
279
|
+
need(packageDigest===found.value.review.packageDigest,'prd_narrow_package_changed');
|
|
280
|
+
recordPrdNarrowUserDecision({specs,feature,packageDigest,state:found.state,input,authorContextId,writeEnabled});
|
|
281
|
+
const after=narrowFound({specs,feature});
|
|
282
|
+
return json({...narrowPublicState(after.state),status:'narrow_user_decision_recorded',acceptedRisks:narrowAcceptedRisks(after.state)});
|
|
283
|
+
}
|
|
284
|
+
// Summary input: the accepted narrow risks of a design feature plus the decision file that binds them, or null.
|
|
285
|
+
export function prdNarrowUserDecisionEvidence({specs,feature}){
|
|
286
|
+
const name=narrowNames(feature).decision;
|
|
287
|
+
const bytes=readCmInitSource(specs,`.reviews/${name}`);if(bytes===null)return null;
|
|
288
|
+
let designSha256;try{designSha256=JSON.parse(bytes.toString('utf8')).designSha256;}catch{need(false,'prd_narrow_record_invalid');}
|
|
289
|
+
// After the design receipt a saved split correction may change design.md; the chain is checked at the decided bytes.
|
|
290
|
+
const found=narrowFound({specs,feature,designSha256});need(found,'prd_narrow_requires_original_correction');
|
|
291
|
+
const risks=narrowAcceptedRisks(found.state);need(risks,'prd_narrow_record_invalid');
|
|
292
|
+
// Bind the validated record; bytes that changed between the two reads are refused, not shown.
|
|
293
|
+
need(found.state.userDecisionSha256===sha(bytes),'prd_narrow_record_invalid');
|
|
294
|
+
return {path:`.reviews/${name}`,sha256:found.state.userDecisionSha256,risks};
|
|
238
295
|
}
|
|
239
296
|
|
|
240
297
|
async function narrowCorrection({specs,feature,correct,attempts,signal}){
|
|
@@ -245,6 +302,7 @@ async function narrowCorrection({specs,feature,correct,attempts,signal}){
|
|
|
245
302
|
need(phase.status!=='awaiting_review'||resumed,'prd_narrow_review_required');
|
|
246
303
|
need(phase.status!=='approved','prd_narrow_already_approved');
|
|
247
304
|
need(phase.status!=='awaiting_user_decision','prd_narrow_awaiting_user_decision');
|
|
305
|
+
need(phase.status!=='user_accepted','prd_narrow_user_decided');
|
|
248
306
|
const round=resumed?lastRow.round:phase.round,archive=`.reviews/${names.correction(round)}`;
|
|
249
307
|
const designRelative=designPath(feature),packageDigest=value.review.packageDigest;
|
|
250
308
|
const current=()=>{
|
|
@@ -314,9 +372,11 @@ export function assertNarrowReceiptAllowed({specs,slug,findingCount,unresolvedCo
|
|
|
314
372
|
const dirs=fs.readdirSync(specs).filter(name=>new RegExp(`^[1-9]\\d*\\.${slug}$`).test(name));
|
|
315
373
|
need(dirs.length===1,'prd_narrow_record_invalid');
|
|
316
374
|
const found=narrowFound({specs,feature:dirs[0]});need(found,'prd_narrow_requires_original_correction');
|
|
317
|
-
need(found.state.phase.status
|
|
375
|
+
need(['approved','user_accepted'].includes(found.state.phase.status),'prd_narrow_review_pending');
|
|
318
376
|
const decisions=found.value.plan.decisions;
|
|
319
377
|
need(findingCount===decisions.length&&unresolvedCount===decisions.filter(item=>item.status==='escalated').length,
|
|
320
378
|
'prd_narrow_disposition_decisions_changed');
|
|
379
|
+
// Every receipt writer binds the user's accept-risks decision it released on (review r2: the record CLI omitted it).
|
|
380
|
+
return found.state.phase.status==='user_accepted'?found.state.userDecisionSha256:null;
|
|
321
381
|
}catch(error){throw typeof error?.code==='string'&&error.code.startsWith('prd_narrow_')?error:invalid();}
|
|
322
382
|
}
|
|
@@ -61,7 +61,7 @@ function disposition({specs,stage,feature,packageDigest,decisions,artifacts,writ
|
|
|
61
61
|
if(validateOnly)return {status:'disposition_prepared',requiresSelfCheck:stage==='split'&&changed.size>0};
|
|
62
62
|
need(stage!=='split'||changed.size===0||checked||failedCheck,'prd_disposition_split_self_check_required');
|
|
63
63
|
const recorded=recordPrdReview({...args,disposition,finding_count:decisions.length,unresolved_count:unresolvedCount,
|
|
64
|
-
...(failedCheck?{correction_check:failedCheck}:{}),artifact:selected.map(item=>path.join(specs,item.path))});
|
|
64
|
+
...(failedCheck?{correction_check:failedCheck}:{}),...(narrow.decisionSha256?{narrow_user_decision_sha256:narrow.decisionSha256}:{}),artifact:selected.map(item=>path.join(specs,item.path))});
|
|
65
65
|
const gate=inspectPrdReview(args);
|
|
66
66
|
need(gate.outcome==='completed'&&gate.disposition===disposition&&gate.package_sha256===packageDigest,
|
|
67
67
|
'prd_disposition_write_unknown');
|
|
@@ -94,6 +94,15 @@ export function createPrdDispositionOwner({checkContext,canRecoverRecorded=()=>f
|
|
|
94
94
|
const scopeOptions=prdTaskScopeOptions(input.specs,input.feature);
|
|
95
95
|
if(scopeOptions.scopes)draft.taskScopes=scopeOptions.scopes;
|
|
96
96
|
if(scopeOptions.sessionTasks)draft.sessionTasks=scopeOptions.sessionTasks;
|
|
97
|
+
// A rule-8 save binds its remaining re-check options too (exemption, evidence check), so the
|
|
98
|
+
// failed receipt re-verifies under exactly these options (review r1 B1). Rules 1-7 keep the
|
|
99
|
+
// input byte-for-byte as before, so a check an older version recorded still resumes (review
|
|
100
|
+
// r2 blocker 1); their receipts re-verify against the record (failed-correction.mjs).
|
|
101
|
+
if(scopeOptions.sessionEvidence){
|
|
102
|
+
if(scopeOptions.inapplicableAcceptance)draft.inapplicableAcceptance=scopeOptions.inapplicableAcceptance;
|
|
103
|
+
draft.sessionEvidence=scopeOptions.sessionEvidence;
|
|
104
|
+
if(scopeOptions.sessionEvidenceExempt)draft.sessionEvidenceExempt=scopeOptions.sessionEvidenceExempt;
|
|
105
|
+
}
|
|
97
106
|
draft.mechanicalSelfCheck=checkPrdDraftMechanics(draft,scopeOptions);
|
|
98
107
|
draft=json(draft,256*1024);
|
|
99
108
|
const review=inspectPrdFindings({specs:input.specs,stage:input.stage,feature:input.feature});
|
|
@@ -7,6 +7,7 @@ import {writeReviewEvidence} from '../cm-ai/review-evidence-file.mjs';
|
|
|
7
7
|
import {reviewResultForPaths} from '../cm-ai/review-runner.mjs';
|
|
8
8
|
import {need,shape,json,digest,id} from '../cm-ai/effect-contract.mjs';
|
|
9
9
|
import {needPrd} from './validation-reason.mjs';
|
|
10
|
+
import {PRD_INDEPENDENT_REVIEWERS} from './review-channels.mjs';
|
|
10
11
|
|
|
11
12
|
export function inspectPrdReviewResponse({reviewPackage,packageDigest,authorContextId,response}){
|
|
12
13
|
reviewPackage=json(reviewPackage,256*1024);response=json(response,64*1024);id(authorContextId);
|
|
@@ -25,7 +26,7 @@ export function inspectPrdReviewResponse({reviewPackage,packageDigest,authorCont
|
|
|
25
26
|
need(degraded?response.independent===false&&response.contextId===authorContextId
|
|
26
27
|
&&typeof response.degradedReason==='string'&&response.degradedReason.trim().length>0
|
|
27
28
|
&&!/[\r\n\v\f\x1c-\x1e\x85\u2028\u2029\0]/.test(response.degradedReason):
|
|
28
|
-
|
|
29
|
+
PRD_INDEPENDENT_REVIEWERS.includes(response.reviewer)&&response.independent===true&&response.contextId!==authorContextId,
|
|
29
30
|
'prd_review_independence_invalid');
|
|
30
31
|
needPrd(typeof response.at==='string'&&Number.isFinite(Date.parse(response.at))
|
|
31
32
|
&&new Date(response.at).toISOString()===response.at,'prd_review_timestamp_invalid',
|
|
@@ -3,6 +3,8 @@ import {parseFeatureTaskText,validDependencies,declaredAcceptanceIds,acceptanceD
|
|
|
3
3
|
import {specLines,taskLines,TASK_GRAMMAR} from '../spec-task-line.mjs';
|
|
4
4
|
import {parseTaskScopes,BOOTSTRAP_FEATURE,sessionTaskProblem,sessionTaskReason} from '../task-scope.mjs';
|
|
5
5
|
import {validateTestCases} from '../../../scripts/validate-test-cases.mjs';
|
|
6
|
+
import {buildAcceptanceContract} from '../cm-ai/acceptance-contract.mjs';
|
|
7
|
+
import {taskAcceptanceText,buildTaskAcceptanceContract} from '../cm-ai/specification-material.mjs';
|
|
6
8
|
import {json,shape,need,digest} from '../cm-ai/effect-contract.mjs';
|
|
7
9
|
|
|
8
10
|
export function inspectPrdContextCheck(raw,draft){
|
|
@@ -72,15 +74,24 @@ function inapplicableAcceptanceIds(source){
|
|
|
72
74
|
// Rule 5 = rule 4 plus the NOT_APPLICABLE coverage exemption (inapplicableAcceptanceIds below).
|
|
73
75
|
// Rule 6 = rule 3 plus that exemption, for sessions on specs still published under task grammar 2:
|
|
74
76
|
// they cannot take rule 4's grammar-3 reading, yet need the exemption too (Wue specs8, 2026-11-14).
|
|
77
|
+
// Rule 7 = rule 5 plus the first, unreleased session-task evidence check (40806f2, reverted in
|
|
78
|
+
// b839c22; firstSessionEvidenceFindings below). Kept only so what that version recorded recomputes
|
|
79
|
+
// with its own verdicts and wording; no new session binds it.
|
|
80
|
+
// Rule 8 = rule 5 plus the session-task evidence check (sessionEvidenceFindings below): a new
|
|
81
|
+
// `开发: 会话` task must declare, under its own task line, a 必跑检查 that runs a script file checking
|
|
82
|
+
// the walkthrough content, since a lone `test -f 走查文件` left the reviewer only the file's prose
|
|
83
|
+
// (aihot specs12 T-002, 2026-12-01).
|
|
75
84
|
// Rules are therefore feature sets, not a ladder: test them with the predicates below.
|
|
76
|
-
// Reports recorded under rules 1–
|
|
77
|
-
export const PRD_SELF_CHECK_RULES=
|
|
85
|
+
// Reports recorded under rules 1–7 recompute exactly as before.
|
|
86
|
+
export const PRD_SELF_CHECK_RULES=8;
|
|
78
87
|
export const PRD_SELF_CHECK_LEGACY_GRAMMAR_RULES=6;
|
|
79
|
-
export const ruleReadsGrammar3=rules=>rules===4||rules===5;
|
|
80
|
-
export const ruleExemptsInapplicable=rules=>rules===5||rules===6;
|
|
88
|
+
export const ruleReadsGrammar3=rules=>rules===4||rules===5||rules===7||rules===8;
|
|
89
|
+
export const ruleExemptsInapplicable=rules=>rules===5||rules===6||rules===7||rules===8;
|
|
90
|
+
export const ruleChecksFirstSessionEvidence=rules=>rules===7;
|
|
91
|
+
export const ruleChecksSessionEvidence=rules=>rules===8;
|
|
81
92
|
// Every rule a session, an operation or a recorded report may carry. Earlier rules
|
|
82
93
|
// stay listed explicitly so raising the current one never drops them.
|
|
83
|
-
export const PRD_SELF_CHECK_RULE_VERSIONS=Object.freeze([...new Set([PRD_SELF_CHECK_RULES,PRD_SELF_CHECK_LEGACY_GRAMMAR_RULES,4,3,2,1])]);
|
|
94
|
+
export const PRD_SELF_CHECK_RULE_VERSIONS=Object.freeze([...new Set([PRD_SELF_CHECK_RULES,PRD_SELF_CHECK_LEGACY_GRAMMAR_RULES,7,5,4,3,2,1])]);
|
|
84
95
|
// Task- or dependency-looking lines the parser skips: a task written this way
|
|
85
96
|
// would silently drop out of execution.
|
|
86
97
|
const TASK_LIKE=/^\s*-\s*\[[^\]]*\]\s+(?:~~)?T-/,DEPENDENCY_LIKE=/^\s*-\s*T-\S*\s+依赖(?:\s|$)/;
|
|
@@ -136,11 +147,16 @@ export function matchesPrdDraftMechanics(draft,recorded,options={}){
|
|
|
136
147
|
// `sessionTasks` ([directory...]) likewise applies only what rule 4 adds (tasks.md
|
|
137
148
|
// read as grammar 3, with the session-task checks) to the features whose save
|
|
138
149
|
// recorded rule 4, so a correction cannot move or add a `开发: 会话` mark unnoticed.
|
|
139
|
-
|
|
150
|
+
// `sessionEvidence` / `firstSessionEvidence` ([directory...]) do the same for rule 8's and
|
|
151
|
+
// rule 7's session-task evidence checks. `sessionEvidenceExempt` ({directory: {taskId: sha256}})
|
|
152
|
+
// names the session tasks an approval held unchanged (task-scope-record.mjs); a change passes the
|
|
153
|
+
// same map as `scopes[directory].evidence`.
|
|
154
|
+
export function checkPrdDraftMechanics(draft,{change=false,previous=null,rules=1,scopes=null,sessionTasks=null,inapplicableAcceptance=null,
|
|
155
|
+
sessionEvidence=null,firstSessionEvidence=null,sessionEvidenceExempt=null}={}){
|
|
140
156
|
need(PRD_SELF_CHECK_RULE_VERSIONS.includes(rules),'prd_self_check_rules_invalid');
|
|
141
|
-
|
|
142
|
-
'prd_self_check_rules_invalid');
|
|
143
|
-
need(
|
|
157
|
+
for(const list of [sessionTasks,inapplicableAcceptance,sessionEvidence,firstSessionEvidence])
|
|
158
|
+
need(list===null||Array.isArray(list)&&list.every(item=>typeof item==='string'),'prd_self_check_rules_invalid');
|
|
159
|
+
need(sessionEvidenceExempt===null||plainObject(sessionEvidenceExempt)&&Object.values(sessionEvidenceExempt).every(validTaskDigests),
|
|
144
160
|
'prd_self_check_rules_invalid');
|
|
145
161
|
const findings=[],features=[];
|
|
146
162
|
for(const feature of draft.features){
|
|
@@ -191,6 +207,14 @@ export function checkPrdDraftMechanics(draft,{change=false,previous=null,rules=1
|
|
|
191
207
|
if(problems.length)add('task_scope_invalid',{field:`${feature.directory}/tasks.md`,problems:problems.slice(0,10)});
|
|
192
208
|
}
|
|
193
209
|
if(grammar3&&!parsed.error)for(const item of sessionTaskFindings(feature.directory,files.get('tasks.md')))add(item.code,item.reason);
|
|
210
|
+
const inFeature=list=>list?.includes(feature.directory)===true;
|
|
211
|
+
if(grammar3&&!parsed.error&&(ruleChecksSessionEvidence(rules)||inFeature(sessionEvidence))){
|
|
212
|
+
need(scope?.evidence===undefined||validTaskDigests(scope.evidence),'prd_self_check_rules_invalid');
|
|
213
|
+
for(const item of sessionEvidenceFindings(feature.directory,files.get('tasks.md'),
|
|
214
|
+
{approved:scope?.evidence??sessionEvidenceExempt?.[feature.directory]??{},
|
|
215
|
+
requirements:files.get('requirements.md')??'',testCases:files.get('test-cases.json')}))add(item.code,item.reason);
|
|
216
|
+
}else if(grammar3&&!parsed.error&&(ruleChecksFirstSessionEvidence(rules)||inFeature(firstSessionEvidence)))
|
|
217
|
+
for(const item of firstSessionEvidenceFindings(feature.directory,files.get('tasks.md'),{exempt:scope?.exempt??[]}))add(item.code,item.reason);
|
|
194
218
|
if(files.has('test-cases.json')){
|
|
195
219
|
let cases;try{cases=JSON.parse(files.get('test-cases.json'));}catch{add('test_cases_invalid');}
|
|
196
220
|
if(cases){
|
|
@@ -225,3 +249,91 @@ export function sessionTaskFindings(directory,source,{grammar=TASK_GRAMMAR}={}){
|
|
|
225
249
|
return problem?[{feature:directory,code:problem.code,reason:{field:`${directory}/tasks.md`,tasks:problem.tasks,
|
|
226
250
|
...(problem.dependents?{dependents:problem.dependents}:{}),expected:sessionTaskReason(problem)}}]:[];
|
|
227
251
|
}
|
|
252
|
+
|
|
253
|
+
// Rule 8: each `开发: 会话` task must declare, on a line of its own block (taskAcceptanceText), a
|
|
254
|
+
// `必跑检查:` command that runs a script file (runsScriptFile) and that cm-ai's strict contract
|
|
255
|
+
// (buildTaskAcceptanceContract over the same tasks, requirements and cases) enables and keeps as a
|
|
256
|
+
// required command. 运行/执行/必跑命令 lines and scripts declared only under a linked AC do not count:
|
|
257
|
+
// cm-ai may run those, but the task itself has to name its walkthrough check (review r1 B2, r3 B2).
|
|
258
|
+
// Existence probes, listings, inline code (`-e`/`-c`), syntax checks and test runners are not
|
|
259
|
+
// walkthrough checks (review r1 B3); what the script checks is left to review.
|
|
260
|
+
// `approved` ({taskId: sha256}) exempts only a task an approval already held as a session task and
|
|
261
|
+
// whose block is byte-for-byte unchanged (sessionTaskDigest; review r1 B4).
|
|
262
|
+
const SCRIPT_ENGINES=new Map([['sh',/\.sh$/],['bash',/\.sh$/],['node',/\.(?:mjs|cjs|js)$/],['python',/\.py$/],['python3',/\.py$/]]);
|
|
263
|
+
const relativeFile=value=>typeof value==='string'&&!value.startsWith('-')&&!value.startsWith('/')
|
|
264
|
+
&&value.replace(/^\.\//,'').split('/').every(part=>part&&part!=='.'&&part!=='..');
|
|
265
|
+
// A `./` command must itself be a script file (review r1 #3: `./tools/node --check x.js` is a syntax check).
|
|
266
|
+
const SCRIPT_FILE=/\.(?:sh|mjs|cjs|js|py)$/;
|
|
267
|
+
export const runsScriptFile=argv=>/^\.\/[^\s]+$/.test(argv[0])&&relativeFile(argv[0])&&SCRIPT_FILE.test(argv[0])
|
|
268
|
+
||SCRIPT_ENGINES.has(argv[0])&&relativeFile(argv[1])&&SCRIPT_ENGINES.get(argv[0]).test(argv[1]);
|
|
269
|
+
export const SESSION_EVIDENCE_HINT='在会话任务自己下面写一行 - 必跑检查: `sh scripts/check-{功能}-walkthrough.sh`(也可 node/python3 执行脚本文件;脚本列入本任务或更早任务的范围)。'
|
|
270
|
+
+'脚本核对走查文件里本任务的每个 AC 编号都有观察记录,且记录引用的截图或日志路径真实存在,缺一项就非零退出;'
|
|
271
|
+
+'只写「运行:」或只在关联 AC 下写脚本都不算;`test -f`、`ls`、`grep`、`node -e`、`sh -c` 包装和 `--check` 语法检查也不算';
|
|
272
|
+
// The task's own block only: lines under its task line, not a separate 验证要求 section (review r1 #2).
|
|
273
|
+
function ownTaskBlock(source,taskId){
|
|
274
|
+
const kept=[];let owner=null,ownerIndent=0;
|
|
275
|
+
for(const {body,declaration} of taskLines(source,{grammar:TASK_GRAMMAR})){
|
|
276
|
+
const indent=/^[ \t]*/.exec(body)[0].length;
|
|
277
|
+
if(declaration){owner=declaration.id;ownerIndent=indent;}
|
|
278
|
+
// A heading ends the block at any indent, as task-scope.mjs reads it (review r2 #1).
|
|
279
|
+
else if(body.trim()&&owner!==null&&(indent<=ownerIndent||/^\s*#/.test(body)))owner=null;
|
|
280
|
+
if(owner===taskId&&body.trim())kept.push(body);
|
|
281
|
+
}
|
|
282
|
+
return kept.join('\n');
|
|
283
|
+
}
|
|
284
|
+
// Both the block and what cm-ai reads for the task: moving a line between them is a change (review r1 #4).
|
|
285
|
+
export const sessionTaskDigest=(source,taskId)=>digest({block:ownTaskBlock(source,taskId),acceptance:taskAcceptanceText(source,taskId)});
|
|
286
|
+
const plainObject=value=>value!==null&&typeof value==='object'&&!Array.isArray(value);
|
|
287
|
+
// {taskId: sha256}, the per-feature shape of sessionEvidenceExempt.
|
|
288
|
+
export const validTaskDigests=value=>plainObject(value)
|
|
289
|
+
&&Object.entries(value).every(([id,sha])=>/^T-[A-Za-z0-9][A-Za-z0-9._-]*$/.test(id)&&typeof sha==='string'&&/^[0-9a-f]{64}$/.test(sha));
|
|
290
|
+
// The commands cm-ai itself takes from each unfenced `必跑检查:` line of the task's own block, read
|
|
291
|
+
// alone: a line cm-ai rejects (prose around the command, shell syntax) yields none, even when the same
|
|
292
|
+
// argv reaches the contract from a linked AC (review r1 #1).
|
|
293
|
+
function ownEvidenceCommands(source,taskId){
|
|
294
|
+
const commands=[];
|
|
295
|
+
for(const {body,fenced} of taskLines(ownTaskBlock(source,taskId),{grammar:TASK_GRAMMAR})){
|
|
296
|
+
if(fenced||!/^必跑检查\s*[::]/.test(body.trim().replace(/^(?:[-*+]|\d+[.)])\s+/,'')))continue;
|
|
297
|
+
const line=buildAcceptanceContract({taskId,taskText:body.trim(),requirementsText:'',explicitOnly:true});
|
|
298
|
+
if(line)commands.push(...line.requiredCommands);
|
|
299
|
+
}
|
|
300
|
+
return commands;
|
|
301
|
+
}
|
|
302
|
+
export function sessionEvidenceFindings(directory,source,{approved={},requirements='',testCases}={}){
|
|
303
|
+
const parsed=parseFeatureTaskText(source,{grammar:TASK_GRAMMAR});
|
|
304
|
+
if(parsed.error)return [];
|
|
305
|
+
const missing=[];
|
|
306
|
+
for(const taskId of parseTaskScopes(source,{grammar:TASK_GRAMMAR}).sessions){
|
|
307
|
+
if(parsed.tasks.some(task=>task.id===taskId&&task.dropped))continue;
|
|
308
|
+
if(Object.hasOwn(approved,taskId)&&approved[taskId]===sessionTaskDigest(source,taskId))continue;
|
|
309
|
+
// A contract cm-ai could not build (e.g. unreadable test cases) enables no check here either.
|
|
310
|
+
let contract=null;
|
|
311
|
+
try{contract=buildTaskAcceptanceContract({texts:{'tasks.md':source,'requirements.md':requirements,
|
|
312
|
+
...(testCases===undefined?{}:{'test-cases.json':testCases})},taskId});}catch{contract=null;}
|
|
313
|
+
const required=new Set((contract?.requiredCommands??[]).map(argv=>JSON.stringify(argv)));
|
|
314
|
+
if(!ownEvidenceCommands(source,taskId).some(argv=>runsScriptFile(argv)&&required.has(JSON.stringify(argv))))missing.push(taskId);
|
|
315
|
+
}
|
|
316
|
+
return missing.length?[{feature:directory,code:'session_task_evidence_missing',
|
|
317
|
+
reason:{field:`${directory}/tasks.md`,tasks:missing,expected:SESSION_EVIDENCE_HINT}}]:[];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Rule 7 (40806f2, never released): verbatim, so its recorded sessions, scope records and reports
|
|
321
|
+
// recompute as that version computed them (review r2 blocker 2, r3 blocker 2).
|
|
322
|
+
const EXISTENCE_PROBES=new Set(['test','[','ls','stat']);
|
|
323
|
+
const existenceOnly=argv=>EXISTENCE_PROBES.has(argv[0])
|
|
324
|
+
||['sh','bash'].includes(argv[0])&&argv[1]==='-c'&&EXISTENCE_PROBES.has(argv[2]);
|
|
325
|
+
const FIRST_SESSION_EVIDENCE_HINT='在会话任务下写一行 - 必跑检查: `sh scripts/check-{功能}-walkthrough.sh`(脚本列入本任务或更早任务的范围)。'
|
|
326
|
+
+'脚本核对走查文件里本任务的每个 AC 编号都有观察记录,且记录引用的截图或日志路径真实存在,缺一项就非零退出;'
|
|
327
|
+
+'`test -f`、`ls` 这类只看走查文件在不在的命令不算';
|
|
328
|
+
function firstSessionEvidenceFindings(directory,source,{exempt=[]}={}){
|
|
329
|
+
const parsed=parseFeatureTaskText(source,{grammar:TASK_GRAMMAR});
|
|
330
|
+
if(parsed.error)return [];
|
|
331
|
+
const known=new Set(exempt),missing=[];
|
|
332
|
+
for(const taskId of parseTaskScopes(source,{grammar:TASK_GRAMMAR}).sessions){
|
|
333
|
+
if(known.has(taskId)||parsed.tasks.some(task=>task.id===taskId&&task.dropped))continue;
|
|
334
|
+
const commands=buildAcceptanceContract({taskId,taskText:taskAcceptanceText(source,taskId),requirementsText:''}).requiredCommands;
|
|
335
|
+
if(!commands.some(argv=>!existenceOnly(argv)))missing.push(taskId);
|
|
336
|
+
}
|
|
337
|
+
return missing.length?[{feature:directory,code:'session_task_evidence_missing',
|
|
338
|
+
reason:{field:`${directory}/tasks.md`,tasks:missing,expected:FIRST_SESSION_EVIDENCE_HINT}}]:[];
|
|
339
|
+
}
|
|
@@ -9,6 +9,8 @@ import {readCmInitSource} from '../cm-init/draft-inspection.mjs';
|
|
|
9
9
|
import {TASK_GRAMMAR} from '../spec-task-line.mjs';
|
|
10
10
|
import {readSpecsStatus} from '../specs-status.mjs';
|
|
11
11
|
import {PRD_SELF_CHECK_RULES,PRD_SELF_CHECK_RULE_VERSIONS,PRD_SELF_CHECK_LEGACY_GRAMMAR_RULES,ruleReadsGrammar3} from './self-check.mjs';
|
|
12
|
+
import {executorRelease,createdByRecord,checkCreatedBy,assertResumable} from '../executor-version.mjs';
|
|
13
|
+
import {PRD_AI_DRAFT_POLICY,prdAiDraftPolicy} from './ai-draft.mjs';
|
|
12
14
|
|
|
13
15
|
export function readPrdSessionFile(root,relative){
|
|
14
16
|
if(!['state.json','inputs-replaced.json'].includes(relative))return readCmInitSource(root,relative)?.toString('utf8')??null;
|
|
@@ -31,6 +33,34 @@ export function replaceSessionFile(root,relative,before,after){
|
|
|
31
33
|
}finally{if(fd!==undefined)fs.closeSync(fd);try{fs.unlinkSync(tmp);}catch(e){if(e.code!=='ENOENT')throw e;}}
|
|
32
34
|
}
|
|
33
35
|
export const MAX_ANSWER_DISCARDS=2;
|
|
36
|
+
// dogfood 2026-12-01 问题 7: sessions created with this marker may discard a recorded prd_correct
|
|
37
|
+
// answer the host refused before writing anything; the host proves that (assertPrdCorrectionRefused).
|
|
38
|
+
export const PRD_CORRECTION_DISCARD=1;
|
|
39
|
+
// Session formats: 1 and 2 predate createdBy (2 = with an execution policy).
|
|
40
|
+
// 3 records the creating CM release; whether it carries a policy is the presence
|
|
41
|
+
// of executionPolicy. 0.21.7 and earlier accept only 1 and 2, so they refuse a 3.
|
|
42
|
+
export const PRD_SESSION_VERSION=3;
|
|
43
|
+
export const prdSessionHasPolicy=state=>state?.version===2||state?.version===3&&Object.hasOwn(state,'executionPolicy');
|
|
44
|
+
// A stored createdBy is checked, and an older executor never continues a session a
|
|
45
|
+
// newer one created. A 1/2 state carrying createdBy is damage, never a legacy run.
|
|
46
|
+
export function checkPrdSessionCreator(state){
|
|
47
|
+
if(state?.version===PRD_SESSION_VERSION){
|
|
48
|
+
assertResumable(Object.hasOwn(state,'createdBy')?state.createdBy:null);
|
|
49
|
+
}else if(state!==null&&typeof state==='object'&&Object.hasOwn(state,'createdBy'))checkCreatedBy(null);
|
|
50
|
+
}
|
|
51
|
+
const prdSessionDirectory=(specs,sessionId)=>path.join(specs,'.reviews','prd-sessions',sessionId);
|
|
52
|
+
// Read-only preflight before anything is written (directories, writer lock,
|
|
53
|
+
// predecessor link): a new session needs a known release, a recorded one must
|
|
54
|
+
// not be newer than this executor. The locked open checks again.
|
|
55
|
+
export function assertPrdSessionExecutor({specs,sessionId}){
|
|
56
|
+
need(/^prd-[a-zA-Z0-9-]{1,80}$/.test(sessionId),'prd_session_id_invalid');
|
|
57
|
+
// An unreadable state is left to the locked open, which reports it; until then
|
|
58
|
+
// treat it as new, so a missing release still stops before any write.
|
|
59
|
+
let bytes=null;try{bytes=readPrdSessionFile(prdSessionDirectory(specs,sessionId),'state.json');}catch{}
|
|
60
|
+
if(bytes===null){executorRelease();return;}
|
|
61
|
+
let state;try{state=JSON.parse(bytes);}catch{return;}
|
|
62
|
+
checkPrdSessionCreator(state);
|
|
63
|
+
}
|
|
34
64
|
// The task grammar and self-check rule a session binds when it is created; they
|
|
35
65
|
// govern only operations it starts later (an active operation keeps its own rule).
|
|
36
66
|
// A session created before they were recorded keeps what was published then, as
|
|
@@ -50,8 +80,11 @@ export function prdSessionVersions(state,specs=null){
|
|
|
50
80
|
}
|
|
51
81
|
return Object.hasOwn(state,'selfCheckRules')?{taskGrammar:state.taskGrammar,selfCheckRules:state.selfCheckRules}:{...PRD_SESSION_LEGACY_VERSIONS};
|
|
52
82
|
}
|
|
53
|
-
|
|
54
|
-
|
|
83
|
+
// specDrafting: a NEW new-mode session binds the AI-draft contract (ai-draft.mjs);
|
|
84
|
+
// an existing state keeps what it was created with, absent = original behaviour.
|
|
85
|
+
export function openPrdSession({specs,sessionId,identity,executionPolicy=null,specDrafting=null}){
|
|
86
|
+
need(specDrafting===null||specDrafting===PRD_AI_DRAFT_POLICY,'prd_session_versions_invalid');
|
|
87
|
+
assertPrdSessionExecutor({specs,sessionId});
|
|
55
88
|
for(const relative of ['.reviews','.reviews/prd-sessions',`.reviews/prd-sessions/${sessionId}`]){
|
|
56
89
|
const dir=path.join(specs,relative);try{fs.mkdirSync(dir,{mode:0o700});}catch(e){if(e.code!=='EEXIST')throw e;}
|
|
57
90
|
need(fs.realpathSync(dir)===dir&&fs.lstatSync(dir).isDirectory(),'prd_session_path_invalid');
|
|
@@ -66,24 +99,30 @@ export function openPrdSession({specs,sessionId,identity,executionPolicy=null}){
|
|
|
66
99
|
}
|
|
67
100
|
const lockBytes=JSON.stringify({pid:process.pid,nonce:randomUUID()});
|
|
68
101
|
const fd=fs.openSync(lock,'wx',0o600);try{fs.writeFileSync(fd,lockBytes);fs.fsyncSync(fd);}finally{fs.closeSync(fd);}
|
|
69
|
-
let bytes
|
|
70
|
-
|
|
71
|
-
...(
|
|
72
|
-
|
|
102
|
+
let bytes,state;
|
|
103
|
+
try{bytes=read();state=bytes===null?{version:PRD_SESSION_VERSION,identity,createdBy:createdByRecord(),checkpoint:null,active:null,segments:{},
|
|
104
|
+
...prdSessionVersions(null,specs),...(specDrafting===null?{}:{specDrafting}),
|
|
105
|
+
...(executionPolicy===null?{}:{executionPolicy:readExecutionPolicy(executionPolicy),responseRepairs:[]}),
|
|
106
|
+
// Created now: a refused original prd_correct answer may be discarded (discardAnswer); stored sessions keep their rule.
|
|
107
|
+
correctionDiscard:PRD_CORRECTION_DISCARD}:JSON.parse(bytes);
|
|
108
|
+
checkPrdSessionCreator(state);
|
|
109
|
+
need([1,2,PRD_SESSION_VERSION].includes(state.version)&&digest(state.identity)===digest(identity),'prd_session_identity_changed');
|
|
73
110
|
need(Object.hasOwn(state,'taskGrammar')===Object.hasOwn(state,'selfCheckRules')&&(!Object.hasOwn(state,'taskGrammar')
|
|
74
111
|
||Number.isSafeInteger(state.taskGrammar)&&state.taskGrammar>=2&&state.taskGrammar<=TASK_GRAMMAR
|
|
75
112
|
&&PRD_SELF_CHECK_RULE_VERSIONS.includes(state.selfCheckRules)
|
|
76
113
|
// A grammar-3 rule only with grammar 3, and rule 6 (grammar-2 exemption) only with grammar 2.
|
|
77
114
|
&&(!ruleReadsGrammar3(state.selfCheckRules)||state.taskGrammar===TASK_GRAMMAR)
|
|
78
115
|
&&(state.selfCheckRules!==PRD_SELF_CHECK_LEGACY_GRAMMAR_RULES||state.taskGrammar===2)),'prd_session_versions_invalid');
|
|
79
|
-
|
|
116
|
+
need(!Object.hasOwn(state,'correctionDiscard')||state.version===PRD_SESSION_VERSION&&state.correctionDiscard===PRD_CORRECTION_DISCARD,'prd_session_versions_invalid');
|
|
117
|
+
need(!Object.hasOwn(state,'specDrafting')||state.version===PRD_SESSION_VERSION&&state.specDrafting===PRD_AI_DRAFT_POLICY,'prd_session_versions_invalid');
|
|
118
|
+
if(prdSessionHasPolicy(state)){readExecutionPolicy(state.executionPolicy);need(Array.isArray(state.responseRepairs),'prd_recovery_binding');}
|
|
80
119
|
else need(executionPolicy===null,'execution_policy_legacy_run');}
|
|
81
120
|
catch(e){fs.unlinkSync(lock);throw e;}
|
|
82
121
|
let cursor=0;
|
|
83
122
|
const save=()=>{const next=JSON.stringify(state);replaceSessionFile(directory,'state.json',bytes,next);bytes=next;};
|
|
84
123
|
const projected=call=>{
|
|
85
124
|
if(!call.responseRepair)return call.result;
|
|
86
|
-
need(state
|
|
125
|
+
need(prdSessionHasPolicy(state)&&call.kind==='prd_review'&&digest({kind:call.kind,payload:call.payload})===call.requestDigest,'prd_recovery_binding');
|
|
87
126
|
const record=call.responseRepair;
|
|
88
127
|
shape(record,['version','callId','requestDigest','originalDigest','originalBase64','response','changes','reason']);
|
|
89
128
|
need(record.version===1&&record.callId===call.callId&&record.requestDigest===call.requestDigest
|
|
@@ -97,7 +136,7 @@ export function openPrdSession({specs,sessionId,identity,executionPolicy=null}){
|
|
|
97
136
|
get state(){return json(state,12*1024*1024);},
|
|
98
137
|
reviewResponse(call){return projected(call);},
|
|
99
138
|
repairReviewResponse(binding){
|
|
100
|
-
need(state
|
|
139
|
+
need(prdSessionHasPolicy(state)&&state.executionPolicy.responseRecovery==='mechanical-v1','execution_policy_required');
|
|
101
140
|
binding=readPrdRepairBinding(binding);
|
|
102
141
|
const saved=state.responseRepairs.find(item=>item.originalCall.callId===binding.callId);
|
|
103
142
|
if(saved){
|
|
@@ -131,6 +170,7 @@ export function openPrdSession({specs,sessionId,identity,executionPolicy=null}){
|
|
|
131
170
|
state.active={request,before,calls:[],...(selfCheckRules===null?{}:{selfCheckRules})};cursor=0;save();},
|
|
132
171
|
selfCheckRules(){return state.active?.selfCheckRules??1;},
|
|
133
172
|
versions(){return prdSessionVersions(state);},
|
|
173
|
+
aiDraftPolicy(){return prdAiDraftPolicy(state);},
|
|
134
174
|
replay(){need(state.active!==null,'prd_nothing_to_resume');cursor=0;return json(state.active,12*1024*1024);},
|
|
135
175
|
commit(checkpoint){state.checkpoint=checkpoint;state.active=null;save();},
|
|
136
176
|
checkpoint(checkpoint){state.checkpoint=checkpoint;save();},
|
|
@@ -150,9 +190,10 @@ export function openPrdSession({specs,sessionId,identity,executionPolicy=null}){
|
|
|
150
190
|
// after recording, so a plain resume replays the same refusal forever) is
|
|
151
191
|
// discarded by an explicit, append-only record and asked again under the same
|
|
152
192
|
// pending operation. Only the last recorded answer, never prd_review (its own
|
|
153
|
-
// abandon path, below) or prd_correct (its archive drives recovery)
|
|
154
|
-
//
|
|
155
|
-
|
|
193
|
+
// abandon path, below) or prd_correct (its archive drives recovery), except a
|
|
194
|
+
// prd_correct the host proved refused before any write (correctionRefused) in a
|
|
195
|
+
// session created with correctionDiscard; at most MAX_ANSWER_DISCARDS per call kind in a session.
|
|
196
|
+
discardAnswer(resolution,{correctionRefused=false}={}){
|
|
156
197
|
need(resolution!==null&&typeof resolution==='object'&&!Array.isArray(resolution)&&resolution.discard===true
|
|
157
198
|
&&!Object.hasOwn(resolution,'result')
|
|
158
199
|
&&Object.keys(resolution).every(key=>['callId','requestDigest','discard','evidence'].includes(key)),'prd_recovery_binding');
|
|
@@ -160,7 +201,8 @@ export function openPrdSession({specs,sessionId,identity,executionPolicy=null}){
|
|
|
160
201
|
const active=state.active,index=active?active.calls.findIndex(item=>item.callId===resolution.callId):-1,call=active?.calls[index];
|
|
161
202
|
need(call&&index===active.calls.length-1&&call.requestDigest===resolution.requestDigest&&Object.hasOwn(call,'result'),'prd_recovery_binding');
|
|
162
203
|
need(call.kind!=='prd_review','prd_review_recovery_required');
|
|
163
|
-
need(call.kind!=='prd_correct'
|
|
204
|
+
need(call.kind!=='prd_correct'||correctionRefused===true&&state.correctionDiscard===PRD_CORRECTION_DISCARD
|
|
205
|
+
&&active.request.operation==='correct_findings','prd_correction_recovery_required');
|
|
164
206
|
const discarded=state.discardedAnswers??[];
|
|
165
207
|
need(discarded.filter(item=>item.kind===call.kind).length<MAX_ANSWER_DISCARDS,'prd_answer_discard_limit');
|
|
166
208
|
const decision={operation:active.request.operation,kind:call.kind,callId:call.callId,requestDigest:call.requestDigest,
|
|
@@ -16,8 +16,10 @@ import {checkPrdDraftMechanics} from './self-check.mjs';
|
|
|
16
16
|
import {prdTaskScopeOptions} from './task-scope-record.mjs';
|
|
17
17
|
import {need,json,shape,digest} from '../cm-ai/effect-contract.mjs';
|
|
18
18
|
import {inspectPrdFailedCorrection} from './failed-correction.mjs';
|
|
19
|
+
import {prdNarrowUserDecisionEvidence} from './review-correction.mjs';
|
|
19
20
|
import {prdDesignRiskSignals} from './design-risk.mjs';
|
|
20
21
|
import {summaryAcceptancePreview} from './acceptance-preview.mjs';
|
|
22
|
+
import {inspectPrdAiDraftSummary,PRD_AI_DRAFT_CHECKLIST,PRD_AI_DRAFT_SUMMARY_INSTRUCTIONS} from './ai-draft.mjs';
|
|
21
23
|
const sha=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
22
24
|
|
|
23
25
|
export function inspectPrdSummaryEvidence(specs,{currentFeatures}={}){
|
|
@@ -113,7 +115,19 @@ export function inspectPrdSummaryEvidence(specs,{currentFeatures}={}){
|
|
|
113
115
|
reviews.split={...reviews.split,archive:reviews.split.archive??'unavailable',
|
|
114
116
|
reason:[reviews.split.reason,`self_check_revision:${error.code??error.message}`].filter(Boolean).join('; ')};
|
|
115
117
|
}
|
|
116
|
-
|
|
118
|
+
// A user's accept-risks decision after the design narrow-review stop: its blockers must reach the human summary.
|
|
119
|
+
// The design receipt binds the decision it released on; a missing or rewritten decision blocks instead of hiding risks.
|
|
120
|
+
let narrowDecision=null,narrowProblem=null;
|
|
121
|
+
try{narrowDecision=prdNarrowUserDecisionEvidence({specs,feature:directory});}catch(error){if(!historical)throw error;narrowProblem=error.code??'invalid';}
|
|
122
|
+
if(narrowDecision)evidenceFiles.push({path:narrowDecision.path,sha256:narrowDecision.sha256});
|
|
123
|
+
let bound=null;
|
|
124
|
+
if(reviews.design?.gate?.outcome==='completed'){
|
|
125
|
+
const receipt=readCmInitSource(specs,`.reviews/prd-${slug}-design-disposition.json`);
|
|
126
|
+
try{bound=JSON.parse(receipt.toString('utf8')).narrow_user_decision_sha256??null;}catch{bound=null;}
|
|
127
|
+
}
|
|
128
|
+
if(!historical&&(bound??null)!==(narrowDecision?.sha256??null)
|
|
129
|
+
&&!(bound===null&&reviews.design?.gate?.outcome!=='completed'))narrowProblem='narrow_user_decision_binding_mismatch';
|
|
130
|
+
features.push({directory,reviews,cases,...(narrowDecision?{narrowUserDecision:narrowDecision.risks}:{}),...(narrowProblem&&!historical?{narrowUserDecisionProblem:narrowProblem}:{}),...(revision?{selfCheckRevision:{reason:revision.reason,round:revision.round,
|
|
117
131
|
changedFiles:revision.features.find(f=>f.directory===directory).changedFiles}}:{}),...(currentFeatures===undefined?{}:{historical})});
|
|
118
132
|
}
|
|
119
133
|
const checked=documents.filter(item=>currentFeatures===undefined||currentFeatures.includes(item.directory));
|
|
@@ -142,7 +156,7 @@ export function publishPrdAwaitingReview({specs,summary,writeEnabled,recover=fal
|
|
|
142
156
|
&&summary.publicationInput.every(item=>item.path==='.cm-specs-status'||before.evidenceFiles.some(next=>next.path===item.path&&next.sha256===item.sha256))
|
|
143
157
|
&&before.evidenceFiles.filter(item=>item.path!=='.cm-specs-status').length===summary.publicationInput.filter(item=>item.path!=='.cm-specs-status').length,
|
|
144
158
|
'prd_summary_inputs_changed');
|
|
145
|
-
return json({status:'awaiting_review',path:path.join(specs,'.cm-specs-status'),features:value.features,
|
|
159
|
+
return json({status:'awaiting_review',path:path.join(specs,'.cm-specs-status'),features:value.features,at:value.at,
|
|
146
160
|
completionAuthorized:false,next:'human_review_then_explicit_cm_ai'});
|
|
147
161
|
}
|
|
148
162
|
}
|
|
@@ -160,7 +174,7 @@ export function publishPrdAwaitingReview({specs,summary,writeEnabled,recover=fal
|
|
|
160
174
|
}});
|
|
161
175
|
need(readCmInitSource(specs,'.cm-specs-status')?.equals(bytes),'prd_summary_status_unknown');
|
|
162
176
|
need(digest(buildManifest(specs))===digest(before.specFiles),'prd_summary_inputs_changed');
|
|
163
|
-
return json({status:'awaiting_review',path:target,features:status.features,completionAuthorized:false,
|
|
177
|
+
return json({status:'awaiting_review',path:target,features:status.features,at:status.at,completionAuthorized:false,
|
|
164
178
|
next:'human_review_then_explicit_cm_ai'});
|
|
165
179
|
}catch{return json({status:'awaiting_review_write_unknown',next:'inspect_status_and_specs_without_automatic_retry',completionAuthorized:false});}
|
|
166
180
|
}
|
|
@@ -173,14 +187,21 @@ export function createPrdSummaryOwner({summarize}){
|
|
|
173
187
|
if(typeof options.aborted==='boolean'){signal=options;options={};}
|
|
174
188
|
const scope={currentFeatures:Array.isArray(options.currentFeatures)?options.currentFeatures.slice():options.currentFeatures};
|
|
175
189
|
need(!signal.aborted,'cancelled');const evidence=inspectPrdSummaryEvidence(specs,scope),evidenceDigest=digest(evidence);
|
|
190
|
+
// options.aiDraft = {analysisDecisions} only for an AI-draft session (ai-draft.mjs).
|
|
191
|
+
const aiDraft=options.aiDraft??null;need(aiDraft===null||Array.isArray(aiDraft.analysisDecisions)
|
|
192
|
+
&&(aiDraft.asked===undefined||Array.isArray(aiDraft.asked)),'prd_summary_details_invalid');
|
|
176
193
|
const details=json(await summarize({evidence,evidenceDigest,
|
|
177
|
-
instructions:'Prepare original cm-prd Step 11 human summary. Read actual source/context as needed. Return {evidenceDigest,deliveryForm,estimatedTime,openQuestions,risks,contextScope,platformReadiness,uiBaseline,designRisk:[{feature,signals:{greenfieldAdr,architectureOrDataFlow,newRuntimeDependencyOrToolchain,publicContractDataOrSecurity,fiveOrMoreFunctions},evidence:[specific references]}]}. designRisk must cover exactly the current features (historical !== true); historical reviews are registration notes only, never new blockers. Signals are booleans and must cover original Step 9.5 criteria; unknown facts must remain explicit in openQuestions/risks, never infer approval. All descriptive fields are non-empty strings. Do not claim review or tests beyond supplied evidence, write files, dispatch reviewers/providers, approve specs or start development.'
|
|
194
|
+
instructions:'Prepare original cm-prd Step 11 human summary. Read actual source/context as needed. Return {evidenceDigest,deliveryForm,estimatedTime,openQuestions,risks,contextScope,platformReadiness,uiBaseline,designRisk:[{feature,signals:{greenfieldAdr,architectureOrDataFlow,newRuntimeDependencyOrToolchain,publicContractDataOrSecurity,fiveOrMoreFunctions},evidence:[specific references]}]}. designRisk must cover exactly the current features (historical !== true); historical reviews are registration notes only, never new blockers. Signals are booleans and must cover original Step 9.5 criteria; unknown facts must remain explicit in openQuestions/risks, never infer approval. All descriptive fields are non-empty strings. Do not claim review or tests beyond supplied evidence, write files, dispatch reviewers/providers, approve specs or start development.'
|
|
195
|
+
+(aiDraft?PRD_AI_DRAFT_SUMMARY_INSTRUCTIONS:'')},signal),64*1024);
|
|
178
196
|
need(!signal.aborted,'cancelled');
|
|
179
|
-
shape(details,['evidenceDigest','deliveryForm','estimatedTime','openQuestions','risks','contextScope','platformReadiness','uiBaseline','designRisk'
|
|
197
|
+
shape(details,['evidenceDigest','deliveryForm','estimatedTime','openQuestions','risks','contextScope','platformReadiness','uiBaseline','designRisk',
|
|
198
|
+
...(aiDraft?['productDecisions','aiDraftSummary']:[])]);
|
|
180
199
|
need(details.evidenceDigest===evidenceDigest,'prd_summary_binding');
|
|
181
200
|
for(const field of ['deliveryForm','estimatedTime','openQuestions','risks','contextScope','platformReadiness','uiBaseline'])
|
|
182
201
|
need(typeof details[field]==='string'&&details[field].trim(),'prd_summary_details_invalid');
|
|
183
202
|
const current=evidence.features.filter(item=>!item.historical),historical=evidence.features.filter(item=>item.historical);
|
|
203
|
+
const decisionCard=aiDraft?inspectPrdAiDraftSummary(details,{analysisDecisions:aiDraft.analysisDecisions,asked:aiDraft.asked??[],
|
|
204
|
+
documents:evidence.documents.filter(item=>current.some(feature=>feature.directory===item.directory))}):null;
|
|
184
205
|
need(Array.isArray(details.designRisk)&&details.designRisk.length===current.length,'prd_summary_risk_coverage');
|
|
185
206
|
const seen=new Set(),blockers=[],notes=[];
|
|
186
207
|
for(const feature of historical)for(const [stage,review] of Object.entries(feature.reviews)){
|
|
@@ -207,12 +228,18 @@ export function createPrdSummaryOwner({summarize}){
|
|
|
207
228
|
risk.feature===finding.feature&&risk.failedChecks.some(check=>digest(check)===digest(finding))));
|
|
208
229
|
if(evidence.mechanical.status==='failed'&&unrecorded.length)blockers.push('mechanical_self_check_failed');
|
|
209
230
|
need(digest(inspectPrdSummaryEvidence(specs,scope))===evidenceDigest,'prd_summary_inputs_changed');
|
|
210
|
-
|
|
231
|
+
// An AI-draft batch shows product checks; technical ones stay with self-check and review.
|
|
232
|
+
const checklist=decisionCard?[...PRD_AI_DRAFT_CHECKLIST]:['跨feature产物不重复','依赖完整且无环','AC可验证','功能粒度合规且每feature≤15任务',
|
|
211
233
|
'开放问题和敏感决策已经人工确认','交付形态符合需求','存在原型时功能与交互覆盖完整'];
|
|
212
234
|
const totals=evidence.mechanical.features.reduce((sum,item)=>({tasks:sum.tasks+item.tasks,
|
|
213
235
|
acceptanceCriteria:sum.acceptanceCriteria+item.acceptanceCriteria}),{tasks:0,acceptanceCriteria:0});
|
|
214
236
|
const revisionNotes=current.filter(feature=>feature.selfCheckRevision).map(feature=>
|
|
215
237
|
`${feature.directory}:整稿自检失败后,在设计审查后修订了 ${feature.selfCheckRevision.changedFiles.join('、')};原因:${feature.selfCheckRevision.reason};第 ${feature.selfCheckRevision.round} 轮;${feature.reviews.split.gate.outcome==='completed'?'这些改动已由拆分审查审阅':'这些改动待拆分审查审阅'},未另做设计审查。`);
|
|
238
|
+
for(const feature of current.filter(item=>item.narrowUserDecisionProblem))blockers.push(`${feature.directory}: ${feature.narrowUserDecisionProblem}`);
|
|
239
|
+
for(const feature of current.filter(item=>item.narrowUserDecision)){
|
|
240
|
+
const decision=feature.narrowUserDecision;
|
|
241
|
+
revisionNotes.push(`${feature.directory}:设计窄审第 ${decision.round} 轮${decision.degradedOnly?'只有降级(作者自审)结论':'仍有阻断'},用户决定带风险继续(原话:${JSON.stringify(decision.userWords)});未解决:${decision.findings.length?decision.findings.map(item=>`${item.id}(${item.severity})${item.message}`).join(';'):'无阻断项(独立审查未通过)'}。`);
|
|
242
|
+
}
|
|
216
243
|
if(evidence.predecessor)revisionNotes.push(`前序批次 ${evidence.predecessor.sessionId} 因输入已替换而结束;原因:${evidence.predecessor.reason}。旧证据仅作历史,本批全部重新审查。`);
|
|
217
244
|
const humanDetails=riskCard.length||revisionNotes.length?{...details,risks:[...riskCard.map(risk=>
|
|
218
245
|
`${risk.feature}:修正自检失败,待人工裁决;${JSON.stringify(risk.failedChecks)}`),...revisionNotes,details.risks].join('\n')}:details;
|
|
@@ -221,6 +248,7 @@ export function createPrdSummaryOwner({summarize}){
|
|
|
221
248
|
need(digest(inspectPrdSummaryEvidence(specs,scope))===evidenceDigest,'prd_summary_inputs_changed');
|
|
222
249
|
const summary=json({...(evidence.predecessor?{predecessor:evidence.predecessor}:{}),status:'human_summary_prepared',evidenceDigest,details:humanDetails,features:evidence.features,totals,
|
|
223
250
|
acceptancePreview,
|
|
251
|
+
...(decisionCard?{decisionCard}:{}),
|
|
224
252
|
...(riskCard.length?{riskCard}:{}),
|
|
225
253
|
...(evidence.currentFeatures===undefined?{}:{currentFeatures:evidence.currentFeatures}),
|
|
226
254
|
notes,historicalSummary:`历史 feature:${historical.length} 个已登记,${historical.filter(item=>Object.values(item.reviews).some(review=>review.archive)).length} 个含旧版归档说明`,
|