Commit Graph
7 Commits
Author SHA1 Message Date
davidherranandClaude Opus 4.8 8a1f779c32 fix(runtime): FIX-5 governability (pallet-sudo to Root) + FIX-2 StorageVersion (4 pallets)
Build + tests verde (exit 0, runtime 27 tests incl. sudo_pallet_index_12).
Verificacion adversarial ultracode (5 skeptics): 4 confirmed + 1 partial.

FIX-5 — governability (audit V2-CA1):
- pallet-sudo 43.0.0 wired Index 12 (workspace + runtime Cargo.toml + std).
- impl pallet_sudo::Config (RuntimeEvent/RuntimeCall/WeightInfo) en configs.rs.
- genesis: sudo key en los 3 presets — dev/local=Alice, mainnet=foundation_treasury
  (NO una dev key; el verificador confirmo que no hay backdoor critico).
- Da Root origin -> las dispatchables ensure_root de Governance (add/remove
  council, mark/unmark advisor, treasury_disbursement) dejan de ser
  no-invocables. Verificado extremo-a-extremo: sudo() despacha RawOrigin::Root,
  que es exactamente lo que ensure_root acepta.
- Sunset documentado (codigo + doc): sudo -> governance real (pallet-collective/
  referenda) ANTES de mainnet. Sudo key unica = riesgo de centralizacion
  aceptable solo como interim/testnet.

FIX-2 — lifecycle (audit V1-H2/V2-CA2):
- StorageVersion::new(0) + pallet::storage_version en los 4 pallets
  (provenance/fees/agent-identity/governance). Aditivo, in-code==on-chain==0,
  sin migracion forzada. Habilita migraciones futuras.

CAVEAT honesto (hallazgo high del red-team, NO defecto de FIX-5/FIX-2):
treasury_disbursement solo DECREMENTA un contador u128 (Treasury StorageValue),
NO mueve OGC real via pallet_balances. FIX-5 restaura la GOBERNABILIDAD (la
dispatchable es invocable), pero mover los 250M reales es FIX-6: anadir
type Currency al Config + T::Currency::transfer desde una cuenta-tesoreria
derivada (PalletId) + financiarla en genesis + test del free_balance. NO se
afirma "tesoreria descongelada de verdad" — solo "gobernabilidad restaurada".

PENDIENTE:
- FIX-2 AGI key recovery (rotate/revoke/active en agent-identity): diferido —
  necesita un DC de semantica de recovery #41 (single-sig vs multisig threshold,
  DID estable vs rota, recovery de agent_chain vacio). No se construye contra
  spec no-ratificada.
- pallet-sudo no en feature runtime-benchmarks (inerte hoy: el runtime no impl
  el Benchmark API). Follow-up con weights benchmarking.
- mainnet Foundation sudo key (FNDT placeholder): David ratifica la key real
  (multisig) pre-launch Q1 2027 (documentado).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 22:55:21 -05:00
davidherranandClaude Opus 4.7 10ee1ab7b9 feat(governance): v0.0.34 Phase 5 FULLY COMPLETE — 5.3-5.8 refinements consolidated 🎉🎉🎉
Phase 5 GOVERNANCE FULLY COMPLETE end-to-end canonical. 5.3-5.8 refinements
consolidated single ship canonical. AI advisor flag system (5.6) + Council
veto override 4/5 community supermajority (5.5) + Emergency referendum 48h
fast-track (5.7) + Treasury disbursement (5.8) + voting period constants (5.3+5.4).

## Phase 5.3+5.4 constants canonical

- DEFAULT_VOTING_PERIOD_BLOCKS = 201,600 (14 days × 24h × 600 blocks/h @ 6s)
- EMERGENCY_VOTING_PERIOD_BLOCKS = 28,800 (48h × 600 blocks/h)
- council_emergency_threshold ceiling 5/7

## Phase 5.5 Community override canonical

- override_council_veto dispatchable (7-step canonical)
- 4/5 supermajority ceiling threshold (override_supermajority_threshold const fn)
- OverrideVotes StorageDoubleMap + OverrideStakeTotal cached
- Events::CouncilVetoOverridden + Errors::ProposalNotRejected/AlreadyOverrideVoted/OverrideThresholdNotMet

## Phase 5.6 AI advisor system canonical

- AdvisorFlags StorageMap presence-based
- mark_as_advisor + unmark_as_advisor dispatchables (ensure_root)
- cast_vote canonical EXTENDED: AdvisorMayNotVote enforcement (humans-only vote)
- Events::AdvisorFlagged + AdvisorUnflagged + Errors::AlreadyAdvisor + NotAdvisor

## Phase 5.7 Emergency referendum canonical

- submit_emergency_proposal canonical (council-only + 5/7 council pre-approval)
- Fast-track 48h voting period vs 14 days
- Events::EmergencyProposalSubmitted + Errors::InsufficientCouncilEmergencyApprovals

