@davoodmehraban89 / Aram-1 / commits / 0d73a3a
Fork 0

test(control): add adversarial detail, source-reference and cash-turnover integrity cases

davoodmehraban89 committed Oct 31, 2026 at 11:24 UTC 0d73a3a66e2fcbef58b93616f85f5a6ea0054593
1 file changed +70
backend/tests/test_cross_statement_reconciliation.py
+70
@@ -410,3 +410,73 @@ def test_internal_cash_transfer_totals_must_be_derived_from_line_trace():
410 result = reconcile(cash_flow=bad)
411 assert not result.cash_flow_bridge_valid
412 assert "CASH_FLOW_BRIDGE_INVALID" in result.findings
413 +
414 +
415 +def test_balance_sheet_line_detail_must_support_summary_totals():
416 + source = bs()
417 + lines = list(source.lines)
418 + lines[0] = replace(lines[0], presentation_amount="51")
419 + result = reconcile(balance_sheet=replace(source, lines=tuple(lines)))
420 + assert "BALANCE_SHEET_DETAIL_INVALID" in result.findings
421 + assert not result.eligible_for_analyst_review
422 +
423 +
424 +def test_income_statement_line_detail_must_support_summary_totals():
425 + source = income()
426 + lines = list(source.lines)
427 + lines[0] = replace(lines[0], presentation_amount="101")
428 + result = reconcile(income_statement=replace(source, lines=tuple(lines)))
429 + assert not result.income_statement_bridge_valid
430 + assert "INCOME_STATEMENT_BRIDGE_INVALID" in result.findings
431 +
432 +
433 +def test_equity_account_detail_must_support_note_and_summary_movements():
434 + source = equity()
435 + account = replace(source.account_movements[0], credit_turnover="39")
436 + result = reconcile(equity_changes=replace(
437 + source, account_movements=(account,),
438 + ))
439 + assert not result.equity_rollforward_valid
440 + assert "EQUITY_STATEMENT_ROLLFORWARD_INVALID" in result.findings
441 +
442 +
443 +def test_trial_balance_row_rollforward_mismatch_cannot_net_off_globally():
444 + source = trial()
445 + rows = list(source.accounts)
446 + rows[0] = replace(rows[0], closing="51")
447 + rows[3] = replace(rows[3], closing="-41")
448 + result = reconcile(trial_balance=replace(source, accounts=tuple(rows)))
449 + assert not result.trial_balance_arithmetic_valid
450 + assert "TRIAL_BALANCE_ARITHMETIC_INVALID" in result.findings
451 +
452 +
453 +def test_cash_account_transaction_turnovers_must_match_cash_flow_line_trace():
454 + source = cash()
455 + account = replace(source.account_reconciliations[0], transaction_debit_turnover="29")
456 + result = reconcile(cash_flow=replace(
457 + source, account_reconciliations=(account,),
458 + ))
459 + assert not result.cash_account_totals_valid
460 + assert "CASH_ACCOUNT_TURNOVER_OR_TOTALS_INVALID" in result.findings
461 +
462 +
463 +def test_all_statement_candidates_must_share_one_note_reference_snapshot():
464 + result = reconcile(income_statement=replace(
465 + income(), note_references_sha256="e" * 64,
466 + ))
467 + assert "CROSS_STATEMENT_NOTE_REFERENCE_SNAPSHOT_MISMATCH" in result.findings
468 + assert not result.eligible_for_analyst_review
469 +
470 +
471 +def test_candidate_eligibility_must_be_a_real_boolean():
472 + with pytest.raises(CoverageError):
473 + reconcile(income_statement=replace(
474 + income(), eligible_for_analyst_review="False",
475 + ))
476 +
477 +
478 +def test_cash_scope_and_ledger_completeness_flags_cannot_be_smuggled_in():
479 + with pytest.raises(CoverageError):
480 + reconcile(cash_flow=replace(
481 + cash(), cash_account_scope_owner_approved=True,
482 + ))