Skip to content

Add streaming parsers for all seven implementations - #203

Merged
konard merged 8 commits into
mainfrom
issue-197-0f9688b95d4f
Sep 15, 2026
Merged

konard merged 8 commits into
mainfrom
issue-197-0f9688b95d4f

Conversation

@konard

@konard konard commented Jan 13, 2026

Copy link
Copy Markdown
Member

Closes #197.

Summary

Adds production-ready incremental parsing to every maintained Links Notation implementation. The parsers accept arbitrary chunks—including one symbol or one line at a time—and emit a top-level record only after indentation, multiline quotes, parentheses, and comments are structurally complete. Every completed segment is validated by the existing canonical parser, so streaming keeps the same syntax and output as whole-document parsing.

This incorporates the useful event/callback and position-tracking ideas from #202, replaces its newline/parenthesis heuristic with canonical record validation, extends the feature from JavaScript and Rust to all seven languages, and supersedes #202.

Native APIs

Language Push API Lazy/native adapter
C# LinkParsed event IEnumerable / IAsyncEnumerable
JavaScript link, error, and end events sync / async iterables
Rust link and error callbacks Iterator
Python link callback generator / async generator
Go callback and io.Writer iter.Seq2
Java Consumer<Link> Stream<Link>
PHP callable Generator

All implementations also expose finish, absolute position, reset/drain, opt-out collection, and a maximum unresolved-record buffer. Disabling collection keeps long-lived callback/iterator streams bounded to the unresolved record.

Reproduction and verification

Before this change, the repository had no supported streaming API on main; the earlier draft handled only JavaScript and Rust and could split an indented record from children or treat newlines inside quotes as record boundaries.

The new shared contract feeds the same document symbol-by-symbol and line-by-line in every language and compares the result with that language's canonical parser. The fixture includes comments, indented children, multiline quoted references, multiline parentheses, and a final record without a trailing newline. It also checks callbacks/events, native lazy adapters, finish behavior, drain/reset, position tracking, and bounded unresolved-record memory.

Run the focused cross-language verification with:

./experiments/issue-197/run.sh

Local full gates passed:

  • JavaScript: format, lint, build, 250 tests
  • Python: Black, isort, Flake8, 220 passed and 1 skipped
  • Go: gofmt, vet, build, race tests, 84.1% coverage
  • Rust: rustfmt, Clippy with warnings denied, release build, unit/integration/doc tests
  • Java: Spotless, compile, 160 tests
  • PHP: strict Composer validation, PHPCS, 210 tests / 539 assertions
  • C#: restore, format verification, release build, 236 tests with zero warnings
  • Generated comparison documents, seven-package version consistency, and documentation comparison checks

Release and documentation

  • Documents streaming APIs in the root and per-language English/Russian READMEs.
  • Adds executable JavaScript and Cargo examples plus the reusable parity experiment.
  • Regenerates the test comparison matrix.
  • Bumps all seven packages and related local consumers from 0.19.0 to 0.20.0; the grammar version is unchanged because the syntax did not change.

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #197
@konard konard self-assigned this Jan 13, 2026
konard and others added 3 commits January 13, 2026 13:09
…sages

This commit implements a streaming parser for both Rust and JavaScript
implementations of links-notation, addressing issue #197. The streaming
parser enables incremental parsing of Links Notation data, which is
essential for handling large messages without loading everything into memory.

**Features:**

Rust Implementation (src/stream_parser.rs):
- StreamParser struct with callback-based API
- on_link() callback for processing parsed links as they arrive
- on_error() callback with detailed error location information
- write() method for feeding data chunks incrementally
- finish() method to complete parsing and return all links
- ErrorLocation type with line, column, and offset information
- Comprehensive test suite with 6 tests covering various scenarios

JavaScript Implementation (src/StreamParser.js):
- EventEmitter-based StreamParser class
- 'link' event emitted for each parsed link
- 'error' event with line/column location information
- write() method for incremental data feeding
- end() method to finalize parsing
- position() method for tracking parse progress
- Configurable maxInputSize and maxDepth options
- Comprehensive test suite with 17 tests

**Examples:**
- examples/rust_streaming_parser.rs - 7 examples demonstrating various use cases
- examples/js_streaming_parser.js - 6 examples showing streaming capabilities

**Documentation:**
- Updated rust/README.md with streaming parser section and API reference
- Updated js/README.md with streaming parser section and API reference
- Added inline documentation and usage examples in code

**Use Cases:**
1. Memory efficiency - Process large messages without loading everything
2. Latency reduction - Start processing before full message arrives
3. Network integration - Natural fit for TCP/HTTP streaming
4. Real-time processing - Handle data as it becomes available

**Testing:**
- All 39 existing Rust tests pass
- All 205 existing JavaScript tests pass (188 + 17 new streaming tests)
- No regressions introduced

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Apply rustfmt to Rust files
- Apply prettier to README files
- No functional changes

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace len() >= 1 with !is_empty() for better idiomatic Rust code.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Add streaming parser for large message handling Add streaming parser for large message handling Jan 13, 2026
@konard
konard marked this pull request as ready for review January 13, 2026 12:14
@konard

konard commented Jan 13, 2026

Copy link
Copy Markdown
Member Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.094619 USD
  • Calculated by Anthropic: $2.499353 USD
  • Difference: $-1.595266 (-38.96%)
    📎 Log file uploaded as Gist (769KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

We need to make sure streaming parser is fully supported in all the languages, meaning we can parse links notation with symbol by symbol, line by line and so on streaming.

So it is possible to have continued access to real time data, or just start processing as soon as it works.

We should support in all our languages all best practices - even driven approach, enumarators and so on, so every language feature is used at the fullest potential and everything is done perfectly in all languages, so most possible use cases are covered.

We also should try to integrate best of #202 if there is something useful and close 202 once we took everything from there.

@konard
konard marked this pull request as draft September 15, 2026 13:28
@konard

konard commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

🤖 AI Work Session Started

Starting automated work session at 2026-09-15T13:28:35.134Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback.

Runtime: solve v2.29.0 · tool codex · model gpt-5.6-sol · task image konard/hive-mind-dind:2.29.0@sha256:11a236d03854cbaea86fdd7ca06265c912cf0b67d1fcc9b3eb60bd84c43ff749

# Conflicts:
#	README.md
#	js/README.md
#	js/src/index.js
#	rust/Cargo.toml
#	rust/README.md
#	rust/links-notation/src/stream_parser.rs
#	rust/src/lib.rs
Add runnable JavaScript and Rust examples plus a seven-language parity experiment. Document each native streaming API in English and Russian, align shared contract tests, regenerate the comparison matrix, and bump all maintained packages for the streaming release.
@konard konard changed the title Add streaming parser for large message handling Add streaming parsers for all seven implementations Sep 15, 2026
@konard
konard marked this pull request as ready for review September 15, 2026 14:39
@konard

konard commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Implemented the requested streaming parity across all seven maintained languages and incorporated the strongest parts of #202. The new parsers support arbitrary symbol/line chunks, canonical syntax validation, native push and lazy APIs, bounded unresolved-record memory, position/drain/reset controls, documentation, examples, and coordinated 0.20.0 release metadata.

The branch now includes current main, the PR is conflict-free and ready for review, and every fresh CI check on 88b769d is green (all language suites, benchmark parity, docs, dependency/security checks, and CodeQL). PR #202 has been closed as superseded.

@konard

konard commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.6 Sol
  • Provider: OpenAI
  • Public pricing estimate: $24.595521

📊 Context and tokens usage:

  • 634.6K / 200K (317%) input tokens, 117.8K / 128K (92%) output tokens

Total: (634.6K + 20.0M cached) input tokens, 117.8K output tokens, $24.595521 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.6-sol
  • Thinking level: xhigh (~31999 tokens)
  • Model: GPT-5.6 Sol (gpt-5.6-sol)

📎 Log file uploaded as Gist (8461KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard
konard merged commit 4b910fc into main Sep 15, 2026
76 checks passed
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.

Add streaming parser for large message handling

1 participant