Skip to main content

Module validate

Module validate 

Source
Expand description

Format validators for fields the protocol declares but could not previously check (SPEC.md §F4, §F5; issues #10 and #12).

Two guarantees were unfalsifiable before this module existed:

  • Bi-temporal retrieval. valid_from / valid_to / recorded_at / as_of were free-form strings with no format rule anywhere, so a provider emitting "valid_from": "last tuesday" was fully conformant. A guarantee nothing can falsify is not a guarantee.
  • Provenance integrity. Provenance.digest was documented as the thing that lets a host detect tampering “before the frame enters a prompt”, but no grammar said which algorithms were valid, what case the hex was in, or which bytes were digested. Two independent providers would disagree and both would be “conformant”.

These validators are deliberately dependency-free — no chrono, no regex. contextgraph-types is the crate every provider in every language ports from, and each dependency it carries is one more thing an implementer has to reproduce or justify.

Constants§

DIGEST_ALGORITHMS
The digest algorithms this protocol revision defines.

Functions§

format_protocol_timestamp
Render a Unix instant (seconds since the epoch, UTC) as a protocol timestamp: the exact spelling is_protocol_timestamp accepts.
is_protocol_timestamp
Whether s is a timestamp in the protocol’s temporal profile.
is_well_formed_digest
Whether s is a well-formed content digest: <algorithm>:<lowercase hex>, e.g. sha256: followed by 64 lowercase hex characters (SPEC.md §F5).