vibe.review.parsing.profiles.loader

Load and manage document family profiles.

Profile YAML format:

profile_id: two_column_law_firm
name: "Two-Column Law Firm Template"
extends: base
rules:
  - rules/layout/header_footer.yml
  - rules/structure/heading_detection.yml
overrides:
  layout:
    column_gap_threshold: 30
    header_region_ratio: 0.15
  structure:
    heading_max_length: 200

Profile

A document family profile.

Attributes:
  • profile_id (str) –

    Unique identifier.

  • name (str) –

    Human-readable name.

  • extends (str | None) –

    Parent profile ID (if any).

  • rules (list[Rule]) –

    List of Rule objects.

  • overrides (dict[str, dict[str, Any]]) –

    Configuration overrides by layer.

  • description (str) –

    Optional description.

get_override

get_override(layer: str, key: str, default: object = None) -> object

Get a configuration override value.

ProfileRegistry

Registry for document profiles.

Manages loading profiles from built-in and user directories, with user profiles able to extend or override built-in ones.

__init__

__init__(builtin_dir: Path | None = None, user_dir: Path | None = None) -> None

Initialize the registry.

Parameters:
  • builtin_dir (Path | None, default: None ) –

    Directory containing built-in profiles.

  • user_dir (Path | None, default: None ) –

    Directory containing user profiles.

get

get(profile_id: str) -> Profile | None

Get a profile by ID.

list_profiles

list_profiles() -> list[str]

List all profile IDs.

resolve

resolve(profile_id: str) -> Profile

Resolve a profile with its parent chain.

Returns a new Profile with merged rules and overrides.

load_profile

load_profile(yaml_path: Path, base_dir: Path | None = None) -> Profile | None

Load a profile from a YAML file.

Parameters:
  • yaml_path (Path) –

    Path to profile YAML file.

  • base_dir (Path | None, default: None ) –

    Base directory for resolving rule paths.

Returns:
  • Profile | None

    Profile object or None on error.