import { OBSERVED_DIAGNOSTIC_CONTRACT_VERSION, MODEL_DIAGNOSTIC_LIMITS } from "@actuarial-ts/core"; import type { DataOperation } from "./dataCapabilities.js"; import { observedDiagnosticRequestSchema, assessObservedDiagnosticEligibilityFromInput } from "./observedDiagnosticsContracts.js"; /** Discovery and execution share source validation and applicability rules; no reserve fit is needed. */ export function observedDiagnosticCapabilities(): readonly DataOperation[] { return [{ id: "diagnostics.observed", kind: "diagnostic", native: "runObservedDiagnostics", nativePackage: "@actuarial-ts/core", entry: "runObservedDiagnosticsFromInput", validator: "assessObservedDiagnosticEligibilityFromInput", parser: "parseObservedDiagnosticRequest", schemaName: "observedDiagnosticRequestSchema", schema: observedDiagnosticRequestSchema, input: "ObservedDiagnosticRequest", output: "ObservedDiagnosticResult", contract: OBSERVED_DIAGNOSTIC_CONTRACT_VERSION, fields: ["id", "version", "source", "context", "quantity", "snapshots", "checks", "policies", "limits"], limits: MODEL_DIAGNOSTIC_LIMITS, work: "source-preparation", checked: ["strict-observed-source-contract", "current-source-preparation-bindings", "quantity-financial-basis-population-references", "knowledge-and-valuation-cutoffs", "actual-calendar-geometry", "check-specific-structural-eligibility", "bounded-origin-cell-and-input-limits"], deferred: ["diagnostic-values-and-numerical-degeneracy", "source-authenticity", "population-comparability", "causality", "reserve-model-suitability", "review-completeness"], coordinates: ["origin", "fromAge", "throughAge", "fromValuation", "throughValuation", "calendarDiagonals.index", "calendarDiagonals.valuationDate"], source: "dated-observed-cumulative-loss", originKinds: ["accident", "policy", "report"], temporalStructures: ["explicit-origin-periods-and-development-age-clock"], replay: ["replayObservedDiagnostics"], replayPackage: "@actuarial-ts/core", unitRule: "Additive cumulative paid or incurred loss retains source units and scale; test statistics and standardized residuals are dimensionless", populationRule: "Declared loss populations remain separate; a diagnostic does not establish comparability across subjects or origins", financialRule: "A complete retained loss basis must match the source quantity currency; counts, rates and recovery-only bases are not relabeled as loss", costQualification: "Preflight validates/replays retained source preparation and checks applicability without a reserve fit or diagnostic-statistic execution. Execution computes only selected native checks; residuals use their declared Mack reference fit. No latency or peak-memory measurement is implied", options: [ { path: "checks", choices: ["calendar-rank", "factor-correlation", "mack-residuals"], default: null, description: "Explicit distinct checks; unsupported individual checks retain not-evaluated results" }, { path: "policies.correlationTies", choices: ["retain-approximation", "not-evaluated"], default: null, description: "Explicit treatment of the native average-rank approximation under ties" }, { path: "policies.futureObservations", choices: ["reject", "truncate"], default: null, description: "Future observations block interpretation unless explicit native truncation is selected" }, ], limitations: [ "Calendar rank evidence requires contiguous equal-duration origins and regular positive ages whose positional diagonals have the same actual dates", "The correlation screen uses the native 50% interval; not-flagged does not establish independence", "Mack residuals are descriptive reference-fit evidence, not fitted residuals of adopted reserve selections; unavailable variance remains null", "Native evaluation status and signal are separate; not-evaluated is never a passing check", "Current-SDK exact replay recalculates evidence and validates source bindings; it does not authenticate original source bytes or certify the review", ], evaluate(input) { const result = assessObservedDiagnosticEligibilityFromInput(input); return { findings: result.findings, status: result.status === "supported" ? "supported-with-warnings" : result.status }; }, }]; }