← Back to Pull requests

[#7] Tests de caractérisation de LogLevel avant renommage #26

Closed
unknown closed this pull request without merging on Sep 23, 2026 14:27 UTC
View on GitHub
unknown unknown commented on Sep 23, 2026 08:57 UTC
Author

Summary


  • New tests/spec/LogLevelSpec.cpp, registered in tests/CMakeLists.txt, pins mddlog::LogLevel's current, observable behavior before #16 renames its enumerators (TRACE...AUDIT → Trace...Audit), so that PR can be verified as an identifier-only change: these same scenarios should pass after the rename with only the LogLevel:: spellings in this file changing.
  • Closes #15.

    Nine new scenarios, grouped by the ticket's checklist


  • Numeric values: underlying type (std::uint8_t) and relative order, via std::to_underlying and direct comparison - the basis every min-level filter relies on.

  • Conversions: toString() for all seven levels + the "UNKNOWN" fallback for an out-of-range value; fromString() for all seven canonical strings + the INFO fallback for an unrecognized (or empty) string; the toString()/fromString() round trip.

  • Colors: getColorCode() for all seven levels (checked against the documented ANSI sequences and for mutual distinctness) + the reset fallback for an out-of-range value, and getResetColorCode().

  • Compliance: isComplianceLevel()'s threshold at WARN.

  • Filtering: a sink's minimum level admitting exactly the levels at or above its threshold, across all seven levels via the generic log() (not logAudit(), whose bypass policy is already covered in AuditPolicySpec.cpp) - complements FilteringSpec.cpp's single-threshold coverage.

  • Textual output: ConsoleSink's actual stdout/stderr routing (captured by redirecting std::cout/std::cerr per level via a small RAII helper, StdStreamCapture, that restores both streams unconditionally) and its formatted output rendering the level in uppercase ("[INFO]").
  • Two things found while writing these, recorded rather than fixed


    A characterization test pins current behavior, it doesn't correct it:
  • ConsoleSink's stderr-routing condition is level >= ERROR, which also covers AUDIT (the highest level) - not just "ERROR and FATAL" as its constructor's doc comment says. The scenario asserts the actual condition and documents the discrepancy in its Then() description.

  • The first version of that scenario failed: it assumed every level gets written somewhere, but ConsoleSink's own default minimum level is INFO (Sink(core::LogLevel::INFO) in its constructor), so TRACE/DEBUG are silently dropped by shouldLog() before reaching either stream. Fixed by explicitly lowering the sink's minimum level to TRACE in that scenario, to isolate stdout/stderr routing from that separately-characterized filtering behavior.
  • Verification


  • Full configure/build/ctest cycle on both reference compilers:

  • - ninja-gcc (gcc 16.1.0): 37/37 pass.
    - ninja-clang (Clang 21.1.8): 38/38 pass (this preset also runs build.cache.namedModuleIntegrity).
    - All nine new scenarios register as individual CTest entries via cmake/MddlogTestDiscovery.cmake.
  • clang-tidy --checks='-,readability-identifier-naming' reports no warnings on the new file.

  • Reformatted with clang-format-21; idempotent (--dry-run --Werror clean on a second pass).
  • Test plan


  • cmake --preset ninja-gcc / ninja-clang + ctest: build and full suite pass on both, including 9 new scenarios.

  • Each new scenario shows up as its own CTest entry (ctest -N).

  • clang-tidy --checks='-*,readability-identifier-naming' clean on the new file.

  • clang-format-21 --dry-run --Werror: idempotent.
  • Diff: 434 lines (+325 / -109) across 5 files Reviewer: AM-L Review duration: 330m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 434 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.363
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #26"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.2% (MEDIUM) · Higher = larger blast radius
    45.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%