@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
|
@@ -7,7 +7,9 @@ import {digest,freeze,hex,id,json,need,shape,validIdentity} from './effect-contr
|
|
|
7
7
|
|
|
8
8
|
const key=(feature,task)=>`${feature}/${task}`;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// unseen: completed tasks with no QA row at all; a triggered QA never clears them.
|
|
11
|
+
// since: tasks whose QA was not triggered after the last triggered one.
|
|
12
|
+
function unassessedParts(binding,context) {
|
|
11
13
|
const completed=new Set(context.completed.map(task=>key(task.feature,task.id)));
|
|
12
14
|
const pendingFeatures=new Set(context.pendingFeatures);
|
|
13
15
|
const unseen=new Set(context.completed.filter(task=>pendingFeatures.has(task.feature))
|
|
@@ -22,10 +24,25 @@ function history(binding,context) {
|
|
|
22
24
|
const task=key(row.feature,row.task);unseen.delete(task);
|
|
23
25
|
if(row.status==='triggered')since.clear();else since.add(task);
|
|
24
26
|
});
|
|
27
|
+
return {unseen,since};
|
|
28
|
+
}
|
|
29
|
+
function unassessed(binding,context) {
|
|
30
|
+
const {unseen,since}=unassessedParts(binding,context);
|
|
31
|
+
return new Set([...unseen,...since]);
|
|
32
|
+
}
|
|
33
|
+
function history(binding,context) {
|
|
25
34
|
// Missing historical QA rows are unknown coverage, never evidence of a reset.
|
|
26
35
|
// This callback only proposes a fresh decision. An older run/package for the
|
|
27
36
|
// same task cannot cover the current work; exact recovery happens in entry.
|
|
28
|
-
return new Set([...
|
|
37
|
+
return new Set([...unassessed(binding,context),key(binding.feature,binding.identity.taskId)]).size;
|
|
38
|
+
}
|
|
39
|
+
// Completed tasks counted toward five_tasks_without_qa right now (count), by the same
|
|
40
|
+
// log reading the decision uses, and how many of them a triggered QA leaves counted
|
|
41
|
+
// (floor). batch-plan.mjs predicts one-member groups from both.
|
|
42
|
+
export function qaUnassessedTaskCounts({specsDir,codeProject,feature,repositoryId}){
|
|
43
|
+
const context=inspectCmAiQaTaskContext({specsDir,codeProject,feature});
|
|
44
|
+
const {unseen,since}=unassessedParts({specsDir,feature,identity:{repositoryId}},context);
|
|
45
|
+
return {count:new Set([...unseen,...since]).size,floor:unseen.size};
|
|
29
46
|
}
|
|
30
47
|
|
|
31
48
|
const categories=['migration','authentication','authorization','payment','api'];
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Host-run facts for a delivered task. The task's own check commands run in a
|
|
2
|
+
// private copy of the project at two extra points: as it was before development
|
|
3
|
+
// (baseline) and with only the declared test files delivered (red). The fully
|
|
4
|
+
// delivered run is the task's own checks, already run in the real project.
|
|
5
|
+
// Facts only: the host never blocks on them. The verification gate and the
|
|
6
|
+
// reviewer judge them; the real project is never written here.
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import {createHostCheck} from './host-check.mjs';
|
|
11
|
+
import {need,json,validIdentity} from './effect-contract.mjs';
|
|
12
|
+
|
|
13
|
+
const FILE_LIMIT=1024*1024,ENTRY_LIMIT=200000,EVIDENCE_LIMIT=1500;
|
|
14
|
+
export const HOST_REPLAY_EVIDENCE_PREFIX='cm-host-replay-v1: ';
|
|
15
|
+
|
|
16
|
+
// Scope file state before development: {bytes,mode}, or null for a file that does
|
|
17
|
+
// not exist yet. Anything else (a link, a directory, an oversized file) makes the
|
|
18
|
+
// snapshot unavailable, never a partial one.
|
|
19
|
+
export function captureBeforeSnapshot(codeProject,scope){
|
|
20
|
+
const files=new Map();
|
|
21
|
+
for(const file of scope){
|
|
22
|
+
const target=path.join(codeProject,file);let stat;
|
|
23
|
+
try{stat=fs.lstatSync(target);}catch(error){if(error.code==='ENOENT'){files.set(file,null);continue;}return {unavailable:'snapshot_unreadable'};}
|
|
24
|
+
if(!stat.isFile()||stat.size>FILE_LIMIT)return {unavailable:'snapshot_unsupported_file'};
|
|
25
|
+
files.set(file,{bytes:fs.readFileSync(target),mode:stat.mode&0o777});
|
|
26
|
+
}
|
|
27
|
+
return {files};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const summarize=rows=>{
|
|
31
|
+
const failed=rows.find(row=>row.outcome!=='passed');
|
|
32
|
+
const evidence=rows.map(row=>`${row.id}: ${row.evidence}`).join('; ');
|
|
33
|
+
return {outcome:failed?failed.outcome:rows.length?'passed':'unavailable',evidence:Buffer.byteLength(evidence)>EVIDENCE_LIMIT
|
|
34
|
+
?Buffer.from(evidence).subarray(0,EVIDENCE_LIMIT).toString('utf8').replace(/�$/,'')+'…':evidence};
|
|
35
|
+
};
|
|
36
|
+
const replayError=code=>Object.assign(new Error(code),{code});
|
|
37
|
+
|
|
38
|
+
// A path inside the project that the copy holds (not .git, not nested specs).
|
|
39
|
+
const copied=(codeProject,specsDir,target)=>{
|
|
40
|
+
const inside=dir=>target===dir||target.startsWith(dir+path.sep);
|
|
41
|
+
return inside(codeProject)&&!inside(specsDir)&&!inside(path.join(codeProject,'.git'));
|
|
42
|
+
};
|
|
43
|
+
const realOrNull=target=>{try{return fs.realpathSync(target);}catch{return null;}};
|
|
44
|
+
// A fresh private copy for each run, so no run inherits another's writes. The
|
|
45
|
+
// directory is owned here until it is returned, so a failed copy is removed too.
|
|
46
|
+
// Links are copied verbatim and never rewritten. A link whose final target (the
|
|
47
|
+
// whole chain, resolved) lies in the copied part of the project must resolve to
|
|
48
|
+
// the same place in the copy; otherwise a check could read the real project, and
|
|
49
|
+
// the run is not replayed (replay_internal_link).
|
|
50
|
+
function copyProject(codeProject,specsDir){
|
|
51
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-host-replay-')));
|
|
52
|
+
try{
|
|
53
|
+
const target=path.join(root,'project');let entries=0;const links=[];
|
|
54
|
+
const skip=new Set([path.join(codeProject,'.git'),specsDir]);
|
|
55
|
+
// Copy-on-write clones where the file system has them (APFS, btrfs); a plain copy otherwise.
|
|
56
|
+
fs.cpSync(codeProject,target,{recursive:true,mode:fs.constants.COPYFILE_FICLONE,verbatimSymlinks:true,filter:source=>{
|
|
57
|
+
if(skip.has(source))return false;
|
|
58
|
+
if(++entries>ENTRY_LIMIT)throw replayError('replay_project_too_large');
|
|
59
|
+
if(fs.lstatSync(source).isSymbolicLink())links.push(path.relative(codeProject,source));
|
|
60
|
+
return true;
|
|
61
|
+
}});
|
|
62
|
+
const project=fs.realpathSync(target);
|
|
63
|
+
for(const link of links){
|
|
64
|
+
const real=realOrNull(path.join(codeProject,link));
|
|
65
|
+
if(real===null||!copied(codeProject,specsDir,real))continue;
|
|
66
|
+
if(realOrNull(path.join(project,link))!==path.join(project,path.relative(codeProject,real)))throw replayError('replay_internal_link');
|
|
67
|
+
}
|
|
68
|
+
return {root,project};
|
|
69
|
+
}catch(error){removeCopy(root);throw error;}
|
|
70
|
+
}
|
|
71
|
+
function removeCopy(root){
|
|
72
|
+
try{fs.rmSync(root,{recursive:true,force:true});}
|
|
73
|
+
catch{try{process.stderr.write(JSON.stringify({diagnostic:'host_replay_cleanup_failed',path:root})+'\n');}catch{}}
|
|
74
|
+
}
|
|
75
|
+
// Writes only through real directories inside the copy: every ancestor and the
|
|
76
|
+
// target itself are checked without following links, before any byte is written.
|
|
77
|
+
function place(project,file,state){
|
|
78
|
+
let current=project;
|
|
79
|
+
for(const part of file.split('/').slice(0,-1)){
|
|
80
|
+
current=path.join(current,part);let stat;
|
|
81
|
+
try{stat=fs.lstatSync(current);}catch(error){if(error.code!=='ENOENT')throw error;fs.mkdirSync(current);continue;}
|
|
82
|
+
if(!stat.isDirectory()||stat.isSymbolicLink())throw replayError('replay_scope_link');
|
|
83
|
+
}
|
|
84
|
+
const target=path.join(project,file);
|
|
85
|
+
let existing=null;
|
|
86
|
+
try{existing=fs.lstatSync(target);}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
87
|
+
if(existing!==null){if(!existing.isFile())throw replayError('replay_scope_link');fs.unlinkSync(target);}
|
|
88
|
+
if(state===null)return;
|
|
89
|
+
const fd=fs.openSync(target,fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|fs.constants.O_NOFOLLOW,state.mode);
|
|
90
|
+
try{fs.writeFileSync(fd,state.bytes);fs.fchmodSync(fd,state.mode);}finally{fs.closeSync(fd);}
|
|
91
|
+
}
|
|
92
|
+
const currentState=(codeProject,file)=>{
|
|
93
|
+
const target=path.join(codeProject,file);let stat;
|
|
94
|
+
try{stat=fs.lstatSync(target);}catch(error){if(error.code==='ENOENT')return null;throw error;}
|
|
95
|
+
if(!stat.isFile()||stat.size>FILE_LIMIT)throw replayError('replay_scope_link');
|
|
96
|
+
return {bytes:fs.readFileSync(target),mode:stat.mode&0o777};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// {version,status:'replayed',baseline,red,green} or {version,status:'not_replayed',reason,green}.
|
|
100
|
+
// red is {skipped:'no_test_files'} when tasks.md declares no test files.
|
|
101
|
+
export async function replayDelivery({codeProject,specsDir,snapshot,scope,tests,checkCommands,timeoutMs,identity,greenChecks,signal,makeCheck=createHostCheck}){
|
|
102
|
+
const green=summarize(json(greenChecks));
|
|
103
|
+
const skipped=reason=>notReplayed(reason,greenChecks);
|
|
104
|
+
if(!snapshot)return skipped('no_before_snapshot');
|
|
105
|
+
if(snapshot.unavailable)return skipped(snapshot.unavailable);
|
|
106
|
+
// A path added to the scope after the snapshot has no known prior state.
|
|
107
|
+
if(!scope.every(file=>snapshot.files.has(file)))return skipped('snapshot_scope_changed');
|
|
108
|
+
if(!Array.isArray(checkCommands)||checkCommands.length===0)return skipped('no_host_checks');
|
|
109
|
+
const testFiles=(tests??[]).filter(file=>scope.includes(file));
|
|
110
|
+
const commands=checkCommands.map(({id,command})=>({id,command}));
|
|
111
|
+
// A command that names the project by absolute path would run the real project, not the copy.
|
|
112
|
+
if(commands.some(item=>item.command.some(argument=>argument.includes(codeProject))))return skipped('absolute_project_path');
|
|
113
|
+
// Each run starts from its own copy of the real project and gets its scope states placed.
|
|
114
|
+
const run=async states=>{
|
|
115
|
+
need(!signal?.aborted,'cancelled');
|
|
116
|
+
const copy=copyProject(codeProject,specsDir);
|
|
117
|
+
try{
|
|
118
|
+
for(const file of scope)place(copy.project,file,states(file));
|
|
119
|
+
// The same sandbox as the task's own checks: the copy is the workspace, specs stay read-only.
|
|
120
|
+
return summarize(await makeCheck({cwd:copy.project,commands,timeoutMs,specsRoot:specsDir})({identity},{signal}));
|
|
121
|
+
}finally{removeCopy(copy.root);}
|
|
122
|
+
};
|
|
123
|
+
try{
|
|
124
|
+
const before=file=>snapshot.files.get(file);
|
|
125
|
+
const baseline=await run(before);
|
|
126
|
+
let red={skipped:'no_test_files'};
|
|
127
|
+
if(testFiles.length){
|
|
128
|
+
const delivered=new Map(testFiles.map(file=>[file,currentState(codeProject,file)]));
|
|
129
|
+
red=await run(file=>delivered.has(file)?delivered.get(file):before(file));
|
|
130
|
+
}
|
|
131
|
+
return {version:1,status:'replayed',baseline,red,green};
|
|
132
|
+
}catch(error){
|
|
133
|
+
if(signal?.aborted)throw error;
|
|
134
|
+
return skipped(error?.code==='replay_project_too_large'?'project_too_large'
|
|
135
|
+
:error?.code==='replay_scope_link'?'scope_link':error?.code==='replay_internal_link'?'internal_link':'replay_failed');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Without a replay: the reason, and the fully delivered run that did happen.
|
|
140
|
+
export const notReplayed=(reason,greenChecks)=>({version:1,status:'not_replayed',reason,green:summarize(json(greenChecks))});
|
|
141
|
+
|
|
142
|
+
// The facts as their own handoff evidence entry, beside the gate's requirement
|
|
143
|
+
// entry: a host-observed record, never the developer's report, with its own bound.
|
|
144
|
+
export function encodeHostReplayEvidence({identity,facts}){
|
|
145
|
+
validIdentity(identity);
|
|
146
|
+
return HOST_REPLAY_EVIDENCE_PREFIX+JSON.stringify({version:1,identity:{repositoryId:identity.repositoryId,
|
|
147
|
+
runId:identity.runId,taskId:identity.taskId,attempt:identity.attempt},facts:json(facts,16*1024)});
|
|
148
|
+
}
|
|
@@ -16,7 +16,7 @@ export function parseHostInputLimit(raw){
|
|
|
16
16
|
&&value>=LIMIT&&value<=4*1024*1024,'invalid_arguments');
|
|
17
17
|
return value;
|
|
18
18
|
}
|
|
19
|
-
const operationNames=new Set(['repair_review_response','reconcile_review','rediagnose','replace_inputs','read_batch','recover_final_review','abandon_step','abandon_review','rerun_blocked_step','abandon_effect','bootstrap_review_recover','develop_redo','advance','start','plan_design','promote_design','select_design_reviews','status','fix_status','fix_advance','fix_action','fix_run','decision','complete','qa','qa_result','prepare_revision','prepare_save',
|
|
19
|
+
const operationNames=new Set(['prepare_diagnosis_module_correction','revision_test_check','prepare_test_type_correction','prepare_command_correction','prepare_verification_recovery','repair_review_response','reconcile_review','retry_review','rediagnose','replace_inputs','read_batch','recover_final_review','abandon_step','abandon_review','rerun_blocked_step','abandon_effect','bootstrap_review_recover','completion_rework','development_rework','revise_scope','develop_redo','advance','start','plan_design','promote_design','select_design_reviews','status','fix_status','fix_advance','fix_action','fix_run','decision','complete','qa','qa_result','prepare_revision','prepare_save',
|
|
20
20
|
'context_refresh','finish','completion_evidence','run_finalize','review_findings','review_disposition','save_draft','save_design','correct_findings','prepare_summary','publish_summary','inspect_correction','resume_correction','cancel','resume','prepare_judge_revision','cause_review_package','cause_review','red_test','baseline','author_tests','repair','regression','retrospective','learning_writeback','handoff','final_review_package','final_review','publish_review','check_n5','post_review_regression','publish_dossier','walkthrough']);
|
|
21
21
|
|
|
22
22
|
// Which contract codes may reach the peer is a deliberate boundary: the host
|
|
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import {digest,json,need,shape,validIdentity,hex} from './effect-contract.mjs';
|
|
5
5
|
import {createHostQaDecisionProvider,readQaCriticalPaths} from './host-qa-policy.mjs';
|
|
6
|
+
import {markImplicitQaDecision} from './implicit-qa-decision.mjs';
|
|
6
7
|
import {createHostQaExecutor} from './host-qa-executor.mjs';
|
|
7
8
|
import {loadConfig} from '../../../scripts/cm-workflow-config.mjs';
|
|
8
9
|
import {validateTestCases} from '../../../scripts/validate-test-cases.mjs';
|
|
@@ -83,8 +84,16 @@ export function createHostWorkflowCapabilities({definition,configuration,bridge,
|
|
|
83
84
|
if(configuration.qa!==null||controlPolicy!==null){
|
|
84
85
|
result.qaLogHome=logHome;
|
|
85
86
|
const requestTimeout={timeoutMs:configuration.qa?.timeoutMs??60000};
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
// The assessment is a read-only confirmation; the decision itself comes from
|
|
88
|
+
// the host policy (host-qa-policy.mjs). A v2 run whose policy disables QA has
|
|
89
|
+
// nobody to ask when it runs unattended, so the host confirms it here; the
|
|
90
|
+
// decision, its triggers and its record are unchanged.
|
|
91
|
+
const assess=controlPolicy?.qa==='disabled'?async()=>({confirmed:true})
|
|
92
|
+
:(request,signal)=>bridge.call('qa_assess',request,signal,requestTimeout);
|
|
93
|
+
// parallelMember: a member developed alongside others, whose QA is deferred. A
|
|
94
|
+
// one-member worktree group passes false and keeps the fixed checkpoints.
|
|
95
|
+
result.qaDecisionProvider=parallelMember?createParallelMemberQaDecisionProvider():createHostQaDecisionProvider({timeoutMs:60000,
|
|
96
|
+
criticalPaths:configuration.qa?.criticalPaths??{},assess});
|
|
88
97
|
}
|
|
89
98
|
if(configuration.qa!==null&&(controlPolicy===null||controlPolicy.qa==='run')){
|
|
90
99
|
need(allowQa===true,'qa_authorization_required');
|
|
@@ -113,3 +122,11 @@ export function createParallelMemberQaDecisionProvider(){
|
|
|
113
122
|
...(binding.changedFiles?{changedFilesSource:binding.changedFiles.source}:{}),at:new Date().toISOString().replace(/\.\d{3}Z$/,'Z')};
|
|
114
123
|
}});
|
|
115
124
|
}
|
|
125
|
+
|
|
126
|
+
// v2 的 N6 判定不依赖 workflow 配置;没有 --workflow-config 时只补判定本身,
|
|
127
|
+
// 不加执行器、文档核对或写回,避免改变这类运行的其他请求。
|
|
128
|
+
export function createImplicitQaDecision({definition,bridge,parallelMember=false,controlPolicy}){
|
|
129
|
+
const {qaLogHome,qaDecisionProvider}=createHostWorkflowCapabilities({definition,
|
|
130
|
+
configuration:{qa:null,documentationPaths:[],applicableAgentFiles:[]},bridge,allowQa:false,parallelMember,controlPolicy});
|
|
131
|
+
return {qaLogHome,qaDecisionProvider:markImplicitQaDecision(qaDecisionProvider)};
|
|
132
|
+
}
|
|
@@ -15,5 +15,5 @@ export function createCmAiHost(options) {
|
|
|
15
15
|
...(qaExecutor===undefined?{}:{qaExecutor}),
|
|
16
16
|
...(documentationProvider===undefined?{}:{documentationProvider}),
|
|
17
17
|
...(qaDecisionProvider===undefined?{}:{qaDecisionProvider})});
|
|
18
|
-
return Object.freeze({handle:entry.handle,inspectFixAssociation:runner.inspectFixAssociation,acceptCompletedFix:runner.acceptCompletedFix,attachQa:runner.attachQa,reviseQa:runner.reviseQa,supersedeEvidence:runner.supersedeEvidence,rebindSpecification:runner.rebindSpecification});
|
|
18
|
+
return Object.freeze({handle:entry.handle,inspectFixAssociation:runner.inspectFixAssociation,acceptCompletedFix:runner.acceptCompletedFix,acceptReviewedIntegration:runner.acceptReviewedIntegration,attachQa:runner.attachQa,reviseQa:runner.reviseQa,supersedeEvidence:runner.supersedeEvidence,rebindSpecification:runner.rebindSpecification,reviseScope:runner.reviseScope,reworkDevelopment:runner.reworkDevelopment});
|
|
19
19
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// v2 运行没有 --workflow-config 时,宿主隐式补上 QA 判定(只有判定,没有执行器和文档能力)。
|
|
2
|
+
// 修复前创建的同类运行指纹里没有它;恢复时宿主据此识别并按原样打开,不改变它们的行为。
|
|
3
|
+
const IMPLICIT=new WeakSet();
|
|
4
|
+
export function markImplicitQaDecision(provider){IMPLICIT.add(provider);return provider;}
|
|
5
|
+
export function isImplicitQaDecision(provider){return provider!=null&&typeof provider==='object'&&IMPLICIT.has(provider);}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Exact additions of reviewed evidence copies, never an ignore rule or an
|
|
2
|
+
// instruction-promotion mechanism. These helpers do not read or write a product.
|
|
3
|
+
import {hex,need,shape} from './effect-contract.mjs';
|
|
4
|
+
|
|
5
|
+
const snapshotPath=p=>typeof p==='string'
|
|
6
|
+
&&/^reports\/(?:[A-Za-z0-9][A-Za-z0-9_.-]*\/)+AGENTS\.md$/.test(p)
|
|
7
|
+
&&!p.split('/').some(part=>['.git','node_modules'].includes(part));
|
|
8
|
+
|
|
9
|
+
export function readIntegrationSnapshots(value){
|
|
10
|
+
shape(value,['files','provenanceSha256']);hex(value.provenanceSha256);
|
|
11
|
+
need(Array.isArray(value.files)&&value.files.length>0&&value.files.length<=64,'integration_snapshot_invalid');
|
|
12
|
+
let previous='',total=0;
|
|
13
|
+
for(const file of value.files){
|
|
14
|
+
shape(file,['path','type','mode','size','sha256']);
|
|
15
|
+
need(snapshotPath(file.path)&&file.path>previous&&file.type==='file'
|
|
16
|
+
&&[0o644,0o664].includes(file.mode)&&Number.isSafeInteger(file.size)&&file.size>=0
|
|
17
|
+
&&file.size<=256*1024,'integration_snapshot_invalid');
|
|
18
|
+
hex(file.sha256);previous=file.path;total+=file.size;
|
|
19
|
+
}
|
|
20
|
+
need(total<=2*1024*1024,'integration_snapshot_invalid');
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function assertSnapshotBoundaries(snapshots,base,packages,learningPaths=[]){
|
|
25
|
+
if(!snapshots)return;
|
|
26
|
+
readIntegrationSnapshots(snapshots);
|
|
27
|
+
const existing=new Set(base.files.map(file=>file.path));
|
|
28
|
+
const protectedPaths=new Set([...base.scope,...base.requirements,...learningPaths,
|
|
29
|
+
...packages.flatMap(pkg=>[...pkg.scope,...pkg.requirements.map(file=>file.path),
|
|
30
|
+
...pkg.changes.map(file=>file.path),...(pkg.instructions??[]).map(file=>file.path)])]);
|
|
31
|
+
for(const file of snapshots.files){
|
|
32
|
+
const directory=file.path.slice(0,-'AGENTS.md'.length);
|
|
33
|
+
need(!existing.has(file.path)&&![...protectedPaths].some(p=>p===file.path||p.startsWith(directory)),
|
|
34
|
+
'integration_snapshot_protected');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function verifySnapshotReview(pkg,snapshots){
|
|
39
|
+
if(!snapshots)return;
|
|
40
|
+
const provenance=pkg.requirements.find(file=>file.path==='integration/snapshot-provenance.json');
|
|
41
|
+
need(provenance?.sha256===snapshots.provenanceSha256&&typeof provenance.contentBase64==='string',
|
|
42
|
+
'integration_snapshot_not_reviewed');
|
|
43
|
+
for(const expected of snapshots.files){
|
|
44
|
+
// Keep copied instructions in data files. Hash deduplication retains all
|
|
45
|
+
// bytes while the plan separately binds every target path and original mode.
|
|
46
|
+
const file=pkg.requirements.find(item=>item.path==='integration/snapshots/'+expected.sha256+'.txt');
|
|
47
|
+
need(file?.type==='file'&&file.sha256===expected.sha256&&file.size===expected.size
|
|
48
|
+
&&typeof file.contentBase64==='string','integration_snapshot_not_reviewed');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -5,7 +5,9 @@ import path from 'node:path';
|
|
|
5
5
|
import {randomUUID} from 'node:crypto';
|
|
6
6
|
import {setTimeout as delay} from 'node:timers/promises';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// develop is opt-in: only the batch driver allows it (session members' protected proposals).
|
|
9
|
+
const DEFAULT_KINDS=['qa_logic','qa_browser','verification_precheck','prd_materials'];
|
|
10
|
+
const KINDS=new Set([...DEFAULT_KINDS,'develop']);
|
|
9
11
|
const fail=code=>{throw Error(code);};
|
|
10
12
|
const inside=(root,file)=>file===root||file.startsWith(root+path.sep);
|
|
11
13
|
function resolvedFutureRoot(file){
|
|
@@ -25,8 +27,10 @@ function ordinaryAncestors(file){
|
|
|
25
27
|
}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
// minimumTimeouts: per-kind floor over timeoutMs, for a kind whose host deadline
|
|
31
|
+
// must fire first (batch develop: the host records call_timeout, not the driver).
|
|
32
|
+
export function createLiveEvidence(config,{base,protectedRoots=[],notify=()=>{},maxBytes=65536,allowedKinds=DEFAULT_KINDS,minimumTimeouts={}}={}){
|
|
33
|
+
if(config===undefined)return {has:()=>false,timeoutFor:()=>null,answer:async()=>null};
|
|
30
34
|
if(!config||typeof config!=='object'||Array.isArray(config)
|
|
31
35
|
||Object.keys(config).some(key=>!['directory','kinds','timeoutMs'].includes(key))
|
|
32
36
|
||typeof config.directory!=='string'||!config.directory.trim()
|
|
@@ -35,7 +39,9 @@ export function createLiveEvidence(config,{base,protectedRoots=[],notify=()=>{},
|
|
|
35
39
|
||!config.kinds.every(kind=>KINDS.has(kind)&&allowedKinds.includes(kind)))fail('live_evidence_invalid_config');
|
|
36
40
|
const timeout=config.timeoutMs??900000;
|
|
37
41
|
if(!Number.isSafeInteger(timeout)||timeout<1||timeout>3600000
|
|
38
|
-
||!Number.isSafeInteger(maxBytes)||maxBytes<1||maxBytes>4194304
|
|
42
|
+
||!Number.isSafeInteger(maxBytes)||maxBytes<1||maxBytes>4194304
|
|
43
|
+
||Object.entries(minimumTimeouts).some(([kind,ms])=>!KINDS.has(kind)||!Number.isSafeInteger(ms)||ms<1))fail('live_evidence_invalid_limit');
|
|
44
|
+
const timeoutFor=kind=>Math.max(timeout,minimumTimeouts[kind]??0);
|
|
39
45
|
const directory=path.resolve(base??process.cwd(),config.directory);
|
|
40
46
|
const validateDirectory=()=>{
|
|
41
47
|
ordinaryAncestors(directory);
|
|
@@ -51,7 +57,7 @@ export function createLiveEvidence(config,{base,protectedRoots=[],notify=()=>{},
|
|
|
51
57
|
};
|
|
52
58
|
validateDirectory();
|
|
53
59
|
const kinds=new Set(config.kinds),seen=new Set();let exchange=null;
|
|
54
|
-
return {has:kind=>kinds.has(kind),async answer(row,{signal}={}){
|
|
60
|
+
return {has:kind=>kinds.has(kind),timeoutFor:kind=>kinds.has(kind)?timeoutFor(kind):null,async answer(row,{signal}={}){
|
|
55
61
|
if(!kinds.has(row.kind))return null;
|
|
56
62
|
if(signal?.aborted)fail('live_evidence_cancelled');
|
|
57
63
|
if(row.type!=='host_request'||!row.sessionId||!row.callId
|
|
@@ -66,7 +72,7 @@ export function createLiveEvidence(config,{base,protectedRoots=[],notify=()=>{},
|
|
|
66
72
|
// File names never contain caller-controlled identifiers.
|
|
67
73
|
const stem=path.join(exchange,randomUUID()),requestFile=stem+'.request.json',resultFile=stem+'.result.json';
|
|
68
74
|
fs.writeFileSync(requestFile,JSON.stringify(row)+'\n',{flag:'wx',mode:0o600});
|
|
69
|
-
notify(requestFile);const end=Date.now()+
|
|
75
|
+
notify(requestFile);const end=Date.now()+timeoutFor(row.kind);
|
|
70
76
|
while(true){
|
|
71
77
|
if(signal?.aborted)fail('live_evidence_cancelled');
|
|
72
78
|
let fd;
|
|
@@ -90,6 +96,22 @@ export function createLiveEvidence(config,{base,protectedRoots=[],notify=()=>{},
|
|
|
90
96
|
}};
|
|
91
97
|
}
|
|
92
98
|
|
|
99
|
+
// The host gives a QA case qa.timeoutMs (60000 when omitted) to answer, while
|
|
100
|
+
// the live responder waits its own timeout. A host window shorter than that wait
|
|
101
|
+
// times the case out while the walkthrough is still running (an iOS UI pass
|
|
102
|
+
// takes minutes) and records it BLOCKED. Drivers refuse that on create and warn
|
|
103
|
+
// on resume, where the recorded configuration is kept.
|
|
104
|
+
export const QA_DEFAULT_ANSWER_WINDOW_MS=60000;
|
|
105
|
+
export function qaAnswerWindowShortfall(qa,live,kinds){
|
|
106
|
+
if(!qa||typeof qa!=='object')return null;
|
|
107
|
+
const window=qa.timeoutMs??QA_DEFAULT_ANSWER_WINDOW_MS;
|
|
108
|
+
const short=[...new Set(kinds)].filter(kind=>['qa_logic','qa_browser'].includes(kind)&&live.has(kind)&&live.timeoutFor(kind)>window);
|
|
109
|
+
if(!short.length)return null;
|
|
110
|
+
return `workflow 的 qa.timeoutMs ${Object.hasOwn(qa,'timeoutMs')?`为 ${window}`:`未填(默认 ${window})`} 毫秒,`
|
|
111
|
+
+`短于 PLAN.liveEvidence 对 ${short.join('、')} 的等待 ${Math.max(...short.map(kind=>live.timeoutFor(kind)))} 毫秒:`
|
|
112
|
+
+'宿主会先超时,把还在走查的用例判 BLOCKED。把 qa.timeoutMs 调到实际走查耗时(最多 3600000),或把 liveEvidence.timeoutMs 调到不超过它';
|
|
113
|
+
}
|
|
114
|
+
|
|
93
115
|
export function driverLiveEvidence(plan,options){
|
|
94
116
|
return createLiveEvidence(plan.liveEvidence,{...options,notify:file=>process.stderr.write(
|
|
95
117
|
`[drive] live_evidence_request: ${file}\n[drive] Read the live request, execute its task, then atomically write the matching .result.json host_result.\n`)});
|
|
@@ -45,15 +45,22 @@ function renderOperatorGuidance(result,{executionActive=false,protocol='legacy',
|
|
|
45
45
|
const v2=protocol==='v2',batch=surface==='batch';
|
|
46
46
|
const resume=batch?'从原批次入口发送 advance':'恢复原运行并发送 advance';
|
|
47
47
|
const permission=flag=>v2?fixedTarget:`显式 ${flag},并提供单行 reason`;
|
|
48
|
-
|
|
48
|
+
// V2 does have a supersede exit (create with a fixed supersedeTarget); it is a
|
|
49
|
+
// new run the user approves, never a flag this guidance hands out.
|
|
50
|
+
const supersede=v2?`${batch?'批次成员先取消本批次,再按单任务处理;':''}`
|
|
51
|
+
+'原运行确无合法恢复出口时,用原配置只读 inspect-history 取得 supersedeTarget 并保存,向用户展示旧状态与重开原因;'
|
|
52
|
+
+'用户批准后按 v2 create 重开流程以新 runId 重开同一任务(docs/cm-control-policy-v2.md「卡死任务重开」)。目标与旧运行不符返回 snapshot_changed 时停止,不自动刷新。'
|
|
49
53
|
:'修好后按 reason 用 --supersede-reviewed-evidence 新建运行重做。';
|
|
50
|
-
const supersedePrerequisites=v2?['原运行记录与现有文件保留,不改写','
|
|
54
|
+
const supersedePrerequisites=v2?['原运行记录与现有文件保留,不改写','重开须经用户批准且绑定已展示的 supersedeTarget','不改变原运行的协议、身份或恢复预算']
|
|
51
55
|
:['原运行记录保留,不改写','本运行留在盘上的改动需还原,或加 --accept-superseded-code-drift'];
|
|
52
56
|
if(result?.workflow!=='cm-ai'||!result.state||!result.identity)return null;
|
|
53
57
|
const {state,code,pendingAction:action,outcome}=result;
|
|
54
58
|
if(outcome==='rejected'||outcome==='denied')return explain('本次操作被拒绝,运行状态没有因此获得新的执行权限。',
|
|
55
59
|
'先核对 code 与 reason,修正请求或取得所需授权;不要据此重复开发或审查。');
|
|
56
60
|
if(executionActive)return explain('原运行仍有操作在执行。','等待原操作结果;可读取状态,不重复派发。');
|
|
61
|
+
if(code==='checkpoint_package_material_invalid')return explain('检查点审查包引用或原始材料校验失败,后续执行已停止。',
|
|
62
|
+
'保留原运行与全部记录,核对被引用记录的摘要和任务身份;交由维护者处理,不改写历史或重新派发。',null,
|
|
63
|
+
['不得替换被引用的原记录','不改变原运行身份与恢复预算']);
|
|
57
64
|
if(code==='spec_drift')return explain('已批准规格发生变化,后续执行被阻止。',
|
|
58
65
|
action==='spec_rebind'?(v2?'先核对重新批准的规格;符合原条件时,只读 status 并展示 launchControlTarget,将完整固定副本写入文件,以原策略和配置带 --expected-control FILE、--rebind-spec-material 与单行 --spec-rebind-reason 恢复;snapshot_changed 时停止,不自动刷新。':'先核对重新批准的规格;符合原任务内容未变的条件时,在原运行显式换绑规格。')
|
|
59
66
|
:'先核对规格变更与原任务绑定;当前没有可直接继续的恢复动作。',null,['保留原运行身份与历史','不得绕过规格审批']);
|
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
// POSIX children must be spawned detached. Own only that child's process group.
|
|
2
2
|
// A leader closing its pipes does not cancel escalation for its descendants.
|
|
3
|
-
|
|
3
|
+
// Every group signal goes through signalOwnedGroup (process-group-exit.mjs), which
|
|
4
|
+
// tells an exited, not yet reaped child (EPERM on macOS) from a live member.
|
|
5
|
+
import {signalOwnedGroup} from './process-group-exit.mjs';
|
|
6
|
+
export function ownedProcessCleanup(child,{graceMs=250,killWaitMs=750,killProcess=process.kill.bind(process),
|
|
7
|
+
exitBudgetMs=1000}={}) {
|
|
4
8
|
let cleanup;
|
|
5
9
|
const error=()=>Object.assign(new Error('process_cleanup_unknown'),{code:'process_cleanup_unknown'});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
// true: a member received it; false: the group is gone. An EPERM resolution never
|
|
11
|
+
// gets more than what is left of one overall deadline (review 2026-10-27): every
|
|
12
|
+
// signal used to get the full exitBudgetMs again, so the last probe could run past
|
|
13
|
+
// the cleanup's own limit.
|
|
14
|
+
let overall=null;
|
|
15
|
+
const left=()=>Math.max(0,overall-Date.now());
|
|
16
|
+
const signal=async(value,cap=exitBudgetMs)=>(await signalOwnedGroup(child,value,
|
|
17
|
+
{killProcess,budgetMs:Math.min(exitBudgetMs,cap,left())}))==='sent';
|
|
10
18
|
const pause=ms=>new Promise(resolve=>setTimeout(resolve,ms));
|
|
11
19
|
return ()=>cleanup??=(async()=>{
|
|
12
20
|
// Preserve the legacy Windows leader termination, without claiming tree cleanup.
|
|
13
21
|
if(process.platform==='win32'){child.kill('SIGTERM');throw error();}
|
|
14
22
|
// A failed spawn has no PID; in-memory test transports also have none.
|
|
15
23
|
if(!Number.isInteger(child.pid)||child.pid<=0){child.kill('SIGTERM');return;}
|
|
16
|
-
|
|
24
|
+
overall=Date.now()+exitBudgetMs+graceMs+killWaitMs;
|
|
25
|
+
if(!await signal('SIGTERM'))return;
|
|
17
26
|
await pause(graceMs);
|
|
18
|
-
if(!signal('SIGKILL'))return;
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
if(!await signal('SIGKILL'))return;
|
|
28
|
+
// Review 2026-10-27 round 3: an EPERM resolution before SIGKILL must not buy the
|
|
29
|
+
// poll a fresh killWaitMs, so the poll also ends at the overall deadline.
|
|
30
|
+
const until=Math.min(Date.now()+killWaitMs,overall);
|
|
31
|
+
// SIGKILL delivery is asynchronous. Give the group one polling turn to
|
|
32
|
+
// exit before probing; this wait consumes the existing deadline. An actual
|
|
33
|
+
// permission error still fails immediately, without another probe.
|
|
34
|
+
do {
|
|
35
|
+
await pause(Math.min(25,Math.max(0,until-Date.now())));
|
|
36
|
+
if(!await signal(0,Math.max(0,until-Date.now())))return;
|
|
37
|
+
} while(Date.now()<until);
|
|
38
|
+
throw error();
|
|
21
39
|
})();
|
|
22
40
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Whether a process group we spawned (detached, so its id is our direct child's pid)
|
|
2
|
+
// has really stopped: the writer-stopped proof behind every owned cleanup.
|
|
3
|
+
//
|
|
4
|
+
// Measured on macOS 26 (2026-10-27): a group whose only member is our own child that
|
|
5
|
+
// already exited but is not reaped yet (a zombie) answers kill(-pgid, 0|SIGTERM) with
|
|
6
|
+
// EPERM; once Node has reaped it (its 'exit' event) the same signal answers ESRCH, or
|
|
7
|
+
// is delivered when a live member is left. A grandchild zombie is reaped by launchd
|
|
8
|
+
// or init promptly. So EPERM is only resolved through our own child: wait (without
|
|
9
|
+
// blocking the event loop) until its exit is observed, then signal again within the
|
|
10
|
+
// same small budget. ESRCH is a stop, a delivered signal means a live member, and an
|
|
11
|
+
// EPERM that persists (a member we may not signal) stays unknown. No process table
|
|
12
|
+
// is read and no external program runs.
|
|
13
|
+
const unknown=()=>Object.assign(new Error('process_cleanup_unknown'),{code:'process_cleanup_unknown'});
|
|
14
|
+
const exited=child=>Number.isInteger(child?.exitCode)||typeof child?.signalCode==='string';
|
|
15
|
+
const pause=ms=>new Promise(resolve=>setTimeout(resolve,ms));
|
|
16
|
+
// Our direct child's exit, observed (Node emits 'exit' after reaping it) before the
|
|
17
|
+
// deadline. A child object without exit tracking can never prove it.
|
|
18
|
+
function childExit(child,deadline){
|
|
19
|
+
if(exited(child))return Promise.resolve(true);
|
|
20
|
+
if(typeof child?.once!=='function')return Promise.resolve(false);
|
|
21
|
+
return new Promise(resolve=>{
|
|
22
|
+
const done=()=>{clearTimeout(timer);resolve(true);};
|
|
23
|
+
const timer=setTimeout(()=>{child.off?.('exit',done);resolve(exited(child));},Math.max(0,deadline-Date.now()));
|
|
24
|
+
child.once('exit',done);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Signal the group of our detached child: 'sent' (a live member received it) or
|
|
29
|
+
// 'gone' (the group no longer exists); throws process_cleanup_unknown otherwise.
|
|
30
|
+
// budgetMs bounds the EPERM resolution (child exit wait plus re-probes) in all.
|
|
31
|
+
export async function signalOwnedGroup(child,signal,{killProcess=process.kill.bind(process),budgetMs=1000,probeEveryMs=50}={}){
|
|
32
|
+
const send=()=>{
|
|
33
|
+
try{killProcess(-child.pid,signal);return 'sent';}
|
|
34
|
+
catch(error){return error?.code==='ESRCH'?'gone':error?.code==='EPERM'?'denied':'error';}
|
|
35
|
+
};
|
|
36
|
+
const first=send();
|
|
37
|
+
if(first==='sent'||first==='gone')return first;
|
|
38
|
+
const deadline=Date.now()+budgetMs;
|
|
39
|
+
if(first==='error'||!await childExit(child,deadline))throw unknown();
|
|
40
|
+
for(;;){
|
|
41
|
+
const again=send();
|
|
42
|
+
if(again==='sent'||again==='gone')return again;
|
|
43
|
+
if(again==='error'||Date.now()>=deadline)throw unknown();
|
|
44
|
+
await pause(Math.min(probeEveryMs,Math.max(0,deadline-Date.now())));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -190,10 +190,11 @@ export function inspectProviderReviewReconciliation(observationText,expectationT
|
|
|
190
190
|
const review=cause?reviewResultForPaths(r.value,expected.pkg,causeReviewPaths(expected.pkg)):reviewResult(r.value,expected.pkg);
|
|
191
191
|
return json({...inspect(observationText,expectationText,cause),observationStatus:'completed',code:null,review});
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
// A Codex rate limit (worker-codex.mjs) is the only other trusted failed terminal; it keeps its class.
|
|
194
|
+
need(['error','turn.failed'].includes(terminal)&&r.status==='failed'&&['provider_failed','reviewer_rate_limited'].includes(r.code),
|
|
194
195
|
'review_reconciliation_evidence_required');
|
|
195
196
|
return json({version:1,kind:'cm-provider-review-failure',requestDigest:expected.request.requestDigest,
|
|
196
197
|
observationDigest:digest(observation),identity:expected.request.identity,logicalContextId:expected.request.contextId,
|
|
197
198
|
provider:expected.request.provider,requestedModel:expected.request.requestedModel,providerThreadId:thread,
|
|
198
|
-
category:'provider',failure:
|
|
199
|
+
category:'provider',failure:REVIEWER_PROVIDER_FAILURES[r.code],completionEligible:false});
|
|
199
200
|
}
|
|
@@ -28,3 +28,25 @@ export function preQaConfigurations(material){
|
|
|
28
28
|
else delete withoutWorkflow.applicableAgentFiles;
|
|
29
29
|
return [withoutQa,withoutWorkflow];
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
// The configurations a v2 run with qa:"disabled" was created with, derived from
|
|
33
|
+
// the qa:"run" launch that turns QA on: the policy's qa value, the executor and
|
|
34
|
+
// at most the QA part of the workflow differ. Under qa:"disabled" the host kept a
|
|
35
|
+
// given workflow (its qa as given, or null) and the QA decision; without any
|
|
36
|
+
// workflow it kept the implicit decision (implicit-qa-decision.mjs), and runs
|
|
37
|
+
// older than that had no decision at all. Each still has to equal the saved digest.
|
|
38
|
+
export function preQaUpgradeConfigurations(material){
|
|
39
|
+
if(material?.execution?.controlPolicy?.qa!=='run'||!material.qaExecutor||!material.qaDecisionProvider)return [];
|
|
40
|
+
const base=structuredClone(json(material));base.execution.controlPolicy.qa='disabled';
|
|
41
|
+
const kept=structuredClone(base);delete kept.qaExecutor;
|
|
42
|
+
const nullQa=structuredClone(kept);
|
|
43
|
+
const wrapped=Object.hasOwn(nullQa.execution.workflow??{},'configuration');
|
|
44
|
+
const workflow=wrapped?nullQa.execution.workflow.configuration:nullQa.execution.workflow;
|
|
45
|
+
if(!workflow?.qa)return [];
|
|
46
|
+
workflow.qa=null;
|
|
47
|
+
const candidates=preQaConfigurations(base);
|
|
48
|
+
const decided=structuredClone(candidates[1]);
|
|
49
|
+
decided.qaDecisionProvider=material.qaDecisionProvider;decided.qaTimeoutMs=material.qaTimeoutMs;
|
|
50
|
+
const plain=structuredClone(decided);delete plain.applicableAgentFiles;
|
|
51
|
+
return [kept,nullQa,...candidates,decided,plain];
|
|
52
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import {digest,json,shape,need,hex,id,text} from './effect-contract.mjs';
|
|
3
3
|
import {createHostQaExecutor} from './host-qa-executor.mjs';
|
|
4
4
|
import {validateHostWorkflowConfiguration} from './host-workflow-capabilities.mjs';
|
|
5
|
-
import {preQaConfigurations,readQaAttachment} from './qa-attachment.mjs';
|
|
5
|
+
import {preQaConfigurations,preQaUpgradeConfigurations,readQaAttachment} from './qa-attachment.mjs';
|
|
6
|
+
import {controlPolicyFromSnapshot,isControlQaUpgrade} from './control-policy.mjs';
|
|
6
7
|
|
|
7
8
|
const workflow=material=>material.execution?.workflow?.configuration??material.execution?.workflow;
|
|
8
9
|
const BUILT_IN='cm-host-qa-executor-v1';
|
|
@@ -113,7 +114,11 @@ export function verifyQaRevisionMaterial(snapshot,material,prior=null){
|
|
|
113
114
|
need(digest(qaConfigurationSlice(candidate))===revisions.at(-1).qaDigest,'fingerprint_mismatch');
|
|
114
115
|
}else{
|
|
115
116
|
const attached=snapshot.records.some(row=>row.payload.type==='qa-attached');
|
|
116
|
-
|
|
117
|
+
// A v2 run that turned QA on (control-policy.mjs isControlQaUpgrade) was
|
|
118
|
+
// attached from its qa:"disabled" configuration; check against that one.
|
|
119
|
+
const upgraded=attached&&isControlQaUpgrade(controlPolicyFromSnapshot(snapshot),candidate?.execution?.controlPolicy??null);
|
|
120
|
+
need((attached?[...preQaConfigurations(candidate),...(upgraded?preQaUpgradeConfigurations(candidate):[])]:[candidate])
|
|
121
|
+
.some(p=>digest(p)===snapshot.fingerprints.config),'fingerprint_mismatch');
|
|
117
122
|
}
|
|
118
123
|
return revisions;
|
|
119
124
|
}
|