T-78: M1.1j — Persist Pass 3/5/6 results into the security master: idempotent PostgreSQL loader with permanent listing_ids and override precedence

This commit is contained in:
Studio 2026-11-27 23:11:48 -05:00
parent d65d3f00d5
commit d68577843e

View file

@ -5,7 +5,6 @@ import { getLogger, setLoggerConfig } from '@stock-bot/logger';
import { PostgreSQLClient, runPostgresMigrations } from '@stock-bot/postgres';
import {
DEFAULT_OTC_MICS,
DEFAULT_VALID_FROM,
formatListingNaturalKey,
linkDelistingChains,
matchInstrumentsStageA,
@ -704,12 +703,12 @@ describe.skipIf(!url)('persistSecurityMaster PostgreSQL integration', () => {
const aaplId = initial.listingIdByKey.get(aaplKey)!;
const shopNyseId = initial.listingIdByKey.get(shopNyseKey)!;
// 1) Override an existing matcher mapping (eod, AAPL.US, 1900-01-01) -> shopNyseId
// 1) Override an existing matcher mapping (eod, AAPL.US, 1980-12-12) -> shopNyseId
// 2) Add an override-only mapping absent from matcher output (qm, MANUAL_OVR:US, 2021-01-01) -> aaplId
await f.pool.query(
`INSERT INTO override (source, source_id, valid_from, valid_to, listing_id, reason, created_by)
VALUES
('eod', 'AAPL.US', DATE '1900-01-01', DATE '2025-12-31', $1, 'conflict resolution', 'director'),
('eod', 'AAPL.US', DATE '1980-12-12', DATE '2025-12-31', $1, 'conflict resolution', 'director'),
('qm', 'MANUAL_OVR:US', DATE '2021-01-01', NULL, $2, 'manual addition', 'director')`,
[shopNyseId, aaplId]
);
@ -743,7 +742,7 @@ describe.skipIf(!url)('persistSecurityMaster PostgreSQL integration', () => {
{
source: 'eod',
source_id: 'AAPL.US',
valid_from: DEFAULT_VALID_FROM,
valid_from: '1980-12-12',
valid_to: '2025-12-31',
listing_id: shopNyseId,
method: 'override',