← /geode/portfolioGEODE . 문서
GitHub
GEODE 운영
레퍼런스

라이프사이클

Bootstrap, serve, shutdown. core/wiring/와 core/runtime.py가 데몬의 수명을 구동하고, 시그널 기반 종료를 처리하며, 라이프사이클 훅 이벤트를 발화합니다.

다섯 단계

1. Bootstrap     — read config, init paths, register hooks, set ContextVars
2. Wire          — start MCP servers, load tools, discover skills
3. Serve         — listen on IPC, accept commands, drive AgenticLoop
4. Drain         — finish pending tool calls, flush queues, close LLM clients
5. Shutdown      — close IPC socket, write session log, exit

진입점

파일역할
core/runtime.py최상위 bootstrap()
core/wiring/ (7 modules)각 단계 구현과 시그널 핸들러
core/server/ (10 modules)IPC 리스너, 요청 디스패치, 데몬 메인 루프

시그널

  • SIGTERM. graceful drain 후 shutdown.
  • SIGINT. 현재 LLM 호출을 중단 (UserCancelledError 전파). 데몬은 유지.
  • SIGHUP. 설정 재로드 (환경 변수, 모델 레지스트리).

Client capability handshake (v0.84+)

Thin CLI가 IPC로 데몬에 연결되는 즉시 client_capability 메시지를 보냅니다.{"type": "client_capability", "is_tty": bool, "width": int}. 데몬은 이 값을 사용해 per-thread Rich Console을 구성합니다. non-TTY 클라이언트에선 ANSI escape와 spinner frame이 자동 suppress 됩니다.

# core/cli/ipc_client.py
def _send_client_capability(self) -> None:
    """Send terminal capability to the daemon."""
    is_tty = sys.stdin.isatty() and sys.stdout.isatty()
    width = shutil.get_terminal_size((80, 24)).columns
    self._send({
        "type": "client_capability",
        "is_tty": is_tty,
        "width": width,
    })

# core/server/ipc_server/poller.py
# receives client_capability and stores it per-connection

ContextVar 배선

Bootstrap은 현재 세션, 현재 모델, 현재 사용자 프로파일, 현재 훅 시스템에 대한 ContextVar 인스턴스를 설정합니다. 에이전틱 루프와 도구 핸들러는 인자로 받지 않고 get_*() 액세서로 읽습니다.

CLAUDE.md의 안티 패턴 한 가지. bootstrap에 대응하는 set_*()가 없는 get_*() 액세서는 조용히 None을 반환하고, 의존 기능은 조용히 degrade 됩니다. CLAUDE.md의 Wiring Verification 표가 이를 막는 게이트입니다.

발화되는 훅 이벤트

  • SESSION_START. bootstrap 종료 시점.
  • SESSION_END. drain 시작 시점.
  • MODEL_SWITCHED. /model 회전 시점.
  • CONTEXT_RESET. /clear 실행 시점.

Cold start (v0.85~v0.89)

v0.85 ~ v0.89 동안 다수의 SDK (anthropic, numpy, pydantic, importlib.metadata 등)를 lazy load로 전환했습니다. 결과: cold start 누적 −258ms, warm cold-start −86% (~33ms). modules 341 → 167 (−174). wiring 모듈 (이전 lifecycle)이 lazy import의 1차 게이트 역할을 합니다.

크래시 복구

데몬에서 잡히지 않은 예외는 요청 디스패처 최상단에서 포착되고, 전체 traceback과 함께 로깅되며, 구조화된 오류 프레임이 CLI로 반환됩니다. 데몬은 살아있고, 실패한 호출만 죽습니다. geode serve --auto-restart로 실행하면 하드 크래시 시 재spawn 합니다.