thedotmack/claude-mem · error

sync hub push: 200 response acknowledgment multiplicity mism

Error message

sync hub push: 200 response acknowledgment multiplicity mismatch (expected ${expected}, received ${actual})

What it means

Thrown when, for some sent operation tuple, the number of acks received does not equal the number sent. Built from sentCounts (how many of each tuple the client pushed) vs ackCounts (how many the hub acked). A mismatch means the hub under- or over-acknowledged a tuple that DOES exist (extra/unknown tuples are caught earlier by [122]).

Source

Thrown at src/services/sync/CloudSync.ts:1059

      ackCounts.set(key, (ackCounts.get(key) ?? 0) + 1);

      const priorTupleSeq = tupleSeq.get(key);
      if (priorTupleSeq !== undefined && priorTupleSeq !== ack.seq) {
        throw new Error('sync hub push: duplicate operation tuple claimed different sequences');
      }
      tupleSeq.set(key, ack.seq);

      const priorSeqTuple = seqTuple.get(ack.seq);
      if (priorSeqTuple !== undefined && priorSeqTuple !== key) {
        throw new Error('sync hub push: distinct operation tuples claimed the same sequence');
      }
      seqTuple.set(ack.seq, key);
    }

    for (const [key, expected] of sentCounts) {
      const actual = ackCounts.get(key) ?? 0;
      if (actual !== expected) {
        throw new Error(
          `sync hub push: 200 response acknowledgment multiplicity mismatch (expected ${expected}, received ${actual})`
        );
      }
    }
    if (ackCounts.size !== sentCounts.size) {
      // Defensive: the unknown-tuple branch above should make this impossible.
      throw new Error('sync hub push: 200 response acknowledgment multiset mismatch');
    }

    if (compareCanonicalDecimals(response.head_seq, response.projected_seq) > 0) {
      throw new Error('sync hub push: checkpoint order requires head_seq <= projected_seq');
    }
    for (const ack of response.acked) {
      if (compareCanonicalDecimals(ack.seq, response.head_seq) > 0) {
        throw new Error('sync hub push: acknowledgment seq exceeds head_seq');
      }
      if (compareCanonicalDecimals(ack.seq, response.projected_seq) > 0) {
        throw new Error('sync hub push: sent operation is not covered by projected_seq');

View on GitHub (pinned to d768ba3643)

Solutions

  1. Use the (expected, received) counts in the message to see whether the hub under- or over-acked that tuple.
  2. Confirm the client is not double-adding identical WireOps to the push payload, and that the hub is not collapsing duplicates.
  3. Ensure hub and client agree on whether identical tuples are pushed/acked once-per-op or deduped.
  4. Re-run the push; a persistent mismatch for the same tuple indicates a hub dedup bug.
Defensive patterns

Strategy: try-catch

Validate before calling

// You can pre-dedup your pushed payload to avoid sending duplicate tuples
// that the hub may collapse:
function dedupPushed(pushed: WireOp[]): WireOp[] {
  const seen = new Set<string>();
  return pushed.filter(op => {
    const body = parseCanonicalOperation(op);
    const key = JSON.stringify([body.id, body.kind, body.entity_rev, op.operation_sha256]);
    if (seen.has(key)) return false; seen.add(key); return true;
  });
}

Try / catch

try { await cloudSync.push(pushed); }
catch (e) {
  if (e instanceof Error && e.message.includes('acknowledgment multiplicity mismatch')) {
    logger.error('SYNC', e.message); // (expected, received) in message
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: validatePushResponse iterates sentCounts and finds ackCounts.get(key) !== expected. Example: client sent 3 of the same tuple, hub acked only 2 (or 4). The message names the exact tuple count and received count.

Common situations: Hub silently dropped a duplicate operation, deduped identical tuples incorrectly, or acked an extra copy. Also from a hub that batches/merges identical operations differently than the client's per-op push granularity. Indicates the hub's acknowledgment multiset does not equal the sent multiset.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12). Data as JSON: /api/errors/f93e0925e96b98df. Report an issue: GitHub.