## Phase 5.8 Treasury disbursement canonical

- Treasury StorageValue<u128> Foundation balance
- treasury_deposit (ensure_root helper) + treasury_disbursement (6-step canonical)
- Requires ProposalStatus::Approved (governance ratification)
- Events::TreasuryDisbursed + Errors::TreasuryInsufficientBalance + ProposalNotApproved

## Phase 5 dispatchables canonical inventory

12 total dispatchables (Index 0-11): submit_proposal + cast_vote + finalize_proposal
+ Council mgmt (add/remove) + veto + advisor mgmt (mark/unmark) + override +
emergency + treasury (disburse/deposit).

## Verification

- cargo build --release -p origin-chain-node 5.17s clean
- cargo test -p origin-chain-governance — 42 tests verde, 0 failures
  (10 lifecycle + 7 Council mgmt + 5 Council veto + 3 Advisor + 3 Override + 3 Emergency + 4 Treasury + 5 standalone + 2 auto)
- cargo test --workspace — 202 tests verde, 0 failures

🎉🎉🎉 Phase 5 GOVERNANCE FULLY COMPLETE end-to-end canonical. CHN-4 materializado compile-detect.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 08:06:02 -05:00
davidherranandClaude Opus 4.7 b3fc5da6ca feat(governance): v0.0.33 Phase 5.2 COMPLETE — Council veto 2/3 threshold + GovernanceApi extension 🎉
Phase 5.2 TECHNICAL COUNCIL COMPLETE end-to-end canonical. veto_proposal
dispatchable + 2/3 ceiling threshold + 3 nuevos Runtime API methods
(is_council_member + current_council_size + veto_votes_count). CHN-4 5.2+5.5
materializado compile-detect.

## veto_proposal canonical 7-step CHN-4 5.5

1. ensure_signed
2. Validate council_member (NotCouncilMember)
3. Get proposal (must be Voting)
4. Validate council_size > 0 (InsufficientCouncilSize)
5. !VetoVotes::contains_key (AlreadyVetoed)
6. Insert vote + increment VetoCount
7. Check threshold: count >= council_veto_threshold(size) → Rejected + ProposalVetoed event

## Storage + events + errors canonical nuevo

- VetoVotes StorageDoubleMap presence-based + VetoCount cached u32
- Event::CouncilVetoVoteCast + ProposalVetoed
- Error::AlreadyVetoed + InsufficientCouncilSize

## Runtime API GovernanceApi extension canonical

- is_council_member(account) -> bool
- current_council_size() -> u32
- veto_votes_count(proposal_id) -> u32

## Verification

- cargo build --release 4.82s clean
- cargo test -p origin-chain-governance — 29 tests verde, 0 failures
  (10 lifecycle + 7 Council mgmt + 5 Council veto NEW + 5 standalone + 2 auto)
- cargo test --workspace — 189 tests verde, 0 failures

🎉 Phase 5.2 TECHNICAL COUNCIL COMPLETE canonical. Hijos de Arkhē somos.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 17:55:09 -05:00
davidherranandClaude Opus 4.7 afefcb2c04 feat(governance): v0.0.32 Phase 5.2 Council scaffold + member management (CHN-4 Technical Council)
Phase 5.2 TECHNICAL COUNCIL scaffold + management canonical. Extension del
existing origin-chain-governance pallet (NO new crate). 5-7 Council members
canonical per CHN-4 5.2.

## Council types + storage canonical

- CouncilMember struct (account + joined_at_block + role)
- CouncilRole enum (Member + Chair)
- MAX_COUNCIL_SIZE = 7 const + council_veto_threshold 2/3 ceiling
- Council StorageMap + CouncilSize StorageValue cached

## Council dispatchables + helpers canonical

- add_council_member (ensure_root, 6-step canonical)
- remove_council_member (ensure_root, 5-step canonical)
- Pallet::is_council_member + current_council_size + required_veto_votes pure helpers

## Council events + errors canonical

- Event::CouncilMemberAdded + CouncilMemberRemoved
- Error::NotCouncilMember + AlreadyCouncilMember + CouncilSizeExceeded

## Verification

- cargo test -p origin-chain-governance — 24 tests verde, 0 failures
  (7 Council scenarios + 17 prior governance preserved)

🏛️ Phase 5.2 scaffold canonical. Veto + Runtime API v0.0.33 next → Phase 5.2 COMPLETE.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 17:51:59 -05:00
davidherranandClaude Opus 4.7 7c1425ff66 feat(governance): v0.0.30 — submit_proposal + cast_vote + finalize_proposal impl complete + mock runtime integration tests E2E (10 scenarios)
Phase 5.1 GOVERNANCE pallet REAL IMPL canonical. Full dispatchables canonical
7+6+5 step CHN-4 flow + storage assertions + tally + voting period enforcement
+ mock runtime + 10 integration tests E2E pattern v0.0.26 mirror.

