Repository navigation
Backlog
Labels
enhancementNew feature or requestknown-downstream-workaroundsDownstream consumer pain or workaround observed in real-world OSS reposneeds-triageMaintainer needs to evaluate this issue
Description
Part of #138
Popularity: 4/7 corpus consumers (cuda-quantum, moqx, wolf, slang-server)
Problem
Two tightly coupled ergonomic gaps around defaults and intrusive field wrappers appear across four independent production consumers:
rfl::DefaultIfMissingis all-or-nothing across an entire deserialized object graph and requires every struct in the tree to be default-constructible (auto t = T{};). Enabling it silently defaults schema-required fields (even forcing dummy defaults on requiredTaggedUnionfields) and erases field presence (preventing partial HTTP PATCH updates or layered config merging). Conversely, omitting it forces consumers to wrap every optional field inrfl::DefaultVal<T>or maintain shadowParsed*/Partial*structs.- Intrusive metadata/field wrappers (
rfl::Description,rfl::Deprecated,rfl::Rename,rfl::DefaultVal,rfl::Skip) alter the field's C++ type rather than attaching out-of-band traits. Consumers must either accept pervasive.value()/.value().value()/.value().value_or(...)double-unwrapping across the entire codebase, or quarantinereflect-cppbehind a full parallel shadow-struct hierarchy guarded by manual field-count driftstatic_asserts.
Observed Downstream Workarounds
NVIDIA/cuda-quantum (90e4aa08)
cudaq/lib/Target/Yaml/v1/TargetConfigV1.h#L20-L94andcudaq/lib/Target/Yaml/v2/TargetConfigV2.h#L42-L118: dozens ofrfl::DefaultVal<...>wrappers mixed with plain required fields (name,description,key,optionFlags), plusrfl::Rename<"default", rfl::DefaultVal<bool>> isDefault;(lines 79 / 63).cudaq/lib/Target/Yaml/CanonicalConversion.h#L115: double.value().value()unwrap onRename<..., DefaultVal<bool>>:outEntry.Default = entry.isDefault.value().value();
cudaq/lib/Target/Yaml/v2/ProfileYaml.h#L16-L22: project-localProfileYaml<P>shadow-struct trait explicitly avoidingrfl::Reflector<P>so public profile types carry noreflect-cppdependency.- Shadow
Optionsstructs with duplicated default values and manual field-count drift assertions in:cudaq/lib/Target/Yaml/v2/QuakeMappedProfileYaml.h#L21-L33cudaq/lib/Target/Yaml/v2/QuakeUnmappedProfileYaml.h#L58-L77cudaq/lib/Target/Yaml/v2/QuakeReferenceSemanticsProfileYaml.h#L39-L54
// Checks that the options and the profile have the same number of fields, // so that a profile field without a YAML option fails the build. static_assert(rfl::named_tuple_t<Yaml::Options>::size() == rfl::named_tuple_t<QuakeUnmappedProfile>::size());
openmoq/moqx (60bab7f13925acbaf578670223e660d71e891547)
- Wrapper double-unwrap tax (
rfl::Description<"...", std::optional<T>>):src/config/loader/ParsedConfig.h#L20-L24:// Note: fields wrapped in rfl::Description<"...", T> expose a .value() accessor // that unwraps the Description wrapper — this is NOT std::optional::value(). // For optional fields the type is rfl::Description<"...", std::optional<T>>, // so .value() returns the std::optional, and a second .value() or // .value_or() unwraps the optional itself.
docs/dev/config.md#L62: explicitly warns contributors about two-level.value().value()/.value().value_or()unwrapping.- Across
src/config/ConfigResolver.cppalone there are 333.value()calls and 46.value().value_or(...)double-unwraps (plus 75.value()calls intest/config/LoaderTest.cpp#L143-L144likel.tls.value().cert_file.value().value()).
- Full shadow struct hierarchy (
ParsedConfig.hvsConfig.h) & quarantine ofreflect-cpp:CMakeLists.txt#L506-L523: splitsmoqx_config(header-only, norfldependency) frommoqx_config_loader(pulls inreflectcpp/yaml-cpp).src/config/loader/ParsedConfig.h(748 lines) mirrorssrc/config/Config.h(339 lines) becauserfl::Descriptionwrappers, schema annotations, and YAML-facing optionals cannot live on the domain structs without polluting every consumer with wrapper types andreflect-cppheaders (docs/dev/config.md#L18-L20).
- 27
rfl::internal::num_fieldsdrift-guardstatic_asserts + post-v0.22.0 internal-header break:- Because
moqx_configstaysrfl-free (and needs redaction of secrets forGET /config),moqxmaintains a 446-line hand-written walker (src/config/ConfigSerializer.h) guarded by 27static_assert(rfl::internal::num_fields<...> == N)assertions intest/config/ConfigSerializerTest.cpp#L14-L130:#include <rfl/internal/num_fields.hpp> // Drift guard: rfl reflects the field count of each resolved Config struct. If // you add or remove a field in Config.h, the matching assert fails and you must // bump the count *and* update serializeConfig() in ConfigSerializer.h. ... static_assert(rfl::internal::num_fields<Config> == 10, "Config changed — update serializeConfig()");
- Note: even though
docs/dev/config.md#L110saysrfl::num_fields, the code includes<rfl/internal/num_fields.hpp>. In newerreflect-cppcommits (C++26 reflection refactor, upstream PR#713),include/rfl/internal/num_fields.hppwas moved toinclude/rfl/internal/cpp20/num_fields.hppwithout a forwarding shim, breaking downstreammoqxbuilds until patched to<rfl/num_fields.hpp>.
- Because
games-on-whales/wolf (ac2461f6)
- Dummy
AppCMD{}default on a requiredrfl::TaggedUnionfield forced byrfl::DefaultIfMissing:
src/moonlight-server/state/serialised_config.hpp#L119-L129(used across 6rfl::toml::load<WolfConfig, rfl::DefaultIfMissing>(...)calls insrc/moonlight-server/state/configTOML.cpp#L218,#L250,#L423,#L439,#L463,#L476):struct BaseApp { std::string title; ... rfl::TaggedUnion<"type", AppCMD, AppDocker> runner = AppCMD{}; // We have to provide a default or rfl::DefaultIfMissing will fail };
- Parallel
PartialClientSettingsshadow struct + duplicated field-by-field merge for partial updates:
src/moonlight-server/api/api.hpp#L54-L62mirrors all 7 fields ofwolf::config::ClientSettingswrapped instd::optional<...>:Every new field added tostruct PartialClientSettings { std::optional<uint> run_uid; std::optional<uint> run_gid; std::optional<std::vector<wolf::config::ControllerType>> controllers_override; std::optional<float> mouse_acceleration; std::optional<float> v_scroll_acceleration; std::optional<float> h_scroll_acceleration; std::optional<wolf::config::ControllerType> motion_controller_override; };
ClientSettings(e.g.motion_controller_overridein commit4ebbd98f) must be duplicated intoPartialClientSettingsand manually threaded through two separate.value_or(...)merge blocks:src/moonlight-server/api/endpoints.cpp#L424-L436and#L572-L581. - Double-unwrap on
rfl::Description<..., std::optional<T>>:
src/moonlight-server/api/api.hpp#L65-L70,#L124-L140andsrc/moonlight-server/api/endpoints.cpp#L411,#L568-L571:auto client_settings = event.value().client_settings.value().value_or(PartialClientSettings{}); ... auto new_settings = payload.settings.get().value_or(PartialClientSettings{}); .app_state_folder = payload.app_state_folder.get().value_or(current_client->app_state_folder),
hudson-trading/slang-server (1b413a46)
- Pervasive
.value()and chained.value().value_or(...)/*field.value()unwrapping on metadata-wrapped fields:
Every field ofConfigand its nested structs (IndexConfig,HoverConfig,InlayHints,Build) is wrapped inrfl::Description<...>,rfl::Deprecated<...>, orrfl::Skip<...>(include/Config.h#L35-L196):src/Indexer.cpp#L674and#L1145:entry.excludeDirs.value().value_or(std::vector<std::string>{})src/SlangServer.cpp#L659-L660,#L671,#L690-L694:m_config.wcpCommand.value().value_or("surfer --wcp-initiate {}") if (m_config.buildPattern.value().has_value()) { ... *m_config.buildPattern.value() ... }
- Also across
src/ServerDriver.cpp#L89-L133,src/Indexer.cpp#L1105-L1113,src/SlangServer.cpp#L787-L807, andinclude/Config.h#L93-L97.
- Double-parsing every layered config file + manual
Generic::Objectpresence tracking:
Becauserfl::DefaultIfMissingfills in missing fields with default-constructed values (erasing whether a field was explicitly provided vs omitted) and cannot merge partial layers into an existingConfigstruct,Config::fromFilesparses every JSONC file twice — first intoConfigpurely for validation (discarding the result), then intorfl::Genericto manually merge arrays/maps/scalars and track explicit presence (e.g.buildPatternExplicit):include/Config.h#L41&#L90-L91:// all fields must be optional ... // This can't be defaulted because of how we paint configs over each other and append // lists together.
src/Config.cpp#L68-L140:// Validate against Config schema first auto fileConfig = rfl::json::read<Config, rfl::DefaultIfMissing>(jsonstr, CONFIG_READ_FLAGS); ... auto generic = rfl::json::read<rfl::Generic>(jsonstr, CONFIG_READ_FLAGS); ... auto finalConfig = rfl::from_generic<Config, rfl::DefaultIfMissing>(config); ... const bool buildPatternExplicit = hasField(workspaceObj, "buildPattern") || hasField(userObj, "buildPattern") || hasField(localObj, "buildPattern");
Related Fork Work
- Prototype zero-bloat metadata attachment and compile-time isolation for large structs #91 — Zero-bloat / non-intrusive metadata attachment (so descriptions/schema annotations live out-of-band instead of wrapping field types).
- Prototype unified wrapper composition, recursive trait peeling, and deep-unwrap #92 (closed; parked in Map (Backlog — Moonshots & Possible Scope Creep) #117) — Prototype unified wrapper composition, recursive trait peeling, and deep-unwrap (directly covers
.value().value()/.value().value_or()unwrap chains). - Prototype JSON Schema extensibility ($defs naming, custom wrapper x-* hooks, integer width bounds, title/examples) #100 / PR feat(schema): add opt-in zero-bloat rfl::Metadata<T> for out-of-band field/struct documentation #119 (
rfl::Metadata<T>) / PR Emit JSON Schema defaults for rfl::DefaultIfMissing (#396) #78 (JSON Schema defaults forDefaultIfMissing). - Triage & Design Notes (Fork-Only): Speculative Schema / Contract APIs #136 — Fork triage design filter explicitly prefers out-of-band traits and processors over field wrappers so shared domain structs stay plain C++ without
<rfl/...>header contagion. - Map (Lane 1): Core Hygiene & Perf #85 / Profile and root-cause 101 MiB Debug object-file and compile-time explosion on wrapper-annotated structs #90 — Core hygiene (including keeping a lightweight forwarding header at
include/rfl/internal/num_fields.hpp->rfl/num_fields.hppforv0.22consumers) and compile-time overhead. - Unaddressed: per-struct
DefaultIfMissingscoping and/or in-place overlay/patch deserialization (read_into(existing_value, input)).
Upstream Overlap
read_to&rfl::SkipIfMissingprocessor munich-data-engineering/reflect-cpp#338 (open, partial) — Requestsread_to+rfl::SkipIfMissingfor partial overlay/patch updates into an existing struct (addresseswolf'sPartialClientSettingsandslang-server's layered config double-parsing; maintainer called it "a very interesting problem").- "Standardize" interface for getting the underlying data in
rfl::wrapper-types munich-data-engineering/reflect-cpp#192 (open, partial) — Requests a standardized interface/trait for unwrapping underlying values acrossrfl::wrapper types. - How to have optional fields with explicit defaults and required fields in the same struct? munich-data-engineering/reflect-cpp#372 (closed/wontfix, partial) — Asked for mixed required + defaulted fields without
DefaultIfMissingmaking all fields optional; maintainer noted C++ limitations prevented a non-intrusive solution, later adding the intrusiverfl::DefaultValwrapper in Addrfl::Defaultmunich-data-engineering/reflect-cpp#534 / Added rfl::DefaultVal, resolves #534 munich-data-engineering/reflect-cpp#553 (merged, post-wolfv0.21/moqxv0.22). - Add operator* and non-const accessors to wrapper classes munich-data-engineering/reflect-cpp#603 & Added the arrow operator; fixes #684 munich-data-engineering/reflect-cpp#704 (resolving Request: Implement 'member-of-pointer' access operator (->) for Rfl types munich-data-engineering/reflect-cpp#684) (merged, partial) — Added
operator*, non-const.get(), andoperator->to wrapper classes (post-v0.22/v0.25) to reduce.value()churn, though wrapper types remain intrusive. - Make
rfl::num_fieldspublic munich-data-engineering/reflect-cpp#465 (resolving Reflect on the number of fields of a too-complex type at compile time? munich-data-engineering/reflect-cpp#451) (merged, partial) — Promotedrfl::num_fieldsto public API (used as a shadow-struct drift guard; Add support for C++-26 reflection munich-data-engineering/reflect-cpp#713 later relocated the internal headerinclude/rfl/internal/num_fields.hpp). - Unfiled upstream: Out-of-band (non-intrusive) field metadata / schema-annotation traits and per-struct
DefaultIfMissingscoping.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestknown-downstream-workaroundsDownstream consumer pain or workaround observed in real-world OSS reposneeds-triageMaintainer needs to evaluate this issue
Activity
[-]API/Defaults & Wrappers: all-or-nothing DefaultIfMissing forces shadow structs, DefaultVal<T>, .value().value(), and drift static_asserts[/-][+]API/Defaults & Wrappers: all-or-nothing DefaultIfMissing and intrusive metadata wrappers force shadow structs, .value().value_or() churn, and drift static_asserts[/+]clockblocker commentedon Nov 29, 2026
Tracking & PR Cross-Reference
Status: Tier-2 (upstream discussion first) — existing prototypes are parked cleanly on
discuss/ssot(all scored below the>= 65cutline in Draft PR #209 without upstream design sign-off).rfl::Metadata<T>out-of-band field/struct documentation (score 45/100)rfl::DefaultIfMissing(refs upstreammunich-data-engineering/reflect-cpp#396, score 41/100)rfl::DefaultIfNullprocessor (refs upstreammunich-data-engineering/reflect-cpp#796, score 33/100)rfl::Aliasread-only field aliases (score 45/100)rfl::Nullable<T>,rfl::TriState<T>, andrfl::AddNullFields(scores 40–52/100)read_into/load_intoatomic overlay deserialization (branchread-into-overlay)