|
| 1 | +<!-- |
| 2 | +Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 3 | +
|
| 4 | +SPDX-License-Identifier: Apache-2.0 |
| 5 | +--> |
| 6 | + |
| 7 | +# Score Tooling — Agent Instructions |
| 8 | + |
| 9 | +**Score Tooling** is a unified Bazel module (`score_tooling`) providing development tools for building, testing, and maintaining code quality. All public macros are re-exported from [defs.bzl](../defs.bzl). |
| 10 | + |
| 11 | +## Modules |
| 12 | + |
| 13 | +| Module | Language | Purpose | Docs | |
| 14 | +|--------|----------|---------|------| |
| 15 | +| `python_basics` | Starlark/Python | `score_py_pytest` + `score_virtualenv` macros | [README](../python_basics/README.md) | |
| 16 | +| `cr_checker` | Python | Copyright header checker/fixer | [README](../cr_checker/README.md) | |
| 17 | +| `dash` | Tool | DASH license compliance | [README](../dash/README.md) | |
| 18 | +| `format_checker` | Starlark | `use_format_targets()` → `:format.fix` / `:format.check` | [README](../format_checker/README.md) | |
| 19 | +| `cli_helper` | Starlark | CLI helper Bazel rule | [README](../cli_helper/README.md) | |
| 20 | +| `starpls` | Config | Starlark language server | [README](../starpls/README.md) | |
| 21 | +| `coverage` | Shell+Bazel | Combined Rust+Python coverage → HTML | [README](../coverage/README.md) | |
| 22 | +| `lobster_bazel` | Python | Extracts traceability tags for LOBSTER | [README](../lobster_bazel/README.md) | |
| 23 | +| `manual_analysis` | Python+Starlark | Interactive manual verification workflow | [README](../manual_analysis/README.md) | |
| 24 | +| `plantuml` | Rust | PlantUML FTA-metamodel parser | [README](../plantuml/parser/README.md) | |
| 25 | +| `validation` | Rust+Python | Bazel-graph vs. PlantUML validation + AI checker | [README](../validation/ai_checker/README.md) | |
| 26 | +| `tools` | Config | Multitool lockfile: ruff, shellcheck, actionlint, yamlfmt | [README](../tools/README.md) | |
| 27 | + |
| 28 | +## Build & Test Commands |
| 29 | + |
| 30 | +```bash |
| 31 | +bazel test //... # all tests |
| 32 | +bazel test //:format.check # check formatting (ruff, buildifier, rustfmt, yamlfmt) |
| 33 | +bazel run //:format.fix # auto-fix formatting |
| 34 | +bazel run //:copyright.check # check copyright headers |
| 35 | + |
| 36 | +# Rust-specific |
| 37 | +bazel build //plantuml/... --config=clippy |
| 38 | +bazel build //validation/... --config=clippy |
| 39 | + |
| 40 | +# Coverage |
| 41 | +bazel run //coverage:combined_report |
| 42 | + |
| 43 | +# IDE virtualenv |
| 44 | +bazel run //:ide_support # creates .venv |
| 45 | + |
| 46 | +# AI checker (runs at test time; inherits Copilot credentials from your shell) |
| 47 | +bazel test //path/to:my_ai_check |
| 48 | +``` |
| 49 | + |
| 50 | +**Integration tests** have their own `MODULE.bazel` — run from their subdirectory: |
| 51 | + |
| 52 | +```bash |
| 53 | +cd python_basics/integration_tests && bazel test //... |
| 54 | +cd starpls/integration_tests && bazel test //... |
| 55 | +``` |
| 56 | + |
| 57 | +## Critical Conventions |
| 58 | + |
| 59 | +### Copyright header — mandatory on every file |
| 60 | +Every `.py`, `.bzl`, `.rs`, `.sh`, `.cpp` file must begin with: |
| 61 | +``` |
| 62 | +# Copyright (c) <year> Contributors to the Eclipse Foundation |
| 63 | +# |
| 64 | +# SPDX-License-Identifier: Apache-2.0 |
| 65 | +``` |
| 66 | +The `:copyright.check` target enforces this and will fail CI if missing. |
| 67 | + |
| 68 | +### Python |
| 69 | +- Version: **3.12** (pinned in `MODULE.bazel` + `python_basics/pyproject.toml`) |
| 70 | +- Linter: **ruff** (`E, F, I, B, C90, UP, SIM, RET` rules) |
| 71 | +- Type checker: **basedpyright** (`standard` mode) |
| 72 | +- All Python tests must use `score_py_pytest`, not raw `py_test` |
| 73 | +- `--incompatible_default_to_explicit_init_py` is active — no automatic `__init__.py` |
| 74 | + |
| 75 | +### Bazel/Starlark |
| 76 | +- Formatting: **buildifier** |
| 77 | +- Bzlmod (`MODULE.bazel`) is primary; `deps.bzl` is legacy compat only |
| 78 | +- Root `BUILD` registers `:copyright.check`, `:format.check`, `:format.fix` targets |
| 79 | + |
| 80 | +### Rust |
| 81 | +- Edition 2021; rustfmt + clippy via `--config=clippy` |
| 82 | + |
| 83 | +## Dependency / Requirements Management |
| 84 | + |
| 85 | +Each sub-package has its own pip hub with `requirements.in` → `requirements.txt`: |
| 86 | + |
| 87 | +| Hub | Lock file | |
| 88 | +|-----|-----------| |
| 89 | +| `pip_tooling` | `python_basics/requirements.txt` | |
| 90 | +| `pip_lobster_bazel` | `lobster_bazel/requirements.txt` | |
| 91 | +| `manual_analysis_deps` | `manual_analysis/requirements.txt` | |
| 92 | +| `pip_validation_ai_checker` | `validation/ai_checker/requirements.txt` | |
| 93 | + |
| 94 | +After editing `requirements.in`, regenerate with: |
| 95 | +```bash |
| 96 | +bazel run //<pkg>:requirements.update |
| 97 | +``` |
| 98 | +Both `requirements.in` and `requirements.txt` are committed to VCS. |
| 99 | + |
| 100 | +## Common Pitfalls |
| 101 | + |
| 102 | +- **AI checker tests need `tags = ["manual"]`** — otherwise `bazel test //...` attempts to run them without Copilot credentials. |
| 103 | +- **`lobster_bazel` traceability tags** must be at the start of a line (not inline). |
| 104 | +- **Format check fails silently** if buildifier or ruff versions are out of sync with the multitool lockfile in `tools/`. |
| 105 | +- **`manual_analysis` lock files are committed** — always run `{target}.update` after changing analysis YAML, then commit the updated lock. |
0 commit comments