← Back to Pull requests

feat(peers): define communication enrollment and delivery contracts #738

Open
unknown opened this pull request with 280 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 03, 2026 03:06 UTC
Author

  • Give connectors and services one generated contract for enrollment, durable delivery, and application acknowledgment.

  • Keep communication identity separate from execution sessions and message bodies separate from immutable history.
  • <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Defines v1alpha1 contracts for attachment fencing, authenticated enrollment, and message delivery that downstream services must implement correctly; changes are additive schema and generated types only.

    > Overview

    Introduces the trogonai.peers protobuf surface so connectors and services share one contract for enrollment, connector leases, peer messaging, and recipient batch delivery.

    > The PeerService NATS micro API covers enroll/heartbeat/detach, roster, idempotent Send/Status, and PrepareBatch/AcknowledgeBatch. Mutating calls carry an AttachmentRef (peer, connector, generation) instead of a retired inline attachment field; tenant/caller identity is documented as coming from the transport subject, not request payloads.

    > Durable history stays separate from erasable bodies: MessageMetadata uses ClaimCheck (storage locator + digest) and reserves legacy content_digest; message text appears only on MessageContent, PreparedMessage, and send/prepare paths. OutboxEntry / InboxEntry, RecipientReceipt, and PeerBatch model idempotency, intake ordinals, and preparation vs application ack. A PeerEvent oneof captures stream facts (enrollment, attachment, heartbeats, accept/intake/settle/dispose, batch prepared/ack), and PeerState folds authoritative mailbox state without embedding body bytes.

    > Rust adds a peers feature on trogonai-proto with a public peers module and a large wire contract test suite (binary/JSON roundtrips, decode limits, enum stability, PeerEvent oneof rules, and proto-JSON Any registration).

    > <sup>Reviewed by Cursor Bugbot for commit f5c6828b168c720b8c6e55993540b87fc164533f. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 280 lines (+210 / -70) across 3 files Reviewer: yordis Review duration: 4407m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.45) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 280 lines diff across 3 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.337
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #738"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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.6% (MEDIUM) · Higher = larger blast radius
    44.6%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 25.5% · Safe to merge
    25.5%