perf(acpmux): index live background processes instead of scanning history (carry #30712)
Carries #30712 (a ChatGPT draft), rebased onto current feat-cmux-next with its commits unchanged.
Leo: "oh btw i talked with chatgpt and they raised a bunch more drafts and issues across cmuxterm-hq, cmux, and cmux-platform. some stuff worth looking at"
What
running_processes_read (called for every chat by host load and views) and any_process_running (idle, cancel and stop-if-idle) scanned a session's whole process history under the table lock. With thousands of completed records that is a linear scan per call.
The process table now keeps an ordered set of the running slots, maintained by insert, fold, upsert, lose_running and the read/rebuild paths. lose_running walks the set oldest-first, the same order as before. Test: hub::processes::process_active_tests (3,000 completed records plus ordered live slots).
No timer, observer or loop is added. No before/after number; this is a scan-to-index change with no harness in place.
Leo-ask: ask-e06a62154f
Agent session: agent session
š¤ Generated with Claude Code
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Carries #30712 to replace linear scans of process history with a live index of running slots, so idle checks and running-process counts stay constant regardless of how many completed records accumulate.
Rebased onto feat-cmux-next and re-merged to stay current. ProcessTable now keeps an ordered set of active process indexes, updated on insert, upsert, fold, and lose_running; lose_running preserves the original oldest-first notification order. No timer, observer, or loop is added. Adds tests covering 3,000 completed records with interleaved status updates.