GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it · Issue #2455 · developing-today/code

projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455

New issue
Copy link
New issue
Copy link
Closed
#4189
Closed
projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it#2455
#4189
Copy link
Assignees
dezren39
Labels
app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobsource/design-architectFiled by the repo design architect jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Description

@dezren39
dezren39
opened on Oct 29, 2026
Issue body actions

Summary

In the PM projector, a comment that GitHub deleted can come back. The comments table's monotonic guard — the ON CONFLICT … WHERE excluded.source_updated_at >= pmp_comments.source_updated_at clause that is supposed to stop stale writes overwriting newer state — keys on the comment's creation time, not its last-update time, and the delete path never advances it. So any stale created/edited upsert for that comment (a redelivered or out-of-order webhook delivery under a new delivery id, a replayed fixture, a delayed retry) satisfies the guard with equality and overwrites the row wholesale — including setting deleted back to 0 and restoring the pre-edit body. Nothing ever re-deletes it: the comment no longer exists in GitHub's comment lists, so reconciliation never sees it again. The deleted comment is permanently back in the unified activity stream (getComments / subject activity) with its original text.

Items do not have this flaw: fromIssueOrPr sets source_updated_at: updatedAt (projector.ts:68), so a stale item write is genuinely refused. Comments are the asymmetric case.

Evidence (main 5a34fa7)

  • pm-stack/projector/src/projector.ts:95 — commentCommon builds every webhook comment row with source_updated_at: createdAt, even for edited events whose updated_at is newer. The row's own updated_at field (line ~86) is set correctly; only the guard key is wrong.
  • pm-stack/projector/src/reconcile.ts:91 and :131 — both reconciliation comment builders (issue/review comments, and reviews) also set source_updated_at: createdAt, so reconcile writes carry the same broken guard key. (Schema comment in schema.sql describes the field as "created_at (or updated_at)" — the code always picks created_at.)
  • pm-stack/projector/src/store.ts:205-224 — upsertComment's conflict update sets every column, including deleted = excluded.deleted (:221), gated only by WHERE excluded.source_updated_at >= pmp_comments.source_updated_at (:224). A stale upsert's guard key (created_at) is equal to the stored one, so it always passes.
  • pm-stack/projector/src/store.ts:247-252 — markCommentDeleted sets deleted = 1 and fetched_at, but does not advance source_updated_at, so the delete leaves no trace the guard can compare against. It is called from the issue_comment deleted branch (projector.ts:159) and the pull_request_review_comment deleted branch (projector.ts:213) — both event kinds are affected.

Verified this run with a laptop Bun probe driving the real applyEvent + real store.ts against a real libSQL file DB (files md5-identical to main 5a34fa7: store.ts 448fc963…, projector.ts d692044c…, schema.sql afaecba…):

after created:               {"body":"original","deleted":0,"source_updated_at":"2026-10-01T01:00:00Z"}
after edited:                {"body":"EDITED",  "deleted":0,"source_updated_at":"2026-10-01T01:00:00Z"}
after deleted:               {"body":"EDITED",  "deleted":1,"source_updated_at":"2026-10-01T01:00:00Z"}
after stale created replay:  {"body":"original","deleted":0,"source_updated_at":"2026-10-01T01:00:00Z"}

Note the second row: even a legitimate edit does not advance source_updated_at, so the stale replay in step 4 also reverts the body from EDITED back to original — the guard cannot order any two versions of a comment, only refuse writes older than its creation (which never exist).

Probe: ~/git/fleet/probe-2026-10-29-laneB-projdel/probe.ts (laptop).

Why it matters

The projector is the fleet dashboard's unified comment-activity projection (aggregator requirement #2): a deleted comment reappearing — with the text its author deliberately removed — is a correctness and trust problem in exactly the stream people read to know what was said. Deletes are also how spam/abuse removals and mistaken posts are retracted; the projection silently un-retracts them on any out-of-order or redelivered delivery, and no subsequent reconciliation repairs it, because GitHub's lists no longer contain the comment. The same broken guard key also means comment edits have no ordering protection at all: a delayed pre-edit delivery overwrites the edited body (self-heals only if a later reconcile happens to re-fetch that comment).

Acceptance criteria

  • After a comment is marked deleted, no upsert whose source state predates the delete can set deleted back to 0 or otherwise modify the row (a stale created/edited replay leaves deleted = 1 and the last body intact).
  • The comments guard key reflects last-update time: an edited upsert advances it, and a stale pre-edit upsert is refused (body stays at the edited text), matching the items behaviour.
  • markCommentDeleted records delete-time ordering information (or an equivalent tombstone rule) so the delete wins against earlier-created source states, for both issue_comment and pull_request_review_comment deletes, and for webhook- and reconcile-sourced writes.
  • Regression tests cover: create → edit → delete → stale-create replay (stays deleted, edited body kept); create → edit → stale-create replay without a delete (edited body kept); the equivalent review-comment delete path; and a fresh legitimate post-delete write ordering case triage defines (e.g. a genuinely newer update still applies, if triage decides one exists).

Dedup

gh searches (open + closed) for markCommentDeleted, pmp_comments, source_updated_at, "projector deleted comment", "projector comment monotonic": no issue covers comment guard ordering or delete resurrection. #1547 (open) is the projector read-API limit parameter — different defect, same service. #1529 (open) is the projector's GitHub App key decoding. Sibling guard asymmetry: items (projector.ts:68) already use updatedAt correctly and are not in scope.

Activity

