quantology-modelmaker 0.1.1__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/MANIFEST.in +1 -0
  2. {quantology_modelmaker-0.1.1/quantology_modelmaker.egg-info → quantology_modelmaker-0.2.0}/PKG-INFO +105 -10
  3. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/README.md +92 -9
  4. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/App.tsx +183 -11
  5. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/BlockNode.tsx +159 -3
  6. quantology_modelmaker-0.2.0/frontend/src/BuildPanel.tsx +589 -0
  7. quantology_modelmaker-0.2.0/frontend/src/BuildReport.tsx +209 -0
  8. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/CodeEditor.tsx +10 -3
  9. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/DataModal.tsx +20 -9
  10. quantology_modelmaker-0.2.0/frontend/src/EnvVarField.tsx +89 -0
  11. quantology_modelmaker-0.2.0/frontend/src/GhostNode.tsx +63 -0
  12. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/Inspector.tsx +42 -3
  13. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/Palette.tsx +3 -1
  14. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/ParamsForm.tsx +190 -0
  15. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/PortDataView.tsx +12 -3
  16. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/SettingsPanel.tsx +73 -0
  17. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/Toolbar.tsx +2 -2
  18. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/api.ts +38 -2
  19. quantology_modelmaker-0.2.0/frontend/src/roles.ts +42 -0
  20. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/types.ts +142 -1
  21. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/vite.config.ts +3 -1
  22. quantology_modelmaker-0.2.0/modelmaker/agent/__init__.py +1 -0
  23. quantology_modelmaker-0.2.0/modelmaker/agent/build.py +435 -0
  24. quantology_modelmaker-0.2.0/modelmaker/agent/catalogue.py +145 -0
  25. quantology_modelmaker-0.2.0/modelmaker/agent/controller.py +566 -0
  26. quantology_modelmaker-0.2.0/modelmaker/agent/layout.py +71 -0
  27. quantology_modelmaker-0.2.0/modelmaker/agent/loop.py +629 -0
  28. quantology_modelmaker-0.2.0/modelmaker/agent/mcp_server.py +90 -0
  29. quantology_modelmaker-0.2.0/modelmaker/agent/prompts.py +211 -0
  30. quantology_modelmaker-0.2.0/modelmaker/agent/tools.py +837 -0
  31. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/api.py +366 -89
  32. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/blocks/base.py +18 -1
  33. quantology_modelmaker-0.2.0/modelmaker/blocks/binning.py +498 -0
  34. quantology_modelmaker-0.2.0/modelmaker/blocks/data_quality.py +304 -0
  35. quantology_modelmaker-0.2.0/modelmaker/blocks/feature_analysis.py +318 -0
  36. quantology_modelmaker-0.2.0/modelmaker/blocks/library.py +715 -0
  37. quantology_modelmaker-0.2.0/modelmaker/blocks/modelling.py +1203 -0
  38. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/blocks/stat_tests.py +217 -20
  39. quantology_modelmaker-0.2.0/modelmaker/blocks/stochastic.py +932 -0
  40. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/compiler.py +101 -25
  41. quantology_modelmaker-0.2.0/modelmaker/demo_data.py +431 -0
  42. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/graph.py +27 -0
  43. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/claude_cli_provider.py +16 -3
  44. quantology_modelmaker-0.2.0/modelmaker/llm/redact.py +45 -0
  45. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/settings.py +19 -1
  46. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/stub_provider.py +5 -0
  47. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/project.py +5 -0
  48. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/run_worker.py +72 -6
  49. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/runner.py +273 -81
  50. quantology_modelmaker-0.2.0/modelmaker/runslot.py +86 -0
  51. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/session.py +86 -6
  52. quantology_modelmaker-0.2.0/modelmaker/stochastic/__init__.py +12 -0
  53. quantology_modelmaker-0.2.0/modelmaker/stochastic/accumulate.py +174 -0
  54. quantology_modelmaker-0.2.0/modelmaker/stochastic/credit.py +107 -0
  55. quantology_modelmaker-0.2.0/modelmaker/stochastic/dependency.py +118 -0
  56. quantology_modelmaker-0.2.0/modelmaker/stochastic/distributions.py +202 -0
  57. quantology_modelmaker-0.2.0/modelmaker/stochastic/proxy.py +137 -0
  58. quantology_modelmaker-0.2.0/modelmaker/stochastic/seed.py +28 -0
  59. quantology_modelmaker-0.2.0/modelmaker/stochastic/var_covar.py +206 -0
  60. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/tui/app.py +37 -1
  61. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/tui/canvas.py +21 -0
  62. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/tui/client.py +1 -1
  63. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/tui/paramspecs.py +78 -0
  64. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/util.py +1 -1
  65. quantology_modelmaker-0.2.0/modelmaker/worker_pool.py +200 -0
  66. quantology_modelmaker-0.2.0/projects/demo_pd_model/model.json +428 -0
  67. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/pyproject.toml +28 -5
  68. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0/quantology_modelmaker.egg-info}/PKG-INFO +105 -10
  69. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/quantology_modelmaker.egg-info/SOURCES.txt +47 -1
  70. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/quantology_modelmaker.egg-info/entry_points.txt +1 -0
  71. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/quantology_modelmaker.egg-info/requires.txt +14 -0
  72. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/setup.py +26 -5
  73. quantology_modelmaker-0.2.0/tests/test_agent_api.py +267 -0
  74. quantology_modelmaker-0.2.0/tests/test_agent_build.py +611 -0
  75. quantology_modelmaker-0.2.0/tests/test_agent_foundations.py +254 -0
  76. quantology_modelmaker-0.2.0/tests/test_agent_loops.py +404 -0
  77. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_api.py +52 -0
  78. quantology_modelmaker-0.2.0/tests/test_binning.py +204 -0
  79. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_compiler.py +61 -14
  80. quantology_modelmaker-0.2.0/tests/test_data_quality.py +155 -0
  81. quantology_modelmaker-0.2.0/tests/test_demo_data.py +163 -0
  82. quantology_modelmaker-0.2.0/tests/test_env_vars.py +91 -0
  83. quantology_modelmaker-0.2.0/tests/test_input_blocks.py +242 -0
  84. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_master_scale.py +56 -1
  85. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_modelling.py +15 -0
  86. quantology_modelmaker-0.2.0/tests/test_prep_blocks.py +127 -0
  87. quantology_modelmaker-0.2.0/tests/test_risk_parameter_blocks.py +302 -0
  88. quantology_modelmaker-0.2.0/tests/test_stochastic_blocks.py +213 -0
  89. quantology_modelmaker-0.2.0/tests/test_stochastic_core.py +334 -0
  90. quantology_modelmaker-0.2.0/tests/test_stochastic_credit.py +231 -0
  91. quantology_modelmaker-0.2.0/tests/test_stochastic_fan_out.py +209 -0
  92. quantology_modelmaker-0.2.0/tests/test_stochastic_runner.py +95 -0
  93. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_tui_app.py +86 -47
  94. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_tui_charts.py +2 -2
  95. quantology_modelmaker-0.2.0/tests/test_validation_blocks.py +98 -0
  96. quantology_modelmaker-0.1.1/frontend/src/roles.ts +0 -17
  97. quantology_modelmaker-0.1.1/modelmaker/blocks/feature_analysis.py +0 -140
  98. quantology_modelmaker-0.1.1/modelmaker/blocks/library.py +0 -327
  99. quantology_modelmaker-0.1.1/modelmaker/blocks/modelling.py +0 -609
  100. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/LICENSE +0 -0
  101. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/NOTICE +0 -0
  102. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/.gitignore +0 -0
  103. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/.npmrc +0 -0
  104. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/.oxlintrc.json +0 -0
  105. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/README.md +0 -0
  106. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/index.html +0 -0
  107. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/package-lock.json +0 -0
  108. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/package.json +0 -0
  109. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/public/brand-quantology/favicon.svg +0 -0
  110. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/public/brand-quantology/icon-mark-light.svg +0 -0
  111. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/public/icons.svg +0 -0
  112. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/DataWireEdge.tsx +0 -0
  113. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/FileBrowser.tsx +0 -0
  114. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/GitPanel.tsx +0 -0
  115. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/LaneBand.tsx +0 -0
  116. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/LaneLabels.tsx +0 -0
  117. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/PortInspector.tsx +0 -0
  118. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/assets/hero.png +0 -0
  119. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/assets/react.svg +0 -0
  120. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/assets/vite.svg +0 -0
  121. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/index.css +0 -0
  122. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/src/main.tsx +0 -0
  123. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/tsconfig.app.json +0 -0
  124. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/tsconfig.json +0 -0
  125. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/frontend/tsconfig.node.json +0 -0
  126. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/__init__.py +0 -0
  127. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/blocks/__init__.py +0 -0
  128. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/cache.py +0 -0
  129. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/gitops.py +0 -0
  130. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/__init__.py +0 -0
  131. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/anthropic_provider.py +0 -0
  132. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/base.py +0 -0
  133. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/gemini_provider.py +0 -0
  134. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/lmstudio_provider.py +0 -0
  135. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/openai_provider.py +0 -0
  136. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/llm/prompts.py +0 -0
  137. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/metadata_transforms.py +0 -0
  138. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/packet.py +0 -0
  139. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/tui/__init__.py +0 -0
  140. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/tui/charts.py +0 -0
  141. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/tui/inspector.py +0 -0
  142. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/tui/preview.py +0 -0
  143. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/modelmaker/tui/screens.py +0 -0
  144. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/quantology_modelmaker.egg-info/dependency_links.txt +0 -0
  145. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/quantology_modelmaker.egg-info/top_level.txt +0 -0
  146. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/run.bat +0 -0
  147. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/setup.cfg +0 -0
  148. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_demo_project.py +0 -0
  149. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_feature_analysis.py +0 -0
  150. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_gitops.py +0 -0
  151. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_graph.py +0 -0
  152. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_library.py +0 -0
  153. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_llm.py +0 -0
  154. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_packet.py +0 -0
  155. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_project.py +0 -0
  156. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_runner.py +0 -0
  157. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_runner_streaming.py +0 -0
  158. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_session.py +0 -0
  159. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_stat_tests.py +0 -0
  160. {quantology_modelmaker-0.1.1 → quantology_modelmaker-0.2.0}/tests/test_tui_client.py +0 -0
@@ -2,5 +2,6 @@ include README.md LICENSE NOTICE run.bat
2
2
  graft frontend
3
3
  prune frontend/node_modules
4
4
  prune frontend/dist
5
+ graft projects/demo_pd_model
5
6
  global-exclude __pycache__
6
7
  global-exclude *.py[cod]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantology-modelmaker
3
- Version: 0.1.1
3
+ Version: 0.2.0
4
4
  Summary: Visual pipeline builder for financial model development
5
5
  Author-email: Maurits Malkus <10948172+mmalkus@users.noreply.github.com>
6
6
  License-Expression: Apache-2.0
@@ -26,16 +26,28 @@ Requires-Dist: uvicorn>=0.29.0
26
26
  Requires-Dist: matplotlib>=3.8.0
27
27
  Requires-Dist: scikit-learn>=1.4.0
28
28
  Requires-Dist: scipy>=1.11.0
29
+ Requires-Dist: numpy>=1.26.0
29
30
  Requires-Dist: python-dotenv>=1.0.0
31
+ Requires-Dist: mcp<2,>=1.0.0
30
32
  Provides-Extra: dev
31
33
  Requires-Dist: pytest>=8.0.0; extra == "dev"
34
+ Requires-Dist: pytest-xdist>=3.5.0; extra == "dev"
32
35
  Requires-Dist: httpx>=0.27.0; extra == "dev"
36
+ Requires-Dist: fastexcel>=0.10.0; extra == "dev"
37
+ Requires-Dist: xlsxwriter>=3.0.0; extra == "dev"
38
+ Requires-Dist: connectorx>=0.3.3; extra == "dev"
39
+ Requires-Dist: pyarrow>=16.0.0; extra == "dev"
33
40
  Provides-Extra: anthropic
34
41
  Requires-Dist: anthropic>=0.70.0; extra == "anthropic"
35
42
  Provides-Extra: tui
36
43
  Requires-Dist: textual>=0.80.0; extra == "tui"
37
44
  Requires-Dist: httpx>=0.27.0; extra == "tui"
38
45
  Requires-Dist: plotext<6,>=5.2.0; extra == "tui"
46
+ Provides-Extra: excel
47
+ Requires-Dist: fastexcel>=0.10.0; extra == "excel"
48
+ Provides-Extra: db
49
+ Requires-Dist: connectorx>=0.3.3; extra == "db"
50
+ Requires-Dist: pyarrow>=16.0.0; extra == "db"
39
51
  Dynamic: license-file
40
52
 
41
53
  # Model-Maker
@@ -104,16 +116,38 @@ it's ready to commit and push right away from the **Git** panel.
104
116
  ## The demo project
105
117
 
106
118
  [`projects/demo_pd_model/`](projects/demo_pd_model) is a complete, runnable
