Skip to content

Case Study: A Midsummer Night's Dream

This page walks through a full Marvin loop on a literary workload: an agent reads chunks of Shakespeare's A Midsummer Night's Dream, decides what to store, runs the offline sleep pass, and merges a memory worktree back to main. The same patterns apply to codebases and chat agents.

The experiment

We simulated a dense session where the agent:

  1. Processed large spans of raw play text.
  2. Logged episodic summaries of the opening act on its own.
  3. Stored a user preference and a procedural analysis strategy when asked.
  4. Ran computational sleep afterward to distill permanent facts — no human editing of the vault.

Step 1: Worktree and episodic logging

Because the task was exploratory, the agent branched memory first:

marvin worktree start session-reading

While answering questions it logged episodic notes. After the session, the sleep pass's entity-extraction stage (langextract when [consolidate] is installed, regex fallback otherwise) rewrote notes with Obsidian [[wikilinks]] that feed the graph retrieval stream:

# Analyzed Act 1 Marriage Laws

## Summary
Answered question about Hermia's suitors and Athenian law.

## Details
Read Act 1. Found that:
[[Hermia]]’s two suitors are [[Lysander]] and [[Demetrius]].

- [[Lysander]] loves [[Hermia]], and [[Hermia]] loves him.
- [[Demetrius]] also seeks to marry [[Hermia]], and [[Egeus]], her father, wants her to marry [[Demetrius]].

The Athenian law, as explained by [[Theseus]], is that [[Hermia]] must obey her father’s choice. If she refuses to marry [[Demetrius]], she faces either:

1. **Death**, according to the law of [[Athens]], or  
2. **A life of chastity in a nunnery** (“on [[Diana]]’s altar”).

So, [[Hermia]] is legally expected to marry the man her father chooses, not necessarily the one she loves.

## Related
- [[Lysander]]
- [[Demetrius]]
- [[Egeus]]
- [[Theseus]]
- [[Hermia]]
- [[Athens]]
- [[Diana]]

The K-Lines Philosophy: Implicit vs. Explicit Entities

Marvin does not automatically create a Markdown file for every entity, such as Theseus.md. In the K-Lines model, an entity is defined by its connections to memories rather than by a placeholder file. Searching for Theseus retrieves the linked episodic and semantic notes through the vault indexes; the entity is a structural node in the graph. If an agent needs a definition, it can store one explicitly with marvin_remember_semantic("Theseus", "Duke of Athens").

Step 2: Extracting rules and preferences

During the session, the agent also fulfilled direct requests by storing a user preference as semantic memory:

# User Preferences

## Facts
- The user's favorite character in [[A Midsummer Night's Dream]] is [[Nick Bottom]].

