Refactor managed-agent runtime into cohesive modules#2974
Merged
Conversation
wesbillman
approved these changes
Jul 26, 2026
wesbillman
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed the full diff and traced both moved helpers and their visibility/call sites. This is a behavior-preserving module extraction: the helper bodies are byte-for-byte unchanged, the parent re-exports retain the existing pub(crate) API, and CI is green across Desktop Core, Rust lint, macOS/Windows builds, smoke, relay, and integration jobs. This reduces runtime.rs from 2,220 to 2,167 lines, restoring 49 lines of headroom under the existing 2,216 ratchet. Recommend this over #2930, which only leaves 3 lines of headroom.
wesbillman
marked this pull request as ready for review
July 26, 2026 14:39
wesbillman
force-pushed
the
kennylopez-fix-desktop-runtime-file-size
branch
from
July 26, 2026 14:47
8314549 to
a824fda
Compare
wesbillman
force-pushed
the
kennylopez-fix-desktop-runtime-file-size
branch
from
July 26, 2026 14:57
a824fda to
b47ccf9
Compare
wesbillman
enabled auto-merge (squash)
July 26, 2026 14:59
Split process ownership, orphan sweeping, dead-instance reaping, lifecycle synchronization, and runtime metadata into cohesive runtime submodules. Keep the existing runtime API through narrow re-exports and remove the temporary runtime.rs file-size override now that the composition root is below the standard 1000-line ceiling. Co-authored-by: Princess Donut <68157ebd23b3897c1991015c3038658ea916200c67d3a54620b0754d1b92f6e0@buzz.block.builderlab.xyz> Co-authored-by: Kenny Lopez <klopez4212@gmail.com> Signed-off-by: Wes <wesbillman@users.noreply.github.com>
wesbillman
force-pushed
the
kennylopez-fix-desktop-runtime-file-size
branch
from
July 26, 2026 15:22
b47ccf9 to
2fffc3e
Compare
tlongwell-block
pushed a commit
that referenced
this pull request
Jul 26, 2026
Main's #2974 modularized managed_agents/runtime.rs (process / orphan_sweep / instance_reaper / lifecycle / metadata) from pre-PR content, conflicting with this PR's runtime.rs changes. Resolution re-applies the PR's semantics into the new module layout, changing nothing else: - process.rs: valid_agent_runtime_receipt delegates to injectable valid_agent_runtime_receipt_with; marker-only ownership (name gate dropped). - orphan_sweep.rs: sweep ownership rule comment block; marker-only gates in sweep_orphaned/sweep_system/collect_same_instance_orphans (macOS + Linux). - instance_reaper.rs: name pre-gate removed on both platforms (marker is the authoritative proof). - lifecycle.rs: kill_stale_tracked_processes delegates to injectable kill_stale_tracked_processes_with. - runtime.rs: build_managed_agent_summary/spawn_agent_child keep the PR's descriptor resolver, global_config param, MissingBinary requirement, and descriptor.env write-back (main refactor did not touch these hunks); cfg(test) re-exports added for the injectable seams. - check-file-sizes.mjs: took main's side (runtime.rs override removed by #2974; post-merge runtime.rs is 944 lines, under the 1000 ceiling). runtime/tests.rs keeps the PR's 1320 ratchet. Verified at merge tree: cargo test --lib 1705/0 (14 ignored), clippy -D warnings, fmt, file-size gate all clean. Co-authored-by: Tyler Longwell <tlongwell@block.xyz> Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
runtimeAPI through narrow re-exports; helper bodies and platformcfgbranches are unchanged apart from module-qualified visibilityruntime.rsfrom 2,220 lines onmainto 908 lines and remove its temporary file-size override, restoring the standard 1,000-line ceilingWhy
mainfailed after stale successful PR checks allowed independent growth to combine aboveruntime.rs's 2,216-line override. The earlier fix in #2974 extracted only 55 lines and left the monolith on a special ratchet. This replacement includes that extraction but establishes responsibility boundaries and removes the exception entirely.Module boundaries
process.rs— process identity, ownership markers, receipt validation, and termination primitivesorphan_sweep.rs— same-instance orphan discovery and cleanupinstance_reaper.rs— foreign/dead desktop instance detection and agent reapinglifecycle.rs— tracked runtime synchronization and stale record cleanupmetadata.rs— model/provider metadata resolutionruntime.rs— summary/config/spawn orchestration and compositionValidation
At
a824fda31eff6ecc0d39ca1b8ea5602a108897e6:desktop-checkdesktop-testdesktop-tauri-test: 1,637 passed, 0 failed, 14 ignored; integration + doc tests passedcargo check --manifest-path desktop/src-tauri/Cargo.toml --libcargo fmt --manifest-path desktop/src-tauri/Cargo.toml --all -- --checknode desktop/scripts/check-file-sizes.mjsSupersedes #2974 and #2930.