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

91
tests/test_rendered.py Normal file
View File

@@ -0,0 +1,91 @@
"""volve_dia.ddr.rendered: the publisher HTML and chandra's blocks reduce to the same `Rendered` report."""
from volve_dia.ddr.rendered import Rendered, Table, parse_html, parse_ocr
from volve_dia.ocr import LABEL_MAP, Block
HTML = """<html><body>
<p class="DDR-ReportHeader">Summary report</p>
<p class="DDR-SubReportHeader"><b>Wellbore: </b>15/9-F-12</p>
<p class="DDR-SubReportHeader"><b>Period: </b>2007-12-31 00:00 - 2008-01-01 00:00</p>
<table id="wellboreInfoTable_1"><thead><tr><th/><th/><th/></tr></thead><tbody>
<tr><td class="ColHead">Status:</td><td class="ColValue">normal</td></tr>
<tr><td class="ColHead">Hole Dia ():</td><td class="ColValue"/></tr>
<tr><td class="ColHead">Rig Name:</td><td class="ColValue">M&#198;RSK INSPIRER</td></tr>
</tbody></table>
<p class="TextHeader">Summary of activities (24 Hours)</p>
<p class="TextData">Installed the BOP.<br/>Tested it. </p>
<p class="TextHeader">Operations</p>
<table><thead><tr><th class="ColHead">Start time</th><th class="ColHead">Remark</th></tr></thead><tbody>
<tr><td class="ColValue">00:00</td><td class="ColValueWrapped">Moved the BOP.
</td></tr><tr><td class="ColValue">03:30</td><td class="ColValueWrapped">Tested.</td></tr></tbody></table>
<p class="TextHeader">Casing Liner Tubing</p>
<table><tbody><tr><td class="ColHead">Start Time</td><td class="ColValue"></td></tr>
<tr><td class="ColHead">Type</td><td class="ColValue">liner</td></tr></tbody></table>
</body></html>"""
EXPECTED = Rendered(
header={"wellbore": "15/9-F-12", "period": "2007-12-31 00:00 - 2008-01-01 00:00"},
fields={"status": "normal", "hole dia ()": "", "rig name": "MÆRSK INSPIRER"},
texts={"Summary of activities (24 Hours)": "Installed the BOP.\nTested it."},
tables={"Operations": Table(["Start time", "Remark"], [["00:00", "Moved the BOP."], ["03:30", "Tested."]]),
"Casing Liner Tubing": Table(None, [["Start Time", ""], ["Type", "liner"]])},
)
def block(page, label, html, text=None):
return Block(page=page, label=LABEL_MAP.get(label.lower(), "paragraph"), raw_label=label, text=text or html,
bbox=[], reading_order=0, html=html)
OPS_HEAD = "<tr><th>Start time</th><th>Remark</th></tr>"
BLOCKS = [
block(1, "Page-Header", "<p>Summary report</p>",
"Summary report\nWellbore: 15/9-F-12 Period: 2007-12-31 00:00 - 2008-01-01 00:00"),
block(1, "Table", "<table><tr><td><b>Status:</b> normal</td></tr><tr><td>Hole Dia ():</td><td></td></tr>"
"<tr><td>Rig Name:</td><td>MÆRSK INSPIRER</td></tr></table>"),
block(1, "Section-Header", "Summary of activities (24 Hours)"),
block(1, "Text", "<p>Installed the BOP.</p>", "Installed the BOP."),
block(2, "Text", "<p>Tested it.</p>", "Tested it."), # the paragraph goes on
block(2, "Text", "<p><b>Operations</b></p>", "Operations"), # bold throughout: a title
block(2, "Table", f"<table>{OPS_HEAD}<tr><td>00:00</td><td>Moved the BOP.</td></tr></table>"),
block(3, "Page-Footer", "<p>Page 2 of 3</p>", "Page 2 of 3"),
block(3, "Table", f"<table>{OPS_HEAD}<tr><td>03:30</td><td>Tested.</td></tr></table>"), # header repeated
block(3, "Section-Header", "Casing Liner Tubing"),
block(3, "Table", "<table><tr><td><b>Start Time</b></td><td></td></tr></table>"),
block(4, "Table", "<table><tr><th>Type</th><th>liner</th></tr></table>"), # a data row read as a header
]
def test_parse_html():
assert parse_html(HTML) == EXPECTED
def test_parse_ocr_undoes_the_page_layout():
r = parse_ocr(BLOCKS)
assert (r.header, r.fields, r.texts, r.tables) == (EXPECTED.header, EXPECTED.fields, EXPECTED.texts,
EXPECTED.tables)
assert r.notes == ["table continued: Operations",
"table continued (header row kept as data): Casing Liner Tubing"]
def test_parse_ocr_repairs_the_table_structure():
period = "2007-12-31 00:00 - 2008-01-01 00:00"
blocks = [
block(1, "Table", "<table><tr><td><b>Summary report</b></td><td>Printed: 2008-10-04 00:00</td></tr>"
f"<tr><td><b>Wellbore: 15/9-F-12</b></td><td><b>Period: {period}</b></td></tr>"
"<tr><td><b>Status:</b></td><td>normal</td></tr></table>"), # header lines as rows
block(1, "Section-Header", "Operations"),
block(1, "Table", f"<table>{OPS_HEAD}<tr><td>00:00</td><td>Moved</td></tr>"
"<tr><td></td><td>the BOP.</td></tr></table>"), # a two-line cell as rows
block(2, "Table", "<table><tr><td>03:30</td><td>ok</td><td>Tested.</td></tr></table>"), # a column split
]
r = parse_ocr(blocks)
assert r.header == {"wellbore": "15/9-F-12", "period": period, "other": "Printed: 2008-10-04 00:00"}
assert r.fields == {"status": "normal"}
assert r.tables == {"Operations": Table(["Start time", "Remark"], [["00:00", "Moved\nthe BOP."],
["03:30", "ok", "Tested."]])}
assert r.notes == ["table continued, columns differ: Operations", "rows merged into the row above: Operations (1)"]
def test_round_trip():
assert Rendered.from_dict(EXPECTED.to_dict()) == EXPECTED