trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
57 lines • 2.13 kB
TypeScript
/**
* Idea Garden — Cluster Detection
*
* DESIGN.md §7.2–7.4 — Identifies "idea clusters": contiguous sequences
* of ops that were never incorporated into a milestone and were later
* diverged from.
*
* Three detection heuristics:
* 1. Context-switch detection (file-set shift)
* 2. Branch abandonment (stale un-milestoned ops)
* 3. Revert detection (ops undone by later ops)
*/
import type { VcsOp } from '../vcs/types.js';
export interface IdeaCluster {
id: string;
ops: VcsOp[];
firstOp: string;
lastOp: string;
affectedFiles: string[];
affectedSymbols: string[];
estimatedIntent: string;
createdAt: string;
abandonedAt: string;
status: 'abandoned' | 'draft' | 'revived';
/** Which heuristic detected this cluster. */
detectedBy: string;
}
export interface ClusterDetector {
name: string;
detect(ops: VcsOp[], milestonedOpHashes: Set<string>): IdeaCluster[];
}
/**
* Detects clusters when the set of files being modified shifts abruptly.
* Groups consecutive un-milestoned file ops by "file affinity" — when
* the overlap between the current working set and the next op drops to zero,
* a new group starts. Groups that are followed by a different group become
* candidate clusters.
*/
export declare const contextSwitchDetector: ClusterDetector;
/**
* Detects clusters where a file's content hash returns to a prior value,
* indicating the intermediate ops were "reverted."
*/
export declare const revertDetector: ClusterDetector;
/**
* Detects un-milestoned ops on branches that haven't seen activity recently.
* Since we operate on a linear op stream for now, this looks for gaps
* where file ops stop and then resume on different files.
*/
export declare const staleBranchDetector: ClusterDetector;
/** All built-in detectors. */
export declare const defaultDetectors: ClusterDetector[];
/**
* Run all detectors and merge results (dedup by cluster ID).
*/
export declare function detectClusters(ops: VcsOp[], milestonedOpHashes: Set<string>, detectors?: ClusterDetector[]): IdeaCluster[];
//# sourceMappingURL=cluster.d.ts.map