Skip to content

Commit 8fb6dd7

Browse files
committed
Replace CallSite file+line with position
1 parent beccb8e commit 8fb6dd7

3 files changed

Lines changed: 30 additions & 12 deletions

File tree

‎skills/codealive-context-engine/scripts/lib/api_client.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,10 @@ def get_artifact_relationships(
628628
(identifier, filePath, startLine, shortSummary).
629629
630630
Call items additionally carry ``callSites`` — where the call is
631-
written (filePath, 1-based line, and a ``confidence`` only when the
632-
position is approximate) — and ``callSiteCount``, the pre-cap total.
633-
Their ABSENCE means the position is not indexed yet, never that the
634-
call does not happen.
631+
written (``position`` as ``path:line``, plus a ``confidence`` only
632+
when the position is approximate) — and ``callSiteCount``, the
633+
pre-cap total. Their ABSENCE means the position is not indexed yet,
634+
never that the call does not happen.
635635
"""
636636
profile_map = {
637637
"callsOnly": "calls_only",

‎skills/codealive-context-engine/scripts/relationships.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,16 @@ def _format_call_sites(item: dict) -> list:
159159

160160
lines = []
161161
for site in call_sites:
162-
file_path = (site or {}).get("filePath")
163-
line_number = (site or {}).get("line")
164-
if not file_path or not line_number:
162+
# The backend already spells a position as "path:line" — the form this line renders — so it is
163+
# printed verbatim rather than reassembled from parts.
164+
position = (site or {}).get("position")
165+
if not position:
165166
continue
166167

167168
# Confidence is shown only when the backend sent one; its absence means the position is exact.
168169
confidence = (site or {}).get("confidence")
169170
approximate = f" (~{confidence:.0%} confident)" if confidence is not None else ""
170-
lines.append(f" ↪ called at {file_path}:{line_number}{approximate}")
171+
lines.append(f" ↪ called at {position}{approximate}")
171172

172173
total = item.get("callSiteCount")
173174
if isinstance(total, int) and total > len(lines) > 0:

‎tests/test_relationship_call_sites.py‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _item(**overrides):
4141
def test_known_positions_are_rendered_as_call_sites() -> None:
4242
# Arrange
4343
item = _item(
44-
callSites=[{"filePath": "src/svc.py", "line": 17}],
44+
callSites=[{"position": "src/svc.py:17"}],
4545
callSiteCount=1,
4646
)
4747

@@ -56,8 +56,8 @@ def test_confidence_is_shown_only_when_the_position_is_approximate() -> None:
5656
# Arrange
5757
item = _item(
5858
callSites=[
59-
{"filePath": "src/svc.py", "line": 17},
60-
{"filePath": "src/svc.py", "line": 88, "confidence": 0.6},
59+
{"position": "src/svc.py:17"},
60+
{"position": "src/svc.py:88", "confidence": 0.6},
6161
],
6262
callSiteCount=2,
6363
)
@@ -73,7 +73,7 @@ def test_confidence_is_shown_only_when_the_position_is_approximate() -> None:
7373
def test_a_capped_list_says_how_many_were_withheld() -> None:
7474
# Arrange
7575
item = _item(
76-
callSites=[{"filePath": "src/svc.py", "line": 17}],
76+
callSites=[{"position": "src/svc.py:17"}],
7777
callSiteCount=4,
7878
)
7979

@@ -98,3 +98,20 @@ def test_an_unindexed_position_renders_nothing_at_all() -> None:
9898
# Assert
9999
assert from_missing == []
100100
assert from_empty == []
101+
102+
103+
def test_a_site_without_a_position_is_skipped_rather_than_rendered_blank() -> None:
104+
# Defensive: a malformed site from an older or partially rolled-back backend must not produce a
105+
# "called at" line pointing nowhere, which an agent would try to read.
106+
# Arrange
107+
item = _item(
108+
# The count is the pre-cap total of KNOWN positions, so a malformed entry does not raise it.
109+
callSites=[{"confidence": 0.6}, {"position": "src/svc.py:17"}],
110+
callSiteCount=1,
111+
)
112+
113+
# Act
114+
lines = relationships._format_call_sites(item)
115+
116+
# Assert
117+
assert lines == [" ↪ called at src/svc.py:17"]

0 commit comments

Comments
 (0)