feat(types): extract duplicated OCI helpers into phenotype-types crate#233
feat(types): extract duplicated OCI helpers into phenotype-types crate#233KooshaPari wants to merge 2 commits into
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
CodeAnt AI is reviewing your PR. |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
|
Legacy Tooling Scan Report
No violations detected. This is a WARN-mode scan. Fix before strict enforcement begins. |
| pub fn dirs_home() -> Option<PathBuf> { | ||
| std::env::var_os("HOME").map(PathBuf::from) | ||
| } |
There was a problem hiding this comment.
Suggestion: dirs_home only reads HOME, so on native Windows (where HOME is often unset) home resolution returns None and expand("~/...") silently falls back to an unexpanded relative path. Add Windows fallbacks (USERPROFILE, then HOMEDRIVE + HOMEPATH) so path expansion works consistently across supported platforms. [logic error]
Severity Level: Major ⚠️
- ❌ OCI helper `expand` mis-resolves `~/` paths on Windows.
- ⚠️ OCI config file lookups can fail on Windows hosts.
- ⚠️ Cross-platform agents may behave differently by platform.Steps of Reproduction ✅
1. Note that `phenotype-types` re-exports `expand`/`dirs_home` from
`crates/phenotype-types/src/lib.rs:17-23`, making them public helpers for downstream OCI
agents.
2. Run any consumer binary on a native Windows host where `HOME` is unset (common; Windows
typically uses `USERPROFILE` / `HOMEDRIVE` + `HOMEPATH`) and call
`phenotype_types::expand("~/.oci/config")` from application code.
3. At `crates/phenotype-types/src/path.rs:25-31`, `expand` evaluates `if let Some(rest) =
p.strip_prefix("~/") && let Some(home) = dirs_home() { ... }`; `strip_prefix("~/")`
succeeds, but `dirs_home()` (lines 13-15) calls `std::env::var_os("HOME")` and returns
`None` because `HOME` is not defined.
4. Because the `if let` pattern fails when `dirs_home()` is `None`, `expand` falls through
to `PathBuf::from(p)` and returns a path containing the literal `~` segment instead of the
user's home directory, so downstream code that expects `~/.oci/config` (per the example in
`path.rs:21-23`) will look for a non-existent `~` directory rather than the intended home
directory config file.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** crates/phenotype-types/src/path.rs
**Line:** 13:15
**Comment:**
*Logic Error: `dirs_home` only reads `HOME`, so on native Windows (where `HOME` is often unset) home resolution returns `None` and `expand("~/...")` silently falls back to an unexpanded relative path. Add Windows fallbacks (`USERPROFILE`, then `HOMEDRIVE` + `HOMEPATH`) so path expansion works consistently across supported platforms.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3238688a9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| anyhow = "1" | ||
| chrono = { version = "0.4", features = ["serde"] } | ||
| tokio = { version = "1", features = ["fs"] } |
There was a problem hiding this comment.
Remove unused runtime dependencies
For this new workspace member, the CI rust-machete job in .github/workflows/ci.yml runs cargo machete .; the cargo-machete README states it returns 1 when unused dependencies are found, and anyhow, chrono, and tokio are not referenced anywhere under crates/phenotype-types/src. This will trip that gate and also forces every downstream consumer of this shared types crate to compile unnecessary transitive dependencies, so these should be removed until the crate actually uses them.
Useful? React with 👍 / 👎.
|
Legacy Tooling Scan Report
No violations detected. This is a WARN-mode scan. Fix before strict enforcement begins. |
|



User description
Summary
Extract duplicated OCI helper types and functions into a shared
phenotype-typescrate to eliminate cross-repo duplication across the compute/infra ecosystem.Context
B16 of the compute/infra cross-repo consolidation DAG (Epic B). Two OCI-related crates (
oci-lotteryandoci-post-acquire) independently defined structurally identical types and utility functions:AcquiredInstance(oci-lottery) andInstanceFile(oci-post-acquire) — both represent an OCI compute instance record with OCID, region, AD, public IP, and acquisition timestamp.expand()/dirs_home()— identical~expansion helpers defined in both crates.LaunchOutcome— the launch result type, only inoci-lottery, but needed by the shared crate to establish a canonical contract.This extraction allows both crates to depend on
phenotype-typesand remove their local copies.Changes
crates/phenotype-types/in the BytePort workspace, containing three modules:instance::OciInstance— unified instance record (replacesAcquiredInstance/InstanceFile)outcome::LaunchOutcome— OCI launch attempt outcome with constructor helperspath::{expand, dirs_home}—~-expansion path utilitiescrates/phenotype-typesin the workspaceCargo.toml.Key Implementation Details
Each type includes:
Serialize/Deserializederive for JSON roundtrip compatibilityLaunchOutcome::success(),LaunchOutcome::failure())Testing
cargo check -p phenotype-types cargo test -p phenotype-typesNo runtime changes to existing agents — the crate provides the canonical types but downstream adoption (migrating
oci-lotteryandoci-post-acquire) is a follow-up step.Links
CodeAnt-AI Description
Add a shared crate for OCI instance records, launch results, and path helpers
What Changed
~path expansion helpers so both agents can resolve home-based paths the same wayImpact
✅ Consistent OCI instance files across agents✅ Clearer launch success and failure reporting✅ Reliable home-directory path handling💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.