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: score each X read on its own evidence instead of the profile read (#3633)

[._.]/ Adam Eivy60b2bf34b42a
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 0f94dfbc7d..400ccef4c9 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -22,4 +22,4 @@
- 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.
+- 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. Each of the three reads is now scored on its own evidence: a page that did not render yields `null` for its checks (shown as the warning-toned "Unknown", with a per-check hint to re-run) and names itself in a plain-language last error instead of clearing it. A page that read fine and did not match still reports `false`, and a positive search hit stays `true` on its own evidence even when a sibling read came back blank.
diff --git a/client/src/pages/X.test.jsx b/client/src/pages/X.test.jsx
index 23b71a2a61..9697708509 100644
--- a/client/src/pages/X.test.jsx
+++ b/client/src/pages/X.test.jsx
@@ -86,7 +86,7 @@ describe('X page', () => {
latestSearchPostCount: null,
},
},
- lastError: 'Could not read the X profile page — visibility checks are unknown, not negative. Retry the diagnostic.',
+ lastError: 'Could not read the X profile page, account search, Latest search — those checks are unknown, not negative. Retry the diagnostic.',
}] });
renderPage(`/x/${account.id}/health`);
await screen.findByRole('heading', { name: 'Reach diagnostics for @example_user' });
diff --git a/server/services/x.js b/server/services/x.js
index 6ae1020b8f..9fe7080737 100644
--- a/server/services/x.js
+++ b/server/services/x.js
@@ -122,23 +122,40 @@ export function deriveXDiagnostics({ accountUsername, profile = {}, latest = {},
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);
+
+ const peopleHandles = Array.isArray(people.handles) ? people.handles.map(safeUsername) : null;
+ const observedInPeopleSearch = people.exactMatch === true || Boolean(peopleHandles?.includes(configured));
+ // A People-search page that actually rendered always returns at least one @handle link, so an
+ // empty handle list is a shell — not "nobody by that name."
+ const peopleRead = observedInPeopleSearch || (peopleHandles !== null && peopleHandles.length > 0);
+
+ const latestPosts = Array.isArray(latest.posts) ? latest.posts : null;
+ const matchingPosts = (latestPosts || []).filter((post) => safeUsername(post.authorHandle) === configured);
+ // Zero results in Latest search is indistinguishable from a shell on its own, so the profile
+ // read is the corroborating signal: if that page rendered, an empty Latest search is a real
+ // observation; if it did not, the whole browser session is suspect and this stays unknown.
+ const latestRead = latestPosts !== null && (latestPosts.length > 0 || profileRead);
+
return {
profileRead,
+ peopleRead,
+ latestRead,
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,
+ appearsInPeopleSearch: peopleRead ? observedInPeopleSearch : null,
+ recentPostsInLatestSearch: latestRead ? matchingPosts.length > 0 : null,
+ latestSearchPostCount: latestRead ? 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.';
+// A read that came back as a shell must leave a trace: clearing `last_error` on the same write
+// that persists three Unknowns hides the reason they are unknown.
+export function buildXReadError({ profileRead, peopleRead, latestRead }) {
+ const unread = [!profileRead && 'profile page', !peopleRead && 'account search', !latestRead && 'Latest search'].filter(Boolean);
+ return unread.length ? `Could not read the X ${unread.join(', ')} — those checks are unknown, not negative. Retry the diagnostic.` : '';
+}
const safeMetric = (value) => Number.isInteger(value) && value >= 0 && value <= MAX_INTEGER ? value : null;
@@ -182,8 +199,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`);
+ const readError = buildXReadError(diagnostics);
+ if (readError) console.warn(`⚠️ X read for @${account.username} came back empty — reporting affected visibility checks as unknown`);
await withTransaction(async (client) => {
for (const post of posts) {
diff --git a/server/services/x.test.js b/server/services/x.test.js
index c3cc645bcc..2bcbdae973 100644
--- a/server/services/x.test.js
+++ b/server/services/x.test.js
@@ -6,7 +6,7 @@ vi.mock('./xBrowser.js', () => ({ openXHandoff: vi.fn() }));
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');
+const { buildXReadError, deriveXDiagnostics, syncAccount } = await import('./x.js');
describe('X diagnostics', () => {
it('distinguishes observable public/search reach from unknown recommendation eligibility', () => {
@@ -50,6 +50,38 @@ describe('X diagnostics', () => {
});
});
+ it('scores each read on its own evidence rather than collapsing them into the profile read', () => {
+ const searchesUnread = deriveXDiagnostics({
+ accountUsername: '@Example_User',
+ profile: { username: 'example_user' },
+ latest: {},
+ people: { handles: [] },
+ });
+
+ expect(searchesUnread).toMatchObject({
+ profileRead: true,
+ profilePublic: true,
+ appearsInPeopleSearch: null,
+ recentPostsInLatestSearch: null,
+ latestSearchPostCount: null,
+ });
+
+ const searchesRead = deriveXDiagnostics({
+ accountUsername: '@Example_User',
+ profile: {},
+ latest: { posts: [{ authorHandle: 'other_user', remoteId: '1' }] },
+ people: { handles: ['other_user'] },
+ });
+
+ expect(searchesRead).toMatchObject({
+ profileRead: false,
+ profilePublic: null,
+ appearsInPeopleSearch: false,
+ recentPostsInLatestSearch: false,
+ latestSearchPostCount: 0,
+ });
+ });
+
it('keeps false for a profile page that read fine but did not return the configured handle', () => {
const result = deriveXDiagnostics({
accountUsername: '@Example_User',
@@ -105,21 +137,25 @@ describe('syncAccount error reporting', () => {
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: [] });
+ it('records a read failure instead of clearing last_error when the pages come back empty', async () => {
+ executeXBrowserRead.mockResolvedValue({ profile: { username: '' }, posts: [], handles: [] });
const { result, update } = await runSync();
expect(result.diagnostics.profilePublic).toBeNull();
- expect(update[1][2]).toBe(PROFILE_READ_FAILED_ERROR);
+ expect(update[1][2]).toBe(buildXReadError({ profileRead: false, peopleRead: false, latestRead: false }));
+ expect(update[1][2]).toMatch(/profile page, account search, Latest search/);
});
- it('clears last_error when the profile page read successfully', async () => {
- executeXBrowserRead.mockResolvedValue({ profile: { username: 'example_user' }, posts: [] });
+ it('clears last_error when every page read successfully', async () => {
+ executeXBrowserRead.mockImplementation(async (name) => (name === 'people'
+ ? { handles: ['example_user'], exactMatch: true }
+ : { profile: { username: 'example_user' }, posts: [{ authorHandle: 'example_user', remoteId: '1' }] }));
const { result, update } = await runSync();
expect(result.diagnostics.profilePublic).toBe(true);
+ expect(result.diagnostics.appearsInPeopleSearch).toBe(true);
expect(update[1][2]).toBe('');
});
});