python-math #14: feat(math): degenerate-tick group-clusterings overwrite + <2-participants edge (legacy mode) - #2642
Draft
jucor wants to merge 1 commit into
Draft
python-math #14: feat(math): degenerate-tick group-clusterings overwrite + <2-participants edge (legacy mode)#2642jucor wants to merge 1 commit into
jucor wants to merge 1 commit into
Conversation
This was referenced Jul 22, 2026
Draft
Draft
Draft
Draft
jucor
marked this pull request as draft
July 22, 2026 00:51
This was referenced Jul 25, 2026
Draft
Draft
Draft
python-math #43: docs(delphi): s7 goal state + journal — mode collapse executed, battery 20/20
#2672
Draft
Draft
Draft
3 tasks
…ite + <2-participants edge (legacy mode)
## What
Ports the approved 2026-07-21 Opus review verdict covering quirks Q4 and Q5 from `delphi/docs/CLOJURE_QUIRKS.md` into clojure-legacy mode (the engine setting that reproduces the old Clojure engine's behavior exactly):
- Quirk Q4 (degenerate ticks still cluster): Clojure recomputes `:group-clusterings` EVERY tick unconditionally — `max-k-fn` is always >= 2 (conversation.clj:274-279) — so a tick with only 1 base cluster still runs k=2 kmeans on a single point. The clean-start initialization caps k at the number of distinct points, yielding 1 cluster carrying a lineage id; that degenerate value OVERWRITES `:group-clusterings`; and the recovery tick warm-starts from it, minting split ids via `(inc max-id)` (clusters.clj:267).
- Quirk Q5 (<2-participants edge): Clojure also has no guard for fewer than 2 in-conv participants (the set of participants admitted to clustering) beyond the truly-empty short-circuit — a 1-participant tick runs the full pipeline.
## How it works
clojure-legacy mode now skips both early returns and falls through to the normal legacy path, which reproduces all of the above exactly: the max_k arithmetic yields the k range [2]; `calculate_silhouette_sklearn` returns the 0.0 sentinel for singleton clusterings, matching Clojure's singleton rule (clusters.clj:350-353); and the advance of the group-k smoother (ported earlier in this stack as PR P6a) is preserved with the same `{2: 0.0}` input via the main path — the branch-local P6a advance block is removed as dead code. The 0-participant early return stays in both modes: it is unreachable past the empty short-circuit given the greedy in-conv floor from PR-E (#2623). improved mode (the engine setting that keeps Python's corrected behavior) keeps both guards byte-for-byte.
## Testing
TDD: `tests/test_degenerate_tick_parity.py` was RED on the old code for the pinned divergences (stale 2-cluster group_clusterings after a collapse tick; empty structures on a single-participant tick), GREEN after. Existing P6a smoother tests are unchanged and green (24 passed with `test_group_k_smoother.py`; 37 passed with the lineage / greedy-carry / pca-warm-start / engine-mode neighbor suites).
commit-id:bbb74f71
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
Ports the approved 2026-07-21 Opus review verdict covering quirks Q4 and Q5 from
delphi/docs/CLOJURE_QUIRKS.mdinto clojure-legacy mode (the engine setting that reproduces the old Clojure engine's behavior exactly)::group-clusteringsEVERY tick unconditionally —max-k-fnis always >= 2 (conversation.clj:274-279) — so a tick with only 1 base cluster still runs k=2 kmeans on a single point. The clean-start initialization caps k at the number of distinct points, yielding 1 cluster carrying a lineage id; that degenerate value OVERWRITES:group-clusterings; and the recovery tick warm-starts from it, minting split ids via(inc max-id)(clusters.clj:267).How it works
clojure-legacy mode now skips both early returns and falls through to the normal legacy path, which reproduces all of the above exactly: the max_k arithmetic yields the k range [2];
calculate_silhouette_sklearnreturns the 0.0 sentinel for singleton clusterings, matching Clojure's singleton rule (clusters.clj:350-353); and the advance of the group-k smoother (ported earlier in this stack as PR P6a) is preserved with the same{2: 0.0}input via the main path — the branch-local P6a advance block is removed as dead code. The 0-participant early return stays in both modes: it is unreachable past the empty short-circuit given the greedy in-conv floor from PR-E (#2623). improved mode (the engine setting that keeps Python's corrected behavior) keeps both guards byte-for-byte.Testing
TDD:
tests/test_degenerate_tick_parity.pywas RED on the old code for the pinned divergences (stale 2-cluster group_clusterings after a collapse tick; empty structures on a single-participant tick), GREEN after. Existing P6a smoother tests are unchanged and green (24 passed withtest_group_k_smoother.py; 37 passed with the lineage / greedy-carry / pca-warm-start / engine-mode neighbor suites).commit-id:bbb74f71
Stack: