{"record":{"id":"d9657f0c6c43a206","repo":"thedotmack/claude-mem","slug":"sync-hub-push-distinct-operation-tuples-claimed-t","errorCode":null,"errorMessage":"sync hub push: distinct operation tuples claimed the same sequence","messagePattern":"sync hub push: distinct operation tuples claimed the same sequence","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/services/sync/CloudSync.ts","lineNumber":1051,"sourceCode":"    const ackCounts = new Map<string, number>();\n    const tupleSeq = new Map<string, string>();\n    const seqTuple = new Map<string, string>();\n    for (const ack of response.acked) {\n      const key = operationTupleKey(ack);\n      if (!sentCounts.has(key)) {\n        throw new Error('sync hub push: 200 response contains an extra or mismatched acknowledgment tuple');\n      }\n      ackCounts.set(key, (ackCounts.get(key) ?? 0) + 1);\n\n      const priorTupleSeq = tupleSeq.get(key);\n      if (priorTupleSeq !== undefined && priorTupleSeq !== ack.seq) {\n        throw new Error('sync hub push: duplicate operation tuple claimed different sequences');\n      }\n      tupleSeq.set(key, ack.seq);\n\n      const priorSeqTuple = seqTuple.get(ack.seq);\n      if (priorSeqTuple !== undefined && priorSeqTuple !== key) {\n        throw new Error('sync hub push: distinct operation tuples claimed the same sequence');\n      }\n      seqTuple.set(ack.seq, key);\n    }\n\n    for (const [key, expected] of sentCounts) {\n      const actual = ackCounts.get(key) ?? 0;\n      if (actual !== expected) {\n        throw new Error(\n          `sync hub push: 200 response acknowledgment multiplicity mismatch (expected ${expected}, received ${actual})`\n        );\n      }\n    }\n    if (ackCounts.size !== sentCounts.size) {\n      // Defensive: the unknown-tuple branch above should make this impossible.\n      throw new Error('sync hub push: 200 response acknowledgment multiset mismatch');\n    }\n\n    if (compareCanonicalDecimals(response.head_seq, response.projected_seq) > 0) {","sourceCodeStart":1033,"sourceCodeEnd":1069,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/services/sync/CloudSync.ts#L1033-L1069","documentation":"Two distinct acked tuples claim the same seq — the hub handed one log sequence number to two different operations. Sequence ownership must be unique (one seq ↔ one op); this check, together with the tuple→seq check, proves the bijective mapping before anything is stamped. Caught pre-stamp in validatePushResponse; flush() backs off and retries. Indicates a hub sequence-allocation bug or replica divergence.","triggerScenarios":"Hub allocates seqs with a non-atomic counter under concurrent appends; two replicas independently assigned the same seq after a partition; a rebuild/replay of the hub log reused sequence numbers.","commonSituations":"Hub concurrency regression after a performance refactor; multi-writer hub topology introduced without single-writer sequencing; log replay tooling reusing seqs.","solutions":["Inspect the hub log around the reported seq for double-assigned entries","Make sequence allocation single-writer/atomic (transactional autoincrement on the authoritative log)","If replicas append in parallel, route all appends through one sequencer before fan-out","Repair or re-sequence the affected log segment, then let clients re-converge via retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if (/distinct operation tuples claimed the same sequence/.test(sync.status().lastError ?? '')) {\n  // seq double-allocation on the hub: inspect the log around that seq, fix the sequencer\n}","preventionTips":["Allocate sequence numbers from a single-writer atomic source (autoincrement on the authoritative log)","Never allow parallel replicas to assign seqs independently","Hub CI: concurrency test asserting unique seq ownership across parallel appends"],"tags":["sync","hub","integrity","sequence","invariant"],"backgroundTag":"data-integrity-violation","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}