← Back to Pull requests

Stop reentrant transport logging feedback [#68] #76

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

Problem and behavior

A transport callback that logs on every write can perpetuate an unlimited feedback loop: one external record produces another record on each subsequent drainOnce(). Deferring reentrant records to the next drain does not stop amplification.

Register consumer-thread logging rings with addConsumerRing(). All rings are snapshotted before dispatch; records written to consumer-owned rings during dispatch are acknowledged without transport delivery and counted in healthSnapshot().reentrantRecords. Nested drainOnce() calls return zero. Independent producer rings retain concurrent records and immediate saturation refusal.

The consumer ring must have the consumer thread as its sole producer. Callback logging must use these rings. Suppression applies to all transports, including healthy ones; consumer-thread logs written outside dispatch remain deliverable. The migration guide documents this contract. Governed records and producer admission are unchanged.

Also expose removeTransport() for ordinary disconnection, release self-handle lookup cells on removal, and retain failure accounting only for failure paths.

Validation

  • Compilation: upstream Clang 21.1.8 on macOS arm64, cmake --build --preset ninja-macos-clang --parallel, passed.

  • Linking: libmddlog.a and mddlog_specs linked successfully.

  • Execution: ctest --preset ninja-macos-clang, 108/108 tests passed.

  • Regression: unconditional callback logging and a nested drain cause one transport write from one external record, followed by 100 empty drains. Logging outside dispatch resumes normally.

  • Concurrency: a producer fills its ring while a transport is blocked; concurrent records survive reentrant suppression, and saturation remains observable.

  • clang-tidy 21: both changed translation units passed with warnings promoted to errors.

  • clang-format 21: all 46 files in the formatting scope passed --dry-run --Werror. The equivalent direct check was used because macOS system Bash lacks the script's mapfile builtin.
  • Addresses #68. ADR-003 acceptance remains a separate review decision; #69 is not implemented by this PR.

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

    Summary by CodeRabbit

    New Features
    Transport health information now reports records written reentrantly during dispatch.
    Consumer-thread logging during dispatch is suppressed; records written outside dispatch remain deliverable.
    Nested drain attempts on the consumer thread return zero.
    Transports can be removed without counting the removal as a failure.
    Documentation
    * Added guidance on ring ownership, registration, reentrant logging, and transport removal, including ring lifetime and producer/consumer requirements.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 356 lines (+267 / -89) across 4 files Reviewer: AM-L Review duration: 812m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 356 lines diff across 4 files
    0.43
    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.352
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #76"
    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: 42.5% (MEDIUM) · Higher = larger blast radius
    42.5%
    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: 16.8% · Safe to merge
    16.8%