Repository navigation
fix: preserve nullable proxy and dead-letter ordering - #183469
Conversation
Keep missing hosts first among tied proxy preset counts and undated ingress failures first before the listing limit, matching SQLite on PostgreSQL. Use the existing explicit order builder without changing filters, count precedence, event-ID ties, schema, or transaction ownership. Build the claimed timestamp and received-at order in one branch, removing a repeated status condition while preserving the existing claimed ordering. Add two-engine owner regressions for all five affected proxy presets and full/bounded dead-letter listings. Follow up #183114.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR explicitly places missing proxy hosts and undated ingress failures first on PostgreSQL, preserving SQLite ordering. Example: A failed-ingress listing contains null-a and null-z with failed_at=NULL, plus tie-a and tie-b with failed_at=10, and requests LIMIT 2.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a concrete ordering mismatch still present on main, with no actionable patch defects found; the PostgreSQL conformance checks remain pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherProxy diagnostics and ingress queue readers build queries through existing Kysely owners; database results become CLI JSON and decoded dead-letter records. flowchart LR
A[Proxy CLI] --> B[Capture query owner]
C[Ingress queue API] --> D[Ingress query owner]
B --> E[Kysely ordering]
D --> E
E --> F[SQLite or PostgreSQL]
F --> G[Ordered diagnostic and dead-letter results]
Technical reviewBest possible solution: Keep explicit NULL placement in the existing query owners and land after the required PostgreSQL checks pass. Do we have a high-confidence way to reproduce the issue? Current-main query owners leave nullable ascending order implicit, and the supplied baseline results report PostgreSQL failures for both added cases; this read-only review ran no target code. Is this the best way to solve the issue? Explicit NULLS FIRST at the existing owners is the smallest complete repair: it preserves filters, limits, count precedence, claimed-message ordering, and decoding without adding another implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dc2cf77715dc. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests +71. Total +71 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 25, 2026, 5:13 AM ET / 09:13 UTC. |
|
Merged via squash.
|
Keep missing hosts first among tied proxy preset counts and undated ingress failures first before the listing limit, matching SQLite on PostgreSQL. Use the existing explicit order builder without changing filters, count precedence, event-ID ties, schema, or transaction ownership. Build the claimed timestamp and received-at order in one branch, removing a repeated status condition while preserving the existing claimed ordering. Add two-engine owner regressions for all five affected proxy presets and full/bounded dead-letter listings. Follow up openclaw#183114.
Related: #183114
What Problem This Solves
PostgreSQL sorts missing proxy hosts and undated ingress failures after populated values, changing proxy diagnostic JSON order and which dead letters a bounded listing returns compared with SQLite.
User Impact
Postgres-readiness prep with no SQLite runtime behavior change. Both engines preserve SQLite's existing NULL-first order for these listings. No schema, configuration, dependency, transaction, or lock changes.
Why This Change Was Made
Use the existing Kysely
nullsFirst()spelling for five proxy host tie-breakers and the failed-ingress timestamp order. Preserve count precedence, event-ID ties, filters, and limits.The ingress reader now constructs the claimed timestamp/received-at order together and appends the shared event-ID tie-breaker once. This removes a repeated status condition and mutable query updates, preserving claimed ordering and passing the line-cap ratchet. Production line count is unchanged; the existing conformance suite gains 71 lines. No new helper or compiler rule.
Evidence
Observable: proxy presets reach CLI JSON directly. Homebrew PostgreSQL 17.11 and SQLite 3.54.1 probes show tied hosts as NULL/a/b on SQLite versus a/b/NULL on PG. Dead-letter
LIMIT 2selects two undated failures on SQLite versus two dated failures on PG.RED/GREEN: both new real-owner PG cases fail at base, covering all five proxy presets and full/limited ingress listings; all five SQLite cases and the three existing PG cases pass. The fix passes all 10 cases on both engines. The final simplified query also passes all 10 on Homebrew PG17 plus SQLite, and all 29 ingress tests.
Plans: canonical table/index fixtures with 100,000 rows per owner retain identical before/after PG plan shapes for all five presets and full/limited ingress reads. No ordered or index-only scan acquires a Sort; no index change is needed. No latency or throughput claim.
Consumers and cost: 75 tests across five consumer files pass.
pnpm test src/infra/database-engine/nullable-ordering.conformance.test.ts --maxWorkers=1takes 24.23s wall on Testbox (2.32s Vitest). Final two-engine Mac replay takes 350.62s including worker preparation/cleanup (58.77s Vitest).Checks: core and infra-test type checks, scoped lint, formatter parity, and diff checks passed before the equivalent query-assembly simplification. Fresh formatting, line-cap ratchet, two-engine/ingress replay, and independent P0–P3 Codex review pass after it.
pr-simplifycompleted. No hook or baseline exceptions.Local broad-proof limitation: Darwin shard 1 recorded 60 passes and eight failures before stopping (933.83s). The Doctor installed-driver rollback case hit its 120s timeout, followed by lock and missing-fixture-table errors; shards 2 and 3 were not started. This PR leaves those owners unchanged. Linux pull-request CI is the required final-head broad proof; all three PG shards must pass before coordinator review. No timeout changes or retries were used to mask the local result.
Final-head CI: pull-request run 40178800289 passed on
3b18044dcaf9c640d7f918597f328f41e70eb341: 46 successful jobs, 28 skipped, no failures. All three PG shards passed: shard 1, 490 tests (21m06s); shard 2, 246 tests (29m42s); shard 3, 497 tests (17m14s). Total: 1,233 passing tests. Both installed-driver Doctor rollback cases passed in Linux (35.039s / 33.585s).