import { BaseEngine, IMetadataProvider, UserInfo } from '@memberjunction/core';
import { MJMLAlgorithmEntity, MJMLAlgorithmUseCaseEntity, MJMLAlgorithmUseCaseRankingEntity, MJMLModelEntity, MJMLModelScoringBindingEntity, MJMLTrainingPipelineEntity, MJMLTrainingRunEntity, MJExperimentEntity, MJExperimentSessionEntity, MJExperimentSessionIterationEntity, MJRecordProcessEntity } from '@memberjunction/core-entities';
import { PSIterationRow, PSProcessRunRow } from '../predictive-studio.view-models';
/**
 * Recommendation levels used by the Algorithm Use Case Rankings matrix, ordered weakest → strongest.
 * Used to rank algorithms within a chosen scenario in the catalog "Guide me" picker.
 */
export type RecommendationLevel = 'NotRecommended' | 'Weak' | 'Viable' | 'Strong' | 'Primary';
/** Numeric rank for each {@link RecommendationLevel} (higher = better fit). */
export declare const RECOMMENDATION_RANK: Record<RecommendationLevel, number>;
/** Minimal shape of a ranking row consumed by {@link computeBestLevels} (decoupled from the entity). */
export interface RankingRow {
    MLAlgorithmID: string;
    MLAlgorithmUseCaseID: string;
    RecommendationLevel: RecommendationLevel;
}
/**
 * Pure ranking-matrix reducer: given ranking rows and a set of selected use-case IDs, returns each
 * algorithm's BEST recommendation level (max by rank) across those scenarios. Extracted from the
 * engine so it is unit-testable without a metadata provider / DB.
 */
export declare function computeBestLevels(rankings: RankingRow[], useCaseIds: string[]): Map<string, RecommendationLevel>;
/**
 * PredictiveStudioEngine — the single, process-wide cache + domain-logic layer for the Predictive
 * Studio dashboard. Follows the canonical MJ BaseEngine pattern (Config() declaring
 * BaseEnginePropertyConfig[], lazy-loaded, ObserveProperty reactivity for free).
 *
 * It caches the SMALL Predictive Studio reference entities (algorithms, use cases, the rankings
 * matrix, models, pipelines, training runs, experiments + sessions + iterations) via RunView so
 * the panels bind to in-memory arrays and stay reactive to saves/deletes. Large columns
 * (serialized model artifacts, feature schemas) live on the entities themselves but these tables
 * are small enough to fully cache.
 */
export declare class PredictiveStudioEngine extends BaseEngine<PredictiveStudioEngine> {
    /** Singleton accessor — never `new` this class directly. */
    static get Instance(): PredictiveStudioEngine;
    private _Algorithms;
    private _UseCases;
    private _Rankings;
    private _Models;
    private _ScoringBindings;
    private _RecordProcesses;
    private _Pipelines;
    private _TrainingRuns;
    private _Experiments;
    private _Sessions;
    private _Iterations;
    Config(forceRefresh?: boolean, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
    get Algorithms(): MJMLAlgorithmEntity[];
    get UseCases(): MJMLAlgorithmUseCaseEntity[];
    get Rankings(): MJMLAlgorithmUseCaseRankingEntity[];
    get Models(): MJMLModelEntity[];
    /** Scoring bindings — a model → (target entity + column, optional Record Process) deployment link. */
    get ScoringBindings(): MJMLModelScoringBindingEntity[];
    /** Record Processes — used to resolve the schedule (cron) + status of a binding's bound process. */
    get RecordProcesses(): MJRecordProcessEntity[];
    get Pipelines(): MJMLTrainingPipelineEntity[];
    get TrainingRuns(): MJMLTrainingRunEntity[];
    get Experiments(): MJExperimentEntity[];
    get Sessions(): MJExperimentSessionEntity[];
    get Iterations(): MJExperimentSessionIterationEntity[];
    /** Look up an ML Model by ID (for joining a scoring binding to its model). */
    ModelByID(modelId: string | null | undefined): MJMLModelEntity | undefined;
    /** Look up a Record Process by ID (for resolving a binding's schedule/status). */
    RecordProcessByID(processId: string | null | undefined): MJRecordProcessEntity | undefined;
    /** Look up an algorithm name by ID (for joining iterations/runs/models to a display name). */
    AlgorithmName(algorithmId: string | null | undefined): string;
    /** All ranking rows for a given use case, joined to their algorithm and ranked best-first. */
    RankingsForUseCase(useCaseId: string): MJMLAlgorithmUseCaseRankingEntity[];
    /**
     * Given a set of selected use-case IDs, compute each algorithm's BEST recommendation level
     * across those scenarios (max by rank) — the core of the catalog "Guide me" picker.
     * Returns a map of algorithmId → best level, omitting algorithms with no ranking row.
     */
    BestLevelsForScenarios(useCaseIds: string[]): Map<string, RecommendationLevel>;
    /** Iterations belonging to a session, in sequence order. */
    IterationsForSession(sessionId: string): MJExperimentSessionIterationEntity[];
    /** Published models only — the production-quality set used for headline KPIs. */
    get PublishedModels(): MJMLModelEntity[];
    /** Sessions whose status is `Running` — the active experiment count. */
    get RunningSessions(): MJExperimentSessionEntity[];
    /**
     * Resolve a model's human-readable display name generically: the producing pipeline's name when
     * available (the most meaningful label — what the model predicts), else the model's denormalized
     * `Pipeline` view field, else a version-stamped fallback. Entity-agnostic — never hardcodes any
     * business entity.
     */
    ModelDisplayName(model: MJMLModelEntity): string;
    /**
     * Map the engine's cached iterations for a session into the pure {@link PSIterationRow} shape the
     * view-model derivations consume — joining each iteration to its algorithm name via the resulting
     * training run (iteration → run → algorithm), since iterations don't carry the algorithm directly.
     */
    IterationRowsForSession(sessionId: string): PSIterationRow[];
    /** Resolve an iteration's algorithm display name via its training run (or 'Unknown'). */
    AlgorithmForIteration(iterationId: string): string;
    /**
     * The `MJ: Record Processes` IDs that ML scoring write-backs run through — every scoring binding's
     * bound Record Process. Used to scope the Home activity feed to ML-scoring runs without depending
     * on a typed `WorkType='ML Model'` enum value (which is registered at runtime, not in the type).
     */
    get ScoringRecordProcessIDs(): string[];
    /**
     * Load recent ML-scoring process runs on demand (NOT bulk-cached — `MJ: Process Runs` grows
     * unbounded). Scopes to runs whose `RecordProcessID` is one of the ML scoring bindings'
     * processes, optionally to the last `sinceDays`, capped at `maxRows`, newest first. Returns the
     * pure {@link PSProcessRunRow} shape for the Home derivations. Returns `[]` (never throws) on any
     * failure or when there are no scoring bindings to scope to.
     *
     * @param provider The provider to run against (multi-provider correctness).
     * @param user The acting user (server-side audit/security).
     * @param options.sinceDays Only runs started within this many days (default 7).
     * @param options.maxRows Row cap (default 50).
     */
    LoadRecentScoringRuns(provider: IMetadataProvider, user: UserInfo | undefined, options?: {
        sinceDays?: number;
        maxRows?: number;
    }): Promise<PSProcessRunRow[]>;
    /**
     * Record Processes (`WorkType='ML Model'`) configured to score with `modelId` — the cached link from a
     * model to the processes that run it, idle/scheduled/bound alike (no DB hit). The `modelId` is read from
     * each Record Process's stored `Configuration` JSON.
     */
    RecordProcessesForModel(modelId: string): MJRecordProcessEntity[];
    /** The cached Record-Process ids scoring with `modelId`. */
    RecordProcessIDsForModel(modelId: string): string[];
    /** Parse a Record Process's stored `modelId` (the `WorkType='ML Model'` config), or null. */
    private recordProcessModelId;
    /**
     * Load recent process runs for ONE model's Record Processes — same DB-light, on-demand contract as
     * {@link LoadRecentScoringRuns}, scoped to a single model. Powers the "Models in Production" per-model
     * run history (a model needs no scoring binding to have runs — any `WorkType='ML Model'` Record Process
     * run persists here).
     */
    LoadRecentRunsForModel(modelId: string, provider: IMetadataProvider, user: UserInfo | undefined, options?: {
        sinceDays?: number;
        maxRows?: number;
    }): Promise<PSProcessRunRow[]>;
    /** Shared run-loader: recent `MJ: Process Runs` for a set of Record-Process ids (capped, newest-first). */
    private loadRunsForProcessIds;
}
//# sourceMappingURL=predictive-studio.engine.d.ts.map