← Back to Pull requests

feat(db): show whether each database is neutralized #30

Closed
unknown closed this pull request without merging on Sep 08, 2026 11:26 UTC
View on GitHub
unknown unknown commented on Aug 26, 2026 07:37 UTC
Author

What

Every database row in the instances list now says whether it is neutralized:

● mi-odoo                  5d 02:20:49  RUNNING
  └── devel                5432  NEUTRALIZED            (green)
  └── e2e                  5432   NOT NEUTRALIZED        (red)

Yellow PARTIALLY NEUTRALIZED for a database whose signals disagree, and no tag at all where psql could not answer — guessing either way is the mistake this exists to prevent.

instance_databases (MCP) returns the whole report, not just the state:

{"flag": "true", "version": "19.0.1.3", "stub": 1, "live_relays": 0, "live_crons": 0,
 "checked": ["fetchmail_server", "iap_account", "mail_template"],
 "extras": {}, "state": "neutralized"}

Why not just read the flag

database.is_neutralized is what the database claims. Written by hand, or left behind by a neutralization that someone switched a cron back on after, it marks a live database as safe — the exact failure the tag exists to catch. So the flag is corroborated against what the database can still do: the stub relay being in place, no real mail server or cron still active, and eight module surfaces that must not still be live (payment providers, IAP credits, fetchmail, templates pinned to a relay, WhatsApp, VoIP, bank feeds, signing certificates), each condition copied from that module's own data/neutralize.sql.

Claimed and clean is the only way to green. The two disagreeing is yellow.

Notable decisions

  • Missing tables. Those module tables are absent on most databases, and naming a missing one fails the whole statement at parse time — losing every signal instead of narrowing them. They go through query_to_xml (SQL as a string, parsed only after to_regclass confirms the table). The report carries checked so a misspelled table name is distinguishable from a module that isn't installed.

  • Odoo 14/15. The stub relay only exists from 16, where neutralize.sql first ships. On 14/15 the flag is set by whatever copied the database, with no stub to find — demanding one would paint every correctly neutralized old staging yellow forever. payment_acquirer is checked alongside payment_provider for the same reason.

  • Mail catchers. mailhog/mailpit/maildev are not counted as live relays: they accept mail and never relay it, which is what the Mail tab already says about them via odoo-db's is_test_catcher. Counting them would have the two halves of the app contradicting each other.

  • Left out on purpose. The checks hanging off res_company/res_users (sms_twilio, microsoft_calendar, l10n_* EDI credentials): those tables exist everywhere while their columns come and go with the module, which no static SQL can guard.

  • Cost. One round trip per instance. Neutralization is per-database state so it takes a connection per db, but they go out as one shell loop — 29ms/db measured, 0.49s for a 17-db cluster, cached per instance.
  • Validation

    Run against 22 real databases (5 docker + 17 host cluster), versions 16 through 19, every state cross-checked against direct SQL rather than through this code:

  • No host-cluster database carries the flag → all red. Correct.

  • v17e_cpc_recycle_production (the surface-richest): 16 payment providers all disabled, 0 account_online_link, 0 fetchmail → extras {}; ir_cron 46 total / 2 active / 1 excluding autovacuum — matches exactly.

  • iap_account caught live credentials on 6 databases (real 32-char tokens, not +disabled) — something the four base signals cannot see.

  • A nonexistent database name mixed into the list is skipped without taking the rest of the list down.

  • Green, yellow and red each reproduced end to end on a real database (yellow by enabling one cron whose nextcall was three weeks out, then restoring it).
  • checked aggregated over all 22: certificate_certificate, payment_acquirer, voip_provider and whatsapp_account have never been evaluated anywhere — no database here has those tables. That is the observability working, not a gap in the checks.

    Not validated on real data: no database older than 16 exists here, so the relaxed-stub path and payment_acquirer are covered by unit tests only.

    Diff: 532 lines (+399 / -133) across 6 files Reviewer: xaviedoanhduy Review duration: 18948m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 532 lines diff across 6 files
    0.48
    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.376
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #30"
    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: 47.9% (MEDIUM) · Higher = larger blast radius
    47.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: 18.9% · Safe to merge
    18.9%