Skip to content

fix: SQLite and PostgreSQL return NULL sort keys in the same position - #183114

Merged
steipete merged 3 commits into
mainfrom
pgprep/pgnullparity
Oct 25, 2026
Merged

steipete merged 3 commits into
mainfrom
pgprep/pgnullparity

Conversation

@steipete

@steipete steipete commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

PostgreSQL's default NULL placement changes participant order, filtered sandbox inventory, and all-window transcript history compared with SQLite. This change makes SQLite placement explicit at each query owner and keeps the NOT NULL membership index-order optimization under the documented not-null spelling. No SQLite behavior, schema, generator, dependency, transaction, or lock changes.

Current approved head: c5cdb1b95d31b191d2f2b88d538003c63622f3ad. The conflict-free rebase onto e8b251188f50 preserves identical stable patch IDs for all seven production files. Upstream #183156/#183203/#183130 changes remain intact. Coordinator REVIEW-OK carries to this exact head.

Final-head proof

PR CI40166602098 tested merge 768a2c13a5a7f606b329d945c472930721608df4, with ordered parents e8b251188f502b088dd037936062a1711ea302e1 and the exact candidate. All three PostgreSQL shards passed: 1,224 passes /39 skips, including all six two-engine nullable-order cases and ten entry-write cases. Shard totals:330/364/530 passes. Security-fast passed. The complete run is77success/3failure/26skipped; CI is not aggregate green.

The final run has exactly two root failures, both inherited:

  • Lint121089383821: unchanged test/helpers/claude-managed-settings.ts:21 triggers openclaw-boundaries/no-recursive-readdir. Three alternating runs per exact e8 base and c5 candidate all reproduce the identical CI diagnostic. Same Node24.22.1, CI=1, pinned oxlint1.88.0 executable and arguments --config config/oxlint/resource-safety.json test/helpers/claude-managed-settings.ts. Base0.605/0.327/0.275s; candidate0.301/0.266/0.260s. The helper/config/plugin/rule hashes match. This is a deterministic inherited lint defect and remains unfixed.
  • Terminal delivery121089133849: the exact strict-NO_REPLY case expects No answer was returned. Ask again if you still need one. and receives the output-token-limit notice. This exactly matches the previously accepted three-base/three-candidate reproduction below. The PR does not change this test or its copy owners; no new replay is claimed.

The aggregate gate121093982032 failed because of those roots. The exact head has one Actions CI gate, suite108867594564; no manual workflow was dispatched after the rebase. The native inherited-failure admin route is authorized for these fully attributed failures. Landing outcome will be verified independently.

Prior focused-owner proof remains applicable to the unchanged patch:90tests/sevenfiles passed64.10s;31-pair PostgreSQL membership plans retain the index-only/no-Sort identity aggregate (median0.105→0.101ms), equal1,000-member tuples, and no median regression over20%. pr-simplify and isolated source review are clean. Earlier red-on-base parity proof, exact commands, test cost, and full hooks/large42/large40/transport/recovery/terminal causality follow below. Nullable proxy-host and ingress-failure ordering remain separate follow-ups.

Earlier proof and CI causality evidence

Related: #183015

What Problem This Solves

PostgreSQL's default NULL placement changes participant order, filtered sandbox inventory, and history that includes empty transcript windows compared with SQLite.

User Impact

These readers return unprompted participants first, and unused sandbox runtimes and empty transcript windows last, on both engines. Existing filters and tie breakers are preserved. This is PostgreSQL-readiness work with no SQLite behavior change, schema migration, dependency, or transaction change.

Why This Change Was Made

The query owners explicitly request ASC NULLS FIRST or DESC NULLS LAST. Nullable participant aggregates use the default SQLite placement. The old native selector is replaced by not-null, documented for keys that are all NOT NULL in the canonical schema; only the two membership aggregates use it. Plain ASC preserves their PostgreSQL index ordering because NULL placement is irrelevant for identity_id.

