@marinoscar/kvox-eval 0.0.0-bootstrap → 0.1.0-next.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 (245) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +21 -0
  3. package/README.md +166 -0
  4. package/dist/ask/index.d.ts +6 -0
  5. package/dist/ask/index.js +28 -0
  6. package/dist/ask/question-schema.d.ts +121 -0
  7. package/dist/ask/question-schema.js +167 -0
  8. package/dist/ask/report.d.ts +88 -0
  9. package/dist/ask/report.js +170 -0
  10. package/dist/ask/scorer.d.ts +104 -0
  11. package/dist/ask/scorer.js +164 -0
  12. package/dist/ask-run/ask-command.d.ts +62 -0
  13. package/dist/ask-run/ask-command.js +254 -0
  14. package/dist/ask-run/host/app.d.ts +65 -0
  15. package/dist/ask-run/host/app.js +146 -0
  16. package/dist/ask-run/host/db.d.ts +38 -0
  17. package/dist/ask-run/host/db.js +126 -0
  18. package/dist/ask-run/host/ports.d.ts +35 -0
  19. package/dist/ask-run/host/ports.js +113 -0
  20. package/dist/ask-run/index.d.ts +13 -0
  21. package/dist/ask-run/index.js +35 -0
  22. package/dist/ask-run/replay.d.ts +128 -0
  23. package/dist/ask-run/replay.js +212 -0
  24. package/dist/ask-run/run-ask-eval.d.ts +125 -0
  25. package/dist/ask-run/run-ask-eval.js +193 -0
  26. package/dist/ask-run/seed-golden-graph.d.ts +64 -0
  27. package/dist/ask-run/seed-golden-graph.js +495 -0
  28. package/dist/cli/index.d.ts +3 -0
  29. package/dist/cli/index.js +12 -0
  30. package/dist/cli/kg-command.d.ts +66 -0
  31. package/dist/cli/kg-command.js +238 -0
  32. package/dist/cli/main.d.ts +18 -0
  33. package/dist/cli/main.js +69 -0
  34. package/dist/fixtures/domains.d.ts +16 -0
  35. package/dist/fixtures/domains.js +33 -0
  36. package/dist/fixtures/fixture-schema.d.ts +323 -0
  37. package/dist/fixtures/fixture-schema.js +199 -0
  38. package/dist/fixtures/index.d.ts +16 -0
  39. package/dist/fixtures/index.js +40 -0
  40. package/dist/fixtures/load.d.ts +73 -0
  41. package/dist/fixtures/load.js +137 -0
  42. package/dist/fixtures/questions.d.ts +15 -0
  43. package/dist/fixtures/questions.js +26 -0
  44. package/dist/index.d.ts +20 -0
  45. package/dist/index.js +36 -0
  46. package/dist/kg/gold-runner.d.ts +13 -0
  47. package/dist/kg/gold-runner.js +57 -0
  48. package/dist/kg/index.d.ts +17 -0
  49. package/dist/kg/index.js +65 -0
  50. package/dist/kg/internals.d.ts +7 -0
  51. package/dist/kg/internals.js +17 -0
  52. package/dist/kg/prediction-schema.d.ts +245 -0
  53. package/dist/kg/prediction-schema.js +102 -0
  54. package/dist/kg/predictions.d.ts +11 -0
  55. package/dist/kg/predictions.js +49 -0
  56. package/dist/kg/report.d.ts +84 -0
  57. package/dist/kg/report.js +125 -0
  58. package/dist/kg/run-kg-eval.d.ts +77 -0
  59. package/dist/kg/run-kg-eval.js +137 -0
  60. package/dist/kg/runner.d.ts +72 -0
  61. package/dist/kg/runner.js +51 -0
  62. package/dist/kg/runners/extract-resolve-runner.d.ts +40 -0
  63. package/dist/kg/runners/extract-resolve-runner.js +199 -0
  64. package/dist/kg/runners/extract-runner.d.ts +65 -0
  65. package/dist/kg/runners/extract-runner.js +243 -0
  66. package/dist/kg/scorer.d.ts +226 -0
  67. package/dist/kg/scorer.js +463 -0
  68. package/dist/kg/targets.d.ts +17 -0
  69. package/dist/kg/targets.js +16 -0
  70. package/dist/kg/text.d.ts +45 -0
  71. package/dist/kg/text.js +100 -0
  72. package/dist/live/adapters.d.ts +16 -0
  73. package/dist/live/adapters.js +58 -0
  74. package/dist/live/env.d.ts +39 -0
  75. package/dist/live/env.js +56 -0
  76. package/dist/live/index.d.ts +6 -0
  77. package/dist/live/index.js +16 -0
  78. package/dist/live/live-ai.d.ts +104 -0
  79. package/dist/live/live-ai.js +157 -0
  80. package/dist/parity/constants.d.ts +79 -0
  81. package/dist/parity/constants.js +104 -0
  82. package/dist/parity/index.d.ts +20 -0
  83. package/dist/parity/index.js +38 -0
  84. package/dist/parity/internals.d.ts +8 -0
  85. package/dist/parity/internals.js +16 -0
  86. package/dist/parity/scenario.d.ts +45 -0
  87. package/dist/parity/scenario.js +245 -0
  88. package/dist/parity/script.d.ts +44 -0
  89. package/dist/parity/script.js +136 -0
  90. package/dist/parity/snapshot.d.ts +43 -0
  91. package/dist/parity/snapshot.js +71 -0
  92. package/dist/real-data/index.d.ts +2 -0
  93. package/dist/real-data/index.js +12 -0
  94. package/dist/real-data/real-data.d.ts +76 -0
  95. package/dist/real-data/real-data.js +156 -0
  96. package/fixtures/kg-golden/README.md +136 -0
  97. package/fixtures/kg-golden/ask-questions.json +458 -0
  98. package/fixtures/kg-golden/meetings/m01-northwind-pilot-kickoff.json +792 -0
  99. package/fixtures/kg-golden/meetings/m02-halden-migration-planning.json +814 -0
  100. package/fixtures/kg-golden/meetings/m03-larkspur-weekly-sync.json +601 -0
  101. package/fixtures/kg-golden/meetings/m04-corvid-intake-discovery.json +690 -0
  102. package/fixtures/kg-golden/meetings/m05-hosting-vendor-selection.json +631 -0
  103. package/fixtures/kg-golden/meetings/m06-northwind-floor-data-review.json +649 -0
  104. package/fixtures/kg-golden/meetings/m07-gullwing-intro-notes.json +428 -0
  105. package/fixtures/kg-golden/meetings/m08-halden-migration-checkpoint.json +672 -0
  106. package/fixtures/kg-golden/meetings/m09-northwind-platform-org-update.json +711 -0
  107. package/fixtures/kg-golden/meetings/m10-corvid-prototype-review.json +623 -0
  108. package/fixtures/kg-golden/meetings/m11-solvane-grid-dashboard-scoping.json +689 -0
  109. package/fixtures/kg-golden/meetings/m12-northwind-pilot-replan.json +681 -0
  110. package/fixtures/kg-golden/meetings/m13-halden-cutover-go-no-go.json +721 -0
  111. package/fixtures/kg-golden/meetings/m14-gullwing-discovery-readout.json +719 -0
  112. package/fixtures/kg-golden/meetings/m15-halden-handover-ravi-leaving.json +716 -0
  113. package/fixtures/kg-golden/meetings/m16-varden-claims-portal-intro.json +704 -0
  114. package/fixtures/kg-golden/meetings/m17-corvid-usability-debrief.json +572 -0
  115. package/fixtures/kg-golden/meetings/m18-hosting-decision-revisited.json +655 -0
  116. package/fixtures/kg-golden/meetings/m19-solvane-integration-kickoff.json +726 -0
  117. package/fixtures/kg-golden/meetings/m20-northwind-go-live-retro.json +673 -0
  118. package/fixtures/kg-golden/meetings/m21-quarterly-account-review.json +449 -0
  119. package/fixtures/kg-golden/meetings/m22-halden-intro-call-2020.json +558 -0
  120. package/fixtures/kg-golden/meetings/m23-gullwing-model-review.json +702 -0
  121. package/fixtures/kg-golden/meetings/m24-varden-discovery-midpoint.json +643 -0
  122. package/fixtures/kg-golden/meetings/m25-corvid-rollout-planning.json +642 -0
  123. package/fixtures/kg-golden/meetings/m26-larkspur-engineering-prep.json +695 -0
  124. package/fixtures/kg-golden/meetings/m27-solvane-phase-one-demo.json +649 -0
  125. package/fixtures/kg-golden/meetings/m28-northwind-building-5-scoping.json +715 -0
  126. package/fixtures/kg-golden/meetings/m29-halden-southern-cutover-review.json +752 -0
  127. package/fixtures/kg-golden/meetings/m30-varden-portal-build-kickoff.json +697 -0
  128. package/fixtures/kg-golden/meetings/m31-gullwing-rollout-renewal.json +681 -0
  129. package/fixtures/kg-golden/meetings/m32-brambleway-weekly-sync.json +472 -0
  130. package/fixtures/kg-golden/meetings/m33-nina-oliver-one-on-one.json +342 -0
  131. package/fixtures/kg-golden/meetings/m34-coffee-with-dana.json +249 -0
  132. package/fixtures/kg-golden/meetings/m35-brambleway-june-sync.json +553 -0
  133. package/fixtures/kg-golden/meetings/m36-copenhagen-conference-planning.json +296 -0
  134. package/host/generated/client.d.ts +1 -0
  135. package/host/generated/client.js +5 -0
  136. package/host/generated/default.d.ts +1 -0
  137. package/host/generated/default.js +5 -0
  138. package/host/generated/edge.d.ts +1 -0
  139. package/host/generated/edge.js +1658 -0
  140. package/host/generated/index-browser.js +1684 -0
  141. package/host/generated/index.d.ts +192335 -0
  142. package/host/generated/index.js +1658 -0
  143. package/host/generated/package.json +139 -0
  144. package/host/generated/query_compiler_fast_bg.js +2 -0
  145. package/host/generated/query_compiler_fast_bg.wasm +0 -0
  146. package/host/generated/query_compiler_fast_bg.wasm-base64.js +2 -0
  147. package/host/generated/runtime/client.d.ts +3433 -0
  148. package/host/generated/runtime/client.js +110 -0
  149. package/host/generated/runtime/index-browser.d.ts +90 -0
  150. package/host/generated/runtime/index-browser.js +6 -0
  151. package/host/generated/runtime/wasm-compiler-edge.js +100 -0
  152. package/host/generated/schema.prisma +6312 -0
  153. package/host/generated/wasm-edge-light-loader.mjs +5 -0
  154. package/host/generated/wasm-worker-loader.mjs +5 -0
  155. package/host/prisma/fragments/kvox.ask.prisma +126 -0
  156. package/host/prisma/fragments/kvox.graph.prisma +1073 -0
  157. package/host/prisma/fragments/kvox.notes.prisma +787 -0
  158. package/host/prisma/fragments/kvox.search.prisma +211 -0
  159. package/host/prisma/fragments/kvox.transcripts.prisma +790 -0
  160. package/host/prisma/kvox.lock +101 -0
  161. package/host/prisma/migrations/20240101000000_initial/migration.sql +297 -0
  162. package/host/prisma/migrations/20240101000001_add_personal_access_tokens/migration.sql +31 -0
  163. package/host/prisma/migrations/20240101000002_add_credentials/migration.sql +20 -0
  164. package/host/prisma/migrations/20240101000003_add_notification_deliveries/migration.sql +27 -0
  165. package/host/prisma/migrations/20240101000004_drop_stale_uuid_defaults/migration.sql +35 -0
  166. package/host/prisma/migrations/20240101000005_add_notifications/migration.sql +22 -0
  167. package/host/prisma/migrations/20240101000006_add_push_subscriptions/migration.sql +25 -0
  168. package/host/prisma/migrations/20240101000007_add_jobs/migration.sql +110 -0
  169. package/host/prisma/migrations/20240101000008_add_worker_nodes/migration.sql +90 -0
  170. package/host/prisma/migrations/20240101000009_add_database_backup_runs/migration.sql +104 -0
  171. package/host/prisma/migrations/20240101000010_add_notification_broadcasts/migration.sql +57 -0
  172. package/host/prisma/migrations/20240101000011_add_backup_run_job_link/migration.sql +87 -0
  173. package/host/prisma/migrations/20240101000012_add_job_node_secrets/migration.sql +61 -0
  174. package/host/prisma/migrations/20240101000013_add_backup_run_pg_dump_version/migration.sql +26 -0
  175. package/host/prisma/migrations/20240101000014_add_job_claim_token/migration.sql +92 -0
  176. package/host/prisma/migrations/20240101000015_add_ai_platform/migration.sql +108 -0
  177. package/host/prisma/migrations/20240101000016_revoke_viewer_ai_use/migration.sql +32 -0
  178. package/host/prisma/migrations/20240101000017_add_user_credentials/migration.sql +29 -0
  179. package/host/prisma/migrations/20240101000018_add_device_session_credential_link/migration.sql +52 -0
  180. package/host/prisma/migrations/20240101000019_add_worker_node_vitals/migration.sql +3 -0
  181. package/host/prisma/migrations/20240101000020_add_job_trace_context/migration.sql +6 -0
  182. package/host/prisma/migrations/20240101000021_add_retention_created_at_indexes/migration.sql +13 -0
  183. package/host/prisma/migrations/20240101000022_add_organizations/migration.sql +142 -0
  184. package/host/prisma/migrations/20240101000023_split_system_org_roles/migration.sql +131 -0
  185. package/host/prisma/migrations/20240101000024_org_scoped_rls/migration.sql +215 -0
  186. package/host/prisma/migrations/20240101000025_add_groups/migration.sql +165 -0
  187. package/host/prisma/migrations/20240101000026_add_grants/migration.sql +117 -0
  188. package/host/prisma/migrations/20240101000027_add_org_settings/migration.sql +49 -0
  189. package/host/prisma/migrations/20240101000028_add_org_credentials/migration.sql +54 -0
  190. package/host/prisma/migrations/20240101000029_add_jobs_org_id/migration.sql +18 -0
  191. package/host/prisma/migrations/20240101000030_add_jobs_org_id_status_index/migration.sql +6 -0
  192. package/host/prisma/migrations/20240101000031_add_broadcast_target_org/migration.sql +21 -0
  193. package/host/prisma/migrations/20240101000032_add_android_app/migration.sql +60 -0
  194. package/host/prisma/migrations/20240101000033_open_job_reason/migration.sql +16 -0
  195. package/host/prisma/migrations/20240101000034_ai_usage_feature/migration.sql +37 -0
  196. package/host/prisma/migrations/20240101000035_add_app_metadata/migration.sql +49 -0
  197. package/host/prisma/migrations/20240101000036_open_sharing_vocabularies/migration.sql +97 -0
  198. package/host/prisma/migrations/20260914130000_kvox_add_transcripts/migration.sql +322 -0
  199. package/host/prisma/migrations/20260914140000_kvox_add_notes/migration.sql +311 -0
  200. package/host/prisma/migrations/20260915120000_kvox_add_search_vectors/migration.sql +150 -0
  201. package/host/prisma/migrations/20260915130000_kvox_add_search_embeddings/migration.sql +362 -0
  202. package/host/prisma/migrations/20260915210000_kvox_add_note_title_source/migration.sql +30 -0
  203. package/host/prisma/migrations/20260923120000_kvox_add_note_generation_context_snapshot/migration.sql +24 -0
  204. package/host/prisma/migrations/20260923130000_kvox_add_user_hidden_note_templates/migration.sql +35 -0
  205. package/host/prisma/migrations/20260923140000_kvox_add_transcript_speaker_identities/migration.sql +6 -0
  206. package/host/prisma/migrations/20260923150000_kvox_transcript_name_checks/migration.sql +95 -0
  207. package/host/prisma/migrations/20260923160000_kvox_add_note_body_format/migration.sql +27 -0
  208. package/host/prisma/migrations/20260923170000_kvox_add_note_version_body_format/migration.sql +23 -0
  209. package/host/prisma/migrations/20260926012548_kvox_add_knowledge_graph/migration.sql +680 -0
  210. package/host/prisma/migrations/20260926030000_kvox_fix_kg_relations_valid_precision_chk/migration.sql +29 -0
  211. package/host/prisma/migrations/20260926030100_kvox_add_transcript_recorded_at/migration.sql +9 -0
  212. package/host/prisma/migrations/20260926030200_kvox_kg_evidence_invariant/migration.sql +60 -0
  213. package/host/prisma/migrations/20260926040000_kvox_add_kg_graph_layouts/migration.sql +30 -0
  214. package/host/prisma/migrations/20260926050000_kvox_add_ask_conversations/migration.sql +99 -0
  215. package/host/prisma/migrations/20260926231512_kvox_add_kg_exports/migration.sql +52 -0
  216. package/host/prisma/migrations/20261016120000_kvox_transcripts_org_id/migration.sql +49 -0
  217. package/host/prisma/platform.lock +319 -0
  218. package/host/prisma/schema/app.kvox.ask.prisma +110 -0
  219. package/host/prisma/schema/app.kvox.graph.prisma +1030 -0
  220. package/host/prisma/schema/app.kvox.notes.prisma +746 -0
  221. package/host/prisma/schema/app.kvox.search.prisma +208 -0
  222. package/host/prisma/schema/app.kvox.transcripts.prisma +726 -0
  223. package/host/prisma/schema/platform.ai.prisma +419 -0
  224. package/host/prisma/schema/platform.android-app.prisma +46 -0
  225. package/host/prisma/schema/platform.base.prisma +15 -0
  226. package/host/prisma/schema/platform.credentials.prisma +156 -0
  227. package/host/prisma/schema/platform.db-backup.prisma +359 -0
  228. package/host/prisma/schema/platform.identity.prisma +638 -0
  229. package/host/prisma/schema/platform.jobs.prisma +824 -0
  230. package/host/prisma/schema/platform.notifications.prisma +641 -0
  231. package/host/prisma/schema/platform.settings.prisma +53 -0
  232. package/host/prisma/schema/platform.sharing.prisma +208 -0
  233. package/host/prisma/schema/platform.storage.prisma +118 -0
  234. package/package.json +112 -1
  235. package/parity/requests.ask.json +2681 -0
  236. package/parity/requests.m01.json +1554 -0
  237. package/parity/requests.m02.json +1554 -0
  238. package/parity/requests.m03.json +1554 -0
  239. package/parity/requests.m04.json +1554 -0
  240. package/parity/requests.m05.json +1554 -0
  241. package/parity/requests.m06.json +1554 -0
  242. package/parity/requests.m07.json +1554 -0
  243. package/parity/requests.m08.json +1554 -0
  244. package/parity/requests.m09.json +1554 -0
  245. package/parity/requests.m10.json +1554 -0
