(source: Any, valid_ids: set[str], max_page: int)
| 177 | |
| 178 | |
| 179 | def source_grounding_errors(source: Any, valid_ids: set[str], max_page: int) -> list[str]: |
| 180 | if contains_old_reference(source): |
| 181 | return ["old_bundle_reference"] |
| 182 | if isinstance(source, str): |
| 183 | return [] if valid_section_id(source, valid_ids) else ["source_reference_unresolved"] |
| 184 | if not isinstance(source, dict): |
| 185 | return ["source_reference_invalid"] |
| 186 | |
| 187 | has_valid_section = valid_section_id(source.get("section_id", ""), valid_ids) |
| 188 | has_valid_pages = valid_pages(source.get("pages"), max_page) or valid_pages( |
| 189 | source.get("page_range"), |
| 190 | max_page, |
| 191 | ) |
| 192 | if has_valid_section or has_valid_pages: |
| 193 | return [] |
| 194 | return ["source_reference_missing_valid_section_or_pages"] |
| 195 | |
| 196 | |
| 197 | def validate_note_plan( |
no test coverage detected