Changeset 6eab7e9 in Klonkt for src/services/guardianship/gated.js
- Timestamp:
- 07/28/2026 11:22:07 PM (6 weeks ago)
- Branches:
- main
- Children:
- 0202104
- Parents:
- 6c152a5
- File:
-
- 1 edited
-
src/services/guardianship/gated.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/guardianship/gated.js
r6c152a5 r6eab7e9 15 15 import db from '../../config/database.js'; 16 16 import { listGuardians } from './relations.js'; 17 import * as availability from './availability.js'; 17 18 18 19 /** The window a gated-setting decision stays open. Reversible, so a day. */ … … 67 68 const column = featureColumn(feature); 68 69 if (!column) return { state: 'expired', error: 'unknown_feature' }; 69 const guardians = listGuardians(slug).map((g) => g.other_uri); 70 if (!guardians.includes(guardianUri)) return { state: 'expired', error: 'not_a_guardian' }; 70 const all = listGuardians(slug).map((g) => g.other_uri); 71 if (!all.includes(guardianUri)) return { state: 'expired', error: 'not_a_guardian' }; 72 // A vote is an answer, whatever it is a vote on (§3.6): the voter is 73 // restored first, so it always counts itself back into the set below. 74 availability.oneAnswer(guardianUri, Date.now()); 75 // §3.5: the threshold runs over the AVAILABLE set. Membership is checked 76 // against the full list above: any guardian may answer, and answering is 77 // exactly what brings it back in. 78 const guardians = availability.availableSet(slug, all, Date.now()); 71 79 72 80 // The window opens with the first answer, and a stale decision starts over: … … 100 108 const votes = db.prepare('SELECT guardian_uri, value FROM ap_gated_votes WHERE slug = ? AND feature = ?') 101 109 .all(slug, feature); 102 const guardians = listGuardians(slug).map((g) => g.other_uri); 110 // Progress over the available set (§3.5), like the tally itself. 111 const guardians = availability.availableSet(slug, listGuardians(slug).map((g) => g.other_uri), Date.now()); 103 112 return { votes: votes.length, need: thresholdFor(guardians.length), of: guardians.length }; 104 113 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)