This reconciles merged #183015 without accepting the measured extra sort from forcing NULLS FIRST onto a NOT NULL membership key. The prior forced-placement experiment increased the identity aggregate median by 66.7%; the final spelling restores its index-only plan. No generator or schema was changed.

Evidence

  • The final ready-event CI run 40162861131 passed all three PostgreSQL conformance shards. Its only root failures are attributed by the recovery/terminal comparison below.
  • Baseline ad2172d77e26: three SQLite cases passed and three PostgreSQL cases failed across standalone/fused participants, filtered sandboxes, and all-window history. Fixtures include NULL/non-NULL keys and ties.
  • Approved c82 production-head proof before this test-only repair: all six parity cases and ten entry-write cases passed; 9.47 s Vitest / 33.05 s command wall. Selected owner suites passed 90 tests in seven files / 64.10 s wall, including the membership read worker.
  • Targeted infra/session types, production/test lint, and formatter parity passed. pr-simplify completed; isolated review is clean through P2.
  • All three actual PostgreSQL conformance steps passed on approved production head c82c9413df61 in CI 40154859348: shard 1, 306 tests / 1,484.22 s runner time; shard 2, 332 tests / 1,215.71 s; shard 3, 547 tests / 38 skips / 721.30 s. Total: 1,185 passes / 38 skips, including all six parity cases and ten entry-write cases.

Membership EXPLAIN on PostgreSQL 17.11 used canonical DDL, 100,000 rows, 1,000 selected members, and 31 alternating pairs per shape. The candidate SQL is compiled through the production helper. Identity-only aggregation retains Aggregate → Index Only Scan, with no Sort: median 0.105 → 0.101 ms, p95 0.116 → 0.142 ms. Tuple aggregation keeps the same bitmap-scan/sort plan: median 0.709 → 0.698 ms, p95 0.820 → 0.782 ms. Results are identical. The median regression gate passes; these are query-plan diagnostics, not a throughput claim.

The earlier sandbox check also passed: 31 pairs, median 0.305 → 0.262 ms, p95 0.393 → 0.276 ms, using idx_sandbox_registry_session. Participant/window indexes do not cover their nullable sort keys.

Earlier standalone test cost before the public-reader migration: pnpm test src/infra/database-engine/nullable-ordering.conformance.test.ts --maxWorkers=1 — 24.41 s wall, including 20.03 s cold worker preparation; 2.32 s Vitest / 107 ms test bodies. This cost measurement is retained from the unchanged test's initial proof run.

Review delta and remaining scope

Compared with reviewed head 9707480263f4, the production revision rebases onto 882dffc79db3, restores the ordered-JSON option as first | not-null, documents its schema constraint, and migrates the two membership callers to not-null. Nullable participant defaults and the three original ordering fixes remain. The seven production files total +13/-8 lines against the rebased main; no new helper, cache, state, or compatibility alias.

Two observable nullable-order families remain outside the explicit allocation: proxy capture presets sorting nullable capture_events.host, and ingress dead-letter listing sorting nullable failed_at. Other inspected candidates exclude NULLs or already specify placement: worker completion cutoffs, shutdown, archived-session retention, cold-storage/cost-report windows, cron terminal completion constraints, approval history, message-position predicates, recently stopped transcripts, and meeting chronology. Invalid NULL ingress claims fail decoding.

Earlier non-PG CI attribution

Nine old-head failures have matching tests/error signatures in main run 40149301577 (f0dcb354e45b):

Failure Matching main job
Windows workspace-quiescence ENAMETOOLONG 121037449160
Windows MXC missing process-runtime mock export 121037449179
Windows trusted-harness packaging module missing 121037449161
Dependency diagnostics (1,346 normalized lines identical) 121037449674
Production types, session-catalog TS2739 121037449659
Core-2 test types, same TS2739 121037449682
tsdown memory fixtures missing fs-safe 121037450396
Four standalone-metadata fixture failures 121037450352
Lifecycle retention assertion 121037450315

The coordinator authorized one failed-job rerun of 40151854642 on old head 9707480263f4. Its isolated-completion case failed again in job 121052941775: timeout after 1,109 ms, code runtime-unavailable. This is an unresolved real failure with no same-test main match, not a passing rerun or an inherited-failure claim. Source inspection shows the fixture substitutes prepared-runtime acquisition and inference and does not call the seven changed query/helper owners, so the coordinator’s changed-owner STOP condition is not met. The previously canceled large-39 job had no verified terminal outcome when monitoring stopped; its last cached observation was in progress. No passing verdict is claimed for it. No second rerun or aggregate-green claim is made.

Final recovery and terminal-delivery causality

On final head f8c2108cd1a9a01dfe93293c698cfaa6c7238ae4 and exact PR merge base 882dffc79db3883bd3d6e004cfdeb0c94022b7d8, each case ran three times per revision with the same command and environment. All twelve processes reached exactly one selected test. The test/config files and lockfile were byte-identical; each revision used its own frozen install and runtime build. One Linux Testbox supplied Node 24.22.1, pinned OpenClaw Bun 1.4.4, pnpm 12.15.0, CI=1, one worker, 4 CPUs, and 15 GiB RAM.

Exact case Base rounds 1 / 2 / 3 Candidate rounds 1 / 2 / 3
Recovery: preserves result loss after committed owner retirement PASS 34 / 29 / 29 s PASS 34 / 30 / 30 s
Terminal delivery: strict NO_REPLY prefix and shared prepared final FAIL 241 / 48 / 48 s FAIL 245 / 49 / 48 s

Recovery-retirement passed the assertion of zero database-execution captures after the committed owner was retired in every run. Its parallel-CI failure observed three captures. This is inherited/flaky under the coordinator's explicit same-result rule; the underlying CI scheduling cause is not claimed fixed.

Terminal delivery was the sole additional failure discovered after the retirement case. All six runs reproduced the same real assertion as CI: the fixture expected No answer was returned. Ask again if you still need one. and received ⚠️ The model reached its output token limit before generating an answer. Please try again. Both revisions behave identically, so this is an inherited expectation/behavior mismatch. No fixture, expectation, or production code was changed. The first terminal run in each checkout includes a cold Gateway runtime build; the comparison's total command wall time was 944.334 seconds. These are diagnostic timings, not performance claims.

Exact commands on each revision, with OPENCLAW_VITEST_RUNTIME=bun and OPENCLAW_VITEST_MAX_WORKERS=1:

node scripts/run-vitest.mjs run --config test/vitest/vitest.runtime-config.config.ts src/config/sessions/session-accessor.recovery.test.ts --testNamePattern 'preserves result loss after committed owner retirement' --maxWorkers=1 --reporter=verbose
node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/e2e/qa-lab/runtime/agent-terminal-delivery.e2e.test.ts --testNamePattern 'holds every strict NO_REPLY prefix and shares the prepared final with channel and SQLite history' --maxWorkers=1 --reporter=verbose

The final ready-event CI run 40162861131 completed with all three PostgreSQL conformance shards passing: shard 1, shard 2, and shard 3. It tested merge e240079de99670c2b1ebac8a348a85fa1f7caede of baseline 745d2e768dff39cceab66eec9cd49870b96356c3 and final candidate f8c2108cd1a9a01dfe93293c698cfaa6c7238ae4. Its only two root failures were recovery-retirement and terminal delivery; the aggregate CI gate consequently failed. There is no aggregate-green claim. No second additional failure surfaced, and no new CI rerun was used.

The existing exact-head native review and GitHub-gated preparation remain on f8c2108cd1a9; preparation skipped pushing because the remote already matched. The coordinator carried REVIEW-OK to this head and authorized landing after the above attribution. The earlier hooks, private-child recovery, child coordination, transport, and nine main-matched failure records are retained in this description.

Decision 7: remaining CI causality

The coordinator carried REVIEW-OK to f8c2108cd1a9a01dfe93293c698cfaa6c7238ae4 and authorized landing after these comparisons. No production or test source changed during this investigation.

The remaining three cases ran three times on the exact PR merge base 882dffc79db3883bd3d6e004cfdeb0c94022b7d8 and on final candidate f8c2108cd1a9a01dfe93293c698cfaa6c7238ae4. Twelve processes executed exactly 18 selected cases; there were no setup-only or no-test verdicts. Each pair used the same command, Node 24.22.1, pinned OpenClaw Bun 1.4.4, pnpm 12.15.0, CI=1, one worker, separate frozen installs, and identical test/config/lockfile inputs. One Linux Testbox supplied 4 CPUs and 15 GiB RAM. Command wall time including both installs was 502.97 seconds.

Exact case Base rounds 1 / 2 / 3 Final candidate rounds 1 / 2 / 3
Hooks: enforces hooks.allowedAgentIds for effective agent routing FAIL 46 s / PASS 34 s / PASS 33 s FAIL 45 s / PASS 34 s / PASS 33 s
Transport: does not throw while recording non-JSON transport rejections PASS / PASS / PASS PASS / PASS / PASS
Transport: extracts Undici codes through the OpenAI SDK error wrapper PASS / PASS / PASS PASS / PASS / PASS

The two transport cases shared a process per round: base 32 / 28 / 29 s, candidate 33 / 29 / 28 s. Exact commands on each revision, with OPENCLAW_VITEST_RUNTIME=bun and OPENCLAW_VITEST_MAX_WORKERS=1:

node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-server.config.ts src/gateway/server.hooks.test.ts --testNamePattern 'enforces hooks.allowedAgentIds for effective agent routing' --maxWorkers=1 --reporter=verbose
node scripts/run-vitest.mjs run --config test/vitest/vitest.unit-fast.config.ts src/agents/transport-stream-shared.test.ts --testNamePattern 'does not throw while recording non-JSON transport rejections|extracts Undici codes through the OpenAI SDK error wrapper' --maxWorkers=1 --reporter=verbose

Both first hooks runs fail the same waitForSystemEventTexts assertion, expected [] to not have a length of +0, matching the final-head CI job. The test retains real target capture: server/hooks.ts calls captureSessionEventTargetForHost, which reads the persisted entry and can reach the changed participant/JSON readers. Therefore the evidence is equal base/candidate behavior; this is not a claim that hooks bypasses the changed owners. No NULL-order dependency or candidate-only failure was found.

The two transport CI failures stop at assignTransportErrorDetails assigning output.usage.usageReport in packages/ai/src/transports/transport-stream-shared.ts:566. Their fixtures reuse ZERO_USAGE_FIXTURE; their synchronous error-projection path has no call to participant projection/hydration/entry-select, sandbox registry, history read, or jsonOrderedArray. Those owners cannot cause these assertions. The multi-file CI process made the usage object non-extensible; its underlying contamination source is not established or fixed here. Both cases pass every isolated base and candidate run.

Under the coordinator's explicit decision rule, these are inherited/flaky failures. The earlier four hooks cases, large42 recovery, and large40 coordination results remain below. In particular, the CI-only recovery cancellation repeats independently of this change and passes all isolated base/candidate runs; it is not claimed repaired. The nine exact main-run matches are retained in the attribution table. No extra CI reruns were used for decision 7, and no aggregate-green result is claimed.

Test-only main integration repair

Current head: f8c2108cd1a9a01dfe93293c698cfaa6c7238ae4. Relative to approved c82c9413df61, only nullable-ordering.conformance.test.ts changes (+5/-6); production code is identical. The coordinator has carried REVIEW-OK to this test-only head; production remains byte-identical to the previously approved head.

