Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions agent-notes/fix-integer-distance-issue-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Assignment-selection issue 3

## Goal
Fix integer distance precision and open a draft PR without merging or changing Propstore pins/source.

## State
Separate worktree/branch fix/integer-distance-issue-3, based on published d855496. Global instructions and repo source/tests/CI read; no local AGENTS.md/CLAUDE.md found. Focused dependency fixes and regression tests explicitly authorized by parent delegation.

## Smallest change and decision
About four source lines: subtract int/int endpoints exactly, then convert the difference to the existing float distance type. Preserve float/numeric-coercion/categorical behavior for all other input pairs. About forty regression-test lines cover adjacent signed-64-bit integers and SIGMA's unique majority winner. No new metric policy or broader numeric redesign.

## Next step
The new tests failed in all six cases before the change (four unit-distance cases and two SIGMA winner cases). After the four-line source fix, the same command passed all six in 0.49s:

`uv run --no-project --offline --python C:/Users/Q/code/assignment-selection/.venv/Scripts/python.exe python -B -m pytest -p no:cacheprovider tests/test_integer_distances.py -q`

PYTHONPATH selected this worktree's src; UV_CACHE_DIR selected its isolated cache. No dependencies installed. Full suite and typing will run in PR CI.

Q separately approved the citation-only edit to issue #3. Replaced only the Propstore solve-owner line anchor 265 with 236, fetched the issue, and verified exact body equality with that one substitution.

Published draft PR https://github.com/ctoth/assignment-selection/pull/4 at source commit 175d32533dc233cb25969154b9f8ca383a996294. Fetched the PR and verified its draft status and exact head. CI run 39339378017 passed all typing/test jobs on Python 3.11, 3.12, and 3.13. No merge or ready transition performed. This final note update records that outcome; verify the note-only final head before handoff.
5 changes: 4 additions & 1 deletion src/assignment_selection/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class EnumerationExceeded:
def claim_distance(a: Any, b: Any) -> float:
"""Distance between two claim values."""
try:
distance = abs(float(a) - float(b))
if isinstance(a, int) and isinstance(b, int):
distance = float(abs(a - b))
else:
distance = abs(float(a) - float(b))
except (ValueError, TypeError):
return 0.0 if a == b else 1.0
if not isfinite(distance):
Expand Down
37 changes: 37 additions & 0 deletions tests/test_integer_distances.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from __future__ import annotations

import pytest

from assignment_selection import Assignment, Problem, SourceAssignment, solve
from assignment_selection.solver import claim_distance


@pytest.mark.parametrize(
"left,right",
[
(2**53, 2**53 + 1),
(2**63 - 2, 2**63 - 1),
(-(2**53), -(2**53) - 1),
(-(2**63), -(2**63) + 1),
],
)
def test_adjacent_large_integers_have_unit_distance(left: int, right: int) -> None:
assert claim_distance(left, right) == 1.0
assert claim_distance(right, left) == 1.0


@pytest.mark.parametrize("majority", [2**53, -(2**63)])
def test_sigma_selects_the_majority_of_adjacent_large_integers(majority: int) -> None:
minority = majority + 1
sources = tuple(
SourceAssignment(str(index), Assignment({"x": value}))
for index, value in enumerate((majority, majority, minority))
)

result = solve(Problem(("x",), sources))

assert tuple(winner.value_for("x") for winner in result.winners) == (majority,)
assert tuple(
(candidate.assignment.value_for("x"), candidate.score)
for candidate in result.scored_candidates
) == ((majority, 1.0), (minority, 2.0))
Loading