GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(pm-stack): decision-set event pipeline — Turso sync + Cloudflare Worker/D1/DO (#9335) by dezren39 · Pull Request #9341 · developing-today/code Conversation
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 44 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: 81461b36d3
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const changes = r.meta?.changes ?? 0; | ||
| inserted += changes; | ||
| if (changes > 0) insertedEvents.push(events[i] as DecisionSetEvent); | ||
| }); | ||
|
|
||
| const fanout: Record<string, unknown> = {}; | ||
| for (const [setId, setEvents] of groupBySet(insertedEvents)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Preserve pending fan-out across D1 deduplication
If the Durable Object ingest fails after the D1 batch commits, these events can never reach the object on retry: their next inserts report zero changes, so insertedEvents excludes them permanently. A non-OK ingest response is also converted into an HTTP 200 webhook response, causing the sync client to acknowledge the events despite the failed fan-out. Persist pending fan-out separately and retry it, with event-ID deduplication at the Durable Object, so transient failures do not permanently lose subscriber notifications and coordination state.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const out = (await res.json().catch(() => null)) as { inserted?: unknown } | null; | ||
| if (!out || typeof out.inserted !== "number") throw new Error("webhook failed: malformed response"); | ||
| inserted += out.inserted; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Check webhook acceptance before acknowledging the batch
The Worker returns HTTP 200 even when individual events fail validation, but this client checks only inserted and then syncDecisionEvents marks every pending event acknowledged. This occurs with the current implementations: an outbox event with ts: "2026-11-12" passes the aggregator's isIsoDate validation but is rejected by the Worker's timestamp validator, which requires T. The event is consequently never stored in D1 and never retried. Check the response's acceptance count and per-event errors before advancing acknowledgment state, and align the two validators.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const after = url.searchParams.get("after"); | ||
| const query = after | ||
| ? "SELECT event_id, set_id, question_ref, type, payload, ts FROM decision_set_events WHERE set_id = ? AND ts > ? ORDER BY ts, event_id LIMIT ?" | ||
| : "SELECT event_id, set_id, question_ref, type, payload, ts FROM decision_set_events WHERE set_id = ? ORDER BY ts, event_id LIMIT ?"; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Include the event ID in the read-back pagination cursor
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.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (process.env.DECISION_EVENTS_SYNC === "0") { | ||
| console.log("sync-decision-events: disabled by DECISION_EVENTS_SYNC=0"); | ||
| return 0; | ||
| } | ||
| const opts = parseArgs(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Parse arguments before returning for the kill switch
With DECISION_EVENTS_SYNC=0, the script returns success before validating arguments, so an invocation such as --targte webhook silently succeeds instead of reporting a usage error. This violates the operator-script contract in AGENTS.md, which requires every unaccounted-for argument to produce a non-zero usage error. Move parseArgs() ahead of the kill-switch return so disabled invocations still validate their command line.
AGENTS.md reference: AGENTS.md:L47-L50
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const opts = parseArgs(); | ||
| const files = opts.files.length > 0 ? [...opts.files] : [defaultDecisionEventsOutboxFile()]; | ||
| if (opts.outboxDir) { | ||
| const entries = await readdir(opts.outboxDir).catch(() => [] as string[]); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Report failures to read the explicitly requested outbox directory
If the directory supplied through --outbox-dir is unreadable, missing, or actually a regular file, this catch converts the read failure into an empty directory without any diagnostic. The script then continues with the default outbox and can exit successfully with zero pending events while leaving the requested source completely unsynchronized. Propagate directory-read failures or report them and return a non-zero exit status so operators can distinguish a broken source from an empty outbox.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…trackb # Conflicts: # pm-stack/aggregator/src/decision-events.ts
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.