@aibyzero/cm-workflow 0.21.1 → 0.21.3
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 +19 -0
- package/README.md +13 -1
- package/VERSION +1 -1
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +6 -1
- package/package.json +1 -1
- package/runtime/js/cm-ai/call-timeout.mjs +21 -0
- package/runtime/js/cm-ai/checkpoint-package-material.mjs +3 -2
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +5 -1
- package/runtime/js/cm-ai/codex-config.mjs +6 -1
- package/runtime/js/cm-ai/durable-runner-state.mjs +19 -4
- package/runtime/js/cm-ai/fix-code-association.mjs +5 -5
- package/runtime/js/cm-ai/host-conversation-execution.mjs +22 -15
- package/runtime/js/cm-ai/host-documentation.mjs +4 -3
- package/runtime/js/cm-ai/host-handoff.mjs +3 -2
- package/runtime/js/cm-ai/host-project-execution.mjs +11 -9
- package/runtime/js/cm-ai/host-qa-executor.mjs +3 -2
- package/runtime/js/cm-ai/host-replay.mjs +28 -8
- package/runtime/js/cm-ai/review-package.mjs +101 -33
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
- package/runtime/js/cm-ai/reviewed-integration.mjs +1 -1
- package/runtime/js/cm-ai/spec-amendment.mjs +20 -0
- package/runtime/js/cm-ai/symlink-material.mjs +153 -0
- package/runtime/js/cm-ai/task-commit.mjs +6 -3
- package/runtime/js/cm-ai/task-runner.mjs +14 -6
- package/runtime/js/cm-ai/worker-claude-developer.mjs +19 -7
- package/runtime/js/cm-ai/worker-codex-developer.mjs +3 -1
- package/runtime/js/cm-fix/protected-edits.mjs +57 -36
- package/runtime/js/cm-prd/change.mjs +4 -1
- package/runtime/js/cm-prd/review-findings.mjs +3 -2
- package/runtime/js/cm-prd/review-publication.mjs +3 -2
- package/runtime/js/cm-prd/split-design.mjs +4 -4
- package/scripts/ci-test-weights.json +1 -0
- package/scripts/cm-ai-admission.test.mjs +5 -5
- package/scripts/cm-ai-batch-drive.mjs +9 -5
- package/scripts/cm-ai-call-timeout.test.mjs +85 -0
- package/scripts/cm-ai-control-launch.test.mjs +18 -0
- package/scripts/cm-ai-drive.mjs +142 -43
- package/scripts/cm-ai-host.mjs +15 -3
- package/scripts/cm-ai-host.test.mjs +3 -1
- package/scripts/cm-ai-launch-diagnostics.test.mjs +23 -0
- package/scripts/cm-ai-review-failure.test.mjs +3 -0
- package/scripts/cm-ai-run.mjs +2 -1
- package/scripts/cm-ai-scope-revision.test.mjs +35 -3
- package/scripts/cm-ai-supersede.test.mjs +51 -3
- package/scripts/cm-ai-symlink.test.mjs +481 -0
- package/scripts/cm-codex-developer-worker.test.mjs +13 -1
- package/scripts/cm-notify-command.test.mjs +3 -0
- package/scripts/cm-notify.test.mjs +3 -0
- package/scripts/cm-patrol.test.mjs +3 -0
- package/scripts/cm-prd-design-phase.test.mjs +31 -0
- package/scripts/cm-prd-review-gate.mjs +28 -3
- package/scripts/cm-prd-summary.test.mjs +5 -5
- package/scripts/cm-skill-hints.mjs +40 -16
- package/scripts/cm-skill-hints.test.mjs +91 -0
- package/scripts/cm-spec-amend.test.mjs +107 -1
- package/scripts/cm-specs-status.test.mjs +5 -5
- package/scripts/cm-start-check.mjs +53 -15
- package/scripts/cm-start-check.test.mjs +41 -2
- package/scripts/cm-task-gate.mjs +42 -13
- package/scripts/cm-task-gate.test.mjs +33 -0
- package/scripts/cm-tool-preview-context.test.mjs +20 -1
- package/scripts/cm-upgrade-compat.test.mjs +7 -0
- package/skills/cm-ai/references/js-host.md +1 -0
- package/skills/cm-prd/SKILL.md +14 -27
- package/skills/cm-prd/references/change-mode.md +2 -0
- package/skills/cm-prd/references/cm-optout.md +11 -0
- package/skills/cm-prd/references/context-scope.md +2 -1
- package/skills/cm-prd/references/js-host.md +2 -2
- package/skills/cm-prd/references/requirement-grilling.md +116 -0
- package/skills/cm-product-manager/SKILL.md +13 -1
|
@@ -8,7 +8,8 @@ import {TextDecoder} from 'node:util';
|
|
|
8
8
|
import {fileURLToPath} from 'node:url';
|
|
9
9
|
import {acceptsPrdSplitDesign} from '../runtime/js/cm-prd/split-design.mjs';
|
|
10
10
|
import {inspectPrdFailedCorrection} from '../runtime/js/cm-prd/failed-correction.mjs';
|
|
11
|
-
import {normalizeRuntimeMarks} from './cm-spec-manifest.mjs';
|
|
11
|
+
import {normalizeRuntimeMarks,normalizeRuntimeMarkBytes} from './cm-spec-manifest.mjs';
|
|
12
|
+
import {APPROVED_SPEC_FILES} from '../runtime/js/cm-ai/spec-amendment.mjs';
|
|
12
13
|
import {tagDiagnosticReason} from '../runtime/js/cm-ai/diagnostic-reason.mjs';
|
|
13
14
|
|
|
14
15
|
// Messages stay byte-identical for the CLI and its Python oracle. Hosts get a stable
|
|
@@ -135,6 +136,11 @@ function loadReceipt(file,args,evidence){
|
|
|
135
136
|
if(value.disposition==='self_check_failed')need(value.stage==='split','prd_failed_check_split_only','prd_failed_check_split_only',where);
|
|
136
137
|
need(Array.isArray(value.artifacts)&&value.artifacts.length>0,'PRD review receipt must contain artifact hashes','prd_review_receipt_invalid',where);
|
|
137
138
|
const root=resolve(path.dirname(path.dirname(file))),seen=new Set();
|
|
139
|
+
// Change mode only (assertPrdReviewsSettled): the bytes the latest human approval bound,
|
|
140
|
+
// as re-bound by applied amendments, path -> runtime-mark-normalized sha256. It stands in
|
|
141
|
+
// for this receipt's fingerprints only; every other receipt and split-binding check runs.
|
|
142
|
+
const approved=args.approvedBaseline instanceof Map?args.approvedBaseline:null;
|
|
143
|
+
const normalizedSha=(bytes,name)=>createHash('sha256').update(normalizeRuntimeMarkBytes(bytes,name)).digest('hex');
|
|
138
144
|
for(const item of value.artifacts){
|
|
139
145
|
need(keys(item,['path','sha256'])&&typeof item.path==='string'&&typeof item.sha256==='string'
|
|
140
146
|
&&/^[0-9a-f]{64}$/.test(item.sha256),'PRD review receipt contains an invalid artifact','prd_review_receipt_invalid',where);
|
|
@@ -144,6 +150,11 @@ function loadReceipt(file,args,evidence){
|
|
|
144
150
|
const named=()=>({receipt,artifact:item.path});
|
|
145
151
|
const raw=path.join(root,item.path);need(!link(raw),'PRD review artifact is missing or unsafe','prd_review_artifact_unsafe',named);
|
|
146
152
|
const artifact=resolve(raw);need(within(root,artifact),'PRD review artifact escapes the specs directory','prd_review_artifact_unsafe',named);
|
|
153
|
+
// Only the optional test-cases.json may be gone, and only when the approved round of a
|
|
154
|
+
// feature it binds no longer lists it; the whole-set check below enforces that round.
|
|
155
|
+
const parts=item.path.split('/');
|
|
156
|
+
if(!stat(artifact)&&approved!==null&&parts.length===2&&parts[1]==='test-cases.json'&&!approved.has(item.path)
|
|
157
|
+
&&approved.has(`${parts[0]}/design.md`)){value.approvedBaselineAccepted=true;continue;}
|
|
147
158
|
need(stat(artifact)?.isFile(),'PRD review artifact is missing or unsafe','prd_review_artifact_unsafe',named);
|
|
148
159
|
const bytes=bytesOf(artifact,'prd_review_artifact_unsafe',named());
|
|
149
160
|
const currentSha=createHash('sha256').update(bytes).digest('hex');
|
|
@@ -151,8 +162,9 @@ function loadReceipt(file,args,evidence){
|
|
|
151
162
|
&&stat(path.join(path.dirname(file),`prd-${value.feature}-split-disposition.json`));
|
|
152
163
|
if(currentSha!==item.sha256||completedSplit){
|
|
153
164
|
const accepted=acceptsPrdSplitDesign({specs:root,evidence:path.relative(root,evidence).split(path.sep).join('/'),
|
|
154
|
-
receipt:value,item,currentSha,pendingSplit:args.pendingSplit??null});
|
|
165
|
+
receipt:value,item,currentSha,pendingSplit:args.pendingSplit??null,approvedBaseline:approved});
|
|
155
166
|
if(accepted===true)continue;
|
|
167
|
+
if(approved?.has(item.path)&&normalizedSha(bytes,path.basename(artifact))===approved.get(item.path)){value.approvedBaselineAccepted=true;continue;}
|
|
156
168
|
if(completedSplit&&accepted!==null)need(false,'prd_design_receipt_changed','prd_design_receipt_changed',named);
|
|
157
169
|
if(currentSha===item.sha256)continue;
|
|
158
170
|
const text=bytes.toString('utf8');
|
|
@@ -163,6 +175,19 @@ function loadReceipt(file,args,evidence){
|
|
|
163
175
|
value.runtimeMarksNormalized=true;
|
|
164
176
|
}
|
|
165
177
|
}
|
|
178
|
+
// Once any file leans on the approved round, every file of the receipt's features must be
|
|
179
|
+
// exactly that round: old receipt bytes cannot be mixed with newly approved ones.
|
|
180
|
+
if(value.approvedBaselineAccepted){
|
|
181
|
+
// Every spec file the approval binds, present or not; other receipt artifacts were
|
|
182
|
+
// already held to the receipt's own fingerprints above.
|
|
183
|
+
const features=[...new Set(value.artifacts.map(item=>item.path.split('/')).filter(parts=>parts.length>1&&/^\d+\./.test(parts[0])).map(parts=>parts[0]))].sort();
|
|
184
|
+
for(const row of features.flatMap(feature=>APPROVED_SPEC_FILES.map(name=>`${feature}/${name}`))){
|
|
185
|
+
const target=path.join(root,row),present=stat(target);
|
|
186
|
+
need(!link(target)&&(present===null||present.isFile()),'PRD review artifact is missing or unsafe','prd_review_artifact_unsafe',()=>({receipt,artifact:row}));
|
|
187
|
+
const current=present===null?undefined:normalizedSha(bytesOf(target,'prd_review_artifact_unsafe',{receipt,artifact:row}),path.basename(row));
|
|
188
|
+
need(current===approved.get(row),'PRD review artifact changed after disposition','prd_review_artifact_changed',()=>({receipt,artifact:row}));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
166
191
|
if(value.disposition==='self_check_failed')inspectPrdFailedCorrection({specs:root,receipt:value});
|
|
167
192
|
return value;
|
|
168
193
|
}
|
|
@@ -272,7 +297,7 @@ export function inspectPrdReview(args){
|
|
|
272
297
|
{...base,outcome:'dispatch_once'};
|
|
273
298
|
evidenceHeader(evidence);if(!stat(receipt))return {...base,outcome:'resume_disposition'};
|
|
274
299
|
const value=loadReceipt(receipt,args,evidence);return {...base,outcome:'completed',disposition:value.disposition,
|
|
275
|
-
...(value.runtimeMarksNormalized?{runtimeMarksNormalized:true}:{})};
|
|
300
|
+
...(value.runtimeMarksNormalized?{runtimeMarksNormalized:true}:{}),...(value.approvedBaselineAccepted?{approvedBaseline:true}:{})};
|
|
276
301
|
}
|
|
277
302
|
export function recordPrdReview(args){
|
|
278
303
|
counts(args.disposition,args.finding_count,args.unresolved_count,typeof args.receipt==='string'?reviewFile(args.receipt):null);
|
|
@@ -16,11 +16,11 @@ import {loadConfig} from './cm-workflow-config.mjs';
|
|
|
16
16
|
import {TASK_GRAMMAR} from '../runtime/js/spec-task-line.mjs';
|
|
17
17
|
import {writeSpecsStatus} from '../runtime/js/specs-status.mjs';
|
|
18
18
|
// Spec approvals write a round ledger under CM_WORKFLOW_HOME; keep it off the real home.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
19
|
+
// Always, not only when unset: an exported CM_WORKFLOW_HOME may be the tester's real home
|
|
20
|
+
// (review 2026-11-17: these suites left 11 approval records in an externally named home).
|
|
21
|
+
const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-approval-home-'));
|
|
22
|
+
process.env.CM_WORKFLOW_HOME=isolatedHome;
|
|
23
|
+
process.on('exit',()=>fs.rmSync(isolatedHome,{recursive:true,force:true}));
|
|
24
24
|
const sha=content=>createHash('sha256').update(content).digest('hex');
|
|
25
25
|
function fixture(t,{pendingCorrection=false,mandatory=false}={}){
|
|
26
26
|
const specs=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-prd-summary-marks-')));
|
|
@@ -161,31 +161,54 @@ export const stripCode=text=>text.replace(/```[\s\S]*?(?:```|$)/g,' ');
|
|
|
161
161
|
// Real misfire: "不要换个会话,继续当前任务" told the model to start handoff.
|
|
162
162
|
// Quoted or inline-code words are being talked about, not asked for. ASCII ' is left
|
|
163
163
|
// alone because English contractions use it.
|
|
164
|
-
|
|
164
|
+
// Quotes never span lines, so an unclosed “ cannot swallow the rest of a message (todo from PR #265).
|
|
165
|
+
// A quote never opens twice, so a stray “ pairs with nothing; ’ inside an English word (don’t) is an
|
|
166
|
+
// apostrophe, not the closing quote (review r1).
|
|
167
|
+
const QUOTED=[/`[^`\n\r\u2028\u2029]*`/g,/“[^“”\n\r\u2028\u2029]*”/g,/「[^「」\n\r\u2028\u2029]*」/g,/『[^『』\n\r\u2028\u2029]*』/g,/"[^"\n\r\u2028\u2029]*"/g,
|
|
168
|
+
// Single quotes go last and never reach into another quote, so ‘ and ’ from two different quotes
|
|
169
|
+
// cannot pair up (review r2).
|
|
170
|
+
/‘(?:[^‘’“”「」『』\n\r\u2028\u2029]|’(?=[a-zA-Z]))*’(?![a-zA-Z])/g];
|
|
165
171
|
export const stripQuoted=text=>QUOTED.reduce((out,re)=>out.replace(re,' '),text);
|
|
166
172
|
// A negation masks only the few characters (Chinese) or words (English) right after it,
|
|
167
173
|
// within its own clause: "不要继续当前任务,换个会话交接" still asks for a handoff.
|
|
168
174
|
// "别忘了/不要忘了/别忘记" mean "do", so a negation followed by 忘 is not one.
|
|
169
175
|
export const NEGATION_WINDOW={zh:4,en:3};
|
|
170
|
-
const CLAUSE_END=/[,,。.!!??;;::\n]/;
|
|
176
|
+
const CLAUSE_END=/[,,。.!!??;;::\n\r\u2028\u2029]/;
|
|
177
|
+
// After a condition word in the same clause, 就 starts the consequence: "如果不需要测试就换个会话交接"
|
|
178
|
+
// (review r1). Without one, 就 is just "right away": "不要现在就换个会话交接" stays negated (review r2).
|
|
179
|
+
// 就 right after a time word (现在就/马上就) means "right away" and stays inside the negation (review r4b).
|
|
180
|
+
// A lone 这 is left out: 这就 (right away) and 放这就 (put it here, then) cannot be told apart here (review r5).
|
|
181
|
+
const RIGHT_AWAY=/(?:现在|马上|立刻|立即|立马|今天)$/;
|
|
182
|
+
// A lone 若 counts only right before the negation (若不用…); elsewhere it may be a name like 若琳 (review r4).
|
|
183
|
+
const ZH_CONDITION=/(?:如果|要是|假如|假设|万一|倘若|若是|(?<![宛仿犹恍])若$)(?![^就]*就)/;
|
|
171
184
|
// A lone 别 inside a word (别人、特别、分别、区别、告别、别名…) is not a negation (review r1),
|
|
172
|
-
// nor are A-not-A questions (
|
|
173
|
-
|
|
174
|
-
const
|
|
185
|
+
// nor are A-not-A questions (要不要、用不用、想不想、需(要)不需要、有没有必要), "why not" (review r2)
|
|
186
|
+
// or questions like "won't you/we …".
|
|
187
|
+
const ZH_NEGATION=/(?:先别|(?<!需)(?<!需要)不需要|(?<!有)没有必要|没必要|(?<!(?<!只)要)不要|(?<!用)不用|(?<!想)不想|无需|不必|(?<![特分区识级类个告差辨鉴性派道送判甄离])别(?![人处的致墅名扭样具]))(?!忘)/g;
|
|
188
|
+
const EN_NEGATION=/\b(?:(?<!why\s+)don['’]?t|(?<!why\s+)won['’]?t(?!\s+(?:you|we|they|i)\b)|do not|no need to|(?<!why\s+)not)\b/g;
|
|
175
189
|
const EN_WORD=/^[ \t]+[^\s,,。.!!??;;::]+/;
|
|
190
|
+
function zhWindowEnd(text,negationIndex,start){
|
|
191
|
+
let clauseStart=negationIndex;
|
|
192
|
+
while(clauseStart>0&&!CLAUSE_END.test(text[clauseStart-1]))clauseStart--;
|
|
193
|
+
const conditional=ZH_CONDITION.test(text.slice(clauseStart,negationIndex));
|
|
194
|
+
let end=start;
|
|
195
|
+
while(end<text.length&&end-start<NEGATION_WINDOW.zh&&!CLAUSE_END.test(text[end])&&!(conditional&&text[end]==='就'&&!RIGHT_AWAY.test(text.slice(Math.max(0,end-2),end))))end++;
|
|
196
|
+
return end;
|
|
197
|
+
}
|
|
176
198
|
export function maskNegated(text){
|
|
177
199
|
let out=text;
|
|
178
200
|
const blank=(from,to)=>{out=out.slice(0,from)+' '.repeat(to-from)+out.slice(to);};
|
|
179
201
|
for(const match of text.matchAll(ZH_NEGATION)){
|
|
180
202
|
const start=match.index+match[0].length;
|
|
181
|
-
|
|
182
|
-
while(end<text.length&&end-start<NEGATION_WINDOW.zh&&!CLAUSE_END.test(text[end]))end++;
|
|
183
|
-
blank(start,end);
|
|
203
|
+
blank(start,zhWindowEnd(text,match.index,start));
|
|
184
204
|
}
|
|
185
205
|
for(const match of text.matchAll(EN_NEGATION)){
|
|
186
206
|
const start=match.index+match[0].length;
|
|
187
207
|
let end=start;
|
|
188
|
-
|
|
208
|
+
// Chinese right after the English negation ("don't换个会话") is masked like a Chinese negation,
|
|
209
|
+
// condition rule included (todo from PR #265, review r1).
|
|
210
|
+
if(/^[\u3400-\u9fff]/.test(text.slice(start)))end=zhWindowEnd(text,match.index,start);
|
|
211
|
+
else for(let words=0;words<NEGATION_WINDOW.en;words++){
|
|
189
212
|
const next=EN_WORD.exec(text.slice(end));
|
|
190
213
|
if(!next)break;
|
|
191
214
|
end+=next[0].length;
|
|
@@ -316,6 +339,12 @@ export async function pickInvoke({prompt,rules,host,env,authorCheck,judgeModule,
|
|
|
316
339
|
const plain=splitHits(candidates,stripCode(prompt.toLowerCase()));
|
|
317
340
|
const raw=plain.map(hit=>hit.keyword||hit.pattern);
|
|
318
341
|
const index=guarded.findIndex((hit,at)=>raw[at]&&(hit.keyword||hit.pattern));
|
|
342
|
+
// What the guards held back, for the log (rule and reason only, never the text); every such rule,
|
|
343
|
+
// also when another rule goes ahead (todo from PR #265, review r1).
|
|
344
|
+
const unguarded=splitHits(candidates,unquoted);
|
|
345
|
+
const suppressed=candidates.flatMap((rule,at)=>raw[at]&&!(guarded[at].keyword||guarded[at].pattern)
|
|
346
|
+
?[{rule:rule.id,skill:rule.skill,reason:unguarded[at].keyword||unguarded[at].pattern?'negated':'quoted'}]:[]);
|
|
347
|
+
if(suppressed.length)fallback.suppressed=suppressed;
|
|
319
348
|
if(index>=0){
|
|
320
349
|
const rule=candidates[index];
|
|
321
350
|
// A rule with patterns keeps its mode only when a pattern matched both before and after
|
|
@@ -323,12 +352,7 @@ export async function pickInvoke({prompt,rules,host,env,authorCheck,judgeModule,
|
|
|
323
352
|
const strong=guarded[index].pattern&&plain[index].pattern;
|
|
324
353
|
return {...fallback,rule,mode:rule.patterns.length&&!strong?'ask':rule.invoke.mode};
|
|
325
354
|
}
|
|
326
|
-
|
|
327
|
-
const first=raw.findIndex(Boolean);
|
|
328
|
-
if(first<0)return {...fallback,rule:null};
|
|
329
|
-
const unguarded=splitHits([candidates[first]],unquoted)[0];
|
|
330
|
-
return {...fallback,rule:null,suppressed:{rule:candidates[first].id,skill:candidates[first].skill,
|
|
331
|
-
reason:unguarded.keyword||unguarded.pattern?'negated':'quoted'}};
|
|
355
|
+
return {...fallback,rule:null};
|
|
332
356
|
}
|
|
333
357
|
function splitHits(rules,text){
|
|
334
358
|
const byPattern=patternMatches(rules,text);
|
|
@@ -373,7 +397,7 @@ export async function hook(input,{env=process.env,host='claude',rulesFile=defaul
|
|
|
373
397
|
// A missing key is the normal state for most users, not worth a line per message.
|
|
374
398
|
if(invoked.error&&!['no-key','off'].includes(invoked.error))appendLog(env,{t:time,event:'judge-error',host,error:invoked.error});
|
|
375
399
|
if(start)appendLog(env,{t:time,event:'invoke',host,rule:invoked.rule.id,skill:start.skill,mode:start.mode,via:invoked.via});
|
|
376
|
-
|
|
400
|
+
for(const item of invoked.suppressed??[])appendLog(env,{t:time,event:'suppressed',host,...item});
|
|
377
401
|
for(const hint of hints)appendLog(env,{t:time,event:'hint',host,rule:hint.rule,skill:hint.skill});
|
|
378
402
|
}catch{/* 统计丢一条 */}
|
|
379
403
|
// Session state is never removed (decided 2026-10-24): a session resumed months
|
|
@@ -909,6 +909,56 @@ test('guards: window edges, case, everyday words with 别, and guards never add
|
|
|
909
909
|
assert.deepEqual(got,cases);
|
|
910
910
|
});
|
|
911
911
|
|
|
912
|
+
test('guards: 不需要, 没必要 and won\'t also negate; A-not-A and why-won\'t stay questions (todo from PR #265)',async t=>{
|
|
913
|
+
const f=guarded(t);
|
|
914
|
+
const cases=[
|
|
915
|
+
['不需要换个会话,继续',null],
|
|
916
|
+
['没必要换个会话交接',null],
|
|
917
|
+
["won't start a new session",null],
|
|
918
|
+
['won’t start a new session',null],
|
|
919
|
+
['需要换个会话交接','direct:handoff'],
|
|
920
|
+
['需不需要换个会话交接','direct:handoff'],
|
|
921
|
+
['有没有必要换个会话交接','direct:handoff'],
|
|
922
|
+
['不需要的先放着,换个会话交接','direct:handoff'],
|
|
923
|
+
["why won't we start a new session",'ask:handoff'],
|
|
924
|
+
["we won't need it, start a new session",'ask:handoff'],
|
|
925
|
+
// review r1: full A-not-A form, won't-questions, a condition ending in 就, and 没有必要.
|
|
926
|
+
['需要不需要换个会话交接','direct:handoff'],
|
|
927
|
+
['Won’t you start a new session?','ask:handoff'],
|
|
928
|
+
["Why exactly won't we start a new session?",'ask:handoff'],
|
|
929
|
+
['如果不需要测试就换个会话交接','direct:handoff'],
|
|
930
|
+
['如果不用测试就换个会话交接','direct:handoff'],
|
|
931
|
+
['没有必要换个会话交接,继续当前任务',null],
|
|
932
|
+
['有没有必要换个会话交接','direct:handoff'],
|
|
933
|
+
// review r2: 就 ends the negation only after a condition word (如果/要是/假如…) in the same clause.
|
|
934
|
+
['不要现在就换个会话交接,先把测试跑完',null],
|
|
935
|
+
['要是不用测试就换个会话交接','direct:handoff'],
|
|
936
|
+
['如果没问题,不要现在就换个会话交接',null],
|
|
937
|
+
// review r3 todo: single-character 若 is a condition word too; 若干/宛若 are not.
|
|
938
|
+
['若不用测试就换个会话交接','direct:handoff'],
|
|
939
|
+
['倘若不需要测试就换个会话交接','direct:handoff'],
|
|
940
|
+
['前面若干步不要就换个会话交接',null],
|
|
941
|
+
['宛若无事不要就换个会话交接',null],
|
|
942
|
+
// review r4: a condition already closed by its own 就 does not reach a later 就; a name like 若琳 is no condition.
|
|
943
|
+
['若测试还没跑完就不要现在就换个会话交接,先继续测试',null],
|
|
944
|
+
['如果测试没跑完就不要现在就换个会话交接',null],
|
|
945
|
+
['若琳说不要现在就换个会话交接,先把测试跑完',null],
|
|
946
|
+
['你若不想测试就换个会话交接','direct:handoff'],
|
|
947
|
+
// review r4b: 就 after a time word (现在就/马上就/立刻就) is "right away", not the consequence.
|
|
948
|
+
['若不想现在就换个会话交接,那就先继续测试',null],
|
|
949
|
+
['如果不想马上就换个会话交接,那就先继续测试',null],
|
|
950
|
+
['要是不用立刻就换个会话交接,就先继续测试',null],
|
|
951
|
+
// review r5: single 这/早 end other words (来这/起早), so they are not time words here.
|
|
952
|
+
['如果不用来这就换个会话交接,剩下的我远程做','direct:handoff'],
|
|
953
|
+
['如果不用起早就换个会话交接,下午再继续','direct:handoff'],
|
|
954
|
+
['若不想今天就换个会话交接,那就先继续测试',null],
|
|
955
|
+
['如果日志不用放这就换个会话交接,日志我移到归档目录','direct:handoff'],
|
|
956
|
+
];
|
|
957
|
+
const got=[];
|
|
958
|
+
for(const [prompt] of cases)got.push([prompt,await f.run(prompt)]);
|
|
959
|
+
assert.deepEqual(got,cases);
|
|
960
|
+
});
|
|
961
|
+
|
|
912
962
|
test('guards: what they hold back is logged with rule and reason only, never the text',async t=>{
|
|
913
963
|
const f=guarded(t);
|
|
914
964
|
await f.run('不要换个会话,继续当前任务');
|
|
@@ -919,6 +969,47 @@ test('guards: what they hold back is logged with rule and reason only, never the
|
|
|
919
969
|
assert.doesNotMatch(fs.readFileSync(logFile(f.env),'utf8'),/换个会话|继续当前任务/);
|
|
920
970
|
});
|
|
921
971
|
|
|
972
|
+
test('guards: Chinese single quotes, quotes never span lines, English negation right before Chinese (todo from PR #265)',async t=>{
|
|
973
|
+
const f=guarded(t);
|
|
974
|
+
const cases=[
|
|
975
|
+
['我们讨论 ‘换个会话’ 这个关键词',null],
|
|
976
|
+
['他说“先看看\n换个会话交接吧\n后面才是”结尾','direct:handoff'],
|
|
977
|
+
['「先看看\n换个会话交接吧\n」','direct:handoff'],
|
|
978
|
+
["don't换个会话,继续当前任务",null],
|
|
979
|
+
["don’t 换个会话,继续当前任务",null],
|
|
980
|
+
['Won’t you start a new session?','ask:handoff'],
|
|
981
|
+
// review r1: ’ inside an English word is an apostrophe; any line break ends a quote; a quote never
|
|
982
|
+
// opens twice; English negation glued to Chinese keeps the condition rule.
|
|
983
|
+
['我们讨论 ‘don’t hand off to a new session’ 这句英文',null],
|
|
984
|
+
['他说“先看看\r换个会话交接吧\r后面才是”结尾','direct:handoff'],
|
|
985
|
+
['他说“先看看\u2028换个会话交接吧\u2028后面才是”结尾','direct:handoff'],
|
|
986
|
+
['这里先留个左引号“,换个会话交接吧,标题用“进度”','direct:handoff'],
|
|
987
|
+
["如果don't测就换个会话交接",'direct:handoff'],
|
|
988
|
+
// review r2: ‘ and ’ never pair across two other quotes; \r and U+2028/U+2029 end a clause too.
|
|
989
|
+
['对比『‘ 是左单引号』和「’ 是右单引号,换个会话交接是测试短语」这两段文字',null],
|
|
990
|
+
['don’t测\u2028换个会话交接','direct:handoff'],
|
|
991
|
+
['不要测\r换个会话交接','direct:handoff'],
|
|
992
|
+
['不要测\u2029换个会话交接','direct:handoff'],
|
|
993
|
+
];
|
|
994
|
+
const got=[];
|
|
995
|
+
for(const [prompt] of cases)got.push([prompt,await f.run(prompt)]);
|
|
996
|
+
assert.deepEqual(got,cases);
|
|
997
|
+
});
|
|
998
|
+
|
|
999
|
+
test('guards: every rule the guards hold back in one message is logged, not just the first (todo from PR #265)',async t=>{
|
|
1000
|
+
const f=guarded(t,{version:1,rules:[
|
|
1001
|
+
{id:'long-session',skill:'handoff',author:true,keywords:['换个会话'],reason:'写交接',invoke:{mode:'direct',when:'写交接'}},
|
|
1002
|
+
{id:'split',skill:'wayfinder',author:true,keywords:['拆会话'],reason:'拆任务',invoke:{mode:'direct',when:'拆任务'}}]});
|
|
1003
|
+
assert.equal(await f.run('不要换个会话,也“拆会话”'),null);
|
|
1004
|
+
assert.deepEqual(f.log().filter(entry=>entry.event==='suppressed').map(({rule,skill,reason})=>({rule,skill,reason})),[
|
|
1005
|
+
{rule:'long-session',skill:'handoff',reason:'negated'},
|
|
1006
|
+
{rule:'split',skill:'wayfinder',reason:'quoted'}]);
|
|
1007
|
+
// review r1: a rule held back is logged even when another rule in the same message goes ahead.
|
|
1008
|
+
assert.equal(await f.run('换个会话交接吧,“拆会话”是另一个选项'),'direct:handoff');
|
|
1009
|
+
assert.deepEqual(f.log().filter(entry=>entry.event==='suppressed').slice(2).map(({rule,reason})=>({rule,reason})),[
|
|
1010
|
+
{rule:'split',reason:'quoted'}]);
|
|
1011
|
+
});
|
|
1012
|
+
|
|
922
1013
|
test('guards: masking a pattern\'s exclusion words never upgrades ask to direct (review r2)',async t=>{
|
|
923
1014
|
const f=guarded(t,{version:1,rules:[{id:'long-session',skill:'handoff',author:true,keywords:['换个会话'],
|
|
924
1015
|
patterns:['^(?![\\s\\S]*只是问问)[\\s\\S]*会话'],reason:'写交接',invoke:{mode:'direct',when:'写交接'}}]});
|
|
@@ -9,7 +9,9 @@ import path from 'node:path';
|
|
|
9
9
|
import {spawnSync} from 'node:child_process';
|
|
10
10
|
import {fileURLToPath} from 'node:url';
|
|
11
11
|
import {approveCmAiSpecs} from '../runtime/js/cm-ai/cm-ai-admission.mjs';
|
|
12
|
-
import {applySpecAmendment,withApprovalLock} from '../runtime/js/cm-ai/spec-amendment.mjs';
|
|
12
|
+
import {applySpecAmendment,withApprovalLock,roundLedgerPath} from '../runtime/js/cm-ai/spec-amendment.mjs';
|
|
13
|
+
import {recordPrdReview} from './cm-prd-review-gate.mjs';
|
|
14
|
+
import {assertPrdReviewsSettled} from '../runtime/js/cm-prd/change.mjs';
|
|
13
15
|
|
|
14
16
|
// The round ledger lives under CM_WORKFLOW_HOME; never touch the real home.
|
|
15
17
|
const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-spec-amend-home-'));
|
|
@@ -508,3 +510,107 @@ test('a failed approval snapshot write leaves no round to restore',()=>fixture((
|
|
|
508
510
|
reset();fs.writeFileSync(target,roundA);edit('tasks.md',addTask);
|
|
509
511
|
assert.deepEqual(inspect().reasons,['snapshot_round_missing']);
|
|
510
512
|
}));
|
|
513
|
+
|
|
514
|
+
// wue 实跑事故(2026-11-17):拆分审查回执之后,设计稿经用户重新批准、任务经 1 级补正换绑,
|
|
515
|
+
// cm-prd --change 的 save_draft 仍拿最早回执指纹比对,误报 prd_review_artifact_changed。
|
|
516
|
+
function splitReceipt(specs,names=['requirements.md','design.md','tasks.md','test-cases.json']){
|
|
517
|
+
const reviews=path.join(specs,'.reviews');fs.mkdirSync(reviews,{recursive:true});
|
|
518
|
+
const args={stage:'split',feature:'login',evidence:path.join(reviews,'prd-login-split-r1.md'),receipt:path.join(reviews,'prd-login-split-disposition.json')};
|
|
519
|
+
fs.writeFileSync(args.evidence,'---\nat: 2026-11-01T00:00:00Z\nreviewer: codex-subagent\nindependent: true\nscope:\n - tasks.md\n---\nSynthetic split review\n');
|
|
520
|
+
recordPrdReview({...args,disposition:'no_findings',finding_count:0,unresolved_count:0,
|
|
521
|
+
artifact:names.map(name=>path.join(specs,'1.login',name))});
|
|
522
|
+
}
|
|
523
|
+
test('change save accepts specs re-bound by a later approval or applied amendment after the split receipt',()=>fixture(({specs,approve,inspect,apply,review,edit})=>{
|
|
524
|
+
splitReceipt(specs);assert.equal(approve().status,0);
|
|
525
|
+
const settled=()=>assertPrdReviewsSettled(specs,['1.login']);
|
|
526
|
+
assert.doesNotThrow(settled);
|
|
527
|
+
edit('design.md',text=>text+'\n模块 2:设计稿换版。\n');
|
|
528
|
+
// The design swap goes back through cm-prd (awaiting_review) and a fresh human 「开始」.
|
|
529
|
+
fs.writeFileSync(path.join(specs,'.cm-specs-status'),JSON.stringify({status:'awaiting_review',features:['1.login'],testCases:[]}));
|
|
530
|
+
const again=approve();assert.equal(again.status,0,JSON.stringify(again.json));
|
|
531
|
+
assert.doesNotThrow(settled);
|
|
532
|
+
edit('tasks.md',addTask);const {tier,deltaDigest}=inspect();assert.equal(tier,1);
|
|
533
|
+
assert.equal(apply(['--review-output',review(deltaDigest),'--reviewer','codex']).status,0);
|
|
534
|
+
assert.doesNotThrow(settled);
|
|
535
|
+
// Runtime completion marks stay outside the comparison, as for the receipt itself.
|
|
536
|
+
edit('tasks.md',text=>text.replace('- [ ] T-001: 登录页','- [x] T-001: 登录页'));
|
|
537
|
+
assert.doesNotThrow(settled);
|
|
538
|
+
},{cases:true}));
|
|
539
|
+
test('change save still refuses specs that match no approved version',()=>{
|
|
540
|
+
fixture(({specs,approve,edit})=>{
|
|
541
|
+
splitReceipt(specs);assert.equal(approve().status,0);
|
|
542
|
+
edit('tasks.md',addTask);
|
|
543
|
+
assert.throws(()=>assertPrdReviewsSettled(specs,['1.login']),/PRD review artifact changed after disposition/);
|
|
544
|
+
},{cases:true});
|
|
545
|
+
// An approved snapshot whose round ledger is gone (or a restored older one) is no baseline.
|
|
546
|
+
fixture(({specs,approve,edit})=>{
|
|
547
|
+
splitReceipt(specs);edit('design.md',text=>text+'\n换版\n');assert.equal(approve().status,0);
|
|
548
|
+
fs.rmSync(roundLedgerPath(specs));
|
|
549
|
+
assert.throws(()=>assertPrdReviewsSettled(specs,['1.login']),/PRD review artifact changed after disposition/);
|
|
550
|
+
},{cases:true});
|
|
551
|
+
// A snapshot never approved (status back to awaiting_review) is no baseline either.
|
|
552
|
+
fixture(({specs,approve,edit})=>{
|
|
553
|
+
splitReceipt(specs);edit('design.md',text=>text+'\n换版\n');assert.equal(approve().status,0);
|
|
554
|
+
const status=path.join(specs,'.cm-specs-status');
|
|
555
|
+
fs.writeFileSync(status,JSON.stringify({...JSON.parse(fs.readFileSync(status,'utf8')),status:'awaiting_review'}));
|
|
556
|
+
assert.throws(()=>assertPrdReviewsSettled(specs,['1.login']),/PRD review artifact changed after disposition/);
|
|
557
|
+
},{cases:true});
|
|
558
|
+
});
|
|
559
|
+
// Codex 审查 #2:同一功能不能拼接旧回执字节与新批准字节。
|
|
560
|
+
test('change save refuses mixing receipt bytes with a later approved round',()=>fixture(({specs,approve,edit})=>{
|
|
561
|
+
splitReceipt(specs);const original=fs.readFileSync(path.join(specs,'1.login/tasks.md'));
|
|
562
|
+
edit('design.md',text=>text+'\n换版\n');edit('tasks.md',addTask);assert.equal(approve().status,0);
|
|
563
|
+
assert.doesNotThrow(()=>assertPrdReviewsSettled(specs,['1.login']));
|
|
564
|
+
fs.writeFileSync(path.join(specs,'1.login/tasks.md'),original);
|
|
565
|
+
assert.throws(()=>assertPrdReviewsSettled(specs,['1.login']),/PRD review artifact changed after disposition/);
|
|
566
|
+
},{cases:true}));
|
|
567
|
+
// Codex 审查 #3:批准轮次已合法去掉 test-cases.json 时不再误拦;未批准的删除仍拦。
|
|
568
|
+
test('change save follows an approved round that no longer has test-cases.json',()=>{
|
|
569
|
+
fixture(({specs,approve})=>{
|
|
570
|
+
splitReceipt(specs);fs.rmSync(path.join(specs,'1.login/test-cases.json'));assert.equal(approve().status,0);
|
|
571
|
+
assert.doesNotThrow(()=>assertPrdReviewsSettled(specs,['1.login']));
|
|
572
|
+
},{cases:true});
|
|
573
|
+
fixture(({specs,approve})=>{
|
|
574
|
+
splitReceipt(specs);assert.equal(approve().status,0);fs.rmSync(path.join(specs,'1.login/test-cases.json'));
|
|
575
|
+
assert.throws(()=>assertPrdReviewsSettled(specs,['1.login']),/PRD review artifact is missing or unsafe/);
|
|
576
|
+
},{cases:true});
|
|
577
|
+
});
|
|
578
|
+
// Codex 审查 #4:畸形状态清单不是基线,也不能打断原回执校验。
|
|
579
|
+
test('malformed approved status falls back to the strict receipt check',()=>fixture(({specs,approve,edit})=>{
|
|
580
|
+
splitReceipt(specs);assert.equal(approve().status,0);
|
|
581
|
+
const status=path.join(specs,'.cm-specs-status');
|
|
582
|
+
fs.writeFileSync(status,JSON.stringify({...JSON.parse(fs.readFileSync(status,'utf8')),specFiles:{}}));
|
|
583
|
+
assert.doesNotThrow(()=>assertPrdReviewsSettled(specs,['1.login']));
|
|
584
|
+
edit('tasks.md',addTask);
|
|
585
|
+
assert.throws(()=>assertPrdReviewsSettled(specs,['1.login']),/PRD review artifact changed after disposition/);
|
|
586
|
+
},{cases:true}));
|
|
587
|
+
// Codex 复审 #1:两份清单都没有的 test-cases.json 后来出现,也要拦。
|
|
588
|
+
test('change save refuses a test-cases.json no approval or receipt bound',()=>fixture(({specs,approve,edit})=>{
|
|
589
|
+
splitReceipt(specs,['requirements.md','design.md','tasks.md']);edit('design.md',text=>text+'\n换版\n');assert.equal(approve().status,0);
|
|
590
|
+
assert.doesNotThrow(()=>assertPrdReviewsSettled(specs,['1.login']));
|
|
591
|
+
fs.writeFileSync(path.join(specs,'1.login/test-cases.json'),JSON.stringify(CASES));
|
|
592
|
+
assert.throws(()=>assertPrdReviewsSettled(specs,['1.login']),/PRD review artifact changed after disposition/);
|
|
593
|
+
}));
|
|
594
|
+
// Codex 复审 #2:批准清单范围外的回执产物仍按回执指纹核对,删除不能借基线放行。
|
|
595
|
+
test('approved baseline never covers receipt artifacts outside the approved spec files',()=>fixture(({specs,approve,edit})=>{
|
|
596
|
+
fs.writeFileSync(path.join(specs,'1.login/api-schema.json'),'{"type":"object"}\n');
|
|
597
|
+
splitReceipt(specs,['requirements.md','design.md','tasks.md','test-cases.json','api-schema.json']);
|
|
598
|
+
edit('design.md',text=>text+'\n换版\n');assert.equal(approve().status,0);
|
|
599
|
+
assert.doesNotThrow(()=>assertPrdReviewsSettled(specs,['1.login']));
|
|
600
|
+
fs.rmSync(path.join(specs,'1.login/api-schema.json'));
|
|
601
|
+
assert.throws(()=>assertPrdReviewsSettled(specs,['1.login']),/PRD review artifact is missing or unsafe/);
|
|
602
|
+
},{cases:true}));
|
|
603
|
+
// Codex 复审第 3 轮:规格根目录下指纹未变的辅助产物不是功能目录,不能被误拦。
|
|
604
|
+
test('approved baseline keeps root-level receipt artifacts on their own fingerprints',()=>fixture(({specs,approve,edit})=>{
|
|
605
|
+
const extra=path.join(specs,'api-schema.json');fs.writeFileSync(extra,'{"type":"object"}\n');
|
|
606
|
+
splitReceipt(specs);
|
|
607
|
+
const receipt=path.join(specs,'.reviews/prd-login-split-disposition.json'),value=JSON.parse(fs.readFileSync(receipt,'utf8'));
|
|
608
|
+
// Old `record` accepted any file inside the specs root; model such a receipt directly.
|
|
609
|
+
fs.rmSync(receipt);
|
|
610
|
+
recordPrdReview({stage:'split',feature:'login',evidence:path.join(specs,'.reviews/prd-login-split-r1.md'),receipt,
|
|
611
|
+
disposition:'no_findings',finding_count:0,unresolved_count:0,artifact:[...value.artifacts.map(item=>path.join(specs,item.path)),extra]});
|
|
612
|
+
edit('design.md',text=>text+'\n换版\n');assert.equal(approve().status,0);
|
|
613
|
+
assert.doesNotThrow(()=>assertPrdReviewsSettled(specs,['1.login']));
|
|
614
|
+
fs.appendFileSync(extra,' ');
|
|
615
|
+
assert.throws(()=>assertPrdReviewsSettled(specs,['1.login']),/PRD review artifact changed after disposition/);
|
|
616
|
+
},{cases:true}));
|
|
@@ -14,11 +14,11 @@ import {publishPrdReview} from '../runtime/js/cm-prd/review-publication.mjs';
|
|
|
14
14
|
import {recordPrdHostDisposition} from '../runtime/js/cm-prd/review-disposition.mjs';
|
|
15
15
|
import {createPrdSummaryOwner,publishPrdAwaitingReview} from '../runtime/js/cm-prd/summary.mjs';
|
|
16
16
|
// Spec approvals write a round ledger under CM_WORKFLOW_HOME; keep it off the real home.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
17
|
+
// Always, not only when unset: an exported CM_WORKFLOW_HOME may be the tester's real home
|
|
18
|
+
// (review 2026-11-17: these suites left 11 approval records in an externally named home).
|
|
19
|
+
const isolatedHome=fs.mkdtempSync(path.join(os.tmpdir(),'cm-approval-home-'));
|
|
20
|
+
process.env.CM_WORKFLOW_HOME=isolatedHome;
|
|
21
|
+
process.on('exit',()=>fs.rmSync(isolatedHome,{recursive:true,force:true}));
|
|
22
22
|
const entry=fileURLToPath(new URL('./cm-ai-admission.mjs',import.meta.url));
|
|
23
23
|
const at='2026-09-18T00:00:00.000Z';
|
|
24
24
|
const keys=['status','summaryDigest','at','features','specFiles','testCases','approval'];
|
|
@@ -12,14 +12,16 @@ import {isXcodebuild, isTestAction, advisoryRunsTest as runsTest, mandatoryCheck
|
|
|
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
14
|
import {readReviewBaseline,captureReviewBaseline} from '../runtime/js/cm-ai/review-package.mjs';
|
|
15
|
+
import {SYMLINK_BASELINE_VERSION} from '../runtime/js/cm-ai/symlink-material.mjs';
|
|
15
16
|
import {taskReviewScope} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
17
|
+
import {callTimeoutFrom} from '../runtime/js/cm-ai/call-timeout.mjs';
|
|
16
18
|
import {codeProjectPaths,resolveCodeProjects} from '../runtime/js/cm-ai/code-projects.mjs';
|
|
17
19
|
import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
|
|
18
20
|
import {acceptanceCoverage} from '../runtime/js/cm-ai/acceptance-contract.mjs';
|
|
19
21
|
import {featureHasBrowserCases,readBrowserCapability} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
20
22
|
|
|
21
23
|
// The whole check step of a current-session run is one host call with this deadline
|
|
22
|
-
// (runtime/js/cm-ai/host-conversation-execution.mjs, outerTimeoutMs). The test
|
|
24
|
+
// (runtime/js/cm-ai/host-conversation-execution.mjs, outerTimeoutMs; default unless --call-timeout-minutes). The test
|
|
23
25
|
// file guards that the literal is still there.
|
|
24
26
|
export const CHECK_CALL_LIMIT_MS = 1800000;
|
|
25
27
|
const MAX_LISTED = 20;
|
|
@@ -97,8 +99,32 @@ const optionValue = (tokens, name) => {
|
|
|
97
99
|
return at === -1 ? '' : tokens[at + 1] ?? '';
|
|
98
100
|
};
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
// 运行可用 --call-timeout-minutes(30–60)放宽整步期限;值非法或重复时宿主会拒绝启动,这里不论有无 checks 都提前报出
|
|
103
|
+
export function callLimit(plan, saved = null) {
|
|
104
|
+
try {
|
|
105
|
+
const value = callTimeoutFrom(plan.permissions), flags = Array.isArray(plan.permissions) ? plan.permissions : [];
|
|
106
|
+
const effective = value ?? CHECK_CALL_LIMIT_MS, bad = message => ({limitMs: CHECK_CALL_LIMIT_MS, findings: [{level: 'error', code: 'call_timeout_invalid', message}]});
|
|
107
|
+
if (saved?.external && effective !== saved.timeoutMs)
|
|
108
|
+
return bad(`外部模型运行恢复时期限须与创建时一致(${saved.timeoutMs / 60000} 分钟)`);
|
|
109
|
+
if (saved && !saved.external && effective < saved.timeoutMs)
|
|
110
|
+
return bad(`--call-timeout-minutes:此运行已用 ${saved.timeoutMs / 60000} 分钟,本次为 ${effective / 60000} 分钟;恢复时不得低于创建时的值`);
|
|
111
|
+
if (value !== null && (flags.includes('--protected-conversation-config') || flags.includes('--protected-config')))
|
|
112
|
+
return {limitMs: CHECK_CALL_LIMIT_MS, findings: [{level: 'error', code: 'call_timeout_invalid', message: '--call-timeout-minutes 不用于受保护运行'}]};
|
|
113
|
+
if (value !== null && flags.includes('--external-models') && plan.mode !== 'resume')
|
|
114
|
+
return {limitMs: CHECK_CALL_LIMIT_MS, findings: [{level: 'error', code: 'call_timeout_invalid', message: '外部模型运行创建时不接受 --call-timeout-minutes'}]};
|
|
115
|
+
return {limitMs: value ?? CHECK_CALL_LIMIT_MS, findings: []};
|
|
116
|
+
}
|
|
117
|
+
catch (error) { return {limitMs: CHECK_CALL_LIMIT_MS, findings: [{level: 'error', code: 'call_timeout_invalid', message: error.message}]}; }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 与宿主同一规则:受保护运行不接受;外部模型运行只在恢复时可带原值
|
|
121
|
+
const canWiden = (plan, saved = null) => {
|
|
122
|
+
const flags = Array.isArray(plan.permissions) ? plan.permissions : [];
|
|
123
|
+
return !saved?.external && !flags.includes('--protected-config') && !flags.includes('--protected-conversation-config') && !flags.includes('--external-models');
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
function checkChecks(plan, saved = null) {
|
|
127
|
+
const {limitMs, findings} = callLimit(plan, saved);
|
|
102
128
|
if (!Array.isArray(plan.checks)) return findings;
|
|
103
129
|
const items = plan.checks.filter(item => item !== null && typeof item === 'object' && !Array.isArray(item));
|
|
104
130
|
let timeouts;
|
|
@@ -131,10 +157,11 @@ function checkChecks(plan) {
|
|
|
131
157
|
message: `检查 ${group.map(entry => entry.item.id).join('、')} 都是同一 scheme/目的地、没有 -only-testing 的 xcodebuild test,很可能各自跑了一遍全量。保留一个,或用 -only-testing 分开`});
|
|
132
158
|
}
|
|
133
159
|
const totalMs = own.reduce((sum, entry) => sum + entry.timeoutMs, 0);
|
|
134
|
-
if (totalMs >
|
|
135
|
-
findings.push({level: 'warn', code: 'check_budget_over_call_limit', totalMs, limitMs
|
|
136
|
-
message: `各检查超时之和 ${Math.round(totalMs / 60000)} 分钟,超过检查整步的 ${
|
|
137
|
-
+ '
|
|
160
|
+
if (totalMs > limitMs)
|
|
161
|
+
findings.push({level: 'warn', code: 'check_budget_over_call_limit', totalMs, limitMs,
|
|
162
|
+
message: `各检查超时之和 ${Math.round(totalMs / 60000)} 分钟,超过检查整步的 ${limitMs / 60000} 分钟期限;这是最坏情况,实际可能更短。`
|
|
163
|
+
+ '按分层缩减(单元测试全跑,界面测试只跑本任务新写的和牵连的,其余留到功能末尾回归任务),或拆成多次运行;'
|
|
164
|
+
+ (canWiden(plan, saved) ? '设备检查确需更久时,在 PLAN.permissions 加 "--call-timeout-minutes","<30–60>"' : '此运行模式不能用 --call-timeout-minutes 延长期限(外部模型运行恢复时只可传创建时的原值)')});
|
|
138
165
|
return findings;
|
|
139
166
|
}
|
|
140
167
|
|
|
@@ -253,12 +280,12 @@ function checkDirtyScope(definition) {
|
|
|
253
280
|
// The runner captures this baseline when the run is created and again before
|
|
254
281
|
// each review package; a tree it refuses there stops the run after the develop
|
|
255
282
|
// answer was already written. Capture it here the same way, read-only.
|
|
256
|
-
export function checkReviewInventory(definition){
|
|
283
|
+
export function checkReviewInventory(definition,version=SYMLINK_BASELINE_VERSION){
|
|
257
284
|
if(!fs.existsSync(definition.codeProject)||typeof definition.specsDir!=='string'||!definition.identity
|
|
258
285
|
||!Array.isArray(definition.requirements))return [];
|
|
259
286
|
try{
|
|
260
287
|
const codeProject=definition.codeProject;
|
|
261
|
-
captureReviewBaseline({root:codeProject,specsRoot:definition.specsDir,identity:definition.identity,
|
|
288
|
+
captureReviewBaseline({root:codeProject,specsRoot:definition.specsDir,identity:definition.identity,version,
|
|
262
289
|
scope:taskReviewScope(definition.scope),requirements:definition.requirements,
|
|
263
290
|
...(typeof definition.feature==='string'?{specification:{specsRoot:definition.specsDir,feature:definition.feature}}:{}),
|
|
264
291
|
...(definition.codeProjects?{codeProjectPaths:codeProjectPaths(codeProject,resolveCodeProjects(codeProject,definition.codeProjects))}:{})});
|
|
@@ -335,6 +362,16 @@ export function checkMandatoryTests(plan, requiredTests) {
|
|
|
335
362
|
+ '补充明确执行这些测试的命令。包装脚本须先经原规格流程确认可机械核对的测试映射,不能仅在参数中出现测试名就认定覆盖'}];
|
|
336
363
|
}
|
|
337
364
|
|
|
365
|
+
// 恢复时读原运行首条记录里的期限与外部模型标记(只读、尽力而为;读不到时按计划自身判断,宿主仍会核对)
|
|
366
|
+
function savedRunConfig(plan, definition) {
|
|
367
|
+
if (plan.mode !== 'resume') return null;
|
|
368
|
+
try {
|
|
369
|
+
const config = readExecutionSnapshot({specsRoot: definition.specsDir,
|
|
370
|
+
identity: {repositoryId: definition.identity.repositoryId, runId: definition.identity.runId}}).records[0]?.payload?.config;
|
|
371
|
+
return config && Number.isInteger(config.timeoutMs) ? {timeoutMs: config.timeoutMs, external: Object.hasOwn(config, 'externalModels')} : null;
|
|
372
|
+
} catch { return null; }
|
|
373
|
+
}
|
|
374
|
+
|
|
338
375
|
function approvedStartContract(plan,definition){
|
|
339
376
|
// Old scope-only advisory inputs have no task identity and make no claim
|
|
340
377
|
// about a runnable CM specification. Real run definitions are checked below.
|
|
@@ -346,7 +383,7 @@ function approvedStartContract(plan,definition){
|
|
|
346
383
|
const baseline=readReviewBaseline(snapshot.records[0]?.payload?.baseline);
|
|
347
384
|
if(baseline.specificationRoot!==definition.specsDir||baseline.identity.taskId!==definition.identity.taskId)
|
|
348
385
|
throw new Error('owner mismatch');
|
|
349
|
-
return baseline.specification?.acceptanceContract??null;
|
|
386
|
+
return {contract:baseline.specification?.acceptanceContract??null,baselineVersion:baseline.version};
|
|
350
387
|
}
|
|
351
388
|
// A create-plan may be inspected before any specification has been written.
|
|
352
389
|
// Preserve its old scope/budget diagnostics; this read-only check grants no
|
|
@@ -360,14 +397,14 @@ function approvedStartContract(plan,definition){
|
|
|
360
397
|
const absent=file=>{try{fs.lstatSync(file);return false;}catch(error){if(error.code==='ENOENT')return true;throw error;}};
|
|
361
398
|
if(absent(path.join(root,'.cm-specs-status'))&&absent(path.join(root,definition.feature)))return null;
|
|
362
399
|
}
|
|
363
|
-
return captureSpecificationMaterial({specsRoot:definition.specsDir,feature:definition.feature,
|
|
364
|
-
taskId:definition.identity.taskId}).acceptanceContract;
|
|
400
|
+
return {contract:captureSpecificationMaterial({specsRoot:definition.specsDir,feature:definition.feature,
|
|
401
|
+
taskId:definition.identity.taskId}).acceptanceContract};
|
|
365
402
|
}catch{throw new InputError('必验合同无法从已批准规格或原运行读取;先核对规格批准与原运行身份,不能由 PLAN 自报或省略必验范围');}
|
|
366
403
|
}
|
|
367
404
|
|
|
368
405
|
export function startCheck(planFile, {requiredTests = []} = {}) {
|
|
369
406
|
const {plan, definition} = loadStartInputs(planFile);
|
|
370
|
-
const contract=approvedStartContract(plan,definition),mandatory=[];
|
|
407
|
+
const {contract,baselineVersion}=approvedStartContract(plan,definition)??{},mandatory=[];
|
|
371
408
|
if(contract){
|
|
372
409
|
if(contract.unresolved.length)mandatory.push({level:'error',code:'acceptance_mapping_required',
|
|
373
410
|
message:`已批准材料的必验映射尚不明确:${contract.unresolved.join(';')}`});
|
|
@@ -377,8 +414,9 @@ export function startCheck(planFile, {requiredTests = []} = {}) {
|
|
|
377
414
|
tests:coverage.missing,unverifiable:coverage.unverifiable,commands:coverage.missingCommands,
|
|
378
415
|
message:'当前计划未完整包含冻结的必验检查;补齐检查,不能缩减批准的验收范围'});
|
|
379
416
|
}
|
|
380
|
-
return [...checkProtectedScope(definition.scope), ...checkChecks(plan), ...checkAffectedTests(plan, definition),
|
|
381
|
-
...checkMandatoryTests(plan, requiredTests), ...mandatory, ...checkDirtyScope(definition), ...checkReviewInventory(definition),
|
|
417
|
+
return [...checkProtectedScope(definition.scope), ...checkChecks(plan, savedRunConfig(plan, definition)), ...checkAffectedTests(plan, definition),
|
|
418
|
+
...checkMandatoryTests(plan, requiredTests), ...mandatory, ...checkDirtyScope(definition), ...checkReviewInventory(definition,baselineVersion),
|
|
419
|
+
...checkLaunchInputs(plan, planFile, definition)];
|
|
382
420
|
}
|
|
383
421
|
|
|
384
422
|
export function main(argv = process.argv.slice(2), out = process.stdout, err = process.stderr) {
|