From 3920a6b1c40036e4f28215778c7aa826c3351f48 Mon Sep 17 00:00:00 2001 From: CEL Dev Team Date: Mon, 23 Nov 2026 15:43:39 -0800 Subject: [PATCH] --- MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⚠️ **Action Required** > Please review the evidence below, and if you believe [cl/1028472676](http://cl/1028472676) caused the breakages shown, LGTM this CL and allow autosubmit. ⚠️ **This CL will be force submitted** if more breakages are detected.   Auto-rollback will roll back any CLs that cause TAP postsubmit targets to break. Look at the target breakage evidence below. **There were at least 5 targets that started failing at the culprit CL.**   ## 🔴 Target Breakage Evidence 🔴 --- TAP Autorollback strongly suspects that at least one of the following TAP targets was broken by cl/1028472676: ### [Full Evidence Dashboard 📊](https://dashboards.corp.google.com/_66539fc6_9f33_40c8_9e29_a4c9a36ab87f?p=CHANGELIST:1028472676). This is a static snapshot of the first 5 pieces of evidence. Click through to the dashboard above for full results. | | | | | | :--- | :--- | :--- | :--- | | 1. | [Investigate](https://dashboards.corp.google.com/_26a783b8_f185_4d7c_9d42_273c59ef8981?p=FINGERPRINT:5356277681301494786&p=CULPRIT:1028472676&f=target:eq://third_party/cel/cpp/checker/tests:java_baseline_diff_test&f=flags:eq:CAUQBagBAQ%3D%3D) | [Fusion](https://fusion2.corp.google.com/ci/redirectTarget?targetId=%2F%2Fthird_party%2Fcel%2Fcpp%2Fchecker%2Ftests%3Ajava_baseline_diff_test&encodedFlags=CAUQBagBAQ%3D%3D&cl=1028472676) | `//third_party/cel/cpp/checker/tests:java_baseline_diff_test` | | | | | `--config=tsan --cpu=arm` | | 2. | [Investigate](https://dashboards.corp.google.com/_26a783b8_f185_4d7c_9d42_273c59ef8981?p=FINGERPRINT:5356277681301494786&p=CULPRIT:1028472676&f=target:eq://third_party/cel/cpp/checker/tests:java_baseline_diff_test&f=flags:eq:CAMQBagBAQ%3D%3D) | [Fusion](https://fusion2.corp.google.com/ci/redirectTarget?targetId=%2F%2Fthird_party%2Fcel%2Fcpp%2Fchecker%2Ftests%3Ajava_baseline_diff_test&encodedFlags=CAMQBagBAQ%3D%3D&cl=1028472676) | `//third_party/cel/cpp/checker/tests:java_baseline_diff_test` | | | | | `--config=tsan` | | 3. | [Investigate](https://dashboards.corp.google.com/_26a783b8_f185_4d7c_9d42_273c59ef8981?p=FINGERPRINT:5356277681301494786&p=CULPRIT:1028472676&f=target:eq://third_party/cel/cpp/checker/tests:java_baseline_diff_test&f=flags:eq:CAMQBdABAQ%3D%3D) | [Fusion](https://fusion2.corp.google.com/ci/redirectTarget?targetId=%2F%2Fthird_party%2Fcel%2Fcpp%2Fchecker%2Ftests%3Ajava_baseline_diff_test&encodedFlags=CAMQBdABAQ%3D%3D&cl=1028472676) | `//third_party/cel/cpp/checker/tests:java_baseline_diff_test` | | | | | `--config=msan` | | 4. | [Investigate](https://dashboards.corp.google.com/_26a783b8_f185_4d7c_9d42_273c59ef8981?p=FINGERPRINT:5356277681301494786&p=CULPRIT:1028472676&f=target:eq://third_party/cel/cpp/checker/tests:java_baseline_diff_test&f=flags:eq:CAUQAg%3D%3D) | [Fusion](https://fusion2.corp.google.com/ci/redirectTarget?targetId=%2F%2Fthird_party%2Fcel%2Fcpp%2Fchecker%2Ftests%3Ajava_baseline_diff_test&encodedFlags=CAUQAg%3D%3D&cl=1028472676) | `//third_party/cel/cpp/checker/tests:java_baseline_diff_test` | | | | | `--compilation_mode=opt --cpu=arm` | | 5. | [Investigate](https://dashboards.corp.google.com/_26a783b8_f185_4d7c_9d42_273c59ef8981?p=FINGERPRINT:5356277681301494786&p=CULPRIT:1028472676&f=target:eq://third_party/cel/cpp/checker/tests:java_baseline_diff_test&f=flags:eq:CAMQAg%3D%3D) | [Fusion](https://fusion2.corp.google.com/ci/redirectTarget?targetId=%2F%2Fthird_party%2Fcel%2Fcpp%2Fchecker%2Ftests%3Ajava_baseline_diff_test&encodedFlags=CAMQAg%3D%3D&cl=1028472676) | `//third_party/cel/cpp/checker/tests:java_baseline_diff_test` | | | | | `--compilation_mode=opt` | For sponge failure logs, click "Investigate" then "Sponge" on one of the failing CLs. [I'm Feeling Lucky](https://fusion2.corp.google.com/invocations/legacy?url=lucky&q=label:test-efficacy-culprit-finder%20cl:1028472676%20(status:FAILED%20OR%20status:FAILED_TO_BUILD%20OR%20status:ABORTED_BY_TOOL)) Review the evidence above, and if you believe [cl/1028472676](http://cl/1028472676) caused the breakages shown, LGTM this CL and allow autosubmit. #### **Why is rollback being requested?**
Expand > Currently there is not enough evidence to roll back automatically, but some breakages were detected. > Reviewers were chosen either because they were the author or reviewer of the culprit CL, or because `p4 findreviewer` suggested them.
#### **How to Reject this CL**
Expand > If you've already fixed the breakage, want to fix forward, or only roll back part of the breaking change, you don't need to submit this change. > 1. Remove yourself and all other reviewers from the CL. > 2. Add a comment to the CL in this format "DO NOT SUBMIT: {insert reason here}". > * A good reason will include the intended fix CL or a link to a bug where the fix is discussed. > 3. Unsubmitted CLs will be automatically deleted after 3 days.
#### 📄 **How was this CL determined to be a culprit?**
Expand > Autorollback ran the broken targets at the rolled back CL *and* at the previous CL **at least 5 times**. The failures are unlikely to be flakes. > > You can investigate the evidence below. Note that the same target might be listed multiple times if it runs under different build flags. *This is intentional*. Each separate build flag configuration provides more evidence that the targets were really broken by this CL ([see this explanation](http://go/tapautorollback-faq#)) > > [**Walkthrough**](http://go/tapautorollback-faq#how-can-i-find-out-why-a-cl-was-rolled-back-by-autorollback): For any target, click the "Investigate" link to see a dashboard of all the culprit finder runs. From there, you can click through to passing/failing sponge logs to see the exact errors.
--- Feedback: [go/tapautorollback-faq#how-can-i-give-feedback](http://go/tapautorollback-faq#how-can-i-give-feedback) --- #### 📄 **Original CL Description**
BEGIN_PUBLIC BEGIN_PUBLIC Resolve leading-dot identifiers outside comprehension scopes in the type checker PiperOrigin-RevId: 1028522878 --- .../src/main/java/dev/cel/checker/Env.java | 32 ++++------------- .../java/dev/cel/checker/ExprChecker.java | 8 ++--- .../java/dev/cel/checker/ExprCheckerTest.java | 29 ---------------- ...olute_declInNonComprehensionScope.baseline | 34 ------------------- .../resources/referenceTypeAbsolute.baseline | 33 ------------------ 5 files changed, 11 insertions(+), 125 deletions(-) delete mode 100644 checker/src/test/resources/referenceAbsolute_declInNonComprehensionScope.baseline diff --git a/checker/src/main/java/dev/cel/checker/Env.java b/checker/src/main/java/dev/cel/checker/Env.java index ddc98fab5..dd1f92c2c 100644 --- a/checker/src/main/java/dev/cel/checker/Env.java +++ b/checker/src/main/java/dev/cel/checker/Env.java @@ -97,8 +97,6 @@ public class Env { */ private final ArrayList decls = new ArrayList<>(); - private int comprehensionScopeCount = 0; - /** A map from expression ids into references resolved for the overall tree so far. */ private final Map referenceMap = new LinkedHashMap<>(); @@ -294,18 +292,6 @@ public void exitScope() { decls.remove(decls.size() - 1); } - /** Enters a scope for comprehension variables, which leading-dot identifiers skip. */ - void enterComprehensionScope() { - enterScope(); - comprehensionScopeCount++; - } - - /** Exits a scope entered with {@link #enterComprehensionScope}. */ - void exitComprehensionScope() { - exitScope(); - comprehensionScopeCount--; - } - /** Return the current scope depth for the environment. */ public int scopeDepth() { return decls.size() - 1; @@ -515,7 +501,7 @@ public Env add(String name, Type type) { } for (String cand : container.resolveCandidateNames(name)) { - CelVarDecl decl = tryLookupCelIdent(cand, name.startsWith(".")); + CelVarDecl decl = tryLookupCelIdent(cand); if (decl != null) { return decl; } @@ -524,9 +510,9 @@ public Env add(String name, Type type) { return null; } - private @Nullable CelVarDecl tryLookupCelIdent(String cand, boolean skipComprehensionScopes) { + private @Nullable CelVarDecl tryLookupCelIdent(String cand) { // First determine whether we know this name already. - CelVarDecl decl = findIdentDecl(cand, skipComprehensionScopes); + CelVarDecl decl = findIdentDecl(cand); if (decl != null) { return decl; } @@ -764,14 +750,10 @@ private void addOverload(CelFunctionDecl.Builder builder, CelOverloadDecl overlo builder.addOverloads(overload); } - /** - * Search for the named identifier declaration, optionally skipping the comprehension scopes on - * top of the stack. - */ - private @Nullable CelVarDecl findIdentDecl(String name, boolean skipComprehensionScopes) { - int topScope = decls.size() - 1 - (skipComprehensionScopes ? comprehensionScopeCount : 0); - for (int i = topScope; i >= 0; i--) { - CelVarDecl ident = decls.get(i).getIdent(name); + /** Search for the named identifier declaration. */ + private @Nullable CelVarDecl findIdentDecl(String name) { + for (DeclGroup declGroup : Lists.reverse(decls)) { + CelVarDecl ident = declGroup.getIdent(name); if (ident != null) { return ident; } diff --git a/checker/src/main/java/dev/cel/checker/ExprChecker.java b/checker/src/main/java/dev/cel/checker/ExprChecker.java index c028724a3..d1e037814 100644 --- a/checker/src/main/java/dev/cel/checker/ExprChecker.java +++ b/checker/src/main/java/dev/cel/checker/ExprChecker.java @@ -535,10 +535,10 @@ private void visit(CelMutableExpr expr, CelMutableComprehension compre) { } // Declare accumulation variable on outer scope. - env.enterComprehensionScope(); + env.enterScope(); env.add(CelVarDecl.newVarDeclaration(compre.accuVar(), accuType)); // Declare iteration variable on inner scope. - env.enterComprehensionScope(); + env.enterScope(); env.add(CelVarDecl.newVarDeclaration(compre.iterVar(), varType)); if (!Strings.isNullOrEmpty(compre.iterVar2())) { env.add(CelVarDecl.newVarDeclaration(compre.iterVar2(), varType2)); @@ -548,9 +548,9 @@ private void visit(CelMutableExpr expr, CelMutableComprehension compre) { visit(compre.loopStep()); assertType(compre.loopStep(), accuType); // Forget iteration variable, as result expression must only depend on accu. - env.exitComprehensionScope(); + env.exitScope(); visit(compre.result()); - env.exitComprehensionScope(); + env.exitScope(); env.setType(expr, inferenceContext.specialize(env.getType(compre.result()))); } diff --git a/checker/src/test/java/dev/cel/checker/ExprCheckerTest.java b/checker/src/test/java/dev/cel/checker/ExprCheckerTest.java index 2d3b8eeb7..824ea57ca 100644 --- a/checker/src/test/java/dev/cel/checker/ExprCheckerTest.java +++ b/checker/src/test/java/dev/cel/checker/ExprCheckerTest.java @@ -33,13 +33,11 @@ import dev.cel.common.CelMutableAst; import dev.cel.common.CelProtoAbstractSyntaxTree; import dev.cel.common.CelProtoDeclConverter; -import dev.cel.common.CelVarDecl; import dev.cel.common.ast.CelConstant; import dev.cel.common.internal.EnvVisitable; import dev.cel.common.internal.EnvVisitor; import dev.cel.common.internal.Errors; import dev.cel.common.types.CelType; -import dev.cel.common.types.CelTypeProvider; import dev.cel.common.types.ListType; import dev.cel.common.types.MapType; import dev.cel.common.types.NullableType; @@ -229,33 +227,6 @@ public void referenceTypeAbsolute() throws Exception { declareVariable("app.config", SimpleType.INT); source = "[0].exists(app, .app.config == 1)"; runTest(); - - source = "[1].all(int, type(int) == .int)"; - runTest(); - } - - @Test - @SuppressWarnings("deprecation") // ExprChecker is used directly to add a non-comprehension scope. - public void referenceAbsolute_declInNonComprehensionScope() throws Exception { - source = "[1].all(x, .x == 'a') && .x == 'a'"; - CelTypeProvider typeProvider = ProtoMessageTypeProvider.newBuilder().build(); - prepareCompiler(typeProvider); - Errors errors = new Errors("", source); - Env env = Env.standard(errors, typeProvider, null, TEST_OPTIONS); - env.enterScope(); - env.add(CelVarDecl.newVarDeclaration("x", SimpleType.STRING)); - - CelAbstractSyntaxTree ast = - ExprChecker.typecheck( - env, container, celCompiler.parse(source).getAst(), Optional.absent()); - - testOutput().println(errors.getAllErrorsAsString()); - testOutput() - .println( - CelDebug.toAdornedDebugString( - CelProtoAbstractSyntaxTree.fromCelAst(ast).getExpr(), - new CheckedExprAdorner( - CelProtoAbstractSyntaxTree.fromCelAst(ast).toCheckedExpr()))); } @Test diff --git a/checker/src/test/resources/referenceAbsolute_declInNonComprehensionScope.baseline b/checker/src/test/resources/referenceAbsolute_declInNonComprehensionScope.baseline deleted file mode 100644 index e63a1f129..000000000 --- a/checker/src/test/resources/referenceAbsolute_declInNonComprehensionScope.baseline +++ /dev/null @@ -1,34 +0,0 @@ -Source: [1].all(x, .x == 'a') && .x == 'a' -=====> - -_&&_( - __comprehension__( - // Variable - x, - // Target - [ - 1~int - ]~list(int), - // Accumulator - @result, - // Init - true~bool, - // LoopCondition - @not_strictly_false( - @result~bool^@result - )~bool^not_strictly_false, - // LoopStep - _&&_( - @result~bool^@result, - _==_( - .x~string^.x, - "a"~string - )~bool^equals - )~bool^logical_and, - // Result - @result~bool^@result)~bool, - _==_( - .x~string^.x, - "a"~string - )~bool^equals -)~bool^logical_and diff --git a/checker/src/test/resources/referenceTypeAbsolute.baseline b/checker/src/test/resources/referenceTypeAbsolute.baseline index 3d4a0c94d..401e6fe0c 100644 --- a/checker/src/test/resources/referenceTypeAbsolute.baseline +++ b/checker/src/test/resources/referenceTypeAbsolute.baseline @@ -34,36 +34,3 @@ __comprehension__( )~bool^logical_or, // Result @result~bool^@result)~bool - -Source: [1].all(int, type(int) == .int) -declare app.config { - value int -} -=====> -__comprehension__( - // Variable - int, - // Target - [ - 1~int - ]~list(int), - // Accumulator - @result, - // Init - true~bool, - // LoopCondition - @not_strictly_false( - @result~bool^@result - )~bool^not_strictly_false, - // LoopStep - _&&_( - @result~bool^@result, - _==_( - type( - int~int^int - )~type(int)^type, - .int~type(int)^.int - )~bool^equals - )~bool^logical_and, - // Result - @result~bool^@result)~bool