Commit 7a02799
authored
refactor(marshal): compareRankRemotablesTied for rank-cover ops (#3265)
Refs: #2871
Refs: #2883
Refs: #3226
## Description
Splits the rank-comparison refactor out from #2871 so that the
codec-admission core of that PR can land in #3226 without depending on
this orthogonal change.
Introduces `compareRankRemotablesTied` (and its anti-rank twin), which
behaves like `compareRank` but treats all remotables as tied for the
same rank rather than short-circuiting on the first remotable
encountered. Makes this the default `compare` for the rank-cover
operations:
- `isRankSorted`, `assertRankSorted`, `sortByRank`, `getIndexCover`
(commit 1)
- `unionRankCovers`, `intersectRankCovers` (commit 2)
`compare` becomes optional and is moved to the trailing position on
each. `getIndexCover`'s argument order shifts from `(sorted, compare,
rankCover)` to `(sorted, rankCover, compare?)`; the only callers are
within the Endo monorepo and are updated. `unionRankCovers` and
`intersectRankCovers` likewise shift from `(compare, covers)` to
`(covers, compare?)`, and `@endo/patterns`'s `patternMatchers.js` (the
only caller) is updated. `compareRankRemotablesTied` and
`compareAntiRankRemotablesTied` are re-exported from `@endo/marshal`'s
`index.js`.
The first commit is salvaged from #2871 with original authorship
preserved (Mark S. Miller).
### Security Considerations
No change to trust boundaries, no new authorities. The comparator change
is internal to marshal's rank ordering; callers that pass an explicit
`compare` keep their existing behavior.
### Scaling Considerations
The tied comparator visits every remotable rather than short-circuiting
on the first, so rank-cover operations over inputs containing many
remotables do more work per call than the prior `compareRank` default.
This matches the intent of the operations (they want a stable cover, not
an early exit), and the prior behavior is still available by passing
`compareRank` explicitly.
### Documentation Considerations
The argument-order changes on `getIndexCover`, `unionRankCovers`, and
`intersectRankCovers` are caller-visible. No internal callers remain on
the old signatures. External callers, if any, would need to swap
argument order; this is captured in the changeset.
### Testing Considerations
`packages/marshal/test/rankOrder.test.js` is extended to:
- Exercise the new optional/default-arg behavior of all six rank-cover
operations.
- Resolve two pre-existing TODOs that asked for the `totally orders
ranks` and `is transitive` property tests to run against both
`compareRank` and `compareRankRemotablesTied`. Both are total preorders,
so both properties hold for both, and we now parameterize the tests to
exercise each.
### Compatibility Considerations
Argument-order shifts on three exported functions (`getIndexCover`,
`unionRankCovers`, `intersectRankCovers`) and one new default comparator
on six. Captured in a changeset. The `compareRankRemotablesTied` and
`compareAntiRankRemotablesTied` exports are additions; nothing is
removed.
### Upgrade Considerations
No live-system upgrade concerns. The changeset covers the package-level
migration for external consumers.5 files changed
Lines changed: 267 additions & 93 deletions
File tree
- .changeset
- packages
- marshal
- src
- test
- patterns/src/patterns
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
362 | 375 | | |
363 | 376 | | |
364 | | - | |
| 377 | + | |
365 | 378 | | |
366 | 379 | | |
367 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
368 | 384 | | |
369 | 385 | | |
370 | 386 | | |
| |||
383 | 399 | | |
384 | 400 | | |
385 | 401 | | |
386 | | - | |
| 402 | + | |
387 | 403 | | |
388 | | - | |
| 404 | + | |
389 | 405 | | |
390 | 406 | | |
391 | 407 | | |
| |||
395 | 411 | | |
396 | 412 | | |
397 | 413 | | |
398 | | - | |
| 414 | + | |
399 | 415 | | |
400 | 416 | | |
401 | | - | |
| 417 | + | |
402 | 418 | | |
403 | 419 | | |
404 | 420 | | |
| |||
439 | 455 | | |
440 | 456 | | |
441 | 457 | | |
442 | | - | |
443 | 458 | | |
444 | | - | |
| 459 | + | |
| 460 | + | |
445 | 461 | | |
446 | 462 | | |
447 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
448 | 469 | | |
449 | 470 | | |
450 | 471 | | |
| |||
463 | 484 | | |
464 | 485 | | |
465 | 486 | | |
466 | | - | |
467 | 487 | | |
| 488 | + | |
| 489 | + | |
468 | 490 | | |
469 | 491 | | |
470 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
471 | 497 | | |
472 | | - | |
473 | | - | |
| 498 | + | |
| 499 | + | |
474 | 500 | | |
475 | 501 | | |
476 | 502 | | |
| |||
524 | 550 | | |
525 | 551 | | |
526 | 552 | | |
527 | | - | |
528 | 553 | | |
| 554 | + | |
| 555 | + | |
529 | 556 | | |
530 | 557 | | |
531 | | - | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
532 | 562 | | |
533 | 563 | | |
534 | 564 | | |
| |||
543 | 573 | | |
544 | 574 | | |
545 | 575 | | |
546 | | - | |
547 | 576 | | |
| 577 | + | |
| 578 | + | |
548 | 579 | | |
549 | 580 | | |
550 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
551 | 585 | | |
552 | 586 | | |
553 | 587 | | |
| |||
0 commit comments