@aibyzero/cm-workflow 0.16.4 → 0.16.6
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 +22 -0
- package/CHANGELOG.md +57 -0
- package/README.md +22 -4
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/VERSION +1 -1
- package/docs/architecture.md +43 -0
- package/docs/execution-optimizations.md +33 -0
- package/docs/external-models.md +114 -0
- package/docs/fixes/.reviews/20260929-bootstrap-unchanged-review-r1.md +7 -0
- package/docs/fixes/.reviews/20260930-develop-package-limit-recovery-r4.md +9 -0
- package/docs/fixes/20260929-bootstrap-rule-refresh-conflict.md +22 -0
- package/docs/fixes/20260929-bootstrap-unchanged-review.md +26 -0
- package/docs/fixes/20260930-develop-package-limit-recovery.md +65 -0
- package/docs/human-correction.md +31 -0
- package/docs/installation.md +48 -7
- package/docs/js-workflow-control.md +293 -33
- package/docs/live-evidence-drivers.md +62 -0
- package/docs/next-steps.md +15 -10
- package/docs/runtime-failover.md +1 -1
- package/docs/untested-branches.md +27 -4
- package/docs/user-guide.md +23 -8
- package/install-codex.sh +28 -11
- package/package.json +1 -1
- package/runtime/js/cm-ai/accepted-fix.mjs +23 -5
- package/runtime/js/cm-ai/bootstrap-feature.mjs +15 -0
- package/runtime/js/cm-ai/claude-review-adapter.mjs +7 -4
- package/runtime/js/cm-ai/claude-review-stream.mjs +12 -0
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -4
- package/runtime/js/cm-ai/cm-ai-admission.mjs +115 -41
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +3 -2
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +208 -34
- package/runtime/js/cm-ai/cm-ai-learning-handoff-writer.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-learning-writer.mjs +22 -5
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +181 -57
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +15 -58
- package/runtime/js/cm-ai/codex-config.mjs +3 -2
- package/runtime/js/cm-ai/codex-review-adapter.mjs +56 -17
- package/runtime/js/cm-ai/committed-rule-basis.mjs +76 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +6 -2
- package/runtime/js/cm-ai/diagnostic-reason.mjs +10 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +315 -0
- package/runtime/js/cm-ai/drive-core.mjs +47 -9
- package/runtime/js/cm-ai/durable-runner-state.mjs +413 -56
- package/runtime/js/cm-ai/effect-abandon-log.mjs +19 -0
- package/runtime/js/cm-ai/effect-contract.mjs +44 -2
- package/runtime/js/cm-ai/execution-policy.mjs +58 -0
- package/runtime/js/cm-ai/execution-store-limits.mjs +18 -0
- package/runtime/js/cm-ai/execution-store.mjs +6 -4
- package/runtime/js/cm-ai/external-group-models.mjs +53 -0
- package/runtime/js/cm-ai/external-model-launch.mjs +23 -0
- package/runtime/js/cm-ai/external-models.mjs +52 -0
- package/runtime/js/cm-ai/external-run-guard.mjs +96 -0
- package/runtime/js/cm-ai/fix-code-association.mjs +171 -18
- package/runtime/js/cm-ai/host-bootstrap.mjs +126 -29
- package/runtime/js/cm-ai/host-check.mjs +30 -4
- package/runtime/js/cm-ai/host-conversation-execution.mjs +66 -20
- package/runtime/js/cm-ai/host-handoff.mjs +13 -6
- package/runtime/js/cm-ai/host-progress.mjs +80 -0
- package/runtime/js/cm-ai/host-project-execution.mjs +16 -11
- package/runtime/js/cm-ai/host-qa-executor.mjs +23 -9
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +23 -6
- package/runtime/js/cm-ai/host-qa-policy.mjs +16 -7
- package/runtime/js/cm-ai/host-session.mjs +12 -4
- package/runtime/js/cm-ai/host-tool-bridge.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +16 -5
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/knowledge-closeout.mjs +56 -0
- package/runtime/js/cm-ai/launch-mismatch.mjs +42 -0
- package/runtime/js/cm-ai/legacy-model-run-preview.mjs +24 -0
- package/runtime/js/cm-ai/legacy-model-settings.mjs +59 -0
- package/runtime/js/cm-ai/live-evidence.mjs +96 -0
- package/runtime/js/cm-ai/log-rows.mjs +21 -0
- package/runtime/js/cm-ai/model-configuration-file.mjs +63 -0
- package/runtime/js/cm-ai/model_configuration_write.py +214 -0
- package/runtime/js/cm-ai/native-usage-log.mjs +26 -0
- package/runtime/js/cm-ai/operator-guidance.mjs +86 -0
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +22 -0
- package/runtime/js/cm-ai/project-qa-gate.mjs +84 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +68 -9
- package/runtime/js/cm-ai/provider-usage.mjs +39 -0
- package/runtime/js/cm-ai/qa-config-revision.mjs +44 -10
- package/runtime/js/cm-ai/review-abandon-log.mjs +21 -0
- package/runtime/js/cm-ai/review-package.mjs +438 -31
- package/runtime/js/cm-ai/review-presentation.mjs +45 -0
- package/runtime/js/cm-ai/review-reconciliation.mjs +20 -0
- package/runtime/js/cm-ai/review-runner.mjs +47 -1
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +97 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +104 -10
- package/runtime/js/cm-ai/reviewed-evidence-supersession-record.mjs +42 -3
- package/runtime/js/cm-ai/specification-material.mjs +154 -12
- package/runtime/js/cm-ai/status-projection.mjs +93 -0
- package/runtime/js/cm-ai/task-commit.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +658 -75
- package/runtime/js/cm-ai/tool-preview.mjs +8 -4
- package/runtime/js/cm-ai/worker-claude-developer.mjs +16 -7
- package/runtime/js/cm-ai/worker-claude.mjs +63 -19
- package/runtime/js/cm-ai/worker-codex-developer.mjs +15 -9
- package/runtime/js/cm-ai/worker-codex.mjs +45 -19
- package/runtime/js/cm-fix/cause-evidence.mjs +5 -3
- package/runtime/js/cm-fix/cause-invocation.mjs +6 -3
- package/runtime/js/cm-fix/cause-package.mjs +10 -1
- package/runtime/js/cm-fix/execution.mjs +279 -52
- package/runtime/js/cm-fix/final-review.mjs +18 -10
- package/runtime/js/cm-fix/host-review.mjs +32 -9
- package/runtime/js/cm-fix/host.mjs +6 -1
- package/runtime/js/cm-fix/layout.mjs +1 -1
- package/runtime/js/cm-fix/progress.mjs +5 -0
- package/runtime/js/cm-fix/protected-edits.mjs +15 -4
- package/runtime/js/cm-fix/qa-source.mjs +6 -4
- package/runtime/js/cm-fix/review-reconciliation.mjs +64 -0
- package/runtime/js/cm-prd/analysis.mjs +2 -1
- package/runtime/js/cm-prd/change.mjs +28 -10
- package/runtime/js/cm-prd/draft.mjs +5 -2
- package/runtime/js/cm-prd/response-recovery.mjs +23 -0
- package/runtime/js/cm-prd/review-preparation.mjs +10 -3
- package/runtime/js/cm-prd/review-publication.mjs +27 -15
- package/runtime/js/cm-prd/review-time.mjs +29 -0
- package/runtime/js/cm-prd/self-check.mjs +6 -3
- package/runtime/js/cm-prd/session.mjs +53 -6
- package/runtime/js/cm-prd/summary.mjs +3 -1
- package/runtime/js/cm-prd/validation-reason.mjs +20 -0
- package/runtime/js/cm-security/finalize.mjs +32 -0
- package/runtime/js/spec-task-line.mjs +117 -0
- package/runtime/js/specs-status.mjs +10 -3
- package/runtime/review.md +5 -0
- package/runtime/task-gates.md +6 -0
- package/runtime/workflow-config.md +10 -1
- package/scripts/cm-ai-abandon-effect-position.test.mjs +201 -0
- package/scripts/cm-ai-admission.mjs +18 -11
- package/scripts/cm-ai-admission.test.mjs +65 -1
- package/scripts/cm-ai-batch-drive.mjs +135 -34
- package/scripts/cm-ai-batch-drive.test.mjs +209 -3
- package/scripts/cm-ai-batch-host.mjs +63 -24
- package/scripts/cm-ai-batch-host.test.mjs +2 -1
- package/scripts/cm-ai-batch-run.mjs +101 -34
- package/scripts/cm-ai-batch-run.test.mjs +56 -5
- package/scripts/cm-ai-bootstrap-driver-preflight.test.mjs +45 -0
- package/scripts/cm-ai-bootstrap-flow.test.mjs +159 -0
- package/scripts/cm-ai-bootstrap-merge.test.mjs +162 -0
- package/scripts/cm-ai-bootstrap.test.mjs +174 -89
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +97 -2
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +924 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +468 -0
- package/scripts/cm-ai-drive-timeout.test.mjs +17 -0
- package/scripts/cm-ai-drive.mjs +526 -60
- package/scripts/cm-ai-drive.test.mjs +336 -10
- package/scripts/cm-ai-fix-later-delivery.test.mjs +383 -0
- package/scripts/cm-ai-host.mjs +142 -43
- package/scripts/cm-ai-host.test.mjs +232 -12
- package/scripts/cm-ai-launch-diagnostics.test.mjs +142 -0
- package/scripts/cm-ai-multi-root.test.mjs +9 -3
- package/scripts/cm-ai-operator-guidance.test.mjs +94 -0
- package/scripts/cm-ai-progress.test.mjs +521 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +308 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +187 -15
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +157 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +27 -2
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +400 -0
- package/scripts/cm-ai-review-drift-precedence.test.mjs +90 -0
- package/scripts/cm-ai-review-failure.test.mjs +977 -0
- package/scripts/cm-ai-review-timeout-config.test.mjs +29 -7
- package/scripts/cm-ai-review-timeout.test.mjs +199 -4
- package/scripts/cm-ai-run.mjs +206 -62
- package/scripts/cm-ai-run.test.mjs +6 -4
- package/scripts/cm-ai-runner-error-code-regression.test.mjs +219 -0
- package/scripts/cm-ai-selection-guard.test.mjs +100 -0
- package/scripts/cm-ai-session-chain.test.mjs +7 -3
- package/scripts/cm-ai-spec-rebind.test.mjs +481 -0
- package/scripts/cm-ai-supersede.test.mjs +571 -17
- package/scripts/cm-ai-verification-gate.test.mjs +2 -1
- package/scripts/cm-bootstrap-review-recovery.test.mjs +70 -0
- package/scripts/cm-capability-gate.test.mjs +21 -2
- package/scripts/cm-check-drive.test.mjs +2 -1
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +12 -1
- package/scripts/cm-claude-developer-worker.test.mjs +3 -1
- package/scripts/cm-claude-install-layout.test.mjs +26 -0
- package/scripts/cm-claude-probe.test.mjs +10 -2
- package/scripts/cm-claude-review-stream.test.mjs +25 -0
- package/scripts/cm-claude-worker.test.mjs +11 -4
- package/scripts/cm-codex-developer-worker.test.mjs +4 -2
- package/scripts/cm-codex-plugin-metadata.py +83 -0
- package/scripts/cm-codex-plugin-metadata.test.mjs +55 -0
- package/scripts/cm-efficiency-checks.test.mjs +37 -0
- package/scripts/cm-efficiency-diagnostics.test.mjs +74 -0
- package/scripts/cm-efficiency-offline.mjs +35 -0
- package/scripts/cm-efficiency-policy.test.mjs +48 -0
- package/scripts/cm-efficiency-presentation.test.mjs +35 -0
- package/scripts/cm-efficiency-response.test.mjs +117 -0
- package/scripts/cm-efficiency-usage.test.mjs +148 -0
- package/scripts/cm-external-batch-host.test.mjs +157 -0
- package/scripts/cm-external-fix-host.test.mjs +281 -0
- package/scripts/cm-external-fix-reconciliation.test.mjs +105 -0
- package/scripts/cm-external-group-models.test.mjs +60 -0
- package/scripts/cm-external-model-host.test.mjs +180 -0
- package/scripts/cm-external-model-recovery.test.mjs +108 -0
- package/scripts/cm-external-models.test.mjs +89 -0
- package/scripts/cm-external-process-cleanup.test.mjs +71 -0
- package/scripts/cm-external-qa-fix.test.mjs +170 -0
- package/scripts/cm-external-review-reconciliation.test.mjs +314 -0
- package/scripts/cm-failover.mjs +8 -8
- package/scripts/cm-fix-abandon.test.mjs +123 -5
- package/scripts/cm-fix-cause-package.test.mjs +2 -0
- package/scripts/cm-fix-drive.mjs +70 -23
- package/scripts/cm-fix-drive.test.mjs +36 -1
- package/scripts/cm-fix-final-review.test.mjs +11 -6
- package/scripts/cm-fix-host.mjs +24 -14
- package/scripts/cm-fix-protected-edits.test.mjs +12 -0
- package/scripts/cm-fix-rediagnosis.test.mjs +168 -0
- package/scripts/cm-fix-review-budget.test.mjs +147 -0
- package/scripts/cm-fixture-process-cleanup.test.mjs +95 -0
- package/scripts/cm-host-check.test.mjs +6 -3
- package/scripts/cm-host-qa-executor.test.mjs +213 -17
- package/scripts/cm-host-session-diagnostic.test.mjs +10 -0
- package/scripts/cm-interactive-qa-diagnostic.test.mjs +53 -0
- package/scripts/cm-knowledge-closeout.test.mjs +160 -0
- package/scripts/cm-live-evidence.test.mjs +64 -0
- package/scripts/cm-log-event.mjs +25 -2
- package/scripts/cm-log-event.py +15 -0
- package/scripts/cm-log-event.test.mjs +31 -0
- package/scripts/cm-model-setup.mjs +79 -0
- package/scripts/cm-prd-completion.test.mjs +75 -0
- package/scripts/cm-prd-draft.test.mjs +14 -0
- package/scripts/cm-prd-drive.mjs +32 -11
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-gate-diagnostic.test.mjs +100 -0
- package/scripts/cm-prd-host.mjs +13 -4
- package/scripts/cm-prd-review-gate.mjs +126 -81
- package/scripts/cm-prd-review-gate.test.mjs +105 -1
- package/scripts/cm-prd-review-preparation.test.mjs +15 -0
- package/scripts/cm-prd-review-publication.test.mjs +6 -0
- package/scripts/cm-prd-self-check.test.mjs +6 -0
- package/scripts/cm-prd-summary.test.mjs +9 -0
- package/scripts/cm-release-smoke.sh +5 -1
- package/scripts/cm-review-dependency-snapshot.test.mjs +15 -0
- package/scripts/cm-review-inventory.test.mjs +253 -1
- package/scripts/cm-runtime-i18n.mjs +15 -4
- package/scripts/cm-runtime-install.mjs +8 -4
- package/scripts/cm-runtime.mjs +116 -23
- package/scripts/cm-runtime.test.mjs +121 -12
- package/scripts/cm-security.test.mjs +32 -0
- package/scripts/cm-spec-manifest.mjs +28 -10
- package/scripts/cm-spec-manifest.test.mjs +8 -4
- package/scripts/cm-spec-task-line.test.mjs +138 -0
- package/scripts/cm-specs-status.test.mjs +12 -1
- package/scripts/cm-task-gate-correction.test.mjs +117 -0
- package/scripts/cm-task-gate.mjs +164 -20
- package/scripts/cm-task-gate.py +2 -1
- package/scripts/cm-test-branch-impact.test.mjs +6 -3
- package/scripts/cm-test-drive.mjs +10 -4
- package/scripts/cm-test-drive.test.mjs +14 -1
- package/scripts/cm-tool-preview-context.test.mjs +12 -0
- package/scripts/cm-usage-report.py +22 -3
- package/scripts/cm-workflow-config.mjs +10 -1
- package/scripts/fixtures/bootstrap-review-runner.mjs +102 -0
- package/scripts/fixtures/claude-review-process.mjs +1 -0
- package/scripts/fixtures/live-evidence-driver.mjs +35 -0
- package/scripts/fixtures/process-cleanup.mjs +101 -0
- package/scripts/test-cm-log-event.py +2 -0
- package/scripts/test-cm-native-usage.py +62 -0
- package/scripts/test-cm-prd-review-gate.py +2 -1
- package/scripts/test-external-model-setup.py +91 -0
- package/scripts/test-model-configuration-write.py +201 -0
- package/scripts/test-npm-install.py +11 -2
- package/scripts/test-scan-public-safety.py +1 -1
- package/scripts/test-spec-manifest.py +16 -8
- package/scripts/test-task-gate.py +2 -2
- package/scripts/test-workflow-config.py +1 -0
- package/scripts/validate-public-repo.py +1 -0
- package/skills/cm-ai/SKILL.md +2 -2
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N8-finish.md +5 -0
- package/skills/cm-ai/references/js-host.md +270 -43
- package/skills/cm-ai/references/knowledge-closeout.md +90 -0
- package/skills/cm-fix/SKILL.md +1 -1
- package/skills/cm-fix/references/js-host.md +52 -3
- package/skills/cm-prd/references/js-change-recovery.md +1 -1
- package/skills/cm-prd/references/js-host.md +6 -0
- package/skills/cm-runtime/SKILL.md +29 -6
- package/skills/cm-security/SKILL.md +4 -2
- package/skills/cm-security/references/scan-contract.md +1 -0
- package/templates/cm-workflow.yml +1 -1
|
@@ -4,11 +4,13 @@ import fs from 'node:fs';
|
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import {PassThrough} from 'node:stream';
|
|
7
|
+
import {spawnSync} from 'node:child_process';
|
|
8
|
+
import {fileURLToPath} from 'node:url';
|
|
7
9
|
import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
8
10
|
import {serveCmAiHost} from '../runtime/js/cm-ai/host-session.mjs';
|
|
9
11
|
import {createHostQaDecisionProvider} from '../runtime/js/cm-ai/host-qa-policy.mjs';
|
|
10
12
|
import {createHostQaExecutor} from '../runtime/js/cm-ai/host-qa-executor.mjs';
|
|
11
|
-
import {recordCmAiQaDecision,recordCmAiQaRun,inspectCmAiQaResult} from '../runtime/js/cm-ai/cm-ai-qa-log.mjs';
|
|
13
|
+
import {recordCmAiQaDecision,recordCmAiQaRun,inspectCmAiQaResult,readCmAiQaRunRound} from '../runtime/js/cm-ai/cm-ai-qa-log.mjs';
|
|
12
14
|
|
|
13
15
|
function fixture() {
|
|
14
16
|
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-qa-exec-')));
|
|
@@ -45,6 +47,27 @@ function begin(f,executor) {
|
|
|
45
47
|
return input;
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
for(const protectedMode of [false,true])test(`progress R1: quiet QA command boundaries; protected=${protectedMode}`,
|
|
51
|
+
{skip:protectedMode&&spawnSync('codex',['--version']).status!==0},async()=>{
|
|
52
|
+
const f=fixture(),events=[],original=process.stderr.write;let captured='';
|
|
53
|
+
try{
|
|
54
|
+
fs.unlinkSync(path.join(f.configuration.specsDir,f.configuration.feature,'test-cases.json'));
|
|
55
|
+
f.configuration.commands=[{id:'quiet-qa',command:[process.execPath,'-e',
|
|
56
|
+
"setTimeout(()=>{console.log('fixture-raw-output');process.exit(0)},400)"],caseIds:[]}];
|
|
57
|
+
const executor=createHostQaExecutor({...f.configuration,...(protectedMode?{specsRoot:f.configuration.specsDir}:{})});
|
|
58
|
+
const binding=begin(f,executor);
|
|
59
|
+
process.stderr.write=function(chunk,...args){
|
|
60
|
+
captured+=String(chunk);if(String(chunk).includes('[check]'))events.push({text:String(chunk),at:Date.now()});
|
|
61
|
+
return original.call(this,chunk,...args);
|
|
62
|
+
};
|
|
63
|
+
const result=await executor.run(binding,new AbortController().signal);
|
|
64
|
+
assert.equal(result.result,'PASS');assert.equal(events.length,2,captured);
|
|
65
|
+
assert.match(events[0].text,/开始检查.*quiet-qa/);assert.match(events[1].text,/检查结束.*quiet-qa.*passed/);
|
|
66
|
+
assert(events[1].at-events[0].at>=300,'start must be visible during the quiet command');
|
|
67
|
+
assert(!captured.includes('fixture-raw-output'),'QA raw project output remains private');
|
|
68
|
+
}finally{process.stderr.write=original;f.cleanup();}
|
|
69
|
+
});
|
|
70
|
+
|
|
48
71
|
for(const transport of ['synchronous','jsonl','coalesced-jsonl'])test(`incident sequence: immediate QA replies over ${transport}`,{timeout:30000},async()=>{
|
|
49
72
|
const f=fixture(),bridge=createHostToolBridge(),input=new PassThrough(),output=new PassThrough();
|
|
50
73
|
let serving;
|
|
@@ -224,7 +247,7 @@ test('host QA cancellation leaves an unfinished invocation and never writes succ
|
|
|
224
247
|
}finally{f.cleanup();}
|
|
225
248
|
});
|
|
226
249
|
|
|
227
|
-
for(const kind of ['qa_logic','qa_browser','qa_assess'])test(`QA request watchdog settles ${kind} as BLOCKED`,async()=>{
|
|
250
|
+
for(const kind of ['qa_logic','qa_browser','qa_assess'])test(`QA request watchdog settles ${kind} ${kind==='qa_assess'?'as a retryable qa_decision_timeout':'as BLOCKED'}`,async()=>{
|
|
228
251
|
const f=fixture(),bridge=createHostToolBridge(),sent=[];
|
|
229
252
|
try{
|
|
230
253
|
bridge.attach(row=>{if(row.type==='host_request'){
|
|
@@ -240,9 +263,12 @@ for(const kind of ['qa_logic','qa_browser','qa_assess'])test(`QA request watchdo
|
|
|
240
263
|
}});
|
|
241
264
|
const call=(name)=>(r,s)=>bridge.call(name,r,s,{timeoutMs:20});
|
|
242
265
|
if(kind==='qa_assess'){
|
|
266
|
+
// A missed assessment window is a transport outcome: nothing to record.
|
|
243
267
|
const {testRunId,...binding}=f.binding;
|
|
244
|
-
const
|
|
245
|
-
assert.
|
|
268
|
+
const log=path.join(f.binding.specsDir,'运行日志.jsonl'),before=fs.readFileSync(log);
|
|
269
|
+
await assert.rejects(createHostQaDecisionProvider({timeoutMs:1000,assess:call(kind)}).decide(binding,new AbortController().signal),
|
|
270
|
+
{code:'qa_decision_timeout'});
|
|
271
|
+
assert.deepEqual(fs.readFileSync(log),before);
|
|
246
272
|
}else{
|
|
247
273
|
const executor=createHostQaExecutor({...f.configuration,logic:call('qa_logic'),browser:call('qa_browser')});
|
|
248
274
|
const binding=begin(f,executor),result=await executor.run(binding,new AbortController().signal);
|
|
@@ -637,9 +663,82 @@ test('step30b empty mid-feature plan emits one explicit deferred BLOCKED row',as
|
|
|
637
663
|
}finally{f.cleanup();assert.equal(fs.existsSync(f.root),false);}
|
|
638
664
|
});
|
|
639
665
|
|
|
640
|
-
for(const
|
|
641
|
-
|
|
642
|
-
|
|
666
|
+
for(const mode of ['unavailable-only','confirmation','failed-and-unavailable','insufficient-and-unavailable','unmapped'])
|
|
667
|
+
test(`logic report rows record why they are BLOCKED: ${mode}`,async()=>{
|
|
668
|
+
const f=fixture();
|
|
669
|
+
try{
|
|
670
|
+
const kill=[process.execPath,'-e','process.kill(process.pid,"SIGKILL")'];
|
|
671
|
+
f.configuration.commands=[{id:'killed',command:kill,caseIds:mode==='unmapped'?[]:['TC-001']},
|
|
672
|
+
...(mode==='failed-and-unavailable'?[{id:'fails',command:[process.execPath,'-e','process.exit(1)'],caseIds:['TC-001']}]:[])];
|
|
673
|
+
if(mode==='confirmation'){
|
|
674
|
+
const source=path.join(f.binding.specsDir,f.binding.feature,'test-cases.json'),contract=JSON.parse(fs.readFileSync(source));
|
|
675
|
+
contract.cases[0].expected=['[需确认] synthetic expectation'];fs.writeFileSync(source,JSON.stringify(contract));
|
|
676
|
+
}
|
|
677
|
+
const artifact=path.join(f.binding.specsDir,'.reviews','browser.txt');fs.writeFileSync(artifact,'Synthetic observation');
|
|
678
|
+
const executor=createHostQaExecutor({...f.configuration,logic:async()=>({verdict:mode==='insufficient-and-unavailable'?'INSUFFICIENT_EVIDENCE':'SUPPORTED',
|
|
679
|
+
evidence:['Synthetic static observation']}),
|
|
680
|
+
browser:async request=>({verdict:'PASS',evidence:[artifact],environment:request.environment,cleanup:'completed'})});
|
|
681
|
+
const result=await executor.run(begin(f,executor),new AbortController().signal);
|
|
682
|
+
const row=fs.readFileSync(result.report,'utf8').split(/^## /m).filter(part=>part.startsWith('TC-001\n'))
|
|
683
|
+
.map(part=>JSON.parse(part.slice('TC-001'.length+1)))[0];
|
|
684
|
+
assert.equal(row.verdict,mode==='failed-and-unavailable'?'FAIL':'BLOCKED');
|
|
685
|
+
assert.equal(row.commandUnavailable,mode==='unavailable-only'?true:undefined);
|
|
686
|
+
assert.equal(row.needsConfirmation,mode==='confirmation'?true:undefined);
|
|
687
|
+
}finally{f.cleanup();}
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
test('superseded rows written before recovery_rule 2 replay under the original rule; new rows use the contract',async()=>{
|
|
691
|
+
const f=fixture();
|
|
692
|
+
try{
|
|
693
|
+
// The original rule accepted a logic INSUFFICIENT_EVIDENCE case even with [需确认].
|
|
694
|
+
const source=path.join(f.binding.specsDir,f.binding.feature,'test-cases.json'),contract=JSON.parse(fs.readFileSync(source));
|
|
695
|
+
contract.cases[0].expected=['[需确认] synthetic expectation'];fs.writeFileSync(source,JSON.stringify(contract));
|
|
696
|
+
f.configuration.commands[0].caseIds=[];
|
|
697
|
+
const artifact=path.join(f.binding.specsDir,'.reviews','browser.txt');fs.writeFileSync(artifact,'Synthetic observation');
|
|
698
|
+
const executor=createHostQaExecutor({...f.configuration,logic:async()=>({verdict:'INSUFFICIENT_EVIDENCE',evidence:['Synthetic static observation']}),
|
|
699
|
+
browser:async request=>({verdict:'PASS',evidence:[artifact],environment:request.environment,cleanup:'completed'})});
|
|
700
|
+
const binding=begin(f,executor),result=await executor.run(binding,new AbortController().signal);
|
|
701
|
+
const base={...binding,logHome:f.configuration.logHome};recordCmAiQaRun({...base,phase:'complete',result});
|
|
702
|
+
assert.equal(result.result,'BLOCKED');
|
|
703
|
+
// Old executors never wrote the marker; an old host wrote the superseded row without recovery_rule.
|
|
704
|
+
fs.writeFileSync(result.report,fs.readFileSync(result.report,'utf8').replace(/,\n\s*"needsConfirmation": true/g,''));
|
|
705
|
+
const {codeProject,testRunId,mode,caseCount,...query}=binding;
|
|
706
|
+
const writer=fileURLToPath(new URL('./cm-log-event.py',import.meta.url));
|
|
707
|
+
const data={node:'N6',repository_id:binding.identity.repositoryId,feature:binding.feature,task:binding.identity.taskId,
|
|
708
|
+
package_digest:binding.packageDigest,qa_decision_id:'qa-fixture-decision',operation_id:testRunId,attempt:1,mode,case_count:caseCount,
|
|
709
|
+
previous_test_run_id:testRunId,reason:'host_evidence_problem',blocked_cases:['TC-001'],expected_environment:f.configuration.environment};
|
|
710
|
+
const written=spawnSync(process.env.CM_PYTHON_BIN||'python3',[writer,'--workflow','cm-ai','--event','test_run','--phase','superseded',
|
|
711
|
+
'--runtime','codex','--project-root',codeProject,'--specs-dir',binding.specsDir,'--run-id',binding.identity.runId,
|
|
712
|
+
'--detail','QA superseded','--data-json',JSON.stringify(data)],{encoding:'utf8',env:{...process.env,CM_WORKFLOW_LOG_HOME:f.configuration.logHome}});
|
|
713
|
+
assert.equal(written.status,0,written.stderr);
|
|
714
|
+
recordCmAiQaRun({...base,testRunId:'legacy-round-2',qaRound:2,previousTestRunId:testRunId,phase:'start'});
|
|
715
|
+
assert.equal(readCmAiQaRunRound({...query,testRunId:'legacy-round-2'}),2);
|
|
716
|
+
// The same history claimed under the current rule is refused: the contract still says [需确认].
|
|
717
|
+
const log=path.join(binding.specsDir,'运行日志.jsonl'),kept=fs.readFileSync(log,'utf8');
|
|
718
|
+
fs.writeFileSync(log,kept.split('\n').map(line=>{if(!line)return line;const row=JSON.parse(line);
|
|
719
|
+
return row.phase==='superseded'?JSON.stringify({...row,recovery_rule:2}):line;}).join('\n'));
|
|
720
|
+
assert.throws(()=>readCmAiQaRunRound({...query,testRunId:'legacy-round-2'}),{code:'qa_round_invalid'});
|
|
721
|
+
fs.writeFileSync(log,kept);assert.equal(readCmAiQaRunRound({...query,testRunId:'legacy-round-2'}),2);
|
|
722
|
+
// The original rule itself is replayed exactly: it never accepted a SUPPORTED logic case.
|
|
723
|
+
const report=fs.readFileSync(result.report,'utf8');
|
|
724
|
+
fs.writeFileSync(result.report,report.replace('"staticVerdict": "INSUFFICIENT_EVIDENCE"','"staticVerdict": "SUPPORTED"'));
|
|
725
|
+
assert.throws(()=>readCmAiQaRunRound({...query,testRunId:'legacy-round-2'}),{code:'qa_round_invalid'});
|
|
726
|
+
fs.writeFileSync(result.report,report);assert.equal(readCmAiQaRunRound({...query,testRunId:'legacy-round-2'}),2);
|
|
727
|
+
}finally{f.cleanup();}
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
// Report forgeries: the approved contract, not the report marker, decides [需确认].
|
|
731
|
+
const FORGED={'contract-resolved-after-run':'logic-confirmation-insufficient','forged-confirmation-insufficient':'logic-confirmation-insufficient',
|
|
732
|
+
'forged-confirmation-unavailable':'logic-confirmation-unavailable','forged-browser-confirmation':'needs-confirmation',
|
|
733
|
+
// No browser answer happened: a marker added to the report must not stand in for one.
|
|
734
|
+
'forged-no-capability':'no-browser-capability','forged-browser-evidence':'needs-confirmation'};
|
|
735
|
+
for(const name of ['evidence','cleanup','environment','timeout','logic','commands','product-blocked',
|
|
736
|
+
'source-drift','FAIL','mixed-failure','round-limit','incomplete','superseded-crash','one-shot','metadata-command',
|
|
737
|
+
'legacy-product-blocked','needs-confirmation','command-unavailable','command-exit','declared-command-exit','declared-product-fail',
|
|
738
|
+
'declared-contradicted','declared-after-repair','declared-superseded-crash','declared-blocked','declared-unknown-verdict',
|
|
739
|
+
'logic-confirmation-unavailable','logic-confirmation-insufficient','no-browser-capability',...Object.keys(FORGED)])
|
|
740
|
+
test(`completed BLOCKED QA explicit rerun: ${name}`,async()=>{
|
|
741
|
+
const scenario=FORGED[name]??name;
|
|
643
742
|
const {createCmAiConversationEntry}=await import('../runtime/js/cm-ai/cm-ai-conversation-entry.mjs');
|
|
644
743
|
const {inspectCmAiQaRecovery}=await import('../runtime/js/cm-ai/cm-ai-qa-log.mjs');
|
|
645
744
|
const {inspectRunClosure}=await import('./cm-log-event.mjs');
|
|
@@ -649,24 +748,62 @@ test(`completed BLOCKED QA explicit rerun: ${scenario}`,async()=>{
|
|
|
649
748
|
if(scenario==='logic')f.configuration.commands[0].caseIds=[];
|
|
650
749
|
if(scenario==='metadata-command')f.configuration.commands[0].id='deferred_cases';
|
|
651
750
|
if(scenario==='commands')f.configuration.commands=[];
|
|
751
|
+
// [需确认] keeps a case BLOCKED on every round; a rerun can never resolve it.
|
|
752
|
+
const confirmation={'needs-confirmation':1,'logic-confirmation-unavailable':0,'logic-confirmation-insufficient':0}[scenario];
|
|
753
|
+
if(confirmation!==undefined){
|
|
754
|
+
const source=path.join(f.binding.specsDir,f.binding.feature,'test-cases.json'),contract=JSON.parse(fs.readFileSync(source));
|
|
755
|
+
contract.cases[confirmation].expected=['[需确认] synthetic expectation'];fs.writeFileSync(source,JSON.stringify(contract));
|
|
756
|
+
}
|
|
757
|
+
// Environment stand-in outside both roots: killed (no exit code) or exit 65 until it is fixed.
|
|
758
|
+
const ready=path.join(f.root,'environment-ready');
|
|
759
|
+
const exits=['command-exit','declared-command-exit','declared-contradicted','declared-after-repair','declared-superseded-crash','declared-unknown-verdict'];
|
|
760
|
+
const killed=['command-unavailable','logic-confirmation-unavailable'].includes(scenario);
|
|
761
|
+
if([...(killed?[scenario]:[]),...exits].includes(scenario))f.configuration.commands[0].command=[process.execPath,'-e',
|
|
762
|
+
`require('node:fs').existsSync(${JSON.stringify(ready)})||${killed?'process.kill(process.pid,"SIGKILL")':'process.exit(65)'}`];
|
|
763
|
+
const failLike=['FAIL','declared-product-fail'].includes(scenario),contradicted=['mixed-failure','declared-contradicted'].includes(scenario);
|
|
764
|
+
const hostBlocked=['product-blocked','legacy-product-blocked'].includes(scenario);
|
|
652
765
|
let repaired=false,browserCalls=0,logicCalls=0;
|
|
653
766
|
const executor=createHostQaExecutor({...f.configuration,
|
|
654
|
-
logic:async()=>{logicCalls++;return {verdict:
|
|
655
|
-
|
|
656
|
-
browser
|
|
767
|
+
logic:async()=>{logicCalls++;return {verdict:contradicted?'CONTRADICTED':
|
|
768
|
+
['logic','logic-confirmation-insufficient'].includes(scenario)?'INSUFFICIENT_EVIDENCE':'SUPPORTED',evidence:['Synthetic static observation']};},
|
|
769
|
+
// Without a browser capability the executor itself blocks the case; no
|
|
770
|
+
// session answered it, so a rerun on the same host cannot change it.
|
|
771
|
+
...(scenario==='no-browser-capability'?{}:{browser:async request=>{
|
|
657
772
|
browserCalls++;
|
|
658
773
|
if(!repaired&&scenario==='source-drift')fs.appendFileSync(path.join(f.configuration.codeProject,'source.mjs'),'// drift\n');
|
|
659
774
|
if(!repaired&&scenario==='timeout')throw Object.assign(new Error('timeout'),{code:'host_request_timeout'});
|
|
660
|
-
return {verdict:!repaired&&
|
|
661
|
-
evidence:!repaired&&['evidence','source-drift','round-limit','incomplete','superseded-crash','one-shot','mixed-failure','metadata-command'].includes(scenario)
|
|
775
|
+
return {verdict:!repaired&&failLike?'FAIL':!repaired&&hostBlocked?'BLOCKED':'PASS',
|
|
776
|
+
evidence:!repaired&&['evidence','source-drift','round-limit','incomplete','superseded-crash','one-shot','mixed-failure','declared-contradicted','metadata-command','declared-blocked'].includes(scenario)
|
|
662
777
|
?['not-an-evidence-file']: [artifact],
|
|
663
778
|
environment:!repaired&&scenario==='environment'?{...request.environment,target:'different-target'}:request.environment,
|
|
664
779
|
cleanup:!repaired&&scenario==='cleanup'?'failed':'completed'};
|
|
665
|
-
}});
|
|
780
|
+
}})});
|
|
666
781
|
const binding=begin(f,executor),result=await executor.run(binding,new AbortController().signal);
|
|
667
782
|
const {codeProject,testRunId,mode,caseCount,...query}=binding;
|
|
668
783
|
const base={...binding,logHome:f.configuration.logHome};
|
|
669
784
|
if(scenario!=='incomplete')recordCmAiQaRun({...base,phase:'complete',result});
|
|
785
|
+
// Older executors wrote host-declared BLOCKED rows without the marker; those stay ineligible.
|
|
786
|
+
if(scenario==='legacy-product-blocked')fs.writeFileSync(result.report,
|
|
787
|
+
fs.readFileSync(result.report,'utf8').replace(/,\n\s*"hostDeclaredBlocked": true/g,''));
|
|
788
|
+
// The contract no longer says [需确认], but the run's own report does: still refused.
|
|
789
|
+
if(name==='contract-resolved-after-run'){
|
|
790
|
+
const source=path.join(f.binding.specsDir,f.binding.feature,'test-cases.json'),contract=JSON.parse(fs.readFileSync(source));
|
|
791
|
+
contract.cases[0].expected=['Synthetic expected behavior'];fs.writeFileSync(source,JSON.stringify(contract));
|
|
792
|
+
}else if(FORGED[name]){
|
|
793
|
+
const forge={'forged-confirmation-insufficient':['TC-001',row=>{delete row.needsConfirmation;}],
|
|
794
|
+
'forged-confirmation-unavailable':['TC-001',row=>{delete row.needsConfirmation;row.commandUnavailable=true;}],
|
|
795
|
+
'forged-browser-confirmation':['TC-002',row=>{row.hostDeclaredBlocked=true;}],
|
|
796
|
+
'forged-no-capability':['TC-002',row=>{row.hostDeclaredBlocked=true;}],
|
|
797
|
+
// A forged evidence problem on a [需确认] case: the contract still refuses it.
|
|
798
|
+
'forged-browser-evidence':['TC-002',row=>{row.evidenceProblem='qa_evidence_required';}]}[name];
|
|
799
|
+
const parts=fs.readFileSync(result.report,'utf8').split(/^## /m),index=parts.findIndex(part=>part.startsWith(`${forge[0]}\n`));
|
|
800
|
+
const body=parts[index].slice(forge[0].length+1),row=JSON.parse(body);forge[1](row);
|
|
801
|
+
parts[index]=`${forge[0]}\n\n${JSON.stringify(row,null,2)}${body.match(/\s*$/)[0]}`;
|
|
802
|
+
fs.writeFileSync(result.report,parts.map((part,i)=>i?`## ${part}`:part).join(''));
|
|
803
|
+
}
|
|
804
|
+
// A report row outside PASS/FAIL/BLOCKED no longer matches the recorded counts.
|
|
805
|
+
if(scenario==='declared-unknown-verdict')fs.writeFileSync(result.report,
|
|
806
|
+
fs.readFileSync(result.report,'utf8').replace(/("id": "TC-001",[\s\S]*?"verdict": )"FAIL"/,'$1"SKIPPED"'));
|
|
670
807
|
if(scenario!=='incomplete'){
|
|
671
808
|
const state=JSON.parse(fs.readFileSync(path.join(binding.specsDir,'.cm-status.json')));
|
|
672
809
|
assert.equal(state.state,result.failed?'qa_failed':'qa_blocked');assert.equal(state.node,'N6');
|
|
@@ -679,6 +816,8 @@ test(`completed BLOCKED QA explicit rerun: ${scenario}`,async()=>{
|
|
|
679
816
|
recordCmAiQaRun({...base,testRunId:`blocked-${round+1}`,qaRound:round+1,previousTestRunId:previous,phase:'start'});
|
|
680
817
|
recordCmAiQaRun({...base,testRunId:`blocked-${round+1}`,qaRound:round+1,phase:'complete',result});
|
|
681
818
|
}
|
|
819
|
+
if(scenario==='declared-superseded-crash')recordCmAiQaRun({...base,phase:'superseded',
|
|
820
|
+
expectedEnvironment:f.configuration.environment,environmentFailure:'simulator runtime was missing'});
|
|
682
821
|
if(scenario==='superseded-crash'){
|
|
683
822
|
recordCmAiQaRun({...base,phase:'superseded'});
|
|
684
823
|
assert.equal(inspectRunClosure(log,binding.identity.runId).closed,false);
|
|
@@ -694,15 +833,36 @@ test(`completed BLOCKED QA explicit rerun: ${scenario}`,async()=>{
|
|
|
694
833
|
assert.equal(without.code,scenario==='incomplete'?'qa_execution_unknown':result.failed?'qa_failed':'qa_result_blocked');
|
|
695
834
|
if(!result.failed&&scenario!=='incomplete')assert.equal(without.pendingAction,'none');
|
|
696
835
|
assert.deepEqual(fs.readFileSync(log),before);
|
|
697
|
-
|
|
698
|
-
|
|
836
|
+
if(scenario==='declared-command-exit'){
|
|
837
|
+
// The declaration only travels with the one-shot rerun grant and a superseded row.
|
|
838
|
+
for(const bad of [{qaEnvironmentFailure:'no rerun grant'},{rerunBlockedQa:true,qaEnvironmentFailure:'two\nlines'}])
|
|
839
|
+
assert.throws(()=>createCmAiConversationEntry({...options,...bad}),{code:'qa_recovery_authorization_required'});
|
|
840
|
+
assert.throws(()=>recordCmAiQaRun({...base,testRunId:'declared-start',qaRound:2,phase:'start',environmentFailure:'misplaced'}),
|
|
841
|
+
{code:'qa_recovery_authorization_required'});
|
|
842
|
+
}
|
|
843
|
+
// An accepted repair already owns the next round of that FAIL.
|
|
844
|
+
const repairedRunner=scenario==='declared-after-repair'?{runner:{...options.runner,status:()=>({...completed,
|
|
845
|
+
acceptedQaFix:{qaRound:1,testRunId,evidenceDigest:'c'.repeat(64)}})}}:{};
|
|
846
|
+
const entry=createCmAiConversationEntry({...options,...repairedRunner,rerunBlockedQa:true,
|
|
847
|
+
...(scenario.startsWith('declared-')&&scenario!=='declared-superseded-crash'?{qaEnvironmentFailure:'simulator runtime was missing'}:{})});
|
|
848
|
+
if(['commands','legacy-product-blocked','needs-confirmation','source-drift','FAIL','mixed-failure','round-limit','incomplete',
|
|
849
|
+
'command-exit','declared-product-fail','declared-contradicted','declared-after-repair','declared-blocked',
|
|
850
|
+
'declared-unknown-verdict','logic-confirmation-unavailable','logic-confirmation-insufficient','no-browser-capability'].includes(scenario)){
|
|
699
851
|
const rejected=await entry.handle(operation);
|
|
700
852
|
assert.equal(rejected.code,scenario==='round-limit'?'qa_round_invalid':scenario==='incomplete'?'qa_execution_unknown':'qa_rerun_not_blocked_by_evidence');
|
|
701
|
-
assert.deepEqual(fs.readFileSync(log),before);
|
|
853
|
+
assert.deepEqual(fs.readFileSync(log),before);
|
|
854
|
+
assert.equal(browserCalls,['needs-confirmation','no-browser-capability'].includes(scenario)?0:1);
|
|
855
|
+
if(name==='no-browser-capability'){
|
|
856
|
+
// Neither the durable log nor the report claims a host answer that never happened.
|
|
857
|
+
const row=JSON.parse(fs.readFileSync(result.report,'utf8').split(/^## /m).find(part=>part.startsWith('TC-002\n')).slice('TC-002'.length+1));
|
|
858
|
+
assert.equal(row.hostDeclaredBlocked,undefined);
|
|
859
|
+
assert.equal(rows().find(item=>item.phase==='case_blocked'&&item.case_id==='TC-002').host_declared_blocked,undefined);
|
|
860
|
+
}
|
|
702
861
|
}else{
|
|
703
862
|
const queried=await entry.handle({...operation,operation:'qa_result',packageDigest:binding.packageDigest,testRunId});
|
|
704
|
-
assert.equal(queried.pendingAction,'qa');
|
|
863
|
+
assert.equal(queried.pendingAction,result.failed?'fix_authorization':'qa');
|
|
705
864
|
repaired=scenario!=='one-shot';
|
|
865
|
+
if(['command-unavailable',...exits].includes(scenario))fs.writeFileSync(ready,'');
|
|
706
866
|
const rerun=await entry.handle(operation);
|
|
707
867
|
assert.equal(rerun.code,['logic','one-shot'].includes(scenario)?'qa_result_blocked':'qa_passed',JSON.stringify(rerun));
|
|
708
868
|
assert.equal(browserCalls,2);assert.equal(logicCalls,2);
|
|
@@ -727,6 +887,42 @@ test(`completed BLOCKED QA explicit rerun: ${scenario}`,async()=>{
|
|
|
727
887
|
fs.writeFileSync(log,corrupt.map(JSON.stringify).join('\n')+'\n');
|
|
728
888
|
assert.throws(()=>inspectCmAiQaRecovery(query,{blocked:true}));fs.writeFileSync(log,after);
|
|
729
889
|
}
|
|
890
|
+
// The passing successor re-validates its predecessor's exact report and
|
|
891
|
+
// supersession fields, so each forged detail is caught on its own.
|
|
892
|
+
const round2=starts[1].operation_id,firstReport=rows().find(row=>row.phase==='complete'&&row.operation_id===testRunId).report;
|
|
893
|
+
const precise=[];
|
|
894
|
+
if(scenario==='command-unavailable')precise.push(['report',row=>{row.exitCode=0;}],
|
|
895
|
+
['report',row=>{row.evidence=['No declared project test command'];}],
|
|
896
|
+
['log',list=>{list.find(row=>row.phase==='superseded').failed_cases=[];}],
|
|
897
|
+
// The logic case is eligible only by its own "blocked by that command" marker.
|
|
898
|
+
['report',row=>{delete row.commandUnavailable;},'TC-001'],['report',row=>{row.commandEvidence=[];},'TC-001'],
|
|
899
|
+
['report',row=>{row.needsConfirmation=true;},'TC-001'],
|
|
900
|
+
['report',row=>{row.staticVerdict='CONTRADICTED';},'TC-001'],
|
|
901
|
+
['log',list=>{list.find(row=>row.phase==='superseded').recovery_rule=3;}],
|
|
902
|
+
['contract',contract=>{contract.cases=contract.cases.filter(item=>item.id!=='TC-001');}]);
|
|
903
|
+
// The host-declared BLOCKED needs both the durable log row and the report mirror.
|
|
904
|
+
if(scenario==='product-blocked')precise.push(
|
|
905
|
+
['log',list=>{delete list.find(row=>row.phase==='case_blocked'&&row.operation_id===testRunId).host_declared_blocked;}],
|
|
906
|
+
['report',row=>{delete row.hostDeclaredBlocked;},'TC-002']);
|
|
907
|
+
if(['declared-command-exit','declared-superseded-crash'].includes(scenario))precise.push(['report',row=>{row.exitCode=null;}],
|
|
908
|
+
['report',row=>{row.exitCode=0;}],['log',list=>{list.find(row=>row.phase==='superseded').environment_failure_reason=' ';}],
|
|
909
|
+
['log',list=>{list.find(row=>row.phase==='superseded').failed_cases=['declared-test'];}],
|
|
910
|
+
['report',row=>{row.verdict='SKIPPED';},'TC-001']);
|
|
911
|
+
if(precise.length)assert.equal(inspectCmAiQaResult({...query,testRunId:round2}).status,'passed');
|
|
912
|
+
const contractFile=path.join(f.binding.specsDir,f.binding.feature,'test-cases.json'),contractBytes=fs.readFileSync(contractFile);
|
|
913
|
+
for(const [target,tamper,caseId='declared-test'] of precise){
|
|
914
|
+
const report=fs.readFileSync(firstReport,'utf8');
|
|
915
|
+
if(target==='contract'){const contract=JSON.parse(contractBytes);tamper(contract);fs.writeFileSync(contractFile,JSON.stringify(contract));}
|
|
916
|
+
else if(target==='report'){
|
|
917
|
+
const parts=report.split(/^## /m),index=parts.findIndex(part=>part.startsWith(`${caseId}\n`));
|
|
918
|
+
const body=parts[index].slice(caseId.length+1),row=JSON.parse(body);tamper(row);
|
|
919
|
+
parts[index]=`${caseId}\n\n${JSON.stringify(row,null,2)}${body.match(/\s*$/)[0]}`;
|
|
920
|
+
fs.writeFileSync(firstReport,parts.map((part,i)=>i?`## ${part}`:part).join(''));
|
|
921
|
+
}else{const corrupt=rows();tamper(corrupt);fs.writeFileSync(log,corrupt.map(JSON.stringify).join('\n')+'\n');}
|
|
922
|
+
assert.throws(()=>inspectCmAiQaResult({...query,testRunId:round2}),{code:'qa_result_invalid'},`${target} ${tamper}`);
|
|
923
|
+
fs.writeFileSync(firstReport,report);fs.writeFileSync(log,after);fs.writeFileSync(contractFile,contractBytes);
|
|
924
|
+
}
|
|
925
|
+
if(precise.length)assert.equal(inspectCmAiQaResult({...query,testRunId:round2}).status,'passed');
|
|
730
926
|
}
|
|
731
927
|
}finally{f.cleanup();}
|
|
732
928
|
});
|
|
@@ -3,6 +3,7 @@ import test from 'node:test';
|
|
|
3
3
|
import {PassThrough} from 'node:stream';
|
|
4
4
|
|
|
5
5
|
import {serveCmAiHost} from '../runtime/js/cm-ai/host-session.mjs';
|
|
6
|
+
import {needPrd} from '../runtime/js/cm-prd/validation-reason.mjs';
|
|
6
7
|
|
|
7
8
|
// Drives one request through the real JSONL transport and returns both channels.
|
|
8
9
|
async function exchange(request,handle){
|
|
@@ -37,6 +38,15 @@ test('the failing operation is named so a strict field set can be told apart', a
|
|
|
37
38
|
assert.equal(diagnostics[0].code,'invalid_input');
|
|
38
39
|
});
|
|
39
40
|
|
|
41
|
+
test('known PRD validation reason reaches operator diagnostics but not peer',async()=>{
|
|
42
|
+
const reason={field:'response.at',expected:'new Date().toISOString() form, e.g. 2026-09-08T00:00:00.000Z'};
|
|
43
|
+
const {replies,diagnostics}=await exchange({operation:'final_review',requestId:'r-prd'},()=>{
|
|
44
|
+
needPrd(false,'prd_review_timestamp_invalid',reason);
|
|
45
|
+
});
|
|
46
|
+
assert.deepEqual(replies,[{requestId:'r-prd',error:{code:'host_request_failed'}}]);
|
|
47
|
+
assert.deepEqual(diagnostics[0].reason,reason);
|
|
48
|
+
});
|
|
49
|
+
|
|
40
50
|
test('a success emits no diagnostic', async () => {
|
|
41
51
|
const {replies,diagnostics}=await exchange({operation:'status',requestId:'r3'},
|
|
42
52
|
async()=>({outcome:'reported'}));
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {readBrowserCapability} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
7
|
+
import {main as hostMain} from './cm-ai-host.mjs';
|
|
8
|
+
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
9
|
+
|
|
10
|
+
test('interactive QA capability failure names iOS simulator and the compatible flag',()=>{
|
|
11
|
+
assert.throws(()=>readBrowserCapability(undefined,['ios-simulator']),error=>{
|
|
12
|
+
assert.equal(error.code,'browser_capability_required');
|
|
13
|
+
assert.match(error.reason,/ios-simulator/);
|
|
14
|
+
assert.match(error.reason,/--browser-qa available\|unavailable/);
|
|
15
|
+
assert.match(error.reason,/interactive QA/);
|
|
16
|
+
return true;
|
|
17
|
+
});
|
|
18
|
+
assert.equal(readBrowserCapability('available',['ios-simulator']),'available');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('interactive carrier diagnostic rejects undeclared carrier text',()=>{
|
|
22
|
+
assert.throws(()=>readBrowserCapability(undefined,['/private/synthetic-secret']),{code:'invalid_arguments'});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('single-task CLI names ios-simulator before opening a host',async t=>{
|
|
26
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-ios-carrier-')));
|
|
27
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
28
|
+
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.work';
|
|
29
|
+
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
|
|
30
|
+
fs.writeFileSync(path.join(specsDir,feature,'requirements.md'),'- [AC-001]: fixture\n');
|
|
31
|
+
fs.writeFileSync(path.join(specsDir,feature,'design.md'),'# Fixture\n');
|
|
32
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: fixture\n');
|
|
33
|
+
fs.writeFileSync(path.join(specsDir,feature,'test-cases.json'),JSON.stringify({schemaVersion:'1.0',feature:'work',
|
|
34
|
+
cases:[{id:'TC-001',kind:'browser',blocking:true,origin:'user',acIds:['AC-001'],taskIds:['T-001'],
|
|
35
|
+
title:'Simulator check',preconditions:[],steps:['Open app'],expected:['App opens'],cleanup:[]}]}));
|
|
36
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],
|
|
37
|
+
specFiles:buildManifest(specsDir)}));
|
|
38
|
+
fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Fixture\n');
|
|
39
|
+
const config=path.join(root,'run.json'),workflow=path.join(root,'workflow.json');
|
|
40
|
+
fs.writeFileSync(config,JSON.stringify({version:1,specsDir,codeProject,feature,
|
|
41
|
+
identity:{repositoryId:'fixture',runId:'ios-carrier',taskId:'T-001',attempt:1},
|
|
42
|
+
scope:['target.mjs'],requirements:['requirements.md']}));
|
|
43
|
+
fs.writeFileSync(workflow,JSON.stringify({documentationPaths:[],applicableAgentFiles:[],
|
|
44
|
+
qa:{commands:[],environment:{kind:'app',carrier:'ios-simulator',target:'fixture-app',scope:'local'}}}));
|
|
45
|
+
let stderr='',stdout='';
|
|
46
|
+
const exit=await hostMain(['serve','--config',config,'--mode','create','--host-context','fixture-host',
|
|
47
|
+
'--allow-development','--workflow-config',workflow,'--allow-qa'],{
|
|
48
|
+
output:{write:text=>{stdout+=text;}},error:{write:text=>{stderr+=text;}}});
|
|
49
|
+
assert.equal(exit,1);assert.equal(stdout,'');
|
|
50
|
+
const error=JSON.parse(stderr).error;
|
|
51
|
+
assert.equal(error.code,'browser_capability_required');
|
|
52
|
+
assert.match(error.reason,/ios-simulator/);
|
|
53
|
+
});
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
7
|
+
import {CLOSEOUT_AREAS,readCloseoutReport,readCloseoutPolicy} from '../runtime/js/cm-ai/knowledge-closeout.mjs';
|
|
8
|
+
import {createCmAiConversationEntry} from '../runtime/js/cm-ai/cm-ai-conversation-entry.mjs';
|
|
9
|
+
import {recordCmAiQaDecision} from '../runtime/js/cm-ai/cm-ai-qa-log.mjs';
|
|
10
|
+
import {openControlRun,runConfigMaterial} from './cm-ai-run.mjs';
|
|
11
|
+
import {openTaskExecutionStore} from '../runtime/js/cm-ai/task-owner.mjs';
|
|
12
|
+
import {createCmAiHost} from '../runtime/js/cm-ai/host.mjs';
|
|
13
|
+
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
14
|
+
|
|
15
|
+
const identity={repositoryId:'closeout',runId:'closeout-run',taskId:'T-001',attempt:1};
|
|
16
|
+
const policy={version:1,enabled:true},packageDigest='8'.repeat(64);
|
|
17
|
+
const report=()=>({version:1,items:CLOSEOUT_AREAS.map(area=>({area,
|
|
18
|
+
status:area==='memory'?'out_of_scope':area==='runtime'?'not_applicable':'checked',
|
|
19
|
+
evidence:['README.md'],detail:area==='memory'?'Personal memory is outside this run':'Controlled fixture evidence'}))});
|
|
20
|
+
const op=operation=>({version:1,operation,requestId:operation,identity,packageDigest,testRunId:null});
|
|
21
|
+
async function fixture(fn,{pending=false}={}){
|
|
22
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-closeout-'))),specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.fixture';
|
|
23
|
+
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
|
|
24
|
+
fs.writeFileSync(path.join(codeProject,'README.md'),'# Fixture\n');
|
|
25
|
+
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
|
|
26
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),`- [${pending?' ':'x'}] T-001: fixture\n`);
|
|
27
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
|
|
28
|
+
const current={state:'fixture_completed',code:null,identity,packageDigest};let effects=0;
|
|
29
|
+
const runner={status:()=>current,executeEffect:()=>{effects++;throw Error('unexpected effect');},run:async()=>current,cancel:()=>current};
|
|
30
|
+
const entry=extra=>createCmAiConversationEntry({specsDir,codeProject,feature,identity,runner,applicableAgentFiles:[],knowledgeCloseout:policy,...extra});
|
|
31
|
+
const seedQa=()=>recordCmAiQaDecision({specsDir,codeProject,feature,identity,packageDigest,logHome:path.join(root,'logs'),
|
|
32
|
+
decision:{decisionId:'old-qa-skip',identity,packageDigest,status:'skipped',reason:'Historical fixture',score:4,at:'2026-09-04T22:00:00Z'}});
|
|
33
|
+
const response=(request,extra={})=>({syncId:request.syncId,identity:request.identity,packageDigest:request.packageDigest,
|
|
34
|
+
contextDigest:request.contextDigest,status:'completed',reason:'Required docs verified in fixture',at:'2026-10-04T12:00:00Z',...extra});
|
|
35
|
+
const stateFile=path.join(specsDir,'.reviews','.execution',identity.runId,'state.json');
|
|
36
|
+
const definition={version:1,specsDir,codeProject,feature,identity,scope:['README.md'],requirements:[]};
|
|
37
|
+
const execution=(enabled)=>({configuration:{kind:'synthetic-host-v1',...(enabled===undefined?{}:{workflow:{knowledgeCloseout:enabled}})},timeoutMs:1000,
|
|
38
|
+
excludedContexts:['main'],hostDecision:null,check:()=>[],applicableAgentFiles:[],documentationProvider:{timeoutMs:1000,inspect:async()=>{throw Error('unexpected inspection');}},
|
|
39
|
+
developer:{provider:'codex',requestedModel:'fixture',contextId:'author',run:async()=>{throw Error('unexpected dispatch');}},
|
|
40
|
+
reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:'fixture',allowed:true,available:true,
|
|
41
|
+
contexts:['review-1','review-2'],run:async()=>{throw Error('unexpected review');}}],
|
|
42
|
+
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['main'],hostContextId:'main',authorize:async()=>{throw Error('unexpected grant');}}});
|
|
43
|
+
try{return await fn({root,specsDir,codeProject,feature,definition,entry,seedQa,response,stateFile,execution,effects:()=>effects});}
|
|
44
|
+
finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
45
|
+
}
|
|
46
|
+
test('six-face report requires evidence and distinguishes denied reads and scope',()=>{
|
|
47
|
+
assert.deepEqual(readCloseoutReport(report()),report());
|
|
48
|
+
const denied=report();denied.items[2]={area:'documentation',status:'unverified',evidence:[],detail:'README.md: EACCES; not read'};
|
|
49
|
+
assert.equal(readCloseoutReport(denied).items[2].status,'unverified');
|
|
50
|
+
for(const mutation of [r=>r.items.pop(),r=>r.items[1].area='code',r=>r.items[0].evidence=[],
|
|
51
|
+
r=>r.items[0].status='passed',r=>r.items[0].grant=true,r=>r.version=2]){
|
|
52
|
+
const value=report();mutation(value);assert.throws(()=>readCloseoutReport(value));
|
|
53
|
+
}
|
|
54
|
+
assert.throws(()=>readCloseoutPolicy({version:2,enabled:true}),{code:'closeout_policy_unsupported'});
|
|
55
|
+
});
|
|
56
|
+
test('one inspection reports six faces; repeated finish/finalize deduplicates without writes to reviewed files',()=>fixture(async f=>{
|
|
57
|
+
f.seedQa();let calls=0;const before=fs.readFileSync(path.join(f.codeProject,'README.md'));
|
|
58
|
+
const entry=f.entry({documentationProvider:{timeoutMs:1000,inspect:async request=>{
|
|
59
|
+
calls++;assert.deepEqual(request.closeout,policy);return f.response(request,{closeout:report()});}}});
|
|
60
|
+
const finished=await entry.handle(op('finish'));assert.equal(finished.code,'documentation_synced');
|
|
61
|
+
assert.equal(finished.knowledgeCloseout.status,'reported');assert.equal(finished.knowledgeCloseout.items.length,6);
|
|
62
|
+
const final=await entry.handle(op('run_finalize'));assert.equal(final.state,'run_done');
|
|
63
|
+
assert.deepEqual(final.knowledgeCloseout,finished.knowledgeCloseout);
|
|
64
|
+
assert.equal((await entry.handle(op('run_finalize'))).deduplicated,true);assert.equal(calls,1);assert.equal(f.effects(),0);
|
|
65
|
+
assert.deepEqual(fs.readFileSync(path.join(f.codeProject,'README.md')),before);
|
|
66
|
+
}));
|
|
67
|
+
test('legacy answer on enabled run is explicitly not_completed and does not replace mandatory documentation block',()=>fixture(async f=>{
|
|
68
|
+
f.seedQa();let blocked=true;
|
|
69
|
+
const entry=f.entry({documentationProvider:{timeoutMs:1000,inspect:async request=>f.response(request,{status:blocked?'blocked':'completed'})}});
|
|
70
|
+
const first=await entry.handle(op('run_finalize'));assert.equal(first.code,'documentation_sync_blocked');
|
|
71
|
+
assert.equal(first.knowledgeCloseout.status,'not_completed');assert(!fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').includes('run_done'));
|
|
72
|
+
blocked=false;const second=await entry.handle(op('run_finalize'));assert.equal(second.state,'run_done');
|
|
73
|
+
assert.equal(second.knowledgeCloseout.status,'not_completed');assert.equal(second.knowledgeCloseout.reason,'report_not_provided');
|
|
74
|
+
}));
|
|
75
|
+
test('explicit OFF still performs mandatory inspection and records disabled',()=>fixture(async f=>{
|
|
76
|
+
f.seedQa();let calls=0;
|
|
77
|
+
const entry=f.entry({knowledgeCloseout:{version:1,enabled:false},documentationProvider:{timeoutMs:1000,inspect:async request=>{
|
|
78
|
+
calls++;assert.equal(request.closeout.enabled,false);return f.response(request);}}});
|
|
79
|
+
const result=await entry.handle(op('run_finalize'));assert.equal(result.state,'run_done');
|
|
80
|
+
assert.equal(result.knowledgeCloseout.status,'disabled');assert.equal(calls,1);
|
|
81
|
+
}));
|
|
82
|
+
for(const kind of ['timeout','cancel','failure','stale','drift','invalid_report'])
|
|
83
|
+
test(`inspection ${kind} cannot write run_done or accept a late report`,()=>fixture(async f=>{
|
|
84
|
+
f.seedQa();let resolve,entered;const started=new Promise(r=>entered=r);
|
|
85
|
+
const entry=f.entry({documentationProvider:{timeoutMs:kind==='timeout'?20:1000,inspect:async request=>{
|
|
86
|
+
entered();if(['timeout','cancel'].includes(kind))return new Promise(r=>resolve=()=>r(f.response(request,{closeout:report()})));
|
|
87
|
+
if(kind==='failure')throw Object.assign(Error('read denied'),{code:'EACCES'});
|
|
88
|
+
if(kind==='drift')fs.appendFileSync(path.join(f.specsDir,f.feature,'design.md'),'Changed after request\n');
|
|
89
|
+
const value=f.response(request,{closeout:report()});
|
|
90
|
+
if(kind==='stale')value.syncId='old-report';if(kind==='invalid_report')value.closeout.items[0].evidence=[];
|
|
91
|
+
return value;
|
|
92
|
+
}}});
|
|
93
|
+
const work=entry.handle(op('run_finalize'));await started;
|
|
94
|
+
if(kind==='cancel')await entry.handle({version:1,operation:'cancel',requestId:'cancel',identity});
|
|
95
|
+
const result=await work;assert.equal(result.outcome,'rejected',JSON.stringify(result));
|
|
96
|
+
assert.equal(result.knowledgeCloseout.status,'not_completed');assert.equal(f.effects(),0);
|
|
97
|
+
if(resolve){resolve();await new Promise(r=>setImmediate(r));}
|
|
98
|
+
assert(!fs.readFileSync(path.join(f.specsDir,'运行日志.jsonl'),'utf8').includes('run_done'));
|
|
99
|
+
}));
|
|
100
|
+
test('concurrent inspection is refused; restart inspects again under the original deduplicated finalizer',()=>fixture(async f=>{
|
|
101
|
+
f.seedQa();let release,request,entered;const started=new Promise(r=>entered=r);let calls=0;
|
|
102
|
+
const provider={timeoutMs:1000,inspect:async r=>{calls++;request=r;entered();return new Promise(resolve=>release=resolve);}};
|
|
103
|
+
const entry=f.entry({documentationProvider:provider});const active=entry.handle(op('finish'));await started;
|
|
104
|
+
assert.equal((await entry.handle(op('finish'))).code,'documentation_pending');release(f.response(request,{closeout:report()}));await active;
|
|
105
|
+
const first=await entry.handle(op('run_finalize'));assert.equal(first.state,'run_done');
|
|
106
|
+
const reopened=f.entry({documentationProvider:{timeoutMs:1000,inspect:async r=>{calls++;return f.response(r,{closeout:report()});}}});
|
|
107
|
+
assert.equal((await reopened.handle(op('run_finalize'))).deduplicated,true);assert.equal(calls,2);
|
|
108
|
+
}));
|
|
109
|
+
for(const enabled of [undefined,false])
|
|
110
|
+
test(`real store freezes create policy ${enabled===undefined?'default ON':'explicit OFF'} and refuses change`,()=>fixture(async f=>{
|
|
111
|
+
let run=await openControlRun(f.definition,'create',f.execution(enabled));run.close();
|
|
112
|
+
const before=fs.readFileSync(f.stateFile),snapshot=JSON.parse(before),saved=snapshot.records[0].payload.config.knowledgeCloseout;
|
|
113
|
+
assert.deepEqual(saved,{version:1,enabled:enabled!==false});
|
|
114
|
+
run=await openControlRun(f.definition,'resume',f.execution(enabled));run.close();assert.deepEqual(fs.readFileSync(f.stateFile),before);
|
|
115
|
+
await assert.rejects(openControlRun(f.definition,'resume',f.execution(enabled===false?true:false)),{code:'closeout_policy_changed'});
|
|
116
|
+
assert.deepEqual(fs.readFileSync(f.stateFile),before);
|
|
117
|
+
},{pending:true}));
|
|
118
|
+
test('real legacy init without closeout resumes byte-identically; explicit activation cannot migrate it',()=>fixture(async f=>{
|
|
119
|
+
const execution=f.execution(),material=runConfigMaterial(f.definition,execution);
|
|
120
|
+
const store=openTaskExecutionStore({tasksPath:path.join(f.specsDir,f.feature,'tasks.md'),feature:'fixture',specsRoot:f.specsDir,
|
|
121
|
+
identity:{repositoryId:identity.repositoryId,runId:identity.runId},create:true,
|
|
122
|
+
fingerprints:{workflow:digest('cm-ai-host-execution-v1'),config:digest(material),inputs:digest({feature:f.feature,task:identity.taskId})}});
|
|
123
|
+
try{createCmAiHost({runner:{root:f.codeProject,identity,scope:f.definition.scope,requirements:[],specification:{specsRoot:f.specsDir,feature:f.feature},
|
|
124
|
+
excludedContexts:execution.excludedContexts,developer:execution.developer,reviewers:execution.reviewers,reviewInvocation:execution.reviewInvocation,
|
|
125
|
+
check:()=>[],timeoutMs:1000,taskCompletion:{reviewsDir:path.join(f.specsDir,'.reviews'),handoffs:[1,2].map(n=>path.join(f.specsDir,'.reviews',`fixture-T-001-a${n}-handoff.json`))},
|
|
126
|
+
taskLearning:{feature:f.feature,hostHandoff:true},persistence:{store,mode:'create',version:3}},entry:{specsDir:f.specsDir,codeProject:f.codeProject,
|
|
127
|
+
feature:f.feature,identity,hostDecision:null,applicableAgentFiles:[],documentationProvider:execution.documentationProvider}});}finally{store.close();}
|
|
128
|
+
const before=fs.readFileSync(f.stateFile);assert(!Object.hasOwn(JSON.parse(before).records[0].payload.config,'knowledgeCloseout'));
|
|
129
|
+
const resumed=await openControlRun(f.definition,'resume',execution);resumed.close();assert.deepEqual(fs.readFileSync(f.stateFile),before);
|
|
130
|
+
await assert.rejects(openControlRun(f.definition,'resume',f.execution(true)),{code:'closeout_policy_changed'});
|
|
131
|
+
assert.deepEqual(fs.readFileSync(f.stateFile),before);
|
|
132
|
+
},{pending:true}));
|
|
133
|
+
for(const saved of [policy,{version:1,enabled:false},null])
|
|
134
|
+
test(`empty original initializer selects only its original fingerprint: ${saved?.enabled??'legacy'}`,()=>fixture(async f=>{
|
|
135
|
+
const execution=f.execution(),material=runConfigMaterial(f.definition,execution,{knowledgeCloseout:saved});
|
|
136
|
+
const store=openTaskExecutionStore({tasksPath:path.join(f.specsDir,f.feature,'tasks.md'),feature:'fixture',specsRoot:f.specsDir,
|
|
137
|
+
identity:{repositoryId:identity.repositoryId,runId:identity.runId},create:true,
|
|
138
|
+
fingerprints:{workflow:digest('cm-ai-host-execution-v1'),config:digest(material),inputs:digest({feature:f.feature,task:identity.taskId})}});store.close();
|
|
139
|
+
const run=await openControlRun(f.definition,'resume',execution);run.close();
|
|
140
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(f.stateFile)).records[0].payload.config.knowledgeCloseout??null,saved);
|
|
141
|
+
},{pending:true}));
|
|
142
|
+
|
|
143
|
+
for(const mutation of ['unsupported-version','stripped-policy','changed-boolean'])
|
|
144
|
+
test(`resume refuses ${mutation} without falling back or changing evidence`,()=>fixture(async f=>{
|
|
145
|
+
const run=await openControlRun(f.definition,'create',f.execution());run.close();
|
|
146
|
+
const snapshot=JSON.parse(fs.readFileSync(f.stateFile));
|
|
147
|
+
const config=snapshot.records[0].payload.config;
|
|
148
|
+
if(mutation==='unsupported-version')config.knowledgeCloseout.version=2;
|
|
149
|
+
if(mutation==='stripped-policy')delete config.knowledgeCloseout;
|
|
150
|
+
if(mutation==='changed-boolean')config.knowledgeCloseout.enabled=false;
|
|
151
|
+
// Even a fully recomputed journal hash chain cannot authorize a different
|
|
152
|
+
// policy than the original configuration fingerprint.
|
|
153
|
+
let previousDigest=null;
|
|
154
|
+
for(const row of snapshot.records){row.previousDigest=previousDigest;const {digest:checksum,...body}=row;row.digest=digest(body);previousDigest=row.digest;}
|
|
155
|
+
const {revision,...body}=snapshot;snapshot.revision=digest(body);
|
|
156
|
+
fs.writeFileSync(f.stateFile,JSON.stringify(snapshot)+'\n');const before=fs.readFileSync(f.stateFile);
|
|
157
|
+
await assert.rejects(openControlRun(f.definition,'resume',f.execution()),error=>
|
|
158
|
+
error.code===(mutation==='unsupported-version'?'closeout_policy_unsupported':'fingerprint_mismatch'));
|
|
159
|
+
assert.deepEqual(fs.readFileSync(f.stateFile),before);
|
|
160
|
+
},{pending:true}));
|