Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 3, 20:45 UTC
codex/aram-windows-five-statement-pilot-20261031
add-index-html-10623938925177053894
arena/094f314c-aram
chatgpt-phase1b2-autopilot
codex/adr-future-connectors-pi-v1
codex/aram-account-note-source-trace-20261031
codex/aram-actions-node24-maintenance-20261031
codex/aram-analyst-review-workbook-20261031
codex/aram-bs-candidate-statement-20261031
codex/aram-cash-flow-direct-candidate-20261031
codex/aram-clean-reference-year-integrity-20261030
codex/aram-cross-statement-controls-20261031
codex/aram-equity-changes-candidate-20261031
codex/aram-five-statement-cli-20261031
codex/aram-five-statement-integration-20261031
codex/aram-five-statement-orchestrator-20261031
codex/aram-gate3-coverage-target-guard-20261030
codex/aram-gate3-hidden-xlsx-guard-20261030
codex/aram-gate3-integration-validation-20261030
codex/aram-gate3-mapping-change-preview-20261030
codex/aram-gate3-stale-note-guard-20261030
codex/aram-income-statement-candidate-20261031
codex/aram-manifest-referential-integrity-20261031
codex/aram-mapping-source-parser-20261101
codex/aram-multidimensional-mapping-20261101
codex/aram-multistatement-mapping-20261031
codex/aram-pipeline-manifest-schema-20261031
codex/aram-readonly-mapping-coverage-20261031
codex/aram-reconciliation-review-gate-20261031
codex/aram-same-flush-fiscal-lock-20261030
codex/aram-synthetic-windows-demo-20261031
codex/aram-trial-balance-diagnostic-20261031
codex/aram-windows-background-detail-search-20261031
codex/aram-windows-detail-review-20261031
codex/aram-windows-five-statement-pilot-20261031
codex/aram-windows-statement-figures-20261031
codex/gate-2a-pilot-workbook
codex/gate-2a-pilot-workbook-6864754244772568979
codex/gate3-authenticated-principal-boundary-20261030
codex/gate3-authored-draft-staging-20261030
codex/gate3-carry-forward-preview-20261023
codex/gate3-draft-staging-audit-20261030
codex/gate3-mapping-batch-freshness-20261030
codex/gate3-mapping-batch-review-20261030
codex/gate3-mapping-core
codex/gate3-mapping-coverage-20261023
codex/gate3-mapping-excel-20261023
codex/gate3-note-mapping-review-20261023
codex/gate3-signed-year-scope-20261030
codex/gate3-unapproved-proposal-storage-20261030
codex/payvast-mapping-discovery-20261023
codex/phase-2a-backend-foundation
codex/phase-2b-post-merge-record
codex/phase-2b-source-registration
codex/phase-2b-source-registration-12955190277775369594
codex/post-gate2a-control-reconciliation
codex/post-pr18-acceptance-record
codex/project-control-foundation
codex/t1-repo-hygiene-20261023
codex/t2-ci-hardening-20261023
codex/t3-explicit-migrations-20261023
codex/t6a-readonly-diagnostics-20261023
codex/v1-01-safety-gate-hardening
codex/v1-year-isolation-followup-20261023
codex/windows-native-pilot-shell-20261030
docs/aram-master-control-plan-20261111
docs/aram-roadmap-dashboard-20261030
docs/financial-statement-reconciliation-1402-1404-20261110
feat/gate3-governed-mapping-20261101
feat/gate3-package9-1-security-20261103
feat/gate3-package9-isolated-20261103
fix/password-unicode-validation-20261111
governance/aram-5-1-3-controls-20261030
governance/role-based-operating-model
jules-1168663913887856558-73b8a885
jules-gate-2b-mapping-workflow-foundation-4137724387867065330
phase-1b1-audit-report-7365389436990903239
phase-2a-backend-foundation-10237597358138521261
phase1b2-postmerge-metadata-fix
refactor/drg-parent-year-id-15088443704684163304
source-data-cleanup
| 1 | """Adversarial validation of the strictly typed five-statement JSON manifest. |
| 2 | |
| 3 | Synthetic data only. No financial documents or account information in fixtures. |
| 4 | """ |
| 5 | from __future__ import annotations |
| 6 | |
| 7 | import json |
| 8 | from copy import deepcopy |
| 9 | |
| 10 | import pytest |
| 11 | |
| 12 | from aram_backend.coverage_preview import CoverageError |
| 13 | from aram_backend.five_statement_pipeline_cli import parse_pipeline_manifest |
| 14 | from test_five_statement_pipeline_integration import pipeline_manifest |
| 15 | |
| 16 | |
| 17 | def parse(document): |
| 18 | return parse_pipeline_manifest(json.dumps(document, ensure_ascii=True).encode("utf-8")) |
| 19 | |
| 20 | |
| 21 | def test_synthetic_manifest_is_accepted_with_exact_money_strings_and_signs(): |
| 22 | document = pipeline_manifest() |
| 23 | result = parse(document) |
| 24 | assert result.company_code == "001" |
| 25 | assert result.fiscal_year == 1404 |
| 26 | assert result.references[0].expected_closing_exposure == "50" |
| 27 | assert result.balance_sheet_policies[0].sign_multiplier == 1 |
| 28 | assert result.transactions[0].cash_debit == "30" |
| 29 | |
| 30 | |
| 31 | @pytest.mark.parametrize("section, index, field, bad", [ |
| 32 | ("references", 0, "expected_closing_exposure", 50), |
| 33 | ("references", 0, "expected_closing_exposure", True), |
| 34 | ("references", 0, "expected_closing_exposure", "NaN"), |
| 35 | ("references", 0, "expected_closing_exposure", "Infinity"), |
| 36 | ("references", 0, "expected_closing_exposure", "1e200"), |
| 37 | ("references", 0, "expected_closing_exposure", " 50"), |
| 38 | ("transactions", 0, "cash_debit", 30), |
| 39 | ("transactions", 0, "cash_debit", False), |
| 40 | ("transactions", 0, "cash_debit", "NaN"), |
| 41 | ("transactions", 0, "cash_debit", "1e500"), |
| 42 | ("transactions", 0, "cash_credit", 0.0), |
| 43 | ("transactions", 0, "counterpart_credit", " 30"), |
| 44 | ("balance_sheet_policies", 0, "sign_multiplier", True), |
| 45 | ("balance_sheet_policies", 0, "sign_multiplier", 1.0), |
| 46 | ("income_statement_policies", 0, "sign_multiplier", "1"), |
| 47 | ("equity_movement_policies", 0, "sign_multiplier", 0), |
| 48 | ("equity_movement_policies", 0, "sign_multiplier", False), |
| 49 | ]) |
| 50 | def test_invalid_amounts_or_signs_fail_before_engine_runs(section, index, field, bad): |
| 51 | document = pipeline_manifest() |
| 52 | document[section][index][field] = bad |
| 53 | with pytest.raises(CoverageError) as exc: |
| 54 | parse(document) |
| 55 | assert exc.value.code == "PIPELINE_MANIFEST_" + section.upper() + "_ROW_INVALID" |
| 56 | |
| 57 | |
| 58 | @pytest.mark.parametrize("section, field, bad", [ |
| 59 | ("references", "statement", None), |
| 60 | ("references", "note_number", ""), |
| 61 | ("references", "evidence_ref", "REF\nBAD"), |
| 62 | ("balance_sheet_policies", "line_label", ""), |
| 63 | ("balance_sheet_policies", "category", 3), |
| 64 | ("income_statement_policies", "policy_evidence_ref", " "), |
| 65 | ("equity_movement_policies", "movement_category", False), |
| 66 | ("cash_accounts", "account_code", ""), |
| 67 | ("cash_accounts", "evidence_ref", "REF\tBAD"), |
| 68 | ("counterpart_policies", "activity", None), |
| 69 | ("counterpart_policies", "evidence_ref", " SRC "), |
| 70 | ("transactions", "line_id", 1), |
| 71 | ("transactions", "posting_date", ""), |
| 72 | ("transactions", "evidence_ref", "SRC\nBAD"), |
| 73 | ("cash_balance_notes", "statement_section", None), |
| 74 | ("cash_balance_notes", "note_number", ""), |
| 75 | ("cash_balance_notes", "evidence_ref", " "), |
| 76 | ]) |
| 77 | def test_invalid_identity_and_evidence_fields_fail_closed(section, field, bad): |
| 78 | document = pipeline_manifest() |
| 79 | document[section][0][field] = bad |
| 80 | with pytest.raises(CoverageError) as exc: |
| 81 | parse(document) |
| 82 | assert exc.value.code == "PIPELINE_MANIFEST_" + section.upper() + "_ROW_INVALID" |
| 83 | |
| 84 | |
| 85 | @pytest.mark.parametrize("field, bad", [ |
| 86 | ("company_code", "002"), |
| 87 | ("fiscal_year", 1403), |
| 88 | ("fiscal_year", "1404"), |
| 89 | ("fiscal_year", True), |
| 90 | ]) |
| 91 | def test_transaction_scope_mismatch_is_rejected(field, bad): |
| 92 | document = pipeline_manifest() |
| 93 | document["transactions"][0][field] = bad |
| 94 | with pytest.raises(CoverageError) as exc: |
| 95 | parse(document) |
| 96 | assert exc.value.code == "PIPELINE_MANIFEST_TRANSACTION_SCOPE_MISMATCH" |
| 97 | |
| 98 | |
| 99 | def test_zero_and_negative_reference_values_remain_exact_strings(): |
| 100 | document = pipeline_manifest() |
| 101 | document["references"][0]["expected_closing_exposure"] = "-0.0001" |
| 102 | document["transactions"][0]["cash_debit"] = "0.0000000001" |
| 103 | parsed = parse(document) |
| 104 | assert parsed.references[0].expected_closing_exposure == "-0.0001" |
| 105 | assert parsed.transactions[0].cash_debit == "0.0000000001" |
| 106 | |
| 107 | |
| 108 | def test_subnote_code_remains_optionally_blank_without_affecting_validation(): |
| 109 | document = pipeline_manifest() |
| 110 | assert all(item["subnote_code"] == "" for item in document["references"]) |
| 111 | parsed = parse(document) |
| 112 | assert len(parsed.references) == len(document["references"]) |
| 113 | |
| 114 | |
| 115 | def test_manifest_fields_are_not_mutated_during_parsing(): |
| 116 | original = pipeline_manifest() |
| 117 | snapshot = deepcopy(original) |
| 118 | parsed = parse(original) |
| 119 | assert original == snapshot |
| 120 | assert parsed.company_code == snapshot["company_code"] |