Skip to content
mak777uhPublic

About

A marketplace of law modules: decompose statutes into anchored Hohfeldian modules, assemble stacks for a territory, check compatibility, rate component quality.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Nomos

A marketplace of law modules. Decompose a statute into small anchored units, give each unit a content address, assemble units into a stack for a territory, and check whether the stack holds together — before a court does it for you.

Status: v1.34, working prototype. 51 modules from three legal orders (UK, RU, CA) plus authored model procedures, sanctions and local clauses, 334 tests, a layered territory chain with monotone tightening and explicit delegations, a compatibility engine with six precedence rules (including weak permission), an equivalence operation with an act taxonomy, a competition leaderboard with deontic-role matching, a pool coverage map, a territory dossier generator, an ingestion queue with recorded human decisions, a self-audit with negative controls and a false-completion metric, and a generated source library with an ordered reading queue. Nothing here is legal advice, and no verdict claims to be one.

$ nomos check stacks/uk-dp-core.stack.json
stack:   uk-dp-core (compose)
modules: 11  atoms: 11  pairs checked: 11
verdict: RESOLVED   assembly: gaps
findings: 1 (conflicts 0, resolved 1, undetermined 0)
  [    info] RESOLVED      uk-gdpr-art-17-1#a1  <->  uk-gdpr-art-17-3-b#a1
             resolved by lex_specialis_exception
             rule=lex_specialis_exception winner=b basis=uk-gdpr-art-17-3-b#a1 is the declared exception to uk-gdpr-art-17-1#a1
gaps: 5
  [C6_GAP_PROCEDURE] uk-gdpr-art-5-1-a#a1: a procedure module implementing this duty -> none in stack
  ...
not claimed:
  NC-01  No claim of legal validity, correctness or fitness for any jurisdiction.
  NC-02  No claim that the corpus is complete: absence of a finding is not absence of a conflict.
  ...

The problem

Laws are sold, copied and compared as monoliths. In practice a legal order is assembled: a state copies a model law, a region derogates from a federal statute, a company picks a governing law, a new jurisdiction drafts a constitution out of borrowed parts. Today that assembly happens in Word and is tested in court. The pieces are not addressable, their compatibility is not computed, and the reasoning that produced a stack is not reproducible a year later.

The operations

operation what it means command
decompose one provision → Hohfeldian atoms, each anchored to a hash-pinned quote nomos validate
assemble a selection of modules + a stated mode + a frozen lockfile nomos check stack.json --lock
chain a territory from constitution to plot: adjacent layers, tightening, delegations, pool digest nomos chain city
check comparable pairs only; conflicts, resolutions, gaps, and what is undetermined nomos compat A B
compare a candidate stack against a reference, atom by atom: equal, narrower, broader, missing, extra nomos compare ref.json candidate.json
compete which module or combination a territory should choose, scored on measurable costs nomos rank stack.json
map what the pool covers, where it is thin, and which slots have real competition nomos pool
report a territory dossier: what is adopted, the verdict, the gaps, the competition, the boundary nomos report stack.json
ingest propose candidates from a source, queue them, record human accept/reject nomos ingest propose <url>
audit does the corpus deserve the trust its claims ask for: outcome validity, planted defects, false completion, pass^k nomos audit
library sources with claims, categories and adoption paths; generated registry, queue and a stale report nomos library stale
status one screen: corpus, cells, library, registry, validation nomos status
docs the numbers and version claims in the documents must match the artefacts nomos docs check
competence was the enacting authority entitled to enact the module? authorized / unauthorized / undetermined nomos competence
standards evaluative standards are recorded as procedures and never evaluated; pairs involving one are undetermined docs/standards.md
parity the Rust core must produce the same bytes and verdicts as the Python reference python tools/parity.py
fuzzing mutated corpus files: both implementations must refuse the same garbage and agree on the rest python tools/fuzz_canonical.py
precedence parity exception, hierarchy, specificity and recency: same winner, same basis python tools/precedence_parity.py
signing Ed25519 over canonical bytes; a manifest verifies offline and fails when the corpus changes nomos verify
applicability which forum applies; replacement vs refusal vs referral cycle nomos applicability
sandbox third-party rule code runs with no host functions, a fuel budget and a memory ceiling nomos-core sandbox
coverage coverage and independence against a declared universe of cases, with the denominator printed nomos coverage
as-of which rules were in force for a fact pattern on a given date nomos asof stack.json --date 2020-01-01
versions the edition chain of one provision nomos versions uk-gdpr-art-17-1
coexist two frameworks checked separately; divergences listed, no global verdict nomos coexist a.stack.json b.stack.json
extract a rules baseline scored on structure, the floor a model-backed proposer must beat nomos extract eval --source uk-gdpr
provenance entity, activity, agent per module; refuses an anonymous or undated artifact nomos provenance --check
claims does the stack support a statement: supported, contradicted, undetermined, not mentioned nomos claims evaluation/claims/uk-dp-core.json
run execute a procedure against facts; a trace of the steps and the condition that blocked one nomos run model-erasure-procedure --fact request_received
cells the invariant units: archetypes across orders, variants as conditions; typed relations and signals nomos cells --check
rate component quality (anchoring, closure, enforceability, definitions, specificity) nomos rate --all

