Skip to main content

Module heuristics

Module heuristics 

Source
Expand description

Turn a neutral DumpProfile into an explicit, self-contained SyntheticModel through a set of small, registered heuristics.

Each heuristic (see the submodules) receives the schema + evidence for one column and proposes zero or more Candidate rules, each tagged with a Precedence, a Confidence, a stable reason code, and — for the rare rule that embeds literal source values — the literals it would persist. Heuristics never mutate a model and never generate a value; they only propose.

The resolver applies a strict precedence order and records both the winner and every rejected alternative (without their values) so --explain can show why a rule won. The precedence order, highest first, is:

  1. explicit YAML (reserved for the overrides merge; never proposed here)
  2. schema constraint (identity / declared default)
  3. credential guard (password/token/secret columns are synthetic-only)
  4. relationship / planner (declared foreign keys)
  5. strong semantic name+shape (email, person, money, …)
  6. observed distribution (categorical, constant, histogram, sample)
  7. type fallback (a plain generator for the column’s family)

The emitted model is self-contained (audit amendment D3): observed row counts are frozen to an integer count while keeping kind: observed, defaults.inference is disabled, raw samples are never retained, and any literal an explicit rule genuinely requires stays in that rule and raises a source-derived warning — there is no “safe to store” mode.

Structs§

Candidate
A single proposed rule for one column: a typed generator plus the metadata the resolver needs to rank it and explain the outcome.
Decision
Why one column ended up with the rule it did, plus the alternatives that lost. Values are never recorded here.
InferenceOptions
Knobs controlling how a profile is turned into a model.
InferenceResult
The output of ModelInference::infer: an explicit, self-contained model, the per-column decisions, and any warnings raised while inferring.
ModelInference
Infers explicit generation rules from a dump profile through the registered heuristics. Build one with ModelInference::standard (the built-in registry + default options) or ModelInference::new.
RejectedCandidate
One rejected alternative recorded for --explain. Deliberately carries no values — only the shape of the losing proposal.

Enums§

Confidence
How sure a heuristic is about a candidate, used to order candidates that share a Precedence and to label the decision for --explain.
InferenceError
Errors from ModelInference::infer.
Precedence
Strict precedence class of a proposed rule. Higher classes always beat lower ones regardless of confidence; see the module docs for the full order.

Functions§

is_credential_name
Whether a column name denotes credential material (any confidence). The profiler consults this — together with the column being string-shaped — to keep raw values of credential columns out of its sketches entirely, so secret material (hashes, tokens, keys) never enters profiling evidence.
schema_inferred_generator
Infer one column’s generator from its schema alone — declared name and type, with no value evidence — reusing the same schema, credential, and semantic heuristics (and their precedence) the profiler applies at schema depth. The distribution heuristics need value evidence and contribute nothing here. A generator is always returned: the type fallback is the guaranteed floor, so a caller relying on this never leaves a column unowned.