Skip to main content

Module codec

Module codec 

Source
Expand description

The world codecs (docs/ONTOLOGY.md §2.5, §3): a home folder ⇄ [World].

folder is our own flavor and the Hermes flavor of the same file layout (a profile folder IS a Hermes home); hermes writes a Hermes home back; openclaw compiles and decompiles an OpenClaw state directory. The decoders in decode are strict for O-records (unknown key = error) and residue-keeping for H-records, exactly as docs/ORCHESTRATOR-IR.md §1 rule 1 states; canonical is the snapshot every “unchanged” decision compares; sqlite opens stores read-only and writes fresh files.

Re-exports§

pub use canonical::canonical_json;
pub use canonical::sort_keys;
pub use decode::LoadError;
pub use folder::carry_unmodeled;
pub use folder::load_home;
pub use folder::save_home;
pub use folder::Flavor;
pub use folder::LoadedHome;
pub use folder::ProfileIo;
pub use hermes::from_hermes;
pub use hermes::to_hermes;
pub use hermes::HermesReport;
pub use hermes::Refusal;
pub use openclaw::from_openclaw;
pub use openclaw::to_openclaw;
pub use openclaw::OpenclawLoaded;
pub use openclaw::OpenclawReport;

Modules§

canonical
The canonical JSON every snapshot and “unchanged” decision compares: keys sorted at every depth, two-space pretty print, trailing newline — ir.mjs::canonicalJson. Sorting is explicit because serde_json’s own object order depends on a cargo feature another crate may enable.
decode
Strict decoders and canonical encoders for every record’s FILE form (ir.mjs). O-records refuse an unknown key by file and key; H-records keep what they do not model in residue.
dotenv
.env in a profile folder is the vault’s store: KEY=value, quotes stripped on read, JSON-quoted on write, sorted by key.
folder
The folder codec: a home folder ⇄ World. The root is the default profile; profiles/<name>/ are the named ones; a profile folder is a complete home (Hermes’s rule). Two flavors of the same layout:
hermes
A Hermes home written from the world (hermes.mjs::toHermes). Tiers per file: byte for cron/jobs.json, cron/executions.db, webhook_subscriptions.json (inline secrets re-inlined from the vault), config.yaml when unchanged, every unmodeled file, and state.db when bindings/obligations are UNCHANGED since import (copied). state.db with changed rows is REFUSED: the Hermes session-store write path is behind UNI-22. Semantic for SOUL.mdAGENTS.md and a re-rendered config.yaml (the O-blocks ride as top-level keys — ORC-1 F5).
openclaw
The OpenClaw codec (openclaw.mjs): an OpenClaw state directory ⇄ the world. agents.* become profiles — the default agent IS the default profile, every other agent keeps its id — each rooted at its own agents/<id>/. Channels, bindings and hooks are install-wide and land on default; jobs, fires and obligations land on the profile their agent id or session key names. openclaw.json is JSON5 (comments and trailing commas survive the read; a re-emit is JSON, which OpenClaw’s parser loads); state/openclaw.sqlite is the pinned v2026.7.1-2 schema, its rows written back column for column when their record is unchanged.
sqlite
SQLite primitives (sqlite.mjs): readers open read-only — the contract every supercode reader keeps over a live store — and writers create fresh files. Rows are read as JSON objects so the codecs see the same shapes the Node package saw.