feat: lifecycle inference from the issue timeline (#5)
Fill the board's Steeping / In-review columns (and the calibration actuals) from real gitea timeline events, replacing the three-column-only v0. core (@commitea/core): - inferLifecycle(issue, events, asOf): five-column inference — closed → done; open PR ref → review; commit ref → steeping; any triage signal → triage; else diagnosis. Earliest event of each kind fixes the stage timestamp. - Derives actualWorkingDays (work-start → close) — the estimate-vs-actual the calibration fit (D3) learns from — and steepingDays (first commit → now) for the board age badge. - workingDaysBetween(): whole Mon–Fri days in [start, end), day-granular. - normalizeTimeline() + client.getIssueTimeline(): map gitea's raw timeline (label/milestone → triage, commit_ref → commit, pull_ref → pull, close, reopen), drop the rest. Paginated. app: - reconcile now fetches every issue's timeline and returns it keyed by number; threaded through the bridge → useBacklog → board/focus. - issuesToBoardColumns + scheduleFocus run inferLifecycle: real Steeping/In-review columns, steeping-age `days` badge, focus-card steeping badge. Known refinement: gitea's pull_ref fires on any PR mention, so an issue merely referenced in a PR body can read as In-review; distinguishing closing refs from mentions needs the PR link's state (later). Re-opening multi-segment actuals also deferred. Verified: 63 core tests green (15 lifecycle, incl. workingDaysBetween + the five transitions), desktop typecheck clean, 14 fixture e2e green, live spec asserts the board's Done column is populated from real events. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { createGiteaClient, normalizeIssue } from './client.js'
|
||||
import { createGiteaClient, normalizeIssue, normalizeTimeline } from './client.js'
|
||||
import { GiteaApiError, type FetchLike, type GiteaConfig, type GiteaRequestInit } from './types.js'
|
||||
|
||||
const CONFIG: GiteaConfig = {
|
||||
@@ -44,6 +44,31 @@ function stubFetch(body: unknown, status = 200): {
|
||||
return { fetch, calls }
|
||||
}
|
||||
|
||||
describe('normalizeTimeline', () => {
|
||||
it('maps known gitea event types to lifecycle signals and drops the rest', () => {
|
||||
const events = normalizeTimeline([
|
||||
{ type: 'label', created_at: '2026-01-06T09:00:00Z' },
|
||||
{ type: 'milestone', created_at: '2026-01-06T09:05:00Z' },
|
||||
{ type: 'commit_ref', created_at: '2026-01-07T12:00:00Z' },
|
||||
{ type: 'pull_ref', created_at: '2026-01-08T12:00:00Z' },
|
||||
{ type: 'comment', created_at: '2026-01-08T13:00:00Z' }, // dropped
|
||||
{ type: 'add_dependency', created_at: '2026-01-08T14:00:00Z' }, // dropped
|
||||
{ type: 'close', created_at: '2026-01-12T09:00:00Z' },
|
||||
])
|
||||
expect(events).toEqual([
|
||||
{ type: 'triage', at: '2026-01-06T09:00:00Z' },
|
||||
{ type: 'triage', at: '2026-01-06T09:05:00Z' },
|
||||
{ type: 'commit', at: '2026-01-07T12:00:00Z' },
|
||||
{ type: 'pull', at: '2026-01-08T12:00:00Z' },
|
||||
{ type: 'close', at: '2026-01-12T09:00:00Z' },
|
||||
])
|
||||
})
|
||||
|
||||
it('skips events missing a timestamp', () => {
|
||||
expect(normalizeTimeline([{ type: 'commit_ref', created_at: '' }])).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('createGiteaClient.getIssue', () => {
|
||||
it('returns a normalized, typed issue from canned JSON', async () => {
|
||||
const { fetch } = stubFetch(RAW_ISSUE)
|
||||
|
||||
Reference in New Issue
Block a user