Skip to content

Prototype JSON Schema extensibility ($defs naming, custom wrapper x-* hooks, integer width bounds, title/examples) #100

Done

Description

@clockblocker

Question

What clean, opt-in JSON Schema extensibility hooks let C++20 structs emit production-grade Draft 2020-12 schemas ($defs naming, custom wrapper x-* annotations, integer width bounds, title/examples, and tuple-array bounds) without manual post-processors?

Evidence & Context

  • Parent map: Map (Lane 4): Schema & Contract Fidelity
  • ccache#2: Mangled $defs names (util__Args__ResponseFileFormat), custom ConfigOption wrapper losing x-env-var / x-aliases metadata, and bare "integer" without integer width bounds (cf. upstream #683).
  • osmium-tool#3: Mangled $defs names (osmium_export__ExportConfig), missing title / examples annotations, and missing tuple-array minItems/maxItems/prefixItems bounds.

Prototype & Measurement Plan

  • Prototype on: showcase/all-lanes — design and implement composable schema hooks for $defs naming, wrapper x-* metadata emission, integer width bounds, and title/examples/tuple bounds.
  • Measure against real Showcase Migrations: Validate in ccache#2 and osmium-tool#3 by removing schema post-processing hacks and verifying clean Draft 2020-12 schema output.
  • Judges & landing: Run Judges (gemini-4-neon + claude-opus-5-5 high via antigravity delegates) on the prototype diff and measurements; if green, hand to coordinator to land on showcase/all-lanes.

Activity

  1. added
    wayfinder:prototype
    on Nov 27, 2026
  2. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Upstream & Showcase Deltas (osmium-tool#3, solidity#3):

    • Upstream signals:
    • Additional concrete requirements (osmium-tool#3, solidity#3):
      • Explicit $defs naming hook such as rfl::SchemaName<"..."> to replace mangled C++ names.
      • Omit empty "required": [] arrays when an object has no required properties.
      • Per-struct DefaultIfMissing control so individual structs in a schema graph can opt in without forcing global processor behavior across the whole root type.
  3. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Delta from clockblocker/slang-server#1 (bf857f4):

    • to_schema<T, rfl::DefaultIfMissing> cleanly deleted slang-server's 30-line addDefaults tree-walker (exact top-level parity + fixed 3 missed nested $defs defaults), but grew bin/gen_config_schema by +23.1% (1,446,752 B → 1,781,456 B) via per-field to_generic instantiation across $defs (tracked for profiling/reduction in #90/#91).
    • Boolean "default"-before-"type" keyword ordering bug filed separately as direct ready-for-agent bugfix: #115.
  4. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Landed on showcase/all-lanes at b73c8aea (dual-Judge approved by claude-opus-5-5 high + gemini-4-neon high; 467/467 targets 0 warnings, 1,129/1,129 CTests).

    • Added include/rfl/SchemaExt.hpp and wired Draft 2020-12 JSON Schema extensibility across NamedTupleParser, Parser_default, ParserBasicType, make_type_name, json/schema/Type.hpp, and json/to_schema:
      1. $defs naming overrides via rfl::SchemaName<T> and rfl::Metadata<T>::schema_name.
      2. Custom wrapper hooks via rfl::SchemaExtension<T> (both $defs and inline_schema = true) and arbitrary x-* extensions via rfl::ExtraFields<rfl::Generic>.
      3. title, examples, and x-* annotations via rfl::Metadata<T> (struct-level, FieldMeta::title, and field_annotations()).
      4. Opt-in rfl::IntegerBounds emitting exact 8..64-bit signed/unsigned minimum/maximum bounds (gated to non-schemaful backends, preserved under rfl::Validator via allOf).
      5. Opt-in rfl::TupleBounds (minItems/maxItems) and rfl::OmitEmptyRequired (omitting "required": []).
      6. Per-struct rfl::DefaultIfMissingFor<T> / rfl::Metadata<T>::default_if_missing (OR-combined, matching read + schema requiredness including non-writable fields).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wayfinder:prototype

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions