Skip to content

P0.4: Canonical Agent SDK#7

Merged
Mehd1b merged 1 commit into
devfrom
kernel-sdk
Jan 23, 2026
Merged

P0.4: Canonical Agent SDK#7
Mehd1b merged 1 commit into
devfrom
kernel-sdk

Conversation

@Mehd1b

@Mehd1b Mehd1b commented Jan 23, 2026

Copy link
Copy Markdown
Member

Summary

Introduces the kernel-sdk crate providing the canonical interface for zkVM agent development, along with significant hardening to kernel-core.

kernel-sdk (new crate)

  • AgentContext: Execution context with version checking, snapshot helpers
  • Action constructors: echo, open_position, close_position, adjust_position, swap
  • Payload decode helpers with structural validation
  • Math module: checked/saturating arithmetic, basis points, drawdown calculations
  • Bytes module: fixed-offset and cursor-style readers/writers
  • Prelude with common exports (Vec but NOT vec! macro to discourage unbounded allocations)
  • Reference echo_agent example with comprehensive tests

kernel-core hardening

  • no_std support with extern crate alloc
  • Codec refactor: encode_into/encoded_len trait methods to avoid per-action allocation
  • Fixed get_var_bytes offset rewind footgun, uses checked_add throughout
  • Version validation in encode_into (prevents encoding invalid structures)
  • MAX_AGENT_OUTPUT_BYTES enforcement on encode/decode
  • sha256() canonical helper with thin wrapper commitment functions
  • debug_assert checks for encoded_len/encode_into consistency

Documentation

  • spec/sdk.md: Complete SDK specification (690 lines)
  • docs/P0.4_DOCUMENTATION.md: Comprehensive usage guide (1117 lines)

Feature hygiene

  • kernel-sdk: default-features = false, no_std
  • kernel-core: default-features = false for sha2, std feature for host tooling
  • kernel-guest: default-features = false for kernel-core
  • host-tests: features = ["std"] for kernel-core

Test plan

  • cargo test - All 159 tests pass
  • cargo build - No warnings
  • Verified no_std compatibility via clippy lints

Introduces kernel-sdk crate providing the canonical interface for zkVM agent development.

## kernel-sdk (new crate)
- AgentContext: Execution context with version checking, snapshot helpers
- Action constructors: echo, open_position, close_position, adjust_position, swap
- Payload decode helpers with structural validation
- Math module: checked/saturating arithmetic, basis points, drawdown calculations
- Bytes module: fixed-offset and cursor-style readers/writers
- Prelude with common exports (Vec but NOT vec! macro to discourage unbounded alloc)
- Reference echo_agent example with comprehensive tests

## kernel-core hardening
- no_std support with extern crate alloc
- Codec refactor: encode_into/encoded_len trait methods to avoid per-action allocation
- Fixed get_var_bytes offset rewind footgun, uses checked_add throughout
- Version validation in encode_into (prevents encoding invalid structures)
- MAX_AGENT_OUTPUT_BYTES enforcement on encode/decode
- sha256() canonical helper with thin wrapper commitment functions
- debug_assert checks for encoded_len/encode_into consistency

## Documentation
- spec/sdk.md: Complete SDK specification (690 lines)
- docs/P0.4_DOCUMENTATION.md: Comprehensive usage guide (1117 lines)

## Feature hygiene
- kernel-sdk: default-features = false, no_std
- kernel-core: default-features = false for sha2, std feature for host tooling
- kernel-guest: default-features = false for kernel-core
- host-tests: features = ["std"] for kernel-core
@Mehd1b
Mehd1b merged commit 09f16c0 into dev Jan 23, 2026
1 check 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