@davoodmehraban89 / Aram-2 Mirror · read-only
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 3, 18:15 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
py 188 lines 5.71 KB
Raw
1 """Synthetic adversarial tests for five-statement manifest referential integrity."""
2 from __future__ import annotations
3
4 from copy import deepcopy
5 import json
6
7 import pytest
8
9 from aram_backend.coverage_preview import CoverageError
10 from aram_backend.five_statement_pipeline_cli import parse_pipeline_manifest
11 from test_five_statement_pipeline_integration import pipeline_manifest
12
13
14 def parse(data):
15 return parse_pipeline_manifest(json.dumps(data, ensure_ascii=True).encode("utf-8"))
16
17
18 def reject(modify, code):
19 data = pipeline_manifest()
20 modify(data)
21 with pytest.raises(CoverageError) as exc:
22 parse(data)
23 assert exc.value.code == code
24
25
26 def test_complete_synthetic_graph_is_accepted_unchanged():
27 source = pipeline_manifest()
28 original = deepcopy(source)
29 output = parse(source)
30 assert len(output.references) == 8
31 assert len(output.balance_sheet_policies) == 4
32 assert len(output.cash_balance_notes) == 1
33 assert source == original
34
35
36 def test_duplicate_reference_to_same_statement_note_rejected():
37 reject(
38 lambda d: d["references"].append(deepcopy(d["references"][0])),
39 "PIPELINE_MANIFEST_DUPLICATE_NOTE_REFERENCE",
40 )
41
42
43 def test_unknown_reference_statement_rejected():
44 reject(
45 lambda d: d["references"][0].update(statement="UNKNOWN"),
46 "PIPELINE_MANIFEST_REFERENCE_STATEMENT_INVALID",
47 )
48
49
50 @pytest.mark.parametrize("section,code", [
51 ("balance_sheet_policies", "PIPELINE_MANIFEST_DUPLICATE_BS_POLICY"),
52 ("income_statement_policies", "PIPELINE_MANIFEST_DUPLICATE_IS_POLICY"),
53 ("equity_movement_policies", "PIPELINE_MANIFEST_DUPLICATE_EQ_POLICY"),
54 ])
55 def test_duplicate_statement_policy_rejected(section, code):
56 reject(lambda d: d[section].append(deepcopy(d[section][0])), code)
57
58
59 @pytest.mark.parametrize("section,code", [
60 ("balance_sheet_policies", "PIPELINE_MANIFEST_ORPHAN_BS_POLICY"),
61 ("income_statement_policies", "PIPELINE_MANIFEST_ORPHAN_IS_POLICY"),
62 ("equity_movement_policies", "PIPELINE_MANIFEST_ORPHAN_EQ_POLICY"),
63 ])
64 def test_policy_target_without_matching_reference_rejected(section, code):
65 reject(
66 lambda d: d[section][0].update(note_number="NONEXISTENT"),
67 code,
68 )
69
70
71 def test_missing_policy_remains_a_blocked_candidate_not_parse_error():
72 data = pipeline_manifest()
73 data["balance_sheet_policies"].pop()
74 assert len(parse(data).balance_sheet_policies) == 3
75
76
77 def test_duplicate_cash_note_selection_rejected():
78 reject(
79 lambda d: d["cash_balance_notes"].append(
80 deepcopy(d["cash_balance_notes"][0])
81 ),
82 "PIPELINE_MANIFEST_DUPLICATE_CASH_NOTE_SELECTION",
83 )
84
85
86 def test_cash_note_selection_without_reference_rejected():
87 reject(
88 lambda d: d["cash_balance_notes"][0].update(note_number="MISSING"),
89 "PIPELINE_MANIFEST_CASH_NOTE_REFERENCE_MISSING",
90 )
91
92
93 def test_cash_note_cannot_select_a_liability_or_equity_policy():
94 reject(
95 lambda d: d["cash_balance_notes"][0].update(
96 statement_section="Current liabilities", note_number="L01",
97 ),
98 "PIPELINE_MANIFEST_CASH_NOTE_NOT_ASSET",
99 )
100
101
102 def test_cash_note_cannot_select_an_unmapped_asset_policy():
103 reject(
104 lambda d: d["balance_sheet_policies"].pop(0),
105 "PIPELINE_MANIFEST_CASH_NOTE_NOT_ASSET",
106 )
107
108
109 def test_duplicate_cash_account_registry_entry_rejected():
110 reject(
111 lambda d: d["cash_accounts"].append(deepcopy(d["cash_accounts"][0])),
112 "PIPELINE_MANIFEST_DUPLICATE_CASH_ACCOUNT",
113 )
114
115
116 def test_duplicate_counterpart_policy_rejected():
117 reject(
118 lambda d: d["counterpart_policies"].append(
119 deepcopy(d["counterpart_policies"][0])
120 ),
121 "PIPELINE_MANIFEST_DUPLICATE_COUNTERPART_POLICY",
122 )
123
124
125 def test_cash_account_cannot_have_non_cash_counterpart_policy():
126 reject(
127 lambda d: d["counterpart_policies"][0].update(account_code="CASH"),
128 "PIPELINE_MANIFEST_CASH_COUNTERPART_OVERLAP",
129 )
130
131
132 def test_duplicate_transaction_line_id_rejected():
133 reject(
134 lambda d: d["transactions"].append(deepcopy(d["transactions"][0])),
135 "PIPELINE_MANIFEST_DUPLICATE_TRANSACTION_LINE",
136 )
137
138
139 def test_unknown_cash_account_in_transaction_rejected():
140 reject(
141 lambda d: d["transactions"][0].update(cash_account_code="UNKNOWN"),
142 "PIPELINE_MANIFEST_UNKNOWN_CASH_ACCOUNT",
143 )
144
145
146 def test_unknown_counterpart_account_in_transaction_rejected():
147 reject(
148 lambda d: d["transactions"][0].update(counterpart_account_code="UNKNOWN"),
149 "PIPELINE_MANIFEST_UNKNOWN_COUNTERPART_ACCOUNT",
150 )
151
152
153 def test_same_cash_and_counterpart_account_rejected():
154 reject(
155 lambda d: d["transactions"][0].update(counterpart_account_code="CASH"),
156 "PIPELINE_MANIFEST_SAME_ACCOUNT_PAIR",
157 )
158
159
160 @pytest.mark.parametrize("section", [
161 "references",
162 "balance_sheet_policies",
163 "income_statement_policies",
164 "equity_movement_policies",
165 "cash_balance_notes",
166 ])
167 @pytest.mark.parametrize("bad", [None, 0, False, 1.5, " ", "A\nB", " A"])
168 def test_invalid_optional_subnote_type_or_control_char_rejected(section, bad):
169 reject(
170 lambda d: d[section][0].update(subnote_code=bad),
171 "PIPELINE_MANIFEST_" + section.upper() + "_ROW_INVALID",
172 )
173
174
175 def test_valid_blank_subnotes_remain_valid():
176 parsed = parse(pipeline_manifest())
177 assert all(x.subnote_code == "" for x in parsed.references)
178
179
180 def test_references_for_cash_flow_may_exist_without_presentation_policy():
181 data = pipeline_manifest()
182 data["references"].append({
183 "statement": "CF", "section": "Cash flow", "note_number": "C00",
184 "subnote_code": "", "expected_closing_exposure": "0",
185 "evidence_ref": "SYNTH-CF-REF",
186 })
187 parsed = parse(data)
188 assert len(parsed.references) == 9