> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spineworkspace.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 05 — Data Model

> The triage data model: candidates, classifications, links, quality scores, and audit records.

# Data Model

## Core Tables

### triage\_results

The primary table for triage candidates. Lives in Neon (Fortress) with D1 mirror.

```sql theme={null}
CREATE TABLE triage_results (
  id UUID PRIMARY KEY,
  message_id TEXT,
  platform TEXT,              -- 'ai_conversation', 'integratewise_session', etc.
  content TEXT,
  priority TEXT,              -- 'low', 'medium', 'high', 'urgent'
  category TEXT,
  confidence REAL,
  reasoning TEXT,
  sentiment TEXT,             -- 'positive', 'neutral', 'negative'
  metadata JSONB,            -- tenant_id, user_id, source, etc.
  approval_status TEXT DEFAULT 'pending'
    CHECK (approval_status IN ('pending', 'approved', 'discarded', 'deferred')),
  approved_by TEXT,
  approved_at TIMESTAMPTZ,
  created_at TIMESTAMPTZ,
  updated_at TIMESTAMPTZ
);
```

**Approval States:**

| State | Meaning | Next States |
| - | - | - |
| `pending` | Awaiting human review | approved, discarded, deferred |
| `approved` | Human approved → triggers consolidation | (terminal for triage) |
| `discarded` | Rejected by human or auto-discard | (terminal) |
| `deferred` | Deferred for later review | pending, discarded |

### consolidated\_memories

Consolidated memories produced by the Memory Consolidator.

```sql theme={null}
CREATE TABLE consolidated_memories (
  id UUID PRIMARY KEY,
  tenant_id TEXT,
  consolidation_type TEXT,   -- 'topic', 'user', 'account', 'pattern'
  topic TEXT,
  user_id TEXT,
  account_id TEXT,
  summary TEXT,
  key_insights JSON,         -- JSON array
  recurring_themes JSON,     -- JSON array
  action_patterns JSON,      -- JSON array
  session_count INTEGER,
  time_range_start TIMESTAMPTZ,
  time_range_end TIMESTAMPTZ,
  created_at TIMESTAMPTZ
);
```

### org\_memory

Canonical organizational memory. Written only by the Pipeline promotion engine.

```sql theme={null}
CREATE TABLE org_memory (
  id UUID PRIMARY KEY,
  tenant_id TEXT,
  topic TEXT,
  category TEXT,
  content TEXT,
  source_session_id TEXT,
  governance_state TEXT,      -- 'staging' or 'approved'
  confidence REAL,
  embedding TEXT,
  metadata JSON,
  created_at TIMESTAMPTZ,
  updated_at TIMESTAMPTZ,
  related_entity_ids JSON,
  related_departments JSON,
  access_scope TEXT,
  lineage_ref TEXT,
  tier TEXT
);
```

### memory\_promotion\_audit

Audit trail for every promotion decision.

```sql theme={null}
CREATE TABLE memory_promotion_audit (
  id UUID PRIMARY KEY,
  tenant_id TEXT,
  entity_id TEXT,
  signals JSON,
  score REAL,
  category TEXT,
  promoted BOOLEAN,
  governance_state TEXT,
  rationale TEXT,
  decided_by TEXT,
  created_at TIMESTAMPTZ
);
```

## Durable Object State (iw-agent-runtime)

The TriageAgent Durable Object maintains operational state in SQLite:

```sql theme={null}
CREATE TABLE triage_items (
  id TEXT PRIMARY KEY,
  tenant_id TEXT,
  kind TEXT,
  content TEXT,
  route TEXT,
  status TEXT,
  created_at TEXT,
  resolved_at TEXT
);
```

This is operational state, not canonical truth. It expires and is rebuildable.

## Memory Scopes (Logical)

| Scope | Table | Governance | Promotion |
| - | - | - | - |
| Personal | `personal_memory` | User-owned | Never widens |
| Agent | `agent_memory` | Working state | Evidence only |
| Conversational | `conversational_memory` | Ephemeral | Never promoted directly |
| Organizational staging | `triage_results` (pending) | Human review required | Via approval |
| Organizational published | `org_memory` (approved) | Canonical governed state | Sole write path |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.