Skip to content

feat(sdk/rust): add SessionEnvelopeV1 harness types (parity with TS SDK)#210

Merged
sanil-23 merged 1 commit into
tinyhumansai:mainfrom
sanil-23:feat/rust-sdk-session-envelope
Jul 2, 2026
Merged

feat(sdk/rust): add SessionEnvelopeV1 harness types (parity with TS SDK)#210
sanil-23 merged 1 commit into
tinyhumansai:mainfrom
sanil-23:feat/rust-sdk-session-envelope

Conversation

@sanil-23

@sanil-23 sanil-23 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Ports the harness session-envelope schema from the TypeScript SDK (sdk/typescript/src/types/harness.ts) to the Rust SDK. Rust consumers (e.g. the OpenHuman core ingest path) can now decode the envelope a wrapped Codex/Claude session forwards inside an encrypted Signal DM body via tinyplace::types::SessionEnvelopeV1, instead of hand-maintaining a mirror that silently drifts from the TS source of truth.

What's added — sdk/rust/src/types/harness.rs

Mirrors the TS interface 1:1:

  • SessionEnvelopeV1 (+ HarnessBucket, HarnessScope, HarnessInfo, HarnessMessage, HarnessSource)
  • SESSION_ENVELOPE_VERSION_V1 const and the SessionEnvelope alias (matching export type SessionEnvelope = SessionEnvelopeV1)
  • String-union type aliases (HarnessProvider, HarnessMessageRole, HarnessBucketUnit, HarnessEnvelopeScope) following the existing pub type EnvelopeType = String convention in messaging.rs
  • is_valid_v1() / parse(&str) -> Option<Self> consumer helpers
  • types/mod.rs: module declared + flat re-exported like every sibling

Wire-format note (important)

The harness envelope is snake_case on the wire (the CLI wrapper emits a literal snake_case object), unlike the camelCase used by the rest of the API. The structs therefore intentionally omit #[serde(rename_all = "camelCase")]. A round-trip unit test guards against a future camelCase "normalization" that would break decoding of real envelopes.

Tests

cargo test -p tinyplace --lib harness — 2 passing:

  • parses_and_round_trips_v1 (asserts snake_case keys survive serialization)
  • rejects_unknown_version_and_plain_dm

cargo fmt --check and cargo clippy clean on the crate.

Notes

  • No behavior change to existing types; purely additive.
  • Follow-up (separate): publish a new tinyplace crate version so downstream (OpenHuman) can bump and drop its hand-written mirror.

Summary by CodeRabbit

  • New Features

    • Added support for a new encrypted direct-message envelope format.
    • Improved message handling with validation for version and required session details.
    • Expanded Rust type exports so the new envelope data can be used across the SDK.
  • Tests

    • Added coverage for valid envelope parsing, JSON round-tripping, and rejection of unsupported or incomplete payloads.

Ports the harness session-envelope schema from the TypeScript SDK
(sdk/typescript/src/types/harness.ts) to the Rust SDK so Rust consumers
can decode the envelope a wrapped Codex/Claude session forwards inside an
encrypted Signal DM body, instead of hand-rolling a mirror.

- types/harness.rs: SessionEnvelopeV1 (+ Bucket/Scope/Info/Message/Source),
  SESSION_ENVELOPE_VERSION_V1, SessionEnvelope alias, and is_valid_v1/parse
  helpers. Wire format is snake_case (the CLI emits a literal snake_case
  object), so structs deliberately omit rename_all=camelCase.
- types/mod.rs: declare + flat re-export the module.
- Unit tests: v1 round-trip (snake_case regression guard) + reject
  unknown version / plain DM.
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

@sanil-23 is attempting to deploy a commit to the Vezures Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 72115fe0-37e6-4bea-9856-f75df0fec0dc

📥 Commits

Reviewing files that changed from the base of the PR and between d641e1b and 94b4a48.

📒 Files selected for processing (2)
  • sdk/rust/src/types/harness.rs
  • sdk/rust/src/types/mod.rs

📝 Walkthrough

Walkthrough

Adds a new Rust module (sdk/rust/src/types/harness.rs) defining serde structs and type aliases for a v1 harness session envelope wire schema, with is_valid_v1 and parse methods and unit tests. Registers the module in the types barrel (sdk/rust/src/types/mod.rs).

Changes

Harness Envelope Schema

Layer / File(s) Summary
Envelope type definitions
sdk/rust/src/types/harness.rs
Adds SESSION_ENVELOPE_VERSION_V1 constant, string type aliases (HarnessProvider, HarnessMessageRole, HarnessBucketUnit, HarnessEnvelopeScope), and structs HarnessBucket, HarnessScope, HarnessInfo, HarnessMessage, HarnessSource, and SessionEnvelopeV1 (with SessionEnvelope alias).
Validation, parsing, and tests
sdk/rust/src/types/harness.rs, sdk/rust/src/types/mod.rs
Implements is_valid_v1 and parse on SessionEnvelopeV1, adds unit tests for round-trip serialization and rejection of invalid payloads, and registers/re-exports the harness module in the types barrel.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

Not applicable — this PR adds a self-contained data schema and parsing utility without multi-component orchestration flow.

Poem

A bunny found a coded scroll,
"session_envelope_v1", quite whole! 🐰
With buckets, scopes, and messages neat,
parse() and is_valid_v1() — such a treat!
Hop hop, the schema's now complete!

🚥 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 summarizes the main change: adding Rust SessionEnvelopeV1 harness types with TypeScript SDK parity.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

@sanil-23 sanil-23 merged commit 1ac1c4b into tinyhumansai:main Jul 2, 2026
9 of 10 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.

1 participant