Write structured cold-start seed data back into roles.json for the matching role.
(
user_id: str,
profile: Dict[str, Any],
*,
explicit_text: Optional[str] = None,
scholar_url: Optional[str] = None,
homepage_url: Optional[str] = None,
scholar_result: Optional[Dict[str, Any]] = None,
homepage_result: Optional[Dict[str, Any]] = None,
)
| 318 | return "" |
| 319 | return f"direction: {', '.join(phrases[:6])}" |
| 320 | |
| 321 | |
| 322 | def sync_role_metadata_from_cold_start( |
| 323 | user_id: str, |
| 324 | profile: Dict[str, Any], |
| 325 | *, |
| 326 | explicit_text: Optional[str] = None, |
| 327 | scholar_url: Optional[str] = None, |
| 328 | homepage_url: Optional[str] = None, |
| 329 | scholar_result: Optional[Dict[str, Any]] = None, |
| 330 | homepage_result: Optional[Dict[str, Any]] = None, |
| 331 | ) -> bool: |
| 332 | """Write structured cold-start seed data back into roles.json for the matching role.""" |
| 333 | roles_meta = _load_roles_meta() |
| 334 | role_match = _find_role_entry_by_user_id(roles_meta, user_id) |
| 335 | if not role_match: |
| 336 | return False |
| 337 | |
| 338 | role_name, role_info = role_match |
| 339 | changed = False |
| 340 | seed_directions = _build_seed_directions(profile) |
| 341 | bootstrap_summary = _build_role_bootstrap_summary( |
| 342 | profile, |
| 343 | explicit_text=explicit_text, |
| 344 | seed_directions=seed_directions, |
| 345 | ) |
| 346 | |
| 347 | if bootstrap_summary and role_info.get("bootstrap_summary") != bootstrap_summary: |
| 348 | role_info["bootstrap_summary"] = bootstrap_summary |
| 349 | changed = True |
| 350 | |
| 351 | if not str(role_info.get("description") or "").strip() and bootstrap_summary: |
| 352 | role_info["description"] = bootstrap_summary |
| 353 | changed = True |
| 354 | |
| 355 | if seed_directions and role_info.get("seed_directions") != seed_directions: |
| 356 | role_info["seed_directions"] = seed_directions |
| 357 | changed = True |
| 358 | |
| 359 | for obsolete_key in ("scholar_url", "homepage_url", "scholar_seed", "homepage_seed"): |
| 360 | if obsolete_key in role_info: |
| 361 | del role_info[obsolete_key] |
| 362 | changed = True |
| 363 | |
| 364 | if not changed: |
| 365 | return False |
| 366 | |
| 367 | role_info["cold_start_updated_at"] = datetime.now().isoformat() |
| 368 | roles_meta.setdefault("roles", {})[role_name] = role_info |
| 369 | _save_roles_meta(roles_meta) |
| 370 | return True |
| 371 |
no test coverage detected