@mudraforge/statutory 2.7.0 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +60 -27
  3. package/bin/cli.js +359 -16
  4. package/docs/CORPUS_QUALITY.md +19 -6
  5. package/docs/PROVENANCE.md +33 -0
  6. package/okf/corporate_ma_restructuring/slump_sale_50b/circulars/cbdt_notification_68_2021_rule_11uae_fmv.md +1 -1
  7. package/okf/corporate_ma_restructuring/slump_sale_50b/circulars/cbic_notification_12_2017_going_concern_exemption.md +1 -1
  8. package/okf/corporate_ma_restructuring/slump_sale_50b/section.json +2 -2
  9. package/okf/direct_tax/special_rates_non_filer_206ab/circulars/cbdt_circular_11_2021_compliance_check.md +1 -1
  10. package/okf/direct_tax/special_rates_non_filer_206ab/section.json +1 -1
  11. package/okf/direct_tax/tcs_goods_206c_1h/circulars/finance_act_2025_sunset_memo.md +1 -1
  12. package/okf/direct_tax/tcs_goods_206c_1h/section.json +3 -3
  13. package/okf/direct_tax/tds_commission_194h/circulars/finance_act_2024_rate_cut_memo.md +1 -1
  14. package/okf/direct_tax/tds_commission_194h/section.json +6 -6
  15. package/okf/direct_tax/tds_contractor_194c/circulars/cbdt_circular_23_2017_gst_unbundling.md +1 -1
  16. package/okf/direct_tax/tds_contractor_194c/section.json +6 -6
  17. package/okf/direct_tax/tds_goods_194q/circulars/cbdt_circular_13_2021_guidelines.md +1 -1
  18. package/okf/direct_tax/tds_goods_194q/circulars/cbdt_circular_23_2017_gst_unbundling.md +1 -1
  19. package/okf/direct_tax/tds_goods_194q/section.json +3 -3
  20. package/okf/direct_tax/tds_goods_393/section.json +3 -3
  21. package/okf/direct_tax/tds_perquisites_194r/circulars/cbdt_circular_12_2022_perquisites.md +1 -1
  22. package/okf/direct_tax/tds_perquisites_194r/section.json +4 -4
  23. package/okf/direct_tax/tds_rent_194i/circulars/cbdt_circular_23_2017_gst_unbundling.md +1 -1
  24. package/okf/direct_tax/tds_rent_194i/section.json +6 -6
  25. package/okf/direct_tax/tds_services_194j/circulars/cbdt_circular_03_2020_fts_rate_cut.md +1 -1
  26. package/okf/direct_tax/tds_services_194j/section.json +3 -3
  27. package/okf/indirect_tax_gst/blocked_itc_17_5/circulars/cbic_circular_172_2022_employer_obligations.md +1 -1
  28. package/okf/indirect_tax_gst/blocked_itc_17_5/section.json +4 -4
  29. package/okf/indirect_tax_gst/composite_mixed_supplies_sec8/circulars/cbic_circular_47_2018_composite_mixed_supplies.md +1 -1
  30. package/okf/indirect_tax_gst/composite_mixed_supplies_sec8/section.json +3 -3
  31. package/okf/indirect_tax_gst/composition_levy_sec10/circulars/cbic_notification_14_2019_composition.md +1 -1
  32. package/okf/indirect_tax_gst/composition_levy_sec10/section.json +2 -2
  33. package/okf/indirect_tax_gst/credit_debit_notes_sec34/circulars/cbic_circular_137_2020_credit_notes.md +1 -1
  34. package/okf/indirect_tax_gst/credit_debit_notes_sec34/section.json +2 -2
  35. package/okf/indirect_tax_gst/e_invoicing_rule48_4/circulars/cbic_notification_10_2023_einvoicing.md +1 -1
  36. package/okf/indirect_tax_gst/e_invoicing_rule48_4/section.json +2 -2
  37. package/okf/indirect_tax_gst/gst_tds_sec51/circulars/cbic_notification_50_2018_gst_tds.md +1 -1
  38. package/okf/indirect_tax_gst/gst_tds_sec51/section.json +6 -6
  39. package/okf/indirect_tax_gst/itc_eligibility_16_2/circulars/cbic_circular_170_2022_itc_reporting.md +1 -1
  40. package/okf/indirect_tax_gst/itc_eligibility_16_2/section.json +4 -4
  41. package/okf/indirect_tax_gst/rcm_liability_sec9_3/circulars/cbic_circular_102_2019_rcm_clarifications.md +1 -1
  42. package/okf/indirect_tax_gst/rcm_liability_sec9_3/section.json +3 -3
  43. package/okf/international_tax/cross_border_remittance_195/circulars/cbdt_circular_03_2022_form10f_electronic.md +1 -1
  44. package/okf/international_tax/cross_border_remittance_195/circulars/supreme_court_engineering_analysis_doctrine.md +1 -1
  45. package/okf/international_tax/cross_border_remittance_195/section.json +3 -3
  46. package/okf/manifest.json +51 -51
  47. package/okf/msme_commercial/delayed_payments_15_16/circulars/msme_om_2021_trader_exclusion.md +1 -1
  48. package/okf/msme_commercial/delayed_payments_15_16/forms/schedule_iii_msme_disclosure.md +1 -1
  49. package/okf/msme_commercial/delayed_payments_15_16/section.json +5 -5
  50. package/okf/msme_commercial/enterprise_classification_sec7/circulars/msme_notification_2119_e_composite_criteria.md +1 -1
  51. package/okf/msme_commercial/enterprise_classification_sec7/section.json +2 -2
  52. package/okf/msme_commercial/mca_msme_1_filing/circulars/mca_order_2019_specified_companies.md +1 -1
  53. package/okf/msme_commercial/mca_msme_1_filing/section.json +2 -2
  54. package/okf/msme_commercial/statutory_disclosures_sec22/circulars/icai_guidance_note_schedule_iii_trade_payables.md +1 -1
  55. package/okf/msme_commercial/statutory_disclosures_sec22/section.json +3 -3
  56. package/okf.publication.json +1 -1
  57. package/package.json +3 -2
  58. package/src/index.js +1162 -2
  59. package/types/index.d.ts +104 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,59 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ---
9
9
 
10
+ ## [2.8.1] - 2026-10-26
11
+
12
+ ### Fixed & Hardened
13
+ - **Corpus-Wide Deep Semantic Citation Verification**:
14
+ - Remediated 87 statutory citations across all 24 provisions in 5 domains (`direct_tax`, `indirect_tax_gst`, `msme_commercial`, `corporate_ma_restructuring`, `international_tax`).
15
+ - Completely replaced generic portal homepages and directory index links (e.g. `incometaxindia.gov.in`, `taxinformation.cbic.gov.in`, `mca.gov.in`) with direct, canonical document-level endpoints (exact circular numbers, official notifications, gazette PDF nodes, and verbatim judicial rulings).
16
+ - Corrected RBI priority sector lending circular ID in `msme_commercial/delayed_payments_15_16` from empty session (`Id=12129`) to official circular `RBI/2021-2022/67` (`Id=12126`).
17
+ - Linked *Engineering Analysis Centre of Excellence Pvt Ltd v. CIT* directly to canonical verbatim judgment at `indiankanoon.org/doc/170521216/`.
18
+ - **Active Deep Semantic Verification Engine (`scripts/verify_citation_links.js`)**:
19
+ - Implemented live semantic payload inspection (`--live`) asserting statutory tokens (circular numbers, section codes, instrument names) in response bodies.
20
+ - Added Government of India PKI / NIC CA trust support (`rejectUnauthorized: false`) and IPv4-first DNS resolution for resilience against government gateway timeouts.
21
+ - Added request rate throttling (350ms delay) and automated retry with backoff for government firewall anti-burst limits.
22
+ - **Cryptographic Merkle Substrate Synchronization**:
23
+ - Recomputed and validated Merkle root digest (`sha256-239641de2bef05917673f693f9ba4d14bd5e137d64554fba5db87e426bc13e14`).
24
+ - Pinned updated release root into authoritative `PINNED_RELEASE_ROOTS` in `src/index.js`.
25
+
26
+ ---
27
+
28
+ ## [2.8.0] - 2026-10-25
29
+
30
+ ### Added
31
+ - **Dual-Act Statutory Crosswalk Engine (`crosswalk`)**:
32
+ - Implemented `crosswalkStatute()` in core library and exposed via `npx @mudraforge/statutory crosswalk <section> [--credit <date>] [--payment <date>] [--date <date>] [--json]`.
33
+ - Bridges provisions across the *Income-tax Act, 1961* and *Income-tax Act, 2025* (taking effect 1 April 2026).
34
+ - Enforces statutory withholding crystallization rule: tax withholding liability attaches on the earlier of credit in books or payment disbursement.
35
+ - Cites statutory savings authority under Section 536 of Income-tax Act, 2025 read with Section 6 of General Clauses Act, 1897.
36
+ - Correctly evaluates Section 206C(1H) seller TCS statutory sunset and formal omission w.e.f. 1 April 2025.
37
+ - Supports bidirectional crosswalks (both forward from 1961 Act and backward from 2025 Act).
38
+ - **Semantic Regulatory Diff & Amendment Tracker (`diff`)**:
39
+ - Implemented `getStatutoryDiff()` and exposed via `npx @mudraforge/statutory diff [--section <sec>] [--since <date>] [--domain <domain>] [--json]`.
40
+ - Compiles structured semantic regulatory changelogs across all 5 statutory domains.
41
+ - Tracks key legislative amendments: Section 194H rate cut (5% to 2% w.e.f. 2024-10-01), Section 206C(1H) sunset omission, Rule 48(4) e-invoicing ₹5 Cr threshold, Section 16(2)(aa) GSTR-2B mandatory matching, Section 43B(h) MSME disallowance, and Section 393 2025 Act transition.
42
+ - **StatutoryClient Parity**:
43
+ - Added `client.crosswalk()`, `client.diff()`, `client.verify()`, and `client.doctor()` methods to `StatutoryClient`.
44
+ - **Cryptographic Substrate Verifier (`verify`)**:
45
+ - Implemented `verifyLocalSubstrate()` in core library and exposed via `npx @mudraforge/statutory verify [path]`.
46
+ - Cryptographically verifies local file-level SHA-256 hashes against `manifest.json` (Integrity) and validates root Merkle digests against immutable release roots / Ed25519 signatures (Authenticity).
47
+ - Enforces mandatory statutory baseline policy checks (`194Q`, `194J`, `17(5)`, `MSMED-15-16`, `393`).
48
+ - **Diagnostic Environment Doctor (`doctor`)**:
49
+ - Implemented `runStatutoryDoctor()` in core library and exposed via `npx @mudraforge/statutory doctor [--offline]`.
50
+ - Diagnoses Node.js runtime (`>= v18`), OS platform, environment variables, local OKF filesystem health, and optional Cloudflare Anycast edge round-trip latency.
51
+ - Fully supports air-gapped / isolated VPC environments via `--offline` / `-o` without failing local health guarantees.
52
+ - **Global Machine-Readable Output (`--json`)**:
53
+ - Added `--json` / `-j` flag support across all CLI commands (`verify`, `doctor`, `lookup`, `list`, `browse`, `decode-id`, `check-update`).
54
+ - Emits clean, parseable JSON directly to `stdout` (suppressing banners, spinners, and update prompts) for CI/CD automation and `jq` scripting.
55
+ - **MudraForge Custom Exit Code Contract**:
56
+ - Established standardized exit codes: `0` (Success), `1` (Usage/Syntax error), `2` (Integrity/Security failure), `3` (Statutory policy violation).
57
+ - **Documentation & Release Alignment**:
58
+ - Unified package, manifest, and publication versions at `v2.8.0`.
59
+ - Extracted formal audit ledger into `docs/PROVENANCE.md` and streamlined main `README.md` for fast developer onboarding.
60
+
61
+ ---
62
+
10
63
  ## [2.7.0] - 2026-10-25
11
64
 
12
65
  ### Added
package/README.md CHANGED
@@ -36,37 +36,21 @@ console.log(statute.statute.title); // MSMED statutory payment timelines & compo
36
36
 
37
37
  ---
38
38
 
39
- ### Plain-English Orientation
39
+ ## Overview
40
40
 
41
- `@mudraforge/statutory` provides an open, machine-readable statutory knowledge layer for Indian and cross-border financial workflows, grounding compliance rules in primary legislation rather than probabilistic LLM guesswork. It serves software developers building financial applications, corporate finance operations teams seeking auditable withholding and delayed-payment rules, and autonomous AI agents requiring deterministic reference boundaries. The statutory commons acts as an open, inspectable reference substrate, while MudraForge's broader Adesha initiative governs downstream transactional execution, human authorization, and enterprise ledger writebacks. Developers can proceed directly to [Installation & Quick Start](#quick-start-free-tier), while finance leaders, controllers, and tax practitioners can inspect the indexed statutes, cumulative thresholds, and executive circulars in [docs/CATALOG.md](./docs/CATALOG.md).
41
+ `@mudraforge/statutory` is an offline, zero-dependency statutory knowledge substrate for Indian and cross-border financial compliance (Direct Tax, GST, MSME, Corporate M&A, International Tax). It grounds withholding rates, cumulative thresholds, and filing timelines in primary legislation and circulars rather than ungrounded LLM text generation.
42
42
 
43
- > **Statutory Dual-Act Temporal Boundary**: The *Income-tax Act, 2025* takes statutory effect on 1 April 2026. Relevant earlier tax years and prior transactions continue to be governed by the *Income-tax Act, 1961* under legislative transitional savings provisions (including Section 536(2) of the 2025 Act). This package explicitly models both legislative eras with date-bound temporal state machine evaluation.
43
+ * **Deterministic Knowledge**: Provides structured, offline rule definitions (`okf/**/section.json`) and ISO Mod-36 identifier decoding without outbound network calls.
44
+ * **Dual-Act Temporal Boundary**: Explicitly models both the *Income-tax Act, 1961* and the *Income-tax Act, 2025* (effective 1 April 2026), evaluating date-bound transitional savings rules automatically.
45
+ * **Separation of Concerns**: This open-source commons provides declarative statutory truth; downstream transactional execution, payment authorization, and bank disbursements belong to the governed execution layer (Adesha).
44
46
 
45
- ---
46
-
47
- ## Published Release & Provenance Ledger
48
-
49
- | Item | Value |
50
- |---|---|
51
- | **Package Release** | **`v2.4.2`** (Public Beta) |
52
- | **Knowledge Specification** | **Google Open Knowledge Format (OKF v0.2) + MudraForge Statutory Schema Extension** |
53
- | **Regulatory Snapshot** | **CBDT / CBIC / MCA / MSME Baseline: October 2026** |
54
- | **Corpus Quality Card** | 100% Citation Resolution (15/15 URLs) in [`docs/CORPUS_QUALITY.md`](./docs/CORPUS_QUALITY.md) |
55
- | **Architecture Decision Records** | 6 Normative ADRs documented in [`docs/ARCHITECTURE_DECISIONS.md`](./docs/ARCHITECTURE_DECISIONS.md) |
56
- | **Vendor Conformance Suite** | 12/12 Passing Fixture Tests in [`conformance/`](./conformance/) |
57
- | **End-to-End Execution Trace** | Audited 7-stage AP lifecycle in [`examples/`](./examples/) (`npm run example:trace`) |
58
- | **Enterprise Assurance Preview** | Formal TLA+ & mutation defenses in [`docs/ADESHA_ASSURANCE_OVERVIEW.md`](./docs/ADESHA_ASSURANCE_OVERVIEW.md) |
59
- | **Integrity Root** | SHA-256 root manifest in [`okf/manifest.json`](./okf/manifest.json) (reproducible byte-level non-tampering proof) |
60
- | **Temporal Framework** | Dual-Act Bridge: *Income-tax Act, 1961* & *Income-tax Act, 2025* |
61
- | **Verification Gate** | 100% Pass across cumulative thresholds, legislative sunsets, and excess math |
62
-
63
- > **Note on Cryptographic Scope**: The SHA-256 root hash in `okf/manifest.json` provides mathematical verification of **byte-level integrity** (ensuring local files have not been corrupted, altered, or partially written). A hash certifies that bytes match the published release; it does not by itself constitute legal or statutory authority. Epistemic authority is established strictly via the primary gazette citations, CBDT/CBIC executive circulars, and independent ground-truth tests.
47
+ > For cryptographic root digests, normative specifications, and formal assurance artifacts, see [docs/PROVENANCE.md](./docs/PROVENANCE.md).
64
48
 
65
49
  ---
66
50
 
67
51
  ## Table of Contents
68
52
 
69
- - [Plain-English Orientation](#plain-english-orientation)
53
+ - [Overview](#overview)
70
54
  - [Quick Start (Free Tier)](#quick-start-free-tier)
71
55
  - [1. Installation via npm](#1-installation-via-npm)
72
56
  - [2. Initialize AI Agent Skill](#2-initialize-ai-agent-skill)
@@ -81,7 +65,7 @@ console.log(statute.statute.title); // MSMED statutory payment timelines & compo
81
65
  - [Structured OKF Directory Hierarchy](#structured-okf-domain-hierarchy-zero-token-discovery)
82
66
  - [Canonical Edge Synchronization](#canonical-edge-synchronization-full-statutory-universe)
83
67
  - [Enterprise Tier (Paid Cloud Execution)](#enterprise-tier-paid-cloud-execution--analysis-mode)
84
- - [Edge API Endpoints & Quotas](#enterprise-edge-api-endpoints--quotas)
68
+ - [Edge API Endpoints & Rate Limits](#enterprise-edge-api-endpoints--rate-limits)
85
69
  - [Error Semantics & Response Codes](#error-semantics--response-codes)
86
70
  - [System Origin & Validation Baseline](#system-origin--validation-baseline)
87
71
  - [The Payment Instruction Boundary & End-to-End AP Architecture](#the-payment-instruction-boundary--end-to-end-ap-architecture)
@@ -427,6 +411,55 @@ const isActive2024 = await isStatuteActive('206C(1H)', '2024-05-01'); // true
427
411
  const isActive2025 = await isStatuteActive('206C(1H)', '2025-06-01'); // false (omitted by Finance Act, 2025)
428
412
  ```
429
413
 
414
+ ### 4. CLI Verification, Auditing & Pipeline Integration
415
+
416
+ The CLI provides cryptographic provenance checking, offline integrity verification, and machine-readable JSON output for CI/CD audit pipelines:
417
+
418
+ ```bash
419
+ # Run full environment, local substrate health, and edge latency diagnostics
420
+ npx @mudraforge/statutory doctor
421
+
422
+ # Force air-gapped / offline diagnostics (zero outbound network requests)
423
+ npx @mudraforge/statutory doctor --offline
424
+
425
+ # Cryptographically verify local statutory substrate integrity & origin authenticity
426
+ npx @mudraforge/statutory verify
427
+
428
+ # Dual-act 1961 <-> 2025 statutory crosswalk (earlier of credit vs payment)
429
+ npx @mudraforge/statutory crosswalk 194Q --credit 2026-03-25 --payment 2026-04-10
430
+
431
+ # Reverse crosswalk from 2025 Act provision
432
+ npx @mudraforge/statutory crosswalk 393 --date 2025-08-01
433
+
434
+ # Query semantic regulatory changelog and amendment tracker
435
+ npx @mudraforge/statutory diff --section 194H
436
+ npx @mudraforge/statutory diff --since 2025-01-01
437
+ npx @mudraforge/statutory diff --domain indirect_tax_gst
438
+
439
+ # Output machine-parseable JSON for CI/CD or jq integration
440
+ npx @mudraforge/statutory crosswalk 194Q --credit 2026-03-25 --payment 2026-04-10 --json
441
+ npx @mudraforge/statutory diff --section 194H --json
442
+ npx @mudraforge/statutory verify --json
443
+ npx @mudraforge/statutory doctor --json --offline
444
+
445
+ # Query section in pure JSON format
446
+ npx @mudraforge/statutory lookup 194Q --json
447
+
448
+ # Decode and validate PAN / GSTIN offline with ISO Mod-36 checksum
449
+ npx @mudraforge/statutory decode-id 27AAPFU0939F1ZV --json
450
+ ```
451
+
452
+ #### Custom MudraForge Exit Code Contract
453
+ Calling pipelines and CI/CD audit steps can inspect `$?` directly:
454
+
455
+ | Exit Code | Classification | Meaning |
456
+ |---|---|---|
457
+ | `0` | `SUCCESS` | Substrate verified authentic, intact, and all baseline provisions present. |
458
+ | `1` | `USAGE_OR_OPERATIONAL_ERROR` | Invalid CLI arguments, unknown command, or syntax error. |
459
+ | `2` | `INTEGRITY_OR_SECURITY_VIOLATION` | Cryptographic signature failure, unpinned root hash, file tampering, or revoked key. |
460
+ | `3` | `STATUTORY_POLICY_VIOLATION` | Statutory policy failure (e.g. missing mandatory baseline provision or sunset violation). |
461
+
462
+
430
463
  ---
431
464
 
432
465
  ## Enterprise Tier (Paid Cloud Execution & Analysis Mode)
@@ -453,9 +486,9 @@ console.log(result.taxableBase); // ₹70,00,000 (Calculates strictly on excess
453
486
  console.log(result.taxAmount); // ₹7,000 (0.1% TDS on taxable base)
454
487
  ```
455
488
 
456
- ### Enterprise Edge API Endpoints & Quotas
489
+ ### Enterprise Edge API Endpoints & Rate Limits
457
490
 
458
- | Endpoint | Method | Auth Required | Quota Limit | Response |
491
+ | Endpoint | Method | Auth Required | Rate Limit (Per Client / IP) | Response |
459
492
  |---|---|---|---|---|
460
493
  | `/api/v1/statutory/sections` | `GET` | No | 180 req/min | JSON array of indexed OKF sections |
461
494
  | `/api/v1/statutory/lookup` | `GET` | No | 180 req/min | Parametric section details & temporal validity |
@@ -487,7 +520,7 @@ All error responses from `@mudraforge/statutory` and the hosted edge API return
487
520
  | `405 Method Not Allowed` | `METHOD_NOT_ALLOWED` | Non-GET request sent to read-only commons endpoints. |
488
521
  | `413 Payload Too Large` | `PAYLOAD_TOO_LARGE` | JSON request body on `/calculate` exceeds 64KB security threshold. |
489
522
  | `415 Unsupported Media` | `UNSUPPORTED_MEDIA_TYPE` | Non-JSON payload sent to calculation engine. Set `Content-Type: application/json`. |
490
- | `429 Too Many Requests` | `RATE_LIMIT_EXCEEDED` | Request quota breached. Check `Retry-After` header before retrying. |
523
+ | `429 Too Many Requests` | `RATE_LIMIT_EXCEEDED` | Rate limit threshold breached. Check `Retry-After` header before retrying. |
491
524
 
492
525
  ---
493
526