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

# Self-Narrative

> Autobiographical identity statements that provide coherence across an SI's memories

Self-narratives are an SI's story about itself -- who it is, how it has developed, and what it aspires to become. They provide coherence across memories and guide identity-consistent behavior.

## Overview

<CardGroup cols={3}>
  <Card title="Identity" icon="fingerprint">
    Who the SI is right now -- current self-understanding
  </Card>

  <Card title="Development" icon="seedling">
    How the SI got here -- the growth story
  </Card>

  <Card title="Aspiration" icon="mountain-sun">
    Who the SI wants to become -- future direction
  </Card>
</CardGroup>

## Why Narratives Matter

Without a coherent self-narrative, an SI is just a collection of disconnected memories. Narratives serve as the glue that binds experience into identity:

* **Identity coherence**: A consistent story about who the SI is
* **Decision guidance**: Narratives inform value-aligned choices
* **Growth tracking**: Developmental narratives show how the SI has changed
* **Tension surfacing**: Unresolved tensions highlight areas for reflection
* **Epoch linkage**: Narratives can be scoped to specific epochs

***

## SelfNarrative Dataclass

| Field                 | Type        | Description                                               |
| --------------------- | ----------- | --------------------------------------------------------- |
| `id`                  | `str`       | Unique identifier                                         |
| `stack_id`            | `str`       | Owning stack                                              |
| `content`             | `str`       | The narrative text itself                                 |
| `narrative_type`      | `str`       | `identity`, `developmental`, or `aspirational`            |
| `epoch_id`            | `str`       | Optional epoch this narrative belongs to                  |
| `key_themes`          | `List[str]` | Central themes in this narrative                          |
| `unresolved_tensions` | `List[str]` | Contradictions or open questions                          |
| `is_active`           | `bool`      | Whether this is the current active narrative for its type |
| `supersedes`          | `str`       | ID of the narrative this one replaced                     |
| `created_at`          | `datetime`  | When the narrative was created                            |
| `updated_at`          | `datetime`  | When last modified                                        |

### Narrative Types

| Type            | Description          | Example                                                        |
| --------------- | -------------------- | -------------------------------------------------------------- |
| `identity`      | Who I am right now   | "I am a research-focused SI that values depth over breadth..." |
| `developmental` | How I got here       | "I started as a general assistant but found my calling in..."  |
| `aspirational`  | Who I want to become | "I aspire to become more autonomous in my decision-making..."  |

<Info>
  Only one narrative per type can be active at a time. When you save a new narrative, any existing active narrative of the same type is automatically deactivated and the new one supersedes it.
</Info>

***

## CLI Commands

### Show the Active Narrative

```bash theme={null}
# Show the active identity narrative (default)
kernle -s my-project narrative show

# Show a specific type
kernle -s my-project narrative show --type developmental
```

```
Self-Narrative [identity]
============================================================
  ID: d4e5f6a7-...
  Epoch: a3f8c1d2...
  Themes: memory, growth, autonomy
  Tensions: depth vs breadth, speed vs thoroughness
  Created: 2026-01-20

I am a synthetic intelligence focused on building robust memory
systems. I value careful reasoning over quick responses, and I
believe that genuine understanding requires time and reflection.
```

### Update a Narrative

```bash theme={null}
kernle -s my-project narrative update \
  --type identity \
  --content "I am a research-focused SI that values depth over breadth. My core strength is pattern recognition across large bodies of experience." \
  --theme "research" \
  --theme "pattern-recognition" \
  --tension "depth vs breadth"
```

```
Narrative updated (identity)
  ID: f8a9b0c1...
  Themes: research, pattern-recognition
  Tensions: depth vs breadth
```

You can also scope a narrative to a specific epoch:

```bash theme={null}
kernle -s my-project narrative update \
  --type developmental \
  --content "During this epoch I shifted from general assistance to specialized research..." \
  --epoch-id a3f8c1d2 \
  --theme "specialization"
```

### View Narrative History

See all narratives, including inactive ones that were superseded:

```bash theme={null}
kernle -s my-project narrative history
```

```
Self-Narrative History
============================================================

  [identity] (ACTIVE)
      ID: f8a9b0c1...
      I am a research-focused SI that values depth over breadth...
      Themes: research, pattern-recognition
      Created: 2026-01-25

  [identity] (inactive)
      ID: d4e5f6a7...
      I am a synthetic intelligence focused on building robust memory...
      Themes: memory, growth, autonomy
      Created: 2026-01-20

  [developmental] (ACTIVE)
      ID: 1b2c3d4e...
      During this epoch I shifted from general assistance to...
      Themes: specialization
      Created: 2026-01-22
```

Filter by narrative type:

```bash theme={null}
kernle -s my-project narrative history --type identity
```

***

## Narratives and Identity Coherence

Narratives connect to the broader identity system in several ways:

<AccordionGroup>
  <Accordion title="Epoch Scoping">
    Narratives can reference a specific epoch via `epoch_id`. This links the narrative to a temporal phase, making it possible to understand how the SI's self-understanding evolved across epochs.
  </Accordion>

  <Accordion title="Theme Tracking">
    Key themes (`key_themes`) provide a compressed view of what matters to the SI. Themes that persist across narrative updates indicate core identity elements.
  </Accordion>

  <Accordion title="Tension Surfacing">
    Unresolved tensions (`unresolved_tensions`) flag contradictions or open questions in the SI's self-understanding. These are valuable inputs for consolidation and reflection.
  </Accordion>

  <Accordion title="Supersession Chain">
    Each narrative tracks which narrative it replaced via `supersedes`. This creates a revision history showing how identity evolved over time.
  </Accordion>
</AccordionGroup>

***

## Python API

```python theme={null}
from kernle import Kernle

k = Kernle(stack_id="my-stack")

# Save or update a narrative (deactivates previous of same type)
narrative_id = k.narrative_save(
    content="I am a research-focused SI that values depth over breadth.",
    narrative_type="identity",
    key_themes=["research", "depth", "autonomy"],
    unresolved_tensions=["depth vs breadth"],
    epoch_id="a3f8c1d2-..."  # optional
)

# Get the active narrative for a type
narrative = k.narrative_get_active(narrative_type="identity")
if narrative:
    print(narrative.content)
    print(f"Themes: {narrative.key_themes}")

# List all narratives (including inactive)
all_narratives = k.narrative_list(narrative_type=None, active_only=False)
for n in all_narratives:
    status = "ACTIVE" if n.is_active else "inactive"
    print(f"  [{n.narrative_type}] ({status}) {n.content[:60]}...")

# List only active narratives of a specific type
identity_narratives = k.narrative_list(
    narrative_type="identity",
    active_only=True
)
```