107
- PD pipeline over [`sample_data/pd_model_data.csv`](sample_data): load →
108
- clean → weight-of-evidence → train/test split → logistic regression → Gini,
109
- KS and PSI. Open it with **Load** (it's what the folder dialog opens on),
110
- then **Run all** — it reads the CSV source itself since it's never been read
111
- before, then runs the rest of the pipeline.
119
+ PD pipeline: load demo data → clean → weight-of-evidence → train/test
120
+ split → logistic regression → Gini, KS and PSI. Open it with **Load** (it's
121
+ what the folder dialog opens on), then **Run all**.
112
122
 
113
123
  It's the quickest way to see what a finished graph looks like, and the test
114
- suite runs it end to end so it can't rot. This folder lives in the git
115
- repository rather than the PyPI package — clone the repo (or just download
116
- it) to try it.
124
+ suite runs it end to end so it can't rot.
125
+
126
+ Its data comes from the **Demo credit data (PD/LGD/CCF)** input block,
127
+ which generates a synthetic retail book of term loans and credit cards in
128
+ memory: no file to find, and it works the same from a repo clone or a
129
+ `pip install`. It is built to support all three credit-risk parameters: a
130
+ 12-month default flag for **PD**, EAD / discounted recoveries / workout
131
+ costs on every default for **LGD** (`compute_lgd`), and limit plus balance
132
+ at reference and at default on defaulted cards for **CCF**
133
+ (`compute_ccf`). Set **n_rows** for the number of records (default 5,000)
134
+ and **seed** to get different data; the same seed always gives the same
135
+ rows. The generator is [`modelmaker/demo_data.py`](modelmaker/demo_data.py),
136
+ whose docstring describes every column. To get the data as a CSV instead:
137
+
138
+ ```bash
139
+ python -m modelmaker.demo_data credit_risk_data.csv --rows 10000
140
+ ```
141
+
142
+ After a `pip install`, copy the demo projects somewhere writable (projects
143
+ save back into their own folder) with:
144
+
145
+ ```bash
146
+ modelmaker-demo # creates ./modelmaker-demo/projects/
147
+ ```
148
+
149
+ then run `modelmaker-api` (or `modelmaker-tui`) from inside that folder.
150
+ `modelmaker-tui --demo` does both steps in one go.
117
151
 
118
152
  ## Working in the tool
119
153
 
@@ -166,6 +200,7 @@ can be saved to a `.txt`/`.html` file alongside the block's own PNG.
166
200
  ```bash
167
201
  modelmaker-tui # spawns its own modelmaker-api, zero setup
168
202
  modelmaker-tui projects/demo_pd_model # ...and loads a project (a folder) on startup
203
+ modelmaker-tui --demo # ...or sets up ./modelmaker-demo and opens the demo there
169
204
  modelmaker-tui --host 127.0.0.1 --port 8001 # attach to an already-running modelmaker-api instead
170
205
  ```
171
206
 
@@ -242,6 +277,64 @@ export MODELMAKER_LLM_MODEL=gpt-5.1
242
277
  modelmaker-api
243
278
  ```
244
279
 
280
+ ## Build with AI
281
+
282
+ Beyond drafting one block at a time, an AI can plan and build a whole model
283
+ graph for you (design: [agent-builder-proposal.md](agent-builder-proposal.md)):
284
+
285
+ 1. **Prepare the data yourself.** Add your input block(s), run them, and tag
286
+ column roles in the port inspector: at least `target`, plus `excluded`
287
+ for anything that must never become a feature (leaky or post-outcome
288
+ columns). The AI never picks files or touches credentials.
289
+ 2. **Select** those blocks (shift-click for several), click **Build with AI**
290
+ and describe the goal.
291
+ 3. **Preflight** checks the selected blocks and everything upstream of them.
292
+ Blocks that aren't up to date get a warning, with **Run upstream** to fix
293
+ them or **Proceed anyway**.
294
+ 4. **Review the plan.** It appears as ghost blocks on the canvas and as a
295
+ list in the panel. Nothing changes until you approve. Send feedback to
296
+ have it re-plan.
297
+ 5. **Watch it build.** It adds blocks, runs each one, reads their summary
298
+ statistics, fixes failures, and asks you when it's stuck. The canvas is
299
+ read-only for you meanwhile. A large dataset is built on a sample, then
300
+ the whole graph runs once on the full data.
301
+ 6. **Read the report** with **Open full report** in the panel. Every
302
+ build keeps its own report, listed under **Build reports**. AI-built
303
+ blocks carry an **AI** badge; click it to see the provenance record
304
+ (build, LLMs, time, whether a person has edited the block since) and
305
+ open the report of each build that made or changed it. **One Undo
306
+ reverts the whole build**, its report included.
307
+
308
+ Guardrails are enforced by the tools, not just the prompt:
309
+ - **No rows.** The AI only ever sees column names, dtypes, roles and
310
+ summary statistics. The min/max of text and id columns are withheld too,
311
+ for every AI feature.
312
+ - **Your blocks stay yours.** It can read and wire *from* your blocks, but
313
+ it only changes blocks it created, plus changes to existing blocks that
314
+ the plan listed and you approved.
315
+ - **Excluded means excluded.** Columns tagged `excluded` are refused as
316
+ features.
317
+ - **Limits.** Tool calls, custom blocks, repeated failures and wall time
318
+ are all capped.
319
+
320
+ Builds run on `claude_cli` (your existing Claude login, via a small MCP
321
+ bridge), `anthropic`, `openai` (or any OpenAI-compatible endpoint that
322
+ supports tool calling, via its base URL), `gemini`, or `lmstudio`. They use
323
+ the same keys, models and base URLs as in the LLM provider settings above.
324
+ **Settings → AI builder** picks a separate plan LLM and build LLM, and each
325
+ build can override them.
326
+
327
+ `lmstudio` covers any local OpenAI-compatible server: LM Studio, or
328
+ llama.cpp's `llama-server` (start it with `--jinja`, which tool calling
329
+ needs), Ollama's `/v1`, or vLLM. The model is auto-detected when unset.
330
+ Local models get a compact prompt, where the block catalogue is block names
331
+ per category and details are fetched on demand. They also get length caps
332
+ on tool results, and older results are dropped when the conversation nears
333
+ the context window. The window size is read from the server (llama.cpp
334
+ reports it) or set with `MODELMAKER_LLM_CONTEXT_TOKENS`. Expect a local
335
+ build to take a while; `MODELMAKER_LLM_TIMEOUT_SECONDS` (default 900 for
336
+ local models) caps a single request.
337
+
245
338
  ## Project structure
246
339
 
247
340
  ```
@@ -249,14 +342,16 @@ modelmaker/
249
342
  api.py FastAPI app and HTTP routes
250
343
  blocks/ Block registry (standard library, modelling, stat tests)
251
344
  llm/ Pluggable LLM providers for AI-assisted drafting
345
+ agent/ AI model builder: tools, guards, build lifecycle, loops, MCP bridge
252
346
  graph.py Graph/block/wire data model
253
347
  session.py Mutable project session wrapping the graph + runner
254
348
  runner.py Block execution + caching engine
255
349
  compiler.py Compiles a graph to a single Python script
350
+ demo_data.py Fixed-seed generator for the PD/LGD/CCF demo dataset
256
351
  packet.py DataFramePacket: the typed value flowing over wires
257
352
  project.py Load/save project files (JSON + block source files)
258
353
  static/ Built frontend bundle (generated, gitignored)
259
354
  frontend/ React + Vite UI
260
355
  tests/ Pytest suite for the backend
261
- sample_data/ Example CSVs for building demo pipelines
356
+ sample_data/ Example CSVs (tests also write a generated credit_risk_data.csv here, gitignored)
262
357
  ```
@@ -64,16 +64,38 @@ it's ready to commit and push right away from the **Git** panel.
64
64
  ## The demo project
65
65
 
66
66
  [`projects/demo_pd_model/`](projects/demo_pd_model) is a complete, runnable
67
- PD pipeline over [`sample_data/pd_model_data.csv`](sample_data): load →
68
- clean → weight-of-evidence → train/test split → logistic regression → Gini,
69
- KS and PSI. Open it with **Load** (it's what the folder dialog opens on),
70
- then **Run all** — it reads the CSV source itself since it's never been read
71
- before, then runs the rest of the pipeline.
67
+ PD pipeline: load demo data → clean → weight-of-evidence → train/test
68
+ split → logistic regression → Gini, KS and PSI. Open it with **Load** (it's
69
+ what the folder dialog opens on), then **Run all**.
72
70
 
73
71
  It's the quickest way to see what a finished graph looks like, and the test
74
- suite runs it end to end so it can't rot. This folder lives in the git
75
- repository rather than the PyPI package — clone the repo (or just download
76
- it) to try it.
72
+ suite runs it end to end so it can't rot.
73
+
74
+ Its data comes from the **Demo credit data (PD/LGD/CCF)** input block,
75
+ which generates a synthetic retail book of term loans and credit cards in
76
+ memory: no file to find, and it works the same from a repo clone or a
77
+ `pip install`. It is built to support all three credit-risk parameters: a
78
+ 12-month default flag for **PD**, EAD / discounted recoveries / workout
79
+ costs on every default for **LGD** (`compute_lgd`), and limit plus balance
80
+ at reference and at default on defaulted cards for **CCF**
81
+ (`compute_ccf`). Set **n_rows** for the number of records (default 5,000)
82
+ and **seed** to get different data; the same seed always gives the same
83
+ rows. The generator is [`modelmaker/demo_data.py`](modelmaker/demo_data.py),
84
+ whose docstring describes every column. To get the data as a CSV instead:
85
+
86
+ ```bash
87
+ python -m modelmaker.demo_data credit_risk_data.csv --rows 10000
88
+ ```
89
+
90
+ After a `pip install`, copy the demo projects somewhere writable (projects
91
+ save back into their own folder) with:
92
+
93
+ ```bash
94
+ modelmaker-demo # creates ./modelmaker-demo/projects/
95
+ ```
96
+
97
+ then run `modelmaker-api` (or `modelmaker-tui`) from inside that folder.
98
+ `modelmaker-tui --demo` does both steps in one go.
77
99
 
78
100
  ## Working in the tool
79
101
 
@@ -126,6 +148,7 @@ can be saved to a `.txt`/`.html` file alongside the block's own PNG.
126
148
  ```bash
127
149
  modelmaker-tui # spawns its own modelmaker-api, zero setup
128
150
  modelmaker-tui projects/demo_pd_model # ...and loads a project (a folder) on startup
151
+ modelmaker-tui --demo # ...or sets up ./modelmaker-demo and opens the demo there
129
152
  modelmaker-tui --host 127.0.0.1 --port 8001 # attach to an already-running modelmaker-api instead
130
153
  ```
131
154
 
@@ -202,6 +225,64 @@ export MODELMAKER_LLM_MODEL=gpt-5.1
202
225
  modelmaker-api
203
226
  ```
204
227
 
228
+ ## Build with AI
229
+
230
+ Beyond drafting one block at a time, an AI can plan and build a whole model
231
+ graph for you (design: [agent-builder-proposal.md](agent-builder-proposal.md)):
232
+
233
+ 1. **Prepare the data yourself.** Add your input block(s), run them, and tag
234
+ column roles in the port inspector: at least `target`, plus `excluded`
235
+ for anything that must never become a feature (leaky or post-outcome
236
+ columns). The AI never picks files or touches credentials.
237
+ 2. **Select** those blocks (shift-click for several), click **Build with AI**
238
+ and describe the goal.
239
+ 3. **Preflight** checks the selected blocks and everything upstream of them.
240
+ Blocks that aren't up to date get a warning, with **Run upstream** to fix
241
+ them or **Proceed anyway**.
242
+ 4. **Review the plan.** It appears as ghost blocks on the canvas and as a
243
+ list in the panel. Nothing changes until you approve. Send feedback to
244
+ have it re-plan.
245
+ 5. **Watch it build.** It adds blocks, runs each one, reads their summary
246
+ statistics, fixes failures, and asks you when it's stuck. The canvas is
247
+ read-only for you meanwhile. A large dataset is built on a sample, then
248
+ the whole graph runs once on the full data.
249
+ 6. **Read the report** with **Open full report** in the panel. Every
250
+ build keeps its own report, listed under **Build reports**. AI-built
251
+ blocks carry an **AI** badge; click it to see the provenance record
252
+ (build, LLMs, time, whether a person has edited the block since) and
253
+ open the report of each build that made or changed it. **One Undo
254
+ reverts the whole build**, its report included.
255
+
256
+ Guardrails are enforced by the tools, not just the prompt:
257
+ - **No rows.** The AI only ever sees column names, dtypes, roles and
258
+ summary statistics. The min/max of text and id columns are withheld too,
259
+ for every AI feature.
260
+ - **Your blocks stay yours.** It can read and wire *from* your blocks, but
261
+ it only changes blocks it created, plus changes to existing blocks that
262
+ the plan listed and you approved.
263
+ - **Excluded means excluded.** Columns tagged `excluded` are refused as
264
+ features.
265
+ - **Limits.** Tool calls, custom blocks, repeated failures and wall time
266
+ are all capped.
267
+
268
+ Builds run on `claude_cli` (your existing Claude login, via a small MCP
269
+ bridge), `anthropic`, `openai` (or any OpenAI-compatible endpoint that
270
+ supports tool calling, via its base URL), `gemini`, or `lmstudio`. They use
271
+ the same keys, models and base URLs as in the LLM provider settings above.
272
+ **Settings → AI builder** picks a separate plan LLM and build LLM, and each
273
+ build can override them.
274
+
275
+ `lmstudio` covers any local OpenAI-compatible server: LM Studio, or
276
+ llama.cpp's `llama-server` (start it with `--jinja`, which tool calling
277
+ needs), Ollama's `/v1`, or vLLM. The model is auto-detected when unset.
278
+ Local models get a compact prompt, where the block catalogue is block names
279
+ per category and details are fetched on demand. They also get length caps
280
+ on tool results, and older results are dropped when the conversation nears
281
+ the context window. The window size is read from the server (llama.cpp
282
+ reports it) or set with `MODELMAKER_LLM_CONTEXT_TOKENS`. Expect a local
283
+ build to take a while; `MODELMAKER_LLM_TIMEOUT_SECONDS` (default 900 for
284
+ local models) caps a single request.
285
+
205
286
  ## Project structure
206
287
 
207
288
  ```
@@ -209,14 +290,16 @@ modelmaker/
209
290
  api.py FastAPI app and HTTP routes
210
291
  blocks/ Block registry (standard library, modelling, stat tests)
211
292
  llm/ Pluggable LLM providers for AI-assisted drafting
293
+ agent/ AI model builder: tools, guards, build lifecycle, loops, MCP bridge
212
294
  graph.py Graph/block/wire data model
213
295
  session.py Mutable project session wrapping the graph + runner
214
296
  runner.py Block execution + caching engine
215
297
  compiler.py Compiles a graph to a single Python script
298
+ demo_data.py Fixed-seed generator for the PD/LGD/CCF demo dataset
216
299
  packet.py DataFramePacket: the typed value flowing over wires
217
300
  project.py Load/save project files (JSON + block source files)
218
301
  static/ Built frontend bundle (generated, gitignored)
219
302
  frontend/ React + Vite UI
220
303
  tests/ Pytest suite for the backend
221
- sample_data/ Example CSVs for building demo pipelines
304
+ sample_data/ Example CSVs (tests also write a generated credit_risk_data.csv here, gitignored)
222
305
  ```
@@ -13,18 +13,29 @@ import '@xyflow/react/dist/style.css'
13
13
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
14
14
  import { api } from './api'
15
15
  import { BlockNode, type BlockFlowNode } from './BlockNode'
16
+ import { BuildPanel } from './BuildPanel'
17
+ import { ReportModal } from './BuildReport'
16
18
  import { DataWireEdge, type DataWireEdgeType } from './DataWireEdge'
19
+ import { GHOST_IN, GHOST_OUT, GhostLane, GhostNode, type GhostFlowNode, type GhostLaneNode } from './GhostNode'
17
20
  import { Inspector } from './Inspector'
18
21
  import { BAND_X, DEFAULT_LANE_HEIGHT, LaneBand, layoutLanes, type LaneBandNode, type LaneLayoutEntry } from './LaneBand'
19
22
  import { LaneLabels, LaneResizeHandles } from './LaneLabels'
20
23
  import { Palette } from './Palette'
21
24
  import { PortInspector } from './PortInspector'
22
25
  import { Toolbar } from './Toolbar'
23
- import type { BlockOut, GraphOut, LaneOut, LLMSettingsOut, PortType, RecoveryInfo } from './types'
26
+ import type { BlockOut, BuildOut, GraphOut, LaneOut, LLMSettingsOut, PortType, RecoveryInfo } from './types'
24
27
 
25
- const nodeTypes = { modelBlock: BlockNode, laneBand: LaneBand }
28
+ const nodeTypes = { modelBlock: BlockNode, laneBand: LaneBand, ghostBlock: GhostNode, ghostLane: GhostLane }
26
29
  const edgeTypes = { dataWire: DataWireEdge }
27
30
 
31
+ // Build phases during which the server refuses user edits (see api.py's
32
+ // agent canvas lock) -- mirrored here only to say so up front.
33
+ const BUILD_LOCKING = new Set(['building', 'awaiting_input', 'final_run'])
34
+ const BUILD_TERMINAL = new Set(['done', 'done_with_errors', 'stopped', 'failed', 'discarded'])
35
+ const BUILD_BLOCK_TOOLS = new Set(['add_block', 'add_custom_block', 'run_to', 'set_params', 'update_custom_block', 'connect'])
36
+
37
+ type AiEdge = { id: string; source: string; sourceHandle: string; target: string; targetHandle: string; style: React.CSSProperties; selectable: false }
38
+
28
39
  // How long to sit idle after the last edit before writing the project file.
29
40
  // Short enough that a save is never more than a few clicks stale, long
30
41
  // enough that dragging a block across the canvas or stepping through a
@@ -37,12 +48,13 @@ export type AutosaveStatus =
37
48
  | { state: 'saved'; at: number }
38
49
  | { state: 'error'; message: string }
39
50
 
40
- type FlowNode = BlockFlowNode | LaneBandNode
51
+ type FlowNode = BlockFlowNode | LaneBandNode | GhostFlowNode | GhostLaneNode
41
52
 
42
53
  function toBlockNodes(
43
54
  graph: GraphOut,
44
55
  collapsedLanes: Set<string>,
45
56
  onViewPort: (blockId: string, port: string, portType: PortType) => void,
57
+ onOpenBuildReport: (buildId: string) => void,
46
58
  ): BlockFlowNode[] {
47
59
  return Object.values(graph.blocks)
48
60
  .filter((block) => !(block.lane && collapsedLanes.has(block.lane)))
@@ -50,7 +62,7 @@ function toBlockNodes(
50
62
  id: block.id,
51
63
  type: 'modelBlock' as const,
52
64
  position: block.position,
53
- data: { block, onViewPort },
65
+ data: { block, onViewPort, onOpenBuildReport },
54
66
  }))
55
67
  }
56
68
 
@@ -84,6 +96,10 @@ function AppInner() {
84
96
  const [llmSettings, setLlmSettings] = useState<LLMSettingsOut | null>(null)
85
97
  const [recovery, setRecovery] = useState<RecoveryInfo | null>(null)
86
98
  const [autosave, setAutosave] = useState<AutosaveStatus>({ state: 'idle' })
99
+ const [buildOpen, setBuildOpen] = useState(false)
100
+ const [build, setBuild] = useState<BuildOut | null>(null)
101
+ // The AI build whose full report is open (see BuildReport.ReportModal).
102
+ const [reportBuildId, setReportBuildId] = useState<string | null>(null)
87
103
  const { fitView, screenToFlowPosition } = useReactFlow()
88
104
  const didInitialFit = useRef(false)
89
105
 
@@ -95,6 +111,15 @@ function AppInner() {
95
111
  reloadLlmSettings()
96
112
  }, [reloadLlmSettings])
97
113
 
114
+ // Pick up an AI build that's still going on the server (e.g. after a page
115
+ // reload) -- a live one keeps BuildPanel mounted, which polls it.
116
+ useEffect(() => {
117
+ api
118
+ .agentCurrent()
119
+ .then((s) => setBuild(s.build))
120
+ .catch(() => {})
121
+ }, [])
122
+
98
123
  const onViewPort = useCallback((blockId: string, port: string, portType: PortType) => {
99
124
  setSelectedPort({ blockId, port, portType })
100
125
  }, [])
