PACT Architecture
PACT (Positioned Adaptive Context Tree) is the foundational architecture that powers Egregore’s context management system. Think of it as a DOM for AI context - allowing you to precisely position, manipulate, and automatically adapt memory components as conversations evolve.The Problem PACT Solves
Traditional chat-based AI systems treat context as a flat append-only log:- No addressability: Can’t reference or modify specific parts of context
- Inefficient: LLM re-processes entire history every turn
- No structure: Flat lists don’t represent hierarchical relationships
- Limited control: Can’t expire, move, or manage individual pieces
The Three Pillars
1. Positioned
Every component has precise coordinates in 3D space:Coordinates enable infinite addressability - you can reference any component precisely, just like DOM elements with IDs or CSS selectors.
2. Adaptive
Components automatically adjust positions as conversation grows through ODI (Overlap Demotion Invariant):3. Context Tree
Hierarchical organization mirrors DOM structure:PACT Coordinate System
Understanding Coordinates
PACT uses tuple coordinates with three dimensions:Depth: Conversation Timeline
- -1: System level (static, never moves)
- 0: Current active message
- 1, 2, 3…: Historical messages (pushed back by ODI)
Position: Attachment Points
- 0: Message core content (user/assistant text)
- 1+: Components attached to the message
- 1-: Alternative component attachment (negative positions)
Offset: Fine-Grained Placement
Relative positioning within a container:- 0: Core/canvas position (always exists)
- 1, 2, 3…: Positive offsets
- -1, -2, -3…: Negative offsets
ODI: Overlap Demotion Invariant
The Magic of Automatic Adaptation ODI is the system that automatically shifts components as conversations grow, maintaining their relative positions.How ODI Works
When a new message is added:- Current message
(0,0,0)becomes historical(1,0,0) - All permanent/sticky components increment depth by 1
- New message takes position
(0,0,0)
ODI Rules
What triggers ODI?
What triggers ODI?
ODI triggers when message count changes between turns:
- Length increase → increment depths
- Length decrease → decrement depths
- Length same → no ODI processing
What components participate in ODI?
What components participate in ODI?
- Permanent components (
ttl=None) - Sticky components (
ttl=1, cadence=1) - Components at depths ≥ 0
- System depth (-1) - always static
- Temporary/cyclic components (they expire instead)
Does ODI affect offset?
Does ODI affect offset?
No! ODI only changes depth, never position or offset. This preserves relative positioning within messages.
ODI Example: Multi-Turn Conversation
PACT Selectors
CSS-like syntax for querying context components:Learn More
Complete PACT selector syntax reference
Message vs Component Positioning
Message Structure (dN,0)
Message core content - permanent by default:
- No TTL by default (permanent)
- Automatically managed by MessageScheduler
- Participate in ODI depth shifting
Component Structure (dN,1+)
Components attached to messages - MAY have TTL:
- Most are permanent (participate in ODI)
- Can have TTL for automatic expiration
- Can use render lifecycle for dynamic positioning
Core Offset Layout Rule
Offset 0 is special - the core/canvas position that always exists:PACT v0.1 Canonical Compliance
All Context components inherit fromPACTNode with canonical fields:
Automatic Serialization
Best Practices
Use Descriptive Keys
Leverage Tags
3-Coordinate Selectors
Trust ODI
Common Patterns
Adding Persistent Metadata
System-Level Instructions
Temporary Reminders
What’s Next?
Context Management
Learn about context operations and component lifecycles
Message Scheduler
Understand episode management and ODI processing
PACT Selectors
Master selector syntax for querying components
Architecture Deep Dive
Full PACT specification and internals

