# Tasks: Inventory Core (040) **Input**: `specs/040-inventory-core/spec.md`, `specs/040-inventory-core/plan.md` ## P1 — MVP (US1/US2) - [ ] T001 [US1] Define Inventory Item data model (tenant-scoped identity + last_seen fields) - [ ] T002 [US1] Define Sync Run data model (tenant_id, selection_hash, status, timestamps, counts, stable error codes) - [ ] T003 [US1] Implement deterministic selection hashing (canonical json + sha256) - [ ] T004 [US1] Implement inventory upsert semantics (no duplicates) - [ ] T005 [US1] Enforce tenant isolation in all inventory/run queries - [ ] T006 [US2] Implement derived “missing” computation relative to latest completed run (tenant_id + selection_hash) - [ ] T007 [US2] Ensure low-confidence missing when latestRun is partial/failed or had_errors - [ ] T008 [US2] Implement meta_jsonb whitelist enforcement (drop unknown keys, never fail sync) ## P2 — Observability & Safety (US3 + NFR) - [ ] T009 [US3] Ensure run records include stable error codes and counts - [ ] T010 [NFR] Add idempotency + locks to prevent overlapping runs per tenant+selection - [ ] T011 [NFR] Add global + per-tenant concurrency limiting strategy - [ ] T012 [NFR] Implement throttling handling strategy (backoff + jitter for transient Graph failures) ## Tests (Required for runtime behavior) - [ ] T020 [US1] Tests: upsert does not create duplicates; last_seen updated - [ ] T021 [US2] Tests: missing derived per latestRun(selection_hash); selection isolation - [ ] T022 [US2] Tests: partial/failed run => low confidence missing - [ ] T023 [US2] Tests: meta whitelist drops unknown keys without failing - [ ] T024 [NFR] Tests: selection_hash determinism (array ordering) ## Notes - “deleted” is reserved and MUST NOT be produced in this feature.