fix: a split's offset line follows its parent when it is recategorized (#454) #515

Merged
maximus merged 4 commits from issue-454-split-offset-follows-parent into main 2026-10-30 00:38:49 +00:00
Owner

Resolves #454
Generated autonomously by /autopilot run of 2026-10-27

Link 1 of 3 of the stack #454 → #513 → #479, milestone planned-2026-10-27-periode-et-repartition. Base: main (eecbd2b).

Level: normal, set by src/services/transactionService.ts (application code). No file of the Haut table: no network call, no consent, no migration, neither lock nor manifest; db.ts is read only. docs/architecture.md, docs/adr/0022-canal-evenements-donnees.md and CLAUDE.md stay at least normal; the CHANGELOGs and STATE.md are low.

Summary

Recategorizing a split transaction moved the parent only. Its offset line, the child of +50 that saveSplitAdjustment writes in the parent's category to cancel the part sent to other categories, stayed in the former category. Every report adds all rows, so a transaction of −120 with −50 split to B, moved from A to C, left +50 in A and −120 in C instead of −70 in C. The keyword path had the same defect, and its preview also offered the children of a split (they carry the parent's description), which it then recategorized alone.

  • src/utils/splitOffset.ts (new): isOffsetChild(parent, child) on { description, amount }: the parent's description, the sign opposite to the parent's, a non-zero amount. The split window's rule, without its category condition (decision D1: no role column, no migration). Header comment: unrelated to src/shared/splitGate.ts.
  • src/services/splitOffsetService.ts (new): propagateCategoryToOffsets(db, parentId, categoryId): Promise<number>. On the handle it receives: reads the row (id, description, amount, is_split, parent_transaction_id), returns 0 without writing for an unknown id, a transaction that is not split, or a child (children carry is_split = 1 too); otherwise reads the children (WHERE parent_transaction_id = $1 ORDER BY id) and gives categoryId (and updated_at) to each one isOffsetChild recognizes, whatever its current category (decision D2: an offset left in a former category is repaired at the parent's next change). It never issues BEGIN/COMMIT/ROLLBACK, never calls getDb(), never notifies; is_manually_categorized of the offset is left as it is.
  • transactionService.ts: updateTransactionCategory runs withTransaction((db) => updateTransactionCategoryInTransaction(db, …)), which issues BEGIN, the parent's UPDATE (unchanged, toSqlFlag), the propagation, COMMIT, and ROLLBACK then rethrow in its catch (the pattern of applyKeywordInTransaction). notifyDataChanged() after withTransaction returns, never on a failure.
  • categorizationService.ts: previewKeywordMatches adds AND t.parent_transaction_id IS NULL; in applyKeywordInTransaction, the loop's UPDATE adds AND parent_transaction_id IS NULL (a child passed by mistake is never recategorized alone), updatedTransactions adds rowsAffected, and propagateCategoryToOffsets(db, txId, input.categoryId) runs for each id before the COMMIT.
  • SplitAdjustmentModal.tsx: the children are filtered with !isOffsetChild(transaction, c), so an offset left in a former category is no longer shown as a row of the split.

No migration (v1→v17 untouched), consolidated_schema.sql and src-tauri/** untouched. No import cycle:

$ grep -n "^import" src/services/splitOffsetService.ts
10:import type Database from "@tauri-apps/plugin-sql";
11:import { isOffsetChild } from "../utils/splitOffset";
12:import { toSqlFlag } from "../utils/sqlFlag";
$ grep -n "splitOffsetService\|from \"./categorizationService\"" src/services/transactionService.ts src/services/categorizationService.ts
src/services/categorizationService.ts:3:import { propagateCategoryToOffsets } from "./splitOffsetService";
src/services/transactionService.ts:4:import { categorizeBatch } from "./categorizationService";
src/services/transactionService.ts:5:import { propagateCategoryToOffsets } from "./splitOffsetService";

Files

  • src/utils/splitOffset.ts, src/utils/splitOffset.test.ts (new, 7 tests).
  • src/services/splitOffsetService.ts, src/services/splitOffsetService.test.ts (new, 10 tests; getDb() mocked to reject, a subscriber catches any notification).
  • src/services/transactionService.ts, src/services/transactionService.test.ts (regression test, plain transaction, failed offset move, handle only; the tests of #390 and #396 find the parent's UPDATE by its SQL and answer the reads of the propagation).
  • src/services/categorizationService.ts, src/services/categorizationService.test.ts (preview filter, offset moved by the keyword, child never alone with rowsAffected, failed offset move, handle only; reads answered in every existing test, the BEGIN/COMMIT order test included).
  • src/components/transactions/SplitAdjustmentModal.tsx, src/components/transactions/SplitAdjustmentModal.test.ts (new, 3 tests through src/test/hookHarness.ts: the loading effect run by commit(), the rows read from the props of their CategoryCombobox and amount field).
  • docs/architecture.md (29 services, 23 described, 21 utilities; rows of transactionService.ts, categorizationService.ts, splitOffsetService.ts), docs/adr/0022-canal-evenements-donnees.md (row of transactionService.ts: notification after the COMMIT, none after a ROLLBACK), CLAUDE.md (line 59 only: « 28 services métier » → 29), CHANGELOG.md, CHANGELOG.fr.md (one Fixed / Corrigé entry), STATE.md (one sub-bullet).

Decisions (tier)

All in the decisions comment that follows; in short:

  • [MEDIUM] A manual check in the app is due at the next release (section below, one STATE.md sub-bullet): the tests and the SQLite replay do not run the Tauri runtime on the most frequent write path, now a transaction, nor the real split window and reports.
  • [HIGH] Regression test first, red on main; mocked reads answered by SQL; tests added beyond the list of the issue to kill mutations it left green (split window M12, getDb() M14/M15, zero amount M7); is_split read through toSqlFlag; rowsAffected counted as in categoryMigrationService.ts; counts recomputed with the command architecture.md cites; ADR 0022 row updated; user guide unchanged (same action, right totals).

Proof

Regression test, on the code of main (eecbd2b, the test file of this branch only):

 FAIL  src/services/transactionService.test.ts > updateTransactionCategory — a split's offset line follows its parent (#454) > moves the offset to the new category with the parent, between one BEGIN and its COMMIT
AssertionError: expected undefined to deeply equal [ 9, 7 ]
 ❯ src/services/transactionService.test.ts:150:38
    149|     // The offset follows the parent to C…
    150|     expect(sent[offsetMove]?.params).toEqual([C, SPLIT_OFFSET.id]);
 Test Files  1 failed (1)
      Tests  1 failed | 10 skipped (11)

SQLite replay (no vitest test runs the SQL: they mock the database). python3 3.12.3, SQLite 3.45.1, consolidated_schema.sql of the branch, PRAGMA foreign_keys = ON as sqlx sets it. The SQL is extracted from the TypeScript sources as written (template literals of saveSplitAdjustment, getSplitChildren, updateTransactionCategoryInTransaction, propagateCategoryToOffsets, previewKeywordMatches, applyKeywordInTransaction; git show origin/main: for the code before the fix), $1 bound by name; explicit BEGIN/COMMIT/ROLLBACK in autocommit mode. Totals by category add every row, as the reports do. Script and log in the run folder, nothing committed.

Scenario Totals
S0: −120 in A, −50 split to B (SQL of saveSplitAdjustment) A −70, B −50
S1 main: parent A → C A +50, B −50, C −120 (bug reproduced)
S2 fix: parent A → C B −50, C −70, A empty
S3 main: keyword, every offered row checked (the dialog's default); the preview offers the parent, the entry and the offset C −120: B's −50 lost too
S3 fix: keyword; the preview offers the parent only B −50, C −70; updatedTransactions 1, 1 offset moved
S4 fix: keyword given the entry's and the offset's ids unchanged, A −70, B −50; updatedTransactions 0 (rowsAffected), 0 moved
S5 D2: offset left in A by main (S1), then fix C → D, by the list and by the keyword B −50, D −70
S6 fix: offset UPDATE fails (TEMP trigger RAISE(ABORT)) ROLLBACK: parent still in A, A −70, B −50, no open transaction
S7 fix: a plain transaction A → C; a split income (+2000, +500 to B) REV → D plain: 0 moved, no read of children; income: B +500, D +1500

Rows of the split window after S1 (SQL of getSplitChildren): the filter of main gives [B 50, A 50], !isOffsetChild gives [B 50].

Probe, build, tests:

  • Probe: src/zz_probe.test.ts with one failing expect, npx vitest run src/zz_probe.test.ts: rc=1, file removed.
  • npm run build (tsc + vite) green.
  • npm test: 165 files / 2776 tests on main → 168 files / 2805 tests, all green.

Mutations: 18, one at a time on the committed code, each restored by git checkout -- with git status --short empty after it; the five test files of the change run after each (script and log in the run folder). All red.

# File Mutation Failing tests
M1 transactionService.ts propagation removed 2
M2 categorizationService.ts propagation removed (keyword) 3
M3 splitOffset.ts sign rule inverted (same sign as the parent) 16
M4 splitOffset.ts description condition removed 2
M5 categorizationService.ts preview filter removed 1
M6 transactionService.ts ROLLBACK removed 2
M7 splitOffset.ts child.amount !== 0 removed 1 (green on the first pass: a zero parent with a zero child added, e130c34)
M8 splitOffsetService.ts child check (parent_transaction_id) removed 1
M9 splitOffsetService.ts is_split check removed 1
M10 categorizationService.ts AND parent_transaction_id IS NULL of the loop removed 1
M11 categorizationService.ts updatedTransactions++ again 1
M12 SplitAdjustmentModal.tsx filter of main back 1
M13 transactionService.ts notification inside the callback, lock held 1
M14 transactionService.ts propagation through await getDb() (a deadlock under the real lock) 1
M15 categorizationService.ts same on the keyword path 1
M16 transactionService.ts propagation after the COMMIT 2
M17 splitOffsetService.ts children read restricted to the parent's category (D2 broken) 1
M18 transactionService.ts BEGIN removed 4

REVIEW.md

Zone « Migrations, profils et données »:

  • Single lock and withTransaction: updateTransactionCategory now holds the lock for its whole BEGIN..COMMIT, on the handle its callback receives; propagateCategoryToOffsets uses only the handle it is given (M14, M15) and issues no BEGIN/COMMIT, since it also runs inside the BEGIN of the keyword path. Piège « Transaction hors verrou » avoided.
  • toSqlFlag: the parent's UPDATE still binds toSqlFlag(isManual) (tests of #390); no boolean bound anywhere; is_split read through toSqlFlag.
  • notifyDataChanged() after success: after withTransaction returns (after the COMMIT, lock released), never after a ROLLBACK (tests of #396, M13); ADR 0022 row updated to say so.
  • No schema change: consolidated_schema.sql and the table/index/migration counts untouched.

Zone « i18n et documentation »: no new string; architecture.md and both CHANGELOGs updated; user guide unchanged (no change of usage). Pièges « Tests sans jsdom » and « Faux t »: the split window test goes through hookHarness (effect run by commit()) and i18nMock. REVIEW.md itself unchanged: no fact it cites becomes false.

Hors périmètre

  • Atomicity of saveSplitAdjustment and deleteSplitAdjustment (neither withTransaction nor notification): #513, the next link of this stack, which starts from this branch.
  • A split already broken stays so until its transaction changes category again (decision D2): no data migration, nothing in the Journal.
  • Observed while reading, outside this issue, no issue opened: restoring a backup that holds a split fails. attachTransactions (dataExportService.ts) re-inserts the exported children with their old parent_transaction_id after DELETE FROM transactions, while the parents get new ids, and sqlx opens SQLite with foreign_keys = ON (sqlx-sqlite 0.8.6, options/mod.rs:185). Replayed on consolidated_schema.sql with the export query and the INSERT as written: FOREIGN KEY constraint failed. Not checked in the app.

For the reviewer

  • updatedTransactions now counts the rows the guarded UPDATE changed (rowsAffected): a child's id counts 0. AddKeywordDialog does not display it today.
  • The former rule of the split window (same category, opposite sign) and isOffsetChild (same description, opposite sign, non-zero) differ only for an offset whose description differs from its parent's: no query changes a description (planning decision of the issue).
  • The replay extracts the SQL from the sources, so it runs the text of this branch, not a copy; a change of one of these queries changes what it replays.
  • The decisions comment and the author's self-review (not independent) follow as PR comments.

Vérifications manuelles dues (prochaine release)

Also added as one sub-bullet at the end of « Vérifications dues à la release suivante » in STATE.md.

In the Base edition, on a test profile, in FR then in EN:

  1. Transactions: split a transaction of category A with the Split button (« Répartition »), one row to B for part of its amount. Note the totals of A and B in the dashboard or the reports.
  2. Change its category to C in the list. Reports: A no longer holds anything from it, B keeps its part, C holds the rest (the amount minus B's part).
  3. Reopen the split window: one row (B); the « Base » line shows C and the rest.
  4. Right-click another split transaction → « Add as keyword » (« Ajouter comme mot-clé »), with a word of its description: the preview lists the transaction once, none of its split parts; apply to a category D: same result as step 2.
  5. A few quick category changes in a row: no « database is locked ».
  6. If a profile kept a split recategorized under v0.17.2 (its former category holds an amount of the opposite sign): change its category once more; the former category is emptied.

🤖 Generated with Claude Code

Resolves #454 Generated autonomously by /autopilot run of 2026-10-27 Link 1 of 3 of the stack #454 → #513 → #479, milestone `planned-2026-10-27-periode-et-repartition`. Base: `main` (`eecbd2b`). **Level: normal**, set by `src/services/transactionService.ts` (application code). No file of the Haut table: no network call, no consent, no migration, neither lock nor manifest; `db.ts` is read only. `docs/architecture.md`, `docs/adr/0022-canal-evenements-donnees.md` and `CLAUDE.md` stay at least normal; the CHANGELOGs and `STATE.md` are low. ## Summary Recategorizing a split transaction moved the parent only. Its offset line, the child of `+50` that `saveSplitAdjustment` writes in the parent's category to cancel the part sent to other categories, stayed in the former category. Every report adds all rows, so a transaction of −120 with −50 split to B, moved from A to C, left +50 in A and −120 in C instead of −70 in C. The keyword path had the same defect, and its preview also offered the children of a split (they carry the parent's description), which it then recategorized alone. - **`src/utils/splitOffset.ts`** (new): `isOffsetChild(parent, child)` on `{ description, amount }`: the parent's description, the sign opposite to the parent's, a non-zero amount. The split window's rule, without its category condition (decision D1: no role column, no migration). Header comment: unrelated to `src/shared/splitGate.ts`. - **`src/services/splitOffsetService.ts`** (new): `propagateCategoryToOffsets(db, parentId, categoryId): Promise<number>`. On the handle it receives: reads the row (`id, description, amount, is_split, parent_transaction_id`), returns 0 without writing for an unknown id, a transaction that is not split, or a child (children carry `is_split = 1` too); otherwise reads the children (`WHERE parent_transaction_id = $1 ORDER BY id`) and gives `categoryId` (and `updated_at`) to each one `isOffsetChild` recognizes, **whatever its current category** (decision D2: an offset left in a former category is repaired at the parent's next change). It never issues `BEGIN`/`COMMIT`/`ROLLBACK`, never calls `getDb()`, never notifies; `is_manually_categorized` of the offset is left as it is. - **`transactionService.ts`**: `updateTransactionCategory` runs `withTransaction((db) => updateTransactionCategoryInTransaction(db, …))`, which issues `BEGIN`, the parent's `UPDATE` (unchanged, `toSqlFlag`), the propagation, `COMMIT`, and `ROLLBACK` then rethrow in its `catch` (the pattern of `applyKeywordInTransaction`). `notifyDataChanged()` after `withTransaction` returns, never on a failure. - **`categorizationService.ts`**: `previewKeywordMatches` adds `AND t.parent_transaction_id IS NULL`; in `applyKeywordInTransaction`, the loop's `UPDATE` adds `AND parent_transaction_id IS NULL` (a child passed by mistake is never recategorized alone), `updatedTransactions` adds `rowsAffected`, and `propagateCategoryToOffsets(db, txId, input.categoryId)` runs for each id before the `COMMIT`. - **`SplitAdjustmentModal.tsx`**: the children are filtered with `!isOffsetChild(transaction, c)`, so an offset left in a former category is no longer shown as a row of the split. No migration (v1→v17 untouched), `consolidated_schema.sql` and `src-tauri/**` untouched. No import cycle: ``` $ grep -n "^import" src/services/splitOffsetService.ts 10:import type Database from "@tauri-apps/plugin-sql"; 11:import { isOffsetChild } from "../utils/splitOffset"; 12:import { toSqlFlag } from "../utils/sqlFlag"; $ grep -n "splitOffsetService\|from \"./categorizationService\"" src/services/transactionService.ts src/services/categorizationService.ts src/services/categorizationService.ts:3:import { propagateCategoryToOffsets } from "./splitOffsetService"; src/services/transactionService.ts:4:import { categorizeBatch } from "./categorizationService"; src/services/transactionService.ts:5:import { propagateCategoryToOffsets } from "./splitOffsetService"; ``` ## Files - `src/utils/splitOffset.ts`, `src/utils/splitOffset.test.ts` (new, 7 tests). - `src/services/splitOffsetService.ts`, `src/services/splitOffsetService.test.ts` (new, 10 tests; `getDb()` mocked to reject, a subscriber catches any notification). - `src/services/transactionService.ts`, `src/services/transactionService.test.ts` (regression test, plain transaction, failed offset move, handle only; the tests of #390 and #396 find the parent's `UPDATE` by its SQL and answer the reads of the propagation). - `src/services/categorizationService.ts`, `src/services/categorizationService.test.ts` (preview filter, offset moved by the keyword, child never alone with `rowsAffected`, failed offset move, handle only; reads answered in every existing test, the `BEGIN`/`COMMIT` order test included). - `src/components/transactions/SplitAdjustmentModal.tsx`, `src/components/transactions/SplitAdjustmentModal.test.ts` (new, 3 tests through `src/test/hookHarness.ts`: the loading effect run by `commit()`, the rows read from the props of their `CategoryCombobox` and amount field). - `docs/architecture.md` (29 services, 23 described, 21 utilities; rows of `transactionService.ts`, `categorizationService.ts`, `splitOffsetService.ts`), `docs/adr/0022-canal-evenements-donnees.md` (row of `transactionService.ts`: notification after the `COMMIT`, none after a `ROLLBACK`), `CLAUDE.md` (line 59 only: « 28 services métier » → 29), `CHANGELOG.md`, `CHANGELOG.fr.md` (one Fixed / Corrigé entry), `STATE.md` (one sub-bullet). ## Decisions (tier) All in the decisions comment that follows; in short: - [MEDIUM] A manual check in the app is due at the next release (section below, one `STATE.md` sub-bullet): the tests and the SQLite replay do not run the Tauri runtime on the most frequent write path, now a transaction, nor the real split window and reports. - [HIGH] Regression test first, red on `main`; mocked reads answered by SQL; tests added beyond the list of the issue to kill mutations it left green (split window M12, `getDb()` M14/M15, zero amount M7); `is_split` read through `toSqlFlag`; `rowsAffected` counted as in `categoryMigrationService.ts`; counts recomputed with the command `architecture.md` cites; ADR 0022 row updated; user guide unchanged (same action, right totals). ## Proof **Regression test, on the code of `main`** (`eecbd2b`, the test file of this branch only): ``` FAIL src/services/transactionService.test.ts > updateTransactionCategory — a split's offset line follows its parent (#454) > moves the offset to the new category with the parent, between one BEGIN and its COMMIT AssertionError: expected undefined to deeply equal [ 9, 7 ] ❯ src/services/transactionService.test.ts:150:38 149| // The offset follows the parent to C… 150| expect(sent[offsetMove]?.params).toEqual([C, SPLIT_OFFSET.id]); Test Files 1 failed (1) Tests 1 failed | 10 skipped (11) ``` **SQLite replay** (no vitest test runs the SQL: they mock the database). python3 3.12.3, SQLite 3.45.1, `consolidated_schema.sql` of the branch, `PRAGMA foreign_keys = ON` as sqlx sets it. The SQL is **extracted from the TypeScript sources as written** (template literals of `saveSplitAdjustment`, `getSplitChildren`, `updateTransactionCategoryInTransaction`, `propagateCategoryToOffsets`, `previewKeywordMatches`, `applyKeywordInTransaction`; `git show origin/main:` for the code before the fix), `$1` bound by name; explicit `BEGIN`/`COMMIT`/`ROLLBACK` in autocommit mode. Totals by category add every row, as the reports do. Script and log in the run folder, nothing committed. | Scenario | Totals | |---|---| | S0: −120 in A, −50 split to B (SQL of `saveSplitAdjustment`) | A −70, B −50 | | S1 `main`: parent A → C | A **+50**, B −50, C **−120** (bug reproduced) | | S2 fix: parent A → C | B −50, C −70, A empty | | S3 `main`: keyword, every offered row checked (the dialog's default); the preview offers the parent, the entry and the offset | C −120: B's −50 lost too | | S3 fix: keyword; the preview offers the parent only | B −50, C −70; `updatedTransactions` 1, 1 offset moved | | S4 fix: keyword given the entry's and the offset's ids | unchanged, A −70, B −50; `updatedTransactions` 0 (`rowsAffected`), 0 moved | | S5 D2: offset left in A by `main` (S1), then fix C → D, by the list and by the keyword | B −50, D −70 | | S6 fix: offset `UPDATE` fails (TEMP trigger `RAISE(ABORT)`) | `ROLLBACK`: parent still in A, A −70, B −50, no open transaction | | S7 fix: a plain transaction A → C; a split income (+2000, +500 to B) REV → D | plain: 0 moved, no read of children; income: B +500, D +1500 | Rows of the split window after S1 (SQL of `getSplitChildren`): the filter of `main` gives `[B 50, A 50]`, `!isOffsetChild` gives `[B 50]`. **Probe, build, tests**: - Probe: `src/zz_probe.test.ts` with one failing `expect`, `npx vitest run src/zz_probe.test.ts`: **rc=1**, file removed. - `npm run build` (tsc + vite) green. - `npm test`: **165 files / 2776 tests** on `main` → **168 files / 2805 tests**, all green. **Mutations**: 18, one at a time on the committed code, each restored by `git checkout --` with `git status --short` empty after it; the five test files of the change run after each (script and log in the run folder). All red. | # | File | Mutation | Failing tests | |---|---|---|---| | M1 | `transactionService.ts` | propagation removed | 2 | | M2 | `categorizationService.ts` | propagation removed (keyword) | 3 | | M3 | `splitOffset.ts` | sign rule inverted (same sign as the parent) | 16 | | M4 | `splitOffset.ts` | description condition removed | 2 | | M5 | `categorizationService.ts` | preview filter removed | 1 | | M6 | `transactionService.ts` | `ROLLBACK` removed | 2 | | M7 | `splitOffset.ts` | `child.amount !== 0` removed | 1 (green on the first pass: a zero parent with a zero child added, `e130c34`) | | M8 | `splitOffsetService.ts` | child check (`parent_transaction_id`) removed | 1 | | M9 | `splitOffsetService.ts` | `is_split` check removed | 1 | | M10 | `categorizationService.ts` | `AND parent_transaction_id IS NULL` of the loop removed | 1 | | M11 | `categorizationService.ts` | `updatedTransactions++` again | 1 | | M12 | `SplitAdjustmentModal.tsx` | filter of `main` back | 1 | | M13 | `transactionService.ts` | notification inside the callback, lock held | 1 | | M14 | `transactionService.ts` | propagation through `await getDb()` (a deadlock under the real lock) | 1 | | M15 | `categorizationService.ts` | same on the keyword path | 1 | | M16 | `transactionService.ts` | propagation after the `COMMIT` | 2 | | M17 | `splitOffsetService.ts` | children read restricted to the parent's category (D2 broken) | 1 | | M18 | `transactionService.ts` | `BEGIN` removed | 4 | ## REVIEW.md Zone « Migrations, profils et données »: - **Single lock and `withTransaction`**: `updateTransactionCategory` now holds the lock for its whole `BEGIN`..`COMMIT`, on the handle its callback receives; `propagateCategoryToOffsets` uses only the handle it is given (M14, M15) and issues no `BEGIN`/`COMMIT`, since it also runs inside the `BEGIN` of the keyword path. Piège « Transaction hors verrou » avoided. - **`toSqlFlag`**: the parent's `UPDATE` still binds `toSqlFlag(isManual)` (tests of #390); no boolean bound anywhere; `is_split` read through `toSqlFlag`. - **`notifyDataChanged()` after success**: after `withTransaction` returns (after the `COMMIT`, lock released), never after a `ROLLBACK` (tests of #396, M13); ADR 0022 row updated to say so. - No schema change: `consolidated_schema.sql` and the table/index/migration counts untouched. Zone « i18n et documentation »: no new string; `architecture.md` and both CHANGELOGs updated; user guide unchanged (no change of usage). Pièges « Tests sans jsdom » and « Faux `t` »: the split window test goes through `hookHarness` (effect run by `commit()`) and `i18nMock`. `REVIEW.md` itself unchanged: no fact it cites becomes false. ## Hors périmètre - Atomicity of `saveSplitAdjustment` and `deleteSplitAdjustment` (neither `withTransaction` nor notification): #513, the next link of this stack, which starts from this branch. - A split already broken stays so until its transaction changes category again (decision D2): no data migration, nothing in the Journal. - **Observed while reading, outside this issue, no issue opened**: restoring a backup that holds a split fails. `attachTransactions` (`dataExportService.ts`) re-inserts the exported children with their old `parent_transaction_id` after `DELETE FROM transactions`, while the parents get new ids, and sqlx opens SQLite with `foreign_keys = ON` (`sqlx-sqlite` 0.8.6, `options/mod.rs:185`). Replayed on `consolidated_schema.sql` with the export query and the `INSERT` as written: `FOREIGN KEY constraint failed`. Not checked in the app. ## For the reviewer - `updatedTransactions` now counts the rows the guarded `UPDATE` changed (`rowsAffected`): a child's id counts 0. `AddKeywordDialog` does not display it today. - The former rule of the split window (same category, opposite sign) and `isOffsetChild` (same description, opposite sign, non-zero) differ only for an offset whose description differs from its parent's: no query changes a description (planning decision of the issue). - The replay extracts the SQL from the sources, so it runs the text of this branch, not a copy; a change of one of these queries changes what it replays. - The decisions comment and the author's self-review (not independent) follow as PR comments. ## Vérifications manuelles dues (prochaine release) Also added as one sub-bullet at the end of « Vérifications dues à la release suivante » in `STATE.md`. In the Base edition, on a test profile, in FR then in EN: 1. Transactions: split a transaction of category A with the Split button (« Répartition »), one row to B for part of its amount. Note the totals of A and B in the dashboard or the reports. 2. Change its category to C in the list. Reports: A no longer holds anything from it, B keeps its part, C holds the rest (the amount minus B's part). 3. Reopen the split window: one row (B); the « Base » line shows C and the rest. 4. Right-click another split transaction → « Add as keyword » (« Ajouter comme mot-clé »), with a word of its description: the preview lists the transaction once, none of its split parts; apply to a category D: same result as step 2. 5. A few quick category changes in a row: no « database is locked ». 6. If a profile kept a split recategorized under v0.17.2 (its former category holds an amount of the opposite sign): change its category once more; the former category is emptied. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Recategorizing a split transaction moved the parent only: its offset
line, which cancels in the parent's category the part sent to other
categories, stayed in the former category. Every report adds all rows,
so a transaction of -120 with -50 split to B, moved from A to C, left
+50 in A and -120 in C instead of -70 in C. The keyword path had the
same defect, and its preview also offered the children of a split,
which it then recategorized alone.

- src/utils/splitOffset.ts: isOffsetChild(parent, child), the rule the
  split window already used, extracted and freed from the category: the
  parent's description, the sign opposite to the parent's, a non-zero
  amount (decision D1: no role column, no migration).
- src/services/splitOffsetService.ts: propagateCategoryToOffsets(db,
  parentId, categoryId) gives the parent's new category to the offset
  line, whatever its current category (decision D2: an offset left in a
  former category is repaired at the parent's next change). It runs on
  the caller's transaction handle: no BEGIN/COMMIT, no getDb(), no
  notification. Nothing for an unknown id, a transaction that is not
  split, or a child (children carry is_split = 1 too). Its own module:
  transactionService.ts already imports categorizationService.ts.
- updateTransactionCategory now runs in withTransaction, with its own
  BEGIN, the parent's UPDATE (unchanged, toSqlFlag), the propagation and
  COMMIT, or ROLLBACK and rethrow; it notifies after the COMMIT only.
- previewKeywordMatches offers rows without a parent only; the keyword
  loop's UPDATE skips a child (AND parent_transaction_id IS NULL),
  counts rowsAffected, and propagates for each id before the COMMIT.
- SplitAdjustmentModal leaves out the child isOffsetChild recognizes,
  so an offset left in a former category is no longer shown as a row.

Tests: the regression test of transactionService.test.ts fails on main
(no UPDATE of the offset); the tests of #390 and #396 now find the
parent's UPDATE by its SQL and answer the reads of the propagation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- docs/architecture.md: splitOffsetService.ts in the services table
  (23 rows) and its callers in the rows of transactionService.ts and
  categorizationService.ts; 29 services (ls src/services/*.ts without
  tests) and 21 pure utilities (splitOffset.ts) in the tree.
- CLAUDE.md: "29 services métier" in the tree (that line only).
- ADR 0022: updateTransactionCategory notifies after its COMMIT, once
  the lock is released, and not after a ROLLBACK.
- CHANGELOG.md / CHANGELOG.fr.md: one Fixed / Corrigé entry.

Resolves #454

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test: pin the amount condition of isOffsetChild under a parent of zero (#454)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m30s
e130c346c5
The mutation pass left one mutation green: without `child.amount !== 0`,
every existing case still failed on the sign test. Only under a parent
of zero does a child of zero pass it (Math.sign(0) === -Math.sign(0),
since 0 === -0); the test now covers that case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Décisions prises sans Max (autopilot)

MEDIUM

  • Une vérification manuelle dans l'app est-elle due à la prochaine release ?
    • Choix : oui, courte. Section « Vérifications manuelles dues (prochaine release) » du corps de la PR, et une sous-puce à la fin de « Vérifications dues à la release suivante » dans STATE.md.
    • Écarté : aucune vérification, puisque les tests unitaires et le rejeu SQLite (le SQL extrait des sources tel qu'il est écrit) prouvent la logique et les requêtes. Ils ne font tourner ni le runtime Tauri (le pool de tauri-plugin-sql et le verrou de db.ts, sur le chemin d'écriture le plus fréquent, devenu une transaction) ni la vraie fenêtre de répartition et les vrais rapports.
    • Effet pour l'utilisateur : aucun. Pour Max : un point de plus à la release (édition Base, un profil de test, environ cinq minutes).

HIGH

  • Test de régression écrit d'abord et lancé sur le code de main (eecbd2b) : rouge, expected undefined to deeply equal [ 9, 7 ] (aucun UPDATE de la compensation).
  • Lectures simulées répondues par leur SQL (answerSplitReads, answerReads), toute autre lecture faisant échouer le test, dans chaque test existant de updateTransactionCategory et d'applyKeywordWithReassignment, celui de l'ordre BEGIN/COMMIT compris.
  • Tests ajoutés au-delà de la liste de l'issue, chacun pour tuer une mutation que la liste laissait verte : la fenêtre de répartition par hookHarness (M12), « tout passe par le handle, rien par getDb() » sur les deux chemins (M14, M15), un parent nul avec un enfant nul (M7, resté vert au premier passage, tué par e130c34).
  • is_split lu par toSqlFlag, lien au parent testé par != null ; enfants lus ORDER BY id ; la compensation ne reçoit que category_id et updated_at (is_manually_categorized intact, décision de planification).
  • Boucle du mot-clé : updatedTransactions += Number(result.rowsAffected ?? 0), le motif de categoryMigrationService.ts ; propagation pour chaque identifiant, juste après son UPDATE, la fonction écartant elle-même ce qui n'est pas un parent.
  • Documentation : 29 services (la commande que architecture.md cite pour les hooks, appliquée à src/services), 23 décrits, 21 utilitaires ; ligne 59 de CLAUDE.md seule ; ligne de transactionService.ts du tableau de l'ADR 0022 mise à jour (notification après le COMMIT, aucune après un ROLLBACK) ; guide d'utilisation et clés docs.* inchangés : même geste, totaux justes.
  • Observation hors périmètre, sans issue ouverte : la restauration d'une sauvegarde qui contient une répartition échoue (FOREIGN KEY constraint failed, rejoué sur consolidated_schema.sql), détail dans « Hors périmètre » du corps de la PR.
## Décisions prises sans Max (autopilot) ### MEDIUM - **Une vérification manuelle dans l'app est-elle due à la prochaine release ?** - Choix : oui, courte. Section « Vérifications manuelles dues (prochaine release) » du corps de la PR, et une sous-puce à la fin de « Vérifications dues à la release suivante » dans `STATE.md`. - Écarté : aucune vérification, puisque les tests unitaires et le rejeu SQLite (le SQL extrait des sources tel qu'il est écrit) prouvent la logique et les requêtes. Ils ne font tourner ni le runtime Tauri (le pool de tauri-plugin-sql et le verrou de `db.ts`, sur le chemin d'écriture le plus fréquent, devenu une transaction) ni la vraie fenêtre de répartition et les vrais rapports. - Effet pour l'utilisateur : aucun. Pour Max : un point de plus à la release (édition Base, un profil de test, environ cinq minutes). ### HIGH - Test de régression écrit d'abord et lancé sur le code de `main` (`eecbd2b`) : rouge, `expected undefined to deeply equal [ 9, 7 ]` (aucun `UPDATE` de la compensation). - Lectures simulées répondues par leur SQL (`answerSplitReads`, `answerReads`), toute autre lecture faisant échouer le test, dans chaque test existant de `updateTransactionCategory` et d'`applyKeywordWithReassignment`, celui de l'ordre `BEGIN`/`COMMIT` compris. - Tests ajoutés au-delà de la liste de l'issue, chacun pour tuer une mutation que la liste laissait verte : la fenêtre de répartition par `hookHarness` (M12), « tout passe par le handle, rien par `getDb()` » sur les deux chemins (M14, M15), un parent nul avec un enfant nul (M7, resté vert au premier passage, tué par `e130c34`). - `is_split` lu par `toSqlFlag`, lien au parent testé par `!= null` ; enfants lus `ORDER BY id` ; la compensation ne reçoit que `category_id` et `updated_at` (`is_manually_categorized` intact, décision de planification). - Boucle du mot-clé : `updatedTransactions += Number(result.rowsAffected ?? 0)`, le motif de `categoryMigrationService.ts` ; propagation pour chaque identifiant, juste après son `UPDATE`, la fonction écartant elle-même ce qui n'est pas un parent. - Documentation : 29 services (la commande que `architecture.md` cite pour les hooks, appliquée à `src/services`), 23 décrits, 21 utilitaires ; ligne 59 de `CLAUDE.md` seule ; ligne de `transactionService.ts` du tableau de l'ADR 0022 mise à jour (notification après le `COMMIT`, aucune après un `ROLLBACK`) ; guide d'utilisation et clés `docs.*` inchangés : même geste, totaux justes. - Observation hors périmètre, sans issue ouverte : la restauration d'une sauvegarde qui contient une répartition échoue (`FOREIGN KEY constraint failed`, rejoué sur `consolidated_schema.sql`), détail dans « Hors périmètre » du corps de la PR.
docs(state): manual check of the offset line of a split (#454)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m29s
1fad948f92
One sub-bullet at the end of "Vérifications dues à la release suivante":
the procedure is in the body of PR #515.

Resolves #454

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Niveau : normal

Verdict : APPROVE

Auto-revue de l'auteur (worker /autopilot, maillon 1 sur 3), pas une revue indépendante : la checklist de /pr-review appliquée à la profondeur du niveau normal sur le diff complet de la PR contre sa base main (eecbd2b), tête 1fad948. Elle ne remplace pas /pr-review.

Résumé

La ligne de compensation d'une répartition suit désormais son parent sur les deux chemins de reclassement (liste des transactions, mot-clé avec réaffectation), dans la même transaction que lui, et ni l'aperçu d'un mot-clé ni sa boucle ne touchent plus un enfant seul. Le plan de l'issue est suivi point par point, D1 et D2 compris ; chaque critère d'acceptation a son test, les cinq mutations de l'issue rougissent, et le rejeu SQLite prouve les totaux par catégorie avec le SQL tel qu'il est écrit dans les sources.

Niveau (Step 0bis, REVIEW.md de main), fichier par fichier

  • src/services/transactionService.ts, categorizationService.ts, splitOffsetService.ts (nouveau), src/utils/splitOffset.ts (nouveau), src/components/transactions/SplitAdjustmentModal.tsx et leurs tests : normal. La ligne « code livré » (zone Vie privée) n'est pas remplie : aucun appel réseau, aucun champ envoyé, aucune URL ouverte, aucun consentement touché. Aucune autre ligne du tableau Haut ne les désigne.
  • docs/architecture.md, docs/adr/0022-canal-evenements-donnees.md, CLAUDE.md : normal (jamais bas). CHANGELOG.md, CHANGELOG.fr.md, STATE.md : bas.
  • Aucun fichier ajouté, renommé ou supprimé à la racine ni dans src-tauri/ ; aucun manifeste, lock, workflow, capability ni REVIEW.md.

Checklist

  • Security : toutes les requêtes ajoutées ou modifiées sont paramétrées ($1, $2), sans interpolation ; aucun secret, aucun .env ; aucune entrée nouvelle venue de l'extérieur (les identifiants viennent de la base ou de la liste cochée de l'aperçu).
  • Correctness :
    • src/services/transactionService.ts:309-344 : withTransaction puis BEGIN, l'UPDATE du parent inchangé (toSqlFlag(isManual)), propagateCategoryToOffsets sur le handle reçu, COMMIT ; ROLLBACK puis relance dans le catch ; notifyDataChanged() l. 319, après le retour de withTransaction seulement. Motif d'applyKeywordInTransaction, sans écart.
    • src/services/splitOffsetService.ts:47-80 : un identifiant inconnu, une transaction non répartie ou un enfant (l. 58, parent_transaction_id != null, puisque les enfants portent aussi is_split = 1) ne déclenchent aucune écriture ; la lecture des enfants n'a aucune condition de catégorie (D2) ; ni BEGIN, ni getDb(), ni notification ; aucun import de transactionService.ts ni de categorizationService.ts (grep dans le corps de la PR).
    • src/services/categorizationService.ts:178 : l'aperçu exclut les enfants ; l. 287-291 : l'UPDATE de la boucle ne touche qu'une ligne sans parent, updatedTransactions compte rowsAffected, la propagation tourne pour chaque identifiant avant le COMMIT.
    • src/components/transactions/SplitAdjustmentModal.tsx:52 : la règle n'a plus de condition de catégorie ; l'ancienne et la nouvelle ne diffèrent que pour une compensation dont la description diffère de celle du parent, cas qu'aucune requête ne produit (aucun UPDATE de transactions ne touche description, vérifié par grep).
    • Cas limites lus : parent à categoryId nul (la compensation passe à nul), revenu réparti (compensation négative), parent de montant nul (aucune compensation reconnue), même catégorie choisie de nouveau (un UPDATE sans effet visible), identifiant coché deux fois (impossible, checked est un Set).
  • Tests : test de régression rouge sur main (expected undefined to deeply equal [ 9, 7 ]) ; 29 tests de plus, aucun skip ni only ; tests existants de #390 et #396 réécrits pour viser l'UPDATE du parent par son SQL, avec les lectures de la propagation répondues par leur SQL (toute autre lecture fait échouer le test). Rejoué dans le worktree (npm ci) : sonde rc=1, npm run build vert, npm test 165/2776 sur main → 168/2805, tous verts. 18 mutations, une à la fois, arbre propre après chacune : toutes rouges, dont les cinq de l'issue (propagation retirée M1/M2, signe inversé M3, description retirée M4, filtre de l'aperçu retiré M5, ROLLBACK retiré M6). Une seule était restée verte au premier passage (M7, child.amount !== 0 retiré : seule une compensation nulle sous un parent nul passe le test de signe) ; tuée par e130c34.
  • Quality : pas de code mort ; propagateCategoryToOffsets rend un nombre que ses appelants n'utilisent pas, comme le plan le fixe, et que ses tests lisent ; conventions du dépôt (en-têtes de module, Number(result.rowsAffected ?? 0) de categoryMigrationService.ts) ; aucune chaîne visible ajoutée. Commits conventionnels, (#454) en fin de titre ; un seul mot-clé de fermeture, celui de la première ligne du corps, repris dans deux commits, et la timeline de l'issue porte exactement un pull_ref closes, celui de cette PR.
  • Data : aucune migration (v1→v17 intactes), consolidated_schema.sql intact ; aucun seed.

Zones de REVIEW.md touchées

  • Migrations, profils et données : verrou unique et withTransaction avec son handle (la propagation n'utilise que le handle reçu, mutations M14 et M15) ; booléen lié par toSqlFlag ; notifyDataChanged() après succès seulement, avec ses tests (#396, mutation M13), et le tableau de l'ADR 0022 mis à jour.
  • i18n et documentation : aucune chaîne ; architecture.md (service, utilitaire, comptes recalculés par ls … | grep -v '\.test\.ts$' | wc -l) et les deux CHANGELOG à jour ; guide inchangé, aucun changement d'usage.
  • Pièges : « Transaction hors verrou » évité ; « Booléen lié en texte » sans objet ; « Tests sans jsdom » : le test de la fenêtre passe par hookHarness, l'effet de chargement joué par commit() puis un second rendu, ce que le test exerce bien (M12 le prouve) ; « Faux t » : i18nMock.

À corriger dans cette PR

Rien.

Non retenu

  • Un test sur node:sqlite, comme categoryService.test.ts, garderait le SQL de la propagation exécuté par la CI ; le rejeu Python l'a exécuté une fois, sans rien commiter, comme le run le demandait.
  • propagateCategoryToOffsets lit chaque transaction cochée par le mot-clé, répartie ou non : une lecture par clé primaire de plus par identifiant, sans effet mesurable.
  • Le docstring de previewKeywordMatches parle encore de LIKE ?1 alors que la requête écrit $1 : antérieur à la PR.
  • La restauration d'une sauvegarde qui contient une répartition échoue sur sa clé étrangère (rejoué, section « Hors périmètre » du corps) : sans rapport avec ce diff, aucune issue ouverte.
Niveau : normal **Verdict : APPROVE** Auto-revue de l'auteur (worker `/autopilot`, maillon 1 sur 3), pas une revue indépendante : la checklist de `/pr-review` appliquée à la profondeur du niveau normal sur le diff complet de la PR contre sa base `main` (`eecbd2b`), tête `1fad948`. Elle ne remplace pas `/pr-review`. ## Résumé La ligne de compensation d'une répartition suit désormais son parent sur les deux chemins de reclassement (liste des transactions, mot-clé avec réaffectation), dans la même transaction que lui, et ni l'aperçu d'un mot-clé ni sa boucle ne touchent plus un enfant seul. Le plan de l'issue est suivi point par point, D1 et D2 compris ; chaque critère d'acceptation a son test, les cinq mutations de l'issue rougissent, et le rejeu SQLite prouve les totaux par catégorie avec le SQL tel qu'il est écrit dans les sources. ## Niveau (Step 0bis, `REVIEW.md` de `main`), fichier par fichier - `src/services/transactionService.ts`, `categorizationService.ts`, `splitOffsetService.ts` (nouveau), `src/utils/splitOffset.ts` (nouveau), `src/components/transactions/SplitAdjustmentModal.tsx` et leurs tests : **normal**. La ligne « code livré » (zone Vie privée) n'est pas remplie : aucun appel réseau, aucun champ envoyé, aucune URL ouverte, aucun consentement touché. Aucune autre ligne du tableau Haut ne les désigne. - `docs/architecture.md`, `docs/adr/0022-canal-evenements-donnees.md`, `CLAUDE.md` : normal (jamais bas). `CHANGELOG.md`, `CHANGELOG.fr.md`, `STATE.md` : bas. - Aucun fichier ajouté, renommé ou supprimé à la racine ni dans `src-tauri/` ; aucun manifeste, lock, workflow, capability ni `REVIEW.md`. ## Checklist - **Security** : toutes les requêtes ajoutées ou modifiées sont paramétrées (`$1`, `$2`), sans interpolation ; aucun secret, aucun `.env` ; aucune entrée nouvelle venue de l'extérieur (les identifiants viennent de la base ou de la liste cochée de l'aperçu). - **Correctness** : - `src/services/transactionService.ts:309-344` : `withTransaction` puis `BEGIN`, l'`UPDATE` du parent inchangé (`toSqlFlag(isManual)`), `propagateCategoryToOffsets` sur le handle reçu, `COMMIT` ; `ROLLBACK` puis relance dans le `catch` ; `notifyDataChanged()` l. 319, après le retour de `withTransaction` seulement. Motif d'`applyKeywordInTransaction`, sans écart. - `src/services/splitOffsetService.ts:47-80` : un identifiant inconnu, une transaction non répartie ou un enfant (l. 58, `parent_transaction_id != null`, puisque les enfants portent aussi `is_split = 1`) ne déclenchent aucune écriture ; la lecture des enfants n'a aucune condition de catégorie (D2) ; ni `BEGIN`, ni `getDb()`, ni notification ; aucun import de `transactionService.ts` ni de `categorizationService.ts` (grep dans le corps de la PR). - `src/services/categorizationService.ts:178` : l'aperçu exclut les enfants ; l. 287-291 : l'`UPDATE` de la boucle ne touche qu'une ligne sans parent, `updatedTransactions` compte `rowsAffected`, la propagation tourne pour chaque identifiant avant le `COMMIT`. - `src/components/transactions/SplitAdjustmentModal.tsx:52` : la règle n'a plus de condition de catégorie ; l'ancienne et la nouvelle ne diffèrent que pour une compensation dont la description diffère de celle du parent, cas qu'aucune requête ne produit (aucun `UPDATE` de `transactions` ne touche `description`, vérifié par grep). - Cas limites lus : parent à `categoryId` nul (la compensation passe à nul), revenu réparti (compensation négative), parent de montant nul (aucune compensation reconnue), même catégorie choisie de nouveau (un `UPDATE` sans effet visible), identifiant coché deux fois (impossible, `checked` est un `Set`). - **Tests** : test de régression rouge sur `main` (`expected undefined to deeply equal [ 9, 7 ]`) ; 29 tests de plus, aucun `skip` ni `only` ; tests existants de #390 et #396 réécrits pour viser l'`UPDATE` du parent par son SQL, avec les lectures de la propagation répondues par leur SQL (toute autre lecture fait échouer le test). Rejoué dans le worktree (`npm ci`) : sonde rc=1, `npm run build` vert, `npm test` 165/2776 sur `main` → 168/2805, tous verts. 18 mutations, une à la fois, arbre propre après chacune : toutes rouges, dont les cinq de l'issue (propagation retirée M1/M2, signe inversé M3, description retirée M4, filtre de l'aperçu retiré M5, `ROLLBACK` retiré M6). Une seule était restée verte au premier passage (M7, `child.amount !== 0` retiré : seule une compensation nulle sous un parent nul passe le test de signe) ; tuée par `e130c34`. - **Quality** : pas de code mort ; `propagateCategoryToOffsets` rend un nombre que ses appelants n'utilisent pas, comme le plan le fixe, et que ses tests lisent ; conventions du dépôt (en-têtes de module, `Number(result.rowsAffected ?? 0)` de `categoryMigrationService.ts`) ; aucune chaîne visible ajoutée. Commits conventionnels, `(#454)` en fin de titre ; un seul mot-clé de fermeture, celui de la première ligne du corps, repris dans deux commits, et la timeline de l'issue porte exactement un `pull_ref` `closes`, celui de cette PR. - **Data** : aucune migration (v1→v17 intactes), `consolidated_schema.sql` intact ; aucun seed. ## Zones de `REVIEW.md` touchées - **Migrations, profils et données** : verrou unique et `withTransaction` avec son handle (la propagation n'utilise que le handle reçu, mutations M14 et M15) ; booléen lié par `toSqlFlag` ; `notifyDataChanged()` après succès seulement, avec ses tests (#396, mutation M13), et le tableau de l'ADR 0022 mis à jour. - **i18n et documentation** : aucune chaîne ; `architecture.md` (service, utilitaire, comptes recalculés par `ls … | grep -v '\.test\.ts$' | wc -l`) et les deux CHANGELOG à jour ; guide inchangé, aucun changement d'usage. - **Pièges** : « Transaction hors verrou » évité ; « Booléen lié en texte » sans objet ; « Tests sans jsdom » : le test de la fenêtre passe par `hookHarness`, l'effet de chargement joué par `commit()` puis un second rendu, ce que le test exerce bien (M12 le prouve) ; « Faux `t` » : `i18nMock`. ## À corriger dans cette PR Rien. ## Non retenu - Un test sur `node:sqlite`, comme `categoryService.test.ts`, garderait le SQL de la propagation exécuté par la CI ; le rejeu Python l'a exécuté une fois, sans rien commiter, comme le run le demandait. - `propagateCategoryToOffsets` lit chaque transaction cochée par le mot-clé, répartie ou non : une lecture par clé primaire de plus par identifiant, sans effet mesurable. - Le docstring de `previewKeywordMatches` parle encore de `LIKE ?1` alors que la requête écrit `$1` : antérieur à la PR. - La restauration d'une sauvegarde qui contient une répartition échoue sur sa clé étrangère (rejoué, section « Hors périmètre » du corps) : sans rapport avec ce diff, aucune issue ouverte.
Author
Owner

Niveau : normal

Verdict : APPROVE

La compensation d'une répartition suit son parent sur les deux chemins de reclassement, dans la même transaction que lui, et le rejeu sur une vraie base le confirme. Un trou reste ouvert par « Catégoriser automatiquement » après un retrait de catégorie (item 1 ci-dessous, non bloquant : main est déjà faux dès le retrait).

Ce que la revue a exécuté

  • Copie hors dépôt de la tête (git archive 1fad948, npm ci) : sonde rc=1, npm run build vert, npm test à 168 fichiers et 2805 tests verts, comme le corps l'annonce. CI de la tête : check-frontend (run 670) vert ; check-rust non déclenché, aucun fichier sous src-tauri/.
  • Rejeu sur une vraie base : les services réels (saveSplitAdjustment, updateTransactionCategory, previewKeywordMatches, applyKeywordWithReassignment, autoCategorizeTransactions, importTransactionsOnly) branchés sur node:sqlite, schéma d'un profil neuf (consolidated_schema.sql, seed compris), clés étrangères actives comme sous sqlx :
    • R-S1, liste, A → C : B −50, C −70, A vide. Le même test sur une copie de main (eecbd2b) est rouge : le défaut est reproduit avec le code réel.
    • R-S2, mot-clé appliqué aux trois identifiants (parent, entrée, compensation) : l'aperçu ne propose que le parent ; B −50, D −70, updatedTransactions à 1.
    • R-S3 : item 1 ci-dessous.
    • R-S4 : section « Hors périmètre ».
  • Huit mutations du relecteur, une à la fois, chacune restaurée puis vérifiée par cmp, avec les cinq fichiers de tests de la PR après chacune : sept rouges, une survivante.
# Mutation Tests rouges
RM1 fenêtre de répartition : condition de catégorie remise (… || c.category_id !== transaction.category_id) 1
RM2 liste : compensation envoyée vers null au lieu de categoryId 1
RM3 mot-clé : propagation pour le seul premier identifiant coché 0
RM4 isOffsetChild : !== au lieu de === - entre les signes 1
RM5 liste : ROLLBACK sans relancer l'erreur 2
RM9 liste : notification avant withTransaction 3
RM12 propagation : garde !parent retirée 1
RM17 mot-clé : propagation après le COMMIT 2

À corriger dans cette PR

  1. src/services/splitOffsetService.ts:44-45 et :74 : la compensation garde is_manually_categorized = 0, parce que « nothing reads it on a child » (docstring, et décision par défaut de la planification de #454). C'est faux : autoCategorizeTransactions (src/services/transactionService.ts:387) choisit category_id IS NULL AND is_manually_categorized = 0 sur toutes les lignes, enfants compris.
    • Scénario R-S3, services réels, mot-clé METRO du seed vers 1111 (Épicerie régulière) : −120 « EPICERIE METRO » réparti avec −50 vers B, puis « Aucune catégorie » dans la liste (TransactionTable.tsx:241, updateTransactionCategory(id, null, true)). Le parent passe à NULL avec le drapeau 1, la compensation à NULL avec le drapeau 0 ; totaux NULL −70 et B −50, corrects. Puis « Catégoriser automatiquement » : une ligne catégorisée, la compensation seule, en 1111. Totaux : 1111 +50, B −50, NULL −120. La compensation ne suit plus son parent jusqu'à son prochain changement de catégorie (D2).
    • Ce n'est pas une régression : sur main, la même suite laisse +50 dans A dès le retrait de la catégorie. C'est un trou dans ce que la PR promet.
    • Remède validé sur la copie : lire is_manually_categorized dans le SELECT du parent (fait après son UPDATE, donc le drapeau neuf) et l'écrire sur la compensation (SET category_id = $1, is_manually_categorized = $2, …, par toSqlFlag). R-S3 reste alors à NULL −70 et B −50. Neuf tests qui épinglent le texte ou les paramètres de l'UPDATE de la compensation sont à mettre à jour, un test du scénario à ajouter, la docstring à corriger.

Décisions techniques prises par défaut (à contester)

  • Remède de l'item 1 : copier sur la compensation le drapeau is_manually_categorized de son parent. Écarté : exclure les enfants de répartition d'autoCategorizeTransactions et y propager la catégorie, parce que ce diff sort du plan de l'issue et change le sort des entrées qu'une réinitialisation des catégories laisse à NULL.

Non retenu

  • RM3 survit : aucun test n'applique un mot-clé à plusieurs identifiants dont un parent réparti qui n'est pas le premier. Le code, une propagation par identifiant dans la boucle, est correct : épingle seulement.
  • Dans updateTransactionCategoryInTransaction, un ROLLBACK qui échoue masque l'erreur d'origine, que runRestore garde ; même motif qu'applyKeywordInTransaction.
  • saveSplitAdjustment crée la compensation avec le drapeau 0, même sous un parent catégorisé à la main : après « Réinitialiser les catégories » (reinitializeCategories met tout à NULL et remet les mots-clés du seed), « Catégoriser automatiquement » la sépare de son parent de la même façon. Antérieur à ce diff ; #513 réécrit cette fonction.

Hors périmètre (observation de l'auteur, confirmée)

La restauration d'une sauvegarde qui contient une répartition échoue. importTransactionsOnly, réel, sur les lignes de getExportTransactions : FOREIGN KEY constraint failed. attachTransactions réinsère les enfants avec l'ancien parent_transaction_id, qu'AUTOINCREMENT ne redonne jamais après le DELETE. Le ROLLBACK de runRestore laisse le profil intact. importTransactionsWithCategories passe par la même fonction. Cette revue n'ouvre pas d'issue.

Décision autopilot

  • Commentaire de décisions (29625) et auto-revue (29629) présents.
  • MEDIUM, vérification manuelle à la prochaine release : présente dans le corps et en sous-puce de STATE.md. Elle ne change aucun comportement et ne s'écarte pas de l'issue : rien à confirmer.

Vérifié sans constat

  • Niveau : les fichiers sous src/ sont du code applicatif, sans appel réseau, URL ni consentement ; aucun manifeste, lock, workflow, migration ni fichier ajouté à la racine ou dans src-tauri/. CLAUDE.md, docs/architecture.md et l'ADR 0022 restent normaux ; les CHANGELOG et STATE.md sont bas.
  • Zone « Migrations, profils et données » : dans le rappel, tout passe par le handle de withTransaction, aucun getDb() ; is_split lu par toSqlFlag, drapeau du parent lié par toSqlFlag ; notification après le COMMIT seulement ; aucune migration, consolidated_schema.sql intact.
  • Comptes de docs/architecture.md et de CLAUDE.md recomptés : 29 services, 23 décrits, 21 utilitaires. CHANGELOG FR et EN sous Corrigé et Fixed ; aucune chaîne visible ajoutée.
  • Aucun cycle d'import, requêtes toutes paramétrées, aucun only ni skip, commits conventionnels.
  • Fermeture : Resolves #454 ; la timeline de #454 porte un seul closes, celui de cette PR ; #513 est cité sans mot-clé.

Actions faites

  • Copies de la tête et de la base sous /tmp/pr515-*, scripts de mutation et journaux supprimés en fin de revue ; dépôt local non modifié (git status vide).

Reviewed-SHA: 1fad948f92

Niveau : normal **Verdict : APPROVE** La compensation d'une répartition suit son parent sur les deux chemins de reclassement, dans la même transaction que lui, et le rejeu sur une vraie base le confirme. Un trou reste ouvert par « Catégoriser automatiquement » après un retrait de catégorie (item 1 ci-dessous, non bloquant : `main` est déjà faux dès le retrait). ## Ce que la revue a exécuté - Copie hors dépôt de la tête (`git archive 1fad948`, `npm ci`) : sonde rc=1, `npm run build` vert, `npm test` à 168 fichiers et 2805 tests verts, comme le corps l'annonce. CI de la tête : `check-frontend` (run 670) vert ; `check-rust` non déclenché, aucun fichier sous `src-tauri/`. - Rejeu sur une vraie base : les services réels (`saveSplitAdjustment`, `updateTransactionCategory`, `previewKeywordMatches`, `applyKeywordWithReassignment`, `autoCategorizeTransactions`, `importTransactionsOnly`) branchés sur `node:sqlite`, schéma d'un profil neuf (`consolidated_schema.sql`, seed compris), clés étrangères actives comme sous sqlx : - R-S1, liste, A → C : B −50, C −70, A vide. Le même test sur une copie de `main` (`eecbd2b`) est rouge : le défaut est reproduit avec le code réel. - R-S2, mot-clé appliqué aux trois identifiants (parent, entrée, compensation) : l'aperçu ne propose que le parent ; B −50, D −70, `updatedTransactions` à 1. - R-S3 : item 1 ci-dessous. - R-S4 : section « Hors périmètre ». - Huit mutations du relecteur, une à la fois, chacune restaurée puis vérifiée par `cmp`, avec les cinq fichiers de tests de la PR après chacune : sept rouges, une survivante. | # | Mutation | Tests rouges | |---|---|---| | RM1 | fenêtre de répartition : condition de catégorie remise (`… \|\| c.category_id !== transaction.category_id`) | 1 | | RM2 | liste : compensation envoyée vers `null` au lieu de `categoryId` | 1 | | RM3 | mot-clé : propagation pour le seul premier identifiant coché | **0** | | RM4 | `isOffsetChild` : `!==` au lieu de `=== -` entre les signes | 1 | | RM5 | liste : `ROLLBACK` sans relancer l'erreur | 2 | | RM9 | liste : notification avant `withTransaction` | 3 | | RM12 | propagation : garde `!parent` retirée | 1 | | RM17 | mot-clé : propagation après le `COMMIT` | 2 | ## À corriger dans cette PR 1. `src/services/splitOffsetService.ts:44-45` et `:74` : la compensation garde `is_manually_categorized = 0`, parce que « nothing reads it on a child » (docstring, et décision par défaut de la planification de #454). C'est faux : `autoCategorizeTransactions` (`src/services/transactionService.ts:387`) choisit `category_id IS NULL AND is_manually_categorized = 0` sur toutes les lignes, enfants compris. - Scénario R-S3, services réels, mot-clé `METRO` du seed vers 1111 (Épicerie régulière) : −120 « EPICERIE METRO » réparti avec −50 vers B, puis « Aucune catégorie » dans la liste (`TransactionTable.tsx:241`, `updateTransactionCategory(id, null, true)`). Le parent passe à NULL avec le drapeau 1, la compensation à NULL avec le drapeau 0 ; totaux NULL −70 et B −50, corrects. Puis « Catégoriser automatiquement » : une ligne catégorisée, la compensation seule, en 1111. Totaux : 1111 +50, B −50, NULL −120. La compensation ne suit plus son parent jusqu'à son prochain changement de catégorie (D2). - Ce n'est pas une régression : sur `main`, la même suite laisse +50 dans A dès le retrait de la catégorie. C'est un trou dans ce que la PR promet. - Remède validé sur la copie : lire `is_manually_categorized` dans le SELECT du parent (fait après son UPDATE, donc le drapeau neuf) et l'écrire sur la compensation (`SET category_id = $1, is_manually_categorized = $2, …`, par `toSqlFlag`). R-S3 reste alors à NULL −70 et B −50. Neuf tests qui épinglent le texte ou les paramètres de l'UPDATE de la compensation sont à mettre à jour, un test du scénario à ajouter, la docstring à corriger. ## Décisions techniques prises par défaut (à contester) - Remède de l'item 1 : copier sur la compensation le drapeau `is_manually_categorized` de son parent. Écarté : exclure les enfants de répartition d'`autoCategorizeTransactions` et y propager la catégorie, parce que ce diff sort du plan de l'issue et change le sort des entrées qu'une réinitialisation des catégories laisse à NULL. ## Non retenu - RM3 survit : aucun test n'applique un mot-clé à plusieurs identifiants dont un parent réparti qui n'est pas le premier. Le code, une propagation par identifiant dans la boucle, est correct : épingle seulement. - Dans `updateTransactionCategoryInTransaction`, un `ROLLBACK` qui échoue masque l'erreur d'origine, que `runRestore` garde ; même motif qu'`applyKeywordInTransaction`. - `saveSplitAdjustment` crée la compensation avec le drapeau 0, même sous un parent catégorisé à la main : après « Réinitialiser les catégories » (`reinitializeCategories` met tout à NULL et remet les mots-clés du seed), « Catégoriser automatiquement » la sépare de son parent de la même façon. Antérieur à ce diff ; #513 réécrit cette fonction. ## Hors périmètre (observation de l'auteur, confirmée) La restauration d'une sauvegarde qui contient une répartition échoue. `importTransactionsOnly`, réel, sur les lignes de `getExportTransactions` : `FOREIGN KEY constraint failed`. `attachTransactions` réinsère les enfants avec l'ancien `parent_transaction_id`, qu'`AUTOINCREMENT` ne redonne jamais après le `DELETE`. Le `ROLLBACK` de `runRestore` laisse le profil intact. `importTransactionsWithCategories` passe par la même fonction. Cette revue n'ouvre pas d'issue. ## Décision autopilot - Commentaire de décisions (29625) et auto-revue (29629) présents. - MEDIUM, vérification manuelle à la prochaine release : présente dans le corps et en sous-puce de `STATE.md`. Elle ne change aucun comportement et ne s'écarte pas de l'issue : rien à confirmer. ## Vérifié sans constat - Niveau : les fichiers sous `src/` sont du code applicatif, sans appel réseau, URL ni consentement ; aucun manifeste, lock, workflow, migration ni fichier ajouté à la racine ou dans `src-tauri/`. `CLAUDE.md`, `docs/architecture.md` et l'ADR 0022 restent normaux ; les CHANGELOG et `STATE.md` sont bas. - Zone « Migrations, profils et données » : dans le rappel, tout passe par le handle de `withTransaction`, aucun `getDb()` ; `is_split` lu par `toSqlFlag`, drapeau du parent lié par `toSqlFlag` ; notification après le `COMMIT` seulement ; aucune migration, `consolidated_schema.sql` intact. - Comptes de `docs/architecture.md` et de `CLAUDE.md` recomptés : 29 services, 23 décrits, 21 utilitaires. CHANGELOG FR et EN sous Corrigé et Fixed ; aucune chaîne visible ajoutée. - Aucun cycle d'import, requêtes toutes paramétrées, aucun `only` ni `skip`, commits conventionnels. - Fermeture : `Resolves #454` ; la timeline de #454 porte un seul `closes`, celui de cette PR ; #513 est cité sans mot-clé. ## Actions faites - Copies de la tête et de la base sous `/tmp/pr515-*`, scripts de mutation et journaux supprimés en fin de revue ; dépôt local non modifié (`git status` vide). Reviewed-SHA: 1fad948f9225f26bdcd5e8d2b5b6958e32691bee
Author
Owner

Décisions de Max (2026-10-28, réponses à /pr-review sur la pile)

  • Point 1 « À corriger » de la revue 29728 (drapeau manuel de la compensation) : corrigé dans la pile, avant le merge. Le correctif est le maillon de suites PR #519, posé en tête de pile sur #517 : la compensation prend le drapeau is_manually_categorized de son parent quand celui-ci change de catégorie (remède de la revue), et aussi à la création d'une répartition (même trou, point « Non retenu » de la revue : reinitializeCategories puis la catégorisation automatique la séparaient de son parent). La PR #519 passe par /pr-review avant /merge-stack.
  • Restauration d'une sauvegarde qui contient une répartition (section « Hors périmètre ») : issue #518 ouverte (type:bug, status:triage), seule issue source:revue de la pile.
## Décisions de Max (2026-10-28, réponses à `/pr-review` sur la pile) - **Point 1 « À corriger » de la revue 29728 (drapeau manuel de la compensation) : corrigé dans la pile, avant le merge.** Le correctif est le maillon de suites PR #519, posé en tête de pile sur #517 : la compensation prend le drapeau `is_manually_categorized` de son parent quand celui-ci change de catégorie (remède de la revue), et aussi à la création d'une répartition (même trou, point « Non retenu » de la revue : `reinitializeCategories` puis la catégorisation automatique la séparaient de son parent). La PR #519 passe par `/pr-review` avant `/merge-stack`. - **Restauration d'une sauvegarde qui contient une répartition (section « Hors périmètre ») : issue #518 ouverte** (`type:bug`, `status:triage`), seule issue `source:revue` de la pile.
maximus deleted branch issue-454-split-offset-follows-parent 2026-10-30 00:38:49 +00:00
Author
Owner

Mergée en avance rapide par l'API, épinglée sur la tête relue 1fad948f9225f26bdcd5e8d2b5b6958e32691bee (revue 29728). Tip cumulé de la pile #515 → #516 → #517 → #519 éprouvé dans un worktree jetable (npm ci propre) : sonde rc=1, build vert, 172 fichiers / 2853 tests ; la pile ne touche ni src-tauri/, ni .cargo/, ni les workflows, ni les manifestes et locks npm. Point 1 « À corriger » (drapeau manuel de la compensation) corrigé dans la pile par #519, sur décision de Max (29888) ; restauration d'une sauvegarde qui contient une répartition suivie en #518. Non retenu (revue 29728) : mot-clé appliqué à plusieurs identifiants dont un parent réparti qui n'est pas le premier, sans test (RM3) ; ROLLBACK en échec qui masque l'erreur d'origine ; drapeau 0 de la compensation à sa création, traité depuis par #519.

Mergée en avance rapide par l'API, épinglée sur la tête relue `1fad948f9225f26bdcd5e8d2b5b6958e32691bee` (revue 29728). Tip cumulé de la pile #515 → #516 → #517 → #519 éprouvé dans un worktree jetable (`npm ci` propre) : sonde rc=1, build vert, 172 fichiers / 2853 tests ; la pile ne touche ni `src-tauri/`, ni `.cargo/`, ni les workflows, ni les manifestes et locks npm. Point 1 « À corriger » (drapeau manuel de la compensation) corrigé dans la pile par #519, sur décision de Max (29888) ; restauration d'une sauvegarde qui contient une répartition suivie en #518. Non retenu (revue 29728) : mot-clé appliqué à plusieurs identifiants dont un parent réparti qui n'est pas le premier, sans test (RM3) ; `ROLLBACK` en échec qui masque l'erreur d'origine ; drapeau 0 de la compensation à sa création, traité depuis par #519.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
maximus/Simpl-Resultat!515
No description provided.