Skip to content

Configuration

No configuration file is required; every default below is the documented behaviour. sg.Config is a tree of frozen dataclasses. Build it in code, from a mapping, from YAML, or from environment variables — all four give the same object.

import schemaguru as sg

cfg = sg.Config(
    budget=sg.Budget(max_bytes_total=5 << 30),
    sampling=sg.SamplingConfig(llm_values="masked", per_glob={"shop.customers": "none"}),
    graph=sg.GraphConfig(attribution_fanin=20.0),
    measure_on_demand="queue",
)
same = sg.Config.from_mapping({
    "budget": {"max_bytes_total": 5 << 30},
    "sampling": {"llm_values": "masked", "per_glob": {"shop.customers": "none"}},
    "graph": {"attribution_fanin": 20.0},
})
print(cfg == same)

env = sg.Config.from_env(environ={
    "SCHEMAGURU_BUDGET__MAX_BYTES_TOTAL": "5368709120",
    "SCHEMAGURU_GRAPH__ATTRIBUTION_FANIN": "20",
    "SCHEMAGURU_MEASURE_ON_DEMAND": "background",
})
print(env.budget.max_bytes_total, env.graph.attribution_fanin, env.measure_on_demand)

guru = sg.Guru.connect("duckdb:///warehouse.duckdb", config=cfg)
guru.config = sg.Config(agent_checks="allow")    # switch at runtime (stops/restarts the drainer)
guru.close()
  • PREFIX_FIELD sets a top-level field, PREFIX_SECTION__FIELD a nested one; values are parsed as YAML scalars. Tuple fields take a list or comma-separated text.
  • Config.from_yaml("schemaguru.config.yaml") reads the same keys; schemaguru init writes a commented one. The CLI reads --config, else the environment.
  • An unknown key or a value of the wrong type raises ConfigError naming the key.

Every key

Config

Key Type Default
enum_max_distinct int 20
fact_ttl_days int 14
measure_on_demand Literal['queue', 'background', 'block'] 'queue'
block_timeout_s float 10.0
store_path str | None None
llm_model str 'claude-sonnet-5-5'
token_counter Literal['chars', 'tiktoken'] 'chars'
agent_checks Literal['allow', 'deny'] 'deny'

Budget

Key Type Default
budget.max_bytes_per_probe int | None 1 GiB
budget.max_bytes_total int | None 10 GiB
budget.max_probes int | None None
budget.max_seconds float | None None
budget.crawl_bytes int | None None
budget.draft_budget_tokens int | None None
budget.period_s float | None 86400.0

SamplingConfig

Key Type Default
sampling.llm_values Literal['masked', 'raw', 'none'] 'masked'
sampling.per_glob Mapping[str, str] {}
sampling.sample_values_per_column int 5
sampling.store_raw_samples bool False
sampling.measurement Literal['auto', 'off', 'force'] 'auto'
sampling.sample_threshold_bytes int 50 GiB
sampling.sample_threshold_rows int 500_000_000
sampling.exact_key_limit int 5_000_000
sampling.block_fraction_floor float 0.001
sampling.block_fraction_ceiling float 0.1
sampling.design_effect float 2.0

GraphConfig

Key Type Default
graph.w_support float 1.0
graph.w_fanout float 0.35
graph.w_hub float 0.25
graph.unmeasured_penalty float 1.0
graph.hop_limit int 6
graph.thin_support float 0.05
graph.attribution_fanin float 10.0
graph.k_paths int 3
graph.include_unmeasured bool False
graph.ok_threshold float 0.95
graph.weak_threshold float 0.05

ScopeConfig

Key Type Default
scope.seed_k int 8
scope.max_expansion_tables int 6
scope.max_values_shown int 6
scope.cache_entries int 256

CrawlConfig

Key Type Default
crawl.page_size int 1000
crawl.column_batch int 200
crawl.workers int 4
crawl.timeout_s float 60.0
crawl.include tuple[str, ...] ()
crawl.exclude tuple[str, ...] ('information_schema.*', 'pg_catalog.*', 'sys.*', '*.*_staging*', '*.*tmp*')

The settings that change behaviour most

Setting Effect
measure_on_demand queue (default): questions never spend; background: a daemon thread drains the queue under the budget; block: measure scoped tables before answering, at most block_timeout_s
agent_checks deny (default): no check_fact tool; allow: agents may run FactLang claims, each admitted through the budget
sampling.llm_values masked (default), raw (opt-in), none — see PII
sampling.measurement auto (sample only large tables), off, force — see Sampling
graph.attribution_fanin the hub-guard threshold; calibrate it (Join graph)
graph.include_unmeasured let unmeasured candidate joins into path search, at a penalty
budget.* per-probe, per-run and per-period spending caps — see Cost and scale
crawl.include / crawl.exclude what is indexed at all