Source code for cadrumo.application.operator_surface.help_models
"""Import-light typed records for operator help and root landing output."""from__future__importannotationsfromenumimportStrEnumfromtypingimportAnnotatedfrompydanticimportBaseModel,Field,StringConstraints,model_validatorfrom...core.errors.hierarchyimportpydantic_validation_boundaryfrom.modelsimportOPERATOR_SURFACE_MODEL_CONFIG
[docs]classHelpSurface(StrEnum):"""Curated help surfaces accepted by :func:`build_help_document`."""ROOT="root"CONFIG="config"APP="app"
HelpLabel=Annotated[str,StringConstraints(min_length=1,max_length=80)]"""One line of the help surface: a command, its description, a section title."""HelpProse=Annotated[str,StringConstraints(min_length=1,max_length=120)]"""A heading or footer, which gets more room than a single help line."""
[docs]classHelpEntry(BaseModel):"""One localized command row in a curated :class:`HelpSection`."""model_config=OPERATOR_SURFACE_MODEL_CONFIGcommand:HelpLabeldescription:HelpLabel
[docs]classHelpSection(BaseModel):"""One workflow-ordered section in a curated :class:`HelpDocument`."""model_config=OPERATOR_SURFACE_MODEL_CONFIGtitle:HelpLabelentries:tuple[HelpEntry,...]=Field(min_length=1)
[docs]classHelpDocument(BaseModel):"""Localized operator-help document for one accepted surface."""model_config=OPERATOR_SURFACE_MODEL_CONFIGsurface:HelpSurfaceheading:HelpProseparagraphs:tuple[str,...]=Field(min_length=1)sections:tuple[HelpSection,...]=Field(min_length=1)footer:HelpProse
[docs]classRootLandingReport(BaseModel):"""Bare-root landing report built from caller-projected profile state."""model_config=OPERATOR_SURFACE_MODEL_CONFIGprofile_selected:bool=Falseactive_profile:str|None=Nonecommand:str=Field(min_length=1,max_length=120)message:str=Field(min_length=1,max_length=160)@model_validator(mode="after")@pydantic_validation_boundarydef_selected_profile_owns_display_identity(self)->RootLandingReport:"""Reject a display label that has no corresponding selected profile."""ifself.active_profileisnotNoneandnotself.profile_selected:raiseValueError("active profile label requires a selected profile")returnself