@aibyzero/cm-workflow 0.16.4 → 0.16.5
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 +8 -0
- package/CHANGELOG.md +50 -0
- package/README.md +12 -1
- package/VERSION +1 -1
- package/docs/installation.md +21 -1
- package/docs/js-workflow-control.md +245 -33
- package/docs/runtime-failover.md +1 -1
- package/package.json +1 -1
- package/runtime/js/cm-ai/accepted-fix.mjs +23 -5
- package/runtime/js/cm-ai/bootstrap-feature.mjs +15 -0
- package/runtime/js/cm-ai/claude-review-stream.mjs +12 -0
- package/runtime/js/cm-ai/cm-ai-admission.mjs +115 -41
- package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +3 -2
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +137 -22
- package/runtime/js/cm-ai/cm-ai-learning-handoff-writer.mjs +11 -9
- package/runtime/js/cm-ai/cm-ai-learning-writer.mjs +22 -5
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +180 -53
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +2 -1
- package/runtime/js/cm-ai/codex-review-adapter.mjs +24 -4
- package/runtime/js/cm-ai/developer-adapter.mjs +6 -2
- package/runtime/js/cm-ai/diagnostic-reason.mjs +10 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +305 -0
- package/runtime/js/cm-ai/drive-core.mjs +39 -7
- package/runtime/js/cm-ai/durable-runner-state.mjs +307 -53
- package/runtime/js/cm-ai/effect-abandon-log.mjs +19 -0
- package/runtime/js/cm-ai/effect-contract.mjs +44 -2
- package/runtime/js/cm-ai/execution-store-limits.mjs +18 -0
- package/runtime/js/cm-ai/execution-store.mjs +6 -4
- package/runtime/js/cm-ai/fix-code-association.mjs +171 -18
- package/runtime/js/cm-ai/host-bootstrap.mjs +68 -21
- package/runtime/js/cm-ai/host-conversation-execution.mjs +16 -4
- package/runtime/js/cm-ai/host-handoff.mjs +13 -6
- package/runtime/js/cm-ai/host-qa-executor.mjs +21 -7
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +4 -4
- package/runtime/js/cm-ai/host-qa-policy.mjs +16 -7
- package/runtime/js/cm-ai/host-session.mjs +12 -4
- package/runtime/js/cm-ai/host-tool-bridge.mjs +1 -1
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +13 -4
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/launch-mismatch.mjs +42 -0
- package/runtime/js/cm-ai/log-rows.mjs +21 -0
- package/runtime/js/cm-ai/project-qa-gate.mjs +84 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +53 -9
- package/runtime/js/cm-ai/qa-config-revision.mjs +44 -10
- package/runtime/js/cm-ai/review-abandon-log.mjs +21 -0
- package/runtime/js/cm-ai/review-package.mjs +427 -31
- package/runtime/js/cm-ai/review-runner.mjs +47 -1
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +97 -0
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +104 -10
- package/runtime/js/cm-ai/reviewed-evidence-supersession-record.mjs +42 -3
- package/runtime/js/cm-ai/specification-material.mjs +154 -12
- package/runtime/js/cm-ai/task-commit.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +502 -65
- package/runtime/js/cm-fix/execution.mjs +109 -25
- package/runtime/js/cm-fix/host-review.mjs +7 -3
- package/runtime/js/cm-fix/host.mjs +3 -1
- package/runtime/js/cm-fix/progress.mjs +1 -0
- package/runtime/js/cm-fix/protected-edits.mjs +15 -4
- package/runtime/js/cm-fix/qa-source.mjs +6 -4
- package/runtime/js/cm-prd/analysis.mjs +2 -1
- package/runtime/js/cm-prd/change.mjs +28 -10
- package/runtime/js/cm-prd/draft.mjs +5 -2
- package/runtime/js/cm-prd/review-preparation.mjs +10 -3
- package/runtime/js/cm-prd/review-publication.mjs +4 -2
- package/runtime/js/cm-prd/self-check.mjs +6 -3
- package/runtime/js/cm-prd/summary.mjs +3 -1
- package/runtime/js/cm-prd/validation-reason.mjs +20 -0
- package/runtime/js/spec-task-line.mjs +117 -0
- package/runtime/js/specs-status.mjs +10 -3
- package/scripts/cm-ai-abandon-effect-position.test.mjs +201 -0
- package/scripts/cm-ai-admission.mjs +18 -11
- package/scripts/cm-ai-admission.test.mjs +65 -1
- package/scripts/cm-ai-batch-drive.mjs +92 -20
- package/scripts/cm-ai-batch-drive.test.mjs +164 -3
- package/scripts/cm-ai-batch-host.mjs +27 -11
- package/scripts/cm-ai-batch-host.test.mjs +2 -1
- package/scripts/cm-ai-batch-run.mjs +33 -10
- package/scripts/cm-ai-batch-run.test.mjs +56 -5
- package/scripts/cm-ai-bootstrap-driver-preflight.test.mjs +45 -0
- package/scripts/cm-ai-bootstrap-flow.test.mjs +158 -0
- package/scripts/cm-ai-bootstrap-merge.test.mjs +45 -0
- package/scripts/cm-ai-bootstrap.test.mjs +99 -7
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +82 -2
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +822 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +468 -0
- package/scripts/cm-ai-drive-timeout.test.mjs +17 -0
- package/scripts/cm-ai-drive.mjs +479 -47
- package/scripts/cm-ai-drive.test.mjs +240 -10
- package/scripts/cm-ai-fix-later-delivery.test.mjs +383 -0
- package/scripts/cm-ai-host.mjs +84 -25
- package/scripts/cm-ai-host.test.mjs +232 -12
- package/scripts/cm-ai-launch-diagnostics.test.mjs +142 -0
- package/scripts/cm-ai-multi-root.test.mjs +9 -3
- package/scripts/cm-ai-project-qa-gate.test.mjs +308 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +166 -15
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +157 -0
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +27 -2
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +400 -0
- package/scripts/cm-ai-review-drift-precedence.test.mjs +90 -0
- package/scripts/cm-ai-review-failure.test.mjs +917 -0
- package/scripts/cm-ai-review-timeout-config.test.mjs +29 -7
- package/scripts/cm-ai-review-timeout.test.mjs +199 -4
- package/scripts/cm-ai-run.mjs +160 -60
- package/scripts/cm-ai-run.test.mjs +4 -3
- package/scripts/cm-ai-runner-error-code-regression.test.mjs +219 -0
- package/scripts/cm-ai-selection-guard.test.mjs +100 -0
- package/scripts/cm-ai-session-chain.test.mjs +7 -3
- package/scripts/cm-ai-spec-rebind.test.mjs +481 -0
- package/scripts/cm-ai-supersede.test.mjs +571 -17
- package/scripts/cm-ai-verification-gate.test.mjs +2 -1
- package/scripts/cm-capability-gate.test.mjs +21 -2
- package/scripts/cm-check-drive.test.mjs +1 -1
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +1 -1
- package/scripts/cm-claude-developer-worker.test.mjs +3 -1
- package/scripts/cm-claude-probe.test.mjs +9 -1
- package/scripts/cm-claude-review-stream.test.mjs +25 -0
- package/scripts/cm-claude-worker.test.mjs +11 -4
- package/scripts/cm-codex-developer-worker.test.mjs +4 -2
- package/scripts/cm-failover.mjs +8 -8
- package/scripts/cm-fix-abandon.test.mjs +123 -5
- package/scripts/cm-fix-cause-package.test.mjs +2 -0
- package/scripts/cm-fix-drive.mjs +45 -13
- package/scripts/cm-fix-drive.test.mjs +36 -1
- package/scripts/cm-fix-host.mjs +9 -6
- package/scripts/cm-fix-review-budget.test.mjs +141 -0
- package/scripts/cm-fixture-process-cleanup.test.mjs +95 -0
- package/scripts/cm-host-check.test.mjs +6 -3
- package/scripts/cm-host-qa-executor.test.mjs +192 -17
- package/scripts/cm-host-session-diagnostic.test.mjs +10 -0
- package/scripts/cm-interactive-qa-diagnostic.test.mjs +53 -0
- package/scripts/cm-log-event.mjs +17 -0
- package/scripts/cm-log-event.test.mjs +31 -0
- package/scripts/cm-prd-completion.test.mjs +75 -0
- package/scripts/cm-prd-draft.test.mjs +14 -0
- package/scripts/cm-prd-gate-diagnostic.test.mjs +100 -0
- package/scripts/cm-prd-review-gate.mjs +126 -81
- package/scripts/cm-prd-review-gate.test.mjs +105 -1
- package/scripts/cm-prd-review-preparation.test.mjs +15 -0
- package/scripts/cm-prd-review-publication.test.mjs +6 -0
- package/scripts/cm-prd-self-check.test.mjs +6 -0
- package/scripts/cm-prd-summary.test.mjs +9 -0
- package/scripts/cm-review-dependency-snapshot.test.mjs +15 -0
- package/scripts/cm-review-inventory.test.mjs +253 -1
- package/scripts/cm-spec-manifest.mjs +28 -10
- package/scripts/cm-spec-manifest.test.mjs +8 -4
- package/scripts/cm-spec-task-line.test.mjs +138 -0
- package/scripts/cm-specs-status.test.mjs +12 -1
- package/scripts/cm-task-gate.mjs +18 -10
- package/scripts/cm-task-gate.py +1 -1
- package/scripts/cm-test-branch-impact.test.mjs +6 -3
- package/scripts/fixtures/claude-review-process.mjs +1 -0
- package/scripts/fixtures/process-cleanup.mjs +99 -0
- package/scripts/test-cm-log-event.py +2 -0
- package/scripts/test-cm-prd-review-gate.py +2 -1
- package/scripts/test-npm-install.py +1 -1
- package/scripts/test-scan-public-safety.py +1 -1
- package/scripts/test-spec-manifest.py +16 -8
- package/scripts/test-task-gate.py +2 -2
- package/scripts/test-workflow-config.py +1 -0
- package/scripts/validate-public-repo.py +1 -0
- package/skills/cm-ai/references/N1-init.md +1 -1
- package/skills/cm-ai/references/js-host.md +261 -42
- package/skills/cm-fix/references/js-host.md +22 -1
- package/skills/cm-prd/references/js-change-recovery.md +1 -1
- package/skills/cm-prd/references/js-host.md +6 -0
|
@@ -5,9 +5,27 @@ import {validateHostWorkflowConfiguration} from './host-workflow-capabilities.mj
|
|
|
5
5
|
import {preQaConfigurations,readQaAttachment} from './qa-attachment.mjs';
|
|
6
6
|
|
|
7
7
|
const workflow=material=>material.execution?.workflow?.configuration??material.execution?.workflow;
|
|
8
|
+
const BUILT_IN='cm-host-qa-executor-v1';
|
|
9
|
+
// Store fingerprint form of a QA executor. The built-in executor's plan (the
|
|
10
|
+
// loaded project/user CM config and the mode, case count, cases, commands and
|
|
11
|
+
// stage order derived from it) follows .cm-workflow.yml, ~/.cm-workflow/
|
|
12
|
+
// runtimes.yml and the plugin's built-in defaults, all of which legitimately
|
|
13
|
+
// change during a project. Version 2 binds only the host's QA inputs; each QA
|
|
14
|
+
// round freezes its own plan at N6 (prepare) and records mode/case_count in its
|
|
15
|
+
// test_run rows. Version 1 is the historical form: stores created with it keep
|
|
16
|
+
// opening only while their original configuration is unchanged.
|
|
17
|
+
export function hasLegacyQaPlanFingerprint(executor){return executor?.configuration?.kind===BUILT_IN;}
|
|
18
|
+
export function qaExecutorMaterial(executor,legacy=false){
|
|
19
|
+
if(legacy||!hasLegacyQaPlanFingerprint(executor))return {version:1,mode:executor.mode,caseCount:executor.caseCount,
|
|
20
|
+
timeoutMs:executor.timeoutMs,...(Object.hasOwn(executor,'configuration')?{configuration:executor.configuration}:{})};
|
|
21
|
+
const {plan,...configuration}=executor.configuration;
|
|
22
|
+
return {version:2,timeoutMs:executor.timeoutMs,configuration};
|
|
23
|
+
}
|
|
8
24
|
export function qaConfigurationSlice(material){
|
|
9
25
|
const qa=workflow(material)?.qa,executor=material.qaExecutor,c=executor?.configuration;
|
|
10
|
-
need(qa&&c?.kind===
|
|
26
|
+
need(qa&&c?.kind===BUILT_IN,'qa_revision_configuration_required');
|
|
27
|
+
if(executor.version===2)return json({qa,timeoutMs:executor.timeoutMs,
|
|
28
|
+
executor:{commands:c.commands,environment:c.environment,timeoutMs:c.timeoutMs}});
|
|
11
29
|
return json({qa,mode:executor.mode,caseCount:executor.caseCount,timeoutMs:executor.timeoutMs,
|
|
12
30
|
executor:{commands:c.commands,environment:c.environment,timeoutMs:c.timeoutMs,
|
|
13
31
|
commandsPlan:c.plan.commands,modes:c.plan.modes}});
|
|
@@ -15,12 +33,15 @@ export function qaConfigurationSlice(material){
|
|
|
15
33
|
function withQaConfiguration(material,slice){
|
|
16
34
|
const result=structuredClone(json(material)),c=result.qaExecutor.configuration;
|
|
17
35
|
workflow(result).qa=slice.qa;
|
|
18
|
-
Object.assign(result.qaExecutor,{mode:slice.mode,caseCount:slice.caseCount,timeoutMs:slice.timeoutMs});
|
|
19
36
|
Object.assign(c,{commands:slice.executor.commands,environment:slice.executor.environment,timeoutMs:slice.executor.timeoutMs});
|
|
37
|
+
if(result.qaExecutor.version===2){result.qaExecutor.timeoutMs=slice.timeoutMs;return result;}
|
|
38
|
+
Object.assign(result.qaExecutor,{mode:slice.mode,caseCount:slice.caseCount,timeoutMs:slice.timeoutMs});
|
|
20
39
|
Object.assign(c.plan,{commands:slice.executor.commandsPlan,modes:slice.executor.modes});
|
|
21
40
|
return result;
|
|
22
41
|
}
|
|
23
42
|
export function qaInvariantDigest(material){
|
|
43
|
+
if(material.qaExecutor?.version===2)return digest(withQaConfiguration(material,{qa:null,timeoutMs:null,
|
|
44
|
+
executor:{commands:null,environment:null,timeoutMs:null}}));
|
|
24
45
|
return digest(withQaConfiguration(material,{qa:null,mode:null,caseCount:null,timeoutMs:null,
|
|
25
46
|
executor:{commands:null,environment:null,timeoutMs:null,commandsPlan:null,modes:null}}));
|
|
26
47
|
}
|
|
@@ -30,30 +51,43 @@ export function previousQaMaterial(material,previousWorkflow){
|
|
|
30
51
|
need(prior.qa!==null,'qa_revision_configuration_required');
|
|
31
52
|
need(digest({...prior,qa:null})===digest({...current,qa:null}),'fingerprint_mismatch');
|
|
32
53
|
const result=structuredClone(json(material)),{kind,plan,capabilities,...configuration}=result.qaExecutor.configuration;
|
|
33
|
-
need(kind===
|
|
34
|
-
// Rebuild the old
|
|
35
|
-
//
|
|
54
|
+
need(kind===BUILT_IN,'qa_revision_configuration_required');
|
|
55
|
+
// Rebuild the old executor with the same validator. A version 2 fingerprint
|
|
56
|
+
// carries no plan, so the current CM config cannot make the previous one
|
|
57
|
+
// irreproducible; version 1 still rebuilds its plan from the current policy.
|
|
58
|
+
// These callbacks are capability markers and are never dispatched.
|
|
36
59
|
const executor=createHostQaExecutor({...configuration,commands:prior.qa.commands,environment:prior.qa.environment,
|
|
37
60
|
...(capabilities.logic?{logic:()=>{}}:{}),...(capabilities.browser?{browser:()=>{}}:{})});
|
|
38
|
-
result.qaExecutor=
|
|
61
|
+
result.qaExecutor=qaExecutorMaterial(executor,result.qaExecutor.version!==2);
|
|
39
62
|
workflow(result).qa=prior.qa;
|
|
40
63
|
need(qaInvariantDigest(result)===qaInvariantDigest(material),'fingerprint_mismatch');
|
|
41
64
|
return result;
|
|
42
65
|
}
|
|
66
|
+
// qaRound 0 with testRunId null records a revision made before any QA round
|
|
67
|
+
// ran: nothing is superseded and no round is consumed. packageDigest is the
|
|
68
|
+
// task's current review package, or null before one exists.
|
|
69
|
+
export const beforeFirstQaRound=r=>r.qaRound===0;
|
|
43
70
|
export function readQaConfigRevision(raw){
|
|
44
71
|
const r=json(raw);
|
|
45
72
|
shape(r,['version','fromFingerprint','toFingerprint','invariantDigest','previousQaDigest','qaDigest','reason','hostContextId',
|
|
46
73
|
'revisedAt','packageDigest','testRunId','qaRound','taskAttempt']);
|
|
47
74
|
need(r.version===1,'qa_revision_invalid');
|
|
48
|
-
for(const key of ['fromFingerprint','toFingerprint','invariantDigest','
|
|
75
|
+
for(const key of ['fromFingerprint','toFingerprint','invariantDigest','previousQaDigest','qaDigest'])hex(r[key]);
|
|
76
|
+
if(!(beforeFirstQaRound(r)&&r.packageDigest===null))hex(r.packageDigest);
|
|
49
77
|
need(r.fromFingerprint!==r.toFingerprint&&r.previousQaDigest!==r.qaDigest,'qa_revision_unchanged');
|
|
50
|
-
id(r.hostContextId);
|
|
78
|
+
id(r.hostContextId);
|
|
79
|
+
if(beforeFirstQaRound(r))need(r.testRunId===null,'qa_revision_invalid');else id(r.testRunId);
|
|
80
|
+
text(r.reason);
|
|
51
81
|
need(r.reason.trim().length>0&&r.reason.length<=500&&!/[\r\n\0]/.test(r.reason),'qa_revision_authorization_required');
|
|
52
82
|
need(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ$/.test(r.revisedAt)&&Number.isFinite(Date.parse(r.revisedAt)),'qa_revision_invalid');
|
|
53
83
|
need([1,2].includes(r.taskAttempt),'qa_revision_invalid');
|
|
54
|
-
need(Number.isInteger(r.qaRound)&&r.qaRound>=
|
|
84
|
+
need(Number.isInteger(r.qaRound)&&r.qaRound>=0&&r.qaRound<3,'qa_round_invalid');
|
|
55
85
|
return r;
|
|
56
86
|
}
|
|
87
|
+
// Rounds strictly increase once QA has run; any number of revisions may
|
|
88
|
+
// precede the first round, and none may follow a completed round at round 0.
|
|
89
|
+
export const qaRevisionFollows=(next,previous)=>next.qaRound>previous.qaRound
|
|
90
|
+
||beforeFirstQaRound(next)&&beforeFirstQaRound(previous);
|
|
57
91
|
export function qaRevisionChain(snapshot){
|
|
58
92
|
let fingerprint=snapshot.fingerprints.config,invariant=null,attached=false;const revisions=[];
|
|
59
93
|
for(const row of snapshot.records){
|
|
@@ -65,7 +99,7 @@ export function qaRevisionChain(snapshot){
|
|
|
65
99
|
const r=readQaConfigRevision(row.payload.record);
|
|
66
100
|
need(r.fromFingerprint===fingerprint&&(invariant===null||r.invariantDigest===invariant)
|
|
67
101
|
&&(!revisions.length||(r.previousQaDigest===revisions.at(-1).qaDigest
|
|
68
|
-
&&r
|
|
102
|
+
&&qaRevisionFollows(r,revisions.at(-1)))),'qa_revision_chain_invalid');
|
|
69
103
|
fingerprint=r.toFingerprint;invariant=r.invariantDigest;revisions.push(r);
|
|
70
104
|
}
|
|
71
105
|
return {fingerprint,revisions};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Repeating this projection on resume repairs a crash after the journal append.
|
|
2
|
+
import {spawnSync} from 'node:child_process';
|
|
3
|
+
import {fileURLToPath} from 'node:url';
|
|
4
|
+
import {digest,need} from './effect-contract.mjs';
|
|
5
|
+
|
|
6
|
+
const writer=fileURLToPath(new URL('../../../scripts/cm-log-event.py',import.meta.url));
|
|
7
|
+
export function recordReviewAbandonment({specsDir,codeProject,feature,identity,record,logHome,runtime='codex'}){
|
|
8
|
+
const p=record.payload;
|
|
9
|
+
const data={node:'N4',feature,task:identity.taskId,effect_id:p.effectId,
|
|
10
|
+
invocation_id:p.invocationId,registered_digest:p.registeredDigest,
|
|
11
|
+
started_digest:p.startedDigest,...(Object.hasOwn(p,'resultDigest')?{result_digest:p.resultDigest}:{}),
|
|
12
|
+
record_digest:record.digest,reason:p.reason};
|
|
13
|
+
const args=[writer,'--workflow','cm-ai','--event','review_abandoned','--runtime',runtime,
|
|
14
|
+
'--project-root',codeProject,'--specs-dir',specsDir,'--run-id',identity.runId,
|
|
15
|
+
'--at',p.at,'--detail',Object.hasOwn(p,'resultDigest')?'显式放弃结论未被接收的独立审查调用':'显式放弃无结果的独立审查调用',
|
|
16
|
+
'--data-json',JSON.stringify(data)];
|
|
17
|
+
const result=spawnSync('python3',args,{timeout:10000,maxBuffer:1024*1024,
|
|
18
|
+
...(logHome?{env:{...process.env,CM_WORKFLOW_LOG_HOME:logHome}}:{})});
|
|
19
|
+
need(!result.error&&result.status===0,'review_abandon_log_failed');
|
|
20
|
+
return digest(data);
|
|
21
|
+
}
|