@sellable/mcp 0.1.535 → 0.1.537

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.
@@ -19,6 +19,43 @@ const REFILL_DONE_REASONS = new Set([
19
19
  "not_an_evergreen_workspace",
20
20
  "no_refillable_campaigns",
21
21
  ]);
22
+ const SCHEDULER_RUN_ENVELOPE_STATUSES = new Set([
23
+ "ran",
24
+ "attached",
25
+ "backoff",
26
+ "window_closed_noop",
27
+ "failed",
28
+ ]);
29
+ const SCHEDULER_RUN_RECEIPT_STATUSES = new Set([
30
+ "ran",
31
+ "window_closed_noop",
32
+ "failed",
33
+ ]);
34
+ const SCHEDULER_RUN_SKIP_REASONS = [
35
+ "window_closed",
36
+ "daily_limit",
37
+ "cooldown",
38
+ "sender_gate",
39
+ "credit_threshold",
40
+ "billing_blocked",
41
+ "duplicate_lead",
42
+ "no_senders",
43
+ "other",
44
+ ];
45
+ const SCHEDULER_RUN_HARD_BLOCK_REASONS = new Set([
46
+ "billing_blocked",
47
+ "credit_threshold",
48
+ "cooldown",
49
+ ]);
50
+ const SCHEDULER_RUN_NEXT_ACTIONS = new Set([
51
+ "refresh_paid_inmail_credits_then_rerun",
52
+ "wait_for_capacity_or_window",
53
+ "inspect_sender_mismatch",
54
+ "no_ready_cells_continue_refill_prep",
55
+ "scheduled_cells",
56
+ "investigate_deferred_reasons",
57
+ "investigate_scheduler_failure",
58
+ ]);
22
59
  function isRecord(value) {
23
60
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
24
61
  }
