Documentation
¶
Overview ¶
Package paradigm computes a database schema's analytic-vs-transactional paradigm and each table's warehouse role, as a pure function over the neutral internal/core/db model. It imports ONLY internal/core/db — never a provider, never internal/config, never a sensor (ADR 0015's schema-only simplicity, extended to this second neutral input by ADR 0033).
Detect SEEDS the classification from structural evidence; Resolve applies an explicit developer override on top, honoring the project's innegociable developer-autonomy principle: an explicit config value always wins over detection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Classification ¶
Classification is a schema's computed paradigm plus its per-table role map (keyed by db.Table.Name). Roles always has an entry for every table in the schema Detect ran over.
func Detect ¶
func Detect(s *db.Schema) Classification
Detect computes a Classification as a pure function of s. Table role is determined by NAME PREFIX as the primary signal (fact_/dim_/stg_/mart_, locked decision A5); a prefixed fact_/dim_ table is further corroborated by REAL relational structure — fact_ needs FK fan-out to factFanOutMin+ distinct tables; dim_ needs to be referenced (fan-in) by at least one other table — and demoted to unclassified when that structural evidence is absent. A lone single-column (surrogate) primary key is deliberately NOT, by itself, corroboration: almost every ordinary OLTP table has one, so accepting it alone made the corroboration vacuous (CRITICAL C1, fixed post-review — see ADR 0033 decision 2 and the S1 review ledger). stg_/ mart_ need no structural signal in S1 (design §2a). A table with no recognized prefix is always unclassified, regardless of structure (name-only demotion never promotes: structure corroborates, it never substitutes for the name).
The schema-level Paradigm folds from the resulting role mix: any olap-role table (fact/dimension/staging/mart) coexisting with at least one non-olap-role (unclassified) table yields mixed — checked FIRST, since a schema is not purely analytic just because it contains a star shape somewhere; a schema of ONLY olap-role tables with at least one fact AND one dimension yields olap; otherwise oltp.
func Resolve ¶
func Resolve(detected Classification, override Paradigm) Classification
Resolve applies an explicit developer override on top of detected. An empty or "auto" override returns detected unchanged (detection decides). An explicit oltp/olap/mixed override REPLACES the schema-level Paradigm only — Roles stay detection-derived, so per-table suppression still works under an override that keeps a mixed reality (developer autonomy: explicit config always wins, but it does not erase the structural facts Roles carries).
type Paradigm ¶
type Paradigm string
Paradigm classifies a schema (or an explicit override) as analytic, transactional, or a mix of both. ParadigmAuto is a valid CONFIG value (meaning "let detection decide") but Detect itself never returns it — detection always resolves to one of oltp/olap/mixed.
type Role ¶
type Role string
Role classifies a single table's warehouse role: an ordinary OLTP table, or a table with no fact_/dim_/stg_/mart_ prefix or insufficient structural corroboration, gets the explicit RoleUnclassified value ("unclassified") — NOT the bare Go zero value (""), which Detect never returns. Every entry in a Classification's Roles map is always one of the five named constants below.