ra-law-db
Public dataset workspace and installable runtime library for Japanese chemical law screening.
ra-law-db is now the canonical non-MCP API for direct law-screening consumers.
ra-law-mcp is a thin wrapper over this package.
Direct package usage
Most consumers should install the package and use the bundled SQLite database directly:
pip install ra-law-db
uv add ra-law-db
from ra_law_db import get_law_screening_database
db = get_law_screening_database()
lookup_result = db.lookup(
cas_number="75-09-2",
language="ja",
context={
"material_form": "powder",
"work_process": "weighing and mixing",
"dust_generation": "medium",
},
)
search_result = db.search(query="ジクロロメタン", mode="auto", limit=10, min_score=0.6)
Public runtime API:
get_law_screening_database(law_db_path: str | None = None)LawScreeningDatabase.lookup(cas_number=None, substance_name=None, language="ja", context=None)LawScreeningDatabase.search(query, mode="auto", law_id=None, limit=20, min_score=0.6)
Default behavior:
- If
law_db_pathis omitted,ra-law-dbuses the packaged bundled SQLite database. law_db_pathmay optionally point to:- a direct SQLite file
- a checked-out
ra-law-dbdirectory containingregulatory.sqlite3and compatibility artifacts
Runtime artifact
The canonical runtime artifact is the bundled SQLite database:
- packaged path:
src/ra_law_db/data/regulatory.sqlite3 - published repo artifact:
regulatory.sqlite3
Normal installed consumers should rely on the packaged bundled database. CSV/JSONL files remain published for compatibility, inspection, and debugging, but they are not required for normal runtime use.
At runtime, the bundled database is resolved safely via importlib.resources and opened through a real filesystem path using importlib.resources.as_file(...).
MCP usage
ra-law-mcp consumes this package directly. In the normal case it does not need a separate ra-law-db checkout.
RA_LAW_DB_PATH is still supported as an override when you want to point the MCP server at:
- a custom SQLite bundle
- a local development checkout of
ra-law-db
Directory layout
regulatory.sqlite3: published SQLite bundlesrc/ra_law_db/data/regulatory.sqlite3: packaged SQLite bundle used by installsparsed/: normalized parsed entries and source snapshot manifestssource_snapshots.jsonllaw_entries.jsonl
mappings/: CAS mapping outputs and unresolved entriescas_mappings.jsonlunresolved_entries.jsonl
exports/: compatibility export filesregulatory_substances.csv
masters/: public-safe law master datasets and alias rowsregulatory_index.csv: authoritative NITE-CHRIP CAS positive-list rowsdataset_coverage.json: source-level update, hash, load, and mapping coveragemaster_coverage.json: law-domain aggregate coverage and negative-conclusion capability
Status semantics
applies: an authoritative positive match establishes application.requires_context: the substance is listed, but concentration, quantity, use, process, business, or facility conditions are needed.not_applies: used only when the screening dataset demonstrably supports a negative conclusion or an explicit authoritative negative exists.unknown: coverage or context cannot safely establish a conclusion.
No dataset hit is not automatically a legal non-applicability finding. Results are screening output, not final legal determinations. Each result exposes its status reason, notes, dataset name/version/load state/coverage, source/update date, evidence, and manual-verification actions.
The runtime also returns process-context screening for the Dust Ordinance, Pneumoconiosis Act, special health examinations, and pneumoconiosis medical examinations. These cannot be determined from CAS alone; provide material form, work process, dust generation, work frequency, assignment history, and facility conditions.
Generation and releases
This repository is published by the private ra-law-scraper pipeline. The public repo contains the generated dataset and compatibility exports, not the private scraping workflow itself.
Release model:
- the package version moves with the bundled SQLite database
- a new bundled DB refresh should be released as a new
ra-law-dbpackage version - direct consumers receive data updates by upgrading
ra-law-db - the private scraper performs a scheduled official-source refresh and opens a review PR; schema drift or missing core snapshots stops release generation
Development
uv sync --group dev
uv run pre-commit install
uv run pre-commit run --all-files
uv run pytest -q
Release
PyPI publishing is handled by GitHub Actions only when a matching v* tag is
pushed. See docs/release.md for the cleanup and release
checklist.
Notes
- SQLite is the canonical runtime format for downstream consumers.
- Alias data is published in
masters/substance_aliases.csvand bundled intoregulatory.sqlite3. - Unresolved law entries are tracked in
mappings/unresolved_entries.jsonlfor manual review. ra-law-dbremains law-source-driven. It is not replaced by CREATE-SIMPLE workbook data whenra-library/ra-mcpadopt a newer CREATE-SIMPLE methodology version.
Release files for ra-law-db 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ra_law_db-0.4.0.tar.gz | 5.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ra_law_db-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 MB
Release files / ra_law_db-0.4.0.tar.gz
| Download URL | ra_law_db-0.4.0.tar.gz |
|---|---|
| Size | 5.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92bf3ecfebde0612bb224ac2cbe3bb157b93c499348defd0c9ea4bc1e8c16317
|
|
BLAKE2b-256 checksum How to use checksums |
356fc2224d5081ebcff41e21d27b1fb7c0ef741a41e5489b8f08a0230596d653
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency logRelease files / ra_law_db-0.4.0-py3-none-any.whl
| Download URL | ra_law_db-0.4.0-py3-none-any.whl |
|---|---|
| Size | 5.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f31eb1197a4dc2365e99095c1f3f59f571d64d11499f3b10958decd87a1512b
|
|
BLAKE2b-256 checksum How to use checksums |
4115de31de4658fb46906b98d8a660e0e72a51f15ef8de263b785960f171e6c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency log