GeezerVison is showing github.com — bin proxies: per-key serialization chain maps never delete settled entries — claude-code (chains), muse (warmChains) and commandcode (acp.locks) leak one entry per conversation, and per request on the anon/ephemeral paths · Issue #2407 · developing-today/code
bin proxies: per-key serialization chain maps never delete settled entries — claude-code (chains), muse (warmChains) and commandcode (acp.locks) leak one entry per conversation, and per request on the anon/ephemeral paths #2407DescriptionProblem
Three of the fleet's warm proxies serialize turns per conversation key with a promise-chain Map that is written on every request and never deleted from — not when the chain settles, not on session eviction, not ever. The fourth proxy in the same directory implements the same pattern correctly, which makes the omission visible:
The correct in-tree pattern — bin/agy-proxy.mjs:756-763:
const chains = new Map();
const enqueue = (key, job) => {
const prev = chains.get(key) || Promise.resolve();
const run = prev.then(job, job);
const stored = run.catch(() => {});
chains.set(key, stored);
stored.then(() => { if (chains.get(key) === stored) chains.delete(key); }); // <-- self-cleanup
return run;
};
The three leaking sites:
bin/claude-code-proxy.mjs:489-494 — chains: chains.set(key, run.catch(() => {})) and no chains.delete anywhere in the file. Worse, the request handler mints a brand-new key for every keyless request (const key = getSessionKey(req, body) || \anon:${crypto.randomUUID()}``, :733), so growth is per-request, not per-conversation, for that traffic.
bin/muse-proxy.mjs:656-662 — warmChains: same shape (warmChains.set(key, run.catch(() => {})), no delete). Keys are conversationKey() hashes (system prompt + first user message, :337-344), so every distinct conversation ever served leaves a permanent entry.
bin/commandcode-proxy.mjs — acp.locks (declared :537; set in runChat, :770-777): this.locks.set(lockKey, run.catch(() => {})), no locks.delete anywhere. Sessionless calls use ephemeral: !sessionKey (:1167), and runChat turns those into `ephemeral:${crypto.randomUUID()}` (:770) — again a guaranteed-never-reused key per request.
These proxies are long-lived systemd services, so the maps grow monotonically for the whole process lifetime: one retained settled promise + key string per distinct conversation — and per request on the anon/ephemeral paths. Nothing else bounds them: claude-code-proxy caps live sessions at 32 and sweeps idle sessions (evictIfNeeded), and commandcode/muse have their own session TTLs, but none of those touch the chain maps.
Evidence (verified this run, main 5a34fa70)
Files are md5-identical on sandbox main and the laptop (bin/claude-code-proxy.mjs 7280c4bb…, bin/muse-proxy.mjs 2f87df2e…, bin/commandcode-proxy.mjs a5223632…, bin/agy-proxy.mjs 988ab4c0…).
Deletion-site census over each whole file: claude-code-proxy chains.set ×1 / chains.delete ×0; muse-proxy warmChains.set ×1 / warmChains.delete ×0; commandcode-proxy locks.set ×1 / locks.delete ×0; agy-proxy (control) chains.set ×1 / chains.delete ×1.
Laptop probe (~/git/fleet/probe-2026-10-29-laneB-chainleak/probe.mjs) extracted the verbatim chains/enqueue, warmChains/enqueueWarm, and agy chains/enqueue code from the real files, ran 50 distinct keys with instantly-settling jobs through each, and let cleanup callbacks run:
after 50 distinct keys, all jobs settled:
claude-code chains.size = 50
muse warmChains.size = 50
agy chains.size (control, self-deleting) = 0
same-key order sanity: 1,2 ; chains.size now 51
Serialization itself works (same-key jobs run in order) — the entries simply never leave.
Why it matters
A slow, unbounded memory leak in always-on infrastructure: the proxies run for weeks between restarts, and the busiest key spaces (anon/ephemeral, one entry per request) are exactly the ones that can never be reused. Each entry is small, so this will never page anyone — it is the kind of leak that surfaces months later as a proxy holding far more RSS than its session caps suggest, with the cause invisible in the session/TTL accounting that does exist. The fix pattern already exists in-tree (agy) and is three lines per file.
Acceptance criteria
- All three chain maps remove a key's entry once its chain settles and no newer job has replaced it (the agy pattern: capture the stored promise,
stored.then(() => { if (map.get(key) === stored) map.delete(key); })), at: bin/claude-code-proxy.mjs (chains), bin/muse-proxy.mjs (warmChains), bin/commandcode-proxy.mjs (acp.locks in runChat).
- Serialization semantics are unchanged: two jobs enqueued back-to-back on the same key still run in order and never concurrently, including when a second job is enqueued while the first is still in flight (the delete must only fire for the latest stored promise).
- A regression test per proxy (the existing
*.test.mjs files sit beside each proxy) drives ≥2 distinct keys through the enqueue helper and asserts the map is empty after all jobs settle, plus a same-key ordering assertion.
- Out of scope: session-store persistence/TTL behaviour (
sessions.json, warm store) — bounded separately and unchanged; agy-proxy itself (already correct, it is the reference pattern).
Activitydeveloping-today commented on Oct 29, 2026 added kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item effort/xsTrivial: expected under 30 minutes of work on Oct 29, 2026dezren39 commented on Oct 29, 2026 🤖 Agent note · filed
- Agent: new-issue-creator-code-b (new-issue-creator job, lane B)
- Session / ID: new-issue-creator-code-b run 2026-10-29 13:50 CDT (18:50 UTC)
- Found via: filed this run
- Task: Filed after verifying this run on main 5a34fa7: the per-key serialization chain maps in bin/claude-code-proxy.mjs (chains), bin/muse-proxy.mjs (warmChains) and bin/commandcode-proxy.mjs (acp.locks) are set on every request and never deleted from — one permanent entry per distinct conversation, and per request on the anon:/ephemeral: random-UUID key paths — while bin/agy-proxy.mjs implements the same pattern with self-delete. Laptop probe with the verbatim helpers: 50 distinct settled keys -> sizes 50/50 vs agy control 0.
- Expectation: effort/xs triage — pin that all three sites adopt the agy self-delete pattern (delete only when the stored promise is still current) and each proxy gains a map-empty-after-settle regression test; then route a small_fix packet.
- Links: probe ~/git/fleet/probe-2026-10-29-laneB-chainleak/ (laptop); body evidence in the issue.
dezren39 commented on Nov 2, 2026 Picked up (task 5277, lane E): implementing the agy-proxy self-delete-on-settle pattern at the three leaking chain maps (claude-code chains, muse warmChains, commandcode acp.locks) plus per-proxy regression tests, per the triage task 3583 pinned sites. Branch: queue/5277-2407-proxy-chain-self-delete.
dezren39 commented on Nov 2, 2026 PR opened (task 5277): PR #4173 implements the agy self-delete pattern at all three sites (claude-code chains, muse warmChains, commandcode acp.locks) with health-reported map sizes and per-proxy regression tests. Laptop verification: node --test — claude-code 7/7, muse 28/28, commandcode 4/4 pass. CI on PR #4173 has not registered beyond CodeRabbit (NEUTRAL) after a bounded poll (Actions backlog), so task 5277 is parked 20 minutes; resume by rechecking PR #4173 checks, dispositioning any Codex findings, and merging when green.
dezren39 commented on Nov 2, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|