Spanish legislation as a Git repo (github.com)

by enriquelop 233 comments 827 points
Read article View on HN

233 comments

[−] _ache_ 49d 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.

[−] golem14 48d ago
For me, a great advantage is that this system makes it far simpler to understand the impact of a change, say a multi-pronged bill incl millionaire taxes, energy subsidy changes etc.

Much harder to hide some impact under the carpet

[−] 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 49d ago
I find it ironic to have it named "catalan(g)" on a post about spanish law.
[−] asveikau 48d ago
Even better. The Catalan word for Catalan is català. So catala-lang.org fits that too.
[−] 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.
[−] efilife 48d ago
Sorry if I'm accusing you wrongly, but aren't you posting LLM-generated comments? Your latest comments have barely any substance and all tend to pick a point to praise/make a positive remark about
[−] 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
[−] deepsun 48d ago
And even more useful would be unit-tests -- here is a loophole and here is the law preventing it.

Whenever a law is about to be changed/removed, run all the tests to make sure no regressions.

[−] ecocentrik 48d ago
Tests for correctness, self similarity, duplication of concerns, contradictory statutes, edge case detection, cruft or outdated laws that muddy the waters...

If the full compliment of software development practices were applied to legislation and ordinances we would be living in a very different world.

[−] dylan604 48d ago
oh gawd, code is law is back. or is it law is code?
[−] psychoslave 48d ago
Jurisdictional laws don't work that way though. It's more like a script for improvised theater. Everybody get the same text, but no one gets the same performance twice.
[−] 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.
[−] Schmerika 49d ago

> There's so many inefficiencies that are trivially solved with existing tech frameworks.

There really, really are.

The legal industry is well aware of that fact - and how many billable hours they stand to lose by making their work more efficient and understandable.

You know how tax prep companies spent over $90m 'lobbying' Congress to ensure that filing your taxes remains difficult and complicated [0]?

Well, lawyers know just as well or better how to butter their bread; and they will pull out every dirty trick they have to scupper attempts to make practising law more transparent or efficient in any way.

0 - https://www.opensecrets.org/news/2023/09/tax-prep-companies-...

[−] dgreisen 49d ago
Our nonprofit, Open Law Library, is working on this exact problem. It is definitely not trivial, but it is very doable. We partner directly with governments to help them implement so the git repos become the canonical record (rather than just an unofficial mirror).

Maryland just launched their regs on our platform:

https://regs.maryland.gov (https://github.com/maryland-dsd/law-xml-codified)

Feel free to reach out (email in bio) if you would like your community to publish their official laws on GitHub!

[−] rafram 49d ago
Everyone in government knows what Track Changes is. The standard format of a piece of legislation in British-influenced systems is a diff. The tech field does not have secret knowledge that the rest of humanity lacks.
[−] appstorelottery 49d ago
I couldn't agree more - this is fantastic work.
[−] Esophagus4 49d ago

> so many inefficiencies that are trivially solved with existing tech frameworks.

Out of curiosity, like what specifically?

Didn’t DOGE’s failure highlight that it actually wasn’t trivial? I’m skeptical at first glance but open to being proven wrong.

[−] idiotsecant 49d ago
And, in the example of the stereotypical venture capital seeking techbro junk that has somehow infected the entire world, this project doesn't actually understand or solve any real world problems.

No shade on the author, they made a fun thing. I'm directing my cannons more towards the parent post idea that the world needs software developers for their rare genius to use their beautiful brains to solve problems in ways no actual participant in the system could have ever thought of.

The additude that because you can prompt a LLM to write some python you are also uniquely situated to solve the world's problems is how we built an entire generation of automated solutions worse than what we had before.

[−] f1shy 49d ago
I would like to have a legal advisor based on that. At least for a first question, qithout paying a lawyer
[−] theptip 49d 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 49d 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 49d 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 49d ago
We need something like this for every country.
[−] 8bitsrule 49d 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 49d 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?