Item record review + push-back
Item record review is the items-side counterpart to assembly_build_review. It's the workhorse Mike uses on the data-cleanup loop — open an item, see its full live state, propose specific field updates, and push the cascade.
The cascade is deliberately wide because items touch a lot: NS fields, spec sheets, pricing_master rows, vendor_costs, assembly memberships, open bid lines, recent transactions. Changes ripple to all of them; the workflow makes the ripple deterministic.
Risk level 3 (medium). Contract at workflow_definitions WHERE workflow_type='item_record_review'.
Trigger conditions
- Mike opens
/item/<code>and notices a stale or wrong field. - Data-quality watchdog fires
data_quality.item_flaggedafter detecting drift. - Vendor response contains a corrected spec (pack size, allergens, etc).
- Customer complaint cites a label discrepancy that traces to an item field.
- Spec audit finds a kosher cert that's missing or expired.
The not_in_active_bid precondition warns (not blocks) — items in open bid lines can still be updated, but the workflow drafts a notification to the bid owner so the customer hears about the change first. That's the standing rule: never let a customer find a spec change in the bid PDF before we tell them.
The 7 beats
-
01
Stage NS field update
A
proposed_actionsrow stages withaction_type=item_field_update, entity_ref=item_code, fields frominputs.proposed_changes. Allowed fields are whitelisted (displayname, salesdescription, custitem_brand, etc) — anything else is rejected at precondition. -
02
Invalidate item cache
Keys
item:{item_code},item_full:{item_code},ns:item:{item_code}are deleted so the live /item/<code> render is fresh. -
03
Invalidate pricing cache (pattern)
Pattern delete on
pricing:{item_code}:*via KV list scan. Busts every customer-pricing cache keyed off this item. -
04
Regenerate spec sheet (conditional)
If proposed_changes touched spec-relevant fields (claims, pack_size, allergens), the spec sheet PDF regenerates via the
regenerate_spec_sheetchat tool. -
05
Recompute assembly cost rollups
For each assembly that has this item in its BOM,
assembly_cost_rolluprecomputes. Keeps margin math current across the assembly catalog. -
06
Flag dependent pricing for review
If item-level changes could affect customer pricing (pack_size ripples to case_price), pricing_master rows touching this item flag for the next pricing review cycle.
-
07
Notify sales if active bid (conditional)
If
open_bid_linesis non-empty, a notification email per bid owner drafts inoutbound_email_logwith status=pending_review.
What's different after the workflow runs
- NS item record reflects the new field values within the NS push drain window.
- Item caches (3 keys) and pricing pattern caches are busted.
- Spec sheet PDF is regenerated if user-facing fields changed.
- Assembly cost rollups are current.
- Bid owners have a notification email waiting if the item is in their open bid.
- reflexion_log carries an
item_review,data_cleanuptagged row.
What can go wrong and how to recover
Precondition item_exists blocks. Mike checks the item_code (case-insensitive lookup) and either fixes the code or runs new_assembly_item if it's genuinely new.
Precondition item_active warns. Mike can still proceed — sometimes reactivating an item is part of the cleanup.
Precondition rejects with severity=block. Adding a new allowed field requires updating the contract's precondition list (and ideally an ADR).
Retry policy is 2 attempts with [300s, 1800s] backoff. Drainer cron picks up persistent failures within 30 minutes.
Adjacent workflows + diagrams
Code paths + invariants
| Concern | Where |
|---|---|
| Workflow contract | workflow_definitions WHERE workflow_type='item_record_review' |
| Allowed field list | precondition: displayname, salesdescription, custitem_brand, custitem_pack_size, custitem_case_count, custitem_buyamerican, custitem_kosher, custitem_allergens, custitem_country_of_origin, custitem_storage_temp, reorderpoint, taxschedule |
| Data-quality trigger | data_quality.item_flagged event |
| Spec regen tool | regenerate_spec_sheet |
| Reflexion tag | item_review,data_cleanup |
| Risk level | 3 |
| Expected duration | ~variable (data-driven) |
| Trigger | manual_or_event · event_type_glob=data_quality.item_flagged |