Technical document

System Design for Business Laws and Statutory Standards Media: Practicing e-Gov Primary Information Tracking, Tamper-Proof Evidence Trails, and Low-Cost AI Legal Auditing

We explain the architecture for accurately handling frequently revised laws and statutory standards (minimum wage, overtime pay, stamp duty, etc.) within a system and delivering them to practitioners. We share design decisions that balance robustness and operational efficiency, covering autonomous monitoring of e-Gov API v2 and primary information from various ministries, cryptographic evidence preservation using RFC 4998 Merkle Tree, three-layer differential analysis, fail-close design with three-value logic, low-cost AI legal auditing at a few cents per month using Vertex AI (Gemini 3.8 Flash), and edge delivery via Cloudflare Workers.
AI Development21 minPublication Date October 12, 2026Update date November 23, 2026
Thumbnail for System Design for Business Laws and Statutory Standards Media: Practicing e-Gov Primary Information Tracking, Tamper-Proof Evidence Trails, and Low-Cost AI Legal Auditing

Summary

Key points of this document

  • We explain the architecture for accurately handling frequently revised laws and statutory standards (minimum wage, overtime pay, stamp duty, etc.) within a system and delivering them to practitioners. We share design decisions that balance robustness and operational efficiency, covering autonomous monitoring of e-Gov API v2 and primary information from various ministries, cryptographic evidence preservation using RFC 4998 Merkle Tree, three-layer differential analysis, fail-close design with three-value logic, low-cost AI legal auditing at a few cents per month using Vertex AI (Gemini 3.8 Flash), and edge delivery via Cloudflare Workers.

Overview

In corporate back-office operations, payroll, electronic contracts, and HR/labor management, compliance with a wide range of statutory standards is required, including minimum wage, overtime pay rates, social insurance eligibility requirements, stamp duty, and the invoice system.

However, these laws and public standards are revised almost every year, and their effective dates are not always uniform nationwide (for example, regional minimum wages have effective dates that vary by several days across prefectures). A single misreading of a numerical value or an incorrect effective date can directly lead to serious compliance violations such as unpaid wages or incorrect tax filings.

This article explains the system architecture and design decisions for a "Business Laws and Statutory Standards Media (Legal Code)" that autonomously tracks legal and notification data from public institutions, preserves it with tamper-proof cryptographic evidence, and delivers it at high speed from the edge after low-cost AI legal auditing.


1. Background and Technical Challenges

When attempting to automatically track legal information and notifications published by public institutions using a system, one faces unique challenges that differ from general web scraping.

  1. Data Source Heterogeneity and Asynchronicity:
  • While the main text of laws can be obtained as structured XML via "e-Gov Law API v2", official gazette notifications, ministerial circulars, and confirmed minimum wage announcements are separately published as HTML tables, PDFs, or image documents.
  1. Failure of Manual Tracking and Human Risk:
  • Continuously monitoring and manually inputting minimum wage revisions and health insurance premium rate revisions for all 47 prefectures results in extremely high operational costs and cannot eliminate human errors.
  1. Need for Audit Trails and Tamper Prevention:
  • Data serving as the basis for statutory calculations and compliance judgments must be cryptographically provable to a third party as to "when it was extracted, from which primary source, and that it has not been altered by anyone."

To solve these challenges, we designed a pipeline based on "fully autonomous monitoring," "tamper-proof evidence preservation," "fail-close by three-value logic," and "low-cost AI auditing."


2. Core Design Principle: Detection by Machine, Activation by Human

What we emphasized most in system design was:"Strictly separating 'what machines can do' from 'the boundaries for which humans should take responsibility'.".

ResponsibilityResponsible PartyImplementation Method
Primary Information Crawling/Difference DetectionMachine (Autonomous Pipeline)Regular Crawler, Conditional HTTP Requests
Original Document Preservation and Cryptographic Evidence GenerationMachine (Cryptographic Engine)RFC 4998 Merkle Tree, CAS, WORM Storage
Extraction to Structured Data and Initial AuditMachine (LLM Audit Engine)Fidelity Audit by Vertex AI (Gemini 3.8 Flash)
Proposal CreationMachine (GitHub Bot)Automatic Pull Request Creation
Production Data Approval/ActivationHuman (Legal/Development Lead)PR Review/Merge

While having an LLM extract tax rates and wage tables is powerful, if the model misreads even a single numerical value, all downstream users' calculations will be incorrect. Therefore,"Always require human approval for finalization of reflection." is an absolute architectural requirement.


3. Primary Information Preservation and Tamper Prevention (Evidence Record & WORM)

The acquired original legal texts (XML/HTML/PDF) are not merely stored in a database but are protected by the following three layers of cryptographic evidence.

① Definition of Assurance Levels

Assurance boundaries are strictly differentiated according to the nature of the primary information source:

  • Level A (Issuer Signature): Originals with digital signatures from public institutions, such as the Cabinet Office Official Gazette publication site.
  • Level B (Hash Catalog): Data for which the conservation law of counts can be verified as a "Closed Universe" where all items can be systematically enumerated, such as the e-Gov Legal API.
  • Level C (Multi-observation TLS Evidence): An Open Universe, such as websites of various ministries and agencies, or notification PDFs. Automatic determination based on a single observation is prohibited, and multiple observations or manual verification are assumed.

② RFC 4998 Compliant Merkle Tree Timestamp Evidence

A SHA-256 digest is calculated from the acquired original binary and stored in Content Addressable Storage (CAS) format. Furthermore, by bundling multiple collected data into a Merkle Tree and applying a timestamp to the root hash, subsequent replacement or tampering is mathematically impossible.

③ GCS WORM Storage (Object Retention Lock)

Original data is stored in a WORM (Write Once, Read Many) bucket with Google Cloud Storage's Bucket Lock (Object Retention) applied. This design physically prevents deletion or overwriting within the retention period, even by privileged administrator accounts (Organization Admin).


4. Three-Layer Diff Analysis (Multi-layer Diff) and Fail-Closed

The HTML of public websites frequently changes in byte sequences due to variations in date display formats, minor wording, and changes in advertisements or navigation. To capture only essential legal revisions without being misled by noise, we have implemented a three-stage diff analysis pipeline.

[External Source] 
    ↓
1. Raw Byte Diff: Exact Match Check (If no changes, terminate immediately to minimize load)
    ↓
2. Normalized Text Diff: Comparison after HTML tag removal, full-width/half-width normalization, and whitespace removal
    ↓
3. Semantic Diff: Comparison of extracted differences in legal article numbers, table structures, effective dates, and monetary amounts
    ↓
[Difference Detection Event Triggered]

Three-Value Judgment (Fail-Closed)

In the extraction of legal provisions and determination of effective dates, if an unknown format or conflict occurs, processing will never be continued based on speculation.Three-valued logic of "True / False / Undetermined"is adopted, and if it becomes Undetermined (undeterminable), processing is safely halted and sent to an isolation queue, requesting manual review.


5. Low-Cost, High-Reliability AI Legal Audit Pipeline

To verify that the extracted structured data (JSON) is faithful to the official original, we have incorporated "AI Legal Audit" using Vertex AI (Gemini 3.8 Flash).

Fidelity & Sanity Audit

The audit engine rigorously checks the following two points:

  • Fidelity: Whether there are any hallucinations (arbitrary creations) or omissions from the numerical values and wording written in the original notification text or tables.
  • Sanity: Whether the effective date is a non-existent date, whether the minimum wage deviates extremely from past revision levels, or whether the number of digits in monetary amounts is abnormal.

Cost optimization operating at a monthly cost of a few sen

The audit engine is triggered precisely only during daily scheduled batches and when diffs occur.

  • Selection of lightweight, high-speed models: Adopting Gemini 3.8 Flash, optimized for audit prompts. The number of tokens per audit is approximately 1,000 to 2,000 tokens.
  • Self-managed OAuth2 JWT Signature: Eliminating heavy cloud SDKs, using Go standard library (crypto/rsa) to directly generate JWT Bearer tokens from service account private keys. Minimizing startup overhead and memory consumption to the extreme.
  • The cost per audit is approximately 0.0003 JPY (0.03 sen), and**even if audits are run daily for one month (60 times), the cost is only about 0.01 to 0.02 JPY.**to complete.
  • Furthermore, it is equipped with an automatic fallback mechanism to a local mock audit engine for external API failures or offline environments, preventing unnecessary retry charges due to API errors.

6. Edge Delivery and Interactive Simulation Design

Structured legal data is edge-delivered through the web media "Hikari no Dougubako Houten" (Light's Toolbox Code), built on Cloudflare Workers, allowing practitioners instant access from their browsers.

① Dynamic Enforcement Determination based on Japan Standard Time (JST)

Without relying on the client's local clock, it matches the JST-based date with the effective_date defined in the legal master data,effective_dateand automatically determines "Before Enforcement" or "Enforced" badges and warnings in real-time.

② Safety Design of Interactive Determination Tools (Simulators)

Instant calculation tools such as "Minimum Wage Checker" and "Stamp Duty Checker" are deployed on the website.

  • Disclaimer and original link co-display: Directly below the calculation results, an external link to the original public institution document (relevant pages of the Ministry of Health, Labour and Welfare or the National Tax Agency) that served as the basis for the calculation must be clearly indicated.
  • Immediate reset upon input value change: The moment a user changes input conditions such as prefecture or amount, the previous calculation results are immediately discarded, and state management is thoroughly implemented to prevent misinterpretation of results based on old conditions.

7. Summary and implications for practical application

When building systems that follow external public data and legal revisions, the design lessons engineers should take away can be summarized into the following three points:

  1. Do not aim for "full automation"; incorporate "separation of approval" into the design:

    Machines excel at "collection," "difference detection," and "consistency verification," while humans bear the final responsibility for "determining acceptance/rejection." This approach maximizes the utilization of AI advancements while minimizing accidents to zero.

  2. Design tamper-proof evidence records from the initial stage:

    By assigning hashes and timestamps to master data that serves as the basis for calculations and persistently storing the location of the original source, robustness capable of withstanding future audits and inquiries is achieved.

  3. Thoroughly implement fail-close (fail-safe):

    If there is even the slightest doubt or an unknown format, the greatest reliability for legal and tax systems comes from having the courage to stop processing as "Undetermined" instead of filling it in with speculation, and passing the baton to a human.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list