import type { QuestionPoolDiscriminator } from "../../questions/domain/question.schema.js"; /** Recipient and intent provenance that scopes one pool preference. */ export interface PoolAdjustmentProvenance { recipientUserId: string; intentId: string; } /** One applied adjustment on an opportunity (stored in metadata.poolAdjustments). */ export interface PoolAdjustment extends PoolAdjustmentProvenance { /** The answered question that produced this adjustment (reversal key). */ questionId: string; /** Discriminator label, e.g. "Hands-on builders vs advisors". */ label: string; /** Side this candidate was assigned to (or "unknown"). */ side: string; /** Multiplicative factor: chosen 1.0, other 0.6, unknown 0.9. */ factor: number; /** Template chip text from the user's own answer. Set on demotions only. */ detail?: string; /** ISO-8601 apply timestamp. */ appliedAt: string; /** Full intent fingerprint authoritative when this adjustment was created. */ intentFingerprint?: string; /** Audit-only marker: stale adjustments remain stored but have no ranking effect. */ stale?: true; } /** Reads valid adjustments, optionally narrowed to one recipient + intent. */ export declare function readPoolAdjustments(metadata: Record | null | undefined, provenance?: PoolAdjustmentProvenance): PoolAdjustment[]; /** Reads valid, non-stale adjustments for ranking and presentation behavior. */ export declare function readActivePoolAdjustments(metadata: Record | null | undefined, provenance?: PoolAdjustmentProvenance): PoolAdjustment[]; /** * Cumulative adjustment multiplier for an opportunity, floored at * {@link POOL_ADJUSTMENT_FLOOR}. 1 when no scoped adjustments exist. */ export declare function poolAdjustmentMultiplier(metadata: Record | null | undefined, provenance: PoolAdjustmentProvenance): number; /** Adjusted confidence: `confidence × Π factor`, floored. */ export declare function adjustedConfidence(confidence: number, metadata: Record | null | undefined, provenance: PoolAdjustmentProvenance): number; /** Deterministic provenance signal stored alongside one adjustment. */ export interface PoolAdjustmentSignal extends PoolAdjustmentProvenance { type: "pool_discriminator"; weight: 1 | -1 | 0; detail: string; questionId: string; } /** Pure helper input shared by Tier-0 answers and newborn stamping. */ export interface BuildPoolAdjustmentInput extends PoolAdjustmentProvenance { questionId: string; label: string; /** Verified side assignment, or null when the candidate is unassigned. */ assignedSide: string | null; chosenSide: string; appliedAt: string; /** Full intent fingerprint authoritative when this adjustment was created. */ intentFingerprint?: string; } /** * Build one P3-compatible adjustment and signal. This is the only place that * defines chosen/other/unknown factors, weights, and safe template details. */ export declare function buildPoolAdjustment(input: BuildPoolAdjustmentInput): { adjustment: PoolAdjustment; signal: PoolAdjustmentSignal; }; /** Plan entry: what to write on one opportunity for one answer. */ export interface PoolAdjustmentPlanEntry { opportunityId: string; adjustment: PoolAdjustment; signal: PoolAdjustmentSignal; } /** * Computes the write plan for one answered discriminator. Pure: the caller * loads/patches rows. "Both matter" (or any label not in `sides`) yields an * empty plan — no preference, no adjustments. * * @param discriminator The asked discriminator (from detection.pool). * @param chosenSide The selected option label (chip label = side label). * @param questionId Reversal key. * @param recipientUserId User whose answer produced the preference. * @param intentId Intent whose candidate pool was ranked. * @param now ISO-8601 timestamp. * @param intentFingerprint Full intent fingerprint authoritative at apply time. */ export declare function planPoolAdjustments(discriminator: QuestionPoolDiscriminator, chosenSide: string, questionId: string, recipientUserId: string, intentId: string, now: string, intentFingerprint?: string): PoolAdjustmentPlanEntry[]; /** * Merges one adjustment into an opportunity's existing metadata, replacing * only the entry for the same question + recipient + intent provenance. * Returns the NEW metadata object (caller persists it wholesale). */ export declare function mergePoolAdjustment(metadata: Record | null | undefined, adjustment: PoolAdjustment): Record; /** Latest scoped user-explainable demotion detail for card presentation. */ export declare function latestPoolDemotionDetail(metadata: Record | null | undefined, provenance: PoolAdjustmentProvenance): string | undefined;