The architecture behind Context Lattice.
Six-layer agent framework, three-tier memory routing, agent work packet schema, end-to-end OTel observability, and architecture-enforced safety. The technical foundation for a governed enterprise context layer.
1. Context Supply Chain
The Context Lattice supply chain has nine stages, from raw source material to memory writeback. Every stage carries a correlation ID; every transition is auditable.
2. Six-Layer Agent Framework
The agent framework is the independent variable. Benchmark rankings shift significantly from framework-only changes — making framework design a primary engineering lever, not a model-selection afterthought. The six layers compose in strict order: Safety wraps Orchestration wraps Execution; Context Assembly and Affective Sensing run in parallel; Memory sits beneath all of them.
3. Three Memory Tiers
Production knowledge systems require tiered memory. A single vector store returns semantically proximate but factually incorrect answers for ownership and relationship queries. Context Lattice routes every retrieval through P1 → P2 → P3 in strict precedence.
CanonStore
SPARQL quad store. Exact-match facts, ownership, relationships. Deterministic.
LatticeMem
Graph-RAG over the company context graph. Session and role aware, permission scoped.
Drop Corpus
Vector similarity over raw source material. Last resort. Never for ownership queries.
Semantic search is a last resort, not a first pass. A vector store cannot answer "who owns this?" reliably — semantic proximity is not factual accuracy. Deterministic tiers carry the load.
4. Agent Work Packet Schema
ContextCurator emits agent work packets. Each packet is the structured artifact that wraps a piece of human intent in everything an agent needs to act safely: source context, constraints, acceptance criteria, and readiness score.
// agent_work_packet.json { "packet_id": "awp_2c91", "issue_id": "PROJ-482", "intent": { "goal": "Add rate limit to /api/contact endpoint", "actor": "engineer:michael", "motivation": "Prevent abuse of strategy session form" }, "constraints": [ "must not modify auth middleware", "backwards compatible with existing clients", "latency budget: < 5ms p99" ], "source_context": [ "atom_8f3a", // rate limiter design decision "atom_a02d" // API style guide ], "acceptance_criteria": [ "returns 429 with Retry-After header", "unit tests cover burst + sustained", "OTel span emitted on throttle event" ], "readiness_score": 0.82, "readiness_gate": 0.75, "agent_authorized": true, "trace_id": "7c4f...a912" }
5. Context Atom Schema
Context atoms are the unit of governed knowledge. Every atom carries provenance, maturity, permissions, and source links. Atoms compose into context packs.
// context_atom.json { "atom_id": "atom_8f3a", "title": "Rate limiting standard: token bucket", "body": "Internal APIs use token bucket with...", "maturity": "verified", // draft | curated | verified | promoted "source": { "doc_id": "arch-spec.md", "section": "3.4 Rate Limiting", "hash": "sha256:c4f8..." }, "owner_role": "platform-eng", "permissions": ["role:engineering", "role:platform-eng"], "links": { "supports": ["atom_a02d"], "supersedes": ["atom_4421"] }, "confidence": 0.94, "last_verified": "2026-04-22T18:11:00Z", "reuse_count": 17 }
6. OTel Observability
Every retrieval, every agent session, every committed action carries a trace ID. The
v_issue_full_trace view joins Plane issue IDs, Claude session IDs,
git commit trailers, and tool call spans into a single chain.
The result: from any deployed line of code, you can trace back through commit → trailer → Claude session → agent work packet → ContextCurator card → source context atoms → originating documents and decisions.
-- v_issue_full_trace view SELECT issue.id AS plane_issue_id, session.id AS claude_session_id, commit.sha AS commit_sha, packet.id AS work_packet_id, atoms.ids AS source_atoms FROM plane_issues issue JOIN agent_sessions session ON session.issue_id = issue.id JOIN git_commits commit ON commit.trailer_session = session.id JOIN work_packets packet ON packet.session_id = session.id JOIN packet_atoms atoms ON atoms.packet_id = packet.id;
7. Safety Architecture
Unconditional constraints belong in framework code, not prompts. Safety guarantees that live in instructions can be reasoned around by the model. Context Lattice enforces action gates, scope isolators, and intervention ladders at the middleware layer.
8. Integration Surface
Context Lattice does not replace your AI platforms. It supplies governed context to them through four interfaces:
# Retrieval API POST /v1/context/retrieve body: { role, query, scope, max_tokens } → returns: { atoms[], pack_metadata, trace_id } # Context pack export GET /v1/packs/{pack_id}/export?format=mdx → returns: assembled context pack in MDX, JSON, or Markdown # MCP server mcp://contextlattice.local/v1 tools: context.retrieve, atom.lookup, packet.next # Memory writeback POST /v1/memory/candidate body: { session_id, outcome, candidate_atom } → returns: { candidate_id, review_status }