Remove manual tagging

A tag could come from two places: rules.toml, or the TUI's t key, which wrote
manual_tag with COALESCE(manual_tag, rule_tag) deciding the winner. That split
paid for itself in the first invariant of the codebase, in ClearOverrides and
the c key, in the * marker on the tag column, and in the one exception to a
disposable index -- a tag set by hand was the only thing in index.db that the
statements could not reproduce.

Now rules.toml decides every tag. The index is derived entirely from the
statements plus that file, so deleting it and re-importing gets back exactly
what was there, and retag has nothing to be careful of. Tagging a one-off means
writing a narrow rule on screen 4, which previews what the glob catches before
it is saved.

A manual tag in an existing index is dropped along with the column the first
time this build opens it, and those rows read as whatever the rules say, or as
untagged. TestManualTagSurvivesRetag guarded the invariant that has just been
removed; TestRetagRewritesEveryTag replaces it with the one that took its
place, and keeps Retag itself covered.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 23:19:24 +02:00
co-authored by Claude Opus 5
parent 5ca6cff87b
commit 02814d09e5
10 changed files with 85 additions and 247 deletions
+7 -8
View File
@@ -17,23 +17,22 @@ internal/glob the `*` / `?` matcher used by rules (linear time, no backt
internal/parser Parser interface + registry; nlb, revolut, traderepublic
internal/store SQLite index (modernc.org/sqlite, no cgo)
internal/importer directory walk, dedupe, balance checks
internal/rules applies ordered rules to rule_* columns only
internal/rules applies ordered rules, writing rule_tag
internal/report per-tag aggregation
internal/tui Bubble Tea models
```
## Invariants
**Rule verdicts and manual edits never share a column.** `rule_tag` is
rewritten wholesale on every retag; `manual_tag` is only ever written by the
user. The effective tag is `COALESCE(manual_tag, rule_tag)`. This is what makes
`money retag` safe to run at any time, and it is the first thing to preserve
when touching the schema or the rules engine. Covered by
`TestManualTagSurvivesRetag`.
**Every tag comes from rules.toml.** There is no way to tag a transaction by
hand; `rule_tag` is derived state that `Engine.Retag` rewrites wholesale, which
is what makes `money retag` safe to run at any time. Nothing may write a tag
from anywhere else — the moment something does, the index stops being
reproducible and retag stops being safe. Covered by `TestRetagRewritesEveryTag`.
**Statements are the source of truth; the index is disposable.** Deleting
`index.db` at the root of the data directory and re-importing must reproduce
everything except the tags set by hand.
everything, with nothing lost.
**Dedupe is by fingerprint**: `sha256(date | amount | normalised description |
ordinal)`, where the ordinal distinguishes identical lines *within one