export interface DetectorOptions {
    /** Absolute path to the canonical instar repo. Required — Layer 4 reads
     *  this from `worktree.repoPath` config or the default fallback chain;
     *  resolution lives in the caller so this class stays I/O-pure for tests. */
    instarRepo: string;
    /** Agent's stateDir — used for the JSONL fallback location and for
     *  attributing the audit entry. */
    stateDir: string;
    /** Roots considered "safe" worktree locations. Each entry is the
     *  realpath of `<agent_home>/.worktrees` for some registered agent.
     *  Detector emits an item for any worktree whose path is NOT under one
     *  of these. */
    safeRoots: ReadonlyArray<string>;
    /** Attention emitter — when present, the detector creates AttentionItems
     *  via this callback (typically `telegramAdapter.createAttentionItem`).
     *  When absent, the detector falls back to JSONL append. */
    emitAttention?: (item: AttentionItemInput) => Promise<void> | void;
    /** Override `git worktree list --porcelain` timeout. Spec default 2s. */
    gitTimeoutMs?: number;
    /** Override the JSONL fallback path (defaults to
     *  `<stateDir>/audit/worktree-detector.jsonl`). */
    fallbackPath?: string;
}
export interface AttentionItemInput {
    /** Stable id used for AttentionQueue dedupe — `worktree-misplaced-summary:<set-hash>`. */
    id: string;
    title: string;
    summary: string;
    description?: string;
    category: string;
    priority: 'URGENT' | 'HIGH' | 'NORMAL' | 'LOW';
    sourceContext?: string;
}
export interface DetectorResult {
    /** Total worktree entries enumerated (including main checkout + bare). */
    enumerated: number;
    /** Entries skipped because they were the main checkout / bare / stale. */
    skipped: number;
    /** Misplaced worktrees found (the count INSIDE the single aggregated item). */
    misplacedCount: number;
    /** Items emitted (Telegram path or JSONL path) — at most 1 per run. */
    emitted: number;
    /** Items deduped against the 24h fallback-file window (JSONL path only). */
    deduped: number;
    /** Set true when `git worktree list` exceeded `gitTimeoutMs`. */
    timedOut: boolean;
}
export declare function runDetection(opts: DetectorOptions): Promise<DetectorResult>;
/**
 * Enumerates safe roots by scanning `~/.instar/agents/<name>/.worktrees`
 * directories DIRECTLY on disk — NOT via the agent registry.
 *
 * 2026-06-05 flood root cause: the previous implementation iterated
 * `loadRegistry().entries`. The registry is rewritten concurrently by every
 * agent/lifeline on the machine, and a reader that catches a lost-update
 * window (or any parse failure, which `loadRegistry` silently maps to an
 * EMPTY entry list) sees a registry without this agent — so this agent's own
 * `.worktrees/` stopped being a safe root and every properly-placed worktree
 * was flagged as misplaced (110 false positives in one boot).
 *
 * The disk IS the ground truth here: a safe root is "an agent home's
 * `.worktrees` directory", and those are directly observable. No shared
 * mutable file in the read path → the transient-empty failure class is gone.
 */
export declare function enumerateSafeRoots(agentsDir?: string): string[];
export interface ResolveDetectorRepoOptions {
    /** Path to user config (defaults to `~/.instar/config.json`). */
    configPath?: string;
    /** Override the fallback chain order (for tests). */
    fallbackChain?: ReadonlyArray<string>;
    /** Override the home directory used for default fallbacks. */
    homeDir?: string;
    /**
     * Override `process.cwd()` for current-checkout discovery (for tests —
     * without this seam the tests silently depend on whether the machine
     * running them has an allowlisted checkout at cwd).
     */
    cwd?: string;
}
/**
 * Per spec: the detector uses a deterministic source (config or default
 * chain), NOT `INSTAR_REPO` env var, because env vars can differ between
 * lifeline boot and interactive sessions and the detector wants
 * consistent results across both.
 */
export declare function resolveDetectorInstarRepo(opts?: ResolveDetectorRepoOptions): string | null;
//# sourceMappingURL=AgentWorktreeDetector.d.ts.map