> ## Documentation Index
> Fetch the complete documentation index at: https://ladygraph.io.vn/llms.txt
> Use this file to discover all available pages before exploring further.

# Invariants

> The promises the index must always keep, and which part of the core enforces each.

Think of the system as a library. The documents are the books, the chunks are numbered passages cut from them, and the concept index is a smart subject catalogue. The administrator's settings are the librarian's rules. The invariants are promises the catalogue must always keep.

The catalogue is built from the passages alone. The librarian's rules are applied at the moment someone asks a question, and are not baked into the catalogue.

## About the catalogue

1. **Every topic points to real text.** A concept exists only if at least one actual passage supports it. Nothing is made up.
2. **Departments stay separate.** A topic in the HR scope never points to a passage in the Credit scope.
3. **Quotes are exact.** Whatever the index says a passage contains, you can open the source and find those exact words there.
4. **Rebuilding gives the same result.** Build the index twice from the same sources and you get the same index.
5. **Removed sources leave no trace.** When a document is withdrawn or replaced, every concept and link that depended only on it disappears too. No dead links.
6. **Only published material counts.** Drafts never enter the index.
7. **"This document amends that one" comes only from people.** A machine never guesses that link.

## About the rules

8. **Changing the rules does not mean re-cataloguing.** You can edit the rules at any time and the index keeps working.
9. **The librarian's vocabulary wins.** If the glossary says the official name is X, the index uses X, and the listed nicknames lead to it.
10. **The machine does not put words in your mouth.** Synonyms the machine learned are never quietly added to your search. Adding too much extra wording to searches hurt accuracy badly in a past test.
11. **Restrictions stay restrictions.** If the rules say "only search policy documents for this kind of question", the index cannot add results from elsewhere.

## About searching

12. **Turning it off changes nothing.** With the feature switched off, search behaves exactly as it does without it.
13. **It can only add, never take away.** The index can suggest extra passages but never hides ones the old search would have found.
14. **It does not wander.** It follows at most a couple of "see also" links and never goes in circles.
15. **Every result can say why it is there.** Each answer comes from a direct match or from a trail you can show, such as "you asked about X, X is defined in Article 5, here is Article 5".

## What the core enforces

| Core check | Invariant |
| - | - |
| Search serves only concepts with evidence that verifies | 1, 3 |
| Every relation and context stays inside one scope | 2 |
| Concept and context ids are permanent, and context choices are pinned and replayed | 4 |
| A unit owns its evidence and relations only, and a concept goes when its last evidence goes | 5 |
| Only Valid documents are indexed, and evidence carries `stale_after` | 6 |
| The ontology can require a `human:` actor for a relation type such as `AMENDS` | 7 |
| A glossary's document word becomes the title, and human content wins on merge | 9 |
| User words lead only to document words, never into search terms | 10 |
| `hops` is at most 2, `fanout` caps each hop, and no node is visited twice | 14 |
| Every `Hit` has a `path` and an `evidence_id` | 15 |
| No source text is stored: evidence is position and fingerprint only | none |

Invariants 8, 11, 12 and 13 depend on how the calling system uses ladyGraph:

* configuration is applied at query time,
* filters act as hard bounds,
* nothing changes when the feature is disabled,
* results are only added.

Each system's adapter tests these, not the core.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.