New assembly item (spec → BOM → NS)
New assembly item creation is the longest cascade on the platform. A new product introduces fifteen-plus downstream effects: catalog rows, BOM rollup, NS records, a PDF spec sheet, pricing pipeline registration, brand routing, bid eligibility, customer programs that should price it, and notifications to customers within the shared brand line.
Each step has a precondition or conditional. The workflow gate (Mike's approval) sits after spec parsing and BOM definition but before any write — once approved, the cascade is deterministic.
Risk level 4 (high). A bad spec going live could ripple into bids, quotes, and customer-facing pages. The 4-stage HITL gates (allergen validation, BOM completeness, spec sheet review, customer notification) exist precisely for that reason.
Trigger conditions
- A new product spec sheet is uploaded via /intake.html.
- An intake form is filled out by sales for a custom-formulated assembly.
- A brand line expansion (e.g. new Melt Mates SKU) is in the pipeline.
- A USDA commodity program adds a new item.
- A customer-specific co-pack lands and needs a SKU.
The precondition bom_complete_if_assembly blocks on an empty BOM for any assembly item. This catches the most common new-item mistake: shipping the spec without the BOM and discovering the cost basis is missing only after the first invoice.
The 8 beats
-
01
Write spec_items + spec_versions
INSERT into
spec_items(the live spec) andspec_versions(the audit trail, withchanged_field=created, new_value=full_json). -
02
Write items shell
INSERT into
itemswith the basic shell (itemid, isinactive=F). NS will populate the rest after push. Parallel with write_spec_items. -
03
Recompute assembly cost rollup (conditional)
If
is_assembly, callrecompute_assembly_cost_rollupto compute raw + packaging + labor + overhead + freight from the BOM components. -
04
NS item record
Enqueue a NS push to create the item record via
customscript_gfs_platform_queryRESTlet. The NS record is the system of record; this push is load-bearing. -
05
NS BOM record (conditional)
If
is_assembly, enqueue a NS BOM push with the components and quantities. -
06
Generate spec sheet PDF
POST
/api/spec/generaterenders the spec sheet template via Browser Rendering and stores atspecs/{item_code}.pdfin R2. -
07
Pricing pipeline registration
INSERT into
pricing_masterfor every customer program that should price this new item. Source-tagged so downstream knows it came from new-item creation. -
08
Customer notification (conditional)
If
shared_brand_customersis non-empty, draft a notification email per customer in the shared brand. Mike approves before send.
What's different after the workflow runs
- A new spec_items row + spec_versions audit row exist.
- A new items shell row exists with NS push enqueued.
- NS has the item record (and BOM if assembly).
- Spec sheet PDF is in R2.
- pricing_master has eligibility rows for matching customer programs.
- Shared-brand customers have a draft notification waiting.
- reflexion_log carries a
new_spec,brand:?,category:?tagged row. - Knowledge corpus is queued for reindex.
What can go wrong and how to recover
Precondition item_code_unique blocks via UPC + existing-spec check. Mike either picks a new code or runs item_record_review to update the existing item.
Precondition bom_complete_if_assembly blocks. Mike fills the BOM in the intake form and re-stages.
Precondition warns (not blocks). Mike confirms and proceeds, or fills allergens before approval. Often happens for ingredient items where allergens are sourced from the vendor spec.
Retry policy is 2 linear-backoff attempts. Persistent failures alert Mike; D1 holds the proposed state and manual POST /admin/ns-push/retry?action_id=<id> recovers.
Adjacent workflows + diagrams
Code paths + invariants
| Concern | Where |
|---|---|
| Workflow contract | workflow_definitions WHERE workflow_type='new_assembly_item' |
| HITL gates | spec intake, BOM completeness, spec review, customer notify |
| NS RESTlet | customscript_gfs_platform_query |
| Spec generator endpoint | /api/spec/generate |
| Knowledge reindex | queue: catalog/reindex |
| Reflexion tag | new_spec,brand:<brand>,category:<cat> |
| Risk level | 4 |
| Expected duration | ~60 min |
| Trigger | manual · sources=spec_sheet_upload, intake_form |