Skip to content

Prototype ErrorDetail::code vocabulary and validator rule-ID propagation #104

Done

Description

@clockblocker

Question

What ErrorDetail::code representation, built-in validator rule-ID vocabulary, and custom-validator propagation hook let RPC servers and CLIs distinguish validation failures (e.g., range Minimum/Maximum vs collection Size<Minimum<1>>) without fragile error-message string matching?

Evidence & Context

  • Parent map: Map (Lane 5): Structured Diagnostics
  • obs-websocket#1: Had to inspect error messages with a "Size validation failed" string-prefix check to map Minimum/Maximum (402) separately from Size<Minimum<1>> (403).
  • Directly validates PLANNED_PR_WAVES.md Wave 7 (error-detail-code).

Prototype & Measurement Plan

  • Prototype on: showcase/all-lanes — implement ErrorDetail::code representation, populate codes for built-in validators (Minimum, Maximum, Size, Pattern, OneOf, etc.), and expose a clean hook for custom validators.
  • Measure against real Showcase Migration: Validate in obs-websocket#1 by deleting the "Size validation failed" string-prefix check and mapping 402 vs 403 purely from ErrorDetail::code / ErrorKind.
  • 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

    Landed Showcase Confirmation (clockblocker/obs-websocket#1, 14aefd0):

    • Confirmed in obs-websocket/src/protocol/RequestCodec.h: mapping RequestFieldOutOfRange (402) (Minimum/Maximum) vs RequestFieldEmpty (403) (Size) still requires matching "Size validation failed" on ErrorKind::constraint_violation, directly validating Wave 7 error-detail-code.
  3. added 2 commits that reference this issue on Nov 27, 2026
  4. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Resolved on showcase/all-lanes (627a4853, Judge polish 6966dec6).

    Summary

    • Added additive std::string ErrorDetail::code = {}; and std::string_view Error::code() const noexcept.
    • Kept sizeof(rfl::Error) unchanged (BuiltinErrorCode : uint8_t packed into ErrorKind's existing tail padding) and preserved zero-detail-allocation (has_allocated_details == false) for all built-in validator leaf errors including Size<...> and CodePoints<...>.
    • Populated canonical built-in validator rule IDs: equal_to, not_equal_to, minimum, exclusive_minimum, maximum, exclusive_maximum, pattern, any_of, one_of, size / size.*, code_points / code_points.*.
    • Exposed two composable custom-validator hooks:
      1. Imperative per-error rfl::error(msg, kind, code) / rfl::error(msg, kind, path, code) (constrained template keeps braced-init {} and {"field"} path overloads unambiguous).
      2. Declarative static constexpr code member (std::string_view / const char* / rfl::internal::StringLiteral) read automatically by Validator, AllOf, Size, and CodePoints when validate() returns an uncoded error or throws std::exception.
    • Preserved .code on validated map keys via MapReader::make_key (KeyType::from_value(...)) and across wrap_error, wrap_field_error, in_field, at, Error::combine, and attach_source_location.
    • Fixed a pre-existing bug discovered in rfl::OneOf::validate_impl where .and_then(...).or_else(...) double-caught tail errors when >1 branch passed.

    Verification

    • reflect-cpp CTest (AppleClang 17, -Wall -Werror, REFLECTCPP_STRICT_WARNINGS=ON): 463/463 targets, 0 warnings, 1,083/1,083 CTests passing.
    • obs-websocket validation: Verified replacing msg.find("Size validation failed") in RequestCodec.h with primary && primary->code == "size.minimum" builds under -Wall -Wextra -Werror and passes 3/3 CTest / 8/8 suites (789 assertions).
    • Dual Judges: Claude Opus 5.5 High (APPROVE WITH NITS) + Gemini 4 Neon High (APPROVE WITH NITS); all nits addressed in 6966dec6.
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