[core] Day 2: capture parsing, splits, share links, QR Platba, sharing boundary; v0.2.0 #2

Manually merged
mnovak merged 5 commits from feature/phones-sharing into main 2026-11-03 23:28:11 +01:00
Owner

Day 2's core: what the phones send, splits, QR Platba, and what a shared budget may receive. Design note: docs/02_capture_sharing.md.

What changes

  • fiscus-ledger
    • New events:
      • payment.shared / payment.unshared (a shared budget's log)
      • split.created / split.settled
      • capture.token_added / capture.token_revoked (hashes only)
      • share.link_created (hash only)
      • account.set
    • apply() stays total: anything that does not add up is rejected with a reason.
    • split::split_equal: sorted and deduplicated by person id, then the day-1 largest-remainder split().
    • share::shared_payment: the only way a payment goes into a shared budget. It carries the effective payment and leaves the card, note and statement details home.
    • pay: a checked Czech IBAN (mod 97, plus the BBAN's mod 11; also from prefix-number/bank) and spayd().
    • State::share_view: exactly one person's open share, or nothing.
  • fiscus-capture (new)
    • The iPhone Shortcut post, parsed strictly. The amount is read from its text, never as a float. Unknown or duplicate fields, a wrong currency, a time without an offset, or anything over 4 KiB is an error.
    • Android notification templates: app filter first, exact literal-with-holes matching, and two disagreeing readings mean unknown.
    • The registry is empty: no notification samples exist (fixtures/notifications/README.md).
  • fiscus-insight: household_duplicates, on shared names only.
  • Version 0.2.0.

Tests (written first): 85 pass, 0 fail

Binary Tests Mandatory test
ledger splits 12 splits always sum exactly (proptest); the remainder doesn't depend on order (proptest); split/settle refusals; the share link shows exactly one person's share; settled, expired or unknown links show nothing
ledger pay 5 SPAYD matches the format; IBAN and Czech account validation
ledger sharing 4 payment.shared only for a payment in that budget, without its card; unshare; a split payment stays shared
capture shortcut 6 malformed, oversized and truncated posts are errors; random bytes never panic
capture notification 6 unselected apps are never read; unknown formats are ignored; ambiguous readings are unknown; the real-fixture walk (0 samples)
insight household 2 duplicates only across two or more members
day 1 50 unchanged, all green

Self-review

  • No float anywhere: the no_float scan still passes over the new crate. Amounts go through Haler::parse_czk, and JSON numbers are read as raw text (RawValue). This avoids arbitrary_precision, which would change serde_json for every crate that links it.
  • Hostile input is never half-applied: every new apply() arm checks first and mutates last. The share-link test serialises the whole page model and looks for the other people's names and amounts.
  • No secrets in the log: capture tokens and share links are stored only as SHA-256. The tests refuse anything that is not 64 lowercase hex characters.
  • Never invent a format: the only templates are the synthetic ones in the test file, named as such.
  • Known and accepted:
    • Any member of a shared budget can split any payment in it (v1).
    • service_key (the first word of the merchant key) may group two products of one company ("google").
  • The three clippy warnings left are in day-1 code (merchant.rs, money.rs, subscriptions.rs), untouched here. Day-1 code isn't rustfmt-formatted, so I didn't reformat anything.
Day 2's core: what the phones send, splits, QR Platba, and what a shared budget may receive. Design note: `docs/02_capture_sharing.md`. ## What changes - **`fiscus-ledger`** - New events: - `payment.shared` / `payment.unshared` (a shared budget's log) - `split.created` / `split.settled` - `capture.token_added` / `capture.token_revoked` (hashes only) - `share.link_created` (hash only) - `account.set` - `apply()` stays total: anything that does not add up is rejected with a reason. - `split::split_equal`: sorted and deduplicated by person id, then the day-1 largest-remainder `split()`. - `share::shared_payment`: the only way a payment goes into a shared budget. It carries the effective payment and leaves the card, note and statement details home. - `pay`: a checked Czech IBAN (mod 97, plus the BBAN's mod 11; also from `prefix-number/bank`) and `spayd()`. - `State::share_view`: exactly one person's open share, or nothing. - **`fiscus-capture`** (new) - The iPhone Shortcut post, parsed strictly. The amount is read from its text, never as a float. Unknown or duplicate fields, a wrong currency, a time without an offset, or anything over 4 KiB is an error. - Android notification templates: app filter first, exact literal-with-holes matching, and two disagreeing readings mean unknown. - **The registry is empty**: no notification samples exist (`fixtures/notifications/README.md`). - **`fiscus-insight`**: `household_duplicates`, on shared names only. - Version 0.2.0. ## Tests (written first): 85 pass, 0 fail | Binary | Tests | Mandatory test | |:--|--:|:--| | ledger `splits` | 12 | splits always sum exactly (proptest); the remainder doesn't depend on order (proptest); split/settle refusals; the share link shows exactly one person's share; settled, expired or unknown links show nothing | | ledger `pay` | 5 | SPAYD matches the format; IBAN and Czech account validation | | ledger `sharing` | 4 | `payment.shared` only for a payment in that budget, without its card; unshare; a split payment stays shared | | capture `shortcut` | 6 | malformed, oversized and truncated posts are errors; random bytes never panic | | capture `notification` | 6 | unselected apps are never read; unknown formats are ignored; ambiguous readings are unknown; the real-fixture walk (**0 samples**) | | insight `household` | 2 | duplicates only across two or more members | | day 1 | 50 | unchanged, all green | ## Self-review - **No float anywhere:** the `no_float` scan still passes over the new crate. Amounts go through `Haler::parse_czk`, and JSON numbers are read as raw text (`RawValue`). This avoids `arbitrary_precision`, which would change `serde_json` for every crate that links it. - **Hostile input is never half-applied:** every new `apply()` arm checks first and mutates last. The share-link test serialises the whole page model and looks for the other people's names and amounts. - **No secrets in the log:** capture tokens and share links are stored only as SHA-256. The tests refuse anything that is not 64 lowercase hex characters. - **Never invent a format:** the only templates are the synthetic ones in the test file, named as such. - Known and accepted: - Any member of a shared budget can split any payment in it (v1). - `service_key` (the first word of the merchant key) may group two products of one company ("google"). - The three clippy warnings left are in day-1 code (`merchant.rs`, `money.rs`, `subscriptions.rs`), untouched here. Day-1 code isn't rustfmt-formatted, so I didn't reformat anything.
mnovak added 5 commits 2026-11-03 23:27:59 +01:00
mnovak manually merged commit 101073f853 into main 2026-11-03 23:28:11 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/FiscusPublic#2