You are browsing as a guest. Sign up (or log in) to start making projects!

1h 58m 11s logged

Made Big Brother stop lying about your loyalty score

The /bigbrother-loyalty command was silently corrupting its own scoreboard. Every call overwrote the user’s stored score with whatever the current calculation produced — which meant a citizen who hit 200 points last week would see their displayed rank drop to 50 after a quiet few days. The scoreboard was a ledger of “most recent” instead of “best ever”, which is the opposite of how a loyalty panopticon should work.

The fix in Code/Surveillance.js was small but mattered: scoreboard() now only writes when the new score strictly beats the stored high, and stamps an achievedAt ISO timestamp on each new record. While in there, I also wired /bigbrother-scoreboard to refresh the caller’s score before displaying, so running it actually updates your entry — previously it just read stale data. The refresh is wrapped in try/catch so a transient Slack or HuggingFace failure doesn’t break the leaderboard read.

That scoreboard bug was the tip of a much longer audit. The same session surfaced and fixed ~50 defects across the codebase: Surveillance.presenceCheck was returning undefined (not 0) on unknown presence values, producing NaN loyalty scores that then broke the sort; Telescreen.propaganda() would crash with TypeError if broadcasts.json was empty; Truth.getNews() called .map() on a potentially-missing articles array; concurrent readFile/writeFile pairs on the same JSON file were last-writer-wins. Added a 12-line per-file async mutex in Code/lock.js and wrapped every read-merge-write critical section. Also added .env validation at boot — previously a missing HF_TOKEN would surface as an undefined auth header 45 minutes into a Slack session instead of failing at startup.

0
4

Comments 0

No comments yet. Be the first!