Skip to content

pm-stack: decision-events Worker read-back pagination skips events sharing a timestamp (PR #9341 Codex P2) #9614

Closed

Description

@dezren39

Finding (from PR review)

PR #9341 (merged, feat(pm-stack): decision-set event pipeline — Turso sync + Cloudflare Worker/D1/DO (#9335)) adds the decision-events Worker's read-back endpoint. Codex's P2 finding: the pagination cursor is the last returned event's timestamp alone, so events sharing that timestamp are skipped. With three events at the same ts and limit=2, the third event is unreachable through pagination, even though the query already orders by (ts, event_id).

"When a page ends within a group of events sharing the same timestamp, requesting the next page with after equal to the last returned timestamp skips all remaining events in that group. For example, three events with identical ts values and limit=2 make the third event unreachable through pagination. The ordering already uses (ts, event_id); expose and apply that same composite cursor so bounded read-back does not omit events."

No-response evidence

Still-live evidence (verified 2026-11-14 on current main)

  • pm-stack/decision-events-worker/src/index.ts:189-197 (handleGetEvents): after is read as a bare timestamp and the query is ... WHERE set_id = ? AND ts > ? ORDER BY ts, event_id LIMIT ? — there is no event_id component to the cursor, so a page boundary inside a same-ts group drops the rest of the group.

Acceptance criteria

  • Read-back pagination uses a composite (ts, event_id) cursor (exposed and applied), so paging through a set returns every event exactly once, including groups sharing a timestamp.
  • A regression test pages through at least three events with identical ts at a small limit and receives all of them.
  • Or: a documented decision on this issue that this omission is accepted, with the reasoning recorded.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 14, 2026
  2. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  3. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Picked up by repo-worker-any-a — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while repo-worker-any-a posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  4. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 14, 2026
  5. 88 remaining items

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 14, 2026
  7. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Agent note — picked up (lane code-d, task 16159)

  8. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Agent note — done (lane code-d, task 16159)

    • State: done — outcome fixed_merged. The triage finding was re-verified live on main and the fix was implemented in this same claim (laptop route restored, so no follow-on split).
    • Fix: PR fix(pm-stack): composite (ts, event_id) cursor for decision-events read-back (#9614) #9645 — the read-back endpoint now uses a composite (ts, event_id) cursor: the response carries nextAfter (<ts>|<eventId> of the page's last event) and after in that form resumes with (ts > ? OR (ts = ? AND event_id > ?)). Bare-ts after keeps its legacy meaning; a malformed cursor is a 400. Cursor helpers live in src/events.ts (encodeEventsCursor / parseEventsCursor); README documents the contract.
    • Tests: new test/pagination.test.ts runs the real handler + real SQL against in-memory SQLite (D1 stand-in) — paging a same-timestamp group at limit=2 returns every event exactly once in (ts, event_id) order; verified failing on the original code (2 of 3 fail, legacy test passes). bun test: 14 pass / 0 fail. bunx tsc --noEmit: pass.
    • Review: Codex review failed to run (usage limits reached, no findings produced, no inline comments); CodeRabbit likewise rate-limited with no findings. No undispositioned findings exist.
    • PR fix(pm-stack): composite (ts, event_id) cursor for decision-events read-back (#9614) #9645 squash-merged 2026-11-14T03:49:17Z, merge commit 6f08faad14df12c51d30e97f7fde6bf46751dfae; this issue auto-closed by the merge. Claim labels removed at completion.
  9. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Agent note — already done (lane code-d, task 16217)

    • State: done — outcome already_done. Task 16217 is the auto follow-on (small_fix) of triage task 16159 for this issue; the fix was implemented and merged inside the task 16159 claim itself, so no duplicate work was done here.
    • Fresh evidence (2026-11-14T03:51Z): this issue is CLOSED; PR fix(pm-stack): composite (ts, event_id) cursor for decision-events read-back (#9614) #9645 is MERGED (merge commit 6f08faad14df12c51d30e97f7fde6bf46751dfae, 2026-11-14T03:49:17Z); current main carries the composite cursor (pm-stack/decision-events-worker/src/index.ts: (ts > ? OR (ts = ? AND event_id > ?)) plus the nextAfter response field).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/pr-comment-reviewFiled by the pr-comment-review 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