/** * THE RULE (e2e rulings R1, 15 Nov 2026): every table of a personal database * is sealed unless crates/cotton-core/src/seal/default.json names it, open by * design (R1) or pending the move of the object's own work on its values * (R2/R3). The default is the core's too: both are held to the same vectors * (crates/cotton-conformance/vectors/seal/default.json). */import { describe, expect, it } from"vitest";import VECTORS from"../../../crates/cotton-conformance/vectors/seal/default.json";import { PERSONAL } from"../src/kits.ts";import { defaultSeal, OPEN_TABLES, parseSeal, PENDING_TABLES, ruled, sealedSetProblem, sealProblem } from"../src/seal.ts";typeDoc = Record<string, unknown>;const id = (t: Doc): string => String(t.id);describe("the seal rule", () => { it("answers every vector the core answers", () => {for (const v of VECTORS.cases as { name: string; table: Doc; seal: Doc | null }[]) {const said = defaultSeal(v.table); expect(said && { clear: said.clear }, v.name).toEqual(v.seal); } }); it("names only tables the personal kit holds, each once and for a reason", () => {const held = newSet(PERSONAL.tables.map(id));for (const [table, why] of [...Object.entries(OPEN_TABLES), ...Object.entries(PENDING_TABLES)]) { expect(held.has(table), `${table} is a personal kit table`).toBe(true); expect(why.length, `${table} says why`).toBeGreaterThan(10); }const both = Object.keys(OPEN_TABLES).filter((t) => Object.hasOwn(PENDING_TABLES, t)); expect(both, "open or pending, never both").toEqual([]); }); it("seals every personal kit table it does not name, and each ruled table reads", () => {const open: string[] = [];for (const raw of PERSONAL.tables) {const t = ruled(raw); expect(sealProblem(t), id(t)).toBeNull();if (!parseSeal(t)) open.push(id(t)); expect(ruled(t), `${id(t)}: ruling twice changes nothing`).toEqual(t); } expect(open.sort(), "open only where the rule names it").toEqual([...Object.keys(OPEN_TABLES), ...Object.keys(PENDING_TABLES)].sort()); }); it("leaves no kit tool's view, automation or computed column reading a sealed column", () => {const tables = PERSONAL.tables.map(ruled); expect(sealedSetProblem([], tables, [...PERSONAL.own, ...PERSONAL.tools])).toBeNull(); });});