Merged #183130 (696f70f3175b) made the database-local history helper private and migrated its sibling test to the maintained reader. The subsequent ready-event CI run 40157542675 exposed our stale import: PostgreSQL shard 3 and the SQLite changed-test job reported listTranscriptInstancesFromDatabase is not a function; test types reported TS2459 and the resulting TS7006. This is a real test integration defect. The repair calls listSessionTranscriptInstances with the fixture's agent ID and store path. NULL/tie fixtures and both history expectations remain identical, and no production export is restored.

Focused SQLite proof passed all three cases. Exact cost command: pnpm test src/infra/database-engine/nullable-ordering.conformance.test.ts --maxWorkers=1, using the pinned OpenClaw Bun fork: 165.17 s wall including 97.23 s worker preparation; Vitest 47.32 s, case bodies 509 ms. The initial command stopped before cases because the installed Bun build was not pinned; official staging resolved that environment mismatch. Formatting passed; pr-simplify and isolated Codex review through P2 are clean. Local lint stopped before analysis because the existing external pnpm declaration store violates the current containment guard; no guard bypass or passing-lint claim. Final-head CI 40160199976 is pinned to this head: core-2 test types and lint passed, and all three actual PostgreSQL conformance steps passed: 1,185 passes / 38 skips, including all six parity cases and ten entry-write cases. Checkout SHA was verified in every PG log. Shard 1: 306 passes / 1,425.72 s runner time; shard 2: 332 / 951.27 s; shard 3: 547 / 38 skips / 915.67 s. An initial dispatch from main failed before tests because main-tier validation requires identical workflow/source revisions; the corrected dispatch uses the published candidate branch and passed preflight.

Decision 6: direct causality results

Both new CI failures pass on the exact PR merge base 882dffc79db3883bd3d6e004cfdeb0c94022b7d8 and approved candidate c82c9413df6177cae1e4d2ed10f853ded83730f1, three runs per case per revision. Every process executed exactly one selected case. Under the coordinator's explicit decision rule, both are CI flakes; this is not a claimed fix of their underlying timing causes. The comparison required no source changes; the subsequent test-only main integration repair is documented above.

Exact case Base rounds 1 / 2 / 3 Candidate rounds 1 / 2 / 3
Recovery: private child final PASS 47 / 36 / 35 s PASS 48 / 36 / 36 s
Child coordination: inline result (timeout) PASS 37 / 31 / 31 s PASS 38 / 31 / 32 s

The comparison used one isolated Linux Testbox, Node 24.22.1, pinned OpenClaw Bun 1.4.4, pnpm 12.15.0, CI=1, one Vitest worker, and separate frozen installs. The selected test files, recovery support, configs, and lockfile are byte-identical. The 12 processes ran serially, alternating base and candidate. Observed resources: 4 CPUs, 15 GiB RAM. Remote command time including checkout/install/setup: 515.57 s.

Exact commands on each revision:

node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-server.config.ts src/gateway/server.subagent-settle-replay.harness.test.ts --testNamePattern 'recovers public work once through a sibling and reconciles its private child final' --maxWorkers=1 --reporter=verbose
node scripts/run-vitest.mjs run --config test/vitest/vitest.infra.config.ts src/agents/openclaw-tools.sessions-send-child-coordination.test.ts --testNamePattern 'consumes an inline child follow-up result without a second requester delivery \(timeout\)' --maxWorkers=1 --reporter=verbose

Original CI evidence: large42/job 121054162637 expected recovery ok/completed, received error/cancelled; large40/job 121054162607 threw Subagent terminal execution changed. Both reach real persisted-session code, but neither produced a candidate-only failure. No ordering expectation was changed and no dependency on the former PostgreSQL NULL placement was established.

