lawref.query
LawQL — детерминированные запросы к CLIR как к данным.
Пакет намеренно не входит в семантический путь evaluator: структурный слой
только реифицирует уже построенный CLIR, а материализации вызывают существующий
lawref.evaluator.evaluate явно.
Classes
| Name | Description |
|---|---|
FactStore | No description. |
QueryEngine | No description. |
QueryError | No description. |
QueryResult | No description. |
Functions
| Name | Description |
|---|---|
load_corpus | Снимок корпуса в FactStore. |
main | No description. |
parse | No 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#
lawref.query.factsView sourceclass 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 = 0node_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) -> Nonedocumentmethod#
def document(package: str) -> dict | Nonefinalizemethod#
def finalize() -> Nonenodemethod#
def node(node_id: str) -> dict | Nonerowsmethod#
def rows(relation: str, package_glob: str = '*') -> list[dict]schemamethod#
def schema() -> dictQueryEngineclass#
lawref.query.engineView sourceclass 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_enginematerialization_limitattributeinstance attribute#
materialization_limit = materialization_limitmaterializationsattributeinstance attribute#
materializations: dict[str, dict] = {}storeattributeinstance attribute#
store = storewarningsattributeinstance attribute#
warnings: list[dict] = []executemethod#
def execute(query: Query) -> QueryResultQueryErrorclassdataclass#
lawref.query.errorsView sourceclass QueryError(code: str, message: str, line: int | None = None, column: int | None = None, hints: tuple[str, ...] = ())Bases: ValueError
codeattributeinstance attribute#
code: strcolumnattributeclass attributeinstance attribute#
column: int | None = Nonehintsattributeclass attributeinstance attribute#
hints: tuple[str, ...] = ()lineattributeclass attributeinstance attribute#
line: int | None = Nonemessageattributeinstance attribute#
message: strQueryResultclassdataclass#
lawref.query.engineView sourceclass QueryResult(document: dict, explain: dict)load_corpusfunction#
lawref.query.factsView sourcedef 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#
lawref.query.cliView sourcedef main(argv: list[str]) -> intparsefunction#
lawref.query.parserView sourcedef parse(source: str) -> Query | InferenceQueryDocumentation for Arxo. Writings — blog.arxo.io.
Anonymous visit counts on stats.arxo.io, no cookies.