Skip to content

Protocol Raw System Architecture

Layer 4: SOP Cross-Reference

Version: 1.0
Status: Production Reference
Last Updated: January 2026
Owner: Protocol Raw Operations


1. SOP Master Index

1.1 Core Operations SOPs

ID Name Version Status Purpose
SOP-00 Shopify → Supabase Bridge v4.0 ✅ Production Order/customer ingestion from Shopify
SOP-01 Batch Creation & Lab-to-Release v4.2 ✅ Production Batch lifecycle, QA, lab processing
SOP-02 Courier Watchdog v3.0 ✅ Production DPD tracking, exception handling
SOP-03 Daily Operations Snapshot v3.1 ✅ Production Morning ops digest
SOP-04 Reserved - - -
SOP-05 Email Processing v3.0 ✅ Production Email outbox queue processing
SOP-0R Formulation Management v4.2 ✅ Production Product formulation tracking
SOP-0X Order Export v3.0 ✅ Production Export orders for fulfillment
SOP-0Y Dispatch Recording v2.0 ✅ Production Record dispatch, tracking submission

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.5 ✅ Production Support system overview
SOP-CS-01 AI Customer Service Triage v2.1 ✅ Production Email classification
SOP-CS-02 Live Chat System v1.8 ✅ Production Real-time messaging
SOP-CS-03 Autonomous Support Agent v1.5 ✅ Production AI-powered automation

1.5 Subscription & Lifecycle SOPs

ID Name Version Status Purpose
SOP-SUB-00 Subscription State Management v1.0 🔵 Design Seal sync, dunning, card expiry
SOP-LC-01 Lifecycle Communications v1.0 ✅ Production All automated emails
SOP-REF-01 Referral System v2.1 ✅ Production Referral codes, credits

1.6 Monitoring & Infrastructure SOPs

ID Name Version Status Purpose
SOP-MON-01 Monitoring & Alerting Architecture v1.0 ✅ Production Centralized monitoring
SOP-MON-02 Order Ingestion SLO Monitor v2.0 ✅ Production Order ingestion health
SOP-AI-KB-01 AI Knowledge Base v1.8 ✅ Production KB management
SOP-CHS-01 Customer Health Scoring v1.0 🔵 Design Churn prediction

1.7 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-00 (Shopify Bridge)
    ↓ Creates: orders, customers, order_items
SOP-INV-01 (Inventory) ← Allocation trigger
    ↓ Creates: allocations
SOP-0X (Order Export)
    ↓ Updates: export_state = 'exported'
SOP-PACK-01 (Packing)
    ↓ Creates: packing_instructions
SOP-0Y (Dispatch)
    ↓ Creates: shipments
SOP-02 (Courier Watchdog)
    ↓ Creates: courier_events
SOP-LC-01 (Lifecycle) → Customer emails

2.2 Batch Flow Dependencies

SOP-01 (Batch Creation)
    ↓ Creates: batches (status: QA_HOLD)
    ↓ Creates: inventory (qty_on_hold)
SOP-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-MON-02 (Order Ingestion SLO) → uses pattern
├── SOP-03 (Daily Snapshot) → uses pattern
├── SOP-01 (Lab SLA) → uses pattern
├── SOP-01 (Working Capital) → uses pattern
├── SOP-INV-01 (Stock Levels) → uses pattern
└── SOP-CS-03 (Support Queue) → uses pattern

3. SOP to Component Mapping

3.1 SOP-00: Shopify Bridge

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-01: Batch Creation & Lab-to-Release

Component Type Name Purpose
Edge Function create-batch Create batch with assets
Database Table batches Batch records
Database Table lab_results Lab test results
Database Table formulations Product formulations
Database Function generate_public_batch_id() Hash generation
Database Trigger trigger_set_public_batch_id Auto-set public ID
Make.com Scenario Lab Results Processing Parse lab PDFs
Monitor Function fn_check_lab_sla_v2() Lab SLA tracking
Monitor Function fn_check_working_capital_v2() QA hold value

3.3 SOP-02: Courier Watchdog

Component Type Name Purpose
Make.com Scenario DPD Tracking Ingestion Receive events
Make.com Scenario Courier Exception Handler Customer notification
Database Table shipments Dispatch records
Database Table courier_events Tracking events
Customer.io Template delivery_exception Exception email

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-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
View v_support_queue Open tickets
View v_customer_context Customer 360
Make.com Scenario Address Update Sync Shopify + Seal sync
Edge Function sync-address-change Address sync trigger

3.8 SOP-CS-01: AI Triage

Component Type Name Purpose
Edge Function cs-agent-triage Classification
Database Table cs_agent_decisions AI decisions
Make.com Scenario CS-01: Email Triage Gmail watch

3.9 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_queue_v2() Queue depth

3.10 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.11 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.12 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
Make.com Scenarios SUB-01 to SUB-05 Dunning sequence

4. SOP to External System Mapping

SOP Shopify Seal DPD Customer.io Gmail OpenAI Claude Slack
SOP-00 ✅ Webhook
SOP-01 ✅ Lab emails ✅ PDF parsing ✅ Alerts
SOP-02 ✅ Webhooks ✅ Exception emails
SOP-03 ✅ Daily digest
SOP-INV-01 ✅ Stock alerts
SOP-PACK-01
SOP-CS-00 ✅ Address ✅ Address ✅ Emails ✅ Support
SOP-CS-01 ✅ Inbox watch ✅ Embeddings ✅ Classify
SOP-CS-03 ✅ Responses ✅ Embeddings ✅ Draft ✅ Queue
SOP-LC-01 ✅ All emails
SOP-SUB-00 ✅ Webhooks ✅ Dunning
SOP-MON-01 ✅ All alerts

5. Database Table to SOP Mapping

Table Primary SOP Related SOPs
customers SOP-00 SOP-CS-00
orders SOP-00 SOP-0X, SOP-PACK-01
order_items SOP-00 SOP-INV-01
batches SOP-01 SOP-INV-01
inventory SOP-INV-01 SOP-01
inventory_movements SOP-INV-01
allocations SOP-INV-01 SOP-00 (trigger)
lab_results SOP-01
shipments SOP-0Y SOP-02
courier_events SOP-02
packing_instructions SOP-PACK-01
support_tickets SOP-CS-00 SOP-CS-01, SOP-CS-03
ticket_messages SOP-CS-00 SOP-CS-03
cs_agent_decisions SOP-CS-01 SOP-CS-03
kb_articles SOP-AI-KB-01 SOP-CS-03
subscriptions SOP-SUB-00
subscription_events SOP-SUB-00
webhook_inbox SOP-00
ops_events Multiple Universal logging
monitoring_runs SOP-MON-01 All monitors
email_outbox SOP-05 SOP-LC-01

6. Edge Function to SOP Mapping

Edge Function Primary SOP Purpose
shopify-webhook-handler SOP-00 Order ingestion
seal-webhook-handler SOP-SUB-00 Subscription sync
create-batch SOP-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-00 Webhook retry

7. Make.com Scenario to SOP Mapping

Scenario Primary SOP Trigger Purpose
CS-01: Email Triage SOP-CS-01 Gmail watch Support intake
Address Update Sync SOP-CS-00 Supabase webhook Address sync
Lab Results Processing SOP-01 Gmail filter Lab PDF parsing
DPD Tracking Ingestion SOP-02 DPD webhook Tracking events
Courier Exception Handler SOP-02 courier_events Customer notification
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-MON-02 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-01 Lab tracking
monitor-working-capital 0 */6 * * * SOP-01 QA hold value
monitor-daily-snapshot 0 9 * * * SOP-03 Daily digest
monitor-support-queue */15 * * * * SOP-CS-03 Support queue
retry-failed-webhooks */5 * * * * SOP-00 Webhook retry
process-email-outbox * * * * * SOP-05 Send emails
order-export 0 6 * * * SOP-0X Export orders

9. Customer.io Template to SOP Mapping

Template ID SOP Trigger
order_confirmation_first SOP-LC-01 First order
order_confirmation_repeat SOP-LC-01 Repeat order
transition_guide SOP-LC-01 +24h first order
transition_week_1 SOP-LC-01 +7d first order
transition_week_2 SOP-LC-01 +14d first order
delivery_reminder_7day SOP-LC-01 -7d renewal
delivery_lock_48h SOP-LC-01 -48h renewal
order_dispatched SOP-LC-01 Dispatch
order_delivered SOP-LC-01 Delivery
delivery_exception SOP-02 Exception
subscription_paused SOP-LC-01 Pause
subscription_resumed SOP-LC-01 Resume
subscription_cancelled SOP-LC-01 Cancel
winback_30day SOP-LC-01 +30d cancel
winback_60day SOP-LC-01 +60d cancel
payment_failed_day0 SOP-SUB-00 Payment fails
payment_failed_day3 SOP-SUB-00 +3d dunning
payment_failed_day7 SOP-SUB-00 +7d dunning
card_expiring_30day SOP-SUB-00 -30d expiry
card_expiring_7day SOP-SUB-00 -7d expiry

10. Quick Reference: "Where Do I Look?"

I need to understand... Start with SOP
How orders get into the system SOP-00
How batches work SOP-01
How inventory is managed SOP-INV-01
How packing works SOP-PACK-01
How dispatch works SOP-0Y
How courier tracking works SOP-02
How customer support works SOP-CS-00
How AI support works SOP-CS-03
How emails are sent SOP-LC-01
How subscriptions work SOP-SUB-00
How monitoring works SOP-MON-01
How the ops portal works Ops Portal Docs
How the customer portal works Customer Portal Docs

Document Purpose
Layer 1: System Map Visual architecture
Layer 2: Component Registry Database and function specs
Layer 3: Integration Specifications External API specs
Operations Portal Documentation Portal features
Customer Portal Documentation Portal features
Visual Identity Guide Brand standards
Email Design System Email standards

Protocol Raw — Verified safe, batch by batch.