Sales adds a new customer. Cascade: NS customer record, D1 customers, default customer_programs assignment, AR setup, pricing tier, welcome email, build first-quote-context bundle.
manual["sales_intake_form"]| name | required | type / hint |
|---|---|---|
company_name | required | — |
contact_email | required | — |
contact_phone | optional | — |
billing_address | required | — |
shipping_address | optional | — |
credit_limit | optional | — |
terms | optional | — |
sales_rep | optional | — |
pricing_tier | optional | — |
existing_by_namecustomersSELECT id, companyname FROM customers WHERE LOWER(companyname) = LOWER(?) OR LOWER(companyname) LIKE LOWER(?)
existing_by_emailcustomersSELECT id, companyname FROM customers WHERE LOWER(email) = LOWER(?)
default_termspayment_termsSELECT id FROM payment_terms WHERE name='Net 30'
| check | rule | severity |
|---|---|---|
no_duplicate | existing_by_name IS NULL AND existing_by_email IS NULL | block |
valid_email | contact_email LIKE '%@%' | 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_new_customer (proposal envelope)workflow:new_customer:run_<run_id>write_d1 d1_write STUB["INSERT customers"]src/lib/workflow_runner.ts (kind d1_write hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.write_ns ns_push STUBcustomerNS_PUSH_QUEUEsrc/lib/workflow_runner.ts (kind ns_push hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.assign_programs d1_write STUB["INSERT customer_programs (default tiers)"]src/lib/workflow_runner.ts (kind d1_write hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.welcome_email hitl_email_draft STUBpropose_email_to_customersrc/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=new_customer, run_id, narrative) | runner automatic (reflexion_enabled=1) |
log_run | INSERT workflow_runs | declared in contract |
reflexion | INSERT reflexion_log with tags=new_customer | declared in contract |
workflow_verify_results (pending — verify cron not yet wired)customer_persistedSELECT id FROM customers WHERE companyname=?
ns_customer_reflectsSELECT id FROM customers WHERE companyname=? AND lastmodifieddate > ?
3exponential150030000true| system | table / resource | action | status | source |
|---|---|---|---|---|
| D1 | workflow_run_log | INSERT (run summary) | REAL | runner automatic |
| D1 | reflexion_log | INSERT (tags=new_customer) | 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) |
| NetSuite (via NS_PUSH_QUEUE) | customer | push | STUB | fan-out #2 (write_ns) |
| D1 | unknown | write | STUB | fan-out #3 (assign_programs) |
| D1 | proposed_actions | INSERT (email draft via propose_email_to_customer) | STUB | fan-out #4 (welcome_email) |