Skip to content

fix(context): count a traced pair's hotness once per caller - #3533

Merged
vitali87 merged 1 commit into
mainfrom
fix/3532-hotness-once-per-pair
Nov 1, 2026
Merged

vitali87 merged 1 commit into
mainfrom
fix/3532-hotness-once-per-pair

Conversation

@vitali87

Copy link
Copy Markdown
Owner

Summary

Demo

No change on the default embedded engine today: there the observation currently lands on one site of the pair, so the sum and the single count agree. On Memgraph, every site carries it, so a caller with several sites was ranked by the inflated sum. #3529 brings the embedded engine to every site as well. The new test shows the counts.

Type of Change

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring (no functional changes)
  • Documentation
  • CI/CD or tooling
  • Dependencies

Related Issues

Closes #3532

Test Plan

  • Unit tests pass (make test-parallel or uv run pytest -n auto -m "not integration")
  • New tests added
  • Integration tests pass (make test-integration, requires Docker)
  • Manual testing (describe below)

Red first: test_hotness_counts_a_traced_pair_once_however_many_sites_it_has failed on main, with run (two sites, observed 5 times) at 10. Green: 32 passed across test_context_slice.py, test_context_source_root.py and test_context_slice_normalisation.py.

Negative test: in that same test, two call sites do not make run (5) hotter than other, which the trace observed 7 times.

Checklist

  • PR title follows Conventional Commits format
  • A breaking change has ! in the title and its release notes in changes/breaking/<PR number>.md (see Breaking changes)
  • All pre-commit checks pass (make pre-commit)
  • No hardcoded strings in non-config/non-constants files
  • No # type: ignore, cast(), Any, or object type hints
  • New comments and docstrings explain why, not what (see Comment Policy)

Trace confirmation writes a pair's observation onto each of its static
sites, so the hotness query returns one row per call site, each with the
pair's whole dynamic_call_count. _hotness summed them, and a caller with
two call sites to the target read as twice as hot as the trace observed.
It now takes the count once per caller.

Closes #3532
@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerTREX TREX

Tested 2 flows, found no issues.

What we tested

  • Pass · Rank traced callers with cgr context · View ↗
  • Pass · Rank traced callers through MCP context · View ↗

@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0c97225 and b7c0787.

Files selected for processing: 2
  • codebase_rag/context_slice.py
  • codebase_rag/tests/test_context_slice.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T19:08:41.726361Z b7c0787 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Fixes caller ranking in context by counting a traced caller–callee pair once.

  • Context slices count each caller's traced hotness once.

Reviews (1) · Last reviewed commit: "fix(context): count a traced pair's hotn..." · Reviewed by Greptile

@sonarqubecloud

Copy link
Copy Markdown

@vitali87
vitali87 merged commit c1cdc19 into main Nov 1, 2026
43 checks passed
@vitali87
vitali87 deleted the fix/3532-hotness-once-per-pair branch November 1, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: context slice adds a traced pair's dynamic_call_count once per call site, so hotness over-counts callers with several sites

1 participant