X-04 · Run 144-rule validation
SOP:
SOP_XBRL_Filing.md§6 / Step 4.0 (MAPPING_IN_PROGRESS → VALIDATION_PASSED | VALIDATION_FAILED)Actors: XBRL Reviewer (xbrl-reviewer@spade.local) or Senior Accountant — holdsRUN_XBRL_VALIDATION. Pre-state: Filing atMAPPING_IN_PROGRESS. EveryXbrlLineItemhas a confirmedXbrlTagMapping(ideally — the validation engine still runs on partial confirmations but produces meaningless results). Post-state:XbrlValidationResultrows persisted. Filing atVALIDATION_PASSED(noERROR-severity unpassed rows) orVALIDATION_FAILED.
0. Prerequisites
- Filing at
MAPPING_IN_PROGRESSwith confirmations complete (see X-03). - Validation rules constitution loadable (
loadValidationRules(taxonomyVersion)returns the 144 rules).
1. Steps
1.1 Trigger validation
POST /ops/xbrl/filings/<filingId>/validate
Authorization: Bearer <xbrl-reviewer-jwt>(Or click Run validation on the Validation tab.)
The handler:
- Asserts
RUN_XBRL_VALIDATION. - Enqueues
run-xbrl-validationwith{xbrlFilingId, requestedBy}. - Returns
202 Accepted.
1.2 Worker — run-xbrl-validation
- Loads every confirmed
XbrlTagMappingfor the filing. - Loads the validation rules for the pinned
taxonomyVersionvialoadValidationRules(version). - Filters by entry point via
rulesForEntryPoint(version, entryPoint)— forFULL_XBRLtypically ~100+ rules. - Evaluates each rule's
expressionagainst the line-item values + the taxonomy semantics (balance,period_type,data_type). - Deletes existing
XbrlValidationResultrows for the filing (re-runs replace). - Inserts one
XbrlValidationResultper rule:{ruleId, category, severity, passed, message, relatedElements, runAt}. - Computes the outcome:
VALIDATION_PASSED— no row withseverity = ERROR AND passed = falseVALIDATION_FAILED— at least one such row
- Transitions the filing accordingly.
- Emits
AuditEventxbrl.validation.runwith{ruleCount, errorCount, warningCount, infoCount}.
2. Verification
Database
SELECT severity, count(*) FILTER (WHERE passed = true) AS passed,
count(*) FILTER (WHERE passed = false) AS failed
FROM xbrl_validation_results
WHERE xbrl_filing_id = '<filingId>'
GROUP BY severity
ORDER BY severity;SELECT status FROM xbrl_filings WHERE id = '<filingId>';
-- expect 'VALIDATION_PASSED' or 'VALIDATION_FAILED'Specific failures
SELECT rule_id, category, message, related_elements
FROM xbrl_validation_results
WHERE xbrl_filing_id = '<filingId>' AND severity = 'ERROR' AND passed = false
ORDER BY rule_id;Audit log
| Event type | Notes |
|---|---|
xbrl.validation.requested | API hit |
xbrl.validation.run | Background completion; payload has rule + severity breakdown |
UI
The Validation tab splits into three panes (Errors / Warnings / Info). Each row shows the rule id, category, message, and the elements it relates to. Failing errors are highlighted; reviewer can click into a row to see the underlying line items.
3. Negative & edge cases
- Validation run on an unconfirmed mapping — the rule evaluator includes only confirmed mappings; unconfirmed line items effectively count as missing for the purpose of mandatory-presence rules. Better to confirm everything first.
- Repeated runs — replace prior results (the upsert is keyed by
(filingId, ruleId)). - Caller without
RUN_XBRL_VALIDATION—403 Forbidden.XBRL_PREPARERcannot run validation by design (the action is part of the reviewer / senior boundary). - Recovery loop —
VALIDATION_FAILED → MAPPING_IN_PROGRESSis implicit: any subsequent mapping change automatically returns the filing to mapping. Re-run validation after fixes. - Warning-only failures — filing still transitions to
VALIDATION_PASSED. Warnings do not block but should be inspected; ACRA can still reject for warning-only issues. - Unknown rule expression — handler logs the rule id and emits a
WARNINGresult for the row; does not crash the whole run. This is a constitution-side bug; file an issue.
Next
Proceed to X-05 · Export BizFinx XLSX and XBRL XML.