Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Evolving Reference Architecture — ShopOps Runtime

This document is the target architecture the book builds toward. Early chapters implement slices; Part IX–X assemble the whole.

Thesis in one diagram

                    ┌──────────────── human review ────────────────┐
                    ▼                                              │
 client/API → orchestrator → case worker(s) → model gateway        │
                    │                │              │              │
                    │                ├─ context assembler           │
                    │                ├─ policy engine ──────────────┤
                    │                ├─ tool executor ──► systems   │
                    │                ├─ memory controller           │
                    │                └─ checkpoint store            │
                    │                                              │
                    ├─ event bus / ledger                          │
                    ├─ trace/obs pipeline                          │
                    └─ eval harness (offline + gated online)       │

Invariant: Model proposes actions; policy + authz + executor dispose; ledger/trace/audit remember.

Logical components

ComponentResponsibilityIntroduced
API layerAuthN, case intake, review UI APIs31, 40, 42
OrchestratorTask graph, budgets, assign, pause18, 31
Case workerRuns control loop / FSM ticks1→8, 32
Model gatewayProvider I/O, routing, timeouts34–35
Context assemblerBudgeted prompt sections3, 35
Tool service / registrySchemas, execution4–6
Policy engineDeterministic permit/deny5, 28
Memory serviceTyped memory + controller9–10
Checkpoint storeResume / HITL8
Event bus + ledgerCoordination & shared facts16–17
Approval / HITL serviceQueues, timeouts29, 40
Trace + metricsDebug, cost, SLOs23, 35
Eval serviceFixtures, regression, judges19–22
Channel adaptersSMS/email/WhatsApp/voice mocks→real39

Control flow (happy path)

  1. support ticket / exception event creates case (checkpointed).
  2. Orchestrator schedules Intake work.
  3. Worker assembles context (policies pinned), model returns structured Decision.
  4. Policy engine permits/denies each tool.
  5. Reads execute; writes may require approval.
  6. Resolution → Policy → Outreach as separate steps or agents with SoD.
  7. Consequential sends append audit evidence pack.
  8. Outcomes feed offline eval datasets (no silent online RL).

State model (conceptual)

CaseState {
  case_id, tenant_id,
  fsm_status,           # idle|planning|awaiting_tool|awaiting_approval|...
  profile,              # typed facts/inferences/unknowns
  strategy,             # proposed actions + evidence refs
  compliance_result,
  approvals[],
  memory_refs[],
  ledger_seq,
  checkpoint_version
}

Transition: (s_{t+1} = F(s_t, a_t, o_{t+1})) with (a_t) filtered by policy.

Trust boundaries

[untrusted] user messages, ticket free text, retrieved web/docs, tool raw bodies
[structured] tool JSON after validation
[trusted config] policy packs, tool allowlists, model route tables
[secrets] never in prompts — only in executor sidecars

Injection defenses live at boundaries (Ch 26), not in “please ignore” wording.

Multi-agent topology (ShopOps)

Agent / moduleCan readCan writeNotes
IntakeOMS/CRM, order/shipment historymemory (intake facts)No customer contact
Resolutionprofile, policiesresolution proposalsNo send
Policyproposals, rule packpolicy verdictsPrefer deterministic
Outreachapproved actionschannel APIsLeast privilege tokens
Orchestratorall metadataassignments, budgetsNot an LLM free-for-all

Shared beliefs that matter to audit go to the ledger, not cross-chats.

Data stores

StoreContents
Primary DBcases, checkpoints, memory cells, tenants
Ledger logappend-only events (hash-chained per case)
Object storelarge traces, evidence packs
Queuework leases by case_id partition
Optional vector indexretrieval corpus — not system of record

Caching & performance (where concepts live)

MechanismRole in ShopOps
KV cacheDecode efficiency inside a generation
Prefix / prompt cacheStable policy+tool preamble across turns
HTTP idempotency + result cacheSafe retries to channels
Retrieval cacheHot policy docs — careful with staleness

Assembler stability (Ch 3) is what makes prefix caching real (Ch 35).

Framework Rosetta (late)

After manual builds, map:

Our conceptTypical framework feature
FSM / graphLangGraph nodes/edges
ToolsOpenAI/Anthropic tools, MCP servers
CheckpointsLangGraph checkpointers, Temporal
WorkersCelery/Temporal/cloud queues
PoliciesCustom; rarely first-class

Frameworks are implementations of these boxes — not replacements for understanding them.

Non-goals

  • Unrestricted autonomous refunds/contact
  • Online RL from raw production rewards without gates
  • “Multi-agent debate” as a truth engine