Files
decision/crates/ld-server/migrations/0011_quorum.sql
T
YvvandClaude Opus 5.5 01b7841472 Lot S, phase 2 : le quorum dans le serveur (ADR 0013), vu rouge puis vert
- migration 0011 (additive ; 0010 reste au lot V) : documents.quorums (par cran,
  NULL = vote_floor à chaque cran, le C d'avant), units.quorum (NULL = celui du
  cran), journaux quorum_changes et quorum_amendments ;
- quorum effectif = units.quorum ?? quorums[cran] ; les propositions d'inertie et
  les modules en héritent ; p0 = 2 × vote_floor / W, jamais le quorum d'un article ;
- route PUT /units/{id}/quorum { "quorum": n | null } : trustin_access::sets_quorum
  (l'auteur de la première version, un administrateur pour le seed), refusée dès
  qu'un vote existe (quorum::voted_units : vote du serveur, bulletin de la chaîne
  en attente ou confirmé, adoption) ; bornes 2..W, 1..W dans le groupe d'essai ;
- amendement gardé 2026-11-03-quorums-par-cran : écrit les quorums du seed là où
  il n'y en a pas, une fois par document, consigné, file de publication là où il
  publie ;
- JSON : evaluation.quorum / yesNeeded / noNeeded ; l'unité : quorum,
  quorumDefault, canSetQuorum ; doc.quorums ; levels[].quorum ; document.json
  publié : quorums ; adoptions.params : quorum (plus de constant) ;
- seed : quorums 12 · 12 · 50 · 50 · 50 (Monnaie libre), 1 partout (essai).
- tests : tests/quorum.rs (5) et les règles pures ; les scénarios du groupe
  d'essai qui demandaient deux voix posent le quorum 2 de l'article, comme son
  auteur le ferait ; les chiffres de Monnaie libre suivent (9 au cran 2, 39 au
  cran 3, 43 au cran 4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 05:00:41 +01:00

49 lines
2.7 KiB
SQL

-- The quorum (2026-11-03, ADR 0013). Additive only: nothing is dropped, nothing
-- an older image needs is rewritten. (0010 is kept for lot V: the gap is meant.)
--
-- Yvv, 2026-11-02: « C suit le cran, mais c'est une proposition par défaut,
-- variable modifiable par l'auteur initial du texte… c'est plutôt un quorum ».
-- The floor C of *for* votes put in front of the formula gives way to a quorum Q
-- by level: from Q voters on, the share of the inertia applies; below it, the
-- voters missing count as against (2026-11-03: « Ils comptent comme non »).
-- `documents.vote_floor` stays: the reference quorum Q₀, read for the reference
-- participation p0 = 2Q₀/W only (never an article's quorum), and as every
-- level's quorum while `quorums` is NULL. An older image ignores both columns.
-- The quorum of each level, 1 to 5, as JSON `[Q1, Q2, Q3, Q4, Q5]`: the default
-- of an article at that level (Yvv: « 12 · 12 · 50 · 50 · 50 » in Monnaie libre,
-- 1 everywhere in the test group). NULL: a base the quorum amendment
-- (src/quorum_amend.rs) has not reached yet.
ALTER TABLE documents ADD COLUMN quorums TEXT;
-- The quorum of an article, set by the author of its first version before the
-- first vote (src/quorum.rs; Yvv: « L'auteur, avant le 1er vote »). NULL: the
-- quorum of its level. A change of its inertia is judged on it too.
ALTER TABLE units ADD COLUMN quorum INTEGER;
-- Every change of an article's own quorum: who, from what, to what.
CREATE TABLE quorum_changes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
unit_id TEXT NOT NULL REFERENCES units(id),
doc_id TEXT NOT NULL REFERENCES documents(id),
from_quorum INTEGER, -- NULL: the quorum of its level
to_quorum INTEGER, -- NULL: back to the quorum of its level
identity_id TEXT NOT NULL REFERENCES identities(id),
at TEXT NOT NULL
);
CREATE INDEX quorum_changes_unit ON quorum_changes(unit_id);
-- Quorum amendments (src/quorum_amend.rs): the quorums by level of the seed,
-- written into an existing document that holds none, decided once per document.
-- Each decision is kept here: applied, refused (and why), or present.
CREATE TABLE quorum_amendments (
amendment_id TEXT NOT NULL,
doc_id TEXT NOT NULL REFERENCES documents(id),
from_quorums TEXT, -- what the document held: NULL, or its JSON
to_quorums TEXT NOT NULL, -- the seed's, JSON
outcome TEXT NOT NULL, -- applied | refused | present
reason TEXT, -- why it was refused
at TEXT NOT NULL,
PRIMARY KEY (amendment_id, doc_id)
);