kepric-calculate 0.1.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.
- kepric_calculate-0.1.0/.gitignore +223 -0
- kepric_calculate-0.1.0/LICENSE +21 -0
- kepric_calculate-0.1.0/PKG-INFO +121 -0
- kepric_calculate-0.1.0/README.md +99 -0
- kepric_calculate-0.1.0/pyproject.toml +140 -0
- kepric_calculate-0.1.0/src/kepric_calculate/__init__.py +17 -0
- kepric_calculate-0.1.0/src/kepric_calculate/__main__.py +15 -0
- kepric_calculate-0.1.0/src/kepric_calculate/engine.py +1421 -0
- kepric_calculate-0.1.0/src/kepric_calculate/mcp/__init__.py +9 -0
- kepric_calculate-0.1.0/src/kepric_calculate/mcp/__main__.py +16 -0
- kepric_calculate-0.1.0/src/kepric_calculate/mcp/catalog.py +343 -0
- kepric_calculate-0.1.0/src/kepric_calculate/mcp/serve.py +255 -0
- kepric_calculate-0.1.0/src/kepric_calculate/py.typed +1 -0
- kepric_calculate-0.1.0/tests/test_kat.py +507 -0
- kepric_calculate-0.1.0/tests/test_mcp.py +507 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
*.lcov
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
# Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# uv
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
# poetry.lock
|
|
110
|
+
# poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
# pdm.lock
|
|
117
|
+
# pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
# pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi/*
|
|
127
|
+
!.pixi/config.toml
|
|
128
|
+
|
|
129
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
130
|
+
__pypackages__/
|
|
131
|
+
|
|
132
|
+
# Celery stuff
|
|
133
|
+
celerybeat-schedule*
|
|
134
|
+
celerybeat.pid
|
|
135
|
+
|
|
136
|
+
# Redis
|
|
137
|
+
*.rdb
|
|
138
|
+
*.aof
|
|
139
|
+
*.pid
|
|
140
|
+
|
|
141
|
+
# RabbitMQ
|
|
142
|
+
mnesia/
|
|
143
|
+
rabbitmq/
|
|
144
|
+
rabbitmq-data/
|
|
145
|
+
|
|
146
|
+
# ActiveMQ
|
|
147
|
+
activemq-data/
|
|
148
|
+
|
|
149
|
+
# SageMath parsed files
|
|
150
|
+
*.sage.py
|
|
151
|
+
|
|
152
|
+
# Environments
|
|
153
|
+
.env
|
|
154
|
+
.envrc
|
|
155
|
+
.venv
|
|
156
|
+
env/
|
|
157
|
+
venv/
|
|
158
|
+
ENV/
|
|
159
|
+
env.bak/
|
|
160
|
+
venv.bak/
|
|
161
|
+
|
|
162
|
+
# Conda environments
|
|
163
|
+
conda-meta/
|
|
164
|
+
|
|
165
|
+
# Spyder project settings
|
|
166
|
+
.spyderproject
|
|
167
|
+
.spyproject
|
|
168
|
+
|
|
169
|
+
# Rope project settings
|
|
170
|
+
.ropeproject
|
|
171
|
+
|
|
172
|
+
# mkdocs/Zensical documentation
|
|
173
|
+
/site
|
|
174
|
+
|
|
175
|
+
# mypy
|
|
176
|
+
.mypy_cache/
|
|
177
|
+
.dmypy.json
|
|
178
|
+
dmypy.json
|
|
179
|
+
|
|
180
|
+
# Pyre type checker
|
|
181
|
+
.pyre/
|
|
182
|
+
|
|
183
|
+
# pytype static type analyzer
|
|
184
|
+
.pytype/
|
|
185
|
+
|
|
186
|
+
# Cython debug symbols
|
|
187
|
+
cython_debug/
|
|
188
|
+
|
|
189
|
+
# PyCharm
|
|
190
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
191
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
192
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
193
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
194
|
+
# .idea/
|
|
195
|
+
|
|
196
|
+
# Abstra
|
|
197
|
+
# Abstra is an AI-powered process automation framework.
|
|
198
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
199
|
+
# Learn more at https://abstra.io/docs
|
|
200
|
+
.abstra/
|
|
201
|
+
|
|
202
|
+
# Visual Studio Code
|
|
203
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
|
|
204
|
+
# can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
205
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer, you
|
|
206
|
+
# could uncomment the following to ignore the entire vscode folder
|
|
207
|
+
# .vscode/
|
|
208
|
+
# Temporary file for partial code execution
|
|
209
|
+
tempCodeRunnerFile.py
|
|
210
|
+
|
|
211
|
+
# Ruff stuff:
|
|
212
|
+
.ruff_cache/
|
|
213
|
+
|
|
214
|
+
# PyPI configuration file
|
|
215
|
+
.pypirc
|
|
216
|
+
|
|
217
|
+
# Marimo
|
|
218
|
+
marimo/_static/
|
|
219
|
+
marimo/_lsp/
|
|
220
|
+
__marimo__/
|
|
221
|
+
|
|
222
|
+
# Streamlit
|
|
223
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mark A Losey
|
|
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,121 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: kepric-calculate
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: To make every number carry its proof: zero-dependency arithmetic and statistics where the trace line {"op","args","result"} returns the provenance with the number
|
|
5
|
+
Project-URL: Homepage, https://github.com/markalosey/kepric-calculate
|
|
6
|
+
Author: Mark A Losey
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: arithmetic,calculator,deterministic,provenance,statistics
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Provides-Extra: mcp
|
|
20
|
+
Requires-Dist: ouncemcp==1.0.0rc3; extra == 'mcp'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# kepric-calculate
|
|
24
|
+
[](https://github.com/markalosey/kepric-calculate/actions/workflows/ci.yml)
|
|
25
|
+
|
|
26
|
+
To make every number carry its proof: zero-dependency arithmetic and statistics where the trace line {"op","args","result"} returns the provenance with the number, the refusals teach the route forward, and the same inputs always yield the same bytes.
|
|
27
|
+
|
|
28
|
+
Every op answers with the trace line — one JSON object on stdout carrying the op, the args, and the result together: the provenance inseparable from the number.
|
|
29
|
+
|
|
30
|
+
One file here is written by a human: [HUMAN.md](HUMAN.md) — the collaborator's note, and the only human-written file in the repository. Everything else is machine-composed through the governed route: the seats' work, the records at `.plans/`, the engine — the verbatim port of hikari's canonical home.
|
|
31
|
+
|
|
32
|
+
## Quickstart
|
|
33
|
+
|
|
34
|
+
```console
|
|
35
|
+
$ pip install kepric-calculate
|
|
36
|
+
$ kepric-calculate add --a=2 --b=3
|
|
37
|
+
{"op": "add", "args": {"a": "2", "b": "3"}, "result": 5}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
That line is the engine's own stdout — the trace line and nothing else. The module form runs the same engine:
|
|
41
|
+
|
|
42
|
+
```console
|
|
43
|
+
$ python -m kepric_calculate add --a=2 --b=3
|
|
44
|
+
{"op": "add", "args": {"a": "2", "b": "3"}, "result": 5}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## The refusal doctrine
|
|
48
|
+
|
|
49
|
+
Invalid operands never traceback. The engine refuses — a four-line block on stderr, stdout byte-empty, exit 1:
|
|
50
|
+
|
|
51
|
+
```console
|
|
52
|
+
$ kepric-calculate divide --a=1 --b=0
|
|
53
|
+
REFUSED
|
|
54
|
+
Expected: a nonzero divisor b (a number)
|
|
55
|
+
Found: b='0' — division by zero is mathematically impossible; no number is the quotient of n / 0
|
|
56
|
+
Next-action: pass a nonzero b, or reformulate the derivation (the boundary is arithmetic and counting only)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The refusals teach the route forward: every error names its fix, never a stack trace.
|
|
60
|
+
|
|
61
|
+
A third envelope shape exists by design — exit 2, the argparse usage error: an unusable invocation (a dropped flag, an unknown op) prints argparse's two-line usage message on stderr, stdout stays empty, exit 2 — never a traceback, never the four-line block.
|
|
62
|
+
|
|
63
|
+
## The MCP surface
|
|
64
|
+
|
|
65
|
+
```console
|
|
66
|
+
$ pip install kepric-calculate[mcp]
|
|
67
|
+
$ kepric-calculate-mcp
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`kepric-calculate-mcp` serves the engine over stdio. All 30 ops ship as tools named `kepric_<op>` (hyphens normalized to underscores), generated at every server start from the engine's own subparser table and census-checked at 30: `kepric_add`, `kepric_subtract`, `kepric_multiply`, `kepric_divide`, `kepric_sum`, `kepric_count`, `kepric_sqrt`, `kepric_power`, `kepric_factorial`, `kepric_combination`, `kepric_proportion`, `kepric_mean`, `kepric_variance`, `kepric_stddev`, `kepric_max`, `kepric_min`, `kepric_median`, `kepric_quantile`, `kepric_wilson`, `kepric_binom_test`, `kepric_normal_cdf`, `kepric_normal_ppf`, `kepric_log`, `kepric_exp`, `kepric_log_factorial`, `kepric_log_combination`, `kepric_log_beta`, `kepric_chisquare`, `kepric_shuffle`, `kepric_derive_seed`.
|
|
71
|
+
|
|
72
|
+
One call — the agentic form returns the same trace line:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
kepric_add {"a": "2", "b": "3"} → {"line": "{\"op\": \"add\", \"args\": {\"a\": \"2\", \"b\": \"3\"}, \"result\": 5}\n"}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The envelope is the framework's shape; the `line` member's value is the engine's own stdout bytes, verbatim — the provenance inseparable at every surface.
|
|
79
|
+
|
|
80
|
+
## The facts
|
|
81
|
+
|
|
82
|
+
- **Zero runtime dependencies** — `dependencies = []`: pure stdlib by law. The MCP surface rides the optional `[mcp]` extra; the core never imports it.
|
|
83
|
+
- **Python >= 3.11** — the supported matrix: 3.11, 3.12, 3.13, 3.14.
|
|
84
|
+
- **MIT licensed** — see [LICENSE](LICENSE).
|
|
85
|
+
- **30 ops** — arithmetic and counting, statistics, combinatorics, distribution, seeded permutation:
|
|
86
|
+
|
|
87
|
+
| op | the operation |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `add` | a + b — the sum of two numbers |
|
|
90
|
+
| `subtract` | a - b — the difference of two numbers |
|
|
91
|
+
| `multiply` | a * b — the product of two numbers |
|
|
92
|
+
| `divide` | a / b — the quotient of two numbers |
|
|
93
|
+
| `sum` | the total of a JSON array of numbers |
|
|
94
|
+
| `count` | the number of elements in a JSON array |
|
|
95
|
+
| `sqrt` | the principal square root of a |
|
|
96
|
+
| `power` | a raised to b (b real) |
|
|
97
|
+
| `factorial` | n! in exact, arbitrary-precision int |
|
|
98
|
+
| `combination` | C(n, k) in exact int |
|
|
99
|
+
| `proportion` | the share part/whole |
|
|
100
|
+
| `mean` | the arithmetic mean of a JSON array of finite numbers |
|
|
101
|
+
| `variance` | the population or sample variance of a JSON array |
|
|
102
|
+
| `stddev` | the population or sample standard deviation of a JSON array |
|
|
103
|
+
| `max` | the greatest element of a JSON array of finite numbers |
|
|
104
|
+
| `min` | the least element of a JSON array of finite numbers |
|
|
105
|
+
| `median` | the middle value of a JSON array of finite numbers |
|
|
106
|
+
| `quantile` | the p-quantile by fixed (n-1)-based linear interpolation |
|
|
107
|
+
| `wilson` | the Wilson score interval [lo, hi] of k in n at z |
|
|
108
|
+
| `binom-test` | the exact binomial tail p of k in n at p (one or two sided) |
|
|
109
|
+
| `normal-cdf` | the standard normal CDF at x |
|
|
110
|
+
| `normal-ppf` | the standard normal inverse CDF at q |
|
|
111
|
+
| `log` | the natural logarithm of a |
|
|
112
|
+
| `exp` | e raised to a |
|
|
113
|
+
| `log-factorial` | the natural log of n! |
|
|
114
|
+
| `log-combination` | the natural log of C(n, k) |
|
|
115
|
+
| `log-beta` | the natural log of the Beta function B(a, b) |
|
|
116
|
+
| `chisquare` | the goodness-of-fit [statistic, df] of observed vs expected |
|
|
117
|
+
| `shuffle` | the deterministic permutation of a JSON array under a seed |
|
|
118
|
+
| `derive-seed` | the stable integer seed derived from a text handle |
|
|
119
|
+
|
|
120
|
+
- **The trace-line contract** — stateless, no store, no session: the same inputs always yield the same trace bytes. `shuffle` takes a required seed; nothing is ever random.
|
|
121
|
+
- **Typed** — `py.typed` ships in the wheel (PEP 561).
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# kepric-calculate
|
|
2
|
+
[](https://github.com/markalosey/kepric-calculate/actions/workflows/ci.yml)
|
|
3
|
+
|
|
4
|
+
To make every number carry its proof: zero-dependency arithmetic and statistics where the trace line {"op","args","result"} returns the provenance with the number, the refusals teach the route forward, and the same inputs always yield the same bytes.
|
|
5
|
+
|
|
6
|
+
Every op answers with the trace line — one JSON object on stdout carrying the op, the args, and the result together: the provenance inseparable from the number.
|
|
7
|
+
|
|
8
|
+
One file here is written by a human: [HUMAN.md](HUMAN.md) — the collaborator's note, and the only human-written file in the repository. Everything else is machine-composed through the governed route: the seats' work, the records at `.plans/`, the engine — the verbatim port of hikari's canonical home.
|
|
9
|
+
|
|
10
|
+
## Quickstart
|
|
11
|
+
|
|
12
|
+
```console
|
|
13
|
+
$ pip install kepric-calculate
|
|
14
|
+
$ kepric-calculate add --a=2 --b=3
|
|
15
|
+
{"op": "add", "args": {"a": "2", "b": "3"}, "result": 5}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
That line is the engine's own stdout — the trace line and nothing else. The module form runs the same engine:
|
|
19
|
+
|
|
20
|
+
```console
|
|
21
|
+
$ python -m kepric_calculate add --a=2 --b=3
|
|
22
|
+
{"op": "add", "args": {"a": "2", "b": "3"}, "result": 5}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## The refusal doctrine
|
|
26
|
+
|
|
27
|
+
Invalid operands never traceback. The engine refuses — a four-line block on stderr, stdout byte-empty, exit 1:
|
|
28
|
+
|
|
29
|
+
```console
|
|
30
|
+
$ kepric-calculate divide --a=1 --b=0
|
|
31
|
+
REFUSED
|
|
32
|
+
Expected: a nonzero divisor b (a number)
|
|
33
|
+
Found: b='0' — division by zero is mathematically impossible; no number is the quotient of n / 0
|
|
34
|
+
Next-action: pass a nonzero b, or reformulate the derivation (the boundary is arithmetic and counting only)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The refusals teach the route forward: every error names its fix, never a stack trace.
|
|
38
|
+
|
|
39
|
+
A third envelope shape exists by design — exit 2, the argparse usage error: an unusable invocation (a dropped flag, an unknown op) prints argparse's two-line usage message on stderr, stdout stays empty, exit 2 — never a traceback, never the four-line block.
|
|
40
|
+
|
|
41
|
+
## The MCP surface
|
|
42
|
+
|
|
43
|
+
```console
|
|
44
|
+
$ pip install kepric-calculate[mcp]
|
|
45
|
+
$ kepric-calculate-mcp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`kepric-calculate-mcp` serves the engine over stdio. All 30 ops ship as tools named `kepric_<op>` (hyphens normalized to underscores), generated at every server start from the engine's own subparser table and census-checked at 30: `kepric_add`, `kepric_subtract`, `kepric_multiply`, `kepric_divide`, `kepric_sum`, `kepric_count`, `kepric_sqrt`, `kepric_power`, `kepric_factorial`, `kepric_combination`, `kepric_proportion`, `kepric_mean`, `kepric_variance`, `kepric_stddev`, `kepric_max`, `kepric_min`, `kepric_median`, `kepric_quantile`, `kepric_wilson`, `kepric_binom_test`, `kepric_normal_cdf`, `kepric_normal_ppf`, `kepric_log`, `kepric_exp`, `kepric_log_factorial`, `kepric_log_combination`, `kepric_log_beta`, `kepric_chisquare`, `kepric_shuffle`, `kepric_derive_seed`.
|
|
49
|
+
|
|
50
|
+
One call — the agentic form returns the same trace line:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
kepric_add {"a": "2", "b": "3"} → {"line": "{\"op\": \"add\", \"args\": {\"a\": \"2\", \"b\": \"3\"}, \"result\": 5}\n"}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The envelope is the framework's shape; the `line` member's value is the engine's own stdout bytes, verbatim — the provenance inseparable at every surface.
|
|
57
|
+
|
|
58
|
+
## The facts
|
|
59
|
+
|
|
60
|
+
- **Zero runtime dependencies** — `dependencies = []`: pure stdlib by law. The MCP surface rides the optional `[mcp]` extra; the core never imports it.
|
|
61
|
+
- **Python >= 3.11** — the supported matrix: 3.11, 3.12, 3.13, 3.14.
|
|
62
|
+
- **MIT licensed** — see [LICENSE](LICENSE).
|
|
63
|
+
- **30 ops** — arithmetic and counting, statistics, combinatorics, distribution, seeded permutation:
|
|
64
|
+
|
|
65
|
+
| op | the operation |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `add` | a + b — the sum of two numbers |
|
|
68
|
+
| `subtract` | a - b — the difference of two numbers |
|
|
69
|
+
| `multiply` | a * b — the product of two numbers |
|
|
70
|
+
| `divide` | a / b — the quotient of two numbers |
|
|
71
|
+
| `sum` | the total of a JSON array of numbers |
|
|
72
|
+
| `count` | the number of elements in a JSON array |
|
|
73
|
+
| `sqrt` | the principal square root of a |
|
|
74
|
+
| `power` | a raised to b (b real) |
|
|
75
|
+
| `factorial` | n! in exact, arbitrary-precision int |
|
|
76
|
+
| `combination` | C(n, k) in exact int |
|
|
77
|
+
| `proportion` | the share part/whole |
|
|
78
|
+
| `mean` | the arithmetic mean of a JSON array of finite numbers |
|
|
79
|
+
| `variance` | the population or sample variance of a JSON array |
|
|
80
|
+
| `stddev` | the population or sample standard deviation of a JSON array |
|
|
81
|
+
| `max` | the greatest element of a JSON array of finite numbers |
|
|
82
|
+
| `min` | the least element of a JSON array of finite numbers |
|
|
83
|
+
| `median` | the middle value of a JSON array of finite numbers |
|
|
84
|
+
| `quantile` | the p-quantile by fixed (n-1)-based linear interpolation |
|
|
85
|
+
| `wilson` | the Wilson score interval [lo, hi] of k in n at z |
|
|
86
|
+
| `binom-test` | the exact binomial tail p of k in n at p (one or two sided) |
|
|
87
|
+
| `normal-cdf` | the standard normal CDF at x |
|
|
88
|
+
| `normal-ppf` | the standard normal inverse CDF at q |
|
|
89
|
+
| `log` | the natural logarithm of a |
|
|
90
|
+
| `exp` | e raised to a |
|
|
91
|
+
| `log-factorial` | the natural log of n! |
|
|
92
|
+
| `log-combination` | the natural log of C(n, k) |
|
|
93
|
+
| `log-beta` | the natural log of the Beta function B(a, b) |
|
|
94
|
+
| `chisquare` | the goodness-of-fit [statistic, df] of observed vs expected |
|
|
95
|
+
| `shuffle` | the deterministic permutation of a JSON array under a seed |
|
|
96
|
+
| `derive-seed` | the stable integer seed derived from a text handle |
|
|
97
|
+
|
|
98
|
+
- **The trace-line contract** — stateless, no store, no session: the same inputs always yield the same trace bytes. `shuffle` takes a required seed; nothing is ever random.
|
|
99
|
+
- **Typed** — `py.typed` ships in the wheel (PEP 561).
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# kepric-calculate — the pyproject, composed: the birth's tools tables + the
|
|
2
|
+
# packaging home grown per the ruling (the composition pulled forward by
|
|
3
|
+
# amendment #72 — the MCP's distribution shape known, the whole [project]
|
|
4
|
+
# composing now). The birth was the tools-only table — the pre-commit hook's
|
|
5
|
+
# pyright leg and the lint wrapper's typecheck home; [project] with
|
|
6
|
+
# name/version/description/scripts landed here (the release effort's own
|
|
7
|
+
# store's ruled shape, Q-package-organization's ruling).
|
|
8
|
+
|
|
9
|
+
# The floor-3.8 law (the founding directive: zero-dependency, pure stdlib, floor
|
|
10
|
+
# 3.8): the interpreter floor, declared at this file's top level — the release
|
|
11
|
+
# effort's [project] table absorbs it as real project metadata when it lands.
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
|
|
14
|
+
[build-system]
|
|
15
|
+
# Hatchling — the corpus §4's recommendation adopted: uv-native, light,
|
|
16
|
+
# PEP 621-first, first-class src support.
|
|
17
|
+
requires = ["hatchling"]
|
|
18
|
+
build-backend = "hatchling.build"
|
|
19
|
+
|
|
20
|
+
[project]
|
|
21
|
+
# The dist name (PEP 503 — the import name kepric_calculate, the directory
|
|
22
|
+
# src/kepric_calculate/); the ruled shape per Q-package-organization's ruling
|
|
23
|
+
# and the conventions corpus (the effort's evidence home,
|
|
24
|
+
# .junro/evidence/Q-package-organization/conventions-corpus.md).
|
|
25
|
+
name = "kepric-calculate"
|
|
26
|
+
version = "0.1.0"
|
|
27
|
+
# The goal line's first clause (AGENTS.md, the cut at the first comma, per
|
|
28
|
+
# REL-1) — the trace line's JSON braces carried verbatim in a TOML literal
|
|
29
|
+
# string: the single quotes hold the inner double quotes unescaped, the
|
|
30
|
+
# parse never breaking.
|
|
31
|
+
description = 'To make every number carry its proof: zero-dependency arithmetic and statistics where the trace line {"op","args","result"} returns the provenance with the number'
|
|
32
|
+
readme = "README.md"
|
|
33
|
+
# The ruled package floor — the matrix {3.11-3.14}, the oldest still-supported
|
|
34
|
+
# release (the corpus §7's recommendation adopted): the birth's floor-3.8 guard
|
|
35
|
+
# absorbed and re-judged here ("the floor-3.8 guard absorbed for the package");
|
|
36
|
+
# the top-level tools floor above stands as its marker, the history preserved.
|
|
37
|
+
requires-python = ">=3.11"
|
|
38
|
+
# The PEP 639 form (the corpus §3): the SPDX expression + the license file.
|
|
39
|
+
license = "MIT"
|
|
40
|
+
license-files = ["LICENSE"]
|
|
41
|
+
# The LICENSE's copyright line ("Copyright (c) 2026 Mark A Losey").
|
|
42
|
+
authors = [{ name = "Mark A Losey" }]
|
|
43
|
+
# The ruled set: the floor matrix {3.11-3.14}, the license, the Typed marker
|
|
44
|
+
# (PEP 561 — py.typed ships in the wheel), the base Python line, the topic.
|
|
45
|
+
classifiers = [
|
|
46
|
+
"License :: OSI Approved :: MIT License",
|
|
47
|
+
"Programming Language :: Python",
|
|
48
|
+
"Programming Language :: Python :: 3.11",
|
|
49
|
+
"Programming Language :: Python :: 3.12",
|
|
50
|
+
"Programming Language :: Python :: 3.13",
|
|
51
|
+
"Programming Language :: Python :: 3.14",
|
|
52
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
53
|
+
"Typing :: Typed",
|
|
54
|
+
]
|
|
55
|
+
# The identity words (the judgment per the corpus's canon): the calculator,
|
|
56
|
+
# the domains, the proof carried, the determinism.
|
|
57
|
+
keywords = ["calculator", "arithmetic", "statistics", "provenance", "deterministic"]
|
|
58
|
+
# ZERO runtime dependencies BY LAW — the empty list the identity carried
|
|
59
|
+
# explicitly, never omitted: the package pure-stdlib by construction (the
|
|
60
|
+
# mcp surface behind the extra; the core's import graph never touches it).
|
|
61
|
+
dependencies = []
|
|
62
|
+
|
|
63
|
+
[project.urls]
|
|
64
|
+
# The repo's origin, found in .git/config (remote "origin":
|
|
65
|
+
# git@github.com:markalosey/kepric-calculate.git — the SSH form) — the HTTPS
|
|
66
|
+
# form composed.
|
|
67
|
+
Homepage = "https://github.com/markalosey/kepric-calculate"
|
|
68
|
+
|
|
69
|
+
[project.optional-dependencies]
|
|
70
|
+
# The MCP surface's distribution (Q-mcp-surface's ruling): the ouncemcp
|
|
71
|
+
# extra — the core zero-dep by construction; the hand-rolled fallback held,
|
|
72
|
+
# the separate distribution priced out.
|
|
73
|
+
# The family pin-hygiene lane (Q-OUNCEMCP Q-4, ruled 2026-11-28): the exact pin / bounded range at the family's ouncemcp/fastmcp substrate; the lockfile hashes hold the reproducibility;
|
|
74
|
+
# the external-security-review watch rides before any 1.0 bump; upgrades DELIBERATE (the three-way drift class measured live: fastmcp 3.4.4/4.2.4/4.2.6 under identical rc3 bytes)
|
|
75
|
+
mcp = ["ouncemcp==1.0.0rc3"]
|
|
76
|
+
|
|
77
|
+
[project.scripts]
|
|
78
|
+
# The two console forms. kepric-calculate-mcp without the extra installed
|
|
79
|
+
# REFUSES loud — mcp/serve.py's doctrine guard (exit 2, the install line
|
|
80
|
+
# named) — the teaching refusal, never a traceback.
|
|
81
|
+
kepric-calculate = "kepric_calculate.__main__:main"
|
|
82
|
+
kepric-calculate-mcp = "kepric_calculate.mcp.serve:main"
|
|
83
|
+
|
|
84
|
+
[dependency-groups]
|
|
85
|
+
# Dev tooling ONLY: pyright (the hook's 0/0/0 leg) + ruff (the lint wrapper's check).
|
|
86
|
+
# pytest NEVER — the test channel is unborn by ruling (the KAT port is the release
|
|
87
|
+
# effort's act). ZERO runtime dependencies by law — the system is pure stdlib.
|
|
88
|
+
# THE GROWTH (the packaging composition): pytest joins dev — the test channel
|
|
89
|
+
# BORN (the port landed, the smoke at tests/ landed; the durable form of the
|
|
90
|
+
# collaborator's pip install; the KAT copy the collaborator's hand) — the
|
|
91
|
+
# "pytest NEVER" clause above superseded by the composition's ruling; the ZERO
|
|
92
|
+
# runtime dependencies law unchanged (the [project] table above carries
|
|
93
|
+
# dependencies = [], the identity explicit).
|
|
94
|
+
dev = [
|
|
95
|
+
"pyright",
|
|
96
|
+
"ruff",
|
|
97
|
+
"pytest",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
[tool.hatch.build.targets.wheel]
|
|
101
|
+
# The wheel: the package alone (the corpus §9) — kepric_calculate/ + py.typed
|
|
102
|
+
# + the mcp subpackage (its guard the no-extra refusal); the tests never
|
|
103
|
+
# ride the wheel.
|
|
104
|
+
packages = ["src/kepric_calculate"]
|
|
105
|
+
exclude = [".plans", ".opencode", ".github"]
|
|
106
|
+
|
|
107
|
+
[tool.hatch.build.targets.sdist]
|
|
108
|
+
# The sdist: the package + README + LICENSE + tests (the corpus §9's
|
|
109
|
+
# downstream courtesy — the wheel never carries them); pyproject.toml
|
|
110
|
+
# rides by hatchling's own law. EXCLUDED from both distributions (the
|
|
111
|
+
# ruled three): .plans (the record home), .opencode (the harness),
|
|
112
|
+
# .github (the CI) — never in the distributions.
|
|
113
|
+
include = ["src", "tests", "README.md", "LICENSE"]
|
|
114
|
+
exclude = [".plans", ".opencode", ".github"]
|
|
115
|
+
|
|
116
|
+
[tool.pyright]
|
|
117
|
+
# The strictness that holds the 0/0/0 bar — the pre-commit hook greps the literal
|
|
118
|
+
# pass string "0 errors, 0 warnings, 0 informations" (a warning is an error
|
|
119
|
+
# waiting to happen; the tane precedent's shape). The include set = the five
|
|
120
|
+
# derived engines at .opencode/scripts, the tree's only .py — they pass
|
|
121
|
+
# UNMODIFIED or the finding is named, never edited.
|
|
122
|
+
# THE GROWTH (the packaging composition, the ruling's rider): the born
|
|
123
|
+
# package at src/ joins the include — the 0/0/0 bar over the package (the
|
|
124
|
+
# port + the mcp surface); the derived engines' law above unchanged
|
|
125
|
+
# (UNMODIFIED or named, never edited — the emission's own act).
|
|
126
|
+
typeCheckingMode = "strict"
|
|
127
|
+
include = [".opencode/scripts", "src"]
|
|
128
|
+
|
|
129
|
+
[tool.ruff]
|
|
130
|
+
# The ruff adjudication's ruled bytes (the 12 config-delta findings
|
|
131
|
+
# resolving by config; the zero-ignore law stands — an ignore is a
|
|
132
|
+
# ruling, never a convenience).
|
|
133
|
+
line-length = 120
|
|
134
|
+
target-version = "py311"
|
|
135
|
+
|
|
136
|
+
[tool.ruff.lint]
|
|
137
|
+
# The ruled select set, moved to ruff 0.17's canonical home (the top-level
|
|
138
|
+
# form deprecated — the rider's warning over this very file, fixed
|
|
139
|
+
# same-turn; the set's bytes unchanged).
|
|
140
|
+
select = ["E", "F", "I", "N", "UP", "B", "SIM", "RUF"]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""The kepric_calculate package — the public surface (the version and the CLI front).
|
|
2
|
+
|
|
3
|
+
Purpose: the kepric_calculate package's public surface — the version and the CLI front.
|
|
4
|
+
Refuses when: never — the declarative surface; the engine's own refusals ride at the call.
|
|
5
|
+
Re-run: n/a — the package's files hand-owned at this tree, the canonical public home, never
|
|
6
|
+
cycle-generated.
|
|
7
|
+
Touches: nothing — declarative.
|
|
8
|
+
Provenance: the release effort's port — the engine verbatim from hikari's engine via the
|
|
9
|
+
emission's byte-identical local view, the PASS 35/35 receipt's chain;
|
|
10
|
+
Q-package-organization's src-layout ruling.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
__version__ = "0.1.0"
|
|
14
|
+
|
|
15
|
+
from .engine import main
|
|
16
|
+
|
|
17
|
+
__all__ = ["__version__", "main"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""The -m entry — python -m kepric_calculate runs the CLI.
|
|
2
|
+
|
|
3
|
+
Purpose: the -m entry — python -m kepric_calculate runs the CLI, the exit code the engine's own.
|
|
4
|
+
Refuses when: the engine's refusals ride through verbatim — the doctrine block the only error shape.
|
|
5
|
+
Re-run: python -m kepric_calculate <op> --flags.
|
|
6
|
+
Touches: the engine's main.
|
|
7
|
+
Provenance: the port.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
from .engine import main
|
|
13
|
+
|
|
14
|
+
if __name__ == "__main__":
|
|
15
|
+
sys.exit(main())
|