#!/usr/bin/env node
import fs from 'fs';
import assert from 'assert';

const files = [
  './.vl-code/workflows/parallel-codegen.json',
  './public/seed-workflows/parallel-codegen.json',
  './.vl-code/workflows/meta-direct-codegen.json',
  './public/seed-workflows/meta-direct-codegen.json',
  './.vl-code/workflows/add-service.json',
  './public/seed-workflows/add-service.json',
];

function main() {
  console.log('\n── Workflow Service Filter Constraints ──');

  for (const file of files) {
    const raw = fs.readFileSync(file, 'utf-8');
    assert.ok(raw.includes('Backend query-safety rules: build filter arrays incrementally.'), `${file} missing query-safety rules`);
    assert.ok(raw.includes('Never generate conditions like [\\"field\\",\\"*eq\\",\\"\\"]'), `${file} missing empty-filter guard`);
    console.log(`PASS ${file}`);
  }

  console.log('PASS test-workflow-service-filter-constraints.js');
}

main();
