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

feat: label audit issues with their metric slug

Adam Eivyb2ecb22c8f7f
diff --git a/docs/features/self-improvement-audits.md b/docs/features/self-improvement-audits.md
index 6dc2357449..bd8569abed 100644
--- a/docs/features/self-improvement-audits.md
+++ b/docs/features/self-improvement-audits.md
@@ -9,6 +9,12 @@ Configure them in **CoS → Schedule**. Every lane is on-demand and enabled by
default, so a fresh install spends nothing until you press Run or pick a cadence
(the AI Provider Usage Policy in `AGENTS.md`).
+Filed forge issues keep a `[<metric>-…]` slug in the title **and** apply that
+same metric as a label (`cognitive-load`, `structural-drift`, `runtime-safety`,
+…) alongside the category (`code-quality`, `bug`, `tests`, …) so the backlog
+can be filtered without parsing titles. When the slug stem is already the
+category (`ux`, `security`) the extra label is omitted.
+
Registry: `server/lib/auditCatalog.js` (what each lane is and how it files),
`server/services/taskScheduleRegistry.js` (cadence and posture),
`server/services/taskPromptDefaults/prompts.js` (the mission bodies).
@@ -23,29 +29,29 @@ the operator's live checkout.
|---|---|---|---|---|
| `security` | Exposure real under the app's own threat model | `security` | implement | |
| `code-quality` | Conventional maintainability defects | `code-quality` | implement | |
-| `test-coverage` | Untested behavior worth covering | `tests` | implement | |
-| `performance` | Provably wasted work on a hot path | `performance` | implement | |
-| `accessibility` | Keyboard, screen-reader, contrast, zoom barriers | `accessibility` | implement | |
-| `documentation` | Docs that are wrong, then docs that are missing | `documentation` | implement | |
-| `ui-bugs` | Things that are broken in the running interface | `bug` | implement | |
+| `test-coverage` | Untested behavior worth covering | `tests`, `test-gap` | implement | |
+| `performance` | Provably wasted work on a hot path | `performance`, `perf` | implement | |
+| `accessibility` | Keyboard, screen-reader, contrast, zoom barriers | `accessibility`, `a11y` | implement | |
+| `documentation` | Docs that are wrong, then docs that are missing | `documentation`, `docs` | implement | |
+| `ui-bugs` | Things that are broken in the running interface | `bug`, `ui-bug` | implement | |
| `mobile-responsive` | Small-screen and touch usability | `mobile` | implement | |
| `error-handling` | Failure paths, timeouts, retries, degraded fallback | `resilience` | implement | |
-| `typing` | Type contracts at boundaries | `code-quality` | implement | |
-| `console-errors` | What the app actually emits while running | `bug` | implement | |
+| `typing` | Type contracts at boundaries | `code-quality`, `typing` | implement | |
+| `console-errors` | What the app actually emits while running | `bug`, `console` | implement | |
| `ux` | Whether a user can get the job done | `ux` | file | |
| `data-safety` | Migrations, schema parity, cross-version safety | `data-safety` | file | |
-| `simplify` | Dead code, duplication, YAGNI | `code-quality` | file | |
-| `module-hygiene` | Responsibility boundaries, reuse, discoverability | `code-quality` | file | yes |
+| `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` | Effect teardown, stale closures, render races | `react-lifecycle` | file | |
-| `observability` | Silent catches, log noise, missing error context | `code-quality` | file | |
-| `copy` | User-facing wording | `ux` | file | |
-| `better-complexity` | Counted branching per function | `code-quality` | file | yes |
-| `better-cognitive-load` | Reader cost no metric captures | `code-quality` | file | yes |
-| `better-structural-drift` | The same fact kept in two places | `code-quality` | file | yes |
-| `better-runtime-safety` | Latent defects not yet triggered | `bug` | file | |
-| `better-dependency-freedom` | Whether a dependency should exist at all | `dependencies` | file | yes |
-| `better-test-quality` | Existing tests that prove nothing | `tests` | 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 |
+| `better-cognitive-load` | Reader cost no metric captures | `code-quality`, `cognitive-load` | file | yes |
+| `better-structural-drift` | The same fact kept in two places | `code-quality`, `structural-drift` | file | yes |
+| `better-runtime-safety` | Latent defects not yet triggered | `bug`, `runtime-safety` | file | |
+| `better-dependency-freedom` | Whether a dependency should exist at all | `dependencies`, `depfree` | file | yes |
+| `better-test-quality` | Existing tests that prove nothing | `tests`, `test-quality` | file | |
## Why the boundaries are explicit
diff --git a/server/lib/README.md b/server/lib/README.md
index c58bb3c92e..c9bd159833 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -73,7 +73,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `quotaBurnLegacyConversion.js` | The ONE rule turning a LEGACY quota-burn step (copied prompt + quota-only `jobType`) into a scheduled-task reference, shared by migration 359 and the live compat path so the two cannot drift. `planQuotaBurnStepConversion` decides between three outcomes — a recognized unmodified shipped preset onto its scheduled audit counterpart with issues-only pinned explicitly (`AUDIT_TASK_TYPE_BY_PRESET_ID`, inverted from `auditCatalog.js`), the two programmatic types onto their scheduled handlers, and anything customized or targetless onto a `buildQuotaBurnCustomJob` on-demand custom task addressed by the deterministic `quotaBurnCustomJobId` (which is what makes a repeated or resumed conversion create no duplicate). `legacyAgentTaskMetadata` reproduces the retired executor's dispatch posture; `applyQuotaBurnStepConversion` rewrites the step, preserving id, label, enabled and run-once state. Recognition is `matchStoredAuditPreset`, never a label or a partial match. |
| `quotaBurnOrigin.js` | Quota-burn PROVENANCE on an on-demand scheduled-task request and on the task it produces. `normalizeQuotaBurnProvenance` reads the request block (family + burn-step id required, plus the limiting-window reset, the provider/model/effort overrides and the optional manual `maintenanceRunId`); `QUOTA_BURN_PROVENANCE_FIELDS` is the ONE block definition every persistence and projection hop derives from, spread by `quotaBurnTaskMetadata` (flat task-metadata keys), `quotaBurnAgentMetadata` (the agent projection) and read back by `quotaBurnProvenance` / `hasQuotaBurnProvenance`, which accept both the flat keys and a nested `quotaBurn` block; `burnPlanOwnsTask` / `burnPlanOwnsAgent` are the ONE rule for whether the family plan (not a manual maintenance run) owns a burn-provenanced task. `onDemandRequestMetadata` is the single spread both on-demand engines apply. Import-light on purpose — `taskScheduleConstants.js` declares the origin string and must not drag the quota-burn config graph. |
| `quotaBurnPresets.js` | FROZEN compatibility-and-migration input (#6381). `QUOTA_BURN_PROMPT_PRESETS` — ready-made single-focus audit prompts for `agent-prompt` burn jobs (UX, a11y, mobile, failure paths, perf, test gaps, dead code, data safety, docs, security), each filing GitHub issues and changing no code. Templates: picking one COPIES its prompt into the job, so editing them never rewrites a configured job. `findQuotaBurnPreset(id)`; `matchStoredAuditPreset` is migration 305's recognition rule (match the MISSION half, gated on the shipped contract anchors + headings) and `upgradeStoredAuditPrompt` is the refresh built on it. |
-| `auditCatalog.js` | `getAuditScheduleMetadata` derives upgrade-safe display names and cluster labels; `AUDIT_RUN_GUIDANCE` supplies advisory sequencing. Shared catalog of scheduled AUDIT task types (`AUDIT_DEFINITIONS` / `AUDIT_TASK_TYPES`) that can either implement a fix or file tracker issues. `isFileIssuesMode`, `isExplicitFileIssuesRequest`, `FILE_ISSUES_DELIVERY_SETTINGS` (the one delivery posture every file-issues lane stamps), `auditDoWorkRequiresWorktree`, `getAuditFilingPreset`, `modeContractFor`, `applyAuditModeWrapper`. Each quota-burn audit preset maps to a scheduled type here (guarded by `auditCatalog.test.js`). Pure — no I/O. |
+| `auditCatalog.js` | `getAuditScheduleMetadata` derives upgrade-safe display names and cluster labels; `AUDIT_RUN_GUIDANCE` supplies advisory sequencing. Shared catalog of scheduled AUDIT task types (`AUDIT_DEFINITIONS` / `AUDIT_TASK_TYPES`) that can either implement a fix or file tracker issues. Filing presets carry `issueLabel` (category) plus `metricLabel`/`extraLabels` from the slug stem (`cognitive-load`, `structural-drift`, `runtime-safety`, …) so forge issues can be filtered by metric as well as titled with it. `metricLabelFromSlugPrefix`, `isFileIssuesMode`, `isExplicitFileIssuesRequest`, `FILE_ISSUES_DELIVERY_SETTINGS` (the one delivery posture every file-issues lane stamps), `auditDoWorkRequiresWorktree`, `getAuditFilingPreset`, `modeContractFor`, `applyAuditModeWrapper`. Each quota-burn audit preset maps to a scheduled type here (guarded by `auditCatalog.test.js`). Pure — no I/O. |
| `quotaBurnTaskRef.js` | The quota-burn STEP model: a discriminated scheduled-task reference (`builtin` task type + validated target app, or `custom` app-job id whose own scope is authoritative) plus the per-invocation `overrides` bag (provider/model/effort/params — unset inherits the task's saved settings, and nothing written here edits the schedule). `normalizeQuotaBurnTaskRef` / `normalizeQuotaBurnOverrides` / `normalizeQuotaBurnParams`, the `QUOTA_BURN_UNAVAILABLE` reason codes, `resolveQuotaBurnStepAvailability` (catalog passed IN, so this stays pure) / `applyQuotaBurnAvailability`, `quotaBurnStepIsDispatchable`, and `evaluateOnDemandEligibility` — the ONE on-demand gate ladder (`enabled` / instance feature / invocation eligibility / target scope / per-app switch / master Improve) shared with `taskSchedule.triggerOnDemandTask`, with `enabledAppIdsByTaskType` deriving its per-app input. |
| `quotaBurnValidation.js` | Zod schemas for the Quota Burn routes (partial config PUT, manual-run body, `run once` re-arm body). |
| `quotaReset.js` | `parseHumanReset` turns a provider CLI's human reset string into ISO 8601 (call it from the adapter); `normalizeResetAt`/`hoursUntilReset` compute time remaining without treating unknown values as imminent resets; `parseObservedReset` pulls the reset a provider stated in its own refusal text, and `isObservedBlockActive` is the shared "is that refusal still holding?" predicate every observed-refusal ledger uses. |
@@ -591,7 +591,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and
| `userActionTypes.js` | Closed vocabulary for the operator-action ledger (`user_action_events`, #5594 / #5596): `USER_ACTION_TYPES` (CoS task/feedback/schedule + settings + instance-feature toggles + event-only creative/Brain pointers), `USER_ACTION_ACTORS` (`user` / `mind` / `schedule` / `system`), and the `isUserActionType` / `isUserActionActor` predicates. `recordUserAction` (`services/userActions.js`) throws on a type absent from the list, so a typo fails a test instead of writing a row nothing can filter on. |
| `uuid.js` | `v4()` thin wrapper over the global `crypto.randomUUID()`. Import-free, so a leaf the browser imports may reach it without a Node built-in — importable, not browser-callable: `randomUUID` needs a secure context there, so client code mints through `client/src/lib/uuid.js`. |
| `versionUtils.js` | `compareSemver(a, b)` — semver ordering (-1/0/1) with pre-release precedence and build-metadata stripping. Shared by the self-update checker (`updateChecker.js`) and the local-LLM Ollama update detector (`localLlm.js`). Inputs must be `v`-stripped. |
-| `workTracker.js` | `WORK_TRACKERS`/`CONCRETE_WORK_TRACKERS`/`DEFAULT_WORK_TRACKER`, `workTrackerLabel`, `hostToWorkTracker`, `isGithubHost` (GitHub-family host test — github.com + enterprise github.*; enterprise-aware replacement for the github.com-only `isGithub` gate), `githubRepoSpec(origin)` (host-qualified `HOST/OWNER/REPO` selector for `gh --repo`, or null for a non-GitHub origin — pairs the isGithubHost gate with the selector so prWatcher/branchReconcile/issueReconcile share one "resolvable GitHub repo" definition), `forgeCliForTracker`, `isFileTracker` (true when the tracker records work as repo files — PLAN.md — so an agent's proposal necessarily dirties the worktree; false for github/gitlab/jira), `trackerToClaimTaskType`, `hostFromOriginUrl` (subgroup-tolerant host parse), pure `resolveWorkTracker({configured,host})`, async `resolveAppWorkTracker(app)` — resolves a managed app's autonomous work source (PLAN.md / GitHub / GitLab / JIRA), defaulting `'auto'` to the git origin host. Async `resolveRepoForgeTarget(repoPath)` — the ONE definition of "which forge can we query for this checkout", returning `{ forge, fullName, repoSpec, apiHost }` (enterprise-aware `gh --repo` selector for GitHub; `repoSpec: null` for GitLab, which `glab` resolves from its cwd) or null for a non-forge origin; shared by `issueReconcile.js` and `appIssues.js`. Async `resolveAppForgeTarget(app, {repoPath})` — the composed `resolveAppWorkTracker` + `resolveRepoForgeTarget` for callers holding the managed-app record, returning `{ tracker, target }` with the app's github/gitlab pin threaded in as `preferredForge` (so a self-hosted forge on a hostname matching neither pattern still resolves); use this instead of re-threading the pin by hand. Also owns the `{trackerInstructions}` prompt block shared by the TRACKER-FILING task types (types that read the app read-only and deliver findings as tracker items, not a commit): `TRACKER_FILING_PRESETS` (per-task-type slug prefix / label / body requirements — `reference-watch`, `ux`, `repo-study`), `TRACKER_FILING_TASK_TYPES` (derived from the presets, so a gated type always has wording), and `formatTrackerInstructions(tracker, options)` which renders the plan/github/gitlab/jira block (reference-watch is the default option set, so a bare call stays byte-identical for it). Consumed by the `claim-work` router in `cosTaskGenerator.js`, `referenceRepos.js`, and `routes/apps.js`. |
+| `workTracker.js` | `WORK_TRACKERS`/`CONCRETE_WORK_TRACKERS`/`DEFAULT_WORK_TRACKER`, `workTrackerLabel`, `hostToWorkTracker`, `isGithubHost` (GitHub-family host test — github.com + enterprise github.*; enterprise-aware replacement for the github.com-only `isGithub` gate), `githubRepoSpec(origin)` (host-qualified `HOST/OWNER/REPO` selector for `gh --repo`, or null for a non-GitHub origin — pairs the isGithubHost gate with the selector so prWatcher/branchReconcile/issueReconcile share one "resolvable GitHub repo" definition), `forgeCliForTracker`, `isFileTracker` (true when the tracker records work as repo files — PLAN.md — so an agent's proposal necessarily dirties the worktree; false for github/gitlab/jira), `trackerToClaimTaskType`, `hostFromOriginUrl` (subgroup-tolerant host parse), pure `resolveWorkTracker({configured,host})`, async `resolveAppWorkTracker(app)` — resolves a managed app's autonomous work source (PLAN.md / GitHub / GitLab / JIRA), defaulting `'auto'` to the git origin host. Async `resolveRepoForgeTarget(repoPath)` — the ONE definition of "which forge can we query for this checkout", returning `{ forge, fullName, repoSpec, apiHost }` (enterprise-aware `gh --repo` selector for GitHub; `repoSpec: null` for GitLab, which `glab` resolves from its cwd) or null for a non-forge origin; shared by `issueReconcile.js` and `appIssues.js`. Async `resolveAppForgeTarget(app, {repoPath})` — the composed `resolveAppWorkTracker` + `resolveRepoForgeTarget` for callers holding the managed-app record, returning `{ tracker, target }` with the app's github/gitlab pin threaded in as `preferredForge` (so a self-hosted forge on a hostname matching neither pattern still resolves); use this instead of re-threading the pin by hand. Also owns the `{trackerInstructions}` prompt block shared by the TRACKER-FILING task types (types that read the app read-only and deliver findings as tracker items, not a commit): `TRACKER_FILING_PRESETS` (per-task-type slug prefix / label / body requirements — `reference-watch`, `ux`, `repo-study`), `TRACKER_FILING_TASK_TYPES` (derived from the presets, so a gated type always has wording), `extraIssueLabels` / `formatForgeCategoryLabelFlags` (category + metric-slug labels + `plan` as repeated `--label` flags), and `formatTrackerInstructions(tracker, options)` which renders the plan/github/gitlab/jira block (reference-watch is the default option set, so a bare call stays byte-identical for it). Consumed by the `claim-work` router in `cosTaskGenerator.js`, `referenceRepos.js`, and `routes/apps.js`. |
| `eidoverseProxyRoutes.js` | Allowlist + path helpers for the same-origin Eidoverse reverse-proxy on `:5555` (`/eidoverse-host` prefix strip and root routes like `/ws` / `/version` while the host is active). Shared by `services/eidoverseProxy.js` so the main server and the optional `:5563` bridge stay in sync with eidoverse-worlds `server/routes.ts`. |
| `workspaceRoots.js` | Shared allow-list for routes that take a caller-supplied filesystem path. `isWithinAllowedRoots(realPath)` is the single complete test — on Windows it also allows any lettered non-system drive (`D:\code`), which appears in no root, so never render `ALLOWED_WORKSPACE_ROOTS` as "the directories you may use". `outsideAllowedRootsMessage(realPath, { field })` formats a redacted server-only diagnostic with the rejected realpath and every checked root. Also `ALLOWED_WORKSPACE_ROOTS` (defaults + `PORTOS_WORKSPACE_ROOTS`, split on the platform path delimiter — `;` on Windows — and symlink-resolved), `isWithinRoot(resolvedPath, root)` (separator-safe containment), and `WORKSPACE_ROOTS_CONFIGURED` (true when the operator set the env var — lets a permissive-by-default route like `routes/detect.js` opt into confinement). Defaults cover home plus wherever the platform mounts secondary volumes: `/tmp` + `/Users` + `/Volumes` + `/mnt` + `/media` + `/opt` on POSIX; home + the temp dir plus the non-system-drive rule on Windows, where those POSIX literals would resolve to whatever drive the process happens to be on. Used by `routes/commands.js`, `routes/scaffold.js`, and `routes/git.js` (always scoped) and `routes/detect.js` (scoped only when configured). |
| `zodCompat.js` | Zod 4 compatibility helpers. `partialWithoutDefaults(objectSchema)` — like `.partial()` but strips inner field defaults first, so a PATCH/update schema doesn't inject (and clobber) the stored values of fields the caller didn't send. Use for any update schema derived from a defaulted base. |
diff --git a/server/lib/auditCatalog.js b/server/lib/auditCatalog.js
index bf80abe2b9..5f665d560b 100644
--- a/server/lib/auditCatalog.js
+++ b/server/lib/auditCatalog.js
@@ -8,15 +8,35 @@
* (toggleable at dispatch via `taskMetadata.fileIssues`).
*/
-const filing = ({ slugPrefix, label, issueLabel, labelDescription, noun }) => Object.freeze({
- slugPrefix,
- label,
- issueLabel,
- labelDescription,
- planItemBody: `From the \`${label}\` audit of <slice> (<today's date>). Problem: <what is wrong, 1–2 sentences>. Impact: <runtime, data, CI/release, or recurring maintenance consequence>. Fix: <files + functions in {appName}>. Scope: <small/medium/large>.`,
- bodyRequirements: `the slice audited and the date, what is wrong with file:line references, the concrete impact (runtime, data, CI/release, or recurring maintenance), a proposed fix naming the files in {appName}, and a \`Scope:\` of small/medium/large`,
- planCommitMessage: `docs(${issueLabel}): propose <N> ${noun}`,
-});
+/**
+ * Inventory stem of a slug prefix (`cognitive-load-` → `cognitive-load`).
+ * The same token is the extra forge label so a backlog can be filtered by
+ * metric without parsing titles.
+ */
+export function metricLabelFromSlugPrefix(slugPrefix) {
+ return String(slugPrefix || '').replace(/-+$/, '');
+}
+
+const filing = ({ slugPrefix, label, issueLabel, labelDescription, noun }) => {
+ const metricLabel = metricLabelFromSlugPrefix(slugPrefix);
+ // Apply the slug-stem as a second label whenever it is not already the
+ // category (`code-quality` + `cognitive-load`, `bug` + `runtime-safety`).
+ // When they coincide (`ux`, `security`) the category flag is enough.
+ const extraLabels = metricLabel && metricLabel !== issueLabel
+ ? Object.freeze([metricLabel])
+ : Object.freeze([]);
+ return Object.freeze({
+ slugPrefix,
+ label,
+ issueLabel,
+ metricLabel,
+ extraLabels,
+ labelDescription,
+ planItemBody: `From the \`${label}\` audit of <slice> (<today's date>). Problem: <what is wrong, 1–2 sentences>. Impact: <runtime, data, CI/release, or recurring maintenance consequence>. Fix: <files + functions in {appName}>. Scope: <small/medium/large>.`,
+ bodyRequirements: `the slice audited and the date, what is wrong with file:line references, the concrete impact (runtime, data, CI/release, or recurring maintenance), a proposed fix naming the files in {appName}, and a \`Scope:\` of small/medium/large`,
+ planCommitMessage: `docs(${issueLabel}): propose <N> ${noun}`,
+ });
+};
/**
* The half of every audit dispatch that is about HOW to run, not WHAT to
@@ -298,8 +318,9 @@ export const AUDIT_DEFINITIONS = Object.freeze({
filing: filing({
slugPrefix: 'observability-',
label: 'observability-audit',
- // Reuses the existing `code-quality` label the way `simplify` does — a
- // missing log line is a maintainability defect, not its own category.
+ // Category stays `code-quality` (a missing log line is a
+ // maintainability defect); the metric label `observability` is
+ // derived from the slug so the backlog can still be filtered by lens.
issueLabel: 'code-quality',
labelDescription: 'Proposed from a logging/observability audit',
noun: 'observability finding(s)',
@@ -313,8 +334,8 @@ export const AUDIT_DEFINITIONS = Object.freeze({
filing: filing({
slugPrefix: 'copy-',
label: 'copy-audit',
- // User-facing wording is a UX concern, so it files under the same label
- // the UX audit uses rather than minting a near-duplicate category.
+ // User-facing wording is a UX concern, so the category stays `ux`;
+ // the metric label `copy` is derived from the slug.
issueLabel: 'ux',
labelDescription: 'Proposed from a copy/text-clarity audit',
noun: 'copy finding(s)',
@@ -325,11 +346,13 @@ export const AUDIT_DEFINITIONS = Object.freeze({
// are refactor- or defect-hunting lanes carved out of the broader
// code-quality / module-hygiene / test-coverage bodies so each can be
// scheduled, pinned to a provider, and toggled between filing and fixing on
- // its own. Every one files under an existing label rather than minting a
- // near-duplicate category, and the refactor lanes require a managed
- // worktree in do-work mode: a mechanical restructuring of a hot function or
- // a dependency swap is exactly the edit that must never land in the user's
- // live checkout.
+ // its own. Each still files under an existing category (`code-quality`,
+ // `bug`, `tests`, `dependencies`) and ALSO under the metric slug
+ // (`cognitive-load`, `structural-drift`, `runtime-safety`, …) so the
+ // backlog can be filtered by lens without parsing titles. The refactor
+ // lanes require a managed worktree in do-work mode: a mechanical
+ // restructuring of a hot function or a dependency swap is exactly the edit
+ // that must never land in the user's live checkout.
'better-complexity': {
quotaBurnId: null,
label: 'Cyclomatic complexity',
diff --git a/server/lib/auditCatalog.test.js b/server/lib/auditCatalog.test.js
index f4c9d9497e..e768faa7a7 100644
--- a/server/lib/auditCatalog.test.js
+++ b/server/lib/auditCatalog.test.js
@@ -13,6 +13,7 @@ import {
isExplicitFileIssuesRequest,
FILE_ISSUES_DELIVERY_SETTINGS,
getAuditFilingPreset,
+ metricLabelFromSlugPrefix,
modeContractFor,
applyAuditModeWrapper,
DO_BETTER_LENS_COVERAGE,
@@ -26,6 +27,10 @@ describe('AUDIT_DEFINITIONS', () => {
expect(def.filing, taskType).toBeTruthy();
expect(def.filing.slugPrefix, taskType).toMatch(/-$/);
expect(def.filing.issueLabel, taskType).toBeTruthy();
+ expect(def.filing.metricLabel, taskType).toBe(metricLabelFromSlugPrefix(def.filing.slugPrefix));
+ expect(def.filing.extraLabels, taskType).toEqual(
+ def.filing.metricLabel === def.filing.issueLabel ? [] : [def.filing.metricLabel]
+ );
expect(def.filing.planCommitMessage, taskType).toContain('propose');
}
});
@@ -205,6 +210,17 @@ describe('getAuditFilingPreset', () => {
expect(getAuditFilingPreset('claim-issue')).toBeNull();
});
+ it('uses the slug-stem metric as an extra forge label when it is not already the category', () => {
+ expect(getAuditFilingPreset('better-cognitive-load').extraLabels).toEqual(['cognitive-load']);
+ expect(getAuditFilingPreset('better-structural-drift').extraLabels).toEqual(['structural-drift']);
+ expect(getAuditFilingPreset('better-runtime-safety')).toMatchObject({
+ issueLabel: 'bug',
+ extraLabels: ['runtime-safety'],
+ });
+ expect(getAuditFilingPreset('ux').extraLabels).toEqual([]);
+ expect(getAuditFilingPreset('ux').metricLabel).toBe('ux');
+ });
+
it('AUDIT_TASK_TYPES is derived from the definitions table', () => {
expect(AUDIT_TASK_TYPES).toEqual(new Set(Object.keys(AUDIT_DEFINITIONS)));
});
diff --git a/server/lib/scheduledTaskTypes.js b/server/lib/scheduledTaskTypes.js
index b46513eff8..e858cf1ed6 100644
--- a/server/lib/scheduledTaskTypes.js
+++ b/server/lib/scheduledTaskTypes.js
@@ -52,11 +52,12 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [
'react-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` label. Defaults to file-issues.
+ // `code-quality` category and the `observability` metric label. Defaults to file-issues.
'observability',
// Quota-burn `copy-audit` counterpart. User-facing wording only — jargon,
- // ambiguous action verbs, dead-end error text. Files under the `ux` label;
- // narrower than the `ux` audit, which walks the running UI. File-issues.
+ // ambiguous action verbs, dead-end error text. Files under the `ux` category
+ // and the `copy` metric label; narrower than the `ux` audit, which walks the
+ // running UI. File-issues.
'copy',
// The six lanes below complete the scheduled counterparts of the slashdo
// `do:better` audit lenses (DO_BETTER_LENS_COVERAGE in lib/auditCatalog.js),
@@ -73,13 +74,14 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [
'better-cognitive-load',
// Carved out of `code-quality` v3: derived artifacts kept as a second
// source of truth, hand-synchronized registries, incidental-layout
- // coupling. Files under `code-quality`; do-work is worktree-isolated.
+ // coupling. Files under `code-quality` plus the `structural-drift` metric
+ // label; do-work is worktree-isolated.
'better-structural-drift',
// 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`
- // (component effects). Files under `bug`.
+ // (component effects). Files under `bug` plus the `runtime-safety` metric label.
'better-runtime-safety',
// Third-party dependency NECESSITY (the `do:depfree` lens) — replace
// micro-packages and native-API wrappers with in-repo code. Distinct from
@@ -87,7 +89,8 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [
'better-dependency-freedom',
// Tests that prove nothing: assert on mocks, can never fail, re-implement
// the code under test, or duplicate a stronger boundary test. Distinct from
- // `test-coverage`, which owns the GAPS. Files under `tests`.
+ // `test-coverage`, which owns the GAPS. Files under `tests` plus the
+ // `test-quality` metric label.
'better-test-quality',
// Audits `git stash list` for {appName} and drops entries already superseded
// by (or a subset of) current `main`/HEAD, or that are stale/abandoned scratch
diff --git a/server/lib/workTracker.js b/server/lib/workTracker.js
index b9d74ef672..014ffb6975 100644
--- a/server/lib/workTracker.js
+++ b/server/lib/workTracker.js
@@ -23,7 +23,7 @@ import {
formatOptionalIssueLabelFlags,
} from './dispatchLabels.js';
import { getOriginInfo, readOriginRemoteUrl } from './gitRemote.js';
-import { getAuditFilingPreset, isAuditTaskType } from './auditCatalog.js';
+import { getAuditFilingPreset, isAuditTaskType, metricLabelFromSlugPrefix } from './auditCatalog.js';
// Every selectable value (UI + Zod enum). `'auto'` is the default; the rest are
// concrete sources.
@@ -246,6 +246,29 @@ export const TRACKER_FILING_PRESETS = {
*/
export const TRACKER_FILING_TASK_TYPES = new Set(Object.keys(TRACKER_FILING_PRESETS));
+/**
+ * Category labels that are not the primary `issueLabel`. Dedupes empties and
+ * a metric that already equals the category (`ux` + slug `ux-`).
+ */
+export function extraIssueLabels(issueLabel, extraLabels = []) {
+ if (!Array.isArray(extraLabels)) return [];
+ return extraLabels.filter((name) => typeof name === 'string' && name.trim() && name !== issueLabel);
+}
+
+/**
+ * Repeated `--label` flags for the category, any metric extras, and `plan`.
+ * Shared by the gh/glab copy-pasteable `issue create` examples.
+ */
+export function formatForgeCategoryLabelFlags(issueLabel, extraLabels = []) {
+ return [issueLabel, ...extraIssueLabels(issueLabel, extraLabels), 'plan']
+ .map((name) => `--label ${name}`)
+ .join(' ');
+}
+
+function metricLabelNoun(count) {
+ return `metric label${count > 1 ? 's' : ''}`;
+}
+
/**
* Pick the {trackerInstructions} block for a resolved work tracker, falling back
* to the PLAN.md block for an unknown/missing tracker (matching `isFileTracker`,
@@ -259,6 +282,7 @@ export function formatTrackerInstructions(tracker, options = {}) {
const referenceWatchPreset = TRACKER_FILING_PRESETS['reference-watch'];
const {
slugPrefix, label, issueLabel, labelDescription,
+ extraLabels = [],
planItemBody, bodyRequirements, planCommitMessage,
} = { ...referenceWatchPreset, ...options };
// The reference-watch preset is the backwards-compatible default, but its
@@ -284,7 +308,22 @@ export function formatTrackerInstructions(tracker, options = {}) {
const forgeFileStep = issueLabelContract ? '4.' : '3.';
// `ref-watch-` → `ref-watch`: the forge title search wants the stem, not the
// trailing separator (`--search "ref-watch in:title"`).
- const slugStem = slugPrefix.replace(/-+$/, '');
+ const slugStem = metricLabelFromSlugPrefix(slugPrefix);
+ const metricExtras = extraIssueLabels(issueLabel, extraLabels);
+ const forgeCategoryFlags = formatForgeCategoryLabelFlags(issueLabel, extraLabels);
+ const extraCreateClause = (render) => {
+ if (!metricExtras.length) return '';
+ return `, then the ${metricLabelNoun(metricExtras.length)} (${metricExtras.map(render).join(', then ')})`;
+ };
+ const extraCreateClauseGh = extraCreateClause(
+ (name) => `\`gh label create ${name} --description "${labelDescription}" --force\``
+ );
+ const extraCreateClauseGlab = extraCreateClause(
+ (name) => `\`glab label create --name ${name} --color "#0366D6" --description "${labelDescription}" 2>/dev/null || true\``
+ );
+ const extraJiraLabels = metricExtras.length
+ ? ` and the ${metricLabelNoun(metricExtras.length)} ${metricExtras.map((name) => `\`${name}\``).join(', ')}`
+ : '';
const blocks = {
plan: `This app records autonomous work in **PLAN.md** at the repo root ({repoPath}).
@@ -301,12 +340,12 @@ export function formatTrackerInstructions(tracker, options = {}) {
- **Inventory:** From {repoPath}, resolve the repo (\`gh repo view --json nameWithOwner -q .nameWithOwner\`) and list existing ${label} issues so you don't duplicate: \`gh issue list --state all --search "${slugStem} in:title" --limit 100 --json number,title\`. Each carries a \`[${slugPrefix}…]\` slug in its title — collect them. If \`gh\` is not authenticated or the remote is not GitHub, exit cleanly.
- **Record** each NEW proposal as a GitHub issue. Do not relabel or edit an existing issue you skipped as a duplicate. Keep the \`[<slug>]\` inventory tag in the title so later runs can de-duplicate; do NOT add \`[category]\` / \`[SEVERITY]\` / \`[model:…]\` / \`[effort:…]\` prefixes (those belong in labels).
- 1. Ensure each label you will apply exists. Create the category label first (\`gh label create ${issueLabel} --description "${labelDescription}" --force\`) and \`gh label create plan --description "Tracked by /do:replan" --force\`. ${dispatchLabelCreateWording}
+ 1. Ensure each label you will apply exists. Create the category label first (\`gh label create ${issueLabel} --description "${labelDescription}" --force\`)${extraCreateClauseGh} and \`gh label create plan --description "Tracked by /do:replan" --force\`. ${dispatchLabelCreateWording}
2. ${dispatchGuidance.split('\n').join('\n ')}
${forgeLabelContract}
${forgeFileStep} File with repeated \`--label\` flags so the category/scope labels stay intact:
\`\`\`bash
- gh issue create --title "[<slug>] <Short title>" --label ${issueLabel} --label plan ${forgeLabelFlags} --body "<body>"
+ gh issue create --title "[<slug>] <Short title>" ${forgeCategoryFlags} ${forgeLabelFlags} --body "<body>"
\`\`\`
The body must contain ${bodyRequirements}. For **Maybe — needs human call** items, also add \`--label needs-decision\` (create it the same way if absent) and end the body with \`**Decision needed:** <one sentence>.\`.
- **Finalize:** No source-code edits, no PLAN.md, no branches, no PRs — the issues ARE the deliverable. \`/claim --issues\` (the \`claim-issue\` flow) picks them up later.`,
@@ -315,12 +354,12 @@ ${forgeLabelContract}
- **Inventory:** From {repoPath}, confirm the forge (\`glab repo view\`) and list existing ${label} issues so you don't duplicate: \`glab issue list --label ${issueLabel} --per-page 100 --output json\` (also scan titles for the \`[${slugPrefix}…]\` slug). Collect the existing slugs. If \`glab\` is not authenticated or the remote is not GitLab, exit cleanly.
- **Record** each NEW proposal as a GitLab issue. Do not relabel or edit an existing issue you skipped as a duplicate. Keep the \`[<slug>]\` inventory tag in the title so later runs can de-duplicate; do NOT add \`[category]\` / \`[SEVERITY]\` / \`[model:…]\` / \`[effort:…]\` prefixes (those belong in labels).
- 1. Ensure each label you will apply exists. Create the category label first (\`glab label create --name ${issueLabel} --color "#0366D6" --description "${labelDescription}" 2>/dev/null || true\`) and the same for \`plan\`. ${dispatchLabelCreateWording} (glab needs \`--name\` and \`#<hex>\`).
+ 1. Ensure each label you will apply exists. Create the category label first (\`glab label create --name ${issueLabel} --color "#0366D6" --description "${labelDescription}" 2>/dev/null || true\`)${extraCreateClauseGlab} and the same for \`plan\`. ${dispatchLabelCreateWording} (glab needs \`--name\` and \`#<hex>\`).
2. ${dispatchGuidance.split('\n').join('\n ')}
${forgeLabelContract}
${forgeFileStep} File with repeated \`--label\` flags so the category/scope labels stay intact:
\`\`\`bash
- glab issue create --title "[<slug>] <Short title>" --label ${issueLabel} --label plan ${forgeLabelFlags} --description "<body>"
+ glab issue create --title "[<slug>] <Short title>" ${forgeCategoryFlags} ${forgeLabelFlags} --description "<body>"
\`\`\`
(Run \`glab issue create --help\` if a flag is rejected — glab's flags evolve.) The body must contain ${bodyRequirements}. For **Maybe — needs human call** items, also add \`--label needs-decision\` and end the body with \`**Decision needed:** <one sentence>.\`.
- **Finalize:** No source-code edits, no PLAN.md, no branches, no MRs — the issues ARE the deliverable. \`/claim --issues\` (the \`claim-issue-gitlab\` flow) picks them up later.`,
@@ -328,7 +367,7 @@ ${forgeLabelContract}
jira: `This app tracks autonomous work in **JIRA**. Create one JIRA issue per proposal in the app's configured project using whatever JIRA CLI/REST this environment provides. **If no JIRA credentials are available, fall back to recording proposals in PLAN.md at {repoPath} (slug-tagged \`- [ ] [<slug>] …\` checklist items under \`## Next Up\`, committed) and say so in your final summary.**
- **Inventory:** Search existing JIRA issues (and PLAN.md, if you fall back) for the \`[${slugPrefix}…]\` slug so you don't duplicate; collect the existing slugs.
-- **Record** each NEW proposal as a JIRA issue whose summary starts with the \`[<slug>]\` tag. Do not relabel a ticket you skipped as a duplicate. The description must contain ${bodyRequirements}. Apply the category label \`${issueLabel}\` ${jiraDispatchLabelWording}
+- **Record** each NEW proposal as a JIRA issue whose summary starts with the \`[<slug>]\` tag. Do not relabel a ticket you skipped as a duplicate. The description must contain ${bodyRequirements}. Apply the category label \`${issueLabel}\`${extraJiraLabels} ${jiraDispatchLabelWording}
${jiraDispatchGuidance.split('\n').join('\n ')}
${jiraLabelContract}
For **Maybe — needs human call** items, end the description with \`**Decision needed:** <one sentence>.\`.
diff --git a/server/lib/workTracker.trackerInstructions.test.js b/server/lib/workTracker.trackerInstructions.test.js
index 738c5eef3d..2db0ee355b 100644
--- a/server/lib/workTracker.trackerInstructions.test.js
+++ b/server/lib/workTracker.trackerInstructions.test.js
@@ -18,7 +18,8 @@ import {
REPO_STUDY_LABEL_CONTRACT,
formatOptionalIssueLabelFlags,
} from './dispatchLabels.js';
-import { formatTrackerInstructions, TRACKER_FILING_PRESETS } from './workTracker.js';
+import { formatTrackerInstructions, TRACKER_FILING_PRESETS, formatForgeCategoryLabelFlags } from './workTracker.js';
+import { getAuditFilingPreset } from './auditCatalog.js';
const REF_WATCH = { slugPrefix: 'ref-watch-', label: 'reference-watch', issueLabel: 'reference-watch' };
@@ -111,6 +112,31 @@ describe('formatTrackerInstructions — forge dispatch hints (#4351)', () => {
});
});
+describe('formatTrackerInstructions — metric labels beside the slug', () => {
+ it('formats category + metric + plan as repeated --label flags', () => {
+ expect(formatForgeCategoryLabelFlags('code-quality', ['cognitive-load']))
+ .toBe('--label code-quality --label cognitive-load --label plan');
+ expect(formatForgeCategoryLabelFlags('ux', [])).toBe('--label ux --label plan');
+ expect(formatForgeCategoryLabelFlags('ux', ['ux'])).toBe('--label ux --label plan');
+ });
+
+ it('applies the slug-stem metric as a second forge label when it differs from the category', () => {
+ const preset = getAuditFilingPreset('better-cognitive-load');
+ const github = formatTrackerInstructions('github', preset);
+ expect(github).toContain('--label code-quality --label cognitive-load --label plan');
+ expect(github).toContain('gh label create cognitive-load --description "Proposed from a cognitive-load/readability audit" --force');
+ expect(formatTrackerInstructions('gitlab', preset)).toContain('--label code-quality --label cognitive-load --label plan');
+ expect(formatTrackerInstructions('jira', preset)).toContain('and the metric label `cognitive-load`');
+ });
+
+ it('does not duplicate the category when the slug stem is already the issue label', () => {
+ const github = formatTrackerInstructions('github', getAuditFilingPreset('ux'));
+ expect(github).toContain('--label ux --label plan');
+ expect(github).not.toContain('--label ux --label ux');
+ expect(github).not.toContain('then the metric label');
+ });
+});
+
describe('formatTrackerInstructions — ux preset (#3273)', () => {
const ux = TRACKER_FILING_PRESETS.ux;