Skip to content

A class-body member line or a C++ prototype touches the class and the function it declares - #2362

Open
zlareb1 wants to merge 14 commits into
mainfrom
fix/filescope-cpp-placement
Open

zlareb1 wants to merge 14 commits into
mainfrom
fix/filescope-cpp-placement

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Related: #2040

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

A changed declaration line of a C++ class body outside its methods (a member, a static constant, a method prototype) or a Python class attribute or docstring line is placed on the class, and a C++ prototype also on the function it declares, so code.review_brief claims their coverage and answers covered_no_gaps or gaps where it answered unsettled on symbols:unmapped_changes. Braces, class heads, access specifiers, using, #include, namespace lines and file-scope constants still keep a brief open.

Why

unmapped_changes marks a changed source line in no function, and it keeps a review brief unsettled. A member or a prototype in a class body, and a prototype at file scope, counted as such a line, though each belongs to a definition the index holds: the class, and the function the prototype declares. A PR that adds a member to a class and uses it in a method could never settle, whatever the tests of that class say.

The change places such a line on that definition and makes it a subject of the brief (a class's data member or static constant is the class's like its other members: the brief claims the definition a change sits in, as for a function whose body changes, not the code that reads it; a file-scope constant sits in no definition, so it stays a change): it joins code.impact's touched_symbols, seeds the radius walk, and the tests section claims its coverage. So the brief settles only when that claim says covered_by, and an uncovered class or function answers gaps (uncovered_symbol). A settle on a change nothing covers is the outcome the rules are built against: a line is placed only on a definition whose claim decides it, as far as the index's rows are right. Where they are not, it is a known gap, named in the docs: a method whose head the parser cannot read (one spelled with a macro it does not expand) has no row, so a declaration in its body sits in the class body by the rows and is placed on the class alone, and so is one in an inline method of an unnamed struct. Placement reads the index's rows and the changed lines, not a parse of the indexed side, so it cannot tell such a body from the class's.

Seeding decision. The class (or declared function) a line is placed on is a walk seed like a changed function. An alternative was to make it a claim subject only. Seeding keeps one rule (every touched symbol seeds the radius and is claimed) and reaches what the index links to the class (its derived classes, the callers of what points at it). A class that holds only lines that stay changes (an access specifier, a brace) stays code.test_gate's alone, as before, and is not seeded.

What stays unmapped, and why.

  • Braces, a class head, an access specifier, using, friend, namespace and preprocessor lines, #include: they shape a scope, so they can move unchanged code into another one or change which overload an unchanged call picks, which no claim about one definition shows.
  • In C++, any class-body line that is not a whole declaration on its own line (ending with ;, with every bracket it opens closed there): the lines of a prototype or template head spread over lines (the head may be virtual), a macro call (FRIEND_TEST(...), check(x);), a statement (return x;), a base clause, a line holding virtual, override or final (they change which function a call through a base reaches, and the overrides are definitions no claim on the class covers), scope words after a member on one line (int x; private:), /*, */, a raw string's opener or a quote no literal closes.
  • In Python, any class-body line but an attribute or a docstring line that leaves no bracket open, below a line of code that leaves none open: a def, class or compound statement head, a decorator, a line with an odd count of triple quotes, a multi-line decorator's argument (it belongs to the method below it), a string line anywhere but right below the class's head (a dict key's value, an argument), and a line below a blank or comment line, where the brackets open above are not known.
  • A line below one ending with \ (a macro body) and a line starting a run the hunk shows no line above (a diff with no context).
  • A file-scope prototype whose candidate is not known to be a free function (it sits in a scope the diff's files do not show to be a namespace, so it may be a method of a class declared elsewhere), and one whose parentheses start with a literal (static const std::regex re("a+");, a constant).
  • A file-scope constant, static or extern declaration: the index links no C++ variable to its readers, and a Python reads edge records an attribute read (config.LIMIT, a typed receiver's field) but not a bare name read in its module or after from config import LIMIT. The readers the index holds are not all of them, so a claim on them would not decide the line.
  • A line of a function the new side pairs with no row (a function a merged PR deleted, an overload added), and any line where the new side was not read.

Registration. A registration statement inside a registration function (REGISTER_FUNCTION(X) { ... }, registerFoo(...)) is already that function's line; the index binds the registered class to it through its registration edges. In the measured set the only registration lines outside every function were registration functions' prototypes, declared in one file and defined in another: a prototype at file scope, once it passes the same whole-declaration check as a class-body line (so a virtual, override or friend line of a struct body, which is file scope here, stays a change), is placed on the function of its name in the same file or one of the same stem in its directory (never a function the compiler tier names in an anonymous namespace; the parser gives namespace { no scope, so without a compiler tier such a function reads as one of the namespace around it), or on a registration function by the index's own rule (registration.is_registration_caller), in each case only when the candidates in the diff's files outside tests share one qualified name and each is a free function: at global scope or in a scope the index shows to be a namespace (one that holds a class or struct row and neither is one nor sits in one; a class whose own row sits outside the diff's files, with a nested class's row in them, reads as one). A function in a scope nothing shows either way may be a method of a class whose row sits outside the diff, so a file-scope prototype is not placed on it; inside one .cpp an out-of-line method and a free function look the same in the rows, so the same file gets no exception. In a class body a prototype is placed only together with the function whose qualified name is the class's and its own (or an open PR's added function of that name); a prototype whose function the diff's files do not define stays a change, since its defaults and parameters reach the function's callers, which a claim on the class does not decide.

Parser change. The C++ parser gave no row to a class or struct defined in a class body or in a variable declaration (struct Options { ... }; inside a class, struct S { ... } s;), nor to a method under #elif: their lines read as lines of the class around them, so a statement in a nested type's inline method would have been placed on the outer class. parse_cpp now holds those rows (the nested type, its methods, #elif and #elifdef branches), so such a statement is its method's line and a nested struct's body stays a change. This is an extraction change: the C++ symbol stage (and the stages that follow it) re-runs for C++ files in every indexed repository, hours of ingest on a large one. On every 20th C++ file under ClickHouse's src/ (519 files) it adds 4.2% symbol rows (5,896 to 6,143), 2.7% chunks (11,287 to 11,593) and 0.8% chunk text to embed: a nested class gets its own skeleton chunk, and the outer class's skeleton keeps the nested text as before. A struct or class defined in a typedef gets a row as well, a union (nested or not) is a struct row, as a Thrift union is, a nested type's doc comment is the one above its declaration, and a pure-virtual method returning an elaborated type (virtual struct Result * make() = 0;) keeps its row. The new rows also give out-of-line definitions of nested-type methods (Pool::Options::reset in a .cpp) the header row they lacked. An unnamed class, struct or union still has no row. Until a repository's re-extraction lands, its rows lack the nested types: a member line of a nested type is placed on the outer class there, as the previous head of this branch did, and an open PR's overlay, parsed by the new parser, reads every inline method of a nested type or under #elif in a changed file as a function the PR adds (classify_symbols marks a qualified name no index row holds as added), so that brief claims them and may answer gaps for functions the PR did not add. Both end with the re-extraction, which every extractor change that adds rows goes through.

Assumptions about the repository, and why each is general.

  • C++ declaration syntax (a member ends with ;, a prototype is type name(...), a class body is between the class's lines in the index) and Python's class body as one indented scope: language rules, not conventions of one code base. Shell has no class or prototype, so nothing changes there; other languages keep their rule.
  • A header and its source share a stem (widget.h, widget.cpp): a common C and C++ layout; where it does not hold, the prototype stays unmapped, as today.
  • Registration functions are named by the index's existing registration rule; a repository with none places no prototype that way.
  • Definitions come from the index's own rows of the diff's files (kind, qualified_name, extents): nothing is read from a path layout, a test harness or a name list.

The new unit tests use a made-up repository (ui::Widget in src/ui/widget.h and widget.cpp, a Python Conf class) with none of ClickHouse's conventions.

Measurements

Replayed offline with the brief's own placement (place_lines with each side parsed as the ingest parses it), on the most recent first-parent merges of the ClickHouse repository that change C++ source, in both brief modes: merged (the reversed diff, index rows at the merge, new side at the parent, as #2315 measured) and open (index rows at the parent, new side at the merge, a name the parent lacks seeded on itself as the overlay seeds it). The second repository is Loom's own mirror (Python, the 100 most recent commits). Definitions keep the kinds the index stores; struct rows are passed for placement alone, as code.impact passes them, and in open mode the functions the head adds are passed as the overlay's added functions. Before is main, after is this head. The script is a one-off and not in the repository.

set briefs with unmapped_changes before after unmapped lines before after
ClickHouse, 46 merges, merged mode 34 33 3,258 3,007
ClickHouse, 200 merges, merged mode 159 153 16,709 15,901
ClickHouse, 46 merges, open mode 34 33 4,107 3,782
ClickHouse, 200 merges, open mode 158 152 16,183 14,869
Loom (Python), 100 commits, merged mode 77 77 7,127 6,230

No brief gained a line. In Loom's commits every brief that keeps the cause also holds a module-scope line (an import, a constant), so placing class attributes shrinks those briefs without settling one. Of the 153 that keep the cause (200 merges, merged mode), 123 hold an #include, using, brace, namespace, access or preprocessor line, 83 a file-scope constant, static or extern, 108 other file-scope code, 31 a line of a struct body, 59 a line of a function the new side pairs with no row; these are the cases above that stay unmapped by design. The ask's count (39 of 51 briefs with unmapped_changes as their only cause) is therefore cut by the member and prototype share only; the rest is code a claim about one definition cannot decide.

New verdicts. For the 6 merged ClickHouse PRs of the 200 whose unmapped_changes this change removes, the brief the service holds now (built by main) and code.coverage_claim of each subject the change adds, read on the live index, give:

  • 2 (#137035, #130699) answer gaps now for another cause (a randomized setting, a regression record) and keep it.
  • #136764 holds no unmapped_changes in the stored brief (an older build, a brief:v1 payload) and is unchanged.
  • #137335 settles: its only cause was symbols:unmapped_changes, and the new subjects (StorageKeeperMap, StorageKeeperMap::getRootPathWithPrefix) are covered_by on tests that name them (exact_scoped), as are its other claims.
  • #133236 moves from symbols:unmapped_changes to tests:cooccurrence_only: their claims rest on a test that changed with the source, which the brief does not settle on.
  • #137851 stays unsettled, now on tests:partly_covered: the class SSTFileReader its member line touches has an unknown claim. This is the case the design is for: the line no longer hides behind unmapped_changes, and the class decides it.

Three PRs an earlier head of this branch cleared keep the cause, each by a rule that refuses a placement it cannot prove: #135441 changes a member of Aggregator::Params, a struct nested in the class, which now has a row; #137526 changes a prototype in Context.h, a header the parser reads no rows of at that commit, so the line read as file scope and its candidate Context::mayUseTaskBasedParallelReplicas is a method; #137918 declares static ... toDataLakeStorageType(...) above its free function in the same .cpp, whose DB scope the file's rows do not show to be a namespace.

Hand check. A sample of placed lines in both repositories, read against the source: C++ members (mutable ASTPtr default_codec_description; on MergeTreeDataPartWriterOnDisk), a prototype on its class and the method it declares (HDFS::ClientPtr getClient() const; on HDFSObjectStorage and HDFSObjectStorage::getClient), a prototype spread over lines left a change, a file-scope prototype in a header on its function in the source of the same stem; Python model fields and model_config lines on their Pydantic classes and typed-dict fields on their class, where the line above is code; a field below a comment or a blank line stays a change. One limitation shows: in a template header whose method head is spelled with a macro the parser does not expand (static void NO_INLINE vectorVector(...)), the method's body lines sit in the class body by the index's rows, so a declaration in that body reads as a member line and lands on the class that holds the method. The docs say so.

Scope and risk

  • server/code/app/symbol/diff.py: unmapped_lines becomes place_lines, which returns Placement(unmapped, rows): the lines left in no definition, as before, and the rows the other lines outside every function are placed on (_place_member). An added line no function of the new side holds sits where its run sits in the index (_FileSpans.around: the innermost definition that holds the old lines on both sides of the run, found by bisection once per file). touched_by_diff combines _touched_rows_for_diff with the placement and is what code.impact reads.
  • server/code/app/symbol/cpp_members.py (new): member_line and declared_name, the C++ text rules; the Python rule is diff._python_member_line. Prototypes find their function through one index of the diff's function names per call (_Functions), so the cost stays linear in the lines. A run whose bounding lines sit in different rows is placed on the innermost row holding both, found through each row's parent.
  • C++ structs: the index serves struct rows to no claim, so code.impact reads the struct rows of the diff's C++ files in one more functions_for_paths call (in parallel with the new side, span impact.struct_rows), and place_lines leaves every line of a struct's body a change. A file-scope prototype never takes a method of a class or struct the index holds as its free function.
  • server/code/domain/extract/treesitter.py: parse_cpp walks a class or struct that is a declaration's type and the #elif/#elifdef branches (the parser change above).
  • Known limits, in the docs: a declaration inside a method the parser did not read (a head spelled with a macro) is placed on the class that holds it; an unnamed struct has no row, so its body reads as the scope around it; words are read as the line spells them (an override without override reads as a member); a file-scope prototype's namespace is not read.
  • server/code/app/symbol/impact.py: the diff shape's touched rows, seeds and causes come from touched_by_diff, which also gets the struct rows and the overlay's added functions; an added function a prototype is placed on is listed once. When the read of the diff's definitions or of its struct rows reaches its limit (2,000 rows), or the diff changes a file past the 200 paths whose rows are read, no line is placed (placing=False): a row the read cut off would leave its lines in the class around it, and a file with no rows read would put its class-body lines at file scope. The 2,000-row check is conservative: the read may return that many rows complete, and then the diff's lines stay changes.
  • code.test_gate is unchanged: it already places a class-body line on the class and counts its own unplaced lines. code.impact passes it the same rows as before, so impacted_tests still matches the gate; a function placed through a prototype seeds the walk and is claimed, but adds no gate row. Once a repository is re-extracted, a changed line of a nested class's body touches the nested class there (the innermost row), where it touched the outer class: a test that names only the outer class no longer links to that line.
  • The review brief's _unmapped (files the call graph is not built for, deleted files of an open PR) is unchanged.
  • The symbols section's note now reads "touched definitions", since it counts the classes placed lines touch as well; the pinned digest of test_code_review_brief_no_groups.py changes with that label alone (checked by building the brief with the old label, which gives the old digest).

Compatibility, rollout and rollback

  • Wire: no op or field added or removed. code.impact's touched_symbols may now hold a class (via: "hunk") or a function a prototype declares, and unmapped_changes is named for fewer diffs; the field comments of touched_symbols and causes say so, and the operations reference is regenerated.
  • Operator steps: none. The extractor stamp moves with the parser change, so each indexed repository's C++ files are re-extracted by the ingest on its own. A stored brief keeps the symbols section its build wrote until it is rebuilt.
  • Rollback: reverting brings back the rule that every class-body and file-scope line is unmapped.

Tests

  • tests/unit/test_code_diff_sides.py (git diffs of a made-up ui::Widget repository): test_a_member_line_or_a_prototype_is_placed_on_what_it_declares (a member, a changed default, a prototype of a defined function, with a trailing comment too, a file-scope prototype, on both sides of the diff); test_a_line_that_shapes_a_scope_or_names_no_definition_stays_unmapped (access, using, friend, a nested class head and braces, #if, a statement, a comment delimiter, a macro continuation, a file-scope constant, an include, a prototype nothing of its stem defines); test_a_file_scope_prototype_is_placed_only_on_one_definition (two qualified names of one name, a same-stem file in another directory, an anonymous-namespace function, a scope inside a known class, a header and source at the repository root, and a registration function's prototype); test_a_python_class_attribute_is_placed_on_the_class (an attribute, a docstring, a def head, a module line); test_a_line_in_an_unpaired_function_stays_unmapped; test_a_class_seeds_the_walk_only_through_a_line_placed_on_it; test_a_prototype_is_placed_on_the_function_of_its_class_outside_tests (another class of the same name, a test file); test_a_file_scope_prototype_is_not_placed_on_a_method (a class's, a struct's, a nested struct's); test_a_line_inside_a_python_decorator_stays_unmapped (a string below a dict key's : in a decorator's arguments too); test_a_line_between_two_inline_methods_is_placed_on_their_class; test_placing_many_prototypes_costs_time_linear_in_them; test_a_prototype_an_open_pr_adds_is_placed_on_the_function_it_adds; test_a_line_of_a_struct_body_stays_unmapped (a struct at file scope, one nested in a class, and a statement in a nested class's inline method, which is that method's line); test_a_member_below_a_line_it_continues_stays_unmapped (a lone virtual, a template head). The unmapped list also covers a prototype with no definition in the diff's files (with a trailing comment too), a braced default, a multi-line and a virtual multi-line prototype, struct-body virtual, override and friend lines, scope text after a member, a base clause, macro calls, virtual, a template head, raw strings and a direct-initialized constant; the Python test covers compound heads and an odd triple quote.
  • tests/unit/test_code_cpp_nested_types.py: the parser's rows for a nested struct and class, their methods, a struct defined in a variable declaration and one in a typedef, a pure-virtual method returning an elaborated type, a method under #elif, a nested type's doc comment, no row for a forward declaration, and a union as a struct row with its method.
  • tests/unit/test_code_epistemic_envelope.py::test_no_line_is_placed_when_a_changed_file_is_past_the_rows_read (200 files place, 201 do not).
  • tests/unit/test_code_diff_sides.py::test_no_line_is_placed_when_the_rows_were_not_all_read, and a static constant placed on its class in the placed list.
  • tests/unit/test_code_diff_sides.py::test_a_member_of_a_nested_class_is_placed_on_the_nested_class: a member line of a nested class goes to it, one of the outer class to the outer class.
  • tests/unit/test_code_review_brief_sections.py: test_a_member_line_of_a_class_body_is_claimed_on_the_class (merged and open: no cause, the class is claimed, covered_no_gaps when covered and gaps when the class is not); the cases that now place a member (the whole new file, the member below k, the wiring fixture, an inserted method whose head the new side lacks) assert the class rows; the "is a change" list keeps its scope lines and moves its member cases to hunks with no context or below a macro line, which stay unmapped.
  • Locally, on the last push: every unit file that uses touched_by_diff, place_lines, functions_for_paths or the impact module, with the impact, test-gate and review-brief files (1579 passed), and on the parser push every unit file that imports the C++ parser, the ingest parse or the extractor stamp, and every test_code_* file (7919 passed; one timing test, test_code_regex_cost.py::test_a_lane_walk_costs_linear_time[cpp-deep-includes], failed once on a loaded machine and passed rerun alone); make format-check; make lint; mypy on the changed modules (no error in them). test_doc_links.py needs markdown_it, which the local environment lacks; CI runs it.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. I checked the rules against the measured unmapped lines and their text, the placements against the source in both repositories, and each line kind left unmapped against what it can change in unchanged code.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

🤖 Generated with Claude Code


Note

Medium Risk
Changes how diff lines seed impact and whether review briefs report symbols:unmapped_changes, with new heuristics and a C++ parser change that triggers repository re-extraction.

Overview
Diff-shaped impact and review briefs no longer treat every class-body or file-scope declaration line as unmapped_changes. unmapped_lines is replaced by place_lines, which attaches qualifying out-of-function edits to index definitions; touched_by_diff merges that with existing hunk mapping and drives code.impact seeds and touched_symbols.

Placed edits include C++ member lines and prototypes (class + declared function when uniquely resolvable in the diff’s files), Python class attributes and class-head docstrings, and prototypes on overlay-added functions. Scope-shaping lines, file-scope constants, struct bodies, ambiguous prototypes, and lines without full index context still stay unmapped.

C++ extraction now emits rows for nested types inside member/typedef declarations and methods under #elif / #elifdef, so placement does not attribute those bodies to the outer class once re-ingested.

Docs, API field comments, and the brief symbols note (“touched definitions”) describe the new rules; extensive unit tests cover placement edge cases.

Reviewed by Cursor Bugbot for commit 703c0bf. Bugbot is set up for automated code reviews on this repo. Configure here.

zlareb1 and others added 2 commits December 6, 2026 06:06
…e function it declares

A C++ member line of a class body (a member, a static constant, a method
prototype) and a Python class attribute are placed on the class that holds
them, and a C++ prototype also on the function it declares when the diff's
files hold one definition of it. The placed definitions join code.impact's
touched symbols and seed the radius, so the review brief claims their
coverage instead of answering unsettled on unmapped_changes. Braces, class
heads, access specifiers, using, friend, namespace and preprocessor lines,
includes, file-scope constants and lines a macro continues stay unmapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 6, 2026 10:40am UTC
loom-telemetry Ready Ready Preview Dec 6, 2026 10:40am UTC

Request Review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/code/app/symbol/diff.py Resolved
Comment thread server/code/app/symbol/cpp_members.py Resolved
Comment thread server/code/app/symbol/diff.py Resolved
A C++ member line now has to read as a declaration and hold no scope word,
macro call, raw string or unclosed quote anywhere on it; a Python class-body
line that opens a compound statement or an odd number of triple quotes stays a
change. A file-scope line whose parentheses start with a literal is a
constant, not a prototype. Prototypes are matched by the class's full
qualified name through one index of the function names built per diff, never
against a test file. A run whose two bounding lines sit in different rows is
placed on the innermost row that holds both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/code/app/symbol/cpp_members.py Outdated
r"\b(?:using|friend|namespace|public|protected|private|class|struct|union|enum"
r"|template|typedef|return|throw|co_return|co_yield|co_await|if|else|for|while|do"
r"|switch|case|default|break|continue|goto|try|catch|operator)\b"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operator prototypes stay unmapped

Medium Severity

_CPP_SCOPE_WORDS treats operator as a scope or statement word, so member_line rejects method prototypes such as operator== and operator(). Those lines stay unmapped_changes and never touch the class, even though they are declarations. return already covers call expressions that use operator.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2bf7011. Configure here.

Comment thread server/code/app/symbol/cpp_members.py Resolved
zlareb1 and others added 2 commits December 6, 2026 06:47
…method are not placed

A Python class-body line is placed only when it is an attribute or a docstring
line below a line that leaves no bracket open, so a line inside a multi-line
decorator stays the method's change. A file-scope prototype no longer matches a
method of a class the diff's files hold. A C++ line holding virtual, override,
final or a template head's words stays unmapped. The Python rule moves out of
the C++ module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…s own line

A C++ member line must end with ';' and close every bracket it opens, so a
parameter line of a multi-line (possibly virtual) prototype or a template head
stays a change. A Python attribute line must leave no bracket open and sit
below a line of code that leaves none open; below a blank or comment line it
stays a change. code.test_gate's rows from code.impact are again exactly the
gate's own: placed prototypes seed the walk and are claimed, and no longer
reach impacted_tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

if depth < 0:
return False
if depth:
return False

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Angle brackets reject finished members

Medium Severity

member_line counts < and > as brackets that must balance, after stripping ->. A finished member or prototype that uses those characters as operators (int flags = 1 << 2;, bool ok = a > 0;, a default a < b) stays unmapped, so the brief keeps unmapped_changes. A template tail that does not end in ; is already dropped by the semicolon check.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9cfdd9e. Configure here.

depth += {"(": 1, "[": 1, "{": 1, ")": -1, "]": -1, "}": -1}.get(c, 0)
if depth < 0:
return False
return depth == 0 and not code.endswith(",")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fields after closers stay unmapped

Medium Severity

_closed fails as soon as bracket depth goes negative, and _python_member_line places an attribute only when the previous line passes that check. A field under the closing ) or ] of a multi-line value stays unmapped. The scan also counts brackets inside strings, so a previous line such as note = ":)" blocks the next attribute too.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9cfdd9e. Configure here.

… in its own directory

A file-scope line, which a struct's body is too, goes through the same
declaration check as a class-body line, so a virtual, override or friend
prototype stays a change. A C++ member line below a line that does not end a
declaration (a lone virtual or template head) stays a change. A same-stem
match requires the same directory and skips anonymous-namespace functions. A
Python string line is a docstring only right below the class head. Placed rows
keep the touched-row order, and the symbols note counts touched definitions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/code/app/symbol/diff.py Resolved
zlareb1 and others added 2 commits December 6, 2026 07:36
…t's lines stay changes

An in-class prototype whose function the diff's files do not define stays a
change: its defaults and parameters reach the callers, which a claim on the
class does not decide. So does one whose name a function in a scope nested in
the class shares. code.impact reads the C++ struct rows of the diff's files for
placement alone, and a line of a struct's body is placed on nothing. The pinned
brief digest follows the symbols note's new label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…on the wrong definition

The prototype name read drops a trailing // comment, and a class-body line
that names something before a ( but is not read as a prototype stays a
change rather than landing on the class alone. A file-scope prototype no
longer takes a struct's method, or a method of a scope nested in a class, as
a free function. An open PR's added functions are what its new prototypes
declare. code.impact reads the struct rows alongside the new side, in their
own span.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

return ""
if not in_class and (not words or rest.lstrip().startswith(_LITERAL_START)):
return ""
return name

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment split ignores string literals

Medium Severity

declared_name and names_call split on the first // without removing string literals, unlike member_line. A // inside a string ends the text early, so a real prototype no longer looks terminated and is not bound. On a class-body line, names_call still sees the (, so the line stays unmapped instead of being placed on the class and the function.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8ef5fd5. Configure here.

…ows to be one

A function in a scope the diff's files show nothing about may be a method
of a class declared elsewhere, so a file-scope prototype is placed only on a
function at global scope or in a scope that holds a class or struct row and
is none itself. The declaration pattern no longer backtracks on a long line
that declares nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/code/app/symbol/diff.py Resolved
A class or struct defined in a class body or a variable declaration, and a
method under `#elif`, got no row, so a statement in a nested type's inline
method read as a line of the outer class's body and was placed on it. They
are rows now, so such a line is its method's and a nested struct's body
stays a change. This changes C++ extraction: the symbol stage re-runs for
C++ files in every indexed repository.

The docs correct what the index's Python reads cover, and the placement
loop names its entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

zlareb1 and others added 2 commits December 6, 2026 09:49
…oc comment

A struct or class defined in a typedef is a row like one defined in a
member or a variable declaration, and its doc comment is the one above the
declaration. A pure-virtual method returning an elaborated type keeps its
row: only a type with a body is walked as a class. A member line of a
nested class is placed on the nested class.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…limit

A row the read cut off (a method, a struct) would leave its lines in the
class around it, so with either read at its limit every line outside a
function stays a change. The docs say why a class's static constant is
placed on the class while a file-scope one is not, and that a docstring is
read below any line ending with `:`. Two pattern alternatives no line could
reach are gone, and `_place_member` reads one side's text as one tuple.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

# row (a method, a struct) would leave its lines in the class around it
complete = len(definitions) < _ROWS_LIMIT and len(structs) < _ROWS_LIMIT
touched_rows, gate_touched, unmapped = touched_by_diff(
[*definitions, *structs], changes, new_side=new_side, added=added_rows, placing=complete

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placement skipped on complete reads

Medium Severity

placing is turned off whenever functions_for_paths returns at least _ROWS_LIMIT rows, but that read does not stop at limit. Each path batch is queried with max(limit, 300 * batch size), the batches are concatenated, and _prefer_scip collapses tiers. A diff whose files hold 2000 or more definitions or structs is therefore treated as truncated even when every row came back, so member lines and prototypes stay unmapped_changes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 984a9aa. Configure here.

…w a class head

A union nested in a class had no row, so a statement in its inline method
read as the outer class's body line; it is a struct row now, as a Thrift
union is. A Python string line is a docstring only right below the class's
head, not below another line ending with `:` such as a dict key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 7 total unresolved issues (including 6 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4c95601. Configure here.

Comment thread server/code/app/symbol/diff.py Resolved
A changed file past the first 200 paths has no rows, so its class-body
lines would read as file scope; placement is off then. A scope inside a
known class is no namespace, so a function in it is no free function for a
file-scope prototype. A header and its source at the repository root pair
by stem, and a docstring below a generic class head is read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants