From f7cd8b39a365299476cc8ed1ab4e546b63098ee9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 11 Sep 2026 14:23:49 +0200 Subject: [PATCH] feat: a grounded resource ends with the references it drew on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The grounding metadata went to the API response and the logs, which is no use to someone holding the deck. A teaching resource shown to trainees should carry its own provenance, so a grounded one now ends with a References section — the final slide in a presentation — listing the library excerpts it actually used, by title and page. Restricted deliberately: only excerpts actually drawn on, nothing invented. That was worth checking rather than trusting. Generated a deck and compared every citation against the source metadata: "Kliegman R. Nelson Textbook of Pediatrics, 22nd ed., 2024, p. 2604" against a stored title of "Kliegman R. Nelson Textbook of Pediatrics 2-Volume Set 22ed 2024" at page 2604, and the same for Fleisher & Ludwig, Rosen's, Understanding Pathophysiology and the AAP compendium. The model reformatted filename-derived titles into readable citations using only what it was given. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Dv6sqaY6Vq3ChZHMem3cnU --- src/routes/learningAI.js | 3 +++ test/learning-retrieval.test.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/routes/learningAI.js b/src/routes/learningAI.js index cb35b2f6..28c40f2f 100644 --- a/src/routes/learningAI.js +++ b/src/routes/learningAI.js @@ -152,6 +152,9 @@ function buildGeneratePrompt(opts) { source += '\nThe following excerpts come from this institution\'s indexed clinical library. ' + 'Prefer them over your own recall wherever they disagree, and do not contradict them. ' + 'They are reference material, not a template: write the resource in your own words.\n\n' + + 'End the resource with a short References section listing only the excerpts you actually ' + + 'drew on, by title and page. In a presentation this is the final slide, titled References. ' + + 'Do not invent references, and do not list an excerpt you did not use.\n\n' + 'LIBRARY EXCERPTS:\n"""\n' + corpusContext + '\n"""\n'; } diff --git a/test/learning-retrieval.test.js b/test/learning-retrieval.test.js index 1d836978..abb6ae2a 100644 --- a/test/learning-retrieval.test.js +++ b/test/learning-retrieval.test.js @@ -111,6 +111,10 @@ test('the corpus block tells the model to prefer it over recall', () => { const route = read('src/routes/learningAI.js'); assert.match(route, /Prefer them over your own recall wherever they disagree/); assert.match(route, /reference material, not a template/, 'so it writes rather than copies'); + // Provenance a clinician can check, on the deck itself rather than only in a + // log. Restricted to excerpts actually used, and explicitly not invented. + assert.match(route, /In a presentation this is the final slide, titled References/); + assert.match(route, /Do not invent references, and do not list an excerpt you did not use/); // Opt in: a resource on something the library does not cover is better // written without it than padded with the nearest unrelated excerpts. assert.match(route, /var useCorpus\s+= String\(req\.body\.useCorpus\) === 'true'/);