pkpython 0.1.0__tar.gz → 0.7.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 (32) hide show
  1. {pkpython-0.1.0 → pkpython-0.7.0}/.gitignore +1 -0
  2. pkpython-0.7.0/CHANGELOG.md +194 -0
  3. {pkpython-0.1.0 → pkpython-0.7.0}/Cargo.lock +280 -432
  4. {pkpython-0.1.0 → pkpython-0.7.0}/Cargo.toml +2 -2
  5. {pkpython-0.1.0 → pkpython-0.7.0}/Makefile +18 -1
  6. {pkpython-0.1.0 → pkpython-0.7.0}/PKG-INFO +4 -2
  7. {pkpython-0.1.0 → pkpython-0.7.0}/README.md +3 -1
  8. pkpython-0.7.0/docs/superpowers/plans/2026-04-28-pkpy-0.0.52-upgrade.md +1742 -0
  9. pkpython-0.7.0/docs/superpowers/plans/2026-04-29-pkpy-pokersession-tablenocell.md +1215 -0
  10. pkpython-0.7.0/docs/superpowers/specs/2026-04-28-pkpy-0.0.52-upgrade-design.md +137 -0
  11. pkpython-0.7.0/docs/superpowers/specs/2026-04-29-pkpy-pokersession-tablenocell-design.md +319 -0
  12. {pkpython-0.1.0 → pkpython-0.7.0}/pyproject.toml +1 -1
  13. {pkpython-0.1.0 → pkpython-0.7.0}/python/pkpy/__init__.py +14 -0
  14. pkpython-0.7.0/src/bot.rs +7 -0
  15. pkpython-0.7.0/src/hand_history.rs +7 -0
  16. {pkpython-0.1.0 → pkpython-0.7.0}/src/lib.rs +51 -14
  17. pkpython-0.7.0/src/session.rs +236 -0
  18. pkpython-0.7.0/src/stats.rs +7 -0
  19. pkpython-0.7.0/src/table_no_cell.rs +232 -0
  20. {pkpython-0.1.0 → pkpython-0.7.0}/tests/test_pkpy.py +14 -8
  21. pkpython-0.7.0/tests/test_session.py +174 -0
  22. pkpython-0.7.0/tests/test_table_no_cell.py +140 -0
  23. pkpython-0.1.0/.claude/settings.local.json +0 -14
  24. {pkpython-0.1.0 → pkpython-0.7.0}/.github/workflows/ci.yml +0 -0
  25. {pkpython-0.1.0 → pkpython-0.7.0}/.github/workflows/publish.yml +0 -0
  26. {pkpython-0.1.0 → pkpython-0.7.0}/LICENSE +0 -0
  27. {pkpython-0.1.0 → pkpython-0.7.0}/demo.py +0 -0
  28. {pkpython-0.1.0 → pkpython-0.7.0}/docs/STACK.md +0 -0
  29. {pkpython-0.1.0 → pkpython-0.7.0}/docs/pypi-publishing-plan.md +0 -0
  30. {pkpython-0.1.0 → pkpython-0.7.0}/examples/calc.py +0 -0
  31. {pkpython-0.1.0 → pkpython-0.7.0}/examples/gto.py +0 -0
  32. {pkpython-0.1.0 → pkpython-0.7.0}/examples/the_hand.py +0 -0
@@ -8,3 +8,4 @@ dist/
8
8
  *.dylib
9
9
  *.dylib.dSYM/
10
10
  Cargo.lock
11
+ .claude/
@@ -0,0 +1,194 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are 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 tracks [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+ The crate version is kept in lockstep with the underlying `pkcore` dependency.
8
+
9
+ ## [0.7.0] - 2026-08-22
10
+
11
+ ### Changed
12
+
13
+ - Bumped `pkcore` dependency from `0.2.1` to `0.7.0`, skipping the `0.3`, `0.4`,
14
+ `0.5` and `0.6` lines.
15
+ - Bumped `pkpy` crate version to `0.7.0` to stay in lockstep with `pkcore`.
16
+
17
+ ### Breaking (Python API)
18
+
19
+ - **`Deck.get(index)` returns `Card | None` instead of `Card`.** `pkcore` 0.7.0
20
+ made `Deck::get` return `Option<Card>` rather than indexing out of bounds, so
21
+ an index outside `0..=51` is now `None` in Python instead of an abort. Callers
22
+ that trusted the index are unaffected; callers that pass computed indices
23
+ should check for `None`.
24
+ - **`PokerSession.next_actor()` raises instead of returning `None` on a failed
25
+ street advance.** `pkcore` 0.7.0 changed `next_actor` to
26
+ `Result<Option<u8>, PKError>` (`DEFECT_019`). Previously a dry deck collapsed
27
+ to `None`, which every `while (actor := session.next_actor()) is not None`
28
+ loop reads as "hand over" — `end_hand()` then raised `ActionIsntFinished` and
29
+ the pot was stranded. Only "no streets remain" is still `None`; a real failure
30
+ now raises `ValueError`. Recover with `abort_hand()`.
31
+ - **`KuhnCfr.train(iterations)` can raise.** `pkcore` 0.7.0 changed
32
+ `KuhnCfr::train` to return `Result<(), PKError>`. pkpy previously discarded
33
+ that result, so a training error produced a silently half-trained strategy.
34
+ - **`SevenFiveBCM.from_cards` and `IndexCardMap.from_cards` raise `ValueError` on
35
+ an unsupported card count.** `pkcore` 0.6.0 replaced `Ok(Self::default())` with
36
+ `Err(PKError::InvalidCardCount)`. Code that relied on a rank-0 default for a
37
+ three-card input must catch the error instead.
38
+
39
+ ### Added
40
+
41
+ - **`PokerSession.abort_hand()` → `int`.** Abandons a hand that cannot continue,
42
+ returning each player's committed chips and resetting the table. This is the
43
+ documented escape hatch for a `Failed` step and for a raising `next_actor()`;
44
+ `end_hand()` cannot settle such a hand because there was no showdown.
45
+ - **`SessionStep` gained the `"Failed"` kind and a `SessionStep.error()`
46
+ accessor.** `pkcore` 0.7.0 added `SessionStep::Failed(PKError)` for a hand that
47
+ cannot continue (dealing or chip collection failed mid-hand). `kind()` now
48
+ returns `"Failed"` for it and `error()` returns the message as a `str`; it
49
+ returns `None` for every other kind.
50
+
51
+ ### Migration notes
52
+
53
+ Drive-a-hand loops should handle the new failure kind:
54
+
55
+ ```python
56
+ session.start_hand()
57
+ while True:
58
+ step = session.next_step()
59
+ if step.kind() == "Failed":
60
+ session.abort_hand() # NOT end_hand() — no showdown to resolve
61
+ break
62
+ if step.kind() == "HandComplete":
63
+ session.end_hand()
64
+ break
65
+ if step.kind() == "PlayerToAct":
66
+ session.apply_action(step.seat(), decide(step.seat()))
67
+ ```
68
+
69
+ Verified with `make ayce`: 228 pytest tests pass, `demo.py` and all three
70
+ examples (`the_hand.py`, `calc.py`, `gto.py`) run clean.
71
+
72
+ ---
73
+
74
+ ## [0.2.1] - 2026-07-10
75
+
76
+ ### Changed
77
+
78
+ - Bumped `pkcore` dependency from `0.2.0` to `0.2.1`.
79
+ - Bumped `pkpy` crate version to `0.2.1` to stay in lockstep with `pkcore`.
80
+
81
+ ### Security (inherited from `pkcore` 0.2.1)
82
+
83
+ `pkcore` 0.2.1 is a dependency-hygiene patch with **no public API, behavior, or
84
+ wire-format changes** — the postcard binary encoding is byte-identical, so solver
85
+ caches and hand-history data are unaffected. It carries two supply-chain fixes that
86
+ flow through to pkpy's dependency tree:
87
+
88
+ - **`crossbeam-epoch` 0.9.18 → 0.9.20 (RUSTSEC-2026-0204).** Fixes an invalid pointer
89
+ dereference in `crossbeam-epoch`'s `fmt::Pointer`/`Display` impl. Pulled in
90
+ transitively via `rayon`; a lockfile-only change.
91
+ - **`atomic-polyfill` (RUSTSEC-2023-0089) removed from the tree.** `pkcore` now builds
92
+ `postcard` with `default-features = false`, dropping the default `heapless-cas`
93
+ feature that pulled the unmaintained `atomic-polyfill` crate. It is gone from
94
+ pkpy's dependency graph after this bump.
95
+
96
+ ### Migration notes
97
+
98
+ - Public Rust API of `pkcore` is **unchanged**. No method signatures, types, or
99
+ imports moved. pkpy compiles clean against `pkcore 0.2.1` with no source changes
100
+ (verified via `cargo check` against local `pkcore 0.2.1`).
101
+ - No Python-facing behavior changes: the same bindings, method names, and return
102
+ values as under `pkcore 0.2.0`.
103
+
104
+ ---
105
+
106
+ ## [0.2.0] - 2026-07-08
107
+
108
+ > **Never published to PyPI.** This version was tagged in-tree but not released; its
109
+ > changes reach users for the first time bundled into 0.2.1. It is the first pkpy build
110
+ > on the `pkcore` 0.2.x line — pkpy migrated **directly from `pkcore` 0.0.54**, skipping
111
+ > the 0.1.x series.
112
+
113
+ ### Changed
114
+
115
+ - Bumped `pkcore` dependency from `0.0.54` to `0.2.0`, and enabled pkcore's **`store`
116
+ feature** explicitly. `pkcore` 0.2.0 moved storage/BCM and solver persistence behind
117
+ cargo features (previously always compiled in); pkpy now opts into `store` so BCM
118
+ loading and `SolverResult` save/load continue to work.
119
+ - Bumped `pkpy` crate version to `0.2.0` to stay in lockstep with `pkcore`.
120
+ - **Internal migration to pkcore 0.2.0's reorganized module tree** (the `casino` package
121
+ reorg and the `TableNoCell → Table` type rename). Import paths in the Rust binding layer
122
+ were updated (`casino::table::event` → `casino::action` / `casino::table_celled::event`,
123
+ `casino::table::seats::*` → `casino::equity::*`, `casino::table::winnings` →
124
+ `casino::winnings`, `casino::table_no_cell::TableNoCell` → `casino::table::Table`, etc.).
125
+
126
+ **No Python-facing class or method names changed.** pkpy deliberately preserves its
127
+ existing Python names — `TableNoCell`, `PlayerNoCell`, `SeatNoCell`, `SeatsNoCell`,
128
+ `TableAction`, `TableLog`, `SeatEquity`, `Seatbit`, `Winnings`, `PotWin`, and the rest —
129
+ so existing Python code imports and calls exactly the same symbols. The pkcore rename is
130
+ invisible from Python.
131
+
132
+ ### Behavior change (inherited from `pkcore` 0.2.0)
133
+
134
+ - **`DealEval(hole_cards)` is now fallible.** The constructor previously always succeeded;
135
+ it now raises a Python exception when the hole cards are invalid. This follows pkcore
136
+ 0.2.0 changing `DealEval::new` to return a `Result` as part of the panic-boundary /
137
+ error de-leak audit work. Wrap `DealEval(...)` in `try/except` if you pass unvalidated
138
+ input; the happy path is unchanged.
139
+ - Errors surfaced from the dealer/eval paths are now pkcore's own error enums (the 0.2.0
140
+ "no format-crate leak" change). pkpy still maps them to Python exceptions via the same
141
+ `to_py_err` path, so raised exception messages may differ slightly from 0.0.54.
142
+
143
+ ### Migration notes
144
+
145
+ - **No Python source changes required** for typical usage: same class names, same methods,
146
+ same imports.
147
+ - The one behavioral gotcha is `DealEval(...)` now raising on invalid hole cards instead of
148
+ being infallible.
149
+ - Card `Display` / `FromStr` string forms (e.g. `"6♠ 6♥"`) and serialized representations
150
+ are unchanged, so data produced under 0.0.54 remains readable.
151
+
152
+ ---
153
+
154
+ ## [0.0.54] - 2026-04-30
155
+
156
+ ### Changed
157
+
158
+ - Bumped `pkcore` dependency from `0.0.53` to `0.0.54`.
159
+ - Bumped `pkpy` crate version to `0.0.54` to stay in lockstep with `pkcore`.
160
+
161
+ ### Fixed (inherited from `pkcore` 0.0.54)
162
+
163
+ No pkpy code was modified for this release, but the upstream fix changes
164
+ observable behavior on one Python-exposed method, `TableNoCell.to_call()`.
165
+
166
+ - **Short-stacked big blind — call target now anchored to the configured BB.**
167
+ When the BB is all-in for less than the configured big blind (e.g. BB=100
168
+ but stack=30), `TableNoCell.to_call()` now returns the full configured BB
169
+ (`100`) instead of the amount the BB physically posted (`30`). Other
170
+ players must call the full configured amount; chip conservation is
171
+ preserved at showdown via side-pot stratification (multiway) or
172
+ uncalled-bet returns (heads-up / no second contestant at that tier).
173
+ This matches standard cardroom rules (TDA, WSOP).
174
+ - **`act_call` now degrades gracefully when the caller is short.** When a
175
+ caller cannot cover the call target, the action is converted to an
176
+ all-in for the caller's remaining stack rather than erroring on
177
+ insufficient chips. Surfaced through pkpy via `PokerSession.apply_action`.
178
+ - **`min_raise` stays anchored to the configured BB** even when the BB is
179
+ all-in for less. Prior behavior could allow under-sized raises in the
180
+ short-BB scenario.
181
+
182
+ ### Migration notes
183
+
184
+ - Public Rust API of `pkcore` is **unchanged**. No method signatures, types,
185
+ or imports moved. pkpy compiles clean against `pkcore 0.0.54` with no
186
+ source changes.
187
+ - If you have Python code that asserts specific chip math against a
188
+ short-stacked-BB scenario built on pkcore 0.0.53 semantics, those
189
+ assertions will need to be updated. The pkpy test suite does not
190
+ currently exercise this scenario, so the in-tree tests remain green.
191
+
192
+ ---
193
+
194
+ Earlier releases pre-date this changelog. See `git log` for prior history.