@aibyzero/cm-workflow 0.20.0 → 0.21.1
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 +36 -0
- package/README.md +13 -1
- package/VERSION +1 -1
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +1 -1
- package/docs/proposals/spec-amendment-tiers.md +100 -0
- package/package.json +1 -1
- package/runtime/js/acceptance-language.mjs +32 -0
- package/runtime/js/autonomy.mjs +15 -6
- package/runtime/js/cm-ai/acceptance-contract.mjs +8 -3
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +13 -3
- package/runtime/js/cm-ai/cm-ai-admission.mjs +35 -2
- package/runtime/js/cm-ai/codex-review-adapter.mjs +19 -3
- package/runtime/js/cm-ai/drive-core.mjs +9 -2
- package/runtime/js/cm-ai/durable-runner-state.mjs +12 -4
- package/runtime/js/cm-ai/effect-contract.mjs +8 -1
- package/runtime/js/cm-ai/execution-snapshot.mjs +4 -3
- package/runtime/js/cm-ai/execution-store-limits.mjs +3 -3
- package/runtime/js/cm-ai/execution-store.mjs +7 -4
- package/runtime/js/cm-ai/fix-code-association.mjs +27 -6
- package/runtime/js/cm-ai/review-package.mjs +20 -6
- package/runtime/js/cm-ai/review-presentation.mjs +12 -5
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +10 -7
- package/runtime/js/cm-ai/reviewed-integration.mjs +1 -1
- package/runtime/js/cm-ai/spec-amendment.mjs +535 -0
- package/runtime/js/cm-ai/task-commit-codec.mjs +4 -2
- package/runtime/js/cm-ai/task-commit.mjs +4 -2
- package/runtime/js/cm-ai/task-runner.mjs +26 -9
- package/runtime/js/cm-ai/user-maintained-paths.mjs +68 -0
- package/runtime/js/cm-prd/change.mjs +35 -4
- package/runtime/js/cm-prd/self-check.mjs +36 -6
- package/runtime/js/cm-prd/session.mjs +8 -3
- package/runtime/js/cm-prd/task-scope-record.mjs +13 -7
- package/runtime/js/task-scope.mjs +4 -1
- package/runtime/test-contract.md +1 -0
- package/scripts/cm-ai-acceptance-contract.test.mjs +10 -0
- package/scripts/cm-ai-admission.mjs +8 -2
- package/scripts/cm-ai-admission.test.mjs +15 -2
- package/scripts/cm-ai-batch-run-fixture.mjs +5 -1
- package/scripts/cm-ai-checkpoint-package-material.test.mjs +60 -6
- package/scripts/cm-ai-checkpoint-package-owner.test.mjs +1 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +1 -0
- package/scripts/cm-ai-drive.mjs +18 -11
- package/scripts/cm-ai-fix-later-delivery.test.mjs +2 -2
- package/scripts/cm-ai-later-delivery-feature.test.mjs +102 -0
- package/scripts/cm-ai-review-input-limit.test.mjs +91 -0
- package/scripts/cm-ai-user-maintained-paths.test.mjs +183 -0
- package/scripts/cm-autonomy-review-r1.test.mjs +49 -0
- package/scripts/cm-check-runtime.sh +4 -1
- package/scripts/cm-drive-liveness.test.mjs +8 -0
- package/scripts/cm-fix-observation-task-id.test.mjs +49 -0
- package/scripts/cm-fix-review-storage.test.mjs +14 -4
- package/scripts/cm-journal-limit.test.mjs +69 -0
- package/scripts/cm-notify.test.mjs +6 -4
- package/scripts/cm-prd-completion.test.mjs +37 -0
- package/scripts/cm-prd-drive.mjs +1 -1
- package/scripts/cm-prd-host.test.mjs +1 -1
- package/scripts/cm-prd-self-check-rules.test.mjs +23 -11
- package/scripts/cm-prd-self-check.test.mjs +24 -1
- package/scripts/cm-prd-summary.test.mjs +6 -0
- package/scripts/cm-review-inventory.test.mjs +5 -1
- package/scripts/cm-skill-hints.json +1 -1
- package/scripts/cm-skill-hints.mjs +66 -3
- package/scripts/cm-skill-hints.test.mjs +96 -0
- package/scripts/cm-spec-amend.mjs +68 -0
- package/scripts/cm-spec-amend.test.mjs +510 -0
- package/scripts/cm-specs-status.test.mjs +6 -0
- package/scripts/cm-start-check.mjs +82 -2
- package/scripts/cm-start-check.test.mjs +64 -1
- package/scripts/cm-task-scope.test.mjs +3 -2
- package/scripts/test-journal-limit-1mib.mjs +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/references/N1-init.md +23 -1
- package/skills/cm-ai/references/js-host-qa-recovery.md +3 -2
- package/skills/cm-ai/references/js-host-recovery.md +2 -1
- package/skills/cm-ai/references/js-host.md +2 -1
- package/skills/cm-prd/references/js-change-recovery.md +1 -0
|
@@ -11,9 +11,12 @@ import {planCheckTimeout} from '../runtime/js/cm-ai/drive-core.mjs';
|
|
|
11
11
|
import {isXcodebuild, isTestAction, advisoryRunsTest as runsTest, mandatoryCheckCoverage} from '../runtime/js/check-coverage.mjs';
|
|
12
12
|
import {git as safeGit} from '../runtime/js/cm-security/scan.mjs';
|
|
13
13
|
import {captureSpecificationMaterial} from '../runtime/js/cm-ai/specification-material.mjs';
|
|
14
|
-
import {readReviewBaseline} from '../runtime/js/cm-ai/review-package.mjs';
|
|
14
|
+
import {readReviewBaseline,captureReviewBaseline} from '../runtime/js/cm-ai/review-package.mjs';
|
|
15
|
+
import {taskReviewScope} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
16
|
+
import {codeProjectPaths,resolveCodeProjects} from '../runtime/js/cm-ai/code-projects.mjs';
|
|
15
17
|
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
16
18
|
import {acceptanceCoverage} from '../runtime/js/cm-ai/acceptance-contract.mjs';
|
|
19
|
+
import {featureHasBrowserCases,readBrowserCapability} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
17
20
|
|
|
18
21
|
// The whole check step of a current-session run is one host call with this deadline
|
|
19
22
|
// (runtime/js/cm-ai/host-conversation-execution.mjs, outerTimeoutMs). The test
|
|
@@ -35,6 +38,8 @@ const usage = '用法: cm-start-check.mjs --plan PLAN.json [--json] [--strict]\n
|
|
|
35
38
|
+ ' scope 改到代码根 TESTING.md「## 牵连测试」表里的路径,却没跑表里对应的旧界面测试——warn;\n'
|
|
36
39
|
+ ' 只跑了部分界面测试(-only-testing)而项目没有这张表——info(没能核对)\n'
|
|
37
40
|
+ ' 3. scope 内文件在代码根是否已有未提交改动——warn(Git 不可用时是 warn,不是 Git 仓库时是 info)\n'
|
|
41
|
+
+ ' 4. 按运行时同样的规则采一次审查基线:代码根文件总量超出审查清单上限(如被忽略的大构建目录没被排除)——error\n'
|
|
42
|
+
+ ' 5. 启用 QA 且 feature 有交互式用例时缺 --browser-qa 或声明无效;advance 会反问而 answers 目录里缺的答案文件——error\n'
|
|
38
43
|
+ '退出码:0 无 error(warn 只提示);1 有 error,或加 --strict 时有 warn;2 输入读不了或不支持。\n';
|
|
39
44
|
|
|
40
45
|
// Modes this check does not model: another check budget (provider), another scope rule
|
|
@@ -245,6 +250,81 @@ function checkDirtyScope(definition) {
|
|
|
245
250
|
|
|
246
251
|
// requiredTests comes from the caller's frozen approved contract, never from the
|
|
247
252
|
// mutable affected-test table or the developer's PLAN. Other warnings stay advisory.
|
|
253
|
+
// The runner captures this baseline when the run is created and again before
|
|
254
|
+
// each review package; a tree it refuses there stops the run after the develop
|
|
255
|
+
// answer was already written. Capture it here the same way, read-only.
|
|
256
|
+
export function checkReviewInventory(definition){
|
|
257
|
+
if(!fs.existsSync(definition.codeProject)||typeof definition.specsDir!=='string'||!definition.identity
|
|
258
|
+
||!Array.isArray(definition.requirements))return [];
|
|
259
|
+
try{
|
|
260
|
+
const codeProject=definition.codeProject;
|
|
261
|
+
captureReviewBaseline({root:codeProject,specsRoot:definition.specsDir,identity:definition.identity,
|
|
262
|
+
scope:taskReviewScope(definition.scope),requirements:definition.requirements,
|
|
263
|
+
...(typeof definition.feature==='string'?{specification:{specsRoot:definition.specsDir,feature:definition.feature}}:{}),
|
|
264
|
+
...(definition.codeProjects?{codeProjectPaths:codeProjectPaths(codeProject,resolveCodeProjects(codeProject,definition.codeProjects))}:{})});
|
|
265
|
+
return [];
|
|
266
|
+
}catch(error){
|
|
267
|
+
if(error.code==='limit_exceeded')return [{level:'error',code:'review_inventory_limit',
|
|
268
|
+
message:`运行时会拒绝这棵代码树:${error.message};把该路径移出代码根,或确认它被 Git 忽略且 git 能在 ${GIT_TIMEOUT_NOTE} 内列完被忽略的文件`}];
|
|
269
|
+
return [{level:'warn',code:'review_inventory_unchecked',message:`没能按运行时规则采集审查基线(${error.code??error.message}),开跑后可能在建运行时被拒`}];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const GIT_TIMEOUT_NOTE='120 秒';
|
|
273
|
+
|
|
274
|
+
// Both stopped Wue specs8 T-001 one advance at a time after earlier checks
|
|
275
|
+
// passed: the host refuses a launch without the session's interactive QA
|
|
276
|
+
// declaration, and the driver refuses an advance whose asked answers are missing.
|
|
277
|
+
// Same inputs and rules as cm-ai-host.mjs (readBrowserCapability) and
|
|
278
|
+
// cm-ai-drive.mjs (the advance asks for qa_assess, documentation_sync/inspect).
|
|
279
|
+
export function checkLaunchInputs(plan,planFile,definition){
|
|
280
|
+
const findings=[],base=path.dirname(path.resolve(planFile)),permissions=plan.permissions??[];
|
|
281
|
+
const value=flag=>{const at=permissions.indexOf(flag);return at===-1?undefined:permissions[at+1];};
|
|
282
|
+
const read=file=>{try{return JSON.parse(fs.readFileSync(path.resolve(base,file),'utf8'));}catch{return null;}};
|
|
283
|
+
const workflow=value('--workflow-config')===undefined?null:read(value('--workflow-config'));
|
|
284
|
+
const control=typeof plan.controlConfig==='string'?read(plan.controlConfig):null;
|
|
285
|
+
const qaEnabled=!control||control.qa!=='disabled';
|
|
286
|
+
// The host always validates the declaration: without interactive QA there are no
|
|
287
|
+
// carriers, and a stray --browser-qa is refused just the same.
|
|
288
|
+
if(typeof definition.specsDir==='string'&&typeof definition.feature==='string'){
|
|
289
|
+
let carriers=[];
|
|
290
|
+
if(workflow?.qa&&qaEnabled){
|
|
291
|
+
try{carriers=featureHasBrowserCases(definition.specsDir,definition.feature,definition.codeProject)?[workflow.qa.environment?.carrier??'browser']:[];}
|
|
292
|
+
catch{carriers=[];}
|
|
293
|
+
}
|
|
294
|
+
try{readBrowserCapability(value('--browser-qa'),carriers);}
|
|
295
|
+
catch(error){findings.push({level:'error',code:'browser_qa_declaration',
|
|
296
|
+
message:`宿主会拒绝启动(${error.code}):${error.reason??''} 在 PLAN.permissions 里加 --browser-qa available(本会话能跑 ${carriers.join('、')||'交互式'} QA 时)`});}
|
|
297
|
+
}
|
|
298
|
+
// 新版控制策略的重开必须带旧运行 inspect-history 给出的 supersedeTarget 文件(Wue specs8 T-003 重开白跑一轮)
|
|
299
|
+
if(control&&permissions.includes('--supersede-reviewed-evidence')){
|
|
300
|
+
const target=value('--supersede-target');
|
|
301
|
+
if(target===undefined||!fs.existsSync(path.resolve(base,target)))findings.push({level:'error',code:'supersede_target_missing',
|
|
302
|
+
message:'重开(--supersede-reviewed-evidence)需要 --supersede-target 文件:先对旧运行执行 cm-ai-run.mjs inspect-history --config 旧RUN.json,保存其中的 supersedeTarget'});
|
|
303
|
+
}
|
|
304
|
+
if(typeof plan.answers==='string'){
|
|
305
|
+
const root=path.resolve(base,plan.answers),need=[];
|
|
306
|
+
if(control&&control.qa!=='disabled'||!control&&workflow?.qa)need.push('qa-assess.json');
|
|
307
|
+
if(workflow?.documentationPaths?.length)need.push('documentation-sync.json');
|
|
308
|
+
if(workflow)need.push('documentation-inspect.json');
|
|
309
|
+
const has=name=>fs.existsSync(path.join(root,name));
|
|
310
|
+
// 首轮开发答案与驾驶员同一命名规则(drive-bootstrap.mjs attemptAnswerName):develop.json 或 develop-a1.json,二者不能并存
|
|
311
|
+
if(plan.mode==='create'){
|
|
312
|
+
if(has('develop.json')&&has('develop-a1.json'))findings.push({level:'error',code:'answers_conflict',
|
|
313
|
+
message:`develop.json 与 develop-a1.json 不能同时存在(${root})`});
|
|
314
|
+
else if(!has('develop.json')&&!has('develop-a1.json'))need.push('develop.json(或 develop-a1.json)');
|
|
315
|
+
}else if(has('develop.json')&&has('develop-a1.json')){
|
|
316
|
+
// A resume reads them only while the run is still on attempt 1; the check cannot
|
|
317
|
+
// know the attempt, so it warns instead of refusing a later-attempt resume.
|
|
318
|
+
findings.push({level:'warn',code:'answers_conflict',
|
|
319
|
+
message:`develop.json 与 develop-a1.json 同时存在(${root}):原运行仍在第 1 轮时驾驶员会拒绝,删掉其中一份`});
|
|
320
|
+
}
|
|
321
|
+
const missing=need.filter(name=>name.includes('(')||!has(name));
|
|
322
|
+
if(missing.length)findings.push({level:'error',code:'answers_missing',files:missing,
|
|
323
|
+
message:`advance 会反问而答案目录里没有:${missing.join('、')}(${root})`});
|
|
324
|
+
}
|
|
325
|
+
return findings;
|
|
326
|
+
}
|
|
327
|
+
|
|
248
328
|
export function checkMandatoryTests(plan, requiredTests) {
|
|
249
329
|
const coverage = mandatoryCheckCoverage({requiredTests,
|
|
250
330
|
commands: (Array.isArray(plan.checks) ? plan.checks : []).map(item => item?.command)});
|
|
@@ -298,7 +378,7 @@ export function startCheck(planFile, {requiredTests = []} = {}) {
|
|
|
298
378
|
message:'当前计划未完整包含冻结的必验检查;补齐检查,不能缩减批准的验收范围'});
|
|
299
379
|
}
|
|
300
380
|
return [...checkProtectedScope(definition.scope), ...checkChecks(plan), ...checkAffectedTests(plan, definition),
|
|
301
|
-
...checkMandatoryTests(plan, requiredTests), ...mandatory, ...checkDirtyScope(definition)];
|
|
381
|
+
...checkMandatoryTests(plan, requiredTests), ...mandatory, ...checkDirtyScope(definition), ...checkReviewInventory(definition), ...checkLaunchInputs(plan, planFile, definition)];
|
|
302
382
|
}
|
|
303
383
|
|
|
304
384
|
export function main(argv = process.argv.slice(2), out = process.stdout, err = process.stderr) {
|
|
@@ -6,7 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import test from 'node:test';
|
|
7
7
|
import {fileURLToPath} from 'node:url';
|
|
8
8
|
import {spawnSync} from 'node:child_process';
|
|
9
|
-
import {CHECK_CALL_LIMIT_MS, MAX_SCOPE_PATHS, startCheck, checkMandatoryTests} from './cm-start-check.mjs';
|
|
9
|
+
import {CHECK_CALL_LIMIT_MS, MAX_SCOPE_PATHS, startCheck, checkMandatoryTests, checkReviewInventory, checkLaunchInputs} from './cm-start-check.mjs';
|
|
10
10
|
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
11
11
|
|
|
12
12
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -479,3 +479,66 @@ test('B1 legacy empty-spec preflight keeps scope diagnostics without permitting
|
|
|
479
479
|
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.demo']}));
|
|
480
480
|
assert.equal(check(p).status,2,'an existing approval with missing source remains a hard input error');
|
|
481
481
|
});
|
|
482
|
+
|
|
483
|
+
// Wue specs8: a git query timed out on a 67 GB ignored build tree, the whole tree
|
|
484
|
+
// entered the review inventory and the run was refused only after the develop
|
|
485
|
+
// answer. The start check captures the same baseline first and reports it.
|
|
486
|
+
test('a code tree over the review inventory limit is an error before the run starts; a normal tree adds nothing', t => {
|
|
487
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cm-start-inventory-'));
|
|
488
|
+
t.after(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
489
|
+
const root = path.join(dir, 'code'), specs = path.join(dir, 'specs');
|
|
490
|
+
fs.mkdirSync(path.join(root, 'src'), {recursive: true});
|
|
491
|
+
fs.mkdirSync(specs);
|
|
492
|
+
fs.writeFileSync(path.join(root, 'src/a.js'), 'a\n');
|
|
493
|
+
const definition = {codeProject: root, specsDir: specs, scope: ['src/a.js'], requirements: ['src/a.js'],
|
|
494
|
+
identity: {repositoryId: 'r', runId: 'run-1', taskId: 'T-001', attempt: 1}};
|
|
495
|
+
assert.deepEqual(checkReviewInventory(definition), []);
|
|
496
|
+
// Sparse: the size check refuses it before any byte is read.
|
|
497
|
+
const big = path.join(root, 'build.bin');
|
|
498
|
+
fs.closeSync(fs.openSync(big, 'w'));
|
|
499
|
+
fs.truncateSync(big, 1024 * 1024 * 1024 + 1);
|
|
500
|
+
const findings = checkReviewInventory(definition);
|
|
501
|
+
assert.deepEqual(findings.map(item => [item.level, item.code]), [['error', 'review_inventory_limit']]);
|
|
502
|
+
assert.match(findings[0].message, /build\.bin/);
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
// Wue specs8 T-001: each of these stopped one advance after the start check had passed.
|
|
506
|
+
test('answers the advance will ask and an invalid interactive QA declaration are errors before launch', t => {
|
|
507
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'cm-start-launch-'));
|
|
508
|
+
t.after(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
509
|
+
const planFile = path.join(dir, 'PLAN.json'), answers = path.join(dir, 'answers');
|
|
510
|
+
fs.mkdirSync(answers);
|
|
511
|
+
fs.writeFileSync(path.join(dir, 'workflow.json'), JSON.stringify({qa: {commands: [], environment: {kind: 'web', carrier: 'browser'}},
|
|
512
|
+
documentationPaths: [], applicableAgentFiles: []}));
|
|
513
|
+
fs.writeFileSync(path.join(dir, 'POLICY.json'), JSON.stringify({version: 2, qa: 'run'}));
|
|
514
|
+
const definition = {codeProject: dir, specsDir: path.join(dir, 'specs'), feature: '1.f', scope: ['a.js']};
|
|
515
|
+
const plan = extra => ({config: 'RUN.json', mode: 'create', answers: 'answers', controlConfig: 'POLICY.json',
|
|
516
|
+
permissions: ['--workflow-config', 'workflow.json', ...extra]});
|
|
517
|
+
const missing = checkLaunchInputs(plan([]), planFile, definition);
|
|
518
|
+
assert.deepEqual(missing.map(item => item.code), ['answers_missing']);
|
|
519
|
+
assert.deepEqual(missing[0].files, ['qa-assess.json', 'documentation-inspect.json', 'develop.json(或 develop-a1.json)']);
|
|
520
|
+
for (const name of ['qa-assess.json', 'documentation-inspect.json', 'develop-a1.json']) fs.writeFileSync(path.join(answers, name), '{}');
|
|
521
|
+
assert.deepEqual(checkLaunchInputs(plan([]), planFile, definition), [], 'develop-a1.json is a valid first-round answer');
|
|
522
|
+
fs.writeFileSync(path.join(answers, 'develop.json'), '{}');
|
|
523
|
+
assert.deepEqual(checkLaunchInputs(plan([]), planFile, definition).map(item => item.code), ['answers_conflict']);
|
|
524
|
+
fs.rmSync(path.join(answers, 'develop-a1.json'));
|
|
525
|
+
assert.deepEqual(checkLaunchInputs(plan([]), planFile, definition), []);
|
|
526
|
+
// A v2 reopen without the old run's supersedeTarget file is refused by the driver: report it first.
|
|
527
|
+
assert.deepEqual(checkLaunchInputs(plan(['--supersede-reviewed-evidence', '--supersede-reason', 'r']), planFile, definition).map(item => item.code), ['supersede_target_missing']);
|
|
528
|
+
fs.writeFileSync(path.join(dir, 'target.json'), '{}');
|
|
529
|
+
assert.deepEqual(checkLaunchInputs(plan(['--supersede-reviewed-evidence', '--supersede-reason', 'r', '--supersede-target', 'target.json']), planFile, definition), []);
|
|
530
|
+
// No interactive cases in the feature: the host refuses a declaration it cannot use.
|
|
531
|
+
assert.deepEqual(checkLaunchInputs(plan(['--browser-qa', 'available']), planFile, definition).map(item => item.code),
|
|
532
|
+
['browser_qa_declaration']);
|
|
533
|
+
// Codex review: QA disabled by the policy, or no workflow at all: the host still refuses a stray declaration.
|
|
534
|
+
fs.writeFileSync(path.join(dir, 'POLICY.json'), JSON.stringify({version: 2, qa: 'disabled'}));
|
|
535
|
+
assert.deepEqual(checkLaunchInputs(plan(['--browser-qa', 'available']), planFile, definition).map(item => item.code),
|
|
536
|
+
['browser_qa_declaration']);
|
|
537
|
+
assert.deepEqual(checkLaunchInputs({config: 'RUN.json', mode: 'create', permissions: ['--browser-qa', 'available']}, planFile, definition)
|
|
538
|
+
.map(item => item.code), ['browser_qa_declaration']);
|
|
539
|
+
assert.deepEqual(checkLaunchInputs({config: 'RUN.json', mode: 'create', permissions: []}, planFile, definition), []);
|
|
540
|
+
// Codex review: a resume reads the first-round answer only while still on attempt 1, so both files warn.
|
|
541
|
+
fs.writeFileSync(path.join(answers, 'develop-a1.json'), '{}');
|
|
542
|
+
const resumed = checkLaunchInputs({...plan([]), mode: 'resume'}, planFile, definition).filter(item => item.code === 'answers_conflict');
|
|
543
|
+
assert.deepEqual(resumed.map(item => item.level), ['warn']);
|
|
544
|
+
});
|
|
@@ -115,7 +115,8 @@ test('rule 4: no task may wait for the session task, directly or through another
|
|
|
115
115
|
test('only exact relative file paths in backticks are accepted',()=>{
|
|
116
116
|
for(const bad of ['src/*.js','src/','/etc/passwd','../x.js','a/./b.js','a\\b.js','AGENTS.md','.git/config','x?.js'])
|
|
117
117
|
assert.equal(validScopePath(bad),false,bad);
|
|
118
|
-
|
|
118
|
+
// expo-router / Next.js dynamic routes are real files; brackets are literal (git calls use :(literal)).
|
|
119
|
+
for(const good of ['README.md','src/deep/file.test.mjs','docs/中文.md','app/reminder/[id].tsx','app/[...slug]/page.tsx'])assert.equal(validScopePath(good),true,good);
|
|
119
120
|
const {errors}=parseTaskScopes(tasksText(['- [ ] T-001: a',' - 范围: src/a.js','- [ ] T-002: b',' - 范围: `src/*.js`',
|
|
120
121
|
'- [ ] T-003: c',' - 范围: `a.js`, `a.js`','- [ ] T-004: d',' - 范围: `a.js`',' - 范围: `b.js`']));
|
|
121
122
|
assert.deepEqual(errors.map(item=>item.taskId),['T-001','T-002','T-003','T-004']);
|
|
@@ -173,7 +174,7 @@ const draft=(tasks)=>({draftDigest:'d',features:[{directory:'1.sample',name:'sam
|
|
|
173
174
|
const codes=report=>report.findings.map(item=>item.code);
|
|
174
175
|
|
|
175
176
|
test('rule 3: every task of a new draft must declare its files; earlier rules do not ask',()=>{
|
|
176
|
-
assert.equal(PRD_SELF_CHECK_RULES,
|
|
177
|
+
assert.equal(PRD_SELF_CHECK_RULES,5,'rules 4 and 5 keep the rule-3 scope check');
|
|
177
178
|
const without=draft('- [ ] T-001: a\n- [ ] T-002: b\n - 范围: `b.js`\n');
|
|
178
179
|
const report=checkPrdDraftMechanics(without,{rules:3});
|
|
179
180
|
assert.deepEqual(codes(report),['task_scope_missing']);
|
|
@@ -47,6 +47,7 @@ CM_AI_RUNTIME = (
|
|
|
47
47
|
"review-package.mjs",
|
|
48
48
|
"review-result.schema.json",
|
|
49
49
|
"review-runner.mjs",
|
|
50
|
+
"spec-amendment.mjs",
|
|
50
51
|
"task-commit-codec.mjs",
|
|
51
52
|
"task-commit.mjs",
|
|
52
53
|
"task-owner.mjs",
|
|
@@ -79,6 +80,8 @@ REQUIRED = (
|
|
|
79
80
|
"scripts/cm-ai-run.test.mjs",
|
|
80
81
|
"docs/js-workflow-control.md",
|
|
81
82
|
"scripts/cm-ai-admission.test.mjs",
|
|
83
|
+
"scripts/cm-spec-amend.mjs",
|
|
84
|
+
"scripts/cm-spec-amend.test.mjs",
|
|
82
85
|
"scripts/cm-check-runtime.sh",
|
|
83
86
|
"scripts/cm-check-runtime.ps1",
|
|
84
87
|
"scripts/cm-release-smoke.sh",
|
|
@@ -105,6 +108,7 @@ REQUIRED = (
|
|
|
105
108
|
"scripts/cm-autonomy.mjs",
|
|
106
109
|
"scripts/cm-autonomy.test.mjs",
|
|
107
110
|
"runtime/js/autonomy.mjs",
|
|
111
|
+
"runtime/js/acceptance-language.mjs",
|
|
108
112
|
"runtime/js/notify-send.mjs",
|
|
109
113
|
"scripts/cm-workflow-config.mjs",
|
|
110
114
|
"scripts/cm-workflow-config.test.mjs",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
|
|
57
57
|
- `--approve` 不接受 `--yes`;只读调用的 `--yes` 也不写审批位。
|
|
58
58
|
- 只有 `awaiting_spec_approval` + `explicit` 且 reason 为 `approval_write_required`、`spec_features_changed` 或 `test_cases_changed` 才写;其余返回原准入结果及 `approveRefused`,不得手改 JSON 绕过。
|
|
59
|
-
- `blocked/spec_drift` →
|
|
59
|
+
- `blocked/spec_drift` → 先按下节「执行中补正分级」运行 `inspect`;0/1 级按该节换绑,2 级保留原状态,要求用 `$cm-prd --change` 说明变更并重新发布摘要。不得手改 `awaiting_review` 或刷新 manifest。manifest 先于测试合同校验,测试合同修改也可能先触发 `spec_drift`。
|
|
60
60
|
|
|
61
61
|
共享 JS writer 生成 `features`、`specFiles`、`testCases` 和审批记录,原样沿用旧 `summaryDigest`,缺失时写 `null`。
|
|
62
62
|
写完返回重跑准入的结果;只有 `ready` 才进入开发,写成 approved 不代表其他检查已通过。
|
|
@@ -64,6 +64,28 @@
|
|
|
64
64
|
需要单独核验批准 manifest 时,可只读运行 `python3 {CM_WORKFLOW_ROOT}/scripts/cm-spec-manifest.py {SPECS_DIR} --status-file {SPECS_DIR}/.cm-specs-status`;失败不授权改写。
|
|
65
65
|
N5/N6 的任务与 AC checkbox 变化仍由现有 manifest 规范化处理,文案、ID、设计和测试合同变化继续受准入保护。
|
|
66
66
|
|
|
67
|
+
## 执行中补正分级
|
|
68
|
+
|
|
69
|
+
首次请用户回复“开始”时,摘要卡末尾加一行:「执行中的补漏(不改需求、设计和验收标准)由独立审查者审过后自动生效,你会收到通知。」
|
|
70
|
+
用户要逐次批准时,写入口加 `--no-spec-amend`。批准写入同时保存 `{SPECS_DIR}/.cm-specs-approved.json` 快照,后续补正与它比对。
|
|
71
|
+
|
|
72
|
+
开发中途改了规格(准入报 `awaiting_spec_approval` 且此前已批准过,或 `blocked/spec_drift`)→ 先只读运行:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
node "{CM_WORKFLOW_ROOT}/scripts/cm-spec-amend.mjs" inspect --specs-dir "{SPECS_DIR}"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| `tier` | 含义 | 动作 |
|
|
79
|
+
| ---- | ---- | ---- |
|
|
80
|
+
| `0` | tasks.md 只追加了「版本」表格行 | `apply --reason "{原因}"`,不审查、不问用户 |
|
|
81
|
+
| `1` | 需求、设计、已有用例、已完成任务都没变;新任务引用已有 AC | `prepare --out {空目录}` → 把 `review-prompt.md` 交新上下文审查者 → `apply --reason --review-output {审查完整输出} --reviewer "{审查者与模型}"`;生效后下一条消息告诉用户改了什么,不等回复 |
|
|
82
|
+
| `2` | 其余一切,或快照缺失/不符、策略关闭、本次人工批准后已补正 3 次 | 回到上节:展示摘要,请用户回复“开始” |
|
|
83
|
+
|
|
84
|
+
- 审查者不能是写补正的会话;宿主要求跨工具审查时按宿主规则选审查者。审查判 `changes_requested` 或摘要不符时 `apply` 拒绝,转 2 级。
|
|
85
|
+
- `apply` 只换绑规格批准,保留原 `approval.response`;在途运行仍按 `js-host.md` 的 `spec_rebind` 规则换绑或重做。
|
|
86
|
+
- 不得手改 `.cm-specs-approved.json` 和 `~/.cm-workflow/spec-approvals/` 下的批准台账;被改过即失效,退回 2 级。`apply` 报 `spec_approval_busy` 时等对方批准结束再试,不删锁文件;持续报错时把 `.cm-specs-approval.lock` 与 `.cm-specs-approval.lock.reclaim` 里的 pid 告诉用户,由用户确认没有批准或补正在运行后自行删除(崩溃遗留不自动清理)。
|
|
87
|
+
- 机器条件与理由见 `docs/proposals/spec-amendment-tiers.md`。快照与回执只绑定内容,不证明是谁写的,保障级别同 `.cm-specs-status`(实跑教训:wue、aihot-dev 两个会话 17 次“开始”里 16 次是开发中补规格)。
|
|
88
|
+
|
|
67
89
|
多任务批次的并行组提议规则见 `js-host.md` 第 3.1 条;本兼容流程不自行发明并行判定。
|
|
68
90
|
|
|
69
91
|
> 这是**入口授权门**(人把关方案端),不属于"暂停仅灾难级"约束的中途暂停,也不计入 METRICS 人工介入。实跑教训:没有这道闸,prd 生成完会被一句"继续"顺势带进开发,人审形同虚设。
|
|
@@ -26,7 +26,8 @@ QA 修复子操作使用原已配置 `qaFix:"manual"|"auto"`;先 fix_status
|
|
|
26
26
|
|
|
27
27
|
## 补挂 QA
|
|
28
28
|
|
|
29
|
-
**v2:**
|
|
29
|
+
**v2:** 不能用 legacy 权限绕开策略/配置指纹。单任务运行用 `qa:"disabled"` 创建并已到 `fixture_completed`(含停在 `qa_triggered/pendingAction:qa_execution`)时,可补开一次 QA:`--mode resume` 换一份只把 `qa` 改为 `run`、其余字段逐字不变的策略,并带含 `qa` 的 `--workflow-config`;不带 `--allow-*` 或 `--expected-control`。宿主按原策略与去掉 QA 的原配置核对原指纹,追加 `qa-attached`、日志写 `decision/qa_attach`,存档原策略不改写,再按原 N6 门禁跑 QA。补开那次不能并用其他启动恢复(`invalid_input`);之后普通恢复用补开后的策略与当前绑定的 QA 配置,不能关回 disabled,显式 QA 配置修订仍走下方原入口。任务未完成报 `qa_attach_not_completed`,策略其他字段也变报 `fingerprint_mismatch`,缺 QA 工作流报 `invalid_arguments`(驾驶员可能启动前拒绝);批次成员未覆盖。完整合同见 [control policy v2](../../../docs/cm-control-policy-v2.md)「已完成运行补开 QA」(事故:AI潮 specs7 按本节旧说法以为 v2 无补开入口,五个 feature 收不了尾)。
|
|
30
|
+
没给 `--workflow-config` 的 v2 运行也有 `qa_assess` 判定;隐式 QA 判定修复前创建的这类运行,按原策略、原配置恢复时照原样打开,仍停在 `qa_decision_required`;已到 `fixture_completed` 的仍可按上段在原 run 补开 QA,不满足补开前提时才按「卡死任务重开」用新 runId 重做。下面一次性附加步骤仅用于 legacy 的原运行。
|
|
30
31
|
|
|
31
32
|
legacy:原无workflow或`qa:null`且任务已为`fixture_completed`时,可在`--mode resume`显式提供
|
|
32
33
|
含QA的`--workflow-config`与`--allow-qa`,一次性附加N6;原definition/scope/requirements/identity、
|
|
@@ -172,7 +173,7 @@ node scripts/cm-ai-host.mjs serve --config run.json --mode resume \
|
|
|
172
173
|
|
|
173
174
|
## 项目收尾核对全部 feature 的 QA
|
|
174
175
|
|
|
175
|
-
**v2:** 同一finalizer仍要求所有必需QA完整PASS。允许的单任务恢复用上述launch target,子修复恢复用fix_status的含child目标;没有QA/最新skipped
|
|
176
|
+
**v2:** 同一finalizer仍要求所有必需QA完整PASS。允许的单任务恢复用上述launch target,子修复恢复用fix_status的含child目标;没有QA/最新skipped不能当通过。`qa:"disabled"` 建的末任务停在 qa_triggered 时,对该运行按上方「补挂 QA」做 v2 补开,PASS 后再对本运行 advance。补开不适用、确需重开末任务时,只能走 [control policy v2](../../../docs/cm-control-policy-v2.md)「卡死任务重开:v2 create supersede」受控入口(人工批准、tasks 未勾选、旧 writer 已关闭、无未结 effect、固定前驱目标等前提不变);不照下面legacy步骤改tasks或切协议。都不适用时保留project_qa_not_passed并报告缺口。
|
|
176
177
|
|
|
177
178
|
`finish` 与 `run_finalize` 在写 run_done 前核对每个已批准 feature 最新一次 QA 决策:触发的 QA 必须以完整 PASS 结束,
|
|
178
179
|
阻塞决策不算通过。任一 feature 最新一轮 FAIL、BLOCKED、已触发未执行、结果未知或旧结果已作废待下一轮时,返回
|
|
@@ -343,10 +343,11 @@ worker 异常、超时或传输歧义仍是 `unknown`,旧 unknown 历史不自
|
|
|
343
343
|
|
|
344
344
|
已完成运行的 QA 恢复、QA 修复、配置修订和收尾先核对原审查包。代码树已变化时,只接受两类变化:同一代码根与仓库中
|
|
345
345
|
其他任务已完成并已提交运行的审查交付(及其已登记的 QA 修复)——包括其 AGENTS.md 教训行和对本任务文件的修改;以及
|
|
346
|
-
本任务范围外的项目根 CM
|
|
346
|
+
本任务范围外的项目根 CM 配置文件,以及代码根 `.cm-user-maintained.json`(`{"version":1,"paths":["Baseline/glass-verdicts.json"]}`)逐个声明的用户手工维护文件和该声明本身(同样只限本任务范围外,大小写不敏感比较;只用于没有已接受 QA 修复的已完成运行,QA 修复链与集成接纳仍严格;只收代码根下的相对普通文件路径,不收目录、通配、`.git/`、`.env`、`AGENTS.md`/`CLAUDE.md`、CM 配置;声明不能被忽略规则排除,核对期间被替换即拒绝;声明无效时什么都不容忍,`reason` 说明原因;事故:AI潮用户直接提交的玻璃放行记录让已完成运行永远无法收尾)。规则是确定的:审查时间晚于本运行批准审查的这类交付全部按审查时间排序、逐个严格接续
|
|
347
347
|
(所改路径的审查前状态必须等于当时的组合),本运行的 QA 修复按其最终审查时间插在同一序列中;不挑选、不搜索、不设
|
|
348
348
|
上限;最终组合必须与当前内容和文件权限完全一致。其余变化,包括对本任务交付文件、需求文件或其他文件的未审改动(例如
|
|
349
349
|
已审 A→B→A 之后手工改回 B),仍返回 `correction_review_required`,`reason` 列出未解释的路径。同一任务的替代运行、
|
|
350
|
+
(同一任务指同一 feature 的 `tasks.md` 加同一任务编号;其他 feature 同编号任务的已审交付照常采纳,旧运行缺 `tasks.md` 记录时仍只按编号排除;事故:AI潮 specs7 各 feature 都从 T-001 编号,误把别的 feature 的 T-005 当作替代运行)
|
|
350
351
|
未完成运行和并行批次成员(工作树根不同)的改动不被采纳。同一代码根上独立的 `cm-fix` 运行正常收尾(最终审查批准该包、`task_done` 与 `run_done` 已绑定)后也算已审交付,按其最终审查登记时间排序;进行中、放弃、取消或升级的不算,QA 修复子运行只经父运行接受计入。接受 QA 修复时,尚未记录且审查早于该修复最终审查的已完成交付排在它之前,以 version 2 关联记录(`laterDeliveries`,
|
|
351
352
|
只含运行 ID、包摘要与位于第几次修复之前)存进 journal,逐文件变化每次从已核实的存档读出;记录此后不变,其余交付(含审查
|
|
352
353
|
早于修复、但在接受之后才提交的交付)一律排在最后一次修复之后现场接续。记录里的交付须仍是所列运行已完成、且审查晚于本运行
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
“可以开始”“确认开始”“开始执行”“现在开始”“可以,请开始开发”(允许尾部中英文句末标点与空白)视为
|
|
9
9
|
明确开始;“继续”“可以”“好”“好的”“OK”“按最优解处理”“你看着办”“行”仍不审批。
|
|
10
10
|
`not_approval` 时提示明确回复“开始”;写审批位仍须原 `--approve` 门禁。
|
|
11
|
-
|
|
11
|
+
开发中途要改规格(越界、扩范围、补修复点)时先跑 `scripts/cm-spec-amend.mjs inspect`:0/1 级按
|
|
12
|
+
[N1 执行中补正分级](N1-init.md#执行中补正分级) 换绑,不再等“开始”。2 级不先问是否走规格变更:直接起草变更提案,按
|
|
12
13
|
`cm-prd/references/js-change-recovery.md`「一次确认」只展示一张卡、只等一次“开始”,再用
|
|
13
14
|
`--expect-revision-digest` 把审批绑到这份提案;卡上写明的后续动作(如替代运行)随之放行,不再逐步确认。
|
|
14
15
|
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
2. 用户疑问以`advance {text}`真实回答。`change_requirements`、`change_design`、`change_tasks`
|
|
13
13
|
各用一次advance推进。`prd_generate`执行C5、C6、C7/C7.5:前阶段产物与清单必须原样带入下一阶段。
|
|
14
14
|
问题未解决仍停当前阶段;不要把提示的问题当答案。生成器只返回当前请求列明的正文,不写文件。
|
|
15
|
+
`change_tasks` 回包里,已有 feature 未改动的文档可以省略:省略的需求/设计按前两阶段已接受的原字节补回,`tasks.md` 与(`testCasesReason` 为 null 时的)`test-cases.json` 按原稿补回;64 KiB 上限只算实际回的文档。新 feature 仍须完整;要删除用例合同照旧写非 null 的 `testCasesReason`。
|
|
15
16
|
3. `change_check`用advance执行原自检。仅失败可修正,最多两次任务稿;不是独立审查或自动批准。
|
|
16
17
|
`change_confirmation`向用户展示proposal的summary、增改删文件/feature、completed保留数、
|
|
17
18
|
`changedUserCases`逐条内容与未决项。确认前不覆盖规格。
|