{"title": "Exact Codecs",
 "producer":
 ["GENERATED by tools/Drivers/Semantics.lean (make gen-semantics); do not edit",
  "format: effect4-semantics-report v8",
  "command: make gen-semantics",
  "inputs: tools/ProofGraph/Registry.lean, tools/Tools/Semantics.lean, tools/Drivers/Semantics.lean, tools/Tools/SemanticsDisplay.lean, tools/Tools/SemanticsDocument.lean, tools/Tools/Document.lean, tools/Tools/Document/Json.lean, src/Effect4/Laws/Auto/Semantics.lean, Test/Counterexamples/REGISTER.md, docs/core/decisions.md, lean-toolchain"],
 "format": "effect4-document/1",
 "body":
 [{"line":
   [{"text": "Invertible embeddings for JSON and Schema representations. "},
    {"text": "19 claims: "},
    {"text": "19 "},
    {"status": "proved"},
    {"text": "."}],
   "kind": "para"},
  {"title": "Exact codecs and data plane embeddings",
   "kind": "part",
   "key": "about:concept:exact-codecs",
   "body":
   [{"line":
     [{"text":
       "This page explains exact codecs and data plane embeddings in Effect4. It covers how values and types serialize to JSON and Schema representations with bidirectional round-trip laws."}],
     "kind": "para"},
    {"title": "The runtime concept",
     "kind": "part",
     "key": "about:concept:exact-codecs:runtime-concept",
     "body":
     [{"line":
       [{"text":
         "Effect uses Effect Schema to validate, encode, and decode data crossing external boundaries. In Effect rc.112, schemas define transformations between runtime objects and JSON values."}],
       "kind": "para"},
      {"line":
       [{"text":
         "Effect4 formalizes this boundary using bidirectional data plane embeddings in "},
        {"code": "Codec"},
        {"text": " ("},
        {"code": "src/Effect4/Schema/Codec.lean"},
        {"text": ") and "},
        {"code": "Bridge"},
        {"text": " ("},
        {"code": "src/Effect4/Schema/Bridge.lean"},
        {"text": ")."}],
       "kind": "para"},
      {"line":
       [{"text":
         "These embeddings translate values to JSON and types to Schema AST representations."}],
       "kind": "para"}]},
    {"title": "Literature foundations",
     "kind": "part",
     "key": "about:concept:exact-codecs:literature",
     "body":
     [{"line":
       [{"text":
         "The metatheory adapts invertible target syntax descriptions from Rendel and Ostermann (2010). Invertible syntax descriptions unify printers and parsers under partial isomorphisms."}],
       "kind": "para"},
      {"line":
       [{"text":
         "Bidirectional transformations adapt the tree lenses of Foster et al. (2007). Lenses formalize GetPut and PutGet laws between abstract and concrete structures."}],
       "kind": "para"},
      {"line":
       [{"text":
         "Exact embeddings adapt the lawful prisms and profunctor optics of Pickering, Gibbons, and Wu (2017)."}],
       "kind": "para"}]},
    {"title": "What Effect4 keeps and what it cuts",
     "kind": "part",
     "key": "about:concept:exact-codecs:adaptations-and-cuts",
     "body":
     [{"line":
       [{"text":
         "Effect4 defines an exact embedding as a write/read pair satisfying three laws:"}],
       "kind": "para"},
      {"lines":
       [[{"text": "Totality on its domain."}],
        [{"text":
          "Retraction: reading a written image recovers the original element."}],
        [{"text":
          "Exactness: anything that reads successfully is an image modulo a named normaliser."}]],
       "kind": "items"},
      {"line":
       [{"text":
         "Under decisions row 128, Effect4 models two exact embeddings:"}],
       "kind": "para"},
      {"lines":
       [[{"text": "The JSON codec: encodes "},
         {"code": "Val"},
         {"text": " into "},
         {"code": "Json"},
         {"text": " exact modulo key sorting via "},
         {"code": "normJ"},
         {"text": "."}],
        [{"text": "The Schema bridge: converts "},
         {"code": "Ty"},
         {"text": " into "},
         {"code": "Representation"},
         {"text": " exact modulo annotation erasure via "},
         {"code": "normS"},
         {"text": "."}]],
       "kind": "items"},
      {"line":
       [{"text": "Under decisions row 179, "},
        {"code": "normS"},
        {"text": " erases only nine approved annotation keys listed in "},
        {"code": "erasedKeys"},
        {"text": ". Arbitrary custom metadata is not erased."}],
       "kind": "para"},
      {"line":
       [{"text": "Effect4 cuts ambiguous left-biased decoding ("},
        {"code": "E4-SCHEMA-CE-059"},
        {"text":
         "). Overlapping union shapes could defeat unchecked recovery."}],
       "kind": "para"},
      {"line":
       [{"text":
         "The public encoder refuses ambiguous values so that every successful encoding decodes back reliably ("},
        {"code": "decode_of_encode"},
        {"text": ")."}],
       "kind": "para"}]},
    {"title": "How to read the claims",
     "kind": "part",
     "key": "about:concept:exact-codecs:reading-claims",
     "body":
     [{"line":
       [{"text":
         "The claims under this concept state that serialization transformations maintain data fidelity without silent information loss."}],
       "kind": "para"},
      {"line": [{"text": "Key properties to inspect:"}], "kind": "para"},
      {"lines":
       [[{"ref": "claim:decode-iff", "label": "`decode-iff`"},
         {"text": ": JSON decoding is exact modulo key ordering "},
         {"code": "normJ"},
         {"text": "."}],
        [{"ref": "claim:decode-encode", "label": "`decode-encode`"},
         {"text":
          ": Decoding an encoded value recovers the original on codec-admitted values at canonical types."}],
        [{"ref": "claim:of-schema-exact", "label": "`of-schema-exact`"},
         {"text":
          ": Schema representation decoding is exact modulo the nine approved keys "},
         {"code": "normS"},
         {"text": "."}]],
       "kind": "items"},
      {"line":
       [{"text":
         "The table of claims on this page gives each claim's status and its statement."}],
       "kind": "para"}]}]},
  {"rows":
   [[[{"ref": "claim:type-metadata-exact", "label": "type-metadata-exact"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Codegen.Metadata.type_metadata_exact"}]],
    [[{"ref": "claim:decode-iff", "label": "decode-iff"}],
     [{"text": "decidability"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Schema.decode_iff"}]],
    [[{"ref": "claim:decode-encode", "label": "decode-encode"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Schema.decode_encode"}]],
    [[{"ref": "claim:of-schema-exact", "label": "of-schema-exact"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Schema.Bridge.ofSchema_exact"}]],
    [[{"ref": "claim:of-schema-schema", "label": "of-schema-schema"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Schema.Bridge.ofSchema_schema"}]],
    [[{"ref": "claim:collection-term-print-read",
       "label": "collection-term-print-read"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Program.readTerm_printTerm"}]],
    [[{"ref": "claim:record-codec-layout", "label": "record-codec-layout"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Schema.decode_iff"}]],
    [[{"ref": "claim:service-identifier-injective",
       "label": "service-identifier-injective"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Program.keyIdentifier_injective"}]],
    [[{"ref": "claim:error-payload-exact", "label": "error-payload-exact"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Program.errOf_valOfErr"}]],
    [[{"ref": "claim:payload-class-decl-exact",
       "label": "payload-class-decl-exact"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Codegen.admitModule_classDecls"}]],
    [[{"ref": "claim:mask-rows-table-premises",
       "label": "mask-rows-table-premises"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Program.mask_rows_table_premises"}]],
    [[{"ref": "claim:sketch-wire", "label": "sketch-wire"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Program.Sketch.decode_exact"}]],
    [[{"ref": "claim:json-read-exact", "label": "json-read-exact"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Store.Canonical.ofJson_exact"}]],
    [[{"ref": "claim:typed-print-connector", "label": "typed-print-connector"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Program.printTyped_eq_print"}]],
    [[{"ref": "claim:typed-print-erasure", "label": "typed-print-erasure"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Codegen.eraseJoinArgs_printTyped"}]],
    [[{"ref": "claim:typed-print-read", "label": "typed-print-read"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Codegen.readTyped_printTyped"}]],
    [[{"ref": "claim:module-defs-round-trip",
       "label": "module-defs-round-trip"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Program.readModule_printModule_defs"}]],
    [[{"ref": "claim:modeled-codec", "label": "modeled-codec"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Schema.Modeled.codec_roundtrip"}]],
    [[{"ref": "claim:record-field-laws", "label": "record-field-laws"}],
     [{"text": "compatibility"}],
     [{"status": "proved"}],
     [{"code": "Effect4.Schema.FieldRef.frame_laws"}]]],
   "kind": "table",
   "headers": ["Claim", "Role", "Status", "Evidence"]},
  {"title": "type-metadata-exact",
   "kind": "part",
   "key": "claim:type-metadata-exact",
   "body":
   [{"line":
     [{"text":
       "Structural TypeScript metadata retains the exact stored Ty declaration"}],
     "kind": "para"},
    {"line":
     [{"text": "The two directions of the proposed "},
      {"code": "type-metadata-exact"},
      {"text": " claim, with no source restriction."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Codegen.Metadata"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "And\n  (∀ (t : Effect4.Program.Ty),\n    Eq (Effect4.Codegen.Metadata.readTy (Effect4.Codegen.Metadata.writeTy t)) (Option.some t))\n  (∀ (e : TypeScript.Expr) (t : Effect4.Program.Ty),\n    Eq (Effect4.Codegen.Metadata.readTy e) (Option.some t) →\n      Eq (Effect4.Codegen.Metadata.writeTy t) e)"}]},
  {"title": "decode-iff",
   "kind": "part",
   "key": "claim:decode-iff",
   "body":
   [{"line": [{"text": "Exactness of JSON decoding modulo normJ"}],
     "kind": "para"},
    {"line":
     [{"text": "The JSON pair is an exact embedding modulo "},
      {"code": "N_J"},
      {"text": " (decisions row 128; "},
      {"code": "AGENTS.md"},
      {"text": "'s exact embedding with the normaliser "},
      {"code": "Codec.normJ"},
      {"text":
       "): a JSON decodes to a value exactly when it is that value's encoding up to the order of object entries."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Schema.Codec"}], "label": "Module"},
      {"line":
       [{"text": "RendelOstermann2010"},
        {"text": ", "},
        {"text": "audit P32"},
        {"text": " (definitionUsed)"}],
       "label": "Literature"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {t : Effect4.Program.Ty} {j : Effect4.Json} {v : Effect4.Machine.Val},\n  Iff (Eq (Effect4.Schema.decode t j) (Option.some v))\n    (Exists fun j' =>\n      And (Eq (Effect4.Schema.encode t v) (Option.some j'))\n        (Eq (Effect4.Schema.Codec.normJ j') (Effect4.Schema.Codec.normJ j)))"}]},
  {"title": "decode-encode",
   "kind": "part",
   "key": "claim:decode-encode",
   "body":
   [{"line": [{"text": "Retraction of JSON encoding on canonical types"}],
     "kind": "para"},
    {"line":
     [{"text":
       "S-3 round trip without an arbitrary default JSON inhabitant or a failing "},
      {"code": "get!"},
      {"text": "."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Schema.Codec"}], "label": "Module"},
      {"line":
       [{"text": "FosterEtAl2007"},
        {"text": ", "},
        {"text": "audit P11"},
        {"text": " (adaptedResult)"}],
       "label": "Literature"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {t : Effect4.Program.CTy} {v : Effect4.Machine.Val},\n  Eq (Effect4.Program.Val.hasTy v t.toRaw) Bool.true →\n    Eq (t.toRaw.isCodecValue v) Bool.true →\n      Eq ((Effect4.Schema.encode t.toRaw v).bind (Effect4.Schema.decode t.toRaw)) (Option.some v)"}]},
  {"title": "of-schema-exact",
   "kind": "part",
   "key": "claim:of-schema-exact",
   "body":
   [{"line": [{"text": "Exactness of Schema reader modulo normS"}],
     "kind": "para"},
    {"line":
     [{"text": "Exactness of the reader, modulo "},
      {"code": "N_S"},
      {"text": " (decisions row 128): a representation "},
      {"code": "ofSchema"},
      {"text":
       " reads is the read type's schema up to the annotation entries that change no decoding. By "},
      {"code": "fun_induction ofSchema"},
      {"text":
       ": one case per arm and branch of the reader, the refusing ones closed by "},
      {"code": "nomatch"},
      {"text": "."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Schema.Bridge"}], "label": "Module"},
      {"line":
       [{"text": "RendelOstermann2010"},
        {"text": ", "},
        {"text": "audit P32"},
        {"text": " (adaptedResult)"}],
       "label": "Literature"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ (r : Effect4.Representation) (t : Effect4.Program.Ty),\n  Eq (Effect4.Schema.Bridge.ofSchema r) (Option.some t) →\n    Eq (Effect4.Schema.Bridge.normS r) (Effect4.Schema.Bridge.schema t)"}]},
  {"title": "of-schema-schema",
   "kind": "part",
   "key": "claim:of-schema-schema",
   "body":
   [{"line":
     [{"text": "Retraction of Schema generation on reserved-free types"}],
     "kind": "para"},
    {"line":
     [{"text":
       "Raw Schema retraction on the closed exact profile. The profile excludes unsupported forms, nonstring map keys, two-item tuples, and the reserved handle id."}],
     "kind": "para"},
    {"rows": [{"line": [{"code": "Effect4.Schema.Bridge"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ (t : Effect4.Program.Ty),\n  Eq t.closed Bool.true →\n    Eq (Effect4.Schema.Bridge.reservedFree t) Bool.true →\n      Eq (Effect4.Schema.Bridge.ofSchema (Effect4.Schema.Bridge.schema t)) (Option.some t)"}]},
  {"title": "collection-term-print-read",
   "kind": "part",
   "key": "claim:collection-term-print-read",
   "body":
   [{"line":
     [{"text":
       "Every scoped term reconstructs after structural printing, including records, payload class constructions under classes that cover them (decisions row 120), and every static tuple index"}],
     "kind": "para"},
    {"line":
     [{"text": "The term round trip ("},
      {"code": "collection-term-print-read"},
      {"text":
       "): a scoped term whose class constructions the classes cover reads back from its printing. Since decisions row 120, part E2, a class construction prints as "},
      {"code": "new Tag({ … })"},
      {"text": " and reads back from the module's classes, with "},
      {"code": "_tag"},
      {"text": " restored first ("},
      {"code": "Classes.classTag?"},
      {"text": "); placed at R8 ("},
      {"code": "translation-simulation"},
      {"text": ") as a step of "},
      {"code": "read_print"},
      {"text": ", and at R3 as the record terms' printed form."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Codegen.ReadLeaf"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {classes : Effect4.Codegen.Classes.Classes} {n : Nat} (t : Effect4.Program.Term),\n  Eq (Effect4.Program.Term.scoped n t) Bool.true →\n    Eq (Effect4.Program.Term.covers classes t) Bool.true →\n      Eq t.unannotated Bool.true →\n        Eq (Effect4.Program.readTerm classes n (Effect4.Program.printTerm n t)) (Except.ok t)"}]},
  {"title": "record-codec-layout",
   "kind": "part",
   "key": "claim:record-codec-layout",
   "body":
   [{"line":
     [{"text":
       "Record JSON decoding is exact under normJ; named record values retain optional presence"}],
     "kind": "para"},
    {"line":
     [{"text": "The JSON pair is an exact embedding modulo "},
      {"code": "N_J"},
      {"text": " (decisions row 128; "},
      {"code": "AGENTS.md"},
      {"text": "'s exact embedding with the normaliser "},
      {"code": "Codec.normJ"},
      {"text":
       "): a JSON decodes to a value exactly when it is that value's encoding up to the order of object entries."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Schema.Codec"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {t : Effect4.Program.Ty} {j : Effect4.Json} {v : Effect4.Machine.Val},\n  Iff (Eq (Effect4.Schema.decode t j) (Option.some v))\n    (Exists fun j' =>\n      And (Eq (Effect4.Schema.encode t v) (Option.some j'))\n        (Eq (Effect4.Schema.Codec.normJ j') (Effect4.Schema.Codec.normJ j)))"}]},
  {"title": "service-identifier-injective",
   "kind": "part",
   "key": "claim:service-identifier-injective",
   "body":
   [{"line":
     [{"text":
       "At one signature's scope key, distinct service keys print distinct target Identifier types"}],
     "kind": "para"},
    {"line":
     [{"text":
       "At one fixed signature's scope identity, different keys have different target Identifier syntax, independently of their carriers. This is a syntax theorem; the pinned TypeScript assignment controls separately test the target interpretation."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Codegen.ReadLeaf"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ (scopeKey : Effect4.ServiceKey), Function.Injective (Effect4.Program.keyIdentifier scopeKey)"}]},
  {"title": "error-payload-exact",
   "kind": "part",
   "key": "claim:error-payload-exact",
   "body":
   [{"line":
     [{"text":
       "A typed failure's record payload reads back exactly through the error image: errOf inverts valOfErr at every represented error, the handle-free record frame included (decisions row 120)"}],
     "kind": "para"},
    {"line":
     [{"text":
       "A value read out of the error alphabet rebuilds the same error ("},
      {"code": "errOf"},
      {"text": " on the left inverse of "},
      {"code": "valOfErr"},
      {"text": "). "},
      {"code": "boom"},
      {"text":
       " has no image, so it is excluded by the hypothesis rather than by a side condition. A payload rebuilds through the last arm ("},
      {"code": "errOf_payload"},
      {"text": ")."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Program.Admit"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ (e : Effect4.Machine.Err) (v : Effect4.Machine.Val),\n  Eq (Effect4.Program.valOfErr e) (Option.some v) → Eq (Effect4.Program.errOf v) e"}]},
  {"title": "payload-class-decl-exact",
   "kind": "part",
   "key": "claim:payload-class-decl-exact",
   "body":
   [{"line":
     [{"text":
       "An admitted module's payload class declarations are exactly the ones the printer writes for the program it reads to (decisions row 120, part E2)"}],
     "kind": "para"},
    {"line":
     [{"text":
       "The envelope admits exactly the printed class declarations (decisions row 120, part E2): an admitted module's leading class declarations are the ones the printer writes for the program it reads to ("},
      {"code": "ClassTable.moduleClasses"},
      {"text": "), in order. Concept "},
      {"code": "exact-codecs"},
      {"text": ", claim "},
      {"code": "payload-class-decl-exact"},
      {"text": " (R3); with "},
      {"code": "ModuleEmission.admit"},
      {"text": ", the class section's exact embedding at the boundary."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Codegen.Admit"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {table : Effect4.Program.RowTable} {name : String}\n  {allowed : List Effect4.Codegen.Bindings.Origin} {ambient : List TypeScript.Import}\n  {module : TypeScript.Module} {r : Effect4.Codegen.ModuleReading table name allowed ambient},\n  Eq (Effect4.Codegen.admitModule name module table allowed ambient) (Except.ok r) →\n    Eq (Effect4.Program.splitClasses module.decls).fst r.classDecls"}]},
  {"title": "mask-rows-table-premises",
   "kind": "part",
   "key": "claim:mask-rows-table-premises",
   "body":
   [{"line":
     [{"text":
       "The mask's two printed rows, the getter as the mask that answers its own restore and a restore site as pipe(E, saved), have two reserved heads and keep the row table's nine decided premises at the extended table; a restore site is readable exactly when its saved term is a readable leaf and its body is readable; read_print and read_exact keep their statements (decisions row 245; program syntax only)"}],
     "kind": "para"},
    {"line":
     [{"text": "The mask's two rows keep the table's premises (the claim "},
      {"code": "mask-rows-table-premises"},
      {"text": "; concept "},
      {"code": "exact-codecs"},
      {"text": ", requirement R8; decisions row 245)."}],
     "kind": "para"},
    {"line":
     [{"text": "Reach: program syntax. The table is the one table of "},
      {"code": "Codegen/Templates.lean"},
      {"text":
       ", and each premise is decided again by the kernel at the extended table. It does not establish typing: a restore site of an ill-typed saved term reads back as well. It establishes no behaviour of a target. An annotated position prints and is not read, as before: "},
      {"code": "Readable"},
      {"text":
       " excludes it. Its consumers are the checked module production and reading, through "},
      {"code": "read_print"},
      {"text": " and "},
      {"code": "read_exact"},
      {"text": "."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Codegen.Mask"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body": "Effect4.Program.MaskRowsPremises"}]},
  {"title": "sketch-wire",
   "kind": "part",
   "key": "claim:sketch-wire",
   "body":
   [{"line":
     [{"text":
       "A sketch's bytes are its program's canonical bytes and its hole table's (Sketch.encode): a well-formed sketch reads back (Sketch.decode_encode), and whatever reads was that sketch's bytes, well-formed (Sketch.decode_exact); the query tool takes a hole table with a request and gives the grown one with an omission, so the sketch it answers can be sent back; nothing of a stored sketch's renumbering when its application gains a row (decisions row 305, point 3)"}],
     "kind": "para"},
    {"line":
     [{"text":
       "Exactness: whatever reads as a sketch was that sketch's bytes, and its value trees are well-formed. The pointer of "},
      {"code": "sketch-wire"},
      {"text": "."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Program.SketchWire"}],
       "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {b : Prod Effect4.Store.Bytes Effect4.Store.Bytes} {s : Effect4.Program.Sketch},\n  Eq (Effect4.Program.Sketch.decode b) (Option.some s) →\n    And (Eq b s.encode)\n      (And (Effect4.Store.ProgramGen.EffC.instCanonicalEff.toVal s.program).WF\n        (Effect4.Store.instCanonicalList.toVal s.holes).WF)"}]},
  {"title": "json-read-exact",
   "kind": "part",
   "key": "claim:json-read-exact",
   "body":
   [{"line":
     [{"text":
       "A canonical carrier read from JSON is the carrier whose canonical print that JSON is (Canonical.ofJson_exact): the reader takes only the canonical print, a number as the binary64 of a natural, hex exact, fields in the shape's order, a case's name checked against its tag; JSON whose objects come in any order reads once ordered by the shape (Canonical.ofJsonAnyOrder), the named normaliser; nothing of the round trip, which needs every natural at most 2^53 and no option holding a shape that prints null (the agent's schema form; decisions row 334)"}],
     "kind": "para"},
    {"line":
     [{"text":
       "A carrier read from JSON is the carrier whose canonical print that JSON is. The pointer of "},
      {"code": "json-read-exact"},
      {"text": "."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Store.ShapeRead"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {α : Type} [inst : Effect4.Store.Canonical α] {j : Effect4.Json} {a : α},\n  Eq (Effect4.Store.Canonical.ofJson j) (Option.some a) → Eq (Effect4.Store.Canonical.print a) j"}]},
  {"title": "typed-print-connector",
   "kind": "part",
   "key": "claim:typed-print-connector",
   "body":
   [{"line":
     [{"text":
       "The typed print, the table-driven print with each node's address, writes a call's type arguments where the row check joins the call's request, in the order of the row's variables, and the type arguments of an approved eliminator site where the site's checked context needs them; a program with no such row and no such site (NoJoin) has the typed print that is its print, byte for byte (printTyped_eq_print); it does not say that tsgo accepts a printed call (decisions row 325)"}],
     "kind": "para"},
    {"line":
     [{"text":
       "Without a row join annotation, the typed print is the ordinary print. This remains the pointer of "},
      {"code": "typed-print-connector"},
      {"text": ", exact-codecs, R8. The "},
      {"code": "NoJoin"},
      {"text":
       " premise states absence at every checked address. It makes no TypeScript typing or execution claim."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Codegen.PrintTyped"}],
       "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {Op : Type} (s : Effect4.Program.Signature Op) (env0 : Effect4.Program.TyEnv)\n  (p : Effect4.Program.Eff Op),\n  Effect4.Program.NoJoin s env0 p →\n    Eq (Effect4.Program.printTyped s env0 p) (Effect4.Program.print s (List.length env0) p)"}]},
  {"title": "typed-print-erasure",
   "kind": "part",
   "key": "claim:typed-print-erasure",
   "body":
   [{"line":
     [{"text":
       "A successful typed print erases to the print: at a readable program and a lawful spelling, the named erasure of the inserted type arguments gives the print of the program, byte for byte; the erasure keeps an operation's own arguments and the stored type annotations; it does not say that tsgo accepts the typed print, or anything of its run (decisions row 325; slice P2b)"}],
     "kind": "para"},
    {"line":
     [{"text":
       "Every successful public typed print erases to the existing ordinary print. The exact old readable and spelling premises remain visible (exact-codecs, R8)."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Codegen.PrintTyped"}],
       "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {Op : Type} {classes : Effect4.Codegen.Classes.Classes} {sig : Effect4.Program.Signature Op}\n  {spell : String → List Effect4.Program.RowArg → Option Op},\n  Effect4.Program.LawfulSpelling sig spell →\n    ∀ {env0 : Effect4.Program.TyEnv} {e : Effect4.Program.Eff Op},\n      Eq (Effect4.Program.Readable classes sig (List.length env0) e) Bool.true →\n        ∀ {x : TypeScript.Expr},\n          Eq (Effect4.Program.printTyped sig env0 e) (Except.ok x) →\n            Eq (Effect4.Program.print sig (List.length env0) e)\n              (Except.ok (Effect4.Codegen.eraseJoinArgs classes sig spell (List.length env0) x))"}]},
  {"title": "typed-print-read",
   "kind": "part",
   "key": "claim:typed-print-read",
   "body":
   [{"line":
     [{"text":
       "The reader reads a successful typed print back to its program after the named erasure, at a readable program and a lawful spelling, by the existing read_print; what the typed reader accepts is the erasure of a print (readTyped_exact); the raw reader still refuses an inserted argument before the erasure, and no equality of raw foreign spellings follows (decisions row 325; slice P3)"}],
     "kind": "para"},
    {"line":
     [{"text":
       "The existing reader reads every successful public typed print after named erasure. The theorem carries the existing read_print fragment (exact-codecs, R8)."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Codegen.PrintTyped"}],
       "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {Op : Type} {classes : Effect4.Codegen.Classes.Classes} {sig : Effect4.Program.Signature Op}\n  {spell : String → List Effect4.Program.RowArg → Option Op},\n  Effect4.Program.LawfulSpelling sig spell →\n    ∀ {env0 : Effect4.Program.TyEnv} {e : Effect4.Program.Eff Op},\n      Eq (Effect4.Program.Readable classes sig (List.length env0) e) Bool.true →\n        ∀ {x : TypeScript.Expr},\n          Eq (Effect4.Program.printTyped sig env0 e) (Except.ok x) →\n            Eq (Effect4.Codegen.readTyped classes sig spell (List.length env0) x) (Except.ok e)"}]},
  {"title": "module-defs-round-trip",
   "kind": "part",
   "key": "claim:module-defs-round-trip",
   "body":
   [{"line":
     [{"text":
       "A module with a definition block reads back: the module printer prints each definition as a constant before the layers, an arrow from its request and its parameters, each a function named by its declaration (slice HO-3a), with its declared result type around a suspension of its body, an invocation as the definition's name applied to its request, and an invocation with programs as that name applied to the request and to each program as an arrow of the binder due at the call (slice HO-3b, read back under the block's invocation laws, LawfulInvokes); the block's module layers print after the services as constants named by their paths (printModuleLayers), and a reference to one prints as that name; when each declaration has readable columns, an empty requirement row and a name with no layer path, each body and each of its own layers at the signature and spelling map its parameters extend (LawfulSpelling.withParams; a body's own hoisted layers print as constants at the top of its suspension, row 341, step 3b), the main program, each layer and each module layer read back at the block's signature through the block's spelling map, and each module layer's name decodes to its path, the module reads back to the program, its module layers rebuilt in order (readModule_printModule_defs); the block's spelling map is lawful under the signature's invocation laws and readable names (LawfulSpelling.withDefs), which the native signature and the printer's name check give (nativeCalls, defsNamed_of_fault), so the program interface's module round trip holds for a program with a block (Api.printModule_roundTrip); the printer refuses an empty block and a reference out of its scope (Eff.inScope), and a requirement row other than never is printed and not read; the block's services, declared by its definitions' roles, print after the definitions as an Effect service's key and layer each (printServices) and give the roles back from the layers (roleOf), when serviceFault finds no fault (printServices_ok, restoreRoles); it does not say that tsgo accepts the module or how rc.112 runs it (decisions rows 328, 338, 339 and 341, G6; slices PROC-3 and CO-6b)"}],
     "kind": "para"},
    {"line":
     [{"text":
       "G6: the round trip of a module with a definition block (decisions rows 328 and 341). The module printer prints a block's definitions as constants, each body's own hoisted layers as constants at the top of its suspension (decisions row 341, step 3), then the block's services' keys and layers (decisions rows 338 and 339), then its module layers, each named by its path (step 2), before the hoisted layers no body took and the main declaration ("},
      {"code": "printModule"},
      {"text": "). When each declaration is readable ("},
      {"code": "DefDecl.readable"},
      {"text":
       ": readable columns, an empty requirement row, a name with no layer path); each body and each of its own layers read back from their printing at the signature its parameters extend ("},
      {"code": "bodyDeclOf"},
      {"text":
       "); the main program, each module layer and each other hoisted layer read back at the block's signature through the block's spelling map ("},
      {"code": "defsSpell"},
      {"text":
       "); and the layers' names decode, the module reads back to the program, with each definition's role given back by the services' layers ("},
      {"code": "roleOf"},
      {"text": ", "},
      {"code": "restoreRoles"},
      {"text": ") and the module's layers by their paths ("},
      {"code": "moduleLayersOf"},
      {"text": "). No hoisted layer stands in the module ("},
      {"code": "Eff.hoistAll_outside"},
      {"text": "). The premises concern the pieces, as "},
      {"code": "readModule_printModule"},
      {"text": "'s do, and they are stated of any reader."}],
     "kind": "para"},
    {"line":
     [{"text":
       "Restated for step 3: each body reads back itself (it was its suspension), and the hoisted layers' premise is split by the scope that prints them ("},
      {"code": "localsReadable"},
      {"text": ", "},
      {"code": "layersReadable"},
      {"text": ")."}],
     "kind": "para"},
    {"line":
     [{"text": "Placement: concept "},
      {"code": "exact-codecs"},
      {"text": ", claim "},
      {"code": "module-defs-round-trip"},
      {"text":
       ", requirement R8. Consumers: the module round trip of the readable domain ("},
      {"code": "readModule_printModule_readable"},
      {"text": ") and, through it, "},
      {"code": "ModuleEmission.readModule"},
      {"text":
       ". It is a structural equation: it does not say that tsgo accepts the module or how rc.112 runs it."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Codegen.Module"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {Op : Type} {classes : Effect4.Codegen.Classes.Classes} {sig : Effect4.Program.Signature Op}\n  {spell : String → List Effect4.Program.RowArg → Option Op} {call param : Nat → Op}\n  {root main body : Effect4.Program.Eff Op} {defs : List Effect4.Program.DefDecl}\n  {bodies : Effect4.Program.Effs Op} {layers : Effect4.Program.LayerTerms Op}\n  {history : List (Prod (List Nat) (Effect4.Program.LayerTerm Op))},\n  Eq root.hoistAll (Except.ok { fst := main, snd := history }) →\n    Eq main.block?\n        (Option.some\n          { fst := defs, snd := { fst := bodies, snd := { fst := body, snd := layers } } }) →\n      ∀ {classDecls : List TypeScript.ClassDecl},\n        Eq (Effect4.Codegen.Classes.readClassDecls classDecls) (Option.some classes) →\n          (∀ (d : Effect4.Program.DefDecl),\n              List.instMembership.mem defs d → Eq d.readable Bool.true) →\n            (∀ (p : Prod Effect4.Program.DefDecl (Effect4.Program.Eff Op)),\n                List.instMembership.mem (defs.zip bodies.toList) p →\n                  Effect4.Program.ReadsBack classes ((sig.withDefs defs).withParams p.fst.params)\n                    (Effect4.Program.paramsSpell param p.fst.params\n                      (Effect4.Program.defsSpell call defs spell))\n                    1 p.snd) →\n              Effect4.Program.ReadsBack classes (sig.withDefs defs)\n                  (Effect4.Program.defsSpell call defs spell) 0 body →\n                (∀ (l : Effect4.Program.LayerTerm Op),\n                    List.instMembership.mem layers.toList l →\n                      Effect4.Program.LayerTerm.ReadsBack classes (sig.withDefs defs)\n                        (Effect4.Program.defsSpell call defs spell) l) →\n                  (∀ (k : Nat),\n                      instLTNat.lt k layers.toList.length →\n                        Eq\n                          (Effect4.Program.LayerTerm.readRefName\n                            (Effect4.Program.LayerTerm.refName (Effect4.Program.Path.layerPath k)))\n                          (Option.some (Effect4.Program.Path.layerPath k))) →\n                    (∀ (entry : Prod (List Nat) (Effect4.Program.LayerTerm Op)),\n                        List.instMembership.mem history entry →\n                          ∀ (d : Effect4.Program.DefDecl),\n                            Eq (Effect4.Program.bodyDeclOf defs entry.fst) (Option.some d) →\n                              Effect4.Program.LayerTerm.ReadsBack classes\n                                ((sig.withDefs defs).withParams d.params)\n                                (Effect4.Program.paramsSpell param d.params\n                                  (Effect4.Program.defsSpell call defs spell))\n                                entry.snd) →\n                      (∀ (entry : Prod (List Nat) (Effect4.Program.LayerTerm Op)),\n                          List.instMembership.mem history entry →\n                            Eq (Effect4.Program.bodyDeclOf defs entry.fst) Option.none →\n                              Effect4.Program.LayerTerm.ReadsBack classes (sig.withDefs defs)\n                                (Effect4.Program.defsSpell call defs spell) entry.snd) →\n                        (∀ (entry : Prod (List Nat) (Effect4.Program.LayerTerm Op)),\n                            List.instMembership.mem history entry →\n                              Eq\n                                (Effect4.Program.LayerTerm.readRefName\n                                  (Effect4.Program.LayerTerm.refName entry.fst))\n                                (Option.some entry.fst)) →\n                          ∀ {name : String} {ty : Effect4.Program.EffTy}\n                            {decls : List TypeScript.ConstDecl},\n                            Eq (Effect4.Program.printModule sig name ty root) (Except.ok decls) →\n                              Eq\n                                (Effect4.Program.readModule sig spell call param\n                                  (instHAppendOfAppend.hAppend\n                                    (List.map TypeScript.Decl.classDecl classDecls)\n                                    (List.map TypeScript.Decl.const decls)))\n                                (Except.ok root)"}]},
  {"title": "modeled-codec",
   "kind": "part",
   "key": "claim:modeled-codec",
   "body":
   [{"line":
     [{"text":
       "A modeled value survives JSON and back at the normal form of its type, under codec admission at the value (Ty.isCodecValue): decoding its encoding and reading the value back answers the value; admission stays a premise, since a natural above 2^53 inhabits nat and has no exact JSON image; no TypeScript codec and no target execution (decisions row 330, slice L1)"}],
     "kind": "para"},
    {"line":
     [{"text": "The JSON round trip of a modeled value (claim "},
      {"code": "modeled-codec"},
      {"text": "), at the normal form of its type. Membership comes from "},
      {"code": "Modeled.member"},
      {"text": " and "},
      {"code": "hasTy_normalize"},
      {"text":
       ". Codec admission stays a premise: it is value-specific, and a natural above 2^53 has no exact JSON image."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Schema.Modeled"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ (α : Type) [m : Effect4.Schema.Modeled α] (a : α),\n  Eq\n      ((Effect4.Program.CTy.ofRaw (m.ty α)).toRaw.isCodecValue\n        ((Effect4.Schema.Modeled.image α).toVal a))\n      Bool.true →\n    Eq\n      (((Effect4.Schema.encode (Effect4.Program.CTy.ofRaw (m.ty α)).toRaw\n                ((Effect4.Schema.Modeled.image α).toVal a)).bind\n            (Effect4.Schema.decode (Effect4.Program.CTy.ofRaw (m.ty α)).toRaw)).bind\n        (Effect4.Schema.Modeled.image α).ofVal)\n      (Option.some a)"}]},
  {"title": "record-field-laws",
   "kind": "part",
   "key": "claim:record-field-laws",
   "body":
   [{"line":
     [{"text":
       "A field reference is a lens on the record frame: for a record with ascending names, at every identity context, the machine's read at the reference's name reads the field's encoding, and its overwrite at that name writes the record the reference's write gives (FieldRef.frame_laws); on carriers the reference is a lawful lens whose writes at two positions commute; nothing of an optional field (decisions row 330, slice L2)"}],
     "kind": "para"},
    {"line":
     [{"text": "The record frame's field laws (claim "},
      {"code": "record-field-laws"},
      {"text":
       "): for a record with ascending names, the machine's read at a reference's name reads the field's encoding, and its overwrite at that name writes the record that the reference's write gives."}],
     "kind": "para"},
    {"rows":
     [{"line": [{"code": "Effect4.Laws.Schema.FieldRef"}], "label": "Module"}],
     "kind": "fields"},
    {"language": "lean",
     "kind": "code",
     "body":
     "∀ {L : Effect4.Schema.Model.Leaves} {fs : List (Prod String (Prod Bool Effect4.Program.Ty))}\n  {t : Effect4.Program.Ty},\n  Effect4.Field.Ascending Effect4.Field.bytesKey fs →\n    ∀ (f : Effect4.Schema.FieldRef fs t)\n      (x : Effect4.Schema.Model.CarrierAt L (Effect4.Program.Ty.record fs))\n      (v : Effect4.Schema.Model.CarrierAt L t),\n      And\n        (Eq\n          (Effect4.Machine.Record.read Bool.false\n            ((Effect4.Schema.Model.imageAt L (Effect4.Program.Ty.record fs)).toVal x) f.name)\n          (Option.some ((Effect4.Schema.Model.imageAt L t).toVal (f.get x))))\n        (Eq\n          (Effect4.Machine.Record.set\n            ((Effect4.Schema.Model.imageAt L (Effect4.Program.Ty.record fs)).toVal x) f.name\n            ((Effect4.Schema.Model.imageAt L t).toVal v))\n          (Option.some\n            ((Effect4.Schema.Model.imageAt L (Effect4.Program.Ty.record fs)).toVal (f.set x v))))"}]}]}
