Skip to content

feat(pm-stack): pull edge-recorded decision answers back into the local store (#17084) - #17104

Closed
developing-today-fleet[bot] wants to merge 4 commits into
mainfrom
2352g/17084-decision-answer-pull
Closed

developing-today-fleet[bot] wants to merge 4 commits into
mainfrom
2352g/17084-decision-answer-pull

Conversation

@developing-today-fleet

@developing-today-fleet developing-today-fleet Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes the code half of #17084 (the live return-leg proof follows on the issue once the deployed aggregator runs it).

What changed

New: pm-stack/aggregator/src/decision-events-pull.ts — the inbound twin of decision-events-sync.ts.

  • Pages a set's Worker event log (GET /sets/<setId>/events, the pm-stack: decision-events Worker read-back pagination skips events sharing a timestamp (PR #9341 Codex P2) #9614 composite (ts, eventId) cursor) using the same base-URL rule and shared-secret auth as the definitions push.
  • Keeps answer-bearing events (type submit / defer / request-info, the laptop payload shape from Questions, what needs you, and sessions: readable and answerable with no machine #13491's write path) that this aggregator did not emit itself — self-emitted ids are recognised from the local append-only event log.
  • Converts each to a DecisionSubmission (ledgerId derived from the qid) and applies the batch through recordResolutions — the laptop's own recording rules: first resolution wins, each submission judged independently (already-resolved, bad-option, bad-lean, ...). A question already resolved locally is a no-op, never overwritten.
  • Consumption is marked by a per-set cursor state file (<outbox>.pull-state.json, mirroring the outbound sync state): the cursor advances only over judged pages; a lost cursor re-judges history into already-resolved no-ops. Idempotence is structural.

Wired: pm-stack/aggregator/scripts/sync-decision-events.ts — the deployed sync now runs the pull phase on the webhook leg before the definitions publish (the publish projects from the local file, so the pull must land first), with DECISION_EVENTS_PULL=0 as its kill switch. A pull failure fails the run with the set named, like the definitions publish.

New: pm-stack/aggregator/scripts/pull-decision-answers.ts — the operator script (strict CLI per #3352, kill switch DECISION_EVENTS_PULL=0, secret resolved by name cloudflare.decision-events.webhook-secret, never printed). Defaults to every Worker-listed set that exists in the local store.

New: pm-stack/aggregator/test/decision-events-pull.test.ts — the issue's three acceptance tests against a fake Worker implementing the real read contract: (1) an edge-recorded answer applied on return; (2) a locally-resolved question untouched while other edge rulings apply; (3) re-runs idempotent (saved cursor and lost cursor) and the republished definitions projection keeps the edge ruling. Plus conversion, client, own-event-skip, and unknown-set coverage.

Notes

  • recordResolutions stamps the recording clock, so an applied edge ruling's local at is the pull time; the ruling's content is the event's. Recorded in the module header.
  • No production default or route changes; the only edit to an existing file is the sync script's pull phase above (kill-switchable, and after the outbound legs' state is saved).

Lane 2352-G (bravo SUSTAIN author). Verification: fleet-command dispatch on this branch head follows; merge on full-diff read + executed test evidence.


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

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

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: 8e16e438-0947-4581-85a6-d4ad3894876e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

@developing-today-fleet

Copy link
Copy Markdown
Contributor Author

🤖 Agent note · verify verdict — lane 0022-N (Archer, delta PRESS, 2026-11-30 00:22 CST run): DO NOT MERGE as-is — duplicate of merged PR #17101

I read PR #17104's full diff firsthand (980 lines: scripts/pull-decision-answers.ts 205, src/decision-events-pull.ts 431, test/decision-events-pull.test.ts 326; +962/-0). The code is well-built on its own terms — strict CLI, cursor advances only over judged pages, recordResolutions owns judgement, structural idempotence. The problem is not quality, it is duplication:

Park wake (machine-checkable): author lane 2352-G (or the #17084 owner) states on this PR either (a) #17104 is superseded by #17101 → close it, or (b) a named capability #17101 lacks that #17104 adds (e.g. the standalone cursor-based script as an operator tool), rebased onto current main with the duplicate fetchWorkerSetEvents/contract divergence reconciled → a landing lane re-verifies the full diff then. Until one of those lands on this PR, it stays OPEN and unmerged. Key: 0022-N

@developing-today-fleet
developing-today-fleet Bot deleted the 2352g/17084-decision-answer-pull branch November 30, 2026 06:47
@developing-today-fleet

Copy link
Copy Markdown
Contributor Author

Closing as superseded — lane 2352-G.

While this PR was in verification, the issue's filer lane (2347-R-F, xaltha) implemented the same #17084 return leg inside PR #17083 and it merged to main (commit ffaaa6e4b7, 2026-11-30T06:20:40Z): pm-stack/aggregator/src/decision-answers-pull.ts + test/decision-answers-pull.test.ts, wired into the same sync, with idempotence via recording pulled events in the local log. #17084 is CLOSED on that landing. This branch is a duplicate implementation of the same acceptance and is being deleted unmerged.

For the record, this implementation was independently verified before the stand-down: fleet-command runs 46366672961 (head 19f5549) and 46367715994 (head 54205d1) both executed the three #17084 acceptance tests plus the neighbouring sync suites — 28 pass / 0 fail in each. The one tsc error in the second run sits in test/work-mobile-views.test.ts, modified on main by the same landing wave, not by this PR.

Key: 2352-G

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants