Skip to content

v0.1.4: Native gRPC transport + Reddit display fix#3

Open
Arrmlet wants to merge 5 commits intomainfrom
save_branch
Open

v0.1.4: Native gRPC transport + Reddit display fix#3
Arrmlet wants to merge 5 commits intomainfrom
save_branch

Conversation

@Arrmlet
Copy link
Copy Markdown
Collaborator

@Arrmlet Arrmlet commented Mar 22, 2026

Summary

  • Migrate from HTTP/JSON transcoding to native gRPC via tonic — eliminates the unstable ALB transcoding layer that caused frequent 500 errors and timeouts
  • Fix Reddit table/CSV display — Reddit search results now display correctly with proper field mapping (author, title, score, comments)
  • Fix cargo install command in READMEdataversedataverse-cli

Why native gRPC?

The Macrocosmos API is a gRPC service. The CLI was hitting it through an HTTP/JSON transcoding layer (ALB) that frequently goes down — the Python SDK uses native gRPC and is unaffected during these outages. This migration puts the CLI on the same transport path as the SDK.

During a 2+ hour outage on March 22, the HTTP endpoint returned 500s and timeouts while native gRPC worked the entire time.

Before (HTTP/JSON) After (Native gRPC)
Transport reqwest → HTTP/2 JSON → ALB → gRPC tonic → native gRPC
Reliability Down during ALB outages Same reliability as Python SDK
Dependency reqwest tonic + prost

Changes

  • src/api/client.rs — Rewritten to use tonic native gRPC with auth interceptor
  • build.rs — New: compiles vendored proto files via tonic-build
  • proto/sn13/v1/sn13_validator.proto — Vendored SN13 service definition
  • proto/gravity/v1/gravity.proto — Vendored Gravity service definition
  • src/display/mod.rs — Reddit display fix (source-aware field mapping)
  • Cargo.toml — Replace reqwest with tonic/prost, add tonic-build, bump to 0.1.4
  • README.md — Fix install command

Test plan

  • dv status — connects via gRPC
  • dv search x -k bitcoin -l 5 — X keyword search
  • dv search x -u @karpathy --from 2026-03-01 -l 50 — X username search
  • dv search reddit -k "machine learning" -l 5 — Reddit table display
  • dv search reddit -k politics -l 3 -o csv — Reddit CSV output
  • dv --dry-run search x -k test — dry-run mode
  • dv gravity status — gravity task listing
  • cargo build --release — release build
  • cargo test — all tests pass

🤖 Generated with Claude Code

Arrmlet and others added 5 commits March 20, 2026 18:40
The Macrocosmos API uses gRPC-Web JSON transcoding over HTTP/2, which
goes through an unstable ALB layer that frequently returns 500 errors
and timeouts. The Python SDK uses native gRPC and is unaffected.

This migration replaces reqwest HTTP calls with tonic native gRPC:
- Add vendored proto files for sn13.v1 and gravity.v1
- Add build.rs for tonic-build proto compilation
- Rewrite ApiClient to use tonic channels with auth interceptor
- Convert prost_types::Struct responses to serde_json::Value
- Map gRPC status codes to user-friendly error messages
- All command/display/config layers unchanged

Tested: search x, search reddit, gravity status, dry-run all work.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Code review fixes from 3 parallel review agents:
- Extract nonempty() helper — replaces 11 inline is_empty checks
- Extract to_grpc_notifications() — deduplicates notification mapping
- Restore SN13_SERVICE/GRAVITY_SERVICE/CLIENT_ID constants
- Pre-compute Bearer header in AuthInterceptor (was formatting on every RPC)
- Convert struct_to_json to use owned values (into_iter, no key cloning)
- Replace 6 per-post is_reddit() calls with single PostFields::extract()
- Fix truncate() double allocation for short strings
- Guard negative timestamps in timestamp_to_string
- Remove thinking-aloud comments

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Gravity's gRPC endpoint is broken server-side — it sends JSON over
the binary gRPC channel (compression flag 123 = '{' ASCII). SN13
search works perfectly via native gRPC.

This simplifies the client to use each transport where it works:
- SN13 (search): native gRPC via tonic (reliable, fast)
- Gravity: HTTP/JSON via reqwest (their gRPC is broken)

Removes ~400 lines of gravity proto conversion code (crawler_to_json,
proto_dataset_to_dataset_info, timestamp helpers, etc.) since HTTP
responses are already JSON and deserialize directly into our types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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