From 377ddb61361d719102ee4e279dca03948757461b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 25 Sep 2026 21:02:39 -0400 Subject: ocda-dump, and the four disagreements it found The agreement check compared ten fields of each object. That was enough to find the blank-first-line defect and not enough for anything subtler, so this adds ocda-dump: the whole loaded model written out canonically, every field, sorted dictionaries, sections in format order, defaults omitted. It is an oracle, not an output format. Two implementations of this model can now be compared with diff. Run against the reference collection it found four disagreements between the two loaders, none of which the ten-field check could see. 1. .identifier and .anchor. The .ssp emits a property only when it carries information, so the identifier is absent when it is simply the ocn and the anchor is absent when it is the segment name; the database stores both unconditionally. Over one document that is 1,314 identifiers and 69 anchors. The loader now derives them, which is what the model means: an object's identifier is its ocn unless it says otherwise. 2. make and doc_has. The database has one metadata table where the text form has three blocks, and tells them apart by a key prefix. The loader now unprefixes them, so a writer asks doc.make["footer"] whichever serialisation it was handed and never doc.metadata["make.footer"]. 3. The JSON columns were read by a character scan that stripped brackets and quotes, which is wrong the moment a value holds an escape: JSONValue.toString escapes "/" as "\/", so every heading containing a slash came back with a backslash in it. All 36 document-languages differed on heading_ancestors_text. Now parsed as JSON. 4. translation.ocn_aligned is in the database and not in the .ssp, legitimately: it says whether the languages share one numbering, and a .ssp is one language and cannot know. It is a fact about the file rather than the document, so the loader leaves it out rather than letting a writer tell which serialisation it was given. Metadata values are also stripped now, as the text loader strips them: one topic_register value carried surrounding spaces in the database that the text form cannot represent. After all four: 36 of 36 document-languages give byte identical dumps from their .ssp and from their .ocda.db. (assisted by Claude-Code) Co-Authored-By: Claude Opus 5 (1M context) --- dlang/flake.nix | 66 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 26 deletions(-) (limited to 'dlang/flake.nix') diff --git a/dlang/flake.nix b/dlang/flake.nix index 954cad9..26dbe2d 100644 --- a/dlang/flake.nix +++ b/dlang/flake.nix @@ -9,37 +9,51 @@ pkgs = import nixpkgs { inherit system; }; /* A library, so there is nothing to install as a binary. What is - built here is the agreement check, which is the library's own - reason to exist put to the question: load a document's .ssp and - its .ocda.db and compare the two models. + built here are the two programs that put the library to the + question: the agreement check, which loads a document's .ssp and + its .ocda.db and compares the two models, and the dump, which + writes a loaded model out canonically so that an implementation in + another language can be diffed against this one. */ - mkAgree = { compiler, compilerBin }: pkgs.stdenv.mkDerivation { - pname = "ocda-lib-agree"; - version = "0.1.0"; - src = self; - nativeBuildInputs = [ compiler ]; - buildInputs = [ pkgs.sqlite ]; - buildPhase = '' - runHook preBuild - export HOME=$TMPDIR - ${compilerBin} -I=src -of=agree src/ocda/*.d test/agree.d -L-lsqlite3 - runHook postBuild - ''; - installPhase = '' - runHook preInstall - mkdir -p $out/bin - install -m755 agree $out/bin/ocda-agree - runHook postInstall - ''; - meta = { - description = "checks that the .ssp and .ocda.db loaders give one model"; - mainProgram = "ocda-agree"; + mkTool = { tool, binary, what, compiler, compilerBin }: + pkgs.stdenv.mkDerivation { + pname = "ocda-lib-${tool}"; + version = "0.1.0"; + src = self; + nativeBuildInputs = [ compiler ]; + buildInputs = [ pkgs.sqlite ]; + buildPhase = '' + runHook preBuild + export HOME=$TMPDIR + ${compilerBin} -I=src -of=${tool} src/ocda/*.d test/${tool}.d -L-lsqlite3 + runHook postBuild + ''; + installPhase = '' + runHook preInstall + mkdir -p $out/bin + install -m755 ${tool} $out/bin/${binary} + runHook postInstall + ''; + meta = { + description = what; + mainProgram = binary; + }; }; - }; + + ldc = { compiler = pkgs.ldc; compilerBin = "ldmd2"; }; in { packages.${system} = { default = self.packages.${system}.ocda-agree; - ocda-agree = mkAgree { compiler = pkgs.ldc; compilerBin = "ldmd2"; }; + + ocda-agree = mkTool (ldc // { + tool = "agree"; binary = "ocda-agree"; + what = "checks that the .ssp and .ocda.db loaders give one model"; + }); + + ocda-dump = mkTool (ldc // { + tool = "dump"; binary = "ocda-dump"; + what = "writes a loaded abstraction out canonically, as an oracle"; + }); }; devShells.${system}.default = pkgs.mkShell { -- cgit v1.2.3