2.4 KiB
2.4 KiB
Functional Compact Status, Bounded Contexts, and Error Adapters
Task ID: M-FUNCTIONAL-02 Phase: P1 Status: APPROVED Contracts: C-01, C-02, C-05 (G-ERROR)
1. Context and baseline
include/Void/Functional/Error.hpp stores free-form message strings and unbounded shared_ptr<const Error> chains with recursive destruction and no machine-readable classification.
2. Deliverables
ErrorKind,ErrorCode,Status, reserved domain constants, bounded message/frame/format limits, and iterative~Error()ininclude/Void/Functional/Error.hpp.fail(Status)andfail(ErrorKind, ...)factories ininclude/Void/Functional/Result.hpp.include/Void/Functional/Adapters.hpp(adapt,try_invoke,from_errno).tests/standalone/Functional/ErrorStatus.cpp.
3. Exact files and interfaces
include/Void/Functional/Error.hpp:ErrorKind:invalid_argument,not_found,conflict,cancelled,timeout,overloaded,unsupported,io,corrupt,exhausted,internal.Status { ErrorKind kind; ErrorCode code; }andexplicit Error(Status) noexcept(zero heap allocation).- Limits:
kDefaultMaxErrorFrames = 16,kDefaultMaxErrorMessageBytes = 1024,kDefaultMaxFormattedErrorBytes = 16 * 1024. with_context()preserves rootStatusandstd::error_code, pins the root cause at the tail when capping > 16 frames, and setstruncated() == true.
include/Void/Functional/Result.hpp: typedfail(...)overloads.include/Void/Functional/Adapters.hpp:adapt,try_invoke,from_errno.
4. Edge cases
Error(Status)makes zero heap allocations.try_invokemust ALWAYS rethrowstd::bad_allocand any exception wheremap_exceptionreturnsstd::nullopt.adapthandlesvoid, move-only values, and never invokesmap_erroron success.- 20-layer context chains preserve
ErrorKind,ErrorCode,system_code, and root cause message.
5. Acceptance criteria
- Existing 1.x
Result*tests pass unchanged;ErrorStatussuite passes under-Werrorand ASan/UBSan.
6. Verification commands
dev cpp-gcc -c cmake -S . -B /tmp/void-p1-functional -G Ninja -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="Functional;Testing" -DVOID_WARNINGS_AS_ERRORS=ON
dev cpp-gcc -c cmake --build /tmp/void-p1-functional --parallel 4
dev cpp-gcc -c /tmp/void-p1-functional/tests/VoidTests --filter "ErrorStatus*|Result*"