Skip to content

fix: rebase prebuilt artifact paths across platforms#73

Open
alongubkin wants to merge 3 commits into
mainfrom
alon/alien-191-fix-prebuilt-release-artifact-path-rebasing
Open

fix: rebase prebuilt artifact paths across platforms#73
alongubkin wants to merge 3 commits into
mainfrom
alon/alien-191-fix-prebuilt-release-artifact-path-rebasing

Conversation

@alongubkin

Copy link
Copy Markdown
Member

Summary

  • Rebase copied prebuilt artifact paths using the artifact path's platform segment.
  • Allow multi-platform prebuilt releases to use shared artifacts built under another platform directory.

Validation

  • cargo fmt --check
  • cargo test -p alien-cli rebase_prebuilt_stack_image_paths

@alongubkin alongubkin changed the title Fix prebuilt artifact path rebasing across platforms fix: rebase prebuilt artifact paths across platforms Jun 11, 2026
@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR removes the explicit platform parameter from rebase_prebuilt_stack_image_paths and its helpers, instead extracting the platform segment directly from the artifact path itself. This allows multi-platform prebuilt releases to correctly locate shared artifacts that were built under a different platform directory.

  • artifact_location_from_build_path now returns (platform, artifact_dir) extracted from the .alien/build/<platform>/<artifact> path pattern, replacing the old artifact_dir_from_build_path that required the caller-supplied platform to match the path's platform component.
  • The rebased path is constructed using the platform embedded in the artifact path rather than the current release's target platform, enabling a gcp release to use an artifact that lives under build/aws/.
  • A new test rebase_prebuilt_stack_image_paths_rewrites_cross_platform_artifact_path is added alongside a minor refactor of the existing same-platform test.

Confidence Score: 4/5

Safe to merge; the logic change is small, well-scoped, and the happy path is covered by tests.

The refactored artifact_location_from_build_path correctly extracts the platform segment from the artifact path itself rather than requiring the caller to supply it, which is the right approach for cross-platform sharing. The only notable gap is that the new test doesn't actually exercise the cross-platform case — it creates an artifact whose path and destination directory use the same platform, so it doesn't prove the function works when the artifact's platform differs from the release's target platform. The core logic is simple enough that this is low risk in practice, but a regressor in the path-parsing could go undetected.

crates/alien-cli/src/commands/release.rs — specifically the new test at line 1614 which doesn't fully validate the cross-platform scenario it claims to cover.

Important Files Changed

Filename Overview
crates/alien-cli/src/commands/release.rs Core logic change: platform parameter removed from rebase helpers; platform now extracted from the artifact path itself via artifact_location_from_build_path. New cross-platform test added but its isolation from the same-platform test is weak.
Cargo.lock Workspace-wide version bump from 1.6.0 to 1.7.1 for all alien-* crates; no substantive changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["release_task_core(platform=gcp, --prebuilt)"] --> B["rebase_prebuilt_stack_image_paths(stack, output_dir)"]
    B --> C["for each Worker / Container / Daemon"]
    C --> D["rebase_prebuilt_image_path(resource_type, id, image, output_dir)"]
    D --> E{"image_path.exists()?"}
    E -- yes --> F["return Ok(None)"]
    E -- no --> G["artifact_location_from_build_path(image_path)"]
    G --> H{"path contains .alien/build/p/a?"}
    H -- yes --> J["extract (artifact_platform, artifact_dir)"]
    J --> K["rebased = output_dir/build/{artifact_platform}/{artifact_dir}"]
    K --> L{"rebased exists && is_dir?"}
    L -- yes --> M["return Ok(Some(rebased))"]
    L -- no --> N["return Err(ValidationError)"]
    H -- no --> I{"absolute or relative path?"}
    I -- yes --> O["return Err(ValidationError)"]
    I -- no --> P["return Ok(None) — remote URI"]
Loading

Comments Outside Diff (1)

  1. crates/alien-cli/src/commands/release.rs, line 1614-1637 (link)

    P2 Test doesn't demonstrate the new cross-platform behaviour

    The new test and the existing rebase_prebuilt_stack_image_paths_rewrites_copied_artifact_path are structurally identical: both set up an artifact whose path and on-disk location use the same platform (gcp/aws respectively). The distinguishing claim — that a release targeting one platform correctly reuses an artifact built under a different platform — is invisible here because platform is no longer passed in at all. A more informative test would create an artifact under aws/ while naming the resource in a way that makes it clear the release context is gcp. As written, if artifact_location_from_build_path were accidentally reverted to require window[2] == "aws", this test would still pass.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: crates/alien-cli/src/commands/release.rs
    Line: 1614-1637
    
    Comment:
    **Test doesn't demonstrate the new cross-platform behaviour**
    
    The new test and the existing `rebase_prebuilt_stack_image_paths_rewrites_copied_artifact_path` are structurally identical: both set up an artifact whose path and on-disk location use the same platform (`gcp`/`aws` respectively). The distinguishing claim — that a release targeting one platform correctly reuses an artifact built under a different platform — is invisible here because `platform` is no longer passed in at all. A more informative test would create an artifact under `aws/` while naming the resource in a way that makes it clear the release context is `gcp`. As written, if `artifact_location_from_build_path` were accidentally reverted to require `window[2] == "aws"`, this test would still pass.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
crates/alien-cli/src/commands/release.rs:1614-1637
**Test doesn't demonstrate the new cross-platform behaviour**

The new test and the existing `rebase_prebuilt_stack_image_paths_rewrites_copied_artifact_path` are structurally identical: both set up an artifact whose path and on-disk location use the same platform (`gcp`/`aws` respectively). The distinguishing claim — that a release targeting one platform correctly reuses an artifact built under a different platform — is invisible here because `platform` is no longer passed in at all. A more informative test would create an artifact under `aws/` while naming the resource in a way that makes it clear the release context is `gcp`. As written, if `artifact_location_from_build_path` were accidentally reverted to require `window[2] == "aws"`, this test would still pass.

Reviews (1): Last reviewed commit: "chore: format files checked by ci" | Re-trigger Greptile

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.

1 participant