robotframework-testselection 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 (39) hide show
  1. robotframework_testselection-0.1.0/.gitignore +36 -0
  2. robotframework_testselection-0.1.0/LICENSE +191 -0
  3. robotframework_testselection-0.1.0/PKG-INFO +408 -0
  4. robotframework_testselection-0.1.0/README.md +350 -0
  5. robotframework_testselection-0.1.0/pyproject.toml +130 -0
  6. robotframework_testselection-0.1.0/src/TestSelection/__init__.py +3 -0
  7. robotframework_testselection-0.1.0/src/TestSelection/cli.py +256 -0
  8. robotframework_testselection-0.1.0/src/TestSelection/embedding/__init__.py +1 -0
  9. robotframework_testselection-0.1.0/src/TestSelection/embedding/embedder.py +43 -0
  10. robotframework_testselection-0.1.0/src/TestSelection/embedding/models.py +198 -0
  11. robotframework_testselection-0.1.0/src/TestSelection/embedding/ports.py +24 -0
  12. robotframework_testselection-0.1.0/src/TestSelection/execution/__init__.py +1 -0
  13. robotframework_testselection-0.1.0/src/TestSelection/execution/listener.py +44 -0
  14. robotframework_testselection-0.1.0/src/TestSelection/execution/prerun_modifier.py +43 -0
  15. robotframework_testselection-0.1.0/src/TestSelection/execution/runner.py +75 -0
  16. robotframework_testselection-0.1.0/src/TestSelection/parsing/__init__.py +1 -0
  17. robotframework_testselection-0.1.0/src/TestSelection/parsing/datadriver_reader.py +54 -0
  18. robotframework_testselection-0.1.0/src/TestSelection/parsing/keyword_resolver.py +51 -0
  19. robotframework_testselection-0.1.0/src/TestSelection/parsing/suite_collector.py +85 -0
  20. robotframework_testselection-0.1.0/src/TestSelection/parsing/text_builder.py +79 -0
  21. robotframework_testselection-0.1.0/src/TestSelection/pipeline/__init__.py +1 -0
  22. robotframework_testselection-0.1.0/src/TestSelection/pipeline/artifacts.py +110 -0
  23. robotframework_testselection-0.1.0/src/TestSelection/pipeline/cache.py +74 -0
  24. robotframework_testselection-0.1.0/src/TestSelection/pipeline/errors.py +18 -0
  25. robotframework_testselection-0.1.0/src/TestSelection/pipeline/execute.py +52 -0
  26. robotframework_testselection-0.1.0/src/TestSelection/pipeline/select.py +183 -0
  27. robotframework_testselection-0.1.0/src/TestSelection/pipeline/vectorize.py +190 -0
  28. robotframework_testselection-0.1.0/src/TestSelection/py.typed +0 -0
  29. robotframework_testselection-0.1.0/src/TestSelection/selection/__init__.py +25 -0
  30. robotframework_testselection-0.1.0/src/TestSelection/selection/dpp.py +31 -0
  31. robotframework_testselection-0.1.0/src/TestSelection/selection/facility.py +25 -0
  32. robotframework_testselection-0.1.0/src/TestSelection/selection/filtering.py +21 -0
  33. robotframework_testselection-0.1.0/src/TestSelection/selection/fps.py +67 -0
  34. robotframework_testselection-0.1.0/src/TestSelection/selection/kmedoids.py +32 -0
  35. robotframework_testselection-0.1.0/src/TestSelection/selection/registry.py +70 -0
  36. robotframework_testselection-0.1.0/src/TestSelection/selection/strategy.py +142 -0
  37. robotframework_testselection-0.1.0/src/TestSelection/shared/__init__.py +1 -0
  38. robotframework_testselection-0.1.0/src/TestSelection/shared/config.py +31 -0
  39. robotframework_testselection-0.1.0/src/TestSelection/shared/types.py +117 -0
