Skip to content

fix: preserve nullable proxy and dead-letter ordering - #183469

Merged
steipete merged 1 commit into
mainfrom
pgprep/pgnullparity2
Oct 25, 2026
Merged

steipete merged 1 commit into
mainfrom
pgprep/pgnullparity2

Conversation

@steipete

@steipete steipete commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

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 2 selects 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=1 takes 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-simplify completed. 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).

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.
@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T09:01:09.923577Z 3b18044 PR opened
ℹ️ 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 25, 2026
@clawsweeper

clawsweeper Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: PostgreSQL returns tie-a and tie-b, while SQLite returns null-a and null-z.
  • After: Both engines return null-a and null-z.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, correct repair with meaningful real-engine owner coverage; validation is reported through harness runs and the required PostgreSQL CI remains unfinished.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored query-only PR is outside the ordinary contributor proof gate; its body reports red/green SQLite/PostgreSQL owner runs, but supplies no shipped-entry-point recording or terminal artifact.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: PostgreSQL changes diagnostic row order and which failures appear in a bounded dead-letter listing compared with SQLite.
Reason: The maintainer-authored direction preserves established SQLite behavior through a narrow query-only repair, with no new configuration, schema, API, or lifecycle owner.

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
Reviewed head: 3b18044dcaf9c640d7f918597f328f41e70eb341

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supplied validation covers real-engine query owners rather than a shipped CLI or Gateway replay; ordinary contributor proof is not required for this maintainer-authored PR.
Agent review details

How this fits together

Proxy 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]
Loading

Technical review

Best 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

  • Proxy preset host ordering keeps the original intent (994ae0c: Centralize typed diagnostic queries while retaining grouping, counts, output order, and native read failure ownership; this is a verified refactor, not proof of the behavior's first introduction.)
  • Failed and claimed ingress listing assembly keeps the original intent (7b461f1: Share repeated durable-delivery control flow without changing delivery ordering; the earlier extracted kernel already had failed_at and event-ID ordering.)
  • Two-engine nullable-ordering conformance suite keeps the original intent (a05a06d: Protect SQLite-compatible NULL placement through real query owners on SQLite and PostgreSQL.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 994ae0c adds src/proxy-capture/store-readonly.ts:69 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 994ae0c76794; files: src/proxy-capture/store-readonly.ts)

PR surface

Source 0, Tests +71. Total +71 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 10 10 0
Tests 1 71 0 +71
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 81 10 +71

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +10/-10; tests +71/-0 Production growth is zero; the added coverage protects two distinct real-engine ordering contracts without new production scaffolding.

Labels

Label changes:

  • add P2: The mismatch affects PostgreSQL diagnostic ordering and bounded dead-letter selection while preserving existing SQLite behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The mismatch affects PostgreSQL diagnostic ordering and bounded dead-letter selection while preserving existing SQLite behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 25, 2026, 5:13 AM ET / 09:13 UTC.

@steipete
steipete merged commit 44347a8 into main Oct 25, 2026
156 checks passed
@steipete
steipete deleted the pgprep/pgnullparity2 branch October 25, 2026 10:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant