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

address review (claude): allow found as a manual transition target, gate wall escalation off 404/5xx, de-tautologize guard test

[._.]/ Adam Eivye87da5927ee3
diff --git a/server/lib/privacyValidation.js b/server/lib/privacyValidation.js
index 77a96ece79..7c795e3e92 100644
--- a/server/lib/privacyValidation.js
+++ b/server/lib/privacyValidation.js
@@ -251,7 +251,9 @@ export const privacyCaseIdParamsSchema = z.object({
// stay reachable ONLY from a verifying re-scan inside the engine. The service's
// assertTransition still enforces the full state machine on top of this.
export const PRIVACY_MANUAL_CASE_TARGETS = Object.freeze([
- 'submitted', 'not_found', 'human_task_queued', 'optout_in_progress', 'blocked',
+ // `found` backs the blocked-case "I'm listed" manual verdict (the user
+ // checked the broker in their own browser past the bot wall).
+ 'submitted', 'not_found', 'found', 'human_task_queued', 'optout_in_progress', 'blocked',
]);
export const privacyCaseTransitionSchema = z.object({
toState: z.enum(PRIVACY_MANUAL_CASE_TARGETS),
diff --git a/server/routes/privacy.test.js b/server/routes/privacy.test.js
index ce6ba2518c..2745304a94 100644
--- a/server/routes/privacy.test.js
+++ b/server/routes/privacy.test.js
@@ -468,6 +468,12 @@ describe('POST /api/privacy/broker-cases/:id/transition (#2146)', () => {
expect(res.body).toMatchObject({ state: 'submitted' });
});
+ it('accepts the blocked-case manual "I\'m listed" target (found)', async () => {
+ const res = await request(makeApp()).post(`/api/privacy/broker-cases/${VALID_UUID}/transition`).send({ toState: 'found' });
+ expect(res.status).toBe(200);
+ expect(brokerService.transitionCase).toHaveBeenCalledWith(VALID_UUID, 'found', {});
+ });
+
it('rejects a verification-only / unknown target state', async () => {
expect((await request(makeApp()).post(`/api/privacy/broker-cases/${VALID_UUID}/transition`).send({ toState: 'confirmed_removed' })).status).toBe(400);
expect((await request(makeApp()).post(`/api/privacy/broker-cases/${VALID_UUID}/transition`).send({ toState: 'bogus' })).status).toBe(400);
diff --git a/server/services/privacyScan.js b/server/services/privacyScan.js
index 4b61ed8948..884911b44e 100644
--- a/server/services/privacyScan.js
+++ b/server/services/privacyScan.js
@@ -137,13 +137,6 @@ function containsAntibot(html) {
return ANTIBOT_MARKERS.some((m) => h.includes(m));
}
-// The one definition of "this response is a bot wall" — shared by the blocked
-// verdict in classifyScanResult and the escalation gate in probeBroker so the
-// two can't drift.
-function isWall(status, html) {
- return status === 403 || containsAntibot(html);
-}
-
function looksLikeJsShell(html) {
if (!html || html.length < JS_SHELL_MAX_LEN) return true;
const h = html.toLowerCase();
@@ -163,7 +156,7 @@ function looksLikeJsShell(html) {
*/
export function classifyScanResult({ status, html = '', vectors = {}, broker = {} }) {
if (status === 404) return { verdict: null, inconclusive: true, evidence: { match_basis: 'http_404' } };
- if (isWall(status, html)) {
+ if (status === 403 || containsAntibot(html)) {
return { verdict: 'blocked', evidence: { match_basis: 'antibot_wall', http_status: status } };
}
if (status && status >= 500) return { verdict: null, inconclusive: true, evidence: { match_basis: `http_${status}` } };
@@ -249,7 +242,11 @@ export async function probeBroker(broker, vectors, {
// challenge in the browsed page still classifies as `blocked` below (never
// solved). On a wall, only adopt substantive browsed content: a shell-length
// browsed page would otherwise flip a real wall into a false `not_found`.
- const walled = result && isWall(status, html);
+ // 404/5xx stay out of the wall gate even when the error page carries an
+ // incidental antibot token — those statuses are inconclusive by contract
+ // (classifyScanResult), and escalating them could adopt a substantive error
+ // page as a definitive not_found.
+ const walled = result && (status === 403 || (status < 400 && containsAntibot(html)));
const jsShell = result && !walled && status >= 200 && status < 400 && looksLikeJsShell(html);
if (walled || jsShell) {
const browsed = await browserFetch(url).catch(() => null);
diff --git a/server/services/privacyScan.test.js b/server/services/privacyScan.test.js
index 0e7d575878..91d7864167 100644
--- a/server/services/privacyScan.test.js
+++ b/server/services/privacyScan.test.js
@@ -170,8 +170,21 @@ describe('scanBroker — classify → record wiring', () => {
it('does NOT adopt a shell-length browser page on a wall (stays blocked, not not_found)', async () => {
brokers.recordScanVerdict.mockClear();
const fetchImpl = vi.fn(async () => ({ status: 403, text: async () => 'Access denied' }));
- const browserFetch = vi.fn(async () => ({ text: 'Just a moment' }));
+ // Marker-free short text: if the adoption guard were dropped, this would
+ // classify as not_found (status rewritten to 200, no antibot marker) —
+ // so the blocked assertion genuinely pins the guard.
+ const browserFetch = vi.fn(async () => ({ text: 'Loading' }));
const res = await scanBroker(broker, vectors, { fetchImpl, browserFetch, urlSafe: async () => true });
expect(res.state).toBe('blocked');
});
+
+ it('a 404 carrying an incidental antibot token stays inconclusive (no wall escalation)', async () => {
+ brokers.recordScanVerdict.mockClear();
+ const fetchImpl = vi.fn(async () => ({ status: 404, text: async () => 'Not found — report a problem (reCAPTCHA)' }));
+ const browserFetch = vi.fn(async () => ({ text: `Nobody here. ${'x'.repeat(700)}` }));
+ const res = await scanBroker(broker, vectors, { fetchImpl, browserFetch, urlSafe: async () => true });
+ expect(res.skipped).toBe(true);
+ expect(browserFetch).not.toHaveBeenCalled();
+ expect(brokers.recordScanVerdict).not.toHaveBeenCalled();
+ });
});