RAIA™ Specification

Documentation

An asset snapshot acts as a highly compiled "cheat sheet" for a rental property. Instead of forcing our AI assistants to search through multiple raw databases, communication logs, and PDF files on the

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

An asset snapshot acts as a highly compiled "cheat sheet" for a rental property. Instead of forcing our AI assistants to search through multiple raw databases, communication logs, and PDF files on the

🧩 Section A: In Plain English

Dynamic Asset Snapshots

An asset snapshot is a compiled cheat sheet for a rental property — a background pipeline gathers data from multiple sources, organizes it, and creates a secure markdown dossier for AI assistants.

🧩 In Plain English

An asset snapshot acts as a highly compiled "cheat sheet" for a rental property. Instead of forcing our AI assistants to search through multiple raw databases, communication logs, and PDF files on the fly, a background pipeline gathers all this information in advance, organizes it, and compresses it. This creates a secure, structured markdown dossier containing tenancy terms, compliance dates, and recent activity. Because we pre-scrub sensitive customer details locally using a private AI filter, we can send this context to external models for summarization without violating data compliance rules or risking training opt-ins.

2 Layers
Static & Live Snapshots
10 Min
Live Debounce Lock
Zero Leak
Local PII Scrubbing
ADR-084
No Webhook Loop Guard

⚡ Dynamic Asset Snapshots & Overnight Pipelines

Sovereign Engineering (ADR-086)

RAIA™ (Real estate Artificial Intelligence Agent) OS implements a dual-layer property context system designed to eliminate LLM hallucinations, enforce localized GDPR/PII boundaries, and optimize API costs. The system splits property context into a multi-year Static Layer and a highly dynamic Live Layer. This ensures our AI concierge has a complete, structured, and compliant understanding of every managed property.

Chapter 1: The Rationale (Why We Snapshot)

1. The Data Fragmentation Problem

A property's ground truth is scattered across multiple isolated silos: relational terms in Supabase, email logs in Google BigQuery, support threads in Intercom, financial records in automated bank reconciliation gateway, and PDF certificates in Google Cloud Storage. Searching all these endpoints dynamically during an active customer chat leads to unacceptable latency (15s+), excessive token consumption, and catastrophic hallucinations when search results fail to align.

2. The AI Hallucination Solution

By compiling these silos into a single, structured Markdown dossier (the "Golden Record") *before* a conversation begins, we constrain the LLM context to verified facts. The AI concierge no longer queries relational tables or writes complex SQL joins; it simply reads the pre-compiled snapshot. This guarantees 100% factual accuracy on complex questions like rent review histories and break-clause dates.

3. PII Minimization & Zero Leakage

Under GDPR/ADR-PII-001, we must never send raw personal documentation or unredacted emails to external API providers. Dynamic snapshots solve this through a **two-step local sanitization pipeline**: raw communications are pulled, pre-scrubbed by our local `nvidia/gliner-PII` NER model to remove names, passport numbers, phone numbers, and emails, and only then sent to Claude/Gemini APIs for summarization.

4. Operational Tokenomics

Compiling a static snapshot is a token-intensive operation, requiring ~15,000 to ~20,000 input tokens. Rebuilding all 3,464 managed assets nightly would cost over $340/day. Instead, we use **Selective Rebuilding**: snapshots are compiled only for properties with active SJT lifecycle events, keeping active DB records lean and keeping daily token costs below $1.50.

Chapter 2: Dual-Layer Architecture & Data Flows

RAIA™ (Real estate Artificial Intelligence Agent) OS splits the property context into two distinct layers managed in a single table, tbl_asset_snapshots, ensuring high-speed delivery to the agent:

Figure 1.1: Dual-Layer Dynamic Snapshot Architecture DATA SOURCES PIPELINE & SECURITY DB DUAL LAYERS CONSUMERS Static Structures tbl_tenancies tbl_documents (Gas/EPC) Historic Comms gmail_legacy.email_diary intercom_legacy Live Events property_events maintenance_tickets Live Financials tbl_rents (automated bank reconciliation gateway) arrears_status rebuild-snapshot-tiers.cjs Core Compilation Coordinator Interval: Nightly Sweep / Lifecycle Triggers Local PII Filter: nvidia/gliner-PII (Local VPS) live-event-listener.cjs Debouncer (10 Min Window) Trigger: property_events INSERT PII Filter: Redacts before external API Anthropic API Claude 4.6 (EU Regional) tbl_asset_snapshots snapshot_static • Landlord Terms • Compliance Dates • Lead Tenant IDs • RRA Legal Flags • Compressed Diaries rebuilt_at / trigger_type snapshot_live • Open Tickets (Owner) • Rent Arrears Ledger • Key Vault Location • Damp/Mould SLA • 14-Day activity log • Quiescent Fallback debounced 10m / event_id Concierge AI Agent Awaab's SLA Alerts Trigger
Figure 1.1: Schematic representation of our decoupled dual-layer storage context, mapping input pipelines to output snapshot records.

Security & Pipeline Guardrails

Guard Rail Operational Layer Enforcement Style Enforcement Action
Local PII Extraction Redaction Input Sanitization Hard-Block Local nvidia/gliner-PII scrubs Tier 2 documents & names before calling external API.
10-Minute Write Debouncer Database Trigger Soft-Gate PostgreSQL triggers check last write. If < 10 mins, shunts rebuild into a lazy queue.
Webhook Loop Prevention Relational Design Hard-Block Decoupled tbl_asset_snapshots table prevents updates on assets from looping.
Canned Quiescent States Inference Cost Saving Auto-Pass No active events in 14 days bypasses LLM call entirely, writing pre-rendered text.

2.1 Detailed Architectural Breakdown

1. The Static Layer (snapshot_static)

The Static Layer represents the overall multi-year relationship context of the property. It contains core specifications (e.g., structural type, keys, smart meter configurations), legal landlord agreements, historical compliance dates (EPC, Gas Safety, EICR, including explicit warning indicators for expiries), and localized tenancy frameworks (break clauses, notices, and rent history). This layer compiles infrequently—typically only upon key tenancy lifecycle events or manual triggers.

2. The Live Layer (snapshot_live)

The Live Layer captures active operational momentum. It indexes outstanding maintenance issues (categorized by contractor ownership and days open), current rent arrears schedules, and key locations, and includes a rolling 14-day activity digest mapping communications across our SMS, email, and WhatsApp channels. To keep this layer running smoothly under high-frequency updates (e.g., when a tenant sends multiple chat messages), a Postgres debouncing trigger enforces a strict **10-minute cooldown** per asset. If no events have occurred in 14 days, the system bypasses the LLM call entirely and writes a pre-formatted, quiescent string, reducing unnecessary API costs.

2.2 Step-by-Step Compilation & Local PII Scrubbing Workflow

When a database event triggers a snapshot rebuild (static or live), the pipeline executes the following sequence:

Figure 1.2: Step-by-Step Compilation Workflow

Repository Code

The live codebase implementation for this specification sits within the following repository folder:

Step 1: Event Lifecycle Event or Live Insert Step 2: Pull Aggregate Silos DB + Comms Step 3: Redact Local PII Filter gliner-PII VPS Zero Cloud Exposure Step 4: AI Call Secure Synthesis Claude 4.6 EU Step 5: Write Commit to DB tbl_asset_snapshots
Figure 1.2: End-to-end pipeline detailing local redaction guardrails preventing unencrypted client PII from leaking to external inference API streams.

Chapter 3: Operational Command Reference

While the background scheduler manages snapshots automatically, engineers can manually trigger, audit, or reset snapshots via CLI commands:

Prerequisites

  • Execution Context: Must run from the pipeline programs directory.
  • Environment: Loaded via /root/projects/raia/03_technology/programs/.env.
  • PostgreSQL: Full read/write access to tbl_asset_snapshots and property_events.

Scheduler Configuration

  • Platform Scheduler: Runs via the central Hermes cron daemon.
  • Error Resilience: Configured with Deepseek failover to guarantee execution during peak API congestion.
  • Logs: Preserved locally under /root/.hermes/cron/output/.

Step-by-Step Manual Rebuild Guide

# 1. Navigate to the pipeline core directory
cd /root/projects/raia/03_technology/09_pipelines/programs/
# 2. Run a targeted dry-run to inspect raw extracted context for a specific property
node rebuild-snapshot-tiers.cjs --asset f9d4b68e-173a-4da2-9f6b-3129487c532a --dry-run
# 3. Force-rebuild and write a fresh static & live snapshot directly to the database
node rebuild-snapshot-tiers.cjs --asset f9d4b68e-173a-4da2-9f6b-3129487c532a --write --force
# 4. Trigger the nightly synchronization sweep manually across all stale UK assets
node rebuild-snapshot.cjs --all --region GB --write

