Liking cljdoc? Tell your friends :D

vaelii.impl.disk.belief-snapshot

A belief certificate: the sparse complement of belief on a clean disk KB, written beside the records and read on the next cold open so recover can skip the one expensive pass of its closing settle — the definitional-clash scan (settle/constraint-nogoods).

This stores a stamp, not belief

Belief is derived, never stored: recover rebuilds it from the records on every open, and the records are the sole durable source of truth. This does not break that. What it writes is a stamp asserting two things about the records as they stood when it was written — their fingerprint (record-store/slot-fingerprint), and whether the KB was clean: every standing definitional clash an equal-strength tie that disbelieves neither side (settle/decide-nogood), so the scan produced no defeat.

On a clean KB the scan is belief-neutral — the rest of the closing settle rederives the same belief without it (settle/*skip-constraint-nogoods*). So a cold open whose records still match the stamp binds that flag and reaches identical belief for the cost of the structural rebuild alone: on the 11.36M-sentex corpus, the scan is the settle's one costly pass, minutes of it. A KB that is not clean carries a strength-differentiated loser whose defeat cascades through what it supported, which no post-hoc force reproduces — so its certificate is stamped :clean? false and the open ignores it and pays the full scan.

What is written

Under dir/belief:

  • meta.edn — the stamp: :format, :fingerprint, :clean?, and counts. Tiny, and the only file the open path reads — read and checked before anything is trusted.
  • out.edn — the disbelieved sentexes, content-keyed [sentence context], human-readable. The sparse complement of belief itself; a verification and inspection artifact, not consulted by the fast path (the scan-skipped settle rederives the same set).
  • notes.edn — the standing clashes, written only when the caller supplies :notes (a :complete dump), for a reader that wants the dilemma records without a scan.

Why it cannot go wrong

The failure to fear is a stale stamp that passes its check. It cannot: the stamp is a fingerprint of the records, re-read on every open, and any record added, deleted, or re-stored moves it (slot-fingerprint reads the slots, not the snapshot's own bytes). A mismatch — or :clean? false, or an absent or torn file — falls back to the full recover, which is always correct because belief is derived. Nothing here is ever the source of truth, so the worst a bad certificate can cost is the recover it was meant to save.

A **belief certificate**: the sparse complement of belief on a *clean* disk KB, written
beside the records and read on the next cold open so `recover` can skip the one
expensive pass of its closing settle — the definitional-clash scan
(`settle/constraint-nogoods`).

## This stores a stamp, not belief

Belief is derived, never stored: `recover` rebuilds it from the records on every open,
and the records are the sole durable source of truth.  This does not break that.  What
it writes is a **stamp** asserting two things about the records as they stood when it was
written — their fingerprint (`record-store/slot-fingerprint`), and whether the KB was
*clean*: every standing definitional clash an equal-strength tie that disbelieves neither
side (`settle/decide-nogood`), so the scan produced no defeat.

On a clean KB the scan is **belief-neutral** — the rest of the closing settle rederives
the same belief without it (`settle/*skip-constraint-nogoods*`).  So a cold open whose
records still match the stamp binds that flag and reaches identical belief for the cost
of the structural rebuild alone: on the 11.36M-sentex corpus, the scan is the settle's
one costly pass, minutes of it.  A KB that is **not** clean carries a
strength-differentiated loser whose defeat cascades through what it supported, which no
post-hoc force reproduces — so its certificate is stamped `:clean? false` and the open
ignores it and pays the full scan.

## What is written

Under `dir/belief`:
- `meta.edn` — the stamp: `:format`, `:fingerprint`, `:clean?`, and counts.  Tiny, and
  the only file the open path reads — read and checked before anything is trusted.
- `out.edn` — the disbelieved sentexes, content-keyed `[sentence context]`, human-readable.
  The sparse complement of belief itself; a verification and inspection artifact, not
  consulted by the fast path (the scan-skipped settle rederives the same set).
- `notes.edn` — the standing clashes, written only when the caller supplies `:notes`
  (a `:complete` dump), for a reader that wants the dilemma records without a scan.

## Why it cannot go wrong

The failure to fear is a stale stamp that passes its check.  It cannot: the stamp is a
fingerprint of the **records**, re-read on every open, and any record added, deleted, or
re-stored moves it (`slot-fingerprint` reads the slots, not the snapshot's own bytes).  A
mismatch — or `:clean? false`, or an absent or torn file — falls back to the full
recover, which is always correct because belief is derived.  Nothing here is ever the
source of truth, so the worst a bad certificate can cost is the recover it was meant to
save.
raw docstring

format-versionclj

The certificate's own layout number. A directory written under an older number is refused (the open rebuilds), so a layout change never reads wrong.

The certificate's own layout number.  A directory written under an older number is
refused (the open rebuilds), so a layout change never reads wrong.
sourceraw docstring

read-metaclj

(read-meta records)

The parsed meta.edn stamp for records, or nil when there is none, the store is not a disk store, or the file does not read.

The parsed `meta.edn` stamp for `records`, or nil when there is none, the store is not a
disk store, or the file does not read.
sourceraw docstring

save!clj

(save! records cert)

Write the belief certificate for a disk KB whose disbelief the caller has already computed into cert{:clean? :out-count :clash-count :clash-losers :out [[sen ctx]…]}, optionally :notes. Stamps it with the records' current slot-fingerprint and writes dir/belief/{meta,out}.edn (and notes.edn when :notes is present). A no-op unless writable?. Returns the certificate directory, or nil.

Write the belief certificate for a disk KB whose disbelief the caller has already
computed into `cert` — `{:clean? :out-count :clash-count :clash-losers :out [[sen ctx]…]}`,
optionally `:notes`.  Stamps it with the records' current `slot-fingerprint` and writes
`dir/belief/{meta,out}.edn` (and `notes.edn` when `:notes` is present).  A no-op unless
`writable?`.  Returns the certificate directory, or nil.
sourceraw docstring

usable?clj

(usable? records)

May a cold open trust the certificate and skip the clash scan? True only when the switch is on, the stamp reads, its :format is current, it certifies the KB :clean?, and its :fingerprint equals the records' current slot-fingerprint. Every other case — off, no file, torn file, changed records, an unclean KB — is false, and the caller pays the full recover. The switch is checked first, so an open with it off never even reads the records' fingerprint.

May a cold open trust the certificate and skip the clash scan?  True only when the
switch is on, the stamp reads, its `:format` is current, it certifies the KB `:clean?`,
and its `:fingerprint` equals the records' current `slot-fingerprint`.  Every other case
— off, no file, torn file, changed records, an unclean KB — is false, and the caller pays
the full recover.  The switch is checked first, so an open with it off never even reads
the records' fingerprint.
sourceraw docstring

writable?clj

(writable? records)

May a certificate be written for records? The switch is on and the store is durable. Read before computing the certificate so a KB with the switch off pays nothing for it.

May a certificate be written for `records`?  The switch is on and the store is durable.
Read before computing the certificate so a KB with the switch off pays nothing for it.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close