fix(bayn): preserve preopen cycles across authority rollover - #14324
Conversation
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1503cee84d
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ba933703e
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d721ac7067
ℹ️ 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".
| AND reconciliation.reconciled_at >= state.updated_at | ||
| AND positions.position_count = 0 | ||
| AND positions.observed_at <= reconciliation.reconciled_at | ||
| AND NOT paper_account_has_unresolved_mutation(cycle.account_id, reconciliation.reconciled_at) |
There was a problem hiding this comment.
Check unresolved mutations through the repair time
When an account has a mutation whose first event occurred after the selected reconciliation—for example, a committed SUBMIT_STARTED followed by a crash before an order row is recorded—passing reconciliation.reconciled_at here causes paper_account_has_unresolved_mutation to ignore that event because it filters on event.occurred_at <= mutation_observed_at. The latest-order check cannot catch an unknown submit with no order row, so this migration can reactivate the cycle despite an unresolved trading outcome; evaluate mutation state through repair_observed_at while the writer fence is held.
AGENTS.md reference: services/bayn/AGENTS.md:L72-L73
Useful? React with 👍 / 👎.
Summary
Related Issues
None
Testing
3fabb3e995: expected no terminal reason before submission open, receivedBLOCKED_AUTHORITY.25dfd4c04f: migration completed while another transaction held the execution writer fence.026e80cb97: runtime settlement reused the timestamp sampled before waiting for the fence.af51736dab: migration revived a cycle after the fence wait crossedsubmission_open_at.bun run --filter @proompteng/bayn test: 926 passed, 40 skipped, 0 failed.bun run --filter @proompteng/bayn test:postgreswith ephemeral local PostgreSQL 17: 25 passed, 0 failed.bun run --filter @proompteng/bayn tscbun run --filter @proompteng/bayn lintbun run --filter @proompteng/bayn lint:oxlintbun run --filter @proompteng/bayn lint:oxlint:typebun run --filter @proompteng/bayn buildnix eval --raw .#packages.x86_64-linux.bayn-image.drvPathnix eval --raw .#packages.aarch64-linux.bayn-image.drvPathd721ac7067.Breaking Changes
None. Migration 0057 is a one-time fail-closed repair, serialized by the execution writer fence, time-checked after lock acquisition, and idempotent.
Checklist