Books / Law as Code in Practice: French Family Benefits / Appendix D

Appendix D

Reproducing the Examples

4 min read

Risograph cover art in French blue and red on off-white paper: the facade of an apartment building with one window lit in red; a thin blue line runs down from it to a small stack of blank sheets.
Contents of Law as Code in Practice: French Family Benefits

The answers in this book come by three routes. Each chapter says which one it used and when the answer was recorded.

  1. Case packages and the law command-line tool — Chapters 0 to 2, 4 to 7, 9, 11, 12, 17 and 18, and the cohort files of Chapters 3 and 14. A case package is a small package that holds one fictional file — the facts, the legal date, the readings it selects — and imports the canons whose rules apply. The rules are never copied into the case.
  2. Scenarios declared in a canon itself, run with law test — Chapters 3, 8 and 10, in the canons corpus/laws/fr/revalorisation, corpus/laws/fr/apl and corpus/laws/fr/pf-paje; the maintenance example of Chapter 10 comes from corpus/laws/fr/pf-maintenance.
  3. Recordings through MCP, the protocol through which an assistant calls the model (Chapter 16) — Chapters 13, 15 and 16 show questions recorded on 9 October 2026 through the local MCP recording server 0.1.0; Chapter 14 and the final exercise show its draft tools — check, evaluate and impact. Where a chapter ran such an answer again with the command-line tool, it says so.

Chapters 0, 1, 3, 4, 7, 12 to 16 and the final exercise also link to scenes recorded in the French Benefits Lab, a demonstration workbench at french-benefits.law.arxo.io.

What you need

  • The law command-line tool, version 0.2.2 or later (npm i -g @arxo/cli), executing law.core/0.2.11. The chapters say which version recorded each table; most were recorded on 11 October 2026 with law 0.1.11 or 0.1.12 in a checkout of the Arxo repository. The reproduction kit below was checked on 12 October 2026 with law 0.2.2.
  • The reproduction kit of this book: two public repositories.
    • the canons, github.com/arxohq/arxo-cnaf: the twenty-one French canons, each with its sources, pinned legal texts and scenarios, and a registry from which the case packages install them. Two circulars of the Cnaf are not redistributed there; tools/fetch_withheld.py downloads them from caf.fr and checks their fingerprints before you build the two canons that pin them;
    • the examples, github.com/arxohq/law-as-code-france-examples: the ten case packages and the saved answer of Chapter 17.

Getting the kit

r=https://github.com/arxohq
git clone $r/arxo-cnaf.git
git clone $r/law-as-code-france-examples.git examples

In the kit each case package is a folder of examples/ under the last part of its path below — corpus/laws/fr/pf-paje/examples/prime-naissance-moreau is examples/prime-naissance-moreau. Install it from the registry before the first question:

cd examples/prime-naissance-moreau
law install --registry arxo=../../arxo-cnaf/registry

law install never picks versions: it restores exactly what law.lock pins and checks every hash.

The case packages

Chapter Case package Files
0, 4 corpus/laws/fr/prestations-versement/examples/famille-trois-enfants-loyer Garnier2026Avril, Garnier2026AvrilTexteSeul, Garnier2026Mai
1 corpus/laws/fr/apl/examples/editions-2021 TenantDecembre, TenantJanvier
2, 5, 17, 18 corpus/laws/fr/pf-paje/examples/prime-naissance-moreau PlafondEgal, PlafondDepasse, RessourcesAbsentes
3, 14 corpus/laws/fr/pf-af/examples/cohorte-revalorisation Martin, Bernard, Petit
6 corpus/laws/fr/apl/examples/foyer-coefficient-k CoupleResidenceAutonomie
7 corpus/laws/fr/apl/examples/douzieme-sans-arrondi ResidentSansLecture, ResidentLectureD82
9 corpus/laws/fr/apl/examples/logement-decent-garnier DecenceEnAttente, DecenceReconnue, NonDecenceConstatee
11 corpus/laws/fr/prestations-versement/examples/famille-dans-le-temps one file per month, such as Famille2025_12
12, 13 corpus/laws/fr/apl/examples/recours-remise-fontaine FontaineRemise
12 corpus/laws/fr/prime-activite/examples/recours-indu-cra AppelPendant, SansAppel

Running a scenario of a canon

A canon declares scenarios: a file, a question and the expected answer. Chapters 3, 8 and 10 run them in the canons fr.css.revalorisation, fr.apl and fr.pf.paje. In the kit each canon is a folder of arxo-cnaf/packages/ with its dependencies pinned inside it, so there is nothing to install. From the folder where you cloned the kit, run the file — the folder plays the part of corpus/laws/fr/<canon> in the chapters’ commands:

cd arxo-cnaf/packages/fr.apl
law test . --file tests/finish-lecture-pp.lawtest --json

On 12 October 2026 the four scenario files of these chapters passed in the kit. The maintenance example of Chapter 10 runs only from a checkout of the Arxo repository.

Asking a question

Each case package keeps its questions as JSON files in queries/. In the package directory, ask a question and save the answer:

answer_dir="$(mktemp -d)"
law ask . --case PlafondEgal --query-json queries/montant.json --out "$answer_dir"

--case names the file, --query-json the question; --out saves the full answer — status, proof, positions and fingerprints — in the directory $answer_dir.

A case package declares scenarios too. To run them all, from the same directory:

law test . --json

Replaying a saved answer

In the same shell, replay the answer saved above:

law eval "$answer_dir"

law eval evaluates the saved answer again — without the source files or a rebuild — and must give the same bytes. Compare manifest.programHash, manifest.caseHash and resultHash in the original and the replay: if all three match, the same programme gave the same answer to the same case. That shows repeatability, not legal correctness — Chapter 17 explains the difference.

The kit keeps the answer of Chapter 17 in prime-naissance-moreau/runs/plafond-egal — PlafondEgal asked montant, €919 established. Its fingerprints, recorded on 12 October 2026; the replay was byte for byte identical:

Fingerprint Value
manifest.programHash sha256:d7740308956c4a9b279537698f7af3d448a2abb9b54e2f676fc16eacfaaf29aa
manifest.caseHash sha256:8134b82a55a7e45ccce7732f00c1659c5b1ff91e98abc16a25590339591a9f92
resultHash sha256:3b041b7e8d987baafb0425b9fb2c0286f11c4d79c8eaa5519db62a2051e64ac2
semantics law.core/0.2.11

If your answer differs

Check, in this order: the version of law; the legal date and the facts of the file; the readings it selects; the editions the canon pins. A later edition of a text, or a corrected fact, gives a new answer to a new question — not a failed reproduction of the old one.

Contents · PDF · EPUB · Free under CC BY 4.0

Law as Code in Practice: French Family Benefits

Contents

Reading settings

Text size
Appearance

Preferences and your reading place are saved only in this browser.