Cohere.Derive.Modules (Cohere v0.1.0)

Copy Markdown View Source

Classifies every module in the host app and groups the domain layer into context groups.

Classification is functional, not name-based: a schema is a module that exports __schema__/1, a repo exports __adapter__/0, a worker declares the Oban.Worker behaviour. Names lie (one validation app's Encrypted.Binary lives in the schema layer but is a Cloak type); compiled modules don't.

A context group is everything under one top-level segment of the app namespace (MyApp.Deals + MyApp.Deals.*). Its kind:

  • :domain — owns at least one Ecto schema
  • :service — has a context module with an API but no schemas (integration wrappers like MyApp.Sheets)
  • :passive — no same-named context module (module collections like MyApp.Workers)
  • :infra — nothing but plumbing (Application, Repo, Ecto types); rendered as a one-line list, not a context entry

Summary

Functions

Classifies one module by reflection. Returns one of :schema, :embedded_schema, :ecto_type, :repo, :application, :router, :worker, :live_view, :live_component, :exception, :protocol, :protocol_impl, :task, :genserver, :module, :unloadable.

Compact summary from the module's @moduledoc: the first paragraph, truncated at a sentence boundary rather than mid-line.

Returns %{groups: [%Group{}], web: %{counts}, root: [module], skipped: [module]}.

Functions

classify(module)

Classifies one module by reflection. Returns one of :schema, :embedded_schema, :ecto_type, :repo, :application, :router, :worker, :live_view, :live_component, :exception, :protocol, :protocol_impl, :task, :genserver, :module, :unloadable.

doc_line(module)

Compact summary from the module's @moduledoc: the first paragraph, truncated at a sentence boundary rather than mid-line.

inventory(project)

Returns %{groups: [%Group{}], web: %{counts}, root: [module], skipped: [module]}.