# Precedence levels check

`precedence-levels-check` · version 1.0.0 · Numbers & math · free, no key needed

Check whether claimed node levels exactly equal the earliest levels induced by a caller-supplied DAG.

**Use when you need to: check claimed earliest dependency levels · verify minimum-depth level partition · audit longest-predecessor ranks.**

## Decide before calling

Read the [versioned contract](/v1/tools/precedence-levels-check/versions/1.0.0) and the supported scope below. Reuse `precedence-levels-check@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `precedence-levels-check@1.0.0` for check claimed earliest dependency levels. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- check claimed earliest dependency levels
- verify minimum-depth level partition
- audit longest-predecessor ranks
- find first incorrect DAG level
- validate canonical precedence layers
- check earliest-start stage assignment

## Not supported

- compute or repair a claimed result
- infer dependencies from prose
- accept cyclic dependency graphs

## Behavior

- nodes and identifiers use exact Unicode scalar-value string equality; no normalization or trimming; null is never an identifier.
- nodes must be unique, every edge endpoint must be declared, self-edges and cyclic graphs are invalid_input.
- A well-typed claim is valid only if it contains every source node exactly once and satisfies the tool-specific precedence rule.
- Claims are never repaired; the first issue is reported by claim index, then source node order, then source edge order.
- Duplicate edges are allowed and have identical semantics to one edge.
- The exact level of a node is 0 for a source, otherwise one plus the maximum level of its immediate predecessors; groups and members retain caller order but every group is nonempty.
- Every output names reference_version Kahn-1962-topological-order-and-poset-linear-extension.

## Input

- `nodes` (array of string, required): max items 5000; each min length 1; each max length 128
- `edges` (array of array of string, required): max items 20000; each min items 2; each max items 2; each each min length 1; each each max length 128
- `levels` (array of array of string, required): max items 5000; each min items 1; each max items 5000; each each min length 1; each each max length 128

## Output

- `valid` (boolean, required)
- `reason` (string, optional)
- `discrepancy` (object, optional)
- `reference_version` (constant "Kahn-1962-topological-order-and-poset-linear-extension", required)

## Limits

- max nodes: 5000
- max edges: 20000
- max id bytes: 128
- max input bytes: 1000000

## Example

Request input:

```json
{
  "nodes": [
    "a",
    "b",
    "c"
  ],
  "edges": [
    [
      "a",
      "c"
    ],
    [
      "b",
      "c"
    ]
  ],
  "levels": [
    [
      "b",
      "a"
    ],
    [
      "c"
    ]
  ]
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reference_version": "Kahn-1962-topological-order-and-poset-linear-extension"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "precedence-levels-check",
  "version": "1.0.0",
  "input": {
    "nodes": [
      "a",
      "b",
      "c"
    ],
    "edges": [
      [
        "a",
        "c"
      ],
      [
        "b",
        "c"
      ]
    ],
    "levels": [
      [
        "b",
        "a"
      ],
      [
        "c"
      ]
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/precedence-levels-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"nodes":["a","b","c"],"edges":[["a","c"],["b","c"]],"levels":[["b","a"],["c"]]}'
```

The machine-readable contract is at [/v1/tools/precedence-levels-check/versions/1.0.0](/v1/tools/precedence-levels-check/versions/1.0.0).

### CLI

```sh
node cli.mjs run precedence-levels-check 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Precedence order check](/tools/precedence-order-check): Check whether a claimed node order is exactly a precedence-respecting linear extension of a caller-supplied DAG.
- [Precedence batches check](/tools/precedence-batches-check): Check whether claimed parallel batches contain every node once and respect a caller-supplied DAG.
- [Maxflow certificate check](/tools/maxflow-certificate-check): Check an exact max-flow/min-cut certificate and return the first deterministic discrepancy.
- [Network flow feasibility check](/tools/network-flow-feasibility-check): Check a claimed s-t flow for capacity bounds and conservation with exact integers; returns the first bad edge or node.
- [Permutation ranked check](/tools/permutation-ranked-check): Check exact stable ordinal ranks for decimal-string values and nulls, reporting the first source-index discrepancy.
- [Coloring validity check](/tools/coloring-validity-check): Check an indexed graph coloring certificate and report the first uncovered vertex or monochromatic edge.
