Skip to content

feat(math): add POLISMATH_ENGINE_MODE flag + prev-tick warm-start scaffolding (PR-A)#2618

Draft
jucor wants to merge 1 commit into
spr/edge/2324207efrom
spr/edge/d61d82ad
Draft

feat(math): add POLISMATH_ENGINE_MODE flag + prev-tick warm-start scaffolding (PR-A)#2618
jucor wants to merge 1 commit into
spr/edge/2324207efrom
spr/edge/d61d82ad

Conversation

@jucor

@jucor jucor commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Introduces the engine-mode switch that will select between Clojure-parity
warm-start (clojure-legacy) and the current cold-recompute behavior
(improved, default). This commit only adds the flag and the plumbing to
capture the previous tick's state; no behavior changes yet (commits B and D
consume the captured state).

  • 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={} (Clojure threads these on the conv,
    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 (mirrors Clojure fnks reading the incoming conv:
    conversation.clj:385, 457) and threads them into _compute_pca /
    _compute_clusters as optional params (unused in this commit).

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 vw pipeline run is byte-identical
under both modes (first-tick warm-start state is empty, so the modes must
coincide). This guards commits B and D from 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:


⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

@jucor
jucor marked this pull request as draft July 18, 2026 01:48
@jucor
jucor force-pushed the spr/edge/d61d82ad branch from d27ed5f to 29d0998 Compare July 18, 2026 01:59
@jucor jucor changed the title feat(math): add POLISMATH_ENGINE_MODE flag + prev-tick warm-start scaffolding (PR-A) feat(math): add POLISMATH_ENGINE_MODE flag + prev-tick warm-start sca… Jul 18, 2026
@jucor
jucor changed the base branch from spr/edge/c9daf6b3 to edge July 18, 2026 13:27
@jucor
jucor force-pushed the spr/edge/d61d82ad branch from 29d0998 to 4d179bd Compare July 18, 2026 13:28
@jucor jucor changed the title feat(math): add POLISMATH_ENGINE_MODE flag + prev-tick warm-start sca… feat(math): add POLISMATH_ENGINE_MODE flag + prev-tick warm-start scaffolding (PR-A) Jul 18, 2026
@jucor jucor mentioned this pull request Jul 18, 2026
@jucor
jucor changed the base branch from edge to spr/edge/d83b0abf July 18, 2026 13:28
@jucor
jucor force-pushed the spr/edge/d83b0abf branch from 43e896f to e345a89 Compare July 18, 2026 13:32
@jucor
jucor force-pushed the spr/edge/d61d82ad branch from 4d179bd to 70c0597 Compare July 18, 2026 13:32
…ffolding (PR-A)

Introduces the engine-mode switch that will select between Clojure-parity
warm-start (`clojure-legacy`) and the current cold-recompute behavior
(`improved`, default). This commit only adds the flag and the plumbing to
capture the previous tick's state; no behavior changes yet (commits B and D
consume the captured state).

- 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={} (Clojure threads these on the conv,
  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 (mirrors Clojure fnks reading the incoming conv:
  conversation.clj:385, 457) and threads them into _compute_pca /
  _compute_clusters as optional params (unused in this commit).

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 vw pipeline run is byte-identical
under both modes (first-tick warm-start state is empty, so the modes must
coincide). This guards commits B and D from 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
@jucor
jucor force-pushed the spr/edge/d83b0abf branch from e345a89 to 68467f1 Compare July 18, 2026 13:35
@jucor
jucor force-pushed the spr/edge/d61d82ad branch from 70c0597 to 5144dc9 Compare July 18, 2026 13:35
@github-actions

Copy link
Copy Markdown

Delphi Coverage Report

File Stmts Miss Cover
init.py 2 0 100%
benchmarks/bench_pca.py 128 107 16%
benchmarks/bench_repness.py 81 65 20%
benchmarks/bench_update_votes.py 38 28 26%
benchmarks/benchmark_utils.py 34 24 29%
components/init.py 1 0 100%
components/config.py 165 133 19%
conversation/init.py 2 0 100%
conversation/conversation.py 1113 258 77%
conversation/manager.py 131 42 68%
database/init.py 1 0 100%
database/dynamodb.py 395 189 52%
database/postgres.py 306 206 33%
pca_kmeans_rep/init.py 5 0 100%
pca_kmeans_rep/clusters.py 257 21 92%
pca_kmeans_rep/corr.py 98 17 83%
pca_kmeans_rep/pca.py 136 18 87%
pca_kmeans_rep/repness.py 208 9 96%
regression/init.py 4 0 100%
regression/clojure_comparer.py 188 20 89%
regression/comparer.py 887 661 25%
regression/datasets.py 135 27 80%
regression/recorder.py 36 27 25%
regression/utils.py 138 94 32%
replay/init.py 2 0 100%
replay/driver.py 51 2 96%
replay/real_data.py 19 2 89%
replay/schedule.py 125 6 95%
replay/stepcompare.py 76 1 99%
replay/store.py 119 11 91%
replay/types.py 65 8 88%
run_math_pipeline.py 261 114 56%
umap_narrative/500_generate_embedding_umap_cluster.py 210 109 48%
umap_narrative/501_calculate_comment_extremity.py 112 53 53%
umap_narrative/502_calculate_priorities.py 135 135 0%
umap_narrative/700_datamapplot_for_layer.py 502 502 0%
umap_narrative/701_static_datamapplot_for_layer.py 310 310 0%
umap_narrative/702_consensus_divisive_datamapplot.py 432 432 0%
umap_narrative/801_narrative_report_batch.py 785 785 0%
umap_narrative/802_process_batch_results.py 268 268 0%
umap_narrative/803_check_batch_status.py 183 183 0%
umap_narrative/llm_factory_constructor/init.py 2 2 0%
umap_narrative/llm_factory_constructor/model_provider.py 192 192 0%
umap_narrative/polismath_commentgraph/init.py 1 0 100%
umap_narrative/polismath_commentgraph/cli.py 270 270 0%
umap_narrative/polismath_commentgraph/core/init.py 3 3 0%
umap_narrative/polismath_commentgraph/core/clustering.py 108 108 0%
umap_narrative/polismath_commentgraph/core/embedding.py 104 104 0%
umap_narrative/polismath_commentgraph/lambda_handler.py 219 219 0%
umap_narrative/polismath_commentgraph/schemas/init.py 2 0 100%
umap_narrative/polismath_commentgraph/schemas/dynamo_models.py 160 9 94%
umap_narrative/polismath_commentgraph/tests/conftest.py 17 17 0%
umap_narrative/polismath_commentgraph/tests/test_clustering.py 74 74 0%
umap_narrative/polismath_commentgraph/tests/test_embedding.py 55 55 0%
umap_narrative/polismath_commentgraph/tests/test_storage.py 87 87 0%
umap_narrative/polismath_commentgraph/utils/init.py 3 0 100%
umap_narrative/polismath_commentgraph/utils/converter.py 283 237 16%
umap_narrative/polismath_commentgraph/utils/group_data.py 354 336 5%
umap_narrative/polismath_commentgraph/utils/storage.py 584 518 11%
umap_narrative/reset_conversation.py 159 50 69%
umap_narrative/run_pipeline.py 453 312 31%
utils/engine_mode.py 9 0 100%
utils/general.py 62 41 34%
Total 11345 7501 34%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant