test-compile-fix-workflow.js 1.6 KB

123456789101112131415161718192021222324252627
  1. import fs from 'fs';
  2. import path from 'path';
  3. function assert(condition, message) {
  4. if (!condition) throw new Error(message);
  5. }
  6. console.log('\n── Compile-Fix Workflow Shape ──');
  7. const workflowPath = path.join(process.cwd(), '.vl-code', 'workflows', 'compile-fix.json');
  8. const workflow = JSON.parse(fs.readFileSync(workflowPath, 'utf-8'));
  9. assert(workflow.version === '3.16', 'compile-fix workflow should stay on spec v3.16');
  10. assert(workflow.registry.files.inputs.includes('.vl-code/last-compile.json'), 'compile-fix workflow should depend on the latest compile report');
  11. const stepIds = workflow.steps.map(step => step.id);
  12. assert(stepIds.includes('LLM_010_LoadCompileReport'), 'compile-fix workflow should load the persisted compile report first');
  13. assert(stepIds.includes('LLM_020_PlanFixes'), 'compile-fix workflow should plan file-level fixes');
  14. assert(stepIds.includes('LLM_031_ApplyFix'), 'compile-fix workflow should rewrite the affected files');
  15. assert(!stepIds.includes('LLM_010_Compile'), 'compile-fix workflow should not pretend to compile internally');
  16. assert(!stepIds.includes('LLM_040_Recompile'), 'compile-fix workflow should leave recompilation to the real compile tool');
  17. const applyFix = workflow.steps.find(step => step.id === 'LLM_031_ApplyFix');
  18. assert(Array.isArray(applyFix?.in?.readFiles) && applyFix.in.readFiles[0] === '=_item.file', 'file fix step should read the current file before rewriting it');
  19. assert(applyFix.out && Object.keys(applyFix.out).includes('/{_item.file}'), 'file fix step should write back to the affected file path');
  20. console.log('PASS test-compile-fix-workflow.js');