Qualifier : corrections R2/R6 + router + modèle DB + wizard frontend
Corrections moteur (TDD) : - R2 : within_mandate → record_in_observatory=True (Observatoire des décisions) - R6 : >50 personnes → collective recommandé, pas obligatoire (confidence=recommended) - R3 supprimée : affected_count=1 hors périmètre de l'outil - R9-R12 renommés G1-G4 (garde-fous internes) - 23 tests, 213/213 verts Étape 1 — Router /api/v1/qualify : - POST / → qualify() avec config depuis DB ou defaults - GET /protocol → protocole actif - POST /protocol → créer/remplacer (auth requise) Étape 2 — Modèle QualificationProtocol : - Table qualification_protocols (seuils configurables via admin) - Migration Alembic + seed du protocole par défaut Étape 3 — Wizard frontend decisions/new.vue : - Étape 1 : formulaire de qualification (mandat, affected_count, structurant, contexte) - Étape 2 : résultat (type, raisons, modalités, observatoire, on-chain) - Étape 3 : formulaire de décision (titre, description, protocole si collectif) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ from app.models.decision import Decision, DecisionStep
|
||||
from app.models.vote import VoteSession, Vote
|
||||
from app.models.mandate import Mandate, MandateStep
|
||||
from app.models.protocol import VotingProtocol, FormulaConfig
|
||||
from app.models.qualification import QualificationProtocol
|
||||
from app.models.sanctuary import SanctuaryEntry
|
||||
from app.models.cache import BlockchainCache
|
||||
|
||||
@@ -16,6 +17,7 @@ __all__ = [
|
||||
"VoteSession", "Vote",
|
||||
"Mandate", "MandateStep",
|
||||
"VotingProtocol", "FormulaConfig",
|
||||
"QualificationProtocol",
|
||||
"SanctuaryEntry",
|
||||
"BlockchainCache",
|
||||
]
|
||||
|
||||
38
backend/app/models/qualification.py
Normal file
38
backend/app/models/qualification.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import json
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, Integer, String, Text, Uuid, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class QualificationProtocol(Base):
|
||||
"""Active configuration for the decision qualification engine.
|
||||
|
||||
Thresholds stored here override the engine defaults and can be updated
|
||||
through the admin interface (meta-governance).
|
||||
Only one record should be active at a time (is_active=True).
|
||||
"""
|
||||
__tablename__ = "qualification_protocols"
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, default=uuid.uuid4)
|
||||
name: Mapped[str] = mapped_column(String(128), nullable=False)
|
||||
description: Mapped[str | None] = mapped_column(Text)
|
||||
|
||||
small_group_max: Mapped[int] = mapped_column(Integer, default=5)
|
||||
collective_wot_min: Mapped[int] = mapped_column(Integer, default=50)
|
||||
|
||||
# JSON array of modality slugs, e.g. '["vote_wot","vote_smith","election"]'
|
||||
default_modalities_json: Mapped[str] = mapped_column(
|
||||
Text,
|
||||
default='["vote_wot","vote_smith","consultation_avis","election"]',
|
||||
)
|
||||
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
@property
|
||||
def default_modalities(self) -> list[str]:
|
||||
return json.loads(self.default_modalities_json)
|
||||
Reference in New Issue
Block a user