← Back to docs

Platform · context

Portal Context — Proactive Intelligence Layer

Event ingestion, workspace modeling, context extraction, template synthesis, and notification management. Builds a real-time model of what the user is doing and proactively surfaces relevant information.

portal-contextv0.3.0context
18.4K
Lines of Code
515
Tests
144
Files

Architecture

20+ modules organized by function: event handling (event_ingestion, events, pcp_bridge), context modeling (context_extraction, context_query, workspace_model, schema, types), intelligence (decision_engine, proactive, default_rules, template_synthesis, notification_manager), infrastructure (config, config_manager, error, telemetry, size_management, privacy, coordination), integration (llm_interface, voice_client, portal_context). The pcp_bridge module connects PCP push events to the context pipeline.

Overview

portal-context is the proactive intelligence layer that observes system events (window changes, app launches, voice commands, file operations) and builds a real-time model of the user's current context. It ingests events from multiple sources, extracts structured context (what apps are active, what task is being performed, what time of day it is), synthesizes narrative descriptions from raw event sequences, and manages proactive notifications. The system can answer queries about the current workspace state and power proactive suggestions. The crate exposes PortalContext as its top-level API — construct it with a config path, call start(), then use query() and telemetry().

Key Types

PortalContextTop-level entry point — construct with config, call start(), use query() and telemetry().
ContextKeyTyped key for context bag entries — type-safe access to extracted context.
ContextIdUnique identifier for a context extraction session.
EventIdUnique identifier for an ingested event.
NotificationIdUnique identifier for a proactive notification.

Modules

event_ingestion

Event ingestion — receives events from system sources (window manager, voice, PCP), normalizes, timestamps.

context_extraction

Context extraction — analyzes event stream to build structured context (active apps, current task, environment).

workspace_model

Workspace model — tracks window layout, app relationships, task transitions over time.

template_synthesis

Template synthesis — generates human-readable narratives from raw context data ('You're editing a document in LibreOffice').

notification_manager

Notification management — decides when and how to surface proactive suggestions, manages notification lifecycle.

decision_engine

Decision engine — evaluates rules against context to determine if a proactive action should be taken.

proactive

Proactive system — generates suggestions based on context (e.g., 'Would you like to open your email?').

default_rules

Default rules — built-in decision rules for common scenarios.

pcp_bridge

PCP push event bridge — connects PCP capability events to the context pipeline (feature-gated, not yet wired).

llm_interface

LLM interface — client for portal-llm daemon, used for context summarization.

voice_client

Voice client — connects to portal-voiced for voice-triggered context queries.

Data Flow

System events → event_ingestion → context_extraction → workspace_model → decision_engine → [notification_manager|proactive] → user notification

Dependencies

External (13)

tokio workspaceserde workspaceserde_json workspacetoml workspacechrono workspacerusqlite workspacelru workspaceparking_lot workspacezstd workspacenotify workspacetera workspacethiserror workspacetracing workspace

Connects to portal-voiced and portal-llmd via IPC. Future: PCP push bridge for capability events.