codex/windows-native-pilot-shell-20261030
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 | # Gate 3 — read-only batch Mapping change classification |
| 2 | |
| 3 | **Proposed Draft PR #51**, child of **unmerged Draft PR #50** at exact SHA `f79947a8624adbd8e84c3f8247ac3ca4a7bd4240`; ultimately depends on Draft #26 and accepted base `source-data-cleanup@7dc864fd032f0c4ae4d650d89304a01286a6d914`. |
| 4 | |
| 5 | **Problem:** a five-column Excel import currently calls `save_mapping_rule` directly, and a manual preview only evaluates one mapping. Bulk review must not silently use first/last matching row or apply one good row while hiding another conflicting/invalid row. This PR introduces a READ-ONLY, provider-neutral proposal classifier, **not** an approved Excel importer or an authorization change. |
| 6 | |
| 7 | ## Canonical input, classification and safe boundary |
| 8 | |
| 9 | `ProposedMappingRow` carries explicit source locator, rule key, literal account code, actual in-scope note ID, mapping type, and expected persisted base version. Future Excel/manual/connector adapters must provide a validated row locator and exact scope; no source system table/column is invented. |
| 10 | |
| 11 | A batch preview is bounded to **1–10,000** typed rows with unique, nonblank, trimmed, bounded source locators. It validates the year ID and requires the specified year to be Draft. It checks that no related financial-domain ORM edits are pending; uses `Session.no_autoflush` and does not commit or write. |
| 12 | |
| 13 | For each scoped `rule_key`: |
| 14 | - **new:** no saved version; proposed version one; captures full old/new preview. |
| 15 | - **changed:** an existing rule is modified with exact current expected version; shows persisted old values and next proposed version. |
| 16 | - **unchanged:** current persisted rule is exactly the proposed content; no new version is produced, and no fake review decision is counted. |
| 17 | - **coalesced:** repeated identical input for the same rule key, including expected version; preserve the original and additional row locators, count at most one new/changed proposal. |
| 18 | - **conflict:** two or more rows for a rule key have different target/account/mapping-type/expected-base content; **every conflicting row** receives a conflict result. No silent first/last wins. |
| 19 | - **invalid:** nonexistent or stale account/note, cross-year target, wrong expected version, invalid input, or an identical repeat of an invalid first proposal. |
| 20 | |
| 21 | Any conflict or invalid item sets `ready_for_review=False` **for the entire batch**, even if other rows are valid. An entirely unchanged batch is not an approvable change. A read-only preview never applies rules; omitted existing rules are not deletion instructions. |
| 22 | |
| 23 | Outputs include per-row reason, stable locators, optional `MappingChangePreview`, deterministic review checksum and counts. This checksum is UNSIGNED: no actor identity, audit event, authenticated review, verified authorization, transaction lock or approval is encoded. An external apply service would still need transactionally re-validate the entire batch; there is deliberately **no apply function** here. |
| 24 | |
| 25 | ## Known limits and gates |
| 26 | |
| 27 | - `mapping_change_preview.py` raises a typed `MappingNoChange` (subclass of the existing validation error) for valid no-ops; avoids unsafe error-message parsing. Existing public error semantics are preserved. |
| 28 | - Current `mapping_excel.import_mapping_workbook` is **unchanged** and can still save without this batch preview. It must be routed through a future approved common proposal/apply service; this PR does not claim bypass elimination. |
| 29 | - Source locator labels are presentation-only; an input adapter must attest actual source file SHA, sheet, and row. This batch preview is not a financial-source reconciliation. |
| 30 | - Different rule keys that overlap on a ledger account are not resolved by rule-key duplicate detection. Accounting owners must approve full account hierarchy, source predicate, multi-match precedence and note/subnote semantics before such overlap can be safely classified. |
| 31 | - The method is read-only but does not provide a cross-database transactionally consistent snapshot under all isolation levels. External SQL writers may mutate facts after preview; Issue #43 requires provider-level enforcement and concurrency controls. |
| 32 | - Genuine C1/C2/C3 independent reviewers and branch protection remain Issue #39; full durable Draft→Reviewed→Approved and audit remain Issue #49. Do not merge Draft #51 until parents and reviews are accepted. |
| 33 | |
| 34 | ## Acceptance harness |
| 35 | |
| 36 | Synthetic cases: first-time batch without writes; identical duplicates coalesced; conflicting duplicates poison every row; valid old/new diff and no-op; stale version rejects only affected row and blocks all approval; foreign-year and unknown accounts; obsolete same-year target; all-noop no approval delta; deterministic digest and unrelated no-autoflush; pending dirty MappingRule rejected; empty/malformed/oversized batch; repeated locator; Approved/Locked year; malformed row fail closed. Exact-final-SHA remote GitHub CI, migration round-trip and compile needed. Do not read/change canonical financial XLSX/PDF, `data/`, customer databases, migrations, dependencies, workflows or releases. |
| 37 | |
| 38 | Rollback: close this unmerged Draft, or use an independently reviewed revert after authorized merge. |
| 39 | |
| 40 | |
| 41 | ## Additional financial identity and provenance hardening |
| 42 | |
| 43 | - Python treats `True == 1`; a malformed Boolean `target_note_id=True` or `expected_base_version=True` must never coalesce with a valid integer `1`. Comparison signatures preserve **actual Python type** for each identifier/value; differing types yield explicit conflicting-source results, not a false "coalesced" success. |
| 44 | - A `source_locator` is an auditable provenance label; reject Unicode category `Cc`, `Cf`, and `Cs` (including newline, tab, NUL, bidi overrides and invisible format characters) rather than allowing log/row-spoofing. Source file hashes and actual cell coordinates must still be verified by the later Excel adapter. |
| 45 | - These are fail-closed **pre-review** rules only. They do not confer authenticated ownership, signed review, or ability to apply any Mapping proposal. |