@aibyzero/cm-workflow 0.16.4 → 0.16.6
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 +22 -0
- package/CHANGELOG.md +57 -0
- package/README.md +22 -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 +48 -7
- package/docs/js-workflow-control.md +293 -33
- package/docs/live-evidence-drivers.md +62 -0
- package/docs/next-steps.md +15 -10
- package/docs/runtime-failover.md +1 -1
- 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/accepted-fix.mjs +23 -5
- package/runtime/js/cm-ai/bootstrap-feature.mjs +15 -0
- package/runtime/js/cm-ai/claude-review-adapter.mjs +7 -4
- package/runtime/js/cm-ai/claude-review-stream.mjs +12 -0
- package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -4
- 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 +208 -34
- 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 +181 -57
- package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +15 -58
- package/runtime/js/cm-ai/codex-config.mjs +3 -2
- package/runtime/js/cm-ai/codex-review-adapter.mjs +56 -17
- package/runtime/js/cm-ai/committed-rule-basis.mjs +76 -0
- 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 +315 -0
- package/runtime/js/cm-ai/drive-core.mjs +47 -9
- package/runtime/js/cm-ai/durable-runner-state.mjs +413 -56
- 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-policy.mjs +58 -0
- 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/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/fix-code-association.mjs +171 -18
- package/runtime/js/cm-ai/host-bootstrap.mjs +126 -29
- package/runtime/js/cm-ai/host-check.mjs +30 -4
- package/runtime/js/cm-ai/host-conversation-execution.mjs +66 -20
- package/runtime/js/cm-ai/host-handoff.mjs +13 -6
- 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 +23 -9
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +23 -6
- 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 +16 -5
- package/runtime/js/cm-ai/host.mjs +1 -1
- package/runtime/js/cm-ai/knowledge-closeout.mjs +56 -0
- package/runtime/js/cm-ai/launch-mismatch.mjs +42 -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 +21 -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 +86 -0
- package/runtime/js/cm-ai/owned-process-cleanup.mjs +22 -0
- package/runtime/js/cm-ai/project-qa-gate.mjs +84 -0
- package/runtime/js/cm-ai/provider-review-observation.mjs +68 -9
- package/runtime/js/cm-ai/provider-usage.mjs +39 -0
- 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 +438 -31
- 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/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/status-projection.mjs +93 -0
- package/runtime/js/cm-ai/task-commit.mjs +2 -2
- package/runtime/js/cm-ai/task-runner.mjs +658 -75
- 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 +279 -52
- package/runtime/js/cm-fix/final-review.mjs +18 -10
- package/runtime/js/cm-fix/host-review.mjs +32 -9
- package/runtime/js/cm-fix/host.mjs +6 -1
- package/runtime/js/cm-fix/layout.mjs +1 -1
- package/runtime/js/cm-fix/progress.mjs +5 -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-fix/review-reconciliation.mjs +64 -0
- 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/response-recovery.mjs +23 -0
- package/runtime/js/cm-prd/review-preparation.mjs +10 -3
- package/runtime/js/cm-prd/review-publication.mjs +27 -15
- package/runtime/js/cm-prd/review-time.mjs +29 -0
- package/runtime/js/cm-prd/self-check.mjs +6 -3
- package/runtime/js/cm-prd/session.mjs +53 -6
- package/runtime/js/cm-prd/summary.mjs +3 -1
- package/runtime/js/cm-prd/validation-reason.mjs +20 -0
- package/runtime/js/cm-security/finalize.mjs +32 -0
- package/runtime/js/spec-task-line.mjs +117 -0
- package/runtime/js/specs-status.mjs +10 -3
- package/runtime/review.md +5 -0
- package/runtime/task-gates.md +6 -0
- package/runtime/workflow-config.md +10 -1
- 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 +135 -34
- package/scripts/cm-ai-batch-drive.test.mjs +209 -3
- package/scripts/cm-ai-batch-host.mjs +63 -24
- package/scripts/cm-ai-batch-host.test.mjs +2 -1
- package/scripts/cm-ai-batch-run.mjs +101 -34
- 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 +159 -0
- package/scripts/cm-ai-bootstrap-merge.test.mjs +162 -0
- package/scripts/cm-ai-bootstrap.test.mjs +174 -89
- package/scripts/cm-ai-conversation-entry-ops.test.mjs +97 -2
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +924 -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 +526 -60
- package/scripts/cm-ai-drive.test.mjs +336 -10
- package/scripts/cm-ai-fix-later-delivery.test.mjs +383 -0
- package/scripts/cm-ai-host.mjs +142 -43
- 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-operator-guidance.test.mjs +94 -0
- package/scripts/cm-ai-progress.test.mjs +521 -0
- package/scripts/cm-ai-project-qa-gate.test.mjs +308 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +187 -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 +977 -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 +206 -62
- package/scripts/cm-ai-run.test.mjs +6 -4
- 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-bootstrap-review-recovery.test.mjs +70 -0
- package/scripts/cm-capability-gate.test.mjs +21 -2
- package/scripts/cm-check-drive.test.mjs +2 -1
- package/scripts/cm-check-host.test.mjs +1 -1
- package/scripts/cm-check-runtime.sh +12 -1
- package/scripts/cm-claude-developer-worker.test.mjs +3 -1
- package/scripts/cm-claude-install-layout.test.mjs +26 -0
- package/scripts/cm-claude-probe.test.mjs +10 -2
- 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-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-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 +70 -23
- package/scripts/cm-fix-drive.test.mjs +36 -1
- package/scripts/cm-fix-final-review.test.mjs +11 -6
- package/scripts/cm-fix-host.mjs +24 -14
- 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 +147 -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 +213 -17
- package/scripts/cm-host-session-diagnostic.test.mjs +10 -0
- package/scripts/cm-interactive-qa-diagnostic.test.mjs +53 -0
- package/scripts/cm-knowledge-closeout.test.mjs +160 -0
- package/scripts/cm-live-evidence.test.mjs +64 -0
- package/scripts/cm-log-event.mjs +25 -2
- package/scripts/cm-log-event.py +15 -0
- package/scripts/cm-log-event.test.mjs +31 -0
- package/scripts/cm-model-setup.mjs +79 -0
- package/scripts/cm-prd-completion.test.mjs +75 -0
- package/scripts/cm-prd-draft.test.mjs +14 -0
- package/scripts/cm-prd-drive.mjs +32 -11
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-gate-diagnostic.test.mjs +100 -0
- package/scripts/cm-prd-host.mjs +13 -4
- 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-release-smoke.sh +5 -1
- package/scripts/cm-review-dependency-snapshot.test.mjs +15 -0
- package/scripts/cm-review-inventory.test.mjs +253 -1
- 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-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-correction.test.mjs +117 -0
- package/scripts/cm-task-gate.mjs +164 -20
- package/scripts/cm-task-gate.py +2 -1
- package/scripts/cm-test-branch-impact.test.mjs +6 -3
- 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/claude-review-process.mjs +1 -0
- package/scripts/fixtures/live-evidence-driver.mjs +35 -0
- package/scripts/fixtures/process-cleanup.mjs +101 -0
- package/scripts/test-cm-log-event.py +2 -0
- package/scripts/test-cm-native-usage.py +62 -0
- package/scripts/test-cm-prd-review-gate.py +2 -1
- package/scripts/test-external-model-setup.py +91 -0
- package/scripts/test-model-configuration-write.py +201 -0
- package/scripts/test-npm-install.py +11 -2
- 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/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 +270 -43
- 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 +52 -3
- package/skills/cm-prd/references/js-change-recovery.md +1 -1
- package/skills/cm-prd/references/js-host.md +6 -0
- 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
|
@@ -6,7 +6,10 @@ import path from 'node:path';
|
|
|
6
6
|
import {spawnSync} from 'node:child_process';
|
|
7
7
|
import {fileURLToPath} from 'node:url';
|
|
8
8
|
import {buildManifest} from './cm-spec-manifest.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import {configFingerprint} from '../runtime/js/cm-ai/codex-config.mjs';
|
|
10
|
+
import {digest} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
11
|
+
import {cmInitRuleTargets} from '../runtime/js/cm-init/draft-generation.mjs';
|
|
12
|
+
import {qaFixAnswerFor,projectDevelopAttempts,bootstrapReviewRecoveryPlanError,buildCmAiDriveRequest} from './cm-ai-drive.mjs';
|
|
10
13
|
|
|
11
14
|
const DRIVER=fileURLToPath(new URL('./cm-ai-drive.mjs',import.meta.url));
|
|
12
15
|
const identity={repositoryId:'drive-fixture',runId:'drive-run',taskId:'T-001',attempt:1};
|
|
@@ -17,7 +20,7 @@ test('help prints the plan command without launching a host',()=>{
|
|
|
17
20
|
function fixture(t){
|
|
18
21
|
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-ai-drive-')));
|
|
19
22
|
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
20
|
-
const specsDir=path.join(root,'
|
|
23
|
+
const specsDir=path.join(root,'specs5'),codeProject=path.join(root,'app'),feature='1.work';
|
|
21
24
|
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
|
|
22
25
|
for(const name of ['requirements.md','design.md'])fs.writeFileSync(path.join(specsDir,feature,name),'# Fixture\n');
|
|
23
26
|
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: fixture\n');
|
|
@@ -26,22 +29,155 @@ function fixture(t){
|
|
|
26
29
|
fs.writeFileSync(path.join(root,'run.json'),JSON.stringify({version:1,specsDir,codeProject,feature,identity,
|
|
27
30
|
scope:['target.mjs'],requirements:['requirements.md']}));
|
|
28
31
|
const answers=path.join(root,'answers');fs.mkdirSync(answers);
|
|
32
|
+
const bin=path.join(root,'bin');fs.mkdirSync(bin);
|
|
29
33
|
const write=(name,value)=>fs.writeFileSync(path.join(answers,name),JSON.stringify(value));
|
|
34
|
+
// create requires a bound review configuration; this one grants no review attempt.
|
|
35
|
+
fs.writeFileSync(path.join(root,'placeholder-review.json'),JSON.stringify({model:'fixture',preflight:{}}));
|
|
30
36
|
const plan=(extra={})=>{const file=path.join(root,`plan-${Math.random().toString(36).slice(2)}.json`);
|
|
31
|
-
|
|
32
|
-
permissions:[],answers:'answers',checks:[{id:'syntax',command:[process.execPath,'--check','target.mjs']}],...extra}
|
|
37
|
+
const value={config:'run.json',mode:'create',hostContext:'drive-host-a',
|
|
38
|
+
permissions:[],answers:'answers',checks:[{id:'syntax',command:[process.execPath,'--check','target.mjs']}],...extra};
|
|
39
|
+
if(!value.permissions.includes('--review-config'))value.permissions=[...value.permissions,'--review-config','placeholder-review.json'];
|
|
40
|
+
fs.writeFileSync(file,JSON.stringify(value));
|
|
33
41
|
return file;};
|
|
34
|
-
const drive=(file,operation)=>spawnSync(process.execPath,[DRIVER,'--plan',file,operation],
|
|
35
|
-
{encoding:'utf8',timeout
|
|
42
|
+
const drive=(file,operation,timeout=30000)=>spawnSync(process.execPath,[DRIVER,'--plan',file,operation],
|
|
43
|
+
{encoding:'utf8',timeout,env:{...process.env,PATH:bin+path.delimiter+process.env.PATH,CM_WORKFLOW_HOME:path.join(root,'home'),
|
|
36
44
|
CM_WORKFLOW_LOG_HOME:path.join(root,'logs')}});
|
|
37
45
|
const store=path.join(specsDir,'.reviews','.execution',identity.runId,'state.json');
|
|
38
|
-
return {root,codeProject,specsDir,answers,write,plan,drive,store};
|
|
46
|
+
return {root,codeProject,specsDir,answers,bin,write,plan,drive,store};
|
|
39
47
|
}
|
|
40
48
|
const develop={status:'succeeded',value:{outcome:'implemented',
|
|
41
49
|
application:{status:'no_relevant_lesson',note:null},
|
|
42
50
|
retrospective:{status:'no_new_lesson',candidates:[],reason:null}},
|
|
43
51
|
edits:{'target.mjs':'target-content.mjs'}};
|
|
44
52
|
function prepared(f){f.write('develop.json',develop);fs.writeFileSync(path.join(f.answers,'target-content.mjs'),'export const value = 42;\n');}
|
|
53
|
+
function changesRequestedReview(f){
|
|
54
|
+
const source=fs.readFileSync(fileURLToPath(new URL('./fixtures/codex-review-process.mjs',import.meta.url)),'utf8');
|
|
55
|
+
const fake=source.replace("verdict:'approved'","verdict:'changes_requested'")
|
|
56
|
+
.replace('findings:[]',"findings:[{id:'F1',severity:'P2',path:'target.mjs',message:'Revise the value',evidence:'Fixture finding'}]");
|
|
57
|
+
const cli=path.join(f.bin,'codex');fs.writeFileSync(cli,fake,{mode:0o700});
|
|
58
|
+
fs.writeFileSync(path.join(f.root,'review.json'),JSON.stringify({model:'fixture',preflight:{passed:true,
|
|
59
|
+
cli_model:'fixture',prompt_transport:'stdin',config_fingerprint:configFingerprint({cwd:f.codeProject,model:'fixture'})}}));
|
|
60
|
+
return ['--review-config','review.json','--allow-review-attempt','1'];
|
|
61
|
+
}
|
|
62
|
+
function reviewPending(f){
|
|
63
|
+
prepared(f);const permissions=changesRequestedReview(f);
|
|
64
|
+
const first=f.drive(f.plan({permissions:permissions.slice(0,2)}),'advance');assert.equal(first.status,0,first.stderr);
|
|
65
|
+
return {permissions,packageDigest:JSON.parse(first.stdout).result.packageDigest};
|
|
66
|
+
}
|
|
67
|
+
function assertActionableFirstReviewHint(stderr){
|
|
68
|
+
assert.match(stderr,/develop-a2\.json/);
|
|
69
|
+
assert.match(stderr,/审查后可能直接进入第 2 轮 develop/);
|
|
70
|
+
assert.match(stderr,/移除 --allow-review-attempt 1/);
|
|
71
|
+
assert.match(stderr,/awaiting_review/);
|
|
72
|
+
assert.match(stderr,/packageDigest.*decision/);
|
|
73
|
+
assert.match(stderr,/\.reviews\/work-T-001-r1\.md/);
|
|
74
|
+
assert.match(stderr,/预先写.*develop-a2\.json/);
|
|
75
|
+
assert.match(stderr,/逐字节相同时.*develop_unchanged_after_review/);
|
|
76
|
+
}
|
|
77
|
+
test('review-enabled advance refuses missing second-round answer before host launch',t=>{
|
|
78
|
+
const f=fixture(t),{permissions,packageDigest}=reviewPending(f),before=fs.readFileSync(f.store);
|
|
79
|
+
const run=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',permissions}),'advance');
|
|
80
|
+
assert.equal(run.status,2,run.stderr);assert.match(run.stderr,/develop-a2\.json/);
|
|
81
|
+
assert.match(run.stderr,/decision/);assert.match(run.stderr,new RegExp(packageDigest));
|
|
82
|
+
assert.match(run.stderr,/\.reviews\/work-T-001-r1\.md/);
|
|
83
|
+
assert.deepEqual(fs.readFileSync(f.store),before);
|
|
84
|
+
});
|
|
85
|
+
test('retryable blocked state projects the same develop attempt',()=>{
|
|
86
|
+
for(const code of ['developer_result_invalid','verification_precheck_failed','check_output_out_of_scope','develop_checks_not_passed'])
|
|
87
|
+
assert.deepEqual(projectDevelopAttempts({state:'blocked',code,attempt:2},'advance',[]).attempts,[2]);
|
|
88
|
+
assert.deepEqual(projectDevelopAttempts({state:'blocked',code:'checks_not_passed',attempt:2},'advance',[]).attempts,[]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('D1 real host retries a check-output-blocked develop with a fresh effect id',t=>{
|
|
92
|
+
const f=fixture(t);prepared(f);
|
|
93
|
+
const definition=JSON.parse(fs.readFileSync(path.join(f.root,'run.json'),'utf8'));
|
|
94
|
+
definition.scope=['App/ContentView.swift'];fs.writeFileSync(path.join(f.root,'run.json'),JSON.stringify(definition));
|
|
95
|
+
fs.writeFileSync(path.join(f.answers,'ContentView.swift'),'import SwiftUI\nstruct ContentView: View { var body: some View { Text("Ready") } }\n');
|
|
96
|
+
f.write('develop.json',{...develop,edits:{'App/ContentView.swift':'ContentView.swift'}});
|
|
97
|
+
const dirty=[{id:'build',command:[process.execPath,'-e',"require('node:fs').mkdirSync('build',{recursive:true});require('node:fs').writeFileSync('build/out.o','x')"]}];
|
|
98
|
+
const first=f.drive(f.plan({runtime:'claude',checks:dirty}),'advance');assert.equal(first.status,0,first.stderr);
|
|
99
|
+
assert.equal(JSON.parse(first.stdout).result.code,'check_output_out_of_scope');
|
|
100
|
+
fs.rmSync(path.join(f.codeProject,'build'),{recursive:true});
|
|
101
|
+
const clean=[{id:'build',command:[process.execPath,'-e','0']}];
|
|
102
|
+
const second=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',runtime:'claude',checks:clean}),'advance');
|
|
103
|
+
assert.equal(second.status,0,second.stderr);
|
|
104
|
+
assert.equal(JSON.parse(second.stdout).result.state,'awaiting_review');
|
|
105
|
+
assert.match(second.stderr,/应答 develop/);
|
|
106
|
+
const intents=JSON.parse(fs.readFileSync(f.store)).records.filter(r=>r.payload.type==='effect-intent').map(r=>r.payload.effect.id);
|
|
107
|
+
assert.deepEqual(intents,['develop-1','develop-1-retry-1']);
|
|
108
|
+
assert.match(fs.readFileSync(path.join(f.codeProject,'App','ContentView.swift'),'utf8'),/import SwiftUI/);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('D1 per-check timeout lets a 61 second check finish under a 65 second limit',t=>{
|
|
112
|
+
const f=fixture(t);prepared(f);
|
|
113
|
+
const checks=[{id:'slow',command:[process.execPath,'-e','setTimeout(()=>{},61000)'],timeoutMs:65000}];
|
|
114
|
+
const run=f.drive(f.plan({checkTimeoutMs:1000,checks}),'advance',80000);
|
|
115
|
+
assert.equal(run.status,0,run.stderr);
|
|
116
|
+
assert.equal(JSON.parse(run.stdout).result.state,'awaiting_review');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
for(const plan of [{checkTimeoutMs:0},{checks:[{id:'syntax',command:[process.execPath,'--check','target.mjs'],timeoutMs:3600001}]}])
|
|
120
|
+
test(`D1 single driver rejects invalid timeout before host launch ${Object.keys(plan)[0]}`,t=>{
|
|
121
|
+
const f=fixture(t);prepared(f);
|
|
122
|
+
const run=f.drive(f.plan(plan),'advance');
|
|
123
|
+
assert.equal(run.status,2);assert.match(run.stderr,/[tT]imeoutMs/);assert.equal(fs.existsSync(f.store),false);
|
|
124
|
+
});
|
|
125
|
+
test('review-authorized create preflights a possible second develop round',t=>{
|
|
126
|
+
const f=fixture(t);prepared(f);const permissions=changesRequestedReview(f);
|
|
127
|
+
const run=f.drive(f.plan({permissions}),'advance');
|
|
128
|
+
assert.equal(run.status,2,run.stderr);assertActionableFirstReviewHint(run.stderr);
|
|
129
|
+
assert.equal(fs.existsSync(f.store),false);
|
|
130
|
+
});
|
|
131
|
+
test('review-authorized resume from ready gives the same two paths before launch',t=>{
|
|
132
|
+
const f=fixture(t);prepared(f);const permissions=changesRequestedReview(f);
|
|
133
|
+
const status=f.drive(f.plan({permissions:permissions.slice(0,2),answers:undefined,checks:undefined}),'status');
|
|
134
|
+
assert.equal(status.status,0,status.stderr);assert.equal(JSON.parse(status.stdout).result.state,'ready');
|
|
135
|
+
const before=fs.readFileSync(f.store);
|
|
136
|
+
const run=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',permissions}),'advance');
|
|
137
|
+
assert.equal(run.status,2,run.stderr);assertActionableFirstReviewHint(run.stderr);
|
|
138
|
+
assert.deepEqual(fs.readFileSync(f.store),before);
|
|
139
|
+
});
|
|
140
|
+
test('create advance without review authorization accepts only develop.json',t=>{
|
|
141
|
+
const f=fixture(t);prepared(f);const permissions=changesRequestedReview(f).slice(0,2);
|
|
142
|
+
assert.equal(fs.existsSync(path.join(f.answers,'develop-a2.json')),false);
|
|
143
|
+
const run=f.drive(f.plan({permissions}),'advance');assert.equal(run.status,0,run.stderr);
|
|
144
|
+
assert.equal(JSON.parse(run.stdout).result.state,'awaiting_review');
|
|
145
|
+
});
|
|
146
|
+
test('decision dispatches only review and leaves changes_requested for authored revision',t=>{
|
|
147
|
+
const f=fixture(t),{permissions,packageDigest}=reviewPending(f);
|
|
148
|
+
const run=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',permissions,
|
|
149
|
+
packageDigest,answers:undefined,checks:undefined}),'decision');
|
|
150
|
+
assert.equal(run.status,0,run.stderr);
|
|
151
|
+
assert.equal(JSON.parse(run.stdout).result.state,'changes_requested');
|
|
152
|
+
assert.equal(JSON.parse(run.stdout).result.identity.attempt,2);
|
|
153
|
+
assert.equal(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),'export const value = 42;\n');
|
|
154
|
+
});
|
|
155
|
+
test('advance applies develop-a2 content after changes_requested review',t=>{
|
|
156
|
+
const f=fixture(t),{permissions}=reviewPending(f);
|
|
157
|
+
fs.writeFileSync(path.join(f.answers,'target-a2.mjs'),'export const value = 43;\n');
|
|
158
|
+
f.write('develop-a2.json',{...develop,edits:{'target.mjs':'target-a2.mjs'}});
|
|
159
|
+
const run=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',permissions}),'advance');
|
|
160
|
+
assert.equal(run.status,0,run.stderr);
|
|
161
|
+
assert.equal(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),'export const value = 43;\n');
|
|
162
|
+
assert.equal(JSON.parse(run.stdout).result.identity.attempt,2);
|
|
163
|
+
});
|
|
164
|
+
test('both first-round develop filenames are refused before launch',t=>{
|
|
165
|
+
const f=fixture(t);prepared(f);f.write('develop-a1.json',develop);
|
|
166
|
+
const run=f.drive(f.plan(),'advance');assert.equal(run.status,2,run.stderr);
|
|
167
|
+
assert.match(run.stderr,/develop\.json.*develop-a1\.json/);assert.equal(fs.existsSync(f.store),false);
|
|
168
|
+
});
|
|
169
|
+
test('develop-a1 alone is accepted for a new run',t=>{
|
|
170
|
+
const f=fixture(t);prepared(f);fs.renameSync(path.join(f.answers,'develop.json'),path.join(f.answers,'develop-a1.json'));
|
|
171
|
+
const run=f.drive(f.plan(),'advance');assert.equal(run.status,0,run.stderr);
|
|
172
|
+
assert.equal(fs.readFileSync(path.join(f.codeProject,'target.mjs'),'utf8'),'export const value = 42;\n');
|
|
173
|
+
});
|
|
174
|
+
test('malformed develop-a2 is rejected before review launch',t=>{
|
|
175
|
+
const f=fixture(t),{permissions}=reviewPending(f),before=fs.readFileSync(f.store);
|
|
176
|
+
f.write('develop-a2.json',{status:'succeeded',value:{outcome:'implemented'},edits:{}});
|
|
177
|
+
const run=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',permissions}),'advance');
|
|
178
|
+
assert.equal(run.status,2,run.stderr);assert.match(run.stderr,/答案格式错误/);
|
|
179
|
+
assert.deepEqual(fs.readFileSync(f.store),before);
|
|
180
|
+
});
|
|
45
181
|
function qaFixture(f,kinds,caseIds=[]){
|
|
46
182
|
const featureRoot=path.join(f.specsDir,'1.work');
|
|
47
183
|
fs.writeFileSync(path.join(featureRoot,'requirements.md'),'- [AC-001]: fixture\n');
|
|
@@ -61,6 +197,69 @@ function qaFixture(f,kinds,caseIds=[]){
|
|
|
61
197
|
...(kinds.some(item=>item.kind==='browser')?['--browser-qa','available']:[])]});
|
|
62
198
|
}
|
|
63
199
|
|
|
200
|
+
for(const mode of ['report','legacy-answer','off'])
|
|
201
|
+
test(`closeout real driver completes the original workflow with ${mode}`,t=>{
|
|
202
|
+
const f=fixture(t);prepared(f);f.write('develop-a2.json',develop);
|
|
203
|
+
const plan=JSON.parse(fs.readFileSync(qaFixture(f,[]),'utf8'));
|
|
204
|
+
fs.unlinkSync(path.join(f.specsDir,'1.work','test-cases.json'));
|
|
205
|
+
fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.work'],specFiles:buildManifest(f.specsDir)}));
|
|
206
|
+
const permissions=changesRequestedReview(f);
|
|
207
|
+
fs.copyFileSync(fileURLToPath(new URL('./fixtures/codex-review-process.mjs',import.meta.url)),path.join(f.bin,'codex'));
|
|
208
|
+
fs.chmodSync(path.join(f.bin,'codex'),0o700);
|
|
209
|
+
if(mode==='off'){
|
|
210
|
+
const p=path.join(f.root,'workflow.json'),workflow=JSON.parse(fs.readFileSync(p));
|
|
211
|
+
workflow.knowledgeCloseout=false;fs.writeFileSync(p,JSON.stringify(workflow));
|
|
212
|
+
}
|
|
213
|
+
const closeout={version:1,items:['code','runtime','documentation','rules','memory','residue'].map(area=>({area,
|
|
214
|
+
status:area==='memory'?'out_of_scope':'unverified',evidence:[],detail:'Controlled fixture; no semantic or account claim'}))};
|
|
215
|
+
f.write('documentation-inspect.json',{status:'completed',reason:'Controlled required-document fixture',
|
|
216
|
+
...(mode==='report'?{closeout}:{})});
|
|
217
|
+
plan.permissions=['--workflow-config','workflow.json','--allow-qa',...permissions];
|
|
218
|
+
let result;
|
|
219
|
+
for(let n=0;n<4;n++){
|
|
220
|
+
const out=f.drive(f.plan({...plan,...(n?{mode:'resume',originalHostContext:'drive-host-a'}:{})}),'advance');
|
|
221
|
+
assert.equal(out.status,0,out.stderr);result=JSON.parse(out.stdout).result;
|
|
222
|
+
if(result.state==='run_done')break;
|
|
223
|
+
}
|
|
224
|
+
assert.equal(result.state,'run_done',JSON.stringify(result));
|
|
225
|
+
assert.equal(result.knowledgeCloseout.status,mode==='report'?'reported':mode==='off'?'disabled':'not_completed');
|
|
226
|
+
if(mode==='report')assert.deepEqual(result.knowledgeCloseout.items,closeout.items);
|
|
227
|
+
const state=JSON.parse(fs.readFileSync(f.store)),before=fs.readFileSync(path.join(f.codeProject,'target.mjs'));
|
|
228
|
+
assert.deepEqual(state.records[0].payload.config.knowledgeCloseout,{version:1,enabled:mode!=='off'});
|
|
229
|
+
assert.match(fs.readFileSync(path.join(f.specsDir,'1.work','tasks.md'),'utf8'),/- \[x\] T-001/);
|
|
230
|
+
const again=f.drive(f.plan({...plan,mode:'resume',originalHostContext:'drive-host-a'}),'advance');
|
|
231
|
+
assert.equal(again.status,0,again.stderr);assert.equal(JSON.parse(again.stdout).result.deduplicated,true);
|
|
232
|
+
const after=JSON.parse(fs.readFileSync(f.store));
|
|
233
|
+
assert.equal(after.records.filter(row=>row.payload.type==='review-invocation-started').length,1);
|
|
234
|
+
assert.deepEqual(after.records,state.records);assert.deepEqual(fs.readFileSync(path.join(f.codeProject,'target.mjs')),before);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test('progress R1: single driver forwards quiet QA command boundaries',t=>{
|
|
238
|
+
const f=fixture(t);prepared(f);f.write('develop-a2.json',develop);
|
|
239
|
+
const plan=JSON.parse(fs.readFileSync(qaFixture(f,[]),'utf8'));
|
|
240
|
+
fs.unlinkSync(path.join(f.specsDir,'1.work','test-cases.json'));
|
|
241
|
+
fs.writeFileSync(path.join(f.specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:['1.work'],
|
|
242
|
+
specFiles:buildManifest(f.specsDir)}));
|
|
243
|
+
const permissions=changesRequestedReview(f);
|
|
244
|
+
fs.copyFileSync(fileURLToPath(new URL('./fixtures/codex-review-process.mjs',import.meta.url)),path.join(f.bin,'codex'));
|
|
245
|
+
fs.chmodSync(path.join(f.bin,'codex'),0o700);
|
|
246
|
+
f.write('qa-assess.json',{scores:{scope:2,risk:2,accumulation:2,boundary:2},
|
|
247
|
+
changes:{api:false,migration:false,authentication:false,authorization:false,payment:false}});
|
|
248
|
+
const workflowPath=path.join(f.root,'workflow.json'),workflow=JSON.parse(fs.readFileSync(workflowPath,'utf8'));
|
|
249
|
+
workflow.qa.commands=[{id:'quiet-qa',command:[process.execPath,'-e','setTimeout(()=>process.exit(0),400)'],caseIds:[]}];
|
|
250
|
+
fs.writeFileSync(workflowPath,JSON.stringify(workflow));
|
|
251
|
+
plan.permissions=['--workflow-config','workflow.json','--allow-qa',...permissions];
|
|
252
|
+
let result,stderr='';
|
|
253
|
+
for(let n=0;n<4;n++){
|
|
254
|
+
const out=f.drive(f.plan({...plan,...(n?{mode:'resume',originalHostContext:'drive-host-a'}:{})}),'advance');
|
|
255
|
+
assert.equal(out.status,0,out.stderr);stderr+=out.stderr;result=JSON.parse(out.stdout).result;
|
|
256
|
+
if(result.code==='documentation_sync_blocked')break;
|
|
257
|
+
}
|
|
258
|
+
assert.equal(result.code,'documentation_sync_blocked',JSON.stringify(result));
|
|
259
|
+
assert.match(stderr,/开始检查.*quiet-qa/);assert.match(stderr,/检查结束.*quiet-qa.*passed/);
|
|
260
|
+
assert.equal(JSON.parse(fs.readFileSync(path.join(f.specsDir,'.cm-status.json'))).state,'qa_passed');
|
|
261
|
+
});
|
|
262
|
+
|
|
64
263
|
test('create and advance run authored edits and actual check, then resume with original context',t=>{
|
|
65
264
|
const f=fixture(t);prepared(f);
|
|
66
265
|
const first=f.drive(f.plan(),'advance');assert.equal(first.status,0,first.stderr);
|
|
@@ -73,6 +272,104 @@ test('create and advance run authored edits and actual check, then resume with o
|
|
|
73
272
|
assert.equal(resumed.status,0,resumed.stderr);assert.equal(JSON.parse(resumed.stdout).result.code,'decision_required');
|
|
74
273
|
});
|
|
75
274
|
|
|
275
|
+
test('driver resumes an interrupted develop and sends the bound abandon_effect request',t=>{
|
|
276
|
+
const f=fixture(t);prepared(f);
|
|
277
|
+
const first=f.drive(f.plan(),'advance');assert.equal(first.status,0,first.stderr);
|
|
278
|
+
const current=JSON.parse(fs.readFileSync(f.store,'utf8'));
|
|
279
|
+
const index=current.records.findIndex(row=>row.payload.type==='effect-intent'
|
|
280
|
+
&&row.payload.effect.kind==='develop');assert(index>=0);
|
|
281
|
+
const {revision,...body}=current;body.records=current.records.slice(0,index+1);
|
|
282
|
+
fs.writeFileSync(f.store,JSON.stringify({...body,revision:digest(body)})+'\n');
|
|
283
|
+
fs.rmSync(path.join(f.codeProject,'target.mjs'));
|
|
284
|
+
const plan=f.plan({mode:'resume',permissions:['--allow-abandon-effect'],
|
|
285
|
+
reason:'Old host and its checks have exited'});
|
|
286
|
+
const result=f.drive(plan,'abandon_effect');assert.equal(result.status,0,result.stderr);
|
|
287
|
+
const response=JSON.parse(result.stdout).result;
|
|
288
|
+
assert.equal(response.state,'cancelled');assert.equal(response.code,'effect_abandoned');
|
|
289
|
+
const saved=JSON.parse(fs.readFileSync(f.store,'utf8'));
|
|
290
|
+
assert.deepEqual(saved.records.slice(-2).map(row=>row.payload.type),['effect-intent','effect-abandoned']);
|
|
291
|
+
});
|
|
292
|
+
test('real host drives split-root bootstrap scaffold, then refuses rules without answer files before creating T-002 run',
|
|
293
|
+
{skip:process.platform!=='darwin'},t=>{
|
|
294
|
+
const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-ai-drive-bootstrap-')));
|
|
295
|
+
t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
|
|
296
|
+
const specsDir=path.join(root,'specs5'),codeProject=path.join(root,'app'),feature='1.bootstrap';
|
|
297
|
+
fs.mkdirSync(path.join(specsDir,feature),{recursive:true});fs.mkdirSync(codeProject);
|
|
298
|
+
fs.writeFileSync(path.join(specsDir,feature,'requirements.md'),'# SwiftUI scaffold and rules\n');
|
|
299
|
+
fs.writeFileSync(path.join(specsDir,feature,'design.md'),'# Split specs5 and app roots\n');
|
|
300
|
+
fs.writeFileSync(path.join(specsDir,feature,'tasks.md'),'- [ ] T-001: 生成项目骨架 scaffold\n- [ ] T-002: 生成 AGENTS.md 和 .claude/ 规范(cm-init)\n');
|
|
301
|
+
fs.writeFileSync(path.join(specsDir,'.cm-specs-status'),JSON.stringify({status:'approved',features:[feature],specFiles:buildManifest(specsDir)}));
|
|
302
|
+
const answers=path.join(root,'answers'),bin=path.join(root,'bin');fs.mkdirSync(answers);fs.mkdirSync(bin);
|
|
303
|
+
fs.writeFileSync(path.join(answers,'app-content.mjs'),'export const app = true;\n');
|
|
304
|
+
fs.writeFileSync(path.join(answers,'develop.json'),JSON.stringify({...develop,edits:{'app.mjs':'app-content.mjs'}}));
|
|
305
|
+
const config=path.join(root,'run.json'),bootstrap=path.join(root,'bootstrap.json');
|
|
306
|
+
const plan=path.join(root,'plan.json'),selection={versionControl:'local',modules:[],analysis:'SwiftUI iOS app'};
|
|
307
|
+
const writeRun=(taskId,scope)=>fs.writeFileSync(config,JSON.stringify({version:1,specsDir,codeProject,feature,
|
|
308
|
+
identity:{repositoryId:'app',runId:`bootstrap-${taskId}`,taskId,attempt:1},scope,requirements:[]}));
|
|
309
|
+
const writePlan=(mode,permissions,extra={})=>fs.writeFileSync(plan,JSON.stringify({config:'run.json',mode,
|
|
310
|
+
hostContext:'drive-bootstrap-host',runtime:'claude',permissions,answers:'answers',
|
|
311
|
+
checks:[{id:'syntax',command:[process.execPath,'--check','app.mjs']}],...extra}));
|
|
312
|
+
const env={...process.env,PATH:bin+path.delimiter+process.env.PATH,
|
|
313
|
+
CM_WORKFLOW_HOME:path.join(root,'home'),CM_WORKFLOW_LOG_HOME:path.join(root,'logs')};
|
|
314
|
+
const drive=operation=>spawnSync(process.execPath,[DRIVER,'--plan',plan,operation],{encoding:'utf8',timeout:30000,env});
|
|
315
|
+
writeRun('T-001',['app.mjs']);fs.writeFileSync(bootstrap,JSON.stringify({selection:null}));
|
|
316
|
+
const reviewCli=path.join(bin,'claude');
|
|
317
|
+
fs.copyFileSync(fileURLToPath(new URL('./fixtures/claude-review-process.mjs',import.meta.url)),reviewCli);
|
|
318
|
+
fs.chmodSync(reviewCli,0o700);
|
|
319
|
+
const preview=spawnSync(process.execPath,[fileURLToPath(new URL('./cm-ai-host.mjs',import.meta.url)),
|
|
320
|
+
'preflight','--config',config,'--review-model','fixture','--runtime','claude'],
|
|
321
|
+
{encoding:'utf8',timeout:10000,env});
|
|
322
|
+
assert.equal(preview.status,0,preview.stderr);
|
|
323
|
+
fs.writeFileSync(path.join(root,'review.json'),preview.stdout);
|
|
324
|
+
writePlan('create',['--bootstrap-config','bootstrap.json','--allow-bootstrap-write','--review-config','review.json']);
|
|
325
|
+
const scaffold=drive('advance');assert.equal(scaffold.status,0,scaffold.stderr);
|
|
326
|
+
const first=JSON.parse(scaffold.stdout).result;assert.equal(first.state,'awaiting_review');
|
|
327
|
+
assert.equal(fs.readFileSync(path.join(codeProject,'app.mjs'),'utf8'),'export const app = true;\n');
|
|
328
|
+
writePlan('resume',['--bootstrap-config','bootstrap.json','--allow-bootstrap-write','--review-config','review.json',
|
|
329
|
+
'--allow-review-attempt','1'],{packageDigest:first.packageDigest});
|
|
330
|
+
const review=drive('decision');
|
|
331
|
+
assert.equal(review.status,0,review.stderr);assert.equal(JSON.parse(review.stdout).result.state,'approved');
|
|
332
|
+
writePlan('resume',['--bootstrap-config','bootstrap.json','--allow-bootstrap-write','--review-config','review.json']);
|
|
333
|
+
const completed=drive('advance');assert.equal(completed.status,0,completed.stderr);
|
|
334
|
+
assert.equal(JSON.parse(completed.stdout).result.state,'fixture_completed');
|
|
335
|
+
assert.match(fs.readFileSync(path.join(specsDir,feature,'tasks.md'),'utf8'),/\[x\] T-001/);
|
|
336
|
+
writeRun('T-002',cmInitRuleTargets(selection,codeProject));
|
|
337
|
+
fs.writeFileSync(bootstrap,JSON.stringify({selection}));
|
|
338
|
+
writePlan('create',['--bootstrap-config','bootstrap.json','--allow-bootstrap-write']);
|
|
339
|
+
const rules=drive('advance');assert.equal(rules.status,2,rules.stderr);
|
|
340
|
+
assert.match(rules.stderr,/会反问 init_generate,但答案文件不存在: .*init-generate\.json/);
|
|
341
|
+
assert.equal(fs.existsSync(path.join(specsDir,'.reviews','.execution','bootstrap-T-002')),false);
|
|
342
|
+
assert.equal(fs.existsSync(path.join(codeProject,'.claude')),false);
|
|
343
|
+
});
|
|
344
|
+
test('driver requires resume, flag and one-line reason for abandon_effect before launch',t=>{
|
|
345
|
+
const f=fixture(t);
|
|
346
|
+
for(const plan of [
|
|
347
|
+
{mode:'create',permissions:['--allow-abandon-effect'],reason:'host exited'},
|
|
348
|
+
{mode:'resume',permissions:[],reason:'host exited'},
|
|
349
|
+
{mode:'resume',permissions:['--allow-abandon-effect'],reason:'line one\nline two'},
|
|
350
|
+
{mode:'resume',permissions:['--allow-abandon-effect'],reason:'x'.repeat(501)}]){
|
|
351
|
+
const run=f.drive(f.plan(plan),'abandon_effect');assert.equal(run.status,2,run.stderr);
|
|
352
|
+
assert.match(run.stderr,/abandon_effect 需要 resume/);
|
|
353
|
+
assert.equal(fs.existsSync(f.store),false);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
test('bootstrap review recovery driver requires a bound resume and sends only the reason',t=>{
|
|
358
|
+
const f=fixture(t);
|
|
359
|
+
for(const plan of [
|
|
360
|
+
{mode:'create',permissions:['--allow-bootstrap-review-recovery'],reason:'review package failed'},
|
|
361
|
+
{mode:'resume',permissions:[],reason:'review package failed'},
|
|
362
|
+
{mode:'resume',permissions:['--allow-bootstrap-review-recovery'],reason:'line one\nline two'}]){
|
|
363
|
+
assert.match(bootstrapReviewRecoveryPlanError('bootstrap_review_recover',plan,plan.permissions),/需要 resume/);
|
|
364
|
+
const run=f.drive(f.plan(plan),'bootstrap_review_recover');assert.equal(run.status,2,run.stderr);
|
|
365
|
+
assert.equal(fs.existsSync(f.store),false);
|
|
366
|
+
}
|
|
367
|
+
const plan={mode:'resume',permissions:['--allow-bootstrap-review-recovery'],reason:'Checked bound files and handoff'};
|
|
368
|
+
assert.equal(bootstrapReviewRecoveryPlanError('bootstrap_review_recover',plan,plan.permissions),null);
|
|
369
|
+
assert.deepEqual(buildCmAiDriveRequest('bootstrap_review_recover',plan,{identity}),
|
|
370
|
+
{version:1,identity,reason:plan.reason});
|
|
371
|
+
});
|
|
372
|
+
|
|
76
373
|
test('missing develop answer is refused before store creation',t=>{
|
|
77
374
|
const f=fixture(t);const run=f.drive(f.plan(),'advance');
|
|
78
375
|
assert.equal(run.status,2);assert.match(run.stderr,/develop\.json/);assert.equal(fs.existsSync(f.store),false);
|
|
@@ -166,10 +463,16 @@ test('protected conversation still requires the authored develop answer',t=>{
|
|
|
166
463
|
permissions:['--protected-conversation-config','protection.json']}),'advance');
|
|
167
464
|
assert.equal(run.status,2);assert.match(run.stderr,/develop\.json/);assert.equal(fs.existsSync(f.store),false);
|
|
168
465
|
});
|
|
169
|
-
test('resume
|
|
466
|
+
test('same-session resume may omit originalHostContext and cross-session omission fails exact fingerprint',t=>{
|
|
170
467
|
const f=fixture(t);prepared(f);
|
|
171
|
-
|
|
172
|
-
|
|
468
|
+
assert.equal(f.drive(f.plan(),'advance').status,0);
|
|
469
|
+
const before=fs.readFileSync(f.store);
|
|
470
|
+
const same=f.drive(f.plan({mode:'resume',answers:undefined,checks:undefined}),'status');
|
|
471
|
+
assert.equal(same.status,0,same.stderr);
|
|
472
|
+
assert.equal(JSON.parse(same.stdout).result.state,'awaiting_review');
|
|
473
|
+
const cross=f.drive(f.plan({mode:'resume',hostContext:'drive-host-b',answers:undefined,checks:undefined}),'status');
|
|
474
|
+
assert.equal(cross.status,1,cross.stderr);assert.match(cross.stderr,/fingerprint_mismatch/);
|
|
475
|
+
assert.deepEqual(fs.readFileSync(f.store),before);
|
|
173
476
|
});
|
|
174
477
|
test('supersession flags reach create and incomplete or resume pairs stop before host launch',t=>{
|
|
175
478
|
const f=fixture(t);prepared(f);
|
|
@@ -177,11 +480,17 @@ test('supersession flags reach create and incomplete or resume pairs stop before
|
|
|
177
480
|
const create=f.drive(f.plan({permissions:both}),'advance');
|
|
178
481
|
assert.equal(create.status,1,create.stderr);
|
|
179
482
|
assert.match(create.stderr,/supersede_unavailable/);
|
|
483
|
+
const accepted=f.drive(f.plan({permissions:[...both,'--accept-superseded-code-drift']}),'advance');
|
|
484
|
+
assert.equal(accepted.status,1,accepted.stderr);
|
|
485
|
+
assert.match(accepted.stderr,/supersede_unavailable/);
|
|
180
486
|
for(const permissions of [['--supersede-reviewed-evidence'],['--supersede-reason','operator restart']]){
|
|
181
487
|
const refused=f.drive(f.plan({permissions}),'advance');
|
|
182
488
|
assert.equal(refused.status,2,refused.stderr);
|
|
183
489
|
assert.match(refused.stderr,/supersede-reviewed-evidence.*supersede-reason/);
|
|
184
490
|
}
|
|
491
|
+
const orphan=f.drive(f.plan({permissions:['--accept-superseded-code-drift']}),'advance');
|
|
492
|
+
assert.equal(orphan.status,2,orphan.stderr);
|
|
493
|
+
assert.match(orphan.stderr,/accept-superseded-code-drift.*supersede-reviewed-evidence/);
|
|
185
494
|
const resumed=f.drive(f.plan({mode:'resume',originalHostContext:'drive-host-a',permissions:both}),'status');
|
|
186
495
|
assert.equal(resumed.status,2,resumed.stderr);
|
|
187
496
|
assert.match(resumed.stderr,/supersede.*create/);
|
|
@@ -256,3 +565,20 @@ driveHost({host:${JSON.stringify(host)},args:[],cwd:${JSON.stringify(f.root)},op
|
|
|
256
565
|
assert.deepEqual(JSON.parse(run.stdout).result.answer,
|
|
257
566
|
{contextDigest:'context',status:'no_relevant_lesson',summary:'No applicable lesson'});
|
|
258
567
|
});
|
|
568
|
+
|
|
569
|
+
test('new policy real driver reuses only declared checks and frozen resume keeps the policy',t=>{
|
|
570
|
+
const f=fixture(t);prepared(f);
|
|
571
|
+
const command=[process.execPath,'-e',"require('node:fs').appendFileSync("+JSON.stringify(path.join(f.root,'execution-count'))+",'x');console.log('tests 1\\npass 1')"];
|
|
572
|
+
const checks=[{id:'tests',command},{id:'ui',command,sameExecutionAs:'tests'}];
|
|
573
|
+
const plan=f.plan({permissions:['--execution-optimizations'],checks});
|
|
574
|
+
const first=f.drive(plan,'advance');assert.equal(first.status,0,first.stderr);assert.equal(JSON.parse(first.stdout).result.state,'awaiting_review',first.stdout+first.stderr);
|
|
575
|
+
assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'x');
|
|
576
|
+
const before=fs.readFileSync(f.store),snapshot=JSON.parse(before);assert.equal(snapshot.records[0].payload.config.executionPolicy.checkReuse,'declared-adjacent-v1');
|
|
577
|
+
const resume=f.plan({mode:'resume',checks});const status=f.drive(resume,'status');assert.equal(status.status,0,status.stderr);
|
|
578
|
+
assert.equal(fs.readFileSync(path.join(f.root,'execution-count'),'utf8'),'x');assert.deepEqual(fs.readFileSync(f.store),before);
|
|
579
|
+
});
|
|
580
|
+
test('legacy real driver rejects optimization aliases before any host or command starts',t=>{
|
|
581
|
+
const f=fixture(t);prepared(f);const command=[process.execPath,'-e',"require('node:fs').writeFileSync('marker','bad')"];
|
|
582
|
+
const result=f.drive(f.plan({checks:[{id:'one',command},{id:'two',command,sameExecutionAs:'one'}]}),'advance');
|
|
583
|
+
assert.notEqual(result.status,0);assert(!fs.existsSync(f.store));assert(!fs.existsSync(path.join(f.codeProject,'marker')));
|
|
584
|
+
});
|