Implement complete agent platform with four major layers:
P5 - Engine Layer (LangGraph):
- AgentState with JSON serialization validation
- 5 async nodes (ask, plan, act, verify, report) with error boundaries
- Template resolution system for {{user_input}} and {{steps.xxx}}
- StateGraph with conditional edges and interrupt_after for approval flow
- 17/17 tests passing, 90% coverage
P6 - LLM Layer:
- ClaudeClient with Decimal-based cost calculation (ROUND_HALF_UP)
- Custom exceptions (ClaudeAPIError, ClaudeTimeoutError, ClaudeRateLimitError)
- PromptBuilder with cache_control support
- ModelRouter with sensitivity-based routing (local vs Claude)
- 18/18 tests passing, 90% coverage
P7 - Audit Layer (Three-tier):
- Sanitizer: mask phone/ID card/API keys, contains_sensitive, mask_dict
- Encryptor: AES-256-GCM with keyring support, 12-byte IV
- AuditLogger: L1 (DB), L2 (OTel), L3 (Encrypted payloads)
- 24/24 tests passing, 86% coverage
P8 - API Layer (FastAPI):
- Lifespan management with 8-step startup sequence
- Middleware: TracingMiddleware, RateLimitMiddleware (Redis), CORS
- Auth: JWT decode with python-jose, RBAC with permission matrix
- Routes: health, chat (SSE), approve, trace
- 13/13 tests passing, 91% coverage
All gate checks passing:
- pytest with 85%+ coverage
- mypy type checking
- ruff style checking
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
24 lines
586 B
Python
24 lines
586 B
Python
"""
|
|
Core engine module — LangGraph-based agent execution.
|
|
|
|
Exports:
|
|
- AgentState: State model for LangGraph
|
|
- build_agent_graph: Graph builder
|
|
- create_agent_graph_for_tests: Test graph with MemorySaver
|
|
- create_agent_graph_with_postgres: Production graph with PostgresSaver
|
|
"""
|
|
|
|
from core.engine.graph import (
|
|
build_agent_graph,
|
|
create_agent_graph_for_tests,
|
|
create_agent_graph_with_postgres,
|
|
)
|
|
from core.engine.state import AgentState
|
|
|
|
__all__ = [
|
|
"AgentState",
|
|
"build_agent_graph",
|
|
"create_agent_graph_for_tests",
|
|
"create_agent_graph_with_postgres",
|
|
]
|