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-28 13:31:52 -05:00
parent fe9ec15199
commit 92edeeaf9f
3 changed files with 7 additions and 7 deletions

View file

@ -79,8 +79,8 @@ bun --env-file=/home/boki/.studio/test-env/stock-bot.env test test/postgres/secu
- **Recorded baseline (`2026-11-28`, host PostgreSQL isolated `stock_bot_safety_*` schema, default `chunkSize = 5000`):**
- Workload: `20,000` instruments, `20,000` listings, `60,000` provider mappings (`100,000` core rows; `140,000` total rows including `20,000` `instrument_identifier_history` and `20,000` `listing_symbol_history` rows).
- Observed end-to-end test wall time: `2.20s` (`2200.02ms`, reported by `bun test`; includes isolated schema migration, synthetic fixture construction, `persistSecurityMaster`, and `COUNT(*)` verification because `test/setup.ts` suppresses `console.info`).
- Throughput (conservative lower bound over full test wall time): `45,454` core rows/s (`100,000 / 2.20002s`), `63,636` total rows/s (`140,000 / 2.20002s`).
- Observed end-to-end test wall time: `2.36s` (`2359.01ms`, reported by `bun test`; includes isolated schema migration, synthetic fixture construction, `persistSecurityMaster`, and `COUNT(*)` verification).
- Throughput (conservative lower bound over full test wall time): `42,391` core rows/s (`100,000 / 2.35901s`), `59,347` total rows/s (`140,000 / 2.35901s`).
## Read-Only Source-Symbol Readers (`source-symbol-readers.ts`)
`apps/stock/data-pipeline/src/security-master/source-symbol-readers.ts` adapts raw `eodSymbols`, `ibSymbols`, `qmSymbols`, `ceoSymbols`, and `eodSymbolChange` documents into deterministic Stage A (`StageASourceRecord`) and Stage B (`StageBEodListingInput`, `StageBIbContractInput`, `StageBTickerSourceInput`, `StageBSymbolChangeInput`) inputs via `readSecurityMasterSources`:

View file

@ -6,9 +6,9 @@
* schema, default `chunkSize = 5000`):
* - Command: `bun --env-file=/home/boki/.studio/test-env/stock-bot.env test test/postgres/security-master-persist.test.ts`
* - Workload: 20,000 instruments, 20,000 listings, 60,000 mappings (100,000 core rows; 140,000 total rows).
* - Observed end-to-end test wall time: 2.20s (2200.02ms, including schema setup, fixture generation,
* persistence, and COUNT(*) verification because `test/setup.ts` suppresses `console.info`).
* - Throughput (lower bound over full test wall time): 45,454 core rows/s, 63,636 total rows/s.
* - Observed end-to-end test wall time: 2.36s (2359.01ms, including schema setup, fixture generation,
* persistence, and COUNT(*) verification).
* - Throughput (lower bound over full test wall time): 42,391 core rows/s, 59,347 total rows/s.
*/
import type {
DelistingChainResult,

View file

@ -1970,8 +1970,8 @@ describe.skipIf(!url)('persistSecurityMaster PostgreSQL integration', () => {
expect(counts.listing).toBe(instrumentCount);
expect(counts.provider_mapping).toBe(instrumentCount * 3);
console.info(
`[security-master-persist benchmark] ${instrumentCount} instruments, ${instrumentCount} listings, ${instrumentCount * 3} mappings (${totalAllRows} total rows) persisted in ${elapsedSec.toFixed(2)}s (${Math.round(totalCoreRows / elapsedSec)} core rows/s, ${Math.round(totalAllRows / elapsedSec)} total rows/s)`
process.stdout.write(
`[security-master-persist benchmark] ${instrumentCount} instruments, ${instrumentCount} listings, ${instrumentCount * 3} mappings (${totalAllRows} total rows) persisted in ${elapsedSec.toFixed(2)}s (${Math.round(totalCoreRows / elapsedSec)} core rows/s, ${Math.round(totalAllRows / elapsedSec)} total rows/s)\n`
);
},
120_000