import { type RalplanIndexRow } from "./ledger-event-renderer"; /** * Native implementation of `gjc ralplan`. * * Two invocation shapes are handled natively: * * 1. **Consensus handoff**: `gjc ralplan [--interactive] [--deliberate] [--architect ] * [--critic ] [--session-id ] ""` validates the documented flag surface, * seeds `.gjc/state/ralplan-state.json`, and updates the shared HUD rail via * `syncSkillActiveState`. The CLI never *runs* the Planner / Architect / Critic loop itself — * that lives in the bundled `/skill:ralplan` skill — but it accepts every documented flag so * scripted users see a useful response and the active run is visible to the TUI. * * 2. **Artifact write**: `gjc ralplan --write --stage --stage_n * (--artifact | --artifact-env GJC_RALPLAN_ARTIFACT) * [--run-id ] [--session-id ] [--lane-verdict ] [--json]` persists Planner / Architect * / Critic / intent / disposition / revision / post-interview / ADR / final artifacts under * `.gjc/plans/ralplan//`, maintains an `index.jsonl` audit log, copies `final` * stages to `pending-approval.md`, and advances the HUD chip to reflect the latest * persisted stage. Disposition stage artifacts are fail-closed JSON documents that * record typed review conflicts with authoritative same-pass source receipts (#2902). */ export interface RalplanCommandResult { status: number; stdout?: string; stderr?: string; } /** Default consensus iterations (planner + revision openers) per run. Matches SKILL.md re-review cap. */ export declare const RALPLAN_DEFAULT_MAX_ITERATIONS = 5; /** Inclusive upper bound for `gjc.ralplan.maxIterations` settings overrides. */ export declare const RALPLAN_MAX_ITERATIONS_LIMIT = 20; /** Operator-visible stuck signal for headless/CI orchestration (#3165). */ export declare const PLANNING_STUCK_MARKER = "PLANNING-STUCK"; /** Default architect/critic review passes per consensus iteration. */ export declare const RALPLAN_DEFAULT_MAX_REVIEW_PASSES_PER_LANE = 1; /** Inclusive upper bound for `gjc.ralplan.maxReviewPassesPerLane` settings overrides. */ export declare const RALPLAN_MAX_REVIEW_PASSES_PER_LANE_LIMIT = 10; export type RalplanAutoHandoffTarget = "off" | "ultragoal" | "autoresearch"; export interface RalplanAutoHandoffResolution { configuredTarget: RalplanAutoHandoffTarget; effectiveTarget: RalplanAutoHandoffTarget; degradationReason: string | null; source: string; } export type RalplanIterationCapDecision = { allowed: true; currentIterations: number; projectedIterations: number; maxIterations: number; } | { allowed: false; currentIterations: number; projectedIterations: number; maxIterations: number; reason: string; }; /** * Pure consensus-iteration budget gate (#3165). * * A `planner` or `revision` write opens a new iteration (same definition as * `summarizeRalplanIndex`). Other stages never open iterations and are always * allowed by this gate — including `final` after the cap is already reached. * * `iterationFloor` raises the observed opener count when on-disk evidence or a * recovered ledger is higher than the parsed index (fail-closed vs wipe/truncate). */ export declare function evaluateRalplanIterationCap(input: { rows: readonly RalplanIndexRow[]; stage: string; maxIterations?: number; /** Minimum opener count (e.g. on-disk stage-*-{planner,revision}.md). */ iterationFloor?: number; }): RalplanIterationCapDecision; export type RalplanReviewLane = "architect" | "critic"; export type RalplanReviewLaneBudgetDecision = { allowed: true; lane?: RalplanReviewLane; currentPasses: number; projectedPasses: number; maxReviewPassesPerLane: number; finalSlot: boolean; ledgerNote?: string; } | { allowed: false; lane: RalplanReviewLane; currentPasses: number; projectedPasses: number; maxReviewPassesPerLane: number; finalSlot: false; ledgerNote?: string; reason: string; }; /** * Pure per-lane review-pass budget gate. Architect and critic passes are limited * within the current consensus iteration; all other stages remain unconditionally * available as escalation paths. */ export declare function evaluateRalplanReviewLaneBudget(input: { rows: readonly RalplanIndexRow[]; stage: string; maxReviewPassesPerLane?: unknown; onDiskLaneCounts?: { architect: number; critic: number; }; }): RalplanReviewLaneBudgetDecision; /** * Count on-disk planner/revision stage artifacts for a run. Used as a floor when * `index.jsonl` is missing, empty, truncated, or otherwise under-counts openers. */ export declare function countRalplanOnDiskOpeners(cwd: string, sessionId: string, runId: string): Promise; /** * Count on-disk Architect/Critic stage artifacts for a run. This is the * fail-closed floor for a missing, truncated, or malformed `index.jsonl`. */ export declare function countRalplanOnDiskLaneArtifacts(cwd: string, sessionId: string, runId: string): Promise<{ architect: number; critic: number; }>; /** * Load index rows for cap enforcement. Unlike HUD reads, returns structural * signals so callers can fail closed when the ledger is empty/malformed while * opener artifacts already exist on disk. */ export declare function loadRalplanIndexForCap(cwd: string, sessionId: string, runId: string): Promise<{ rows: RalplanIndexRow[]; indexPresent: boolean; parseableLines: number; rawLineCount: number; rawText?: string; }>; /** * Resolve the ralplan consensus iteration cap through the shared resolver. * Project `.gjc/config.yml` and `.gjc/settings.json` beat user layers. */ export declare function resolveRalplanMaxIterations(cwd: string, agentDir?: string): Promise<{ maxIterations: number; source: string; }>; type RalplanAutoHandoffOptions = { planningStuck?: boolean; /** The session's effective agent directory (see resolveWorkflowSetting). */ agentDir?: string; }; export declare function resolveRalplanAutoHandoff(cwd: string, options?: RalplanAutoHandoffOptions): Promise; /** Resolve the per-lane review-pass budget through the shared resolver. */ export declare function resolveRalplanMaxReviewPassesPerLane(cwd: string, agentDir?: string): Promise<{ maxReviewPassesPerLane: number; source: string; }>; export declare function isRalplanArtifactWriteInvocation(args: readonly string[]): boolean; /** * Explicit target-worktree routing (#4693). `--worktree-root ` selects the * canonical git worktree that owns every ralplan persistence root (run state, * stage artifacts, index ledger, HUD state, stuck markers, and review-budget * accounting) regardless of the writer process's ambient cwd. Without the flag, * behavior stays cwd-based. The invoking cwd is retained only for resolving a * relative `--artifact` input file. */ interface RalplanTargetRoot { /** Canonical persistence root: the invocation cwd, or the --worktree-root target. */ root: string; /** True when the caller explicitly selected the target via --worktree-root. */ explicit: boolean; } export declare function resolveRalplanTargetRoot(args: readonly string[], invocationCwd: string): Promise; export declare function assertExplicitTargetGjcNotSymlinked(root: string): Promise; export declare function runNativeRalplanCommand(args: string[], cwd?: string, options?: { agentDir?: string; }): Promise; export {};