@aibyzero/cm-workflow 0.17.1 → 0.19.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 +242 -0
- package/README.md +20 -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/autonomy.mjs +152 -0
- 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 +56 -17
- 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 +115 -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 +581 -65
- 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 +5 -4
- 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 +21 -7
- package/scripts/cm-ai-admission.test.mjs +171 -3
- 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-autonomy.mjs +94 -0
- package/scripts/cm-autonomy.test.mjs +162 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +1 -1
- package/scripts/cm-check-runtime.sh +60 -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 +581 -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 +323 -0
- package/scripts/cm-start-check.test.mjs +406 -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 +4 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N3-execute-task.md +1 -1
- 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 +82 -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 +14 -9
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +8 -1
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-change-recovery.md +14 -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
|
@@ -8,6 +8,7 @@ const sqlite=()=>process.getBuiltinModule('node:sqlite');
|
|
|
8
8
|
import { need,shape,id,hex,json,digest,freeze,JOURNAL_PAYLOAD_LIMIT } from './effect-contract.mjs';
|
|
9
9
|
import { isSupportedExecutionPlatform } from './execution-platform.mjs';
|
|
10
10
|
import { MiB,STATE_LIMIT,PHYSICAL_LIMIT } from './execution-store-limits.mjs';
|
|
11
|
+
import {fixJournalWorkflow,packFixJournalPayload,packFixJournalState,unpackFixJournalState} from './review-presentation.mjs';
|
|
11
12
|
|
|
12
13
|
const APP_ID=0x434d5831;
|
|
13
14
|
const PROTOCOL_SQL='CREATE TABLE protocol(version INTEGER NOT NULL CHECK(version=1))';
|
|
@@ -33,7 +34,7 @@ function regular(p,limit) {
|
|
|
33
34
|
need(s.isFile() && !s.isSymbolicLink() && s.nlink===1,'unsupported_file');
|
|
34
35
|
need((s.mode&0o077)===0,'store_permissions');need(s.size<=limit,'limit_exceeded');return s;
|
|
35
36
|
}
|
|
36
|
-
function readState(p) {
|
|
37
|
+
function readState(p,{withBytes=false}={}) {
|
|
37
38
|
const before=regular(p,STATE_LIMIT),fd=fs.openSync(p,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);
|
|
38
39
|
try {
|
|
39
40
|
need(sameInode(before,fs.fstatSync(fd)),'snapshot_changed');
|
|
@@ -43,7 +44,8 @@ function readState(p) {
|
|
|
43
44
|
&& before.ctimeMs===after.ctimeMs && bytes.length===after.size,'snapshot_changed');
|
|
44
45
|
const raw=bytes.toString('utf8'),value=JSON.parse(raw);
|
|
45
46
|
// Compare original bytes: replacement decoding must never repair corruption.
|
|
46
|
-
need(Buffer.from(JSON.stringify(value)+'\n').equals(bytes),'store_corrupt');
|
|
47
|
+
need(Buffer.from(JSON.stringify(value)+'\n').equals(bytes),'store_corrupt');
|
|
48
|
+
return withBytes?{value,bytes}:value;
|
|
47
49
|
}finally{fs.closeSync(fd);}
|
|
48
50
|
}
|
|
49
51
|
function validateState(raw,options) {
|
|
@@ -56,7 +58,8 @@ function validateState(raw,options) {
|
|
|
56
58
|
for(const [index,r] of v.records.entries()) {
|
|
57
59
|
shape(r,['version','seq','id','kind','payload','previousDigest','digest']);
|
|
58
60
|
need(r.version===1,'store_version');need(r.seq===index+1 && r.previousDigest===previous,'store_corrupt');
|
|
59
|
-
id(r.id);need(!ids.has(r.id) && kinds.has(r.kind),'store_corrupt');ids.add(r.id);
|
|
61
|
+
id(r.id);need(!ids.has(r.id) && kinds.has(r.kind),'store_corrupt');ids.add(r.id);
|
|
62
|
+
need(Buffer.byteLength(JSON.stringify(packFixJournalPayload(r.payload,{workflow:fixJournalWorkflow(v)})))<=JOURNAL_PAYLOAD_LIMIT,'limit_exceeded');
|
|
60
63
|
const {digest:checksum,...data}=r;hex(checksum);need(digest(data)===checksum,'store_corrupt');previous=checksum;
|
|
61
64
|
}
|
|
62
65
|
const {revision,...data}=v;hex(revision);need(digest(data)===revision,'store_corrupt');return v;
|
|
@@ -72,8 +75,10 @@ function runBytes(dir) {
|
|
|
72
75
|
}
|
|
73
76
|
need(total<=PHYSICAL_LIMIT,'limit_exceeded');return total;
|
|
74
77
|
}
|
|
75
|
-
function atomicState(dir,value) {
|
|
76
|
-
const
|
|
78
|
+
function atomicState(dir,value,physical=null) {
|
|
79
|
+
const encoded=physical??packFixJournalState(value);
|
|
80
|
+
if(physical!==null)need(digest(unpackFixJournalState(physical))===digest(value),'store_corrupt');
|
|
81
|
+
const bytes=Buffer.from(JSON.stringify(encoded)+'\n');need(bytes.length<=STATE_LIMIT,'limit_exceeded');
|
|
77
82
|
need(runBytes(dir)+bytes.length<=PHYSICAL_LIMIT,'limit_exceeded');
|
|
78
83
|
const tmp=path.join(dir,`.state.${randomUUID()}.tmp`);let fd,renamed=false;
|
|
79
84
|
try {
|
|
@@ -168,6 +173,28 @@ function acquireWriter(p,create) {
|
|
|
168
173
|
return {db,inode:regular(p,64*1024),certificate:current,inspectionFd,release};
|
|
169
174
|
}catch(error){release();if(error.errcode===5)need(false,'store_busy');throw error;}
|
|
170
175
|
}
|
|
176
|
+
// Every create probes the legacy shared writer. Another process creating a run
|
|
177
|
+
// in the same specs root holds that probe's write lock for a moment, so two
|
|
178
|
+
// creates started together used to fail one of them with store_busy (seen in a
|
|
179
|
+
// real two-task run). Only that transient contention is retried, briefly, and
|
|
180
|
+
// only here, before this create has written anything; any other failure, or a
|
|
181
|
+
// legacy writer that stays held, still refuses with store_busy as before.
|
|
182
|
+
export const LEGACY_PROBE_ATTEMPTS=20;
|
|
183
|
+
export const LEGACY_PROBE_DELAY_MS=50;
|
|
184
|
+
const pause=ms=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,ms);
|
|
185
|
+
function probeLegacyWriter(legacyPath){
|
|
186
|
+
for(let attempt=1;;attempt++){
|
|
187
|
+
// Probe with the full existing protocol; never create or migrate old files.
|
|
188
|
+
// release closes SQLite before its inspection fd and removes the inode key.
|
|
189
|
+
let probe;
|
|
190
|
+
try{probe=acquireWriter(legacyPath,false);}
|
|
191
|
+
catch(error){
|
|
192
|
+
if(error?.code==='store_busy'&&attempt<LEGACY_PROBE_ATTEMPTS){pause(LEGACY_PROBE_DELAY_MS);continue;}
|
|
193
|
+
need(false,'store_busy');
|
|
194
|
+
}
|
|
195
|
+
probe.release();return;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
171
198
|
export { appendFits } from './execution-store-limits.mjs';
|
|
172
199
|
export function openExecutionStore(input) {
|
|
173
200
|
const options=json(input);shape(options,['specsRoot','identity','fingerprints','create']);
|
|
@@ -184,13 +211,7 @@ export function openExecutionStore(input) {
|
|
|
184
211
|
if(options.create) {
|
|
185
212
|
const legacyPath=path.join(execution,'writer.sqlite');let legacy=false;
|
|
186
213
|
try{fs.lstatSync(legacyPath);legacy=true;}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
187
|
-
if(legacy)
|
|
188
|
-
// Probe with the full existing protocol; never create or migrate old files.
|
|
189
|
-
// release closes SQLite before its inspection fd and removes the inode key.
|
|
190
|
-
let probe;
|
|
191
|
-
try{probe=acquireWriter(legacyPath,false);}catch{need(false,'store_busy');}
|
|
192
|
-
probe.release();
|
|
193
|
-
}
|
|
214
|
+
if(legacy)probeLegacyWriter(legacyPath);
|
|
194
215
|
}
|
|
195
216
|
const existed=fs.existsSync(dir);
|
|
196
217
|
directory(dir,options.create);
|
|
@@ -210,16 +231,29 @@ export function openExecutionStore(input) {
|
|
|
210
231
|
};
|
|
211
232
|
const statePath=path.join(dir,'state.json');
|
|
212
233
|
if(options.create)atomicState(dir,seal({version:1,identity:options.identity,fingerprints:options.fingerprints,records:[]}));
|
|
234
|
+
let physicalState=null,validatedBytes=null,validatedLogical=null;
|
|
213
235
|
const snapshot=()=>{
|
|
214
236
|
need(!closed,'store_closed');need(!poisoned,'store_poisoned');
|
|
215
|
-
try{
|
|
237
|
+
try{
|
|
238
|
+
guard();runBytes(dir);
|
|
239
|
+
const {value:physical,bytes}=readState(statePath,{withBytes:true});
|
|
240
|
+
// Reuse only after every fresh path/ownership/read/canonical check above.
|
|
241
|
+
// The buffer stays private; validateState returns a deeply frozen value.
|
|
242
|
+
if(validatedBytes!==null && validatedBytes.equals(bytes))return validatedLogical;
|
|
243
|
+
const logical=validateState(unpackFixJournalState(physical),options);
|
|
244
|
+
// Private physical rows never escape to the logical owner. Append keeps
|
|
245
|
+
// these validated old objects verbatim instead of encoding them again.
|
|
246
|
+
physicalState=physical;validatedBytes=bytes;validatedLogical=logical;return logical;
|
|
247
|
+
}catch(error){poisoned=true;throw error;}
|
|
216
248
|
};
|
|
217
249
|
snapshot();
|
|
218
250
|
const append=input=>{
|
|
219
251
|
need(!closed,'store_closed');need(!poisoned,'store_poisoned');
|
|
220
|
-
const v=json(input,MiB
|
|
221
|
-
id(v.id);hex(v.expectedRevision);need(kinds.has(v.kind));
|
|
222
|
-
const current=snapshot(),
|
|
252
|
+
const v=json(input,10*MiB);shape(v,['id','kind','payload','expectedRevision']);
|
|
253
|
+
id(v.id);hex(v.expectedRevision);need(kinds.has(v.kind));
|
|
254
|
+
const current=snapshot(),physicalPayload=packFixJournalPayload(v.payload,{workflow:fixJournalWorkflow(current)});
|
|
255
|
+
need(Buffer.byteLength(JSON.stringify({...v,payload:physicalPayload}))<=MiB+1024,'limit_exceeded');
|
|
256
|
+
const existing=current.records.find(r=>r.id===v.id);
|
|
223
257
|
if(existing){need(existing.kind===v.kind && digest(existing.payload)===digest(v.payload),'record_conflict');return current;}
|
|
224
258
|
need(v.expectedRevision===current.revision,'revision_mismatch');
|
|
225
259
|
need(current.records.length<1024,'limit_exceeded');
|
|
@@ -227,7 +261,16 @@ export function openExecutionStore(input) {
|
|
|
227
261
|
previousDigest:current.records.at(-1)?.digest??null};
|
|
228
262
|
const {revision:oldRevision,...data}=current;
|
|
229
263
|
const next=validateState(seal({...data,records:[...current.records,{...record,digest:digest(record)}]}),options);
|
|
230
|
-
|
|
264
|
+
const {storageEncoding,...physicalData}=physicalState;
|
|
265
|
+
const encodedSequences=[...(storageEncoding?.records??[]),
|
|
266
|
+
...(Buffer.byteLength(JSON.stringify(v.payload))>JOURNAL_PAYLOAD_LIMIT?[record.seq]:[])];
|
|
267
|
+
const physicalNext={...physicalData,records:[...physicalState.records,{...record,payload:physicalPayload,digest:digest(record)}],
|
|
268
|
+
revision:next.revision,...(encodedSequences.length?{storageEncoding:{version:1,kind:'cm-fix-review-payloads-v1',records:encodedSequences}}:{})};
|
|
269
|
+
try{
|
|
270
|
+
guard();atomicState(dir,next,physicalNext);
|
|
271
|
+
// A new physical state must take the full validation path on next read.
|
|
272
|
+
validatedBytes=null;validatedLogical=null;
|
|
273
|
+
}catch(error){poisoned=true;throw error;}
|
|
231
274
|
return next;
|
|
232
275
|
};
|
|
233
276
|
return Object.freeze({snapshot,append,close});
|
|
@@ -3,6 +3,7 @@ import {captureReviewBaseline,compareReviewInventoryToBaseline,readReviewBaselin
|
|
|
3
3
|
import {verifySpecificationMaterial} from './specification-material.mjs';
|
|
4
4
|
import {CONFIG_FILENAMES} from '../../../scripts/cm-workflow-config.mjs';
|
|
5
5
|
import {digest,hex,id,json,need,shape} from './effect-contract.mjs';
|
|
6
|
+
import {assertSnapshotBoundaries} from './integration-snapshots.mjs';
|
|
6
7
|
|
|
7
8
|
const inventoryFile=({contentBase64,...metadata})=>metadata;
|
|
8
9
|
const sameFile=(a,b)=>digest(a===null?null:inventoryFile(a))===digest(b===null?null:inventoryFile(b));
|
|
@@ -35,6 +36,16 @@ const compact=steps=>steps.map(({beforeFix,runId,packageDigest})=>({beforeFix,ru
|
|
|
35
36
|
// deliveries: [{runId,packages:[{pkg,reviewedAt}]}].
|
|
36
37
|
export const deliveredAfter=(item,after)=>Number.isSafeInteger(after)
|
|
37
38
|
&&Number.isSafeInteger(item.reviewedAt)&&item.reviewedAt>after;
|
|
39
|
+
// Only the runner's already-validated journal supplies this lower bound. Its
|
|
40
|
+
// first review registration is necessarily after its frozen baseline. Missing
|
|
41
|
+
// legacy evidence keeps the historical, final-review-only composition.
|
|
42
|
+
export function firstReviewAt(records,identity){
|
|
43
|
+
const row=records?.find(record=>record.payload?.type==='review-invocation-registered')?.payload;
|
|
44
|
+
const bound=(row?.binding??row?.grant)?.identity;
|
|
45
|
+
return row?.version===3&&row.protocol==='cm-task-runner'&&Number.isSafeInteger(row.registeredAt)
|
|
46
|
+
&&bound?.repositoryId===identity.repositoryId&&bound.runId===identity.runId&&bound.taskId===identity.taskId
|
|
47
|
+
&&Number.isInteger(bound.attempt)&&bound.attempt>=1?row.registeredAt:null;
|
|
48
|
+
}
|
|
38
49
|
const key=file=>file===null||file===undefined?null:`${file.sha256}:${file.mode}`;
|
|
39
50
|
const applyMeta=(state,pkg)=>{for(const change of pkg.changes){
|
|
40
51
|
if(change.after===null)state.delete(change.path);else state.set(change.path,inventoryFile(change.after));}};
|
|
@@ -130,7 +141,7 @@ export function explainReviewedDrift({root,baseline,composed,ownScope,deliveries
|
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
// Completed run without accepted fixes: its own reviewed composition, then drift.
|
|
133
|
-
export function explainCompletedDelivery({root,baseline,parentPackage,deliveries,after}){
|
|
144
|
+
export function explainCompletedDelivery({root,baseline,parentPackage,deliveries,after,since=null}){
|
|
134
145
|
const base=readReviewBaseline(baseline),parent=readReviewPackage(parentPackage);
|
|
135
146
|
need(parent.baseIdentity===base.baselineDigest&&parent.rootDigest===base.rootDigest
|
|
136
147
|
&&digest(parent.identity)===digest(base.identity),'fix_parent_binding_mismatch');
|
|
@@ -140,7 +151,67 @@ export function explainCompletedDelivery({root,baseline,parentPackage,deliveries
|
|
|
140
151
|
need(sameFile(expected.get(change.path)??null,change.before),'fix_before_mismatch');
|
|
141
152
|
if(change.after===null)expected.delete(change.path);else expected.set(change.path,inventoryFile(change.after));
|
|
142
153
|
}
|
|
143
|
-
|
|
154
|
+
try{
|
|
155
|
+
explainReviewedDrift({root,baseline:base,composed:[...expected.values()],ownScope:parent.scope,deliveries,after});
|
|
156
|
+
return;
|
|
157
|
+
}catch(error){
|
|
158
|
+
if(error.code!=='fix_current_code_unexplained'||base.version!==2||!Number.isSafeInteger(since)
|
|
159
|
+
||!Number.isSafeInteger(after)||since>=after)throw error;
|
|
160
|
+
// A sibling can finish while the parent is being revised. Prove the whole
|
|
161
|
+
// bounded interval from the unchanged baseline, in durable review order;
|
|
162
|
+
// never select packages or stop the chain to fit the current tree.
|
|
163
|
+
const earlier=laterSequence(deliveries,since,base.rootDigest).filter(entry=>entry.reviewedAt<after);
|
|
164
|
+
if(!earlier.length)throw error;
|
|
165
|
+
const interval=new Map(base.files.map(file=>[file.path,inventoryFile(file)]));
|
|
166
|
+
for(const entry of earlier){
|
|
167
|
+
need(entry.pkg.identity.repositoryId===parent.identity.repositoryId&&entry.pkg.identity.runId===entry.runId
|
|
168
|
+
&&entry.runId!==parent.identity.runId&&entry.pkg.identity.taskId!==parent.identity.taskId,'fix_association_unverified');
|
|
169
|
+
applyDelivery(interval,entry.pkg,strict);
|
|
170
|
+
}
|
|
171
|
+
// The parent's own reviewed scope remains authoritative, including paths
|
|
172
|
+
// that were unchanged or absent in its final package. Earlier deliveries
|
|
173
|
+
// can explain only the rest of the tree; they cannot undo a parent change.
|
|
174
|
+
const own=new Set(parent.scope);
|
|
175
|
+
for(const p of new Set([...expected.keys(),...interval.keys()]))if(!own.has(p)){
|
|
176
|
+
if(interval.has(p))expected.set(p,interval.get(p));else expected.delete(p);
|
|
177
|
+
}
|
|
178
|
+
explainReviewedDrift({root,baseline:base,composed:[...expected.values()],ownScope:parent.scope,deliveries,after});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Called only after the explicit integration evidence has authenticated each
|
|
183
|
+
// additional source in its original namespace. Never rewrite package identity
|
|
184
|
+
// or rootDigest to make it pass ordinary delivery discovery.
|
|
185
|
+
export function explainIntegratedDelivery({root,baseline,parentPackage,deliveries,after,since,sources,documents,snapshots}){
|
|
186
|
+
const base=readReviewBaseline(baseline),parent=readReviewPackage(parentPackage);
|
|
187
|
+
need(base.version===2&&parent.baseIdentity===base.baselineDigest&&parent.rootDigest===base.rootDigest
|
|
188
|
+
&&digest(parent.identity)===digest(base.identity),'fix_parent_binding_mismatch');
|
|
189
|
+
if(base.specification)verifySpecificationMaterial(base);
|
|
190
|
+
const expected=new Map(base.files.map(file=>[file.path,inventoryFile(file)]));
|
|
191
|
+
applyDelivery(expected,parent,strict);
|
|
192
|
+
const earlier=laterSequence(deliveries,since,base.rootDigest).filter(entry=>entry.reviewedAt<after);
|
|
193
|
+
if(earlier.length){
|
|
194
|
+
const interval=new Map(base.files.map(file=>[file.path,inventoryFile(file)]));
|
|
195
|
+
for(const entry of earlier)applyDelivery(interval,entry.pkg,strict);
|
|
196
|
+
const own=new Set(parent.scope);
|
|
197
|
+
for(const p of new Set([...expected.keys(),...interval.keys()]))if(!own.has(p)){
|
|
198
|
+
if(interval.has(p))expected.set(p,interval.get(p));else expected.delete(p);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// These exact transitions have their own new independent review; historical
|
|
202
|
+
// merge prose is never interpreted as approval. Parent scope is unchanged.
|
|
203
|
+
applyDelivery(expected,{changes:documents},strict);
|
|
204
|
+
const ordinary=laterSequence(deliveries,after,base.rootDigest);
|
|
205
|
+
const imported=sources.flatMap(delivery=>delivery.packages.map((item,index)=>({
|
|
206
|
+
runId:delivery.runId,index,reviewedAt:item.reviewedAt,pkg:readReviewPackage(item.pkg)})));
|
|
207
|
+
const later=[...ordinary,...imported].sort((a,b)=>a.reviewedAt-b.reviewedAt
|
|
208
|
+
||(a.runId<b.runId?-1:a.runId>b.runId?1:0)||a.index-b.index);
|
|
209
|
+
need(new Set(later.map(entry=>entry.runId+'\0'+entry.pkg.packageDigest)).size===later.length,'fix_association_unverified');
|
|
210
|
+
const tolerated=toleratedConfig(parent.scope);
|
|
211
|
+
for(const entry of later)applyDelivery(expected,entry.pkg,tolerated);
|
|
212
|
+
assertSnapshotBoundaries(snapshots,base,[parent,...earlier.map(entry=>entry.pkg),...later.map(entry=>entry.pkg)]);
|
|
213
|
+
if(snapshots)applyDelivery(expected,{changes:snapshots.files.map(file=>({path:file.path,before:null,after:file}))},strict);
|
|
214
|
+
compareCurrent({root,base,state:expected,tolerated});
|
|
144
215
|
}
|
|
145
216
|
|
|
146
217
|
// One deterministic order for a run with QA fixes, from facts fixed at
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Runs host-configured, already-authorized project checks. Commands may execute
|
|
2
2
|
// project code; specsRoot opts into Codex's native sandbox for that subprocess.
|
|
3
3
|
// Without specsRoot this preserves the existing direct host-check behavior.
|
|
4
|
+
import {signalOwnedGroup} from './process-group-exit.mjs';
|
|
4
5
|
import {beginHostStage} from './host-stage-observer.mjs';
|
|
5
6
|
import fs from 'node:fs';
|
|
6
7
|
import path from 'node:path';
|
|
@@ -74,13 +75,18 @@ export function createHostCheck({cwd,commands,timeoutMs=60000,specsRoot=null,out
|
|
|
74
75
|
const match=line.trim().match(/^[^0-9A-Za-z]*(tests|suites|pass|passed|passing|fail|failed|failing|skipped|todo)\s*[:=]?\s*(\d+)\s*$/i);
|
|
75
76
|
if(match&&counts.size<8&&!counts.has(match[1].toLowerCase()))counts.set(match[1].toLowerCase(),match[2]);
|
|
76
77
|
};
|
|
77
|
-
|
|
78
|
+
// signalOwnedGroup (process-group-exit.mjs): an exited, not yet reaped command
|
|
79
|
+
// (EPERM on macOS) is stopped only once its exit is observed and a re-probe
|
|
80
|
+
// answers ESRCH; anything unproven is cleanup_failed, as before.
|
|
81
|
+
const kill=async name=>{
|
|
78
82
|
if(!Number.isInteger(child.pid)||child.pid<=0)return false;
|
|
79
|
-
try{
|
|
80
|
-
catch
|
|
83
|
+
try{return await signalOwnedGroup(child,name)==='sent';}
|
|
84
|
+
catch{failure??='cleanup_failed';return false;}
|
|
81
85
|
};
|
|
82
|
-
const clean=()=>cleanup??=(
|
|
83
|
-
|
|
86
|
+
const clean=()=>cleanup??=(async()=>{
|
|
87
|
+
if(!await kill('SIGTERM'))return;
|
|
88
|
+
await new Promise(done=>setTimeout(done,1000));await kill('SIGKILL');
|
|
89
|
+
})();
|
|
84
90
|
const stop=reason=>{failure??=reason;clean();};
|
|
85
91
|
const abort=()=>stop('cancelled');
|
|
86
92
|
signal.addEventListener('abort',abort,{once:true});
|
|
@@ -18,9 +18,13 @@ import {createCodexReviewRun} from './codex-review-adapter.mjs';
|
|
|
18
18
|
import {createClaudeReviewRun} from './claude-review-adapter.mjs';
|
|
19
19
|
import {claudeWorker,claudePreflightMatches} from './worker-claude.mjs';
|
|
20
20
|
import {codexWorker,preflightMatches} from './worker-codex.mjs';
|
|
21
|
-
import {createHostWorkflowCapabilities} from './host-workflow-capabilities.mjs';
|
|
21
|
+
import {createHostWorkflowCapabilities,createImplicitQaDecision} from './host-workflow-capabilities.mjs';
|
|
22
22
|
import {resolveHostRole} from './host-role-routing.mjs';
|
|
23
23
|
import {checklistGaps} from './checklist-coverage.mjs';
|
|
24
|
+
import {readRequirementItems,splitRequirementReport} from './requirement-evidence.mjs';
|
|
25
|
+
import {replayDelivery,notReplayed} from './host-replay.mjs';
|
|
26
|
+
import {autoVerificationVerdict} from './verification-auto.mjs';
|
|
27
|
+
import {declaredTaskScope} from '../task-scope.mjs';
|
|
24
28
|
import {specsPermissionArgs} from './codex-config.mjs';
|
|
25
29
|
import {createProjectExecution} from './host-project-execution.mjs';
|
|
26
30
|
import {codeProjectPaths,codeProjectInstructionPaths,resolveCodeProjects} from './code-projects.mjs';
|
|
@@ -55,20 +59,10 @@ export const externalConversationDefinition=execution=>externalConversations.get
|
|
|
55
59
|
// requirement is satisfied. Mechanical shape is not semantic coverage.
|
|
56
60
|
export function readVerificationPrecheck(raw){
|
|
57
61
|
const value=json(raw,256*1024);shape(value,['items']);
|
|
58
|
-
const items=arrayItems(value.items);
|
|
59
|
-
need(items.length>0&&items.length<=64,'verification_precheck_invalid');
|
|
60
|
-
for(const item of items){
|
|
61
|
-
shape(item,['requirement','satisfied','evidence']);
|
|
62
|
-
need(typeof item.satisfied==='boolean','verification_precheck_invalid');
|
|
63
|
-
for(const field of ['requirement','evidence']){
|
|
64
|
-
const text=item[field];
|
|
65
|
-
need(typeof text==='string'&&text.trim().length>0&&Buffer.byteLength(text,'utf8')<=2000
|
|
66
|
-
&&!/[\x00-\x08\x0b-\x1f]/.test(text),'verification_precheck_invalid');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
62
|
+
const items=readRequirementItems(arrayItems(value.items));
|
|
69
63
|
return freeze({satisfied:items.every(item=>item.satisfied===true),
|
|
70
64
|
unsatisfied:items.filter(item=>item.satisfied!==true).map(item=>item.requirement),
|
|
71
|
-
evidence:items.map(item=>item.evidence).join('\n')});
|
|
65
|
+
evidence:items.map(item=>item.evidence).join('\n'),items});
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
// The delivered evidence usually lives in the scope files (a walkthrough
|
|
@@ -107,14 +101,25 @@ export const REVIEW_BOUND_MARGIN_MS=60000;
|
|
|
107
101
|
export const reviewRaceTimeout=(outerTimeoutMs,reviewTimeoutMs)=>Math.max(outerTimeoutMs,reviewTimeoutMs+REVIEW_BOUND_MARGIN_MS);
|
|
108
102
|
export function createConversationExecution(definition,hostContextId,bridge,review=null,reservedReviewAttempt=null,workflow=null,allowQa=false,runtime='codex',options={}){
|
|
109
103
|
definition=json(definition);workflow=workflow===null?null:json(workflow);options=json(options);
|
|
110
|
-
shape(options,[...['originalHostContextId','protection','batchWorkflowsDigest','qaLogHome','bootstrap','providerDevelopment','externalModels','reviewerRuntime','reviewRuntime','parallelMember','verificationPrecheck','executionPolicy','controlPolicy'].filter(key=>Object.hasOwn(options,key))]);
|
|
104
|
+
shape(options,[...['originalHostContextId','protection','batchWorkflowsDigest','qaLogHome','bootstrap','providerDevelopment','externalModels','reviewerRuntime','reviewRuntime','parallelMember','soloMember','verificationPrecheck','executionPolicy','controlPolicy','memberDevelopment'].filter(key=>Object.hasOwn(options,key))]);
|
|
111
105
|
const controlPolicy=options.controlPolicy?readControlPolicy(options.controlPolicy):null;
|
|
112
106
|
need(!Object.hasOwn(options,'verificationPrecheck')||typeof options.verificationPrecheck==='boolean','invalid_input');
|
|
113
107
|
const executionPolicy=options.executionPolicy?readExecutionPolicy(options.executionPolicy):null;
|
|
114
108
|
const parallelMember=options.parallelMember??false;need(typeof parallelMember==='boolean','invalid_input');
|
|
109
|
+
// soloMember: a worktree member alone in its group (batch-plan.mjs worktree_all). It
|
|
110
|
+
// keeps the worktree review and bridge of a member but not the deferred QA: only a
|
|
111
|
+
// member developed alongside others defers its N6 to the feature's final task.
|
|
112
|
+
const soloMember=options.soloMember??false;need(typeof soloMember==='boolean'&&(!soloMember||parallelMember),'invalid_input');
|
|
113
|
+
const deferMemberQa=parallelMember&&!soloMember;
|
|
115
114
|
const provider=options.providerDevelopment??null;
|
|
115
|
+
// memberDevelopment 'session': a batch execution table (batch-plan.mjs) has the
|
|
116
|
+
// current session develop this member, so it never carries providerDevelopment, even
|
|
117
|
+
// under a provider policy; every other member of such a policy carries it.
|
|
118
|
+
need(!Object.hasOwn(options,'memberDevelopment')||options.memberDevelopment==='session','invalid_input');
|
|
119
|
+
const sessionMember=options.memberDevelopment==='session';
|
|
120
|
+
need(!sessionMember||!provider,'invalid_arguments');
|
|
116
121
|
if(controlPolicy){
|
|
117
|
-
need((controlPolicy.development==='provider')===Boolean(provider),'invalid_arguments');
|
|
122
|
+
need((controlPolicy.development==='provider'&&!sessionMember)===Boolean(provider),'invalid_arguments');
|
|
118
123
|
need(controlPolicy.bootstrap!=='write'||Boolean(options.bootstrap),'invalid_arguments');
|
|
119
124
|
need(controlPolicy.qa!=='run'||workflow?.qa!=null,'invalid_arguments');
|
|
120
125
|
need(!options.bootstrap||controlPolicy.bootstrap==='write','invalid_arguments');
|
|
@@ -165,7 +170,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
165
170
|
// Keep the unverified native permissions boundary intact for this first host
|
|
166
171
|
// slice too. A transport is not physical protection of nested specs.
|
|
167
172
|
need(protection||!definition.specsDir.startsWith(definition.codeProject+path.sep),'nested_specs_protection_required');
|
|
168
|
-
const configuration={kind:'cm-current-conversation-v1',...(parallelMember?{parallelMember}:{}),definitionDigest:digest(definition),hostContextId:durableHostContextId,
|
|
173
|
+
const configuration={kind:'cm-current-conversation-v1',...(parallelMember?{parallelMember}:{}),...(soloMember?{soloMember}:{}),definitionDigest:digest(definition),hostContextId:durableHostContextId,
|
|
169
174
|
...(controlPolicy?{controlPolicy}:{}),
|
|
170
175
|
...(runtime==='claude'?{runtime}:{}),
|
|
171
176
|
...(options.reviewRuntime===undefined?{}:{reviewRuntime:options.reviewRuntime}),
|
|
@@ -186,6 +191,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
186
191
|
// Preserve P4a's unauthorizable placeholder bytes for existing unconfigured runs.
|
|
187
192
|
const reviewProvider=review?reviewerRuntime:'codex', adapterId=`${reviewProvider}-review-adapter`;
|
|
188
193
|
// Reread role declarations at each boundary; never switch a bound invocation.
|
|
194
|
+
// A session member's review (bound pair checked at construction) is rechecked too.
|
|
189
195
|
// onWorker (provider development, task-runner.mjs) journals the worker's
|
|
190
196
|
// identity right before and right after the spawn; a journal failure kills
|
|
191
197
|
// the new process group like a refused role route does.
|
|
@@ -206,17 +212,40 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
206
212
|
};
|
|
207
213
|
};
|
|
208
214
|
const used=new Set();
|
|
215
|
+
// Host replay (host-replay.mjs) restores the task baseline the runner hands the
|
|
216
|
+
// gate (control.baselineSnapshot). Each attempt's per-requirement report is split
|
|
217
|
+
// off the developer value before it is validated or journaled; it lives in memory
|
|
218
|
+
// only, so a resumed process without it reports the report as missing.
|
|
219
|
+
const requirementReports=new Map();
|
|
220
|
+
const reportKey=identity=>`${identity.taskId}:${identity.attempt}`;
|
|
221
|
+
const replayable=projectExecution!==null&&!definition.codeProjects;
|
|
222
|
+
const declaredTests=taskId=>{try{return declaredTaskScope(definition.specsDir,definition.feature,taskId)?.tests??[];}catch{return [];}};
|
|
223
|
+
// Only a protected single-root run has host checks to replay; any other run
|
|
224
|
+
// keeps its gate request and handoff exactly as before (facts null).
|
|
225
|
+
const hostRuns=(request,control)=>replayable?replayDelivery({codeProject:definition.codeProject,specsDir:definition.specsDir,
|
|
226
|
+
snapshot:control.baselineSnapshot??null,scope:request.scope??definition.scope,
|
|
227
|
+
tests:declaredTests(request.identity.taskId),checkCommands:protection.checkCommands,timeoutMs:protection.timeoutMs,
|
|
228
|
+
identity:request.identity,greenChecks:request.checks,signal:control.signal}):null;
|
|
209
229
|
// The gate is opt-in: without it the flow is byte-for-byte what it was.
|
|
210
230
|
// The runner contract is exactly {satisfied}. Which requirements failed is
|
|
211
231
|
// what the operator needs to act on, so it goes to this process's stderr the
|
|
212
232
|
// same way other host diagnostics do, not into the runner state.
|
|
213
|
-
|
|
214
|
-
|
|
233
|
+
// A v2 policy may enable the gate durably (it is part of the run fingerprint);
|
|
234
|
+
// the legacy launch flag keeps working for runs created without it.
|
|
235
|
+
// auto: the host answers from the developer's report and its own runs
|
|
236
|
+
// (verification-auto.mjs); precheck: the session answers, seeing the host runs.
|
|
237
|
+
const gateMode=controlPolicy?.verification==='auto'?'auto'
|
|
238
|
+
:options.verificationPrecheck===true||controlPolicy?.verification==='precheck'?'precheck':null;
|
|
239
|
+
const verificationGate=gateMode?async(request,control)=>{
|
|
240
|
+
const facts=await hostRuns(request,control);
|
|
241
|
+
const verdict=gateMode==='auto'?autoVerificationVerdict({report:requirementReports.get(reportKey(request.identity))??null,
|
|
242
|
+
facts:facts??notReplayed(definition.codeProjects?'multi_root':'no_host_checks',request.checks)})
|
|
243
|
+
:readVerificationPrecheck(await bridge.call('verification_precheck',
|
|
215
244
|
{...request,codeProject:definition.codeProject,feature:definition.feature,
|
|
216
|
-
scope:definition.scope},control.signal));
|
|
245
|
+
scope:request.scope??definition.scope,...(facts?{hostRuns:facts}:{})},control.signal));
|
|
217
246
|
if(!verdict.satisfied)try{
|
|
218
247
|
process.stderr.write(JSON.stringify({diagnostic:'verification_precheck_failed',
|
|
219
|
-
task:request.identity.taskId,attempt:request.identity.attempt,
|
|
248
|
+
task:request.identity.taskId,attempt:request.identity.attempt,mode:gateMode,
|
|
220
249
|
unsatisfied:verdict.unsatisfied})+'\n');
|
|
221
250
|
}catch{/* diagnostics never change the verdict */}
|
|
222
251
|
// Advisory only. An enumerated list in the task text whose entries are not
|
|
@@ -226,12 +255,16 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
226
255
|
try{
|
|
227
256
|
const gaps=checklistGaps([request.description,request.verification]
|
|
228
257
|
.filter(text=>typeof text==='string').join('\n'),
|
|
229
|
-
[verdict.evidence
|
|
258
|
+
[verdict.evidence??(verdict.items??[]).map(item=>item.evidence).join('\n'),
|
|
259
|
+
deliveredText(definition.codeProject,request.scope??definition.scope)].join('\n'));
|
|
230
260
|
if(gaps.length>0)process.stderr.write(JSON.stringify({diagnostic:'checklist_coverage',
|
|
231
261
|
task:request.identity.taskId,attempt:request.identity.attempt,advisory:true,
|
|
232
262
|
gaps:gaps.map(gap=>({total:gap.total,missing:gap.missing}))})+'\n');
|
|
233
263
|
}catch{/* diagnostics never change the verdict */}
|
|
234
|
-
|
|
264
|
+
// The answered items travel to the runner, which binds them into the host
|
|
265
|
+
// handoff the reviewer reads; a failed gate halts before any handoff exists.
|
|
266
|
+
// The host record travels as its own handoff entry (host-replay.mjs), never inside the items.
|
|
267
|
+
return verdict.satisfied?{satisfied:true,items:verdict.items,...(facts?{hostRecord:facts}:{})}:{satisfied:false};
|
|
235
268
|
}:null;
|
|
236
269
|
const outerTimeoutMs=provider?protection.timeoutMs:1800000;
|
|
237
270
|
const progress=(request,control,stage,run,selectedRuntime=runtime)=>withHostProgress({definition,
|
|
@@ -240,7 +273,8 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
240
273
|
...(verificationGate?{verificationGate:(request,control)=>progress(request,control,'verifying',()=>verificationGate(request,control))}:{}),
|
|
241
274
|
...(bootstrap?{bootstrap}:{}),
|
|
242
275
|
...(provider&&!controlPolicy?{developmentAttempt:provider.attempt}:{}),
|
|
243
|
-
...(workflow?createHostWorkflowCapabilities({definition,configuration:workflow,bridge,allowQa,runtime,protectedExecution:protection!==null,bootstrap,parallelMember,controlPolicy})
|
|
276
|
+
...(workflow?createHostWorkflowCapabilities({definition,configuration:workflow,bridge,allowQa,runtime,protectedExecution:protection!==null,bootstrap,parallelMember:deferMemberQa,controlPolicy})
|
|
277
|
+
:controlPolicy?createImplicitQaDecision({definition,bridge,parallelMember:deferMemberQa,controlPolicy}):{}),
|
|
244
278
|
...(options.qaLogHome?{qaLogHome:options.qaLogHome}:{}),
|
|
245
279
|
developer:{provider:coderRuntime,requestedModel:provider?.model??'current-session',contextId:author,run:async(request,control)=>{
|
|
246
280
|
const bound=(coderRuntime==='codex'?readCodexDeveloperRequest:readClaudeDeveloperRequest)(request);
|
|
@@ -256,10 +290,18 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
256
290
|
cwd:definition.codeProject,model:provider.model,...(externalModels?{effort:provider.effort}:{}),timeoutMs:protection.timeoutMs,
|
|
257
291
|
...(coderRuntime==='codex'?{specsRoot:definition.specsDir}:{}),
|
|
258
292
|
spawnProcess:dispatchSpawn('coder',bound.identity,control.signal,typeof control.onWorker==='function'?control.onWorker:null)}):null;
|
|
293
|
+
const splitReport=response=>{
|
|
294
|
+
if(response?.status!=='succeeded')return response;
|
|
295
|
+
const split=splitRequirementReport(response.value);
|
|
296
|
+
requirementReports.set(reportKey(bound.identity),split.items);
|
|
297
|
+
if(split.items==='invalid')try{process.stderr.write(JSON.stringify({diagnostic:'requirement_report_invalid',
|
|
298
|
+
task:bound.identity.taskId,attempt:bound.identity.attempt,problem:split.problem})+'\n');}catch{/* diagnostics never change the result */}
|
|
299
|
+
return {...response,value:split.value};
|
|
300
|
+
};
|
|
259
301
|
const worker=async({prompt})=>{
|
|
260
302
|
if(provider&&coderRuntime==='codex'){
|
|
261
303
|
if(documentationPaths.length)prompt='Synchronize approved documentation inside this invocation: '+JSON.stringify(documentationPaths)+'\n'+prompt;
|
|
262
|
-
const response=await processWorker({prompt},control);
|
|
304
|
+
const response=splitReport(await processWorker({prompt},control));
|
|
263
305
|
developerLog?.complete(developerUsage??{usage_state:'unavailable'},response.status==='succeeded'?'success':response.status==='cancelled'?'cancelled':'error');
|
|
264
306
|
return response;
|
|
265
307
|
}
|
|
@@ -269,10 +311,10 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
269
311
|
if(!parallelMember&&documentationPaths.length&&isFinalCmAiTask({specsDir:definition.specsDir,codeProject:definition.codeProject,
|
|
270
312
|
feature:definition.feature,taskId:bound.identity.taskId,featureSelection:definition.featureSelection?.feature}))prompt+=' Include necessary documentation synchronization in the same edits: '+JSON.stringify(documentationPaths);
|
|
271
313
|
}
|
|
272
|
-
const response=provider?await processWorker({prompt:prompt+'\n'+JSON.stringify({editMode:'protected-text-v1',expected})},control):json(await bridge.call('develop',{request:bound,prompt,codeProject:definition.codeProject,route,
|
|
314
|
+
const response=splitReport(provider?await processWorker({prompt:prompt+'\n'+JSON.stringify({editMode:'protected-text-v1',expected})},control):json(await bridge.call('develop',{request:bound,prompt,codeProject:definition.codeProject,route,
|
|
273
315
|
...(definition.codeProjects?{codeProjects:resolveCodeProjects(definition.codeProject,definition.codeProjects),
|
|
274
316
|
projectInstructions:definition.codeProjects.map(root=>({codeProject:root,files:readProjectInstructionContext(root)}))}:{}),
|
|
275
|
-
...(protection?{editMode:'protected-text-v1',expected}: {})},control.signal));
|
|
317
|
+
...(protection?{editMode:'protected-text-v1',expected}: {})},control.signal)));
|
|
276
318
|
if(provider)developerLog?.complete(developerUsage??{usage_state:'unavailable'},response.status==='succeeded'?'success':response.status==='cancelled'?'cancelled':'error');
|
|
277
319
|
if(response.status==='succeeded'){
|
|
278
320
|
const edits=[];
|
|
@@ -331,7 +373,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
331
373
|
if(check)return check(request,control);
|
|
332
374
|
const route=resolveHostRole({definition,identity:request.identity,role:'tester',signal:control.signal,runtime});
|
|
333
375
|
return bridge.call('check',{...request,codeProject:definition.codeProject,
|
|
334
|
-
scope:definition.scope,requirements:definition.requirements,route},control.signal);
|
|
376
|
+
scope:request.scope??definition.scope,requirements:definition.requirements,route},control.signal);
|
|
335
377
|
}),
|
|
336
378
|
// The process adapter records observed reviewer events. Preflight checks capability.
|
|
337
379
|
reviewers:[{id:'reviewer',adapterId,provider:reviewProvider,requestedModel:reviewOptions.model,
|
|
@@ -339,7 +381,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
339
381
|
run:(request,control)=>{
|
|
340
382
|
need(review!==null,'review_configuration_required');
|
|
341
383
|
let observedUsage=null;const usageLog=executionPolicy?createNativeUsageLog({definition,request,provider:reviewerRuntime,role:'reviewer'}):null;
|
|
342
|
-
const selectedOptions={...reviewOptions,...(usageLog?{onUsageClaim:()=>usageLog.claimed(),onUsage:value=>{observedUsage=value;}}:{}),...(provider?{spawnProcess:dispatchSpawn('reviewer',request.identity,control.signal)}:{})};
|
|
384
|
+
const selectedOptions={...reviewOptions,...(usageLog?{onUsageClaim:()=>usageLog.claimed(),onUsage:value=>{observedUsage=value;}}:{}),...(provider||sessionMember&&options.reviewRuntime!==undefined?{spawnProcess:dispatchSpawn('reviewer',request.identity,control.signal)}:{})};
|
|
343
385
|
return progress(request,control,'review_starting',async observation=>{
|
|
344
386
|
const observedControl={...control,onEvent:event=>{
|
|
345
387
|
control.onEvent(event);
|
|
@@ -112,7 +112,7 @@ function logStep(configuration,binding,event,phase,data,detail) {
|
|
|
112
112
|
// empty). A FAIL, a BLOCKED, another environment or a failed cleanup is never
|
|
113
113
|
// asked again: those stay as judged, and only an explicit recovery reruns them.
|
|
114
114
|
const CORRECTION_INSTRUCTION='Only the evidence list of the previous PASS answer can be corrected. Evidence must be non-empty '
|
|
115
|
-
+'files inside the .reviews directory of the specs root (for example
|
|
115
|
+
+'files inside the .reviews directory of the specs root (for example the evidenceDirectory of this request, created if missing); copy the files you observed '
|
|
116
116
|
+'there and answer again. Keep the verdict, environment and cleanup you actually observed; if you no longer stand by the '
|
|
117
117
|
+'PASS, answer FAIL or BLOCKED.';
|
|
118
118
|
// Every other condition of the verdict must already hold, so the correction can
|
|
@@ -129,6 +129,22 @@ function answerProblems(configuration,observed,environment,item){
|
|
|
129
129
|
return problems;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
// A QA command that declares reuseCheck takes the result of that task check
|
|
133
|
+
// instead of running again, only when the check ran the identical command on
|
|
134
|
+
// this reviewed package and passed. The entry hands over the package's checks
|
|
135
|
+
// after proving the code root still matches that package (runner
|
|
136
|
+
// qaCompletionChecks); anything else runs the command as before and says why.
|
|
137
|
+
function reusedTaskCheck(command,checks,packageDigest){
|
|
138
|
+
if(!Object.hasOwn(command,'reuseCheck'))return {};
|
|
139
|
+
if(checks===null)return {unavailable:'no_verified_task_checks'};
|
|
140
|
+
const check=checks.find(item=>item?.id===command.reuseCheck);
|
|
141
|
+
if(!check)return {unavailable:'check_not_in_package'};
|
|
142
|
+
if(JSON.stringify(check.command)!==JSON.stringify(command.command))return {unavailable:'command_differs'};
|
|
143
|
+
if(check.outcome!=='passed'||check.exitCode!==0)return {unavailable:'check_not_passed'};
|
|
144
|
+
const evidence=`reused task check ${check.id} of reviewed package ${packageDigest.slice(0,12)}: ${String(check.evidence??'')}`.slice(0,500);
|
|
145
|
+
return {observed:{outcome:'passed',exitCode:0,evidence}};
|
|
146
|
+
}
|
|
147
|
+
|
|
132
148
|
function evidence(raw) {
|
|
133
149
|
const result=json(raw);need(Array.isArray(result)&&result.length>0&&result.length<=32,'qa_evidence_required');
|
|
134
150
|
for(const item of result){text(item);need(item.length<=2000&&!item.includes('\0'),'qa_evidence_required');}
|
|
@@ -178,8 +194,11 @@ export function createHostQaExecutor(options) {
|
|
|
178
194
|
need(['codex','claude'].includes(configuration.runtime));validCallTimeout(configuration.timeoutMs);
|
|
179
195
|
const ids=new Set();need(Array.isArray(configuration.commands)&&configuration.commands.length<=32);
|
|
180
196
|
for(const item of configuration.commands){
|
|
181
|
-
shape(item,['id','command','caseIds',...(roots?['codeProject']:[])
|
|
197
|
+
shape(item,['id','command','caseIds',...(roots?['codeProject']:[]),...(Object.hasOwn(item,'reuseCheck')?['reuseCheck']:[])]);
|
|
198
|
+
id(item.id);need(!ids.has(item.id));ids.add(item.id);
|
|
182
199
|
if(roots)need(roots.includes(item.codeProject),'execution_root_mismatch');
|
|
200
|
+
// Opt-in: name the task check with the same command; see reusedTaskCheck below.
|
|
201
|
+
if(Object.hasOwn(item,'reuseCheck')){id(item.reuseCheck);need(!roots,'qa_check_reuse_invalid');}
|
|
183
202
|
need(Array.isArray(item.caseIds)&&new Set(item.caseIds).size===item.caseIds.length);
|
|
184
203
|
for(const caseId of item.caseIds)id(caseId);
|
|
185
204
|
// Reuse the actual host checker validator, without running a command.
|
|
@@ -205,9 +224,10 @@ export function createHostQaExecutor(options) {
|
|
|
205
224
|
return Object.freeze({...initial,timeoutMs:configuration.timeoutMs,prepare,
|
|
206
225
|
async run(rawBinding,signal){
|
|
207
226
|
const {mode,caseCount,configuration:{plan}}=prepared??prepare();
|
|
208
|
-
let binding=json(rawBinding);
|
|
227
|
+
let {completionChecks=null,...binding}=json(rawBinding);
|
|
209
228
|
shape(binding,['specsDir','codeProject','feature','identity','packageDigest','testRunId','mode','caseCount',
|
|
210
229
|
...(Object.hasOwn(binding,'qaRound')?['qaRound']:[])]);
|
|
230
|
+
need(completionChecks===null||Array.isArray(completionChecks)&&completionChecks.length<=32,'qa_check_reuse_invalid');
|
|
211
231
|
validIdentity(binding.identity);hex(binding.packageDigest);id(binding.testRunId);
|
|
212
232
|
const qaRound=readCmAiQaRunRound({specsDir:binding.specsDir,feature:binding.feature,
|
|
213
233
|
identity:binding.identity,packageDigest:binding.packageDigest,testRunId:binding.testRunId});
|
|
@@ -243,6 +263,13 @@ export function createHostQaExecutor(options) {
|
|
|
243
263
|
else if(!plan.commands.length)rows.push({id:'commands-unavailable',kind:'commands',verdict:'BLOCKED',evidence:['No declared project test command',...dropped]});
|
|
244
264
|
for(const command of plan.commands){
|
|
245
265
|
notCancelled();
|
|
266
|
+
const reuse=reusedTaskCheck(command,completionChecks,binding.packageDigest);
|
|
267
|
+
if(reuse.observed){
|
|
268
|
+
commandResults.set(command.id,reuse.observed);
|
|
269
|
+
rows.push({id:command.id,kind:'commands',verdict:'PASS',exitCode:reuse.observed.exitCode,
|
|
270
|
+
evidence:[reuse.observed.evidence],reusedCheck:command.reuseCheck});
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
246
273
|
// Q13: the command's process group identity, so a cleanup_failed row can
|
|
247
274
|
// later be released once the host proves that group gone.
|
|
248
275
|
let spawned=null;
|
|
@@ -265,11 +292,17 @@ export function createHostQaExecutor(options) {
|
|
|
265
292
|
notCancelled();
|
|
266
293
|
commandResults.set(command.id,observed);
|
|
267
294
|
rows.push({id:command.id,kind:'commands',verdict:observed.outcome==='passed'?'PASS':observed.outcome==='failed'?'FAIL':'BLOCKED',
|
|
268
|
-
exitCode:observed.exitCode,evidence:[...(roots?[`cwd=${command.codeProject}`]:[]),observed.evidence]
|
|
295
|
+
exitCode:observed.exitCode,evidence:[...(roots?[`cwd=${command.codeProject}`]:[]),observed.evidence],
|
|
296
|
+
...(reuse.unavailable?{reuseUnavailable:reuse.unavailable}:{})});
|
|
269
297
|
}
|
|
270
298
|
}else for(const item of plan.cases.filter(candidate=>candidate.kind===stage)){
|
|
271
299
|
notCancelled();
|
|
272
|
-
|
|
300
|
+
// A browser case is told where inside {specs}/.reviews to put its evidence
|
|
301
|
+
// files, the only place an answer's evidence is accepted from. Only a path:
|
|
302
|
+
// the host creates nothing there, and reportFile still judges every file.
|
|
303
|
+
const evidenceDirectory=stage==='browser'?path.join(configuration.specsDir,'.reviews','qa-evidence',binding.testRunId,item.id):null;
|
|
304
|
+
const request=freeze({...binding,case:item,route:routed,environment,...(roots?{codeProjects:roots}:{}),
|
|
305
|
+
...(evidenceDirectory?{evidenceDirectory}:{})});
|
|
273
306
|
if(stage==='logic'){
|
|
274
307
|
let observed,hostRequestTimeout=false;
|
|
275
308
|
try{observed=logic===null?{verdict:'INSUFFICIENT_EVIDENCE',evidence:['Logic host unavailable']}:json(await logic(request,signal));}
|
|
@@ -46,7 +46,7 @@ export function createQaFixOwnerHost({parent,reopenParent,hostContextId,parentHo
|
|
|
46
46
|
if(fixedTemplate)fixedTemplate=inherited;else definition=inherited;
|
|
47
47
|
}
|
|
48
48
|
if(externalModels){
|
|
49
|
-
const target=fixedTemplate??definition,runtime=target.configuration.runtime??'codex';
|
|
49
|
+
const target=fixedTemplate??definition,runtime=target.configuration.reviewRuntime??target.configuration.runtime??'codex';
|
|
50
50
|
const selected=selectExternalModels(externalModels,[runtime]);
|
|
51
51
|
if(!fixedTemplate&&!target.configuration.externalModels)need(false,'external_model_legacy_child_inheritance_forbidden');
|
|
52
52
|
if(target.configuration.externalModels)need(digest(target.configuration.externalModels)===digest(selected),'external_model_pair_conflict');
|
|
@@ -121,7 +121,7 @@ export function createQaFixOwnerHost({parent,reopenParent,hostContextId,parentHo
|
|
|
121
121
|
let actionResult;
|
|
122
122
|
if(advancing||acting){
|
|
123
123
|
const host=createFixHost({owner:child,config:{...definition.configuration,specsRoot:definition.specsRoot,identity:definition.identity},
|
|
124
|
-
runtime:definition.configuration.runtime??'codex',permissions:[...permissions,'--allow-reproduction'],...fixAuthorities,recoveryInvocationId});
|
|
124
|
+
runtime:definition.configuration.runtime??'codex',reviewRuntime:definition.configuration.reviewRuntime,permissions:[...permissions,'--allow-reproduction'],...fixAuthorities,recoveryInvocationId});
|
|
125
125
|
const action=advancing?{operation:'advance'}:{operation:value.fixOperation,
|
|
126
126
|
...(value.fixOperation==='reconcile_review'?{invocationId:value.invocationId}:{}),
|
|
127
127
|
...(QA_FIX_REASONED.includes(value.fixOperation)?{reason:value.reason}:{}),
|