acpmux: _acpmux/info answers while logs load

Merged
TE
17d ago
+95-5

Root cause

#22916 made _acpmux/info wait for logs_ready, which a restarted daemon sets once the deferred chat-log load (load_logs, after its ready line) is done. On a large log store that load takes longer than 2 s. The app daemon (cmux-tui-core) calls info with a 2 s timeout, and it reads only what the saved session list already holds:

  • agent_message_acpmux.rs: the pump's hand-over checks the session id. A timeout makes it Handover::Unreachable, so the message stays queued. The withdraw path's NoSession check also reads only the id.
  • agent_session_link.rs: the message policy's workspace lookup reads sessionEnv.CMUX_WORKSPACE_ID. A timeout gives None, so an agent's send is held as workspace_unknown.

Other callers do read what the logs fill in (queue, turn, status): the acpmux CLI, restore-journey.py, chat-transfer-live.py. Making info stop waiting for everyone would undo #22916 for them.

Fix

Option (1), opt-in:

  • _acpmux/info takes waitLogs: false. With it, info answers at once. Every answer now carries logsLoading, which is true while the logs are still being read; then the queue, turn and status come from the saved session list.
  • Without the flag, info still waits for the logs, as #22916 made it.
  • The three cmux-tui-core calls above pass waitLogs: false through one info_params helper. Their 2 s timeouts are unchanged.
  • An older acpmux ignores the unknown param and behaves as it does today.
  • docs/acpmux-schema.json documents the param and the field.

Not changed: agent_transfer/ask_first.rs already gives info 15 s.

The seam ACPMUX_TEST_DELAY_LOAD_LOGS_MS is debug-only and capped at 10 s. It lives in daemon.rs, before load_logs_async, so this PR does not touch hub/mod.rs, where #23118 adds its LogsReady drop guard. Both PRs add a test to tests/durable_agents.rs, in different places (#23118 after a_dequeued_prompt_survives_a_daemon_crash, this one at the end of the file).

Red, then green (fleet, cmux-ci run --class isolated --script scripts/ci/cmux-tui-rust-check.sh --arg=test --arg=<filter>)

FilterCommitStepResult
info_answers_while_the_chat_logs_load6cc5cb781eb9 (test, red)e5fe9a0f2e3fb12ffa1ec7c4FAIL, failed alone too: _acpmux/info {waitLogs: false} answered within 2 s while the logs load: Elapsed(())
while_acpmux_reads_its_chat_logs4fc39d65df14 (test, red)e5ff731e5a393053a8d1e4cbFAIL: the delivery never happened: … "state":"queued","attempts":"0"
info_answers_while_the_chat_logs_loaddbc73521fbd2 (fix; same acpmux tree as head)f364da01b7ce18c671119d831 passed
while_acpmux_reads_its_chat_logs2d331b3d67ef (head)4a90b26576acc5e0f104a95b1 passed
info2d331b3d67ef (head)aacece8c86c0dfc6bcc25a9a22 passed, including info_answers_while_the_chat_logs_load
survive2d331b3d67ef (head)f87ba700080859d262939b50116 passed
attach2d331b3d67ef (head)d1e54bceda87a78dfb32f41e380 passed, 4 failed. The 4 are known base reds: attachment_tests::bad_types_sizes_and_hashes_are_refused_before_any_bytes and three host_scrollback::sized_attach tests

Observed / Not run

Observed:

  • All the runs above, on the fleet.
  • The acpmux test fails on the test commit for the right reason: info does not answer within 2 s.
  • The cmux-tui test fails because the pump never delivers; the message stays queued.

Not run:

  • The full CI suite. CI runs it on this PR.
  • No test covers the workspace lookup (agent_session_link.rs) or the withdraw NoSession path with logs loading. I first wrote a policy test for the lookup, but an agent sender needs acp_credential, and credential.mint is refused on base (origin.forbidden, credential_owner_only). That same refusal is behind the known queue base reds (agent_message_pump::*, deliveries_start_queued_…). So the lookup change is covered only by reading the code. It reuses the same helper as the hand-over, which is tested.
  • No live run against a daemon with a real large log store.

Changelog

  • Fixed: agent messages reach an acpmux chat, and their workspace is found, while a restarted acpmux is still reading large chat logs.

Follow-up to #22916 review

Agent session: cosmic-gray

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes _acpmux/info timing out the cmux-tui app after an acpmux restart while the deferred chat-log load is still running. The app daemon's info calls (pump hand-over, withdraw check, workspace lookup) only need the session id and env from the session list, but info waited for the logs, which on a large store takes longer than the 2 s timeout.

  • _acpmux/info now accepts waitLogs: false to answer immediately, and every answer includes logsLoading while the logs are still being read.
  • Callers that read queue, turn, or status continue to wait as before.