Protocol Raw System Architecture
Layer 4: SOP Cross-Reference
Version: 1.1
Status: Production Reference
Last Updated: April 2026
Owner: Protocol Raw Operations
1. SOP Master Index
1.1 Core Operations SOPs
| ID |
Name |
Version |
Status |
Purpose |
| SOP-ORD-01 |
Order Ingestion |
v5.0 |
✅ Production |
Webhook capture, processing, retry, and monitoring for Shopify order data |
| SOP-LAB-01 |
Batch Creation & Lab-to-Release |
v1.0 |
✅ Production |
Batch lifecycle, QA, lab processing (replaces SOP-01) |
| SOP-DLV-01 |
Courier Watchdog |
v4.0 |
✅ Production |
DPD tracking, exception handling, direct Customer.io notifications (replaces SOP-02) |
| SOP-03 |
Daily Operations Snapshot |
v3.1 |
✅ Production |
Morning ops digest |
| ~~SOP-04~~ |
Ad Spend Sync (deprecated) |
v4.0 |
❌ Deprecated |
Make.com-based ad spend sync — replaced by SOP-FIN-01 |
| SOP-05 |
Email Processing |
v3.0 |
✅ Production |
Email outbox queue processing |
| SOP-PROOF-00 |
Proof-of-Safety System |
v1.0 |
✅ Production |
QR codes, pouch labels, co-packer email, proof job queue (replaces ~~SOP-0R~~) |
| SOP-PROOF-01 |
Proof Portal System |
v1.1 |
✅ Production |
Public batch verification portal, DB-owned business logic, nonce-based CSP, SOP-MON-01 monitoring (replaces v1.0) |
| SOP-ORD-02 |
3PL Order Export |
v4.0 |
✅ Production |
Export orders for fulfillment (replaces SOP-0X) |
| SOP-ORD-03 |
Dispatch Ingestion |
v3.0 |
✅ Production |
Dispatch file processing, quarantine, monitoring (replaces SOP-0Y) |
1.2 Inventory SOPs
| ID |
Name |
Version |
Status |
Purpose |
| SOP-INV-01 |
Inventory Control |
v1.1 |
✅ Production |
Stock levels, manual adjustments |
| SOP-INV-02 |
Demand Forecasting |
v1.0 |
✅ Production |
Predict inventory needs |
1.3 Packing & Fulfillment SOPs
| ID |
Name |
Version |
Status |
Purpose |
| SOP-PACK-01 |
Intelligent Packing |
v2.0 |
✅ Production |
PCM calculation, pack day workflow |
| SOP-COLD-01 |
Cold Chain Integrity |
v1.0 |
✅ Production |
3PL cold chain requirements |
1.4 Customer Operations SOPs
| ID |
Name |
Version |
Status |
Purpose |
| SOP-CS-00 |
Customer Operations System |
v1.8 |
✅ Production |
Support system overview |
| SOP-CS-01 |
AI Customer Service Triage |
v2.2 |
✅ Production |
Email classification, health monitoring |
| SOP-CS-02 |
Live Chat System |
v1.8 |
✅ Production |
Real-time messaging |
| SOP-CS-03 |
Autonomous Support Agent |
v1.6 |
🟡 Shadow Validation |
AI-powered automation |
1.5 Subscription & Lifecycle SOPs
| ID |
Name |
Version |
Status |
Purpose |
| SOP-SUB-00 |
Subscription State Management |
v4.1 |
✅ Production |
Seal sync, native dunning, card expiry, reconciliation |
| SOP-LC-01 |
Lifecycle Communications |
v1.5 |
✅ Production |
All automated emails |
| SOP-REF-01 |
Referral System |
v3.0 |
✅ Production |
Referral codes, credits |
1.6 Monitoring & Infrastructure SOPs
| ID |
Name |
Version |
Status |
Purpose |
| SOP-MON-01 |
Monitoring & Alerting Architecture |
v1.1 |
✅ Production |
Centralized monitoring |
| ~~SOP-MON-02~~ |
~~Order Ingestion SLO Monitor~~ |
~~v2.0~~ |
❌ Retired |
Absorbed into SOP-ORD-01 v5.1 |
| SOP-AI-KB-01 |
AI Knowledge Base |
v3.4 |
✅ Production |
KB management |
| SOP-CHS-01 |
Customer Health Scoring |
v1.0 |
🔵 Design |
Churn prediction |
1.7 Finance SOPs
| ID |
Name |
Version |
Status |
Purpose |
| SOP-FIN-01 |
Ad Spend Sync |
v1.2.1 |
✅ Production |
Daily Meta/Google ad spend ingestion, FX conversion, CAC reporting (replaces ~~SOP-04~~) |
| SOP-FIN-02 |
Cost Tracking System |
v1.0 |
✅ Production |
Supplier invoices, COGS/CPD allocation, unit economics, cost anomaly monitoring (replaces ~~SOP-05~~ invoice parsing) |
1.8 Content & Marketing SOPs
| ID |
Name |
Version |
Status |
Purpose |
| SOP-JOURNAL-01 |
Journal Content Management |
v1.0 |
🔵 Design |
Blog content workflow |
2. SOP Dependency Map
2.1 Order Flow Dependencies
SOP-ORD-01 (Order Ingestion)
↓ Creates: orders, customers, order_items
↓
SOP-INV-01 (Inventory) ← Allocation trigger
↓ Creates: allocations
↓
SOP-ORD-02 (3PL Order Export)
↓ Updates: export_state = 'queued' → 'sent'
↓
SOP-PACK-01 (Packing)
↓ Creates: packing_instructions
↓
SOP-ORD-03 (Dispatch)
↓ Creates: shipments
↓
SOP-DLV-01 (Courier Watchdog)
↓ Creates: courier_events
↓
SOP-LC-01 (Lifecycle) → Customer emails
2.2 Batch Flow Dependencies
SOP-LAB-01 (Batch Creation)
↓ Creates: batches (status: QA_HOLD)
↓ Creates: inventory (qty_on_hold)
↓
SOP-LAB-01 (Lab Processing)
↓ Creates: lab_results
↓ Updates: batch status → RELEASED
↓
SOP-INV-01 (Inventory)
↓ Releases: inventory to qty_available
↓ Triggers: pending order allocation
2.3 Support Flow Dependencies
SOP-CS-00 (Customer Ops System)
↓ Defines: Overall support architecture
↓
SOP-CS-01 (AI Triage)
↓ Creates: support_tickets, cs_agent_decisions
↓
SOP-CS-03 (Autonomous Agent)
↓ Updates: tickets, sends responses
↓
SOP-AI-KB-01 (Knowledge Base)
↓ Provides: kb_articles for AI context
2.4 Monitoring Dependencies
SOP-MON-01 (Monitoring Architecture)
↓ Defines: run-monitor, ops-alerter pattern
↓
├── SOP-ORD-01 (Order Ingestion SLO) → uses pattern
├── SOP-03 (Daily Snapshot) → uses pattern
├── SOP-LAB-01 (Lab SLA) → uses pattern
├── SOP-LAB-01 (Working Capital) → uses pattern
├── SOP-INV-01 (Stock Levels) → uses pattern
├── SOP-CS-03 (Support Queue) → uses pattern
├── SOP-DLV-01 (Courier Watchdog Health) → uses pattern
├── SOP-ORD-02 (3PL Export Health) → uses pattern
└── SOP-ORD-03 (Dispatch Processing Health) → uses pattern
3. SOP to Component Mapping
3.1 SOP-ORD-01: Order Ingestion
| Component Type |
Name |
Purpose |
| Edge Function |
shopify-webhook-handler |
Receive webhooks |
| Database Table |
webhook_inbox |
Store raw webhooks |
| Database Table |
customers |
Customer master |
| Database Table |
orders |
Order headers |
| Database Table |
order_items |
Line items |
| Database Function |
process_order_webhook_txn() |
Processing logic |
| pg_cron Job |
retry-failed-webhooks |
Retry failures |
| View |
v_webhook_health |
24h metrics |
| View |
v_retry_queue_depth |
Queue status |
3.2 SOP-LAB-01: Batch Creation & Lab-to-Release
| Component Type |
Name |
Purpose |
| Edge Function |
create-batch |
Create batch with assets |
| Edge Function |
lab-email-ingestion |
Gmail Pub/Sub → PDF parse → lab result insert |
| Database Table |
batches |
Batch records |
| Database Table |
lab_results |
Lab test results |
| Database Table |
lab_email_failures |
Quarantine queue for failed lab emails |
| Database Table |
formulations |
Product formulations |
| Database Function |
generate_public_batch_id() |
Hash generation |
| Database Function |
fn_process_lab_email_v1() |
Idempotent lab result insert |
| Database Function |
fn_check_lab_ingestion_health_v2() |
Lab ingestion monitoring |
| Database Trigger |
trigger_set_public_batch_id |
Auto-set public ID |
| pg_cron Job |
lab-01-gmail-watch-renew |
Gmail watch renewal every 6 days |
| pg_cron Job |
lab-01-fallback-poll |
Safety net poll every 30 min |
| Monitor Function |
fn_check_lab_sla_v2() |
Lab SLA tracking |
| Monitor Function |
fn_check_working_capital_v2() |
QA hold value |
3.3 SOP-DLV-01: Courier Watchdog
| Component Type |
Name |
Purpose |
| Make.com Scenario |
DPD Tracking Ingestion |
Receive inbound DPD events (pending DPD UK API) |
| Database Table |
shipments |
Dispatch records |
| Database Table |
courier_events |
Tracking events |
| Database Table |
courier_event_mapping |
Event code → template mapping |
| Database Table |
ops_events |
Customer notification queue (CUSTOMER_EVENT rows) |
| Database Function |
process_courier_event() |
Core event processing |
| Database Function |
notify_courier_exception() |
Trigger → send-courier-notification |
| Database Function |
fn_retry_courier_notifications_v1() |
Retry pending notifications with backoff |
| Database Function |
fn_check_courier_watchdog_health_v2() |
MON-01 health monitor |
| Edge Function |
send-courier-notification |
Direct Customer.io delivery (replaces Make.com Event Bridge) |
| Customer.io Campaign |
Courier Exception Handler |
5 email templates |
| pg_cron Job |
dlv-01-retry-notifications |
Retry every 5 min |
| pg_cron Job |
monitor-dlv-01-watchdog-health |
Health check every 15 min |
3.4 SOP-03: Daily Snapshot
| Component Type |
Name |
Purpose |
| Monitor Function |
fn_daily_snapshot_v2() |
Daily metrics |
| Database Function |
get_daily_snapshot() |
Metric calculation |
| pg_cron Job |
monitor-daily-snapshot |
Daily 09:00 |
| Slack Channel |
#daily-ops |
Delivery |
3.5 SOP-INV-01: Inventory Control
| Component Type |
Name |
Purpose |
| Database Table |
inventory |
Stock levels |
| Database Table |
inventory_movements |
Audit trail |
| Database Function |
execute_manual_inventory_adjustment() |
Manual adjustments |
| Database Function |
get_current_inventory_for_reconciliation() |
Inventory display |
| Database Trigger |
trg_decrement_inventory_on_dispatch |
Auto-decrement |
| Monitor Function |
fn_check_stock_levels_v2() |
Low stock alerts |
3.6 SOP-PACK-01: Intelligent Packing
| Component Type |
Name |
Purpose |
| Edge Function |
calculate-pack-day-instructions |
PCM calculation |
| Database Table |
packing_instructions |
Pack requirements |
| View |
v_pack_queue |
Orders to pack |
| External API |
OpenWeatherMap |
Weather forecast |
3.7 SOP-ORD-03: Dispatch Ingestion
| Component Type |
Name |
Purpose |
| Edge Function |
poll-dispatch-files |
List inbox, download, process, archive |
| Edge Function |
import-3pl-dispatch |
3PL dispatch data import (API) |
| Database Table |
shipments |
Dispatch records |
| Database Table |
processed_3pl_files |
File-level idempotency |
| Database Table |
dispatch_file_failures |
Quarantine queue |
| Database Function |
fn_import_3pl_dispatch() |
Core dispatch processing |
| Database Function |
fn_reprocess_dispatch_file_v1() |
Controlled reprocessing |
| Monitor Function |
fn_check_dispatch_processing_health_v2() |
MON-01 health monitor |
| pg_cron Job |
poll-dispatch-files-every-5-min |
File processing every 5 min |
| pg_cron Job |
monitor-ord-03-dispatch-health |
Health check every 15 min |
| Storage Bucket |
dispatch-files |
inbox/ and archive/ |
| View |
v_dispatch_metrics_daily |
Daily dispatch metrics |
| View |
v_order_fulfillment_status |
Fulfillment status |
3.8 SOP-CS-00: Customer Operations System
| Component Type |
Name |
Purpose |
| Database Table |
support_tickets |
Tickets |
| Database Table |
ticket_messages |
Conversation history |
| Database Table |
address_changes |
Address sync tracking |
| Database Table |
cancellation_reasons |
Structured cancellation reason capture (v2.0) |
| View |
v_support_queue |
Open tickets |
| View |
v_customer_context |
Customer 360 |
| Edge Function |
portal-update-address |
Address sync to Shopify + Seal |
| Edge Function |
cancellation-tracking |
Cancel flow v2.0 (4 routes) |
3.9 SOP-CS-01: AI Triage
| Component Type |
Name |
Purpose |
| Edge Function |
cs-agent-triage |
Classification |
| Database Table |
cs_agent_decisions |
AI decisions |
| Cloudflare Worker |
email-ingest |
Email routing to cs-agent-triage |
3.10 SOP-CS-03: Autonomous Agent
| Component Type |
Name |
Purpose |
| Edge Function |
cs-agent-triage |
Classification + draft |
| Edge Function |
send-support-email |
Email delivery |
| Database Table |
cs_agent_decisions |
AI decisions |
| Database Table |
ticket_messages |
Conversation log |
| Monitor Function |
fn_check_support_health_v2() |
Support health (queue, triage, intake) |
3.11 SOP-LC-01: Lifecycle Communications
| Component Type |
Name |
Purpose |
| Customer.io Templates |
Multiple |
All email templates |
| Make.com Scenario |
Event Bridge |
Trigger campaigns |
| Database Table |
email_outbox |
Email queue |
3.12 SOP-MON-01: Monitoring Architecture
| Component Type |
Name |
Purpose |
| Edge Function |
run-monitor |
Generic runner |
| Edge Function |
ops-alerter |
Slack delivery |
| Database Table |
monitoring_runs |
Execution log |
| pg_cron Jobs |
monitor-* |
All schedules |
| Slack Channels |
#ops-alerts, #ops-urgent, #daily-ops |
Alert delivery |
3.13 SOP-SUB-00: Subscription State Management
| Component Type |
Name |
Purpose |
| Edge Function |
seal-webhook-handler |
Webhook ingestion |
| Database Table |
subscriptions |
Local state cache |
| Database Table |
subscription_events |
Event log |
| Database Table |
billing_attempts |
Payment attempts |
| pg_cron Job |
dunning-processor (*/15 min) |
Dunning email dispatch |
| Edge Function |
reconcile-subscriptions |
Daily Seal API reconciliation |
| pg_cron Job |
reconcile-subscriptions-daily (daily 03:00) |
Trigger daily reconciliation |
| Database Table |
subscription_reconciliation_runs |
Reconciliation run tracking |
| Database Table |
subscription_reconciliation_staging |
Seal subscription snapshot |
| Database Table |
subscription_reconciliation_diffs |
Subscription drift records |
| Database Table |
billing_reconciliation_staging |
Seal billing attempt snapshot |
| Database Table |
billing_reconciliation_diffs |
Billing drift records |
| Function |
fn_finalize_subscription_reconciliation_v1() |
Set-based subscription comparison |
| Function |
fn_finalize_billing_reconciliation_v1() |
Set-based billing comparison |
4. SOP to External System Mapping
5. Database Table to SOP Mapping
6. Edge Function to SOP Mapping
| Edge Function |
Primary SOP |
Purpose |
| shopify-webhook-handler |
SOP-ORD-01 |
Order ingestion |
| seal-webhook-handler |
SOP-SUB-00 |
Subscription sync |
| create-batch |
SOP-LAB-01 |
Batch creation |
| cs-agent-triage |
SOP-CS-01 |
AI classification |
| send-support-email |
SOP-CS-00 |
Email delivery |
| sync-address-change |
SOP-CS-00 |
Address sync |
| calculate-pack-day-instructions |
SOP-PACK-01 |
PCM calculation |
| run-monitor |
SOP-MON-01 |
Monitor execution |
| ops-alerter |
SOP-MON-01 |
Slack delivery |
| retry-failed-webhooks |
SOP-ORD-01 |
Webhook retry |
| export-3pl-dispatch |
SOP-ORD-02 |
3PL CSV email via Resend |
| poll-dispatch-files |
SOP-ORD-03 |
Dispatch file ingestion from Storage |
| import-3pl-dispatch |
SOP-ORD-03 |
3PL dispatch data import (API) |
| send-courier-notification |
SOP-DLV-01 |
Direct Customer.io delivery |
| process-dunning |
SOP-SUB-00 |
Dunning + card expiry processor |
| reconcile-subscriptions |
SOP-SUB-00 |
Daily Seal API reconciliation |
| Scenario |
Primary SOP |
Trigger |
Purpose |
| ~~CS-01: Email Triage~~ |
SOP-CS-01 |
~~Deactivated~~ |
Replaced by Cloudflare Worker email-ingest (2026-04-06) |
| ~~Address Update Sync~~ |
SOP-CS-00 |
~~Deactivated~~ |
Replaced by portal-update-address Edge Function |
| ~~Lab Results Processing~~ |
SOP-LAB-01 |
~~Deactivated~~ |
Replaced by lab-email-ingestion Edge Function (2026-03-19) |
| DPD Tracking Ingestion |
SOP-DLV-01 |
DPD webhook |
Tracking events (still via Make.com pending DPD UK API) |
| ~~Courier Exception Handler~~ |
SOP-DLV-01 |
~~Deactivated~~ |
Replaced by send-courier-notification Edge Function (2026-03-19) |
| ~~Process Dispatch Files~~ |
SOP-ORD-03 |
~~Deactivated~~ |
Replaced by poll-dispatch-files Edge Function + pg_cron (2026-03-19) |
| Event Bridge |
SOP-LC-01 |
Database trigger |
Customer.io events |
8. pg_cron Job to SOP Mapping
| Job Name |
Schedule |
SOP |
Purpose |
| monitor-order-ingestion-slo |
*/2 * * * * |
SOP-ORD-01 |
Order health |
| monitor-outbox-health |
*/2 * * * * |
SOP-MON-01 |
Email queue |
| monitor-stock-levels |
*/15 * * * * |
SOP-INV-01 |
Low stock |
| monitor-lab-sla |
*/15 * * * * |
SOP-LAB-01 |
Lab tracking |
| monitor-working-capital |
0 */6 * * * |
SOP-LAB-01 |
QA hold value |
| monitor-lab-ingestion-health |
*/15 * * * * |
SOP-LAB-01 |
Lab email quarantine |
| lab-01-gmail-watch-renew |
0 0 */6 * * |
SOP-LAB-01 |
Gmail watch renewal |
| lab-01-fallback-poll |
*/30 * * * * |
SOP-LAB-01 |
Lab email safety net |
| monitor-daily-snapshot |
0 9 * * * |
SOP-03 |
Daily digest |
| monitor-cs-01-support-health |
*/15 * * * * |
SOP-CS-01 |
Support health |
| ord-01-webhook-retry |
*/5 * * * * |
SOP-ORD-01 |
Webhook retry |
| monitor-ord-01-webhook-health |
*/5 * * * * |
SOP-ORD-01 |
Webhook health |
| monitor-ord-01-daily-digest |
0 9 * * * |
SOP-ORD-01 |
Webhook daily digest |
| monitor-heartbeat |
*/15 * * * * |
SOP-MON-01 |
Monitoring system heartbeat |
| dlv-01-retry-notifications |
*/5 * * * * |
SOP-DLV-01 |
Retry failed courier notifications |
| monitor-dlv-01-watchdog-health |
*/15 * * * * |
SOP-DLV-01 |
Courier watchdog health |
| process-email-outbox |
* * * * * |
SOP-05 |
Send emails |
| ord-02-3pl-export-cycle |
*/15 * * * * |
SOP-ORD-02 |
Export orders to 3PL |
| ord-02-retry-exports |
*/5 * * * * |
SOP-ORD-02 |
Retry failed exports |
| monitor-ord-02-export-health |
*/5 * * * * |
SOP-ORD-02 |
3PL export health |
| poll-dispatch-files-every-5-min |
*/5 * * * * |
SOP-ORD-03 |
Process dispatch CSV files |
| monitor-ord-03-dispatch-health |
*/15 * * * * |
SOP-ORD-03 |
Dispatch processing health |
| monitor-subscription-health |
*/5 * * * * |
SOP-SUB-00 |
Subscription health checks |
| monitor-subscription-daily |
5 9 * * * |
SOP-SUB-00 |
Subscription daily digest |
| dunning-processor |
*/15 * * * * |
SOP-SUB-00 |
Dunning email dispatch |
| card-expiry-processor |
0 9 * * * |
SOP-SUB-00 |
Card expiry warnings |
| reconcile-subscriptions-daily |
0 3 * * * |
SOP-SUB-00 |
Daily Seal reconciliation |
9. Customer.io Template to SOP Mapping
10. Quick Reference: "Where Do I Look?"
| Document |
Purpose |
| Systems Overview v3.1 |
Infrastructure counts, Edge Function registry, data flows |
| Operations Portal Documentation |
Portal features |
| Customer Portal Documentation v3.1 |
Portal features |
| Visual Identity Guide |
Brand standards |
| Email Design System |
Email standards |
Protocol Raw — Verified safe, batch by batch.