Repository navigation
feat(bots): icon rules storage and roster timestamps (#692) - #348
Merged
Merged
Conversation
…#692) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ck-fixtures test(bots): icon rule fields in test fixtures (pingdotgg#692)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
notFrost
commented
Dec 1, 2026
notFrost
left a comment
Author
There was a problem hiding this comment.
Review (Lukas, lead engineer): approved, merging into feat/bot-icon-timeline. Posted as a comment because this account can't formally approve.
Checked against the issue pingdotgg#692 decisions and phase3-contract.md:
- Storage: additive
icon_rules_jsoncolumn. NULL decodes toDEFAULT_BOT_ICON_RULES. Tested with a legacy row that has the column dropped. - Validation:
BotIconRulesInputis decoded again in the service for in-process callers. Timeline images accept png/jpeg/webp only, so a GIF data URL or reference is refused (D19). Timeline images share the 512 KB limit. - D32: rule shapes equal to the Default Icon's shape are nulled on create and on update, including an icon-only update.
- D31: an icon change keeps
iconRules. - Images:
removeAvatarsExceptkeeps the icon and every timeline image, andavatarPathserves timeline images. Tested. - Roster timestamps:
workingSinceis set only while the Bot is working, and restarts after a blocking wait (D16). Tested, including after a restart.deliveredAtcounts completed, non-silent runs and excludesNO_REPLY(D18).erroredAtis set on a failed run (D23).- The waiting → running roster push is now fixed via
onRequestSettled. The proof: the D16 test times out without the fix.
- D25/D33:
iconRulesis not in the MCP tools. - Scope: the diff against the base touches only the 21 expected files, so no stray reverts.
Run locally on fb9458aa9a (Windows):
vp run typecheck → 44/44 successful, exit 0
vp lint --report-unused-disable-directives <21 changed files> → exit 0
vp test run apps/server/src/bots apps/server/src/serverPush apps/server/src/mcp \
packages/contracts/src/bot.test.ts packages/client-runtime/src/botAvatarShapeIds.test.ts
Test Files 2 failed | 49 passed (51)
Tests 2 failed | 756 passed (758)
The two failures are the Windows-only worktree tests (WorktreeMcpService.test.ts explicit local alias, handlers.test.ts approved layout command). They also fail on the clean base d7519d4, so they are not caused by this PR.
Noted, not blocking:
- An interrupted run with a partial reply doesn't count as delivered. That's fine for now, and I'll raise it with Frost if he wants otherwise.
onRequestSettlednow pushes the roster on every settled request in a Bot thread, not only user_input ones. That's a little extra traffic, and it's acceptable.
This was referenced Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part A of notFrost/sophie#692, phase 3: contract, storage and server. The client evaluator and display come in part B.
Bots get per-rule icon timelines and rule shapes (
iconRules). The roster now says when a Bot started working, delivered a reply, or failed, so clients can pick which icon to show without extra requests.What changed
Contract (
packages/contracts/src/bot.ts)BotRecord.iconRules: lenient when read back, so a later limit change can't break an older client. Absent means the default.BotIconRulesInputon create and update enforces the limits:orderholds each rule exactly once;BOT_AVATAR_SHAPE_IDS;lastCalledShapeAfterMinutesbetween 1 and 525,600;BotRosterEntrygainsworkingSince,deliveredAtanderroredAt: an ISO time or null, and null when absent.iconRulesis left out of thebot_createandbot_updateMCP tools (D25, D33).Storage (
BotStore.ts)icon_rules_jsoncolumn, added for existing databases bymigrateColumns. A Bot saved before this reads as the default.Server (
BotService.ts, newBotIconRules.tsandBotRosterTimes.ts)removeAvatarsExceptkeeps the icon plus every timeline image.avatarPathserves only an image the Bot currently shows.iconRules. An update withouticonRuleskeeps the stored value.workingSinceis the later of the active work's start (activityRunStartedAt) and the user's last answer to a request that blocked the Bot (D16). Null unless the Bot is working.deliveredAtis the latest run's completion time when it completed and its last assistant message isn'tNO_REPLYor empty (D18).erroredAtis the latest run's completion time when it failed (D23).No changes to
orchestrationV2.tsorProjectionStore.ts.Answers from the investigation
a) Does a failed run set
completedAt? Yes.completedAt.RunExecutionService.ts:771sets it,:866-870puts it on the run,:1032emits it. This covers failed as well as completed, interrupted and cancelled.Orchestrator.ts:2589), a start failure (Orchestrator.ts:13723), andProviderTurnStartService.ts:627.latestRunCompletedAt(ProjectionStore.ts:1955), and failed runs are never treated as silent (ProjectionStore.ts:2074).b) How are
NO_REPLYand silent runs detected?ProjectionStorealready drops them from the shell's runs. That covers idle compactions, memory consolidations, and check-ins or mention notices the Bot answered withNO_REPLY(isSilentRunForShell,ProjectionStore.ts:2068-2085, applied at:1881). So the shell's latest run is always the latest non-silent one, anddeliveredAtonly looks at that run. A silent run afterwards doesn't replace an earlier delivery.NO_REPLY: the shell leaveslatestVisibleMessagenull (ProjectionStore.ts:1977), so the server reads that run's assistant messages. It does that once per run and caches the verdict per Bot thread (BotService.ts:336).isDelivery(BotRosterTimes.ts:52) takes the last non-empty assistant message and checks it with the sharedisBotNoReplyMessage, which also catchesNO_REPLYwrapped in markdown.completedruns count as a delivery, matchingisAnsweredRuninProjectionStore. An interrupted run with a partial reply does not.c) Which event re-sends the roster on waiting → running? Before this PR, none.
running. The Bot reads as waiting only throughshell.pendingRequests(statusOf), so answering it emits norun.updated.runtime-request.updated. The reactor used to return early for every settled request (only a resolveduser_inputreachedonHumanInput, which doesn't notify).onRequestSettled(BotService.ts:1191, reached from:1223) notifies for any settled request in a Bot thread. It also records the wait's end forworkingSince.run.updated(:1219) still covers deliveries and failures.TestTimeoutError: Test timed out in 120000ms). With it, the test passes.How
workingSincelearns when a wait ended:BotService.ts:324).Tests
vp run typecheck:vp run: 42/44 cache hit (95%), 44/44 successful(exit 0)vp linton the changed files: exit 0. The pre-commit hook passed fmt, lint and knip.vp test run apps/server/src/bots apps/server/src/serverPush apps/server/src/mcp packages/contracts/src/bot.test.ts:The 2 failing tests were already failing before this PR. I ran both on a separate clean checkout of
origin/feat/bot-icon-timeline(d7519d4), and both fail there the same way:One compares a Windows path separator (
\worktreevs/worktree); the other runs a layout shell command that exits non-zero on Windows. Neither touches Bot code.New tests:
BotService.test.ts:avatarPath;iconRuleskeeps it;order, unknown shape, last-called delay of 0 or over a year, GIF upload, stored GIF);NO_REPLY,**NO_REPLY**, no reply, a failed run and a working Bot;workingSinceand re-sends the roster, and a non-blocking answer doesn't move it;BotStore.test.ts: a Bot keeps its icon rules, and a database without the column reads the default.BotRosterTimes.test.ts,BotIconRules.test.ts: pure helpers.mcp/toolkits/bots/handlers.test.ts: its fake thread service gained an emptygetThreadRecords, because the roster now reads records while a Bot is working.Left out
packages/client-runtime,apps/web).iconRulesthrough MCP (D25, D33).🤖 Generated with Claude Code