Multi-step quote drafting from natural-language request
hitl_approval"proposed_actions row with action_type='price_change' or 'bid_price_update' approved"| name | required | type / hint |
|---|---|---|
customer_id | required | — |
sku | required | — |
new_price | required | — |
effective_date | required | — |
reasoning_text | required | — |
bid_id | optional | — |
current_pricingpricing_masterSELECT * FROM pricing_master WHERE customer_id=? AND item_code=?
bid_linebid_linesSELECT * FROM bid_lines WHERE bid_id=? AND item_code=?
vendor_costvendor_costsSELECT unit_cost, effective_from FROM vendor_costs WHERE item_code=? ORDER BY effective_from DESC LIMIT 1
reflexionreflexion_logSELECT * FROM reflexion_log WHERE entity_type='customer' AND entity_id=? AND tags LIKE '%price%'
| check | rule | severity |
|---|---|---|
vendor_cost_recency | effective_from > datetime('now','-7 days') | warn |
new_price_positive | new_price > 0 | block |
margin_floor | (new_price - cost_basis) / new_price * 100 >= customer_program.margin_floor | 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_draft_quote (proposal envelope)workflow:draft_quote:run_<run_id>write_ns ns_push STUBitempricing{"customer":"?customer_id","item":"?sku","price":"?new_price","effective":"?effective_date"}NS_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.write_d1 d1_write STUBwrite_ns["UPDATE pricing_master SET case_price=?, cost_basis=?, margin_pct=?, updated_at=now WHERE id=?","INSERT INTO pricing_history (customer_id,item_code,case_price,changed_at,changed_by) VALUES (?,?,?,now,?)"]src/lib/workflow_runner.ts (kind d1_write hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.update_bid_lines d1_write STUB["UPDATE bid_lines SET proposed_price=?, updated_at=now WHERE bid_id=? AND item_code=?"]bid_id presentsrc/lib/workflow_runner.ts (kind d1_write hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.regen_bid_artifact http_call STUB/api/bids/:bid_id/regenerate["updated bid PDF","updated price-quotes tab"]bid_id present AND artifact_r2_key existssrc/lib/workflow_runner.ts (kind http_call hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.invalidate_hub_cache kv_invalidate REALhub:nycdoe:bid_?bid_idhub:nycdoe:summarybid_id IN active_hub_bidsspec_sheet_check flag STUBINSERT proposed_actions (action_type=spec_review_needed, entity_ref=?sku)abs(price_change_pct) > 5src/lib/workflow_runner.ts (kind flag hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.customer_notify hitl_email_draft STUBpropose_email_to_customercustomer has open quote AND price_increasesrc/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=draft_quote, run_id, narrative) | runner automatic (reflexion_enabled=1) |
log_run | INSERT INTO workflow_runs (workflow_type, status, inputs_json, started_at, finished_at) | declared in contract |
reflexion | INSERT INTO reflexion_log (workflow_run_id, entity_type, entity_id, outcome, tags) | declared in contract |
customer_profile_touch | UPDATE customer_profiles SET last_pricing_event=now WHERE customer_id=? | declared in contract |
workflow_verify_results (pending — verify cron not yet wired)ns_reflects_new_priceSELECT
case_price
FROM pricing_customer_prices
WHERE customer_id=?
AND item_code=?
AND last_synced_at > datetime('now','-15 minutes')hub_cache_bustedd1_pricing_master_updatedSELECT case_price FROM pricing_master WHERE customer_id=? AND item_code=?
3exponential100030000true| system | table / resource | action | status | source |
|---|---|---|---|---|
| KV (CACHE) | hub:nycdoe:bid_?bid_id | invalidate | REAL | fan-out #5 (invalidate_hub_cache) |
| KV (CACHE) | hub:nycdoe:summary | invalidate | REAL | fan-out #5 (invalidate_hub_cache) |
| D1 | workflow_run_log | INSERT (run summary) | REAL | runner automatic |
| D1 | reflexion_log | INSERT (tags=draft_quote) | REAL | runner automatic |
| Event | workflow.completed (or workflow.failed) | fire | REAL | runner automatic |
| D1 | workflow_verify_results | INSERT pending × 3 | REAL | runner verify staging |
| D1 | proposed_actions | INSERT (HITL gate envelope) | REAL | runner HITL gate |
| NetSuite (via NS_PUSH_QUEUE) | itempricing | push | STUB | fan-out #1 (write_ns) |
| D1 | unknown | write | STUB | fan-out #2 (write_d1) |
| D1 | unknown | write | STUB | fan-out #3 (update_bid_lines) |
| Worker HTTP | POST /api/bids/:bid_id/regenerate | invoke | STUB | fan-out #4 (regen_bid_artifact) |
| D1 | flags / status field | set = | STUB | fan-out #6 (spec_sheet_check) |
| D1 | proposed_actions | INSERT (email draft via propose_email_to_customer) | STUB | fan-out #7 (customer_notify) |