---
title: "Storage, Hashing & VCS Oracle Specification"
source: "https://edawise.com/docs/cli/storage-and-format/"
---

# Storage, Hashing & VCS Oracle Specification

`deccy` stores the entire decision graph as plain files inside `.deccy/`. There is no database, daemon, index cache, or hidden state outside that directory.

---

## 1. Directory Layout

```text
.deccy/
├── format                          # Always "deccy-cli-exp 1\n"
├── nodes/
│   └── <id>.json                   # One pretty-printed JSON record per node
└── rationale/
    └── <id>.md                     # Rationale bytes pointed to by a record
```

- **`.deccy/format`:** Contains the single line `deccy-cli-exp 1\n`.
- **`.deccy/nodes/<id>.json`:** The node's record. The filename stem must match the record's `"id"` field.
- **`.deccy/rationale/...`:** Prose files referenced by a record's `"rationale"` field. By default `deccy` names these `rationale/<id>.md`, but any normalized relative path inside `rationale/` (with any extension or none) is valid.
- **No symlinks:** `deccy` inspects every path component with `symlink_metadata` and refuses symlinks inside `.deccy/` as well as symlinked claim paths.

---

## 2. Record Schema & Pretty Format

### Decision Record

A decision has exactly six fields in alphabetical order (`claims`, `id`, `kind`, `rationale`, `title`, `type`):

```json
{
  "claims": {
    "src/store.rs": "9c1f2a40e8d1c2b3a4f5061728394a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f"
  },
  "id": "ktvsvszpzoxlzrsoqpvsuztsstmyvqvp",
  "kind": "decision",
  "rationale": "rationale/ktvsvszpzoxlzrsoqpvsuztsstmyvqvp.md",
  "title": "Put the store's objects in plain files",
  "type": "text"
}
```

### Connector Record

A connector has the same six fields plus `head` and `tail`:

```json
{
  "claims": {},
  "head": [
    {"at": "1f3c89a0...", "id": "qonutznvlyssluxyzysswxltlztxlwro"}
  ],
  "id": "srmtuwvwxxyyzzkkllmmnnooppqqrrss",
  "kind": "connector",
  "rationale": null,
  "tail": [
    {"at": "8e04b712...", "id": "pouvsykppxynykyovrslllkzyvvkzqmp"}
  ],
  "title": "Every decision has a rationale",
  "type": "review-criteria"
}
```

### Field Rules

- **Strict field set:** Unknown fields, duplicate JSON keys, floating-point numbers, or missing fields are refused.
- **`claims`:** `{ "<path>": "<64-char lowercase hex>", ... }`, sorted bytewise by path. `{}` when empty.
- **`id`:** 32 characters from the reverse-hex alphabet `zyxwvutsrqponmlk` (`0 → z`, `15 → k`).
- **`kind`:** Either `"decision"` or `"connector"`.
- **`rationale`:** Either `null` or a normalized relative path string starting with `"rationale/"`.
- **`title` and `type`:** Non-empty single-line strings (no `\n`, `\r`, or control characters).
- **`head` and `tail`:** Present only on connectors. Arrays of `{"at": "<64-hex>", "id": "<32-char-id>"}` objects, deduplicated and sorted by `id`. (A hand-written `"at": "current"` is parsed by the graph loader so `status` and `validate` can report it as `unpinned`, but `deccy` always writes concrete 64-hex digests.)

---

## 3. Canonical JSON & BLAKE3 Domain Separation

All digests in `deccy` use **BLAKE3-256** (64 lowercase hex characters) with an explicit ASCII domain prefix ending in `\n`.

| Domain Tag | Constant | Formula | Used For |
| :--- | :--- | :--- | :--- |
| `"deccy-blob\n"` | `DOMAIN_BLOB` | `BLAKE3("deccy-blob\n" ‖ file_bytes)` | Claim snapshots and `deccy hash`. |
| `"deccy-node\n"` | `DOMAIN_NODE` | `BLAKE3("deccy-node\n" ‖ u64le(len(canonical_record)) ‖ canonical_record ‖ rationale_bytes)` | Node digests (reported in `list` and pinned in connector `at` fields). |
| `"deccy-id\n"` | `DOMAIN_ID` | `first_16_bytes(BLAKE3("deccy-id\n" ‖ seed ‖ "\n" ‖ attempt))` | Deterministic ID generation under `DECCY_ID_SEED`. |

### Why `deccy-node` is length-framed

The node digest hashes the 8-byte little-endian byte length of `canonical(record)` before concatenating `canonical(record)` and `rationale_bytes`. Because `rationale_bytes` is empty when `"rationale": null` (while the canonical JSON still contains `"rationale":null` vs `"rationale":"rationale/..."`), a node without a rationale and a node with an empty rationale file never collide, and boundaries between record and prose bytes cannot be shifted.

---

## 4. The Read-Only VCS Oracle

`deccy` detects `jj` first (when `.jj/` exists at the store root and `jj` is on `PATH`), falls back to `git` (when `.git` exists at the store root and `git` is on `PATH`), and otherwise reports `vcs none`.

Every `jj` command includes `--ignore-working-copy` so `deccy` never triggers a working-copy snapshot or mutates the repo. `git status` is never used.

The oracle answers five read-only queries:

| Question | `jj` Command | `git` Command |
| :--- | :--- | :--- |
| **1. Current revision & conflicts** | `jj log -r @ --no-graph -T 'commit_id ++ "\n"'` and `jj resolve --list -r @` | `git rev-parse HEAD` and `git ls-files -u` |
| **2. Parent revisions & merge base** | `jj log -r 'parents(REV)' ...` and `jj log -r 'heads(::A & ::B)' ...` | `git rev-list --parents -n 1 REV` and `git merge-base A B` |
| **3. Last change touching a file** | `jj log -r 'files("<path>") & ancestors(@)' --no-graph -T ... --limit 1` | `git log -1 --format=%H%x09%s -- <path>` |
| **4. One node file at a revision** | `jj file show -r REV <path>` | `git show REV:<path>` |
| **5. All node files at a revision** | `jj file list -r REV .deccy/nodes` | `git ls-tree -r --name-only REV -- .deccy/nodes` |

---

## 5. Git Attributes Recommendation

Because node records are formatted with one JSON key or array entry per line, standard text diffs and merges handle independent edits cleanly without a custom merge driver. Add this rule to your repository's `.gitattributes`:

```gitattributes
.deccy/nodes/*.json text eol=lf
```
