@inflexa-ai/harness 0.16.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 (295) hide show
  1. package/dist/agents/conversation-agent.d.ts +3 -0
  2. package/dist/agents/conversation-agent.js +5 -2
  3. package/dist/agents/report-builder.d.ts +2 -0
  4. package/dist/agents/report-builder.js +2 -0
  5. package/dist/agents/sandbox/shared.d.ts +3 -0
  6. package/dist/agents/sandbox/shared.js +5 -0
  7. package/dist/agents/sandbox/types.d.ts +1 -1
  8. package/dist/app/chat-turn.d.ts +2 -0
  9. package/dist/app/chat-turn.js +11 -2
  10. package/dist/app/spawn-report-session.d.ts +85 -0
  11. package/dist/app/spawn-report-session.js +83 -0
  12. package/dist/app/synthesize-run.d.ts +3 -0
  13. package/dist/app/synthesize-run.js +2 -1
  14. package/dist/citations/__fixtures__/resolver.d.ts +3 -0
  15. package/dist/citations/__fixtures__/resolver.js +9 -0
  16. package/dist/citations/aggregate.d.ts +3 -0
  17. package/dist/citations/aggregate.js +44 -0
  18. package/dist/citations/clients/arxiv.d.ts +6 -0
  19. package/dist/citations/clients/arxiv.js +34 -0
  20. package/dist/citations/clients/common.d.ts +11 -0
  21. package/dist/citations/clients/common.js +43 -0
  22. package/dist/citations/clients/crossref.d.ts +8 -0
  23. package/dist/citations/clients/crossref.js +98 -0
  24. package/dist/citations/clients/doi-registry.d.ts +3 -0
  25. package/dist/citations/clients/doi-registry.js +95 -0
  26. package/dist/citations/clients/pubmed.d.ts +6 -0
  27. package/dist/citations/clients/pubmed.js +83 -0
  28. package/dist/citations/clients/semantic-scholar.d.ts +6 -0
  29. package/dist/citations/clients/semantic-scholar.js +60 -0
  30. package/dist/citations/compare.d.ts +9 -0
  31. package/dist/citations/compare.js +72 -0
  32. package/dist/citations/match.d.ts +11 -0
  33. package/dist/citations/match.js +173 -0
  34. package/dist/citations/normalize.d.ts +31 -0
  35. package/dist/citations/normalize.js +187 -0
  36. package/dist/citations/plan.d.ts +2 -0
  37. package/dist/citations/plan.js +59 -0
  38. package/dist/citations/resolve.d.ts +28 -0
  39. package/dist/citations/resolve.js +238 -0
  40. package/dist/citations/types.d.ts +583 -0
  41. package/dist/citations/types.js +129 -0
  42. package/dist/contracts/chat-events.d.ts +9 -0
  43. package/dist/contracts/index.d.ts +6 -2
  44. package/dist/contracts/index.js +3 -1
  45. package/dist/contracts/organ-system.d.ts +49 -0
  46. package/dist/contracts/organ-system.js +67 -0
  47. package/dist/contracts/report-blocks.d.ts +564 -0
  48. package/dist/contracts/report-blocks.js +117 -0
  49. package/dist/contracts/report-reference.d.ts +459 -0
  50. package/dist/contracts/report-reference.js +256 -0
  51. package/dist/contracts/schemas/chat-events.d.ts +2 -0
  52. package/dist/contracts/schemas/chat-events.js +2 -0
  53. package/dist/contracts/schemas/chat-parts.d.ts +8 -8
  54. package/dist/contracts/severity.d.ts +15 -0
  55. package/dist/contracts/severity.js +10 -0
  56. package/dist/contracts/target-dossier.d.ts +8673 -12970
  57. package/dist/contracts/target-dossier.js +534 -591
  58. package/dist/data/safety-panel-schema.d.ts +18 -5
  59. package/dist/data/safety-panel-schema.js +4 -4
  60. package/dist/execution/artifact-metadata.js +1 -0
  61. package/dist/execution/report-runner.js +1 -3
  62. package/dist/execution/run-synthesis.d.ts +3 -0
  63. package/dist/execution/run-synthesis.js +3 -0
  64. package/dist/index.d.ts +12 -1
  65. package/dist/index.js +22 -0
  66. package/dist/lib/async-utils.d.ts +16 -4
  67. package/dist/lib/async-utils.js +20 -15
  68. package/dist/lib/cache.d.ts +8 -0
  69. package/dist/lib/cache.js +35 -0
  70. package/dist/lib/host-concurrency.js +1 -0
  71. package/dist/lib/rate-limit.d.ts +35 -0
  72. package/dist/lib/rate-limit.js +121 -0
  73. package/dist/literature/sources/arxiv.d.ts +22 -0
  74. package/dist/literature/sources/arxiv.js +103 -0
  75. package/dist/literature/sources/http.d.ts +28 -0
  76. package/dist/literature/sources/http.js +97 -0
  77. package/dist/literature/sources/pubmed.d.ts +68 -0
  78. package/dist/literature/sources/pubmed.js +266 -0
  79. package/dist/literature/sources/semantic-scholar.d.ts +24 -0
  80. package/dist/literature/sources/semantic-scholar.js +71 -0
  81. package/dist/loop/__fixtures__/scripted-provider.js +23 -2
  82. package/dist/loop/run-agent.js +58 -10
  83. package/dist/loop/tool-detail.d.ts +40 -0
  84. package/dist/loop/tool-detail.js +35 -3
  85. package/dist/loop/types.d.ts +13 -0
  86. package/dist/memory/thread-history.d.ts +10 -0
  87. package/dist/memory/thread-history.js +12 -1
  88. package/dist/memory/thread-store.d.ts +142 -25
  89. package/dist/memory/thread-store.js +228 -40
  90. package/dist/prompts/literature-reviewer.d.ts +1 -1
  91. package/dist/prompts/literature-reviewer.js +2 -0
  92. package/dist/prompts/target-assessment/briefs/executive-recommendation.d.ts +1 -1
  93. package/dist/prompts/target-assessment/briefs/executive-recommendation.js +5 -5
  94. package/dist/prompts/target-assessment/briefs/liability-bullets.d.ts +1 -1
  95. package/dist/prompts/target-assessment/briefs/liability-bullets.js +1 -1
  96. package/dist/prompts/target-assessment/briefs/target-organ-liabilities.d.ts +1 -1
  97. package/dist/prompts/target-assessment/briefs/target-organ-liabilities.js +11 -3
  98. package/dist/prompts/target-assessment/investigation/adversarial-critique.d.ts +1 -0
  99. package/dist/prompts/target-assessment/investigation/adversarial-critique.js +67 -0
  100. package/dist/prompts/target-assessment/investigation/claim-reverification.d.ts +1 -0
  101. package/dist/prompts/target-assessment/investigation/claim-reverification.js +49 -0
  102. package/dist/prompts/target-assessment/investigation/index.d.ts +3 -0
  103. package/dist/prompts/target-assessment/investigation/index.js +3 -0
  104. package/dist/prompts/target-assessment/investigation/mechanism-proposal.d.ts +1 -0
  105. package/dist/prompts/target-assessment/investigation/mechanism-proposal.js +49 -0
  106. package/dist/prompts/target-assessment/tox-voice/index.d.ts +1 -1
  107. package/dist/prompts/target-assessment/tox-voice/vocabulary.d.ts +8 -5
  108. package/dist/prompts/target-assessment/tox-voice/vocabulary.js +9 -20
  109. package/dist/providers/__fixtures__/session.d.ts +5 -4
  110. package/dist/providers/__fixtures__/session.js +4 -4
  111. package/dist/report-model/block-walk.d.ts +56 -0
  112. package/dist/report-model/block-walk.js +89 -0
  113. package/dist/report-model/draft-finish.d.ts +60 -0
  114. package/dist/report-model/draft-finish.js +56 -0
  115. package/dist/report-model/draft-operations.d.ts +125 -0
  116. package/dist/report-model/draft-operations.js +341 -0
  117. package/dist/report-model/draft-read.d.ts +59 -0
  118. package/dist/report-model/draft-read.js +109 -0
  119. package/dist/report-model/draft.d.ts +51 -0
  120. package/dist/report-model/draft.js +32 -0
  121. package/dist/report-model/fixture-resolver.d.ts +8 -0
  122. package/dist/report-model/fixture-resolver.js +252 -0
  123. package/dist/report-model/mint-snapshot.d.ts +30 -0
  124. package/dist/report-model/mint-snapshot.js +40 -0
  125. package/dist/report-model/reference-resolver.d.ts +113 -0
  126. package/dist/report-model/reference-resolver.js +60 -0
  127. package/dist/report-model/structural-validation.d.ts +22 -0
  128. package/dist/report-model/structural-validation.js +68 -0
  129. package/dist/report-model/validate.d.ts +40 -0
  130. package/dist/report-model/validate.js +80 -0
  131. package/dist/report-render/chart.d.ts +33 -0
  132. package/dist/report-render/chart.js +538 -0
  133. package/dist/report-render/page.d.ts +127 -0
  134. package/dist/report-render/page.js +307 -0
  135. package/dist/report-render/references.d.ts +32 -0
  136. package/dist/report-render/references.js +44 -0
  137. package/dist/report-render/render.d.ts +25 -0
  138. package/dist/report-render/render.js +125 -0
  139. package/dist/report-render/script-json.d.ts +13 -0
  140. package/dist/report-render/script-json.js +15 -0
  141. package/dist/report-render/types.d.ts +39 -0
  142. package/dist/report-render/types.js +10 -0
  143. package/dist/report-render/views/chart-view.d.ts +11 -0
  144. package/dist/report-render/views/chart-view.js +23 -0
  145. package/dist/report-render/views/page-view.d.ts +20 -0
  146. package/dist/report-render/views/page-view.js +49 -0
  147. package/dist/report-render/views/prose.d.ts +28 -0
  148. package/dist/report-render/views/prose.js +75 -0
  149. package/dist/report-render/views/references-view.d.ts +20 -0
  150. package/dist/report-render/views/references-view.js +64 -0
  151. package/dist/report-render/views/values.d.ts +42 -0
  152. package/dist/report-render/views/values.js +43 -0
  153. package/dist/runtime/assemble.d.ts +50 -4
  154. package/dist/runtime/assemble.js +47 -3
  155. package/dist/runtime/boot.d.ts +3 -3
  156. package/dist/runtime/boot.js +22 -5
  157. package/dist/runtime/dbos.d.ts +4 -4
  158. package/dist/state/artifacts.d.ts +16 -0
  159. package/dist/state/artifacts.js +18 -0
  160. package/dist/state/init.js +77 -1
  161. package/dist/state/purge-analysis.js +1 -0
  162. package/dist/state/report-versions.d.ts +132 -0
  163. package/dist/state/report-versions.js +194 -0
  164. package/dist/state/schema.d.ts +2 -2
  165. package/dist/tasks/data-profile.js +1 -0
  166. package/dist/tools/bio/chembl.js +1 -0
  167. package/dist/tools/bio/comptox.js +1 -0
  168. package/dist/tools/bio/drug-gene-interactions.js +1 -0
  169. package/dist/tools/bio/gene-disease-evidence.js +1 -0
  170. package/dist/tools/bio/gene-preclinical-profile.d.ts +1 -1
  171. package/dist/tools/bio/gene-preclinical-profile.js +1 -0
  172. package/dist/tools/bio/keys.d.ts +4 -2
  173. package/dist/tools/bio/keys.js +3 -2
  174. package/dist/tools/bio/lookup-annotation.js +1 -0
  175. package/dist/tools/bio/opentargets.d.ts +3 -3
  176. package/dist/tools/bio/opentargets.js +4 -3
  177. package/dist/tools/bio/pubchem.js +1 -0
  178. package/dist/tools/bio/pubmed.js +4 -4
  179. package/dist/tools/bio/search-clinical-trials.js +1 -0
  180. package/dist/tools/bio/search-faers.js +1 -0
  181. package/dist/tools/bio/search-geo-datasets.js +1 -0
  182. package/dist/tools/bio/search-interactions.js +1 -0
  183. package/dist/tools/bio/target-safety.d.ts +4 -6
  184. package/dist/tools/bio/target-safety.js +7 -6
  185. package/dist/tools/define-tool.d.ts +19 -12
  186. package/dist/tools/define-tool.js +4 -2
  187. package/dist/tools/display/show-user.js +1 -0
  188. package/dist/tools/iterate-report.js +2 -0
  189. package/dist/tools/lib/chembl-client.d.ts +2 -0
  190. package/dist/tools/lib/chembl-client.js +1 -0
  191. package/dist/tools/lib/monarch-client.d.ts +42 -0
  192. package/dist/tools/lib/monarch-client.js +100 -0
  193. package/dist/tools/lib/ncbi-utils.d.ts +3 -58
  194. package/dist/tools/lib/ncbi-utils.js +2 -286
  195. package/dist/tools/lib/pubmed-client.d.ts +5 -12
  196. package/dist/tools/lib/pubmed-client.js +20 -79
  197. package/dist/tools/report/build-report.js +1 -0
  198. package/dist/tools/report/mint-preview-url.js +1 -0
  199. package/dist/tools/report/preview-snapshot.js +1 -0
  200. package/dist/tools/report/submit-report.js +1 -0
  201. package/dist/tools/report/version-fs.js +4 -0
  202. package/dist/tools/report-authoring/authoring-tools.d.ts +134 -0
  203. package/dist/tools/report-authoring/authoring-tools.js +352 -0
  204. package/dist/tools/research/context7-docs.js +2 -0
  205. package/dist/tools/research/generate-analogy-report.js +3 -2
  206. package/dist/tools/research/generate-plan.js +3 -0
  207. package/dist/tools/research/index.d.ts +1 -0
  208. package/dist/tools/research/index.js +1 -0
  209. package/dist/tools/research/inspect-data-profile.js +4 -0
  210. package/dist/tools/research/inspect-run.d.ts +1 -1
  211. package/dist/tools/research/literature-reviewer.d.ts +3 -0
  212. package/dist/tools/research/literature-reviewer.js +3 -0
  213. package/dist/tools/research/resolve-citation.d.ts +3 -0
  214. package/dist/tools/research/resolve-citation.js +15 -0
  215. package/dist/tools/research/search-arxiv.d.ts +3 -19
  216. package/dist/tools/research/search-arxiv.js +10 -105
  217. package/dist/tools/research/search-github-repos.js +1 -0
  218. package/dist/tools/research/search-semantic-scholar.d.ts +8 -33
  219. package/dist/tools/research/search-semantic-scholar.js +30 -88
  220. package/dist/tools/sandbox/list-available-packages.js +23 -0
  221. package/dist/tools/sandbox/list-available-refs.js +37 -2
  222. package/dist/tools/sandbox/report-blocker.js +1 -0
  223. package/dist/tools/sandbox/skills.js +2 -0
  224. package/dist/tools/workspace/file-stat.js +1 -0
  225. package/dist/tools/workspace/show-file.js +2 -0
  226. package/dist/tools/workspace/show-plan.js +1 -0
  227. package/dist/workflows/execute-analysis.d.ts +8 -1
  228. package/dist/workflows/execute-analysis.js +6 -5
  229. package/dist/workflows/execute-target-assessment.d.ts +13 -2
  230. package/dist/workflows/execute-target-assessment.js +78 -16
  231. package/dist/workflows/sandbox-step.d.ts +5 -0
  232. package/dist/workflows/sandbox-step.js +1 -0
  233. package/dist/workflows/target-assessment/assemblers/index.d.ts +1 -1
  234. package/dist/workflows/target-assessment/assemblers/index.js +1 -1
  235. package/dist/workflows/target-assessment/assemblers/literature.d.ts +9 -27
  236. package/dist/workflows/target-assessment/assemblers/literature.js +32 -48
  237. package/dist/workflows/target-assessment/assemblers/orchestrator.d.ts +17 -9
  238. package/dist/workflows/target-assessment/assemblers/orchestrator.js +195 -85
  239. package/dist/workflows/target-assessment/assemblers/safety.d.ts +70 -48
  240. package/dist/workflows/target-assessment/assemblers/safety.js +125 -42
  241. package/dist/workflows/target-assessment/collectors/index.d.ts +5 -2
  242. package/dist/workflows/target-assessment/collectors/index.js +48 -5
  243. package/dist/workflows/target-assessment/coverage.d.ts +43 -27
  244. package/dist/workflows/target-assessment/coverage.js +33 -29
  245. package/dist/workflows/target-assessment/fanout/index.js +1 -0
  246. package/dist/workflows/target-assessment/investigation/index.d.ts +97 -0
  247. package/dist/workflows/target-assessment/investigation/index.js +419 -0
  248. package/dist/workflows/target-assessment/lib/approval-precedents.d.ts +26 -5
  249. package/dist/workflows/target-assessment/lib/approval-precedents.js +95 -29
  250. package/dist/workflows/target-assessment/lib/citation-validator.js +1 -1
  251. package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.d.ts +2 -2
  252. package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.d.ts +2 -3
  253. package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.js +0 -4
  254. package/dist/workflows/target-assessment/lib/compute-derived.d.ts +6 -5
  255. package/dist/workflows/target-assessment/lib/compute-derived.js +14 -5
  256. package/dist/workflows/target-assessment/lib/family-complex-supplement.d.ts +5 -6
  257. package/dist/workflows/target-assessment/lib/family-complex-supplement.js +2 -3
  258. package/dist/workflows/target-assessment/lib/fda-label-safety.d.ts +72 -0
  259. package/dist/workflows/target-assessment/lib/fda-label-safety.js +166 -0
  260. package/dist/workflows/target-assessment/lib/heterodimer-filter.d.ts +0 -9
  261. package/dist/workflows/target-assessment/lib/heterodimer-filter.js +0 -10
  262. package/dist/workflows/target-assessment/lib/hpo-organ-map.d.ts +34 -0
  263. package/dist/workflows/target-assessment/lib/hpo-organ-map.js +63 -0
  264. package/dist/workflows/target-assessment/lib/impc-organ-map.d.ts +19 -0
  265. package/dist/workflows/target-assessment/lib/impc-organ-map.js +39 -0
  266. package/dist/workflows/target-assessment/lib/meddra-organ-map.d.ts +24 -14
  267. package/dist/workflows/target-assessment/lib/meddra-organ-map.js +59 -47
  268. package/dist/workflows/target-assessment/lib/recommendation-sanitizer.js +1 -1
  269. package/dist/workflows/target-assessment/lib/regulatory-actions.d.ts +2 -3
  270. package/dist/workflows/target-assessment/lib/regulatory-actions.js +33 -4
  271. package/dist/workflows/target-assessment/lib/safety-corroboration.d.ts +44 -0
  272. package/dist/workflows/target-assessment/lib/safety-corroboration.js +273 -0
  273. package/dist/workflows/target-assessment/lib/target-identity-filter.d.ts +5 -7
  274. package/dist/workflows/target-assessment/lib/target-identity-filter.js +5 -7
  275. package/dist/workflows/target-assessment/metrics.d.ts +1 -6
  276. package/dist/workflows/target-assessment/metrics.js +1 -13
  277. package/dist/workflows/target-assessment/phase4-assemble.d.ts +2149 -809
  278. package/dist/workflows/target-assessment/phase4-assemble.js +19 -19
  279. package/dist/workflows/target-assessment/phase5-persist.d.ts +20 -21
  280. package/dist/workflows/target-assessment/phase5-persist.js +56 -173
  281. package/dist/workflows/target-assessment/schemas.d.ts +48 -3
  282. package/dist/workflows/target-assessment/schemas.js +19 -0
  283. package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.d.ts +1 -0
  284. package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.js +2 -0
  285. package/dist/workflows/target-assessment/steps/phase2-aggregate.d.ts +27 -63
  286. package/dist/workflows/target-assessment/steps/phase2-aggregate.js +0 -4
  287. package/dist/workflows/target-assessment/steps/phase3-aggregate.d.ts +28 -155
  288. package/dist/workflows/target-assessment/steps/phase3-aggregate.js +0 -6
  289. package/dist/workflows/target-assessment/steps/synthesis/diagnostics.d.ts +0 -6
  290. package/dist/workflows/target-assessment/steps/synthesis/diagnostics.js +0 -18
  291. package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.d.ts +1 -0
  292. package/dist/workflows/target-assessment/synthesis/index.d.ts +52 -5
  293. package/dist/workflows/target-assessment/synthesis/index.js +4 -1
  294. package/dist/workflows/target-assessment/synthesis-probes.d.ts +3 -3
  295. package/package.json +4 -1
