Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: rename scheduled audit to ui-lifecycle

[._.]/ Adam Eivyf03ac5d6ace8
diff --git a/.quality.json b/.quality.json
index 813705699e..0fba65f50d 100644
--- a/.quality.json
+++ b/.quality.json
@@ -21,7 +21,7 @@
"module-hygiene",
"observability",
"performance",
- "react-lifecycle",
+ "ui-lifecycle",
"security",
"simplify",
"test-coverage",
diff --git a/docs/features/scheduled-audit-organization.md b/docs/features/scheduled-audit-organization.md
index c8b1a85e97..0a52bb8262 100644
--- a/docs/features/scheduled-audit-organization.md
+++ b/docs/features/scheduled-audit-organization.md
@@ -11,7 +11,7 @@ better-test-coverage, better-performance, better-accessibility,
better-documentation, better-ui-bugs, better-mobile-responsive,
better-error-handling, better-typing, better-console-errors, better-ux,
better-data-safety, better-simplify, better-module-hygiene, better-api-contract,
-better-react-lifecycle, better-observability, and better-copy. The six existing
+better-ui-lifecycle, better-observability, and better-copy. The six existing
better-* names remain unchanged.
Operational tasks (claims, review pipelines, reconciliation, releases, repo sync),
diff --git a/docs/features/self-improvement-audits.md b/docs/features/self-improvement-audits.md
index 5a24427093..3056452ab4 100644
--- a/docs/features/self-improvement-audits.md
+++ b/docs/features/self-improvement-audits.md
@@ -43,7 +43,7 @@ the operator's live checkout.
| `simplify` | Dead code, duplication, YAGNI | `code-quality`, `simplify` | file | |
| `module-hygiene` | Responsibility boundaries, reuse, discoverability | `code-quality`, `module-hygiene` | file | yes |
| `api-contract` | Route validation, client/server drift, envelopes | `api-contract` | file | |
-| `react-lifecycle` | UI resource lifetimes, stale data, async ordering, state continuity | `react-lifecycle` | file | |
+| `ui-lifecycle` | UI resource lifetimes, stale data, async ordering, state continuity | `ui-lifecycle` | file | |
| `observability` | Silent catches, log noise, missing error context | `code-quality`, `observability` | file | |
| `copy` | User-facing wording | `ux`, `copy` | file | |
| `better-complexity` | Counted branching per function | `code-quality`, `complexity` | file | yes |
@@ -71,9 +71,8 @@ problem:
- **Defects are split four ways.** `better-runtime-safety` reads source for
latent defects; `console-errors` collects what actually errors at runtime;
`error-handling` owns the failure path once something goes wrong; and
- `react-lifecycle` owns UI lifecycle and state correctness across UI runtimes.
- Its legacy task ID and tracking labels remain stable; its display name is
- **UI lifecycle & state** and its checks follow the target app’s own semantics.
+ `ui-lifecycle` owns UI lifecycle and state correctness across UI runtimes.
+ Its checks follow the target app’s own semantics.
- **Tests are split two ways.** `test-coverage` owns the gaps;
`better-test-quality` owns the tests that already exist.
diff --git a/scripts/migrations/408-rename-ui-lifecycle-task.js b/scripts/migrations/408-rename-ui-lifecycle-task.js
new file mode 100644
index 0000000000..e09cd4885b
--- /dev/null
+++ b/scripts/migrations/408-rename-ui-lifecycle-task.js
@@ -0,0 +1,185 @@
+/**
+ * Rename the framework-neutral UI lifecycle audit while preserving schedules,
+ * app overrides, pending runs, execution history, and run-order dependencies.
+ *
+ * The task used to be stored as `react-lifecycle`; all newly written task IDs
+ * use `ui-lifecycle`. These values are operator-owned schedule records, so the
+ * rename merges into the new key when both are present and only then removes
+ * the retired key. The migration is idempotent and does not dispatch work.
+ */
+
+import { readFile } from 'fs/promises';
+import { join } from 'path';
+import { atomicWrite } from '../../server/lib/fileCore.js';
+
+const SCHEDULE_PATH = join('data', 'cos', 'task-schedule.json');
+const APPS_PATH = join('data', 'apps.json');
+const LEGACY_TASK = 'react-lifecycle';
+const CURRENT_TASK = 'ui-lifecycle';
+const LEGACY_EXECUTION = `task:${LEGACY_TASK}`;
+const CURRENT_EXECUTION = `task:${CURRENT_TASK}`;
+
+const isObject = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
+const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
+const renameTaskType = (taskType) => taskType === LEGACY_TASK ? CURRENT_TASK : taskType;
+
+async function readJson(rootDir, relPath) {
+ const fullPath = join(rootDir, relPath);
+ const raw = await readFile(fullPath, 'utf-8').catch((err) => {
+ if (err.code === 'ENOENT') return null;
+ throw err;
+ });
+ if (raw == null) return null;
+ try {
+ return { fullPath, value: JSON.parse(raw) };
+ } catch (err) {
+ throw new Error(`${relPath} is not valid JSON (${err.message}) — repair it and re-run migrations`);
+ }
+}
+
+const writeJson = (fullPath, value) => atomicWrite(fullPath, `${JSON.stringify(value, null, 2)}\n`);
+
+function mergeConfig(legacy, current) {
+ const oldConfig = isObject(legacy) ? legacy : {};
+ const newConfig = isObject(current) ? current : {};
+ const merged = { ...oldConfig, ...newConfig };
+ if (hasOwn(newConfig, 'taskMetadata') && newConfig.taskMetadata === null) {
+ merged.taskMetadata = null;
+ } else if (isObject(oldConfig.taskMetadata) || isObject(newConfig.taskMetadata)) {
+ merged.taskMetadata = {
+ ...(isObject(oldConfig.taskMetadata) ? oldConfig.taskMetadata : {}),
+ ...(isObject(newConfig.taskMetadata) ? newConfig.taskMetadata : {}),
+ };
+ }
+ if (Array.isArray(merged.runAfter)) {
+ merged.runAfter = [...new Set(merged.runAfter.map(renameTaskType))];
+ }
+ return merged;
+}
+
+function newerTimestamp(left, right) {
+ if (!left) return right || left;
+ if (!right) return left;
+ const leftTime = Date.parse(left);
+ const rightTime = Date.parse(right);
+ if (Number.isFinite(leftTime) && Number.isFinite(rightTime)) return rightTime > leftTime ? right : left;
+ if (Number.isFinite(rightTime)) return right;
+ if (Number.isFinite(leftTime)) return left;
+ return right;
+}
+
+function mergeExecutionRecord(legacy, current) {
+ const oldRecord = isObject(legacy) ? legacy : {};
+ const newRecord = isObject(current) ? current : {};
+ const merged = { ...oldRecord, ...newRecord };
+ if (Number.isFinite(oldRecord.count) || Number.isFinite(newRecord.count)) {
+ merged.count = (Number.isFinite(oldRecord.count) ? oldRecord.count : 0)
+ + (Number.isFinite(newRecord.count) ? newRecord.count : 0);
+ }
+ if (oldRecord.lastRun || newRecord.lastRun) {
+ merged.lastRun = newerTimestamp(oldRecord.lastRun, newRecord.lastRun);
+ }
+
+ if (isObject(oldRecord.perApp) || isObject(newRecord.perApp)) {
+ merged.perApp = { ...(isObject(oldRecord.perApp) ? oldRecord.perApp : {}) };
+ for (const [appId, record] of Object.entries(isObject(newRecord.perApp) ? newRecord.perApp : {})) {
+ merged.perApp[appId] = mergeExecutionRecord(merged.perApp[appId], record);
+ }
+ }
+ return merged;
+}
+
+function migrateSchedule(schedule) {
+ if (!isObject(schedule)) return { changed: false, pendingRequests: 0 };
+ let changed = false;
+ let pendingRequests = 0;
+
+ if (isObject(schedule.tasks)) {
+ if (hasOwn(schedule.tasks, LEGACY_TASK)) {
+ schedule.tasks[CURRENT_TASK] = mergeConfig(schedule.tasks[LEGACY_TASK], schedule.tasks[CURRENT_TASK]);
+ delete schedule.tasks[LEGACY_TASK];
+ changed = true;
+ }
+ for (const config of Object.values(schedule.tasks)) {
+ if (!isObject(config) || !Array.isArray(config.runAfter)) continue;
+ const renamed = [...new Set(config.runAfter.map(renameTaskType))];
+ if (renamed.some((taskType, index) => taskType !== config.runAfter[index])
+ || renamed.length !== config.runAfter.length) {
+ config.runAfter = renamed;
+ changed = true;
+ }
+ }
+ }
+
+ if (isObject(schedule.executions) && hasOwn(schedule.executions, LEGACY_EXECUTION)) {
+ schedule.executions[CURRENT_EXECUTION] = mergeExecutionRecord(
+ schedule.executions[LEGACY_EXECUTION],
+ schedule.executions[CURRENT_EXECUTION],
+ );
+ delete schedule.executions[LEGACY_EXECUTION];
+ changed = true;
+ }
+
+ if (Array.isArray(schedule.onDemandRequests)) {
+ for (const request of schedule.onDemandRequests) {
+ if (request?.taskType !== LEGACY_TASK) continue;
+ request.taskType = CURRENT_TASK;
+ pendingRequests += 1;
+ changed = true;
+ }
+ }
+
+ return { changed, pendingRequests };
+}
+
+function migrateApp(app) {
+ if (!isObject(app)) return false;
+ let changed = false;
+
+ if (isObject(app.taskTypeOverrides) && hasOwn(app.taskTypeOverrides, LEGACY_TASK)) {
+ app.taskTypeOverrides[CURRENT_TASK] = mergeConfig(
+ app.taskTypeOverrides[LEGACY_TASK],
+ app.taskTypeOverrides[CURRENT_TASK],
+ );
+ delete app.taskTypeOverrides[LEGACY_TASK];
+ changed = true;
+ }
+
+ if (Array.isArray(app.disabledTaskTypes)) {
+ const renamed = [...new Set(app.disabledTaskTypes.map(renameTaskType))];
+ if (renamed.some((taskType, index) => taskType !== app.disabledTaskTypes[index])
+ || renamed.length !== app.disabledTaskTypes.length) {
+ app.disabledTaskTypes = renamed;
+ changed = true;
+ }
+ }
+
+ return changed;
+}
+
+export default {
+ async up({ rootDir }) {
+ let schedules = 0;
+ let pendingRequests = 0;
+ const storedSchedule = await readJson(rootDir, SCHEDULE_PATH);
+ if (storedSchedule) {
+ const result = migrateSchedule(storedSchedule.value);
+ if (result.changed) {
+ await writeJson(storedSchedule.fullPath, storedSchedule.value);
+ schedules = 1;
+ pendingRequests = result.pendingRequests;
+ }
+ }
+
+ const storedApps = await readJson(rootDir, APPS_PATH);
+ let migratedApps = 0;
+ if (isObject(storedApps?.value?.apps)) {
+ for (const app of Object.values(storedApps.value.apps)) {
+ if (migrateApp(app)) migratedApps += 1;
+ }
+ if (migratedApps) await writeJson(storedApps.fullPath, storedApps.value);
+ }
+
+ return { schedules, pendingRequests, migratedApps };
+ },
+};
diff --git a/scripts/migrations/408-rename-ui-lifecycle-task.test.js b/scripts/migrations/408-rename-ui-lifecycle-task.test.js
new file mode 100644
index 0000000000..ea7336f047
--- /dev/null
+++ b/scripts/migrations/408-rename-ui-lifecycle-task.test.js
@@ -0,0 +1,105 @@
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
+import { tmpdir } from 'os';
+import { join } from 'path';
+
+import migration from './408-rename-ui-lifecycle-task.js';
+
+const writeJson = (path, value) => writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
+const readJson = (path) => JSON.parse(readFileSync(path, 'utf8'));
+
+describe('migration 408 — rename the UI lifecycle task', () => {
+ let rootDir;
+ let schedulePath;
+ let appsPath;
+
+ beforeEach(() => {
+ rootDir = mkdtempSync(join(tmpdir(), 'migration-408-'));
+ mkdirSync(join(rootDir, 'data', 'cos'), { recursive: true });
+ schedulePath = join(rootDir, 'data', 'cos', 'task-schedule.json');
+ appsPath = join(rootDir, 'data', 'apps.json');
+ });
+
+ afterEach(() => rmSync(rootDir, { recursive: true, force: true }));
+
+ it('renames saved task state and merges collisions without losing settings or history', async () => {
+ writeJson(schedulePath, {
+ version: 2,
+ tasks: {
+ 'react-lifecycle': {
+ enabled: true,
+ providerId: 'legacy-provider',
+ prompt: 'custom prompt',
+ taskMetadata: { fileIssues: true, useWorktree: false },
+ },
+ 'ui-lifecycle': {
+ enabled: false,
+ model: 'current-model',
+ taskMetadata: { openPR: false },
+ },
+ 'another-task': { runAfter: ['security', 'react-lifecycle'] },
+ },
+ executions: {
+ 'task:react-lifecycle': {
+ count: 2,
+ lastRun: '2026-09-20T00:00:00.000Z',
+ perApp: { 'app-a': { count: 1, lastRun: '2026-09-19T00:00:00.000Z' } },
+ },
+ 'task:ui-lifecycle': {
+ count: 3,
+ lastRun: '2026-09-21T00:00:00.000Z',
+ perApp: { 'app-a': { count: 2, lastRun: '2026-09-21T00:00:00.000Z' } },
+ },
+ },
+ onDemandRequests: [{ id: 'pending-1', taskType: 'react-lifecycle' }],
+ });
+ writeJson(appsPath, {
+ apps: {
+ 'app-a': {
+ taskTypeOverrides: {
+ 'react-lifecycle': { enabled: true, interval: 'weekly', taskMetadata: { fileIssues: true } },
+ 'ui-lifecycle': { enabled: false, taskMetadata: { useWorktree: false } },
+ },
+ },
+ 'app-b': { disabledTaskTypes: ['react-lifecycle', 'security', 'ui-lifecycle'] },
+ },
+ });
+
+ expect(await migration.up({ rootDir })).toEqual({ schedules: 1, pendingRequests: 1, migratedApps: 2 });
+
+ const schedule = readJson(schedulePath);
+ expect(schedule.tasks).not.toHaveProperty('react-lifecycle');
+ expect(schedule.tasks['ui-lifecycle']).toMatchObject({
+ enabled: false,
+ providerId: 'legacy-provider',
+ model: 'current-model',
+ prompt: 'custom prompt',
+ taskMetadata: { fileIssues: true, useWorktree: false, openPR: false },
+ });
+ expect(schedule.tasks['another-task'].runAfter).toEqual(['security', 'ui-lifecycle']);
+ expect(schedule.executions).not.toHaveProperty('task:react-lifecycle');
+ expect(schedule.executions['task:ui-lifecycle']).toMatchObject({
+ count: 5,
+ lastRun: '2026-09-21T00:00:00.000Z',
+ perApp: { 'app-a': { count: 3, lastRun: '2026-09-21T00:00:00.000Z' } },
+ });
+ expect(schedule.onDemandRequests[0].taskType).toBe('ui-lifecycle');
+
+ const apps = readJson(appsPath).apps;
+ expect(apps['app-a'].taskTypeOverrides).not.toHaveProperty('react-lifecycle');
+ expect(apps['app-a'].taskTypeOverrides['ui-lifecycle']).toEqual({
+ enabled: false,
+ interval: 'weekly',
+ taskMetadata: { fileIssues: true, useWorktree: false },
+ });
+ expect(apps['app-b'].disabledTaskTypes).toEqual(['ui-lifecycle', 'security']);
+ });
+
+ it('is idempotent when the active schedule has already been renamed', async () => {
+ writeJson(schedulePath, { version: 2, tasks: { 'ui-lifecycle': { enabled: false } } });
+ writeJson(appsPath, { apps: { 'app-a': { taskTypeOverrides: { 'ui-lifecycle': { enabled: true } } } } });
+
+ expect(await migration.up({ rootDir })).toEqual({ schedules: 0, pendingRequests: 0, migratedApps: 0 });
+ expect(readJson(schedulePath).tasks).toEqual({ 'ui-lifecycle': { enabled: false } });
+ });
+});
diff --git a/scripts/regen-prompt-integrity-snapshot.test.js b/scripts/regen-prompt-integrity-snapshot.test.js
index 01b8404db2..5d350c8905 100644
--- a/scripts/regen-prompt-integrity-snapshot.test.js
+++ b/scripts/regen-prompt-integrity-snapshot.test.js
@@ -100,6 +100,31 @@ describe('advancePromptIntegritySnapshot', () => {
expect(snapshot.PREVIOUS_DEFAULT_PROMPTS).toEqual({ audit: [V1] });
});
+ it('moves current and retired hashes with a renamed prompt key', () => {
+ const oldBody = 'old lifecycle body';
+ const oldCurrent = hashPromptBody(oldBody);
+ const oldRetired = 'a'.repeat(32);
+ const renamedSource = {
+ DEFAULT_TASK_PROMPTS: { 'ui-lifecycle': 'new lifecycle body' },
+ PROMPT_VERSIONS: { 'ui-lifecycle': 2 },
+ REFERENCE_WATCH_AUDITED_VERSION: 3,
+ };
+ const committed = {
+ ...buildPromptIntegritySnapshot({
+ DEFAULT_TASK_PROMPTS: { 'react-lifecycle': oldBody },
+ PROMPT_VERSIONS: { 'react-lifecycle': 2 },
+ REFERENCE_WATCH_AUDITED_VERSION: 3,
+ }),
+ PREVIOUS_DEFAULT_PROMPTS: { 'react-lifecycle': [oldRetired] },
+ };
+
+ const { snapshot, drift, dropped } = advancePromptIntegritySnapshot(committed, renamedSource);
+
+ expect({ drift, dropped }).toEqual({ drift: [], dropped: [] });
+ expect(snapshot.PREVIOUS_DEFAULT_PROMPTS).toEqual({ 'ui-lifecycle': [oldRetired, oldCurrent] });
+ expect(snapshot.PREVIOUS_DEFAULT_PROMPTS).not.toHaveProperty('react-lifecycle');
+ });
+
it('is a no-op on an unchanged source, byte for byte', () => {
const committed = committedFor(source({ audit: 'audit v2 body', auditVersion: 2 }), { audit: [V1] });
const { snapshot, retired, drift, dropped } = advancePromptIntegritySnapshot(committed, source({ audit: 'audit v2 body', auditVersion: 2 }));
diff --git a/server/lib/auditCatalog.js b/server/lib/auditCatalog.js
index e9fa685b7d..db48ecbcea 100644
--- a/server/lib/auditCatalog.js
+++ b/server/lib/auditCatalog.js
@@ -99,6 +99,12 @@ If you find additional problems, mention them in the summary — do not expand s
*/
export const AUDIT_REPO_CAPABILITIES = Object.freeze(['ui', 'typescript', 'tests', 'dependencies', 'api']);
+/** Read aliases kept only for in-flight tasks and historical quality records. */
+export const LEGACY_AUDIT_TASK_TYPE_ALIASES = Object.freeze({ 'react-lifecycle': 'ui-lifecycle' });
+export const normalizeAuditTaskType = (taskType) => Object.hasOwn(LEGACY_AUDIT_TASK_TYPE_ALIASES, taskType)
+ ? LEGACY_AUDIT_TASK_TYPE_ALIASES[taskType]
+ : taskType;
+
/** Why an app lacking the capability is not worth scheduling that audit for. */
export const AUDIT_CAPABILITY_MISSING_REASON = Object.freeze({
ui: 'no user interface found in this repository',
@@ -330,17 +336,16 @@ export const AUDIT_DEFINITIONS = Object.freeze({
noun: 'API contract finding(s)',
}),
},
- // Legacy IDs and filing labels preserve saved schedules and audit history.
- 'react-lifecycle': {
- quotaBurnId: 'react-lifecycle-audit',
+ 'ui-lifecycle': {
+ quotaBurnId: 'ui-lifecycle-audit',
label: 'UI lifecycle & state',
description: 'UI lifecycle audit — configurable: file issues (default) or implement fixes',
defaultFileIssues: true,
requiresCapability: 'ui',
filing: filing({
- slugPrefix: 'react-lifecycle-',
- label: 'react-lifecycle-audit',
- issueLabel: 'react-lifecycle',
+ slugPrefix: 'ui-lifecycle-',
+ label: 'ui-lifecycle-audit',
+ issueLabel: 'ui-lifecycle',
labelDescription: 'Proposed from a UI lifecycle/state audit',
noun: 'UI lifecycle finding(s)',
}),
@@ -492,7 +497,7 @@ export const AUDIT_TASK_TYPE_LIST = Object.freeze([...AUDIT_TASK_TYPES]);
* @returns {boolean} True if registered in AUDIT_DEFINITIONS
*/
export function isAuditTaskType(taskType) {
- return AUDIT_TASK_TYPES.has(taskType);
+ return AUDIT_TASK_TYPES.has(normalizeAuditTaskType(taskType));
}
/**
@@ -502,7 +507,7 @@ export function isAuditTaskType(taskType) {
* @returns {boolean} True if the audit defaults to filing issues rather than fixing
*/
export function defaultFileIssuesFor(taskType) {
- return AUDIT_DEFINITIONS[taskType]?.defaultFileIssues === true;
+ return AUDIT_DEFINITIONS[normalizeAuditTaskType(taskType)]?.defaultFileIssues === true;
}
/**
@@ -513,7 +518,7 @@ export function defaultFileIssuesFor(taskType) {
* @returns {boolean} True when live-checkout remediation is forbidden
*/
export function auditDoWorkRequiresWorktree(taskType) {
- return AUDIT_DEFINITIONS[taskType]?.doWorkRequiresWorktree === true;
+ return AUDIT_DEFINITIONS[normalizeAuditTaskType(taskType)]?.doWorkRequiresWorktree === true;
}
/**
@@ -606,7 +611,7 @@ export const FILE_ISSUES_DELIVERY_SETTINGS = Object.freeze({
* @returns {string|null} A member of AUDIT_REPO_CAPABILITIES, or null
*/
export function auditCapabilityRequirement(taskType) {
- return AUDIT_DEFINITIONS[taskType]?.requiresCapability || null;
+ return AUDIT_DEFINITIONS[normalizeAuditTaskType(taskType)]?.requiresCapability || null;
}
/**
@@ -616,7 +621,7 @@ export function auditCapabilityRequirement(taskType) {
* @returns {object|null} Filing preset metadata (slugPrefix, label, issueLabel, planItemBody, etc.) or null
*/
export function getAuditFilingPreset(taskType) {
- return AUDIT_DEFINITIONS[taskType]?.filing || null;
+ return AUDIT_DEFINITIONS[normalizeAuditTaskType(taskType)]?.filing || null;
}
/**
@@ -670,7 +675,7 @@ export const DO_BETTER_LENS_COVERAGE = Object.freeze({
dry: ['simplify'],
architecture: ['module-hygiene', 'api-contract'],
'bugs-perf': ['better-runtime-safety', 'performance', 'error-handling', 'observability'],
- 'stack-specific': ['react-lifecycle', 'accessibility', 'data-safety', 'security'],
+ 'stack-specific': ['ui-lifecycle', 'accessibility', 'data-safety', 'security'],
deps: ['better-dependency-freedom', 'security'],
tests: ['test-coverage', 'better-test-quality'],
ux: ['ux', 'mobile-responsive', 'copy'],
@@ -680,11 +685,12 @@ export const DO_BETTER_LENS_COVERAGE = Object.freeze({
/** Display metadata is derived, so upgrades never rewrite durable task IDs. */
export function getAuditScheduleMetadata(taskType) {
- if (!isAuditTaskType(taskType)) return { displayName: taskType, defaultLabels: [] };
+ const canonicalType = normalizeAuditTaskType(taskType);
+ if (!isAuditTaskType(canonicalType)) return { displayName: taskType, defaultLabels: [] };
const lenses = Object.entries(DO_BETTER_LENS_COVERAGE)
- .filter(([, types]) => types.includes(taskType)).map(([lens]) => lens);
+ .filter(([, types]) => types.includes(canonicalType)).map(([lens]) => lens);
return {
- displayName: taskType.startsWith('better-') ? taskType : `better-${taskType}`,
+ displayName: canonicalType.startsWith('better-') ? canonicalType : `better-${canonicalType}`,
defaultLabels: ['codebase-improvement', 'slashdo', ...lenses],
};
}
diff --git a/server/lib/auditCatalog.test.js b/server/lib/auditCatalog.test.js
index 0604075bc8..c8c4cc7502 100644
--- a/server/lib/auditCatalog.test.js
+++ b/server/lib/auditCatalog.test.js
@@ -8,6 +8,8 @@ import {
AUDIT_REPO_CAPABILITIES,
AUDIT_CAPABILITY_MISSING_REASON,
auditCapabilityRequirement,
+ getAuditFilingPreset,
+ getAuditScheduleMetadata,
FILE_ISSUES_MODE_CONTRACT,
DO_WORK_MODE_CONTRACT,
isAuditTaskType,
@@ -105,6 +107,20 @@ describe('AUDIT_DEFINITIONS', () => {
expect(AUDIT_TASK_TYPE_LIST).toEqual([...AUDIT_TASK_TYPES]);
expect(AUDIT_TASK_TYPE_LIST.every(isAuditTaskType)).toBe(true);
});
+
+ it('files UI lifecycle findings under framework-neutral names', () => {
+ expect(AUDIT_DEFINITIONS['ui-lifecycle'].filing).toMatchObject({
+ slugPrefix: 'ui-lifecycle-',
+ issueLabel: 'ui-lifecycle',
+ label: 'ui-lifecycle-audit',
+ });
+ expect(AUDIT_DEFINITIONS).not.toHaveProperty('react-lifecycle');
+ expect(QUOTA_BURN_PROMPT_PRESETS.map((preset) => preset.id)).toContain('ui-lifecycle-audit');
+ expect(isAuditTaskType('react-lifecycle')).toBe(true);
+ expect(AUDIT_TASK_TYPES.has('react-lifecycle')).toBe(false);
+ expect(getAuditFilingPreset('react-lifecycle').slugPrefix).toBe('ui-lifecycle-');
+ expect(getAuditScheduleMetadata('react-lifecycle').displayName).toBe('better-ui-lifecycle');
+ });
});
describe('isFileIssuesMode', () => {
diff --git a/server/lib/auditQuality.js b/server/lib/auditQuality.js
index fb5c3d403f..400930936a 100644
--- a/server/lib/auditQuality.js
+++ b/server/lib/auditQuality.js
@@ -1,5 +1,5 @@
import { z } from 'zod';
-import { AUDIT_DEFINITIONS } from './auditCatalog.js';
+import { AUDIT_DEFINITIONS, normalizeAuditTaskType } from './auditCatalog.js';
import { safeJSONParse } from './jsonIo.js';
const REPORT_PREFIX = 'QUALITY_AUDIT_JSON: ';
@@ -22,7 +22,7 @@ export const AUDIT_DISCOVERY = Object.freeze({
simplify: 'Scan source exports, callers and repeated blocks across the repository; rank proven dead subsystems and duplicated behavior by maintenance cost and drift.',
'module-hygiene': 'Inventory module sizes, imports, responsibilities and catalogs across source roots; inspect the largest responsibility tangles and most reused missing abstractions.',
'api-contract': 'Inventory all routes, schemas and clients; compare request/response and version contracts, prioritizing destructive writes and widely consumed APIs.',
- 'react-lifecycle': 'Identify the UI runtime, then scan resource lifetimes, subscriptions, async state updates and shared state across views; rank resource leaks, stale writes and corrupted user state.',
+ 'ui-lifecycle': 'Identify the UI runtime, then scan resource lifetimes, subscriptions, async state updates and shared state across views; rank resource leaks, stale writes and corrupted user state.',
observability: 'Inventory critical workflows and their failure/status signals; rank invisible data loss, silent failures and operations that cannot be diagnosed.',
copy: 'Inventory shared messages, destructive confirmations, setup and empty/error screens; rank wording that causes wrong actions or prevents task completion.',
'better-complexity': 'Run an available language-aware complexity analyzer over all first-party source roots. Otherwise use repository-wide branching searches to shortlist functions, then count decision points manually. Publish the top measured functions and counts; file length is only a discovery hint.',
@@ -34,18 +34,19 @@ export const AUDIT_DISCOVERY = Object.freeze({
});
export function auditQualityInstructions(taskType) {
- if (!Object.hasOwn(AUDIT_DEFINITIONS, taskType)) return '';
+ const category = normalizeAuditTaskType(taskType);
+ if (!Object.hasOwn(AUDIT_DEFINITIONS, category)) return '';
return `## Repository-wide discovery, worst offender first, and quality assessment
This contract overrides narrower slice-selection or ranking advice in the mission, including customized prompts. Preserve the selected file-issues/fix mode and documented non-issues.
1. Inventory all first-party source roots with git ls-files or rg --files, excluding vendored/generated/build/dependency output. Do a cheap repository-wide signal scan BEFORE choosing where to investigate. Do not deep-read the entire repository.
-2. Category search: ${AUDIT_DISCOVERY[taskType]}
+2. Category search: ${AUDIT_DISCOVERY[category]}
3. Rank at least the top five candidates (or all if fewer), with paths, measured signals, impact, reach, confidence and why higher candidates win. Validate the top candidates through callers, tests and relevant history before filing or fixing. Severity and user impact outrank ease, small scope and recency. Churn and fan-in break ties; inactivity alone never dismisses a severe offender. If the raw worst is exempt, already filed or not actionable, report why and continue down the ranking. Existing unresolved issues still count against quality. Never pick a nit while a verified major problem remains actionable.
4. Keep investigation bounded after this scan. Report scanned roots, tools/commands, candidate ranking, exclusions, reviewed paths, unreviewed inventory and stopping reason. If tools or budget prevent broad discovery, report partial coverage, never claim a global worst or a clean repository.
5. Assess the PRE-FIX codebase for this category on 0–100 (higher is healthier): 90–100 no material defect found after broad evidence; 70–89 localized moderate debt; 40–69 significant recurring or widespread problems; 10–39 severe/core-workflow defects; 0–9 pervasive critical failure. Score the category, not the agent's performance or issue count. Explain the score using severity, prevalence and concrete evidence. Do not award points merely for filing or fixing this run. Use score:null for unavailable or inapplicable assessment; zero is a real score.
6. Score the worst finding's severity separately on 1–10: 1–3 minor localized impact, 4–6 material recurring cost, 7–8 major workflow/reliability impact, 9–10 critical data/security/availability failure. Use 0 only when no material finding was verified. List this severity for every finding in the narrative.
7. Include exactly one single-line QUALITY_AUDIT_JSON: {...} in your completion sentinel summary AND final response, with no secrets or personal data. Replace the example values with observed evidence. The category is fixed to this task; do not rate other categories. Keep ordinary completion/PR instructions and summaries too.
-QUALITY_AUDIT_JSON: {"version":1,"category":"${taskType}","score":null,"worstSeverity":0,"coverage":"unavailable","confidence":"low","summary":"Explain the assessment and strongest evidence","scannedFiles":0,"totalFiles":0}
+QUALITY_AUDIT_JSON: {"version":1,"category":"${category}","score":null,"worstSeverity":0,"coverage":"unavailable","confidence":"low","summary":"Explain the assessment and strongest evidence","scannedFiles":0,"totalFiles":0}
Allowed coverage: broad, partial, unavailable, not-applicable. Allowed confidence: low, medium, high. scannedFiles counts files actually included in the category signal scan; totalFiles is the eligible inventory. Broad requires the whole inventory to be scanned (deep review remains bounded). Partial scores are provisional and excluded from the overall score. If unavailable or not-applicable, score must be null and explain why. Even a zero-finding audit returns this assessment.`;
}
@@ -61,7 +62,8 @@ export const appListQuerySchema = appQualityQuerySchema.extend({
export const auditQualityReportSchema = z.object({
version: z.literal(1),
- category: z.string().refine(value => Object.hasOwn(AUDIT_DEFINITIONS, value)),
+ category: z.string().transform(normalizeAuditTaskType)
+ .refine(value => Object.hasOwn(AUDIT_DEFINITIONS, value)),
score: z.number().int().min(0).max(100).nullable(),
worstSeverity: z.number().int().min(0).max(10),
coverage: z.enum(['broad', 'partial', 'unavailable', 'not-applicable']),
@@ -78,14 +80,18 @@ export function parseAuditQualityReport(summary, category) {
const lines = summary.split(/\r?\n/).filter(line => line.startsWith(REPORT_PREFIX));
if (lines.length !== 1) return null;
const parsed = auditQualityReportSchema.safeParse(safeJSONParse(lines[0].slice(REPORT_PREFIX.length), null));
- return parsed.success && parsed.data.category === category ? parsed.data : null;
+ return parsed.success && parsed.data.category === normalizeAuditTaskType(category) ? parsed.data : null;
}
export const AUDIT_FRESHNESS_MS = 30 * 24 * 60 * 60 * 1000;
export function summarizeAppQuality(records = [], now = Date.now()) {
+ const normalizedRecords = records.map(record => ({
+ ...record,
+ category: normalizeAuditTaskType(record.category),
+ }));
const categories = Object.entries(AUDIT_DEFINITIONS).map(([id, definition]) => {
- const record = records.find(row => row.category === id);
+ const record = normalizedRecords.find(row => row.category === id);
const report = auditQualityReportSchema.safeParse(record?.report);
const valid = report.success && report.data.category === id;
const assessedAt = record?.assessedAt;
@@ -109,6 +115,7 @@ export function buildAppQualityHistory(records, days, now = Date.now()) {
const dayMs = 86400000;
const today = Math.floor(now / dayMs) * dayMs;
const sorted = records.filter(r => Number.isFinite(Date.parse(r.assessedAt)))
+ .map(record => ({ ...record, category: normalizeAuditTaskType(record.category) }))
.sort(compareQualityRecords);
const latest = new Map();
let cursor = 0;
@@ -132,7 +139,10 @@ export function buildAppQualityHistory(records, days, now = Date.now()) {
/** One newest measurement per category, with a stable run tie-break across all installs. */
export function latestQualityRecords(records) {
const latest = new Map();
- for (const record of [...records].sort(compareQualityRecords)) latest.set(record.category, record);
+ for (const record of [...records].sort(compareQualityRecords)) {
+ const normalized = { ...record, category: normalizeAuditTaskType(record.category) };
+ latest.set(normalized.category, normalized);
+ }
return [...latest.values()];
}
diff --git a/server/lib/quotaBurnPresets.js b/server/lib/quotaBurnPresets.js
index 8cd5e01343..a6239d971c 100644
--- a/server/lib/quotaBurnPresets.js
+++ b/server/lib/quotaBurnPresets.js
@@ -553,7 +553,7 @@ invalid shape, and the concrete failure that occurs.`,
}),
auditPreset({
- id: 'react-lifecycle-audit',
+ id: 'ui-lifecycle-audit',
label: 'UI lifecycle & state',
summary: 'Resource cleanup, stale data, async ordering, and state continuity in interactive UI code.',
labels: '`bug`, `area:ui`, `plan`',
diff --git a/server/lib/scheduledTaskTypes.js b/server/lib/scheduledTaskTypes.js
index 5ba7c3b4cd..83601e724d 100644
--- a/server/lib/scheduledTaskTypes.js
+++ b/server/lib/scheduledTaskTypes.js
@@ -46,10 +46,10 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [
// Quota-burn `api-contract-audit` counterpart. Route validation, client/server
// drift, status envelopes, and missing `asyncHandler`. Defaults to file-issues.
'api-contract',
- // Quota-burn `react-lifecycle-audit` counterpart. UI resource cleanup, stale
+ // Quota-burn `ui-lifecycle-audit` counterpart. UI resource cleanup, stale
// reads, and async state ordering — distinct from `ui-bugs` (console errors)
// and `accessibility`. Defaults to file-issues.
- 'react-lifecycle',
+ 'ui-lifecycle',
// Quota-burn `observability-audit` counterpart. Silent catches, log noise, and
// errors logged without the context needed to reproduce them. Files under the
// `code-quality` category and the `observability` metric label. Defaults to file-issues.
@@ -80,7 +80,7 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [
// Latent defects found by reading source: missing awaits, unhandled
// rejections, unguarded null access, resource leaks, races, unbounded
// reads. Distinct from `console-errors` (observed at runtime),
- // `error-handling` (failure paths + resilience) and `react-lifecycle`
+ // `error-handling` (failure paths + resilience) and `ui-lifecycle`
// (UI lifecycle and state). Files under `bug` plus the `runtime-safety` metric label.
'better-runtime-safety',
// Third-party dependency NECESSITY (the `do:depfree` lens) — replace
diff --git a/server/services/appQuality.js b/server/services/appQuality.js
index efdce58a69..8679a6b427 100644
--- a/server/services/appQuality.js
+++ b/server/services/appQuality.js
@@ -2,6 +2,7 @@
import { ensureSchema, query } from '../lib/db.js';
import { doneSentinelPath, parseSentinelPayload } from '../lib/agentSentinel.js';
import { tryReadFile } from '../lib/jsonIo.js';
+import { normalizeAuditTaskType } from '../lib/auditCatalog.js';
import { parseAuditQualityReport, summarizeAppQuality, buildAppQualityHistory, latestQualityRecords } from '../lib/auditQuality.js';
import { collectAppQuality, qualityRecord, readQualityRecords, readReleaseQuality } from './appQualityFederation.js';
@@ -9,7 +10,8 @@ export async function recordAuditQuality({ task, taskType, agentId, workspacePat
if (!success || !workspacePath || !task?.metadata?.app || !agentId) return false;
const contents = await (deps.readFile || tryReadFile)(doneSentinelPath(workspacePath, agentId));
const { summary } = parseSentinelPayload(contents);
- const report = parseAuditQualityReport(summary, taskType);
+ const category = normalizeAuditTaskType(taskType);
+ const report = parseAuditQualityReport(summary, category);
if (!report) {
console.warn(`⚠️ Audit quality report missing or invalid for ${agentId} (${taskType})`);
return false;
@@ -24,7 +26,7 @@ export async function recordAuditQuality({ task, taskType, agentId, workspacePat
`INSERT INTO app_quality_measurements (app_id, category, agent_id, assessed_at, report)
VALUES ($1, $2, $3, $4, $5::jsonb)
ON CONFLICT (app_id, category, agent_id) DO NOTHING`,
- [task.metadata.app, taskType, agentId, assessedAt, JSON.stringify(report)]
+ [task.metadata.app, category, agentId, assessedAt, JSON.stringify(report)]
);
return true;
}
diff --git a/server/services/appQuality.test.js b/server/services/appQuality.test.js
index 0f282afb21..98f7920b9c 100644
--- a/server/services/appQuality.test.js
+++ b/server/services/appQuality.test.js
@@ -19,6 +19,7 @@ describe('scheduled audit measurement workflow', () => {
expect(auditQualityInstructions(category)).toContain(`"category":"${category}"`);
}
expect(auditQualityInstructions('claim-issue')).toBe('');
+ expect(auditQualityInstructions('react-lifecycle')).toContain('"category":"ui-lifecycle"');
});
it('accepts the structured sentinel envelope and uses server-owned app, category and run provenance', async () => {
@@ -31,6 +32,18 @@ describe('scheduled audit measurement workflow', () => {
});
+ it('records an in-flight task under the current UI lifecycle category', async () => {
+ const legacyReport = report({ category: 'react-lifecycle', score: 73 });
+ const query = vi.fn().mockResolvedValue({ rows: [] });
+ await expect(recordAuditQuality({ task, taskType: 'react-lifecycle', agentId: 'agent-legacy', workspacePath: '/repo', success: true, assessedAt }, {
+ readFile: vi.fn().mockResolvedValue(JSON.stringify({ summary: sentinel(legacyReport), payload: null })), query,
+ })).resolves.toBe(true);
+ expect(query.mock.calls[0][1]).toEqual([
+ 'portos-default', 'ui-lifecycle', 'agent-legacy', assessedAt,
+ JSON.stringify({ ...legacyReport, category: 'ui-lifecycle' }),
+ ]);
+ });
+
it('rejects malformed, cross-category, duplicate and dishonest coverage reports and failed runs without writing', async () => {
const warning = vi.spyOn(console, 'warn').mockImplementation(() => {});
const query = vi.fn();
@@ -63,6 +76,20 @@ describe('scheduled audit measurement workflow', () => {
expect(summarizeAppQuality().score).toBeNull();
});
+ it('surfaces previously stored lifecycle scores under the renamed category', () => {
+ const now = Date.now();
+ const legacy = {
+ category: 'react-lifecycle',
+ assessedAt: new Date(now).toISOString(),
+ report: report({ category: 'react-lifecycle', score: 73 }),
+ };
+
+ expect(summarizeAppQuality([legacy], now).categories.find(category => category.id === 'ui-lifecycle'))
+ .toMatchObject({ score: 73, coverage: 'broad', stale: false });
+ expect(buildAppQualityHistory([legacy], 1, now).points.at(-1).categories['ui-lifecycle'])
+ .toMatchObject({ score: 73, coverage: 'broad', confidence: 'high' });
+ });
+
it('makes database unavailability explicit without failing app management', async () => {
const log = vi.spyOn(console, 'error').mockImplementation(() => {});
const [app] = await enrichAppsWithQuality([{ id: 'app' }], { query: vi.fn().mockRejectedValue(new Error('offline')) });
diff --git a/server/services/appQualityFederation.js b/server/services/appQualityFederation.js
index 073578cc3f..260d5c9862 100644
--- a/server/services/appQualityFederation.js
+++ b/server/services/appQualityFederation.js
@@ -4,6 +4,7 @@ import { createHash } from 'node:crypto';
import { z } from 'zod';
import { query } from '../lib/db.js';
import { PORTOS_APP_ID } from '../lib/appIdentity.js';
+import { normalizeAuditTaskType } from '../lib/auditCatalog.js';
import { auditQualityReportSchema, AUDIT_FRESHNESS_MS } from '../lib/auditQuality.js';
import { PORTOS_SCHEMA_VERSIONS } from '../lib/schemaVersions.js';
import { getOriginInfo } from '../lib/gitRemote.js';
@@ -49,7 +50,7 @@ async function eligiblePeers(deps) {
}
export function qualityRecord(row) {
- return { category: row.category, agentId: row.agent_id,
+ return { category: normalizeAuditTaskType(row.category), agentId: row.agent_id,
measurementId: hash(row.agent_id), assessedAt: new Date(row.assessed_at).toISOString(), report: row.report };
}
diff --git a/server/services/appQualityFederation.test.js b/server/services/appQualityFederation.test.js
index acebd21fe5..4cdcc66b2a 100644
--- a/server/services/appQualityFederation.test.js
+++ b/server/services/appQualityFederation.test.js
@@ -50,6 +50,15 @@ it('combines newest categories in app view and UTC history without changing othe
expect((await exportPortosQuality(peer.instanceId, 30, local)).measurements.map(m => m.report.score)).toEqual([20]);
});
+it('reads stored lifecycle measurements under the renamed category', async () => {
+ const [app] = await enrichAppsWithQuality(
+ [{ id: 'portos-default' }],
+ deps([row('react-lifecycle', 73)]),
+ );
+ expect(app.quality.categories.find(category => category.id === 'ui-lifecycle'))
+ .toMatchObject({ score: 73, coverage: 'broad', stale: false });
+});
+
it('keeps local scores on old, offline, malformed, oversize or mismatched peers and rejects future evidence', async () => {
const payload = await exportPortosQuality(peer.instanceId, 30, deps([row('security', 90)]));
const local = deps([row('security', 20)]);
diff --git a/server/services/appQualitySchedule.js b/server/services/appQualitySchedule.js
index ed165fa284..962b876e2b 100644
--- a/server/services/appQualitySchedule.js
+++ b/server/services/appQualitySchedule.js
@@ -25,6 +25,7 @@ import {
AUDIT_DEFINITIONS,
AUDIT_REPO_CAPABILITIES,
AUDIT_TASK_TYPE_LIST,
+ normalizeAuditTaskType,
auditCapabilityRequirement,
} from '../lib/auditCatalog.js';
import {
@@ -150,7 +151,8 @@ async function loadNotApplicableCategories(appId) {
[appId]
).catch(() => null);
if (!result) return new Set();
- return new Set(result.rows.filter(row => row.report?.coverage === 'not-applicable').map(row => row.category));
+ return new Set(result.rows.filter(row => row.report?.coverage === 'not-applicable')
+ .map(row => normalizeAuditTaskType(row.category)));
}
/**
diff --git a/server/services/appQualitySchedule.test.js b/server/services/appQualitySchedule.test.js
index a8b2d8968b..5f9c7f3e39 100644
--- a/server/services/appQualitySchedule.test.js
+++ b/server/services/appQualitySchedule.test.js
@@ -83,6 +83,15 @@ describe('resolveQualityChecks', () => {
expect(security.reason).toMatch(/previous audit/);
});
+ it('recognizes a retired lifecycle category in stored applicability results', async () => {
+ query.mockResolvedValue({ rows: [{ category: 'react-lifecycle', report: { coverage: 'not-applicable' } }] });
+ const { checks } = await resolveQualityChecks(appWith(['package.json', 'src/App.jsx']));
+ expect(checks.find(check => check.taskType === 'ui-lifecycle')).toMatchObject({
+ applicable: false,
+ reason: 'a previous audit reported this category as not applicable here',
+ });
+ });
+
it('treats a repository it could only skim as unknown, not as empty', async () => {
// `git ls-files` unavailable (not a checkout, git missing, timeout) falls
// back to a two-level listing, which cannot see src/components/App.jsx.
diff --git a/server/services/appQualitySnapshotFormat.js b/server/services/appQualitySnapshotFormat.js
index c43f68291c..8a108611a2 100644
--- a/server/services/appQualitySnapshotFormat.js
+++ b/server/services/appQualitySnapshotFormat.js
@@ -15,7 +15,7 @@
*/
import { createHash } from 'node:crypto';
import { z } from 'zod';
-import { AUDIT_DEFINITIONS } from '../lib/auditCatalog.js';
+import { AUDIT_DEFINITIONS, LEGACY_AUDIT_TASK_TYPE_ALIASES } from '../lib/auditCatalog.js';
import { auditQualityReportSchema } from '../lib/auditQuality.js';
export const APP_QUALITY_FILE_SCHEMA_VERSION = 2;
@@ -27,6 +27,7 @@ export const MAX_QUALITY_SNAPSHOT_ROWS = 10000;
const REPOSITORY = /^[a-f0-9]{64}$/;
const CATEGORIES = new Set(Object.keys(AUDIT_DEFINITIONS));
+const READABLE_CATEGORIES = new Set([...CATEGORIES, ...Object.keys(LEGACY_AUDIT_TASK_TYPE_ALIASES)]);
const COVERAGE = new Set(QUALITY_COVERAGE_VALUES);
const CONFIDENCE = new Set(QUALITY_CONFIDENCE_VALUES);
const V1_KEYS = new Set(['schemaVersion', 'repository', 'measurements']);
@@ -224,7 +225,7 @@ function parseV2(value) {
return { status: 'malformed' };
}
if (typeof value.repository !== 'string' || !REPOSITORY.test(value.repository)) return { status: 'malformed' };
- const categories = parseDictionary(value.categories, CATEGORIES);
+ const categories = parseDictionary(value.categories, READABLE_CATEGORIES);
const coverage = parseDictionary(value.coverage, COVERAGE);
const confidence = parseDictionary(value.confidence, CONFIDENCE);
if (!categories || !coverage || !confidence) return { status: 'malformed' };
diff --git a/server/services/appQualitySnapshotFormat.test.js b/server/services/appQualitySnapshotFormat.test.js
index 3a0fbc93e8..16a99193e0 100644
--- a/server/services/appQualitySnapshotFormat.test.js
+++ b/server/services/appQualitySnapshotFormat.test.js
@@ -118,6 +118,24 @@ it('normalizes v1 JSON idempotently and keeps its measurement id off the v2 byte
expect(first.canonical).not.toContain(measurementId);
});
+it('reads retired task categories and emits them under their current audit name', () => {
+ const legacy = {
+ schemaVersion: 2,
+ repository,
+ reportVersion: 1,
+ categories: ['react-lifecycle'],
+ coverage: [...QUALITY_COVERAGE_VALUES],
+ confidence: [...QUALITY_CONFIDENCE_VALUES],
+ measurements: [['2026-09-22T00:00:00.000Z', 0, 78, 4, 0, 2, 42, 42]],
+ };
+
+ const parsed = classifyQualitySnapshot(JSON.stringify(legacy));
+
+ expect(parsed.status).toBe('v2');
+ expect(parsed.records[0]).toMatchObject({ category: 'ui-lifecycle', score: 78 });
+ expect(JSON.parse(parsed.canonical).categories).toEqual(['ui-lifecycle']);
+});
+
it('rejects future, unrecognized, malformed, duplicate-day, and invalid-index documents', () => {
expect(classifyQualitySnapshot('category\tscore\n').status).toBe('unrecognized');
expect(classifyQualitySnapshot('{"quality":true}').status).toBe('unrecognized');
diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.js
index 796e716d05..6b833a9768 100644
--- a/server/services/taskPromptDefaults.test.js
+++ b/server/services/taskPromptDefaults.test.js
@@ -49,6 +49,16 @@ const importDefaultsUnder = async (env, expectedOrigin) => {
};
describe('taskPromptDefaults integrity snapshot', () => {
+ it('keeps the lifecycle prompt history under the renamed task key', () => {
+ expect(DEFAULT_TASK_PROMPTS['ui-lifecycle']).toContain('UI lifecycle and state audit');
+ expect(PROMPT_VERSIONS['ui-lifecycle']).toBe(2);
+ expect(SNAPSHOT.DEFAULT_TASK_PROMPTS).toHaveProperty('ui-lifecycle');
+ expect(SNAPSHOT.PREVIOUS_DEFAULT_PROMPTS['ui-lifecycle']).toHaveLength(1);
+ expect(SNAPSHOT.DEFAULT_TASK_PROMPTS).not.toHaveProperty('react-lifecycle');
+ expect(SNAPSHOT.PROMPT_VERSIONS).not.toHaveProperty('react-lifecycle');
+ expect(SNAPSHOT.PREVIOUS_DEFAULT_PROMPTS).not.toHaveProperty('react-lifecycle');
+ });
+
it('module-hygiene v1 is generic, evidence-led, and bounded', () => {
const current = DEFAULT_TASK_PROMPTS['module-hygiene'];
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index 66b67f1183..117b4c69b9 100644
--- a/server/services/taskPromptDefaults/integrity.snapshot.json
+++ b/server/services/taskPromptDefaults/integrity.snapshot.json
@@ -40,7 +40,6 @@
"pr-reviewer-review": "a4b35a1dc44e03b3d0ecf1a4e1bae6df",
"pr-reviewer-security": "d1e99626b12939ee39ab38eaa7d23f59",
"pr-watcher": "5246968aa90bb2bbf7957dcd9ae13a51",
- "react-lifecycle": "d2eaa653e57897d3fb8b6c52c2c18e38",
"reference-watch": "e0e20754700fb08d5159b8437d9c260b",
"refresh-local-llm-catalog": "9741ca6a8419fcdea2743e3b64781a8b",
"release-check": "cd936b9a4fb76273b36ec54c3ed6d5ba",
@@ -51,6 +50,7 @@
"test-coverage": "36beffc0c2959be5d818ded54b3fe298",
"typing": "bd7cb874b2784395280b116369c7e7ac",
"ui-bugs": "073bea13a94b0266c53b5f55bb2344b9",
+ "ui-lifecycle": "d2eaa653e57897d3fb8b6c52c2c18e38",
"user-action-review": "1a083430e43f60cdd586cfffbdebc583",
"ux": "b8c0bde4075685625443a405b2c70b50"
},
@@ -90,7 +90,6 @@
"plan-task": 19,
"pr-reviewer": 5,
"pr-watcher": 2,
- "react-lifecycle": 2,
"reference-watch": 3,
"refresh-local-llm-catalog": 4,
"release-check": 14,
@@ -101,6 +100,7 @@
"test-coverage": 3,
"typing": 3,
"ui-bugs": 3,
+ "ui-lifecycle": 2,
"user-action-review": 2,
"ux": 3
},
@@ -312,9 +312,6 @@
"pr-watcher": [
"53ead8e26d396849bfa78f28550bd691"
],
- "react-lifecycle": [
- "14b3816d1bcc10f0d7d6357e55cc5e69"
- ],
"reference-watch": [
"f9322140bff7d3f603799c09ce468da9",
"722ca590fb4b6323c98850a176b9b309"
@@ -360,6 +357,9 @@
"01d2a7e034713195f33071f2c71a3c99",
"def9ad96bd74ab397233f234d79a1974"
],
+ "ui-lifecycle": [
+ "14b3816d1bcc10f0d7d6357e55cc5e69"
+ ],
"user-action-review": [
"945a716d446d26a03e2805d28bd1ae16"
],
diff --git a/server/services/taskPromptDefaults/integrityHash.js b/server/services/taskPromptDefaults/integrityHash.js
index a5f1f8cde4..414ea41f2f 100644
--- a/server/services/taskPromptDefaults/integrityHash.js
+++ b/server/services/taskPromptDefaults/integrityHash.js
@@ -57,6 +57,11 @@ const API_URL_PLACEHOLDER = '{{PORTOS_API_URL}}';
// (issue #3359).
const LEGACY_API_ORIGIN = 'http://localhost:5555';
+// Prompt history follows a scheduled task when its public task key is renamed.
+// The old key remains here only so installs carrying its persisted prompt body
+// can still recognize that body as shipped after the task config is migrated.
+const PROMPT_KEY_RENAMES = Object.freeze({ 'react-lifecycle': 'ui-lifecycle' });
+
// Longest first: the two origins can overlap — `PORTOS_API_URL=http://localhost`
// (port 80) is a prefix of the legacy literal, and replacing it first would turn
// `http://localhost:5555` into `{{PORTOS_API_URL}}:5555`, which the legacy pass
@@ -120,6 +125,16 @@ export const advancePromptIntegritySnapshot = (committed, defaults) => {
const retired = [];
const drift = [];
+ for (const [oldKey, newKey] of Object.entries(PROMPT_KEY_RENAMES)) {
+ const moved = [...(history[oldKey] || [])];
+ const oldCurrent = committed.DEFAULT_TASK_PROMPTS[oldKey];
+ if (oldCurrent && oldCurrent !== next.DEFAULT_TASK_PROMPTS[newKey]) moved.push(oldCurrent);
+ if (moved.length) {
+ history[newKey] = [...new Set([...(history[newKey] || []), ...moved])];
+ }
+ delete history[oldKey];
+ }
+
for (const [key, to] of Object.entries(next.PROMPT_VERSIONS)) {
if (committed.PROMPT_VERSIONS[key] > to) drift.push({ key, version: to, reason: 'rollback' });
}
diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.js
index 6cee7f841f..8fc4d4b54f 100644
--- a/server/services/taskPromptDefaults/prompts.js
+++ b/server/services/taskPromptDefaults/prompts.js
@@ -1064,7 +1064,7 @@ Trace client callers through to server routes and schemas, hunting for:
For each finding, name the caller AND the route with \`file.js:LINE\`, the shape
that gets through, and the concrete failure it produces.`,
- 'react-lifecycle': `[Improvement: {appName}] UI lifecycle and state audit
+ 'ui-lifecycle': `[Improvement: {appName}] UI lifecycle and state audit
Audit {appName}'s UI resource lifetimes and state correctness.
diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.js
index 51638b3c04..460f5b907f 100644
--- a/server/services/taskPromptDefaults/versions.js
+++ b/server/services/taskPromptDefaults/versions.js
@@ -51,7 +51,7 @@ export const PROMPT_VERSIONS = {
'simplify': 1, // v1: dead-code/duplication audit. Mode injected at dispatch.
'module-hygiene': 1, // v1: evidence-led complexity, responsibility, reuse, and reusable-surface discoverability audit. Mode injected at dispatch.
'api-contract': 1, // v1: API/route-contract audit (validation gaps, client/server drift, status envelopes, asyncHandler). Net-new type (no retired-hash history needed). Mode injected at dispatch.
- 'react-lifecycle': 2, // v2: framework-neutral UI lifecycle and state correctness. v1: React lifecycle/state audit (effect teardowns, stale closures, unmounted setState, derived state). Net-new type. Mode injected at dispatch.
+ 'ui-lifecycle': 2, // v2: framework-neutral UI lifecycle and state correctness. v1: lifecycle/state audit limited to React effects, stale closures, unmounted setState, and derived state. Mode injected at dispatch.
'observability': 1, // v1: logging/observability audit (silent catches, log noise, missing error context, uninstrumented pipelines). Net-new type. Mode injected at dispatch.
'copy': 1, // v1: copy/text-clarity audit (jargon, ambiguous action verbs, dead-end errors, pluralization). Net-new type. Mode injected at dispatch.
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index c2ecca2859..0d6cb9e524 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -1859,6 +1859,7 @@ describe('taskSchedule', () => {
const FILE_ISSUES_LANES = [
['data-safety', NO_PRELOAD],
['simplify', NO_PRELOAD],
+ ['ui-lifecycle', NO_PRELOAD],
['module-hygiene', DEDUP_PRELOAD],
// Derived, so a seventh better-* lane cannot be added without landing here.
...[...AUDIT_TASK_TYPES]
diff --git a/server/services/taskScheduleRegistry.js b/server/services/taskScheduleRegistry.js
index 19c930ca12..9d8c40d7a8 100644
--- a/server/services/taskScheduleRegistry.js
+++ b/server/services/taskScheduleRegistry.js
@@ -338,7 +338,7 @@ export const DEFAULT_TASK_INTERVALS = {
'simplify': { type: INTERVAL_TYPES.ON_DEMAND, enabled: true, providerId: null, model: null, prompt: null, taskMetadata: { fileIssues: true, useWorktree: false, openPR: false } },
'module-hygiene': { type: INTERVAL_TYPES.ON_DEMAND, enabled: true, providerId: null, model: null, prompt: null, dataInputs: ['open-issues', 'open-pull-requests'], taskMetadata: { fileIssues: true, useWorktree: false, openPR: false } },
'api-contract': { type: INTERVAL_TYPES.ON_DEMAND, enabled: true, providerId: null, model: null, prompt: null, taskMetadata: { fileIssues: true, useWorktree: false, openPR: false } },
- 'react-lifecycle': { type: INTERVAL_TYPES.ON_DEMAND, enabled: true, providerId: null, model: null, prompt: null, taskMetadata: { fileIssues: true, useWorktree: false, openPR: false } },
+ 'ui-lifecycle': { type: INTERVAL_TYPES.ON_DEMAND, enabled: true, providerId: null, model: null, prompt: null, taskMetadata: { fileIssues: true, useWorktree: false, openPR: false } },
'observability': { type: INTERVAL_TYPES.ON_DEMAND, enabled: true, providerId: null, model: null, prompt: null, taskMetadata: { fileIssues: true, useWorktree: false, openPR: false } },
'copy': { type: INTERVAL_TYPES.ON_DEMAND, enabled: true, providerId: null, model: null, prompt: null, taskMetadata: { fileIssues: true, useWorktree: false, openPR: false } },
// The do:better-lens lanes. All file-issues by default (an unattended run
@@ -544,7 +544,7 @@ export const TASK_TYPE_DESCRIPTIONS = {
'simplify': 'Dead-code/duplication audit — file issues (default) or implement removals',
'module-hygiene': 'Module hygiene — complexity, reuse, ownership, and discoverability; file issues (default) or implement one refactor',
'api-contract': 'API/route-contract audit — file issues (default) or implement fixes',
- 'react-lifecycle': 'UI lifecycle/state audit — file issues (default) or implement fixes',
+ 'ui-lifecycle': 'UI lifecycle/state audit — file issues (default) or implement fixes',
'observability': 'Logging/observability audit — file issues (default) or implement fixes',
'copy': 'Copy/text-clarity audit — file issues (default) or implement rewrites',
'better-complexity': 'Cyclomatic complexity — measure branching per function, reduce the hottest offenders; file issues (default) or implement one refactor',