poordjaevin 0.1.1__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 (73) hide show
  1. poordjaevin-0.1.1/.github/workflows/publish.yml +19 -0
  2. poordjaevin-0.1.1/.github/workflows/scorecard.yml +38 -0
  3. poordjaevin-0.1.1/.github/workflows/tests.yml +17 -0
  4. poordjaevin-0.1.1/.gitignore +17 -0
  5. poordjaevin-0.1.1/CHANGELOG.md +30 -0
  6. poordjaevin-0.1.1/CITATION.cff +12 -0
  7. poordjaevin-0.1.1/CLAUDE.md +61 -0
  8. poordjaevin-0.1.1/LICENSE +21 -0
  9. poordjaevin-0.1.1/PKG-INFO +403 -0
  10. poordjaevin-0.1.1/PRD.md +271 -0
  11. poordjaevin-0.1.1/README.corporate-windows.md +32 -0
  12. poordjaevin-0.1.1/README.linux.md +32 -0
  13. poordjaevin-0.1.1/README.md +365 -0
  14. poordjaevin-0.1.1/README.windows.md +32 -0
  15. poordjaevin-0.1.1/RESULTS.md +84 -0
  16. poordjaevin-0.1.1/assets/banner.svg +23 -0
  17. poordjaevin-0.1.1/calibration.json +7 -0
  18. poordjaevin-0.1.1/crossbench/README.md +90 -0
  19. poordjaevin-0.1.1/crossbench/banking77_harness.py +186 -0
  20. poordjaevin-0.1.1/crossbench/data/banking77_labels.json +79 -0
  21. poordjaevin-0.1.1/crossbench/data/banking77_sample.jsonl +154 -0
  22. poordjaevin-0.1.1/crossbench/data/build_banking77.py +51 -0
  23. poordjaevin-0.1.1/crossbench/plot_comparison.py +58 -0
  24. poordjaevin-0.1.1/crossbench/results/banking77_jev_results.json +14 -0
  25. poordjaevin-0.1.1/crossbench/results/banking77_laya_results.json +14 -0
  26. poordjaevin-0.1.1/crossbench/results/banking77_poorjev_recalibrated.json +17 -0
  27. poordjaevin-0.1.1/crossbench/results/banking77_poorjev_results.json +14 -0
  28. poordjaevin-0.1.1/crossbench/results/banking77_von_results.json +14 -0
  29. poordjaevin-0.1.1/crossbench/results/typed_decisions_jev_results.json +9 -0
  30. poordjaevin-0.1.1/crossbench/results/typed_decisions_laya_results.json +37 -0
  31. poordjaevin-0.1.1/crossbench/results/typed_decisions_poordjaevin_results.json +5 -0
  32. poordjaevin-0.1.1/crossbench/results/typed_decisions_von_results.json +9 -0
  33. poordjaevin-0.1.1/crossbench/typed_decisions_harness.py +155 -0
  34. poordjaevin-0.1.1/crossbench/typesafe_client.py +53 -0
  35. poordjaevin-0.1.1/docs/reliability_before_after.png +0 -0
  36. poordjaevin-0.1.1/docs/reliability_raw.png +0 -0
  37. poordjaevin-0.1.1/docs/risk_coverage.png +0 -0
  38. poordjaevin-0.1.1/docs/vs_field_benchmark.png +0 -0
  39. poordjaevin-0.1.1/evalset/README.md +43 -0
  40. poordjaevin-0.1.1/evalset/source.py +170 -0
  41. poordjaevin-0.1.1/evalset/tasks.jsonl +55 -0
  42. poordjaevin-0.1.1/examples/demo.py +60 -0
  43. poordjaevin-0.1.1/examples/ticket_router.py +40 -0
  44. poordjaevin-0.1.1/examples/tool_gate.py +53 -0
  45. poordjaevin-0.1.1/llms.txt +32 -0
  46. poordjaevin-0.1.1/pyproject.toml +49 -0
  47. poordjaevin-0.1.1/server.json +26 -0
  48. poordjaevin-0.1.1/src/poordjaevin/__init__.py +51 -0
  49. poordjaevin-0.1.1/src/poordjaevin/backends/__init__.py +4 -0
  50. poordjaevin-0.1.1/src/poordjaevin/backends/acp_devin.py +241 -0
  51. poordjaevin-0.1.1/src/poordjaevin/backends/local_nli.py +110 -0
  52. poordjaevin-0.1.1/src/poordjaevin/calibration.py +164 -0
  53. poordjaevin-0.1.1/src/poordjaevin/cli.py +184 -0
  54. poordjaevin-0.1.1/src/poordjaevin/client.py +106 -0
  55. poordjaevin-0.1.1/src/poordjaevin/djaevin_log.py +233 -0
  56. poordjaevin-0.1.1/src/poordjaevin/evaluate.py +95 -0
  57. poordjaevin-0.1.1/src/poordjaevin/mcp_server.py +555 -0
  58. poordjaevin-0.1.1/src/poordjaevin/metrics.py +137 -0
  59. poordjaevin-0.1.1/src/poordjaevin/plots.py +119 -0
  60. poordjaevin-0.1.1/src/poordjaevin/primitives.py +280 -0
  61. poordjaevin-0.1.1/src/poordjaevin/scripts/djaevin-acp-bridge.mjs +307 -0
  62. poordjaevin-0.1.1/src/poordjaevin/verdicts.py +59 -0
  63. poordjaevin-0.1.1/tests/fixtures/fake_acp_bridge.mjs +31 -0
  64. poordjaevin-0.1.1/tests/fixtures/fake_devin_cli.mjs +40 -0
  65. poordjaevin-0.1.1/tests/test_acp_backend.py +144 -0
  66. poordjaevin-0.1.1/tests/test_calibration.py +89 -0
  67. poordjaevin-0.1.1/tests/test_client.py +112 -0
  68. poordjaevin-0.1.1/tests/test_djaevin_log.py +139 -0
  69. poordjaevin-0.1.1/tests/test_evaluate.py +86 -0
  70. poordjaevin-0.1.1/tests/test_mcp.py +82 -0
  71. poordjaevin-0.1.1/tests/test_metrics.py +77 -0
  72. poordjaevin-0.1.1/tests/test_primitives.py +210 -0
  73. poordjaevin-0.1.1/tests/test_verdicts.py +44 -0
