fix(inventory): make prefix search deterministic and refuse ambiguous matches #119

Merged
yuris merged 1 commit from fix/81-find-inventory-prefix-ambiguity into main 2026-09-28 20:50:09 +00:00
Owner

Resolves #81

Summary

  • Update findInventoryByPrefix to check for exact name match first via findInventoryByName.
  • Order prefix queries deterministically with .orderBy(asc(schema.inventory.itemName), asc(schema.inventory.id)).
  • Fetch up to 2 rows and refuse silent resolution when multiple rows match prefix (returns undefined) so callers do not guess or overwrite wrong inventory rows.
  • Add comprehensive tests in queries.test.ts covering exact match precedence, deterministic single match resolution, ambiguous match refusal, and edge cases.

Verification

  • direnv exec . pnpm verify:management passes (test: 441/441 passed across 20 files, lint: exit 0, typecheck: exit 0).
Resolves #81 ### Summary - Update `findInventoryByPrefix` to check for exact name match first via `findInventoryByName`. - Order prefix queries deterministically with `.orderBy(asc(schema.inventory.itemName), asc(schema.inventory.id))`. - Fetch up to 2 rows and refuse silent resolution when multiple rows match prefix (returns `undefined`) so callers do not guess or overwrite wrong inventory rows. - Add comprehensive tests in `queries.test.ts` covering exact match precedence, deterministic single match resolution, ambiguous match refusal, and edge cases. ### Verification - `direnv exec . pnpm verify:management` passes (test: 441/441 passed across 20 files, lint: exit 0, typecheck: exit 0).
fix(inventory): make prefix search deterministic and refuse ambiguous matches (#81)
All checks were successful
Checks / test garage (pull_request) Successful in 1m22s
Checks / typecheck apps/management (pull_request) Successful in 1m35s
Checks / lint (biome) (pull_request) Successful in 12s
Checks / test @garage/catalog (pull_request) Successful in 1m15s
Checks / test garage-store (pull_request) Successful in 1m18s
Checks / typecheck apps/store (pull_request) Successful in 1m20s
f040f6deae
yuris left a comment

VERDICT: approve

  • Prefers exact name match before prefix matching.
  • Adds deterministic orderBy(asc(schema.inventory.itemName), asc(schema.inventory.id)).
  • Queries limit(2) and returns undefined on ambiguous multiple matches, preventing silent poisoning of item prices.
  • Unit tests in queries.test.ts verify all branches.
VERDICT: approve - Prefers exact name match before prefix matching. - Adds deterministic `orderBy(asc(schema.inventory.itemName), asc(schema.inventory.id))`. - Queries `limit(2)` and returns `undefined` on ambiguous multiple matches, preventing silent poisoning of item prices. - Unit tests in `queries.test.ts` verify all branches.
yuris merged commit 9171e43bb3 into main 2026-09-28 20:50:09 +00:00
yuris changed title from fix(inventory): make prefix search deterministic and refuse ambiguous matches (#81) to fix(inventory): make prefix search deterministic and refuse ambiguous matches 2026-09-28 21:09:17 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
yuris/garage!119
No description provided.