SIGN IN SIGN UP

mcp: make late-registration tool refresh one-shot + surface it (#206 follow-up)

The #206 fix lets `tool_definitions()` rebuild the locked tool snapshot
once when `mcp__*` tools register asynchronously after the first turn.
We deliberately do NOT block the first turn on MCP connection (servers
can be slow or hang, and the agent should be reachable the moment the
session spawns), so the first snapshot is locked without MCP tools and a
single intentional provider prompt-cache miss is accepted to expose them.

Two improvements:

1. One-shot guard. Add `mcp_late_register_resolved` so the registry is
   scanned for late MCP tools at most once per locked snapshot instead of
   on every turn. After the accepted rebuild (or once we confirm there
   are no MCP tools to wait for) the per-turn scan stops. Without this, a
   server that connects in waves could keep rebuilding and thrash the
   prompt cache. The flag is re-armed on any explicit unlock (mcp reload)
   and on compaction/reset/resume/repair so a fresh snapshot can pick up
   MCP tools again once.

2. Surface the intentional miss. The rebuild now logs an explicit message
   explaining it is a deliberate one-time cache miss (and why), and the
   TUI shows a "MCP ready: N tools ... (one-time tool refresh)" status
   notice when MCP tools first become available, so the refresh isn't
   mistaken for a bug.

Tests: rebuild happens at most once (second-wave MCP tool is not
surfaced until an explicit unlock; guard latches and re-arms correctly),
plus the existing #206 visibility/stability guards still pass.
J
jeremy committed
1c1d18e85eca650a4ce1ad273352ce9bbb7e4903
Parent: 423f408