@@ -0,0 +1,36 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ *.egg
6
+ dist/
7
+ build/
8
+
9
+ # Virtual environments
10
+ .venv/
11
+
12
+ # Testing
13
+ .pytest_cache/
14
+ .coverage
15
+ htmlcov/
16
+ results/
17
+
18
+ # IDE
19
+ .idea/
20
+ .vscode/
21
+ *.swp
22
+
23
+ # Tools
24
+ .ruff_cache/
25
+ .mypy_cache/
26
+
27
+ # Claude Flow
28
+ .claude-flow/
29
+ .claude/
30
+
31
+ # Example suite (cloned repos, not part of the package)
32
+ example-suite/
33
+
34
+ # Artifacts
35
+ artifacts/
36
+ *.npz
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2024 Many Kasiriha
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,408 @@
1
+ Metadata-Version: 2.4
2
+ Name: robotframework-testselection
3
+ Version: 0.1.0
4
+ Summary: Vector-based diverse test case selection for Robot Framework
5
+ Project-URL: Homepage, https://github.com/manykarim/robotframework-testselection
6
+ Project-URL: Documentation, https://github.com/manykarim/robotframework-testselection#readme
7
+ Project-URL: Repository, https://github.com/manykarim/robotframework-testselection
8
+ Project-URL: Issues, https://github.com/manykarim/robotframework-testselection/issues
9
+ Project-URL: Changelog, https://github.com/manykarim/robotframework-testselection/blob/main/CHANGELOG.md
10
+ Author: Many Kasiriha
11
+ License: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: diversity,embeddings,machine-learning,nlp,robotframework,test-selection,testing
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Framework :: Robot Framework
16
+ Classifier: Framework :: Robot Framework :: Library
17
+ Classifier: Framework :: Robot Framework :: Tool
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: License :: OSI Approved :: Apache Software License
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Topic :: Software Development :: Quality Assurance
27
+ Classifier: Topic :: Software Development :: Testing
28
+ Requires-Python: >=3.10
29
+ Requires-Dist: numpy>=1.24
30
+ Requires-Dist: robotframework>=7.0
31
+ Requires-Dist: scikit-learn>=1.3
32
+ Provides-Extra: all
33
+ Requires-Dist: apricot-select>=0.6; extra == 'all'
34
+ Requires-Dist: chromadb>=0.4; extra == 'all'
35
+ Requires-Dist: dppy>=0.3; extra == 'all'
36
+ Requires-Dist: mypy; extra == 'all'
37
+ Requires-Dist: pytest-benchmark; extra == 'all'
38
+ Requires-Dist: pytest-cov; extra == 'all'
39
+ Requires-Dist: pytest>=8.0; extra == 'all'
40
+ Requires-Dist: ruff; extra == 'all'
41
+ Requires-Dist: scikit-learn-extra>=0.3; extra == 'all'
42
+ Requires-Dist: sentence-transformers>=2.2; extra == 'all'
43
+ Provides-Extra: chromadb
44
+ Requires-Dist: chromadb>=0.4; extra == 'chromadb'
45
+ Provides-Extra: dev
46
+ Requires-Dist: mypy; extra == 'dev'
47
+ Requires-Dist: pytest-benchmark; extra == 'dev'
48
+ Requires-Dist: pytest-cov; extra == 'dev'
49
+ Requires-Dist: pytest>=8.0; extra == 'dev'
50
+ Requires-Dist: ruff; extra == 'dev'
51
+ Provides-Extra: selection-extras
52
+ Requires-Dist: apricot-select>=0.6; extra == 'selection-extras'
53
+ Requires-Dist: dppy>=0.3; extra == 'selection-extras'
54
+ Requires-Dist: scikit-learn-extra>=0.3; extra == 'selection-extras'
55
+ Provides-Extra: vectorize
56
+ Requires-Dist: sentence-transformers>=2.2; extra == 'vectorize'
57
+ Description-Content-Type: text/markdown
58
+
59
+ # robotframework-testselection
60
+
61
+ Vector-based diverse test case selection for Robot Framework. Embeds test cases as semantic vectors and selects maximally diverse subsets to reduce test suite execution time while preserving coverage breadth.
62
+
63
+ ## How It Works
64
+
65
+ The system operates as a **3-stage pipeline**:
66
+
67
+ ```
68
+ Vectorize Select Execute
69
+ (.robot files) ──► (embeddings.npz ──► (selected_tests.json
70
+ test_manifest.json) + robot --prerunmodifier)
71
+ ```
72
+
73
+ 1. **Vectorize** — Parses `.robot` files via the Robot Framework API, converts each test case to a natural-language text representation (name + tags + resolved keyword tree), then encodes with `all-MiniLM-L6-v2` (384-dim sentence embeddings).
74
+ 2. **Select** — Loads embedding vectors and applies a diversity-maximizing selection algorithm (default: Farthest Point Sampling) to choose *k* tests that are as semantically different from each other as possible.
75
+ 3. **Execute** — Runs the selected tests via Robot Framework using a `PreRunModifier` (for standard tests) and a `Listener v3` (for DataDriver-generated tests).
76
+
77
+ If any stage fails, the pipeline **gracefully degrades** by running all tests (exit code 2).
78
+
79
+ ## Installation
80
+
81
+ ```bash
82
+ # From PyPI
83
+ pip install robotframework-testselection
84
+
85
+ # With sentence-transformers for vectorization
86
+ pip install robotframework-testselection[vectorize]
87
+
88
+ # With all optional selection algorithms
89
+ pip install robotframework-testselection[selection-extras]
90
+
91
+ # Everything
92
+ pip install robotframework-testselection[all]
93
+ ```
94
+
95
+ ### Development Install (from source)
96
+
97
+ Requires Python 3.10+ and [uv](https://docs.astral.sh/uv/).
98
+
99
+ ```bash
100
+ uv sync --extra vectorize
101
+ uv sync --extra all
102
+ ```
103
+
104
+ ### Dependency Groups
105
+
106
+ | Group | Packages | Purpose |
107
+ |-------|----------|---------|
108
+ | *(base)* | `robotframework`, `numpy`, `scikit-learn` | Core pipeline |
109
+ | `vectorize` | `sentence-transformers` | Embedding model (Stage 1) |
110
+ | `selection-extras` | `scikit-learn-extra`, `dppy`, `apricot-select` | k-Medoids, DPP, Facility Location strategies |
111
+ | `chromadb` | `chromadb` | Alternative vector storage |
112
+ | `dev` | `pytest`, `pytest-cov`, `pytest-benchmark`, `ruff`, `mypy` | Development |
113
+
114
+ ## Quick Start
115
+
116
+ ### Full Pipeline (one command)
117
+
118
+ ```bash
119
+ testcase-select run \
120
+ --suite tests/robot/ \
121
+ --k 20 \
122
+ --strategy fps \
123
+ --seed 42 \
124
+ --output-dir ./results/
125
+ ```
126
+
127
+ ### Stage-by-Stage
128
+
129
+ ```bash
130
+ # Stage 1: Vectorize
131
+ testcase-select vectorize \
132
+ --suite tests/robot/ \
133
+ --output ./artifacts/ \
134
+ --model all-MiniLM-L6-v2 \
135
+ --resolve-depth 2
136
+
137
+ # Stage 2: Select
138
+ testcase-select select \
139
+ --artifacts ./artifacts/ \
140
+ --k 20 \
141
+ --strategy fps \
142
+ --seed 42 \
143
+ --output selected_tests.json
144
+
145
+ # Stage 3: Execute
146
+ testcase-select execute \
147
+ --suite tests/robot/ \
148
+ --selection selected_tests.json \
149
+ --output-dir ./results/
150
+ ```
151
+
152
+ ### With DataDriver CSV Files
153
+
154
+ ```bash
155
+ testcase-select vectorize \
156
+ --suite tests/robot/ \
157
+ --output ./artifacts/ \
158
+ --datadriver-csv tests/data/login.csv tests/data/search.csv
159
+ ```
160
+
161
+ ### Direct Robot Framework Integration
162
+
163
+ You can also use the components directly with `robot`:
164
+
165
+ ```bash
166
+ # PreRunModifier for standard tests
167
+ robot --prerunmodifier TestSelection.execution.prerun_modifier.DiversePreRunModifier:selected_tests.json tests/
168
+
169
+ # Listener v3 for DataDriver tests
170
+ robot --listener TestSelection.execution.listener.DiverseDataDriverListener:selected_tests.json tests/
171
+
172
+ # Both together
173
+ robot \
174
+ --prerunmodifier TestSelection.execution.prerun_modifier.DiversePreRunModifier:selected_tests.json \
175
+ --listener TestSelection.execution.listener.DiverseDataDriverListener:selected_tests.json \
176
+ tests/
177
+ ```
178
+
179
+ ## Environment Variables
180
+
181
+ | Variable | Default | Description |
182
+ |----------|---------|-------------|
183
+ | `DIVERSE_K` | `50` | Number of tests to select |
184
+ | `DIVERSE_STRATEGY` | `fps` | Selection algorithm |
185
+ | `DIVERSE_SEED` | `42` | Random seed for reproducibility |
186
+ | `DIVERSE_OUTPUT` | *(none)* | Output file path for selection JSON |
187
+
188
+ ## Selection Strategies
189
+
190
+ | Strategy | Name | Dependencies | Description |
191
+ |----------|------|-------------|-------------|
192
+ | **FPS** | `fps` | *(base)* | Farthest Point Sampling. Greedy farthest-first traversal. O(N*k*d). 2-approximation guarantee for max-min dispersion. **Default.** |
193
+ | **FPS Multi-Start** | `fps_multi` | *(base)* | Runs FPS from multiple random starting points, keeps the result with the highest minimum pairwise distance. Mitigates initial-point sensitivity. |
194
+ | **k-Medoids** | `kmedoids` | `selection-extras` | PAM algorithm for medoid-based clustering. Better centroid representativeness. |
195
+ | **DPP** | `dpp` | `selection-extras` | Determinantal Point Process. Probabilistic repulsion-based sampling. |
196
+ | **Facility Location** | `facility` | `selection-extras` | Submodular facility location maximization. Optimizes for both diversity and representativeness. |
197
+
198
+ ## Tag Filtering
199
+
200
+ Filter tests by tags before selection:
201
+
202
+ ```bash
203
+ # Include only smoke and regression tests
204
+ testcase-select select \
205
+ --artifacts ./artifacts/ \
206
+ --k 20 \
207
+ --include-tags smoke regression
208
+
209
+ # Exclude slow tests
210
+ testcase-select select \
211
+ --artifacts ./artifacts/ \
212
+ --k 20 \
213
+ --exclude-tags slow manual
214
+
215
+ # Exclude DataDriver tests
216
+ testcase-select select \
217
+ --artifacts ./artifacts/ \
218
+ --k 20 \
219
+ --no-datadriver
220
+ ```
221
+
222
+ ## Caching
223
+
224
+ Stage 1 uses **content-hash caching**. It computes MD5 hashes of all `.robot` and `.csv` files and stores them alongside artifacts. On subsequent runs, vectorization is skipped when no source files have changed. Use `--force` to bypass the cache:
225
+
226
+ ```bash
227
+ testcase-select vectorize --suite tests/ --output ./artifacts/ --force
228
+ ```
229
+
230
+ ## Artifacts
231
+
232
+ The pipeline produces these artifacts:
233
+
234
+ | File | Stage | Format | Contents |
235
+ |------|-------|--------|----------|
236
+ | `embeddings.npz` | Vectorize | NumPy compressed | N x 384 float32 matrix |
237
+ | `test_manifest.json` | Vectorize | JSON | Test metadata (names, tags, suites, IDs) |
238
+ | `file_hashes.json` | Vectorize | JSON | Source file MD5 hashes for cache invalidation |
239
+ | `selected_tests.json` | Select | JSON | Selected test list + diversity metrics |
240
+
241
+ ### Selection Output Format
242
+
243
+ ```json
244
+ {
245
+ "strategy": "fps",
246
+ "k": 20,
247
+ "seed": 42,
248
+ "total_tests": 150,
249
+ "filtered_tests": 120,
250
+ "selected": [
251
+ {
252
+ "name": "Login With Valid Credentials",
253
+ "id": "a1b2c3d4...",
254
+ "suite": "tests/login.robot",
255
+ "is_datadriver": false
256
+ }
257
+ ],
258
+ "diversity_metrics": {
259
+ "avg_pairwise_distance": 0.8234,
260
+ "min_pairwise_distance": 0.4512,
261
+ "suite_coverage": 8,
262
+ "suite_total": 10
263
+ }
264
+ }
265
+ ```
266
+
267
+ ## CI/CD Integration
268
+
269
+ Pre-built configurations are provided in `config/`:
270
+
271
+ ### GitHub Actions
272
+
273
+ ```yaml
274
+ # .github/workflows/diverse-tests.yml
275
+ # Copy from config/github-actions.yml
276
+ ```
277
+
278
+ Features:
279
+ - 3-job pipeline with artifact transfer between stages
280
+ - Content-hash caching (`actions/cache@v4`) to skip vectorization
281
+ - Automatic PR annotations with selection summary
282
+ - `workflow_dispatch` for manual runs with custom k/strategy
283
+
284
+ ### GitLab CI
285
+
286
+ ```yaml
287
+ # .gitlab-ci.yml
288
+ # Copy from config/gitlab-ci.yml
289
+ ```
290
+
291
+ ### Jenkins
292
+
293
+ ```groovy
294
+ // Jenkinsfile
295
+ // Copy from config/Jenkinsfile
296
+ ```
297
+
298
+ ## Project Structure
299
+
300
+ ```
301
+ src/TestSelection/
302
+ shared/ # Shared kernel (types, config)
303
+ types.py # TestCaseId, Tag, TestCaseRecord, KeywordTree, ...
304
+ config.py # PipelineConfig, TextBuilderConfig
305
+ parsing/ # Bounded context: Robot Framework parsing
306
+ suite_collector.py # RobotApiAdapter (TestSuite.from_file_system)
307
+ keyword_resolver.py# Recursive keyword tree resolution
308
+ text_builder.py # Natural language text representation
309
+ datadriver_reader.py # DataDriver CSV reader
310
+ embedding/ # Bounded context: vector embedding
311
+ ports.py # EmbeddingModel protocol
312
+ embedder.py # SentenceTransformerAdapter (ACL)
313
+ models.py # EmbeddingMatrix aggregate, ManifestEntry
314
+ selection/ # Bounded context: diversity selection
315
+ strategy.py # SelectionStrategy protocol, SelectionResult
316
+ fps.py # FarthestPointSampling, FPSMultiStart
317
+ kmedoids.py # KMedoidsSelection (optional)
318
+ dpp.py # DPPSelection (optional)
319
+ facility.py # FacilityLocationSelection (optional)
320
+ registry.py # StrategyRegistry with auto-discovery
321
+ filtering.py # Tag-based pre-selection filtering
322
+ execution/ # Bounded context: Robot Framework execution
323
+ prerun_modifier.py # DiversePreRunModifier (SuiteVisitor)
324
+ listener.py # DiverseDataDriverListener (Listener v3)
325
+ runner.py # ExecutionRunner
326
+ pipeline/ # Orchestration layer
327
+ vectorize.py # Stage 1 orchestrator
328
+ select.py # Stage 2 orchestrator
329
+ execute.py # Stage 3 orchestrator
330
+ cache.py # Content-hash cache invalidator
331
+ artifacts.py # Artifact storage and validation
332
+ errors.py # Domain error hierarchy
333
+ cli.py # CLI entry point (argparse)
334
+
335
+ tests/
336
+ fixtures/ # Sample .robot and .csv files
337
+ unit/ # Unit tests
338
+ integration/ # Integration tests
339
+ benchmarks/ # Performance benchmarks
340
+ ```
341
+
342
+ ## Development
343
+
344
+ ```bash
345
+ # Install with dev dependencies
346
+ uv sync --extra dev
347
+
348
+ # Run all tests
349
+ uv run pytest tests/ -v --benchmark-disable
350
+
351
+ # Run unit tests only
352
+ uv run pytest tests/unit/ -v
353
+
354
+ # Run integration tests only
355
+ uv run pytest tests/integration/ -v
356
+
357
+ # Run benchmarks
358
+ uv run pytest tests/benchmarks/ -v
359
+
360
+ # Lint
361
+ uv run ruff check src/
362
+
363
+ # Type check
364
+ uv run mypy src/
365
+ ```
366
+
367
+ ### Test Markers
368
+
369
+ ```bash
370
+ # Skip slow tests (ML model loading)
371
+ uv run pytest -m "not slow"
372
+
373
+ # Only integration tests
374
+ uv run pytest -m integration
375
+
376
+ # Only benchmarks
377
+ uv run pytest -m benchmark
378
+ ```
379
+
380
+ ## Performance
381
+
382
+ Benchmarked on 384-dimensional normalized vectors:
383
+
384
+ | N (tests) | FPS Time | FPS Multi (5 starts) |
385
+ |-----------|----------|---------------------|
386
+ | 100 | 12 ms | — |
387
+ | 500 | 99 ms | — |
388
+ | 1,000 | 304 ms | 376 ms (3 starts) |
389
+ | 5,000 | 8.0 s | — |
390
+
391
+ Keyword resolution: ~18 us/depth-1 resolve, ~61 us/depth-3 resolve. Text building for 100 tests: ~458 us.
392
+
393
+ ## Architecture Decision Records
394
+
395
+ | ADR | Title |
396
+ |-----|-------|
397
+ | [ADR-001](docs/adr/ADR-001-pipeline-architecture.md) | 3-Stage Pipeline Architecture |
398
+ | [ADR-002](docs/adr/ADR-002-embedding-model-and-storage.md) | Embedding Model and Storage |
399
+ | [ADR-003](docs/adr/ADR-003-selection-algorithm-strategy.md) | Selection Algorithm Strategy Pattern |
400
+ | [ADR-004](docs/adr/ADR-004-robot-framework-integration.md) | Robot Framework Integration |
401
+ | [ADR-005](docs/adr/ADR-005-project-structure-and-uv.md) | Project Structure and uv |
402
+ | [ADR-006](docs/adr/ADR-006-text-representation-strategy.md) | Text Representation Strategy |
403
+ | [ADR-007](docs/adr/ADR-007-cicd-integration-and-caching.md) | CI/CD Integration and Caching |
404
+ | [ADR-008](docs/adr/ADR-008-reliability-and-observability.md) | Reliability and Observability |
405
+
406
+ ## License
407
+
408
+ Apache 2.0