MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / classify_checkfile_role

Function classify_checkfile_role

scripts/drift_engine.py:263–285  ·  view source on GitHub ↗
(checkfile: Dict[str, Any])

Source from the content-addressed store, hash-verified

261
262def classify_checkfile_role(checkfile: Dict[str, Any]) -> str:
263 explicit_role = str(checkfile.get("trigger_role") or "").strip()
264 if explicit_role:
265 return explicit_role
266
267 name = str(checkfile.get("name") or "").strip().lower()
268 drift_method = str(checkfile.get("drift_method") or "").strip().lower()
269 trigger_type = str((checkfile.get("trigger") or {}).get("type") or "").strip().lower()
270
271 if name in {"topic_shift", "author_shift", "keyword_shift", "inactive_topic_decay"}:
272 return CHECKFILE_ROLE_START_OBSERVING
273 if drift_method in {"topic_weight_decay", "must_read_replace", "keyword_emergence"}:
274 return CHECKFILE_ROLE_START_OBSERVING
275 if trigger_type in {"selected_paper_topic_match", "keyword_frequency", "author_exposure", "inactive_topic_decay"}:
276 return CHECKFILE_ROLE_START_OBSERVING
277
278 if name == "direction_remove" or drift_method == "direction_remove" or trigger_type == "low_engagement":
279 return CHECKFILE_ROLE_SUPPRESS_OLD_TOPICS
280
281 if name == "direction_add" or drift_method == "direction_add" or trigger_type == "direction_exposure":
282 return CHECKFILE_ROLE_SUPPORT_SHIFT
283
284 return CHECKFILE_ROLE_SUPPORT_SHIFT
285
286
287def filter_checkfiles_by_role(checkfiles: List[Dict[str, Any]], *roles: str) -> List[Dict[str, Any]]:
288 allowed_roles = {str(role).strip() for role in roles if str(role).strip()}

Callers 1

Calls 1

getMethod · 0.80

Tested by

no test coverage detected