Skip to content

feat(math): in-conv greedy floor + persistent carry (PR-E)#2623

Draft
jucor wants to merge 1 commit into
spr/edge/ca2af3c7from
spr/edge/a861cd87
Draft

feat(math): in-conv greedy floor + persistent carry (PR-E)#2623
jucor wants to merge 1 commit into
spr/edge/ca2af3c7from
spr/edge/a861cd87

Conversation

@jucor

@jucor jucor commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Port the two Clojure :in-conv steps the Python pipeline was missing
(conversation.clj:243-269) into the 'clojure-legacy' engine mode of
Conversation._get_in_conv_participants. Improved mode (default) is unchanged
(threshold set only, no carry, no greedy floor).

Legacy mode now, every tick:

  1. CARRY: unions the vote-threshold set (>= min(7, n_cmts) votes) into the
    PERSISTENT in-conv set carried on the conv ((or (:in-conv conv) #{}),
    conversation.clj:247), so a participant, once in, never leaves.
  2. GREEDY FLOOR: if fewer than 15 participants are in, greedily admits the
    top 15 - n remaining participants by vote count descending, INCLUDING
    below-threshold voters (conversation.clj:259-268), and persists them.
    The persisted set feeds base clustering (which matrix rows) and is serialized
    as the blob :in-conv (to_dict), matching the clustered rows.

self.in_conv is threaded in-memory across update_votes (deepcopy in recompute),
NOT persisted to dynamo — same lifetime as the PCA/smoother/cluster warm state.

Greedy tie rule: Clojure sorts a hash-map with (sort-by (comp - second)),
whose order among EQUAL vote counts is hash-map iteration order — inherently
non-deterministic. We break ties by matrix ROW ORDER (user-vote-counts
insertion order) via a STABLE sort — a deterministic, reproducible surrogate
for that underspecified Clojure tie case. Flagged for the integrator.

RED evidence (against PR-C HEAD, before this commit):

  • test_legacy_greedy_fills_to_fifteen: got 2 (threshold only) != 15.
  • test_legacy_greedy_tie_break_is_row_order: lows never admitted.
  • carry / self.in_conv tests: AttributeError (no in_conv field / no greedy).
    GREEN: 9 new tests pass; full suite 520 passed / 17 skipped / 47 xfailed (was
    511 after PR-C), zero regressions. The vw cold-identity gate stays green (67
    in-conv > 15, so no greedy fires and the serialized :in-conv is unchanged).

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

commit-id:a861cd87


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 02:29
@jucor
jucor force-pushed the spr/edge/a861cd87 branch from d65c2ef to 55b02d5 Compare July 18, 2026 13:28
@jucor
jucor force-pushed the spr/edge/ca2af3c7 branch from 99c120b to 380f97a Compare July 18, 2026 13:28
@jucor
jucor force-pushed the spr/edge/a861cd87 branch from 55b02d5 to 7c607b1 Compare July 18, 2026 13:32
@jucor
jucor force-pushed the spr/edge/ca2af3c7 branch from 380f97a to 6a3085f Compare July 18, 2026 13:32
Port the two Clojure :in-conv steps the Python pipeline was missing
(conversation.clj:243-269) into the 'clojure-legacy' engine mode of
Conversation._get_in_conv_participants. Improved mode (default) is unchanged
(threshold set only, no carry, no greedy floor).

Legacy mode now, every tick:
  1. CARRY: unions the vote-threshold set (>= min(7, n_cmts) votes) into the
     PERSISTENT in-conv set carried on the conv (`(or (:in-conv conv) #{})`,
     conversation.clj:247), so a participant, once in, never leaves.
  2. GREEDY FLOOR: if fewer than 15 participants are in, greedily admits the
     top `15 - n` remaining participants by vote count descending, INCLUDING
     below-threshold voters (conversation.clj:259-268), and persists them.
The persisted set feeds base clustering (which matrix rows) and is serialized
as the blob :in-conv (to_dict), matching the clustered rows.

self.in_conv is threaded in-memory across update_votes (deepcopy in recompute),
NOT persisted to dynamo — same lifetime as the PCA/smoother/cluster warm state.

Greedy tie rule: Clojure sorts a hash-map with `(sort-by (comp - second))`,
whose order among EQUAL vote counts is hash-map iteration order — inherently
non-deterministic. We break ties by matrix ROW ORDER (user-vote-counts
insertion order) via a STABLE sort — a deterministic, reproducible surrogate
for that underspecified Clojure tie case. Flagged for the integrator.

RED evidence (against PR-C HEAD, before this commit):
- test_legacy_greedy_fills_to_fifteen: got 2 (threshold only) != 15.
- test_legacy_greedy_tie_break_is_row_order: lows never admitted.
- carry / self.in_conv tests: AttributeError (no in_conv field / no greedy).
GREEN: 9 new tests pass; full suite 520 passed / 17 skipped / 47 xfailed (was
511 after PR-C), zero regressions. The vw cold-identity gate stays green (67
in-conv > 15, so no greedy fires and the serialized :in-conv is unchanged).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

commit-id:a861cd87
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