@inflexa-ai/harness 0.35.8 → 0.36.1

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 (198) hide show
  1. package/dist/auth/types.d.ts +5 -14
  2. package/dist/auth/types.js +3 -10
  3. package/dist/billing/usage-recorder.d.ts +1 -1
  4. package/dist/contracts/analogy-report.d.ts +1 -1
  5. package/dist/contracts/analogy-report.js +1 -1
  6. package/dist/contracts/chat-parts.d.ts +2 -3
  7. package/dist/contracts/index.d.ts +0 -4
  8. package/dist/contracts/index.js +0 -2
  9. package/dist/index.d.ts +0 -7
  10. package/dist/index.js +0 -21
  11. package/dist/lib/metrics.d.ts +1 -1
  12. package/dist/lib/otel-spans.d.ts +0 -2
  13. package/dist/lib/otel-spans.js +0 -2
  14. package/dist/loop/genai-spans.d.ts +14 -0
  15. package/dist/loop/genai-spans.js +35 -0
  16. package/dist/loop/run-agent.d.ts +1 -1
  17. package/dist/loop/run-agent.js +37 -4
  18. package/dist/runtime/assemble.d.ts +0 -3
  19. package/dist/runtime/assemble.js +0 -3
  20. package/dist/state/index.d.ts +0 -2
  21. package/dist/state/index.js +0 -1
  22. package/dist/state/init.js +1 -60
  23. package/dist/state/purge-analysis.d.ts +1 -2
  24. package/dist/state/purge-analysis.js +1 -2
  25. package/dist/tasks/regulatory-corpus-boot-refresh.js +1 -1
  26. package/dist/tools/bio/gene-preclinical-profile.d.ts +1 -3
  27. package/dist/tools/bio/gene-preclinical-profile.js +1 -3
  28. package/dist/tools/lib/chembl-client.d.ts +1 -4
  29. package/dist/tools/lib/chembl-client.js +1 -4
  30. package/dist/tools/lib/clinical-benchmarks-client.d.ts +1 -1
  31. package/dist/tools/lib/clinical-benchmarks-client.js +1 -1
  32. package/dist/tools/lib/clinical-trials-client.d.ts +0 -3
  33. package/dist/tools/lib/clinical-trials-client.js +0 -3
  34. package/dist/tools/lib/identifier-resolver.d.ts +5 -7
  35. package/dist/tools/lib/identifier-resolver.js +5 -7
  36. package/dist/tools/lib/iuphar-client.d.ts +1 -3
  37. package/dist/tools/lib/iuphar-client.js +1 -3
  38. package/dist/tools/lib/opentargets-client.d.ts +1 -1
  39. package/dist/tools/lib/opentargets-client.js +1 -1
  40. package/dist/tools/lib/protein-family-normalize.d.ts +5 -7
  41. package/dist/tools/lib/protein-family-normalize.js +5 -7
  42. package/dist/tools/lib/uniprot-client.d.ts +0 -7
  43. package/dist/tools/lib/uniprot-client.js +2 -9
  44. package/package.json +1 -1
  45. package/dist/contracts/target-assessment-row.d.ts +0 -85
  46. package/dist/contracts/target-assessment-row.js +0 -37
  47. package/dist/contracts/target-dossier.d.ts +0 -12423
  48. package/dist/contracts/target-dossier.js +0 -1282
  49. package/dist/prompts/target-assessment/briefs/executive-recommendation.d.ts +0 -1
  50. package/dist/prompts/target-assessment/briefs/executive-recommendation.js +0 -85
  51. package/dist/prompts/target-assessment/briefs/index.d.ts +0 -4
  52. package/dist/prompts/target-assessment/briefs/index.js +0 -4
  53. package/dist/prompts/target-assessment/briefs/liability-bullets.d.ts +0 -1
  54. package/dist/prompts/target-assessment/briefs/liability-bullets.js +0 -114
  55. package/dist/prompts/target-assessment/briefs/target-organ-liabilities.d.ts +0 -1
  56. package/dist/prompts/target-assessment/briefs/target-organ-liabilities.js +0 -37
  57. package/dist/prompts/target-assessment/briefs/translational-commentary.d.ts +0 -1
  58. package/dist/prompts/target-assessment/briefs/translational-commentary.js +0 -23
  59. package/dist/prompts/target-assessment/drugs-in-class.d.ts +0 -1
  60. package/dist/prompts/target-assessment/drugs-in-class.js +0 -29
  61. package/dist/prompts/target-assessment/investigation/adversarial-critique.d.ts +0 -1
  62. package/dist/prompts/target-assessment/investigation/adversarial-critique.js +0 -67
  63. package/dist/prompts/target-assessment/investigation/claim-reverification.d.ts +0 -1
  64. package/dist/prompts/target-assessment/investigation/claim-reverification.js +0 -49
  65. package/dist/prompts/target-assessment/investigation/index.d.ts +0 -3
  66. package/dist/prompts/target-assessment/investigation/index.js +0 -3
  67. package/dist/prompts/target-assessment/investigation/mechanism-proposal.d.ts +0 -1
  68. package/dist/prompts/target-assessment/investigation/mechanism-proposal.js +0 -49
  69. package/dist/prompts/target-assessment/modulator-triage.d.ts +0 -1
  70. package/dist/prompts/target-assessment/modulator-triage.js +0 -31
  71. package/dist/prompts/target-assessment/off-target-annotator.d.ts +0 -1
  72. package/dist/prompts/target-assessment/off-target-annotator.js +0 -28
  73. package/dist/prompts/target-assessment/tox-voice/core.d.ts +0 -1
  74. package/dist/prompts/target-assessment/tox-voice/core.js +0 -74
  75. package/dist/prompts/target-assessment/tox-voice/critique.d.ts +0 -7
  76. package/dist/prompts/target-assessment/tox-voice/critique.js +0 -109
  77. package/dist/prompts/target-assessment/tox-voice/exemplars.d.ts +0 -8
  78. package/dist/prompts/target-assessment/tox-voice/exemplars.js +0 -24
  79. package/dist/prompts/target-assessment/tox-voice/index.d.ts +0 -4
  80. package/dist/prompts/target-assessment/tox-voice/index.js +0 -4
  81. package/dist/prompts/target-assessment/tox-voice/vocabulary.d.ts +0 -18
  82. package/dist/prompts/target-assessment/tox-voice/vocabulary.js +0 -61
  83. package/dist/state/target-assessments.d.ts +0 -68
  84. package/dist/state/target-assessments.js +0 -222
  85. package/dist/workflows/execute-target-assessment.d.ts +0 -118
  86. package/dist/workflows/execute-target-assessment.js +0 -631
  87. package/dist/workflows/target-assessment/assemblers/index.d.ts +0 -5
  88. package/dist/workflows/target-assessment/assemblers/index.js +0 -4
  89. package/dist/workflows/target-assessment/assemblers/literature.d.ts +0 -281
  90. package/dist/workflows/target-assessment/assemblers/literature.js +0 -971
  91. package/dist/workflows/target-assessment/assemblers/orchestrator.d.ts +0 -118
  92. package/dist/workflows/target-assessment/assemblers/orchestrator.js +0 -945
  93. package/dist/workflows/target-assessment/assemblers/safety.d.ts +0 -374
  94. package/dist/workflows/target-assessment/assemblers/safety.js +0 -1068
  95. package/dist/workflows/target-assessment/assemblers/trials.d.ts +0 -30
  96. package/dist/workflows/target-assessment/assemblers/trials.js +0 -75
  97. package/dist/workflows/target-assessment/collectors/index.d.ts +0 -114
  98. package/dist/workflows/target-assessment/collectors/index.js +0 -538
  99. package/dist/workflows/target-assessment/coverage.d.ts +0 -97
  100. package/dist/workflows/target-assessment/coverage.js +0 -86
  101. package/dist/workflows/target-assessment/decisions/index.d.ts +0 -86
  102. package/dist/workflows/target-assessment/decisions/index.js +0 -127
  103. package/dist/workflows/target-assessment/fanout/index.d.ts +0 -32
  104. package/dist/workflows/target-assessment/fanout/index.js +0 -156
  105. package/dist/workflows/target-assessment/investigation/index.d.ts +0 -97
  106. package/dist/workflows/target-assessment/investigation/index.js +0 -419
  107. package/dist/workflows/target-assessment/lib/approval-precedents.d.ts +0 -73
  108. package/dist/workflows/target-assessment/lib/approval-precedents.js +0 -185
  109. package/dist/workflows/target-assessment/lib/citation-validator.d.ts +0 -46
  110. package/dist/workflows/target-assessment/lib/citation-validator.js +0 -316
  111. package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.d.ts +0 -65
  112. package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.js +0 -174
  113. package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.d.ts +0 -44
  114. package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.js +0 -152
  115. package/dist/workflows/target-assessment/lib/compute-derived.d.ts +0 -20
  116. package/dist/workflows/target-assessment/lib/compute-derived.js +0 -261
  117. package/dist/workflows/target-assessment/lib/compute-selectivity.d.ts +0 -15
  118. package/dist/workflows/target-assessment/lib/compute-selectivity.js +0 -18
  119. package/dist/workflows/target-assessment/lib/dedup-modulators.d.ts +0 -37
  120. package/dist/workflows/target-assessment/lib/dedup-modulators.js +0 -157
  121. package/dist/workflows/target-assessment/lib/evidence-conflict-detector.d.ts +0 -17
  122. package/dist/workflows/target-assessment/lib/evidence-conflict-detector.js +0 -100
  123. package/dist/workflows/target-assessment/lib/expression-constants.d.ts +0 -21
  124. package/dist/workflows/target-assessment/lib/expression-constants.js +0 -21
  125. package/dist/workflows/target-assessment/lib/family-complex-supplement.d.ts +0 -20
  126. package/dist/workflows/target-assessment/lib/family-complex-supplement.js +0 -36
  127. package/dist/workflows/target-assessment/lib/fda-label-safety.d.ts +0 -72
  128. package/dist/workflows/target-assessment/lib/fda-label-safety.js +0 -166
  129. package/dist/workflows/target-assessment/lib/heterodimer-filter.d.ts +0 -30
  130. package/dist/workflows/target-assessment/lib/heterodimer-filter.js +0 -44
  131. package/dist/workflows/target-assessment/lib/hpo-organ-map.d.ts +0 -34
  132. package/dist/workflows/target-assessment/lib/hpo-organ-map.js +0 -63
  133. package/dist/workflows/target-assessment/lib/impc-organ-map.d.ts +0 -19
  134. package/dist/workflows/target-assessment/lib/impc-organ-map.js +0 -39
  135. package/dist/workflows/target-assessment/lib/intended-polypharm-filter.d.ts +0 -4
  136. package/dist/workflows/target-assessment/lib/intended-polypharm-filter.js +0 -24
  137. package/dist/workflows/target-assessment/lib/llm-step.d.ts +0 -80
  138. package/dist/workflows/target-assessment/lib/llm-step.js +0 -101
  139. package/dist/workflows/target-assessment/lib/meddra-organ-map.d.ts +0 -40
  140. package/dist/workflows/target-assessment/lib/meddra-organ-map.js +0 -138
  141. package/dist/workflows/target-assessment/lib/recommendation-quality-gates.d.ts +0 -17
  142. package/dist/workflows/target-assessment/lib/recommendation-quality-gates.js +0 -99
  143. package/dist/workflows/target-assessment/lib/recommendation-sanitizer.d.ts +0 -2
  144. package/dist/workflows/target-assessment/lib/recommendation-sanitizer.js +0 -51
  145. package/dist/workflows/target-assessment/lib/regulatory-actions.d.ts +0 -25
  146. package/dist/workflows/target-assessment/lib/regulatory-actions.js +0 -176
  147. package/dist/workflows/target-assessment/lib/safety-corroboration.d.ts +0 -44
  148. package/dist/workflows/target-assessment/lib/safety-corroboration.js +0 -273
  149. package/dist/workflows/target-assessment/lib/structured-llm.d.ts +0 -61
  150. package/dist/workflows/target-assessment/lib/structured-llm.js +0 -102
  151. package/dist/workflows/target-assessment/lib/target-identity-filter.d.ts +0 -59
  152. package/dist/workflows/target-assessment/lib/target-identity-filter.js +0 -95
  153. package/dist/workflows/target-assessment/lib/therapeutic-programs.d.ts +0 -20
  154. package/dist/workflows/target-assessment/lib/therapeutic-programs.js +0 -68
  155. package/dist/workflows/target-assessment/metrics.d.ts +0 -16
  156. package/dist/workflows/target-assessment/metrics.js +0 -30
  157. package/dist/workflows/target-assessment/phase4-assemble.d.ts +0 -3182
  158. package/dist/workflows/target-assessment/phase4-assemble.js +0 -39
  159. package/dist/workflows/target-assessment/phase5-persist.d.ts +0 -59
  160. package/dist/workflows/target-assessment/phase5-persist.js +0 -349
  161. package/dist/workflows/target-assessment/progress-stream.d.ts +0 -75
  162. package/dist/workflows/target-assessment/progress-stream.js +0 -110
  163. package/dist/workflows/target-assessment/progress.d.ts +0 -39
  164. package/dist/workflows/target-assessment/progress.js +0 -77
  165. package/dist/workflows/target-assessment/schemas.d.ts +0 -970
  166. package/dist/workflows/target-assessment/schemas.js +0 -318
  167. package/dist/workflows/target-assessment/steps/collectors/pathways.d.ts +0 -15
  168. package/dist/workflows/target-assessment/steps/collectors/pathways.js +0 -58
  169. package/dist/workflows/target-assessment/steps/fanout/aes-for-one-class-drug-step.d.ts +0 -34
  170. package/dist/workflows/target-assessment/steps/fanout/aes-for-one-class-drug-step.js +0 -31
  171. package/dist/workflows/target-assessment/steps/fanout/aes-for-one-trial-step.d.ts +0 -57
  172. package/dist/workflows/target-assessment/steps/fanout/aes-for-one-trial-step.js +0 -54
  173. package/dist/workflows/target-assessment/steps/fanout/faers-for-one-modulator-step.d.ts +0 -35
  174. package/dist/workflows/target-assessment/steps/fanout/faers-for-one-modulator-step.js +0 -32
  175. package/dist/workflows/target-assessment/steps/fanout/index.d.ts +0 -14
  176. package/dist/workflows/target-assessment/steps/fanout/index.js +0 -10
  177. package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.d.ts +0 -29
  178. package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.js +0 -29
  179. package/dist/workflows/target-assessment/steps/phase2-aggregate.d.ts +0 -657
  180. package/dist/workflows/target-assessment/steps/phase2-aggregate.js +0 -34
  181. package/dist/workflows/target-assessment/steps/phase3-aggregate.d.ts +0 -806
  182. package/dist/workflows/target-assessment/steps/phase3-aggregate.js +0 -16
  183. package/dist/workflows/target-assessment/steps/synthesis/diagnostics.d.ts +0 -28
  184. package/dist/workflows/target-assessment/steps/synthesis/diagnostics.js +0 -27
  185. package/dist/workflows/target-assessment/sub-workflows/index.d.ts +0 -15
  186. package/dist/workflows/target-assessment/sub-workflows/index.js +0 -11
  187. package/dist/workflows/target-assessment/sub-workflows/per-class-drug-aes.d.ts +0 -41
  188. package/dist/workflows/target-assessment/sub-workflows/per-class-drug-aes.js +0 -12
  189. package/dist/workflows/target-assessment/sub-workflows/per-modulator-faers.d.ts +0 -41
  190. package/dist/workflows/target-assessment/sub-workflows/per-modulator-faers.js +0 -12
  191. package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.d.ts +0 -37
  192. package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.js +0 -12
  193. package/dist/workflows/target-assessment/sub-workflows/per-trial-aes.d.ts +0 -66
  194. package/dist/workflows/target-assessment/sub-workflows/per-trial-aes.js +0 -12
  195. package/dist/workflows/target-assessment/synthesis/index.d.ts +0 -607
  196. package/dist/workflows/target-assessment/synthesis/index.js +0 -354
  197. package/dist/workflows/target-assessment/synthesis-probes.d.ts +0 -56
  198. package/dist/workflows/target-assessment/synthesis-probes.js +0 -320
