25 lines · 1.2 KB · TypeScriptRaw
import { existsSync, readdirSync, readFileSync } from "node:fs";import { join, resolve } from "node:path";import { expect, it } from "vitest";function sources(dir: string): string[] { return readdirSync(dir, { withFileTypes: true }).flatMap(entry => { const path = join(dir, entry.name); return entry.isDirectory() ? sources(path) : /\.(rs|swift)$/.test(path) && !/_tests\.rs$/.test(path) ? [path] : []; });}/// RULE: No production reader uses a numeric definitions revision or min_revision gate; hashes identify content, build stamps order seeds, and field presence gates capabilities.it("production code has no numeric definitions revision reader", () => { const root = resolve(__dirname, "../.."); const crateSources = readdirSync(join(root, "crates"), { withFileTypes: true }) .filter(entry => entry.isDirectory()) .map(entry => join(root, "crates", entry.name, "src")) .filter(existsSync); for (const dir of [...crateSources, join(root, "apps/cotton/Sources")]) { for (const path of sources(dir)) { const text = readFileSync(path, "utf8"); expect(text, path).not.toMatch(/BUILTIN_DEFINITIONS_REVISION|\bmin_revision\b|\bminRevision\b|\.int\("builtin_revision"\)/); } }});