Next
  1. developing-today commented on Oct 29, 2026

    @developing-today
    developing-todayBot
    on Oct 29, 2026 – with developing.today
    Contributor
    More actions

    CODE-1254

  2. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued queue task
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    status/needs-triageNot yet triaged; needs a first look
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 29, 2026
  3. dezren39 commented on Oct 29, 2026

    @dezren39
    dezren39
    on Oct 29, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator-code-b
    • Session / ID: new-issue-creator-code-b cron run 2026-10-29 17:50 CDT
    • Found via: filed this run
    • Task: Filed the projector comments guard flaw: commentCommon (projector.ts:95) and both reconcile comment builders (reconcile.ts:91,131) set source_updated_at = createdAt, so upsertComment's monotonic guard (store.ts:224) can never order comment versions, and markCommentDeleted (store.ts:247-252) never advances it — a stale created replay after a delete resurrects the comment (deleted=0) with its pre-edit body, permanently (GitHub's lists no longer contain it, so reconcile never re-deletes). Verified with a laptop Bun probe driving the real applyEvent + store.ts against a real libSQL DB (main 5a34fa7, md5-identical files): create→edit→delete→stale replay ended deleted=0, body reverted to "original"; even the legitimate edit never advanced source_updated_at.
    • Expectation: effort xs; done when triage pins the guard-key fix (last-update time + delete tombstone ordering) and routes a small_fix packet with the named regression tests.
    • Links: projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455 projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455 · distinct from projector: read-API limit is never validated — ?limit=-1 returns the whole table and ?limit=2.7 500s the request #1547 (projector limit param) and projector(github): GITHUB_APP_PRIVATE_KEY 'base64 of PEM' form fails — decodePem never unwraps it, appJwt throws Invalid keyData #1529 (App key decoding)
  4. github-actions
    assigned
    dezren39
    on Oct 30, 2026
  5. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    on Nov 1, 2026
  6. 10 remaining items

  7. dezren39 commented on Nov 1, 2026

    @dezren39
    dezren39
    on Nov 1, 2026
    MemberAuthor
    More actions

    🤖 Agent note · handed off

    • Agent: repo-worker-code
    • Session / ID: ses_e5e69a9b065ffeQti2RVWVJFrY · triage task 3672
    • Outcome: Reproduced the stale-comment resurrection on current main and routed the bounded implementation packet as queued small_fix task 5339: projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455
    • Next: Worker 5339 should implement the monotonic update-time guard + absorbing delete tombstone and regression tests; projector(reviews): webhook reviews get a fabricated created_at (delivery time, not submitted_at) — reconcile's correct row is then guard-refused forever #3087 review submitted_at and projector(comments): pmp_comments is keyed by the bare GitHub numeric ID — an issue comment, a review comment and a review with the same ID silently overwrite each other #2694 numeric-ID collision stay separate.
  8. dezren39 commented on Nov 2, 2026

    @dezren39
    dezren39
    on Nov 2, 2026
    MemberAuthor
    More actions

    🤖 Agent note · picked up

    • Agent: repo-worker-code
    • Session / ID: ses_e5e655f0c49ffeLxp0KHVxIoa0 · queue task 5339
    • Task: Implement monotonic update-time ordering and absorbing delete tombstones for mutable comment rows, with store-backed, webhook, and reconcile regression tests.
    • Links: projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455
  9. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    queue/queuedHas a queued queue task
    status/triagedTriaged and routed (see agent note)
    on Nov 2, 2026
  10. dezren39 commented on Nov 2, 2026

    @dezren39
    dezren39
    on Nov 2, 2026
    MemberAuthor
    More actions

    🤖 Agent note · handed off

    • Agent: repo-worker-code
    • Session / ID: ses_e5e655f0c49ffeLxp0KHVxIoa0 · queue task 5339
    • Outcome: Implemented comment update-time guards and absorbing delete tombstones; PR fix(projector): preserve comment ordering and tombstones #4189 is open. Full projector suite passes: 64 tests, 294 expectations.
    • CI: Queued on PR fix(projector): preserve comment ordering and tombstones #4189 at handoff; local TypeScript check has the same unrelated Bun.serve errors on clean main.
    • Next: Review CI and merge PR fix(projector): preserve comment ordering and tombstones #4189 when checks are green.
    • Links: fix(projector): preserve comment ordering and tombstones #4189 · projector(comments): a deleted comment is resurrected by any stale upsert — the comments monotonic guard keys on created_at and markCommentDeleted never advances it #2455
  11. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 2, 2026
  12. dezren39
    added a parent issue on Nov 2, 2026
    • Design: a projection writes only what the event proves — one application contract for the PM projector #4302
  13. dezren39
    added
    source/design-architectFiled by the repo design architect job
    on Nov 2, 2026
  14. dezren39 commented on Nov 2, 2026

    @dezren39
    dezren39
    on Nov 2, 2026
    MemberAuthor
    More actions

    Design architect, pass 37 (2026-11-02): this issue is adopted as Phase 2 of design #4302 (a projection writes only what the event proves — one application contract for the PM projector), together with #2694 and #3087, and linked as a sub-issue of #4302. Design doc: files/designs/code-projector-application-contract.md (goal workspace).

    Recorded decisions for this phase: the comments guard key becomes the object's last-update time (updated_at ?? created_at) in both writers, and comment deletion is absorbing — the conflict clause sets deleted = MAX(deleted, excluded.deleted), so no upsert ever clears it. GitHub has no un-delete, which answers this issue's open post-delete-write question: no legitimate post-delete write resurrects a comment. The two compose: the last-update key orders versions (stale pre-edit replays are refused), absorbing deleted makes the delete itself unreplayable-away even by an equal-key replay; markCommentDeleted needs no key change. Triage: record the phase structure — do not re-file, re-scope or split this issue.

  15. dezren39
    closed this as completedin #4189on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobsource/design-architectFiled by the repo design architect jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.