The one authorized recovery job rerun completed in run 40154859348 attempt 2, job 121066009688, with the same private-child-final error/cancelled assertion. The selected case passed all three isolated base and candidate runs; the parallel CI failure remains unresolved and is not claimed fixed. The one child-coordination rerun passed in attempt 3, job 121070301089. Its log verifies the old c82 checkout and the exact timeout case passing. GitHub initially refused it while attempt 2 was active, then required the copied current-attempt job ID. No second accepted rerun of either job, and no aggregate-green claim.

Earlier hooks causality result

Direct causality testing resolves the hooks STOP. On the exact PR merge base 882dffc79db3883bd3d6e004cfdeb0c94022b7d8 and the candidate, the same four selected cases ran three times each, alternating revisions on one Testbox with Node 24.22.1, pinned OpenClaw Bun 1.4.4, CI=1, and one worker. Both exact worktrees used frozen installs, identical test and lockfile bytes, and the same environment settings.

Round Base Candidate Base / candidate wall
1 3 pass / 1 fail 3 pass / 1 fail 49 / 49 s
2 4 pass 4 pass 38 / 37 s
3 4 pass 4 pass 37 / 37 s

Both first runs fail hook name cannot forge an extra System: line in queued events with expected [] to not have a length of +0, the same assertion as CI. It passes in both later runs. The other three selected cases pass in every run. This is inherited/flaky under the coordinator’s explicit base-fails decision; the lower-level timing cause is not established. No source or expectation change, and no CI rerun under this decision branch.

Exact command, with OPENCLAW_VITEST_RUNTIME=bun and OPENCLAW_VITEST_MAX_WORKERS=1:

node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-server.config.ts src/gateway/server.hooks.test.ts --testNamePattern 'hook name cannot forge an extra System: line in queued events|enforces templated vs static mapping session keys on /hooks/<mapping>|dispatches agent hooks when the process clock is outside the Date range|requires stable keys for mapped persistent hooks \(missing: false\)' --maxWorkers=1 --reporter=verbose

Earlier manual-run failures retain their recorded attribution: standalone metadata, Windows MXC, and Windows packaging exactly match main run 40149301577. Dependency diagnostics only partially match inspected main logs; the unmatched diagnostics are outside the seven changed owners, while the history-reader unused export matches main. Swift packages has a schema-32 fixture expecting rejection while its owner supports 32; this is outside the patch and has no established main-run match. No aggregate-green claim.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 25, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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: blocked before merge.

What this changes

This PR makes participant, filtered sandbox, and transcript-window readers use the same NULL placement on SQLite and PostgreSQL.

Example: A session has participant z with first_prompted_at=NULL and participant a with first_prompted_at=10.

  • Before: Standalone and cold-patch PostgreSQL reads return a before z, while SQLite returns z before a.
  • After: Both engines return z before a, preserving the existing identity tie breakers.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused repair with meaningful real-engine regression coverage and no discrete defect in the introduced patch; current-main caller integration remains before merge.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored query-only PR is outside the ordinary contributor proof gate; supplied evidence covers real SQLite/PostgreSQL query owners through conformance runs, without claiming a shipped Gateway demonstration.
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 returns unprompted participants, unused sandbox runtimes, and empty transcript windows in different positions from SQLite.
Reason: The maintainer-authored direction establishes parity while preserving SQLite behavior, filters, and tie breakers.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR repairs a concrete PostgreSQL ordering mismatch; its draft integration work remains necessary after the related index-ordering change merged.

Priority: P2
Reviewed head: 9707480263f40e781f3ef4caa9bbdab65cdcec7a

Before merge

  • Resolve merge risk - Before merge, the PR owner must remove the two membership-aggregate native arguments added by fix(postgres): avoid full-table sorts for limited ordered reads #183015; combining those callers with the new three-argument helper otherwise produces TypeScript argument-count errors.
  • Complete the queued repair - Apply the queued review repair and run a fresh exact-head review before merge.

Findings

None.

Agent review details

How this fits together

Session and sandbox query owners translate database rows into ordered participant identities, runtime inventories, and transcript-window history.

