Skip to content

perf: expose Czech bank-code membership - #176

Merged
jan-kubica merged 1 commit into
mainfrom
feat/cz-bank-code-membership
Jul 28, 2026
Merged

perf: expose Czech bank-code membership#176
jan-kubica merged 1 commit into
mainfrom
feat/cz-bank-code-membership

Conversation

@jan-kubica

@jan-kubica jan-kubica commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • expose the generated Czech bank-code catalog through a narrow allocation-free Rust API
  • preserve catalog ownership in stella-stdnum-core for callers that already parse account syntax
  • lock the hot path to zero allocations

Validation

  • cargo test --workspace --all-features
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • bun run lint
  • bun run typecheck
  • bun run codegen:check
  • bun run format:check
  • bun test

Summary by CodeRabbit

  • New Features
    • Added an allocation-free check for determining whether a four-digit Czech bank code is assigned.
    • The check now clearly indicates that its result should be used, helping prevent accidental misuse.
  • Documentation
    • Improved documentation describing the Czech bank-code assignment check.
  • Tests
    • Added coverage confirming expected results for valid and unassigned sample bank codes.
    • Verified that the check performs without memory allocation.

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3daccbb7-3f77-4e94-b3ab-34e7308477b5

📥 Commits

Reviewing files that changed from the base of the PR and between 5c35d1a and 9b65f60.

📒 Files selected for processing (3)
  • .changeset/lean-bank-code.md
  • crates/stdnum-core/src/validators/cz/bankaccount.rs
  • crates/stdnum-core/tests/canonical_fast_path.rs
📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Bindings and packages
  • GitHub Check: Oracle
  • GitHub Check: Rust
  • GitHub Check: Pack
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{rs,ts,tsx,py}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Keep Node.js, WASM, and Python bindings as thin adapters over the single Rust implementation; do not hand-write validator logic in bindings.

Files:

  • crates/stdnum-core/tests/canonical_fast_path.rs
  • crates/stdnum-core/src/validators/cz/bankaccount.rs
crates/**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

crates/**/*.rs: Register every new validator in the Rust catalog.
Add Rust unit-test, property-test, and shared-fixture coverage for every new validator.

Files:

  • crates/stdnum-core/tests/canonical_fast_path.rs
  • crates/stdnum-core/src/validators/cz/bankaccount.rs
**/*.{ts,tsx,js,jsx,rs}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx,rs}: Prefer explicit designs, fail fast at boundaries, return or throw early, and minimize brace nesting with early returns.
Use named constants instead of string literals for domain values.

Files:

  • crates/stdnum-core/tests/canonical_fast_path.rs
  • crates/stdnum-core/src/validators/cz/bankaccount.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Use Rust 2024 for new crates, pin the toolchain in rust-toolchain.toml, and keep rustfmt and clippy installed.
Forbid unsafe code by default; if required, isolate it in a small module and document the invariant with a SAFETY: comment.
Production Rust must not use unwrap(), expect(), panic!(), todo!(), or unimplemented!(); use typed errors or make impossible states unrepresentable.
Avoid unchecked indexing, string slicing, and unchecked as casts; use safe accessors, UTF-8-safe APIs, TryFrom, checked conversions, and domain newtypes.
Prefer narrow domain types over primitive strings or numbers, keep struct fields private unless public construction is contractual, and use smart constructors for invariants.
Use enums for closed domain states; use options structs or bon builders for named arguments and APIs with many optional parameters.
Prefer Result<T, E> with concrete error enums for library code, using thiserror; use miette only for human-facing diagnostics.
Add #[must_use] to builders, configuration transforms, computed results, and APIs whose ignored result is likely a bug.
Keep comments concise and document invariants, non-obvious algorithms, generated contracts, and safety boundaries rather than narrating obvious code.
Keep domain dictionaries, language rules, fixtures, and generated artifacts out of code and in reproducible data files or build outputs.
Public Rust docs, logs, diagnostics, and comments must write stella in lowercase.
Extensible analyzers, detectors, linters, and validators should use module-owned declarative rule specifications; central registries should remain thin and preserve ordering and iteration only.
Avoid expensive module initialization and library-import side effects such as filesystem, network, environment, or global logger setup; applications and CLIs own process-level effects.
Use cargo nextest run --workspace --all-features when available, otherwise the repository's documented test command; ...

Files:

  • crates/stdnum-core/tests/canonical_fast_path.rs
  • crates/stdnum-core/src/validators/cz/bankaccount.rs
**/*.{rs,ts,py}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{rs,ts,py}: Binding layers should remain thin: business logic belongs in the Rust core, while TypeScript, Python, WASM, and NAPI layers translate types and call shared core logic.
Generated artifacts must be versioned and validated at load time, rejecting stale, mismatched, or oversized artifacts with typed errors.
Test only behavior that can actually fail beyond guarantees from the type system, framework, or linter; prefer invariants over examples for large input spaces.
Do not snapshot sensitive raw text unless fixtures are intentionally public and minimal; prefer normalized summaries, counts, spans, labels, and redacted output.

Files:

  • crates/stdnum-core/tests/canonical_fast_path.rs
  • crates/stdnum-core/src/validators/cz/bankaccount.rs
**/*.{rs,ts}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{rs,ts}: Use property and mutation testing for checksum behavior and differential testing of specialized canonical validators against the full validator.
Canonical ASCII validation must be zero-allocation, byte-oriented, single-pass, and return NotCanonical when normalization would change input; keep Unicode normalization as the compatibility fallback.
Separate validation status from presentation: kernels return compact statuses and typed error codes, while bindings create strings, objects, exceptions, and diagnostics only when required.
Keep binding calls coarse through indexed dispatch and batch operations, and treat performance as a tested contract with deterministic allocation assertions and controlled normalized benchmarks.

Files:

  • crates/stdnum-core/tests/canonical_fast_path.rs
  • crates/stdnum-core/src/validators/cz/bankaccount.rs
**/*.{ts,tsx,rs}

📄 CodeRabbit inference engine (AGENTS.md)

Preserve per-country module boundaries and public export paths; package exports are public API.

Files:

  • crates/stdnum-core/tests/canonical_fast_path.rs
  • crates/stdnum-core/src/validators/cz/bankaccount.rs
crates/stdnum-core/src/validators/**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Implement new identifier validators under crates/stdnum-core/src/validators/.

Files:

  • crates/stdnum-core/src/validators/cz/bankaccount.rs
🔇 Additional comments (3)
crates/stdnum-core/src/validators/cz/bankaccount.rs (1)

235-240: LGTM!

crates/stdnum-core/tests/canonical_fast_path.rs (1)

224-234: LGTM!

.changeset/lean-bank-code.md (1)

1-5: LGTM!


📝 Walkthrough

Walkthrough

The Czech bank-code predicate now has public documentation and #[must_use] enforcement. Tests verify assigned-code results and zero allocations, reallocations, and allocated bytes. A Changesets entry records a patch release for @stll/stdnum.

Changes

Czech bank-code API

Layer / File(s) Summary
Predicate contract and allocation validation
crates/stdnum-core/src/validators/cz/bankaccount.rs, crates/stdnum-core/tests/canonical_fast_path.rs, .changeset/lean-bank-code.md
is_assigned_bank_code is documented and marked #[must_use]; tests cover codes 800 and 1124 and verify zero allocation activity. A patch release note is added.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • stella/stdnum#170: Introduced the Czech bank-code helper whose documentation and allocation-free behaviour are extended here.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: exposing Czech bank-code membership checks, with the performance focus implied by the prefix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cz-bank-code-membership

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jan-kubica
jan-kubica merged commit 5059ce8 into main Jul 28, 2026
13 checks passed
@jan-kubica
jan-kubica deleted the feat/cz-bank-code-membership branch July 28, 2026 21:06
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant