# Measurement Protocol for File-Output Receipts

**Status:** Proposed research protocol, 2026-10-10. The examples are synthetic. No incident-time faculty file is included, and this protocol does not resolve the historical 979-versus-535 disagreement.

## Measurement identity

Measure an immutable copy after the writer has finished. The child and parent must identify the same artifact bytes and the same version of the measurement procedure. Record the SHA-256, byte count, resolved path, Python version, command, exit status, and measurement-script revision or hash. A digest is a snapshot identifier, not proof of correct authorship or truthful content. The script reads one byte buffer but does not lock live files; simultaneous editing must be prevented outside the script.

From this paper directory:

```bash
python measure_file.py /path/to/output.md
python -m unittest test_measure_file.py
```

The script supports UTF-8 with optional BOM and LF or CRLF line endings. It rejects bare CR and invalid UTF-8 instead of silently substituting characters. It does not resolve filesystem containment or permissions for an agent workflow; its resolved path is information for the reviewer.

## Counting definitions

| Metric | Definition |
|---|---|
| Bytes | Length of raw file bytes, including BOM and line-ending bytes |
| Newline count | Number of LF bytes, whether standalone or in CRLF |
| Logical lines | LF/CRLF-delimited text segments; retain empty lines, but do not invent an extra line after a terminal delimiter; empty file has zero lines |
| Nonempty lines | Logical lines whose content is not the empty string |
| Nonblank lines | Logical lines containing at least one non-whitespace character |
| Lexical H2 headings | Lines starting exactly with `## `, with one-based line positions; this is not a Markdown parser and includes matches inside code fences |

For the synthetic bytes `a\n\n \nb`, these definitions produce four logical lines, three LF bytes, three nonempty lines, and two nonblank lines. All are correct under their stated definitions. Comparing one to another without labelling the definition creates an apparent discrepancy.

The historical report's `Get-Content | Measure-Object -Line` command uses a different text-measurement path. The 2026-10-10 PowerShell 7.6.6 check `@('a', '', 'b') | Measure-Object -Line` returned two. That is a mechanism illustration, not proof of the historical file's line count or the historical command's environment.

## Comparison and disposition

If digests differ, classify **SNAPSHOT_MISMATCH** and locate the correct revision before comparing metrics. If definitions differ, classify **DEFINITION_MISMATCH**. If a receipt is missing or cannot be rerun, classify **UNVERIFIABLE**. Only equal-digest, equal-definition disagreements support **MEASUREMENT_DISCREPANCY**. A mismatch alone does not identify whether the cause is copying, a tool defect, a bad estimate, or deception.

Report each child's original claim alongside the independent measurement and disposition. Verify substantive requirements separately. The synthetic checks cover empty files, trailing delimiters, empty and whitespace-only lines, LF/CRLF/BOM differences, and unsupported input; passing them establishes the script's behavior on those cases, not the output contract's effectiveness.
