# Precedence order check

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

Check whether a claimed node order is exactly a precedence-respecting linear extension of a caller-supplied DAG.

**Use when you need to: check claimed topological order · verify linear extension certificate · audit serialized task ordering.**

## Decide before calling

Read the [versioned contract](/v1/tools/precedence-order-check/versions/1.0.0) and the supported scope below. Reuse `precedence-order-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-order-check@1.0.0` for check claimed topological order. 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 topological order
- verify linear extension certificate
- audit serialized task ordering
- find first ordering edge violation
- validate dependency sequence permutation
- check ordered DAG execution plan

## 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.
- Any permutation satisfying every edge is accepted; unrelated-node tie order is unrestricted.
- 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
- `order` (array of string, required): max items 5000; each min length 1; 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": [
    "compile",
    "test",
    "ship"
  ],
  "edges": [
    [
      "compile",
      "test"
    ],
    [
      "test",
      "ship"
    ]
  ],
  "order": [
    "compile",
    "test",
    "ship"
  ]
}
```

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-order-check",
  "version": "1.0.0",
  "input": {
    "nodes": [
      "compile",
      "test",
      "ship"
    ],
    "edges": [
      [
        "compile",
        "test"
      ],
      [
        "test",
        "ship"
      ]
    ],
    "order": [
      "compile",
      "test",
      "ship"
    ]
  }
}
```

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [Precedence batches check](/tools/precedence-batches-check): Check whether claimed parallel batches contain every node once and respect a caller-supplied DAG.
- [Topological order check](/tools/topological-order-check): Check that a claimed vertex order is a permutation and topological order of a digraph; reports the first backward edge
- [Join inner result check](/tools/join-inner-result-check): Check a claimed ordered inner join index result and report its first discrepancy.
- [Join left result check](/tools/join-left-result-check): Check a claimed ordered left join index result and report its first discrepancy.
- [Join semi result check](/tools/join-semi-result-check): Check a claimed ordered semi-join index result and report its first discrepancy.
- [Precedence levels check](/tools/precedence-levels-check): Check whether claimed node levels exactly equal the earliest levels induced by a caller-supplied DAG.
