← Back to Pull requests

feat(food-prices): add PriceCatcher basket-survey staples with per-item dates #10927

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 17, 2026 14:47 UTC
Author

Summary

Follow-up to #10922, which is merged. This adds the food-security staples #10922 left out: packaged rice, cooking oil, sugar, flour and meat, plus coconut and fruit. KPDN quotes these 19 items only on irregular basket-survey days: 2, 5 and 16 November in the publisher's 2026-11 file, with 9 November skipped around the holiday. Each item therefore reports its latest survey day, compared with its most recent survey at least seven days earlier.

Items. Each item's exact lookup name and unit are pinned and validated, as in #10922. Every item has at least 81 premises on each of the three November survey days.

  • Imported rice, 10 kg (3): Faiza Emas, Jasmine Super 5, Rambutan 5%

  • Cooking oil (3): the subsidised 1 kg packet, Seri Murni 5 kg, Buruh 1 kg

  • White sugar, coarse and fine (2)

  • Wheat flour (2)

  • Coconut, whole and grated (2)

  • Buffalo meat from India, topside and block (2), and local beef thigh (1)

  • Banana, papaya, pineapple and seedless watermelon (4)
  • Adapter (pricecatcher.mjs)

  • Every item is tagged daily or basket. The 39 daily staples keep #10922's rule unchanged: the latest completed day on which every one reported, compared with exactly seven days earlier.

  • Survey days are detected from the total basket quotes per day. A day counts as a survey day if it has at least 1,000 basket quotes and at least half as many as the busiest basket day in the window.

  • Off-survey days still carry stray quotes, up to about 50 premises per item, which pass the 10-premise floor. The survey-day rule never promotes them, and a window holding only strays produces no basket rows.

  • refreshedReports are now scoped by {date, item}. A basket survey on a daily item's baseline day therefore can't erase that day's daily rows in history, and the reverse holds too.

  • Output units are now kg, 30 pieces, 10 kg, 5 kg and piece.
  • API (food-prices.ts). A new opt-in registry flag, latestPerSeries, is set only for pricecatcher. With the flag on, each series shows its own latest observation, compared with that series' most recent observation on or before seven days earlier. Every other source keeps one shared latest date and the exact seven-day rule; a test asserts both paths.

    Card. A row whose date differs from the source report date now shows Report date: <date>. This reuses the existing label, so no locale files change. The source attribution, in both registry copies, explains the two cadences.

    Type of change

  • New feature

  • New data source / feed (widened existing source)
  • Affected areas

  • API endpoints (/api/*): GetFoodPrices returns a date per series for PriceCatcher only

  • Other: food prices card, Railway food-price seeder (seed-food-prices-pricecatcher)
  • Checklist

  • Tested on worldmonitor.app variant: not deployed; local dev server only

  • No API keys or secrets committed

  • TypeScript compiles without errors (npm run typecheck)

  • New or repointed health probes: N/A
  • Verification

    All checks below were run locally. The test suite and typecheck were rerun on head bcc88f9dd, after rebasing onto main with #10922 merged.

    Live publisher file (2026-11, fetched 2026-11-17):

  • Survey days are detected as exactly 2, 5 and 16 November.

  • All 58 items report: 39 daily items for 11-16 against 11-09, and 19 basket items for 11-16 against 11-05.

  • Sample prices: subsidised packet oil RM 2.50/kg, coarse white sugar RM 2.85/kg, Faiza Emas rice RM 32.50 per 10 kg.
  • Tests

  • Basket survey detection against a synthetic copy of the real pattern: surveys on 11-02, 11-05 and 11-16, with strays on 11-09 and 11-17. It also covers a window holding only strays, and a latest survey with no survey at least a week earlier.

  • Updated fixture and collect tests: 58 items, with history refreshed per item and date.

  • A handler test for the per-series path and the exact-week path.

  • A DOM test for row dates.
  • Checks

  • npm run test:related: 533/533.

  • Food-prices DOM tests: 12/12.

  • npm run typecheck, npm run typecheck:api, npm run lint:boundaries, e2e tsc and git diff --check all pass.
  • Unverified

  • The e2e/food-prices.spec.ts assertions: 58 rows, 39 against 11-09 and 19 against 11-05. As noted in #10922, that spec already fails on main before it reaches this table. I checked the same assertions with a manual drive instead.

  • A seeder run against Redis, including how existing history merges with the new item-scoped refreshes. mergeHistory already supports {date, item}.

  • The card's general method note still says "exactly seven days earlier". For basket rows, the "vs <date>" next to each row and the source attribution give the actual comparison date.
  • Documentation Alignment Checklist

    N/A. Only the source attribution text changes.

    Screenshots

    These come from a manual drive with the verify-worldmonitor harness. I added the panel through the command palette, and get-food-prices returned a controlled response.

    To show the mixed-date state the new row date exists for, I built that response with "now" set to 2026-11-18:

  • Daily staples report 11-17, compared with 11-10.

  • Basket items keep their 11-16 survey, compared with 11-05.

  • The 19 basket rows show "Report date: 2026-11-16".

  • The 11-17 data comes from a file captured mid-day on 11-17, so treat it as test data, not a complete publisher day.
  • Results:

  • 1440 px: 58 rows and no horizontal page overflow. The panel's scrollWidth exceeds its clientWidth by 5 px, the same as on main.

  • 390 px: 58 rows; neither the panel nor the page overflows. This view was reached by resizing after adding the panel at desktop width.
  • The screenshots were captured locally but not uploaded: this session has no gh CLI for gh pr edit --attach, so the upload is still pending.

    Bundle budget provenance

    N/A

    ---
    _Generated by Claude Code_

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: chatgpt-codex-connector[bot] Review duration: 5m
    All Vouch review confidence checks passed
    Residual risk 0.39 = Change Risk (0.52) × (1 − Review Confidence (0.25)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 32% · Reviewer familiarity: 35%
    25%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #10927"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 25.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 25.2% · Lower = rushed or shallow review
    25.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 38.9% · Moderate risk
    38.9%