Skip to content

fix(walk): read version strings the way keripy's smell does - #6

Merged
dhh1128 merged 1 commit into
mainfrom
fix/version-smell
Oct 13, 2026
Merged

dhh1128 merged 1 commit into
mainfrom
fix/version-smell

Conversation

@dhh1128

@dhh1128 dhh1128 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Ports two version-string fixes from the signify-ts copy of this walker, where Kent Bull found them in review (WebOfTrust/signify-ts#413). Both bugs exist here too.

The v1 version digits were matched as decimal, so a valid token like KERI1aJSON00012b_ (protocol version 1.10) was not recognised as a version string at all. keripy's VEREX1 reads them as hex, as it does the size, and VersionValue already did.

parseVersion searched a 128-byte window and tried the v2 layout first, so a version-like string inside a field value could take over the outer message's framing. {"v":"KERI10JSON000033_","x":"KERICAACAAJSONAAD_."} was framed as a 255-byte v2 message starting at byte 30 and reported as recoverably incomplete. It now does what keripy's smell does: one combined v2|v1 search for the earliest token, rejected if it starts more than MAXVSOFFSET (8) bytes in, with the window read one character per byte so that offsets are byte offsets.

When fewer than SMELLSIZE (27) bytes remain and no token is found, the result is incomplete rather than a permanent no-version-string, because the token may be cut off. Short garbage in the viewer therefore reads as too short rather than as not CESR. The tests that used 7-byte garbage now use input long enough to rule a token out.

Type renames and the body/attachments restructure from #413 are left for a later PR.

Tests: tsc clean; vitest 238 passed, 8 skipped. New tests are in src/cesr/__tests__/walk.test.ts under "version-string smelling (keripy smell)".

🤖 Generated with Claude Code

https://claude.ai/code/session_01WRfCuQNE3iHSDxqvPGMUez

Two bugs, both found by Kent Bull in the signify-ts copy of this walker
(WebOfTrust/signify-ts#413) and present here too.

The v1 version digits were matched as decimal, so a valid token like
`KERI1aJSON00012b_` (protocol version 1.10) was not a version string at
all. keripy's VEREX1 reads them as hex, like the size; VersionValue
already did.

parseVersion searched a 128-byte window and tried the v2 layout first, so
a version-like string inside a field value could take over the outer
message's framing: `{"v":"KERI10JSON000033_","x":"KERICAACAAJSONAAD_."}`
framed as a 255-byte v2 message from byte 30 and was reported as
recoverably incomplete. It now does what smell does: one combined v2|v1
search for the earliest token, rejected if it starts more than
MAXVSOFFSET (8) bytes in, with the window read one character per byte so
offsets are byte offsets. When fewer than SMELLSIZE bytes remain and no
token is found, the result is `incomplete` rather than a permanent
`no-version-string`, since the token may be cut off. Short garbage in the
viewer therefore reads as too short rather than as not CESR; the tests
that used 7-byte garbage now use input long enough to rule a token out.

Claude-Session: https://claude.ai/code/session_01WRfCuQNE3iHSDxqvPGMUez
Signed-off-by: Daniel Hardman <daniel.hardman@gmail.com>
dhh1128 added a commit that referenced this pull request Oct 13, 2026
…incomplete (#6 hostile pass). Under SMELLSIZE (27) bytes with no version token, walk() returns incomplete/permanent:false even when no offset 0..8 could start a token (e.g. 26 '@' bytes). Faithful to keripy smell (ShortageError on len<SMELLSIZE, kering.py:227), where the cold-start ColdCodex sniff on byte 0 rejects garbage first. Fix: add a cold-start first-byte sniff, or a prefix-feasibility check that returns no-version-string once no position <= MAXVSOFFSET can still begin [A-Z]{4}.

Signed-off-by: Daniel Hardman <daniel.hardman@gmail.com>
@dhh1128
dhh1128 merged commit 6f678a8 into main Oct 13, 2026
4 checks passed
@dhh1128
dhh1128 deleted the fix/version-smell branch October 13, 2026 03:58
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