tdfs4ds.agent.feature_groups¶
tdfs4ds.agent.feature_groups
¶
Semantic groups of features, generated once and reused.
The consumer agent lists a large scope (a data domain, an entity) as business groups,
each with a label, one sentence and the technical names. The grouping is proposed by
the instruct model once per feature set, checked against the catalog (no invented
or missing name), and stored in the business dictionary as the section
FEATURE_GROUPS of a reserved object (__SCOPE__<domain>[__<entity>]), keyed by
a hash of the feature set. Every later answer reuses it, so the same question gets
the same answer; a change of the feature set regenerates it.
The section is an internal artefact, not documentation: the vector indexes and the
documentation coverage skip it (SECTION_NAME = FEATURE_GROUPS_SECTION).
feature_set_hash
¶
Order-insensitive hash of a feature set (names upper-cased).
render_text
¶
Stored form: readable, one group per block.
hash=<h> then, per group, ## <label> | <description> and a line of names.
validate
¶
Keep only real names, each in exactly one group, every name somewhere.
Names are matched case-insensitively and returned as the catalog writes them.
A name the model invented is dropped; a name it forgot goes to other_label.
Empty groups disappear. Returns (groups, dropped).
_generate
¶
Ask the model for groups. rows: [(name, description)].
groups_for
¶
Semantic groups of frame's features for a scope, or None.
Reuses the stored grouping when its hash matches the feature set; otherwise asks
llm_json (the agent's _llm_call_json), validates and stores it. None
when nothing is stored and no model can be asked: the caller then groups by
producing process, as before.
document_feature_groups
¶
(Re)generate and store the semantic groups of every data domain.
The consumer agent does this lazily the first time a large domain is listed;
calling it ahead (rebuild_documentation does) makes the first answer as fast
as the next ones. force=True regenerates even when the stored grouping still
matches the feature set. Needs an instruct model. Returns
{domain: number_of_groups or None}; never raises.