← Back to Pull requests

Record deleted messages and let moderators restore them (0.3.0) #11

Closed
unknown closed this pull request without merging on Nov 02, 2026 10:56 UTC
View on GitHub
unknown unknown commented on Nov 02, 2026 10:47 UTC
Author

Why

Deleting a message blanked it and dropped its mentions and references, with no record of what it said or who deleted it, and no way to undo it. Comply 100 lets Senior Oversight delete other people's messages. They need to confirm who deleted what, thread replies included, and undo mistakes.

What (ADR-0012)

  • MessageDeletion: one row per deletion, holding the original encoded body, the mentioned user ids, the reference rows, deleted_by/deleted_at and restored_by/restored_at. Migration 0003.

  • ChatService.delete_message() writes the row in the same transaction and returns it. The message is still blanked, so no read path can show deleted text.

  • ChatService.restore_message(user, message) undoes the latest deletion. The body, mentions and references come back, nobody is notified again, and viewers get the normal edited broadcast.

  • Policy hooks can_restore_message and can_view_deletions. The default for both is whoever manages the channel.

  • Signals message_deleted and message_restored, plus huddle.message.deleted/restored log lines.

  • Querysets: MessageDeletion.objects.in_channels(channels) and .unrestored().

  • Docs: README section, CHANGELOG, version 0.3.0.
  • Tests

  • New tests/test_deletion_audit.py (8 tests):

  • - what a deletion records, including who deleted it and the signal;
    - thread replies;
    - restoring text, mentions and references;
    - permission checks;
    - nothing to restore;
    - two delete/restore cycles.
  • Full suite passes on Django 6.0 and 6.1, and ruff and mypy are clean.
  • Diff: 199 lines (+149 / -50) across 2 files Reviewer: BenA-SA Review duration: 8m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 199 lines diff across 2 files
    0.36
    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.317
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #11"
    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: 36.1% (MEDIUM) · Higher = larger blast radius
    36.1%
    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: 14.3% · Safe to merge
    14.3%