Skip to content

lawref.query

LawQL — детерминированные запросы к CLIR как к данным.

Пакет намеренно не входит в семантический путь evaluator: структурный слой только реифицирует уже построенный CLIR, а материализации вызывают существующий lawref.evaluator.evaluate явно.

Classes

NameDescription
FactStoreNo description.
QueryEngineNo description.
QueryErrorNo description.
QueryResultNo description.

Functions

NameDescription
load_corpusСнимок корпуса в FactStore.
mainNo description.
parseNo description.

Modules

  • cliCLI python -m lawref query для LawQL.
  • engineНаивный детерминированный join-движок LawQL (Ф2/Ф3).
  • errorsСтруктурные диагностики LawQL (LDC-Qxxxx).
  • factsРеификация CLIR в плоские отношения LawQL (DECISION-0079, Ф1).
  • inferenceФ5: query … over … → эфемерный CLIR → существующие движки ядра.
  • materializeЯвные eval()-материализации LawQL (Ф3).
  • parserРекурсивный спуск LawQL без внешних зависимостей (Ф2/Ф3/Ф5).

FactStoreclassdataclass#

class FactStore(relations: dict[str, list[dict]] = lambda : {name: [] for name in RELATION_FIELDS}(), documents: list[dict] = list(), node_kinds: tuple[str, ...] = schema_node_kinds(), node_count: int = 0, enabled_relations: set[str] = lambda : set(RELATION_FIELDS)(), _by_id: dict[str, dict] = dict(), _doc_by_package: dict[str, dict] = dict(), _parameter_owners: dict[str, str] = dict())

documentsattributeclass attributeinstance attribute#

documents: list[dict] = field(default_factory=list)

enabled_relationsattributeclass attributeinstance attribute#

enabled_relations: set[str] = field(default_factory=lambda : set(RELATION_FIELDS))

node_countattributeclass attributeinstance attribute#

node_count: int = 0

node_kindsattributeclass attributeinstance attribute#

node_kinds: tuple[str, ...] = field(default_factory=schema_node_kinds)

relationsattributeclass attributeinstance attribute#

relations: dict[str, list[dict]] = field(default_factory=lambda : {name: [] for name in RELATION_FIELDS})

add_documentmethod#

def add_document(document: dict, path: Path, law_path: str | None = None) -> None

documentmethod#

def document(package: str) -> dict | None

finalizemethod#

def finalize() -> None

nodemethod#

def node(node_id: str) -> dict | None

rowsmethod#

def rows(relation: str, package_glob: str = '*') -> list[dict]

schemamethod#

def schema() -> dict

QueryEngineclass#

class QueryEngine(store: FactStore, *, base_path: Path | None = None, materialization_limit: int | None = None, materialization_engine: str = 'lawref', indexes: SnapshotIndexes | None = None)

base_pathattributeinstance attribute#

base_path = base_path or Path.cwd().resolve()

materialization_engineattributeinstance attribute#

materialization_engine = materialization_engine

materialization_limitattributeinstance attribute#

materialization_limit = materialization_limit

materializationsattributeinstance attribute#

materializations: dict[str, dict] = {}

storeattributeinstance attribute#

store = store

warningsattributeinstance attribute#

warnings: list[dict] = []

executemethod#

def execute(query: Query) -> QueryResult

QueryErrorclassdataclass#

class QueryError(code: str, message: str, line: int | None = None, column: int | None = None, hints: tuple[str, ...] = ())

Bases: ValueError

codeattributeinstance attribute#

code: str

columnattributeclass attributeinstance attribute#

column: int | None = None

hintsattributeclass attributeinstance attribute#

hints: tuple[str, ...] = ()

lineattributeclass attributeinstance attribute#

line: int | None = None

messageattributeinstance attribute#

message: str

QueryResultclassdataclass#

class QueryResult(document: dict, explain: dict)

documentattributeinstance attribute#

document: dict

explainattributeinstance attribute#

explain: dict

load_corpusfunction#

def load_corpus(paths: Iterable[Path] | None = None, package_glob: str = '*', relations: Iterable[str] | None = None, package_globs: Iterable[str] | None = None, include_law_paths: bool = True, documents: Iterable[tuple[Path | str, dict]] | None = None) -> FactStore

Снимок корпуса в FactStore.

Два входа, взаимоисключающие: paths — файлы CLIR (по умолчанию весь corpus/clir), documents — пары (путь, уже разобранный CLIR) от хоста, который держит корпус в памяти (каталог MCP: те же документы, сверенные по stat за миллисекунды, вместо второго чтения и разбора 184 МБ на каждый вызов). Путь при документе нужен ровно тем, чем и при файле: порядком обхода (первый в канонической сортировке — единственный снимок пакета) и полем path строк фактов; байты результата от входа не зависят — это держит check_query.py. Документы не копируются и не мутируются: строки фактов ссылаются на их узлы, поэтому хост обязан отдавать их разделяемыми и неизменяемыми (у каталога MCP это уже контракт corpus_snapshot).

Глоб пакета применяется ДО разбора, когда путь известен: имя подглядывается в байтах (peek_package_name), и файл вне глоба не разбирается вовсе. Следствие, названное честно: испорченный CLIR ВНЕ глоба запрос больше не роняет — его целостность держат ворота компилятора, а не LawQL.

mainfunction#

def main(argv: list[str]) -> int

parsefunction#

def parse(source: str) -> Query | InferenceQuery

Documentation for Arxo. Writings — blog.arxo.io.

Anonymous visit counts on stats.arxo.io, no cookies.