Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions potpie/context-engine/application/readers/infra_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Inputs: scope (service / env / file). Logic: bounded neighbourhood
traversal over claim edges with topology predicates (``DEFINED_IN``,
``DEPLOYED_TO``, ``DEPENDS_ON``, ``USES``, ``HOSTED_ON``, ``OWNED_BY``,
``PROVIDES``, ``IMPLEMENTED_IN``),
``USES_ADAPTER``, ``CONFIGURES``, ``DEPLOYED_WITH``),
environment-filtered via the ``environment`` edge property. Supports
blast-radius (incoming ``DEPENDS_ON`` traversal with depth). Supports
``as_of`` via the bitemporal predicate.
Expand Down Expand Up @@ -44,8 +44,6 @@
"DEPLOYED_WITH",
"HOSTED_ON",
"OWNED_BY",
"PROVIDES",
"IMPLEMENTED_IN",
)


Expand Down
9 changes: 8 additions & 1 deletion potpie/context-engine/domain/agent_context_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@
FALLBACK_ONLY_INCLUDES: frozenset[str] = PLANNED_INCLUDES

DEFAULT_INTENT_INCLUDES: dict[str, tuple[str, ...]] = {
"feature": ("coding_preferences", "infra_topology", "decisions", "owners", "docs"),
"feature": (
"coding_preferences",
"features",
"infra_topology",
"decisions",
"owners",
"docs",
),
"debugging": ("prior_bugs", "infra_topology", "timeline"),
"review": ("coding_preferences", "decisions", "timeline", "owners"),
"operations": ("infra_topology", "timeline", "owners"),
Expand Down
1 change: 0 additions & 1 deletion potpie/context-engine/domain/graph_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def _v(
"DEFINED_IN",
"HOSTED_ON",
"OWNED_BY",
"PROVIDES",
"EXPOSES",
),
traversal=True,
Expand Down
7 changes: 6 additions & 1 deletion potpie/context-engine/tests/unit/test_graph_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ def test_use_case_views_are_backed() -> None:

def test_traversal_flag_only_on_neighborhood_views() -> None:
traversal = {v.name for v in GRAPH_VIEWS.values() if v.traversal}
assert traversal == {"infra_topology.service_neighborhood", "features.feature_context"}
assert traversal == {
"infra_topology.service_neighborhood",
"features.feature_context",
}


def test_neighborhood_declares_depth_direction_environment() -> None:
spec = view_spec("infra_topology.service_neighborhood")
assert {"depth", "direction", "environment"} <= set(spec.inputs)
assert "PROVIDES" not in spec.inline_relations
Comment thread
coderabbitai[bot] marked this conversation as resolved.
assert "EXPOSES" in spec.inline_relations


def test_neighborhood_documents_environment_filter_rule() -> None:
Expand Down
62 changes: 62 additions & 0 deletions potpie/context-engine/tests/unit/test_read_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,65 @@ def test_intent_expands_to_backed_readers() -> None:
# readers; empty backed readers return no items, not unsupported includes.
assert "coding_preferences" in {i.include for i in env.items}
assert env.unsupported_includes == ()


def test_feature_intent_routes_feature_claims_to_features_include() -> None:
store = InMemoryClaimQueryStore()
store.add(
ClaimRow(
pot_id="p1",
predicate="PROVIDES",
subject_key="repo:github.com/acme/widgets",
object_key="feature:search",
evidence_strength="attested",
fact="widgets repo provides search",
properties={},
)
)
orch = ReadOrchestrator(claim_query=store)

env = orch.resolve(
pot_id="p1",
intent="feature",
scope={"anchor_entity_key": "repo:github.com/acme/widgets"},
)

includes = [item.include for item in env.items]
assert "features" in includes
assert "infra_topology" not in includes


def test_infra_topology_excludes_feature_predicates() -> None:
store = InMemoryClaimQueryStore()
store.add(
ClaimRow(
pot_id="p1",
predicate="DEFINED_IN",
subject_key="service:search-api",
object_key="repo:github.com/acme/widgets",
evidence_strength="attested",
fact="search api lives in widgets repo",
properties={},
)
)
store.add(
ClaimRow(
pot_id="p1",
predicate="PROVIDES",
subject_key="repo:github.com/acme/widgets",
object_key="feature:search",
evidence_strength="attested",
fact="widgets repo provides search",
properties={},
)
)
orch = ReadOrchestrator(claim_query=store)

env = orch.resolve(
pot_id="p1",
include=["infra_topology"],
scope={"anchor_entity_key": "repo:github.com/acme/widgets"},
)

assert [item.include for item in env.items] == ["infra_topology"]
assert env.items[0].payload["predicate"] == "DEFINED_IN"
Loading