Repository navigation
Conversation
Turn settlement marked a thread unread after any turn but a keepalive or a quiet wake, so the cache-expiry compaction an hour after a bot's answer lit it up again with nothing new. turnIsNews now decides unread, the bot unread count and notifications alike: an answer or a failure, never a compaction, a keepalive, a quiet wake or a stop.
|
This pull request stops read bot threads from flipping back to unread after hourly cache compactions, keepalives, quiet wakes, or stopped turns. Only a finished answer or failure now marks a thread unread, matching what the unread count already ignored. No comments posted: the reviewers raised no finding. Review details
Commands run (11)Installed deps (bun install exit 0). Attempted core compact.test.ts via bun test runner but it was killed/timed out under the 3-min/1GB sandbox limit, so the PR's new regression test and full core/UI suites could not be verified here. Inspected changed files: turnIsNews in packages/contracts/src/turns.ts now gates unread/notification on done/error excluding compact/keepalive and quiet done wakes, with store.ts, turn-settlement.ts and fake-client wired to it; no failure attributable to the change was reproduced. passed · exit 0 · 0 s ls -R /work | head -n 100; echo "---"; cat /work/package.json | head -n 120passed · exit 0 · 0 s cat /work/packages/core/package.json; echo "---CORE_SCRIPTS---"; cat /work/packages/contracts/package.json; echo "---UI---"; cat /work/packages/ui/package.json | head -n 80passed · exit 0 · 5 s bun install --frozen-lockfile 2>&1 | tail -n 20
echo "EXIT:$?"timed out · 3 min bun run --cwd packages/core test test/compact.test.ts 2>&1 | tail -n 80; echo "EXIT:${PIPESTATUS[0]}"passed · exit 0 · 0 s cat packages/core/package.json | head -n 60; echo "---"; ls packages/core/test/compact* 2>&1; echo "---"; wc -l packages/core/test/compact.test.ts packages/contracts/src/turns.ts packages/core/src/threads/turn-settlement.ts
timeout 10 bun --version; echo OKpassed · exit 0 · 1 s git diff HEAD~1 --stat 2>&1 | head -n 30; echo "==="; git log --oneline -5 2>&1 | head -n 10
echo "---TEST_RUNNER---"; head -n 80 packages/core/bin/test.ts
echo "---TURNS---"; cat packages/contracts/src/turns.tspassed · exit 0 · 0 s git log --oneline -5; echo "==="; git diff HEAD~1 --stat
echo "===runner==="; wc -l packages/core/bin/test.ts; head -n 120 packages/core/bin/test.tspassed · exit 0 · 0 s git diff HEAD~1 -- packages/contracts/src/turns.ts packages/core/src/threads/turn-settlement.ts packages/core/src/agents/store.ts packages/ui/src/lib/fake-client/turns.ts docs/bots.md
echo "===NEWTEST==="; git diff HEAD~1 -- packages/core/test/compact.test.tspassed · exit 0 · 0 s cat packages/contracts/src/turns.ts | head -n 140
echo "===DOC==="; git diff HEAD~1 -- docs/bots.mdpassed · exit 0 · 0 s cat packages/contracts/src/turns.ts | tail -n +135 | head -n 100
echo "===SETTLE==="; cat packages/core/src/threads/turn-settlement.ts
echo "===FAKE==="; cat packages/ui/src/lib/fake-client/turns.ts | head -n 120passed · exit 0 · 0 s grep -n "turnIsNews\|notifiesOnFinish\|countUnread" packages/contracts/src/turns.ts; echo "==="; sed -n '130,219p' packages/contracts/src/turns.ts
echo "===SETTLE_HEAD==="; sed -n '1,90p' packages/core/src/threads/turn-settlement.ts |
Problem
A bot the owner had read lit up again as "1 new answer" with nothing new in it. In a live journal, over 3 days, 14 of 77 read-to-unread flips on bot threads came from compact turns: the cache-expiry compaction about an hour after the bot's last answer. 3 more came from turns stopped by a core restart.
Turn settlement treated only keepalives and quiet wakes as silent. The bot unread count (
countUnread) andnotifiesOnFinishalready ignored compactions, keepalives and turns that were neither done nor failed, so the row showedmax(1, 0)= 1 for a thread marked unread by housekeeping.Change
turnIsNewsinpackages/contracts/src/turns.ts: a done or failed turn, not a compaction or keepalive, not a quiet done wake.countUnread,notifiesOnFinish(same results as before) and the fake client use the same rule.docs/bots.mdsays what counts as unread.Coordination, delegation, routine and event answers still count as news.
Verified
a thread read before its compaction or a stop stays read: neither is newsinpackages/core/test/compact.test.tsfails on main at both its compaction and stop assertions, passes here.bun run check: exit 0.notifiesOnFinish, one process each: 70 pass. Incompact.test.ts,resolved driver and idle policies...hits the 5 s timeout on the loaded dev box the same way on main, and passes with--timeout 30000.No visual change.