Skip to content

Fix partial-prefix fallback in stream delimiter matching - #2

Draft
Tommyapi wants to merge 1 commit into
aliensense:mainfrom
Tommyapi:codex/read-until-prefix-fallback
Draft

Tommyapi wants to merge 1 commit into
aliensense:mainfrom
Tommyapi:codex/read-until-prefix-fallback

Conversation

@Tommyapi

@Tommyapi Tommyapi commented Oct 5, 2026

Copy link
Copy Markdown

read_until(b"aab") misses the delimiter in b"aaab": after the third a, the current fallback keeps progress 1 instead of 2. This change retains the longest matching prefix suffix, so the following b completes the match. It also fixes b"abac" in b"ababac".

Related: #1. Submitted as a draft for review and import into the internal tree, following CONTRIBUTING.md.

The generator considers fallback lengths in descending order, emits only the longest state for each next-byte value, and skips the byte already handled by the normal match branch. This avoids the bytecode expansion found in an earlier unsubmitted candidate. Whole-delimiter overlap rejection and the timeout/max paths remain unchanged; generated drivers are untouched.

Validation against released base 8fd8135e8781aeacbbb7939b94f09cec96e44386:

  • Linux Python 3.12: pip install -e '.[cyphal]' and nxs --version passed (nxs 1.1.0) in an isolated environment.
  • Offline actual code generation plus a bounded interpreter of the public opcode subset: 6 explicit fixtures and 3,570 short delimiter/input combinations passed. The released source failed 128 of those combinations against bytes.find.
  • 12 delimiter shapes of 32/64/96/128 bytes compiled through the emitter; 36 associated behavior cases passed. For the tested 64-byte repeated/mixed/unique shapes, sizes are 2,641 / 3,061 / 3,881 bytes, versus 3,881 for each released program. No previously in-budget tested shape crossed 4,096 bytes.
  • Tested one-byte, a5 5a, and CRLF programs remain byte-identical. Existing invalid-delimiter rejection was preserved.

The private VM tests, hardware, asynchronous byte arrival, and full driver deployment were not tested. Some 96/128-byte programs exceed 4,096 bytes in both versions; successful emitter construction is not a deployment claim. Please port the small fixtures to the internal regression suite and review the full program budget before accepting.

Prepared for ERDI TECH LTD with AI-assisted source analysis, implementation, and independent review. No ERDI hardware integration or commercial compatibility is claimed.

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