Skip to content

fix(deep): reject sparse sort input before mutation - #255

Merged
andrewzolotukhin merged 1 commit into
developmentfrom
fix/deep-sort-sparse-input
Oct 18, 2026
Merged

andrewzolotukhin merged 1 commit into
developmentfrom
fix/deep-sort-sparse-input

Conversation

@andrewzolotukhin

@andrewzolotukhin andrewzolotukhin commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

deepSort introduced in #254 can duplicate an existing record when its input contains a hole: map preserves the hole, sorting moves the populated entry, and writing the result back leaves the original populated slot in place. Validate every position with Array.from so a missing record rejects before sorting or mutation.

Original request

Provide reusable, documented deep helpers with a unit-test safety net. This follows up on a sparse-input case found while verifying the newly merged sorter.

What changed

  • Visit every input position during key validation, including holes.
  • Add a regression proving TypeError, preservation of the hole and preservation of the original record reference.
  • Document dense-input requirements and include a patch changeset.

Reasoning

The existing validation-before-mutation contract should apply to sparse arrays as well. The fix preserves ordinary stable sorting and the public interface.

Type of Change

  • Bug fix
  • Documentation update

Blog post

Skipped: correctness fix in a non-visual data-processing helper.

Screenshots / preview evidence

Not applicable: pure data helper. A before/after reproduction demonstrates duplication on the original implementation and rejection without mutation after the fix.

Validation

  • npm run lint, npm run build, npm run test: pass.
  • Full suite: 300 files, 5,381 tests, no type errors.
  • npm run test:coverage: all published-package floors pass; the sorter retains 100% lines/statements/functions/branches.
  • All required CI passes: lint/build/tests, PostgreSQL, Garage, browser/API/telemetry E2E and Striff.

Checklist

  • Added a failing-before/passing-after regression
  • Ran lint
  • Ran build and test
  • Added a changeset

@andrewzolotukhin
andrewzolotukhin merged commit aecdad9 into development Oct 18, 2026
5 checks passed
@andrewzolotukhin
andrewzolotukhin deleted the fix/deep-sort-sparse-input branch October 18, 2026 10:29
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