add find deluta fields in diffrent streams add in profile

This commit is contained in:
larssand
2026-06-30 21:27:01 +02:00
parent 81c0ba34a6
commit baa3bb95e8
4 changed files with 74 additions and 3 deletions

View File

@@ -154,6 +154,30 @@ class ProfileSuggestionTests(unittest.TestCase):
self.assertEqual(rejected["constant_field"], "constant value")
self.assertEqual(rejected["request_id"], "too high cardinality")
def test_fields_shared_between_streams_are_default_profile_candidates(self):
events = []
for stream_id, stream_name in (("billing", "BillingApp"), ("orders", "OrdersApp")):
events.extend(
parse_log_line(
f"fgai_stream_id={stream_id} fgai_stream={stream_name} actor_id=user{index % 6} "
f"tenant_id=t{index % 3} workflow_state={'approved' if index % 2 else 'rejected'} "
f"result_code=r{index % 4} latency_ms={index % 9} created_at=2026-06-29T10:00:{index:02d}Z"
)
for index in range(1, 30)
)
suggestions = {item["stream_id"]: item for item in suggest_stream_profiles(events)}
for suggestion in suggestions.values():
profile = suggestion["profile"]
shared = {item["field"] for item in suggestion["shared_fields"]}
self.assertIn("workflow_state", shared)
self.assertIn("result_code", shared)
self.assertIn("latency_ms", shared)
self.assertIn("workflow_state", profile["categorical_fields"])
self.assertIn("result_code", profile["categorical_fields"])
self.assertIn("latency_ms", profile["numeric_fields"])
def test_applies_valid_llm_advice_and_rejects_unknown_fields(self):
suggestion = suggest_stream_profiles([
parse_log_line("fgai_stream_id=windows fgai_stream=Windows username=alice hostname=host01 eventid=4625 action=failure")