Skip to content

test(nexus): no_std compile-gate for derive macro output (#304)#305

Merged
joeldsouzax merged 1 commit into
mainfrom
feat/304-nostd-derive-smoketest
Jul 8, 2026
Merged

test(nexus): no_std compile-gate for derive macro output (#304)#305
joeldsouzax merged 1 commit into
mainfrom
feat/304-nostd-derive-smoketest

Conversation

@joeldsouzax

Copy link
Copy Markdown
Contributor

Closes #304.

Why

#279 (PR #303) made the nexus kernel no_std and added flake gates (nexus-nostd = thumbv7em, nexus-wasm) that build the kernel bare (--no-default-features). Those prove the core compiles no_std, but they never compile the output of #[nexus::aggregate] / #[derive(DomainEvent)] for a no_std target — during #279 the macro source was only grepped for std:: (weak). If a macro emits a std:: path, a no_std consumer (Bombay-SDK "KERI on phone") breaks and we only find out downstream. The derive-on-no_std guarantee is what the IoT/embedded README claim rests on.

What

New crate nexus-nostd-smoketest:

  • src/smoke.rs — a real #![no_std] aggregate using both #[nexus::aggregate] and #[derive(DomainEvent)] plus two Handle impls, entirely in core: [u8; 8] id + core::fmt::Display, Events<E, 0> (single-event, no allocator), thiserror no_std error. drive() instantiates the monomorphised AggregateRoot driver methods so a std leak in any of them surfaces at compile time on the target.
  • src/lib.rs#![no_std]; the probe lives behind #[cfg(feature = "derive")], so --no-default-features is a trivially-empty lib and --features derive compiles the macro output.
  • Cargo.tomlnexus + thiserror optional, pulled only by the derive feature (forwards nexus/derive, not nexus/std).
  • .config/hakari.toml — added to [final-excludes].workspace-members (same mechanism as nexus) so no std workspace-hack edge reaches the bare-metal build.
  • flake.nix — both nexus-nostd and nexus-wasm gates now also cargo build -p nexus-nostd-smoketest ... --no-default-features --features derive.

Acceptance

  • a #![no_std] crate using the derive macros compiles for thumbv7em-none-eabihf + wasm32-unknown-unknown under nix flake check
  • gate fails if a macro emits a std:: path (verified: a dangling symbol reference reddened the thumbv7em build until fixed)

The optional testing-fixture + alloc target (issue path #2) is deferred to a follow-up, as the acceptance criteria mark it optional; it needs a #[global_allocator] and is a separate, larger piece.

The macro output was already core-clean — this lands as a regression guard, locking in a property #279 established but never compile-tested.

🤖 Generated with Claude Code

#279 (PR #303) made the kernel no_std and added flake gates that build it
`--no-default-features` for thumbv7em + wasm32. Those prove the *core* is
no_std, but never compile the *output* of `#[nexus::aggregate]` /
`#[derive(DomainEvent)]` for a no_std target — the macro source was only
grepped for `std::`, which is weak.

Add `nexus-nostd-smoketest`: a `#![no_std]` crate defining an aggregate via
both macros + `Handle` impls, entirely in `core` (`Events<E, 0>`, no
allocator). Both flake gates now also build it `--features derive` for
thumbv7em + wasm32, so a macro emitting a `std::` path fails the bare-metal
build. The probe lives behind the `derive` feature; `nexus`/`thiserror` are
optional and pulled only by it (`nexus/derive` is additive, not `nexus/std`).

Excluded from workspace-hack (like `nexus`) so no std edge reaches the
bare-metal build. Logic correctness stays covered on the host by the
nexus-cross-crate-test suite — this is a compile probe.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joeldsouzax joeldsouzax merged commit ae7d9bf into main Jul 8, 2026
4 checks passed
@joeldsouzax joeldsouzax deleted the feat/304-nostd-derive-smoketest branch July 8, 2026 20:12
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.

[freeze] no_std smoke-test: compile-gate derive macro output for thumbv7em + wasm

1 participant