Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

Ports all v1.0.3 encoder/decoder changes from zon-TS to the Python package, including security limits, strict mode validation, conformance tests, and comprehensive documentation.

Encoder

  • Circular reference detection with ZonEncodeError
  • NaN/Infinity → null, no scientific notation
  • ISO date detection for smart quoting
  • Sparse table encoding for semi-uniform data
  • Compact anonymous table format (@count:cols for pure lists)

Decoder

  • Security limits: 100MB docs (E301), 1MB lines (E302), 1M array items (E303), 100K keys (E304)
  • Strict mode (default) with E001/E002 validation for row/field count mismatches
  • 100-level nesting depth limit
  • Prototype pollution prevention (__proto__, constructor)

API

import zon
from zon import ZonDecodeError

# Encode with circular reference detection
data = {"users": [{"id": 1, "name": "Alice"}]}
encoded = zon.encode(data)  # @1:id,name\n1,Alice

# Decode with strict mode (default)
decoded = zon.decode(encoded)

# Non-strict mode allows row/field mismatches
decoded = zon.decode(encoded, strict=False)

# Error handling with codes
try:
    zon.decode(invalid_zon)
except ZonDecodeError as e:
    print(e.code)  # "E001", "E002", etc.

Tests

Ported from TypeScript: security, security-limits, strict-mode, conformance-encoder, conformance-decoder, canonical-numbers. 93/93 passing.

Scripts

  • scripts/generate_examples.py - Generate JSON/ZON example files
  • scripts/verify_roundtrip.py - Verify lossless roundtrip (13/13 pass)

Documentation

Added comprehensive documentation from TypeScript implementation:

  • docs/SPEC.md - Complete formal specification
  • docs/api-reference.md - Python API documentation with examples
  • docs/syntax-cheatsheet.md - Quick syntax reference
  • docs/llm-best-practices.md - LLM usage guide with Python examples

README Updates

  • Updated with comprehensive token efficiency benchmarks
  • Added retrieval accuracy comparisons across GPT-4o, Claude 3.5, and Llama 3
  • Added documentation links section
Original prompt

https://github.com/ZON-Format/zon-TS

we have lots of changes made in the encoders and all. your job is to implement all those things here in this python package. make sure you have every test script and all readme files exactly as it is there on the above meintions zon ts/js version


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 28, 2025 23:08
Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement encoder changes from zon-TS Port ZON v1.0.4 features from TypeScript to Python Nov 28, 2025
Copilot AI requested a review from ronibhakta1 November 28, 2025 23:21
@ronibhakta1
Copy link
Contributor

@copilot it is v1.0.3 for python

Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 28, 2025

@copilot it is v1.0.3 for python

Updated all version references from v1.0.4 to v1.0.3 in commit b8155a3.

@ronibhakta1
Copy link
Contributor

@copilot https://github.com/ZON-Format/zon-TS/tree/main/docs
https://github.com/ZON-Format/zon-TS/blob/main/README.md
https://github.com/ZON-Format/zon-TS/blob/main/SPEC.md

add the above docs as its importand also there are few benchmarks and all are old in the current python we have all latest things in the shared repos. I want you to make sure you add all the things in the readme and all

Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 28, 2025

@copilot https://github.com/ZON-Format/zon-TS/tree/main/docs
https://github.com/ZON-Format/zon-TS/blob/main/README.md
https://github.com/ZON-Format/zon-TS/blob/main/SPEC.md...

Added all documentation from the TypeScript repository in commit d9785eb:

  • docs/SPEC.md - Complete formal specification
  • docs/api-reference.md - Python API documentation
  • docs/syntax-cheatsheet.md - Quick syntax reference
  • docs/llm-best-practices.md - LLM usage guide

Also updated README.md with comprehensive benchmarks including retrieval accuracy and token efficiency comparisons across GPT-4o, Claude 3.5, and Llama 3.

Copilot AI changed the title Port ZON v1.0.4 features from TypeScript to Python Port ZON v1.0.3 features from TypeScript to Python Nov 28, 2025
@ronibhakta1 ronibhakta1 marked this pull request as ready for review November 29, 2025 00:00
@ronibhakta1 ronibhakta1 merged commit 43773c6 into main Nov 29, 2025
10 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.

2 participants