@@ -24,18 +24,14 @@ export interface Identity {
24
24
  readonly user: string;
25
25
  }
26
26
  /**
27
- * What the request operates on — a discriminated union owning its resource
28
- * coordinates (`scopeResource`) and the workload id (`scopeWorkloadId`) used
29
- * for attribution. `threadId` lives on the analysis variant only.
27
+ * What the request operates on. It owns its resource coordinates
28
+ * (`scopeResource`) and the workload id (`scopeWorkloadId`) used for
29
+ * attribution.
30
30
  */
31
31
  export type Scope = {
32
32
  readonly kind: "analysis";
33
33
  readonly analysisId: string;
34
34
  readonly threadId?: string;
35
- } | {
36
- readonly kind: "target-assessment";
37
- readonly targetAssessmentId: string;
38
- readonly billingContextId: string;
39
35
  };
40
36
  declare const CRED_BRAND: unique symbol;
41
37
  /**
@@ -64,15 +60,10 @@ export interface RunFrame {
64
60
  }
65
61
  /** Canonical resource coordinates a `Scope` resolves to. */
66
62
  export interface ResourceCoordinates {
67
- readonly resourceType: "analysis" | "billing_context";
63
+ readonly resourceType: "analysis";
68
64
  readonly resourceId: string;
69
65
  }
70
- /**
71
- * Derive the `{ resourceType, resourceId }` a scope resolves through.
72
- * Analysis → `{ "analysis", analysisId }`; target-assessment →
73
- * `{ "billing_context", billingContextId }` (TA resolves billing via the
74
- * billing-context discriminator until it is a first-class resource).
75
- */
66
+ /** Derive the `{ resourceType, resourceId }` a scope resolves through: `{ "analysis", analysisId }`. */
76
67
  export declare function scopeResource(scope: Scope): ResourceCoordinates;
77
68
  /** The value stamped into the workload tag — the workload id for this scope. */
78
69
  export declare function scopeWorkloadId(scope: Scope): string;
@@ -19,20 +19,13 @@
19
19
  * Neither bundle carries resolved billing headers — billing is resolved
20
20
  * lazily at the LLM call site (see `harness/billing/resolver.ts`).
21
21
  */
22
- /**
23
- * Derive the `{ resourceType, resourceId }` a scope resolves through.
24
- * Analysis → `{ "analysis", analysisId }`; target-assessment →
25
- * `{ "billing_context", billingContextId }` (TA resolves billing via the
26
- * billing-context discriminator until it is a first-class resource).
27
- */
22
+ /** Derive the `{ resourceType, resourceId }` a scope resolves through: `{ "analysis", analysisId }`. */
28
23
  export function scopeResource(scope) {
29
- return scope.kind === "analysis"
30
- ? { resourceType: "analysis", resourceId: scope.analysisId }
31
- : { resourceType: "billing_context", resourceId: scope.billingContextId };
24
+ return { resourceType: "analysis", resourceId: scope.analysisId };
32
25
  }
33
26
  /** The value stamped into the workload tag — the workload id for this scope. */
34
27
  export function scopeWorkloadId(scope) {
35
- return scope.kind === "analysis" ? scope.analysisId : scope.targetAssessmentId;
28
+ return scope.analysisId;
36
29
  }
37
30
  /**
38
31
  * Derive a child session for a sub-agent call — provenance only. Sets the
@@ -36,7 +36,7 @@ export interface LlmUsageRecord {
36
36
  readonly agentId: string;
37
37
  /** Provenance path from the root agent down to `agentId`. */
38
38
  readonly callPath: readonly string[];
39
- /** Scope ids as attribution: `analysisId` or `targetAssessmentId`. */
39
+ /** Scope ids as attribution: `analysisId`. */
40
40
  readonly scope: Scope;
41
41
  /** Present only for calls made inside a run (the session carries a `RunFrame`). */
42
42
  readonly runId?: string;
@@ -3,7 +3,7 @@
3
3
  * source of truth for the JSON envelope returned to the conversation
4
4
  * agent. Both Cortex and the frontend import from this module.
5
5
  *
6
- * Coverage discipline mirrors `target-dossier.ts`: every analogy carries a
6
+ * Coverage discipline: every analogy carries a
7
7
  * `coverage` discriminator. Only the extraction phase is allowed to throw;
8
8
  * search-phase failures surface via `coverage: "search_failed" |
9
9
  * "queried_no_data" | "not_loaded"`.
@@ -3,7 +3,7 @@
3
3
  * source of truth for the JSON envelope returned to the conversation
4
4
  * agent. Both Cortex and the frontend import from this module.
5
5
  *
6
- * Coverage discipline mirrors `target-dossier.ts`: every analogy carries a
6
+ * Coverage discipline: every analogy carries a
7
7
  * `coverage` discriminator. Only the extraction phase is allowed to throw;
8
8
  * search-phase failures surface via `coverage: "search_failed" |
9
9
  * "queried_no_data" | "not_loaded"`.
@@ -211,9 +211,8 @@ export interface StepSummaryPart {
211
211
  * absent or zeroed figure. Per-call granularity is the usage-record ledger's
212
212
  * job, never this part's.
213
213
  *
214
- * Scoped to analysis runs. Workflows without step parts (target assessment,
215
- * ephemeral runs, data profiling) reach the ledger through the recorder seam and
216
- * carry no usage part.
214
+ * Scoped to analysis runs. Workflows without step parts (ephemeral runs, data
215
+ * profiling) reach the ledger through the recorder seam and carry no usage part.
217
216
  */
218
217
  export interface StepUsagePart {
219
218
  type: "data-step-usage";
@@ -14,8 +14,4 @@ export { PART_REGISTRY, isTransient, isReconciling, isSidebarPart } from "./part
14
14
  export type { CortexChatPartType, PartDescriptor, PartEmitter, PartConsumer } from "./part-registry.js";
15
15
  export { AnalogyCoverageSchema, AnalogyReportSchema, AnalogyReportErrorSchema, AnalogicalReasonerOutputSchema } from "./analogy-report.js";
16
16
  export type { AnalogyCoverage, AnalogyReport, AnalogyReportError, AnalogicalReasonerOutput } from "./analogy-report.js";
17
- export { CoverageSchema, RowCoverageSchema, EntitySchema, ClaimSupportSchema, ClaimEvidenceSchema, LiabilityBulletSchema, LiabilitySummarySchema, TractabilitySchema, IndicationsSchema, DrugInteractionsSchema, ClinicalTrialAttributionSchema, ClinicalDevelopmentSchema, OrganRiskRowSchema, OffTargetRowSchema, OffTargetPanelSchema, RegulatoryActionRowSchema, SafetyFlagSchema, SafetyProfileSchema, OffTissueRowSchema, OffTissueRiskSchema, ReferenceBiologyShape, EvidenceConflictsSchema, EvidenceTimelineSchema, TranslationalChainSchema, AdditionalEvidenceSchema, DiscoveryTrialsSchema, QualityGateStatusSchema, QualityGatesSchema, DerivedSchema, DossierSchema, DossierBodySchema, isDossier, dossierJsonSchema, SECTION_BLURBS, TargetAssessmentPhaseSchema, TargetAssessmentProgressEventSchema, } from "./target-dossier.js";
18
- export type { Coverage, RowCoverage, Entity, EvidenceItem, ClaimSupport, ClaimEvidence, LiabilityBullet, LiabilitySummary, TractabilitySection, ClinicalTrialAttribution, ClinicalTrialRow, ClinicalDevelopment, FailedTrialRow, TrialOutcomeRow, OrganRiskRow, OffTargetRow, RegulatoryActionRow, SafetyFlag, SafetyProfile, OffTissueRow, QualityGateStatus, QualityGates, Derived, Dossier, DossierBody, SectionBlurbKey, TargetAssessmentPhase, TargetAssessmentProgressEvent, } from "./target-dossier.js";
19
- export { TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentListRowSchema, TargetAssessmentRowSchema, } from "./target-assessment-row.js";
20
- export type { TargetAssessmentStatus, TargetAssessmentError, TargetAssessmentListRow, TargetAssessmentRow } from "./target-assessment-row.js";
21
17
  export { buildReportSessionUrl, reportSessionResourceId } from "./content-url.js";
@@ -4,6 +4,4 @@ export { DATA_PROFILE_RUN_LITERAL } from "./data-profile.js";
4
4
  export { DIMENSION_CATEGORIES, DIMENSION_CATEGORY_IDS, DIMENSION_PROBE_IDS, DIMENSION_PROBES, GROUP_CATEGORIES, GROUP_CATEGORY_IDS, GROUP_ROLE_IDS, GROUP_ROLES, PROBE_OUTCOME_IDS, dimensionCategoryEntry, dimensionScope, groupCategoryEntry, } from "./profile-vocabulary.js";
5
5
  export { PART_REGISTRY, isTransient, isReconciling, isSidebarPart } from "./part-registry.js";
6
6
  export { AnalogyCoverageSchema, AnalogyReportSchema, AnalogyReportErrorSchema, AnalogicalReasonerOutputSchema } from "./analogy-report.js";
7
- export { CoverageSchema, RowCoverageSchema, EntitySchema, ClaimSupportSchema, ClaimEvidenceSchema, LiabilityBulletSchema, LiabilitySummarySchema, TractabilitySchema, IndicationsSchema, DrugInteractionsSchema, ClinicalTrialAttributionSchema, ClinicalDevelopmentSchema, OrganRiskRowSchema, OffTargetRowSchema, OffTargetPanelSchema, RegulatoryActionRowSchema, SafetyFlagSchema, SafetyProfileSchema, OffTissueRowSchema, OffTissueRiskSchema, ReferenceBiologyShape, EvidenceConflictsSchema, EvidenceTimelineSchema, TranslationalChainSchema, AdditionalEvidenceSchema, DiscoveryTrialsSchema, QualityGateStatusSchema, QualityGatesSchema, DerivedSchema, DossierSchema, DossierBodySchema, isDossier, dossierJsonSchema, SECTION_BLURBS, TargetAssessmentPhaseSchema, TargetAssessmentProgressEventSchema, } from "./target-dossier.js";
8
- export { TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentListRowSchema, TargetAssessmentRowSchema, } from "./target-assessment-row.js";
9
7
  export { buildReportSessionUrl, reportSessionResourceId } from "./content-url.js";
package/dist/index.d.ts CHANGED
@@ -156,13 +156,6 @@ export { registerExecuteAnalysis } from "./workflows/execute-analysis.js";
156
156
  export type { ExecuteAnalysisDeps, ExecuteAnalysisInput, ExecuteAnalysisResult, RunObservation, RunStepObservation, StepRuntimeStatus, } from "./workflows/execute-analysis.js";
157
157
  export { registerSandboxStep } from "./workflows/sandbox-step.js";
158
158
  export type { SandboxStepDeps, SandboxStepInput, SandboxStepResult, SandboxAgentBuildContext } from "./workflows/sandbox-step.js";
159
- export { DEFAULT_CLAIM_INVESTIGATION_CONFIG } from "./workflows/target-assessment/investigation/index.js";
160
- export type { ClaimInvestigationConfig } from "./workflows/target-assessment/investigation/index.js";
161
- export { insertAssessment, getAssessment, updateProgress, listAssessmentsByOrg } from "./state/target-assessments.js";
162
- export type { InsertAssessmentInput, ListAssessmentsOptions } from "./state/target-assessments.js";
163
- export type { TargetAssessmentRow, TargetAssessmentListRow, TargetAssessmentStatus, TargetAssessmentError } from "./state/target-assessments.js";
164
- export { createTargetAssessmentProgressStream } from "./workflows/target-assessment/progress-stream.js";
165
- export type { TargetAssessmentProgressStream, TargetAssessmentProgressStreamDeps, TargetAssessmentProgressHandler, TargetAssessmentProgressSubscribeOptions, } from "./workflows/target-assessment/progress-stream.js";
166
159
  export { createRunEventStream } from "./execution/run-event-stream.js";
167
160
  export type { RunEventStream, RunEventStreamDeps, RunEventSubscribeOptions, RunEventPartHandler } from "./execution/run-event-stream.js";
168
161
  export { createSandboxAgents, SANDBOX_AGENT_META } from "./agents/sandbox/index.js";
package/dist/index.js CHANGED
@@ -271,27 +271,6 @@ export { ExecEventMessageSchema } from "./sandbox/types.js";
271
271
  // these, but an embedder running only the run engine registers them directly.
272
272
  export { registerExecuteAnalysis } from "./workflows/execute-analysis.js";
273
273
  export { registerSandboxStep } from "./workflows/sandbox-step.js";
274
- // Target assessment — the bounds its claim-investigation phase runs under. An
275
- // embedder wiring `executeTargetAssessment` sets these at its composition root;
276
- // the dossier reports whichever values were in force.
277
- export { DEFAULT_CLAIM_INVESTIGATION_CONFIG } from "./workflows/target-assessment/investigation/index.js";
278
- // The row surface of `cortex_target_assessments`: the intake write an embedder's
279
- // trigger route makes, the two reads its detail and list routes make, and the
280
- // progress write. The row types ride with them — `getAssessment` and
281
- // `listAssessmentsByOrg` hand back values an embedder cannot hold without naming,
282
- // and `TargetAssessmentStatus` is what a host switches on to render one. The
283
- // terminal writers (`setDossier`, `markFailed`, `markAssessmentSuspended`,
284
- // `markAssessmentRunning`, `softDeleteAssessment`) stay off the front door: the
285
- // workflow's own terminal path owns them, and an embedder calling one races the
286
- // state the workflow is about to write.
287
- export { insertAssessment, getAssessment, updateProgress, listAssessmentsByOrg } from "./state/target-assessments.js";
288
- // The read side of a target assessment's progress stream. `emitProgress` writes
289
- // one part per phase and the workflow owns that write; this is the only way to
290
- // read it back without reaching for the durability engine, which is exactly what
291
- // an embedder rendering a progress bar would otherwise have to do. One stream per
292
- // assessment (`workflowID === assessmentId`), so it needs no pool — unlike the
293
- // run-event seam below, which fans in a parent and its children.
294
- export { createTargetAssessmentProgressStream } from "./workflows/target-assessment/progress-stream.js";
295
274
  // Run-event read seam — the fine-grained durable channel beside `observeRun`.
296
275
  // The two are a deliberate pair, not a duplication: `observeRun` is the coarse,
297
276
  // in-process run/step snapshot a workflow hands its host synchronously, and it
@@ -35,7 +35,7 @@ import type { StepExecutionStatus } from "../state/schema.js";
35
35
  /** Terminal status of a run. A budget pause records as `canceled`, the same as the run ledger. */
36
36
  export type RunOutcome = "completed" | "partial" | "failed" | "canceled";
37
37
  /** The workflow family a run belongs to. */
38
- export type RunWorkflow = "analysis" | "target_assessment" | "data_profile";
38
+ export type RunWorkflow = "analysis" | "data_profile";
39
39
  /** Terminal status of an executed step. A blocker is a failure to deliver, so `blocked` maps here to `failed`. */
40
40
  export type StepOutcome = "completed" | "failed" | "canceled";
41
41
  /**
@@ -48,8 +48,6 @@ export declare const ATTR_INFLEXA_TOOL_USE_ID = "inflexa.tool_use_id";
48
48
  export declare const ATTR_INFLEXA_EXEC_ID = "inflexa.exec_id";
49
49
  /** The 1-based attempt counter of a sandbox poll, pull, or liveness-probe step. */
50
50
  export declare const ATTR_INFLEXA_ATTEMPT = "inflexa.attempt";
51
- /** The per-item key (a ChEMBL or NCT id) of a target-assessment fan-out step. */
52
- export declare const ATTR_INFLEXA_FANOUT_KEY = "inflexa.fanout_key";
53
51
  /**
54
52
  * Rename the DBOS span of the step that is running to `name` and put its id
55
53
  * in `attributes`. Call it as the first statement of a step body whose DBOS
@@ -71,8 +71,6 @@ export const ATTR_INFLEXA_TOOL_USE_ID = "inflexa.tool_use_id";
71
71
  export const ATTR_INFLEXA_EXEC_ID = "inflexa.exec_id";
72
72
  /** The 1-based attempt counter of a sandbox poll, pull, or liveness-probe step. */
73
73
  export const ATTR_INFLEXA_ATTEMPT = "inflexa.attempt";
74
- /** The per-item key (a ChEMBL or NCT id) of a target-assessment fan-out step. */
75
- export const ATTR_INFLEXA_FANOUT_KEY = "inflexa.fanout_key";
76
74
  /**
77
75
  * Rename the DBOS span of the step that is running to `name` and put its id
78
76
  * in `attributes`. Call it as the first statement of a step body whose DBOS
@@ -3,6 +3,10 @@
3
3
  * `runAgent`, and `execute_tool` around each tool call that it dispatches. The AI
4
4
  * SDK traces the model calls (`providers/ai-sdk.ts`). It never sees the loop or
5
5
  * the tools, because the harness runs both itself.
6
+ *
7
+ * An `execute_tool` span is ERROR when our code fails the call. A failure that a
8
+ * tool returns as data, for example a sandbox command that exits non-zero, is
9
+ * normal iteration of the agent, and its span stays OK.
6
10
  */
7
11
  import type { ToolCallPart } from "ai";
8
12
  import type { AgentSession } from "../auth/types.js";
@@ -17,4 +21,14 @@ interface AgentRun {
17
21
  export declare function traceAgentRun<T extends AgentRun>(agentName: string, session: AgentSession, run: () => Promise<T>): Promise<T>;
18
22
  /** Run one tool call under an `execute_tool` span that records how the call ended. */
19
23
  export declare function traceToolCall<T>(call: Pick<ToolCallPart, "toolName" | "toolCallId">, run: () => Promise<T>, outcomeOf: (value: T) => ToolOutcome): Promise<T>;
24
+ /**
25
+ * Record an exception that a tool threw on the active `execute_tool` span.
26
+ * `error.type` is the code of the error when it has one, else its name.
27
+ */
28
+ export declare function recordToolException(err: Error): void;
29
+ /**
30
+ * Label a tool failure that is not an exception on the active `execute_tool`
31
+ * span. `message` is text that our tool wrote, never text from the model.
32
+ */
33
+ export declare function labelToolFailure(type: string, message?: string): void;
20
34
  export {};
@@ -3,6 +3,10 @@
3
3
  * `runAgent`, and `execute_tool` around each tool call that it dispatches. The AI
4
4
  * SDK traces the model calls (`providers/ai-sdk.ts`). It never sees the loop or
5
5
  * the tools, because the harness runs both itself.
6
+ *
7
+ * An `execute_tool` span is ERROR when our code fails the call. A failure that a
8
+ * tool returns as data, for example a sandbox command that exits non-zero, is
9
+ * normal iteration of the agent, and its span stays OK.
6
10
  */
7
11
  import { SpanStatusCode, trace } from "@opentelemetry/api";
8
12
  /** Run one agent loop under an `invoke_agent` span. */
@@ -26,6 +30,37 @@ export function traceToolCall(call, run, outcomeOf) {
26
30
  return value;
27
31
  });
28
32
  }
33
+ /** The cap of `inflexa.tool.error`, in characters. */
34
+ const TOOL_ERROR_MAX_CHARS = 1_000;
35
+ /**
36
+ * Record an exception that a tool threw on the active `execute_tool` span.
37
+ * `error.type` is the code of the error when it has one, else its name.
38
+ */
39
+ export function recordToolException(err) {
40
+ const span = trace.getActiveSpan();
41
+ if (span === undefined)
42
+ return;
43
+ span.recordException(err);
44
+ span.setAttribute("error.type", errorTypeOf(err));
45
+ }
46
+ /**
47
+ * Label a tool failure that is not an exception on the active `execute_tool`
48
+ * span. `message` is text that our tool wrote, never text from the model.
49
+ */
50
+ export function labelToolFailure(type, message) {
51
+ const span = trace.getActiveSpan();
52
+ if (span === undefined)
53
+ return;
54
+ span.setAttribute("error.type", type);
55
+ if (message !== undefined)
56
+ span.setAttribute("inflexa.tool.error", message.slice(0, TOOL_ERROR_MAX_CHARS));
57
+ }
58
+ function errorTypeOf(err) {
59
+ const code = "code" in err ? err.code : undefined;
60
+ if ((typeof code === "string" && code !== "") || typeof code === "number")
61
+ return String(code);
62
+ return err.name === "" ? "_OTHER" : err.name;
63
+ }
29
64
  function withSpan(name, attributes, run) {
30
65
  return trace.getTracer("@inflexa-ai/harness").startActiveSpan(name, { attributes }, async (span) => {
31
66
  try {
@@ -70,7 +70,7 @@ export interface RunAgentOptions {
70
70
  *
71
71
  * The policy lives here, on the run, rather than on the provider, precisely
72
72
  * so it applies to loops and *not* to the one-shot LLM calls made elsewhere
73
- * (report generation, target-assessment steps): those would pay the
73
+ * (report generation): those would pay the
74
74
  * cache-write premium for a cache nothing ever reads back.
75
75
  */
76
76
  readonly promptCache?: PromptCachePolicy;
@@ -4,6 +4,7 @@ import { createNoopUsageRecorder } from "../billing/noop-usage-recorder.js";
4
4
  import { stripNulCharacters } from "../input-sanitization.js";
5
5
  import { createNoopLogger } from "../lib/console-logger.js";
6
6
  import { ATTR_INFLEXA_TOOL_USE_ID, stableSpan } from "../lib/otel-spans.js";
7
+ import { ResultError } from "../lib/result.js";
7
8
  import { hintForZodIssue, repairToolInput } from "../lib/zod-issues.js";
8
9
  import { markInterruptedMessage, syntheticUserMessage } from "../memory/ai-sdk-message-storage.js";
9
10
  import { stripUnansweredToolCalls } from "../memory/tool-call-integrity.js";
@@ -13,7 +14,7 @@ import { DEFAULT_REASONING } from "../providers/reasoning.js";
13
14
  import { resultStep } from "./run-step.js";
14
15
  import { AskRejectedError, UnavailableAsk } from "../tools/approval/contract.js";
15
16
  import { isToolError, readToolResultImages } from "../tools/define-tool.js";
16
- import { traceAgentRun, traceToolCall } from "./genai-spans.js";
17
+ import { labelToolFailure, recordToolException, traceAgentRun, traceToolCall } from "./genai-spans.js";
17
18
  import { addChatUsage, hasReportedUsage, recordAgentRun } from "./metrics.js";
18
19
  import { computeDetail, computeResultDetail } from "./tool-detail.js";
19
20
  import { toolOutcomeForOutputType } from "./tool-outcome.js";
@@ -602,6 +603,7 @@ function readDispatchedStep(settled) {
602
603
  async function dispatchTool(tu, toolsById, ctx, isFatalLoopError, encoding) {
603
604
  const tool = toolsById.get(tu.toolName);
604
605
  if (tool === undefined) {
606
+ labelToolFailure("unknown_tool");
605
607
  return { result: errorResult(tu, `unknown tool: ${tu.toolName}`) };
606
608
  }
607
609
  const parsed = tool.inputSchema.safeParse(tu.input);
@@ -615,13 +617,17 @@ async function dispatchTool(tu, toolsById, ctx, isFatalLoopError, encoding) {
615
617
  const repaired = repairedInput === undefined ? undefined : tool.inputSchema.safeParse(repairedInput);
616
618
  if (repaired?.success === true)
617
619
  return execute(tu, tool, repaired.data, ctx, isFatalLoopError, encoding);
620
+ // The Zod text can quote the input, thus the span gets no message.
621
+ labelToolFailure("validation");
618
622
  return { result: errorResult(tu, `input validation failed: ${formatZodIssues(parsed.error, tu.input)}`) };
619
623
  }
620
624
  async function execute(tu, tool, input, ctx, isFatalLoopError, encoding) {
621
625
  try {
622
626
  const output = await tool.execute(input, ctx);
623
- if (output.isErr())
627
+ if (output.isErr()) {
628
+ markToolFailure(tu, tool, output.error, encoding.log);
624
629
  return { result: errorResult(tu, toolErrorContent(output.error)) };
630
+ }
625
631
  // The one place a result description runs: the ok value in hand, the
626
632
  // input already validated, and the guard inside the compute.
627
633
  const detail = computeResultDetail(tool, input, output.value, encoding.log);
@@ -633,9 +639,35 @@ async function execute(tu, tool, input, ctx, isFatalLoopError, encoding) {
633
639
  throw err;
634
640
  if (isAskRejected(err))
635
641
  return { result: deniedResult(tu, err.feedback) };
642
+ markToolFailure(tu, tool, err, encoding.log);
636
643
  return { result: errorResult(tu, toolErrorContent(err)) };
637
644
  }
638
645
  }
646
+ /**
647
+ * Label the span of a tool call that our tool code failed. A `ToolError` is a
648
+ * failure that the tool modeled, thus its own text is the account, with no
649
+ * exception and no log. Any other `Error` is a fault that the tool did not
650
+ * model: the span records the exception, and the log gets one warn.
651
+ */
652
+ function markToolFailure(tu, tool, failure, log) {
653
+ const toolError = modeledToolError(failure);
654
+ if (toolError !== undefined) {
655
+ labelToolFailure("tool_error", toolError.error);
656
+ }
657
+ else if (failure instanceof Error) {
658
+ recordToolException(failure);
659
+ log.warn("tool call threw", { tool: tool.id, toolCallId: tu.toolCallId, ...log.errorFields(failure) });
660
+ }
661
+ else {
662
+ labelToolFailure("_OTHER");
663
+ }
664
+ }
665
+ /** The `ToolError` of a failure: the value itself, or the value that `unwrapOrThrow` wrapped in a `ResultError`. */
666
+ function modeledToolError(failure) {
667
+ if (isToolError(failure))
668
+ return failure;
669
+ return failure instanceof ResultError && isToolError(failure.value) ? failure.value : undefined;
670
+ }
639
671
  /**
640
672
  * Normalize a tool's return value to plain JSON, stripping NUL from every string
641
673
  * it holds ({@link stripNulCharacters}). The reviver sees values, not keys — a
@@ -700,8 +732,9 @@ function successResult(toolCall, value, encoding) {
700
732
  // is the six-character escape \u0000 — legitimate JSON text, and no longer
701
733
  // distinguishable from an error that happens to quote that escape.
702
734
  function toolErrorContent(value) {
703
- if (isToolError(value)) {
704
- return JSON.stringify({ error: stripNulCharacters(value.error), retryable: value.retryable });
735
+ const toolError = modeledToolError(value);
736
+ if (toolError !== undefined) {
737
+ return JSON.stringify({ error: stripNulCharacters(toolError.error), retryable: toolError.retryable });
705
738
  }
706
739
  const { retryable } = classifyProviderError(value);
707
740
  const error = stripNulCharacters(value instanceof Error ? value.message : String(value));
@@ -25,7 +25,6 @@ import { type AcquireEyes } from "../lib/eyes.js";
25
25
  import type { ThreadType } from "../memory/thread-store.js";
26
26
  import { type ExecuteAnalysisDeps, type ExecuteAnalysisInput, type ExecuteAnalysisResult } from "../workflows/execute-analysis.js";
27
27
  import { type SandboxStepDeps, type SandboxStepInput, type SandboxStepResult } from "../workflows/sandbox-step.js";
28
- import { type ExecuteTargetAssessmentDeps, type ExecuteTargetAssessmentInput, type ExecuteTargetAssessmentResult } from "../workflows/execute-target-assessment.js";
29
28
  import { type DataProfileDeps, type DataProfileWorkflowInput } from "../tasks/data-profile.js";
30
29
  import { type ExtractValuesResult, type ExtractValuesWorkflowInput } from "../tasks/extract-values.js";
31
30
  import type { DeriveTableExecInput } from "../tools/report-session/derive-table.js";
@@ -54,14 +53,12 @@ export type SandboxStepCallable = (input: SandboxStepInput) => Promise<SandboxSt
54
53
  export interface CoreWorkflowDeps {
55
54
  readonly sandboxStep: Omit<SandboxStepDeps, "usageRecorder" | "citationResolver">;
56
55
  readonly buildExecuteAnalysis: (sandboxStep: SandboxStepCallable) => Omit<ExecuteAnalysisDeps, "usageRecorder" | "citationResolver">;
57
- readonly executeTargetAssessment: Omit<ExecuteTargetAssessmentDeps, "usageRecorder">;
58
56
  readonly dataProfile: Omit<DataProfileDeps, "usageRecorder">;
59
57
  }
60
58
  /** The registered, callable workflow handles. */
61
59
  export interface RegisteredWorkflows {
62
60
  readonly executeAnalysis: (input: ExecuteAnalysisInput) => Promise<ExecuteAnalysisResult>;
63
61
  readonly sandboxStep: SandboxStepCallable;
64
- readonly executeTargetAssessment: (input: ExecuteTargetAssessmentInput) => Promise<ExecuteTargetAssessmentResult>;
65
62
  readonly dataProfile: (input: DataProfileWorkflowInput) => Promise<void>;
66
63
  readonly extractValues: (input: ExtractValuesWorkflowInput) => Promise<ExtractValuesResult>;
67
64
  readonly deriveTableExec: (input: DeriveTableExecInput) => Promise<ExecResult>;
@@ -23,7 +23,6 @@ import { hasBrowserUrl } from "../lib/chrome.js";
23
23
  import { createStaticEyes } from "../lib/eyes.js";
24
24
  import { registerExecuteAnalysis } from "../workflows/execute-analysis.js";
25
25
  import { registerSandboxStep } from "../workflows/sandbox-step.js";
26
- import { registerExecuteTargetAssessment, } from "../workflows/execute-target-assessment.js";
27
26
  import { registerDataProfileWorkflow } from "../tasks/data-profile.js";
28
27
  import { bindExtractionTrigger, createExtractionArm, registerExtractValuesWorkflow, } from "../tasks/extract-values.js";
29
28
  import { registerDeriveTableExecWorkflow, triggerDeriveTableExec } from "../tasks/derive-table-exec.js";
@@ -86,7 +85,6 @@ export function assembleCoreRuntime(deps) {
86
85
  });
87
86
  const sandboxStep = registerSandboxStep({ ...wf.sandboxStep, citationResolver, usageRecorder });
88
87
  const executeAnalysis = registerExecuteAnalysis({ ...wf.buildExecuteAnalysis(sandboxStep), citationResolver, usageRecorder });
89
- const executeTargetAssessment = registerExecuteTargetAssessment({ ...wf.executeTargetAssessment, usageRecorder });
90
88
  const dataProfile = registerDataProfileWorkflow({ ...wf.dataProfile, usageRecorder });
91
89
  // The extraction workflow shares the profile's sandbox and authorization rails, thus it draws the same
92
90
  // three seams from the profile deps. The report resolver factory binds the extraction arm over this
@@ -196,7 +194,6 @@ export function assembleCoreRuntime(deps) {
196
194
  workflows: {
197
195
  executeAnalysis,
198
196
  sandboxStep,
199
- executeTargetAssessment,
200
197
  dataProfile,
201
198
  extractValues,
202
199
  deriveTableExec,
@@ -27,5 +27,3 @@ export { createAnalysisPurge } from "./purge-analysis.js";
27
27
  export type { AnalysisPurge, AnalysisPurgeDeps, AnalysisPurgeOutcome } from "./purge-analysis.js";
28
28
  export { AnalysisStateRowSchema, ArtifactRole, ArtifactRowSchema, RunStatus, StepExecutionStatus, SynthesisStatus, CortexRunRowSchema, StepExecutionRowSchema, CortexPlanRowSchema, } from "./schema.js";
29
29
  export type { AnalysisStateRow, ArtifactRow, CortexRunRow, StepExecutionRow, CortexPlanRow } from "./schema.js";
30
- export { insertAssessment, updateProgress, setDossier, markFailed, getAssessment, listAssessmentsByOrg, softDeleteAssessment, TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentRowSchema, } from "./target-assessments.js";
31
- export type { TargetAssessmentStatus, TargetAssessmentRow, TargetAssessmentError, InsertAssessmentInput, ListAssessmentsOptions, } from "./target-assessments.js";
@@ -20,4 +20,3 @@ export { queryRunCountsByAnalyses, queryThreadCountsByAnalyses, queryDataProfile
20
20
  // alone, with the workflow ledger behind an injected seam.
21
21
  export { createAnalysisPurge } from "./purge-analysis.js";
22
22
  export { AnalysisStateRowSchema, ArtifactRole, ArtifactRowSchema, RunStatus, StepExecutionStatus, SynthesisStatus, CortexRunRowSchema, StepExecutionRowSchema, CortexPlanRowSchema, } from "./schema.js";
23
- export { insertAssessment, updateProgress, setDossier, markFailed, getAssessment, listAssessmentsByOrg, softDeleteAssessment, TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentRowSchema, } from "./target-assessments.js";
@@ -199,65 +199,6 @@ CREATE TABLE IF NOT EXISTS cortex_report_session_state (
199
199
  CREATE INDEX IF NOT EXISTS idx_cortex_report_session_state_analysis
200
200
  ON cortex_report_session_state(analysis_id);
201
201
 
202
- -- Target assessments — organization-scoped, snapshot-style target dossiers.
203
- -- Independent of analyses, projects, runs, and chat threads. The full
204
- -- dossier is persisted as JSONB on the row, no separate artifacts table.
205
- CREATE TABLE IF NOT EXISTS cortex_target_assessments (
206
- id UUID PRIMARY KEY,
207
- organization_id TEXT NOT NULL,
208
- target_id TEXT NOT NULL,
209
- target_label TEXT NOT NULL,
210
- goal TEXT,
211
- status TEXT NOT NULL,
212
- progress TEXT,
213
- dossier JSONB,
214
- billing_context_id TEXT NOT NULL,
215
- error JSONB,
216
- requested_by TEXT NOT NULL,
217
- workflow_run_id TEXT,
218
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
219
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
220
- completed_at TIMESTAMPTZ
221
- );
222
-
223
- ALTER TABLE cortex_target_assessments
224
- ADD COLUMN IF NOT EXISTS workflow_run_id TEXT;
225
-
226
- -- DBOS workflow id for the executeTargetAssessment workflow. For DBOS-shaped
227
- -- rows, workflow_id = assessmentId (the workflowID passed to DBOS.startWorkflow).
228
- -- Nullable so older rows tolerate NULL -- new rows always write
229
- -- workflow_id alongside the row insert.
230
- ALTER TABLE cortex_target_assessments
231
- ADD COLUMN IF NOT EXISTS workflow_id TEXT;
232
-
233
- CREATE INDEX IF NOT EXISTS idx_cortex_target_assessments_workflow_id
234
- ON cortex_target_assessments(workflow_id);
235
-
236
- CREATE INDEX IF NOT EXISTS idx_cortex_target_assessments_org_created
237
- ON cortex_target_assessments(organization_id, created_at DESC);
238
-
239
- CREATE INDEX IF NOT EXISTS idx_cortex_target_assessments_org_target_created
240
- ON cortex_target_assessments(organization_id, target_id, created_at DESC);
241
-
242
- -- Per-row clinical-consequence annotations for off-target hits, produced by
243
- -- a focused LLM annotator. Cached by (primary_target_gene, off_target_key)
244
- -- so repeat assessments of the same target reuse prior work and avoid
245
- -- per-run LLM cost.
246
- --
247
- -- off_target_key is the ChEMBL ID when present, else the (trimmed,
248
- -- lowercased) off-target name. Composite primary key prevents duplicate
249
- -- annotations.
250
- CREATE TABLE IF NOT EXISTS cortex_off_target_annotations (
251
- primary_target_gene TEXT NOT NULL,
252
- off_target_key TEXT NOT NULL,
253
- off_target_name TEXT NOT NULL,
254
- clinical_consequence TEXT NOT NULL,
255
- provenance TEXT,
256
- model TEXT NOT NULL,
257
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
258
- PRIMARY KEY (primary_target_gene, off_target_key)
259
- );
260
-
261
202
  -- Regulatory guidance corpus — pre-indexed FDA CDER, FDA CBER, and ICH
262
203
  -- guidance documents. Written/refreshed via tasks/refresh-regulatory-corpus.ts
263
204
  -- and searched (top-K cosine) via lib/regulatory-corpus.ts. No synthesis tool
@@ -684,7 +625,7 @@ export async function initCortexState(pool, injected) {
684
625
  }
685
626
  // No boot-time orphan sweep on cortex_runs / cortex_step_executions.
686
627
  // Every running row is backed by a DBOS workflow (executeAnalysis,
687
- // executeTargetAssessment, resume entry); DBOS recovery is the
628
+ // resume entry); DBOS recovery is the
688
629
  // substitute — each pod has a stable executorID (StatefulSet pod name)
689
630
  // and runs `recoverPendingWorkflows` for its own ID at launch (ADR
690
631
  // 0012). The workflow body owns the terminal transition on cortex_runs;
@@ -28,8 +28,7 @@
28
28
  *
29
29
  * What it does not reach, so that absent coverage is never read as delivered:
30
30
  * scheduled operational workflows (they belong to no analysis and accumulate
31
- * independently of any purge), target assessments and their annotations (a
32
- * separate top-level entity), the shared regulatory corpus, `messages` rows whose
31
+ * independently of any purge), the shared regulatory corpus, `messages` rows whose
33
32
  * thread row is already gone (nothing attributes them to an analysis), and
34
33
  * workspace files on disk (the embedder owns their disposal).
35
34
  */
@@ -28,8 +28,7 @@
28
28
  *
29
29
  * What it does not reach, so that absent coverage is never read as delivered:
30
30
  * scheduled operational workflows (they belong to no analysis and accumulate
31
- * independently of any purge), target assessments and their annotations (a
32
- * separate top-level entity), the shared regulatory corpus, `messages` rows whose
31
+ * independently of any purge), the shared regulatory corpus, `messages` rows whose
33
32
  * thread row is already gone (nothing attributes them to an analysis), and
34
33
  * workspace files on disk (the embedder owns their disposal).
35
34
  */
@@ -79,7 +79,7 @@ export async function maybeKickOffRegulatoryCorpusRefresh(deps) {
79
79
  return "skipped-fresh";
80
80
  }
81
81
  // Corpus is stale — resolve the maintenance embedder. System-scoped
82
- // maintenance work has no analysis/target-assessment to bill against, so
82
+ // maintenance work has no analysis to bill against, so
83
83
  // we route directly to api.openai.com on a dedicated key. Never the
84
84
  // billing-gateway-routed workspace embedder, which would emit unattributed calls
85
85
  // and flood the boot log via `billing-fetch-patch`.
@@ -12,9 +12,7 @@
12
12
  *
13
13
  * No source caps its own output: Bgee returns every annotated tissue per
14
14
  * species, IMPC every significant phenotype term, and Monarch every curated
15
- * HPO annotation, so each half is trimmed here rather than in the clients — the
16
- * target-assessment collectors read the same clients and legitimately want full
17
- * fidelity for the dossier.
15
+ * HPO annotation, so each half is trimmed here rather than in the clients.
18
16
  */
19
17
  import { type SupportedSpecies, type TissueRow } from "../lib/bgee-client.js";
20
18
  import { type MpTerm, type ViabilityCall, type ViabilityCategory } from "../lib/impc-client.js";
@@ -12,9 +12,7 @@
12
12
  *
13
13
  * No source caps its own output: Bgee returns every annotated tissue per
14
14
  * species, IMPC every significant phenotype term, and Monarch every curated
15
- * HPO annotation, so each half is trimmed here rather than in the clients — the
16
- * target-assessment collectors read the same clients and legitimately want full
17
- * fidelity for the dossier.
15
+ * HPO annotation, so each half is trimmed here rather than in the clients.
18
16
  */
19
17
  import { ok } from "neverthrow";
20
18
  import { z } from "zod";
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Pure async client functions for the ChEMBL REST API.
3
3
  *
4
- * Used directly by target-assessment workflow steps and by tool wrappers.
4
+ * Used by tool wrappers.
5
5
  *
6
6
  * Absence policy: ChEMBL sends an explicit `null` for an absent value, and it
7
7
  * never omits the key. Thus a maybe-absent field carries `.nullable()`, not
@@ -234,8 +234,5 @@ export declare function getMoleculeInChIKey(moleculeChemblId: string): Promise<s
234
234
  * Resolve a drug's mechanism-of-action targets to UniProt accessions.
235
235
  * Returns deduplicated accessions across all mechanism rows.
236
236
  * Empty array on no mechanism, missing target, or non-protein target.
237
- *
238
- * Used by target-identity-filter to detect off-target trials (e.g., a
239
- * trial of a CALCRL drug being surfaced under a CALCR assessment).
240
237
  */
241
238
  export declare function getDrugPrimaryTargetUniprots(moleculeChemblId: string): Promise<string[]>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Pure async client functions for the ChEMBL REST API.
3
3
  *
4
- * Used directly by target-assessment workflow steps and by tool wrappers.
4
+ * Used by tool wrappers.
5
5
  *
6
6
  * Absence policy: ChEMBL sends an explicit `null` for an absent value, and it
7
7
  * never omits the key. Thus a maybe-absent field carries `.nullable()`, not
@@ -673,9 +673,6 @@ export async function getMoleculeInChIKey(moleculeChemblId) {
673
673
  * Resolve a drug's mechanism-of-action targets to UniProt accessions.
674
674
  * Returns deduplicated accessions across all mechanism rows.
675
675
  * Empty array on no mechanism, missing target, or non-protein target.
676
- *
677
- * Used by target-identity-filter to detect off-target trials (e.g., a
678
- * trial of a CALCRL drug being surfaced under a CALCR assessment).
679
676
  */
680
677
  export async function getDrugPrimaryTargetUniprots(moleculeChemblId) {
681
678
  const mechRes = await apiFetchValidated(`${CHEMBL_BASE}/mechanism.json?molecule_chembl_id=${encodeURIComponent(moleculeChemblId)}&limit=20`, MechanismsResponseSchema, { headers: HEADERS });
@@ -29,7 +29,7 @@ export declare function inferTherapeuticArea(indicationLabels: string[]): string
29
29
  * `source` field discloses whether the fallback was used.
30
30
  */
31
31
  export declare function getBenchmarks(therapeuticArea: string | null): BenchmarkResult;
32
- /** Return the dataset's metadata for transparency in the dossier. */
32
+ /** Return the dataset's metadata for transparency. */
33
33
  export declare function getDatasetAttribution(): {
34
34
  data_version: string;
35
35
  data_window: string;