Skip to content

fix(sessions): bounded resumable lookup, connector-file retention, reap pane-less claude (v0.471.0) - #907

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/connectors-scale
Nov 19, 2026
Merged

vikasprogrammer merged 1 commit into
mainfrom
feat/connectors-scale

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

Why

A live tenant stopped answering (/health timed out, 460 queued connections). Three compounding causes:

  1. resumableIds() read the whole connectors/ folder on every /api/sessions/summary, the console's 1.5s poll. The folder had 61k files (677 MB), so each read took ~50ms.
  2. That folder is never pruned, and it holds each run's resolved connector credentials (.mcp.json) and session secret (.env).
  3. A claude whose pane had been stopped 70 days earlier was still running at 23 GB RSS, with swap full. Six more pane-less claude processes (8–50 days old) were on the box. No reaper could see them.

What

  • resumableIds: the by-id (summary) path stats only the visible rows. The full list reads the folder once and reuses the result until the folder's mtime changes.
  • pruneConnectorFiles (every 10 min off the reaper, ≤500 sessions/pass, audited connectors.pruned): an ended (done/stopped/crashed) session older than 30 days with no live pane keeps only session-<id>.log. Files left by deleted sessions are aged by their mtime. Nothing is pruned when liveness is unknown.
  • ProcessJanitor claude kind: matches a session's claude by --mcp-config <dir>/session-<id>.mcp.json and asks the tenant that owns <dir> via sessionPaneAlive. It reaps only on a definite false, seen on two sweeps past the 10-min grace, and never on null.

Tests

  • New scripts/connectors-retention-test.cjs. It checks that the summary path does no readdir, that the memo is invalidated when a file is removed, which sessions retention prunes and which it keeps, the per-pass bound, and that nothing happens when liveness is unknown.
  • New pane-less claude cases in scripts/process-janitor-test.cjs.
  • npm run test:governance green.

🤖 Generated with Claude Code

…ap pane-less claude (v0.471.0)

The console's 1.5s sessions poll read the whole connectors folder (61k files
on a live tenant, ~50ms a call); with several tabs open on a CPU/swap-starved
box the server stopped answering. The summary path now stats only its rows and
the full list memoizes on the folder mtime.

Ended sessions older than 30 days with no live pane now keep only their .log,
pruning stale credential copies (.mcp.json, .env) in bounded passes.

The process janitor reaps a claude whose session pane is gone (one ran 70 days
at 23 GB after its pane was stopped), asking the owning tenant for liveness and
never killing on unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vikasprogrammer
vikasprogrammer merged commit f3d91d7 into main Nov 19, 2026
1 check passed
@vikasprogrammer
vikasprogrammer deleted the feat/connectors-scale branch November 19, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant