--- convoy: pricing-online-local brief_number: 3 depends_on: [2] recommended_model: composer-2.5 model_tier: standard files: - lib/card-import/bulk-sync.js - test/lib/card-import/bulk-sync.test.js cross_brief_commitments: - brief: 2 description: | Uses `recordPriceSnapshots` and sets `prices_updated_at = CURRENT_TIMESTAMP` on each upsert batch where price columns change. --- # Brief 3: MTG bulk sync + snapshots ## Goal (1 sentence) Update Scryfall bulk sync to stamp `prices_updated_at` and record daily price history snapshots. ## Files in scope (do not edit anything else) - `lib/card-import/bulk-sync.js` - `test/lib/card-import/bulk-sync.test.js` ## Conventions to follow - Keep existing `mapCard()` mapping: `usd` → `current_price`, `usd_foil` → `market_price`. - Add `prices_updated_at` to INSERT/UPDATE columns (set when either price is non-null). - After each successful `upsertBatch`, call `recordPriceSnapshots` for rows with prices (`source: 'scryfall'`, `priceType: 'market'` for nonfoil amount, optionally second snapshot for foil if present). - Export `mapCard` for unit tests (or test via named export already present). - Preserve Scryfall User-Agent header. ## Acceptance criteria - [ ] `upsertBatch` writes `prices_updated_at` - [ ] Price snapshots recorded per card per sync day - [ ] `mapCard` unit tests cover price parsing - [ ] Existing `runBulkMtgSync` return shape unchanged (add optional `snapshotsWritten` count) - [ ] Tests pass - [ ] No scope expansion ## Rationale (≤3 sentences) MTG already has price data from Scryfall; this brief wires timestamps and history without changing upstream source. Fixes the data pipeline for Phase 1 pricing API reads.