feat(parties): phase 0 prerequisites, pg_trgm and golden-set draw (#2157)
* feat(parties): phase 0 prerequisites, pg_trgm and golden-set draw Phase 0 of the Kontakter plan: make the counterparty resolver measurable before building it. - Migration 20260902120000 enables pg_trgm (trigram blocking of counterparty keys) and drops the two context-graph tables from 20260706193007 whose feature code was never merged and which prod no longer has, so fresh replays agree with prod. - tests/pg/parties-phase0.pg.test.ts pins the extension, a sanity check on trigram ranking, and the absence of the graph tables. - scripts/parties/draw-golden-set.sql is the reproducible, read-only draw of the 200-key labelling sample (three strata, md5-ordered) and the payee-identity base rate. The drawn rows contain customer voucher text and are kept in gitignored dev_docs, never in this public repo. - scripts/parties/README.md records the label vocabulary and the numbers measured on prod on 2026-09-02. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(archive): drop the two context-graph tables from the archive contract The migration in this PR removes graph_counterparties and graph_transaction_counterparties, so the full-archive contract must stop classifying them: tests/schema/no-phantom-columns.test.ts asserts that every classified table exists in the migration replay, and the live-DB twin in tests/pg/full-archive-coverage.pg.test.ts asserts the same against information_schema. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
Jakob Wennberg
parent
f266c386f3
commit
61a76b1669
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { getPool } from './setup'
|
||||
|
||||
/**
|
||||
* Parties, phase 0 (migration 20260902120000): pg_trgm is available for
|
||||
* trigram blocking of counterparty keys, and the two context-graph tables
|
||||
* whose feature code was never merged are gone, so local replays agree with
|
||||
* prod (where they were dropped during the context-graph revert).
|
||||
*/
|
||||
describe('parties phase 0 (pg)', () => {
|
||||
it('pg_trgm is installed', async () => {
|
||||
const { rows } = await getPool().query<{ n: number }>(
|
||||
`SELECT count(*)::int AS n FROM pg_extension WHERE extname = 'pg_trgm'`,
|
||||
)
|
||||
expect(rows[0]!.n).toBe(1)
|
||||
})
|
||||
|
||||
it('trigram similarity ranks the same vendor above a different one', async () => {
|
||||
const { rows } = await getPool().query<{ same: number; other: number }>(
|
||||
`SELECT extensions.similarity('levfakt beijer byggmaterial 097', 'beijer byggmaterial') AS same,
|
||||
extensions.similarity('levfakt beijer byggmaterial 097', 'skelleftea plat') AS other`,
|
||||
)
|
||||
expect(Number(rows[0]!.same)).toBeGreaterThan(Number(rows[0]!.other))
|
||||
expect(Number(rows[0]!.same)).toBeGreaterThan(0.3)
|
||||
})
|
||||
|
||||
it('the reverted context-graph tables are gone', async () => {
|
||||
const { rows } = await getPool().query<{ n: number }>(
|
||||
`SELECT count(*)::int AS n
|
||||
FROM pg_tables
|
||||
WHERE schemaname = 'public'
|
||||
AND tablename IN ('graph_counterparties', 'graph_transaction_counterparties')`,
|
||||
)
|
||||
expect(rows[0]!.n).toBe(0)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user