rhscope 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 (100) hide show
  1. rhscope-0.1.0/.gitignore +64 -0
  2. rhscope-0.1.0/CHANGELOG.md +230 -0
  3. rhscope-0.1.0/LICENSE +201 -0
  4. rhscope-0.1.0/PKG-INFO +212 -0
  5. rhscope-0.1.0/README.md +157 -0
  6. rhscope-0.1.0/examples/README.md +23 -0
  7. rhscope-0.1.0/pyproject.toml +208 -0
  8. rhscope-0.1.0/src/rhscope/__init__.py +83 -0
  9. rhscope-0.1.0/src/rhscope/_deps.py +97 -0
  10. rhscope-0.1.0/src/rhscope/activations.py +329 -0
  11. rhscope-0.1.0/src/rhscope/bench/__init__.py +86 -0
  12. rhscope-0.1.0/src/rhscope/bench/compare.py +351 -0
  13. rhscope-0.1.0/src/rhscope/bench/curation.py +279 -0
  14. rhscope-0.1.0/src/rhscope/bench/detectors.py +286 -0
  15. rhscope-0.1.0/src/rhscope/bench/leaderboard.py +275 -0
  16. rhscope-0.1.0/src/rhscope/bench/ref_delta.py +278 -0
  17. rhscope-0.1.0/src/rhscope/bench/result.py +138 -0
  18. rhscope-0.1.0/src/rhscope/bench/rhdetect.py +347 -0
  19. rhscope-0.1.0/src/rhscope/cli.py +764 -0
  20. rhscope-0.1.0/src/rhscope/envs/__init__.py +35 -0
  21. rhscope-0.1.0/src/rhscope/envs/base.py +153 -0
  22. rhscope-0.1.0/src/rhscope/envs/code_shortcut.py +676 -0
  23. rhscope-0.1.0/src/rhscope/hub.py +222 -0
  24. rhscope-0.1.0/src/rhscope/integrations/__init__.py +39 -0
  25. rhscope-0.1.0/src/rhscope/integrations/base.py +185 -0
  26. rhscope-0.1.0/src/rhscope/integrations/dpo.py +178 -0
  27. rhscope-0.1.0/src/rhscope/integrations/sinks.py +164 -0
  28. rhscope-0.1.0/src/rhscope/integrations/trl.py +174 -0
  29. rhscope-0.1.0/src/rhscope/integrations/verl.py +266 -0
  30. rhscope-0.1.0/src/rhscope/io.py +98 -0
  31. rhscope-0.1.0/src/rhscope/metadata.py +92 -0
  32. rhscope-0.1.0/src/rhscope/metrics.py +437 -0
  33. rhscope-0.1.0/src/rhscope/model_card.py +287 -0
  34. rhscope-0.1.0/src/rhscope/monitor.py +296 -0
  35. rhscope-0.1.0/src/rhscope/probes/__init__.py +34 -0
  36. rhscope-0.1.0/src/rhscope/probes/base.py +220 -0
  37. rhscope-0.1.0/src/rhscope/probes/dom.py +161 -0
  38. rhscope-0.1.0/src/rhscope/probes/logistic.py +172 -0
  39. rhscope-0.1.0/src/rhscope/probes/mlp.py +250 -0
  40. rhscope-0.1.0/src/rhscope/probes/online.py +290 -0
  41. rhscope-0.1.0/src/rhscope/probes/tokens.py +294 -0
  42. rhscope-0.1.0/src/rhscope/py.typed +0 -0
  43. rhscope-0.1.0/src/rhscope/recipes/__init__.py +50 -0
  44. rhscope-0.1.0/src/rhscope/recipes/config.py +303 -0
  45. rhscope-0.1.0/src/rhscope/recipes/grpo.py +456 -0
  46. rhscope-0.1.0/src/rhscope/recipes/probe_grid.py +368 -0
  47. rhscope-0.1.0/src/rhscope/recipes/run.py +26 -0
  48. rhscope-0.1.0/src/rhscope/research/__init__.py +31 -0
  49. rhscope-0.1.0/src/rhscope/research/evasion.py +497 -0
  50. rhscope-0.1.0/src/rhscope/sandbox.py +362 -0
  51. rhscope-0.1.0/src/rhscope/training/__init__.py +21 -0
  52. rhscope-0.1.0/src/rhscope/training/data.py +185 -0
  53. rhscope-0.1.0/src/rhscope/training/layer_select.py +38 -0
  54. rhscope-0.1.0/src/rhscope/training/trainer.py +360 -0
  55. rhscope-0.1.0/tests/conftest.py +73 -0
  56. rhscope-0.1.0/tests/fixtures/synthetic_hack.jsonl +32 -0
  57. rhscope-0.1.0/tests/test_activation_cache.py +186 -0
  58. rhscope-0.1.0/tests/test_activations.py +219 -0
  59. rhscope-0.1.0/tests/test_bench_compare.py +139 -0
  60. rhscope-0.1.0/tests/test_bench_composite_detector.py +114 -0
  61. rhscope-0.1.0/tests/test_bench_curation.py +194 -0
  62. rhscope-0.1.0/tests/test_bench_detectors.py +59 -0
  63. rhscope-0.1.0/tests/test_bench_leaderboard.py +270 -0
  64. rhscope-0.1.0/tests/test_bench_ref_delta.py +212 -0
  65. rhscope-0.1.0/tests/test_bench_result.py +76 -0
  66. rhscope-0.1.0/tests/test_bench_rhdetect.py +194 -0
  67. rhscope-0.1.0/tests/test_cli.py +357 -0
  68. rhscope-0.1.0/tests/test_deps.py +104 -0
  69. rhscope-0.1.0/tests/test_env_registry.py +64 -0
  70. rhscope-0.1.0/tests/test_envs_base.py +64 -0
  71. rhscope-0.1.0/tests/test_envs_code_shortcut.py +294 -0
  72. rhscope-0.1.0/tests/test_hub.py +138 -0
  73. rhscope-0.1.0/tests/test_integrations_base.py +120 -0
  74. rhscope-0.1.0/tests/test_integrations_dpo.py +152 -0
  75. rhscope-0.1.0/tests/test_integrations_sinks.py +74 -0
  76. rhscope-0.1.0/tests/test_integrations_trl.py +266 -0
  77. rhscope-0.1.0/tests/test_integrations_verl.py +157 -0
  78. rhscope-0.1.0/tests/test_io.py +130 -0
  79. rhscope-0.1.0/tests/test_metadata.py +93 -0
  80. rhscope-0.1.0/tests/test_metrics.py +158 -0
  81. rhscope-0.1.0/tests/test_metrics_classification.py +138 -0
  82. rhscope-0.1.0/tests/test_model_card.py +147 -0
  83. rhscope-0.1.0/tests/test_monitor.py +160 -0
  84. rhscope-0.1.0/tests/test_probe_from_pretrained.py +78 -0
  85. rhscope-0.1.0/tests/test_probe_grid.py +126 -0
  86. rhscope-0.1.0/tests/test_probe_grid_hub.py +88 -0
  87. rhscope-0.1.0/tests/test_probes_base.py +172 -0
  88. rhscope-0.1.0/tests/test_probes_dom.py +132 -0
  89. rhscope-0.1.0/tests/test_probes_logistic.py +95 -0
  90. rhscope-0.1.0/tests/test_probes_mlp.py +159 -0
  91. rhscope-0.1.0/tests/test_probes_online.py +223 -0
  92. rhscope-0.1.0/tests/test_probes_tokens.py +249 -0
  93. rhscope-0.1.0/tests/test_recipes_config.py +162 -0
  94. rhscope-0.1.0/tests/test_recipes_config_monitor.py +55 -0
  95. rhscope-0.1.0/tests/test_recipes_grpo.py +200 -0
  96. rhscope-0.1.0/tests/test_research_evasion.py +148 -0
  97. rhscope-0.1.0/tests/test_sandbox.py +151 -0
  98. rhscope-0.1.0/tests/test_training_data.py +135 -0
  99. rhscope-0.1.0/tests/test_training_layer_select.py +39 -0
  100. rhscope-0.1.0/tests/test_training_trainer.py +232 -0
