Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [Improve] Align HugeCountStrategy with upstream TINKERPOP-2911…

  1. User

    ISSUE DESCRIPTION

    [Improve] Align HugeCountStrategy with upstream TINKERPOP-2911 ConnectiveStep fixes

    Feature Description (功能描述)

    Background

    PR #2993 introduced HugeCountStrategy to fix the negative-bound optimization issues behind #2930, #2931, and #2932.

    That fix was implemented by forking an older version of TinkerPop's CountStrategy and adding HugeGraph-specific guards for negative bounds.

    However, the current local fork does not yet include the upstream follow-up fix for ConnectiveStep / and() / or() handling from TINKERPOP-2911.

    As a result, HugeGraph is now aligned for the negative-bound cases fixed in #2993, but it may still inherit older CountStrategy behavior for some connective-filter patterns.

    Follow-up Scope

    Port the upstream TINKERPOP-2911 changes for ConnectiveStep into HugeCountStrategy, and add regression coverage for connective traversal shapes.

    Suggested regression cases include:

    • __.and(__.out().count().is(0), __.in().count().is(0))
    • __.or(__.out().count().is(0), __.in().count().is(0))
    • __.where(__.or(__.out("none").out().count().is(0), __.has("none")))
    • __.where(__.or(__.out("none").out().count().is(0), __.has("none").count().is(0)))

    Expected Result

    • HugeCountStrategy should behave consistently with the upstream CountStrategy fixes around ConnectiveStep
    • connective and()/or() traversal shapes should no longer rely on older inherited behavior from the forked strategy
    • regression tests should cover the above traversal forms and protect against future drift

    I’d be happy to follow up on this as a separate improvement issue and work on a later refinement PR.

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /hugegraph, current file: none) bash-$

  2. GLM Assistant

    I'll start by exploring the repository structure to understand the codebase and find the relevant files mentioned in the issue.

  3. GLM Assistant

    Now let me look at the test file:

  4. GLM Assistant

    Now let me look at the upstream TinkerPop CountStrategy to understand what TINKERPOP-2911 changes look like. Let me check the TinkerPop dependency version:

  5. GLM Assistant

    Let me get the full decompiled output of the upstream CountStrategy to understand the TINKERPOP-2911 changes:

  6. GLM Assistant

    Now let me look at the TINKERPOP-2911 fix details. Let me check the ConnectiveStep handling difference. The key change in TINKERPOP-2911 is in doStrategy: it adds a check for ConnectiveStep as the parent. Let me look more closely at the upstream doStrategy:

  7. GLM Assistant

    Let me look for the TINKERPOP-2911 source code. The key issue is about ConnectiveStep handling. Let me look at the upstream source from the TinkerPop github:

  8. GLM Assistant

    Now let me understand the key difference in TINKERPOP-2911. Let me search for the source of the upstream CountStrategy. The key change is that in doStrategy, it adds ConnectiveStep as a special case - when the parent is a ConnectiveStep, it should also do the strategy. Let me look at the actual source:

  9. GLM Assistant

    Now I can see the key changes in TINKERPOP-2911. Let me also check the HugeCountStrategy version and the git history to understand what was already fixed:

  10. GLM Assistant

    Now I have a clear picture. Let me check if TraversalHelper.removeAllSteps exists in 3.5.1:

  11. GLM Assistant

    Good, removeAllSteps exists. Now let me compare the current HugeCountStrategy with the latest upstream. Let me understand the key differences:

    1. TINKERPOP-2911 ConnectiveStep handling: The upstream 3.7.0 version added special handling for ConnectiveStep parents: when parent instanceof ConnectiveStep, it wraps the child of and()/or() in not() using transformToNotStep and removeAllSteps. The current HugeGraph version uses the older code path that falls into the else branch (prev-based NotStep handling) for ConnectiveStep.

    2. transformToNotStep uses traversal.clone() instead of traversal directly - the current HugeGraph code uses traversal directly.

    3. highRange < 0 ? 0 : highRange in RangeGlobalStep - the HugeGraph version already handles this with a separate if (highRange != null && highRange < 0L) { highRange = null; } block (which is actually different - it nullifies instead of clamping to 0).

    Let me first create a test to reproduce the issue with connective traversals:

  12. GLM Assistant

    Now let me write a reproduction test to understand what the current behavior is. Let me create a temporary test:

  13. GLM Assistant

    Need to add the license header. Let me fix the test file:

  14. GLM Assistant

    The "none" edge label needs to exist in schema for HugeGraph. Let me update the test to add those schema items (with no data, so they return empty):

  15. GLM Assistant

    I found the bug. testWhereOrWithNoneAndHasNone expects 3 (all vertices match because out("none").out().count().is(0) is true for all), but returns 0. This is the ConnectiveStep handling bug.

    Let me now look at the current HugeCountStrategy code more carefully and apply the TINKERPOP-2911 fix:

  16. GLM Assistant

    Now I'll apply the TINKERPOP-2911 fix. Let me replace the if (!dismissCountIs) block to add ConnectiveStep handling:

  17. GLM Assistant

    Let me use the edit command instead. First let me view the exact lines to replace:

  18. GLM Assistant

    Now let me add the transformToNotStep helper method. Let me view the end of the file:

  19. GLM Assistant

    I see there's a duplication. Let me fix lines 272-317:

  20. GLM Assistant

    Now let me verify the file compiles by building the core module:

  21. GLM Assistant

    There's a generics type inference issue. The upstream uses raw Step type. Let me fix the filterStep declaration:

  22. GLM Assistant

    Now let me try to compile again:

  23. GLM Assistant

    It compiles. Now let me run the reproduction test:

  24. GLM Assistant

    Need to use -am flag to build dependencies:

  25. GLM Assistant

    All 4 tests pass. The key fix: testWhereOrWithNoneAndHasNone went from 0 (wrong) to 3 (correct). Now let me run the existing CountStrategyCoreTest to ensure nothing broke:

  26. GLM Assistant

    All 19 existing tests pass. Now let me add regression tests for the connective traversal shapes to the existing test file. First, let me clean up my temp test:

  27. GLM Assistant

    Now let me add regression tests to the CountStrategyCoreTest file. Let me open the end of the test file:

  28. GLM Assistant

    Let me look at the end of the test file to add new tests. I need to add regression tests for the connective traversal shapes mentioned in the issue:

    • __.and(__.out().count().is(0), __.in().count().is(0))
    • __.or(__.out().count().is(0), __.in().count().is(0))
    • __.where(__.or(__.out("none").out().count().is(0), __.has("none")))
    • __.where(__.or(__.out("none").out().count().is(0), __.has("none").count().is(0)))

    I need a schema with "none" edge label and "none" property key. Let me add a separate init method or extend the existing initSchema. I'll add a separate helper for the connective tests that includes "none" label/key.

    Let me view the end of the file first.

  29. GLM Assistant

    Now let me add the regression tests. I'll add a new schema init method that includes the "none" label/key, and add tests for the connective traversal shapes:

  30. GLM Assistant

    Let me check the expected values more carefully. Let me verify the graph structure and correct the assertions. Let me run the tests to see actual values:

  31. GLM Assistant

    The actual values match my careful semantic derivation. Let me fix the assertions and comments to be correct:

    • testAndConnectiveCountIsZero: and(out==0, in==0) → no vertex has both 0 out and 0 in → 0
    • testOrConnectiveCountIsZero: or(out==0, in==0) → marko(in=0), josh(out=0), lop(out=0) → 3
    • testOrConnectiveWithNegativeBoundKeepsSemantics: or(out.lt(-1) [always false], in==0) → marko(in=0) → 1
  32. GLM Assistant

    Now let me fix the last assertion for testOrConnectiveWithNegativeBoundKeepsSemantics:

  33. GLM Assistant

    Now let me run the full test suite again:

  34. GLM Assistant

    All 25 tests pass (19 existing + 6 new). Now let me verify the fix doesn't break the negative-bound regression by checking that the strategy is being properly applied. Let me also verify the fix actually transforms the traversal correctly by writing a quick verification script that prints the traversal after strategy application:

  35. GLM Assistant

    Let me remove the verification script since the tests already confirm correctness:

  36. GLM Assistant

    Now let me verify the old behavior was actually broken by reverting the fix temporarily and running the new tests. First, let me check the diff of my changes:

  37. GLM Assistant

    Let me verify the old behavior was broken by temporarily stashing my fix and running just the new tests:

  38. GLM Assistant

    This confirms the bug exists in the old code: testWhereOrWithNonExistentLabelAndHasNone fails with expected:<3> but was:<0>. Now let me restore my fix:

  39. GLM Assistant

    I see there's a pom.xml modification. Let me check what that is:

  40. GLM Assistant

    The pom.xml changes are unrelated to my fix (they appear to be pre-existing environment modifications for lombok/compiler plugin). Let me revert them to keep my submission focused:

  41. GLM Assistant

    Now let me run the full test suite one more time to confirm everything passes after the pom.xml revert:

  42. GLM Assistant

    All 25 tests pass. Now let me also run a broader set of related tests to make sure I haven't broken anything else. Let me check what other test classes might be affected by the CountStrategy change:

  43. GLM Assistant

    Let me find the test method name and run it to confirm it still works with the connective + repeat pattern:

  44. GLM Assistant

    That test passes. Now let me run a broader test to check for any regressions. Let me run the full EdgeCoreTest and VertexCoreTest which are the most likely to use traversals:

  45. GLM Assistant

    All 168 EdgeCoreTest tests pass. Let me also check there's a TinkerPop test suite that might be relevant. Let me search for any count strategy related tests in the test suite:

  46. GLM Assistant

    Good, only those two test files use count().is(). Both pass now. Let me also verify the final state of the HugeCountStrategy file is correct:

  47. GLM Assistant

    The implementation looks correct and matches the upstream TINKERPOP-2911 approach. Let me run the full CountStrategyCoreTest one final time and verify no temp files are left:

  48. GLM Assistant

    No temp files left. Let me run the full CountStrategyCoreTest suite one final time to confirm everything is green:

  49. GLM Assistant

    All 25 tests pass. Let me do a final review of the complete diff:

  50. GLM Assistant

    The diff is clean and focused. Let me do a final verification run of both affected test suites together:

  51. GLM Assistant

    All tests pass. Let me now go through the checklist before submitting:

    Checklist Review

    • [x] If an error was reported in the issue description, I have successfully reproduced it. — Yes. The issue described that connective and()/or() traversal shapes still rely on older inherited CountStrategy behavior. I reproduced the concrete bug: __.where(__.or(__.out("none").out().count().is(0), __.has("none"))) returned 0 matching vertices with the old code, when it should return 3 (since out("none") yields nothing, making count().is(0) always true).

    • [x] If an error was reported in the issue description, I have confirmed that my fix resolves the error. — Yes. After porting the TINKERPOP-2911 ConnectiveStep handling, the same traversal correctly returns 3. I verified by stashing the fix and confirming the test failed with old code (expected:<3> but was:<0>), then restoring the fix and confirming it passes.

    • [x] I have thought about edge cases and made sure my fix handles them as well. — Yes. I considered: (a) connective children with prefix steps before count() (e.g., out("none").out().count().is(0)) — now the whole prefix is wrapped in not(); (b) connective children with negative bounds — the #2993/TINKERPOP-2893 guards still fire (useNotStep/dismissCountIs set false, negative highRange nullified), preserving semantics; (c) empty child after removing count+is — transformToNotStep falls back to __.identity(); (d) the non-connective FilterStep case — refactored to use transformToNotStep with clone() (matches upstream, equivalent behavior, existing tests pass); (e) repeat().until(or(...)) connective pattern used in EdgeCoreTest#testQueryCountAsCondition — still passes.

    • [x] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. — Yes. CountStrategyCoreTest (25 tests: 19 existing + 6 new) and EdgeCoreTest (168 tests, including testQueryCountAsCondition which uses or(inE().count().is(0), loops().is(3)) inside repeat/until) all pass.

    The solution ports the upstream TINKERPOP-2911 ConnectiveStep fix into HugeCountStrategy:

    1. Added an explicit parent instanceof ConnectiveStep branch that wraps the entire child traversal in a NotStep (via a new transformToNotStep helper), then replaces the child's steps with just that NotStep — instead of the old behavior that only rewrote the trailing step before count() and discarded prefix steps.
    2. Refactored the FilterStep branch to reuse transformToNotStep (which uses traversal.clone() so the original traversal can be safely cleared).
    3. Added 6 regression tests covering the suggested connective traversal shapes plus negative-bound connective cases.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.