Skip to content

Chore/refactor structure#81

Merged
artefactop merged 16 commits into
mainfrom
chore/refactor_structure
Jul 5, 2026
Merged

Chore/refactor structure#81
artefactop merged 16 commits into
mainfrom
chore/refactor_structure

Conversation

@artefactop

@artefactop artefactop commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Reorganized the compiler into a multi-crate Cargo workspace with shared dependency management.
    • Improved build-time runtime library discovery with automatic runtime building when the archive is missing.
    • Expanded and aligned compiler/CLI pipeline interfaces, including ownership-pass sidecar consistency and additional toolchain helpers.
  • Bug Fixes
    • More reliable rebuild behavior when runtime sources or runtime selection change.
  • Documentation
    • Updated and corrected developer architecture/workspace documentation; removed outdated single-crate developer guide content.
  • Chores
    • Refreshed CI formatting/lint/test commands and ensured toolchain version sourcing matches the updated structure.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6178165c-d630-4b28-9665-da04970ffab1

📥 Commits

Reviewing files that changed from the base of the PR and between f7420ff and 0c04355.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • CLAUDE.md
  • docs/dev/arc_optimizer.md
  • docs/dev/implementation_roadmap.md
  • ryo-backend/build.rs
  • ryo-frontend/Cargo.toml
💤 Files with no reviewable changes (1)
  • ryo-frontend/Cargo.toml
✅ Files skipped from review due to trivial changes (3)
  • docs/dev/implementation_roadmap.md
  • docs/dev/arc_optimizer.md
  • CLAUDE.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • ryo-backend/build.rs

📝 Walkthrough

Walkthrough

The project is reorganized into a multi-crate Cargo workspace. Shared ownership and IR types move into ryo-core, frontend/backend/driver code is rewired to use shared crate paths, the binary crate imports pipeline/toolchain code from external crates, and workspace-oriented documentation replaces the old single-crate layout.

Changes

Multi-crate workspace extraction

Layer / File(s) Summary
Workspace manifest conversion
Cargo.toml
Root Cargo.toml becomes a workspace with resolver, explicit members/default-members, and workspace-wide dependency declarations.
ryo-core shared types
ryo-core/Cargo.toml, ryo-core/src/lib.rs, ryo-core/src/ownership.rs
New core crate exposes shared modules and defines ownership sidecar types used by codegen and pipeline stages.
Frontend imports and ownership re-exports
ryo-frontend/Cargo.toml, ryo-frontend/src/lib.rs, ryo-frontend/src/astgen.rs, ryo-frontend/src/builtins.rs, ryo-frontend/src/lexer.rs, ryo-frontend/src/ownership.rs, ryo-frontend/src/parser.rs, ryo-frontend/src/sema.rs
New frontend crate and module exports are added, and frontend code/tests switch to ryo_core paths while re-exporting ownership metadata from ryo_core::ownership.
Backend crate API and codegen wiring
ryo-backend/Cargo.toml, ryo-backend/src/lib.rs, ryo-backend/src/codegen.rs, ryo-backend/src/linker.rs, ryo-backend/src/toolchain.rs
New backend crate wiring is added, and backend APIs are updated to use ryo_core ownership/error types and new public visibility.
Runtime build script
ryo-backend/build.rs
The backend build script resolves libryo_runtime.a, rebuilds the runtime in a separate target directory when missing, and exports runtime path/hash environment variables.
Driver pipeline and binary entrypoints
ryo-driver/Cargo.toml, ryo-driver/src/lib.rs, ryo-driver/src/pipeline.rs, ryo/Cargo.toml, ryo/build.rs, ryo/src/main.rs
New driver crate exports the pipeline module, CLI command functions become public, ownership sidecar wiring switches to frontend/core crates, and the binary crate imports pipeline/toolchain code from external crates with workspace-root-relative build paths.
Workspace documentation updates
CLAUDE.md, docs/dev/CLAUDE.md, docs/dev/arc_optimizer.md, docs/dev/implementation_roadmap.md, docs/dev/installation.md, docs/dev/mojo_reference.md, docs/dev/pipeline_alignment.md, docs/dev/proposals/wasm_target.md, docs/dev/rust_reference.md
Developer documentation is updated for the workspace layout and new source paths, and obsolete docs for the old single-crate structure are removed.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • ryolang/ryo#74: This PR adds the runtime archive resolution, hashing, and RYO_RUNTIME_LIB/RYO_RUNTIME_HASH build-script wiring used by the new backend build script.
  • ryolang/ryo#79: This PR rewires ownership sidecar use in the IR pipeline to ryo_frontend::ownership::check and ryo_core::ownership::OwnershipSidecar, matching the same pipeline path here.
  • ryolang/ryo#80: This PR changes the ownership-sidecar plumbing and codegen signatures that this workspace split now points at through ryo_core types.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is very generic and does not clearly describe the main workspace refactor and crate split. Rename it to something specific like "Refactor project into a multi-crate Cargo workspace".
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/refactor_structure

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread docs/superpowers/plans/2026-07-02-cargo-workspace-refactor.md Outdated
Comment thread docs/superpowers/specs/2026-07-02-cargo-workspace-refactor-design.md Outdated
artefactop

This comment was marked as outdated.

Comment thread ryo-backend/build.rs
Comment thread ryo/src/main.rs
use crate::types::InternPool;
use crate::uir::Uir;
#[derive(Clone, Copy, Debug, PartialEq, Eq, clap::ValueEnum)]
pub enum EmitKind {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

why here?

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/superpowers/specs/2026-07-02-cargo-workspace-refactor-design.md (1)

1-217: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Rename this spec and retag the examples.

docs/superpowers/specs/2026-07-02-cargo-workspace-refactor-design.md violates the docs filename rule, and the fenced examples below use toml/rust/bash instead of the required ryo language tag. Please rename it to use underscores and switch every code block to ryo. As per coding guidelines, documentation files must use lowercase with underscores naming convention except for special files like README.md, CLAUDE.md, and TODO.md, and code examples in documentation must use fenced code blocks with ryo language tag.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/superpowers/specs/2026-07-02-cargo-workspace-refactor-design.md` around
lines 1 - 217, The spec file name needs to conform to the docs naming rule, and
all fenced examples in this spec must use the required ryo language tag. Rename
the document to use lowercase underscores instead of hyphens, then update every
fenced code block in the design sections (for example, the Cargo manifest
snippets) so they are tagged with ryo rather than toml, rust, or bash. Focus on
the examples and markup in this spec document only.

Source: Coding guidelines

🧹 Nitpick comments (1)
ryo/build.rs (1)

3-8: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse root_dir for the git paths instead of hardcoded "../".

root_dir is computed later at Line 21 and correctly used for the runtime target dir and runtime_src, but the git-related paths at Lines 6-8 and 100 still hardcode "../.git/...". Both represent the same "workspace root" concept; keeping one path derivation would avoid the two silently diverging if the crate is ever nested differently again.

♻️ Proposed consolidation
 fn main() {
-    println!("cargo:rerun-if-changed=../.git/HEAD");
-    if let Some(git_ref) = resolve_git_ref() {
-        println!("cargo:rerun-if-changed=../{git_ref}");
-    }
+    let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+    let root_dir = PathBuf::from(&manifest_dir).parent().unwrap().to_path_buf();
+
+    println!("cargo:rerun-if-changed={}", root_dir.join(".git/HEAD").display());
+    if let Some(git_ref) = resolve_git_ref(&root_dir) {
+        println!("cargo:rerun-if-changed={}", root_dir.join(git_ref).display());
+    }
     let pkg_version = env::var("CARGO_PKG_VERSION").unwrap_or_else(|_| "0.0.0".to_string());
     let short_hash = get_git_short_hash();
     let commit_date = get_git_commit_date();
     let version = match (short_hash, commit_date) {
         (Some(hash), Some(date)) => format!("{pkg_version}-dev.{date}+{hash}"),
         (Some(hash), None) => format!("{pkg_version}-dev+{hash}"),
         _ => pkg_version,
     };
     println!("cargo:rustc-env=RYO_VERSION={version}");
 
-    let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
-    let root_dir = PathBuf::from(&manifest_dir).parent().unwrap().to_path_buf();
-
     // Runtime archive path. ...
-fn resolve_git_ref() -> Option<String> {
-    let head = std::fs::read_to_string("../.git/HEAD").ok()?;
+fn resolve_git_ref(root_dir: &std::path::Path) -> Option<String> {
+    let head = std::fs::read_to_string(root_dir.join(".git/HEAD")).ok()?;
     let head = head.trim();
     head.strip_prefix("ref: ")
         .map(|refpath| format!(".git/{refpath}"))
 }

Also applies to: 20-21, 99-103

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ryo/build.rs` around lines 3 - 8, The git path handling in main() still
hardcodes "../" even though root_dir already represents the workspace root;
update the git-related cargo:rerun-if-changed paths to derive from root_dir
instead of string literals. Reuse the same root_dir-based path construction used
for the runtime target dir and runtime_src so resolve_git_ref and the later git
path logic stay consistent if the crate layout changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/superpowers/plans/2026-07-02-cargo-workspace-refactor.md`:
- Around line 1-561: The plan doc needs to follow the docs filename convention
and all fenced examples must use the required language tag. Rename the document
to use lowercase underscores instead of hyphens, and update every code fence in
this file from toml/rust/bash to ryo; use the unique symbols in the plan itself,
such as the repeated fenced examples and task sections, to verify all blocks
were retagged consistently.

---

Outside diff comments:
In `@docs/superpowers/specs/2026-07-02-cargo-workspace-refactor-design.md`:
- Around line 1-217: The spec file name needs to conform to the docs naming
rule, and all fenced examples in this spec must use the required ryo language
tag. Rename the document to use lowercase underscores instead of hyphens, then
update every fenced code block in the design sections (for example, the Cargo
manifest snippets) so they are tagged with ryo rather than toml, rust, or bash.
Focus on the examples and markup in this spec document only.

---

Nitpick comments:
In `@ryo/build.rs`:
- Around line 3-8: The git path handling in main() still hardcodes "../" even
though root_dir already represents the workspace root; update the git-related
cargo:rerun-if-changed paths to derive from root_dir instead of string literals.
Reuse the same root_dir-based path construction used for the runtime target dir
and runtime_src so resolve_git_ref and the later git path logic stay consistent
if the crate layout changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c12a9ca2-475b-431f-bccd-51b1a93da389

📥 Commits

Reviewing files that changed from the base of the PR and between dc68c64 and e7f202b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (39)
  • Cargo.toml
  • docs/superpowers/plans/2026-07-02-cargo-workspace-refactor.md
  • docs/superpowers/specs/2026-07-02-cargo-workspace-refactor-design.md
  • ryo-backend/Cargo.toml
  • ryo-backend/build.rs
  • ryo-backend/src/codegen.rs
  • ryo-backend/src/lib.rs
  • ryo-backend/src/linker.rs
  • ryo-backend/src/runtime_lib.rs
  • ryo-backend/src/toolchain.rs
  • ryo-core/Cargo.toml
  • ryo-core/src/ast.rs
  • ryo-core/src/diag.rs
  • ryo-core/src/errors.rs
  • ryo-core/src/lib.rs
  • ryo-core/src/ownership.rs
  • ryo-core/src/tir.rs
  • ryo-core/src/types.rs
  • ryo-core/src/uir.rs
  • ryo-driver/Cargo.toml
  • ryo-driver/src/lib.rs
  • ryo-driver/src/pipeline.rs
  • ryo-frontend/Cargo.toml
  • ryo-frontend/src/astgen.rs
  • ryo-frontend/src/builtins.rs
  • ryo-frontend/src/indent.rs
  • ryo-frontend/src/lexer.rs
  • ryo-frontend/src/lib.rs
  • ryo-frontend/src/ownership.rs
  • ryo-frontend/src/parser.rs
  • ryo-frontend/src/sema.rs
  • ryo/Cargo.toml
  • ryo/build.rs
  • ryo/src/main.rs
  • ryo/tests/asan_smoke.rs
  • ryo/tests/common/mod.rs
  • ryo/tests/integration_tests.rs
  • ryo/tests/valgrind_smoke.rs
  • src/CLAUDE.md
💤 Files with no reviewable changes (1)
  • src/CLAUDE.md

Comment thread docs/superpowers/plans/2026-07-02-cargo-workspace-refactor.md Outdated
Comment thread src/CLAUDE.md
@artefactop

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CLAUDE.md`:
- Around line 8-17: The workspace section in CLAUDE.md conflates actual Cargo
workspace members with general repository directories. Update the layout
description to separate the real workspace members (such as ryo, ryo-core,
ryo-frontend, ryo-backend, ryo-driver, and runtime) from non-member repository
areas like docs, experimental, and .github, and keep the repository layout
wording aligned with the root manifest so contributors are not misled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c579589a-2b0e-4f05-a7fa-a0c549848efc

📥 Commits

Reviewing files that changed from the base of the PR and between e7f202b and 6558e56.

📒 Files selected for processing (11)
  • CLAUDE.md
  • docs/dev/CLAUDE.md
  • docs/dev/arc_optimizer.md
  • docs/dev/implementation_roadmap.md
  • docs/dev/installation.md
  • docs/dev/mojo_reference.md
  • docs/dev/pipeline_alignment.md
  • docs/dev/project_structure.md
  • docs/dev/proposals/wasm_target.md
  • docs/dev/rust_reference.md
  • ryo/build.rs
💤 Files with no reviewable changes (1)
  • docs/dev/project_structure.md
✅ Files skipped from review due to trivial changes (8)
  • docs/dev/installation.md
  • docs/dev/rust_reference.md
  • docs/dev/implementation_roadmap.md
  • docs/dev/mojo_reference.md
  • docs/dev/CLAUDE.md
  • docs/dev/arc_optimizer.md
  • docs/dev/proposals/wasm_target.md
  • docs/dev/pipeline_alignment.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • ryo/build.rs

Comment thread CLAUDE.md Outdated
The layout section conflated actual Cargo workspace members with general
repository directories. Group the 6 manifest members separately from
non-member areas (docs/, .github/), and drop the stale experimental/
entry, which no longer exists in the repo.
- ci: test/clippy/fmt now run across the full workspace
  (cargo test --workspace, clippy --workspace --all-targets, fmt --all)
  Restores ~333 unit tests in ryo-frontend/ryo-core/ryo-backend
  that silently stopped running after default-members=[ryo].
- ci: fix ZIG_VERSION grep path src/toolchain.rs -> ryo-backend/src/toolchain.rs
- build(ryo-backend): TODO noting build.rs runtime-resolution is
  duplicated verbatim from ryo/build.rs (extract into shared crate)
- docs: fix stale src/arc_optimizer.rs ref in CLAUDE.md
- deps(ryo-frontend): drop unused hashbrown
- docs: refresh stale src/*.rs paths in active docs to workspace paths
@artefactop

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@artefactop

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@artefactop artefactop merged commit ab521aa into main Jul 5, 2026
8 checks passed
@artefactop artefactop deleted the chore/refactor_structure branch July 5, 2026 17:53
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