Plateforme de decisions collectives pour Duniter/G1. Backend FastAPI async + PostgreSQL (14 tables, 8 routers, 6 services, moteur de vote avec formule d'inertie WoT/Smith/TechComm). Frontend Nuxt 4 + Nuxt UI v3 + Pinia (9 pages, 5 stores). Infrastructure Docker + Woodpecker CI + Traefik. Documentation technique et utilisateur (15 fichiers). Seed : Licence G1, Engagement Forgeron v2.0.0, 4 protocoles de vote. 30 tests unitaires (formules, mode params, vote nuance) -- tous verts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
84 lines
3.2 KiB
Python
84 lines
3.2 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
# ── Formula Config ───────────────────────────────────────────────
|
|
|
|
|
|
class FormulaConfigCreate(BaseModel):
|
|
"""Payload for creating a WoT threshold formula configuration."""
|
|
|
|
name: str = Field(..., min_length=1, max_length=128)
|
|
description: str | None = None
|
|
|
|
# WoT threshold params
|
|
duration_days: int = Field(default=30, ge=1, description="Duration of the vote in days")
|
|
majority_pct: int = Field(default=50, ge=1, le=100, description="Majority percentage required")
|
|
base_exponent: float = Field(default=0.1, ge=0.0, le=1.0, description="Base exponent B in the formula")
|
|
gradient_exponent: float = Field(default=0.2, ge=0.0, le=2.0, description="Gradient exponent G in the formula")
|
|
constant_base: float = Field(default=0.0, ge=0.0, le=1.0, description="Constant base C in the formula")
|
|
|
|
# Smith criterion
|
|
smith_exponent: float | None = Field(default=None, ge=0.0, le=1.0, description="Smith criterion exponent S")
|
|
|
|
# TechComm criterion
|
|
techcomm_exponent: float | None = Field(default=None, ge=0.0, le=1.0, description="TechComm criterion exponent T")
|
|
|
|
# Nuanced vote
|
|
nuanced_min_participants: int | None = Field(default=None, ge=0, description="Minimum participants for nuanced vote")
|
|
nuanced_threshold_pct: int | None = Field(default=None, ge=0, le=100, description="Threshold percentage for nuanced vote")
|
|
|
|
|
|
class FormulaConfigOut(BaseModel):
|
|
"""Full formula configuration representation."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: UUID
|
|
name: str
|
|
description: str | None = None
|
|
duration_days: int
|
|
majority_pct: int
|
|
base_exponent: float
|
|
gradient_exponent: float
|
|
constant_base: float
|
|
smith_exponent: float | None = None
|
|
techcomm_exponent: float | None = None
|
|
nuanced_min_participants: int | None = None
|
|
nuanced_threshold_pct: int | None = None
|
|
created_at: datetime
|
|
|
|
|
|
# ── Voting Protocol ──────────────────────────────────────────────
|
|
|
|
|
|
class VotingProtocolCreate(BaseModel):
|
|
"""Payload for creating a voting protocol."""
|
|
|
|
name: str = Field(..., min_length=1, max_length=128)
|
|
description: str | None = None
|
|
vote_type: str = Field(..., max_length=32, description="binary, nuanced")
|
|
formula_config_id: UUID = Field(..., description="Reference to the formula configuration")
|
|
mode_params: str | None = Field(default=None, max_length=64, description='e.g. "D30M50B.1G.2T.1"')
|
|
is_meta_governed: bool = Field(default=False, description="Whether this protocol is itself governed by meta-vote")
|
|
|
|
|
|
class VotingProtocolOut(BaseModel):
|
|
"""Full voting protocol representation including formula config."""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: UUID
|
|
name: str
|
|
description: str | None = None
|
|
vote_type: str
|
|
formula_config_id: UUID
|
|
mode_params: str | None = None
|
|
is_meta_governed: bool
|
|
created_at: datetime
|
|
formula_config: FormulaConfigOut
|