← Back to Pull requests

fix(controller): return an error for an unconfigured model #217

Merged
vfalico merged 2 files (37 lines) on Oct 26, 2026 21:50 UTC
View on GitHub
vfalico vfalico commented on Oct 23, 2026 13:22 UTC
Author

Summary

Controller.Exec panics when a live model call has neither a regular nor a streaming model callback.

Return an error at invocation instead. Keep nil model callbacks valid during construction because replay and streaming-only controllers support them.

Add a table-driven regression covering missing, regular and streaming-only callbacks, including journal-chain verification.

Verification

  • Confirmed the focused regression panics on the unchanged base and passes with this fix:

  • go test -p=2 -count=1 -timeout=90s -run=^TestExecModelConfiguration$ -v ./controller
  • Passed controller-package race coverage:

  • go test -race -p=2 -count=1 -shuffle=on -timeout=180s ./controller
  • Passed go vet -p=2 ./controller.
  • Full-repository contribution gates have not been run locally.

    Diff: 37 lines (+37 / -0) across 2 files Reviewer: gambtho Review duration: 4827m
    All Vouch review confidence checks passed
    Residual risk 0.06 = Change Risk (0.49) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.49 · 37 lines diff across 2 files
    0.49
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.85 · 2 substantive comment(s)
    0.85
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    87%
    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.218
    Sensitive Paths sensitive_paths
    0.049
    Real PR Conversation Timeline
    6 items
    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 23, 2026 13:24 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🟢 Approval recommended

    The localized guard preserves callback dispatch and has focused regression coverage, though full contribution gates remain unverified.

    No open issues 🎉

    <details>
    <summary><strong>What changed in this PR</strong></summary>

    Prevents Controller.Exec from panicking when no model callback is configured, while preserving nil callbacks for replay and streaming-only controllers.

    Changes:

  • Returns an error when a live call has neither a regular nor a streaming callback.

  • Documents the supported nil-model behavior.

  • Adds table-driven coverage for missing, regular, and streaming-only callbacks, with journal-chain verification.
  • | File | Description |
    | ---- | ----------- |
    | controller/​controller.go | Guards against an unconfigured model and documents the behavior. |
    | controller/​controller_test.go | Tests callback configurations and verifies journal integrity. |
    </details>

    <sub>Review effort: Balanced</sub>

    gambtho gambtho approved these changes on Oct 23, 2026 13:44 UTC
    Approved Reviewer

    Thanks Slava, looks good. One small test nit: assert the missing-callback error in the unconfigured case, so an unrelated failure can't satisfy it.

    aramase aramase commented on code on Oct 23, 2026 16:40 UTC
    Code Review
    controller/controller_test.go:1
    @@ -113,6 +113,39 @@ func TestExecReplayIdentityAcrossRestart(t *testing.T) {
     	}
     }
     
    +func TestExecModelConfiguration(t *testing.T) {
    +	for _, tc := range []struct {
    +		name    string
    +		model   controller.ModelFunc
    +		stream  controller.StreamFunc
    +		wantErr bool
    +	}{
    +		{name: "unconfigured", wantErr: true},
    +		{name: "plain", model: echoModel},
    +		{
    +			name: "streaming only",
    +			stream: func(ctx context.Context, req api.ModelRequest, _ func(string)) (api.ModelResponse, error) {
    +				return echoModel(ctx, req)
    +			},
    +		},
    +	} {
    +		t.Run(tc.name, func(t *testing.T) {
    +			log := eventlog.AsStore(eventlog.New())
    +			c, err := controller.New(log, tc.model, controller.WithStreamingModel(tc.stream))
    +			if err != nil {
    +				t.Fatal(err)
    +			}
    +			err = c.Exec(t.Context(), &echoHarness{}, []api.Message{msg("hi")}, 0)
    +			if (err != nil) != tc.wantErr {

    nit: could the unconfigured row assert the specific error (errors.Is or the message), so an unrelated Exec failure can't satisfy it?

    aramase aramase commented on code on Oct 23, 2026 16:40 UTC
    Code Review
    controller/controller.go:1
    @@ -583,6 +584,9 @@ func (c *Controller) emitDelta(executionID string, partIndex int32, chunk string
     // are a view of the call in progress, not the record of it.
     func (c *Controller) invokeModel(ctx context.Context, executionID string, req api.ModelRequest) (api.ModelResponse, error) {
     	if c.stream == nil {
    +		if c.model == nil {
    +			return api.ModelResponse{}, errors.New("controller: model callback is not configured")

    nit: could this be an exported sentinel like ErrMissingSessionUID, so callers can tell a missing model from a provider failure and the test can pin it?

    aramase aramase approved these changes on Oct 26, 2026 21:50 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    vfalico vfalico
    Labels
    risk: low confidence: 87.6% reviewed sensitive_module
    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: 49.4% (MEDIUM) · Higher = larger blast radius
    49.4%
    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: 87.6% · Lower = rushed or shallow review
    87.6%
    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: 6.1% · Safe to merge
    6.1%