@@ -102,8 +127,17 @@ function AppInner() {
102
127
  const reload = useCallback(() => {
103
128
  api.graph().then((g) => {
104
129
  setGraph(g)
105
- const nextBlockNodes = toBlockNodes(g, collapsedLanes, onViewPort)
106
- setBlockNodes(nextBlockNodes)
130
+ const nextBlockNodes = toBlockNodes(g, collapsedLanes, onViewPort, setReportBuildId)
131
+ // Carry over React Flow's measured size and selection: the run poll
132
+ // reloads every 200ms, and fresh nodes without `measured` are hidden
133
+ // until re-measured, which blinks the whole canvas.
134
+ setBlockNodes((prev) => {
135
+ const prevById = new Map(prev.map((n) => [n.id, n]))
136
+ return nextBlockNodes.map((n) => {
137
+ const old = prevById.get(n.id)
138
+ return old ? { ...n, measured: old.measured, selected: old.selected } : n
139
+ })
140
+ })
107
141
  // fit the view to the actual blocks (not the oversized lane bands) once,
108
142
  // on first load -- re-fitting on every later reload would yank the
109
143
  // viewport out from under someone mid-edit.
@@ -228,7 +262,7 @@ function AppInner() {
228
262
  }, [anyRunning, reload])
229
263
 
230
264
  useEffect(() => {
231
- if (graph) setBlockNodes(toBlockNodes(graph, collapsedLanes, onViewPort))
265
+ if (graph) setBlockNodes(toBlockNodes(graph, collapsedLanes, onViewPort, setReportBuildId))
232
266
  // eslint-disable-next-line react-hooks/exhaustive-deps
233
267
  }, [collapsedLanes])
234
268
 
@@ -323,12 +357,116 @@ function AppInner() {
323
357
  [laneLayout, collapsedLanes],
324
358
  )
325
359
 
326
- const nodes: FlowNode[] = useMemo(() => [...laneNodes, ...blockNodes], [laneNodes, blockNodes])
360
+ // ---- AI build overlays (see BuildPanel / agent-builder-proposal.md §4.2) --
361
+ // While a plan awaits review: its steps as ghost blocks (plus ghost bands
362
+ // for lanes it would create) and its wiring as dashed edges. While
363
+ // building: a highlight on whichever block the AI last touched.
364
+ const reviewPlan = build?.phase === 'awaiting_approval' ? build.plan : null
365
+ const ghostNodes: (GhostFlowNode | GhostLaneNode)[] = useMemo(() => {
366
+ if (!reviewPlan) return []
367
+ const lanes: GhostLaneNode[] = Object.entries(reviewPlan.lane_layout ?? {}).map(([key, l]) => ({
368
+ id: `ghostlane_${key}`,
369
+ type: 'ghostLane' as const,
370
+ position: { x: BAND_X, y: l.top },
371
+ draggable: false,
372
+ selectable: false,
373
+ zIndex: -9,
374
+ data: { name: l.name, height: l.height },
375
+ }))
376
+ const steps: GhostFlowNode[] = reviewPlan.steps
377
+ .filter((s) => reviewPlan.layout?.[s.ref])
378
+ .map((s) => ({
379
+ id: `ghost_${s.ref}`,
380
+ type: 'ghostBlock' as const,
381
+ position: { x: reviewPlan.layout[s.ref].x, y: reviewPlan.layout[s.ref].y },
382
+ draggable: false,
383
+ selectable: false,
384
+ data: { step: s, highlighted: false },
385
+ }))
386
+ return [...lanes, ...steps]
387
+ }, [reviewPlan])
388
+
389
+ const ghostEdges: AiEdge[] = useMemo(() => {
390
+ if (!reviewPlan) return []
391
+ const refs = new Set(reviewPlan.steps.map((s) => s.ref))
392
+ return reviewPlan.steps.flatMap((s) =>
393
+ s.inputs.map((inp, i) => ({
394
+ id: `ghostedge_${s.ref}_${i}`,
395
+ source: refs.has(inp.from) ? `ghost_${inp.from}` : inp.from,
396
+ sourceHandle: refs.has(inp.from) ? GHOST_OUT : inp.from_port,
397
+ target: `ghost_${s.ref}`,
398
+ targetHandle: GHOST_IN,
399
+ style: { stroke: '#a78bfa', strokeDasharray: '6 4' },
400
+ selectable: false as const,
401
+ })),
402
+ )
403
+ }, [reviewPlan])
404
+
405
+ const aiActiveBlock = useMemo(() => {
406
+ if (!build || !BUILD_LOCKING.has(build.phase)) return null
407
+ for (let i = build.events.length - 1; i >= 0; i--) {
408
+ const e = build.events[i]
409
+ if (e.kind === 'tool' && BUILD_BLOCK_TOOLS.has(String(e.tool))) {
410
+ const args = (e.args ?? {}) as Record<string, unknown>
411
+ const result = (e.result ?? {}) as Record<string, unknown>
412
+ return String(args.block ?? args.to_block ?? result.block ?? '')
413
+ }
414
+ }
415
+ return null
416
+ }, [build])
417
+
418
+ const plannedChanges = useMemo(() => {
419
+ const m = new Map<string, string>()
420
+ for (const c of reviewPlan?.changes_to_existing ?? []) m.set(c.block, m.has(c.block) ? `${m.get(c.block)}; ${c.change}` : c.change)
421
+ return m
422
+ }, [reviewPlan])
423
+
424
+ const overlaidBlockNodes = useMemo(
425
+ () =>
426
+ blockNodes.map((n) =>
427
+ n.id === aiActiveBlock || plannedChanges.has(n.id)
428
+ ? { ...n, data: { ...n.data, aiActive: n.id === aiActiveBlock, aiPlannedChange: plannedChanges.get(n.id) ?? null } }
429
+ : n,
430
+ ),
431
+ [blockNodes, aiActiveBlock, plannedChanges],
432
+ )
433
+
434
+ // Lane bands and ghosts are derived (memoized) rather than held in state,
435
+ // so React Flow's measured sizes for them would otherwise be dropped --
436
+ // and in controlled mode an unmeasured node stays `visibility: hidden`
437
+ // and can't anchor edges. Keep their measurements here and hand them back.
438
+ const [derivedMeasured, setDerivedMeasured] = useState<Record<string, { width: number; height: number }>>({})
439
+ const nodes: FlowNode[] = useMemo(
440
+ () => [
441
+ ...laneNodes.map((n) => (derivedMeasured[n.id] ? { ...n, measured: derivedMeasured[n.id] } : n)),
442
+ ...overlaidBlockNodes,
443
+ ...ghostNodes.map((n) => (derivedMeasured[n.id] ? { ...n, measured: derivedMeasured[n.id] } : n)),
444
+ ],
445
+ [laneNodes, overlaidBlockNodes, ghostNodes, derivedMeasured],
446
+ )
327
447
 
328
448
  const onNodesChange = useCallback((changes: NodeChange<FlowNode>[]) => {
329
- setBlockNodes((nds) => applyNodeChanges(changes, nds) as BlockFlowNode[])
449
+ const isDerived = (id: string) => id.startsWith('laneband_') || id.startsWith('ghost')
450
+ const derived = changes.filter((c) => c.type === 'dimensions' && isDerived(c.id) && c.dimensions)
451
+ if (derived.length > 0) {
452
+ setDerivedMeasured((prev) => {
453
+ const next = { ...prev }
454
+ for (const c of derived) if (c.type === 'dimensions' && c.dimensions) next[c.id] = c.dimensions
455
+ return next
456
+ })
457
+ }
458
+ const blockChanges = changes.filter((c) => !('id' in c) || !isDerived(c.id))
459
+ if (blockChanges.length > 0) setBlockNodes((nds) => applyNodeChanges(blockChanges as NodeChange<BlockFlowNode>[], nds))
330
460
  }, [])
331
461
 
462
+ const selectedIds = useMemo(() => {
463
+ const ids = blockNodes.filter((n) => n.selected).map((n) => n.id)
464
+ return ids.length > 0 ? ids : selectedId ? [selectedId] : []
465
+ }, [blockNodes, selectedId])
466
+
467
+ const buildLive = build != null && !BUILD_TERMINAL.has(build.phase)
468
+ const canvasLocked = build != null && BUILD_LOCKING.has(build.phase)
469
+
332
470
  const laneForY = useCallback(
333
471
  (y: number): string | null => {
334
472
  const hit = laneLayout.find((l) => y >= l.top && y < l.top + l.height)
@@ -367,6 +505,7 @@ function AppInner() {
367
505
 
368
506
  const onEdgeClick = useCallback(
369
507
  (_: unknown, edge: DataWireEdgeType) => {
508
+ if (edge.id.startsWith('ghostedge_')) return
370
509
  if (confirm('Delete this wire?')) {
371
510
  api.deleteWire(edge.id).then(reload)
372
511
  }
@@ -519,7 +658,7 @@ function AppInner() {
519
658
  <div style={{ flex: 1 }} onDragOver={onDragOver} onDrop={onDrop}>
520
659
  <ReactFlow
521
660
  nodes={nodes}
522
- edges={graph ? toEdges(graph) : []}
661
+ edges={graph ? [...toEdges(graph), ...(ghostEdges as unknown as DataWireEdgeType[])] : []}
523
662
  nodeTypes={nodeTypes}
524
663
  edgeTypes={edgeTypes}
525
664
  onNodesChange={onNodesChange}
@@ -548,6 +687,23 @@ function AppInner() {
548
687
  onMove={moveLane}
549
688
  />
550
689
  <LaneResizeHandles lanes={laneLayout} collapsedLanes={collapsedLanes} onResize={resizeLane} />
690
+ <Panel position="top-right" style={{ display: 'flex', gap: 6, alignItems: 'center' }}>
691
+ {canvasLocked && (
692
+ <span
693
+ title="While the AI builds, the graph is read-only for you -- stop the build to edit"
694
+ style={{ background: '#ede9fe', color: '#5b21b6', borderRadius: 4, padding: '3px 8px', fontSize: 12 }}
695
+ >
696
+ AI is editing -- canvas read-only
697
+ </span>
698
+ )}
699
+ <button
700
+ className={buildOpen ? undefined : 'brand-primary'}
701
+ onClick={() => setBuildOpen((o) => !o)}
702
+ title="Have an AI plan and build a model from the selected blocks"
703
+ >
704
+ {buildLive && !buildOpen ? 'AI build in progress…' : 'Build with AI'}
705
+ </button>
706
+ </Panel>
551
707
  <Panel
552
708
  position="bottom-right"
553
709
  style={{
@@ -572,7 +728,22 @@ function AppInner() {
572
728
  </Panel>
573
729
  </ReactFlow>
574
730
  </div>
575
- {selectedPort && graph ? (
731
+ {graph && (buildOpen || buildLive) && (
732
+ // Kept mounted (just hidden) while a build is live, so it keeps
733
+ // polling the build -- and the canvas -- with the panel closed.
734
+ <div style={{ display: buildOpen ? 'flex' : 'none' }}>
735
+ <BuildPanel
736
+ graph={graph}
737
+ selectedIds={selectedIds}
738
+ llmSettings={llmSettings}
739
+ onChanged={reload}
740
+ onBuild={setBuild}
741
+ onClose={() => setBuildOpen(false)}
742
+ onOpenReport={setReportBuildId}
743
+ />
744
+ </div>
745
+ )}
746
+ {buildOpen ? null : selectedPort && graph ? (
576
747
  <PortInspector
577
748
  blockId={selectedPort.blockId}
578
749
  port={selectedPort.port}
@@ -585,6 +756,7 @@ function AppInner() {
585
756
  <Inspector block={selectedBlock} onChanged={reload} provider={llmSettings?.active_provider ?? null} />
586
757
  )}
587
758
  </div>
759
+ {reportBuildId && <ReportModal key={reportBuildId} buildId={reportBuildId} onClose={() => setReportBuildId(null)} />}
588
760
  </div>
589
761
  )
590
762
  }