## Related
- [[Nick Bottom]]
- [[A Midsummer Night's Dream]]

It stored the requested analysis strategy as procedural memory:

# Play Analysis Strategy

## Procedure
1. Identify the [[ruler]] or [[authority figure]] in the [[scene]].
2. Identify who is petitioning the [[authority]].
3. Map out the [[power dynamics]] before analyzing [[character emotions]].

## Related
- [[authority figure]]
- [[ruler]]
- [[power dynamics]]
- [[scene]]
- [[character emotions]]
- [[authority]]

Step 3: Computational sleep

After the session, sleep ran on demand with marvin consolidate or marvin_trigger_sleep. The local LLM read the noisy episodic logs and wrote a compact semantic fact — still plain Markdown in the vault:

# Athenian law in Act 1

## Facts
- [[Theseus]] explains that [[Hermia]] must obey her father's choice of husband or face death or a life of chastity in a nunnery.

## Related
- [[Theseus]]
- [[Hermia]]

Step 4: Git-backed worktree merge

After the session succeeded, Marvin merged the session-reading branch back into main with --no-ff. The vault history records each saved note and the merge:

*   31b3c92 Merge worktree session-reading
|\  
| * 190787f auto-save: Athenian law in Act 1
| * 9437517 chore(graph): auto-linked entities in A Midsummer Night's Dream Act 1
| * cecd4bb auto-save: A Midsummer Night's Dream Act 1
| * 7d743bd chore(graph): auto-linked entities in The Harshness of Athenian Law
| * 800b102 auto-save: The Harshness of Athenian Law
| * d3031ce chore(graph): auto-linked entities in Play Analysis Strategy
| * cc996ee auto-save: Play Analysis Strategy
| * 01d4d3f chore(graph): auto-linked entities in User Preferences
| * 2059598 auto-save: User Preferences
| * 3845d87 chore(graph): auto-linked entities in Analyzed Act 1 Marriage Laws
| * 7accc13 auto-save: Analyzed Act 1 Marriage Laws
|/  
* ed26814 chore: init vault

The result

The agent read a text, answered questions, learned a preference, acquired a rule, and built Git-tracked, Obsidian-native memory. The next search for Hermia surfaces narrative facts and prior insights through hybrid RRF.

Generated Obsidian Graph

graph TD;
  Demetrius["Demetrius"]
  Theseus["Theseus"]
  Athens["Athens"]
  Egeus["Egeus"]
  EgeusasksTheseustoenforceHermiasmarriage["Egeus asks Theseus to enforce Hermia's marriage"]
  Lysanderswidowedaunt["Lysander's widowed aunt"]
  Athenianlaw["Athenian law"]
  EgeusasksTheseustoenforceHermiasmarriagetoDemetrius["Egeus asks Theseus to enforce Hermia's marriage to Demetrius"]
  thewoods["the woods"]
  TheseusgivesHermiaanultimatum["Theseus gives Hermia an ultimatum"]
  DukeofAthens["Duke of Athens"]
  LysanderandHermiaplantofleeAthens["Lysander and Hermia plan to flee Athens"]
  Hermia["Hermia"]
  woods["woods"]
  Lysandersaunt["Lysander's aunt"]
  Lysander["Lysander"]
  DukeTheseus["Duke Theseus"]
  Theseus --> DukeofAthens
  Theseus --> Athens
  TheseusgivesHermiaanultimatum --> Theseus
  TheseusgivesHermiaanultimatum --> Hermia
  TheseusgivesHermiaanultimatum --> Demetrius
  Lysander --> Hermia
  Lysander --> Egeus
  EgeusasksTheseustoenforceHermiasmarriage --> Egeus
  EgeusasksTheseustoenforceHermiasmarriage --> Theseus
  EgeusasksTheseustoenforceHermiasmarriage --> Hermia
  EgeusasksTheseustoenforceHermiasmarriage --> Athenianlaw
  EgeusasksTheseustoenforceHermiasmarriage --> Demetrius
  LysanderandHermiaplantofleeAthens --> Lysander
  LysanderandHermiaplantofleeAthens --> Hermia
  LysanderandHermiaplantofleeAthens --> Athens
  LysanderandHermiaplantofleeAthens --> Athenianlaw
  LysanderandHermiaplantofleeAthens --> thewoods
  LysanderandHermiaplantofleeAthens --> Lysanderswidowedaunt
  Lysandersaunt --> Lysander
  Lysandersaunt --> Athens
  Lysandersaunt --> Hermia
  Lysandersaunt --> Athenianlaw
  Egeus --> Hermia
  Egeus --> Demetrius
  Egeus --> Lysander
  Hermia --> Lysander
  Hermia --> Demetrius
  TheseusgivesHermiaanultimatum --> Egeus
  TheseusgivesHermiaanultimatum --> Athens
  EgeusasksTheseustoenforceHermiasmarriagetoDemetrius --> Egeus
  EgeusasksTheseustoenforceHermiasmarriagetoDemetrius --> Theseus
  EgeusasksTheseustoenforceHermiasmarriagetoDemetrius --> Hermia
  EgeusasksTheseustoenforceHermiasmarriagetoDemetrius --> Demetrius
  EgeusasksTheseustoenforceHermiasmarriagetoDemetrius --> Lysander
  EgeusasksTheseustoenforceHermiasmarriagetoDemetrius --> DukeTheseus
  LysanderandHermiaplantofleeAthens --> woods
  LysanderandHermiaplantofleeAthens --> Lysandersaunt