<a id="reference-diagnostics-label"></a>

# Diagnostics

A *diagnostic* is what the checker reports about a specification: a syntax error, or an *issue* found by one of its analyses.
Each kind of issue has a *code* that does not change, a *severity* and a message.
This page lists them all. For each one it gives an example specification that `reqtool` really reports, and how to fix it.

## Reading a report

```req
package System
  part Wheel
    let speed in real \ m/s \
  part

  requirement Wheel_exists top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall exist.
    @@
  requirement

  requirement Speed_bound top bottom
    on Wheel::speed
  is
    Wheel::speed < false
  requirement
package
```

**reqtool check**

```none
16:4         E03010 expected type Number got Boolean
Wheel::speed < false
```

* The position of the issue in the source, `line:column`, both counted from zero.
* The code, `E03010`, and the message.
* The source the issue is about, here the expression.

`reqtool check` prints nothing when the specification has no diagnostic.

The checker’s messages call the entity a requirement constrains, the one after `on`, its *restriction*, and the one after `via`, its *allocation*.
With `--json`, `reqtool check` gives the same information in a machine-readable report, with the path of the entity the issue is about (here `System::Speed_bound`) in addition, see [LLMs and agents](../agents.md).
The language server gives each diagnostic its code.

## Severities

An issue has one of four severities, from the least to the most severe: `light`, `moderate`, `severe` and `critical`.
The language server shows them as hints, information, warnings and errors, in this order.

A syntax error is always `critical`, and `reqtool` reports it in the same list as the other diagnostics.

## Codes and kinds

A code is `E0`, a digit and three more digits, like `E04010`. The digit is the *kind* of the issue, what it is about:

| Kind         | Codes    | What the issue is about                                                                         |
|--------------|----------|-------------------------------------------------------------------------------------------------|
| `syntax`     | `E00xxx` | The source does not follow the grammar of the language.                                         |
| `path`       | `E01xxx` | The name of an entity, which must be unique and well formed, and the root of the specification. |
| `reference`  | `E02xxx` | A reference that points at nothing.                                                             |
| `typing`     | `E03xxx` | The type of an expression.                                                                      |
| `connection` | `E04xxx` | Where an entity is, and how requirements are linked to the entities and to each other.          |

The kind is also given by `reqtool check --json` and by the language server.

A code is never changed or reused, even when its issue is no longer reported. The numbers go by steps of ten, so that an issue can be split in two and the new one take a number next to the old one.

### All the codes

