feat(audit): real CBOR + EVM-calldata decode for the web audit view (#153)#194
Open
hanwencheng wants to merge 1 commit into
Open
feat(audit): real CBOR + EVM-calldata decode for the web audit view (#153)#194hanwencheng wants to merge 1 commit into
hanwencheng wants to merge 1 commit into
Conversation
ca34532 to
f82334f
Compare
Member
Author
Codex adversarial review — appliedRan Fixed in
Real Heima explorer URLs wired (per operator): Ruled out (with evidence):
Validation: core 157, daemon 66/15/15, |
f82334f to
d2ccefe
Compare
…153) Replaces the parent-control web UI's decodeCalldata mock + placeholder contract addresses with real backend decode, end to end. Core decode (agentkeys-core): - audit/calldata.rs: keccak selectors + minimal head/tail ABI decode/encode for the four stage-1 contracts; bounds-checked (no OOM); selectors pinned to cast. - audit/mod.rs: AuditEnvelope::to_json() + decode_envelope_hex(); #137 vectors are the decode fixtures. - chain_profile.rs + heima.json: embedded contract registry + real explorer.heima.network /address/ + /contract/ links. Daemon: ui_bridge.rs GET /v1/chain/info + /v1/audit/:id/decode; audit_decode.rs decodes envelope + calldata (encode→decode round-trip), labelled synthesized:true. Web UI: client seam getChainInfo()/decodeAuditEvent(); ChainPage real addresses; the audit decode is a dedicated page (audit feed → click event → `decode` view with a back button + panels + preview banner), not a modal; no fabricated tx links. Contract src↔deploy divergence (verified on-chain): - DEPLOYED AgentKeysScope (prod 0xd44b375… + test 0x338d68…, both 4572B) is the stage-1 setScopeWithWebauthn(...,K11Assertion) design (sel 0x864ae93c / 0x6f37dd80). src/AgentKeysScope.sol is the #164 ERC-4337 rewrite (setScope) — built by the deploy script but NOT yet deployed (idempotent skip; gated on the master-account cutover). #164's ERC-4337 infra (EntryPoint, factory) IS live. Live source preserved at archived/AgentKeysScope.deployed-stage1.sol; gap documented in deployed-contracts.md. calldata.rs decodes both forms with the real deployed selectors. CI deploy fix: setup-broker-host.sh self-healing rust toolchain health gate — verify rustc runs (repair once if not) before building. Fixes the test-EC2 'could not execute process rustc … No such file' failure. Idempotent. Tests: core 157, daemon 66/15/15, clippy -D warnings clean, forge build clean, bash -n clean. App tsc: changed files clean (the only 2 errors are the gitignored, dev.sh-generated lib/wasm bindings absent in CI checkouts).
d2ccefe to
4cc1828
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #153. Replaces the parent-control web app's mock audit decode (
decodeCalldata) and placeholder—contract addresses with real backend decode, end to end — the follow-up to #187 (which wired onboarding but left the step-9 audit view mocked).Two things the user asked for: show the contract information and show (decode) the audit.
What landed
agentkeys-core— decode primitivesaudit/calldata.rs— keccakselector()+ a minimal head/tail ABI decoder + encoder for the four stage-1 contracts (CredentialAudit,SidecarRegistry,AgentKeysScope,K3EpochCounter). Real selectors (e.g.append=0xc1bf0e32,registerAgentDevice=0x9847ca95) pinned tocastground truth so ABI drift fails CI. Supportsbytes32/uint*/address/bool/bytes/bytes32[]; a trailing WebAuthntupleis noted, not guessed.audit/mod.rs—AuditEnvelope::to_json()+decode_envelope_hex(). The agentkeys-core: AuditEnvelope v1 cross-language CBOR vector exporter #137 cross-language CBOR vectors are the decode fixtures (acceptance bullet 4).chain_profile.rs+chain-profiles/heima.json— embedded deployed-contract registry (single source of truth, mirrorsdocs/spec/deployed-contracts.md).agentkeys-daemon— endpointsaudit_decode.rs— decode one audit event into its CBORAuditEnvelope(round-tripped through real canonical CBOR) and the on-chain calldata it commits (ABI-encoded from the action's real values, then decoded against the verified ABI — real bytes, not a fabricated view).ui_bridge.rs—GET /v1/chain/info+GET /v1/audit/:id/decode.apps/parent-control— web UIgetChainInfo()+decodeAuditEvent().ChainPagerenders real addresses + explorer links;EventDecodeModalrenders the decoded envelope + typed calldata args. Demo data kept as a clearly-labelled offline fallback.Acceptance (#153)
Deliberate deviation
The issue suggested
ethabi/alloy. I wrote a small, fully-tested decoder/encoder instead (onlysha3needed — no heavy dep), selectors pinned tocastground truth + encode/decode round-trip tested. Equivalent correctness, far smaller footprint.Test plan
cargo test -p agentkeys-core audit::— calldata + envelope decode + agentkeys-core: AuditEnvelope v1 cross-language CBOR vector exporter #137 vectors (153+ pass)cargo test -p agentkeys-daemon— audit_decode + endpoint wiring (66/15/15 pass)cargo clippy -p agentkeys-core -p agentkeys-daemon --all-targets -- -D warnings— cleancargo check --workspace— cleanapps/parent-control:tsc --noEmit— clean🤖 Generated with Claude Code