# 01 — The current system, completely specified

This directory is the **parity bar**: rebuild-ready specifications of
everything the current app does, written so a future session can
rebuild each feature from its spec alone. Ground-truth precedence used
throughout: actual code > extraction analyses > the old feature docs.
Where sources disagreed, the spec follows code and records the
divergence as a wart with a rebuild requirement.

## Reference docs

| doc | contents |
|---|---|
| [schema.md](schema.md) | Final-state database schema after all 41 migrations: every table, column, constraint, index, trigger — plus the schema history that matters for migration and the columns the rebuild drops. |
| [rpcs-and-authz.md](rpcs-and-authz.md) | Exact semantics of every RPC/SQL function (final versions), the full RLS policy set, the TypeScript permission truth tables, and the effective-user/view-as resolution chain. |
| [tests.md](tests.md) | All 116 existing tests, file by file, each with a ports-to verdict. |

## Feature specs (`features/`)

Each follows the same template: purpose → user workflows → numbered
testable behaviors (B1…Bn) → data model → permissions → edge cases →
UI notes (incl. rian's recorded taste) → rebuild deltas → test specs.

| spec | scope |
|---|---|
| [auth-and-login.md](features/auth-and-login.md) | Login, forced password change, session refresh, signout — all REPLACED by id-auth Pattern B (deltas map each behavior). |
| [organizations-and-team.md](features/organizations-and-team.md) | Orgs, membership roles, teams, team members, rates, consolidate_as, Gary the $0 AI. |
| [entries.md](features/entries.md) | The /entries page: filters, statuses, inline edit, cascading inheritance, manual entry, bulk ops + the bulk-safety history. |
| [imports.md](features/imports.md) | CSV parsing (all dialects + auto-detection), two-step staging, the resolver, commit pipeline, batch management. |
| [invoices.md](features/invoices.md) | Invoice lifecycle, apply/lock semantics, margin view, the paste-block export. |
| [projects-and-entities.md](features/projects-and-entities.md) | /projects summary + expand, income/margin, quick filters; /projects/manage entity CRUD, rename propagation, delete/reassign, move. |
| [summary.md](features/summary.md) | The root Summary page: month picker, $/duration cells, pivots, adjustment math. |
| [adjustments-and-rates.md](features/adjustments-and-rates.md) | Rates, overrides (fixed/pct, precedence), display-only adjustments, stamping + re-stamp. |
| [cc-expenses.md](features/cc-expenses.md) | CC expense batches, paste parsing, auto-rules, highlight keywords, color semantics, billing export. |
| [comments.md](features/comments.md) | Global comments board, @mentions, resolve lifecycle, nav bell. |
| [permissions-and-view-as.md](features/permissions-and-view-as.md) | The permission matrix (exact truth tables — the R1 parity contract, keyed to effective enforcement) + view-as impersonation. |
| [phase-outs.md](features/phase-outs.md) | Everything the rebuild deliberately drops (Toggl/transfer, rate_proportion, Supabase machinery…) with what absorbs each responsibility. |

## Parity-bar deltas since 2026-07-07

- **2026-07-08 — CSV archiving added to the old app** (the ONE
  sanctioned change, Day-0 #4): `uploadClockifyCsv` now writes every
  incoming CSV verbatim to `.csv-archive/` (host-mounted volume;
  best-effort try/catch — cannot break an import). No user-visible
  behavior change; no spec/test rows affected. The rebuild's parser
  cross-validation consumes the archive until cutover.
