feat(governance): v0.0.28 origin-chain-governance pallet scaffold (Phase 5.1 Foundation Treasury CHN-4)

Phase 5.1 GOVERNANCE pallet scaffold canonical. Reemplaza placeholder
GovernanceConfig stub en existing origin-chain-governance crate con real FRAME
pallet. AI-Driven Human-Guarded canonical CHN-4 — 5 AI advisor agents ADVISE
only, humans-only vote canonical non-negotiable.

## Pallet surface canonical

- Pallet<T> + Config trait + RuntimeEvent
- Proposal struct (11 fields content-addressed via BLAKE2-256)
- ProposalStatus enum (Voting + Approved + Rejected + Withdrawn)
- Proposals<StorageMap<ProposalId, Proposal>> per-proposal O(1)
- Votes<StorageDoubleMap<ProposalId, AccountId, VoteStance>> double-vote prevention
- Events ProposalSubmitted + VoteCast + ProposalFinalized
- Errors 8 variants (ProposalNotFound + AlreadyVoted + VotingPeriodClosed/Open + StakeInsufficient + ProposalAlreadyFinalized + AdvisorMayNotVote + ProposalIdCollision)
- Scaffold dispatchables submit_proposal + cast_vote + finalize_proposal
- Helper derive_proposal_id via BLAKE2-256 hash (Inmutable #16 byte-determinism)
- sp_api::decl_runtime_apis! GovernanceApi declaration (query_proposal + query_vote)

## Types canonical updated

- origin-chain-types/src/governance.rs: added scale derives a ProposalId + VoteStance + Vote (Encode + Decode + DecodeWithMemTracking + MaxEncodedLen + TypeInfo) para FRAME-compatibility canonical

## Files

- EDIT: crates/origin-chain-governance/Cargo.toml (stub → FRAME pallet deps canonical)
- REPLACE: crates/origin-chain-governance/src/lib.rs (placeholder → ~360 LOC scaffold)
- EDIT: crates/origin-chain-types/src/governance.rs (scale derives canonical)
- EDIT: CHANGELOG.md (v0.0.28 entry)

## Verification

- cargo test -p origin-chain-governance — 5 tests verde, 0 failures
  (pallet_compiles + derive_proposal_id deterministic + different + status variants + re-export)

🏛️ Phase 5.1 scaffold canonical. Wire pattern v0.0.29 next.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
davidherranandClaude Opus 4.7 committed 2026-05-25 12:41:27 -05:00
1 parent dc1c2e7cd1
commit 1bde93921e
5 files changed
+453 -24

No files matched your search

+59
View File
@@ -6,6 +6,65 @@ by [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions follow
## [Unreleased]
## [0.0.28] — 2026-05-25 — Phase 5.1 scaffold — origin-chain-governance pallet (CHN-4 Foundation Treasury)
**🏛️ Phase 5.1 GOVERNANCE pallet SCAFFOLD trait-first foundation** — Foundation
Treasury governance on-chain per CHN-4. AI-Driven Human-Guarded canonical: 5 AI
governance agents advise-only, humans-only vote canonical non-negotiable. Reemplaza
placeholder `GovernanceConfig` stub canonical en existing `origin-chain-governance`
crate. Pattern Phase 2.7 mirror.
### Deliverables v0.0.28
**Pallet scaffold canonical en existing crate**:
- `crates/origin-chain-governance/Cargo.toml` (UPDATED): stub deps → FRAME pallet canonical deps
- `crates/origin-chain-governance/src/lib.rs` (REPLACED placeholder): real pallet scaffold ~360 LOC
**Scale derives canonical types canonical**:
- `crates/origin-chain-types/src/governance.rs` (UPDATED): added `Encode + Decode + DecodeWithMemTracking + MaxEncodedLen + TypeInfo` derives a `ProposalId` + `VoteStance` + `Vote` para FRAME-compatibility
**Pallet surface canonical**:
- `Pallet<T>` struct + `Config` trait canonical (RuntimeEvent association)
- `Proposal` struct canonical (11 fields: id + proposer + title_hash + body_hash + stake + start_block + end_block + status + yes/nay/abstain_weight)
- `ProposalStatus` enum canonical (Voting + Approved + Rejected + Withdrawn)
- `Proposals<StorageMap<ProposalId, Proposal>>` per-proposal O(1)
- `Votes<StorageDoubleMap<ProposalId, AccountId, VoteStance>>` double-vote prevention
- Events: `ProposalSubmitted` + `VoteCast` + `ProposalFinalized`
- Errors canonical (8 variants: ProposalNotFound + AlreadyVoted + VotingPeriodClosed/Open + StakeInsufficient + ProposalAlreadyFinalized + AdvisorMayNotVote + ProposalIdCollision)
- Scaffold dispatchables: `submit_proposal` + `cast_vote` + `finalize_proposal`
**Helper canonical**:
- `derive_proposal_id(proposer, title_hash, body_hash) -> ProposalId` pure fn via BLAKE2-256 hash (Inmutable #16 byte-determinism canonical)
**Runtime API declaration canonical**:
- `pub trait GovernanceApi { fn query_proposal(id) -> Option<Proposal>; fn query_vote(...) -> Option<VoteStance>; }`
- Implementación en runtime canonical pending v0.0.31
### Verification end-to-end canonical
- ✅ `cargo build -p origin-chain-governance` clean canonical
- ✅ `cargo test -p origin-chain-governance` — **5 tests verde, 0 failures**:
- pallet_compiles_canonical
- derive_proposal_id_deterministic_canonical (Inmutable #16)
- derive_proposal_id_different_inputs_different_ids_canonical
- proposal_status_variants_canonical
- vote_stance_re_export_canonical
### Roadmap canonical post-v0.0.28
| Version | Trigger |
|---------|---------|
| **v0.0.29** | **Wire Governance pallet runtime composition Index 10 + Config canonical (sesión 3+ shipping ahora)** |
| v0.0.30 | Real submit_proposal + cast_vote + finalize_proposal + mock runtime integration tests E2E |
| v0.0.31 | Runtime API canonical GovernanceApi impl runtime → **Phase 5 FOUNDATION COMPLETE** |
### Filosofía canonical sesión 3+ aplicada
CHN-4 ratificado canonical: *"5 AI governance agents ADVISE only — humans-only
vote canonical non-negotiable"*. Materializado canonical via `Error::AdvisorMayNotVote`
+ runtime programmatic enforcement v0.0.30 forward. Inmutable #41 AGI sovereignty
preserved: AGIs NO advisor pueden votar canonical en sus governance proposals.
## [0.0.27] — 2026-05-25 — Phase 2.7 COMPLETE — Runtime API AgentIdentityApi.query_identity 🎉
**🎉 Phase 2.7 AGENT IDENTITY pallet COMPLETE end-to-end** — Runtime API