@inflexa-ai/harness 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/dist/agents/report-builder.d.ts +2 -0
  2. package/dist/agents/report-builder.js +2 -0
  3. package/dist/app/spawn-report-session.d.ts +85 -0
  4. package/dist/app/spawn-report-session.js +83 -0
  5. package/dist/contracts/chat-events.d.ts +9 -0
  6. package/dist/contracts/index.d.ts +6 -2
  7. package/dist/contracts/index.js +3 -1
  8. package/dist/contracts/organ-system.d.ts +49 -0
  9. package/dist/contracts/organ-system.js +67 -0
  10. package/dist/contracts/report-blocks.d.ts +564 -0
  11. package/dist/contracts/report-blocks.js +117 -0
  12. package/dist/contracts/report-reference.d.ts +459 -0
  13. package/dist/contracts/report-reference.js +256 -0
  14. package/dist/contracts/schemas/chat-events.d.ts +2 -0
  15. package/dist/contracts/schemas/chat-events.js +2 -0
  16. package/dist/contracts/severity.d.ts +15 -0
  17. package/dist/contracts/severity.js +10 -0
  18. package/dist/contracts/target-dossier.d.ts +8675 -12972
  19. package/dist/contracts/target-dossier.js +534 -591
  20. package/dist/data/safety-panel-schema.d.ts +18 -5
  21. package/dist/data/safety-panel-schema.js +4 -4
  22. package/dist/execution/artifact-metadata.js +1 -0
  23. package/dist/execution/report-runner.js +1 -3
  24. package/dist/execution/run-synthesis.js +2 -0
  25. package/dist/index.d.ts +6 -0
  26. package/dist/index.js +19 -0
  27. package/dist/lib/async-utils.d.ts +16 -4
  28. package/dist/lib/async-utils.js +20 -15
  29. package/dist/lib/host-concurrency.js +1 -0
  30. package/dist/loop/__fixtures__/scripted-provider.js +23 -2
  31. package/dist/loop/run-agent.js +58 -10
  32. package/dist/loop/tool-detail.d.ts +40 -0
  33. package/dist/loop/tool-detail.js +35 -3
  34. package/dist/loop/types.d.ts +13 -0
  35. package/dist/memory/thread-history.d.ts +10 -0
  36. package/dist/memory/thread-history.js +12 -1
  37. package/dist/prompts/target-assessment/briefs/executive-recommendation.d.ts +1 -1
  38. package/dist/prompts/target-assessment/briefs/executive-recommendation.js +5 -5
  39. package/dist/prompts/target-assessment/briefs/liability-bullets.d.ts +1 -1
  40. package/dist/prompts/target-assessment/briefs/liability-bullets.js +1 -1
  41. package/dist/prompts/target-assessment/briefs/target-organ-liabilities.d.ts +1 -1
  42. package/dist/prompts/target-assessment/briefs/target-organ-liabilities.js +11 -3
  43. package/dist/prompts/target-assessment/investigation/adversarial-critique.d.ts +1 -0
  44. package/dist/prompts/target-assessment/investigation/adversarial-critique.js +67 -0
  45. package/dist/prompts/target-assessment/investigation/claim-reverification.d.ts +1 -0
  46. package/dist/prompts/target-assessment/investigation/claim-reverification.js +49 -0
  47. package/dist/prompts/target-assessment/investigation/index.d.ts +3 -0
  48. package/dist/prompts/target-assessment/investigation/index.js +3 -0
  49. package/dist/prompts/target-assessment/investigation/mechanism-proposal.d.ts +1 -0
  50. package/dist/prompts/target-assessment/investigation/mechanism-proposal.js +49 -0
  51. package/dist/prompts/target-assessment/tox-voice/index.d.ts +1 -1
  52. package/dist/prompts/target-assessment/tox-voice/vocabulary.d.ts +8 -5
  53. package/dist/prompts/target-assessment/tox-voice/vocabulary.js +9 -20
  54. package/dist/providers/__fixtures__/session.d.ts +5 -4
  55. package/dist/providers/__fixtures__/session.js +4 -4
  56. package/dist/report-model/block-walk.d.ts +56 -0
  57. package/dist/report-model/block-walk.js +89 -0
  58. package/dist/report-model/draft-finish.d.ts +60 -0
  59. package/dist/report-model/draft-finish.js +56 -0
  60. package/dist/report-model/draft-operations.d.ts +125 -0
  61. package/dist/report-model/draft-operations.js +341 -0
  62. package/dist/report-model/draft-read.d.ts +59 -0
  63. package/dist/report-model/draft-read.js +109 -0
  64. package/dist/report-model/draft.d.ts +51 -0
  65. package/dist/report-model/draft.js +32 -0
  66. package/dist/report-model/fixture-resolver.d.ts +8 -0
  67. package/dist/report-model/fixture-resolver.js +252 -0
  68. package/dist/report-model/mint-snapshot.d.ts +30 -0
  69. package/dist/report-model/mint-snapshot.js +40 -0
  70. package/dist/report-model/reference-resolver.d.ts +113 -0
  71. package/dist/report-model/reference-resolver.js +60 -0
  72. package/dist/report-model/structural-validation.d.ts +22 -0
  73. package/dist/report-model/structural-validation.js +68 -0
  74. package/dist/report-model/validate.d.ts +40 -0
  75. package/dist/report-model/validate.js +80 -0
  76. package/dist/report-render/chart.d.ts +33 -0
  77. package/dist/report-render/chart.js +538 -0
  78. package/dist/report-render/page.d.ts +127 -0
  79. package/dist/report-render/page.js +307 -0
  80. package/dist/report-render/references.d.ts +32 -0
  81. package/dist/report-render/references.js +44 -0
  82. package/dist/report-render/render.d.ts +25 -0
  83. package/dist/report-render/render.js +125 -0
  84. package/dist/report-render/script-json.d.ts +13 -0
  85. package/dist/report-render/script-json.js +15 -0
  86. package/dist/report-render/types.d.ts +39 -0
  87. package/dist/report-render/types.js +10 -0
  88. package/dist/report-render/views/chart-view.d.ts +11 -0
  89. package/dist/report-render/views/chart-view.js +23 -0
  90. package/dist/report-render/views/page-view.d.ts +20 -0
  91. package/dist/report-render/views/page-view.js +49 -0
  92. package/dist/report-render/views/prose.d.ts +28 -0
  93. package/dist/report-render/views/prose.js +75 -0
  94. package/dist/report-render/views/references-view.d.ts +20 -0
  95. package/dist/report-render/views/references-view.js +64 -0
  96. package/dist/report-render/views/values.d.ts +42 -0
  97. package/dist/report-render/views/values.js +43 -0
  98. package/dist/runtime/boot.d.ts +3 -3
  99. package/dist/runtime/boot.js +15 -4
  100. package/dist/runtime/dbos.d.ts +4 -4
  101. package/dist/state/artifacts.d.ts +16 -0
  102. package/dist/state/artifacts.js +18 -0
  103. package/dist/state/init.js +31 -0
  104. package/dist/state/purge-analysis.js +1 -0
  105. package/dist/state/report-versions.d.ts +132 -0
  106. package/dist/state/report-versions.js +194 -0
  107. package/dist/tasks/data-profile.js +1 -0
  108. package/dist/tools/bio/chembl.js +1 -0
  109. package/dist/tools/bio/comptox.js +1 -0
  110. package/dist/tools/bio/drug-gene-interactions.js +1 -0
  111. package/dist/tools/bio/gene-disease-evidence.js +1 -0
  112. package/dist/tools/bio/gene-preclinical-profile.js +1 -0
  113. package/dist/tools/bio/keys.d.ts +3 -2
  114. package/dist/tools/bio/keys.js +3 -2
  115. package/dist/tools/bio/lookup-annotation.js +1 -0
  116. package/dist/tools/bio/opentargets.d.ts +3 -3
  117. package/dist/tools/bio/opentargets.js +4 -3
  118. package/dist/tools/bio/pubchem.js +1 -0
  119. package/dist/tools/bio/search-clinical-trials.js +1 -0
  120. package/dist/tools/bio/search-faers.js +1 -0
  121. package/dist/tools/bio/search-geo-datasets.js +1 -0
  122. package/dist/tools/bio/search-interactions.js +1 -0
  123. package/dist/tools/bio/target-safety.d.ts +4 -6
  124. package/dist/tools/bio/target-safety.js +7 -6
  125. package/dist/tools/define-tool.d.ts +19 -12
  126. package/dist/tools/define-tool.js +4 -2
  127. package/dist/tools/display/show-user.js +1 -0
  128. package/dist/tools/iterate-report.js +2 -0
  129. package/dist/tools/lib/chembl-client.d.ts +2 -0
  130. package/dist/tools/lib/chembl-client.js +1 -0
  131. package/dist/tools/lib/monarch-client.d.ts +42 -0
  132. package/dist/tools/lib/monarch-client.js +100 -0
  133. package/dist/tools/report/build-report.js +1 -0
  134. package/dist/tools/report/mint-preview-url.js +1 -0
  135. package/dist/tools/report/preview-snapshot.js +1 -0
  136. package/dist/tools/report/submit-report.js +1 -0
  137. package/dist/tools/report/version-fs.js +4 -0
  138. package/dist/tools/report-authoring/authoring-tools.d.ts +134 -0
  139. package/dist/tools/report-authoring/authoring-tools.js +352 -0
  140. package/dist/tools/research/context7-docs.js +2 -0
  141. package/dist/tools/research/generate-analogy-report.js +1 -0
  142. package/dist/tools/research/generate-plan.js +3 -0
  143. package/dist/tools/research/inspect-data-profile.js +4 -0
  144. package/dist/tools/research/literature-reviewer.js +1 -0
  145. package/dist/tools/research/search-arxiv.js +1 -0
  146. package/dist/tools/research/search-github-repos.js +1 -0
  147. package/dist/tools/research/search-semantic-scholar.js +1 -0
  148. package/dist/tools/sandbox/list-available-packages.js +23 -0
  149. package/dist/tools/sandbox/list-available-refs.js +36 -0
  150. package/dist/tools/sandbox/report-blocker.js +1 -0
  151. package/dist/tools/sandbox/skills.js +2 -0
  152. package/dist/tools/workspace/file-stat.js +1 -0
  153. package/dist/tools/workspace/show-file.js +2 -0
  154. package/dist/tools/workspace/show-plan.js +1 -0
  155. package/dist/workflows/execute-analysis.d.ts +5 -1
  156. package/dist/workflows/execute-analysis.js +5 -5
  157. package/dist/workflows/execute-target-assessment.d.ts +13 -2
  158. package/dist/workflows/execute-target-assessment.js +78 -16
  159. package/dist/workflows/target-assessment/assemblers/index.d.ts +1 -1
  160. package/dist/workflows/target-assessment/assemblers/index.js +1 -1
  161. package/dist/workflows/target-assessment/assemblers/literature.d.ts +9 -27
  162. package/dist/workflows/target-assessment/assemblers/literature.js +32 -48
  163. package/dist/workflows/target-assessment/assemblers/orchestrator.d.ts +17 -9
  164. package/dist/workflows/target-assessment/assemblers/orchestrator.js +195 -85
  165. package/dist/workflows/target-assessment/assemblers/safety.d.ts +70 -48
  166. package/dist/workflows/target-assessment/assemblers/safety.js +125 -42
  167. package/dist/workflows/target-assessment/collectors/index.d.ts +5 -2
  168. package/dist/workflows/target-assessment/collectors/index.js +48 -5
  169. package/dist/workflows/target-assessment/coverage.d.ts +43 -27
  170. package/dist/workflows/target-assessment/coverage.js +33 -29
  171. package/dist/workflows/target-assessment/fanout/index.js +1 -0
  172. package/dist/workflows/target-assessment/investigation/index.d.ts +97 -0
  173. package/dist/workflows/target-assessment/investigation/index.js +419 -0
  174. package/dist/workflows/target-assessment/lib/approval-precedents.d.ts +26 -5
  175. package/dist/workflows/target-assessment/lib/approval-precedents.js +95 -29
  176. package/dist/workflows/target-assessment/lib/citation-validator.js +1 -1
  177. package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.d.ts +2 -2
  178. package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.d.ts +2 -3
  179. package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.js +0 -4
  180. package/dist/workflows/target-assessment/lib/compute-derived.d.ts +6 -5
  181. package/dist/workflows/target-assessment/lib/compute-derived.js +14 -5
  182. package/dist/workflows/target-assessment/lib/family-complex-supplement.d.ts +5 -6
  183. package/dist/workflows/target-assessment/lib/family-complex-supplement.js +2 -3
  184. package/dist/workflows/target-assessment/lib/fda-label-safety.d.ts +72 -0
  185. package/dist/workflows/target-assessment/lib/fda-label-safety.js +166 -0
  186. package/dist/workflows/target-assessment/lib/heterodimer-filter.d.ts +0 -9
  187. package/dist/workflows/target-assessment/lib/heterodimer-filter.js +0 -10
  188. package/dist/workflows/target-assessment/lib/hpo-organ-map.d.ts +34 -0
  189. package/dist/workflows/target-assessment/lib/hpo-organ-map.js +63 -0
  190. package/dist/workflows/target-assessment/lib/impc-organ-map.d.ts +19 -0
  191. package/dist/workflows/target-assessment/lib/impc-organ-map.js +39 -0
  192. package/dist/workflows/target-assessment/lib/meddra-organ-map.d.ts +24 -14
  193. package/dist/workflows/target-assessment/lib/meddra-organ-map.js +59 -47
  194. package/dist/workflows/target-assessment/lib/recommendation-sanitizer.js +1 -1
  195. package/dist/workflows/target-assessment/lib/regulatory-actions.d.ts +2 -3
  196. package/dist/workflows/target-assessment/lib/regulatory-actions.js +33 -4
  197. package/dist/workflows/target-assessment/lib/safety-corroboration.d.ts +44 -0
  198. package/dist/workflows/target-assessment/lib/safety-corroboration.js +273 -0
  199. package/dist/workflows/target-assessment/lib/target-identity-filter.d.ts +5 -7
  200. package/dist/workflows/target-assessment/lib/target-identity-filter.js +5 -7
  201. package/dist/workflows/target-assessment/metrics.d.ts +1 -6
  202. package/dist/workflows/target-assessment/metrics.js +1 -13
  203. package/dist/workflows/target-assessment/phase4-assemble.d.ts +2147 -807
  204. package/dist/workflows/target-assessment/phase4-assemble.js +19 -19
  205. package/dist/workflows/target-assessment/phase5-persist.d.ts +20 -21
  206. package/dist/workflows/target-assessment/phase5-persist.js +56 -173
  207. package/dist/workflows/target-assessment/schemas.d.ts +46 -1
  208. package/dist/workflows/target-assessment/schemas.js +19 -0
  209. package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.d.ts +1 -0
  210. package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.js +2 -0
  211. package/dist/workflows/target-assessment/steps/phase2-aggregate.d.ts +26 -62
  212. package/dist/workflows/target-assessment/steps/phase2-aggregate.js +0 -4
  213. package/dist/workflows/target-assessment/steps/phase3-aggregate.d.ts +27 -154
  214. package/dist/workflows/target-assessment/steps/phase3-aggregate.js +0 -6
  215. package/dist/workflows/target-assessment/steps/synthesis/diagnostics.d.ts +0 -6
  216. package/dist/workflows/target-assessment/steps/synthesis/diagnostics.js +0 -18
  217. package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.d.ts +1 -0
  218. package/dist/workflows/target-assessment/synthesis/index.d.ts +52 -5
  219. package/dist/workflows/target-assessment/synthesis/index.js +4 -1
  220. package/dist/workflows/target-assessment/synthesis-probes.d.ts +3 -3
  221. package/package.json +4 -1
@@ -41,10 +41,10 @@ dossier in the rationale.
41
41
  plausibility only; they do not support tractability, safety, or
42
42
  efficacy claims.
43
43
  - Do NOT cite trial AEs, efficacy, or termination reasons from
44
- \`related_target_trials[]\` as evidence of the assessment target's
45
- drug behaviour. These trials are on related receptors (e.g.,
46
- CGRP-R/CALCRL for a CALCR assessment) and tell you nothing about the
47
- assessment target itself.
44
+ \`excluded_rows[]\` as evidence of the assessment target's drug
45
+ behaviour. Those trials are attributed elsewhere — often to a related
46
+ receptor (e.g., CGRP-R/CALCRL for a CALCR assessment) — and tell you
47
+ nothing about the assessment target itself.
48
48
  - Do NOT interpret a Reactome pathway containing the gene symbol as
49
49
  evidence of drug-target binding. Reactome pathways list participating
50
50
  genes, not drug interactions. Drug-binding evidence comes from
@@ -61,7 +61,7 @@ dossier in the rationale.
61
61
  distinct-substance counts.
62
62
  - Do NOT surface organ-level liability claims (kidney, CNS, hepatic,
63
63
  cardiac, etc.) unless they appear in
64
- \`safety_profile.target_organ_liabilities\`. That section is the
64
+ \`safety_profile.target_organ_liabilities.data.rows\`. That section is the
65
65
  probe-validated source for organ claims; any organ liability the
66
66
  probe rejected does not belong in \`key_risks\`.
67
67
  - Do NOT recommend a between-cofactor selectivity margin against rows in
@@ -1 +1 @@
1
- export declare const liabilityBulletsBrief = "# Section: Liability bullets\n\nWrite evidence-cited liability bullets in toxicologist voice. Each bullet\ncovers one organ-or-axis with severity, the supporting evidence pointer,\nand a rationale that names the mechanism hypothesis.\n\n## Inputs\nYou receive the full Phase-4 dossier as JSON. Cite section paths and\ncounts (FAERS n=NN, IMPC p=...) verbatim from the dossier.\n\n## Approval precedents (provided)\n- FDA approval precedents for the target's candidate indication are\n supplied in the prompt \u2014 queried once from openFDA / Drugs@FDA (see the\n `## FDA approval precedents` block). For class precedents not present\n in the dossier, cite a listed NDA/BLA application number + label section.\n Do not assert precedents absent from that block and the dossier.\n\n## Output discipline\n- Severity is one of high / medium / low.\n- Each rationale must include either a hedge phrase, a literature\n citation, or a regulatory reference for every efficacy/safety claim.\n- Do not fabricate counts. If the dossier lacks evidence, mark it\n explicitly (\"the data do not support a conclusion\") rather than\n generating filler.\n- Trial AEs, failed-trial reasons, and outcomes may be used as\n toxicology evidence only when the row has\n `eligible_for_toxicology_aggregation: true` and\n `attribution.evidence_role: \"supports_target\"`. Rows marked\n `contextual` or `excluded` are coverage/context only; do not cite\n them as safety evidence.\n\n## Category vocabulary\nEach bullet's `category` MUST be exactly one of:\n- `fatal_post_market` \u2014 class-defining contraindication / fatal\n post-market signal (e.g., anaphylaxis-with-death on a class label).\n When `safety_profile.regulatory_actions.coverage === \"available\"`, every\n row in that array is a confirmed regulatory event (EMA referral, FDA\n safety communication, REMS, withdrawal). Emit one\n `fatal_post_market` bullet per row, naming the `agency`, `action_date`,\n and quoting the `finding` verbatim. Do NOT phrase regulatory\n actions as inferences from FAERS counts.\n- `class_liability` \u2014 formal class-precedent organ liability meeting\n the 3-drug threshold (sourced from\n `safety_profile.class_precedent.data.per_organ`).\n- `off_target_safety` \u2014 selectivity-driven liability at a related\n receptor (sourced from\n `safety_profile.off_target_panel.data.rows`).\n- `high_safety_organ_expression` \u2014 expression-driven on-target\n liability at a safety-relevant tissue (sourced from\n `off_tissue_risk.data.rows` and the\n `safety_profile.target_organ_liabilities` probe).\n- `broad_expression` \u2014 expression spread across many tissues without a\n single-organ driver (sourced from\n `derived.liability_summary.expression_breadth`).\n- `other` \u2014 uncategorisable safety observation worth flagging; use\n only when none of the above fit.\n\n## Obligate-cofactor rows\n\n`safety_profile.off_target_panel.data.excluded_rows[]` may contain rows\nwith `relationship: \"obligate_cofactor\"`. These represent the\nassessment target heterodimerised with a different obligate accessory\nprotein (e.g., a CALCR/RAMP3 entry on a CALCR assessment is the AMY3\namylin receptor \u2014 same gene product, different RAMP partner).\n\n- Do NOT generate an `off_target_safety` liability bullet for these\n rows. Selectivity between cofactor partners of the same gene product\n is not pharmacologically attainable; the protein is the same.\n- Do NOT recommend a between-cofactor selectivity margin (e.g., \"\u2265N-fold\n over <gene>/RAMP<N>\") against an obligate-cofactor row. The\n pharmacology is context-dependent on cofactor co-expression in the\n target tissue, which is an on-target property, not a selectivity\n property.\n- If the row carries a `clinical_consequence` annotation (e.g.,\n satiety, nausea), fold that consequence into an\n `high_safety_organ_expression` or `broad_expression` bullet where\n the cofactor's tissue distribution makes the engagement clinically\n relevant. Do not invent a selectivity liability.\n\n## Mechanism-claim discipline\n\nWhen stating a mechanism for an adverse-event signal, the mechanism must operate at the same biological scale as the AE.\n\n- Do NOT cite developmental, regenerative, or homeostatic biology (e.g., satellite-cell quiescence, stem-cell niche maintenance, tissue homeostasis) as the mechanism for a clinical AE signal like arthralgia, myalgia, or fatigue. Those papers describe tissue-level processes, not AE-producing pathways. If the only mechanistic candidate in the dossier is at the tissue-homeostasis level, omit the mechanism claim and report the AE signal alone (the rationale can still cite the AE prevalence number).\n\n- Respect anatomical boundaries. The nucleus tractus solitarius (NTS) is brainstem, not hypothalamus. The nucleus accumbens is basal ganglia, not hypothalamus. The amygdala is subcortical, not hypothalamus. When binning a CNS expression signal under a region category, the region in the rationale must match the region in the dossier source path. Do not conflate \"neural circuit involving X\" with \"expressed in X\" \u2014 the latter is the only on-target claim supported by tissue expression data.\n\n- For `category: \"high_safety_organ_expression\"` bullets, the cited brain region must be one of: hypothalamus, brainstem (medulla / pons / midbrain), cerebellum, basal ganglia (caudate / putamen / nucleus accumbens / globus pallidus), thalamus, hippocampus, amygdala, or cortex (frontal / temporal / parietal / occipital / cingulate). Do not invent new region categories.\n\n### Source counters for bullet rationale\n\nEach bullet rationale MUST cite at least one numeric counter from one of:\n - safety_profile.faers.data.top_signals[].report_count (preferred when available)\n - safety_profile.faers.data.per_modulator[].report_count\n - safety_profile.class_precedent.data.per_organ[].top_aes[].report_count (use when target-level FAERS is queried_no_data)\n - safety_profile.trial_aes.data.serious[].incidence_pct / non_serious[].incidence_pct\n - safety_profile.off_target_panel.data.rows[].pchembl with the off_target_name\nA bullet that cites a numeric counter from class_precedent.per_organ.top_aes.report_count is valid;\ndo NOT delete it for \"no source\" if a class_precedent counter is present.\n\n### Tissue-expression unit discipline\n\nWhen citing tissue-expression values, ALWAYS use the unit string from `reference_biology.normal_tissue_expression.data.unit` (one of: \"tpm\",\n\"ntpm\", \"consensus_normalized\"). Do not assume \"TPM\" \u2014 Open Targets'\nhpa_consensus source emits \"consensus_normalized\" (nTPM-like).\nRender as e.g. \"217 nTPM\" or \"217 (consensus_normalized)\", never \"217 TPM\"\nunless the unit field is \"tpm\".\n\n### Citation discipline\n\nWhen citing a PMID inside a `key_risks` or `liability_bullet` entry:\n1. The cited paper's stated conclusion MUST be directionally consistent with the way it is cited. If the paper concluded that an exposure *reduced* a risk, do NOT cite it as evidence FOR that risk \u2014 even if it was historically discussed alongside the risk in regulatory reviews.\n2. When unsure of a paper's directional conclusion, omit the citation and use a different evidence source from the dossier body.\n3. Every NCT cited must appear in the dossier's clinical_development.trials, failed_trials, or analytics.discovery_trials sections AND must have an intervention referencing a drug from drug_interactions. NCTs whose interventions are outside the on-target class (e.g., SGLT2 inhibitors in a GLP-1R dossier) must not be cited.";
1
+ export declare const liabilityBulletsBrief = "# Section: Liability bullets\n\nWrite evidence-cited liability bullets in toxicologist voice. Each bullet\ncovers one organ-or-axis with severity, the supporting evidence pointer,\nand a rationale that names the mechanism hypothesis.\n\n## Inputs\nYou receive the full Phase-4 dossier as JSON. Cite section paths and\ncounts (FAERS n=NN, IMPC p=...) verbatim from the dossier.\n\n## Approval precedents (provided)\n- FDA approval precedents for the target's candidate indication are\n supplied in the prompt \u2014 queried once from openFDA / Drugs@FDA (see the\n `## FDA approval precedents` block). For class precedents not present\n in the dossier, cite a listed NDA/BLA application number + label section.\n Do not assert precedents absent from that block and the dossier.\n\n## Output discipline\n- Severity is one of high / medium / low.\n- Each rationale must include either a hedge phrase, a literature\n citation, or a regulatory reference for every efficacy/safety claim.\n- Do not fabricate counts. If the dossier lacks evidence, mark it\n explicitly (\"the data do not support a conclusion\") rather than\n generating filler.\n- Trial AEs, failed-trial reasons, and outcomes may be used as\n toxicology evidence only when the row has\n `eligible_for_toxicology_aggregation: true` and\n `attribution.evidence_role: \"supports_target\"`. Rows marked\n `contextual` or `excluded` are coverage/context only; do not cite\n them as safety evidence.\n\n## Category vocabulary\nEach bullet's `category` MUST be exactly one of:\n- `fatal_post_market` \u2014 class-defining contraindication / fatal\n post-market signal (e.g., anaphylaxis-with-death on a class label).\n When `safety_profile.regulatory_actions.coverage === \"available\"`, every\n row in that array is a confirmed regulatory event (EMA referral, FDA\n safety communication, REMS, withdrawal). Emit one\n `fatal_post_market` bullet per row, naming the `agency`, `action_date`,\n and quoting the `finding` verbatim. Do NOT phrase regulatory\n actions as inferences from FAERS counts.\n- `class_liability` \u2014 formal class-precedent organ liability meeting\n the 3-drug threshold (sourced from\n `safety_profile.class_precedent.data.per_organ`).\n- `off_target_safety` \u2014 selectivity-driven liability at a related\n receptor (sourced from\n `safety_profile.off_target_panel.data.rows`).\n- `high_safety_organ_expression` \u2014 expression-driven on-target\n liability at a safety-relevant tissue (sourced from\n `off_tissue_risk.data.rows` and the\n `safety_profile.target_organ_liabilities.data.rows` probe).\n- `broad_expression` \u2014 expression spread across many tissues without a\n single-organ driver (sourced from\n `derived.liability_summary.expression_breadth`).\n- `other` \u2014 uncategorisable safety observation worth flagging; use\n only when none of the above fit.\n\n## Obligate-cofactor rows\n\n`safety_profile.off_target_panel.data.excluded_rows[]` may contain rows\nwith `relationship: \"obligate_cofactor\"`. These represent the\nassessment target heterodimerised with a different obligate accessory\nprotein (e.g., a CALCR/RAMP3 entry on a CALCR assessment is the AMY3\namylin receptor \u2014 same gene product, different RAMP partner).\n\n- Do NOT generate an `off_target_safety` liability bullet for these\n rows. Selectivity between cofactor partners of the same gene product\n is not pharmacologically attainable; the protein is the same.\n- Do NOT recommend a between-cofactor selectivity margin (e.g., \"\u2265N-fold\n over <gene>/RAMP<N>\") against an obligate-cofactor row. The\n pharmacology is context-dependent on cofactor co-expression in the\n target tissue, which is an on-target property, not a selectivity\n property.\n- If the row carries a `clinical_consequence` annotation (e.g.,\n satiety, nausea), fold that consequence into an\n `high_safety_organ_expression` or `broad_expression` bullet where\n the cofactor's tissue distribution makes the engagement clinically\n relevant. Do not invent a selectivity liability.\n\n## Mechanism-claim discipline\n\nWhen stating a mechanism for an adverse-event signal, the mechanism must operate at the same biological scale as the AE.\n\n- Do NOT cite developmental, regenerative, or homeostatic biology (e.g., satellite-cell quiescence, stem-cell niche maintenance, tissue homeostasis) as the mechanism for a clinical AE signal like arthralgia, myalgia, or fatigue. Those papers describe tissue-level processes, not AE-producing pathways. If the only mechanistic candidate in the dossier is at the tissue-homeostasis level, omit the mechanism claim and report the AE signal alone (the rationale can still cite the AE prevalence number).\n\n- Respect anatomical boundaries. The nucleus tractus solitarius (NTS) is brainstem, not hypothalamus. The nucleus accumbens is basal ganglia, not hypothalamus. The amygdala is subcortical, not hypothalamus. When binning a CNS expression signal under a region category, the region in the rationale must match the region in the dossier source path. Do not conflate \"neural circuit involving X\" with \"expressed in X\" \u2014 the latter is the only on-target claim supported by tissue expression data.\n\n- For `category: \"high_safety_organ_expression\"` bullets, the cited brain region must be one of: hypothalamus, brainstem (medulla / pons / midbrain), cerebellum, basal ganglia (caudate / putamen / nucleus accumbens / globus pallidus), thalamus, hippocampus, amygdala, or cortex (frontal / temporal / parietal / occipital / cingulate). Do not invent new region categories.\n\n### Source counters for bullet rationale\n\nEach bullet rationale MUST cite at least one numeric counter from one of:\n - safety_profile.faers.data.top_signals[].report_count (preferred when available)\n - safety_profile.faers.data.per_modulator[].report_count\n - safety_profile.class_precedent.data.per_organ[].top_aes[].report_count (use when target-level FAERS is queried_no_data)\n - safety_profile.trial_aes.data.serious[].incidence_pct / non_serious[].incidence_pct\n - safety_profile.off_target_panel.data.rows[].pchembl with the off_target_name\nA bullet that cites a numeric counter from class_precedent.per_organ.top_aes.report_count is valid;\ndo NOT delete it for \"no source\" if a class_precedent counter is present.\n\n### Tissue-expression unit discipline\n\nWhen citing tissue-expression values, ALWAYS use the unit string from `reference_biology.normal_tissue_expression.data.unit` (one of: \"tpm\",\n\"ntpm\", \"consensus_normalized\"). Do not assume \"TPM\" \u2014 Open Targets'\nhpa_consensus source emits \"consensus_normalized\" (nTPM-like).\nRender as e.g. \"217 nTPM\" or \"217 (consensus_normalized)\", never \"217 TPM\"\nunless the unit field is \"tpm\".\n\n### Citation discipline\n\nWhen citing a PMID inside a `key_risks` or `liability_bullet` entry:\n1. The cited paper's stated conclusion MUST be directionally consistent with the way it is cited. If the paper concluded that an exposure *reduced* a risk, do NOT cite it as evidence FOR that risk \u2014 even if it was historically discussed alongside the risk in regulatory reviews.\n2. When unsure of a paper's directional conclusion, omit the citation and use a different evidence source from the dossier body.\n3. Every NCT cited must appear in the dossier's clinical_development.trials, failed_trials, or analytics.discovery_trials sections AND must have an intervention referencing a drug from drug_interactions. NCTs whose interventions are outside the on-target class (e.g., SGLT2 inhibitors in a GLP-1R dossier) must not be cited.";
@@ -48,7 +48,7 @@ Each bullet's \`category\` MUST be exactly one of:
48
48
  - \`high_safety_organ_expression\` — expression-driven on-target
49
49
  liability at a safety-relevant tissue (sourced from
50
50
  \`off_tissue_risk.data.rows\` and the
51
- \`safety_profile.target_organ_liabilities\` probe).
51
+ \`safety_profile.target_organ_liabilities.data.rows\` probe).
52
52
  - \`broad_expression\` — expression spread across many tissues without a
53
53
  single-organ driver (sourced from
54
54
  \`derived.liability_summary.expression_breadth\`).
@@ -1 +1 @@
1
- export declare const targetOrganLiabilitiesBrief = "# Section: Target-organ liabilities (audit trail)\n\nFor each implicated organ system, write a per-organ trail that connects\ngenetic, expression, FAERS, and class-precedent evidence to a stated\nmechanism hypothesis.\n\n## Inputs\nYou receive the full Phase-4 dossier as JSON. Cite section paths and\ncounts verbatim. Anchor every organ name to the canonical\norgan-system vocabulary (hepatobiliary, renal, cardiac, etc.) \u2014 colloquial\nsubstitutes are rejected by the voice probe.\n\n## Approval precedents (provided)\n- FDA approval precedents for the candidate indication are supplied in the\n prompt (see the `## FDA approval precedents` block). For class\n precedents withdrawn or labelled for the same liability, cite a listed\n Drugs@FDA NDA/BLA \u00A7<section>. Do not assert precedents absent from that block.\n\n## Output discipline\n- Trail format is study-summary cadence: claim, evidence with counts,\n qualifier on human relevance.\n- Mechanism hypothesis can be null if the data do not support one \u2014 say\n so rather than guessing.\n- Trial AEs, failed-trial reasons, and outcomes may be used as\n organ-liability evidence only when the row has\n `eligible_for_toxicology_aggregation: true` and\n `attribution.evidence_role: \"supports_target\"`. Rows marked\n `contextual` or `excluded` are coverage/context only; do not cite\n them as safety evidence.";
1
+ export declare const targetOrganLiabilitiesBrief: string;
@@ -1,3 +1,7 @@
1
+ import { ORGAN_SYSTEMS } from "../../../contracts/organ-system.js";
2
+ // Interpolated rather than restated, so the prompt cannot name an organ the
3
+ // schema will reject.
4
+ const organTokens = ORGAN_SYSTEMS.join(", ");
1
5
  export const targetOrganLiabilitiesBrief = `# Section: Target-organ liabilities (audit trail)
2
6
 
3
7
  For each implicated organ system, write a per-organ trail that connects
@@ -6,9 +10,9 @@ mechanism hypothesis.
6
10
 
7
11
  ## Inputs
8
12
  You receive the full Phase-4 dossier as JSON. Cite section paths and
9
- counts verbatim. Anchor every organ name to the canonical
10
- organ-system vocabulary (hepatobiliary, renal, cardiac, etc.) — colloquial
11
- substitutes are rejected by the voice probe.
13
+ counts verbatim. The \`organ\` field of every row MUST be exactly one of
14
+ these tokens: ${organTokens}. Anything else is rejected. Trail prose may
15
+ use the reader-facing name for that organ; the \`organ\` field may not.
12
16
 
13
17
  ## Approval precedents (provided)
14
18
  - FDA approval precedents for the candidate indication are supplied in the
@@ -19,6 +23,10 @@ substitutes are rejected by the voice probe.
19
23
  ## Output discipline
20
24
  - Trail format is study-summary cadence: claim, evidence with counts,
21
25
  qualifier on human relevance.
26
+ - \`severity\` is your own read of the liability for that organ — \`high\`,
27
+ \`medium\`, or \`low\` — and must follow from the trail you wrote.
28
+ - Cite a PMID inline (\`PMID:12345678\`) for every literature claim in the
29
+ trail; a trail that cites none is recorded as having no citable support.
22
30
  - Mechanism hypothesis can be null if the data do not support one — say
23
31
  so rather than guessing.
24
32
  - Trial AEs, failed-trial reasons, and outcomes may be used as
@@ -0,0 +1 @@
1
+ export declare const adversarialCritiquePrompt = "You are the adversarial critic in a target-assessment claim investigation.\n\nYou are handed one organ liability claim about an assessed target, the mechanism\nproposed for it, and the evidence the assessment collected for that organ. Your\njob is to argue that the claim does NOT hold.\n\nYou are not a reviewer and you are not a second opinion. Nobody is asking you\nwhether the claim looks reasonable. Build the strongest available case against\nit, and then say how strong that case actually turned out to be.\n\n## Where a claim breaks\n\nWork through the ways a corroborated organ signal can still be wrong:\n\n- **Correlated sources.** Several sources agreeing is only evidence when they are\n independent. Curated databases routinely re-import the same primary study.\n- **Species and model.** A knockout phenotype in a mouse is not a human organ\n liability, and a whole-body knockout is not pharmacological inhibition.\n- **Confounded clinical signal.** Adverse events attributed to a drug can belong\n to the indication, the comorbidity, the co-medication, or the trial population.\n- **Expression is not consequence.** Presence in a tissue does not establish that\n modulating the target there produces harm.\n- **Wrong scale.** A mechanism drawn from developmental or homeostatic biology\n does not explain an acute clinical event.\n- **Direction.** A cited paper may conclude the opposite of the way it is used.\n- **Better explanation.** Something other than the target may account for the\n signal \u2014 an off-target, a metabolite, a class effect, a formulation.\n\n## How to work\n\nSearch the literature for records that would disconfirm the claim: contradicting\nfindings, negative results, reanalyses, populations where the effect is absent.\nUse the tools you were given. Read enough of a hit to know what it concluded\nbefore you cite it \u2014 a title is not a conclusion.\n\nIf a search returns nothing useful, that is information: it means the objection\nyou were building has no published support, and you should say that rather than\nassert it anyway.\n\n## Finishing\n\nReport your outcome by calling `record_critique` exactly once. Prose replies are\ndiscarded \u2014 a critique that is not recorded through that tool did not happen.\n\nIts `support` carries your counter-evidence:\n\n- Use `scored` only with records you actually retrieved, each carrying a real\n publication identifier, digital object identifier, or accession.\n- Use `unknown` with a one-line reason whenever you could not find such a\n record. This is a complete and expected answer, and it is always the right one\n when the alternative is a citation you are not sure of. An objection with\n unknown support is still recorded and still read.\n\n## Do NOT\n\n- Do NOT endorse the claim. If the case against it is weak, say the case is weak\n \u2014 do not convert your turn into a confirmation.\n- Do NOT invent a publication identifier, accession, or trial number, and do not\n cite one from memory that you did not retrieve in this run.\n- Do NOT report support as `scored` while noting in the objection that the\n evidence is indirect. Indirect is `unknown` with that as the reason.\n- Do NOT object on grounds you cannot state concretely. \"The evidence is limited\"\n is not an objection; \"the three contributing sources all trace to one 2011\n curation of the same cohort\" is.\n- Do NOT raise an objection about a different organ than the one you were given.\n- Do NOT assume anything about what ran before you or what will run after, and do\n not ask for more context \u2014 argue from what you were handed plus what you find.";
@@ -0,0 +1,67 @@
1
+ export const adversarialCritiquePrompt = `You are the adversarial critic in a target-assessment claim investigation.
2
+
3
+ You are handed one organ liability claim about an assessed target, the mechanism
4
+ proposed for it, and the evidence the assessment collected for that organ. Your
5
+ job is to argue that the claim does NOT hold.
6
+
7
+ You are not a reviewer and you are not a second opinion. Nobody is asking you
8
+ whether the claim looks reasonable. Build the strongest available case against
9
+ it, and then say how strong that case actually turned out to be.
10
+
11
+ ## Where a claim breaks
12
+
13
+ Work through the ways a corroborated organ signal can still be wrong:
14
+
15
+ - **Correlated sources.** Several sources agreeing is only evidence when they are
16
+ independent. Curated databases routinely re-import the same primary study.
17
+ - **Species and model.** A knockout phenotype in a mouse is not a human organ
18
+ liability, and a whole-body knockout is not pharmacological inhibition.
19
+ - **Confounded clinical signal.** Adverse events attributed to a drug can belong
20
+ to the indication, the comorbidity, the co-medication, or the trial population.
21
+ - **Expression is not consequence.** Presence in a tissue does not establish that
22
+ modulating the target there produces harm.
23
+ - **Wrong scale.** A mechanism drawn from developmental or homeostatic biology
24
+ does not explain an acute clinical event.
25
+ - **Direction.** A cited paper may conclude the opposite of the way it is used.
26
+ - **Better explanation.** Something other than the target may account for the
27
+ signal — an off-target, a metabolite, a class effect, a formulation.
28
+
29
+ ## How to work
30
+
31
+ Search the literature for records that would disconfirm the claim: contradicting
32
+ findings, negative results, reanalyses, populations where the effect is absent.
33
+ Use the tools you were given. Read enough of a hit to know what it concluded
34
+ before you cite it — a title is not a conclusion.
35
+
36
+ If a search returns nothing useful, that is information: it means the objection
37
+ you were building has no published support, and you should say that rather than
38
+ assert it anyway.
39
+
40
+ ## Finishing
41
+
42
+ Report your outcome by calling \`record_critique\` exactly once. Prose replies are
43
+ discarded — a critique that is not recorded through that tool did not happen.
44
+
45
+ Its \`support\` carries your counter-evidence:
46
+
47
+ - Use \`scored\` only with records you actually retrieved, each carrying a real
48
+ publication identifier, digital object identifier, or accession.
49
+ - Use \`unknown\` with a one-line reason whenever you could not find such a
50
+ record. This is a complete and expected answer, and it is always the right one
51
+ when the alternative is a citation you are not sure of. An objection with
52
+ unknown support is still recorded and still read.
53
+
54
+ ## Do NOT
55
+
56
+ - Do NOT endorse the claim. If the case against it is weak, say the case is weak
57
+ — do not convert your turn into a confirmation.
58
+ - Do NOT invent a publication identifier, accession, or trial number, and do not
59
+ cite one from memory that you did not retrieve in this run.
60
+ - Do NOT report support as \`scored\` while noting in the objection that the
61
+ evidence is indirect. Indirect is \`unknown\` with that as the reason.
62
+ - Do NOT object on grounds you cannot state concretely. "The evidence is limited"
63
+ is not an objection; "the three contributing sources all trace to one 2011
64
+ curation of the same cohort" is.
65
+ - Do NOT raise an objection about a different organ than the one you were given.
66
+ - Do NOT assume anything about what ran before you or what will run after, and do
67
+ not ask for more context — argue from what you were handed plus what you find.`;
@@ -0,0 +1 @@
1
+ export declare const claimReverificationBrief = "# Task: re-verify one organ liability claim\n\nYou are given a corroborated organ liability claim, the mechanism proposed for\nit, the objection raised against it, and the evidence the assessment collected\nfor that organ. Decide what survives.\n\nYou are adjudicating, not summarising. Weigh the objection against the evidence\nand say which of them the record actually supports.\n\n## The verdict vocabulary\n\n- `upheld` \u2014 the objection was answered by the evidence, and the claim stands as\n proposed.\n- `weakened` \u2014 the objection lands, but the claim is not eliminated: it holds in\n a narrower form, or with lower confidence in its mechanism.\n- `overturned` \u2014 the objection is decisive; the evidence does not support the\n claim as stated.\n- `undetermined` \u2014 the record settles neither side. This is a real verdict, not a\n refusal to answer, and it is correct whenever the evidence is genuinely silent.\n\nThe verdict is your read of the record in words. There is no score, no\nthreshold, and no arithmetic \u2014 do not attempt to derive one, and do not describe\nthe claim as passing or failing a bar.\n\nNothing you return removes a claim from the assessment. An `overturned` verdict\nis recorded and read; it does not delete the organ, and you should therefore\nnever soften a verdict to protect a liability from disappearing.\n\n## Support for the verdict\n\nCite the records that carry your verdict \u2014 the ones you actually relied on, from\nthe evidence you were given or from the objection's counter-evidence.\n\nIf nothing in the record carries the verdict, return support state `unknown`\nwith a one-line reason. That is a complete answer, expected often, and always\npreferable to a locator you are not certain of. The verdict itself is still\nrecorded.\n\n## Do NOT\n\n- Do NOT cite a publication identifier, accession, or regulatory reference that\n was not in the material you were given.\n- Do NOT report support as `scored` while noting the evidence is thin. Thin is\n `unknown` with that as the reason.\n- Do NOT restate the objection as the verdict. Say what the record supports.\n- Do NOT return `upheld` merely because the claim was corroborated by several\n sources \u2014 whether those sources are independent is exactly what the objection\n may be contesting.\n- Do NOT assume anything about what ran before you or what will run after.";
@@ -0,0 +1,49 @@
1
+ export const claimReverificationBrief = `# Task: re-verify one organ liability claim
2
+
3
+ You are given a corroborated organ liability claim, the mechanism proposed for
4
+ it, the objection raised against it, and the evidence the assessment collected
5
+ for that organ. Decide what survives.
6
+
7
+ You are adjudicating, not summarising. Weigh the objection against the evidence
8
+ and say which of them the record actually supports.
9
+
10
+ ## The verdict vocabulary
11
+
12
+ - \`upheld\` — the objection was answered by the evidence, and the claim stands as
13
+ proposed.
14
+ - \`weakened\` — the objection lands, but the claim is not eliminated: it holds in
15
+ a narrower form, or with lower confidence in its mechanism.
16
+ - \`overturned\` — the objection is decisive; the evidence does not support the
17
+ claim as stated.
18
+ - \`undetermined\` — the record settles neither side. This is a real verdict, not a
19
+ refusal to answer, and it is correct whenever the evidence is genuinely silent.
20
+
21
+ The verdict is your read of the record in words. There is no score, no
22
+ threshold, and no arithmetic — do not attempt to derive one, and do not describe
23
+ the claim as passing or failing a bar.
24
+
25
+ Nothing you return removes a claim from the assessment. An \`overturned\` verdict
26
+ is recorded and read; it does not delete the organ, and you should therefore
27
+ never soften a verdict to protect a liability from disappearing.
28
+
29
+ ## Support for the verdict
30
+
31
+ Cite the records that carry your verdict — the ones you actually relied on, from
32
+ the evidence you were given or from the objection's counter-evidence.
33
+
34
+ If nothing in the record carries the verdict, return support state \`unknown\`
35
+ with a one-line reason. That is a complete answer, expected often, and always
36
+ preferable to a locator you are not certain of. The verdict itself is still
37
+ recorded.
38
+
39
+ ## Do NOT
40
+
41
+ - Do NOT cite a publication identifier, accession, or regulatory reference that
42
+ was not in the material you were given.
43
+ - Do NOT report support as \`scored\` while noting the evidence is thin. Thin is
44
+ \`unknown\` with that as the reason.
45
+ - Do NOT restate the objection as the verdict. Say what the record supports.
46
+ - Do NOT return \`upheld\` merely because the claim was corroborated by several
47
+ sources — whether those sources are independent is exactly what the objection
48
+ may be contesting.
49
+ - Do NOT assume anything about what ran before you or what will run after.`;
@@ -0,0 +1,3 @@
1
+ export { mechanismProposalBrief } from "./mechanism-proposal.js";
2
+ export { adversarialCritiquePrompt } from "./adversarial-critique.js";
3
+ export { claimReverificationBrief } from "./claim-reverification.js";
@@ -0,0 +1,3 @@
1
+ export { mechanismProposalBrief } from "./mechanism-proposal.js";
2
+ export { adversarialCritiquePrompt } from "./adversarial-critique.js";
3
+ export { claimReverificationBrief } from "./claim-reverification.js";
@@ -0,0 +1 @@
1
+ export declare const mechanismProposalBrief: string;
@@ -0,0 +1,49 @@
1
+ import { ORGAN_SYSTEMS } from "../../../contracts/organ-system.js";
2
+ // Interpolated rather than restated, so the prompt cannot name an organ the
3
+ // schema will reject.
4
+ const organTokens = ORGAN_SYSTEMS.join(", ");
5
+ export const mechanismProposalBrief = `# Task: propose a mechanism for one organ liability
6
+
7
+ You are given ONE canonical organ token and the evidence this assessment has
8
+ already collected about that organ — the sources that raised a signal for it,
9
+ what each of them said, and the record each signal came from. Propose how the
10
+ assessed target could produce a liability in that organ.
11
+
12
+ The organ is supplied to you and is already one of: ${organTokens}. You are not
13
+ asked to choose an organ and you must not reassign the claim to another one.
14
+
15
+ ## What a proposal is
16
+
17
+ - One mechanism, stated plainly: what the target does, in which cells or tissue,
18
+ and how that becomes the observed liability.
19
+ - Grounded in the evidence you were handed. Every record you were given carries
20
+ a locator; cite the locators of the records your mechanism actually rests on.
21
+ - Scaled to the observation. A mechanism must operate at the same biological
22
+ scale as the signal it explains — do not explain a clinical adverse-event
23
+ signal with developmental or tissue-homeostasis biology.
24
+
25
+ ## Reporting no mechanism costs you nothing
26
+
27
+ If the evidence supports no mechanism, say so: return no mechanism statement and
28
+ a support reason explaining what was missing. That is a complete, correct answer
29
+ and it is preferred over a plausible-sounding story.
30
+
31
+ If you can state a mechanism but cannot point at a record that supports it,
32
+ return the statement with support state \`unknown\` and a one-line reason. An
33
+ unknown support is a normal outcome, not a penalty, and it is always cheaper
34
+ than a citation you are not certain of.
35
+
36
+ ## Do NOT
37
+
38
+ - Do NOT cite a publication identifier, accession, or regulatory reference that
39
+ was not in the evidence you were given. A locator you produced from memory is
40
+ a fabrication even when the paper exists.
41
+ - Do NOT report support as \`scored\` while explaining in prose that the evidence
42
+ is weak or indirect. Weak or indirect support is \`unknown\` with that as the
43
+ reason.
44
+ - Do NOT restate the evidence back as the mechanism. "Several sources report
45
+ hepatic signals" is an observation; a mechanism says why.
46
+ - Do NOT propose a mechanism for a different organ, a different target, or a
47
+ drug class rather than the target.
48
+ - Do NOT assume anything about what ran before you or what will run after. Work
49
+ from what you were handed.`;
@@ -1,4 +1,4 @@
1
1
  export { toxVoiceCore } from "./core.js";
2
2
  export { toxVoiceExemplars, type SectionType } from "./exemplars.js";
3
- export { toxVoiceVocabulary, type OrganSystem, type LiabilityFraming, type HedgePhrase, type BannedTerm } from "./vocabulary.js";
3
+ export { toxVoiceVocabulary, type LiabilityFraming, type HedgePhrase, type BannedTerm } from "./vocabulary.js";
4
4
  export { buildVoiceCritique, type VoiceProbe } from "./critique.js";
@@ -1,15 +1,18 @@
1
1
  /**
2
- * Tox-voice canon. Lists are intentionally not exhaustive — they are the
3
- * minimum surface the deterministic voice probe enforces. Editorial
4
- * judgment in the agent prompts covers the long tail.
2
+ * Tox-voice canon. The stylistic lists are intentionally not exhaustive —
3
+ * they are the minimum surface the deterministic voice probe enforces, and
4
+ * editorial judgment in the agent prompts covers the long tail.
5
+ *
6
+ * `organSystems` is the exception: it is closed, because it is a projection
7
+ * of the canonical organ vocabulary rather than a list of its own. Prose and
8
+ * structured fields must name the same organs.
5
9
  */
6
10
  export declare const toxVoiceVocabulary: {
7
- readonly organSystems: readonly ["hepatobiliary", "renal", "cardiac", "vascular", "haematologic", "central nervous system", "peripheral nervous system", "respiratory", "gastrointestinal", "reproductive", "endocrine", "musculoskeletal", "dermatologic", "ocular", "immunologic"];
11
+ readonly organSystems: string[];
8
12
  readonly liabilityFraming: readonly ["on-target liability", "off-target liability", "secondary pharmacology", "class liability", "mechanism-related", "exaggerated pharmacology", "target-organ toxicity"];
9
13
  readonly hedgePhrases: readonly ["the data are consistent with", "the data suggest", "human relevance is uncertain", "human relevance remains to be established", "interpretation is limited by", "no causal inference is supported", "the available evidence is consistent with", "the available evidence does not support", "translatability to humans is unclear", "species differences"];
10
14
  readonly banned: readonly ["groundbreaking", "cutting-edge", "state-of-the-art", "best-in-class", "first-in-class", "revolutionary", "leverages", "leveraging", "robust", "powerful", "seamlessly", "cleanly", "elegant", "unparalleled", "demonstrates the power of", "showcases", "unlocks", "enables breakthrough", "very promising", "extremely", "incredibly", "highly innovative"];
11
15
  };
12
- export type OrganSystem = (typeof toxVoiceVocabulary.organSystems)[number];
13
16
  export type LiabilityFraming = (typeof toxVoiceVocabulary.liabilityFraming)[number];
14
17
  export type HedgePhrase = (typeof toxVoiceVocabulary.hedgePhrases)[number];
15
18
  export type BannedTerm = (typeof toxVoiceVocabulary.banned)[number];
@@ -1,26 +1,15 @@
1
1
  /**
2
- * Tox-voice canon. Lists are intentionally not exhaustive — they are the
3
- * minimum surface the deterministic voice probe enforces. Editorial
4
- * judgment in the agent prompts covers the long tail.
2
+ * Tox-voice canon. The stylistic lists are intentionally not exhaustive —
3
+ * they are the minimum surface the deterministic voice probe enforces, and
4
+ * editorial judgment in the agent prompts covers the long tail.
5
+ *
6
+ * `organSystems` is the exception: it is closed, because it is a projection
7
+ * of the canonical organ vocabulary rather than a list of its own. Prose and
8
+ * structured fields must name the same organs.
5
9
  */
10
+ import { ORGAN_SYSTEMS, ORGAN_SYSTEM_LABELS } from "../../../contracts/organ-system.js";
6
11
  export const toxVoiceVocabulary = {
7
- organSystems: [
8
- "hepatobiliary",
9
- "renal",
10
- "cardiac",
11
- "vascular",
12
- "haematologic",
13
- "central nervous system",
14
- "peripheral nervous system",
15
- "respiratory",
16
- "gastrointestinal",
17
- "reproductive",
18
- "endocrine",
19
- "musculoskeletal",
20
- "dermatologic",
21
- "ocular",
22
- "immunologic",
23
- ],
12
+ organSystems: ORGAN_SYSTEMS.map((organ) => ORGAN_SYSTEM_LABELS[organ]),
24
13
  liabilityFraming: [
25
14
  "on-target liability",
26
15
  "off-target liability",
@@ -1,16 +1,17 @@
1
1
  /**
2
2
  * Test-only harness `RequestSession` builder. Not a `*.test.ts` file, so the test
3
3
  * runner ignores it; imported by harness unit tests that need a session but never
4
- * read its (opaque) auth. The auth is the trivial local one — the harness never
5
- * inspects it. Managed-adapter tests that exercise `getAuth` / the managed seams
6
- * use the managed builder in `compose/__fixtures__/session.ts` instead.
4
+ * read its (opaque) auth. `auth` defaults to the trivial local value the harness
5
+ * never inspects; an embedder whose adapters downcast `auth` to a concrete type
6
+ * overrides it rather than re-declaring the whole session shape.
7
7
  */
8
- import type { RequestSession, Scope } from "../../auth/types.js";
8
+ import type { AuthContext, RequestSession, Scope } from "../../auth/types.js";
9
9
  export interface SessionOverrides {
10
10
  user?: string;
11
11
  scope?: Scope;
12
12
  agentId?: string;
13
13
  callPath?: readonly string[];
14
+ auth?: AuthContext;
14
15
  }
15
16
  /** Build a fully-populated harness `RequestSession` for tests, with per-field overrides. */
16
17
  export declare function makeSession(overrides?: SessionOverrides): RequestSession;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Test-only harness `RequestSession` builder. Not a `*.test.ts` file, so the test
3
3
  * runner ignores it; imported by harness unit tests that need a session but never
4
- * read its (opaque) auth. The auth is the trivial local one — the harness never
5
- * inspects it. Managed-adapter tests that exercise `getAuth` / the managed seams
6
- * use the managed builder in `compose/__fixtures__/session.ts` instead.
4
+ * read its (opaque) auth. `auth` defaults to the trivial local value the harness
5
+ * never inspects; an embedder whose adapters downcast `auth` to a concrete type
6
+ * overrides it rather than re-declaring the whole session shape.
7
7
  */
8
8
  import { makeLocalAuth } from "../../auth/local-auth-context.js";
9
9
  /** Build a fully-populated harness `RequestSession` for tests, with per-field overrides. */
@@ -15,6 +15,6 @@ export function makeSession(overrides = {}) {
15
15
  agentId: overrides.agentId ?? "conversation-agent",
16
16
  callPath: overrides.callPath ?? ["conversation-agent"],
17
17
  },
18
- auth: makeLocalAuth(),
18
+ auth: overrides.auth ?? makeLocalAuth(),
19
19
  };
20
20
  }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The one walk over a block tree.
3
+ *
4
+ * A block kind decides where a reference sits, which prose carries a free numeral, and whether the block
5
+ * holds children. Three consumers need that same knowledge: the mechanical validator, the draft finish,
6
+ * and the draft operations. A switch for each consumer is a switch that a ninth block kind can miss in
7
+ * silence, because each arm returns and none of them fails to build. Thus the walk lives here one time.
8
+ *
9
+ * The walk reads a finished `Block` tree and a relaxed `DraftBlock` tree alike. The two differ only in the
10
+ * section rules, and the section arm reads the children of either one.
11
+ *
12
+ * The walk resolves nothing and it opens no file. It reports what the tree holds, and a caller decides
13
+ * which part it needs.
14
+ */
15
+ import type { Block } from "../contracts/report-blocks.js";
16
+ import type { Reference } from "../contracts/report-reference.js";
17
+ import type { DraftBlock } from "./draft.js";
18
+ /** A block of a finished report, or a block of a draft. The atoms are the same shape in both. */
19
+ export type AnyBlock = Block | DraftBlock;
20
+ /**
21
+ * One reference that the walk met, tied to the block that carries it.
22
+ *
23
+ * `encodingColumns` is present for a `chart` only. A chart names its axes as free strings, thus the names
24
+ * must be matched against the table that the binding resolves to. Nothing else can catch a chart that
25
+ * plots a column which does not exist. The match needs the resolved rows, thus only a value-tier consumer
26
+ * reads this field.
27
+ */
28
+ export interface CollectedReference {
29
+ blockId: string;
30
+ reference: Reference;
31
+ encodingColumns?: string[];
32
+ }
33
+ /** An advisory warning about the content of one block. A warning never makes a report invalid. */
34
+ export interface ReportWarning {
35
+ blockId: string;
36
+ kind: "free-numeral";
37
+ detail: string;
38
+ }
39
+ /** What one walk over a block tree found. */
40
+ export interface BlockWalk {
41
+ /** Each reference, in document order, tied to the block that carries it. */
42
+ references: CollectedReference[];
43
+ /** Each id that more than one block holds, named one time, in sorted order. */
44
+ repeatedIds: string[];
45
+ /** Each free numeral that prose carries. */
46
+ warnings: ReportWarning[];
47
+ }
48
+ /** Warn for each free-standing numeral that the prose of one block carries. */
49
+ export declare function numeralWarnings(blockId: string, prose: string): ReportWarning[];
50
+ /**
51
+ * Walk a block tree, and report each reference, each repeated id, and each free numeral.
52
+ *
53
+ * An id is what makes a block addressable, thus an amend by id is well defined only while each id belongs
54
+ * to one block. The walk is pre-order, thus the references follow the document order.
55
+ */
56
+ export declare function walkBlocks(blocks: readonly AnyBlock[]): BlockWalk;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The one walk over a block tree.
3
+ *
4
+ * A block kind decides where a reference sits, which prose carries a free numeral, and whether the block
5
+ * holds children. Three consumers need that same knowledge: the mechanical validator, the draft finish,
6
+ * and the draft operations. A switch for each consumer is a switch that a ninth block kind can miss in
7
+ * silence, because each arm returns and none of them fails to build. Thus the walk lives here one time.
8
+ *
9
+ * The walk reads a finished `Block` tree and a relaxed `DraftBlock` tree alike. The two differ only in the
10
+ * section rules, and the section arm reads the children of either one.
11
+ *
12
+ * The walk resolves nothing and it opens no file. It reports what the tree holds, and a caller decides
13
+ * which part it needs.
14
+ */
15
+ /**
16
+ * A free-standing token that looks like a number, with an optional decimal part and an optional percent
17
+ * sign.
18
+ *
19
+ * The left boundary keeps the digits of a name out of the warnings. The domain prose is dense with a
20
+ * symbol such as `TP53`, `CD8`, or `IL6`, and without the boundary each one warns for its digits and
21
+ * buries the real free figures.
22
+ *
23
+ * The check is advisory only. A natural-language numeral is brittle to police, because a numeral in prose
24
+ * can be a real free-standing figure or a harmless part of a name. Thus a hit warns, and it never fails
25
+ * the report.
26
+ */
27
+ const NUMERAL_PATTERN = /(?<![A-Za-z0-9])-?\d+(?:\.\d+)?%?/g;
28
+ /** Warn for each free-standing numeral that the prose of one block carries. */
29
+ export function numeralWarnings(blockId, prose) {
30
+ const warnings = [];
31
+ for (const match of prose.matchAll(NUMERAL_PATTERN)) {
32
+ warnings.push({ blockId, kind: "free-numeral", detail: match[0] });
33
+ }
34
+ return warnings;
35
+ }
36
+ /**
37
+ * Walk a block tree, and report each reference, each repeated id, and each free numeral.
38
+ *
39
+ * An id is what makes a block addressable, thus an amend by id is well defined only while each id belongs
40
+ * to one block. The walk is pre-order, thus the references follow the document order.
41
+ */
42
+ export function walkBlocks(blocks) {
43
+ const references = [];
44
+ const warnings = [];
45
+ const seenIds = new Set();
46
+ const repeated = new Set();
47
+ const visit = (block) => {
48
+ if (seenIds.has(block.id)) {
49
+ repeated.add(block.id);
50
+ }
51
+ else {
52
+ seenIds.add(block.id);
53
+ }
54
+ switch (block.kind) {
55
+ case "section":
56
+ for (const child of block.blocks) {
57
+ visit(child);
58
+ }
59
+ return;
60
+ case "text":
61
+ warnings.push(...numeralWarnings(block.id, block.content.prose));
62
+ return;
63
+ case "claim":
64
+ warnings.push(...numeralWarnings(block.id, block.content.prose));
65
+ for (const binding of block.bindings) {
66
+ references.push({ blockId: block.id, reference: binding });
67
+ }
68
+ return;
69
+ case "metric":
70
+ references.push({ blockId: block.id, reference: block.value });
71
+ return;
72
+ case "chart": {
73
+ const encoding = block.encoding;
74
+ const encodingColumns = [encoding.x, encoding.y, encoding.group, encoding.value].filter((column) => column !== undefined);
75
+ references.push({ blockId: block.id, reference: block.binding, encodingColumns });
76
+ return;
77
+ }
78
+ case "table":
79
+ case "figure":
80
+ case "citation":
81
+ references.push({ blockId: block.id, reference: block.binding });
82
+ return;
83
+ }
84
+ };
85
+ for (const block of blocks) {
86
+ visit(block);
87
+ }
88
+ return { references, repeatedIds: [...repeated].sort(), warnings };
89
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The finish of a draft.
3
+ *
4
+ * An edit refuses what is wrong. The finish refuses what is missing. Thus the finish gates the whole
5
+ * draft one time: the full document schema, the unique ids, and the structural tier over every reference.
6
+ *
7
+ * The finish opens no file, and it reads the snapshot alone. Thus it runs the structural tier only, and
8
+ * the value tier stays in the gate of the report pipeline. The chart encoding-column match needs the rows
9
+ * behind a binding, thus it stays with the value tier.
10
+ *
11
+ * The free-numeral scan needs no file, thus the finish runs it and reports each hit as a warning. A
12
+ * warning never makes a draft invalid, and it rides beside the outcome in either case. Without the
13
+ * channel a caller could not read the one signal that catches a figure typed into prose with no metric
14
+ * block behind it.
15
+ *
16
+ * The result is plain data. A gap is an expected outcome, not an error, thus the finish never throws. On
17
+ * a pass the finish gives the valid document, and it does not change the draft.
18
+ */
19
+ import { type ReportDocument } from "../contracts/report-blocks.js";
20
+ import type { UnresolvedReference } from "../contracts/report-reference.js";
21
+ import { type ReportWarning } from "./block-walk.js";
22
+ import type { DraftDocument } from "./draft.js";
23
+ import type { ReportSnapshot } from "./reference-resolver.js";
24
+ /** A schema conformance gap, reduced to a path and a message. */
25
+ export interface SchemaGap {
26
+ kind: "schema";
27
+ path: string;
28
+ message: string;
29
+ }
30
+ /** A duplicate id gap. More than one block holds the id. */
31
+ export interface DuplicateIdGap {
32
+ kind: "duplicate-id";
33
+ id: string;
34
+ }
35
+ /** An unresolved reference gap. It ties the block that carries the reference to the reason it did not resolve. */
36
+ export interface UnresolvedReferenceGap {
37
+ kind: "unresolved-reference";
38
+ blockId: string;
39
+ failure: UnresolvedReference;
40
+ }
41
+ /** One completeness gap of a draft. The kind set is closed. */
42
+ export type FinishGap = SchemaGap | DuplicateIdGap | UnresolvedReferenceGap;
43
+ /**
44
+ * The finish result. On a pass it gives the valid document. On a fail it gives each gap. The warnings
45
+ * ride along in either case, because a warning is advisory and it never decides the outcome.
46
+ */
47
+ export type FinishResult = {
48
+ valid: true;
49
+ document: ReportDocument;
50
+ warnings: ReportWarning[];
51
+ } | {
52
+ valid: false;
53
+ gaps: FinishGap[];
54
+ warnings: ReportWarning[];
55
+ };
56
+ /**
57
+ * Finish a draft. The finish validates the schema, the unique ids, and the structural resolution of each
58
+ * reference, and it reports each gap as data. It warns about each free numeral in prose.
59
+ */
60
+ export declare function finishDraft(draft: DraftDocument, snapshot: ReportSnapshot): FinishResult;