@@ -0,0 +1,64 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ dist/
9
+ *.egg-info/
10
+ *.egg
11
+ .installed.cfg
12
+
13
+ # uv / virtualenv
14
+ .venv/
15
+ venv/
16
+ env/
17
+
18
+ # Testing / coverage
19
+ .pytest_cache/
20
+ .coverage
21
+ .coverage.*
22
+ htmlcov/
23
+ .mypy_cache/
24
+ .ruff_cache/
25
+
26
+ # IDE
27
+ .vscode/
28
+ .idea/
29
+ *.swp
30
+
31
+ # OS
32
+ .DS_Store
33
+ Thumbs.db
34
+
35
+ # HF Hub cache (local only; not shipped)
36
+ .cache/
37
+ hf_cache/
38
+
39
+ # Scratch
40
+ scratch/
41
+ tmp/
42
+ *.ipynb_checkpoints/
43
+
44
+ # Logs
45
+ *.log
46
+ runs/
47
+ wandb/
48
+ tensorboard_logs/
49
+
50
+ # Datasets / checkpoints / artifacts
51
+ datasets/*/
52
+ !datasets/.gitkeep
53
+ checkpoints/
54
+ artifacts/
55
+ *.safetensors
56
+ *.bin
57
+ *.ckpt
58
+
59
+ # Jupyter
60
+ .ipynb_checkpoints/
61
+
62
+ # Sphinx build output
63
+ docs/_build/
64
+ docs/_autosummary/
@@ -0,0 +1,230 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-11-29
9
+
10
+ Initial release. rhscope is scoped to **activation probes for reward
11
+ hacking in LLM RL post-training**. The public surface described below
12
+ is stable from v0.1.0 onward; deeper imports may still be refactored.
13
+
14
+ ### Added
15
+
16
+ #### Probes
17
+
18
+ - `Probe` abstract base class with self-registering subclass dispatch
19
+ and a shared SafeTensors + JSON-sidecar persistence format.
20
+ - `ProbeMetadata` (Pydantic v2) carrying `base_model`, `layer`,
21
+ `pooling`, `probe_type`, `category`, `hidden_dim`, `val_auroc`,
22
+ `train_examples`, SHA-256 training-data hash, `rhscope_version`,
23
+ `created_at`, and an opaque `extra` dict preserved across
24
+ round-trips.
25
+ - `DoMProbe` - difference-of-means, optional ZCA whitening.
26
+ - `LogisticProbe` - L2 logistic regression via torch-native L-BFGS.
27
+ - `MLPProbe` - shallow two-layer tanh MLP with early stopping for
28
+ non-linear separations.
29
+ - `Probe.from_pretrained(path_or_hub_id)` and
30
+ `HackMonitor.from_pretrained(path_or_hub_id)` resolve a local stem
31
+ or a Hugging Face Hub repo transparently.
32
+
33
+ #### Monitor
34
+
35
+ - `HackMonitor` wraps a probe-backed `Detector` with a decision
36
+ threshold and the `score_batch(prompts, responses)` surface the
37
+ integrations consume. `.from_probe(...)` and `.from_pretrained(...)`
38
+ are the two factories; the probe-specific accessors
39
+ (`base_model`, `layer`, `pooling`, `category`, `hidden_dim`,
40
+ `metadata`, `probe`, `score(activations)`, `require_base_model(...)`)
41
+ raise `AttributeError` for non-probe detectors.
42
+
43
+ #### Research
44
+
45
+ - `research.EvasionDetector`: anchors a baseline probe direction, fits
46
+ a fresh direction at each eval step on freshly-labelled activations,
47
+ measures the subspace angle between fresh and baseline, and scores
48
+ both directions on a held-out validation half of the step's data.
49
+ Classifies the trajectory as `obfuscating` / `reforming` /
50
+ `stable` / `undecided`.
51
+ - `research.subspace_angle(a, b)`: standalone geometry primitive
52
+ (sign-folded to `[0, pi/2]`).
53
+ - `research.RefDeltaDetector`: scores hacking as a per-token
54
+ log-probability delta between the trained policy and its frozen
55
+ reference model. Near-zero marginal cost during RL rollouts.
56
+ - `research.OnlineProbe`: DoM-style probe with `partial_fit` for
57
+ streaming RL rollouts; `snapshot()` freezes to a regular `DoMProbe`
58
+ on demand.
59
+ - `probes.score_tokens` + `probes.extract_token_activations`:
60
+ per-token probe scoring with peak-token attribution for mid-
61
+ generation early-stop and span-level analysis.
62
+
63
+ #### Benchmark
64
+
65
+ - `bench.RHDetectBench` runner with JSONL (`load_jsonl`) and HF Hub
66
+ (`load_hub`) loaders, tolerant schema normalization accepting
67
+ `label` / `is_hacking` / `hack` and `category` / `behavior` / `type`
68
+ aliases.
69
+ - `bench.BenchResult` with Markdown summary, JSON round-trip, and
70
+ per-category breakdown computing pooled + per-category AUROC,
71
+ Youden-J accuracy, ECE, Brier.
72
+ - `bench.Leaderboard` + `run_probe_leaderboard` grouping probes by
73
+ `base_model` so each model is loaded at most once across a grid.
74
+ - `bench.curation` for building balanced `HackExample` subsets by
75
+ category and label.
76
+ - `bench.compare_detectors(...)`: head-to-head analysis of multiple
77
+ detectors on the same bench; returns agreement matrix, Pearson
78
+ correlation, and top disagreement cases.
79
+
80
+ #### Detectors + composition
81
+
82
+ - `Detector` protocol with `score_batch(prompts, responses) ->
83
+ np.ndarray`. `ProbeDetector` is the primary implementation.
84
+ - `RandomDetector` and `TokenCountDetector`: neutral chance-line /
85
+ length-only baselines for benchmarks.
86
+ - `CallableDetector`: wrap any `(prompts, responses) -> np.ndarray`
87
+ callable so users can compose their own external detectors (an
88
+ OpenAI / Anthropic / Ollama judge, a custom rule) with rhscope's
89
+ probes.
90
+ - `CompositeDetector`: fuse any set of detectors with one of five
91
+ reducers (`mean`, `max`, `min`, `sum`, `weighted_mean`).
92
+
93
+ **Deliberately not shipped:** built-in LLM-as-judge or regex /
94
+ heuristic / AST detectors. Users who want those for benchmarking or
95
+ ensembling can bring their own callable via `CallableDetector`.
96
+
97
+ #### Metrics
98
+
99
+ - Pure-numpy `auroc`, `accuracy_at_threshold`, `youden_j_threshold`,
100
+ `expected_calibration_error`, `brier_score`, numerically-stable
101
+ `sigmoid`. Cross-checked against scikit-learn in tests.
102
+ - `ConfusionMatrix` dataclass with derived `precision` / `recall` /
103
+ `f1` / `accuracy`; `confusion_matrix(scores, labels, threshold)`
104
+ builder; `precision_recall_curve`; `average_precision` (PR-AUC).
105
+
106
+ #### Activations
107
+
108
+ - `extract_activations` with `last_token` / `mean` / `max` pooling,
109
+ batched inference, multi-layer extraction in one forward pass.
110
+ - `ActivationCache`: content-addressed SafeTensors disk cache keyed
111
+ on SHA-256 of `(model_id, prompt, response, layer, pooling,
112
+ max_length)`. Shared across probe-grid cells that reuse
113
+ `(model, examples)`.
114
+
115
+ #### Training
116
+
117
+ - `train_probe(model, tokenizer, examples, probe_type, category, ...)`:
118
+ stratified split, extract, fit per layer, select by val AUROC,
119
+ re-fit the winner on train+val.
120
+ - `load_model_for_probing` convenience wrapper.
121
+ - `training/layer_select.candidate_layers`: 5 depth candidates per
122
+ model, skipping the embedding layer.
123
+
124
+ #### Environments
125
+
126
+ - `envs/base.py`: `BaseEnv` abstract class with auto-registry by
127
+ `name`; `EnvTask` dataclass.
128
+ - `envs/code_shortcut.py::CodeShortcutEnv`: model-agnostic
129
+ coding env with disjoint weak-test (reward) and strong-test (oracle)
130
+ evaluation. Spoof-resistant sandbox runner using per-call random
131
+ sentinels and sidecar payload files.
132
+ - `envs/code_shortcut.py::load_mbpp_tasks`: MBPP loader with
133
+ configurable weak/strong split.
134
+
135
+ #### Sandbox
136
+
137
+ - `sandbox.run_python(..., backend="subprocess")`: fast fresh-Python
138
+ subprocess with `-I` isolated mode, wall-clock timeout, and POSIX
139
+ `rlimit` CPU + memory caps.
140
+ - `sandbox.run_python(..., backend="docker")`: container with
141
+ `--network=none`, `--read-only`, `--cap-drop=ALL`,
142
+ `--security-opt=no-new-privileges`, `--pids-limit=128`,
143
+ `--user 65534:65534`, memory + CPU caps. `is_docker_available()`
144
+ helper.
145
+
146
+ #### Trainer integrations
147
+
148
+ - `integrations.base.MonitorPenaltyAdapter`: framework-neutral
149
+ primitive owning the monitor, activation forward pass, metrics
150
+ buffer, and sink. Returns a `MonitorPenaltyResult` with rewards,
151
+ raw scores, and recorded metrics.
152
+ - `integrations.trl.make_monitor_reward_fn(...)`: TRL-compatible
153
+ reward callable that adds a monitor-based penalty alongside the
154
+ base env reward via TRL's native "sum of reward functions" surface.
155
+ - `integrations.trl.MonitorStatsCallback`: injects buffered monitor
156
+ metrics into the trainer's `on_log` events.
157
+ - `integrations.verl.MonitorRewardModel`: verl-compatible reward
158
+ model adapter accepting `DataProto`-shaped batches with either
159
+ decoded strings or token-id tensors.
160
+ - `integrations.dpo.score_dpo_pairs(...)`: offline helper for
161
+ preference-based post-training; returns `DPOPairScores` with
162
+ chosen/rejected scores, preference-flip detection, and filter masks.
163
+ - `integrations.sinks`: `Sink` protocol + `StdoutSink`,
164
+ `TensorBoardSink`, `WandbSink`, `NullSink`, `make_sink` factory.
165
+
166
+ #### Hugging Face Hub
167
+
168
+ - `hub.resolve_probe_stem`: locate a probe locally or download from
169
+ the Hub under canonical filenames.
170
+ - `hub.push_probe_to_hub`: publish a trained probe with an
171
+ auto-generated model-card-aware commit message.
172
+ - `hub.read_hub_metadata`: peek at a probe's metadata without
173
+ downloading its weights.
174
+
175
+ #### Recipes
176
+
177
+ - `recipes.config`: strict Pydantic schema (`ModelConfig`, `EnvConfig`,
178
+ `LoRAConfig`, `GRPOHyperparameters`, `MonitorConfig`,
179
+ `LoggingConfig`, `RecipeConfig`) with YAML loader.
180
+ - `recipes.grpo.run_grpo_recipe(...)`: wires config to TRL
181
+ `GRPOTrainer`. LoRA via PEFT with `target_modules="all-linear"`.
182
+ - `recipes/grpo_default.yaml`: sensible defaults.
183
+ - `recipes.probe_grid.train_probe_grid(...)`: trains the full
184
+ Cartesian product of models x categories, writes per-cell artifacts
185
+ + model cards, optionally pushes each cell to the Hub.
186
+
187
+ #### Model cards
188
+
189
+ - `model_card.render_model_card` / `save_model_card`: Hugging Face
190
+ compatible Markdown card with structured YAML front matter.
191
+ Deterministic, diff-able, no Jinja dependency.
192
+
193
+ #### CLI
194
+
195
+ - `rhscope train-probe` - train one probe from a JSONL dataset.
196
+ - `rhscope eval` - score a probe or baseline on an RH-Detect JSONL.
197
+ - `rhscope curate` - build a balanced `HackExample` JSONL subset.
198
+ - `rhscope info` - inspect a probe's metadata (local or Hub) without
199
+ loading weights.
200
+ - `rhscope train-grid` - run the full probe matrix.
201
+ - `rhscope benchmark-grid` - leaderboard across any number of probes.
202
+ - `rhscope model-card` - render / save a Hugging Face model card.
203
+ - `rhscope run-recipe` - execute a GRPO recipe YAML with
204
+ `--override key.path=value`.
205
+ - `rhscope env-eval` - measure a base model's hacking rate on an env.
206
+
207
+ #### Documentation
208
+
209
+ - README focused on the probe workflow.
210
+ - `docs/introduction.md`: what rhscope is, when to use it, how to
211
+ train your first probe.
212
+ - `docs/quickstart.md`: install to first score in ten minutes.
213
+ - `docs/api_overview.md`: complete public surface.
214
+ - `docs/related_work.md`: positioning against activation-probe
215
+ literature and monitor-evasion research, with an explicit scope
216
+ statement.
217
+ - `docs/limitations.md`: v0.1 non-goals, failure modes, sandbox
218
+ caveats, v0.2 roadmap.
219
+ - `docs/probes/catalog.md` + `docs/benchmark.md`: probe catalog and
220
+ benchmark methodology.
221
+ - Sphinx + Furo documentation site under `docs/` with auto-generated
222
+ API reference from the package docstrings.
223
+ - `CONTRIBUTING.md`, `SECURITY.md`, GitHub issue / PR templates under
224
+ `.github/`.
225
+
226
+ ### Tests
227
+
228
+ - 500+ passing unit tests; platform-specific skips for POSIX-only
229
+ rlimit and Docker-only hardened sandbox. Full ruff + ruff format +
230
+ mypy clean.
rhscope-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
95
+ Derivative 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 describing the origin of the Work and
141
+ 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 Support. 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 support.
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 rhscope contributors
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.