@aibyzero/cm-workflow 0.17.0 → 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 +27 -0
- package/CHANGELOG.md +230 -1
- package/CONTRIBUTING.md +47 -0
- package/README.md +21 -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 +40 -13
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +153 -16
- 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 +94 -21
- 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 +24 -6
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +236 -34
- 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 +14 -6
- 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 +42 -9
- package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
- package/runtime/js/cm-ai/host-tool-bridge.mjs +22 -9
- 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 +63 -30
- 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 +247 -41
- 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 +38 -17
- 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 +12 -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 +27 -14
- 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 +483 -63
- 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 +82 -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-bootstrap-rules.test.mjs +3 -2
- package/scripts/cm-ai-drive.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +37 -5
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host-fixture.mjs +9 -6
- package/scripts/cm-ai-host-protected.test.mjs +1 -1
- package/scripts/cm-ai-host.mjs +60 -19
- package/scripts/cm-ai-host.test.mjs +15 -0
- 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 +71 -0
- 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-review-timeout.test.mjs +20 -0
- 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 +2 -2
- package/scripts/cm-check-host.test.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-probe.test.mjs +26 -0
- package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +49 -0
- package/scripts/cm-claude-worker.test.mjs +16 -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-drive-liveness.test.mjs +83 -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 +12 -9
- 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-diagnostic.test.mjs +33 -0
- package/scripts/cm-host-liveness.test.mjs +150 -0
- package/scripts/cm-host-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -0
- package/scripts/cm-host-stage-observer.test.mjs +41 -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 +625 -75
- 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 +46 -2
- 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 +16 -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-session-recovery.test.mjs +5 -3
- package/scripts/cm-prd-summary.test.mjs +55 -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 +3 -15
- 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-test-suite.mjs +109 -0
- package/scripts/cm-test-suite.test.mjs +162 -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/host-diagnostic.mjs +33 -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 +89 -17
- 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
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Driver-side wait-and-redispatch for a review the provider rate limited
|
|
2
|
+
// (reviewFailure reviewer_rate_limited, 2026-10-26: Codex 429 stopped a batch
|
|
3
|
+
// while the weekly quota was at 3%). It only re-runs the same driver command in
|
|
4
|
+
// resume mode, i.e. what a person does by saying "继续": the runner's own rules
|
|
5
|
+
// decide whether that dispatches a review. It never sends abandon_review, never
|
|
6
|
+
// spends a review round and needs no extra permission: the runner grants one
|
|
7
|
+
// automatic no-verdict redispatch per review round (pending_review), and a
|
|
8
|
+
// second rate limit in the same round comes back as blocked, which stops here.
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import {createHash} from 'node:crypto';
|
|
12
|
+
|
|
13
|
+
export const RATE_LIMIT_RETRY_ENV='CM_DRIVE_RATE_LIMIT_RETRY';
|
|
14
|
+
// SHA-256 of the PLAN bytes the waiting driver started from; a re-run reading
|
|
15
|
+
// other bytes stops before launching anything.
|
|
16
|
+
export const RATE_LIMIT_PLAN_DIGEST_ENV='CM_DRIVE_RATE_LIMIT_PLAN_DIGEST';
|
|
17
|
+
export const RATE_LIMIT_DELAYS_ENV='CM_DRIVE_RATE_LIMIT_DELAYS_MS';
|
|
18
|
+
// At most three waits, 15, 10 and 5 minutes, 30 minutes in all. The first is the
|
|
19
|
+
// longest: on 2026-10-26 the review succeeded when resumed about 15 minutes after
|
|
20
|
+
// the 429, and a round has only one automatic redispatch, so it should not be spent
|
|
21
|
+
// too early.
|
|
22
|
+
export const RATE_LIMIT_DEFAULT_DELAYS_MS=Object.freeze([900000,600000,300000]);
|
|
23
|
+
export const RATE_LIMIT_MAX_TOTAL_MS=1800000;
|
|
24
|
+
// Operations whose rate-limited stop is retried (cm-ai-conversation-entry.mjs: advance and
|
|
25
|
+
// decision dispatch the review; resume only reports the state and never dispatches).
|
|
26
|
+
// The single-task retry is a bound decision; the batch retry is the batch host's
|
|
27
|
+
// retry_review, checked under batch.lock and the member's writer lock.
|
|
28
|
+
// The retry itself is always a decision bound to the frozen stop (never the
|
|
29
|
+
// original advance), so it can only redispatch that one review.
|
|
30
|
+
export const RATE_LIMIT_RETRY_OPERATIONS=Object.freeze(['advance','decision']);
|
|
31
|
+
|
|
32
|
+
const obj=value=>value&&typeof value==='object'&&!Array.isArray(value)?value:{};
|
|
33
|
+
// Overridable (tests use milliseconds); anything out of range keeps the default.
|
|
34
|
+
export function rateLimitDelays(env=process.env){
|
|
35
|
+
const raw=env[RATE_LIMIT_DELAYS_ENV];
|
|
36
|
+
if(typeof raw!=='string'||!raw)return [...RATE_LIMIT_DEFAULT_DELAYS_MS];
|
|
37
|
+
const values=raw.split(',').map(item=>Number(item.trim()));
|
|
38
|
+
const valid=values.length>=1&&values.length<=3&&values.every(value=>Number.isSafeInteger(value)&&value>=1)
|
|
39
|
+
&&values.reduce((sum,value)=>sum+value,0)<=RATE_LIMIT_MAX_TOTAL_MS;
|
|
40
|
+
return valid?values:[...RATE_LIMIT_DEFAULT_DELAYS_MS];
|
|
41
|
+
}
|
|
42
|
+
export function rateLimitRetriesDone(env=process.env){
|
|
43
|
+
const value=Number(env[RATE_LIMIT_RETRY_ENV]);
|
|
44
|
+
return Number.isSafeInteger(value)&&value>=1&&value<=RATE_LIMIT_DEFAULT_DELAYS_MS.length?value:0;
|
|
45
|
+
}
|
|
46
|
+
// A rate-limited review end, whatever state the runner put it in.
|
|
47
|
+
export const rateLimitedReview=row=>!row?.error&&obj(row?.result).reviewFailure==='reviewer_rate_limited';
|
|
48
|
+
// Only the runner's own automatic redispatch state qualifies.
|
|
49
|
+
export const rateLimitRetryable=row=>{
|
|
50
|
+
const result=obj(row?.result);
|
|
51
|
+
// A refused (e.g. stale) request dispatched nothing and is never retried.
|
|
52
|
+
return rateLimitedReview(row)&&result.outcome!=='rejected'&&result.staleRetry!==true
|
|
53
|
+
&&result.state==='pending_review'&&result.code==='review_provider_failed'&&result.pendingAction==='resume';
|
|
54
|
+
};
|
|
55
|
+
// {attempt,max,delayMs} for the next wait, or null.
|
|
56
|
+
// kind 'batch': the batch driver, whose retry_review also needs the batch target.
|
|
57
|
+
export function nextRateLimitRetry(row,env=process.env,kind='single'){
|
|
58
|
+
const expected=expectedReviewStop(row);
|
|
59
|
+
if(!rateLimitRetryable(row)||expected===null||kind==='batch'&&!expected.batch)return null;
|
|
60
|
+
const delays=rateLimitDelays(env),done=rateLimitRetriesDone(env);
|
|
61
|
+
return done<delays.length?{attempt:done+1,max:delays.length,delayMs:delays[done]}:null;
|
|
62
|
+
}
|
|
63
|
+
// The re-run resumes the run the first command created (same session).
|
|
64
|
+
export function applyRateLimitResume(plan,env=process.env){
|
|
65
|
+
if(rateLimitRetriesDone(env)===0||plan?.mode!=='create')return plan;
|
|
66
|
+
plan.mode='resume';plan.originalHostContext=plan.hostContext;
|
|
67
|
+
return plan;
|
|
68
|
+
}
|
|
69
|
+
// Driver eligibility: an operation that can dispatch the review, and a plan the
|
|
70
|
+
// resume re-run accepts unchanged (create-only supersede flags are left alone).
|
|
71
|
+
export function rateLimitRetryEligible(operation,plan){
|
|
72
|
+
const permissions=Array.isArray(plan?.permissions)?plan.permissions:[];
|
|
73
|
+
return RATE_LIMIT_RETRY_OPERATIONS.includes(operation)
|
|
74
|
+
&&!permissions.some(flag=>typeof flag==='string'&&(flag.startsWith('--supersede')||flag==='--accept-superseded-code-drift'));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const digestBytes=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
78
|
+
// The PLAN file a driver command names (--plan <file>), as the driver resolves it.
|
|
79
|
+
export function planFileFromArgv(argv=process.argv.slice(2),cwd=process.cwd()){
|
|
80
|
+
const at=argv.indexOf('--plan');
|
|
81
|
+
return at!==-1&&typeof argv[at+1]==='string'&&argv[at+1]?path.resolve(cwd,argv[at+1]):null;
|
|
82
|
+
}
|
|
83
|
+
export function planDigest(file){try{return digestBytes(fs.readFileSync(file));}catch{return null;}}
|
|
84
|
+
const text=value=>typeof value==='string'&&value?value:null;
|
|
85
|
+
// The frozen precondition a timed retry sends with its decision (the cm-ai host
|
|
86
|
+
// checks it under the run's writer lock, cm-ai-conversation-entry.mjs
|
|
87
|
+
// rateLimitStopMatches): the round's identity, the reviewed package and the
|
|
88
|
+
// failed review invocation. null when the result does not carry all of them.
|
|
89
|
+
export const RATE_LIMIT_EXPECTED_ENV='CM_DRIVE_RATE_LIMIT_EXPECTED';
|
|
90
|
+
// A batch stop (cm-ai-batch-run.mjs withReviewRetryTarget) also carries its batch
|
|
91
|
+
// target: the member taskKey and the digest of the batch log when it stopped.
|
|
92
|
+
export function expectedReviewStop(row){
|
|
93
|
+
const result=obj(row?.result),identity=obj(result.identity),target=obj(result.reviewRetryTarget);
|
|
94
|
+
if(!['repositoryId','runId','taskId'].every(key=>text(identity[key]))||!Number.isSafeInteger(identity.attempt)
|
|
95
|
+
||!/^[a-f0-9]{64}$/.test(result.packageDigest??'')||!text(result.reviewInvocationId))return null;
|
|
96
|
+
const batch=text(target.taskKey)&&/^[a-f0-9]{64}$/.test(target.batchDigest??'')?{taskKey:target.taskKey,batchDigest:target.batchDigest}:null;
|
|
97
|
+
return {identity:{repositoryId:identity.repositoryId,runId:identity.runId,taskId:identity.taskId,attempt:identity.attempt},
|
|
98
|
+
packageDigest:result.packageDigest,invocationId:result.reviewInvocationId,...(batch?{batch}:{})};
|
|
99
|
+
}
|
|
100
|
+
export function readExpectedReviewStop(env=process.env){
|
|
101
|
+
const raw=env[RATE_LIMIT_EXPECTED_ENV];if(typeof raw!=='string'||!raw)return null;
|
|
102
|
+
let value;try{value=JSON.parse(raw);}catch{return null;}
|
|
103
|
+
return expectedReviewStop({result:{identity:value?.identity,packageDigest:value?.packageDigest,reviewInvocationId:value?.invocationId,
|
|
104
|
+
...(value?.batch?{reviewRetryTarget:value.batch}:{})}});
|
|
105
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import {packageMaterialEligible,resolveCheckpointPackage} from './checkpoint-package-material.mjs';
|
|
2
|
+
import {validateIntegrationRecord} from './reviewed-integration.mjs';
|
|
1
3
|
import {readExecutionPolicy} from './execution-policy.mjs';
|
|
2
4
|
import {readControlPolicy} from './control-policy.mjs';
|
|
5
|
+
import {applyScopeRevision} from './scope-revision.mjs';
|
|
3
6
|
import {readExternalModels} from './external-models.mjs';
|
|
4
7
|
import {beforeFirstQaRound,qaRevisionFollows,readQaConfigRevision} from './qa-config-revision.mjs';
|
|
5
8
|
import {readCloseoutPolicy} from './knowledge-closeout.mjs';
|
|
6
9
|
// Host-only S3b2b journal grammar. Data validation grants no provider authority.
|
|
7
|
-
import {digest,need,shape,id,text,hex,json,validIdentity,validTaskLearningInput,validCallTimeout,validBlockedReason,requestFor,JOURNAL_REASON_LIMIT,boundedReason} from './effect-contract.mjs';
|
|
10
|
+
import {digest,need,shape,id,text,hex,json,validIdentity,validTaskLearningInput,validCallTimeout,validBlockedReason,validFailureCode,requestFor,JOURNAL_REASON_LIMIT,boundedReason} from './effect-contract.mjs';
|
|
8
11
|
import {readReviewBaseline,readReviewPackage,reviewSpecsPath,reviewMaterialLimitReason} from './review-package.mjs';
|
|
9
12
|
import {reviewResult,reviewReceipt} from './review-runner.mjs';
|
|
10
13
|
import {checkCompletion} from './gate-bridge.mjs';
|
|
@@ -138,8 +141,17 @@ function pinnedDevelopStart(s,skip,from=s.cache.length-2){
|
|
|
138
141
|
for(let i=from;i>=0;i--){
|
|
139
142
|
const entry=s.cache[i];
|
|
140
143
|
if(skip(entry)&&entry.effect.identity.attempt===s.attempt)continue;
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
const reviewed=s.attempt===2&&s.reviewPackage?.identity.attempt===1;
|
|
145
|
+
const rejected=entry.effect.kind==='review'&&entry.result.state==='changes_requested'
|
|
146
|
+
&&s.priorReview?.verdict==='changes_requested';
|
|
147
|
+
// Only the validated completion-rework transition produces a2 with an
|
|
148
|
+
// approved a1 prior review and this retained failed complete at its start.
|
|
149
|
+
const rework=entry.effect.kind==='complete'&&entry.effect.identity.attempt===1
|
|
150
|
+
&&entry.result.state==='blocked'&&entry.result.code==='completion_checks_changed'
|
|
151
|
+
&&s.priorReview?.verdict==='approved'&&entry.result.packageDigest===s.reviewPackage?.packageDigest
|
|
152
|
+
&&entry.result.receipt?.identity.attempt===1&&entry.result.receipt.result.verdict==='approved'
|
|
153
|
+
&&entry.result.receipt.packageDigest===s.reviewPackage?.packageDigest;
|
|
154
|
+
return reviewed&&(rejected||rework)?'reviewed_package':null;
|
|
143
155
|
}
|
|
144
156
|
return s.attempt===1&&s.reviewPackage===null?'baseline':null;
|
|
145
157
|
}
|
|
@@ -200,10 +212,43 @@ export const developRecheckSource=entry=>{
|
|
|
200
212
|
&&call?.terminal==='succeeded'&&call.channel==='fixture'
|
|
201
213
|
&&result.learningWriteback!=null&&result.learningWriteback.outcome!=='writeback_pending';
|
|
202
214
|
};
|
|
203
|
-
|
|
215
|
+
// Only a validated journal can prove the old timeout -> recheck -> stale-signal
|
|
216
|
+
// cancellation chain. A cancelled code alone never grants a retry.
|
|
217
|
+
export function developRecheckCancellationBinding(records,s,config){
|
|
218
|
+
if(records[0]?.payload.version!==3||s.state!=='unknown'||s.code!=='cancelled'
|
|
219
|
+
||config.developer.requestedModel!=='current-session'||config.controlPolicy?.development==='provider'
|
|
220
|
+
||config.externalModels||config.executionPolicy||s.cancellationRequested||s.cancelAfterCommit||s.workflowError
|
|
221
|
+
||s.reviewPackage!==null||s.receipt!==null||s.receipts.length||s.priorReview!==null||s.reviewInvocation!==null
|
|
222
|
+
||s.taskCommit!=null||s.learningResult==null||s.learningResult.writeback.outcome==='writeback_pending')return null;
|
|
223
|
+
const checkpointIndex=records.findLastIndex(row=>row.payload.type==='effect-checkpoint');
|
|
224
|
+
const intentIndex=records.slice(0,checkpointIndex).findLastIndex(row=>row.payload.type==='effect-intent');
|
|
225
|
+
const recheckIndex=records.slice(0,intentIndex).findLastIndex(row=>row.payload.type==='develop-recheck');
|
|
226
|
+
const sourceIndex=records.slice(0,recheckIndex).findLastIndex(row=>row.payload.type==='effect-checkpoint');
|
|
227
|
+
if(sourceIndex<0||recheckIndex<0||intentIndex<0)return null;
|
|
228
|
+
const sourceRecord=records[sourceIndex],source=sourceRecord.payload.checkpoint;
|
|
229
|
+
const recheck=records[recheckIndex],intent=records[intentIndex],checkpoint=records[checkpointIndex],last=s.cache.at(-1);
|
|
230
|
+
const previous=source.cache.at(-1),call=source.calls.at(-1);
|
|
231
|
+
if(source.state!=='unknown'||source.code!=='call_timeout'||source.cancellationRequested||source.cancelAfterCommit||source.workflowError
|
|
232
|
+
||!developRecheckSource(previous)||recheck.payload.code!=='check_answer_missing'
|
|
233
|
+
||recheck.payload.effectId!==previous.effect.id||recheck.payload.invocationId!==call.invocationId
|
|
234
|
+
||intent.payload.effect.kind!=='develop'||intent.payload.effect.id!==last?.effect.id
|
|
235
|
+
||checkpoint.payload.effectId!==last.effect.id||source.attempt!==s.attempt
|
|
236
|
+
||digest(intent.payload.effect.learningInput)!==digest(previous.effect.learningInput)
|
|
237
|
+
||digest(source.calls)!==digest(s.calls)||digest(source.learningResult)!==digest(s.learningResult)
|
|
238
|
+
||records.slice(sourceIndex+1).some(row=>row.payload.type==='control'
|
|
239
|
+
&&['cancel','late-cancel','workflow-error'].includes(row.payload.event))
|
|
240
|
+
||records.slice(recheckIndex+1,intentIndex).some(row=>row.payload.type!=='host-joined')
|
|
241
|
+
||records.slice(intentIndex+1,checkpointIndex).some(row=>row.payload.type!=='host-joined')
|
|
242
|
+
||records.slice(checkpointIndex+1).some(row=>row.payload.type!=='host-joined'))return null;
|
|
243
|
+
return {effectId:last.effect.id,invocationId:call.invocationId,sourceEffectId:previous.effect.id,
|
|
244
|
+
sourceCheckpointDigest:sourceRecord.digest,recheckDigest:recheck.digest,checkpointDigest:checkpoint.digest};
|
|
245
|
+
}
|
|
246
|
+
export function developRecheckCode(s,config,recorded=0,cancelledBinding=null){
|
|
204
247
|
if(config.bootstrap?.mode==='instructions'||config.taskLearning?.hostHandoff!==true)return null;
|
|
205
248
|
const last=s.cache.at(-1);
|
|
206
|
-
|
|
249
|
+
const cancelledRecheck=s.state==='unknown'&&s.code==='cancelled'&&last?.result.state==='unknown'&&last.result.code==='cancelled'
|
|
250
|
+
&&cancelledBinding?.effectId===last.effect.id&&cancelledBinding.invocationId===last.result.calls.at(-1)?.invocationId;
|
|
251
|
+
if(!last||last.effect.identity.attempt!==s.attempt||!(developRecheckSource(last)||cancelledRecheck)
|
|
207
252
|
||s.learningResult==null||s.receipt!==null)return null;
|
|
208
253
|
if(s.state==='blocked'&&RECHECK_CODES.includes(s.code))return s.code;
|
|
209
254
|
if(!(s.state==='unknown'&&s.code===last.result.code)||recorded>=MAX_ANSWER_GAP_RETRIES)return null;
|
|
@@ -477,16 +522,32 @@ const COMPLETION_RETRY_CODES=['completion_checks_changed','completion_package_ch
|
|
|
477
522
|
const completionBlock=entry=>entry.effect.kind==='complete'&&entry.result.state==='blocked'
|
|
478
523
|
&&COMPLETION_RETRY_CODES.includes(entry.result.code);
|
|
479
524
|
export const completionBlockCount=cache=>cache.filter(completionBlock).length;
|
|
480
|
-
export const completedEffectCount=(cache,calls=[])=>cache.filter(entry=>!(entry.effect.kind==='develop'
|
|
525
|
+
export const completedEffectCount=(cache,calls=[],recheckEffects=[])=>cache.filter(entry=>!(entry.effect.kind==='develop'
|
|
481
526
|
&&entry.result.state==='blocked'&&['developer_result_invalid','check_output_out_of_scope'].includes(entry.result.code))
|
|
482
527
|
&&!timeoutEffect(entry)&&!developTimeoutEffect(entry)&&!developAnswerInvalidEffect(entry)&&!developRecheckSource(entry)
|
|
483
528
|
&&!developRedoSource(entry)&&!developDispatchFailedEffect(entry)&&!documentationSyncSource(entry)
|
|
529
|
+
&&!(entry.result.state==='unknown'&&entry.result.code==='cancelled'&&recheckEffects.includes(entry.effect.id))
|
|
484
530
|
&&!abandonedResult(entry,calls)&&entry.effect.kind!=='complete').length;
|
|
485
531
|
// The six-effect cap counts develop and review effects only; completion (above),
|
|
486
532
|
// QA, documentation and finalization hold no slot.
|
|
487
533
|
export const MAX_RUNNER_EFFECTS=6;
|
|
488
534
|
// Only develop and review intents need a free slot; complete is gated by stage.
|
|
489
|
-
|
|
535
|
+
// Only journal-derived rework identities may use the one extra slot. Once its
|
|
536
|
+
// develop intent is recorded, even a free timeout slot cannot dispatch again.
|
|
537
|
+
export const effectSlotFree=(kind,cache,calls,recheckEffects=[],rework=null,effectId=null,before=null)=>{
|
|
538
|
+
if(kind==='complete')return true;
|
|
539
|
+
const checkOnly=kind==='develop'&&before?.state==='blocked'&&RECHECK_CODES.includes(before.code);
|
|
540
|
+
if(rework&&kind==='develop'&&!checkOnly&&(rework.developerConsumed||effectId!==rework.developerEffectId))return false;
|
|
541
|
+
const bound=rework&&(kind==='develop'&&!rework.developerConsumed&&effectId===rework.developerEffectId
|
|
542
|
+
||checkOnly&&rework.developerConsumed
|
|
543
|
+
||kind==='review'&&rework.developerConsumed&&/^review-2(?:-retry-[1-9][0-9]*)?(?:-resume-[1-9][0-9]*)?$/.test(effectId??''));
|
|
544
|
+
return completedEffectCount(cache,calls,recheckEffects)<MAX_RUNNER_EFFECTS+(bound?1:0);
|
|
545
|
+
};
|
|
546
|
+
export const verificationBlockCount=(cache,recheckEffects=[])=>cache.filter(entry=>entry.effect.kind==='develop'
|
|
547
|
+
&&entry.result?.state==='blocked'
|
|
548
|
+
&&['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)
|
|
549
|
+
||developTimeoutEffect(entry)||developAnswerInvalidEffect(entry)||developRecheckSource(entry)||developRedoSource(entry)||developDispatchFailedEffect(entry)
|
|
550
|
+
||documentationSyncSource(entry)||recheckEffects.includes(entry.effect.id)).length;
|
|
490
551
|
// A delivery is only worth starting while it could still be reviewed: its own
|
|
491
552
|
// call and effect slot, and its review's. Otherwise the run could only end in a
|
|
492
553
|
// refused checkpoint after the developer or reviewer already ran, so it stops
|
|
@@ -494,16 +555,91 @@ export const effectSlotFree=(kind,cache,calls)=>kind==='complete'||completedEffe
|
|
|
494
555
|
// retryable. (Today every counted develop/review effect in a developable state
|
|
495
556
|
// also holds a counted call, so the call term decides; the effect term keeps
|
|
496
557
|
// the rule true for blocks that could stop before their developer call.)
|
|
497
|
-
export const developBudget=s=>({calls:countedCalls(s.calls,s.cache),effects:completedEffectCount(s.cache,s.calls)});
|
|
498
|
-
export const developBudgetExhausted=s=>{
|
|
558
|
+
export const developBudget=(s,recheckEffects=[])=>({calls:countedCalls(s.calls,s.cache),effects:completedEffectCount(s.cache,s.calls,recheckEffects)});
|
|
559
|
+
export const developBudgetExhausted=(s,recheckEffects=[],rework=null)=>{
|
|
499
560
|
if(!stageAllowed('develop',s.state,s.code,s.priorReview?.verdict))return false;
|
|
500
561
|
// A re-check makes no developer call: only its review needs one.
|
|
501
|
-
const used=developBudget(s),calls=RECHECK_CODES.includes(s.code)?1:2;
|
|
502
|
-
|
|
562
|
+
const used=developBudget(s,recheckEffects),calls=RECHECK_CODES.includes(s.code)?1:2;
|
|
563
|
+
const credit=rework&&s.attempt===2&&s.state==='blocked'
|
|
564
|
+
&&(!rework.developerConsumed&&s.code==='develop_checks_not_passed'||rework.developerConsumed&&RECHECK_CODES.includes(s.code))?1:0;
|
|
565
|
+
return used.calls+calls>MAX_RUNNER_CALLS||used.effects+2>MAX_RUNNER_EFFECTS+credit;
|
|
503
566
|
};
|
|
504
567
|
// At most this many re-checks after a blocked completion. Each re-runs only the
|
|
505
568
|
// local checks and the commit gate, so a small fixed bound keeps the journal
|
|
506
569
|
// bounded; an environment that keeps changing needs fixing, not more attempts.
|
|
570
|
+
// An explicit request may use the unused second review round after a genuine
|
|
571
|
+
// failed complete. It never changes an approved verdict or creates a third round.
|
|
572
|
+
export function completionReworkBinding(s,config){
|
|
573
|
+
const entry=s.cache.at(-1),pkg=s.reviewPackage,receipt=s.receipt;
|
|
574
|
+
need(config.controlPolicy?.version===2&&config.controlPolicy.development==='conversation'&&config.bootstrap==null
|
|
575
|
+
&&(config.parallelSelection??null)===null
|
|
576
|
+
&&s.state==='blocked'&&s.code==='completion_checks_changed'&&s.attempt===1
|
|
577
|
+
&&s.taskCommit==null&&!s.cancellationRequested&&!s.cancelAfterCommit&&!s.workflowError
|
|
578
|
+
&&entry?.effect.kind==='complete'&&entry.effect.identity.attempt===1
|
|
579
|
+
&&entry.result.state==='blocked'&&entry.result.code===s.code
|
|
580
|
+
&&pkg?.identity.attempt===1&&receipt?.identity.attempt===1
|
|
581
|
+
&&receipt.result.verdict==='approved'&&s.priorReview?.verdict==='approved'
|
|
582
|
+
&&receipt.packageDigest===pkg.packageDigest,'completion_rework_unavailable');
|
|
583
|
+
const used=developBudget(s);
|
|
584
|
+
need(used.calls+2<=MAX_RUNNER_CALLS&&used.effects+2<=MAX_RUNNER_EFFECTS,'completion_rework_budget_exhausted');
|
|
585
|
+
return {effectId:entry.effect.id,failedCheckpointDigest:digest(entry),packageDigest:pkg.packageDigest,
|
|
586
|
+
receiptDigest:receipt.receiptDigest,artifactDigest:pkg.artifactDigest,handoffDigest:digest(pkg.handoff??null)};
|
|
587
|
+
}
|
|
588
|
+
export function applyCompletionRework(s,config,record){
|
|
589
|
+
const binding=completionReworkBinding(s,config);
|
|
590
|
+
for(const key of Object.keys(binding))same(record[key],binding[key]);
|
|
591
|
+
need(record.fromAttempt===1&&record.toAttempt===2,'completion_rework_unavailable');
|
|
592
|
+
need(typeof record.reason==='string'&&record.reason.trim().length>0
|
|
593
|
+
&&Buffer.byteLength(record.reason,'utf8')<=500&&!/[\r\n\0]/.test(record.reason),'completion_rework_reason_required');
|
|
594
|
+
need(typeof record.at==='string'&&new Date(record.at).toISOString()===record.at,'completion_rework_unavailable');
|
|
595
|
+
return {...s,state:'changes_requested',code:null,reason:null,attempt:2,receipt:null,reviewInvocation:null};
|
|
596
|
+
}
|
|
597
|
+
// This binding is computed only after the historical prefix passed the normal
|
|
598
|
+
// journal validator. The event cannot retroactively enlarge earlier budgets.
|
|
599
|
+
export function developmentReworkBinding(records,s,config,original,rechecks=[],rework=null){
|
|
600
|
+
const limit=records.at(-1),failure=records.at(-2),entry=s.cache.at(-1),receipt=s.receipts.at(-1),pkg=s.reviewPackage;
|
|
601
|
+
const used=developBudget(s,rechecks),call=s.calls.at(-1);
|
|
602
|
+
need(rework===null&&config.controlPolicy?.version===2&&config.controlPolicy.development==='conversation'
|
|
603
|
+
&&config.controlPolicy.bootstrap==='disabled'&&config.controlPolicy.qaFix==='disabled'&&config.bootstrap==null
|
|
604
|
+
&&config.developer.requestedModel==='current-session'&&!config.externalModels&&!config.executionPolicy
|
|
605
|
+
&&s.state==='blocked'&&s.code==='develop_retry_limit'&&s.attempt===2
|
|
606
|
+
&&s.taskCommit==null&&!s.cancellationRequested&&!s.cancelAfterCommit&&!s.workflowError
|
|
607
|
+
&&limit?.payload.type==='develop-retry-limit'&&limit.payload.fromState==='blocked'
|
|
608
|
+
&&limit.payload.fromCode==='develop_checks_not_passed'&&limit.payload.countedCalls===4&&limit.payload.countedEffects===5
|
|
609
|
+
&&failure?.payload.type==='effect-checkpoint'&&failure.payload.effectId===entry?.effect.id
|
|
610
|
+
&&entry?.effect.kind==='develop'&&entry.effect.identity.attempt===2
|
|
611
|
+
&&entry.result.state==='blocked'&&entry.result.code==='develop_checks_not_passed'
|
|
612
|
+
&&call?.terminal==='succeeded'&&call.channel==='fixture'&&s.learningResult?.writeback!=null
|
|
613
|
+
&&s.learningResult.writeback.outcome!=='writeback_pending'
|
|
614
|
+
&&Array.isArray(s.currentChecks)&&s.currentChecks.some(check=>check.outcome==='failed')&&used.calls===4&&used.effects===5
|
|
615
|
+
&&s.receipt===null&&s.receipts.length===1&&receipt.identity.attempt===1
|
|
616
|
+
&&receipt.result.verdict==='changes_requested'&&s.priorReview?.verdict==='changes_requested'
|
|
617
|
+
&&pkg?.identity.attempt===1&&pkg.packageDigest===receipt.packageDigest
|
|
618
|
+
&&!s.cache.some(item=>item.effect.kind==='review'&&item.effect.identity.attempt===2)
|
|
619
|
+
&&!records.some(row=>row.payload.type==='review-invocation-registered'&&row.payload.binding.identity.attempt===2)
|
|
620
|
+
&&!records.some(row=>row.payload.type==='effect-interrupted'||row.payload.type.startsWith('qa-')
|
|
621
|
+
&&(row.payload.type!=='qa-config-revised'||!beforeFirstQaRound(readQaConfigRevision(row.payload.record)))
|
|
622
|
+
||row.payload.type==='control'&&['cancel','late-cancel','workflow-error'].includes(row.payload.event))
|
|
623
|
+
&&used.calls+2<=MAX_RUNNER_CALLS,'development_rework_unavailable');
|
|
624
|
+
// Canonical entry IDs come from the same cache derivation as live dispatch.
|
|
625
|
+
const rejected=s.calls.filter(call=>call.terminal==='failed'&&call.failureResult?.code==='invalid_result'
|
|
626
|
+
&&call.failureResult.retryable===true).length;
|
|
627
|
+
return {effectId:entry.effect.id,failedCheckpointDigest:failure.digest,limitDigest:limit.digest,
|
|
628
|
+
deliveryDigest:digest(entry),packageDigest:pkg.packageDigest,receiptDigest:receipt.receiptDigest,
|
|
629
|
+
baselineDigest:original.baselineDigest,scopeDigest:digest(config.scope),configDigest:digest(config),
|
|
630
|
+
developerEffectId:`develop-2-retry-${rejected+verificationBlockCount(s.cache,rechecks)}`,reviewEffectId:'review-2'};
|
|
631
|
+
}
|
|
632
|
+
export function applyDevelopmentRework(records,s,config,original,record,rechecks=[],rework=null){
|
|
633
|
+
const binding=developmentReworkBinding(records,s,config,original,rechecks,rework);
|
|
634
|
+
for(const key of Object.keys(binding))same(record[key],binding[key]);
|
|
635
|
+
need(record.fromDigest===records.at(-1).digest&&record.effectCredit===1,'development_rework_unavailable');
|
|
636
|
+
hex(record.sourceDigest);
|
|
637
|
+
need(typeof record.reason==='string'&&record.reason.trim().length>0&&Buffer.byteLength(record.reason,'utf8')<=500
|
|
638
|
+
&&!/[\r\n\0]/.test(record.reason),'development_rework_reason_required');
|
|
639
|
+
need(typeof record.at==='string'&&Number.isFinite(Date.parse(record.at))&&new Date(record.at).toISOString()===record.at,
|
|
640
|
+
'development_rework_unavailable');
|
|
641
|
+
return {...s,state:'blocked',code:'develop_checks_not_passed',reason:null};
|
|
642
|
+
}
|
|
507
643
|
export const MAX_COMPLETION_RETRIES=3;
|
|
508
644
|
export const completionRetriesExhausted=s=>s.state==='blocked'&&COMPLETION_RETRY_CODES.includes(s.code)
|
|
509
645
|
&&completionBlockCount(s.cache)>MAX_COMPLETION_RETRIES;
|
|
@@ -613,14 +749,17 @@ export function runnerStatus(s,config) {
|
|
|
613
749
|
...(Object.hasOwn(s,'reviewInvocation')?{reviewInvocation:s.reviewInvocation}:{}),
|
|
614
750
|
...(Object.hasOwn(config,'taskLearning')?{learningWriteback:s.learningResult?.writeback??null}:{})},LIMIT);
|
|
615
751
|
}
|
|
616
|
-
export function controlledState(state,event,outstanding,version=1) {
|
|
752
|
+
export function controlledState(state,event,outstanding,version=1,developmentReworkPending=false) {
|
|
617
753
|
const s=structuredClone(state);
|
|
618
754
|
const unresolvedReview=version===3&&s.reviewInvocation?.result?.reconciliationRequired===true
|
|
619
755
|
&&s.reviewInvocation.registration?.binding?.identity?.attempt===s.attempt;
|
|
620
756
|
if(event==='workflow-error') {s.workflowError='workflow_error';if(!outstanding && s.state!=='fixture_completed'
|
|
621
757
|
&& !(s.state==='unknown'&&(version>=2&&s.taskCommit||unresolvedReview))){s.state='blocked';s.code='workflow_error';if(Object.hasOwn(s,'reason'))s.reason=null;}}
|
|
622
758
|
else if(event==='late-cancel'){s.cancelAfterCommit=true;s.cancellationRequested=true;}
|
|
623
|
-
else if(event==='cancel') {if(!['blocked','unknown','cancelled','fixture_completed'].includes(s.state)
|
|
759
|
+
else if(event==='cancel') {if(!['blocked','unknown','cancelled','fixture_completed'].includes(s.state)
|
|
760
|
+
||outstanding&&s.state==='blocked'&&([...RECHECK_CODES,COMPLETE_RECHECK_CODE].includes(s.code)
|
|
761
|
+
||developmentReworkPending&&s.code==='develop_checks_not_passed')){
|
|
762
|
+
s.state='cancelled';s.code='cancelled';if(Object.hasOwn(s,'reason'))s.reason=null;s.cancellationRequested=true;}}
|
|
624
763
|
else need(false,'runner_control');
|
|
625
764
|
return s;
|
|
626
765
|
}
|
|
@@ -633,7 +772,7 @@ function packageLink(pkg,original,attempt,checks) {
|
|
|
633
772
|
if(Object.hasOwn(p,'unchangedScope')){
|
|
634
773
|
const changed=new Set(p.changes.map(c=>c.path));
|
|
635
774
|
same(p.unchangedScope,b.scope.filter(path=>!changed.has(path)&&files.has(path))
|
|
636
|
-
.map(path=>({path,sha256:files.get(path).sha256})));
|
|
775
|
+
.map(path=>b.scopeRevisionPaths?.includes(path)?files.get(path):({path,sha256:files.get(path).sha256})));
|
|
637
776
|
}
|
|
638
777
|
same(p.specification??null,b.specification??null);
|
|
639
778
|
same(p.requirements,b.requirements.map(path=>files.get(path)??null));
|
|
@@ -648,7 +787,12 @@ function callRequest(call,adapter,contextId,role,payload,identity,session,index)
|
|
|
648
787
|
...(Object.hasOwn(call,'providerThreadId')?['providerThreadId']:[]),
|
|
649
788
|
...(Object.hasOwn(call,'failureResult')?['failureResult']:[]),
|
|
650
789
|
...(Object.hasOwn(call,'blockedReason')?['blockedReason']:[]),
|
|
790
|
+
...(Object.hasOwn(call,'failureCode')?['failureCode']:[]),
|
|
651
791
|
...(Object.hasOwn(call,'documentationSync')?['documentationSync']:[])]);
|
|
792
|
+
if(Object.hasOwn(call,'failureCode')){
|
|
793
|
+
need(role==='developer'&&['failed','unknown'].includes(call.terminal)&&!Object.hasOwn(call,'failureResult')
|
|
794
|
+
&&!Object.hasOwn(call,'blockedReason'),'runner_call');validFailureCode(call.failureCode);
|
|
795
|
+
}
|
|
652
796
|
// Q16: the documentation-sync-started record this developer call journaled.
|
|
653
797
|
if(Object.hasOwn(call,'documentationSync')){need(role==='developer','runner_call');hex(call.documentationSync);}
|
|
654
798
|
if(Object.hasOwn(call,'blockedReason')){
|
|
@@ -780,7 +924,7 @@ function invocationCall(call,registration,started,result,before) {
|
|
|
780
924
|
&&call.resultDigest===digest(result.outcome==='observed'?result.inspection.review:result)
|
|
781
925
|
&&before.sequence+1===Number(request.invocationId.split('.').at(-1)),'runner_call');
|
|
782
926
|
}
|
|
783
|
-
function checkpoint(before,raw,effect,config,original,session,controls,version=1,taskCommit=null,invocation=null,carried=null,documentation=null) {
|
|
927
|
+
function checkpoint(before,raw,effect,config,original,session,controls,version=1,taskCommit=null,invocation=null,carried=null,documentation=null,recheckEffects=[],rework=null) {
|
|
784
928
|
const s=json(raw,LIMIT);
|
|
785
929
|
shape(s,['state','code','attempt','session','sequence','reviewPackage','currentChecks','receipt','receipts','calls','cache',
|
|
786
930
|
...(Object.hasOwn(s,'reason')?['reason']:[]),
|
|
@@ -804,7 +948,11 @@ function checkpoint(before,raw,effect,config,original,session,controls,version=1
|
|
|
804
948
|
// checkpointed, or its journaled result was abandoned), so it holds no call
|
|
805
949
|
// slot either; the attempt's one redispatch is bounded by reviewRetrySpent.
|
|
806
950
|
need(Array.isArray(s.calls) && countedCalls(s.calls,s.cache)<=MAX_RUNNER_CALLS && s.sequence===s.calls.length,'runner_calls');
|
|
807
|
-
|
|
951
|
+
// The current check-only intent is already derived from the validated journal;
|
|
952
|
+
// its checkpoint still has to pass the unchanged-call/Learning checks below.
|
|
953
|
+
const rechecks=version===3&&effect.kind==='develop'&&before.state==='blocked'&&RECHECK_CODES.includes(before.code)
|
|
954
|
+
?[...recheckEffects,effect.id]:recheckEffects;
|
|
955
|
+
need(Array.isArray(s.receipts) && s.receipts.length<=2 && Array.isArray(s.cache) && completedEffectCount(s.cache,s.calls,rechecks)<=MAX_RUNNER_EFFECTS+(rework?.developerConsumed?1:0),'runner_limits');
|
|
808
956
|
prefix(before.calls,s.calls);prefix(before.receipts,s.receipts);prefix(before.cache,s.cache);
|
|
809
957
|
need(s.cache.length===before.cache.length+1,'runner_cache');
|
|
810
958
|
const entry=s.cache.at(-1);shape(entry,['effect','digest','result']);same(entry.effect,effect);same(entry.digest,digest(effect));
|
|
@@ -907,7 +1055,7 @@ function checkpoint(before,raw,effect,config,original,session,controls,version=1
|
|
|
907
1055
|
need(digest(s.reviewPackage)===digest(before.reviewPackage),'runner_develop');
|
|
908
1056
|
same(s.receipts,before.receipts);
|
|
909
1057
|
if(s.code==='develop_unchanged_after_review')
|
|
910
|
-
need(before.attempt===2&&before.priorReview?.verdict
|
|
1058
|
+
need(before.attempt===2&&['changes_requested','approved'].includes(before.priorReview?.verdict),'runner_develop');
|
|
911
1059
|
expectedState='blocked';expectedCode=s.code;
|
|
912
1060
|
}
|
|
913
1061
|
if(added[0]?.terminal==='succeeded'&&s.code==='bootstrap_review_mismatch'){
|
|
@@ -1085,8 +1233,13 @@ function checkpoint(before,raw,effect,config,original,session,controls,version=1
|
|
|
1085
1233
|
function completionConfig(config,version){
|
|
1086
1234
|
shape(config,['root','identity','scope','requirements','excludedContexts','timeoutMs','developer','reviewers','completion',
|
|
1087
1235
|
...(version===3?['reviewInvocation']:[]),...(Object.hasOwn(config,'taskLearning')?['taskLearning']:[]),
|
|
1088
|
-
...['bootstrap','codeProjectPaths','knowledgeCloseout','externalModels','executionPolicy','controlPolicy'].filter(key=>Object.hasOwn(config,key))]);
|
|
1236
|
+
...['bootstrap','codeProjectPaths','knowledgeCloseout','externalModels','executionPolicy','controlPolicy','parallelSelection'].filter(key=>Object.hasOwn(config,key))]);
|
|
1089
1237
|
if(Object.hasOwn(config,'controlPolicy')){same(config.controlPolicy,readControlPolicy(config.controlPolicy));need(version===3,'runner_version');}
|
|
1238
|
+
if(Object.hasOwn(config,'parallelSelection')){
|
|
1239
|
+
shape(config.parallelSelection,['version','group']);need(config.parallelSelection.version===1&&Array.isArray(config.parallelSelection.group)
|
|
1240
|
+
&&config.parallelSelection.group.length>=1&&config.parallelSelection.group.includes(config.identity.taskId),'runner_config');
|
|
1241
|
+
for(const task of config.parallelSelection.group)id(task);
|
|
1242
|
+
}
|
|
1090
1243
|
if(Object.hasOwn(config,'knowledgeCloseout'))readCloseoutPolicy(config.knowledgeCloseout);
|
|
1091
1244
|
if(Object.hasOwn(config,'executionPolicy')){same(config.executionPolicy,readExecutionPolicy(config.executionPolicy));need(version===3,'execution_policy_runner_version');}
|
|
1092
1245
|
if(Object.hasOwn(config,'externalModels')){same(config.externalModels,readExternalModels(config.externalModels));need(version===3,'external_model_runner_version');}
|
|
@@ -1176,9 +1329,12 @@ export function readRunnerHistory(raw,config,version=1) {
|
|
|
1176
1329
|
need(records[0]?.payload?.version===version,'runner_version');
|
|
1177
1330
|
const completion=version>=2?completionConfig(config,version):null;
|
|
1178
1331
|
let original,session,state,pending=null,beforeIntent=null,controlCount=0,controls={},completeIntentDigest=null,transaction=null;
|
|
1332
|
+
let acceptedIntegration=null;
|
|
1179
1333
|
let invocation={registration:null,started:null,result:null};let registrationRecord=null,startedRecord=null,resultRecord=null,lastReview=null;
|
|
1180
1334
|
const acceptedFixes=[],joinedHosts=[],reviewerThreads=[];let qaAttachment=null,qaRevision=null,joinedForInvocation=false,supersession=null;
|
|
1335
|
+
let scopeRevisions=0,developmentRework=null;
|
|
1181
1336
|
const answerGaps={developRecheck:0,completeRecheck:0,developRedo:0,developDispatch:0,documentationSync:0,reviewRedispatch:{1:0,2:0}};
|
|
1337
|
+
const developRecheckEffects=[];
|
|
1182
1338
|
// Q16: documentation-sync-started records by digest, and the pending develop's.
|
|
1183
1339
|
const documentationRecords=new Map();let pendingDocumentation=null,documentationStop=null;
|
|
1184
1340
|
// V8/V9: interrupted intents (their ids are never reused) and the provider
|
|
@@ -1293,7 +1449,11 @@ export function readRunnerHistory(raw,config,version=1) {
|
|
|
1293
1449
|
if(Object.hasOwn(e,'learningInput')){need(e.kind==='develop'&&Object.hasOwn(config,'taskLearning'),'runner_learning');
|
|
1294
1450
|
validTaskLearningInput(e.learningInput,e.identity,config.taskLearning.feature);}
|
|
1295
1451
|
same(e.identity,{...config.identity,attempt:state.attempt});need(e.version===1 && stageAllowed(e.kind,state.state,state.code,state.priorReview?.verdict),'runner_stage');
|
|
1296
|
-
need(effectSlotFree(e.kind,state.cache,state.calls) && !state.cache.some(c=>c.effect.id===e.id),'runner_cache');
|
|
1452
|
+
need(effectSlotFree(e.kind,state.cache,state.calls,developRecheckEffects,developmentRework,e.id,state) && !state.cache.some(c=>c.effect.id===e.id),'runner_cache');
|
|
1453
|
+
if(developmentRework){
|
|
1454
|
+
if(e.kind==='develop')developmentRework.developerConsumed=true;
|
|
1455
|
+
if(e.kind==='review'&&e.id===developmentRework.reviewEffectId)developmentRework.reviewConsumed=true;
|
|
1456
|
+
}
|
|
1297
1457
|
pending=e;beforeIntent=structuredClone(state);controls={};completeIntentDigest=e.kind==='complete'?r.digest:null;pendingDocumentation=null;documentationStop=null;
|
|
1298
1458
|
invocation={registration:null,started:null,result:null};registrationRecord=null;startedRecord=null;resultRecord=null;
|
|
1299
1459
|
joinedForInvocation=false;lastReview=null;
|
|
@@ -1325,7 +1485,7 @@ export function readRunnerHistory(raw,config,version=1) {
|
|
|
1325
1485
|
resultRecord=r;
|
|
1326
1486
|
} else if(version===3&&['review-invocation-receipt','review-invocation-reconciled'].includes(p.type)) {
|
|
1327
1487
|
const bindingKeys=['effectId','invocationId','registeredDigest','startedDigest','resultDigest'];
|
|
1328
|
-
shape(p,[...common,...bindingKeys,...(p.type==='review-invocation-receipt'?['receipt']:['receiptDigest','checkpoint'])]);
|
|
1488
|
+
shape(p,[...common,...bindingKeys,...(p.type==='review-invocation-receipt'?['receipt']:['receiptDigest','checkpoint',...['packageMaterial','packageRef'].filter(key=>Object.hasOwn(p,key))])]);
|
|
1329
1489
|
need((config.externalModels||config.executionPolicy)&&r.kind==='result'&&pending===null&&lastReview!==null
|
|
1330
1490
|
&&(state.state==='unknown'&&lastReview.invocation.result.reconciliationRequired===true
|
|
1331
1491
|
||state.state==='pending_review'&&reviewTransportTimeout(lastReview.invocation.result))
|
|
@@ -1347,16 +1507,18 @@ export function readRunnerHistory(raw,config,version=1) {
|
|
|
1347
1507
|
lastReview.reconciliation={receiptDigest:r.digest,result};
|
|
1348
1508
|
}else{
|
|
1349
1509
|
need(lastReview.reconciliation?.receiptDigest===p.receiptDigest,'review_reconciliation_evidence_required');
|
|
1350
|
-
|
|
1351
|
-
|
|
1510
|
+
if(['packageMaterial','packageRef'].some(key=>Object.hasOwn(p,key)))need(packageMaterialEligible(config,version),'checkpoint_package_material_invalid');
|
|
1511
|
+
const recovered=resolveCheckpointPackage(p,records.slice(0,index),lastReview.effect.identity);
|
|
1512
|
+
state=checkpoint(lastReview.before,recovered,lastReview.effect,config,original,session,lastReview.controls,version,
|
|
1513
|
+
state.taskCommit??null,{...lastReview.invocation,result:lastReview.reconciliation.result},supersession?.carriedReview??null,null,developRecheckEffects,developmentRework);
|
|
1352
1514
|
lastReview=null;
|
|
1353
1515
|
}
|
|
1354
1516
|
} else if(version===3&&p.type==='develop-retry-limit') {
|
|
1355
1517
|
// Terminal: written instead of a develop intent when no delivery can still
|
|
1356
1518
|
// be reviewed. Every field is recomputed from the replayed state.
|
|
1357
1519
|
shape(p,[...common,'fromState','fromCode','countedCalls','countedEffects']);
|
|
1358
|
-
const used=developBudget(state);
|
|
1359
|
-
need(r.kind==='result'&&pending===null&&developBudgetExhausted(state)&&p.fromState===state.state
|
|
1520
|
+
const used=developBudget(state,developRecheckEffects);
|
|
1521
|
+
need(r.kind==='result'&&pending===null&&developBudgetExhausted(state,developRecheckEffects,developmentRework)&&p.fromState===state.state
|
|
1360
1522
|
&&p.fromCode===state.code&&p.countedCalls===used.calls&&p.countedEffects===used.effects,'runner_retry_limit');
|
|
1361
1523
|
state.state='blocked';state.code='develop_retry_limit';
|
|
1362
1524
|
state.reason=developRetryLimitReason(p);lastReview=null;
|
|
@@ -1379,11 +1541,31 @@ export function readRunnerHistory(raw,config,version=1) {
|
|
|
1379
1541
|
// Written by advance for a delivered develop whose later checks never got
|
|
1380
1542
|
// a usable answer; everything is re-derived from the replayed journal.
|
|
1381
1543
|
shape(p,[...common,'effectId','invocationId','code']);
|
|
1382
|
-
const code=developRecheckCode(state,config,answerGaps.developRecheck
|
|
1544
|
+
const code=developRecheckCode(state,config,answerGaps.developRecheck,
|
|
1545
|
+
developRecheckCancellationBinding(records.slice(0,index),state,config));
|
|
1383
1546
|
need(r.kind==='result'&&pending===null&&state.state==='unknown'&&code!==null&&p.code===code
|
|
1384
1547
|
&&p.effectId===state.cache.at(-1).effect.id&&p.invocationId===state.calls.at(-1).invocationId,'runner_develop_recheck');
|
|
1385
1548
|
answerGaps.developRecheck++;
|
|
1386
1549
|
state.state='blocked';state.code=code;state.reason=developRecheckReason(code,state.cache.at(-1).result.code,state.cache.at(-1).result.reason);lastReview=null;
|
|
1550
|
+
} else if(version===3&&p.type==='scope-revised') {
|
|
1551
|
+
shape(p,[...common,'fromDigest','effectId','failedCheckpointDigest','previousScopeDigest','baselineDigest','scope','files','reason','at']);
|
|
1552
|
+
need(r.kind==='result'&&pending===null&&transaction===null&&p.fromDigest===records[index-1].digest,'scope_revision_unavailable');
|
|
1553
|
+
need(!developBudgetExhausted(state,developRecheckEffects,developmentRework),'scope_revision_budget_exhausted');
|
|
1554
|
+
const next=applyScopeRevision(state,config,original,p,scopeRevisions);
|
|
1555
|
+
original=next.baseline;config={...config,scope:next.scope};scopeRevisions++;
|
|
1556
|
+
} else if(version===3&&p.type==='development-rework-authorized') {
|
|
1557
|
+
shape(p,[...common,'fromDigest','effectId','failedCheckpointDigest','limitDigest','deliveryDigest','packageDigest',
|
|
1558
|
+
'receiptDigest','baselineDigest','scopeDigest','configDigest','developerEffectId','reviewEffectId',
|
|
1559
|
+
'effectCredit','sourceDigest','reason','at']);
|
|
1560
|
+
need(r.kind==='result'&&pending===null&&transaction===null,'development_rework_unavailable');
|
|
1561
|
+
state=applyDevelopmentRework(records.slice(0,index),state,config,original,p,developRecheckEffects,developmentRework);
|
|
1562
|
+
developmentRework={developerEffectId:p.developerEffectId,reviewEffectId:p.reviewEffectId,sourceDigest:p.sourceDigest,
|
|
1563
|
+
authorizationDigest:r.digest,developerConsumed:false,reviewConsumed:false};lastReview=null;
|
|
1564
|
+
} else if(version===3&&p.type==='completion-rework-requested') {
|
|
1565
|
+
shape(p,[...common,'effectId','failedCheckpointDigest','packageDigest','receiptDigest','artifactDigest','handoffDigest',
|
|
1566
|
+
'fromAttempt','toAttempt','reason','at']);
|
|
1567
|
+
need(r.kind==='result'&&pending===null,'completion_rework_unavailable');
|
|
1568
|
+
state=applyCompletionRework(state,config,p);lastReview=null;
|
|
1387
1569
|
} else if(version===3&&p.type==='develop-answer-redo') {
|
|
1388
1570
|
// The operator confirmed the session stopped writing (R3); the redo itself
|
|
1389
1571
|
// is the next develop intent. Re-derived from the journal, never the disk.
|
|
@@ -1649,9 +1831,15 @@ export function readRunnerHistory(raw,config,version=1) {
|
|
|
1649
1831
|
state.state='cancelled';state.code='effect_abandoned';state.reason=p.reason;state.sequence++;
|
|
1650
1832
|
pending=null;beforeIntent=null;
|
|
1651
1833
|
} else if(p.type==='effect-checkpoint') {
|
|
1652
|
-
shape(p,[...common,'effectId','checkpoint']
|
|
1653
|
-
|
|
1654
|
-
|
|
1834
|
+
shape(p,[...common,'effectId','checkpoint',...['packageMaterial','packageRef'].filter(key=>Object.hasOwn(p,key))]);
|
|
1835
|
+
need(r.kind==='result' && pending && p.effectId===pending.id,'runner_checkpoint');
|
|
1836
|
+
const material=Object.hasOwn(p,'packageMaterial'),reference=Object.hasOwn(p,'packageRef');
|
|
1837
|
+
if(material||reference)need(packageMaterialEligible(config,version),'checkpoint_package_material_invalid');
|
|
1838
|
+
const checkpointValue=resolveCheckpointPackage(p,records.slice(0,index),pending.identity);
|
|
1839
|
+
state=checkpoint(beforeIntent,checkpointValue,pending,config,original,session,controls,version,state.taskCommit??null,invocation,
|
|
1840
|
+
supersession?.carriedReview??null,pendingDocumentation,developRecheckEffects,developmentRework);pendingDocumentation=null;
|
|
1841
|
+
if(version===3&&pending.kind==='develop'&&beforeIntent.state==='blocked'&&RECHECK_CODES.includes(beforeIntent.code))
|
|
1842
|
+
developRecheckEffects.push(pending.id);
|
|
1655
1843
|
lastReview=version===3&&pending.kind==='review'&&invocation.result?{effect:pending,request:invocation.registration.request,
|
|
1656
1844
|
registrationRecord,startedRecord,resultRecord,before:beforeIntent,controls,invocation}:null;
|
|
1657
1845
|
if(pending.kind==='develop'&&pendingWorker?.journal)workers[pending.id]=workerSummary(pendingWorker);
|
|
@@ -1698,7 +1886,15 @@ export function readRunnerHistory(raw,config,version=1) {
|
|
|
1698
1886
|
&&revision.previousQaDigest===qaRevision.qaDigest&&qaRevisionFollows(revision,qaRevision),'qa_revision_chain_invalid');
|
|
1699
1887
|
else need(revision.fromFingerprint===(qaAttachment?.qaFingerprint??completion.fingerprints.config),'qa_revision_chain_invalid');
|
|
1700
1888
|
qaRevision=revision;
|
|
1889
|
+
} else if(version===3&&p.type==='reviewed-integration-accepted') {
|
|
1890
|
+
shape(p,[...common,'record']);
|
|
1891
|
+
need(r.kind==='result'&&pending===null&&state.state==='fixture_completed'
|
|
1892
|
+
&&state.taskCommit?.outcome==='fixture_committed'&&acceptedFixes.length===0
|
|
1893
|
+
&&acceptedIntegration===null,'integration_parent_not_completed');
|
|
1894
|
+
acceptedIntegration=validateIntegrationRecord({record:p.record,
|
|
1895
|
+
baseline:attemptBaseline(original,state.attempt),parentPackage:state.reviewPackage,records:records.slice(0,index)});
|
|
1701
1896
|
} else if(version===3&&p.type==='qa-fix-accepted') {
|
|
1897
|
+
need(acceptedIntegration===null,'integration_fix_unsupported');
|
|
1702
1898
|
shape(p,[...common,'record']);need(r.kind==='result'&&pending===null&&state.state==='fixture_completed','fix_parent_not_completed');
|
|
1703
1899
|
acceptedFixes.push(validateAcceptedFix({record:p.record,previous:acceptedFixes,
|
|
1704
1900
|
baseline:attemptBaseline(original,state.attempt),parentPackage:state.reviewPackage,feature:config.taskLearning?.feature}));
|
|
@@ -1707,7 +1903,10 @@ export function readRunnerHistory(raw,config,version=1) {
|
|
|
1707
1903
|
if(p.event==='late-cancel')need(state.state==='fixture_completed' || pending?.kind==='complete','runner_control');
|
|
1708
1904
|
if(p.event==='cancel')need(state.state!=='fixture_completed','runner_control');
|
|
1709
1905
|
if(version>=2&&p.event==='cancel')need(transaction===null,'runner_control');
|
|
1710
|
-
const
|
|
1906
|
+
const reworkPending=developmentRework?.developerConsumed===true&&pending?.kind==='develop'
|
|
1907
|
+
&&pending.id===developmentRework.developerEffectId&&beforeIntent.state==='blocked'
|
|
1908
|
+
&&beforeIntent.code==='develop_checks_not_passed';
|
|
1909
|
+
const next=controlledState(state,p.event,pending!==null,version,reworkPending);need(digest(next)!==digest(state),'runner_control');state=next;
|
|
1711
1910
|
if(pending){if(p.event==='cancel')controls.cancelled=true;if(p.event==='late-cancel')controls.cancelAfterCommit=true;
|
|
1712
1911
|
if(p.event==='workflow-error')controls.workflowError='workflow_error';}
|
|
1713
1912
|
} else need(false,'runner_record');
|
|
@@ -1731,7 +1930,9 @@ export function readRunnerHistory(raw,config,version=1) {
|
|
|
1731
1930
|
const interruptLimit=pending!==null&&!interruptible
|
|
1732
1931
|
&&interrupted.filter(item=>item.kind===pending.kind).length>=MAX_EFFECT_INTERRUPTIONS;
|
|
1733
1932
|
const workerVoidable=pending!==null&&pendingWorkerVoidable(pending,lastIntentIndex,records.length);
|
|
1734
|
-
return {original,session,state,pending,acceptedFixes,qaAttachment,answerGaps,
|
|
1933
|
+
return {original,effectiveScope:config.scope,scopeRevisions,session,state,pending,acceptedFixes,qaAttachment,answerGaps,
|
|
1934
|
+
...(acceptedIntegration===null?{}:{acceptedIntegration}),
|
|
1935
|
+
developmentRework,developRecheckEffects,developRecheckRecovery:pending===null?developRecheckCancellationBinding(records,state,config):null,
|
|
1735
1936
|
...(version===3?{joinedHosts,reviewerThreads,supersession,pendingAbandonable,reviewResultAbandon,
|
|
1736
1937
|
interrupted,workers,pendingInterruptible:interruptible,pendingReviewExhausted:pendingReviewExhausted(),
|
|
1737
1938
|
pendingResultAbandonable:pending!==null&&pendingResultAbandonable(),
|
|
@@ -1759,7 +1960,7 @@ const gapLimitReason=(code,what,source)=>`${code}: ${what}(原记录 ${source}
|
|
|
1759
1960
|
export function answerGapLimit(s,config,gaps={}){
|
|
1760
1961
|
if(!['unknown','blocked'].includes(s.state))return null;
|
|
1761
1962
|
const source=`${s.state}/${s.code}`;
|
|
1762
|
-
if(s.state==='unknown'&&(gaps.developRecheck??0)>=MAX_ANSWER_GAP_RETRIES&&developRecheckCode(s,config,0)!==null)
|
|
1963
|
+
if(s.state==='unknown'&&(gaps.developRecheck??0)>=MAX_ANSWER_GAP_RETRIES&&developRecheckCode(s,config,0,gaps.developRecheckRecovery)!==null)
|
|
1763
1964
|
return {code:'check_answer_retry_limit',reason:gapLimitReason('check_answer_retry_limit','开发后的检查或验证预检重跑',source)};
|
|
1764
1965
|
if(s.state==='unknown'&&(gaps.completeRecheck??0)>=MAX_ANSWER_GAP_RETRIES&&completeRecheckable(s,0))
|
|
1765
1966
|
return {code:'complete_recheck_limit',reason:gapLimitReason('complete_recheck_limit','完成前复查重跑',source)};
|
|
@@ -1778,7 +1979,7 @@ export function answerGapLimit(s,config,gaps={}){
|
|
|
1778
1979
|
// missing one ends a real redo in host_close. Exits that need an operator
|
|
1779
1980
|
// confirmation first (develop_redo) are not projected as retryable.
|
|
1780
1981
|
export function projectedRunnerStatus(history,config){
|
|
1781
|
-
const s=history.state,gaps=history.answerGaps
|
|
1982
|
+
const s=history.state,gaps={...history.answerGaps,developRecheckRecovery:history.developRecheckRecovery};
|
|
1782
1983
|
const project=code=>({...s,state:'blocked',code});
|
|
1783
1984
|
if(s.state==='blocked'&&s.code==='failed'&&developAnswerRetryable(s,config.bootstrap))return project('develop_answer_invalid');
|
|
1784
1985
|
if(s.state==='blocked'&&s.code==='failed'){const limit=answerGapLimit(s,config,gaps);
|
|
@@ -1792,7 +1993,7 @@ export function projectedRunnerStatus(history,config){
|
|
|
1792
1993
|
if(reviewRedispatchExhausted(s,contextId,records))return {...s,code:REVIEW_REDISPATCH_LIMIT_CODE,reason:reviewRedispatchLimitReason(s.code)};
|
|
1793
1994
|
}
|
|
1794
1995
|
if(s.state!=='unknown')return s;
|
|
1795
|
-
const recheck=developRecheckCode(s,config,gaps.developRecheck??0);
|
|
1996
|
+
const recheck=developRecheckCode(s,config,gaps.developRecheck??0,history.developRecheckRecovery);
|
|
1796
1997
|
if(recheck!==null)return project(recheck);
|
|
1797
1998
|
if(completeRecheckable(s,gaps.completeRecheck??0))return project(COMPLETE_RECHECK_CODE);
|
|
1798
1999
|
// Q16/Q17: a failed documentation_sync needs the operator's stop
|