Skip to content
← Public packages

@kody/kody-factory

Forkable multi-project software factory: signals, priority queue, project UI, sweep job. Agent runners and Sentry reach it by events.

FollowFork

Files

decision.ts

19 lines · 767 B · TypeScript
type Rec = Record<string, unknown>

const CLOSE = new Set(['closed', 'deleted'])

/**
 * One comparable decision string for an issues delivery, from either path.
 * Ledger-dependent details (dropped vs noted) are left out on purpose: the
 * webhook runs first and changes the ledger, so the event path would see a
 * different "before".
 */
export function issueDecision(action: string, result: Rec): string {
	if (result.ok === false) return `error:${String(result.error ?? 'unknown')}`
	if (result.skipped) return `skip:${String(result.reason ?? '')}`
	const where = `${String(result.projectId ?? '')}:${String(result.repoRef ?? '')}`
	if (CLOSE.has(action)) return `close:${where}`
	if (action === 'reopened') return `reopen:${where}`
	return `ingest:${where}`
}