Skip to content

refactor(#57): kill the utils dumping grounds + cohesive b64 (naming + error de-collision)#62

Merged
joeldsouzax merged 10 commits into
mainfrom
refactor/57-consolidate-utils
Jul 2, 2026
Merged

refactor(#57): kill the utils dumping grounds + cohesive b64 (naming + error de-collision)#62
joeldsouzax merged 10 commits into
mainfrom
refactor/57-consolidate-utils

Conversation

@joeldsouzax

Copy link
Copy Markdown
Contributor

Summary

Completes the remaining #57 work (PR #60 delivered only part 1, the utils/b64/ rename). Design-first: spec + plan under docs/superpowers/. Seven gated, behaviour-preserving commits — the full suite (1679 tests) and keripy_diff differential vectors stay green throughout.

  • Killed both remaining "utils" dumping grounds. src/stream/util.rs and src/core/utils.rs are deleted, their contents rehomed.
  • b64 is now a pure, dependency-free primitive leaf with a single byte lookup b64::alphabet::b64_byte_to_index and the encode_int/decode_int codec pair. The char lookup, stream::util::b64_char_to_value, and stream::binary::b64_val (the Base64 char→value lookup was triplicated) collapse to that one primitive. The integer encoder (also triplicated: b64::encode_int, stream::util::int_to_b64, a hand-rolled indexer copy) now routes through b64::encode_int everywhere.
  • qb64↔qb2 stays code-aware in stream (deliberate deviation from the issue's literal "b64 owns qb64↔qb2" — keeps b64 a leaf; mirrors keripy's _infil/_binfil living on Matter). stream/binary.rsstream/qb2.rs.
  • Code-size lookups moved from core/utils.rs to core/matter/code/hard.rs (co-located with their only caller).
  • Error de-collision: indexer::error::{ParseError, ValidationError}{IndexerParseError, IndexerValidationError}, so stream::ParseError and matter::ValidationError are now each defined exactly once. Per-module error enums are kept (documented rule).
  • Docs: CLAUDE.md module table (utilsb64) + new Naming Conventions section; CHANGELOG breaking-change entries.

Breaking changes

  • b64::decode_to_intb64::decode_int (input bound widened AsRef<str>AsRef<[u8]>).
  • b64::alphabet::b64_char_to_index (char) → b64_byte_to_index (u8).
  • core::indexer::error::{ParseError, ValidationError}{IndexerParseError, IndexerValidationError}.
  • stream::util module removed (int_to_b64/b64_to_int gone — use b64::encode_int/b64::decode_int).
  • stream::binary module renamed stream::qb2 (the re-exported stream::qb64_to_qb2/stream::qb2_to_qb64 paths are unchanged).

Test plan

  • nix flake check green (clippy across features, nextest 1679, wasm, no_std, doctest, typos, deny, audit, fmt, taplo)
  • keripy_diff differential vectors green (proves byte-identical output vs the keripy reference)
  • Whole-branch review: READY TO MERGE

Closes #57.

🤖 Generated with Claude Code

joeldsouzax and others added 10 commits July 2, 2026 16:15
…r cleanup

Approved design for the remaining #57 work (PR #60 delivered part 1). Locks two
decisions: keep per-module error enums (de-collide names), and keep b64 a pure
primitive leaf with qb64<->qb2 staying code-aware in stream. Refs #57

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…er de-collision)

Plan for the remaining #57 work in 7 gated behaviour-preserving tasks. Spec
refined during planning: b64_byte_to_index becomes the single lookup primitive
(char version was only used by decode), and error de-collision renames only
indexer's two enums (resolves both clashes, avoids ~92 edits in matter/). Refs #57

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b64_char_to_index -> b64_byte_to_index (the single byte lookup primitive);
decode_to_int -> decode_int with AsRef<[u8]> input. Behaviour-preserving.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
int_to_b64 -> b64::encode_int; b64_to_int -> b64::decode_int. Kills the
second 'utils' dumping ground.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…_val

qb2.rs owns qb64<->qb2; its private b64_val is deleted in favour of
b64::alphabet::b64_byte_to_index. Public stream::qb64_to_qb2 path unchanged.
Also fixes benches/matter.rs (used the old stream::binary module path
directly) and rewords a stream::binary reference in a b64::alphabet.rs
doc comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deletes the third 'utils' dumping ground (core/utils.rs); co-locates the
hard-size lookups with their only caller, matter_code.rs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Removes the last hand-rolled Base64 integer encoder.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
BREAKING: de-collides the two error-enum name clashes (stream::ParseError and
matter::ValidationError are now unique). Variants and messages unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codspeed-hq

codspeed-hq Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 17 untouched benchmarks


Comparing refactor/57-consolidate-utils (6bb950f) with main (3160e69)

Open in CodSpeed

@joeldsouzax joeldsouzax enabled auto-merge (squash) July 2, 2026 16:13
@joeldsouzax joeldsouzax merged commit 856f6be into main Jul 2, 2026
6 checks passed
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.

Restructure modules + naming (kill the three 'utils' dumping grounds; cohesive Base64 module)

1 participant