galaxy-tool-refactor-registry 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. galaxy_tool_refactor_registry-0.2.0/.gitignore +24 -0
  2. galaxy_tool_refactor_registry-0.2.0/CLAUDE.md +108 -0
  3. galaxy_tool_refactor_registry-0.2.0/PKG-INFO +94 -0
  4. galaxy_tool_refactor_registry-0.2.0/README.md +80 -0
  5. galaxy_tool_refactor_registry-0.2.0/docs/decisions.md +751 -0
  6. galaxy_tool_refactor_registry-0.2.0/pyproject.toml +57 -0
  7. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/__init__.py +18 -0
  8. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/adapters.py +135 -0
  9. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/apply.py +55 -0
  10. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/bundle_rename.py +449 -0
  11. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/errors.py +34 -0
  12. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/facade.py +589 -0
  13. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/handle.py +48 -0
  14. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/macro_datatype.py +110 -0
  15. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/macro_profile.py +219 -0
  16. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/parity.py +67 -0
  17. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/planemo.py +26 -0
  18. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/py.typed +0 -0
  19. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/registry.py +190 -0
  20. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/resolve.py +135 -0
  21. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/results.py +197 -0
  22. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/rulesets.py +37 -0
  23. galaxy_tool_refactor_registry-0.2.0/src/galaxy_tool_refactor_registry/version_token_share.py +313 -0
  24. galaxy_tool_refactor_registry-0.2.0/tests/conftest.py +21 -0
  25. galaxy_tool_refactor_registry-0.2.0/tests/data/planemo_linters_c6e0ee3.txt +146 -0
  26. galaxy_tool_refactor_registry-0.2.0/tests/test_bundle_rename.py +319 -0
  27. galaxy_tool_refactor_registry-0.2.0/tests/test_decision_citations.py +224 -0
  28. galaxy_tool_refactor_registry-0.2.0/tests/test_facade.py +575 -0
  29. galaxy_tool_refactor_registry-0.2.0/tests/test_macro_datatype.py +86 -0
  30. galaxy_tool_refactor_registry-0.2.0/tests/test_macro_profile.py +171 -0
  31. galaxy_tool_refactor_registry-0.2.0/tests/test_partition.py +131 -0
  32. galaxy_tool_refactor_registry-0.2.0/tests/test_planemo_aliases.py +142 -0
  33. galaxy_tool_refactor_registry-0.2.0/tests/test_planemo_parity_table.py +31 -0
  34. galaxy_tool_refactor_registry-0.2.0/tests/test_proof_documents.py +36 -0
  35. galaxy_tool_refactor_registry-0.2.0/tests/test_registry.py +185 -0
  36. galaxy_tool_refactor_registry-0.2.0/tests/test_research_note_citations.py +259 -0
  37. galaxy_tool_refactor_registry-0.2.0/tests/test_ruleset_membership.py +67 -0
  38. galaxy_tool_refactor_registry-0.2.0/tests/test_rulesets_resolve.py +113 -0
  39. galaxy_tool_refactor_registry-0.2.0/tests/test_serializer_allowlist.py +159 -0
  40. galaxy_tool_refactor_registry-0.2.0/tests/test_stat_artifact_coverage.py +201 -0
  41. galaxy_tool_refactor_registry-0.2.0/tests/test_tier_boundaries.py +127 -0
  42. galaxy_tool_refactor_registry-0.2.0/tests/test_version_token_share.py +103 -0
  43. galaxy_tool_refactor_registry-0.2.0/tests/test_workspace_versions.py +133 -0
@@ -0,0 +1,24 @@
1
+ # Machine-local scratch, never committed: the cloned corpus (.local/corpus,
2
+ # seeded from corpus_sources.json) and external source clones for inspection
3
+ # (e.g. .local/galaxy-src = a clone of galaxyproject/galaxy used to verify
4
+ # Galaxy-internal behaviour locally).
5
+ # No trailing slash: `.local/` matches only a directory, so an accidental
6
+ # symlink at this path was committable (it happened once; removed in this branch).
7
+ .local
8
+ .venv/
9
+ __pycache__/
10
+ *.pyc
11
+ *.pyo
12
+ .pytest_cache/
13
+ .mypy_cache/
14
+ .ruff_cache/
15
+ dist/
16
+ *.egg-info/
17
+
18
+ # Local-only draft of the GCC poster abstract.
19
+ gcc2026-abstract.txt
20
+
21
+ # Claude Code session scratch (the tracked .claude/ settings + skills stay; this
22
+ # runtime lock for scheduled wakeups is machine-local).
23
+ .claude/scheduled_tasks.lock
24
+ .claude/worktrees/
@@ -0,0 +1,108 @@
1
+ # CLAUDE.md
2
+
3
+ Guidance for Claude Code working in this repository.
4
+
5
+ ## Project
6
+
7
+ `galaxy-tool-refactor-registry` is the **rule-registry facade** tier (tier 3.6)
8
+ of the Galaxy tool refactoring framework: a unified, code-addressable view over
9
+ every baked-in rule, named rulesets, per-rule enable/disable, and a library-first
10
+ `run`/`upgrade`/`detect` API.
11
+
12
+ | Tier | Layer | Package |
13
+ |---|---|---|
14
+ | 0.5 | rule metadata | `galaxy-tool-refactor-rules` |
15
+ | 1 | parsing & validation | `galaxy-tool-source` |
16
+ | 2 | structure | `galaxy-tool-codemod` |
17
+ | 3 | formatting | `galaxy-tool-fmt` |
18
+ | 3.5 | advisory checks | `galaxy-tool-lint` |
19
+ | 3.6 | **rule registry / rulesets** | `galaxy-tool-refactor-registry` *(this repo)* |
20
+ | 4 | app / CLI | `galaxy-tool-refactor-cli` |
21
+ | 4 | MCP server | `galaxy-tool-refactor-mcp` |
22
+
23
+ It depends on the rule tiers (0.5 / 1 / 2 / 3 / 3.5); **the lower tiers do not
24
+ depend on it**, and it is the only orchestration layer below the app CLI. Both
25
+ the CLI and the MCP server (`galaxy-tool-refactor-mcp`) sit on top of it.
26
+
27
+ ## Key invariants
28
+
29
+ - **Library-first.** No `click` / `sys.exit` / printing in the call path; inputs
30
+ are path / bytes / `ToolDocument`; outputs are structured (`FormatResult` /
31
+ `UpgradeResult` / `DetectResult`); files are written only when a `write_path`
32
+ is given. This is what lets the CLI and the MCP server be thin adapters.
33
+ - **fmt is still the only serializer.** All XML bytes come out of
34
+ `format_tool_document_subset` / fmt's `to_bytes`; the facade never serialises
35
+ XML itself.
36
+ - **One handle per code.** `RuleHandle` (`handle.py`) adapts each family's rule
37
+ to a uniform `meta` / `family` / `fixable` / `detect` / `apply` shape; the
38
+ registry asserts the GTR code namespace is collision-free.
39
+ - **Selectable ≠ all.** `registry()` is the selectable set (canonical codemods +
40
+ cosmetic fmt + advisory checks). The non-selectable codemods — GTR007–GTR012 + GTR093
41
+ (validity-gated, internal to `UpgradeToLatest`), GTR014–GTR016 (runtime-gated,
42
+ applied by `upgrade`), and the opt-in-command-only GTR092/GTR094 (applied by
43
+ `convert-help` / `tokenize-version`; `adapters.OPT_IN_COMMAND_BY_CODE`) — appear only in
44
+ `all_handles()` / `list_rules(include_upgrade=True)`. `--select`/`--ignore`
45
+ on one of them raises `UnknownRuleCode` with a hint naming where it lives.
46
+ - **Apply ordering reproduces `format`.** Codemods in `canonical_codemods()` order,
47
+ then cosmetic fmt in `meta.order`. The `default` ruleset reproduces the direct
48
+ `canonical_codemods()` + cosmetic pipeline (a regression test pins facade ==
49
+ pipeline). Note this tracks the *live* `canonical_codemods()`: when GTR020.1 joined
50
+ it, default-`format` output shifted vs the pre-partition historical bytes (codemod
51
+ `docs/decisions.md` §30) — the facade-vs-pipeline pin still holds.
52
+ - **Rulesets and rules are developer-defined.** No user-defined rules/rulesets.
53
+
54
+ ## Coding standards
55
+
56
+ Hand-written code follows **dignified-python** (vendored at the workspace root
57
+ `.claude/skills/dignified-python/`): LBYL over try/except (the facade has no
58
+ exception handling — it raises typed `UnknownRuleCode`/`UnknownRuleset` from
59
+ `errors.py`, which the CLI catches at its boundary); `pathlib` with explicit
60
+ `encoding` for text I/O; keyword-only args after the first; absolute imports, no
61
+ re-exports, no `__all__`; no import-time side effects (`@cache` for the
62
+ registry/ruleset tables). `optimized-python` is a secondary reference;
63
+ dignified-python governs on conflict. New code lands tests-first.
64
+
65
+ ## Commands
66
+
67
+ Run from the **workspace root** (`galaxy-tool-refactor/`):
68
+
69
+ - `uv sync`
70
+ - `uv run --package galaxy-tool-refactor-registry pytest galaxy-tool-refactor-registry/tests/`
71
+ - `uv run ruff check galaxy-tool-refactor-registry/src galaxy-tool-refactor-registry/tests`
72
+ - `uv run mypy --config-file galaxy-tool-refactor-registry/pyproject.toml galaxy-tool-refactor-registry/src`
73
+
74
+ ## Module map
75
+
76
+ - `handle.py` — the `RuleHandle` adapter dataclass.
77
+ - `adapters.py` — wrap each family (codemod / fmt / check) into a `RuleHandle`;
78
+ the family class enumerations.
79
+ - `registry.py` — `@cache`d `code -> RuleHandle` index (duplicate-code guard);
80
+ `registry` / `all_handles` / `by_code` / `known_codes` / `advisory_codes`.
81
+ - `rulesets.py` — derives ruleset code sets from per-rule `RuleMeta.rulesets`
82
+ membership, `DEFAULT_RULESET`.
83
+ - `resolve.py` — `resolve_codes` / `resolve_upgrade_codes` (ignore ▸ select ▸
84
+ ruleset; select replaces; named rulesets union).
85
+ - `apply.py` — `apply_selection` (phase-ordered apply).
86
+ - `facade.py` — `run` / `upgrade` / `detect` / `find_references` / `rename_param`
87
+ (the mutating sibling of `find_references`; deep-copies + serialises on success, see
88
+ `docs/decisions.md` D11) / `convert_help` / `tokenize_version` / `list_rulesets` / `list_rules`.
89
+ - `macro_profile.py` — Phase-3b imported-`@PROFILE@` upgrade: `profile_token_site`
90
+ (one tool → defining file + target), the pure `plan_from_sites` (per-file
91
+ importer agreement), and `apply_profile_token_plans` (bump the agreed files'
92
+ tokens via `format_macro_document`, skip the rest). See `docs/decisions.md` D5.
93
+ - `version_token_share.py`: shared-macros version tokenization (`tokenize-version
94
+ --macros-file`) via `plan_shared_tokenization` (create / merge / consensus) behind a
95
+ proof-by-execution gate (every retargeted tool still expands to its original; a merge
96
+ is inert for every other importer of the file). The facade's `tokenize_version` (one
97
+ tool) and `tokenize_version_shared` (a directory group) sit on top. See
98
+ `docs/decisions.md` D20.
99
+ - `results.py` — the structured result + introspection dataclasses.
100
+ - `errors.py` — `UnknownRuleCode` / `UnknownRuleset`.
101
+
102
+ ## Useful references
103
+
104
+ - `galaxy-tool-refactor-cli/src/galaxy_tool_refactor_cli/cli.py` — the CLI that
105
+ consumes this facade.
106
+ - `galaxy-tool-refactor-mcp/src/.../service.py` — the facade->JSON adapter the MCP
107
+ server wraps (mcp `docs/decisions.md` D1); `docs/vision.md` — the agent-rules future.
108
+ - `galaxy-tool-fmt/docs/decisions.md` §D15 — the per-rule subset seams.
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: galaxy-tool-refactor-registry
3
+ Version: 0.2.0
4
+ Summary: Unified, code-addressable rule registry + named presets for the Galaxy tool refactoring tiers — tier 3.6, a library-first facade the CLI (and a future MCP server) compose.
5
+ Author: Richard Burhans
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: galaxy-tool-codemod==0.2.0
9
+ Requires-Dist: galaxy-tool-fmt==0.2.0
10
+ Requires-Dist: galaxy-tool-lint==0.2.0
11
+ Requires-Dist: galaxy-tool-refactor-rules==0.2.0
12
+ Requires-Dist: galaxy-tool-source==0.2.0
13
+ Description-Content-Type: text/markdown
14
+
15
+ # galaxy-tool-refactor-registry
16
+
17
+ The **rule-registry facade** (tier 3.6) of the Galaxy tool refactoring framework:
18
+ a single, code-addressable view over every baked-in rule across the three rule
19
+ families — codemod (tier 2, structural GTR), fmt (tier 3, cosmetic GTR), and
20
+ check (tier 3.5, advisory) — plus **named rulesets** and **per-rule
21
+ enable/disable**, behind a **library-first** API.
22
+
23
+ ```
24
+ galaxy-tool-refactor-registry (this package, tier 3.6)
25
+ ↑ ↑
26
+ galaxy-tool-refactor-cli (tier 4) galaxy-tool-refactor-mcp (tier 4, future)
27
+ ```
28
+
29
+ It depends on the rule tiers (0.5 / 1 / 2 / 3 / 3.5); the lower tiers do **not**
30
+ depend on it. It is the orchestration core the `galaxy-tool-refactor` CLI sits on
31
+ top of, and the core the agent-facing MCP server sits on
32
+ (`galaxy-tool-refactor-mcp`). All XML serialisation goes through fmt, preserving
33
+ "fmt is the only tier that writes/serialises XML".
34
+
35
+ ## Why library-first
36
+
37
+ No `click` / `sys.exit` / printing in the call path; functions take a path, raw
38
+ `bytes`, or a `ToolDocument` and return **structured results**; files are written
39
+ only when a `write_path` is given; and the rule/ruleset catalogs are
40
+ introspectable (`list_rules()` / `list_rulesets()`). That shape lets both the CLI
41
+ and a future agent-facing MCP server be thin adapters over the same core. See
42
+ `../galaxy-tool-refactor-mcp/docs/vision.md`.
43
+
44
+ ## Rulesets
45
+
46
+ | Ruleset | Contents | Notes |
47
+ |---|---|---|
48
+ | `cosmetic` | fmt cosmetic rules (GTR001/003/004) | whitespace / indent / shorthand only |
49
+ | `default` *(default)* | canonical codemods (GTR006/002/005/013) + cosmetic | today's `format` — the opinionated formatter |
50
+ | `iuc` | mirrors `default` (placeholder) | reserved for an IUC-specific divergence |
51
+ | `strict` | `default` + advisory checks | format + flag everything IUC cares about (report-only) |
52
+
53
+ Membership is declared **per rule** (`RuleMeta.rulesets`): the registry derives
54
+ each ruleset's code set by grouping every registered rule by the names in its
55
+ `meta.rulesets`. Adding or changing rules and rulesets is a **developer** task —
56
+ there are no user-defined rules or rulesets.
57
+
58
+ ## Selection
59
+
60
+ `resolve_codes(rulesets=…, select=…, ignore=…)` turns ruleset names plus
61
+ `--select`/`--ignore` code lists into a concrete code set — the base is the
62
+ **union** of the named rulesets (or the default ruleset when none are named).
63
+ Precedence is ruff-style: `--ignore` ▸ `--select` ▸ `--ruleset` — an explicit
64
+ `--select` *replaces* the rulesets' set, then `--ignore` subtracts. Unknown
65
+ ruleset names / rule codes raise the typed `UnknownRuleset` / `UnknownRuleCode`.
66
+
67
+ ## Public API (by submodule import; no re-exports)
68
+
69
+ ```python
70
+ from galaxy_tool_refactor_registry.facade import (
71
+ run, upgrade, detect, list_rulesets, list_rules,
72
+ )
73
+ from galaxy_tool_refactor_registry.resolve import resolve_codes, resolve_upgrade_codes
74
+ from galaxy_tool_refactor_registry.registry import by_code, known_codes, advisory_codes
75
+ ```
76
+
77
+ - `run(source, *, codes, write_path=None) -> FormatResult` — apply the fixable
78
+ rules in the selection (codemods in canonical order, then cosmetic fmt),
79
+ reporting advisory findings as notes.
80
+ - `upgrade(source, *, codes, write_path=None) -> UpgradeResult` — profile-upgrade
81
+ plus the selected fixable rules.
82
+ - `detect(source, *, codes) -> DetectResult` — report-only over the selection.
83
+ - `by_code(code) -> RuleHandle` — the uniform, callable handle for one rule
84
+ (`meta`, `family`, `fixable`, `detect(document)`, `apply(document)` or `None`).
85
+
86
+ ## Develop
87
+
88
+ Run from the workspace root (`galaxy-tool-refactor/`):
89
+
90
+ ```bash
91
+ uv run --package galaxy-tool-refactor-registry pytest galaxy-tool-refactor-registry/tests/
92
+ uv run ruff check galaxy-tool-refactor-registry/src galaxy-tool-refactor-registry/tests
93
+ uv run mypy --config-file galaxy-tool-refactor-registry/pyproject.toml galaxy-tool-refactor-registry/src
94
+ ```
@@ -0,0 +1,80 @@
1
+ # galaxy-tool-refactor-registry
2
+
3
+ The **rule-registry facade** (tier 3.6) of the Galaxy tool refactoring framework:
4
+ a single, code-addressable view over every baked-in rule across the three rule
5
+ families — codemod (tier 2, structural GTR), fmt (tier 3, cosmetic GTR), and
6
+ check (tier 3.5, advisory) — plus **named rulesets** and **per-rule
7
+ enable/disable**, behind a **library-first** API.
8
+
9
+ ```
10
+ galaxy-tool-refactor-registry (this package, tier 3.6)
11
+ ↑ ↑
12
+ galaxy-tool-refactor-cli (tier 4) galaxy-tool-refactor-mcp (tier 4, future)
13
+ ```
14
+
15
+ It depends on the rule tiers (0.5 / 1 / 2 / 3 / 3.5); the lower tiers do **not**
16
+ depend on it. It is the orchestration core the `galaxy-tool-refactor` CLI sits on
17
+ top of, and the core the agent-facing MCP server sits on
18
+ (`galaxy-tool-refactor-mcp`). All XML serialisation goes through fmt, preserving
19
+ "fmt is the only tier that writes/serialises XML".
20
+
21
+ ## Why library-first
22
+
23
+ No `click` / `sys.exit` / printing in the call path; functions take a path, raw
24
+ `bytes`, or a `ToolDocument` and return **structured results**; files are written
25
+ only when a `write_path` is given; and the rule/ruleset catalogs are
26
+ introspectable (`list_rules()` / `list_rulesets()`). That shape lets both the CLI
27
+ and a future agent-facing MCP server be thin adapters over the same core. See
28
+ `../galaxy-tool-refactor-mcp/docs/vision.md`.
29
+
30
+ ## Rulesets
31
+
32
+ | Ruleset | Contents | Notes |
33
+ |---|---|---|
34
+ | `cosmetic` | fmt cosmetic rules (GTR001/003/004) | whitespace / indent / shorthand only |
35
+ | `default` *(default)* | canonical codemods (GTR006/002/005/013) + cosmetic | today's `format` — the opinionated formatter |
36
+ | `iuc` | mirrors `default` (placeholder) | reserved for an IUC-specific divergence |
37
+ | `strict` | `default` + advisory checks | format + flag everything IUC cares about (report-only) |
38
+
39
+ Membership is declared **per rule** (`RuleMeta.rulesets`): the registry derives
40
+ each ruleset's code set by grouping every registered rule by the names in its
41
+ `meta.rulesets`. Adding or changing rules and rulesets is a **developer** task —
42
+ there are no user-defined rules or rulesets.
43
+
44
+ ## Selection
45
+
46
+ `resolve_codes(rulesets=…, select=…, ignore=…)` turns ruleset names plus
47
+ `--select`/`--ignore` code lists into a concrete code set — the base is the
48
+ **union** of the named rulesets (or the default ruleset when none are named).
49
+ Precedence is ruff-style: `--ignore` ▸ `--select` ▸ `--ruleset` — an explicit
50
+ `--select` *replaces* the rulesets' set, then `--ignore` subtracts. Unknown
51
+ ruleset names / rule codes raise the typed `UnknownRuleset` / `UnknownRuleCode`.
52
+
53
+ ## Public API (by submodule import; no re-exports)
54
+
55
+ ```python
56
+ from galaxy_tool_refactor_registry.facade import (
57
+ run, upgrade, detect, list_rulesets, list_rules,
58
+ )
59
+ from galaxy_tool_refactor_registry.resolve import resolve_codes, resolve_upgrade_codes
60
+ from galaxy_tool_refactor_registry.registry import by_code, known_codes, advisory_codes
61
+ ```
62
+
63
+ - `run(source, *, codes, write_path=None) -> FormatResult` — apply the fixable
64
+ rules in the selection (codemods in canonical order, then cosmetic fmt),
65
+ reporting advisory findings as notes.
66
+ - `upgrade(source, *, codes, write_path=None) -> UpgradeResult` — profile-upgrade
67
+ plus the selected fixable rules.
68
+ - `detect(source, *, codes) -> DetectResult` — report-only over the selection.
69
+ - `by_code(code) -> RuleHandle` — the uniform, callable handle for one rule
70
+ (`meta`, `family`, `fixable`, `detect(document)`, `apply(document)` or `None`).
71
+
72
+ ## Develop
73
+
74
+ Run from the workspace root (`galaxy-tool-refactor/`):
75
+
76
+ ```bash
77
+ uv run --package galaxy-tool-refactor-registry pytest galaxy-tool-refactor-registry/tests/
78
+ uv run ruff check galaxy-tool-refactor-registry/src galaxy-tool-refactor-registry/tests
79
+ uv run mypy --config-file galaxy-tool-refactor-registry/pyproject.toml galaxy-tool-refactor-registry/src
80
+ ```