Vendor email or manual entry indicates a cost change. Cascade: vendor_costs row, recompute assembly_cost_rollup, flag open quotes, NS vendor cost update, flag dependent specs needing review.
event["vendor_email","manual_entry","scheduled_review"]| name | required | type / hint |
|---|---|---|
vendor_id | required | — |
sku | required | — |
new_unit_cost | required | — |
effective_from | required | — |
source | required | — |
notes | optional | — |
current_vendor_costvendor_costs · vendor_itemsSELECT unit_cost, effective_from FROM vendor_costs WHERE vendor_item_id=(SELECT id FROM vendor_items WHERE vendor_name=? AND vendor_item_code=?) ORDER BY effective_from DESC LIMIT 1
impacted_pricingpricing_masterSELECT COUNT(*) AS n FROM pricing_master WHERE item_code=? AND cost_basis IS NOT NULL
impacted_assembliesspec_items · bom_components · itemsSELECT COUNT(DISTINCT s.id) AS n FROM spec_items s WHERE s.item_code=? OR EXISTS (SELECT 1 FROM bom_components c JOIN items i ON i.id=c.item WHERE i.itemid=?)
impacted_quotesquotes · quote_linesSELECT
COUNT(DISTINCT q.id) AS n
FROM quotes q
JOIN quote_lines ql ON ql.quote_id=q.id
WHERE ql.item_code=?
AND q.lifecycle_status IN ('draft','proposed','sent')| check | rule | severity |
|---|---|---|
positive_cost | new_unit_cost > 0 | block |
reasonable_change | abs((new_unit_cost - current_unit_cost) / current_unit_cost) <= 0.5 | warn |
effective_not_future_beyond_30d | effective_from <= now + 30 days | warn |
Risk level 3 ≥ 3 — runner stages a proposed_actions row before fan-out runs. Mike must approve in proposed-actions.html before any side-effect step executes (real or stub).
workflow_vendor_cost_update (proposal envelope)workflow:vendor_cost_update:run_<run_id>write_d1 d1_write STUB["INSERT INTO vendor_costs (vendor_item_id, unit_cost, effective_from, source, status) VALUES (?,?,?,?,'active')"]src/lib/workflow_runner.ts (kind d1_write hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.recompute_assemblies chat_tool STUBrecompute_assembly_cost_rollupwrite_d1src/lib/workflow_runner.ts (kind chat_tool hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.flag_pricing_recheck stage_proposed_action REALmargin_recheck_requestflag_open_quotes stage_proposed_action REALflag_stale_quoteimpacted_quotes.n > 0ns_push ns_push STUBvendorNS_PUSH_QUEUEretry_3_then_alertsrc/lib/workflow_runner.ts (kind ns_push hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.notify_vendor_owner hitl_email_draft STUBpropose_email_to_customerpct_change > 5src/lib/workflow_runner.ts (kind hitl_email_draft hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.| id | action | source |
|---|---|---|
runner_log_run | INSERT into workflow_run_log (run_id, workflow_type, status, started_at, completed_at, summary_json) | runner automatic |
runner_reflexion | INSERT into reflexion_log (tags=vendor_cost_update, run_id, narrative) | runner automatic (reflexion_enabled=1) |
log_run | INSERT workflow_runs | declared in contract |
reflexion | INSERT reflexion_log with tags=vendor_cost_change | declared in contract |
workflow_verify_results (pending — verify cron not yet wired)vendor_cost_recordedSELECT unit_cost FROM vendor_costs WHERE effective_from = ? ORDER BY id DESC LIMIT 1
assembly_rollup_refreshedSELECT MAX(computed_at) FROM assembly_cost_rollup WHERE status='active'
3exponential100030000true| system | table / resource | action | status | source |
|---|---|---|---|---|
| D1 | proposed_actions | INSERT (action_type=margin_recheck_request, entity_type=workflow_run) | REAL | fan-out #3 (flag_pricing_recheck) |
| D1 | proposed_actions | INSERT (action_type=flag_stale_quote, entity_type=workflow_run) | REAL | fan-out #4 (flag_open_quotes) |
| D1 | workflow_run_log | INSERT (run summary) | REAL | runner automatic |
| D1 | reflexion_log | INSERT (tags=vendor_cost_update) | REAL | runner automatic |
| Event | workflow.completed (or workflow.failed) | fire | REAL | runner automatic |
| D1 | workflow_verify_results | INSERT pending × 2 | REAL | runner verify staging |
| D1 | proposed_actions | INSERT (HITL gate envelope) | REAL | runner HITL gate |
| D1 | unknown | write | STUB | fan-out #1 (write_d1) |
| Chat tool | recompute_assembly_cost_rollup | invoke (side_effects=unknown) | STUB | fan-out #2 (recompute_assemblies) |
| NetSuite (via NS_PUSH_QUEUE) | vendor | push | STUB | fan-out #5 (ns_push) |
| D1 | proposed_actions | INSERT (email draft via propose_email_to_customer) | STUB | fan-out #6 (notify_vendor_owner) |