As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.
We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.
Summary
README.mdPublic entries: Python and R. Passing coverage requires an installed inventory.
Goal: add one total laboratory record per subject and visit whose
analysis value (AVAL) is the collected component results added in the
order the source records were stored, flagged with the record-type flag
(DTYPE).
Input: collected laboratory records carrying the study identifier,
subject identifier, sequence number, test code and name, visit, and
standardized result. The component values are deliberately simple
(0.1, 0.2, 0.3) so the floating-point rounding stays visible.
Variables:
PARAM: the collected test name on each component record; "Total of Components" on the new total record.AVAL: the collected result on each component record; on the total record, the component results added in stored record order. A component with no collected result contributes nothing, and a subject and visit with no collected results at all leaves the total empty rather than zero.DTYPE: empty on the collected records;CALCULATIONon the total record, marking it as calculated rather than collected.
Note: binary floating-point addition makes the total sensitive to
that order: one subject's records stored as 0.1, 0.2, 0.3 total
0.6000000000000001, while another subject's identical values stored as
0.3, 0.2, 0.1 total 0.6.
Inputs
Under review1 source fileinput/lb.csv
Edit12 rows| STUDYID | USUBJID | LBSEQ | LBTESTCD | LBTEST | VISIT | LBSTRESN |
|---|---|---|---|---|---|---|
| YAMAA-01 | 1 | COMP1 | Component 1 | WEEK 1 | 0.1 | |
| YAMAA-01 | 2 | COMP2 | Component 2 | WEEK 1 | 0.2 | |
| YAMAA-01 | 3 | COMP3 | Component 3 | WEEK 1 | 0.3 | |
| YAMAA-01 | 1 | COMP3 | Component 3 | WEEK 1 | 0.3 | |
| YAMAA-01 | 2 | COMP2 | Component 2 | WEEK 1 | 0.2 | |
| YAMAA-01 | 3 | COMP1 | Component 1 | WEEK 1 | 0.1 | |
| YAMAA-01 | 1 | COMP1 | Component 1 | WEEK 1 | 0.1 | |
| YAMAA-01 | 1 | COMP1 | Component 1 | WEEK 1 | 0.1 | |
| YAMAA-01 | 2 | COMP2 | Component 2 | WEEK 1 | — | |
| YAMAA-01 | 3 | COMP3 | Component 3 | WEEK 1 | 0.3 | |
| YAMAA-01 | 1 | COMP1 | Component 1 | WEEK 1 | — | |
| YAMAA-01 | 2 | COMP2 | Component 2 | WEEK 1 | — |
Expected output
Under review17 expected rowsexpected/adlb.csv
Edit17 rows| STUDYID | USUBJID | PARAMCD | PARAM | AVISIT | AVAL | DTYPE |
|---|---|---|---|---|---|---|
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | 0.1 | — | |
| YAMAA-01 | COMP2 | Component 2 | WEEK 1 | 0.2 | — | |
| YAMAA-01 | COMP3 | Component 3 | WEEK 1 | 0.3 | — | |
| YAMAA-01 | COMP3 | Component 3 | WEEK 1 | 0.3 | — | |
| YAMAA-01 | COMP2 | Component 2 | WEEK 1 | 0.2 | — | |
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | 0.1 | — | |
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | 0.1 | — | |
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | 0.1 | — | |
| YAMAA-01 | COMP2 | Component 2 | WEEK 1 | — | — | |
| YAMAA-01 | COMP3 | Component 3 | WEEK 1 | 0.3 | — | |
| YAMAA-01 | COMP1 | Component 1 | WEEK 1 | — | — | |
| YAMAA-01 | COMP2 | Component 2 | WEEK 1 | — | — | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | 0.6000000000000001 | CALCULATION | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | 0.6 | CALCULATION | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | 0.1 | CALCULATION | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | 0.4 | CALCULATION | |
| YAMAA-01 | TOTAL | Total of Components | WEEK 1 | — | CALCULATION |
Human review and assessment
| Dataset Name | Variable Name | Variable Label | Type | Codelist/Controlled Terms | Core | Computational Method | Origin |
|---|---|---|---|---|---|---|---|
| ADLB | STUDYID | Study Identifier | character | Copy value from LB.STUDYID. | Predecessor | ||
| ADLB | USUBJID | Unique Subject Identifier | character | Copy value from LB.USUBJID. | Predecessor | ||
| ADLB | AVISIT | Analysis Visit | character | Copy value from LB.VISIT. | Predecessor | ||
| ADLB | PARAMCD | Parameter Code | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | PARAM | Parameter | character | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | AVAL | Analysis Value | numeric | Set per constructed row; see the Row construction sheet. | Derived | ||
| ADLB | DTYPE | Derivation Type | character | Set per constructed row; see the Row construction sheet. | Derived |
| Template | Include when | PARAMCD | PARAM | AVAL | DTYPE |
|---|---|---|---|---|---|
| collected | Copy LB.LBTESTCD | Copy LB.LBTEST | Copy LB.LBSTRESN | Constant "None" | |
| total | Constant "TOTAL" | Constant "Total of Components" | Aggregate SUM(LB.LBSTRESN) over records matching on the shared output keys | Constant "CALCULATION" |
| Version | Date | Author | Description | Reviewer | Sign-off |
|---|---|---|---|---|---|
| 1.7 | 2026-10-20 | yamaa docs build | Read a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default | ||
| 1.6 | 2026-10-17 | yamaa docs build | Describe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight | ||
| 1.5 | 2026-10-17 | yamaa docs build | Name collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part | ||
| 1.4 | 2026-10-15 | yamaa docs build | State datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks | ||
| 1.3 | 2026-09-29 | yamaa docs build | Show study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata | ||
| 1.2 | 2026-09-29 | yamaa docs build | Classify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived | ||
| 1.1 | 2026-09-29 | yamaa docs build | Resolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML | ||
| 1.0 | yamaa docs build | Initial generation from spec.yaml |
prompts/adam-adlb-ordered-sum/full.md
Edit19 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per subject per parameter per visit.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE
The output holds every collected laboratory record and adds one total record for each subject and visit. On a collected record, PARAMCD is the collected test code, PARAM is the collected test name, and AVAL is the collected standardized result. On the total record, PARAMCD is TOTAL and PARAM is "Total of Components". AVAL on the total record is that subject's collected component results for the visit, added in the order the source records were stored. A component with no collected result contributes nothing to the total. When a subject and visit has no collected results at all, AVAL on the total record has no value rather than zero. AVAL is not rounded. DTYPE has no value on the collected records and is CALCULATION on the total record.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-ordered-sum/conventions.md
Edit11 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per subject per parameter per visit.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE
On the total record, PARAMCD is TOTAL and PARAM is "Total of Components". AVAL is not rounded. DTYPE is CALCULATION or has no value.
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
prompts/adam-adlb-ordered-sum/brief.md
Edit8 linesFollowing CDISC ADaM standards, use the provided LB dataset to create an ADLB dataset with one record per subject per parameter per visit.
The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE
Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.csv.
R
Edit3 lineslibrary(yamaa)yamaa_spec("spec.yaml")$run()$outputPython
Edit3 linesimport yamaayamaa.spec("spec.yaml").run().outputsolutions/adam-adlb-ordered-sum/result.R
Edit65 lines# Reference solution for the yamaa benchmark adam-adlb-ordered-sum (R track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.library(dplyr, warn.conflicts = FALSE)library(readr)lb <- read_csv( "/app/input/lb.csv", col_types = cols( LBSEQ = col_integer(), LBSTRESN = col_double(), .default = col_character() ))# Keep every collected component record; DTYPE has no value on these.components <- lb |> transmute( STUDYID, USUBJID, PARAMCD = LBTESTCD, PARAM = LBTEST, AVISIT = VISIT, AVAL = LBSTRESN, DTYPE = NA_character_ )# One total record per subject and visit: the sum of the collected# component results in laboratory sequence order. No value, rather than# zero, when none of them has a collected result.ordered_sum <- function(x) { vals <- x[!is.na(x)] if (length(vals) == 0) { return(NA_real_) } total <- vals[[1]] if (length(vals) > 1) { for (v in vals[-1]) { total <- total + v } } total}totals <- lb |> arrange(USUBJID, VISIT, LBSEQ) |> group_by(STUDYID, USUBJID, VISIT) |> summarise( AVAL = ordered_sum(LBSTRESN), .groups = "drop" ) |> mutate( PARAMCD = "TOTAL", PARAM = "Total of Components", AVISIT = VISIT, DTYPE = "CALCULATION" ) |> select(STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE)adlb <- bind_rows(components, totals)dir.create("/app/output", showWarnings = FALSE)write_csv(adlb, "/app/output/adlb.csv", na = "")solutions/adam-adlb-ordered-sum/result.py
Edit76 lines# Reference solution for the yamaa benchmark adam-adlb-ordered-sum (Python track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1."""Create ADLB from LB: every collected record plus one TOTAL recordper subject and visit, summed in the order the source records werestored."""import csvimport osINPUT_DIR = "/app/input"OUTPUT_DIR = "/app/output"COLUMNS = ["STUDYID", "USUBJID", "PARAMCD", "PARAM", "AVISIT", "AVAL", "DTYPE"]def main(): with open(os.path.join(INPUT_DIR, "lb.csv"), newline="") as f: source = list(csv.DictReader(f)) collected = [] # (group key, output row) in stored order totals = {} # group key -> running total, None until a result is seen last_index = {} # group key -> index in `collected` of its last record for row in source: key = (row["STUDYID"], row["USUBJID"], row["VISIT"]) result = (row["LBSTRESN"] or "").strip() totals.setdefault(key, None) if result != "": value = float(result) totals[key] = value if totals[key] is None else totals[key] + value collected.append( ( key, { "STUDYID": row["STUDYID"], "USUBJID": row["USUBJID"], "PARAMCD": row["LBTESTCD"], "PARAM": row["LBTEST"], "AVISIT": row["VISIT"], "AVAL": result, "DTYPE": "", }, ) ) last_index[key] = len(collected) - 1 final_rows = [] for i, (key, row) in enumerate(collected): final_rows.append(row) if last_index[key] == i: total = totals[key] final_rows.append( { "STUDYID": key[0], "USUBJID": key[1], "PARAMCD": "TOTAL", "PARAM": "Total of Components", "AVISIT": key[2], "AVAL": "" if total is None else repr(total), "DTYPE": "CALCULATION", } ) os.makedirs(OUTPUT_DIR, exist_ok=True) with open(os.path.join(OUTPUT_DIR, "adlb.csv"), "w", newline="") as f: writer = csv.DictWriter(f, fieldnames=COLUMNS) writer.writeheader() writer.writerows(final_rows)if __name__ == "__main__": main()solutions/adam-adlb-ordered-sum/result.sas
Edit32 lines/* opensas reference solution for the yamaa benchmark adam-adlb-ordered-sum. Reads the benchmark inputs and derives the requested output. Execute with the existing opensas runtime: opensas /app/output/result.sas. */data lb; length STUDYID USUBJID LBTESTCD LBTEST VISIT $1024; infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767; input STUDYID : $char1024. USUBJID : $char1024. LBSEQ LBTESTCD : $char1024. LBTEST : $char1024. VISIT : $char1024. LBSTRESN;run;data collected; length PARAMCD $16 PARAM $1024 AVISIT $1024 DTYPE $11; set lb; PARAMCD=LBTESTCD; PARAM=LBTEST; AVISIT=VISIT; AVAL=LBSTRESN;run;proc sort data=collected; by STUDYID USUBJID AVISIT LBSEQ; run;data totals; length PARAMCD $16 PARAM $1024 DTYPE $11; set collected; by STUDYID USUBJID AVISIT; if first.AVISIT then do; total=0; count=0; end; if not missing(AVAL) then do; total+AVAL; count+1; end; if last.AVISIT then do; PARAMCD='TOTAL'; PARAM='Total of Components'; DTYPE='CALCULATION'; AVAL=.; if count>0 then AVAL=total; output; end;run;data result; set collected totals; run;proc sql; create table final as select STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, DTYPE from result;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;
yamaa