Modules
Hugo carved into five feature modules plus a shared Platform layer. Use this breakdown to scope agent work, write per-module docs, and point teammates at the right part of the codebase.Feature modules
What lives here: Limited Partnership Agreement drafts, investor comment memos, canonical Q&A, and reply propagation. Everything to do with the fund's constitutional document and the comments investors raise against it.
Key tables: lpa_documents, lpa_memos, memo_comments, memo_comment_turns, memo_comment_turn_attachments, canonical_questions, standard_replies, memo_comment_canonical_links, canonical_question_sources.
Routes: /lpa-drafts, /lpa-memos, /memo-review, /canonical-questions, /review-queue.
Invariant: LPA is always separate from Side Letter. Different documents, different lifecycles, different modules. Do not merge.
What lives here: Upload, parse, review, and merge of side letters and master side letters (MSL/BPMSL). Plus the full MFN engine: rule configuration, election policy, and impact analysis. MFN is treated as a side-letter mechanism — the policy layer over side-letter clause distribution — not an Investors feature, even though elections are commitment-scoped.
Key tables: documents (type side_letter / msl / bpmsl), document_parse_attempts, clauses, clause_assignments, clause_ops_tags, mfn_basic_rules, mfn_general_rules, mfn_individual_rules, mfn_elections.
Routes: /upload, /upload-review, /mfn-settings, /mfn-impact, MSL browsing under /library?msl=true.
What lives here: The obligations register / Operations Manual — a reporting-and-compliance view over clause_ops_tags that surfaces operational obligations (reporting duties, consents, notices) extracted from clauses. Currently side-letter-derived but broadens over time, which is why it's its own module rather than a sub-area of Side Letter.
Main file: src/pages/operations.tsx.
Sidebar label: "Operations manual".
What lives here: The firm's cross-fund knowledge layer. Everything the firm knows about clauses it has negotiated, investors it has met, and sponsors it has dealt with — plus the tools for applying that knowledge to new deals. Read-mostly.
Features:
- Clause Precedent — cross-fund precedent lookup (
pages/clause-precedent.tsx, serves/intelligence). - Pro Forma generation — compose a projected side letter for an incoming LP using precedent. Pro Forma lives in Intelligence, not Side Letter, because generating it is fundamentally a precedent lookup + composition activity.
- Investor Register — firm-wide directory and profile lookup for investors and LPs.
- Sponsor Register — firm-wide directory and profile lookup for sponsors and GP entities.
- Comparables (
services/comparables.ts). - LP Profile lookup (
services/lp-profile.ts). - Freeform chat over the corpus (
services/chat-router.ts).
Note: "Investor Book" is not a name used in Hugo — the feature is called Investor Register, and it lives inside Intelligence alongside the other cross-fund lookup features.
What lives here: The lawyer's work on a specific fund across its lifecycle. One module because a lawyer opens a fund and from that context reviews the action queue, works their task list, runs a closing, and generates an ISL — they think "I'm working on Fund Baltic III", not "now I'm in Tasks, now I'm in Export".
Features:
- Fund overview / hub —
pages/fund-detail.tsx, the action queue. - Fund setup — create funds, configure sponsors/GPs as entities, LPAC. (Operational/write side — the read-only register view lives in Intelligence.)
- Closings —
fund_closings, closing workflow. - LP Tasks — closing checklists, kanban, comments, history.
- Activity feed — per-fund view of
activity_log. - Per-fund export — generic ISL/EF bundle generation (non-pro-forma; Pro Forma is Intelligence).
- Investor operational work — commitments CRUD, bulk import, investor taxonomy management when scoped to a fund.
Key tables (partial): funds, sponsors, gp_entities, fund_closings, lpac_members, lp_tasks, lp_task_comments, lp_task_history, commitments, fund_export_settings.
Platform (cross-cutting; not a feature module)
Platform is the layer agents should read before touching any module. It answers "things every module needs to know".
- Auth + fund-access middleware (
src/middleware/) - AI Gateway (
src/lib/ai.ts) — allAI.run()calls must go through the CF AI Gateway. Direct calls are forbidden. - Docx parsing (
src/lib/docx-extract/) - R2 storage helpers (
src/lib/r2-keys.ts) - Queues + DLQ handlers (
src/queues/) - Shared types (
src/lib/types.ts) - D1 retry wrapper (
src/lib/db.ts) — always usec.var.db, neverc.env.DB - Telemetry:
activity-logger.ts,fund-events.ts,impact-emit.ts— written to by every module as side effects - Global admin: users, system settings, clause names/groups config, ops tag categories, definitions (truly global, not fund-scoped)
Consider
- Generated
schema.sqlsnapshot. 72 migration files on top of0001_init.sql, with later migrations dropping/renaming columns —CREATE TABLEin0001no longer reflects current shape. An auto-generated reference-onlyschema.sql(dumped fromsqlite_master, regenerated in CI, never executed) would give agents and humans a single file to grep for the true current schema without replaying the migration ledger.
Design decisions worth knowing
| Decision | Why |
|---|---|
| No "Clause Library" module | Clause browsing surfaces live inside the module that owns the data: MSL browsing → Side Letter, clause groups config → Platform admin, clause precedent → Intelligence. |
| No "Document Export" module | Export is a verb. Per-fund exports → Fund Management; Pro Forma → Intelligence; side-letter bundle exports → Side Letter. |
| No "Activity" module | Activity is telemetry infrastructure (Platform) with per-fund read views (Fund Management). |
| Sponsors appear in two modules | Fund Management owns entity config (write side). Intelligence owns the firm-wide register (read side). Different modes of the same underlying data. |
| MFN lives in Side Letter, not Investors | Even though mfn_elections is commitment-scoped, MFN is conceptually a side-letter mechanism: a side letter grants a clause, MFN decides which other LPs automatically inherit it. Policy layer over side-letter clause distribution. |
| LPA and Side Letter are always separate | Different legal instruments with different lifecycles. An LPA is the fund's constitutional document; a side letter is a bilateral supplement to it. They may share utility code via Platform (docx parsing, clause text normalization) but never merge at the module level. |