# Public exchange formats

Source: https://usecns.dev/engram-topic-public-exchange-formats/

[Start here](https://usecns.dev/manual-engram/)
[CLI commands](https://usecns.dev/commands-engram/)
[Configuration & integration](https://usecns.dev/engram-topics/)

For directory knowledge, author `compartments.json` as an object with a `compartments` array:

```
{"compartments":[{"compartment_id":"fixture","ring":"M2","pages":["retry.md"],"snapshot_hash":"fixture-v1"}]}
```

Each entry requires nonempty `compartment_id`, exact `ring` (`M0`/`M2`) and a nonempty literal relative `pages` list locally. Optional `frontmatter_map` is a root-relative mapping path; optional `attestation` is armored SSH signature text, not a filename. Extra descriptive keys are tolerated. Remote missing `pages` defaults to `["index.md"]`. A snapshot label is anchor metadata, not a replacement for verification of exact M0 page/map bytes. Directory compartment mapping overrides CLI mapping; remote page compilation uses the supplied CLI map, not a remotely fetched map file. Avoid remote compartment mapping unless the corresponding local verification mapping is deliberately available.

Explicit local retirements live in `keys.json`, for example `{"retired":["fixture-old",{"key":"fixture-renamed"}]}`. After pages apply, hydration processes this list only without `--compartment` and without `--check`. **Without `--ring-id`, retirement is not restricted to M2 or `--ring-filter`: all active matches can be selected.** Use an explicit target ring ID, review the list first, and expect guarded nodes to refuse retirement. Missing keys are harmless; missing pages alone never imply retirement. A malformed retirement file can fail after page writes.

Fact exchange is UTF-8 JSONL, one envelope per nonblank line: `fact_id` (nonempty string), `occurred_at_ms` (integer), `payload` (object with nonempty `fact_type`). Export rather than hand-author facts: IDs derive from memory/edge/event/receipt identity, not every metadata field. Changing metadata while reusing an ID can create a divergent duplicate, not an update.

Known tags: `memory_minted_v1`, `edge_linked_v1`, `outcome_recorded_v1`, `outcome_recorded_v2`, `graduation_changed_v1`, `graduation_changed_v2`, `guard_event_v1`, `reactivated_v1`, `revert_v1`. V2 outcomes carry optional `oracle` and object `provenance`; oracle must agree with signal. V2 graduation adds an upward-transition receipt. Guard events include session, target, violation, mode and disposition; they can reveal paths and operational activity. Streams also contain bodies/lineage/signature metadata: authorize the entire export, not just its ring label.

Malformed envelopes are hard errors. Unknown tags and known-but-uninterpretable payloads are retained verbatim for relay without application. Extra fields on an otherwise valid known fact do not prevent application and survive relay. Known facts still undergo local trust/declared-delta/derived-ID checks: do not equate tolerant decoding with admission. Import reports `newly_applied`, `duplicate_skipped`, `stored_unapplied`, category maps, `divergent_duplicates`, `deferred_applied`, `attestation_refused`, `delta_refused`, `fact_id_mismatch`, `relay_candidates`, `legacy_translated`, `pending_unheld`, claim/carry-edge verification counts and warnings. A refused delta or mismatched ID is not relayed as an admitted fact; attestation candidates may relay while awaiting a trusted signer. First admissible stored duplicate wins. Late-arriving dependencies are retried. Pull reports only a subset of the full import report; inspect stderr warnings as well.

Remote calls are HTTP(S) POST JSON-RPC `tools/call` at the exact configured endpoint. Redirects are disabled; connect/request limits are 10/60 seconds. Non-2xx, JSON-RPC errors and first-content tool errors fail. Results may be a direct `result` object or JSON in `result.content[0].text`.

| Remote tool consumed | Request arguments → response used |
| --- | --- |
| `sync_memory_facts` | `facts_jsonl`, `source_rig`, `source_seat` → hub acknowledgment, included in push report; successful transport/tool response advances push watermark, not proof of equivalent local trust. |
| `export_memory_facts` | `since_sequence_id`, optional `ring_id` → `facts_jsonl`, integer `next_sequence_id`; pull imports then advances per-URL cursor. Missing stream/cursor currently fall back to empty/previous cursor; run conformance to check actual hub shapes. |
| `list_knowledge_compartments` | Optional `ring_filter` → object containing `compartments` as above. |
| `read_knowledge_page` | `compartment_id`, `page` → `content_markdown`, optional `snapshot_hash`; an empty/missing body is skipped for ordinary M2 hydration. |

No local MCP tool serves these four remote contracts. Conformance checks stricter shapes/semantics than ordinary tolerant client fallbacks and replays exported facts; it is not a read-only network inspection.