Skip to content

#276 member 3 (SL-11): canonical JSON writing in the standard library (LexLeanStd.Json) — draft - #363

Merged
humuhumu33 merged 21 commits into
release/v0.4from
member3-json
Nov 6, 2026
Merged

humuhumu33 merged 21 commits into
release/v0.4from
member3-json

Conversation

@humuhumu33

@humuhumu33 humuhumu33 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Member 3 of #276, the third standard-library member the self-hosted compiler needs (SPEC.md §17.22, row SL-11). Stacks on #328 (member 2, SL-10), which stacks on #326 (member 1, SL-09): the diff below is the Json member only. It is the writer half of the canonical JSON of §21.7; the reader is member 4 (SL-13). Claim: #276 (comment)

What it adds

stdlib/src/Json.lex.tex, LexLeanStd.Json: one recursive value Json and three production roots for rust-std.

Root Oracle
writeJson (value : Json) : Bytes canonical_json::Json::to_canonical_string
writeJsonFile (value : Json) : Bytes Json::to_file_bytes, the payload and one final LF
escapeString (text : Bytes) : Bytes the string escape of write_escaped, quotes included
  • The value. JBool, JInt (a sign and a magnitude, so an i64 is in range), JStr (bytes), JArr, JObj, with the elements of an array and the members of an object as spines (JNil, JItem, JMember) of the same type. This differs from the claim comment, which said a mutual group of three types. I used the shape of bootstrap's Expr because it is proven on this line, as a structural mutual definition group (writeValue, renderItems, renderMembers). The mutual-type form was not tried.
  • Objects. The members are rendered, sorted by Order.sortEntries (SL-10), and of a run of equal keys the last is kept, which is what the oracle's BTreeMap insertion keeps. The stable sort keeps their input order, so the last of a run is the last one given.
  • Integers are the shortest decimal through Numeral.decimal; - only before a nonzero magnitude, so a negative zero writes 0.
  • Strings escape ", \, \b, \f, \n, \r, \t, and \u00 plus two lowercase hex digits for every other byte below 0x20; every other byte is raw.
  • The two writers admit recursion, so each needs a stack bound (PD-08).

What landed here

  • The register row, the §31 row, the §17.22 prose, the scenario, and the count mirrors, 460 -> 461 (8463c8091).
  • The case wired and registered to fail first, per R3 (b6a3bf400).
  • The module, its differential, the export roots, the entrypoint, and the locks of stdlib, bootstrap and examples/helpdesk (85a3ad620).
  • The case reports the first disagreement of the planted writer (a91e5083a).
  • The falsifiability record in VERIFICATION.md (ac6792679).
  • The §17.22 prose corrected: it gave a false reason for the shape (f4b18d0cb).

Evidence measured on this host (WSL Ubuntu, pinned Rust 1.97.1 and Lean 4.32.1)

  • Fail-first watched: 1 failed … 460 filtered out, the panic naming the missing work.
  • check, build, fmt --check clean; the eligibility report has all three roots eligible for rust-std with exactly their declared effects (escapeString [allocation, overflow]; writeJson and writeJsonFile [allocation, overflow, recursion]).
  • The evaluator agrees with the oracle on 300 runs per root, the rendered packages under the pinned rustc on 1,500 per root, over trees with repeated and prefix keys, multibyte and control characters, and integers from i64::MIN to i64::MAX.
  • The plant (keep the first of a repeated key) is detected: 24 of 300 runs disagree, the first {"j":3,"k":1} against {"j":3,"k":4}. On trees with no repeated key the planted writer agrees, so only a repeated key catches it.
  • cargo clippy -p repo-conformance -p xtask --all-targets --all-features -D warnings, validate-model (461 ids), validate-spec-links (461 rows), check-test-inventory, and the five bdd meta-gate tests pass.

Not confirmed, stated plainly

Refs #276 (member 3; member 4, the reader, takes SL-13).

🤖 Generated with Claude Code

humuhumu33 and others added 5 commits October 29, 2026 11:37
…the count mirrors (460 -> 461)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…he locks of its consumers

One recursive Json value (the spine shape of bootstrap Expr) and a mutual
structural writer: writeJson and writeJsonFile for the whole value,
escapeString for a string. An object is written with its members sorted by
Order.sortEntries and the last of a repeated key kept, as the oracle BTreeMap
keeps it; integers are a sign and a magnitude through Numeral.decimal.
Held to canonical_json::Json::to_canonical_string and to_file_bytes. The plant
keeps the first of a repeated key: only trees that repeat a key catch it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…iter

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The sentence said a mutual group of types has no structural recursion. The
mutual-group rule admits a recursive family over one inductive group; the
module takes the shape of Expr because it is proven on this line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The conflicts were the counts, two README rows, the CHANGELOG, VERIFICATION.md,
and the lock. The register is the release's 469 plus SL-11, 470, in SPEC.md,
README.md, xtask/src/spec_links.rs and the repository case. The lock takes the
release's header: stdlib's entrypoint moved, so the locks, exports and build
oracles are regenerated once, on top of #390, in the next commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
humuhumu33 and others added 3 commits November 3, 2026 14:40
The merge of #364 took the release header into stdlib/lexlean.lock, which still
describes a stdlib without LexLeanStd.Json: `repro` and six stdlib cases of
`bdd` refuse it with LLC0102. `lexlean lock` in stdlib, bootstrap, and
examples/helpdesk moves their digests. The exports, build oracles and counts
are the regeneration that follows.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…72 IDs

The line gained DF-19 and PD-10 since the last merge (#364), so the §31
total, README, the two row-count checks and the CHANGELOG move from 471 to
472 with SL-11. stdlib/lexlean.toml lists both the line's Host and this
member's Json among its entrypoints. The locks of stdlib, bootstrap and
examples/helpdesk are taken from the line here and rewritten in the next
commit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`lexlean lock` in stdlib, bootstrap and examples/helpdesk, with the binary
built from this tree: stdlib's project_config_sha256 moves for the Json
entrypoint, and the two consumers' pins of it follow. The exports, build
oracles, verify records and counts are the regeneration that follows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@humuhumu33
humuhumu33 changed the base branch from member2-order to release/v0.4 November 4, 2026 22:13
@afflom afflom mentioned this pull request Nov 4, 2026

@afflom afflom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bounded refresh confirms this branch now descends from accepted Host c613290. The Json implementation and stdlib_json case are byte-identical to previously reviewed9525f0e6; the latest commit changes only the stdlib lock and the bootstrap/helpdesk stdlib pins. The complete current-base delta isolates19 SL11 source/contract/test/documentation/lock paths. No new JSON implementation or test weakening is established by this head.

The body still describes an older base and historical461-row evidence. Please distinguish those records from the current c613-based preparation. Its disclosed throwaway bypass measured only the later rustc differential/plant portion; it remains neither a committed weakening nor full SL11 acceptance. The committed certified escape_string/write_json/write_json_file packages, recursive stack-bound observations, actual Lean certificate/export comparison and full final gate are still owed.

Please report the current writer state and preserve any active atomic writer's logs/output before further coordination. #393's reviewed repaired carrier is now in its final changed-head CI; reconcile the settled release source before another product/count wave, without guessing combined corpus totals or rerunning unchanged-head CI. This draft remains the existing delivery owner, with #414/#415 source-stack coordination preserved. #276 remains open for its broader compiler/library scope.

humuhumu33 and others added 11 commits November 5, 2026 14:12
…on release/v0.4

SL-11 (#276, #363) on the merged line: `check-production-export --write` adds the
certificates of stdlib/escape_string, write_json and write_json_file (25 stdlib
packages) and moves the rest with the runtime; `LEXLEAN_MEASURE_STACK=all` on
conformance_sl_11 adds the debug bounds of write_json and write_json_file;
`check-golden --write` moves the build oracles of stdlib, bootstrap and
examples/helpdesk. Run on the normative host (WSL Ubuntu, Rust 1.97.1, Lean 4.32.1).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`cargo xtask verify-examples --write` over every example but uor-atlas (whose
whole verify is OOM-killed in a 16 GB WSL; CI holds it), compiler, stdlib,
std-models, std-reasoning and bootstrap. Only stdlib's records changed: the R*
of the Json roots, and the audit names that move with the package set. Every
project verified on the normative host.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…BS-15

The numbers are what each part's count assert reported on the normative host over
the regenerated tree (manifests and packages 283 to 286, programs 200 to 203,
crates 259 to 262, and the vectors each case draws from them). BS-11 and BS-12
passed whole, so the new records moved no mutant draw. The counts asserted after
these first ones are being rerun; any that move follow in another commit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The line took #393 (SM-37, SP-32, SP-33, BS-16) with a compiler-semantics move, so
every lock, record, golden, fixture and package was regenerated there. This merge
takes the line's oracles, records, export and bootstrap counts as they are, keeps
the SL-11 row, module, scenario and changelog bullet, and sets the register to
476. The Json packages' export, stack bounds, build oracles, verify records and
count mirrors regenerate on this tree in the commits that follow.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The merge took the line's tests/production-export wholesale, which is right for the
packages (regenerated here) but dropped the three roots SL-11 registers in
stdlib/roots.json, so the export wrote no escape_string, write_json or
write_json_file package and the SL-11 case found none. Restored from b7ff581.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…se/v0.4 at 55be551

SL-11 (#276, #363) on the merged line: `lexlean lock` moves stdlib's lock (the
consumers' locks stand); `check-production-export --write` adds the certificates
of stdlib/escape_string, write_json and write_json_file (25 stdlib packages) and
moves the rest with the runtime; `LEXLEAN_MEASURE_STACK=all` on conformance_sl_11
confirms the committed debug bounds of write_json and write_json_file;
`check-golden --write` moves the build oracles of stdlib, bootstrap and
examples/helpdesk. Run on the normative host (WSL Ubuntu, Rust 1.97.1, Lean 4.32.1).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>


`cargo xtask verify-examples --write` over every example but uor-atlas (whose
whole verify is OOM-killed in a 16 GB WSL; CI holds it), compiler, stdlib,
std-models, std-reasoning and bootstrap. Only stdlib's records changed: the R*
of the Json roots, and the audit names that move with the package set. Every
project verified on the normative host.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…BS-15

The numbers are what each part's count assert reported on the normative host over
the regenerated tree at 55be551 (manifests and packages 284 to 287, programs 201
to 204, crates 260 to 263, and the vectors each case draws from them). BS-11 and
BS-12 passed whole, so the new records moved no mutant draw. The counts asserted
after these first ones are CI's to report; any that move follow in another commit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The asserts after the corpus counts, as the parts reported them on the normative
host once the first counts were mirrored: BS-05 runs validateCrate 499 times
(211 refused) and correspondCrate 364 (100 refused); BS-06 runs 2,838 vectors, 693
of printCrate over 526 committed distinct crates (65 refused), 2,145 of printExpr.
BS-07 and BS-08 passed whole on the mirrored counts.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Of the 693 printCrate vectors on the Json packages, 584 are of at most 6,000
nodes (583 before), as the part reported once its totals were mirrored. BS-05
passed whole on its mirrored totals.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@humuhumu33
humuhumu33 marked this pull request as ready for review November 6, 2026 21:07
@humuhumu33
humuhumu33 merged commit cb146c5 into release/v0.4 Nov 6, 2026
56 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