Skip to content

test: cross-engine regression coverage for unq on number lists#227

Merged
danieljohnmorris merged 2 commits into
mainfrom
fix/unq-hang-numbers
May 13, 2026
Merged

test: cross-engine regression coverage for unq on number lists#227
danieljohnmorris merged 2 commits into
mainfrom
fix/unq-hang-numbers

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

The 2026-05-11 edu-teacher persona report (lines 391 / 586 of ilo_assessment_feedback.md) said len unq xs hung with exit 137 / OOM on a L n of meaningful size. I went looking for the bug and could not reproduce it on main — at any size from [1,2,2,3] up to 100k all-unique elements, on any engine, in any path. The actual fix landed back in 5a30e00 (2026-03-06) which switched the list dedup path from raw-bits comparison to nanval_equal. That commit pre-dates the persona report by two months — they were almost certainly running a stale binary (their own entry #9 in the same batch documents ~/.cargo/bin/ilo being out of date and needing reinstall).

No code change here. The substantive fix is already in main. What was missing was lock-in coverage for unq on number lists specifically — tests/eval_inline.rs covered the text case but not the number-list case, so any future regression back to raw-bits comparison, RC mishandling, or quadratic blowup would slip through.

This PR adds that coverage across all three engines.

Repro

Before (claimed):

ilo 'f xs:L n>n;len unq xs' "[1,2,2,3]" → hang, exit 137

Now (verified on current main):

ilo 'f xs:L n>n;len unq xs' "[1,2,2,3]" → 3, exit 0, <50ms

Scaling check: 100k all-unique numbers → 100000, ~42ms. Linear in practice.

What's in the diff

Two commits, both additive:

  1. test: cross-engine regression for unq on number lists — new tests/regression_unq_numbers.rs with 24 tests (8 cases × 3 engines): persona repro, order preservation, all-same, empty, all-unique, floats, negatives/zero, and a 1000-element stress test that catches quadratic-blowup OOM.

  2. examples: unq on number lists — new examples/unq-numbers.ilo exercising the same shapes through the examples_engines harness for a second line of cross-engine coverage, and as an in-context example for future agents.

No production source touched.

Test plan

  • cargo fmt clean
  • cargo clippy --release --features cranelift --tests --all-targets clean
  • cargo test --release --features cranelift --test regression_unq_numbers → 24/24 pass
  • cargo test --release --features cranelift --test examples_engines → pass
  • cargo test --release --features cranelift full suite green (2861 lib + all integration suites, 0 failures)

Follow-ups

The unq list path is O(n²) (inner out.iter().any(nanval_equal) scan) but scales linearly in practice up to 100k elements thanks to auto-vectorisation of the equality compare. A hash-keyed rework would be a future optimisation, not a fix — no live bug forcing it, manifesto win is theoretical. Deferred.

After merge, the entry will move out of 🛠 In Progress into ✅ Addressed citing 5a30e00 + this PR.

Locks in the fix from 5a30e00 (unq list dedup via nanval_equal) across
tree, VM, and Cranelift engines. The original persona report claimed
len unq xs hung with exit 137 on a L n of meaningful size; cannot
reproduce on current main, but adding coverage so any future drift
back to raw-bits comparison or quadratic blowup gets caught.

Covers: persona repro (len unq [1,2,2,3] = 3), order preservation,
all-same, empty, all-unique, floats, negatives/zero, and a
1000-element stress test.
Demonstrates unq across the shapes the regression test pins:
basic dedup, all-same, empty, all-unique, floats, negatives.
The examples_engines harness asserts identical output across
tree/VM/Cranelift, giving us a second line of coverage on top
of the cross-engine regression test.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@danieljohnmorris danieljohnmorris merged commit 3166f34 into main May 13, 2026
5 checks passed
@danieljohnmorris danieljohnmorris deleted the fix/unq-hang-numbers branch May 13, 2026 12:46
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