@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
|
@@ -10,7 +10,7 @@ import {readCloseoutPolicy} from './knowledge-closeout.mjs';
|
|
|
10
10
|
import {readQaAttachment} from './qa-attachment.mjs';
|
|
11
11
|
import {acceptanceProblems,encodeAcceptanceEvidence,acceptanceCoverage,describeAcceptanceProblems} from './acceptance-contract.mjs';
|
|
12
12
|
// Trusted synthetic fixture host; explicit V2 supports isolated task-file writes.
|
|
13
|
-
import { randomUUID } from 'node:crypto';
|
|
13
|
+
import { randomUUID, createHash } from 'node:crypto';
|
|
14
14
|
import { types } from 'node:util';
|
|
15
15
|
import fs from 'node:fs';
|
|
16
16
|
import path from 'node:path';
|
|
@@ -18,7 +18,7 @@ import {createRequire} from 'node:module';
|
|
|
18
18
|
import {verifySpecificationMaterial,boundSpecificationMaterial,inspectSpecificationDrift,describeSpecificationDrift,
|
|
19
19
|
readSpecificationRebind} from './specification-material.mjs';
|
|
20
20
|
import {SYMLINK_BASELINE_VERSION} from './symlink-material.mjs';
|
|
21
|
-
import { captureReviewBaseline, captureScopeRevisionSources, captureReviewInventory, compareReviewBaseline, createReviewPackage, verifyReviewPackage, verifyCompletionReviewPackage, validChecks, readReviewSourceFiles } from './review-package.mjs';
|
|
21
|
+
import { captureReviewBaseline, captureScopeRevisionSources, captureReviewInventory, compareReviewInventoryToBaseline, readHandoffSnapshot, reviewPackageFileIdentities, compareReviewBaseline, createReviewPackage, verifyReviewPackage, verifyCompletionReviewPackage, validChecks, readReviewSourceFiles } from './review-package.mjs';
|
|
22
22
|
import { digest,need,shape,id,text,json,freeze,arrayItems,validIdentity,validTaskLearningInput,validCallTimeout,requestFor,terminalFor,failureCode,
|
|
23
23
|
JOURNAL_PAYLOAD_LIMIT,JOURNAL_REASON_LIMIT,developCheckpointReserve,taskReviewScope,boundedReason } from './effect-contract.mjs';
|
|
24
24
|
import { reviewResult,reviewReceipt,boundReviewText,reviewPaths } from './review-runner.mjs';
|
|
@@ -35,7 +35,10 @@ import { runnerPayload,runnerPayloadV3,readRunnerHistory,attemptBaseline,boundRu
|
|
|
35
35
|
DEVELOP_REDO_CODE,developAnswerMissingEffect,developRedoCause,developRedoRequiredReason,developRedoReason,
|
|
36
36
|
DISPATCH_RETRY_CODE,developDispatchFailedEffect,developDispatchBasis,developDispatchReason,answerGapLimit,
|
|
37
37
|
pendingDevelopStart,redoDevelopStart,workerGoneBinding,EFFECT_INTERRUPT_LIMIT_CODE,effectInterruptLimitReason,developRedoSource,COMMIT_INTERRUPTED_CODE,COMMIT_INTERRUPTED_REASON,
|
|
38
|
-
DOCUMENTATION_SYNC_CODES,documentationSyncSource,documentationSyncRetryCode,documentationSyncStopReason
|
|
38
|
+
DOCUMENTATION_SYNC_CODES,documentationSyncSource,documentationSyncRetryCode,documentationSyncStopReason,
|
|
39
|
+
REVIEW_CONTINUATION_REJECTED,reviewContinuationBinding,applyReviewContinuation } from './durable-runner-state.mjs';
|
|
40
|
+
import {continuationPaths,continuationMarkerBytes,continuationUsedElsewhere,writeContinuationMarker,continuationDeliveryProblem,
|
|
41
|
+
prepareContinuationCorrection,publishContinuationReview} from './review-continuation.mjs';
|
|
39
42
|
import {splitDocumentationState} from './host-documentation.mjs';
|
|
40
43
|
import {readControlPolicy} from './control-policy.mjs';
|
|
41
44
|
import {encodeRequirementEvidence} from './requirement-evidence.mjs';
|
|
@@ -44,7 +47,7 @@ import {scopeRevisionBinding,revisedScope,applyScopeRevision} from './scope-revi
|
|
|
44
47
|
import {readProcessStartTime,inspectWorkerGroup} from './worker-process-identity.mjs';
|
|
45
48
|
import {recoverRunnerCommitImage} from './task-commit.mjs';
|
|
46
49
|
import {commitRunnerFixture} from './task-commit.mjs';
|
|
47
|
-
import {inspectProviderReview,hasProviderReviewResult,inspectProviderReviewFailure} from './provider-review-observation.mjs';
|
|
50
|
+
import {inspectProviderReview,inspectProviderReviewLive,hasProviderReviewResult,inspectProviderReviewFailure} from './provider-review-observation.mjs';
|
|
48
51
|
import {attachCmAiTaskLearningApplicationEvidence,attachCmAiTaskLearningEvidence,
|
|
49
52
|
readCmAiTaskLearningApplication} from './cm-ai-context-refresh.mjs';
|
|
50
53
|
import {readCmAiProjectLearningWriteback,writeCmAiProjectLearning} from './cm-ai-learning-writer.mjs';
|
|
@@ -149,6 +152,13 @@ const safeReason=error=>{
|
|
|
149
152
|
&&descriptor.value.length<=8192&&!/[\r\n\0]/.test(descriptor.value)?descriptor.value:null;
|
|
150
153
|
};
|
|
151
154
|
|
|
155
|
+
// Checks that ran against the very candidate the reviewer approved are reused
|
|
156
|
+
// at completion while the live tree still rebuilds that package byte for byte.
|
|
157
|
+
export const COMPLETION_CHECK_REUSE='reviewed-unchanged-v1';
|
|
158
|
+
// N6 counts five_tasks_without_qa within the task's own feature, and a periodic
|
|
159
|
+
// QA (that trigger alone) defers browser cases to feature completion.
|
|
160
|
+
export const QA_CADENCE='feature-v1';
|
|
161
|
+
const CHECKS_REWROTE_FILES='[cm] checks rewrote existing files, completion reruns them:';
|
|
152
162
|
export function createTaskRunner(options) {
|
|
153
163
|
const taskMode=options && Object.hasOwn(options,'taskCompletion');
|
|
154
164
|
const requestedVersion=taskMode&&options?.persistence?.version;
|
|
@@ -163,11 +173,16 @@ export function createTaskRunner(options) {
|
|
|
163
173
|
if(options && Object.hasOwn(options,'verificationGate'))optionKeys.push('verificationGate');
|
|
164
174
|
if(options && Object.hasOwn(options,'providerDevelopment'))optionKeys.push('providerDevelopment');
|
|
165
175
|
if(options && Object.hasOwn(options,'protectedDevelopment'))optionKeys.push('protectedDevelopment');
|
|
176
|
+
if(options && Object.hasOwn(options,'diskEdits'))optionKeys.push('diskEdits');
|
|
166
177
|
if(options && Object.hasOwn(options,'knowledgeCloseout'))optionKeys.push('knowledgeCloseout');
|
|
167
178
|
if(options && Object.hasOwn(options,'executionPolicy'))optionKeys.push('executionPolicy');
|
|
168
179
|
if(options && Object.hasOwn(options,'externalModels'))optionKeys.push('externalModels');
|
|
169
180
|
if(options && Object.hasOwn(options,'controlPolicy'))optionKeys.push('controlPolicy');
|
|
170
181
|
if(options && Object.hasOwn(options,'parallelSelection'))optionKeys.push('parallelSelection');
|
|
182
|
+
if(options && Object.hasOwn(options,'batchCompletionGate'))optionKeys.push('batchCompletionGate');
|
|
183
|
+
if(options && Object.hasOwn(options,'onChecksReused'))optionKeys.push('onChecksReused');
|
|
184
|
+
if(options && Object.hasOwn(options,'completionCheckReuse'))optionKeys.push('completionCheckReuse');
|
|
185
|
+
if(options && Object.hasOwn(options,'qaCadence'))optionKeys.push('qaCadence');
|
|
171
186
|
if(invocationMode)optionKeys.push('reviewInvocation');
|
|
172
187
|
shape(options,optionKeys);
|
|
173
188
|
need(options.providerDevelopment===undefined||typeof options.providerDevelopment==='boolean','invalid_input');
|
|
@@ -175,6 +190,20 @@ export function createTaskRunner(options) {
|
|
|
175
190
|
// development applies proposals in a sandbox, so a stuck develop there may be a
|
|
176
191
|
// partial write and gets no develop_redo exit (durable-runner-state.mjs).
|
|
177
192
|
need(options.protectedDevelopment===undefined||typeof options.protectedDevelopment==='boolean','invalid_input');
|
|
193
|
+
// Transient launch option for native disk editing in non-protected conversation
|
|
194
|
+
// runs: the session edits the code root directly after freezing the create baseline,
|
|
195
|
+
// and post-develop createReviewPackage still verifies scope and snapshot changes.
|
|
196
|
+
need(options.diskEdits===undefined||typeof options.diskEdits==='boolean','invalid_input');
|
|
197
|
+
const diskEdits=options.diskEdits===true;
|
|
198
|
+
need(!diskEdits||(!options.providerDevelopment&&!options.protectedDevelopment),'invalid_input');
|
|
199
|
+
// Transient diagnostic hook, never journaled: told when completion reuses the
|
|
200
|
+
// reviewed checks. It cannot change the verdict and its failure is ignored.
|
|
201
|
+
need(options.onChecksReused===undefined||typeof options.onChecksReused==='function','invalid_input');
|
|
202
|
+
// Transient creation choice, never journaled itself: false creates a run whose
|
|
203
|
+
// completion always runs fresh checks (the frozen setting is then absent).
|
|
204
|
+
need(options.completionCheckReuse===undefined||typeof options.completionCheckReuse==='boolean','invalid_input');
|
|
205
|
+
// Same kind of creation choice: false creates a run with the historical QA cadence.
|
|
206
|
+
need(options.qaCadence===undefined||typeof options.qaCadence==='boolean','invalid_input');
|
|
178
207
|
const {check,commit}=options;need(typeof check==='function' && (taskMode||typeof commit==='function'));
|
|
179
208
|
// Opt-in gate between the task's own checks and the independent review. It may
|
|
180
209
|
// only block: passing it grants nothing and never substitutes for that review.
|
|
@@ -183,6 +212,11 @@ export function createTaskRunner(options) {
|
|
|
183
212
|
let requirementEvidence=null,hostReplayEvidence=null,acceptanceEvidence=null;
|
|
184
213
|
need(verificationGate===null||typeof verificationGate==='function');
|
|
185
214
|
if(taskMode)need(Object.hasOwn(options,'persistence'),'runner_completion');
|
|
215
|
+
const batchCompletionGate=options.batchCompletionGate;
|
|
216
|
+
need(batchCompletionGate===undefined||taskMode&&typeof batchCompletionGate==='function','invalid_input');
|
|
217
|
+
const requireBatchMerge=()=>{
|
|
218
|
+
if(batchCompletionGate)need(batchCompletionGate({...config.identity,attempt},reviewPackage?.packageDigest)===true,'batch_merge_not_verified');
|
|
219
|
+
};
|
|
186
220
|
const config=json({root:options.root,identity:options.identity,scope:options.scope,requirements:options.requirements,
|
|
187
221
|
...(Object.hasOwn(options,'codeProjectPaths')?{codeProjectPaths:validateCodeProjectPaths(options.codeProjectPaths)}:{}),
|
|
188
222
|
excludedContexts:options.excludedContexts,timeoutMs:Object.hasOwn(options,'timeoutMs')?options.timeoutMs:1000});
|
|
@@ -236,7 +270,16 @@ export function createTaskRunner(options) {
|
|
|
236
270
|
...(Object.hasOwn(options,'controlPolicy')?{controlPolicy:readControlPolicy(options.controlPolicy)}:{}),
|
|
237
271
|
...(Object.hasOwn(options,'parallelSelection')&&
|
|
238
272
|
(options.persistence?.mode==='create'||options.persistence?.store?.snapshot().records[0]?.payload.config.parallelSelection)
|
|
239
|
-
?{parallelSelection:json(options.parallelSelection)}:{})
|
|
273
|
+
?{parallelSelection:json(options.parallelSelection)}:{}),
|
|
274
|
+
// Frozen at creation, never added on resume: only NEW native task runs may
|
|
275
|
+
// complete on their reviewed checks (see the complete branch below).
|
|
276
|
+
...(taskMode&&invocationMode&&(options.persistence?.mode==='create'&&options.completionCheckReuse!==false
|
|
277
|
+
||options.persistence?.mode==='resume'&&options.persistence?.store?.snapshot().records[0]?.payload.config.completionCheckReuse)
|
|
278
|
+
?{completionCheckReuse:COMPLETION_CHECK_REUSE}:{}),
|
|
279
|
+
// Frozen at creation as well: older runs keep the cross-feature QA count.
|
|
280
|
+
...(taskMode&&invocationMode&&(options.persistence?.mode==='create'&&options.qaCadence!==false
|
|
281
|
+
||options.persistence?.mode==='resume'&&options.persistence?.store?.snapshot().records[0]?.payload.config.qaCadence)
|
|
282
|
+
?{qaCadence:QA_CADENCE}:{})});
|
|
240
283
|
const taskLearning=metadata.taskLearning??null;
|
|
241
284
|
if(taskLearning!==null){need(taskMode,'runner_learning');
|
|
242
285
|
shape(taskLearning,['feature',...(Object.hasOwn(taskLearning,'hostHandoff')?['hostHandoff']:[])]);
|
|
@@ -302,6 +345,8 @@ export function createTaskRunner(options) {
|
|
|
302
345
|
let learningResult=null;
|
|
303
346
|
// Journaled supersession context: shown, never counted as a review verdict.
|
|
304
347
|
let carriedReview=restored?.supersession?.carriedReview??null;
|
|
348
|
+
// Journaled third controlled review authorization (null when never granted).
|
|
349
|
+
let continuation=restored?.reviewContinuation??null;
|
|
305
350
|
const acceptedFixes=structuredClone(restored?.acceptedFixes??[]);
|
|
306
351
|
let acceptedIntegration=restored?.acceptedIntegration??null;
|
|
307
352
|
let qaAttachment=restored?.qaAttachment??null;
|
|
@@ -312,11 +357,19 @@ export function createTaskRunner(options) {
|
|
|
312
357
|
const {baselineDigest,...data}={...fresh,specification:boundSpecificationMaterial(original,fresh.specification)};
|
|
313
358
|
return {...data,baselineDigest:digest(data)};
|
|
314
359
|
};
|
|
360
|
+
const continuationFiles=()=>continuationPaths(completion.reviewsDir,completion.owner.feature,config.identity.taskId);
|
|
361
|
+
// After a review continuation every attempt-2 delivery is the correction one.
|
|
362
|
+
const deliveryHandoff=()=>continuation!==null&&attempt===2?continuationFiles().handoff:completion.handoffs[attempt-1];
|
|
315
363
|
const handoffBinding=(pkg=reviewPackage)=>pkg&&Object.hasOwn(pkg,'handoff')
|
|
316
|
-
?{handoffPath:
|
|
364
|
+
?{handoffPath:continuation!==null&&pkg.identity.attempt===2&&pkg.handoff.path===path.basename(continuationFiles().handoff)
|
|
365
|
+
?continuationFiles().handoff:completion.handoffs[pkg.identity.attempt-1]}:{};
|
|
317
366
|
function publishRegisteredReview(inspectOnly=false){
|
|
318
367
|
if(!invocationMode||taskLearning?.hostHandoff!==true||!receipt||!reviewPackage?.handoff)return;
|
|
319
368
|
need(inspectOnly||!busy,'busy');
|
|
369
|
+
// The authorization cleared the r2 receipt: any receipt now is the third review's.
|
|
370
|
+
if(continuation!==null){publishContinuationReview({reviewsDir:completion.reviewsDir,feature:completion.owner.feature,
|
|
371
|
+
projectRoot:config.root,inspectOnly,allowSymlinks:base.version===SYMLINK_BASELINE_VERSION,reviewPackage,receipt,registered:registered.get(receipt.id),
|
|
372
|
+
at:reviewInvocation.registration.registeredAt});return;}
|
|
320
373
|
publishHostReview({reviewsDir:completion.reviewsDir,feature:completion.owner.feature,inspectOnly,
|
|
321
374
|
...handoffBinding(),reviewPackage,receipt,registered:registered.get(receipt.id),
|
|
322
375
|
at:reviewInvocation.registration.registeredAt});
|
|
@@ -649,7 +702,8 @@ export function createTaskRunner(options) {
|
|
|
649
702
|
:'缺少原调用的可信终态或本地清理证据。保留本 run、attempt、journal 和快照;按 invocationId / providerThreadId 向原宿主或 provider 核对结果及终止状态,并确认本地后代已退出。当前适配器没有远端状态查询入口,人工说明、PID 消失或重启均不能解锁;不要删 journal、换 runId 或重派。'});
|
|
650
703
|
}
|
|
651
704
|
if(!busy&&!poisoned)try{publishRegisteredReview(true);}
|
|
652
|
-
catch{return freeze({...current,code:'review_publication_required'
|
|
705
|
+
catch{return freeze({...current,code:'review_publication_required',
|
|
706
|
+
...(current.state==='blocked'?{publicationBlockedCode:current.code}:{})});}
|
|
653
707
|
// Every next effect re-verifies the bound specification. When it no longer
|
|
654
708
|
// verifies, report that and its real exits instead of the refused action.
|
|
655
709
|
if(!busy&&!poisoned&&specificationLive(current.state,current.code)){
|
|
@@ -659,7 +713,12 @@ export function createTaskRunner(options) {
|
|
|
659
713
|
}
|
|
660
714
|
if(current.state==='blocked'&¤t.code==='spec_drift'&&!current.reason)
|
|
661
715
|
return freeze({...current,reason:HALTED_SPEC_DRIFT});
|
|
662
|
-
if(!busy&&reviewPackage&&
|
|
716
|
+
if(!busy&&reviewPackage&¤t.state==='changes_requested'&&diskEdits){
|
|
717
|
+
try{assertReviewPackageHandoff();}
|
|
718
|
+
catch(error){return freeze({...current,state:'blocked',code:'review_package_changed',reason:error.message});}
|
|
719
|
+
}
|
|
720
|
+
if(!busy&&reviewPackage&&(['awaiting_review','approved'].includes(current.state)
|
|
721
|
+
||current.state==='changes_requested'&&!diskEdits
|
|
663
722
|
||current.state==='blocked'&&['review_package_changed','completion_package_changed'].includes(current.code))){
|
|
664
723
|
try{
|
|
665
724
|
verifyReviewPackage({root:config.root,baseline:attemptBaseline(original,reviewPackage.identity.attempt),
|
|
@@ -667,9 +726,11 @@ export function createTaskRunner(options) {
|
|
|
667
726
|
if(current.state==='blocked'&¤t.code==='review_package_changed'){
|
|
668
727
|
const {reason:oldReason,...rest}=current;
|
|
669
728
|
if(priorReview?.verdict==='approved')return freeze({...rest,state:'approved',code:null});
|
|
670
|
-
if(priorReview?.verdict==='changes_requested'&&attempt===2&&reviewPackage.identity.attempt===1
|
|
729
|
+
if(priorReview?.verdict==='changes_requested'&&attempt===2&&(reviewPackage.identity.attempt===1
|
|
730
|
+
||continuation!==null&&receipts.length===2))
|
|
671
731
|
return freeze({...rest,state:'changes_requested',code:null});
|
|
672
|
-
return freeze({...rest,state:'blocked',code:
|
|
732
|
+
return freeze({...rest,state:'blocked',code:continuation!==null?REVIEW_CONTINUATION_REJECTED
|
|
733
|
+
:priorReview?.verdict==='changes_requested'?'review_limit':'review_blocked'});
|
|
673
734
|
}
|
|
674
735
|
if(current.code==='completion_package_changed')return freeze({...current,retryReady:true});
|
|
675
736
|
}catch(error){return freeze({...current,state:'blocked',
|
|
@@ -718,6 +779,38 @@ export function createTaskRunner(options) {
|
|
|
718
779
|
}
|
|
719
780
|
};
|
|
720
781
|
const halt=(next,why,detail=null)=>{state=next;code=why;reason=detail;};
|
|
782
|
+
function assertReviewPackageHandoff(pkg=reviewPackage){
|
|
783
|
+
if(!pkg||!Object.hasOwn(pkg,'handoff'))return;
|
|
784
|
+
const {handoffPath}=handoffBinding(pkg);
|
|
785
|
+
if(!handoffPath)return;
|
|
786
|
+
need(readHandoffSnapshot(handoffPath).sha256===pkg.handoff.sha256,'handoff_changed');
|
|
787
|
+
}
|
|
788
|
+
function assertDiskEditsPrecheck(){
|
|
789
|
+
const originalFiles=new Map((original.files??[]).map(file=>[file.path,file]));
|
|
790
|
+
const allowedAgents=new Map();
|
|
791
|
+
if(attempt>1&&reviewPackage?.changes){
|
|
792
|
+
for(const change of reviewPackage.changes){
|
|
793
|
+
if(!effectiveScope.includes(change.path)&&(change.path==='AGENTS.md'||change.path.endsWith('/AGENTS.md'))){
|
|
794
|
+
allowedAgents.set(change.path,change.after);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
const diffs=compareReviewInventoryToBaseline(config.root,original,{withMode:true,protectScope:true});
|
|
799
|
+
for(const row of diffs){
|
|
800
|
+
if(allowedAgents.has(row.path)){
|
|
801
|
+
const expected=allowedAgents.get(row.path);
|
|
802
|
+
const matches=expected===null?row.sha256===null:row.sha256===expected.sha256&&row.mode===expected.mode;
|
|
803
|
+
if(matches)continue;
|
|
804
|
+
}
|
|
805
|
+
need(effectiveScope.includes(row.path),'out_of_scope');
|
|
806
|
+
if(row.sha256!==null&&row.mode!==null){
|
|
807
|
+
const before=originalFiles.get(row.path)??null;
|
|
808
|
+
if(!before||before.mode!==row.mode){
|
|
809
|
+
need([0o644,0o755].includes(row.mode),'unsupported_file');
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
721
814
|
function assertReadyBaseline(){
|
|
722
815
|
compareReviewBaseline(withBoundSpecification(captureReviewBaseline({...configToBaseline(effectiveMetadata()),version:original.version,
|
|
723
816
|
...(Object.hasOwn(original,'specification')?{specification:{specsRoot:original.specificationRoot,feature:original.specification.feature}}:{})},
|
|
@@ -764,7 +857,7 @@ export function createTaskRunner(options) {
|
|
|
764
857
|
'review-invocation-abandoned':'result','review-invocation-receipt':'result','review-invocation-reconciled':'result','effect-abandoned':'result',
|
|
765
858
|
'host-joined':'result','qa-fix-accepted':'result','reviewed-integration-accepted':'result','qa-attached':'result','qa-config-revised':'result',
|
|
766
859
|
'evidence-superseded':'result','develop-retry-limit':'result','develop-worker':'result','effect-interrupted':'result','develop-timeout-retry':'result','develop-answer-retry':'result','develop-recheck':'result','complete-recheck':'result','develop-answer-redo':'result','develop-dispatch-retry':'result','review-redispatch':'result','review-dispatch-confirmed':'result','completion-retry-limit':'result','specification-rebound':'result','documentation-sync-started':'result','documentation-sync-retry':'result',
|
|
767
|
-
'completion-rework-requested':'result','development-rework-authorized':'result','scope-revised':'result','bootstrap-review-recovered':'result'}[type],
|
|
860
|
+
'completion-rework-requested':'result','development-rework-authorized':'result','review-continuation-authorized':'result','scope-revised':'result','bootstrap-review-recovered':'result'}[type],
|
|
768
861
|
payload:version===3?runnerPayloadV3(type,fields):runnerPayload(type,fields,version)};
|
|
769
862
|
const body={version:1,seq:journal.length+1,...basic,previousDigest:journal.at(-1)?.digest??null};
|
|
770
863
|
const record={...body,digest:digest(body)};boundRunnerRecord(record,body.seq);
|
|
@@ -804,7 +897,8 @@ export function createTaskRunner(options) {
|
|
|
804
897
|
}
|
|
805
898
|
function nativeCompletion(fresh){
|
|
806
899
|
const input=json({selectors:{tasksPath:completion.owner.tasksPath,feature:completion.owner.feature,
|
|
807
|
-
reviewsDir:completion.reviewsDir,handoff:
|
|
900
|
+
reviewsDir:completion.reviewsDir,handoff:deliveryHandoff(),
|
|
901
|
+
...(continuation!==null?{correction:continuationFiles().record}:{})},root:config.root,
|
|
808
902
|
identity:{...config.identity,attempt},baseline:base,reviewPackage,checks:fresh,receipt,
|
|
809
903
|
registered:registered.get(receipt?.id),execution:calls.find(c=>c.invocationId===receipt?.id)},16*1024*1024);
|
|
810
904
|
need(completeEffect?.effect.identity.attempt===attempt&&state==='committing'&&busy,'commit_phase_invalid');
|
|
@@ -925,8 +1019,8 @@ export function createTaskRunner(options) {
|
|
|
925
1019
|
return {request,response,call};
|
|
926
1020
|
} catch(error){call.terminal=state==='cancelled'?'cancelled':'unknown';throw error;}
|
|
927
1021
|
}
|
|
928
|
-
function acceptReview(request,call,rawResult,fallbackReasons=[]) {
|
|
929
|
-
const result=reviewResult(rawResult,reviewPackage);
|
|
1022
|
+
function acceptReview(request,call,rawResult,fallbackReasons=[],{strictBlocked=true}={}) {
|
|
1023
|
+
const result=reviewResult(rawResult,reviewPackage,{strictBlocked});
|
|
930
1024
|
let drift=null;
|
|
931
1025
|
try{verifyReviewPackage({root:config.root,baseline:base,checks:currentChecks,
|
|
932
1026
|
reviewPackage,expectedDigest:reviewPackage.packageDigest,...handoffBinding()});}
|
|
@@ -937,6 +1031,8 @@ export function createTaskRunner(options) {
|
|
|
937
1031
|
receipt=reviewReceipt({request,call,result,reviewPackage,developerProvider:developer.provider,fallbackReasons});
|
|
938
1032
|
registered.set(receipt.id,receipt);receipts.push(receipt);priorReview=result;
|
|
939
1033
|
if(result.verdict==='approved'){state='approved';code=null;}
|
|
1034
|
+
else if(continuation!==null)halt('blocked',REVIEW_CONTINUATION_REJECTED,verdictReason(
|
|
1035
|
+
'review_continuation_rejected: 第三次受控审查仍未通过,本任务的续审额度已用完',result.summary));
|
|
940
1036
|
else if(result.verdict==='changes_requested' && attempt===1) {
|
|
941
1037
|
state='changes_requested';code=null;attempt=2;
|
|
942
1038
|
const {baselineDigest:old,...data}=original,newData={...data,identity:{...config.identity,attempt}};
|
|
@@ -1111,7 +1207,7 @@ export function createTaskRunner(options) {
|
|
|
1111
1207
|
providerResult=json({status:'succeeded',value:bounded});
|
|
1112
1208
|
}
|
|
1113
1209
|
let recorded,inspection;
|
|
1114
|
-
try{recorded=observation(providerResult);inspection=
|
|
1210
|
+
try{recorded=observation(providerResult);inspection=inspectProviderReviewLive(JSON.stringify(recorded),JSON.stringify(expectation));}
|
|
1115
1211
|
catch{
|
|
1116
1212
|
const failure=recorded===undefined?null:inspectProviderReviewFailure(JSON.stringify(recorded),JSON.stringify(expectation));
|
|
1117
1213
|
if(failure){reviewerFailed(recorded,failure);return;}
|
|
@@ -1142,13 +1238,49 @@ export function createTaskRunner(options) {
|
|
|
1142
1238
|
if(cancelReject)controller.signal.removeEventListener('abort',cancelReject);}
|
|
1143
1239
|
}
|
|
1144
1240
|
async function collectChecks(){
|
|
1145
|
-
const
|
|
1241
|
+
const reuse=metadata.completionCheckReuse===COMPLETION_CHECK_REUSE;
|
|
1242
|
+
// Reuse runs compare the files the review package itself selects (scope paths
|
|
1243
|
+
// matched by ignore rules included), by full identity: type, mode, content or
|
|
1244
|
+
// link target. Deletions and permission-only changes therefore count too.
|
|
1245
|
+
// A package that cannot be built yet (an oversized delivery) is reported by the
|
|
1246
|
+
// package step after the checks as before; here it only means "not provable",
|
|
1247
|
+
// so the checks still run and completion reruns them.
|
|
1248
|
+
const identities=()=>{try{return new Map(reviewPackageFileIdentities({root:config.root,baseline:base})
|
|
1249
|
+
.map(file=>[file.path,JSON.stringify(file)]));}catch{return null;}};
|
|
1250
|
+
const before=new Set(captureReviewInventory(config.root,base).map(file=>file.path));
|
|
1251
|
+
const reviewedBefore=reuse?identities():null;
|
|
1146
1252
|
const results=json(await bounded(check,json({identity:{...config.identity,attempt},
|
|
1147
1253
|
...(parsedHistory?.scopeRevisions?{scope:effectiveScope}: {})})));
|
|
1148
1254
|
validChecks(results);
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1255
|
+
checkNewPaths=new Set(captureReviewInventory(config.root,base).filter(file=>!before.has(file.path)).map(file=>file.path));
|
|
1256
|
+
if(!reuse)return results;
|
|
1257
|
+
// Files the checks themselves rewrote, removed or re-permissioned (generators,
|
|
1258
|
+
// --fix, cleanup): the results then describe other files than the package will
|
|
1259
|
+
// hold. The note travels in the reviewed evidence, so completion never reuses
|
|
1260
|
+
// such results. Runs without reuse keep their evidence byte for byte.
|
|
1261
|
+
const reviewedAfter=identities();
|
|
1262
|
+
const rewritten=reviewedBefore===null||reviewedAfter===null?['(package files unavailable)']
|
|
1263
|
+
:[...reviewedBefore.keys()].filter(file=>reviewedAfter.get(file)!==reviewedBefore.get(file));
|
|
1264
|
+
if(!rewritten.length)return results;
|
|
1265
|
+
const shown=rewritten.slice(0,5).map(file=>file.length>100?`${file.slice(0,100)}…`:file);
|
|
1266
|
+
const notes=[`\n${CHECKS_REWROTE_FILES} ${rewritten.length}: ${shown.join(', ')}${rewritten.length>5?' ...':''}`,
|
|
1267
|
+
`\n${CHECKS_REWROTE_FILES} ${rewritten.length}`];
|
|
1268
|
+
// Stay inside the 64 KiB check-result bound: trim the longest evidence tail,
|
|
1269
|
+
// always keeping one non-blank character, and fall back to the short note.
|
|
1270
|
+
const limit=64*1024;let marked=null;
|
|
1271
|
+
for(const note of notes){
|
|
1272
|
+
marked=json(results).map((item,index)=>index===0?{...item,evidence:item.evidence+note}:{...item});
|
|
1273
|
+
const body=index=>index===0?marked[0].evidence.slice(0,-note.length):marked[index].evidence;
|
|
1274
|
+
for(let over=Buffer.byteLength(JSON.stringify(marked))-limit;over>0;over=Buffer.byteLength(JSON.stringify(marked))-limit){
|
|
1275
|
+
const index=marked.map((_,i)=>i).reduce((a,b)=>body(b).length>body(a).length?b:a,0);
|
|
1276
|
+
const text=body(index);if(text.length<=1)break;
|
|
1277
|
+
let kept=text.slice(0,Math.max(1,text.length-over));
|
|
1278
|
+
if(!kept.trim())kept=text.trimStart().slice(0,1);
|
|
1279
|
+
marked[index].evidence=index===0?kept+note:kept;
|
|
1280
|
+
}
|
|
1281
|
+
if(Buffer.byteLength(JSON.stringify(marked))<=limit)break;
|
|
1282
|
+
}
|
|
1283
|
+
return json(marked);
|
|
1152
1284
|
}
|
|
1153
1285
|
const failedChecks=checks=>checks.filter(item=>item.outcome!=='passed'||item.kind!=='visual'&&item.exitCode!==0);
|
|
1154
1286
|
const checkFailureReason=(checks,code='checks_not_passed')=>{
|
|
@@ -1231,7 +1363,7 @@ export function createTaskRunner(options) {
|
|
|
1231
1363
|
// last review round; the same attempt may deliver again under a new effect id.
|
|
1232
1364
|
function unchangedSinceRejection(){
|
|
1233
1365
|
if(attempt!==2||!['changes_requested','approved'].includes(priorReview?.verdict))return null;
|
|
1234
|
-
const rejected=receipts.findLast(item=>item.identity.attempt===1&&['changes_requested','approved'].includes(item.result.verdict));
|
|
1366
|
+
const rejected=receipts.findLast(item=>item.identity.attempt===(continuation!==null?2:1)&&['changes_requested','approved'].includes(item.result.verdict));
|
|
1235
1367
|
if(!rejected)return null;
|
|
1236
1368
|
const candidate=createReviewPackage({root:config.root,baseline:base,checks:currentChecks});
|
|
1237
1369
|
return candidate.artifactDigest===rejected.artifactDigest
|
|
@@ -1280,7 +1412,7 @@ export function createTaskRunner(options) {
|
|
|
1280
1412
|
try{unchanged=unchangedSinceRejection();}catch(error){emptyDelivery(error);return false;}
|
|
1281
1413
|
if(unchanged){halt('blocked','develop_unchanged_after_review',unchanged);return false;}
|
|
1282
1414
|
try{createHostHandoff({root:config.root,baseline:base,checks:currentChecks,
|
|
1283
|
-
handoffPath:
|
|
1415
|
+
handoffPath:deliveryHandoff(),evidence:[...journal.filter(row=>row.payload.type==='completion-rework-requested')
|
|
1284
1416
|
.map(row=>'cm-completion-rework-v1: '+JSON.stringify({identity:{...config.identity,attempt:2},recordDigest:row.digest})),
|
|
1285
1417
|
...(requirementEvidence===null?[]:[requirementEvidence]),...(hostReplayEvidence===null?[]:[hostReplayEvidence]),
|
|
1286
1418
|
...(acceptanceEvidence===null?[]:[acceptanceEvidence])]});}
|
|
@@ -1292,7 +1424,7 @@ export function createTaskRunner(options) {
|
|
|
1292
1424
|
// (requirement evidence makes that reachable) is the same retryable package
|
|
1293
1425
|
// block as an oversized initial handoff, never an unknown effect.
|
|
1294
1426
|
function appendLearningHandoff(v,{application,retrospective,writeback}){
|
|
1295
|
-
try{writeCmAiTaskLearningHandoff({handoffPath:
|
|
1427
|
+
try{writeCmAiTaskLearningHandoff({handoffPath:deliveryHandoff(),feature:taskLearning.feature,
|
|
1296
1428
|
identity:{...config.identity,attempt},learningInput:v.learningInput,application,retrospective,writeback});}
|
|
1297
1429
|
catch(error){emptyDelivery(error);return false;}
|
|
1298
1430
|
return true;
|
|
@@ -1301,8 +1433,18 @@ export function createTaskRunner(options) {
|
|
|
1301
1433
|
active();
|
|
1302
1434
|
let nextPackage;
|
|
1303
1435
|
try{nextPackage=createReviewPackage({root:config.root,baseline:base,checks:currentChecks,
|
|
1304
|
-
...(taskLearning?.hostHandoff===true?{handoffPath:
|
|
1436
|
+
...(taskLearning?.hostHandoff===true?{handoffPath:deliveryHandoff()}:{})});}
|
|
1305
1437
|
catch(error){emptyDelivery(error);return;}
|
|
1438
|
+
// The controlled correction keeps the reviewed file set and needs a real
|
|
1439
|
+
// revision; refuse before any record exists so the same attempt may redo.
|
|
1440
|
+
if(continuation!==null&&taskLearning?.hostHandoff===true){
|
|
1441
|
+
const problem=continuationDeliveryProblem({reviewedHandoff:completion.handoffs[1],correctionHandoff:deliveryHandoff(),
|
|
1442
|
+
task:config.identity.taskId});
|
|
1443
|
+
if(problem?.code==='develop_unchanged_after_review'){halt('blocked',problem.code,
|
|
1444
|
+
'develop_unchanged_after_review: 第三次受控审查的补正与第 2 轮已审代码相同;按第 2 轮 findings 修改后重新交付');return;}
|
|
1445
|
+
if(problem){halt('blocked',problem.code,boundedReason('develop_continuation_scope_mismatch: 第三次受控审查只允许修改第 2 轮已审的同一批文件:',
|
|
1446
|
+
problem.paths,';还原多出的文件或补回缺少的改动后重新交付'));return;}
|
|
1447
|
+
}
|
|
1306
1448
|
if(taskLearning!==null)validateTaskLearningReviewPackage(nextPackage,learningResult.writeback,v.learningInput,
|
|
1307
1449
|
learningResult.bootstrap??null,metadata.bootstrap??null);
|
|
1308
1450
|
reviewPackage=nextPackage;
|
|
@@ -1329,6 +1471,44 @@ export function createTaskRunner(options) {
|
|
|
1329
1471
|
if(raw==='out_of_scope')return {code:'documentation_sync_out_of_scope',detail:safeReason(error)};
|
|
1330
1472
|
return {code:'documentation_sync_answer_missing',detail:typeof raw==='string'&&/^[a-z_]{1,64}$/.test(raw)?raw:'execution_error'};
|
|
1331
1473
|
}
|
|
1474
|
+
function verifyCompletion(checks){
|
|
1475
|
+
try {
|
|
1476
|
+
verifyCompletionReviewPackage({root:config.root,baseline:base,checks,reviewPackage,expectedDigest:reviewPackage.packageDigest,...handoffBinding()});
|
|
1477
|
+
} catch(error){
|
|
1478
|
+
const duringCheck=error.code==='out_of_scope'&&Array.isArray(error.violations)
|
|
1479
|
+
&&error.violations.length>0&&error.violations.every(item=>item.newFile);
|
|
1480
|
+
const blockedCode=duringCheck?'completion_package_changed':failureCode(error);
|
|
1481
|
+
return {code:blockedCode,reason:blockedCode==='completion_checks_changed'&&failedChecks(checks).length
|
|
1482
|
+
?checkFailureReason(checks):safeReason(error)};
|
|
1483
|
+
}
|
|
1484
|
+
if(taskLearning!==null)try {
|
|
1485
|
+
const learningInput=currentLearningInput();
|
|
1486
|
+
verifyCmAiTaskLearningHandoff({handoffPath:deliveryHandoff(),feature:taskLearning.feature,
|
|
1487
|
+
identity:{...config.identity,attempt},learningInput,
|
|
1488
|
+
...(Object.hasOwn(learningResult,'application')?{application:learningResult.application}:{}),
|
|
1489
|
+
retrospective:learningResult.retrospective,
|
|
1490
|
+
writeback:learningResult.writeback});
|
|
1491
|
+
} catch {return {code:'package_mismatch',reason:'package_mismatch: 完成前核对 Learning handoff 与已审交付不一致(handoff 文件或 Learning 记录被改动);保留现场核对 .reviews 下的 handoff,不能直接重试。'};}
|
|
1492
|
+
try {
|
|
1493
|
+
checkCompletion({receipt,registered:registered.get(receipt?.id),execution:calls.find(c=>c.invocationId===receipt?.id),
|
|
1494
|
+
reviewPackage,identity:{...config.identity,attempt}});
|
|
1495
|
+
} catch(error){return {code:failureCode(error)};}
|
|
1496
|
+
return null;
|
|
1497
|
+
}
|
|
1498
|
+
async function preflightBatchCompletion(identity,packageDigest){
|
|
1499
|
+
need(batchCompletionGate&&!busy&&!poisoned&&state==='approved'&&code===null,'completion_not_ready');
|
|
1500
|
+
same(identity,{...config.identity,attempt},'identity_mismatch');
|
|
1501
|
+
need(reviewPackage?.packageDigest===packageDigest,'stale_completion');
|
|
1502
|
+
busy=true;
|
|
1503
|
+
try{
|
|
1504
|
+
active();
|
|
1505
|
+
// Before sealing, verify the reviewed delivery using its frozen checks.
|
|
1506
|
+
// The native completion effect collects fresh checks after the merge.
|
|
1507
|
+
const block=verifyCompletion(reviewPackage.checks);
|
|
1508
|
+
return block?freeze({outcome:'blocked',...block}):freeze({outcome:'passed',changes:reviewPackage.changes});
|
|
1509
|
+
}catch(error){return freeze({outcome:'blocked',code:failureCode(error),reason:safeReason(error)});}
|
|
1510
|
+
finally{busy=false;}
|
|
1511
|
+
}
|
|
1332
1512
|
async function perform(v) {
|
|
1333
1513
|
if(v.kind==='develop') {
|
|
1334
1514
|
need(stageAllowed('develop',state,code,priorReview?.verdict),'stage_mismatch');
|
|
@@ -1427,6 +1607,7 @@ export function createTaskRunner(options) {
|
|
|
1427
1607
|
if(v.kind==='review') {
|
|
1428
1608
|
state='reviewing';verifyReviewPackage({root:config.root,baseline:base,checks:currentChecks,
|
|
1429
1609
|
reviewPackage,expectedDigest:reviewPackage.packageDigest,...handoffBinding()});
|
|
1610
|
+
|
|
1430
1611
|
if(invocationMode){await invokeObserved(reviewers[0],reviewers[0].contexts[attempt-1],{reviewPackage,priorReview,
|
|
1431
1612
|
...supersededReviewPayload(carriedReview,attempt)},v.id);return;}
|
|
1432
1613
|
const fallbackReasons=[];
|
|
@@ -1445,29 +1626,33 @@ export function createTaskRunner(options) {
|
|
|
1445
1626
|
halt('pending_review','review_channels_unavailable');return;
|
|
1446
1627
|
}
|
|
1447
1628
|
if(v.kind==='complete') {
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1629
|
+
// The reviewed package already holds passing command checks of this exact
|
|
1630
|
+
// candidate. When the live tree still rebuilds that package byte for byte,
|
|
1631
|
+
// completion reuses them instead of running the same commands again (5
|
|
1632
|
+
// projects: 2.54 check batches per task, 2026-11-28). Visual checks (device,
|
|
1633
|
+
// browser) always run fresh: a second walkthrough has caught real defects.
|
|
1634
|
+
// A run already inside a task commit keeps the original fresh path so its
|
|
1635
|
+
// recorded commit input stays reproducible on recovery. Only runs created
|
|
1636
|
+
// with completionCheckReuse reuse (older runs and the legacy commit contract
|
|
1637
|
+
// keep their guaranteed final check), and only on the first completion
|
|
1638
|
+
// attempt: after any earlier complete result the checks run fresh. A parallel
|
|
1639
|
+
// batch member completing after its merge (batchCompletionGate) always runs
|
|
1640
|
+
// fresh: those are the post-merge checks the merge proof stands on.
|
|
1641
|
+
let fresh=null;
|
|
1642
|
+
if(metadata.completionCheckReuse===COMPLETION_CHECK_REUSE&&taskCommit===null&&!batchCompletionGate
|
|
1643
|
+
&&![...cache.values()].some(entry=>entry.effect.kind==='complete')
|
|
1644
|
+
&&!reviewPackage.checks.some(item=>item.evidence.includes(CHECKS_REWROTE_FILES))&&reviewPackage.checks.every(item=>item.kind!=='visual'&&item.outcome==='passed'))try {
|
|
1645
|
+
verifyCompletionReviewPackage({root:config.root,baseline:base,checks:reviewPackage.checks,reviewPackage,expectedDigest:reviewPackage.packageDigest,...handoffBinding()});
|
|
1646
|
+
fresh=reviewPackage.checks;
|
|
1647
|
+
} catch {fresh=null;}
|
|
1648
|
+
if(fresh!==null){
|
|
1649
|
+
if(options.onChecksReused)try{options.onChecksReused({identity:{...config.identity,attempt},checkCount:fresh.length});}
|
|
1650
|
+
catch{/* diagnostics never change completion */}
|
|
1651
|
+
// Cancellation after the checks propagates as before, never as a blocked check.
|
|
1652
|
+
} else {fresh=await collectChecks();active();}
|
|
1653
|
+
const block=verifyCompletion(fresh);
|
|
1654
|
+
if(block){halt('blocked',block.code,block.reason);return;}
|
|
1655
|
+
active();requireBatchMerge();state='committing';
|
|
1471
1656
|
if(taskMode){nativeCompletion(fresh);state='fixture_completed';return;}
|
|
1472
1657
|
const returned=commit(json({identity:{...config.identity,attempt},packageDigest:reviewPackage.packageDigest,receiptDigest:receipt.receiptDigest}));
|
|
1473
1658
|
if(types.isPromise(returned)) {
|
|
@@ -1480,7 +1665,7 @@ export function createTaskRunner(options) {
|
|
|
1480
1665
|
// No delivery can still be reviewed: journal the terminal limit instead of an
|
|
1481
1666
|
// intent, so no developer call runs (see developBudgetExhausted).
|
|
1482
1667
|
const retryLimitDue=()=>invocationMode&&store&&!poisoned
|
|
1483
|
-
&&developBudgetExhausted({state,code,attempt,priorReview,calls,cache:[...cache.values()]},parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework);
|
|
1668
|
+
&&developBudgetExhausted({state,code,attempt,priorReview,calls,cache:[...cache.values()]},parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework,continuation);
|
|
1484
1669
|
function recordRetryLimit(){
|
|
1485
1670
|
const used=developBudget({calls,cache:[...cache.values()]},parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework);
|
|
1486
1671
|
persist('develop-retry-limit',{fromState:state,fromCode:code,countedCalls:used.calls,countedEffects:used.effects});
|
|
@@ -1506,6 +1691,7 @@ export function createTaskRunner(options) {
|
|
|
1506
1691
|
if(Object.hasOwn(v,'learningInput')){need(v.kind==='develop'&&taskLearning!==null,'runner_learning');
|
|
1507
1692
|
validTaskLearningInput(v.learningInput,v.identity,taskLearning.feature);}
|
|
1508
1693
|
for(const k of ['repositoryId','runId','taskId'])need(v.identity[k]===config.identity[k],'identity_mismatch');
|
|
1694
|
+
if(v.kind==='complete')requireBatchMerge();
|
|
1509
1695
|
// Publication is retryable local projection, never a provider redispatch.
|
|
1510
1696
|
// Recovered/cached reviews can repair a missing file from the same receipt.
|
|
1511
1697
|
try{publishRegisteredReview();}catch(error){
|
|
@@ -1547,7 +1733,7 @@ export function createTaskRunner(options) {
|
|
|
1547
1733
|
}
|
|
1548
1734
|
answerRetry=v.kind==='develop'&&state==='blocked'&&code==='failed'&&answerRetryable();
|
|
1549
1735
|
need(timeoutBasis!==null||answerRetry||recheck!==null||completeSource!==null||dispatchBasis!==null
|
|
1550
|
-
||stageAllowed(v.kind,state,code,priorReview?.verdict),'stage_mismatch');need(effectSlotFree(v.kind,[...cache.values()],calls,parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework,v.id,recheck!==null?{state:'blocked',code:recheck}:{state,code}),'limit_exceeded');
|
|
1736
|
+
||stageAllowed(v.kind,state,code,priorReview?.verdict),'stage_mismatch');need(effectSlotFree(v.kind,[...cache.values()],calls,parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework,v.id,recheck!==null?{state:'blocked',code:recheck}:{state,code},continuation),'limit_exceeded');
|
|
1551
1737
|
if(v.kind==='develop'&&parsedHistory?.developmentRework&&!parsedHistory.developmentRework.developerConsumed)need(digest(captureReviewInventory(config.root,original,{withMode:true}))===parsedHistory.developmentRework.sourceDigest,'development_rework_source_changed');
|
|
1552
1738
|
if(Object.hasOwn(original,'specification'))verifySpecificationMaterial(original);
|
|
1553
1739
|
if(v.kind==='develop'&&bootstrap!==null)bootstrap.assertWriteAuthorized();
|
|
@@ -1589,7 +1775,12 @@ export function createTaskRunner(options) {
|
|
|
1589
1775
|
if(v.kind==='complete'&&completionLimitDue()){try{return Promise.resolve(recordCompletionLimit());}catch{return Promise.resolve(poison());}}
|
|
1590
1776
|
if(store) {
|
|
1591
1777
|
try {
|
|
1592
|
-
|
|
1778
|
+
const allowPreEditedDisk=diskEdits&&v.kind==='develop'&&(state==='ready'||state==='changes_requested'
|
|
1779
|
+
||(state==='blocked'&&!['review_package_changed','develop_call_timeout'].includes(code)&&stageAllowed('develop',state,code,priorReview?.verdict)));
|
|
1780
|
+
if(allowPreEditedDisk){
|
|
1781
|
+
if(reviewPackage!==null)assertReviewPackageHandoff();
|
|
1782
|
+
assertDiskEditsPrecheck();
|
|
1783
|
+
}else if(state==='ready')assertReadyBaseline();
|
|
1593
1784
|
// A rejected first delivery has no review package yet. Every later
|
|
1594
1785
|
// developer effect must recheck the reviewed tree before dispatch,
|
|
1595
1786
|
// except one that redoes a delivery this attempt already made: that
|
|
@@ -1601,6 +1792,16 @@ export function createTaskRunner(options) {
|
|
|
1601
1792
|
checks:reviewPackage.checks,reviewPackage,expectedDigest:reviewPackage.packageDigest,...handoffBinding()});
|
|
1602
1793
|
} catch(error){return Promise.resolve(freeze({outcome:'rejected',code:failureCode(error),
|
|
1603
1794
|
...(safeReason(error)?{reason:safeReason(error)}:{})}));}
|
|
1795
|
+
// Third controlled review: the one correction record binds this exact
|
|
1796
|
+
// handoff before any review intent, so a gate refusal journals nothing.
|
|
1797
|
+
if(v.kind==='review'&&continuation!==null)try{
|
|
1798
|
+
ensureContinuationMarker();
|
|
1799
|
+
prepareContinuationCorrection({reviewsDir:completion.reviewsDir,feature:completion.owner.feature,
|
|
1800
|
+
task:config.identity.taskId,projectRoot:config.root,reason:continuation.reason,
|
|
1801
|
+
allowSymlinks:base.version===SYMLINK_BASELINE_VERSION});
|
|
1802
|
+
}catch(error){return Promise.resolve(freeze({outcome:'rejected',code:'review_continuation_evidence_invalid',
|
|
1803
|
+
reason:boundedReason('review_continuation_evidence_invalid: ',[String(error?.message??error).slice(0,300)],
|
|
1804
|
+
';保留现场核对 .reviews 下的补正文件,不覆盖或删除')}));}
|
|
1604
1805
|
try{const record=persist('effect-intent',{effect:v,...(v.kind==='develop'&&workerJournaling()?{workerJournal:true}:{})});
|
|
1605
1806
|
if(taskMode&&v.kind==='complete')completeEffect={effect:v,digest:record.digest};
|
|
1606
1807
|
}catch{return Promise.resolve(poison());}
|
|
@@ -1701,7 +1902,9 @@ export function createTaskRunner(options) {
|
|
|
1701
1902
|
&&row.payload.reviewPackage.packageDigest===reviewPackage?.packageDigest)??false;
|
|
1702
1903
|
const develop=[...cache.values()].filter(entry=>entry.effect.kind==='develop'
|
|
1703
1904
|
&&digest(entry.effect.identity)===digest(currentIdentity)
|
|
1704
|
-
&&(entry.result.state==='awaiting_review'||recovered&&['unknown','blocked'].includes(entry.result.state))
|
|
1905
|
+
&&(entry.result.state==='awaiting_review'||recovered&&['unknown','blocked'].includes(entry.result.state))
|
|
1906
|
+
// A review continuation delivers attempt 2 again: bind the reviewed package's own delivery.
|
|
1907
|
+
&&(continuation===null||entry.result.packageDigest===reviewPackage?.packageDigest));
|
|
1705
1908
|
need(develop.length===1&&Object.hasOwn(develop[0].effect,'learningInput'),'runner_learning');
|
|
1706
1909
|
return develop[0].effect.learningInput;
|
|
1707
1910
|
}
|
|
@@ -2009,6 +2212,7 @@ export function createTaskRunner(options) {
|
|
|
2009
2212
|
const recoverCommit=()=>{
|
|
2010
2213
|
try{
|
|
2011
2214
|
const transaction=commitRecoveryTransaction();need(transaction!==null,'commit_recovery_unavailable');
|
|
2215
|
+
requireBatchMerge();
|
|
2012
2216
|
const effect=restored.pending,intent=transaction.intentRecord.payload.commit;
|
|
2013
2217
|
// tasks.md is never touched again and no second result is appended once
|
|
2014
2218
|
// the journal holds the commit result; only the checkpoint is missing.
|
|
@@ -2118,6 +2322,70 @@ export function createTaskRunner(options) {
|
|
|
2118
2322
|
({state,code,reason}=parsedHistory.state);publication=privateStatus();return status();
|
|
2119
2323
|
}catch(error){return freeze({outcome:'rejected',code:poisoned?'store_failure':error.code??'development_rework_unavailable'});}
|
|
2120
2324
|
};
|
|
2325
|
+
// Third controlled review pilot. Same launch-only discipline as
|
|
2326
|
+
// development_rework: the journal record is the authority, the per-task marker
|
|
2327
|
+
// makes the one continuation visible to every other run of the task.
|
|
2328
|
+
const continuationMarker=record=>continuationMarkerBytes({feature:completion.owner.feature,task:config.identity.taskId,
|
|
2329
|
+
repositoryId:config.identity.repositoryId,runId:config.identity.runId,fromDigest:record.fromDigest,at:record.at});
|
|
2330
|
+
// The marker must be exactly the bytes the journal bound (markerSha256).
|
|
2331
|
+
function ensureContinuationMarker(){
|
|
2332
|
+
const bytes=continuationMarker(continuation);
|
|
2333
|
+
need(createHash('sha256').update(bytes).digest('hex')===continuation.markerSha256,'review_continuation_marker_mismatch');
|
|
2334
|
+
writeContinuationMarker(completion.reviewsDir,completion.owner.feature,config.identity.taskId,bytes);
|
|
2335
|
+
}
|
|
2336
|
+
const continuationRefusal=()=>{
|
|
2337
|
+
need(invocationMode&&store&&taskMode&&taskLearning?.hostHandoff===true,'review_continuation_unavailable');
|
|
2338
|
+
need(continuation===null,'review_continuation_used');
|
|
2339
|
+
const history=readRunnerHistory(journal,metadata,3);
|
|
2340
|
+
need(history.pending===null&&history.transaction===null&&history.scopeRevisions===0&&history.developmentRework===null,
|
|
2341
|
+
'review_continuation_unavailable');
|
|
2342
|
+
const binding=reviewContinuationBinding(journal,history.state,{...metadata,scope:effectiveScope},history.reviewContinuation);
|
|
2343
|
+
need(!continuationUsedElsewhere(completion.reviewsDir,completion.owner.feature,config.identity.taskId),'review_continuation_used');
|
|
2344
|
+
return {history,binding};
|
|
2345
|
+
};
|
|
2346
|
+
const CONTINUATION_REASONS={review_continuation_used:'该任务已用过第三次受控审查或补正(每任务最多一次)',
|
|
2347
|
+
review_continuation_unavailable:'当前状态或运行配置不满足试点条件(仅 v2 单任务、当前会话开发、单代码根,且停在 review_limit)'};
|
|
2348
|
+
const reviewContinuationAvailability=()=>{
|
|
2349
|
+
try{need(!busy&&!poisoned,'review_continuation_unavailable');continuationRefusal();return freeze({available:true,reason:null});}
|
|
2350
|
+
catch(error){return freeze({available:false,code:error.code??'review_continuation_unavailable',
|
|
2351
|
+
reason:CONTINUATION_REASONS[error.code]??CONTINUATION_REASONS.review_continuation_unavailable});}
|
|
2352
|
+
};
|
|
2353
|
+
const reviewContinuationActive=()=>continuation!==null;
|
|
2354
|
+
// Same deterministic projection executeEffect repairs before any effect: a
|
|
2355
|
+
// terminal block (review_limit, review_continuation_rejected) has no next
|
|
2356
|
+
// effect, so a crash before its review file was written must still heal.
|
|
2357
|
+
const repairReviewPublication=()=>{
|
|
2358
|
+
if(busy||poisoned)return;
|
|
2359
|
+
try{publishRegisteredReview(true);}catch{publishRegisteredReview();}
|
|
2360
|
+
};
|
|
2361
|
+
const authorizeReviewContinuation=raw=>{
|
|
2362
|
+
try{
|
|
2363
|
+
need(!busy&&!poisoned&&options.persistence?.mode==='resume'&&options.providerDevelopment!==true
|
|
2364
|
+
&&options.protectedDevelopment!==true,'review_continuation_unavailable');
|
|
2365
|
+
const value=json(raw);shape(value,['allowed','reason']);need(value.allowed===true,'review_continuation_authorization_required');
|
|
2366
|
+
need(typeof value.reason==='string'&&value.reason.trim().length>0&&Buffer.byteLength(value.reason,'utf8')<=500
|
|
2367
|
+
&&!/[\r\n\0]/.test(value.reason),'review_continuation_reason_required');
|
|
2368
|
+
const {history,binding}=continuationRefusal();
|
|
2369
|
+
const rows=taskDeclarations(fs.readFileSync(completion.owner.tasksPath,'utf8'),
|
|
2370
|
+
{grammar:approvedTaskGrammar(completion.owner.specsRoot)}).filter(item=>item.id===config.identity.taskId);
|
|
2371
|
+
need(rows.length===1&&!rows[0].completed,'review_continuation_task_completed');
|
|
2372
|
+
if(Object.hasOwn(original,'specification'))verifySpecificationMaterial(original);
|
|
2373
|
+
// The r2 evidence the gate's correction history binds must already be published.
|
|
2374
|
+
publishRegisteredReview(true);
|
|
2375
|
+
const at=new Date().toISOString(),record={...binding,markerSha256:''.padEnd(64,'0'),reason:value.reason,at};
|
|
2376
|
+
record.markerSha256=createHash('sha256').update(continuationMarker(record)).digest('hex');
|
|
2377
|
+
applyReviewContinuation(journal,history.state,{...metadata,scope:effectiveScope},record,null);
|
|
2378
|
+
// The task-level marker is claimed first and exclusively: a crash before the
|
|
2379
|
+
// journal append leaves the task's one continuation spent, never reusable.
|
|
2380
|
+
writeContinuationMarker(completion.reviewsDir,completion.owner.feature,config.identity.taskId,
|
|
2381
|
+
continuationMarker(record),{exclusive:true});
|
|
2382
|
+
persist('review-continuation-authorized',record);
|
|
2383
|
+
const next=readRunnerHistory(journal,metadata,3);
|
|
2384
|
+
continuation=next.reviewContinuation;ensureContinuationMarker();
|
|
2385
|
+
({state,code,attempt,receipt,reviewInvocation,reason}=next.state);
|
|
2386
|
+
base=attemptBaseline(original,attempt);publication=privateStatus();return status();
|
|
2387
|
+
}catch(error){return freeze({outcome:'rejected',code:poisoned?'store_failure':error.code??'review_continuation_unavailable'});}
|
|
2388
|
+
};
|
|
2121
2389
|
const reworkCompletion=raw=>{
|
|
2122
2390
|
try{
|
|
2123
2391
|
need(invocationMode&&store&&!busy&&!poisoned&&options.persistence.mode==='resume'
|
|
@@ -2199,7 +2467,30 @@ export function createTaskRunner(options) {
|
|
|
2199
2467
|
checks:reviewPackage.checks,reviewPackage,expectedDigest:reviewPackage.packageDigest,...handoffBinding()});
|
|
2200
2468
|
return freeze(structuredClone(reviewPackage.checks));
|
|
2201
2469
|
};
|
|
2202
|
-
|
|
2470
|
+
// The frozen N6 cadence (null for runs created before it); entry passes it on.
|
|
2471
|
+
const qaCadence=()=>metadata.qaCadence??null;
|
|
2472
|
+
// Read-only facts for the review_limit decision card: replayed receipts and the
|
|
2473
|
+
// last reviewed package, plus which evidence files exist. Never dispatches,
|
|
2474
|
+
// runs checks, publishes or repairs anything; absent facts stay absent.
|
|
2475
|
+
const reviewLimitEvidence=()=>{
|
|
2476
|
+
if(!taskMode||!completion?.owner)return null;
|
|
2477
|
+
const present=file=>{try{return fs.lstatSync(file).isFile();}catch{return false;}};
|
|
2478
|
+
const evidenceName=(round,kind)=>kind==='handoff'?completion.handoffs[round-1]
|
|
2479
|
+
:path.join(completion.reviewsDir,`${completion.owner.feature}-${config.identity.taskId}-r${round}.md`);
|
|
2480
|
+
return freeze(structuredClone({
|
|
2481
|
+
rounds:receipts.map(r=>({attempt:r.identity.attempt,verdict:r.result.verdict,summary:r.result.summary,
|
|
2482
|
+
findings:r.result.findings.map(({id,severity,path:file,message})=>({id,severity,path:file,message})),
|
|
2483
|
+
packageDigest:r.packageDigest,receiptDigest:r.receiptDigest})),
|
|
2484
|
+
packageAttempt:reviewPackage?.identity.attempt??null,packageDigest:reviewPackage?.packageDigest??null,
|
|
2485
|
+
checks:reviewPackage?reviewPackage.checks.map(c=>({id:c.id,outcome:c.outcome})):null,
|
|
2486
|
+
changes:reviewPackage?reviewPackage.changes.map(c=>({path:c.path,
|
|
2487
|
+
kind:c.before===null?'created':c.after===null?'deleted':'modified'})):null,
|
|
2488
|
+
files:[...[1,2].flatMap(round=>['handoff','review'].map(kind=>({round,kind,present:present(evidenceName(round,kind))}))),
|
|
2489
|
+
// The third controlled review's own evidence once it has a receipt.
|
|
2490
|
+
...(continuation!==null&&receipts.length===3?Object.entries({handoff:'handoff',correction_record:'record',
|
|
2491
|
+
review:'review',receipt:'receipt'}).map(([kind,key])=>({round:3,kind,present:present(continuationFiles()[key])})):[])]}));
|
|
2492
|
+
};
|
|
2493
|
+
const api={...(batchCompletionGate?{preflightBatchCompletion}:{}),reviewLimitEvidence,reviewContinuationAvailability,reviewContinuationActive,authorizeReviewContinuation,repairReviewPublication,qaChangedFiles,qaCompletionChecks,qaCadence,qaAllowsSymlinks,reviseQa,supersedeEvidence,rebindSpecification,abandonReview,reconcileReview,abandonEffect,recoverBootstrapReview,reworkCompletion,reworkDevelopment,reviseScope,executeEffect,status,cancel,run,inspectFixAssociation,acceptCompletedFix,acceptReviewedIntegration,attachQa,verificationBlocks,completionBlocks,reviewEffectIds,recheckLearningInput,redoDevelop,recoverCommit,interruptions};
|
|
2203
2494
|
if(bootstrap!==null)api.inspectBootstrapAdmission=()=>bootstrap.inspectAdmission(original);
|
|
2204
2495
|
if(taskLearning!==null)api.attachLearningEvidence=attachLearningEvidence;
|
|
2205
2496
|
// A terminal reviewer observation is durable even if the host died before
|
|
@@ -2212,7 +2503,7 @@ export function createTaskRunner(options) {
|
|
|
2212
2503
|
resultDigest:digest(result.inspection.review),providerThreadId:observed.started};
|
|
2213
2504
|
sequence++;calls.push(call);
|
|
2214
2505
|
reviewInvocation=json({registration:observed.registration,started:observed.started,result});
|
|
2215
|
-
acceptReview(request,call,result.inspection.review);
|
|
2506
|
+
acceptReview(request,call,result.inspection.review,[],{strictBlocked:false});
|
|
2216
2507
|
const effect=restored.pending,response=privateStatus();
|
|
2217
2508
|
cache.set(effect.id,{effect,digest:digest(effect),result:response});
|
|
2218
2509
|
persist('effect-checkpoint',{effectId:effect.id,checkpoint:frame()});
|