Skip to content

python-math #20: feat(delphi): acceptance canonicalization — suppress cross-engine ordering artifacts in certify comparer - #2648

Draft
jucor wants to merge 1 commit into
spr/edge/4a87a6aefrom
spr/edge/d1ae732b
Draft

python-math #20: feat(delphi): acceptance canonicalization — suppress cross-engine ordering artifacts in certify comparer#2648
jucor wants to merge 1 commit into
spr/edge/4a87a6aefrom
spr/edge/d1ae732b

Conversation

@jucor

@jucor jucor commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

What

Teaches the certify comparer to canonicalize both engines' result blobs before comparing, so pure ORDERING differences stop counting as divergences.

Array-order canonicalization

Clojure emits tids (comment ids) and in-conv (the participants admitted to clustering) — and everything positionally aligned to them: pca center / comps rows / comment arrays, base-clusters columns — in hash/insertion order; Python emits them sorted. Both blobs are internally consistent, so cross-engine array order is not a semantic divergence. canonicalize_blob() (crosslang.py) normalizes both sides inside project_acceptance:

  • tids sorted, with the tid-aligned pca arrays re-indexed alongside;
  • in-conv / mod-in / mod-out / meta-tids sorted when they are lists (None passes through);
  • base-clusters columns re-indexed by sorted id, members sorted;
  • group-clusters sorted by id, members sorted.

votes-base is deliberately NOT permuted — it is already sort-by-:id-aligned on both engines by construction (conversation.clj:593).

This kills ~850 of the ~1030 step-0 battery divergences as ordering artifacts; the residual real roots (sign convention, votes-base shape, emission gaps) are ledgered in docs/divergences.json.

PCA component-sign canonicalization

Also canonicalizes run-arbitrary PCA COMPONENT SIGNS: Clojure's first-tick power iteration has no start vectors, so its unseeded initialization flips component signs between ITS OWN runs (observed on a vw single-cut re-record: comps[1] and base-clusters.y negated versus the prior recording). Each component's sign is fixed deterministically (the max-|entry| coefficient made positive, evaluated after tid alignment), and every component-aligned array flips with it (comps row, comment-projection row, base-clusters x/y, group-clusters center[k]); pca.center is a data mean and never flips. An inconsistent flip (y negated without comps[1]) still diverges.

commit-id:d1ae732b


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 changed the title feat(delphi): acceptance canonicalization — suppress cross-engine ordering artifacts in certify comparer feat(delphi): acceptance canonicalization — suppress cross-engine ord… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/4a87a6ae to edge July 22, 2026 02:10
@jucor jucor changed the title feat(delphi): acceptance canonicalization — suppress cross-engine ord… feat(delphi): acceptance canonicalization — suppress cross-engine ordering artifacts in certify comparer Jul 22, 2026
@jucor
jucor changed the base branch from edge to spr/edge/4a87a6ae July 22, 2026 02:10
@jucor jucor changed the title feat(delphi): acceptance canonicalization — suppress cross-engine ordering artifacts in certify comparer feat(delphi): acceptance canonicalization — suppress cross-engine ord… Jul 22, 2026
@jucor
jucor changed the base branch from spr/edge/4a87a6ae to edge July 22, 2026 03:54
@jucor jucor changed the title feat(delphi): acceptance canonicalization — suppress cross-engine ord… feat(delphi): acceptance canonicalization — suppress cross-engine ordering artifacts in certify comparer Jul 22, 2026
This was referenced Jul 27, 2026
@jucor
jucor force-pushed the spr/edge/4a87a6ae branch from 8d6fafb to 9ac3280 Compare July 28, 2026 00:11
@jucor
jucor force-pushed the spr/edge/d1ae732b branch from a9b5866 to 129128f Compare July 28, 2026 00:11
@jucor jucor changed the title feat(delphi): acceptance canonicalization — suppress cross-engine ordering artifacts in certify comparer python-math #20: feat(delphi): acceptance canonicalization — suppress cross-engine ordering artifacts in certify comparer Jul 28, 2026
… cross-engine ordering artifacts in certify comparer

## What

Teaches the certify comparer to canonicalize both engines' result blobs before comparing, so pure ORDERING differences stop counting as divergences.

## Array-order canonicalization

Clojure emits tids (comment ids) and in-conv (the participants admitted to clustering) — and everything positionally aligned to them: pca center / comps rows / comment arrays, base-clusters columns — in hash/insertion order; Python emits them sorted. Both blobs are internally consistent, so cross-engine array order is not a semantic divergence. `canonicalize_blob()` (`crosslang.py`) normalizes both sides inside `project_acceptance`:

- tids sorted, with the tid-aligned pca arrays re-indexed alongside;
- in-conv / mod-in / mod-out / meta-tids sorted when they are lists (None passes through);
- base-clusters columns re-indexed by sorted id, members sorted;
- group-clusters sorted by id, members sorted.

`votes-base` is deliberately NOT permuted — it is already sort-by-`:id`-aligned on both engines by construction (conversation.clj:593).

This kills ~850 of the ~1030 step-0 battery divergences as ordering artifacts; the residual real roots (sign convention, votes-base shape, emission gaps) are ledgered in `docs/divergences.json`.

## PCA component-sign canonicalization

Also canonicalizes run-arbitrary PCA COMPONENT SIGNS: Clojure's first-tick power iteration has no start vectors, so its unseeded initialization flips component signs between ITS OWN runs (observed on a vw single-cut re-record: comps[1] and base-clusters.y negated versus the prior recording). Each component's sign is fixed deterministically (the max-|entry| coefficient made positive, evaluated after tid alignment), and every component-aligned array flips with it (comps row, comment-projection row, base-clusters x/y, group-clusters center[k]); `pca.center` is a data mean and never flips. An inconsistent flip (y negated without comps[1]) still diverges.

commit-id:d1ae732b
@jucor
jucor force-pushed the spr/edge/4a87a6ae branch from 9ac3280 to ee206ec Compare July 28, 2026 01:10
@jucor
jucor force-pushed the spr/edge/d1ae732b branch from 129128f to a268220 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