From 1503e579bab024d4a0c8787033e2cb901b8c68db Mon Sep 17 00:00:00 2001 From: Yvv Date: Fri, 30 Oct 2026 11:22:23 +0100 Subject: [PATCH] =?UTF-8?q?v3=20:=20les=20versions=20d'un=20m=C3=AAme=20in?= =?UTF-8?q?stant=20gardent=20l'ordre=20o=C3=B9=20elles=20ont=20=C3=A9t?= =?UTF-8?q?=C3=A9=20=C3=A9crites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les variantes d'un seed partagent la même seconde : la liste les ordonnait par leur identifiant aléatoire, donc différemment d'une base à l'autre (E3 : 0.4.0-draft avant 1.0.0 une fois sur deux, vu par C14). Dernier départage : l'ordre d'insertion (rowid). Le moteur classe les rivales lui-même ; seul l'affichage change. Co-Authored-By: Claude Opus 5.5 --- crates/ld-server/src/docs.rs | 4 +++- crates/ld-server/tests/api.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ld-server/src/docs.rs b/crates/ld-server/src/docs.rs index d9cd60f..8776901 100644 --- a/crates/ld-server/src/docs.rs +++ b/crates/ld-server/src/docs.rs @@ -289,9 +289,11 @@ pub async fn load_state(state: &AppState, doc_id: &str) -> AppResult { .bind(doc_id) .fetch_all(&state.db) .await?; + // Same second (the variants of a seed): the order they were written in, not their + // random identifiers. The engine ranks rivals on its own; this order is what people see. let proposals = sqlx::query_as::<_, ProposalRow>(&format!( "{PROPOSAL_SELECT} WHERE p.unit_id IN (SELECT id FROM units WHERE doc_id = ?) - AND p.status IN ('open', 'in_force', 'draft') ORDER BY p.submitted_at, p.created_at, p.id" + AND p.status IN ('open', 'in_force', 'draft') ORDER BY p.submitted_at, p.created_at, p.rowid" )) .bind(doc_id) .fetch_all(&state.db) diff --git a/crates/ld-server/tests/api.rs b/crates/ld-server/tests/api.rs index f7574db..fd0263d 100644 --- a/crates/ld-server/tests/api.rs +++ b/crates/ld-server/tests/api.rs @@ -115,7 +115,9 @@ async fn the_seed_a_minima_and_the_open_proposals() { // Every other article is an open proposal at zero votes, standard inertia. let e3 = unit(&doc, "E3"); assert!(e3["inForce"].is_null()); - assert_eq!(e3["proposals"].as_array().expect("p").len(), 2, "E3 and its 0.4.0 variant"); + // In the order of the seed, whatever their random identifiers. + let labels: Vec<&str> = e3["proposals"].as_array().expect("p").iter().filter_map(|p| p["label"].as_str()).collect(); + assert_eq!(labels, ["1.0.0", "0.4.0-draft"], "E3 and its 0.4.0 variant"); assert_eq!(e3["inertia"], "standard"); // Translations seeded. assert!(e1["translations"]["en"]["body"].as_str().expect("en").contains("commit"));