Skip to content

feat: migrate validated usage kernels to Rust - #75

Merged
softmaxe merged 3 commits into
mainfrom
t3/rust-core-logic-assessment
Nov 16, 2026
Merged

softmaxe merged 3 commits into
mainfrom
t3/rust-core-logic-assessment

Conversation

@softmaxe

Copy link
Copy Markdown
Owner

Summary

Move five validated usage kernels to a statically linked Rust core while preserving Swift UI, actor ownership, SQLite transactions, history and authentication behavior.

Swift CostService / UsageRecorder
  → Rust JSON classification, Claude decoding and line streaming
  → existing Swift SQLite recording and price-book policy
  → Rust numeric pricing and reduced-row aggregation
  → existing Swift snapshots and UI

Foundation remains the Claude compatibility fallback. Aggregation preserves checked-error order, floating-point order and original Unicode key spellings.

CI installs the pinned Rust toolchain in both required macOS checks, release packaging and CodeQL's Swift build. Add build-free Rust CodeQL analysis, Cargo Dependabot updates and the repository's custom runner label for actionlint. Rust/C bridge/toolchain changes continue to require both macOS checks; documentation-only changes retain the skip path.

Evidence

  • Before: Original Swift revision f8df98b129c9138ccb9e6290d6c801e805fed1be.
    After: 1,861 Swift assertions, 20 Rust unit tests, formatting and Clippy pass. Seven lifecycle checkpoints and four workloads × seven alternating pairs match SQLite schema/rows, cursor state and snapshots.
  • Before / after initial scans: short Claude 21.861 / 15.353 ms; plain long Claude 83.578 / 44.452 ms; dense escapes 401.844 / 277.387 ms; Codex 23.317 / 23.089 ms. Synthetic warm-filesystem measurements include FFI, SQLite, pricing and snapshot construction; they are not whole-app speedup claims.
  • Before / after UI: 32 paired offscreen PNGs are byte-identical with the same sample clock; UI sources are unchanged. Startup is effectively equal.
  • CI validation: actionlint and shell syntax pass; all-target Swift build succeeds with CodeQL's fresh --scratch-path; pinned Rust setup succeeds; nine isolated classification cases pass; staged secret scans pass. Local release packaging and strict signature verification pass.

Methods, limits and reproduction: docs/rust-migration.md, docs/rust-validation.md, Scripts/validate_rust_pipeline.py.

Merge Danger

Door: two-way

No database/schema/settings migration. Reverting code and build integration restores Swift without converting stored history.

Blast Radius: core

Rust adds a compiler, C ABI and build maintenance. Small-group aggregation adds approximately 0.391 ms initial / 0.098 ms appended scan time in its isolated full-chain comparison; retained under the explicit preference for Rust at comparable performance. Bare SwiftPM/Xcode package builds require the documented wrapper integration. Real credentials, hosted release publication and new platform support are outside this validation.

@softmaxe
softmaxe enabled auto-merge (squash) November 16, 2026 12:02
@softmaxe
softmaxe disabled auto-merge November 16, 2026 12:03
@softmaxe
softmaxe enabled auto-merge (squash) November 16, 2026 12:04
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@softmaxe
softmaxe merged commit 96fc2af into main Nov 16, 2026
11 of 13 checks passed
@softmaxe
softmaxe deleted the t3/rust-core-logic-assessment branch November 16, 2026 12:09
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.

2 participants