Heuristic:1ay1 Agentty Single Source Of Truth
| Knowledge Sources | |
|---|---|
| Domains | Architecture, Data_Integrity |
| Last Updated | 2026-10-28 14:00 GMT |
Overview
Each fact lives in exactly one place — one canonical definition, one canonical name, one canonical format — so that every consumer reads from the same source and contradictions are structurally impossible.
Description
The Single_Source_Of_Truth heuristic mandates that every piece of domain knowledge (a model name, a capability key, a user preference, a file path) has exactly one canonical definition in the codebase. All other code that needs that knowledge reads from or normalizes to that single source, never re-deriving or re-encoding it independently. This eliminates an entire class of bugs where two code paths disagree about the same fact because they each maintain their own copy.
In agentty this shows up pervasively: model display names are decoded by one function (`model_name.hpp`), capability keys are normalized by one algorithm (`capkey.hpp`), user settings live in one table (`settings_registry.hpp`), the home directory is resolved by one function (`home_dir.hpp`), and the storage root is defined by one type (`user_root.hpp`).
Usage
Apply this heuristic whenever a piece of data is needed by more than one subsystem. Instead of each subsystem hardcoding or re-deriving the data, define it once and have every consumer reference that single definition. This is especially critical for string identifiers, file paths, configuration keys, and display names.
The Insight (Rule of Thumb)
- Action: Identify each domain fact and give it exactly one canonical definition site.
- Value: One function, one table, or one constant block — never duplicated.
- Trade-off: Slightly more coupling (consumers depend on the canonical source) but eliminates entire classes of drift bugs.
- Compatibility: Works with any architecture; especially powerful in header-only C++ where the canonical site is a single header.
Reasoning
When two code paths independently encode the same fact (e.g., both the UI and the transport layer hardcode a model's display name), they inevitably drift: one path gets updated, the other doesn't, and the user sees inconsistent behavior. By centralizing each fact, drift becomes structurally impossible — there is no second copy to forget to update. The cost is a dependency on the canonical source, but that dependency is the point: it makes the coupling explicit and the contract enforceable.
Related Pages
- Implementation:1ay1_Agentty_Model_Name_Decoder
- Implementation:1ay1_Agentty_Capability_Key_Normalization
- Implementation:1ay1_Agentty_Settings_Registry
- Implementation:1ay1_Agentty_Base64_Codec
- Implementation:1ay1_Agentty_Provider_Picker_Rows
- Implementation:1ay1_Agentty_Slash_Command_Catalog
- Implementation:1ay1_Agentty_Theme_Resolution
- Implementation:1ay1_Agentty_MCP_Import
- Implementation:1ay1_Agentty_User_Storage_Root
- Implementation:1ay1_Agentty_Immutable_Snapshot
- Implementation:1ay1_Agentty_Fuzzy_Matcher
- Implementation:1ay1_Agentty_Bundled_Model_Floor
- Implementation:1ay1_Agentty_Published_Appearance_Prefs
- Implementation:1ay1_Agentty_Home_Directory_Resolution
- Implementation:1ay1_Agentty_Entitlement_Registry