← Back to Pull requests

ADR-003: bounded, non-reentrant transport consumer with independent health [#68] #75

Closed
unknown closed this pull request without merging on Sep 30, 2026 07:11 UTC
View on GitHub
unknown unknown commented on Sep 28, 2026 20:05 UTC
Author

Summary

  • Implements [ADR-003](docs/adr/ADR-003-application-integration-and-sink-ownership.md) Decision 5

  • for issue #68: a bounded,
    non-reentrant transport consumer with independent health, following #66 and #67.
  • Adds mddlog::adapter::TransportConsumer (TransportConsumer.cppm), which drains one or more

  • bounded RingLogs (ADR-001 Decision 4) on a host-owned consumer thread and dispatches records
    to transport write callbacks through SinkRegistry (#67, ADR-003 Decision 4). This follows the
    existing pull-model convention (RingSinkAdapter, AuditSinkAdapter): the adapter owns no
    thread of its own.
  • The pull model breaks the Frame::addBuffer synchronous re-entrancy cycle structurally: a log

  • emitted from inside a transport's write() re-enters the producer path
    (RingLog::tryWrite()), not the consumer path, so it is only visible to the next
    drainOnce() call - never re-entered within the current one, on any thread.
  • A synchronous throw from write() self-detaches the failing transport via SinkRegistry's

  • deferred self-removal (non-blocking, no further invocation admitted). An asynchronous failure
    discovered later - from any thread, e.g. a write-completion handler - is reported through
    reportFailure(), which detaches via ordinary removal: the slot is retired before waiting, so
    no invocation starting from that point on can reach the failing transport. Neither path lets a
    failing transport receive its own failure record.
  • TransportHealthSnapshot/TransportHealth expose delivered/write-failure/reported-failure/

  • detachment/ring-refusal/active-transport counters, readable without going through any sink.

    Test plan

  • cmake --preset ninja-macos-clang -DMDDLOG_BUILD_EXAMPLES=OFF -DMDDLOG_BUILD_TESTS=ON

  • cmake --build build-macos-clang --parallel

  • ctest --test-dir build-macos-clang --output-on-failure - 107/107 passed, including 6 new

  • TransportConsumer scenarios (slow transport not blocking a producer, saturation refusal +
    counter, synchronous reentrant logging not recursing, synchronous failure detachment,
    asynchronous cross-thread failure detachment without amplification, health readable without
    a sink)
  • clang-tidy (LLVM 21.1.8, project's pinned version): no findings on the new files

  • clang-format applied to the new files
  • Out of scope for this issue, per the ADR (left to later WebFront-adoption work): the WebFront
    facade itself, the real Frame::addBuffer call site, and wiring a real WebSocket sink - this PR
    is the mddlog-side consumer only, exercised through synthetic transports reproducing the same
    sync/async failure shapes.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added transport delivery for log records, with support for multiple registered logs and transport callbacks.
    Added health snapshots covering delivery, transport failures, and records refused by full logs.
    Failed transports are detached automatically, whether errors occur during delivery or are reported asynchronously.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 409 lines (+306 / -103) across 5 files Reviewer: AM-L Review duration: 2106m
    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 · 409 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.360
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #75"
    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: 44.9% (MEDIUM) · Higher = larger blast radius
    44.9%
    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.7% · Safe to merge
    17.7%