Structural-refactor framework for Galaxy tool XML — tier 2 of the galaxy-tool-source ecosystem.
Project description
galaxy-tool-codemod
A LibCST-shaped framework for structural refactors of Galaxy tool XML. The structure tier of the Galaxy refactoring architecture:
| Tier | Layer | Package | Role |
|---|---|---|---|
| 0.5 | rule metadata | galaxy-tool-refactor-rules |
shared RuleMeta descriptor |
| 1 | parsing & validation | galaxy-tool-source |
parse · profile-aware validate · typed view |
| 2 | structure | galaxy-tool-codemod (this repo) |
structural refactors |
| 3 | formatting | galaxy-tool-fmt |
cosmetic black-like formatter |
| 3.5 | advisory checks | galaxy-tool-lint |
detect-only checks |
| 3.6 | rule registry / rulesets | galaxy-tool-refactor-registry |
unified rules + rulesets (facade) |
| 4 | app / CLI | galaxy-tool-refactor-cli |
composes the tiers via the facade (format / upgrade / check) |
Status
M1–M3.5 shipped: framework primitives (Module, Cursor,
CodemodCommand), the corpus_check.py codemod sweep (retains failures
as regression fixtures), and two ordered pipeline contracts run by the
tier-4 app (galaxy-tool-refactor-cli):
canonical_codemods()=FixTypos → NormalizeBooleanValues → RepairHelpRst → TrimAttributeWhitespace → ReplaceOutputElement → DropRedundantParamName → ReorderParamAttributes → ReorderToolAttributes → ReorderToolChildren → WrapCommandCdata → WrapHelpCdata → SingleQuoteCommandVars— the safe canonical/format pipeline (the app'sformatcommand), derived from the codemods declaring the"default"ruleset and ordered bymeta.order(no hardcoded tuple, §36). Never changesprofile=.AUTO_UPGRADE_CODEMODS=FixTypos → NormalizeBooleanValues → UpgradeToLatest— the opt-in profile-upgrade pipeline (the app'supgradecommand).
The codemods:
FixTypos— repair near-miss spelling typos so a well-formed-but-globally-invalid tool validates (in both pipelines);NormalizeBooleanValues— rewrite Python-style boolean attribute values (True/Yes/…) to canonicalxs:booleanso a globally-invalid tool validates; schema-type-aware and behaviour-preserving (in both pipelines);UpgradeToLatest— loopUpdateProfile(declare the newest profile the tool validates at, bump-up-only) + single-stepupgrade_vNcodemods fromupgrades.pyto bring a tool to the latest profile (UpdateProfileis a building block run inside this loop, not a separate pipeline entry);ReorderParamAttributes/ReorderToolAttributes— IUC<param>and documented<tool>attribute order;ReorderToolChildren— IUC<tool>child-element order (best-practice #52); validity-safe because the<tool>content model is order-free (xs:all).
Every bundled codemod carries a RuleMeta GTR code; catalog.coded_codemods() is the
authoritative enumeration (the prose list above is illustrative — format also runs the
planemo-parity fixers GTR035–037 and the partition .1 fixers GTR018.1/019.1/020.1 and
GTR089.1 RepairHelpRst). See docs/decisions.md §15–37.
The upgrade registry is grown empirically: the corpus_check codemod
sweep reports STICKING POINT versions still needing an upgrade_vN, and
each upgrade_vN's advance count. Upgrades shipped: Upgrade24_1
(24.1 → 24.2), Upgrade25_1 (25.1 → 26.0). See docs/decisions.md §11–14.
M4 (matcher language) and M5 (Cheetah reference resolver) are not yet
implemented — see PLAN.md.
Public API
from pathlib import Path
from galaxy_tool_codemod.parse import parse_module
from galaxy_tool_codemod.canonical import canonical_codemods
module = parse_module(Path("tool.xml"))
for codemod_cls in canonical_codemods():
codemod_cls().apply(module)
# module.document.tree now reflects the canonical structural form
| Symbol | Purpose |
|---|---|
parse.parse_module(source) |
Entry point — accepts Path | bytes | ToolDocument. |
module.Module |
Frozen wrapper carrying document, model, cursor. |
cursor.Cursor |
lxml-backed view with read + typed mutation primitives. |
codemod.CodemodCommand |
Base for user-authored codemods (tag-PascalCase dispatch). |
codemods.fix_typos.FixTypos |
Repair near-miss typos until a globally-invalid tool validates (canonical, runs first). |
codemods.normalize_boolean_values.NormalizeBooleanValues |
Normalize Python-style boolean values (True/Yes/…) to xs:boolean until a globally-invalid tool validates (canonical, GTR017). |
codemods.repair_help_rst.RepairHelpRst |
Repair deterministically-fixable invalid <help> reStructuredText behind a render-equivalence gate (canonical, GTR089.1; the fix half of the GTR089 partition). |
upgrades.UpgradeToLatest |
In AUTO_UPGRADE_CODEMODS. Loop UpdateProfile + single-step upgrades to reach the latest profile. |
codemods.update_profile.UpdateProfile |
Declare the newest profile the tool validates at, bump-up-only. Building block run inside UpgradeToLatest — not itself a pipeline member. |
upgrades.UPGRADE_CODEMODS |
Registry: sticking version → its single-step upgrade codemod. |
codemods.upgrade_24_1.Upgrade24_1 |
Single-step 24.1 → 24.2 (normalize format / ftype). |
codemods.upgrade_25_1.Upgrade25_1 |
Single-step 25.1 → 26.0 (drop obsolete <trackster_conf>). |
codemods.reorder_param_attributes.ReorderParamAttributes |
IUC <param> attribute order. |
codemods.reorder_tool_attributes.ReorderToolAttributes |
Documented <tool> attribute prefix. |
codemods.reorder_tool_children.ReorderToolChildren |
IUC <tool> child-element order (#52). |
canonical.canonical_codemods() |
Ordered canonical/format pipeline (the app's format command). |
canonical.AUTO_UPGRADE_CODEMODS |
Ordered opt-in upgrade pipeline (the app's upgrade command). |
catalog.coded_codemods |
Every GTR-coded codemod, sorted by code (for the rule registry). |
eligibility.corpus_test_profile |
Codemod-sweep validation-profile policy (sweep default). |
Setup
From the workspace root:
uv sync
uv run --package galaxy-tool-codemod pytest galaxy-tool-codemod/tests/
Relationship to fmt and the app
Neither galaxy-tool-fmt's library nor its CLI depends on this
package — fmt is cosmetic-only. Orchestration lives one tier up: the
galaxy-tool-refactor app CLI (galaxy-tool-refactor-cli) hard-depends
on this package and on fmt, runs canonical_codemods() (its format
command) or AUTO_UPGRADE_CODEMODS (its upgrade command), and writes
the result through fmt's serializer.
Coding standards
Hand-written code follows dignified-python (vendored at
.claude/skills/dignified-python/). See CLAUDE.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file galaxy_tool_codemod-0.2.0.tar.gz.
File metadata
- Download URL: galaxy_tool_codemod-0.2.0.tar.gz
- Upload date:
- Size: 171.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
791cf60eb9c629c34d63c5504ebed2d1dc4c72108f5eb3af423394a3ac081870
|
|
| MD5 |
e0807a820a49d46fb3afef8c37019449
|
|
| BLAKE2b-256 |
f293a42a790d6b60e08d6362a377ad3ec57f999ae5cbcd141dceacb0c06c9744
|
Provenance
The following attestation bundles were made for galaxy_tool_codemod-0.2.0.tar.gz:
Publisher:
release.yml on richard-burhans/galaxy-tool-refactor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
galaxy_tool_codemod-0.2.0.tar.gz -
Subject digest:
791cf60eb9c629c34d63c5504ebed2d1dc4c72108f5eb3af423394a3ac081870 - Sigstore transparency entry: 1792636083
- Sigstore integration time:
-
Permalink:
richard-burhans/galaxy-tool-refactor@524c6b6ee8dba405f5d3b1d192d120d996140a65 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/richard-burhans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@524c6b6ee8dba405f5d3b1d192d120d996140a65 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file galaxy_tool_codemod-0.2.0-py3-none-any.whl.
File metadata
- Download URL: galaxy_tool_codemod-0.2.0-py3-none-any.whl
- Upload date:
- Size: 90.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d9e2082b2cfaac56455d8e65ca93476a3e59eddf1f34d35d5289c819916999a
|
|
| MD5 |
062e71a28ad4ae88fe9bf58c62e1a406
|
|
| BLAKE2b-256 |
8445841ff163831f2e5e264dc0dc8ca47150a6ecab2348e3f93add3dbbfa9c88
|
Provenance
The following attestation bundles were made for galaxy_tool_codemod-0.2.0-py3-none-any.whl:
Publisher:
release.yml on richard-burhans/galaxy-tool-refactor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
galaxy_tool_codemod-0.2.0-py3-none-any.whl -
Subject digest:
6d9e2082b2cfaac56455d8e65ca93476a3e59eddf1f34d35d5289c819916999a - Sigstore transparency entry: 1792636295
- Sigstore integration time:
-
Permalink:
richard-burhans/galaxy-tool-refactor@524c6b6ee8dba405f5d3b1d192d120d996140a65 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/richard-burhans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@524c6b6ee8dba405f5d3b1d192d120d996140a65 -
Trigger Event:
workflow_dispatch
-
Statement type: