Commit aaf2de6
authored
Scope Python RPC marketplace responses to the requested distribution (#7512)
* Scope Python RPC marketplace responses to the requested distribution
`discover_recipes()` eagerly walked every `openrewrite.recipes` entry
point on `_get_marketplace()` init and `handle_get_marketplace()`
returned the full singleton, so installing any pip package had its
`RecipeBundle` tagged with every recipe in the process - including the
eight built-in `org.openrewrite.python.*` recipes activated by the
`openrewrite` distribution itself. A visualization-only package like
`moderne-visualizations-misc` ended up "owning" every Python recipe.
Track per-distribution attribution at activation time
(`{distribution_name -> set(recipe_name)}`), have
`handle_install_recipes` return only the rows for the requested
package, and let `handle_get_marketplace` filter by `packageName` when
supplied. `PipRecipeBundleReader` now uses the install response
directly instead of issuing a follow-up `GetMarketplace` call that
would still see the full singleton.
`InstallRecipesResponse` carries the new `recipes` field
backwards-compatibly: older Python servers that don't include it
deserialize to `null`, accessed through `recipesOrEmpty()`.
* Avoid baking the recipe count into prose
The number of built-in `org.openrewrite.python.*` recipes will change
over time. Drop the hard-coded "eight" from the comments and test
docstrings so they don't decay.
* Wrap attribution map in a RecipeAttribution type
`Optional[Dict[str, Set[str]]]` told the reader nothing about what the
keys or values mean, and pushed PEP 503 normalization out to every
call site. Replace it with a small `RecipeAttribution` dataclass that
encapsulates the storage, normalizes distribution names on both
record and lookup, and exposes named `record(...)` / `recipes_for(...)`
methods. Export it from the package since it's now part of the
`discover_recipes` signature.
* Address review feedback on attribution typing + recipesInstalled semantic
- `recipesInstalled` is back to the diff semantic (recipes added by THIS
call, zero on idempotent reinstalls), matching the field name's promise
and the prior wire contract. The new `recipes` field carries the
cumulative per-distribution row list separately. Audit of other
language servers (Java in-process, C# LanguageServer, JS, Go) confirms
Python is the sole InstallRecipes producer and no consumer reads
`recipesInstalled` today, so the diff semantic is the safe default.
- Drop `@dataclass` on `RecipeAttribution`. The auto-generated
`__init__(_by_package=...)` exposed the internal map through the
constructor signature and we don't use the auto `__eq__`/`__repr__`.
Plain class with `__init__(self) -> None` keeps the storage truly
private.
- Replace bare `Dict[str, Set[str]]` with NewType-typed
`Dict[NormalizedDistName, Set[RecipeName]]`. `NormalizedDistName` can
only be built via `_normalize_package_name`; `RecipeName` propagates
through `recipe_name_set`, the attribution API, and
`_collect_marketplace_rows`'s filter parameter. Zero runtime cost,
type-checker discipline at every site.1 parent c229022 commit aaf2de6
7 files changed
Lines changed: 367 additions & 34 deletions
File tree
- rewrite-python
- rewrite
- src/rewrite
- rpc
- tests
- src/main/java/org/openrewrite/python
- marketplace
- rpc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
30 | 78 | | |
31 | 79 | | |
32 | 80 | | |
33 | 81 | | |
34 | 82 | | |
35 | 83 | | |
36 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
37 | 94 | | |
38 | | - | |
| 95 | + | |
39 | 96 | | |
40 | 97 | | |
41 | 98 | | |
| |||
45 | 102 | | |
46 | 103 | | |
47 | 104 | | |
48 | | - | |
| 105 | + | |
| 106 | + | |
49 | 107 | | |
50 | 108 | | |
51 | 109 | | |
52 | 110 | | |
53 | 111 | | |
54 | 112 | | |
55 | 113 | | |
56 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
57 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
58 | 124 | | |
59 | 125 | | |
60 | 126 | | |
61 | 127 | | |
62 | 128 | | |
63 | 129 | | |
64 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
65 | 145 | | |
66 | 146 | | |
67 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
584 | 586 | | |
585 | 587 | | |
586 | 588 | | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
587 | 595 | | |
588 | 596 | | |
589 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
590 | 606 | | |
591 | 607 | | |
592 | | - | |
| 608 | + | |
593 | 609 | | |
594 | 610 | | |
595 | 611 | | |
596 | | - | |
597 | | - | |
| 612 | + | |
598 | 613 | | |
599 | | - | |
600 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
601 | 624 | | |
| 625 | + | |
602 | 626 | | |
603 | 627 | | |
604 | 628 | | |
| |||
616 | 640 | | |
617 | 641 | | |
618 | 642 | | |
619 | | - | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
620 | 650 | | |
621 | 651 | | |
622 | 652 | | |
| 653 | + | |
623 | 654 | | |
624 | 655 | | |
625 | | - | |
626 | 656 | | |
627 | 657 | | |
628 | 658 | | |
| 659 | + | |
| 660 | + | |
629 | 661 | | |
630 | 662 | | |
631 | 663 | | |
| |||
636 | 668 | | |
637 | 669 | | |
638 | 670 | | |
| 671 | + | |
639 | 672 | | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
640 | 676 | | |
641 | 677 | | |
642 | 678 | | |
| |||
655 | 691 | | |
656 | 692 | | |
657 | 693 | | |
| 694 | + | |
658 | 695 | | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
659 | 699 | | |
660 | 700 | | |
661 | 701 | | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
666 | 715 | | |
667 | | - | |
668 | | - | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
669 | 719 | | |
670 | 720 | | |
671 | 721 | | |
| |||
828 | 878 | | |
829 | 879 | | |
830 | 880 | | |
831 | | - | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
832 | 888 | | |
833 | 889 | | |
834 | 890 | | |
835 | 891 | | |
836 | | - | |
837 | | - | |
838 | 892 | | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
839 | 915 | | |
840 | 916 | | |
841 | | - | |
842 | | - | |
| 917 | + | |
843 | 918 | | |
844 | 919 | | |
845 | | - | |
846 | | - | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
847 | 923 | | |
848 | 924 | | |
849 | 925 | | |
| |||
854 | 930 | | |
855 | 931 | | |
856 | 932 | | |
857 | | - | |
| 933 | + | |
858 | 934 | | |
859 | | - | |
860 | 935 | | |
861 | | - | |
| 936 | + | |
862 | 937 | | |
863 | | - | |
864 | 938 | | |
865 | 939 | | |
866 | 940 | | |
| |||
0 commit comments