Email arrives at one of the 5 mailboxes. Cascade: parse + classify + route to workflow, log to inbound_email_log, attempt entity resolution, draft response (HITL), surface in intake.html.
event["cf_email_routing"]| name | required | type / hint |
|---|---|---|
email_uuid | required | — |
from_email | required | — |
to_address | required | — |
subject | required | — |
body_text | required | — |
attachments[] | optional | — |
sender_knowncustomers · vendorsSELECT id, type FROM (SELECT id, 'customer' AS type FROM customers WHERE LOWER(email)=LOWER(?) UNION SELECT id, 'vendor' AS type FROM vendors WHERE LOWER(email)=LOWER(?))
existing_threadinbound_email_logSELECT id, workflow_routed_to FROM inbound_email_log WHERE from_email=? AND subject LIKE ? ORDER BY received_at DESC LIMIT 5
| check | rule | severity |
|---|---|---|
valid_from | from_email LIKE '%@%' | block |
not_spam | sender_known IS NOT NULL OR is_known_domain | warn |
Risk level 2 < 3 — no HITL gate. Fan-out runs immediately after preconditions pass.
log d1_write STUB["INSERT inbound_email_log"]src/lib/workflow_runner.ts (kind d1_write hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.route_to_workflow dispatch_workflow STUB{"bid_amendment":"bid_amendment_arrives","invoice_dispute":"customer_invoice_dispute","vendor_cost":"vendor_cost_update","spec_sheet":"new_assembly_item"}src/lib/workflow_runner.ts (kind dispatch_workflow hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.draft_response hitl_email_draft STUBpropose_email_to_customerclassification != spam AND requires_responsesrc/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=inbound_email_triage, run_id, narrative) | runner automatic (reflexion_enabled=1) |
log_run | INSERT workflow_runs | declared in contract |
reflexion | INSERT reflexion_log with tags=email_triage,classification:? | declared in contract |
workflow_verify_results (pending — verify cron not yet wired)email_loggedSELECT id FROM inbound_email_log WHERE email_uuid=?
routedSELECT workflow_routed_to FROM inbound_email_log WHERE email_uuid=?
3exponential100015000true| system | table / resource | action | status | source |
|---|---|---|---|---|
| D1 | workflow_run_log | INSERT (run summary) | REAL | runner automatic |
| D1 | reflexion_log | INSERT (tags=inbound_email_triage) | 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 | unknown | write | STUB | fan-out #1 (log) |
| Cloudflare Workflow | unknown | invoke instance | STUB | fan-out #2 (route_to_workflow) |
| D1 | proposed_actions | INSERT (email draft via propose_email_to_customer) | STUB | fan-out #3 (draft_response) |