| Code              | Title                                        | Severity   | Kind       |
|-------------------|----------------------------------------------|------------|------------|
| [E00010](#e00010) | Syntax error                                 | critical   | syntax     |
| [E01010](#e01010) | Duplicated entity                            | critical   | path       |
| [E01020](#e01020) | Invalid identifier                           | critical   | path       |
| [E01030](#e01030) | Invalid root                                 | critical   | path       |
| [E02010](#e02010) | Unresolved reference                         | critical   | reference  |
| [E03010](#e03010) | Unexpected type                              | critical   | typing     |
| [E03020](#e03020) | Not a set                                    | critical   | typing     |
| [E03030](#e03030) | Not evaluable                                | critical   | typing     |
| [E03040](#e03040) | Propagated type error                        | critical   | typing     |
| [E04010](#e04010) | Missing constraint                           | severe     | connection |
| [E04020](#e04020) | Missing upward traceability                  | light      | connection |
| [E04030](#e04030) | Missing downward traceability                | light      | connection |
| [E04040](#e04040) | Invalid requirement parent                   | critical   | connection |
| [E04050](#e04050) | Invalid package parent                       | critical   | connection |
| [E04060](#e04060) | Invalid attribute parent                     | critical   | connection |
| [E04070](#e04070) | Unrestricted entity                          | moderate   | connection |
| [E04080](#e04080) | Unused entity                                | light      | connection |
| [E04090](#e04090) | Not a part or attribute                      | critical   | connection |
| [E04100](#e04100) | Not a requirement                            | critical   | connection |
| [E04110](#e04110) | Allocation of a bottom requirement           | critical   | connection |
| [E04120](#e04120) | Allocation without derivation                | light      | connection |
| [E04130](#e04130) | Duplicated traceability link                 | moderate   | connection |
| [E04140](#e04140) | Conflicting traceability links               | severe     | connection |
| [E04150](#e04150) | Specialization mismatch                      | severe     | connection |
| [E04160](#e04160) | Cyclic traceability                          | severe     | connection |
| [E04170](#e04170) | Upward link of a top requirement             | moderate   | connection |
| [E04180](#e04180) | Downward link to a bottom requirement        | moderate   | connection |
| [E04190](#e04190) | Refinement mismatch                          | severe     | connection |
| [E04200](#e04200) | Derivation of an unallocated requirement     | moderate   | connection |
| [E04210](#e04210) | Derivation mismatch                          | severe     | connection |
| [E04220](#e04220) | Unrelated derivation                         | moderate   | connection |
| [E04230](#e04230) | Constrained entity not used                  | moderate   | connection |
| [E04240](#e04240) | Allocation and constraint on the same entity | moderate   | connection |

## Syntax

The source does not follow the grammar of the language.

<a id="e00010"></a>

### Syntax error

* **Code:**
  E00010
* **Severity:**
  critical
* **Kind:**
  syntax

The source does not follow the grammar. The checker reports the token it could not go on with, here `part`, which has no name.

The entities around a syntax error may be incomplete, so the other diagnostics around it can be consequences of it: fix the syntax errors first. `reqtool fmt` does not format a source that has syntax errors.

For now all the syntax errors have the same code and message: the checker tells where the parse stopped, not why.

### Example

A part needs a name.

```req
package System
  part
package
```

**reqtool check**

```none
1:2          E00010 syntax error
part
```

### Fix

Correct the source at the reported position: the error is the token the parser could not go on with.

## Path

The name of an entity, which must be unique.

<a id="e01010"></a>

### Duplicated entity

* **Code:**
  E01010
* **Severity:**
  critical
* **Kind:**
  path

Two entities have the same path: the same identifier under the same parent. Both of them are reported.

### Example

Two requirements of the package `System` are named `Wheel_size`.

```req
package System
  part Wheel
  part

  requirement Wheel_size top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall be round.
    @@
  requirement

  requirement Wheel_size top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall be below 30 cm.
    @@
  requirement
package
```

**reqtool check**

```none
4:14         E01010 two entities have the same name at the same location
Wheel_size
12:14        E01010 two entities have the same name at the same location
Wheel_size
```

### Fix

Rename one of the two entities, or move it under another parent: the same identifier can be used under different parents.

### Why

Each entity is uniquely identified by its path, see [Reference](entity.md#reference-reference-label).

<a id="e01020"></a>

### Invalid identifier

* **Code:**
  E01020
* **Severity:**
  critical
* **Kind:**
  path

The identifier of an entity is not made of letters, digits and `_`, or starts with a digit. Letters of any
alphabet are accepted: `température` is an identifier.

### Example

`1st_stage` starts with a digit, and `Booster-2` has a dash.

```req
package Launcher
  part 1st_stage
  part

  part Booster-2
  part

  requirement Separation top bottom
    on 1st_stage
  is
    @@
      The [[1st_stage]] shall separate cleanly from the [[Booster-2]].
    @@
  requirement

  requirement Recovery top bottom
    on Booster-2
  is
    @@
      The [[Booster-2]] shall be recovered after separation.
    @@
  requirement
package
```

**reqtool check**

```none
1:7          E01020 an identifier is made of letters, digits and _, and does not start with a digit
1st_stage
4:7          E01020 an identifier is made of letters, digits and _, and does not start with a digit
Booster-2
```

### Fix

Rename the entity: replace the other characters with `_` and start it with a letter, `First_stage` and
`Booster_2` here.

### Why

An expression reads `1st_stage` as the number `1` followed by `st_stage`, and `Booster-2` as a
subtraction: it could never refer to these entities. See [Entity](entity.md#reference-entities-label).

<a id="e01030"></a>

### Invalid root

* **Code:**
  E01030
* **Severity:**
  critical
* **Kind:**
  path

The root of the specification, the entity that contains all the others, is not a package.

### Example

The specification starts with the part `Machine`. No requirement can be written in a part, so nothing uses
or constrains `Machine`, which is reported as well, see [E04080](#e04080) and [E04070](#e04070).

```req
part Machine
part
```

**reqtool check**

```none
0:5          E01030 the root of a specification is a package
Machine
0:5          E04080 this entity is not used by any requirement
Machine
0:5          E04070 this entity is not restricted by any requirement
Machine
```

### Fix

Put the specification in a package: `package Factory`, the part `Machine`, then `package`.

### Why

A specification starts with a package, the parent of all the other entities, see [Entity](entity.md#reference-entities-label).

## Reference

A reference that points at nothing.

<a id="e02010"></a>

### Unresolved reference

* **Code:**
  E02010
* **Severity:**
  critical
* **Kind:**
  reference

A reference points to a path that is not in scope. A reference is the path written after `on`, `via`, `refines`, `derives` or `specializes`, between `[[` and `]]` in a text, or an identifier of an expression. The path is resolved with the rules of [Reference](entity.md#reference-reference-label).

A reference that cannot be resolved connects nothing: a requirement whose `on` cannot be resolved is also reported as [E04010](#e04010).

An expression that contains an identifier that cannot be resolved has no type. The expressions around it are not reported for it, see [E03040](#e03040).

### Example

`Wheel::radius` is referenced in the text, but `Wheel` has no attribute `radius`.

```req
package System
  part Wheel
  part

  requirement Wheel_size top bottom
    on Wheel
  is
    @@
      The [[Wheel]] radius, [[Wheel::radius]], shall be below 30 cm.
    @@
  requirement
package
```

**reqtool check**

```none
8:30         E02010 reference target not found in scope
Wheel::radius
```

### Example

The expression compares the speed with `Wheel::limit`, which does not exist.

```req
package System
  part Wheel
    let speed in real \ m/s \
  part

  requirement Wheel_exists top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall exist.
    @@
  requirement

  requirement Speed_bound top bottom
    on Wheel::speed
  is
    Wheel::speed < Wheel::limit
  requirement
package
```

**reqtool check**

```none
16:19        E02010 reference target not found in scope
Wheel::limit
```

### Fix

Write the path of an entity that exists. Look for a typo or a missing prefix, or define the entity.

## Typing

The type of an expression.

<a id="e03010"></a>

### Unexpected type

* **Code:**
  E03010
* **Severity:**
  critical
* **Kind:**
  typing

A sub-expression has a type other than the one its operator expects. The message gives the type expected, then the type found: `Number`, `Boolean` or a `Set`.

For example, a comparison of a number with a Boolean, a set literal whose elements do not all have the same type, or a filter (`such that`) that is not Boolean.

### Example

`false` is a Boolean, and `<` compares numbers.

```req
package System
  part Wheel
    let speed in real \ m/s \
  part

  requirement Wheel_exists top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall exist.
    @@
  requirement

  requirement Speed_bound top bottom
    on Wheel::speed
  is
    Wheel::speed < false
  requirement
package
```

**reqtool check**

```none
16:4         E03010 expected type Number got Boolean
Wheel::speed < false
```

### Fix

Use an operand of the type expected. Check the domain of the attributes and what the operator applies to, see the [type system](expression.md#reference-expression-label) of the expression language.

<a id="e03020"></a>

### Not a set

* **Code:**
  E03020
* **Severity:**
  critical
* **Kind:**
  typing

An expression needs a set and has another type. A set is expected as the right operand of `in` and `includes`, as the domain of a comprehension, and as the domain of an attribute used in an expression. The message gives the type found.

### Example

`in` expects a set on its right, and `3` is a number.

```req
package System
  part Wheel
    let speed in real \ m/s \
  part

  requirement Wheel_exists top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall exist.
    @@
  requirement

  requirement Speed_bound top bottom
    on Wheel::speed
  is
    Wheel::speed in 3
  requirement
package
```

**reqtool check**

```none
16:4         E03020 expected a set type got Number
Wheel::speed in 3
```

### Fix

Write a set, such as `{1, 2}`, see [Set](expression.md#reference-type-set-label).

<a id="e03030"></a>

### Not evaluable

* **Code:**
  E03030
* **Severity:**
  critical
* **Kind:**
  typing

An expression uses an entity that has no type. An entity gets its type from its expression, the domain of an attribute for instance. A part, a package or an informal requirement has none.

### Example

`Wheel` is a part: only its attributes have a type.

```req
package System
  part Wheel
    let speed in real \ m/s \
  part

  requirement Wheel_exists top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall exist.
    @@
  requirement

  requirement Speed_bound top bottom
    on Wheel::speed
  is
    Wheel::speed < Wheel
  requirement
package
```

**reqtool check**

```none
16:19        E03030 this expression points to an entity that has no type
Wheel
```

### Fix

Name an attribute of the entity instead of the entity itself.

<a id="e03040"></a>

### Propagated type error

* **Code:**
  E03040
* **Severity:**
  critical
* **Kind:**
  typing

An expression depends on a sub-expression that already has an issue. The issue is marked on the expressions that contain it, so that one mistake is reported once, where it is.

This code is reserved: it is never reported. It is listed so that its number is not reused.

### Fix

Fix the issue that is reported on the sub-expression.

## Connection

Where an entity is, and how requirements are linked to the entities and to each other.

<a id="e04010"></a>

### Missing constraint

* **Code:**
  E04010
* **Severity:**
  severe
* **Kind:**
  connection

A requirement does not name the entity it constrains: it has no `on`, or the entity after `on` cannot be resolved (it is then reported as [E02010](#e02010)).

The checker’s messages call the constrained entity the *restriction* of the requirement. See [Constraint](entity.md#reference-requirement-constraint-label).

### Example

`Wheel_exists` has no `on`. As a consequence, nothing constrains `Wheel`, which is reported as well, see [E04070](#e04070).

```req
package System
  part Wheel
  part

  requirement Wheel_exists top bottom
  is
    @@
      The [[Wheel]] shall exist.
    @@
  requirement
package
```

**reqtool check**

```none
1:7          E04070 this entity is not restricted by any requirement
Wheel
4:14         E04010 requirement is missing a constraint
Wheel_exists
```

### Fix

Add `on` with the path of the part or attribute the requirement constrains. If the path is already there, fix the [unresolved reference](#e02010).

<a id="e04020"></a>

### Missing upward traceability

* **Code:**
  E04020
* **Severity:**
  light
* **Kind:**
  connection

A requirement that is not `top` has no parent: no `refines` and no `derives` link to another requirement. A `specializes` link does not count. See [Inhibitors](entity.md#reference-requirement-inhibitor-label).

### Example

`Wheel_round` is `bottom` but not `top`, and it refines nothing.

```req
package System
  part Wheel
  part

  requirement Wheel_round bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall be round.
    @@
  requirement
package
```

**reqtool check**

```none
4:14         E04020 missing upward traceability
Wheel_round
```

### Fix

Link the requirement to its parent with `refines` or `derives`. If it has no parent, mark it `top`.

<a id="e04030"></a>

### Missing downward traceability

* **Code:**
  E04030
* **Severity:**
  light
* **Kind:**
  connection

A requirement that is not `bottom` has no children: no other requirement refines or derives it. A `specializes` link does not count. See [Inhibitors](entity.md#reference-requirement-inhibitor-label).

### Example

`Wheel_round` is `top` but not `bottom`, and no requirement refines it.

```req
package System
  part Wheel
  part

  requirement Wheel_round top
    on Wheel
  is
    @@
      The [[Wheel]] shall be round.
    @@
  requirement
package
```

**reqtool check**

```none
4:14         E04030 missing downward traceability
Wheel_round
```

### Fix

Add the requirements that refine or derive it. If it needs no refinement, mark it `bottom`.

<a id="e04040"></a>

### Invalid requirement parent

* **Code:**
  E04040
* **Severity:**
  critical
* **Kind:**
  connection

A requirement is contained in an entity that is not a package, here a part.

### Example

`Wheel_round` is written inside the part `Wheel`.

```req
package System
  part Wheel
    requirement Wheel_round top bottom
      on System::Wheel
    is
      @@
        The [[System::Wheel]] shall be round.
      @@
    requirement
  part
package
```

**reqtool check**

```none
2:16         E04040 requirements are expected to be contained in packages
Wheel_round
```

### Fix

Move the requirement into a package.

### Why

A requirement belongs to one and only one package, see [Package](entity.md#reference-package-label).

<a id="e04050"></a>

### Invalid package parent

* **Code:**
  E04050
* **Severity:**
  critical
* **Kind:**
  connection

A package is contained in an entity that is not a package, here a part.

### Example

The package `Details` is written inside the part `Wheel`.

```req
package System
  part Wheel
    package Details
    package
  part

  requirement Wheel_exists top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall exist.
    @@
  requirement
package
```

**reqtool check**

```none
2:12         E04050 packages are expected to be contained in packages
Details
```

### Fix

Move the package into another package.

### Why

A package contains packages, parts, requirements and imports, and a part contains attributes, parts and imports, see [Package](entity.md#reference-package-label) and [Part](entity.md#reference-part-label).

<a id="e04060"></a>

### Invalid attribute parent

* **Code:**
  E04060
* **Severity:**
  critical
* **Kind:**
  connection

An attribute is contained in an entity that is not a part, here a package.

### Example

The attribute `speed` is written directly in the package `System`.

```req
package System
  let speed in real \ m/s \

  requirement Speed_bound top bottom
    on speed
  is
    speed < 3
  requirement
package
```

**reqtool check**

```none
1:6          E04060 attributes are expected to be contained in parts
speed
```

### Fix

Move the attribute into a part.

### Why

A part is the container of attributes, see [Part](entity.md#reference-part-label).

<a id="e04070"></a>

### Unrestricted entity

* **Code:**
  E04070
* **Severity:**
  moderate
* **Kind:**
  connection

No requirement constrains this part or attribute: no requirement names it after `on`.

### Example

`Battery` is mentioned in a text, but no requirement is `on` it.

```req
package System
  part Wheel
  part

  part Battery
  part

  requirement Wheel_power top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall be powered by the [[Battery]].
    @@
  requirement
package
```

**reqtool check**

```none
4:7          E04070 this entity is not restricted by any requirement
Battery
```

### Fix

Add a requirement that is `on` the entity, or remove the entity if the specification does not need it.

<a id="e04080"></a>

### Unused entity

* **Code:**
  E04080
* **Severity:**
  light
* **Kind:**
  connection

No requirement uses this part or attribute. A requirement uses an entity when its text has a reference `[[...]]` to it, or when its expression has an identifier that points to it. Being the entity after `on` is not a use, see [E04230](#e04230).

### Example

`Wheel` is not mentioned anywhere. It is not constrained either, which is reported as well, see [E04070](#e04070).

```req
package System
  part Wheel
  part
package
```

**reqtool check**

```none
1:7          E04080 this entity is not used by any requirement
Wheel
1:7          E04070 this entity is not restricted by any requirement
Wheel
```

### Fix

Reference the entity in the requirement that is `on` it, or in another one, or remove the entity if the specification does not need it.

<a id="e04090"></a>

### Not a part or attribute

* **Code:**
  E04090
* **Severity:**
  critical
* **Kind:**
  connection

The path after `on` or `via` is the path of another kind of entity: only a part or an attribute can be constrained or allocated.

### Example

`Wheel_smooth` is `on` the requirement `Wheel_round`.

```req
package System
  part Wheel
  part

  requirement Wheel_round top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall be round.
    @@
  requirement

  requirement Wheel_smooth top bottom
    on Wheel_round
  is
    @@
      The [[Wheel_round]] shall be smooth.
    @@
  requirement
package
```

**reqtool check**

```none
13:7         E04090 part or attribute expected
Wheel_round
```

### Fix

Name the part or attribute the requirement is about.

<a id="e04100"></a>

### Not a requirement

* **Code:**
  E04100
* **Severity:**
  critical
* **Kind:**
  connection

The path after `refines`, `derives` or `specializes` is the path of another kind of entity: only a requirement can be traced.

### Example

`Wheel_round` refines the part `Wheel`.

```req
package System
  part Wheel
  part

  requirement Wheel_round bottom
    on Wheel
    refines Wheel
  is
    @@
      The [[Wheel]] shall be round.
    @@
  requirement
package
```

**reqtool check**

```none
6:12         E04100 requirement expected
Wheel
```

### Fix

Name the requirement to trace.

### Why

See [Traceability](entity.md#reference-requirement-traceability-label).

<a id="e04110"></a>

### Allocation of a bottom requirement

* **Code:**
  E04110
* **Severity:**
  critical
* **Kind:**
  connection

A requirement has a `via` and is `bottom`. An allocated requirement is meant to be derived, and a `bottom` requirement has no children.

### Example

`Wheel_stop` is allocated to `Brake` and marked `bottom`. Nothing derives it, which is reported as well, see [E04120](#e04120).

```req
package System
  part Wheel
  part

  part Brake
  part

  requirement Brake_exists top bottom
    on Brake
  is
    @@
      The [[Brake]] shall exist.
    @@
  requirement

  requirement Wheel_stop top bottom
    on Wheel
    via Brake
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement
package
```

**reqtool check**

```none
17:8         E04120 allocation of an entity without a deriving requirement
Brake
17:8         E04110 the requirement is allocated but the inhibitor forbids derivation
Brake
```

### Fix

Remove `bottom` so that the requirement can be derived, or remove `via` if it is not to be derived.

### Why

An allocated requirement is not `bottom`, since it is meant to be derived, see [Allocation](entity.md#reference-requirement-allocation-label) and [Inhibitors](entity.md#reference-requirement-inhibitor-label).

<a id="e04120"></a>

### Allocation without derivation

* **Code:**
  E04120
* **Severity:**
  light
* **Kind:**
  connection

A requirement is allocated with `via`, and no requirement derives it while constraining the allocated entity. The issue is reported on the `via`.

### Example

`Wheel_stop` is allocated to `Brake`, and nothing derives it. It has no children either, which is reported as well, see [E04030](#e04030).

```req
package System
  part Wheel
  part

  part Brake
  part

  requirement Brake_exists top bottom
    on Brake
  is
    @@
      The [[Brake]] shall exist.
    @@
  requirement

  requirement Wheel_stop top
    on Wheel
    via Brake
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement
package
```

**reqtool check**

```none
15:14        E04030 missing downward traceability
Wheel_stop
17:8         E04120 allocation of an entity without a deriving requirement
Brake
```

### Fix

Add a requirement that is `on` the allocated entity and `derives` the allocated requirement, or remove the `via`.

### Why

An allocated requirement is expected to be answered by requirements that derive it and constrain the allocated entity, see [Allocation](entity.md#reference-requirement-allocation-label).

<a id="e04130"></a>

### Duplicated traceability link

* **Code:**
  E04130
* **Severity:**
  moderate
* **Kind:**
  connection

A requirement has the same kind of link to the same requirement more than once. The issue is reported on the repeated link.

### Example

`Speed_bound` refines `Wheel_stop` twice.

```req
package System
  part Wheel
    let speed in real \ m/s \
  part

  requirement Wheel_stop top
    on Wheel
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement

  requirement Speed_bound bottom
    on Wheel::speed
    refines Wheel_stop
    refines Wheel_stop
  is
    Wheel::speed < 3
  requirement
package
```

**reqtool check**

```none
16:12        E04130 traceability link is duplicated
Wheel_stop
```

### Fix

Remove the repeated link.

<a id="e04140"></a>

### Conflicting traceability links

* **Code:**
  E04140
* **Severity:**
  severe
* **Kind:**
  connection

A requirement has links of different kinds to the same requirement, such as `refines` and `specializes`. Each of the links is reported.

### Example

`Wheel_stop_wet` both refines and specializes `Wheel_stop`.

```req
package System
  part Wheel
  part

  requirement Wheel_stop top
    on Wheel
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement

  requirement Wheel_stop_wet bottom
    on Wheel
    refines Wheel_stop
    specializes Wheel_stop
  is
    @@
      On a wet road, the [[Wheel]] shall stop.
    @@
  requirement
package
```

**reqtool check**

```none
15:16        E04140 traceability link is in conflict
Wheel_stop
14:12        E04140 traceability link is in conflict
Wheel_stop
```

### Fix

Keep the one kind of link that says how the two requirements are related.

### Why

Each kind of link has its own meaning, see [Traceability](entity.md#reference-requirement-traceability-label).

<a id="e04150"></a>

### Specialization mismatch

* **Code:**
  E04150
* **Severity:**
  severe
* **Kind:**
  connection

A requirement specializes a requirement that constrains another entity. The issue is reported on the `specializes` link. Nothing is reported when one of the two requirements has no constraint, see [E04010](#e04010).

### Example

`Brake_stop` constrains `Brake`, and specializes `Wheel_stop`, which constrains `Wheel`.

```req
package System
  part Wheel
  part

  part Brake
  part

  requirement Wheel_stop top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement

  requirement Brake_stop top bottom
    on Brake
    specializes Wheel_stop
  is
    @@
      The [[Brake]] shall stop on a wet road.
    @@
  requirement
package
```

**reqtool check**

```none
17:16        E04150 specialization with different restricted subjects
Wheel_stop
```

### Fix

Constrain the same entity as the specialized requirement, or link the requirements with another kind of link.

### Why

A specialization applies to a subset of the situations of its parent: both requirements constrain the same entity, see [Traceability](entity.md#reference-requirement-traceability-label).

<a id="e04160"></a>

### Cyclic traceability

* **Code:**
  E04160
* **Severity:**
  severe
* **Kind:**
  connection

Following the traceability links leads back to the requirement they started from. Every link of the cycle is reported.

### Example

`Wheel_round` refines `Wheel_smooth`, which refines `Wheel_round`.

```req
package System
  part Wheel
  part

  requirement Wheel_round
    on Wheel
    refines Wheel_smooth
  is
    @@
      The [[Wheel]] shall be round.
    @@
  requirement

  requirement Wheel_smooth
    on Wheel
    refines Wheel_round
  is
    @@
      The [[Wheel]] shall be smooth.
    @@
  requirement
package
```

**reqtool check**

```none
6:12         E04160 traceability link is part of a cycle
Wheel_smooth
15:12        E04160 traceability link is part of a cycle
Wheel_round
```

### Fix

Remove one of the links of the cycle.

### Why

Each link goes from a child requirement to its parent, see [Traceability](entity.md#reference-requirement-traceability-label): a requirement cannot be its own ancestor.

<a id="e04170"></a>

### Upward link of a top requirement

* **Code:**
  E04170
* **Severity:**
  moderate
* **Kind:**
  connection

A requirement marked `top`, which has no parent, refines or derives another requirement. A `specializes` link is not concerned. See [Inhibitors](entity.md#reference-requirement-inhibitor-label).

### Example

`Speed_bound` is `top`, and refines `Wheel_stop`.

```req
package System
  part Wheel
    let speed in real \ m/s \
  part

  requirement Wheel_stop top
    on Wheel
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement

  requirement Speed_bound top bottom
    on Wheel::speed
    refines Wheel_stop
  is
    Wheel::speed < 3
  requirement
package
```

**reqtool check**

```none
15:12        E04170 the requirement is inhibited upward but traces to another requirement
Wheel_stop
```

### Fix

Remove `top` if the requirement has a parent, or remove the link.

<a id="e04180"></a>

### Downward link to a bottom requirement

* **Code:**
  E04180
* **Severity:**
  moderate
* **Kind:**
  connection

A requirement refines or derives a requirement that is marked `bottom`, which has no children. A `specializes` link is not concerned. See [Inhibitors](entity.md#reference-requirement-inhibitor-label).

### Example

`Wheel_stop` is `bottom`, and `Speed_bound` refines it.

```req
package System
  part Wheel
    let speed in real \ m/s \
  part

  requirement Wheel_stop top bottom
    on Wheel
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement

  requirement Speed_bound bottom
    on Wheel::speed
    refines Wheel_stop
  is
    Wheel::speed < 3
  requirement
package
```

**reqtool check**

```none
15:12        E04180 the traced requirement is inhibited downward
Wheel_stop
```

### Fix

Remove `bottom` from the traced requirement, or remove the link.

<a id="e04190"></a>

### Refinement mismatch

* **Code:**
  E04190
* **Severity:**
  severe
* **Kind:**
  connection

A requirement refines a requirement that constrains an entity that does not contain the entity it constrains: the entity of the refined requirement is neither the entity of this one, nor one of its ancestors. The issue is reported on the `refines` link. Nothing is reported when one of the two requirements has no constraint, see [E04010](#e04010).

### Example

`Battery_voltage` constrains an attribute of `Battery`, and refines `Wheel_deceleration`, which constrains `Wheel`.

```req
package System
  part Wheel
    let deceleration_duration in real \ s \
  part

  part Battery
    let voltage in real \ V \
  part

  requirement Wheel_deceleration top
    on Wheel
  is
    @@
      The [[Wheel]] shall decelerate within 3s.
    @@
  requirement

  requirement Deceleration_bound bottom
    on Wheel::deceleration_duration
    refines Wheel_deceleration
  is
    Wheel::deceleration_duration <= 3
  requirement

  requirement Battery_supply top bottom
    on Battery
  is
    @@
      The [[Battery]] shall supply the drive.
    @@
  requirement

  requirement Battery_voltage bottom
    on Battery::voltage
    refines Wheel_deceleration
  is
    Battery::voltage > 20
  requirement
package
```

**reqtool check**

```none
34:12        E04190 refinement does not restrict a child of the refined restriction
Wheel_deceleration
```

### Fix

Refine a requirement that constrains the same entity, or an entity that contains the one you constrain. Otherwise link the requirements with another kind of link, or no link.

### Why

A refinement constrains the entity of its parent, or an entity nested inside it, see [Traceability](entity.md#reference-requirement-traceability-label).

<a id="e04200"></a>

### Derivation of an unallocated requirement

* **Code:**
  E04200
* **Severity:**
  moderate
* **Kind:**
  connection

A requirement derives a requirement that has no `via`. The issue is reported on the `derives` link.

### Example

`Brake_stops_wheel` derives `Wheel_stop`, which is not allocated.

```req
package System
  part Wheel
  part

  part Brake
  part

  requirement Wheel_stop top
    on Wheel
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement

  requirement Brake_stops_wheel bottom
    on Brake
    derives Wheel_stop
  is
    @@
      The [[Brake]] shall stop the [[Wheel]].
    @@
  requirement
package
```

**reqtool check**

```none
17:12        E04200 this requirement does not derive a requirement that allocates
Wheel_stop
```

### Fix

Allocate the derived requirement to the entity the deriving requirement constrains, with `via`.

### Why

A derived requirement expects its parent to be allocated, see [Traceability](entity.md#reference-requirement-traceability-label) and [Allocation](entity.md#reference-requirement-allocation-label).

<a id="e04210"></a>

### Derivation mismatch

* **Code:**
  E04210
* **Severity:**
  severe
* **Kind:**
  connection

A requirement derives a requirement that is allocated to another entity than the one it constrains. The issue is reported on the `derives` link.

### Example

`Wheel_stop` is allocated to `Brake`, and the requirement that derives it constrains `Battery`. The allocation has no derivation, which is reported as well, see [E04120](#e04120).

```req
package System
  part Wheel
  part

  part Brake
  part

  part Battery
  part

  requirement Brake_exists top bottom
    on Brake
  is
    @@
      The [[Brake]] shall exist.
    @@
  requirement

  requirement Wheel_stop top
    on Wheel
    via Brake
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement

  requirement Battery_powers_brake bottom
    on Battery
    derives Wheel_stop
  is
    @@
      The [[Battery]] shall power the [[Wheel]].
    @@
  requirement
package
```

**reqtool check**

```none
20:8         E04120 allocation of an entity without a deriving requirement
Brake
29:12        E04210 derived requirement is not allocated to the restriction of this requirement
Wheel_stop
```

### Fix

Constrain the allocated entity in the deriving requirement, or allocate the derived requirement to the entity the deriving requirement constrains.

### Why

Every requirement that derives an allocated requirement constrains the allocated entity, see [Allocation](entity.md#reference-requirement-allocation-label).

<a id="e04220"></a>

### Unrelated derivation

* **Code:**
  E04220
* **Severity:**
  moderate
* **Kind:**
  connection

A requirement derives a requirement, and does not use the entity this one constrains. A requirement uses an entity when its text has a reference `[[...]]` to it, or when its expression has an identifier that points to it. The issue is reported on the `derives` link. Nothing is reported when the derived requirement has no constraint, see [E04010](#e04010).

### Example

`Brake_stops_wheel` derives `Wheel_stop`, which constrains `Wheel`, and its text does not mention `Wheel`.

```req
package System
  part Wheel
  part

  part Brake
  part

  requirement Wheel_stop top
    on Wheel
    via Brake
  is
    @@
      The [[Wheel]] shall stop.
    @@
  requirement

  requirement Brake_stops_wheel bottom
    on Brake
    derives Wheel_stop
  is
    @@
      The [[Brake]] shall act.
    @@
  requirement
package
```

**reqtool check**

```none
18:12        E04220 derived requirement is not using its parent restriction
Wheel_stop
```

### Fix

Use the entity of the derived requirement in the text or in the expression.

<a id="e04230"></a>

### Constrained entity not used

* **Code:**
  E04230
* **Severity:**
  moderate
* **Kind:**
  connection

A requirement is `on` an entity that its text or its expression does not use. A requirement uses an entity when its text has a reference `[[...]]` to it, or when its expression has an identifier that points to it.

### Example

`Wheel_round` is `on` `Wheel`, and its text says “the wheel” without a reference. As a consequence nothing uses `Wheel`, which is reported as well, see [E04080](#e04080).

```req
package System
  part Wheel
  part

  requirement Wheel_round top bottom
    on Wheel
  is
    @@
      The wheel shall be round.
    @@
  requirement
package
```

**reqtool check**

```none
1:7          E04080 this entity is not used by any requirement
Wheel
5:7          E04230 requirement does not use its restriction in its expression
Wheel
```

### Fix

Reference the entity in the text, or use it in the expression.

<a id="e04240"></a>

### Allocation and constraint on the same entity

* **Code:**
  E04240
* **Severity:**
  moderate
* **Kind:**
  connection

A requirement is `on` and `via` the same entity. Both references are reported.

### Example

`Wheel_round` is `on Wheel` and `via Wheel`. It has no derivation and no children either, which is reported as well, see [E04120](#e04120) and [E04030](#e04030).

```req
package System
  part Wheel
  part

  requirement Wheel_round top
    on Wheel
    via Wheel
  is
    @@
      The [[Wheel]] shall be round.
    @@
  requirement
package
```

**reqtool check**

```none
4:14         E04030 missing downward traceability
Wheel_round
6:8          E04240 allocation and restriction should be on different subjects
Wheel
6:8          E04120 allocation of an entity without a deriving requirement
Wheel
5:7          E04240 allocation and restriction should be on different subjects
Wheel
```

### Fix

Allocate the requirement to another entity, or remove the `via`.

### Why

The allocated entity differs from the entity the requirement constrains, see [Allocation](entity.md#reference-requirement-allocation-label).
