Skip to content

crit push lacks ghost-success / at-least-once dedup safety #450

@tomasz-tomczyk

Description

@tomasz-tomczyk

Problem

crit push POSTs each comment via gh api and assigns the returned github_id locally. If the network call returns a transport error AFTER the server already accepted the POST (e.g., timeout reading the response, TCP RST during read), the local file does not get the github_id and the next push will POST again, creating a duplicate remote comment.

This is the classic at-least-once delivery problem. We have no idempotency key on the request, so retries can't be deduped server-side.

Suggested approach

Two options:

  1. Pull-before-push reconcile: before any POST, pull and dedupe by (path, line, body, author, commit_sha) to drop already-present items. Cheap when comment count is small, but loses precision if the user is editing the same line multiple times.
  2. Stable client request id stored alongside github_id (e.g., request_id populated client-side, posted in body markdown footer like <!-- crit:req:abc123 -->). On retry, dedupe by parsing that marker. Survives ghost-success.

Option 2 is more robust. Either way, decide before adding a roundtrip test — the test would otherwise be flaky.

Why no test yet

A reliable repro needs network mocking (kill connection between server-write and client-read). The roundtrip harness can't trigger this against the live API deterministically. Add the test once an idempotency strategy lands.

Source

Surfaced by the comment-scenario gap-finder ahead of PR #445.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions