Expand description
Lifecycle telemetry readers.
Lifeloop owns lifecycle-relevant telemetry parsing for harness adapters.
Clients (CCD, RLM, and other lifecycle clients) consume neutral
PressureObservation snapshots instead of writing per-harness log
readers themselves.
§Boundary (issue #5)
This module owns:
- parsing harness-native session/telemetry artifacts into a neutral
PressureObservation(adapter id, observed time, model name, token counts, context window, compaction signal), - the env-var resolution rules used to locate those artifacts and to
override their parsed values (with
LIFELOOP_*aliases winning over the compatibilityCCD_*inputs), - a neutral telemetry
TelemetryErrortype whose variants name the lifecycle failure classes (telemetry_unavailable, hook_protocol_error, internal_error).
This module does not own:
- receipt emission (callers translate
TelemetryErrorinto acrate::LifecycleReceipt), - the placement/payload pipeline (issue #4 owns asset rendering),
- adapter manifest registration (issue #6 owns the manifest registry —
this module merely reports
supportstates the registry can attach to acontext_pressureclaim), - the hook protocol command strings (issue #3),
- lifecycle routing (issue #7),
- any client-side state, prompt semantics, or continuity vocabulary. Specifically: no memory, recall, promotion, compaction policy, radar, or governance reasoning. Lifeloop reports the signal; clients decide what it means.
§CCD compatibility
Existing CCD_* env vars (e.g. CCD_CLAUDE_HOME,
CCD_CONTEXT_WINDOW_TOKENS, CCD_HOST_MODEL) are honored as
compatibility inputs through lifeloop.v0.x. Each has a
LIFELOOP_* alias; when both are set, the LIFELOOP_* value wins
and a single bounded warning is recorded per resolved key per
process. Removal criteria are tracked in
docs/tombstones/lifeloop.v0.md.
Modules§
- claude
- Claude Code lifecycle telemetry reader.
- codex
- Codex CLI lifecycle telemetry reader.
- gemini
- Gemini CLI lifecycle telemetry reader.
- host
- Host-adapter dispatch and shared env aliases for telemetry readers.
- opencode
- OpenCode lifecycle telemetry reader.
Structs§
- EnvAlias
- A single CCD→Lifeloop env-var alias.
- EnvPrecedence
Warning - Bounded warning emitted once per resolved alias when both
LIFELOOP_*andCCD_*are set. Thelifeloopvalue wins; theccd_compatvalue is shadowed. - EnvWarning
Sink - Sink for env-precedence warnings.
- Pressure
Observation - A neutral lifecycle-pressure observation extracted from harness
telemetry. Carries everything a
context.pressure_observedevent or a receipttelemetry_summaryneeds, with no harness-private fields. - Token
Usage - Per-side token usage breakdown. All fields default to zero so the type
stays format-agnostic for
Deserialize.
Enums§
- Telemetry
Error - Telemetry-side errors. The variants name the failure classes the spec uses for telemetry-derived receipts:
Constants§
- GENERAL_
CONTEXT_ WINDOW_ ALIASES Lifeloop/CCDgeneral context-window fallback. Adapter readers should consult their adapter-specific alias first, then fall back to this. The general fallback exists so users with custom or local setups don’t have to set a runtime-prefixed env var.- GENERAL_
HOST_ MODEL_ ALIASES - Generic host-model fallback used by every adapter when a more specific alias does not resolve.
- RECENT_
ACTIVITY_ SECS - Default recency window (seconds) for considering a telemetry artifact
fresh enough to drive a
context.pressure_observedevent. Mirrors the 30-minute threshold the CCD readers used.
Functions§
- as_u64
- Coerce a JSON value to u64, accepting both numbers and parseable strings.
- compute_
pct - env_
warning_ sink - Process-wide warning sink used by
resolve_env_stringandresolve_env_u64. Callers candrainto surface these warnings on their preferred channel. - file_
mtime_ epoch_ s - Seconds since UNIX epoch for the file’s mtime, or
Noneif the file is missing. - general_
context_ window - general_
host_ model - home_
dir - is_
recent - now_
epoch_ s - number_
key - Recursively search a JSON value for the first matching numeric value by candidate key names. Accepts both JSON numbers and stringified integers.
- resolve_
env_ string - Resolve an env-var string through the alias list. The first alias
whose
lifeloopkey is set wins; otherwise the first alias whoseccd_compatkey is set wins. Whenever an alias has both sides set, a precedence warning is recorded (once perlifeloopkey per process) regardless of which alias actually carried the resolution. - resolve_
env_ string_ with - Like
resolve_env_stringbut reads through a closure (for tests that don’t want to mutate process env). - resolve_
env_ u64 - Resolve an env alias as
u64, parsing the string form. - string_
key - Recursively search a JSON value for the first matching string by candidate key names. Descends into objects and arrays depth-first.