Customer crosses AR threshold + days criteria. Flag for service hold: customer flag, sales rep notification, customer-facing notice, NS order block.
event["ar_aging_tick_threshold","manual"]| name | required | type / hint |
|---|---|---|
customer_id | required | — |
ar_balance | required | — |
days_overdue | required | — |
reason | required | — |
customercustomersSELECT * FROM customers WHERE id=?
open_sostransactionsSELECT
COUNT(*) AS n, SUM(foreigntotal) AS total
FROM transactions
WHERE entity=?
AND type='SalesOrd'
AND status NOT IN ('closed','cancelled')prior_holdsauto_decisionsSELECT COUNT(*) FROM auto_decisions WHERE entity_type='customer' AND entity_id=? AND decision_type='service_hold'
| check | rule | severity |
|---|---|---|
customer_active | customer.isinactive != 'T' | block |
reasonable_threshold | days_overdue >= 60 AND ar_balance >= 10000 | warn |
Risk level 4 ≥ 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_service_hold_trigger (proposal envelope)workflow:service_hold_trigger:run_<run_id>flag_customer d1_write STUB["UPDATE customers SET entitystatus='hold', last_modified=now WHERE id=?"]src/lib/workflow_runner.ts (kind d1_write hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.notify_sales_rep hitl_email_draft STUBpropose_email_to_customersales_repsrc/lib/workflow_runner.ts (kind hitl_email_draft hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.draft_customer_notice hitl_email_draft STUBpropose_email_to_customercustomersrc/lib/workflow_runner.ts (kind hitl_email_draft hits the placeholder branch at line ~340 and emits step status 'stub'). Documented intent only.ns_order_block ns_push STUBcustomerNS_PUSH_QUEUE{credit_hold:true}src/lib/workflow_runner.ts (kind ns_push 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=service_hold_trigger, run_id, narrative) | runner automatic (reflexion_enabled=1) |
log_run | INSERT workflow_runs | declared in contract |
reflexion | INSERT reflexion_log with tags=service_hold,customer:? | declared in contract |
auto_decisions | INSERT auto_decisions row | declared in contract |
workflow_verify_results (pending — verify cron not yet wired)hold_applied_d1SELECT entitystatus FROM customers WHERE id=?
hold_applied_ns3exponential200030000true| system | table / resource | action | status | source |
|---|---|---|---|---|
| D1 | workflow_run_log | INSERT (run summary) | REAL | runner automatic |
| D1 | reflexion_log | INSERT (tags=service_hold_trigger) | 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 (flag_customer) |
| D1 | proposed_actions | INSERT (email draft via propose_email_to_customer) | STUB | fan-out #2 (notify_sales_rep) |
| D1 | proposed_actions | INSERT (email draft via propose_email_to_customer) | STUB | fan-out #3 (draft_customer_notice) |
| NetSuite (via NS_PUSH_QUEUE) | customer | push | STUB | fan-out #4 (ns_order_block) |