Add P0 infrastructure for the Volve-DIA benchmark

Set up the data, parsing and quality-control layer for a public benchmark
on the Volve daily drilling reports (DDR) and WITSML real-time data.

- Data manifest with SHA-256 hashes of the three Volve subtrees in use.
- DDR XML parser into DuckDB (1,759 reports, 26 wellbores, 23,447
  activities, 17 tables) with locked expected counts.
- Render QC of the publisher HTML against the XML (272,544 items).
- OCR client for the shared chandra vLLM service, with a page cache keyed
  on model, prompt hash, dpi, max_tokens and temperature, and OCR QC
  against the HTML on a 26-report pilot.
- Run logging (scripts/runlog.sh, logs/index.csv), the P0 runner and
  40 tests.
- Research plan, technical overview and progress page (in Vietnamese).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 12:45:34 +00:00
commit a3c175638f
172 changed files with 145856 additions and 0 deletions

85
tests/test_qc.py Normal file
View File

@@ -0,0 +1,85 @@
"""volve_dia.ddr.qc: equality, row alignment, label matching and what the XML says the HTML should print."""
from volve_dia.ddr import qc
from volve_dia.ddr.rendered import Rendered, Table
def test_equalities():
assert qc.exact("a b\n", "a b") and not qc.exact("a", None) and not qc.exact("1353", "1353.0")
assert qc.same_value("1353", "1353.0") and qc.same_value("-999.99", "") and qc.same_value("None", "")
assert not qc.same_value("", "x") and not qc.same_value("a", None) and qc.same_value("10 3/4", "10 3/4")
def test_align_skips_missing_and_dissimilar_rows():
a = [["00:00", "moved the BOP"], ["01:00", "tested"], ["02:00", "pulled out of hole"]]
assert qc.align(a, [a[0], a[2]]) == [(0, 0), (2, 1)]
assert qc.align(a, [["xx", "completely different"]]) == []
assert qc.align([], a) == []
def test_compare_counts_misread_labels_and_inventions():
ref = Rendered(fields={"rig name": "MÆRSK INSPIRER", "status": "normal"},
tables={"Operations": Table(["Start time", "Remark"], [["00:00", "Moved"], ["03:30", "Tested"]])})
hyp = Rendered(fields={"rig nam": "MERSK INSPIRER", "status": "normal", "bogus": "1"},
tables={"Operations": Table(None, [["Start time", "Remark"], ["03:30", "Tested"],
["04:00", "Invented row"]])})
items = {(i["part"], i["key"], i["row"]): i for i in qc.compare(ref, hyp)}
label, field = items[("field_label", "rig name", -1)], items[("field", "rig name", -1)]
assert not label["exact"] and label["hyp"] == "rig nam" # misread label, still matched
assert not field["exact"] and field["edits"] == 1 and field["chars"] == 14
assert items[("field", "status", -1)]["exact"]
assert items[("field_extra", "bogus", -1)]["hyp"] == "bogus: 1"
assert items[("colhead", "Start time", -1)]["exact"] # header row not recognised as one
assert items[("cell", "Remark", 0)]["hyp"] is None # row 0 was not read
assert items[("cell", "Remark", 1)]["exact"]
assert items[("row_extra", "", 1)]["hyp"] == "04:00 | Invented row"
assert not {"header_extra", "field_extra", "text_extra", "table_extra"} & {
i["part"] for i in qc.compare(ref, hyp, extras=False)}
def test_compare_pairs_labels_by_place_and_counts_invented_header_text():
ref = Rendered(header={"wellbore": "15/9-F-15"}, fields={"tight well": "N", "hpht": "Y", "temperature": ""})
hyp = Rendered(header={"wellbore": "15/9-F-15", "other": "Printed: 2008-10-04 00:00"},
fields={"tight well": "N", "hptt": "Y", "temperature": ""})
items = {(i["part"], i["key"]): i for i in qc.compare(ref, hyp)}
assert items[("field", "hpht")]["exact"] and not items[("field_label", "hpht")]["exact"] # ratio 75: by place
assert not any(p == "field_extra" for p, _ in items)
assert items[("header_extra", "other")]["hyp"] == "Printed: 2008-10-04 00:00"
def test_compare_maps_columns_by_header_when_their_number_differs():
ref = Rendered(tables={"A": Table(["Start", "Activity", "State", "Remark"], [["00:00", "drilling -- trip", "ok",
"Moved"]]),
"B": Table(["Start", "Remark"], [["01:00", "Tested"]])})
hyp = Rendered(tables={"A": Table(["Start", "Activity", "Remark"], [["00:00", "drilling -- ok trip", "Moved"]]),
"B": Table(["Start", "Remark", "Note"], [["01:00", "Tested", "x"]])})
items = {(i["part"], i["table"], i["key"]): i for i in qc.compare(ref, hyp)}
assert items[("cell", "A", "State")]["hyp"] is None and items[("colhead", "A", "State")]["hyp"] is None
assert items[("cell", "A", "Remark")]["exact"] and items[("cell", "A", "Activity")]["edits"] == 3
assert items[("col_extra", "B", "Note")]["hyp"] == "Note | x" and items[("cell", "B", "Remark")]["exact"]
def test_from_xml_prints_like_the_publisher():
report = {"wellbore": "15/9-F-12", "dTimStart": "2007-12-31T00:00:00+01:00",
"dTimEnd": "2008-01-01T00:00:00+01:00", "tightWell": 0, "hpht": 1, "waterDepth": 91.0,
"reportNo": 98, "sum24Hr": "Installed the BOP.", "forecast24Hr": None}
acts = [{"seq": 1, "dTimStart": "2007-12-31T03:30:00+01:00", "dTimEnd": "2008-01-01T00:00:00+01:00", "md": 0.0,
"proprietaryCode": "drilling -- bop/wellhead equipment", "state": "ok", "comments": "Tested."},
{"seq": 0, "dTimStart": "2007-12-31T00:00:00+01:00", "dTimEnd": "2007-12-31T03:30:00+01:00",
"md": 12.5, "proprietaryCode": "drilling -- bop/wellhead equipment", "state": "ok", "comments": "Moved."}]
r = qc.from_xml(report, acts)
assert r.header == {"wellbore": "15/9-F-12", "period": "2007-12-31 00:00 - 2008-01-01 00:00"}
assert r.fields["tight well"] == "N" and r.fields["hpht"] == "Y" and r.fields["water depth msl"] == "91"
assert r.fields["report number"] == "98" and r.fields["wellbore type"] == ""
assert r.texts == {"Summary of activities (24 Hours)": "Installed the BOP.",
"Summary of planned activities (24 Hours)": ""}
assert r.tables["Operations"].rows == [["00:00", "03:30", "12.5", "drilling -- bop/wellhead equipment", "ok",
"Moved."],
["03:30", "00:00", "0", "drilling -- bop/wellhead equipment", "ok",
"Tested."]]
def test_html_for_xml_drops_units():
r = qc.html_for_xml(Rendered(header={"wellbore": "NO 15/9-F-12"}, fields={"hole dia (in)": "8.5",
"hole dia ()": "", "status": "x"}))
assert r.header["wellbore"] == "15/9-F-12" and r.fields == {"hole dia": "8.5", "status": "x"}