Files
Library/docs/roadmap/modules/Core.md
T

142 lines
9.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Core completion plan
Status: planning only. All feature tasks below are **PLANNED**. Baseline:
`f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`, inspected 2026-11-24.
## Existing capability and evidence
[Core's declaration](../../../src/Core/module.cmake) currently declares no internal
dependencies. Its public headers include [Bits](../../../include/Void/Core/Bits.hpp),
[Flags](../../../include/Void/Core/Flags.hpp), [Hash](../../../include/Void/Core/Hash.hpp),
[Scope](../../../include/Void/Core/Scope.hpp), [Lazy](../../../include/Void/Core/Lazy.hpp),
[Counted](../../../include/Void/Core/Counted.hpp),
[TypeList](../../../include/Void/Core/TypeList.hpp),
[TypeMap](../../../include/Void/Core/TypeMap.hpp),
[Variant](../../../include/Void/Core/Variant.hpp), and reflection
[Meta](../../../include/Void/Core/Meta.hpp). These are separate namespaces such as
`Void::Bits`, `Void::Meta`, and `Void::Scope`, not an existing `Void::Core` namespace.
Reflection is conditionally compiled; retaining C++26 reflection remains R-002.
[Uuid](../../../include/Void/Core/Uuid.hpp) stores sixteen bytes, parses compact or
hyphenated hex, generates v4 through `Void::Random`, and exposes `v5_lite` using
noncryptographic hashes. The Math include is a real undeclared dependency to remove.
`v5_lite` is not interoperable SHA-1 UUID v5 and must never be advertised as such.
Its temporary string allocation and several allocating `noexcept` APIs warrant an
exception-specification audit. Hash functions are utility hashes, not authentication.
[Core tests](../../../tests/standalone/Core) exercise all these header families;
[UUID tests](../../../tests/standalone/Core/Uuid.cpp),
[scope tests](../../../tests/standalone/Core/Scope.cpp), and
[reflection tests](../../../tests/standalone/Core/Meta.cpp) provide baseline fixtures.
These are inspected capabilities, not a fresh test-pass claim. Graph coverage reported
partial parsing at Meta line 280 and Variant line 17; those ranges were read directly.
## Ownership and target boundary
[Architecture C-01/C-02/C-13](../ARCHITECTURE.md) governs this layer. Core stays native
and standard-library-only: identity representation, bit operations, traits, lifetime
guards, and small vocabulary helpers. It never imports Math, Functional, Memory,
execution, logging, or crypto. Fallible Core primitives use
`std::expected<T, local_error_enum>`; Functional supplies optional error adapters above
Core. Allocator facilities belong to [Memory](../subsystems/Memory.md), checked general
numeric arithmetic to [Math](Math.md), and error categorization to [Functional](Functional.md).
Keep the default include cost small: bit and type-list users must not instantiate
reflection or diagnostic formatting. Split heavyweight formatting/reflection bridges
into explicitly included headers, preserving forwarding includes for one major migration.
Do not replace standard scope or type utilities merely to add another spelling.
## NEW API shapes and behavior
The following are illustrative NEW declarations, not compiling current examples.
Proposed paths are `include/Void/Core/Uuid.hpp` extensions and NEW
`include/Void/Core/CheckedBits.hpp`.
```cpp
namespace Void::Uuid {
enum class GenerateError { entropy_unavailable, invalid_source };
// Caller-supplied URBG; deterministic tests need no global generator.
template<std::uniform_random_bit_generator G> Uuid v4(G& generator);
std::expected<Uuid, GenerateError> try_v4();
// Fixed-size output excludes string allocation and null termination.
std::array<char, 36> format_chars(const Uuid&) noexcept;
}
namespace Void::Bits {
enum class BitError { invalid_range, invalid_alignment, overflow };
template<std::unsigned_integral T>
std::expected<T, BitError> checked_extract(T value, unsigned offset, unsigned count);
template<std::unsigned_integral T>
std::expected<T, BitError> checked_align_up(T value, T alignment);
}
```
`try_v4()` uses a standard entropy source locally, reports source failure, and makes
no cryptographic-strength guarantee. Security-sensitive identifiers obtain bytes from
Security/Crypto through the injected-generator overload; that adapter lives above Core.
Mask version and variant only after all bytes are acquired. No hidden worker or cached
process service is created. Keep `Uuid::Uuid` layout and string representation stable.
The legacy no-argument `v4()` becomes a documented throwing convenience in the major
release; remove its misleading unconditional `noexcept` rather than returning a nil ID
on failure. An explicit legacy adapter preserves old source names during transition.
Checked bit operations validate offset/count without overflowing their sum. Count zero
returns zero for extraction; a full-width mask never shifts by the width. Alignment must
be nonzero and a power of two; overflow returns failure before arithmetic. Existing fast
preconditioned helpers remain available with their preconditions stated.
Scope callbacks execute once, must not throw during destruction, and hold decayed owned
callables unless references are explicitly wrapped. Conditional move `noexcept` must
match the callable. `Lazy` stays single-threaded; `LazySync` uses `call_once` publication,
including synchronized observation of `evaluated()`. A failed factory remains retryable;
recursive access is documented as invalid and gets a debug diagnostic. Neither lazy
wrapper promises a cancellation or reset protocol across concurrent readers.
TypeMap gains reference lookup without copying `std::any` values; returned references
expire on replacement/erase/destruction. It remains a utility, not a service registry.
Counters document wraparound and prohibit use as durable identities; an opt-in checked
sequence reports exhaustion. Compile-time list operations get diagnostics for missing
types and bad indices, rather than accidental template-depth explosions.
## Backlog and ordered implementation
| Task | Phase; dependencies | Intended scope and acceptance | Recommended role |
| --- | --- | --- | --- |
| M-CORE-01 | P0; current source | Inventory every public header, namespace, reflection branch, exception specification and direct include; isolated Core consumer exposes the Math leak and records the compatibility surface. | sol_implementer |
| M-CORE-02 | P1; M-CORE-01 | Implement injected UUID generation, allocation-free parse/format and fallible entropy path; preserve byte/string fixtures and remove all Core→Math includes. | sol_implementer |
| M-CORE-03 | P1; M-CORE-01 | Add checked bit/alignment helpers and portable hash byte loading; constexpr boundary tests cover zero/full widths, maximum values and endianness. | sol_implementer |
| M-CORE-04 | P2; M-CORE-01 | Repair guard move contracts and lazy observation; throwing/move-only factories and contended successful initialization execute/destruct exactly as specified. | astra_implementer |
| M-CORE-05 | P2; M-CORE-01 | Add TypeMap reference access, checked sequence exhaustion and useful list diagnostics; no service/runtime dependency and no implicit copy on reference lookup. | sol_implementer |
| M-CORE-06 | P2; M-CORE-02–05 | Publish compatibility headers and independent-header consumers; Core-only static/shared installed consumers and reflection-enabled/disabled configurations satisfy the package gate. | sol_implementer |
## Resource and performance gates
UUID parse/format and checked bits allocate zero bytes. `v5_lite` retains existing output
fixtures but gets an allocation-free incremental implementation only if byte-for-byte
compatibility is proved; no collision-resistance claim follows. TypeMap's NEW bounded
constructor defaults to 256 distinct types and rejects additional admissions; explicit
unbounded construction is separate. Lazy wrappers retain one result and one factory;
no histories, queues, shutdown work, or background timers exist.
Measure fixed-size UUID batches, type-list compiler cost at 16/64/256 types, Meta formatting
at shallow/deep aggregates, and contended first lazy access. Follow
[PERFORMANCE](../PERFORMANCE.md) for p50/p95/p99, throughput, allocations, RSS/CPU and
build cost. Report entropy acquisition separately from UUID masking/formatting.
## Validation, compatibility and rollback
CURRENT checks are the source suites linked above and the parent-recorded baseline;
this planning task ran no C++ checks. PROPOSED checks require M-CORE-06 consumers and
the supported C++26 toolchain: independent headers, ODR across two shared objects,
sanitizers for lifetime paths, TSAN for LazySync, and fixed hash/UUID fixtures. Include
malformed hyphens, uppercase hex, nil UUIDs, throwing entropy, bit width 0/width/width+1,
throwing guard moves and factories that fail once then succeed.
Migration follows [MIGRATION](../MIGRATION.md) and
[BUILD-AND-DISTRIBUTION](../BUILD-AND-DISTRIBUTION.md). Keep `v5_lite` as a visibly legacy
nonstandard operation; never reinterpret persisted IDs as standards-compliant v5.
Rollback is an old-version package/header selection with the same persisted UUID bytes.
Do not publish the new major until downstream Core-only consumers and optional
Functional formatting bridges pass [VALIDATION](../VALIDATION.md). The
[requirements](../REQUIREMENTS.md), [dependencies](../DEPENDENCIES.md) and
[delivery plan](../DELIVERY.md) own cross-module scope and sequencing.