# Precedence batches check

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

Check whether claimed parallel batches contain every node once and respect a caller-supplied DAG.

**Use when you need to: check claimed parallel dependency batches · verify feasible batched schedule · audit deferred parallel work groups.**

## Decide before calling

Read the [versioned contract](/v1/tools/precedence-batches-check/versions/1.0.0) and the supported scope below. Reuse `precedence-batches-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-batches-check@1.0.0` for check claimed parallel dependency batches. 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 parallel dependency batches
- verify feasible batched schedule
- audit deferred parallel work groups
- find first cross-batch violation
- validate dependency-safe batch plan
- check staged concurrent execution

## 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.
- Each batch is nonempty; an edge requires its source in a strictly earlier batch, while otherwise-ready nodes may be deferred.
- 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
- `batches` (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"
    ]
  ],
  "batches": [
    [
      "a"
    ],
    [
      "b"
    ],
    [
      "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-batches-check",
  "version": "1.0.0",
  "input": {
    "nodes": [
      "a",
      "b",
      "c"
    ],
    "edges": [
      [
        "a",
        "c"
      ]
    ],
    "batches": [
      [
        "a"
      ],
      [
        "b"
      ],
      [
        "c"
      ]
    ]
  }
}
```

### HTTP (no key)

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

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

### CLI

```sh
node cli.mjs run precedence-batches-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 levels check](/tools/precedence-levels-check): Check whether claimed node levels exactly equal the earliest levels induced by a caller-supplied DAG.
- [Flow feasibility check](/tools/flow-feasibility-check): Check exact integer edge capacities and flow conservation, returning the first 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.
- [Dedupe first check](/tools/dedupe-first-check): Check an exact first-wins SameValueZero deduplication claim and report its first discrepancy.
- [Dedupe keyed check](/tools/dedupe-keyed-check): Check an exact keyed Map deduplication claim and report its first discrepancy.
