"""Skill group updates that preserve recommender-assigned categories. apply_update_skill_groups lives in an over-limit module and keeps keyword-only classification for manual patch edits; this wrapper reuses its cleaning and then re-groups with the recommender's (LLM) categories, which win over keywords. """ from __future__ import annotations from typing import Any from .resume_document_mutations import apply_update_skill_groups from .skill_classifier import classify_skills def update_skill_groups( content: dict[str, Any], skills: list[Any], preferred_categories: dict[str, str] | None = None ) -> dict[str, Any]: result = apply_update_skill_groups(content, skills) flat = [skill for group in result.get("skill_groups") or [] for skill in group.get("skills") or []] result["skill_groups"] = classify_skills(flat, preferred=preferred_categories) return result