T-151: M2.1i — findings + provider_caveats append-only PostgreSQL migration (research track, 37-research-findings.sql) with fresh-database schema tests (no adapters, no new deps)

This commit is contained in:
Studio 2026-12-02 00:12:13 -05:00
parent 34fdfd6bc4
commit c16d6b3f60
7 changed files with 672 additions and 11 deletions

View file

@ -37,6 +37,7 @@ const migrations = [
'32-candidate-parameter-defaults.sql',
'33-candidate-decimal-normalization.sql',
'36-trial-ledger.sql',
'37-research-findings.sql',
];
const cleanup: (() => Promise<void>)[] = [];
afterEach(async () => {
@ -384,17 +385,22 @@ describe.skipIf(!url)('startup migrations on real PostgreSQL', () => {
];
// 1. research track must NOT apply 34-security-master.sql or 35-security-master-exchange-seed.sql,
// and MUST apply 36-trial-ledger.sql; master track applies 34-35 (not 36) and is idempotent on re-run.
// and MUST apply 36-trial-ledger.sql and 37-research-findings.sql; master track applies 34-35 (not 36-37) and is idempotent on re-run.
const f1 = await fixture();
const runner1 = f1.startup();
const researchApplied = await runner1.runTrack('research');
expect(researchApplied).not.toContain('34-security-master.sql');
expect(researchApplied).not.toContain('35-security-master-exchange-seed.sql');
expect(researchApplied).toContain('36-trial-ledger.sql');
expect(researchApplied).toContain('37-research-findings.sql');
expect(researchApplied.indexOf('37-research-findings.sql')).toBe(
researchApplied.indexOf('36-trial-ledger.sql') + 1
);
const recordedAfterResearch = await f1.recorded();
expect(recordedAfterResearch).not.toContain('34-security-master.sql');
expect(recordedAfterResearch).not.toContain('35-security-master-exchange-seed.sql');
expect(recordedAfterResearch).toContain('36-trial-ledger.sql');
expect(recordedAfterResearch).toContain('37-research-findings.sql');
const tablesAfterResearch = new Set(await f1.relations());
for (const table of securityMasterTables) {
@ -402,11 +408,14 @@ describe.skipIf(!url)('startup migrations on real PostgreSQL', () => {
}
expect(tablesAfterResearch.has('trial_ledger')).toBe(true);
expect(tablesAfterResearch.has('vault_evaluations')).toBe(true);
expect(tablesAfterResearch.has('findings')).toBe(true);
expect(tablesAfterResearch.has('provider_caveats')).toBe(true);
const masterApplied = await runner1.runTrack('master');
expect(masterApplied).toContain('34-security-master.sql');
expect(masterApplied).toContain('35-security-master-exchange-seed.sql');
expect(masterApplied).not.toContain('36-trial-ledger.sql');
expect(masterApplied).not.toContain('37-research-findings.sql');
expect(masterApplied.indexOf('35-security-master-exchange-seed.sql')).toBe(
masterApplied.indexOf('34-security-master.sql') + 1
);
@ -421,7 +430,7 @@ describe.skipIf(!url)('startup migrations on real PostgreSQL', () => {
expect(await runner1.runTrack('master')).toEqual([]);
// 2. all track applies 34, 35, and 36 alongside 01-05 and 09-33 and is idempotent.
// 2. all track applies 34, 35, 36, and 37 alongside 01-05 and 09-33 and is idempotent.
const f2 = await fixture();
const runner2 = f2.startup();
const allApplied = await runner2.runTrack('all');
@ -432,10 +441,12 @@ describe.skipIf(!url)('startup migrations on real PostgreSQL', () => {
expect(allApplied).toContain('34-security-master.sql');
expect(allApplied).toContain('35-security-master-exchange-seed.sql');
expect(allApplied).toContain('36-trial-ledger.sql');
expect(allApplied).toContain('37-research-findings.sql');
const recordedAfterAll = await f2.recorded();
expect(recordedAfterAll).toContain('34-security-master.sql');
expect(recordedAfterAll).toContain('35-security-master-exchange-seed.sql');
expect(recordedAfterAll).toContain('36-trial-ledger.sql');
expect(recordedAfterAll).toContain('37-research-findings.sql');
const tablesAfterAll = new Set(await f2.relations());
for (const table of securityMasterTables) {
@ -443,6 +454,8 @@ describe.skipIf(!url)('startup migrations on real PostgreSQL', () => {
}
expect(tablesAfterAll.has('trial_ledger')).toBe(true);
expect(tablesAfterAll.has('vault_evaluations')).toBe(true);
expect(tablesAfterAll.has('findings')).toBe(true);
expect(tablesAfterAll.has('provider_caveats')).toBe(true);
expect(await runner2.runTrack('all')).toEqual([]);
});