Skip to content

Add RFC 7464 JSON text sequences to JSONStreaming - #98

Merged
ThorFuchs merged 2 commits into
mainfrom
feature/1.10-json-seq
Nov 14, 2026
Merged

ThorFuchs merged 2 commits into
mainfrom
feature/1.10-json-seq

Conversation

@ThorFuchs

Copy link
Copy Markdown
Owner

Summary

1.10 exact interchange: RFC 7464 JSON text sequences (application/json-seq) in JSONStreaming.

Reader: JSONTextSequence

  • Each text starts with RS (0x1E) and runs to the next RS or EOF. It uses the same pull model, one-iterator ledger and per-text value quotas as NDJSONValueSequence.
  • Each text is parsed by the strict grammar, so it may span several lines. Consecutive, leading and final RS bytes are not empty texts.
  • Truncation (RFC 7464 §2.4): a top-level number, true, false or null without trailing whitespace is reported as possibly truncated (.syntax/.unexpectedEOF). Bytes before the first RS are malformed.
  • Malformed texts: they fail by default, consistent with the package's strict readers. JSONTextSequenceOptions.MalformedTexts.skip skips them and continues at the next RS, as the RFC recommends; Iterator.skippedTexts counts them. Resource failures, cancellation and source errors are never skipped.
  • Failure locations: absolute byte offset, the text number as record, and line and column within the text.

Writer: JSONTextSequenceWriter

  • Writes RS, the strict writer's bytes, then LF, per value.
  • encode(_:) / encodeWithReport(_:) produce a whole sequence under one ledger.
  • write(_:to:) / writeWithReport(_:to:) emit one text in awaited, bounded chunks, like JSONAsyncWriter.

Docs

  • New DocC article TextSequences.md, with landing-page topics.
  • CHANGELOG entry under 1.10.0, plus README product row and stream paragraph.
  • Updated the stale AGENTS.md note that said text-sequence framing was deferred.
  • JSONStreamingTests discovery counts 36 → 42 (root/portable/WASI).
  • CLI identity regenerated.

Qualification (local)

Toolchain: Apple Swift 6.4.2 (swiftlang-6.4.2.1.9), macOS 27.3. Base: 97bfd7d.

  • python3 Scripts/ci.py --lane native on 9d2a26c: exit 0, 62/62 commands passed, 0 failed.
  • python3 Scripts/ci.py --lane docs on 9d2a26c: exit 1. DocC rejected a cross-module symbol link to JSONWritingOptions.
  • feee9c3 changes that link to plain code and regenerates the CLI identity; nothing else changes.
  • Docs lane rerun on that state: exit 0, 4/4 commands passed. Native was not rerun locally after this doc-comment change; GitHub CI covers it.

New tests (6) cover:

  • every chunk split;
  • truncation for each scalar kind;
  • leading garbage;
  • skip with counts;
  • resource limits that skip does not bypass;
  • writer round trips, including indented output and bounded chunks;
  • cancellation.

No tag, release or publication follows from this PR.

🤖 Generated with Claude Code

ThorFuchs and others added 2 commits November 14, 2026 18:30
JSONTextSequence reads application/json-seq texts framed by the record
separator with the NDJSON pull model and budgets. Unterminated top-level
scalars count as possibly truncated (RFC 7464 section 2.4). Malformed texts
fail by default or are skipped and counted on request; resource failures
are never skipped. JSONTextSequenceWriter writes RS, strict JSON and LF per
value, as one sequence or in awaited bounded chunks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ThorFuchs
ThorFuchs merged commit b3eef29 into main Nov 14, 2026
21 checks passed
@ThorFuchs
ThorFuchs deleted the feature/1.10-json-seq branch November 14, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant