Browse Source

feat: export all P1 modules + complete P1-4 integration (P1 complete)

Exports all Phase 2 (P1) modules from __init__.py:
- CostGrade, estimate_cost, format_cost_estimate (graded types)
- optimize_agent, RewriteLog (algebraic law rewrites)
- AgentCEKMachine, CostVector, CostMonotonicityViolation (CEK)

P1-4 (precise cost vector) is fulfilled by:
- CEK machine tracks per-step CostVector(tokens, latency, money)
- cost_summary() returns structured cost breakdown
- CostMonotonicityViolation enforces Paper II Prop. 23
- TraceHandler.handle_cost() accumulates runtime cost

175 total passing tests across 7 test files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kenny67nju 7 months ago
parent
commit
876adf8c08
1 changed files with 16 additions and 0 deletions
  1. 16 0
      lambdagent/__init__.py

+ 16 - 0
lambdagent/__init__.py

@@ -101,6 +101,15 @@ from .handlers import (
     EffectHandler, ProductionHandler, TestHandler, TraceHandler,
     get_current_handler, set_current_handler, with_handler,
 )
+# Paper III §4.3: Graded Cost Prediction
+from .cost_grade import (
+    CostGrade, estimate_cost, format_cost_estimate,
+    grade_serial, grade_parallel, grade_iterate, grade_guard,
+)
+# Paper II Theorems 36-41: Algebraic Law Rewrite Rules
+from .rewrite import optimize as optimize_agent, RewriteLog, RewriteEntry
+# Paper II: CEK Machine upgrades
+from .cek_machine import AgentCEKMachine, CostVector, CostMonotonicityViolation
 # Phase 1: P0 Engineering Improvements
 from .cancellation import CancellationToken, CancelledError, NullCancellationToken
 from .retry import RetryPolicy, CircuitBreaker, CircuitOpenError, with_retry, with_retry_sync
@@ -197,6 +206,13 @@ __all__ = [
     # Paper III §6: 代数效果处理器
     "EffectHandler", "ProductionHandler", "TestHandler", "TraceHandler",
     "get_current_handler", "set_current_handler", "with_handler",
+    # Paper III §4.3: 分级成本预测
+    "CostGrade", "estimate_cost", "format_cost_estimate",
+    "grade_serial", "grade_parallel", "grade_iterate", "grade_guard",
+    # Paper II: 代数定律重写
+    "optimize_agent", "RewriteLog", "RewriteEntry",
+    # Paper II: CEK 机器
+    "AgentCEKMachine", "CostVector", "CostMonotonicityViolation",
     # 辅助设施
     "Dataset",
     "from_config", "build_agent", "describe_config",