Skip to main content

lifeloop/
host_assets.rs

1//! Host integration asset rendering and merge behavior.
2//!
3//! Lifeloop owns the file shape, merge safety, and status reporting for
4//! lifecycle integration assets installed into harness host directories
5//! (`.claude/`, `.codex/`, `.hermes/`, `.openclaw/`). The `host apply`
6//! and `host inspect` compatibility commands route here.
7//!
8//! # Boundary (issue #4)
9//!
10//! This module owns:
11//! * rendering source/applied asset content as in-memory data,
12//! * additive-merge logic that preserves user-owned entries,
13//! * asset status reporting (`Present`/`Missing`/`Drifted`/`InvalidMode`/
14//!   `NotApplicable`),
15//! * supported-mode rules for each adapter.
16//!
17//! This module does **not** own:
18//! * the hook protocol command strings themselves (those are issue #3 —
19//!   the strings appear here only as opaque compatibility labels that the
20//!   merge logic must recognize so it can scrub stale entries);
21//! * the full adapter manifest registry (issue #6);
22//! * lifecycle routing (issue #7);
23//! * telemetry parsing (issue #5);
24//! * filesystem IO. Callers handle reads, writes, mode bits, and atomic
25//!   replace. This module is pure: it operates on `serde_json::Value`,
26//!   strings, and byte slices.
27//!
28//! # CCD compatibility
29//!
30//! The command-prefix constants and legacy recognizer patterns
31//! (`CCD_COMPAT_*`) are CCD compatibility labels — Lifeloop's first
32//! client wires its own binary into harness hooks via these prefixes.
33//! They are *not* core Lifeloop semantics: a future non-CCD client
34//! gets its own profile in the same shape. Keeping them in one place
35//! makes the compat surface auditable.
36//!
37//! # Lifecycle integration profiles (issue #26)
38//!
39//! [`LifecycleProfile`] generalizes the CCD-shaped command-prefix /
40//! managed-event surface into a per-client-profile struct. The free
41//! functions exported from this module keep their CCD-compat default
42//! behavior (they delegate to [`CCD_COMPAT_PROFILE`]); paired
43//! `*_with_profile` variants accept any profile so a future non-CCD
44//! client shape can render and merge its own lifecycle hook assets
45//! without editing core merge logic. This is the bridge contemplated by
46//! `docs/release-gates.md` for the CCD slimdown
47//! (dusk-network/ccd#723) — the slimdown lands by switching active
48//! installs from `CCD_COMPAT_PROFILE` to another profile, not by
49//! rewriting the renderer.
50
51mod merge;
52mod model;
53mod profiles;
54mod render;
55mod status;
56
57pub use merge::{
58    codex_hooks_contain_managed_lifecycle, codex_hooks_contain_managed_lifecycle_with_profile,
59    codex_hooks_feature_is_enabled, merge_claude_settings, merge_claude_settings_text,
60    merge_claude_settings_text_with_profile, merge_claude_settings_with_profile,
61    merge_codex_config_text, merge_codex_hooks, merge_codex_hooks_text,
62    merge_codex_hooks_text_with_profile, merge_codex_hooks_with_profile,
63};
64pub use model::*;
65pub use profiles::*;
66pub use render::{
67    render_applied_assets, render_applied_assets_with_profile, render_required_source_assets,
68    render_source_assets, render_source_assets_with_profile,
69};
70pub use status::{
71    aggregate_status, asset_status, byte_equal_asset_status, claude_settings_status,
72    claude_settings_status_with_profile, codex_config_status, codex_hooks_status,
73    codex_hooks_status_with_profile,
74};