Skip to content

fix: harden Result state representation - #22

Merged
zuudevs merged 5 commits into
mainfrom
hardening/result-contract
Sep 15, 2026
Merged

zuudevs merged 5 commits into
mainfrom
hardening/result-contract

Conversation

@zuudevs

@zuudevs zuudevs commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Summary

Starts roadmap milestone v0.8 by hardening the project-owned Result<T> contract without replacing the current std::variant storage baseline.

Result changes

  • switch state inspection from type-based lookup to variant index/discriminant
  • switch accessors to index-based std::get_if so wrong-state access does not hide a std::bad_variant_access path inside noexcept
  • retain the documented precondition model for wrong-state access
  • add explicit Result<T>::success(...) and Result<T>::failure(...) factories
  • make Result<Error> capable of representing both success and failure unambiguously
  • direct Result<Error>{Error{...}} remains the failure form; successful Error payloads use Result<Error>::success(...)
  • preserve move-only payload support
  • explicitly reject Result<void> until a concrete specialization is required
  • keep std::variant rather than adding custom manual storage before measurement justifies it

Tests

Adds dedicated Result<T> coverage for:

  • success and failure states
  • mutable/const value access
  • convertible success inputs
  • move-only payloads
  • copy/move trait behavior
  • explicit factories
  • Result<Error> success/failure distinction

Documentation

  • updates the Result<T> contract with explicit factory semantics and the Result<Error> rule
  • synchronizes docs/roadmap.md: v0.5, v0.6 and v0.7 are complete; v0.8 is now in progress
  • records URL/query correctness as the next v0.8 substep

Scope

This PR does not change HTTP, transport, redirect, or connection-reuse behavior. It is the first focused correctness-hardening PR for v0.8.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13548c29e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +24 to +25
Result(U&& value)
: storage_(std::in_place_index<0>, std::forward<U>(value)) {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve braced success construction

When a success payload is supplied as a braced initializer, such as Result<std::vector<int>>{{1, 2, 3}} or return {{1, 2, 3}}, template argument deduction cannot infer U, so code accepted by the previous Result(T) constructor now fails to compile. Preserve a non-template path for constructing T from a braced initializer while retaining the special handling required for Result<Error>.

Useful? React with 👍 / 👎.

@zuudevs
zuudevs merged commit c87e078 into main Sep 15, 2026
6 checks passed
@zuudevs
zuudevs deleted the hardening/result-contract branch September 15, 2026 00:40
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.

1 participant