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: keep scheduled tasks from drawing unrelated skill guidance (#6608)

[._.]/ Adam Eivyd5fe81213982
diff --git a/server/lib/README.md b/server/lib/README.md
index 47cc9c55e8..e569518ed3 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -413,6 +413,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and
| `taskRequeue.js` | The REQUEUE stamp (#3376) — pure metadata helpers for the one BACKWARD lifecycle step (`in_progress → pending`, performed by the orphan sweep and the retry-hold release). `REQUEUED_AT_KEY` / `LAST_SPAWNED_AT_KEY` name the two stamps; `isPostSpawnRequeue(pendingTask, inProgressTask)` answers whether the requeue happened strictly AFTER that spawn, which is how the federated merge tells a real requeue apart from an ordinary edit landing on a peer's stale `pending` copy. Returns false when either stamp is missing, so callers fall back to the lifecycle rank. |
| `taskRetryHold.js` | The failed-task RETRY HOLD state (#3373) — pure metadata helpers shared by the failure verdict, the post-cleanup release, the spawn guard, and the orphan sweep. `retryHoldMetadata(agentId, now)` arms it (task stays `in_progress`, so no dequeue tier can claim the retry before its resume pointer is resolved); `clearedRetryHoldMetadata()` releases it in the same write that flips the task to `pending`; `isRetryHeld(metadata)` / `isRetryHoldOwner(metadata, agentId)` gate the spawn and the owner-scoped release; `isStaleRetryHold(metadata, now, graceMs)` + `RETRY_HOLD_GRACE_MS` let the orphan sweep finish a transition whose process died. |
| `taskTargetBranch.js` | Pure task-branch contract: `resolveTaskTargetBranch(metadata)` reads a retry's legacy `existingBranch` or a review-loop follow-up's canonical `reviewLoopPRBranch`; `shouldStripTaskTargetBranch(metadata)` identifies only retry-owned pointers for terminal cleanup. |
+| `scheduledTaskTypes.js` | Registered scheduled task names (`SELF_IMPROVEMENT_TASK_TYPES`), shared by schedule configuration and authoritative skill routing. |
| `taskTargetScope.js` | Target scope for a scheduled task type: `INSTALL_WIDE_TASK_TYPES`, `MANAGED_APP_TARGET_TASK_TYPES`, `PROGRAMMATIC_SCHEDULED_TASK_TYPES`, `isProgrammaticScheduledTaskType`, `requiresManagedAppTarget`, `requiresInstallWideTarget`. Declared here (not in `services/taskScheduleRegistry.js`, which re-exports it) so `quotaBurnValidation.js` can reject a burn reference with the wrong target scope without importing upward into services. |
| `taxonomyTally.js` | Generic taxonomy tally + top-N-line render engine shared by the two Layered Intelligence leaf taxonomies (`services/layeredIntelligenceRejections.js`, `layeredIntelligenceExecutionFailures.js`). `createTaxonomyTally({predicate, select, field, vocabulary, sentinel, glossFn, gapWording})` is the single composed seam — it binds a taxonomy config into `{summarize, format}`, where `summarize(records)` yields the three-bucket `{entries, unknown, unclassified, diagnosed, total}` tally (commonest-first + taxonomy-order tie-break) and `format(records, limit)` renders one prompt line naming every non-zero gap. Also exports the two leaf utilities the classifiers use directly: `normalizeToken(value)` (lowercase + separator-collapse for label/category matching) and `formatTaxonomyToken(token, labels)` (gloss-map render, nullish→'', unglossed passthrough). Pure leaf — imports nothing from the LI graph. |
| `worktreeOwnership.js` | Pure ownership gate for destructive worktree operations. `worktreeOwnershipReason()` applies root, agent-id, lock, active-agent, liveness and claim policies IN THAT ORDER, so an unconditional hold always outranks a claim and callers never re-derive the precedence from the slug; the claim hold has two opt-outs (`allowStaleClaim` for reapers, `allowLiveClaim` for the dispatch side). `worktreeAgentId()` is separator-safe; `isHumanClaimWorktree()` and `isAgentWorktreeId()` make the protected namespaces explicit; `worktreeHoldExpiresAt()` names when a hold lapses on its own (the stale-claim window) so callers can wait exactly that long. |
diff --git a/server/lib/importScoping.test.js b/server/lib/importScoping.test.js
index cf2d0b3c3d..f6141c8d0a 100644
--- a/server/lib/importScoping.test.js
+++ b/server/lib/importScoping.test.js
@@ -39,6 +39,8 @@ const reaches = (entry, target) => staticImportClosure(abs(entry)).files.has(abs
// Each row: the entry that was narrowed, the module it must no longer
// statically reach, and why the entry only ever needed a slice of it.
const NARROWED = [
+ ['services/promptSections/instructions.js', 'services/taskScheduleRegistry.js',
+ 'needs task names, which scheduledTaskTypes.js declares'],
['services/agentAppWorkspace.js', 'services/promptRunner.js',
'resolves app records without AI-backed JIRA title generation'],
['services/agentAppWorkspace.js', 'services/jira.js',
@@ -79,6 +81,7 @@ describe('narrowed imports stay narrow (#6009)', () => {
// Positive controls. Without these the negatives above would also pass if
// `staticImportClosure` stopped resolving these files at all.
it('still sees the modules the narrowed entries were pointed AT', () => {
+ expect(reaches('services/promptSections/instructions.js', 'lib/scheduledTaskTypes.js')).toBe(true);
expect(reaches('services/agentAppWorkspace.js', 'lib/fileUtils.js')).toBe(true);
expect(reaches('lib/pipelineValidation.js', 'lib/editorial/checkInfra/taxonomy.js')).toBe(true);
expect(reaches('services/apps.js', 'lib/cosValidation.js')).toBe(true);
diff --git a/server/lib/index.js b/server/lib/index.js
index 5bc9d471c3..acc1454fc7 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -384,6 +384,7 @@ export * from './taskBlockCategories.js';
export * from './taskRequeue.js';
export * from './taskRetryHold.js';
export * from './taskTargetBranch.js';
+export * from './scheduledTaskTypes.js';
export * from './taskTargetScope.js';
export * from './taxonomyTally.js';
export * from './worktreeOwnership.js';
diff --git a/server/lib/scheduledTaskTypes.js b/server/lib/scheduledTaskTypes.js
new file mode 100644
index 0000000000..b46513eff8
--- /dev/null
+++ b/server/lib/scheduledTaskTypes.js
@@ -0,0 +1,160 @@
+/** Registered scheduled task names, kept separate from schedule configuration. */
+import { PRIVATE_SECURITY_TASK_TYPE } from './privateSecurityPolicy.js';
+import { PROGRAMMATIC_SCHEDULED_TASK_TYPES } from './taskTargetScope.js';
+
+export const SELF_IMPROVEMENT_TASK_TYPES = [
+ PRIVATE_SECURITY_TASK_TYPE,
+ 'model-comparison-refresh',
+ 'security', 'code-quality', 'test-coverage', 'performance',
+ 'accessibility', 'branch-reconcile', 'issue-reconcile', 'console-errors', 'dependency-updates', 'documentation',
+ 'ui-bugs', 'mobile-responsive', 'feature-ideas', 'plan-task', 'claim-issue', 'claim-work', 'error-handling',
+ 'typing', 'release-check', 'pr-reviewer', 'code-reviewer-a', 'code-reviewer-b',
+ 'jira-sprint-manager', 'jira-status-report', 'do-replan',
+ // Polls the app's GitHub repo for pull requests newly opened against the
+ // default branch and dispatches an agent (running the configurable
+ // pr-watcher prompt) for each one. `taskMetadata.prAuthorFilter` gates on
+ // PR authorship (self / others / any). See server/services/prWatcher.js.
+ 'pr-watcher',
+ // Programmatically scans new external issue comments and unreviewed external
+ // PRs. Only replies and code-review judgments consume an agent; assignment,
+ // review submission, rebase/CI policy enforcement, and merging are hooks.
+ 'issue-watcher',
+ // Watches `referenceRepos` configured on the app — fetches each upstream
+ // repo, finds commits since lastReviewedSha, and appends slug-tagged
+ // `[ref-watch-…]` checklist items to the app's PLAN.md for `/claim` /
+ // `plan-task` to pick up. No source-code edits, no separate review file.
+ 'reference-watch',
+ // Walks the running app UI with a UX reviewer's eye (Playwright MCP) against a
+ // named checklist — buried primary actions, dead-end empty/error states,
+ // affordances that drift between sibling screens. Defaults to filing tracker
+ // issues (`fileIssues: true`); the user can flip it to implement. Deliberately
+ // narrower than its siblings: raw console errors belong to `ui-bugs`, viewport
+ // breakage to `mobile-responsive`, ARIA/contrast/keyboard to `accessibility`.
+ 'ux',
+ // Quota-burn `data-safety-audit` counterpart. Migrations, schema parity, and
+ // cross-version compatibility. Defaults to file-issues (safer for unattended).
+ 'data-safety',
+ // Quota-burn `simplify-audit` counterpart. Dead code, unused exports,
+ // copy-paste drift, and YAGNI (speculative abstractions) — distinct from
+ // `code-quality` (conventional defects: magic values, brittle conditionals,
+ // convention violations). Defaults to file-issues.
+ 'simplify',
+ // Structural-maintainability audit. Treats complexity thresholds as candidate
+ // signals, then proves responsibility, reuse, or discoverability impact before
+ // filing. Direct remediation is isolated in a managed worktree.
+ 'module-hygiene',
+ // 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. Effect teardowns, stale
+ // closures, and post-unmount state — distinct from `ui-bugs` (console errors)
+ // and `accessibility`. Defaults to file-issues.
+ '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.
+ '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.
+ 'copy',
+ // The six lanes below complete the scheduled counterparts of the slashdo
+ // `do:better` audit lenses (DO_BETTER_LENS_COVERAGE in lib/auditCatalog.js),
+ // so every category of app quality can be scheduled on its own cadence
+ // instead of fanning eight sub-agents out of one command run.
+ // Measured branching per function — ranks the hottest high-complexity
+ // functions by churn and reduces them with a named transformation. The
+ // structural cousin of `module-hygiene` (which owns responsibility and
+ // ownership, and only uses complexity as a candidate signal). Remediation
+ // is a mechanical refactor of hot code, so do-work is worktree-isolated.
+ 'better-complexity',
+ // Reader cost no metric catches: mixed abstraction levels, flag arguments,
+ // misleading names, action at a distance. Sibling of `better-complexity`.
+ '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.
+ '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`.
+ 'better-runtime-safety',
+ // Third-party dependency NECESSITY (the `do:depfree` lens) — replace
+ // micro-packages and native-API wrappers with in-repo code. Distinct from
+ // `dependency-updates`, which bumps what stays. Worktree-isolated do-work.
+ '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`.
+ '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
+ // work — without discarding real unlanded work. On-demand only (no cadence
+ // makes sense for something the user notices ad hoc); non-committing
+ // coordinator posture, since a cleared stash is a repo-hygiene side effect,
+ // never a commit. See DEFAULT_TASK_PROMPTS['stash-cleanup'].
+ 'stash-cleanup',
+ // Install-wide git hygiene sweep: for EVERY managed app (PortOS included) put
+ // the checkout back on its default branch, level with origin both ways, with
+ // no leftover local branches/worktrees and an empty stash list. A deterministic
+ // Tier-1 pass in services/repoSync.js does everything provable with no LLM call
+ // (push what is strictly ahead, fast-forward the default branch, return to it
+ // when the current branch is clean + already merged, delegate merged-branch and
+ // worktree deletion to branchReconcile, drop stashes whose content is identical
+ // to the default branch). It dispatches ONE coordinator agent only when the
+ // sweep leaves something needing judgment — a mid-flight merge/rebase,
+ // uncommitted work, a diverged branch, unpushed commits with no PR, a stash it
+ // could not prove redundant — or, under the default `verifyMode:
+ // 'when-changed'`, to double-check a run that actually mutated something.
+ // On-demand only, and GLOBAL: 'Run Now' with no app sweeps the whole install,
+ // which is the shape the task exists for. Non-committing coordinator posture.
+ 'repo-sync',
+ // The planning-only sibling of `feature-ideas`: runs the same brainstorm
+ // research (PRD.md/GOALS.md or repository docs, changelog/git log, and
+ // closed-unmerged PRs)
+ // but NEVER implements — its deliverable is ONE decision-complete feature
+ // plan filed into the app's resolved work tracker via {trackerInstructions}
+ // (PLAN.md checklist item / GitHub / GitLab issue / JIRA ticket), which the
+ // claim flows pick up later. Always-filing tracker-filing type
+ // (TRACKER_FILING_PRESETS['plan-feature']), like reference-watch/repo-study.
+ 'plan-feature',
+ // user-action-review reads the machine-local operator-action ledger
+ // (services/userActions.js) for repeated manual work — Run Now on the same
+ // schedule type over and over, near-duplicate task prompts, negative feedback
+ // clusters, settings churn — and PROPOSES automations as filed tracker issues
+ // (default) or queued CoS tasks. It never edits settings or schedules itself.
+ // Install-wide: the ledger records PortOS-operator activity, not one managed
+ // app's tree. Its buildTaskInput hook (userActionReviewHooks.js) skips the
+ // dispatch entirely when the ledger is empty, so no provider call is burned.
+ 'user-action-review',
+ // layered-intelligence is a PROGRAMMATIC-I/O task: it spawns a NORMAL reasoning
+ // agent (visible in the CoS queue + Active Agents, TUI-attachable) with two
+ // deterministic hooks around it — buildTaskInput gathers the app's goals +
+ // telemetry + open issues and builds the reasoning prompt; processTaskOutput
+ // validates the agent's `.agent-done` payload, dedups, and files ONE tracker
+ // issue. The agent runs in a THROWAWAY worktree (discardWorktree) that is never
+ // committed/merged, so the reasoner still can't write code — the structured
+ // payload is its only channel out. Scheduling (enabled/interval/provider/model)
+ // lives in the per-app taskTypeOverrides; behavior (sources/scopes/rules/handoff)
+ // stays in app.layeredIntelligence. Has NO DEFAULT_TASK_PROMPTS entry — the
+ // buildTaskInput hook renders the prompt. See taskTypeHooks.js +
+ // autonomousJobs/layeredIntelligenceHooks.js.
+ 'layered-intelligence',
+ // The two PROGRAMMATIC handlers (services/scheduledHandlers/) — the only
+ // scheduled types PortOS executes ITSELF, with no agent, no CoS task, and no
+ // spawn slot. They fill blank universe-bible sheets and render the entries
+ // that have no image, using the same domain services the Universe Builder's
+ // own buttons call. Install-wide (a universe is not a managed app's repo —
+ // see `requiresInstallWideTarget`) and ON_DEMAND with no interval, so they are
+ // never clock-due and a fresh install spends nothing until the user runs one.
+ // Quota Burn reaches the SAME handlers through `quotaBurnInvoke.js`; there
+ // is one implementation, not two.
+ ...PROGRAMMATIC_SCHEDULED_TASK_TYPES,
+ // NOTE: `quota-burn` used to live here as a per-app perpetual task type. It is
+ // now ONE install-level loop (services/quotaBurnRunner.js) configured on the
+ // Quota Burn page — the burn plan is machine-local, and its jobs name which
+ // managed app (if any) the work targets. Migration 221 moves existing per-app
+ // overrides across; do not re-add it as a scheduled type.
+];
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index 840e712d03..d8c9fa35b7 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -166,7 +166,7 @@ describe('composable skill template routing', () => {
}))).toEqual(['simplify']);
});
- it.each(['analysisType', 'selfImprovementType'])(
+ it.each(['analysisType', 'taskAnalysisType', 'selfImprovementType'])(
'prefers authoritative %s routing over broad description keywords',
(metadataKey) => {
expect(detectSkillTemplates(makeTask({
@@ -176,23 +176,24 @@ describe('composable skill template routing', () => {
},
);
- // A registered audit type is authoritative about what it is, so it must never
- // fall through to the description keyword matcher. That matcher cannot read
- // an audit correctly: the security template claims the bare word "audit",
- // which every audit prompt says about itself in its opening line, so eleven of
- // nineteen audit types were being handed OWASP scoping guidance the operator
- // never chose — copy, typing, api-contract, ux and the rest. Ordinary
- // vocabulary misroutes the others just as easily: an audit that mentions
- // duplication while explicitly ceding it to a sibling drew the dead-code
- // template. The correct answer for an audit type with no template of its own
- // is NO lifecycle template, not a guess.
- it('never keyword-guesses a lifecycle template for a registered audit type', async () => {
- const { AUDIT_TASK_TYPES } = await import('../lib/auditCatalog.js');
+ // Catch incidental lifecycle matches across every shipped scheduled prompt.
+ it('never keyword-guesses a lifecycle template for a registered scheduled type', async () => {
+ const { SELF_IMPROVEMENT_TASK_TYPES, DEFAULT_TASK_INTERVALS, TASK_TYPE_PROMPT_INFO } = await import('./taskScheduleRegistry.js');
+ expect([...SELF_IMPROVEMENT_TASK_TYPES].sort()).toEqual(Object.keys(DEFAULT_TASK_INTERVALS).sort());
const SKILLED = { security: 'security-audit', 'mobile-responsive': 'mobile-responsive', documentation: 'documentation', 'data-safety': 'data-safety', simplify: 'simplify', 'module-hygiene': 'module-hygiene' };
- for (const taskType of AUDIT_TASK_TYPES) {
+ for (const taskType of SELF_IMPROVEMENT_TASK_TYPES) {
// The real dispatched body, which is what the matcher actually sees.
- const description = DEFAULT_TASK_PROMPTS[taskType]
+ const prompt = DEFAULT_TASK_PROMPTS[taskType];
+ // Router, reviewer, hook-generated and programmatic lanes have no stored body.
+ if (!prompt) {
+ expect(
+ ['claim-work', 'code-reviewer-a', 'code-reviewer-b'].includes(taskType)
+ || ['runtime-generated', 'programmatic'].includes(TASK_TYPE_PROMPT_INFO[taskType]?.mode),
+ taskType,
+ ).toBe(true);
+ }
+ const description = (prompt || 'Audit security, touch files, remove dead code')
.replaceAll('{appName}', 'Example App')
.replaceAll('{repoPath}', '/workspace/example-app')
.replace('{modeInstructions}', '## Mode: file issues, change nothing');
@@ -207,7 +208,7 @@ describe('composable skill template routing', () => {
description: 'Fix the broken avatar upload crash',
}))).toEqual(['bug-fix']);
// An unregistered type falls through to keywords rather than resolving to
- // no template, so a custom job is unaffected by the audit-type gate.
+ // no template, so a custom job is unaffected by the scheduled-type gate.
expect(detectSkillTemplates(makeTask({
description: 'Refactor the export pipeline',
metadata: { analysisType: 'custom-app-job' },
diff --git a/server/services/promptSections/instructions.js b/server/services/promptSections/instructions.js
index cb1a186493..6c162468ff 100644
--- a/server/services/promptSections/instructions.js
+++ b/server/services/promptSections/instructions.js
@@ -7,7 +7,7 @@ import { readdir } from 'fs/promises';
import { homedir } from 'os';
import { PATHS, tryReadFile } from '../../lib/fileUtils.js';
import { AGENT_INSTRUCTIONS_FILENAME, CLAUDE_BRIDGE_FILENAME } from '../../lib/agentInstructionsFile.js';
-import { isAuditTaskType } from '../../lib/auditCatalog.js';
+import { SELF_IMPROVEMENT_TASK_TYPES } from '../../lib/scheduledTaskTypes.js';
const SKILLS_DIR = join(PATHS.root, 'data/prompts/skills');
@@ -61,21 +61,11 @@ const TASK_TYPE_SKILL_ALIASES = Object.freeze({
});
/**
- * A registered audit type carries its whole method in its own prompt body and
- * is therefore AUTHORITATIVE about what it is — so when it has no template of
- * its own, the answer is "no lifecycle template", not "guess from the words".
- *
- * The keyword fallback below exists for free-text user tasks, and it cannot
- * read an audit correctly: the `security-audit` matcher claims the bare word
- * `audit`, which every audit prompt says about itself in its first line. That
- * silently spliced OWASP scoping guidance into the copy, typing, api-contract,
- * react-lifecycle, observability, ux, accessibility, ui-bugs, console-errors,
- * error-handling and test-coverage audits — eleven of nineteen at the time this
- * gate was added. Ordinary vocabulary misroutes the rest just as easily: an
- * audit that mentions "duplication" while ceding it to a sibling drew the
- * dead-code template, and one that mentions the module-hygiene work drew that
- * one. Every case reads as a template the operator never chose.
+ * Registered scheduled types own their method. Explicit templates opt in above
+ * the no-template gate; incidental words in generated prompts must not select
+ * another lifecycle. Keyword routing remains available to free-text/custom jobs.
*/
+const SCHEDULED_TASK_TYPES = new Set(SELF_IMPROVEMENT_TASK_TYPES);
const NO_LIFECYCLE_SKILL = Symbol('no-lifecycle-skill');
const skillForTaskType = (task) => {
@@ -91,7 +81,7 @@ const skillForTaskType = (task) => {
return TASK_TYPE_SKILL_ALIASES[normalized];
}
if (SKILL_NAMES.has(normalized)) return normalized;
- if (isAuditTaskType(normalized)) return NO_LIFECYCLE_SKILL;
+ if (SCHEDULED_TASK_TYPES.has(normalized)) return NO_LIFECYCLE_SKILL;
}
return null;
};
diff --git a/server/services/taskScheduleRegistry.js b/server/services/taskScheduleRegistry.js
index 961a39bec2..de7013e2a6 100644
--- a/server/services/taskScheduleRegistry.js
+++ b/server/services/taskScheduleRegistry.js
@@ -25,162 +25,9 @@ import {
export { isProgrammaticScheduledTaskType, PROGRAMMATIC_SCHEDULED_TASK_TYPES };
-export const SELF_IMPROVEMENT_TASK_TYPES = [
- PRIVATE_SECURITY_TASK_TYPE,
- 'model-comparison-refresh',
- 'security', 'code-quality', 'test-coverage', 'performance',
- 'accessibility', 'branch-reconcile', 'issue-reconcile', 'console-errors', 'dependency-updates', 'documentation',
- 'ui-bugs', 'mobile-responsive', 'feature-ideas', 'plan-task', 'claim-issue', 'claim-work', 'error-handling',
- 'typing', 'release-check', 'pr-reviewer', 'code-reviewer-a', 'code-reviewer-b',
- 'jira-sprint-manager', 'jira-status-report', 'do-replan',
- // Polls the app's GitHub repo for pull requests newly opened against the
- // default branch and dispatches an agent (running the configurable
- // pr-watcher prompt) for each one. `taskMetadata.prAuthorFilter` gates on
- // PR authorship (self / others / any). See server/services/prWatcher.js.
- 'pr-watcher',
- // Programmatically scans new external issue comments and unreviewed external
- // PRs. Only replies and code-review judgments consume an agent; assignment,
- // review submission, rebase/CI policy enforcement, and merging are hooks.
- 'issue-watcher',
- // Watches `referenceRepos` configured on the app — fetches each upstream
- // repo, finds commits since lastReviewedSha, and appends slug-tagged
- // `[ref-watch-…]` checklist items to the app's PLAN.md for `/claim` /
- // `plan-task` to pick up. No source-code edits, no separate review file.
- 'reference-watch',
- // Walks the running app UI with a UX reviewer's eye (Playwright MCP) against a
- // named checklist — buried primary actions, dead-end empty/error states,
- // affordances that drift between sibling screens. Defaults to filing tracker
- // issues (`fileIssues: true`); the user can flip it to implement. Deliberately
- // narrower than its siblings: raw console errors belong to `ui-bugs`, viewport
- // breakage to `mobile-responsive`, ARIA/contrast/keyboard to `accessibility`.
- 'ux',
- // Quota-burn `data-safety-audit` counterpart. Migrations, schema parity, and
- // cross-version compatibility. Defaults to file-issues (safer for unattended).
- 'data-safety',
- // Quota-burn `simplify-audit` counterpart. Dead code, unused exports,
- // copy-paste drift, and YAGNI (speculative abstractions) — distinct from
- // `code-quality` (conventional defects: magic values, brittle conditionals,
- // convention violations). Defaults to file-issues.
- 'simplify',
- // Structural-maintainability audit. Treats complexity thresholds as candidate
- // signals, then proves responsibility, reuse, or discoverability impact before
- // filing. Direct remediation is isolated in a managed worktree.
- 'module-hygiene',
- // 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. Effect teardowns, stale
- // closures, and post-unmount state — distinct from `ui-bugs` (console errors)
- // and `accessibility`. Defaults to file-issues.
- '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.
- '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.
- 'copy',
- // The six lanes below complete the scheduled counterparts of the slashdo
- // `do:better` audit lenses (DO_BETTER_LENS_COVERAGE in lib/auditCatalog.js),
- // so every category of app quality can be scheduled on its own cadence
- // instead of fanning eight sub-agents out of one command run.
- // Measured branching per function — ranks the hottest high-complexity
- // functions by churn and reduces them with a named transformation. The
- // structural cousin of `module-hygiene` (which owns responsibility and
- // ownership, and only uses complexity as a candidate signal). Remediation
- // is a mechanical refactor of hot code, so do-work is worktree-isolated.
- 'better-complexity',
- // Reader cost no metric catches: mixed abstraction levels, flag arguments,
- // misleading names, action at a distance. Sibling of `better-complexity`.
- '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.
- '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`.
- 'better-runtime-safety',
- // Third-party dependency NECESSITY (the `do:depfree` lens) — replace
- // micro-packages and native-API wrappers with in-repo code. Distinct from
- // `dependency-updates`, which bumps what stays. Worktree-isolated do-work.
- '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`.
- '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
- // work — without discarding real unlanded work. On-demand only (no cadence
- // makes sense for something the user notices ad hoc); non-committing
- // coordinator posture, since a cleared stash is a repo-hygiene side effect,
- // never a commit. See DEFAULT_TASK_PROMPTS['stash-cleanup'].
- 'stash-cleanup',
- // Install-wide git hygiene sweep: for EVERY managed app (PortOS included) put
- // the checkout back on its default branch, level with origin both ways, with
- // no leftover local branches/worktrees and an empty stash list. A deterministic
- // Tier-1 pass in services/repoSync.js does everything provable with no LLM call
- // (push what is strictly ahead, fast-forward the default branch, return to it
- // when the current branch is clean + already merged, delegate merged-branch and
- // worktree deletion to branchReconcile, drop stashes whose content is identical
- // to the default branch). It dispatches ONE coordinator agent only when the
- // sweep leaves something needing judgment — a mid-flight merge/rebase,
- // uncommitted work, a diverged branch, unpushed commits with no PR, a stash it
- // could not prove redundant — or, under the default `verifyMode:
- // 'when-changed'`, to double-check a run that actually mutated something.
- // On-demand only, and GLOBAL: 'Run Now' with no app sweeps the whole install,
- // which is the shape the task exists for. Non-committing coordinator posture.
- 'repo-sync',
- // The planning-only sibling of `feature-ideas`: runs the same brainstorm
- // research (PRD.md/GOALS.md or repository docs, changelog/git log, and
- // closed-unmerged PRs)
- // but NEVER implements — its deliverable is ONE decision-complete feature
- // plan filed into the app's resolved work tracker via {trackerInstructions}
- // (PLAN.md checklist item / GitHub / GitLab issue / JIRA ticket), which the
- // claim flows pick up later. Always-filing tracker-filing type
- // (TRACKER_FILING_PRESETS['plan-feature']), like reference-watch/repo-study.
- 'plan-feature',
- // user-action-review reads the machine-local operator-action ledger
- // (services/userActions.js) for repeated manual work — Run Now on the same
- // schedule type over and over, near-duplicate task prompts, negative feedback
- // clusters, settings churn — and PROPOSES automations as filed tracker issues
- // (default) or queued CoS tasks. It never edits settings or schedules itself.
- // Install-wide: the ledger records PortOS-operator activity, not one managed
- // app's tree. Its buildTaskInput hook (userActionReviewHooks.js) skips the
- // dispatch entirely when the ledger is empty, so no provider call is burned.
- 'user-action-review',
- // layered-intelligence is a PROGRAMMATIC-I/O task: it spawns a NORMAL reasoning
- // agent (visible in the CoS queue + Active Agents, TUI-attachable) with two
- // deterministic hooks around it — buildTaskInput gathers the app's goals +
- // telemetry + open issues and builds the reasoning prompt; processTaskOutput
- // validates the agent's `.agent-done` payload, dedups, and files ONE tracker
- // issue. The agent runs in a THROWAWAY worktree (discardWorktree) that is never
- // committed/merged, so the reasoner still can't write code — the structured
- // payload is its only channel out. Scheduling (enabled/interval/provider/model)
- // lives in the per-app taskTypeOverrides; behavior (sources/scopes/rules/handoff)
- // stays in app.layeredIntelligence. Has NO DEFAULT_TASK_PROMPTS entry — the
- // buildTaskInput hook renders the prompt. See taskTypeHooks.js +
- // autonomousJobs/layeredIntelligenceHooks.js.
- 'layered-intelligence',
- // The two PROGRAMMATIC handlers (services/scheduledHandlers/) — the only
- // scheduled types PortOS executes ITSELF, with no agent, no CoS task, and no
- // spawn slot. They fill blank universe-bible sheets and render the entries
- // that have no image, using the same domain services the Universe Builder's
- // own buttons call. Install-wide (a universe is not a managed app's repo —
- // see `requiresInstallWideTarget`) and ON_DEMAND with no interval, so they are
- // never clock-due and a fresh install spends nothing until the user runs one.
- // Quota Burn reaches the SAME handlers through `quotaBurnInvoke.js`; there
- // is one implementation, not two.
- ...PROGRAMMATIC_SCHEDULED_TASK_TYPES,
- // NOTE: `quota-burn` used to live here as a per-app perpetual task type. It is
- // now ONE install-level loop (services/quotaBurnRunner.js) configured on the
- // Quota Burn page — the burn plan is machine-local, and its jobs name which
- // managed app (if any) the work targets. Migration 221 moves existing per-app
- // overrides across; do not re-add it as a scheduled type.
-];
+// Keep the public registry export while prompt routing imports the narrow catalog.
+import { SELF_IMPROVEMENT_TASK_TYPES } from '../lib/scheduledTaskTypes.js';
+export { SELF_IMPROVEMENT_TASK_TYPES };
// Shared taskMetadata posture for the NON-COMMITTING COORDINATOR types
// (NON_COMMITTING_COORDINATOR_TASK_TYPES in taskTypeHooks.js — branch-reconcile /