@@ -0,0 +1,19 @@
1
+ name: publish
2
+
3
+ # Builds the package and publishes to PyPI via the reusable workflow in
4
+ # devin-powerups. Requires repo secret PYPI_API_TOKEN.
5
+ # Triggers: publishing a GitHub Release, or manual Actions dispatch.
6
+
7
+ on:
8
+ release:
9
+ types: [published]
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ publish:
14
+ permissions:
15
+ contents: read
16
+ id-token: write # passed through to the reusable job for OIDC
17
+ uses: Icaro0310/devin-powerups/.github/workflows/pypi-publish.yml@main
18
+ secrets:
19
+ PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,38 @@
1
+ name: OpenSSF Scorecard
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ schedule:
7
+ - cron: "30 1 * * 6"
8
+ workflow_dispatch:
9
+
10
+ permissions: read-all
11
+
12
+ jobs:
13
+ analysis:
14
+ name: Scorecard analysis
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ security-events: write
18
+ id-token: write
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ with:
22
+ persist-credentials: false
23
+ - name: Run analysis
24
+ uses: ossf/scorecard-action@v2.4.1
25
+ with:
26
+ results_file: results.sarif
27
+ results_format: sarif
28
+ publish_results: true
29
+ - name: Upload artifact
30
+ uses: actions/upload-artifact@v4
31
+ with:
32
+ name: SARIF file
33
+ path: results.sarif
34
+ retention-days: 5
35
+ - name: Upload to code-scanning
36
+ uses: github/codeql-action/upload-sarif@v3
37
+ with:
38
+ sarif_file: results.sarif
@@ -0,0 +1,17 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - run: pip install -e ".[dev]"
17
+ - run: pytest -q
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .eggs/
5
+ build/
6
+ dist/
7
+ .pytest_cache/
8
+ .coverage
9
+ htmlcov/
10
+ .venv/
11
+ venv/
12
+ env/
13
+ .DS_Store
14
+ *.png
15
+ !docs/*.png
16
+ models/
17
+ .hf_cache/
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-10-03
9
+
10
+ ### Added
11
+
12
+ - Initial public release of poordjaevin, an open source local-first
13
+ decision layer for LLM apps: typed `Choice` / `Score` / `Noul` questions
14
+ answered in one pass with calibrated confidence.
15
+ - Calibrated decision layer: temperature scaling fit by k-fold CV plus
16
+ conformal abstention. On the shipped eval set it cuts calibration error
17
+ (ECE) from 0.170 to 0.071 with zero loss of accuracy.
18
+ - Devin ACP backend as the default: `poordjaevin serve` scores through the
19
+ model your Devin CLI already uses, with automatic model rotation and
20
+ per-call cost telemetry. No extra model download, no Ollama, no API key
21
+ beyond Devin's own credentials. The keyless offline NLI backend remains
22
+ as `POORDJAEVIN_BACKEND=nli`.
23
+ - MCP server mode (`poordjaevin serve`, stdio): exposes gate, judge,
24
+ classify, rate and decide tools so Devin or any MCP client can make
25
+ fast, calibrated decisions; `server.json` manifest for the MCP registry.
26
+ - Hand-labelled eval set (`evalset/tasks.jsonl`), stdlib-only metrics
27
+ (accuracy, ECE, Brier, risk-coverage) and reliability diagrams via
28
+ `poordjaevin eval` and `poordjaevin calibrate`.
29
+ - CLI: `poordjaevin eval | calibrate | ask | serve`. PyPI publish workflow
30
+ shared via the ecosystem's reusable `pypi-publish.yml`.
@@ -0,0 +1,12 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it as below."
3
+ type: software
4
+ title: poordjaevin
5
+ authors:
6
+ - family-names: Galvao
7
+ given-names: Icaro
8
+ url: "https://github.com/Icaro0310/poordjaevin"
9
+ repository-code: "https://github.com/Icaro0310/poordjaevin"
10
+ license: MIT
11
+ abstract: "A local-first typed decision layer with provably calibrated confidence: Choice/Score/Noul primitives, an offline NLI backend, a Devin ACP backend, and an MCP server mode."
12
+ keywords: [calibration, decision-making, llm, mcp-server, nli, structured-output]
@@ -0,0 +1,61 @@
1
+ # CLAUDE.md
2
+
3
+ Guidance for Claude Code (and any agent) working in this repo.
4
+
5
+ ## What poordjaevin is
6
+
7
+ An open source, local-first "System One" decision layer: ask typed questions
8
+ about some state (Choice / Score / Noul), get typed answers with **calibrated**
9
+ confidence, in one pass, no API key by default. The differentiator is honest,
10
+ measured calibration. See `PRD.md` for the full spec and `README.md` for the pitch.
11
+
12
+ ## Architecture (read in this order)
13
+
14
+ - `src/poordjaevin/primitives.py` — the contract. `Choice` / `Score` / `Noul` and
15
+ their frozen typed answers. Schema validity is **structural**: a decided
16
+ answer's `value` is always in the declared set, even for adversarial scores.
17
+ - `src/poordjaevin/client.py` — `Client.ask(state, questions)`. Builds one batched
18
+ set of (state, hypothesis) pairs across all questions, calls the backend once,
19
+ applies the fitted `temperature`, and decides. Backends are a Protocol.
20
+ - `src/poordjaevin/backends/local_nli.py` — default keyless backend. A zero-shot NLI
21
+ model scores each hypothesis for entailment. Lazy torch/transformers import.
22
+ - `src/poordjaevin/calibration.py` — the moat. Temperature scaling (fit by k-fold
23
+ CV) + conformal abstention.
24
+ - `src/poordjaevin/metrics.py` — accuracy, ECE, Brier, risk-coverage (stdlib only).
25
+ - `src/poordjaevin/evaluate.py` — run the eval set through a backend, score vs gold.
26
+ - `src/poordjaevin/plots.py` — reliability diagram + risk-coverage plot.
27
+ - `src/poordjaevin/mcp_server.py` — expose poordjaevin as MCP tools (gate/judge/classify/
28
+ rate/decide). Logic is in plain `do_*` functions; MCP wrappers are thin.
29
+ - `src/poordjaevin/cli.py` — `poordjaevin eval | calibrate | ask | serve`.
30
+ - `evalset/source.py` -> `evalset/tasks.jsonl` — hand-labelled data.
31
+
32
+ ## Commands
33
+
34
+ ```bash
35
+ pip install -e ".[local,plots,mcp,dev]" # full dev install
36
+ pytest -q # fast suite, no model, no key
37
+ poordjaevin eval --set evalset/tasks.jsonl # accuracy + ECE (downloads model)
38
+ poordjaevin calibrate --set evalset/tasks.jsonl --plots # before/after ECE + diagrams
39
+ poordjaevin serve # run the MCP server (stdio)
40
+ python evalset/source.py # regenerate tasks.jsonl
41
+ ```
42
+
43
+ ## Conventions
44
+
45
+ - **Tests never need a model or a key.** Unit tests use a fake/scripted backend.
46
+ Anything that loads the real model is an example or a manual run, not a test.
47
+ - **Honesty is the product.** Every headline number must be reproducible by
48
+ `poordjaevin eval` / `poordjaevin calibrate` on the shipped set. No cherry-picking. If
49
+ a number is bad, print it. Keep the honest-limitations sections truthful.
50
+ - **No em-dashes in README / marketing copy.** Use commas, colons, short
51
+ sentences. (Source code and this file are exempt.)
52
+ - **Ask concrete questions.** The local NLI model handles "this moves money"
53
+ well and "this is dangerous" poorly. Prefer concrete hypotheses; decompose
54
+ abstract ones and apply a rule.
55
+ - **Commits:** author as the repo owner only; do not add co-author trailers.
56
+
57
+ ## Good first contributions
58
+
59
+ - More labelled decision tasks in `evalset/` (raises the eval's credibility).
60
+ - Per-question temperature in `calibration.py` (likely lowers ECE further).
61
+ - A new backend implementing `entail_probs(pairs)` (e.g. the optional LLM one).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rupesh Poojary
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,403 @@
1
+ Metadata-Version: 2.5
2
+ Name: poordjaevin
3
+ Version: 0.1.1
4
+ Summary: A local-first typed decision layer with calibrated confidence, including an optional Devin ACP backend.
5
+ Project-URL: Source, https://github.com/Icaro0310/poordjaevin
6
+ Project-URL: Upstream, https://github.com/rupeshpoojary9/poorjev
7
+ Author: Icaro0310
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: calibration,classification,conformal-prediction,guardrails,llm,mcp,structured-output,system-one,zero-shot
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.10
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
23
+ Requires-Dist: pytest>=8.0; extra == 'dev'
24
+ Provides-Extra: llm
25
+ Requires-Dist: anthropic>=0.40; extra == 'llm'
26
+ Requires-Dist: openai>=1.40; extra == 'llm'
27
+ Provides-Extra: local
28
+ Requires-Dist: protobuf>=4.0; extra == 'local'
29
+ Requires-Dist: sentencepiece>=0.2; extra == 'local'
30
+ Requires-Dist: torch>=2.2; extra == 'local'
31
+ Requires-Dist: transformers>=4.40; extra == 'local'
32
+ Provides-Extra: mcp
33
+ Requires-Dist: mcp>=1.2; extra == 'mcp'
34
+ Provides-Extra: plots
35
+ Requires-Dist: matplotlib>=3.8; extra == 'plots'
36
+ Requires-Dist: numpy>=1.26; extra == 'plots'
37
+ Description-Content-Type: text/markdown
38
+
39
+ <div align="center">
40
+
41
+ <img src="assets/banner.svg" alt="poordjaevin" width="100%"/>
42
+
43
+ <a href="https://github.com/Icaro0310/poordjaevin/actions/workflows/tests.yml"><img src="https://github.com/Icaro0310/poordjaevin/actions/workflows/tests.yml/badge.svg" alt="tests"/></a>
44
+
45
+
46
+ <a href="https://scorecard.dev/viewer/?uri=github.com/Icaro0310/poordjaevin"><img src="https://api.scorecard.dev/projects/github.com/Icaro0310/poordjaevin/badge" alt="OpenSSF Scorecard"/></a>
47
+ <a href="https://github.com/Icaro0310/poordjaevin"><img src="https://img.shields.io/github/stars/Icaro0310/poordjaevin" alt="GitHub stars"/></a>
48
+ <a href="https://github.com/Icaro0310/poordjaevin/commits/main"><img src="https://img.shields.io/github/last-commit/Icaro0310/poordjaevin" alt="Last commit"/></a>
49
+ <a href="https://github.com/Icaro0310/awesome-devin"><img src="https://img.shields.io/badge/part%20of-devin--*-ecosystem-7c3aed" alt="devin-* ecosystem"/></a>
50
+ <a href="https://github.com/Icaro0310/poordjaevin/issues"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen" alt="PRs welcome"/></a>
51
+ </div>
52
+
53
+ <h1 align="center">poordjaevin</h1>
54
+
55
+ <p align="center"><b>The poor man's Jev.</b> An open source, local-first "System One" decision layer for LLM apps: typed decisions with <b>provably calibrated confidence</b>. No API key. No waitlist.</p>
56
+
57
+ <p align="center">
58
+ <img src="https://img.shields.io/badge/license-MIT-green" alt="MIT license">
59
+ <img src="https://img.shields.io/badge/python-3.10%2B-blue" alt="Python 3.10+">
60
+ <img src="https://img.shields.io/badge/ECE-0.170%20%E2%86%92%200.071-orange" alt="ECE 0.170 to 0.071">
61
+ <img src="https://img.shields.io/badge/API%20key-not%20required-blueviolet" alt="no API key required">
62
+ </p>
63
+
64
+ <p align="center"><sub>Community project. Not affiliated with, endorsed by, or sponsored by Cognition AI. "Devin" is a trademark of Cognition AI.</sub></p>
65
+
66
+ **[Linux](README.linux.md)** · **[Personal Windows](README.windows.md)** · **[Corporate Windows](README.corporate-windows.md)**
67
+
68
+ Part of the [awesome-devin](https://github.com/Icaro0310/awesome-devin) ecosystem: the curated hub for the devin-* tools.
69
+
70
+ > **Fork note:** this is the Devin-ecosystem fork of
71
+ > [rupeshpoojary9/poordjaevin](https://github.com/rupeshpoojary9/poordjaevin).
72
+ > It adds a **Devin ACP backend**: `poordjaevin serve` scores through the model
73
+ > your Devin CLI already uses, with automatic model rotation and per-call cost
74
+ > telemetry, so Devin users need no extra model download, no Ollama, no VM, and
75
+ > no API key beyond Devin's own credentials. The original keyless local backend
76
+ > remains as the fully offline fallback (`POORDJAEVIN_BACKEND=nli`).
77
+
78
+ ---
79
+
80
+ **Your model's `0.9` is a vibe. poordjaevin's `0.9` is a measurement.**
81
+
82
+ Every LLM-in-JSON-mode hands you a confidence score and hopes you don't check it. poordjaevin checks it. On the shipped eval set it cuts calibration error (ECE) from **0.170 to 0.071** with zero loss of accuracy, and it runs on your laptop with no API key.
83
+
84
+ <p align="center">
85
+ <img src="https://raw.githubusercontent.com/Icaro0310/poordjaevin/main/docs/reliability_before_after.png" alt="Reliability diagram: raw confidences are overconfident, calibrated confidences hug the diagonal" width="760">
86
+ </p>
87
+
88
+ <p align="center"><i>Left: raw confidences, overconfident. Right: calibrated, a stated 0.8 really is right about 80% of the time.</i></p>
89
+
90
+ ## Quickstart
91
+
92
+ Not on PyPI yet. Install from GitHub:
93
+
94
+ ```bash
95
+ # Linux / macOS
96
+ pip install "poordjaevin[local] @ git+https://github.com/Icaro0310/poordjaevin.git"
97
+ ```
98
+
99
+ ```powershell
100
+ # Windows (PowerShell)
101
+ py -m pip install "poordjaevin[local] @ git+https://github.com/Icaro0310/poordjaevin.git"
102
+ ```
103
+
104
+ `[local]` pulls torch + transformers for the offline NLI backend. If you only
105
+ plan to use the Devin ACP backend (`poordjaevin serve` default), a plain
106
+ `pip install "poordjaevin @ git+https://github.com/Icaro0310/poordjaevin.git"`
107
+ is enough.
108
+
109
+ ```python
110
+ from poordjaevin import Client, Choice, Score, Noul
111
+
112
+ client = Client() # local model, no key, offline after one download
113
+
114
+ result = client.ask(
115
+ state="I've emailed three times and I'm STILL being double-charged. Cancel my account today.",
116
+ questions={
117
+ "topic": Choice(["billing", "technical", "account", "shipping", "other"]),
118
+ "frustration": Score(levels=["low", "medium", "high"]),
119
+ "is_urgent": Noul("The customer needs a response today."),
120
+ "wants_cancel": Noul("The customer wants to cancel their account."),
121
+ },
122
+ )
123
+
124
+ result["topic"].value # "billing" always one of your options, by construction
125
+ result["topic"].confidence # 0.86 calibrated, not a vibe
126
+ result["frustration"].value # "high"
127
+ result["is_urgent"].value # True
128
+ result["wants_cancel"].value # True
129
+ ```
130
+
131
+ One call, one model pass, four typed answers. No prompt engineering, no JSON parsing, no "the model returned prose."
132
+
133
+ ## Use it with Devin (MCP server, Devin-only)
134
+
135
+ <!-- mcp-name: io.github.Icaro0310/poordjaevin -->
136
+
137
+ poordjaevin ships an MCP server, so Devin (or any MCP client) can make fast,
138
+ calibrated decisions as tools. The obvious use: gate a risky tool call before
139
+ the agent runs it.
140
+
141
+ **This mode needs nothing but Devin.** The default backend (`acp`) talks to
142
+ `devin acp` through a small packaged Node bridge, so every decision is scored
143
+ by the model your Devin plan already provides, with automatic model rotation.
144
+ No Ollama, no VM, no tunnel, no second API key: the bridge reads the same
145
+ `credentials.toml` the Devin CLI uses.
146
+
147
+ ```bash
148
+ # Devin users: no local model needed
149
+ pipx install "poordjaevin[mcp] @ git+https://github.com/Icaro0310/poordjaevin.git"
150
+ ```
151
+
152
+ Add it to your Devin MCP configuration:
153
+
154
+ ```json
155
+ {
156
+ "mcpServers": {
157
+ "poordjaevin": { "command": "poordjaevin", "args": ["serve"] }
158
+ }
159
+ }
160
+ ```
161
+
162
+ Requirements for the ACP backend: the `devin` CLI on PATH (or `DEVIN_CLI_PATH`),
163
+ Node.js >= 18 on PATH, and valid Devin credentials at
164
+ `%APPDATA%\devin\credentials.toml` (Windows) or
165
+ `~/.local/share/devin/credentials.toml` (Linux, override with
166
+ `DEVIN_CREDENTIALS_PATH`).
167
+
168
+ Backend selection and tuning, all optional:
169
+
170
+ | Variable | Default | Meaning |
171
+ |---|---|---|
172
+ | `POORDJAEVIN_BACKEND` | `acp` | `acp` = Devin's model via ACP, `nli` = fully offline local model |
173
+ | `POORDJAEVIN_ACP_MODEL` | auto | pin a specific Devin model instead of automatic rotation |
174
+ | `POORDJAEVIN_ACP_TIMEOUT` | `120` | seconds per decision round trip |
175
+ | `POORDJAEVIN_ACP_MAX_COST` | unset | fail closed when cumulative ACP cost exceeds this budget |
176
+ | `POORDJAEVIN_ABSTAIN` | `off` | `on` = abstain below the calibrated threshold instead of answering |
177
+
178
+ Honesty note: with `acp` the confidence is `self_report` (the model's own
179
+ stated probability, temperature-adjusted), not NLI logprobs. Every tool
180
+ response carries a `confidence_source` field so callers never mistake one for
181
+ the other, and `model`/`cost` are logged per call for quota monitoring.
182
+
183
+ No Devin on the machine? Use the offline path:
184
+
185
+ ```bash
186
+ pipx install "poordjaevin[local,mcp] @ git+https://github.com/Icaro0310/poordjaevin.git"
187
+ POORDJAEVIN_BACKEND=nli poordjaevin serve # ~400MB one-time model download, then offline
188
+ ```
189
+
190
+ The server also works with Claude Code/Desktop (`claude mcp add poordjaevin --
191
+ poordjaevin serve`), same JSON config shape.
192
+
193
+ The agent then has these local tools:
194
+
195
+ | Tool | What it does |
196
+ |---|---|
197
+ | `gate(action)` | guardrail: should this action be blocked (moves money, deletes data)? |
198
+ | `judge(text, statement)` | a yes/no question, with calibrated `P(true)` |
199
+ | `classify(text, options)` | pick one option, with calibrated confidence |
200
+ | `rate(text, levels)` | an ordinal score (low / medium / high) |
201
+ | `decide(text, questions)` | several typed questions at once, one pass |
202
+
203
+ Why this beats asking an LLM to judge: it is local (private), free (no tokens),
204
+ fast, and the confidence is calibrated instead of made up.
205
+
206
+ ## Why poordjaevin exists
207
+
208
+ Most production AI work is not chat. It is fast structured decisions: **route** a ticket, **classify** an intent, **score** a sentiment, **extract** a field, **gate** a tool call. TypeSafe's **Jev** named this category ("System One" models) and nailed the thesis — and, per the independent [cross-system benchmark](crossbench/) below, it currently backs its calibration claims up: it's the strongest model measured here. It's also closed, hosted, and behind a waitlist.
209
+
210
+ poordjaevin exists for the deployments where "call a hosted API" isn't the answer: private data, offline environments, zero marginal cost, no waitlist. It reproduces Jev's typed-decision interface on a small local model and proves its **own** calibration honestly (5-fold cross-validated, never graded on what it was fit on). Against the other open local alternatives it leads on the mixed decision-primitive benchmark below, but not on the high-cardinality one — see the real breakdown. It does not beat Jev. That's the honest trade for fully local and free.
211
+
212
+ ## poordjaevin vs the field
213
+
214
+ Independently measured, not self-reported — see [`crossbench/`](crossbench/) for the full harness, data, and every raw result file.
215
+
216
+ <p align="center">
217
+ <img src="https://raw.githubusercontent.com/Icaro0310/poordjaevin/main/docs/vs_field_benchmark.png" alt="Bar chart comparing poordjaevin, Jev, von, and Laya on accuracy and ECE across Banking77 and the multi-primitive set. Jev leads the multi-primitive set on both metrics; von leads Banking77 on both accuracy and calibration among the open options; poordjaevin leads the open options on the multi-primitive set only." width="760">
218
+ </p>
219
+
220
+ <p align="center"><i>poordjaevin in red. Chart regenerates from <code>crossbench/results/</code> via <code>crossbench/plot_comparison.py</code> — same numbers as the table below.</i></p>
221
+
222
+ | | **Jev** (TypeSafe) | **von** | **Laya** | **poordjaevin** |
223
+ |---|---|---|---|---|
224
+ | Interface (typed questions, one pass) | yes | yes | yes | yes |
225
+ | Runs locally, no API key | no | yes | yes | **yes** |
226
+ | Your data stays in your environment | no | yes | yes | **yes** |
227
+ | Waitlist / signup | yes | no | no | **no** |
228
+ | Open source | no | yes (Apache-2.0) | yes (Apache-2.0) | **yes (MIT)** |
229
+ | Accuracy, Banking77 (77-way, n=154) | 0.812 | **0.838** | 0.519 | 0.656 |
230
+ | ECE, Banking77 (lower better) | **0.084** | 0.135 | 0.388 | 0.414 |
231
+ | Accuracy, multi-primitive set (n=160) | **0.906** | 0.775 | 0.775 | 0.781 |
232
+ | ECE, multi-primitive set (lower better) | **0.045** | 0.108 | 0.215 | 0.071 |
233
+
234
+ Read straight, because that's the point of doing this:
235
+
236
+ - **Jev wins the multi-primitive set outright** — best accuracy and best
237
+ calibration, no caveats.
238
+ - **`von` wins Banking77** — best accuracy of *all four* systems (0.838,
239
+ ahead of even Jev's 0.812), though Jev still calibrates better there
240
+ (0.084 vs 0.135).
241
+ - **poordjaevin leads the open, local options on the multi-primitive set** — best
242
+ accuracy and best calibration among Laya/`von`/poordjaevin there. That does
243
+ **not** carry over to Banking77: `von` beats poordjaevin on accuracy by a wide
244
+ margin (0.838 vs 0.656), and poordjaevin has the *worst* calibration of all four
245
+ systems there (0.414 — even behind Laya's 0.388), not the best.
246
+
247
+ Nobody sweeps, and poordjaevin specifically does not sweep the open-source field —
248
+ it wins one benchmark and loses the other, to `von`, decisively. Full
249
+ methodology, fairness notes, and every raw result file are in
250
+ [`crossbench/`](crossbench/) — reproducible for a few cents of Jev API calls
251
+ and some CPU time.
252
+
253
+ poordjaevin is not a Jev clone and makes no claim to beat it, or to beat `von`
254
+ across the board. It reproduces the **interface**, proves its own calibration
255
+ with numbers instead of marketing copy, and is the strongest fully local
256
+ option on the mixed decision-primitive benchmark — not on high-cardinality
257
+ classification, where `von` currently leads.
258
+
259
+ ## The three primitives
260
+
261
+ | Primitive | Use it for | Returns |
262
+ |---|---|---|
263
+ | `Choice(options)` | classification, routing | winning option, per-option probabilities, calibrated confidence |
264
+ | `Score(levels)` | ordinal rating, severity | winning level, a continuous score on the scale, confidence |
265
+ | `Noul(statement)` | yes/no gates, guardrails | `P(true)`, thresholded to a bool |
266
+
267
+ The returned `value` is **always** drawn from the set you declared. An invalid category is structurally impossible, not "usually avoided." This is tested against adversarial inputs (NaN, infinity, negatives, all-zero score vectors).
268
+
269
+ ## How it works
270
+
271
+ ```
272
+ state + typed questions
273
+ |
274
+ v
275
+ one batched pass through a local zero-shot NLI model (no API key)
276
+ |
277
+ v
278
+ raw probabilities per option
279
+ |
280
+ v
281
+ calibration: temperature scaling + conformal abstention
282
+ |
283
+ v
284
+ typed, schema-valid answers + calibrated confidence
285
+ ```
286
+
287
+ - **Local NLI backend (fully offline):** one small natural-language-inference model scores every option as an entailment hypothesis, in a single batched forward pass. Fully offline after a one-time ~400MB download. No key, no vendor, your text never leaves your machine. This is the backend used by `poordjaevin eval` / `calibrate` and by `Client()` in Python; select it for `serve` with `POORDJAEVIN_BACKEND=nli`.
288
+ - **Devin ACP backend (default for `poordjaevin serve`):** routes scoring through `devin acp`, so decisions use the model your Devin plan already provides, with automatic rotation and per-call cost reporting. No extra model, no extra key.
289
+ - **Calibration (the moat):** temperature scaling fits one scalar so predicted confidence matches real accuracy; conformal thresholding turns a target risk budget into an "I don't know, escalate" signal. Calibration is backend-specific: a calibrator fitted on the NLI backend is not applied to ACP scores (the server warns and falls back to raw confidence on a mismatch).
290
+
291
+ ## Benchmarks
292
+
293
+ Reproduce everything with two commands:
294
+
295
+ ```bash
296
+ poordjaevin eval --set evalset/tasks.jsonl # accuracy, ECE, Brier, risk-coverage
297
+ poordjaevin calibrate --set evalset/tasks.jsonl --plots # before/after ECE + the diagrams
298
+ ```
299
+
300
+ On the shipped eval set (55 hand-labelled items, 160 decisions), local NLI backend, keyless:
301
+
302
+ | Metric | Raw | Calibrated |
303
+ |---|---:|---:|
304
+ | Accuracy | 0.781 | 0.781 |
305
+ | **ECE (calibration error)** | **0.170** | **0.071** |
306
+ | Brier | 0.184 | lower |
307
+ | Temperature | 1.00 | 2.71 |
308
+
309
+ Temperature is fit by 5-fold cross-validation, so the "after" number is measured on held-out data, never on data it was fit on. Full tables and the honest limitations are in [RESULTS.md](RESULTS.md).
310
+
311
+ **Against Jev, Laya, and von, on the same inputs, same metrics code:** see [poordjaevin vs the field](#poordjaevin-vs-the-field) above and the full harness in [`crossbench/`](crossbench/). Short version: poordjaevin leads the open options on this mixed decision-primitive benchmark, `von` leads on high-cardinality classification, Jev leads overall.
312
+
313
+ ## Selective prediction: it knows when it doesn't know
314
+
315
+ Set a risk budget and poordjaevin abstains on its least confident decisions instead of guessing:
316
+
317
+ <p align="center">
318
+ <img src="https://raw.githubusercontent.com/Icaro0310/poordjaevin/main/docs/risk_coverage.png" alt="Risk-coverage curve: error rate drops as the model abstains on low-confidence decisions" width="440">
319
+ </p>
320
+
321
+ At a 10% error budget it confidently answers 55% of decisions and escalates the rest. That is the natural bridge from System One (fast automatic answer) to System Two (a human, or a bigger model).
322
+
323
+ ## Real examples
324
+
325
+ ```bash
326
+ python examples/ticket_router.py # full triage on a support ticket
327
+ python examples/tool_gate.py # gate a risky tool call before it runs
328
+ python examples/demo.py # raw vs calibrated, side by side
329
+ ```
330
+
331
+ The tool-gate example encodes a practical lesson: the local model is strong at **concrete** questions ("this action moves money", "this deletes data") and weak at **abstract** ones ("this is dangerous"). Ask concrete questions and let a one-line rule apply the policy.
332
+
333
+ ## Honest limitations
334
+
335
+ No hype. Here is what this is not.
336
+
337
+ - **Not as fast as Jev.** Jev uses a custom model. poordjaevin uses commodity ones. We report latency, we do not market it.
338
+ - **The eval set is small** (tens of items, one labeller, English, support flavoured). Enough to show calibration direction and schema validity, not a leaderboard.
339
+ - **After-ECE is 0.071, not below 0.05.** That is the real cross-validated number, reported as measured. Per-question temperature would likely push it lower.
340
+ - **The local model is moderately intelligent.** It does real semantic entailment, not deep reasoning. Calibration and abstention are what make that safe.
341
+ - **Jev is currently ahead, measured, not assumed, and so is `von` on one axis.** The [cross-system benchmark](crossbench/) has Jev winning the multi-primitive set outright and leading Banking77 calibration; `von` beats both Jev and poordjaevin on Banking77 accuracy. poordjaevin's honest position is "best fully local/free option on the mixed decision-primitive benchmark," not "beats Jev" and not "beats every open alternative everywhere."
342
+ - **Temperature scaling doesn't fix everything.** At Banking77's 77-way cardinality, a proper cross-validated temperature refit barely moves ECE (0.414 → 0.416) — the miscalibration there is structural to the small NLI backend at high option counts, not a scalar you can fit away. See [`crossbench/results/banking77_poordjaevin_recalibrated.json`](crossbench/results/banking77_poordjaevin_recalibrated.json).
343
+
344
+ ## FAQ
345
+
346
+ **Is this a Jev clone?** No. It reproduces Jev's developer interface and its calibrated-confidence guarantee on open, local models. It does not copy Jev's architecture or its speed.
347
+
348
+ **Can I run Jev locally?** Not Jev itself, it is closed and hosted. poordjaevin is the local, open-source alternative: it runs the same typed-decision interface on your own machine, offline, with no API key and no waitlist.
349
+
350
+ **Is there an open-source alternative to Jev?** Yes, this is one. poordjaevin is MIT-licensed, reproduces Jev's `Choice`/`Score`/`Noul` interface on commodity models, and proves its calibration with reproducible numbers.
351
+
352
+ **Do I need an API key or GPU?** No. Two free paths: `serve` defaults to the ACP backend, which reuses your existing Devin credentials and model; `nli` runs on CPU, offline, after one model download.
353
+
354
+ **How is this different from an LLM in JSON mode?** Two ways. Output is schema-valid by construction, not by parsing. And the confidence is calibrated and proven, not a number the model made up.
355
+
356
+ **What is a "System One" model?** A model for fast, automatic, structured decisions (classify, route, score, gate), as opposed to slow, deliberative chat. The name is from Kahneman's System 1 / System 2.
357
+
358
+ **What is ECE?** Expected Calibration Error: the average gap between a model's confidence and its actual accuracy. Lower is better. poordjaevin's whole job is to shrink it.
359
+
360
+ **Can I use my own model?** Yes. Backends are pluggable; a backend only implements `entail_probs(pairs)`.
361
+
362
+ ## Roadmap
363
+
364
+ - [x] Typed primitives, schema-valid by construction
365
+ - [x] Local NLI backend, single pass, keyless
366
+ - [x] Eval set + metrics (accuracy, ECE, Brier, risk-coverage)
367
+ - [x] Calibration: temperature scaling + conformal abstention
368
+ - [x] MCP server: use poordjaevin as local tools in Claude Code
369
+ - [x] Independent cross-system benchmark vs Jev, Laya, von ([`crossbench/`](crossbench/))
370
+ - [x] Devin ACP backend: LLM scoring through your existing Devin credentials (the intelligence dial)
371
+ - [ ] Close the Banking77 accuracy/calibration gap to Jev (bigger backend, per-class calibration)
372
+
373
+ ## Platform support
374
+
375
+ Windows, Linux, and macOS. The ACP bridge resolves Devin credentials and the
376
+ `devin` executable per platform:
377
+
378
+ | Platform | Devin credentials | Devin CLI |
379
+ |---|---|---|
380
+ | Windows | `%APPDATA%\devin\credentials.toml` | `devin.exe` on PATH |
381
+ | Linux | `$XDG_DATA_HOME/devin/credentials.toml` (default `~/.local/share/devin/credentials.toml`) | `devin` on PATH |
382
+ | macOS | `~/Library/Application Support/devin/credentials.toml` | `devin` on PATH |
383
+
384
+ Override either with `DEVIN_CREDENTIALS_PATH` and `DEVIN_CLI_PATH`. The
385
+ credential file is read only to authenticate the ACP session; it is never
386
+ logged or copied.
387
+
388
+ ## Contributing
389
+
390
+ Issues and PRs welcome, especially new labelled decision tasks for the eval set. If you find a case where the confidence is not honest, that is a bug worth filing.
391
+
392
+ ## License
393
+
394
+ MIT. Use it, ship it, sell it.
395
+
396
+ ---
397
+
398
+ <p align="center"><i>poordjaevin: poor in price, rich in honesty. If your model's confidence is a vibe, come check it.</i></p>
399
+
400
+
401
+ ---
402
+
403
+ If this saved you debugging time, a ⭐ on the repo helps others find it.