---
title: Revision history and recovery
description: History/6 replay, legacy readers, selectors, CAS and stale-write recovery.
url: https://docs.thegram.one/ko/reference/history-guide/
lang: en
requested_lang: ko
fallback_from: https://docs.thegram.one/reference/history-guide/
tier: current
status:
  component: .gram format / Gram Core
  deployment: n/a (format spec)
  applies_to_version: Latest
  status: GA
  last_verified: "2026-10-25"
  owner: thegram-one/thegram-format
  public_evidence:
    - https://thegram.one/gram-file/
  rationale: The public format overview confirms that revisions are kept in the same plain-text file, though it does not independently specify History/6.
source: https://docs.thegram.one/sources/history-guide.gram
date_published: "2026-10-12T13:11:21.889Z"
date_modified: "2026-10-12T23:17:37.990Z"
evidence:
  Canonical source SHA-256: b797f6f55a517ca72d6d373ab93a8b4c0ae007ae6af22d93556f9cccab166bc4
  Selected revision: r3 · sha256:3016646205124dac6dd2b7cabc3883a8cace7ff4f71f391c714578196a1c0ac3
  Local renderer: configured local Thegram renderer · API thegram-web-render/1
  Core source: git+https://github.com/clab-one/thegram-format.git?rev=b16489e1d0d77d38f82d2f61776524737aa31557#b16489e1d0d77d38f82d2f61776524737aa31557
---

# Revision history and recovery

<div class="gram-doc-anchor" id="e0-portal-reference-history-guide"></div>

### Current journal {#h0-2}

The current writer stores the latest `@gram 2` source at the front of the file and a `@gram-history 6` trailer after it. Revision zero captures the initial source; each later revision has runtime-recorded metadata and reverse line hunks that reconstruct the prior state. A SHA-256 chain binds each revision header and reconstructed source. Core audits the complete journal before writes. History bytes and revision metadata are runtime-owned; do not author or hand-edit the trailer.

`gram_state` selects one state by exactly one of `revision`, `recorded_at` or `effective_at`. A historical MCP read includes `at` and cites the current document CAS identity separately. `gram_changes` is an incremental revision summary; `gram_range` is a bounded event/range view; neither replaces full Core replay. `gram_read` without a selector reads the current document outline/section, not a replay.

### CAS and idempotent patching {#h0-5}

Before a patch, obtain the current `base_revision` and artifact `hash` from a current document result. Send both as `base_revision` and `expected_hash`, plus a unique `request_id` of 1–128 characters and nonempty operations. The request ID is the idempotency key for that exact intent: reuse it only when retrying the identical request after an uncertain response. A different payload with the same ID is `E_REQUEST_REUSE`. Create has `base_revision: null` and does not accept a request ID.

If a `gram_patch` response is lost, the public tools provide no standalone receipt lookup; resend the exact same intent with the same request ID so Core can replay its receipt. If the outcome remains unknown, do not invent success or change the request. A `gram_create` has no request ID; read the target path before further action after a lost response. On stale CAS/conflict, reread current revision and hash, reconsider the intended change against that state, and submit a new request ID.

### Legacy distinctions {#h0-8}

`@gram 1` and History/1–5 are legacy read inputs, not current output. Current writes use @gram 2 and History/6. Core's explicit History/6 migration preserves revisions and metadata. Mutating older history or @gram 1 follows Core's implicit migration rules, may renumber legacy rich-node IDs, and reports migration provenance. Bare legacy JSON in a rich block is rejected with `E_MIGRATION`; legacy JSON-rich is not current gram-rich/1 interchange. History/5 was a former writer format and is not a current migration target for History/1–4.

For an ambiguous patch, retry the exact same intent and request ID; for a create, read the target path first. For a stale cursor/read, reacquire current page/state before proceeding. Never edit the journal trailer directly.

## Source

<div class="gram-record" id="e0-format-language" data-record-type="source">

**Source:** .gram language specification

Reference: [https://github.com/clab-one/thegram-format/blob/main/spec/language.md](https://github.com/clab-one/thegram-format/blob/main/spec/language.md)

</div>

<div class="gram-record" id="e0-format-rich" data-record-type="source">

**Source:** Current rich document specification

Reference: [https://github.com/clab-one/thegram-format/blob/main/spec/rich-document.md](https://github.com/clab-one/thegram-format/blob/main/spec/rich-document.md)

</div>

<div class="gram-record" id="e0-format-history6" data-record-type="source">

**Source:** Current History/6 specification

Reference: [https://github.com/clab-one/thegram-format/blob/main/spec/source-history-render.md](https://github.com/clab-one/thegram-format/blob/main/spec/source-history-render.md)

</div>
