Skip to content

API Reference parrot_tools.legal.boe.datasource

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.legal.boe.datasource

View source

BOEDataSource — ExtractDataSource adapter for BOE consolidated legislation.

Lets BOE data enter the existing OntologyRefreshPipeline without any modification to the pipeline: it calls datasource_factory.get(entity_def.source, config).extract(fields=...) and expects an ExtractionResult back, nothing more.

BOE arrives as structured records (parsed by parrot_tools.legal.boe.parser.parse_consolidated), so it enters through ExtractDataSource and never touches GraphIndexBuilder or UniversalNode.

Class BOEDataSource

Extracts norma/articulo records from BOE consolidated legislation.

Parameter Type Default Description
name str Human-readable name for logging and reporting.
config dict[str, Any] | None None Source-specific configuration (see Config above).

Method BOEDataSource.extract

Fetch and parse the configured BOE norms into records.

extract(fields: list[str] | None = None, filters: dict[str, Any] | None = None) -> ExtractionResult

Parameter Type Default Description
fields list[str] | None None Optional field projection. Also used to infer which entity (norma or articulo) is being refreshed, since their property sets are disjoint.
filters dict[str, Any] | None None Optional filters. Supports {"since": <date|str>} to restrict extraction to norms published on/after that date (an incremental-sync approximation based on fecha_publicacion, the only date TASK-2372's parser surfaces on the norma record). Falls back to self.config["since"] when filters does not specify one — OntologyRefreshPipeline._refresh_entity calls extract(fields=...) without ever forwarding filters, so sync_boe(since=...) (TASK-2374) can only reach this restriction via the constructor config (source_configs={"boe": {"since": since}}), not via the filters kwarg.

Returns: ExtractionResult — ExtractionResult with the norma and/or articulo records for the requested entity, plus any parser errors. Never raises — fetch/parse failures are collected in errors.

Method BOEDataSource.list_fields

Return the field names available across both BOE-sourced entities.

list_fields() -> list[str]

Returns: list[str] — Sorted list of norma and articulo field names.

Method BOEDataSource.extract_relations

Return the modifica/deroga provenance relations.

ExtractDataSource.extract() only ever returns node records (norma/articulo), because it exists to feed OntologyRefreshPipeline's generic node upsert path. The provenance relations parsed alongside those nodes (ParsedNorm.relations — see parrot_tools.legal.boe.parser) have no field-match discovery rule to ride into the graph through (modifica/deroga declare zero rules in legal.ontology.yaml by design, since they are facts extracted directly from BOE's XML, not field-matchable). This method exposes them explicitly so a caller (sync_boe) can bridge them into ArangoOntologyGraphStore.create_edges itself.

Reuses the same per-instance parse cache as extract() — call both on the SAME BOEDataSource instance to avoid re-fetching each configured norm twice.

Never raises — mirrors extract()'s error-surfacing contract: a fetch/parse failure for a given boe_id yields no relations for that norm plus an entry in the returned errors list, instead of being silently swallowed.

extract_relations() -> tuple[list[dict[str, Any]], list[str]]

Returns: tuple[list[dict[str, Any]], list[str]] — A (relations, errors) tuple: the flattened list of relation records across all configured boe_ids, each {"type": "modifica"|"deroga", "from": <boe_id>, "to": <boe_id or articulo_key>}; and any fetch/parse errors encountered (ParsedNorm.errors) along the way.

Alias ParsedNorm

Re-exported from parrot_tools.legal.boe.models.ParsedNorm.

Alias parse_consolidated

Re-exported from parrot_tools.legal.boe.parser.parse_consolidated.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally