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 — feat(pm-stack): decision-set event pipeline — Turso sync + Cloudflare Worker/D1/DO (#9335) by dezren39 · Pull Request #9341 · developing-today/code

Conversation

@dezren39

@dezren39 dezren39 commented Nov 13, 2026 •
edited by blacksmith-sh Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

What

Track B of Decision Sets v2 (#9335): the external event pipeline for decision-set activity events {eventId, setId, questionRef, type, payload, ts}.

Aggregator side (pm-stack/aggregator)

  • src/decision-events.ts — the wire contract + outbox reader (JSONL, default ~/.local/state/pm-aggregator/decision-events-outbox.jsonl), a libSQL HTTP pipeline client (typed args, malformed-envelope-safe, per the design: move agent append streams (agent.events, agent.quota_records) from Supabase to Turso staging #5690/github-ci(turso client): a wrong-shape 200 response is read as success or escapes as a raw TypeError — batch() never validates the pipeline envelope #6949 pattern), and per-leg sync state (acked eventIds per sink; corrupt state re-syncs, sinks dedupe).
  • scripts/sync-decision-events.ts — operator sync script (strict Design: unknown means stop — one strict argument contract for the repo's operator scripts #3352 argument contract). Two independent legs, both INSERT OR IGNORE on eventId:
    • Turso: fleet-platform DB, table decision_set_events, token by BWS name turso.fleet-platform-rw-token (the gather-quota.ts precedent from design: move agent append streams (agent.events, agent.quota_records) from Supabase to Turso staging #5690).
    • Worker webhook: shared secret by BWS name cloudflare.decision-events.webhook-secret.
  • test/decision-events.test.ts — 11 tests (validation, outbox parsing/dedupe, fake-libSQL oracle proving insert-once idempotence, leg independence, state round-trip).

Worker (pm-stack/decision-events-worker)

  • POST /events (alias /webhook): constant-time shared-secret auth, batch validation (one bad event never poisons a batch), D1 store, then per-set Durable Object fan-out of only the newly inserted events.
  • DecisionSetEvents Durable Object, keyed by idFromName(setId): per-set fan-out state (count, last event) + hibernatable WebSocket subscribers (GET /sets/<id>/stream).
  • GET /sets/<id>/events, GET /sets/<id>/state read-backs (authenticated); GET /health public; fails closed (503) with no secret configured.
  • test/events.test.ts — 7 contract tests; tsc --noEmit clean.

Live state (already deployed — this PR is the source of record)

  • Turso: decision_set_events + indexes created in fleet-platform; verified by independent pipeline read-back.
  • D1: database decision-events (68ade85e-6835-46a8-af6a-a9f2f2d966ae) created, schema.sql applied remotely.
  • Worker: deployed — https://decision-events.developing-today.workers.dev (version 9e5607c8-b26d-47d3-b671-d1465e114253), WEBHOOK_SECRET set from the BWS-vaulted value by name.
  • Secret: newly minted, vaulted in Bitwarden as cloudflare.decision-events.webhook-secret; value never in repo/logs.
  • Smoke (end-to-end, real sync script on the laptop): 3 events for set smoke-9335 → Turso inserted=1×3, Worker inserted=1×3; re-run with fresh state → attempted=3, inserted=0 on both legs (sink-level idempotence); Worker /state shows the DO at fannedOut=3, D1=3; unauthenticated GET/POST → 401.

Verification

  • Aggregator: bun test test/decision-events.test.ts 11/11; neighboring decisions + events suites still green (79/79 across the three files). Typecheck: 20 errors = exact origin/main baseline, 0 in new files.
  • Worker: bun test 7/7, tsc --noEmit clean.
  • A live-response quirk found during the smoke is fixed in this PR: libSQL counts inserts under affected_row_count (not rows_affected) — the counter and the test fake now match the real envelope.

Not in this PR

Track A's local event-log producer (the aggregator-side appends to the outbox) is the parallel leg; this sync consumes whatever JSONL outbox carries the wire shape (--file/--outbox-dir overridable). No timer/cron wiring yet — the sync is safe to run on any cadence once Track A's outbox path is final.

Refs #9335


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
repo-worker-tmp-code-b
feat(pm-stack): decision-set event pipeline — Turso sync + Cloudflare…
81461b3
… Worker/D1/DO (#9335)

Track B of Decision Sets v2. Aggregator: src/decision-events.ts (wire shape {eventId,setId,questionRef,type,payload,ts}, JSONL outbox reader, libSQL pipeline client, per-leg sync state) + scripts/sync-decision-events.ts (strict #3352 arg contract; tokens by BWS name turso.fleet-platform-rw-token / cloudflare.decision-events.webhook-secret; INSERT OR IGNORE idempotent on eventId; legs fail independently). Worker: pm-stack/decision-events-worker — POST /events authenticated webhook -> D1 (decision-events DB) + Durable Object per setId (fan-out state + WebSocket stream), GET read-backs, fail-closed auth. Deployed and smoke-verified live; see issue #9335 outcome comment.
@dezren39
dezren39 requested a review from a team as a code owner November 13, 2026 05:30
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5c44eefb-7eb2-491b-bfe0-5218e2973365
Commits

Reviewing files that changed from the base of the PR and between c19737b and 66940fb.

Files ignored due to path filters: 1

  • pm-stack/decision-events-worker/bun.lock is excluded by !**/*.lock
Files selected for processing: 11

  • pm-stack/aggregator/scripts/sync-decision-events.ts
  • pm-stack/aggregator/src/decision-events-sync.ts
  • pm-stack/aggregator/test/decision-events.test.ts
  • pm-stack/decision-events-worker/README.md
  • pm-stack/decision-events-worker/package.json
  • pm-stack/decision-events-worker/schema.sql
  • pm-stack/decision-events-worker/src/events.ts
  • pm-stack/decision-events-worker/src/index.ts
  • pm-stack/decision-events-worker/test/events.test.ts
  • pm-stack/decision-events-worker/tsconfig.json
  • pm-stack/decision-events-worker/wrangler.toml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

  • X
  • Mastodon
  • Reddit
  • LinkedIn
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T05:43:47.002015Z 66940fb New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dezren39 dezren39 mentioned this pull request Nov 13, 2026
pm-stack decision sets v2: rich questions, event log, submit API + activity webhook/hook #9335
Closed
18 tasks
chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Nov 13, 2026
View reviewed changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81461b36d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pm-stack/decision-events-worker/src/index.ts
Comment on lines +164 to +170
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)) {

@chatgpt-codex-connector chatgpt-codex-connector Bot Nov 13, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pm-stack/aggregator/src/decision-events.ts Outdated
Comment on lines +308 to +310
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;

@chatgpt-codex-connector chatgpt-codex-connector Bot Nov 13, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pm-stack/decision-events-worker/src/index.ts
Comment on lines +192 to +195
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 ?";

@chatgpt-codex-connector chatgpt-codex-connector Bot Nov 13, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pm-stack/aggregator/scripts/sync-decision-events.ts
Comment on lines +100 to +104
if (process.env.DECISION_EVENTS_SYNC === "0") {
console.log("sync-decision-events: disabled by DECISION_EVENTS_SYNC=0");
return 0;
}
const opts = parseArgs();

@chatgpt-codex-connector chatgpt-codex-connector Bot Nov 13, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pm-stack/aggregator/scripts/sync-decision-events.ts
const opts = parseArgs();
const files = opts.files.length > 0 ? [...opts.files] : [defaultDecisionEventsOutboxFile()];
if (opts.outboxDir) {
const entries = await readdir(opts.outboxDir).catch(() => [] as string[]);

@chatgpt-codex-connector chatgpt-codex-connector Bot Nov 13, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
repo-worker-tmp-code-b
Merge remote-tracking branch 'origin/main' into decision-events/9335-…
66940fb
…trackb

# Conflicts:
#	pm-stack/aggregator/src/decision-events.ts
@dezren39
dezren39 merged commit aad1d36 into main Nov 13, 2026
7 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@dezren39
dezren39 deleted the decision-events/9335-trackb branch November 13, 2026 05:45
@blacksmith-sh blacksmith-sh Bot mentioned this pull request Nov 13, 2026
feat(id): add native shell session state #7197
Merged
This was referenced Nov 14, 2026
pm-stack: decision-events Worker loses Durable Object fan-out when ingest fails after the D1 commit (PR #9341 Codex P1) #9612
Closed
pm-stack: decision-event sync acks events the Worker rejected — validator mismatch silently drops events (PR #9341 Codex P2) #9613
Closed
pm-stack: decision-events Worker read-back pagination skips events sharing a timestamp (PR #9341 Codex P2) #9614
Closed
pm-stack: sync-decision-events silently ignores an unreadable --outbox-dir (PR #9341 Codex P2) #9615
Closed
fix(pm-stack): preserve DO fan-out on ingest failure and deduplicate by eventId (#9612) #9624
Merged
fix(pm-stack): fail non-zero when --outbox-dir cannot be read (#9615) #9636
Merged
fix(pm-stack): composite (ts, event_id) cursor for decision-events read-back (#9614) #9645
Merged
pm-stack: sync-decision-events kill switch returns 0 before parseArgs, so invalid args silently succeed (from PR #9341) #9794
Closed
fix(pm-stack): validate args before the sync-decision-events kill switch #10113
Merged
watchdog: reopen issues the bot wrongly closes on merges #10105
Closed
@dezren39 dezren39 mentioned this pull request Nov 21, 2026
Closure audit: every closed issue/PR verified; unmerged branches + unpushed worktrees inventoried #7079
Open
@dezren39 dezren39 added the audit:partial PR partially implemented; gap filed label Nov 24, 2026
@dezren39 dezren39 mentioned this pull request Nov 24, 2026
Schedule registry: register the #9335 decision-events sync timer (+ verify activity-processor cron row) #14517
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

audit:partial PR partially implemented; gap filed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@dezren39
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.