T-57: M1.3b — trial_ledger + vault_evaluations append-only PostgreSQL migration (research track)
This commit is contained in:
parent
5025286e49
commit
0c7a2c14a5
3 changed files with 22 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ const FROZEN_TRIAL_LEDGER_COLUMNS = [
|
|||
'campaign_id UUID',
|
||||
'stage VARCHAR(16) NOT NULL',
|
||||
'universe_market VARCHAR(12) NOT NULL',
|
||||
'horizon_bucket VARCHAR(16) NOT NULL',
|
||||
'horizon_bucket VARCHAR(32) NOT NULL',
|
||||
'hypothesis_id UUID',
|
||||
'expression_hash CHAR(64) NOT NULL',
|
||||
'sample_start DATE NOT NULL',
|
||||
|
|
@ -151,6 +151,25 @@ describe('36-trial-ledger.sql static contract', () => {
|
|||
expect(readSql()).toMatch(/sample_end.*VAULT_CUTOFF_DATE/);
|
||||
});
|
||||
|
||||
test('every VARCHAR(N) column fits all literals in its IN (...) CHECK constraint', () => {
|
||||
const sql = stripComments(readSql());
|
||||
const matches = [
|
||||
...sql.matchAll(/(\w+)\s+VARCHAR\((\d+)\)\s+NOT NULL\s+CHECK\s*\(\1\s+IN\s*\(([^)]+)\)\)/g),
|
||||
];
|
||||
expect(matches.length).toBeGreaterThanOrEqual(3);
|
||||
for (const [, col, maxLenStr, valuesList] of matches) {
|
||||
const maxLen = Number(maxLenStr);
|
||||
const literals = [...valuesList!.matchAll(/'([^']+)'/g)].map(m => m[1]!);
|
||||
expect(literals.length).toBeGreaterThan(0);
|
||||
for (const literal of literals) {
|
||||
expect(
|
||||
literal.length,
|
||||
`${col} VARCHAR(${maxLen}) must fit enum value '${literal}' (length ${literal.length})`
|
||||
).toBeLessThanOrEqual(maxLen);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('defines idempotent immutability and rolling-year vault cap triggers', () => {
|
||||
const sql = stripComments(readSql()).replace(/\s+/g, ' ');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue