fix: RTC observed live with provenance, non-circular PIS/COFINS applicability, canonical CST normalization (1.1.8)

- RTC: Agent reads ALL PARAMETROS rows every sync (conflict => off), reports rtc_source/rtc_observed_at/rtc_param_rows; legal_effective_context is informational only
- PIS/COFINS: applicability from CRT + PISCOFINS flag + incidence only (never from empty fields); Simples w/o special treatment NOT_APPLICABLE, taxed regime with explicit N OPTIONAL, unreadable declaration NEEDS_REVIEW
- CST: one digit with an official zero-padded form is VALID_AFTER_NORMALIZATION (non-blocking warning), nothing is written to the ERP
- tests: RTC toggle 0->1->0 across syncs (Agent + Hub stale closing), non-circularity, normalization, panel provenance

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
gti
2026-09-24 17:46:45 -03:00
co-authored by Claude Sonnet 5
parent 1430042322
commit 88f4318072
18 changed files with 679 additions and 814 deletions
+34 -12
View File
@@ -1,7 +1,7 @@
{
"mode": "FISCAL_ONLY (no Hub decision)",
"database": "MMMODAS",
"crt": "2",
"crt": "1",
"products": 20997,
"fiscal_products_read": 20997,
"BEFORE": {
@@ -26,19 +26,33 @@
"OTHER_BLOCKERS": 0,
"blockers_by_type": {},
"applicability": {
"OPTIONAL": 1,
"NOT_APPLICABLE": 20995
"NOT_APPLICABLE": 20996
},
"rtc_applicability": {
"NOT_APPLICABLE": 20996
},
"changed_products": 0,
"examples": [],
"non_canonical_warnings": 0,
"context": {
"rtc_enabled": false,
"erp_rtc_enabled": false,
"rtc_supported": true,
"rtc_catalog_valid": true,
"rtc_param": 0,
"rtc_param": "0",
"rtc_source": "PARAMETROS.USAR_REFORMA_TRIBUTARIA",
"rtc_param_rows": 1,
"rtc_param_conflict": false,
"rtc_observed_at": "2026-09-24T20:40:49+00:00",
"legal_effective_context": {
"crt": "1",
"informational_only": true,
"ibs_cbs_in_documents": "FROM_2027_FOR_SIMPLES_ORIENTATION_PENDING",
"sources": [
"NT 2025.002-RTC v1.51 (Portal NF-e, 04/08/2026): CRT 1/2/4 orientations in a future NT; IBS/CBS taxation of these taxpayers only from 2027",
"LC 214/2025 art. 348"
]
},
"catalog_integrity": {
"classes": 145,
"cst": 18,
@@ -48,8 +62,16 @@
"duplicates": 0,
"valid": true
},
"crt": "2",
"products_evaluated": 20997
"crt": "1",
"products_evaluated": 20997,
"pis_cofins_applicability": {
"NOT_APPLICABLE": 20997
},
"non_canonical_warnings": {
"products": 0,
"by_type": {},
"samples": []
}
}
},
"RTC_OFF_SIMULATION": {
@@ -67,14 +89,14 @@
"OTHER_BLOCKERS": 0,
"blockers_by_type": {},
"applicability": {
"OPTIONAL": 1,
"NOT_APPLICABLE": 20995
"NOT_APPLICABLE": 20996
},
"rtc_applicability": {
"NOT_APPLICABLE": 20996
},
"changed_products": 0,
"examples": []
"examples": [],
"non_canonical_warnings": 0
},
"RTC_ON_SIMULATION": {
"rtc_enabled": true,
@@ -93,8 +115,7 @@
"CCLASSTRIB_MISSING": 20996
},
"applicability": {
"OPTIONAL": 1,
"NOT_APPLICABLE": 20995
"NOT_APPLICABLE": 20996
},
"rtc_applicability": {
"REQUIRED": 20996
@@ -341,7 +362,8 @@
"CCLASSTRIB_MISSING"
]
}
]
],
"non_canonical_warnings": 0
}
},
"SAFETY": {