コンテンツにスキップ

依存レイヤー

src/ は六つの layer (L0–L5) に分かれています。dependencies は upward only です。higher layer から lower layer への import は許可されず、review と architecture checks で捕まえます。

LayerModulesRole
L0contracts/, config/, utils/Cross-boundary types, IDs, TOML schema
L1core/memory/, core/persona/, core/providers/, core/sessions/, core/subagents/, core/experience/, core/eval/Durable state, identity, provider abstraction, shared runtime domain
L2core/tools/, security/Tool system, approval, policy, taint, governance
L3core/agent/, core/affect/, media/Turn executor, affect detection, multimodal processing
L4runtime/services/, runtime/diagnostics/, runtime/observability/Composition root, DI, telemetry
L5transport/, cli/, platform/, plugins/, ui/, onboard/Gateway, channels, CLI, desktop plugins

layering が守る property は一つです。continuity state (L1) は、それを読んでいる surface を知らない。

  • Memory、persona、sessions は transport/cli/ を import しません。Discord message の形や HTTP request の形に accidental coupling しません。
  • Core agent logic (L3) は security / tool layer (L2) を飛び越えて channel と直接話しません。
  • Transports (L5) は、新しい channel、desktop panel、新しい gateway route などに変わっても、それが表示する state を触らずに変えられます。

この barrier が porous だと、runtime は一回の refactor で Discord-shaped memory や gateway-flavored persona に近づきます。layering は shared turn pipeline を honest に保つための仕組みです。

すべては src/runtime/services/ で wire されます。この module は次を行います。

  • auth、security policy、memory、rate limiter を初期化する
  • provider を build する。provider は reliability と OAuth recovery layers で wrap される
  • tool registry を assemble する
  • every tool call に渡す ExecutionContext を construct する

composition root はすべての pieces を同時に知る唯一の場所です。他の module は narrow slice だけを見ます。

module boundaries で特に重要なのは三つの traits です。

  • MemoryMemoryWriter (append_event)、MemoryReader (recall_scoped, resolve_slot)、MemoryGovernance (health_check, forget_slot) を合わせた supertrait。backends は PostgreSQL (default) または Markdown fallback。
  • Toolname()description()parameters_schema()execute(args, ctx)core/tools/registry.rs に registered。
  • Provider — required method は chat_with_system()ReliableProvider (retry + circuit-breaker) と OAuthRecoveryProvider で wrap される。implementations は Anthropic、OpenAI、OpenRouter、Ollama、Gemini。

この三つは cross-layer communication の主要 contract です。変更を trace していてここに辿り着いたなら、正しい境界を見ています。

experimental または retired code は、active module tree から export され architecture checks で守られていない限り、production layering contract の一部ではありません。現在の companion runtime は上の layers が所有します。古い planner、simulation、evolution surfaces は product-bearing entrypoints ではありません。