Skip to content

fix(postgres): preserve numeric scores in session recall - #202304

Merged
vincentkoc merged 7 commits into
mainfrom
test-postgres-recall-authorization-20261120
Nov 20, 2026
Merged

vincentkoc merged 7 commits into
mainfrom
test-postgres-recall-authorization-20261120

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

PostgreSQL substring searches could return a text-valued zero score. The session-search tool correctly requires numeric scores, so it silently discarded matching CJK results.

User Impact

Restores CJK substring matches in session recall while preserving permission filtering, numeric result contracts, and result limits. No SQLite schema-version, DDL, migration, persisted-format, configuration, or public-API changes.

Why This Change Was Made

The fallback query now selects a numeric SQL literal. The tool and database driver retain their existing validation and decoding behavior.

The PostgreSQL product suite also covers real asynchronous authorization with 27 denied matches before two allowed hits, ordered results and truncation, the unscoped tool, physical global ownership, shared-store underscore namespaces, and child visibility. Each case owns its state and registry and disposes readers before cleanup.

Evidence

The published candidate is 7aa35a2bc19d31b56a7680cab5b081c6443439c0; exact-head CI passed all 28 executed jobs, including all four PostgreSQL conformance shards and the CI gate. Path-gated jobs were skipped by the plan.

  • Real PostgreSQL 16 diagnostics reproduced the text score, exposed by the unscoped tool assertion.
  • The fixture now reapplies its environment after Vitest resets it and isolates canonical session keys between cases.
  • Direct score checks cover relevance/recent ordering and exact/prefix matching.
  • Current candidate: 7aa35a2bc19d31b56a7680cab5b081c6443439c0.
  • Production: +2/-1 lines; tests: +313/-12 lines. Formatting and git diff --check pass.
  • PostgreSQL 16.15: all 8 product cases passed with no skips; pgvector 0.8.7, unaccent 1.1, and pg_trgm 1.6. The catalog/trigger preflight passed, final user-schema and other-connection counts were zero, and the isolated container was removed.
  • Independent source/result review and fresh structured review passed with no actionable findings.
  • SQLite sibling tests: 42/42 passed in 3 files, with no skips. The same head also passed all 8 product cases in hosted PostgreSQL 17 CI, with no target skips; all four hosted PostgreSQL containers were removed.
  • Current-main merge CI also passed all 31 executed jobs on merge source 0432ca0f49069428f0acd1fa474e79c83764ce2f: product 8/8 and admission 8/8 on PostgreSQL 17, plus pinned PostgreSQL 16 Gateway cron smoke 4/4. Path-gated jobs were skipped; the product and smoke cases were not skipped.
  • The original failed dependency check was inherited from unchanged Discord exports. The baseline refresh includes their canonical repair in #202297.

Review Scope and Limits

The exact-head ClawSweeper review found no actionable code findings. Its optional rank-up request for a deployed Gateway/agent capture is deferred: this change has real PostgreSQL proof through the production tool, handler, authorization owner, and worker, with an injected in-process transport. It does not claim a deployed Gateway or external transport test. No additional deployment surface is introduced by the numeric SQL projection fix.

The earlier candidate CI job failed the new cases before the fixture and producer repairs. The subsequent PostgreSQL 16 diagnostic at 186d returned the matching CJK hit with score: "0"; the real tool returned no matching result. The repaired candidate returns numeric score: 0 and retains both expected hits through that same tool path. This was a diagnostic of the broken producer, not a claim that the final suite passed on an unchanged base.

@vincentkoc vincentkoc self-assigned this Nov 20, 2026
@clawsweeper

clawsweeper Bot commented Nov 20, 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.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Nov 20, 2026
@clawsweeper

clawsweeper Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes substring-search scores numeric and extends PostgreSQL recall coverage for visibility, ordering, and result limits.

Example: Search for 会 in a visible transcript containing 明天下午开会讨论.

  • Before: PostgreSQL can return score "0", causing sessions_search to discard the matching result.
  • After: The query returns numeric score 0, allowing sessions_search to retain the match.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and source-correct, with useful real-database regression coverage, but the required shipped-entry-point evidence is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Session recall silently omits matching CJK text when PostgreSQL supplies a text-valued fallback score.
Reason: This restores documented substring recall through the existing owner, and the maintainer-authored direction requires no additional product decision.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR fixes a concrete PostgreSQL recall defect still present on main; no actionable patch defect was found.

Priority: P2
Reviewed head: 7aa35a2bc19d31b56a7680cab5b081c6443439c0

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted output from an isolated shipped Gateway and agent showing sessions_search returning the interior 会 match after the fix; the claimed base-failing regression output is also not supplied.
Agent review details

How this fits together

The transcript worker queries indexed session text, passes candidates through Gateway visibility filtering, and returns scored hits consumed by sessions_search.

flowchart LR
  A[Session search tool] --> B[Gateway search handler]
  B --> C[Transcript worker]
  C --> D[PostgreSQL transcript index]
  D --> C
  C --> E[Visibility filtering]
  E --> F[Numeric scored results]
  F --> A
Loading

Technical review

Best possible solution:

Keep the numeric literal in the existing query owner while preserving driver decoding, tool validation, visibility filtering, and persisted indexes.

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

Source establishes the untyped fallback score, unchanged PostgreSQL decoding, and numeric-only tool filter; the author reports reproducing the text score, but this review executed no target code.

Is this the best way to solve the issue?

The smallest complete fix changes the SQL producer to return numeric zero; coercing scores in the driver or weakening tool validation would broaden the change unnecessarily.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Substring fallback score keeps the original intent (8eb11ec: Find interior CJK text after word-search misses without changing persisted tokenizers; the later worker extraction carried the bound zero forward.)
  • PostgreSQL product-flow fixture keeps the original intent (3ccddbd: Exercise real transcript writes, searches, lifecycle operations, and public tool consumption against PostgreSQL.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +1, Tests +301. Total +302 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 313 12 +301
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 315 13 +302

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test changes Production +2/-1; tests +313/-12 Production remains a single producer correction; test growth covers numeric-score propagation and distinct authorization, physical-store, namespace, and child-visibility boundaries.

Labels

Label changes:

  • add P2: Matching CJK transcripts are silently omitted from PostgreSQL recall, with a limited database-specific blast radius.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • remove P3: Current review triage priority is P2, so this older priority label is no longer current.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P2: Matching CJK transcripts are silently omitted from PostgreSQL recall, with a limited database-specific blast radius.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide the production recall capture described in the proof assessment.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-20T06:44:43.793Z sha efab8b2 :: needs maintainer review before merge. :: none

Reviewed November 20, 2026, 3:03 AM ET / 08:03 UTC (Revision 2).

@vincentkoc vincentkoc changed the title chore(postgres): verify recall permissions and result limits fix(postgres): preserve numeric scores in session recall Nov 20, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 7aa35a2bc19d31b56a7680cab5b081c6443439c0. The prepared correction fixes text-valued PostgreSQL substring scores at the SQL producer and isolates each test fixture's state/registry; no schema/version/DDL/migration/config/public API changes.

All 8 real PostgreSQL 16 product cases and 42 SQLite sibling tests pass. Independent source/result review and fresh structured review are clean. The earlier dependency failure came from unchanged Discord exports and is addressed by the canonical baseline repair #202297. Exact-head CI is still running: https://github.com/openclaw/openclaw/actions/runs/44698574297 . The PR body contains the current proof and remaining gate.

@clawsweeper

clawsweeper Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Nov 20, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 20, 2026 08:27
@vincentkoc
vincentkoc merged commit 04d1dd1 into main Nov 20, 2026
303 of 304 checks passed
@vincentkoc
vincentkoc deleted the test-postgres-recall-authorization-20261120 branch November 20, 2026 09:03
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 21, 2026
…2304)

* test(postgres): cover recall authorization and paging

* fix: refresh the reviewed correction baseline

Baseline-Refresh: ca9e7c36d7cfb71430b03378577e9a6e16e0317c

* test(postgres): trace recall readiness and physical owners

* test(postgres): preserve cold recall diagnostic order

* test(postgres): trace recall target and admission failures

* fix(postgres): preserve numeric scores for substring recall

* test(postgres): isolate recall fixture state per case

Co-authored-by: Vincent Koc <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
* test(postgres): cover recall authorization and paging

* fix: refresh the reviewed correction baseline

Baseline-Refresh: ca9e7c36d7cfb71430b03378577e9a6e16e0317c

* test(postgres): trace recall readiness and physical owners

* test(postgres): preserve cold recall diagnostic order

* test(postgres): trace recall target and admission failures

* fix(postgres): preserve numeric scores for substring recall

* test(postgres): isolate recall fixture state per case

Co-authored-by: Vincent Koc <[email protected]>
(cherry picked from commit 04d1dd1)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit faa8c043085a2156c345af810f8426a2db212e41)
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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M 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