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: report a failed X profile read as unknown visibility instead of a negative verdict (#3633)
[._.]/ Adam Eivy2331e6fa48c7
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 433691bf7c..0f94dfbc7d 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -21,3 +21,5 @@- An agent that merely *prints* a provider banner no longer benches a healthy provider. The immediate-fallback detector stamped every match as provider chrome, so a CoS agent that quoted Antigravity's account-eligibility banner — investigating that failure mode, `cat`-ing a prior run's transcript, grepping for it — sidelined the provider for the full cooldown across every subsequently dequeued task, not just its own run. The banner is now promoted to provider provenance only when it opens its own line behind nothing but TUI gutter chrome, the shape the CLI actually renders; a quoted mention still fails that one run and routes it to a fallback, but is no longer treated as evidence about the provider's health. Real banners arriving as the run's own terminal output bench exactly as before.- A CoS task whose agent spawn is **rejected by the runner** is now requeued immediately instead of being penalized for it. The runner-rejection path finalized the agent but never transitioned the task, so it sat `in_progress` holding its federation claim until the 15-minute orphan sweep — a path meant for genuine orphans, which charged one of the task's finite `orphanRetryCount` retries and armed a 30-minute cooldown for a failure the task did not cause (the agent never started; a momentarily unreachable runner was enough). It now runs the same `finalizeAgent` → `releaseRetryHold` chain the TUI path does, under its own `spawn-rejected` reason, so the task returns to `pending` with its claim released the moment the rejection lands and the runner's actual error is on the agent record.++- A failed X profile read no longer reads as "you are shadowbanned." The reach diagnostic settles the X SPA for a moment and only throws on an origin mismatch, so a page that rate-limited, rendered late, or returned an app shell resolved *successfully* with an empty profile — and all three visibility checks persisted as hard `false` while `last_error` was cleared, presenting a confident "your profile is not public, you do not appear in search, you have no recent posts" verdict produced by a read that simply failed. That is the one conclusion the feature exists to avoid drawing. An unread profile page now yields `null` for every check the failed read could have emptied (rendered as the warning-toned "Unknown", with a per-check hint to re-run) and records a plain-language last error instead of clearing it. A profile page that read fine and did not match still reports `false`, and a positive search hit stays `true` on its own evidence.diff --git a/client/src/pages/X.jsx b/client/src/pages/X.jsxindex 11e813afed..9350bfeab4 100644--- a/client/src/pages/X.jsx+++ b/client/src/pages/X.jsx@@ -225,10 +225,11 @@ export default function XPage() {const snapshot = selected?.profileSnapshot || {};const profile = snapshot.profile || {};const checks = snapshot.diagnostics || {};+ const unreadDetail = 'The profile page did not return a handle, so this check could not be observed. Re-run the diagnostic.';const checkRows = [- { label: 'Public profile reachable', value: checks.profilePublic, detail: 'The profile page returned the configured handle.' },- { label: 'Exact account search', value: checks.appearsInPeopleSearch, detail: 'The handle appeared in X People search.' },- { label: 'Recent posts in Latest search', value: checks.recentPostsInLatestSearch, detail: `${formatCount(checks.latestSearchPostCount)} matching original post(s) were returned.` },+ { label: 'Public profile reachable', value: checks.profilePublic, detail: checks.profilePublic === null ? unreadDetail : 'The profile page returned the configured handle.' },+ { label: 'Exact account search', value: checks.appearsInPeopleSearch, detail: checks.appearsInPeopleSearch === null ? unreadDetail : 'The handle appeared in X People search.' },+ { label: 'Recent posts in Latest search', value: checks.recentPostsInLatestSearch, detail: checks.recentPostsInLatestSearch === null ? unreadDetail : `${formatCount(checks.latestSearchPostCount)} matching original post(s) were returned.` },{ label: 'Recommendation eligibility', value: null, detail: 'X does not expose a public yes/no recommendation-eligibility signal here.' },];return <div className="space-y-4">diff --git a/client/src/pages/X.test.jsx b/client/src/pages/X.test.jsxindex ca993ae36b..23b71a2a61 100644--- a/client/src/pages/X.test.jsx+++ b/client/src/pages/X.test.jsx@@ -74,6 +74,27 @@ describe('X page', () => {expect(screen.getByTestId('location')).toHaveTextContent(`/x/${account.id}/health`);});+ it('renders a failed profile read as Unknown rather than a negative verdict', async () => {+ api.getXAccounts.mockResolvedValue({ accounts: [{+ ...account,+ profileSnapshot: {+ profile: {},+ diagnostics: {+ profilePublic: null,+ appearsInPeopleSearch: null,+ recentPostsInLatestSearch: null,+ latestSearchPostCount: null,+ },+ },+ lastError: 'Could not read the X profile page — visibility checks are unknown, not negative. Retry the diagnostic.',+ }] });+ renderPage(`/x/${account.id}/health`);+ await screen.findByRole('heading', { name: 'Reach diagnostics for @example_user' });+ expect(screen.getAllByText('Unknown')).toHaveLength(4);+ expect(screen.queryByText('Not observed')).not.toBeInTheDocument();+ expect(screen.getByText(/Could not read the X profile page/)).toBeInTheDocument();+ });+it('runs a manual diagnostic and keeps publishing out of the page workflow', async () => {const user = userEvent.setup();api.syncXAccount.mockResolvedValue({ account: { ...account, lastSyncAt: '2026-08-05T13:00:00.000Z' }, posts: [], ingested: 2 });diff --git a/server/services/x.js b/server/services/x.jsindex 52a56792c9..6ae1020b8f 100644--- a/server/services/x.js+++ b/server/services/x.js@@ -113,22 +113,33 @@ export async function deleteAccount(id) {return result.rowCount > 0;}+// A browser read that returns an app shell, a rate-limit interstitial, or a page that rendered+// late still resolves successfully with an empty profile. Reporting that as `false` manufactures+// the shadowban verdict the feature exists to avoid — so an unread profile page means `null`+// ("Unknown") for every check that a failed read could have silently emptied. A positive+// observation is self-validating and stays `true` even when the profile page came back blank.export function deriveXDiagnostics({ accountUsername, profile = {}, latest = {}, people = {} }) {const configured = normalizeUsername(accountUsername);const profileUsername = safeUsername(profile.username);+ const profileRead = Boolean(profileUsername);const latestPosts = Array.isArray(latest.posts) ? latest.posts : [];const matchingPosts = latestPosts.filter((post) => safeUsername(post.authorHandle) === configured);+ const observedInPeopleSearch = people.exactMatch === true || (Array.isArray(people.handles) && people.handles.map(safeUsername).includes(configured));+ const observedOrUnknown = (observed) => observed || (profileRead ? false : null);return {- profilePublic: Boolean(profileUsername && profileUsername === configured),- profileHandleMatches: Boolean(profileUsername && profileUsername === configured),- appearsInPeopleSearch: people.exactMatch === true || (Array.isArray(people.handles) && people.handles.map(safeUsername).includes(configured)),- recentPostsInLatestSearch: matchingPosts.length > 0,- latestSearchPostCount: matchingPosts.length,+ profileRead,+ profilePublic: profileRead ? profileUsername === configured : null,+ profileHandleMatches: profileRead ? profileUsername === configured : null,+ appearsInPeopleSearch: observedOrUnknown(observedInPeopleSearch),+ recentPostsInLatestSearch: observedOrUnknown(matchingPosts.length > 0),+ latestSearchPostCount: (profileRead || matchingPosts.length > 0) ? matchingPosts.length : null,recommendationEligibility: 'unknown',checkedAt: new Date().toISOString(),};}+export const PROFILE_READ_FAILED_ERROR = 'Could not read the X profile page — visibility checks are unknown, not negative. Retry the diagnostic.';+const safeMetric = (value) => Number.isInteger(value) && value >= 0 && value <= MAX_INTEGER ? value : null;const normalizeRemotePost = (post) => {@@ -171,6 +182,8 @@ async function syncAccountUnlocked(accountId) {latestSearch: { postCount: diagnostics.latestSearchPostCount },};const posts = mergePosts(profileResult.posts || [], latestPosts);+ const readError = diagnostics.profileRead ? '' : PROFILE_READ_FAILED_ERROR;+ if (readError) console.warn(`⚠️ X profile read returned no handle for @${account.username} — reporting visibility as unknown`);await withTransaction(async (client) => {for (const post of posts) {@@ -188,8 +201,8 @@ async function syncAccountUnlocked(accountId) {);}await client.query(- `UPDATE x_accounts SET profile_snapshot=$2,last_sync_at=NOW(),last_error='',updated_at=NOW() WHERE id=$1`,- [accountId, snapshot],+ `UPDATE x_accounts SET profile_snapshot=$2,last_sync_at=NOW(),last_error=$3,updated_at=NOW() WHERE id=$1`,+ [accountId, snapshot, readError],);});const [nextAccount, nextPosts] = await Promise.all([getAccount(accountId), listPosts(accountId)]);diff --git a/server/services/x.test.js b/server/services/x.test.jsindex d19d8e142a..c3cc645bcc 100644--- a/server/services/x.test.js+++ b/server/services/x.test.js@@ -1,10 +1,12 @@-import { describe, expect, it, vi } from 'vitest';+import { beforeEach, describe, expect, it, vi } from 'vitest';vi.mock('../lib/db.js', () => ({ query: vi.fn(), withTransaction: vi.fn() }));vi.mock('../integrations/x/index.js', () => ({ executeXBrowserRead: vi.fn() }));vi.mock('./xBrowser.js', () => ({ openXHandoff: vi.fn() }));-const { deriveXDiagnostics } = await import('./x.js');+const { query, withTransaction } = await import('../lib/db.js');+const { executeXBrowserRead } = await import('../integrations/x/index.js');+const { deriveXDiagnostics, syncAccount, PROFILE_READ_FAILED_ERROR } = await import('./x.js');describe('X diagnostics', () => {it('distinguishes observable public/search reach from unknown recommendation eligibility', () => {@@ -19,6 +21,7 @@ describe('X diagnostics', () => {});expect(result).toMatchObject({+ profileRead: true,profilePublic: true,profileHandleMatches: true,appearsInPeopleSearch: true,@@ -27,4 +30,96 @@ describe('X diagnostics', () => {recommendationEligibility: 'unknown',});});++ it('reports unknown rather than false when the profile page read came back empty', () => {+ const result = deriveXDiagnostics({+ accountUsername: '@Example_User',+ profile: { username: '' },+ latest: { posts: [] },+ people: {},+ });++ expect(result).toMatchObject({+ profileRead: false,+ profilePublic: null,+ profileHandleMatches: null,+ appearsInPeopleSearch: null,+ recentPostsInLatestSearch: null,+ latestSearchPostCount: null,+ recommendationEligibility: 'unknown',+ });+ });++ it('keeps false for a profile page that read fine but did not return the configured handle', () => {+ const result = deriveXDiagnostics({+ accountUsername: '@Example_User',+ profile: { username: 'someone_else' },+ latest: { posts: [{ authorHandle: 'someone_else', remoteId: '1' }] },+ people: { handles: ['someone_else'] },+ });++ expect(result).toMatchObject({+ profileRead: true,+ profilePublic: false,+ profileHandleMatches: false,+ appearsInPeopleSearch: false,+ recentPostsInLatestSearch: false,+ latestSearchPostCount: 0,+ });+ });++ it('keeps a positive search observation true even when the profile page read came back empty', () => {+ const result = deriveXDiagnostics({+ accountUsername: '@Example_User',+ profile: {},+ latest: { posts: [{ authorHandle: 'example_user', remoteId: '1' }] },+ people: { exactMatch: true },+ });++ expect(result).toMatchObject({+ profileRead: false,+ profilePublic: null,+ appearsInPeopleSearch: true,+ recentPostsInLatestSearch: true,+ latestSearchPostCount: 1,+ });+ });+});++describe('syncAccount error reporting', () => {+ const accountRow = { id: 'acct-1', username: 'example_user', enabled: true, label: 'Example', profile_snapshot: {} };++ beforeEach(() => {+ vi.clearAllMocks();+ query.mockImplementation(async (sql) => {+ if (/FROM x_accounts/.test(sql)) return { rows: [accountRow] };+ return { rows: [] };+ });+ });++ const runSync = async () => {+ const client = { query: vi.fn().mockResolvedValue({ rows: [] }) };+ withTransaction.mockImplementation(async (callback) => callback(client));+ const result = await syncAccount('acct-1');+ const update = client.query.mock.calls.find(([sql]) => /UPDATE x_accounts/.test(sql));+ return { result, update };+ };++ it('records a read failure instead of clearing last_error when the profile page is unreadable', async () => {+ executeXBrowserRead.mockResolvedValue({ profile: { username: '' }, posts: [] });++ const { result, update } = await runSync();++ expect(result.diagnostics.profilePublic).toBeNull();+ expect(update[1][2]).toBe(PROFILE_READ_FAILED_ERROR);+ });++ it('clears last_error when the profile page read successfully', async () => {+ executeXBrowserRead.mockResolvedValue({ profile: { username: 'example_user' }, posts: [] });++ const { result, update } = await runSync();++ expect(result.diagnostics.profilePublic).toBe(true);+ expect(update[1][2]).toBe('');+ });});