@aibyzero/cm-workflow 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +23 -0
- package/CHANGELOG.md +224 -0
- package/README.md +14 -3
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/VERSION +1 -1
- package/compat/claude-commands/cm-challenge.md +3 -0
- package/docs/architecture.md +11 -0
- package/docs/cm-control-policy-v2.md +127 -9
- package/docs/installation.md +310 -4
- package/docs/js-workflow-control.md +150 -15
- package/docs/live-evidence-drivers.md +28 -4
- package/docs/out-of-scope/README.md +25 -0
- package/docs/out-of-scope/background-supervisor.md +32 -0
- package/docs/reviewed-integration.md +48 -0
- package/docs/user-guide.md +50 -21
- package/install-codex.sh +331 -18
- package/install.ps1 +28 -2
- package/install.sh +321 -17
- package/package.json +2 -1
- package/runtime/js/cm-ai/batch-location.mjs +55 -0
- package/runtime/js/cm-ai/batch-plan.mjs +242 -0
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +83 -14
- package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
- package/runtime/js/cm-ai/codex-config.mjs +6 -2
- package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
- package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
- package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
- package/runtime/js/cm-ai/control-policy.mjs +21 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
- package/runtime/js/cm-ai/drive-core.mjs +114 -11
- package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
- package/runtime/js/cm-ai/effect-contract.mjs +11 -2
- package/runtime/js/cm-ai/execution-policy.mjs +3 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
- package/runtime/js/cm-ai/execution-store.mjs +60 -17
- package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
- package/runtime/js/cm-ai/host-check.mjs +11 -5
- package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
- package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
- package/runtime/js/cm-ai/host-replay.mjs +148 -0
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
- package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
- package/runtime/js/cm-ai/live-evidence.mjs +28 -6
- package/runtime/js/cm-ai/operator-guidance.mjs +9 -2
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
- package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
- package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
- package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
- package/runtime/js/cm-ai/review-package.mjs +79 -7
- package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
- package/runtime/js/cm-ai/review-presentation.mjs +177 -8
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
- package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
- package/runtime/js/cm-ai/scope-revision.mjs +38 -0
- package/runtime/js/cm-ai/specification-material.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +242 -39
- package/runtime/js/cm-ai/verification-auto.mjs +38 -0
- package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
- package/runtime/js/cm-ai/worker-claude.mjs +35 -13
- package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
- package/runtime/js/cm-ai/worker-codex.mjs +41 -7
- package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
- package/runtime/js/cm-fix/cause-package.mjs +46 -1
- package/runtime/js/cm-fix/command-correction.mjs +37 -0
- package/runtime/js/cm-fix/cooperative.mjs +12 -0
- package/runtime/js/cm-fix/dossier.mjs +8 -2
- package/runtime/js/cm-fix/execution.mjs +578 -100
- package/runtime/js/cm-fix/final-review.mjs +39 -8
- package/runtime/js/cm-fix/finish.mjs +15 -11
- package/runtime/js/cm-fix/host-review.mjs +65 -10
- package/runtime/js/cm-fix/host.mjs +35 -12
- package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
- package/runtime/js/cm-fix/metrics.mjs +18 -5
- package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
- package/runtime/js/cm-fix/regression.mjs +16 -7
- package/runtime/js/cm-fix/repair.mjs +29 -8
- package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
- package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
- package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
- package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
- package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
- package/runtime/js/cm-fix/review-verification.mjs +214 -0
- package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
- package/runtime/js/cm-fix/start.mjs +6 -3
- package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
- package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
- package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
- package/runtime/js/cm-prd/accepted-design.mjs +8 -0
- package/runtime/js/cm-prd/analysis.mjs +13 -9
- package/runtime/js/cm-prd/change.mjs +37 -16
- package/runtime/js/cm-prd/draft-save.mjs +13 -6
- package/runtime/js/cm-prd/draft.mjs +31 -3
- package/runtime/js/cm-prd/failed-correction.mjs +19 -3
- package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
- package/runtime/js/cm-prd/review-correction.mjs +6 -4
- package/runtime/js/cm-prd/review-disposition.mjs +7 -1
- package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
- package/runtime/js/cm-prd/self-check.mjs +125 -6
- package/runtime/js/cm-prd/session.mjs +30 -1
- package/runtime/js/cm-prd/summary.mjs +11 -5
- package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
- package/runtime/js/cm-prd/tree-digest.mjs +34 -0
- package/runtime/js/cm-prd/validation-reason.mjs +8 -4
- package/runtime/js/cm-security/scan.mjs +1 -1
- package/runtime/js/commander/decision.mjs +44 -0
- package/runtime/js/commander/dispatch-registry.mjs +110 -0
- package/runtime/js/commander/ledger.mjs +265 -0
- package/runtime/js/commander/preflight.mjs +107 -0
- package/runtime/js/notify-later.mjs +13 -0
- package/runtime/js/notify-send.mjs +6 -2
- package/runtime/js/notify.mjs +570 -63
- package/runtime/js/review-findings.mjs +38 -0
- package/runtime/js/session-boundary.mjs +56 -0
- package/runtime/js/session-handoff.mjs +68 -0
- package/runtime/js/spec-task-line.mjs +27 -13
- package/runtime/js/specs-status.mjs +1 -1
- package/runtime/js/task-scope.mjs +197 -0
- package/runtime/logging.md +6 -1
- package/runtime/model-efficiency.md +69 -10
- package/runtime/orchestration.md +3 -1
- package/runtime/project-learning.md +2 -0
- package/runtime/review.md +3 -2
- package/runtime/test-contract.md +1 -0
- package/scripts/ci-test-weights.json +3 -0
- package/scripts/cm-ai-admission.mjs +11 -5
- package/scripts/cm-ai-admission.test.mjs +23 -2
- package/scripts/cm-ai-batch-drive.mjs +79 -18
- package/scripts/cm-ai-batch-drive.test.mjs +169 -3
- package/scripts/cm-ai-batch-host.mjs +38 -9
- package/scripts/cm-ai-batch-host.test.mjs +6 -5
- package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
- package/scripts/cm-ai-batch-location.test.mjs +57 -0
- package/scripts/cm-ai-batch-plan.mjs +52 -0
- package/scripts/cm-ai-batch-plan.test.mjs +397 -0
- package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
- package/scripts/cm-ai-batch-run.mjs +471 -57
- package/scripts/cm-ai-batch-run.test.mjs +23 -4
- package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
- package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
- package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
- package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
- package/scripts/cm-ai-control-launch.test.mjs +21 -0
- package/scripts/cm-ai-control-policy.test.mjs +14 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
- package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
- package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
- package/scripts/cm-ai-development-rework.test.mjs +423 -0
- package/scripts/cm-ai-drive.mjs +73 -17
- package/scripts/cm-ai-drive.test.mjs +34 -2
- package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
- package/scripts/cm-ai-host.mjs +60 -19
- package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
- package/scripts/cm-ai-integration-independence.test.mjs +23 -0
- package/scripts/cm-ai-integration-launch.test.mjs +240 -0
- package/scripts/cm-ai-integration-preview.mjs +41 -0
- package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
- package/scripts/cm-ai-nested-execution.test.mjs +29 -1
- package/scripts/cm-ai-operator-guidance.test.mjs +16 -1
- package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
- package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
- package/scripts/cm-ai-review-failure.test.mjs +150 -5
- package/scripts/cm-ai-run.mjs +88 -21
- package/scripts/cm-ai-scope-revision.test.mjs +341 -0
- package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
- package/scripts/cm-ai-supersede.test.mjs +28 -0
- package/scripts/cm-ai-verification-auto.test.mjs +99 -0
- package/scripts/cm-announce-hook.mjs +35 -8
- package/scripts/cm-announce-hook.test.mjs +25 -0
- package/scripts/cm-challenge.test.mjs +61 -0
- package/scripts/cm-check-drive-files.mjs +1 -1
- package/scripts/cm-check-runtime.sh +58 -1
- package/scripts/cm-claude-developer-worker.test.mjs +56 -7
- package/scripts/cm-claude-install-layout.test.mjs +1 -1
- package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
- package/scripts/cm-claude-review-stream.test.mjs +13 -0
- package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
- package/scripts/cm-codex-developer-worker.test.mjs +120 -0
- package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
- package/scripts/cm-codex-prompt-input.test.mjs +153 -0
- package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
- package/scripts/cm-commander-ledger.test.mjs +260 -0
- package/scripts/cm-commander-p2.test.mjs +295 -0
- package/scripts/cm-commander-preflight.mjs +84 -0
- package/scripts/cm-commander.mjs +116 -0
- package/scripts/cm-config-lock.mjs +35 -0
- package/scripts/cm-controlled-correction.test.mjs +10 -1
- package/scripts/cm-developer-failure-code.test.mjs +62 -0
- package/scripts/cm-display-task-id.test.mjs +41 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
- package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
- package/scripts/cm-external-batch-host.test.mjs +4 -3
- package/scripts/cm-external-process-cleanup.test.mjs +128 -0
- package/scripts/cm-external-qa-fix.test.mjs +89 -7
- package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
- package/scripts/cm-failover.mjs +48 -10
- package/scripts/cm-failover.test.mjs +46 -0
- package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
- package/scripts/cm-fix-command-correction.mjs +17 -0
- package/scripts/cm-fix-command-correction.test.mjs +211 -0
- package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
- package/scripts/cm-fix-drive.mjs +33 -5
- package/scripts/cm-fix-drive.test.mjs +49 -0
- package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
- package/scripts/cm-fix-host-review.test.mjs +21 -9
- package/scripts/cm-fix-host.mjs +26 -8
- package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
- package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
- package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
- package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
- package/scripts/cm-fix-review-preflight.mjs +24 -0
- package/scripts/cm-fix-review-storage.test.mjs +233 -0
- package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
- package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
- package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
- package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
- package/scripts/cm-fix-review-verification.test.mjs +146 -0
- package/scripts/cm-fix-revision-transport.test.mjs +81 -0
- package/scripts/cm-fix-source-correction.test.mjs +296 -0
- package/scripts/cm-fix-test-type-correction.mjs +18 -0
- package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
- package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
- package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
- package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
- package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
- package/scripts/cm-fix-verification-recovery.mjs +33 -0
- package/scripts/cm-host-qa-executor.test.mjs +77 -0
- package/scripts/cm-host-replay.test.mjs +176 -0
- package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
- package/scripts/cm-install-manifest.sh +351 -0
- package/scripts/cm-live-evidence.test.mjs +59 -1
- package/scripts/cm-log-event.mjs +61 -10
- package/scripts/cm-log-event.test.mjs +121 -1
- package/scripts/cm-matt-skills.mjs +576 -0
- package/scripts/cm-matt-skills.test.mjs +550 -0
- package/scripts/cm-notify-command.test.mjs +42 -10
- package/scripts/cm-notify.mjs +14 -10
- package/scripts/cm-notify.test.mjs +575 -59
- package/scripts/cm-patrol.mjs +4 -1
- package/scripts/cm-patrol.test.mjs +23 -5
- package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
- package/scripts/cm-prd-completion.test.mjs +56 -13
- package/scripts/cm-prd-design-phase.test.mjs +78 -8
- package/scripts/cm-prd-draft-save.test.mjs +12 -0
- package/scripts/cm-prd-draft.test.mjs +1 -1
- package/scripts/cm-prd-drive.mjs +13 -6
- package/scripts/cm-prd-drive.test.mjs +45 -1
- package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
- package/scripts/cm-prd-host.mjs +10 -5
- package/scripts/cm-prd-host.test.mjs +4 -2
- package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
- package/scripts/cm-prd-review-disposition.test.mjs +124 -8
- package/scripts/cm-prd-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-revision.test.mjs +1 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
- package/scripts/cm-prd-self-check.test.mjs +105 -5
- package/scripts/cm-prd-summary.test.mjs +24 -3
- package/scripts/cm-prd-task-grouping.test.mjs +6 -6
- package/scripts/cm-prd-tree-digest.test.mjs +74 -0
- package/scripts/cm-refactor-drive.mjs +2 -1
- package/scripts/cm-refactor-drive.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +1 -1
- package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
- package/scripts/cm-skill-hints-exam.mjs +149 -0
- package/scripts/cm-skill-hints-install.test.mjs +168 -0
- package/scripts/cm-skill-hints.exam.json +706 -0
- package/scripts/cm-skill-hints.json +119 -0
- package/scripts/cm-skill-hints.mjs +669 -0
- package/scripts/cm-skill-hints.test.mjs +831 -0
- package/scripts/cm-skill-judge.mjs +181 -0
- package/scripts/cm-skill-judge.test.mjs +255 -0
- package/scripts/cm-specs-status.test.mjs +4 -2
- package/scripts/cm-start-check.mjs +208 -0
- package/scripts/cm-start-check.test.mjs +321 -0
- package/scripts/cm-task-gate.mjs +150 -29
- package/scripts/cm-task-gate.test.mjs +73 -1
- package/scripts/cm-task-id-grammar.test.mjs +66 -0
- package/scripts/cm-task-scope.test.mjs +308 -0
- package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
- package/scripts/cm-upgrade-compat.test.mjs +239 -0
- package/scripts/cm-workflow-config.mjs +12 -2
- package/scripts/fixtures/fix-verification-claude.mjs +44 -0
- package/scripts/fixtures/reviewed-integration.mjs +202 -0
- package/scripts/scan-public-safety.py +1 -0
- package/scripts/session-boundary.test.mjs +170 -0
- package/scripts/test-npm-install.py +14 -3
- package/scripts/test-shell-compat.sh +2 -0
- package/scripts/validate-public-repo.py +1 -0
- package/scripts/validate-test-cases.mjs +3 -2
- package/skills/cm-ai/SKILL.md +5 -2
- package/skills/cm-ai/references/N4-review.md +2 -1
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/N8-finish.md +22 -0
- package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
- package/skills/cm-ai/references/js-host-recovery.md +79 -3
- package/skills/cm-ai/references/js-host.md +56 -16
- package/skills/cm-challenge/SKILL.md +65 -0
- package/skills/cm-challenge/evals/README.md +18 -0
- package/skills/cm-challenge/evals/trigger-cases.json +20 -0
- package/skills/cm-challenge/evals/trigger-config.json +28 -0
- package/skills/cm-challenge/references/examples.md +15 -0
- package/skills/cm-check/SKILL.md +5 -0
- package/skills/cm-check/references/js-host.md +2 -0
- package/skills/cm-fix/SKILL.md +12 -3
- package/skills/cm-fix/references/command-correction.md +67 -0
- package/skills/cm-fix/references/isolated-review.md +54 -0
- package/skills/cm-fix/references/js-host.md +62 -2
- package/skills/cm-fix/references/test-type-correction.md +72 -0
- package/skills/cm-fix/references/verification-recovery.md +114 -0
- package/skills/cm-idea/SKILL.md +2 -0
- package/skills/cm-idea/references/js-host.md +2 -0
- package/skills/cm-notify/SKILL.md +2 -0
- package/skills/cm-prd/SKILL.md +12 -8
- package/skills/cm-prd/references/brownfield.md +8 -1
- package/skills/cm-prd/references/change-mode.md +6 -0
- package/skills/cm-prd/references/greenfield.md +4 -0
- package/skills/cm-prd/references/js-host.md +4 -2
- package/skills/cm-prd/references/spec-self-check.md +5 -1
- package/skills/cm-refactor/SKILL.md +8 -0
- package/skills/cm-refactor/references/js-host.md +2 -0
- package/skills/cm-test/SKILL.md +4 -0
- package/templates/dashboard/dashboard.html +2 -2
- package/templates/pixel/cm-pixel.html +1 -1
- package/templates/pixel/cm-pixel.sh +1 -1
- package/templates/pixel/dev/template.html +1 -1
- package/templates/statusline/cm-statusline.sh +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {inspectVerificationDiagnostic,splitVerificationResult,verificationCallbackFailure,inspectResultWithFailureDiagnostic} from './review-verification-diagnostic.mjs';
|
|
2
|
+
import {readReviewVerification,inspectReviewVerificationEvidence} from './review-verification-contract.mjs';
|
|
1
3
|
import {readExecutionPolicy} from '../cm-ai/execution-policy.mjs';
|
|
2
4
|
import {inspectFixReconciledResult} from './review-reconciliation.mjs';
|
|
3
5
|
// Existing V3 grants and standard implementation-review observations only.
|
|
@@ -17,7 +19,7 @@ import {inspectFixRegressionFailure} from './regression-evidence.mjs';
|
|
|
17
19
|
export function fixFinalReviewConfiguration(configuration,causeThread=null){
|
|
18
20
|
const hosts=fixHostContexts(configuration);
|
|
19
21
|
const base=validateCauseReviewer(configuration.causeReview,hosts);
|
|
20
|
-
return {...(configuration.executionPolicy?{executionPolicy:readExecutionPolicy(configuration.executionPolicy)}:{}),...(configuration.externalModels?{externalModels:configuration.externalModels}:{}),hostContextId:configuration.hostContextId,...(hosts.length>1?{hostContextIds:hosts}:{}),
|
|
22
|
+
return {...(Object.hasOwn(configuration,'reviewVerification')?{reviewVerification:readReviewVerification(configuration.reviewVerification)}:{}),...(configuration.executionPolicy?{executionPolicy:readExecutionPolicy(configuration.executionPolicy)}:{}),...(configuration.externalModels?{externalModels:configuration.externalModels}:{}),hostContextId:configuration.hostContextId,...(hosts.length>1?{hostContextIds:hosts}:{}),
|
|
21
23
|
reviewer:{...base,reviewerId:'fix-final-reviewer',
|
|
22
24
|
adapterId:`${base.provider}-review-adapter`,contextId:'fix-final-review-context',
|
|
23
25
|
excludedThreadIds:[...new Set([...base.excludedThreadIds,...(Array.isArray(causeThread)?causeThread:causeThread?[causeThread]:[])])]}};
|
|
@@ -61,13 +63,25 @@ export function inspectFixFinalRegistration(raw,configuration){
|
|
|
61
63
|
return value;
|
|
62
64
|
}
|
|
63
65
|
export function inspectFixFinalResult(raw,registration,configuration,started){
|
|
64
|
-
const value=json(raw,1024*1024);shape(value,['dispatchAt','observation',...(Object.hasOwn(value,'reconciliationReceipt')?['reconciliationReceipt']:[])]);
|
|
66
|
+
const value=json(raw,1024*1024);shape(value,['dispatchAt','observation',...(Object.hasOwn(value,'reconciliationReceipt')?['reconciliationReceipt']:[]),...(Object.hasOwn(value,'verification')?['verification']:[]),...(Object.hasOwn(value,'verificationDiagnostic')?['verificationDiagnostic']:[])]);
|
|
65
67
|
need(Number.isSafeInteger(value.dispatchAt)&&value.dispatchAt>=registration.registeredAt
|
|
66
68
|
&&value.dispatchAt<registration.grant.expiresAt,'final_registration_mismatch');
|
|
67
69
|
need(!value.reconciliationReceipt||(configuration.externalModels||configuration.executionPolicy),'review_reconciliation_unavailable');
|
|
68
70
|
const expected=expectation(registration.request,configuration);
|
|
69
71
|
const checked=value.reconciliationReceipt?inspectFixReconciledResult(value,expected):inspectProviderReview(JSON.stringify(value.observation),JSON.stringify(expected));
|
|
70
|
-
need(checked.providerThreadId===started,'final_registration_mismatch');
|
|
72
|
+
need(checked.providerThreadId===started,'final_registration_mismatch');
|
|
73
|
+
if(configuration.reviewVerification){
|
|
74
|
+
readReviewVerification(configuration.reviewVerification);
|
|
75
|
+
need(!value.reconciliationReceipt,'review_verification_invalid');
|
|
76
|
+
if(checked.observationStatus==='completed'||Object.hasOwn(value,'verification'))
|
|
77
|
+
inspectReviewVerificationEvidence(value.verification,{request:registration.request,configuration:configuration.reviewVerification,providerThreadId:started});
|
|
78
|
+
}else need(!Object.hasOwn(value,'verification'),'review_verification_invalid');
|
|
79
|
+
if(Object.hasOwn(value,'verificationDiagnostic')){
|
|
80
|
+
need(configuration.reviewVerification&&checked.observationStatus!=='completed','review_verification_invalid');
|
|
81
|
+
const diagnostic=inspectVerificationDiagnostic(value.verificationDiagnostic,{request:registration.request,configuration:configuration.reviewVerification,providerThreadId:started});
|
|
82
|
+
return {...checked,verificationDiagnostic:diagnostic};
|
|
83
|
+
}
|
|
84
|
+
return checked;
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
// Read-only feedback for the next repair; registration is still supplied by the
|
|
@@ -114,8 +128,10 @@ export function createFixFinalReview({reviewPackage,configuration,timeoutMs},{au
|
|
|
114
128
|
const pkg=readReviewPackage(reviewPackage);need(pkg.handoff,'final_handoff_required');
|
|
115
129
|
const config=json(configuration,12*1024*1024);shape(config,['hostContextId','reviewer',...(Object.hasOwn(config,'externalModels')?['externalModels']:[]),...(Object.hasOwn(config,'executionPolicy')?['executionPolicy']:[]),
|
|
116
130
|
...(Object.hasOwn(config,'hostContextIds')?['hostContextIds']:[]),
|
|
131
|
+
...(Object.hasOwn(config,'reviewVerification')?['reviewVerification']:[]),
|
|
117
132
|
...(Object.hasOwn(config,'reviewFeedback')?['reviewFeedback']:[])]);
|
|
118
133
|
if(config.executionPolicy)readExecutionPolicy(config.executionPolicy);
|
|
134
|
+
if(Object.hasOwn(config,'reviewVerification'))readReviewVerification(config.reviewVerification);
|
|
119
135
|
const previous=config.reviewFeedback?inspectFixRepairReview(config.reviewFeedback,pkg.identity):null;
|
|
120
136
|
const reviewer=validateCauseReviewer(config.reviewer,fixHostContexts(config),previous?35:34);
|
|
121
137
|
if(previous)need(reviewer.excludedThreadIds.includes(previous.providerThreadId),'final_context_mismatch');
|
|
@@ -150,15 +166,30 @@ export function createFixFinalReview({reviewPackage,configuration,timeoutMs},{au
|
|
|
150
166
|
events.push(event);return true;
|
|
151
167
|
}catch(error){diagnostic=reviewDiagnostic(eventPhase,error,event);controller.abort();return false;}
|
|
152
168
|
};
|
|
153
|
-
let transport;
|
|
169
|
+
let transport,verification,verificationInvalid=false,verificationError;
|
|
170
|
+
const onVerification=raw=>{
|
|
171
|
+
if(sealed||controller.signal.aborted)return false;
|
|
172
|
+
try{
|
|
173
|
+
need(config.reviewVerification&&verification===undefined&&!verificationInvalid,'review_verification_invalid');
|
|
174
|
+
const value=json(raw,1024*1024);
|
|
175
|
+
inspectReviewVerificationEvidence(value,{request,configuration:config.reviewVerification,providerThreadId:started});
|
|
176
|
+
verification=value;return undefined;
|
|
177
|
+
}catch(error){verificationInvalid=true;verificationError??=error;throw error;}
|
|
178
|
+
};
|
|
154
179
|
try{
|
|
155
180
|
timer=setTimeout(()=>{timedOut=true;controller.abort();},timeoutMs);
|
|
156
|
-
transport=Promise.resolve().then(()=>{need(!controller.signal.aborted,'cancelled');return run(request,{signal:controller.signal,onEvent,...(onReconciliation?{onReconciliation}:{})});});
|
|
157
|
-
|
|
181
|
+
transport=Promise.resolve().then(()=>{need(!controller.signal.aborted,'cancelled');return run(request,{signal:controller.signal,onEvent,...(config.reviewVerification?{onVerification}:{}),...(!config.reviewVerification&&onReconciliation?{onReconciliation}:{})});});
|
|
182
|
+
let result;try{result=await Promise.race([interrupted,transport]);}catch(error){
|
|
183
|
+
if(!verificationInvalid||controller.signal.aborted)throw error;
|
|
184
|
+
}
|
|
158
185
|
need(!controller.signal.aborted,'interrupted');
|
|
159
|
-
|
|
186
|
+
if(verificationInvalid){result=verificationCallbackFailure(verificationError,{request,configuration:config.reviewVerification,providerThreadId:started});verification=undefined;}
|
|
187
|
+
const response=splitVerificationResult(result);
|
|
188
|
+
let value={dispatchAt,observation:observation(response.result),...(verification===undefined?{}:{verification}),
|
|
189
|
+
...(response.verificationDiagnostic?{verificationDiagnostic:response.verificationDiagnostic}:{})};
|
|
160
190
|
phase='result';
|
|
161
|
-
|
|
191
|
+
let inspection;({value,inspection}=inspectResultWithFailureDiagnostic(value,v=>inspectFixFinalResult(v,registration,config,started),
|
|
192
|
+
{request,configuration:config.reviewVerification,providerThreadId:started}));
|
|
162
193
|
return {outcome:'observed',value,inspection,completionEligible:false};
|
|
163
194
|
}catch(error){
|
|
164
195
|
const reason=timedOut?'timeout':signal.aborted?'cancelled':'transport_incomplete';
|
|
@@ -6,10 +6,11 @@ import {checkN5} from '../../../scripts/cm-task-gate.mjs';
|
|
|
6
6
|
import {readReviewSourceFiles} from '../cm-ai/review-package.mjs';
|
|
7
7
|
import {digest,need} from '../cm-ai/effect-contract.mjs';
|
|
8
8
|
import {publishFixDossier} from './dossier.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import {appendFixMetricsSteps,fixMetricsRow} from './metrics.mjs';
|
|
10
10
|
import {logFixEvent} from './start.mjs';
|
|
11
11
|
import {loadConfig} from '../../../scripts/cm-workflow-config.mjs';
|
|
12
12
|
import {fixDossierRelative} from './layout.mjs';
|
|
13
|
+
import {runStepsSync,runStepsCooperatively} from './cooperative.mjs';
|
|
13
14
|
|
|
14
15
|
export {eventsAt} from './log-events.mjs';
|
|
15
16
|
import {eventsAt} from './log-events.mjs';
|
|
@@ -29,17 +30,18 @@ function lessonRecord(identity,status){
|
|
|
29
30
|
+JSON.stringify(candidates,null,2).split('\n').map(line=>` ${line}`).join('\n')+'\n';
|
|
30
31
|
return {marker,block};
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function* appendLessonsSteps({specsRoot,identity,status},verify){
|
|
33
34
|
if(!status.retrospective.content.candidates.length)return;
|
|
34
35
|
const {marker,block}=lessonRecord(identity,status);
|
|
35
|
-
const target=path.join(specsRoot,'LESSONS.md');verify();let fd;
|
|
36
|
+
const target=path.join(specsRoot,'LESSONS.md');yield;verify();let fd;
|
|
36
37
|
try{
|
|
37
38
|
fd=fs.openSync(target,fs.constants.O_RDWR|fs.constants.O_CREAT|fs.constants.O_APPEND|(fs.constants.O_NOFOLLOW??0),0o600);
|
|
38
39
|
const before=fs.fstatSync(fd);need(before.isFile()&&before.nlink===1&&before.size<=1024*1024,'fix_lessons_invalid');
|
|
39
40
|
const content=fs.readFileSync(fd).toString('utf8');
|
|
40
41
|
if(content.includes(marker)){need(content.split(marker).length===2&&content.includes(block),'fix_lessons_conflict');return;}
|
|
41
42
|
const bytes=Buffer.from((content.endsWith('\n')||!content?'':'\n')+block);need(before.size+bytes.length<=1024*1024,'limit_exceeded');
|
|
42
|
-
verify();const current=fs.lstatSync(target);need(!current.isSymbolicLink()&¤t.dev===before.dev&¤t.ino===before.ino&¤t.size===before.size,'fix_lessons_changed');
|
|
43
|
+
yield;verify();const current=fs.lstatSync(target);need(!current.isSymbolicLink()&¤t.dev===before.dev&¤t.ino===before.ino&¤t.size===before.size,'fix_lessons_changed');
|
|
44
|
+
need(fs.readFileSync(fd).toString('utf8')===content,'fix_lessons_changed');
|
|
43
45
|
need(fs.writeSync(fd,bytes)===bytes.length,'fix_lessons_write_unknown');fs.fsyncSync(fd);
|
|
44
46
|
const [written]=readReviewSourceFiles(specsRoot,['LESSONS.md']);need(Buffer.from(written.contentBase64,'base64').toString('utf8').includes(block),'fix_lessons_write_unknown');
|
|
45
47
|
}finally{if(fd!==undefined)fs.closeSync(fd);}
|
|
@@ -73,7 +75,9 @@ export function fixCompletionProjection({specsRoot,identity,status,configuration
|
|
|
73
75
|
}catch{return {...status,completionHistory,...(status.stage==='closeout_required'?{stage:'closeout_incomplete'}:{})};}
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
export function finishFix({
|
|
78
|
+
export function finishFix(options,guard){return runStepsSync(finishFixSteps(options,guard));}
|
|
79
|
+
export function finishFixCooperatively(options,guard){return runStepsCooperatively(finishFixSteps(options,guard));}
|
|
80
|
+
export function* finishFixSteps({specsRoot,identity,configuration,status,registeredAt},{assertOwned}){
|
|
77
81
|
need(['closeout_required','closeout_incomplete','completed'].includes(status.stage),'fix_closeout_unavailable');
|
|
78
82
|
requireCloseoutEvidence(status);
|
|
79
83
|
const feature=`fix-${identity.taskId.slice(6)}`,reviewsDir=path.join(specsRoot,'.reviews');
|
|
@@ -98,9 +102,9 @@ export function finishFix({specsRoot,identity,configuration,status,registeredAt}
|
|
|
98
102
|
reviewsDir,feature,task:identity.taskId,projectRoot:configuration.reproduction.cwd,requireLearning:true});
|
|
99
103
|
need(digest(gate)===digest(status.n5.gate),'n5_evidence_changed');
|
|
100
104
|
};
|
|
101
|
-
verify();
|
|
105
|
+
yield;verify();
|
|
102
106
|
const dossier=publishFixDossier({specsRoot,identity,configuration,status:{...status,stage:'closeout_required',completionEligible:false},registeredAt,final:true});
|
|
103
|
-
|
|
107
|
+
yield* appendLessonsSteps({specsRoot,identity,status},verify);
|
|
104
108
|
const bare=configuration.archiveMode==='bare';
|
|
105
109
|
const data={result:'completed',package_digest:status.n5.packageDigest,dossier_file:fixDossierRelative(configuration,path.basename(dossier.path)),
|
|
106
110
|
dossier_sha256:dossier.sha256,walkthrough_result:'passed'};
|
|
@@ -109,12 +113,12 @@ export function finishFix({specsRoot,identity,configuration,status,registeredAt}
|
|
|
109
113
|
event:'task_done',event_id:'preflight',at:new Date().toISOString(),...data};
|
|
110
114
|
const events=eventsAt(specsRoot,configuration),prior=events.filter(row=>matches(row,identity)&&row.event==='task_done');
|
|
111
115
|
if(!bare)fixMetricsRow({events:prior.length?events:[...events,provisional],identity,dossierFile:path.basename(dossier.path)});
|
|
112
|
-
verify();
|
|
116
|
+
yield;verify();
|
|
113
117
|
const task=logFixEvent({specsRoot,identity,configuration,event:'task_done',detail:'JS defect verified and dossier finalized',data});
|
|
114
|
-
const metrics=bare?null:
|
|
115
|
-
verify();
|
|
118
|
+
const metrics=bare?null:yield* appendFixMetricsSteps({specsRoot,identity,dossierFile:path.basename(dossier.path)},{assertOwned:verify});
|
|
119
|
+
yield;verify();
|
|
116
120
|
logFixEvent({specsRoot,identity,configuration,event:'run_done',detail:'JS defect closeout completed',data:{...data,
|
|
117
121
|
completion_event_id:task.event_id,...(bare?{metrics_skipped:'no_specs'}:{metrics_row_digest:digest(metrics.line)})}});
|
|
118
|
-
verify();
|
|
122
|
+
yield;verify();
|
|
119
123
|
return fixCompletionProjection({specsRoot,identity,configuration,status:{...status,stage:'closeout_required',completionEligible:false}});
|
|
120
124
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {verificationFailure,verificationFailureCode,bindVerificationDiagnostic} from './review-verification-diagnostic.mjs';
|
|
2
|
+
import {readReviewVerification} from './review-verification-contract.mjs';
|
|
3
|
+
import {createReviewVerificationSession,assertVerificationIsolation,validateReviewVerificationInputs} from './review-verification.mjs';
|
|
4
|
+
import {ConfigError,loadConfig,resolveProtectedRuntimes} from '../../../scripts/cm-workflow-config.mjs';
|
|
1
5
|
import {selectExternalModels} from '../cm-ai/external-models.mjs';
|
|
2
6
|
import {readExecutionPolicy} from '../cm-ai/execution-policy.mjs';
|
|
3
7
|
import {createNativeUsageLog} from '../cm-ai/native-usage-log.mjs';
|
|
@@ -12,8 +16,21 @@ import {fixFinalReviewConfiguration} from './final-review.mjs';
|
|
|
12
16
|
import {digest,id,json,need} from '../cm-ai/effect-contract.mjs';
|
|
13
17
|
|
|
14
18
|
const DEFAULT_REVIEW_TIMEOUT_MS=900000;
|
|
15
|
-
export function createFixReviewHost({codeProject,hostContextId,runtime='codex',review=null,permissions=[],workerFactory=null,externalModels=null,executionPolicy=null,specsDir=null}){
|
|
16
|
-
id(hostContextId);need(['codex','claude'].includes(
|
|
19
|
+
export function createFixReviewHost({codeProject,hostContextId,runtime:hostRuntime='codex',reviewRuntime,review=null,permissions=[],workerFactory=null,externalModels=null,executionPolicy=null,specsDir=null,verification=null}){
|
|
20
|
+
id(hostContextId);need(['codex','claude'].includes(hostRuntime),'invalid_runtime');
|
|
21
|
+
if(reviewRuntime!==undefined)need(['codex','claude'].includes(reviewRuntime),'invalid_runtime');
|
|
22
|
+
const runtime=reviewRuntime??hostRuntime;
|
|
23
|
+
if(verification!==null){verification=readReviewVerification(verification);need(runtime==='claude','review_verification_provider');assertVerificationIsolation();}
|
|
24
|
+
need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
25
|
+
// Explicit selection is bound to declared roles; absence preserves old runs.
|
|
26
|
+
const assertRoute=()=>{
|
|
27
|
+
if(reviewRuntime===undefined)return;
|
|
28
|
+
let route;
|
|
29
|
+
try{route=resolveProtectedRuntimes(loadConfig({projectRoot:codeProject}),hostRuntime);}
|
|
30
|
+
catch(error){if(error instanceof ConfigError)need(false,'invalid_workflow_config');throw error;}
|
|
31
|
+
need(route.coderRuntime===hostRuntime&&route.reviewerRuntime===runtime,'fix_review_runtime_mismatch');
|
|
32
|
+
};
|
|
33
|
+
assertRoute();
|
|
17
34
|
const policy=executionPolicy===null?null:readExecutionPolicy(executionPolicy);
|
|
18
35
|
const allowed=new Set(json(permissions)),config=review===null?null:json(review);
|
|
19
36
|
const pair=externalModels?selectExternalModels(externalModels,[runtime]).providers[runtime]:null;
|
|
@@ -22,30 +39,68 @@ export function createFixReviewHost({codeProject,hostContextId,runtime='codex',r
|
|
|
22
39
|
const worker=workerFactory??(runtime==='claude'?claudeWorker:codexWorker);
|
|
23
40
|
need(runtime!=='claude'||!config||config.disabledSkills.length===0,'invalid_review_config');
|
|
24
41
|
const enabled=['--allow-cause-review','--allow-final-review','--allow-test-author','--allow-repair'].some(flag=>allowed.has(flag));
|
|
25
|
-
need(!enabled||config!==null,'review_configuration_required');
|
|
42
|
+
need(!(enabled||reviewRuntime!==undefined||verification!==null)||config!==null,'review_configuration_required');
|
|
26
43
|
// Review transport budget from the review configuration (outside its
|
|
27
44
|
// authorized digest), shared by the worker and the owner's review watchdog.
|
|
28
45
|
const timeoutMs=config?.timeoutMs??DEFAULT_REVIEW_TIMEOUT_MS;
|
|
29
46
|
const workerOptions=config?{cwd:codeProject,model:config.model,...(pair?{effort:pair.effort}:{}),disabledSkills:config.disabledSkills,
|
|
30
|
-
promptTransport:'stdin',preflight:config.preflight,timeoutMs,
|
|
47
|
+
promptTransport:'stdin',preflight:config.preflight,timeoutMs,...(verification?{verification}:{}),
|
|
31
48
|
schemaPath:fileURLToPath(new URL('../cm-ai/review-result.schema.json',import.meta.url))}:null;
|
|
32
|
-
const assertReviewReady=()
|
|
33
|
-
|
|
49
|
+
const assertReviewReady=reviewPackage=>{assertRoute();need(config&&matches(config.preflight,workerOptions),'tool_preflight_missing');
|
|
50
|
+
if(verification&&reviewPackage)validateReviewVerificationInputs({codeProject,configuration:verification,reviewPackage});};
|
|
51
|
+
if(enabled||reviewRuntime!==undefined)assertReviewReady();
|
|
34
52
|
const reviewer=config?{reviewerId:'fix-cause-reviewer',adapterId:`${runtime}-cause-review-adapter`,provider:runtime,
|
|
35
53
|
requestedModel:config.model,contextId:'fix-cause-review-context',excludedThreadIds:[],
|
|
36
54
|
workerConfigurationDigest:digest({cwd:codeProject,model:config.model,...(pair?{effort:pair.effort}:{}),disabledSkills:config.disabledSkills,
|
|
37
|
-
promptTransport:'stdin',...(runtime==='claude'?{runtime}:{}),...(policy?{executionPolicy:policy}:{})})}:null;
|
|
55
|
+
promptTransport:'stdin',...(runtime==='claude'?{runtime}:{}),...(verification?{verification}:{}),...(policy?{executionPolicy:policy}:{})})}:null;
|
|
38
56
|
const authorityFor=(reviewer,permission)=>createHostReviewAuthority({hostContextId,
|
|
39
57
|
reviewerId:reviewer.reviewerId,adapterId:reviewer.adapterId,
|
|
40
58
|
decide:async()=>allowed.has(permission)?{status:'approved'}:{status:'denied',code:'permission_denied'}});
|
|
41
59
|
const authority=config?authorityFor(reviewer,'--allow-cause-review'):null;
|
|
42
60
|
const finalAuthority=config?authorityFor(fixFinalReviewConfiguration({hostContextId,causeReview:reviewer}).reviewer,'--allow-final-review'):null;
|
|
61
|
+
const runVerifiedReview=async(request,control,cause)=>{
|
|
62
|
+
assertReviewReady();
|
|
63
|
+
let session=null,providerThreadId=null,log=null,usage={usage_state:'unavailable'},result,phase='snapshot';
|
|
64
|
+
const failure=error=>({status:'failed',code:verificationFailureCode(error),verificationDiagnostic:session
|
|
65
|
+
?session.diagnostic(providerThreadId,error,phase)
|
|
66
|
+
:bindVerificationDiagnostic(verificationFailure({phase,code:verificationFailureCode(error)}),{request,configuration:verification,providerThreadId})});
|
|
67
|
+
try{
|
|
68
|
+
if(verification)session=createReviewVerificationSession({codeProject,configuration:verification,request});
|
|
69
|
+
phase='worker';
|
|
70
|
+
const native=worker({...workerOptions,...(session?{verificationTransport:session.transport}:{}),...(policy?{onUsage:value=>{usage=value;},onUsageClaim:()=>{
|
|
71
|
+
log??=createNativeUsageLog({definition:{codeProject,specsDir,feature:request.identity.feature??'fix'},request,provider:runtime,role:'reviewer',workflow:'cm-fix'});log.claimed();
|
|
72
|
+
}}:{})});
|
|
73
|
+
const wrapped=session?async(input,inner)=>{
|
|
74
|
+
need(input.prompt.includes('Use no tools and do not execute code.')||input.prompt.includes('No tools or follow-up fetches.'),'review_verification_prompt_contract');
|
|
75
|
+
const prompt=input.prompt.replaceAll('Use no tools and do not execute code.','Use only the isolated cm_review verification tools.')
|
|
76
|
+
.replace('No tools or follow-up fetches.','Only registered isolated verification tools are available.')+session.prompt;
|
|
77
|
+
const answer=await native({prompt},{...inner,onEvent:event=>{
|
|
78
|
+
if(event.event==='thread.started')providerThreadId=event.provider_thread;return inner.onEvent(event);
|
|
79
|
+
}});
|
|
80
|
+
if(answer.status==='succeeded'){
|
|
81
|
+
phase='finish';const evidence=session.finish(providerThreadId);
|
|
82
|
+
phase='callback';need(typeof control.onVerification==='function','review_verification_callback_failed');
|
|
83
|
+
need(control.onVerification(evidence)!==false,'review_verification_callback_failed');
|
|
84
|
+
}
|
|
85
|
+
return answer;
|
|
86
|
+
}:native;
|
|
87
|
+
result=await (cause?createCauseReviewRun(wrapped,runtime,policy):(runtime==='claude'?createClaudeReviewRun:createCodexReviewRun)(wrapped,policy))(request,control);
|
|
88
|
+
}catch(error){
|
|
89
|
+
result=failure(error);
|
|
90
|
+
}finally{
|
|
91
|
+
let cleaned=false;try{await session?.close();cleaned=true;}catch(error){phase='cleanup';result=failure(error);}
|
|
92
|
+
finally{log?.complete(usage,control.signal.aborted?'cancelled':cleaned&&result?.status==='succeeded'?'success':'error');}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
};
|
|
43
96
|
const runReview=(request,control,cause)=>{
|
|
97
|
+
assertReviewReady();
|
|
98
|
+
if(verification)return runVerifiedReview(request,control,cause);
|
|
99
|
+
// Retain the legacy synchronous validation and lazy worker contract.
|
|
44
100
|
let log=null,usage={usage_state:'unavailable'},result;
|
|
45
101
|
const native=worker({...workerOptions,...(policy?{onUsage:value=>{usage=value;},onUsageClaim:()=>{
|
|
46
|
-
log??=createNativeUsageLog({definition:{codeProject,specsDir,feature:request.identity.feature??'fix'},request,provider:runtime,role:'reviewer',workflow:'cm-fix'});
|
|
47
|
-
|
|
48
|
-
}}: {})});
|
|
102
|
+
log??=createNativeUsageLog({definition:{codeProject,specsDir,feature:request.identity.feature??'fix'},request,provider:runtime,role:'reviewer',workflow:'cm-fix'});log.claimed();
|
|
103
|
+
}}:{})});
|
|
49
104
|
const complete=()=>log?.complete(usage,control.signal.aborted?'cancelled':result?.status==='succeeded'?'success':'error');
|
|
50
105
|
try{
|
|
51
106
|
const pending=(cause?createCauseReviewRun(native,runtime,policy):(runtime==='claude'?createClaudeReviewRun:createCodexReviewRun)(native,policy))(request,control);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {setImmediate as yieldHost} from 'node:timers/promises';
|
|
1
2
|
// Shared original cm-fix action dispatch for standalone and parent hosts.
|
|
2
3
|
import {inspectFixQaSource} from './qa-source.mjs';
|
|
3
4
|
import {startFixRun} from './start.mjs';
|
|
@@ -5,12 +6,16 @@ import {digest,need,shape} from '../cm-ai/effect-contract.mjs';
|
|
|
5
6
|
import {fixArchiveRoot} from './layout.mjs';
|
|
6
7
|
import {fixProgress} from './progress.mjs';
|
|
7
8
|
|
|
8
|
-
export function createFixHost({owner,config,runtime='codex',permissions=[],authority=null,finalAuthority=null,recoveryInvocationId=null}){
|
|
9
|
+
export function createFixHost({owner,config,runtime='codex',reviewRuntime,permissions=[],authority=null,finalAuthority=null,recoveryInvocationId=null,verificationRecoveryAuthorization=null}){
|
|
9
10
|
const extra=new Set(permissions);
|
|
10
11
|
const host={async handle(request){
|
|
11
12
|
shape(request,['requestId','operation',...(request.operation==='resume'?['evidenceFiles']:[]),
|
|
12
13
|
...(['abandon_step','abandon_review','rediagnose','rerun_blocked_step'].includes(request.operation)&&Object.hasOwn(request,'reason')?['reason']:[]),
|
|
13
14
|
...(request.operation==='prepare_revision'&&Object.hasOwn(request,'tests')?['tests']:[]),
|
|
15
|
+
...(request.operation==='prepare_test_type_correction'?['expected','testTypeCorrection','previousInvocationStopped','reason']:[]),
|
|
16
|
+
...(request.operation==='prepare_command_correction'?['expected','commandCorrection','previousInvocationStopped','reason']:[]),
|
|
17
|
+
...(request.operation==='prepare_diagnosis_module_correction'?['expected','previousInvocationStopped','reason']:[]),
|
|
18
|
+
...(request.operation==='prepare_verification_recovery'?['expected','previousInvocationStopped','reason',...(Object.hasOwn(request,'sourceCorrection')?['sourceCorrection']:[])]:[]),
|
|
14
19
|
...(request.operation==='reconcile_review'?['invocationId']:[]),
|
|
15
20
|
...(request.operation==='recover_final_review'?['invocationId','packageDigest','previousInvocationStopped','reason']:[])]);
|
|
16
21
|
if(config.qaSource&&!['status','cancel','completion_evidence'].includes(request.operation))
|
|
@@ -21,9 +26,24 @@ export function createFixHost({owner,config,runtime='codex',permissions=[],autho
|
|
|
21
26
|
const recoveryAllowed=!status.finalReviewRecovery||extra.has('--allow-final-review-recovery')
|
|
22
27
|
&&(status.finalReviewRecoveryCount<=1&&recoveryInvocationId===null
|
|
23
28
|
||recoveryInvocationId===status.finalReviewRecovery.invocationId);
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
const bounded=status.verificationRecovery,phase=bounded?.target.phase;
|
|
30
|
+
const boundedWaiting=bounded&&!bounded.used&&status.stage===`${phase}_required`;
|
|
31
|
+
const boundedFailed=bounded?.used&&status.stage==='unknown'&&(
|
|
32
|
+
phase==='cause_review'&&status.causeReview?.observationStatus!=='completed'
|
|
33
|
+
||phase==='final_review'&&status.finalReview?.observationStatus!=='completed'
|
|
34
|
+
||phase==='revision_final_review'&&status.revisionFinalReview?.observationStatus!=='completed');
|
|
35
|
+
const progress=fixProgress(status,config,{finalReviewAllowed:finalAuthority!==null
|
|
36
|
+
&&extra.has('--allow-final-review')&&recoveryAllowed&&(!boundedWaiting||verificationRecoveryAuthorization===bounded.authorizationDigest)});
|
|
37
|
+
if(boundedFailed)Object.assign(progress,{blocker:'fix_verification_recovery_used',requiresUser:true,
|
|
38
|
+
nextAction:'本次有界验证续审已消耗;保留失败历史,不再放弃、续审或重建运行绕过。'});
|
|
39
|
+
if(boundedWaiting&&verificationRecoveryAuthorization!==bounded.authorizationDigest)Object.assign(progress,{blocker:'fix_verification_recovery_authorization_required',requiresUser:true,
|
|
40
|
+
nextAction:'重新启动原 run,显式传入 --verification-recovery-authorization 和本次准备记录摘要,并保留原审查权限;准备操作不授权派发。'});
|
|
41
|
+
return {...status,progress};
|
|
26
42
|
}
|
|
43
|
+
if(request.operation==='prepare_test_type_correction')return owner.prepareTestTypeCorrection({authorized:extra.has('--allow-test-type-correction'),expected:request.expected,declaration:request.testTypeCorrection,previousInvocationStopped:request.previousInvocationStopped,reason:request.reason});
|
|
44
|
+
if(request.operation==='prepare_command_correction')return owner.prepareCommandCorrection({authorized:extra.has('--allow-command-correction'),expected:request.expected,declaration:request.commandCorrection,previousInvocationStopped:request.previousInvocationStopped,reason:request.reason});
|
|
45
|
+
if(request.operation==='prepare_diagnosis_module_correction')return owner.prepareDiagnosisModuleCorrection({authorized:extra.has('--allow-diagnosis-module-correction'),expected:request.expected,previousInvocationStopped:request.previousInvocationStopped,reason:request.reason});
|
|
46
|
+
if(request.operation==='prepare_verification_recovery')return owner.prepareVerificationRecovery({authorized:extra.has('--allow-verification-recovery'),sourceCorrectionAuthorized:extra.has('--allow-source-correction'),expected:request.expected,...(Object.hasOwn(request,'sourceCorrection')?{sourceCorrection:request.sourceCorrection}:{}),previousInvocationStopped:request.previousInvocationStopped,reason:request.reason});
|
|
27
47
|
if(request.operation==='reconcile_review')return owner.reconcileReview({invocationId:request.invocationId});
|
|
28
48
|
if(request.operation==='recover_final_review')return owner.recoverFinalReview({
|
|
29
49
|
authorized:extra.has('--allow-final-review-recovery'),recoveryInvocationId,invocationId:request.invocationId,
|
|
@@ -34,7 +54,7 @@ export function createFixHost({owner,config,runtime='codex',permissions=[],autho
|
|
|
34
54
|
if(request.operation==='abandon_review')return owner.abandonReview({authorized:extra.has('--allow-abandon-review'),reason:request.reason});
|
|
35
55
|
if(request.operation==='rediagnose')return owner.rediagnose({authorized:extra.has('--allow-rediagnosis'),reason:request.reason});
|
|
36
56
|
if(request.operation==='completion_evidence')return owner.completionEvidence();
|
|
37
|
-
if(request.operation==='finish')return owner.finish({authorized:extra.has('--allow-finish')});
|
|
57
|
+
if(request.operation==='finish')return owner.finish({authorized:extra.has('--allow-finish'),cooperative:true});
|
|
38
58
|
if(request.operation==='author_tests')return owner.authorTests({authorized:extra.has('--allow-test-author')});
|
|
39
59
|
if(request.operation==='repair')return owner.repair({authorized:extra.has('--allow-repair')});
|
|
40
60
|
if(request.operation==='revision_test_check')return owner.runRevisionTests({authorized:extra.has('--allow-regression')});
|
|
@@ -50,32 +70,35 @@ export function createFixHost({owner,config,runtime='codex',permissions=[],autho
|
|
|
50
70
|
if(request.operation==='walkthrough')return owner.runWalkthrough({authorized:extra.has('--allow-walkthrough')});
|
|
51
71
|
if(request.operation==='post_review_regression')return owner.runRegression({authorized:extra.has('--allow-regression'),postReview:true});
|
|
52
72
|
if(request.operation==='final_review'){
|
|
53
|
-
|
|
54
|
-
if(
|
|
73
|
+
const current=owner.status();
|
|
74
|
+
if(!['final_review_required','revision_final_review_required'].includes(current.stage))return owner.reviewFinal({verificationRecoveryAuthorization});
|
|
75
|
+
if(current.stage==='final_review_required'&¤t.finalReviewRecovery){
|
|
55
76
|
need(extra.has('--allow-final-review-recovery'),'fix_review_recovery_authorization_required');
|
|
56
|
-
if(
|
|
57
|
-
need(recoveryInvocationId===
|
|
77
|
+
if(current.finalReviewRecoveryCount>1||recoveryInvocationId!==null)
|
|
78
|
+
need(recoveryInvocationId===current.finalReviewRecovery.invocationId,'fix_review_recovery_authorization_required');
|
|
58
79
|
}
|
|
59
80
|
need(finalAuthority!==null,'review_configuration_required');
|
|
60
81
|
const pkg=owner.finalReviewPackage();
|
|
82
|
+
// Run transport timers before signing; reviewFinal rechecks the live package.
|
|
83
|
+
await yieldHost();
|
|
61
84
|
await finalAuthority.hostDecisionProvider.decide({identity:pkg.identity,packageDigest:pkg.packageDigest},new AbortController().signal);
|
|
62
|
-
return owner.reviewFinal();
|
|
85
|
+
return owner.reviewFinal({verificationRecoveryAuthorization});
|
|
63
86
|
}
|
|
64
87
|
if(request.operation==='red_test')return owner.runRedTest({authorized:extra.has('--allow-red-test')});
|
|
65
88
|
if(request.operation==='baseline')return owner.captureBaseline({authorized:extra.has('--allow-baseline')});
|
|
66
89
|
if(request.operation==='cause_review_package')return owner.causeReviewPackage();
|
|
67
90
|
if(request.operation==='cause_review'){
|
|
68
|
-
if(!['cause_review_required','observation_cause_review_correction_required'].includes(owner.status().stage))return owner.reviewCause();
|
|
91
|
+
if(!['cause_review_required','observation_cause_review_correction_required'].includes(owner.status().stage))return owner.reviewCause({verificationRecoveryAuthorization});
|
|
69
92
|
need(authority!==null,'review_configuration_required');
|
|
70
93
|
const pkg=owner.causeReviewPackage();
|
|
71
94
|
await authority.hostDecisionProvider.decide({identity:config.identity,packageDigest:pkg.packageDigest},new AbortController().signal);
|
|
72
|
-
return owner.reviewCause();
|
|
95
|
+
return owner.reviewCause({verificationRecoveryAuthorization});
|
|
73
96
|
}
|
|
74
97
|
if(request.operation==='cancel')return owner.cancel();
|
|
75
98
|
if(request.operation==='advance'){
|
|
76
99
|
need(extra.has('--allow-reproduction'),'fix_execution_authorization_required');
|
|
77
100
|
if(['reproduce','diagnose'].includes(owner.status().stage))startFixRun({specsRoot:fixArchiveRoot(config.specsRoot,config.reproduction.cwd),
|
|
78
|
-
identity:config.identity,configuration:{reproduction:config.reproduction,...(config.specsRoot==null?{archiveMode:'bare'}:{}),...(runtime==='claude'?{runtime}:{})}});
|
|
101
|
+
identity:config.identity,configuration:{reproduction:config.reproduction,...(config.specsRoot==null?{archiveMode:'bare'}:{}),...(runtime==='claude'?{runtime}:{}),...(reviewRuntime!==undefined?{reviewRuntime}:{})}});
|
|
79
102
|
return owner.advance({authorized:true});
|
|
80
103
|
}
|
|
81
104
|
need(false,'fix_operation_unavailable');
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// An additive configuration-discovery correction. Never accepts replacement argv.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {digest,json,need,shape} from '../cm-ai/effect-contract.mjs';
|
|
5
|
+
import {readReviewSourceFiles} from '../cm-ai/review-package.mjs';
|
|
6
|
+
import {verificationPath} from './review-verification-contract.mjs';
|
|
7
|
+
export const COMMAND_CORRECTION='fix-command-correction';
|
|
8
|
+
export const correctionRow=records=>records.find(r=>r.id===COMMAND_CORRECTION)??null;
|
|
9
|
+
const jest=argv=>Array.isArray(argv)&&argv.length>1&&/(?:^|[\\/])jest[\\/]bin[\\/]jest\.js$/.test(argv[1]);
|
|
10
|
+
function selected(config){return [
|
|
11
|
+
...(config.redTest?.command?[{id:'red-test',cwd:config.redTest.cwd,command:config.redTest.command}]:[]),
|
|
12
|
+
...(config.baseline?.commands??[]).map(c=>({...c,id:`baseline.${c.id}`,cwd:config.baseline.cwd})),
|
|
13
|
+
...(config.walkthrough?.flows??[]).filter(f=>f.kind==='commands').map(f=>({id:`walkthrough.${f.id}`,cwd:config.reproduction.cwd,command:f.command})),
|
|
14
|
+
];}
|
|
15
|
+
function configFile(root,relative){
|
|
16
|
+
verificationPath(relative);need(relative.endsWith('/package.json')||relative==='package.json','fix_command_correction_config');
|
|
17
|
+
const [file]=readReviewSourceFiles(root,[relative]);
|
|
18
|
+
need(file.size<=128*1024,'fix_command_correction_config');
|
|
19
|
+
let parsed;try{parsed=JSON.parse(Buffer.from(file.contentBase64,'base64').toString('utf8'));}catch{need(false,'fix_command_correction_config');}
|
|
20
|
+
need(parsed.jest&&typeof parsed.jest==='object'&&!Array.isArray(parsed.jest),'fix_command_correction_config');
|
|
21
|
+
const {contentBase64,...metadata}=file;return metadata;
|
|
22
|
+
}
|
|
23
|
+
export function deriveJestCorrection(configuration,declaration,file){
|
|
24
|
+
const d=json(declaration);shape(d,['kind','path']);verificationPath(d.path);
|
|
25
|
+
need(d.kind==='jest-config-path'&&d.path===file.path,'fix_command_correction_config');
|
|
26
|
+
const root=configuration.reproduction.cwd,commands=selected(configuration).filter(c=>jest(c.command)&&!c.command.some(v=>v==='--config'||v.startsWith('--config=')));
|
|
27
|
+
need(commands.length>0,'fix_command_correction_unavailable');
|
|
28
|
+
const directory=path.posix.dirname(d.path);
|
|
29
|
+
for(const c of commands){
|
|
30
|
+
const at=c.command.indexOf('--rootDir');
|
|
31
|
+
need(c.cwd===root&&at>=0&&c.command[at+1]===directory,'fix_command_correction_config');
|
|
32
|
+
}
|
|
33
|
+
return commands.map(c=>({id:c.id,before:c.command,after:[...c.command,'--config',d.path]}));
|
|
34
|
+
}
|
|
35
|
+
export function applyCommandCorrection(configuration,payload){
|
|
36
|
+
const {target}=payload,derived=deriveJestCorrection(configuration,target.declaration,target.configFile);
|
|
37
|
+
need(digest(derived)===digest(target.commands),'fix_command_correction_binding');
|
|
38
|
+
const byId=new Map(derived.map(c=>[c.id,c.after]));
|
|
39
|
+
return json({...configuration,
|
|
40
|
+
...(configuration.redTest?{redTest:{...configuration.redTest,command:byId.get('red-test')??configuration.redTest.command}}:{}),
|
|
41
|
+
...(configuration.baseline?{baseline:{...configuration.baseline,commands:configuration.baseline.commands.map(c=>({...c,command:byId.get(`baseline.${c.id}`)??c.command}))}}:{}),
|
|
42
|
+
...(configuration.walkthrough?{walkthrough:{...configuration.walkthrough,flows:configuration.walkthrough.flows.map(f=>({...f,...(byId.has(`walkthrough.${f.id}`)?{command:byId.get(`walkthrough.${f.id}`)}:{})}))}}:{}),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export function readCorrectionConfig(configuration,declaration){return configFile(configuration.reproduction.cwd,declaration.path);}
|
|
46
|
+
export function assertCorrectionConfigCurrent(configuration,payload){
|
|
47
|
+
need(digest(readCorrectionConfig(configuration,payload.target.declaration))===digest(payload.target.configFile),'fix_command_correction_drift');
|
|
48
|
+
}
|
|
49
|
+
export function correctionFiles(configuration,declaration){
|
|
50
|
+
const root=configuration.reproduction.cwd,paths=[...new Set([declaration.path,...(configuration.reviewVerification?.files??[]),...(configuration.repair?.scope??[]),...(configuration.repair?.requirements??[]),...(configuration.redTest?.testFiles??[])])].sort();
|
|
51
|
+
return paths.map(p=>{
|
|
52
|
+
verificationPath(p);let cursor=root;
|
|
53
|
+
for(const part of p.split('/')){cursor=path.join(cursor,part);try{need(!fs.lstatSync(cursor).isSymbolicLink(),'fix_command_correction_drift');}catch(e){if(e.code!=='ENOENT')throw e;return {path:p,sha256:null,mode:null};}}
|
|
54
|
+
const [{sha256,mode}]=readReviewSourceFiles(root,[p]);return {path:p,sha256,mode};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// New drivers reject a deterministic launch error before creating a frozen run.
|
|
58
|
+
export function assertJestConfigurationDiscovery(configuration){
|
|
59
|
+
for(const c of selected(configuration)){
|
|
60
|
+
if(!jest(c.command)||c.command.some(v=>v==='--config'||v.startsWith('--config=')))continue;
|
|
61
|
+
let directory=c.cwd,found=false;
|
|
62
|
+
for(;;){
|
|
63
|
+
if(['js','ts','mjs','cjs','json'].some(ext=>fs.existsSync(path.join(directory,`jest.config.${ext}`)))){found=true;break;}
|
|
64
|
+
try{if(fs.statSync(path.join(directory,'package.json')).isFile()){found=true;break;}}catch{}
|
|
65
|
+
const parent=path.dirname(directory);if(parent===directory)break;directory=parent;
|
|
66
|
+
}
|
|
67
|
+
need(found,'fix_jest_config_path_required');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -7,6 +7,7 @@ import {readReviewSourceFiles} from '../cm-ai/review-package.mjs';
|
|
|
7
7
|
import {eventsAt} from './log-events.mjs';
|
|
8
8
|
import {id,need,validIdentity} from '../cm-ai/effect-contract.mjs';
|
|
9
9
|
import {METRICS_HEADER as header,METRICS_SEPARATOR as separator,hasMetricsHeader} from '../cm-ai/metrics-table.mjs';
|
|
10
|
+
import {runStepsSync} from './cooperative.mjs';
|
|
10
11
|
const cell=value=>String(value).replaceAll('|','|').replace(/[\r\n]+/g,' ');
|
|
11
12
|
const same=(event,identity)=>event.workflow==='cm-fix'&&event.node==='FIX'&&event.run_id===identity.runId
|
|
12
13
|
&&event.repository_id===identity.repositoryId&&event.task===identity.taskId;
|
|
@@ -35,14 +36,14 @@ export function fixMetricsRow({events,identity,dossierFile}){
|
|
|
35
36
|
return {line:`| ${row.map(cell).join(' | ')} |`,completionEventId:end.event_id};
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
export function
|
|
39
|
+
export function* appendFixMetricsSteps({specsRoot,identity,dossierFile},{assertOwned}){
|
|
39
40
|
need(typeof assertOwned==='function','metrics_owner_required');
|
|
40
41
|
const owned=()=>{
|
|
41
42
|
const result=assertOwned();
|
|
42
43
|
if(types.isPromise(result))Promise.prototype.then.call(result,()=>{},()=>{});
|
|
43
44
|
need(result===undefined,'metrics_owner_required');
|
|
44
45
|
};
|
|
45
|
-
owned();
|
|
46
|
+
yield;owned();
|
|
46
47
|
need(path.isAbsolute(specsRoot)&&fs.realpathSync(specsRoot)===specsRoot,'unsupported_path');
|
|
47
48
|
// Streamed: the log may exceed the 1 MiB review-material limit (see log-events.mjs).
|
|
48
49
|
const events=eventsAt(specsRoot);
|
|
@@ -58,17 +59,29 @@ export function appendFixMetrics({specsRoot,identity,dossierFile},{assertOwned})
|
|
|
58
59
|
const matches=content.split(/\r?\n/).filter(line=>line.startsWith(`| ${dossierFile} | fix |`));
|
|
59
60
|
if(matches.length){
|
|
60
61
|
need(matches.length===1&&matches[0]===record.line,'metrics_row_conflict');
|
|
62
|
+
yield;owned();
|
|
61
63
|
const current=fs.lstatSync(target);need(!current.isSymbolicLink()&¤t.dev===stat.dev&¤t.ino===stat.ino&¤t.size===stat.size,'metrics_file_changed');
|
|
62
|
-
|
|
64
|
+
const [verified]=readReviewSourceFiles(specsRoot,['METRICS.md']);
|
|
65
|
+
need(Buffer.from(verified.contentBase64,'base64').equals(before),'metrics_file_changed');
|
|
66
|
+
return {...record,path:target,deduplicated:true};
|
|
63
67
|
}
|
|
64
68
|
if(before.length)need(hasMetricsHeader(content),'metrics_table_invalid');
|
|
65
69
|
const bytes=Buffer.from((before.length?(content.endsWith('\n')?'':'\n'):`${header}\n${separator}\n`)+record.line+'\n');
|
|
66
|
-
need(before.length+bytes.length<=1024*1024,'limit_exceeded');owned();
|
|
70
|
+
need(before.length+bytes.length<=1024*1024,'limit_exceeded');yield;owned();
|
|
67
71
|
const current=fs.lstatSync(target);need(!current.isSymbolicLink()&¤t.dev===stat.dev&¤t.ino===stat.ino&¤t.size===stat.size,'metrics_file_changed');
|
|
72
|
+
const [pinned]=readReviewSourceFiles(specsRoot,['METRICS.md']);
|
|
73
|
+
need(Buffer.from(pinned.contentBase64,'base64').equals(before),'metrics_file_changed');
|
|
68
74
|
// One append preserves existing bytes; a short/uncertain write is not success.
|
|
69
75
|
need(fs.writeSync(fd,bytes)===bytes.length,'metrics_write_unknown');fs.fsyncSync(fd);
|
|
70
76
|
const [written]=readReviewSourceFiles(specsRoot,['METRICS.md']),all=Buffer.from(written.contentBase64,'base64');
|
|
71
77
|
need(all.subarray(0,before.length).equals(before)&&all.includes(bytes),'metrics_write_unknown');
|
|
72
|
-
owned();
|
|
78
|
+
yield;owned();
|
|
79
|
+
const [verified]=readReviewSourceFiles(specsRoot,['METRICS.md']);
|
|
80
|
+
need(Buffer.from(verified.contentBase64,'base64').equals(all),'metrics_file_changed');
|
|
81
|
+
return {...record,path:target,deduplicated:false};
|
|
73
82
|
}finally{if(fd!==undefined)fs.closeSync(fd);}
|
|
74
83
|
}
|
|
84
|
+
|
|
85
|
+
export function appendFixMetrics(options,control){
|
|
86
|
+
return runStepsSync(appendFixMetricsSteps(options,control));
|
|
87
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import {typeFiles} from './test-type-recovery.mjs';
|
|
1
2
|
// Shared read-only regression evidence checks; no execution or review authority.
|
|
2
3
|
import {currentTestFiles,inspectExtensionCheck} from './test-extension.mjs';
|
|
3
4
|
import {inspectFixBaseline} from './baseline.mjs';
|
|
4
5
|
import {digest,json,need,shape,text} from '../cm-ai/effect-contract.mjs';
|
|
5
6
|
import {isVisual,inspectVisualAfter} from './visual.mjs';
|
|
6
7
|
|
|
7
|
-
export function inspectFixRegression(raw,{redTest,baseline,beforeBaseline,testExtension=null}){
|
|
8
|
+
export function inspectFixRegression(raw,{redTest,baseline,beforeBaseline,testExtension=null,testTypeCorrection=null}){
|
|
8
9
|
const value=json(raw);shape(value,['status','red','baseline','comparison','completionEligible',...(testExtension?['testExtension']:[])]);
|
|
9
|
-
beforeBaseline={...beforeBaseline,testFiles:currentTestFiles(beforeBaseline.testFiles,testExtension)};
|
|
10
|
+
beforeBaseline={...beforeBaseline,testFiles:currentTestFiles(typeFiles(beforeBaseline.testFiles,testTypeCorrection),testExtension)};
|
|
10
11
|
const extra=testExtension?inspectExtensionCheck(value.testExtension,{redTest},testExtension.plan,testExtension.files):null;
|
|
11
12
|
if(isVisual(redTest)){
|
|
12
13
|
const observed=inspectVisualAfter(value.red,redTest),comparison=compareFixBaseline(beforeBaseline,value.baseline,baseline);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {typeFiles} from './test-type-recovery.mjs';
|
|
1
2
|
// Post-repair command checks. The durable owner must register before calling;
|
|
2
3
|
// these observations do not grant repair authority or satisfy independent review.
|
|
3
4
|
import {currentTestFiles,verifyExtensionFiles,extensionConfig} from './test-extension.mjs';
|
|
@@ -12,15 +13,23 @@ import {isVisual,observeVisualAfter} from './visual.mjs';
|
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
export function createFixRegression(options,{specsRoot:protectedSpecsRoot=null,bridge=null}={}){
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
// Validate the entire plain input before reading any option value. Complete
|
|
17
|
+
// feedback has its existing 12 MiB contract; ordinary arguments stay at 1 MiB.
|
|
18
|
+
const hasReviewFeedback=options!==null&&typeof options==='object'&&Object.hasOwn(options,'reviewFeedback');
|
|
19
|
+
const config=hasReviewFeedback?json(options,13*1024*1024+Buffer.byteLength(',"reviewFeedback":')):json(options);
|
|
20
|
+
if(hasReviewFeedback){
|
|
21
|
+
const {reviewFeedback,...parameters}=config;
|
|
22
|
+
json(parameters);
|
|
23
|
+
}
|
|
24
|
+
shape(config,['identity','specsRoot','redTest','baseline','redEvidence','beforeBaseline',...(Object.hasOwn(config,'reviewFeedback')?['reviewFeedback']:[]),...(Object.hasOwn(config,'testExtension')?['testExtension']:[]),...(Object.hasOwn(config,'testTypeCorrection')?['testTypeCorrection']:[])]);
|
|
25
|
+
const {identity,specsRoot,redTest,baseline,redEvidence,beforeBaseline}=config;
|
|
17
26
|
validIdentity(identity);
|
|
18
|
-
const priorReview=Object.hasOwn(
|
|
27
|
+
const priorReview=Object.hasOwn(config,'reviewFeedback')?inspectFixRepairReview(config.reviewFeedback,identity):null;
|
|
19
28
|
const redIdentity=priorReview&&redEvidence.output?.path?.startsWith(`.reviews/fix-${identity.taskId.slice(6)}-a1-red-output`)?priorReview.identity:identity;
|
|
20
29
|
const originalRed=inspectFixRedTest(redEvidence,redTest,redIdentity,redEvidence.testFiles,redEvidenceRetry(redEvidence));
|
|
21
30
|
need(originalRed.status==='red_confirmed','red_test_not_confirmed');
|
|
22
31
|
const originalBaseline=inspectFixBaseline(beforeBaseline,baseline,beforeBaseline.testFiles);
|
|
23
|
-
const extension=
|
|
32
|
+
const correction=config.testTypeCorrection,extension=config.testExtension,comparisonBaseline={...originalBaseline,testFiles:currentTestFiles(typeFiles(originalBaseline.testFiles,correction),extension)};
|
|
24
33
|
need(originalBaseline.status==='recorded','baseline_unavailable');
|
|
25
34
|
need(redTest.cwd===baseline.cwd,'baseline_project_mismatch');
|
|
26
35
|
const redCheck=isVisual(redTest)?null:createHostCheck({cwd:redTest.cwd,commands:[{id:'red-test',command:redTest.command}],timeoutMs:redTest.timeoutMs,specsRoot:protectedSpecsRoot});
|
|
@@ -29,19 +38,19 @@ export function createFixRegression(options,{specsRoot:protectedSpecsRoot=null,b
|
|
|
29
38
|
need(authorized===true,'regression_authorization_required');need(!used,'regression_already_attempted');
|
|
30
39
|
need(digest(request.identity)===digest(identity),'identity_mismatch');need(!signal.aborted,'cancelled');
|
|
31
40
|
verifyExtensionFiles(redTest.cwd,extension);
|
|
32
|
-
verifyFixRedEvidence(originalRed,redTest,specsRoot,currentTestFiles(originalRed.testFiles,extension));
|
|
41
|
+
verifyFixRedEvidence(originalRed,redTest,specsRoot,currentTestFiles(typeFiles(originalRed.testFiles,correction),extension));
|
|
33
42
|
need(digest(fixBaselineFiles(baseline))===digest(comparisonBaseline.testFiles),'baseline_files_changed');
|
|
34
43
|
used=true;
|
|
35
44
|
const red=isVisual(redTest)?await observeVisualAfter(redTest,{bridge,signal,identity,specsRoot}):(await redCheck(request,{signal}))[0];
|
|
36
45
|
// Collect the existing suites even if the target defect remains red.
|
|
37
46
|
const after=await baselineCheck(request,{signal,authorized:true});
|
|
38
47
|
verifyExtensionFiles(redTest.cwd,extension);
|
|
39
|
-
verifyFixRedEvidence(originalRed,redTest,specsRoot,currentTestFiles(originalRed.testFiles,extension));
|
|
48
|
+
verifyFixRedEvidence(originalRed,redTest,specsRoot,currentTestFiles(typeFiles(originalRed.testFiles,correction),extension));
|
|
40
49
|
const comparison=compareFixBaseline(comparisonBaseline,after,baseline);
|
|
41
50
|
const testExtension=extension?await createFixBaseline(extensionConfig({redTest},extension.plan),{specsRoot:protectedSpecsRoot})(request,{signal,authorized:true}):null;
|
|
42
51
|
verifyExtensionFiles(redTest.cwd,extension);
|
|
43
52
|
const status=testExtension&&testExtension.observations[0].outcome!=='passed'?(testExtension.status==='blocked'?'blocked':'defect_remaining'):isVisual(redTest)?red.verdict==='BLOCKED'?'blocked':red.verdict==='FAIL'?'defect_remaining':comparison.status:
|
|
44
53
|
red.outcome==='unavailable'?'blocked':red.outcome!=='passed'?'defect_remaining':comparison.status;
|
|
45
|
-
return inspectFixRegression({status,red,baseline:after,comparison,...(extension?{testExtension}:{}),completionEligible:false},{redTest,baseline,beforeBaseline:originalBaseline,testExtension:extension});
|
|
54
|
+
return inspectFixRegression({status,red,baseline:after,comparison,...(extension?{testExtension}:{}),completionEligible:false},{redTest,baseline,beforeBaseline:originalBaseline,testTypeCorrection:correction,testExtension:extension});
|
|
46
55
|
};
|
|
47
56
|
}
|