# Protocol v5: T5 similar-interval retrieval (optional task of plan section 4). Extends locked v4. protocol: volve-dia version: 5 status: locked drafted: 2026-11-20 locked_before: >- any retrieval or forecasting score was computed; only relevance-label counts (eligible intervals per definition, well, section and formation, and the number of fully relevant candidates per query) were inspected extends: file: configs/protocol_v4.yaml sha256: 6a9ad0fb64e319b914427e4ec58c4cfafdca91b393da9309f9b30391a12568d0 deviation: date: 2026-11-20 what: >- Plan section 4 lists T5 as optional (embedding of WITSML, DDR and formation windows; nDCG@k, MRR; PR-AUC when trouble is forecast from neighbours; leave-one-wellbore-out; relevance by rule: same hole section, same formation, same NPT group). Protocols v1 to v4 do not define it. v5 fixes items, relevance, representations, metrics and statistics before any score. The primary candidate pool excludes the query's whole well, matching the primary grouping of v1; the plan's leave-one-wellbore-out pool is a sensitivity analysis. consequence: >- T5 is a diagnostic task outside G2. The relevance labels come from the XML-derived T3 intervals, the T1 section and the formation picks, all by code. No rater is involved and no gate depends on T5. unchanged: - protocols v1 to v4 in full, including masking, T3 labels and the T1-T4 headline metrics items: unit: T3 interval (outputs/labels/t3_intervals.parquet) primary_definition: b sensitivity_definition: a eligible: >- an interval of a T3 wellbore of protocol v1 (tasks.t3.wellbores) whose md_top lies in the own hole (md_top >= own_hole_top_md of that wellbore), whose section is known and whose formation is known section: >- t1_reports.section (published or forward-filled) of the report of the interval's first activity (the act_id that sorts first); intervals whose report has no section are not eligible formation: >- the unit of the deepest formation pick with md <= interval md_top among the picks of the DDR wellbore (outputs/witsml/formation_tops.parquet, column wellbore); the unit is case-folded and the words "volve" and "sand" and the suffixes "fm." and "gp." are removed, so "Hugin Fm. VOLVE" becomes "hugin" and "Heather Fm. Sand VOLVE" becomes "heather"; intervals above the first pick are not eligible cause_set: the pipe-separated causes of the interval (derived from codes by the T3 rule; never a model input) relevance: gain: g = [same section] + [same formation] + [cause sets intersect], so g takes the values 0 to 3 fully_relevant: g = 3 candidates: primary: every eligible interval of the same definition from the other wells (leave-one-well-out) sensitivity: every eligible interval of the same definition from the other wellbores (leave-one-wellbore-out) representations: rule: >- No representation reads activity codes, causes, labels, section or formation fields. Text is the masked activity comments of table t2_inputs. Hole sizes or depths named in the text are observable context, not code leakage (as in v1 t1_hole_size). Transformations (TF-IDF vocabulary and weights, imputation medians, z-scores) are fitted on the candidate pool of each held-out group, never on the query group. random: mean of each metric over 100 random orderings of the candidates (numpy default_rng, seed 20261117) depth: absolute difference of md_top (smaller is closer) witsml_pre: >- mean and population standard deviation of HKLD, ROP, RPM and SPPA in the 24 hours before the interval's first_start_utc (end excluded; suspect values missing as in v1), the same aggregation as the T3 features; missing values replaced by the candidate-pool median, z-scored on the pool, Euclidean distance text_pre: >- TF-IDF (word 1-2 grams, min_df 1, sublinear tf) of the masked comments of the same wellbore's activities that end in [first_start_utc - 24 h, first_start_utc), joined in time order; cosine similarity text_event: >- TF-IDF as above of the masked comments of the interval's own activities. This is a description view (query by example after the event), not a forecast, and is reported separately from the pre-event representations rrf_pre: reciprocal rank fusion, sum of 1 / (60 + rank), over depth, witsml_pre and text_pre rrf_all: reciprocal rank fusion over depth, witsml_pre, text_pre and text_event ties: equal scores are ordered by one fixed random order of the candidates (numpy default_rng, seed 20261117) metrics: primary: nDCG@10 with linear gain g; the ideal ranking sorts all candidates of the query by g secondary: - MRR of the first fully relevant candidate; queries without a fully relevant candidate are left out of MRR and their number is reported - P@10, the share of fully relevant candidates among the first 10 - per-attribute share among the first 10 (same section, same formation, cause overlap), descriptive aggregation: mean over queries statistics: ci: whole-well cluster bootstrap over query wells, 2,000 resamples, seed 20261117, percentile 95% interval paired: per-query differences against random and against depth, with the same bootstrap reading: >- Descriptive, no gate. A representation is said to retrieve better than another only if the 95% interval of the paired difference excludes 0. Section and formation are both functions of depth within one field, so depth is the reference baseline. knn_forecast: purpose: the plan's PR-AUC when trouble is forecast from neighbours; secondary items: the 4,894 cells of outputs/m34/features_t3.parquet (the T3 universe of v1), label_b primary, label_a sensitivity neighbours: the k = 10 nearest cells from the other wells (leave-one-well-out); ties by row order representations: depth: md_top depth_witsml: >- md_top, depth_from_own_top and the eight witsml mean and sd columns of the T3 feature table; missing values replaced by the training-pool median, z-scored on the training pool, Euclidean distance score: mean label of the k neighbours metric: >- pooled out-of-fold average precision with a whole-well bootstrap 95% interval (2,000 resamples, seed 20261117), reported beside the prevalence and the v1 T3 baselines (majority 0.114, TF-IDF 0.123, definition b, masked) code: scripts/20_m5_t5.py, volve_dia/m5_t5.py outputs: outputs/m5/t5/