evaporator 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 (90) hide show
  1. evaporator-0.2.0/LICENSE +202 -0
  2. evaporator-0.2.0/PKG-INFO +422 -0
  3. evaporator-0.2.0/README.md +395 -0
  4. evaporator-0.2.0/pyproject.toml +39 -0
  5. evaporator-0.2.0/setup.cfg +4 -0
  6. evaporator-0.2.0/src/evaporator/__init__.py +1 -0
  7. evaporator-0.2.0/src/evaporator/__main__.py +3 -0
  8. evaporator-0.2.0/src/evaporator/app/__init__.py +3 -0
  9. evaporator-0.2.0/src/evaporator/app/app.tcss +55 -0
  10. evaporator-0.2.0/src/evaporator/app/chat.py +618 -0
  11. evaporator-0.2.0/src/evaporator/app/chat_commands.py +263 -0
  12. evaporator-0.2.0/src/evaporator/app/chat_confirm.py +233 -0
  13. evaporator-0.2.0/src/evaporator/app/figures.py +81 -0
  14. evaporator-0.2.0/src/evaporator/app/main.py +616 -0
  15. evaporator-0.2.0/src/evaporator/app/onboarding.py +561 -0
  16. evaporator-0.2.0/src/evaporator/app/theme.py +40 -0
  17. evaporator-0.2.0/src/evaporator/app/widgets.py +334 -0
  18. evaporator-0.2.0/src/evaporator/callsites.py +106 -0
  19. evaporator-0.2.0/src/evaporator/capture.py +86 -0
  20. evaporator-0.2.0/src/evaporator/chat/__init__.py +1 -0
  21. evaporator-0.2.0/src/evaporator/chat/api_engine.py +202 -0
  22. evaporator-0.2.0/src/evaporator/chat/claude_engine.py +187 -0
  23. evaporator-0.2.0/src/evaporator/chat/codex_engine.py +169 -0
  24. evaporator-0.2.0/src/evaporator/chat/discover.py +211 -0
  25. evaporator-0.2.0/src/evaporator/chat/engine.py +47 -0
  26. evaporator-0.2.0/src/evaporator/chat/gate.py +78 -0
  27. evaporator-0.2.0/src/evaporator/cli.py +414 -0
  28. evaporator-0.2.0/src/evaporator/compile.py +513 -0
  29. evaporator-0.2.0/src/evaporator/connect.py +80 -0
  30. evaporator-0.2.0/src/evaporator/control.py +384 -0
  31. evaporator-0.2.0/src/evaporator/deid.py +174 -0
  32. evaporator-0.2.0/src/evaporator/extraction.py +273 -0
  33. evaporator-0.2.0/src/evaporator/graduate.py +255 -0
  34. evaporator-0.2.0/src/evaporator/guard.py +399 -0
  35. evaporator-0.2.0/src/evaporator/handoff.py +179 -0
  36. evaporator-0.2.0/src/evaporator/ingest/__init__.py +106 -0
  37. evaporator-0.2.0/src/evaporator/ingest/common.py +76 -0
  38. evaporator-0.2.0/src/evaporator/ingest/langfuse.py +61 -0
  39. evaporator-0.2.0/src/evaporator/ingest/mapping.py +42 -0
  40. evaporator-0.2.0/src/evaporator/ingest/providers.py +81 -0
  41. evaporator-0.2.0/src/evaporator/labels.py +45 -0
  42. evaporator-0.2.0/src/evaporator/llm/__init__.py +60 -0
  43. evaporator-0.2.0/src/evaporator/llm/anthropic_client.py +64 -0
  44. evaporator-0.2.0/src/evaporator/llm/openai_client.py +43 -0
  45. evaporator-0.2.0/src/evaporator/llm/subscriptions.py +313 -0
  46. evaporator-0.2.0/src/evaporator/mcp.py +364 -0
  47. evaporator-0.2.0/src/evaporator/ood.py +61 -0
  48. evaporator-0.2.0/src/evaporator/pr.py +89 -0
  49. evaporator-0.2.0/src/evaporator/pricing.py +61 -0
  50. evaporator-0.2.0/src/evaporator/program.py +180 -0
  51. evaporator-0.2.0/src/evaporator/runner.py +78 -0
  52. evaporator-0.2.0/src/evaporator/runner_main.py +67 -0
  53. evaporator-0.2.0/src/evaporator/scan.py +252 -0
  54. evaporator-0.2.0/src/evaporator/settings.py +196 -0
  55. evaporator-0.2.0/src/evaporator/skill/SKILL.md +46 -0
  56. evaporator-0.2.0/src/evaporator/stats.py +23 -0
  57. evaporator-0.2.0/src/evaporator/store.py +74 -0
  58. evaporator-0.2.0/src/evaporator/synth.py +225 -0
  59. evaporator-0.2.0/src/evaporator/trace.py +144 -0
  60. evaporator-0.2.0/src/evaporator/tui.py +314 -0
  61. evaporator-0.2.0/src/evaporator.egg-info/PKG-INFO +422 -0
  62. evaporator-0.2.0/src/evaporator.egg-info/SOURCES.txt +88 -0
  63. evaporator-0.2.0/src/evaporator.egg-info/dependency_links.txt +1 -0
  64. evaporator-0.2.0/src/evaporator.egg-info/entry_points.txt +2 -0
  65. evaporator-0.2.0/src/evaporator.egg-info/requires.txt +19 -0
  66. evaporator-0.2.0/src/evaporator.egg-info/top_level.txt +1 -0
  67. evaporator-0.2.0/tests/test_app_chat.py +1848 -0
  68. evaporator-0.2.0/tests/test_app_main.py +684 -0
  69. evaporator-0.2.0/tests/test_app_onboarding.py +376 -0
  70. evaporator-0.2.0/tests/test_capture.py +119 -0
  71. evaporator-0.2.0/tests/test_chat_api.py +229 -0
  72. evaporator-0.2.0/tests/test_chat_claude.py +346 -0
  73. evaporator-0.2.0/tests/test_chat_codex.py +233 -0
  74. evaporator-0.2.0/tests/test_chat_discover.py +208 -0
  75. evaporator-0.2.0/tests/test_chat_gate.py +167 -0
  76. evaporator-0.2.0/tests/test_cli_entry.py +172 -0
  77. evaporator-0.2.0/tests/test_connect.py +113 -0
  78. evaporator-0.2.0/tests/test_control.py +127 -0
  79. evaporator-0.2.0/tests/test_deid.py +69 -0
  80. evaporator-0.2.0/tests/test_e2e.py +155 -0
  81. evaporator-0.2.0/tests/test_extraction.py +174 -0
  82. evaporator-0.2.0/tests/test_graduate.py +50 -0
  83. evaporator-0.2.0/tests/test_guard.py +112 -0
  84. evaporator-0.2.0/tests/test_handoff.py +205 -0
  85. evaporator-0.2.0/tests/test_ingest.py +78 -0
  86. evaporator-0.2.0/tests/test_mcp.py +211 -0
  87. evaporator-0.2.0/tests/test_program.py +91 -0
  88. evaporator-0.2.0/tests/test_settings.py +241 -0
  89. evaporator-0.2.0/tests/test_subscriptions.py +309 -0
  90. evaporator-0.2.0/tests/test_tui.py +61 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,422 @@
1
+ Metadata-Version: 2.4
2
+ Name: evaporator
3
+ Version: 0.2.0
4
+ Summary: Turn the predictable parts of LLM traffic into ordinary code, with an abstention boundary and a runtime guard.
5
+ License: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/soummyaanon/evaporator
7
+ Project-URL: Repository, https://github.com/soummyaanon/evaporator
8
+ Project-URL: Issues, https://github.com/soummyaanon/evaporator/issues
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: typer>=0.12
13
+ Requires-Dist: rich>=13
14
+ Requires-Dist: textual>=8.2
15
+ Requires-Dist: anthropic>=1.0
16
+ Requires-Dist: openai>=1.0
17
+ Provides-Extra: anthropic
18
+ Provides-Extra: openai
19
+ Provides-Extra: presidio
20
+ Requires-Dist: presidio-analyzer>=2.2; extra == "presidio"
21
+ Provides-Extra: all
22
+ Requires-Dist: anthropic>=1.0; extra == "all"
23
+ Requires-Dist: openai>=1.0; extra == "all"
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ <div align="center">
29
+
30
+ # 💧 Evaporator
31
+
32
+ ### An AI application should need less AI over time.
33
+
34
+ Evaporator reads the logs of your high-volume LLM calls, writes ordinary code for the predictable part of that traffic, proves it on held-out data, and ships it to you as a pull request with a runtime guard. The model still handles everything the code isn't sure about.
35
+
36
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
37
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-3776AB.svg?logo=python&logoColor=white)](pyproject.toml)
38
+ [![Generated code: Python 3.8+, zero deps](https://img.shields.io/badge/generated%20code-py3.8%2B%20%C2%B7%20zero%20deps-2ea44f.svg)](#-the-runtime-guard)
39
+ [![Status: pre-release](https://img.shields.io/badge/status-pre--release-orange.svg)](#-status)
40
+
41
+ **Routers pick a cheaper model. Caches reuse old answers. Distillers train a smaller model.**<br>
42
+ **Evaporator removes the model call.**
43
+
44
+ [Quickstart](#-quickstart) · [Connect](#-connect) · [How it works](#%EF%B8%8F-how-it-works) · [Safety model](#-safety-model) · [Runtime guard](#-the-runtime-guard) · [Control plane](#-control-plane) · [Coding agents](#-use-it-from-a-coding-agent) · [Status](#-status)
45
+
46
+ </div>
47
+
48
+ ---
49
+
50
+ ## ✨ The whole product in one interaction
51
+
52
+ ```console
53
+ $ evaporator scan traces.jsonl --labels labels.csv
54
+ Loaded 20,000 calls from traces.jsonl across 1 call site(s); cost known for 100%, ground truth for 20,000.
55
+ Found 1 compilation candidate.
56
+
57
+ classify_ticket() 70.1% validated offline
58
+
59
+ classify_ticket()
60
+ Validated offline coverage 70.1%
61
+ Held-out examples 4,000
62
+ Accuracy vs ground truth 100.00%
63
+ LLM accuracy on same slice 98.61%
64
+ Rare-class errors 0
65
+ Rules graduated 4 of 6
66
+ outcome preserved on held-out test
67
+
68
+ $ evaporator compile classify_ticket --target app/tickets.py:classify_ticket
69
+ ✓ generated implementation evaporated/classify_ticket.py
70
+ ✓ generated abstention boundary evaporated/classify_ticket.envelope.json
71
+ ✓ generated tests tests/evaporated/test_classify_ticket.py (2,094 cases)
72
+ ✓ 20,000 historical cases replayed: 14,052 answered by code (100.00% correct), 5,948 left to the LLM, 0 rare-class errors
73
+ ✓ generated tests: 6 passed
74
+ ✓ GitHub PR opened
75
+ ```
76
+
77
+ <sub>Output from the bundled synthetic support-ticket dataset. Your numbers depend on your traffic, and finding them is the point of running <code>scan</code>.</sub>
78
+
79
+ What you get is a **pull request**: ordinary source code you review, own and merge. The diff at your call site is one line:
80
+
81
+ ```python
82
+ from evaporated.classify_ticket import evaporate
83
+
84
+ @evaporate # 70% of calls answered by code, the rest go to the LLM exactly as before
85
+ def classify_ticket(text):
86
+ return call_llm(text)
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 🧠 The core idea: compile + abstain
92
+
93
+ The code doesn't need to know everything. It needs to know two things very well: **what it can answer**, and **when it must abstain**. The second is the hard part, and it's what Evaporator is built around.
94
+
95
+ ```mermaid
96
+ flowchart LR
97
+ A[Input] --> B{Inside the validated<br/>envelope?}
98
+ B -- yes --> C[Compiled code]
99
+ B -- no --> D[Original LLM call]
100
+ C --> E[Result]
101
+ D --> E
102
+ C -. 1% shadow sample .-> D
103
+ ```
104
+
105
+ - **Partial coverage is success.** "68% runs as code, 32% still goes to the model" is the expected outcome, and abstaining isn't a failure.
106
+ - **Measure the real outcome, not agreement.** Code that copies the LLM's mistakes scores 99.99% agreement and proves nothing. When you supply ground truth, it's the bar. When you don't, the report says so, every time.
107
+ - **Report only what the evidence supports.** Rare or thinly observed regions stay on the LLM.
108
+ - **You own the code.** It's plain Python in your repo, with no black-box runtime.
109
+
110
+ ---
111
+
112
+ ## 🚀 Quickstart
113
+
114
+ ```bash
115
+ uvx evaporator # try it without installing (needs uv: https://docs.astral.sh/uv/)
116
+ ```
117
+
118
+ To keep it installed, pick one:
119
+
120
+ ```bash
121
+ uv tool install evaporator # recommended
122
+ pipx install evaporator
123
+ pip install evaporator # into an existing Python 3.11+ environment
124
+ uv tool install "git+https://github.com/soummyaanon/evaporator" # latest unreleased main
125
+ ```
126
+
127
+ Run `evaporator` in your project folder. It opens a chat with the prompt ready, finds your call logs and your AI connection by itself and says in one line what it found. Then type:
128
+
129
+ ```text
130
+ which of my AI calls can become code?
131
+ ```
132
+
133
+ You get each call site with its calls, its spend and a plain label: *looks like it can become code (not proven yet)*, *stays on the AI (open-ended)* or *too few calls*. The chat then offers to prove the top candidate on held-out calls, naming the model it will use. A scan, a compile and a pull request each run only after you say yes.
134
+
135
+ Slash commands in the same prompt:
136
+
137
+ | Command | |
138
+ |---|---|
139
+ | `/model` | Change the AI connection or model |
140
+ | `/logs` | Pick which call logs to use, or type a path |
141
+ | `/agent` | Open Claude Code, Codex or fx full-screen with Evaporator's tools |
142
+ | `/dashboard` | Leave the chat for the call-site dashboard |
143
+ | `/help` | List these commands |
144
+ | `/quit` | Leave (ctrl+q works too) |
145
+
146
+ Prefer the commands, or working from a clone?
147
+
148
+ ```bash
149
+ git clone https://github.com/soummyaanon/evaporator && cd evaporator
150
+ python3 -m venv .venv && source .venv/bin/activate
151
+ pip install -e '.[all]'
152
+
153
+ evaporator setup # connect a model once (see Connect below)
154
+ evaporator scan your-export.jsonl --list # profile call sites; no model calls, no cost
155
+ evaporator scan your-export.jsonl --labels truth.csv # synthesize + validate
156
+ evaporator compile <callsite> --target app/file.py:func # branch, tests, PR
157
+ ```
158
+
159
+ `evaporator setup` reruns the connection steps without opening the app. Without a terminal it prints how to configure through the environment instead.
160
+
161
+ In a terminal, `scan` and `report` draw the call site as a small isometric evaporator: the tank boils down to the share that still needs the LLM, and the steam that rises turns into code. Pipes and CI get plain text; set `EVAPORATOR_PLAIN=1` to force it.
162
+
163
+ **Supported log formats:** OpenAI and Anthropic request/response logs, Langfuse exports, Evaporator's native JSONL, and any JSONL or CSV through a small TOML field mapping:
164
+
165
+ ```toml
166
+ [fields]
167
+ id = "request_id"
168
+ timestamp = "created_at"
169
+ input = "payload.text"
170
+ output = "result.label"
171
+ ground_truth = "reviewed_label"
172
+ ```
173
+
174
+ ---
175
+
176
+ ## 🔌 Connect
177
+
178
+ Synthesis needs a model. The chat picks one automatically: the one you chose before, else a signed-in Claude Code, else a signed-in Codex, else a saved API key, else `ANTHROPIC_API_KEY` / `OPENAI_API_KEY`. The header always names the connection in use; `/model` changes it (as does `evaporator setup`). If nothing is found, the chat asks you to connect one:
179
+
180
+ - **Claude Code.** Uses the `claude` you already signed in to. Evaporator runs the binary and never reads its token store.
181
+ - **Codex.** The same, through your `codex` binary.
182
+ - **API key.** Anthropic, OpenAI, or any OpenAI-compatible gateway.
183
+
184
+ Subscription usage counts against your Claude or ChatGPT plan. Evaporator writes no chat transcript, but when the chat runs on Claude Code or Codex those tools keep their own session history, as they do for any use.
185
+
186
+ **Key precedence:** `--api-key-env` / `EVAPORATOR_API_KEY_ENV` beats a saved credential, which beats `ANTHROPIC_API_KEY` / `OPENAI_API_KEY`. Provider and model: flag, then `EVAPORATOR_*` environment, then your saved config, then the default.
187
+
188
+ **Where things live:**
189
+
190
+ | What | Where |
191
+ |---|---|
192
+ | Your provider and model | `~/.config/evaporator/config.toml` (honours `XDG_CONFIG_HOME`) |
193
+ | A saved API key | `~/.config/evaporator/credentials`, mode `600` |
194
+ | Per-project logs, labels and flags | `<project>/.evaporator/project.toml` (the project is the git root of where you run it) |
195
+
196
+ A key is never printed, logged or written anywhere else.
197
+
198
+ **Personal data.** Before the first scan in a project, and before Claude Code or Codex can otherwise reach it (Codex's first chat turn, `/agent`, `/dashboard`), the chat asks once whether the data contains patient or personal data, and saves the answer as `sensitive` in `project.toml`. Subscriptions are not BAA-covered, so on a sensitive project the chat warns once before it uses `claude-code` or `codex` ("Use anyway" or "Connect an API key"). "Use anyway" is saved as `allow_subscription = true` in `project.toml` and the header then shows "personal data · not BAA-covered"; "Connect an API key" ends that conversation and asks for a key on a BAA-covered endpoint. Until the warning is accepted (or you set `allow_subscription = true` yourself), the CLI, MCP and the dashboard refuse subscriptions on that project. (Changed on 2026-10-18, decided by the user: a sensitive project used to refuse subscriptions outright.)
199
+
200
+ **Nothing runs without your yes.** A scan runs only after you agree to it in the chat, with the model named. Writing a compile into a repository needs a yes naming the repository, and pushing or opening a pull request needs a second, separate yes.
201
+
202
+ ---
203
+
204
+ ## ⚙️ How it works
205
+
206
+ ```mermaid
207
+ flowchart TD
208
+ A[Exported LLM logs] --> B[Ingest + group by call site]
209
+ B --> C{Bounded output?}
210
+ C -- open-ended --> L[Stays on the LLM]
211
+ C -- labels or JSON fields --> D[Time-ordered split<br/>60 / 20 / 20]
212
+ D --> E[Synthesize rules<br/>from de-identified examples]
213
+ E --> F[Graduate each rule<br/>on validation evidence]
214
+ F -->|refine| E
215
+ F --> G[Score once on<br/>untouched test split]
216
+ G --> H[Compile: code + envelope<br/>+ guard + tests]
217
+ H --> I[Pull request]
218
+ I --> J[Runtime guard<br/>shadow · drift · revert]
219
+ J --> K[Control plane]
220
+ ```
221
+
222
+ | Step | What happens |
223
+ |---|---|
224
+ | **Ingest** | Groups calls by an explicit call-site tag or a fingerprint of the system prompt, and strips any prompt template every input shares. Cost comes from the logs or from token counts. |
225
+ | **Profile** | **Classification and routing** (at most 50 labels) and **extraction** (JSON with at most 30 fields) are candidates. Open-ended generation is out of scope. |
226
+ | **Synthesize** | Claude (default) or any OpenAI-compatible endpoint writes named `@rule("label")` functions or `@field("name")` extractors, refined over rounds of validation feedback. |
227
+ | **Graduate** | Each rule earns its place on its own: enough support, accuracy at the bar, a confidence lower bound, and zero rare-class errors. Rules that fail are dropped, and the rest are re-scored until the set is stable. |
228
+ | **Score once** | The surviving program is scored a single time on the time-ordered test split it has never seen. |
229
+ | **Compile** | Writes the code, envelope, a copy of the guard, and a replay test suite on a new branch through a temporary git worktree, so your checkout is never touched. It then opens the PR with the full evidence. |
230
+
231
+ ---
232
+
233
+ ## 🛡 Safety model
234
+
235
+ | Layer | Protects against |
236
+ |---|---|
237
+ | **Per-rule graduation.** At least `--min-support` calls, accuracy ≥ `--bar` (default 99.5%) or ≥ the LLM's own accuracy on that slice, and a 95% Wilson lower bound ≥ `--min-lower`. | Rules that look good on a handful of examples |
238
+ | **Rare-class rule.** Any error involving a label under 1% of traffic disqualifies the rule. | Fraud, escalations and rejections silently misrouted |
239
+ | **Out-of-distribution envelope.** Vocabulary, length and shape must match what was seen in training. | New input types, languages or document formats |
240
+ | **All-or-nothing extraction.** A call runs as code only if every field has a graduated answer. | Half-filled records |
241
+ | **Sandboxed synthesis.** Static validation, restricted builtins, an import allowlist, CPU/memory/file-descriptor limits, and an OS sandbox with no network or file writes. | LLM-written code doing anything but computing |
242
+ | **De-identification.** Regex covering names, DOB, MRN, IDs, contact details, addresses and dates, plus field-aware redaction and optional Presidio NER. Placeholders stay consistent across input and output. | PHI/PII reaching the synthesis model or your repo |
243
+ | **Runtime guard.** Shadow sampling, self-revert, drift alerts, and an instant revert switch. | Degradation after merge |
244
+
245
+ ---
246
+
247
+ ## 🪝 The runtime guard
248
+
249
+ The guard is stdlib-only and gets copied into your repo inside the PR, so there's nothing new to install.
250
+
251
+ - **Sync and `async def`**, including methods: `@evaporate(input_arg=1)`, with custom input extraction and output mapping.
252
+ - **Shadow sampling.** 1% of compiled answers are re-checked against the LLM in the background. Too many mismatches and the guard reverts itself.
253
+ - **Revert without a deploy.** `EVAPORATOR_REVERT=classify_ticket` (or `*`), a revert file, or one command through the control plane.
254
+ - **Drift detection.** It warns when the share of out-of-envelope inputs rises above what was seen offline.
255
+
256
+ ---
257
+
258
+ ## 📡 Control plane
259
+
260
+ ```bash
261
+ evaporator serve --token "$TOKEN" --slack-webhook "$SLACK_URL"
262
+ export EVAPORATOR_TELEMETRY_URL=http://control:8787/v1/telemetry EVAPORATOR_TELEMETRY_TOKEN="$TOKEN"
263
+
264
+ evaporator status # fleet view
265
+ evaporator revert classify_ticket --reason "incident" # every instance, at its next check-in
266
+ evaporator resume classify_ticket
267
+ ```
268
+
269
+ ```text
270
+ ┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┓
271
+ ┃ call site ┃ instances ┃ calls ┃ compiled ┃ shadow agree ┃ outside envelope ┃ saved ┃ state ┃
272
+ ┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━┩
273
+ │ classify_ticket │ 1/1 │ 100 │ 60.0% │ n/a │ 20.0% │ $0.05 │ ok │
274
+ └─────────────────┴───────────┴───────┴──────────┴──────────────┴──────────────────┴───────┴───────┘
275
+ ```
276
+
277
+ It's a stdlib HTTP server with SQLite storage.
278
+
279
+ - **Aggregation.** Combines telemetry from every instance and ignores out-of-order snapshots.
280
+ - **Alerts.** Sends drift and revert alerts to Slack or email, at most once an hour per call site and kind.
281
+ - **Auto-revert.** Reverts a call site fleet-wide when combined shadow mismatch since the last resume crosses the envelope's threshold.
282
+ - **New instances.** A new instance picks up an active revert at startup.
283
+
284
+ ---
285
+
286
+ ## 🤖 Use it from a coding agent
287
+
288
+ `evaporator mcp` is a stdio MCP server, so [fx](https://fx.sh), Claude Code, Cursor and other agents can ask Evaporator to do the work instead of hand-writing an unproven classifier. The agent gets four tools:
289
+
290
+ | Tool | What it does | Cost |
291
+ |---|---|---|
292
+ | `list_callsites` | Groups the logs by call site and says which ones can be compiled | Free, no model calls |
293
+ | `scan` | Synthesizes rules, graduates them and scores them once on held-out calls | Calls your synthesis model |
294
+ | `report` | Shows the evidence per rule and why rules were dropped | Free |
295
+ | `compile` | Writes code, envelope, guard and tests on a new branch; opens a PR only with `pr: true` | Free |
296
+
297
+ **Bring your own model.** Synthesis runs on your key, chosen when you start the server, never by the agent:
298
+
299
+ ```bash
300
+ # Anthropic (default)
301
+ export ANTHROPIC_API_KEY=...
302
+
303
+ # OpenAI, or any OpenAI-compatible gateway
304
+ export OPENAI_API_KEY=...
305
+ export EVAPORATOR_PROVIDER=openai EVAPORATOR_MODEL=<model> # EVAPORATOR_BASE_URL=<gateway> optional
306
+ ```
307
+
308
+ The same `EVAPORATOR_*` variables work for `evaporator scan`. The agent can't change the model, the endpoint, the thresholds or de-identification, and it can't score its own rules against the test split. Those switches exist only on the CLI.
309
+
310
+ **fx:** add the server and the skill:
311
+
312
+ ```text
313
+ /mcp add evaporator evaporator mcp
314
+ /skills install soummyaanon/evaporator --skill evaporator
315
+ ```
316
+
317
+ A scan takes minutes, longer than fx's default 60-second MCP timeout, so raise it in `~/.fx/mcp.json`:
318
+
319
+ ```json
320
+ {
321
+ "mcp": {
322
+ "evaporator": {
323
+ "type": "local",
324
+ "command": ["evaporator", "mcp"],
325
+ "environment": { "EVAPORATOR_PROVIDER": "openai", "EVAPORATOR_MODEL": "<model>" },
326
+ "operation_timeout_ms": 1800000
327
+ }
328
+ }
329
+ }
330
+ ```
331
+
332
+ **Claude Code:** `claude mcp add evaporator -- evaporator mcp`, and copy `skills/evaporator` into `.claude/skills/`.
333
+
334
+ Then ask: *"Find the LLM calls in logs/traces.jsonl that should be code."*
335
+
336
+ ---
337
+
338
+ ## 🧭 Where it fits
339
+
340
+ | | What it does | After adopting it |
341
+ |---|---|---|
342
+ | Routers and gateways | Pick a cheaper model | Still inference |
343
+ | Semantic caches | Reuse answers to near-duplicate queries | Still inference on anything new |
344
+ | Distillation | Train a smaller specialist model | Still inference |
345
+ | **Evaporator** | **Replace a measured share of calls with reviewed code** | **Zero inference on that share** |
346
+
347
+ **In scope:** classification, routing, normalization, validation and structured extraction, meaning functions where a correct output can be stated and checked mechanically.<br>
348
+ **Out of scope:** open-ended generation, conversational replies, multi-step agents, and judgment-heavy decisions.
349
+
350
+ ---
351
+
352
+ ## 🔐 Configuration reference
353
+
354
+ <details>
355
+ <summary><b>scan</b></summary>
356
+
357
+ | Flag | Default | |
358
+ |---|---|---|
359
+ | `--labels FILE` | none | CSV or JSONL with `id,label` ground truth |
360
+ | `--list` | off | Profile call sites only; no model calls |
361
+ | `--program rules.py` | none | Evaluate an existing rules file; no model calls |
362
+ | `--provider` / `--model` / `--base-url` | `anthropic` / `claude-opus-5` | Any OpenAI-compatible endpoint, gateway or BAA deployment |
363
+ | `--bar` / `--min-support` / `--min-lower` | `0.995` / `30` / `0.95` | Graduation criteria |
364
+ | `--rare-share` | `0.01` | Labels under this share count as rare |
365
+ | `--deid-backend` | `regex` | `presidio` for NER: `pip install -e '.[presidio]' && python -m spacy download en_core_web_lg` |
366
+ | `--no-deid` | off | Send raw inputs to the synthesis model |
367
+
368
+ </details>
369
+
370
+ <details>
371
+ <summary><b>compile</b></summary>
372
+
373
+ | Flag | Default | |
374
+ |---|---|---|
375
+ | `--target file.py:func` | none | Add `@evaporate` to the call site (functions, methods, async) |
376
+ | `--pr / --no-pr` | `--pr` | Push the branch and open a GitHub PR through `gh` |
377
+ | `--no-commit` | off | Write files into the working tree only |
378
+ | `--include-abstained` | off | Also write inputs the code abstains on into the repo test file |
379
+ | `--raw-cases` | off | Skip redaction of the repo test cases |
380
+ | `--force` | off | Compile even if the held-out test failed |
381
+
382
+ </details>
383
+
384
+ <details>
385
+ <summary><b>Runtime environment variables</b></summary>
386
+
387
+ | Variable | |
388
+ |---|---|
389
+ | `EVAPORATOR_REVERT` | Comma-separated call sites (or `*`) to send back to the LLM |
390
+ | `EVAPORATOR_REVERT_FILE` | File listing call sites to revert |
391
+ | `EVAPORATOR_SHADOW_RATE` | Override the shadow sampling rate (default `0.01`) |
392
+ | `EVAPORATOR_TELEMETRY_URL` / `_TOKEN` / `_INTERVAL` | Control-plane reporting |
393
+
394
+ </details>
395
+
396
+ ---
397
+
398
+ ## 📍 Status
399
+
400
+ **Pre-release.** The CLI, guard and control plane are built and covered by 59 tests, including end-to-end scan → compile → run.
401
+
402
+ It **has not yet been validated on real production traffic**. The number that decides whether this is worth doing is *what share of real inference dollars can be removed without degrading the measured outcome*, and producing it is the first milestone:
403
+
404
+ - [x] Scan, compile, PR, runtime guard, control plane
405
+ - [x] Classification, routing and structured extraction
406
+ - [x] Sandboxed synthesis and PHI de-identification
407
+ - [ ] Phase 0: measured results on three real call sites
408
+ - [ ] First design-partner PR merged, savings verified over 30 days
409
+ - [ ] TypeScript guard, GitLab/Bitbucket
410
+
411
+ ---
412
+
413
+ ## 🛠 Development
414
+
415
+ ```bash
416
+ pip install -e '.[all,dev]'
417
+ pytest
418
+ ```
419
+
420
+ <div align="center">
421
+ <sub>Licensed under <a href="LICENSE">Apache-2.0</a>.</sub>
422
+ </div>