Skip to main content

🗒️ The Internal Monologue – System-Wide Event Log

The internalmonologue table is Reggie’s sensory bus.
Every RABS module—transport, comms, rostering, billing—emits structured events into this one place.
A scheduled LLM job reads the stream, produces summaries, and feeds insights back into the Brainframe.


1. Purpose

BenefitExplanation
Unified visibilityEliminates siloed logs by storing all module events in one table.
LLM summarisationPeriodic job condenses thousands of rows into actionable insights.
Audit & replayTime-sequenced history supports root-cause analysis and simulation.
Vector searchpgvector column enables “find similar incident” semantic look-ups.

2. Table Schema (PostgreSQL)

ColumnTypeNotes
iduuid PKUnique event identifier
timestamptimestamptz NOT NULLServer-side insertion time
moduletext NOT NULLOriginating subsystem (transport, comms, hr, …)
event_typetext NOT NULLEnum-like string (VEHICLE_ASSIGNED, SMS_SENT, …)
payloadjsonb NOT NULLRaw event data (schema varies per event_type)
vectorvector(768)Embedding of payload for similarity search
processedboolean DEFAULT falseMarked true once summarised by the LLM

Size guard: individual events should be ≤ 8 KB.
Retention: rows older than 90 days move to cold storage.


3. Event Ingestion

Modules write events via a single authenticated endpoint:

POST /brainframe/event

Example:

{
"module": "transport",
"event_type": "VEHICLE_ASSIGNED",
"payload": {
"vehicle_id": "VAN-003",
"booking_id": "BK-921",
"driver": "Sally Nguyen"
}
}

4. LLM Summarisation Job

A cron job runs every 15 minutes to:

  1. Select a batch of processed = false rows.
  2. Generate vector embeddings for new payloads.
  3. Call the LLM to draft a summary, flag anomalies, and suggest todo_actions.
  4. Insert a synthetic SUMMARY event back into internalmonologue.
  5. Mark the original rows as processed = true.

This loop converts raw data into structured knowledge Reggie can reason over.


5. Retention & Monitoring

  • Cold-storage archiving: Nightly task copies rows > 90 days to S3 and deletes local copies.
  • Metrics: monologue_ingest_rate, monologue_lag_seconds, monologue_unprocessed_count.
  • Alerts: PagerDuty triggers if unprocessed events > 10 000 or lag > 30 min.