AI scan flags an anomaly (margin compression, vendor cost spike, customer order pattern shift). Create anomaly_investigations row, propose remediation actions, surface in dashboard.
cron22,37,52 * * * *"R174"recent_anomaliesanomaly_investigationsSELECT
*
FROM anomaly_investigations
WHERE created_at > datetime('now','-2 hours')
AND status='open'Risk level 2 < 3 — no HITL gate. Fan-out runs immediately after preconditions pass.
propose_remediation stage_proposed_action REALanomaly_responsesurface_dashboard d1_write STUB["INSERT anomaly_investigations","UPDATE weekly_anomalies"]src/lib/workflow_runner.ts (kind d1_write 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=anomaly_remediation, run_id, narrative) | runner automatic (reflexion_enabled=1) |
log_run | INSERT workflow_runs | declared in contract |
reflexion | INSERT reflexion_log with tags=anomaly_remediation | declared in contract |
workflow_verify_results (pending — verify cron not yet wired)anomalies_surfacedSELECT COUNT(*) FROM anomaly_investigations WHERE created_at > ?
1nonefalse| system | table / resource | action | status | source |
|---|---|---|---|---|
| D1 | proposed_actions | INSERT (action_type=anomaly_response, entity_type=workflow_run) | REAL | fan-out #1 (propose_remediation) |
| D1 | workflow_run_log | INSERT (run summary) | REAL | runner automatic |
| D1 | reflexion_log | INSERT (tags=anomaly_remediation) | REAL | runner automatic |
| Event | workflow.completed (or workflow.failed) | fire | REAL | runner automatic |
| D1 | workflow_verify_results | INSERT pending × 1 | REAL | runner verify staging |
| D1 | unknown | write | STUB | fan-out #2 (surface_dashboard) |