/** * Internalization Job Graph Topology (PRI-61) * * Defines the DAG topology for peer runner job execution. * Follows ADR-0003 Section 3.7 job graph rules: * 1. No cycles — graph must be acyclic * 2. Dependency gating — task with non-empty dependencyTaskIds * must NOT be leased until ALL dependencies are in succeeded state * 3. Dependency failure propagation — if any dependency enters failed, * the dependent task is NOT auto-failed (escalation policy in PRI-62) * * @see docs/adr/0003-peer-agent-state-machine-orchestration.md */ import type { InternalizationChannel, PeerRunnerKind, DiagnosticianStageKind, PipelineTopologyMode } from './peer-runner-contracts.js'; /** * Full-chain edges — the legacy v1 linear graph, retained as the topology of * `code_tool_hook`/`skill` chains and of any chain explicitly seeded with * `pipelineMode: 'full_chain'` (PRI-720 Owner override). * * v1: rollout_reviewer is the terminal peer runner. The trainer/model_training * surface was removed in PRI-449 (MVP-Gone). * * @see ADR-0003 Section 3.7 */ export declare const ALLOWED_EDGES: readonly (readonly [PeerRunnerKind, PeerRunnerKind])[]; /** * Channel-aware topology (PRI-720) — the single source of truth for which * edges exist per channel. `code_tool_hook`/`skill` keep the full chain * byte-compatible; `prompt`/`defer_archive` take the principle-semantic path. */ export declare const CHANNEL_EDGES: Readonly>; /** * Resolves the effective edge set for a channel + topology mode (PRI-720). * * Topology mode convention (P1 fix, Owner review 2026-09-15): * - `pipelineMode: 'standard'` → channel-aware edges (prompt/defer take the * principle-semantic short path). * - `pipelineMode: 'full_chain'` or **absent** → the full legacy linear * graph. Absence means a pre-PRI-720 record whose topology must NOT be * reinterpreted mid-flight (AC12) — new seeds always write the field * explicitly, so absence unambiguously identifies legacy chains. * - No channel (legacy callers) → full graph. */ export declare function resolveChannelEdges(channel?: InternalizationChannel, pipelineMode?: PipelineTopologyMode): readonly (readonly [PeerRunnerKind, PeerRunnerKind])[]; /** * Allowed edges in the diagnostician chain. * diag_rootcause → diag_distiller → diag_router */ export declare const DIAGNOSTICIAN_EDGES: readonly (readonly [DiagnosticianStageKind, DiagnosticianStageKind])[]; /** * PRI-720: topology scope selecting the edge set for a graph query. * Absent scope = full graph (legacy callers, backward compatible). */ export interface EdgeScope { channel?: InternalizationChannel; pipelineMode?: PipelineTopologyMode; } /** * Validates whether a transition from one runner to another is legal. * * Channel-aware since PRI-720: the edge set is resolved from the task's * channel + pipeline topology mode via resolveChannelEdges. Without a scope * the full graph is checked (backward-compatible with legacy callers); with * `pipelineMode: 'full_chain'` the full graph is always allowed regardless of * channel. * * @param from - Source peer runner kind * @param to - Target peer runner kind * @param scope - Channel + topology mode of the task chain */ export declare function validateEdge(from: PeerRunnerKind, to: PeerRunnerKind, scope?: EdgeScope): boolean; /** * Validates whether a diagnostician chain transition is legal. */ export declare function validateDiagEdge(from: DiagnosticianStageKind, to: DiagnosticianStageKind): boolean; /** * Returns allowed successor for a diagnostician stage kind. */ export declare function getDiagSuccessors(from: DiagnosticianStageKind): DiagnosticianStageKind[]; /** * Checks whether a set of edges forms a valid DAG (no cycles). * * Uses Kahn's algorithm for topological sorting: * 1. Compute in-degree for all nodes * 2. Start with nodes having in-degree 0 * 3. BFS: remove nodes, update in-degrees of neighbors * 4. If all nodes visited (no cycles) → valid DAG * 5. If nodes remain unvisited (cycles detected) → invalid * * @param edges - Array of [from, to] edge pairs * @returns true if edges form a valid DAG, false if cycles exist */ export declare function isAcyclic(edges: readonly (readonly [string, string])[]): boolean; /** * Returns all allowed successor runner kinds for a given runner. * * Channel-aware since PRI-720 (see resolveChannelEdges): prompt/defer_archive * chains route scribe → rollout_reviewer; full-chain mode and unchannelled * legacy reads keep the linear graph. rollout_reviewer is terminal. * * @param from - Source peer runner kind * @param channel - Internalization channel of the task chain * @param pipelineMode - Explicit topology mode override * @returns Array of allowed successor runner kinds */ export declare function getAllowedSuccessors(from: PeerRunnerKind, channel?: InternalizationChannel, pipelineMode?: PipelineTopologyMode): PeerRunnerKind[]; /** * Returns all allowed predecessor runner kinds for a given runner. * * Channel-aware since PRI-720 (see resolveChannelEdges). * * @param to - Target peer runner kind * @param channel - Internalization channel of the task chain * @param pipelineMode - Explicit topology mode override * @returns Array of allowed predecessor runner kinds */ export declare function getAllowedPredecessors(to: PeerRunnerKind, channel?: InternalizationChannel, pipelineMode?: PipelineTopologyMode): PeerRunnerKind[]; export { PEER_RUNNER_KINDS, INTERNALIZATION_CHANNELS } from './peer-runner-contracts.js'; //# sourceMappingURL=internalization-job-graph.d.ts.map