- MultiVerS: cross-source label aggregation (confidence-weighted tally -> supported/refuted/mixed/insufficient) feeding the contradiction atlas (papertrail_aggregate.py -> lib/scieval/crossSourceAggregate.ts, /api/scieval/aggregate) - open_deep_research: deterministic iterative evidence-sufficiency loop (bounded MAX_ROUNDS=3, widen actions) (papertrail_iterative.py -> lib/research/iterativeLoop.ts, /api/deep-research/iterative) - pytrials: eligibility parsing + design-credibility priors (randomized/blinding/enrollment/phase -> tier + weight) (papertrail_design.py -> lib/sources/trialDesign.ts, /api/trials/design) ALL 17 vendored OSS engines now carry a PaperTrail-native papertrail_* specialization + PAPERTRAIL.md, mirrored by a native TS module + public API. Deterministic numeric paths; tsc + build green.
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { z } from "zod";
|
|
|
|
// Zod schema for the PUBLIC /api/trials/design request body. Never trust raw JSON:
|
|
// this validates the boundary and hands the deterministic engine typed, normalized
|
|
// inputs. No LLM is involved anywhere in this feature — this is a structural schema.
|
|
//
|
|
// A request must carry AT LEAST ONE of: an `eligibility` text blob to split into
|
|
// gates, or a `design` object to score for credibility. An empty {} probe is rejected
|
|
// so the route always has something to compute.
|
|
|
|
const DesignSchema = z.object({
|
|
randomized: z.boolean().nullish(),
|
|
// Free-text masking descriptor from the registry (e.g. "Double (Participant, Investigator)").
|
|
blinding: z.string().trim().max(200).nullish(),
|
|
enrollment: z.number().finite().nullish(),
|
|
// Phase token (e.g. "PHASE3", "PHASE1/PHASE2"); normalized deterministically downstream.
|
|
phase: z.string().trim().max(64).nullish(),
|
|
});
|
|
|
|
export const TrialDesignRequestSchema = z
|
|
.object({
|
|
eligibility: z.string().max(50_000).optional(),
|
|
design: DesignSchema.optional(),
|
|
})
|
|
.refine((v) => v.eligibility !== undefined || v.design !== undefined, {
|
|
message: "Provide `eligibility` text and/or a `design` object.",
|
|
path: ["eligibility"],
|
|
});
|
|
|
|
export type TrialDesignRequest = z.infer<typeof TrialDesignRequestSchema>;
|