Chapter 4: Snapshot Pipeline File Inventory

The entire snapshot architecture is implemented across a specialized collection of scripts housed under 03_technology/09_pipelines/programs/:

File Name Scope & Responsibility Primary Triggers
rebuild-snapshot.cjs Core compiler coordinator. Evaluates stale properties, fetches relational inputs, formats prompt structure, and writes outputs. Nightly sweep, CLI
rebuild-snapshot-tiers.cjs Multi-tier content compiler. Evaluates depth limits of historical data to prevent token overflows on dense property histories. CLI manual overrides
rebuild-snapshot-latymer.cjs Specialized integration harness and golden standard compiler for our flagship test property (Flat 121, Latymer Court). Manual QA, CI Tests
snapshot-model-build.cjs Generates and caches raw structured payloads mapping metadata keys to raw table formats before compile pipeline is launched. Compiler dependency
lettspay-snapshot-compress.cjs Aggregates years of raw bank ledger transactions from automated bank reconciliation gateway into compressed monthly ledger summaries to fit the LLM token budget. rebuild-snapshot
ddl-snapshot-rebuild.cjs Monitors schemas, mapping database relationships into human-readable prompt instructions to align models on recent table changes. Schema changes
diary-snapshot-rebuild.cjs Pulls unredacted email diaries, compiles, and groups records by theme (maintenance vs rent) before dispatching to compiler. rebuild-snapshot
bq-snapshot-prime.cjs Performs optimized caching of BigQuery databases on local SQLite registers, avoiding heavy, slow BQ executions during compiler run. Cron pre-sweep

Chapter 5: Common Pitfalls & Mitigation Strategies

Snapshot pipelines operate at the intersection of AI inference and raw datastores. Several key technical traps have been resolved through strict engineering constraints:

❌ 1. Token Overrun on Multi-Year Email Diaries (Severity: Critical)

The Problem: Pulling all unredacted emails from BigQuery for a property managed for over 5 years exceeds 150,000 tokens, causing direct API timeouts and staggering costs.
Mitigation: lettspay-snapshot-compress.cjs aggregates transaction records into simple monthly totals, and diary-snapshot-rebuild.cjs summarizes past comms into high-density historical highlights, keeping the prompt footprint below 12,000 tokens.

❌ 2. Webhook Infinite Trigger Loops (Severity: Critical)

The Problem: When a compiler wrote the generated snapshot back to the core tbl_assets record, it triggered our database webhook, which BigQuery caught, registering a "new change" and firing the compiler again, launching an infinite, expensive loop.
Mitigation: We decoupled snapshots completely from the asset record, creating tbl_asset_snapshots as an isolated 1:1 table. Updates to snapshots do not fire the asset-updated webhooks (ADR-084).

⚠️ 3. Webhook Concurrency Spam (Severity: Caution)

The Problem: If an agent updates three compliance documents in a row, three separate database events fire in the same minute, launching three concurrent, expensive compilation jobs.
Mitigation: Live events utilize a PostgreSQL debouncer. Rebuilds are delayed by 10 minutes and pooled, meaning multiple changes in quick succession collapse into a single execution job.

Chapter 6: Pipeline Vibe Check

Use this checklists to verify that the snapshot pipelines are functioning correctly and that our compliance boundaries remain uncompromised:

Pre-Run Checklist (SJT Gates)

  • ✓ Verify local nvidia/gliner-PII container is running and healthy on 127.0.0.1:8000/v1/predict.
  • ✓ Confirm database credentials exist inside /root/projects/raia/03_technology/programs/.env.
  • ✓ Ensure target property carries an active tenancy record on tbl_tenancies (otherwise, compilation will abort on null terms).

Post-Run Verification Checklist

  • ✓ Check tbl_asset_snapshots.snapshot_static starts with structured markdown sections (Emergency, Rent Reference, Utilities).
  • ✓ Query tbl_asset_snapshots.static_rebuilt_at to verify the timestamp reflects recent runtime execution.
  • ✓ Verify unredacted customer names do not exist in the compiled text, confirming that the PII-scrubber has done its job.

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder: