From bf1294cf89265cfab7e4886a505e0338c9013203 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 21 Sep 2026 14:15:34 -0400 Subject: verify: this spine still produces this abstraction? does this spine still produce this abstraction? A database states an abstraction and carries the markup it was built from, so re-parsing the one and comparing against the other says whether the two still agree. Checked as follows: - automatically and unskippably when a document is built from a database, at the moment it is parsed and before anything has been written from it. - on --ocda-verify=, an action of its own that materialises, parses every language, compares, reports and writes nothing, the exit status being the answer. - on --no-verify as the escape, warning per document, for a newer spine reading an older artefact where the abstraction is expected to differ and the output is wanted anyway. A build ends at the first failure rather than skipping the language. A document rebuilt from a database now has its whole abstraction built. (assisted by Claude-Code) --- src/sisudoc/ocda/abstraction/db_in.d | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/sisudoc/ocda/abstraction/db_in.d') diff --git a/src/sisudoc/ocda/abstraction/db_in.d b/src/sisudoc/ocda/abstraction/db_in.d index 0a01364..986a09d 100644 --- a/src/sisudoc/ocda/abstraction/db_in.d +++ b/src/sisudoc/ocda/abstraction/db_in.d @@ -90,6 +90,34 @@ template spineDbLanguages() { return _out; } } +/+ ↓ the .ssp digest a database recorded for each of its languages. + . + What verify holds its answer against: the database says which .ssp it was + built from, so re-parsing the markup it carries and emitting the .ssp again + either reproduces that digest or does not. + . + Its own template, for the reason spineDbLanguages is: asking a file what it + recorded should not instantiate the reader. ++/ +template spineDbSspDigests() { + @trusted string[string] spineDbSspDigests(string db_file) { + import std.file : exists; + import d2sqlite3; + string[string] _out; + if (!db_file.exists) { return _out; } + try { + auto db = Database(db_file, SQLITE_OPEN_READONLY); + foreach (row; db.execute( + "SELECT lang, ssp_digest FROM documents ORDER BY id") + ) { + _out[row["lang"].as!string] = row["ssp_digest"].as!string; + } + } catch (Exception ex) { + return string[string].init; + } + return _out; + } +} template spineAbstractionDbRead() { import std.conv : to; import std.file; -- cgit v1.2.3