Skip to content

feat(parsing): frame CESR 2.0 (v2) streams (stacked on #402) - #403

Open
dhh1128 wants to merge 2 commits into
WebOfTrust:mainfrom
dhh1128:feat/cesr-stream-parser-v2
Open

feat(parsing): frame CESR 2.0 (v2) streams (stacked on #402)#403
dhh1128 wants to merge 2 commits into
WebOfTrust:mainfrom
dhh1128:feat/cesr-stream-parser-v2

Conversation

@dhh1128

@dhh1128 dhh1128 commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Adds CESR 2.0 / KERI 2.x support to the stream parser introduced in #402.
The parser now frames both CESR-1 and CESR-2 streams to the same resilience
posture, ground-truthed against keripy 2.0.0-dev6.

Stacked on #402. This branch is based on feat/cesr-stream-parser, so
until #402 merges the diff here shows both commits; the change owned by this
PR is the second commit (feat(parsing): frame CESR 2.0 (v2) streams via genus dispatch). Please review/merge #402 first — this will then narrow to just the
v2 commit and can retarget cleanly onto main.

What it does

  • parseVersion now parses the v2 version string
    (proto + protocol-version + embedded CESR-genus-version + kind +
    base64 size + . terminator) and returns the genus.
  • frameGroup dispatches by CESR genus. Native v2 counter framing (from
    keripy's CtrDex_2_0) is added because signify-ts's Counter carries only the
    v1 table and silently misframes v2 codes — they collide with v1 code
    strings but denote different groups (e.g. v1 -C is NonTransReceiptCouples;
    v2 -C is the AttachmentGroup wrapper). Every v2 group counts its body in
    quadlets, so it self-frames as count*4 bytes: decomposition is uniform,
    even unrecognized codes are unknown-but-framed, and the v1 -V
    resilience-boundary rule generalizes to all groups.
  • Primitives still delegate to Matter/Indexer even under v2 — primitive
    codes are genus-stable, so a v2 AID/SAID/key/signature parses unchanged.
  • AttachmentGroup gains a genus field, since a code's meaning depends on it.

Tests

Adds v2 parseVersion, framing, and resilience/corruption tests, plus a real
keripy-generated v2 witness-OOBI vector (PII-free synthetic). All four CI gates
(build, lint, pretty:check, tests) pass locally.

Provenance

Developed and proven in a downstream viewer against a corpus of keripy
2.0.0-dev6 streams, then contributed upstream.

🤖 Generated with Claude Code

dhh1128 and others added 2 commits July 21, 2026 14:32
signify-ts has the primitive classes (Matter/Counter/Indexer) and EMITS framed
streams (eventing.messagize) but has no parser that CONSUMES a stream. Add
src/keri/core/parsing.ts: a deterministic v1 stream walker that frames messages
by version-string size + attachment counters (never by sniffing a leading '{',
so binary CBOR/MGPK bodies work too), delegating all primitive/counter/indexer
sizing to the existing classes. Every node carries byte-span provenance, and the
walk is resilient — on a code it cannot frame it stops and reports, keeping
everything parsed so far. Body decoders are pluggable (JSON built in). Exported
via src/exports.ts; 30 inline keripy-vector tests in test/core/parsing.test.ts.

Scope: CESR v1 only; the v2 count/genus/version-string machinery is a separate
follow-up.

Signed-off-by: Daniel Hardman <daniel.hardman@gmail.com>
Stacks on the v1 stream parser (WebOfTrust#402): the parser now also handles CESR 2.0 /
KERI 2.x streams, ground-truthed to keripy 2.0.0-dev6.

- parseVersion parses the v2 version string (proto + protocol-version + embedded
  CESR-genus-version + kind + base64 size + '.') and returns the genus.
- frameGroup dispatches by genus. Native v2 counter framing (from keripy's
  CtrDex_2_0) is added because signify-ts's Counter carries only the v1 table and
  silently misframes v2 codes (they collide with v1 strings but denote different
  groups). Every v2 group counts its body in quadlets, so it self-frames as
  count*4 bytes — decomposition is uniform and even unrecognized codes are
  unknown-but-framed, with the -V resilience-boundary rule generalized to all
  groups. Primitives still delegate to Matter/Indexer (genus-stable).
- AttachmentGroup gains `genus`, since a code's meaning depends on it.

Adds v2 parseVersion, framing, and resilience/corruption tests, plus a real
keripy-generated v2 witness-OOBI vector. All four CI gates green locally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Hardman <daniel.hardman@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant