# Citation passage check

`citation-passage-check` · version 1.0.0 · Text · free, no key needed

Check that a cited start/end span of a supplied source version reads exactly as the quoted passage.

**Use when you need to: verify quoted passage at character offsets · check citation span matches source text · does this quote really appear at position start end.**

## Decide before calling

Read the [versioned contract](/v1/tools/citation-passage-check/versions/1.0.0) and the supported scope below. Reuse `citation-passage-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 `citation-passage-check@1.0.0` for verify quoted passage at character offsets. 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

- verify quoted passage at character offsets
- check citation span matches source text
- does this quote really appear at position start end
- validate text position selector against document
- check rag citation offsets against retrieved chunk
- verify quotation from a specific document version
- בדיקת ציטוט מול טקסט המקור לפי מיקום

## Not supported

- fetching the source or proving the supplied text is authentic
- fuzzy, case-insensitive or whitespace-normalized quote matching
- UTF-16 or byte offsets (positions are Unicode code points)
- grapheme-cluster boundary checks

## Behavior

- Implements W3C Web Annotation Data Model (Recommendation 2017-02-23) 4.2.4 TextQuoteSelector, 4.2.5 TextPositionSelector; r68 supplied-text profile 1.0.0; every result carries reference_version.
- Checks only the caller-supplied text: authenticity_checked is always false and a valid result never claims the text is the real content of the named source or version.
- Sources are (source_id, version, text) entries; the pair must be unique. version is an immutable label compared exactly. The cited source_id must exist (else unknown_source) and the cited version must be one supplied for it (else version_mismatch with available_versions sorted by code point).
- TextPositionSelector start and end count Unicode code points from 0; start is included and end excluded (W3C 4.2.5). Comparison order: span_reversed (start > end), span_out_of_range (end > text length), then quote_mismatch.
- The quote is compared code point by code point with no normalization; quote_mismatch reports quote_offset (index in the quote), source_offset, expected_char (source code point, null past the span) and claimed_char (null past the quote).
- Strings with lone surrogates are invalid_input; text may be empty, quote may not.

## Input

- `sources` (array of object, required): min items 1; max items 16
- `citation` (object, required)

## Output

- `valid` (boolean, required)
- `reason` (one of null, "unknown_source", "version_mismatch", "span_reversed", "span_out_of_range", "quote_mismatch", required)
- `first_discrepancy` (object or null, required)
- `authenticity_checked` (constant false, required)
- `reference_version` (constant "W3C Web Annotation Data Model (Recommendation 2017-02-23) 4.2.4 TextQuoteSelector, 4.2.5 TextPositionSelector; r68 supplied-text profile 1.0.0", required)

## Limits

- max input bytes: 1048576
- max sources: 16
- max text bytes: 524288
- max quote bytes: 16384
- max label bytes: 256

## Example

Request input:

```json
{
  "sources": [
    {
      "source_id": "alphabet",
      "version": "v1",
      "text": "abcdefghijklmnopqrstuvwxyz"
    }
  ],
  "citation": {
    "source_id": "alphabet",
    "version": "v1",
    "selector": {
      "type": "TextPositionSelector",
      "start": 4,
      "end": 7
    },
    "quote": "efg"
  }
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reason": null,
    "first_discrepancy": null,
    "authenticity_checked": false,
    "reference_version": "W3C Web Annotation Data Model (Recommendation 2017-02-23) 4.2.4 TextQuoteSelector, 4.2.5 TextPositionSelector; r68 supplied-text profile 1.0.0"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "citation-passage-check",
  "version": "1.0.0",
  "input": {
    "sources": [
      {
        "source_id": "alphabet",
        "version": "v1",
        "text": "abcdefghijklmnopqrstuvwxyz"
      }
    ],
    "citation": {
      "source_id": "alphabet",
      "version": "v1",
      "selector": {
        "type": "TextPositionSelector",
        "start": 4,
        "end": 7
      },
      "quote": "efg"
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/citation-passage-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"sources":[{"source_id":"alphabet","version":"v1","text":"abcdefghijklmnopqrstuvwxyz"}],"citation":{"source_id":"alphabet","version":"v1","selector":{"type":"TextPositionSelector","start":4,"end":7},"quote":"efg"}}'
```

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

### CLI

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

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

## Related tools

- [Citation anchor check](/tools/citation-anchor-check): Check a quote anchor (exact text plus prefix/suffix) matches exactly one place in a supplied source version.
- [Citation batch check](/tools/citation-batch-check): Check an ordered batch of citations (span+quote or quote anchors) against supplied sources; returns the first failure.
- [Text delimiter chunk](/tools/text-delimiter-chunk): Split text on an explicit literal delimiter (Python str.split rules, optional max_splits) with spans and line numbers.
- [Text paragraphs split](/tools/text-paragraphs-split): Split text into paragraphs separated by blank lines (CommonMark line rules) with code point spans and line numbers.
- [Markdown sections chunk](/tools/markdown-sections-chunk): Chunk a CommonMark document into sections at its top-level ATX and setext headings, with levels, paths and spans.
- [Text sentence offsets](/tools/text-sentence-offsets): Return UAX #29 sentence spans as start/end offsets in code points, UTF-16 units or UTF-8 bytes, with the ending rule.
