feat(parsing): frame CESR 2.0 (v2) streams (stacked on #402) - #403
Open
dhh1128 wants to merge 2 commits into
Open
feat(parsing): frame CESR 2.0 (v2) streams (stacked on #402)#403dhh1128 wants to merge 2 commits into
dhh1128 wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.What it does
parseVersionnow parses the v2 version string(
proto+ protocol-version + embedded CESR-genus-version +kind+base64
size+.terminator) and returns the genus.frameGroupdispatches by CESR genus. Native v2 counter framing (fromkeripy's
CtrDex_2_0) is added because signify-ts'sCountercarries only thev1 table and silently misframes v2 codes — they collide with v1 code
strings but denote different groups (e.g. v1
-CisNonTransReceiptCouples;v2
-Cis theAttachmentGroupwrapper). Every v2 group counts its body inquadlets, so it self-frames as
count*4bytes: decomposition is uniform,even unrecognized codes are unknown-but-framed, and the v1
-Vresilience-boundary rule generalizes to all groups.
Matter/Indexereven under v2 — primitivecodes are genus-stable, so a v2 AID/SAID/key/signature parses unchanged.
AttachmentGroupgains agenusfield, since a code's meaning depends on it.Tests
Adds v2
parseVersion, framing, and resilience/corruption tests, plus a realkeripy-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-dev6streams, then contributed upstream.🤖 Generated with Claude Code