# Erasure preparation: what node hashes remember Status: **notes**, kept with the code. They record one decision taken for 1.0 and the consequence a caller has to weigh. They are not legal advice. SirixDB keeps every revision. That is the point of it, and it is also why removing a value is not a matter of overwriting it in place: the value, or something derived from it, can survive in more than one structure. This page covers one of those structures — the optional per-node subtree hash — and states what is and is not settled. ## The decision **Node hashes are off by default since 1.0.** A resource created without an explicit `hashKind(...)` uses `HashType.NONE`: | Entry point | Default | |---|---| | `ResourceConfiguration.Builder` (Java API) | `NONE` (`ResourceConfiguration.DEFAULT_HASH_TYPE`) | | `BasicJsonDBStore` / `BasicXmlDBStore`, `jn:store` / `xn:store` options | `NONE` (resolved from the same constant) | | Kotlin CLI (`create-resource`, `create`) | `NONE` | | REST (`?hashType=`) | `NONE` (unchanged — the REST server never defaulted to hashes) | Hashing stays available as an explicit, per-resource choice: `hashKind(HashType.ROLLING)`, the `hashType` store option, `?hashType=ROLLING` on REST resource creation, or `-Dsirix.hashType=ROLLING` to restore the old Java default for a whole JVM. The query stores also accept the legacy `-DhashType` override, which takes precedence over `sirix.hashType` there. REST still defaults to `NONE` unless its creation request explicitly supplies `hashType`. **Specified, implementation pending:** POSTORDER is removed for 1.0, by the captain's decision of 2026-11-28. The supported kinds and refusal rules belong to [CONF-111](../spec/CONF-configuration.md#conf-111--supported-hash-kinds); the enum and parser removal follows in a separate implementation PR. An **existing** resource with NONE or ROLLING is not affected and needs no migration. The hash kind is persisted in the resource settings and read back on open, so a store created with rolling hashes keeps them and keeps maintaining them. ## Why off is the default A leaf's own hash is computed over its key, its parent's key, its kind, its neighbours, its field-name key and its **raw value**. With `ROLLING`, a container's *stored* hash is its own hash plus 77081 times the sum of its children's hashes. So every ancestor up to the document root carries a term that depends on the leaf's value, in every revision in which that value existed. Everything in that computation except the value itself is known to whoever holds the store. A guess can therefore be checked: rebuild the hash with a candidate value and compare. For a date of birth, a postcode, a diagnosis code or a yes/no field, the candidate set is small enough to enumerate. This was reproduced against the engine — five guesses to confirm a date of birth — during the 1.0 erasure/format design review. Hashes off is the only default under which a value removed from a store leaves no such confirmable residue. It also removes the stored hash of every container record and the hash maintenance work on every commit. For the current count behavior and the proposed independent choice, see [Descendant counts](#descendant-counts). **Stored versus derived.** What `HashType.NONE` removes is the *stored* hash. A container (`ObjectNode`, `ArrayNode`) then reads back `0`. A primitive leaf, and an XML element, instead *derive* a hash from the record's own content when none is stored (`StringNode#getHash`, `ElementNode#getHash`), so `getHash()` and `sdb:hash` can still answer non-zero there. That derivation is no residue: it is computed on demand from the value the caller already holds, it is not persisted with `HashType.NONE`, and it aggregates nothing. The oracle in the section above needs the *container's* stored aggregate, which is exactly what is gone. ## Capabilities and trade-offs Turning hashes **on** is a legitimate choice for a resource that holds no data anybody may ask you to erase. It buys: * `sdb:hash` as a subtree aggregate, and with it hash-based change detection across `jn:all-times`; * the hash-optimized diff route, which can skip a subtree whose stored hash is unchanged. A resource with hashes also stores descendant counts. A container's own hash covers its count, so hashes cannot be kept without counts. For the current REST precondition mechanism and its planned replacement, see the [README](../README.md#bitemporal-queries). ## Descendant counts The 1.0 specification decouples stored descendant counts from node hashes. **Not implemented yet:** at this code baseline, counts are still stored and maintained only when hashes are on. The creation option and its default belong to [CONF-110](../spec/CONF-configuration.md#conf-110--descendant-count-setting), the record layout to [FMT-501](../spec/FMT-disk-format.md#fmt-501--descendant-count-field-of-container-records), and the counted-record definition and maintenance to [TXN-901 to TXN-908](../spec/TXN-transactions-durability.md#txn-901--descendant-count-definition-and-exactness). Reader behavior when counts are disabled belongs to [JAPI-112](../spec/JAPI-java-api.md#japi-112--descendant-count-option-and-honest-refusal), [REST-215](../spec/REST-api.md#rest-215--descendant-counts-in-serialized-metadata) and [QRY-701](../spec/QRY-query-execution.md#qry-701--sdbdescendant-count-answers-or-refuses). A count is computed from the shape of the tree alone, never from a value, so it gives no oracle for confirming a guessed value. It is still a residue of a different kind: every ancestor of a removed subtree records, in each revision in which the subtree existed, how many records it held. A future eraser has to rewrite those ancestor counts as well as the records it removes. Without hashes the diff compares nodes. The existing differential fixtures (`JsonDiffHashEquivalenceTest`, `XmlDiffHashEquivalenceTest`) require byte-identical diffs with and without hashing, and `DiffFactoryHashKindTest` checks that a hashless resource refuses the hash shortcut. These fixtures do not establish equivalence for every edit: the [open hash-equality audit](../spec/TXN-transactions-durability.md#deferred-implementation-and-verification) records why rolling-hash equality cannot establish unchanged child order or placement. These hashes never were a security control: they are XXH3-64, recomputable by anyone. See the [storage integrity limits](DISK_FORMAT.md#3-integrity) and the [tamper-evident ledger proposal](TAMPER_EVIDENCE_PLAN.md). ## What this page does not settle Hashes off removes one residue. It is not erasure, and the following are **not** implemented: * **Blinded hashes** — a hash salted with a secret that is destroyed with the data, which would let a resource keep node hashes *and* be erasable. Not in 1.0. * **An eraser** — removing a subtree from every revision by rewriting the pages that hold it. * **Retention** — dropping whole old revisions and reclaiming their space. * **Page-checksum residue** — a record page's parent stores the XXH3-64 of that page's bytes, which is the same kind of oracle for anyone able to reproduce the page. Record pages now carry random salts by default; destroying those salts during a future erasure is separate from disabling node hashes, and no eraser exists yet. * **Other copies** — REST multipart uploads, backups and replicas are outside this page. * **Descendant-count residue** — the ancestor counts described above. No eraser rewrites them yet. Until those exist, the honest statement is: a value written to a SirixDB store stays recoverable from that store's history. Choosing `HashType.NONE` means a *future* erasure of it will not be defeated by the node hashes.