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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([propagate-runner-errorAnalysis-into-onRunFailed-context]): reuse runner error analysis
[._.]/ Adam Eivycfbd8c3a3a6c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 7150335bda..a85b84df0e 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -23,6 +23,7 @@## Fixed+- **[propagate-runner-errorAnalysis-into-onRunFailed-context] Propagate `metadata.errorAnalysis` into the `onRunFailed` event context.** Runner-provided error analysis now rides the failed run result into `promptRunner`, so fallback provider marking reuses the category and wait-time already computed by the runner instead of analyzing the wrapper error again. The emitted `AI_PROVIDER_EXECUTION_FAILED` context also includes `errorAnalysis` for downstream auto-fix and diagnostics consumers.- **`plan-task` agents now claim their own PLAN.md item instead of one the scheduler pre-picks.** The scheduled "plan-task" job used to reserve a PLAN.md slug at dispatch time and hand it to the agent as a hard constraint, but the actual lock (the `claim/<slug>` branch) isn't created until the agent runs — so two runs firing close together could both be handed the same first-available item, and one would waste its turn (the failure mode behind the 2026-05-21 duplicate-PR incident). The agent now picks the next unclaimed item itself at execution time and immediately creates the claim branch, exactly like the `/claim` command, so concurrent runs naturally land on different items. The dispatch-time scan is kept only as a gate that skips the run when nothing is claimable. Existing scheduled-task prompts auto-upgrade on next load (`plan-task` prompt v6 → v7); `feature-ideas` is unaffected.- **Codex agents can now open PRs.** Codex CLI agents were spawned as `codex exec` with no sandbox/approval bypass, while Claude (`--dangerously-skip-permissions`) and Gemini (`--yolo`) got one — so Codex ran under the default sandbox that blocks network (its `gh pr create` couldn't resolve `api.github.com`) and, in non-interactive mode, silently cancelled any command needing approval. A Codex agent could push a branch over SSH yet fail to open the PR over HTTPS. Codex now gets `--dangerously-bypass-approvals-and-sandbox`, matching the other CLIs' unrestricted posture on PortOS's private single-user machine.- **Non-Claude agents get a working "simplify" step.** `/simplify` is a Claude Code built-in slash command, so Codex/Gemini agents couldn't run the literal `/simplify` instruction baked into task prompts. The reuse/quality/efficiency self-review step is now phrased so any CLI can do it — Claude Code still runs `/simplify`, while other CLIs are told to do the equivalent diff review by hand. Applies to the scheduled-task templates and the per-agent completion sections.diff --git a/PLAN.md b/PLAN.mdindex 9c235b10fa..39cfe5a0e7 100644--- a/PLAN.md+++ b/PLAN.md@@ -5,7 +5,6 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changel## Next Up- [x] [test-autosubscribe-fanout-getpeers-guard-remaining] **Apply the `getPeers → []` test stub to the remaining record-creating test files.** Completed 2026-05-23: `server/lib/mockPathsDataRoot.js` now exposes `mockNoPeers()` / `mockNoPeerSync()`, the remaining universe/series-creating suites use the guard, sharing suites preserve explicit identity stubs, and `CLAUDE.md` documents the convention for new record-creating tests.-- [ ] [propagate-runner-errorAnalysis-into-onRunFailed-context] **Propagate `metadata.errorAnalysis` into the `onRunFailed` event context** so `promptRunner.js#markProviderUnavailableFromError` doesn't re-run `analyzeError` on the same text the runner already analyzed. The runner writes `errorAnalysis` to `metadata` (`server/lib/aiToolkit/runner.js:245`, 343, 433) but `server/index.js:202` only forwards a subset to the error event, so the analysis pass is duplicated on every failure. Either add `errorAnalysis` to the event context AND to the rejected error thrown to promptRunner, or attach it to the metadata object that the rejection carries. Microsecond-class perf, but cleaner. Surfaced by /simplify efficiency review during the ai-fallback PR (2026-05-22).- [ ] [upcoming-tasks-widget-drop-catch-to-empty] **Drop the `.catch(() => [])` in `UpcomingTasksWidget.jsx:21`.** Pre-existing tech debt (not touched in v2.6.0): `useAutoRefetch(() => api.getCosUpcomingTasks(6).catch(() => []), 60000)` wipes the prior list on transient errors. The seven sibling callers (Brain, DigitalTwin, QuickSummary, ActionableInsightsBanner, ProcessesTab, SystemHealthPage, CyberCity) were fixed during the v2.6.0 release review by dropping the catch and passing `{ silent: true }` to the API helper instead. Apply the same pattern here: add an `options` parameter to `getCosUpcomingTasks` (in `client/src/services/apiAgents.js`, mirroring `getCosQuickSummary`), drop the catch, and pass `{ silent: true }` in the call site. Surfaced by reviewer-4 in the v2.6.0 release review (2026-05-21).- [ ] [extract-compare-helpers-once-eight-callers] **Extract `equalByKeys` / `equalListByKeys` once `useAutoRefetch`'s `compare` reaches ~8 widget callers.** With the dashboard rollout (PR #421) there are now 5 widget callers (Backup, Chief of Staff, Decision Log, Goal Progress, Proactive Alerts) on top of EpisodeVideoStage / Brain / Digital Twin from PR #425, using two emerging shapes — (a) scalar-object key equality (BackupWidget status, DecisionLogWidget last24Hours, ProactiveAlertsWidget counts) and (b) array equality by length + per-item key tuple (BackupWidget snapshots, GoalProgressWidget goals, ProactiveAlertsWidget alerts list, DecisionLogWidget impactfulDecisions). Inline forms are noisy but each has an explanatory comment that an `equalByKeys(prev, next, ['status', 'lastRun', …])` would lose. Defer until enough more callers appear that the abstraction pays for itself, then add helpers to `client/src/lib/compareHelpers.js` (register in `index.js` + `README.md`) and migrate the flat callers — leave CosDashboardWidget's nested-optional-chain shape inline. Surfaced by /simplify reuse review during `[useautorefetch-compare-caller-rollout-widgets]` claim 2026-05-21.- [ ] [codex5-onboarding-capability-map] **[P2][ONBOARDING]** Capability map of connected systems. One page showing each integration's status: Providers (per-provider configured/available/throttled), Calendar, Brain/memory embeddings, Voice (mic + TTS), Tailscale + HTTPS, Genome/health imports, Telegram/messages, App registry/PM2. Each row links to the relevant settings page. Doubles as a setup checklist and a runtime health overview.diff --git a/server/index.js b/server/index.jsindex d243129c07..7c4aa5b3d4 100644--- a/server/index.js+++ b/server/index.js@@ -233,6 +233,7 @@ const aiToolkitHooks = {workspacePath: metadata.workspacePath,workspaceName: metadata.workspaceName,errorDetails: errorMessage,+ errorAnalysis: metadata.errorAnalysis,// Note: promptPreview and outputTail intentionally omitted to avoid leaking sensitive data}});diff --git a/server/lib/promptRunner.js b/server/lib/promptRunner.jsindex c5f26742ff..ae40b10d1c 100644--- a/server/lib/promptRunner.js+++ b/server/lib/promptRunner.js@@ -259,7 +259,7 @@ export async function runPromptThroughProvider(args) {throw stripFallbackContext(firstError);}- await markProviderUnavailableFromError(failed, firstError.message).catch(err => {+ await markProviderUnavailableFromError(failed, firstError.message, firstError.errorAnalysis).catch(err => {console.error(`❌ markUnavailable failed for ${failed.id}: ${err.message}`);});@@ -337,22 +337,25 @@ async function pickFallbackProvider(failed) {/*** Translate the runner's failure into an availability marker on the- * failed provider. Uses analyzeError to categorize and pick a cooldown;- * usage-limit failures route through `markUsageLimit` so the parsed- * wait time (e.g. "reset 5pm") is honored.+ * failed provider. Reuses the runner's precomputed error analysis when+ * present, otherwise falls back to analyzeError to categorize and pick a+ * cooldown; usage-limit failures route through `markUsageLimit` so the+ * parsed wait time (e.g. "reset 5pm") is honored.** Skips the mark when the toolkit's `executeApiRun` has already marked* the provider unavailable inline (it does this for RATE_LIMIT and* USAGE_LIMIT before firing onComplete) — re-marking would double-* increment `failureCount` and re-write the status file for no gain.*/-async function markProviderUnavailableFromError(failed, errorMessage) {+async function markProviderUnavailableFromError(failed, errorMessage, runnerAnalysis) {const toolkit = getAIToolkitInstance();const providerStatus = toolkit?.services?.providerStatus;if (!providerStatus) return;if (!providerStatus.isAvailable(failed.id)) return;- const analysis = analyzeError(errorMessage || '');+ const analysis = runnerAnalysis && typeof runnerAnalysis === 'object'+ ? runnerAnalysis+ : analyzeError(errorMessage || '');const category = analysis?.category || ERROR_CATEGORIES.UNKNOWN;if (category === ERROR_CATEGORIES.USAGE_LIMIT) {@@ -490,7 +493,11 @@ async function executeProviderRunOnce({ provider, prompt, source, model, runId:const labelByType = { cli: 'CLI', api: 'API', tui: 'TUI' };const onComplete = (result) => {if (result?.error || result?.success === false) {- safeReject(new Error(result?.error || `${labelByType[effectiveProvider.type] || effectiveProvider.type} execution failed`));+ const err = new Error(result?.error || `${labelByType[effectiveProvider.type] || effectiveProvider.type} execution failed`);+ if (result?.errorAnalysis && typeof result.errorAnalysis === 'object') {+ err.errorAnalysis = result.errorAnalysis;+ }+ safeReject(err);} else {// TUI runs do their own cleanup inside executeTuiRun (preferring// the response file the model was directed to write, falling backdiff --git a/server/lib/promptRunner.test.js b/server/lib/promptRunner.test.jsindex 60bc293479..4cff1095bb 100644--- a/server/lib/promptRunner.test.js+++ b/server/lib/promptRunner.test.js@@ -678,6 +678,40 @@ describe('promptRunner — retry-with-fallback', () => {expect(autoFixer.noteFallbackHandled).toHaveBeenCalledTimes(1);});+ it('uses runner-provided errorAnalysis when marking the failed provider', async () => {+ const status = mockToolkitWithFallback();+ const runnerErrorAnalysis = {+ hasError: true,+ category: 'usage-limit',+ message: 'Usage limit reset at 5pm',+ waitTime: 12345,+ };++ runner.executeCliRun.mockImplementation(async (id, _p, _pr, _cwd, _onData, onComplete, _t) => {+ onComplete({+ success: false,+ error: 'plain wrapper error',+ errorAnalysis: runnerErrorAnalysis,+ });+ });+ runner.executeApiRun.mockImplementation(async (id, _p, _m, _pr, _cwd, _ctx, onData, onComplete) => {+ onData('recovered');+ onComplete({ success: true });+ });++ await runPromptThroughProvider({+ provider: primaryCli,+ prompt: 'p',+ source: 'test',+ });++ expect(status.markUsageLimit).toHaveBeenCalledWith('primary-cli', {+ message: 'Usage limit reset at 5pm',+ waitTime: 12345,+ });+ expect(status.markUnavailable).not.toHaveBeenCalled();+ });+it('does NOT suppress the investigation task when the fallback ALSO fails (both errors must surface)', async () => {mockToolkitWithFallback();