Repository navigation
fix(database): preserve session JSON semantics on PostgreSQL - #183560
Conversation
|
🦞👀 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 makes session ownership and transcript queries portable to PostgreSQL while preserving SQLite JSON semantics. Example: Assign agent research as owner of session portable-owner with lifecycle revision owner-revision on PostgreSQL.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR repairs concrete PostgreSQL failures still present on main, and the reviewed diff has no definite introduced defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSession accessors read and update agent databases for ownership, worktree cleanup, transcript navigation, continuation, and replay protection; shared dialect helpers translate their JSON operations into SQLite or PostgreSQL SQL. flowchart TD
A[Session operations] --> B[Existing session accessors]
B --> C[Shared JSON dialect helpers]
C --> D[SQLite or PostgreSQL]
D --> E[Selected JSON facts]
E --> F[Lexical scanner]
F --> G[Session decisions and publications]
Technical reviewBest possible solution: Retain the focused repair in the existing session and dialect owners, preserving exact JSON behavior and normal CI gates. Do we have a high-confidence way to reproduce the issue? Current-main SQL exposes the PostgreSQL failure directly, and the PR records failing real-engine conformance runs; this read-only review executed no target code. Is this the best way to solve the issue? The repair uses existing owners and preserves first-versus-last member semantics through compact projections and the existing scanner, avoiding JSONB duplicate-key loss. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 384100f491d7. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +313, Tests +686. Total +999 across 13 files. Added test files: 2. 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, 8:15 AM ET / 12:15 UTC. |
|
Merged via squash.
|
…w#183560) * fix(database): preserve session JSON semantics on PostgreSQL * fix(database): build JSON table references through Kysely
What Problem This Solves
Fixes PostgreSQL query failures when assigning session owners, reading worktree facts, checking active transcript inputs, rebasing prepared replies, repairing suffix idempotency, and navigating unindexed history.
User Impact
PostgreSQL-readiness preparation with preserved SQLite behavior. No schema, configuration, dependency, retention, transaction, or locking changes.
Why This Change Was Made
These readers still used SQLite-only JSON functions and non-NULL
IScomparisons. Shared JSON dialect helpers now project the consumed fields, preserving first-versus-last duplicate-member behavior, raw revision tokens, malformed/deep JSON handling, and nullable scalar comparisons. The existing lexical scanner gains additive exact duplicate-key metadata. Transcript timestamps use the existing shared greatest helper.Hot transcript reads retain compact native projections. Exceptional JSON that native decoding cannot preserve uses the existing scanner. Cold owner/worktree reads scan original text to preserve validation without constructing unrelated objects.
This is the owner-fix follow-up to #183296. The static portability guard will be a separate follow-up after the separately owned cron repair in #183508 lands; no guard, exemption marker, or baseline change is included here.
Evidence
pnpm test src/infra/database-engine/session-owner-portability.conformance.test.ts --maxWorkers=1: 4 SQLite passed, 4 PostgreSQL skipped in the default single-engine run; 3.23 seconds Vitest / 30.72 seconds wrapper. The explicit two-engine run above executes PostgreSQL.pnpm test src/infra/database-engine/session-transcript-portability.conformance.test.ts --maxWorkers=1: 4 SQLite passed, 4 PostgreSQL skipped by default; 3.17 seconds Vitest / 30.59 seconds wrapper.pnpm test src/state/json-predicate-fields.test.ts --maxWorkers=1: 19 passed, 2.17 seconds Vitest / 4.98 seconds wrapper.Table functions and aliases use Kysely expressions and typed column references in the shared JSON owner; no guard, baseline, or classification was changed. The full Kysely guard passes, and the dialect ratchet improves mechanical occurrences from 4 to 2 (design 22 to 15). Scoped typecheck and lint pass. A fresh isolated Codex P0–P2 review of the correction is clean.
Final-head CI 40191097468 passed: 52 successful jobs, 26 skipped jobs, zero failures. All three PostgreSQL conformance shards executed and passed (1/3: 20m43s; 2/3: 14m58s; 3/3: 16m51s). The single effective
openclaw/ci-gatecheck passed on this head. No manual workflow was dispatched and no CI rerun was needed. The static portability guard remains a separate follow-up after #183508 lands.