Spanish legislation as a Git repo (github.com)

by enriquelop 233 comments 827 points
Read article View on HN

233 comments

[−] _ache_ 48d ago
In France, not only our law are versioned. It's formally proved too!

https://catala-lang.org/

*Edit*: Woah ! The French crew is here. We are at least 5 quoting a variation of <https://www.legifrance.gouv.fr/> for versioning.

[−] krtab 48d ago
Catala is not at all about "proving the law" formally (I'm not even sure what it would mean?). It's about having a formal language to translate law into that both matches the way law is usually written ("default logic") and allows to make numerical computations on. This can typically be used to implement tax or benefits law so that it is way easier to check that the algorithm computing taxes/benefits is correct compared to the actual state of the art of using general purpose programming languages.
[−] mentalgear 48d ago

> scope QualifiedEmployeeDiscount :

  definition qualified_employee_discount

    under condition is_property consequence

  equals

    if employee_discount >=

      customer_price \* gross_profit_percentage

    then customer_price \* gross_profit_percentage

    else employee_discount
Dang, I wish all law was written like this instead of the purposefully obfuscated legalise of (lobbied) legislative lawyers meant to mislead people and slip in loopholes for their interest groups to profit of.

Clear legislature is definitely something every person in the world would benefit of - if the the country's administration would want that.

[−] mdnahas 48d ago
I don’t know if they do it, but it allows proving properties of the law. For example, that the tax increases with income or that an exception doesn’t accidentally increase the tax paid.
[−] allan_s 48d ago
I find it ironic to have it named "catalan(g)" on a post about spanish law.
[−] kiliancs 48d ago
[−] qubex 48d ago
Borbaqui est la volonté du peuple!
[−] lcrisci 48d ago
I love it. This is a step in the right direction to have a transparent database of existing laws and be able to consult them with your AI or anything capable to reason about them and explain the status quo of our national laws. I would love to see a similar setup for other countries.
[−] enriquelop 48d ago
OP here. Thank you for the incredible response — I did not expect this.

Many of you asked if the code is shared. It is now: https://github.com/legalize-dev

The pipeline is multi-country by design. France already works as a second country (Légifrance data). Adding a new country means implementing 4 Python interfaces for your national gazette. The rest (markdown, git, web, API) is generic.

I wrote a guide for contributors who want to add their country: https://github.com/legalize-dev/legalize-pipeline/blob/main/...

From this thread alone, people asked about Germany, Portugal, Sweden, Finland, Netherlands, and Brazil. If you know your country's open data source for legislation, a PR is the best way to help.

I'll be honest — I don't know how much time I'll be able to dedicate to this, but I'd love to build something big. Legislation is massive and scaling to more countries takes real infrastructure. I'm setting up an Open Collective to fund hosting and development: https://opencollective.com/legalize

Live site with browsable laws + diffs: https://legalize.dev

Everything is still very precarious, time to time.

Thank you

[−] wrxd 48d ago
It would have been cool if the commit authors reflected the actual politicians responsible for the reforms. Find a law, run git blame and immediately know who’s responsible for it
[−] j-bos 49d ago
This is brilliant. I wish this were available for all legislations. There's so many inefficiencies that are trivially solved with existing tech frameworks.
[−] theptip 48d ago
Nice! I was just implementing this for CA state bills.

Is the parsing/uploading code shared somewhere else?

Definitely the kind of idea that would have been below my activation energy pre-Claude.

I think this approach should be standard, I have always wondered why the source of truth for these documents is not moved to a repo like git.

[−] Quarrel 49d ago
Great project.

For others wondering, while most of the Franco-era laws were nuked in 1978, this does include lots of old laws (ie pre-20th C).

However, the source material starts with a sqashed commit in 1960 :) So no changelog before that. The BOE source though is pretty phenomonal, they've scanned files going back to the 1600s so far.

[−] cyrusradfar 49d ago
I think this is great. Only limit of git is I can't imagine "git blame" works. It would be nice to know who voted for and against each patch. Git isn't structured for collaborative commits.
[−] vitorbaptistaa 49d ago
Congratulations! This is a very cool project. A few years ago there were similar ones -- browse gitlaw.

In Brazil we have lexml, a standard to describe the law and their changes over time. It's surprisingly complex.

[−] josalhor 49d ago
Not only would be cool for laws to have appropiate time stamps so we can "go back in time to how it was at a certain moment", but also if we could have proper git commit diffs of how laws change over time. See this: https://www.boe.es/buscar/act.php?id=BOE-A-2015-11430

You can see how certain articles have the option to check "how that particular article was at each moment in time". That would be way harder to track, but it would be awesome if not only could you "go back in time and see what the law was" but also "how its been evolving".

[−] sigio 49d ago
I did the same with a limited subset of dutch laws a while back: https://github.com/sigio?tab=repositories&q=wetboek
[−] comboy 49d ago
Add CI to check if new laws don't contradict with any existing ones.
[−] PhilipV 48d ago
Well done. I believe that Governments should have a Open Licence for copyright purposes like exists in the UK that allows Govt docs to be used for commercial purposes without issue. I would want to propose a step forward there so that the next generation of this open licence actually has a data set approach to making data sets available - possibly at cost. Governments are losing the ability to charge for nominal items in paper as digital is so openly available - they can make a revenue on providing data at large to public so that others can build or simply if not for free.

Well done and great to see items like this and great to see the comments.

[−] maCDzP 48d ago
Nice, I am going to this for Swedish law! Any suggestions on how one can model parliament voting when a law passes using GitHub? Or all the work that preceded a law, that’s like a feature request or a bug report.
[−] NoMoreNicksLeft 48d ago
The biggest impediment to tracking law via git is that you can't commit anything with a timestamp before the unix epoch. And law almost certainly requires the historical antecedents in the repo too, if it's going to be useful.

It's sort of funny to think about how you'd format Thomas Jefferson's email address so that he could be credited as the author of this article or that amendment. I bet someone's already figured out how to do that though.

[−] ks2048 48d ago
A couple things I noticed opening one random page (https://github.com/EnriqueLop/legalize-es/blob/master/spain/...)

It left out the tables (e.g. under 2.1 Materiales.) and the images (e.g see the very bottom).

[−] sebastianconcpt 48d ago
We need something like this for every country.
[−] 8bitsrule 48d ago
Looks like we're heading toward some resolution to the old problem 'ignorance of the law is no excuse'. Born in a world with plenty of laws, the jeopardy that goes with them, and no easy and reliable resources, that would certainly be welcome.
[−] bertil 49d ago
This is a key project, and I’m sure many countries have enough developers who might try and get it done, but a project that can do it for most legal systems (assuming the sources are on-line) would help a lot more people access legal resources.
[−] 0x3f 49d ago
Neat. I wonder if there are commercial products that are formal specifications of laws, decisions, etc. Such that you can reason on them via solvers etc.
[−] wyan 48d ago
The fact that the oldest current law in the list is about places where nuns are allowed to be buried is quite amusing, in some sort of way.
[−] TodBobCharlie 47d ago
This is an interesting idea, the normalisation of technology is happening, quite inspiring
[−] frobisher 48d ago
Love this - modern governance has yet to take advantage of the information revolution
[−] SweetSoftPillow 49d ago
We need it for every country and every law in the history of humanity
[−] reality_inspctr 48d ago
love this. I did something similar w the US Constitution. https://usconstitutionapi.com/
[−] Ericson2314 48d ago
All legislatures need to work this way as soon as possible!
[−] sandbx 48d ago
Did you try more heading levels for the article names?