import type { BoardRegistry } from '../boards/index.js'; import type { AuditActorProfileInput, AuditActorType, AuditContext } from '../storage/domains/audit/base.js'; import type { AuditRecorder } from '../storage/domains/audit/domain.js'; import type { WorkItemRow, WorkItemsStorage } from '../storage/domains/work-items/base.js'; import type { FactoryRuleActor, FactoryRuleCausalEntry, FactoryRuleStage, FactoryTriageType, FactoryTransitionResult } from './types.js'; export interface FactoryTransitionRequest { orgId: string; factoryProjectId: string; workItemId: string; /** Installed board id; the service rejects boards that are not installed. */ board: string; stage: FactoryRuleStage; expectedRevision: number; actor: FactoryRuleActor; actorProfile?: AuditActorProfileInput; /** Where a browser request came from; rules and agents carry none. */ context?: AuditContext; ingress: { type: 'human' | 'agent' | 'toolResult' | 'github' | 'rule'; identity: string; transitionId?: string; }; cause: string; causalChain?: readonly FactoryRuleCausalEntry[]; /** Internal materialization path: evaluate only the destination onEnter leaf even when already at that stage. */ initialEntry?: boolean; /** Re-runs the stage's entry rules when the item already holds that stage, to restart work the entry invalidated. */ reenter?: boolean; /** Structured verdict required from a bound triage-agent terminal request. */ triageType?: FactoryTriageType; } export interface FactoryTransitionServiceOptions { configVersion: string; storage: WorkItemsStorage; boards?: BoardRegistry; /** Every commit, accepted or rejected, lands here as `stage_moved` / `transition_rejected` under the request's actor. */ audit?: AuditRecorder; timeoutMs?: number; /** * Called after a transition commits into a phase the board declares * terminal — the point where the item's sessions stop receiving runs, so * resources they hold (e.g. sandboxes) can be released for reuse. Awaited, * but failures are swallowed: releasing resources must never break or roll * back the committed transition. */ onTerminalStage?: (args: { orgId: string; factoryProjectId: string; workItemId: string; stage: FactoryRuleStage; revision: number; }) => Promise | void; /** Upper bound on how long a committed transition waits for * `onTerminalStage` before returning (default 30s). The cleanup continues * in the background past the bound. */ terminalCleanupTimeoutMs?: number; /** * Called after a transition first records a person's acceptance of a * non-bug item (see `WorkItemRow.acceptedAt`). Fire-and-forget: failures * are swallowed, the committed transition never depends on it. */ onAccepted?: (args: { orgId: string; factoryProjectId: string; workItemId: string; item: WorkItemRow; }) => Promise | void; } export declare function auditActorOf(actor: FactoryRuleActor): { actorId: string; actorType: AuditActorType; }; export declare function currentStage(stages: readonly string[]): FactoryRuleStage | undefined; export declare class FactoryTransitionService { #private; constructor(options: FactoryTransitionServiceOptions); get configVersion(): string; transition(request: FactoryTransitionRequest): Promise; } //# sourceMappingURL=transition-service.d.ts.map