pulsemcp-cms-admin-mcp-server 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/shared/src/pulsemcp-admin-client/lib/set-popularity-drop-bypass.js +38 -0
- package/build/shared/src/pulsemcp-admin-client/pulsemcp-admin-client.integration-mock.js +7 -0
- package/build/shared/src/server.js +4 -0
- package/build/shared/src/tools/set-popularity-drop-bypass.js +55 -0
- package/build/shared/src/tools.js +5 -0
- package/node_modules/@pulsemcp/mcp-elicitation/package.json +1 -1
- package/package.json +1 -1
- package/shared/pulsemcp-admin-client/lib/set-popularity-drop-bypass.d.ts +11 -0
- package/shared/pulsemcp-admin-client/lib/set-popularity-drop-bypass.js +38 -0
- package/shared/pulsemcp-admin-client/pulsemcp-admin-client.integration-mock.js +7 -0
- package/shared/server.d.ts +3 -1
- package/shared/server.js +4 -0
- package/shared/tools/set-popularity-drop-bypass.d.ts +30 -0
- package/shared/tools/set-popularity-drop-bypass.js +55 -0
- package/shared/tools.js +5 -0
- package/shared/types.d.ts +5 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { adminFetch } from './admin-fetch.js';
|
|
2
|
+
/**
|
|
3
|
+
* Enable or disable the one-off SYSTEMIC_DROP bypass for popularity estimates.
|
|
4
|
+
*
|
|
5
|
+
* POST /api/popularity_drop_bypass with body { enabled } sets the flag and
|
|
6
|
+
* returns the resulting status. When enabled, the NEXT run of
|
|
7
|
+
* UpdatePopularityEstimatesFromBigqueryJob flushes legitimate drops held by the
|
|
8
|
+
* SYSTEMIC_DROP guardrail, then consumes (auto-resets) the flag.
|
|
9
|
+
*/
|
|
10
|
+
export async function setPopularityDropBypass(apiKey, baseUrl, enabled) {
|
|
11
|
+
const url = new URL('/api/popularity_drop_bypass', baseUrl);
|
|
12
|
+
const response = await adminFetch(url.toString(), {
|
|
13
|
+
method: 'POST',
|
|
14
|
+
headers: {
|
|
15
|
+
'X-API-Key': apiKey,
|
|
16
|
+
Accept: 'application/json',
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
},
|
|
19
|
+
body: JSON.stringify({ enabled }),
|
|
20
|
+
});
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
if (response.status === 401) {
|
|
23
|
+
throw new Error('Invalid API key');
|
|
24
|
+
}
|
|
25
|
+
if (response.status === 403) {
|
|
26
|
+
throw new Error('User lacks write privileges');
|
|
27
|
+
}
|
|
28
|
+
if (response.status === 404) {
|
|
29
|
+
throw new Error('Popularity drop bypass endpoint not found');
|
|
30
|
+
}
|
|
31
|
+
if (response.status === 422) {
|
|
32
|
+
const errorData = (await response.json().catch(() => ({})));
|
|
33
|
+
throw new Error(`Validation failed: ${errorData.errors?.join(', ') || 'Unknown error'}`);
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`Failed to set popularity drop bypass: ${response.status} ${response.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
return (await response.json());
|
|
38
|
+
}
|
|
@@ -940,6 +940,13 @@ export function createMockPulseMCPAdminClient(mockData) {
|
|
|
940
940
|
deleted_count: 0,
|
|
941
941
|
};
|
|
942
942
|
},
|
|
943
|
+
async setPopularityDropBypass(enabled) {
|
|
944
|
+
return {
|
|
945
|
+
enabled,
|
|
946
|
+
enabled_at: enabled ? '2026-06-09T00:00:00Z' : null,
|
|
947
|
+
enabled_by: enabled ? 'mock-admin' : null,
|
|
948
|
+
};
|
|
949
|
+
},
|
|
943
950
|
// Proctor methods
|
|
944
951
|
async runExamForMirror() {
|
|
945
952
|
return {
|
|
@@ -60,6 +60,7 @@ import { retryGoodJob } from './pulsemcp-admin-client/lib/retry-good-job.js';
|
|
|
60
60
|
import { discardGoodJob } from './pulsemcp-admin-client/lib/discard-good-job.js';
|
|
61
61
|
import { rescheduleGoodJob } from './pulsemcp-admin-client/lib/reschedule-good-job.js';
|
|
62
62
|
import { forceTriggerGoodJobCron } from './pulsemcp-admin-client/lib/force-trigger-good-job-cron.js';
|
|
63
|
+
import { setPopularityDropBypass } from './pulsemcp-admin-client/lib/set-popularity-drop-bypass.js';
|
|
63
64
|
import { cleanupGoodJobs } from './pulsemcp-admin-client/lib/cleanup-good-jobs.js';
|
|
64
65
|
import { runExamForMirror } from './pulsemcp-admin-client/lib/run-exam-for-mirror.js';
|
|
65
66
|
import { saveResultsForMirror } from './pulsemcp-admin-client/lib/save-results-for-mirror.js';
|
|
@@ -293,6 +294,9 @@ export class PulseMCPAdminClient {
|
|
|
293
294
|
async forceTriggerGoodJobCron(cronKey) {
|
|
294
295
|
return forceTriggerGoodJobCron(this.apiKey, this.baseUrl, cronKey);
|
|
295
296
|
}
|
|
297
|
+
async setPopularityDropBypass(enabled) {
|
|
298
|
+
return setPopularityDropBypass(this.apiKey, this.baseUrl, enabled);
|
|
299
|
+
}
|
|
296
300
|
async cleanupGoodJobs(params) {
|
|
297
301
|
return cleanupGoodJobs(this.apiKey, this.baseUrl, params);
|
|
298
302
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const PARAM_DESCRIPTIONS = {
|
|
3
|
+
enabled: 'true enables the one-off bypass; false disables it. When enabled, the NEXT run of UpdatePopularityEstimatesFromBigqueryJob flushes the legitimate downward corrections currently held by the SYSTEMIC_DROP guardrail (and clears their popularity_drop_held_since), then the flag auto-resets to false so the bypass never silently stays on.',
|
|
4
|
+
};
|
|
5
|
+
const SetPopularityDropBypassSchema = z.object({
|
|
6
|
+
enabled: z.boolean().describe(PARAM_DESCRIPTIONS.enabled),
|
|
7
|
+
});
|
|
8
|
+
export function setPopularityDropBypass(_server, clientFactory) {
|
|
9
|
+
return {
|
|
10
|
+
name: 'set_popularity_drop_bypass',
|
|
11
|
+
description: `Enable or disable a deliberate, auditable ONE-OFF bypass of the SYSTEMIC_DROP guardrail in the popularity-estimates pipeline.
|
|
12
|
+
|
|
13
|
+
Background: UpdatePopularityEstimatesFromBigqueryJob holds large downward popularity corrections when more than ~10% of servers would drop at once (a possible systemic upstream event), keeping each flagged server at its stale value for ~3 days. During a known-legitimate remediation wave (e.g. correcting servers mis-linked to famous registry packages), that guardrail keeps genuinely-corrected servers visible at inflated values.
|
|
14
|
+
|
|
15
|
+
Enabling this bypass tells the NEXT job run to skip the SYSTEMIC_DROP hold for that single run only: it applies the corrected (dropped) BigQuery values, clears popularity_drop_held_since for the affected servers, then CONSUMES the flag (auto-resets enabled→false). The independent impossible-RISE guardrail is unaffected.
|
|
16
|
+
|
|
17
|
+
Returns the resulting bypass status (enabled / enabled_at / enabled_by).
|
|
18
|
+
|
|
19
|
+
Use cases:
|
|
20
|
+
- Enable the bypass before the next scheduled run to flush a known-legitimate correction wave caught in a systemic hold
|
|
21
|
+
- Disable the bypass if it was enabled in error and the next run has not yet consumed it`,
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
enabled: { type: 'boolean', description: PARAM_DESCRIPTIONS.enabled },
|
|
26
|
+
},
|
|
27
|
+
required: ['enabled'],
|
|
28
|
+
},
|
|
29
|
+
handler: async (args) => {
|
|
30
|
+
const validatedArgs = SetPopularityDropBypassSchema.parse(args);
|
|
31
|
+
const client = clientFactory();
|
|
32
|
+
try {
|
|
33
|
+
const result = await client.setPopularityDropBypass(validatedArgs.enabled);
|
|
34
|
+
const text = `Popularity drop bypass ${result.enabled ? 'ENABLED' : 'DISABLED'}.
|
|
35
|
+
- enabled: ${result.enabled}
|
|
36
|
+
- enabled_at: ${result.enabled_at ?? '(none)'}
|
|
37
|
+
- enabled_by: ${result.enabled_by ?? '(none)'}${result.enabled
|
|
38
|
+
? '\n\nThe next UpdatePopularityEstimatesFromBigqueryJob run will flush held drops and then auto-reset this flag.'
|
|
39
|
+
: ''}`;
|
|
40
|
+
return { content: [{ type: 'text', text }] };
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return {
|
|
44
|
+
content: [
|
|
45
|
+
{
|
|
46
|
+
type: 'text',
|
|
47
|
+
text: `Error setting popularity drop bypass: ${error instanceof Error ? error.message : String(error)}`,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
isError: true,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -65,6 +65,7 @@ import { discardGoodJob } from './tools/discard-good-job.js';
|
|
|
65
65
|
import { rescheduleGoodJob } from './tools/reschedule-good-job.js';
|
|
66
66
|
import { forceTriggerGoodJobCron } from './tools/force-trigger-good-job-cron.js';
|
|
67
67
|
import { cleanupGoodJobs } from './tools/cleanup-good-jobs.js';
|
|
68
|
+
import { setPopularityDropBypass } from './tools/set-popularity-drop-bypass.js';
|
|
68
69
|
// Proctor tools
|
|
69
70
|
import { runExamForMirror } from './tools/run-exam-for-mirror.js';
|
|
70
71
|
import { getExamResult } from './tools/get-exam-result.js';
|
|
@@ -263,6 +264,10 @@ const ALL_TOOLS = [
|
|
|
263
264
|
{ factory: rescheduleGoodJob, groups: ['good_jobs'], isWriteOperation: true },
|
|
264
265
|
{ factory: forceTriggerGoodJobCron, groups: ['good_jobs'], isWriteOperation: true },
|
|
265
266
|
{ factory: cleanupGoodJobs, groups: ['good_jobs'], isWriteOperation: true },
|
|
267
|
+
// setPopularityDropBypass toggles a one-off bypass of the SYSTEMIC_DROP guardrail in
|
|
268
|
+
// UpdatePopularityEstimatesFromBigqueryJob. It lives in good_jobs because it controls the
|
|
269
|
+
// behavior of a background job and is exposed via the same write-enabled good_jobs credential.
|
|
270
|
+
{ factory: setPopularityDropBypass, groups: ['good_jobs'], isWriteOperation: true },
|
|
266
271
|
// Proctor tools
|
|
267
272
|
{ factory: runExamForMirror, groups: ['proctor'], isWriteOperation: true },
|
|
268
273
|
{ factory: getExamResult, groups: ['proctor'], isWriteOperation: false },
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PopularityDropBypassStatus } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Enable or disable the one-off SYSTEMIC_DROP bypass for popularity estimates.
|
|
4
|
+
*
|
|
5
|
+
* POST /api/popularity_drop_bypass with body { enabled } sets the flag and
|
|
6
|
+
* returns the resulting status. When enabled, the NEXT run of
|
|
7
|
+
* UpdatePopularityEstimatesFromBigqueryJob flushes legitimate drops held by the
|
|
8
|
+
* SYSTEMIC_DROP guardrail, then consumes (auto-resets) the flag.
|
|
9
|
+
*/
|
|
10
|
+
export declare function setPopularityDropBypass(apiKey: string, baseUrl: string, enabled: boolean): Promise<PopularityDropBypassStatus>;
|
|
11
|
+
//# sourceMappingURL=set-popularity-drop-bypass.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { adminFetch } from './admin-fetch.js';
|
|
2
|
+
/**
|
|
3
|
+
* Enable or disable the one-off SYSTEMIC_DROP bypass for popularity estimates.
|
|
4
|
+
*
|
|
5
|
+
* POST /api/popularity_drop_bypass with body { enabled } sets the flag and
|
|
6
|
+
* returns the resulting status. When enabled, the NEXT run of
|
|
7
|
+
* UpdatePopularityEstimatesFromBigqueryJob flushes legitimate drops held by the
|
|
8
|
+
* SYSTEMIC_DROP guardrail, then consumes (auto-resets) the flag.
|
|
9
|
+
*/
|
|
10
|
+
export async function setPopularityDropBypass(apiKey, baseUrl, enabled) {
|
|
11
|
+
const url = new URL('/api/popularity_drop_bypass', baseUrl);
|
|
12
|
+
const response = await adminFetch(url.toString(), {
|
|
13
|
+
method: 'POST',
|
|
14
|
+
headers: {
|
|
15
|
+
'X-API-Key': apiKey,
|
|
16
|
+
Accept: 'application/json',
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
},
|
|
19
|
+
body: JSON.stringify({ enabled }),
|
|
20
|
+
});
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
if (response.status === 401) {
|
|
23
|
+
throw new Error('Invalid API key');
|
|
24
|
+
}
|
|
25
|
+
if (response.status === 403) {
|
|
26
|
+
throw new Error('User lacks write privileges');
|
|
27
|
+
}
|
|
28
|
+
if (response.status === 404) {
|
|
29
|
+
throw new Error('Popularity drop bypass endpoint not found');
|
|
30
|
+
}
|
|
31
|
+
if (response.status === 422) {
|
|
32
|
+
const errorData = (await response.json().catch(() => ({})));
|
|
33
|
+
throw new Error(`Validation failed: ${errorData.errors?.join(', ') || 'Unknown error'}`);
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`Failed to set popularity drop bypass: ${response.status} ${response.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
return (await response.json());
|
|
38
|
+
}
|
|
@@ -940,6 +940,13 @@ export function createMockPulseMCPAdminClient(mockData) {
|
|
|
940
940
|
deleted_count: 0,
|
|
941
941
|
};
|
|
942
942
|
},
|
|
943
|
+
async setPopularityDropBypass(enabled) {
|
|
944
|
+
return {
|
|
945
|
+
enabled,
|
|
946
|
+
enabled_at: enabled ? '2026-06-09T00:00:00Z' : null,
|
|
947
|
+
enabled_by: enabled ? 'mock-admin' : null,
|
|
948
|
+
};
|
|
949
|
+
},
|
|
943
950
|
// Proctor methods
|
|
944
951
|
async runExamForMirror() {
|
|
945
952
|
return {
|
package/shared/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
-
import type { Post, PostsResponse, CreatePostParams, UpdatePostParams, ImageUploadResponse, Author, AuthorsResponse, MCPServer, MCPClient, MCPImplementation, MCPImplementationsResponse, SaveMCPImplementationParams, CreateMCPImplementationParams, Provider, ProvidersResponse, OfficialMirrorQueueStatus, OfficialMirrorQueueResponse, OfficialMirrorQueueItemDetail, OfficialMirrorQueueActionResponse, UnofficialMirror, UnofficialMirrorsResponse, CreateUnofficialMirrorParams, UpdateUnofficialMirrorParams, OfficialMirrorRest, OfficialMirrorsResponse, Tenant, TenantsResponse, ListTenantServersResponse, BulkUpdateTenantServersParams, BulkUpdateTenantServersResponse, McpJson, McpJsonsResponse, CreateMcpJsonParams, UpdateMcpJsonParams, UnifiedMCPServer, UnifiedMCPServersResponse, UpdateUnifiedMCPServerParams, Redirect, RedirectsResponse, RedirectStatus, CreateRedirectParams, UpdateRedirectParams, GoodJob, GoodJobsResponse, GoodJobStatus, GoodJobCronSchedule, GoodJobProcess, GoodJobStatistics, GoodJobActionResponse, GoodJobCleanupResponse, ProctorRunExamParams, ProctorRunExamResponse, ProctorSaveResultsParams, ProctorSaveResultsResponse, ProctorRunsResponse, GetProctorRunsParams, ProctorMetadataResponse, DiscoveredUrlsResponse, MarkDiscoveredUrlProcessedParams, MarkDiscoveredUrlProcessedResponse, DiscoveredUrlStats, MozMetricsResponse, MozBacklinksResponse, MozStoredMetricsResponse, CreateTenantParams, ApiKey, CreateApiKeyParams, DeleteTenantParams, DeleteTenantResponse, DeleteApiKeyResponse, RecacheMCPServerResponse, SetKnownMissingInitToolsListResponse } from './types.js';
|
|
2
|
+
import type { Post, PostsResponse, CreatePostParams, UpdatePostParams, ImageUploadResponse, Author, AuthorsResponse, MCPServer, MCPClient, MCPImplementation, MCPImplementationsResponse, SaveMCPImplementationParams, CreateMCPImplementationParams, Provider, ProvidersResponse, OfficialMirrorQueueStatus, OfficialMirrorQueueResponse, OfficialMirrorQueueItemDetail, OfficialMirrorQueueActionResponse, UnofficialMirror, UnofficialMirrorsResponse, CreateUnofficialMirrorParams, UpdateUnofficialMirrorParams, OfficialMirrorRest, OfficialMirrorsResponse, Tenant, TenantsResponse, ListTenantServersResponse, BulkUpdateTenantServersParams, BulkUpdateTenantServersResponse, McpJson, McpJsonsResponse, CreateMcpJsonParams, UpdateMcpJsonParams, UnifiedMCPServer, UnifiedMCPServersResponse, UpdateUnifiedMCPServerParams, Redirect, RedirectsResponse, RedirectStatus, CreateRedirectParams, UpdateRedirectParams, GoodJob, GoodJobsResponse, GoodJobStatus, GoodJobCronSchedule, GoodJobProcess, GoodJobStatistics, GoodJobActionResponse, GoodJobCleanupResponse, PopularityDropBypassStatus, ProctorRunExamParams, ProctorRunExamResponse, ProctorSaveResultsParams, ProctorSaveResultsResponse, ProctorRunsResponse, GetProctorRunsParams, ProctorMetadataResponse, DiscoveredUrlsResponse, MarkDiscoveredUrlProcessedParams, MarkDiscoveredUrlProcessedResponse, DiscoveredUrlStats, MozMetricsResponse, MozBacklinksResponse, MozStoredMetricsResponse, CreateTenantParams, ApiKey, CreateApiKeyParams, DeleteTenantParams, DeleteTenantResponse, DeleteApiKeyResponse, RecacheMCPServerResponse, SetKnownMissingInitToolsListResponse } from './types.js';
|
|
3
3
|
export interface IPulseMCPAdminClient {
|
|
4
4
|
getPosts(params?: {
|
|
5
5
|
search?: string;
|
|
@@ -166,6 +166,7 @@ export interface IPulseMCPAdminClient {
|
|
|
166
166
|
discardGoodJob(id: string): Promise<GoodJobActionResponse>;
|
|
167
167
|
rescheduleGoodJob(id: string, scheduledAt: string): Promise<GoodJobActionResponse>;
|
|
168
168
|
forceTriggerGoodJobCron(cronKey: string): Promise<GoodJobActionResponse>;
|
|
169
|
+
setPopularityDropBypass(enabled: boolean): Promise<PopularityDropBypassStatus>;
|
|
169
170
|
cleanupGoodJobs(params?: {
|
|
170
171
|
older_than_days?: number;
|
|
171
172
|
status?: GoodJobStatus;
|
|
@@ -366,6 +367,7 @@ export declare class PulseMCPAdminClient implements IPulseMCPAdminClient {
|
|
|
366
367
|
discardGoodJob(id: string): Promise<GoodJobActionResponse>;
|
|
367
368
|
rescheduleGoodJob(id: string, scheduledAt: string): Promise<GoodJobActionResponse>;
|
|
368
369
|
forceTriggerGoodJobCron(cronKey: string): Promise<GoodJobActionResponse>;
|
|
370
|
+
setPopularityDropBypass(enabled: boolean): Promise<PopularityDropBypassStatus>;
|
|
369
371
|
cleanupGoodJobs(params?: {
|
|
370
372
|
older_than_days?: number;
|
|
371
373
|
status?: GoodJobStatus;
|
package/shared/server.js
CHANGED
|
@@ -60,6 +60,7 @@ import { retryGoodJob } from './pulsemcp-admin-client/lib/retry-good-job.js';
|
|
|
60
60
|
import { discardGoodJob } from './pulsemcp-admin-client/lib/discard-good-job.js';
|
|
61
61
|
import { rescheduleGoodJob } from './pulsemcp-admin-client/lib/reschedule-good-job.js';
|
|
62
62
|
import { forceTriggerGoodJobCron } from './pulsemcp-admin-client/lib/force-trigger-good-job-cron.js';
|
|
63
|
+
import { setPopularityDropBypass } from './pulsemcp-admin-client/lib/set-popularity-drop-bypass.js';
|
|
63
64
|
import { cleanupGoodJobs } from './pulsemcp-admin-client/lib/cleanup-good-jobs.js';
|
|
64
65
|
import { runExamForMirror } from './pulsemcp-admin-client/lib/run-exam-for-mirror.js';
|
|
65
66
|
import { saveResultsForMirror } from './pulsemcp-admin-client/lib/save-results-for-mirror.js';
|
|
@@ -293,6 +294,9 @@ export class PulseMCPAdminClient {
|
|
|
293
294
|
async forceTriggerGoodJobCron(cronKey) {
|
|
294
295
|
return forceTriggerGoodJobCron(this.apiKey, this.baseUrl, cronKey);
|
|
295
296
|
}
|
|
297
|
+
async setPopularityDropBypass(enabled) {
|
|
298
|
+
return setPopularityDropBypass(this.apiKey, this.baseUrl, enabled);
|
|
299
|
+
}
|
|
296
300
|
async cleanupGoodJobs(params) {
|
|
297
301
|
return cleanupGoodJobs(this.apiKey, this.baseUrl, params);
|
|
298
302
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import type { ClientFactory } from '../server.js';
|
|
3
|
+
export declare function setPopularityDropBypass(_server: Server, clientFactory: ClientFactory): {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
enabled: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: "true enables the one-off bypass; false disables it. When enabled, the NEXT run of UpdatePopularityEstimatesFromBigqueryJob flushes the legitimate downward corrections currently held by the SYSTEMIC_DROP guardrail (and clears their popularity_drop_held_since), then the flag auto-resets to false so the bypass never silently stays on.";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
required: string[];
|
|
15
|
+
};
|
|
16
|
+
handler: (args: unknown) => Promise<{
|
|
17
|
+
content: {
|
|
18
|
+
type: string;
|
|
19
|
+
text: string;
|
|
20
|
+
}[];
|
|
21
|
+
isError?: undefined;
|
|
22
|
+
} | {
|
|
23
|
+
content: {
|
|
24
|
+
type: string;
|
|
25
|
+
text: string;
|
|
26
|
+
}[];
|
|
27
|
+
isError: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=set-popularity-drop-bypass.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const PARAM_DESCRIPTIONS = {
|
|
3
|
+
enabled: 'true enables the one-off bypass; false disables it. When enabled, the NEXT run of UpdatePopularityEstimatesFromBigqueryJob flushes the legitimate downward corrections currently held by the SYSTEMIC_DROP guardrail (and clears their popularity_drop_held_since), then the flag auto-resets to false so the bypass never silently stays on.',
|
|
4
|
+
};
|
|
5
|
+
const SetPopularityDropBypassSchema = z.object({
|
|
6
|
+
enabled: z.boolean().describe(PARAM_DESCRIPTIONS.enabled),
|
|
7
|
+
});
|
|
8
|
+
export function setPopularityDropBypass(_server, clientFactory) {
|
|
9
|
+
return {
|
|
10
|
+
name: 'set_popularity_drop_bypass',
|
|
11
|
+
description: `Enable or disable a deliberate, auditable ONE-OFF bypass of the SYSTEMIC_DROP guardrail in the popularity-estimates pipeline.
|
|
12
|
+
|
|
13
|
+
Background: UpdatePopularityEstimatesFromBigqueryJob holds large downward popularity corrections when more than ~10% of servers would drop at once (a possible systemic upstream event), keeping each flagged server at its stale value for ~3 days. During a known-legitimate remediation wave (e.g. correcting servers mis-linked to famous registry packages), that guardrail keeps genuinely-corrected servers visible at inflated values.
|
|
14
|
+
|
|
15
|
+
Enabling this bypass tells the NEXT job run to skip the SYSTEMIC_DROP hold for that single run only: it applies the corrected (dropped) BigQuery values, clears popularity_drop_held_since for the affected servers, then CONSUMES the flag (auto-resets enabled→false). The independent impossible-RISE guardrail is unaffected.
|
|
16
|
+
|
|
17
|
+
Returns the resulting bypass status (enabled / enabled_at / enabled_by).
|
|
18
|
+
|
|
19
|
+
Use cases:
|
|
20
|
+
- Enable the bypass before the next scheduled run to flush a known-legitimate correction wave caught in a systemic hold
|
|
21
|
+
- Disable the bypass if it was enabled in error and the next run has not yet consumed it`,
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
enabled: { type: 'boolean', description: PARAM_DESCRIPTIONS.enabled },
|
|
26
|
+
},
|
|
27
|
+
required: ['enabled'],
|
|
28
|
+
},
|
|
29
|
+
handler: async (args) => {
|
|
30
|
+
const validatedArgs = SetPopularityDropBypassSchema.parse(args);
|
|
31
|
+
const client = clientFactory();
|
|
32
|
+
try {
|
|
33
|
+
const result = await client.setPopularityDropBypass(validatedArgs.enabled);
|
|
34
|
+
const text = `Popularity drop bypass ${result.enabled ? 'ENABLED' : 'DISABLED'}.
|
|
35
|
+
- enabled: ${result.enabled}
|
|
36
|
+
- enabled_at: ${result.enabled_at ?? '(none)'}
|
|
37
|
+
- enabled_by: ${result.enabled_by ?? '(none)'}${result.enabled
|
|
38
|
+
? '\n\nThe next UpdatePopularityEstimatesFromBigqueryJob run will flush held drops and then auto-reset this flag.'
|
|
39
|
+
: ''}`;
|
|
40
|
+
return { content: [{ type: 'text', text }] };
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return {
|
|
44
|
+
content: [
|
|
45
|
+
{
|
|
46
|
+
type: 'text',
|
|
47
|
+
text: `Error setting popularity drop bypass: ${error instanceof Error ? error.message : String(error)}`,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
isError: true,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
package/shared/tools.js
CHANGED
|
@@ -65,6 +65,7 @@ import { discardGoodJob } from './tools/discard-good-job.js';
|
|
|
65
65
|
import { rescheduleGoodJob } from './tools/reschedule-good-job.js';
|
|
66
66
|
import { forceTriggerGoodJobCron } from './tools/force-trigger-good-job-cron.js';
|
|
67
67
|
import { cleanupGoodJobs } from './tools/cleanup-good-jobs.js';
|
|
68
|
+
import { setPopularityDropBypass } from './tools/set-popularity-drop-bypass.js';
|
|
68
69
|
// Proctor tools
|
|
69
70
|
import { runExamForMirror } from './tools/run-exam-for-mirror.js';
|
|
70
71
|
import { getExamResult } from './tools/get-exam-result.js';
|
|
@@ -263,6 +264,10 @@ const ALL_TOOLS = [
|
|
|
263
264
|
{ factory: rescheduleGoodJob, groups: ['good_jobs'], isWriteOperation: true },
|
|
264
265
|
{ factory: forceTriggerGoodJobCron, groups: ['good_jobs'], isWriteOperation: true },
|
|
265
266
|
{ factory: cleanupGoodJobs, groups: ['good_jobs'], isWriteOperation: true },
|
|
267
|
+
// setPopularityDropBypass toggles a one-off bypass of the SYSTEMIC_DROP guardrail in
|
|
268
|
+
// UpdatePopularityEstimatesFromBigqueryJob. It lives in good_jobs because it controls the
|
|
269
|
+
// behavior of a background job and is exposed via the same write-enabled good_jobs credential.
|
|
270
|
+
{ factory: setPopularityDropBypass, groups: ['good_jobs'], isWriteOperation: true },
|
|
266
271
|
// Proctor tools
|
|
267
272
|
{ factory: runExamForMirror, groups: ['proctor'], isWriteOperation: true },
|
|
268
273
|
{ factory: getExamResult, groups: ['proctor'], isWriteOperation: false },
|
package/shared/types.d.ts
CHANGED
|
@@ -897,6 +897,11 @@ export interface SetKnownMissingInitToolsListResponse {
|
|
|
897
897
|
known_missing_init_tools_list: boolean;
|
|
898
898
|
known_missing_init_tools_list_filter_to: string | null;
|
|
899
899
|
}
|
|
900
|
+
export interface PopularityDropBypassStatus {
|
|
901
|
+
enabled: boolean;
|
|
902
|
+
enabled_at: string | null;
|
|
903
|
+
enabled_by: string | null;
|
|
904
|
+
}
|
|
900
905
|
export interface MozMetrics {
|
|
901
906
|
page_authority?: number;
|
|
902
907
|
domain_authority?: number;
|