flowchart LR
  A[Session and sandbox callers] --> B[Existing query owners]
  B --> C[Kysely ordering and JSON aggregation]
  C --> D[SQLite]
  C --> E[PostgreSQL]
  D --> F[Ordered reader results]
  E --> F
Loading

Technical review

Best possible solution:

Keep the explicit ordering repair in the existing owners and complete the two membership-caller updates when integrating current main.

Do we have a high-confidence way to reproduce the issue?

Current-main SQL leaves nullable ordering implicit, and the supplied real-engine baseline results identify the affected readers; this read-only review did not execute a reproduction.

Is this the best way to solve the issue?

Explicit placement at the existing query and aggregation owners is the smallest complete repair, with distinct regression cases and no additional state or compatibility layer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 478ab60992ab.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the explicit ordering repair in the existing owners and complete the two membership-caller updates when integrating current main.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Provenance checked

  • Ordered JSON and cold-patch participant ordering changes intended behavior with a stated reason (ba1f3b2: Fuse participant reads without changing either engine's existing cold-patch order.)
  • Standalone participant queries changes intended behavior with a stated reason (ef22b23: Reuse single-session queries while preserving identity validation and ordering.)
  • Sandbox registry reads changes intended behavior with a stated reason (2889a99: Move existing reads into the shared read owner while preserving returned records and ordering.)
  • Transcript-window history changes intended behavior with a stated reason (516a142: Relocate existing transcript reads to reduce worker coupling while preserving history behavior; this relocation does not establish the ordering's original introduction.)
  • Actor participant hydration keeps the original intent (d5173cc: Hydrate actor facts through existing storage owners; the outer JSON aggregate already normalizes NULL timestamps first.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/infra/database-engine/nullable-ordering.conformance.test.ts --maxWorkers=1
  • pnpm test src/infra/database-engine/session-entry-write.conformance.test.ts --maxWorkers=1
  • Run the repository PostgreSQL conformance lane for both affected suites on the repaired head.
  • Run targeted session and infra typechecks to verify all jsonOrderedArray callers.
  • git diff --check

What I checked:

PR surface

Source 0, Tests +137. Total +137 across 9 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 9 9 0
Tests 3 141 4 +137
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 150 13 +137

Labels

Label changes:

  • add P2: The repair addresses bounded PostgreSQL reader-order differences without changing SQLite results, storage, or configuration.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The repair addresses bounded PostgreSQL reader-order differences without changing SQLite results, storage, or configuration.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 24, 2026, 10:06 PM ET / October 25, 2026, 02:06 UTC.

@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-25T05:45:49.709280Z c5cdb1b 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.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: c5cdb1b95d31b191d2f2b88d538003c63622f3ad
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/sandbox/registry.kernel.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@steipete
steipete marked this pull request as draft October 25, 2026 03:53
@steipete
steipete marked this pull request as ready for review October 25, 2026 04:42
Match SQLite NULL placement for participant reads, filtered sandbox inventory, and all-window transcript history. Remove the obsolete native ordered-JSON selector while preserving filters and tie breakers.

Regression fixtures fail on PostgreSQL before the fix and pass on both engines afterward. No schema, transaction, or SQLite behavior change.
@steipete
steipete merged commit a05a06d into main Oct 25, 2026
173 of 177 checks passed
@steipete
steipete deleted the pgprep/pgnullparity branch October 25, 2026 07:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Oct 25, 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 #183114.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…openclaw#183114)

* fix(database): align nullable result ordering across engines

Match SQLite NULL placement for participant reads, filtered sandbox inventory, and all-window transcript history. Remove the obsolete native ordered-JSON selector while preserving filters and tie breakers.

Regression fixtures fail on PostgreSQL before the fix and pass on both engines afterward. No schema, transaction, or SQLite behavior change.

* fix(database): preserve index ordering for non-null JSON keys

* test(database): use public transcript history reader
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

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant