Conversation
P0.4: Canonical Agent SDK
## Summary Replace the hardcoded TrivialAgent::run() call in kernel-guest with the canonical extern "Rust" fn agent_main(ctx, opaque_inputs) entrypoint. ## Key Changes ### API Design - Use `extern "Rust"` instead of `extern "C"` for ABI safety with Rust types - 2-argument signature: `agent_main(ctx: &AgentContext, opaque_inputs: &[u8])` - AgentContext uses owned fields (no lifetimes) - clean "header" struct ### New Crate: example-agent - Minimal example agent demonstrating the canonical entrypoint - Echoes input when opaque_inputs[0] == 1, empty output otherwise - Used for testing kernel execution flow ### Refactored Crates - kernel-sdk: AgentContext now uses owned [u8; 32] fields, 144 bytes fixed size - kernel-guest: Uses extern "Rust" block, no unsafe pointer casts needed - agent-traits: Re-exports from kernel-sdk, deprecated legacy Agent trait - host-tests: Added tests for agent_main behavior ## Technical Details - AgentContext is #[repr(C)], Clone, Copy, Debug, PartialEq, Eq - #[no_mangle] requires #[allow(unsafe_code)] due to Rust lint rules - All 88 host-tests pass, plus crate-specific tests
…ypoint feat: Replace TrivialAgent with canonical agent_main entrypoint
The agent-traits crate was providing duplicate ABI definitions that conflicted with kernel-sdk's canonical definitions. Since nothing is deployed yet, removing the crate entirely simplifies the architecture. All canonical ABI types (AgentContext, AgentOutput, AgentEntrypoint) are now defined solely in kernel-sdk. The example-agent crate demonstrates the correct agent implementation pattern. Also fixed stale comment in host-tests that referenced "extern C" when it should say "extern Rust".
…rypoint refactor: Remove agent-traits crate and simplify ABI definitions
- Add methods crate for building zkVM guest ELF and exporting IMAGE_ID - Add zkvm-guest wrapper crate for risc0-build compatibility - Add e2e-tests crate with feature-gated proof generation tests - Add agent code hash binding (build.rs generates AGENT_CODE_HASH) - Add spec/e2e-tests.md specification document - Update README with E2E testing and on-chain verification sections Test cases: - test_e2e_success_with_echo: Happy path with proof generation - test_e2e_agent_code_hash_mismatch: Security validation - test_e2e_empty_output: Empty output commitment verification - test_e2e_determinism: Deterministic execution verification On-chain data extraction: - seal (256 bytes Groth16 proof) - journal (KernelJournalV1 bytes) - imageId (bytes32 guest identity)
feat: Add E2E zkVM proof tests with RISC Zero integration
|
Claude finished @Mehd1b's task —— View job PR Review: p2p testingI've completed a comprehensive review of this substantial PR that adds zkVM proof generation and E2E testing infrastructure. This is an impressive implementation with strong security properties and thorough testing. Todo List
✅ StrengthsArchitecture & Design
Security Implementation
Test Coverage (180 tests total)
Code Quality
|
Summary
methodscrate for building zkVM guest ELF and exportingZKVM_GUEST_ELF/ZKVM_GUEST_IDzkvm-guestwrapper crate for risc0-build compatibilitye2e-testscrate with feature-gated proof generation testsbuild.rsgeneratesAGENT_CODE_HASHat compile time)spec/e2e-tests.mdspecification documentTest Cases
test_e2e_success_with_echotest_e2e_agent_code_hash_mismatchtest_e2e_empty_outputtest_e2e_determinismOn-Chain Verification Data
Extracts data needed for Solidity verifier:
seal(256 bytes Groth16 proof)journal(KernelJournalV1 bytes)imageId(bytes32 guest identity)Test Plan
cargo test -p e2e-testspasses (unit tests, no RISC Zero required)cargo test -p host-testspasses (92 tests, no regressions)cargo test -p e2e-tests --features risc0-e2e test_e2e_success_with_echogenerates valid proofcargo test -p e2e-tests --features risc0-e2e test_e2e_agent_code_hash_mismatchcorrectly failscargo test -p e2e-tests --features risc0-e2e test_e2e_empty_outputgenerates valid proof