/** * P7/D15 A3 — drift-lock for the install_audit CHECK constraints. * * install-audit.ts generates the table DDL from the canonical @waggle/shared * arrays. This test pins every CHECK list to that single source, so a drift * fails CI instead of crashing auditStore.record() in production. */ import { describe, it, expect } from 'vitest'; import { sqlInList, RISK_LEVELS, APPROVAL_CLASSES, AUDIT_ACTIONS, AUDIT_CAPABILITY_TYPES, AUDIT_INITIATORS, TRUST_SOURCES, } from '@waggle/shared'; import { INSTALL_AUDIT_TABLE_SQL } from '../../src/local/install-audit.js'; const COLUMNS = [ { col: 'capability_type', values: AUDIT_CAPABILITY_TYPES }, { col: 'risk_level', values: RISK_LEVELS }, { col: 'trust_source', values: TRUST_SOURCES }, { col: 'approval_class', values: APPROVAL_CLASSES }, { col: 'action', values: AUDIT_ACTIONS }, { col: 'initiator', values: AUDIT_INITIATORS }, ] as const; describe('install_audit CHECK parity (A3)', () => { for (const { col, values } of COLUMNS) { const expected = `${col} IN (${sqlInList(values)})`; it(`install-audit DDL pins ${col} to the canonical list`, () => { expect(INSTALL_AUDIT_TABLE_SQL).toContain(expected); }); } it('the DDL accepts the P5/D4 uninstalled action', () => { expect(INSTALL_AUDIT_TABLE_SQL).toContain("'uninstalled'"); }); });