Skip to content

feat: Build minimal DAG for multi-target execution#248

Merged
szmyty merged 3 commits into
mainfrom
copilot/build-minimal-dag-multi-target
Apr 8, 2026
Merged

feat: Build minimal DAG for multi-target execution#248
szmyty merged 3 commits into
mainfrom
copilot/build-minimal-dag-multi-target

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

When rendering to multiple output formats, each target's transformation path is computed independently — leading to redundant intermediate steps (e.g. Markdown→HTML executed twice when targeting both PDF and DOCX). This adds a MultiTargetDag that merges paths into a single shared execution graph.

Changes

src/graph/multi_target.rs (new)

  • MultiTargetDag — merged DAG struct backed by petgraph::DiGraph
  • merge_edge — inserts an edge for a (from, to) pair; keeps the cheaper edge on collision, discarding the duplicate
  • execution_order — returns edges via topological sort (petgraph::algo::toposort), guaranteeing each step runs only after its inputs are ready
  • Inspection helpers: contains_edge, edge_count, node_count, all_edges

src/graph/mod.rs

  • TransformGraph::build_multi_target_dag(from, targets) — runs find_path (Dijkstra) per target, feeds all edges through merge_edge, returns None if any target is unreachable
  • Exports MultiTargetDag from the public graph module

Example

let mut graph = TransformGraph::new();
graph.add_transform(TransformEdge::new(Format::Markdown, Format::Html, 0.5, 1.0));
graph.add_transform(TransformEdge::new(Format::Html, Format::Pdf,  0.8, 0.85));
graph.add_transform(TransformEdge::new(Format::Html, Format::Docx, 0.6, 0.90));

let dag = graph
    .build_multi_target_dag(Format::Markdown, &[Format::Pdf, Format::Docx])
    .unwrap();

assert_eq!(dag.edge_count(), 3); // Markdown→Html shared; 3 edges, not 4

let order = dag.execution_order(); // [Markdown→Html, Html→Pdf, Html→Docx]

Copilot AI linked an issue Apr 8, 2026 that may be closed by this pull request
5 tasks
Copilot AI changed the title [WIP] Build minimal DAG for multi-target execution feat: Build minimal DAG for multi-target execution Apr 8, 2026
Copilot AI requested a review from szmyty April 8, 2026 17:14
@szmyty szmyty marked this pull request as ready for review April 8, 2026 19:07
@szmyty szmyty merged commit 515c7e4 into main Apr 8, 2026
@devactivity-app
Copy link
Copy Markdown

Pull Request Summary by devActivity

Metrics

Cycle Time: 2h 7m Coding Time: < 1 min Pickup Time: 1h 52m Review Time: < 1 min

Achievements

@szmyty szmyty deleted the copilot/build-minimal-dag-multi-target branch April 8, 2026 19:07
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.

🧩 Build minimal DAG for multi-target execution

2 participants