refactor: rename 'tier' to 'level' across the codebase

- Updated WorkerState type to use 'level' instead of 'tier'.
- Modified functions related to worker state management, including parseWorkerState, emptyWorkerState, getSessionForLevel, activateWorker, and deactivateWorker to reflect the new terminology.
- Adjusted health check logic to utilize 'level' instead of 'tier'.
- Refactored tick and setup tools to accommodate the change from 'tier' to 'level', including model configuration and workspace scaffolding.
- Updated tests to ensure consistency with the new 'level' terminology.
- Revised documentation and comments to reflect the changes in terminology from 'tier' to 'level'.
This commit is contained in:
Lauren ten Hoor
2026-02-11 03:04:17 +08:00
parent 1f95ad4518
commit 5df4b912c9
18 changed files with 296 additions and 278 deletions

View File

@@ -7,10 +7,10 @@
import type { Issue, StateLabel } from "../providers/provider.js";
import type { IssueProvider } from "../providers/provider.js";
import { createProvider } from "../providers/index.js";
import { selectTier } from "../model-selector.js";
import { getWorker, getSessionForTier, readProjects } from "../projects.js";
import { selectLevel } from "../model-selector.js";
import { getWorker, getSessionForLevel, readProjects } from "../projects.js";
import { dispatchTask } from "../dispatch.js";
import { ALL_TIERS, isDevTier, type Tier } from "../tiers.js";
import { DEV_LEVELS, QA_LEVELS, isDevLevel } from "../tiers.js";
// ---------------------------------------------------------------------------
// Shared constants + helpers (used by tick, work-start, auto-pickup)
@@ -20,9 +20,22 @@ export const DEV_LABELS: StateLabel[] = ["To Do", "To Improve"];
export const QA_LABELS: StateLabel[] = ["To Test"];
export const PRIORITY_ORDER: StateLabel[] = ["To Improve", "To Test", "To Do"];
export function detectTierFromLabels(labels: string[]): Tier | null {
export function detectLevelFromLabels(labels: string[]): string | null {
const lower = labels.map((l) => l.toLowerCase());
return (ALL_TIERS as readonly string[]).find((t) => lower.includes(t)) as Tier | undefined ?? null;
// Match role.level labels (e.g., "dev.senior", "qa.reviewer")
for (const l of lower) {
const dot = l.indexOf(".");
if (dot === -1) continue;
const role = l.slice(0, dot);
const level = l.slice(dot + 1);
if (role === "dev" && (DEV_LEVELS as readonly string[]).includes(level)) return level;
if (role === "qa" && (QA_LEVELS as readonly string[]).includes(level)) return level;
}
// Fallback: plain level name
const all = [...DEV_LEVELS, ...QA_LEVELS] as readonly string[];
return all.find((l) => lower.includes(l)) ?? null;
}
export function detectRoleFromLabel(label: StateLabel): "dev" | "qa" | null {
@@ -77,7 +90,7 @@ export type TickAction = {
issueTitle: string;
issueUrl: string;
role: "dev" | "qa";
tier: string;
level: string;
sessionAction: "spawn" | "send";
announcement: string;
};
@@ -145,14 +158,14 @@ export async function projectTick(opts: {
const { issue, label: currentLabel } = next;
const targetLabel: StateLabel = role === "dev" ? "Doing" : "Testing";
// Tier selection: label → heuristic
const selectedTier = resolveTierForIssue(issue, role);
// Level selection: label → heuristic
const selectedLevel = resolveLevelForIssue(issue, role);
if (dryRun) {
pickups.push({
project: project.name, groupId, issueId: issue.iid, issueTitle: issue.title, issueUrl: issue.web_url,
role, tier: selectedTier,
sessionAction: getSessionForTier(worker, selectedTier) ? "send" : "spawn",
role, level: selectedLevel,
sessionAction: getSessionForLevel(worker, selectedLevel) ? "send" : "spawn",
announcement: `[DRY RUN] Would pick up #${issue.iid}`,
});
} else {
@@ -160,13 +173,13 @@ export async function projectTick(opts: {
const dr = await dispatchTask({
workspaceDir, agentId, groupId, project: fresh, issueId: issue.iid,
issueTitle: issue.title, issueDescription: issue.description ?? "", issueUrl: issue.web_url,
role, tier: selectedTier, fromLabel: currentLabel, toLabel: targetLabel,
role, level: selectedLevel, fromLabel: currentLabel, toLabel: targetLabel,
transitionLabel: (id, from, to) => provider.transitionLabel(id, from as StateLabel, to as StateLabel),
pluginConfig, sessionKey,
});
pickups.push({
project: project.name, groupId, issueId: issue.iid, issueTitle: issue.title, issueUrl: issue.web_url,
role, tier: dr.tier, sessionAction: dr.sessionAction, announcement: dr.announcement,
role, level: dr.level, sessionAction: dr.sessionAction, announcement: dr.announcement,
});
} catch (err) {
skipped.push({ role, reason: `Dispatch failed: ${(err as Error).message}` });
@@ -184,16 +197,16 @@ export async function projectTick(opts: {
// ---------------------------------------------------------------------------
/**
* Determine the tier for an issue based on labels, role overrides, and heuristic fallback.
* Determine the level for an issue based on labels, role overrides, and heuristic fallback.
*/
function resolveTierForIssue(issue: Issue, role: "dev" | "qa"): string {
const labelTier = detectTierFromLabels(issue.labels);
if (labelTier) {
// QA role but label specifies a dev tier → heuristic picks the right QA tier
if (role === "qa" && isDevTier(labelTier)) return selectTier(issue.title, issue.description ?? "", role).tier;
// DEV role but label specifies a QA tier → heuristic picks the right dev tier
if (role === "dev" && !isDevTier(labelTier)) return selectTier(issue.title, issue.description ?? "", role).tier;
return labelTier;
function resolveLevelForIssue(issue: Issue, role: "dev" | "qa"): string {
const labelLevel = detectLevelFromLabels(issue.labels);
if (labelLevel) {
// QA role but label specifies a dev level → heuristic picks the right QA level
if (role === "qa" && isDevLevel(labelLevel)) return selectLevel(issue.title, issue.description ?? "", role).level;
// DEV role but label specifies a QA level → heuristic picks the right dev level
if (role === "dev" && !isDevLevel(labelLevel)) return selectLevel(issue.title, issue.description ?? "", role).level;
return labelLevel;
}
return selectTier(issue.title, issue.description ?? "", role).tier;
return selectLevel(issue.title, issue.description ?? "", role).level;
}