mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
[sweep] proactive: drop vestigial code-patterns surface from context package
Code indexing was removed, so _find_code_patterns always returned [] yet build_context_package still called it, ContextPackage.code_patterns stayed a live field, _build_summary advertised 'Found N code patterns', and _count_items counted it — a permanently-empty slot the system claimed to populate. The dead method, its call, the summary line, and the count reference are removed. The code_patterns field itself is retained (always-empty, serialized in to_dict and the optimal route response) for API/schema back-compat, marked deprecated in its docstring.
This commit is contained in:
@@ -7,7 +7,6 @@ Automatically injects relevant context when:
|
||||
|
||||
Searches for:
|
||||
- Similar past tasks and their learnings
|
||||
- Relevant code patterns
|
||||
- Applicable standards
|
||||
- Recent team decisions
|
||||
- Known issues related to the work
|
||||
@@ -37,6 +36,9 @@ class ContextPackage:
|
||||
agent_id: UUID | None = None
|
||||
similar_tasks: list[SearchResult] = field(default_factory=list)
|
||||
relevant_learnings: list[SearchResult] = field(default_factory=list)
|
||||
# Deprecated: code indexing was removed. Retained as an always-empty field
|
||||
# for API/schema back-compat (serialized in to_dict and the optimal route
|
||||
# response); never populated by build_context_package (#382).
|
||||
code_patterns: list[SearchResult] = field(default_factory=list)
|
||||
applicable_standards: list[SearchResult] = field(default_factory=list)
|
||||
recent_decisions: list[SearchResult] = field(default_factory=list)
|
||||
@@ -79,7 +81,6 @@ class ContextPackage:
|
||||
[
|
||||
self.similar_tasks,
|
||||
self.relevant_learnings,
|
||||
self.code_patterns,
|
||||
self.applicable_standards,
|
||||
self.recent_decisions,
|
||||
self.known_issues,
|
||||
@@ -127,9 +128,9 @@ class ProactiveKnowledgeService:
|
||||
Searches for:
|
||||
1. Similar past tasks
|
||||
2. Learnings from those tasks
|
||||
3. Relevant code patterns
|
||||
4. Applicable standards
|
||||
5. Recent decisions
|
||||
3. Applicable standards
|
||||
4. Recent decisions
|
||||
5. Known issues related to the work
|
||||
|
||||
Args:
|
||||
task_id: ID of the claimed task
|
||||
@@ -161,26 +162,20 @@ class ProactiveKnowledgeService:
|
||||
except Exception as e:
|
||||
logger.warning("Failed to get learnings", error=str(e))
|
||||
|
||||
# 3. Find relevant code patterns
|
||||
try:
|
||||
package.code_patterns = await self._find_code_patterns(query)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to find code patterns", error=str(e))
|
||||
|
||||
# 4. Get applicable standards
|
||||
# 3. Get applicable standards
|
||||
try:
|
||||
domain = self._infer_domain(task_type, task_description)
|
||||
package.applicable_standards = await self._get_applicable_standards(domain)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to get standards", error=str(e))
|
||||
|
||||
# 5. Find recent relevant decisions
|
||||
# 4. Find recent relevant decisions
|
||||
try:
|
||||
package.recent_decisions = await self._find_relevant_decisions(query)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to find decisions", error=str(e))
|
||||
|
||||
# 6. Check for known issues
|
||||
# 5. Check for known issues
|
||||
try:
|
||||
package.known_issues = await self._check_known_issues(query)
|
||||
except Exception as e:
|
||||
@@ -379,13 +374,6 @@ class ProactiveKnowledgeService:
|
||||
),
|
||||
)
|
||||
|
||||
async def _find_code_patterns(
|
||||
self, query: str, top_k: int = 3
|
||||
) -> list[SearchResult]:
|
||||
"""DEPRECATED: Code indexing has been removed."""
|
||||
_ = query, top_k # Unused
|
||||
return [] # Code index deprecated
|
||||
|
||||
async def _get_applicable_standards(
|
||||
self, domain: str, top_k: int = 5
|
||||
) -> list[SearchResult]:
|
||||
@@ -494,9 +482,6 @@ class ProactiveKnowledgeService:
|
||||
if package.relevant_learnings:
|
||||
parts.append(f"Found {len(package.relevant_learnings)} relevant learnings")
|
||||
|
||||
if package.code_patterns:
|
||||
parts.append(f"Found {len(package.code_patterns)} code patterns")
|
||||
|
||||
if package.applicable_standards:
|
||||
parts.append(f"{len(package.applicable_standards)} standards apply")
|
||||
|
||||
@@ -517,7 +502,6 @@ class ProactiveKnowledgeService:
|
||||
[
|
||||
len(package.similar_tasks),
|
||||
len(package.relevant_learnings),
|
||||
len(package.code_patterns),
|
||||
len(package.applicable_standards),
|
||||
len(package.recent_decisions),
|
||||
len(package.known_issues),
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
"""The code-patterns surface is vestigial — build_context_package must never
|
||||
populate it and the summary must never advertise it (#382).
|
||||
|
||||
Code indexing was removed, so ``ContextPackage.code_patterns`` is a permanently
|
||||
empty slot. These tests pin that ``on_task_claimed`` leaves it empty and the
|
||||
generated summary omits the code-patterns line, so no consumer can branch on a
|
||||
field the system claims to populate but doesn't.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
from roboco.models.optimal import IndexType, SearchResult
|
||||
from roboco.services.proactive import ContextPackage, ProactiveKnowledgeService
|
||||
|
||||
|
||||
def _result(content: str) -> SearchResult:
|
||||
return SearchResult(
|
||||
content=content,
|
||||
source="test",
|
||||
score=1.0,
|
||||
index_type=IndexType.JOURNALS,
|
||||
metadata={},
|
||||
)
|
||||
|
||||
|
||||
class _StubOptimal:
|
||||
"""Minimal stand-in returning one item per search surface."""
|
||||
|
||||
async def search(self, **_: Any) -> list[SearchResult]:
|
||||
return [_result("similar")]
|
||||
|
||||
async def search_learnings(self, **_: Any) -> list[SearchResult]:
|
||||
return [_result("learning")]
|
||||
|
||||
async def get_standards(self, **_: Any) -> list[SearchResult]:
|
||||
return [_result("standard")]
|
||||
|
||||
async def search_errors(self, **_: Any) -> list[SearchResult]:
|
||||
return [_result("issue")]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_on_task_claimed_never_populates_code_patterns() -> None:
|
||||
service = ProactiveKnowledgeService()
|
||||
await service.initialize(_StubOptimal())
|
||||
|
||||
package = await service.on_task_claimed(
|
||||
task_id=uuid4(),
|
||||
agent_id=uuid4(),
|
||||
task_title="Add auth endpoint",
|
||||
task_description="Implement login",
|
||||
task_type="feature",
|
||||
)
|
||||
|
||||
assert package.code_patterns == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_summary_omits_code_patterns_line() -> None:
|
||||
service = ProactiveKnowledgeService()
|
||||
await service.initialize(_StubOptimal())
|
||||
|
||||
package = await service.on_task_claimed(
|
||||
task_id=uuid4(),
|
||||
agent_id=uuid4(),
|
||||
task_title="Add auth endpoint",
|
||||
task_description="Implement login",
|
||||
task_type="feature",
|
||||
)
|
||||
|
||||
assert "code patterns" not in package.summary
|
||||
|
||||
|
||||
def test_context_package_field_back_compat_empty() -> None:
|
||||
"""The deprecated field stays present and default-empty for API back-compat."""
|
||||
pkg = ContextPackage()
|
||||
assert pkg.code_patterns == []
|
||||
assert "code_patterns" in pkg.to_dict()
|
||||
Reference in New Issue
Block a user