Skip to main content

Module cml_context

Module cml_context 

Source
Expand description

Rust-native CML context graph + COF HTML+RDFa for the hypermedia Library.

Goal: every ingested document (legislation, notes, policies, contracts) gets a TEXT → CONCEPT → LOGIC layer that is honest about provenance:

  • All machine output is cml:Proposed (never cml:Attested).
  • Structure + signal extraction is deterministic (no Python, no Ollama required).
  • Deontic cues compile into real NQuin norms (OP_OBLIGATE / OP_PERMIT / OP_FORBID).
  • Privacy / GDPR-family / rights / temporal / cross-ref signals become topics + graph edges.
  • COF (cof_html) serialises the same graph as HTML+RDFa for agent windows, with token-bounded segments (index + body packs) when a document is large.

Optional local LLM enrichment can attach later on the same ContextUnit surface; the product path stays pure Rust.

Structs§

CmlConcept
A proposed concept in the CML layer.
CmlContextGraph
Full context graph for a document or provision.
CofPackage
A complete COF package: index + ordered body segments.
CofSegment
One COF HTML segment (self-contained HTML document, RDFa-complete).
ContextUnit
One structural unit (section, heading block, or paragraph cluster).
SignalHit
A named signal hit (privacy family, rights, etc.).

Enums§

CofStyle
DeonticClass
Proposed deontic class for a provision / paragraph.
PrivacySignal
Privacy / data-protection family (GDPR-like and cognates).

Constants§

COF_PROFILE
Official COF HTML+RDFa profile (must match cof.n3 / legis2cml).
DEFAULT_SEGMENT_MAX_CHARS
Default agent body-segment budget (~6–8k tokens at ~4 chars/token; leave headroom).
MEDIA_TYPE_COF

Functions§

build_cof_package
Build a full COF package (index + body segments) for agent token optimisation.
build_document_context
Build a multi-unit CML context graph for a document.
build_unit_context
Build CML context for a single unit (provision or paragraph).
classify_deontic
Classify deontic force from English legislative / policy phrasing.
extract_cross_refs
Cross-references to other provisions / instruments.
extract_privacy_signals
Extract GDPR-like / privacy-family signals.
extract_rights_signals
Human-rights / civil-rights cues (broader than privacy).
extract_temporal_signals
Temporal / LTL-ish cues (commencement, deadlines).
pack_units_into_segments
Pack units into COF segments under a character budget (section-aligned).
render_cof_document
Single-document COF (no multi-segment) — still valid html-rdfa-1.
render_unit_fragment
Render one unit as a COF section fragment (no document chrome).
units_from_headings
Split plain text into heading-aware units (Markdown # / ALL-CAPS lines / blank-line blocks).
units_from_paragraphs
Fallback: split on blank lines into paragraph units (max 64).