A module is one provision: an article, a paragraph, a section. An atom is one legal position — a duty, a privilege, a right, a power — with an actor, an action, conditions, and a quote. A stack is the product's central object: this selection, checked together, frozen at a digest.

compare is deliberately not a similarity score. A candidate atom can fill at most one reference slot, matching is one-to-one and deterministic, and the result is a list of named relations (EQUAL, NARROWER, BROADER, DIFFERENT, MISSING, EXTRA). "70% equivalent" would be the same single-number trap the rating already avoids. See docs/equivalence.md.

Why the verdict is not a boolean

COMPATIBLE  <  RESOLVED  <  UNDETERMINED  <  CONFLICT
  • COMPATIBLE — no comparable pair contradicts another.
  • RESOLVED — a contradiction exists and an explicit rule (exception, hierarchy, specificity, recency) says which side governs. The rule and its arithmetic are printed.
  • UNDETERMINED — the pair is comparable in principle but the evidence does not decide it: an unstated applicability, a cross-jurisdiction pair, or two overlapping permissions with no named basis. It is never silently reported as compatible.
  • CONFLICT — two forces contradict and no rule applies. One unresolved conflict caps the whole stack, no matter how many clean pairs sit next to it.

What this is not

  • Not legal advice, and not a claim of validity in any jurisdiction (NC-01).
  • Not a complete corpus. Absence of a finding is not absence of a conflict (NC-02).
  • Not an equivalence engine. Cross-jurisdiction pairs are refused, not resolved (NC-04).
  • Not a parser. Extraction is manual today; the anchor mechanism is what makes model-assisted extraction reviewable later (NC-06).

Quickstart

git clone https://github.com/mak777uh/nomos && cd nomos
export PYTHONPATH=src            # Windows: $env:PYTHONPATH='src'

python -m nomos validate          # corpus: schema, anchors, escapes
python -m nomos selftest          # every guard is shown to fail when it should
python -m nomos check stacks/uk-dp-core.stack.json
python -m nomos check stacks/planetary-demo.stack.json
python -m nomos rank stacks/planetary-demo.stack.json
python -m nomos compare stacks/uk-dp-core.stack.json stacks/ru-processing.stack.json
python -m nomos pool
python -m nomos report stacks/rights-demo.stack.json
python -m nomos chain alder-city
python -m nomos audit
python -m nomos compat uk-gdpr-art-17-1 uk-gdpr-art-17-3-b
python -m nomos rate uk-gdpr-art-33-1 --json
python -m nomos sources verify    # re-fetches the official source, checks every quote

No dependencies. Python ≥ 3.10, standard library only.

Corpus: a planetary pool, not a country

Modules come from any legal order, and from no order at all. The demonstration pool holds:

  • UK — 19 modules from the UK GDPR (official XML, OGL v3.0), pinned at a consolidated revision;
  • RU — 10 modules from 152-ФЗ «О персональных данных» (consolidated edition published article by article; declared consolidated, so it is flagged as a weaker source);
  • DE — 3 modules from the Basic Law (Art. 103(1), 19(4)) and the Administrative Procedure Act (§ 39), official
  • CA — 9 modules from PIPEDA (Schedule 1 principles plus the s. 9 access exception), official Department of Justice text;
  • INT (authored) — a model clause on revocable consent, written for this corpus, attributed, CC0, anchored to its own committed text through a repo: URI.

A territory is a project that selects modules and declares what governs when orders disagree:

"origin": { "policy": "mixed_declared", "precedence": ["UK", "RU"] }

Without a declared order, two legal orders do not conflict — they are UNDETERMINED, pair by pair. With one, the contradiction is resolved by territory_precedence and the declared list is printed. docs/planetary.md describes the model, the competition scoring and the authored-module path.

Design principles

Each is a mechanism in the code, not a sentence in this file:

  1. Anchor or refuse. An atom without a quote that occurs in a pinned revision is not evidence.
  2. Content addresses, not names. digest covers the whole artifact; uid covers only the norm, so translations and re-anchoring keep one semantic identity.
  3. Unknown is a verdict. UNDETERMINED is a first-class outcome with a reason, never a fallback.
  4. Conflicts are refused, not averaged. A resolution names its rule and its arithmetic.
  5. A report ships its own boundary. Every verdict carries a coded not_claimed list.
  6. Generated indexes are never hand-edited. nomos registry build --check fails on drift.
  7. Every guard is shown to fail. nomos selftest plants a defect per guard; a green gate that has never refused anything is indistinguishable from a disabled one.

The full analysis behind these choices — four rounds over the six pinned repositories, with what was adopted, rejected and deferred — is in docs/insights/round-01.md (Russian).

Repository map

path what lives there
src/nomos/ model, anchors, store, compatibility, precedence, ratings, stacks, CLI
schema/ JSON Schemas; the validator interprets them, it does not re-implement them
corpus/ UK GDPR, RU 152-ФЗ and an authored model clause; each source pinned by text digest
stacks/ demonstration stacks (single-order, mixed-order, exception pair, layers) and lockfiles
territories/ territory chains: level, parent, stack, delegations
registry/ generated index (JSON); never edited by hand
reports/ generated territory dossiers; never edited by hand
tests/ 334 tests, including the conflict matrix, planetary precedence, equivalence and the guard selftest
tools/ fill_anchors.py — quote extraction from the pinned source
cases/ verification cases: claim, evidence, reproduce, verdict, limits
library/ 79 sources with claims, question tags and adoption paths; generated registry and queue
research/ briefs for research agents: what to search, how to verify, how to hand results back
CHANGELOG.md what shipped in each version, with the case that carries the evidence
docs/ vision, cells, planetary model, layers, model, compatibility, equivalence, coexistence, execution, ratings, provenance, ingestion, evaluation, library, limits, roadmap, insights

Roadmap (short)

  1. Equivalence across orders — "these two provisions say the same thing", with an explicit crosswalk; precedence chooses a winner, it does not prove sameness.
  2. Procedures and sanctions as first-class modules, to close the gaps every stack already reports.
  3. Model laws (UNCITRAL electronic commerce, cross-border insolvency) — the natural first inventory of a planetary pool, because they exist to be adopted.
  4. Extraction pipeline with a review queue, cost accounting and per-source revision triggering.
  5. Authored-module reputation — authorship, forks, reviews and usage as evidence, so a model clause can be trusted without a state behind it.

По-русски, коротко

Nomos — маркетплейс законов как составных частей, планетарный по замыслу: пул собирается из норм любых правопорядков и из пользовательских норм, которые не принадлежат ни одному государству. Закон разбирается на атомы (обязанность, дозволение, право, полномочие), каждый атом привязан к точной цитате в закреплённой редакции текста и получает хеш-адрес. Из атомов собирается «стек» — набор норм для территории, реальной или гипотетической. Территория сама объявляет, что главнее при столкновении правопорядков (mixed_declared + список приоритета): без этого объявления пары из разных правопорядков остаются неопределёнными, а не «совместимыми». Законы и их связки конкурируют: команда nomos rank считает для каждой позиции стека альтернативы из пула и ранжирует их по измеримой цене — качество модуля, число вносимых конфликтов, изменение числа пробелов; политическую желательность инструмент не измеряет и говорит об этом. Авторские модули — полноправные участники пула: у них есть автор, лицензия, собственный текст в репозитории и тот же якорь; рейтинг помечает их как не имеющие официального источника. Ничто здесь не является юридической консультацией; каждый отчёт несёт список того, чего он не утверждает.

Слои территории. Первый пользователь — не персона, а место: конституция → страна → регион → город → район → дом/участок. Нижний уровень может ужесточать верхний (добавлять условия), но не ослаблять его; ослабление — конфликт, который решается в пользу верхнего уровня (layer_superior), если только верхний уровень явно не делегировал этот класс действий (delegations). В последнем случае движок честно говорит UNDETERMINED: право решать передано вниз, и решение остаётся за людьми. pool_digest цепочки отвечает на вопрос «в каком пуле я еду»: он покрывает и набор модулей, и цепочку с её делегациями.

Licence

Code: Apache-2.0. Documentation: CC BY 4.0. Quoted legal text: Crown copyright, Open Government Licence v3.0, quoted with attribution and pinned by digest.

About

A marketplace of law modules: decompose statutes into anchored Hohfeldian modules, assemble stacks for a territory, check compatibility, rate component quality.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages