Implement adjudicated DO items across backend, frontend, deploy

From the ROADMAP adjudication (12 of 13 DO items; D2 is a commit action).

Backend:
- B3: pytest suite (auth, entity CRUD, rollup) + dev deps + pytest config
- B4: cap document uploads at TEN31_MAX_UPLOAD_SIZE (default 50MB), stream-
  checked with partial-file cleanup, 413 on overflow
- B7: type AuditLog.detail as dict|list|str|None to match the JSON column
- B10: index foreign-key columns (migration a7b8c9d0e1f2 + index=True)
- B11: cli delete-user logs file-removal errors instead of swallowing them

Frontend:
- F2: distinguish "server unreachable" from "logged out"; retry prompt
- F4: confirm before destructive holdings-replace on import; step progress
- F6: expandable audit-log detail with full JSON
- F7: empty-state on the Investments page
- F8: shared role helpers (WRITER_ROLES/canEditRound/isApprover), used by
  EntitiesList, AuditLog, Import, ValuationWorkflow

Deploy:
- D5: run tsc --noEmit before packaging (build script)
- D6: TEN31_LOG_LEVEL env var (defaults to info)

Verified: 8/8 backend tests pass; alembic upgrades to head with 13 FK
indexes; upload limit rejects oversized + cleans up; frontend tsc + vite
build clean; dev server serves and proxies to the API.
This commit is contained in:
Jonathan Kirkwood
2026-07-01 13:33:40 -05:00
parent 77eeb3bd7f
commit 8247c28243
22 changed files with 1757 additions and 465 deletions
@@ -0,0 +1,50 @@
"""add indexes on foreign-key columns
Indexes the FK columns that are commonly filtered/joined and are not already the left-most
column of an existing unique constraint (those are covered by the constraint's index). Names
match SQLModel's index=True default (ix_<table>_<column>) so the ORM and DB stay in sync.
Revision ID: a7b8c9d0e1f2
Revises: f6a7b8c9d0e1
Create Date: 2026-07-01 09:30:00.000000
"""
from typing import Sequence, Union
from alembic import op
revision: str = 'a7b8c9d0e1f2'
down_revision: Union[str, None] = 'f6a7b8c9d0e1'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
# (index_name, table, column)
_INDEXES = [
('ix_users_primary_account_id', 'users', 'primary_account_id'),
('ix_holdings_entity_id', 'holdings', 'entity_id'),
('ix_positions_holding_id', 'positions', 'holding_id'),
('ix_valuation_rounds_submitted_by', 'valuation_rounds', 'submitted_by'),
('ix_valuation_rounds_approved_by', 'valuation_rounds', 'approved_by'),
('ix_valuations_position_id', 'valuations', 'position_id'),
('ix_audit_log_actor_user_id', 'audit_log', 'actor_user_id'),
('ix_entity_access_entity_id', 'entity_access', 'entity_id'),
('ix_documents_entity_id', 'documents', 'entity_id'),
('ix_documents_investor_user_id', 'documents', 'investor_user_id'),
('ix_documents_uploaded_by', 'documents', 'uploaded_by'),
('ix_capital_account_statements_investor_user_id',
'capital_account_statements', 'investor_user_id'),
('ix_capital_account_statements_document_id',
'capital_account_statements', 'document_id'),
]
def upgrade() -> None:
for name, table, column in _INDEXES:
op.create_index(name, table, [column])
def downgrade() -> None:
for name, table, _column in reversed(_INDEXES):
op.drop_index(name, table_name=table)