@@ -0,0 +1,459 @@
1
+ /**
2
+ * A reference binds a report block to the evidence that justifies it. It is the one canonical way a
3
+ * block points at a value, a table, a derived quantity, or an external source.
4
+ *
5
+ * The reference lives here, in `contracts/`, because a consumer reads it back after a run. The consumer
6
+ * imports this module without the harness's own dependencies, thus it holds a reference as plain data.
7
+ *
8
+ * Resolution reads the evidence again at render time. The `assert` field is the authored belief, and
9
+ * the resolver matches the fresh read against it.
10
+ */
11
+ import { type Result } from "neverthrow";
12
+ import { z } from "zod";
13
+ /**
14
+ * A reference to one scalar value inside an artifact, addressed by a locator. It resolves to a scalar,
15
+ * thus it carries the value assert.
16
+ */
17
+ export declare const ArtifactValueReferenceSchema: z.ZodObject<{
18
+ unit: z.ZodOptional<z.ZodString>;
19
+ format: z.ZodOptional<z.ZodString>;
20
+ locator: z.ZodObject<{
21
+ column: z.ZodString;
22
+ rowFilter: z.ZodOptional<z.ZodObject<{
23
+ column: z.ZodString;
24
+ op: z.ZodLiteral<"eq">;
25
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
26
+ }, z.core.$strict>>;
27
+ row: z.ZodOptional<z.ZodNumber>;
28
+ }, z.core.$strict>;
29
+ assert: z.ZodOptional<z.ZodObject<{
30
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
31
+ tolerance: z.ZodOptional<z.ZodNumber>;
32
+ }, z.core.$strict>>;
33
+ run: z.ZodOptional<z.ZodString>;
34
+ path: z.ZodString;
35
+ hash: z.ZodString;
36
+ snapshot: z.ZodOptional<z.ZodString>;
37
+ kind: z.ZodLiteral<"artifact-value">;
38
+ }, z.core.$strict>;
39
+ /**
40
+ * A reference to a whole table artifact. It carries no locator, because it binds every row.
41
+ *
42
+ * It carries no assert. A table is not one value, thus the only belief that an author can hold about it
43
+ * is its bytes, and the pinned `hash` already carries that belief.
44
+ */
45
+ export declare const ArtifactTableReferenceSchema: z.ZodObject<{
46
+ unit: z.ZodOptional<z.ZodString>;
47
+ format: z.ZodOptional<z.ZodString>;
48
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
49
+ run: z.ZodOptional<z.ZodString>;
50
+ path: z.ZodString;
51
+ hash: z.ZodString;
52
+ snapshot: z.ZodOptional<z.ZodString>;
53
+ kind: z.ZodLiteral<"artifact-table">;
54
+ }, z.core.$strict>;
55
+ /**
56
+ * A reference to a whole artifact file, for example an image. It carries no locator and no columns,
57
+ * because a file is pinned whole and has no addressable cell inside it. It carries no assert, for the
58
+ * same reason as a table reference.
59
+ */
60
+ export declare const ArtifactFileReferenceSchema: z.ZodObject<{
61
+ unit: z.ZodOptional<z.ZodString>;
62
+ format: z.ZodOptional<z.ZodString>;
63
+ run: z.ZodOptional<z.ZodString>;
64
+ path: z.ZodString;
65
+ hash: z.ZodString;
66
+ snapshot: z.ZodOptional<z.ZodString>;
67
+ kind: z.ZodLiteral<"artifact-file">;
68
+ }, z.core.$strict>;
69
+ /**
70
+ * A reference to an external source, addressed by an external identifier. It resolves to the prefixed
71
+ * key, thus its assert compares against that key and carries no hash.
72
+ */
73
+ export declare const CitationReferenceSchema: z.ZodObject<{
74
+ unit: z.ZodOptional<z.ZodString>;
75
+ format: z.ZodOptional<z.ZodString>;
76
+ kind: z.ZodLiteral<"citation">;
77
+ idKind: z.ZodEnum<{
78
+ doi: "doi";
79
+ pmid: "pmid";
80
+ arxiv: "arxiv";
81
+ }>;
82
+ id: z.ZodString;
83
+ raw: z.ZodString;
84
+ assert: z.ZodOptional<z.ZodObject<{
85
+ value: z.ZodString;
86
+ }, z.core.$strict>>;
87
+ }, z.core.$strict>;
88
+ /**
89
+ * The one reference kind that a derivation can consume.
90
+ *
91
+ * The arithmetic needs a scalar, and `artifact-value` is the only reference that resolves to one without
92
+ * itself being a derivation. A table, a file, and a citation resolve to something else, thus each is
93
+ * unrepresentable here rather than a parse that succeeds and then always fails at resolution. A
94
+ * derivation is out of the set too, thus a derivation over a derivation stays unrepresentable.
95
+ */
96
+ export declare const DerivationInputReferenceSchema: z.ZodObject<{
97
+ unit: z.ZodOptional<z.ZodString>;
98
+ format: z.ZodOptional<z.ZodString>;
99
+ locator: z.ZodObject<{
100
+ column: z.ZodString;
101
+ rowFilter: z.ZodOptional<z.ZodObject<{
102
+ column: z.ZodString;
103
+ op: z.ZodLiteral<"eq">;
104
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
105
+ }, z.core.$strict>>;
106
+ row: z.ZodOptional<z.ZodNumber>;
107
+ }, z.core.$strict>;
108
+ assert: z.ZodOptional<z.ZodObject<{
109
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
110
+ tolerance: z.ZodOptional<z.ZodNumber>;
111
+ }, z.core.$strict>>;
112
+ run: z.ZodOptional<z.ZodString>;
113
+ path: z.ZodString;
114
+ hash: z.ZodString;
115
+ snapshot: z.ZodOptional<z.ZodString>;
116
+ kind: z.ZodLiteral<"artifact-value">;
117
+ }, z.core.$strict>;
118
+ /**
119
+ * A reference to a value computed from other references. Each of the three operations takes two inputs,
120
+ * thus `inputs` holds exactly two scalar-resolving references and no other count is representable. The
121
+ * result is computed and not artifact-backed, thus its assert carries the value fields only.
122
+ */
123
+ export declare const DerivationReferenceSchema: z.ZodObject<{
124
+ unit: z.ZodOptional<z.ZodString>;
125
+ format: z.ZodOptional<z.ZodString>;
126
+ kind: z.ZodLiteral<"derivation">;
127
+ op: z.ZodEnum<{
128
+ ratio: "ratio";
129
+ delta: "delta";
130
+ pctChange: "pctChange";
131
+ }>;
132
+ inputs: z.ZodArray<z.ZodObject<{
133
+ unit: z.ZodOptional<z.ZodString>;
134
+ format: z.ZodOptional<z.ZodString>;
135
+ locator: z.ZodObject<{
136
+ column: z.ZodString;
137
+ rowFilter: z.ZodOptional<z.ZodObject<{
138
+ column: z.ZodString;
139
+ op: z.ZodLiteral<"eq">;
140
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
141
+ }, z.core.$strict>>;
142
+ row: z.ZodOptional<z.ZodNumber>;
143
+ }, z.core.$strict>;
144
+ assert: z.ZodOptional<z.ZodObject<{
145
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
146
+ tolerance: z.ZodOptional<z.ZodNumber>;
147
+ }, z.core.$strict>>;
148
+ run: z.ZodOptional<z.ZodString>;
149
+ path: z.ZodString;
150
+ hash: z.ZodString;
151
+ snapshot: z.ZodOptional<z.ZodString>;
152
+ kind: z.ZodLiteral<"artifact-value">;
153
+ }, z.core.$strict>>;
154
+ assert: z.ZodOptional<z.ZodObject<{
155
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
156
+ tolerance: z.ZodOptional<z.ZodNumber>;
157
+ }, z.core.$strict>>;
158
+ }, z.core.$strict>;
159
+ /** The full reference union. A block binds to one of these. */
160
+ export declare const ReferenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
161
+ unit: z.ZodOptional<z.ZodString>;
162
+ format: z.ZodOptional<z.ZodString>;
163
+ locator: z.ZodObject<{
164
+ column: z.ZodString;
165
+ rowFilter: z.ZodOptional<z.ZodObject<{
166
+ column: z.ZodString;
167
+ op: z.ZodLiteral<"eq">;
168
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
169
+ }, z.core.$strict>>;
170
+ row: z.ZodOptional<z.ZodNumber>;
171
+ }, z.core.$strict>;
172
+ assert: z.ZodOptional<z.ZodObject<{
173
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
174
+ tolerance: z.ZodOptional<z.ZodNumber>;
175
+ }, z.core.$strict>>;
176
+ run: z.ZodOptional<z.ZodString>;
177
+ path: z.ZodString;
178
+ hash: z.ZodString;
179
+ snapshot: z.ZodOptional<z.ZodString>;
180
+ kind: z.ZodLiteral<"artifact-value">;
181
+ }, z.core.$strict>, z.ZodObject<{
182
+ unit: z.ZodOptional<z.ZodString>;
183
+ format: z.ZodOptional<z.ZodString>;
184
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
185
+ run: z.ZodOptional<z.ZodString>;
186
+ path: z.ZodString;
187
+ hash: z.ZodString;
188
+ snapshot: z.ZodOptional<z.ZodString>;
189
+ kind: z.ZodLiteral<"artifact-table">;
190
+ }, z.core.$strict>, z.ZodObject<{
191
+ unit: z.ZodOptional<z.ZodString>;
192
+ format: z.ZodOptional<z.ZodString>;
193
+ run: z.ZodOptional<z.ZodString>;
194
+ path: z.ZodString;
195
+ hash: z.ZodString;
196
+ snapshot: z.ZodOptional<z.ZodString>;
197
+ kind: z.ZodLiteral<"artifact-file">;
198
+ }, z.core.$strict>, z.ZodObject<{
199
+ unit: z.ZodOptional<z.ZodString>;
200
+ format: z.ZodOptional<z.ZodString>;
201
+ kind: z.ZodLiteral<"derivation">;
202
+ op: z.ZodEnum<{
203
+ ratio: "ratio";
204
+ delta: "delta";
205
+ pctChange: "pctChange";
206
+ }>;
207
+ inputs: z.ZodArray<z.ZodObject<{
208
+ unit: z.ZodOptional<z.ZodString>;
209
+ format: z.ZodOptional<z.ZodString>;
210
+ locator: z.ZodObject<{
211
+ column: z.ZodString;
212
+ rowFilter: z.ZodOptional<z.ZodObject<{
213
+ column: z.ZodString;
214
+ op: z.ZodLiteral<"eq">;
215
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
216
+ }, z.core.$strict>>;
217
+ row: z.ZodOptional<z.ZodNumber>;
218
+ }, z.core.$strict>;
219
+ assert: z.ZodOptional<z.ZodObject<{
220
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
221
+ tolerance: z.ZodOptional<z.ZodNumber>;
222
+ }, z.core.$strict>>;
223
+ run: z.ZodOptional<z.ZodString>;
224
+ path: z.ZodString;
225
+ hash: z.ZodString;
226
+ snapshot: z.ZodOptional<z.ZodString>;
227
+ kind: z.ZodLiteral<"artifact-value">;
228
+ }, z.core.$strict>>;
229
+ assert: z.ZodOptional<z.ZodObject<{
230
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
231
+ tolerance: z.ZodOptional<z.ZodNumber>;
232
+ }, z.core.$strict>>;
233
+ }, z.core.$strict>, z.ZodObject<{
234
+ unit: z.ZodOptional<z.ZodString>;
235
+ format: z.ZodOptional<z.ZodString>;
236
+ kind: z.ZodLiteral<"citation">;
237
+ idKind: z.ZodEnum<{
238
+ doi: "doi";
239
+ pmid: "pmid";
240
+ arxiv: "arxiv";
241
+ }>;
242
+ id: z.ZodString;
243
+ raw: z.ZodString;
244
+ assert: z.ZodOptional<z.ZodObject<{
245
+ value: z.ZodString;
246
+ }, z.core.$strict>>;
247
+ }, z.core.$strict>], "kind">;
248
+ /**
249
+ * The references that resolve to one scalar value. A metric's value slot admits only these, thus no
250
+ * numeric literal can sit in the slot: the type admits a reference only.
251
+ */
252
+ export declare const ScalarReferenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
253
+ unit: z.ZodOptional<z.ZodString>;
254
+ format: z.ZodOptional<z.ZodString>;
255
+ locator: z.ZodObject<{
256
+ column: z.ZodString;
257
+ rowFilter: z.ZodOptional<z.ZodObject<{
258
+ column: z.ZodString;
259
+ op: z.ZodLiteral<"eq">;
260
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
261
+ }, z.core.$strict>>;
262
+ row: z.ZodOptional<z.ZodNumber>;
263
+ }, z.core.$strict>;
264
+ assert: z.ZodOptional<z.ZodObject<{
265
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
266
+ tolerance: z.ZodOptional<z.ZodNumber>;
267
+ }, z.core.$strict>>;
268
+ run: z.ZodOptional<z.ZodString>;
269
+ path: z.ZodString;
270
+ hash: z.ZodString;
271
+ snapshot: z.ZodOptional<z.ZodString>;
272
+ kind: z.ZodLiteral<"artifact-value">;
273
+ }, z.core.$strict>, z.ZodObject<{
274
+ unit: z.ZodOptional<z.ZodString>;
275
+ format: z.ZodOptional<z.ZodString>;
276
+ kind: z.ZodLiteral<"derivation">;
277
+ op: z.ZodEnum<{
278
+ ratio: "ratio";
279
+ delta: "delta";
280
+ pctChange: "pctChange";
281
+ }>;
282
+ inputs: z.ZodArray<z.ZodObject<{
283
+ unit: z.ZodOptional<z.ZodString>;
284
+ format: z.ZodOptional<z.ZodString>;
285
+ locator: z.ZodObject<{
286
+ column: z.ZodString;
287
+ rowFilter: z.ZodOptional<z.ZodObject<{
288
+ column: z.ZodString;
289
+ op: z.ZodLiteral<"eq">;
290
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
291
+ }, z.core.$strict>>;
292
+ row: z.ZodOptional<z.ZodNumber>;
293
+ }, z.core.$strict>;
294
+ assert: z.ZodOptional<z.ZodObject<{
295
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
296
+ tolerance: z.ZodOptional<z.ZodNumber>;
297
+ }, z.core.$strict>>;
298
+ run: z.ZodOptional<z.ZodString>;
299
+ path: z.ZodString;
300
+ hash: z.ZodString;
301
+ snapshot: z.ZodOptional<z.ZodString>;
302
+ kind: z.ZodLiteral<"artifact-value">;
303
+ }, z.core.$strict>>;
304
+ assert: z.ZodOptional<z.ZodObject<{
305
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
306
+ tolerance: z.ZodOptional<z.ZodNumber>;
307
+ }, z.core.$strict>>;
308
+ }, z.core.$strict>], "kind">;
309
+ /**
310
+ * The reason that a reference did not resolve.
311
+ *
312
+ * Two of the reasons are easy to confuse. `artifact-missing` means that the snapshot holds no entry for
313
+ * the path. `unreadable-artifact` means that the entry exists, and that the resolver cannot read the
314
+ * artifact as a table. Two conditions give the second reason. The file type refuses a read of a cell, or
315
+ * the bytes are unrecoverable.
316
+ */
317
+ export declare const UnresolvedReasonSchema: z.ZodEnum<{
318
+ "artifact-missing": "artifact-missing";
319
+ "hash-mismatch": "hash-mismatch";
320
+ "locator-out-of-range": "locator-out-of-range";
321
+ "ambiguous-match": "ambiguous-match";
322
+ "assertion-failed": "assertion-failed";
323
+ "unreadable-artifact": "unreadable-artifact";
324
+ }>;
325
+ /** A reference that resolution could not bind, with the reason and an optional detail. */
326
+ export declare const UnresolvedReferenceSchema: z.ZodObject<{
327
+ reference: z.ZodDiscriminatedUnion<[z.ZodObject<{
328
+ unit: z.ZodOptional<z.ZodString>;
329
+ format: z.ZodOptional<z.ZodString>;
330
+ locator: z.ZodObject<{
331
+ column: z.ZodString;
332
+ rowFilter: z.ZodOptional<z.ZodObject<{
333
+ column: z.ZodString;
334
+ op: z.ZodLiteral<"eq">;
335
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
336
+ }, z.core.$strict>>;
337
+ row: z.ZodOptional<z.ZodNumber>;
338
+ }, z.core.$strict>;
339
+ assert: z.ZodOptional<z.ZodObject<{
340
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
341
+ tolerance: z.ZodOptional<z.ZodNumber>;
342
+ }, z.core.$strict>>;
343
+ run: z.ZodOptional<z.ZodString>;
344
+ path: z.ZodString;
345
+ hash: z.ZodString;
346
+ snapshot: z.ZodOptional<z.ZodString>;
347
+ kind: z.ZodLiteral<"artifact-value">;
348
+ }, z.core.$strict>, z.ZodObject<{
349
+ unit: z.ZodOptional<z.ZodString>;
350
+ format: z.ZodOptional<z.ZodString>;
351
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
352
+ run: z.ZodOptional<z.ZodString>;
353
+ path: z.ZodString;
354
+ hash: z.ZodString;
355
+ snapshot: z.ZodOptional<z.ZodString>;
356
+ kind: z.ZodLiteral<"artifact-table">;
357
+ }, z.core.$strict>, z.ZodObject<{
358
+ unit: z.ZodOptional<z.ZodString>;
359
+ format: z.ZodOptional<z.ZodString>;
360
+ run: z.ZodOptional<z.ZodString>;
361
+ path: z.ZodString;
362
+ hash: z.ZodString;
363
+ snapshot: z.ZodOptional<z.ZodString>;
364
+ kind: z.ZodLiteral<"artifact-file">;
365
+ }, z.core.$strict>, z.ZodObject<{
366
+ unit: z.ZodOptional<z.ZodString>;
367
+ format: z.ZodOptional<z.ZodString>;
368
+ kind: z.ZodLiteral<"derivation">;
369
+ op: z.ZodEnum<{
370
+ ratio: "ratio";
371
+ delta: "delta";
372
+ pctChange: "pctChange";
373
+ }>;
374
+ inputs: z.ZodArray<z.ZodObject<{
375
+ unit: z.ZodOptional<z.ZodString>;
376
+ format: z.ZodOptional<z.ZodString>;
377
+ locator: z.ZodObject<{
378
+ column: z.ZodString;
379
+ rowFilter: z.ZodOptional<z.ZodObject<{
380
+ column: z.ZodString;
381
+ op: z.ZodLiteral<"eq">;
382
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
383
+ }, z.core.$strict>>;
384
+ row: z.ZodOptional<z.ZodNumber>;
385
+ }, z.core.$strict>;
386
+ assert: z.ZodOptional<z.ZodObject<{
387
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
388
+ tolerance: z.ZodOptional<z.ZodNumber>;
389
+ }, z.core.$strict>>;
390
+ run: z.ZodOptional<z.ZodString>;
391
+ path: z.ZodString;
392
+ hash: z.ZodString;
393
+ snapshot: z.ZodOptional<z.ZodString>;
394
+ kind: z.ZodLiteral<"artifact-value">;
395
+ }, z.core.$strict>>;
396
+ assert: z.ZodOptional<z.ZodObject<{
397
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
398
+ tolerance: z.ZodOptional<z.ZodNumber>;
399
+ }, z.core.$strict>>;
400
+ }, z.core.$strict>, z.ZodObject<{
401
+ unit: z.ZodOptional<z.ZodString>;
402
+ format: z.ZodOptional<z.ZodString>;
403
+ kind: z.ZodLiteral<"citation">;
404
+ idKind: z.ZodEnum<{
405
+ doi: "doi";
406
+ pmid: "pmid";
407
+ arxiv: "arxiv";
408
+ }>;
409
+ id: z.ZodString;
410
+ raw: z.ZodString;
411
+ assert: z.ZodOptional<z.ZodObject<{
412
+ value: z.ZodString;
413
+ }, z.core.$strict>>;
414
+ }, z.core.$strict>], "kind">;
415
+ reason: z.ZodEnum<{
416
+ "artifact-missing": "artifact-missing";
417
+ "hash-mismatch": "hash-mismatch";
418
+ "locator-out-of-range": "locator-out-of-range";
419
+ "ambiguous-match": "ambiguous-match";
420
+ "assertion-failed": "assertion-failed";
421
+ "unreadable-artifact": "unreadable-artifact";
422
+ }>;
423
+ detail: z.ZodOptional<z.ZodString>;
424
+ }, z.core.$strict>;
425
+ export type ArtifactValueReference = z.infer<typeof ArtifactValueReferenceSchema>;
426
+ export type ArtifactTableReference = z.infer<typeof ArtifactTableReferenceSchema>;
427
+ export type ArtifactFileReference = z.infer<typeof ArtifactFileReferenceSchema>;
428
+ export type CitationReference = z.infer<typeof CitationReferenceSchema>;
429
+ export type DerivationInputReference = z.infer<typeof DerivationInputReferenceSchema>;
430
+ export type DerivationReference = z.infer<typeof DerivationReferenceSchema>;
431
+ export type Reference = z.infer<typeof ReferenceSchema>;
432
+ export type ScalarReference = z.infer<typeof ScalarReferenceSchema>;
433
+ export type UnresolvedReason = z.infer<typeof UnresolvedReasonSchema>;
434
+ export type UnresolvedReference = z.infer<typeof UnresolvedReferenceSchema>;
435
+ /**
436
+ * Serialize a reference to a canonical URI.
437
+ *
438
+ * The payload is an opaque base64url of the canonical JSON, and not a structured URI with a field for
439
+ * each property. The reference object is the source of truth. A structured URI re-parses field by
440
+ * field, and it drifts from the object as the shape grows. An opaque payload cannot drift, because it
441
+ * round-trips the whole object.
442
+ */
443
+ export declare function serializeReference(reference: Reference): string;
444
+ /**
445
+ * The reason that a reference URI did not parse. Each of the four modes is distinct: a wrong prefix, a
446
+ * payload that is empty or holds a character outside the base64url alphabet, JSON that does not parse,
447
+ * and a value that the schema rejects. A caller reads the `kind` to tell them apart. `detail` carries no
448
+ * secret, thus a schema mismatch gives the kind alone.
449
+ */
450
+ export type ParseReferenceError = {
451
+ kind: "bad-prefix" | "invalid-payload" | "invalid-json" | "schema-mismatch";
452
+ detail?: string;
453
+ };
454
+ /**
455
+ * Parse a reference URI. Each failure mode gives its own `Err` `kind`, thus a caller tells a wrong
456
+ * prefix from malformed bytes, malformed JSON, and a schema mismatch. This function never throws, thus a
457
+ * caller treats a failed parse as a normal condition.
458
+ */
459
+ export declare function parseReference(uri: string): Result<Reference, ParseReferenceError>;