Skip to content

python-math #29: feat(math): moderation + restart replay parity — mod_update, restart-seam restore, Q13-Q18 - #2656

Draft
jucor wants to merge 1 commit into
spr/edge/90ba0c34from
spr/edge/9467ac51
Draft

python-math #29: feat(math): moderation + restart replay parity — mod_update, restart-seam restore, Q13-Q18#2656
jucor wants to merge 1 commit into
spr/edge/90ba0c34from
spr/edge/9467ac51

Conversation

@jucor

@jucor jucor commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

What

Certification-battery coverage (the battery: recorded real-conversation vote schedules replayed through both engines and compared step by step) for the goal-doc's moderation-heavy, meta-tids (comments flagged is_meta) and restart-seam edge cases, plus the quirks they surfaced. All TDD, ledgered in CLOJURE_QUIRKS.md; design in MOD_RESTART_PORT_SPEC.md.

Engine ports

  • Conversation.mod_update: parity with Clojure's mod-update reducer (conversation.clj:846-884) — a comment flagged is_meta lands in BOTH mod sets, un-moderation removes via disj, application is order-sensitive, and the moderation watermark takes a max floor.
  • Quirk Q15: legacy recompute() drops the moderation watermark, because Clojure's conv-update plumbing graph has no :last-mod-timestamp node — replicated.
  • Quirk Q16: rank-1 principal components collapse ALL projections to [0,0] (Clojure's utils/zip truncates when pc2 is nil) — replicated at both projection helpers; found by review-driven 1xN/Nx1 tiny-shape tests with Clojure-derived reference values.
  • group-votes tally source: tallies read from raw-rating-mat (the raw, pre-moderation-filter rating matrix; conversation.clj:601-608) at ALL THREE tally sites — the compute path, the inline to_dict, and to_dynamo_dict.

Replay drivers

  • Mod-event weaving: votes-then-moderation per batch, one result blob (the JSON math result) per step, plus a load-or-init restart seam (kill the engine mid-schedule, then resume from the persisted blob) — both in BOTH drivers. The blob round-trips via db/load-conv's longs-else-keywords key-fn and restructure-json-conv, with full-history raw-rating-mat and mod-update; the Clojure seam was validated bit-identical pre-seam vs cached recordings.
  • Restart-seam restore (2026-07-24): Conversation.from_dict now restores zid (blobs emit 'zid' in both engine modes), base-clusters (unfold + the legacy un-negate — the warm-start lineage input), and group-votes (tid keys re-intified — the recovery tick's previous-tick priorities input, per quirk Q2: comment priorities always read the PREVIOUS tick's stored group-votes) — mirroring Clojure's restructure-json-conv (conv_man.clj:171-186). Both restart battery entries MATCH at every step.
  • Restart-driver review fixes: at the seam, replay woven mods only (Clojure restart-conv's (mapcat :mods steps-so-far), never dataset.mod_events); restart_after range validation; modified-only comments-CSV header (is-meta optional); to_dynamo_dict tally gate.

Quirks resolved this round

  • Q17 PORTED: legacy cluster_step resolves k-means distance ties by Clojure's cleared-clusters map iteration order — insertion order for <=8 clusters, PersistentHashMap trie order (via clj_hash) for >8. Quirk Q11's cancellation floor (the Clojure distance formula floors near-coincident distances to exactly 0.0) makes exact 0.0 ties common, not measure-zero.
  • Q18 CARVED out of certification: uniqify merge-center exactness is value-dependent ulp luck, amplified by exact-equality comparison over ~1e-16 cross-engine PCA noise (real-vectorz evidence recorded in the quirk row). Consequently pc-modheavy-01 + pc-meta-01 are re-scheduled to single-cut-mod (cold tick, full moderation weave — deterministic), and a NEW entry pc-meta-02 (moderate coincidence density) carries the warm-chain mod/meta coverage.

Tooling + results

  • prodclone extractor (pulls datasets from the production-database clone): additive is-meta/modified comment columns; certify passes --comments for moderation schedules.
  • Battery: 20 entries — 20/20 MATCH on TWO consecutive full passes (2026-07-24); divergences.json at 0 open (70 resolved + 11 carved-out).

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

commit-id:9467ac51


Stack:


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

This was referenced Jul 22, 2026
@jucor
jucor force-pushed the spr/edge/90ba0c34 branch from a628d9e to c94d602 Compare July 22, 2026 11:23
This was referenced Jul 27, 2026
@jucor
jucor force-pushed the spr/edge/9467ac51 branch from 3f5ceff to 5f9f031 Compare July 28, 2026 00:11
@jucor
jucor force-pushed the spr/edge/90ba0c34 branch from 3f3411c to 5d45782 Compare July 28, 2026 00:12
@jucor jucor changed the title feat(math): moderation + restart replay parity — mod_update, restart-seam restore, Q13-Q18 python-math #29: feat(math): moderation + restart replay parity — mod_update, restart-seam restore, Q13-Q18 Jul 28, 2026
…_update, restart-seam restore, Q13-Q18

## What

Certification-battery coverage (the battery: recorded real-conversation vote schedules replayed through both engines and compared step by step) for the goal-doc's moderation-heavy, meta-tids (comments flagged `is_meta`) and restart-seam edge cases, plus the quirks they surfaced. All TDD, ledgered in `CLOJURE_QUIRKS.md`; design in `MOD_RESTART_PORT_SPEC.md`.

## Engine ports

- `Conversation.mod_update`: parity with Clojure's `mod-update` reducer (`conversation.clj:846-884`) — a comment flagged `is_meta` lands in BOTH mod sets, un-moderation removes via `disj`, application is order-sensitive, and the moderation watermark takes a max floor.
- Quirk Q15: legacy `recompute()` drops the moderation watermark, because Clojure's `conv-update` plumbing graph has no `:last-mod-timestamp` node — replicated.
- Quirk Q16: rank-1 principal components collapse ALL projections to `[0,0]` (Clojure's `utils/zip` truncates when pc2 is nil) — replicated at both projection helpers; found by review-driven 1xN/Nx1 tiny-shape tests with Clojure-derived reference values.
- group-votes tally source: tallies read from `raw-rating-mat` (the raw, pre-moderation-filter rating matrix; `conversation.clj:601-608`) at ALL THREE tally sites — the compute path, the inline `to_dict`, and `to_dynamo_dict`.

## Replay drivers

- Mod-event weaving: votes-then-moderation per batch, one result blob (the JSON math result) per step, plus a load-or-init restart seam (kill the engine mid-schedule, then resume from the persisted blob) — both in BOTH drivers. The blob round-trips via `db/load-conv`'s longs-else-keywords key-fn and `restructure-json-conv`, with full-history `raw-rating-mat` and `mod-update`; the Clojure seam was validated bit-identical pre-seam vs cached recordings.
- Restart-seam restore (2026-07-24): `Conversation.from_dict` now restores `zid` (blobs emit `'zid'` in both engine modes), base-clusters (unfold + the legacy un-negate — the warm-start lineage input), and group-votes (tid keys re-intified — the recovery tick's previous-tick priorities input, per quirk Q2: comment priorities always read the PREVIOUS tick's stored group-votes) — mirroring Clojure's `restructure-json-conv` (`conv_man.clj:171-186`). Both restart battery entries MATCH at every step.
- Restart-driver review fixes: at the seam, replay woven mods only (Clojure `restart-conv`'s `(mapcat :mods steps-so-far)`, never `dataset.mod_events`); `restart_after` range validation; modified-only comments-CSV header (`is-meta` optional); `to_dynamo_dict` tally gate.

## Quirks resolved this round

- Q17 PORTED: legacy `cluster_step` resolves k-means distance ties by Clojure's cleared-clusters map iteration order — insertion order for <=8 clusters, PersistentHashMap trie order (via `clj_hash`) for >8. Quirk Q11's cancellation floor (the Clojure distance formula floors near-coincident distances to exactly 0.0) makes exact 0.0 ties common, not measure-zero.
- Q18 CARVED out of certification: `uniqify` merge-center exactness is value-dependent ulp luck, amplified by exact-equality comparison over ~1e-16 cross-engine PCA noise (real-vectorz evidence recorded in the quirk row). Consequently `pc-modheavy-01` + `pc-meta-01` are re-scheduled to single-cut-mod (cold tick, full moderation weave — deterministic), and a NEW entry `pc-meta-02` (moderate coincidence density) carries the warm-chain mod/meta coverage.

## Tooling + results

- prodclone extractor (pulls datasets from the production-database clone): additive `is-meta`/`modified` comment columns; certify passes `--comments` for moderation schedules.
- Battery: 20 entries — 20/20 MATCH on TWO consecutive full passes (2026-07-24); `divergences.json` at 0 open (70 resolved + 11 carved-out).

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

commit-id:9467ac51
@jucor
jucor force-pushed the spr/edge/90ba0c34 branch from 5d45782 to d1cb4c7 Compare July 28, 2026 01:10
@jucor
jucor force-pushed the spr/edge/9467ac51 branch from 5f9f031 to 042deef Compare July 28, 2026 01:10
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.

2 participants