{
 "notes": "Tomasz was explicit: if I can only get to two this week, do #1 (trend shape) and #2 (theft-tag concentration), since those are what he and Tobias will be pressed on. I'm spending all three slots tonight on those two, since each deserves more than a single pass.\n\nFor #1: my existing monthly view (764→946 events/month) shows a fairly flat Jan-Sep and then a clear step up in Oct (865→941, +8.8%) that holds through Nov-Dec. Monthly resolution could be smoothing over or mis-locating the actual inflection point, and it conflates two possible causes: a genuine worsening rate, versus simply more warehouses coming online and doing cycle counts (warehouses_affected already grew 85→111 across the year in my night-1 report). So tonight's trend report uses half-month buckets (fine enough to spot a step, coarse enough to stay well under the row cap) and adds a per-active-location rate alongside raw counts, plus a count of newly-opened warehouses per period, so I can tell scale growth apart from a true rate increase and point to when it started.\n\nFor #2: Tomasz's suspicion is that \"theft-suspected\" being almost exactly the same size as \"damage\" and \"expired\" (1,781/1,755/1,717 events) smells like a dropdown default or habit rather than real incident variety. The sharpest test is whether the tag concentrates in a handful of specific staff or sites rather than being spread proportionally across everyone who logs adjustments. I'm running two cuts — by the staff member who logged the adjustment (adjusted_by_user_id), with a bonus column on what time of day their theft-tagged entries get logged (to catch an end-of-shift batch-logging pattern), and by warehouse/site — since Tomasz asked about both people and sites, and these are two genuinely different grains, not a bundle of the same question.\n\n#3 (why the Dec-31 B2B batch exists) and #4 (apparel concentration by site/shift) are real work but lower priority per Tomasz's note — I'll pick those up on a later night this week.",
 "requests": [
  {
   "title": "Trend of stock-count discrepancies within 2025: steady climb or step change?",
   "question": "Did the 24% year-over-year rise in routine stock-count discrepancies climb steadily, or did it step up at a specific point in the year (and is that step explained by more warehouses coming online, or a genuine per-location worsening)?",
   "grain": "half-month period, 2025 (24 periods: each calendar month split into days 1-15 and 16-end)",
   "columns": [
    "period_label (e.g. '2025-01 (1-15)')",
    "events (count of stock_adjustments rows with created_at in the period)",
    "abs_units_variance (sum of abs(quantity_delta))",
    "net_units_variance (signed sum; negative = net shrinkage)",
    "distinct_locations_active (distinct stock_location_id with >=1 stock_adjustments row in the period)",
    "events_per_active_location (events / distinct_locations_active, rounded 2dp)",
    "new_warehouses_opened_this_period (count of warehouses.created_at falling within the period, across all tenants)"
   ],
   "details": "Source: stock_adjustments, created_at between 2025-01-01 and 2025-12-31 (half-open bound: >= 2025-01-01 and < 2026-01-01), split into 24 half-month periods using day_of_month <= 15 vs > 15 (use calendar_days.day_of_month to derive this, or equivalent date-part logic). Join stock_locations on stock_location_id only to confirm location identity for distinct_locations_active (no warehouse rollup needed here, kept for report 3 below). For new_warehouses_opened_this_period, count warehouses.created_at falling in the same half-month window, independent of the stock_adjustments join — this is a separate count over the same time axis, not a join. Order by period ascending (chronological), which with 24 rows is already a unique, deterministic order.",
   "builds_on": [
    "Monthly volume of stock_adjustments table entries, 2025",
    "Scale of stock count discrepancies by month"
   ]
  },
  {
   "title": "Who logs 'Missing - suspected theft' stock adjustments: concentrated among specific staff?",
   "question": "Is the 'Missing - suspected theft' reason spread roughly proportionally across everyone who logs stock adjustments, or does it concentrate in a handful of specific staff members — and do their theft entries cluster at a particular time of day (suggesting end-of-shift batch logging rather than individually investigated incidents)?",
   "grain": "staff user (adjusted_by_user_id) with at least one stock_adjustments row in 2025",
   "columns": [
    "staff_name (users.full_name; 'Unknown/unassigned' if adjusted_by_user_id is null)",
    "total_adjustments_logged",
    "theft_tagged_count (reason = 'Missing - suspected theft')",
    "pct_theft_of_own_adjustments (theft_tagged_count / total_adjustments_logged * 100, rounded 1dp)",
    "damage_tagged_count (reason = 'Damaged in warehouse')",
    "expired_tagged_count (reason = 'Expired')",
    "cycle_count_variance_count (reason = 'Cycle count variance')",
    "avg_hour_of_day_for_theft_entries (average hour 0-23 extracted from created_at, computed only over this user's theft-tagged rows; null if they have none, rounded 1dp)"
   ],
   "details": "Source: stock_adjustments, created_at between 2025-01-01 and 2025-12-31 (half-open bound). Left join users on adjusted_by_user_id for staff_name. Group by adjusted_by_user_id (treat null as its own 'Unknown/unassigned' group). Order by theft_tagged_count descending, tie-break by total_adjustments_logged descending, then staff_name ascending. Cap at 50 rows (top 50 by theft_tagged_count) and note the total distinct staff count with >=1 adjustment in 2025 even if it exceeds 50.",
   "builds_on": []
  },
  {
   "title": "Where 'Missing - suspected theft' tags concentrate: by warehouse",
   "question": "Does the 'Missing - suspected theft' reason concentrate in a handful of specific warehouses/sites, or is it spread evenly across all sites that log stock adjustments?",
   "grain": "warehouse (one row per warehouse with at least one stock_adjustments row in 2025)",
   "columns": [
    "warehouse_name",
    "tenant_name",
    "total_adjustments_at_site (count of stock_adjustments rows at this warehouse)",
    "theft_tagged_count (reason = 'Missing - suspected theft')",
    "pct_theft_of_site_adjustments (theft_tagged_count / total_adjustments_at_site * 100, rounded 1dp)",
    "distinct_staff_logging_theft_here (count of distinct adjusted_by_user_id among this warehouse's theft-tagged rows)"
   ],
   "details": "Source: stock_adjustments, created_at between 2025-01-01 and 2025-12-31 (half-open bound). Join stock_locations on stock_location_id to get warehouse_id, then warehouses (name) and tenants (name) via warehouses.tenant_id. Group by warehouse. Order by theft_tagged_count descending, tie-break by pct_theft_of_site_adjustments descending, then warehouse_name ascending. Cap at 50 rows and note the total distinct warehouse count even if it exceeds 50.",
   "builds_on": [
    "Where 'Missing - suspected theft' tags concentrate: by warehouse"
   ]
  }
 ]
}