/**
 * Lifecycle inference, v0 — the coarse column an issue sits in, derived from
 * *only* what a single issues-list read gives us (state, labels, milestone).
 *
 * The real five-column inference (P1-5) needs the issue timeline: first
 * branch/commit ref → Steeping, PR opened → In review, PR merged → Deploy.
 * Until that lands, v0 can only place three columns honestly; `steeping` and
 * `review` stay empty rather than guess. Board renders all five columns and
 * fills the middle two once the event stream is available.
 */

import type { GiteaIssue } from '../gitea/types.js'

export type LifecycleColumn = 'diagnosis' | 'triage' | 'steeping' | 'review' | 'done'

export const LIFECYCLE_COLUMNS: readonly LifecycleColumn[] = [
  'diagnosis',
  'triage',
  'steeping',
  'review',
  'done',
]

/**
 * Closed → done. Open with any human intent applied (a label or a milestone)
 * → triage. Open and bare → diagnosis. Never returns steeping/review in v0.
 */
export function inferColumnV0(issue: Pick<GiteaIssue, 'state' | 'labels' | 'milestone'>): LifecycleColumn {
  if (issue.state === 'closed') return 'done'
  const hasIntent = issue.labels.length > 0 || issue.milestone !== null
  return hasIntent ? 'triage' : 'diagnosis'
}
