---
title: "Manifests"
description: "Create, write and read the manifests that record each source's segments."
canonical_url: "https://diglot.sh/store/manifests"
---
# Manifests

> Create, write and read the manifests that record each source's segments.

A manifest lists the segments of every file of one source at one revision. Comparing a fresh extraction with the stored manifest is how diglot finds [what changed](https://diglot.sh/guide/concepts/keeping-in-sync).

## Shape

```json
{
  "version": 1,
  "source": "nuxt-main",
  "ref": "main",
  "sha": "<commit>",
  "policy": "<fingerprint>",
  "files": {
    "docs/guide/intro.md": [
      { "hash": "...", "kind": "paragraph", "format": "markdown", "words": 9, "skeleton": "..." }
    ]
  }
}
```

Each entry has the `hash`, `kind`, `format`, `words` and `skeleton` of a segment, plus `placeholders` (their types by id) and `salt` when there are any. The ids and types are enough to validate a translation without parsing the document again, which is what `validationTarget(entry)` returns for `validate`.

## Functions

<table>
<thead>
  <tr>
    <th>
      Function
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        createManifest(source, files, { ref?, sha?, policy? })
      </code>
    </td>
    
    <td>
      Builds a manifest from extracted segments, with files sorted by path
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        manifestPath(stateDir, source)
      </code>
    </td>
    
    <td>
      The path <code>
        <stateDir>/manifest/<source>.json
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        serialiseManifest(manifest)
      </code>
    </td>
    
    <td>
      Text with one entry per line, so diffs show changed segments
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        writeManifest(stateDir, manifest)
      </code>
    </td>
    
    <td>
      Writes the manifest and returns its path
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        readManifest(stateDir, source)
      </code>
    </td>
    
    <td>
      One manifest, or <code>
        undefined
      </code>
      
       if there is none. An unsupported version throws
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        readManifests(stateDir)
      </code>
    </td>
    
    <td>
      Every manifest in the state directory, sorted by file name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        liveHashes(manifests)
      </code>
    </td>
    
    <td>
      The set of hashes used by any file of the given manifests
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        validationTarget(entry)
      </code>
    </td>
    
    <td>
      What <code>
        validate
      </code>
      
       needs to check a translation of an entry
    </td>
  </tr>
</tbody>
</table>

`policy` is the `policyFingerprint` of the policy the segments were extracted under. `diglot extract` and the Action set it and write the policy itself to `.diglot/policy.json` with `writePolicy(stateDir, policy)`, which `readPolicy(stateDir)` reads back. Together they let a server check that it extracts with the same policy as the manifests. See [snapshots](https://diglot.sh/core/policy-and-config#snapshots).

`createManifest`, `serialiseManifest`, `validationTarget` and `liveHashes` are also exported from `@diglot/store/runtime`.

A hash is *live* when some manifest uses it. Records whose hash isn't live are unused: they stay in git, and bundles leave them out by default.


## Sitemap

See the full [sitemap](https://diglot.sh/sitemap.md) for all pages.
