Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hydro_lang/src/compile/built.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<'a> BuiltFlow<'a> {
}

/// Serialize the IR as JSON.
#[cfg(feature = "runtime_support")]
#[cfg(feature = "viz")]
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

Changing ir_json() from runtime_support to viz makes this API require the viz feature, which pulls in additional dependencies (e.g., clap, itertools, and build) beyond serde_json. If the intent is to make IR JSON available without the full viz stack, consider gating this method on a narrower feature (e.g., a dedicated ir_json/serde_json feature) instead of viz.

Suggested change
#[cfg(feature = "viz")]
#[cfg(stageleft_runtime)]

Copilot uses AI. Check for mistakes.
pub fn ir_json(&self) -> Result<String, serde_json::Error> {
super::ir::serialize_dedup_shared(|| serde_json::to_string_pretty(&self.ir))
}
Expand Down
5 changes: 5 additions & 0 deletions hydro_lang/src/viz/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ impl<'a> GraphApi<'a> {
crate::viz::config::GraphType::Mermaid => render_hydro_ir_mermaid(self.ir, config),
crate::viz::config::GraphType::Dot => render_hydro_ir_dot(self.ir, config),
crate::viz::config::GraphType::Json => render_hydro_ir_json(self.ir, config),
crate::viz::config::GraphType::Ir => {
crate::compile::ir::serialize_dedup_shared(|| {
serde_json::to_string_pretty(self.ir).expect("failed to serialize IR")
})
}
Comment on lines +43 to +47
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

GraphApi::render panics on IR serialization failure via expect("failed to serialize IR"). Since this is user-facing CLI output and write_to_file already returns a Result, prefer propagating the serde_json error (e.g., make render return a Result<String, _> or handle the error in write_to_file/generate_graph) rather than aborting the process.

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +47
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

A new GraphType::Ir format was added, but the existing test_string_generation test only exercises Mermaid/Dot/Json. Add an assertion covering the Ir branch (and ideally validate that it is valid JSON) to prevent regressions in the new output mode.

Copilot uses AI. Check for mistakes.
}
}

Expand Down
3 changes: 3 additions & 0 deletions hydro_lang/src/viz/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub enum GraphType {
Dot,
/// JSON format for Hydroscope interactive viewer.
Json,
/// Serialized IR JSON for standalone coordination analysis.
Ir,
}

impl GraphType {
Expand All @@ -18,6 +20,7 @@ impl GraphType {
GraphType::Mermaid => "mmd",
GraphType::Dot => "dot",
GraphType::Json => "json",
GraphType::Ir => "ir.json",
}
}
}
Expand Down
Loading