Skip to content

dx worktree hook stop: stop slot Bazel servers (part of #10043) - #10125

Merged
TrapsterDK merged 2 commits into
mainfrom
memgate-limit
Nov 9, 2026
Merged

TrapsterDK merged 2 commits into
mainfrom
memgate-limit

Conversation

@TrapsterDK

@TrapsterDK TrapsterDK commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #10043.

Done: dx worktree hook stop (SubagentStop) shuts down the Bazel server of each slot it marks gone. DX_BUILD_SLOT_MEMORY sets the memory planned per build slot; --build-slots <n> / DX_BUILD_SLOTS already limit live servers. Bazel runs inside a dx worktree slot start the server with --max_idle_secs=300. Already on main: memory-based build slots with pressure waits, reaping, shutdown on worktree release. Docs updated in docs/cli/commands/README.md and worktree.md.

Tested: //cli/worktree:dx_worktree_test, //cli/process:dx_process_test, //cli/plan:dx_plan_test. Nested-Bazel and consumer tests not run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hwESun1HL2eSVd1d5B

@TrapsterDK
TrapsterDK marked this pull request as ready for review November 9, 2026 16:18
@TrapsterDK TrapsterDK added the needs-review Touches review paths; needs a second-session Review: comment label Nov 9, 2026
@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Review: approve

Scope check against the stated intent:

  • Only the stopped agent's own slots are touched. hook::stop shuts down pool.slot_path(slot) for the records it just marked (matching session and agent_id, held && !gone). Other slots and the main checkout are never named. stop_server goes through Host::bazel_shutdown (bazel shutdown in that slot) and checks server_in by workspace path first. No kill-by-pattern.
  • Missing slots: stop_server returns false when no server runs in the path. With no process list, the failed bazel shutdown in a missing dir is ignored. The hook still returns the marked slots.
  • DX_BUILD_SLOT_MEMORY parsing and scaling look right. Zero, negative, fractional and unknown suffixes fall back to the default.

Non-blocking:

  • cli/worktree/src/tests.rs (hooks test): only the positive case is asserted. Add a case where another agent's slot or the primary checkout has a server and shutdown_paths() stays empty for it. That is the property this PR is meant to guarantee.
  • cli/worktree/src/hook.rs:344: drop(lock) before the shutdown means the record is no longer protected while the server stops. A gone holder's slot waits out its grace period, so the window is narrow. Re-reading the record before the shutdown would close it.
  • cli/process/src/rc.rs:334: --max_idle_secs=300 is added whenever dx runs in a slot, even if an rc file already sets it. The command-line value wins, so the rc value is silently overridden. A plain bazel run in the slot with a different value restarts the server.
  • PR title says "part of dx: limit concurrent Bazel servers across worktree slots by available memory #10043", body says "Closes dx: limit concurrent Bazel servers across worktree slots by available memory #10043".
  • cli/plan/src/slots.rs (deadline: in Gate::acquire) is a formatting-only change unrelated to this PR.

AGENTS.md style: no rationale comments added. The doc lines are plain.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hwESun1HL2eSVd1d5B

@TrapsterDK
TrapsterDK merged commit 5b21fd4 into main Nov 9, 2026
1 check failed
@TrapsterDK
TrapsterDK deleted the memgate-limit branch November 9, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Touches review paths; needs a second-session Review: comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dx: limit concurrent Bazel servers across worktree slots by available memory

1 participant