trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
63 lines • 2.43 kB
TypeScript
/**
* trellis lane gc — lane lifecycle sweep (TRL-407).
*
* Pure classification ({@link classifyLane}) + engine-backed sweep
* ({@link gcLanes}). No CLI/IO coupling in the classifier — unit-testable.
*/
import type { TrellisVcsEngine } from '../engine.js';
import type { IssueInfo } from './issue.js';
import type { LaneMeta } from './lane.js';
export type LaneGcDisposition = 'promote' | 'drop' | 'garden' | 'leave';
export interface LaneGcRow {
laneId: string;
boundIssue?: string;
opCount: number;
disposition: LaneGcDisposition;
reason: string;
action: 'none' | 'promoted' | 'dropped' | 'gardened';
}
export interface LaneGcOptions {
/** Execute dispositions (dry-run is the default). */
apply?: boolean;
/** Allow destructive drop of lanes that carry ops. */
force?: boolean;
/** Restrict the sweep to one session (session-end hook path). */
sessionId?: string;
/** Clock injection for tests. */
now?: number;
}
export interface GcLaneInput {
lane: LaneMeta;
issue: IssueInfo | null;
opCount: number;
now?: number;
}
/**
* Stale cutoff: lease expired OR older than 24h. Mirrors `isStaleLane` in the
* lane CLI (lane.ts).
*/
export declare function isLaneStale(lane: LaneMeta, now: number): boolean;
/**
* Classify one lane into a disposition. Pure — no engine/IO side effects.
*
* 1. **promote** — active, bound issue `closed`, lane has ops.
* 2. **drop** — active, bound issue `closed` with 0 ops, OR bound issue
* abandoned (`cancelled`/`backlog`) and lane stale.
* 3. **garden** — active, no bound issue, 0 ops, stale.
* 4. **leave** — everything else (retained).
*
* Dirty-guard is enforced by {@link gcLanes} (drop of a lane with ops requires
* `force`); the classifier reports the ideal disposition and reason.
*/
export declare function classifyLane(input: GcLaneInput): LaneGcRow;
/**
* Sweep lanes. Default is dry-run: classify everything, mutate nothing.
* With `apply`, executes dispositions (promote via engine promote path, drop
* and garden via dropLane — which archives the journal and prunes the
* worktree).
*
* Dirty-guard: a lane whose disposition is destructive is never dropped with
* ops unless `force` is set — it degrades to `leave`.
*/
export declare function gcLanes(engine: TrellisVcsEngine, opts?: LaneGcOptions): Promise<LaneGcRow[]>;
//# sourceMappingURL=lane-gc.d.ts.map