Skip to main content

Module orchestrate

Module orchestrate 

Source
Expand description

End-to-end “run this block”: single function every UI calls.

Flow:

  1. Parse the page (.md on disk → AST).
  2. Walk the AST to find the block at flat_index (DFS preorder).
  3. Extract (language, body) from its fence text.
  4. Look up the runtime, call execute.
  5. Render the output as a > **result:** subblock.
  6. Upsert that subblock under the code block.
  7. Re-render the AST back to .md, atomic-write, reconcile into the op log.

The function is sync today — runtimes are sync, the I/O is sync, the TUI calls it from its event loop. When we add long-running runtimes (compile-then-run Rust, streaming output) the boundary becomes an async wrapper; the orchestration stays the same.

Structs§

RunReport
What a successful run hands back to the caller (the UI). Enough to show a status-line message without re-reading the page.

Enums§

RunError
Errors that can happen around execution — before we ever reach the runtime, or while persisting its output.

Constants§

DEFAULT_TIMEOUT
Wall-clock budget for a single fence execution (non-iOS targets).

Functions§

run_block_at_index
Run the code block at flat_index inside md_path through the registry’s matching runtime.
run_block_at_index_if_source_changed
Cache-aware variant of run_block_at_index.