@sellable/mcp 0.1.748 → 0.1.750

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.
@@ -689,6 +689,13 @@ type WorkspaceCoordinatorWaitAction = {
689
689
  reason: string | null;
690
690
  };
691
691
  declare function clearCompleteDefersForCampaign(runState: Record<string, unknown> | undefined, campaignId: string | null, preserveActionKey?: string | null): Record<string, unknown> | undefined;
692
+ declare function deferWorkspaceExactTarget(params: {
693
+ runState: unknown;
694
+ target: WorkspaceExactTarget;
695
+ blocker: string;
696
+ }): {
697
+ coordinatorBlockedExactTargets: (Record<string, unknown> | null)[];
698
+ };
692
699
  export declare function approvedPacketComparison(input: RefillSendsCommandInput, targetPlan: unknown): {
693
700
  changed: boolean;
694
701
  expectedTargetShapeRevision: string | null;
@@ -732,6 +739,9 @@ type RefillSenderSelectorMiss = {
732
739
  export declare const refillSendsDeferInternals: {
733
740
  clearCompleteDefersForCampaign: typeof clearCompleteDefersForCampaign;
734
741
  SUPPLY_INVALIDATED_DEFER_BLOCKERS: Set<string>;
742
+ deferWorkspaceExactTarget: typeof deferWorkspaceExactTarget;
743
+ EXACT_ACTION_COMPLETE_BLOCKER: string;
744
+ EXACT_ACTION_COMPLETE_CONFIRMED_BLOCKER: string;
735
745
  };
736
746
  export declare function executeRefillSendsCommand(input?: RefillSendsCommandInput): Promise<import("./workspace-context.js").WorkspaceRequiredResult | {
737
747
  ok: boolean;
@@ -933,10 +933,17 @@ const WORKSPACE_SUPPLY_ACTION_FAMILIES = new Set([
933
933
  // stale proof, not by absent supply.
934
934
  //
935
935
  // Same shape as 112c: a bounded ATTEMPT must not harden into a standing claim.
936
+ const EXACT_ACTION_COMPLETE_BLOCKER = "exact_action_complete";
937
+ // fix(112as-b): a completeness claim RE-CONFIRMED by a second identical receipt.
938
+ // The 112as release deliberately never waives this, which is what stops the
939
+ // release from looping forever across continuations.
940
+ const EXACT_ACTION_COMPLETE_CONFIRMED_BLOCKER = "exact_action_complete_confirmed";
936
941
  const SUPPLY_INVALIDATED_DEFER_BLOCKERS = new Set([
937
942
  "complete",
938
943
  "capped_by_scheduler",
939
944
  "exact_action_complete",
945
+ // new supply genuinely invalidates even a re-confirmed claim
946
+ "exact_action_complete_confirmed",
940
947
  ]);
941
948
  function clearCompleteDefersForCampaign(runState, campaignId,
942
949
  // fix(112ar): the action that JUST landed keeps its own defer. Clearing it
@@ -1204,20 +1211,42 @@ function deferWorkspaceExactTarget(params) {
1204
1211
  const existing = Array.isArray(current.coordinatorBlockedExactTargets)
1205
1212
  ? current.coordinatorBlockedExactTargets.map(recordValue).filter(Boolean)
1206
1213
  : [];
1214
+ const matchesTarget = (entry) => {
1215
+ const candidate = coordinatorBlockedExactTargets({
1216
+ version: 1,
1217
+ coordinatorBlockedExactTargets: [entry],
1218
+ })[0];
1219
+ return Boolean(candidate &&
1220
+ coordinatorBlockedExactTargetMatches(candidate, params.target));
1221
+ };
1222
+ // fix(112as-b): 112as bounds its release with `waiveCompleteClaims`, which is
1223
+ // per SELECTION CALL. Every next_exact_target continuation starts a fresh
1224
+ // selection, so the same completed edge was released over and over and the
1225
+ // coordinator ping-ponged between two already-complete edges without
1226
+ // executing either (Dotwork: alternating prepare_messages:e5fc49c5 and
1227
+ // approve_messages:4bf8c1e1). That traded the invariant breach for a
1228
+ // livelock.
1229
+ //
1230
+ // Bound the release PER EDGE instead: the first exact_action_complete is a
1231
+ // bounded attempt and stays releasable, but if the SAME edge comes back
1232
+ // complete a second time, the claim is CONFIRMED by its own re-receipt and is
1233
+ // never waived again. Self-limiting, and it needs no new ledger — the entry
1234
+ // already survives continuations inside workspaceRunState.
1235
+ const alreadyCompleteClaim = params.blocker === EXACT_ACTION_COMPLETE_BLOCKER &&
1236
+ existing.some((entry) => matchesTarget(entry) &&
1237
+ (stringValue(recordValue(entry)?.blocker) ===
1238
+ EXACT_ACTION_COMPLETE_BLOCKER ||
1239
+ stringValue(recordValue(entry)?.blocker) ===
1240
+ EXACT_ACTION_COMPLETE_CONFIRMED_BLOCKER));
1207
1241
  return {
1208
1242
  ...current,
1209
1243
  coordinatorBlockedExactTargets: [
1210
- ...existing.filter((entry) => {
1211
- const candidate = coordinatorBlockedExactTargets({
1212
- version: 1,
1213
- coordinatorBlockedExactTargets: [entry],
1214
- })[0];
1215
- return (!candidate ||
1216
- !coordinatorBlockedExactTargetMatches(candidate, params.target));
1217
- }),
1244
+ ...existing.filter((entry) => !matchesTarget(entry)),
1218
1245
  {
1219
1246
  ...params.target,
1220
- blocker: params.blocker,
1247
+ blocker: alreadyCompleteClaim
1248
+ ? EXACT_ACTION_COMPLETE_CONFIRMED_BLOCKER
1249
+ : params.blocker,
1221
1250
  decidedAt: new Date().toISOString(),
1222
1251
  },
1223
1252
  ],
@@ -1470,12 +1499,18 @@ async function selectWorkspaceExactTarget(input, workspacePlanOverride, options
1470
1499
  // opening is barred for those targets (in the selection loop below).
1471
1500
  const completeDeferredTargets = blockedExactTargets.filter((blocked) => blocked.blocker === "complete" ||
1472
1501
  blocked.blocker === "capped_by_scheduler");
1502
+ const waiveCompleteClaims = options.waiveCompleteClaims === true;
1473
1503
  const prefilterBlockedTargets = blockedExactTargets.filter((blocked) => blocked.blocker !== "complete" &&
1474
- blocked.blocker !== "capped_by_scheduler");
1504
+ blocked.blocker !== "capped_by_scheduler" &&
1505
+ // fix(112as): on the bounded release pass, a self-issued
1506
+ // exact_action_complete claim no longer bars its own edge.
1507
+ !(waiveCompleteClaims && blocked.blocker === "exact_action_complete"));
1475
1508
  const seenTargetKeys = new Set();
1476
1509
  // fix(112ak): every refusal is recorded so a non-empty-census terminal can
1477
1510
  // name the concrete per-lane blocker instead of reporting a bare dead end.
1478
- const coordinatorExcludedEdges = [];
1511
+ const coordinatorExcludedEdges = [
1512
+ ...(options.seedExcludedEdges ?? []),
1513
+ ];
1479
1514
  const recordExcludedEdge = (candidate, blocked, stage) => {
1480
1515
  coordinatorExcludedEdges.push({
1481
1516
  campaignId: candidate.campaignId,
@@ -1487,6 +1522,46 @@ async function selectWorkspaceExactTarget(input, workspacePlanOverride, options
1487
1522
  stage,
1488
1523
  });
1489
1524
  };
1525
+ // fix(112as): a self-issued `exact_action_complete` claim is a BOUNDED
1526
+ // ATTEMPT, not a standing proof — the same principle as 112c.
1527
+ //
1528
+ // The claim is dropped at BOTH refusal points (prefilter and post_rebind),
1529
+ // and 112ar only clears it when a prepare/supply action LANDS on that
1530
+ // campaign. When every edge the planner exposed for the campaign is already
1531
+ // held by such a claim, nothing can land, so nothing ever clears it: a closed
1532
+ // loop that terminals `actionable_supply_not_queued` against visible supply
1533
+ // (Dotwork 2026-07-30/31: 100 enrichment candidates, approve_messages
1534
+ // refused at post_rebind on every run). 112ak made that terminal NAME the
1535
+ // refusal, which is honest but does not fill the day.
1536
+ //
1537
+ // So: if the ONLY reason we have no selection is our own completeness
1538
+ // claims, and the census still shows actionable supply, waive them and
1539
+ // re-select ONCE. Bounded by waiveCompleteClaims so it can never livelock,
1540
+ // and it reuses the SAME workspacePlan so no extra planner call is made and
1541
+ // the census stays consistent with the decision.
1542
+ const completeClaimReleaseRetry = async () => {
1543
+ if (waiveCompleteClaims)
1544
+ return null;
1545
+ if (coordinatorExcludedEdges.length === 0)
1546
+ return null;
1547
+ if (!coordinatorExcludedEdges.every((edge) => edge.blocker === "exact_action_complete")) {
1548
+ return null;
1549
+ }
1550
+ const census = workspaceGapBearingActionableSupply(workspacePlan);
1551
+ if (census.actionableRows <= 0 && !census.frontierHasMoreRows) {
1552
+ return null;
1553
+ }
1554
+ const released = await selectWorkspaceExactTarget(input, workspacePlan, {
1555
+ ...options,
1556
+ waiveCompleteClaims: true,
1557
+ seedExcludedEdges: [...coordinatorExcludedEdges],
1558
+ });
1559
+ // The release may only ADD a dispatch. If it fails to bind an edge, fall
1560
+ // back to this pass's terminal, which already NAMES the refused edges —
1561
+ // 112ak's honesty guarantee must not be traded away for an optimistic
1562
+ // retry that lands on a vaguer blocker.
1563
+ return released.status === "selected" ? released : null;
1564
+ };
1490
1565
  const targetCandidates = actionTargets.filter((candidate) => {
1491
1566
  const key = workspaceExactTargetKey(candidate);
1492
1567
  if (seenTargetKeys.has(key))
@@ -1583,6 +1658,9 @@ async function selectWorkspaceExactTarget(input, workspacePlanOverride, options
1583
1658
  const readyLoadedSelection = readySurplusLoadedSelection(workspacePlan);
1584
1659
  if (readyLoadedSelection)
1585
1660
  return readyLoadedSelection;
1661
+ const releasedEmptyCandidates = await completeClaimReleaseRetry();
1662
+ if (releasedEmptyCandidates)
1663
+ return releasedEmptyCandidates;
1586
1664
  return {
1587
1665
  status: "blocked",
1588
1666
  ...classifyWorkspaceUnavailableTerminal(workspacePlan, (excludedTargets.length > 0 ||
@@ -1761,6 +1839,13 @@ async function selectWorkspaceExactTarget(input, workspacePlanOverride, options
1761
1839
  blocked.blocker === "loaded_awaiting_scheduler") {
1762
1840
  return false;
1763
1841
  }
1842
+ // fix(112as): the release pass must waive here too. post_rebind
1843
+ // re-matches AFTER the exact preflight re-issues the semantic
1844
+ // actionKey, so waiving only at prefilter would leave the edge blocked.
1845
+ if (waiveCompleteClaims &&
1846
+ blocked.blocker === "exact_action_complete") {
1847
+ return false;
1848
+ }
1764
1849
  recordExcludedEdge(exactSelectedTarget, blocked, "post_rebind");
1765
1850
  return true;
1766
1851
  })) {
@@ -1880,6 +1965,9 @@ async function selectWorkspaceExactTarget(input, workspacePlanOverride, options
1880
1965
  const readyLoadedSelection = readySurplusLoadedSelection(workspacePlan);
1881
1966
  if (readyLoadedSelection)
1882
1967
  return readyLoadedSelection;
1968
+ const releasedFilteredCandidates = await completeClaimReleaseRetry();
1969
+ if (releasedFilteredCandidates)
1970
+ return releasedFilteredCandidates;
1883
1971
  return {
1884
1972
  status: "blocked",
1885
1973
  ...classifyWorkspaceUnavailableTerminal(workspacePlan, (workspaceCoverage.remainingReadyOrProjectedGap !== 0
@@ -3056,6 +3144,9 @@ async function resolveRefillSenderSelectors(params) {
3056
3144
  export const refillSendsDeferInternals = {
3057
3145
  clearCompleteDefersForCampaign,
3058
3146
  SUPPLY_INVALIDATED_DEFER_BLOCKERS,
3147
+ deferWorkspaceExactTarget,
3148
+ EXACT_ACTION_COMPLETE_BLOCKER,
3149
+ EXACT_ACTION_COMPLETE_CONFIRMED_BLOCKER,
3059
3150
  };
3060
3151
  export async function executeRefillSendsCommand(input = {}) {
3061
3152
  const normalizedInput = normalizeRefillSendsInput(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellable/mcp",
3
- "version": "0.1.748",
3
+ "version": "0.1.750",
4
4
  "type": "module",
5
5
  "description": "Sellable MCP server for Claude Code, Codex, and Hermes campaign workflows",
6
6
  "main": "dist/index.js",