@@ -0,0 +1,245 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * One citation of a predicted row: a segment (`segmentId`) or the note, and the quote.
4
+ *
5
+ * @stability experimental
6
+ */
7
+ export declare const predictedEvidenceSchema: z.ZodObject<{
8
+ source: z.ZodEnum<{
9
+ note: "note";
10
+ segment: "segment";
11
+ }>;
12
+ segmentId: z.ZodNullable<z.ZodString>;
13
+ quote: z.ZodString;
14
+ }, z.core.$strip>;
15
+ /**
16
+ * A parsed {@link predictedEvidenceSchema}.
17
+ *
18
+ * @stability experimental
19
+ */
20
+ export type PredictedEvidence = z.infer<typeof predictedEvidenceSchema>;
21
+ /**
22
+ * What resolution decided for a predicted entity: linked (to `entityId`, with its score
23
+ * and whether the pre-check accepted it), new, or uncertain.
24
+ *
25
+ * @stability experimental
26
+ */
27
+ export declare const predictedResolutionSchema: z.ZodObject<{
28
+ outcome: z.ZodEnum<{
29
+ linked: "linked";
30
+ new: "new";
31
+ uncertain: "uncertain";
32
+ }>;
33
+ entityId: z.ZodNullable<z.ZodString>;
34
+ score: z.ZodNullable<z.ZodNumber>;
35
+ prechecked: z.ZodBoolean;
36
+ }, z.core.$strip>;
37
+ /**
38
+ * A predicted entity: its `ref` (what relations and items point at), type, label,
39
+ * aliases, resolution and evidence.
40
+ *
41
+ * @stability experimental
42
+ */
43
+ export declare const predictedEntitySchema: z.ZodObject<{
44
+ ref: z.ZodString;
45
+ type: z.ZodString;
46
+ label: z.ZodString;
47
+ aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
48
+ resolution: z.ZodDefault<z.ZodNullable<z.ZodObject<{
49
+ outcome: z.ZodEnum<{
50
+ linked: "linked";
51
+ new: "new";
52
+ uncertain: "uncertain";
53
+ }>;
54
+ entityId: z.ZodNullable<z.ZodString>;
55
+ score: z.ZodNullable<z.ZodNumber>;
56
+ prechecked: z.ZodBoolean;
57
+ }, z.core.$strip>>>;
58
+ evidence: z.ZodDefault<z.ZodArray<z.ZodObject<{
59
+ source: z.ZodEnum<{
60
+ note: "note";
61
+ segment: "segment";
62
+ }>;
63
+ segmentId: z.ZodNullable<z.ZodString>;
64
+ quote: z.ZodString;
65
+ }, z.core.$strip>>>;
66
+ }, z.core.$strip>;
67
+ /**
68
+ * A parsed {@link predictedEntitySchema}.
69
+ *
70
+ * @stability experimental
71
+ */
72
+ export type PredictedEntity = z.infer<typeof predictedEntitySchema>;
73
+ /**
74
+ * A predicted edge between two refs or known ids, with its temporal bounds and precision.
75
+ *
76
+ * @stability experimental
77
+ */
78
+ export declare const predictedRelationSchema: z.ZodObject<{
79
+ type: z.ZodString;
80
+ from: z.ZodString;
81
+ to: z.ZodString;
82
+ validFrom: z.ZodNullable<z.ZodString>;
83
+ validTo: z.ZodNullable<z.ZodString>;
84
+ precision: z.ZodEnum<{
85
+ unknown: "unknown";
86
+ day: "day";
87
+ month: "month";
88
+ year: "year";
89
+ }>;
90
+ evidence: z.ZodDefault<z.ZodArray<z.ZodObject<{
91
+ source: z.ZodEnum<{
92
+ note: "note";
93
+ segment: "segment";
94
+ }>;
95
+ segmentId: z.ZodNullable<z.ZodString>;
96
+ quote: z.ZodString;
97
+ }, z.core.$strip>>>;
98
+ }, z.core.$strip>;
99
+ /**
100
+ * A parsed {@link predictedRelationSchema}.
101
+ *
102
+ * @stability experimental
103
+ */
104
+ export type PredictedRelation = z.infer<typeof predictedRelationSchema>;
105
+ /**
106
+ * A predicted commitment, decision, claim or person fact.
107
+ *
108
+ * @stability experimental
109
+ */
110
+ export declare const predictedItemSchema: z.ZodObject<{
111
+ kind: z.ZodEnum<{
112
+ commitment: "commitment";
113
+ decision: "decision";
114
+ claim: "claim";
115
+ person_fact: "person_fact";
116
+ }>;
117
+ subject: z.ZodString;
118
+ owner: z.ZodDefault<z.ZodNullable<z.ZodString>>;
119
+ counterparty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
120
+ title: z.ZodString;
121
+ statement: z.ZodString;
122
+ occurredAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
123
+ dueAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
124
+ sensitivity: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
125
+ business: "business";
126
+ personal: "personal";
127
+ sensitive: "sensitive";
128
+ }>>>;
129
+ evidence: z.ZodDefault<z.ZodArray<z.ZodObject<{
130
+ source: z.ZodEnum<{
131
+ note: "note";
132
+ segment: "segment";
133
+ }>;
134
+ segmentId: z.ZodNullable<z.ZodString>;
135
+ quote: z.ZodString;
136
+ }, z.core.$strip>>>;
137
+ }, z.core.$strip>;
138
+ /**
139
+ * A parsed {@link predictedItemSchema}.
140
+ *
141
+ * @stability experimental
142
+ */
143
+ export type PredictedItem = z.infer<typeof predictedItemSchema>;
144
+ /**
145
+ * What a runner writes for one fixture, `<outDir>/<fixtureId>.json`: the entities,
146
+ * relations and items a run proposed, the model id (never a key) and the dropped counts.
147
+ *
148
+ * @stability experimental
149
+ */
150
+ export declare const kgEvalPredictionSchema: z.ZodObject<{
151
+ fixtureId: z.ZodString;
152
+ model: z.ZodNullable<z.ZodString>;
153
+ entities: z.ZodArray<z.ZodObject<{
154
+ ref: z.ZodString;
155
+ type: z.ZodString;
156
+ label: z.ZodString;
157
+ aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
158
+ resolution: z.ZodDefault<z.ZodNullable<z.ZodObject<{
159
+ outcome: z.ZodEnum<{
160
+ linked: "linked";
161
+ new: "new";
162
+ uncertain: "uncertain";
163
+ }>;
164
+ entityId: z.ZodNullable<z.ZodString>;
165
+ score: z.ZodNullable<z.ZodNumber>;
166
+ prechecked: z.ZodBoolean;
167
+ }, z.core.$strip>>>;
168
+ evidence: z.ZodDefault<z.ZodArray<z.ZodObject<{
169
+ source: z.ZodEnum<{
170
+ note: "note";
171
+ segment: "segment";
172
+ }>;
173
+ segmentId: z.ZodNullable<z.ZodString>;
174
+ quote: z.ZodString;
175
+ }, z.core.$strip>>>;
176
+ }, z.core.$strip>>;
177
+ relations: z.ZodArray<z.ZodObject<{
178
+ type: z.ZodString;
179
+ from: z.ZodString;
180
+ to: z.ZodString;
181
+ validFrom: z.ZodNullable<z.ZodString>;
182
+ validTo: z.ZodNullable<z.ZodString>;
183
+ precision: z.ZodEnum<{
184
+ unknown: "unknown";
185
+ day: "day";
186
+ month: "month";
187
+ year: "year";
188
+ }>;
189
+ evidence: z.ZodDefault<z.ZodArray<z.ZodObject<{
190
+ source: z.ZodEnum<{
191
+ note: "note";
192
+ segment: "segment";
193
+ }>;
194
+ segmentId: z.ZodNullable<z.ZodString>;
195
+ quote: z.ZodString;
196
+ }, z.core.$strip>>>;
197
+ }, z.core.$strip>>;
198
+ items: z.ZodArray<z.ZodObject<{
199
+ kind: z.ZodEnum<{
200
+ commitment: "commitment";
201
+ decision: "decision";
202
+ claim: "claim";
203
+ person_fact: "person_fact";
204
+ }>;
205
+ subject: z.ZodString;
206
+ owner: z.ZodDefault<z.ZodNullable<z.ZodString>>;
207
+ counterparty: z.ZodDefault<z.ZodNullable<z.ZodString>>;
208
+ title: z.ZodString;
209
+ statement: z.ZodString;
210
+ occurredAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
211
+ dueAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
212
+ sensitivity: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
213
+ business: "business";
214
+ personal: "personal";
215
+ sensitive: "sensitive";
216
+ }>>>;
217
+ evidence: z.ZodDefault<z.ZodArray<z.ZodObject<{
218
+ source: z.ZodEnum<{
219
+ note: "note";
220
+ segment: "segment";
221
+ }>;
222
+ segmentId: z.ZodNullable<z.ZodString>;
223
+ quote: z.ZodString;
224
+ }, z.core.$strip>>>;
225
+ }, z.core.$strip>>;
226
+ stats: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
227
+ }, z.core.$strip>;
228
+ /**
229
+ * A parsed {@link kgEvalPredictionSchema}.
230
+ *
231
+ * @stability experimental
232
+ */
233
+ export type KgEvalPrediction = z.infer<typeof kgEvalPredictionSchema>;
234
+ /**
235
+ * A prediction as written on disk (before defaults).
236
+ *
237
+ * @stability experimental
238
+ */
239
+ export type KgEvalPredictionInput = z.input<typeof kgEvalPredictionSchema>;
240
+ /**
241
+ * A prediction with nothing in it: what a missing prediction file scores as.
242
+ *
243
+ * @stability experimental
244
+ */
245
+ export declare function emptyPrediction(fixtureId: string, model?: string | null): KgEvalPrediction;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ // =============================================================================
3
+ // What a kg:eval runner writes, one file per fixture: `<outDir>/<fixtureId>.json`
4
+ // (issue #362). `from`/`to`/`subject`/`owner`/`counterparty` name either a
5
+ // prediction entity `ref` or a `knownEntities` id from the fixture.
6
+ // =============================================================================
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.kgEvalPredictionSchema = exports.predictedItemSchema = exports.predictedRelationSchema = exports.predictedEntitySchema = exports.predictedResolutionSchema = exports.predictedEvidenceSchema = void 0;
9
+ exports.emptyPrediction = emptyPrediction;
10
+ const zod_1 = require("zod");
11
+ const index_js_1 = require("../fixtures/index.js");
12
+ /**
13
+ * One citation of a predicted row: a segment (`segmentId`) or the note, and the quote.
14
+ *
15
+ * @stability experimental
16
+ */
17
+ exports.predictedEvidenceSchema = zod_1.z.object({
18
+ source: zod_1.z.enum(['segment', 'note']),
19
+ segmentId: zod_1.z.string().nullable(),
20
+ quote: zod_1.z.string(),
21
+ });
22
+ /**
23
+ * What resolution decided for a predicted entity: linked (to `entityId`, with its score
24
+ * and whether the pre-check accepted it), new, or uncertain.
25
+ *
26
+ * @stability experimental
27
+ */
28
+ exports.predictedResolutionSchema = zod_1.z.object({
29
+ outcome: zod_1.z.enum(['linked', 'new', 'uncertain']),
30
+ entityId: zod_1.z.string().nullable(),
31
+ score: zod_1.z.number().nullable(),
32
+ prechecked: zod_1.z.boolean(),
33
+ });
34
+ /**
35
+ * A predicted entity: its `ref` (what relations and items point at), type, label,
36
+ * aliases, resolution and evidence.
37
+ *
38
+ * @stability experimental
39
+ */
40
+ exports.predictedEntitySchema = zod_1.z.object({
41
+ ref: zod_1.z.string(),
42
+ type: zod_1.z.string(),
43
+ label: zod_1.z.string(),
44
+ aliases: zod_1.z.array(zod_1.z.string()).default([]),
45
+ resolution: exports.predictedResolutionSchema.nullable().default(null),
46
+ evidence: zod_1.z.array(exports.predictedEvidenceSchema).default([]),
47
+ });
48
+ /**
49
+ * A predicted edge between two refs or known ids, with its temporal bounds and precision.
50
+ *
51
+ * @stability experimental
52
+ */
53
+ exports.predictedRelationSchema = zod_1.z.object({
54
+ type: zod_1.z.string(),
55
+ from: zod_1.z.string(),
56
+ to: zod_1.z.string(),
57
+ validFrom: zod_1.z.string().nullable(),
58
+ validTo: zod_1.z.string().nullable(),
59
+ precision: index_js_1.validPrecisionSchema,
60
+ evidence: zod_1.z.array(exports.predictedEvidenceSchema).default([]),
61
+ });
62
+ /**
63
+ * A predicted commitment, decision, claim or person fact.
64
+ *
65
+ * @stability experimental
66
+ */
67
+ exports.predictedItemSchema = zod_1.z.object({
68
+ kind: zod_1.z.enum(index_js_1.ITEM_LABEL_KINDS),
69
+ subject: zod_1.z.string(),
70
+ owner: zod_1.z.string().nullable().default(null),
71
+ counterparty: zod_1.z.string().nullable().default(null),
72
+ title: zod_1.z.string(),
73
+ statement: zod_1.z.string(),
74
+ occurredAt: zod_1.z.string().nullable().default(null),
75
+ dueAt: zod_1.z.string().nullable().default(null),
76
+ sensitivity: zod_1.z.enum(['business', 'personal', 'sensitive']).nullable().default(null),
77
+ evidence: zod_1.z.array(exports.predictedEvidenceSchema).default([]),
78
+ });
79
+ /**
80
+ * What a runner writes for one fixture, `<outDir>/<fixtureId>.json`: the entities,
81
+ * relations and items a run proposed, the model id (never a key) and the dropped counts.
82
+ *
83
+ * @stability experimental
84
+ */
85
+ exports.kgEvalPredictionSchema = zod_1.z.object({
86
+ fixtureId: zod_1.z.string(),
87
+ /** The model id only — never a key, never a provider credential. */
88
+ model: zod_1.z.string().nullable(),
89
+ entities: zod_1.z.array(exports.predictedEntitySchema),
90
+ relations: zod_1.z.array(exports.predictedRelationSchema),
91
+ items: zod_1.z.array(exports.predictedItemSchema),
92
+ /** Passthrough from the proposal (`uncited`, `invalid`, … dropped counts). */
93
+ stats: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).default({}),
94
+ });
95
+ /**
96
+ * A prediction with nothing in it: what a missing prediction file scores as.
97
+ *
98
+ * @stability experimental
99
+ */
100
+ function emptyPrediction(fixtureId, model = null) {
101
+ return { fixtureId, model, entities: [], relations: [], items: [], stats: {} };
102
+ }
@@ -0,0 +1,11 @@
1
+ import { type KgEvalPrediction } from './prediction-schema.js';
2
+ /**
3
+ * One prediction file, or `null` when absent.
4
+ *
5
+ * @param dir - the predictions directory.
6
+ * @param fixtureId - the fixture the file is named after.
7
+ * @returns the prediction, or `null`.
8
+ * @throws `KgEvalLoadError` when the file is not JSON, does not match the schema or names another fixture.
9
+ * @stability experimental
10
+ */
11
+ export declare function loadPredictionFile(dir: string, fixtureId: string): KgEvalPrediction | null;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ // Loading a predictions directory (issue #362): `<dir>/<fixtureId>.json`, one
3
+ // file per fixture, parsed through `kgEvalPredictionSchema`. A missing file is
4
+ // `null` (the caller scores it as empty and says so); a malformed one throws
5
+ // with its name.
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.loadPredictionFile = loadPredictionFile;
8
+ const fs_1 = require("fs");
9
+ const path_1 = require("path");
10
+ const index_js_1 = require("../fixtures/index.js");
11
+ const prediction_schema_js_1 = require("./prediction-schema.js");
12
+ /**
13
+ * One prediction file, or `null` when absent.
14
+ *
15
+ * @param dir - the predictions directory.
16
+ * @param fixtureId - the fixture the file is named after.
17
+ * @returns the prediction, or `null`.
18
+ * @throws `KgEvalLoadError` when the file is not JSON, does not match the schema or names another fixture.
19
+ * @stability experimental
20
+ */
21
+ function loadPredictionFile(dir, fixtureId) {
22
+ const file = (0, path_1.join)(dir, `${fixtureId}.json`);
23
+ let text;
24
+ try {
25
+ text = (0, fs_1.readFileSync)(file, 'utf8');
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ let raw;
31
+ try {
32
+ raw = JSON.parse(text);
33
+ }
34
+ catch (err) {
35
+ throw new index_js_1.KgEvalLoadError(`${file}: not valid JSON (${err.message})`);
36
+ }
37
+ const parsed = prediction_schema_js_1.kgEvalPredictionSchema.safeParse(raw);
38
+ if (!parsed.success) {
39
+ const issues = parsed.error.issues
40
+ .slice(0, 5)
41
+ .map((i) => `${i.path.join('.')}: ${i.message}`)
42
+ .join('; ');
43
+ throw new index_js_1.KgEvalLoadError(`${file}: does not match kgEvalPredictionSchema — ${issues}`);
44
+ }
45
+ if (parsed.data.fixtureId !== fixtureId) {
46
+ throw new index_js_1.KgEvalLoadError(`${file}: fixtureId is ${parsed.data.fixtureId}, expected ${fixtureId}`);
47
+ }
48
+ return parsed.data;
49
+ }
@@ -0,0 +1,84 @@
1
+ import { z } from 'zod';
2
+ import { type RunScore } from './scorer.js';
3
+ /**
4
+ * The kg evaluation report, the JSON `--json` writes: per-type counts and ratios, the §6
5
+ * target metrics, evidence validity, temporal accuracy, the dropped counts and the
6
+ * per-fixture sums. A tuning script may rely on its shape.
7
+ *
8
+ * @stability experimental
9
+ */
10
+ export declare const kgEvalReportSchema: z.ZodObject<{
11
+ fixtures: z.ZodNumber;
12
+ fixtureIds: z.ZodArray<z.ZodString>;
13
+ runner: z.ZodString;
14
+ model: z.ZodNullable<z.ZodString>;
15
+ types: z.ZodArray<z.ZodObject<{
16
+ type: z.ZodString;
17
+ tp: z.ZodNumber;
18
+ fp: z.ZodNumber;
19
+ fn: z.ZodNumber;
20
+ precision: z.ZodNullable<z.ZodNumber>;
21
+ recall: z.ZodNullable<z.ZodNumber>;
22
+ f1: z.ZodNullable<z.ZodNumber>;
23
+ }, z.core.$strip>>;
24
+ metrics: z.ZodObject<{
25
+ entityCoverage: z.ZodObject<{
26
+ value: z.ZodNullable<z.ZodNumber>;
27
+ target: z.ZodNumber;
28
+ pass: z.ZodNullable<z.ZodBoolean>;
29
+ }, z.core.$strip>;
30
+ commitmentRecall: z.ZodObject<{
31
+ value: z.ZodNullable<z.ZodNumber>;
32
+ target: z.ZodNumber;
33
+ pass: z.ZodNullable<z.ZodBoolean>;
34
+ }, z.core.$strip>;
35
+ autoLinkPrecision: z.ZodObject<{
36
+ value: z.ZodNullable<z.ZodNumber>;
37
+ target: z.ZodNumber;
38
+ pass: z.ZodNullable<z.ZodBoolean>;
39
+ }, z.core.$strip>;
40
+ evidenceValidity: z.ZodObject<{
41
+ value: z.ZodNullable<z.ZodNumber>;
42
+ }, z.core.$strip>;
43
+ temporalAccuracy: z.ZodObject<{
44
+ value: z.ZodNullable<z.ZodNumber>;
45
+ }, z.core.$strip>;
46
+ }, z.core.$strip>;
47
+ dropped: z.ZodRecord<z.ZodString, z.ZodNumber>;
48
+ perFixture: z.ZodArray<z.ZodObject<{
49
+ fixtureId: z.ZodString;
50
+ tp: z.ZodNumber;
51
+ fp: z.ZodNumber;
52
+ fn: z.ZodNumber;
53
+ }, z.core.$strip>>;
54
+ targetsMet: z.ZodBoolean;
55
+ }, z.core.$strip>;
56
+ /**
57
+ * A parsed {@link kgEvalReportSchema}.
58
+ *
59
+ * @stability experimental
60
+ */
61
+ export type KgEvalReport = z.infer<typeof kgEvalReportSchema>;
62
+ /**
63
+ * Turns a run's score into the report.
64
+ *
65
+ * @param run - the run's score (`scoreRun`).
66
+ * @param meta - the runner label, the model and the fixture ids.
67
+ * @returns the report (`targetsMet` is `true` when no target with a value fails).
68
+ *
69
+ * @stability experimental
70
+ */
71
+ export declare function buildReport(run: RunScore, meta: {
72
+ runner: string;
73
+ model: string | null;
74
+ fixtureIds: string[];
75
+ }): KgEvalReport;
76
+ /**
77
+ * The report as the fixed-column table the command prints.
78
+ *
79
+ * @param r - the report.
80
+ * @returns the table.
81
+ *
82
+ * @stability experimental
83
+ */
84
+ export declare function formatReport(r: KgEvalReport): string;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ // kg:eval report (issue #362): one object, printed as a fixed-column table and
3
+ // optionally written as JSON (`--json`). `kgEvalReportSchema` is the JSON's
4
+ // contract — a tuning script that reads it can rely on its shape.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.kgEvalReportSchema = void 0;
7
+ exports.buildReport = buildReport;
8
+ exports.formatReport = formatReport;
9
+ const zod_1 = require("zod");
10
+ const scorer_js_1 = require("./scorer.js");
11
+ const targets_js_1 = require("./targets.js");
12
+ const nullableRatio = zod_1.z.number().min(0).max(1).nullable();
13
+ const targetMetric = zod_1.z.object({ value: nullableRatio, target: zod_1.z.number(), pass: zod_1.z.boolean().nullable() });
14
+ /**
15
+ * The kg evaluation report, the JSON `--json` writes: per-type counts and ratios, the §6
16
+ * target metrics, evidence validity, temporal accuracy, the dropped counts and the
17
+ * per-fixture sums. A tuning script may rely on its shape.
18
+ *
19
+ * @stability experimental
20
+ */
21
+ exports.kgEvalReportSchema = zod_1.z.object({
22
+ fixtures: zod_1.z.number().int(),
23
+ fixtureIds: zod_1.z.array(zod_1.z.string()),
24
+ runner: zod_1.z.string(),
25
+ model: zod_1.z.string().nullable(),
26
+ types: zod_1.z.array(zod_1.z.object({
27
+ type: zod_1.z.string(),
28
+ tp: zod_1.z.number().int(),
29
+ fp: zod_1.z.number().int(),
30
+ fn: zod_1.z.number().int(),
31
+ precision: nullableRatio,
32
+ recall: nullableRatio,
33
+ f1: nullableRatio,
34
+ })),
35
+ metrics: zod_1.z.object({
36
+ entityCoverage: targetMetric,
37
+ commitmentRecall: targetMetric,
38
+ autoLinkPrecision: targetMetric,
39
+ evidenceValidity: zod_1.z.object({ value: nullableRatio }),
40
+ temporalAccuracy: zod_1.z.object({ value: nullableRatio }),
41
+ }),
42
+ dropped: zod_1.z.record(zod_1.z.string(), zod_1.z.number()),
43
+ perFixture: zod_1.z.array(zod_1.z.object({ fixtureId: zod_1.z.string(), tp: zod_1.z.number().int(), fp: zod_1.z.number().int(), fn: zod_1.z.number().int() })),
44
+ /** true when every target with a value meets it (an `n/a` target never fails). */
45
+ targetsMet: zod_1.z.boolean(),
46
+ });
47
+ function target(value, t) {
48
+ return { value, target: t, pass: value === null ? null : value >= t };
49
+ }
50
+ /**
51
+ * Turns a run's score into the report.
52
+ *
53
+ * @param run - the run's score (`scoreRun`).
54
+ * @param meta - the runner label, the model and the fixture ids.
55
+ * @returns the report (`targetsMet` is `true` when no target with a value fails).
56
+ *
57
+ * @stability experimental
58
+ */
59
+ function buildReport(run, meta) {
60
+ const relationTypes = Object.keys(run.types)
61
+ .filter((t) => t.startsWith('relation:'))
62
+ .sort();
63
+ const types = [...scorer_js_1.BASE_REPORT_TYPES, ...relationTypes].map((type) => {
64
+ const c = run.types[type] ?? { tp: 0, fp: 0, fn: 0 };
65
+ return { type, ...c, precision: (0, scorer_js_1.precisionOf)(c), recall: (0, scorer_js_1.recallOf)(c), f1: (0, scorer_js_1.f1Of)(c) };
66
+ });
67
+ const metrics = {
68
+ entityCoverage: target((0, scorer_js_1.entityCoverage)(run), targets_js_1.KG_EVAL_TARGETS.entityCoverage),
69
+ commitmentRecall: target((0, scorer_js_1.commitmentRecall)(run), targets_js_1.KG_EVAL_TARGETS.commitmentRecall),
70
+ autoLinkPrecision: target((0, scorer_js_1.autoLinkPrecision)(run), targets_js_1.KG_EVAL_TARGETS.autoLinkPrecision),
71
+ evidenceValidity: { value: (0, scorer_js_1.ratio)(run.evidence.valid, run.evidence.total) },
72
+ temporalAccuracy: { value: (0, scorer_js_1.ratio)(run.temporal.accurate, run.temporal.total) },
73
+ };
74
+ const dropped = { uncited: 0, invalid: 0, ...run.stats };
75
+ const perFixture = run.perFixture.map((f) => {
76
+ const sum = { tp: 0, fp: 0, fn: 0 };
77
+ for (const c of Object.values(f.types)) {
78
+ sum.tp += c.tp;
79
+ sum.fp += c.fp;
80
+ sum.fn += c.fn;
81
+ }
82
+ return { fixtureId: f.fixtureId, ...sum };
83
+ });
84
+ const targetsMet = [metrics.entityCoverage, metrics.commitmentRecall, metrics.autoLinkPrecision].every((m) => m.pass !== false);
85
+ return {
86
+ fixtures: run.fixtures,
87
+ fixtureIds: meta.fixtureIds,
88
+ runner: meta.runner,
89
+ model: meta.model,
90
+ types,
91
+ metrics,
92
+ dropped,
93
+ perFixture,
94
+ targetsMet,
95
+ };
96
+ }
97
+ const fmt = (v) => (v === null ? 'n/a' : v.toFixed(3));
98
+ const pad = (s, n) => String(s).padEnd(n);
99
+ /**
100
+ * The report as the fixed-column table the command prints.
101
+ *
102
+ * @param r - the report.
103
+ * @returns the table.
104
+ *
105
+ * @stability experimental
106
+ */
107
+ function formatReport(r) {
108
+ const lines = [];
109
+ lines.push(`kg:eval fixtures=${r.fixtures} runner=${r.runner} model=${r.model ?? '-'}`);
110
+ lines.push(`${pad('TYPE', 26)}${pad('TP', 6)}${pad('FP', 6)}${pad('FN', 6)}${pad('P', 7)}${pad('R', 7)}F1`);
111
+ for (const t of r.types) {
112
+ lines.push(`${pad(t.type, 26)}${pad(t.tp, 6)}${pad(t.fp, 6)}${pad(t.fn, 6)}${pad(fmt(t.precision), 7)}${pad(fmt(t.recall), 7)}${fmt(t.f1)}`);
113
+ }
114
+ const verdict = (m) => (m.pass === null ? '' : m.pass ? 'PASS' : 'FAIL');
115
+ const m = r.metrics;
116
+ lines.push(`${pad('ENTITY COVERAGE', 21)}${pad(fmt(m.entityCoverage.value), 8)}target ≥ ${m.entityCoverage.target.toFixed(2)} ${verdict(m.entityCoverage)}`);
117
+ lines.push(`${pad('COMMITMENT RECALL', 21)}${pad(fmt(m.commitmentRecall.value), 8)}target ≥ ${m.commitmentRecall.target.toFixed(2)} ${verdict(m.commitmentRecall)}`);
118
+ lines.push(`${pad('AUTO-LINK PRECISION', 21)}${pad(fmt(m.autoLinkPrecision.value), 8)}target ≥ ${m.autoLinkPrecision.target.toFixed(2)} ${m.autoLinkPrecision.value === null ? '(no resolution in predictions)' : verdict(m.autoLinkPrecision)}`);
119
+ lines.push(`${pad('EVIDENCE VALIDITY', 21)}${pad(fmt(m.evidenceValidity.value), 8)}(cites that resolve to a fixture segment/note and whose quote is located)`);
120
+ lines.push(`${pad('TEMPORAL ACCURACY', 21)}${pad(fmt(m.temporalAccuracy.value), 8)}(matched temporal relations/items with equal precision and dates at that precision)`);
121
+ lines.push(`${pad('DROPPED (stats)', 21)}${Object.entries(r.dropped)
122
+ .map(([k, v]) => `${k}=${v}`)
123
+ .join(' ')}`);
124
+ return lines.join('\n');
125
+ }