Files
arkhe-origin-chain/crates/origin-chain-agent-identity/src
davidherranandClaude Opus 4.7 2fefe4cf51 feat(agent-identity): v0.0.26 — register_agent_did impl complete + mock runtime integration tests E2E (10 scenarios)
Phase 2.7 AGENT IDENTITY pallet REAL IMPL canonical. Full 8-step CHN-7 flow
canonical register_agent_did dispatchable + storage assertions + Inmutable #41
Cross-Species Co-authorship enforcement compile-detect. Mock runtime + 10
integration tests E2E pattern v0.0.18 + v0.0.22 mirror.

## Real impl canonical 8-step CHN-7

1. ensure_signed(origin)
2. Idempotency check (!Identities::contains_key(&who))
3. Derive DID canonical via derive_did(public_key) BLAKE3 (Inmutable #16)
4. DID collision check (!DidToAccount::contains_key(&did))
5. Build AgentChain BoundedVec from co_authors_raw Vec<[u8;32]> (overflow → AgentChainOverflow)
6. Inmutable #41 enforce: Hybrid requires non-empty agent_chain
7. Storage insert: Identities + DidToAccount reverse lookup
8. Emit AgentRegistered + AgentBound (if cross-species)

Pure helper Pallet::<T>::query_identity_of() para Runtime API v0.0.27.

## 10 integration tests E2E canonical

- scenario_1: Human self-registration → ok + DID + empty chain
- scenario_2: AGI self-registration → ok + Inmutable #41 sovereign
- scenario_3: Hybrid + 2 co-authors → ok + AgentBound emitted
- scenario_4: Hybrid + empty chain → Err::HybridRequiresAgentChain
- scenario_5: duplicate account → Err::AlreadyRegistered
- scenario_6: same pubkey diff account → Err::DidAlreadyTaken
- scenario_7: 11 co-authors → Err::AgentChainOverflow (ConstU32<10>)
- scenario_8: DID → Account reverse lookup canonical
- scenario_9: Human + AGI both is_sovereign() (Inmutable #41 lobo blanco)
- scenario_10: 8-step CHN-7 walkthrough explicit Pre/Post assertions

## Files

- EDIT: crates/origin-chain-agent-identity/src/lib.rs (real impl 8-step + query_identity_of helper)
- NEW: crates/origin-chain-agent-identity/src/mock.rs (80 LOC mock runtime)
- NEW: crates/origin-chain-agent-identity/src/tests_integration.rs (310 LOC, 10 tests)
- EDIT: CHANGELOG.md (v0.0.26 entry comprehensive)

## Verification

- cargo test -p origin-chain-agent-identity — 16 tests verde canonical, 0 failures
  (10 integration + 4 standalone + 2 auto-generated)

🛠️ Phase 2.7 real impl canonical. Runtime API v0.0.27 next ship → Phase 2.7 COMPLETE.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 06:43:14 -05:00
..