@aibyzero/cm-workflow 0.12.0 → 0.13.2
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 +1 -0
- package/CHANGELOG.md +55 -1
- package/README.md +31 -3
- package/VERSION +1 -1
- package/compat/claude-commands/cm-runtime.md +3 -0
- package/docs/installation.md +43 -1
- package/docs/js-workflow-control.md +63 -6
- package/docs/runtime-failover.md +97 -0
- package/docs/user-guide.md +37 -1
- package/install-codex.sh +5 -0
- package/install.ps1 +10 -2
- package/install.sh +5 -0
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-developer-proposal.schema.json +151 -0
- package/runtime/js/cm-ai/claude-review-stream.mjs +69 -8
- package/runtime/js/cm-ai/claude-tool-preview.mjs +6 -4
- package/runtime/js/cm-ai/cm-ai-admission.mjs +38 -16
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +44 -17
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +105 -12
- package/runtime/js/cm-ai/codex-config.mjs +6 -0
- package/runtime/js/cm-ai/codex-review-adapter.mjs +6 -2
- package/runtime/js/cm-ai/developer-adapter.mjs +41 -16
- package/runtime/js/cm-ai/durable-runner-state.mjs +72 -15
- package/runtime/js/cm-ai/effect-contract.mjs +10 -1
- package/runtime/js/cm-ai/fix-code-association.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +112 -27
- package/runtime/js/cm-ai/host-documentation.mjs +4 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +17 -4
- package/runtime/js/cm-ai/host-qa-policy.mjs +6 -3
- package/runtime/js/cm-ai/host-role-routing.mjs +9 -5
- package/runtime/js/cm-ai/host-tool-bridge.mjs +10 -7
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +9 -4
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/provider-review-observation.mjs +8 -4
- package/runtime/js/cm-ai/qa-attachment.mjs +30 -0
- package/runtime/js/cm-ai/review-package.mjs +76 -18
- package/runtime/js/cm-ai/review-runner.mjs +15 -3
- package/runtime/js/cm-ai/runtime-failover.mjs +75 -0
- package/runtime/js/cm-ai/specification-material.mjs +98 -0
- package/runtime/js/cm-ai/task-runner.mjs +57 -20
- package/runtime/js/cm-ai/worker-claude-developer.mjs +174 -0
- package/runtime/js/cm-ai/worker-claude.mjs +18 -5
- package/runtime/js/cm-ai/worker-codex-developer.mjs +15 -4
- package/runtime/js/cm-ai/worker-codex.mjs +8 -12
- package/runtime/js/cm-init/draft-generation.mjs +24 -4
- package/runtime/js/cm-init/draft-inspection.mjs +29 -1
- package/runtime/js/cm-prd/session.mjs +19 -2
- package/runtime/js/cm-prd/summary.mjs +46 -20
- package/runtime/review.md +11 -1
- package/runtime/workflow-config.md +39 -2
- package/runtime/workflow-routing.md +6 -1
- package/scripts/cm-ai-admission.test.mjs +99 -0
- package/scripts/cm-ai-batch-host.test.mjs +4 -1
- package/scripts/cm-ai-batch-run.test.mjs +7 -1
- package/scripts/cm-ai-bootstrap.test.mjs +2 -1
- package/scripts/cm-ai-fix-integration.test.mjs +2 -1
- package/scripts/cm-ai-host.mjs +81 -12
- package/scripts/cm-ai-host.test.mjs +520 -5
- package/scripts/cm-ai-multi-root.test.mjs +9 -3
- package/scripts/cm-ai-nested-execution.test.mjs +11 -4
- package/scripts/cm-ai-review-timeout.test.mjs +226 -0
- package/scripts/cm-ai-run.mjs +40 -13
- package/scripts/cm-ai-run.test.mjs +45 -9
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +51 -1
- package/scripts/cm-claude-developer-worker.test.mjs +236 -0
- package/scripts/cm-claude-probe.test.mjs +64 -1
- package/scripts/cm-claude-review-stream.test.mjs +236 -1
- package/scripts/cm-claude-worker.test.mjs +110 -1
- package/scripts/cm-codex-developer-adapter.test.mjs +50 -2
- package/scripts/cm-codex-developer-worker.test.mjs +84 -1
- package/scripts/cm-codex-review-progress.test.mjs +34 -6
- package/scripts/cm-failover.mjs +288 -0
- package/scripts/cm-failover.test.mjs +184 -0
- package/scripts/cm-host-qa-executor.test.mjs +277 -0
- package/scripts/cm-host-tool-bridge.test.mjs +31 -0
- package/scripts/cm-init-draft-generation.test.mjs +62 -0
- package/scripts/cm-init-draft-inspection.test.mjs +76 -0
- package/scripts/cm-init-host.mjs +4 -4
- package/scripts/cm-init-host.test.mjs +12 -7
- package/scripts/cm-init-session.test.mjs +50 -0
- package/scripts/cm-log-event.mjs +34 -5
- package/scripts/cm-prd-completion.test.mjs +2 -2
- package/scripts/cm-prd-host.mjs +39 -3
- package/scripts/cm-prd-host.test.mjs +52 -0
- package/scripts/cm-prd-review-gate.mjs +11 -2
- package/scripts/cm-prd-review-gate.test.mjs +62 -0
- package/scripts/cm-prd-session-recovery.test.mjs +167 -0
- package/scripts/cm-prd-summary.test.mjs +147 -0
- package/scripts/cm-review-dependency-snapshot.test.mjs +10 -0
- package/scripts/cm-review-inventory.test.mjs +189 -0
- package/scripts/cm-review-schema.test.mjs +35 -1
- package/scripts/cm-review-scope-recovery.test.mjs +63 -0
- package/scripts/cm-runtime-edit.mjs +104 -0
- package/scripts/cm-runtime-failover.test.mjs +130 -0
- package/scripts/cm-runtime-install.mjs +42 -0
- package/scripts/cm-runtime.mjs +113 -0
- package/scripts/cm-runtime.test.mjs +117 -0
- package/scripts/cm-spec-manifest.mjs +24 -21
- package/scripts/cm-spec-manifest.test.mjs +19 -0
- package/scripts/cm-workflow-config.mjs +113 -5
- package/scripts/cm-workflow-config.test.mjs +124 -1
- package/scripts/fixtures/prd-review-gate-python-oracle.py +18 -2
- package/scripts/test-cm-prd-review-gate.py +30 -0
- package/scripts/test-shell-compat.sh +34 -0
- package/scripts/validate-public-repo.py +5 -0
- package/skills/cm-ai/references/N4-review.md +5 -4
- package/skills/cm-ai/references/js-host.md +36 -2
- package/skills/cm-check/SKILL.md +7 -3
- package/skills/cm-init/SKILL.md +4 -0
- package/skills/cm-init/references/js-host.md +2 -0
- package/skills/cm-init/references/runtime-declaration.md +26 -0
- package/skills/cm-prd/SKILL.md +3 -3
- package/skills/cm-prd/references/js-change-recovery.md +24 -3
- package/skills/cm-prd/references/summary-card.md +7 -0
- package/skills/cm-runtime/SKILL.md +32 -0
- package/templates/auto-update/cm-update.sh +1 -1
- package/templates/cm-workflow.yml +16 -0
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
// Fixed current-conversation factory, separate from CLI top-level execution.
|
|
2
2
|
import fs from 'node:fs';
|
|
3
|
+
import {spawn} from 'node:child_process';
|
|
4
|
+
import {createHash} from 'node:crypto';
|
|
5
|
+
import {loadConfig,resolveProtectedRuntimes} from '../../../scripts/cm-workflow-config.mjs';
|
|
6
|
+
import {claudeDeveloperWorker,validateClaudeProposal} from './worker-claude-developer.mjs';
|
|
7
|
+
import {codexDeveloperWorker} from './worker-codex-developer.mjs';
|
|
3
8
|
import path from 'node:path';
|
|
4
9
|
import {fileURLToPath} from 'node:url';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
10
|
+
import {readCodexDeveloperRequest} from './codex-developer-adapter.mjs';
|
|
11
|
+
import {readClaudeDeveloperRequest} from './claude-developer-adapter.mjs';
|
|
12
|
+
import {createDeveloperRun,validateDeveloperValue} from './developer-adapter.mjs';
|
|
7
13
|
import {createCodexReviewRun} from './codex-review-adapter.mjs';
|
|
8
14
|
import {createClaudeReviewRun} from './claude-review-adapter.mjs';
|
|
9
15
|
import {claudeWorker,claudePreflightMatches} from './worker-claude.mjs';
|
|
@@ -16,14 +22,29 @@ import {createProjectExecution} from './host-project-execution.mjs';
|
|
|
16
22
|
import {codeProjectPaths,codeProjectInstructionPaths,resolveCodeProjects} from './code-projects.mjs';
|
|
17
23
|
import {readProjectInstructionContext} from './cm-ai-context-refresh.mjs';
|
|
18
24
|
import {validateDocumentationPaths} from './host-documentation.mjs';
|
|
25
|
+
import {verifySpecificationMaterial} from './specification-material.mjs';
|
|
19
26
|
import {isFinalCmAiTask} from './cm-ai-admission.mjs';
|
|
20
27
|
import {createHostBootstrap} from './host-bootstrap.mjs';
|
|
21
|
-
import {digest,id,json,need,shape,freeze} from './effect-contract.mjs';
|
|
28
|
+
import {digest,id,hex,json,need,shape,freeze} from './effect-contract.mjs';
|
|
29
|
+
export const protectedTextInstructions='\nProtected current-host mode: do not write files or run commands. Return {status,value,edits} on success; '
|
|
30
|
+
+'value retains the original implementation/Learning contract. edits is [{path,beforeSha256,content}], complete UTF-8 text or null for deletion. '
|
|
31
|
+
+'Only the supplied scope and expected hashes are allowed. The fixed sandbox applies these edits. On failure return {status,code} without edits. '
|
|
32
|
+
+'status must be exactly "succeeded" on success (with value and edits) or "failed" (with code). Return the object through the structured output schema; never wrap it in markdown fences.';
|
|
22
33
|
const protectedConversations=new WeakMap();
|
|
23
34
|
export const conversationProtection=execution=>protectedConversations.get(execution)??null;
|
|
24
35
|
export function createConversationExecution(definition,hostContextId,bridge,review=null,allowedAttempt=null,workflow=null,allowQa=false,runtime='codex',options={}){
|
|
25
36
|
definition=json(definition);workflow=workflow===null?null:json(workflow);options=json(options);
|
|
26
|
-
shape(options,[...['protection','batchWorkflowsDigest','qaLogHome','bootstrap'].filter(key=>Object.hasOwn(options,key))]);
|
|
37
|
+
shape(options,[...['protection','batchWorkflowsDigest','qaLogHome','bootstrap','providerDevelopment'].filter(key=>Object.hasOwn(options,key))]);
|
|
38
|
+
const provider=options.providerDevelopment??null;
|
|
39
|
+
if(provider){
|
|
40
|
+
shape(provider,['model','attempt','coderRuntime','reviewerRuntime']);
|
|
41
|
+
need(options.protection&&review!==null,'protected_configuration_required');
|
|
42
|
+
need([1,2].includes(provider.attempt),'provider_development_authorization_required');
|
|
43
|
+
need(/^[a-zA-Z0-9._-]+$/.test(provider.model),'invalid_model');
|
|
44
|
+
need(digest(resolveProtectedRuntimes(loadConfig({projectRoot:definition.codeProject}),runtime))
|
|
45
|
+
===digest({coderRuntime:provider.coderRuntime,reviewerRuntime:provider.reviewerRuntime}),'runtime_selection_mismatch');
|
|
46
|
+
}
|
|
47
|
+
const coderRuntime=provider?.coderRuntime??runtime,reviewerRuntime=provider?.reviewerRuntime??runtime;
|
|
27
48
|
let bootstrap=null;
|
|
28
49
|
if(options.bootstrap){
|
|
29
50
|
shape(options.bootstrap,['selection','allowWrite']);
|
|
@@ -47,6 +68,7 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
47
68
|
need(protection||!definition.specsDir.startsWith(definition.codeProject+path.sep),'nested_specs_protection_required');
|
|
48
69
|
const configuration={kind:'cm-current-conversation-v1',definitionDigest:digest(definition),hostContextId,
|
|
49
70
|
...(runtime==='claude'?{runtime}:{}),
|
|
71
|
+
...(provider?{providerDevelopment:{model:provider.model,coderRuntime,reviewerRuntime}}:{}),
|
|
50
72
|
...(protection?{protection}:{}),
|
|
51
73
|
...(bootstrap?{bootstrap:bootstrap.configuration}:{}),
|
|
52
74
|
...(options.batchWorkflowsDigest?{batchWorkflowsDigest:options.batchWorkflowsDigest}:{}),
|
|
@@ -54,50 +76,112 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
54
76
|
...(workflow?{workflow}: {})};
|
|
55
77
|
const reviewOptions={cwd:definition.codeProject,model:review?.model??'unconfigured',preflight:review?.preflight??null,
|
|
56
78
|
disabledSkills:review?.disabledSkills??[],
|
|
79
|
+
...(protection?{timeoutMs:protection.timeoutMs}:{}),
|
|
57
80
|
promptTransport:'stdin',schemaPath:fileURLToPath(new URL('./review-result.schema.json',import.meta.url))};
|
|
58
81
|
need(!allowedAttempts.length||review!==null,'review_configuration_required');
|
|
59
|
-
if(allowedAttempts.length)need((
|
|
60
|
-
need(
|
|
82
|
+
if(allowedAttempts.length||provider)need((reviewerRuntime==='codex'?preflightMatches:claudePreflightMatches)(reviewOptions.preflight,reviewOptions),'tool_preflight_missing');
|
|
83
|
+
need(reviewerRuntime!=='claude'||!review||review.disabledSkills.length===0,'invalid_review_config');
|
|
61
84
|
// Preserve P4a's unauthorizable placeholder bytes for existing unconfigured runs.
|
|
62
|
-
const reviewProvider=review?
|
|
85
|
+
const reviewProvider=review?reviewerRuntime:'codex', adapterId=`${reviewProvider}-review-adapter`;
|
|
63
86
|
const authority=review?createHostReviewAuthority({hostContextId,reviewerId:'reviewer',adapterId,
|
|
64
87
|
decide:async binding=>allowedAttempts.includes(binding.identity.attempt)?{status:'approved'}:null}):null;
|
|
65
|
-
|
|
88
|
+
// Reread role declarations at each boundary; never switch a bound invocation.
|
|
89
|
+
const dispatchSpawn=(role,identity,signal)=>{
|
|
90
|
+
const configuration=loadConfig({projectRoot:definition.codeProject});
|
|
91
|
+
need(digest(resolveProtectedRuntimes(configuration,runtime))===digest({coderRuntime,reviewerRuntime}),'runtime_selection_mismatch');
|
|
92
|
+
return (cli,args,options)=>{
|
|
93
|
+
const child=spawn(cli,args,options);
|
|
94
|
+
if(Number.isInteger(child.pid)){
|
|
95
|
+
try{resolveHostRole({definition,identity,role,signal,runtime,configuration,
|
|
96
|
+
dispatchedRuntime:role==='coder'?coderRuntime:reviewerRuntime});}
|
|
97
|
+
catch(error){child.on('error',()=>{});child.stdin?.on('error',()=>{});
|
|
98
|
+
try{options.detached?process.kill(-child.pid,'SIGKILL'):child.kill('SIGKILL');}catch{}throw error;}
|
|
99
|
+
}
|
|
100
|
+
return child;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const used=new Set();
|
|
104
|
+
const execution={configuration,timeoutMs:provider?protection.timeoutMs:1800000,excludedContexts:[hostContextId],hostDecision:null,applicableAgentFiles:[],
|
|
66
105
|
...(bootstrap?{bootstrap}:{}),
|
|
106
|
+
...(provider?{developmentAttempt:provider.attempt}:{}),
|
|
67
107
|
...(workflow?createHostWorkflowCapabilities({definition,configuration:workflow,bridge,allowQa,runtime,protectedExecution:protection!==null,bootstrap}):{}),
|
|
68
108
|
...(options.qaLogHome?{qaLogHome:options.qaLogHome}:{}),
|
|
69
109
|
...(authority?{hostDecisionProvider:authority.hostDecisionProvider}:{}),
|
|
70
|
-
developer:{provider:
|
|
71
|
-
const bound=(
|
|
72
|
-
|
|
110
|
+
developer:{provider:coderRuntime,requestedModel:provider?.model??'current-session',contextId:author,run:async(request,control)=>{
|
|
111
|
+
const bound=(coderRuntime==='codex'?readCodexDeveloperRequest:readClaudeDeveloperRequest)(request);
|
|
112
|
+
if(provider){
|
|
113
|
+
need(bound.identity.attempt===provider.attempt&&digest({...bound.identity,attempt:1})===digest(definition.identity),'permission_denied');
|
|
114
|
+
need(!used.has(bound.invocationId),'duplicate_dispatch');used.add(bound.invocationId);
|
|
115
|
+
}
|
|
116
|
+
const route=provider?null:resolveHostRole({definition,identity:bound.identity,role:'coder',signal:control.signal,runtime});
|
|
117
|
+
const processWorker=provider?(coderRuntime==='codex'?codexDeveloperWorker:claudeDeveloperWorker)({
|
|
118
|
+
cwd:definition.codeProject,model:provider.model,timeoutMs:protection.timeoutMs,
|
|
119
|
+
...(coderRuntime==='codex'?{specsRoot:definition.specsDir}:{}),
|
|
120
|
+
spawnProcess:dispatchSpawn('coder',bound.identity,control.signal)}):null;
|
|
73
121
|
const worker=async({prompt})=>{
|
|
122
|
+
if(provider&&coderRuntime==='codex'){
|
|
123
|
+
if(documentationPaths.length)prompt='Synchronize approved documentation inside this invocation: '+JSON.stringify(documentationPaths)+'\n'+prompt;
|
|
124
|
+
return processWorker({prompt},control);
|
|
125
|
+
}
|
|
74
126
|
const expected=projectExecution?projectExecution.expected(bound.payload.scope):null;
|
|
75
127
|
if(protection){
|
|
76
|
-
prompt+=
|
|
77
|
-
+'value retains the original implementation/Learning contract. edits is [{path,beforeSha256,content}], complete UTF-8 text or null for deletion. '
|
|
78
|
-
+'Only the supplied scope and expected hashes are allowed. The fixed sandbox applies these edits. On failure return {status,code} without edits.';
|
|
128
|
+
prompt+=protectedTextInstructions;
|
|
79
129
|
if(documentationPaths.length&&isFinalCmAiTask({specsDir:definition.specsDir,codeProject:definition.codeProject,
|
|
80
130
|
feature:definition.feature,taskId:bound.identity.taskId}))prompt+=' Include necessary documentation synchronization in the same edits: '+JSON.stringify(documentationPaths);
|
|
81
131
|
}
|
|
82
|
-
const response=json(await bridge.call('develop',{request:bound,prompt,codeProject:definition.codeProject,route,
|
|
132
|
+
const response=provider?await processWorker({prompt:prompt+'\n'+JSON.stringify({editMode:'protected-text-v1',expected})},control):json(await bridge.call('develop',{request:bound,prompt,codeProject:definition.codeProject,route,
|
|
83
133
|
...(definition.codeProjects?{codeProjects:resolveCodeProjects(definition.codeProject,definition.codeProjects),
|
|
84
134
|
projectInstructions:definition.codeProjects.map(root=>({codeProject:root,files:readProjectInstructionContext(root)}))}:{}),
|
|
85
135
|
...(protection?{editMode:'protected-text-v1',expected}: {})},control.signal));
|
|
86
136
|
if(response.status==='succeeded'){
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if(response
|
|
91
|
-
|
|
92
|
-
|
|
137
|
+
const edits=[];
|
|
138
|
+
try{
|
|
139
|
+
shape(response,['status','value',...(protection?['edits']:[]),...(provider?['providerThread']:[])]);
|
|
140
|
+
if(provider){const {providerThread,...proposal}=response;id(providerThread);validateClaudeProposal(proposal);}
|
|
141
|
+
if(protection){
|
|
142
|
+
// Complete local validation precedes every protected write.
|
|
143
|
+
validateDeveloperValue(response.value,bound);
|
|
144
|
+
need(Array.isArray(response.edits),'protected_edit_invalid');
|
|
145
|
+
if(response.value.outcome==='blocked')need(response.edits.length===0,'protected_edit_invalid');
|
|
146
|
+
const seen=new Set();
|
|
147
|
+
for(const edit of response.edits){
|
|
148
|
+
shape(edit,['path','beforeSha256','content']);
|
|
149
|
+
need(bound.payload.scope.includes(edit.path)&&!seen.has(edit.path),'out_of_scope');seen.add(edit.path);
|
|
150
|
+
if(edit.beforeSha256!==null)hex(edit.beforeSha256);
|
|
151
|
+
need(edit.content===null||typeof edit.content==='string','protected_edit_invalid');
|
|
152
|
+
need(edit.content===null||Buffer.byteLength(edit.content)<=1024*1024,'limit_exceeded');
|
|
153
|
+
need(edit.content!==null||edit.beforeSha256!==null,'protected_edit_invalid');
|
|
154
|
+
// Reuse a previous proposal only when its exact output is
|
|
155
|
+
// already present. A stale proposal never overwrites drift.
|
|
156
|
+
if(edit.beforeSha256!==expected[edit.path]){
|
|
157
|
+
const after=edit.content===null?null:createHash('sha256').update(edit.content).digest('hex');
|
|
158
|
+
need(after===expected[edit.path],'protected_edit_stale');
|
|
159
|
+
}else edits.push(edit);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}catch(error){return {status:'failed',code:error.code==='protected_edit_stale'?'protected_edit_stale':'invalid_result',
|
|
163
|
+
reason:error.code??'invalid_input'};}
|
|
164
|
+
if(protection&&response.value.outcome!=='blocked'){
|
|
165
|
+
if(bound.payload.specification)verifySpecificationMaterial({specificationRoot:definition.specsDir,
|
|
166
|
+
specification:bound.payload.specification,identity:bound.identity});
|
|
167
|
+
try{await projectExecution.commit({scope:bound.payload.scope,
|
|
168
|
+
edits,expected,identity:bound.identity,signal:control.signal});}
|
|
169
|
+
catch(error){
|
|
170
|
+
// This code is emitted by the pre-write expected-hash check.
|
|
171
|
+
// Sandbox execution/partial-write failures stay ambiguous.
|
|
172
|
+
if(error.code==='protected_edit_stale')return {status:'failed',code:'protected_edit_stale'};
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
93
175
|
}
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
return {status:response.status,value:response.value,providerThread:hostContextId};
|
|
176
|
+
// CLI session identity comes from the observed process stream; current
|
|
177
|
+
// conversation responses retain the trusted host identity.
|
|
178
|
+
return {status:response.status,value:response.value,providerThread:provider?response.providerThread:hostContextId};
|
|
97
179
|
}
|
|
180
|
+
if(provider){const {providerThread,...failure}=response;shape(failure,['status','code']);return failure;}
|
|
98
181
|
shape(response,['status','code']);return response;
|
|
99
182
|
};
|
|
100
|
-
return (
|
|
183
|
+
return createDeveloperRun({worker,provider:coderRuntime,requestedModel:provider?.model??'current-session',
|
|
184
|
+
protectedCurrentSession:protection!==null&&provider===null})(bound,control);
|
|
101
185
|
}},
|
|
102
186
|
check:check??((request,control)=>{
|
|
103
187
|
const route=resolveHostRole({definition,identity:request.identity,role:'tester',signal:control.signal,runtime});
|
|
@@ -110,8 +194,9 @@ export function createConversationExecution(definition,hostContextId,bridge,revi
|
|
|
110
194
|
allowed:true,available:true,contexts:reviewContexts,
|
|
111
195
|
run:(request,control)=>{
|
|
112
196
|
need(review!==null,'review_configuration_required');
|
|
113
|
-
|
|
114
|
-
|
|
197
|
+
const selectedOptions={...reviewOptions,...(provider?{spawnProcess:dispatchSpawn('reviewer',request.identity,control.signal)}:{})};
|
|
198
|
+
return reviewerRuntime==='codex'?createCodexReviewRun(codexWorker(selectedOptions))(request,control)
|
|
199
|
+
:createClaudeReviewRun(claudeWorker(selectedOptions))(request,control);
|
|
115
200
|
}}],
|
|
116
201
|
reviewInvocation:{developerThreadId:author,excludedThreadIds:[hostContextId],
|
|
117
202
|
authorize:authority?.authorize??(()=>({status:'denied',code:'permission_denied'}))},
|
|
@@ -26,13 +26,15 @@ export function withHostDocumentation({developer,documentationSync,specsDir,code
|
|
|
26
26
|
need(!control.signal.aborted,'cancelled');
|
|
27
27
|
if(!isFinalCmAiTask({specsDir,codeProject,feature,taskId:request.identity.taskId}))return response;
|
|
28
28
|
const baseline=captureReviewBaseline({root:codeProject,specsRoot:specsDir,identity:request.identity,
|
|
29
|
-
scope:paths,requirements:request.payload.requirements.map(file=>file.path)
|
|
29
|
+
scope:paths,requirements:request.payload.requirements.map(file=>file.path),
|
|
30
|
+
...(request.payload.specification?{specification:{specsRoot:specsDir,feature}}:{})});
|
|
30
31
|
const result=json(await run(json({identity:request.identity,invocationId:request.invocationId,
|
|
31
32
|
specsDir,codeProject,feature,paths}),control.signal));
|
|
32
33
|
need(!control.signal.aborted,'cancelled');shape(result,['status']);
|
|
33
34
|
need(result.status==='completed','documentation_sync_blocked');
|
|
34
35
|
const after=captureReviewBaseline({root:codeProject,specsRoot:specsDir,identity:request.identity,
|
|
35
|
-
scope:paths,requirements:request.payload.requirements.map(file=>file.path)
|
|
36
|
+
scope:paths,requirements:request.payload.requirements.map(file=>file.path),
|
|
37
|
+
...(request.payload.specification?{specification:{specsRoot:specsDir,feature}}:{})});
|
|
36
38
|
need(digest(baseline.files.filter(file=>!paths.includes(file.path)))===
|
|
37
39
|
digest(after.files.filter(file=>!paths.includes(file.path))),'out_of_scope');
|
|
38
40
|
return response;
|
|
@@ -141,7 +141,9 @@ export function createHostQaExecutor(options) {
|
|
|
141
141
|
const unchanged=()=>need(digest(readPlan(configuration))===digest(plan),'qa_plan_changed');
|
|
142
142
|
const notCancelled=()=>need(!signal.aborted,'cancelled');notCancelled();unchanged();
|
|
143
143
|
const snapshot=()=>captureReviewBaseline({root:configuration.codeProject,specsRoot:configuration.specsDir,
|
|
144
|
-
identity:binding.identity,scope:configuration.bootstrap?.scope??configuration.requirements,requirements:configuration.requirements,
|
|
144
|
+
identity:binding.identity,scope:configuration.bootstrap?.scope??(configuration.requirements.length?configuration.requirements:['AGENTS.md']),requirements:configuration.requirements,
|
|
145
|
+
...(!configuration.bootstrap&&!configuration.requirements.length
|
|
146
|
+
?{specification:{specsRoot:configuration.specsDir,feature:configuration.feature}}:{}),
|
|
145
147
|
...(configuration.bootstrap?{bootstrapRequirements:configuration.bootstrap.requirements}:{}),
|
|
146
148
|
...(roots?{codeProjectPaths:codeProjectPaths(configuration.codeProject,resolveCodeProjects(configuration.codeProject,roots))}:{})});
|
|
147
149
|
const before=snapshot(),rows=[],commandResults=new Map();
|
|
@@ -182,17 +184,27 @@ export function createHostQaExecutor(options) {
|
|
|
182
184
|
notCancelled();
|
|
183
185
|
const request=freeze({...binding,case:item,route:routed,environment,...(roots?{codeProjects:roots}:{})});
|
|
184
186
|
if(stage==='logic'){
|
|
185
|
-
|
|
187
|
+
let observed,hostRequestTimeout=false;
|
|
188
|
+
try{observed=logic===null?{verdict:'INSUFFICIENT_EVIDENCE',evidence:['Logic host unavailable']}:json(await logic(request,signal));}
|
|
189
|
+
catch(error){
|
|
190
|
+
if(error.code!=='host_request_timeout')throw error;
|
|
191
|
+
hostRequestTimeout=true;observed={verdict:'INSUFFICIENT_EVIDENCE',evidence:['host_request_timeout']};
|
|
192
|
+
}
|
|
186
193
|
notCancelled();shape(observed,['verdict','evidence']);
|
|
187
194
|
need(['SUPPORTED','CONTRADICTED','INSUFFICIENT_EVIDENCE'].includes(observed.verdict),'qa_verdict_invalid');
|
|
188
195
|
rows.push({id:item.id,kind:'logic',origin:item.origin,blocking:item.blocking,
|
|
189
|
-
staticVerdict:observed.verdict,verdict:'BLOCKED',evidence:evidence(observed.evidence)
|
|
196
|
+
staticVerdict:observed.verdict,verdict:'BLOCKED',evidence:evidence(observed.evidence),
|
|
197
|
+
...(hostRequestTimeout?{hostRequestTimeout:true}:{})});
|
|
190
198
|
}else{
|
|
191
199
|
logStep(configuration,binding,'test_run','case_start',{case_id:item.id},'QA browser case started');
|
|
192
200
|
let observed;
|
|
193
201
|
if(browser===null||item.expected.some(value=>value.includes('[需确认]')))
|
|
194
202
|
observed={verdict:'BLOCKED',evidence:[],environment,cleanup:'not_needed'};
|
|
195
|
-
else observed=json(await browser(request,signal));
|
|
203
|
+
else try{observed=json(await browser(request,signal));}
|
|
204
|
+
catch(error){
|
|
205
|
+
if(error.code!=='host_request_timeout')throw error;
|
|
206
|
+
observed={verdict:'BLOCKED',evidence:['host_request_timeout'],environment,cleanup:'failed'};
|
|
207
|
+
}
|
|
196
208
|
notCancelled();shape(observed,['verdict','evidence','environment','cleanup']);
|
|
197
209
|
need(['PASS','FAIL','BLOCKED'].includes(observed.verdict),'qa_verdict_invalid');
|
|
198
210
|
need(['completed','not_needed','failed'].includes(observed.cleanup),'qa_cleanup_required');
|
|
@@ -224,6 +236,7 @@ export function createHostQaExecutor(options) {
|
|
|
224
236
|
row.commandEvidence=mappings.map(item=>item.id);
|
|
225
237
|
const item=plan.cases.find(item=>item.id===row.id);
|
|
226
238
|
if(item.expected.some(value=>value.includes('[需确认]')))row.verdict='BLOCKED';
|
|
239
|
+
if(row.hostRequestTimeout)row.verdict='BLOCKED';
|
|
227
240
|
}
|
|
228
241
|
if(rows.length===0)rows.push({id:'qa-unavailable',kind:'commands',verdict:'BLOCKED',evidence:['No executable QA contract']});
|
|
229
242
|
const drift=digest(before.files)!==digest(snapshot().files);
|
|
@@ -56,14 +56,17 @@ export function createHostQaDecisionProvider({assess,timeoutMs}) {
|
|
|
56
56
|
const context=inspectCmAiQaTaskContext({...binding,taskId:binding.identity.taskId});
|
|
57
57
|
const unassessedTasks=history(binding,context);
|
|
58
58
|
need(!signal.aborted,'cancelled');
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
let assessment,timedOut=false;
|
|
60
|
+
try{assessment=await assess(freeze({...binding,pending:context.pending,mergeEligible:context.mergeEligible,
|
|
61
|
+
unassessedTasks}),signal);}
|
|
62
|
+
catch(error){if(error.code!=='host_request_timeout')throw error;timedOut=true;}
|
|
61
63
|
need(!signal.aborted,'cancelled');
|
|
62
64
|
// Assessment is read-only. A task/log change while it was pending requires
|
|
63
65
|
// another decision; do not bind an answer to different policy inputs.
|
|
64
66
|
const current=inspectCmAiQaTaskContext({...binding,taskId:binding.identity.taskId});
|
|
65
67
|
need(digest(current)===digest(context)&&history(binding,current)===unassessedTasks,'stale_qa');
|
|
66
|
-
const result=
|
|
68
|
+
const result=timedOut?{status:'blocked',score:null,reason:'host_request_timeout'}:
|
|
69
|
+
decideHostQaPolicy({assessment,pending:context.pending,mergeEligible:context.mergeEligible,unassessedTasks});
|
|
67
70
|
return freeze({...result,decisionId:`qa-${digest({identity:binding.identity,packageDigest:binding.packageDigest}).slice(0,48)}`,
|
|
68
71
|
identity:binding.identity,packageDigest:binding.packageDigest,at:new Date().toISOString().replace(/\.\d{3}Z$/,'Z')});
|
|
69
72
|
}});
|
|
@@ -7,9 +7,9 @@ import {json,need,validIdentity} from './effect-contract.mjs';
|
|
|
7
7
|
|
|
8
8
|
const writer=fileURLToPath(new URL('../../../scripts/cm-log-event.py',import.meta.url));
|
|
9
9
|
|
|
10
|
-
export function resolveHostRole({definition,identity,role,signal,runtime='codex'}){
|
|
10
|
+
export function resolveHostRole({definition,identity,role,signal,runtime='codex',configuration=null,dispatchedRuntime=null}){
|
|
11
11
|
need(['codex','claude'].includes(runtime),'invalid_runtime');
|
|
12
|
-
validIdentity(identity);need(['coder','tester'].includes(role),'invalid_role');
|
|
12
|
+
validIdentity(identity);need(['coder','tester','reviewer'].includes(role),'invalid_role');
|
|
13
13
|
need(!signal.aborted,'cancelled');
|
|
14
14
|
const log=(event,data,detail)=>{
|
|
15
15
|
const result=spawnSync('python3',[writer,'--workflow','cm-ai','--event',event,'--phase','route',
|
|
@@ -24,15 +24,19 @@ export function resolveHostRole({definition,identity,role,signal,runtime='codex'
|
|
|
24
24
|
need(receipt.run_id===identity.runId&&receipt.project_log===path.join(definition.specsDir,'运行日志.jsonl'),'role_log_failed');
|
|
25
25
|
};
|
|
26
26
|
let route;
|
|
27
|
-
try{route=resolveRole(loadConfig({projectRoot:definition.codeProject}),role,runtime);}
|
|
27
|
+
try{route=resolveRole(configuration??loadConfig({projectRoot:definition.codeProject}),role,runtime);}
|
|
28
28
|
catch{
|
|
29
29
|
// Do not echo parser errors: they can contain user configuration values.
|
|
30
30
|
log('error',{outcome:'invalid_workflow_config'},'Workflow role configuration invalid; no tool request');
|
|
31
31
|
need(false,'invalid_workflow_config');
|
|
32
32
|
}
|
|
33
|
+
if(dispatchedRuntime!==null){
|
|
34
|
+
need(['codex','claude'].includes(dispatchedRuntime),'invalid_runtime');
|
|
35
|
+
if(route.adapter===`${dispatchedRuntime}-cli`&&runtime!==dispatchedRuntime)route.route_state='cli-dispatch';
|
|
36
|
+
}
|
|
33
37
|
log('decision',{adapter:route.adapter,requested_model:route.model,source:route.source,
|
|
34
|
-
purpose:role==='coder'?'implementation':'task_checks',route_state:route.route_state},`Current conversation role: ${role}`);
|
|
35
|
-
if(!['current-runtime','local-tool'].includes(route.route_state))
|
|
38
|
+
purpose:role==='coder'?'implementation':role==='reviewer'?'independent_review':'task_checks',route_state:route.route_state},`Current conversation role: ${role}`);
|
|
39
|
+
if(!['current-runtime','local-tool','cli-dispatch'].includes(route.route_state))
|
|
36
40
|
log('degrade',{adapter:route.adapter,requested_model:route.model,route_state:route.route_state,
|
|
37
41
|
outcome:'current_conversation_only'},'Requested role adapter not invoked; current conversation tools only');
|
|
38
42
|
// Metadata does not select a model, invoke an adapter, or grant any tool permission.
|
|
@@ -6,8 +6,8 @@ import {digest,json,need,shape} from './effect-contract.mjs';
|
|
|
6
6
|
export function createHostToolBridge({responseLimit=64*1024}={}){
|
|
7
7
|
need(Number.isSafeInteger(responseLimit)&&responseLimit>=64*1024&&responseLimit<=4*1024*1024,'host_response_limit_invalid');
|
|
8
8
|
const sessionId=randomUUID();let send=null,pending=null,closed=false;
|
|
9
|
-
const stop=code=>{
|
|
10
|
-
|
|
9
|
+
const stop=(code,call=pending)=>{
|
|
10
|
+
if(!call||pending!==call)return;pending=null;clearTimeout(call.timer);
|
|
11
11
|
call.signal.removeEventListener('abort',call.abort);
|
|
12
12
|
call.reject(Object.assign(new Error(code),{code}));
|
|
13
13
|
};
|
|
@@ -16,22 +16,25 @@ export function createHostToolBridge({responseLimit=64*1024}={}){
|
|
|
16
16
|
need(send===null&&typeof sender==='function'&&!closed,'host_bridge_unavailable');send=sender;
|
|
17
17
|
Promise.resolve(send({type:'host_ready',sessionId})).catch(()=>{closed=true;stop('host_disconnected');});
|
|
18
18
|
},
|
|
19
|
-
call(kind,payload,signal){
|
|
19
|
+
call(kind,payload,signal,{timeoutMs=null}={}){
|
|
20
20
|
need(send!==null&&!closed,'host_bridge_unavailable');need(pending===null,'host_bridge_busy');
|
|
21
21
|
need(['develop','check','check_runtime','check_semantic','qa_assess','qa_logic','qa_browser','change_impact','test_cases','refactor_analyze','refactor_confirm','refactor_apply','refactor_review','refactor_batch','refactor_prepare_tests','refactor_retrospective','refactor_recover','documentation_sync','documentation_inspect','fix_diagnose','fix_learning','fix_test_author','fix_repair','fix_retrospective','init_analyze','init_generate','init_verify','init_confirm','init_review','init_write','idea_interview','idea_confirm_save','prd_analyze','prd_materials','prd_generate','prd_self_check','prd_review','prd_correct','prd_summary']
|
|
22
22
|
.includes(kind),'host_operation_invalid');need(!signal.aborted,'cancelled');
|
|
23
23
|
const data=json({kind,payload},12*1024*1024);
|
|
24
24
|
const request={type:'host_request',sessionId,callId:randomUUID(),requestDigest:digest(data),...data};
|
|
25
|
+
need(timeoutMs===null||Number.isSafeInteger(timeoutMs)&&timeoutMs>0&&timeoutMs<=3600000,'host_request_timeout_invalid');
|
|
25
26
|
return new Promise((resolve,reject)=>{
|
|
26
27
|
const abort=()=>{
|
|
27
|
-
stop('cancelled');
|
|
28
|
+
stop('cancelled',call);
|
|
28
29
|
Promise.resolve(send({type:'host_call_cancelled',sessionId,callId:request.callId})).catch(()=>{});
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
+
const call={request,signal,abort,resolve,reject,timer:null};pending=call;
|
|
32
|
+
if(timeoutMs!==null)call.timer=setTimeout(()=>stop('host_request_timeout',call),timeoutMs);
|
|
33
|
+
signal.addEventListener('abort',abort,{once:true});
|
|
31
34
|
if(signal.aborted){abort();return;}
|
|
32
35
|
Promise.resolve().then(()=>{
|
|
33
36
|
if(pending?.request===request&&!closed&&!signal.aborted)return send(request);
|
|
34
|
-
}).catch(()=>stop('host_disconnected'));
|
|
37
|
+
}).catch(()=>stop('host_disconnected',call));
|
|
35
38
|
});
|
|
36
39
|
},
|
|
37
40
|
accept(raw){
|
|
@@ -45,7 +48,7 @@ export function createHostToolBridge({responseLimit=64*1024}={}){
|
|
|
45
48
|
need(reply.type==='host_result'&&pending!==null&&!closed,'host_response_mismatch');
|
|
46
49
|
for(const key of ['sessionId','callId','requestDigest'])need(reply[key]===pending.request[key],'host_response_mismatch');
|
|
47
50
|
}catch{return {accepted:false,code:'host_response_mismatch'};}
|
|
48
|
-
const call=pending;pending=null;call.signal.removeEventListener('abort',call.abort);
|
|
51
|
+
const call=pending;pending=null;clearTimeout(call.timer);call.signal.removeEventListener('abort',call.abort);
|
|
49
52
|
call.resolve(reply.result);return {accepted:true,callId:reply.callId};
|
|
50
53
|
},
|
|
51
54
|
close(){closed=true;stop('host_disconnected');},
|
|
@@ -16,7 +16,11 @@ export function validateHostWorkflowConfiguration(raw){
|
|
|
16
16
|
shape(config,['qa','documentationPaths','applicableAgentFiles']);
|
|
17
17
|
for(const key of ['documentationPaths','applicableAgentFiles'])
|
|
18
18
|
need(Array.isArray(config[key])&&config[key].length<=256&&config[key].every(item=>typeof item==='string'),'invalid_workflow_config');
|
|
19
|
-
if(config.qa!==null)
|
|
19
|
+
if(config.qa!==null){
|
|
20
|
+
shape(config.qa,['commands','environment',...(Object.hasOwn(config.qa,'timeoutMs')?['timeoutMs']:[])]);
|
|
21
|
+
if(Object.hasOwn(config.qa,'timeoutMs'))need(Number.isSafeInteger(config.qa.timeoutMs)
|
|
22
|
+
&&config.qa.timeoutMs>0&&config.qa.timeoutMs<=60000,'invalid_workflow_config');
|
|
23
|
+
}
|
|
20
24
|
return config;
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -31,15 +35,16 @@ export function createHostWorkflowCapabilities({definition,configuration,bridge,
|
|
|
31
35
|
if(configuration.qa!==null){
|
|
32
36
|
need(allowQa===true,'qa_authorization_required');
|
|
33
37
|
result.qaLogHome=logHome;
|
|
38
|
+
const requestTimeout={timeoutMs:configuration.qa.timeoutMs??60000};
|
|
34
39
|
result.qaDecisionProvider=createHostQaDecisionProvider({timeoutMs:60000,
|
|
35
|
-
assess:(request,signal)=>bridge.call('qa_assess',request,signal)});
|
|
40
|
+
assess:(request,signal)=>bridge.call('qa_assess',request,signal,requestTimeout)});
|
|
36
41
|
result.qaExecutor=createHostQaExecutor({specsDir,codeProject,feature,requirements,runtime,
|
|
37
42
|
...(definition.codeProjects?{codeProjects:definition.codeProjects}:{}),
|
|
38
43
|
...(bootstrap?{bootstrap:{requirements:bootstrap.configuration.bootstrapRequirements,scope:definition.scope}}:{}),
|
|
39
44
|
...configuration.qa,timeoutMs:1800000,logHome,
|
|
40
45
|
...(protectedExecution?{specsRoot:specsDir}:{}),
|
|
41
|
-
logic:(request,signal)=>bridge.call('qa_logic',request,signal),
|
|
42
|
-
browser:(request,signal)=>bridge.call('qa_browser',request,signal)});
|
|
46
|
+
logic:(request,signal)=>bridge.call('qa_logic',request,signal,requestTimeout),
|
|
47
|
+
browser:(request,signal)=>bridge.call('qa_browser',request,signal,requestTimeout)});
|
|
43
48
|
}
|
|
44
49
|
return result;
|
|
45
50
|
}
|
|
@@ -16,5 +16,5 @@ export function createCmAiHost(options) {
|
|
|
16
16
|
...(qaExecutor===undefined?{}:{qaExecutor}),
|
|
17
17
|
...(documentationProvider===undefined?{}:{documentationProvider}),
|
|
18
18
|
...(qaDecisionProvider===undefined?{}:{qaDecisionProvider})});
|
|
19
|
-
return Object.freeze({handle:entry.handle,inspectFixAssociation:runner.inspectFixAssociation,acceptCompletedFix:runner.acceptCompletedFix});
|
|
19
|
+
return Object.freeze({handle:entry.handle,inspectFixAssociation:runner.inspectFixAssociation,acceptCompletedFix:runner.acceptCompletedFix,attachQa:runner.attachQa});
|
|
20
20
|
}
|
|
@@ -26,7 +26,7 @@ function expectation(v,cause=false) {
|
|
|
26
26
|
}
|
|
27
27
|
function eventStream(events,excluded) {
|
|
28
28
|
need(Array.isArray(events)&&events.length<=64);
|
|
29
|
-
let stage=0,thread=null,terminal=null,close=null;
|
|
29
|
+
let stage=0,thread=null,terminal=null,close=null,hasResult=false;
|
|
30
30
|
for(const e of events) {
|
|
31
31
|
need(close===null);
|
|
32
32
|
if(e?.event==='process_closed') {
|
|
@@ -42,13 +42,16 @@ function eventStream(events,excluded) {
|
|
|
42
42
|
}else {
|
|
43
43
|
shape(e,['event','item_type']);
|
|
44
44
|
if(e.event==='turn.started'){need(stage===1&&e.item_type===null);stage=2;}
|
|
45
|
-
else if(e.event==='item.completed'){need(stage===2&&e.item_type==='agent_message');stage=3;}
|
|
45
|
+
else if(e.event==='item.completed'){need(stage===2&&e.item_type==='agent_message');stage=3;hasResult=true;}
|
|
46
46
|
else if(e.event==='turn.completed'){need(stage===3&&e.item_type===null);terminal=e.event;}
|
|
47
47
|
else {need(['error','turn.failed'].includes(e.event)&&e.item_type===null);terminal=e.event;}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
return {thread,terminal,close};
|
|
50
|
+
return {thread,terminal,close,hasResult};
|
|
51
51
|
}
|
|
52
|
+
// Reuse the validated normalized stream; a final message counts even if its
|
|
53
|
+
// value was truncated or the process never reached turn.completed.
|
|
54
|
+
export const hasProviderReviewResult=events=>eventStream(events,new Set()).hasResult;
|
|
52
55
|
export function inspectProviderReview(observationText,expectationText) {
|
|
53
56
|
need(arguments.length===2);
|
|
54
57
|
return inspect(observationText,expectationText,false);
|
|
@@ -79,7 +82,8 @@ function inspect(observationText,expectationText,cause) {
|
|
|
79
82
|
observationStatus,code,review,completionEligible:false});
|
|
80
83
|
}catch(error){
|
|
81
84
|
const allowed=['limit_exceeded','observation_binding','observation_context','invalid_package',
|
|
82
|
-
'review_package_mismatch','missing_material','contradictory_verdict'
|
|
85
|
+
'review_package_mismatch','missing_material','contradictory_verdict',
|
|
86
|
+
'invalid_finding_path','invalid_finding_id','invalid_finding_severity','invalid_finding_shape'];
|
|
83
87
|
const code=allowed.includes(error?.code)?error.code:'observation_invalid';
|
|
84
88
|
throw Object.assign(new Error(code),{code});
|
|
85
89
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// A one-time extension of a completed run, never a replacement store identity.
|
|
2
|
+
import {json,shape,need,hex,id} from './effect-contract.mjs';
|
|
3
|
+
|
|
4
|
+
export function readQaAttachment(raw){
|
|
5
|
+
const record=json(raw);
|
|
6
|
+
shape(record,['version','qaFingerprint','attachedAt','hostContextId']);
|
|
7
|
+
need(record.version===1,'qa_attachment_invalid');hex(record.qaFingerprint);id(record.hostContextId);
|
|
8
|
+
need(typeof record.attachedAt==='string'&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(record.attachedAt)
|
|
9
|
+
&&Number.isFinite(Date.parse(record.attachedAt)),'qa_attachment_invalid');
|
|
10
|
+
return record;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Reconstruct only supported pre-QA configurations. All unrelated fields remain
|
|
14
|
+
// byte-for-byte digest inputs, including definition, host, protection and review.
|
|
15
|
+
export function preQaConfigurations(material){
|
|
16
|
+
if(!material?.execution)return [];
|
|
17
|
+
const wrapped=Object.hasOwn(material.execution.workflow??{},'configuration');
|
|
18
|
+
const workflow=wrapped?material.execution.workflow.configuration:material.execution.workflow;
|
|
19
|
+
if(!workflow?.qa||!material.qaExecutor||!material.qaDecisionProvider)return [];
|
|
20
|
+
const withoutQa=structuredClone(json(material));
|
|
21
|
+
delete withoutQa.qaExecutor;delete withoutQa.qaDecisionProvider;delete withoutQa.qaTimeoutMs;
|
|
22
|
+
const priorWorkflow=wrapped?withoutQa.execution.workflow.configuration:withoutQa.execution.workflow;
|
|
23
|
+
priorWorkflow.qa=null;
|
|
24
|
+
const withoutWorkflow=structuredClone(withoutQa);
|
|
25
|
+
delete withoutWorkflow.execution.workflow;
|
|
26
|
+
delete withoutWorkflow.documentationProvider;delete withoutWorkflow.documentationSync;
|
|
27
|
+
if(withoutWorkflow.execution.kind==='cm-current-conversation-v1')withoutWorkflow.applicableAgentFiles=[];
|
|
28
|
+
else delete withoutWorkflow.applicableAgentFiles;
|
|
29
|
+
return [withoutQa,withoutWorkflow];
|
|
30
|
+
}
|