P0.4: Canonical Agent SDK#8
Conversation
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
|
Claude finished @Mehd1b's task —— View job PR Review: P0.4 Canonical Agent SDKI've completed a comprehensive review of this substantial PR introducing the kernel-sdk crate and hardening kernel-core. Overall, this is high-quality code with excellent design principles and documentation. Here are my findings: Review Checklist:
✅ StrengthsArchitecture & Design
Code Quality
Security
Performance
|
Summary
Introduces the
kernel-sdkcrate providing the canonical interface for zkVM agent development, along with significant hardening tokernel-core.kernel-sdk (new crate)
AgentContext: Execution context with version checking, snapshot helpersecho,open_position,close_position,adjust_position,swapVecbut NOTvec!macro to discourage unbounded allocations)echo_agentexample with comprehensive testskernel-core hardening
no_stdsupport withextern crate allocencode_into/encoded_lentrait methods to avoid per-action allocationget_var_bytesoffset rewind footgun, useschecked_addthroughoutencode_into(prevents encoding invalid structures)MAX_AGENT_OUTPUT_BYTESenforcement on encode/decodesha256()canonical helper with thin wrapper commitment functionsdebug_assertchecks forencoded_len/encode_intoconsistencyDocumentation
spec/sdk.md: Complete SDK specification (690 lines)docs/P0.4_DOCUMENTATION.md: Comprehensive usage guide (1117 lines)Feature hygiene
default-features = false,no_stddefault-features = falsefor sha2,stdfeature for host toolingdefault-features = falsefor kernel-corefeatures = ["std"]for kernel-coreTest plan
cargo test- All 159 tests passcargo build- No warnings