Skip to main content

Triage System — Execution Flow

Two-Path Mapping

Triage spans the User Path (human experience) and System Path (operational pipeline). The diagram below shows which steps belong to which path.
Neither path can bypass the other. The System Path never writes canonical memory. The User Path never classifies.

End-to-End Data Flow

Step-by-Step Walkthrough

Step 1: Intake

An event arrives from one of:
  • MCP Connector — saves session memory after a tool call
  • Conversation Archive — triggers extraction when a conversation is archived
  • Session Triage — /v1/triage/session endpoint receives session summary
  • Manual Trigger — admin triggers triage via API
The iw-agent-runtime TriageAgent (Durable Object) receives the event, classifies it by simple pattern matching, and stores it as a triage_item in operational state.

Step 2: Continuity Emission

The TriageAgent calls emitTriageInput() which posts to the Continuity service at http://internal/v1/continuity/events. This creates a cognition/system event in the continuity stream.

Step 3: Cognitive Evaluation

If the event qualifies for cognitive triage (higher-stakes content), the intelligence service’s TriageAgent performs a deep evaluation:
  1. Intelligent Categorization — What is the true intent? (Lead, Document, Operational Request)
  2. Contextual Linking — How does this relate to canonical memory? Which entities does it touch?
  3. Canonical Review — Is it stale? Duplicate? Conflicts with established truths?
  4. Guardrails & Governance — Based on sensitivity, should it be staged for review or rejected?
Output is strictly: "STAGE_FOR_REVIEW" or "REJECT". No AUTO_APPROVE.

Step 4: Workflow Routing

The TriageWorkflow durable workflow routes the result:
  • pending_approval → sent to HITL DLQ (Human-In-The-Loop Dead Letter Queue)
  • rejected → terminal state, no memory published
  • approved (legacy — should not occur after patching) → treated as staging_for_review
No direct writes to R2, Pipeline, D1, or Vectorize from this workflow.

Step 5: Knowledge Extraction

The knowledge service’s triage-bot.ts extracts structured knowledge using Workers AI:
  • Memory types: insight, preference, fact, decision, action_item, relationship
  • All extractions written to triage_results with approval_status = 'pending'
  • Slack notification sent for review (channel, not authority bypass)

Step 6: Human Review

A human reviews the triage item via:
  • Workspace Triage Inbox — GET /v1/knowledge/inbox shows pending/deferred items
  • Slack Reactions — ✅ Approve, ❌ Discard, ⏰ Defer (must be verified as approval event)
  • API — PATCH /v1/knowledge/triage/:id with action: approve/discard/defer
The approval endpoint requires:
  1. Authenticated principal
  2. Tenant authority
  3. Optimistic/version check
  4. Approver identity and timestamp
  5. Immutable decision audit

Step 7: Consolidation

The Memory Consolidator runs on schedule: It reads only approved triage items and generates consolidated memories.

Step 8: Canonical Promotion

The Pipeline’s memory-promoter.ts is the sole canonical writer:
  1. Scores the Spine write against 7 Promotion Signals
  2. Determines governance state (staging vs approved)
  3. Writes to org_memory (D1)
  4. Deduplicates by lineage_ref
  5. Creates audit trail in memory_promotion_audit
  6. Indexes approved memory into AI Search

Step 9: Indexing and Consumption

Approved org_memory entries are indexed into AI Search as markdown documents with full metadata. Twin reads published memory through bounded context projection — never raw canonical storage.