pampa: raw-json — lossless pampa-native JSON reader/writer (bd-en2hvrwn)#400
Merged
Merged
Conversation
…wn, GH #11) Adds -t raw-json / -f raw-json: a pampa-specific format whose contract is that write-then-read is the identity on the full pampa AST, including everything Pandoc JSON cannot represent — standalone Inline::Attr (the GH #11 repro), NoteReference, the CriticMarkup inlines, Shortcode, CaptionBlock, and full-fidelity ConfigValue metadata (Path/Glob/Expr kinds, merge ops, scalar YAML types, map entry order). Implementation: a raw mode on the shared streaming JSON writer/reader (JsonConfig::raw / SourceInfoDeserializer.raw) rather than a parallel code path — the source-info pool, astContext encoding, and all standard node arms are the same battle-tested code as -t json, so Arc-shared source-info DAGs survive roundtrip. The envelope self-identifies with a first-key "pampa-json-format" marker (version-checked on read) and deliberately omits pandoc-api-version; each reader rejects the other format with a targeted error. Fidelity fixes in the shared reader, found by the new corpus sweep (these improve -f json roundtrips too): - Link/Image target_source (targetS sidecar) was written but dropped on read; now restored. - Citation.id_source (citationIdS) likewise. Tests: 21 new integration tests (TDD; written and failing first), including identity roundtrips for every extension construct, meta fidelity, marker/version rejection in both directions, shared-parent source-info preservation, and an identity sweep over the existing tests/writers/json/*.md corpus. E2E verified through the binary: the issue #11 document renders, three write-read generations are byte-identical, and -f raw-json -t qmd reproduces the input exactly. Design doc: claude-notes/designs/raw-json-format.md Plan: claude-notes/plans/2026-07-17-raw-json-format.md Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11.
Adds
pampa -t raw-json/-f raw-json: a pampa-specific JSON format whose contract is that write-then-read is the identity on the full pampa AST, including everything Pandoc-shaped JSON cannot represent:Inline::Attr(the exact repro from feature: "raw" JSON format #11 — previously error Q-3-32)NoteReference, the four CriticMarkup inlines,Shortcode,CaptionBlockConfigValuemetadata:Path/Glob/Exprkinds, merge ops, scalar YAML types, and map entry orderDesign
A raw mode on the shared streaming JSON writer/reader (
JsonConfig::raw/SourceInfoDeserializer.raw) rather than a fork or a serde-derived parallel format: the source-info pool,astContextencoding, and all standard node arms are the same code path as-t json, so Arc-shared source-info DAGs keep their structural sharing across the roundtrip. Because the raw arms live inside the same exhaustivematches, a new AST variant fails compilation until its raw behavior is decided.The output is unmistakably not
pandoc -t json: the envelope's first key is"pampa-json-format": {"version": 1}(version-checked on read) andpandoc-api-versionis deliberately absent. Each reader rejects the other format with a targeted error pointing at the right-fflag.Contract, tag vocabulary, and versioning policy:
claude-notes/designs/raw-json-format.md. Plan and decision history:claude-notes/plans/2026-07-17-raw-json-format.md.Fidelity fixes in the shared reader (improve
-f jsontoo)The new corpus sweep caught two pre-existing write-only sidecars that were silently dropped on read-back, now restored:
Link/Imagetarget_source(targetS)Citation.id_source(citationIdS)Testing
Substring-parent preservation,Concat/Generatedchains, and an identity sweep over the existingtests/writers/json/*.mdcorpus.cargo xtask verifygreen on all legs except the 20 "live"hub-mcp.test.tstests, which requirewss://sync.automerge.org(down at time of writing; quarto-hub-mcp has no pampa dependency).Three
write → readgenerations byte-identical;-f raw-json -t qmdreproduces the input exactly. (Byte-stability is not part of the contract — semantic identity is; see the design doc.)🤖 Generated with Claude Code