import type { Partition } from "./modularity.js"; /** * One independently-sourced view of the target, contributing a family of * partitions over the shared node universe. A multi-resolution behavior source * (call/import, co-change, data/state) supplies several partitions (one per * resolution); an intent-declared source (directory, docs, comments) typically * supplies one. */ export interface DecompositionSource { /** Stable source id, e.g. `call_import` / `co_change` / `directory`. */ id: string; /** * Which decomposition family this source belongs to (design §"two families"): * `behavior` = what the system does (coupling / co-change / data-state); * `intent` = what humans assert the pieces are (dirs / docs / comments). Only * `behavior` partitions feed the scale-stability score. */ family: "behavior" | "intent"; partitions: Partition[]; } /** A discovered subsystem candidate — an emergent node, never pre-defined. */ export interface DecomposedNode { /** Stable id: the lexicographically smallest member. */ node_id: string; /** Member node ids, lexically sorted. */ members: string[]; /** Fraction of signalling sources that best-fit the members together, in [0,1]. */ agreed_across_source: number; /** Fraction of behavior resolution levels at which the best-fit holds, in [0,1]. */ stable_across_scale: number; /** True when source agreement is below the consensus majority. */ contested: boolean; } export interface DecomposeResult { target: string; /** Nodes high on BOTH scores — confident subsystems. */ consensus: DecomposedNode[]; /** Nodes low on EITHER score — contested boundaries (each a hotspot/finding). */ contested: DecomposedNode[]; } export interface DecomposeOptions { /** * Minimum agreed-across-source a pair needs for its members to be unioned into * the same candidate node. The co-association edge threshold. */ agreementThreshold?: number; /** * Per-source best-fit F1 bar. A source "votes together" for a cluster when it * places (most of) the cluster inside a single right-sized community with F1 * (precision × recall of cluster-vs-community) at or above this bar. */ fitThreshold?: number; /** * Fraction of the *signalling* sources that must vote together for a cluster to * be consensus. A source "signals" on a cluster when it contains ≥2 of its * members (a source that can't speak to the cluster does not dilute the vote). */ sourceMajority?: number; /** * A community larger than this fraction of the node universe is a whole-area * bucket (directory-depth-1 "src", a coarse-Louvain blob), not cohesion * evidence, and is skipped when scoring fit. This is what stops the metric from * being gullible to coarse partitions. */ maxCommunityFraction?: number; } /** * Cluster nodes that co-locate in at least `minFraction` of the given partitions * (a consensus over the partition family). Returns member groups of size ≥ 2, * lexically sorted, in a deterministic order. Shared by {@link decompose} and by * the non-co-localization finding detectors, which need behavior-only and * intent-only cluster views separately. */ export declare function clustersFromPartitions(partitions: Partition[], minFraction?: number): string[][]; /** * The overlay-and-delta operator. Builds a co-association over all sources, * unions strongly-agreed pairs into candidate nodes, scores each node on the two * orthogonal robustness axes, and splits confident (consensus) from contested. */ export declare function decompose(sources: DecompositionSource[], target: string, options?: DecomposeOptions): DecomposeResult; //# sourceMappingURL=consensus.d.ts.map