Skip to content

ROCMAI-209: extract services/log rendering and internal sandbox tool execution into services_text.rs - #757

Merged
jussielo-amd merged 1 commit into
mainfrom
rocmai-209-services-text
Oct 29, 2026
Merged

jussielo-amd merged 1 commit into
mainfrom
rocmai-209-services-text

Conversation

@jussielo-amd

@jussielo-amd jussielo-amd commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Phase 6f-2 of the main.rs modularization (epic ROCMAI-27). Mechanical relocation, no behavior change: moves services/log rendering and internal sandbox tool execution out of apps/rocm/src/main.rs into a new apps/rocm/src/services_text.rs — the largest cluster in this 8-way split (~1170 lines of production code).

  • 36 listed functions moved exactly contiguously, plus two interleaved items not named in the ticket (struct LogBrowserEntry, const MANAGED_STOP_GRACE), both private with no external callers.
  • dispatch() has multiple direct call sites into this cluster (render_internal_status_text, run_internal_sandbox_tool, render_service_logs_text, render_logs_browser_text, render_logs_text, render_services_text, render_services_json) — body confirmed byte-identical (independently re-verified by SHA-256), only imports changed.
  • Visibility: eight functions now called across modules widen from private to pub(crate) (load_managed_service, read_optional_tail_lines, read_tail_lines, render_internal_status_text, render_service_action_result, restart_internal_managed_service, run_internal_sandbox_tool, validate_service_id). render_logs_browser_page_text has no caller outside the new module, so it narrows from pub(crate) to private. Moved bodies are otherwise unchanged.
  • Real external callers fixed across chat.rs, service_launch.rs, runtime_services.rs, and managed_service_status.rs's own test module.
  • Stale "callers" prose in engine_runtime_select.rs's and gpu_policy.rs's own doc comments (and the matching docs/architecture.md bullets) corrected, since the functions they referenced moved here.
  • 32 tests + 5 helper fixtures partitioned into the new module's own test block (confirmed: services_text::tests:: shows exactly 32 #[test] fns, including the stop-confirmation test added upstream since the first version of this PR, ported with the code it covers). Three tests that only incidentally call into this cluster but primarily test other modules' functions were deliberately left in main.rs/stayed put, documented in both the new module's doc comment and the architecture-doc bullet.
  • docs/architecture.md updated.

Test plan

Verified locally at this head (rebased onto main after #756 merged):

  • cargo fmt --all --check
  • cargo clippy -p rocm --all-targets -- -D warnings
  • cargo test -p rocm — 1366 passed, 0 failed, 7 ignored
  • cargo doc -p rocm --no-deps --document-private-items — no unresolved link for parse_device_policy
  • Every function removed from main.rs exists in services_text.rs; none dropped or duplicated

Not re-run locally at this head: the workspace-wide build/test, cargo xtask checks, the smoke script and the Windows build; CI covers them.

Follows #756 (ROCMAI-215), now merged — seventh PR in the ROCMAI-86 (Phase 6f) stack.
Part of Jira ROCMAI-209 / epic ROCMAI-27.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The unconditional Stdio import is unused on Windows and fails the configured warnings-as-errors Clippy check.

1 open issue
What changed in this PR

Continues the main.rs modularization by moving service/log rendering and sandbox-tool execution into services_text.rs, with no intended behavior change.

Changes:

  • Relocates service rendering, stop/restart helpers, and 31 tests into the new module.
  • Updates caller imports while preserving dispatch call sites.
  • Updates module comments and architecture documentation to reflect the relocation.

Verification was limited to source and CI configuration inspection; builds and tests were not run.

File Description
docs/​architecture.md Documents the new module and updated caller relationships.
apps/​rocm/​src/​services_text.rs Contains relocated rendering, lifecycle helpers, and tests.
apps/​rocm/​src/​service_launch.rs Imports relocated service helpers.
apps/​rocm/​src/​runtime_services.rs Imports relocated loading and restart functions.
apps/​rocm/​src/​managed_service_status.rs Updates the test module’s service-loader import.
apps/​rocm/​src/​main.rs Registers the module and removes relocated code and tests.
apps/​rocm/​src/​gpu_policy.rs Updates caller descriptions in comments only.
apps/​rocm/​src/​engine_runtime_select.rs Updates caller descriptions in comments only.
apps/​rocm/​src/​chat.rs Imports rendering and validation helpers from the new module.

Review effort: Balanced

Comment thread apps/rocm/src/services_text.rs
@jussielo-amd
jussielo-amd force-pushed the rocmai-209-services-text branch from 9ea6873 to ffded61 Compare October 29, 2026 13:46
Base automatically changed from rocmai-215-engine-runtime-select to main October 29, 2026 13:56
…execution into services_text.rs

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
@jussielo-amd
jussielo-amd force-pushed the rocmai-209-services-text branch from ffded61 to 587f157 Compare October 29, 2026 13:56
@jussielo-amd
jussielo-amd marked this pull request as ready for review October 29, 2026 14:02
@jussielo-amd
jussielo-amd requested a review from a team as a code owner October 29, 2026 14:02

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Mechanical extraction into services_text.rs, no behavior change found.

  • Compared removed vs added lines: moved bodies match verbatim. Differences are limited to import lists, doc-comment prose, and visibility changes on 8 fn signatures (e.g. load_managed_service is now pub(crate)).
  • Test count is preserved (33 #[test] moved, bodies unchanged).
  • Imports in chat.rs, service_launch.rs, runtime_services.rs, managed_service_status.rs and main.rs are updated; stale prose in gpu_policy.rs, engine_runtime_select.rs and docs/architecture.md is fixed, and the module map has a new entry.
  • dispatch() call sites are unchanged.

Nit (non-blocking): render_logs_browser_page_text narrows from pub(crate) to private. It compiles and has no outside callers, so fine, just a small non-verbatim change.

CI is green at this head (22 pass, 2 skipped).

@jussielo-amd

Copy link
Copy Markdown
Collaborator Author

Thanks for the review.

  • Visibility changes: you are right, and the description did not say so. It now lists the eight functions widened to pub(crate) for cross-module callers. The narrowing of render_logs_browser_page_text is deliberate: it has no caller outside services_text.rs, so private is the accurate visibility. Leaving it as is.
  • Test count: I count 32 tests moved, not 33, and all 32 are absent from main.rs at this head. The 33rd removed #[test] line in the raw diff is a_delivery_that_is_not_an_open_never_reaches_the_browser, which stays in main.rs and shows as removed/re-added because of how the diff aligns.

No code change, so the approved head is unchanged.

@jussielo-amd
jussielo-amd added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit f8dcff5 Oct 29, 2026
24 checks passed
@jussielo-amd
jussielo-amd deleted the rocmai-209-services-text branch October 29, 2026 15:05
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.

3 participants