{
  "id": "tfl-shell-to-ars-metadata",
  "title": "TFL shell to ARS metadata: one worked example on CDISCPILOT01 (SAP Template 5)",
  "study": {
    "name": "CDISCPILOT01 (CDISC SDTM/ADaM Pilot Project, xanomeline TTS in mild to moderate Alzheimer's disease)",
    "source_url": "https://github.com/cdisc-org/sdtm-adam-pilot-project",
    "licence_note": "Excerpts are quoted from the Statistical Analysis Plan, Appendix 9 of the CDISCPILOT01 CSR (CSR pages 417-487), and from the pilot's ADaM define.xml and ADQSADAS data, CDISC. The repository README terms require attribution to CDISC, no modification and no sale of the data; the data were used unmodified and are not redistributed here. The study is a repurposed mock submission with fictional dates, not a real filing. The SAP excerpts are shortened and are the ones used on the TLF shells page; the Template 5 text is reflowed from the PDF (columns and spacing collapsed, rows kept); the define.xml listing was written by the builder from the ADQSADAS item definitions (labels as in the file; the CHG entry shows its derivation comment because the file gives CHG the label 'Baseline Value'; the TRTP and TRTPN values come from the data, not from define.xml). The ARS schema and model are CDISC's: https://github.com/cdisc-org/analysis-results-standard (MIT for code and scripts, CC BY 4.0 for content, per its README; v1.0 per cdisc.org, repository HEAD bbebea4, 2026-04-28). The schema file is not copied into this project; run B saw only a short extract of property names and enum values. Not legal advice."
  },
  "task": "Turn a SAP table shell (Template 5, the primary efficacy table: ADAS-Cog 11 change from baseline at Week 24, ANCOVA) into CDISC Analysis Results Standard (ARS) v1.0 JSON metadata, then validate the JSON against the real ARS schema and check its content against the SAP text, the define.xml and the pilot data. Nothing in this example is invented: the dataset and variable bindings come from the pilot's own define.xml listing, not from the SAP, which predates ARS.",
  "time_to_try_minutes": {
    "value": 25,
    "label": "estimate: paste excerpts and prompt, then clone the ARS repository and run the validation script on the reply"
  },
  "good": {
    "input_excerpt": "[SAP 1.2, p.5] The treatment groups referred to throughout the pilot submission will be \"xanomeline high dose,\" \"xanomeline low dose,\" and \"placebo\".\n\n[SAP 6, p.8] Efficacy population: All patients who were randomized and took drug, and have at least 1 post-baseline measure for both ADAS-Cog and CIBIC+\n\n[SAP 7, p.8] All statistical tests will be 2-sided with a significance level of 0.05. Summary statistics for continuous variables will include the number of observations, mean, standard deviation, median, minimum, and maximum.\n\n[SAP 8.1, p.9] Missing postbaseline efficacy values will be imputed using last observation carried forward (LOCF).\n\n[SAP 10.1.1, p.13] The primary analysis of the ADAS-Cog (11) at Week 24 will use the efficacy population with LOCF imputation for any missing values at Week 24. For each of these analyses, an ANCOVA model will be used with the baseline score, site, and treatment included as independent variables. Treatment will be included as a continuous variable, and results for a test of dose response will be produced. Interaction terms will not be investigated. If the test for dose response is statistically significant, pairwise comparisons among the 3 groups will be performed and evaluated at a significance level of 0.05.\n\n[SAP 13.2, Template 5, p.23] Population: Efficacy\nADAS Cog (11) - Change from Baseline to Week xx - LOCF\nColumns: Placebo (N=xxx) | Xanomeline Low Dose (N=xxx) | Xanomeline High Dose (N=xxx)\nBaseline: N; Mean (SD) xx.x (xx.xx); Median (Range) xx.x (xx;xxx)\nWeek xx: N; Mean (SD); Median (Range)\nChange from Baseline: N; Mean (SD); Median (Range)\nP-value(Dose Response) [1][2]  x.xxx\nP-value(Xan - Placebo) [1][3]  x.xxx (low), x.xxx (high)\n  Diff. of LS Means (SE) xx.x(x.xx); 95% CI (xx.xx;xx.xx)\nP-value(Xan High - Xan Low) [1][3]  x.xxx\n  Diff. of LS Means (SE) xx.x(x.xx); 95% CI (xx.xx;xx.xx)\n[1] Based on Analysis of covariance (ANCOVA) model with treatment and site as factors, and baseline ADAS Cog (11) value as a covariate.\n[2] Test for a non-zero coefficient for treatment (dose) as a continuous variable.\n[3] Pairwise comparison with treatment as a categorical variable: p-values without adjustment for multiple comparisons.\n\n[ADaM define.xml (CDISC pilot, adam_define.xml), dataset ADQSADAS, \"ADAS-Cog Analysis\", class BDS, one record per subject per parameter per analysis visit per analysis date]\nVariables: SITEID \"Study Site Identifier\"; TRTP \"Planned Treatment\" (values Placebo, Xanomeline Low Dose, Xanomeline High Dose); TRTPN \"Planned Treatment (N)\" (0, 54, 81); EFFFL \"Efficacy Population Flag\" (Y/N); AVISIT \"Analysis Visit\"; AVISITN \"Analysis Visit (N)\"; PARAMCD \"Parameter Code\" (ACTOT = \"Adas-Cog(11) Subscore\"); AVAL \"Analysis Value\"; BASE \"Baseline Value\"; CHG \"AVAL - BASE\"; ANL01FL \"Analysis Record Flag 01\" (Y or blank); DTYPE \"Derivation Type\" (LOCF = Last Observation Carried Forward, or blank).",
    "prompt": "From the excerpts above, write the CDISC Analysis Results Standard (ARS) v1.0 reporting event JSON for this one display: Template 5 run for Week 24 (the ADAS-Cog (11) change from baseline table). Return one JSON object (the ReportingEvent), then a list of everything you could not determine from the excerpts. Include the analysis set, the treatment grouping with its three groups, any data subsets, the analysis methods with their operations, the analyses (baseline, Week 24 and change summaries; dose response; pairwise comparisons), the output and its display, and the list of contents. Bind datasets and variables only from the define.xml extract. Do not add analyses the excerpts do not support; if you add something from habit, say so in its description. Use the ARS property names as you know them, and say where you are unsure of one.",
    "output": "```json\n{\n  \"id\": \"RE_CDISCPILOT01_T5_ADAS_WK24\",\n  \"name\": \"CDISCPILOT01 Template 5, ADAS-Cog (11) change from baseline to Week 24, LOCF\",\n  \"version\": \"1\",\n  \"label\": \"SAP Template 5 run for Week 24\",\n  \"description\": \"Reporting event for one display only: SAP 13.2 Template 5 with xx = 24. Source: SAP sections 1.2, 6, 7, 8.1, 10.1.1, 13.2 and the ADQSADAS define.xml extract.\",\n  \"referenceDocuments\": [\n    {\"id\": \"RD_SAP\", \"name\": \"Statistical Analysis Plan\", \"location\": \"not given in excerpts\"}\n  ],\n  \"analysisSets\": [\n    {\n      \"id\": \"AS_EFF\",\n      \"name\": \"Efficacy population\",\n      \"label\": \"Efficacy\",\n      \"level\": 1,\n      \"order\": 1,\n      \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"EFFFL\", \"comparator\": \"EQ\", \"value\": [\"Y\"]}\n    }\n  ],\n  \"analysisGroupings\": [\n    {\n      \"id\": \"AnlsGrouping_TRTP\",\n      \"name\": \"Planned treatment\",\n      \"label\": \"Treatment group\",\n      \"groupingDataset\": \"ADQSADAS\",\n      \"groupingVariable\": \"TRTP\",\n      \"dataDriven\": false,\n      \"groups\": [\n        {\"id\": \"Grp_Pbo\", \"name\": \"Placebo\", \"label\": \"Placebo\", \"level\": 1, \"order\": 1,\n         \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"TRTP\", \"comparator\": \"EQ\", \"value\": [\"Placebo\"]}},\n        {\"id\": \"Grp_XanLow\", \"name\": \"Xanomeline Low Dose\", \"label\": \"Xanomeline Low Dose\", \"level\": 1, \"order\": 2,\n         \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"TRTP\", \"comparator\": \"EQ\", \"value\": [\"Xanomeline Low Dose\"]}},\n        {\"id\": \"Grp_XanHigh\", \"name\": \"Xanomeline High Dose\", \"label\": \"Xanomeline High Dose\", \"level\": 1, \"order\": 3,\n         \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"TRTP\", \"comparator\": \"EQ\", \"value\": [\"Xanomeline High Dose\"]}}\n      ]\n    }\n  ],\n  \"dataSubsets\": [\n    {\n      \"id\": \"DS_ACTOT_WK24\",\n      \"name\": \"ADAS-Cog (11) total score at Week 24\",\n      \"label\": \"ACTOT, Week 24\",\n      \"level\": 1,\n      \"order\": 1,\n      \"compoundExpression\": {\n        \"logicalOperator\": \"AND\",\n        \"whereClauses\": [\n          {\"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"PARAMCD\", \"comparator\": \"EQ\", \"value\": [\"ACTOT\"]}},\n          {\"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"AVISITN\", \"comparator\": \"EQ\", \"value\": [\"24\"]}}\n        ]\n      }\n    },\n    {\n      \"id\": \"DS_PW_LOW_PBO\",\n      \"name\": \"Comparison: Xanomeline Low Dose vs Placebo\",\n      \"label\": \"Low vs Placebo\",\n      \"level\": 1,\n      \"order\": 2,\n      \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"TRTP\", \"comparator\": \"IN\", \"value\": [\"Placebo\", \"Xanomeline Low Dose\"]}\n    },\n    {\n      \"id\": \"DS_PW_HIGH_PBO\",\n      \"name\": \"Comparison: Xanomeline High Dose vs Placebo\",\n      \"label\": \"High vs Placebo\",\n      \"level\": 1,\n      \"order\": 3,\n      \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"TRTP\", \"comparator\": \"IN\", \"value\": [\"Placebo\", \"Xanomeline High Dose\"]}\n    },\n    {\n      \"id\": \"DS_PW_HIGH_LOW\",\n      \"name\": \"Comparison: Xanomeline High Dose vs Xanomeline Low Dose\",\n      \"label\": \"High vs Low\",\n      \"level\": 1,\n      \"order\": 4,\n      \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"TRTP\", \"comparator\": \"IN\", \"value\": [\"Xanomeline Low Dose\", \"Xanomeline High Dose\"]}\n    }\n  ],\n  \"methods\": [\n    {\n      \"id\": \"MTH_SUMM\",\n      \"name\": \"Summary statistics for a continuous variable\",\n      \"label\": \"Continuous summary\",\n      \"description\": \"SAP 7: number of observations, mean, SD, median, minimum, maximum. Template 5 shows N; Mean (SD); Median (Range).\",\n      \"operations\": [\n        {\"id\": \"MTH_SUMM_1_n\", \"name\": \"n\", \"label\": \"n\", \"order\": 1, \"resultPattern\": \"XXX\"},\n        {\"id\": \"MTH_SUMM_2_mean\", \"name\": \"Mean\", \"label\": \"Mean\", \"order\": 2, \"resultPattern\": \"XX.X\"},\n        {\"id\": \"MTH_SUMM_3_sd\", \"name\": \"Standard deviation\", \"label\": \"SD\", \"order\": 3, \"resultPattern\": \"XX.XX\"},\n        {\"id\": \"MTH_SUMM_4_median\", \"name\": \"Median\", \"label\": \"Median\", \"order\": 4, \"resultPattern\": \"XX.X\"},\n        {\"id\": \"MTH_SUMM_5_min\", \"name\": \"Minimum\", \"label\": \"Min\", \"order\": 5, \"resultPattern\": \"XX\"},\n        {\"id\": \"MTH_SUMM_6_max\", \"name\": \"Maximum\", \"label\": \"Max\", \"order\": 6, \"resultPattern\": \"XXX\"}\n      ]\n    },\n    {\n      \"id\": \"MTH_ANCOVA_DOSERESP\",\n      \"name\": \"ANCOVA dose-response test\",\n      \"label\": \"ANCOVA, treatment as continuous\",\n      \"description\": \"ANCOVA with baseline ADAS-Cog (11) (BASE) as covariate, SITEID as factor, and treatment (dose, continuous; TRTPN assumed) as the term of interest. Test of a non-zero coefficient for dose. 2-sided, alpha 0.05. No interaction terms (SAP 10.1.1).\",\n      \"operations\": [\n        {\"id\": \"MTH_ANCOVA_DOSERESP_1_pval\", \"name\": \"p-value (dose response)\", \"label\": \"P-value (Dose Response)\", \"order\": 1, \"resultPattern\": \"X.XXX\"}\n      ]\n    },\n    {\n      \"id\": \"MTH_ANCOVA_PAIRWISE\",\n      \"name\": \"ANCOVA pairwise comparison\",\n      \"label\": \"ANCOVA, treatment as categorical\",\n      \"description\": \"ANCOVA with baseline ADAS-Cog (11) (BASE) as covariate, SITEID and treatment (categorical) as factors. Pairwise difference of LS means, 2-sided, alpha 0.05, no multiplicity adjustment. SAP 10.1.1 says pairwise tests are done only if the dose-response test is significant; that gating is not encoded as an operation.\",\n      \"operations\": [\n        {\"id\": \"MTH_ANCOVA_PAIRWISE_1_pval\", \"name\": \"p-value (pairwise)\", \"label\": \"P-value\", \"order\": 1, \"resultPattern\": \"X.XXX\"},\n        {\"id\": \"MTH_ANCOVA_PAIRWISE_2_diff\", \"name\": \"Difference of LS means\", \"label\": \"Diff. of LS Means\", \"order\": 2, \"resultPattern\": \"XX.X\"},\n        {\"id\": \"MTH_ANCOVA_PAIRWISE_3_se\", \"name\": \"Standard error of difference\", \"label\": \"SE\", \"order\": 3, \"resultPattern\": \"X.XX\"},\n        {\"id\": \"MTH_ANCOVA_PAIRWISE_4_lcl\", \"name\": \"95% CI lower limit\", \"label\": \"95% CI lower\", \"order\": 4, \"resultPattern\": \"XX.XX\"},\n        {\"id\": \"MTH_ANCOVA_PAIRWISE_5_ucl\", \"name\": \"95% CI upper limit\", \"label\": \"95% CI upper\", \"order\": 5, \"resultPattern\": \"XX.XX\"}\n      ]\n    }\n  ],\n  \"analyses\": [\n    {\n      \"id\": \"AN_N_EFF\",\n      \"name\": \"Number of subjects per group (column header N)\",\n      \"version\": 1,\n      \"description\": \"Supports the (N=xxx) column headers. Added because the template shows N in headers; the excerpts do not say how N is counted. No variable is bound because the subject identifier is not in the define.xml extract.\",\n      \"dataset\": \"ADQSADAS\",\n      \"analysisSetId\": \"AS_EFF\",\n      \"dataSubsetId\": \"DS_ACTOT_WK24\",\n      \"orderedGroupings\": [{\"order\": 1, \"resultsByGroup\": true, \"groupingId\": \"AnlsGrouping_TRTP\"}],\n      \"methodId\": \"MTH_SUMM\",\n      \"referencedAnalysisOperations\": [{\"referencedOperationRelationshipId\": \"n_only\", \"analysisId\": \"AN_N_EFF\"}]\n    },\n    {\n      \"id\": \"AN_BASE_SUMM\",\n      \"name\": \"Baseline ADAS-Cog (11) summary\",\n      \"version\": 1,\n      \"description\": \"Baseline summary: N; Mean (SD); Median (Range). Uses BASE on the Week 24 records.\",\n      \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"},\n      \"dataset\": \"ADQSADAS\",\n      \"variable\": \"BASE\",\n      \"analysisSetId\": \"AS_EFF\",\n      \"dataSubsetId\": \"DS_ACTOT_WK24\",\n      \"orderedGroupings\": [{\"order\": 1, \"resultsByGroup\": true, \"groupingId\": \"AnlsGrouping_TRTP\"}],\n      \"methodId\": \"MTH_SUMM\"\n    },\n    {\n      \"id\": \"AN_WK24_SUMM\",\n      \"name\": \"Week 24 ADAS-Cog (11) summary (LOCF)\",\n      \"version\": 1,\n      \"description\": \"Week 24 value summary: N; Mean (SD); Median (Range). LOCF per SAP 8.1 and 10.1.1.\",\n      \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"},\n      \"dataset\": \"ADQSADAS\",\n      \"variable\": \"AVAL\",\n      \"analysisSetId\": \"AS_EFF\",\n      \"dataSubsetId\": \"DS_ACTOT_WK24\",\n      \"orderedGroupings\": [{\"order\": 1, \"resultsByGroup\": true, \"groupingId\": \"AnlsGrouping_TRTP\"}],\n      \"methodId\": \"MTH_SUMM\"\n    },\n    {\n      \"id\": \"AN_CHG_SUMM\",\n      \"name\": \"Change from baseline to Week 24 summary (LOCF)\",\n      \"version\": 1,\n      \"description\": \"Change from baseline summary: N; Mean (SD); Median (Range).\",\n      \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"},\n      \"dataset\": \"ADQSADAS\",\n      \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\",\n      \"dataSubsetId\": \"DS_ACTOT_WK24\",\n      \"orderedGroupings\": [{\"order\": 1, \"resultsByGroup\": true, \"groupingId\": \"AnlsGrouping_TRTP\"}],\n      \"methodId\": \"MTH_SUMM\"\n    },\n    {\n      \"id\": \"AN_DOSERESP\",\n      \"name\": \"Dose-response test, change from baseline at Week 24\",\n      \"version\": 1,\n      \"description\": \"Test of non-zero coefficient for treatment (dose) as a continuous variable (footnote [2]). Response variable CHG is an assumption (see list below).\",\n      \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"},\n      \"dataset\": \"ADQSADAS\",\n      \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\",\n      \"dataSubsetId\": \"DS_ACTOT_WK24\",\n      \"methodId\": \"MTH_ANCOVA_DOSERESP\"\n    },\n    {\n      \"id\": \"AN_PW_LOW_PBO\",\n      \"name\": \"Pairwise: Xanomeline Low Dose - Placebo\",\n      \"version\": 1,\n      \"description\": \"P-value, difference of LS means (SE) and 95% CI (footnote [3]).\",\n      \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"},\n      \"dataset\": \"ADQSADAS\",\n      \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\",\n      \"dataSubsetId\": \"DS_PW_LOW_PBO\",\n      \"methodId\": \"MTH_ANCOVA_PAIRWISE\"\n    },\n    {\n      \"id\": \"AN_PW_HIGH_PBO\",\n      \"name\": \"Pairwise: Xanomeline High Dose - Placebo\",\n      \"version\": 1,\n      \"description\": \"P-value, difference of LS means (SE) and 95% CI (footnote [3]).\",\n      \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"},\n      \"dataset\": \"ADQSADAS\",\n      \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\",\n      \"dataSubsetId\": \"DS_PW_HIGH_PBO\",\n      \"methodId\": \"MTH_ANCOVA_PAIRWISE\"\n    },\n    {\n      \"id\": \"AN_PW_HIGH_LOW\",\n      \"name\": \"Pairwise: Xanomeline High Dose - Xanomeline Low Dose\",\n      \"version\": 1,\n      \"description\": \"P-value, difference of LS means (SE) and 95% CI (footnote [3]).\",\n      \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"},\n      \"dataset\": \"ADQSADAS\",\n      \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\",\n      \"dataSubsetId\": \"DS_PW_HIGH_LOW\",\n      \"methodId\": \"MTH_ANCOVA_PAIRWISE\"\n    }\n  ],\n  \"outputs\": [\n    {\n      \"id\": \"OUT_T5_ADAS_WK24\",\n      \"name\": \"ADAS Cog (11) - Change from Baseline to Week 24 - LOCF\",\n      \"version\": \"1\",\n      \"fileSpecifications\": [{\"name\": \"Output file\", \"fileType\": {\"controlledTerm\": \"rtf\"}, \"location\": \"not given in excerpts\"}],\n      \"displays\": [\n        {\n          \"order\": 1,\n          \"display\": {\n            \"id\": \"DISP_T5_ADAS_WK24\",\n            \"name\": \"Template 5, Week 24\",\n            \"version\": \"1\",\n            \"displayTitle\": \"ADAS Cog (11) - Change from Baseline to Week 24 - LOCF\",\n            \"displaySections\": [\n              {\"sectionType\": \"Title\", \"orderedSubSections\": [\n                {\"order\": 1, \"subSection\": {\"id\": \"SS_T1\", \"text\": \"Population: Efficacy\"}},\n                {\"order\": 2, \"subSection\": {\"id\": \"SS_T2\", \"text\": \"ADAS Cog (11) - Change from Baseline to Week 24 - LOCF\"}}\n              ]},\n              {\"sectionType\": \"Header\", \"orderedSubSections\": [\n                {\"order\": 1, \"subSection\": {\"id\": \"SS_H1\", \"text\": \"Columns: Placebo (N=xxx) | Xanomeline Low Dose (N=xxx) | Xanomeline High Dose (N=xxx)\"}}\n              ]},\n              {\"sectionType\": \"Footnote\", \"orderedSubSections\": [\n                {\"order\": 1, \"subSection\": {\"id\": \"SS_F1\", \"text\": \"[1] Based on Analysis of covariance (ANCOVA) model with treatment and site as factors, and baseline ADAS Cog (11) value as a covariate.\"}},\n                {\"order\": 2, \"subSection\": {\"id\": \"SS_F2\", \"text\": \"[2] Test for a non-zero coefficient for treatment (dose) as a continuous variable.\"}},\n                {\"order\": 3, \"subSection\": {\"id\": \"SS_F3\", \"text\": \"[3] Pairwise comparison with treatment as a categorical variable: p-values without adjustment for multiple comparisons.\"}}\n              ]}\n            ]\n          }\n        }\n      ]\n    }\n  ],\n  \"mainListOfContents\": {\n    \"name\": \"Main list of contents\",\n    \"label\": \"Efficacy tables\",\n    \"contentsList\": {\n      \"listItems\": [\n        {\n          \"name\": \"ADAS Cog (11) - Change from Baseline to Week 24 - LOCF\",\n          \"level\": 1,\n          \"order\": 1,\n          \"outputId\": \"OUT_T5_ADAS_WK24\",\n          \"sublist\": {\n            \"listItems\": [\n              {\"name\": \"Column header N\", \"level\": 2, \"order\": 1, \"analysisId\": \"AN_N_EFF\"},\n              {\"name\": \"Baseline\", \"level\": 2, \"order\": 2, \"analysisId\": \"AN_BASE_SUMM\"},\n              {\"name\": \"Week 24\", \"level\": 2, \"order\": 3, \"analysisId\": \"AN_WK24_SUMM\"},\n              {\"name\": \"Change from Baseline\", \"level\": 2, \"order\": 4, \"analysisId\": \"AN_CHG_SUMM\"},\n              {\"name\": \"P-value (Dose Response)\", \"level\": 2, \"order\": 5, \"analysisId\": \"AN_DOSERESP\"},\n              {\"name\": \"P-value (Xan Low - Placebo)\", \"level\": 2, \"order\": 6, \"analysisId\": \"AN_PW_LOW_PBO\"},\n              {\"name\": \"P-value (Xan High - Placebo)\", \"level\": 2, \"order\": 7, \"analysisId\": \"AN_PW_HIGH_PBO\"},\n              {\"name\": \"P-value (Xan High - Xan Low)\", \"level\": 2, \"order\": 8, \"analysisId\": \"AN_PW_HIGH_LOW\"}\n            ]\n          }\n        }\n      ]\n    }\n  }\n}\n```\n\n**Could not determine from the excerpts**\n\n1. Baseline visit: the define.xml extract does not give the AVISIT/AVISITN value for baseline. I summarised baseline from BASE on the Week 24 records. That means baseline N equals the number of subjects with a Week 24 record, which may differ from the true baseline N.\n2. Week 24 coding: AVISITN = 24 is inferred from \"Week 24\". The AVISIT text value is not given. The excerpts don't say whether LOCF records (DTYPE = LOCF) are already carried at AVISITN 24.\n3. ANL01FL: I left it out of the subsets. The excerpts don't say the table uses it. Adding `ANL01FL EQ Y` would have been from habit.\n4. Continuous treatment variable: SAP says \"continuous\" but does not name the variable. I assumed TRTPN (0, 54, 81). The dose-response method names it only in its description. It is not bound to an analysis variable or grouping.\n5. Response variable: the SAP says ANCOVA but not whether the response is CHG or AVAL with baseline as covariate. I assumed CHG because of the table title.\n6. N counts: the (N=xxx) headers need a subject identifier. USUBJID is not in the extract, so AN_N_EFF has no variable. I added this analysis because the template shows N. The excerpts don't define the counting rule. The `referencedAnalysisOperations` on it is a placeholder and needs a proper operation relationship.\n7. Pairwise model: the excerpts don't say whether pairwise differences come from the 3-group model or from separate 2-group fits. I used data subsets to identify each pair. In ARS terms that restricts the data and so implies 2-group fits. This may not match the intent.\n8. Gating: SAP 10.1.1 says pairwise tests are done only if the dose-response test is significant. Template 5 prints all p-values. ARS has no clean way to encode the gate, so I left it out. I also don't know whether the table shows pairwise results when the gate fails.\n9. Not stated: how the table shows LS means, rounding rules, the output file name and type, and the program or code references. Dataset-level LOCF imputation (SAP 8.1) is not modelled as a method.\n10. Median (Range) and Min/Max: the template pattern \"xx;xxx\" is taken as min;max. The operations are present, but the exact format is not specified beyond the template.\n\n**Unsure of ARS v1.0 property names**\n\n- Unsure: `analysisGroupings` vs `dataGroupings` at the top level, and `groupingDataset`.\n- Unsure: `compoundExpression` / `whereClauses` / `logicalOperator` for combined conditions. I'm fairly sure of the `condition` fields (dataset, variable, comparator, value).\n- Unsure: `reason` and `purpose` as controlled-term objects. The term strings \"SPECIFIED IN SAP\" and \"PRIMARY OUTCOME MEASURE\" are from memory.\n- Unsure: `orderedGroupings` entries with `order`, `resultsByGroup` and `groupingId`.\n- Unsure: the display structure `displays` → `display` → `displaySections` → `orderedSubSections` → `subSection`, and the `sectionType` terms (Title, Header, Footnote).\n- Unsure: `fileSpecifications` and `fileType`.\n- Unsure: `mainListOfContents` → `contentsList` → `listItems`, with `sublist`, `outputId` and `analysisId`. I'm not certain how analyses attach to a display beyond the list of contents.\n- Unsure: `referenceDocuments`.\n- Not in ARS from my knowledge: nothing here sets significance level 0.05 or the 95% CI level as a formal parameter. They appear only in method descriptions.",
    "trim_note": "Run A, not trimmed: the complete reply as returned (JSON plus its two lists), saved verbatim from the sub-agent's hand-back. Nothing was edited. Run B (the same excerpt and prompt, plus a short schema extract) is saved beside it in variant_with_schema. One run of each, so a difference between them may be sampling noise.",
    "contamination_note": "Cold runs, 2026-10-21: two fresh Claude sub-agents (model sonnet), each given only the text shown and told to use no tools and no files (an instruction, not harness-enforced; the harness logged one tool call per run, probably the hand-back). The builder had read the TLF page and the SAP templates before choosing the excerpt, and the ARS repository holds pilot examples that a model may know. The SAP excerpts are the ones used on the TLF shells page, plus Template 5 as reflowed text.",
    "variant_with_schema": {
      "added_input": "ARS v1.0 JSON schema extract (cdisc-org/analysis-results-standard, model/ars_ldm.json; property names only, additional properties are not allowed). 'required' lists must be present.\n\nReportingEvent (root): required ['id', 'mainListOfContents', 'name']; properties ['analyses', 'analysisGroupings', 'analysisOutputCategorizations', 'analysisSets', 'dataSubsets', 'description', 'globalDisplaySections', 'id', 'label', 'mainListOfContents', 'methods', 'name', 'otherListsOfContents', 'outputs', 'referenceDocuments', 'terminologyExtensions', 'version']\nAnalysis: required ['id', 'reason', 'purpose', 'methodId', 'name']; properties ['analysisSetId', 'categoryIds', 'dataSubsetId', 'dataset', 'description', 'documentRefs', 'id', 'label', 'methodId', 'name', 'orderedGroupings', 'programmingCode', 'purpose', 'reason', 'referencedAnalysisOperations', 'results', 'variable', 'version']\nAnalysisSet: required ['id', 'name', 'level', 'order']; properties ['compoundExpression', 'condition', 'description', 'id', 'label', 'level', 'name', 'order']\nDataSubset: required ['id', 'name', 'level', 'order']; properties ['compoundExpression', 'condition', 'description', 'id', 'label', 'level', 'name', 'order']\nWhereClauseCondition: required []; properties ['comparator', 'dataset', 'value', 'variable']\nCompoundSetExpression: required ['logicalOperator']; properties ['logicalOperator', 'whereClauses']\nCompoundSubsetExpression: required ['logicalOperator']; properties ['logicalOperator', 'whereClauses']\nGroupingFactor: required ['id', 'dataDriven', 'name']; properties ['dataDriven', 'description', 'groupingDataset', 'groupingVariable', 'groups', 'id', 'label', 'name']\nGroup: required ['id', 'name', 'level', 'order']; properties ['compoundExpression', 'condition', 'description', 'id', 'label', 'level', 'name', 'order']\nAnalysisMethod: required ['id', 'operations', 'name']; properties ['codeTemplate', 'description', 'documentRefs', 'id', 'label', 'name', 'operations']\nOperation: required ['id', 'order', 'name']; properties ['description', 'id', 'label', 'name', 'order', 'referencedOperationRelationships', 'resultPattern']\nOutput: required ['id', 'displays', 'name']; properties ['categoryIds', 'description', 'displays', 'documentRefs', 'fileSpecifications', 'id', 'label', 'name', 'programmingCode', 'version']\nOutputDisplay: required ['id', 'name']; properties ['description', 'displaySections', 'displayTitle', 'id', 'label', 'name', 'version']\nDisplaySection: required []; properties ['orderedSubSections', 'sectionType']\nDisplaySubSection: required ['id', 'text']; properties ['id', 'text']\nListOfContents: required ['contentsList', 'name']; properties ['contentsList', 'description', 'label', 'name']\nNestedList: required []; properties ['listItems']\nOrderedListItem: required ['level', 'order', 'name']; properties ['analysisId', 'description', 'label', 'level', 'name', 'order', 'outputId', 'sublist']\nOrderedGroupingFactor: required ['order', 'groupingId', 'resultsByGroup']; properties ['groupingId', 'order', 'resultsByGroup']\nOrderedDisplay: required ['order', 'display']; properties ['display', 'order']\nOrderedSubSection: required ['order', 'subSection']; properties ['order', 'subSection', 'subSectionId']\nReferenceDocument: required ['id', 'name']; properties ['description', 'id', 'label', 'location', 'name']\nDocumentReference: required ['referenceDocumentId']; properties ['pageRefs', 'referenceDocumentId']\nAnalysisOutputCategorization: required ['id', 'categories']; properties ['categories', 'id', 'label']\nAnalysisOutputCategory: required ['id']; properties ['id', 'label', 'subCategorizations']\nAnalysisPurpose: required ['controlledTerm']; properties ['controlledTerm', 'sponsorTermId']\nAnalysisReason: required ['controlledTerm']; properties ['controlledTerm', 'sponsorTermId']\nOutputFile: required ['name']; properties ['description', 'fileType', 'label', 'location', 'name', 'style']\nConditionComparatorEnum values: ['EQ', 'NE', 'GT', 'GE', 'LT', 'LE', 'IN', 'NOTIN']\nExpressionLogicalOperatorEnum values: ['AND', 'OR', 'NOT']\nDisplaySectionTypeEnum values: ['Header', 'Title', 'Rowlabel Header', 'Legend', 'Abbreviation', 'Footnote', 'Footer']\nAnalysisPurposeEnum values: ['PRIMARY OUTCOME MEASURE', 'SECONDARY OUTCOME MEASURE', 'EXPLORATORY OUTCOME MEASURE']\nAnalysisReasonEnum values: ['SPECIFIED IN PROTOCOL', 'SPECIFIED IN SAP', 'DATA DRIVEN', 'REQUESTED BY REGULATORY AGENCY']\nOperationRoleEnum values: ['NUMERATOR', 'DENOMINATOR']",
      "prompt": "From the excerpts above, write the CDISC Analysis Results Standard (ARS) v1.0 reporting event JSON for this one display: Template 5 run for Week 24 (the ADAS-Cog (11) change from baseline table). Return one JSON object (the ReportingEvent) that follows the schema extract, then a list of everything you could not determine from the excerpts. Include the analysis set, the treatment grouping with its three groups, any data subsets, the analysis methods with their operations, the analyses (baseline, Week 24 and change summaries; dose response; pairwise comparisons), the output and its display, and the list of contents. Bind datasets and variables only from the define.xml extract. Do not add analyses the excerpts do not support; if you add something from habit, say so in its description.",
      "output": "```json\n{\n  \"id\": \"RE_CDISCPILOT01_T5_WK24\",\n  \"name\": \"CDISC Pilot - ADAS-Cog (11) Change from Baseline to Week 24 - LOCF (SAP Template 5)\",\n  \"label\": \"SAP Template 5, Week 24\",\n  \"version\": \"1\",\n  \"description\": \"Reporting event for one display: SAP section 13.2 Template 5 run for Week 24. Source: SAP 1.2, 6, 7, 8.1, 10.1.1, 13.2 (p.23); ADaM define.xml dataset ADQSADAS.\",\n  \"referenceDocuments\": [\n    {\"id\": \"RD_SAP\", \"name\": \"Statistical Analysis Plan (CDISC pilot)\", \"description\": \"Sections 1.2, 6, 7, 8.1, 10.1.1 (p.8, p.13) and 13.2 Template 5 (p.23).\"},\n    {\"id\": \"RD_DEFINE\", \"name\": \"ADaM define.xml (adam_define.xml)\", \"description\": \"Source of all dataset and variable bindings (ADQSADAS).\"}\n  ],\n  \"analysisSets\": [\n    {\n      \"id\": \"AS_EFF\", \"name\": \"Efficacy Population\", \"label\": \"Efficacy\", \"level\": 1, \"order\": 1,\n      \"description\": \"SAP 6: all patients randomized and took drug, with at least 1 post-baseline measure for both ADAS-Cog and CIBIC+. Bound to the ADQSADAS flag EFFFL = Y (assumed to implement this definition).\",\n      \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"EFFFL\", \"comparator\": \"EQ\", \"value\": [\"Y\"]}\n    }\n  ],\n  \"dataSubsets\": [\n    {\n      \"id\": \"DS_ACTOT_WK24\", \"name\": \"ADAS-Cog (11) total, Week 24\", \"label\": \"ACTOT, Week 24\", \"level\": 1, \"order\": 1,\n      \"description\": \"ADAS-Cog (11) total score records at the Week 24 analysis visit. The AVISIT value 'Week 24' is an assumption (taken from the template wording); the define.xml extract does not list AVISIT values.\",\n      \"compoundExpression\": {\n        \"logicalOperator\": \"AND\",\n        \"whereClauses\": [\n          {\"level\": 1, \"order\": 1, \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"PARAMCD\", \"comparator\": \"EQ\", \"value\": [\"ACTOT\"]}},\n          {\"level\": 1, \"order\": 2, \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"AVISIT\", \"comparator\": \"EQ\", \"value\": [\"Week 24\"]}}\n        ]\n      }\n    }\n  ],\n  \"analysisGroupings\": [\n    {\n      \"id\": \"GF_TRT\", \"name\": \"Planned Treatment\", \"label\": \"Treatment group\", \"dataDriven\": false,\n      \"description\": \"Three treatment groups in template column order (SAP 1.2, Template 5). Bound to TRTP.\",\n      \"groupingDataset\": \"ADQSADAS\", \"groupingVariable\": \"TRTP\",\n      \"groups\": [\n        {\"id\": \"GRP_PBO\", \"name\": \"Placebo\", \"level\": 1, \"order\": 1, \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"TRTP\", \"comparator\": \"EQ\", \"value\": [\"Placebo\"]}},\n        {\"id\": \"GRP_XLOW\", \"name\": \"Xanomeline Low Dose\", \"level\": 1, \"order\": 2, \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"TRTP\", \"comparator\": \"EQ\", \"value\": [\"Xanomeline Low Dose\"]}},\n        {\"id\": \"GRP_XHIGH\", \"name\": \"Xanomeline High Dose\", \"level\": 1, \"order\": 3, \"condition\": {\"dataset\": \"ADQSADAS\", \"variable\": \"TRTP\", \"comparator\": \"EQ\", \"value\": [\"Xanomeline High Dose\"]}}\n      ]\n    }\n  ],\n  \"methods\": [\n    {\n      \"id\": \"MTH_SUMMARY\", \"name\": \"Summary statistics for a continuous variable\",\n      \"description\": \"SAP 7: number of observations, mean, standard deviation, median, minimum, maximum. Template shows N; Mean (SD); Median (Range).\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"operations\": [\n        {\"id\": \"OP_N\", \"order\": 1, \"name\": \"n\", \"label\": \"N\", \"resultPattern\": \"XXX\"},\n        {\"id\": \"OP_MEAN\", \"order\": 2, \"name\": \"Mean\", \"label\": \"Mean\", \"resultPattern\": \"XX.X\"},\n        {\"id\": \"OP_SD\", \"order\": 3, \"name\": \"Standard deviation\", \"label\": \"SD\", \"resultPattern\": \"XX.XX\"},\n        {\"id\": \"OP_MEDIAN\", \"order\": 4, \"name\": \"Median\", \"label\": \"Median\", \"resultPattern\": \"XX.X\"},\n        {\"id\": \"OP_MIN\", \"order\": 5, \"name\": \"Minimum\", \"label\": \"Min\", \"resultPattern\": \"XX\"},\n        {\"id\": \"OP_MAX\", \"order\": 6, \"name\": \"Maximum\", \"label\": \"Max\", \"resultPattern\": \"XXX\"}\n      ]\n    },\n    {\n      \"id\": \"MTH_ANCOVA_DR\", \"name\": \"ANCOVA dose-response test\",\n      \"description\": \"SAP 10.1.1 and Template 5 footnote [1][2]: ANCOVA with baseline score, site and treatment as independent variables; treatment entered as a continuous variable (dose); test for a non-zero treatment coefficient. Two-sided, alpha 0.05. No interaction terms.\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"operations\": [\n        {\"id\": \"OP_DR_P\", \"order\": 1, \"name\": \"P-value (dose response)\", \"label\": \"P-value(Dose Response)\", \"resultPattern\": \"X.XXX\"}\n      ]\n    },\n    {\n      \"id\": \"MTH_ANCOVA_PW\", \"name\": \"ANCOVA pairwise comparison of LS means\",\n      \"description\": \"SAP 10.1.1 and Template 5 footnote [1][3]: ANCOVA with treatment (categorical), site and baseline ADAS-Cog (11) covariate; pairwise difference of LS means, p-values NOT adjusted for multiple comparisons. Two-sided, alpha 0.05. Performed per SAP only if the dose-response test is significant (gating not encoded in ARS; see list below).\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"operations\": [\n        {\"id\": \"OP_PW_P\", \"order\": 1, \"name\": \"P-value (pairwise)\", \"label\": \"P-value\", \"resultPattern\": \"X.XXX\"},\n        {\"id\": \"OP_PW_DIFF\", \"order\": 2, \"name\": \"Difference of LS means\", \"label\": \"Diff. of LS Means\", \"resultPattern\": \"XX.X\"},\n        {\"id\": \"OP_PW_SE\", \"order\": 3, \"name\": \"Standard error of difference\", \"label\": \"SE\", \"resultPattern\": \"X.XX\"},\n        {\"id\": \"OP_PW_LCL\", \"order\": 4, \"name\": \"95% CI lower limit\", \"label\": \"95% CI lower\", \"resultPattern\": \"XX.XX\"},\n        {\"id\": \"OP_PW_UCL\", \"order\": 5, \"name\": \"95% CI upper limit\", \"label\": \"95% CI upper\", \"resultPattern\": \"XX.XX\"}\n      ]\n    }\n  ],\n  \"analyses\": [\n    {\n      \"id\": \"AN_BASE\", \"name\": \"ADAS-Cog (11) baseline summary\", \"dataset\": \"ADQSADAS\", \"variable\": \"BASE\",\n      \"analysisSetId\": \"AS_EFF\", \"dataSubsetId\": \"DS_ACTOT_WK24\", \"methodId\": \"MTH_SUMMARY\",\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"}, \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"description\": \"Template 5 'Baseline' rows. Purpose value is an assumption (display supports the primary analysis; SAP does not label summaries separately).\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"orderedGroupings\": [{\"order\": 1, \"groupingId\": \"GF_TRT\", \"resultsByGroup\": true}]\n    },\n    {\n      \"id\": \"AN_WK24\", \"name\": \"ADAS-Cog (11) Week 24 summary (LOCF)\", \"dataset\": \"ADQSADAS\", \"variable\": \"AVAL\",\n      \"analysisSetId\": \"AS_EFF\", \"dataSubsetId\": \"DS_ACTOT_WK24\", \"methodId\": \"MTH_SUMMARY\",\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"}, \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"description\": \"Template 5 'Week xx' rows. Missing Week 24 values imputed by LOCF (SAP 8.1, 10.1.1); how LOCF records are selected in ADQSADAS is not stated (see list below).\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"orderedGroupings\": [{\"order\": 1, \"groupingId\": \"GF_TRT\", \"resultsByGroup\": true}]\n    },\n    {\n      \"id\": \"AN_CHG\", \"name\": \"ADAS-Cog (11) change from baseline to Week 24 summary (LOCF)\", \"dataset\": \"ADQSADAS\", \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\", \"dataSubsetId\": \"DS_ACTOT_WK24\", \"methodId\": \"MTH_SUMMARY\",\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"}, \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"description\": \"Template 5 'Change from Baseline' rows.\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"orderedGroupings\": [{\"order\": 1, \"groupingId\": \"GF_TRT\", \"resultsByGroup\": true}]\n    },\n    {\n      \"id\": \"AN_DR\", \"name\": \"ADAS-Cog (11) Week 24 ANCOVA dose-response test\", \"dataset\": \"ADQSADAS\", \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\", \"dataSubsetId\": \"DS_ACTOT_WK24\", \"methodId\": \"MTH_ANCOVA_DR\",\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"}, \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"description\": \"Response CHG (assumed). Covariates: BASE (baseline), SITEID (site), TRTPN (dose, continuous; TRTPN 0/54/81 assumed to be the dose scale). SAP 10.1.1.\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}]\n    },\n    {\n      \"id\": \"AN_PW_XLOW_PBO\", \"name\": \"Pairwise: Xanomeline Low Dose - Placebo\", \"dataset\": \"ADQSADAS\", \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\", \"dataSubsetId\": \"DS_ACTOT_WK24\", \"methodId\": \"MTH_ANCOVA_PW\",\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"}, \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"description\": \"Contrast: GRP_XLOW minus GRP_PBO. Covariates BASE, SITEID; treatment TRTP as categorical. The contrast is carried in name/description only; the schema extract has no structured field for it.\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"orderedGroupings\": [{\"order\": 1, \"groupingId\": \"GF_TRT\", \"resultsByGroup\": false}]\n    },\n    {\n      \"id\": \"AN_PW_XHIGH_PBO\", \"name\": \"Pairwise: Xanomeline High Dose - Placebo\", \"dataset\": \"ADQSADAS\", \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\", \"dataSubsetId\": \"DS_ACTOT_WK24\", \"methodId\": \"MTH_ANCOVA_PW\",\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"}, \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"description\": \"Contrast: GRP_XHIGH minus GRP_PBO. Covariates BASE, SITEID; treatment TRTP as categorical.\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"orderedGroupings\": [{\"order\": 1, \"groupingId\": \"GF_TRT\", \"resultsByGroup\": false}]\n    },\n    {\n      \"id\": \"AN_PW_XHIGH_XLOW\", \"name\": \"Pairwise: Xanomeline High Dose - Xanomeline Low Dose\", \"dataset\": \"ADQSADAS\", \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_EFF\", \"dataSubsetId\": \"DS_ACTOT_WK24\", \"methodId\": \"MTH_ANCOVA_PW\",\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"}, \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"description\": \"Contrast: GRP_XHIGH minus GRP_XLOW. Covariates BASE, SITEID; treatment TRTP as categorical.\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"orderedGroupings\": [{\"order\": 1, \"groupingId\": \"GF_TRT\", \"resultsByGroup\": false}]\n    }\n  ],\n  \"outputs\": [\n    {\n      \"id\": \"OUT_T5_WK24\", \"name\": \"ADAS Cog (11) - Change from Baseline to Week 24 - LOCF\",\n      \"description\": \"SAP Template 5 (p.23) for Week 24, Efficacy population.\",\n      \"documentRefs\": [{\"referenceDocumentId\": \"RD_SAP\"}],\n      \"displays\": [\n        {\n          \"order\": 1,\n          \"display\": {\n            \"id\": \"DISP_T5_WK24\", \"name\": \"Table: ADAS Cog (11) CFB Week 24 LOCF\",\n            \"displayTitle\": \"ADAS Cog (11) - Change from Baseline to Week 24 - LOCF\",\n            \"displaySections\": [\n              {\n                \"sectionType\": \"Title\",\n                \"orderedSubSections\": [\n                  {\"order\": 1, \"subSection\": {\"id\": \"SS_TITLE\", \"text\": \"ADAS Cog (11) - Change from Baseline to Week 24 - LOCF\"}},\n                  {\"order\": 2, \"subSection\": {\"id\": \"SS_POP\", \"text\": \"Population: Efficacy\"}}\n                ]\n              },\n              {\n                \"sectionType\": \"Footnote\",\n                \"orderedSubSections\": [\n                  {\"order\": 1, \"subSection\": {\"id\": \"SS_FN1\", \"text\": \"[1] Based on Analysis of covariance (ANCOVA) model with treatment and site as factors, and baseline ADAS Cog (11) value as a covariate.\"}},\n                  {\"order\": 2, \"subSection\": {\"id\": \"SS_FN2\", \"text\": \"[2] Test for a non-zero coefficient for treatment (dose) as a continuous variable.\"}},\n                  {\"order\": 3, \"subSection\": {\"id\": \"SS_FN3\", \"text\": \"[3] Pairwise comparison with treatment as a categorical variable: p-values without adjustment for multiple comparisons.\"}}\n                ]\n              }\n            ]\n          }\n        }\n      ]\n    }\n  ],\n  \"mainListOfContents\": {\n    \"name\": \"Table of analyses\",\n    \"contentsList\": {\n      \"listItems\": [\n        {\n          \"name\": \"ADAS Cog (11) - Change from Baseline to Week 24 - LOCF\", \"level\": 1, \"order\": 1, \"outputId\": \"OUT_T5_WK24\",\n          \"sublist\": {\n            \"listItems\": [\n              {\"name\": \"Baseline summary\", \"level\": 2, \"order\": 1, \"analysisId\": \"AN_BASE\"},\n              {\"name\": \"Week 24 summary\", \"level\": 2, \"order\": 2, \"analysisId\": \"AN_WK24\"},\n              {\"name\": \"Change from baseline summary\", \"level\": 2, \"order\": 3, \"analysisId\": \"AN_CHG\"},\n              {\"name\": \"Dose response\", \"level\": 2, \"order\": 4, \"analysisId\": \"AN_DR\"},\n              {\"name\": \"Xanomeline Low Dose - Placebo\", \"level\": 2, \"order\": 5, \"analysisId\": \"AN_PW_XLOW_PBO\"},\n              {\"name\": \"Xanomeline High Dose - Placebo\", \"level\": 2, \"order\": 6, \"analysisId\": \"AN_PW_XHIGH_PBO\"},\n              {\"name\": \"Xanomeline High Dose - Xanomeline Low Dose\", \"level\": 2, \"order\": 7, \"analysisId\": \"AN_PW_XHIGH_XLOW\"}\n            ]\n          }\n        }\n      ]\n    }\n  }\n}\n```\n\nNothing was added from habit beyond what the excerpts support. The purpose value on the summary analyses is a labeling choice (see below).\n\n**Could not determine from the excerpts**\n1. The WhereClause object (its `level`, `order`, `condition` fields) is not in the schema extract. I used those fields from memory of ARS in the compound expression, so check them.\n2. The AVISIT / AVISITN value for Week 24 is not given. \"Week 24\" is a guess, and the AVISITN number is unknown.\n3. Whether EFFFL = Y exactly matches the SAP efficacy definition. The define.xml extract gives only the label \"Efficacy Population Flag\".\n4. How LOCF records are flagged. I did not use ANL01FL or DTYPE in the subset, because the excerpts do not say whether the analysis records are ANL01FL = Y or DTYPE = LOCF. The SAP itself imputes at Week 24 only.\n5. The ANCOVA response variable. I assumed CHG, based on the template title. The SAP says only \"baseline score, site, treatment\".\n6. The dose scale for the continuous treatment term. I assumed TRTPN (0, 54, 81). The SAP does not say.\n7. Whether each pairwise ANCOVA is fit on all three groups or only the two compared. Pairwise contrasts are encoded in analysis names and descriptions only, because the schema extract has no structured contrast field.\n8. How to encode the SAP rule that pairwise comparisons are done only if the dose-response test is significant. ARS has no gating field in the extract, so it is stated only in the method description.\n9. The method code templates, the `programmingCode`, and the results. These are not in the excerpts, so I left them out.\n10. The `pageRefs` structure, and the locations of the SAP and define.xml. I put page numbers in descriptions instead.\n11. The output file name, type and location (`fileSpecifications`), and any analysis output categories.\n12. How the column header \"N=xxx\" is derived. I did not add an analysis for it. The excerpts do not give a separate N-count analysis.\n13. Whether the purpose for the summary analyses should be PRIMARY OUTCOME MEASURE. I used it because SAP 10.1.1 calls the Week 24 ADAS-Cog analysis primary.\n14. The result patterns, which I inferred from the template's \"xx.x\" strings. The Min/Max pattern and the SE pattern are guesses.\n15. Rounding conventions, and the CIBIC+ analyses. CIBIC+ is outside this display.",
      "note": "Run B. Same excerpt, the schema extract above placed between the excerpt and the task, and two prompt changes (follow the schema extract; the 'say where you are unsure' sentence removed). The extract is property names, required lists and six enum value lists copied from model/ars_ldm.json; it does not show how classes nest."
    }
  },
  "bad": {
    "input": "make me CDISC ARS JSON for my ADAS-Cog change from baseline at week 24 table",
    "output": "Below is an illustrative CDISC ARS (Analysis Results Standard, v1.0 model) JSON skeleton for an ADAS-Cog change-from-baseline-at-Week-24 table. I wrote it from memory, so validate it against the official ARS JSON schema before use. All IDs, dataset and variable names (ADQS, PARAMCD=ACTOT, AVISIT, CHG, TRT01P, BASE, etc.), treatment arms and covariates are assumptions. Please adapt them to your SAP and ADaM specs. The model is an MMRM-style ANCOVA, and results are left blank for you to populate.\n\n```json\n{\n  \"id\": \"RE_ADASCOG_CFB_W24\",\n  \"name\": \"ADAS-Cog(11) Change from Baseline at Week 24\",\n  \"label\": \"Table 14.2.1 ADAS-Cog Change from Baseline at Week 24 (ITT)\",\n  \"version\": \"1\",\n  \"mainListOfContents\": {\n    \"contentsList\": {\n      \"listItems\": [\n        {\n          \"name\": \"Table 14.2.1\",\n          \"level\": 1,\n          \"order\": 1,\n          \"outputId\": \"OUT_T14_2_1\"\n        }\n      ]\n    }\n  },\n  \"analysisSets\": [\n    {\n      \"id\": \"AS_ITT\",\n      \"name\": \"Intent-to-Treat\",\n      \"label\": \"ITT Population\",\n      \"level\": 1,\n      \"order\": 1,\n      \"condition\": {\n        \"dataset\": \"ADSL\",\n        \"variable\": \"ITTFL\",\n        \"comparator\": \"EQ\",\n        \"value\": [\"Y\"]\n      }\n    }\n  ],\n  \"dataSubsets\": [\n    {\n      \"id\": \"DS_ADASCOG_W24\",\n      \"name\": \"ADAS-Cog total, Week 24\",\n      \"label\": \"PARAMCD=ACTOT, AVISIT=Week 24\",\n      \"level\": 1,\n      \"order\": 1,\n      \"compoundExpression\": {\n        \"logicalOperator\": \"AND\",\n        \"whereClauses\": [\n          {\n            \"level\": 1,\n            \"order\": 1,\n            \"condition\": {\n              \"dataset\": \"ADQS\",\n              \"variable\": \"PARAMCD\",\n              \"comparator\": \"EQ\",\n              \"value\": [\"ACTOT\"]\n            }\n          },\n          {\n            \"level\": 1,\n            \"order\": 2,\n            \"condition\": {\n              \"dataset\": \"ADQS\",\n              \"variable\": \"AVISIT\",\n              \"comparator\": \"EQ\",\n              \"value\": [\"Week 24\"]\n            }\n          }\n        ]\n      }\n    }\n  ],\n  \"analysisGroupings\": [\n    {\n      \"id\": \"AnlsGrouping_TRT\",\n      \"name\": \"Planned Treatment\",\n      \"label\": \"Planned Treatment\",\n      \"groupingVariable\": \"TRT01P\",\n      \"dataDriven\": false,\n      \"groups\": [\n        {\n          \"id\": \"AnlsGrp_PBO\",\n          \"name\": \"Placebo\",\n          \"label\": \"Placebo\",\n          \"level\": 1,\n          \"order\": 1,\n          \"condition\": {\n            \"dataset\": \"ADQS\",\n            \"variable\": \"TRT01P\",\n            \"comparator\": \"EQ\",\n            \"value\": [\"Placebo\"]\n          }\n        },\n        {\n          \"id\": \"AnlsGrp_TRT\",\n          \"name\": \"Active\",\n          \"label\": \"Active Treatment\",\n          \"level\": 1,\n          \"order\": 2,\n          \"condition\": {\n            \"dataset\": \"ADQS\",\n            \"variable\": \"TRT01P\",\n            \"comparator\": \"EQ\",\n            \"value\": [\"Active\"]\n          }\n        }\n      ]\n    }\n  ],\n  \"analysisMethods\": [\n    {\n      \"id\": \"AM_DESC\",\n      \"name\": \"Descriptive statistics\",\n      \"label\": \"n, Mean, SD, Median, Min, Max\",\n      \"operations\": [\n        {\"id\": \"AM_DESC_N\", \"name\": \"n\", \"label\": \"n\", \"order\": 1, \"resultPattern\": \"XX\"},\n        {\"id\": \"AM_DESC_MEAN\", \"name\": \"Mean\", \"label\": \"Mean\", \"order\": 2, \"resultPattern\": \"XX.X\"},\n        {\"id\": \"AM_DESC_SD\", \"name\": \"SD\", \"label\": \"SD\", \"order\": 3, \"resultPattern\": \"XX.XX\"},\n        {\"id\": \"AM_DESC_MEDIAN\", \"name\": \"Median\", \"label\": \"Median\", \"order\": 4, \"resultPattern\": \"XX.X\"},\n        {\"id\": \"AM_DESC_MIN\", \"name\": \"Min\", \"label\": \"Min\", \"order\": 5, \"resultPattern\": \"XX\"},\n        {\"id\": \"AM_DESC_MAX\", \"name\": \"Max\", \"label\": \"Max\", \"order\": 6, \"resultPattern\": \"XX\"}\n      ]\n    },\n    {\n      \"id\": \"AM_ANCOVA\",\n      \"name\": \"ANCOVA\",\n      \"label\": \"ANCOVA of CHG with baseline and treatment; LS means and contrast vs placebo\",\n      \"description\": \"CHG ~ TRT01P + BASE + SITEGR1 (covariates per SAP). Type III SS. LS means with 95% CI, difference vs placebo.\",\n      \"operations\": [\n        {\"id\": \"AM_ANCOVA_LSM\", \"name\": \"LS Mean\", \"label\": \"LS Mean\", \"order\": 1, \"resultPattern\": \"XX.XX\"},\n        {\"id\": \"AM_ANCOVA_SE\", \"name\": \"LS Mean SE\", \"label\": \"SE\", \"order\": 2, \"resultPattern\": \"X.XXX\"},\n        {\"id\": \"AM_ANCOVA_DIFF\", \"name\": \"LS Mean Difference\", \"label\": \"Difference vs Placebo\", \"order\": 3, \"resultPattern\": \"XX.XX\"},\n        {\"id\": \"AM_ANCOVA_LCL\", \"name\": \"95% CI Lower\", \"label\": \"Lower 95% CL\", \"order\": 4, \"resultPattern\": \"XX.XX\"},\n        {\"id\": \"AM_ANCOVA_UCL\", \"name\": \"95% CI Upper\", \"label\": \"Upper 95% CL\", \"order\": 5, \"resultPattern\": \"XX.XX\"},\n        {\"id\": \"AM_ANCOVA_P\", \"name\": \"p-value\", \"label\": \"p-value\", \"order\": 6, \"resultPattern\": \"X.XXXX\"}\n      ]\n    }\n  ],\n  \"analyses\": [\n    {\n      \"id\": \"AN_ADASCOG_CHG_W24_DESC\",\n      \"name\": \"ADAS-Cog CHG Week 24 descriptive\",\n      \"version\": 1,\n      \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"},\n      \"categoryIds\": [\"AnCat_Efficacy\"],\n      \"dataset\": \"ADQS\",\n      \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_ITT\",\n      \"dataSubsetId\": \"DS_ADASCOG_W24\",\n      \"orderedGroupings\": [\n        {\"order\": 1, \"groupingId\": \"AnlsGrouping_TRT\", \"resultsByGroup\": true}\n      ],\n      \"methodId\": \"AM_DESC\"\n    },\n    {\n      \"id\": \"AN_ADASCOG_CHG_W24_ANCOVA\",\n      \"name\": \"ADAS-Cog CHG Week 24 ANCOVA\",\n      \"version\": 1,\n      \"reason\": {\"controlledTerm\": \"SPECIFIED IN SAP\"},\n      \"purpose\": {\"controlledTerm\": \"PRIMARY OUTCOME MEASURE\"},\n      \"categoryIds\": [\"AnCat_Efficacy\"],\n      \"dataset\": \"ADQS\",\n      \"variable\": \"CHG\",\n      \"analysisSetId\": \"AS_ITT\",\n      \"dataSubsetId\": \"DS_ADASCOG_W24\",\n      \"orderedGroupings\": [\n        {\"order\": 1, \"groupingId\": \"AnlsGrouping_TRT\", \"resultsByGroup\": true}\n      ],\n      \"methodId\": \"AM_ANCOVA\"\n    }\n  ],\n  \"analysisCategorizations\": [\n    {\n      \"id\": \"AnCatn_Type\",\n      \"label\": \"Analysis Type\",\n      \"categories\": [\n        {\"id\": \"AnCat_Efficacy\", \"label\": \"Efficacy\"}\n      ]\n    }\n  ],\n  \"outputs\": [\n    {\n      \"id\": \"OUT_T14_2_1\",\n      \"name\": \"Table 14.2.1\",\n      \"version\": 1,\n      \"fileSpecifications\": [\n        {\"name\": \"t_14_2_1_adascog_chg_w24.rtf\", \"fileType\": {\"controlledTerm\": \"rtf\"}}\n      ],\n      \"displays\": [\n        {\n          \"order\": 1,\n          \"display\": {\n            \"id\": \"DISP_T14_2_1\",\n            \"name\": \"ADAS-Cog Change from Baseline at Week 24\",\n            \"version\": 1,\n            \"displayTitle\": \"Table 14.2.1: ADAS-Cog(11) Change from Baseline at Week 24 (ITT Population)\",\n            \"displaySections\": [\n              {\n                \"sectionType\": \"Header\",\n                \"orderedSubSections\": [\n                  {\"order\": 1, \"subSection\": {\"id\": \"SS_HDR\", \"text\": \"ADAS-Cog(11) Total Score\"}}\n                ]\n              },\n              {\n                \"sectionType\": \"Footnote\",\n                \"orderedSubSections\": [\n                  {\"order\": 1, \"subSection\": {\"id\": \"SS_FN1\", \"text\": \"Higher scores indicate greater cognitive impairment. Negative change indicates improvement.\"}},\n                  {\"order\": 2, \"subSection\": {\"id\": \"SS_FN2\", \"text\": \"ANCOVA model includes treatment and baseline ADAS-Cog as covariates.\"}}\n                ]\n              }\n            ]\n          }\n        }\n      ]\n    }\n  ]\n}\n```\n\nNotes:\n- Results are not included. In ARS they go in a separate `resultGroups`/`results` structure under each analysis (`operationId`, `rawValue`, `formattedValue`).\n- If your SAP specifies an MMRM (common for ADAS-Cog), replace `AM_ANCOVA` with an MMRM method (`CHG ~ TRT01P*AVISIT + BASE*AVISIT`, unstructured covariance, Kenward-Roger df).\n- The footnote about score direction applies to ADAS-Cog(11), where range is 0-70. Change it if you use ADAS-Cog(13), where the range is 0-85.\n- Add a baseline analysis and a Week 24 observed-value analysis if your shell shows them. Each is another entry in `analyses`.\n- If you share your SAP, shell, or ADaM specs, I can tailor the IDs, covariates and layout.",
    "what_went_wrong": [
      "Two arms. It invents a two-group grouping, Placebo and 'Active' on TRT01P. The SAP and Template 5 have three groups (Placebo, Xanomeline Low Dose, Xanomeline High Dose) and the pilot data has no value 'Active' (SAP 1.2, p.5; Template 5, p.23).",
      "Wrong dataset and variables. It binds ADQS, TRT01P and an ITTFL flag on ADSL. The pilot dataset is ADQSADAS; its treatment variable is TRTP; the primary analysis set is the Efficacy population (EFFFL), not ITT (SAP 6, p.8; 10.1.1, p.13; define.xml).",
      "Wrong analysis. It calls the model 'MMRM-style ANCOVA' with treatment and baseline only. The SAP model has baseline, site and treatment, treatment as a continuous variable with a dose-response test, and pairwise comparisons (SAP 10.1.1, p.13). It has no dose-response analysis, no pairwise analyses and no baseline or Week 24 summaries; Template 5 has all of these (p.23).",
      "Nothing about LOCF, the method that defines the table title (SAP 8.1, p.9; Template 5 title).",
      "Not valid ARS. It fails the real schema (2 errors: no name on mainListOfContents, version as a string). It also uses analysisMethods and analysisCategorizations at the top level, which are not ARS names (methods and analysisOutputCategorizations); the schema lets unknown root keys through, so only a strict check or a reference check shows that all four methodId and categoryIds links point at nothing.",
      "Invented detail presented as fact: 'Table 14.2.1', an rtf file name and ITT in the label. The reply does say these are assumptions and says to validate; the part that matters was left to the reader."
    ]
  },
  "what_changed": [
    "Both good runs bound to the right things the lazy run missed: three arms in Template 5 order on TRTP, the Efficacy flag EFFFL, ADQSADAS, PARAMCD ACTOT, and a dose-response test plus three unadjusted pairwise comparisons with the Template 5 footnotes copied verbatim.",
    "The real schema separates the runs: lazy 2 errors, run A 7, run B 1. Run B had a property and enum extract (names only) and run A had only its memory of ARS; run A got reason and purpose right as controlled terms but missed required level and order in whereClauses and required fields on its extra analysis.",
    "Passing is not right: run B with its version fixed passes the schema yet its Week 24 subset has no ANL01FL = Y and returns 237 rows for 234 subjects. The define.xml comment that explains ANL01FL was not in the excerpt; both runs said so in their gap lists but treated the filter as optional.",
    "Run A modelled the pairwise comparisons as three two-group data subsets that restrict treatment only, so they lose the ACTOT and Week 24 conditions and contradict the single three-group model. Run B kept one subset and one method and put the contrast in the name and description.",
    "The gap lists are again the review agenda: both are honest about gating, programming code and results, but about 10 items are answerable from the SAP, Template 5, define.xml or the data (dose scale, CHG response, 'Week 24', USUBJID, Baseline and LOCF rows)."
  ],
  "check_before_trust": [
    "Validate against the schema of the ARS version your tools expect, and read the error list rather than the pass or fail flag. Also check root keys and ids yourself: the published schema allows unknown top-level keys and does not test that ids resolve.",
    "Do not trust a pass. Check each analysis set, data subset and method against the SAP text and the define.xml, then run the subset on the data: count rows and subjects per arm and compare with the SAP population (here 234 subjects, 79/74/81; the draft subset gave 237 rows).",
    "Give the model the define.xml derivation comments for every flag and record-selection variable (ANL01FL, DTYPE, SITEGR1, AVISIT windowing), not only labels. The excerpt here listed ANL01FL by label and omitted SITEGR1, and the drafts show that gap.",
    "Check each 'could not determine' item before treating it as an open question. About 10 here were answerable from the SAP, Template 5, define.xml or the data.",
    "Read the contrast and gating logic yourself. Neither run encodes 'pairwise only if the dose-response test is significant', and neither has a structured contrast; run A's two-group subsets also change the model. ARS operation relationships and result groups were not tested.",
    "Contamination: the ARS repository itself holds CDISC pilot examples (workfiles/examples/ARS v1, including the pilot SAP) that a model may have seen; this example did not open or use them. The SAP excerpts are the ones used on the TLF page and the builder had read that page and its outputs before building this one. Two runs are not a rate."
  ],
  "verification": {
    "answer_key": "Reference document (SAP Template 5 and prose, pp.8-23, and the pilot define.xml), plus a schema validation against the real CDISC ARS JSON schema and a script check of the dataset and variable bindings against the pilot ADaM data. The pilot predates ARS, so there is no published ARS answer for this display in the SAP; the ARS repository's own pilot examples were deliberately not opened. Verdicts: correct, partly, wrong, not in source, false gap.",
    "schema_validation": {
      "schema_source": "CDISC Analysis Results Standard (ARS) v1.0, model/ars_ldm.json in https://github.com/cdisc-org/analysis-results-standard, repository HEAD commit bbebea4f5de870eaf09456ee147233c6f26d0e48 (2026-04-28), cloned 2026-10-21. JSON Schema draft-07, $id https://www.cdisc.org/ars/1-0, metamodel_version 1.7.0. The repository has no release or tag. The cdisc.org ARS page (opened 2026-10-21) lists ARS v1.0 released 19 April 2024.",
      "licence": "Repository README: code and scripts MIT (LICENSE file; its copyright line still reads '[INCLUDE COPYRIGHT INSTANCE]'), documentation and other content CC BY 4.0, no trademark permissions. The cdisc.org ARS page shows no licence statement. The schema file is not copied into this project: the validation script points at a clone. Run B was shown a property-name and enum extract of the schema (about 375 words, derived from the MIT-licensed file, attribution to CDISC ARS).",
      "tool": "tfl-shell-to-ars-metadata_validate.py (python jsonschema 4.26.0, Draft 7). It reports the real schema's errors, then two checks added by the builder that are not part of the CDISC schema: a strict pass with root additionalProperties set to false (the published schema allows unknown top-level keys, so a misspelled root key is not an error), and a dangling-reference check on ids.",
      "results": [
        {
          "output": "Lazy run (bad)",
          "schema_errors": 2,
          "pass": false,
          "detail": "mainListOfContents has no name; version \"1\" is a string. Strict pass: 3 errors, because analysisMethods and analysisCategorizations are not ARS root keys (ARS uses methods and analysisOutputCategorizations) and the schema lets them through. Reference check: 4 dangling ids (both methodId and categoryIds point at nothing)."
        },
        {
          "output": "Run A (excerpt and prompt only)",
          "schema_errors": 7,
          "pass": false,
          "detail": "analyses[0] (AN_N_EFF) lacks reason and purpose (2); both whereClauses lack level and order (2); version is a string on the event, output and display (3). Strict pass: 7. Reference check: pass. After changing version to an integer: 4 errors remain."
        },
        {
          "output": "Run B (excerpt, prompt and schema extract)",
          "schema_errors": 1,
          "pass": false,
          "detail": "version \"1\" is a string; nothing else. Strict pass: 1. Reference check: pass. After changing version to an integer: 0 errors, a pass."
        }
      ],
      "not_proved": "A schema pass says the JSON is well formed ARS. It does not say the analysis set, subset, method, covariates or variables are right. Run B's JSON with the version fixed passes the schema and still selects 237 rows for 234 subjects and uses SITEID instead of the pooled site."
    },
    "bindings_check": {
      "script": "tfl-shell-to-ars-metadata_Rrun/check_bindings.R, output in check_bindings_output.txt (R 4.6.1, haven, dplyr; pilot ADaM data unmodified)",
      "findings": [
        "All 13 variables either run binds exist in ADQSADAS.",
        "TRTP values Placebo, Xanomeline Low Dose, Xanomeline High Dose match with TRTPN 0, 54, 81; PARAMCD ACTOT, AVISIT 'Week 24' = AVISITN 24 match.",
        "EFFFL = Y gives 79, 74, 81 subjects (Placebo, High, Low), 234 in total, in ADSL and in the Week 24 records.",
        "Week 24 ACTOT rows for EFFFL = Y: 237 rows for 234 subjects (79/75/83 by arm) without ANL01FL; 234 rows (79/74/81) with ANL01FL = Y, of which 79 are DTYPE = LOCF.",
        "Site: 17 SITEID values but 11 pooled SITEGR1 values among the analysis records."
      ]
    },
    "rows": [
      {
        "claim": "B: Efficacy analysis set bound to ADQSADAS EFFFL EQ Y",
        "verdict": "correct",
        "cite": "define.xml EFFFL label 'Efficacy Population Flag', Comment ADSL.FASFL; check_bindings s3: 79/74/81 = 234 subjects; SAP 6"
      },
      {
        "claim": "B: gap 3 - unsure EFFFL=Y matches the SAP efficacy definition (description says 'assumed')",
        "verdict": "false gap",
        "cite": "check_bindings s3 and s4: EFFFL=Y gives 234 distinct subjects, 79/74/81 per arm, consistent with SAP 6; define.xml EFFFL derived from ADSL.FASFL"
      },
      {
        "claim": "B: analysis set text restates SAP 6 (randomized, took drug, >=1 post-baseline ADAS-Cog and CIBIC+)",
        "verdict": "correct",
        "cite": "SAP 6, Efficacy population"
      },
      {
        "claim": "B: three treatment groups Placebo, Xanomeline Low Dose, Xanomeline High Dose in Template 5 order, level 1 order 1-3",
        "verdict": "correct",
        "cite": "Template 5 columns (SAP p.23); SAP 1.2 lists high, low, placebo, a different order, Template order is right for a display"
      },
      {
        "claim": "B: grouping bound to ADQSADAS.TRTP with literal values Placebo / Xanomeline Low Dose / Xanomeline High Dose",
        "verdict": "correct",
        "cite": "check_bindings s2: TRTP values match exactly"
      },
      {
        "claim": "B: Week 24 subset PARAMCD EQ ACTOT",
        "verdict": "correct",
        "cite": "check_bindings s2: PARAMCD ACTOT"
      },
      {
        "claim": "B: Week 24 subset AVISIT EQ 'Week 24'",
        "verdict": "correct",
        "cite": "check_bindings s2: AVISIT 'Week 24' = AVISITN 24 (2453 rows)"
      },
      {
        "claim": "B: gap 2 - AVISIT value 'Week 24' called a guess, AVISITN unknown",
        "verdict": "false gap",
        "cite": "check_bindings s2 confirms 'Week 24' and AVISITN 24. Honest given the inputs, but the data answer it"
      },
      {
        "claim": "B: Week 24 subset omits ANL01FL=Y, so it selects every Week 24 ACTOT row for EFFFL=Y subjects",
        "verdict": "wrong",
        "cite": "check_bindings s4: 237 rows, 234 subjects, 3 subjects with 2 rows, arm counts 79/75/83 vs correct 79/74/81; define.xml ANL01FL comment (closest record in window flagged Y)"
      },
      {
        "claim": "B: gap 4 - cannot tell whether analysis records are ANL01FL=Y or DTYPE=LOCF, so neither used",
        "verdict": "false gap",
        "cite": "SAP 8.1 (LOCF on targeted/analyzable assessments by window) and define ANL01FL comment; check_bindings s4: ANL01FL=Y gives one row per subject, 79 DTYPE=LOCF. The define comment was not shown to the model, SAP 8.1 was"
      },
      {
        "claim": "B: AN_WK24 description 'how LOCF records are selected in ADQSADAS is not stated'",
        "verdict": "false gap",
        "cite": "SAP 8.1 windows/targeted assessment; define ANL01FL comment"
      },
      {
        "claim": "B: summary method lists n, mean, SD, median, min, max (6 operations)",
        "verdict": "correct",
        "cite": "SAP 7 summary statistics; Template 5 N; Mean (SD); Median (Range)"
      },
      {
        "claim": "B: result patterns n XXX, mean XX.X, SD XX.XX, median XX.X, min XX, max XXX",
        "verdict": "correct",
        "cite": "Template 5 cells xxx / xx.x (xx.xx) / xx.x (xx;xxx)"
      },
      {
        "claim": "B: gap 14 - result patterns inferred; Min/Max and SE patterns are 'guesses'",
        "verdict": "partly",
        "cite": "Template 5 prints 'xx;xxx' for (Min;Max) and '(x.xx)' for SE, so patterns are given; small false gap"
      },
      {
        "claim": "B: baseline summary uses BASE on the Week 24 subset (AN_BASE), not stated that baseline N comes from Week 24 records",
        "verdict": "partly",
        "cite": "Gives same result because LOCF gives all 234 subjects a Week 24 row; Baseline visit exists in data (check_bindings s2); undisclosed choice"
      },
      {
        "claim": "B: Week 24 summary uses AVAL, change summary uses CHG, by TRTP, resultsByGroup true",
        "verdict": "correct",
        "cite": "Template 5 rows Week xx / Change from Baseline; check_bindings s1"
      },
      {
        "claim": "B: dose-response method: ANCOVA, treatment continuous, test of non-zero coefficient, 2-sided alpha 0.05, no interactions",
        "verdict": "correct",
        "cite": "SAP 10.1.1; Template 5 footnote [2]"
      },
      {
        "claim": "B: dose-response covariates BASE, SITEID, TRTPN recorded only in analysis description, not as structured terms",
        "verdict": "partly",
        "cite": "SAP 10.1.1 baseline, site, treatment; variables exist in define.xml; model terms not bound"
      },
      {
        "claim": "B: gap 6 - dose scale for continuous treatment unknown; TRTPN 0/54/81 'assumed'",
        "verdict": "false gap",
        "cite": "SAP 3.1.1, p.6: drug dose (0, 50 cm2 [54 mg], and 75 cm2 [81 mg]); check_bindings s2: TRTPN 0/54/81 aligned to Placebo/Low/High. Assumption is right and SAP 1.2 supports it"
      },
      {
        "claim": "B: gap 5 - dose-response response CHG 'assumed'",
        "verdict": "false gap",
        "cite": "Template 5 title 'Change from Baseline to Week xx' and footnote [1] baseline as covariate imply CHG; mild false gap"
      },
      {
        "claim": "B: pairwise method: treatment categorical, ANCOVA with site and baseline, unadjusted p-values, alpha 0.05",
        "verdict": "correct",
        "cite": "Template 5 footnotes [1][3]; SAP 10.1.1"
      },
      {
        "claim": "B: pairwise operations: p-value, difference of LS means, SE, 95% CI lower and upper",
        "verdict": "correct",
        "cite": "Template 5 rows P-value, Diff. of LS Means (SE), 95% CI"
      },
      {
        "claim": "B: three pairwise analyses on the same 3-group Week 24 subset, contrast only in name/description",
        "verdict": "partly",
        "cite": "Consistent with one 3-group model (footnote [1]); contrast not structurally encoded, disclosed"
      },
      {
        "claim": "B: gap 7 - unsure whether each pairwise fit uses all 3 groups or only 2",
        "verdict": "partly",
        "cite": "SAP 10.1.1 'pairwise comparisons among the 3 groups' and footnote [1] describe one model; mostly answerable, honest hedge"
      },
      {
        "claim": "B: gating (pairwise only if dose response significant) not encoded, stated in method description (gap 8)",
        "verdict": "correct",
        "cite": "SAP 7 and 10.1.1; honest gap"
      },
      {
        "claim": "B: site covariate SITEID; SAP 7.1 pooled site and ADQSADAS.SITEGR1 neither used nor mentioned",
        "verdict": "wrong",
        "cite": "SAP 7.1 pools sites with <3 patients per arm; define SITEGR1 'Pooled Site Group 1'; check_bindings s5: 17 SITEID vs 11 SITEGR1 levels"
      },
      {
        "claim": "B: footnotes [1][2][3] copied verbatim from Template 5",
        "verdict": "correct",
        "cite": "SAP p.23"
      },
      {
        "claim": "B: titles 'Population: Efficacy' and 'ADAS Cog (11) - Change from Baseline to Week 24 - LOCF'",
        "verdict": "correct",
        "cite": "Template 5 header, xx=24; B puts title before population line, Template has population first, trivial"
      },
      {
        "claim": "B: no column header (N=xxx) and no N-count analysis (gap 12)",
        "verdict": "partly",
        "cite": "Template 5 shows (N=xxx) per arm; omission disclosed, but a display element is missing; USUBJID is in define.xml"
      },
      {
        "claim": "B: purpose PRIMARY OUTCOME MEASURE on baseline, Week 24 and change summaries (flagged as assumption, gap 13)",
        "verdict": "partly",
        "cite": "SAP 10.1.1 calls only the Week 24 ADAS-Cog analysis primary; descriptive summaries are not the primary test. Flagged honestly; reason SPECIFIED IN SAP fine"
      },
      {
        "claim": "B: purpose PRIMARY OUTCOME MEASURE, reason SPECIFIED IN SAP on dose-response and pairwise analyses",
        "verdict": "partly",
        "cite": "SAP 3.1.1 and 3.2.1, p.6 (primary analysis is a test for dose response): dose response is the primary test; pairwise are gated follow-ups, so defensible not exact"
      },
      {
        "claim": "B: two reference documents RD_SAP and RD_DEFINE cited from methods, analyses, outputs",
        "verdict": "partly",
        "cite": "Both real sources; no locations or pageRefs; 'p.8, p.13' omits p.9 (7.1, 8.1); RD_DEFINE is a useful addition"
      },
      {
        "claim": "B: gaps 9, 10, 11, 15 (programmingCode, pageRefs, output file spec, rounding)",
        "verdict": "correct",
        "cite": "Not in SAP excerpt; honest gaps"
      },
      {
        "claim": "B: gap 1 - WhereClause fields (level, order, condition) used from memory",
        "verdict": "correct",
        "cite": "validate_output: B has only the version error, whereClauses valid"
      },
      {
        "claim": "B: closing note 'Nothing was added from habit'",
        "verdict": "correct",
        "cite": "No extra analyses; consistent"
      },
      {
        "claim": "A: Efficacy set EFFFL EQ Y, no SAP 6 description and no hedge",
        "verdict": "correct",
        "cite": "define.xml EFFFL; check_bindings s3"
      },
      {
        "claim": "A: treatment grouping on TRTP, same 3 groups and order as B",
        "verdict": "correct",
        "cite": "Template 5; check_bindings s2"
      },
      {
        "claim": "A: Week 24 subset PARAMCD EQ ACTOT and AVISITN EQ '24'",
        "verdict": "correct",
        "cite": "check_bindings s2: AVISITN 24 = Week 24"
      },
      {
        "claim": "A: gap 3 - left ANL01FL out; 'adding it would have been from habit'",
        "verdict": "wrong",
        "cite": "Same defect as B (237 vs 234 rows, 3 duplicated subjects, check_bindings s4); the omission is the error, the filter is not habit; define ANL01FL comment"
      },
      {
        "claim": "A: gap 2 - 'excerpts do not say whether LOCF records (DTYPE=LOCF) are carried at AVISITN 24'",
        "verdict": "false gap",
        "cite": "check_bindings s4: 79 LOCF rows among ANL01FL=Y Week 24 records; SAP 8.1"
      },
      {
        "claim": "A: gap 1 - baseline AVISIT/AVISITN not given, baseline N may differ from true baseline N",
        "verdict": "false gap",
        "cite": "check_bindings s2: AVISIT 'Baseline' AVISITN 0 exists; with LOCF all 234 subjects have a Week 24 row, so baseline N is identical"
      },
      {
        "claim": "A: same summary operations and patterns as B (n, mean, SD, median, min, max)",
        "verdict": "correct",
        "cite": "SAP 7, Template 5"
      },
      {
        "claim": "A: gap 10 - 'xx;xxx' taken as min;max, exact format not specified",
        "verdict": "false gap",
        "cite": "Template 5 Median (Range) shows xx;xxx; mild"
      },
      {
        "claim": "A: BASE, AVAL, CHG summaries on DS_ACTOT_WK24 by TRTP; dose response on CHG with TRTPN in description only",
        "verdict": "correct",
        "cite": "Template 5; check_bindings s1"
      },
      {
        "claim": "A: gaps 4 and 5 - TRTPN dose variable not named by SAP; CHG response assumed",
        "verdict": "false gap",
        "cite": "SAP 3.1.1, p.6 doses 0/54/81 with TRTPN data; Template 5 title and footnote [1]"
      },
      {
        "claim": "A: pairwise data subsets DS_PW_* restrict only TRTP, no PARAMCD or AVISIT/AVISITN condition",
        "verdict": "wrong",
        "cite": "Subsets cover all ACTOT visits incl. Baseline, Week 8, 16 (check_bindings s2); Week 24 condition lost; not flagged by A"
      },
      {
        "claim": "A: pairwise via two-group data subsets implies 2-group fits (self-flagged, gap 7)",
        "verdict": "wrong",
        "cite": "Footnote [1] and SAP 10.1.1 describe one model of the 3 groups; 2-group fits change residual variance and SE; flagged honestly but wrong design"
      },
      {
        "claim": "A: AN_N_EFF extra analysis for (N=xxx) headers, no variable bound, flagged as added because template shows N",
        "verdict": "partly",
        "cite": "Template 5 header (N=xxx); gap 6 says USUBJID 'is not in the extract' but define.xml has ADQSADAS.USUBJID (false gap); MTH_SUMM would return mean etc., not just a count"
      },
      {
        "claim": "A: AN_N_EFF referencedAnalysisOperations has relationship id 'n_only' pointing to AN_N_EFF itself",
        "verdict": "wrong",
        "cite": "Self-reference with undefined relationship; validate_output reference check passes only because the id resolves to itself; A admits placeholder"
      },
      {
        "claim": "A: site covariate SITEID; SAP 7.1 pooled site / SITEGR1 not mentioned",
        "verdict": "wrong",
        "cite": "Same as B: SAP 7.1; define SITEGR1; check_bindings s5"
      },
      {
        "claim": "A: gating not encoded, stated in description and gap 8",
        "verdict": "correct",
        "cite": "SAP 7, 10.1.1; honest gap"
      },
      {
        "claim": "A: footnotes [1][2][3] verbatim, population line first, header section 'Columns: ... (N=xxx)'",
        "verdict": "correct",
        "cite": "Template 5; header is one free-text string, not columns"
      },
      {
        "claim": "A: purpose PRIMARY OUTCOME MEASURE and reason SPECIFIED IN SAP on all analyses, not flagged as an assumption; terms 'from memory'",
        "verdict": "partly",
        "cite": "SAP 10.1.1 as for B; B flagged the choice, A did not; AN_N_EFF has neither (validate_output: required)"
      },
      {
        "claim": "A: one reference document RD_SAP, location 'not given in excerpts'; no define.xml reference",
        "verdict": "partly",
        "cite": "Placeholder in location field; define.xml is the real binding source"
      },
      {
        "claim": "A: output file specification fileType rtf",
        "verdict": "not in source",
        "cite": "Template 5 gives no file type; A's gap 9 says the type is not stated; invented"
      },
      {
        "claim": "A: description cites SAP section 13.2 Template 5",
        "verdict": "correct",
        "cite": "SAP 13.2 Templates for Data Displays, p.23"
      },
      {
        "claim": "A: gap 9 dataset-level LOCF not modelled; rounding and code references not stated",
        "verdict": "correct",
        "cite": "Honest gaps"
      }
    ],
    "errors_found": [
      "Both runs leave ANL01FL = Y out of the Week 24 data subset. Run on the pilot ADQSADAS data, the subset as written (EFFFL = Y, PARAMCD = ACTOT, Week 24) returns 237 rows for 234 subjects, with 3 subjects twice and arm counts 79/75/83 instead of 79/74/81. Neither model was shown the define.xml comment that explains ANL01FL. Run A calls the filter 'from habit', which gets it backwards.",
      "Run A's three pairwise data subsets restrict only TRTP, so the ACTOT and Week 24 conditions are lost and each subset spans every ADAS-Cog item and visit. Run A also implies separate two-group fits, where footnote [1] and SAP 10.1.1 describe one model of the 3 groups. Run A said it was unsure of the second point; it did not notice the first.",
      "Run A's extra analysis AN_N_EFF points its referencedAnalysisOperations at itself with an undefined relationship id, binds no variable, and has no reason or purpose (two of the seven schema errors). The reference check passes only because the id resolves to its own analysis.",
      "Neither run uses the SAP 7.1 pooled site (ADQSADAS.SITEGR1, 11 levels); both use SITEID (17 levels) and do not flag it. SITEGR1 was not in the variable list this example gave the models, so this is partly an input limit.",
      "About 10 'could not determine' items are false gaps: the dose scale 0/54/81 (SAP 3.1.1, TRTPN in the data), the CHG response (Template 5), the 'Week 24' AVISIT value, a Baseline visit and LOCF rows (the data), USUBJID (define.xml). Several are true of the excerpts and answerable from the full documents, as on the TLF page.",
      "Run A invents an rtf file type; Template 5 gives none. Both runs put PRIMARY OUTCOME MEASURE on the descriptive summaries (run B flags this as an assumption, run A does not).",
      "Run B has no (N=xxx) column header encoded and the pairwise contrasts exist only as free text in names and descriptions, as the schema extract has no contrast field. Run A at least tried the N analysis.",
      "Schema result: run A 7 errors (FAIL), run B 1 error (FAIL), and run B has 0 after changing the string version \"1\" to the integer 1, while run A still has 4. Passing the schema did not catch the ANL01FL, SITEGR1 or pairwise-subset problems."
    ],
    "summary": "Run A (cold, excerpts and prompt only) and run B (same plus a short schema property extract), 2026-10-21, one run each. Objective check: run A fails the real CDISC ARS v1.0 JSON schema with 7 errors, run B fails with 1 (a string version that should be an integer; 0 errors once fixed), the lazy run fails with 2. Content check of 57 claims by a separate sub-agent against SAP Template 5, the define.xml and the pilot data: 27 correct, 12 partly, 7 wrong, 1 not in source, 10 false gap. What the excerpt fixed: three arms, Efficacy population, ANCOVA with dose response, unadjusted pairwise tests, the Template 5 footnotes, and datasets and variables bound only from the define.xml listing. What a schema pass does not catch: both runs omit ANL01FL = Y (237 rows for 234 subjects) and use SITEID rather than the SAP 7.1 pooled site, and run A builds its pairwise subsets on treatment alone. Several gap-list items are answerable from the full SAP, define.xml or data. Verified by a sub-agent that did not write the outputs; the schema and data checks were run by the builder. One model, one run each, so this is not a rate.",
    "independence": "The 57 content rows were written by a separate sub-agent that did not write either output; it read the SAP text, define.xml and the script output, and did not re-run the validator. The builder ran the validator and the R script, corrected two cites in the rows (the 0/54/81 doses are SAP 3.1.1, p.6, not 1.2) and wrote the page. Not a human review."
  },
  "run": {
    "generated_by": "Claude (Anthropic), run as subagents (model sonnet) on 2026-10-21: lazy run, then run A and run B in parallel, then a separate verifier sub-agent. Builder: Claude Sonnet 5.5.",
    "not_tested_in": "Microsoft 365 Copilot"
  },
  "run_summary": [
    {
      "kind": "fail",
      "label": "Real ARS schema",
      "text": "Run A 7 errors, run B 1 error (0 once a string version is made an integer), lazy run 2. Objective, but it checks form only."
    },
    {
      "kind": "warn",
      "label": "Passing is not right",
      "text": "Both runs omit ANL01FL = Y: 237 rows for 234 subjects, and both use SITEID not the pooled site."
    },
    {
      "kind": "ok",
      "label": "From the excerpt",
      "text": "Three arms, Efficacy set, ANCOVA dose response, unadjusted pairwise and footnotes matched Template 5; variables bound from define.xml only."
    }
  ]
}