Spanish Laws for RAG
An Apify Actor that turns Spain's consolidated legislation into RAG-ready chunks, in the wording in force on the date you choose. When a law changes, it syncs only what changed into your vector store, deletions included.
- Own product
- VazquezDev
- MIT licence
Live · Apify Store
One reform: 7 upserts and 1 delete, 261 chunks untouched
- 273 chunks from 140 articles on the first run
- 0 operations on the second run
- 17 versions of art. 37 in the source
On Spain's Workers' Statute.
- Python 3.14
- Apify SDK
- httpx
- xml.etree
- uv
The problem
The situation
The open-data XML from the BOE, Spain's official gazette, holds every version of every article, out of order and mixed with editorial notes and repealed text: one article can have 17 versions, and the latest isn't always the one in force. Anyone building a legal RAG assistant spends days cleaning it and, after every reform, recomputes, and pays for, embeddings for thousands of chunks that didn't change.
The task
A data source a RAG team can schedule and forget: citable chunks in the wording in force on any date, and a sync that only touches what changed, deletions included.
How and why
D1 A sync that keeps state.
The BOE consolidates a reform days after it takes effect, so a stateless diff would miss it forever; the Actor diffs against a manifest of the hashes it emitted.
D2 Hashes that ignore the law's update date.
That date moves whenever any article is amended; with it in the hash, one reform would re-upload, and re-bill, the whole law.
D3 A functional core.
Parsing the XML, choosing the wording in force (the later law prevails, as on boe.es), chunking and diffing are pure functions, tested on real XML from four laws.
D4 Billing in a safe order: deliver, record, charge.
A run interrupted midway never bills anyone twice.