Skip to content

sdk: make the IntentBody derive no_std#451

Merged
mfw78 merged 1 commit into
dev/m1from
feat/m3-intent-body-no-std
Jul 21, 2026
Merged

sdk: make the IntentBody derive no_std#451
mfw78 merged 1 commit into
dev/m1from
feat/m3-intent-body-no-std

Conversation

@mfw78

@mfw78 mfw78 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What

Rewrites the #[derive(IntentBody)] codegen in nexum-macros to emit ::core/::alloc paths (via a new nexum_venue_sdk::body::__private::alloc re-export) instead of ::std. Flips cow-venue to #![no_std] (tests aside) and adds a no-std-probe workspace crate that derives IntentBody under #![no_std] with no extern crate alloc of its own.

Why

The derive's generated code named ::std, so any consumer linked std and could never be a genuine #![no_std] crate, breaking the no_std contract the venue body slice documents. Guest wasm targets tolerated it (wasip2 is std-bearing) but it blocked bare-metal consumers.

Testing

  • no-std-probe crate compiles #![no_std] against the derive (workspace check/clippy gate covers it going forward).
  • cow-venue builds #![no_std] outside test cfg.

Closes #322

AI Assistance

Implemented with Claude Code assistance; reviewed and tested by a human.

@lgahdl lgahdl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macro codegen rewrite itself is clean — checked the full intent_body.rs at the head commit and there's no straggler ::std path anywhere in the file, and the __private::alloc re-export follows the standard serde-style macro-hygiene pattern. One thing worth verifying before treating this as done, though:

//! so an adapter or a module that wants only the body types stays
//! dependency-light.

#![cfg_attr(not(test), no_std)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the actual owning crate of IntentBody/BodyError/__private::allocnexum-venue-sdk's lib.rs has no #![no_std] attribute anywhere (confirmed at this PR's head commit); it's a regular std crate. cow-venue depends on it unconditionally for the body feature. #![no_std] on cow-venue only governs this crate's own prelude/source, it doesn't make the dependency graph no_std-capable — building for a genuine bare-metal target (no std implementation at all, unlike wasm32-wasip2 which the PR body itself notes is "std-bearing") would almost certainly fail at nexum-venue-sdk's own compilation step, before cow-venue is even reached. The repo's only specialized target config (.cargo/config.toml) is wasm32-wasip2, and there's no CI job or just recipe building against an actual no-std-only target triple (e.g. thumbv7em-none-eabi) — so the stated goal ("blocked bare-metal consumers" → unblocked) is checked only by cargo check on the default host target, where std is trivially available regardless of any #![no_std] attribute. Worth either converting nexum-venue-sdk itself to #![no_std] (if that's feasible), or scoping the PR's claim down to "the derive no longer hardcodes ::std paths" rather than "unblocks bare-metal consumers," since that part is unverified and likely not yet true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed still valid at HEAD. videre-sdk (the IntentBody owner post-rename) still carries no #![no_std] at the tip, and there is no CI/just build against a real no-std triple - only wasm32-wasip2 (std-bearing) and host cargo check. The derive itself is clean; the bare-metal goal is unverified and, per the unconditional videre-sdk dependency, not yet reachable. Tracked in #521, with your scope-down alternative recorded there.


[dependencies]
# Source of the `IntentBody` derive and trait the probe enum implements.
nexum-venue-sdk = { path = "../nexum-venue-sdk" }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relatedly: this direct dependency on nexum-venue-sdk is exactly the path through which a genuine no-std-target build would fail (see the cow-venue/lib.rs:28 comment) — the probe only proves the derive macro's generated code doesn't reference ::std textually, not that the crate graph can target a real bare-metal platform. Also, separately: the probe only derives IntentBody on ProbeBody, it never calls to_bytes/from_bytes — so it proves macro expansion under no_std, not correctness of the generated round-trip logic. A #[cfg(test)] mod tests block (tests are exempted from the no_std attribute per the cow-venue pattern) exercising an actual encode/decode round-trip would close that gap cheaply.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed still valid at HEAD - the no-std-probe at the tip still only derives IntentBody without a round-trip. A #[cfg(test)] encode/decode test (exempt from #![no_std], per the cow-venue pattern) would prove the generated logic, not just expansion. Folded into #521.

@mfw78
mfw78 force-pushed the feat/m2-zero-leak-blocking branch 2 times, most recently from 8706226 to cc831bb Compare July 21, 2026 07:44
Base automatically changed from feat/m2-zero-leak-blocking to dev/m1 July 21, 2026 07:50
The derive reaches Vec and ToString through the venue SDK's __private
alloc re-export instead of ::std, so a #![no_std] consumer needs no
extern crate alloc. cow-venue flips to no_std (tests aside) and a
compile-only no-std-probe crate keeps the contract under the workspace
gate.
@mfw78
mfw78 force-pushed the feat/m3-intent-body-no-std branch from 446ee89 to 6d89d42 Compare July 21, 2026 07:51
@mfw78
mfw78 merged commit 02e04a9 into dev/m1 Jul 21, 2026
6 checks passed
@mfw78
mfw78 deleted the feat/m3-intent-body-no-std branch July 21, 2026 08:32
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