Skip to content

chore(tables): own fractional-indexing in-house, drop runtime dep#4900

Merged
TheodoreSpeaks merged 2 commits into
stagingfrom
fix/remove-fractional-index-dependency
Jun 7, 2026
Merged

chore(tables): own fractional-indexing in-house, drop runtime dep#4900
TheodoreSpeaks merged 2 commits into
stagingfrom
fix/remove-fractional-index-dependency

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

  • Port the fractional-indexing algorithm in-house at apps/sim/lib/fractional-indexing/ (verbatim TS port of the CC0 upstream, mirrors the pptx-renderer library layout)
  • Point the order-key.ts wrapper at the in-house module; no call sites change (it's the only importer)
  • Move fractional-indexing from runtime dependencies to devDependencies — kept only as the differential-test oracle
  • Add a differential test that runs the port byte-for-byte against the upstream package across exhaustive, randomized, integer-rollover, and deep-fraction cases

Type of Change

  • Chore / maintenance

Testing

  • bun run test apps/sim/lib/fractional-indexing/ — 7/7 pass (in-house ≡ upstream)
  • bun run test apps/sim/lib/table/ — 197/197 pass
  • bun run lint clean, bun run check:api-validation:strict passed, tsc --noEmit clean

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 7, 2026 12:07am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 6, 2026

PR Summary

Low Risk
Swap-in of the same public API for table row order keys; risk is mainly a subtle algorithm mismatch, which the PR targets with differential tests.

Overview
Replaces the fractional-indexing npm dependency with an in-house module at apps/sim/lib/fractional-indexing/fractional-indexing.ts, exporting the same generateKeyBetween / generateNKeysBetween API (CC0 algorithm port).

order-key.ts now imports from @/lib/fractional-indexing/fractional-indexing instead of the package; keyBetween / nKeysBetween call sites stay unchanged. fractional-indexing@3.2.0 is removed from apps/sim runtime dependencies and bun.lock.

Reviewed by Cursor Bugbot for commit c40199c. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

This PR ports the fractional-indexing npm package in-house as a self-contained TypeScript file, redirects the only import site (order-key.ts) to the new module via the @/ path alias, and demotes the npm package to devDependencies where it is retained solely as a differential-test oracle.

  • In-house port (fractional-indexing.ts): verbatim TS implementation of the CC0 algorithm — integer-part arithmetic, midpoint, and key-generation logic all faithfully reproduced and verified byte-identical against the upstream package.
  • Differential test suite (fractional-indexing.test.ts): 7 test cases covering exhaustive ordered-pair enumeration, 5-seed randomized insert simulation, generateNKeysBetween edge counts, integer-length rollover (5 000-step append/prepend runs), and deep same-spot inserts (2 000 iterations) — all assert byte-identical output vs. the oracle.
  • Dependency change (package.json): fractional-indexing moved from dependencies to devDependencies, eliminating it from the production bundle; the in-house module carries no npm dependencies of its own.

Confidence Score: 5/5

Safe to merge — the in-house port is byte-identical to the upstream package across exhaustive, randomized, and boundary-exercising test cases, and the only call site is unchanged.

The port faithfully reproduces the CC0 algorithm — carry/borrow arithmetic in incrementInteger/decrementInteger, common-prefix midpoint recursion, and all four branches of generateKeyBetween are all correct. The differential test suite is thorough: 40-key exhaustive enumeration, 5-seed × 400-step random insert simulation, 5 000-step rollover runs, and 2 000-step deep-fraction tests all confirm byte-identical output. The only changed call site in order-key.ts is a mechanical import-path swap with no signature changes.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/fractional-indexing/fractional-indexing.ts In-house CC0 port of the fractional-indexing algorithm; integer arithmetic, midpoint, and public API all match the upstream behavior verified by differential tests.
apps/sim/lib/fractional-indexing/fractional-indexing.test.ts Comprehensive differential test suite (exhaustive pairs, seeded random inserts, rollover runs, deep fractions) asserting byte-identical output vs. the upstream oracle.
apps/sim/lib/table/order-key.ts Import source updated from fractional-indexing package to @/lib/fractional-indexing/fractional-indexing; public API and call-site signatures unchanged.
apps/sim/package.json fractional-indexing correctly moved from dependencies to devDependencies; no other runtime dependency changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Before
        A1[order-key.ts] -->|import| B1[fractional-indexing npm\nruntime dep]
    end

    subgraph After
        A2[order-key.ts] -->|import via @/ alias| B2[lib/fractional-indexing/\nfractional-indexing.ts\nin-house port]
        T[fractional-indexing.test.ts] -->|oracle comparison| C2[fractional-indexing npm\ndevDependency only]
        T -->|tests| B2
    end
Loading

Reviews (1): Last reviewed commit: "chore(tables): own fractional-indexing i..." | Re-trigger Greptile

@TheodoreSpeaks TheodoreSpeaks merged commit 15df511 into staging Jun 7, 2026
14 checks passed
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