roschema 0.1.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 (117) hide show
  1. roschema-0.1.0/.github/workflows/ci.yml +47 -0
  2. roschema-0.1.0/.github/workflows/release.yml +52 -0
  3. roschema-0.1.0/.gitignore +30 -0
  4. roschema-0.1.0/LICENSE +201 -0
  5. roschema-0.1.0/PKG-INFO +270 -0
  6. roschema-0.1.0/README.md +242 -0
  7. roschema-0.1.0/action/action.yml +51 -0
  8. roschema-0.1.0/docs/rules.md +313 -0
  9. roschema-0.1.0/pyproject.toml +61 -0
  10. roschema-0.1.0/src/roschema/__init__.py +3 -0
  11. roschema-0.1.0/src/roschema/cli.py +457 -0
  12. roschema-0.1.0/src/roschema/config.py +263 -0
  13. roschema-0.1.0/src/roschema/deep.py +114 -0
  14. roschema-0.1.0/src/roschema/differ.py +296 -0
  15. roschema-0.1.0/src/roschema/discovery/__init__.py +28 -0
  16. roschema-0.1.0/src/roschema/discovery/discover.py +74 -0
  17. roschema-0.1.0/src/roschema/discovery/model.py +55 -0
  18. roschema-0.1.0/src/roschema/discovery/resolve.py +209 -0
  19. roschema-0.1.0/src/roschema/formatter.py +48 -0
  20. roschema-0.1.0/src/roschema/freeze.py +109 -0
  21. roschema-0.1.0/src/roschema/ir.py +180 -0
  22. roschema-0.1.0/src/roschema/loader.py +32 -0
  23. roschema-0.1.0/src/roschema/mcap_fs.py +246 -0
  24. roschema-0.1.0/src/roschema/parser/__init__.py +36 -0
  25. roschema-0.1.0/src/roschema/parser/core.py +361 -0
  26. roschema-0.1.0/src/roschema/parser/errors.py +41 -0
  27. roschema-0.1.0/src/roschema/report/__init__.py +17 -0
  28. roschema-0.1.0/src/roschema/report/github.py +30 -0
  29. roschema-0.1.0/src/roschema/report/json_report.py +46 -0
  30. roschema-0.1.0/src/roschema/report/summary.py +64 -0
  31. roschema-0.1.0/src/roschema/report/text.py +106 -0
  32. roschema-0.1.0/src/roschema/rules/__init__.py +30 -0
  33. roschema-0.1.0/src/roschema/rules/breaking/__init__.py +44 -0
  34. roschema-0.1.0/src/roschema/rules/breaking/rs001_field_removed.py +27 -0
  35. roschema-0.1.0/src/roschema/rules/breaking/rs002_field_added.py +27 -0
  36. roschema-0.1.0/src/roschema/rules/breaking/rs003_field_type_changed.py +32 -0
  37. roschema-0.1.0/src/roschema/rules/breaking/rs004_fields_reordered.py +28 -0
  38. roschema-0.1.0/src/roschema/rules/breaking/rs005_field_renamed.py +28 -0
  39. roschema-0.1.0/src/roschema/rules/breaking/rs006_array_kind_changed.py +32 -0
  40. roschema-0.1.0/src/roschema/rules/breaking/rs007_bound_tightened.py +32 -0
  41. roschema-0.1.0/src/roschema/rules/breaking/rs008_bound_loosened.py +32 -0
  42. roschema-0.1.0/src/roschema/rules/breaking/rs020_constant_removed.py +24 -0
  43. roschema-0.1.0/src/roschema/rules/breaking/rs021_constant_value_changed.py +32 -0
  44. roschema-0.1.0/src/roschema/rules/breaking/rs022_constant_type_changed.py +29 -0
  45. roschema-0.1.0/src/roschema/rules/breaking/rs030_default_changed.py +38 -0
  46. roschema-0.1.0/src/roschema/rules/breaking/rs040_interface_removed.py +24 -0
  47. roschema-0.1.0/src/roschema/rules/breaking/rs060_message_version.py +39 -0
  48. roschema-0.1.0/src/roschema/rules/breaking/rs110_transitive.py +36 -0
  49. roschema-0.1.0/src/roschema/rules/gendocs.py +98 -0
  50. roschema-0.1.0/src/roschema/rules/lint/__init__.py +22 -0
  51. roschema-0.1.0/src/roschema/rules/lint/_common.py +34 -0
  52. roschema-0.1.0/src/roschema/rules/lint/rsl001_field_snake_case.py +36 -0
  53. roschema-0.1.0/src/roschema/rules/lint/rsl002_constant_upper_snake.py +33 -0
  54. roschema-0.1.0/src/roschema/rules/lint/rsl003_name_pascal_case.py +30 -0
  55. roschema-0.1.0/src/roschema/rules/lint/rsl004_missing_doc.py +35 -0
  56. roschema-0.1.0/src/roschema/rules/lint/rsl005_discouraged_types.py +42 -0
  57. roschema-0.1.0/src/roschema/rules/lint/rsl006_unbounded.py +43 -0
  58. roschema-0.1.0/src/roschema/rules/lint/rsl010_srv_shadow.py +43 -0
  59. roschema-0.1.0/src/roschema/rules/model.py +161 -0
  60. roschema-0.1.0/src/roschema/rules/registry.py +98 -0
  61. roschema-0.1.0/src/roschema/vfs.py +187 -0
  62. roschema-0.1.0/tests/_helpers.py +68 -0
  63. roschema-0.1.0/tests/conftest.py +14 -0
  64. roschema-0.1.0/tests/fixtures/AMENT_IGNORE +0 -0
  65. roschema-0.1.0/tests/fixtures/COLCON_IGNORE +0 -0
  66. roschema-0.1.0/tests/fixtures/golden_check.json +300 -0
  67. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/action/Move.action +5 -0
  68. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/ArrayKind.msg +1 -0
  69. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/BoundLoose.msg +1 -0
  70. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/BoundTight.msg +1 -0
  71. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/BoundedNest.msg +1 -0
  72. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/Constants.msg +3 -0
  73. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/Empty.msg +1 -0
  74. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/FieldAdded.msg +2 -0
  75. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/FieldRemoved.msg +1 -0
  76. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/Renamed.msg +1 -0
  77. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/Reordered.msg +2 -0
  78. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/Suppressed.msg +1 -0
  79. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/TypeChanged.msg +1 -0
  80. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/Unchanged.msg +1 -0
  81. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/msg/WeirdSpacing.msg +2 -0
  82. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/package.xml +4 -0
  83. roschema-0.1.0/tests/fixtures/ws_new/demo_msgs/srv/DoThing.srv +3 -0
  84. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/action/Move.action +5 -0
  85. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/ArrayKind.msg +1 -0
  86. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/BoundLoose.msg +1 -0
  87. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/BoundTight.msg +1 -0
  88. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/BoundedNest.msg +1 -0
  89. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/Constants.msg +4 -0
  90. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/Empty.msg +1 -0
  91. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/FieldAdded.msg +1 -0
  92. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/FieldRemoved.msg +2 -0
  93. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/Removed.msg +1 -0
  94. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/Renamed.msg +1 -0
  95. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/Reordered.msg +2 -0
  96. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/Suppressed.msg +1 -0
  97. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/TypeChanged.msg +1 -0
  98. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/Unchanged.msg +1 -0
  99. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/msg/WeirdSpacing.msg +2 -0
  100. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/package.xml +4 -0
  101. roschema-0.1.0/tests/fixtures/ws_old/demo_msgs/srv/DoThing.srv +3 -0
  102. roschema-0.1.0/tests/test_check_cli.py +182 -0
  103. roschema-0.1.0/tests/test_cli_ls.py +47 -0
  104. roschema-0.1.0/tests/test_config.py +149 -0
  105. roschema-0.1.0/tests/test_deep.py +75 -0
  106. roschema-0.1.0/tests/test_differ.py +136 -0
  107. roschema-0.1.0/tests/test_discovery.py +128 -0
  108. roschema-0.1.0/tests/test_fmt.py +94 -0
  109. roschema-0.1.0/tests/test_freeze.py +128 -0
  110. roschema-0.1.0/tests/test_gendocs.py +46 -0
  111. roschema-0.1.0/tests/test_golden.py +52 -0
  112. roschema-0.1.0/tests/test_lint.py +122 -0
  113. roschema-0.1.0/tests/test_mcap.py +196 -0
  114. roschema-0.1.0/tests/test_parser.py +243 -0
  115. roschema-0.1.0/tests/test_report_formats.py +96 -0
  116. roschema-0.1.0/tests/test_rules.py +127 -0
  117. roschema-0.1.0/tests/test_vfs.py +88 -0
@@ -0,0 +1,47 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: ci-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ lint:
14
+ name: lint & type-check
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: astral-sh/setup-uv@v5
19
+ with:
20
+ python-version: "3.12"
21
+ enable-cache: true
22
+ - name: Install
23
+ run: uv sync --extra dev --extra bag
24
+ - name: Ruff
25
+ run: uv run ruff check .
26
+ - name: Mypy
27
+ run: uv run mypy --strict src
28
+ - name: Rule docs in sync
29
+ run: uv run python -m roschema.rules.gendocs --check
30
+
31
+ test:
32
+ name: test (py${{ matrix.python-version }})
33
+ runs-on: ubuntu-latest
34
+ strategy:
35
+ fail-fast: false
36
+ matrix:
37
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - uses: astral-sh/setup-uv@v5
41
+ with:
42
+ python-version: ${{ matrix.python-version }}
43
+ enable-cache: true
44
+ - name: Install
45
+ run: uv sync --extra dev --extra bag
46
+ - name: Pytest
47
+ run: uv run pytest -q
@@ -0,0 +1,52 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ build:
9
+ name: build & verify
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: astral-sh/setup-uv@v5
14
+ with:
15
+ python-version: "3.12"
16
+ enable-cache: true
17
+ - name: Install
18
+ run: uv sync --extra dev --extra bag
19
+ - name: Test, lint, type-check
20
+ run: |
21
+ uv run pytest -q
22
+ uv run ruff check .
23
+ uv run mypy --strict src
24
+ uv run python -m roschema.rules.gendocs --check
25
+ - name: Tag matches package version
26
+ run: |
27
+ version=$(uv run python -c "import roschema; print(roschema.__version__)")
28
+ tag="${GITHUB_REF_NAME#v}"
29
+ if [ "$version" != "$tag" ]; then
30
+ echo "tag $tag does not match roschema.__version__ $version" >&2
31
+ exit 1
32
+ fi
33
+ - name: Build sdist and wheel
34
+ run: uv build
35
+ - uses: actions/upload-artifact@v4
36
+ with:
37
+ name: dist
38
+ path: dist/
39
+
40
+ publish:
41
+ name: publish to PyPI
42
+ needs: build
43
+ runs-on: ubuntu-latest
44
+ environment: pypi
45
+ permissions:
46
+ id-token: write # required for Trusted Publishing
47
+ steps:
48
+ - uses: actions/download-artifact@v4
49
+ with:
50
+ name: dist
51
+ path: dist/
52
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,30 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ uv.lock
9
+
10
+ # Virtual envs
11
+ .venv/
12
+ venv/
13
+ env/
14
+
15
+ # Tooling caches
16
+ .pytest_cache/
17
+ .mypy_cache/
18
+ .ruff_cache/
19
+ .coverage
20
+ htmlcov/
21
+ .tox/
22
+
23
+ # Editor / OS
24
+ .idea/
25
+ .vscode/
26
+ *.swp
27
+ .DS_Store
28
+
29
+ # internal bookkeeping docs
30
+ .docs
roschema-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Saif Sidhik
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,270 @@
1
+ Metadata-Version: 2.4
2
+ Name: roschema
3
+ Version: 0.1.0
4
+ Summary: Breaking-change detection, linting and formatting for ROS 2 interface definitions
5
+ Project-URL: Homepage, https://github.com/justagist/roschema
6
+ Project-URL: Documentation, https://github.com/justagist/roschema#readme
7
+ Author-email: Saif Sidhik <saif.sidhik@helloleap.ai>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: action,breaking-change,interface,lint,msg,ros,ros2,srv
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development :: Quality Assurance
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: rich>=13.0
18
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
19
+ Requires-Dist: typer>=0.12
20
+ Provides-Extra: bag
21
+ Requires-Dist: mcap>=1.1; extra == 'bag'
22
+ Provides-Extra: dev
23
+ Requires-Dist: mypy>=1.10; extra == 'dev'
24
+ Requires-Dist: pytest>=7.4; extra == 'dev'
25
+ Requires-Dist: ruff>=0.5; extra == 'dev'
26
+ Requires-Dist: tomli>=2.0; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # roschema
30
+
31
+ [![CI](https://github.com/justagist/roschema/actions/workflows/ci.yml/badge.svg)](https://github.com/justagist/roschema/actions/workflows/ci.yml)
32
+ [![PyPI](https://img.shields.io/pypi/v/roschema.svg)](https://pypi.org/project/roschema/)
33
+ [![Python versions](https://img.shields.io/pypi/pyversions/roschema.svg)](https://pypi.org/project/roschema/)
34
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
35
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
36
+ [![Checked with mypy](https://img.shields.io/badge/mypy-strict-blue.svg)](https://mypy-lang.org/)
37
+
38
+ Catch breaking ROS 2 interface changes in the PR, not on the robot.
39
+
40
+ `roschema` detects breaking changes, lints and formats ROS 2 interface
41
+ definitions (`.msg`, `.srv`, `.action`) with zero ROS dependencies, so it runs
42
+ in a bare CI container.
43
+
44
+ ![demo](docs/demo.gif)
45
+ <!-- TODO: replace with an animated capture of `roschema check` on a PR. -->
46
+
47
+ ## Quickstart
48
+
49
+ ```bash
50
+ # in a pull request, compare the working tree against the base branch
51
+ uvx roschema check --against origin/main
52
+ ```
53
+
54
+ See the full [rule reference](docs/rules.md) for every check (`RS***`) and lint
55
+ (`RSL***`) rule.
56
+
57
+ ## Checking
58
+
59
+ ```
60
+ roschema check [TARGET] --against REF [--level LEVEL] [--format text|json|github]
61
+ [--deep] [--exit-zero] [--config PATH] [--exclude GLOB]
62
+ ```
63
+
64
+ `TARGET` is a path, a package name, or a glob (`'src/**'`) that expands to every
65
+ package underneath; omit it for the current workspace.
66
+
67
+ `--against` accepts a git ref (validated with `git rev-parse`), a directory, an
68
+ MCAP bag (`.mcap`) or a lockfile (`roschema.lock`); the type is auto-detected. A
69
+ git ref is preferred when a directory of the same name also exists -- prefix the
70
+ argument with `./` (e.g. `--against ./main`) to force the directory. Exit codes:
71
+ `0` clean, `1` breaking changes found, `2` tool/usage error. `--exit-zero` forces
72
+ `0`. Warnings alone do not fail (exit `0`).
73
+
74
+ CDR is positional -- fields are serialised in declaration order with no field
75
+ tags -- so adding, removing, reordering or retyping a field is wire-breaking
76
+ even when your code still compiles. That is why the taxonomy is structural, and
77
+ why the default `source` level already reports wire-level changes.
78
+
79
+ ## Freeze (non-git baselines)
80
+
81
+ ```
82
+ roschema freeze [TARGET] -o roschema.lock
83
+ roschema check [TARGET] --against roschema.lock
84
+ ```
85
+
86
+ `freeze` writes a lockfile holding each interface's canonical (post-`fmt`) text
87
+ plus a sha256, so a release tarball can carry its own baseline without git.
88
+ `check --against roschema.lock` reads it back (sha256-verified) and compares.
89
+
90
+ The lockfile records the roschema `tool_version` for provenance; upgrading
91
+ roschema therefore changes that one line on the next `freeze` even when the
92
+ interfaces are identical. It is not read during comparison -- `check` diffs only
93
+ the interface text -- so the churn is cosmetic.
94
+
95
+ ## Deep checking
96
+
97
+ `check --deep` resolves nested complex types through the workspace and ament
98
+ index and reports transitive breakage (`RS110`): an interface that embeds -
99
+ directly or through nested types - another whose wire layout changed is flagged
100
+ even when its own definition is unchanged, with the causal chain shown. Without
101
+ `--deep`, nested types are compared by name only.
102
+
103
+ ## Linting and formatting
104
+
105
+ ```
106
+ roschema lint [TARGET] [--format text|json|github] [--rules RULE=SEV] [--exit-zero]
107
+ roschema fmt [TARGET] [--check]
108
+ ```
109
+
110
+ `lint` checks a single tree (no baseline). Naming rules follow rosidl: field
111
+ names snake_case (RSL001), constants UPPER_SNAKE (RSL002), interface names
112
+ PascalCase (RSL003); it also flags deprecated `char`/scalar-`byte` (RSL005) and
113
+ request/response field shadowing in services (RSL010). RSL004 (missing doc) and
114
+ RSL006 (unbounded) are off by default; enable via `[lint.rules]` or per run with
115
+ `--rules` (e.g. `--rules RSL004=warn --rules RSL001=off`; a bare `--rules RSL004`
116
+ means `=warn`). `--rules` is repeatable and beats config.
117
+
118
+ `fmt` canonically formats interface files (single space between type and name,
119
+ `=` without spaces for constants, one trailing newline) while preserving
120
+ comments, blank lines and section separators. It is idempotent and never
121
+ changes what `check` reports; `--check` exits `1` if any file would change.
122
+ Inline `# roschema: ignore=` suppressions survive formatting.
123
+
124
+ ## Checking against a recorded bag
125
+
126
+ ```
127
+ pip install 'roschema[bag]'
128
+ roschema bag-check recording.mcap [TARGETS...] [--format ...]
129
+ ```
130
+
131
+ `bag-check` reads the interface definitions embedded in an MCAP bag and checks
132
+ whether they are still compatible with your **current environment** - the bag is
133
+ the baseline, so it flags changes that would stop current code from reading the
134
+ recorded data. By default the bag's types are resolved from the ament index
135
+ (`AMENT_PREFIX_PATH`), i.e. the packages installed in the sourced environment,
136
+ so system packages like `sensor_msgs` are compared against their installed
137
+ definitions rather than reported as missing.
138
+
139
+ Optional `TARGETS` (paths or package names) are overlaid on top of the
140
+ environment, so a package you are editing can be checked from source instead of
141
+ its installed copy. A bag type found in neither the environment nor any target
142
+ is reported as removed (RS040). `ros2msg` schemas (including concatenated
143
+ dependent definitions) are fully supported; `ros2idl` is a best-effort
144
+ conversion of the msg-equivalent subset.
145
+
146
+ ## Compatibility levels
147
+
148
+ `--level` selects a cumulative bundle of what is reported; the default is
149
+ `source`.
150
+
151
+ | Level | Reports |
152
+ |---|---|
153
+ | `wire` | CDR byte-stream compatibility only |
154
+ | `source` | wire + generated C++/Python API |
155
+ | `introspection` | source + name-based tooling (bags, echo, YAML) |
156
+ | `behavior` | introspection + semantics (defaults, constant values) |
157
+
158
+ ## Configuration
159
+
160
+ `roschema.toml` at the workspace root, a per-package `roschema.toml`, or
161
+ `[tool.roschema]` in `pyproject.toml`. Precedence: CLI > package > workspace >
162
+ defaults.
163
+
164
+ ```toml
165
+ [check]
166
+ level = "source"
167
+
168
+ [check.rules]
169
+ RS008 = "off" # off | warn | error
170
+
171
+ [check.allow]
172
+ # intentional breaks need a fully-qualified target and a mandatory reason
173
+ "my_msgs/msg/State.old_field" = { rules = ["RS001"], reason = "removed in 2.0, see #142" }
174
+ ```
175
+
176
+ Inline suppression: a trailing comment on the new-side member line, e.g.
177
+ `float64 theta # roschema: ignore=RS003` (comma-separate multiple IDs).
178
+ Suppressed findings are counted, not failed.
179
+
180
+ ## JSON output
181
+
182
+ `--format json` emits a stable document (`version: 1`):
183
+
184
+ ```json
185
+ {
186
+ "version": 1,
187
+ "findings": [
188
+ {
189
+ "rule": "RS003",
190
+ "severity": "error",
191
+ "level": "wire",
192
+ "package": "my_msgs",
193
+ "interface": "my_msgs/msg/Pose",
194
+ "section": "message",
195
+ "target": "theta",
196
+ "message": "type changed float32 -> float64",
197
+ "old": { "file": "my_msgs/msg/Pose.msg", "line": 1 },
198
+ "new": { "file": "my_msgs/msg/Pose.msg", "line": 1 },
199
+ "suppressed": false
200
+ }
201
+ ],
202
+ "summary": {
203
+ "total": 1,
204
+ "errors": 1,
205
+ "warnings": 0,
206
+ "suppressed": 0,
207
+ "advisories": { "my_msgs": "MAJOR" }
208
+ }
209
+ }
210
+ ```
211
+
212
+ `old`/`new` are `null` when there is no corresponding side (e.g. a removed
213
+ interface has no `new`). `--format github` emits `::error`/`::warning`
214
+ workflow-command annotations instead.
215
+
216
+ ## GitHub Action
217
+
218
+ A composite action wraps `uvx roschema check` and posts inline annotations on
219
+ the PR diff:
220
+
221
+ ```yaml
222
+ # .github/workflows/interfaces.yml
223
+ on: pull_request
224
+ jobs:
225
+ interfaces:
226
+ runs-on: ubuntu-latest
227
+ steps:
228
+ - uses: actions/checkout@v4
229
+ with:
230
+ fetch-depth: 0 # needed for the git-ref baseline
231
+ - uses: justagist/roschema/action@v1
232
+ with:
233
+ against: origin/${{ github.base_ref }}
234
+ # level: source
235
+ # deep: "true"
236
+ # exclude: "vendor_msgs* legacy_msgs/msg/Old"
237
+ ```
238
+
239
+ `against` takes the same values as the CLI (git ref, directory, `.mcap`,
240
+ `roschema.lock`). A lockfile or directory baseline needs no `fetch-depth: 0`
241
+ because it is a plain file in the checkout.
242
+
243
+ ## Rule reference
244
+
245
+ Every rule, its levels, default severity and rationale is documented in
246
+ [docs/rules.md](docs/rules.md), generated from the rule metadata with
247
+ `python -m roschema.rules.gendocs`.
248
+
249
+ ## Non-goals
250
+
251
+ roschema deliberately does **not**:
252
+
253
+ - generate migration or translation rules;
254
+ - parse ROS 1 `.msg` (md5 semantics differ);
255
+ - parse hand-written `.idl` beyond the MCAP-embedded subset;
256
+ - provide any registry or server component;
257
+ - parse `CMakeLists.txt` for discovery (directory convention + ament index only).
258
+
259
+ ## Relationship to REP-2011 and type hashes
260
+
261
+ These are complementary layers, not alternatives:
262
+
263
+ - **roschema** prevents *accidental* breaks at PR time, before anything ships.
264
+ - **RIHS type hashes** (REP-2011) detect a pub/sub *mismatch at runtime* -- after
265
+ the fact, on the robot.
266
+ - **REP-2011 type-description distribution / translation** mitigates *intentional*
267
+ evolution by carrying enough information to translate between versions.
268
+
269
+ roschema is the earliest gate: catch the break in review so the later layers
270
+ never have to.