> ## 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.

# Ownership, versions and merging

> What happens when a change unit's contribution is applied, and how two writers are reconciled.

A change unit owns the evidence and relations it contributed, not the concepts. Within a unit, ownership is per passage, so re-extracting two changed passages leaves the evidence of the others alone.

## Applying a contribution

Applying a `Contribution` is four steps, in one transaction:

1. **Remove.** Remove the unit's evidence for the passages in `replaces` (all of them when `replaces` is `None`), and the relations that lose all their evidence.
2. **Restamp.** Restamp all of the unit's evidence, kept and new, with the contribution's `access_labels` and `stale_after`. A metadata change therefore reaches evidence whose text did not change.
3. **Merge.** Merge in the new concepts, creating the ones that do not exist.
4. **Check.** Check each concept left with no evidence. If a human verified it, mark it `deprecated` and log it. Otherwise delete it, leaving a redirect if it had been exported.

## When two units disagree

When two units give a concept different text, content from a human actor wins. Otherwise the newest `generated.at` wins, and the vector travels with the winning text.

Merging two concepts keeps the older id. The other becomes a redirect.

Lesson 1 walks through these cases on one concept:

| Case | Result |
| - | - |
| First contribution | `created` |
| A human rewrites the description in a later contribution | `updated`, and the human's text wins. Words are unioned. |
| The passage is replaced and the new extraction no longer supports the concept | `deleted`, unless a human had verified it |
| A human had verified the concept | `deprecated` instead of deleted |
| Two concepts mean the same thing | The older id survives and the other becomes a redirect with status `deprecated` |

## Versions make an update cheap

A unit's `DocVersion` has three hashes: file, metadata and passages. Comparing them with the source's manifest shows what changed, so only that is redone. New metadata re-opens context choices. Changed passages are re-extracted, and unchanged ones keep their pinned choices.

A rebuild gives the same index because ids derive from fixed founding fields and context choices are pinned and replayed.

## Invariants

The promises that ownership and merging keep, such as "removed sources leave no trace" and "a rebuild gives the same result", are listed on the [Invariants](https://ladygraph.io.vn/concepts/invariants.md) page.


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