Coverage for node / src / stigmem_node / models / lint.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-25 01:49 +0000

1"""Lint route wire-format models.""" 

2 

3from __future__ import annotations 

4 

5from typing import Literal 

6 

7from pydantic import BaseModel, Field 

8 

9LintCheck = Literal["contradiction", "stale", "orphan", "broken_ref", "namespacing"] 

10ALL_CHECKS: list[LintCheck] = ["contradiction", "stale", "orphan", "broken_ref", "namespacing"] 

11 

12 

13class LintRequest(BaseModel): 

14 scope: str = Field(..., description="Fact scope to sweep") 

15 checks: list[LintCheck] | None = Field(None, description="Checks to run; omit for all") 

16 entity: str | None = Field(None, description="Restrict to a specific entity URI") 

17 relation: str | None = Field(None, description="Restrict to a specific relation") 

18 stale_lookahead_s: int = Field(0, ge=0, description="Also flag facts expiring within N seconds") 

19 

20 

21class LintFinding(BaseModel): 

22 check: LintCheck 

23 severity: Literal["error", "warning", "info"] 

24 entity: str 

25 relation: str | None 

26 fact_ids: list[str] 

27 detail: str 

28 

29 

30class LintResult(BaseModel): 

31 findings: list[LintFinding] 

32 checked_at: str 

33 scope: str 

34 checks_run: list[LintCheck] 

35 fact_count: int