/**
 * @module        StageEngine
 * @description   通用阶段引擎，根据 YAML 配置驱动任意流水线阶段的执行与流转
 *
 * @author        eddy
 * @organization  wykj
 * @ownership     wykj/eddy
 *
 * @created       2026-04-03
 * @updated       2026-04-03
 *
 * @role          engine
 * @layer         engine
 * @boundedContext pipeline-execution
 *
 * @stateTransition stage.from → stage.to (由 StageDefinition 配置驱动)
 * @workflow       tick → prepare (first stage) → claim → launch worker → complete → release (last stage)
 */
import type { ProjectContext } from '../core/context.js';
import type { ProjectPipelineAdapter, StageDefinition } from '../core/projectPipelineAdapter.js';
import type { Notifier } from '../interfaces/Notifier.js';
import type { RepoBackend } from '../interfaces/RepoBackend.js';
import type { TaskBackend } from '../interfaces/TaskBackend.js';
import type { WorkerManager } from '../manager/worker-manager.js';
import type { Card, CommandResult } from '../shared/types.js';
/**
 * v0.51.0: pull pinned wiki page ids from card frontmatter `meta.wiki_pages`
 * (string[] or comma-separated string). Tolerates both shapes.
 *
 * Exported for unit testing.
 */
export declare function extractPinnedPages(card: Card): string[];
/**
 * StageEngine — generic engine that handles any pipeline stage.
 *
 * Replaces both ExecutionEngine and CloseoutEngine. Behavior is driven by
 * the StageDefinition from YAML config + positional flags (isFirstStage / isLastStage).
 *
 * Single-worker model: worker runs directly in PROJECT_DIR on the current branch.
 * First stage: handles prepare (Backlog → Ready) and launches workers.
 * Last stage: handles release (resource cleanup).
 */
export declare class StageEngine {
    private ctx;
    private stage;
    private stageIndex;
    private totalStages;
    private taskBackend;
    private workerManager;
    private pipelineAdapter;
    private notifier?;
    private log;
    private runtimeStore;
    constructor(ctx: ProjectContext, stage: StageDefinition, stageIndex: number, totalStages: number, taskBackend: TaskBackend, _repoBackend: RepoBackend, workerManager: WorkerManager, pipelineAdapter: ProjectPipelineAdapter, notifier?: Notifier | undefined);
    /** Stage name from YAML */
    get name(): string;
    /** Whether this is the first stage (responsible for prepare: branch + worktree) */
    get isFirstStage(): boolean;
    /** Whether this is the last stage (responsible for release: worktree cleanup) */
    get isLastStage(): boolean;
    /** Whether this stage uses FIFO queue for serialization */
    tick(opts?: {
        dryRun?: boolean;
    }): Promise<CommandResult>;
    private processStageCard;
    private inspectStageWorker;
    private startStageWorker;
    private completeAndAdvance;
    /**
     * Release resources after final stage completion.
     * Order: Move Done → Release claim → Release slot → Stop worker → Mark worktree cleanup
     */
    private releaseAndDone;
    private checkActiveCard;
    private prepareCard;
    private launchWorker;
    private listRuntimeAwareActiveCards;
    private reconcilePmStatesWithRuntime;
    private derivePmStateFromLease;
    private buildStagePrompt;
    /**
     * v0.51.0: build the wiki injection (`wikiContext`) and the trailing
     * wiki-update reminder (`wikiUpdateReminder`) for the current card.
     *
     * Disabled when `WIKI_ENABLED` is not 'true' or the project has no
     * `wiki/WIKI.md`. Failures degrade silently — wiki notes are best-effort
     * context and shouldn't block a card.
     */
    private buildWikiSections;
    private loadSkillProfiles;
    private shouldSkip;
    private cleanAuxiliaryLabels;
    /**
     * Handle cards flagged with ACK-TIMEOUT by MonitorEngine.
     *
     *  - First-time timeout: cancel the worker, wipe ACK-TIMEOUT, add
     *    ACK-RETRIED-<stage>, move card back to triggerState so the normal
     *    launch flow re-dispatches in the same tick (fresh session).
     *  - Already retried (ACK-RETRIED-<stage> present): escalate to NEEDS-FIX.
     *
     * Runs for all stages; only processes cards in this stage's activeState.
     */
    private handleAckTimeouts;
    private findRuntimeSlotName;
    private releaseSlot;
    private releaseSlotForStage;
    private markNeedsFix;
    private addLabelSafe;
    private commentSafe;
    private notifySafe;
    private logEvent;
    /**
     * Launch a single card (for `sps worker launch <project> <seq>`).
     * Only available on the first stage.
     */
    launchSingle(seq: string, opts?: {
        dryRun?: boolean;
    }): Promise<CommandResult>;
}
/**
 * v0.50.17：skill 解析的纯函数版本。顺序：card.skills → stage.profile → DEFAULT_WORKER_SKILLS。
 * 三条都空返空数组。
 *
 * 历史：v0.42 前读 `card.labels` 里 `skill:*` 前缀；v0.42 起改 frontmatter `skills` 字段；
 * v0.50.9 修了 StageEngine 还在读 labels 的 bug；v0.50.17 抽成纯函数补上测试。
 */
export declare function resolveRequiredSkills(card: {
    skills?: string[];
}, stage: {
    profile?: string;
}, defaultWorkerSkills: string | undefined): string[];
/** v0.50.17：skill 段模板，和 loadSkillProfiles 共用。 */
export declare function formatSkillRequirement(skills: string[]): string;
//# sourceMappingURL=StageEngine.d.ts.map