← Back to Pull requests

fix(trainer): execute top-level train calls and strictly validate func_args #31

Closed
unknown closed this pull request without merging on Jun 24, 2026 08:09 UTC
View on GitHub
unknown unknown commented on Jun 06, 2026 15:00 UTC
Author

Description


This PR fixes a silent failure issue where training scripts that define a top-level train() function were nested inside the generated wrapper but never executed.

Type of Change


  • feat: New feature

  • fix: Bug fix

  • revert: Revert a change

  • chore: Maintenance / tooling
  • Checklist


  • Tests pass locally (make test-python)

  • Linting passes (make verify)

  • Documentation updated (if applicable)

  • Commit messages follow conventional format
  • Related Issues


    Closes #19

    Problem


    _make_train_func() always wraps the submitted script in a generated def train(): wrapper. When a user's script already defines a top-level train(), it becomes nested and is never called silently skipping training.

    Fix


    Use ast.parse to detect top-level def train() (sync and async).
    If found and func_args match the signature → call it with forwarded arguments.
    If found but func_args are missing from the signature or do not match → raise a clear ValueError instead of silently failing.
    If not found → wrap as before (existing behavior unchanged).

    Tests Added


    Plain script gets wrapped correctly
    Async train() detected and executable
    Matching func_args work correctly
    Missing params raise ValueError

    Diff: 163 lines (+122 / -41) across 2 files Reviewer: reckless-sherixx Review duration: 25509m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.35) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 163 lines diff across 2 files
    0.35
    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.305
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #31"
    general weight: 0.35
    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: 35.0% (LOW) · Higher = larger blast radius
    35.0%
    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: 13.8% · Safe to merge
    13.8%