python-math #5: feat(math): add POLISMATH_ENGINE_MODE flag + prev-tick warm-start scaffolding (PR-A) - #2618
Draft
jucor wants to merge 1 commit into
Draft
python-math #5: feat(math): add POLISMATH_ENGINE_MODE flag + prev-tick warm-start scaffolding (PR-A)#2618jucor wants to merge 1 commit into
jucor wants to merge 1 commit into
Conversation
This was referenced Jul 18, 2026
Draft
jucor
marked this pull request as draft
July 18, 2026 01:48
This was referenced Jul 18, 2026
This was referenced Jul 18, 2026
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
Closed
This was referenced Jul 27, 2026
Draft
Draft
python-math #43: docs(delphi): s7 goal state + journal — mode collapse executed, battery 20/20
#2672
Draft
Draft
Draft
5 tasks
3 tasks
…k warm-start scaffolding (PR-A)
## What
Introduces `POLISMATH_ENGINE_MODE`, the engine-mode switch that will select between Clojure-parity warm-start behavior (`clojure-legacy` — the setting that reproduces the old Clojure engine's tick-to-tick behavior exactly) and the current cold-recompute behavior (`improved`, the default). This commit only adds the flag and the plumbing to capture the previous tick's state (a tick = one incremental math recompute over newly arrived votes); no behavior changes yet — the follow-up commits PR-B and PR-D consume the captured state.
## Changes
- New `polismath/utils/engine_mode.py`: `ENGINE_MODE_*` constants + `resolve_engine_mode()`, reusing `pca._resolve_impl_flag` (`pca.py:37-57`) so resolution rules match the PCA-solver switch. Default `improved`.
- `Conversation.__init__` gains cold-default fields `group_clusterings={}` and `group_k_smoother={}` (the Clojure engine threads these on the conversation object across ticks, `conversation.clj:433-484`; NOT persisted, per `conv_man.clj:52-74`).
- `recompute()` captures `prev_pca` / `prev_group_clusterings` / `prev_group_k_smoother` from the deepcopied `result` BEFORE the compute steps overwrite them (mirroring the Clojure fnks that read the incoming conversation: `conversation.clj:385, 457`) and threads them into `_compute_pca` / `_compute_clusters` as optional params (unused in this commit).
## Testing
TDD RED evidence (before implementing `engine_mode.py`): `tests/test_engine_mode.py` collection error — "ModuleNotFoundError: No module named 'polismath.utils.engine_mode'".
Cold-start invariance guard: a single-shot pipeline run on the small `vw` test conversation dataset is byte-identical under both modes (first-tick warm-start state is empty, so the modes must coincide). This guards PR-B and PR-D against drifting on the cold path.
Tests: 8 new (7 flag-resolution + 1 cold invariance). Full suite 414 passed, 17 skipped, 47 xfailed (was 406/17/47).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
commit-id:d61d82ad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Introduces
POLISMATH_ENGINE_MODE, the engine-mode switch that will select between Clojure-parity warm-start behavior (clojure-legacy— the setting that reproduces the old Clojure engine's tick-to-tick behavior exactly) and the current cold-recompute behavior (improved, the default). This commit only adds the flag and the plumbing to capture the previous tick's state (a tick = one incremental math recompute over newly arrived votes); no behavior changes yet — the follow-up commits PR-B and PR-D consume the captured state.Changes
polismath/utils/engine_mode.py:ENGINE_MODE_*constants +resolve_engine_mode(), reusingpca._resolve_impl_flag(pca.py:37-57) so resolution rules match the PCA-solver switch. Defaultimproved.Conversation.__init__gains cold-default fieldsgroup_clusterings={}andgroup_k_smoother={}(the Clojure engine threads these on the conversation object across ticks,conversation.clj:433-484; NOT persisted, perconv_man.clj:52-74).recompute()capturesprev_pca/prev_group_clusterings/prev_group_k_smootherfrom the deepcopiedresultBEFORE the compute steps overwrite them (mirroring the Clojure fnks that read the incoming conversation:conversation.clj:385, 457) and threads them into_compute_pca/_compute_clustersas optional params (unused in this commit).Testing
TDD RED evidence (before implementing
engine_mode.py):tests/test_engine_mode.pycollection error — "ModuleNotFoundError: No module named 'polismath.utils.engine_mode'".Cold-start invariance guard: a single-shot pipeline run on the small
vwtest conversation dataset is byte-identical under both modes (first-tick warm-start state is empty, so the modes must coincide). This guards PR-B and PR-D against drifting on the cold path.Tests: 8 new (7 flag-resolution + 1 cold invariance). Full suite 414 passed, 17 skipped, 47 xfailed (was 406/17/47).
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
commit-id:d61d82ad
Stack: