@aibyzero/cm-workflow 0.16.5 → 0.16.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +14 -0
- package/CHANGELOG.md +19 -1
- package/README.md +17 -4
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/VERSION +1 -1
- package/docs/architecture.md +43 -0
- package/docs/execution-optimizations.md +33 -0
- package/docs/external-models.md +114 -0
- package/docs/fixes/.reviews/20260929-bootstrap-unchanged-review-r1.md +7 -0
- package/docs/fixes/.reviews/20260930-develop-package-limit-recovery-r4.md +9 -0
- package/docs/fixes/20260929-bootstrap-rule-refresh-conflict.md +22 -0
- package/docs/fixes/20260929-bootstrap-unchanged-review.md +26 -0
- package/docs/fixes/20260930-develop-package-limit-recovery.md +65 -0
- package/docs/human-correction.md +31 -0
- package/docs/installation.md +28 -7
- package/docs/js-workflow-control.md +96 -6
- package/docs/live-evidence-drivers.md +62 -0
- package/docs/next-steps.md +15 -10
- package/docs/untested-branches.md +27 -4
- package/docs/user-guide.md +23 -8
- package/install-codex.sh +28 -11
- package/package.json +1 -1
- package/runtime/js/cm-ai/claude-review-adapter.mjs +7 -4
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -4
- package/runtime/js/cm-ai/cm-ai-admission.mjs +34 -10
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +9 -5
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +111 -34
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +93 -31
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +13 -57
- package/runtime/js/cm-ai/codex-config.mjs +3 -2
- package/runtime/js/cm-ai/codex-review-adapter.mjs +34 -15
- package/runtime/js/cm-ai/committed-rule-basis.mjs +76 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +8 -5
- package/runtime/js/cm-ai/drive-bootstrap.mjs +22 -12
- package/runtime/js/cm-ai/drive-core.mjs +9 -3
- package/runtime/js/cm-ai/durable-runner-state.mjs +146 -14
- package/runtime/js/cm-ai/effect-contract.mjs +1 -1
- package/runtime/js/cm-ai/execution-policy.mjs +58 -0
- package/runtime/js/cm-ai/external-group-models.mjs +53 -0
- package/runtime/js/cm-ai/external-model-launch.mjs +23 -0
- package/runtime/js/cm-ai/external-models.mjs +52 -0
- package/runtime/js/cm-ai/external-run-guard.mjs +96 -0
- package/runtime/js/cm-ai/host-bootstrap.mjs +70 -20
- package/runtime/js/cm-ai/host-check.mjs +30 -4
- package/runtime/js/cm-ai/host-conversation-execution.mjs +59 -17
- package/runtime/js/cm-ai/host-documentation.mjs +2 -2
- package/runtime/js/cm-ai/host-progress.mjs +80 -0
- package/runtime/js/cm-ai/host-project-execution.mjs +16 -11
- package/runtime/js/cm-ai/host-qa-executor.mjs +54 -8
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +22 -5
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +3 -1
- package/runtime/js/cm-ai/knowledge-closeout.mjs +56 -0
- package/runtime/js/cm-ai/legacy-model-run-preview.mjs +24 -0
- package/runtime/js/cm-ai/legacy-model-settings.mjs +59 -0
- package/runtime/js/cm-ai/live-evidence.mjs +96 -0
- package/runtime/js/cm-ai/log-rows.mjs +36 -0
- package/runtime/js/cm-ai/model-configuration-file.mjs +63 -0
- package/runtime/js/cm-ai/model_configuration_write.py +214 -0
- package/runtime/js/cm-ai/native-usage-log.mjs +26 -0
- package/runtime/js/cm-ai/operator-guidance.mjs +89 -0
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +22 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +15 -0
- package/runtime/js/cm-ai/provider-usage.mjs +39 -0
- package/runtime/js/cm-ai/review-package.mjs +11 -0
- package/runtime/js/cm-ai/review-presentation.mjs +45 -0
- package/runtime/js/cm-ai/review-reconciliation.mjs +20 -0
- package/runtime/js/cm-ai/status-projection.mjs +93 -0
- package/runtime/js/cm-ai/task-runner.mjs +176 -25
- package/runtime/js/cm-ai/tool-preview.mjs +8 -4
- package/runtime/js/cm-ai/worker-claude-developer.mjs +16 -7
- package/runtime/js/cm-ai/worker-claude.mjs +63 -19
- package/runtime/js/cm-ai/worker-codex-developer.mjs +15 -9
- package/runtime/js/cm-ai/worker-codex.mjs +45 -19
- package/runtime/js/cm-fix/cause-evidence.mjs +5 -3
- package/runtime/js/cm-fix/cause-invocation.mjs +6 -3
- package/runtime/js/cm-fix/cause-package.mjs +10 -1
- package/runtime/js/cm-fix/execution.mjs +183 -40
- package/runtime/js/cm-fix/final-review.mjs +18 -10
- package/runtime/js/cm-fix/finish.mjs +2 -19
- package/runtime/js/cm-fix/host-review.mjs +25 -6
- package/runtime/js/cm-fix/host.mjs +4 -1
- package/runtime/js/cm-fix/layout.mjs +1 -1
- package/runtime/js/cm-fix/log-events.mjs +29 -0
- package/runtime/js/cm-fix/metrics.mjs +3 -2
- package/runtime/js/cm-fix/progress.mjs +4 -0
- package/runtime/js/cm-fix/review-reconciliation.mjs +64 -0
- package/runtime/js/cm-prd/analysis.mjs +5 -2
- package/runtime/js/cm-prd/response-recovery.mjs +23 -0
- package/runtime/js/cm-prd/review-host.mjs +2 -1
- package/runtime/js/cm-prd/review-publication.mjs +23 -13
- package/runtime/js/cm-prd/review-time.mjs +29 -0
- package/runtime/js/cm-prd/session.mjs +53 -6
- package/runtime/js/cm-security/finalize.mjs +32 -0
- package/runtime/js/cm-test/recovery.mjs +4 -4
- package/runtime/review.md +5 -0
- package/runtime/task-gates.md +6 -0
- package/runtime/workflow-config.md +10 -1
- package/scripts/cm-ai-admission.mjs +14 -3
- package/scripts/cm-ai-batch-drive.mjs +52 -23
- package/scripts/cm-ai-batch-drive.test.mjs +47 -2
- package/scripts/cm-ai-batch-host.mjs +44 -16
- package/scripts/cm-ai-batch-run.mjs +77 -29
- package/scripts/cm-ai-bootstrap-flow.test.mjs +3 -2
- package/scripts/cm-ai-bootstrap-merge.test.mjs +118 -1
- package/scripts/cm-ai-bootstrap.test.mjs +80 -87
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +15 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +102 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +2 -2
- package/scripts/cm-ai-drive.mjs +73 -28
- package/scripts/cm-ai-drive.test.mjs +119 -1
- package/scripts/cm-ai-feature-selection.test.mjs +178 -0
- package/scripts/cm-ai-host.mjs +79 -27
- package/scripts/cm-ai-host.test.mjs +88 -0
- package/scripts/cm-ai-operator-guidance.test.mjs +94 -0
- package/scripts/cm-ai-progress.test.mjs +521 -0
- package/scripts/cm-ai-protected-scope.test.mjs +194 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +21 -0
- package/scripts/cm-ai-review-failure.test.mjs +71 -11
- package/scripts/cm-ai-run.mjs +94 -19
- package/scripts/cm-ai-run.test.mjs +2 -1
- package/scripts/cm-bootstrap-review-recovery.test.mjs +70 -0
- package/scripts/cm-check-drive.test.mjs +1 -0
- package/scripts/cm-check-runtime.sh +11 -0
- package/scripts/cm-claude-install-layout.test.mjs +26 -0
- package/scripts/cm-claude-probe.test.mjs +1 -1
- package/scripts/cm-codex-plugin-metadata.py +83 -0
- package/scripts/cm-codex-plugin-metadata.test.mjs +55 -0
- package/scripts/cm-efficiency-checks.test.mjs +37 -0
- package/scripts/cm-efficiency-diagnostics.test.mjs +74 -0
- package/scripts/cm-efficiency-offline.mjs +35 -0
- package/scripts/cm-efficiency-policy.test.mjs +48 -0
- package/scripts/cm-efficiency-presentation.test.mjs +35 -0
- package/scripts/cm-efficiency-response.test.mjs +117 -0
- package/scripts/cm-efficiency-usage.test.mjs +148 -0
- package/scripts/cm-external-batch-host.test.mjs +157 -0
- package/scripts/cm-external-fix-host.test.mjs +281 -0
- package/scripts/cm-external-fix-reconciliation.test.mjs +105 -0
- package/scripts/cm-external-group-models.test.mjs +60 -0
- package/scripts/cm-external-model-host.test.mjs +180 -0
- package/scripts/cm-external-model-recovery.test.mjs +108 -0
- package/scripts/cm-external-models.test.mjs +89 -0
- package/scripts/cm-external-process-cleanup.test.mjs +71 -0
- package/scripts/cm-external-qa-fix.test.mjs +170 -0
- package/scripts/cm-external-review-reconciliation.test.mjs +314 -0
- package/scripts/cm-fix-drive.mjs +28 -13
- package/scripts/cm-fix-final-review.test.mjs +11 -6
- package/scripts/cm-fix-host.mjs +17 -10
- package/scripts/cm-fix-large-log.test.mjs +113 -0
- package/scripts/cm-fix-protected-edits.test.mjs +12 -0
- package/scripts/cm-fix-rediagnosis.test.mjs +168 -0
- package/scripts/cm-fix-review-budget.test.mjs +7 -1
- package/scripts/cm-host-qa-executor.test.mjs +329 -3
- package/scripts/cm-knowledge-closeout.test.mjs +160 -0
- package/scripts/cm-live-evidence.test.mjs +64 -0
- package/scripts/cm-log-event.mjs +34 -7
- package/scripts/cm-log-event.py +15 -0
- package/scripts/cm-model-setup.mjs +79 -0
- package/scripts/cm-prd-drive.mjs +32 -11
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +26 -6
- package/scripts/cm-prd-host.test.mjs +4 -0
- package/scripts/cm-prd-review-host.test.mjs +17 -0
- package/scripts/cm-prd-session-recovery.test.mjs +44 -2
- package/scripts/cm-prd-task-grouping.test.mjs +206 -0
- package/scripts/cm-release-smoke.sh +5 -1
- package/scripts/cm-review-scope-recovery.test.mjs +5 -3
- package/scripts/cm-runtime-i18n.mjs +15 -4
- package/scripts/cm-runtime-install.mjs +8 -4
- package/scripts/cm-runtime.mjs +116 -23
- package/scripts/cm-runtime.test.mjs +121 -12
- package/scripts/cm-security.test.mjs +32 -0
- package/scripts/cm-task-gate-correction.test.mjs +117 -0
- package/scripts/cm-task-gate.mjs +146 -10
- package/scripts/cm-task-gate.py +1 -0
- package/scripts/cm-test-branch-impact.test.mjs +11 -0
- package/scripts/cm-test-drive.mjs +10 -4
- package/scripts/cm-test-drive.test.mjs +14 -1
- package/scripts/cm-tool-preview-context.test.mjs +12 -0
- package/scripts/cm-usage-report.py +22 -3
- package/scripts/cm-workflow-config.mjs +10 -1
- package/scripts/fixtures/bootstrap-review-runner.mjs +102 -0
- package/scripts/fixtures/live-evidence-driver.mjs +35 -0
- package/scripts/fixtures/process-cleanup.mjs +3 -1
- package/scripts/test-cm-native-usage.py +62 -0
- package/scripts/test-external-model-setup.py +91 -0
- package/scripts/test-model-configuration-write.py +201 -0
- package/scripts/test-npm-install.py +10 -1
- package/skills/cm-ai/SKILL.md +2 -2
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/N8-finish.md +5 -0
- package/skills/cm-ai/references/js-host.md +16 -7
- package/skills/cm-ai/references/knowledge-closeout.md +90 -0
- package/skills/cm-fix/SKILL.md +1 -1
- package/skills/cm-fix/references/js-host.md +30 -2
- package/skills/cm-prd/SKILL.md +5 -4
- package/skills/cm-prd/references/spec-self-check.md +3 -1
- package/skills/cm-runtime/SKILL.md +29 -6
- package/skills/cm-security/SKILL.md +4 -2
- package/skills/cm-security/references/scan-contract.md +1 -0
- package/templates/cm-workflow.yml +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {readExecutionPolicy} from './execution-policy.mjs';
|
|
2
|
+
import {reconciliationControl} from './review-reconciliation.mjs';
|
|
1
3
|
// Claude normalized review bridge, no process dispatch or authority of its own.
|
|
2
4
|
import {need} from './effect-contract.mjs';
|
|
3
5
|
import {buildReviewPrompt} from './codex-review-adapter.mjs';
|
|
@@ -5,12 +7,13 @@ export function buildClaudeReviewPrompt(raw){
|
|
|
5
7
|
need(arguments.length===1,'review_request_invalid');
|
|
6
8
|
return buildReviewPrompt(raw,'claude');
|
|
7
9
|
}
|
|
8
|
-
export function createClaudeReviewRun(worker){
|
|
9
|
-
|
|
10
|
+
export function createClaudeReviewRun(worker,executionPolicy=null){
|
|
11
|
+
if(executionPolicy)readExecutionPolicy(executionPolicy);
|
|
12
|
+
need(arguments.length<=2&&typeof worker==='function','review_worker_invalid');
|
|
10
13
|
return Object.freeze((request,control)=>{
|
|
11
14
|
need(control&&typeof control==='object'&&typeof control.onEvent==='function'
|
|
12
15
|
&&control.signal&&typeof control.signal.aborted==='boolean','review_control_invalid');
|
|
13
|
-
return worker({prompt:
|
|
14
|
-
|
|
16
|
+
return worker({prompt:buildReviewPrompt(request,'claude',executionPolicy)},
|
|
17
|
+
reconciliationControl(control));
|
|
15
18
|
});
|
|
16
19
|
}
|
|
@@ -46,13 +46,13 @@ export function claudeProbeSandbox(temp,port) {
|
|
|
46
46
|
(deny file-write*)(allow file-write* (subpath ${JSON.stringify(temp)}) (literal "/dev/null"))`;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export async function previewClaudeTools({cwd,model,cli='claude',spawnProcess=spawn}) {
|
|
49
|
+
export async function previewClaudeTools({cwd,model,effort,cli='claude',spawnProcess=spawn}) {
|
|
50
50
|
if(process.platform!=='darwin'||!fs.existsSync('/usr/bin/sandbox-exec')) {
|
|
51
51
|
throw Object.assign(Error('unsupported_probe_isolation'),{code:'unsupported_probe_isolation'});
|
|
52
52
|
}
|
|
53
53
|
cwd=fs.realpathSync(cwd);
|
|
54
54
|
if(!fs.statSync(cwd).isDirectory())throw Error('invalid_code_project');
|
|
55
|
-
const fingerprint=claudeReviewFingerprint({cwd,model,cli});
|
|
55
|
+
const fingerprint=claudeReviewFingerprint({cwd,model,effort,cli});
|
|
56
56
|
const temp=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-claude-probe-')));
|
|
57
57
|
const observations=[];
|
|
58
58
|
const controller=new AbortController();let stoppedByProbe=false,modelMarker=null;
|
|
@@ -115,7 +115,7 @@ export async function previewClaudeTools({cwd,model,cli='claude',spawnProcess=sp
|
|
|
115
115
|
const preflight={passed:true,provider:'claude',prompt_transport:'stdin',config_fingerprint:fingerprint};
|
|
116
116
|
// Internal diagnostic bootstrap: same worker lifecycle, forced sink and synthetic prompt only.
|
|
117
117
|
// This object is never returned as a passing receipt without examining the captured request.
|
|
118
|
-
const worker=claudeWorker({cwd,model,cli,preflight,timeoutMs:15000,
|
|
118
|
+
const worker=claudeWorker({cwd,model,effort,cli,preflight,timeoutMs:15000,
|
|
119
119
|
spawnProcess:(command,args,options)=>{
|
|
120
120
|
const child=spawnProcess('/usr/bin/sandbox-exec',
|
|
121
121
|
['-p',claudeProbeSandbox(temp,port),command,...args],{...options,env:{...options.env,
|
|
@@ -137,7 +137,7 @@ export async function previewClaudeTools({cwd,model,cli='claude',spawnProcess=sp
|
|
|
137
137
|
fs.rmSync(temp,{recursive:true,force:true});
|
|
138
138
|
}
|
|
139
139
|
const messages=observations.filter(item=>item.startup!==true);
|
|
140
|
-
return {model,disabledSkills:[],preflight:{provider:'claude',prompt_transport:'stdin',
|
|
140
|
+
return {model,...(effort===undefined?{}:{effort}),disabledSkills:[],preflight:{provider:'claude',prompt_transport:'stdin',
|
|
141
141
|
config_fingerprint:fingerprint,passed:modelMarker===null&&messages.length>=1&&messages.length<=2&&messages.every(message=>message.valid)
|
|
142
142
|
&&stoppedByProbe&&result?.status==='cancelled'&&closeEvidence!==null&&!closeEvidence.timed_out,
|
|
143
143
|
local_requests:observations.length,message_requests:messages.length,message_requests_expected:'1-2',
|
|
@@ -34,8 +34,8 @@ export function inspectCmAiBootstrapTask({specsDir,codeProject,taskId},inProgres
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// Read N6 task counts with the original task parser, including later features.
|
|
37
|
-
export function inspectCmAiQaTaskContext({specsDir,codeProject,feature,taskId}) {
|
|
38
|
-
const admission=inspectCmAiAdmission({specsDir,codeProject});
|
|
37
|
+
export function inspectCmAiQaTaskContext({specsDir,codeProject,feature,taskId,featureSelection}) {
|
|
38
|
+
const admission=inspectCmAiAdmission({specsDir,codeProject,...selectedFeature(featureSelection)});
|
|
39
39
|
const fail=code=>{throw Object.assign(new Error(code),{code});};
|
|
40
40
|
if(!['ready','complete'].includes(admission.state))fail(admission.reason);
|
|
41
41
|
const discovered=discoverFeatures(admission.specsDir);if(discovered.error)fail(discovered.error);
|
|
@@ -54,8 +54,8 @@ export function inspectCmAiQaTaskContext({specsDir,codeProject,feature,taskId})
|
|
|
54
54
|
|
|
55
55
|
// Admission's public feature summary stops at the selected feature. Count all
|
|
56
56
|
// approved features with the same parser before treating a task as the last one.
|
|
57
|
-
export function isFinalCmAiTask({specsDir,codeProject,feature,taskId,parallelSelection=null}) {
|
|
58
|
-
const admission=inspectCmAiAdmission({specsDir,codeProject});
|
|
57
|
+
export function isFinalCmAiTask({specsDir,codeProject,feature,taskId,parallelSelection=null,featureSelection}) {
|
|
58
|
+
const admission=inspectCmAiAdmission({specsDir,codeProject,...selectedFeature(featureSelection)});
|
|
59
59
|
if(!matchesCmAiTaskSelection(admission,feature,taskId,parallelSelection))
|
|
60
60
|
throw Object.assign(new Error('documentation_admission_required'),{code:'documentation_admission_required'});
|
|
61
61
|
const discovered=discoverFeatures(admission.specsDir);
|
|
@@ -69,6 +69,11 @@ export function isFinalCmAiTask({specsDir,codeProject,feature,taskId,parallelSel
|
|
|
69
69
|
return pending===1;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
// An explicit feature selection is bound by the run definition (featureSelection)
|
|
73
|
+
// and only then passed to admission. Without it, selection is the original
|
|
74
|
+
// lowest-numbered feature with pending tasks.
|
|
75
|
+
export const selectedFeature=feature=>feature===undefined||feature===null?{}:{feature};
|
|
76
|
+
|
|
72
77
|
function frozen(value){
|
|
73
78
|
if(value && typeof value==='object'){for(const item of Object.values(value))frozen(item);Object.freeze(value);}
|
|
74
79
|
return value;
|
|
@@ -89,7 +94,7 @@ function approvalIntent(response,assumeYes){
|
|
|
89
94
|
if(response===undefined||response===null||response==='')return 'none';
|
|
90
95
|
if(typeof response!=='string')return 'not_approval';
|
|
91
96
|
const normalized=response.trim().replace(/[。!!.~~\s]+$/gu,'');
|
|
92
|
-
return new Set(['开始','开始吧','可以开始','确认开始','开始执行','现在开始']).has(normalized)?'explicit':'not_approval';
|
|
97
|
+
return new Set(['开始','开始吧','可以开始','确认开始','开始执行','现在开始','可以,请开始开发']).has(normalized)?'explicit':'not_approval';
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
|
|
@@ -311,7 +316,7 @@ function dependenciesSatisfied(task,parsed,byId){
|
|
|
311
316
|
});
|
|
312
317
|
}
|
|
313
318
|
|
|
314
|
-
function selectTask(specsDir,names){
|
|
319
|
+
function selectTask(specsDir,names,requestedFeature=null){
|
|
315
320
|
const features=[];
|
|
316
321
|
const warnings=[];
|
|
317
322
|
const evidence=reviewEvidenceNames(specsDir);
|
|
@@ -335,6 +340,9 @@ function selectTask(specsDir,names){
|
|
|
335
340
|
pending:pending.length,
|
|
336
341
|
});
|
|
337
342
|
if(!pending.length)continue;
|
|
343
|
+
// An explicitly selected later feature passes over earlier unfinished ones;
|
|
344
|
+
// they stay pending and unchanged, with their counts in features.
|
|
345
|
+
if(requestedFeature!==null&&name!==requestedFeature)continue;
|
|
338
346
|
// One dependency rule for nextTask and --task/parallel eligibility: a
|
|
339
347
|
// prerequisite is satisfied once it is completed or DROPPED.
|
|
340
348
|
const ready=task=>dependenciesSatisfied(task,parsed,byId);
|
|
@@ -343,6 +351,16 @@ function selectTask(specsDir,names){
|
|
|
343
351
|
return {features,warnings,nextTask:{feature:name,id:eligible.id,description:eligible.description},
|
|
344
352
|
eligibleTasks:pending.filter(ready).map(task=>({feature:name,id:task.id}))};
|
|
345
353
|
}
|
|
354
|
+
// The selected feature has nothing left: say so, and report the project's own
|
|
355
|
+
// next task rather than "complete". Callers never bind it to the selection.
|
|
356
|
+
// Keep this loop's feature summaries (every feature, the selected one too):
|
|
357
|
+
// the run of that feature still refreshes its context after its last task.
|
|
358
|
+
if(requestedFeature!==null){
|
|
359
|
+
const project=selectTask(specsDir,names);
|
|
360
|
+
if(project.error)return project;
|
|
361
|
+
return {...project,features,warnings:[...warnings,`所选 feature ${requestedFeature} 已无待办任务;`
|
|
362
|
+
+'不会为其他 feature 建运行或生成运行定义,请明确选择下一个 feature'],requestedFeatureComplete:requestedFeature};
|
|
363
|
+
}
|
|
346
364
|
return {features,warnings,nextTask:null};
|
|
347
365
|
}
|
|
348
366
|
|
|
@@ -420,6 +438,9 @@ function admissionFor(options,inProgressBootstrap=null){
|
|
|
420
438
|
if(!codeProject)return result(base,'blocked','code_project_missing');
|
|
421
439
|
const discovered=discoverFeatures(specsDir);
|
|
422
440
|
if(discovered.error)return result(base,'blocked',discovered.error);
|
|
441
|
+
const requestedFeature=input.feature===undefined?null:input.feature;
|
|
442
|
+
if(requestedFeature!==null&&!discovered.names.includes(requestedFeature))
|
|
443
|
+
return result(base,'blocked','feature_selection_invalid');
|
|
423
444
|
const status=readSpecsStatus(specsDir);
|
|
424
445
|
if(status.kind==='invalid')return result(base,'blocked','spec_status_invalid');
|
|
425
446
|
if(status.kind==='missing'||status.value.status==='awaiting_review'){
|
|
@@ -439,12 +460,13 @@ function admissionFor(options,inProgressBootstrap=null){
|
|
|
439
460
|
const bootstrapProblem=validateBootstrap(codeProject,specsDir,discovered.names);
|
|
440
461
|
if(bootstrapProblem&&!(bootstrapProblem==='bootstrap_conflict'&&inProgressBootstrap==='T-001'))
|
|
441
462
|
return result(base,'blocked',bootstrapProblem);
|
|
442
|
-
const selection=selectTask(specsDir,discovered.names);
|
|
463
|
+
const selection=selectTask(specsDir,discovered.names,requestedFeature);
|
|
443
464
|
if(selection.error)return result(base,'blocked',selection.error,{features:selection.features,warnings:selection.warnings,
|
|
444
465
|
...(selection.detail?{detail:selection.detail}:{})});
|
|
445
466
|
const warnings=[...selection.warnings,...featureQaWarnings(specsDir,selection.features)];
|
|
446
|
-
|
|
447
|
-
return result(base,'
|
|
467
|
+
const requested=selection.requestedFeatureComplete?{requestedFeatureComplete:selection.requestedFeatureComplete}:{};
|
|
468
|
+
if(!selection.nextTask)return result(base,'complete','all_tasks_terminal',{features:selection.features,warnings,...requested});
|
|
469
|
+
return result(base,'ready','task_selected',{features:selection.features,nextTask:selection.nextTask,eligibleTasks:selection.eligibleTasks,warnings,...requested});
|
|
448
470
|
}
|
|
449
471
|
|
|
450
472
|
// Diagnostic only: why an explicit --task selection is not eligible. Never used
|
|
@@ -452,7 +474,9 @@ function admissionFor(options,inProgressBootstrap=null){
|
|
|
452
474
|
export function explainCmAiTaskSelection(admission,{feature,taskId,selection=null}){
|
|
453
475
|
if(admission.state!=='ready')return `当前准入状态为 ${admission.state}/${admission.reason},不能选择任务`;
|
|
454
476
|
const next=admission.nextTask;
|
|
455
|
-
if(
|
|
477
|
+
if(admission.requestedFeatureComplete===feature)return `所选 feature ${feature} 已无待办任务,不能为它新建运行;请明确选择下一个 feature`;
|
|
478
|
+
if(next&&next.feature!==feature)return `--task 只能选择当前 feature ${next.feature} 的任务(运行定义为 ${feature})`
|
|
479
|
+
+(admission.requestedFeatureComplete===undefined?`;已批准的跨 feature 顺序要先做 ${feature} 时,用 cm-ai-admission.mjs --feature ${feature} --print-run-definition 重新生成运行定义,或给 cm-ai-host.mjs 加 --feature ${feature}`:'');
|
|
456
480
|
if(!admission.specsDir)return `${taskId} 不在可选任务中`;
|
|
457
481
|
let parsed;
|
|
458
482
|
try{parsed=readFeature(admission.specsDir,feature);}catch{return `无法读取 ${feature}/tasks.md`;}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {createHash} from 'node:crypto';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import {inspectCmAiAdmission,matchesCmAiTaskSelection,identifyApprovedBootstrapFeature} from './cm-ai-admission.mjs';
|
|
5
|
+
import {inspectCmAiAdmission,matchesCmAiTaskSelection,identifyApprovedBootstrapFeature,selectedFeature} from './cm-ai-admission.mjs';
|
|
6
6
|
import {arrayItems,digest,freeze,hex,json,need,shape,text,validIdentity,validTaskLearningInput} from './effect-contract.mjs';
|
|
7
7
|
|
|
8
8
|
const BASELINE_RULES=['coding-style.md','testing.md','security.md'];
|
|
@@ -59,9 +59,12 @@ export function readProjectInstructionContext(codeProject,applicableAgentFiles=[
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export function inspectCmAiContextRefresh(input,{admission:trustedAdmission=null}={}) {
|
|
62
|
-
shape(input,['specsDir','codeProject','feature','applicableAgentFiles']);
|
|
62
|
+
shape(input,['specsDir','codeProject','feature','applicableAgentFiles',...(Object.hasOwn(input,'featureSelection')?['featureSelection']:[])]);
|
|
63
63
|
text(input.specsDir);text(input.codeProject);text(input.feature);
|
|
64
|
-
|
|
64
|
+
// A run bound to an explicit feature (featureSelection) reads admission for it.
|
|
65
|
+
need(!Object.hasOwn(input,'featureSelection')||input.featureSelection===input.feature,'context_invalid');
|
|
66
|
+
const admission=trustedAdmission??inspectCmAiAdmission({specsDir:input.specsDir,codeProject:input.codeProject,
|
|
67
|
+
...selectedFeature(input.featureSelection)});
|
|
65
68
|
if(trustedAdmission!==null)need(input.feature===identifyApprovedBootstrapFeature(
|
|
66
69
|
trustedAdmission.features.map(item=>item.name))
|
|
67
70
|
&&admission.specsDir===input.specsDir&&admission.codeProject===input.codeProject,'context_invalid');
|
|
@@ -80,10 +83,11 @@ export function inspectCmAiContextRefresh(input,{admission:trustedAdmission=null
|
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
export function inspectCmAiTaskLearningInput(input,authority={}) {
|
|
83
|
-
shape(input,['specsDir','codeProject','feature','identity','applicableAgentFiles']);
|
|
86
|
+
shape(input,['specsDir','codeProject','feature','identity','applicableAgentFiles',...(Object.hasOwn(input,'featureSelection')?['featureSelection']:[])]);
|
|
84
87
|
text(input.feature);const identity=json(input.identity);validIdentity(identity);
|
|
85
88
|
const refresh=inspectCmAiContextRefresh({specsDir:input.specsDir,codeProject:input.codeProject,
|
|
86
|
-
feature:input.feature,applicableAgentFiles:input.applicableAgentFiles
|
|
89
|
+
feature:input.feature,applicableAgentFiles:input.applicableAgentFiles,
|
|
90
|
+
...(Object.hasOwn(input,'featureSelection')?{featureSelection:input.featureSelection}:{})},authority);
|
|
87
91
|
need(matchesCmAiTaskSelection(refresh,input.feature,identity.taskId,authority.parallelSelection??null),'learning_context_invalid');
|
|
88
92
|
const agentPaths=new Set(['AGENTS.md',...arrayItems(input.applicableAgentFiles)]);
|
|
89
93
|
const selected=refresh.contextFiles.filter(file=>file.scope==='specs'?file.path==='LESSONS.md':
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
// Fixed Codex-host entry for the existing cm-ai admission and V3 task runner.
|
|
2
|
-
import {inspectCmAiAdmission,matchesCmAiTaskSelection} from './cm-ai-admission.mjs';
|
|
2
|
+
import {inspectCmAiAdmission,matchesCmAiTaskSelection,selectedFeature} from './cm-ai-admission.mjs';
|
|
3
3
|
import {inspectCmAiContextRefresh,inspectCmAiTaskLearningInput} from './cm-ai-context-refresh.mjs';
|
|
4
4
|
import {findCmAiQaDecision,inspectCmAiQaDecision,inspectCmAiQaResult,recordCmAiQaDecision,
|
|
5
5
|
latestCmAiQaRun,recordCmAiQaRun,inspectCmAiQaRecovery,inspectCmAiQaConfigurationRecovery,timedOutQaDecision,
|
|
6
6
|
replacesTimedOutQaDecision,validEnvironmentFailureReason} from './cm-ai-qa-log.mjs';
|
|
7
7
|
import {recordCmAiRunDone} from './cm-ai-run-finalizer.mjs';
|
|
8
|
+
import {projectHostResult} from './host-progress.mjs';
|
|
9
|
+
import {operatorGuidance} from './operator-guidance.mjs';
|
|
8
10
|
import {outstandingFeatureQa,describeOutstandingQa} from './project-qa-gate.mjs';
|
|
9
11
|
import {REVIEWED_HANDOFF_HINT} from './host-handoff.mjs';
|
|
10
12
|
import {readHostQaFixHandoff} from './host-qa-fix.mjs';
|
|
13
|
+
import {readCloseoutPolicy,readCloseoutReport,closeoutSummary} from './knowledge-closeout.mjs';
|
|
11
14
|
import {digest,freeze,hex,id,json,need,shape,text,validIdentity} from './effect-contract.mjs';
|
|
12
15
|
|
|
13
16
|
const sameIdentity=(left,right)=>['repositoryId','runId','taskId','attempt'].every(key=>left[key]===right[key]);
|
|
@@ -33,6 +36,8 @@ export const completionRetryable=status=>status.state==='blocked'
|
|
|
33
36
|
const pendingAction=status=>status.state==='awaiting_spec_approval'?'spec_approval':
|
|
34
37
|
// The runner reports spec_drift over any state whose next effect would be refused.
|
|
35
38
|
status.code==='spec_drift'?(status.specificationRebind==='available'?'spec_rebind':'none'):
|
|
39
|
+
status.bootstrapReviewRecovery===true?'bootstrap_review_recover':
|
|
40
|
+
status.reviewReconciliation?.available?'reconcile_review':
|
|
36
41
|
status.state==='changes_requested'||retryDeveloper(status)||retryReview(status)?'resume':
|
|
37
42
|
status.state==='awaiting_review'?'decision':status.state==='unknown'
|
|
38
43
|
?(status.pendingEffectKind?'abandon_effect':
|
|
@@ -54,6 +59,7 @@ const pendingAction=status=>status.state==='awaiting_spec_approval'?'spec_approv
|
|
|
54
59
|
const summary=(operation,status,outcome)=>freeze({version:1,workflow:'cm-ai',operation:operation.operation,
|
|
55
60
|
requestDigest:digest(operation),identity:status.identity,outcome,state:status.state,code:status.code??null,
|
|
56
61
|
packageDigest:status.packageDigest??null,pendingAction:pendingAction(status),
|
|
62
|
+
...(status.reviewReconciliation?{reviewReconciliation:status.reviewReconciliation}:{}),
|
|
57
63
|
...(typeof status.reason==='string'?{reason:status.reason}:{}),
|
|
58
64
|
...(status.code==='handoff_exists'?{reason:REVIEWED_HANDOFF_HINT}:{}),
|
|
59
65
|
...(status.state==='blocked'&&status.calls?.at(-1)?.blockedReason!==undefined
|
|
@@ -63,7 +69,7 @@ const correctionSummary=(operation,status)=>status.code==='correction_review_req
|
|
|
63
69
|
// run_done is a project claim: every approved feature's latest mandatory QA must
|
|
64
70
|
// have passed, not only this final run's own. Read with the strict owner validator.
|
|
65
71
|
function projectQaSummary(operation,status,options){
|
|
66
|
-
const admission=inspectCmAiAdmission({specsDir:options.specsDir,codeProject:options.codeProject});
|
|
72
|
+
const admission=inspectCmAiAdmission({specsDir:options.specsDir,codeProject:options.codeProject,...selectedFeature(options.featureSelection)});
|
|
67
73
|
const outstanding=outstandingFeatureQa({specsDir:options.specsDir,features:admission.features.map(({name,pending})=>({name,pending})),
|
|
68
74
|
currentRunId:status.identity.runId,inspect:latestCmAiQaRun});
|
|
69
75
|
if(!outstanding.length)return null;
|
|
@@ -76,9 +82,11 @@ function readOperation(raw) {
|
|
|
76
82
|
const operation=json(raw),keys=['version','operation','requestId','identity'];
|
|
77
83
|
if(['decision','complete','qa','qa_result','context_refresh','finish','run_finalize'].includes(operation?.operation))keys.push('packageDigest');
|
|
78
84
|
if(['qa_result','context_refresh','finish','run_finalize'].includes(operation?.operation))keys.push('testRunId');
|
|
79
|
-
if(['abandon_review','abandon_effect'].includes(operation?.operation))keys.push('reason');
|
|
85
|
+
if(['abandon_review','abandon_effect','bootstrap_review_recover'].includes(operation?.operation))keys.push('reason');
|
|
86
|
+
if(operation?.operation==='reconcile_review')keys.push('invocationId');
|
|
80
87
|
shape(operation,keys);
|
|
81
|
-
|
|
88
|
+
if(operation?.operation==='reconcile_review')id(operation.invocationId);
|
|
89
|
+
need(operation.version===1&&['advance','start','status','decision','complete','qa','qa_result','context_refresh','finish','run_finalize','cancel','resume','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover']
|
|
82
90
|
.includes(operation.operation));
|
|
83
91
|
id(operation.requestId);validIdentity(operation.identity);
|
|
84
92
|
if(operation.operation==='abandon_review')need(typeof operation.reason==='string'
|
|
@@ -87,6 +95,9 @@ function readOperation(raw) {
|
|
|
87
95
|
if(operation.operation==='abandon_effect')need(typeof operation.reason==='string'
|
|
88
96
|
&&operation.reason.trim().length>0&&Buffer.byteLength(operation.reason,'utf8')<=500
|
|
89
97
|
&&!/[\r\n\0]/.test(operation.reason),'effect_abandon_reason_required');
|
|
98
|
+
if(operation.operation==='bootstrap_review_recover')need(typeof operation.reason==='string'
|
|
99
|
+
&&operation.reason.trim().length>0&&Buffer.byteLength(operation.reason,'utf8')<=500
|
|
100
|
+
&&!/[\r\n\0]/.test(operation.reason),'bootstrap_review_recovery_reason_required');
|
|
90
101
|
if(['decision','complete','qa','qa_result','context_refresh','finish','run_finalize'].includes(operation.operation))hex(operation.packageDigest);
|
|
91
102
|
if(operation.operation==='qa_result')id(operation.testRunId);
|
|
92
103
|
if(['context_refresh','finish','run_finalize'].includes(operation.operation)){
|
|
@@ -148,8 +159,10 @@ const contextSummary=(operation,status,refresh)=>freeze({version:1,workflow:'cm-
|
|
|
148
159
|
pendingAction:refresh.state==='complete'?'finish':'start_next_task',nextTask:refresh.nextTask,
|
|
149
160
|
contextDigest:refresh.contextDigest,contextFiles:refresh.contextFiles});
|
|
150
161
|
|
|
151
|
-
function validateDocumentationResult(result,status,refresh) {
|
|
152
|
-
shape(result,['syncId','identity','packageDigest','contextDigest','status','reason','at'
|
|
162
|
+
function validateDocumentationResult(result,status,refresh,policy=null) {
|
|
163
|
+
shape(result,['syncId','identity','packageDigest','contextDigest','status','reason','at',
|
|
164
|
+
...(policy?.enabled&&Object.hasOwn(result,'closeout')?['closeout']:[])]);
|
|
165
|
+
if(Object.hasOwn(result,'closeout'))readCloseoutReport(result.closeout);
|
|
153
166
|
id(result.syncId);validIdentity(result.identity);hex(result.packageDigest);hex(result.contextDigest);
|
|
154
167
|
need(sameIdentity(result.identity,status.identity),'identity_mismatch');
|
|
155
168
|
need(result.packageDigest===status.packageDigest&&result.contextDigest===refresh.contextDigest,'stale_documentation');
|
|
@@ -176,11 +189,16 @@ export function createCmAiConversationEntry(options) {
|
|
|
176
189
|
if(options&&Object.hasOwn(options,'applicableAgentFiles'))optionKeys.push('applicableAgentFiles');
|
|
177
190
|
if(options&&Object.hasOwn(options,'documentationResult'))optionKeys.push('documentationResult');
|
|
178
191
|
if(options&&Object.hasOwn(options,'documentationProvider'))optionKeys.push('documentationProvider');
|
|
192
|
+
if(options&&Object.hasOwn(options,'knowledgeCloseout'))optionKeys.push('knowledgeCloseout');
|
|
193
|
+
if(options&&Object.hasOwn(options,'codeProjects'))optionKeys.push('codeProjects');
|
|
179
194
|
if(options&&Object.hasOwn(options,'parallelSelection'))optionKeys.push('parallelSelection');
|
|
180
195
|
if(options&&Object.hasOwn(options,'allowAbandonReview'))optionKeys.push('allowAbandonReview');
|
|
181
196
|
if(options&&Object.hasOwn(options,'allowAbandonEffect'))optionKeys.push('allowAbandonEffect');
|
|
197
|
+
if(options&&Object.hasOwn(options,'allowBootstrapReviewRecovery'))optionKeys.push('allowBootstrapReviewRecovery');
|
|
182
198
|
if(options&&Object.hasOwn(options,'holdRevision'))optionKeys.push('holdRevision');
|
|
199
|
+
if(options&&Object.hasOwn(options,'featureSelection'))optionKeys.push('featureSelection');
|
|
183
200
|
shape(options,optionKeys);
|
|
201
|
+
need(!Object.hasOwn(options,'featureSelection')||options.featureSelection===options.feature,'invalid_input');
|
|
184
202
|
need(!Object.hasOwn(options,'holdRevision')||options.holdRevision===true,'invalid_input');
|
|
185
203
|
if(Object.hasOwn(options,'developmentAttempt'))need([1,2].includes(options.developmentAttempt),'invalid_development_attempt');
|
|
186
204
|
text(options.specsDir);text(options.codeProject);text(options.feature);
|
|
@@ -197,7 +215,9 @@ export function createCmAiConversationEntry(options) {
|
|
|
197
215
|
if(runner&&Object.hasOwn(runner,'supersedeEvidence'))runnerKeys.push('supersedeEvidence');
|
|
198
216
|
if(runner&&Object.hasOwn(runner,'rebindSpecification'))runnerKeys.push('rebindSpecification');
|
|
199
217
|
if(runner&&Object.hasOwn(runner,'abandonReview'))runnerKeys.push('abandonReview');
|
|
218
|
+
if(runner&&Object.hasOwn(runner,'reconcileReview'))runnerKeys.push('reconcileReview');
|
|
200
219
|
if(runner&&Object.hasOwn(runner,'abandonEffect'))runnerKeys.push('abandonEffect');
|
|
220
|
+
if(runner&&Object.hasOwn(runner,'recoverBootstrapReview'))runnerKeys.push('recoverBootstrapReview');
|
|
201
221
|
if(runner&&Object.hasOwn(runner,'inspectBootstrapAdmission'))runnerKeys.push('inspectBootstrapAdmission');
|
|
202
222
|
shape(runner,runnerKeys);
|
|
203
223
|
for(const name of ['executeEffect','status','cancel','run'])need(typeof runner[name]==='function');
|
|
@@ -208,12 +228,16 @@ export function createCmAiConversationEntry(options) {
|
|
|
208
228
|
if(Object.hasOwn(runner,'attachQa'))need(typeof runner.attachQa==='function');
|
|
209
229
|
if(Object.hasOwn(runner,'reviseQa'))need(typeof runner.reviseQa==='function');
|
|
210
230
|
if(Object.hasOwn(runner,'abandonReview'))need(typeof runner.abandonReview==='function');
|
|
231
|
+
if(Object.hasOwn(runner,'reconcileReview'))need(typeof runner.reconcileReview==='function');
|
|
211
232
|
if(Object.hasOwn(runner,'abandonEffect'))need(typeof runner.abandonEffect==='function');
|
|
233
|
+
if(Object.hasOwn(runner,'recoverBootstrapReview'))need(typeof runner.recoverBootstrapReview==='function');
|
|
212
234
|
if(Object.hasOwn(runner,'inspectBootstrapAdmission'))need(typeof runner.inspectBootstrapAdmission==='function');
|
|
213
235
|
need(options.allowAbandonReview===undefined||typeof options.allowAbandonReview==='boolean','invalid_input');
|
|
214
236
|
let abandonPermission=options.allowAbandonReview===true;
|
|
215
237
|
need(options.allowAbandonEffect===undefined||typeof options.allowAbandonEffect==='boolean','invalid_input');
|
|
216
238
|
let abandonEffectPermission=options.allowAbandonEffect===true;
|
|
239
|
+
need(options.allowBootstrapReviewRecovery===undefined||typeof options.allowBootstrapReviewRecovery==='boolean','invalid_input');
|
|
240
|
+
let bootstrapReviewRecoveryPermission=options.allowBootstrapReviewRecovery===true;
|
|
217
241
|
|
|
218
242
|
const hostDecision=Object.hasOwn(options,'hostDecision')?json(options.hostDecision):null;
|
|
219
243
|
let hostDecisionProvider=null,pendingReviewDecision=null;
|
|
@@ -254,6 +278,9 @@ export function createCmAiConversationEntry(options) {
|
|
|
254
278
|
}
|
|
255
279
|
const applicableAgentFiles=Object.hasOwn(options,'applicableAgentFiles')?json(options.applicableAgentFiles):null;
|
|
256
280
|
const documentationResult=Object.hasOwn(options,'documentationResult')?json(options.documentationResult):null;
|
|
281
|
+
const knowledgeCloseout=Object.hasOwn(options,'knowledgeCloseout')?readCloseoutPolicy(options.knowledgeCloseout):null;
|
|
282
|
+
if(Object.hasOwn(options,'codeProjects'))need(knowledgeCloseout!==null&&Array.isArray(options.codeProjects)
|
|
283
|
+
&&options.codeProjects.length>0&&options.codeProjects.every(value=>typeof value==='string'),'invalid_input');
|
|
257
284
|
let documentationProvider=null,pendingDocumentation=null,inspectedDocumentation=null;
|
|
258
285
|
if(Object.hasOwn(options,'documentationProvider')){
|
|
259
286
|
shape(options.documentationProvider,['inspect','timeoutMs']);
|
|
@@ -266,7 +293,9 @@ export function createCmAiConversationEntry(options) {
|
|
|
266
293
|
async function documentationFor(status,refresh){
|
|
267
294
|
if(documentationProvider===null)return documentationResult;
|
|
268
295
|
const binding=json({specsDir:options.specsDir,codeProject:options.codeProject,feature:options.feature,
|
|
269
|
-
identity:status.identity,packageDigest:status.packageDigest,contextDigest:refresh.contextDigest
|
|
296
|
+
identity:status.identity,packageDigest:status.packageDigest,contextDigest:refresh.contextDigest,
|
|
297
|
+
...(knowledgeCloseout===null?{}:{closeout:knowledgeCloseout,
|
|
298
|
+
...(options.codeProjects?{codeProjects:options.codeProjects}:{})})});
|
|
270
299
|
const syncId=`docs-${digest(binding).slice(0,48)}`;
|
|
271
300
|
if(inspectedDocumentation?.syncId===syncId)return inspectedDocumentation;
|
|
272
301
|
need(pendingDocumentation===null,'documentation_pending');
|
|
@@ -286,35 +315,39 @@ export function createCmAiConversationEntry(options) {
|
|
|
286
315
|
need(!controller.signal.aborted,'cancelled');need(result.syncId===syncId,'stale_documentation');
|
|
287
316
|
const current=boundStatus(runner.status(),status.identity);
|
|
288
317
|
need(current.state==='fixture_completed'&¤t.code==null&¤t.packageDigest===status.packageDigest,'stale_documentation');
|
|
289
|
-
const reread=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
318
|
+
const reread=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,...(options.featureSelection===undefined?{}:{featureSelection:options.featureSelection}),
|
|
290
319
|
feature:options.feature,applicableAgentFiles});
|
|
291
320
|
need(reread.state==='complete'&&reread.contextDigest===refresh.contextDigest,'stale_documentation');
|
|
292
|
-
validateDocumentationResult(result,current,reread);
|
|
321
|
+
validateDocumentationResult(result,current,reread,knowledgeCloseout);
|
|
293
322
|
if(result.status==='completed')inspectedDocumentation=result;
|
|
294
323
|
return result;
|
|
295
324
|
}finally{clearTimeout(timer);pendingDocumentation=null;}
|
|
296
325
|
}
|
|
297
326
|
|
|
327
|
+
// Admission summaries do not describe a runner transition. Track their
|
|
328
|
+
// origin privately; other awaiting results still need progress projection.
|
|
329
|
+
const admissionReports=new WeakSet();
|
|
298
330
|
async function route(raw) {
|
|
299
331
|
const operation=readOperation(raw);
|
|
300
332
|
need(sameTask(operation.identity,ownerIdentity),'identity_mismatch');
|
|
301
333
|
need(operation.identity.attempt>=ownerIdentity.attempt,'identity_mismatch');
|
|
302
334
|
const admission=['start','resume'].includes(operation.operation)
|
|
303
|
-
?runner.inspectBootstrapAdmission?.()??inspectCmAiAdmission({specsDir:options.specsDir,codeProject:options.codeProject}):null;
|
|
335
|
+
?runner.inspectBootstrapAdmission?.()??inspectCmAiAdmission({specsDir:options.specsDir,codeProject:options.codeProject,...selectedFeature(options.featureSelection)}):null;
|
|
304
336
|
if(admission&&admission.state!=='ready'){
|
|
305
337
|
// Original callers still stop before reading runner state. A caller using
|
|
306
338
|
// a newer attempt must bind it to the runner before we report its block.
|
|
307
339
|
const blockedIdentity=sameIdentity(operation.identity,ownerIdentity)?ownerIdentity:
|
|
308
340
|
boundStatus(runner.status(),operation.identity).identity;
|
|
309
|
-
|
|
341
|
+
const report=summary(operation,{state:admission.state,code:admission.reason,
|
|
310
342
|
identity:blockedIdentity,packageDigest:null},'awaiting');
|
|
343
|
+
admissionReports.add(report);return report;
|
|
311
344
|
}
|
|
312
345
|
const initialStatus=runner.status();
|
|
313
346
|
const identity=json(initialStatus.identity);validIdentity(identity);
|
|
314
347
|
need(sameTask(identity,ownerIdentity)&&identity.attempt>=ownerIdentity.attempt,'identity_mismatch');
|
|
315
348
|
// Stable run-definition identity can query/control or resume the current
|
|
316
349
|
// attempt. Package-bound mutations must name the current attempt exactly.
|
|
317
|
-
const stableControl=['status','cancel','advance','resume','abandon_review','abandon_effect'].includes(operation.operation)
|
|
350
|
+
const stableControl=['status','cancel','advance','resume','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover'].includes(operation.operation)
|
|
318
351
|
&&sameIdentity(operation.identity,ownerIdentity);
|
|
319
352
|
need(sameIdentity(operation.identity,identity)||stableControl,'identity_mismatch');
|
|
320
353
|
if(operation.operation==='advance'){
|
|
@@ -353,7 +386,7 @@ export function createCmAiConversationEntry(options) {
|
|
|
353
386
|
notCancelled();
|
|
354
387
|
need(pendingExecution===null,'qa_execution_pending');
|
|
355
388
|
const binding={specsDir:options.specsDir,feature:options.feature,identity:result.identity,packageDigest:result.packageDigest};
|
|
356
|
-
let previous,recovery=null,configurationRecovery=false;
|
|
389
|
+
let previous,recovery=null,configurationRecovery=false,incompleteReport=false;
|
|
357
390
|
try{previous=latestCmAiQaRun(binding);}
|
|
358
391
|
catch(error){
|
|
359
392
|
if(error.code==='qa_result_superseded'){
|
|
@@ -365,6 +398,14 @@ export function createCmAiConversationEntry(options) {
|
|
|
365
398
|
try{recovery=inspectCmAiQaRecovery(binding);}
|
|
366
399
|
catch(error){if(error.code!=='qa_execution_unknown')throw error;}
|
|
367
400
|
}
|
|
401
|
+
// The call wrote its fixed report but no complete row (a host before
|
|
402
|
+
// this fix rejected stale_qa in between). --rerun-blocked-qa reads
|
|
403
|
+
// that report under the ordinary blocked-evidence rules.
|
|
404
|
+
if(recovery===null&&rerunBlockedQa){
|
|
405
|
+
recovery=inspectCmAiQaRecovery(binding,{blocked:true,environment:qaExecutor.configuration?.environment,
|
|
406
|
+
environmentFailure:qaEnvironmentFailure});
|
|
407
|
+
incompleteReport=true;
|
|
408
|
+
}
|
|
368
409
|
if(recovery===null)return summary(operation,{...runner.status(),code:'qa_execution_unknown'},'blocked');
|
|
369
410
|
previous=null;
|
|
370
411
|
}
|
|
@@ -373,7 +414,7 @@ export function createCmAiConversationEntry(options) {
|
|
|
373
414
|
// decision with no QA run under it yet (just written, or written
|
|
374
415
|
// before an interruption): run the ordinary first round, not a rerun.
|
|
375
416
|
if(rerunBlockedQa&&previous===null&&replacesTimedOutQaDecision(binding))rerunBlockedQa=false;
|
|
376
|
-
if(rerunBlockedQa){
|
|
417
|
+
if(rerunBlockedQa&&!incompleteReport){
|
|
377
418
|
need(previous!==null,'qa_rerun_not_blocked_by_evidence');
|
|
378
419
|
recovery=inspectCmAiQaRecovery(binding,{blocked:true,environment:qaExecutor.configuration?.environment,
|
|
379
420
|
environmentFailure:qaEnvironmentFailure});
|
|
@@ -418,9 +459,16 @@ export function createCmAiConversationEntry(options) {
|
|
|
418
459
|
return qaExecutor.run(freeze(invocation),controller.signal);
|
|
419
460
|
}),interrupted]);
|
|
420
461
|
need(!controller.signal.aborted,'cancelled');
|
|
462
|
+
// A run that moved on meanwhile (for example files in scope replaced):
|
|
463
|
+
// still record a BLOCKED or FAIL this call observed, so the restored run
|
|
464
|
+
// can take the ordinary --rerun-blocked-qa path instead of staying
|
|
465
|
+
// qa_execution_unknown (a source change is already BLOCKED/sourceChanged).
|
|
466
|
+
// A PASS is never recorded unconfirmed; it stays unknown, and only
|
|
467
|
+
// --rerun-unknown-qa may discard that fully backed all-PASS report.
|
|
421
468
|
const current=boundStatus(runner.status(),result.identity);
|
|
422
|
-
|
|
423
|
-
recordCmAiQaRun({...logInput,phase:'complete',result:executed});
|
|
469
|
+
const fresh=current.state==='fixture_completed'&¤t.code==null&¤t.packageDigest===result.packageDigest;
|
|
470
|
+
if(fresh||executed.result!=='PASS')recordCmAiQaRun({...logInput,phase:'complete',result:executed});
|
|
471
|
+
need(fresh,'stale_qa');
|
|
424
472
|
}finally{clearTimeout(timer);pendingExecution=null;}
|
|
425
473
|
}
|
|
426
474
|
result=await call('qa_result',result.packageDigest,{testRunId});
|
|
@@ -443,7 +491,9 @@ export function createCmAiConversationEntry(options) {
|
|
|
443
491
|
}
|
|
444
492
|
// Next-task execution and QA execution still need their host adapters;
|
|
445
493
|
// a refreshed nextTask is not permission to dispatch it or claim run_done.
|
|
446
|
-
|
|
494
|
+
const advanced=freeze({...result,operation:'advance',requestDigest:digest(operation)});
|
|
495
|
+
if(admissionReports.has(result))admissionReports.add(advanced);
|
|
496
|
+
return advanced;
|
|
447
497
|
}
|
|
448
498
|
if(operation.operation==='status'){
|
|
449
499
|
const status=boundStatus(initialStatus,identity);
|
|
@@ -460,6 +510,12 @@ export function createCmAiConversationEntry(options) {
|
|
|
460
510
|
const status=boundStatus(runner.cancel(),identity);
|
|
461
511
|
return summary(operation,status,status.state==='cancelled'||interrupted?'cancelled':'reported');
|
|
462
512
|
}
|
|
513
|
+
if(operation.operation==='reconcile_review'){
|
|
514
|
+
const result=runner.reconcileReview?.({invocationId:operation.invocationId})
|
|
515
|
+
??{outcome:'rejected',code:'review_reconciliation_unavailable'};
|
|
516
|
+
return result.outcome==='rejected'?summary(operation,{...runner.status(),code:result.code},'rejected')
|
|
517
|
+
:summary(operation,result,'reconciled');
|
|
518
|
+
}
|
|
463
519
|
if(operation.operation==='abandon_review'){
|
|
464
520
|
if(!abandonPermission)return summary(operation,{...runner.status(),
|
|
465
521
|
code:'review_abandon_authorization_required'},'rejected');
|
|
@@ -479,6 +535,16 @@ export function createCmAiConversationEntry(options) {
|
|
|
479
535
|
...(result.reason?{reason:result.reason}:{})},'rejected');
|
|
480
536
|
return summary(operation,boundStatus(result,identity),'abandoned');
|
|
481
537
|
}
|
|
538
|
+
if(operation.operation==='bootstrap_review_recover'){
|
|
539
|
+
if(!bootstrapReviewRecoveryPermission)return summary(operation,{...runner.status(),
|
|
540
|
+
code:'bootstrap_review_recovery_authorization_required'},'rejected');
|
|
541
|
+
bootstrapReviewRecoveryPermission=false;
|
|
542
|
+
const result=runner.recoverBootstrapReview?.({allowed:true,reason:operation.reason})
|
|
543
|
+
??{outcome:'rejected',code:'bootstrap_review_recovery_unavailable'};
|
|
544
|
+
if(result.outcome==='rejected')return summary(operation,{...runner.status(),code:result.code,
|
|
545
|
+
...(result.reason?{reason:result.reason}:{})},'rejected');
|
|
546
|
+
return summary(operation,boundStatus(result,identity),'advanced');
|
|
547
|
+
}
|
|
482
548
|
if(operation.operation==='decision'){
|
|
483
549
|
const status=boundStatus(runner.status(),identity);
|
|
484
550
|
need(status.packageDigest===operation.packageDigest,'stale_decision');
|
|
@@ -573,7 +639,7 @@ export function createCmAiConversationEntry(options) {
|
|
|
573
639
|
}
|
|
574
640
|
if(decision===null)return summary(operation,{...status,code:'qa_decision_required'},'awaiting');
|
|
575
641
|
if(decision.status==='skipped'){
|
|
576
|
-
const admission=inspectCmAiAdmission({specsDir:options.specsDir,codeProject:options.codeProject});
|
|
642
|
+
const admission=inspectCmAiAdmission({specsDir:options.specsDir,codeProject:options.codeProject,...selectedFeature(options.featureSelection)});
|
|
577
643
|
if(!['ready','complete'].includes(admission.state))
|
|
578
644
|
return summary(operation,{...status,code:admission.reason},'awaiting');
|
|
579
645
|
const feature=admission.features.find(item=>item.name===options.feature);
|
|
@@ -614,7 +680,7 @@ export function createCmAiConversationEntry(options) {
|
|
|
614
680
|
need(status.state==='fixture_completed','context_not_ready');
|
|
615
681
|
contextEvidence(options,identity,operation);
|
|
616
682
|
need(applicableAgentFiles!==null,'context_invalid');
|
|
617
|
-
const refresh=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
683
|
+
const refresh=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,...(options.featureSelection===undefined?{}:{featureSelection:options.featureSelection}),
|
|
618
684
|
feature:options.feature,applicableAgentFiles});
|
|
619
685
|
if(!['ready','complete'].includes(refresh.state))return summary(operation,{state:refresh.state,
|
|
620
686
|
code:refresh.reason,identity,packageDigest:status.packageDigest},'awaiting');
|
|
@@ -627,7 +693,7 @@ export function createCmAiConversationEntry(options) {
|
|
|
627
693
|
need(status.state==='fixture_completed','run_not_ready');
|
|
628
694
|
contextEvidence(options,identity,operation);
|
|
629
695
|
need(applicableAgentFiles!==null,'context_invalid');
|
|
630
|
-
const refresh=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
696
|
+
const refresh=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,...(options.featureSelection===undefined?{}:{featureSelection:options.featureSelection}),
|
|
631
697
|
feature:options.feature,applicableAgentFiles});
|
|
632
698
|
need(refresh.state==='complete','run_not_ready');
|
|
633
699
|
const projectQa=projectQaSummary(operation,status,options);if(projectQa)return projectQa;
|
|
@@ -639,10 +705,11 @@ export function createCmAiConversationEntry(options) {
|
|
|
639
705
|
need(current.state==='fixture_completed'&¤t.code==null&¤t.packageDigest===status.packageDigest,'stale_documentation');
|
|
640
706
|
if(documentation===null)
|
|
641
707
|
return summary(operation,{...status,code:'documentation_sync_required'},'awaiting');
|
|
642
|
-
const result=validateDocumentationResult(documentation,status,refresh);
|
|
643
|
-
if(result==='blocked')return summary(operation,{...status,code:'documentation_sync_blocked'},'blocked')
|
|
708
|
+
const result=validateDocumentationResult(documentation,status,refresh,knowledgeCloseout);
|
|
709
|
+
if(result==='blocked')return freeze({...summary(operation,{...status,code:'documentation_sync_blocked'},'blocked'),
|
|
710
|
+
...closeoutSummary(knowledgeCloseout,documentation)});
|
|
644
711
|
return freeze({...summary(operation,{...status,code:'documentation_synced'},'verified'),
|
|
645
|
-
contextDigest:refresh.contextDigest});
|
|
712
|
+
contextDigest:refresh.contextDigest,...closeoutSummary(knowledgeCloseout,documentation)});
|
|
646
713
|
}
|
|
647
714
|
if(operation.operation==='run_finalize'){
|
|
648
715
|
const status=boundStatus(runner.status(),identity);
|
|
@@ -651,7 +718,7 @@ export function createCmAiConversationEntry(options) {
|
|
|
651
718
|
need(status.state==='fixture_completed','run_not_ready');
|
|
652
719
|
contextEvidence(options,identity,operation);
|
|
653
720
|
need(applicableAgentFiles!==null,'context_invalid');
|
|
654
|
-
const refresh=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
721
|
+
const refresh=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,...(options.featureSelection===undefined?{}:{featureSelection:options.featureSelection}),
|
|
655
722
|
feature:options.feature,applicableAgentFiles});
|
|
656
723
|
need(refresh.state==='complete','run_not_ready');
|
|
657
724
|
const projectQa=projectQaSummary(operation,status,options);if(projectQa)return projectQa;
|
|
@@ -662,12 +729,13 @@ export function createCmAiConversationEntry(options) {
|
|
|
662
729
|
const current=boundStatus(runner.status(),identity);
|
|
663
730
|
need(!current.cancellationRequested&&!current.cancelAfterCommit,'cancelled');
|
|
664
731
|
need(current.state==='fixture_completed'&¤t.code==null&¤t.packageDigest===status.packageDigest,'stale_documentation');
|
|
665
|
-
const finalContext=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
732
|
+
const finalContext=inspectCmAiContextRefresh({specsDir:options.specsDir,codeProject:options.codeProject,...(options.featureSelection===undefined?{}:{featureSelection:options.featureSelection}),
|
|
666
733
|
feature:options.feature,applicableAgentFiles});
|
|
667
734
|
need(finalContext.state==='complete'&&finalContext.contextDigest===refresh.contextDigest,'stale_documentation');
|
|
668
|
-
const documentationStatus=validateDocumentationResult(documentation,status,refresh);
|
|
735
|
+
const documentationStatus=validateDocumentationResult(documentation,status,refresh,knowledgeCloseout);
|
|
669
736
|
if(documentationStatus==='blocked')
|
|
670
|
-
return summary(operation,{...status,code:'documentation_sync_blocked'},'blocked')
|
|
737
|
+
return freeze({...summary(operation,{...status,code:'documentation_sync_blocked'},'blocked'),
|
|
738
|
+
...closeoutSummary(knowledgeCloseout,documentation)});
|
|
671
739
|
const finalQa=projectQaSummary(operation,status,options);if(finalQa)return finalQa;
|
|
672
740
|
const input={specsDir:options.specsDir,codeProject:options.codeProject,feature:options.feature,identity,
|
|
673
741
|
packageDigest:operation.packageDigest,contextDigest:refresh.contextDigest,
|
|
@@ -677,7 +745,8 @@ export function createCmAiConversationEntry(options) {
|
|
|
677
745
|
return freeze({version:1,workflow:'cm-ai',operation:operation.operation,requestDigest:digest(operation),identity,
|
|
678
746
|
outcome:'finalized',state:'run_done',code:result.degraded?'run_done_degraded':'run_done',
|
|
679
747
|
packageDigest:operation.packageDigest,pendingAction:'none',contextDigest:refresh.contextDigest,
|
|
680
|
-
deduplicated:result.deduplicated,degraded:result.degraded
|
|
748
|
+
deduplicated:result.deduplicated,degraded:result.degraded,
|
|
749
|
+
...closeoutSummary(knowledgeCloseout,documentation)});
|
|
681
750
|
}
|
|
682
751
|
need(['start','resume'].includes(operation.operation),'invalid_input');
|
|
683
752
|
need(matchesCmAiTaskSelection(admission,options.feature,identity.taskId,options.parallelSelection??null),'task_mismatch');
|
|
@@ -695,7 +764,8 @@ export function createCmAiConversationEntry(options) {
|
|
|
695
764
|
if(options.holdRevision===true&&status.state==='changes_requested')
|
|
696
765
|
return summary(operation,{...status,code:'revision_answer_required'},'awaiting');
|
|
697
766
|
const learningInput=inspectCmAiTaskLearningInput({specsDir:options.specsDir,codeProject:options.codeProject,
|
|
698
|
-
feature:options.feature,identity,applicableAgentFiles:applicableAgentFiles??[]
|
|
767
|
+
feature:options.feature,identity,applicableAgentFiles:applicableAgentFiles??[],
|
|
768
|
+
...(options.featureSelection===undefined?{}:{featureSelection:options.featureSelection})},
|
|
699
769
|
{admission:runner.inspectBootstrapAdmission?.()??null,parallelSelection:options.parallelSelection??null});
|
|
700
770
|
// Keep rejected effects immutable. A run-wide rejection count gives each
|
|
701
771
|
// corrected result a new effect id without changing the provider attempt.
|
|
@@ -709,14 +779,21 @@ export function createCmAiConversationEntry(options) {
|
|
|
709
779
|
return effectSummary(operation,result,runner,identity);
|
|
710
780
|
}
|
|
711
781
|
const handle=async raw=>{
|
|
712
|
-
let token=null;
|
|
782
|
+
let token=null,operation=null;const epoch=cancellationEpoch;
|
|
713
783
|
try{
|
|
714
|
-
|
|
715
|
-
if(!['status','cancel','abandon_review','abandon_effect'].includes(operation.operation)){
|
|
784
|
+
operation=readOperation(raw);
|
|
785
|
+
if(!['status','cancel','reconcile_review','abandon_review','abandon_effect','bootstrap_review_recover'].includes(operation.operation)){
|
|
716
786
|
token=Symbol(operation.operation);inFlightHandles.add(token);
|
|
717
787
|
}
|
|
718
|
-
|
|
719
|
-
|
|
788
|
+
const routed=await route(operation);
|
|
789
|
+
const guidance=operatorGuidance(routed,{executionActive:inFlightHandles.size>(token===null?0:1)});
|
|
790
|
+
const result=guidance?freeze({...routed,guidance}):routed;
|
|
791
|
+
if(!admissionReports.has(routed)&&(epoch===cancellationEpoch||operation.operation==='cancel'))projectHostResult({specsDir:options.specsDir,
|
|
792
|
+
feature:options.feature,result,readCurrent:()=>runner.status()});
|
|
793
|
+
return result;
|
|
794
|
+
}catch(error){return freeze({...rejected(ownerIdentity,error),
|
|
795
|
+
...(['finish','run_finalize'].includes(operation?.operation)
|
|
796
|
+
?closeoutSummary(knowledgeCloseout,null,error.code??'inspection_failed'): {})});}
|
|
720
797
|
finally{if(token!==null)inFlightHandles.delete(token);}
|
|
721
798
|
};
|
|
722
799
|
return Object.freeze({handle});
|