import { z } from "zod"; import type { LeaksReport } from "../types.js"; export declare const countAliveSchema: z.ZodObject<{ path: z.ZodString; className: z.ZodOptional; topN: z.ZodDefault; includeReferenceTree: z.ZodDefault; sortBy: z.ZodDefault>; excludeFrameworkNoise: z.ZodDefault; additionalNoisePatterns: z.ZodOptional>; unsuppressClassPatterns: z.ZodOptional>; noiseAuditMode: z.ZodDefault; }, "strip", z.ZodTypeAny, { path: string; topN: number; includeReferenceTree: boolean; sortBy: "count" | "totalBytes"; excludeFrameworkNoise: boolean; noiseAuditMode: boolean; className?: string | undefined; additionalNoisePatterns?: string[] | undefined; unsuppressClassPatterns?: string[] | undefined; }, { path: string; className?: string | undefined; topN?: number | undefined; includeReferenceTree?: boolean | undefined; sortBy?: "count" | "totalBytes" | undefined; excludeFrameworkNoise?: boolean | undefined; additionalNoisePatterns?: string[] | undefined; unsuppressClassPatterns?: string[] | undefined; noiseAuditMode?: boolean | undefined; }>; export type CountAliveInput = z.infer; export interface CountAliveEntry { className: string; instanceCount: number; /** When `includeReferenceTree: true`, the cycle-side contribution (often 0 for abandoned-memory shapes). */ byCycle?: number; /** When `includeReferenceTree: true`, the reference-tree contribution. Often the only non-zero side on `leakCount: 0` memgraphs. */ byReferenceTree?: number; /** * v1.14+. Per-instance size in bytes derived from the memgraph. For * fixed-size ObjC classes every instance has the same size; for * variable-size classes (NSData with payload, etc.) this is an average * (totalBytes / instanceCount, rounded). Absent when neither the * cycle-side `[N]` annotation nor the reference-tree parens-size * carried a number (rare). */ instanceSizeBytes?: number; /** * v1.17 B-07. Present only for variable-size classes (when observed * per-instance sizes are NOT all equal). Reports the actual spread * so the caller can tell "every NSData is 32 bytes" from "NSData * ranges 32-65536 bytes". Absent for fixed-size classes (the single * `instanceSizeBytes` value already tells the full story). * * `instanceSizeBytesMin` / `instanceSizeBytesMax` / `instanceSizeBytesMedian` * are the spread across all observed instances of this class in the * memgraph. For variable-size classes, `instanceSizeBytes` is the * median (was the first-non-zero observed value pre-v1.17, which * misled the caller). */ instanceSizeBytesMin?: number; instanceSizeBytesMax?: number; instanceSizeBytesMedian?: number; /** * v1.14+. Total bytes attributed to this class: sum of per-instance * sizes from the cycle forest plus the reference-tree totals. FLEX * surfaces this as the "Size" sort column in its Live Objects view. * Useful for "where is my memory going?" investigations. */ totalBytes?: number; } export interface CountAliveResult { ok: boolean; path: string; /** Total nodes counted in the cycle forest (across all classes). */ totalNodes: number; /** Per-class counts. When `className` is given, contains a single entry. */ counts: CountAliveEntry[]; /** * v1.12+. Present when `includeReferenceTree: true` and at least one * reference-tree row survived the framework-noise filter. Mirrors the * top-N list but with the noise classes (NSMutableDictionary, CFString, * `__DATA __bss`, allocator stacks, etc.) filtered out so the actionable * classes surface at the top. */ actionableCounts?: CountAliveEntry[]; /** * v1.17 B-10. Present when `noiseAuditMode: true`. Lists every class the * filter touched with the matching reason: 'default-list' (curated noise), * 'additional-pattern' (user-supplied regex), or 'kept-by-unsuppress' * (user-supplied override re-included it). Use this to validate that the * filter is calibrated for your app before trusting `actionableCounts[]`. */ noiseAudit?: Array<{ className: string; reason: "default-list" | "additional-pattern" | "kept-by-unsuppress"; }>; } /** Pure: count node occurrences by exact className across the cycle forest. * Backwards-compatible API; for v1.14 byte aggregation use * {@link countByClassWithBytes}. */ export declare function countByClass(report: LeaksReport): Map; /** * Pure: aggregate occurrences AND bytes by exact className across the * cycle forest. Each node's `instanceSize` is summed into `totalBytes`. * * v1.17 B-07: pre-v1.17 we recorded the first-non-zero observed size as * `instanceSizeBytes` and called it canonical. That misleads the caller * for variable-size classes (NSData, NSString, CFData) where each * instance has a payload-dependent size. Now: collect all observed * sizes; if they are uniform we report the single value; if they vary * we report the median in `instanceSizeBytes` AND surface the spread * via `instanceSizeBytesMin / max / median`. */ export declare function countByClassWithBytes(report: LeaksReport): Map; export declare function countAlive(input: CountAliveInput): Promise;