# Form response diff

`form-response-diff` · version 1.0.0 · Forms · free, no key needed

Reconcile two form response sets by exact respondent id.

**Use when you need to: diff form responses · reconcile form respondents.**

## Supported

- diff form responses
- reconcile form respondents

## Not supported

- fuzzy respondent matching
- inferred identity
- definition migration
- html extraction

## Behavior

- Join responses by exact respondent_id. Duplicate ids are rejected. Ids are not trimmed or normalized.
- Added and removed respondents include their answers. Identical respondents are listed by id only.
- A changed respondent carries the shared-definition answer diff and its precedence: invalid before added, removed, changed, or order_only.
- Both nulls compare equal and do not by themselves mark the respondent changed. This comparison is not a completeness check.
- Answer key order does not matter. Output answer keys follow the definition order, then unknown keys.
- counts.added + counts.removed + counts.changed + counts.unchanged equals the respondent union.

## Input

- `definition` (object, required)
- `left` (array of object, required)
- `right` (array of object, required)

## Output

- `added_respondents` (array of any, required)
- `removed_respondents` (array of any, required)
- `changed_respondents` (array of any, required)
- `unchanged_respondent_ids` (array of string, required)
- `counts` (object, required)

## Limits

- max input bytes: 262144
- max output bytes: 262144
- max input depth: 16
- max input nodes: 20000
- max fields: 100
- max choices: 50
- max respondents: 100
- max id bytes: 128
- max label bytes: 256
- max choice bytes: 128
- max answer string bytes: 4096
- max answer depth: 6
- max answer nodes: 50
- max changes: 500
- max mapping: 100

## Example

Request input:

```json
{
  "definition": {
    "fields": [
      {
        "id": "name",
        "label": "Name",
        "type": "string",
        "required": true
      }
    ]
  },
  "left": [
    {
      "respondent_id": "r1",
      "answers": {
        "name": "Ada"
      }
    },
    {
      "respondent_id": "r2",
      "answers": {
        "name": "Lin"
      }
    }
  ],
  "right": [
    {
      "respondent_id": "r2",
      "answers": {
        "name": "Lin"
      }
    },
    {
      "respondent_id": "r3",
      "answers": {
        "name": "Grace"
      }
    }
  ]
}
```

Response:

```json
{
  "result": {
    "added_respondents": [
      {
        "respondent_id": "r3",
        "answers": {
          "name": "Grace"
        }
      }
    ],
    "removed_respondents": [
      {
        "respondent_id": "r1",
        "answers": {
          "name": "Ada"
        }
      }
    ],
    "changed_respondents": [],
    "unchanged_respondent_ids": [
      "r2"
    ],
    "counts": {
      "added": 1,
      "removed": 1,
      "changed": 0,
      "unchanged": 1,
      "respondents": 3
    }
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "form-response-diff",
  "version": "1.0.0",
  "input": {
    "definition": {
      "fields": [
        {
          "id": "name",
          "label": "Name",
          "type": "string",
          "required": true
        }
      ]
    },
    "left": [
      {
        "respondent_id": "r1",
        "answers": {
          "name": "Ada"
        }
      },
      {
        "respondent_id": "r2",
        "answers": {
          "name": "Lin"
        }
      }
    ],
    "right": [
      {
        "respondent_id": "r2",
        "answers": {
          "name": "Lin"
        }
      },
      {
        "respondent_id": "r3",
        "answers": {
          "name": "Grace"
        }
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/form-response-diff/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"definition":{"fields":[{"id":"name","label":"Name","type":"string","required":true}]},"left":[{"respondent_id":"r1","answers":{"name":"Ada"}},{"respondent_id":"r2","answers":{"name":"Lin"}}],"right":[{"respondent_id":"r2","answers":{"name":"Lin"}},{"respondent_id":"r3","answers":{"name":"Grace"}}]}'
```

The machine-readable contract is at [/v1/tools/form-response-diff/versions/1.0.0](/v1/tools/form-response-diff/versions/1.0.0).

### CLI

```sh
node cli.mjs run form-response-diff 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [Form answer diff](/tools/form-answer-diff): Diff two answer maps against one shared form definition.
- [Form compare](/tools/form-compare): Compare two filled form snapshots and return compact field and answer changes.
- [Form definition diff](/tools/form-definition-diff): Diff two form definitions by stable field id, including choice lists and field order.
- [Form response check](/tools/form-response-check): Report missing required answers, nulls, type failures, and choice failures.
- [Form field map](/tools/form-field-map): Rename form fields with an explicit id map and reject collisions.
