@aibyzero/cm-workflow 0.16.8 → 0.17.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/CHANGELOG.md +31 -0
- package/README.md +22 -3
- package/VERSION +1 -1
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/cm-control-policy-v2.md +331 -0
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +3 -3
- package/docs/human-correction.md +5 -5
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +119 -78
- package/docs/next-steps.md +19 -2
- package/docs/untested-branches.md +2 -3
- package/docs/user-guide.md +105 -5
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +103 -68
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +79 -27
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/control-policy.mjs +111 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +11 -8
- package/runtime/js/cm-ai/drive-core.mjs +9 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +883 -69
- package/runtime/js/cm-ai/effect-abandon-log.mjs +5 -2
- package/runtime/js/cm-ai/effect-contract.mjs +6 -1
- package/runtime/js/cm-ai/external-run-guard.mjs +18 -7
- package/runtime/js/cm-ai/gate-bridge.mjs +4 -4
- package/runtime/js/cm-ai/host-check.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +33 -24
- package/runtime/js/cm-ai/host-documentation.mjs +53 -12
- package/runtime/js/cm-ai/host-project-execution.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +49 -4
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +53 -9
- package/runtime/js/cm-ai/host-qa-policy.mjs +63 -21
- package/runtime/js/cm-ai/host-review-authority.mjs +2 -2
- package/runtime/js/cm-ai/host-review-file.mjs +1 -1
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-tool-bridge.mjs +43 -3
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +21 -10
- package/runtime/js/cm-ai/host.mjs +1 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +89 -3
- package/runtime/js/cm-ai/provider-review-observation.mjs +50 -0
- package/runtime/js/cm-ai/qa-resource-release.mjs +46 -0
- package/runtime/js/cm-ai/qa-round-budget.mjs +13 -0
- package/runtime/js/cm-ai/review-package.mjs +26 -5
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +1 -1
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
- package/runtime/js/cm-ai/task-commit.mjs +39 -0
- package/runtime/js/cm-ai/task-runner.mjs +629 -121
- package/runtime/js/cm-ai/worker-claude-developer.mjs +9 -0
- package/runtime/js/cm-ai/worker-claude.mjs +10 -3
- package/runtime/js/cm-ai/worker-process-identity.mjs +43 -0
- package/runtime/js/cm-fix/execution.mjs +176 -48
- package/runtime/js/cm-fix/host.mjs +2 -1
- package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
- package/runtime/js/cm-fix/progress.mjs +13 -3
- package/runtime/js/cm-fix/protected-edits.mjs +10 -3
- package/runtime/js/cm-fix/repair.mjs +11 -3
- package/runtime/js/cm-fix/test-author.mjs +10 -3
- package/runtime/js/cm-idea/session.mjs +67 -4
- package/runtime/js/cm-init/review-evidence.mjs +3 -1
- package/runtime/js/cm-prd/review-correction.mjs +10 -4
- package/runtime/js/cm-prd/review-host.mjs +1 -1
- package/runtime/js/cm-prd/review-publication.mjs +5 -3
- package/runtime/js/cm-prd/session.mjs +43 -0
- package/runtime/js/cm-refactor/records.mjs +98 -8
- package/runtime/js/cm-refactor/workflow.mjs +80 -10
- package/runtime/js/cm-test/host.mjs +10 -3
- package/runtime/js/cm-test/session.mjs +45 -6
- package/runtime/js/notify-safe-read.mjs +49 -0
- package/runtime/js/notify-send.mjs +313 -0
- package/runtime/js/notify.mjs +164 -37
- package/runtime/js/policy-binding-compat.mjs +55 -0
- package/runtime/review.md +52 -7
- package/runtime/task-gates.md +107 -9
- package/scripts/ci-test-shards.mjs +67 -0
- package/scripts/ci-test-shards.test.mjs +64 -0
- package/scripts/ci-test-weights.json +222 -0
- package/scripts/cm-ai-abandon-effect-position.test.mjs +71 -10
- package/scripts/cm-ai-answer-gap-dispatch.test.mjs +86 -0
- package/scripts/cm-ai-answer-gap-driver.test.mjs +51 -0
- package/scripts/cm-ai-answer-gap-fixture.mjs +89 -0
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +70 -0
- package/scripts/cm-ai-answer-gap-redo.test.mjs +103 -0
- package/scripts/cm-ai-batch-drive.mjs +98 -34
- package/scripts/cm-ai-batch-drive.test.mjs +124 -16
- package/scripts/cm-ai-batch-host.mjs +167 -29
- package/scripts/cm-ai-batch-host.test.mjs +303 -31
- package/scripts/cm-ai-batch-run-fixture.mjs +452 -0
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +26 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +7 -0
- package/scripts/cm-ai-batch-run-reschedule.test.mjs +17 -0
- package/scripts/cm-ai-batch-run.mjs +213 -25
- package/scripts/cm-ai-batch-run.test.mjs +21 -341
- package/scripts/cm-ai-bootstrap-flow.test.mjs +1 -7
- package/scripts/cm-ai-bootstrap.test.mjs +2 -3
- package/scripts/cm-ai-control-launch.test.mjs +219 -0
- package/scripts/cm-ai-control-policy.test.mjs +124 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +270 -0
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +97 -0
- package/scripts/cm-ai-develop-call-timeout.test.mjs +146 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +37 -23
- package/scripts/cm-ai-direct-review.test.mjs +348 -0
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +54 -25
- package/scripts/cm-ai-drive.mjs +142 -58
- package/scripts/cm-ai-drive.test.mjs +70 -84
- package/scripts/cm-ai-fix-integration.test.mjs +3 -5
- package/scripts/cm-ai-fix-later-delivery.test.mjs +3 -6
- package/scripts/cm-ai-fix-run-delivery.test.mjs +3 -6
- package/scripts/cm-ai-host-cli-workflow.test.mjs +267 -0
- package/scripts/cm-ai-host-fixture.mjs +296 -0
- package/scripts/cm-ai-host-protected.test.mjs +253 -0
- package/scripts/cm-ai-host.mjs +122 -100
- package/scripts/cm-ai-host.test.mjs +35 -776
- package/scripts/cm-ai-launch-diagnostics.test.mjs +5 -3
- package/scripts/cm-ai-legacy-history.test.mjs +53 -0
- package/scripts/cm-ai-light-modules.test.mjs +54 -0
- package/scripts/cm-ai-multi-root.test.mjs +4 -4
- package/scripts/cm-ai-nested-execution.test.mjs +16 -19
- package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
- package/scripts/cm-ai-progress.test.mjs +10 -8
- package/scripts/cm-ai-project-qa-gate.test.mjs +37 -10
- package/scripts/cm-ai-protected-scope.test.mjs +8 -5
- package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +1 -9
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +12 -9
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +95 -13
- package/scripts/cm-ai-qa-fixed-log.test.mjs +41 -0
- package/scripts/cm-ai-qa-recovery-args.test.mjs +7 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +59 -14
- package/scripts/cm-ai-review-drift-precedence.test.mjs +1 -1
- package/scripts/cm-ai-review-failure.test.mjs +137 -32
- package/scripts/cm-ai-review-timeout-config.test.mjs +3 -1
- package/scripts/cm-ai-review-timeout.test.mjs +132 -67
- package/scripts/cm-ai-run.mjs +91 -28
- package/scripts/cm-ai-run.test.mjs +11 -38
- package/scripts/cm-ai-selection-guard.test.mjs +2 -2
- package/scripts/cm-ai-session-chain.test.mjs +18 -15
- package/scripts/cm-ai-spec-rebind.test.mjs +14 -18
- package/scripts/cm-ai-supersede.test.mjs +489 -51
- package/scripts/cm-blocked-reason.test.mjs +2 -3
- package/scripts/cm-capability-gate.test.mjs +33 -1
- package/scripts/cm-check-drive-files.mjs +8 -0
- package/scripts/cm-check-drive.test.mjs +2 -5
- package/scripts/cm-check-runtime.sh +4 -2
- package/scripts/cm-claude-developer-worker.test.mjs +15 -0
- package/scripts/cm-claude-review-stream.test.mjs +21 -16
- package/scripts/cm-claude-review-synthetic.test.mjs +155 -0
- package/scripts/cm-claude-worker.test.mjs +23 -5
- package/scripts/cm-controlled-correction.test.mjs +469 -0
- package/scripts/cm-external-batch-host.test.mjs +30 -11
- package/scripts/cm-external-model-host.test.mjs +1 -1
- package/scripts/cm-external-model-recovery.test.mjs +32 -12
- package/scripts/cm-external-qa-fix.test.mjs +1 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +6 -24
- package/scripts/cm-fix-abandon.test.mjs +163 -10
- package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
- package/scripts/cm-fix-drive.mjs +25 -7
- package/scripts/cm-fix-host.mjs +8 -7
- package/scripts/cm-fix-review-budget.test.mjs +13 -0
- package/scripts/cm-fix-review-recovery.test.mjs +36 -1
- package/scripts/cm-host-answer-timeout.test.mjs +65 -0
- package/scripts/cm-host-call-kinds.test.mjs +28 -0
- package/scripts/cm-host-documentation.test.mjs +49 -0
- package/scripts/cm-host-qa-executor.test.mjs +23 -12
- package/scripts/cm-host-qa-policy.test.mjs +43 -16
- package/scripts/cm-host-review-authority.test.mjs +0 -31
- package/scripts/cm-idea-answer-gaps.test.mjs +164 -0
- package/scripts/cm-idea-drive.mjs +49 -11
- package/scripts/cm-idea-drive.test.mjs +66 -0
- package/scripts/cm-idea-host.mjs +106 -16
- package/scripts/cm-init-answer-gaps.test.mjs +258 -0
- package/scripts/cm-init-drive.mjs +41 -7
- package/scripts/cm-init-host.mjs +61 -12
- package/scripts/cm-knowledge-closeout.test.mjs +3 -3
- package/scripts/cm-log-event.mjs +21 -10
- package/scripts/cm-notify-command.test.mjs +936 -0
- package/scripts/cm-notify-read-drift.test.mjs +270 -0
- package/scripts/cm-notify.mjs +481 -0
- package/scripts/cm-notify.test.mjs +312 -23
- package/scripts/cm-patrol.test.mjs +3 -2
- package/scripts/cm-prd-answer-gaps.test.mjs +216 -0
- package/scripts/cm-prd-drive.mjs +18 -5
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +37 -4
- package/scripts/cm-prd-review-disposition.test.mjs +6 -1
- package/scripts/cm-prd-review-gate.mjs +56 -0
- package/scripts/cm-refactor-answer-gaps.test.mjs +206 -0
- package/scripts/cm-refactor-drive.mjs +52 -8
- package/scripts/cm-refactor-drive.test.mjs +44 -0
- package/scripts/cm-refactor-host.test.mjs +10 -6
- package/scripts/cm-release-smoke.sh +2 -0
- package/scripts/cm-task-gate-correction.test.mjs +69 -16
- package/scripts/cm-task-gate.mjs +368 -34
- package/scripts/cm-task-gate.py +2 -0
- package/scripts/cm-task-gate.test.mjs +252 -4
- package/scripts/cm-test-answer-gaps.test.mjs +151 -0
- package/scripts/cm-test-drive.mjs +21 -5
- package/scripts/fixtures/bootstrap-review-runner.mjs +1 -7
- package/scripts/fixtures/claude-review-process.mjs +1 -1
- package/scripts/fixtures/native-gate-fixture.mjs +18 -0
- package/scripts/policy-binding-compat.test.mjs +103 -0
- package/scripts/scan-public-safety.py +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/SKILL.md +8 -6
- package/skills/cm-ai/references/N3-execute-task.md +17 -2
- package/skills/cm-ai/references/N4-review.md +11 -21
- package/skills/cm-ai/references/N5-mark-done.md +1 -1
- package/skills/cm-ai/references/N6-qa-eval.md +49 -21
- package/skills/cm-ai/references/js-host-modes.md +35 -14
- package/skills/cm-ai/references/js-host-qa-recovery.md +85 -11
- package/skills/cm-ai/references/js-host-recovery.md +181 -21
- package/skills/cm-ai/references/js-host.md +76 -32
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/SKILL.md +12 -0
- package/skills/cm-fix/references/js-host.md +44 -5
- package/skills/cm-idea/references/js-host.md +27 -2
- package/skills/cm-init/references/js-host.md +17 -4
- package/skills/cm-notify/SKILL.md +34 -0
- package/skills/cm-prd/references/js-change-recovery.md +35 -1
- package/skills/cm-prd/references/js-host.md +1 -1
- package/skills/cm-refactor/SKILL.md +12 -0
- package/skills/cm-refactor/references/js-host.md +17 -0
- package/skills/cm-test/references/js-host.md +14 -1
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
2
1
|
import test from 'node:test';
|
|
3
2
|
import assert from 'node:assert/strict';
|
|
4
3
|
import fs from 'node:fs';
|
|
5
4
|
import os from 'node:os';
|
|
6
|
-
import {spawnSync} from 'node:child_process';
|
|
7
|
-
import {createParallelMemberQaDecisionProvider} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
8
5
|
import path from 'node:path';
|
|
9
|
-
import {createCmAiBatch,taskCommitArgs} from './cm-ai-batch-run.mjs';
|
|
10
|
-
import {
|
|
11
|
-
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
12
|
-
import {reviewPaths} from '../runtime/js/cm-ai/review-runner.mjs';
|
|
13
|
-
import {createHostQaDecisionProvider} from '../runtime/js/cm-ai/host-qa-policy.mjs';
|
|
14
|
-
import {createHostQaExecutor} from '../runtime/js/cm-ai/host-qa-executor.mjs';
|
|
6
|
+
import {createCmAiBatch,taskCommitArgs,memberRescheduleAllowed,memberRunHistory} from './cm-ai-batch-run.mjs';
|
|
7
|
+
import {batchFixture} from './cm-ai-batch-run-fixture.mjs';
|
|
15
8
|
|
|
16
9
|
for(const mode of ['continuous','qa-resume','failed-qa','cancel','learning','policy','executor'])
|
|
17
10
|
test(`real multi-task runner keeps QA and recovery authoritative: ${mode}`,()=>batchFixture(mode));
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
// Q24/Q25: a strict-batch parallel member that can still recover in its own run stops
|
|
13
|
+
// with the batch operation named; the batch forwards develop_redo to it and continues.
|
|
14
|
+
// Review round 1 (blocker): an unresolved unknown member of a strict batch is never
|
|
15
|
+
// rescheduled into a second generation; it stays in its run with an explicit stop.
|
|
16
|
+
// Round-2 review: the host projects a raw unknown whose redo budget is spent as
|
|
17
|
+
// blocked/develop_redo_limit with pendingAction none. The reschedule decision reads
|
|
18
|
+
// the raw journal, so that member stays in its original run.
|
|
19
|
+
test('reschedule needs a raw checkpointed blocked state, never a projection over a raw unknown',()=>{
|
|
20
|
+
const projected={state:'blocked',code:'develop_redo_limit',pendingAction:'none'};
|
|
21
|
+
assert.equal(memberRescheduleAllowed(projected,{state:{state:'unknown',code:'call_timeout'},pending:null}),false);
|
|
22
|
+
assert.equal(memberRescheduleAllowed(projected,null),false);
|
|
23
|
+
assert.equal(memberRescheduleAllowed({state:'blocked',code:'failed',pendingAction:'none'},{state:{state:'blocked',code:'failed'},pending:{id:'develop-1'}}),false);
|
|
24
|
+
assert.equal(memberRescheduleAllowed({state:'blocked',code:'review_transport_timeout',pendingAction:'abandon_review',reviewRedispatchStopRequired:true},
|
|
25
|
+
{state:{state:'blocked',code:'review_transport_timeout'},pending:null}),false);
|
|
26
|
+
assert.equal(memberRescheduleAllowed({state:'unknown',code:'reconciliation_required',pendingAction:'reconcile'},{state:{state:'unknown'},pending:null}),false);
|
|
27
|
+
assert.equal(memberRescheduleAllowed({state:'blocked',code:'failed',pendingAction:'none'},{state:{state:'blocked',code:'failed'},pending:null}),true);
|
|
28
|
+
const missing=fs.mkdtempSync(path.join(os.tmpdir(),'cm-batch-history-'));
|
|
29
|
+
try{assert.equal(memberRunHistory(missing,'no-such-run'),null);}finally{fs.rmSync(missing,{recursive:true,force:true});}
|
|
30
30
|
});
|
|
31
|
-
|
|
32
|
-
test('a batch member whose reviewer failed without a verdict resumes its one review retry',()=>batchFixture('review-provider-retry'));
|
|
33
|
-
test('a parallel member whose reviewer failed without a verdict resumes its one review retry',()=>batchFixture('parallel-review-provider-retry'));
|
|
31
|
+
|
|
34
32
|
test('dirty batch entry lists files and creates no member worktrees',()=>batchFixture('parallel-dirty'));
|
|
35
33
|
test('a parallel member whose scope file already exists on HEAD is refused before any worktree',()=>batchFixture('parallel-existing'));
|
|
36
34
|
|
|
@@ -82,321 +80,3 @@ test('task commit subjects are single-line and bounded while bodies preserve des
|
|
|
82
80
|
assert.deepEqual(taskCommitArgs('T-001',description,'failed'),['-m','WIP T-001: blocked (failed)','-m',description]);
|
|
83
81
|
}
|
|
84
82
|
});
|
|
85
|
-
|
|
86
|
-
async function batchFixture(mode,options={}){
|
|
87
|
-
const parallel=mode.startsWith('parallel');
|
|
88
|
-
const recovery=mode==='parallel-recovery',blockedIds=options.blockedIds??['T-002'];
|
|
89
|
-
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-batch-')));
|
|
90
|
-
try{
|
|
91
|
-
const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.work';
|
|
92
|
-
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
|
|
93
|
-
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
|
|
94
|
-
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: first\n- [ ] T-002: second\n'+(parallel?'- [ ] T-003: final\n\n- T-003 依赖 T-001, T-002\n':''));
|
|
95
|
-
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
|
|
96
|
-
fs.writeFileSync(path.join(codeProject,'requirements.md'),'# Fixture\n');
|
|
97
|
-
const git=(cwd,args)=>{const result=spawnSync('git',['-C',cwd,...args],{encoding:'utf8'});assert.equal(result.status,0,result.stderr);return result.stdout.trim();};
|
|
98
|
-
{git(codeProject,['init','-b','main']);git(codeProject,['config','user.name','Fixture']);git(codeProject,['config','user.email','fixture@example.invalid']);
|
|
99
|
-
fs.writeFileSync(path.join(codeProject,parallel?'base.js':'file0.js'),'base\n');git(codeProject,['add','-A']);git(codeProject,['commit','-m','fixture baseline']);}
|
|
100
|
-
const config={version:1,repositoryId:'batch-fixture',batchId:'batch-fixture',specsDir,codeProject,
|
|
101
|
-
...(parallel?{parallel:[[`${feature}/T-001`,`${feature}/T-002`]]}:{}),
|
|
102
|
-
tasks:(parallel?['T-001','T-002','T-003']:['T-001','T-002']).map((taskId,index)=>({feature,taskId,scope:[`file${index}.js`],requirements:['requirements.md']}))};
|
|
103
|
-
const calls=[],qaCalls=[],assessments=[],blockedEvidence=[],checkCalls=new Map();let qaReady=mode!=='qa-resume',started;
|
|
104
|
-
const began=new Promise(resolve=>{started=resolve;});
|
|
105
|
-
let conflictHead=null,interrupted=false,reviewFailed=false;
|
|
106
|
-
const executionFor=async(definition,{parallelMember=false}={})=>({configuration:{kind:'batch-fixture-v1',...(parallelMember?{parallelMember:true}:{})},timeoutMs:3000,
|
|
107
|
-
excludedContexts:['host'],hostDecision:{status:'approved'},applicableAgentFiles:[],
|
|
108
|
-
developer:{provider:'codex',requestedModel:'fixture',contextId:'author',run:createCodexDeveloperRun({requestedModel:'fixture',
|
|
109
|
-
worker:async({prompt},{signal})=>{
|
|
110
|
-
const data=JSON.parse(prompt.split('<cm-developer-data-json>\n')[1]),material=data.specification;
|
|
111
|
-
assert.equal(material.task.id,definition.identity.taskId);
|
|
112
|
-
assert.deepEqual(material.sources,buildManifest(specsDir));
|
|
113
|
-
if(recovery&&!parallelMember&&blockedIds.includes(definition.identity.taskId)){
|
|
114
|
-
const key=`${feature}/${definition.identity.taskId}`;
|
|
115
|
-
assert.equal(definition.codeProject,codeProject);
|
|
116
|
-
assert.equal(definition.identity.runId,`task-${digest({batchId:config.batchId,task:key,generation:2}).slice(0,48)}`);
|
|
117
|
-
const rows=fs.readFileSync(path.join(specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
118
|
-
const blocked=rows.find(row=>row.phase==='batch_member_blocked'&&row.from_key===key);
|
|
119
|
-
const expectedReason=options.withReason?'Expected stub throws; waiting for peer':'failed';
|
|
120
|
-
assert(blocked);assert.equal(blocked.generation,2);assert.equal(blocked.code,'failed');
|
|
121
|
-
assert(!fs.existsSync(blocked.worktree));
|
|
122
|
-
assert.match(git(codeProject,['log','-1','--format=%s',blocked.branch]),/^WIP .*: blocked \(failed\)$/);
|
|
123
|
-
blockedEvidence.push({reason:blocked.reason,body:git(codeProject,['log','-1','--format=%b',blocked.branch]),
|
|
124
|
-
expectedReason,description:definition.identity.taskId==='T-001'?'first':'second'});
|
|
125
|
-
assert.equal(git(codeProject,['show',`${blocked.branch}:${definition.scope[0]}`]),'implemented');
|
|
126
|
-
for(const id of ['T-001','T-002'].filter(id=>!blockedIds.includes(id))){
|
|
127
|
-
const merged=rows.find(row=>row.phase==='batch_handoff'&&row.from_key===`${feature}/${id}`);
|
|
128
|
-
assert(merged);assert(rows.indexOf(merged)<rows.indexOf(blocked));
|
|
129
|
-
assert.equal(fs.readFileSync(path.join(codeProject,config.tasks.find(task=>task.taskId===id).scope[0]),'utf8'),'implemented\n');
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
// A second attempt must change the rejected bytes (develop_unchanged_after_review).
|
|
133
|
-
calls.push(definition.identity.taskId);fs.writeFileSync(path.join(definition.codeProject,definition.scope[0]),
|
|
134
|
-
data.identity.attempt===1?'implemented\n':'implemented again\n');
|
|
135
|
-
if(recovery&&blockedIds.includes(definition.identity.taskId)&&(parallelMember||options.terminalAgain))
|
|
136
|
-
return {status:'succeeded',value:{outcome:'blocked',...(options.withReason?{reason:'Expected stub throws; waiting for peer'}:{})}};
|
|
137
|
-
if(parallel&&definition.identity.taskId==='T-002')await new Promise(resolve=>setTimeout(resolve,50));
|
|
138
|
-
if(mode==='parallel-conflict'&&definition.identity.taskId==='T-002'){
|
|
139
|
-
fs.writeFileSync(path.join(codeProject,'file0.js'),'main conflict\n');git(codeProject,['add','file0.js']);git(codeProject,['commit','-m','concurrent main change']);conflictHead=git(codeProject,['rev-parse','HEAD']);
|
|
140
|
-
}
|
|
141
|
-
if(mode==='cancel'){started();await new Promise(resolve=>signal.addEventListener('abort',resolve,{once:true}));}
|
|
142
|
-
const application={status:'no_relevant_lesson',note:null};
|
|
143
|
-
let retrospective={status:'no_new_lesson',candidates:[],reason:null};
|
|
144
|
-
if(mode==='learning'&&definition.identity.taskId==='T-001')retrospective={status:'lesson_candidate',reason:null,
|
|
145
|
-
candidates:[{classification:'structured',trigger:'Synthetic task input requires explicit validation',
|
|
146
|
-
action:'Read the validated input before writing the next fixture',evidence:['file0.js']}]};
|
|
147
|
-
if(mode==='learning'&&definition.identity.taskId==='T-002'){
|
|
148
|
-
const source=fs.readFileSync(path.join(codeProject,'AGENTS.md'),'utf8');
|
|
149
|
-
assert(source.includes('Synthetic task input requires explicit validation'));
|
|
150
|
-
assert(prompt.includes('AGENTS.md'));
|
|
151
|
-
application.status='applied';application.note='Read and applied the T-001 synthetic input-validation lesson from AGENTS.md';
|
|
152
|
-
}
|
|
153
|
-
return {status:'succeeded',value:{outcome:'implemented',application,retrospective}};
|
|
154
|
-
}})},
|
|
155
|
-
check:async()=>{
|
|
156
|
-
const key=definition.identity.taskId,count=(checkCalls.get(key)??0)+1;checkCalls.set(key,count);
|
|
157
|
-
const failed=parallelMember&&key==='T-002'
|
|
158
|
-
&&(mode==='parallel-completion-retry'&&count===2||mode==='parallel-develop-check-retry'&&count===1);
|
|
159
|
-
return [{id:'fixture',command:['fixture'],outcome:failed?'failed':'passed',exitCode:failed?1:0,
|
|
160
|
-
evidence:failed?'Synthetic transient failure':'Synthetic task check'}];
|
|
161
|
-
},
|
|
162
|
-
reviewers:[{id:'reviewer',adapterId:'codex-review-adapter',provider:'codex',requestedModel:'fixture',allowed:true,available:true,
|
|
163
|
-
contexts:['review-1','review-2'],run:(request,{onEvent})=>{
|
|
164
|
-
assert.equal(request.payload.reviewPackage.specification.task.id,definition.identity.taskId);
|
|
165
|
-
assert.deepEqual(request.payload.reviewPackage.specification.sources,buildManifest(specsDir));
|
|
166
|
-
if(mode==='learning'&&request.identity.taskId==='T-001')
|
|
167
|
-
assert(request.payload.reviewPackage.changes.some(change=>change.path==='AGENTS.md'));
|
|
168
|
-
if(mode.endsWith('review-provider-retry')&&request.identity.taskId==='T-001'&&!reviewFailed){
|
|
169
|
-
reviewFailed=true;
|
|
170
|
-
// Claude CLI rate limit: no tool call, no verdict, process exited.
|
|
171
|
-
for(const event of [{event:'thread.started',provider_thread:'review-rate-limited'},{event:'turn.started',item_type:null},
|
|
172
|
-
{event:'process_closed',exit_code:1,signal:null,timed_out:false}])onEvent(event);
|
|
173
|
-
return {status:'failed',code:'reviewer_rate_limited'};
|
|
174
|
-
}
|
|
175
|
-
for(const event of [{event:'thread.started',provider_thread:`review-${request.identity.taskId}`},
|
|
176
|
-
{event:'turn.started',item_type:null},{event:'item.completed',item_type:'agent_message'},
|
|
177
|
-
{event:'turn.completed',item_type:null},{event:'process_closed',exit_code:0,signal:null,timed_out:false}])onEvent(event);
|
|
178
|
-
const retry=mode==='parallel-retry'&&request.identity.taskId==='T-001'&&request.identity.attempt===1;
|
|
179
|
-
return {status:'succeeded',value:{verdict:retry?'changes_requested':'approved',packageDigest:request.payload.reviewPackage.packageDigest,
|
|
180
|
-
examinedPaths:reviewPaths(request.payload.reviewPackage),findings:retry?[{id:'F1',severity:'P2',path:'file0.js',message:'Synthetic repair',evidence:'First implementation'}]:[],summary:'Synthetic independent review'}};
|
|
181
|
-
}}],
|
|
182
|
-
reviewInvocation:{developerThreadId:'author',excludedThreadIds:['host'],authorize:(request,{authorizationAt})=>{
|
|
183
|
-
const body={version:1,kind:'cm-review-dispatch-grant',grantId:'grant',adapterId:'codex-review-adapter',
|
|
184
|
-
invocationId:request.invocationId,requestDigest:request.requestDigest,identity:request.identity,reviewerId:'reviewer',
|
|
185
|
-
logicalContextId:request.contextId,packageDigest:request.payload.reviewPackage.packageDigest,hostContextId:'host',
|
|
186
|
-
decisionId:'decision',decision:'approved',issuedAt:authorizationAt,expiresAt:authorizationAt+60000};
|
|
187
|
-
return {...body,grantDigest:digest(body)};
|
|
188
|
-
}},
|
|
189
|
-
qaDecisionProvider:parallelMember?createParallelMemberQaDecisionProvider():mode==='policy'?createHostQaDecisionProvider({timeoutMs:1000,assess:async binding=>{
|
|
190
|
-
assessments.push(binding.identity.taskId);
|
|
191
|
-
return {scores:{scope:1,risk:1,accumulation:1,boundary:1},
|
|
192
|
-
changes:{api:binding.identity.taskId==='T-001',migration:false,authentication:false,authorization:false,payment:false}};
|
|
193
|
-
}}):{timeoutMs:1000,decide:async binding=>{
|
|
194
|
-
if(!qaReady)throw Object.assign(new Error('await QA decision'),{code:'qa_decision_required'});
|
|
195
|
-
const skip=binding.identity.taskId==='T-001'&&mode!=='failed-qa';
|
|
196
|
-
return {decisionId:`qa-${binding.identity.taskId}`,identity:binding.identity,packageDigest:binding.packageDigest,
|
|
197
|
-
status:skip?'skipped':'triggered',reason:'synthetic',score:skip?4:null,at:'2026-09-08T01:00:00Z'};
|
|
198
|
-
}},
|
|
199
|
-
qaExecutor:mode==='executor'?(()=>{
|
|
200
|
-
const executor=createHostQaExecutor({specsDir,codeProject,feature,runtime:'codex',requirements:definition.requirements,
|
|
201
|
-
commands:[{id:'fixture-command',command:[process.execPath,'-e',
|
|
202
|
-
"require('node:assert/strict').equal(require('node:fs').readFileSync(process.argv[1],'utf8'),'implemented\\n')",
|
|
203
|
-
definition.scope[0]],caseIds:[]}],environment:{kind:'web',carrier:'browser',target:'fixture-command-only',scope:'local'},
|
|
204
|
-
timeoutMs:5000,logHome:path.join(root,'logs')});
|
|
205
|
-
return {...executor,run:(binding,signal)=>{qaCalls.push(binding.identity.taskId);return executor.run(binding,signal);}};
|
|
206
|
-
})():{mode:'commands',caseCount:1,timeoutMs:1000,run:async binding=>{
|
|
207
|
-
qaCalls.push(binding.identity.taskId);
|
|
208
|
-
const report=path.join(specsDir,'.reviews',`${binding.testRunId}.md`);fs.writeFileSync(report,'# Synthetic QA\n');
|
|
209
|
-
const fail=mode==='failed-qa';return {result:fail?'FAIL':'PASS',passed:fail?0:1,failed:fail?1:0,blocked:0,report};
|
|
210
|
-
}},
|
|
211
|
-
documentationProvider:{timeoutMs:1000,inspect:async binding=>({syncId:binding.syncId,identity:binding.identity,
|
|
212
|
-
packageDigest:binding.packageDigest,contextDigest:binding.contextDigest,status:'completed',reason:'Synthetic docs',at:'2026-09-08T01:00:00Z'})},
|
|
213
|
-
});
|
|
214
|
-
const open=()=>createCmAiBatch({configuration:config,executionFor,logHome:path.join(root,'logs')});
|
|
215
|
-
if(mode==='parallel-existing'){
|
|
216
|
-
// T-002's scope file is committed on HEAD, so it is an edit, not a new file.
|
|
217
|
-
fs.writeFileSync(path.join(codeProject,'file1.js'),'existing\n');git(codeProject,['add','file1.js']);git(codeProject,['commit','-m','existing file']);
|
|
218
|
-
await assert.rejects(open().handle({operation:'advance',requestId:'existing'}),error=>error.code==='parallel_scope_existing_file');
|
|
219
|
-
assert.deepEqual(calls,[]);assert(!fs.existsSync(path.join(root,'.cm-worktrees')));
|
|
220
|
-
assert.equal(git(codeProject,['status','--porcelain']),'');return;
|
|
221
|
-
}
|
|
222
|
-
if(mode==='parallel-dirty'){
|
|
223
|
-
fs.writeFileSync(path.join(codeProject,'dirty.txt'),'user-owned\n');
|
|
224
|
-
const result=await open().handle({operation:'advance',requestId:'dirty'});
|
|
225
|
-
assert.equal(result.code,'batch_main_dirty');assert.match(result.reason,/dirty\.txt/);assert.deepEqual(result.files,['?? dirty.txt']);
|
|
226
|
-
assert.deepEqual(calls,[]);assert(!fs.existsSync(path.join(root,'.cm-worktrees')));
|
|
227
|
-
assert(!fs.existsSync(path.join(specsDir,'运行日志.jsonl')));
|
|
228
|
-
assert.equal(git(codeProject,['status','--porcelain']),'?? dirty.txt');return;
|
|
229
|
-
}
|
|
230
|
-
const originalRead=fs.readFileSync,originalExists=fs.existsSync;
|
|
231
|
-
if(recovery&&options.crashAt)fs.existsSync=function(file,...args){
|
|
232
|
-
if(!interrupted&&(options.crashAt==='serial'?String(file).endsWith('state.json'):String(file).endsWith('T-002'))){
|
|
233
|
-
const logfile=path.join(specsDir,'运行日志.jsonl');
|
|
234
|
-
if(originalExists(logfile)&&originalRead(logfile,'utf8').split('\n').filter(Boolean).map(JSON.parse).some(row=>row.phase==='batch_member_blocked')){
|
|
235
|
-
interrupted=true;throw Object.assign(new Error('simulated interrupt'),{code:'simulated_interrupt'});
|
|
236
|
-
}
|
|
237
|
-
}return originalExists.call(fs,file,...args);
|
|
238
|
-
};
|
|
239
|
-
if(mode==='parallel-resume'||mode==='final-commit')fs.existsSync=function(file,...args){
|
|
240
|
-
if(!interrupted&&String(file).endsWith('state.json')){
|
|
241
|
-
const logfile=path.join(specsDir,'运行日志.jsonl');
|
|
242
|
-
if(originalExists(logfile)&&originalRead(logfile,'utf8').split('\n').filter(Boolean).map(JSON.parse).some(row=>row.phase==='batch_handoff')){
|
|
243
|
-
interrupted=true;throw Object.assign(new Error('simulated interrupt'),{code:'simulated_interrupt'});
|
|
244
|
-
}
|
|
245
|
-
}return originalExists.call(fs,file,...args);
|
|
246
|
-
};
|
|
247
|
-
const batch=open(),pending=batch.handle({operation:'advance',requestId:'advance-1'});
|
|
248
|
-
if(mode==='cancel'){
|
|
249
|
-
await began;await batch.handle({operation:'cancel',requestId:'cancel'});
|
|
250
|
-
assert.equal((await pending).code,'cancelled');
|
|
251
|
-
assert.equal((await open().handle({operation:'advance',requestId:'resume'})).code,'cancelled');
|
|
252
|
-
assert.deepEqual(calls,['T-001']);return;
|
|
253
|
-
}
|
|
254
|
-
let result;
|
|
255
|
-
try{result=await pending;}catch(error){if(!(mode==='parallel-resume'||mode==='final-commit'||recovery&&options.crashAt)||error.code!=='simulated_interrupt')throw error;}finally{fs.existsSync=originalExists;}
|
|
256
|
-
if(mode==='final-commit'){
|
|
257
|
-
assert(interrupted);
|
|
258
|
-
const logfile=path.join(specsDir,'运行日志.jsonl');
|
|
259
|
-
const rows=fs.readFileSync(logfile,'utf8').trim().split('\n').map(JSON.parse);
|
|
260
|
-
const commit=rows.find(row=>row.phase==='batch_task_committed');assert(commit);
|
|
261
|
-
// Restore the crash prefix before handoff; the next task has not started.
|
|
262
|
-
fs.writeFileSync(logfile,rows.filter(row=>row.phase!=='batch_handoff').map(row=>JSON.stringify(row)+'\n').join(''));
|
|
263
|
-
result=await open().handle({operation:'advance',requestId:'resume-commit-prefix'});
|
|
264
|
-
const recovered=fs.readFileSync(logfile,'utf8').trim().split('\n').map(JSON.parse);
|
|
265
|
-
assert.equal(recovered.find(row=>row.phase==='batch_handoff').task_commit,commit.task_commit);
|
|
266
|
-
}
|
|
267
|
-
if(mode==='parallel-completion-retry'){
|
|
268
|
-
assert.equal(result.code,'completion_checks_changed',JSON.stringify(result));
|
|
269
|
-
const logfile=path.join(specsDir,'运行日志.jsonl');
|
|
270
|
-
let rows=fs.readFileSync(logfile,'utf8').trim().split('\n').map(JSON.parse);
|
|
271
|
-
assert.equal(rows.filter(row=>row.phase==='batch_member_blocked').length,0);
|
|
272
|
-
assert(fs.existsSync(path.join(root,'.cm-worktrees',config.batchId.slice(0,8),'T-002')));
|
|
273
|
-
result=await open().handle({operation:'advance',requestId:'retry-completion'});
|
|
274
|
-
assert.equal(result.code,'run_done',JSON.stringify(result));
|
|
275
|
-
rows=fs.readFileSync(logfile,'utf8').trim().split('\n').map(JSON.parse);
|
|
276
|
-
assert.equal(rows.filter(row=>row.phase==='batch_member_blocked').length,0);
|
|
277
|
-
assert.equal(checkCalls.get('T-002'),3);
|
|
278
|
-
assert.deepEqual(calls,['T-001','T-002','T-003']);
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
if(mode==='parallel-develop-check-retry'){
|
|
282
|
-
assert.equal(result.code,'develop_checks_not_passed',JSON.stringify(result));
|
|
283
|
-
const logfile=path.join(specsDir,'运行日志.jsonl');
|
|
284
|
-
let rows=fs.readFileSync(logfile,'utf8').trim().split('\n').map(JSON.parse);
|
|
285
|
-
assert.equal(rows.filter(row=>row.phase==='batch_member_blocked').length,0);
|
|
286
|
-
result=await open().handle({operation:'advance',requestId:'retry-develop-check'});
|
|
287
|
-
assert.equal(result.code,'run_done',JSON.stringify(result));
|
|
288
|
-
rows=fs.readFileSync(logfile,'utf8').trim().split('\n').map(JSON.parse);
|
|
289
|
-
assert.equal(rows.filter(row=>row.phase==='batch_member_blocked').length,0);
|
|
290
|
-
assert.equal(checkCalls.get('T-002'),3);
|
|
291
|
-
assert.equal(calls.filter(task=>task==='T-002').length,2);
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
if(recovery&&options.crashAt){assert(interrupted);result=await open().handle({operation:'advance',requestId:'resume-recovery'});}
|
|
295
|
-
if(recovery){
|
|
296
|
-
// Assert outside the worker: worker exceptions intentionally become unknown terminals.
|
|
297
|
-
assert(blockedEvidence.length>0);
|
|
298
|
-
for(const evidence of blockedEvidence){
|
|
299
|
-
assert.equal(evidence.reason,evidence.expectedReason);
|
|
300
|
-
assert.equal(evidence.body,evidence.description+'\n\n'+evidence.expectedReason);
|
|
301
|
-
}
|
|
302
|
-
assert.equal(result.code,options.terminalAgain?'failed':'run_done',JSON.stringify(result));
|
|
303
|
-
const before=[...calls];
|
|
304
|
-
const resumed=await open().handle({operation:'advance',requestId:'resume-recovery-done'});
|
|
305
|
-
assert.equal(resumed.code,result.code);assert.deepEqual(calls,before);
|
|
306
|
-
const rows=fs.readFileSync(path.join(specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
307
|
-
assert.equal(rows.filter(row=>row.phase==='batch_member_blocked').length,blockedIds.length);
|
|
308
|
-
for(const id of blockedIds){
|
|
309
|
-
assert.equal(calls.filter(task=>task===id).length,2);
|
|
310
|
-
const key=`${feature}/${id}`,row=rows.find(row=>row.phase==='batch_handoff'&&row.from_key===key);
|
|
311
|
-
if(options.terminalAgain){assert.equal(row,undefined);continue;}
|
|
312
|
-
assert.match(row.task_commit,/^[a-f0-9]{40}$/);
|
|
313
|
-
assert.equal(git(codeProject,['show',`${row.task_commit}:${config.tasks.find(task=>task.taskId===id).scope[0]}`]),'implemented');
|
|
314
|
-
assert.equal(git(codeProject,['show','-s','--format=%s',row.task_commit]),`${id}: ${id==='T-001'?'first':'second'}`);
|
|
315
|
-
const runId=`task-${digest({batchId:config.batchId,task:key,generation:2}).slice(0,48)}`;
|
|
316
|
-
const state=JSON.parse(fs.readFileSync(path.join(specsDir,'.reviews','.execution',runId,'state.json'),'utf8'));
|
|
317
|
-
assert.equal(state.revision,row.checkpoint);
|
|
318
|
-
}
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
if(mode==='parallel-resume'){assert(interrupted);const before=[...calls];result=await open().handle({operation:'advance',requestId:'resume-parallel'});assert.deepEqual(calls.slice(0,before.length),before);}
|
|
322
|
-
if(mode==='parallel-conflict'){
|
|
323
|
-
assert.equal(result.code,'merge_conflict',JSON.stringify(result));assert.equal(git(codeProject,['rev-parse','HEAD']),conflictHead);
|
|
324
|
-
for(const task of ['T-001','T-002'])assert(fs.existsSync(path.join(root,'.cm-worktrees',config.batchId.slice(0,8),task)));
|
|
325
|
-
// Kept member branches are namespaced per batch, so a later batch of the same
|
|
326
|
-
// tasks does not collide with the WIP branches this one leaves behind.
|
|
327
|
-
const segment=config.batchId.slice(0,8).replace(/\./g,'-');
|
|
328
|
-
const heads=git(codeProject,['for-each-ref','--format=%(refname:short)','refs/heads/cm']).split('\n').filter(Boolean);
|
|
329
|
-
assert.deepEqual(heads.sort(),[`cm/${segment}/work/T-001`,`cm/${segment}/work/T-002`]);
|
|
330
|
-
for(const name of heads)git(codeProject,['check-ref-format','--branch',name]);
|
|
331
|
-
for(const task of ['T-001','T-002'])assert.throws(()=>git(codeProject,['rev-parse','--verify',`refs/heads/cm/work/${task}`]));
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
if(mode.endsWith('review-provider-retry')){
|
|
335
|
-
assert.equal(result.state,'pending_review',JSON.stringify(result));assert.equal(result.code,'review_provider_failed');
|
|
336
|
-
assert.match(result.reason,/^reviewer_rate_limited: /);assert.deepEqual(calls,parallel?['T-001','T-002']:['T-001']);
|
|
337
|
-
result=await open().handle({operation:'advance',requestId:'retry-review'});
|
|
338
|
-
}
|
|
339
|
-
if(mode==='qa-resume'){
|
|
340
|
-
assert.equal(result.code,'qa_decision_required');assert.deepEqual(calls,['T-001']);
|
|
341
|
-
assert(fs.readFileSync(path.join(specsDir,feature,'tasks.md'),'utf8').includes('[x] T-001'));
|
|
342
|
-
const changed=structuredClone(config);changed.tasks[1].scope=['other.js'];
|
|
343
|
-
await assert.rejects(createCmAiBatch({configuration:changed,executionFor,logHome:path.join(root,'logs')})
|
|
344
|
-
.handle({operation:'advance',requestId:'changed-plan'}),{code:'batch_plan_mismatch'});
|
|
345
|
-
qaReady=true;result=await open().handle({operation:'advance',requestId:'advance-2'});
|
|
346
|
-
}
|
|
347
|
-
assert.equal(result.code,mode==='failed-qa'?'qa_failed':'run_done',JSON.stringify(result));
|
|
348
|
-
assert.deepEqual(calls,parallel?(mode==='parallel-retry'?['T-001','T-002','T-001','T-003']:['T-001','T-002','T-003']):mode==='failed-qa'?['T-001']:['T-001','T-002']);
|
|
349
|
-
if(parallel){
|
|
350
|
-
const rows=fs.readFileSync(path.join(specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
351
|
-
const ready=rows.filter(row=>row.phase==='batch_member_ready'),handoffs=rows.filter(row=>row.phase==='batch_handoff');
|
|
352
|
-
assert.equal(ready.length,2);assert.equal(handoffs.length,2);assert.deepEqual(handoffs.map(row=>row.from_key),ready.map(row=>row.from_key));
|
|
353
|
-
assert(handoffs.every(row=>/^[a-f0-9]{40}$/.test(row.merge_commit)&&row.post_merge_check==='skipped'));
|
|
354
|
-
assert.equal(rows.filter(row=>row.event==='qa'&&row.reason==='parallel_member_deferred'&&row.status==='skipped').length,2);
|
|
355
|
-
assert.deepEqual(qaCalls,['T-003']);
|
|
356
|
-
assert(fs.readFileSync(path.join(specsDir,feature,'tasks.md'),'utf8').includes('[x] T-003'));
|
|
357
|
-
assert.equal(git(codeProject,['branch','--show-current']),'main');
|
|
358
|
-
}
|
|
359
|
-
if(mode==='learning'){
|
|
360
|
-
const handoff=JSON.parse(fs.readFileSync(path.join(specsDir,'.reviews','work-T-002-a1-handoff.json'),'utf8'));
|
|
361
|
-
assert(handoff.evidence.some(item=>typeof item==='string'&&item.includes('"status":"applied"')));
|
|
362
|
-
}
|
|
363
|
-
if(mode==='final-commit'){
|
|
364
|
-
const rows=fs.readFileSync(path.join(specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
365
|
-
const commits=rows.filter(row=>row.phase==='batch_task_committed');
|
|
366
|
-
assert.deepEqual(commits.map(row=>row.from_key),[`${feature}/T-001`,`${feature}/T-002`]);
|
|
367
|
-
assert(rows.indexOf(commits[0])<rows.findIndex(row=>row.phase==='batch_handoff'));
|
|
368
|
-
assert.equal(result.task_commit,commits[1].task_commit);
|
|
369
|
-
assert.equal(result.task_commit,git(codeProject,['rev-parse','HEAD']));
|
|
370
|
-
assert.equal(git(codeProject,['show','-s','--format=%s',result.task_commit]),'T-002: second');
|
|
371
|
-
assert.equal(git(codeProject,['show','-s','--format=%b',result.task_commit]),'second');
|
|
372
|
-
assert.equal(git(codeProject,['show',`${result.task_commit}:file1.js`]),'implemented');
|
|
373
|
-
assert.equal(git(codeProject,['status','--porcelain']),'');
|
|
374
|
-
const resumedFinal=await open().handle({operation:'advance',requestId:'resume-final-commit'});
|
|
375
|
-
assert.equal(resumedFinal.code,result.code);assert.equal(resumedFinal.task_commit,result.task_commit);
|
|
376
|
-
assert.equal(fs.readFileSync(path.join(specsDir,'运行日志.jsonl'),'utf8').trim().split('\n')
|
|
377
|
-
.map(JSON.parse).filter(row=>row.phase==='batch_task_committed').length,2);
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
const before=[...calls],qaBefore=[...qaCalls];
|
|
381
|
-
const resumed=await open().handle({operation:'advance',requestId:'resume'});
|
|
382
|
-
assert.equal(resumed.code,result.code);assert.deepEqual(calls,before);assert.deepEqual(qaCalls,qaBefore);
|
|
383
|
-
if(mode==='final-commit'){
|
|
384
|
-
const rows=fs.readFileSync(path.join(specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
385
|
-
const commit=rows.find(row=>row.phase==='batch_task_committed');
|
|
386
|
-
assert.equal(rows.find(row=>row.phase==='batch_handoff').task_commit,commit.task_commit);
|
|
387
|
-
assert.equal(git(codeProject,['status','--porcelain']),'');
|
|
388
|
-
}
|
|
389
|
-
if(mode==='executor'){
|
|
390
|
-
assert.deepEqual(qaCalls,['T-002']);
|
|
391
|
-
const reports=fs.readdirSync(path.join(specsDir,'.reviews')).filter(name=>name.endsWith('-execution.md'));
|
|
392
|
-
assert.equal(reports.length,1);assert(fs.readFileSync(path.join(specsDir,'.reviews',reports[0]),'utf8').includes('host check exited 0'));
|
|
393
|
-
}
|
|
394
|
-
if(mode==='policy'){
|
|
395
|
-
assert.deepEqual(assessments,['T-001','T-002']);assert.deepEqual(qaCalls,['T-002']);
|
|
396
|
-
const log=fs.readFileSync(path.join(specsDir,'运行日志.jsonl'),'utf8').trim().split('\n').map(JSON.parse);
|
|
397
|
-
assert(log.some(row=>row.event==='qa'&&row.task==='T-001'&&row.reason==='merged_to_feature_qa'));
|
|
398
|
-
assert.equal(log.filter(row=>row.event==='decision'&&row.phase==='qa_merge'&&row.task==='T-001').length,1);
|
|
399
|
-
assert(log.some(row=>row.event==='qa'&&row.task==='T-002'&&row.reason==='feature_complete'));
|
|
400
|
-
}
|
|
401
|
-
}finally{fs.rmSync(root,{recursive:true,force:true});}
|
|
402
|
-
}
|
|
@@ -85,13 +85,7 @@ function open(f,taskId,mode='create',overrides={}){
|
|
|
85
85
|
return {status:'succeeded',value:{verdict:revise?'changes_requested':'approved',packageDigest:request.payload.reviewPackage.packageDigest,
|
|
86
86
|
examinedPaths:reviewPaths(request.payload.reviewPackage),findings:revise?[{id:'F1',severity:'P2',path:'AGENTS.md',
|
|
87
87
|
message:'Reverify instruction applicability',evidence:'Synthetic revision fixture'}]:[],summary:'Synthetic independent review'}};}}],
|
|
88
|
-
reviewInvocation:{developerThreadId:'scaffold-author',excludedThreadIds:['main'],
|
|
89
|
-
const body={version:1,kind:'cm-review-dispatch-grant',grantId:'grant-'+request.identity.attempt,adapterId:'codex-review-adapter',
|
|
90
|
-
invocationId:request.invocationId,requestDigest:request.requestDigest,identity:request.identity,reviewerId:'reviewer',
|
|
91
|
-
logicalContextId:request.contextId,packageDigest:request.payload.reviewPackage.packageDigest,hostContextId:'main',
|
|
92
|
-
decisionId:'decision-'+request.identity.attempt,decision:'approved',issuedAt:authorizationAt,expiresAt:authorizationAt+60000};
|
|
93
|
-
return {...body,grantDigest:digest(body)};
|
|
94
|
-
}},
|
|
88
|
+
reviewInvocation:{developerThreadId:'scaffold-author',excludedThreadIds:['main']},
|
|
95
89
|
check:createHostCheck({cwd:f.codeProject,timeoutMs:1000,commands:[{id:'syntax',command:[process.execPath,'--check','app.mjs']}]}),
|
|
96
90
|
taskCompletion:{reviewsDir:path.join(f.specsDir,'.reviews'),handoffs:[1,2].map(a=>path.join(f.specsDir,'.reviews',`bootstrap-${taskId}-a${a}-handoff.json`))},
|
|
97
91
|
persistence:{store,mode,version:3}});
|
|
@@ -43,7 +43,7 @@ function prepareCli(f){
|
|
|
43
43
|
for(const [name,value] of Object.entries(files))fs.writeFileSync(path.join(f.root,name+'.json'),JSON.stringify(value));
|
|
44
44
|
return {cli,env,args:['serve','--config',config,'--mode','create','--host-context','bootstrap-current-host','--allow-development',
|
|
45
45
|
'--protected-conversation-config',path.join(f.root,'protection.json'),'--bootstrap-config',path.join(f.root,'bootstrap.json'),
|
|
46
|
-
'--allow-bootstrap-write','--review-config',path.join(f.root,'review.json'),
|
|
46
|
+
'--allow-bootstrap-write','--review-config',path.join(f.root,'review.json'),
|
|
47
47
|
'--workflow-config',path.join(f.root,'workflow.json'),'--allow-qa']};
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -67,8 +67,7 @@ function runCli(f,config,mode,operation){
|
|
|
67
67
|
if(['init_generate','init_verify'].includes(row.kind)){assert(mode==='create'||f.resumeInit);
|
|
68
68
|
response=reply(f,row.kind,row.payload);
|
|
69
69
|
if(row.kind==='init_verify'&&f.failVerify>0){f.failVerify--;response.checks.commands={status:'failed',evidence:'npm test exited 1'};}}
|
|
70
|
-
else if(row.kind==='qa_assess')response={
|
|
71
|
-
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}};
|
|
70
|
+
else if(row.kind==='qa_assess')response={confirmed:true};
|
|
72
71
|
else if(row.kind==='documentation_inspect'){
|
|
73
72
|
const {syncId,identity,packageDigest,contextDigest}=row.payload;
|
|
74
73
|
response={syncId,identity,packageDigest,contextDigest,status:'completed',reason:'Fixture instructions inspected; no documentation paths configured',
|