Skip to content

Harden codebase correctness and efficiency - #24

Merged
11sid11 merged 1 commit into
mainfrom
agent/codebase-quality-hardening
Aug 16, 2026
Merged

Harden codebase correctness and efficiency#24
11sid11 merged 1 commit into
mainfrom
agent/codebase-quality-hardening

Conversation

@11sid11

@11sid11 11sid11 commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Summary

This is a focused codebase hardening pass based on the senior engineering audit. It fixes concrete correctness drift first, then applies measured efficiency and maintainability improvements without adding dependencies or changing the IndexedDB table schema.

What changed

  • Fix Overview monthly budget lookup by using the canonical Track budget repository/month index instead of treating month as a primary key.
  • Reuse canonical financial domain logic in Overview:
    • Lend signs come from entryToSignedAmount.
    • Split balances come from computeMemberBalances.
  • Make archived Lend ledgers consistently non-active across repositories, live queries, Overview balances/activity, and quick-entry resolution.
  • Make Lend getOrCreate(personId, currency) transactional so concurrent callers cannot create two active ledgers for the same pair.
  • Reduce avoidable IndexedDB work:
    • person-specific Lend queries use existing personId / compound indexes;
    • Split payer/share relations use the existing expenseId index with anyOf() instead of loading entire relation tables;
    • pure Split composition uses useMemo rather than useLiveQuery when no database read occurs;
    • Track budget lookup uses its month index.
  • Harden portable backup validation with Zod-backed runtime validation for persisted financial rows.
  • Add the financially meaningful defaultCurrency to backups while preserving device-only UI preferences on restore.
  • Bump the portable backup format version to 2. This is intentionally not backward-compatible because the app is still in development.
  • Code-split route screens with TanStack Router's supported lazyRouteComponent() API.
  • Add PR CI that runs install, typecheck, lint, tests, and production build before merge.
  • Move Spinner to Spinner.tsx; keep Tabs.tsx as a tiny compatibility re-export and correct the UI barrel export.
  • Correct repository-layer documentation to match the actual rule: repositories own writes; query/projection layers may read Dexie; UI components should not touch tables directly.

Regression coverage

  • Overview budget lookup with a generated budget ID.
  • Overview excludes archived Lend ledgers.
  • Archived Lend ledgers are excluded from active repository lists and quick-entry creates a fresh active ledger.
  • Backup validation rejects malformed financial rows with a useful field path.
  • Backup round-trip preserves records and the default financial currency.
  • Backup E2E uses the canonical Lend sign function.

Compatibility / data model

  • No IndexedDB table or index schema changes.
  • Portable backup schema is intentionally bumped to v2; v1 backups/recovery snapshots are not migrated in this development-stage change.
  • No new dependencies.

Validation

The new PR CI workflow is included in this branch and will run pnpm typecheck, pnpm lint, pnpm test, and pnpm build. I will not merge until those checks are green.

@11sid11
11sid11 merged commit e152943 into main Aug 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant