@aibyzero/cm-workflow 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +23 -0
- package/CHANGELOG.md +224 -0
- package/README.md +14 -3
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/VERSION +1 -1
- package/compat/claude-commands/cm-challenge.md +3 -0
- package/docs/architecture.md +11 -0
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +150 -15
- package/docs/live-evidence-drivers.md +28 -4
- package/docs/out-of-scope/README.md +25 -0
- package/docs/out-of-scope/background-supervisor.md +32 -0
- package/docs/reviewed-integration.md +48 -0
- package/docs/user-guide.md +50 -21
- package/install-codex.sh +331 -18
- package/install.ps1 +28 -2
- package/install.sh +321 -17
- package/package.json +2 -1
- package/runtime/js/cm-ai/batch-location.mjs +55 -0
- package/runtime/js/cm-ai/batch-plan.mjs +242 -0
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +83 -14
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
- package/runtime/js/cm-ai/codex-config.mjs +6 -2
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
- package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
- package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
- package/runtime/js/cm-ai/control-policy.mjs +21 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +114 -11
- package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
- package/runtime/js/cm-ai/effect-contract.mjs +11 -2
- package/runtime/js/cm-ai/execution-policy.mjs +3 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
- package/runtime/js/cm-ai/execution-store.mjs +60 -17
- package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
- package/runtime/js/cm-ai/host-check.mjs +11 -5
- package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
- package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
- package/runtime/js/cm-ai/host-replay.mjs +148 -0
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
- package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
- package/runtime/js/cm-ai/live-evidence.mjs +28 -6
- package/runtime/js/cm-ai/operator-guidance.mjs +9 -2
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
- package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
- package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
- package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
- package/runtime/js/cm-ai/review-package.mjs +79 -7
- package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
- package/runtime/js/cm-ai/review-presentation.mjs +177 -8
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
- package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
- package/runtime/js/cm-ai/scope-revision.mjs +38 -0
- package/runtime/js/cm-ai/specification-material.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +242 -39
- package/runtime/js/cm-ai/verification-auto.mjs +38 -0
- package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
- package/runtime/js/cm-ai/worker-claude.mjs +35 -13
- package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
- package/runtime/js/cm-ai/worker-codex.mjs +41 -7
- package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
- package/runtime/js/cm-fix/cause-package.mjs +46 -1
- package/runtime/js/cm-fix/command-correction.mjs +37 -0
- package/runtime/js/cm-fix/cooperative.mjs +12 -0
- package/runtime/js/cm-fix/dossier.mjs +8 -2
- package/runtime/js/cm-fix/execution.mjs +578 -100
- package/runtime/js/cm-fix/final-review.mjs +39 -8
- package/runtime/js/cm-fix/finish.mjs +15 -11
- package/runtime/js/cm-fix/host-review.mjs +65 -10
- package/runtime/js/cm-fix/host.mjs +35 -12
- package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
- package/runtime/js/cm-fix/metrics.mjs +18 -5
- package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
- package/runtime/js/cm-fix/regression.mjs +16 -7
- package/runtime/js/cm-fix/repair.mjs +29 -8
- package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
- package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
- package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
- package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
- package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
- package/runtime/js/cm-fix/review-verification.mjs +214 -0
- package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
- package/runtime/js/cm-fix/start.mjs +6 -3
- package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
- package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
- package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
- package/runtime/js/cm-prd/accepted-design.mjs +8 -0
- package/runtime/js/cm-prd/analysis.mjs +13 -9
- package/runtime/js/cm-prd/change.mjs +37 -16
- package/runtime/js/cm-prd/draft-save.mjs +13 -6
- package/runtime/js/cm-prd/draft.mjs +31 -3
- package/runtime/js/cm-prd/failed-correction.mjs +19 -3
- package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
- package/runtime/js/cm-prd/review-correction.mjs +6 -4
- package/runtime/js/cm-prd/review-disposition.mjs +7 -1
- package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
- package/runtime/js/cm-prd/self-check.mjs +125 -6
- package/runtime/js/cm-prd/session.mjs +30 -1
- package/runtime/js/cm-prd/summary.mjs +11 -5
- package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
- package/runtime/js/cm-prd/tree-digest.mjs +34 -0
- package/runtime/js/cm-prd/validation-reason.mjs +8 -4
- package/runtime/js/cm-security/scan.mjs +1 -1
- package/runtime/js/commander/decision.mjs +44 -0
- package/runtime/js/commander/dispatch-registry.mjs +110 -0
- package/runtime/js/commander/ledger.mjs +265 -0
- package/runtime/js/commander/preflight.mjs +107 -0
- package/runtime/js/notify-later.mjs +13 -0
- package/runtime/js/notify-send.mjs +6 -2
- package/runtime/js/notify.mjs +570 -63
- package/runtime/js/review-findings.mjs +38 -0
- package/runtime/js/session-boundary.mjs +56 -0
- package/runtime/js/session-handoff.mjs +68 -0
- package/runtime/js/spec-task-line.mjs +27 -13
- package/runtime/js/specs-status.mjs +1 -1
- package/runtime/js/task-scope.mjs +197 -0
- package/runtime/logging.md +6 -1
- package/runtime/model-efficiency.md +69 -10
- package/runtime/orchestration.md +3 -1
- package/runtime/project-learning.md +2 -0
- package/runtime/review.md +3 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +11 -5
- package/scripts/cm-ai-admission.test.mjs +23 -2
- package/scripts/cm-ai-batch-drive.mjs +79 -18
- package/scripts/cm-ai-batch-drive.test.mjs +169 -3
- package/scripts/cm-ai-batch-host.mjs +38 -9
- package/scripts/cm-ai-batch-host.test.mjs +6 -5
- package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
- package/scripts/cm-ai-batch-location.test.mjs +57 -0
- package/scripts/cm-ai-batch-plan.mjs +52 -0
- package/scripts/cm-ai-batch-plan.test.mjs +397 -0
- package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
- package/scripts/cm-ai-batch-run.mjs +471 -57
- package/scripts/cm-ai-batch-run.test.mjs +23 -4
- package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
- package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
- package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
- package/scripts/cm-ai-control-launch.test.mjs +21 -0
- package/scripts/cm-ai-control-policy.test.mjs +14 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
- package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
- package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
- package/scripts/cm-ai-development-rework.test.mjs +423 -0
- package/scripts/cm-ai-drive.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +34 -2
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host.mjs +60 -19
- package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
- package/scripts/cm-ai-integration-independence.test.mjs +23 -0
- package/scripts/cm-ai-integration-launch.test.mjs +240 -0
- package/scripts/cm-ai-integration-preview.mjs +41 -0
- package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
- package/scripts/cm-ai-nested-execution.test.mjs +29 -1
- package/scripts/cm-ai-operator-guidance.test.mjs +16 -1
- package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
- package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
- package/scripts/cm-ai-review-failure.test.mjs +150 -5
- package/scripts/cm-ai-run.mjs +88 -21
- package/scripts/cm-ai-scope-revision.test.mjs +341 -0
- package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
- package/scripts/cm-ai-supersede.test.mjs +28 -0
- package/scripts/cm-ai-verification-auto.test.mjs +99 -0
- package/scripts/cm-announce-hook.mjs +35 -8
- package/scripts/cm-announce-hook.test.mjs +25 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +1 -1
- package/scripts/cm-check-runtime.sh +58 -1
- package/scripts/cm-claude-developer-worker.test.mjs +56 -7
- package/scripts/cm-claude-install-layout.test.mjs +1 -1
- package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +13 -0
- package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
- package/scripts/cm-codex-developer-worker.test.mjs +120 -0
- package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
- package/scripts/cm-codex-prompt-input.test.mjs +153 -0
- package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
- package/scripts/cm-commander-ledger.test.mjs +260 -0
- package/scripts/cm-commander-p2.test.mjs +295 -0
- package/scripts/cm-commander-preflight.mjs +84 -0
- package/scripts/cm-commander.mjs +116 -0
- package/scripts/cm-config-lock.mjs +35 -0
- package/scripts/cm-controlled-correction.test.mjs +10 -1
- package/scripts/cm-developer-failure-code.test.mjs +62 -0
- package/scripts/cm-display-task-id.test.mjs +41 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
- package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
- package/scripts/cm-external-batch-host.test.mjs +4 -3
- package/scripts/cm-external-process-cleanup.test.mjs +128 -0
- package/scripts/cm-external-qa-fix.test.mjs +89 -7
- package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
- package/scripts/cm-failover.mjs +48 -10
- package/scripts/cm-failover.test.mjs +46 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
- package/scripts/cm-fix-command-correction.mjs +17 -0
- package/scripts/cm-fix-command-correction.test.mjs +211 -0
- package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
- package/scripts/cm-fix-drive.mjs +33 -5
- package/scripts/cm-fix-drive.test.mjs +49 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
- package/scripts/cm-fix-host-review.test.mjs +21 -9
- package/scripts/cm-fix-host.mjs +26 -8
- package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
- package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
- package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
- package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
- package/scripts/cm-fix-review-preflight.mjs +24 -0
- package/scripts/cm-fix-review-storage.test.mjs +233 -0
- package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
- package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
- package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
- package/scripts/cm-fix-review-verification.test.mjs +146 -0
- package/scripts/cm-fix-revision-transport.test.mjs +81 -0
- package/scripts/cm-fix-source-correction.test.mjs +296 -0
- package/scripts/cm-fix-test-type-correction.mjs +18 -0
- package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
- package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
- package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
- package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
- package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
- package/scripts/cm-fix-verification-recovery.mjs +33 -0
- package/scripts/cm-host-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -0
- package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
- package/scripts/cm-install-manifest.sh +351 -0
- package/scripts/cm-live-evidence.test.mjs +59 -1
- package/scripts/cm-log-event.mjs +61 -10
- package/scripts/cm-log-event.test.mjs +121 -1
- package/scripts/cm-matt-skills.mjs +576 -0
- package/scripts/cm-matt-skills.test.mjs +550 -0
- package/scripts/cm-notify-command.test.mjs +42 -10
- package/scripts/cm-notify.mjs +14 -10
- package/scripts/cm-notify.test.mjs +575 -59
- package/scripts/cm-patrol.mjs +4 -1
- package/scripts/cm-patrol.test.mjs +23 -5
- package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
- package/scripts/cm-prd-completion.test.mjs +56 -13
- package/scripts/cm-prd-design-phase.test.mjs +78 -8
- package/scripts/cm-prd-draft-save.test.mjs +12 -0
- package/scripts/cm-prd-draft.test.mjs +1 -1
- package/scripts/cm-prd-drive.mjs +13 -6
- package/scripts/cm-prd-drive.test.mjs +45 -1
- package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
- package/scripts/cm-prd-host.mjs +10 -5
- package/scripts/cm-prd-host.test.mjs +4 -2
- package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
- package/scripts/cm-prd-review-disposition.test.mjs +124 -8
- package/scripts/cm-prd-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
- package/scripts/cm-prd-self-check.test.mjs +105 -5
- package/scripts/cm-prd-summary.test.mjs +24 -3
- package/scripts/cm-prd-task-grouping.test.mjs +6 -6
- package/scripts/cm-prd-tree-digest.test.mjs +74 -0
- package/scripts/cm-refactor-drive.mjs +2 -1
- package/scripts/cm-refactor-drive.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +1 -1
- package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
- package/scripts/cm-skill-hints-exam.mjs +149 -0
- package/scripts/cm-skill-hints-install.test.mjs +168 -0
- package/scripts/cm-skill-hints.exam.json +706 -0
- package/scripts/cm-skill-hints.json +119 -0
- package/scripts/cm-skill-hints.mjs +669 -0
- package/scripts/cm-skill-hints.test.mjs +831 -0
- package/scripts/cm-skill-judge.mjs +181 -0
- package/scripts/cm-skill-judge.test.mjs +255 -0
- package/scripts/cm-specs-status.test.mjs +4 -2
- package/scripts/cm-start-check.mjs +208 -0
- package/scripts/cm-start-check.test.mjs +321 -0
- package/scripts/cm-task-gate.mjs +150 -29
- package/scripts/cm-task-gate.test.mjs +73 -1
- package/scripts/cm-task-id-grammar.test.mjs +66 -0
- package/scripts/cm-task-scope.test.mjs +308 -0
- package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
- package/scripts/cm-upgrade-compat.test.mjs +239 -0
- package/scripts/cm-workflow-config.mjs +12 -2
- package/scripts/fixtures/fix-verification-claude.mjs +44 -0
- package/scripts/fixtures/reviewed-integration.mjs +202 -0
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/session-boundary.test.mjs +170 -0
- package/scripts/test-npm-install.py +14 -3
- package/scripts/test-shell-compat.sh +2 -0
- package/scripts/validate-public-repo.py +1 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N4-review.md +2 -1
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/N8-finish.md +22 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
- package/skills/cm-ai/references/js-host-recovery.md +79 -3
- package/skills/cm-ai/references/js-host.md +56 -16
- package/skills/cm-challenge/SKILL.md +65 -0
- package/skills/cm-challenge/evals/README.md +18 -0
- package/skills/cm-challenge/evals/trigger-cases.json +20 -0
- package/skills/cm-challenge/evals/trigger-config.json +28 -0
- package/skills/cm-challenge/references/examples.md +15 -0
- package/skills/cm-check/SKILL.md +5 -0
- package/skills/cm-check/references/js-host.md +2 -0
- package/skills/cm-fix/SKILL.md +12 -3
- package/skills/cm-fix/references/command-correction.md +67 -0
- package/skills/cm-fix/references/isolated-review.md +54 -0
- package/skills/cm-fix/references/js-host.md +62 -2
- package/skills/cm-fix/references/test-type-correction.md +72 -0
- package/skills/cm-fix/references/verification-recovery.md +114 -0
- package/skills/cm-idea/SKILL.md +2 -0
- package/skills/cm-idea/references/js-host.md +2 -0
- package/skills/cm-notify/SKILL.md +2 -0
- package/skills/cm-prd/SKILL.md +12 -8
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +6 -0
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-host.md +4 -2
- package/skills/cm-prd/references/spec-self-check.md +5 -1
- package/skills/cm-refactor/SKILL.md +8 -0
- package/skills/cm-refactor/references/js-host.md +2 -0
- package/skills/cm-test/SKILL.md +4 -0
- package/templates/dashboard/dashboard.html +2 -2
- package/templates/pixel/cm-pixel.html +1 -1
- package/templates/pixel/cm-pixel.sh +1 -1
- package/templates/pixel/dev/template.html +1 -1
- package/templates/statusline/cm-statusline.sh +1 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {packageMaterialEligible,checkpointStoragePlan,checkpointPackageBudget,packageMaterialReference} from './checkpoint-package-material.mjs';
|
|
2
|
+
import {taskDeclarations,approvedTaskGrammar} from '../spec-task-line.mjs';
|
|
3
|
+
import {readIntegrationEvidenceFile,validateIntegrationRecord,verifyReviewedIntegration} from './reviewed-integration.mjs';
|
|
1
4
|
import {beginHostStage} from './host-stage-observer.mjs';
|
|
2
5
|
import {readExecutionPolicy} from './execution-policy.mjs';
|
|
3
6
|
import {readExternalModels} from './external-models.mjs';
|
|
@@ -12,16 +15,16 @@ import path from 'node:path';
|
|
|
12
15
|
import {createRequire} from 'node:module';
|
|
13
16
|
import {verifySpecificationMaterial,boundSpecificationMaterial,inspectSpecificationDrift,describeSpecificationDrift,
|
|
14
17
|
readSpecificationRebind} from './specification-material.mjs';
|
|
15
|
-
import { captureReviewBaseline, captureReviewInventory, compareReviewBaseline, createReviewPackage, verifyReviewPackage, verifyCompletionReviewPackage, validChecks, readReviewSourceFiles } from './review-package.mjs';
|
|
18
|
+
import { captureReviewBaseline, captureScopeRevisionSources, captureReviewInventory, compareReviewBaseline, createReviewPackage, verifyReviewPackage, verifyCompletionReviewPackage, validChecks, readReviewSourceFiles } from './review-package.mjs';
|
|
16
19
|
import { digest,need,shape,id,text,json,freeze,arrayItems,validIdentity,validTaskLearningInput,validCallTimeout,requestFor,terminalFor,failureCode,
|
|
17
20
|
JOURNAL_PAYLOAD_LIMIT,developCheckpointReserve,taskReviewScope,boundedReason } from './effect-contract.mjs';
|
|
18
21
|
import { reviewResult,reviewReceipt,boundReviewText,reviewPaths } from './review-runner.mjs';
|
|
19
22
|
import { checkCompletion } from './gate-bridge.mjs';
|
|
20
23
|
import { runnerPayload,runnerPayloadV3,readRunnerHistory,attemptBaseline,boundRunnerRecord,
|
|
21
24
|
MAX_AI_JOINED_HOSTS,controlledState,stageAllowed,effectSlotFree,reviewTimeoutTransition,validateTaskLearningReviewPackage,
|
|
22
|
-
reviewRetrySpent,abandonableReviewResult,developBudget,developBudgetExhausted,
|
|
25
|
+
reviewRetrySpent,abandonableReviewResult,developBudget,developBudgetExhausted,verificationBlockCount,developmentReworkBinding,applyDevelopmentRework,
|
|
23
26
|
MAX_REVIEW_REDISPATCHES,REVIEW_RETRY_CODES,reviewRedispatchCount,reviewRedispatchable,reviewRedispatchExhausted,REVIEW_REDISPATCH_LIMIT_CODE,reviewRedispatchLimitReason,reviewRedispatchStopReason,reviewAbandonRefusal,
|
|
24
|
-
completionBlockCount,completionRetriesExhausted,supersededReviewPayload,bootstrapReviewRecoverable,protectedDevelopScope,protectedScopeBlockReason,
|
|
27
|
+
completionBlockCount,completionRetriesExhausted,completionReworkBinding,applyCompletionRework,supersededReviewPayload,bootstrapReviewRecoverable,protectedDevelopScope,protectedScopeBlockReason,
|
|
25
28
|
developTimeoutBasis,developTimeoutEffect,developTimeoutState,DEVELOP_CALL_TIMEOUT_REASON,
|
|
26
29
|
developAnswerInvalidEffect,developAnswerRetryable,developAnswerInvalidReason,
|
|
27
30
|
RECHECK_CODES,COMPLETE_RECHECK_CODE,developRecheckSource,developRecheckCode,developRecheckReason,
|
|
@@ -32,6 +35,9 @@ import { runnerPayload,runnerPayloadV3,readRunnerHistory,attemptBaseline,boundRu
|
|
|
32
35
|
DOCUMENTATION_SYNC_CODES,documentationSyncSource,documentationSyncRetryCode,documentationSyncStopReason } from './durable-runner-state.mjs';
|
|
33
36
|
import {splitDocumentationState} from './host-documentation.mjs';
|
|
34
37
|
import {readControlPolicy} from './control-policy.mjs';
|
|
38
|
+
import {encodeRequirementEvidence} from './requirement-evidence.mjs';
|
|
39
|
+
import {encodeHostReplayEvidence} from './host-replay.mjs';
|
|
40
|
+
import {scopeRevisionBinding,revisedScope,applyScopeRevision} from './scope-revision.mjs';
|
|
35
41
|
import {readProcessStartTime,inspectWorkerGroup} from './worker-process-identity.mjs';
|
|
36
42
|
import {recoverRunnerCommitImage} from './task-commit.mjs';
|
|
37
43
|
import {commitRunnerFixture} from './task-commit.mjs';
|
|
@@ -42,7 +48,7 @@ import {readCmAiProjectLearningWriteback,writeCmAiProjectLearning} from './cm-ai
|
|
|
42
48
|
import {verifyCmAiTaskLearningHandoff,writeCmAiTaskLearningHandoff} from './cm-ai-learning-handoff-writer.mjs';
|
|
43
49
|
import {implementationSha256,loadHandoff} from '../../../scripts/cm-task-gate.mjs';
|
|
44
50
|
import {createHostHandoff} from './host-handoff.mjs';
|
|
45
|
-
import {inspectFixCodeAssociation,explainCompletedDelivery} from './fix-code-association.mjs';
|
|
51
|
+
import {inspectFixCodeAssociation,explainCompletedDelivery,firstReviewAt} from './fix-code-association.mjs';
|
|
46
52
|
import {approvedReviewAt,completedReviewedDeliveries,fixReviewedAt,resolveDeliverySteps} from './reviewed-deliveries.mjs';
|
|
47
53
|
import {validateAcceptedFix} from './accepted-fix.mjs';
|
|
48
54
|
import {appendFits} from './execution-store-limits.mjs';
|
|
@@ -158,6 +164,7 @@ export function createTaskRunner(options) {
|
|
|
158
164
|
if(options && Object.hasOwn(options,'executionPolicy'))optionKeys.push('executionPolicy');
|
|
159
165
|
if(options && Object.hasOwn(options,'externalModels'))optionKeys.push('externalModels');
|
|
160
166
|
if(options && Object.hasOwn(options,'controlPolicy'))optionKeys.push('controlPolicy');
|
|
167
|
+
if(options && Object.hasOwn(options,'parallelSelection'))optionKeys.push('parallelSelection');
|
|
161
168
|
if(invocationMode)optionKeys.push('reviewInvocation');
|
|
162
169
|
shape(options,optionKeys);
|
|
163
170
|
need(options.providerDevelopment===undefined||typeof options.providerDevelopment==='boolean','invalid_input');
|
|
@@ -169,6 +176,8 @@ export function createTaskRunner(options) {
|
|
|
169
176
|
// Opt-in gate between the task's own checks and the independent review. It may
|
|
170
177
|
// only block: passing it grants nothing and never substitutes for that review.
|
|
171
178
|
const verificationGate=options.verificationGate??null;
|
|
179
|
+
// The latest satisfied gate's handoff entry; reset on every gate run.
|
|
180
|
+
let requirementEvidence=null,hostReplayEvidence=null;
|
|
172
181
|
need(verificationGate===null||typeof verificationGate==='function');
|
|
173
182
|
if(taskMode)need(Object.hasOwn(options,'persistence'),'runner_completion');
|
|
174
183
|
const config=json({root:options.root,identity:options.identity,scope:options.scope,requirements:options.requirements,
|
|
@@ -221,7 +230,10 @@ export function createTaskRunner(options) {
|
|
|
221
230
|
...(Object.hasOwn(options,'knowledgeCloseout')?{knowledgeCloseout:readCloseoutPolicy(options.knowledgeCloseout)}:{}),
|
|
222
231
|
...(Object.hasOwn(options,'executionPolicy')?{executionPolicy:readExecutionPolicy(options.executionPolicy)}:{}),
|
|
223
232
|
...(Object.hasOwn(options,'externalModels')?{externalModels:readExternalModels(options.externalModels)}:{}),
|
|
224
|
-
...(Object.hasOwn(options,'controlPolicy')?{controlPolicy:readControlPolicy(options.controlPolicy)}:{})
|
|
233
|
+
...(Object.hasOwn(options,'controlPolicy')?{controlPolicy:readControlPolicy(options.controlPolicy)}:{}),
|
|
234
|
+
...(Object.hasOwn(options,'parallelSelection')&&
|
|
235
|
+
(options.persistence?.mode==='create'||options.persistence?.store?.snapshot().records[0]?.payload.config.parallelSelection)
|
|
236
|
+
?{parallelSelection:json(options.parallelSelection)}:{})});
|
|
225
237
|
const taskLearning=metadata.taskLearning??null;
|
|
226
238
|
if(taskLearning!==null){need(taskMode,'runner_learning');
|
|
227
239
|
shape(taskLearning,['feature',...(Object.hasOwn(taskLearning,'hostHandoff')?['hostHandoff']:[])]);
|
|
@@ -272,10 +284,14 @@ export function createTaskRunner(options) {
|
|
|
272
284
|
need(completion&&specificationSelection.specsRoot===completion.owner.specsRoot
|
|
273
285
|
&&specificationSelection.feature===taskLearning?.feature,'spec_drift');
|
|
274
286
|
}
|
|
275
|
-
|
|
287
|
+
let effectiveScope=restored?.effectiveScope??config.scope;
|
|
288
|
+
let scopeRevisionPaths=restored?.original.scopeRevisionPaths??null;
|
|
289
|
+
const effectiveMetadata=()=>({...metadata,scope:effectiveScope,...(scopeRevisionPaths?{scopeRevisionPaths}: {})});
|
|
290
|
+
const baselineOptions=()=>({...configToBaseline(effectiveMetadata()),
|
|
276
291
|
...(specificationSelection===null?{}:{specification:specificationSelection})});
|
|
277
|
-
|
|
278
|
-
|
|
292
|
+
let original=restored?.original??captureReviewBaseline(baselineOptions());
|
|
293
|
+
let controller=new AbortController();
|
|
294
|
+
const calls=[],cache=new Map(),session=restored?.session??randomUUID(),registered=new Map(),receipts=[];
|
|
279
295
|
let state=reviewers.some(r=>r.allowed&&r.available)?'ready':'pending_review',code=null,attempt=1;
|
|
280
296
|
let busy=false,pending=null,sequence=0,base=original,reviewPackage=null,currentChecks=null,workflowRunning=false;
|
|
281
297
|
let reason=null,checkNewPaths=null;
|
|
@@ -284,6 +300,7 @@ export function createTaskRunner(options) {
|
|
|
284
300
|
// Journaled supersession context: shown, never counted as a review verdict.
|
|
285
301
|
let carriedReview=restored?.supersession?.carriedReview??null;
|
|
286
302
|
const acceptedFixes=structuredClone(restored?.acceptedFixes??[]);
|
|
303
|
+
let acceptedIntegration=restored?.acceptedIntegration??null;
|
|
287
304
|
let qaAttachment=restored?.qaAttachment??null;
|
|
288
305
|
// A fresh ready-state capture carries the current material; represent an
|
|
289
306
|
// accepted (identical or explicitly rebound) one by the bound material.
|
|
@@ -305,11 +322,7 @@ export function createTaskRunner(options) {
|
|
|
305
322
|
// so the next corrected delivery needs a new effect id or it would just read
|
|
306
323
|
// the blocked result back out of the cache. Counting them here keeps that
|
|
307
324
|
// derivation in one place, next to the cache it is derived from.
|
|
308
|
-
const verificationBlocks=()=>[...cache.values()]
|
|
309
|
-
&&entry.result?.state==='blocked'
|
|
310
|
-
&&['verification_precheck_failed','check_output_out_of_scope','develop_checks_not_passed','develop_unchanged_after_review','develop_empty_changes','develop_requirement_missing','develop_package_too_large','bootstrap_verification_failed','bootstrap_instruction_conflict','develop_call_timeout'].includes(entry.result?.code)
|
|
311
|
-
||developTimeoutEffect(entry)||developAnswerInvalidEffect(entry)||developRecheckSource(entry)||developRedoSource(entry)||developDispatchFailedEffect(entry)
|
|
312
|
-
||documentationSyncSource(entry)).length;
|
|
325
|
+
const verificationBlocks=()=>verificationBlockCount([...cache.values()],parsedHistory?.developRecheckEffects);
|
|
313
326
|
const completionBlocks=()=>[...cache.values()].filter(entry=>entry.effect.kind==='complete'
|
|
314
327
|
&&entry.result?.state==='blocked'&&['completion_checks_changed','completion_package_changed'].includes(entry.result?.code)
|
|
315
328
|
||completeRecheckSource(entry)).length;
|
|
@@ -391,7 +404,7 @@ export function createTaskRunner(options) {
|
|
|
391
404
|
const answerGapCount=type=>journal?.filter(row=>row.payload.type===type).length??0;
|
|
392
405
|
const gapsLive=()=>Boolean(store&&taskMode&&invocationMode&&!busy&&!poisoned&&!(restored?.pending&&!cache.has(restored.pending.id)));
|
|
393
406
|
const developRecheck=()=>gapsLive()?developRecheckCode({state,code,attempt,cache:[...cache.values()],learningResult,receipt},
|
|
394
|
-
metadata,answerGapCount('develop-recheck')):null;
|
|
407
|
+
metadata,answerGapCount('develop-recheck'),parsedHistory?.developRecheckRecovery):null;
|
|
395
408
|
const completeRecheck=()=>gapsLive()&&completeRecheckable({state,code,attempt,cache:[...cache.values()],taskCommit},
|
|
396
409
|
answerGapCount('complete-recheck'));
|
|
397
410
|
// V2 + R3: a stuck current-session develop that only an operator confirmation
|
|
@@ -445,7 +458,7 @@ export function createTaskRunner(options) {
|
|
|
445
458
|
// scope and the ignore policy bound at create, as the task baseline), split
|
|
446
459
|
// at the documentation paths. The adapter takes its start and end with it too.
|
|
447
460
|
function documentationSnapshot(paths){
|
|
448
|
-
const baseline=captureReviewBaseline({...configToBaseline(
|
|
461
|
+
const baseline=captureReviewBaseline({...configToBaseline(effectiveMetadata()),version:original.version,
|
|
449
462
|
...(Object.hasOwn(original,'specification')?{specification:{specsRoot:original.specificationRoot,feature:original.specification.feature}}:{})},
|
|
450
463
|
!Object.hasOwn(original,'ignorePolicy'),original.ignorePolicy?.version??2,
|
|
451
464
|
original.ignorePolicy?.version===2?original.ignorePolicy:null);
|
|
@@ -552,6 +565,7 @@ export function createTaskRunner(options) {
|
|
|
552
565
|
};
|
|
553
566
|
const status=()=>{
|
|
554
567
|
let current=store?publication:privateStatus();
|
|
568
|
+
if(parsedHistory?.scopeRevisions)current=freeze({...current,effectiveScope});
|
|
555
569
|
if(current.state==='unknown'&&commitRecoveryTransaction()!==null){
|
|
556
570
|
const {reason:discard,...rest}=current;
|
|
557
571
|
current=freeze({...rest,state:'blocked',code:COMMIT_INTERRUPTED_CODE,reason:COMMIT_INTERRUPTED_REASON});
|
|
@@ -596,7 +610,7 @@ export function createTaskRunner(options) {
|
|
|
596
610
|
if((current.state==='unknown'||current.state==='blocked'&&['failed','unavailable'].includes(current.code))&&gapsLive()
|
|
597
611
|
&&(options.providerDevelopment!==true||providerRun)){
|
|
598
612
|
const limit=answerGapLimit({state,code,attempt,cache:[...cache.values()],calls,receipt,learningResult,taskCommit,reviewPackage,priorReview},
|
|
599
|
-
metadata,{developRecheck:answerGapCount('develop-recheck'),completeRecheck:answerGapCount('complete-recheck'),
|
|
613
|
+
metadata,{developRecheck:answerGapCount('develop-recheck'),developRecheckRecovery:parsedHistory?.developRecheckRecovery,completeRecheck:answerGapCount('complete-recheck'),
|
|
600
614
|
developRedo:answerGapCount('develop-answer-redo'),developDispatch:answerGapCount('develop-dispatch-retry'),
|
|
601
615
|
documentationSync:documentationRetries(),
|
|
602
616
|
workers:parsedHistory?.workers??null});
|
|
@@ -660,6 +674,10 @@ export function createTaskRunner(options) {
|
|
|
660
674
|
}
|
|
661
675
|
if(current.state!=='fixture_completed')return current;
|
|
662
676
|
try {
|
|
677
|
+
if(acceptedIntegration){
|
|
678
|
+
inspectAcceptedIntegration(acceptedIntegration);
|
|
679
|
+
return freeze({...current,acceptedIntegrationDigest:acceptedIntegration.planDigest});
|
|
680
|
+
}
|
|
663
681
|
if(acceptedFixes.length){
|
|
664
682
|
for(const item of acceptedFixes){
|
|
665
683
|
const {handoffDigest,...binding}=item.evidence.qaSource;
|
|
@@ -683,7 +701,8 @@ export function createTaskRunner(options) {
|
|
|
683
701
|
const handoff=handoffBinding().handoffPath;
|
|
684
702
|
need(digest(readReviewSourceFiles(path.dirname(handoff),[path.basename(handoff)])[0])===digest(reviewPackage.handoff),'package_mismatch');
|
|
685
703
|
}
|
|
686
|
-
explainCompletedDelivery({root:config.root,baseline:base,parentPackage:reviewPackage,deliveries:laterDeliveries(),after:reviewedAt()
|
|
704
|
+
explainCompletedDelivery({root:config.root,baseline:base,parentPackage:reviewPackage,deliveries:laterDeliveries(),after:reviewedAt(),
|
|
705
|
+
since:firstReviewAt(journal,config.identity)});
|
|
687
706
|
}
|
|
688
707
|
return current;
|
|
689
708
|
} catch(error){
|
|
@@ -694,7 +713,7 @@ export function createTaskRunner(options) {
|
|
|
694
713
|
};
|
|
695
714
|
const halt=(next,why,detail=null)=>{state=next;code=why;reason=detail;};
|
|
696
715
|
function assertReadyBaseline(){
|
|
697
|
-
compareReviewBaseline(withBoundSpecification(captureReviewBaseline({...configToBaseline(
|
|
716
|
+
compareReviewBaseline(withBoundSpecification(captureReviewBaseline({...configToBaseline(effectiveMetadata()),version:original.version,
|
|
698
717
|
...(Object.hasOwn(original,'specification')?{specification:{specsRoot:original.specificationRoot,feature:original.specification.feature}}:{})},
|
|
699
718
|
!Object.hasOwn(original,'ignorePolicy'),original.ignorePolicy?.version??2,
|
|
700
719
|
original.ignorePolicy?.version===2?original.ignorePolicy:null)),original);
|
|
@@ -717,15 +736,29 @@ export function createTaskRunner(options) {
|
|
|
717
736
|
same(current.identity,storeIdentity,'identity_mismatch');same(current.fingerprints,completion.fingerprints,'identity_mismatch');
|
|
718
737
|
need(current.revision===storeRevision,'runner_store_changed');need(!poisoned,'store_failure');return current;
|
|
719
738
|
}
|
|
739
|
+
const packageMaterialEnabled=()=>packageMaterialEligible(metadata,version);
|
|
740
|
+
function checkpointReserve(checkpoint){
|
|
741
|
+
if(!checkpoint.reviewPackage)return 0;
|
|
742
|
+
const size=value=>Buffer.byteLength(JSON.stringify(value??null));
|
|
743
|
+
return developCheckpointReserve({examinedPathsBytes:size(reviewPaths(checkpoint.reviewPackage)),
|
|
744
|
+
receiptsBytes:size(checkpoint.receipts),callsBytes:size(checkpoint.calls),writebackBytes:size(checkpoint.learningResult?.writeback)});
|
|
745
|
+
}
|
|
720
746
|
function candidate(type,fields){
|
|
747
|
+
if(['effect-checkpoint','review-invocation-reconciled'].includes(type)&&packageMaterialEnabled()){
|
|
748
|
+
const plan=checkpointStoragePlan({records:journal,effectId:fields.effectId,checkpoint:fields.checkpoint,
|
|
749
|
+
identity:{...config.identity,attempt:fields.checkpoint.attempt},enabled:packageMaterialEnabled(),
|
|
750
|
+
reserve:checkpointReserve(fields.checkpoint),type,
|
|
751
|
+
binding:type==='effect-checkpoint'?{}:Object.fromEntries(['invocationId','registeredDigest','startedDigest','resultDigest','receiptDigest'].map(key=>[key,fields[key]]))});
|
|
752
|
+
fields={...fields,checkpoint:plan.checkpoint,...plan.payloadFields};
|
|
753
|
+
}
|
|
721
754
|
const basic={id:`runner.${String(journal.length+1).padStart(6,'0')}`,
|
|
722
755
|
kind:{init:'result','effect-intent':'intent','effect-checkpoint':'result',control:'cancel',
|
|
723
756
|
'task-commit-intent':'commit-intent','task-commit-result':'commit-result',
|
|
724
757
|
'review-invocation-registered':'intent','review-invocation-started':'result','review-invocation-result':'result',
|
|
725
758
|
'review-invocation-abandoned':'result','review-invocation-receipt':'result','review-invocation-reconciled':'result','effect-abandoned':'result',
|
|
726
|
-
'host-joined':'result','qa-fix-accepted':'result','qa-attached':'result','qa-config-revised':'result',
|
|
759
|
+
'host-joined':'result','qa-fix-accepted':'result','reviewed-integration-accepted':'result','qa-attached':'result','qa-config-revised':'result',
|
|
727
760
|
'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',
|
|
728
|
-
'bootstrap-review-recovered':'result'}[type],
|
|
761
|
+
'completion-rework-requested':'result','development-rework-authorized':'result','scope-revised':'result','bootstrap-review-recovered':'result'}[type],
|
|
729
762
|
payload:version===3?runnerPayloadV3(type,fields):runnerPayload(type,fields,version)};
|
|
730
763
|
const body={version:1,seq:journal.length+1,...basic,previousDigest:journal.at(-1)?.digest??null};
|
|
731
764
|
const record={...body,digest:digest(body)};boundRunnerRecord(record,body.seq);
|
|
@@ -880,6 +913,7 @@ export function createTaskRunner(options) {
|
|
|
880
913
|
call.terminal=response.status;call.effectiveModel=response.effectiveModel;call.resultDigest=digest(response.result);
|
|
881
914
|
if(role==='developer'&&response.status==='failed'&&response.result!==null)call.failureResult=response.result;
|
|
882
915
|
if(role==='developer'&&Object.hasOwn(response,'blockedReason'))call.blockedReason=response.blockedReason;
|
|
916
|
+
if(role==='developer'&&Object.hasOwn(response,'failureCode'))call.failureCode=response.failureCode;
|
|
883
917
|
if(Object.hasOwn(response,'providerThreadId'))call.providerThreadId=response.providerThreadId;
|
|
884
918
|
return {request,response,call};
|
|
885
919
|
} catch(error){call.terminal=state==='cancelled'?'cancelled':'unknown';throw error;}
|
|
@@ -1102,7 +1136,8 @@ export function createTaskRunner(options) {
|
|
|
1102
1136
|
}
|
|
1103
1137
|
async function collectChecks(){
|
|
1104
1138
|
const before=new Map(captureReviewInventory(config.root,base).map(file=>[file.path,file.sha256]));
|
|
1105
|
-
const results=json(await bounded(check,json({identity:{...config.identity,attempt}
|
|
1139
|
+
const results=json(await bounded(check,json({identity:{...config.identity,attempt},
|
|
1140
|
+
...(parsedHistory?.scopeRevisions?{scope:effectiveScope}: {})})));
|
|
1106
1141
|
validChecks(results);
|
|
1107
1142
|
const after=captureReviewInventory(config.root,base);
|
|
1108
1143
|
checkNewPaths=new Set(after.filter(file=>!before.has(file.path)).map(file=>file.path));
|
|
@@ -1117,7 +1152,22 @@ export function createTaskRunner(options) {
|
|
|
1117
1152
|
// Runs on the checks just collected, before any handoff or review package is
|
|
1118
1153
|
// built, so a deliverable that does not satisfy the task's own written
|
|
1119
1154
|
// verification never spends an independent review round.
|
|
1155
|
+
// The scope as the task baseline recorded it when the run was created: durable,
|
|
1156
|
+
// so a resumed process still knows the state before any development. The host
|
|
1157
|
+
// replay restores it as "before development" (host-replay.mjs). A scope file
|
|
1158
|
+
// the baseline holds without content makes it unavailable, never partial.
|
|
1159
|
+
function baselineSnapshot(){
|
|
1160
|
+
const files=new Map();
|
|
1161
|
+
for(const file of effectiveScope){
|
|
1162
|
+
const record=base.files.find(item=>item.path===file);
|
|
1163
|
+
if(!record){files.set(file,null);continue;}
|
|
1164
|
+
if(record.type!=='file'||typeof record.contentBase64!=='string')return {unavailable:'baseline_without_content'};
|
|
1165
|
+
files.set(file,{bytes:Buffer.from(record.contentBase64,'base64'),mode:record.mode});
|
|
1166
|
+
}
|
|
1167
|
+
return {files};
|
|
1168
|
+
}
|
|
1120
1169
|
async function verificationSatisfied(checks) {
|
|
1170
|
+
requirementEvidence=null;hostReplayEvidence=null;
|
|
1121
1171
|
if(verificationGate===null)return true;
|
|
1122
1172
|
// The description carries hard requirements too ("also confirm X/Y/Z do not
|
|
1123
1173
|
// regress", "do not modify A"), and a gate that reads only the verification
|
|
@@ -1131,20 +1181,30 @@ export function createTaskRunner(options) {
|
|
|
1131
1181
|
const verdict=json(await bounded(verificationGate,
|
|
1132
1182
|
json({identity:{...config.identity,attempt},
|
|
1133
1183
|
...(written(description)?{description}:{}),
|
|
1134
|
-
...(written(verification)?{verification}:{}),checks
|
|
1135
|
-
|
|
1184
|
+
...(written(verification)?{verification}:{}),checks,
|
|
1185
|
+
...(parsedHistory?.scopeRevisions?{scope:effectiveScope}: {})}),{baselineSnapshot:baselineSnapshot()}));
|
|
1186
|
+
shape(verdict,['satisfied',...['items','hostRecord'].filter(key=>Object.hasOwn(verdict,key))]);
|
|
1187
|
+
need(typeof verdict.satisfied==='boolean','invalid_result');
|
|
1188
|
+
need(verdict.satisfied||!Object.hasOwn(verdict,'items')&&!Object.hasOwn(verdict,'hostRecord'),'invalid_result');
|
|
1189
|
+
// The host's own replay record (host-replay.mjs) is a separate handoff entry.
|
|
1190
|
+
hostReplayEvidence=Object.hasOwn(verdict,'hostRecord')
|
|
1191
|
+
?encodeHostReplayEvidence({identity:{...config.identity,attempt},facts:verdict.hostRecord}):null;
|
|
1192
|
+
// A satisfied gate may return its per-requirement answers; they become one
|
|
1193
|
+
// handoff evidence entry bound to this identity and attempt.
|
|
1194
|
+
requirementEvidence=Object.hasOwn(verdict,'items')
|
|
1195
|
+
?encodeRequirementEvidence({identity:{...config.identity,attempt},items:verdict.items}):null;
|
|
1136
1196
|
return verdict.satisfied;
|
|
1137
1197
|
}
|
|
1138
1198
|
// Attempt 2 exists to answer the findings that rejected attempt 1. Code
|
|
1139
1199
|
// byte-identical to that rejected artifact cannot, so it never spends the
|
|
1140
1200
|
// last review round; the same attempt may deliver again under a new effect id.
|
|
1141
1201
|
function unchangedSinceRejection(){
|
|
1142
|
-
if(attempt!==2
|
|
1143
|
-
const rejected=receipts.findLast(item=>item.identity.attempt===1&&item.result.verdict
|
|
1202
|
+
if(attempt!==2||!['changes_requested','approved'].includes(priorReview?.verdict))return null;
|
|
1203
|
+
const rejected=receipts.findLast(item=>item.identity.attempt===1&&['changes_requested','approved'].includes(item.result.verdict));
|
|
1144
1204
|
if(!rejected)return null;
|
|
1145
1205
|
const candidate=createReviewPackage({root:config.root,baseline:base,checks:currentChecks});
|
|
1146
1206
|
return candidate.artifactDigest===rejected.artifactDigest
|
|
1147
|
-
?`develop_unchanged_after_review: 第 2 轮交付与第 1
|
|
1207
|
+
?`develop_unchanged_after_review: 第 2 轮交付与第 1 轮已审代码逐字节相同(artifactDigest ${rejected.artifactDigest.slice(0,12)});按审查 findings 修改后重新交付`:null;
|
|
1148
1208
|
}
|
|
1149
1209
|
// A delivery that changes nothing in scope has no review package to build. It
|
|
1150
1210
|
// is the delivery that must be redone, exactly like failed checks, not an
|
|
@@ -1155,7 +1215,7 @@ export function createTaskRunner(options) {
|
|
|
1155
1215
|
// packaged (every requirement must exist), which is again a delivery to redo.
|
|
1156
1216
|
// Only in-scope requirements qualify: touching any other file stays out_of_scope,
|
|
1157
1217
|
// which the package builder reports before it ever reads the requirements.
|
|
1158
|
-
const missingScopeRequirements=()=>
|
|
1218
|
+
const missingScopeRequirements=()=>effectiveScope.filter(p=>config.requirements.includes(p)).filter(p=>{
|
|
1159
1219
|
try{const stat=fs.lstatSync(path.join(config.root,p));return !stat.isFile()||stat.isSymbolicLink();}
|
|
1160
1220
|
catch(error){if(error.code==='ENOENT'||error.code==='ENOTDIR')return true;throw error;}
|
|
1161
1221
|
});
|
|
@@ -1189,7 +1249,19 @@ export function createTaskRunner(options) {
|
|
|
1189
1249
|
try{unchanged=unchangedSinceRejection();}catch(error){emptyDelivery(error);return false;}
|
|
1190
1250
|
if(unchanged){halt('blocked','develop_unchanged_after_review',unchanged);return false;}
|
|
1191
1251
|
try{createHostHandoff({root:config.root,baseline:base,checks:currentChecks,
|
|
1192
|
-
handoffPath:completion.handoffs[attempt-1]
|
|
1252
|
+
handoffPath:completion.handoffs[attempt-1],evidence:[...journal.filter(row=>row.payload.type==='completion-rework-requested')
|
|
1253
|
+
.map(row=>'cm-completion-rework-v1: '+JSON.stringify({identity:{...config.identity,attempt:2},recordDigest:row.digest})),
|
|
1254
|
+
...(requirementEvidence===null?[]:[requirementEvidence]),...(hostReplayEvidence===null?[]:[hostReplayEvidence])]});}
|
|
1255
|
+
catch(error){emptyDelivery(error);return false;}
|
|
1256
|
+
return true;
|
|
1257
|
+
}
|
|
1258
|
+
// The Learning evidence is appended to the handoff hostDeliveryChecks just
|
|
1259
|
+
// published. A delivery whose handoff fit before the append and not after
|
|
1260
|
+
// (requirement evidence makes that reachable) is the same retryable package
|
|
1261
|
+
// block as an oversized initial handoff, never an unknown effect.
|
|
1262
|
+
function appendLearningHandoff(v,{application,retrospective,writeback}){
|
|
1263
|
+
try{writeCmAiTaskLearningHandoff({handoffPath:completion.handoffs[attempt-1],feature:taskLearning.feature,
|
|
1264
|
+
identity:{...config.identity,attempt},learningInput:v.learningInput,application,retrospective,writeback});}
|
|
1193
1265
|
catch(error){emptyDelivery(error);return false;}
|
|
1194
1266
|
return true;
|
|
1195
1267
|
}
|
|
@@ -1244,9 +1316,7 @@ export function createTaskRunner(options) {
|
|
|
1244
1316
|
// the checks, the precheck, the handoff and the package. No developer call.
|
|
1245
1317
|
if(recheck){
|
|
1246
1318
|
if(!await hostDeliveryChecks())return;
|
|
1247
|
-
|
|
1248
|
-
identity:{...config.identity,attempt},learningInput:v.learningInput,application:learningResult.application,
|
|
1249
|
-
retrospective:learningResult.retrospective,writeback:learningResult.writeback});
|
|
1319
|
+
if(!appendLearningHandoff(v,learningResult))return;
|
|
1250
1320
|
await packageDelivery(v);return;
|
|
1251
1321
|
}
|
|
1252
1322
|
const previousLearning=learningResult;
|
|
@@ -1266,7 +1336,7 @@ export function createTaskRunner(options) {
|
|
|
1266
1336
|
const adapter=bootstrap===null?developer:{...developer,run:(request,control)=>
|
|
1267
1337
|
bootstrap.run(request,control,developer.run,{previous:previousBootstrap,previousWriteback,baseline:original,
|
|
1268
1338
|
verificationFailed:detail=>{verificationReason=detail;}})};
|
|
1269
|
-
const result=await invoke(adapter,'developer',developer.contextId,{scope:
|
|
1339
|
+
const result=await invoke(adapter,'developer',developer.contextId,{scope:effectiveScope,
|
|
1270
1340
|
requirements:original.files.filter(f=>config.requirements.includes(f.path)),priorReview,
|
|
1271
1341
|
...supersededReviewPayload(carriedReview,attempt),
|
|
1272
1342
|
...(Object.hasOwn(original,'specification')?{specification:verifySpecificationMaterial(original)}:{}),
|
|
@@ -1307,8 +1377,7 @@ export function createTaskRunner(options) {
|
|
|
1307
1377
|
learningResult=freeze({application,retrospective,writeback,...(instructionEvidence?{bootstrap:instructionEvidence}:{})});
|
|
1308
1378
|
if(writeback.outcome==='writeback_pending'){halt('blocked','learning_writeback_pending');return;}
|
|
1309
1379
|
if(taskLearning.hostHandoff===true&&!await hostDeliveryChecks())return;
|
|
1310
|
-
|
|
1311
|
-
identity:{...config.identity,attempt},learningInput:v.learningInput,application,retrospective,writeback});
|
|
1380
|
+
if(!appendLearningHandoff(v,{application,retrospective,writeback}))return;
|
|
1312
1381
|
}
|
|
1313
1382
|
need(result.response.result.outcome==='implemented','invalid_result');
|
|
1314
1383
|
if(taskLearning?.hostHandoff!==true){
|
|
@@ -1378,9 +1447,9 @@ export function createTaskRunner(options) {
|
|
|
1378
1447
|
// No delivery can still be reviewed: journal the terminal limit instead of an
|
|
1379
1448
|
// intent, so no developer call runs (see developBudgetExhausted).
|
|
1380
1449
|
const retryLimitDue=()=>invocationMode&&store&&!poisoned
|
|
1381
|
-
&&developBudgetExhausted({state,code,priorReview,calls,cache:[...cache.values()]});
|
|
1450
|
+
&&developBudgetExhausted({state,code,attempt,priorReview,calls,cache:[...cache.values()]},parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework);
|
|
1382
1451
|
function recordRetryLimit(){
|
|
1383
|
-
const used=developBudget({calls,cache:[...cache.values()]});
|
|
1452
|
+
const used=developBudget({calls,cache:[...cache.values()]},parsedHistory?.developRecheckEffects,parsedHistory?.developmentRework);
|
|
1384
1453
|
persist('develop-retry-limit',{fromState:state,fromCode:code,countedCalls:used.calls,countedEffects:used.effects});
|
|
1385
1454
|
const recovered=readRunnerHistory(journal,metadata,3).state;
|
|
1386
1455
|
({state,code}=recovered);reason=recovered.reason??null;publication=privateStatus();return publication;
|
|
@@ -1422,6 +1491,7 @@ export function createTaskRunner(options) {
|
|
|
1422
1491
|
if(v.kind==='develop'&&(recheck!==null||state==='blocked'&&RECHECK_CODES.includes(code)))
|
|
1423
1492
|
need(digest(v.learningInput)===digest([...cache.values()].at(-1).effect.learningInput),'runner_learning');
|
|
1424
1493
|
if(v.kind==='complete'&&state==='unknown'&&completeRecheck())completeSource=code;
|
|
1494
|
+
if(recheck!==null||completeSource!==null)need(!cancellationRequested&&!cancelAfterCommit&&!workflowError,'cancelled');
|
|
1425
1495
|
if(v.kind==='develop'&&state==='unknown'&&recheck===null)dispatchBasis=developDispatchRetry();
|
|
1426
1496
|
// Q16/Q17: re-ask only documentation_sync; refused (nothing journaled)
|
|
1427
1497
|
// while the code root outside the documentation paths changed, or while a
|
|
@@ -1444,7 +1514,8 @@ export function createTaskRunner(options) {
|
|
|
1444
1514
|
}
|
|
1445
1515
|
answerRetry=v.kind==='develop'&&state==='blocked'&&code==='failed'&&answerRetryable();
|
|
1446
1516
|
need(timeoutBasis!==null||answerRetry||recheck!==null||completeSource!==null||dispatchBasis!==null
|
|
1447
|
-
||stageAllowed(v.kind,state,code,priorReview?.verdict),'stage_mismatch');need(effectSlotFree(v.kind,[...cache.values()],calls),'limit_exceeded');
|
|
1517
|
+
||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');
|
|
1518
|
+
if(v.kind==='develop'&&parsedHistory?.developmentRework&&!parsedHistory.developmentRework.developerConsumed)need(digest(captureReviewInventory(config.root,original,{withMode:true}))===parsedHistory.developmentRework.sourceDigest,'development_rework_source_changed');
|
|
1448
1519
|
if(Object.hasOwn(original,'specification'))verifySpecificationMaterial(original);
|
|
1449
1520
|
if(v.kind==='develop'&&bootstrap!==null)bootstrap.assertWriteAuthorized();
|
|
1450
1521
|
} catch(error){return Promise.resolve(freeze({outcome:'rejected',code:error.code??'invalid_input',
|
|
@@ -1473,6 +1544,9 @@ export function createTaskRunner(options) {
|
|
|
1473
1544
|
catch{return Promise.resolve(poison());}
|
|
1474
1545
|
halt('blocked',COMPLETE_RECHECK_CODE,completeRecheckReason(completeSource));publication=privateStatus();
|
|
1475
1546
|
}
|
|
1547
|
+
// A check timeout aborted its signal, not the accepted delivery or review.
|
|
1548
|
+
// Only these journaled check-only recoveries receive a fresh controller.
|
|
1549
|
+
if(recheck!==null||completeSource!==null)controller=new AbortController();
|
|
1476
1550
|
if(answerRetry){
|
|
1477
1551
|
try{persist('develop-answer-retry',{effectId:[...cache.values()].at(-1).effect.id,invocationId:calls.at(-1).invocationId});}
|
|
1478
1552
|
catch{return Promise.resolve(poison());}
|
|
@@ -1526,7 +1600,10 @@ export function createTaskRunner(options) {
|
|
|
1526
1600
|
const reserve=developCheckpointReserve({examinedPathsBytes:size(reviewPaths(reviewPackage)),
|
|
1527
1601
|
receiptsBytes:size(receipts),callsBytes:size(calls),writebackBytes:size(learningResult?.writeback)});
|
|
1528
1602
|
const budget=JOURNAL_PAYLOAD_LIMIT-reserve;
|
|
1529
|
-
|
|
1603
|
+
const enabled=packageMaterialEnabled();
|
|
1604
|
+
const capacity=enabled?checkpointPackageBudget({inlineBytes:bytes,packageBytes:size(reviewPackage),reserve,enabled,
|
|
1605
|
+
referenced:packageMaterialReference(journal,reviewPackage,{...config.identity,attempt})!==null}):{fits:bytes<=budget};
|
|
1606
|
+
if(!capacity.fits){
|
|
1530
1607
|
const changed=reviewPackage.changes.filter(change=>change.after).map(change=>change.after);
|
|
1531
1608
|
reviewPackage=packageBefore;
|
|
1532
1609
|
halt('blocked','develop_package_too_large',boundedReason(`develop_package_too_large: the review checkpoint would be ${bytes} bytes, `
|
|
@@ -1613,8 +1690,48 @@ export function createTaskRunner(options) {
|
|
|
1613
1690
|
}
|
|
1614
1691
|
return status();
|
|
1615
1692
|
}
|
|
1693
|
+
function inspectAcceptedIntegration(record){
|
|
1694
|
+
const {evidence,reference}=readIntegrationEvidenceFile(record.reviewFile.path);
|
|
1695
|
+
same(reference,record.reviewFile,'integration_evidence_changed');
|
|
1696
|
+
same(evidence.plan,record.plan,'integration_evidence_changed');
|
|
1697
|
+
if(reviewPackage.handoff){
|
|
1698
|
+
const handoff=handoffBinding().handoffPath;
|
|
1699
|
+
need(digest(readReviewSourceFiles(path.dirname(handoff),[path.basename(handoff)])[0])===digest(reviewPackage.handoff),'package_mismatch');
|
|
1700
|
+
}
|
|
1701
|
+
return verifyReviewedIntegration({root:config.root,specsRoot:completion.owner.specsRoot,
|
|
1702
|
+
baseline:base,parentPackage:reviewPackage,records:journal.slice(0,record.plan.target.recordCount),...evidence});
|
|
1703
|
+
}
|
|
1704
|
+
// Launch-only authority. The existing owner holds the store lock; evidence
|
|
1705
|
+
// never grants itself permission. No provider, QA, commit, or product write.
|
|
1706
|
+
const acceptReviewedIntegration=raw=>{
|
|
1707
|
+
try{
|
|
1708
|
+
shape(raw,['allowed','evidenceFile','expectedDigest']);
|
|
1709
|
+
need(raw.allowed===true,'integration_authorization_required');
|
|
1710
|
+
need(invocationMode&&store&&completion&&!busy&&!poisoned&&!restored?.pending
|
|
1711
|
+
&&state==='fixture_completed'&&acceptedFixes.length===0,'integration_parent_not_completed');
|
|
1712
|
+
currentStore();
|
|
1713
|
+
const {evidence,reference}=readIntegrationEvidenceFile(raw.evidenceFile);
|
|
1714
|
+
need(raw.expectedDigest===digest(evidence.plan),'integration_target_changed');
|
|
1715
|
+
if(acceptedIntegration){
|
|
1716
|
+
same(acceptedIntegration.plan,evidence.plan,'integration_target_changed');
|
|
1717
|
+
same(acceptedIntegration.reviewFile,reference,'integration_evidence_changed');
|
|
1718
|
+
inspectAcceptedIntegration(acceptedIntegration);return status();
|
|
1719
|
+
}
|
|
1720
|
+
const record=validateIntegrationRecord({record:{version:1,plan:evidence.plan,reviewFile:reference,
|
|
1721
|
+
reason:'Explicit reviewed integration',planDigest:raw.expectedDigest},
|
|
1722
|
+
baseline:base,parentPackage:reviewPackage,records:journal});
|
|
1723
|
+
inspectAcceptedIntegration(record);
|
|
1724
|
+
// Re-read exact evidence after all source, Git, and inventory checks.
|
|
1725
|
+
same(readIntegrationEvidenceFile(raw.evidenceFile).reference,reference,'integration_evidence_changed');
|
|
1726
|
+
assertJournalFits('reviewed-integration-accepted',{record},'integration_storage_limit');
|
|
1727
|
+
persist('reviewed-integration-accepted',{record});acceptedIntegration=record;
|
|
1728
|
+
return status();
|
|
1729
|
+
}catch(error){return freeze({outcome:'rejected',code:error?.code??'integration_evidence_invalid',
|
|
1730
|
+
...(Array.isArray(error.paths)?{reason:error.paths.join(', ').slice(0,8192)}:{})});}
|
|
1731
|
+
};
|
|
1616
1732
|
// Read-only content comparison, not completion authority or a JSON operation.
|
|
1617
1733
|
const inspectFixAssociation=(fixPackage,evidence=null)=>{
|
|
1734
|
+
need(acceptedIntegration===null,'integration_fix_unsupported');
|
|
1618
1735
|
need(!busy&&!poisoned,'host_busy');
|
|
1619
1736
|
const current=status();
|
|
1620
1737
|
need(current.state==='fixture_completed'&¤t.code!=='review_publication_required','qa_fix_parent_not_completed');
|
|
@@ -1905,6 +2022,82 @@ export function createTaskRunner(options) {
|
|
|
1905
2022
|
}catch(error){return freeze({outcome:'rejected',code:poisoned?'store_failure':error.code??'develop_redo_unavailable',
|
|
1906
2023
|
...(!poisoned&&error.reason?{reason:error.reason}:{})});}
|
|
1907
2024
|
};
|
|
2025
|
+
const reviseScope=raw=>{
|
|
2026
|
+
try{
|
|
2027
|
+
need(invocationMode&&store&&!busy&&!poisoned&&options.persistence.mode==='resume'
|
|
2028
|
+
&&options.providerDevelopment!==true&&options.protectedDevelopment!==true,'scope_revision_unavailable');
|
|
2029
|
+
const value=json(raw);shape(value,['allowed','reason','scope']);need(value.allowed===true,'scope_revision_authorization_required');
|
|
2030
|
+
const history=readRunnerHistory(journal,metadata,3);
|
|
2031
|
+
need(history.pending===null&&history.transaction===null,'scope_revision_unavailable');
|
|
2032
|
+
const binding=scopeRevisionBinding(history.state,effectiveMetadata(),history.scopeRevisions);
|
|
2033
|
+
need(!developBudgetExhausted(history.state,history.developRecheckEffects),'scope_revision_budget_exhausted');
|
|
2034
|
+
const rows=taskDeclarations(fs.readFileSync(completion.owner.tasksPath,'utf8'),
|
|
2035
|
+
{grammar:approvedTaskGrammar(completion.owner.specsRoot)}).filter(item=>item.id===config.identity.taskId);
|
|
2036
|
+
need(rows.length===1&&!rows[0].completed,'scope_revision_task_completed');
|
|
2037
|
+
if(Object.hasOwn(original,'specification'))verifySpecificationMaterial(original);
|
|
2038
|
+
const scope=revisedScope(value.scope,effectiveScope);
|
|
2039
|
+
const files=captureScopeRevisionSources(config.root,original,scope);
|
|
2040
|
+
const record={fromDigest:journal.at(-1).digest,...binding,baselineDigest:original.baselineDigest,
|
|
2041
|
+
scope,files,reason:value.reason,at:new Date().toISOString()};
|
|
2042
|
+
applyScopeRevision(history.state,effectiveMetadata(),original,record,history.scopeRevisions);
|
|
2043
|
+
assertJournalFits('scope-revised',record,'scope_revision_too_large');
|
|
2044
|
+
persist('scope-revised',record);
|
|
2045
|
+
original=parsedHistory.original;effectiveScope=parsedHistory.effectiveScope;scopeRevisionPaths=original.scopeRevisionPaths;
|
|
2046
|
+
base=attemptBaseline(original,attempt);publication=privateStatus();return status();
|
|
2047
|
+
}catch(error){return freeze({outcome:'rejected',code:poisoned?'store_failure':error.code??'scope_revision_unavailable'});}
|
|
2048
|
+
};
|
|
2049
|
+
const reworkDevelopment=raw=>{
|
|
2050
|
+
try{
|
|
2051
|
+
need(invocationMode&&store&&!busy&&!poisoned&&options.persistence.mode==='resume'
|
|
2052
|
+
&&options.providerDevelopment!==true&&options.protectedDevelopment!==true,'development_rework_unavailable');
|
|
2053
|
+
const value=json(raw);shape(value,['allowed','reason']);need(value.allowed===true,'development_rework_authorization_required');
|
|
2054
|
+
const history=readRunnerHistory(journal,metadata,3);
|
|
2055
|
+
need(history.pending===null&&history.transaction===null,'development_rework_unavailable');
|
|
2056
|
+
const effectiveConfig={...metadata,scope:effectiveScope};
|
|
2057
|
+
const binding=developmentReworkBinding(journal,history.state,effectiveConfig,original,
|
|
2058
|
+
history.developRecheckEffects,history.developmentRework);
|
|
2059
|
+
const rows=taskDeclarations(fs.readFileSync(completion.owner.tasksPath,'utf8'),
|
|
2060
|
+
{grammar:approvedTaskGrammar(completion.owner.specsRoot)}).filter(item=>item.id===config.identity.taskId);
|
|
2061
|
+
need(rows.length===1&&!rows[0].completed,'development_rework_task_completed');
|
|
2062
|
+
if(Object.hasOwn(original,'specification'))verifySpecificationMaterial(original);
|
|
2063
|
+
for(const file of [completion.handoffs[1],path.join(completion.reviewsDir,
|
|
2064
|
+
completion.owner.feature.replace(/^\d+\./,'')+'-'+config.identity.taskId+'-r2.md')]){
|
|
2065
|
+
try{fs.lstatSync(file);need(false,'development_rework_evidence_exists');}
|
|
2066
|
+
catch(error){if(error.code!=='ENOENT')throw error;}
|
|
2067
|
+
}
|
|
2068
|
+
const record={fromDigest:journal.at(-1).digest,...binding,effectCredit:1,
|
|
2069
|
+
sourceDigest:digest(captureReviewInventory(config.root,original,{withMode:true})),reason:value.reason,at:new Date().toISOString()};
|
|
2070
|
+
applyDevelopmentRework(journal,history.state,effectiveConfig,original,record,history.developRecheckEffects,history.developmentRework);
|
|
2071
|
+
persist('development-rework-authorized',record);
|
|
2072
|
+
({state,code,reason}=parsedHistory.state);publication=privateStatus();return status();
|
|
2073
|
+
}catch(error){return freeze({outcome:'rejected',code:poisoned?'store_failure':error.code??'development_rework_unavailable'});}
|
|
2074
|
+
};
|
|
2075
|
+
const reworkCompletion=raw=>{
|
|
2076
|
+
try{
|
|
2077
|
+
need(invocationMode&&store&&!busy&&!poisoned&&options.persistence.mode==='resume'
|
|
2078
|
+
&&(options.parallelSelection??null)===null&&options.providerDevelopment!==true&&options.protectedDevelopment!==true,'completion_rework_unavailable');
|
|
2079
|
+
const value=json(raw);shape(value,['allowed','reason']);need(value.allowed===true,'completion_rework_authorization_required');
|
|
2080
|
+
const binding=completionReworkBinding(frame(),metadata);
|
|
2081
|
+
need(!readRunnerHistory(journal,metadata,3).pending,'completion_rework_unavailable');
|
|
2082
|
+
publishRegisteredReview(true);
|
|
2083
|
+
verifyReviewPackage({root:config.root,baseline:base,checks:currentChecks,reviewPackage,
|
|
2084
|
+
expectedDigest:binding.packageDigest,...handoffBinding()});
|
|
2085
|
+
const rows=taskDeclarations(fs.readFileSync(completion.owner.tasksPath,'utf8'),
|
|
2086
|
+
{grammar:approvedTaskGrammar(completion.owner.specsRoot)}).filter(item=>item.id===config.identity.taskId);
|
|
2087
|
+
need(rows.length===1&&!rows[0].completed,'completion_rework_task_completed');
|
|
2088
|
+
for(const file of [completion.handoffs[1],path.join(completion.reviewsDir,
|
|
2089
|
+
completion.owner.feature.replace(/^\d+\./,'')+'-'+config.identity.taskId+'-r2.md')]){
|
|
2090
|
+
try{fs.lstatSync(file);need(false,'completion_rework_evidence_exists');}
|
|
2091
|
+
catch(error){if(error.code!=='ENOENT')throw error;}
|
|
2092
|
+
}
|
|
2093
|
+
const record={...binding,fromAttempt:1,toAttempt:2,reason:value.reason,at:new Date().toISOString()};
|
|
2094
|
+
applyCompletionRework(frame(),metadata,record);
|
|
2095
|
+
persist('completion-rework-requested',record);
|
|
2096
|
+
const next=readRunnerHistory(journal,metadata,3).state;
|
|
2097
|
+
({state,code,attempt,receipt,reviewInvocation,reason}=next);
|
|
2098
|
+
base=attemptBaseline(original,attempt);publication=privateStatus();return publication;
|
|
2099
|
+
}catch(error){return freeze({outcome:'rejected',code:error.code??'completion_rework_unavailable'});}
|
|
2100
|
+
};
|
|
1908
2101
|
const recoverBootstrapReview=raw=>{
|
|
1909
2102
|
try{
|
|
1910
2103
|
need(invocationMode&&store&&!busy&&!poisoned&&options.persistence.mode==='resume',
|
|
@@ -1947,7 +2140,16 @@ export function createTaskRunner(options) {
|
|
|
1947
2140
|
need(state==='fixture_completed'&&reviewPackage?.packageDigest===packageDigest,'stale_qa');
|
|
1948
2141
|
return freeze({paths:reviewPackage.changes.map(change=>change.path),source:'review_package'});
|
|
1949
2142
|
};
|
|
1950
|
-
|
|
2143
|
+
// Read-only: the reviewed package's task checks, only while the code root
|
|
2144
|
+
// still matches that package, so a QA command may reuse an identical passed
|
|
2145
|
+
// check instead of running it again (host-qa-executor reuseCheck).
|
|
2146
|
+
const qaCompletionChecks=packageDigest=>{
|
|
2147
|
+
need(state==='fixture_completed'&&reviewPackage?.packageDigest===packageDigest,'stale_qa');
|
|
2148
|
+
verifyReviewPackage({root:config.root,baseline:attemptBaseline(original,reviewPackage.identity.attempt),
|
|
2149
|
+
checks:reviewPackage.checks,reviewPackage,expectedDigest:reviewPackage.packageDigest,...handoffBinding()});
|
|
2150
|
+
return freeze(structuredClone(reviewPackage.checks));
|
|
2151
|
+
};
|
|
2152
|
+
const api={qaChangedFiles,qaCompletionChecks,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};
|
|
1951
2153
|
if(bootstrap!==null)api.inspectBootstrapAdmission=()=>bootstrap.inspectAdmission(original);
|
|
1952
2154
|
if(taskLearning!==null)api.attachLearningEvidence=attachLearningEvidence;
|
|
1953
2155
|
// A terminal reviewer observation is durable even if the host died before
|
|
@@ -1971,6 +2173,7 @@ export function createTaskRunner(options) {
|
|
|
1971
2173
|
function configToBaseline(c){
|
|
1972
2174
|
const scope=Object.hasOwn(c,'taskLearning')?taskReviewScope(c.scope):c.scope;
|
|
1973
2175
|
return {root:c.root,identity:c.identity,scope,requirements:c.requirements,
|
|
2176
|
+
...(c.scopeRevisionPaths?{scopeRevisionPaths:c.scopeRevisionPaths}:{}),
|
|
1974
2177
|
...(c.codeProjectPaths?{codeProjectPaths:c.codeProjectPaths}:{}),
|
|
1975
2178
|
...(c.bootstrap?{bootstrapRequirements:c.bootstrap.bootstrapRequirements}:{}),
|
|
1976
2179
|
...(c.completion?{specsRoot:c.completion.owner.specsRoot}:{})};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// The verification gate answered by the host (control policy verification:"auto").
|
|
2
|
+
// It accepts the developer's per-requirement report only when every item is
|
|
3
|
+
// satisfied and no tagged item contradicts what the host itself ran
|
|
4
|
+
// (host-replay.mjs). It can only stop: a satisfied verdict still leaves the full
|
|
5
|
+
// independent review, which also reads the host's own replay record.
|
|
6
|
+
//
|
|
7
|
+
// Run claims are matched by their structured tag, never by reading free text:
|
|
8
|
+
// run "red" needs the test-files-only run to have run and failed; run "baseline"
|
|
9
|
+
// needs the baseline to have run (a run that could not start proves nothing) and,
|
|
10
|
+
// with a result, to have that result. An untagged item is not a run claim here.
|
|
11
|
+
// The same limit as the session-answered gate: coverage of every written
|
|
12
|
+
// requirement, and the tagging of every run claim, are not proven.
|
|
13
|
+
const ran=run=>run&&['passed','failed'].includes(run.outcome);
|
|
14
|
+
const redFact=facts=>facts.status!=='replayed'?`未实跑(${facts.reason})`
|
|
15
|
+
:facts.red.skipped?'tasks.md 未写测试文件,没有只放入测试文件的实跑'
|
|
16
|
+
:`只放入测试文件时检查 ${facts.red.outcome}`;
|
|
17
|
+
|
|
18
|
+
// report: the developer's items, null (absent) or 'invalid'. facts: replayDelivery's result.
|
|
19
|
+
export function autoVerificationVerdict({report,facts}){
|
|
20
|
+
if(report===null)return {satisfied:false,unsatisfied:['开发结果没有逐条要求与证据(requirements)']};
|
|
21
|
+
if(report==='invalid')return {satisfied:false,unsatisfied:['开发结果的逐条要求与证据(requirements)格式不合法']};
|
|
22
|
+
const unsatisfied=[],replayed=facts.status==='replayed';
|
|
23
|
+
for(const item of report){
|
|
24
|
+
if(item.satisfied!==true){unsatisfied.push(item.requirement);continue;}
|
|
25
|
+
if(item.run==='red'&&!(replayed&&!facts.red.skipped&&facts.red.outcome==='failed'))
|
|
26
|
+
unsatisfied.push(`${item.requirement}(标记为先失败,宿主实跑与此不符:${redFact(facts)})`);
|
|
27
|
+
if(item.run==='baseline'){
|
|
28
|
+
if(!replayed)unsatisfied.push(`${item.requirement}(标记为基线,宿主没有实跑基线:${facts.reason})`);
|
|
29
|
+
else if(!ran(facts.baseline))unsatisfied.push(`${item.requirement}(标记为基线,宿主基线没有跑起来:${facts.baseline.outcome})`);
|
|
30
|
+
else if(item.result&&item.result!==facts.baseline.outcome)
|
|
31
|
+
unsatisfied.push(`${item.requirement}(标记基线 ${item.result},宿主实跑基线 ${facts.baseline.outcome})`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// The runner stops at develop_checks_not_passed before this gate when the
|
|
35
|
+
// task's own checks fail; kept so the gate never passes a failed delivery.
|
|
36
|
+
if(facts.green.outcome!=='passed')unsatisfied.push(`宿主实跑:全部放入后检查 ${facts.green.outcome}`);
|
|
37
|
+
return unsatisfied.length?{satisfied:false,unsatisfied}:{satisfied:true,items:report};
|
|
38
|
+
}
|