feat: case-study notebooks (envir + KK afgørelse), conductor.viz, dep-graph fix#3
Open
mhenrichsen wants to merge 2 commits into
Open
feat: case-study notebooks (envir + KK afgørelse), conductor.viz, dep-graph fix#3mhenrichsen wants to merge 2 commits into
mhenrichsen wants to merge 2 commits into
Conversation
…-graph fix Adds: - examples/09_case_study_miljorapport.ipynb — real environmental-impact- report pipeline (PLST). Parallel external fetches via for-each, per-chapter generate→evaluate→revise→ground with SKIPPED-sentinel routing, full-report assembly using shared references for project context + EA index broadcast, HITL dataset-mapping review. - examples/10_case_study_kk_afgorelse.ipynb — Copenhagen Municipality kolonihave decision drafts. Parallel OCR fan-out, sequential checkpoint chain via FlowStore, decision-edge-guards routing to one of five draft generators, human-in-the-loop approval gate. - packages/conductor/src/conductor/viz.py — `to_mermaid(compiled)` for rendering a CompiledGraph as a Mermaid flowchart. Decision diamonds, compound subroutines, managed parallelograms, dashed shared-reference arrows, CEL guards inline. Both notebooks render their full pipeline via `IPython.display.Markdown`. 7 unit tests. Engine fix: - packages/conductor/src/conductor/execution/engine.py:_build_dep_graph — edge-based deps now redirect through `managed_to_region_start` exactly like consume_map already did. Without this, a node downstream of `for-each-end` had in_degree=0 (because the end is not schedulable) and dispatched immediately, racing the region body. Surfaces as empty/missing inputs on the downstream node. Regression test in tests/test_core/test_compound.py::TestForEachDownstreamNode. Index updates: CLAUDE.md notebook count, README examples table. 438 tests pass; ruff clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Both case studies now produce realistic Danish content per node so a reader can see what each step actually decided and rendered: - envir: fake_llm gives chapter-specific paragraphs (landskab, jord, vand, biologi, kumulative, resume); fake_ea_lookup returns realistic per-template excerpts; llm-chapter synthesizes four distinct named sections (lovgrundlag, eksisterende forhold, vurdering, konklusion); template chapters render chapter-specific Danish prose. - kk: fake_llm returns realistic Danish municipal letter prose per decision type; checkpoints carry descriptive Danish reasons; case summary surfaces structured sagsinfo / vurdering blocks. Both notebooks now include a streaming execution trace section (per-node timing + output snippet rendered live as a Markdown table) and a drill-down section showing each node's actual output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two new case-study notebooks demonstrating Conductor against real-world processes, a graph-visualization helper, and one engine bug fix surfaced while building them.
Notebooks
examples/09_case_study_miljorapport.ipynb— the PLST environmental-impact-report pipeline. Models the parse → context extraction → external data fan-out → 14 chapter generation → revise/ground → resume → docx assembly chain. Uses for-each for the external fetches, shared references forproject_context/EA indexbroadcast across chapters, SKIPPED-sentinel routing for the eval/revise branch, ConnectionList aggregation for the cumulative chapter and the docx assembler, and aHumanInputRequiredpause modeling the dataset-mapping review.examples/10_case_study_kk_afgorelse.ipynb— the Copenhagen Municipality kolonihave decision-draft pipeline. Showcases a different mix: parallel OCR fan-out (for-each+execution_mode="Parallel"), a sequential checkpoint chain folded throughFlowStore, decision-node + edge-guard CEL routing to one of five draft generators, and a human-in-the-loop approval gate that lets a case officer override the AI recommendation.Both notebooks run end-to-end with stubbed services (no API keys, no network).
conductor.vizNew module:
to_mermaid(compiled, *, direction="LR")renders anyCompiledGraphas a Mermaid flowchart string. Wrap in a fenced```mermaidblock — GitHub renders it natively, Jupyter viaIPython.display.Markdown. Visual conventions:[rectangle]{diamond}[[subroutine]][/parallelogram/]⟦…⟧7 unit tests in
tests/test_core/test_viz.py. Both case-study notebooks include a render cell using it.Engine fix
packages/conductor/src/conductor/execution/engine.py:_build_dep_graphnow redirects edge-based dependencies throughmanaged_to_region_startexactly likeconsume_mapalready did. Without this, any node positioned downstream of afor-each-endhadin_degree=0(becauseendis not inschedulable), so it dispatched immediately and raced the region body — observed as a node firing with empty/missing inputs in the envir notebook'sindex-resultsstep. Regression test added attests/test_core/test_compound.py::TestForEachDownstreamNode::test_node_after_end_sees_collected_results.Index updates
CLAUDE.mdnotebook count (7 → 10).README.mdexamples table — rows for 09 and 10.Test plan
conductor.viz).uvx ruff check .clean.jupyter nbconvert --executeand produce sensible output (chapter drafts assembled, kk decision routes to the chosen branch).🤖 Generated with Claude Code