ROCMAI-83: extract persistence.rs from apps/rocmd/src/lib.rs - #477
jussielo-amd wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The extraction preserves implementation and test coverage while consistently updating all references.
Review effort: Balanced
Findings: None
What changed in this PR
Extracts daemon persistence helpers from lib.rs into a focused module without changing behavior.
Changes:
- Moves event recording and managed-service loading into
persistence.rs. - Updates all call sites and relocates the associated unit test.
- Documents the modularization progress.
| File | Description |
|---|---|
apps/rocmd/src/lib.rs |
Registers and uses the persistence module. |
apps/rocmd/src/persistence.rs |
Contains persistence helpers and their test. |
docs/architecture.md |
Records current and planned modularization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
r0x0r
left a comment
There was a problem hiding this comment.
Review: clean mechanical relocation — approving
Verified as pure code motion. record_event and load_managed_services are byte-for-byte identical to their originals at lib.rs:5110 and lib.rs:5224 on main — no changed error handling, no dropped .context(...), no reordered statements, no altered literals.
What I checked
- Call sites — all 42 previously-bare calls are now
persistence::-qualified; no unqualified call survives inlib.rs. - Imports —
append_automation_eventis correctly dropped fromlib.rs(its only non-test user moved), andAutomationEventRecordis correctly re-gated behind#[cfg(test)]since its only remaining uses inlib.rsare in tests. Both matter: the workspace gates onclippy -- -D warnings, where an unused import fails the build. I re-checked every dropped import against the remaining body and found no symbol left referenced without one. - Visibility —
pub(crate)on both items, which is exactly what the cross-module calls need and no wider. - Tests — the test attribute count is conserved at 130 across the branch (129 in
lib.rs+ 1 inpersistence.rs), matching the PR's claim precisely.record_event_mirrors_watcher_actions_to_audit_logmoved intact. - Docs — the
docs/architecture.mdtext accurately describes this branch:persistence.rsis the only module present, and it is the only one claimed as extracted. (This is worth calling out because the sibling PRs in this phase do not have that property — see below.) - Blast radius — nothing outside
apps/rocmdreferences either symbol.apps/rocm/src/main.rshas its own, differentload_managed_services; it is untouched. Therocm-dash-daemonmention is a prose comment with no code dependency. - Leak scan (AGENTS.md §2) — clean.
Non-blocking: the test-helper duplication will compound
temp_app_paths, unique_test_root and workspace_test_artifact_dir are now byte-identical copies in both persistence.rs's and lib.rs's test modules. That is a reasonable call for one module, and it is unavoidable without a shared helper module since each #[cfg(test)] mod tests is a separate private scope.
The reason to raise it here rather than later: the same three helpers are also duplicated into common.rs on #479 and into sandbox.rs on #483. Phase 5 has seven target modules, so on the current trajectory this ends at roughly eight copies of workspace_test_artifact_dir, each independently able to drift on the next change to the artifact path. A #[cfg(test)] mod test_support; at the crate root, introduced once, would cost one small PR now and save seven divergence risks later. Worth deciding before the remaining cluster PRs land, not after.
Note on merge order for this phase
This PR is the only one of the five whose architecture-doc hunk matches its own branch. #479, #480, #481 and #483 each rewrite the same single line of docs/architecture.md with a cumulative list that assumes everything earlier in the sequence has already merged. Since all five are branched independently from main, that line is a guaranteed conflict for whichever four merge later — and, more importantly, any of them merging before this one would apply cleanly while planting a description of files that do not exist on main. Landing this PR first is what makes the rest of the sequence coherent.
🤖 by agent-hub on AMD AgentHub
Phase 5 merge-order note — posting here because this is the PR that lands firstMy approval above stands: this PR is clean on its own. Since then the rest of Phase 5 has opened (#479, #480, #481, #483, #484, #487, #489) and I've reviewed all eight. Two problems only show up when you look across them, so I'm recording them here rather than repeating them on each. 1. The eight PRs do not compile once merged, and nothing conflicts to warn youEach new module reaches back into the crate root via Checking every
The reason this is worth raising loudly is where the breakage sits. Take the clearest case: #489 moves Every one of the 52 has that shape: a dangling reference in a file the relocating PR never touches. Nothing is wrong with the
2. Three symbols are claimed by two PRs each
These aren't dangling-path problems — both definitions would exist, one unused, which the workspace's
3. The architecture-doc line, across all eightEvery PR rewrites the same single line of Where that leaves the eightReviewed clean on their own merits, blocked only on the above: #479, #480, #481, #483, #484, #487, #489. This one (#477) is approved and is the right thing to land first — it is the only one whose doc hunk already matches its own branch, and the only one with no broken 🤖 by agent-hub on AMD AgentHub |
|
Re test-helper duplication (r0x0r's note on the approved review): fixed. Sibling PRs in this phase can adopt |
|
Re the Phase 5 merge-order note: confirmed plan is to stack the remaining seven PRs rather than keep them independent. #477 merges first, independently, staying based on `main` (no base change needed here — it already has no broken `crate::` references and its `docs/architecture.md` hunk already matches its own branch, as you noted). #479 → #480 → #481 → #483 → #484 → #487 → #489 will each be restacked as drafts dependent on their predecessor per AGENTS.md §11 (kept in draft until the predecessor merges upstream, then rebased and marked ready). Rebasing each onto its already-merged/already-fixed predecessor resolves both issues you flagged mechanically: the dangling `crate::` references see the real post-move location of everything already relocated, and the cumulative `docs/architecture.md` line conflicts/resolves naturally one hunk at a time instead of needing the line scoped to an append per-module. Will flag the doubly-claimed-symbol conflicts (`CommandCapture`, `run_command_with_timeout`, `update_check_message`) for resolution on the specific PRs that introduce them (#479/#483/#484) as each is restacked. |
|
Following up on the #479-specific finding above ( #479's base is conceptually this branch now — GitHub doesn't let a fork-based PR's base ref point at a branch that only exists on the fork, so its base field still shows |
Pull record_event/load_managed_services (automation-event/audit-log and managed-service-registry I/O) out of the daemon's flat lib.rs into their own module, first of the Phase 5 rocmd modularization sequence (ROCMAI-27) since sandbox/mcp/service/watchers all reach into these two helpers. No behavior change; call sites repointed to persistence::. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
lib.rs's and persistence.rs's test modules each carried byte-identical copies of temp_app_paths/unique_test_root/workspace_test_artifact_dir. Phase 5's remaining module extractions (common.rs, sandbox.rs, ...) would each need their own copy, so share one now via a new Signed-off-by: Jussi Elo <jussi.elo@amd.com> #[cfg(test)]-gated apps/rocmd/src/test_support module instead.
…pps/rocmd modules The still-pending cli.rs/sandbox.rs/mcp.rs/service.rs/webhook.rs/watchers.rs and common.rs names don't exist yet, so the new path-citation checker (ROCm#432) flags them as stale. Describe the remaining clusters in prose instead, matching the no-filename convention already used for main.rs. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
a6b6e35 to
ebe4c33
Compare
Summary
First PR of Phase 5 (ROCMAI-83, part of the modularization epic ROCMAI-27): extracts
record_event/load_managed_servicesout ofapps/rocmd/src/lib.rs's flat 9,980-line body into a newpersistence.rsmodule. These two helpers (automation-event/audit-log writes and managed-service-registry reads) are reached into by every other cluster slated for later PRs in this phase (sandbox, mcp, service, watchers), so this lands first per the ticket's explicit sequencing.persistence::record_event/persistence::load_managed_services.record_eventdirectly moved intopersistence.rs's own#[cfg(test)] mod testsin this same PR (per the epic's rule against deferring test-splitting).docs/architecture.mdupdated in this PR to reflect progress on this phase.Test plan
cargo build(rocmd, androcm+rocmdtogether to confirm the external API surface —rocmd::run_bin_cli/rocmd::run_from_args— is untouched)cargo clippy --workspace --all-targets -- -D warningscargo test -p rocmd— 130 tests, same count as before this change (129 passed + 1 pre-existing ignored)cargo xtask manifest --checkcargo fmt/ prek hooks cleantests/e2e-cucumber(CI)