# JSON keyed resolution apply

`json-keyed-resolution-apply` · version 1.0.0 · JSON & JSONL · free, no key needed

Apply explicit choices to every keyed-array merge conflict and return the fully reconstructed JSON array.

**Use when you need to: apply keyed JSON merge resolutions · resolve three way array conflicts · choose left or right per JSON key.**

## Decide before calling

Read the [versioned contract](/v1/tools/json-keyed-resolution-apply/versions/1.0.0) and the supported scope below. Reuse `json-keyed-resolution-apply@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 `json-keyed-resolution-apply@1.0.0` for apply keyed JSON merge resolutions. 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

- apply keyed JSON merge resolutions
- resolve three way array conflicts
- choose left or right per JSON key
- reconstruct resolved keyed array
- apply manual values to merge conflicts
- finish deterministic JSON array merge

## Not supported

- silently default unresolved conflicts
- resolve conflicts by timestamp

## Behavior

- Implements RFC 8259 JSON, RFC 6901 pointer decoding, and packet-defined R23 keyed merge rules version 1.0.0.
- Exactly one resolution is required for every reported conflict; unknown and duplicate conflict identifiers are rejected.
- Content choices are base, left, right, delete, or an explicit key-preserving value; order choices are base, left, or right.

## Input

- `base` (array of any JSON value, required): max items 256
- `left` (array of any JSON value, required): max items 256
- `right` (array of any JSON value, required): max items 256
- `key_pointer` (string, required): min length 1; max length 1024
- `resolutions` (array of object, required): max items 512

## Output

- `reference` (constant "RFC 8259 + RFC 6901 + ComputeFirst R23 keyed merge rules", required)
- `version` (constant "r23-json-keyed-merge-1.0.0", required)
- `resolved` (array of any JSON value, required): max items 256
- `applied_count` (integer, required): min 0; max 512

## Limits

- max input bytes: 262144
- max items per array: 256
- max nodes: 20000
- max depth: 32
- max conflicts: 512
- max output bytes: 524288

## Example

Request input:

```json
{
  "base": [
    {
      "id": "x",
      "n": 0
    }
  ],
  "left": [
    {
      "id": "x",
      "n": 1
    }
  ],
  "right": [
    {
      "id": "x",
      "n": 2
    }
  ],
  "key_pointer": "/id",
  "resolutions": [
    {
      "conflict_id": "key:x",
      "choice": "left"
    }
  ]
}
```

Response:

```json
{
  "result": {
    "reference": "RFC 8259 + RFC 6901 + ComputeFirst R23 keyed merge rules",
    "version": "r23-json-keyed-merge-1.0.0",
    "resolved": [
      {
        "id": "x",
        "n": 1
      }
    ],
    "applied_count": 1
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "json-keyed-resolution-apply",
  "version": "1.0.0",
  "input": {
    "base": [
      {
        "id": "x",
        "n": 0
      }
    ],
    "left": [
      {
        "id": "x",
        "n": 1
      }
    ],
    "right": [
      {
        "id": "x",
        "n": 2
      }
    ],
    "key_pointer": "/id",
    "resolutions": [
      {
        "conflict_id": "key:x",
        "choice": "left"
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/json-keyed-resolution-apply/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"base":[{"id":"x","n":0}],"left":[{"id":"x","n":1}],"right":[{"id":"x","n":2}],"key_pointer":"/id","resolutions":[{"conflict_id":"key:x","choice":"left"}]}'
```

The machine-readable contract is at [/v1/tools/json-keyed-resolution-apply/versions/1.0.0](/v1/tools/json-keyed-resolution-apply/versions/1.0.0).

### CLI

```sh
node cli.mjs run json-keyed-resolution-apply 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [JSON keyed array merge](/tools/json-keyed-array-merge): Three-way merge JSON arrays by a JSON Pointer key, returning edits, moves, inserts, deletes, and conflicts.
- [JSON keyed conflicts list](/tools/json-keyed-conflicts-list): List deterministic content and order conflicts from a three-way JSON keyed-array comparison without resolving them.
- [JSON array three way merge](/tools/json-array-three-way-merge): Merge base, left and right JSON arrays, returning deterministic output and explicit conflicting edit regions.
- [JSON array merge verify](/tools/json-array-merge-verify): Verify a candidate JSON array against the deterministic three-way merge result and return an exact witness.
- [JSON array align](/tools/json-array-align): Align two JSON arrays with duplicate-safe occurrence pairs and deterministic LCS tie-breaking.
- [JSON array index by](/tools/json-array-index-by): Convert an array of objects into a single object indexed by a specific key.
