rank-badges: rungs belong to names, so "not" is revoked too when a key leaves the directory

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FAqjv2GjbEF3HRasdLdmzF
This commit is contained in:
teahubxyzandClaude Opus 5.5 committed 2026-10-29 19:19:41 +00:00
1 parent 6c497686da
commit 9721b59ea9
1 file changed
+3 -2
+3 -2
View File
@@ -4,7 +4,8 @@ name: rank-badges
# 2. Reads https://well-known.online/ranks.json (every ranked key by its current rung). A key holds its rung and
# every rung below it: not = all ranked keys, slightly = slightly + very, very = very.
# 3. Awards (kind 8) one event per key per rung, only where missing, so repeat runs are no-ops.
# 4. Revokes: a key that slipped below slightly/very gets that award deleted (NIP-09 kind 5). "not" is never revoked.
# 4. Revokes: a key that slipped below a rung, or whose name lapsed (rungs belong to names), gets that award deleted
# (NIP-09 kind 5).
on:
schedule:
- cron: '*/15 * * * *'
@@ -95,7 +96,7 @@ jobs:
const held = new Map(); // pubkey -> [award event ids]
for (const e of awards) for (const t of e.tags) if (t[0] === 'p') held.set(t[1], [...(held.get(t[1]) || []), e.id]);
const add = [...want[r]].filter((k) => !held.has(k));
const drop = r === 'not' ? [] : [...held.keys()].filter((k) => !want[r].has(k));
const drop = [...held.keys()].filter((k) => !want[r].has(k));
console.log(`${r}: want ${want[r].size}, held ${held.size}, award ${add.length}, revoke ${drop.length}`);
for (const k of add) await publish(sign(8, [['a', coord(r)], ['p', k, RELAYS[0]]]), `award ${r} ${k.slice(0, 8)}`);
for (const k of drop) await publish(sign(5, [...held.get(k).map((id) => ['e', id]), ['k', '8']], `slipped below ${r}.well-known`), `revoke ${r} ${k.slice(0, 8)}`);