fix: a split's offset line takes its parent's manual flag (#454) #519
No reviewers
Labels
No labels
autopilot:pending-human
source:analyste
source:defenseur
source:human
source:medic
source:revue
status:approved
status:blocked
status:in-progress
status:needs-clarification
status:needs-fix
status:ready
status:review
status:to-test
status:triage
type:bug
type:feature
type:infra
type:refactor
type:schema
type:security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
maximus/Simpl-Resultat!519
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-454-offset-manual-flag"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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, head4d1ac59).Level: normal (
REVIEW.mdofmain), set bysrc/services/splitOffsetService.tsandsrc/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 undersrc/__integration__/, neither at the root nor directly insrc-tauri/;docs/architecture.mdandREVIEW.md(outside « Niveaux ») stay normal; the CHANGELOGs are low.Summary
autoCategorizeTransactionspicks every rowWHERE 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:updateTransactionCategory(id, null, true)): totals NULL −70 and B −50, correct; then « Auto-catégoriser »: the seed'sMETROkeyword sends the offset line alone to 1111 (« Épicerie régulière »): 1111 +50, B −50, NULL −120.reinitializeCategoriessets everycategory_idto NULL and keeps the flags) exposed it the same way.The change:
propagateCategoryToOffsetsreadsis_manually_categorizedwith 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 writescategory_id,is_manually_categorized(throughtoSqlFlag) andupdated_at. In the app, both callers (the list, the keyword path) write the flag 1 on the parent, so the offset line gets 1.saveSplitAdjustmentInTransactionwrites the offset line withis_manually_categorized = toSqlFlag(parent.is_manually_categorized). The entries keep the column's default, 0 (out of scope).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:82counts 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.getTransactionPage,t.parent_transaction_id IS NULL) andgetSplitParentTransactionsread the flag on parents only. The Dashboard drill-down (getTransactionsByCategory,dashboardService.ts:142) does return children with their flag, but no component readsis_manually_categorized(only the optimistic update of the list row,useTransactions.ts:188).toSqlFlag(dataExportService.ts): an offset line under a parent at 1 now goes out and back with 1.importCategoriesOnlystill resets every flag to 0. On the Rust side,profile_db.rsonly converts the TEXT'true'(#390).Files
src/services/splitOffsetService.tsParentRow.is_manually_categorized; the parent's SELECT reads the flag; the offset line's UPDATE isSET category_id = $1, is_manually_categorized = $2, updated_at = CURRENT_TIMESTAMP WHERE id = $3, flag bytoSqlFlag; docstring correctedsrc/services/transactionService.tssaveSplitAdjustmentInTransactionaddsis_manually_categorized($9,toSqlFlag(parent.is_manually_categorized)); the entries' INSERT is unchanged; docstring ofsaveSplitAdjustmentsrc/__integration__/split-offset-manual-flag.test.tssrc/services/splitOffsetService.test.ts'true'; flag read on the parent, never on the offset line)src/services/transactionService.test.tsINSERT_OFFSET); 1 test of the read order, 3 tests of the copy at creationsrc/services/categorizationService.test.tsdocs/architecture.mdsplitOffsetService.ts: the flag follows the parent, when and why; « SQL réel —node:sqlite»: the new testCHANGELOG.md,CHANGELOG.fr.mdREVIEW.mdsrc-tauri/»: the new test readsconsolidated_schema.sqlThe integration test runs
node:sqlite(DatabaseSync, in memory) on the whole ofconsolidated_schema.sql, seed included, foreign keys on as under sqlx, with the realsaveSplitAdjustment,updateTransactionCategoryandautoCategorizeTransactions.../services/dbis mocked by an adapter local to the file:selectandexecutewith$Nbound by name,rowsAffectedandlastInsertId,withTransactionpassing the same handle,getDb()refused during a transaction. No shared harness (#392 plans one). Its tests:METROkeyword, as the brief expected (no substitute needed);Decisions
Decided before this link:
propagateCategoryToOffsets, read on the parent after the caller's UPDATE and written with its category throughtoSqlFlag. Rejected: excluding the children of a split fromautoCategorizeTransactionsand 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.saveSplitAdjustmentInTransaction, bytoSqlFlag(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):
… 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.isOffsetChild, in TypeScript, recognizes it) and the exposure needs a parent without a category plus « Auto-catégoriser ».getDb()during a transaction, ascategoryService.test.tsdoes. Rejected: agetDb()that always answers, because agetDb()call inside the callback, which deadlocks under the real lock, would pass unseen.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.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 lisentsrc-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 onlysrc-tauri/**skipscheck-frontendwithout 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 ofsplitOffsetService.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 runof the four files, exit 1). Both integration scenarios reproduce R-S3 with the real code; the witness stays green: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 cidone):src/zz_probe.test.ts, deliberately red,npx vitest run src/zz_probe.test.tsexit 1, file deleted;npm run build(tsc + vite): green;npm test: 171 files / 2841 tests on4d1ac59, 172 files / 2853 tests on the head (+1 file, +12 tests), all green;check-frontendrun 676 green on4526637(Node v24.22.2):npm run build, then 172 test files / 2853 tests, the 4 tests ofsplit-offset-manual-flag.test.tsincluded.check-rustnot triggered: no file undersrc-tauri/,.cargo/orsrc/__fixtures__/samples/(the new test only readsconsolidated_schema.sql).Mutations, one at a time on
36c04ad, each restored bygit checkout -- <file>withgit status --shortempty, the four test files run after each (72 tests): 9 mutations, 9 red.toSqlFlagremoved, raw value bound'true'toSqlFlagremoved, raw value bound'true'at creationM4a 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 »:
1/0(toSqlFlag) »: both new bindings go throughtoSqlFlag(M4a, M4b) and are bound as numbers (asserted bytypeof).withTransactionet 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 throughgetDb(); the handle-only tests of #454 and #513 stay green, and the integration adapter refusesgetDb()during a transaction.notifyDataChanged(): no new write site. The flag written on the offset line (whichmanual_categorizedofCOUNTERS_SQLcounts) is written bysaveSplitAdjustment,updateTransactionCategoryandapplyKeywordWithReassignment, which already notify after their COMMIT.consolidated_schema.sqluntouched.Zone « i18n et documentation »: no visible string added; the #454 entry of both CHANGELOGs has one more sentence;
docs/architecture.mdfollows; no change of usage for the user guide.For the reviewer
saveSplitAdjustmentthat pinned the offset line's INSERT « as before #513 » now pin it with the flag: new constantINSERT_OFFSET,SAVED_PARENTwithis_manually_categorized: 1,SAVED_WRITESwith 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 matchesINSERT_OFFSET. « reads the parent first … » and « sends every statement through the transaction's handle … » follow throughSAVED_WRITES. The values of the entries do not change.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 intransactionService.test.ts(« moves the offset to the new category … », « rolls back, rethrows … when the offset cannot be moved »), 2 incategorizationService.test.ts(« moves the offset line of a checked split parent … », « rolls the keyword and the transactions back … »).updateTransactionCategoryInTransaction: the tests tell them apart by their target (targetOf, last parameter), and the comment ofownUpdates()says so.🤖 Generated with Claude Code
Niveau : normal
Verdict : APPROVE
La ligne de compensation d'une répartition prend désormais le drapeau
is_manually_categorizedde 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é
git archive 4526637,npm ci) : sonde volontairement rouge à rc=1,npm run buildvert,npm testà 172 fichiers et 2853 tests verts (Node 22.22.0). CI de la tête :check-frontendrun 676 vert (Node v24.22.2, 172 fichiers, 2853 tests, les 4 desplit-offset-manual-flag.test.tscompris) ;check-rustnon déclenché, aucun fichier soussrc-tauri/,.cargo/nisrc/__fixtures__/samples/.splitOffsetService.tsettransactionService.tsde4d1ac59) : 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.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 :reinitializeCategorieset « 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.applyKeywordWithReassignmentvers 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).git checkoutavec un arbre vérifié propre, puis les quatre fichiers de tests de la PR (72 tests) après chacune : huit rouges, une survivante.is_split(toujours 1 sous un parent réparti)is_split(0 à la première répartition)RM7 appliquée au rejeu R-S6 le fait rougir : la compensation reste à 1113 avec le drapeau 0 sous un parent à 1.
Non retenu
propagateCategoryToOffsetslit 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).split-offset-manual-flag.test.ts:149, le commentaire detransactionService.ts:507et 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
splitOffsetService.tsettransactionService.tssont du code livré sans appel réseau, URL ni consentement ; le test ajouté est soussrc/__integration__/, ni à la racine ni directement danssrc-tauri/;REVIEW.mdn'est touché que dans « Pièges de revue » et reste normal, commedocs/architecture.md; les CHANGELOG sont bas.toSqlFlaget partent en nombre ; la lecture et les deux écritures passent par le handle de la transaction de l'appelant, jamais pargetDb(); aucun nouveau site d'écriture, les appelants notifiant déjà après leurCOMMIT; aucune migration,consolidated_schema.sqlintact.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 etgetSplitParentTransactions, parents seuls ; le détail du tableau de bord, qu'aucun composant ne lit ; l'export et la restauration, partoSqlFlag;importCategoriesOnly, qui remet tout à 0. SeulssaveSplitAdjustmentet la restauration écrivent des enfants.transactions.autoCategorizeettransactions.table.noCategorydefr.jsoneten.json; mot-cléMETROvers 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 lisentsrc-tauri/» exact.$Nlié par nom à la N-ième valeur, comme sqlx le lie par son numéro ;getDb()refusé pendant une transaction.only,skipni reste de débogage ; requêtes paramétrées ; commits conventionnels (fix:puisdocs:).Refs #454dans le corps et les deux commits, aucun mot-clé de fermeture ; la timeline de #454 porte un seulcloses, celui de #515, etnonepour #519.Actions faites
/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 statusvide,fetchseul).status:approved(revue de #515) et n'est ni enstatus:reviewni enstatus:needs-fix: aucun label changé.Reviewed-SHA:
4526637223Mergée en avance rapide par l'API, épinglée sur la tête relue
45266372231337fb9a9fb29efe62a6e8908f02c6(revue 29892), base reciblée surmainpar 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 surnode:sqliterejoue 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.