Skip to content

Add default Runnable rendering and HTML export#30

Closed
santib wants to merge 6 commits intomainfrom
santib/rendering
Closed

Add default Runnable rendering and HTML export#30
santib wants to merge 6 commits intomainfrom
santib/rendering

Conversation

@santib
Copy link
Copy Markdown
Member

@santib santib commented Mar 1, 2026

Summary

  • Default Runnable rendering: Graph::Base now provides a default to_graph that renders any Runnable as a [Name] box node. Included into Mars::Runnable via include_extensions, so custom Runnable subclasses are renderable without needing a specific graph module
  • HTML export: New Mars::Rendering::Html generates a self-contained HTML file with embedded Mermaid.js. Supports render (returns string) and write(path) (writes file). Escapes HTML in titles for safety

Phase 6 of the v2 refactor. Based on #29.

Test plan

  • Any Runnable subclass renders as a box node via default to_graph
  • AgentStep still renders correctly with its specific graph module
  • HTML render includes DOCTYPE, mermaid script, flowchart diagram
  • Custom direction and title options work
  • HTML title escaping prevents XSS
  • write produces a valid file on disk
  • 77 specs pass, 0 failures
  • Rubocop clean

🤖 Generated with Claude Code

santib and others added 4 commits March 1, 2026 17:50
Phase 1 of the Mars v2 refactor — additive, no breaking changes.

- ExecutionContext: n8n-style state that flows between steps, with
  namespaced access to previous outputs, fork/merge for parallel
  branches, and shared global_state
- Formatter: injectable input/output transform (identity by default)
- Hooks: class-level before_run/after_run callbacks mixin

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 2 of the Mars v2 refactor.

- Runnable: include Hooks, add `name` (auto-derived from class via
  `step_name`), add `formatter` class-level DSL with instance fallback
- Gate, Aggregator, Sequential, Parallel: delegate `name` to Runnable
  via super instead of managing their own attr_reader
- Runnable spec: cover name derivation, formatter DSL, hooks integration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 3 of the Mars v2 refactor.

- Rename Mars::Agent → Mars::AgentStep with class-level `agent` macro
  that wraps a RubyLLM::Agent subclass
- AgentStep#run creates a new agent instance and delegates via .ask
- Remove old Agent with its manual Chat setup (before_run/after_run,
  system_prompt, tools, schema instance methods)
- Rename rendering graph module accordingly
- Bump ruby_llm dependency to ~> 1.12

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 4 of the Mars v2 refactor.

- Gate: add class-level `condition`/`branch` DSL for reusable gates.
  Gate#run now executes the matched branch directly instead of
  returning a Runnable for Sequential to detect
- Aggregator: context-aware — accepts ExecutionContext and passes
  its outputs to the operation
- Sequential: remove is_a?(Runnable) check, now just chains step results

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@santib santib force-pushed the santib/context-flow branch from 8f6f5b4 to 68a3b04 Compare March 1, 2026 21:34
Phase 4 of the Mars v2 refactor.

- Gate: add class-level `condition`/`branch` DSL for reusable gates.
  Gate#run now executes the matched branch directly instead of
  returning a Runnable for Sequential to detect
- Aggregator: context-aware — accepts ExecutionContext and passes
  its outputs to the operation
- Sequential: remove is_a?(Runnable) check, now just chains step results

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@santib santib force-pushed the santib/context-flow branch from 68a3b04 to 45d8133 Compare March 1, 2026 21:38
@santib santib force-pushed the santib/rendering branch 3 times, most recently from 92b0ee6 to 6c65614 Compare March 1, 2026 22:04
@santib santib force-pushed the santib/rendering branch from 6c65614 to b7c3795 Compare March 1, 2026 22:06
@santib santib force-pushed the santib/context-flow branch 4 times, most recently from 1993d90 to a5c12d5 Compare March 6, 2026 18:37
Base automatically changed from santib/context-flow to main March 6, 2026 18:48
@santib santib closed this Mar 6, 2026
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