Nobody has started this yet — be first.
Business impact
Reconcile can detect drift between the materialized sku_inventory row and what the ledger says is true, but there is no way to fix it short of hand-writing SQL during an incident -- exactly the kind of manual, error-prone, hard-to-audit intervention this project's append-only ledger design is supposed to make unnecessary.
Problem
inventory.Repair does not exist yet; there is no automated way to correct drift Reconcile reports.
Current behavior
Calling inventory.Repair currently panics with "TODO(ticket-23): Repair not implemented".
Expected behavior
Repair(ctx, pool, skuID) (Drift, error) recomputes the correct values for a SKU (the same computation Reconcile already does) and writes them back to sku_inventory, so a subsequent Reconcile call reports in_sync: true. It returns the drift it found (and fixed).
Steps to reproduce
go test ./tickets/tests/... -run TestTicket23 -vWhy this matters
The repair must be safe against a concurrent Reserve/Commit/Release happening at the same time -- locking the row for the duration of the read-recompute-write, the same way every other write to sku_inventory in this codebase already does, so a repair can't race a legitimate concurrent claim and either overwrite it or itself get overwritten by a stale write.
Suggested approach
Compare Reconcile's own two-part structure (read the materialized row, sum the ledger) against what Repair needs to do differently: instead of just comparing and returning, Repair needs to SELECT ... FOR UPDATE the row first (so nothing else can write to it mid-repair), do the same ledger-sum computation, and UPDATE sku_inventory to match before releasing the lock.
Acceptance criteria
Verification
TEST_DATABASE_URL=postgresql://... go test ./tickets/tests/... -run TestTicket23 -v
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
Sign in to create it automatically, or do it yourself:
$git checkout -b feat/reconcile-repairFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin feat/reconcile-repairSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign inSKIP LOCKEDhttp://localhost:8081localhost:5434flash-saleeveryday-widgetcurl localhost:8081/healthzgo run ./cmd/loadtest -url http://localhost:8081 -sku flash-sale -concurrency 10000Work the tickets in tickets/docs/ (ordered easy → hard); each names one dedicated Go test in tickets/tests/:
export TEST_DATABASE_URL=postgresql://inventory:inventory@localhost:5432/inventory_test?sslmode=disable
go test ./tickets/tests/... -run TestTicket24 -v # a single ticket
./tickets/run_tickets.sh # all 25, clean pass/fail summary
Tickets that don't touch Postgres (02, 07, 17, 19) run fine without TEST_DATABASE_URL; the rest t.Skip cleanly, not fail, if it's unset.
Level 2
Implement a feature
Extend the system within its own patterns.