Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:1ay1 Agentty Single Source Of Truth

From Leeroopedia
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

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment