/**
 * PR Sync Watcher Service
 *
 * Polls GitHub PR status and CI status for features in the Review lifecycle
 * stage, and upstream PR status for features in the AwaitingUpstream stage,
 * updating feature records and emitting notifications when transitions
 * are detected. Follows the NotificationWatcherService polling pattern.
 *
 * Maintains in-memory tracking of last-known PR and CI status per feature
 * to avoid duplicate updates and notifications. Features are grouped by
 * repositoryPath for batch `gh pr list` queries.
 */
import type { IFeatureRepository } from '../../../application/ports/output/repositories/feature-repository.interface.js';
import type { IAgentRunRepository } from '../../../application/ports/output/agents/agent-run-repository.interface.js';
import type { IGitPrService } from '../../../application/ports/output/services/git-pr-service.interface.js';
import type { INotificationService } from '../../../application/ports/output/services/notification-service.interface.js';
import type { IGitForkService } from '../../../application/ports/output/services/git-fork-service.interface.js';
import type Database from 'better-sqlite3';
export declare class PrSyncWatcherService {
    private readonly featureRepo;
    private readonly agentRunRepo;
    private readonly gitPrService;
    private readonly notificationService;
    private readonly gitForkService;
    private readonly pollIntervalMs;
    private readonly trackedFeatures;
    private readonly skippedRepos;
    private readonly rateLimitedUntil;
    private readonly db;
    private readonly processId;
    private intervalId;
    private pollCycle;
    constructor(featureRepo: IFeatureRepository, agentRunRepo: IAgentRunRepository, gitPrService: IGitPrService, notificationService: INotificationService, pollIntervalMs?: number, db?: Database.Database | null, gitForkService?: IGitForkService | null);
    isRunning(): boolean;
    start(): void;
    stop(): void;
    /** Attempt to acquire the cross-process poll lock. Returns true if acquired. */
    private tryAcquireLock;
    /** Check if a feature should be polled this cycle based on its unchanged cycles count. */
    private shouldPollFeature;
    private poll;
    private isRateLimited;
    private handleRateLimitError;
    private processRepository;
    private processFeature;
    /**
     * Extract upstream repo (owner/name) from an upstream PR URL.
     * Expected format: https://github.com/owner/repo/pull/123
     */
    private extractUpstreamRepo;
    /**
     * Poll upstream PR status for a feature in AwaitingUpstream lifecycle.
     * If the upstream PR is merged, transition to Maintain.
     * If the upstream PR is closed, update upstreamPrStatus to Closed.
     */
    private processAwaitingUpstreamFeature;
    /** Mark associated agent run as completed so the UI reflects "done" state. */
    private completeAgentRun;
    private emitNotification;
}
/**
 * Initialize the PR sync watcher singleton.
 * Must be called once during web server startup.
 *
 * @throws Error if the watcher is already initialized
 */
export declare function initializePrSyncWatcher(featureRepo: IFeatureRepository, agentRunRepo: IAgentRunRepository, gitPrService: IGitPrService, notificationService: INotificationService, pollIntervalMs?: number, db?: Database.Database | null, gitForkService?: IGitForkService | null): void;
/**
 * Get the PR sync watcher singleton.
 *
 * @returns The PR sync watcher service
 * @throws Error if the watcher hasn't been initialized yet
 */
export declare function getPrSyncWatcher(): PrSyncWatcherService;
/**
 * Check if the PR sync watcher has been initialized.
 */
export declare function hasPrSyncWatcher(): boolean;
/**
 * Reset the PR sync watcher singleton (for testing purposes only).
 * Stops the watcher if running before resetting.
 *
 * @internal
 */
export declare function resetPrSyncWatcher(): void;
//# sourceMappingURL=pr-sync-watcher.service.d.ts.map