// 🤖 Drift gate for the native seed catalogue: the JSON bundled into // LChatCore (Seed/app-catalog.json, decoded by AppRegistry) must equal what // tools/gen-app-catalog.mjs generates from the live app framework. When an // app's manifest facts change (title, glyph, places, presentation, commands), // regenerate with `node tools/gen-app-catalog.mjs --write` and commit both // sides — the same shape as the schema drift gate (schema-engine.test.mjs). import { readFileSync } from "node:fs"; import { collect, seedPath } from "../tools/gen-app-catalog.mjs"; const generated = JSON.stringify(await collect(), null, 2) + "\n"; const committed = readFileSync(seedPath, "utf8"); if (generated !== committed) { console.error("FAIL: the bundled native seed catalogue has drifted from the app framework."); console.error("Run: node tools/gen-app-catalog.mjs --write (then commit the seed)"); const a = JSON.parse(generated), b = JSON.parse(committed); const an = new Set(a.map((x) => x.name)), bn = new Set(b.map((x) => x.name)); const missing = [...an].filter((n) => !bn.has(n)); const stale = [...bn].filter((n) => !an.has(n)); if (missing.length) console.error(" missing from seed:", missing.join(", ")); if (stale.length) console.error(" stale in seed:", stale.join(", ")); process.exit(1); } // A couple of load-bearing facts native routing depends on — if these change // on the web side, the native routers' behaviour changes with them; fail // loudly so the change is a decision, not an accident. const seed = JSON.parse(committed); const byName = Object.fromEntries(seed.map((a) => [a.name, a])); function assert(cond, msg) { if (!cond) { console.error("FAIL:", msg); process.exit(1); } } assert(byName.admin?.companion === true && byName.admin?.defaultView === "interface", "admin must be a companion opening on its interface (the Mac Chat|View / iOS routing fix)"); assert(byName.board?.places.includes("chat"), "board must be group-capable (the board-in-a-group fix)"); assert(byName.todo?.companion === true && byName.remind?.companion === true, "todo/remind stay companions (the native schema surfaces key off this)"); console.log(`appcatalog-seed: seed matches the framework (${seed.length} apps)`);