feat(arx): base64url wire encoding (B. prefix) for chat-safe ARX - #14
Conversation
- encodeBase64url/decodeBase64url/isBase64urlEncoded and arxCompressBase64url - arxDecompress auto-detects base64url; falls back to base76 when B. is a base76 length prefix but Brotli fails - buildArxCandidates includes base64url alongside base76/base1k/baseBMP Co-authored-by: Aanish Bhirud <baanish@users.noreply.github.com>
Co-authored-by: Aanish Bhirud <baanish@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds base64url as a fourth arx wire shape, switches encoder candidate selection to shortest transport length (percent-encoded UTF‑8), updates decoder probing order and Brotli handling, and adjusts docs, benchmarks, tests, and fragment selection to include base64url ( Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Encoder
participant Brotli
participant Transport
participant Viewer
participant Decompressor
Client->>Encoder: provide payload (JSON)
Encoder->>Encoder: apply dictionary substitution
Encoder->>Brotli: compress bytes
Brotli-->>Encoder: compressed bytes
Encoder->>Transport: generate wire candidates (baseBMP, base1k, base64url, base76)
Transport-->>Encoder: compute transport lengths (percent-encoded UTF-8)
Encoder->>Transport: select shortest transport-length candidate
Encoder-->>Client: return fragment (`v1.arx.<dict>.<payload>`)
Client->>Viewer: deliver fragment
Viewer->>Decompressor: detect wire shape (prefers baseBMP, then base64url, base76, base1k)
Decompressor->>Brotli: brotli-decompress bytes
Brotli-->>Decompressor: decompressed bytes
Decompressor->>Viewer: reconstruct original JSON
Viewer-->>Client: present payload
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
Deploying agent-render with
|
| Latest commit: |
612859e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://80cac995.agent-render.pages.dev |
| Branch Preview URL: | https://cursor-arx-base64url-encodin.agent-render.pages.dev |
Code Review SummaryStatus: No New Issues | Recommendation: Merge Overview
Resolution of Existing CommentThe inline comment on line 175 regarding base64url not being automatically selectable has been addressed in this PR:
Changes Reviewed (7 files)
Implementation Quality
Files Reviewed (7 files)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3de0ca657
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const [ascii, unicode, bmp, b64url] = await Promise.all([ | ||
| arxCompress(json), | ||
| arxCompressUnicode(json), | ||
| arxCompressBMP(json), | ||
| arxCompressBase64url(json), |
There was a problem hiding this comment.
Make the new base64url ARX candidate actually selectable
Any caller that relies on encodeEnvelopeAsync to choose the best arx wire shape will still never emit the new B. form. selectCandidate ranks candidates by transportLength, and computeTransportLength treats both base76 and base64url as plain ASCII; since arxCompress encodes the same Brotli bytes with a denser 77-symbol alphabet than base64url’s 64 symbols, the base76 candidate is always no longer than arxCompressBase64url. So auto mode keeps producing the old punctuation-heavy base76 fragments, and the chat-safe base64url path introduced here is effectively unreachable unless a caller bypasses encodeEnvelopeAsync and invokes arxCompressBase64url directly.
Useful? React with 👍 / 👎.
…ection-bug fix(arx): account for chat-safe transport when selecting ARX wire form
Summary
Adds a fourth binary-to-text option inside the existing
arxcodec (not a new schema codec): base64url (A-Za-z0-9-_, no padding) with wire prefixB.so it is distinguishable from base1k/baseBMP and detectable inarxDecompress.Implementation
encodeBase64url/decodeBase64url/isBase64urlEncodedinarx-codec.tsarxCompressBase64url— same pipeline as other ARX variants (dict → brotli → encode)arxDecompresstries base64url whenisBase64urlEncoded; if Brotli fails, falls back to base76 (covers the rare case where base76’s length prefix is alsoB., e.g. 140-byte payloads)buildArxCandidatesinfragment.tsadds a base64url candidate; selection still uses smallesttransportLength(so base64url wins when percent-encoded Unicode inflates Unicode encodings)Tests & docs
tests/arx-codec.test.ts(roundtrip, emptyB., URL-safe charset, detection)docs/payload-format.md,docs/architecture.md,skills/agent-render-linking/SKILL.md, andscripts/codec-poc.mjsfor the new tierVerification
npm testnpm run lint/npm run typecheckSummary by CodeRabbit
New Features
Behavior Changes
Documentation
Tests