@@ -40,6 +77,253 @@ function arrayValue(value) {
40
77
  function hasBlocker(value, blocker) {
41
78
  return isRecord(value) && value.blocker === blocker;
42
79
  }
80
+ function schedulerRunSkipReasons(value) {
81
+ const raw = recordValue(value) ?? {};
82
+ const normalized = {};
83
+ for (const reason of SCHEDULER_RUN_SKIP_REASONS) {
84
+ normalized[reason] = numberValue(raw[reason]) ?? 0;
85
+ }
86
+ return normalized;
87
+ }
88
+ function schedulerRunCountMap(value) {
89
+ const raw = recordValue(value) ?? {};
90
+ return Object.fromEntries(Object.entries(raw)
91
+ .map(([key, rawCount]) => [key, numberValue(rawCount) ?? 0])
92
+ .filter(([, count]) => count > 0)
93
+ .sort(([left], [right]) => left.localeCompare(right)));
94
+ }
95
+ function schedulerRunNestedCountMap(value) {
96
+ const raw = recordValue(value) ?? {};
97
+ return Object.fromEntries(Object.entries(raw)
98
+ .map(([key, nested]) => [key, schedulerRunCountMap(nested)])
99
+ .filter(([, nested]) => Object.keys(nested).length > 0)
100
+ .sort(([left], [right]) => left.localeCompare(right)));
101
+ }
102
+ function dominantSchedulerRunSkipReason(skipReasons) {
103
+ let dominant = null;
104
+ let dominantCount = 0;
105
+ for (const reason of SCHEDULER_RUN_SKIP_REASONS) {
106
+ const count = skipReasons[reason] ?? 0;
107
+ if (count > dominantCount) {
108
+ dominant = reason;
109
+ dominantCount = count;
110
+ }
111
+ }
112
+ return dominantCount > 0 ? dominant : null;
113
+ }
114
+ function dominantSchedulerRunCountReason(counts) {
115
+ let dominant = null;
116
+ let dominantCount = 0;
117
+ for (const reason of Object.keys(counts).sort()) {
118
+ const count = counts[reason] ?? 0;
119
+ if (count > dominantCount) {
120
+ dominant = reason;
121
+ dominantCount = count;
122
+ }
123
+ }
124
+ return dominantCount > 0 ? dominant : null;
125
+ }
126
+ function schedulerRunReasonLooksLike(reasons, pattern) {
127
+ return Object.keys(reasons).some((reason) => (reasons[reason] ?? 0) > 0 && pattern.test(reason));
128
+ }
129
+ function schedulerRunHasReason(reasons, reason) {
130
+ return (reasons[reason] ?? 0) > 0;
131
+ }
132
+ function schedulerRunRecommendedAction(params) {
133
+ if (params.rawAction && SCHEDULER_RUN_NEXT_ACTIONS.has(params.rawAction)) {
134
+ return params.rawAction;
135
+ }
136
+ if (schedulerRunReasonLooksLike(params.prefilterReasons, /(credit|paid[_ -]?inmail|stale[_ -]?credit|missing[_ -]?credit)/i) ||
137
+ schedulerRunHasReason(params.skippedReasons, "credit_threshold") ||
138
+ schedulerRunHasReason(params.deferredReasons, "credit_threshold")) {
139
+ return "refresh_paid_inmail_credits_then_rerun";
140
+ }
141
+ if (schedulerRunReasonLooksLike(params.prefilterReasons, /sender[_ -]?mismatch/i)) {
142
+ return "inspect_sender_mismatch";
143
+ }
144
+ if (schedulerRunReasonLooksLike(params.prefilterReasons, /(no[_ -]?capacity|capacity|window|daily[_ -]?limit|cooldown)/i) ||
145
+ schedulerRunHasReason(params.skippedReasons, "window_closed") ||
146
+ schedulerRunHasReason(params.skippedReasons, "daily_limit") ||
147
+ schedulerRunHasReason(params.skippedReasons, "cooldown") ||
148
+ schedulerRunHasReason(params.deferredReasons, "window_closed") ||
149
+ schedulerRunHasReason(params.deferredReasons, "daily_limit") ||
150
+ schedulerRunHasReason(params.deferredReasons, "cooldown")) {
151
+ return "wait_for_capacity_or_window";
152
+ }
153
+ if (params.cellsScheduled > 0)
154
+ return "scheduled_cells";
155
+ if (params.readyCellsFound === 0)
156
+ return "no_ready_cells_continue_refill_prep";
157
+ if (params.cellsConsidered > 0)
158
+ return "investigate_deferred_reasons";
159
+ return null;
160
+ }
161
+ function schedulerRunCampaignScopeSummary(value) {
162
+ const raw = recordValue(value);
163
+ if (!raw) {
164
+ return {
165
+ totalEligibleTables: 0,
166
+ tablesWithReadyCells: 0,
167
+ returnedTables: 0,
168
+ omittedTables: 0,
169
+ truncated: false,
170
+ tables: [],
171
+ };
172
+ }
173
+ const rawTables = arrayValue(raw.tables).slice(0, 25);
174
+ const tables = rawTables
175
+ .map((entry) => {
176
+ const table = recordValue(entry);
177
+ if (!table)
178
+ return null;
179
+ const tableId = stringValue(table.tableId);
180
+ if (!tableId)
181
+ return null;
182
+ return {
183
+ tableId,
184
+ tableName: stringValue(table.tableName),
185
+ workspaceId: stringValue(table.workspaceId),
186
+ campaignOfferId: stringValue(table.campaignOfferId),
187
+ campaignName: stringValue(table.campaignName),
188
+ readyCells: numberValue(table.readyCells) ?? 0,
189
+ readyCellsByType: schedulerRunCountMap(table.readyCellsByType),
190
+ consideredCells: numberValue(table.consideredCells) ?? 0,
191
+ consideredCellsByType: schedulerRunCountMap(table.consideredCellsByType),
192
+ prefilteredCells: numberValue(table.prefilteredCells) ?? 0,
193
+ prefilterReasons: schedulerRunCountMap(table.prefilterReasons),
194
+ prefilterReasonsByType: schedulerRunNestedCountMap(table.prefilterReasonsByType),
195
+ };
196
+ })
197
+ .filter((entry) => entry != null);
198
+ return {
199
+ totalEligibleTables: numberValue(raw.totalEligibleTables) ?? 0,
200
+ tablesWithReadyCells: numberValue(raw.tablesWithReadyCells) ?? tables.length,
201
+ returnedTables: tables.length,
202
+ omittedTables: numberValue(raw.omittedTables) ?? 0,
203
+ truncated: booleanValue(raw.truncated) ?? false,
204
+ tables,
205
+ };
206
+ }
207
+ function sanitizeSchedulerRunReceipt(raw) {
208
+ const envelope = recordValue(raw);
209
+ if (!envelope)
210
+ return null;
211
+ const status = stringValue(envelope.status);
212
+ if (!status || !SCHEDULER_RUN_ENVELOPE_STATUSES.has(status))
213
+ return null;
214
+ const retryAfterMs = envelope.retryAfterMs == null ? null : numberValue(envelope.retryAfterMs);
215
+ if (envelope.retryAfterMs != null && retryAfterMs == null)
216
+ return null;
217
+ const receiptInput = envelope.receipt;
218
+ let receipt = null;
219
+ let dominantSkipReason = null;
220
+ let dominantPrefilterReason = null;
221
+ let dominantDeferredReason = null;
222
+ let recommendedNextAction = null;
223
+ if (receiptInput != null) {
224
+ const rawReceipt = recordValue(receiptInput);
225
+ if (!rawReceipt)
226
+ return null;
227
+ const receiptStatus = stringValue(rawReceipt.status);
228
+ if (!receiptStatus || !SCHEDULER_RUN_RECEIPT_STATUSES.has(receiptStatus)) {
229
+ return null;
230
+ }
231
+ const cellsConsidered = numberValue(rawReceipt.cellsConsidered);
232
+ const cellsScheduled = numberValue(rawReceipt.cellsScheduled);
233
+ const cellsSkipped = numberValue(rawReceipt.cellsSkipped);
234
+ const cellsDeferred = numberValue(rawReceipt.cellsDeferred);
235
+ const tablesFilteredForNoCapacity = numberValue(rawReceipt.tablesFilteredForNoCapacity);
236
+ if (cellsConsidered == null ||
237
+ cellsScheduled == null ||
238
+ cellsSkipped == null ||
239
+ cellsDeferred == null ||
240
+ tablesFilteredForNoCapacity == null) {
241
+ return null;
242
+ }
243
+ const skipReasons = schedulerRunSkipReasons(rawReceipt.skipReasons);
244
+ const skippedReasons = rawReceipt.skippedReasons
245
+ ? schedulerRunSkipReasons(rawReceipt.skippedReasons)
246
+ : skipReasons;
247
+ const deferredReasons = rawReceipt.deferredReasons
248
+ ? schedulerRunSkipReasons(rawReceipt.deferredReasons)
249
+ : schedulerRunSkipReasons(null);
250
+ const prefilterReasons = schedulerRunCountMap(rawReceipt.prefilterReasons);
251
+ const prefilterReasonsByType = schedulerRunNestedCountMap(rawReceipt.prefilterReasonsByType);
252
+ const readyCellsByType = schedulerRunCountMap(rawReceipt.readyCellsByType);
253
+ const consideredCellsByType = schedulerRunCountMap(rawReceipt.consideredCellsByType);
254
+ const prefilteredCellsByType = schedulerRunCountMap(rawReceipt.prefilteredCellsByType);
255
+ const readyCellsFound = numberValue(rawReceipt.readyCellsFound) ?? cellsConsidered;
256
+ const prefilteredCells = numberValue(rawReceipt.prefilteredCells) ?? 0;
257
+ const tablesFilteredForSenderMismatch = numberValue(rawReceipt.tablesFilteredForSenderMismatch) ?? 0;
258
+ dominantSkipReason = dominantSchedulerRunSkipReason(skipReasons);
259
+ dominantPrefilterReason =
260
+ dominantSchedulerRunCountReason(prefilterReasons);
261
+ dominantDeferredReason =
262
+ dominantSchedulerRunSkipReason(deferredReasons);
263
+ recommendedNextAction = schedulerRunRecommendedAction({
264
+ rawAction: stringValue(rawReceipt.nextAction),
265
+ readyCellsFound,
266
+ cellsConsidered,
267
+ cellsScheduled,
268
+ prefilterReasons,
269
+ skippedReasons,
270
+ deferredReasons,
271
+ });
272
+ receipt = {
273
+ status: receiptStatus,
274
+ ...(numberValue(rawReceipt.receiptVersion) != null
275
+ ? { receiptVersion: numberValue(rawReceipt.receiptVersion) }
276
+ : {}),
277
+ ...(numberValue(rawReceipt.diagnosticsVersion) != null
278
+ ? { diagnosticsVersion: numberValue(rawReceipt.diagnosticsVersion) }
279
+ : {}),
280
+ readyCellsFound,
281
+ readyCellsByType,
282
+ cellsConsidered,
283
+ consideredCellsByType,
284
+ cellsScheduled,
285
+ cellsSkipped,
286
+ cellsDeferred,
287
+ prefilteredCells,
288
+ prefilteredCellsByType,
289
+ tablesFilteredForNoCapacity,
290
+ tablesFilteredForSenderMismatch,
291
+ prefilterReasons,
292
+ prefilterReasonsByType,
293
+ skippedReasons,
294
+ deferredReasons,
295
+ skipReasons,
296
+ campaignScopeSummary: schedulerRunCampaignScopeSummary(rawReceipt.campaignScopeSummary),
297
+ ...(stringValue(rawReceipt.summary)
298
+ ? { summary: stringValue(rawReceipt.summary) }
299
+ : {}),
300
+ ...(recommendedNextAction ? { nextAction: recommendedNextAction } : {}),
301
+ };
302
+ }
303
+ return {
304
+ status,
305
+ retryAfterMs,
306
+ receipt,
307
+ dominantSkipReason,
308
+ dominantPrefilterReason,
309
+ dominantDeferredReason,
310
+ recommendedNextAction,
311
+ hardBlocked: (dominantSkipReason != null &&
312
+ SCHEDULER_RUN_HARD_BLOCK_REASONS.has(dominantSkipReason)) ||
313
+ (dominantDeferredReason != null &&
314
+ SCHEDULER_RUN_HARD_BLOCK_REASONS.has(dominantDeferredReason)) ||
315
+ recommendedNextAction === "refresh_paid_inmail_credits_then_rerun",
316
+ };
317
+ }
318
+ function schedulerRunReceiptIsFreshZeroScheduled(schedulerRunReceipt) {
319
+ const status = stringValue(schedulerRunReceipt?.status);
320
+ const fresh = status === "ran" || status === "window_closed_noop";
321
+ if (!fresh)
322
+ return false;
323
+ const receipt = recordValue(schedulerRunReceipt?.receipt);
324
+ return (status === "window_closed_noop" ||
325
+ numberValue(receipt?.cellsScheduled) === 0);
326
+ }
43
327
  function isLeaseLost(value) {
44
328
  return hasBlocker(value, "lease_lost");
45
329
  }
@@ -1022,6 +1306,7 @@ async function verifySchedulerWait(input, deps, ctx, action, budgets) {
1022
1306
  const enteredAt = stringValue(progress.schedulerWaitEnteredAt) ??
1023
1307
  (deps.now?.() ?? new Date()).toISOString();
1024
1308
  const jitFired = booleanValue(progress.schedulerJitFired) ?? false;
1309
+ let schedulerRunReceipt = recordValue(progress.schedulerRunReceipt) ?? null;
1025
1310
  if (!jitFired) {
1026
1311
  const senderId = actionSenderId(action);
1027
1312
  if (senderId) {
@@ -1048,16 +1333,27 @@ async function verifySchedulerWait(input, deps, ctx, action, budgets) {
1048
1333
  }
1049
1334
  }
1050
1335
  if (deps.requestSchedulerRun) {
1051
- await deps.requestSchedulerRun(input.workspaceId);
1336
+ try {
1337
+ schedulerRunReceipt = sanitizeSchedulerRunReceipt(await deps.requestSchedulerRun(input.workspaceId));
1338
+ }
1339
+ catch {
1340
+ schedulerRunReceipt = null;
1341
+ }
1052
1342
  }
1053
1343
  ctx.runState = mergeRunState(ctx.runState, {
1054
1344
  progress: mergeProgress(ctx, {
1055
1345
  schedulerWaitEnteredAt: enteredAt,
1056
1346
  schedulerJitFired: true,
1347
+ ...(schedulerRunReceipt ? { schedulerRunReceipt } : {}),
1057
1348
  }),
1058
1349
  });
1059
1350
  }
1060
- for (let poll = 0; poll < budgets.maxSchedulerReadbacks; poll += 1) {
1351
+ const zeroScheduledFresh = schedulerRunReceiptIsFreshZeroScheduled(schedulerRunReceipt);
1352
+ // EDGE-2: the on-demand run only executes placement; cron can still process
1353
+ // due/timed-out cells later. We still do one readback, then avoid burning the
1354
+ // full wait budget when the fresh receipt says nothing was placeable now.
1355
+ const readbackBudget = zeroScheduledFresh ? 1 : budgets.maxSchedulerReadbacks;
1356
+ for (let poll = 0; poll < readbackBudget; poll += 1) {
1061
1357
  const fresh = await deps.readPlan({
1062
1358
  workspaceId: input.workspaceId,
1063
1359
  intent: input.intent,
package/dist/server.js CHANGED
@@ -45,6 +45,7 @@ import { allTools } from "./tools/registry.js";
45
45
  import { getRows, getTableRows, getTableRowsMinimal } from "./tools/rows.js";
46
46
  import { addRubricItem, checkRubric, deleteRubricItem, draftRubrics, saveRubrics, selectNecessaryRubrics, updateRubricItem, waitForRubricResults, } from "./tools/rubrics.js";
47
47
  import { getSchedulerFillCapacity } from "./tools/scheduler-fill-capacity.js";
48
+ import { runSchedulerSweep } from "./tools/scheduler-run.js";
48
49
  import { getSenderRoutingTool, setSenderRoutingTool, } from "./tools/sender-routing.js";
49
50
  import { getSender, listSenders, refreshPaidInmailCredits, } from "./tools/senders.js";
50
51
  import { attachRecommendedSequence, attachSequence, createWorkflowTable, } from "./tools/sequencer.js";
@@ -235,6 +236,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
235
236
  case "get_scheduler_fill_capacity":
236
237
  result = await getSchedulerFillCapacity(args);
237
238
  break;
239
+ case "run_scheduler_sweep":
240
+ result = await runSchedulerSweep(args);
241
+ break;
238
242
  case "refill_sends":
239
243
  result = await executeRefillSendsCommand(args);
240
244
  break;
@@ -82,6 +82,7 @@ export interface SourceScoutRegistryResponse {
82
82
  codex: string;
83
83
  claude: string;
84
84
  parentThreadRule: string;
85
+ schedulerRunReceiptRule?: string;
85
86
  prepareMessagesRule?: string;
86
87
  };
87
88
  }
@@ -132,6 +133,7 @@ export interface PostFindLeadsScoutRegistryResponse {
132
133
  codex: string;
133
134
  claude: string;
134
135
  parentThreadRule: string;
136
+ schedulerRunReceiptRule?: string;
135
137
  prepareMessagesRule?: string;
136
138
  };
137
139
  }
@@ -379,6 +379,7 @@ export function getPostFindLeadsScoutRegistry() {
379
379
  codex: 'After confirm_lead_list copies source rows and the initial campaign-table execution slice exists, ask the filter-choice question immediately. Do not spawn anything before that question. After the answer, launch only Message Drafting. The filter-choice answer is the post-import user gate for this single worker; do not ask another question about starting it in step-wise or YOLO mode. The registry lookup is not a launch: after get_post_find_leads_scout_registry, immediately invoke Task/spawn_agent or the host background-agent mechanism before loading filter-leads.md, before saving rubrics, and before treating skip-filters as ready for message review. Both choices route through this kickoff; do not let filters_skipped jump straight from filter-choice to message-generation. If filters are chosen, the parent stays on Filter Rules and drafts/saves rubrics with MCP tools while Message Drafting runs in the background. If filters are skipped, move to Messages/message review only after Message Drafting has started or is ready; update_campaign(currentStep=messages) is not proof of launch. If the named Message Drafting custom agent is unavailable, spawn a generic gpt-5.5 xhigh Message Drafting background agent with the same lean campaign/table basis. When the background worker starts, persist workerDetails.messageDraftBuilder with statusSource "branch", status "branch-running", runId, startedAt, updatedAt, basisToken when known, and basis containing campaignId, selectedLeadListId, workflowTableId, filterChoice, and reviewBatchRowHash or reviewBatchRowIds; workerStatuses.messageDraftBuilder may be "running" as a simple badge only. Never put rich proof under workerStatuses and never use workerStatuses.messageDrafting. If no background-agent tool is callable, start the same full message branch inline before filter drafting or before skip-filter message review, record workerDetails.messageDraftBuilder with statusSource "parent-thread-fallback" and status "fallback-active", and require the same live context, prompt, assets, and validation gate before message review; do not wait until filters are saved and then call the registry.',
380
380
  claude: "After confirm_lead_list copies source rows and the initial campaign-table execution slice exists, ask the filter-choice question immediately. Do not invoke any Task/Agent before that question. After the answer, invoke only Message Drafting. If filters are chosen, parent drafts/saves rubrics with MCP tools while Message Drafting runs, asks filter approval, then joins Message Drafting. If filters are skipped, invoke only Message Drafting and move to Messages/message review.",
381
381
  parentThreadRule: 'Named agents are optional acceleration, but message drafting is not optional. The only normal background worker is Message Drafting. The filter-choice answer is the campaign-scoped go-ahead for this single post-import worker; do not ask another question to start it in step-wise or YOLO mode. If a named agent is unavailable, use a generic gpt-5.5 xhigh Message Drafting background agent. source work and filter work stay in the parent thread with MCP tools. If post-find-leads-message-scout is available, run it as the background Message Draft Builder after the filter-choice answer. The registry lookup is not a launch: get_post_find_leads_scout_registry only identifies the worker, and Message Drafting counts as started only after Task/spawn_agent or the host background-agent tool is invoked, or after the parent begins the same full message branch inline because no background-agent tool is callable. This launch must happen before loading filter-leads.md, save_rubrics, filter approval, or skip-filter message review; currentStep=messages is not proof of launch. If post-find-leads-message-scout is absent, do not customer-surface install status. Do not silently treat message drafting as started; the main thread must either launch the background worker or execute the same message branch from CampaignOffer state, selected source state, workflowTableId, and initial campaign-table execution slice rows. For a spawned worker, record workerDetails.messageDraftBuilder with statusSource branch / status branch-running, runId, startedAt, updatedAt, and basis containing campaignId, selectedLeadListId, workflowTableId, filterChoice, and reviewBatchRowHash or reviewBatchRowIds. workerStatuses.messageDraftBuilder is optional simple badge text only ("running", "ready", "blocked", "idle"); never put runId/statusSource/basis under workerStatuses and never use workerStatuses.messageDrafting. If no background-agent tool is callable, start that same full message branch inline before filter drafting or before skip-filter message review, record workerDetails.messageDraftBuilder with statusSource parent-thread-fallback / status fallback-active then ready, and require the same live context, prompt, assets, and validation gate before message review; do not report that as a background worker failure. If neither branch nor inline fallback can run, return blocked/retry-needed; do not wait until filters are saved and then call the registry. The Message Drafting handoff must be lean. Do not paste copied row counts, brief hashes, review-batch hashes, full reviewBatchRowIds, broad row data, or local debug artifacts into the spawn prompt. Local markdown/json files are not normal-path inputs. The filter-choice question is the first post-import user gate; do not load post-lead registries or filter references before it. Message drafting starts after the filter-choice answer, must load get_subskill_prompt({ subskillName: "generate-messages" }), and must load every required message asset named by generate-messages Mode 0 through get_subskill_asset before drafting. Reference Asset Loading means loading the required pre-draft reference pack before drafting; return blocked/retry-needed if required assets cannot be loaded; load ai-tells.md because it is never optional. The branch or parent-thread fallback loads the full generate-messages prompt and every referenced asset through get_subskill_asset. After generating/revising the candidate and before returning ready, must load get_subskill_prompt({ subskillName: "create-campaign-v2-validation" }) as the final internal validation gate, must read live campaign table state through scoped MCP/product tools, and must reject mismatched selectedLeadListId/workflowTableId/campaign/workspace input. Do not block when filters were chosen but leadScoringRubrics are not yet visible in the branch read; the parent owns save_rubrics and filter approval in parallel, so Message Drafting should return status ready with basisStatus usable_initial when campaign/list/table identity and the non-empty execution slice match. Do not use any alternate, local-artifact, or examples-only message prompt. User copy feedback, message QA, or rewrite requests before approve-message must be routed back to Message Drafting with the current recommendation, lean campaign/table basis, and latest user text; the parent must not rewrite or QA the template from memory and must not call update_campaign_brief before approve-message. The worker validates internally and returns only templateRecommendation, tokenFillRules, renderedGoodSample, status, approveOrReviseRecommendation, validationStatus, outputAt, outputHash, and blocked/retry detail. Do not render renderedFallbackSample, risk notes, or a qaReceipt on the normal happy path. On the filter path, save_rubrics keeps the browser on Filter Rules after save_rubrics so the user can approve the saved criteria; after saved-filter approval, move to Filter Leads with currentStep=apply-icp-rubric whether Message Drafting is ready or still running. Wait there for message approval. Enrichment, filtering, Generate Message cells, sender setup, sequence attach, and launch wait for template approval on the Use Template path. On the skip path, move to Messages/message review after Message Drafting has started or is ready and wait for message approval before enrichment or Settings. Do not render message review from checklist or shortcut instructions; message review requires a messageDraftRecommendation whose basis proves the generate-messages prompt, required message assets, and validation gate ran for the current campaign/table execution slice. Do not automatically rerun Message Drafting after filters/enrichment finish; show the initial draft by default and offer an enriched rewrite only with explicit user opt-in. Handoff and recommendation output are Markdown with labeled fields, not raw JSON.',
382
+ schedulerRunReceiptRule: "For refill prompt handoffs, scheduler-run receipt interpretation is mandatory: cellsConsidered is allocation-attempt count, not total ready supply, while readyCellsFound is ready inventory found before prefilters. Inspect campaignScopeSummary before assuming the selected refill campaign/table was included. Interpret prefiltered, skipped, and deferred separately. For ready closed-InMail cells with stale paid-credit prefilter/defer reasons, route to refresh_paid_inmail_credits_then_rerun once, then rerun/status. wait_for_capacity_or_window means report loaded/capped/waiting and do not source or prep more rows. no_ready_cells_continue_refill_prep means return to the refill/prep ladder. Do not treat cellsScheduled:0 alone as failure.",
382
383
  prepareMessagesRule: `Default create-campaign stays on the existing reviewBatchLimit:15 first campaign-table execution slice. For plain post-mint fill/load/refill requests, load get_subskill_prompt({ subskillName: "refill-sends-workflow" }) and get_subskill_asset({ subskillName: "refill-sends-workflow", assetPath: "core/flow.v1.json" }) to hasMore:false before operational steps, then call resolve_campaign_fill_route({ intent:"plain" }), list_senders, and get_campaign_refill_state for enough candidate campaigns to identify the campaign that most recently had scheduler-owned sends for the relevant sender set before any mutation. Route outcomes are route:"evergreen_horizon", route:"active_campaigns", and route:"ask_create"; if a plain managed-waterfall route has archived/completed skipped slots or does not cover the named sender set, immediately refetch with resolve_campaign_fill_route({ intent:"active" }) and inspect current dashboard-active ACTIVE/PAUSED campaign-backed sequence campaigns before declaring a sender blocked; stay in the same campaignOfferId/campaignId context after minting. Plain fill is not an alias for fill_campaign_horizon or campaign creation. fill_campaign_horizon is evergreen-only and is not the generic regular-campaign fill path. Campaign creation is allowed only after route:"ask_create" and explicit user selection; it is never the default response to plain fill. Treat "fill up/load sends" as capacity-fill preparation, and treat "refill senders", "fill senders", "max out senders", and "load everyone up" as sender-scoped capacity-fill preparation. For sender-scoped requests with no named senders, --yolo means all eligible healthy senders enrolled in active campaign-backed sequence campaigns in the active workspace; without --yolo, ask which eligible enrolled senders to refill before choosing campaigns or mutating. In non-yolo interactive Codex or Claude Code sessions, post the full sender/campaign/action approval packet in normal chat as Markdown first, then ask request_user_input/AskUserQuestion with exactly Accept and Decline and a compact body that refers back to the posted packet; do not duplicate the campaign table or full operator packet inside the structured question. The chat packet must show workspace, sender scope, a campaign-by-campaign table, exact ids/caps/dates, side effects, forbidden actions, and stop condition before mutation. Default --yolo target is the scheduler-forward 48-hour target window: sender-local send days whose configured sending windows overlap the rolling target window, skipping no-send-hour days. For campaign-scoped fill/refill, select the best recent-send campaign and calculate the bounded gap from healthy sender daily capacity minus projected coverage (actual sent plus future scheduler-owned scheduled sends) and ready-to-schedule rows, then prepare only that gap. For sender-scoped fill/refill, calculate the bounded gap per eligible sender across active enrolled campaigns, counting actual sent coverage, future scheduled rows, and ready-to-schedule rows across those campaigns, then choose the best same-sender campaign to fill each sender gap: prefer recent/future scheduler-owned sends for that sender, then strongest recent result evidence, then source health. Maintain a target-window saturation ledger per selected sender with selected send days, gross capacity, actual sent counts, future scheduler-owned scheduled counts, projected coverage, ready-to-schedule buffer, remaining projected gap, paid-InMail threshold feasibility, and the next MCP primitive. The structured packet lives in target.senderRefillPlans[] with target.eligibleSenderLedger, campaignRanking.options, sourcePlan, nextActions, manualAlternates, and target.globalActionQueue; preserve Need to prepare, Goal, Already sent, Scheduled, Ready and waiting to be scheduled, and Still need labels. In --yolo, execute exactly one globally ranked primitive from the post-refresh target.globalActionQueue[0], then rerun get_refill_target_plan before choosing another action. Refill action ladder: approve generated rows only when an explicit bounded approval gate exists, process all existing same-campaign unenriched/unprepared rows in bounded batches before any source work, then copy bounded net-new rows from the selected source (selectedLeadListId, provider, and source fingerprint preserved), then use provider-aligned source-more. A new source or provider switch changes the reply-rate baseline and is a manual alternate, not a --yolo side effect. The refill_sends MCP command maintains a run-local refreshedPaidInmailSenderIds set: if the first target plan contains refresh_paid_inmail_credits for stale/missing paid-InMail facts, refill_sends refreshes each selected paid-InMail sender at most once, reruns get_refill_target_plan, and returns autoPaidInmailRefresh plus the post-refresh targetPlan before the operator chooses prep/source-copy/bounded-approval/read-only wait. Freshness gate precedes scheduler wait: if any selected target.senderRefillPlans[].paidInmail.status is missing_credit_facts or stale_credit_facts, or the target plan contains refresh_paid_inmail_credits, do not enter wait_for_scheduler even when remainingReadyOrProjectedGap is 0; refresh exact sender credit facts once, reread get_refill_target_plan, then choose scheduler wait only if freshness is clean. Do not present paid-credit refresh as the next operator action after refill_sends has returned a post-refresh targetPlan. Do not stop after filling only one sender when the request was sender-scoped. In --yolo, continue through every safe selected sender/campaign action covered by the rendered packet, reread after each terminal apply/prep/source-copy/bounded-approval/read-only wait result, recompute the target-window saturation ledger, and keep going until projected coverage (sent + scheduled) fills the scheduler-forward target window or a concrete non-scheduler blocker is proven. Ready-to-schedule rows are buffer, not completion; if ready covers the projected gap but scheduled cells do not, report loaded, awaiting scheduler and run a persistent read-only scheduler wait/reread loop and keep the run open while awaiting_scheduler_after_ready_buffer is the only remaining state. Paid-InMail threshold changes and connection-campaign creation are explicit continuation options, never --yolo side effects. When no safe in-packet action remains return concrete continuation options with campaign names, exact ids, and which options require a new approval packet; do not return final completion for scheduler wait unless Christian explicitly asks for status or stops the run. Use the refill workflow to decide whether to enrich/prep more rows in that same recent-send/best-result campaign, add/import more rows to that same campaign/source path, use a different existing campaign only when the selected same-sender lane is blocked/exhausted/already loaded while the sender still has a gap, or ask what to create. Do not create warm-post-engager side campaigns. Surface sender-health blockers and paid-InMail threshold blockers separately from prepared/approved/scheduled counts. User-facing refill decisions must be campaign-name-first and sender-name-first, with ids as proof/execution targets only. Trust schedulerGate.sendable and scheduler blockers over raw unipileAccountStatus labels alone. For long-running prep use compact prep status checks, reread target plans after prep or cancel, avoid huge parallel target-plan reads when output is large, and if prepared/ready rows grow but sender-level projected coverage does not move after one bounded settle loop, pivot to compact prep status or a scheduler-proven lane instead of waiting on campaign-level ready counts. For already-running regular campaigns that need Signal Discovery source replenishment, use the guarded currentStep clear with clearCurrentStepIfMatches:"running", campaign-scoped provider prompt/search/select, and import_leads with the existing sourceLeadListId when a newly approved selected-post scrape would otherwise return reusedExistingSourceList. Before prep, inspect get_campaign_refill_state.preparationFrontier. If hasLaterPreparedIsland:true or earliestUnpreparedRow exists before later successful enrichment, use rowSelector:{type:"needsEnrichment"} with columnRole:"enrich" in table-position order or start_campaign_message_preparation adaptive defaults; do not use the UI Jump anchor or needsGeneratedMessage as the refill cursor. After confirm_lead_list copies rows into an existing table, avoid fixed maxRowsToCheck:100; if confirm_lead_list returns USER_ADDED_ROWS_LIMIT_EXCEEDED, create a bounded same-source split from selectedLeadListId with get_rows_minimal/load_csv_linkedin_leads, confirm that smaller source list into the same campaign, and inspect reviewBatch only as diagnostics unless the approved packet explicitly prioritizes the just-copied split and earlier needsEnrichment rows are exhausted, dependency-blocked, or excluded. For approval diagnostics use rowSelector:{type:"needsApproval"} after current generated messages exist; mutating Approved cells still requires approvalMode:approve and exact bounded approval. Do not interpret checkedRows as enriched rows; it is only the table cursor. Prepared, approved, and ready_to_schedule rows are intermediate states; never call them scheduled unless a re-read proves scheduler-owned scheduled cells with non-null scheduledFor contribute to projected coverage, and never call them complete unless a final re-read proves projected coverage fills the scheduler-forward target window. Before source import, prep, approval, or selected paused campaign start, require exact visible approval or --yolo packet auto-accept and a fresh get_campaign_refill_state reread; stop if freshness.stateHash or exact ids changed. For "approve X messages", use approvalMode:approve only when explicitly requested. For "schedule X sends" or "fill sender sends", approve only when explicitly requested, then re-read campaign/table scheduled counts; if projected coverage does not fill the horizon, keep polling when ready buffer covers the gap and report only interim prepared/approved/ready - awaiting scheduler status if Christian asks. Do not call start_campaign as part of fill/schedule horizon. start_campaign is allowed in refill only for exact selected PAUSED, dashboard-active, campaign-backed sequence targets named in the bounded packet, and the packet must state that starting can let the product scheduler schedule/send approved eligible sequence actions. Never start unrelated, archived, completed, draft, direct, or non-selected campaigns, never broad approve-all, and never use direct scheduler writes. campaignId is CampaignOffer.id. If the user asks to stop preparation, the target is wrong, or status shows the wrong campaign/table, use cancel_campaign_message_preparation only for the exact active job. Low-level selectors are diagnostics and recovery only for this lane.`,
383
384
  },
384
385
  };
@@ -5,6 +5,7 @@ import { runRefillV2Loop } from "../refill-run-loop.js";
5
5
  import { getPrepareCampaignMessagesStatus } from "./campaign-message-preparation.js";
6
6
  import { getRefillPlanV2 } from "./evergreen-refill-plan.js";
7
7
  import { executeOneYoloPrimitive, executeStartCampaignPrimitive, prepareRowSelectorValue, refillPrepareRequestHash, refreshPaidInmailCreditsWithRetry, } from "./refill-executors.js";
8
+ import { runSchedulerSweep } from "./scheduler-run.js";
8
9
  const FORBIDDEN_ACTIONS = [
9
10
  "Do not schedule sends.",
10
11
  "Do not send messages.",
@@ -152,6 +153,7 @@ export async function refillSendsV2Command(input) {
152
153
  localState: {
153
154
  writeRefillWorkspaceState,
154
155
  },
156
+ requestSchedulerRun: (workspaceId) => runSchedulerSweep({ workspaceId, action: "run" }),
155
157
  });
156
158
  return {
157
159
  ...(await maybeAddLostFenceGuidance(result, { ...input, workspaceId })),
@@ -233,6 +233,7 @@ export function refillSendsCommand(input = {}) {
233
233
  "Source/fallback primitives require receipt-proven exhaustion: existingRowFrontier.hasMoreFrontierRows:false, approvalCandidates:0, no fresh active prep, no stuckActiveCells, and no non-terminal approvedNotDispatched rows. Treat anomalies, stuckActiveCells, and non-terminal approvedNotDispatched as diagnose-and-report gates, not exhaustion. Terminal approvedNotDispatched blockers may be reported and then the ladder can proceed.",
234
234
  "In manual/non-yolo, scheduled, and --yolo modes, this tool may automatically refresh stale or missing paid-InMail credit facts once per selected sender when the first target plan returns refresh_paid_inmail_credits candidates. This is the only newly allowed automatic write in manual/non-yolo mode; it reruns get_refill_target_plan and returns autoPaidInmailRefresh with attemptedSenderIds, refreshedPaidInmailSenderIds, failedPaidInmailRefreshes, and the post-refresh targetPlan before any prep/source-copy/bounded-approval/read-only wait action is chosen.",
235
235
  "Freshness gate precedes scheduler wait: if any selected target.senderRefillPlans[].paidInmail.status is missing_credit_facts or stale_credit_facts, or the target plan contains refresh_paid_inmail_credits, do not enter wait_for_scheduler even when remainingReadyOrProjectedGap is 0; refresh exact sender credit facts once, reread get_refill_target_plan, then choose scheduler wait only if freshness is clean.",
236
+ "Scheduler-run receipt interpretation: cellsConsidered is allocation-attempt count, readyCellsFound is ready inventory before prefilters, and campaignScopeSummary must include the selected campaign/table before inferring it was ready-but-blocked. Read prefiltered, skipped, and deferred separately. For ready closed-InMail cells with stale paid-credit facts, route to refresh_paid_inmail_credits_then_rerun once, then rerun/status. wait_for_capacity_or_window means report loaded/capped/waiting and do not source or prep more rows. no_ready_cells_continue_refill_prep means return to the refill/prep ladder.",
236
237
  "For wait_for_active_work and wait_for_scheduler, honor the receipt's absolute wait.deadlineAt when present. If the deadline is expired on this call, escalate to diagnostics with the receipt evidence instead of issuing another blind wait.",
237
238
  "Do not present paid-credit refresh as the next operator action after refill_sends returns autoPaidInmailRefresh and the post-refresh targetPlan.",
238
239
  "If paid InMail feasibility remains below threshold after that automatic refresh, report the exact sender/campaign/table/column threshold action or same-campaign connection fallback; --yolo must not lower paid InMail thresholds or create campaigns.",
@@ -7370,6 +7370,25 @@ export declare const allTools: ({
7370
7370
  };
7371
7371
  required: string[];
7372
7372
  };
7373
+ } | {
7374
+ name: string;
7375
+ description: string;
7376
+ inputSchema: {
7377
+ type: string;
7378
+ properties: {
7379
+ workspaceId: {
7380
+ type: string;
7381
+ description: string;
7382
+ };
7383
+ action: {
7384
+ type: string;
7385
+ enum: string[];
7386
+ description: string;
7387
+ };
7388
+ };
7389
+ required: string[];
7390
+ additionalProperties: boolean;
7391
+ };
7373
7392
  } | {
7374
7393
  name: string;
7375
7394
  description: string;
@@ -40,6 +40,7 @@ import { refillTargetPlanToolDefinitions } from "./refill-target-plan.js";
40
40
  import { rowToolDefinitions } from "./rows.js";
41
41
  import { rubricToolDefinitions } from "./rubrics.js";
42
42
  import { schedulerFillCapacityToolDefinitions } from "./scheduler-fill-capacity.js";
43
+ import { schedulerRunToolDefinitions } from "./scheduler-run.js";
43
44
  import { senderRoutingToolDefinitions } from "./sender-routing.js";
44
45
  import { senderToolDefinitions } from "./senders.js";
45
46
  import { sequencerToolDefinitions } from "./sequencer.js";
@@ -57,6 +58,7 @@ export const allTools = [
57
58
  ...refillPlanV2ToolDefinitions,
58
59
  ...refillTargetPlanToolDefinitions,
59
60
  ...schedulerFillCapacityToolDefinitions,
61
+ ...schedulerRunToolDefinitions,
60
62
  ...refillSendsToolDefinitions,
61
63
  ...refillSendsV2ToolDefinitions,
62
64
  ...setupEvergreenCampaignsToolDefinitions,
@@ -0,0 +1,27 @@
1
+ type SchedulerRunAction = "run" | "status";
2
+ type RunSchedulerSweepInput = {
3
+ workspaceId: string;
4
+ action?: SchedulerRunAction;
5
+ };
6
+ export declare const schedulerRunToolDefinitions: {
7
+ name: string;
8
+ description: string;
9
+ inputSchema: {
10
+ type: string;
11
+ properties: {
12
+ workspaceId: {
13
+ type: string;
14
+ description: string;
15
+ };
16
+ action: {
17
+ type: string;
18
+ enum: string[];
19
+ description: string;
20
+ };
21
+ };
22
+ required: string[];
23
+ additionalProperties: boolean;
24
+ };
25
+ }[];
26
+ export declare function runSchedulerSweep(input: RunSchedulerSweepInput): Promise<unknown>;
27
+ export {};
@@ -0,0 +1,45 @@
1
+ import { getApi } from "../api.js";
2
+ import { normalizeExplicitWorkspaceId, workspaceRequestOptions, } from "./workspace-context.js";
3
+ async function postSchedulerRun(body, workspaceId) {
4
+ const api = getApi();
5
+ const requestOptions = workspaceRequestOptions(workspaceId);
6
+ return requestOptions
7
+ ? api.post("/api/v3/mcp/scheduler-run", body, requestOptions)
8
+ : api.post("/api/v3/mcp/scheduler-run", body);
9
+ }
10
+ export const schedulerRunToolDefinitions = [
11
+ {
12
+ name: "run_scheduler_sweep",
13
+ description: 'Trigger the product scheduler placement sweep for one explicit workspace now, or read the last on-demand scheduler run status with action "status". A run is workspace-wide, not a scoped run for one campaign/table, and returns a synchronous envelope with status ran, attached, backoff, window_closed_noop, or failed; retryAfterMs for backoff replays; and a backward-compatible receipt. In v2 receipts, readyCellsFound is total scheduler-ready supply found before filters, cellsConsidered is the allocation-attempt count that survived prefilters, prefiltered means ready cells removed before allocation such as no capacity, stale paid InMail credit facts, or sender mismatch, skipped means considered cells rejected by hard scheduler gates, and deferred means considered cells waiting on windows/capacity/cooldown. campaignScopeSummary lists bounded tables/campaigns the workspace-wide run inspected; absence there is not a scoped-run guarantee that the target was ready. The receipt can include readyCellsByType, consideredCellsByType, prefilterReasons, skippedReasons, deferredReasons, summary, and nextAction. It places cells within existing scheduler gates only: it can move placement earlier, but it cannot bypass sending windows, daily limits, cooldowns, sender gates, billing, or credit thresholds, and it never sends messages directly. Repeated calls inside the backoff window replay the last receipt verbatim. Status is read-only and scoped to the last on-demand run only; cron sweeps are not recorded here.',
14
+ inputSchema: {
15
+ type: "object",
16
+ properties: {
17
+ workspaceId: {
18
+ type: "string",
19
+ description: "Explicit request-scoped workspace id for scheduled/yolo refill automation. Pass this instead of switching the shared active workspace.",
20
+ },
21
+ action: {
22
+ type: "string",
23
+ enum: ["run", "status"],
24
+ description: 'Use "run" to trigger a placement sweep now. Use "status" for a read-only view of the last on-demand run. Defaults to "run".',
25
+ },
26
+ },
27
+ required: ["workspaceId"],
28
+ additionalProperties: false,
29
+ },
30
+ },
31
+ ];
32
+ export async function runSchedulerSweep(input) {
33
+ const workspaceId = normalizeExplicitWorkspaceId(input.workspaceId);
34
+ if (!workspaceId) {
35
+ throw new Error("workspaceId is required for run_scheduler_sweep.");
36
+ }
37
+ const action = input.action ?? "run";
38
+ if (action !== "run" && action !== "status") {
39
+ throw new Error('action must be "run" or "status" for run_scheduler_sweep.');
40
+ }
41
+ return postSchedulerRun({
42
+ workspaceId,
43
+ action,
44
+ }, workspaceId);
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellable/mcp",
3
- "version": "0.1.535",
3
+ "version": "0.1.537",
4
4
  "type": "module",
5
5
  "description": "Sellable MCP server for Claude Code, Codex, and Hermes campaign workflows",
6
6
  "main": "dist/index.js",
@@ -6,6 +6,7 @@ allowed-tools:
6
6
  - mcp__sellable__refill_sends
7
7
  - mcp__sellable__get_refill_target_plan
8
8
  - mcp__sellable__get_scheduler_fill_capacity
9
+ - mcp__sellable__run_scheduler_sweep
9
10
  - mcp__sellable__refresh_paid_inmail_credits
10
11
  - mcp__sellable__get_subskill_asset
11
12
  - mcp__sellable__get_auth_status
@@ -114,10 +115,11 @@ or install-time workspace mapping. Pass `workspaceId` on every scheduled or
114
115
  `--yolo` refill tool call, including setup/read calls such as
115
116
  `refill_sends`, `get_refill_target_plan`, `list_senders`,
116
117
  `get_sender_routing`, `resolve_campaign_fill_route`,
117
- `get_campaign_refill_state`, `get_scheduler_fill_capacity`, and any later
118
- refill mutation covered by the packet. Missing `workspaceId` in scheduled or
119
- `--yolo` mode is a blocker; stop with `WORKSPACE_REQUIRED` instead of running
120
- against an implicit or guessed workspace.
118
+ `get_campaign_refill_state`, `get_scheduler_fill_capacity`,
119
+ `run_scheduler_sweep`, and any later refill mutation covered by the packet.
120
+ Missing `workspaceId` in scheduled or `--yolo` mode is a blocker; stop with
121
+ `WORKSPACE_REQUIRED` instead of running against an implicit or guessed
122
+ workspace.
121
123
 
122
124
  Do not solve scheduled or `--yolo` workspace uncertainty by changing the shared
123
125
  active workspace. Manual interactive workspace switching remains a separate
@@ -269,6 +271,23 @@ need raw proof, call the read-only `get_scheduler_fill_capacity` query for the
269
271
  same sender/action/date; it tells the MCP how many cells the product scheduler
270
272
  will try to place and does not import, approve, schedule, refresh credits, or
271
273
  mutate.
274
+ When the refill loop has ready rows and needs scheduler pickup now, use
275
+ `run_scheduler_sweep` with the same explicit `workspaceId`; it can place cells
276
+ within existing scheduler gates and returns the receipt, but it never sends or
277
+ bypasses limits.
278
+ Scheduler-run receipt interpretation: `cellsConsidered is allocation-attempt
279
+ count`, not total ready supply, while `readyCellsFound` is ready inventory found
280
+ before prefilters. Inspect `campaignScopeSummary` before assuming the selected
281
+ refill campaign/table was included; if absent, do not infer that target was
282
+ ready-but-blocked. Interpret `prefiltered` as ready cells removed before
283
+ allocation, `skipped` as considered cells blocked by scheduler gates, and
284
+ `deferred` as considered cells waiting on windows/capacity/cooldown. For ready
285
+ closed-InMail cells with stale paid-credit prefilter/defer reasons, refresh
286
+ paid-InMail credits once through existing tools, then rerun `run_scheduler_sweep`
287
+ or read `action:"status"`; `refresh_paid_inmail_credits_then_rerun` is that
288
+ path. `wait_for_capacity_or_window` means report loaded/capped/waiting and do
289
+ not source or prep more rows; `no_ready_cells_continue_refill_prep` means return
290
+ to the refill/prep ladder. Do not treat `cellsScheduled:0` alone as failure.
272
291
  If the target plan is complete by projected coverage, report that the selected
273
292
  target is already filled and no-op without asking for approval. If the ready
274
293
  buffer covers the projected gap, paid InMail credit facts are fresh for every
@@ -128,6 +128,17 @@ Reinvoke with that handle. The approximately five minute scheduler budget is at
128
128
  the run level, not one tool call. A window-closed or loaded-awaiting scheduler
129
129
  report must include remaining-ready count, exact expected pickup time, and the
130
130
  resume handle; never treat bare "awaiting scheduler" copy as a final answer.
131
+ Scheduler-run receipt interpretation still applies to terminal progress:
132
+ `cellsConsidered is allocation-attempt count`, not total ready supply, while
133
+ `readyCellsFound` is ready inventory found before prefilters. Inspect
134
+ `campaignScopeSummary` before assuming the selected refill campaign/table was
135
+ included; if absent, do not infer that target was ready-but-blocked. Interpret
136
+ `prefiltered`, `skipped`, and `deferred` separately. For ready closed-InMail
137
+ cells with stale paid-credit reasons, route to
138
+ `refresh_paid_inmail_credits_then_rerun` once, then rerun/status.
139
+ `wait_for_capacity_or_window` means report loaded/capped/waiting and do not
140
+ source or prep more rows; `no_ready_cells_continue_refill_prep` means return to
141
+ the refill/prep ladder. Do not treat `cellsScheduled:0` alone as failure.
131
142
 
132
143
  After the first prep batch, read the conversion-verdict journal line. It is
133
144
  rendered from packet facts: `supplyCensus`, `censusReason`, and
@@ -117,6 +117,17 @@ Scheduler wait is cross-invocation. If the tool returns `in_progress` with
117
117
  sweep guidance, re-invoke `refill_sends_v2` with `{runId, fence}`. The scheduler
118
118
  budget is cumulative at the run level. Zero pickup after a confirmed sweep is
119
119
  debugged from `pipelineDiagnosis`; it is not waited out forever.
120
+ Scheduler-run receipt interpretation still applies to terminal progress:
121
+ `cellsConsidered is allocation-attempt count`, not total ready supply, while
122
+ `readyCellsFound` is ready inventory found before prefilters. Inspect
123
+ `campaignScopeSummary` before assuming the selected refill campaign/table was
124
+ included; if absent, do not infer that target was ready-but-blocked. Interpret
125
+ `prefiltered`, `skipped`, and `deferred` separately. For ready closed-InMail
126
+ cells with stale paid-credit reasons, route to
127
+ `refresh_paid_inmail_credits_then_rerun` once, then rerun/status.
128
+ `wait_for_capacity_or_window` means report loaded/capped/waiting and do not
129
+ source or prep more rows; `no_ready_cells_continue_refill_prep` means return to
130
+ the refill/prep ladder. Do not treat `cellsScheduled:0` alone as failure.
120
131
 
121
132
  ## G4 Report
122
133
 
@@ -6,6 +6,7 @@ allowed-tools:
6
6
  - mcp__sellable__get_subskill_asset
7
7
  - mcp__sellable__get_refill_target_plan
8
8
  - mcp__sellable__get_scheduler_fill_capacity
9
+ - mcp__sellable__run_scheduler_sweep
9
10
  - mcp__sellable__refresh_paid_inmail_credits
10
11
  - mcp__sellable__list_senders
11
12
  - mcp__sellable__get_sender_routing
@@ -67,11 +68,12 @@ request-scoped `workspaceId`. Pass that same `workspaceId` on every refill tool
67
68
  call in this workflow: `get_refill_target_plan`, `list_senders`,
68
69
  `get_sender_routing`, `resolve_campaign_fill_route`,
69
70
  `get_campaign_refill_state`, `get_scheduler_fill_capacity`,
70
- `refresh_paid_inmail_credits`, source import/readiness calls, preparation calls,
71
- approval calls, and campaign start calls. Missing `workspaceId` in scheduled or
72
- `--yolo` mode is a blocker; return or report `WORKSPACE_REQUIRED` instead of
73
- falling back to shared config state. Manual interactive workspace switching is
74
- diagnostic setup only and is not an automation control path.
71
+ `run_scheduler_sweep`, `refresh_paid_inmail_credits`, source import/readiness
72
+ calls, preparation calls, approval calls, and campaign start calls. Missing
73
+ `workspaceId` in scheduled or `--yolo` mode is a blocker; return or report
74
+ `WORKSPACE_REQUIRED` instead of falling back to shared config state. Manual
75
+ interactive workspace switching is diagnostic setup only and is not an
76
+ automation control path.
75
77
 
76
78
  Goal-mode continuation: a skill cannot create or invoke `/goal` by itself. When
77
79
  this workflow is already running inside an active Codex goal, keep that goal
@@ -186,6 +188,24 @@ files or memory.
186
188
  how many cells the product scheduler will try to place for that sender; it
187
189
  does not create rows, import, approve, schedule, refresh paid-InMail credits,
188
190
  or mutate thresholds.
191
+ When ready rows exist and the wait is for scheduler pickup, call
192
+ `run_scheduler_sweep` with the same explicit `workspaceId` to request the
193
+ product scheduler placement pass now and read its receipt. This may place
194
+ cells within existing gates, never sends messages, and never bypasses limits.
195
+ Scheduler-run receipt interpretation: `cellsConsidered is
196
+ allocation-attempt count`, not total ready supply, while `readyCellsFound`
197
+ is ready inventory found before prefilters. Inspect `campaignScopeSummary`
198
+ before assuming the selected refill campaign/table was included; if absent,
199
+ do not infer that target was ready-but-blocked. Interpret `prefiltered` as
200
+ ready cells removed before allocation, `skipped` as considered cells blocked
201
+ by scheduler gates, and `deferred` as considered cells waiting on
202
+ windows/capacity/cooldown. For ready closed-InMail cells with stale
203
+ paid-credit prefilter/defer reasons, refresh paid-InMail credits once through
204
+ existing tools, then rerun `run_scheduler_sweep` or read `action:"status"`;
205
+ `refresh_paid_inmail_credits_then_rerun` is that path.
206
+ `wait_for_capacity_or_window` means report loaded/capped/waiting and do not
207
+ source or prep more rows; `no_ready_cells_continue_refill_prep` means return
208
+ to the refill/prep ladder. Do not treat `cellsScheduled:0` alone as failure.
189
209
  If `status:"complete"`, report the target, selected dates, sent count,
190
210
  scheduled count, projected count, campaign ids, and no-op proof without
191
211
  asking for approval or mutating.
@@ -191,7 +191,8 @@
191
191
  "description": "Read-only scheduler polling after rows are ready and paid-credit facts are fresh.",
192
192
  "allowedTools": [
193
193
  "get_refill_target_plan",
194
- "get_scheduler_fill_capacity"
194
+ "get_scheduler_fill_capacity",
195
+ "run_scheduler_sweep"
195
196
  ],
196
197
  "entryConditions": [
197
198
  "remainingReadyOrProjectedGap == 0",
@@ -201,6 +202,10 @@
201
202
  ],
202
203
  "rules": [
203
204
  "Poll every 60-120 seconds or on the host continuation interval.",
205
+ "Use run_scheduler_sweep with the explicit workspaceId when ready rows need scheduler pickup now; it places cells only inside existing gates and never sends.",
206
+ "cellsConsidered is allocation-attempt count; inspect campaignScopeSummary before assuming the selected refill campaign/table was included or ready-but-blocked.",
207
+ "Read prefiltered, skipped, and deferred separately: prefiltered ready closed-InMail cells with stale paid-credit facts require refresh_paid_inmail_credits_then_rerun once, then rerun/status.",
208
+ "wait_for_capacity_or_window means report loaded/capped/waiting and do not source or prep more rows; no_ready_cells_continue_refill_prep means return to the refill/prep ladder.",
204
209
  "Stop waiting when projected coverage fills the target.",
205
210
  "Leave wait if a concrete non-scheduler blocker appears.",
206
211
  "Do not mark complete or blocked only because awaiting_scheduler_after_ready_buffer persists."