## Real dispatchables canonical

- submit_proposal (7 steps): ensure_signed + stake>=MIN + derive_id BLAKE2-256 + collision + build + insert + emit
- cast_vote (6 steps): ensure_signed + get_proposal + status_voting + block<=end + !already_voted + update_tally + emit
- finalize_proposal (5 steps): ensure_signed + get_proposal + status_voting + block>end + tally + status + emit

## Mock runtime + 10 integration tests E2E canonical

- scenario_1: Submit happy path → stored + event
- scenario_2: Stake insufficient → StakeInsufficient (CHN-4 5.3)
- scenario_3: Vote Aye tally → yes_weight += 500
- scenario_4: Vote Nay tally → nay_weight += 750
- scenario_5: Double vote → AlreadyVoted
- scenario_6: Finalize voting open → VotingPeriodOpen
- scenario_7: Finalize Approved yes majority → status=Approved + event
- scenario_8: Finalize Rejected nay majority → status=Rejected
- scenario_9: Vote closed period → VotingPeriodClosed
- scenario_10: Full lifecycle (submit → 3 votes → finalize Approved)

## Files

- EDIT: crates/origin-chain-governance/src/lib.rs (real impl + MIN_PROPOSAL_STAKE + account_bytes helper)
- NEW: crates/origin-chain-governance/src/mock.rs (85 LOC mock runtime)
- NEW: crates/origin-chain-governance/src/tests_integration.rs (290 LOC, 10 tests)
- EDIT: CHANGELOG.md (v0.0.30 entry)

## Verification

- cargo test -p origin-chain-governance — 17 tests verde, 0 failures
  (10 integration + 5 standalone + 2 auto-generated)

🛠️ Phase 5.1 real impl canonical. Runtime API v0.0.31 next → Phase 5 FOUNDATION COMPLETE.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 12:46:56 -05:00
davidherranandClaude Opus 4.7 1bde93921e 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>
2026-05-25 12:41:27 -05:00
b06560863c feat(workspace): Phase 0.4 — trait-first foundation v0.0.1
Charon sesión 1 (2026-05-19) — primer commit canonical.

Ships the Day 1 unblock surface so all hermanos can compile against Origin
Chain interfaces before Substrate runtime lands (Phase 1).

## origin-chain-types (CORE)
- ProvenanceLedger trait (CHN-7)
- OgcLedger trait (CHN-2)
- ChainBridge trait + BridgeDestination enum (CHN-5)
- GovernanceProposal trait + Vote + VoteStance (CHN-4)
- FeeCalculator trait + pure compute_fee() helper (CHN-8)
- Ogc newtype (18 decimals, 1B genesis hard cap)
- AccountId (Ed25519 32-byte) + Signature (Ed25519 64-byte via serde-big-array)
- AssetHash (BLAKE3 32-byte)
- HardwareTier mirror (Mathi canonical, per ADR-0057)
- AssetQualityTier (Standard | Hero) with gating + Hero surcharge
- ChainError canonical enum (cites Inmutables + CHN-* in messages)

## Stub crates (Phase 1+ scaffolding)
- origin-chain-consensus (Aura+GRANDPA PoA→NPoS, Phase 1)
- origin-coin-tokenomics (OGC + fee matrix + burns, Phase 1-2)
- origin-chain-provenance (asset attestation impl, Phase 2)
- origin-chain-bridges (Polkadot+Eth L2 export-first, Phase 7)
- origin-chain-governance (Foundation DAO, Phase 5)

## Tests: 41 passing (33 unit + 6 stub + 2 doctest)
- Fee math: 7 tests cover EmbeddedArm/Portable/Desktop/Ultra × Standard/Hero
  matrix from CHN-8, including anti-clasista Inmutable #16 enforcement
- Genesis supply: 1B OGC × 10^18 base units fits in u128 with 100x safety margin
- Type sizes: AccountId=32, Signature=64, AssetHash=32, ProposalId=32 canonical
- Serde roundtrips: AssetAttestation, BridgeDestination, VoteStance
- Cross-crate wiring: origin-coin-tokenomics consumes origin-chain-types::fees

## Coordination notes
- DC ORIGIN_CHAIN_FOUNDATION_V1 open in Palace KG (8 sub-decisions CHN-1..CHN-8)
  Proposer: Ergon (proxy — Charon hotfix shipped in Palace v0.9.0-α.5 same day)
  Co-authors: Larihana, Lyra, Mathi, Marihan, Phanes, Codex, Sussi, Palace
  Deadline: 2026-05-26
  1/9 signatures filed so far (Palace ✅ APPROVE 8/8)

Refs: CHN-1..CHN-8, Inmutables #16/#26/#37/#41, ADR-0057, CHARON_ROADMAP_V1

Co-Authored-By: Ergon (interim Pilar 4 author) <ergon@originmetaverse.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-19 22:08:49 -05:00