```python
import argparse
import json
import sys
from pathlib import Path


def load_and_validate_records(filepath: str) -> list[dict]:
    """Load JSON file and validate records. Exit 2 on any error."""
    path = Path(filepath)
    if not path.exists():
        print(f"Error: File '{filepath}' does not exist.", file=sys.stderr)
        sys.exit(2)
    if not path.is_file():
        print(f"Error: '{filepath}' is not a file.", file=sys.stderr)
        sys.exit(2)
    try:
        with open(path, 'r', encoding='utf-8') as f:
            data = json.load(f)
    except json.JSONDecodeError as e:
        print(f"Error: Invalid JSON in '{filepath}': {e}", file=sys.stderr)
        sys.exit(2)
    except UnicodeDecodeError as e:
        print(f"Error: File '{filepath}' is not valid UTF-8: {e}", file=sys.stderr)
        sys.exit(2)

    if not isinstance(data, list):
        print(f"Error: Expected a JSON list at the top level, got {type(data).__name__}.", file=sys.stderr)
        sys.exit(2)

    seen_ids = set()
    records = []
    for i, record in enumerate(data):
        if not isinstance(record, dict):
            print(f"Error: Record at index {i} is not an object.", file=sys.stderr)
            sys.exit(2)
        if 'id' not in record:
            print(f"Error: Record at index {i} is missing required field 'id'.", file=sys.stderr)
            sys.exit(2)
        if 'text' not in record:
            print(f"Error: Record at index {i} is missing required field 'text'.", file=sys.stderr)
            sys.exit(2)
        if 'confirmed' not in record:
            print(f"Error: Record at index {i} is missing required field 'confirmed'.", file=sys.stderr)
            sys.exit(2)

        rid = record['id']
        if not isinstance(rid, str):
            print(f"Error: Record at index {i} has non-string 'id'.", file=sys.stderr)
            sys.exit(2)
        if rid in seen_ids:
            print(f"Error: Duplicate id '{rid}' found at index {i}.", file=sys.stderr)
            sys.exit(2)
        seen_ids.add(rid)

        text = record['text']
        if not isinstance(text, str):
            print(f"Error: Record at index {i} has non-string 'text'.", file=sys.stderr)
            sys.exit(2)

        confirmed = record['confirmed']
        if not isinstance(confirmed, bool):
            print(f"Error: Record at index {i} has non-boolean 'confirmed'.", file=sys.stderr)
            sys.exit(2)

        records.append({
            'id': rid,
            'text': text,
            'confirmed': confirmed,
        })

    records.sort(key=lambda r: r['id'])
    return records


def print_section(title: str, records: list[dict]) -> None:
    """Print a section with its records."""
    print(title)
    if not records:
        print("(empty)")
    else:
        for rec in records:
            print(rec['id'])
            print(rec['text'])


def main() -> None:
    parser = argparse.ArgumentParser(
        description=(
            "Build Publication Desk: help a writer prepare confirmed quotations "
            "and find the follow-up work before sharing a draft.\n\n"
            "By default, prints two sections:\n"
            "  READY        - notes with confirmed=true\n"
            "  NEEDS REVIEW - notes with confirmed=false\n\n"
            "Each note is printed as its id on one line, followed by its exact text on the next line.\n"
            "Empty sections print (empty).\n\n"
            "Exit codes:\n"
            "  0 - All notes are confirmed (READY); no follow-up needed.\n"
            "  1 - Useful output produced, but some notes need review (follow-up pending).\n"
            "  2 - Invalid input: missing file, invalid JSON, or invalid record structure.\n\n"
            "Use --ready-only to print only the READY section, so the reader can redirect it into a draft file.\n"
            "In both modes, exit 1 if any note needs review, otherwise exit 0.\n"
            "Exit 1 means useful output with follow-up pending, not invalid input.\n"
            "confirmed is treated as the writer's supplied decision; no factual verification is performed."
        )
    )
    parser.add_argument(
        'input_file',
        help='Path to a UTF-8 JSON file containing a list of objects with unique string id, string text, and boolean confirmed.'
    )
    parser.add_argument(
        '--ready-only',
        action='store_true',
        help='Print only the READY section (confirmed=true notes). Useful for redirecting into a draft file.'
    )

    args = parser.parse_args()

    records = load_and_validate_records(args.input_file)

    ready = [r for r in records if r['confirmed']]
    needs_review = [r for r in records if not r['confirmed']]

    if args.ready_only:
        print_section("READY", ready)
    else:
        print_section("READY", ready)
        print_section("NEEDS REVIEW", needs_review)

    if needs_review:
        sys.exit(1)
    else:
        sys.exit(0)


if __name__ == '__main__':
    main()
```