Back to feed

sledtools/pika branch #101

pika-orch-incus-cleanup-23

Centralize staged payload mount paths

Target branch: master

Merge Commit: 37b81232033b670cf70e9300f2d54f1bb8146054

branch: merged tutorial: ready ci: success
Open CI Details

Continuous Integration

CI: success

Compact status on the review page, with full logs on the CI page.

Open CI Details

Latest run #127 success

6 passed

head ce422031a4a8211a54f63509d48e6d3e37741198 · queued 2026-03-26 01:53:50 · 6 lane(s)

queued 6s · ran 29s

check-notifications · success check-agent-contracts · success check-pikachat · success check-pikachat-typescript · success check-pikachat-openclaw-e2e · success check-fixture · success

Summary

This branch centralizes the guest mount path and local mount path logic for staged Linux Rust payloads into the StagedLinuxRustPayloadRole enum in model.rs, removing scattered constants and inline path construction from executor.rs and run.rs. Two new methods—guest_mount_path() and local_mount_path()—are added to the enum, replacing the REMOTE_LINUX_VM_INCUS_WORKSPACE_DEPS_MOUNT_PATH and REMOTE_LINUX_VM_INCUS_WORKSPACE_BUILD_MOUNT_PATH constants and an inline job_dir.join(...) chain. Tests are updated to call the new methods instead of referencing the deleted constants, and new assertions verify the method return values directly.

Tutorial Steps

Add `guest_mount_path()` and `local_mount_path()` methods to `StagedLinuxRustPayloadRole`

Intent: Centralize the definition of guest and local mount paths on the enum that already represents the payload role, so that every call site derives paths from a single source of truth instead of duplicating string literals or path-join logic.

Affected files: crates/pikaci/src/model.rs

Evidence
@@ -188,6 +188,19 @@ impl StagedLinuxRustPayloadRole {
+    pub fn guest_mount_path(self) -> &'static str {
+        match self {
+            Self::WorkspaceDeps => "/staged/linux-rust/workspace-deps",
+            Self::WorkspaceBuild => "/staged/linux-rust/workspace-build",
+        }
+    }
+
+    pub fn local_mount_path(self, job_dir: &Path) -> PathBuf {
+        job_dir
+            .join("staged-linux-rust")
+            .join(self.mount_dir_name())
+    }

Two methods are added to StagedLinuxRustPayloadRole in crates/pikaci/src/model.rs:191-202.

guest_mount_path(self) returns the static in-VM mount path (/staged/linux-rust/workspace-deps or /staged/linux-rust/workspace-build) that was previously defined as module-level constants in executor.rs.

local_mount_path(self, job_dir: &Path) constructs the host-side path by joining job_dir with staged-linux-rust and the role's mount_dir_name(). This path assembly was previously done inline in run.rs.

Remove redundant constants from `executor.rs`

Intent: Delete the `REMOTE_LINUX_VM_INCUS_WORKSPACE_DEPS_MOUNT_PATH` and `REMOTE_LINUX_VM_INCUS_WORKSPACE_BUILD_MOUNT_PATH` constants that are now superseded by `StagedLinuxRustPayloadRole::guest_mount_path()`.

Affected files: crates/pikaci/src/executor.rs

Evidence
@@ -228,10 +228,6 @@ const REMOTE_LINUX_VM_INCUS_READ_ONLY_DISK_IO_BUS: &str = "virtiofs";
-#[cfg(test)]
-const REMOTE_LINUX_VM_INCUS_WORKSPACE_DEPS_MOUNT_PATH: &str = "/staged/linux-rust/workspace-deps";
-#[cfg(test)]
-const REMOTE_LINUX_VM_INCUS_WORKSPACE_BUILD_MOUNT_PATH: &str = "/staged/linux-rust/workspace-build";

Both constants were #[cfg(test)]-only, meaning they existed solely to support assertions in the test module. Their values are now owned by the enum, so they are deleted outright rather than left behind as dead code.

The corresponding use entries in the test module's import block are also removed to keep the imports clean.

Update executor tests to use the new enum methods

Intent: Replace all references to the deleted constants in test assertions with calls to `StagedLinuxRustPayloadRole::guest_mount_path()`, keeping the tests equivalent in behavior.

Affected files: crates/pikaci/src/executor.rs

Evidence
@@ -2740,7 +2735,7 @@
-            REMOTE_LINUX_VM_INCUS_WORKSPACE_DEPS_MOUNT_PATH,
+            StagedLinuxRustPayloadRole::WorkspaceDeps.guest_mount_path(),
@@ -2752,7 +2747,7 @@
-            REMOTE_LINUX_VM_INCUS_WORKSPACE_DEPS_MOUNT_PATH
+            StagedLinuxRustPayloadRole::WorkspaceDeps.guest_mount_path()
@@ -2809,7 +2804,9 @@
-                guest_path: REMOTE_LINUX_VM_INCUS_WORKSPACE_BUILD_MOUNT_PATH.to_string(),
+                guest_path: StagedLinuxRustPayloadRole::WorkspaceBuild
+                    .guest_mount_path()
+                    .to_string(),

Three test sites in executor.rs are updated:

  1. The argument passed to the disk-attach helper now uses StagedLinuxRustPayloadRole::WorkspaceDeps.guest_mount_path() instead of the constant (crates/pikaci/src/executor.rs:2738).
  2. The format! assertion that checks the path= argument in the generated Incus command uses the same method call (crates/pikaci/src/executor.rs:2750).
  3. The PreparedOutputPayloadMountRecord expectation for the build payload switches from the build constant to StagedLinuxRustPayloadRole::WorkspaceBuild.guest_mount_path().to_string() (crates/pikaci/src/executor.rs:2806).

A new use for StagedLinuxRustPayloadRole is added to the test module's model import group to support these calls.

Replace inline path construction in `run.rs` with `local_mount_path()`

Intent: Eliminate the duplicated `job_dir.join("staged-linux-rust").join(role.mount_dir_name())` inline expression in favor of the new `local_mount_path()` method.

Affected files: crates/pikaci/src/run.rs

Evidence
@@ -1722,9 +1722,7 @@
-            local_mount_path: job_dir
-                .join("staged-linux-rust")
-                .join(role.mount_dir_name()),
+            local_mount_path: role.local_mount_path(job_dir),

In staged_linux_payload_specs() at crates/pikaci/src/run.rs:1724, the three-line path join is replaced with a single role.local_mount_path(job_dir) call. This is the production call site that motivated extracting the method; any future callers that need the same path can now reuse it without reimplementing the join logic.

Add model-level unit tests for the new methods

Intent: Verify that `guest_mount_path()` returns the expected static strings for both enum variants, providing a regression safety net independent of the integration-style executor tests.

Affected files: crates/pikaci/src/model.rs

Evidence
@@ -993,12 +1006,20 @@
+        assert_eq!(
+            roles[0].guest_mount_path(),
+            "/staged/linux-rust/workspace-deps"
+        );
         assert_eq!(
+        assert_eq!(
+            roles[1].guest_mount_path(),
+            "/staged/linux-rust/workspace-build"
+        );

Two new assert_eq! checks are inserted into the existing model test in crates/pikaci/src/model.rs:1009-1012 and 1018-1021. They confirm that WorkspaceDeps.guest_mount_path() and WorkspaceBuild.guest_mount_path() return the literal paths that were previously hard-coded as constants. This ensures the enum is the canonical owner of these values going forward.

Diff