← Back to Pull requests

feat: add drop_enabled message option #143

Merged
loganintech merged 3 files (279 lines) on Jul 01, 2026 17:48 UTC
View on GitHub
loganintech loganintech commented on Jul 01, 2026 17:02 UTC
Author

Summary

Adds a new drop_enabled option to MessageOptions, alongside disabled / nested_only / etc. When a message sets drop_enabled = true, code generation emits only two helpers and nothing else:

  • DBDropTableStatement() string — returns the DROP TABLE IF EXISTS "<table>" statement for the record's table.

  • DBTruncateTableStatement() string — returns the TRUNCATE TABLE "<table>" statement for the record's table.
  • No descriptor, message, or query-builder code is generated. This provides a way to mark a record as completely inactive and prepare it to be removed from the database.

    Implementation

  • proto/pgdb/v1/pgdb.proto — added bool drop_enabled = 12; to MessageOptions (regenerated pgdb/v1/pgdb.pb.go).

  • pgdb/v1/schema_sql.go — added public runtime helpers DropTableStatement(tableName) and TruncateTableStatement(tableName), reusing the existing pgWriteString identifier quoting.

  • internal/pgdb/pgdb_module.go — after the existing GetDisabled() skip, a new GetDropEnabled() branch renders the drop helpers and skips all other generation.

  • internal/pgdb/pgdb_drop.go + internal/pgdb/templates/drop.tmpl (new) — the render function and template for the two generated methods, with the hashed table name baked in at codegen time.
  • Design notes

  • Method names follow the existing DB-prefixed generated-method convention (DBReflect); they take no args since DROP/TRUNCATE don't vary by dialect, and are callable on a nil pointer like other generated accessors.

  • DROP TABLE IF EXISTS (no CASCADE) for idempotency without unexpectedly dropping dependent objects.
  • Testing

  • Added DeprecatedExhibit (a drop_enabled message) to the zoo example and confirmed only the two methods generate.

  • Unit tests for the runtime helpers (pgdb/v1/schema_sql_test.go).

  • Generated-method tests in example/models/zoo/v1/zoo_test.go, including a Postgres round-trip (create → insert → truncate → drop → idempotent drop).

  • buf lint, go build ./..., gofmt, and the non-DB tests pass. The DB round-trip test requires PostgreSQL (same as all existing schema tests) and runs in CI.
  • 🤖 Generated with Claude Code

    Diff: 279 lines (+209 / -70) across 3 files Reviewer: None requested Review duration: 45m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.52) × (1 − Review Confidence (0.44)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 279 lines diff across 3 files
    0.52
    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: 10%
    44%
    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
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Real PR Conversation Timeline
    1 comments
    "Review active on #143"
    general weight: 0.35
    Reviewers
    None requested
    Assignees
    loganintech loganintech
    Labels
    risk: low confidence: 44.2% 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: 51.6% (MEDIUM) · Higher = larger blast radius
    51.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: 44.2% · Lower = rushed or shallow review
    44.2%
    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: 28.8% · Safe to merge
    28.8%