Skip to content

feat(agent): process fd/RSS ceilings gate connection admission (W2.5) - #49

Merged
rldyourmnd merged 3 commits into
mainfrom
w25-process-resource-budgets
Sep 27, 2026
Merged

rldyourmnd merged 3 commits into
mainfrom
w25-process-resource-budgets

Conversation

@rldyourmnd

Copy link
Copy Markdown
Contributor

Summary

  • AgentLimits::with_process_budget(max_fds, max_rss_mb) installs a
    process-level resource gate: while the kernel reports the agent at or
    above the configured fd/RSS ceiling, new connections are refused at
    admission — the pending Incoming is dropped (runner) or the
    established conn is closed (serve) — before a slot or task is spent.
  • Sampling uses /proc/self/fd + VmRSS on Linux and /dev/fd +
    proc_pidinfo on macOS, cached 200ms so procfs scans stay off the
    accept hot path. Platforms that cannot observe a quantity keep serving
    rather than gate on a guess.
  • Settings: limits.max_fds / limits.max_rss_mb (positive NonZero,
    JSON + --max-fds / --max-rss-mb flags, merged with file precedence).
  • Observability: refusals reuse ConnectionBudgetExhausted; metrics
    snapshot reports rds_agent_process_fds / rds_agent_process_rss_bytes
    where the kernel reports them.

Test plan

  • sys kernel sanity + ResourceGate unit tests (none/impossible/
    generous ceilings)
  • e2e: over-budget runner refuses handshake; serve refuses an
    established conn; above-usage ceiling admits and pings normally
  • settings merge/resolve/zero-rejection coverage
  • cargo fmt --check, clippy default + x11 lanes, workspace tests —
    all green locally

Still open under W2.5: per-service fairness inside the stream budget,
disk/media cancellation breadth, storm-grade RSS/FD stress proof.

Generated with Devin

@rldyourmnd
rldyourmnd force-pushed the w25-process-resource-budgets branch 2 times, most recently from e508ba5 to 1a16db2 Compare September 27, 2026 08:51
Comment thread crates/rds-agent/tests/lifecycle.rs Fixed
rldyourmnd and others added 3 commits September 27, 2026 14:40
AgentLimits gains with_process_budget(max_fds, max_rss_mb); when either
ceiling is set the agent samples the kernel view (/proc/self/fd + VmRSS
on Linux, /dev/fd + proc_pidinfo on macOS, re-statting at most every
200ms) and refuses new connections while usage sits at or above the
ceiling — before a connection slot or stream task is consumed. Refusals
reuse ConnectionBudgetExhausted; unobservable platforms keep serving.
Settings expose limits.max_fds/max_rss_mb (positive, flag-overridable
via --max-fds/--max-rss-mb) and the metrics snapshot reports
rds_agent_process_fds/rds_agent_process_rss_bytes where observed.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
scenario.rs already generates ping payloads via rand::random elsewhere;
the literal `1` tripped the CodeQL rust/hard-coded-cryptographic-value
rule (critical alert on main). Same treatment.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@rldyourmnd
rldyourmnd force-pushed the w25-process-resource-budgets branch from c9574cd to 4954164 Compare September 27, 2026 09:41
@rldyourmnd
rldyourmnd merged commit a3a4ce6 into main Sep 27, 2026
23 checks passed
@rldyourmnd
rldyourmnd deleted the w25-process-resource-budgets branch September 27, 2026 09:56
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.

2 participants