← Back to Pull requests

Do not emit a leading boolean operator for the first enabled filter rule (fixes #76) #563

Closed
unknown closed this pull request without merging on Nov 14, 2026 21:31 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 02:36 UTC
Author

Don't emit a leading boolean operator for the first enabled filter rule (fixes #76)

Problem

JavaScriptBuilder.appendFilterScript builds the filter as one boolean expression,
prefixing every enabled rule with its operator:

builder.append("function doFilter() { ... return (");
for (...) {
    String operator = "";
    if (rule.getOperator() == AND) operator = " && ";
    else if (rule.getOperator() == OR) operator = " || ";
    builder.append(operator + "(filterRule" + i + "() == true)");
}

The operator of the first term is emitted too. Normally the first rule's operator is
NONE/null, so nothing is prepended. But when the first step is disabled, the next
enabled rule carries the AND/OR it was given relative to the step above it, so the
expression starts with a dangling operator:

function doFilter() { ... return ( && (filterRule1() == true) || (filterRule2() == true)); }

That is invalid JavaScript, so the channel fails to deploy. Multiple users have hit this
in production.

Fix

Skip the operator for the first enabled rule — it has nothing to combine with:

boolean firstRule = true;
for (...) {
    String operator = "";
    if (!firstRule) {
        if (rule.getOperator() == AND) operator = " && ";
        else if (rule.getOperator() == OR) operator = " || ";
    }
    firstRule = false;
    builder.append(operator + "(filterRule" + i + "() == true)");
}

The channel now deploys and the disabled step does not execute, which is the expected
behavior described in the issue.

Tests

Added JavaScriptBuilderTest.testFilterDisabledFirstRuleNoLeadingOperator: a disabled
first step followed by an enabled AND rule must not produce a leading operator in
doFilter(). The test fails on main and passes with this change; the existing
JavaScriptBuilderTest cases are unchanged (7 tests, 0 failures).

A note on approach

The issue raised three possible directions: disallow saving this configuration, fix the
generated code, or reorder so the first enabled rule becomes the first. This PR takes the
second — fixing the generated code — as the least invasive change that produces the
issue's stated expected behavior. Happy to switch to validation-on-save or reordering if
you'd prefer one of those.

Diff: 286 lines (+214 / -72) across 3 files Reviewer: pacmano1 Review duration: 14094m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 286 lines diff across 3 files
0.40
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%
56%
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.339
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #563"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% 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: 39.8% (MEDIUM) · Higher = larger blast radius
39.8%
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: 56.8% · Lower = rushed or shallow review
56.8%
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: 17.2% · Safe to merge
17.2%