Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 4, 01:45 UTC
docs(mapping): specify stale-note carry-forward guard and verification
davoodmehraban89 committed
Oct 30, 2026 at 17:29 UTC
6d6da288a79f13d1f5634c3d9a4c2516f8dbbcf2
1 file changed
+18
docs/superpowers/specs/2026-10-30-carry-forward-stale-source-note.md
new
+18
@@ -0,0 +1,18 @@
1
+# Issue #37 — stale source note prevention in carry-forward
2
+
3
+**Status:** Proposed Draft PR #45; not accepted, not merged. **Base:** unmerged PR #30 `dfcf3f008df54498759243001bdfcd98669a8f23` (parent PR #26 also Draft). Accepted branch unaffected.
4
+
5
+## Invariant and failure mode
6
+
7
+Rule selection uses latest MappingRule per `rule_key` (version descending, id descending), but that latest rule may still target an **older** NoteDefinition of the same `note_number`. Carrying it to a current target-year note would silently perpetuate an obsolete accounting classification. Never treat matching note numbers as an approval to resurrect stale source rules.
8
+
9
+- Read all source-year NoteDefinitions, deterministically ordered by `note_number, version DESC, id DESC`.
10
+- Resolve latest source-year NoteDefinition per `note_number`.
11
+- If the selected latest rule references any older source NoteDefinition, return `("rule_key", "source_note_stale")` in the stable `skipped` queue and **no candidate**.
12
+- Preserve original `source_note_missing`, `target_account_missing`, `target_note_missing`, `target_rule_exists` reasons, target-year Draft checks, chronological company/year checks and current rule selection.
13
+- If both source rule and source note are current, accept only a **read-only preview**; no automatic persistence, target guessing, new rule or flush.
14
+- The caller must obtain explicit accountant approval before saving through separately governed mapping service. No real ledger figures or canonical workbooks are touched.
15
+
16
+## Acceptance
17
+
18
+Synthetic regressions cover stale source v1 vs v2/v3, current source note, preserved target latest-note resolution, and pending unrelated Session changes not autoflushed. Full Backend CI, Alembic upgrade/downgrade, compileall on final exact SHA; separate non-author C1 technical, C2 accounting and C3 acceptance checks. No release or merge permitted while reviewers/parents unaccepted. Raw SQL/provider concurrency outside scope.