codebaobab
Python workspace

All problemsData & Systems

Catalog Cache Review

Review an AI-written pull request that caches product lookups and prices and fix its blocking problems.

Python45 minutesData & Systems

Challenge brief

Read before you begin

Your mission · AI code review

Review a pull request that caches product lookups and prices, and fix its blocking findings.

Halyard Home's Black Friday sale starts at midnight, and product pages are slow at peak. Pull request 318 adds a cache that makes them ten times faster. On staging, though, a UK page showed a dollar price, and a marked-down sofa kept its old price. Checkout charges what the page showed.

  • Mode · code review
  • Diff · PR-318
Skip to round setup

Your assignment

  1. Read pull request 318 against the catalog contract.
  2. Find the steps that prove each finding.
  3. Rank findings in NOTES.md: blocking, should fix, nit.
  4. Fix the blocking findings, one at a time.
  5. Handle the new requirement when it arrives.

The problem

Wrong currency on UK pages

On staging, a UK shopper opened the sofa right after a US shopper and saw 1,499.00 in dollars.

Impact: Shoppers in Canada and the UK see another region's price.

Old prices after a markdown

Merchandising cut the sofa to 999.00 in the UK, and the page kept showing 1,199.00 for minutes.

Impact: Checkout charges a price the shopper did not agree to.

Memory with no ceiling

The cache keeps every entry it ever stored until the worker restarts.

Impact: A day of traffic grows the worker past its memory limit.

Context

Store reads a second at peak
2,100
SKUs in three regions
38,000
Black Friday sale starts
Nov 27

Requirements

  • Each region sees its own price and currency.
  • A price change shows on the next view.
  • Other regions keep their cached price.
  • One store read per product and per price.
  • Entries expire after 300 seconds.
  • Unknown SKUs are not cached.
  • Keep the cache: reads checks must pass.

System overview

Edit the components marked “Your work”. The other components show where your changes fit.

StorefrontShows product pages
Merchandising adminChanges prices
Catalog serviceBuilds product pages
Catalog cache (PR 318)(Your work)Caches products and prices
Product storeHolds names and prices
CheckoutCharges the shown price
Read the connections
  • Storefront → Catalog service: page request
  • Catalog service → Catalog cache (PR 318): product, price
  • Catalog cache (PR 318) → Product store: misses
  • Merchandising admin → Catalog service: price change
  • Storefront → Checkout: shown price
  • Storefront: Product pages, search results and the cart in three regions.
  • Merchandising admin: Merchandisers change one region's price at a time.
  • Catalog service: handle(request) in catalog/app.py; Catalog in catalog/services/catalog.py.
  • Catalog cache (PR 318): CatalogCache in catalog/services/cache.py: products by SKU, prices by SKU and region.
  • Product store: Names and per-region prices. Counts every read.
  • Checkout: Charges the price the product page showed.

Details

Full requirements

Functional

  1. A product page shows the name and the price and currency of the shopper's region: USD in the US, CAD in Canada, GBP in the UK. Prices are set per region, never converted.
  2. A price change made in the admin tool shows on the very next view of that SKU and region, because checkout charges the price the page showed. It does not change what other regions see.
  3. The cache saves store reads: one product read per SKU and one price read per SKU and region, each used for at most 300 seconds. A price change removes only the cached price it replaces.
  4. A miss for an unknown SKU is not cached, because new products go live during the day.
  5. The review: findings ranked as blocking, should fix or nit, each with a step list that proves it, and the blocking ones fixed.

Non-functional

  • Load: about 2,100 store reads a second at peak before the cache, and 2.5 times that expected on Black Friday. With the cache on staging, reads fell by 96 percent.
  • Latency: p99 page time is 410 ms today and 38 ms with the cache. The target for the sale is under 100 ms.
  • Memory: each of the 24 catalog workers has a 2 GB limit. 38,000 SKUs in three regions is about 152,000 entries if nothing is ever evicted.
  • Correctness over speed: a page that shows a price checkout will not honor is a refund and a complaint; a cache miss costs one store read.

Out of scope

  • Keeping the 24 workers' caches in step with each other: a price change event bus is planned for January.
  • Search results and the cart, which call the catalog the same way and get the fix for free.
  • Tax, shipping and currency conversion: prices are set per region by merchandising.
Data model

Product

FieldTypeNotes
skustringUnique, such as LAMP-01.
namestringThe same in every region.
prices{us, ca, uk}Whole cents (pence in the UK), above 0.

Product page

FieldTypeNotes
sku, name, regionstringWhat the shopper asked for.
amountintThe region's price in whole cents.
currencystringUSD, CAD or GBP, from the region.

Cache entry

FieldTypeNotes
keySKU, or SKU and regionProducts by SKU; prices by SKU and region.
stored_atintClock seconds when it was read from the store.
valuedictWhat the store returned, copied on the way out.
Files you are given · 4
  • samples/request-sofa-markdown.json A US and a UK shopper open the sofa, merchandising marks the UK price down, and both look again, then once more after 300 seconds. Ready to pass to handle.
    {
      "op": "run",
      "products": [
        {
          "sku": "LAMP-01",
          "name": "Arc floor lamp",
          "prices": {
            "us": 12900,
            "ca": 17500,
            "uk": 9900
          }
        },
        {
          "sku": "SOFA-02",
          "name": "Linen three-seat sofa",
          "prices": {
            "us": 149900,
            "ca": 199900,
            "uk": 119900
          }
        },
        {
          "sku": "RUG-07",
          "name": "Wool flatweave rug",
          "prices": {
            "us": 34900,
            "ca": 45900,
            "uk": 27900
          }
        }
      ],
      "steps": [
        {
          "op": "view",
          "sku": "SOFA-02",
          "region": "us"
        },
        {
          "op": "view",
          "sku": "SOFA-02",
          "region": "uk"
        },
        {
          "op": "set_price",
          "sku": "SOFA-02",
          "region": "uk",
          "amount": 99900
        },
        {
          "op": "view",
          "sku": "SOFA-02",
          "region": "uk"
        },
        {
          "op": "view",
          "sku": "SOFA-02",
          "region": "us"
        },
        {
          "op": "wait",
          "seconds": 300
        },
        {
          "op": "view",
          "sku": "SOFA-02",
          "region": "uk"
        }
      ]
    }
  • samples/results-sofa-markdown-expected.json The results the contract requires for that request.
    {
      "results": [
        {
          "sku": "SOFA-02",
          "name": "Linen three-seat sofa",
          "region": "us",
          "amount": 149900,
          "currency": "USD"
        },
        {
          "sku": "SOFA-02",
          "name": "Linen three-seat sofa",
          "region": "uk",
          "amount": 119900,
          "currency": "GBP"
        },
        {
          "sku": "SOFA-02",
          "region": "uk",
          "amount": 99900
        },
        {
          "sku": "SOFA-02",
          "name": "Linen three-seat sofa",
          "region": "uk",
          "amount": 99900,
          "currency": "GBP"
        },
        {
          "sku": "SOFA-02",
          "name": "Linen three-seat sofa",
          "region": "us",
          "amount": 149900,
          "currency": "USD"
        },
        {
          "now": 300
        },
        {
          "sku": "SOFA-02",
          "name": "Linen three-seat sofa",
          "region": "uk",
          "amount": 99900,
          "currency": "GBP"
        }
      ]
    }
  • samples/reads-sofa-markdown.json The same steps as a reads request, with the store reads the contract allows: two product reads and four price reads.
    {
      "request": {
        "op": "reads",
        "products": [
          {
            "sku": "LAMP-01",
            "name": "Arc floor lamp",
            "prices": {
              "us": 12900,
              "ca": 17500,
              "uk": 9900
            }
          },
          {
            "sku": "SOFA-02",
            "name": "Linen three-seat sofa",
            "prices": {
              "us": 149900,
              "ca": 199900,
              "uk": 119900
            }
          },
          {
            "sku": "RUG-07",
            "name": "Wool flatweave rug",
            "prices": {
              "us": 34900,
              "ca": 45900,
              "uk": 27900
            }
          }
        ],
        "steps": [
          {
            "op": "view",
            "sku": "SOFA-02",
            "region": "us"
          },
          {
            "op": "view",
            "sku": "SOFA-02",
            "region": "uk"
          },
          {
            "op": "set_price",
            "sku": "SOFA-02",
            "region": "uk",
            "amount": 99900
          },
          {
            "op": "view",
            "sku": "SOFA-02",
            "region": "uk"
          },
          {
            "op": "view",
            "sku": "SOFA-02",
            "region": "us"
          },
          {
            "op": "wait",
            "seconds": 300
          },
          {
            "op": "view",
            "sku": "SOFA-02",
            "region": "uk"
          }
        ]
      },
      "expected": {
        "reads": {
          "product": 2,
          "price": 4
        }
      }
    }
  • logs/catalog-staging-2026-11-25.log What pull request 318 did on staging: a UK page in dollars from a cache hit, a markdown hidden for four minutes, and the worker's memory at the end of the day.
    {"ts": "2026-11-25T16:02:11.204Z", "worker": "catalog-7", "event": "page", "sku": "SOFA-02", "region": "us", "amount": 149900, "currency": "USD", "cache": "miss"}
    {"ts": "2026-11-25T16:02:13.871Z", "worker": "catalog-7", "event": "page", "sku": "SOFA-02", "region": "uk", "amount": 149900, "currency": "USD", "cache": "hit"}
    {"ts": "2026-11-25T16:04:40.019Z", "worker": "catalog-7", "event": "price_change", "sku": "LAMP-01", "region": "uk", "amount": 7900, "by": "merch-ana"}
    {"ts": "2026-11-25T16:05:02.553Z", "worker": "catalog-7", "event": "page", "sku": "LAMP-01", "region": "uk", "amount": 9900, "currency": "GBP", "cache": "hit"}
    {"ts": "2026-11-25T16:09:12.300Z", "worker": "catalog-7", "event": "page", "sku": "LAMP-01", "region": "uk", "amount": 7900, "currency": "GBP", "cache": "miss"}
    {"ts": "2026-11-25T23:58:00.000Z", "worker": "catalog-7", "event": "memory", "rss_mb": 1912, "cache_entries": 151870}
Tickets · 3
  • TASK-201 Read pull request 318 against the catalog contract Reported by Nadia (Storefront lead)

    Expected The UK views show GBP, and the view after the markdown shows 99900.

    Actual The first UK view shows 149900 USD, and the view after the markdown still shows 149900 USD.

  • TASK-202 Rank the findings, each with steps that prove it Reported by Nadia (Storefront lead)

    Expected Every blocking finding has steps that show it, and the things that look wrong but are fine are listed with a reason.

    Actual NOTES.md is empty. The pull request description says a five-minute delay is fast enough.

  • TASK-203 Fix the blocking findings and keep the cache Reported by Jonah (Storefront)

    Expected Every public check passes and samples/reads-sofa-markdown.json still reads the store six times in all.

    Actual 7 of the 22 public checks fail, including "Each region sees its own price" and "A price change shows on the next view".

What you hand in
  • NOTES.md: your findings ranked (blocking, should fix, nit), each with the steps that prove it, what looks wrong but is fine, and your verdict on the merge.
  • The blocking fixes in catalog/services, with every public check passing and the cache still saving reads, including the new requirement when it arrives.
  • Your answer to the interviewer's follow-up and the debrief questions.
How the work is judged
Breaking down the work
Matches each caching rule in the contract to the line of the diff that keeps it before ranking or fixing anything.
Directing the assistant
Gives the assistant a short step list and asks for the cache keys and the page each view returns, instead of asking whether the cache is correct.
Checking the work
Proves each finding with steps or a failing check, before and after the fix, and keeps the reads checks passing.
Judging the assistant
Ranks the region leak and the stale price as blocking and the unbounded cache and names below them. Rejects a shorter TTL and a full flush on every write; keeps int cents and the copy.
Correct result
Every check passes: each region sees its own price, a price change shows on the next view, and reads stay at one per key.
Explaining the work
Findings a teammate can act on: ranked, each with its steps, what the shopper sees and the fix, and a clear merge verdict.
Trade-offs to discuss
  • Removing one entry on a price change versus writing the new price into the cache: which is safer when the store applies its own rules to a write?
  • With 24 workers each holding a cache, how a price change reaches all of them, and what the shopper sees until it does.
  • Blocking a pull request that makes pages ten times faster the night before the sale, versus shipping it with a known wrong-price bug.
How you are graded
  • Decomposition 5%
  • Prompting the assistant 5%
  • Verification 20%
  • Judgment about AI output 30%
  • Correctness 15%
  • Communication 25%

Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard

Interview guidance

A teammate used an assistant to add a cache to the product catalog, and wants to merge before the sale goes live at midnight. Review pull request 318. Rank your findings in NOTES.md, tell me which ones block the merge and why, and fix those. Use the AI assistant however you like, but the review is yours. Before you change any code, tell me your most severe finding and the steps that show it.

  • AI is allowed and expected: your own Claude, OpenAI or Gemini key, or the free in-browser model.
  • You are graded on how you drive and check the AI, not on how much you prompt.
  • Run the checks; read what fails.
  • A new requirement will arrive partway through.
  • Too little AI use is reported as “not enough to grade”, never as a fail.
Debrief · 7 questions
  • What did you delegate to the AI, and why?
  • Name one AI suggestion you rejected or changed, and why.
  • Choose one block the AI helped write. Explain what each line does and which test verifies it.
  • What is still risky, and what would you test or ship next?
  • What was your most severe finding, and what steps convinced you it was real?
  • Name one thing the assistant flagged that you decided was not a problem. How did you check?
  • The pull request's own tests all passed. What kind of test was missing, and how would you ask a teammate to add it?