Add daemon.max_handles config to cap concurrent agents per daemon #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
hark's daemon currently allows an unbounded number of concurrent agent handles. Eachinitcall creates a new handle, a new WebSocket to the router, and a new per-handle queue with up tomax_messages_per_handlemessages andmax_bytes_per_handlebytes.A buggy or malicious local process can exhaust daemon resources by repeatedly calling
init:max_bytes_per_handle × handle_count, withhandle_countuncapped.For a single-operator workstation this is acceptable. For shared hosts, CI runners, or any context where local processes are not fully trusted, an explicit cap is required.
Proposed change
Add a
daemon.max_handlesfield toconfig.tomlwith a sensible default (suggest 64).Reject
initwith a stable error code (daemon_at_capacity) when the cap is reached. Surface the limit and current count indaemon statusoutput.Acceptance
daemon.max_handlesparsed from config; default 64; documented in README andspecs/config.md.initreturnsdaemon_at_capacitywhen at limit (suggest HTTP 503 + structured error, plus a new exit code).daemon statusshowshandles: N / M.initis rejected;closefrees a slot, subsequentinitsucceeds.Refs
cbcl-runtimedeck slide 17 (Flow control)