stability-nexus 1.0.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.
@@ -0,0 +1,2 @@
1
+ # SCM syntax highlighting & preventing 3-way merges
2
+ pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+ push:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - uses: prefix-dev/setup-pixi@v0.8.4
16
+ with:
17
+ pixi-version: latest
18
+
19
+ - run: pixi install
20
+
21
+ - run: pixi run pytest
22
+
23
+ - run: pixi run build
@@ -0,0 +1,73 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ permissions:
8
+ contents: write
9
+
10
+ jobs:
11
+ release:
12
+ name: Semantic Release
13
+ runs-on: ubuntu-latest
14
+ concurrency:
15
+ group: release-${{ github.ref_name }}
16
+ cancel-in-progress: false
17
+ permissions:
18
+ contents: write
19
+ outputs:
20
+ released: ${{ steps.release.outputs.released }}
21
+ tag: ${{ steps.release.outputs.tag }}
22
+ version: ${{ steps.release.outputs.version }}
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ with:
26
+ fetch-depth: 0
27
+
28
+ - name: Python Semantic Release
29
+ id: release
30
+ uses: python-semantic-release/python-semantic-release@v10.5.3
31
+ with:
32
+ github_token: ${{ secrets.GITHUB_TOKEN }}
33
+ build: false
34
+
35
+ build:
36
+ name: Build distribution
37
+ runs-on: ubuntu-latest
38
+ needs: release
39
+ if: needs.release.outputs.released == 'true'
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+ with:
43
+ ref: ${{ needs.release.outputs.tag }}
44
+
45
+ - uses: prefix-dev/setup-pixi@v0.8.4
46
+ with:
47
+ pixi-version: latest
48
+
49
+ - run: pixi install
50
+
51
+ - run: pixi run build
52
+
53
+ - uses: actions/upload-artifact@v4
54
+ with:
55
+ name: dist
56
+ path: dist/
57
+
58
+ pypi-publish:
59
+ name: Publish to PyPI
60
+ runs-on: ubuntu-latest
61
+ needs: build
62
+ environment:
63
+ name: pypi
64
+ url: https://pypi.org/p/stability-nexus
65
+ permissions:
66
+ id-token: write
67
+ steps:
68
+ - uses: actions/download-artifact@v4
69
+ with:
70
+ name: dist
71
+ path: dist/
72
+
73
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,362 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+ *.egg
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ ENV/
16
+
17
+ # IDE
18
+ .idea/
19
+ .vscode/
20
+ *.swp
21
+ *.swo
22
+
23
+ # Testing
24
+ .pytest_cache/
25
+ .coverage
26
+ htmlcov/
27
+ .mypy_cache/
28
+ .ruff_cache/
29
+
30
+ # OS
31
+ .DS_Store
32
+ Thumbs.db
33
+ # pixi environments
34
+ .pixi/*
35
+ !.pixi/config.toml
36
+
37
+ ## Core latex/pdflatex auxiliary files:
38
+ *.aux
39
+ *.lof
40
+ *.log
41
+ *.lot
42
+ *.fls
43
+ *.out
44
+ *.toc
45
+ *.fmt
46
+ *.fot
47
+ *.cb
48
+ *.cb2
49
+ .*.lb
50
+
51
+ ## Intermediate documents:
52
+ *.dvi
53
+ *.xdv
54
+ *-converted-to.*
55
+ # these rules might exclude image files for figures etc.
56
+ # *.ps
57
+ # *.eps
58
+ # *.pdf
59
+
60
+ ## Generated if empty string is given at "Please type another file name for output:"
61
+ .pdf
62
+
63
+ ## Bibliography auxiliary files (bibtex/biblatex/biber):
64
+ *.bbl
65
+ *.bbl-SAVE-ERROR
66
+ *.bcf
67
+ *.bcf-SAVE-ERROR
68
+ *.blg
69
+ *-blx.aux
70
+ *-blx.bib
71
+ *.run.xml
72
+
73
+ ## Build tool auxiliary files:
74
+ *.fdb_latexmk
75
+ *.synctex
76
+ *.synctex(busy)
77
+ *.synctex.gz
78
+ *.synctex.gz(busy)
79
+ *.pdfsync
80
+ *.rubbercache
81
+ rubber.cache
82
+
83
+ ## Build tool directories for auxiliary files
84
+ # latexrun
85
+ latex.out/
86
+
87
+ ## Auxiliary and intermediate files from other packages:
88
+ # algorithms
89
+ *.alg
90
+ *.loa
91
+
92
+ # achemso
93
+ acs-*.bib
94
+
95
+ # amsthm
96
+ *.thm
97
+
98
+ # attachfile2
99
+ *.atfi
100
+
101
+ # beamer
102
+ *.nav
103
+ *.pre
104
+ *.snm
105
+ *.vrb
106
+
107
+ # changes
108
+ *.soc
109
+ *.loc
110
+
111
+ # comment
112
+ *.cut
113
+
114
+ # cprotect
115
+ *.cpt
116
+
117
+ # elsarticle (documentclass of Elsevier journals)
118
+ *.spl
119
+
120
+ # endnotes
121
+ *.ent
122
+
123
+ # fixme
124
+ *.lox
125
+
126
+ # feynmf/feynmp
127
+ *.mf
128
+ *.mp
129
+ *.t[1-9]
130
+ *.t[1-9][0-9]
131
+ *.tfm
132
+
133
+ #(r)(e)ledmac/(r)(e)ledpar
134
+ *.end
135
+ *.?end
136
+ *.[1-9]
137
+ *.[1-9][0-9]
138
+ *.[1-9][0-9][0-9]
139
+ *.[1-9]R
140
+ *.[1-9][0-9]R
141
+ *.[1-9][0-9][0-9]R
142
+ *.eledsec[1-9]
143
+ *.eledsec[1-9]R
144
+ *.eledsec[1-9][0-9]
145
+ *.eledsec[1-9][0-9]R
146
+ *.eledsec[1-9][0-9][0-9]
147
+ *.eledsec[1-9][0-9][0-9]R
148
+
149
+ # glossaries
150
+ *.acn
151
+ *.acr
152
+ *.glg
153
+ *.glg-abr
154
+ *.glo
155
+ *.glo-abr
156
+ *.gls
157
+ *.gls-abr
158
+ *.glsdefs
159
+ *.lzo
160
+ *.lzs
161
+ *.slg
162
+ *.slo
163
+ *.sls
164
+
165
+ # uncomment this for glossaries-extra (will ignore makeindex's style files!)
166
+ # *.ist
167
+
168
+ # gnuplot
169
+ *.gnuplot
170
+ *.table
171
+
172
+ # gnuplottex
173
+ *-gnuplottex-*
174
+
175
+ # gregoriotex
176
+ *.gaux
177
+ *.glog
178
+ *.gtex
179
+
180
+ # htlatex
181
+ *.4ct
182
+ *.4tc
183
+ *.idv
184
+ *.lg
185
+ *.trc
186
+ *.xref
187
+
188
+ # hypdoc
189
+ *.hd
190
+
191
+ # hyperref
192
+ *.brf
193
+
194
+ # knitr
195
+ *-concordance.tex
196
+ # TODO Uncomment the next line if you use knitr and want to ignore its generated tikz files
197
+ # *.tikz
198
+ *-tikzDictionary
199
+
200
+ # latexindent will create succesive backup files by default
201
+ #*.bak*
202
+
203
+ # listings
204
+ *.lol
205
+
206
+ # luatexja-ruby
207
+ *.ltjruby
208
+
209
+ # makeidx
210
+ *.idx
211
+ *.ilg
212
+ *.ind
213
+
214
+ # minitoc
215
+ *.maf
216
+ *.mlf
217
+ *.mlt
218
+ *.mtc[0-9]*
219
+ *.slf[0-9]*
220
+ *.slt[0-9]*
221
+ *.stc[0-9]*
222
+
223
+ # minted
224
+ _minted*
225
+ *.data.minted
226
+ *.pyg
227
+
228
+ # morewrites
229
+ *.mw
230
+
231
+ # newpax
232
+ *.newpax
233
+
234
+ # nomencl
235
+ *.nlg
236
+ *.nlo
237
+ *.nls
238
+
239
+ # pax
240
+ *.pax
241
+
242
+ # pdfpcnotes
243
+ *.pdfpc
244
+
245
+ # sagetex
246
+ *.sagetex.sage
247
+ *.sagetex.py
248
+ *.sagetex.scmd
249
+
250
+ # scrwfile
251
+ *.wrt
252
+
253
+ # spelling
254
+ *.spell.bad
255
+ *.spell.txt
256
+
257
+ # svg
258
+ svg-inkscape/
259
+
260
+ # sympy
261
+ *.sout
262
+ *.sympy
263
+ sympy-plots-for-*.tex/
264
+
265
+ # pdfcomment
266
+ *.upa
267
+ *.upb
268
+
269
+ # pythontex
270
+ *.pytxcode
271
+ pythontex-files-*/
272
+
273
+ # tcolorbox
274
+ *.listing
275
+
276
+ # thmtools
277
+ *.loe
278
+
279
+ # TikZ & PGF
280
+ *.dpth
281
+ *.md5
282
+ *.auxlock
283
+
284
+ # titletoc
285
+ *.ptc
286
+
287
+ # todonotes
288
+ *.tdo
289
+
290
+ # vhistory
291
+ *.hst
292
+ *.ver
293
+
294
+ # easy-todo
295
+ *.lod
296
+
297
+ # xcolor
298
+ *.xcp
299
+
300
+ # xmpincl
301
+ *.xmpi
302
+
303
+ # xindy
304
+ *.xdy
305
+
306
+ # xypic precompiled matrices and outlines
307
+ *.xyc
308
+ *.xyd
309
+
310
+ # endfloat
311
+ *.ttt
312
+ *.fff
313
+
314
+ # Latexian
315
+ TSWLatexianTemp*
316
+
317
+ ## Editors:
318
+ # WinEdt
319
+ *.bak
320
+ *.sav
321
+
322
+ # latexindent.pl
323
+ *.bak[0-9]*
324
+
325
+ # Texpad
326
+ .texpadtmp
327
+
328
+ # LyX
329
+ *.lyx~
330
+
331
+ # Kile
332
+ *.backup
333
+
334
+ # gummi
335
+ .*.swp
336
+
337
+ # KBibTeX
338
+ *~[0-9]*
339
+
340
+ # TeXnicCenter
341
+ *.tps
342
+
343
+ # auto folder when using emacs and auctex
344
+ ./auto/*
345
+ *.el
346
+
347
+ # expex forward references with \gathertags
348
+ *-tags.tex
349
+
350
+ # standalone packages
351
+ *.sta
352
+
353
+ # Makeindex log files
354
+ *.lpz
355
+
356
+ # xwatermark package
357
+ *.xwm
358
+
359
+ # REVTeX puts footnotes in the bibliography by default, unless the nofootinbib
360
+ # option is specified. Footnotes are the stored in a file with suffix Notes.bib.
361
+ # Uncomment the next line to have this generated file ignored.
362
+ #*Notes.bib
@@ -0,0 +1,69 @@
1
+ # AGENTS.md
2
+
3
+ This file provides guidance to WARP (warp.dev) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ `stability-nexus` is a Python multi-protocol simulation library. The primary implementation is the Gluon protocol reactor, which models fission, fusion, and beta decay reactions on a two-token (neutron/proton) system backed by basecoin reserves.
8
+
9
+ ## Commands
10
+
11
+ ### Environment
12
+
13
+ This project uses [pixi](https://pixi.sh) for dependency management per project convention. There is no `pixi.lock` yet — if one is needed, run `pixi install`.
14
+
15
+ ```bash
16
+ pixi install # set up the environment
17
+ pixi shell # activate the environment
18
+ ```
19
+
20
+ ### Testing
21
+
22
+ ```bash
23
+ pixi run pytest # run all tests
24
+ pixi run pytest tests/test_gluon.py -x -v # single file, fail fast, verbose
25
+ pixi run pytest tests/test_gluon.py::test_version -x -v # single test
26
+ ```
27
+
28
+ ### Build
29
+
30
+ The project uses the `hatchling` build backend. Build artifacts are just the package wheel, installed in editable mode via pixi. To build:
31
+
32
+ ```bash
33
+ pixi run python -m build
34
+ ```
35
+
36
+ ### Linting / formatting
37
+
38
+ No linter or formatter is configured yet. If adding one, use the project convention (pixi tasks in `[tool.pixi.tasks]` in `pyproject.toml`).
39
+
40
+ ## Architecture
41
+
42
+ ### Package layout
43
+
44
+ All source lives under `src/stability_nexus/` (`src` layout). `Basecoin = float` is the single global type in `src/stability_nexus/types.py`. Protocols live in subpackages (`src/stability_nexus/gluon/`).
45
+
46
+ ### Reactor pattern
47
+
48
+ The Gluon module uses an **abstract base class with a `Generic[R]` type parameter** to support multiple reactor variants (currently only concrete: `GluonZReactor`).
49
+
50
+ - **`GluonReactor`** (`gluon/reactors/gluon_reactor.py`) — abstract base parametrized by `R: GluonReactorState`. Declares the full reaction interface: `fission`, `fusion`, `beta_decay_plus`, `beta_decay_minus`, neutron/proton pricing, volume delta, fees, and the `execute` dispatch method.
51
+ - **`GluonZReactor`** (`gluon/reactors/gluon_z_reactor.py`) — concrete implementation typed as `GluonReactor[GluonZReactorState]`. Adds Z-specific parameters (`volume_decay_factor`) and state (`prev_volume_delta`, `prev_reaction_time`) to implement time-decaying volume tracking for beta decay fee calculation.
52
+
53
+ Key hierarchy: `GluonReactorParameters` → `GluonZReactorParameters` (adds `volume_decay_factor`), and `GluonReactorState` → `GluonZReactorState` (adds `prev_volume_delta`, `prev_reaction_time`). New reactor variants should follow this pattern: subclass both the parameters dataclass and state dataclass, then extend `GluonReactor[YourState]`.
54
+
55
+ ### Reaction dispatch
56
+
57
+ `execute()` uses Python 3.10+ `match/case` to dispatch on `GluonReaction` enum values. Each case mutates `self._state` in place and returns a `GluonExecution[GluonZReactorState]` containing the reactor output and the updated state snapshot.
58
+
59
+ ### Types
60
+
61
+ Type aliases (`Basecoin`, `Neutron`, `Proton`, `BasecoinPerNeutron`, `BasecoinPerProton`) are all `float` — they serve as documentation only, not compile-time safety. `Tokeons` is a dataclass bundling `neutrons` + `protons`. These are defined in `gluon/reactors/types.py`.
62
+
63
+ ## Adding a new protocol
64
+
65
+ 1. Create `src/stability_nexus/<protocol>/` with `__init__.py`.
66
+ 2. If the protocol has shared types beyond `Basecoin`, add them in a `types.py` within that package.
67
+ 3. Follow the existing Gluon pattern if the protocol involves reactors: abstract base, concrete implementations, parameter/state dataclass hierarchy.
68
+ 4. Export public symbols through `__init__.py`.
69
+ 5. Add tests under `tests/test_<protocol>.py`.
@@ -0,0 +1,7 @@
1
+ # CHANGELOG
2
+
3
+ <!-- version list -->
4
+
5
+ ## v1.0.0 (2026-11-28)
6
+
7
+ - Initial Release
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.5
2
+ Name: stability-nexus
3
+ Version: 1.0.0
4
+ Summary: Stability Nexus multi-protocol simulation library.
5
+ Project-URL: Homepage, https://stability.nexus
6
+ Author-email: Luca D'Angelo <ldgaetano@protonmail.com>
7
+ License-Expression: MIT
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+
16
+ # stability-nexus
17
+
18
+ Stability Nexus multi-protocol simulation library.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install stability-nexus
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ```python
29
+ from stability_nexus.gluon.reactors import GluonZReactor
30
+ from stability_nexus.gluon.reactors.types import (
31
+ GluonReaction,
32
+ GluonZReactorParameters,
33
+ GluonZReactorState,
34
+ Tokeons,
35
+ )
36
+
37
+ # Configure reactor parameters
38
+ params = GluonZReactorParameters(
39
+ critical_neutron_ratio=0.5,
40
+ fission_fee=0.01,
41
+ fusion_fee=0.01,
42
+ beta_decay_fee_slope=0.1,
43
+ beta_decay_fee_intercept=0.005,
44
+ volume_decay_factor=0.99,
45
+ )
46
+
47
+ # Initialize reactor state
48
+ state = GluonZReactorState(
49
+ reserves=1000.0,
50
+ neutron_circulating_supply=500.0,
51
+ proton_circulating_supply=500.0,
52
+ prev_volume_delta=0.0,
53
+ prev_reaction_time=0.0,
54
+ )
55
+
56
+ # Create reactor instance
57
+ reactor = GluonZReactor(params, state)
58
+
59
+ # Execute a fission reaction (basecoins -> neutrons + protons)
60
+ result = reactor.execute(
61
+ GluonReaction.FISSION,
62
+ balance=100.0,
63
+ neutron_target_price=1.0,
64
+ reaction_time=1.0,
65
+ )
66
+ print(f"Received: {result.reactor_output}")
67
+ print(f"New reserves: {result.reactor_state.reserves}")
68
+ ```
69
+
70
+ ## Reactions
71
+
72
+ The Gluon protocol supports four reaction types:
73
+
74
+ - **FISSION**: Convert basecoins into neutrons and protons
75
+ - **FUSION**: Convert neutrons and protons back into basecoins
76
+ - **BETA_DECAY_PLUS**: Convert protons into neutrons
77
+ - **BETA_DECAY_MINUS**: Convert neutrons into protons
78
+
79
+ ## Types
80
+
81
+ The library uses type aliases for documentation:
82
+
83
+ - `Basecoin` - Reserve currency amounts (`float`)
84
+ - `Neutron` - Neutron token amounts (`float`)
85
+ - `Proton` - Proton token amounts (`float`)
86
+ - `BasecoinPerNeutron` - Price ratio (`float`)
87
+ - `BasecoinPerProton` - Price ratio (`float`)
88
+ - `Tokeons` - A dataclass containing neutrons and protons
89
+
90
+ ## Contributing
91
+
92
+ If you encounter bugs, need help, or have feature requests:
93
+
94
+ - Please open an issue in this repository providing detailed information.
95
+ - Describe the problem clearly and include any relevant logs or screenshots.
96
+
97
+ We appreciate your feedback and contributions!
98
+
99
+ © 2025 The Stable Order.
@@ -0,0 +1,84 @@
1
+ # stability-nexus
2
+
3
+ Stability Nexus multi-protocol simulation library.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install stability-nexus
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from stability_nexus.gluon.reactors import GluonZReactor
15
+ from stability_nexus.gluon.reactors.types import (
16
+ GluonReaction,
17
+ GluonZReactorParameters,
18
+ GluonZReactorState,
19
+ Tokeons,
20
+ )
21
+
22
+ # Configure reactor parameters
23
+ params = GluonZReactorParameters(
24
+ critical_neutron_ratio=0.5,
25
+ fission_fee=0.01,
26
+ fusion_fee=0.01,
27
+ beta_decay_fee_slope=0.1,
28
+ beta_decay_fee_intercept=0.005,
29
+ volume_decay_factor=0.99,
30
+ )
31
+
32
+ # Initialize reactor state
33
+ state = GluonZReactorState(
34
+ reserves=1000.0,
35
+ neutron_circulating_supply=500.0,
36
+ proton_circulating_supply=500.0,
37
+ prev_volume_delta=0.0,
38
+ prev_reaction_time=0.0,
39
+ )
40
+
41
+ # Create reactor instance
42
+ reactor = GluonZReactor(params, state)
43
+
44
+ # Execute a fission reaction (basecoins -> neutrons + protons)
45
+ result = reactor.execute(
46
+ GluonReaction.FISSION,
47
+ balance=100.0,
48
+ neutron_target_price=1.0,
49
+ reaction_time=1.0,
50
+ )
51
+ print(f"Received: {result.reactor_output}")
52
+ print(f"New reserves: {result.reactor_state.reserves}")
53
+ ```
54
+
55
+ ## Reactions
56
+
57
+ The Gluon protocol supports four reaction types:
58
+
59
+ - **FISSION**: Convert basecoins into neutrons and protons
60
+ - **FUSION**: Convert neutrons and protons back into basecoins
61
+ - **BETA_DECAY_PLUS**: Convert protons into neutrons
62
+ - **BETA_DECAY_MINUS**: Convert neutrons into protons
63
+
64
+ ## Types
65
+
66
+ The library uses type aliases for documentation:
67
+
68
+ - `Basecoin` - Reserve currency amounts (`float`)
69
+ - `Neutron` - Neutron token amounts (`float`)
70
+ - `Proton` - Proton token amounts (`float`)
71
+ - `BasecoinPerNeutron` - Price ratio (`float`)
72
+ - `BasecoinPerProton` - Price ratio (`float`)
73
+ - `Tokeons` - A dataclass containing neutrons and protons
74
+
75
+ ## Contributing
76
+
77
+ If you encounter bugs, need help, or have feature requests:
78
+
79
+ - Please open an issue in this repository providing detailed information.
80
+ - Describe the problem clearly and include any relevant logs or screenshots.
81
+
82
+ We appreciate your feedback and contributions!
83
+
84
+ © 2025 The Stable Order.