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

Function _select_seed_directions

scripts/clear_database.py:89–118  ·  view source on GitHub ↗

Choose 2-3 stable seed directions for a role.

(role_name: str, parsed: Dict[str, Any])

Source from the content-addressed store, hash-verified

87
88
89def _select_seed_directions(role_name: str, parsed: Dict[str, Any]) -> Dict[str, float]:
90 """Choose 2-3 stable seed directions for a role."""
91 core_directions = _prune_redundant_directions(parsed.get("core_directions") or {})
92 if not core_directions:
93 return {}
94
95 selected_keys = []
96 for direction_key in ROLE_DIRECTION_OVERRIDES.get(role_name, []):
97 if direction_key in core_directions and direction_key not in selected_keys:
98 selected_keys.append(direction_key)
99
100 if len(selected_keys) < 2:
101 for direction_key, _weight in sorted(
102 core_directions.items(),
103 key=lambda item: (-float(item[1]), item[0]),
104 ):
105 if direction_key not in selected_keys:
106 selected_keys.append(direction_key)
107 if len(selected_keys) >= 3:
108 break
109 else:
110 selected_keys = selected_keys[:3]
111
112 if len(selected_keys) < 2:
113 selected_keys = selected_keys[: min(3, len(core_directions))]
114
115 return {
116 direction_key: round(float(core_directions[direction_key]), 4)
117 for direction_key in selected_keys
118 }
119
120
121def _extract_seed_directions_from_role(role_data: Dict[str, Any]) -> Dict[str, float]:

Callers 1

build_seed_profileFunction · 0.85

Calls 2

getMethod · 0.80

Tested by

no test coverage detected