# Sequence key order check

`sequence-key-order-check` · version 1.0.0 · Sequences & diffs · free, no key needed

Check an exact stable ordering claim for bounded records by a scalar key.

**Use when you need to: Check an exact stable ordering claim for bounded records by a scalar key. · verify record key ordering · check keyed index certificate.**

## Decide before calling

Read the [versioned contract](/v1/tools/sequence-key-order-check/versions/1.0.0) and the supported scope below. Reuse `sequence-key-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 `sequence-key-order-check@1.0.0` for Check an exact stable ordering claim for bounded records by a scalar key.. 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 an exact stable ordering claim for bounded records by a scalar key.
- verify record key ordering
- check keyed index certificate
- validate rows sorted by field
- locate keyed order mismatch
- audit property based ranking

## Not supported

- sorting data into a replacement result
- locale-aware or floating-point ordering

## Behavior

- Values use the total type order null, boolean, safe integer, string; strings compare Unicode scalar values lexicographically.
- Equal values retain source-index order; claims are exact source-index permutations and are never repaired.
- Every verdict names ECMA-262-2026-SameValue-relational+ISO-IEC-9899-2018-7.24.4.2.

## Input

- `source` (array of object, required): max items 10000
- `claim` (array of integer, required): max items 10000; each min 0; each max 9999
- `direction` (one of "ascending", "descending", required)
- `key` (string, required): min length 1; max length 64

## Output

- `valid` (boolean, required)
- `reason` (string, optional)
- `discrepancy` (object, optional)
- `reference_version` (string, required)

## Limits

- max input bytes: 262144
- max items: 10000
- max string code points: 4096

## Example

Request input:

```json
{
  "source": [
    {
      "id": "b",
      "n": 2
    },
    {
      "id": "a",
      "n": 1
    }
  ],
  "claim": [
    1,
    0
  ],
  "direction": "ascending",
  "key": "n"
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reference_version": "ECMA-262-2026-SameValue-relational+ISO-IEC-9899-2018-7.24.4.2"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "sequence-key-order-check",
  "version": "1.0.0",
  "input": {
    "source": [
      {
        "id": "b",
        "n": 2
      },
      {
        "id": "a",
        "n": 1
      }
    ],
    "claim": [
      1,
      0
    ],
    "direction": "ascending",
    "key": "n"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/sequence-key-order-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"source":[{"id":"b","n":2},{"id":"a","n":1}],"claim":[1,0],"direction":"ascending","key":"n"}'
```

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

### CLI

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

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

## Related tools

- [Sequence order check](/tools/sequence-order-check): Check an exact stable ascending or descending source-index ordering claim.
- [Sequence strict order check](/tools/sequence-strict-order-check): Check an exact strictly ascending or descending source-index ordering claim.
- [Myers diff bounded](/tools/myers-diff-bounded): Produce a canonical Myers edit script within a caller distance cap, or a deterministic over-cap result.
- [Sequence index map](/tools/sequence-index-map): Map each left-sequence index to a kept right index, or null if deleted, and list inserted right indices.
- [Myers common subsequence](/tools/myers-common-subsequence): Return a canonical indexed LCS witness derived from bounded Myers search, or null when its cap is exceeded.
- [Myers distance bounded](/tools/myers-distance-bounded): Compute Myers insert/delete distance up to a caller cap, returning null predictably when the cap is exceeded.
