@aibyzero/cm-workflow 0.21.6 → 0.25.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 +58 -0
- package/README.md +18 -3
- package/VERSION +1 -1
- package/docs/architecture.md +9 -0
- package/docs/cm-acceptance-completion.md +3 -1
- package/docs/cm-control-policy-v2.md +35 -3
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +1 -0
- package/docs/human-correction.md +1 -1
- package/docs/installation.md +42 -16
- package/docs/js-workflow-control.md +65 -30
- package/docs/next-steps.md +10 -0
- package/docs/runtime-failover.md +5 -3
- package/docs/user-guide.md +6 -6
- package/package.json +1 -1
- package/runtime/js/cm-ai/batch-location.mjs +14 -0
- package/runtime/js/cm-ai/batch-plan.mjs +6 -2
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +9 -2
- package/runtime/js/cm-ai/cm-ai-admission.mjs +9 -3
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +51 -8
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +30 -4
- package/runtime/js/cm-ai/codex-review-adapter.mjs +2 -4
- package/runtime/js/cm-ai/delivery-evidence.mjs +3 -1
- package/runtime/js/cm-ai/developer-adapter.mjs +15 -1
- package/runtime/js/cm-ai/drive-core.mjs +50 -6
- package/runtime/js/cm-ai/drive-next-step.mjs +61 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +85 -23
- package/runtime/js/cm-ai/execution-snapshot.mjs +5 -2
- package/runtime/js/cm-ai/execution-store.mjs +21 -3
- package/runtime/js/cm-ai/external-run-guard.mjs +9 -1
- package/runtime/js/cm-ai/host-check.mjs +4 -2
- package/runtime/js/cm-ai/host-conversation-execution.mjs +23 -2
- package/runtime/js/cm-ai/host-handoff.mjs +7 -0
- package/runtime/js/cm-ai/host-progress.mjs +18 -0
- package/runtime/js/cm-ai/host-qa-executor.mjs +47 -15
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +11 -2
- package/runtime/js/cm-ai/host-qa-policy.mjs +24 -14
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +1 -1
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/operator-guidance.mjs +126 -2
- package/runtime/js/cm-ai/project-qa-gate.mjs +13 -2
- package/runtime/js/cm-ai/provider-review-observation.mjs +7 -3
- package/runtime/js/cm-ai/qa-plan-notes.mjs +106 -0
- package/runtime/js/cm-ai/review-continuation.mjs +102 -0
- package/runtime/js/cm-ai/review-evidence-file.mjs +11 -0
- package/runtime/js/cm-ai/review-package.mjs +25 -4
- package/runtime/js/cm-ai/review-presentation.mjs +31 -14
- package/runtime/js/cm-ai/review-runner.mjs +5 -4
- package/runtime/js/cm-ai/review-verdict-rules.mjs +7 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +30 -1
- package/runtime/js/cm-ai/task-commit-codec.mjs +11 -1
- package/runtime/js/cm-ai/task-commit.mjs +7 -4
- package/runtime/js/cm-ai/task-owner.mjs +5 -2
- package/runtime/js/cm-ai/task-runner.mjs +343 -52
- package/runtime/js/cm-ai/tool-preview.mjs +6 -0
- package/runtime/js/cm-fix/diagnosis.mjs +16 -3
- package/runtime/js/cm-fix/execution.mjs +47 -9
- package/runtime/js/cm-fix/finish.mjs +9 -1
- package/runtime/js/cm-fix/step-timing.mjs +222 -0
- package/runtime/js/cm-idea/session.mjs +22 -3
- package/runtime/js/cm-init/review-evidence.mjs +20 -7
- package/runtime/js/cm-prd/ai-draft.mjs +260 -0
- package/runtime/js/cm-prd/analysis.mjs +27 -9
- package/runtime/js/cm-prd/change.mjs +29 -8
- package/runtime/js/cm-prd/failed-correction.mjs +24 -4
- package/runtime/js/cm-prd/narrow-review.mjs +63 -3
- package/runtime/js/cm-prd/review-correction.mjs +65 -5
- package/runtime/js/cm-prd/review-disposition.mjs +10 -1
- package/runtime/js/cm-prd/self-check.mjs +121 -9
- package/runtime/js/cm-prd/session.mjs +55 -13
- package/runtime/js/cm-prd/summary.mjs +34 -6
- package/runtime/js/cm-prd/task-scope-record.mjs +40 -15
- package/runtime/js/cm-refactor/records.mjs +82 -11
- package/runtime/js/cm-refactor/workflow.mjs +3 -1
- package/runtime/js/executor-version.mjs +81 -0
- package/runtime/js/python-log-writer.mjs +15 -0
- package/runtime/js/run-analysis.mjs +136 -11
- package/runtime/logging.md +6 -0
- package/runtime/review.md +3 -1
- package/runtime/workflow-config.md +1 -1
- package/scripts/ci-test-weights.json +1 -0
- package/scripts/cm-ai-admission.mjs +27 -1
- package/scripts/cm-ai-admission.test.mjs +34 -2
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +3 -2
- package/scripts/cm-ai-batch-drive.mjs +54 -17
- package/scripts/cm-ai-batch-drive.test.mjs +123 -6
- package/scripts/cm-ai-batch-host.mjs +55 -9
- package/scripts/cm-ai-batch-host.test.mjs +22 -3
- package/scripts/cm-ai-batch-location.test.mjs +22 -1
- package/scripts/cm-ai-batch-merge.mjs +102 -0
- package/scripts/cm-ai-batch-plan.mjs +55 -2
- package/scripts/cm-ai-batch-plan.test.mjs +228 -6
- package/scripts/cm-ai-batch-run-fixture.mjs +239 -15
- package/scripts/cm-ai-batch-run-parallel.test.mjs +23 -1
- package/scripts/cm-ai-batch-run.mjs +435 -33
- package/scripts/cm-ai-batch-session-member.test.mjs +85 -0
- package/scripts/cm-ai-check-recheck-cancellation.test.mjs +23 -2
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +28 -0
- package/scripts/cm-ai-completion-summary.test.mjs +2 -1
- package/scripts/cm-ai-control-v2-drive.test.mjs +39 -9
- package/scripts/cm-ai-direct-review.test.mjs +1 -1
- package/scripts/cm-ai-disk-edits.test.mjs +229 -0
- package/scripts/cm-ai-drive-next-step.test.mjs +191 -0
- package/scripts/cm-ai-drive.mjs +66 -14
- package/scripts/cm-ai-drive.test.mjs +13 -3
- package/scripts/cm-ai-host-cli-workflow.test.mjs +4 -2
- package/scripts/cm-ai-host.mjs +16 -8
- package/scripts/cm-ai-host.test.mjs +12 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +132 -1
- package/scripts/cm-ai-project-qa-gate.test.mjs +26 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +18 -0
- package/scripts/cm-ai-review-continuation.test.mjs +335 -0
- package/scripts/cm-ai-review-failure.test.mjs +13 -10
- package/scripts/cm-ai-review-timeout.test.mjs +1 -1
- package/scripts/cm-ai-run.mjs +42 -11
- package/scripts/cm-ai-run.test.mjs +26 -0
- package/scripts/cm-ai-supersede.test.mjs +10 -2
- package/scripts/cm-capability-gate.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +9 -0
- package/scripts/cm-codex-clean-env.test.mjs +40 -0
- package/scripts/cm-codex-prompt-input.test.mjs +2 -1
- package/scripts/cm-developer-self-review.test.mjs +27 -0
- package/scripts/cm-efficiency-presentation-delta.test.mjs +4 -3
- package/scripts/cm-efficiency-response.test.mjs +2 -1
- package/scripts/cm-executor-version-draft.test.mjs +251 -0
- package/scripts/cm-executor-version-entries.test.mjs +93 -0
- package/scripts/cm-executor-version-prd.test.mjs +154 -0
- package/scripts/cm-executor-version-records.test.mjs +256 -0
- package/scripts/cm-executor-version.test.mjs +250 -0
- package/scripts/cm-external-model-host.test.mjs +6 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +1 -1
- package/scripts/cm-fix-closeout-preflight.test.mjs +123 -0
- package/scripts/cm-fix-diagnosis-module-correction.test.mjs +5 -1
- package/scripts/cm-fix-drive.mjs +7 -2
- package/scripts/cm-fix-drive.test.mjs +45 -0
- package/scripts/cm-fix-entry.mjs +5 -2
- package/scripts/cm-fix-frozen-baseline.test.mjs +50 -0
- package/scripts/cm-fix-host.mjs +9 -2
- package/scripts/cm-fix-test-extension.test.mjs +30 -2
- package/scripts/cm-host-check.test.mjs +12 -0
- package/scripts/cm-host-qa-executor.test.mjs +172 -1
- package/scripts/cm-host-qa-policy.test.mjs +55 -1
- package/scripts/cm-idea-drive.mjs +5 -2
- package/scripts/cm-idea-entry.mjs +5 -2
- package/scripts/cm-idea-host.mjs +3 -1
- package/scripts/cm-init-drive.mjs +8 -5
- package/scripts/cm-init-entry.mjs +5 -2
- package/scripts/cm-init-host.mjs +6 -2
- package/scripts/cm-log-event.mjs +10 -2
- package/scripts/cm-log-event.test.mjs +29 -0
- package/scripts/cm-prd-ai-draft-fixture.mjs +18 -0
- package/scripts/cm-prd-ai-draft.test.mjs +505 -0
- package/scripts/cm-prd-answer-gaps.test.mjs +110 -5
- package/scripts/cm-prd-completion.test.mjs +67 -4
- package/scripts/cm-prd-design-phase.test.mjs +48 -13
- package/scripts/cm-prd-drive.mjs +89 -20
- package/scripts/cm-prd-drive.test.mjs +109 -4
- package/scripts/cm-prd-entry.mjs +5 -2
- package/scripts/cm-prd-host.mjs +89 -20
- package/scripts/cm-prd-host.test.mjs +17 -8
- package/scripts/cm-prd-narrow-review.test.mjs +49 -1
- package/scripts/cm-prd-review-disposition.test.mjs +94 -1
- package/scripts/cm-prd-review-gate.mjs +11 -4
- package/scripts/cm-prd-self-check-rules.test.mjs +175 -10
- package/scripts/cm-prd-self-check.test.mjs +1 -1
- package/scripts/cm-refactor-drive.mjs +10 -4
- package/scripts/cm-refactor-entry.mjs +5 -2
- package/scripts/cm-refactor-host.mjs +3 -1
- package/scripts/cm-run-analysis.test.mjs +373 -1
- package/scripts/cm-runtime-i18n.mjs +3 -3
- package/scripts/cm-runtime-install.mjs +19 -10
- package/scripts/cm-runtime.mjs +2 -4
- package/scripts/cm-runtime.test.mjs +55 -13
- package/scripts/cm-skill-hints-autowire.test.mjs +1 -1
- package/scripts/cm-skill-hints-exam.mjs +3 -1
- package/scripts/cm-skill-hints-install.test.mjs +1 -1
- package/scripts/cm-skill-hints.mjs +106 -10
- package/scripts/cm-skill-hints.test.mjs +162 -6
- package/scripts/cm-skill-judge.mjs +2 -1
- package/scripts/cm-statusline.test.mjs +54 -0
- package/scripts/cm-task-gate.mjs +88 -18
- package/scripts/cm-task-scope.test.mjs +1 -1
- package/scripts/cm-test-drive.mjs +13 -8
- package/scripts/cm-test-entry.mjs +5 -2
- package/scripts/cm-test-host.mjs +3 -1
- package/scripts/cm-upgrade-compat-batch.test.mjs +62 -9
- package/scripts/fixtures/fresh-completion-checks.mjs +8 -0
- package/scripts/fixtures/prd-review-gate-python-oracle.py +9 -0
- package/scripts/policy-binding-compat.test.mjs +3 -2
- package/scripts/test-cm-prd-review-gate.py +25 -0
- package/skills/cm-ai/SKILL.md +1 -1
- package/skills/cm-ai/references/N1-init.md +4 -3
- package/skills/cm-ai/references/N4-review.md +6 -3
- package/skills/cm-ai/references/N6-qa-eval.md +3 -1
- package/skills/cm-ai/references/js-host-recovery.md +4 -1
- package/skills/cm-ai/references/js-host.md +25 -5
- package/skills/cm-fix/references/js-host.md +20 -0
- package/skills/cm-fix/references/test-extension.md +1 -1
- package/skills/cm-prd/SKILL.md +8 -6
- package/skills/cm-prd/references/ai-draft.md +81 -0
- package/skills/cm-prd/references/change-mode.md +2 -0
- package/skills/cm-prd/references/greenfield.md +2 -0
- package/skills/cm-prd/references/js-change-recovery.md +2 -2
- package/skills/cm-prd/references/js-host.md +9 -6
- package/skills/cm-prd/references/light-mode.md +19 -0
- package/skills/cm-prd/references/requirement-grilling.md +2 -0
- package/skills/cm-prd/references/spec-self-check.md +1 -0
- package/skills/cm-prd/references/summary-card.md +1 -0
- package/skills/cm-runtime/SKILL.md +6 -6
- package/templates/statusline/cm-statusline.sh +63 -1
|
@@ -5,9 +5,11 @@ import os from 'node:os';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import {spawnSync} from 'node:child_process';
|
|
7
7
|
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
8
|
-
import {createCmAiBatch} from './cm-ai-batch-run.mjs';
|
|
9
|
-
import {main} from './cm-ai-batch-plan.mjs';
|
|
8
|
+
import {createCmAiBatch,batchTaskRunId} from './cm-ai-batch-run.mjs';
|
|
9
|
+
import {main,redactConfigMessage} from './cm-ai-batch-plan.mjs';
|
|
10
10
|
import {planCmAiBatch,parallelSettings} from '../runtime/js/cm-ai/batch-plan.mjs';
|
|
11
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
12
|
+
import {createdByRecord} from '../runtime/js/executor-version.mjs';
|
|
11
13
|
|
|
12
14
|
const scope=file=>`\n - 范围: \`${file}\``;
|
|
13
15
|
function project(t,tasks,{feature='1.work',emptyCode=false,caseKinds=null,taskGrammar=null}={}){
|
|
@@ -177,6 +179,75 @@ test('one-member groups stop before a task could be the fifth without QA',t=>{
|
|
|
177
179
|
// Real groups defer their QA and are unaffected.
|
|
178
180
|
assert.deepEqual(project(t,chainOf(7)).plan({enabled:true,max:2,worktree_all:false}).groups,[]);
|
|
179
181
|
});
|
|
182
|
+
// Review q4: the count is read again under batch.lock. An older host's status call (or a
|
|
183
|
+
// legacy batch_start) written after this host was built refuses before anything runs.
|
|
184
|
+
// An older host's row lacks created_by too; the QA count is checked first so its restart reason is kept.
|
|
185
|
+
test('a batch QA count changed after the host was built refuses under the lock',async t=>{
|
|
186
|
+
const f=project(t,chainOf(7)),plan=f.plan(),batch=host(f,plan.config.batch);
|
|
187
|
+
const unchanged=await batch.handle({operation:'status',requestId:'s1'}).then(value=>value,error=>error);
|
|
188
|
+
assert.notEqual(unchanged?.code,'batch_qa_cadence_changed');
|
|
189
|
+
fs.appendFileSync(path.join(f.specsDir,'运行日志.jsonl'),JSON.stringify({schema_version:1,workflow:'cm-ai',event:'decision',
|
|
190
|
+
phase:'batch_start',run_id:plan.config.batch.batchId,repository_id:'r',plan_digest:digest(plan.config.batch),from_key:'1.work/T-001'})+'\n');
|
|
191
|
+
await assert.rejects(batch.handle({operation:'status',requestId:'s2'}),{code:'batch_qa_cadence_changed',reason:/重启|重新/});
|
|
192
|
+
// A newer release's row on the old count keeps its upgrade refusal, not the restart one.
|
|
193
|
+
const n=project(t,chainOf(7)),newer=n.plan(),late=host(n,newer.config.batch);
|
|
194
|
+
fs.appendFileSync(path.join(n.specsDir,'运行日志.jsonl'),JSON.stringify({schema_version:1,workflow:'cm-ai',event:'decision',
|
|
195
|
+
phase:'batch_start',run_id:newer.config.batch.batchId,repository_id:'r',plan_digest:digest(newer.config.batch),from_key:'1.work/T-001',
|
|
196
|
+
created_by:createdByRecord('99.0.0')})+'\n');
|
|
197
|
+
await assert.rejects(late.handle({operation:'status',requestId:'s3'}),{code:'run_created_by_newer_executor'});
|
|
198
|
+
// Review q5: every member open re-reads it, outside batch.lock too (controlTarget of a
|
|
199
|
+
// serial batch opens its current member).
|
|
200
|
+
const g=project(t,chainOf(3)),serial=g.plan(legacy),other=host(g,serial.config.batch);
|
|
201
|
+
assert.deepEqual(serial.groups,[]);
|
|
202
|
+
fs.appendFileSync(path.join(g.specsDir,'运行日志.jsonl'),JSON.stringify({schema_version:1,workflow:'cm-ai',event:'decision',
|
|
203
|
+
phase:'batch_start',run_id:serial.config.batch.batchId,repository_id:'r',plan_digest:digest({config:serial.config.batch,createdBy:createdByRecord()}),from_key:'1.work/T-001',created_by:createdByRecord()})+'\n');
|
|
204
|
+
await assert.rejects(other.controlTarget(),{code:'batch_qa_cadence_changed'});
|
|
205
|
+
// Outside the lock too: a member store a newer release opened on the old count after
|
|
206
|
+
// this host was built keeps its upgrade refusal (review r3).
|
|
207
|
+
const m=project(t,chainOf(3)),mplan=m.plan(legacy),built=host(m,mplan.config.batch);
|
|
208
|
+
const memberId={repositoryId:'r',runId:batchTaskRunId(mplan.config.batch.batchId,'1.work/T-001')};
|
|
209
|
+
const dir=path.join(m.specsDir,'.reviews','.execution',memberId.runId);fs.mkdirSync(dir,{recursive:true,mode:0o700});
|
|
210
|
+
fs.chmodSync(path.join(m.specsDir,'.reviews','.execution'),0o700);
|
|
211
|
+
const record={version:1,seq:1,id:'init',kind:'intent',payload:{config:{}},previousDigest:null};
|
|
212
|
+
const state={version:2,identity:memberId,fingerprints:{workflow:'a'.repeat(64),config:'b'.repeat(64),inputs:'c'.repeat(64)},
|
|
213
|
+
createdBy:createdByRecord('99.0.0'),records:[{...record,digest:digest(record)}]};
|
|
214
|
+
fs.writeFileSync(path.join(dir,'state.json'),JSON.stringify({...state,revision:digest(state)})+'\n',{mode:0o600});
|
|
215
|
+
await assert.rejects(built.controlTarget(),{code:'run_created_by_newer_executor'});
|
|
216
|
+
});
|
|
217
|
+
// Reviews reg2/reg3: an unreadable member store leaves the batch QA count unknown.
|
|
218
|
+
// Guessing either count could freeze the other beside it, so every operation refuses
|
|
219
|
+
// until the store reads again (then the count differs from launch: restart).
|
|
220
|
+
test('an unreadable member store leaves the batch QA count unknown and refuses',async t=>{
|
|
221
|
+
const f=project(t,chainOf(3)),plan=f.plan(legacy);
|
|
222
|
+
const dir=path.join(f.specsDir,'.reviews','.execution',batchTaskRunId(plan.config.batch.batchId,'1.work/T-001'));
|
|
223
|
+
fs.mkdirSync(dir,{recursive:true,mode:0o700});fs.writeFileSync(path.join(dir,'state.json'),'{}',{mode:0o600});
|
|
224
|
+
const batch=host(f,plan.config.batch);
|
|
225
|
+
await assert.rejects(batch.handle({operation:'status',requestId:'u1'}),{code:'batch_member_store_unreadable',reason:/读不了/});
|
|
226
|
+
await assert.rejects(batch.controlTarget(),{code:'batch_member_store_unreadable'});
|
|
227
|
+
assert.equal(fs.existsSync(path.join(f.specsDir,'运行日志.jsonl')),false,'nothing is written while the count is unknown');
|
|
228
|
+
fs.rmSync(dir,{recursive:true,force:true});
|
|
229
|
+
await assert.rejects(batch.handle({operation:'status',requestId:'u2'}),{code:'batch_qa_cadence_changed'});
|
|
230
|
+
});
|
|
231
|
+
// Review reg4: every member is read before deciding (an older readable member first
|
|
232
|
+
// never hides a damaged one after it), and a run directory whose store vanished is
|
|
233
|
+
// unknown, not absent.
|
|
234
|
+
test('the batch QA count reads every member and treats a vanished store as unknown',async t=>{
|
|
235
|
+
const f=project(t,chainOf(3)),plan=f.plan(legacy),execution=path.join(f.specsDir,'.reviews','.execution');
|
|
236
|
+
const store=(taskKey,state)=>{const dir=path.join(execution,batchTaskRunId(plan.config.batch.batchId,taskKey));
|
|
237
|
+
fs.mkdirSync(dir,{recursive:true,mode:0o700});fs.chmodSync(execution,0o700);
|
|
238
|
+
if(state!==undefined)fs.writeFileSync(path.join(dir,'state.json'),state,{mode:0o600});return dir;};
|
|
239
|
+
const identity={repositoryId:'r',runId:batchTaskRunId(plan.config.batch.batchId,'1.work/T-001')};
|
|
240
|
+
const record={version:1,seq:1,id:'init',kind:'intent',payload:{config:{}},previousDigest:null};
|
|
241
|
+
const older={version:2,identity,fingerprints:{workflow:'a'.repeat(64),config:'b'.repeat(64),inputs:'c'.repeat(64)},
|
|
242
|
+
createdBy:createdByRecord(),records:[{...record,digest:digest(record)}]};
|
|
243
|
+
store('1.work/T-001',JSON.stringify({...older,revision:digest(older)})+'\n');
|
|
244
|
+
const damaged=store('1.work/T-002','{}');
|
|
245
|
+
await assert.rejects(host(f,plan.config.batch).handle({operation:'status',requestId:'v1'}),{code:'batch_member_store_unreadable'});
|
|
246
|
+
fs.rmSync(path.join(damaged,'state.json'));
|
|
247
|
+
await assert.rejects(host(f,plan.config.batch).handle({operation:'status',requestId:'v2'}),{code:'batch_member_store_unreadable'});
|
|
248
|
+
fs.rmSync(damaged,{recursive:true,force:true});
|
|
249
|
+
assert.notEqual(await host(f,plan.config.batch).handle({operation:'status',requestId:'v3'}).then(()=>null,error=>error.code),'batch_member_store_unreadable');
|
|
250
|
+
});
|
|
180
251
|
test('a fifth task kept in the main checkout resets the count when the host policy decides QA',t=>{
|
|
181
252
|
// Ticket 05: T-005 stays in the main checkout as the fifth without QA, so its QA
|
|
182
253
|
// triggers for certain and T-006 starts from zero again. That holds only where the
|
|
@@ -196,8 +267,11 @@ test('a fifth task kept in the main checkout resets the count when the host poli
|
|
|
196
267
|
const auth={qa:{criticalPaths:{authentication:['f2.js']}},applicableAgentFiles:[]};
|
|
197
268
|
assert.deepEqual(f.plan(undefined,auth).groups,keys([1,3,4,6,8]));
|
|
198
269
|
assert.throws(()=>host(f,{...plan.config.batch,parallel:[1,3,4,6,7].map(id=>[`1.work/T-00${id}`])},every(auth)),{code:'parallel_solo_qa_checkpoint',reason:/T-007/});
|
|
199
|
-
// Tasks completed with no QA row at all stay counted after a triggered QA
|
|
200
|
-
|
|
270
|
+
// Tasks completed with no QA row at all stay counted after a triggered QA (feature-v1
|
|
271
|
+
// member runs as well).
|
|
272
|
+
const done=project(t,chainOf(9,2)),walked=done.plan(undefined,none);
|
|
273
|
+
assert.deepEqual(walked.groups,keys([3,4,6,7]));
|
|
274
|
+
assert.ok(host(done,walked.config.batch,Object.fromEntries(walked.config.batch.tasks.map(task=>[`1.work/${task.taskId}`,none]))));
|
|
201
275
|
});
|
|
202
276
|
test('the count walk keeps every reset a group, qa:null or several features may hide',t=>{
|
|
203
277
|
// Review r1 (ticket 05). Each case once let a one-member group reach five in its worktree.
|
|
@@ -233,8 +307,8 @@ test('the count walk keeps every reset a group, qa:null or several features may
|
|
|
233
307
|
// one-member group there is no count to protect.
|
|
234
308
|
assert.ok(host(h,{...batch,parallel:[['1.work/T-002','1.work/T-001'],...solo([8])]},every(batch,none)));
|
|
235
309
|
assert.ok(host(h,{...batch,parallel:[['1.work/T-001','1.work/T-005']]},every(batch,none)));
|
|
236
|
-
// 4. The
|
|
237
|
-
//
|
|
310
|
+
// 4. The walk predicts one feature's count: no one-member group in a batch of several
|
|
311
|
+
// features.
|
|
238
312
|
const more=path.join(h.specsDir,'2.more');fs.mkdirSync(more);
|
|
239
313
|
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(more,name),'# Fixture\n');
|
|
240
314
|
fs.writeFileSync(path.join(more,'tasks.md'),`- [ ] T-001: g1${scope('g1.js')}\n`);
|
|
@@ -395,3 +469,151 @@ test('grammar 3 session tasks: not final, several, or (defensively) grouped are
|
|
|
395
469
|
const plan=project(t,chain([3]),{taskGrammar:3}).plan();
|
|
396
470
|
assert.ok(plan.groups.every(group=>!group.includes('T-003')));assert.deepEqual(plan.config.batch.memberDevelopment,{'1.work/T-003':'session'});
|
|
397
471
|
});
|
|
472
|
+
|
|
473
|
+
// 2026-12-01 探针实跑:.cm-workflow.yml 读取失败只输出 {"error":{"code":"batch_plan_failed"}},真实原因丢失。
|
|
474
|
+
test('a project config error keeps its message as the reason',t=>{
|
|
475
|
+
const f=project(t,diamond());
|
|
476
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.yml'),'version: 2\n');
|
|
477
|
+
const writes=[];const original=process.stderr.write.bind(process.stderr);
|
|
478
|
+
process.stderr.write=chunk=>{writes.push(String(chunk));return true;};
|
|
479
|
+
let code;try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1']);}
|
|
480
|
+
finally{process.stderr.write=original;}
|
|
481
|
+
assert.equal(code,1);const {error}=JSON.parse(writes.join(''));
|
|
482
|
+
assert.equal(error.code,'batch_plan_failed');
|
|
483
|
+
assert.match(error.reason,/config\.version must equal integer 1/);assert.match(error.reason,/\.cm-workflow\.yml/);
|
|
484
|
+
// A parser error that would quote the file's own text keeps only its fixed prefix.
|
|
485
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.yml'),'version: 1\nroles: {fixture-private-value}\n');
|
|
486
|
+
writes.length=0;process.stderr.write=chunk=>{writes.push(String(chunk));return true;};
|
|
487
|
+
try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1']);}
|
|
488
|
+
finally{process.stderr.write=original;}
|
|
489
|
+
assert.equal(code,1);const quoted=JSON.parse(writes.join('')).error;
|
|
490
|
+
assert.match(quoted.reason,/项目工作流配置无效:invalid inline mapping item(原文不回显)/);assert.doesNotMatch(quoted.reason,/fixture-private-value/);
|
|
491
|
+
// The user-level runtimes.yml error carries a file prefix; it is cut the same way.
|
|
492
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.yml'),'version: 1\n');
|
|
493
|
+
const home=path.join(f.root,'user-home');fs.mkdirSync(home);
|
|
494
|
+
fs.writeFileSync(path.join(home,'runtimes.yml'),'version: 1\nroles: {fixture-private-value}\n');
|
|
495
|
+
const saved=process.env.CM_WORKFLOW_HOME;process.env.CM_WORKFLOW_HOME=home;
|
|
496
|
+
writes.length=0;process.stderr.write=chunk=>{writes.push(String(chunk));return true;};
|
|
497
|
+
try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1']);}
|
|
498
|
+
finally{process.stderr.write=original;if(saved===undefined)delete process.env.CM_WORKFLOW_HOME;else process.env.CM_WORKFLOW_HOME=saved;}
|
|
499
|
+
assert.equal(code,1);const user=JSON.parse(writes.join('')).error;
|
|
500
|
+
assert.match(user.reason,/invalid inline mapping item(原文不回显)/,user.reason);assert.doesNotMatch(user.reason,/fixture-private-value/);
|
|
501
|
+
// Codex 第三轮:原文里写上 "invalid JSON near byte 7" 曾让整条消息跳过截断。
|
|
502
|
+
fs.writeFileSync(path.join(home,'runtimes.yml'),'version: 1\nruntimes: {fixture-private-value invalid JSON near byte 7}\n');
|
|
503
|
+
writes.length=0;process.env.CM_WORKFLOW_HOME=home;process.stderr.write=chunk=>{writes.push(String(chunk));return true;};
|
|
504
|
+
try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1']);}
|
|
505
|
+
finally{process.stderr.write=original;if(saved===undefined)delete process.env.CM_WORKFLOW_HOME;else process.env.CM_WORKFLOW_HOME=saved;}
|
|
506
|
+
assert.equal(code,1);const tail=JSON.parse(writes.join('')).error;
|
|
507
|
+
assert.match(tail.reason,/(原文不回显)/,tail.reason);assert.doesNotMatch(tail.reason,/fixture-private-value/);
|
|
508
|
+
// A genuine byte-position JSON error keeps its position.
|
|
509
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.json'),'{"version":1} x');
|
|
510
|
+
fs.rmSync(path.join(f.codeProject,'.cm-workflow.yml'));
|
|
511
|
+
writes.length=0;process.stderr.write=chunk=>{writes.push(String(chunk));return true;};
|
|
512
|
+
try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1']);}
|
|
513
|
+
finally{process.stderr.write=original;}
|
|
514
|
+
assert.equal(code,1);assert.match(JSON.parse(writes.join('')).error.reason,/invalid JSON near byte \d+。/);
|
|
515
|
+
// Codex 第四轮:键名、字段路径和文件路径也会被拼进报错;只放行已知字段名与固定文案。
|
|
516
|
+
for(const [text,shown] of [
|
|
517
|
+
['{"version":1,"g\\u0068p_FIXTUREONLY123456":true}',/config has unknown field\(s\)(字段名不回显)/],
|
|
518
|
+
['{"version":1,"g\\u0068p_FIXTUREONLY123456":1,"g\\u0068p_FIXTUREONLY123456":2}',/有重复的键(键名不回显)/],
|
|
519
|
+
['{"version":1,"roles":{"g\\u0068p_FIXTUREONLY123456":{"password":"x"}}}',/有凭证字段名或疑似密钥的值(位置不回显)/],
|
|
520
|
+
]){
|
|
521
|
+
fs.writeFileSync(path.join(f.codeProject,'.cm-workflow.json'),text);
|
|
522
|
+
writes.length=0;process.stderr.write=chunk=>{writes.push(String(chunk));return true;};
|
|
523
|
+
try{code=main(['--specs-dir',f.specsDir,'--code-project',f.codeProject,'--repository-id','r','--batch-id','plan-batch-1']);}
|
|
524
|
+
finally{process.stderr.write=original;}
|
|
525
|
+
assert.equal(code,1);const {reason}=JSON.parse(writes.join('')).error;
|
|
526
|
+
assert.match(reason,shown,reason);assert.doesNotMatch(reason,/FIXTUREONLY|password/,reason);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
test('a config error message keeps only known field names, fixed wording and line numbers',()=>{
|
|
531
|
+
for(const [message,expected] of [
|
|
532
|
+
['config.version must equal integer 1','config.version must equal integer 1'],
|
|
533
|
+
['runtimes.yml: user.preset must be one of: claude-only, codex-only','runtimes.yml: user.preset must be one of: claude-only, codex-only'],
|
|
534
|
+
["line 3: expected 'key: value'","line 3: expected 'key: value'"],
|
|
535
|
+
['config.policies.tests must be a non-empty list of logic/commands/browser','config.policies.tests must be a non-empty list of logic/commands/browser'],
|
|
536
|
+
['/tmp/fixture-proj/.cm-workflow.yml: EACCES: permission denied','配置格式或字段不合法(原文含用户写的内容,不回显)'],
|
|
537
|
+
['cannot read configuration /tmp/fixture/x.yml: boom','配置格式或字段不合法(原文含用户写的内容,不回显)'],
|
|
538
|
+
['line 4: duplicate key "ghp_x"','line 4: 有重复的键(键名不回显)'],
|
|
539
|
+
['config.ghp_FIXTURE.inner: secret-like values are forbidden','有凭证字段名或疑似密钥的值(位置不回显)'],
|
|
540
|
+
['unknown workflow role: ghp_FIXTURE','配置格式或字段不合法(原文含用户写的内容,不回显)'],
|
|
541
|
+
// Codex 第五轮:截断后引号不闭合、键名含空格或方括号、路径含空格,都曾漏出原文。
|
|
542
|
+
['line 2: duplicate key "PRIVATE_PART: suffix"','line 2: 有重复的键(键名不回显)'],
|
|
543
|
+
['duplicate JSON object key "PRIVATE_PART: suffix"','有重复的键(键名不回显)'],
|
|
544
|
+
['config.roles.private team.password: credential fields are forbidden','有凭证字段名或疑似密钥的值(位置不回显)'],
|
|
545
|
+
['config.roles[x PRIVATE].a: secret-like values are forbidden','有凭证字段名或疑似密钥的值(位置不回显)'],
|
|
546
|
+
['user.runtimes: /cm-probe/Private Folder/runtimes.yml: EISDIR','user.runtimes: 用户级 runtimes.yml 读取失败(路径与系统原文不回显)'],
|
|
547
|
+
['line 5: missing value for "PRIVATE_PART"','line 5: 缺少值(键名不回显)'],
|
|
548
|
+
// 正常诊断保留定位信息。
|
|
549
|
+
['config.roles.coder.model must be a non-empty string','config.roles.coder.model must be a non-empty string'],
|
|
550
|
+
['config.project.type must be one of: generic, web','config.project.type must be one of: generic, web'],
|
|
551
|
+
["invalid JSON: expected ':'","invalid JSON: expected ':'"],
|
|
552
|
+
['config.roles has unknown field(s): PRIVATE_PART','config.roles has unknown field(s)(字段名不回显)'],
|
|
553
|
+
['roles.reviewer.adapter claude-cli needs the claude runtime, but runtimes.available declares codex','roles.reviewer.adapter claude-cli needs the claude runtime, but runtimes.available declares codex'],
|
|
554
|
+
['invalid inline mapping item: PRIVATE_PART','invalid inline mapping item(原文不回显)'],
|
|
555
|
+
// Codex 第六轮:多份配置、超长和带大写的合法选项要能看出该查哪里。
|
|
556
|
+
['multiple CM workflow configs found: .cm-workflow.json, .cm-workflow.yml','multiple CM workflow configs found: .cm-workflow.json, .cm-workflow.yml'],
|
|
557
|
+
['configuration file exceeds 65536 bytes: /tmp/x y/.cm-workflow.yml','项目配置文件 configuration file exceeds 65536 bytes(路径不回显)'],
|
|
558
|
+
// Codex 第七轮:用户级文件读取失败时没有 runtimes.yml: 前缀,要能看出是用户级那份。
|
|
559
|
+
['/tmp/x y/runtimes.yml: configuration exceeds 65536 bytes','用户级 runtimes.yml: configuration exceeds 65536 bytes'],
|
|
560
|
+
['/tmp/x y/runtimes.yml: configuration must be a regular file','用户级 runtimes.yml: configuration must be a regular file'],
|
|
561
|
+
// Codex 第八轮:根目录下的用户级文件、lstat 阶段的读取失败也要指出用户级 runtimes.yml。
|
|
562
|
+
['/runtimes.yml: configuration exceeds 65536 bytes','用户级 runtimes.yml: configuration exceeds 65536 bytes'],
|
|
563
|
+
["user.runtimes: EACCES: permission denied, lstat '/tmp/x y/runtimes.yml'",'user.runtimes: 用户级 runtimes.yml 读取失败(路径与系统原文不回显)'],
|
|
564
|
+
["/tmp/x y/runtimes.yml: EACCES: permission denied, open '/tmp/x y/runtimes.yml'",'用户级 runtimes.yml 读取失败(路径与系统原文不回显)'],
|
|
565
|
+
// Codex 第七轮:未知键名写成「路径: 安全句」的样子,曾被当成安全诊断显示。
|
|
566
|
+
['config has unknown field(s): note: config.project.type must be one of: Demo.PrivateTeam','config has unknown field(s)(字段名不回显)'],
|
|
567
|
+
['runtimes.yml: user has unknown field(s): x: config.version must equal integer 1','runtimes.yml: user has unknown field(s)(字段名不回显)'],
|
|
568
|
+
['config.roles.external_expert.model_policy must be one of: auto, strict-Pro','config.roles.external_expert.model_policy must be one of: auto, strict-Pro'],
|
|
569
|
+
['preset must be one of: claude-only, codex-only','preset must be one of: claude-only, codex-only'],
|
|
570
|
+
])assert.equal(redactConfigMessage(message),expected,message);
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
// 守卫:cm-workflow-config.mjs 里任何报错模板,插值位置填上用户内容都不得回显(Codex 第一至七轮的同类泄露)。
|
|
574
|
+
// Each slot gets a strong canary and a plain lowercase word. A slot may show the plain word only
|
|
575
|
+
// when it is listed here by its exact template and slot index, with why the parser itself
|
|
576
|
+
// produces that value; a new or changed template is checked strictly (Codex round 7: exempting
|
|
577
|
+
// by variable name let a user key through).
|
|
578
|
+
const CODE_DERIVED=new Map([
|
|
579
|
+
// rejectUnknown/requireMapping/requireString are called with code-written locations only.
|
|
580
|
+
['${location} has unknown field(s): ${unknown.join(\', \')}',[0]],
|
|
581
|
+
['${location} must be a mapping',[0]],['${location} must be a non-empty string',[0]],
|
|
582
|
+
['${location} contains unsupported characters',[0]],
|
|
583
|
+
// Choices are code constants.
|
|
584
|
+
['${location} must be one of: ${[...choices].sort().join(\', \')}',[0,1]],
|
|
585
|
+
['preset must be one of: ${Object.keys(RUNTIME_PRESETS).join(\', \')}',[0]],
|
|
586
|
+
// validateRaw/validateEffective iterate roles only after rejectUnknown(ROLE_NAMES); adapter
|
|
587
|
+
// values pass requireString(ADAPTERS) first; runtimes come from CLI_ADAPTER_RUNTIME.
|
|
588
|
+
['config.roles.${role}.adapter cannot be external-browser; only external_expert may use the external browser',[0]],
|
|
589
|
+
['config.roles.${role}.adapter browser is reserved for browser_qa',[0]],
|
|
590
|
+
['config.roles.${role}.source browser is reserved for external_expert',[0]],
|
|
591
|
+
['config.roles.${role}.enabled must be boolean',[0]],
|
|
592
|
+
['roles.${role}.adapter cannot be external-browser; only external_expert may use it',[0]],
|
|
593
|
+
['roles.${role}.adapter browser is reserved for browser_qa',[0]],
|
|
594
|
+
['roles.${role}.source browser is reserved for external_expert',[0]],
|
|
595
|
+
['roles.${role}.adapter ${roleData.adapter} needs the ${runtime} runtime, but runtimes.available declares ${available}',[0,1,2,3]],
|
|
596
|
+
['roles.coder and roles.reviewer both resolve to ${coder}; with runtimes.available both, review must run on the other runtime',[0]],
|
|
597
|
+
]);
|
|
598
|
+
test('no ConfigError template echoes an interpolated value through the batch plan reason',()=>{
|
|
599
|
+
const source=fs.readFileSync(new URL('./cm-workflow-config.mjs',import.meta.url),'utf8');
|
|
600
|
+
const calls=[...source.matchAll(/\bConfigError\s*\(/g)].length;
|
|
601
|
+
const templates=[...source.matchAll(/new ConfigError\(`([^`]*)`\)/g)].map(match=>match[1]);
|
|
602
|
+
const plain=[...source.matchAll(/new ConfigError\(('[^']*'|"[^"]*")\)/g)].map(match=>match[1].slice(1,-1));
|
|
603
|
+
// 'text'+expr concatenation becomes a template with one slot.
|
|
604
|
+
const joined=[...source.matchAll(/new ConfigError\('([^']*)'\+(.+?)\);/g)].map(match=>`${match[1]}\${${match[2]}}`);
|
|
605
|
+
assert.equal(templates.length+plain.length+joined.length,calls,'ConfigError 有守卫不认识的写法:写成 new ConfigError(`模板`)、纯字符串或 \'文字\'+表达式,或扩展本守卫');
|
|
606
|
+
const strong='CANARY x: "q" /p a]b.c',weak=['canary_private','canaryprivate'],leaks=[];
|
|
607
|
+
for(const template of [...templates,...joined]){
|
|
608
|
+
const slots=template.match(/\$\{[^}]*\}/g)??[];
|
|
609
|
+
for(let target=0;target<slots.length;target++){
|
|
610
|
+
for(const canary of [strong,...(CODE_DERIVED.get(template)?.includes(target)?[]:weak)]){
|
|
611
|
+
let slot=0;const message=template.replace(/\$\{[^}]*\}/g,()=>slot++===target?canary:'config');
|
|
612
|
+
for(const wrapped of [message,`runtimes.yml: ${message}`,`line 3: ${message}`,`/tmp/x y/runtimes.yml: ${message}`])
|
|
613
|
+
if(/canary/i.test(redactConfigMessage(wrapped)))leaks.push(`${template} [${target}] → ${redactConfigMessage(wrapped)}`);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
assert.deepEqual(leaks,[]);
|
|
618
|
+
for(const message of plain)assert.doesNotMatch(redactConfigMessage(message),/canary/i);
|
|
619
|
+
});
|