Files
waggle-os/packages/server/tests/local/install-audit-check-parity.test.ts
shumeiko.it 2e08f2ae96 refactor(server): move the install audit trail from core to the server (P1.2, UF-040)
Core keeps only shared infrastructure, so InstallAuditStore leaves it and
lives in packages/server/src/local/install-audit.ts. The trail itself stays:
the Audit and Activity tabs, the extend and export routes, and the threat
model entry keep working on the same waggle.db table.

- @waggle/shared gets RecordAuditInput and the narrow InstallAuditRecorder
  (record only), which the agent's skill tools now depend on.
- The server creates the audit table before the one-time legacy copy, which
  no longer constructs it in core.
- UF-040: GET /api/debug/logs called prepare() on the store's private db
  wrapper, which has none, so the support bundle never carried recent
  installs. It now reads them through getRecentSummary().
2026-10-25 21:32:38 +01:00

37 lines
1.3 KiB
TypeScript

/**
* 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'");
});
});