fix: a split's offset line takes its parent's manual flag (#454) #519

Merged
maximus merged 2 commits from issue-454-offset-manual-flag into main 2026-10-30 00:39:19 +00:00
Owner

Refs #454

Follow-up link at the head of the stack #515 → #516 → #517, decided by Max on 2026-10-28 in answer to /pr-review: item 1 « À corriger » of review 29728 of PR #515, plus the same hole at the creation of a split (« Non retenu » of the same review). Base: issue-479-reports-period-filters (PR #517, head 4d1ac59).

Level: normal (REVIEW.md of main), set by src/services/splitOffsetService.ts and src/services/transactionService.ts. No file of the Haut table: both are shipped code (src/**) that adds no network call, changes nothing a call sends, opens no URL and touches no consent; the new test file sits under src/__integration__/, neither at the root nor directly in src-tauri/; docs/architecture.md and REVIEW.md (outside « Niveaux ») stay normal; the CHANGELOGs are low.

Summary

autoCategorizeTransactions picks every row WHERE category_id IS NULL AND is_manually_categorized = 0, the children of a split included. The offset line of a split kept the flag 0 whatever its parent's, so « Auto-catégoriser » could send it alone, away from its parent, to the category of the keyword of its description:

  • R-S3 (review 29728): −120 « EPICERIE METRO » split with −50 to B, then « Sans catégorie » in the Transactions list (updateTransactionCategory(id, null, true)): totals NULL −70 and B −50, correct; then « Auto-catégoriser »: the seed's METRO keyword sends the offset line alone to 1111 (« Épicerie régulière »): 1111 +50, B −50, NULL −120.
  • Same hole at creation (« Non retenu » of the same review): a split made under a parent already set to « Sans catégorie » by hand wrote its offset line at NULL with the flag 0, with the same result; under a parent categorized by hand, « Réinitialiser » on the Categories page (reinitializeCategories sets every category_id to NULL and keeps the flags) exposed it the same way.

The change:

  • propagateCategoryToOffsets reads is_manually_categorized with the parent, after the caller's UPDATE of the parent (so the flag the caller has just written), and its UPDATE of the offset line writes category_id, is_manually_categorized (through toSqlFlag) and updated_at. In the app, both callers (the list, the keyword path) write the flag 1 on the parent, so the offset line gets 1.
  • saveSplitAdjustmentInTransaction writes the offset line with is_manually_categorized = toSqlFlag(parent.is_manually_categorized). The entries keep the column's default, 0 (out of scope).
  • The docstring of propagateCategoryToOffsets, which said that nothing reads the flag on a child, now says who reads it and why the offset line takes it (in the code commit, with the code it documents).

Effects outside « Auto-catégoriser », rechecked: none visible.

  • onboardingService.ts:82 counts the rows at 1, children included, but the getting-started checklist only tests >= 1 (onboardingChecklist.ts:73), and an offset line only gets 1 from a parent at 1, which already counts.
  • The Transactions list (getTransactionPage, t.parent_transaction_id IS NULL) and getSplitParentTransactions read the flag on parents only. The Dashboard drill-down (getTransactionsByCategory, dashboardService.ts:142) does return children with their flag, but no component reads is_manually_categorized (only the optimistic update of the list row, useTransactions.ts:188).
  • A backup exports each row's flag and restores it through toSqlFlag (dataExportService.ts): an offset line under a parent at 1 now goes out and back with 1. importCategoriesOnly still resets every flag to 0. On the Rust side, profile_db.rs only converts the TEXT 'true' (#390).

Files

File Change
src/services/splitOffsetService.ts ParentRow.is_manually_categorized; the parent's SELECT reads the flag; the offset line's UPDATE is SET category_id = $1, is_manually_categorized = $2, updated_at = CURRENT_TIMESTAMP WHERE id = $3, flag by toSqlFlag; docstring corrected
src/services/transactionService.ts the offset line's INSERT in saveSplitAdjustmentInTransaction adds is_manually_categorized ($9, toSqlFlag(parent.is_manually_categorized)); the entries' INSERT is unchanged; docstring of saveSplitAdjustment
src/__integration__/split-offset-manual-flag.test.ts new: 4 tests on a real SQLite database (below)
src/services/splitOffsetService.test.ts parent fixture with the flag 1; 5 pins updated; 4 tests of the copy (flag 1, flag 0, TEXT 'true'; flag read on the parent, never on the offset line)
src/services/transactionService.test.ts split parent fixture with the flag 1; 2 pins of #454 and the #513 pins of the offset line's INSERT updated (INSERT_OFFSET); 1 test of the read order, 3 tests of the copy at creation
src/services/categorizationService.test.ts parent fixture with the flag 1; 2 pins updated
docs/architecture.md line of splitOffsetService.ts: the flag follows the parent, when and why; « SQL réel — node:sqlite »: the new test
CHANGELOG.md, CHANGELOG.fr.md one more sentence in the #454 entry, under Fixed / Corrigé
REVIEW.md pitfall « Tests vitest qui lisent src-tauri/ »: the new test reads consolidated_schema.sql

The integration test runs node:sqlite (DatabaseSync, in memory) on the whole of consolidated_schema.sql, seed included, foreign keys on as under sqlx, with the real saveSplitAdjustment, updateTransactionCategory and autoCategorizeTransactions. ../services/db is mocked by an adapter local to the file: select and execute with $N bound by name, rowsAffected and lastInsertId, withTransaction passing the same handle, getDb() refused during a transaction. No shared harness (#392 plans one). Its tests:

  1. the seed sends « EPICERIE METRO » to 1111 by its METRO keyword, as the brief expected (no substitute needed);
  2. R-S3: totals NULL −70 and B (1112) −50 before and after « Auto-catégoriser », no row categorized, parent and offset line NULL at 1, entry in B at 0;
  3. a split made under a parent set to « Sans catégorie » by hand: same totals before and after, offset line NULL at 1;
  4. witness: a parent imported without a category (flag 0) and its offset line both go to 1111 (2 rows categorized), 1111 −70 and B −50, as before (green on the base too).

Decisions

Decided before this link:

  • Remedy of item 1 (technical decision of review 29728, kept): the offset line takes its parent's flag in propagateCategoryToOffsets, read on the parent after the caller's UPDATE and written with its category through toSqlFlag. Rejected: excluding the children of a split from autoCategorizeTransactions and propagating the category there, because that diff leaves the plan of the issue and changes the fate of the entries that a reset of the categories leaves at NULL.
  • Decision of the main session: the offset line also takes its parent's flag at its creation, in the INSERT of saveSplitAdjustmentInTransaction, by toSqlFlag(parent.is_manually_categorized). Rejected: fixing the propagation only, because a split created under a parent categorized by hand (or set by hand to no category) otherwise keeps the flag 0, and « Catégoriser automatiquement » separates it from its parent, after « Réinitialiser les catégories » as under a parent without a category. The entries keep 0: out of scope.

Taken by default in this link (to contest):

  • The offset line has its own INSERT (… is_split, is_manually_categorized) VALUES (…, 1, $9)). Rejected: one INSERT with an explicit flag for the entries and the offset line alike, because the entries are out of scope and their statement stays the one of before #513.
  • No repair of the offset lines already written at 0 under a parent at 1: they get the flag at their parent's next change of category or at the next save of their split, as D2 of #454 repairs an offset line left in a former category. Rejected: a data migration, because no column marks the offset line (D1 of #454: only isOffsetChild, in TypeScript, recognizes it) and the exposure needs a parent without a category plus « Auto-catégoriser ».
  • The test adapter refuses getDb() during a transaction, as categoryService.test.ts does. Rejected: a getDb() that always answers, because a getDb() call inside the callback, which deadlocks under the real lock, would pass unseen.
  • The unit fixtures of the parent's read carry is_manually_categorized: 1, as both callers write it before that read. Rejected: leaving them without the flag, because the updated pins would then not tell a copy of the flag from a constant 0.
  • The CHANGELOGs name the labels of the UI: « Auto-catégoriser » / “Auto-categorize” (transactions.autoCategorize) and « Sans catégorie » / “No category” (transactions.table.noCategory). Rejected: « Catégoriser automatiquement » and « Aucune catégorie » of the brief and the review, because the user reads the button and the option of the list.
  • REVIEW.md: the new test joins the pitfall « Tests vitest qui lisent src-tauri/ ». Rejected: leaving the list as it was, because the test executes the whole schema with its seed (METRO → 1111, categories 1111 and 1112), and a PR that touches only src-tauri/** skips check-frontend without its review knowing to run it.
  • docs/architecture.md, « SQL réel — node:sqlite »: one paragraph on the new test. Rejected: updating only the line of splitOffsetService.ts, because the section said « Les autres tests de services gardent leurs faux », which this test makes false.

Proof

Red on the base 4d1ac59, with the tests of this link and the code of the base: 23 failed of 72 in the four files (npx vitest run of the four files, exit 1). Both integration scenarios reproduce R-S3 with the real code; the witness stays green:

FAIL  src/__integration__/split-offset-manual-flag.test.ts > … > a split parent set to no category by hand keeps its offset line through « Catégoriser automatiquement »
AssertionError: expected { '1111': 50, '1112': -50, none: -120 } to deeply equal { '1112': -50, none: -70 }
FAIL  src/__integration__/split-offset-manual-flag.test.ts > … > a split made under a parent set to no category by hand keeps its offset line through « Catégoriser automatiquement »
AssertionError: expected { '1111': 50, '1112': -50, none: -120 } to deeply equal { '1112': -50, none: -70 }

The other 21 red tests on the base are the unit tests of the copy and the pins that this link changes on purpose.

From the worktree (npm ci done):

  • probe: src/zz_probe.test.ts, deliberately red, npx vitest run src/zz_probe.test.ts exit 1, file deleted;
  • npm run build (tsc + vite): green;
  • npm test: 171 files / 2841 tests on 4d1ac59, 172 files / 2853 tests on the head (+1 file, +12 tests), all green;
  • CI: check-frontend run 676 green on 4526637 (Node v24.22.2): npm run build, then 172 test files / 2853 tests, the 4 tests of split-offset-manual-flag.test.ts included. check-rust not triggered: no file under src-tauri/, .cargo/ or src/__fixtures__/samples/ (the new test only reads consolidated_schema.sql).

Mutations, one at a time on 36c04ad, each restored by git checkout -- <file> with git status --short empty, the four test files run after each (72 tests): 9 mutations, 9 red.

# Mutation Red Among them
M1 propagation: flag copy removed (offset line's UPDATE as on the base) 13 R-S3 scenario, the three copies, the pins
M2 creation: flag copy removed (offset line's INSERT as on the base) 9 creation scenario, the three copies at creation, the #513 pins
M3 propagation: flag read on the offset line instead of the parent 11 R-S3 scenario, « reads the flag on the parent, never on the offset line »
M4a propagation: toSqlFlag removed, raw value bound 1 copy of the TEXT 'true'
M4b creation: toSqlFlag removed, raw value bound 1 copy of the TEXT 'true' at creation
M5 propagation: the parent's SELECT no longer reads the flag 3 R-S3 scenario, SELECT pin, read-order test
M6 list path: propagation before the parent's UPDATE (stale flag) 2 R-S3 scenario, read-order test
M7 creation: constant 1 instead of the parent's flag 2 witness scenario, copy of the flag 0 at creation
M8 propagation: constant 1 instead of the parent's flag 2 copy of the flag 0, flag read on the parent

M4a and M4b are caught by the unit tests only: on a real base the flag reads back as an integer, and only a base written before #390 may hold the TEXT 'true'.

REVIEW.md

Zone « Migrations, profils et données »:

  • « Un booléen se lie en 1/0 (toSqlFlag) »: both new bindings go through toSqlFlag (M4a, M4b) and are bound as numbers (asserted by typeof).
  • « une transaction par withTransaction et son handle »: the new read and the two writes run on the handle of the caller's transaction (db), between its BEGIN and its COMMIT, never through getDb(); the handle-only tests of #454 and #513 stay green, and the integration adapter refuses getDb() during a transaction.
  • notifyDataChanged(): no new write site. The flag written on the offset line (which manual_categorized of COUNTERS_SQL counts) is written by saveSplitAdjustment, updateTransactionCategory and applyKeywordWithReassignment, which already notify after their COMMIT.
  • No migration, no schema change, consolidated_schema.sql untouched.

Zone « i18n et documentation »: no visible string added; the #454 entry of both CHANGELOGs has one more sentence; docs/architecture.md follows; no change of usage for the user guide.

For the reviewer

  • The #513 tests change on purpose. The tests of saveSplitAdjustment that pinned the offset line's INSERT « as before #513 » now pin it with the flag: new constant INSERT_OFFSET, SAVED_PARENT with is_manually_categorized: 1, SAVED_WRITES with the offset line's $9. « writes the same statements, with the same values, as before #513 » is renamed « …, but the offset line's manual flag (#454) »; « writes the fallbacks … » reads both INSERTs and expects 1 at the end of the offset line; the case « the INSERT of the offset line » of the rollback table matches INSERT_OFFSET. « reads the parent first … » and « sends every statement through the transaction's handle … » follow through SAVED_WRITES. The values of the entries do not change.
  • The nine pins of the offset line's UPDATE (count of review 29728): 5 in splitOffsetService.test.ts (« moves the offset line of a split parent, and only it », « reads the row by its id, with its manual flag, … » for the SELECT, « … of a split income … », « … to no category … », « lets a failed move reach the caller … »), 2 in transactionService.test.ts (« moves the offset to the new category … », « rolls back, rethrows … when the offset cannot be moved »), 2 in categorizationService.test.ts (« moves the offset line of a checked split parent … », « rolls the keyword and the transactions back … »).
  • The offset line's UPDATE now has the same SQL as the parent's own UPDATE in updateTransactionCategoryInTransaction: the tests tell them apart by their target (targetOf, last parameter), and the comment of ownUpdates() says so.
  • Offset lines already written at 0 under a parent at 1 stay so until their parent's next change of category or the next save of their split (decision above).
  • Suggested manual check at the release, in the Base edition, on a new profile: split « EPICERIE METRO » (or any transaction whose description matches a keyword) with part of it to another category, set it to « Sans catégorie » in the Transactions list, click « Auto-catégoriser »: no transaction categorized, and « Épicerie régulière » gets nothing in the Reports (before this link: +50). Same after setting a transaction to « Sans catégorie » first and splitting it afterwards.

🤖 Generated with Claude Code

Refs #454 Follow-up link at the head of the stack #515 → #516 → #517, decided by Max on 2026-10-28 in answer to `/pr-review`: item 1 « À corriger » of review 29728 of PR #515, plus the same hole at the creation of a split (« Non retenu » of the same review). Base: `issue-479-reports-period-filters` (PR #517, head `4d1ac59`). **Level: normal** (`REVIEW.md` of `main`), set by `src/services/splitOffsetService.ts` and `src/services/transactionService.ts`. No file of the Haut table: both are shipped code (`src/**`) that adds no network call, changes nothing a call sends, opens no URL and touches no consent; the new test file sits under `src/__integration__/`, neither at the root nor directly in `src-tauri/`; `docs/architecture.md` and `REVIEW.md` (outside « Niveaux ») stay normal; the CHANGELOGs are low. ## Summary `autoCategorizeTransactions` picks every row `WHERE category_id IS NULL AND is_manually_categorized = 0`, the children of a split included. The offset line of a split kept the flag 0 whatever its parent's, so « Auto-catégoriser » could send it alone, away from its parent, to the category of the keyword of its description: - **R-S3** (review 29728): −120 « EPICERIE METRO » split with −50 to B, then « Sans catégorie » in the Transactions list (`updateTransactionCategory(id, null, true)`): totals NULL −70 and B −50, correct; then « Auto-catégoriser »: the seed's `METRO` keyword sends the offset line alone to 1111 (« Épicerie régulière »): 1111 +50, B −50, NULL −120. - **Same hole at creation** (« Non retenu » of the same review): a split made under a parent already set to « Sans catégorie » by hand wrote its offset line at NULL with the flag 0, with the same result; under a parent categorized by hand, « Réinitialiser » on the Categories page (`reinitializeCategories` sets every `category_id` to NULL and keeps the flags) exposed it the same way. The change: - `propagateCategoryToOffsets` reads `is_manually_categorized` with the parent, after the caller's UPDATE of the parent (so the flag the caller has just written), and its UPDATE of the offset line writes `category_id`, `is_manually_categorized` (through `toSqlFlag`) and `updated_at`. In the app, both callers (the list, the keyword path) write the flag 1 on the parent, so the offset line gets 1. - `saveSplitAdjustmentInTransaction` writes the offset line with `is_manually_categorized = toSqlFlag(parent.is_manually_categorized)`. The entries keep the column's default, 0 (out of scope). - The docstring of `propagateCategoryToOffsets`, which said that nothing reads the flag on a child, now says who reads it and why the offset line takes it (in the code commit, with the code it documents). Effects outside « Auto-catégoriser », rechecked: none visible. - `onboardingService.ts:82` counts the rows at 1, children included, but the getting-started checklist only tests `>= 1` (`onboardingChecklist.ts:73`), and an offset line only gets 1 from a parent at 1, which already counts. - The Transactions list (`getTransactionPage`, `t.parent_transaction_id IS NULL`) and `getSplitParentTransactions` read the flag on parents only. The Dashboard drill-down (`getTransactionsByCategory`, `dashboardService.ts:142`) does return children with their flag, but no component reads `is_manually_categorized` (only the optimistic update of the list row, `useTransactions.ts:188`). - A backup exports each row's flag and restores it through `toSqlFlag` (`dataExportService.ts`): an offset line under a parent at 1 now goes out and back with 1. `importCategoriesOnly` still resets every flag to 0. On the Rust side, `profile_db.rs` only converts the TEXT `'true'` (#390). ## Files | File | Change | |---|---| | `src/services/splitOffsetService.ts` | `ParentRow.is_manually_categorized`; the parent's SELECT reads the flag; the offset line's UPDATE is `SET category_id = $1, is_manually_categorized = $2, updated_at = CURRENT_TIMESTAMP WHERE id = $3`, flag by `toSqlFlag`; docstring corrected | | `src/services/transactionService.ts` | the offset line's INSERT in `saveSplitAdjustmentInTransaction` adds `is_manually_categorized` (`$9`, `toSqlFlag(parent.is_manually_categorized)`); the entries' INSERT is unchanged; docstring of `saveSplitAdjustment` | | `src/__integration__/split-offset-manual-flag.test.ts` | new: 4 tests on a real SQLite database (below) | | `src/services/splitOffsetService.test.ts` | parent fixture with the flag 1; 5 pins updated; 4 tests of the copy (flag 1, flag 0, TEXT `'true'`; flag read on the parent, never on the offset line) | | `src/services/transactionService.test.ts` | split parent fixture with the flag 1; 2 pins of #454 and the #513 pins of the offset line's INSERT updated (`INSERT_OFFSET`); 1 test of the read order, 3 tests of the copy at creation | | `src/services/categorizationService.test.ts` | parent fixture with the flag 1; 2 pins updated | | `docs/architecture.md` | line of `splitOffsetService.ts`: the flag follows the parent, when and why; « SQL réel — `node:sqlite` »: the new test | | `CHANGELOG.md`, `CHANGELOG.fr.md` | one more sentence in the #454 entry, under Fixed / Corrigé | | `REVIEW.md` | pitfall « Tests vitest qui lisent `src-tauri/` »: the new test reads `consolidated_schema.sql` | The integration test runs `node:sqlite` (`DatabaseSync`, in memory) on the whole of `consolidated_schema.sql`, seed included, foreign keys on as under sqlx, with the real `saveSplitAdjustment`, `updateTransactionCategory` and `autoCategorizeTransactions`. `../services/db` is mocked by an adapter local to the file: `select` and `execute` with `$N` bound by name, `rowsAffected` and `lastInsertId`, `withTransaction` passing the same handle, `getDb()` refused during a transaction. No shared harness (#392 plans one). Its tests: 1. the seed sends « EPICERIE METRO » to 1111 by its `METRO` keyword, as the brief expected (no substitute needed); 2. R-S3: totals NULL −70 and B (1112) −50 before and after « Auto-catégoriser », no row categorized, parent and offset line NULL at 1, entry in B at 0; 3. a split made under a parent set to « Sans catégorie » by hand: same totals before and after, offset line NULL at 1; 4. witness: a parent imported without a category (flag 0) and its offset line both go to 1111 (2 rows categorized), 1111 −70 and B −50, as before (green on the base too). ## Decisions Decided before this link: - Remedy of item 1 (technical decision of review 29728, kept): the offset line takes its parent's flag in `propagateCategoryToOffsets`, read on the parent after the caller's UPDATE and written with its category through `toSqlFlag`. Rejected: excluding the children of a split from `autoCategorizeTransactions` and propagating the category there, because that diff leaves the plan of the issue and changes the fate of the entries that a reset of the categories leaves at NULL. - Decision of the main session: the offset line also takes its parent's flag at its creation, in the INSERT of `saveSplitAdjustmentInTransaction`, by `toSqlFlag(parent.is_manually_categorized)`. Rejected: fixing the propagation only, because a split created under a parent categorized by hand (or set by hand to no category) otherwise keeps the flag 0, and « Catégoriser automatiquement » separates it from its parent, after « Réinitialiser les catégories » as under a parent without a category. The entries keep 0: out of scope. Taken by default in this link (to contest): - The offset line has its own INSERT (`… is_split, is_manually_categorized) VALUES (…, 1, $9)`). Rejected: one INSERT with an explicit flag for the entries and the offset line alike, because the entries are out of scope and their statement stays the one of before #513. - No repair of the offset lines already written at 0 under a parent at 1: they get the flag at their parent's next change of category or at the next save of their split, as D2 of #454 repairs an offset line left in a former category. Rejected: a data migration, because no column marks the offset line (D1 of #454: only `isOffsetChild`, in TypeScript, recognizes it) and the exposure needs a parent without a category plus « Auto-catégoriser ». - The test adapter refuses `getDb()` during a transaction, as `categoryService.test.ts` does. Rejected: a `getDb()` that always answers, because a `getDb()` call inside the callback, which deadlocks under the real lock, would pass unseen. - The unit fixtures of the parent's read carry `is_manually_categorized: 1`, as both callers write it before that read. Rejected: leaving them without the flag, because the updated pins would then not tell a copy of the flag from a constant 0. - The CHANGELOGs name the labels of the UI: « Auto-catégoriser » / “Auto-categorize” (`transactions.autoCategorize`) and « Sans catégorie » / “No category” (`transactions.table.noCategory`). Rejected: « Catégoriser automatiquement » and « Aucune catégorie » of the brief and the review, because the user reads the button and the option of the list. - `REVIEW.md`: the new test joins the pitfall « Tests vitest qui lisent `src-tauri/` ». Rejected: leaving the list as it was, because the test executes the whole schema with its seed (`METRO` → 1111, categories 1111 and 1112), and a PR that touches only `src-tauri/**` skips `check-frontend` without its review knowing to run it. - `docs/architecture.md`, « SQL réel — `node:sqlite` »: one paragraph on the new test. Rejected: updating only the line of `splitOffsetService.ts`, because the section said « Les autres tests de services gardent leurs faux », which this test makes false. ## Proof Red on the base `4d1ac59`, with the tests of this link and the code of the base: 23 failed of 72 in the four files (`npx vitest run` of the four files, exit 1). Both integration scenarios reproduce R-S3 with the real code; the witness stays green: ``` FAIL src/__integration__/split-offset-manual-flag.test.ts > … > a split parent set to no category by hand keeps its offset line through « Catégoriser automatiquement » AssertionError: expected { '1111': 50, '1112': -50, none: -120 } to deeply equal { '1112': -50, none: -70 } FAIL src/__integration__/split-offset-manual-flag.test.ts > … > a split made under a parent set to no category by hand keeps its offset line through « Catégoriser automatiquement » AssertionError: expected { '1111': 50, '1112': -50, none: -120 } to deeply equal { '1112': -50, none: -70 } ``` The other 21 red tests on the base are the unit tests of the copy and the pins that this link changes on purpose. From the worktree (`npm ci` done): - probe: `src/zz_probe.test.ts`, deliberately red, `npx vitest run src/zz_probe.test.ts` exit 1, file deleted; - `npm run build` (tsc + vite): green; - `npm test`: 171 files / 2841 tests on `4d1ac59`, 172 files / 2853 tests on the head (+1 file, +12 tests), all green; - CI: `check-frontend` run 676 green on `4526637` (Node v24.22.2): `npm run build`, then 172 test files / 2853 tests, the 4 tests of `split-offset-manual-flag.test.ts` included. `check-rust` not triggered: no file under `src-tauri/`, `.cargo/` or `src/__fixtures__/samples/` (the new test only reads `consolidated_schema.sql`). Mutations, one at a time on `36c04ad`, each restored by `git checkout -- <file>` with `git status --short` empty, the four test files run after each (72 tests): 9 mutations, 9 red. | # | Mutation | Red | Among them | |---|---|---|---| | M1 | propagation: flag copy removed (offset line's UPDATE as on the base) | 13 | R-S3 scenario, the three copies, the pins | | M2 | creation: flag copy removed (offset line's INSERT as on the base) | 9 | creation scenario, the three copies at creation, the #513 pins | | M3 | propagation: flag read on the offset line instead of the parent | 11 | R-S3 scenario, « reads the flag on the parent, never on the offset line » | | M4a | propagation: `toSqlFlag` removed, raw value bound | 1 | copy of the TEXT `'true'` | | M4b | creation: `toSqlFlag` removed, raw value bound | 1 | copy of the TEXT `'true'` at creation | | M5 | propagation: the parent's SELECT no longer reads the flag | 3 | R-S3 scenario, SELECT pin, read-order test | | M6 | list path: propagation before the parent's UPDATE (stale flag) | 2 | R-S3 scenario, read-order test | | M7 | creation: constant 1 instead of the parent's flag | 2 | witness scenario, copy of the flag 0 at creation | | M8 | propagation: constant 1 instead of the parent's flag | 2 | copy of the flag 0, flag read on the parent | M4a and M4b are caught by the unit tests only: on a real base the flag reads back as an integer, and only a base written before #390 may hold the TEXT `'true'`. ## REVIEW.md Zone « Migrations, profils et données »: - « Un booléen se lie en `1`/`0` (`toSqlFlag`) »: both new bindings go through `toSqlFlag` (M4a, M4b) and are bound as numbers (asserted by `typeof`). - « une transaction par `withTransaction` et son handle »: the new read and the two writes run on the handle of the caller's transaction (`db`), between its BEGIN and its COMMIT, never through `getDb()`; the handle-only tests of #454 and #513 stay green, and the integration adapter refuses `getDb()` during a transaction. - `notifyDataChanged()`: no new write site. The flag written on the offset line (which `manual_categorized` of `COUNTERS_SQL` counts) is written by `saveSplitAdjustment`, `updateTransactionCategory` and `applyKeywordWithReassignment`, which already notify after their COMMIT. - No migration, no schema change, `consolidated_schema.sql` untouched. Zone « i18n et documentation »: no visible string added; the #454 entry of both CHANGELOGs has one more sentence; `docs/architecture.md` follows; no change of usage for the user guide. ## For the reviewer - **The #513 tests change on purpose.** The tests of `saveSplitAdjustment` that pinned the offset line's INSERT « as before #513 » now pin it with the flag: new constant `INSERT_OFFSET`, `SAVED_PARENT` with `is_manually_categorized: 1`, `SAVED_WRITES` with the offset line's `$9`. « writes the same statements, with the same values, as before #513 » is renamed « …, but the offset line's manual flag (#454) »; « writes the fallbacks … » reads both INSERTs and expects 1 at the end of the offset line; the case « the INSERT of the offset line » of the rollback table matches `INSERT_OFFSET`. « reads the parent first … » and « sends every statement through the transaction's handle … » follow through `SAVED_WRITES`. The values of the entries do not change. - **The nine pins of the offset line's UPDATE** (count of review 29728): 5 in `splitOffsetService.test.ts` (« moves the offset line of a split parent, and only it », « reads the row by its id, with its manual flag, … » for the SELECT, « … of a split income … », « … to no category … », « lets a failed move reach the caller … »), 2 in `transactionService.test.ts` (« moves the offset to the new category … », « rolls back, rethrows … when the offset cannot be moved »), 2 in `categorizationService.test.ts` (« moves the offset line of a checked split parent … », « rolls the keyword and the transactions back … »). - The offset line's UPDATE now has the same SQL as the parent's own UPDATE in `updateTransactionCategoryInTransaction`: the tests tell them apart by their target (`targetOf`, last parameter), and the comment of `ownUpdates()` says so. - Offset lines already written at 0 under a parent at 1 stay so until their parent's next change of category or the next save of their split (decision above). - Suggested manual check at the release, in the Base edition, on a new profile: split « EPICERIE METRO » (or any transaction whose description matches a keyword) with part of it to another category, set it to « Sans catégorie » in the Transactions list, click « Auto-catégoriser »: no transaction categorized, and « Épicerie régulière » gets nothing in the Reports (before this link: +50). Same after setting a transaction to « Sans catégorie » first and splitting it afterwards. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`autoCategorizeTransactions` picks every row without a category whose
`is_manually_categorized` is 0, the children of a split included. The
offset line kept the flag 0 whatever its parent's, so a split parent set
to « Aucune catégorie » by hand lost its offset line to « Catégoriser
automatiquement »: the keyword of the parent's description sent it alone
to its category. With −120 « EPICERIE METRO » split as −50 to B, then set
to no category, the totals went from NULL −70 and B −50 to 1111 +50,
B −50 and NULL −120 (scenario R-S3 of the review of PR #515).

- propagateCategoryToOffsets reads the parent's flag, after the caller's
  UPDATE of the parent, and writes it on the offset line with its
  category, through toSqlFlag (a base written before #390 may hold the
  TEXT 'true').
- saveSplitAdjustment gives the offset line its parent's flag when it
  writes the split, so a split made under a parent categorized, or set to
  no category, by hand does not lose it either. The entries keep the
  column's default, 0.

Tests: a scenario test on a real SQLite database (node:sqlite, the schema
of a new profile with its seed, foreign keys on, the real services
through an adapter local to the file), unit tests of both copies (flag 1,
flag 0 and the TEXT 'true'), and the tests that pinned the offset line's
UPDATE and, since #513, its INSERT, which change on purpose.

Refs #454

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: the offset line's manual flag in the docs and changelogs (#454)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m25s
4526637223
- docs/architecture.md: the line of splitOffsetService.ts says that the
  offset line takes its parent's manual flag, when, and why; the « SQL
  réel — node:sqlite » section describes the scenario test that runs
  whole services on the schema of a new profile, seed included.
- CHANGELOG.md, CHANGELOG.fr.md: one more sentence in the entry of #454,
  “Auto-categorize” no longer moves that amount alone.
- REVIEW.md: the new test joins the list of the front tests that read
  consolidated_schema.sql, which a PR touching only src-tauri/** does not
  run.

Refs #454

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

Niveau : normal

Verdict : APPROVE

La ligne de compensation d'une répartition prend désormais le drapeau is_manually_categorized de son parent, à sa création comme à chaque reclassement du parent, et « Auto-catégoriser » ne la sépare plus d'un parent mis à la main sur « Sans catégorie ». Les rejeux sur une vraie base confirment le correctif sur les deux chemins de reclassement et après « Réinitialiser » ; une seule mutation du relecteur survit, sur un ordre que le code respecte (Non retenu).

Ce que la revue a exécuté

  • Copie hors dépôt de la tête (git archive 4526637, npm ci) : sonde volontairement rouge à rc=1, npm run build vert, npm test à 172 fichiers et 2853 tests verts (Node 22.22.0). CI de la tête : check-frontend run 676 vert (Node v24.22.2, 172 fichiers, 2853 tests, les 4 de split-offset-manual-flag.test.ts compris) ; check-rust non déclenché, aucun fichier sous src-tauri/, .cargo/ ni src/__fixtures__/samples/.
  • Tests de la PR sur le code de production de la base (splitOffsetService.ts et transactionService.ts de 4d1ac59) : 23 rouges sur 72, comme annoncé. Les deux scénarios d'intégration reproduisent R-S3 et le trou à la création avec le code réel ({ '1111': 50, '1112': -50, none: -120 }), le témoin reste vert.
  • Rejeux du relecteur sur une vraie base (node:sqlite, schéma d'un profil neuf avec son seed, clés étrangères actives, services réels derrière le même adaptateur), dans un fichier jetable de la copie :
    • R-S5, « Réinitialiser » : parent mis à la main dans 1111, réparti (−50 vers 1112), puis reinitializeCategories et « Auto-catégoriser ». Parent et compensation restent à NULL avec le drapeau 1, seule l'entrée part vers 22 par sa description : NULL −70, 22 −50. Sur la base : NULL −120 et 22 à 0, la compensation partant avec l'entrée.
    • R-S6, chemin du mot-clé (applyKeywordWithReassignment vers 1113) : la compensation passe à 1113 avec le drapeau 1, puis tient après « Réinitialiser » et « Auto-catégoriser » (NULL −70, 22 −50). Rouge sur la base (drapeau 0).
    • R-S7, compensation héritée, écrite à 0 sous un parent déjà mis à la main sur « Sans catégorie », comme en v0.17.2 : le prochain changement de catégorie du parent la répare (drapeau 1, rien de catégorisé ensuite). R-S7b, la même sans réparation : « Auto-catégoriser » la déplace encore seule (1111 +50, 1112 −50, NULL −120), comme la décision « pas de réparation » de la PR le prévoit.
  • Neuf mutations du relecteur, une à la fois sur la copie, chacune restaurée par git checkout avec un arbre vérifié propre, puis les quatre fichiers de tests de la PR (72 tests) après chacune : huit rouges, une survivante.
# Mutation Tests rouges
RM1 propagation : drapeau pris dans is_split (toujours 1 sous un parent réparti) 2
RM2 propagation : drapeau copié seulement quand le parent perd sa catégorie, 0 sinon 4
RM3 création : drapeau pris dans is_split (0 à la première répartition) 6
RM4 création : drapeau copié seulement quand le parent a une catégorie 2, dont le scénario d'intégration de la création
RM5 création : les entrées prennent aussi le drapeau du parent (UPDATE de tous les enfants avant de marquer la répartition) 3
RM6 propagation : tous les enfants prennent le drapeau, entrées comprises 11
RM7 mot-clé : propagation avant l'UPDATE du parent (drapeau périmé) 0
RM8 création : parent lu par colonnes nommées, sans le drapeau 4, dont le scénario d'intégration de la création
RM9 propagation : drapeau lu sur l'enfant quand la ligne en porte un 1

RM7 appliquée au rejeu R-S6 le fait rougir : la compensation reste à 1113 avec le drapeau 0 sous un parent à 1.

Non retenu

  • RM7 survit : aucun test n'épingle, sur le chemin du mot-clé, que propagateCategoryToOffsets lit le parent après son UPDATE ; seul le chemin de la liste a son test d'ordre. Le code est correct (categorizationService.ts:291, après l'UPDATE) : épingle seulement. Le scénario d'intégration ne passe ni par ce chemin ni par « Réinitialiser » (R-S5 et R-S6 ci-dessus).
  • Compensations héritées : une répartition enregistrée en v0.17.2 sous un parent déjà mis à la main sur « Sans catégorie » garde sa compensation à NULL avec le drapeau 0, et « Auto-catégoriser » la déplace encore seule jusqu'au prochain changement de catégorie du parent ou au prochain enregistrement de la répartition (R-S7b, R-S7). C'est la décision « pas de réparation » de la PR, que la revue garde ; la phrase ajoutée aux CHANGELOG (« ne déplace plus ce montant seul ») ne vaut pour ces répartitions qu'après cette réparation.
  • Libellés : les noms des tests et le commentaire de split-offset-manual-flag.test.ts:149, le commentaire de transactionService.ts:507 et le message du commit de code disent « Catégoriser automatiquement » et « Aucune catégorie », là où l'interface et les CHANGELOG disent « Auto-catégoriser » et « Sans catégorie ».

Vérifié sans constat

  • Niveau : splitOffsetService.ts et transactionService.ts sont du code livré sans appel réseau, URL ni consentement ; le test ajouté est sous src/__integration__/, ni à la racine ni directement dans src-tauri/ ; REVIEW.md n'est touché que dans « Pièges de revue » et reste normal, comme docs/architecture.md ; les CHANGELOG sont bas.
  • Zone « Migrations, profils et données » : les deux nouvelles liaisons passent par toSqlFlag et partent en nombre ; la lecture et les deux écritures passent par le handle de la transaction de l'appelant, jamais par getDb() ; aucun nouveau site d'écriture, les appelants notifiant déjà après leur COMMIT ; aucune migration, consolidated_schema.sql intact.
  • Lecteurs du drapeau relus dans tout src/ : autoCategorizeTransactions ; COUNTERS_SQL, dont la case se coche dès 1, une compensation n'ayant 1 que sous un parent déjà à 1 ; la liste et getSplitParentTransactions, parents seuls ; le détail du tableau de bord, qu'aucun composant ne lit ; l'export et la restauration, par toSqlFlag ; importCategoriesOnly, qui remet tout à 0. Seuls saveSplitAdjustment et la restauration écrivent des enfants.
  • Faits cités : libellés transactions.autoCategorize et transactions.table.noCategory de fr.json et en.json ; mot-clé METRO vers 1111 et catégorie 1112 du seed ; entrée de #454 sous Corrigé et Fixed des deux CHANGELOG ; ajout au piège « Tests vitest qui lisent src-tauri/ » exact.
  • Adaptateur du test d'intégration : $N lié par nom à la N-ième valeur, comme sqlx le lie par son numéro ; getDb() refusé pendant une transaction.
  • Aucun only, skip ni reste de débogage ; requêtes paramétrées ; commits conventionnels (fix: puis docs:).
  • Fermeture : Refs #454 dans le corps et les deux commits, aucun mot-clé de fermeture ; la timeline de #454 porte un seul closes, celui de #515, et none pour #519.

Actions faites

  • Copie de la tête sous /tmp/pr519-head, script de mutations, rapports, journaux et fichier de rejeu supprimés en fin de revue ; dépôt local non modifié (git status vide, fetch seul).
  • Label : #454 porte déjà status:approved (revue de #515) et n'est ni en status:review ni en status:needs-fix : aucun label changé.

Reviewed-SHA: 4526637223

Niveau : normal **Verdict : APPROVE** La ligne de compensation d'une répartition prend désormais le drapeau `is_manually_categorized` de son parent, à sa création comme à chaque reclassement du parent, et « Auto-catégoriser » ne la sépare plus d'un parent mis à la main sur « Sans catégorie ». Les rejeux sur une vraie base confirment le correctif sur les deux chemins de reclassement et après « Réinitialiser » ; une seule mutation du relecteur survit, sur un ordre que le code respecte (Non retenu). ## Ce que la revue a exécuté - Copie hors dépôt de la tête (`git archive 4526637`, `npm ci`) : sonde volontairement rouge à rc=1, `npm run build` vert, `npm test` à 172 fichiers et 2853 tests verts (Node 22.22.0). CI de la tête : `check-frontend` run 676 vert (Node v24.22.2, 172 fichiers, 2853 tests, les 4 de `split-offset-manual-flag.test.ts` compris) ; `check-rust` non déclenché, aucun fichier sous `src-tauri/`, `.cargo/` ni `src/__fixtures__/samples/`. - Tests de la PR sur le code de production de la base (`splitOffsetService.ts` et `transactionService.ts` de `4d1ac59`) : 23 rouges sur 72, comme annoncé. Les deux scénarios d'intégration reproduisent R-S3 et le trou à la création avec le code réel (`{ '1111': 50, '1112': -50, none: -120 }`), le témoin reste vert. - Rejeux du relecteur sur une vraie base (`node:sqlite`, schéma d'un profil neuf avec son seed, clés étrangères actives, services réels derrière le même adaptateur), dans un fichier jetable de la copie : - R-S5, « Réinitialiser » : parent mis à la main dans 1111, réparti (−50 vers 1112), puis `reinitializeCategories` et « Auto-catégoriser ». Parent et compensation restent à NULL avec le drapeau 1, seule l'entrée part vers 22 par sa description : NULL −70, 22 −50. Sur la base : NULL −120 et 22 à 0, la compensation partant avec l'entrée. - R-S6, chemin du mot-clé (`applyKeywordWithReassignment` vers 1113) : la compensation passe à 1113 avec le drapeau 1, puis tient après « Réinitialiser » et « Auto-catégoriser » (NULL −70, 22 −50). Rouge sur la base (drapeau 0). - R-S7, compensation héritée, écrite à 0 sous un parent déjà mis à la main sur « Sans catégorie », comme en v0.17.2 : le prochain changement de catégorie du parent la répare (drapeau 1, rien de catégorisé ensuite). R-S7b, la même sans réparation : « Auto-catégoriser » la déplace encore seule (1111 +50, 1112 −50, NULL −120), comme la décision « pas de réparation » de la PR le prévoit. - Neuf mutations du relecteur, une à la fois sur la copie, chacune restaurée par `git checkout` avec un arbre vérifié propre, puis les quatre fichiers de tests de la PR (72 tests) après chacune : huit rouges, une survivante. | # | Mutation | Tests rouges | |---|---|---| | RM1 | propagation : drapeau pris dans `is_split` (toujours 1 sous un parent réparti) | 2 | | RM2 | propagation : drapeau copié seulement quand le parent perd sa catégorie, 0 sinon | 4 | | RM3 | création : drapeau pris dans `is_split` (0 à la première répartition) | 6 | | RM4 | création : drapeau copié seulement quand le parent a une catégorie | 2, dont le scénario d'intégration de la création | | RM5 | création : les entrées prennent aussi le drapeau du parent (UPDATE de tous les enfants avant de marquer la répartition) | 3 | | RM6 | propagation : tous les enfants prennent le drapeau, entrées comprises | 11 | | RM7 | mot-clé : propagation avant l'UPDATE du parent (drapeau périmé) | **0** | | RM8 | création : parent lu par colonnes nommées, sans le drapeau | 4, dont le scénario d'intégration de la création | | RM9 | propagation : drapeau lu sur l'enfant quand la ligne en porte un | 1 | RM7 appliquée au rejeu R-S6 le fait rougir : la compensation reste à 1113 avec le drapeau 0 sous un parent à 1. ## Non retenu - RM7 survit : aucun test n'épingle, sur le chemin du mot-clé, que `propagateCategoryToOffsets` lit le parent après son UPDATE ; seul le chemin de la liste a son test d'ordre. Le code est correct (`categorizationService.ts:291`, après l'UPDATE) : épingle seulement. Le scénario d'intégration ne passe ni par ce chemin ni par « Réinitialiser » (R-S5 et R-S6 ci-dessus). - Compensations héritées : une répartition enregistrée en v0.17.2 sous un parent déjà mis à la main sur « Sans catégorie » garde sa compensation à NULL avec le drapeau 0, et « Auto-catégoriser » la déplace encore seule jusqu'au prochain changement de catégorie du parent ou au prochain enregistrement de la répartition (R-S7b, R-S7). C'est la décision « pas de réparation » de la PR, que la revue garde ; la phrase ajoutée aux CHANGELOG (« ne déplace plus ce montant seul ») ne vaut pour ces répartitions qu'après cette réparation. - Libellés : les noms des tests et le commentaire de `split-offset-manual-flag.test.ts:149`, le commentaire de `transactionService.ts:507` et le message du commit de code disent « Catégoriser automatiquement » et « Aucune catégorie », là où l'interface et les CHANGELOG disent « Auto-catégoriser » et « Sans catégorie ». ## Vérifié sans constat - Niveau : `splitOffsetService.ts` et `transactionService.ts` sont du code livré sans appel réseau, URL ni consentement ; le test ajouté est sous `src/__integration__/`, ni à la racine ni directement dans `src-tauri/` ; `REVIEW.md` n'est touché que dans « Pièges de revue » et reste normal, comme `docs/architecture.md` ; les CHANGELOG sont bas. - Zone « Migrations, profils et données » : les deux nouvelles liaisons passent par `toSqlFlag` et partent en nombre ; la lecture et les deux écritures passent par le handle de la transaction de l'appelant, jamais par `getDb()` ; aucun nouveau site d'écriture, les appelants notifiant déjà après leur `COMMIT` ; aucune migration, `consolidated_schema.sql` intact. - Lecteurs du drapeau relus dans tout `src/` : `autoCategorizeTransactions` ; `COUNTERS_SQL`, dont la case se coche dès 1, une compensation n'ayant 1 que sous un parent déjà à 1 ; la liste et `getSplitParentTransactions`, parents seuls ; le détail du tableau de bord, qu'aucun composant ne lit ; l'export et la restauration, par `toSqlFlag` ; `importCategoriesOnly`, qui remet tout à 0. Seuls `saveSplitAdjustment` et la restauration écrivent des enfants. - Faits cités : libellés `transactions.autoCategorize` et `transactions.table.noCategory` de `fr.json` et `en.json` ; mot-clé `METRO` vers 1111 et catégorie 1112 du seed ; entrée de #454 sous Corrigé et Fixed des deux CHANGELOG ; ajout au piège « Tests vitest qui lisent `src-tauri/` » exact. - Adaptateur du test d'intégration : `$N` lié par nom à la N-ième valeur, comme sqlx le lie par son numéro ; `getDb()` refusé pendant une transaction. - Aucun `only`, `skip` ni reste de débogage ; requêtes paramétrées ; commits conventionnels (`fix:` puis `docs:`). - Fermeture : `Refs #454` dans le corps et les deux commits, aucun mot-clé de fermeture ; la timeline de #454 porte un seul `closes`, celui de #515, et `none` pour #519. ## Actions faites - Copie de la tête sous `/tmp/pr519-head`, script de mutations, rapports, journaux et fichier de rejeu supprimés en fin de revue ; dépôt local non modifié (`git status` vide, `fetch` seul). - Label : #454 porte déjà `status:approved` (revue de #515) et n'est ni en `status:review` ni en `status:needs-fix` : aucun label changé. Reviewed-SHA: 45266372231337fb9a9fb29efe62a6e8908f02c6
maximus changed target branch from issue-479-reports-period-filters to main 2026-10-30 00:39:11 +00:00
maximus deleted branch issue-454-offset-manual-flag 2026-10-30 00:39:20 +00:00
Author
Owner

Mergée en avance rapide par l'API, épinglée sur la tête relue 45266372231337fb9a9fb29efe62a6e8908f02c6 (revue 29892), base reciblée sur main par Forgejo après le merge de #517 ; tête du tip éprouvé (sonde rc=1, build vert, 172 fichiers / 2853 tests). Corrige le point 1 « À corriger » de la revue 29728 de #515, sur décision de Max (29888). La vérification manuelle proposée sous « For the reviewer » n'est pas ajoutée à STATE.md : Max ne l'a pas demandée au merge, et le test d'intégration sur node:sqlite rejoue le scénario avec les services réels. Non retenu (revue 29892) : lecture du parent après son UPDATE non épinglée sur le chemin du mot-clé (RM7) ; répartitions héritées exposées jusqu'à leur prochain changement ; libellés « Catégoriser automatiquement » et « Aucune catégorie » dans les tests et le message de commit.

Mergée en avance rapide par l'API, épinglée sur la tête relue `45266372231337fb9a9fb29efe62a6e8908f02c6` (revue 29892), base reciblée sur `main` par Forgejo après le merge de #517 ; tête du tip éprouvé (sonde rc=1, build vert, 172 fichiers / 2853 tests). Corrige le point 1 « À corriger » de la revue 29728 de #515, sur décision de Max (29888). La vérification manuelle proposée sous « For the reviewer » n'est pas ajoutée à `STATE.md` : Max ne l'a pas demandée au merge, et le test d'intégration sur `node:sqlite` rejoue le scénario avec les services réels. Non retenu (revue 29892) : lecture du parent après son UPDATE non épinglée sur le chemin du mot-clé (RM7) ; répartitions héritées exposées jusqu'à leur prochain changement ; libellés « Catégoriser automatiquement » et « Aucune catégorie » dans les tests et le message de commit.
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!519
No description provided.