Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 3, 18:15 UTC
codex/aram-mapping-source-parser-20261101
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 | """Synthetic inspection package creation and safety tests.""" |
| 2 | from __future__ import annotations |
| 3 | |
| 4 | from hashlib import sha256 |
| 5 | import json |
| 6 | |
| 7 | import pytest |
| 8 | |
| 9 | from aram_backend.five_statement_pipeline_cli import run_pipeline_cli |
| 10 | from aram_backend.synthetic_five_statement_demo import ( |
| 11 | DEMO_MANIFEST, DEMO_NOTICE, DEMO_WORKBOOK, |
| 12 | main, pipeline_manifest, source_workbook, write_demo_bundle, |
| 13 | ) |
| 14 | |
| 15 | |
| 16 | def test_generated_demo_bundle_runs_real_five_statement_pipeline(tmp_path): |
| 17 | destination = tmp_path / "ARAM-DEMO-SYNTHETIC-ONLY" |
| 18 | workbook, manifest = write_demo_bundle(destination) |
| 19 | assert workbook.name == DEMO_WORKBOOK |
| 20 | assert manifest.name == DEMO_MANIFEST |
| 21 | assert (destination / DEMO_NOTICE).is_file() |
| 22 | assert "SYNTHETIC" in (destination / DEMO_NOTICE).read_text(encoding="utf-8") |
| 23 | assert len(tuple(destination.iterdir())) == 3 |
| 24 | |
| 25 | original_workbook = sha256(workbook.read_bytes()).hexdigest() |
| 26 | original_manifest = sha256(manifest.read_bytes()).hexdigest() |
| 27 | result = run_pipeline_cli(str(workbook), str(manifest)) |
| 28 | assert result.eligible_for_analyst_review, result.findings |
| 29 | assert result.balance_sheet.assets_total == "100" |
| 30 | assert result.income_statement.net_result == "20" |
| 31 | assert result.equity_changes.closing_equity_total == "90" |
| 32 | assert result.cash_flow.closing_cash_and_equivalents == "50" |
| 33 | assert not result.releasable and not result.official_financial_statement |
| 34 | assert sha256(workbook.read_bytes()).hexdigest() == original_workbook |
| 35 | assert sha256(manifest.read_bytes()).hexdigest() == original_manifest |
| 36 | |
| 37 | |
| 38 | def test_example_manifest_is_structurally_parseable_and_not_real_company_data(): |
| 39 | document = pipeline_manifest() |
| 40 | assert document["schema_version"] == 1 |
| 41 | assert document["company_code"] == "001" |
| 42 | assert all(str(item["evidence_ref"]).startswith("SYNTH-") for item in document["references"]) |
| 43 | assert all(str(item["line_id"]).startswith("CF-") for item in document["transactions"]) |
| 44 | assert source_workbook()[:2] == b"PK" |
| 45 | |
| 46 | |
| 47 | def test_generator_never_overwrites_an_existing_directory_or_file(tmp_path): |
| 48 | destination = tmp_path / "EXISTING-DATA" |
| 49 | destination.mkdir() |
| 50 | original = destination / "private.xlsx" |
| 51 | original.write_bytes(b"private untouched") |
| 52 | before = sha256(original.read_bytes()).hexdigest() |
| 53 | with pytest.raises(FileExistsError): |
| 54 | write_demo_bundle(destination) |
| 55 | assert sha256(original.read_bytes()).hexdigest() == before |
| 56 | assert list(destination.iterdir()) == [original] |
| 57 | |
| 58 | |
| 59 | def test_generator_never_overwrites_existing_demo_bundle(tmp_path): |
| 60 | directory = tmp_path / "ARAM-DEMO" |
| 61 | workbook, manifest = write_demo_bundle(directory) |
| 62 | digests = ( |
| 63 | sha256(workbook.read_bytes()).hexdigest(), |
| 64 | sha256(manifest.read_bytes()).hexdigest(), |
| 65 | ) |
| 66 | with pytest.raises(FileExistsError): |
| 67 | write_demo_bundle(directory) |
| 68 | assert ( |
| 69 | sha256(workbook.read_bytes()).hexdigest(), |
| 70 | sha256(manifest.read_bytes()).hexdigest(), |
| 71 | ) == digests |
| 72 | |
| 73 | |
| 74 | def test_generator_rejects_symlink_directory(tmp_path): |
| 75 | destination = tmp_path / "SENSITIVE" |
| 76 | destination.mkdir() |
| 77 | link = tmp_path / "ALIAS" |
| 78 | try: |
| 79 | link.symlink_to(destination, target_is_directory=True) |
| 80 | except (OSError, NotImplementedError): |
| 81 | pytest.skip("Symlinks unavailable on this runner") |
| 82 | with pytest.raises(FileExistsError): |
| 83 | write_demo_bundle(link) |
| 84 | assert not list(destination.iterdir()) |
| 85 | |
| 86 | |
| 87 | def test_module_cli_requires_explicit_output_directory(tmp_path): |
| 88 | with pytest.raises(SystemExit): |
| 89 | main([]) |
| 90 | destination = tmp_path / "FIRST-DEMO" |
| 91 | assert main(["--output-dir", str(destination)]) == 0 |
| 92 | assert (destination / DEMO_WORKBOOK).is_file() |
| 93 | with pytest.raises(SystemExit) as exc: |
| 94 | main(["--output-dir", str(destination)]) |
| 95 | assert exc.value.code == 2 |