system_status always reports no warnings and no errors
### Problem/Motivation
The `tool_belt:system_status` tool never sets `has_warnings` or `has_errors`, so its message always ends with "Warnings: No, Errors: No", even when its own `status_report` output lists warning and error items. An agent that trusts the summary flags (the natural reading of the tool) concludes the site is healthy when it is not.
The cause is in `modules/tool_belt_system/src/Plugin/tool/Tool/SystemStatus.php`:
- Lines 80-85 normalize every severity to the `\Drupal\Core\Extension\Requirement\RequirementSeverity` enum (an integer severity from a hook is converted with `RequirementSeverity::from()`).
- Lines 98-104 then compare that enum against the legacy integer constants `REQUIREMENT_WARNING` and `REQUIREMENT_ERROR` with `==`. In PHP an enum case is never loosely equal to an integer (`RequirementSeverity::Warning == 1` is `FALSE`), so neither branch can ever match. The `?? REQUIREMENT_OK` fallback on line 98 is also dead, because line 80 has already filled the key.
The same code has two compatibility problems with the core versions the module declares (`core_version_requirement: ^10.5 || ^11 || ^12` in `tool_belt_system.info.yml:5`):
- `RequirementSeverity` only exists from Drupal 11.2 (the file is absent on the core `10.5.x`, `10.6.x` and `11.1.x` branches and present on `11.2.x`). On 10.5 through 11.1 every requirement carries an integer severity, so line 84 runs `RequirementSeverity::from()` on the first item and fails with a class-not-found `\Error`. The `catch (\Exception $e)` on line 121 does not catch `\Error`, so the tool call fails outright rather than returning a failure result.
- The `REQUIREMENT_*` constants are deprecated in 11.2 and removed in 12.0 (`core/includes/install.inc:20-57`). On Drupal 12, line 99 fails with an undefined-constant `\Error`.
So the tool misreports on 11.2 and later, fails on 10.5 through 11.1, and will fail on 12. There is no kernel test for this tool, which is why neither case was caught.
### Steps to reproduce
On a site whose status report has at least one warning and one error (Drupal 11.4.2 here), call the tool over MCP as a user with "administer site configuration":
```json
{"name": "tool_api__tool_belt_system_status", "arguments": {}}
```
Observed:
- Text: `Successfully retrieved system status with 39 items. Warnings: No, Errors: No`
- Structured output: `"has_warnings": false`, `"has_errors": false`
- The same response's `status_report` contains 6 items with `severity.status` "warning" (for example `configuration_files`, `update_core`, `experimental_modules`) and 4 with "error" (for example `entity_update` "Mismatched entity and/or field definitions", `invalid_module`). Totals: 23 ok, 6 checked, 6 warning, 4 error.
Expected: `has_warnings: true`, `has_errors: true`, and the message ending "Warnings: Yes, Errors: Yes".
On Drupal 10.5 (not reproduced locally; read from the code and the core branches), the same call is expected to fail with "Class \"Drupal\Core\Extension\Requirement\RequirementSeverity\" not found".
### Proposed resolution
Compare severities by their integer level, and stop depending on either the enum or the constants existing:
1. Normalize each severity to an integer once: `$level = $severity instanceof \BackedEnum ? $severity->value : (int) ($severity ?? 0);`. Both the enum (11.2 and later) and the legacy integers (10.5 through 11.1, and contributed hooks on any version) map to -1, 0, 1 or 2.
2. Set `$has_warnings` when `$level === 1` and `$has_errors` when `$level === 2`. Using literal levels, or private class constants on the tool, avoids the removed `REQUIREMENT_*` constants.
3. Build the `severity` output (`value`, `status`, `label`) from a private map keyed by level (`-1` checked/Checked, `0` ok/OK, `1` warning/Warnings found, `2` error/Errors found), which matches what `RequirementSeverity::status()` and `::title()` return today, so the output shape does not change on 11.2 and later. Optionally, when `enum_exists(RequirementSeverity::class)` is true, take the label from `RequirementSeverity::from($level)->title()` instead.
4. Remove the `use` of `RequirementSeverity` if it is no longer referenced, and widen the `catch` on line 121 to `\Throwable` so an unexpected failure returns a failure result instead of ending the call.
Add `modules/tool_belt_system/tests/src/Kernel/SystemStatusTest.php` (following the per-tool test convention), with a small test module under `modules/tool_belt_system/tests/modules/` that implements `hook_requirements('runtime')` returning one warning and one error with integer severities (valid on every supported core). Cases:
- A warning and an error present: `has_warnings` and `has_errors` are `TRUE`, the message ends "Warnings: Yes, Errors: Yes", and the two items appear in `status_report` with `severity.status` "warning" and "error".
- The test module's items removed (for example through a `hook_requirements_alter()` state flag): both flags are `FALSE` when no other requirement is at warning or error level. If the kernel environment itself reports warnings, assert only on the test module's items and on flag agreement with the counted items instead.
- On 11.2 and later, a second hook (`hook_runtime_requirements()`) returning enum severities, to cover the enum path.
Because the belt CI already runs the previous-major jobs, this test will also cover the 10.x path.
### Remaining tasks
- Implement the integer-level comparison and the version-neutral severity map.
- Add the kernel test and test module.
- Separate follow-up: `SystemStatus.php:87-89` casts `value` with `(string)` and passes `description` through unchanged, but requirement values and descriptions may be render arrays. On this site the `invalid_module` item returns `"value": "Array"` (with an "Array to string conversion SystemStatus.php:88" PHP warning in the server log), and the `description` of `cron`, `coverage_core`, `update_core`, `update_contrib` and `scheduler_timecheck` is not a string. These should be rendered to plain text. This does not block the fix above.
### AI usage (if applicable)
* [ ] AI Assisted Issue: This issue was generated with AI assistance, but was reviewed and refined by the creator.
* [ ] AI Assisted Code: This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.
* [ ] AI Generated Code: This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.
* [ ] Vibe Coded: This code was generated by an AI and has only been functionally tested.
issue
GitLab AI Context
Project: project/tool_belt
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/tool_belt/-/raw/1.0.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/tool_belt
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD