tlcconfig.projection¶

Storage projections for configuration values.

A projection is the backing store for a config key’s provenanced writes. The default in-memory projection keeps values in the process; other projections delegate to a process-wide native registry (e.g. the URL-alias registry in Rust) so native code and Python config share one source of truth.

class:

~tlcconfig.store.ConfigStore dispatches every storage operation through the projection bound to an option via Option.projection, so the store carries no per-key branches: adding a native-backed option is a matter of implementing an adapter and tagging the option.

This mirrors the Rust tlc-config::ConfigProjection trait — domains own their projections and implement a uniform interface (notably clear_source for reload teardown) so the configuration layer treats them generically.

Module Contents¶

Classes¶

Class

Description

ConfigProjection

Backing store for the provenanced writes of one or more config keys.

Data¶

API¶

class ConfigProjection¶

Bases: typing.Protocol

Backing store for the provenanced writes of one or more config keys.

A projection records writes tagged by (source, source_info) and exposes them back as :class:~tlcconfig.store.ProvenancedItem lists, from which the store synthesizes its merged / per-tier / provenance views. The store owns those reductions once; a projection only has to store and surface items, so every projection — in-memory or native-backed — shares the same precedence logic.

Implementations are responsible for their own thread-safety.

clear_source(
source: ConfigSource,
source_info: str | None,
) None¶

Drop every entry contributed by (source, source_info) — the reload teardown.

items(
key: str,
) list[ProvenancedItem]¶

Return the per-item view the store’s read reductions consume.

remove_item(
key: str,
sub_key_or_value: Any,
source: ConfigSource,
source_info: str | None,
) bool¶

Remove a single sub-element at the given tier; return whether one was removed.

set_raw(
key: str,
value: Any,
source: ConfigSource,
source_info: str | None,
) None¶

Additively record a write, splitting compounds into per-item entries.

set_value(
key: str,
value: Any,
source: ConfigSource,
source_info: str | None,
) None¶

Replace the entire (source, source_info) slice with value.

to_serialized(
key: str,
value: Any,
) Any¶

Map a merged value to its on-disk YAML shape (identity unless the domain differs).

MEMORY_PROJECTION = memory¶
NATIVE_ALIAS_PROJECTION = native-aliases¶