# Read and edit Memory

Open **History → Memory** and select a topic. Documents and Core source records open in Preview; **Edit** changes the Markdown. There are no save controls.

| Aspect | Behaviour |
| --- | --- |
| Saving | Each edit goes to this browser's draft storage and is queued for file persistence. Writes are serialized, so an earlier response cannot overwrite newer typing. |
| Undo | Cmd+Z or Ctrl+Z. Redo: Cmd+Shift+Z, Ctrl+Shift+Z or Ctrl+Y. Autosave keeps undo history while the app stays open. |
| Conflict or rejection | The draft stays and the error shows. **Review latest** compares saved text with the draft in History; **Replace latest with this draft** retries against that version. A further concurrent change is still rejected. |

## History

| Change | Git commit |
| --- | --- |
| Manual edits | Five-minute checkpoints by the server, tolerance 15 seconds. The deadline survives restart and needs no open editor. The state before the interval is retained. |
| Background write | Its own, named for the conversation |
| Reorganizing a write triggers | Its own |
| Nightly reorganization | One per file it splits and per folder it regroups: a company, person or project with several notes gets a folder of its own, and `openprogram memory regroup` does this on demand |
| `memory_update` by the agent | Its own, named for the conversation |
| Edits outside OpenProgram | Committed alone just before the next write, so restoring a write never takes them along |

A write that fails its checks changes neither files nor history.

**History** lists revisions newest first with local time; selecting one shows added and removed lines. **Restore this version** records the current state, then the restoration as a new commit, so it can be reversed. It keeps valid source references and refuses to break links from other Memory documents.

## When automatic writing stops

| Problem | Automatic repair |
| --- | --- |
| Writer model unusable (rejected sign-in, plan without access, unknown model, exhausted plan) | Switches to the default agent's model, then the last used model |
| Edits fail format checks | Sent back to fix in place up to three times, then redoes the turn once |
| Topic files written by you or another tool | Remembered as written: search finds them and recall can bring them in, marked "added by person" or "outside file" instead of a source. Memory never rewrites a file another tool wrote; a file that is not text is named once on the Memory page and the rest of memory goes on |
| Citing a message by hand | End the paragraph with a footnote whose source is `[keyword](/s/<conversation>#<message>)`: the conversation ID ends the link **Copy link** copies (keep only the `/s/…` part), the message ID is what **Copy ID** copies for its node in the context graph. A conversation with memory off cannot be cited. |

**When a memory write fails**

| Case | Result |
| --- | --- |
| Last run still failed | Red strip at the top of Memory: why, last write, turns waiting |
| Retried on its own | Strip only. An outage or usage limit waits from 5 minutes up to 6 hours and is never given up on. A failure in the conversation is tried three times, an hour apart, then waits for the conversation to change. A sign-in failure, or a memory the writer cannot start from, stops writing once until the sign-in, the configuration or that memory changes |
| Nothing will retry | Strip plus one notice, repeated only if the reason changes |
| Unwritten turns | Retried |
| Nothing worth keeping | Counts as written |

## Format checks

Every Topic paragraph ends in a footnote citing its chat message: `[keyword](/s/<session>#<message>)`. Memory keeps no copy of the conversation.

| Footnote | Result |
| --- | --- |
| Missing on a substantive paragraph | `INVALID_TOPIC_FORMAT` before any write; a rejected batch commits nothing |
| New citation of a message the chat does not hold, or one not a person's or the assistant's words, such as a tool result | Same |
| Definition written twice, or left behind by a moved or deleted paragraph | Removed, not rejected |

The background writer runs these checks after every file it changes and fixes breaks before its turn ends.

Clicking a footnote shows the message with the turns around it, and **Open original session** jumps there. If the session was deleted the view says **Original session deleted** and the memory remains. Archiving hides a session, keeps content and links, and never deletes it by age or capacity.

**Workspaces with a sources folder**

On first use, an older workspace's `sources/` footnotes are rewritten to chat links and the folder is removed, in one commit, `memory: cite chats directly`. Git history keeps the old copy.

Agent-specific memory modes and spaces: [Agents](https://fzkuji.github.io/OpenProgram/docs/capabilities/agents.html)
