[#33] Add InlineString<N>: fixed-capacity, owned, allocation-free string #43
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #43"
general
weight: 0.35
ambroise-leclerc
Summary
Implements ADR-001 Decisions 1-2's replacement for
std::stringin the governed zone (mddlog-core), per #33 (after #31's contracts, in parallel with #32 which is already merged).InlineString<N>: astd::array<char, N>plus astd::uint16_tlength —constexpr,noexcept, trivially copyable, no allocation and no exception anywhere in the module.Nbounded at compile time: arequiresclause rejects anyNoutside theuint16_tlength's representable range. No compile-fail test harness exists in this project yet, so this is the documented fallback the issue's acceptance criteria allow.assignExact()— identifier-kind semantics (ADR-001 Decision 2): stores the value only if it fits whole; otherwise leaves the object exactly as it was.assignTruncating()— descriptive-text semantics: always stores, shortening to the longest prefix that never splits a well-formed UTF-8 sequence, and reports whether it did. Implements the algorithm ADR-001 Decision 2 documents, including the malformed-input backtrack-cap behavior for already-invalid input.view()), not raw storage — two instances with different write histories but the same current value compare equal (a mistake an earlier revision of the memory-budget ADR work made and had to fix; guarded against here from the start).constevalself-tests withstatic_assert, shipped in the module itself (not just the spec), proveconstexprevaluation of both assignment operations — the acceptance criterion's "at least onestatic_assert" plus a bit more, as a permanent regression guard.Also adds
tests/spec/InlineStringSpec.cpp(SpecLab), covering: empty/partial/exact-capacity for both assignment kinds, capacity+1 refusal leaving the prior value untouched, 2/3/4-byte UTF-8 sequences right at the truncation boundary (both "fits whole" and "gets dropped entirely" cases), already-malformed input's documented backtrack-cap behavior, trivial-copyability, and logical-content equality.InlineString<N>is not re-exported through themddlogumbrella module at this stage — it's a governed-zone-only building block (ADR-001's full governed record doesn't exist yet); the spec importsmddlog.core.inlinestringdirectly.Invitation and contributor agreement
Not applicable — this PR is the project steward's own change, made directly by the maintainer (ambroise-leclerc); there is no external contributor or CLA issue involved.
Verification
std::array,std::string_view,std::uint16_t/std::size_t, andstd::copy_nare used.clang-format18 (project config targets 21, documented as 18+-compatible).-Werroron a signed-chartarget.scripts/run-clang-tidy.shrequires the pinned clang-tidy-21 plus built Clang module interfaces neither of which this sandbox can produce. Named the UTF-8 bit-pattern literals as constants specifically to preemptcppcoreguidelines-avoid-magic-numbers, and replaced indexed-loop copies withstd::copy_nto avoidcppcoreguidelines-pro-bounds-constant-array-indexon thestd::arraymember — best-effort against the enabled check set, not a substitute for CI actually running it.constevalself-test and a SpecLab regression scenario pinning the exact case reported.Acceptance criteria (from #33)
InlineStringSpec.cpp; CI green.Nhors plage rejeté à la compilation — enforced by therequiresclause; documented rather than exercised by a non-compilation test, per the issue's own fallback.constexprdémontrée par au moins unstatic_assert— threeconsteval+static_assertpairs shipped in the module.try/catch/throwni allocation dans le module — confirmed by review (see Verification); tooled proof is explicitly out of scope for #33 (belongs to the boundary-controls batch).<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Added fixed-capacity string storage that avoids dynamic allocation.
Strings can be assigned exactly, preserving their existing value if the input exceeds capacity, or assigned with truncation when needed.
Truncation avoids splitting well-formed UTF-8 characters at the capacity boundary. The string also supports viewing its contents, checking its size and emptiness, and comparing values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->