Skip to content

refactor: enforce Router → Service → DB with an import contract and a shrink-only baseline #4418

Open

Description

@vybe

Summary

Invariant #1 says routers hold no business logic and services hold no HTTP concerns. Nothing enforces it, and the code has drifted.

Context

  • About 680 direct db.*() calls under src/backend/routers/.
  • 15 service modules import from routers.
  • About 1,400 function-local imports under services/ and routers/, many of them working around import cycles.

Acceptance Criteria

  • An import contract (routers → services → db) runs in CI with a shrink-only baseline.
  • Helpers that services import from routers move into services.
  • The baseline is committed with its starting counts.

Technical Notes

Mirror the existing ratchets under tests/unit/.

Found in the 2026-11-09 architecture review; facts checked on dev at 13d32e22f. See "Proposed Targets" in docs/planning/TARGET_ARCHITECTURE.md (PR #4405).

Activity

  1. added
    priority-p3
    type-refactor
    theme-devex
    complexity-medium
    status-ready
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p3status-readytheme-devextype-refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions