# Volve-DIA, task T4: question templates for evidence-grounded question answering over the daily drilling reports. # # Engine: volve_dia/t4.py. Build: scripts/08_t4_questions.py -> outputs/t4/. Independent check: volve_dia/t4_pandas.py. # # Rules # * Gold answers come from `answer_sql` on outputs/ddr/volve_ddr.duckdb (the DDR XML as parsed by # scripts/02_parse_ddr.py). No language model, no HTML, no PDF. Evidence rows come from `evidence_sql`. # * `slots_sql` enumerates the candidate instances from the data: one row per instance, one column per slot, in the # order of `slots`. In `answer_sql` and `evidence_sql`, `$slot` is replaced by the SQL literal of the slot value. # * `answer_sql` returns the column `answer` (one row; several rows for a list) and may return `drop_reason`: a # non-NULL value drops the instance and is counted under that reason (ambiguous_multiple_values, tie, # implausible_value, inconsistent_source, not_contiguous). A NULL answer drops the instance (null_answer) or, with # `on_null: not_reported`, yields an unanswerable question whose gold answer is "not reported". # * `evidence_sql` returns "table", report_id, seq (NULL for a row of `reports`) and, for evidence_mode group, grp. # Evidence modes: all = every row is needed; any = each row states the answer by itself; group = one row per # group is enough. # * `sample` / `negatives`: at most `n` answerable / unanswerable instances per group of `by` (slots or `answer`), # chosen by a hash of `seed` and the instance key. # * Trouble questions use the published codes (`proprietaryCode`, printed as "Main - Sub Activity", and # `stateDetailActivity`), never the NPT definition of T2, which is not locked. # # Conventions used in question texts and answers # * Report date: the date in the report file name (`reports.file_date`). It is the END date of the 24 h reporting # period, so the report dated 2008-01-01 covers 2007-12-31 00:00 to 2008-01-01 00:00 local time. # * Event date: the calendar date of the activity start as published (`activities.dTimStart`, local time with its # UTC offset). "First" means the earliest `start_utc`. # * Depths are measured depths in metres as published (`units` table: m; datum RKB/KB where given). An activity's # depth is its "End Depth mMD". # * Sizes are in inches. Sentinels (-999.99, -999.25, -9999) are NULL in the tables and never enter an answer. # * The report `15_9_19_A_1980_01_01` (dated 1980, no activities, 5 survey stations) is part of the published data # and is not excluded. # # Tolerances: a predicted number p matches the gold g if |p - g| <= max(abs, rel * |g|). The values below are design # choices fixed before any model was run; they are not calibrated on model output. # depth m: abs 1.0 | density g/cm3: abs 0.01 | inclination: abs 0.1 dega | hours: abs 0.25 h | ROP: rel 0.02 | # counts and dates: exact | sizes in: abs 0.01 version: 1 task: T4 seed: 20261117 database: outputs/ddr/volve_ddr.duckdb # TADI (Lu, arXiv:2605.00060v1, Table 3 and Appendix C): 130 stress questions in six categories. `tadi.category` and # `tadi.subcategory` of a template name the closest TADI class; `tadi.fit` says how close: direct (the template asks # what the subcategory asks), partial (a factual building block of it) or none (outside the taxonomy). tadi_taxonomy: source: "Lu, R. TADI: Tool-Augmented Drilling Intelligence via Agentic LLM Orchestration over Heterogeneous Wellsite Data. arXiv:2605.00060v1, 2026. Table 3; Appendix C." categories: 1: {name: "Phase Identification & Validation", questions: 20} 2: {name: "Time & Efficiency Analysis", questions: 21} 3: {name: "Section & ROP Performance", questions: 21} 4: {name: "BHA & Configuration Effectiveness", questions: 20} 5: {name: "Operational Issues & Root Causes", questions: 26} 6: {name: "Synthesis, Comparison & Recommendations", questions: 22} not_covered: - "Cat. 6 narrative subcategories (best practices, lessons learned, recommendations, shift handover, executive summary, cost estimation, future well planning, drilling-production integration): no answer computable by SQL." - "Root-cause inference in Cat. 5: the templates ask what the codes record, not why it happened." - "Cat. 3 gas response, lithology-ROP, d-exponent, drilling parameter correlation and Cat. 4 BHA runs: need WITSML (see `planned`)." families: lookup: "One published value (or a list of values) of one wellbore." aggregation: "A sum, count, ratio or arg-max over the rows of one wellbore." temporal_event: "The first occurrence of a coded event, what preceded it, how long it lasted, or whether it occurred." comparison: "Two wellbores of the same well, or all wellbores of the field." multi_hop: "A value looked up at the place or time that another query finds." templates: # ------------------------------------------------------------------------------------------------------------------ # Lookup # ------------------------------------------------------------------------------------------------------------------ - id: L01_spud_date family: lookup tadi: {category: 1, subcategory: "phase boundary detection", fit: partial} questions: - "What spud date do the daily drilling reports of wellbore {wellbore} state?" - "According to the header of the daily drilling reports of wellbore {wellbore}, on what date was the wellbore spudded?" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} slots_sql: SELECT DISTINCT wellbore FROM reports ORDER BY 1 answer_sql: | SELECT min(substr(dTimSpud, 1, 10)) AS answer, CASE WHEN count(DISTINCT substr(dTimSpud, 1, 10)) > 1 THEN 'ambiguous_multiple_values' END AS drop_reason FROM reports WHERE wellbore = $wellbore evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND dTimSpud IS NOT NULL evidence_mode: any answer: {type: date, tolerance: {days: 0}} source: [reports.dTimSpud] caveats: - "Header value as published. A sidetrack may carry the spud date of its parent wellbore (15/9-F-11 A and 15/9-F-11 T2 state the spud date of 15/9-F-11)." - id: L02_drill_complete_date family: lookup tadi: {category: 1, subcategory: "phase boundary detection", fit: partial} questions: - "What drilling completion date ('Date Well Complete') do the daily drilling reports of wellbore {wellbore} state?" - "On what date was drilling of wellbore {wellbore} completed according to the header field 'Date Well Complete' of its daily drilling reports?" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} slots_sql: SELECT DISTINCT wellbore FROM reports ORDER BY 1 answer_sql: | SELECT min(substr(dateDrillComplete, 1, 10)) AS answer, CASE WHEN count(DISTINCT substr(dateDrillComplete, 1, 10)) > 1 THEN 'ambiguous_multiple_values' END AS drop_reason FROM reports WHERE wellbore = $wellbore evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND dateDrillComplete IS NOT NULL evidence_mode: any answer: {type: date, tolerance: {days: 0}} on_null: not_reported source: [reports.dateDrillComplete] caveats: - "Unanswerable where no report of the wellbore carries the field (5 wellbores)." - id: L03_deepest_md family: lookup tadi: {category: 1, subcategory: "phase boundary detection", fit: partial} questions: - "What is the deepest measured depth (field 'Depth mMD') stated in the daily drilling reports of wellbore {wellbore}?" - "Across all daily drilling reports of wellbore {wellbore}, what is the maximum reported measured depth of the wellbore?" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} slots_sql: SELECT DISTINCT wellbore FROM reports ORDER BY 1 answer_sql: SELECT max(md) AS answer FROM reports WHERE wellbore = $wellbore evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND md = (SELECT max(md) FROM reports WHERE wellbore = $wellbore) evidence_mode: any answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} source: [reports.md] caveats: - "The deepest depth the reports state, not an official total depth: `md` is NULL in 331 reports and later reports may state a shallower depth after plugging back." - id: L04_deepest_md_date family: lookup tadi: {category: 1, subcategory: "phase boundary detection", fit: partial} questions: - "What is the date of the first daily drilling report of wellbore {wellbore} that states the deepest measured depth of the wellbore? (Report date: the end of the 24 h reporting period.)" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} slots_sql: SELECT DISTINCT wellbore FROM reports ORDER BY 1 answer_sql: | SELECT min(file_date) AS answer FROM reports WHERE wellbore = $wellbore AND md = (SELECT max(md) FROM reports WHERE wellbore = $wellbore) evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND md = (SELECT max(md) FROM reports WHERE wellbore = $wellbore) ORDER BY file_date LIMIT 1 evidence_mode: all answer: {type: date, tolerance: {days: 0}} source: [reports.md, reports.file_date] caveats: - "A report date is the end of its period: the depth was reached during the 24 h before that date." - id: L05_casing_bottom_md family: lookup tadi: {category: 1, subcategory: "phase boundary detection", fit: partial} questions: - "In the 'Casing Liner Tubing' records of the daily drilling reports of wellbore {wellbore}, what is the deepest bottom depth (m MD) recorded for pipe with an outside diameter of {od}?" - "According to the casing, liner and tubing records in the daily drilling reports of wellbore {wellbore}, how deep (m MD) does the {od} string reach?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with casing records"} od: {type: inch, enumerated_by: "outside diameters recorded for the wellbore"} slots_sql: SELECT DISTINCT wellbore, od FROM casings ORDER BY 1, 2 answer_sql: SELECT max(mdBottom) AS answer FROM casings WHERE wellbore = $wellbore AND od = $od evidence_sql: | SELECT 'casings' AS "table", report_id, seq FROM casings WHERE wellbore = $wellbore AND od = $od AND mdBottom = (SELECT max(mdBottom) FROM casings WHERE wellbore = $wellbore AND od = $od) evidence_mode: any answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} source: [casings.od, casings.mdBottom] caveats: - "A string is published as one row or as one row per joint group; the answer is the deepest `mdBottom` of the rows with that outside diameter. Casing records exist for 21 of 26 wellbores and 67 reports." - id: L06_casing_sizes family: lookup tadi: {category: 1, subcategory: "phase sequence reconstruction", fit: partial} questions: - "Which outside diameters of casing, liner or tubing are recorded in the 'Casing Liner Tubing' sections of the daily drilling reports of wellbore {wellbore}?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with casing records"} slots_sql: SELECT DISTINCT wellbore FROM casings ORDER BY 1 answer_sql: SELECT DISTINCT od AS answer FROM casings WHERE wellbore = $wellbore ORDER BY 1 DESC evidence_sql: SELECT 'casings' AS "table", report_id, seq, od AS grp FROM casings WHERE wellbore = $wellbore evidence_mode: group answer: {type: list, item_type: number, unit: in, tolerance: {abs: 0.01}} source: [casings.od] caveats: - "Only strings that have a casing record in the DDRs of this wellbore; strings set in a parent wellbore are not repeated." - id: L07_hole_sizes family: lookup tadi: {category: 1, subcategory: "phase sequence reconstruction", fit: direct} questions: - "Which hole diameters (field 'Hole Dia') do the daily drilling reports of wellbore {wellbore} state?" - "List every distinct hole diameter that appears in the 'Hole Dia' field of the daily drilling reports of wellbore {wellbore}." slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one stated hole diameter"} slots_sql: SELECT DISTINCT wellbore FROM reports WHERE diaHole IS NOT NULL ORDER BY 1 answer_sql: | SELECT DISTINCT diaHole AS answer FROM reports WHERE wellbore = $wellbore AND diaHole IS NOT NULL ORDER BY 1 DESC evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq, diaHole AS grp FROM reports WHERE wellbore = $wellbore AND diaHole IS NOT NULL evidence_mode: group answer: {type: list, item_type: number, unit: in, tolerance: {abs: 0.01}} source: [reports.diaHole] caveats: - "`diaHole` is NULL in 990 of 1,759 reports; the list holds the stated diameters only, pilot holes included (15/9-19 S: 9 7/8 in; 15/9-F-12: 8 1/2 in before 26 in)." - id: L08_hole_section_start_md family: lookup tadi: {category: 1, subcategory: "phase boundary detection", fit: direct} render: {printed: false, note: "`mdDiaHoleStart` is in the XML only; the HTML and PDF renders do not print it."} questions: - "At what measured depth did the {hole} hole section of wellbore {wellbore} start according to the daily drilling reports (start depth of the current hole diameter)?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one stated hole diameter"} hole: {type: inch, enumerated_by: "hole diameters stated for the wellbore"} slots_sql: SELECT DISTINCT wellbore, diaHole AS hole FROM reports WHERE diaHole IS NOT NULL ORDER BY 1, 2 answer_sql: | SELECT CASE WHEN count(DISTINCT mdDiaHoleStart) = 1 THEN min(mdDiaHoleStart) END AS answer, CASE WHEN count(DISTINCT mdDiaHoleStart) > 1 THEN 'ambiguous_multiple_values' END AS drop_reason FROM reports WHERE wellbore = $wellbore AND diaHole = $hole evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND diaHole = $hole AND mdDiaHoleStart IS NOT NULL evidence_mode: any answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} source: [reports.diaHole, reports.mdDiaHoleStart] caveats: - "Dropped when the reports of the section state more than one start depth (the section was re-entered or the field was edited)." - id: L09_hole_section_max_md family: lookup tadi: {category: 1, subcategory: "phase boundary detection", fit: direct} questions: - "What is the deepest measured depth stated in those daily drilling reports of wellbore {wellbore} that give a hole diameter of {hole}?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one stated hole diameter"} hole: {type: inch, enumerated_by: "hole diameters stated for the wellbore"} slots_sql: SELECT DISTINCT wellbore, diaHole AS hole FROM reports WHERE diaHole IS NOT NULL ORDER BY 1, 2 answer_sql: SELECT max(md) AS answer FROM reports WHERE wellbore = $wellbore AND diaHole = $hole evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND diaHole = $hole AND md = (SELECT max(md) FROM reports WHERE wellbore = $wellbore AND diaHole = $hole) evidence_mode: any answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} source: [reports.diaHole, reports.md] caveats: - "The depth range of a hole size as the reports state it; reports without `diaHole` (990) are outside every section." - id: L10_max_inclination family: lookup tadi: {category: 3, subcategory: null, fit: none} questions: - "What is the highest inclination among the survey stations listed in the daily drilling reports of wellbore {wellbore}?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with survey stations"} slots_sql: SELECT DISTINCT wellbore FROM surveys WHERE incl IS NOT NULL ORDER BY 1 answer_sql: SELECT max(incl) AS answer FROM surveys WHERE wellbore = $wellbore evidence_sql: | SELECT 'surveys' AS "table", report_id, seq FROM surveys WHERE wellbore = $wellbore AND incl = (SELECT max(incl) FROM surveys WHERE wellbore = $wellbore) evidence_mode: any answer: {type: number, unit: dega, round: 2, tolerance: {abs: 0.1}} source: [surveys.incl] caveats: - "Survey stations of the DDRs (274 reports), not the definitive survey; the WITSML trajectory may differ." - "TADI has no trajectory subcategory." - id: L11_max_inclination_md family: lookup tadi: {category: 3, subcategory: null, fit: none} questions: - "At what measured depth is the survey station with the highest inclination that the daily drilling reports of wellbore {wellbore} list?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with survey stations"} slots_sql: SELECT DISTINCT wellbore FROM surveys WHERE incl IS NOT NULL ORDER BY 1 answer_sql: | SELECT CASE WHEN count(DISTINCT md) = 1 THEN min(md) END AS answer, CASE WHEN count(DISTINCT md) > 1 THEN 'tie' END AS drop_reason FROM surveys WHERE wellbore = $wellbore AND incl = (SELECT max(incl) FROM surveys WHERE wellbore = $wellbore) evidence_sql: | SELECT 'surveys' AS "table", report_id, seq FROM surveys WHERE wellbore = $wellbore AND incl = (SELECT max(incl) FROM surveys WHERE wellbore = $wellbore) evidence_mode: any answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} source: [surveys.incl, surveys.md] caveats: - "Dropped when the highest inclination is listed at more than one depth." - id: L12_mud_density_on_date family: lookup tadi: {category: 5, subcategory: "mud losses and circulation", fit: partial} questions: - "What drilling fluid density does the daily drilling report of wellbore {wellbore} dated {date} state? (Report date: the end of the 24 h reporting period.)" - "Which mud weight (fluid density) is recorded in the 'Drilling Fluid' section of the daily drilling report of {date} for wellbore {wellbore}? (Report date: the end of the 24 h reporting period.)" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with fluid records"} date: {type: date, enumerated_by: "report dates with at least one fluid density"} slots_sql: | SELECT DISTINCT r.wellbore, r.file_date AS date FROM reports r JOIN fluids f USING (report_id) WHERE f.density IS NOT NULL ORDER BY 1, 2 answer_sql: | SELECT CASE WHEN count(DISTINCT f.density) = 1 THEN min(f.density) END AS answer, CASE WHEN count(DISTINCT f.density) > 1 THEN 'ambiguous_multiple_values' WHEN min(f.density) < 0.5 OR max(f.density) > 3 THEN 'implausible_value' END AS drop_reason FROM fluids f JOIN reports r USING (report_id) WHERE r.wellbore = $wellbore AND r.file_date = $date AND f.density IS NOT NULL evidence_sql: | SELECT 'fluids' AS "table", f.report_id, f.seq FROM fluids f JOIN reports r USING (report_id) WHERE r.wellbore = $wellbore AND r.file_date = $date AND f.density IS NOT NULL evidence_mode: any answer: {type: number, unit: g/cm3, round: 3, tolerance: {abs: 0.01}} sample: {by: [wellbore], n: 6} source: [fluids.density, reports.file_date] caveats: - "Dropped when the fluid samples of the report differ in density, or when a density is outside 0.5 to 3 g/cm3 (103.0 g/cm3 is published in 4 rows)." - id: L13_mud_density_at_depth family: lookup tadi: {category: 5, subcategory: "mud losses and circulation", fit: partial} questions: - "What drilling fluid density do the daily drilling reports of wellbore {wellbore} record for fluid samples with a sample depth of {md} m MD?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with fluid records"} md: {type: number, enumerated_by: "sample depths above 0 m with at least one fluid density"} slots_sql: | SELECT DISTINCT wellbore, md FROM fluids WHERE md > 0 AND density IS NOT NULL ORDER BY 1, 2 answer_sql: | SELECT CASE WHEN count(DISTINCT density) = 1 THEN min(density) END AS answer, CASE WHEN count(DISTINCT density) > 1 THEN 'ambiguous_multiple_values' WHEN min(density) < 0.5 OR max(density) > 3 THEN 'implausible_value' END AS drop_reason FROM fluids WHERE wellbore = $wellbore AND md = $md AND density IS NOT NULL evidence_sql: | SELECT 'fluids' AS "table", report_id, seq FROM fluids WHERE wellbore = $wellbore AND md = $md AND density IS NOT NULL evidence_mode: any answer: {type: number, unit: g/cm3, round: 3, tolerance: {abs: 0.01}} sample: {by: [wellbore], n: 4} source: [fluids.md, fluids.density] caveats: - "`fluids.md` is the sample depth ('Sample Depth mMD'), the hole depth when the sample was taken, not the depth at which the mud was in the hole." - "Dropped when samples at that depth differ in density across reports." - id: L14_formation_top_md family: lookup tadi: {category: 3, subcategory: "formation-level ROP analysis", fit: partial} questions: - "At what measured depth is the top of the {formation} according to the 'Stratigraphic Information' of the daily drilling reports of wellbore {wellbore}?" - "What depth to top of formation (m MD) do the daily drilling reports of wellbore {wellbore} give for the {formation}?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with stratigraphic records"} formation: {type: string, enumerated_by: "formation names of the wellbore, trailing dots and spaces removed"} slots_sql: SELECT DISTINCT wellbore, rtrim(description, ' .') AS formation FROM strat ORDER BY 1, 2 answer_sql: | SELECT CASE WHEN count(DISTINCT mdTop) = 1 THEN min(mdTop) END AS answer, CASE WHEN count(DISTINCT mdTop) > 1 THEN 'ambiguous_multiple_values' END AS drop_reason FROM strat WHERE wellbore = $wellbore AND rtrim(description, ' .') = $formation evidence_sql: | SELECT 'strat' AS "table", report_id, seq FROM strat WHERE wellbore = $wellbore AND rtrim(description, ' .') = $formation evidence_mode: any answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} sample: {by: [wellbore], n: 8} source: [strat.description, strat.mdTop] caveats: - "Tops as reported while drilling (102 reports, 20 wellbores), not the final picks of Well_picks_Volve_v1.dat." - "Dropped when the reports give more than one top depth for the formation." - id: L15_rig_name family: lookup tadi: {category: null, subcategory: null, fit: none} questions: - "Which rig do the daily drilling reports of wellbore {wellbore} name (field 'Rig Name')?" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} slots_sql: SELECT DISTINCT wellbore FROM reports ORDER BY 1 answer_sql: | SELECT min(rigAlias_NPD_Name) AS answer, CASE WHEN count(DISTINCT rigAlias_NPD_Name) > 1 THEN 'ambiguous_multiple_values' END AS drop_reason FROM reports WHERE wellbore = $wellbore evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND rigAlias_NPD_Name IS NOT NULL evidence_mode: any answer: {type: string} source: [reports.rigAlias_NPD_Name] caveats: - "Dropped when the reports of the wellbore name more than one rig (15/9-19 ST2)." - "Report metadata; outside the TADI taxonomy." - id: L16_kickoff_md family: lookup tadi: {category: 1, subcategory: "phase boundary detection", fit: partial} questions: - "What kick-off depth (field 'Depth at Kick Off mMD') do the daily drilling reports of wellbore {wellbore} state?" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} slots_sql: SELECT DISTINCT wellbore FROM reports ORDER BY 1 answer_sql: | SELECT CASE WHEN count(DISTINCT mdKickoff) = 1 THEN min(mdKickoff) END AS answer, CASE WHEN count(DISTINCT mdKickoff) > 1 THEN 'ambiguous_multiple_values' END AS drop_reason FROM reports WHERE wellbore = $wellbore evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND mdKickoff IS NOT NULL evidence_mode: any answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} on_null: not_reported negatives: {n: 4} source: [reports.mdKickoff] caveats: - "The field is filled in 248 reports of 4 wellbores only; a sidetrack without the field is unanswerable from the DDR header, although its reports may mention a kick-off in free text." # ------------------------------------------------------------------------------------------------------------------ # Aggregation # ------------------------------------------------------------------------------------------------------------------ - id: A01_reports_per_hole_size family: aggregation tadi: {category: 2, subcategory: "drilling efficiency trends", fit: partial} questions: - "How many daily drilling reports of wellbore {wellbore} state a hole diameter of {hole}?" - "On how many report days does the 'Hole Dia' field of the daily drilling reports of wellbore {wellbore} read {hole}?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one stated hole diameter"} hole: {type: inch, enumerated_by: "hole diameters stated for the wellbore"} slots_sql: SELECT DISTINCT wellbore, diaHole AS hole FROM reports WHERE diaHole IS NOT NULL ORDER BY 1, 2 answer_sql: SELECT count(*) AS answer FROM reports WHERE wellbore = $wellbore AND diaHole = $hole evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND diaHole = $hole evidence_mode: all answer: {type: number, unit: reports, round: 0, tolerance: {abs: 0}} source: [reports.diaHole] caveats: - "Days on which the reports state this hole size, not the duration of the section: days without `diaHole` (casing, completion, waiting) are not counted." - id: A02_metres_drilled family: aggregation tadi: {category: 3, subcategory: "section difficulty ranking", fit: partial} questions: - "What is the total distance drilled in wellbore {wellbore} when the 'Dist Drilled' values of all its daily drilling reports are added up?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with a drilled distance above zero"} slots_sql: SELECT DISTINCT wellbore FROM reports WHERE distDrill > 0 ORDER BY 1 answer_sql: SELECT sum(distDrill) AS answer FROM reports WHERE wellbore = $wellbore AND distDrill > 0 evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND distDrill > 0 evidence_mode: all answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} source: [reports.distDrill] caveats: - "`distDrill` is a sentinel in 1,247 of 1,759 reports, so the sum is what the reports state and may be less than the drilled interval." - id: A03_metres_drilled_section family: aggregation tadi: {category: 3, subcategory: "section difficulty ranking", fit: partial} questions: - "How many metres were drilled in the {hole} hole of wellbore {wellbore}, adding up the 'Dist Drilled' values of the daily drilling reports that state this hole diameter?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one stated hole diameter"} hole: {type: inch, enumerated_by: "hole diameters stated for the wellbore"} slots_sql: SELECT DISTINCT wellbore, diaHole AS hole FROM reports WHERE diaHole IS NOT NULL ORDER BY 1, 2 answer_sql: | SELECT sum(distDrill) AS answer FROM reports WHERE wellbore = $wellbore AND diaHole = $hole AND distDrill > 0 evidence_sql: | SELECT 'reports' AS "table", report_id, NULL AS seq FROM reports WHERE wellbore = $wellbore AND diaHole = $hole AND distDrill > 0 evidence_mode: all answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} source: [reports.diaHole, reports.distDrill] caveats: - "Dropped (null_answer) when no report of the section states a drilled distance above zero." - "Seven reports state a drilled distance without a hole diameter; they belong to no section." - id: A04_rop_section family: aggregation tadi: {category: 3, subcategory: "formation-level ROP analysis", fit: partial} questions: - "What is the average rate of penetration in the {hole} hole of wellbore {wellbore}, computed from the daily drilling reports as the total 'Dist Drilled' divided by the total duration of the activities coded 'drilling -- drill', over the reports that state this hole diameter and a drilled distance above zero?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one stated hole diameter"} hole: {type: inch, enumerated_by: "hole diameters stated for the wellbore"} slots_sql: SELECT DISTINCT wellbore, diaHole AS hole FROM reports WHERE diaHole IS NOT NULL ORDER BY 1, 2 answer_sql: | WITH d AS (SELECT report_id, sum(duration_h) AS h FROM activities WHERE proprietaryCode = 'drilling -- drill' GROUP BY 1), s AS (SELECT r.distDrill, d.h FROM reports r LEFT JOIN d USING (report_id) WHERE r.wellbore = $wellbore AND r.diaHole = $hole AND r.distDrill > 0) SELECT sum(distDrill) / sum(h) AS answer, CASE WHEN count(*) FILTER (WHERE h IS NULL) > 0 THEN 'inconsistent_source' END AS drop_reason FROM s evidence_sql: | WITH s AS (SELECT report_id FROM reports WHERE wellbore = $wellbore AND diaHole = $hole AND distDrill > 0) SELECT 'reports' AS "table", report_id, NULL AS seq FROM s UNION ALL SELECT 'activities', a.report_id, a.seq FROM activities a JOIN s USING (report_id) WHERE a.proprietaryCode = 'drilling -- drill' evidence_mode: all answer: {type: number, unit: m/h, round: 2, tolerance: {rel: 0.02}} source: [reports.distDrill, reports.diaHole, activities.proprietaryCode, activities.duration_h] caveats: - "ROP source: DDR only (`distDrill` over hours coded 'drilling -- drill'). `ropCurrent` is a sentinel in every report. This is a gross on-code ROP: the coded hours include connections and short stops." - "Dropped (inconsistent_source) when a report of the section states metres drilled but has no activity coded 'drilling -- drill': the ratio would not be an ROP (41 such reports, mostly the 1990s wellbores)." - id: A05_bit_run_rop_max family: aggregation tadi: {category: 4, subcategory: "best BHA run identification", fit: partial} questions: - "What is the highest bit-run average rate of penetration ('Form ROP' in the Bit Record) that the daily drilling reports of wellbore {wellbore} record for {bit} bits?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with bit records"} bit: {type: inch, enumerated_by: "bit sizes above 0 in recorded for the wellbore"} slots_sql: SELECT DISTINCT wellbore, diaBit AS bit FROM bits WHERE diaBit > 0 ORDER BY 1, 2 answer_sql: SELECT max(bitRun_ropAv) AS answer FROM bits WHERE wellbore = $wellbore AND diaBit = $bit evidence_sql: | SELECT 'bits' AS "table", report_id, seq FROM bits WHERE wellbore = $wellbore AND diaBit = $bit AND bitRun_ropAv = (SELECT max(bitRun_ropAv) FROM bits WHERE wellbore = $wellbore AND diaBit = $bit) evidence_mode: any answer: {type: number, unit: m/h, round: 2, tolerance: {rel: 0.02}} source: [bits.diaBit, bits.bitRun_ropAv] caveats: - "ROP source: `bits.bitRun_ropAv` (88 values in 80 reports, 21 wellbores). A bit record, not a BHA run: the WITSML bhaRun objects are not used here." - "Dropped (null_answer) when no bit record of that size carries an ROP. One bit record has the size -999 in, which is not a sentinel of the parser and is excluded by `diaBit > 0`." - id: A06_hours_per_code family: aggregation tadi: {category: 2, subcategory: "NPT decomposition", fit: partial} questions: - "How many hours of activities coded '{code}' (Main - Sub Activity) do the daily drilling reports of wellbore {wellbore} record in total?" - "What is the total duration, in hours, of all activities with the code '{code}' in the daily drilling reports of wellbore {wellbore}?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one activity of the code"} code: {type: string, enumerated_by: "the ten interruption codes and drilling -- drill, trip, casing"} slots_sql: | SELECT DISTINCT wellbore, proprietaryCode AS code FROM activities WHERE code_main = 'interruption' OR proprietaryCode IN ('drilling -- drill', 'drilling -- trip', 'drilling -- casing') ORDER BY 1, 2 answer_sql: | SELECT sum(duration_h) AS answer FROM activities WHERE wellbore = $wellbore AND proprietaryCode = $code evidence_sql: | SELECT 'activities' AS "table", report_id, seq FROM activities WHERE wellbore = $wellbore AND proprietaryCode = $code evidence_mode: all answer: {type: number, unit: h, round: 2, tolerance: {abs: 0.25}} sample: {by: [wellbore], n: 6} source: [activities.proprietaryCode, activities.duration_h] caveats: - "Hours under a published code, not NPT: the NPT definition of T2 is not locked and is not used." - "Activities cover less than the report period in 221 reports (2,605 h in total), so code hours are a lower bound of the time spent." - id: A07_equip_failure_count family: aggregation tadi: {category: 5, subcategory: "equipment reliability", fit: direct} questions: - "How many entries does the 'Equipment Failure Information' section hold in total across the daily drilling reports of wellbore {wellbore}?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with equipment failure records"} slots_sql: SELECT DISTINCT wellbore FROM equip_failures ORDER BY 1 answer_sql: SELECT count(*) AS answer FROM equip_failures WHERE wellbore = $wellbore evidence_sql: SELECT 'equip_failures' AS "table", report_id, seq FROM equip_failures WHERE wellbore = $wellbore evidence_mode: all answer: {type: number, unit: entries, round: 0, tolerance: {abs: 0}} source: [equip_failures] caveats: - "Entries, not distinct failures: the same failure can be listed in more than one report (5 groups of identical time, class and description)." - "The five 15/9-19 wellbores have no such section; they are not asked." - id: A08_top_interruption_code family: aggregation tadi: {category: 2, subcategory: "NPT decomposition", fit: direct} questions: - "Among the activities of wellbore {wellbore} whose main code is 'interruption', which Main - Sub Activity code accounts for the most hours in the daily drilling reports?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with interruption activities"} slots_sql: SELECT DISTINCT wellbore FROM activities WHERE code_main = 'interruption' ORDER BY 1 answer_sql: | WITH h AS (SELECT proprietaryCode AS code, round(sum(duration_h), 4) AS h FROM activities WHERE wellbore = $wellbore AND code_main = 'interruption' GROUP BY 1) SELECT min(code) AS answer, CASE WHEN count(*) > 1 THEN 'tie' END AS drop_reason FROM h WHERE h = (SELECT max(h) FROM h) evidence_sql: | WITH h AS (SELECT proprietaryCode AS code, round(sum(duration_h), 4) AS h FROM activities WHERE wellbore = $wellbore AND code_main = 'interruption' GROUP BY 1) SELECT 'activities' AS "table", report_id, seq FROM activities WHERE wellbore = $wellbore AND proprietaryCode IN (SELECT code FROM h WHERE h = (SELECT max(h) FROM h)) evidence_mode: all answer: type: enumeration choices: {sql: "SELECT DISTINCT proprietaryCode FROM activities WHERE code_main = 'interruption' ORDER BY 1"} source: [activities.proprietaryCode, activities.code_main, activities.duration_h] caveats: - "The evidence rows are the activities of the winning code; the hours of the other codes are not listed." - "'interruption -- other' is a code of its own and often the largest." - id: A09_wow_days family: aggregation tadi: {category: 5, subcategory: "weather impact", fit: direct} questions: - "How many daily drilling reports of wellbore {wellbore} contain at least one activity coded 'interruption -- waiting on weather'?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with waiting-on-weather activities"} slots_sql: | SELECT DISTINCT wellbore FROM activities WHERE proprietaryCode = 'interruption -- waiting on weather' ORDER BY 1 answer_sql: | SELECT count(DISTINCT report_id) AS answer FROM activities WHERE wellbore = $wellbore AND proprietaryCode = 'interruption -- waiting on weather' evidence_sql: | SELECT 'activities' AS "table", report_id, seq, report_id AS grp FROM activities WHERE wellbore = $wellbore AND proprietaryCode = 'interruption -- waiting on weather' evidence_mode: group answer: {type: number, unit: reports, round: 0, tolerance: {abs: 0}} source: [activities.proprietaryCode] caveats: - "Report days with the code, not calendar days of bad weather." # ------------------------------------------------------------------------------------------------------------------ # Temporal and event questions. The events are the published state details of an activity (`stateDetailActivity`). # ------------------------------------------------------------------------------------------------------------------ - id: E01_first_event_date family: temporal_event tadi: {category: 5, subcategory: "stuck pipe and tight hole; mud losses and circulation", fit: direct} render: {printed: false, note: "`stateDetailActivity` is in the XML only: the HTML and PDF renders print the state (ok or fail) but not the state detail."} questions: - "On what date did the first activity with the state detail '{detail}' start in wellbore {wellbore}, according to the activity records of its daily drilling reports?" - "The daily drilling reports code each activity with a state detail. In wellbore {wellbore}, on which calendar date does the earliest activity coded '{detail}' begin?" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} detail: {type: string, enumerated_by: "stuck equipment, circulation loss, mud loss"} slots_sql: | SELECT w.wellbore, d.detail FROM (SELECT DISTINCT wellbore FROM reports) w CROSS JOIN (VALUES ('stuck equipment'), ('circulation loss'), ('mud loss')) d(detail) ORDER BY 1, 2 answer_sql: | WITH e AS (SELECT dTimStart, start_utc FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail), f AS (SELECT * FROM e WHERE start_utc = (SELECT min(start_utc) FROM e)) SELECT min(substr(dTimStart, 1, 10)) AS answer, CASE WHEN count(*) > 1 THEN 'tie' END AS drop_reason FROM f evidence_sql: | SELECT 'activities' AS "table", report_id, seq FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1 evidence_mode: all answer: {type: date, tolerance: {days: 0}} on_null: not_reported negatives: {by: [detail], n: 3} source: [activities.stateDetailActivity, activities.dTimStart] caveats: - "The first activity that carries the code, not the first time the phenomenon happened: the remarks of an earlier activity may describe it without the code. Unanswerable ('not reported') means no activity of the wellbore carries the code." - "The date is the start of the activity in local time, usually one day before the report date." - id: E02_first_event_md family: temporal_event tadi: {category: 5, subcategory: "stuck pipe and tight hole; mud losses and circulation", fit: direct} render: {printed: false, note: "`stateDetailActivity` is in the XML only."} questions: - "What end depth (m MD) do the daily drilling reports of wellbore {wellbore} record for the first activity with the state detail '{detail}'?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one activity of the state detail"} detail: {type: string, enumerated_by: "stuck equipment, circulation loss, mud loss"} slots_sql: | SELECT DISTINCT wellbore, stateDetailActivity AS detail FROM activities WHERE stateDetailActivity IN ('stuck equipment', 'circulation loss', 'mud loss') ORDER BY 1, 2 answer_sql: | WITH e AS (SELECT md, start_utc FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail), f AS (SELECT * FROM e WHERE start_utc = (SELECT min(start_utc) FROM e)) SELECT min(md) AS answer, CASE WHEN count(*) > 1 THEN 'tie' END AS drop_reason FROM f evidence_sql: | SELECT 'activities' AS "table", report_id, seq FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1 evidence_mode: all answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} source: [activities.stateDetailActivity, activities.md] caveats: - "`activities.md` is the 'End Depth mMD' of the activity, not necessarily the depth of the problem; it is 0 m for two first events (15/9-19 BT2 circulation loss, 15/9-F-1 B mud loss)." - id: E03_activity_before_first_event family: temporal_event tadi: {category: 5, subcategory: "stuck pipe and tight hole; mud losses and circulation", fit: partial} render: {printed: false, note: "`stateDetailActivity` is in the XML only."} questions: - "Which Main - Sub Activity code has the activity that immediately precedes the first activity with the state detail '{detail}' in the daily drilling reports of wellbore {wellbore}?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one activity of the state detail"} detail: {type: string, enumerated_by: "stuck equipment, circulation loss, mud loss"} slots_sql: | SELECT DISTINCT wellbore, stateDetailActivity AS detail FROM activities WHERE stateDetailActivity IN ('stuck equipment', 'circulation loss', 'mud loss') ORDER BY 1, 2 answer_sql: | WITH a AS (SELECT stateDetailActivity, start_utc, lag(proprietaryCode) OVER (ORDER BY start_utc) AS prev_code, lag(end_utc) OVER (ORDER BY start_utc) AS prev_end FROM activities WHERE wellbore = $wellbore) SELECT prev_code AS answer, CASE WHEN prev_end <> start_utc THEN 'not_contiguous' END AS drop_reason FROM a WHERE stateDetailActivity = $detail ORDER BY start_utc LIMIT 1 evidence_sql: | WITH a AS (SELECT report_id, seq, stateDetailActivity, start_utc, lag(report_id) OVER (ORDER BY start_utc) AS prev_report, lag(seq) OVER (ORDER BY start_utc) AS prev_seq FROM activities WHERE wellbore = $wellbore), f AS (SELECT * FROM a WHERE stateDetailActivity = $detail ORDER BY start_utc LIMIT 1) SELECT 'activities' AS "table", report_id, seq FROM f UNION ALL SELECT 'activities', prev_report, prev_seq FROM f evidence_mode: all answer: type: enumeration choices: {sql: "SELECT DISTINCT proprietaryCode FROM activities ORDER BY 1"} source: [activities.stateDetailActivity, activities.proprietaryCode, activities.start_utc, activities.end_utc] caveats: - "'What was being done' is read as the code of the preceding activity of the same wellbore in time order, which may be in the previous report." - "Dropped (not_contiguous) when the preceding activity does not end where the event starts, and (null_answer) when the event is the first activity of the wellbore." - id: E04_first_episode_hours family: temporal_event tadi: {category: 5, subcategory: "stuck pipe and tight hole; mud losses and circulation", fit: direct} render: {printed: false, note: "`stateDetailActivity` is in the XML only."} questions: - "In wellbore {wellbore}, how many hours does the first uninterrupted run of activities with the state detail '{detail}' last, counting the consecutive activity records from the first one with this state detail until the next activity with a different state detail?" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} detail: {type: string, enumerated_by: "stuck equipment, circulation loss, mud loss"} slots_sql: | SELECT w.wellbore, d.detail FROM (SELECT DISTINCT wellbore FROM reports) w CROSS JOIN (VALUES ('stuck equipment'), ('circulation loss'), ('mud loss')) d(detail) ORDER BY 1, 2 answer_sql: | WITH a AS (SELECT duration_h, stateDetailActivity = $detail AS hit, row_number() OVER (ORDER BY start_utc) AS rn FROM activities WHERE wellbore = $wellbore), b AS (SELECT (SELECT min(rn) FROM a WHERE hit) AS rn0), c AS (SELECT b.rn0, (SELECT min(rn) FROM a WHERE NOT hit AND rn > b.rn0) AS rn1 FROM b) SELECT sum(a.duration_h) AS answer FROM a, c WHERE a.rn >= c.rn0 AND (c.rn1 IS NULL OR a.rn < c.rn1) evidence_sql: | WITH a AS (SELECT report_id, seq, stateDetailActivity = $detail AS hit, row_number() OVER (ORDER BY start_utc) AS rn FROM activities WHERE wellbore = $wellbore), b AS (SELECT (SELECT min(rn) FROM a WHERE hit) AS rn0), c AS (SELECT b.rn0, (SELECT min(rn) FROM a WHERE NOT hit AND rn > b.rn0) AS rn1 FROM b) SELECT 'activities' AS "table", a.report_id, a.seq FROM a, c WHERE a.rn >= c.rn0 AND (c.rn1 IS NULL OR a.rn < c.rn1) evidence_mode: all answer: {type: number, unit: h, round: 2, tolerance: {abs: 0.25}} on_null: not_reported negatives: {by: [detail], n: 2} source: [activities.stateDetailActivity, activities.duration_h, activities.start_utc] caveats: - "An episode is a run of consecutive activity records with the same state detail; it is a property of the coding, not a measured event duration, and it ends at the first record coded differently even if the trouble went on." - id: E05_max_wow_day family: temporal_event tadi: {category: 5, subcategory: "weather impact", fit: direct} questions: - "Which daily drilling report of wellbore {wellbore} records the most hours of activities coded 'interruption -- waiting on weather'? Give the report date (the end of the 24 h reporting period)." slots: wellbore: {type: wellbore, enumerated_by: "wellbores with waiting-on-weather activities"} slots_sql: | SELECT DISTINCT wellbore FROM activities WHERE proprietaryCode = 'interruption -- waiting on weather' ORDER BY 1 answer_sql: | WITH w AS (SELECT r.file_date, round(sum(a.duration_h), 4) AS h FROM activities a JOIN reports r USING (report_id) WHERE a.wellbore = $wellbore AND a.proprietaryCode = 'interruption -- waiting on weather' GROUP BY 1) SELECT min(file_date) AS answer, CASE WHEN count(*) > 1 THEN 'tie' END AS drop_reason FROM w WHERE h = (SELECT max(h) FROM w) evidence_sql: | WITH w AS (SELECT a.report_id, round(sum(a.duration_h), 4) AS h FROM activities a WHERE a.wellbore = $wellbore AND a.proprietaryCode = 'interruption -- waiting on weather' GROUP BY 1) SELECT 'activities' AS "table", report_id, seq FROM activities WHERE wellbore = $wellbore AND proprietaryCode = 'interruption -- waiting on weather' AND report_id IN (SELECT report_id FROM w WHERE h = (SELECT max(h) FROM w)) evidence_mode: all answer: {type: date, tolerance: {days: 0}} source: [activities.proprietaryCode, activities.duration_h, reports.file_date] caveats: - "Dropped (tie) when two or more reports share the highest total, typically several full 24 h days of waiting." - id: E06_code_present family: temporal_event tadi: {category: 5, subcategory: "well control events; mud losses and circulation", fit: partial} questions: - "Do the daily drilling reports of wellbore {wellbore} contain at least one activity coded '{code}' (Main - Sub Activity)?" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} code: {type: string, enumerated_by: "interruption codes for well control, lost circulation, sidetrack, fish"} slots_sql: | SELECT w.wellbore, c.code FROM (SELECT DISTINCT wellbore FROM reports) w CROSS JOIN (VALUES ('interruption -- well control'), ('interruption -- lost circulation'), ('interruption -- sidetrack'), ('interruption -- fish')) c(code) ORDER BY 1, 2 answer_sql: | SELECT count(*) > 0 AS answer FROM activities WHERE wellbore = $wellbore AND proprietaryCode = $code evidence_sql: | SELECT 'activities' AS "table", report_id, seq FROM activities WHERE wellbore = $wellbore AND proprietaryCode = $code evidence_mode: any answer: {type: boolean} sample: {by: [code, answer], n: 3} source: [activities.proprietaryCode] caveats: - "A 'no' is supported by the absence of the code in every activity of the wellbore, so it has no evidence rows; it does not mean the phenomenon is absent from the remarks." # ------------------------------------------------------------------------------------------------------------------ # Comparison # ------------------------------------------------------------------------------------------------------------------ - id: C01_more_hours_pair family: comparison scope: pair tadi: {category: 5, subcategory: "cross-well issue comparison", fit: direct} questions: - "Which of the two wellbores {wellbore_a} and {wellbore_b} has more hours of activities coded '{code}' in its daily drilling reports?" slots: wellbore_a: {type: wellbore, enumerated_by: "pairs of wellbores of the same well, a before b by name"} wellbore_b: {type: wellbore, enumerated_by: "see wellbore_a"} code: {type: string, enumerated_by: "interruption -- waiting on weather, interruption -- repair"} slots_sql: | WITH w AS (SELECT DISTINCT wellbore, split_part(wellbore, ' ', 1) AS well FROM reports) SELECT a.wellbore AS wellbore_a, b.wellbore AS wellbore_b, c.code FROM w a JOIN w b ON a.well = b.well AND a.wellbore < b.wellbore CROSS JOIN (VALUES ('interruption -- waiting on weather'), ('interruption -- repair')) c(code) ORDER BY 1, 2, 3 answer_sql: | WITH h AS (SELECT wellbore, round(sum(duration_h), 4) AS h FROM activities WHERE proprietaryCode = $code AND wellbore IN ($wellbore_a, $wellbore_b) GROUP BY 1), v AS (SELECT coalesce((SELECT h FROM h WHERE wellbore = $wellbore_a), 0) AS ha, coalesce((SELECT h FROM h WHERE wellbore = $wellbore_b), 0) AS hb) SELECT CASE WHEN ha > hb THEN $wellbore_a WHEN hb > ha THEN $wellbore_b END AS answer, CASE WHEN ha = hb AND ha > 0 THEN 'tie' END AS drop_reason FROM v evidence_sql: | SELECT 'activities' AS "table", report_id, seq FROM activities WHERE proprietaryCode = $code AND wellbore IN ($wellbore_a, $wellbore_b) evidence_mode: all answer: {type: enumeration, choices: {slots: [wellbore_a, wellbore_b]}} source: [activities.proprietaryCode, activities.duration_h] caveats: - "Same-well pairs only, so a question never spans two wells; it still spans two wellbores, which matters if the split groups by wellbore." - "Dropped (null_answer) when neither wellbore has the code and (tie) when the totals are equal." - "Wellbores differ in length and season, so more hours is not a higher rate." - id: C02_faster_rop_pair family: comparison scope: pair tadi: {category: 6, subcategory: "well-on-well improvement", fit: partial} questions: - "Which of the two wellbores {wellbore_a} and {wellbore_b} drilled its {hole} hole at the higher average rate of penetration, taking for each wellbore the total 'Dist Drilled' divided by the total duration of the activities coded 'drilling -- drill', over the daily drilling reports that state this hole diameter and a drilled distance above zero?" slots: wellbore_a: {type: wellbore, enumerated_by: "pairs of wellbores of the same well that both report metres drilled in the hole size, a before b by name"} wellbore_b: {type: wellbore, enumerated_by: "see wellbore_a"} hole: {type: inch, enumerated_by: "hole diameters in which both wellbores report metres drilled"} slots_sql: | WITH s AS (SELECT DISTINCT wellbore, split_part(wellbore, ' ', 1) AS well, diaHole AS hole FROM reports WHERE diaHole IS NOT NULL AND distDrill > 0) SELECT a.wellbore AS wellbore_a, b.wellbore AS wellbore_b, a.hole FROM s a JOIN s b ON a.well = b.well AND a.hole = b.hole AND a.wellbore < b.wellbore ORDER BY 1, 2, 3 answer_sql: | WITH d AS (SELECT report_id, sum(duration_h) AS h FROM activities WHERE proprietaryCode = 'drilling -- drill' GROUP BY 1), s AS (SELECT r.wellbore, r.distDrill, d.h FROM reports r LEFT JOIN d USING (report_id) WHERE r.wellbore IN ($wellbore_a, $wellbore_b) AND r.diaHole = $hole AND r.distDrill > 0), g AS (SELECT wellbore, sum(distDrill) / sum(h) AS rop, count(*) FILTER (WHERE h IS NULL) AS bad FROM s GROUP BY 1), v AS (SELECT (SELECT rop FROM g WHERE wellbore = $wellbore_a) AS ra, (SELECT rop FROM g WHERE wellbore = $wellbore_b) AS rb, (SELECT sum(bad) FROM g) AS bad) SELECT CASE WHEN ra > rb THEN $wellbore_a WHEN rb > ra THEN $wellbore_b END AS answer, CASE WHEN bad > 0 THEN 'inconsistent_source' WHEN abs(ra - rb) <= 0.02 * greatest(ra, rb) THEN 'tie' END AS drop_reason FROM v evidence_sql: | WITH s AS (SELECT report_id FROM reports WHERE wellbore IN ($wellbore_a, $wellbore_b) AND diaHole = $hole AND distDrill > 0) SELECT 'reports' AS "table", report_id, NULL AS seq FROM s UNION ALL SELECT 'activities', a.report_id, a.seq FROM activities a JOIN s USING (report_id) WHERE a.proprietaryCode = 'drilling -- drill' evidence_mode: all answer: {type: enumeration, choices: {slots: [wellbore_a, wellbore_b]}} source: [reports.distDrill, reports.diaHole, activities.proprietaryCode, activities.duration_h] caveats: - "ROP source and rule as in A04_rop_section (DDR only; inconsistent_source when metres are stated without hours coded 'drilling -- drill')." - "Dropped (tie) when the two rates differ by no more than 2 %, the tolerance of the ROP templates." - id: C03_field_most_hours family: comparison scope: field tadi: {category: 5, subcategory: "field-wide risk ranking", fit: partial} questions: - "Across all Volve wellbores with daily drilling reports, which wellbore has the most hours of activities coded '{code}'?" slots: code: {type: string, enumerated_by: "the ten interruption codes"} slots_sql: SELECT DISTINCT proprietaryCode AS code FROM activities WHERE code_main = 'interruption' ORDER BY 1 answer_sql: | WITH h AS (SELECT wellbore, round(sum(duration_h), 4) AS h FROM activities WHERE proprietaryCode = $code GROUP BY 1) SELECT min(wellbore) AS answer, CASE WHEN count(*) > 1 THEN 'tie' END AS drop_reason FROM h WHERE h = (SELECT max(h) FROM h) evidence_sql: | WITH h AS (SELECT wellbore, round(sum(duration_h), 4) AS h FROM activities WHERE proprietaryCode = $code GROUP BY 1) SELECT 'activities' AS "table", report_id, seq FROM activities WHERE proprietaryCode = $code AND wellbore IN (SELECT wellbore FROM h WHERE h = (SELECT max(h) FROM h)) evidence_mode: all answer: type: enumeration choices: {sql: "SELECT DISTINCT wellbore FROM reports ORDER BY 1"} source: [activities.proprietaryCode, activities.duration_h] caveats: - "Field scope: the question uses every wellbore, so it belongs to no single split group and must be kept out of any fold whose test wellbores it would reveal." - "The evidence rows are the activities of the winning wellbore only." # ------------------------------------------------------------------------------------------------------------------ # Multi-hop: a value looked up at the report or depth of the first coded event, or from two header values. # ------------------------------------------------------------------------------------------------------------------ - id: M01_mud_density_at_first_event family: multi_hop tadi: {category: 5, subcategory: "mud losses and circulation; stuck pipe and tight hole", fit: direct} render: {printed: false, note: "`stateDetailActivity` is in the XML only."} questions: - "What drilling fluid density is stated in the daily drilling report of wellbore {wellbore} that contains the first activity with the state detail '{detail}'?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one activity of the state detail"} detail: {type: string, enumerated_by: "stuck equipment, circulation loss, mud loss"} slots_sql: | SELECT DISTINCT wellbore, stateDetailActivity AS detail FROM activities WHERE stateDetailActivity IN ('stuck equipment', 'circulation loss', 'mud loss') ORDER BY 1, 2 answer_sql: | WITH e AS (SELECT report_id FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1) SELECT CASE WHEN count(DISTINCT f.density) = 1 THEN min(f.density) END AS answer, CASE WHEN count(DISTINCT f.density) > 1 THEN 'ambiguous_multiple_values' WHEN min(f.density) < 0.5 OR max(f.density) > 3 THEN 'implausible_value' END AS drop_reason FROM fluids f JOIN e USING (report_id) WHERE f.density IS NOT NULL evidence_sql: | WITH e AS (SELECT report_id, seq FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1) SELECT 'activities' AS "table", report_id, seq, 'event' AS grp FROM e UNION ALL SELECT 'fluids', f.report_id, f.seq, 'fluid' FROM fluids f JOIN e USING (report_id) WHERE f.density IS NOT NULL evidence_mode: group answer: {type: number, unit: g/cm3, round: 3, tolerance: {abs: 0.01}} source: [activities.stateDetailActivity, fluids.density] caveats: - "The density of the report that holds the event, sampled at some time of that day, not at the moment of the event." - "Dropped when that report has no fluid record (null_answer) or samples of different density." - id: M02_hole_size_at_first_event family: multi_hop tadi: {category: 5, subcategory: "stuck pipe and tight hole; mud losses and circulation", fit: direct} render: {printed: false, note: "`stateDetailActivity` is in the XML only."} questions: - "What hole diameter does the daily drilling report of wellbore {wellbore} state on the day of the first activity with the state detail '{detail}'?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one activity of the state detail"} detail: {type: string, enumerated_by: "stuck equipment, circulation loss, mud loss"} slots_sql: | SELECT DISTINCT wellbore, stateDetailActivity AS detail FROM activities WHERE stateDetailActivity IN ('stuck equipment', 'circulation loss', 'mud loss') ORDER BY 1, 2 answer_sql: | WITH e AS (SELECT report_id FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1) SELECT r.diaHole AS answer FROM reports r JOIN e USING (report_id) evidence_sql: | WITH e AS (SELECT report_id, seq FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1) SELECT 'activities' AS "table", report_id, seq FROM e UNION ALL SELECT 'reports', report_id, NULL FROM e evidence_mode: all answer: {type: number, unit: in, round: 3, tolerance: {abs: 0.01}} source: [activities.stateDetailActivity, reports.diaHole] caveats: - "Dropped (null_answer) when the report of the event states no hole diameter." - id: M03_formation_at_first_event family: multi_hop tadi: {category: 5, subcategory: "stuck pipe and tight hole; mud losses and circulation", fit: partial} render: {printed: false, note: "`stateDetailActivity` is in the XML only."} questions: - "Among the formation tops listed in the 'Stratigraphic Information' of the daily drilling reports of wellbore {wellbore}, which formation has the deepest top at or above the end depth of the first activity with the state detail '{detail}'?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one activity of the state detail"} detail: {type: string, enumerated_by: "stuck equipment, circulation loss, mud loss"} slots_sql: | SELECT DISTINCT wellbore, stateDetailActivity AS detail FROM activities WHERE stateDetailActivity IN ('stuck equipment', 'circulation loss', 'mud loss') ORDER BY 1, 2 answer_sql: | WITH e AS (SELECT md FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1), c AS (SELECT rtrim(s.description, ' .') AS fm, s.mdTop FROM strat s, e WHERE s.wellbore = $wellbore AND s.mdTop <= e.md) SELECT min(fm) AS answer, CASE WHEN count(DISTINCT fm) > 1 THEN 'tie' END AS drop_reason FROM c WHERE mdTop = (SELECT max(mdTop) FROM c) evidence_sql: | WITH e AS (SELECT report_id, seq, md FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1), c AS (SELECT s.report_id, s.seq, s.mdTop FROM strat s, e WHERE s.wellbore = $wellbore AND s.mdTop <= e.md) SELECT 'activities' AS "table", report_id, seq, 'event' AS grp FROM e UNION ALL SELECT 'strat', report_id, seq, 'top' FROM c WHERE mdTop = (SELECT max(mdTop) FROM c) evidence_mode: group answer: {type: string} source: [activities.stateDetailActivity, activities.md, strat.mdTop, strat.description] caveats: - "Uses the tops the DDRs list (20 of 26 wellbores); a top below the last listed one is unknown, so the answer is the deepest listed top above the depth, not a geological interpretation." - "Dropped (null_answer) when the wellbore has no stratigraphic record or the end depth is above every top (two first events have an end depth of 0 m)." - id: M04_last_casing_at_first_event family: multi_hop tadi: {category: 5, subcategory: "stuck pipe and tight hole; mud losses and circulation", fit: partial} render: {printed: false, note: "`stateDetailActivity` is in the XML only."} questions: - "What depth of the last casing ('Depth At Last Casing mMD') does the daily drilling report of wellbore {wellbore} state on the day of the first activity with the state detail '{detail}'?" slots: wellbore: {type: wellbore, enumerated_by: "wellbores with at least one activity of the state detail"} detail: {type: string, enumerated_by: "stuck equipment, circulation loss, mud loss"} slots_sql: | SELECT DISTINCT wellbore, stateDetailActivity AS detail FROM activities WHERE stateDetailActivity IN ('stuck equipment', 'circulation loss', 'mud loss') ORDER BY 1, 2 answer_sql: | WITH e AS (SELECT report_id FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1) SELECT r.mdCsgLast AS answer FROM reports r JOIN e USING (report_id) evidence_sql: | WITH e AS (SELECT report_id, seq FROM activities WHERE wellbore = $wellbore AND stateDetailActivity = $detail ORDER BY start_utc LIMIT 1) SELECT 'activities' AS "table", report_id, seq FROM e UNION ALL SELECT 'reports', report_id, NULL FROM e evidence_mode: all answer: {type: number, unit: m, round: 2, tolerance: {abs: 1.0}} source: [activities.stateDetailActivity, reports.mdCsgLast] caveats: - "As published: the 1997-1998 reports of 15/9-19 A, B and BT2 state 4,643 m, deeper than the wellbores themselves." - id: M05_days_spud_to_deepest_md family: multi_hop tadi: {category: 2, subcategory: "drilling efficiency trends", fit: partial} questions: - "How many days lie between the spud date stated in the daily drilling reports of wellbore {wellbore} and the date of the first report that states the deepest measured depth of the wellbore? (Report date: the end of the 24 h reporting period.)" slots: wellbore: {type: wellbore, enumerated_by: "every wellbore with reports"} slots_sql: SELECT DISTINCT wellbore FROM reports ORDER BY 1 answer_sql: | WITH r AS (SELECT * FROM reports WHERE wellbore = $wellbore), t AS (SELECT min(file_date) AS d FROM r WHERE md = (SELECT max(md) FROM r)), s AS (SELECT min(substr(dTimSpud, 1, 10)) AS d, count(DISTINCT substr(dTimSpud, 1, 10)) AS n FROM r), v AS (SELECT s.n, date_diff('day', CAST(s.d AS DATE), CAST(t.d AS DATE)) AS days FROM s, t) SELECT days AS answer, CASE WHEN n > 1 THEN 'ambiguous_multiple_values' WHEN days < 0 THEN 'implausible_value' END AS drop_reason FROM v evidence_sql: | WITH r AS (SELECT * FROM reports WHERE wellbore = $wellbore), t AS (SELECT report_id FROM r WHERE md = (SELECT max(md) FROM r) ORDER BY file_date LIMIT 1) SELECT 'reports' AS "table", report_id, NULL AS seq, 'deepest' AS grp FROM t UNION ALL SELECT 'reports', report_id, NULL, 'spud' FROM r WHERE dTimSpud IS NOT NULL evidence_mode: group answer: {type: number, unit: d, round: 0, tolerance: {abs: 0}} source: [reports.dTimSpud, reports.md, reports.file_date] caveats: - "Calendar arithmetic on two published values, not drilling time. The F-slot top holes were drilled in batches and deepened later (15/9-F-1: 2,089 days), and a sidetrack may carry the spud date of its parent." - "Dropped (implausible_value) when the deepest depth is reported before the stated spud date." # ---------------------------------------------------------------------------------------------------------------------- # Planned templates: WITSML time logs, WITSML trajectory and formation tops (Well_picks_Volve_v1.dat). # Disabled until outputs/witsml/ and outputs/tops/ exist; no SQL yet. Each needs its pandas twin and a locked count. # ---------------------------------------------------------------------------------------------------------------------- planned: - id: W01_rop_section_witsml enabled: false family: aggregation needs: [outputs/witsml time logs, reports.diaHole] tadi: {category: 3, subcategory: "formation-level ROP analysis", fit: direct} question: "What is the mean on-bottom rate of penetration in the {hole} hole of wellbore {wellbore} according to the WITSML time log?" answer: {type: number, unit: m/h, tolerance: {rel: 0.05}} design: "Mean of the ROP channel over samples with bit depth = hole depth and the TADI sentinel filters, within the depth range of the hole size (L09). 14 wellbores have both DDR and time logs. Paired with A04_rop_section, it gives the DDR-WITSML consistency questions of TADI Cat. 3." - id: W02_max_inclination_trajectory enabled: false family: lookup needs: [outputs/witsml trajectory] tadi: {category: 3, subcategory: "DDR-WITSML consistency", fit: partial} question: "What is the highest inclination among the WITSML trajectory stations of wellbore {wellbore}, and at what measured depth?" answer: {type: number, unit: dega, tolerance: {abs: 0.1}} design: "Twin of L10/L11 on the trajectory object; a third template asks whether the DDR survey and the trajectory agree within 0.5 dega at the deepest common station (boolean)." - id: W03_formation_at_first_event_picks enabled: false family: multi_hop needs: [outputs/tops, activities.md] tadi: {category: 5, subcategory: "stuck pipe and tight hole; mud losses and circulation", fit: direct} question: "In which formation, by the official well picks, is the end depth of the first activity with the state detail '{detail}' in wellbore {wellbore}?" answer: {type: string} design: "As M03_formation_at_first_event with the picks of Well_picks_Volve_v1.dat instead of the tops listed in the DDRs. Needs the name mapping of 15/9-19 SR and 15/9-F-9 A; an instance is dropped when the depth is below the deepest pick." - id: W04_best_bha_run enabled: false family: aggregation needs: [outputs/witsml bhaRun, outputs/witsml time logs] tadi: {category: 4, subcategory: "best BHA run identification", fit: direct} question: "Which BHA run of wellbore {wellbore} in the {hole} hole drilled the most metres, and at what average rate of penetration?" answer: {type: enumeration} design: "Arg-max over bhaRun objects of the drilled interval; tie dropped. A second template compares the answer with the bit record of the DDR (A05) for the DDR-WITSML consistency subcategory of TADI Cat. 4." - id: W05_parameters_in_formation enabled: false family: multi_hop needs: [outputs/witsml time logs, outputs/tops] tadi: {category: 3, subcategory: "drilling parameter correlation", fit: partial} question: "What is the mean weight on bit while drilling the {formation} in wellbore {wellbore} according to the WITSML time log?" answer: {type: number, unit: kkgf, tolerance: {rel: 0.05}} design: "Mean of the WOB channel over on-bottom samples between two consecutive picks. The unit is fixed after the WITSML parser reports the channel units; the same pattern serves RPM, torque and standpipe pressure."