Skip to content

epic(refactor): decompose monolith files along settled crate boundaries #1016

Description

@DecisionNerd

Found during the architecture audit (sub-agent review).

Finding (HIGH, XL)

Three crates are ~70% of all source (≈429k total): storage 127,371 LOC / api 89,257 / exec 84,065. Crate boundaries no longer reflect module structure; change blast radius and compile time concentrate there. Monolith files:

  • graphforge-rel/src/expr.rs18,350 lines (whole rel crate: 28,591 in 5 files)
  • graphforge-api/src/lib.rs20,534 lines
  • graphforge-storage/src/uuid_membership.rs — 10,965
  • graphforge-storage/src/graph_construction.rs — 10,912
  • graphforge-exec/src/algorithm_rank.rs — 10,407
  • graphforge-exec/src/lib.rs — 8,061
  • graphforge-storage/src/writer.rs — 8,910

Acceptance criteria

  • No crates/*/src file exceeds a stated bound (suggest 3,000 lines) without an ADR exemption
  • rel/expr.rs decomposed along its existing internal sections (lowering, UDFs, scalar eval) with no behavior change
  • api/lib.rs decomposed into existing topic modules (search/knowledge/provenance already split out — continue the pattern)
  • All existing tests green per extraction step; no batch mega-PR

Architecture review decision

This is an epic, not a single implementation PR. File-size reduction follows settled crate boundaries; it must not run ahead of #1006, #1008, #1010, #1013, #1015, #1017, #1018, or #1021 and cause the same code to be moved twice.

The suggested 3,000-line figure is a review trigger, not an arbitrary universal hard limit. Create one child issue per file/domain extraction, with behavior-preserving commits and normal test gates. ADR exemptions should explain cohesion and reviewability, not merely file length.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreCore source code changesrelease:noneNo release note or version impact

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions